diff options
author | Alexey Samsonov <vonosmas@gmail.com> | 2014-11-07 22:29:38 +0000 |
---|---|---|
committer | Alexey Samsonov <vonosmas@gmail.com> | 2014-11-07 22:29:38 +0000 |
commit | c914e25cc8f42fb1889b6695005d3c09437a3b20 (patch) | |
tree | ec1539466d919c26b55209c9b818a70d2be5b48f /lib/Basic | |
parent | 64f15a10a95d7a106501d7b4ee8ef167444c549c (diff) |
Introduce a SanitizerKind enum to LangOptions.
Use the bitmask to store the set of enabled sanitizers instead of a
bitfield. On the negative side, it makes syntax for querying the
set of enabled sanitizers a bit more clunky. On the positive side, we
will be able to use SanitizerKind to eventually implement the
new semantics for -fsanitize-recover= flag, that would allow us
to make some sanitizers recoverable, and some non-recoverable.
No functionality change.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@221558 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Basic')
-rw-r--r-- | lib/Basic/LangOptions.cpp | 15 | ||||
-rw-r--r-- | lib/Basic/Targets.cpp | 3 |
2 files changed, 13 insertions, 5 deletions
diff --git a/lib/Basic/LangOptions.cpp b/lib/Basic/LangOptions.cpp index f7ea16a451..8992bfaff2 100644 --- a/lib/Basic/LangOptions.cpp +++ b/lib/Basic/LangOptions.cpp @@ -14,10 +14,17 @@ using namespace clang; -SanitizerOptions::SanitizerOptions() { -#define SANITIZER(NAME, ID) ID = 0; -#include "clang/Basic/Sanitizers.def" - SanitizeAddressFieldPadding = 0; +SanitizerOptions::SanitizerOptions() + : Kind(0), SanitizeAddressFieldPadding(0) {} + +bool SanitizerOptions::has(SanitizerKind K) const { + unsigned Bit = static_cast<unsigned>(K); + return Kind & (1 << Bit); +} + +void SanitizerOptions::set(SanitizerKind K, bool Value) { + unsigned Bit = static_cast<unsigned>(K); + Kind = Value ? (Kind | (1 << Bit)) : (Kind & ~(1 << Bit)); } void SanitizerOptions::clear() { diff --git a/lib/Basic/Targets.cpp b/lib/Basic/Targets.cpp index 2f34304089..61f0a53086 100644 --- a/lib/Basic/Targets.cpp +++ b/lib/Basic/Targets.cpp @@ -94,7 +94,8 @@ static void getDarwinDefines(MacroBuilder &Builder, const LangOptions &Opts, Builder.defineMacro("OBJC_NEW_PROPERTIES"); // AddressSanitizer doesn't play well with source fortification, which is on // by default on Darwin. - if (Opts.Sanitize.Address) Builder.defineMacro("_FORTIFY_SOURCE", "0"); + if (Opts.Sanitize.has(SanitizerKind::Address)) + Builder.defineMacro("_FORTIFY_SOURCE", "0"); if (!Opts.ObjCAutoRefCount) { // __weak is always defined, for use in blocks and with objc pointers. |