9#include "../ClangTidy.h"
10#include "../ClangTidyDiagnosticConsumer.h"
11#include "../ClangTidyForceLinker.h"
12#include "../ClangTidyModule.h"
13#include "clang/Frontend/CompilerInstance.h"
14#include "clang/Frontend/FrontendPluginRegistry.h"
15#include "clang/Frontend/MultiplexConsumer.h"
26 std::unique_ptr<ClangTidyContext> Context;
27 std::unique_ptr<DiagnosticsEngine> DiagEngine;
30 WrapConsumer(std::unique_ptr<ClangTidyContext> Context,
31 std::unique_ptr<DiagnosticsEngine> DiagEngine,
32 std::vector<std::unique_ptr<ASTConsumer>> Consumer)
34 DiagEngine(std::move(DiagEngine)) {}
39 StringRef File)
override {
43 auto DiagEngine = std::make_unique<DiagnosticsEngine>(
45 Context->setDiagnosticsEngine(DiagEngine.get());
49 std::vector<std::unique_ptr<ASTConsumer>> Vec;
52 return std::make_unique<WrapConsumer>(
53 std::move(Context), std::move(DiagEngine), std::move(Vec));
57 const std::vector<std::string> &
Args)
override {
64 for (StringRef Arg :
Args)
65 if (Arg.starts_with(
"-checks="))
66 OverrideOptions.
Checks = std::string(Arg.substr(strlen(
"-checks=")));
68 auto Options = std::make_unique<FileOptionsProvider>(
69 GlobalOptions, DefaultOptions, OverrideOptions);
70 Context = std::make_unique<ClangTidyContext>(std::move(Options));
75 std::unique_ptr<ClangTidyContext> Context;
83static clang::FrontendPluginRegistry::Add<clang::tidy::ClangTidyPluginAction>
84 X(
"clang-tidy",
"clang-tidy");
volatile int ClangTidyPluginAnchorSource
DiagnosticConsumer DiagConsumer
std::unique_ptr< clang::ASTConsumer > createASTConsumer(clang::CompilerInstance &Compiler, StringRef File)
Returns an ASTConsumer that runs the specified clang-tidy checks.
A diagnostic consumer that turns each Diagnostic into a SourceManager-independent ClangTidyError.
The core clang tidy plugin action.
std::unique_ptr< ASTConsumer > CreateASTConsumer(CompilerInstance &Compiler, StringRef File) override
bool ParseArgs(const CompilerInstance &, const std::vector< std::string > &Args) override
Contains options for clang-tidy.
std::optional< std::string > Checks
Checks filter.