aboutsummaryrefslogtreecommitdiff
path: root/clang/test/CodeGen/ubsan-ignorelist.c
blob: 409cb18a3179dc8bc835842105d84ce7c9a8eb10 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
// Verify ubsan doesn't emit checks for ignorelisted functions and files
// RUN: echo "fun:hash" > %t-func.ignorelist
// RUN: echo "src:%s" | sed -e 's/\\/\\\\/g' > %t-file.ignorelist
// RUN: %clang_cc1 -fsanitize=unsigned-integer-overflow -emit-llvm %s -o - | FileCheck %s --check-prefix=DEFAULT
// RUN: %clang_cc1 -fsanitize=unsigned-integer-overflow -fsanitize-ignorelist=%t-func.ignorelist -emit-llvm %s -o - | FileCheck %s --check-prefix=FUNC
// RUN: %clang_cc1 -fsanitize=unsigned-integer-overflow -fsanitize-ignorelist=%t-file.ignorelist -emit-llvm %s -o - | FileCheck %s --check-prefix=FILE

unsigned i;

// DEFAULT: @hash
// FUNC: @hash
// FILE: @hash
unsigned hash(void) {
// DEFAULT: call {{.*}}void @__ubsan
// FUNC-NOT: call {{.*}}void @__ubsan
// FILE-NOT: call {{.*}}void @__ubsan
  return i * 37;
}

// DEFAULT: @add
// FUNC: @add
// FILE: @add
unsigned add(void) {
// DEFAULT: call {{.*}}void @__ubsan
// FUNC: call {{.*}}void @__ubsan
// FILE-NOT: call {{.*}}void @__ubsan
  return i + 1;
}