[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
This commit is contained in:
Petr Hosek 2017-07-21 01:17:49 +00:00
parent 8b591f592b
commit eb4127ffb5
2 changed files with 13 additions and 1 deletions

View File

@ -504,7 +504,7 @@ SanitizerArgs::SanitizerArgs(const ToolChain &TC,
// Disable coverage and not claim the flags if there is at least one // Disable coverage and not claim the flags if there is at least one
// non-supporting sanitizer. // non-supporting sanitizer.
if (!(AllAddedKinds & ~setGroupBits(SupportsCoverage))) { if (!(AllAddedKinds & ~AllRemove & ~setGroupBits(SupportsCoverage))) {
Arg->claim(); Arg->claim();
} else { } else {
CoverageFeatures = 0; CoverageFeatures = 0;

View File

@ -95,3 +95,15 @@
// CLANG-CL-COVERAGE-NOT: unknown argument // CLANG-CL-COVERAGE-NOT: unknown argument
// CLANG-CL-COVERAGE: -fsanitize-coverage-type=1 // CLANG-CL-COVERAGE: -fsanitize-coverage-type=1
// CLANG-CL-COVERAGE: -fsanitize=address // CLANG-CL-COVERAGE: -fsanitize=address
// 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
// CHECK-VS-SAFESTACK: -fsanitize=safe-stack
// CHECK-VS-SAFESTACK-NOT: -fsanitize-coverage-trace-pc-guard
// 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
// CHECK-NO-SAFESTACK-NOT: error:
// CHECK-NO-SAFESTACK-NOT: warning:
// CHECK-NO-SAFESTACK-NOT: argument unused
// CHECK-NO-SAFESTACK-NOT: unknown argument
// CHECK-NO-SAFESTACK-NOT: -fsanitize=safe-stack
// CHECK-NO-SAFESTACK: -fsanitize-coverage-trace-pc-guard