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
,
19 llvm::vfs::FileSystem
&VFS
,
21 std::unique_ptr
<clang::SanitizerSpecialCaseList
> SSCL(
22 new SanitizerSpecialCaseList());
23 if (SSCL
->createInternal(Paths
, VFS
, Error
)) {
24 SSCL
->createSanitizerSections();
30 std::unique_ptr
<SanitizerSpecialCaseList
>
31 SanitizerSpecialCaseList::createOrDie(const std::vector
<std::string
> &Paths
,
32 llvm::vfs::FileSystem
&VFS
) {
34 if (auto SSCL
= create(Paths
, VFS
, Error
))
36 llvm::report_fatal_error(StringRef(Error
));
39 void SanitizerSpecialCaseList::createSanitizerSections() {
40 for (auto &S
: Sections
) {
43 #define SANITIZER(NAME, ID) \
44 if (S.SectionMatcher->match(NAME)) \
45 Mask |= SanitizerKind::ID;
46 #define SANITIZER_GROUP(NAME, ID, ALIAS) SANITIZER(NAME, ID)
48 #include "clang/Basic/Sanitizers.def"
50 #undef SANITIZER_GROUP
52 SanitizerSections
.emplace_back(Mask
, S
.Entries
);
56 bool SanitizerSpecialCaseList::inSection(SanitizerMask Mask
, StringRef Prefix
,
58 StringRef Category
) const {
59 for (auto &S
: SanitizerSections
)
60 if ((S
.Mask
& Mask
) &&
61 SpecialCaseList::inSectionBlame(S
.Entries
, Prefix
, Query
, Category
))