xref: /llvm-project/clang/test/CodeGen/ubsan-ignorelist.c (revision 46b0d0eef9e0a7290851cce0d44002b750584f1b)
1 // Verify ubsan doesn't emit checks for ignorelisted functions and files
2 // RUN: echo "fun:hash" > %t-func.ignorelist
3 // RUN: echo "src:%s" | sed -e 's/\\/\\\\/g' > %t-file.ignorelist
4 // RUN: %clang_cc1 -fsanitize=unsigned-integer-overflow -emit-llvm %s -o - | FileCheck %s --check-prefix=DEFAULT
5 // RUN: %clang_cc1 -fsanitize=unsigned-integer-overflow -fsanitize-ignorelist=%t-func.ignorelist -emit-llvm %s -o - | FileCheck %s --check-prefix=FUNC
6 // RUN: %clang_cc1 -fsanitize=unsigned-integer-overflow -fsanitize-ignorelist=%t-file.ignorelist -emit-llvm %s -o - | FileCheck %s --check-prefix=FILE
7 
8 unsigned i;
9 
10 // DEFAULT: @hash
11 // FUNC: @hash
12 // FILE: @hash
hash(void)13 unsigned hash(void) {
14 // DEFAULT: call {{.*}}void @__ubsan
15 // FUNC-NOT: call {{.*}}void @__ubsan
16 // FILE-NOT: call {{.*}}void @__ubsan
17   return i * 37;
18 }
19 
20 // DEFAULT: @add
21 // FUNC: @add
22 // FILE: @add
add(void)23 unsigned add(void) {
24 // DEFAULT: call {{.*}}void @__ubsan
25 // FUNC: call {{.*}}void @__ubsan
26 // FILE-NOT: call {{.*}}void @__ubsan
27   return i + 1;
28 }
29