Skip to content

Commit eb4127f

Browse files
committedJul 21, 2017
[Driver] Consider -fno-sanitize=... state when filtering out -fsanitize-coverage=...
The driver ignores -fsanitize-coverage=... flags when also given -fsanitize=... flags for sanitizer flavors that don't support the coverage runtime. This logic failed to account for subsequent -fno-sanitize=... flags that disable the sanitizer flavors that conflict with -fsanitize-coverage=... flags. Patch by Roland McGrath Differential Revision: https://reviews.llvm.org/D35603 llvm-svn: 308707
1 parent 8b591f5 commit eb4127f

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed
 

‎clang/lib/Driver/SanitizerArgs.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -504,7 +504,7 @@ SanitizerArgs::SanitizerArgs(const ToolChain &TC,
504504

505505
// Disable coverage and not claim the flags if there is at least one
506506
// non-supporting sanitizer.
507-
if (!(AllAddedKinds & ~setGroupBits(SupportsCoverage))) {
507+
if (!(AllAddedKinds & ~AllRemove & ~setGroupBits(SupportsCoverage))) {
508508
Arg->claim();
509509
} else {
510510
CoverageFeatures = 0;

‎clang/test/Driver/fsanitize-coverage.c

+12
Original file line numberDiff line numberDiff line change
@@ -95,3 +95,15 @@
9595
// CLANG-CL-COVERAGE-NOT: unknown argument
9696
// CLANG-CL-COVERAGE: -fsanitize-coverage-type=1
9797
// CLANG-CL-COVERAGE: -fsanitize=address
98+
99+
// RUN: %clang -target x86_64-linux-gnu -fsanitize=safe-stack -fsanitize-coverage=trace-pc-guard %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-VS-SAFESTACK
100+
// CHECK-VS-SAFESTACK: -fsanitize=safe-stack
101+
// CHECK-VS-SAFESTACK-NOT: -fsanitize-coverage-trace-pc-guard
102+
103+
// RUN: %clang -target x86_64-linux-gnu -fsanitize=safe-stack -fsanitize-coverage=trace-pc-guard -fno-sanitize=safe-stack %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-NO-SAFESTACK
104+
// CHECK-NO-SAFESTACK-NOT: error:
105+
// CHECK-NO-SAFESTACK-NOT: warning:
106+
// CHECK-NO-SAFESTACK-NOT: argument unused
107+
// CHECK-NO-SAFESTACK-NOT: unknown argument
108+
// CHECK-NO-SAFESTACK-NOT: -fsanitize=safe-stack
109+
// CHECK-NO-SAFESTACK: -fsanitize-coverage-trace-pc-guard

0 commit comments

Comments
 (0)
Please sign in to comment.