[PATCH] D21317: [sanitizer] Allow sanitize coverage w/o sanitizers.
Evgeniy Stepanov via cfe-commits
cfe-commits at lists.llvm.org
Mon Jun 13 17:37:40 PDT 2016
eugenis created this revision.
eugenis added reviewers: pcc, kcc.
eugenis added a subscriber: cfe-commits.
eugenis set the repository for this revision to rL LLVM.
The reason is that this (a) seems to work just fine and (b) is useful when building stuff with
sanitizer+coverage, but needing to exclude the sanitizer for a particular source file.
Repository:
rL LLVM
http://reviews.llvm.org/D21317
Files:
lib/Driver/SanitizerArgs.cpp
test/Driver/fsanitize-coverage.c
Index: test/Driver/fsanitize-coverage.c
===================================================================
--- test/Driver/fsanitize-coverage.c
+++ test/Driver/fsanitize-coverage.c
@@ -33,7 +33,7 @@
// CHECK-SANITIZE-COVERAGE-5: error: unsupported argument '5' to option 'fsanitize-coverage='
// RUN: %clang -target x86_64-linux-gnu -fsanitize=thread -fsanitize-coverage=func %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-SANITIZE-COVERAGE-UNUSED
-// RUN: %clang -target x86_64-linux-gnu -fsanitize-coverage=func %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-SANITIZE-COVERAGE-UNUSED
+// RUN: %clang -target x86_64-linux-gnu -fsanitize-coverage=func %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-SANITIZE-COVERAGE-FUNC
// CHECK-SANITIZE-COVERAGE-UNUSED: argument unused during compilation: '-fsanitize-coverage=func'
// CHECK-SANITIZE-COVERAGE-UNUSED-NOT: -fsanitize-coverage-type=1
Index: lib/Driver/SanitizerArgs.cpp
===================================================================
--- lib/Driver/SanitizerArgs.cpp
+++ lib/Driver/SanitizerArgs.cpp
@@ -159,11 +159,10 @@
}
bool SanitizerArgs::needsUbsanRt() const {
- return (Sanitizers.Mask & NeedsUbsanRt & ~TrapSanitizers.Mask) &&
- !Sanitizers.has(Address) &&
- !Sanitizers.has(Memory) &&
- !Sanitizers.has(Thread) &&
- !CfiCrossDso;
+ return ((Sanitizers.Mask & NeedsUbsanRt & ~TrapSanitizers.Mask) ||
+ CoverageFeatures) &&
+ !Sanitizers.has(Address) && !Sanitizers.has(Memory) &&
+ !Sanitizers.has(Thread) && !CfiCrossDso;
}
bool SanitizerArgs::needsCfiRt() const {
@@ -485,10 +484,10 @@
continue;
}
CoverageFeatures |= parseCoverageFeatures(D, Arg);
- // If there is trace-pc, allow it w/o any of the sanitizers.
- // Otherwise, require that one of the supported sanitizers is present.
- if ((CoverageFeatures & CoverageTracePC) ||
- (AllAddedKinds & SupportsCoverage)) {
+
+ // Disable coverage and not claim the flags if there is at least one
+ // non-supporting sanitizer.
+ if (!(AllAddedKinds & ~setGroupBits(SupportsCoverage))) {
Arg->claim();
} else {
CoverageFeatures = 0;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D21317.60635.patch
Type: text/x-patch
Size: 2257 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20160614/be7f69f7/attachment.bin>
More information about the cfe-commits
mailing list