clang 22.0.0git
SanitizerSpecialCaseList.h
Go to the documentation of this file.
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"
19#include "llvm/ADT/StringRef.h"
20#include "llvm/Support/SpecialCaseList.h"
21#include <memory>
22#include <utility>
23#include <vector>
24
25namespace llvm {
26namespace vfs {
27class FileSystem;
28}
29} // namespace llvm
30
31namespace clang {
32
33class SanitizerSpecialCaseList : public llvm::SpecialCaseList {
34public:
35 static std::unique_ptr<SanitizerSpecialCaseList>
36 create(const std::vector<std::string> &Paths, llvm::vfs::FileSystem &VFS,
37 std::string &Error);
38
39 static std::unique_ptr<SanitizerSpecialCaseList>
40 createOrDie(const std::vector<std::string> &Paths,
41 llvm::vfs::FileSystem &VFS);
42
43 // Query ignorelisted entries if any bit in Mask matches the entry's section.
44 bool inSection(SanitizerMask Mask, StringRef Prefix, StringRef Query,
45 StringRef Category = StringRef()) const;
46
47 // Query ignorelisted entries if any bit in Mask matches the entry's section.
48 // Return NotFound (0,0) if not found. If found, return the file index number
49 // and the line number (FileIdx, LineNo) (FileIdx starts with 1 and LineNo
50 // starts with 0).
51 std::pair<unsigned, unsigned>
52 inSectionBlame(SanitizerMask Mask, StringRef Prefix, StringRef Query,
53 StringRef Category = StringRef()) const;
54
55protected:
56 // Initialize SanitizerSections.
58
60 SanitizerSection(SanitizerMask SM, SectionEntries &E, unsigned idx)
61 : Mask(SM), Entries(E), FileIdx(idx) {};
62
64 SectionEntries &Entries;
65 unsigned FileIdx;
66 };
67
68 std::vector<SanitizerSection> SanitizerSections;
69};
70
71} // end namespace clang
72
73#endif
Forward-declares and imports various common LLVM datatypes that clang wants to use unqualified.
#define SM(sm)
Defines the clang::SanitizerKind enum.
static std::unique_ptr< SanitizerSpecialCaseList > create(const std::vector< std::string > &Paths, llvm::vfs::FileSystem &VFS, std::string &Error)
bool inSection(SanitizerMask Mask, StringRef Prefix, StringRef Query, StringRef Category=StringRef()) const
std::pair< unsigned, unsigned > inSectionBlame(SanitizerMask Mask, StringRef Prefix, StringRef Query, StringRef Category=StringRef()) const
static std::unique_ptr< SanitizerSpecialCaseList > createOrDie(const std::vector< std::string > &Paths, llvm::vfs::FileSystem &VFS)
std::vector< SanitizerSection > SanitizerSections
The JSON file list parser is used to communicate input to InstallAPI.
Diagnostic wrappers for TextAPI types for error reporting.
Definition Dominators.h:30
SanitizerSection(SanitizerMask SM, SectionEntries &E, unsigned idx)