brintos

brintos / llvm-project-archived public Read only

0
0
Text · 762 B · 973b423 Raw
27 lines · c
1// RUN: %clang_dfsan %s -mllvm -dfsan-combine-offset-labels-on-gep=false -Wno-error=int-conversion -o %t && %run %t2// RUN: %clang_dfsan %s -DPROP_OFFSET_LABELS -Wno-error=int-conversion -o %t && %run %t3 4// Tests that labels are propagated through GEP.5 6#include <sanitizer/dfsan_interface.h>7#include <assert.h>8 9int main(void) {10  int i = 1;11  int *p = &i;12  int j = 2;13  // test that pointer arithmetic propagates labels in terms of the flag.14  dfsan_set_label(1, &i, sizeof(i));15  p += i;16#ifdef PROP_OFFSET_LABELS17  assert(dfsan_get_label(p) == 1);18#else19  assert(dfsan_get_label(p) == 0);20#endif21  // test that non-pointer operations always propagate labels.22  dfsan_set_label(2, &j, sizeof(j));23  j += i;24  assert(dfsan_get_label(j) == 3);25  return 0;26}27