14#include "llvm/ADT/Hashing.h"
15#include "llvm/ADT/SmallVector.h"
16#include "llvm/ADT/StringSwitch.h"
17#include "llvm/Support/Format.h"
18#include "llvm/Support/MathExtras.h"
19#include "llvm/Support/raw_ostream.h"
48#define SANITIZER(NAME, ID) constexpr SanitizerMask SanitizerKind::ID;
49#define SANITIZER_GROUP(NAME, ID, ALIAS) \
50 constexpr SanitizerMask SanitizerKind::ID; \
51 constexpr SanitizerMask SanitizerKind::ID##Group;
52#include "clang/Basic/Sanitizers.def"
56#define SANITIZER(NAME, ID) .Case(NAME, SanitizerKind::ID)
57#define SANITIZER_GROUP(NAME, ID, ALIAS) \
58 .Case(NAME, AllowGroups ? SanitizerKind::ID##Group : SanitizerMask())
59#include "clang/Basic/Sanitizers.def"
67#define SANITIZER(NAME, ID) .StartsWith(NAME "=", SanitizerKind::ID)
68#define SANITIZER_GROUP(NAME, ID, ALIAS) \
69 .StartsWith(NAME "=", \
70 AllowGroups ? SanitizerKind::ID##Group : SanitizerMask())
71#include "clang/Basic/Sanitizers.def"
76 auto [N, W] =
Value.split(
'=');
80 A = std::clamp(A, 0.0, 1.0);
89#define SANITIZER(NAME, ID) \
90 if (Set.has(SanitizerKind::ID)) \
91 Values.push_back(NAME);
92#include "clang/Basic/Sanitizers.def"
97#define SANITIZER(NAME, ID) \
98 if (auto C = Cutoffs[SanitizerKind::SO_##ID]) { \
100 llvm::raw_string_ostream OS(Str); \
101 OS << NAME "=" << llvm::format("%.8f", *C); \
102 Values.emplace_back(StringRef(Str).rtrim('0')); \
104#include "clang/Basic/Sanitizers.def"
108#define SANITIZER(NAME, ID)
109#define SANITIZER_GROUP(NAME, ID, ALIAS) \
110 if (Kinds & SanitizerKind::ID##Group) \
111 Kinds |= SanitizerKind::ID;
112#include "clang/Basic/Sanitizers.def"
117 return llvm::hash_combine_range(&maskLoToHigh[0], &maskLoToHigh[kNumElem]);
123 for (
const auto &Val : maskLoToHigh)
124 total += llvm::popcount(Val);
134 case llvm::AsanDtorKind::None:
136 case llvm::AsanDtorKind::Global:
138 case llvm::AsanDtorKind::Invalid:
145 return llvm::StringSwitch<llvm::AsanDtorKind>(kindStr)
146 .Case(
"none", llvm::AsanDtorKind::None)
147 .Case(
"global", llvm::AsanDtorKind::Global)
148 .Default(llvm::AsanDtorKind::Invalid);
152 llvm::AsanDetectStackUseAfterReturnMode mode) {
154 case llvm::AsanDetectStackUseAfterReturnMode::Always:
156 case llvm::AsanDetectStackUseAfterReturnMode::Runtime:
158 case llvm::AsanDetectStackUseAfterReturnMode::Never:
160 case llvm::AsanDetectStackUseAfterReturnMode::Invalid:
166llvm::AsanDetectStackUseAfterReturnMode
168 return llvm::StringSwitch<llvm::AsanDetectStackUseAfterReturnMode>(modeStr)
169 .Case(
"always", llvm::AsanDetectStackUseAfterReturnMode::Always)
170 .Case(
"runtime", llvm::AsanDetectStackUseAfterReturnMode::Runtime)
171 .Case(
"never", llvm::AsanDetectStackUseAfterReturnMode::Never)
172 .Default(llvm::AsanDetectStackUseAfterReturnMode::Invalid);
static const double SanitizerMaskCutoffsEps
Defines the clang::SanitizerKind enum.
void clear(SanitizerMask K=SanitizerKind::All)
void set(SanitizerMask K, double V)
std::optional< double > operator[](unsigned Kind) const
llvm::hash_code hash_value() const
unsigned countPopulation() const
static constexpr SanitizerMask bitPosToMask(const unsigned Pos)
Create a mask with a bit enabled at position Pos.
The JSON file list parser is used to communicate input to InstallAPI.
StringRef AsanDtorKindToString(llvm::AsanDtorKind kind)
void serializeSanitizerSet(SanitizerSet Set, SmallVectorImpl< StringRef > &Values)
Serialize a SanitizerSet into values for -fsanitize= or -fno-sanitize=.
bool parseSanitizerWeightedValue(StringRef Value, bool AllowGroups, SanitizerMaskCutoffs &Cutoffs)
Parse a single weighted value (e.g., 'undefined=0.05') from a -fsanitize= or -fno-sanitize= value lis...
SanitizerMask expandSanitizerGroups(SanitizerMask Kinds)
For each sanitizer group bit set in Kinds, set the bits for sanitizers this group enables.
void serializeSanitizerMaskCutoffs(const SanitizerMaskCutoffs &Cutoffs, SmallVectorImpl< std::string > &Values)
Serialize a SanitizerMaskCutoffs into values for -fsanitize= or -fno-sanitize=.
SanitizerMask parseSanitizerValue(StringRef Value, bool AllowGroups)
Parse a single value from a -fsanitize= or -fno-sanitize= value list.
llvm::hash_code hash_value(const CustomizableOptional< T > &O)
llvm::AsanDtorKind AsanDtorKindFromString(StringRef kind)
llvm::AsanDetectStackUseAfterReturnMode AsanDetectStackUseAfterReturnModeFromString(StringRef modeStr)
StringRef AsanDetectStackUseAfterReturnModeToString(llvm::AsanDetectStackUseAfterReturnMode mode)