Skip to content

Commit 459d375

Browse files
committed
[sanitizer] Fix empty string in unsupported argument error for -fsanitize-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`. Expand groups for the diagnostic.
1 parent f91df0d commit 459d375

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

clang/lib/Driver/SanitizerArgs.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,7 @@ parseSanitizeArgs(const Driver &D, const llvm::opt::ArgList &Args,
286286
Add & AlwaysOut & ~DiagnosedAlwaysOutViolations) {
287287
if (DiagnoseErrors) {
288288
SanitizerSet SetToDiagnose;
289-
SetToDiagnose.Mask |= KindsToDiagnose;
289+
SetToDiagnose.Mask |= expandSanitizerGroups(KindsToDiagnose);
290290
D.Diag(diag::err_drv_unsupported_option_argument)
291291
<< Arg->getSpelling() << toString(SetToDiagnose);
292292
DiagnosedAlwaysOutViolations |= KindsToDiagnose;
@@ -302,7 +302,7 @@ parseSanitizeArgs(const Driver &D, const llvm::opt::ArgList &Args,
302302
Remove & AlwaysIn & ~DiagnosedAlwaysInViolations) {
303303
if (DiagnoseErrors) {
304304
SanitizerSet SetToDiagnose;
305-
SetToDiagnose.Mask |= KindsToDiagnose;
305+
SetToDiagnose.Mask |= expandSanitizerGroups(KindsToDiagnose);
306306
D.Diag(diag::err_drv_unsupported_option_argument)
307307
<< Arg->getSpelling() << toString(SetToDiagnose);
308308
DiagnosedAlwaysInViolations |= KindsToDiagnose;

clang/test/Driver/fsanitize.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -259,6 +259,9 @@
259259
// RUN: not %clang --target=aarch64-linux -fsanitize=memtag -I +mte %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-SANMT-NOMT-1
260260
// CHECK-SANMT-NOMT-1: '-fsanitize=memtag-stack' requires hardware support (+memtag)
261261

262+
// 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
263+
// CHECK-SANMT-TRAP: error: unsupported argument 'memtag-stack,memtag-heap,memtag-globals' to option '-fsanitize-trap='
264+
262265
// 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
263266
// 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
264267
// CHECK-USE-AFTER-SCOPE: -cc1{{.*}}-fsanitize-address-use-after-scope

0 commit comments

Comments
 (0)