-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[sanitizer] Fix empty string in unsupported argument error for -fsanitize-trap #136549
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
Conversation
@llvm/pr-subscribers-clang @llvm/pr-subscribers-clang-driver Author: Sinkevich Artem (ArtSin) ChangesWhen using Full diff: https://github.com/llvm/llvm-project/pull/136549.diff 2 Files Affected:
diff --git a/clang/lib/Driver/SanitizerArgs.cpp b/clang/lib/Driver/SanitizerArgs.cpp
index f27cb813012f2..05ca2656c6522 100644
--- a/clang/lib/Driver/SanitizerArgs.cpp
+++ b/clang/lib/Driver/SanitizerArgs.cpp
@@ -286,7 +286,7 @@ parseSanitizeArgs(const Driver &D, const llvm::opt::ArgList &Args,
Add & AlwaysOut & ~DiagnosedAlwaysOutViolations) {
if (DiagnoseErrors) {
SanitizerSet SetToDiagnose;
- SetToDiagnose.Mask |= KindsToDiagnose;
+ SetToDiagnose.Mask |= expandSanitizerGroups(KindsToDiagnose);
D.Diag(diag::err_drv_unsupported_option_argument)
<< Arg->getSpelling() << toString(SetToDiagnose);
DiagnosedAlwaysOutViolations |= KindsToDiagnose;
@@ -302,7 +302,7 @@ parseSanitizeArgs(const Driver &D, const llvm::opt::ArgList &Args,
Remove & AlwaysIn & ~DiagnosedAlwaysInViolations) {
if (DiagnoseErrors) {
SanitizerSet SetToDiagnose;
- SetToDiagnose.Mask |= KindsToDiagnose;
+ SetToDiagnose.Mask |= expandSanitizerGroups(KindsToDiagnose);
D.Diag(diag::err_drv_unsupported_option_argument)
<< Arg->getSpelling() << toString(SetToDiagnose);
DiagnosedAlwaysInViolations |= KindsToDiagnose;
diff --git a/clang/test/Driver/fsanitize.c b/clang/test/Driver/fsanitize.c
index c154e339941f2..434e6fd8c4a15 100644
--- a/clang/test/Driver/fsanitize.c
+++ b/clang/test/Driver/fsanitize.c
@@ -259,6 +259,9 @@
// RUN: not %clang --target=aarch64-linux -fsanitize=memtag -I +mte %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-SANMT-NOMT-1
// CHECK-SANMT-NOMT-1: '-fsanitize=memtag-stack' requires hardware support (+memtag)
+// RUN: not %clang --target=aarch64-linux-android31 -fsanitize-trap=memtag -march=armv8-a+memtag -c %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-SANMT-TRAP
+// CHECK-SANMT-TRAP: error: unsupported argument 'memtag-stack,memtag-heap,memtag-globals' to option '-fsanitize-trap='
+
// RUN: %clang --target=x86_64-linux-gnu -fsanitize=address -fsanitize-address-use-after-scope %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-USE-AFTER-SCOPE
// RUN: %clang_cl --target=x86_64-windows -fsanitize=address -fsanitize-address-use-after-scope -### -- %s 2>&1 | FileCheck %s --check-prefix=CHECK-USE-AFTER-SCOPE
// CHECK-USE-AFTER-SCOPE: -cc1{{.*}}-fsanitize-address-use-after-scope
|
PTAL @vitalybuka |
459d375
to
f5c8b4e
Compare
PTAL @thurstond |
Ping @vitalybuka |
Sorry, I didn't notice being tagged earlier. It didn't show up in my review queue since the "Request Review" wasn't used. Thanks for the patch! I agree this is an improvement over the empty output, but it's arguably confusing to tell the user
(clang/lib/Driver/SanitizerArgs.cpp) so that it works for SANITIZER_GROUP as well instead of only SANITIZER. |
clang/test/Driver/fsanitize.c
Outdated
@@ -259,6 +259,9 @@ | |||
// RUN: not %clang --target=aarch64-linux -fsanitize=memtag -I +mte %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-SANMT-NOMT-1 | |||
// CHECK-SANMT-NOMT-1: '-fsanitize=memtag-stack' requires hardware support (+memtag) | |||
|
|||
// RUN: not %clang --target=aarch64-linux-android31 -fsanitize-trap=memtag -march=armv8-a+memtag -c %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-SANMT-TRAP | |||
// CHECK-SANMT-TRAP: error: unsupported argument 'memtag-stack,memtag-heap,memtag-globals' to option '-fsanitize-trap=' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Optional: precommit this test to show that it currently prints
unsupported argument '' to option '-fsanitize-trap='
…tize-trap When using `-fsanitize-trap` with a sanitizer group that doesn't support trapping, an empty argument is passed to `err_drv_unsupported_option_argument`. Use new `toStringWithGroups` for the diagnostic.
f5c8b4e
to
626d7e1
Compare
I agree, but adding groups to |
Hmm, that's a good point. I like your |
@thurstond can you please merge this? I don't have write access. |
Sure! Thanks for the fix :-) |
LLVM Buildbot has detected a new failure on builder Full details are available at: https://lab.llvm.org/buildbot/#/builders/174/builds/17824 Here is the relevant piece of the build log for the reference
|
When using
-fsanitize-trap
with a sanitizer group that doesn't support trapping, an empty argument is passed toerr_drv_unsupported_option_argument
. Use newtoStringWithGroups
for the diagnostic.