Debian Codegraph @

src/SuppressionManager.h

raw
1 /*
2 SPDX-FileCopyrightText: 2016 Sergio Martins <[email protected]>
3
4 SPDX-License-Identifier: LGPL-2.0-or-later
5 */
6
7 #ifndef CLAZY_SUPPRESSION_MANAGER_H
8 #define CLAZY_SUPPRESSION_MANAGER_H
9
10 #include <llvm/Support/Regex.h>
11 #include <set>
12 #include <string>
13 #include <unordered_map>
14 #include <utility>
15 #include <vector>
16
17 namespace llvm
18 {
19 class Regex;
20 }
21
22 namespace clang
23 {
24 class SourceLocation;
25 class LangOptions;
26 class SourceManager;
27 class FileID;
28 }
29
30 class SuppressionManager
31 {
32 public:
33 using SourceFileID = unsigned int;
34 using LineNumber = unsigned int;
35 using CheckName = std::string;
36 using LineAndCheckName = std::pair<LineNumber, CheckName>;
37 struct CheckBeginAndEnd {
38 std::vector<llvm::Regex> checksToSkipWildcard;
39 LineNumber begin;
40 LineNumber end;
41 };
42
43 struct Suppressions {
44 bool skipEntireFile = false;
45 std::set<unsigned> skipNextLine;
46 std::set<CheckName> checksToSkip;
47 std::set<LineAndCheckName> checksToSkipByLine;
48 std::unordered_map<LineNumber, llvm::Regex> checkWildcardsToSkipByLine;
49 std::vector<CheckBeginAndEnd> checkWildcardsRanges;
50 };
51
52 SuppressionManager();
53
54 bool isSuppressed(const std::string &checkName, clang::SourceLocation, const clang::SourceManager &, const clang::LangOptions &) const;
55
56 private:
57 void parseFile(clang::FileID, const clang::SourceManager &, const clang::LangOptions &lo) const;
58 SuppressionManager(const SuppressionManager &) = delete;
59 SuppressionManager &operator=(const SuppressionManager &) = delete;
60 mutable std::unordered_map<SourceFileID, Suppressions> m_processedFileIDs;
61 };
62
63 #endif