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 4 // 5 // REQUIRES: x86_64-target-arch 6 7 #include <sanitizer/dfsan_interface.h> 8 #include <assert.h> 9 #include <stdlib.h> 10 11 int global; 12 main()13int main() { 14 int local; 15 int *heap = (int*)malloc(sizeof(int)); 16 17 dfsan_set_label(10, &global, sizeof(global)); 18 dfsan_set_label(20, &local, sizeof(local)); 19 dfsan_set_label(30, heap, sizeof(*heap)); 20 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)); 28 #endif 29 30 dfsan_flush(); 31 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); 38 39 free(heap); 40 } 41