diff options
author | Petr Hosek <phosek@chromium.org> | 2018-03-07 01:27:03 +0000 |
---|---|---|
committer | Petr Hosek <phosek@chromium.org> | 2018-03-07 01:27:03 +0000 |
commit | a14b46073ebb4c0d5d1cfcf6a1cecb9e5d0192e4 (patch) | |
tree | 59f2a1db3a4975d24a3000bfa1971e1ac649433a | |
parent | a0db2eb096cb60f6a1aa0b1b724be567609b7f5c (diff) | |
download | bcm5719-llvm-a14b46073ebb4c0d5d1cfcf6a1cecb9e5d0192e4.tar.gz bcm5719-llvm-a14b46073ebb4c0d5d1cfcf6a1cecb9e5d0192e4.zip |
[Driver] Automatically disable incompatible default sanitizers
When a sanitizer incompatible with one of the default sanitizers
is explicitly enabled, automatically disable all the conflicting
default sanitizers.
Differential Revision: https://reviews.llvm.org/D44064
llvm-svn: 326860
-rw-r--r-- | clang/lib/Driver/SanitizerArgs.cpp | 36 |
1 files changed, 23 insertions, 13 deletions
diff --git a/clang/lib/Driver/SanitizerArgs.cpp b/clang/lib/Driver/SanitizerArgs.cpp index 06e04b17ba7..0f00f678585 100644 --- a/clang/lib/Driver/SanitizerArgs.cpp +++ b/clang/lib/Driver/SanitizerArgs.cpp @@ -332,8 +332,30 @@ SanitizerArgs::SanitizerArgs(const ToolChain &TC, } } + std::pair<SanitizerMask, SanitizerMask> IncompatibleGroups[] = { + std::make_pair(Address, Thread | Memory), + std::make_pair(Thread, Memory), + std::make_pair(Leak, Thread | Memory), + std::make_pair(KernelAddress, Address | Leak | Thread | Memory), + std::make_pair(HWAddress, Address | Thread | Memory | KernelAddress), + std::make_pair(Efficiency, Address | HWAddress | Leak | Thread | Memory | + KernelAddress), + std::make_pair(Scudo, Address | HWAddress | Leak | Thread | Memory | + KernelAddress | Efficiency), + std::make_pair(SafeStack, Address | HWAddress | Leak | Thread | Memory | + KernelAddress | Efficiency)}; + // Enable toolchain specific default sanitizers if not explicitly disabled. - Kinds |= TC.getDefaultSanitizers() & ~AllRemove; + SanitizerMask Default = TC.getDefaultSanitizers() & ~AllRemove; + + // Disable default sanitizers that are incompatible with the default ones. + for (auto G : IncompatibleGroups) { + SanitizerMask Group = G.first; + if ((Default & Group) && (Kinds & G.second)) + Default &= ~Group; + } + + Kinds |= Default; // We disable the vptr sanitizer if it was enabled by group expansion but RTTI // is disabled. @@ -369,18 +391,6 @@ SanitizerArgs::SanitizerArgs(const ToolChain &TC, } // Warn about incompatible groups of sanitizers. - std::pair<SanitizerMask, SanitizerMask> IncompatibleGroups[] = { - std::make_pair(Address, Thread | Memory), - std::make_pair(Thread, Memory), - std::make_pair(Leak, Thread | Memory), - std::make_pair(KernelAddress, Address | Leak | Thread | Memory), - std::make_pair(HWAddress, Address | Thread | Memory | KernelAddress), - std::make_pair(Efficiency, Address | HWAddress | Leak | Thread | Memory | - KernelAddress), - std::make_pair(Scudo, Address | HWAddress | Leak | Thread | Memory | - KernelAddress | Efficiency), - std::make_pair(SafeStack, Address | HWAddress | Leak | Thread | Memory | - KernelAddress | Efficiency)}; for (auto G : IncompatibleGroups) { SanitizerMask Group = G.first; if (Kinds & Group) { |