1 // Verify ubsan doesn't emit checks for blacklisted functions and files
2 // RUN: echo "fun:hash" > %t-func.blacklist
3 // RUN: echo "src:%s" | sed -e 's/\\/\\\\/g' > %t-file.blacklist
4 
5 // RUN: rm -f %t-vfsoverlay.yaml
6 // RUN: rm -f %t-nonexistent.blacklist
7 // RUN: sed -e "s|@DIR@|%/T|g" %S/Inputs/sanitizer-blacklist-vfsoverlay.yaml | sed -e "s|@REAL_FILE@|%/t-func.blacklist|g" | sed -e "s|@NONEXISTENT_FILE@|%/t-nonexistent.blacklist|g" > %t-vfsoverlay.yaml
8 // RUN: %clang_cc1 -fsanitize=unsigned-integer-overflow -ivfsoverlay %t-vfsoverlay.yaml -fsanitize-blacklist=%/T/only-virtual-file.blacklist -emit-llvm %s -o - | FileCheck %s --check-prefix=FUNC
9 
10 // RUN: not %clang_cc1 -fsanitize=unsigned-integer-overflow -ivfsoverlay %t-vfsoverlay.yaml -fsanitize-blacklist=%/T/invalid-virtual-file.blacklist -emit-llvm %s -o - 2>&1 | FileCheck %s --check-prefix=INVALID-MAPPED-FILE
11 // INVALID-MAPPED-FILE: invalid-virtual-file.blacklist': {{[Nn]}}o such file or directory
12 
13 // RUN: not %clang_cc1 -fsanitize=unsigned-integer-overflow -ivfsoverlay %t-vfsoverlay.yaml -fsanitize-blacklist=%t-nonexistent.blacklist -emit-llvm %s -o - 2>&1 | FileCheck %s --check-prefix=INVALID
14 // INVALID: nonexistent.blacklist': {{[Nn]}}o such file or directory
15 
16 unsigned i;
17 
18 // DEFAULT: @hash
19 // FUNC: @hash
20 // FILE: @hash
hash()21 unsigned hash() {
22 // DEFAULT: call {{.*}}void @__ubsan
23 // FUNC-NOT: call {{.*}}void @__ubsan
24 // FILE-NOT: call {{.*}}void @__ubsan
25   return i * 37;
26 }
27 
28 // DEFAULT: @add
29 // FUNC: @add
30 // FILE: @add
add()31 unsigned add() {
32 // DEFAULT: call {{.*}}void @__ubsan
33 // FUNC: call {{.*}}void @__ubsan
34 // FILE-NOT: call {{.*}}void @__ubsan
35   return i + 1;
36 }
37