[docs] Fix build-docs.sh
[llvm-project.git] / compiler-rt / test / dfsan / basic.c
blob783b33dfaa4115285a2624c99b16be97b66961b8
1 // RUN: %clang_dfsan %s -o %t && %run %t
2 //
3 // REQUIRES: x86_64-target-arch
5 // Tests that labels are propagated through loads and stores.
7 #include <sanitizer/dfsan_interface.h>
8 #include <assert.h>
10 int main(void) {
11 int i = 1;
12 dfsan_label i_label = 1;
13 dfsan_set_label(i_label, &i, sizeof(i));
15 dfsan_label new_label = dfsan_get_label(i);
16 assert(i_label == new_label);
18 dfsan_label read_label = dfsan_read_label(&i, sizeof(i));
19 assert(i_label == read_label);
21 dfsan_label j_label = 2;
22 dfsan_add_label(j_label, &i, sizeof(i));
24 read_label = dfsan_read_label(&i, sizeof(i));
25 assert(dfsan_has_label(read_label, i_label));
26 assert(dfsan_has_label(read_label, j_label));
28 return 0;