Home | History | Annotate | Download | only in dfsan
      1 // RUN: %clang_dfsan %s -o %t && %run %t
      2 // RUN: %clang_dfsan -mllvm -dfsan-args-abi %s -o %t && %run %t
      3 
      4 // Tests that labels are propagated through loads and stores.
      5 
      6 #include <sanitizer/dfsan_interface.h>
      7 #include <assert.h>
      8 
      9 int main(void) {
     10   int i = 1;
     11   dfsan_label i_label = dfsan_create_label("i", 0);
     12   dfsan_set_label(i_label, &i, sizeof(i));
     13 
     14   dfsan_label new_label = dfsan_get_label(i);
     15   assert(i_label == new_label);
     16 
     17   dfsan_label read_label = dfsan_read_label(&i, sizeof(i));
     18   assert(i_label == read_label);
     19 
     20   dfsan_label j_label = dfsan_create_label("j", 0);
     21   dfsan_add_label(j_label, &i, sizeof(i));
     22 
     23   read_label = dfsan_read_label(&i, sizeof(i));
     24   assert(dfsan_has_label(read_label, i_label));
     25   assert(dfsan_has_label(read_label, j_label));
     26 
     27   return 0;
     28 }
     29