1 // Tests dfsan_flush().
2 // RUN: %clang_dfsan %s -o %t && %run %t
3 // RUN: %clang_dfsan -DORIGIN_TRACKING -mllvm -dfsan-track-origins=1 %s -o %t && %run %t
5 // REQUIRES: x86_64-target-arch
7 #include <sanitizer/dfsan_interface.h>
15 int *heap
= (int*)malloc(sizeof(int));
17 dfsan_set_label(10, &global
, sizeof(global
));
18 dfsan_set_label(20, &local
, sizeof(local
));
19 dfsan_set_label(30, heap
, sizeof(*heap
));
21 assert(dfsan_get_label(global
) == 10);
22 assert(dfsan_get_label(local
) == 20);
23 assert(dfsan_get_label(*heap
) == 30);
24 #ifdef ORIGIN_TRACKING
25 assert(dfsan_get_origin(global
));
26 assert(dfsan_get_origin(local
));
27 assert(dfsan_get_origin(*heap
));
32 assert(dfsan_get_label(global
) == 0);
33 assert(dfsan_get_label(local
) == 0);
34 assert(dfsan_get_label(*heap
) == 0);
35 assert(dfsan_get_origin(global
) == 0);
36 assert(dfsan_get_origin(local
) == 0);
37 assert(dfsan_get_origin(*heap
) == 0);