1 //===--- SanitizerSpecialCaseList.cpp - SCL for sanitizers ----------------===//
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
7 //===----------------------------------------------------------------------===//
9 // An extension of SpecialCaseList to allowing querying sections by
12 //===----------------------------------------------------------------------===//
13 #include "clang/Basic/SanitizerSpecialCaseList.h"
15 using namespace clang;
17 std::unique_ptr<SanitizerSpecialCaseList>
18 SanitizerSpecialCaseList::create(const std::vector<std::string> &Paths,
20 std::unique_ptr<clang::SanitizerSpecialCaseList> SSCL(
21 new SanitizerSpecialCaseList());
22 if (SSCL->createInternal(Paths, Error)) {
23 SSCL->createSanitizerSections();
29 std::unique_ptr<SanitizerSpecialCaseList>
30 SanitizerSpecialCaseList::createOrDie(const std::vector<std::string> &Paths) {
32 if (auto SSCL = create(Paths, Error))
34 llvm::report_fatal_error(Error);
37 void SanitizerSpecialCaseList::createSanitizerSections() {
38 for (auto &S : Sections) {
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)
46 #include "clang/Basic/Sanitizers.def"
48 #undef SANITIZER_GROUP
50 SanitizerSections.emplace_back(Mask, S.Entries);
54 bool SanitizerSpecialCaseList::inSection(SanitizerMask Mask, StringRef Prefix,
56 StringRef Category) const {
57 for (auto &S : SanitizerSections)
58 if ((S.Mask & Mask) &&
59 SpecialCaseList::inSectionBlame(S.Entries, Prefix, Query, Category))