10 #include "../ClangTidy.h" 11 #include "../ClangTidyModule.h" 12 #include "clang/Frontend/CompilerInstance.h" 13 #include "clang/Frontend/FrontendPluginRegistry.h" 14 #include "clang/Frontend/MultiplexConsumer.h" 25 std::unique_ptr<ClangTidyContext> Context;
28 WrapConsumer(std::unique_ptr<ClangTidyContext> Context,
29 std::vector<std::unique_ptr<ASTConsumer>> Consumer)
35 StringRef
File)
override {
37 Context->setDiagnosticsEngine(&Compiler.getDiagnostics());
41 std::vector<std::unique_ptr<ASTConsumer>> Vec;
44 return llvm::make_unique<WrapConsumer>(std::move(Context), std::move(Vec));
48 const std::vector<std::string> &Args)
override {
55 for (StringRef Arg : Args)
56 if (Arg.startswith(
"-checks="))
57 OverrideOptions.
Checks = Arg.substr(strlen(
"-checks="));
59 auto Options = llvm::make_unique<FileOptionsProvider>(
60 GlobalOptions, DefaultOptions, OverrideOptions);
61 Context = llvm::make_unique<ClangTidyContext>(std::move(Options));
66 std::unique_ptr<ClangTidyContext> Context;
75 static clang::FrontendPluginRegistry::Add<clang::tidy::ClangTidyPluginAction>
76 X(
"clang-tidy",
"clang-tidy");
llvm::Optional< std::string > Checks
Checks filter.
volatile int GoogleModuleAnchorSource
volatile int ReadabilityModuleAnchorSource
bool ParseArgs(const CompilerInstance &, const std::vector< std::string > &Args) override
static int LLVM_ATTRIBUTE_UNUSED LLVMModuleAnchorDestination
Contains options for clang-tidy.
volatile int LLVMModuleAnchorSource
volatile int PerformanceModuleAnchorSource
volatile int ClangTidyPluginAnchorSource
volatile int CppCoreGuidelinesModuleAnchorSource
static int LLVM_ATTRIBUTE_UNUSED ObjCModuleAnchorDestination
static int LLVM_ATTRIBUTE_UNUSED ReadabilityModuleAnchorDestination
volatile int MPIModuleAnchorSource
volatile int CERTModuleAnchorSource
static ClangTidyModuleRegistry::Add< bugprone::BugproneModule > X("bugprone-module", "Adds checks for bugprone code constructs.")
static int LLVM_ATTRIBUTE_UNUSED GoogleModuleAnchorDestination
volatile int ObjCModuleAnchorSource
volatile int MiscModuleAnchorSource
static int LLVM_ATTRIBUTE_UNUSED PerformanceModuleAnchorDestination
static int LLVM_ATTRIBUTE_UNUSED MiscModuleAnchorDestination
static int LLVM_ATTRIBUTE_UNUSED CppCoreGuidelinesModuleAnchorDestination
static int LLVM_ATTRIBUTE_UNUSED ModernizeModuleAnchorDestination
std::unique_ptr< clang::ASTConsumer > CreateASTConsumer(clang::CompilerInstance &Compiler, StringRef File)
Returns an ASTConsumer that runs the specified clang-tidy checks.
volatile int ModernizeModuleAnchorSource
static int LLVM_ATTRIBUTE_UNUSED MPIModuleAnchorDestination
static int LLVM_ATTRIBUTE_UNUSED CERTModuleAnchorDestination
The core clang tidy plugin action.
std::unique_ptr< ASTConsumer > CreateASTConsumer(CompilerInstance &Compiler, StringRef File) override