xref: /freebsd/contrib/llvm-project/clang/include/clang/Basic/SanitizerSpecialCaseList.h (revision fe6060f10f634930ff71b7c50291ddc610da2475)
1 //===--- SanitizerSpecialCaseList.h - SCL for sanitizers --------*- C++ -*-===//
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 //===----------------------------------------------------------------------===//
13 
14 #ifndef LLVM_CLANG_BASIC_SANITIZERSPECIALCASELIST_H
15 #define LLVM_CLANG_BASIC_SANITIZERSPECIALCASELIST_H
16 
17 #include "clang/Basic/LLVM.h"
18 #include "clang/Basic/Sanitizers.h"
19 #include "llvm/ADT/StringRef.h"
20 #include "llvm/Support/SpecialCaseList.h"
21 #include <memory>
22 #include <vector>
23 
24 namespace llvm {
25 namespace vfs {
26 class FileSystem;
27 }
28 } // namespace llvm
29 
30 namespace clang {
31 
32 class SanitizerSpecialCaseList : public llvm::SpecialCaseList {
33 public:
34   static std::unique_ptr<SanitizerSpecialCaseList>
35   create(const std::vector<std::string> &Paths, llvm::vfs::FileSystem &VFS,
36          std::string &Error);
37 
38   static std::unique_ptr<SanitizerSpecialCaseList>
39   createOrDie(const std::vector<std::string> &Paths,
40               llvm::vfs::FileSystem &VFS);
41 
42   // Query ignorelisted entries if any bit in Mask matches the entry's section.
43   bool inSection(SanitizerMask Mask, StringRef Prefix, StringRef Query,
44                  StringRef Category = StringRef()) const;
45 
46 protected:
47   // Initialize SanitizerSections.
48   void createSanitizerSections();
49 
50   struct SanitizerSection {
SanitizerSectionSanitizerSection51     SanitizerSection(SanitizerMask SM, SectionEntries &E)
52         : Mask(SM), Entries(E){};
53 
54     SanitizerMask Mask;
55     SectionEntries &Entries;
56   };
57 
58   std::vector<SanitizerSection> SanitizerSections;
59 };
60 
61 } // end namespace clang
62 
63 #endif
64