Skip to content

Commit f8888ab

Browse files
committed
[𝘀𝗽𝗿] initial version
Created using spr 1.3.6
2 parents 2a3afa2 + dd04cac commit f8888ab

File tree

4 files changed

+139
-8
lines changed

4 files changed

+139
-8
lines changed

clang/lib/Basic/NoSanitizeList.cpp

Lines changed: 3 additions & 3 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,
@@ -64,7 +64,7 @@ bool NoSanitizeList::containsFile(SanitizerMask Mask, StringRef FileName,
6464

6565
bool NoSanitizeList::containsMainFile(SanitizerMask Mask, StringRef FileName,
6666
StringRef Category) const {
67-
return SSCL->inSection(Mask, "mainfile", FileName, Category);
67+
return containsPrefix(Mask, "mainfile", FileName, Category);
6868
}
6969

7070
bool NoSanitizeList::containsLocation(SanitizerMask Mask, SourceLocation Loc,
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};

clang/test/CodeGen/sanitize-ignorelist-mainfile.c

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
/// Test mainfile in a sanitizer special case list.
22
// RUN: rm -rf %t && split-file %s %t
3-
// RUN: %clang_cc1 -emit-llvm -triple x86_64 -fsanitize=address,alignment %t/a.c -o - | FileCheck %s --check-prefixes=CHECK,DEFAULT
3+
// RUN: %clang_cc1 -emit-llvm -triple x86_64 -fsanitize=address,alignment %t/a.c -o - | FileCheck %s --check-prefixes=CHECK,SANITIZE
44
// RUN: %clang_cc1 -emit-llvm -triple x86_64 -fsanitize=address,alignment -fsanitize-ignorelist=%t/a.list %t/a.c -o - | FileCheck %s --check-prefixes=CHECK,IGNORE
55
// RUN: %clang_cc1 -emit-llvm -triple x86_64 -fsanitize=address,alignment -fsanitize-ignorelist=%t/b.list %t/a.c -o - | FileCheck %s --check-prefixes=CHECK,IGNORE
6+
// RUN: %clang_cc1 -emit-llvm -triple x86_64 -fsanitize=address,alignment -fsanitize-ignorelist=%t/c.list %t/a.c -o - | FileCheck %s --check-prefixes=CHECK,SANITIZE
7+
// RUN: %clang_cc1 -emit-llvm -triple x86_64 -fsanitize=address,alignment -fsanitize-ignorelist=%t/d.list %t/a.c -o - | FileCheck %s --check-prefixes=CHECK,IGNORE
68

79
//--- a.list
810
mainfile:*a.c
@@ -14,6 +16,15 @@ mainfile:*a.c
1416
[alignment]
1517
mainfile:*.c
1618

19+
//--- c.list
20+
mainfile:*a.c
21+
mainfile:*a.c=sanitize
22+
23+
//--- d.list
24+
mainfile:*a.c
25+
mainfile:*a.c=sanitize
26+
mainfile:*a.c
27+
1728
//--- a.h
1829
int global_h;
1930

@@ -30,12 +41,12 @@ int foo(void *x) {
3041
return load(x);
3142
}
3243

33-
// DEFAULT: @___asan_gen_{{.*}} = {{.*}} c"global_h\00"
34-
// DEFAULT: @___asan_gen_{{.*}} = {{.*}} c"global_c\00"
44+
// SANITIZE: @___asan_gen_{{.*}} = {{.*}} c"global_h\00"
45+
// SANITIZE: @___asan_gen_{{.*}} = {{.*}} c"global_c\00"
3546
// IGNORE-NOT: @___asan_gen_
3647

3748
// CHECK-LABEL: define {{.*}}@load(
38-
// DEFAULT: call void @__ubsan_handle_type_mismatch_v1_abort(
39-
// DEFAULT: call void @__asan_report_load4(
49+
// SANITIZE: call void @__ubsan_handle_type_mismatch_v1_abort(
50+
// SANITIZE: call void @__asan_report_load4(
4051
// IGNORE-NOT: call void @__ubsan_handle_type_mismatch_v1_abort(
4152
// IGNORE-NOT: call void @__asan_report_load4(
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)