-
Notifications
You must be signed in to change notification settings - Fork 13.6k
[Sanitizer][Ignorelist] Expanding =sanitize to mainfile. #142472
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
qinkunbao
merged 3 commits into
main
from
users/qinkunbao/spr/sanitizerignorelist-expanding-sanitize-to-global
Jun 2, 2025
Merged
[Sanitizer][Ignorelist] Expanding =sanitize to mainfile. #142472
qinkunbao
merged 3 commits into
main
from
users/qinkunbao/spr/sanitizerignorelist-expanding-sanitize-to-global
Jun 2, 2025
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Created using spr 1.3.6 [skip ci]
Created using spr 1.3.6
@llvm/pr-subscribers-clang Author: Qinkun Bao (qinkunbao) ChangesSee #139128 Full diff: https://github.com/llvm/llvm-project/pull/142472.diff 2 Files Affected:
diff --git a/clang/lib/Basic/NoSanitizeList.cpp b/clang/lib/Basic/NoSanitizeList.cpp
index 24d2276f50ddf..96f79fb2a2a29 100644
--- a/clang/lib/Basic/NoSanitizeList.cpp
+++ b/clang/lib/Basic/NoSanitizeList.cpp
@@ -64,7 +64,7 @@ bool NoSanitizeList::containsFile(SanitizerMask Mask, StringRef FileName,
bool NoSanitizeList::containsMainFile(SanitizerMask Mask, StringRef FileName,
StringRef Category) const {
- return SSCL->inSection(Mask, "mainfile", FileName, Category);
+ return containsPrefix(Mask, "mainfile", FileName, Category);
}
bool NoSanitizeList::containsLocation(SanitizerMask Mask, SourceLocation Loc,
diff --git a/clang/test/CodeGen/sanitize-ignorelist-mainfile.c b/clang/test/CodeGen/sanitize-ignorelist-mainfile.c
index 419e0417c1d82..599ff8e597c98 100644
--- a/clang/test/CodeGen/sanitize-ignorelist-mainfile.c
+++ b/clang/test/CodeGen/sanitize-ignorelist-mainfile.c
@@ -1,8 +1,10 @@
/// Test mainfile in a sanitizer special case list.
// RUN: rm -rf %t && split-file %s %t
-// RUN: %clang_cc1 -emit-llvm -triple x86_64 -fsanitize=address,alignment %t/a.c -o - | FileCheck %s --check-prefixes=CHECK,DEFAULT
+// RUN: %clang_cc1 -emit-llvm -triple x86_64 -fsanitize=address,alignment %t/a.c -o - | FileCheck %s --check-prefixes=CHECK,SANITIZE
// 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
// 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
+// 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
+// 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
//--- a.list
mainfile:*a.c
@@ -14,6 +16,15 @@ mainfile:*a.c
[alignment]
mainfile:*.c
+//--- c.list
+mainfile:*a.c
+mainfile:*a.c=sanitize
+
+//--- d.list
+mainfile:*a.c
+mainfile:*a.c=sanitize
+mainfile:*a.c
+
//--- a.h
int global_h;
@@ -30,12 +41,12 @@ int foo(void *x) {
return load(x);
}
-// DEFAULT: @___asan_gen_{{.*}} = {{.*}} c"global_h\00"
-// DEFAULT: @___asan_gen_{{.*}} = {{.*}} c"global_c\00"
+// SANITIZE: @___asan_gen_{{.*}} = {{.*}} c"global_h\00"
+// SANITIZE: @___asan_gen_{{.*}} = {{.*}} c"global_c\00"
// IGNORE-NOT: @___asan_gen_
// CHECK-LABEL: define {{.*}}@load(
-// DEFAULT: call void @__ubsan_handle_type_mismatch_v1_abort(
-// DEFAULT: call void @__asan_report_load4(
+// SANITIZE: call void @__ubsan_handle_type_mismatch_v1_abort(
+// SANITIZE: call void @__asan_report_load4(
// IGNORE-NOT: call void @__ubsan_handle_type_mismatch_v1_abort(
// IGNORE-NOT: call void @__asan_report_load4(
|
vitalybuka
approved these changes
Jun 2, 2025
…nding-sanitize-to-global
sallto
pushed a commit
to sallto/llvm-project
that referenced
this pull request
Jun 3, 2025
See llvm#139128 If multiple entries match the source, than the latest entry takes the precedence.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
clang:frontend
Language frontend issues, e.g. anything involving "Sema"
clang
Clang issues not falling into any other category
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
See #139128
If multiple entries match the source, than the latest entry takes the
precedence.