Skip to content

Commit dd04cac

Browse files
committed
[𝘀𝗽𝗿] changes to main this commit is based on
Created using spr 1.3.6 [skip ci]
1 parent 2a3afa2 commit dd04cac

File tree

3 files changed

+122
-2
lines changed

3 files changed

+122
-2
lines changed

clang/lib/Basic/NoSanitizeList.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ bool NoSanitizeList::containsPrefix(SanitizerMask Mask, StringRef Prefix,
4444

4545
bool NoSanitizeList::containsGlobal(SanitizerMask Mask, StringRef GlobalName,
4646
StringRef Category) const {
47-
return SSCL->inSection(Mask, "global", GlobalName, Category);
47+
return containsPrefix(Mask, "global", GlobalName, Category);
4848
}
4949

5050
bool NoSanitizeList::containsType(SanitizerMask Mask, StringRef MangledTypeName,
@@ -54,7 +54,7 @@ bool NoSanitizeList::containsType(SanitizerMask Mask, StringRef MangledTypeName,
5454

5555
bool NoSanitizeList::containsFunction(SanitizerMask Mask,
5656
StringRef FunctionName) const {
57-
return SSCL->inSection(Mask, "fun", FunctionName);
57+
return containsPrefix(Mask, "fun", FunctionName, {});
5858
}
5959

6060
bool NoSanitizeList::containsFile(SanitizerMask Mask, StringRef FileName,
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
// RUN: rm -rf %t
2+
// RUN: split-file %s %t
3+
4+
// RUN: %clang -target x86_64-unknown-linux-gnu -S -emit-llvm -fsanitize=address %t/test.c -o - | FileCheck %s --check-prefixes=SANITIZE
5+
6+
// RUN: %clang -target x86_64-unknown-linux-gnu -S -emit-llvm -fsanitize=address -fsanitize-ignorelist=%t/order-0.ignorelist %t/test.c -o - | FileCheck %s --check-prefixes=IGNORE
7+
// RUN: %clang -target x86_64-unknown-linux-gnu -S -emit-llvm -fsanitize=address -fsanitize-ignorelist=%t/order-1.ignorelist %t/test.c -o - | FileCheck %s --check-prefixes=SANITIZE
8+
// RUN: %clang -target x86_64-unknown-linux-gnu -S -emit-llvm -fsanitize=address -fsanitize-ignorelist=%t/order-2.ignorelist %t/test.c -o - | FileCheck %s --check-prefixes=IGNORE
9+
// RUN: %clang -target x86_64-unknown-linux-gnu -S -emit-llvm -fsanitize=address -fsanitize-ignorelist=%t/order-3.ignorelist %t/test.c -o - | FileCheck %s --check-prefixes=SANITIZE
10+
11+
// The same type can appear multiple times within an ignorelist. Any ``=sanitize`` type
12+
// entries enable sanitizer instrumentation, even if it was ignored by entries before.
13+
// If multiple entries match the source, then the latest entry takes the
14+
// precedence.
15+
16+
//--- order-0.ignorelist
17+
global:global_array
18+
19+
//--- order-1.ignorelist
20+
global:global_array
21+
global:global_array=sanitize
22+
23+
//--- order-2.ignorelist
24+
global:*
25+
global:global_array=sanitize
26+
global:global_array
27+
28+
//--- order-3.ignorelist
29+
global:*
30+
global:global_array=sanitize
31+
global:global*
32+
global:*array=sanitize
33+
34+
//--- test.c
35+
// SANITIZE: @global_array ={{.*}} global {{.*}}, comdat, align {{.*}}
36+
// IGNORE: @global_array ={{.*}} global {{.*}}, no_sanitize_address, align {{.*}}
37+
unsigned global_array[100] = {-1};
Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
// RUN: rm -rf %t
2+
// RUN: split-file %s %t
3+
4+
// RUN: %clang_cc1 -triple x86_64-linux-gnu -fsanitize=signed-integer-overflow,unsigned-integer-overflow -fsanitize-ignorelist=%t/order-0.ignorelist -emit-llvm %t/test.c -o - | FileCheck %s --check-prefixes=CHECK,SANITIZE
5+
// RUN: %clang_cc1 -triple x86_64-linux-gnu -fsanitize=signed-integer-overflow,unsigned-integer-overflow -fsanitize-ignorelist=%t/order-1.ignorelist -emit-llvm %t/test.c -o - | FileCheck %s --check-prefixes=CHECK,IGNORE
6+
// RUN: %clang_cc1 -triple x86_64-linux-gnu -fsanitize=signed-integer-overflow,unsigned-integer-overflow -fsanitize-ignorelist=%t/order-2.ignorelist -emit-llvm %t/test.c -o - | FileCheck %s --check-prefixes=CHECK,SANITIZE
7+
// RUN: %clang_cc1 -triple x86_64-linux-gnu -fsanitize=signed-integer-overflow,unsigned-integer-overflow -fsanitize-ignorelist=%t/order-3.ignorelist -emit-llvm %t/test.c -o - | FileCheck %s --check-prefixes=CHECK,IGNORE
8+
// RUN: %clang_cc1 -triple x86_64-linux-gnu -fsanitize=signed-integer-overflow,unsigned-integer-overflow -fsanitize-ignorelist=%t/order-4.ignorelist -emit-llvm %t/test.c -o - | FileCheck %s --check-prefixes=CHECK,SANITIZE
9+
// RUN: %clang_cc1 -triple x86_64-linux-gnu -fsanitize=signed-integer-overflow,unsigned-integer-overflow -fsanitize-ignorelist=%t/order-5.ignorelist -emit-llvm %t/test.c -o - | FileCheck %s --check-prefixes=CHECK,IGNORE
10+
// RUN: %clang_cc1 -triple x86_64-linux-gnu -fsanitize=signed-integer-overflow,unsigned-integer-overflow -fsanitize-ignorelist=%t/order-6.ignorelist -emit-llvm %t/test.c -o - | FileCheck %s --check-prefixes=CHECK,SANITIZE
11+
// RUN: %clang_cc1 -triple x86_64-linux-gnu -fsanitize=signed-integer-overflow,unsigned-integer-overflow -fsanitize-ignorelist=%t/order-7.ignorelist -emit-llvm %t/test.c -o - | FileCheck %s --check-prefixes=CHECK,IGNORE
12+
// RUN: %clang_cc1 -triple x86_64-linux-gnu -fsanitize=signed-integer-overflow,unsigned-integer-overflow -fsanitize-ignorelist=%t/order-8.ignorelist -emit-llvm %t/test.c -o - | FileCheck %s --check-prefixes=CHECK,SANITIZE
13+
14+
15+
// The same type can appear multiple times within an ignorelist. Any ``=sanitize`` type
16+
// entries enable sanitizer instrumentation, even if it was ignored by entries before.
17+
// If multiple entries match the source, then the latest entry takes the
18+
// precedence.
19+
20+
21+
//--- order-0.ignorelist
22+
fun:add
23+
fun:add=sanitize
24+
25+
//--- order-1.ignorelist
26+
fun:add=sanitize
27+
fun:add
28+
29+
//--- order-2.ignorelist
30+
fun:ad*
31+
fun:add=sanitize
32+
33+
//--- order-3.ignorelist
34+
fun:ad*=sanitize
35+
fun:add
36+
37+
//--- order-4.ignorelist
38+
fun:add
39+
fun:ad*=sanitize
40+
41+
//--- order-5.ignorelist
42+
fun:add=sanitize
43+
fun:ad*
44+
45+
//--- order-6.ignorelist
46+
fun:add
47+
fun:add=sanitize
48+
fun:a*d
49+
fun:*dd=sanitize
50+
51+
//--- order-7.ignorelist
52+
[{unsigned-integer-overflow,signed-integer-overflow}]
53+
fun:*
54+
fun:add=sanitize
55+
fun:a*d
56+
fun:*dd=sanitize
57+
[{unsigned-integer-overflow,signed-integer-overflow}]
58+
fun:*
59+
fun:add
60+
fun:a*d=sanitize
61+
fun:*d
62+
63+
//--- order-8.ignorelist
64+
[{unsigned-integer-overflow,signed-integer-overflow}]
65+
fun:*
66+
fun:add
67+
fun:a*d=sanitize
68+
fun:*dd
69+
[{unsigned-integer-overflow,signed-integer-overflow}]
70+
fun:*
71+
fun:add=sanitize
72+
fun:a*d
73+
fun:*dd=sanitize
74+
75+
76+
//--- test.c
77+
// CHECK-LABEL: define dso_local void @add
78+
void add(int A) {
79+
// IGNORE: %inc = add nsw
80+
// SANITIZE: @llvm.sadd.with.overflow.i32
81+
++A;
82+
}
83+

0 commit comments

Comments
 (0)