Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 37 additions & 0 deletions clang/test/CodeGen/ubsan-src-ignorelist-category.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
// RUN: rm -rf %t
// RUN: split-file %s %t
// RUN: %clang_cc1 -triple x86_64-linux-gnu -fsanitize=signed-integer-overflow -fsanitize-ignorelist=%t/src.ignorelist -emit-llvm %t/test1.c -o - | FileCheck %s -check-prefix=CHECK-ALLOWLIST
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's not going to hurt to test all 2 files for 3 cases

// RUN: %clang_cc1 -triple x86_64-linux-gnu -fsanitize=signed-integer-overflow -fsanitize-ignorelist=%t/src.ignorelist -emit-llvm %t/test2.c -o - | FileCheck %s -check-prefix=CHECK-IGNORELIST
// RUN: %clang_cc1 -triple x86_64-linux-gnu -fsanitize=signed-integer-overflow -fsanitize-ignorelist=%t/src.ignorelist.contradict1 -emit-llvm %t/test1.c -o - | FileCheck %s -check-prefix=CHECK-ALLOWLISTOVERIDE1
// RUN: %clang_cc1 -triple x86_64-linux-gnu -fsanitize=signed-integer-overflow -fsanitize-ignorelist=%t/src.ignorelist.contradict2 -emit-llvm %t/test1.c -o - | FileCheck %s -check-prefix=CHECK-ALLOWLISTOVERIDE2


// Verify ubsan only emits checks for files in the allowlist

//--- src.ignorelist
src:*
src:*/test1.c=sanitize

//--- src.ignorelist.contradict1
src:*
src:*/test1.c=sanitize
src:*/test1.c

//--- src.ignorelist.contradict2
src:*
src:*/test1.c
src:*/test1.c=sanitize

//--- test1.c
int add1(int a, int b) {
// CHECK-ALLOWLIST: llvm.sadd.with.overflow.i32
// CHECK-ALLOWLISTOVERIDE1-NOT: llvm.sadd.with.overflow.i32
// CHECK-ALLOWLISTOVERIDE2: llvm.sadd.with.overflow.i32
return a+b;
}

//--- test2.c
int add2(int a, int b) {
// CHECK-IGNORELIST-NOT: llvm.sadd.with.overflow.i32
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use --implicit-check-not= when possible instead of not -NOT

-NOT is order dependent, it's easy to break code, but -NOT will be satisfied.

In this case you are looking at exact expression in the code, so we rather check precisely instead of NOT

return a+b;
}
Loading