forked from OSchip/llvm-project
[sanitizer] Allow sanitize coverage w/o sanitizers.
The reason is that this (a) seems to work just fine and (b) useful when building stuff with sanitizer+coverage, but need to exclude the sanitizer for a particular source file. llvm-svn: 272717
This commit is contained in:
parent
f2f2a6395f
commit
5b49eb42c5
clang
|
@ -16,8 +16,9 @@ How to build and run
|
|||
====================
|
||||
|
||||
SanitizerCoverage can be used with :doc:`AddressSanitizer`,
|
||||
:doc:`LeakSanitizer`, :doc:`MemorySanitizer`, and UndefinedBehaviorSanitizer.
|
||||
In addition to ``-fsanitize=``, pass one of the following compile-time flags:
|
||||
:doc:`LeakSanitizer`, :doc:`MemorySanitizer`,
|
||||
UndefinedBehaviorSanitizer, or without any sanitizer. Pass one of the
|
||||
following compile-time flags:
|
||||
|
||||
* ``-fsanitize-coverage=func`` for function-level coverage (very fast).
|
||||
* ``-fsanitize-coverage=bb`` for basic-block-level coverage (may add up to 30%
|
||||
|
@ -27,8 +28,9 @@ In addition to ``-fsanitize=``, pass one of the following compile-time flags:
|
|||
You may also specify ``-fsanitize-coverage=indirect-calls`` for
|
||||
additional `caller-callee coverage`_.
|
||||
|
||||
At run time, pass ``coverage=1`` in ``ASAN_OPTIONS``, ``LSAN_OPTIONS``,
|
||||
``MSAN_OPTIONS`` or ``UBSAN_OPTIONS``, as appropriate.
|
||||
At run time, pass ``coverage=1`` in ``ASAN_OPTIONS``,
|
||||
``LSAN_OPTIONS``, ``MSAN_OPTIONS`` or ``UBSAN_OPTIONS``, as
|
||||
appropriate. For the standalone coverage mode, use ``UBSAN_OPTIONS``.
|
||||
|
||||
To get `Coverage counters`_, add ``-fsanitize-coverage=8bit-counters``
|
||||
to one of the above compile-time flags. At runtime, use
|
||||
|
|
|
@ -159,11 +159,10 @@ static SanitizerMask parseSanitizeTrapArgs(const Driver &D,
|
|||
}
|
||||
|
||||
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 @@ SanitizerArgs::SanitizerArgs(const ToolChain &TC,
|
|||
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;
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
Loading…
Reference in New Issue