File indexing completed on 2026-05-10 08:36:22
0001
0002
0003
0004
0005
0006
0007
0008
0009 #ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_CLANGTIDY_H
0010 #define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_CLANGTIDY_H
0011
0012 #include "ClangTidyDiagnosticConsumer.h"
0013 #include "ClangTidyOptions.h"
0014 #include "llvm/ADT/StringSet.h"
0015 #include <memory>
0016 #include <vector>
0017
0018 namespace llvm {
0019 class raw_ostream;
0020 }
0021
0022 namespace clang {
0023
0024 class ASTConsumer;
0025 class CompilerInstance;
0026 namespace tooling {
0027 class CompilationDatabase;
0028 }
0029
0030 namespace tidy {
0031
0032 class ClangTidyCheckFactories;
0033
0034 class ClangTidyASTConsumerFactory {
0035 public:
0036 ClangTidyASTConsumerFactory(
0037 ClangTidyContext &Context,
0038 IntrusiveRefCntPtr<llvm::vfs::OverlayFileSystem> OverlayFS = nullptr);
0039
0040
0041 std::unique_ptr<clang::ASTConsumer>
0042 createASTConsumer(clang::CompilerInstance &Compiler, StringRef File);
0043
0044
0045 std::vector<std::string> getCheckNames();
0046
0047
0048 ClangTidyOptions::OptionMap getCheckOptions();
0049
0050 private:
0051 ClangTidyContext &Context;
0052 IntrusiveRefCntPtr<llvm::vfs::OverlayFileSystem> OverlayFS;
0053 std::unique_ptr<ClangTidyCheckFactories> CheckFactories;
0054 };
0055
0056
0057
0058 std::vector<std::string> getCheckNames(const ClangTidyOptions &Options,
0059 bool AllowEnablingAnalyzerAlphaCheckers);
0060
0061 struct ChecksAndOptions {
0062 llvm::StringSet<> Checks;
0063 llvm::StringSet<> Options;
0064 };
0065
0066 ChecksAndOptions
0067 getAllChecksAndOptions(bool AllowEnablingAnalyzerAlphaCheckers = true);
0068
0069
0070
0071
0072
0073
0074
0075 ClangTidyOptions::OptionMap
0076 getCheckOptions(const ClangTidyOptions &Options,
0077 bool AllowEnablingAnalyzerAlphaCheckers);
0078
0079
0080
0081
0082
0083
0084
0085
0086 std::vector<ClangTidyError>
0087 runClangTidy(clang::tidy::ClangTidyContext &Context,
0088 const tooling::CompilationDatabase &Compilations,
0089 ArrayRef<std::string> InputFiles,
0090 llvm::IntrusiveRefCntPtr<llvm::vfs::OverlayFileSystem> BaseFS,
0091 bool ApplyAnyFix, bool EnableCheckProfile = false,
0092 llvm::StringRef StoreCheckProfile = StringRef());
0093
0094
0095 enum FixBehaviour {
0096
0097 FB_NoFix,
0098
0099 FB_Fix,
0100
0101 FB_FixNotes
0102 };
0103
0104
0105
0106
0107
0108
0109
0110
0111 void handleErrors(llvm::ArrayRef<ClangTidyError> Errors,
0112 ClangTidyContext &Context, FixBehaviour Fix,
0113 unsigned &WarningsAsErrorsCount,
0114 llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem> BaseFS);
0115
0116
0117
0118 void exportReplacements(StringRef MainFilePath,
0119 const std::vector<ClangTidyError> &Errors,
0120 raw_ostream &OS);
0121
0122 }
0123 }
0124
0125 #endif