aboutsummaryrefslogtreecommitdiff
path: root/test/dfsan/flags.c
blob: 914f54f42b6cd2e241123add8e14eb24568867cb (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
// RUN: %clang_dfsan %s -fsanitize-blacklist=%S/Inputs/flags_abilist.txt -mllvm -dfsan-debug-nonzero-labels -o %t && %run %t 2>&1 | FileCheck %s
// 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
// 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

// Tests that flags work correctly.

#include <sanitizer/dfsan_interface.h>

int f(int i) {
  return i;
}

int main(void) {
  int i = 1;
  dfsan_label i_label = dfsan_create_label("i", 0);
  dfsan_set_label(i_label, &i, sizeof(i));

  // CHECK: WARNING: DataFlowSanitizer: call to uninstrumented function f
  // CHECK-NOT: WARNING: DataFlowSanitizer: saw nonzero label
  // CHECK-NONZERO: WARNING: DataFlowSanitizer: saw nonzero label
  f(i);

  return 0;
}