From 4a93caf4cf81c719a5049eaa54aa0d4c04f98914 Mon Sep 17 00:00:00 2001 From: Benjamin Kramer Date: Tue, 14 Jul 2015 15:34:19 +0000 Subject: [PATCH] Pull trivial SanitizerSet methods into the header. Inlining them is always preferable to a call. NFC. llvm-svn: 242154 --- clang/include/clang/Basic/Sanitizers.h | 21 +++++++++++++-------- clang/lib/Basic/Sanitizers.cpp | 25 ------------------------- 2 files changed, 13 insertions(+), 33 deletions(-) diff --git a/clang/include/clang/Basic/Sanitizers.h b/clang/include/clang/Basic/Sanitizers.h index 78c1ddb..98e70de 100644 --- a/clang/include/clang/Basic/Sanitizers.h +++ b/clang/include/clang/Basic/Sanitizers.h @@ -17,8 +17,7 @@ #include "clang/Basic/LLVM.h" #include "llvm/ADT/StringRef.h" - -#include +#include "llvm/Support/MathExtras.h" namespace clang { @@ -47,22 +46,28 @@ enum SanitizerOrdinal : uint64_t { } struct SanitizerSet { - SanitizerSet(); + SanitizerSet() : Mask(0) {} /// \brief Check if a certain (single) sanitizer is enabled. - bool has(SanitizerMask K) const; + bool has(SanitizerMask K) const { + assert(llvm::isPowerOf2_64(K)); + return Mask & K; + } /// \brief Check if one or more sanitizers are enabled. - bool hasOneOf(SanitizerMask K) const; + bool hasOneOf(SanitizerMask K) const { return Mask & K; } /// \brief Enable or disable a certain (single) sanitizer. - void set(SanitizerMask K, bool Value); + void set(SanitizerMask K, bool Value) { + assert(llvm::isPowerOf2_64(K)); + Mask = Value ? (Mask | K) : (Mask & ~K); + } /// \brief Disable all sanitizers. - void clear(); + void clear() { Mask = 0; } /// \brief Returns true if at least one sanitizer is enabled. - bool empty() const; + bool empty() const { return Mask == 0; } /// \brief Bitmask of enabled sanitizers. SanitizerMask Mask; diff --git a/clang/lib/Basic/Sanitizers.cpp b/clang/lib/Basic/Sanitizers.cpp index d3676b6..91b6b2d 100644 --- a/clang/lib/Basic/Sanitizers.cpp +++ b/clang/lib/Basic/Sanitizers.cpp @@ -14,34 +14,9 @@ #include "clang/Basic/LLVM.h" #include "llvm/ADT/StringRef.h" #include "llvm/ADT/StringSwitch.h" -#include "llvm/Support/MathExtras.h" using namespace clang; -SanitizerSet::SanitizerSet() : Mask(0) {} - -bool SanitizerSet::has(SanitizerMask K) const { - assert(llvm::countPopulation(K) == 1); - return Mask & K; -} - -bool SanitizerSet::hasOneOf(SanitizerMask K) const { - return Mask & K; -} - -void SanitizerSet::set(SanitizerMask K, bool Value) { - assert(llvm::countPopulation(K) == 1); - Mask = Value ? (Mask | K) : (Mask & ~K); -} - -void SanitizerSet::clear() { - Mask = 0; -} - -bool SanitizerSet::empty() const { - return Mask == 0; -} - SanitizerMask clang::parseSanitizerValue(StringRef Value, bool AllowGroups) { SanitizerMask ParsedKind = llvm::StringSwitch(Value) #define SANITIZER(NAME, ID) .Case(NAME, SanitizerKind::ID) -- 2.7.4