1 //===--- Sanitizers.h - C Language Family Language Options ------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
11 /// \brief Defines the clang::SanitizerKind enum.
13 //===----------------------------------------------------------------------===//
15 #ifndef LLVM_CLANG_BASIC_SANITIZERS_H
16 #define LLVM_CLANG_BASIC_SANITIZERS_H
18 #include "clang/Basic/LLVM.h"
19 #include "llvm/ADT/StringRef.h"
25 typedef uint64_t SanitizerMask;
27 namespace SanitizerKind {
29 // Assign ordinals to possible values of -fsanitize= flag, which we will use as
31 enum SanitizerOrdinal : uint64_t {
32 #define SANITIZER(NAME, ID) SO_##ID,
33 #define SANITIZER_GROUP(NAME, ID, ALIAS) SO_##ID##Group,
34 #include "clang/Basic/Sanitizers.def"
38 // Define the set of sanitizer kinds, as well as the set of sanitizers each
39 // sanitizer group expands into.
40 #define SANITIZER(NAME, ID) \
41 const SanitizerMask ID = 1ULL << SO_##ID;
42 #define SANITIZER_GROUP(NAME, ID, ALIAS) \
43 const SanitizerMask ID = ALIAS; \
44 const SanitizerMask ID##Group = 1ULL << SO_##ID##Group;
45 #include "clang/Basic/Sanitizers.def"
52 /// \brief Check if a certain (single) sanitizer is enabled.
53 bool has(SanitizerMask K) const;
55 /// \brief Enable or disable a certain (single) sanitizer.
56 void set(SanitizerMask K, bool Value);
58 /// \brief Disable all sanitizers.
61 /// \brief Returns true if at least one sanitizer is enabled.
64 /// \brief Bitmask of enabled sanitizers.
68 /// Parse a single value from a -fsanitize= or -fno-sanitize= value list.
69 /// Returns a non-zero SanitizerMask, or \c 0 if \p Value is not known.
70 SanitizerMask parseSanitizerValue(StringRef Value, bool AllowGroups);
72 /// For each sanitizer group bit set in \p Kinds, set the bits for sanitizers
73 /// this group enables.
74 SanitizerMask expandSanitizerGroups(SanitizerMask Kinds);
76 } // end namespace clang