clang  9.0.0
SanitizerSpecialCaseList.cpp
Go to the documentation of this file.
1 //===--- SanitizerSpecialCaseList.cpp - SCL for sanitizers ----------------===//
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 // An extension of SpecialCaseList to allowing querying sections by
10 // SanitizerMask.
11 //
12 //===----------------------------------------------------------------------===//
14 
15 using namespace clang;
16 
17 std::unique_ptr<SanitizerSpecialCaseList>
18 SanitizerSpecialCaseList::create(const std::vector<std::string> &Paths,
19  std::string &Error) {
20  std::unique_ptr<clang::SanitizerSpecialCaseList> SSCL(
22  if (SSCL->createInternal(Paths, Error)) {
23  SSCL->createSanitizerSections();
24  return SSCL;
25  }
26  return nullptr;
27 }
28 
29 std::unique_ptr<SanitizerSpecialCaseList>
30 SanitizerSpecialCaseList::createOrDie(const std::vector<std::string> &Paths) {
31  std::string Error;
32  if (auto SSCL = create(Paths, Error))
33  return SSCL;
34  llvm::report_fatal_error(Error);
35 }
36 
38  for (auto &S : Sections) {
39  SanitizerMask Mask;
40 
41 #define SANITIZER(NAME, ID) \
42  if (S.SectionMatcher->match(NAME)) \
43  Mask |= SanitizerKind::ID;
44 #define SANITIZER_GROUP(NAME, ID, ALIAS) SANITIZER(NAME, ID)
45 
46 #include "clang/Basic/Sanitizers.def"
47 #undef SANITIZER
48 #undef SANITIZER_GROUP
49 
50  SanitizerSections.emplace_back(Mask, S.Entries);
51  }
52 }
53 
55  StringRef Query,
56  StringRef Category) const {
57  for (auto &S : SanitizerSections)
58  if ((S.Mask & Mask) &&
59  SpecialCaseList::inSectionBlame(S.Entries, Prefix, Query, Category))
60  return true;
61 
62  return false;
63 }
std::vector< SanitizerSection > SanitizerSections
int Category
Definition: Format.cpp:1714
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.
static std::unique_ptr< SanitizerSpecialCaseList > createOrDie(const std::vector< std::string > &Paths)