File indexing completed on 2024-04-21 05:38:48
0001 /* 0002 SPDX-FileCopyrightText: 2016 Sergio Martins <smartins@kde.org> 0003 0004 SPDX-License-Identifier: LGPL-2.0-or-later 0005 */ 0006 0007 #ifndef CLAZY_SUPPRESSION_MANAGER_H 0008 #define CLAZY_SUPPRESSION_MANAGER_H 0009 0010 #include <set> 0011 #include <string> 0012 #include <unordered_map> 0013 #include <utility> 0014 0015 namespace clang 0016 { 0017 class SourceLocation; 0018 class LangOptions; 0019 class SourceManager; 0020 class FileID; 0021 } 0022 0023 class SuppressionManager 0024 { 0025 public: 0026 using SourceFileID = unsigned int; 0027 using LineNumber = unsigned int; 0028 using CheckName = std::string; 0029 using LineAndCheckName = std::pair<LineNumber, CheckName>; 0030 0031 struct Suppressions { 0032 bool skipEntireFile = false; 0033 std::set<unsigned> skipNextLine; 0034 std::set<CheckName> checksToSkip; 0035 std::set<LineAndCheckName> checksToSkipByLine; 0036 }; 0037 0038 SuppressionManager(); 0039 0040 bool isSuppressed(const std::string &checkName, clang::SourceLocation, const clang::SourceManager &, const clang::LangOptions &) const; 0041 0042 private: 0043 void parseFile(clang::FileID, const clang::SourceManager &, const clang::LangOptions &lo) const; 0044 SuppressionManager(const SuppressionManager &) = delete; 0045 SuppressionManager &operator=(const SuppressionManager &) = delete; 0046 mutable std::unordered_map<SourceFileID, Suppressions> m_processedFileIDs; 0047 }; 0048 0049 #endif