clang 10.0.0git

Sanitizers.cpp
Go to the documentation of this file.
1 //===- Sanitizers.cpp - C Language Family Language Options ----------------===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 //
9 // This file defines the classes from Sanitizers.h
10 //
11 //===----------------------------------------------------------------------===//
12
13 #include "clang/Basic/Sanitizers.h"
14 #include "llvm/ADT/Hashing.h"
15 #include "llvm/ADT/StringSwitch.h"
16
17 using namespace clang;
18
19 // Once LLVM switches to C++17, the constexpr variables can be inline and we
20 // won't need this.
21 #define SANITIZER(NAME, ID) constexpr SanitizerMask SanitizerKind::ID;
22 #define SANITIZER_GROUP(NAME, ID, ALIAS) \
23 constexpr SanitizerMask SanitizerKind::ID; \
24 constexpr SanitizerMask SanitizerKind::ID##Group;
25 #include "clang/Basic/Sanitizers.def"
26
27 SanitizerMask clang::parseSanitizerValue(StringRef Value, bool AllowGroups) {
28 SanitizerMask ParsedKind = llvm::StringSwitch<SanitizerMask>(Value)
29 #define SANITIZER(NAME, ID) .Case(NAME, SanitizerKind::ID)
30 #define SANITIZER_GROUP(NAME, ID, ALIAS) \
31 .Case(NAME, AllowGroups ? SanitizerKind::ID##Group : SanitizerMask())
32 #include "clang/Basic/Sanitizers.def"
33 .Default(SanitizerMask());
34 return ParsedKind;
35 }
36
37 SanitizerMask clang::expandSanitizerGroups(SanitizerMask Kinds) {
38 #define SANITIZER(NAME, ID)
39 #define SANITIZER_GROUP(NAME, ID, ALIAS) \
40 if (Kinds & SanitizerKind::ID##Group) \
41 Kinds |= SanitizerKind::ID;
42 #include "clang/Basic/Sanitizers.def"
43 return Kinds;
44 }
45
46 llvm::hash_code SanitizerMask::hash_value() const {
47 return llvm::hash_combine_range(&maskLoToHigh[0], &maskLoToHigh[kNumElem]);
48 }
49
50 namespace clang {
51 llvm::hash_code hash_value(const clang::SanitizerMask &Arg) {
52 return Arg.hash_value();
53 }
54 } // namespace clang
clang::Builtin::ID
ID
Definition: Builtins.h:46
Value
Value
Definition: UninitializedValues.cpp:101
Sanitizers.h
Defines the clang::SanitizerKind enum.
clang::SanitizerMask::hash_value
llvm::hash_code hash_value() const
Definition: Sanitizers.cpp:46
clang::SanitizerMask
Definition: Sanitizers.h:29
SANITIZER
#define SANITIZER(NAME, ID)
Definition: Sanitizers.cpp:21
clang
Dataflow Directional Tag Classes.
Definition: CFGReachabilityAnalysis.h:21
clang::parseSanitizerValue
SanitizerMask parseSanitizerValue(StringRef Value, bool AllowGroups)
Parse a single value from a -fsanitize= or -fno-sanitize= value list.
Definition: Sanitizers.cpp:27
clang::expandSanitizerGroups
SanitizerMask expandSanitizerGroups(SanitizerMask Kinds)
For each sanitizer group bit set in Kinds, set the bits for sanitizers this group enables...
Definition: Sanitizers.cpp:37