23#include "clang-tidy-config.h"
24#include "clang/AST/ASTConsumer.h"
25#include "clang/ASTMatchers/ASTMatchFinder.h"
26#include "clang/Format/Format.h"
27#include "clang/Frontend/ASTConsumers.h"
28#include "clang/Frontend/CompilerInstance.h"
29#include "clang/Frontend/FrontendDiagnostic.h"
30#include "clang/Frontend/MultiplexConsumer.h"
31#include "clang/Frontend/TextDiagnosticPrinter.h"
32#include "clang/Lex/PPCallbacks.h"
33#include "clang/Lex/Preprocessor.h"
34#include "clang/Lex/PreprocessorOptions.h"
35#include "clang/Rewrite/Frontend/FixItRewriter.h"
36#include "clang/Rewrite/Frontend/FrontendActions.h"
37#include "clang/Tooling/Core/Diagnostic.h"
38#include "clang/Tooling/DiagnosticsYaml.h"
39#include "clang/Tooling/Refactoring.h"
40#include "clang/Tooling/ReplacementsYaml.h"
41#include "clang/Tooling/Tooling.h"
42#include "llvm/Support/Process.h"
46#if CLANG_TIDY_ENABLE_STATIC_ANALYZER
47#include "clang/Analysis/PathDiagnostic.h"
48#include "clang/StaticAnalyzer/Frontend/AnalysisConsumer.h"
52using namespace clang::driver;
61#if CLANG_TIDY_ENABLE_STATIC_ANALYZER
62static const char *AnalyzerCheckNamePrefix =
"clang-analyzer-";
64class AnalyzerDiagnosticConsumer :
public ento::PathDiagnosticConsumer {
66 AnalyzerDiagnosticConsumer(ClangTidyContext &Context) : Context(Context) {}
68 void FlushDiagnosticsImpl(std::vector<const ento::PathDiagnostic *> &Diags,
69 FilesMade *FilesMade)
override {
70 for (
const ento::PathDiagnostic *PD : Diags) {
71 SmallString<64> CheckName(AnalyzerCheckNamePrefix);
72 CheckName += PD->getCheckerName();
73 Context.diag(CheckName, PD->getLocation().asLocation(),
74 PD->getShortDescription())
75 << PD->path.back()->getRanges();
77 for (
const auto &DiagPiece :
78 PD->path.flatten(
true)) {
79 Context.diag(CheckName, DiagPiece->getLocation().asLocation(),
80 DiagPiece->getString(), DiagnosticIDs::Note)
81 << DiagPiece->getRanges();
86 StringRef getName()
const override {
return "ClangTidyDiags"; }
87 bool supportsLogicalOpControlFlow()
const override {
return true; }
88 bool supportsCrossFileDiagnostics()
const override {
return true; }
91 ClangTidyContext &Context;
97 ErrorReporter(ClangTidyContext &Context,
FixBehaviour ApplyFixes,
98 llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem> BaseFS)
99 : Files(FileSystemOptions(), std::move(BaseFS)),
100 DiagOpts(new DiagnosticOptions()),
101 DiagPrinter(new TextDiagnosticPrinter(
llvm::outs(), &*DiagOpts)),
102 Diags(IntrusiveRefCntPtr<DiagnosticIDs>(new DiagnosticIDs), &*DiagOpts,
104 SourceMgr(Diags, Files), Context(Context), ApplyFixes(ApplyFixes) {
105 DiagOpts->ShowColors = Context.getOptions().UseColor.value_or(
106 llvm::sys::Process::StandardOutHasColors());
107 DiagPrinter->BeginSourceFile(LangOpts);
108 if (DiagOpts->ShowColors && !llvm::sys::Process::StandardOutIsDisplayed()) {
109 llvm::sys::Process::UseANSIEscapeCodes(
true);
113 SourceManager &getSourceManager() {
return SourceMgr; }
116 const tooling::DiagnosticMessage &
Message =
Error.Message;
120 SmallVector<std::pair<SourceLocation, bool>, 4> FixLocations;
122 auto Level =
static_cast<DiagnosticsEngine::Level
>(
Error.DiagLevel);
124 if (!
Error.EnabledDiagnosticAliases.empty())
125 Name +=
"," + llvm::join(
Error.EnabledDiagnosticAliases,
",");
126 if (
Error.IsWarningAsError) {
127 Name +=
",-warnings-as-errors";
128 Level = DiagnosticsEngine::Error;
131 auto Diag = Diags.Report(
Loc, Diags.getCustomDiagID(Level,
"%0 [%1]"))
133 for (
const FileByteRange &FBR :
Error.Message.Ranges)
134 Diag << getRange(FBR);
136 const llvm::StringMap<Replacements> *ChosenFix =
nullptr;
139 for (
const auto &FileAndReplacements : *ChosenFix) {
140 for (
const auto &Repl : FileAndReplacements.second) {
142 bool CanBeApplied =
false;
143 if (!Repl.isApplicable())
145 SourceLocation FixLoc;
146 SmallString<128> FixAbsoluteFilePath = Repl.getFilePath();
147 Files.makeAbsolutePath(FixAbsoluteFilePath);
148 tooling::Replacement R(FixAbsoluteFilePath, Repl.getOffset(),
149 Repl.getLength(), Repl.getReplacementText());
150 auto &
Entry = FileReplacements[R.getFilePath()];
151 Replacements &Replacements =
Entry.Replaces;
152 llvm::Error Err = Replacements.add(R);
155 llvm::errs() <<
"Trying to resolve conflict: "
156 << llvm::toString(std::move(Err)) <<
"\n";
158 Replacements.getShiftedCodePosition(R.getOffset());
159 unsigned NewLength = Replacements.getShiftedCodePosition(
160 R.getOffset() + R.getLength()) -
162 if (NewLength == R.getLength()) {
163 R = Replacement(R.getFilePath(), NewOffset, NewLength,
164 R.getReplacementText());
165 Replacements = Replacements.merge(tooling::Replacements(R));
170 <<
"Can't resolve conflict, skipping the replacement.\n";
176 FixLoc = getLocation(FixAbsoluteFilePath, Repl.getOffset());
177 FixLocations.push_back(std::make_pair(FixLoc, CanBeApplied));
182 reportFix(Diag,
Error.Message.Fix);
184 for (
auto Fix : FixLocations) {
185 Diags.Report(
Fix.first,
Fix.second ? diag::note_fixit_applied
186 : diag::note_fixit_failed);
188 for (
const auto &Note :
Error.Notes)
193 if (TotalFixes > 0) {
194 auto &VFS = Files.getVirtualFileSystem();
195 auto OriginalCWD = VFS.getCurrentWorkingDirectory();
196 bool AnyNotWritten =
false;
198 for (
const auto &FileAndReplacements : FileReplacements) {
199 Rewriter Rewrite(SourceMgr, LangOpts);
200 StringRef File = FileAndReplacements.first();
201 VFS.setCurrentWorkingDirectory(FileAndReplacements.second.BuildDir);
202 llvm::ErrorOr<std::unique_ptr<MemoryBuffer>> Buffer =
203 SourceMgr.getFileManager().getBufferForFile(File);
205 llvm::errs() <<
"Can't get buffer for file " << File <<
": "
206 << Buffer.getError().message() <<
"\n";
210 StringRef
Code = Buffer.get()->getBuffer();
211 auto Style = format::getStyle(
212 *Context.getOptionsForFile(File).FormatStyle, File,
"none");
214 llvm::errs() << llvm::toString(Style.takeError()) <<
"\n";
217 llvm::Expected<tooling::Replacements> Replacements =
218 format::cleanupAroundReplacements(
219 Code, FileAndReplacements.second.Replaces, *Style);
221 llvm::errs() << llvm::toString(Replacements.takeError()) <<
"\n";
224 if (llvm::Expected<tooling::Replacements> FormattedReplacements =
225 format::formatReplacements(
Code, *Replacements, *Style)) {
226 Replacements = std::move(FormattedReplacements);
228 llvm_unreachable(
"!Replacements");
230 llvm::errs() << llvm::toString(FormattedReplacements.takeError())
231 <<
". Skipping formatting.\n";
233 if (!tooling::applyAllReplacements(Replacements.get(), Rewrite)) {
234 llvm::errs() <<
"Can't apply replacements for file " << File <<
"\n";
236 AnyNotWritten |= Rewrite.overwriteChangedFiles();
240 llvm::errs() <<
"clang-tidy failed to apply suggested fixes.\n";
242 llvm::errs() <<
"clang-tidy applied " << AppliedFixes <<
" of "
243 << TotalFixes <<
" suggested fixes.\n";
247 VFS.setCurrentWorkingDirectory(*OriginalCWD);
251 unsigned getWarningsAsErrorsCount()
const {
return WarningsAsErrors; }
254 SourceLocation getLocation(StringRef FilePath,
unsigned Offset) {
255 if (FilePath.empty())
258 auto File = SourceMgr.getFileManager().getOptionalFileRef(FilePath);
262 FileID
ID = SourceMgr.getOrCreateFileID(*File, SrcMgr::C_User);
263 return SourceMgr.getLocForStartOfFile(
ID).getLocWithOffset(
Offset);
266 void reportFix(
const DiagnosticBuilder &Diag,
267 const llvm::StringMap<Replacements> &
Fix) {
268 for (
const auto &FileAndReplacements :
Fix) {
269 for (
const auto &Repl : FileAndReplacements.second) {
270 if (!Repl.isApplicable())
273 FBR.FilePath = Repl.getFilePath().str();
274 FBR.FileOffset = Repl.getOffset();
275 FBR.Length = Repl.getLength();
277 Diag << FixItHint::CreateReplacement(getRange(FBR),
278 Repl.getReplacementText());
283 void reportNote(
const tooling::DiagnosticMessage &Message) {
286 Diags.Report(
Loc, Diags.getCustomDiagID(DiagnosticsEngine::Note,
"%0"))
288 for (
const FileByteRange &FBR :
Message.Ranges)
289 Diag << getRange(FBR);
293 CharSourceRange getRange(
const FileByteRange &Range) {
294 SmallString<128> AbsoluteFilePath{
Range.FilePath};
295 Files.makeAbsolutePath(AbsoluteFilePath);
296 SourceLocation BeginLoc = getLocation(AbsoluteFilePath,
Range.FileOffset);
297 SourceLocation EndLoc = BeginLoc.getLocWithOffset(
Range.Length);
301 return CharSourceRange::getCharRange(BeginLoc, EndLoc);
304 struct ReplacementsWithBuildDir {
310 LangOptions LangOpts;
311 IntrusiveRefCntPtr<DiagnosticOptions> DiagOpts;
313 DiagnosticsEngine Diags;
314 SourceManager SourceMgr;
315 llvm::StringMap<ReplacementsWithBuildDir> FileReplacements;
316 ClangTidyContext &Context;
318 unsigned TotalFixes = 0U;
319 unsigned AppliedFixes = 0U;
320 unsigned WarningsAsErrors = 0U;
325 ClangTidyASTConsumer(std::vector<std::unique_ptr<ASTConsumer>> Consumers,
326 std::unique_ptr<ClangTidyProfiling> Profiling,
327 std::unique_ptr<ast_matchers::MatchFinder> Finder,
328 std::vector<std::unique_ptr<ClangTidyCheck>> Checks)
330 Profiling(std::move(Profiling)), Finder(std::move(Finder)),
331 Checks(std::move(Checks)) {}
336 std::unique_ptr<ClangTidyProfiling> Profiling;
337 std::unique_ptr<ast_matchers::MatchFinder> Finder;
338 std::vector<std::unique_ptr<ClangTidyCheck>> Checks;
345 IntrusiveRefCntPtr<llvm::vfs::OverlayFileSystem> OverlayFS)
346 : Context(Context), OverlayFS(std::move(OverlayFS)),
348 for (ClangTidyModuleRegistry::entry
E : ClangTidyModuleRegistry::entries()) {
349 std::unique_ptr<ClangTidyModule> Module =
E.instantiate();
350 Module->addCheckFactories(*CheckFactories);
354#if CLANG_TIDY_ENABLE_STATIC_ANALYZER
357 clang::AnalyzerOptions &AnalyzerOptions) {
358 StringRef AnalyzerPrefix(AnalyzerCheckNamePrefix);
359 for (
const auto &Opt : Opts.CheckOptions) {
360 StringRef OptName(Opt.getKey());
361 if (!OptName.consume_front(AnalyzerPrefix))
364 AnalyzerOptions.Config[OptName] = Opt.getValue().Value;
368using CheckersList = std::vector<std::pair<std::string, bool>>;
370static CheckersList getAnalyzerCheckersAndPackages(ClangTidyContext &Context,
371 bool IncludeExperimental) {
374 const auto &RegisteredCheckers =
375 AnalyzerOptions::getRegisteredCheckers(IncludeExperimental);
376 const bool AnalyzerChecksEnabled =
377 llvm::any_of(RegisteredCheckers, [&](StringRef CheckName) ->
bool {
378 return Context.isCheckEnabled(
379 (AnalyzerCheckNamePrefix + CheckName).str());
382 if (!AnalyzerChecksEnabled)
390 for (StringRef CheckName : RegisteredCheckers) {
391 std::string ClangTidyCheckName((AnalyzerCheckNamePrefix + CheckName).str());
393 if (CheckName.starts_with(
"core") ||
394 Context.isCheckEnabled(ClangTidyCheckName)) {
395 List.emplace_back(std::string(CheckName),
true);
402std::unique_ptr<clang::ASTConsumer>
404 clang::CompilerInstance &Compiler, StringRef File) {
407 SourceManager *SM = &Compiler.getSourceManager();
408 Context.setSourceManager(SM);
409 Context.setCurrentFile(File);
410 Context.setASTContext(&Compiler.getASTContext());
412 auto WorkingDir = Compiler.getSourceManager()
414 .getVirtualFileSystem()
415 .getCurrentWorkingDirectory();
417 Context.setCurrentBuildDirectory(WorkingDir.get());
419 std::vector<std::unique_ptr<ClangTidyCheck>> Checks =
420 CheckFactories->createChecksForLanguage(&Context);
422 ast_matchers::MatchFinder::MatchFinderOptions FinderOptions;
424 std::unique_ptr<ClangTidyProfiling> Profiling;
425 if (Context.getEnableProfiling()) {
426 Profiling = std::make_unique<ClangTidyProfiling>(
427 Context.getProfileStorageParams());
428 FinderOptions.CheckProfiling.emplace(Profiling->Records);
431 std::unique_ptr<ast_matchers::MatchFinder> Finder(
432 new ast_matchers::MatchFinder(std::move(FinderOptions)));
434 Preprocessor *PP = &Compiler.getPreprocessor();
435 Preprocessor *ModuleExpanderPP = PP;
437 if (Context.canEnableModuleHeadersParsing() &&
438 Context.getLangOpts().Modules && OverlayFS !=
nullptr) {
439 auto ModuleExpander = std::make_unique<ExpandModularHeadersPPCallbacks>(
440 &Compiler, OverlayFS);
441 ModuleExpanderPP = ModuleExpander->getPreprocessor();
442 PP->addPPCallbacks(std::move(ModuleExpander));
445 for (
auto &Check : Checks) {
446 Check->registerMatchers(&*Finder);
447 Check->registerPPCallbacks(*SM, PP, ModuleExpanderPP);
450 std::vector<std::unique_ptr<ASTConsumer>> Consumers;
452 Consumers.push_back(Finder->newASTConsumer());
454#if CLANG_TIDY_ENABLE_STATIC_ANALYZER
455 AnalyzerOptions &AnalyzerOptions = Compiler.getAnalyzerOpts();
456 AnalyzerOptions.CheckersAndPackages = getAnalyzerCheckersAndPackages(
457 Context, Context.canEnableAnalyzerAlphaCheckers());
458 if (!AnalyzerOptions.CheckersAndPackages.empty()) {
459 setStaticAnalyzerCheckerOpts(Context.getOptions(), AnalyzerOptions);
460 AnalyzerOptions.AnalysisDiagOpt = PD_NONE;
461 AnalyzerOptions.eagerlyAssumeBinOpBifurcation =
true;
462 std::unique_ptr<ento::AnalysisASTConsumer> AnalysisConsumer =
463 ento::CreateAnalysisConsumer(Compiler);
464 AnalysisConsumer->AddDiagnosticConsumer(
465 new AnalyzerDiagnosticConsumer(Context));
466 Consumers.push_back(std::move(AnalysisConsumer));
469 return std::make_unique<ClangTidyASTConsumer>(
470 std::move(Consumers), std::move(Profiling), std::move(Finder),
475 std::vector<std::string> CheckNames;
476 for (
const auto &CheckFactory : *CheckFactories) {
477 if (Context.isCheckEnabled(CheckFactory.getKey()))
478 CheckNames.emplace_back(CheckFactory.getKey());
481#if CLANG_TIDY_ENABLE_STATIC_ANALYZER
482 for (
const auto &AnalyzerCheck : getAnalyzerCheckersAndPackages(
483 Context, Context.canEnableAnalyzerAlphaCheckers()))
484 CheckNames.push_back(AnalyzerCheckNamePrefix + AnalyzerCheck.first);
487 llvm::sort(CheckNames);
493 std::vector<std::unique_ptr<ClangTidyCheck>> Checks =
494 CheckFactories->createChecks(&Context);
495 for (
const auto &Check : Checks)
496 Check->storeOptions(Options);
500std::vector<std::string>
519 DiagnosticsEngine DE(llvm::makeIntrusiveRefCnt<DiagnosticIDs>(),
520 llvm::makeIntrusiveRefCnt<DiagnosticOptions>(),
522 Context.setDiagnosticsEngine(&DE);
527std::vector<ClangTidyError>
529 const CompilationDatabase &Compilations,
530 ArrayRef<std::string> InputFiles,
531 llvm::IntrusiveRefCntPtr<llvm::vfs::OverlayFileSystem> BaseFS,
534 ClangTool Tool(Compilations, InputFiles,
535 std::make_shared<PCHContainerOperations>(), BaseFS);
538 ArgumentsAdjuster PerFileExtraArgumentsInserter =
539 [&Context](
const CommandLineArguments &
Args, StringRef
Filename) {
541 CommandLineArguments AdjustedArgs =
Args;
542 if (Opts.ExtraArgsBefore) {
543 auto I = AdjustedArgs.begin();
544 if (I != AdjustedArgs.end() && !StringRef(*I).starts_with(
"-"))
546 AdjustedArgs.insert(I, Opts.ExtraArgsBefore->begin(),
547 Opts.ExtraArgsBefore->end());
550 AdjustedArgs.insert(AdjustedArgs.end(), Opts.ExtraArgs->begin(),
551 Opts.ExtraArgs->end());
555 Tool.appendArgumentsAdjuster(PerFileExtraArgumentsInserter);
556 Tool.appendArgumentsAdjuster(getStripPluginsAdjuster());
561 DiagnosticsEngine DE(
new DiagnosticIDs(),
new DiagnosticOptions(),
563 Context.setDiagnosticsEngine(&DE);
569 IntrusiveRefCntPtr<llvm::vfs::OverlayFileSystem> BaseFS)
570 : ConsumerFactory(Context, std::move(BaseFS)) {}
571 std::unique_ptr<FrontendAction> create()
override {
572 return std::make_unique<Action>(&ConsumerFactory);
575 bool runInvocation(std::shared_ptr<CompilerInvocation> Invocation,
577 std::shared_ptr<PCHContainerOperations> PCHContainerOps,
580 Invocation->getPreprocessorOpts().SetUpStaticAnalyzer =
true;
581 return FrontendActionFactory::runInvocation(
586 class Action :
public ASTFrontendAction {
589 std::unique_ptr<ASTConsumer> CreateASTConsumer(CompilerInstance &Compiler,
590 StringRef File)
override {
601 ActionFactory Factory(Context, std::move(BaseFS));
608 unsigned &WarningsAsErrorsCount,
609 llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem> BaseFS) {
610 ErrorReporter Reporter(Context,
Fix, std::move(BaseFS));
611 llvm::vfs::FileSystem &FileSystem =
612 Reporter.getSourceManager().getFileManager().getVirtualFileSystem();
613 auto InitialWorkingDir = FileSystem.getCurrentWorkingDirectory();
614 if (!InitialWorkingDir)
615 llvm::report_fatal_error(
"Cannot get current working path.");
618 if (!
Error.BuildDirectory.empty()) {
623 FileSystem.setCurrentWorkingDirectory(
Error.BuildDirectory);
625 Reporter.reportDiagnostic(
Error);
627 FileSystem.setCurrentWorkingDirectory(InitialWorkingDir.get());
630 WarningsAsErrorsCount += Reporter.getWarningsAsErrorsCount();
634 const std::vector<ClangTidyError> &Errors,
636 TranslationUnitDiagnostics TUD;
637 TUD.MainSourceFile = std::string(MainFilePath);
638 for (
const auto &
Error : Errors) {
639 tooling::Diagnostic Diag =
Error;
640 if (
Error.IsWarningAsError)
641 Diag.DiagLevel = tooling::Diagnostic::Error;
642 TUD.Diagnostics.insert(TUD.Diagnostics.end(), Diag);
645 yaml::Output YAML(
OS);
658 for (
const ClangTidyModuleRegistry::entry &Module :
659 ClangTidyModuleRegistry::entries()) {
660 Module.instantiate()->addCheckFactories(Factories);
663 for (
const auto &Factory : Factories)
664 Result.Names.insert(Factory.getKey());
666#if CLANG_TIDY_ENABLE_STATIC_ANALYZER
667 SmallString<64> Buffer(AnalyzerCheckNamePrefix);
668 size_t DefSize = Buffer.size();
669 for (
const auto &AnalyzerCheck : AnalyzerOptions::getRegisteredCheckers(
671 Buffer.truncate(DefSize);
672 Buffer.append(AnalyzerCheck);
673 Result.Names.insert(Buffer);
677 Context.setOptionsCollector(&Result.Options);
678 for (
const auto &Factory : Factories) {
679 Factory.getValue()(Factory.getKey(), &Context);
llvm::SmallString< 256U > Name
static cl::opt< bool > EnableCheckProfile("enable-check-profile", desc(R"(
Enable per-check timing profiles, and print a
report to stderr.
)"), cl::init(false), cl::cat(ClangTidyCategory))
static cl::opt< bool > Fix("fix", desc(R"(
Apply suggested fixes. Without -fix-errors
clang-tidy will bail out if any compilation
errors were found.
)"), cl::init(false), cl::cat(ClangTidyCategory))
static cl::opt< bool > AllowEnablingAnalyzerAlphaCheckers("allow-enabling-analyzer-alpha-checkers", cl::init(false), cl::Hidden, cl::cat(ClangTidyCategory))
This option allows enabling the experimental alpha checkers from the static analyzer.
static cl::opt< std::string > StoreCheckProfile("store-check-profile", desc(R"(
By default reports are printed in tabulated
format to stderr. When this option is passed,
these per-TU profiles are instead stored as JSON.
)"), cl::value_desc("prefix"), cl::cat(ClangTidyCategory))
static constexpr llvm::SourceMgr::DiagKind Error
CharSourceRange Range
SourceRange for the file name.
std::string Filename
Filename as a string.
DiagnosticConsumer DiagConsumer
llvm::raw_string_ostream OS
std::unique_ptr< clang::ASTConsumer > createASTConsumer(clang::CompilerInstance &Compiler, StringRef File)
Returns an ASTConsumer that runs the specified clang-tidy checks.
ClangTidyOptions::OptionMap getCheckOptions()
Get the union of options from all checks.
ClangTidyASTConsumerFactory(ClangTidyContext &Context, IntrusiveRefCntPtr< llvm::vfs::OverlayFileSystem > OverlayFS=nullptr)
std::vector< std::string > getCheckNames()
Get the list of enabled checks.
A collection of ClangTidyCheckFactory instances.
Every ClangTidyCheck reports errors through a DiagnosticsEngine provided by this context.
A diagnostic consumer that turns each Diagnostic into a SourceManager-independent ClangTidyError.
void reportDiagnostic(DiagnosticBuilder D, const T *Node, SourceRange SR, bool DefaultConstruction)
constexpr llvm::StringLiteral Message
const llvm::StringMap< tooling::Replacements > * getFixIt(const tooling::Diagnostic &Diagnostic, bool AnyFix)
Gets the Fix attached to Diagnostic.
std::vector< std::string > getCheckNames(const ClangTidyOptions &Options, bool AllowEnablingAnalyzerAlphaCheckers)
Fills the list of check names that are enabled when the provided filters are applied.
FixBehaviour
Controls what kind of fixes clang-tidy is allowed to apply.
@ FB_NoFix
Don't try to apply any fix.
@ FB_FixNotes
Apply fixes found in notes.
ClangTidyOptions::OptionMap getCheckOptions(const ClangTidyOptions &Options, bool AllowEnablingAnalyzerAlphaCheckers)
Returns the effective check-specific options.
void handleErrors(llvm::ArrayRef< ClangTidyError > Errors, ClangTidyContext &Context, FixBehaviour Fix, unsigned &WarningsAsErrorsCount, llvm::IntrusiveRefCntPtr< llvm::vfs::FileSystem > BaseFS)
Displays the found Errors to the users.
std::vector< ClangTidyError > runClangTidy(clang::tidy::ClangTidyContext &Context, const CompilationDatabase &Compilations, ArrayRef< std::string > InputFiles, llvm::IntrusiveRefCntPtr< llvm::vfs::OverlayFileSystem > BaseFS, bool ApplyAnyFix, bool EnableCheckProfile, llvm::StringRef StoreCheckProfile)
NamesAndOptions getAllChecksAndOptions(bool AllowEnablingAnalyzerAlphaCheckers)
llvm::Registry< ClangTidyModule > ClangTidyModuleRegistry
void exportReplacements(const llvm::StringRef MainFilePath, const std::vector< ClangTidyError > &Errors, raw_ostream &OS)
Some operations such as code completion produce a set of candidates.
A detected error complete with information to display diagnostic and automatic fix.
Contains options for clang-tidy.
llvm::StringMap< ClangTidyValue > OptionMap