summaryrefslogtreecommitdiff
path: root/test/CodeGen/ubsan-blacklist.c
diff options
context:
space:
mode:
Diffstat (limited to 'test/CodeGen/ubsan-blacklist.c')
-rw-r--r--test/CodeGen/ubsan-blacklist.c31
1 files changed, 31 insertions, 0 deletions
diff --git a/test/CodeGen/ubsan-blacklist.c b/test/CodeGen/ubsan-blacklist.c
new file mode 100644
index 000000000000..6c67f027e922
--- /dev/null
+++ b/test/CodeGen/ubsan-blacklist.c
@@ -0,0 +1,31 @@
+// Verify ubsan doesn't emit checks for blacklisted functions and files
+// RUN: echo "fun:hash" > %t-func.blacklist
+// RUN: echo "src:%s" > %t-file.blacklist
+// RUN: %clang_cc1 -fsanitize=unsigned-integer-overflow -emit-llvm %s -o - | FileCheck %s --check-prefix=DEFAULT
+// RUN: %clang_cc1 -fsanitize=unsigned-integer-overflow -fsanitize-blacklist=%t-func.blacklist -emit-llvm %s -o - | FileCheck %s --check-prefix=FUNC
+// RUN: %clang_cc1 -fsanitize=unsigned-integer-overflow -fsanitize-blacklist=%t-file.blacklist -emit-llvm %s -o - | FileCheck %s --check-prefix=FILE
+
+// FIXME: %t-file.blacklist contains DOSish paths.
+// REQUIRES: shell
+
+unsigned i;
+
+// DEFAULT: @hash
+// FUNC: @hash
+// FILE: @hash
+unsigned hash() {
+// 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() {
+// DEFAULT: call void @__ubsan
+// FUNC: call void @__ubsan
+// FILE-NOT: call void @__ubsan
+ return i + 1;
+}