clang  6.0.0svn
SanitizerSpecialCaseList.cpp
Go to the documentation of this file.
1 //===--- SanitizerSpecialCaseList.cpp - SCL for sanitizers ----------------===//
2 //
3 // The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 // An extension of SpecialCaseList to allowing querying sections by
11 // SanitizerMask.
12 //
13 //===----------------------------------------------------------------------===//
15 
16 using namespace clang;
17 
18 std::unique_ptr<SanitizerSpecialCaseList>
19 SanitizerSpecialCaseList::create(const std::vector<std::string> &Paths,
20  std::string &Error) {
21  std::unique_ptr<clang::SanitizerSpecialCaseList> SSCL(
23  if (SSCL->createInternal(Paths, Error)) {
24  SSCL->createSanitizerSections();
25  return SSCL;
26  }
27  return nullptr;
28 }
29 
30 std::unique_ptr<SanitizerSpecialCaseList>
31 SanitizerSpecialCaseList::createOrDie(const std::vector<std::string> &Paths) {
32  std::string Error;
33  if (auto SSCL = create(Paths, Error))
34  return SSCL;
35  llvm::report_fatal_error(Error);
36 }
37 
39  for (auto &S : Sections) {
40  SanitizerMask Mask = 0;
41 
42 #define SANITIZER(NAME, ID) \
43  if (S.SectionMatcher->match(NAME)) \
44  Mask |= SanitizerKind::ID;
45 #define SANITIZER_GROUP(NAME, ID, ALIAS) SANITIZER(NAME, ID)
46 
47 #include "clang/Basic/Sanitizers.def"
48 #undef SANITIZER
49 #undef SANITIZER_GROUP
50 
51  SanitizerSections.emplace_back(Mask, S.Entries);
52  }
53 }
54 
56  StringRef Query,
57  StringRef Category) const {
58  for (auto &S : SanitizerSections)
59  if ((S.Mask & Mask) &&
60  SpecialCaseList::inSectionBlame(S.Entries, Prefix, Query, Category))
61  return true;
62 
63  return false;
64 }
std::vector< SanitizerSection > SanitizerSections
int Category
Definition: Format.cpp:1348
bool inSection(SanitizerMask Mask, StringRef Prefix, StringRef Query, StringRef Category=StringRef()) const
static std::unique_ptr< SanitizerSpecialCaseList > create(const std::vector< std::string > &Paths, std::string &Error)
Dataflow Directional Tag Classes.
uint64_t SanitizerMask
Definition: Sanitizers.h:24
static std::unique_ptr< SanitizerSpecialCaseList > createOrDie(const std::vector< std::string > &Paths)