[AMDGPU][AsmParser][NFC] Translate parsed MIMG instructions to MCInsts automatically.
[llvm-project.git] / clang-tools-extra / clang-tidy / misc / IncludeCleanerCheck.h
blobd5f75f2b1c7fa261ab48c041bbf763465fbc7192
1 //===--- IncludeCleanerCheck.h - clang-tidy ---------------------*- 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 //===----------------------------------------------------------------------===//
9 #ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MISC_INCLUDECLEANER_H
10 #define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MISC_INCLUDECLEANER_H
12 #include "../ClangTidyCheck.h"
13 #include "../ClangTidyDiagnosticConsumer.h"
14 #include "../ClangTidyOptions.h"
15 #include "clang-include-cleaner/Record.h"
16 #include "clang-include-cleaner/Types.h"
17 #include "clang/ASTMatchers/ASTMatchFinder.h"
18 #include "clang/Basic/LLVM.h"
19 #include "clang/Basic/SourceLocation.h"
20 #include "clang/Lex/HeaderSearch.h"
21 #include "llvm/Support/Regex.h"
22 #include <vector>
24 namespace clang::tidy::misc {
26 /// Checks for unused and missing includes. Generates findings only for
27 /// the main file of a translation unit.
28 /// Findings correspond to https://clangd.llvm.org/design/include-cleaner.
29 ///
30 /// For the user-facing documentation see:
31 /// http://clang.llvm.org/extra/clang-tidy/checks/misc/include-cleaner.html
32 class IncludeCleanerCheck : public ClangTidyCheck {
33 public:
34 IncludeCleanerCheck(StringRef Name, ClangTidyContext *Context);
35 void registerMatchers(ast_matchers::MatchFinder *Finder) override;
36 void check(const ast_matchers::MatchFinder::MatchResult &Result) override;
37 void registerPPCallbacks(const SourceManager &SM, Preprocessor *PP,
38 Preprocessor *ModuleExpanderPP) override;
39 void storeOptions(ClangTidyOptions::OptionMap &Opts) override;
40 bool isLanguageVersionSupported(const LangOptions &LangOpts) const override;
42 private:
43 include_cleaner::RecordedPP RecordedPreprocessor;
44 include_cleaner::PragmaIncludes RecordedPI;
45 HeaderSearch *HS;
46 std::vector<StringRef> IgnoreHeaders;
47 llvm::SmallVector<llvm::Regex> IgnoreHeadersRegex;
48 bool shouldIgnore(const include_cleaner::Header &H);
51 } // namespace clang::tidy::misc
53 #endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MISC_INCLUDECLEANER_H