Skip to content

Commit 43c2234

Browse files
authored
[Sanitizer][Ignorelist] Expanding =sanitize to global. (#142456)
See #139128 If multiple entries match the source, than the latest entry takes the precedence.`
1 parent b9a5285 commit 43c2234

File tree

2 files changed

+38
-1
lines changed

2 files changed

+38
-1
lines changed

clang/lib/Basic/NoSanitizeList.cpp

Lines changed: 1 addition & 1 deletion
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,
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};

0 commit comments

Comments
 (0)