xref: /aosp_15_r20/external/compiler-rt/test/dfsan/flags.c (revision 7c3d14c8b49c529e04be81a3ce6f5cc23712e4c6)
1*7c3d14c8STreehugger Robot // RUN: %clang_dfsan %s -fsanitize-blacklist=%S/Inputs/flags_abilist.txt -mllvm -dfsan-debug-nonzero-labels -o %t && %run %t 2>&1 | FileCheck %s
2*7c3d14c8STreehugger Robot // RUN: %clang_dfsan %s -fsanitize-blacklist=%S/Inputs/flags_abilist.txt -mllvm -dfsan-debug-nonzero-labels -o %t && DFSAN_OPTIONS=warn_unimplemented=0 %run %t 2>&1 | count 0
3*7c3d14c8STreehugger Robot // RUN: %clang_dfsan %s -fsanitize-blacklist=%S/Inputs/flags_abilist.txt -mllvm -dfsan-debug-nonzero-labels -o %t && DFSAN_OPTIONS=warn_nonzero_labels=1 %run %t 2>&1 | FileCheck --check-prefix=CHECK-NONZERO %s
4*7c3d14c8STreehugger Robot 
5*7c3d14c8STreehugger Robot // Tests that flags work correctly.
6*7c3d14c8STreehugger Robot 
7*7c3d14c8STreehugger Robot #include <sanitizer/dfsan_interface.h>
8*7c3d14c8STreehugger Robot 
f(int i)9*7c3d14c8STreehugger Robot int f(int i) {
10*7c3d14c8STreehugger Robot   return i;
11*7c3d14c8STreehugger Robot }
12*7c3d14c8STreehugger Robot 
main(void)13*7c3d14c8STreehugger Robot int main(void) {
14*7c3d14c8STreehugger Robot   int i = 1;
15*7c3d14c8STreehugger Robot   dfsan_label i_label = dfsan_create_label("i", 0);
16*7c3d14c8STreehugger Robot   dfsan_set_label(i_label, &i, sizeof(i));
17*7c3d14c8STreehugger Robot 
18*7c3d14c8STreehugger Robot   // CHECK: WARNING: DataFlowSanitizer: call to uninstrumented function f
19*7c3d14c8STreehugger Robot   // CHECK-NOT: WARNING: DataFlowSanitizer: saw nonzero label
20*7c3d14c8STreehugger Robot   // CHECK-NONZERO: WARNING: DataFlowSanitizer: saw nonzero label
21*7c3d14c8STreehugger Robot   f(i);
22*7c3d14c8STreehugger Robot 
23*7c3d14c8STreehugger Robot   return 0;
24*7c3d14c8STreehugger Robot }
25