[docs] Fix build-docs.sh
[llvm-project.git] / compiler-rt / test / dfsan / gep.c
blobd3f507ffd9a6b06ecc28adfdb1b72ab9c5f9c4b8
1 // RUN: %clang_dfsan %s -mllvm -dfsan-combine-offset-labels-on-gep=false -Wno-error=int-conversion -o %t && %run %t
2 // RUN: %clang_dfsan %s -DPROP_OFFSET_LABELS -Wno-error=int-conversion -o %t && %run %t
3 //
4 // REQUIRES: x86_64-target-arch
6 // Tests that labels are propagated through GEP.
8 #include <sanitizer/dfsan_interface.h>
9 #include <assert.h>
11 int main(void) {
12 int i = 1;
13 int *p = &i;
14 int j = 2;
15 // test that pointer arithmetic propagates labels in terms of the flag.
16 dfsan_set_label(1, &i, sizeof(i));
17 p += i;
18 #ifdef PROP_OFFSET_LABELS
19 assert(dfsan_get_label(p) == 1);
20 #else
21 assert(dfsan_get_label(p) == 0);
22 #endif
23 // test that non-pointer operations always propagate labels.
24 dfsan_set_label(2, &j, sizeof(j));
25 j += i;
26 assert(dfsan_get_label(j) == 3);
27 return 0;