22 #include "clang/AST/ASTConsumer.h" 23 #include "clang/AST/ASTContext.h" 24 #include "clang/AST/Decl.h" 25 #include "clang/ASTMatchers/ASTMatchFinder.h" 26 #include "clang/Config/config.h" 27 #include "clang/Format/Format.h" 28 #include "clang/Frontend/ASTConsumers.h" 29 #include "clang/Frontend/CompilerInstance.h" 30 #include "clang/Frontend/FrontendActions.h" 31 #include "clang/Frontend/FrontendDiagnostic.h" 32 #include "clang/Frontend/MultiplexConsumer.h" 33 #include "clang/Frontend/TextDiagnosticPrinter.h" 34 #include "clang/Lex/PPCallbacks.h" 35 #include "clang/Lex/Preprocessor.h" 36 #include "clang/Rewrite/Frontend/FixItRewriter.h" 37 #include "clang/Rewrite/Frontend/FrontendActions.h" 38 #if CLANG_ENABLE_STATIC_ANALYZER 39 #include "clang/StaticAnalyzer/Core/BugReporter/PathDiagnostic.h" 40 #include "clang/StaticAnalyzer/Frontend/AnalysisConsumer.h" 41 #endif // CLANG_ENABLE_STATIC_ANALYZER 42 #include "clang/Tooling/DiagnosticsYaml.h" 43 #include "clang/Tooling/Refactoring.h" 44 #include "clang/Tooling/ReplacementsYaml.h" 45 #include "clang/Tooling/Tooling.h" 46 #include "llvm/Support/Process.h" 47 #include "llvm/Support/Signals.h" 62 #if CLANG_ENABLE_STATIC_ANALYZER 63 static const char *AnalyzerCheckNamePrefix =
"clang-analyzer-";
65 class AnalyzerDiagnosticConsumer :
public ento::PathDiagnosticConsumer {
67 AnalyzerDiagnosticConsumer(ClangTidyContext &Context) : Context(Context) {}
69 void FlushDiagnosticsImpl(std::vector<const ento::PathDiagnostic *> &Diags,
70 FilesMade *filesMade)
override {
71 for (
const ento::PathDiagnostic *PD : Diags) {
72 SmallString<64> CheckName(AnalyzerCheckNamePrefix);
73 CheckName += PD->getCheckName();
74 Context.diag(CheckName, PD->getLocation().asLocation(),
75 PD->getShortDescription())
76 << PD->path.back()->getRanges();
78 for (
const auto &DiagPiece :
79 PD->path.flatten(
true)) {
80 Context.diag(CheckName, DiagPiece->getLocation().asLocation(),
81 DiagPiece->getString(), DiagnosticIDs::Note)
82 << DiagPiece->getRanges();
87 StringRef getName()
const override {
return "ClangTidyDiags"; }
88 bool supportsLogicalOpControlFlow()
const override {
return true; }
89 bool supportsCrossFileDiagnostics()
const override {
return true; }
92 ClangTidyContext &Context;
94 #endif // CLANG_ENABLE_STATIC_ANALYZER 98 ErrorReporter(ClangTidyContext &Context,
bool ApplyFixes,
99 llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem> BaseFS)
100 : Files(FileSystemOptions(), BaseFS), 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),
106 DiagOpts->ShowColors = llvm::sys::Process::StandardOutHasColors();
107 DiagPrinter->BeginSourceFile(LangOpts);
110 SourceManager &getSourceManager() {
return SourceMgr; }
112 void reportDiagnostic(
const ClangTidyError &Error) {
113 const tooling::DiagnosticMessage &
Message = Error.Message;
114 SourceLocation
Loc = getLocation(Message.FilePath, Message.FileOffset);
117 SmallVector<std::pair<SourceLocation, bool>, 4> FixLocations;
119 auto Level =
static_cast<DiagnosticsEngine::Level
>(Error.DiagLevel);
120 std::string
Name = Error.DiagnosticName;
121 if (Error.IsWarningAsError) {
122 Name +=
",-warnings-as-errors";
123 Level = DiagnosticsEngine::Error;
126 auto Diag = Diags.Report(Loc, Diags.getCustomDiagID(Level,
"%0 [%1]"))
127 << Message.Message << Name;
128 for (
const auto &FileAndReplacements : Error.Fix) {
129 for (
const auto &Repl : FileAndReplacements.second) {
130 SourceLocation FixLoc;
132 bool CanBeApplied =
false;
133 if (Repl.isApplicable()) {
134 SmallString<128> FixAbsoluteFilePath = Repl.getFilePath();
135 Files.makeAbsolutePath(FixAbsoluteFilePath);
137 tooling::Replacement R(FixAbsoluteFilePath, Repl.getOffset(),
139 Repl.getReplacementText());
140 Replacements &Replacements = FileReplacements[R.getFilePath()];
141 llvm::Error Err = Replacements.add(R);
144 llvm::errs() <<
"Trying to resolve conflict: " 147 Replacements.getShiftedCodePosition(R.getOffset());
148 unsigned NewLength = Replacements.getShiftedCodePosition(
149 R.getOffset() + R.getLength()) -
151 if (NewLength == R.getLength()) {
152 R = Replacement(R.getFilePath(), NewOffset, NewLength,
153 R.getReplacementText());
154 Replacements = Replacements.merge(tooling::Replacements(R));
159 <<
"Can't resolve conflict, skipping the replacement.\n";
167 FixLoc = getLocation(FixAbsoluteFilePath, Repl.getOffset());
168 SourceLocation FixEndLoc =
169 FixLoc.getLocWithOffset(Repl.getLength());
173 CharSourceRange
Range =
174 CharSourceRange::getCharRange(SourceRange(FixLoc, FixEndLoc));
175 Diag << FixItHint::CreateReplacement(Range,
176 Repl.getReplacementText());
180 FixLocations.push_back(std::make_pair(FixLoc, CanBeApplied));
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 (ApplyFixes && TotalFixes > 0) {
194 Rewriter Rewrite(SourceMgr, LangOpts);
195 for (
const auto &FileAndReplacements : FileReplacements) {
196 StringRef File = FileAndReplacements.first();
197 llvm::ErrorOr<std::unique_ptr<MemoryBuffer>> Buffer =
198 SourceMgr.getFileManager().getBufferForFile(File);
200 llvm::errs() <<
"Can't get buffer for file " << File <<
": " 201 << Buffer.getError().message() <<
"\n";
205 StringRef Code = Buffer.get()->getBuffer();
206 auto Style = format::getStyle(
207 *Context.getOptionsForFile(File).FormatStyle, File,
"none");
212 llvm::Expected<tooling::Replacements> Replacements =
213 format::cleanupAroundReplacements(Code, FileAndReplacements.second,
219 if (llvm::Expected<tooling::Replacements> FormattedReplacements =
220 format::formatReplacements(Code, *Replacements, *Style)) {
221 Replacements = std::move(FormattedReplacements);
223 llvm_unreachable(
"!Replacements");
226 <<
". Skipping formatting.\n";
228 if (!tooling::applyAllReplacements(Replacements.get(), Rewrite)) {
229 llvm::errs() <<
"Can't apply replacements for file " << File <<
"\n";
232 if (Rewrite.overwriteChangedFiles()) {
233 llvm::errs() <<
"clang-tidy failed to apply suggested fixes.\n";
235 llvm::errs() <<
"clang-tidy applied " << AppliedFixes <<
" of " 236 << TotalFixes <<
" suggested fixes.\n";
244 SourceLocation getLocation(StringRef FilePath,
unsigned Offset) {
245 if (FilePath.empty())
246 return SourceLocation();
248 const FileEntry *File = SourceMgr.getFileManager().getFile(FilePath);
249 FileID ID = SourceMgr.getOrCreateFileID(File, SrcMgr::C_User);
250 return SourceMgr.getLocForStartOfFile(ID).getLocWithOffset(Offset);
253 void reportNote(
const tooling::DiagnosticMessage &Message) {
254 SourceLocation Loc = getLocation(Message.FilePath, Message.FileOffset);
255 Diags.Report(Loc, Diags.getCustomDiagID(DiagnosticsEngine::Note,
"%0"))
260 LangOptions LangOpts;
261 IntrusiveRefCntPtr<DiagnosticOptions> DiagOpts;
263 DiagnosticsEngine Diags;
264 SourceManager SourceMgr;
265 llvm::StringMap<Replacements> FileReplacements;
266 ClangTidyContext &Context;
269 unsigned AppliedFixes;
275 ClangTidyASTConsumer(std::vector<std::unique_ptr<ASTConsumer>> Consumers,
276 std::unique_ptr<ClangTidyProfiling> Profiling,
277 std::unique_ptr<ast_matchers::MatchFinder> Finder,
278 std::vector<std::unique_ptr<ClangTidyCheck>>
Checks)
280 Profiling(std::move(Profiling)), Finder(std::move(Finder)),
286 std::unique_ptr<ClangTidyProfiling> Profiling;
287 std::unique_ptr<ast_matchers::MatchFinder> Finder;
288 std::vector<std::unique_ptr<ClangTidyCheck>>
Checks;
293 ClangTidyASTConsumerFactory::ClangTidyASTConsumerFactory(
296 for (ClangTidyModuleRegistry::iterator I = ClangTidyModuleRegistry::begin(),
297 E = ClangTidyModuleRegistry::end();
299 std::unique_ptr<ClangTidyModule> Module(I->instantiate());
300 Module->addCheckFactories(*CheckFactories);
304 #if CLANG_ENABLE_STATIC_ANALYZER 306 AnalyzerOptionsRef AnalyzerOptions) {
307 StringRef AnalyzerPrefix(AnalyzerCheckNamePrefix);
309 StringRef OptName(Opt.first);
310 if (!OptName.startswith(AnalyzerPrefix))
312 AnalyzerOptions->Config[OptName.substr(AnalyzerPrefix.size())] = Opt.second;
316 typedef std::vector<std::pair<std::string, bool>> CheckersList;
319 bool IncludeExperimental) {
322 const auto &RegisteredCheckers =
323 AnalyzerOptions::getRegisteredCheckers(IncludeExperimental);
324 bool AnalyzerChecksEnabled =
false;
325 for (StringRef CheckName : RegisteredCheckers) {
326 std::string ClangTidyCheckName((AnalyzerCheckNamePrefix + CheckName).str());
327 AnalyzerChecksEnabled |= Context.
isCheckEnabled(ClangTidyCheckName);
330 if (!AnalyzerChecksEnabled)
338 for (StringRef CheckName : RegisteredCheckers) {
339 std::string ClangTidyCheckName((AnalyzerCheckNamePrefix + CheckName).str());
341 if (CheckName.startswith(
"core") ||
343 List.emplace_back(CheckName,
true);
348 #endif // CLANG_ENABLE_STATIC_ANALYZER 350 std::unique_ptr<clang::ASTConsumer>
352 clang::CompilerInstance &Compiler, StringRef File) {
359 auto WorkingDir = Compiler.getSourceManager()
361 .getVirtualFileSystem()
362 ->getCurrentWorkingDirectory();
366 std::vector<std::unique_ptr<ClangTidyCheck>>
Checks;
367 CheckFactories->createChecks(&Context, Checks);
369 ast_matchers::MatchFinder::MatchFinderOptions FinderOptions;
371 std::unique_ptr<ClangTidyProfiling> Profiling;
373 Profiling = llvm::make_unique<ClangTidyProfiling>(
375 FinderOptions.CheckProfiling.emplace(Profiling->Records);
378 std::unique_ptr<ast_matchers::MatchFinder> Finder(
379 new ast_matchers::MatchFinder(std::move(FinderOptions)));
381 for (
auto &Check : Checks) {
382 Check->registerMatchers(&*Finder);
383 Check->registerPPCallbacks(Compiler);
386 std::vector<std::unique_ptr<ASTConsumer>> Consumers;
388 Consumers.push_back(Finder->newASTConsumer());
390 #if CLANG_ENABLE_STATIC_ANALYZER 391 AnalyzerOptionsRef AnalyzerOptions = Compiler.getAnalyzerOpts();
392 AnalyzerOptions->CheckersControlList =
394 if (!AnalyzerOptions->CheckersControlList.empty()) {
395 setStaticAnalyzerCheckerOpts(Context.
getOptions(), AnalyzerOptions);
396 AnalyzerOptions->AnalysisStoreOpt = RegionStoreModel;
397 AnalyzerOptions->AnalysisDiagOpt = PD_NONE;
398 AnalyzerOptions->AnalyzeNestedBlocks =
true;
399 AnalyzerOptions->eagerlyAssumeBinOpBifurcation =
true;
400 std::unique_ptr<ento::AnalysisASTConsumer> AnalysisConsumer =
401 ento::CreateAnalysisConsumer(Compiler);
402 AnalysisConsumer->AddDiagnosticConsumer(
403 new AnalyzerDiagnosticConsumer(Context));
404 Consumers.push_back(std::move(AnalysisConsumer));
406 #endif // CLANG_ENABLE_STATIC_ANALYZER 407 return llvm::make_unique<ClangTidyASTConsumer>(
408 std::move(Consumers), std::move(Profiling), std::move(Finder),
413 std::vector<std::string> CheckNames;
414 for (
const auto &CheckFactory : *CheckFactories) {
416 CheckNames.push_back(CheckFactory.first);
419 #if CLANG_ENABLE_STATIC_ANALYZER 420 for (
const auto &AnalyzerCheck : getCheckersControlList(
422 CheckNames.push_back(AnalyzerCheckNamePrefix + AnalyzerCheck.first);
423 #endif // CLANG_ENABLE_STATIC_ANALYZER 425 std::sort(CheckNames.begin(), CheckNames.end());
431 std::vector<std::unique_ptr<ClangTidyCheck>>
Checks;
432 CheckFactories->createChecks(&Context, Checks);
433 for (
const auto &Check : Checks)
434 Check->storeOptions(Options);
439 DiagnosticIDs::Level Level) {
440 return Context->
diag(CheckName, Loc, Message, Level);
443 void ClangTidyCheck::run(
const ast_matchers::MatchFinder::MatchResult &
Result) {
452 : NamePrefix(CheckName.str() +
"."), CheckOptions(CheckOptions) {}
455 const auto &Iter = CheckOptions.find(NamePrefix + LocalName.str());
456 if (Iter != CheckOptions.end())
462 StringRef Default)
const {
463 auto Iter = CheckOptions.find(NamePrefix + LocalName.str());
464 if (Iter != CheckOptions.end())
467 Iter = CheckOptions.find(LocalName.str());
468 if (Iter != CheckOptions.end())
474 StringRef LocalName, StringRef Value)
const {
475 Options[NamePrefix + LocalName.str()] = Value;
479 StringRef LocalName, int64_t Value)
const {
480 store(Options, LocalName, llvm::itostr(Value));
483 std::vector<std::string>
489 AllowEnablingAnalyzerAlphaCheckers);
500 AllowEnablingAnalyzerAlphaCheckers);
505 std::vector<ClangTidyError>
507 const CompilationDatabase &Compilations,
508 ArrayRef<std::string> InputFiles,
509 llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem> BaseFS,
511 ClangTool Tool(Compilations, InputFiles,
512 std::make_shared<PCHContainerOperations>(), BaseFS);
515 ArgumentsAdjuster PerFileExtraArgumentsInserter =
516 [&Context](
const CommandLineArguments &Args, StringRef
Filename) {
518 CommandLineArguments AdjustedArgs = Args;
520 auto I = AdjustedArgs.begin();
521 if (I != AdjustedArgs.end() && !StringRef(*I).startswith(
"-"))
527 AdjustedArgs.insert(AdjustedArgs.end(), Opts.
ExtraArgs->begin(),
532 Tool.appendArgumentsAdjuster(PerFileExtraArgumentsInserter);
533 Tool.appendArgumentsAdjuster(getStripPluginsAdjuster());
538 DiagnosticsEngine DE(
new DiagnosticIDs(),
new DiagnosticOptions(),
539 &DiagConsumer,
false);
541 Tool.setDiagnosticConsumer(&DiagConsumer);
543 class ActionFactory :
public FrontendActionFactory {
546 FrontendAction *create()
override {
return new Action(&ConsumerFactory); }
548 bool runInvocation(std::shared_ptr<CompilerInvocation> Invocation,
550 std::shared_ptr<PCHContainerOperations> PCHContainerOps,
555 Invocation->getFrontendOpts().ProgramAction = frontend::RunAnalysis;
556 return FrontendActionFactory::runInvocation(
557 Invocation, Files, PCHContainerOps, DiagConsumer);
561 class Action :
public ASTFrontendAction {
564 std::unique_ptr<ASTConsumer> CreateASTConsumer(CompilerInstance &Compiler,
565 StringRef File)
override {
576 ActionFactory Factory(Context);
578 return DiagConsumer.
take();
583 unsigned &WarningsAsErrorsCount,
584 llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem> BaseFS) {
585 ErrorReporter Reporter(Context, Fix, BaseFS);
586 llvm::vfs::FileSystem &FileSystem =
587 *Reporter.getSourceManager().getFileManager().getVirtualFileSystem();
588 auto InitialWorkingDir = FileSystem.getCurrentWorkingDirectory();
589 if (!InitialWorkingDir)
590 llvm::report_fatal_error(
"Cannot get current working path.");
593 if (!Error.BuildDirectory.empty()) {
598 FileSystem.setCurrentWorkingDirectory(Error.BuildDirectory);
600 Reporter.reportDiagnostic(Error);
602 FileSystem.setCurrentWorkingDirectory(InitialWorkingDir.get());
605 WarningsAsErrorsCount += Reporter.getWarningsAsErrorsCount();
609 const std::vector<ClangTidyError> &Errors,
611 TranslationUnitDiagnostics TUD;
612 TUD.MainSourceFile = MainFilePath;
613 for (
const auto &Error : Errors) {
614 tooling::Diagnostic Diag = Error;
615 TUD.Diagnostics.insert(TUD.Diagnostics.end(), Diag);
618 yaml::Output YAML(OS);
SourceLocation Loc
'#' location in the include directive
std::vector< std::string > getCheckNames()
Get the list of enabled checks.
std::string getLocalOrGlobal(StringRef LocalName, StringRef Default) const
Read a named option from the Context.
llvm::Optional< ArgList > ExtraArgs
Add extra compilation arguments to the end of the list.
void store(ClangTidyOptions::OptionMap &Options, StringRef LocalName, StringRef Value) const
Stores an option with the check-local name LocalName with string value Value to Options.
Some operations such as code completion produce a set of candidates.
bool canEnableAnalyzerAlphaCheckers() const
If the experimental alpha checkers from the static analyzer can be enabled.
std::string get(StringRef LocalName, StringRef Default) const
Read a named option from the Context.
ClangTidyOptions::OptionMap getCheckOptions()
Get the union of options from all checks.
bool isCheckEnabled(StringRef CheckName) const
Returns true if the check is enabled for the CurrentFile.
bool getEnableProfiling() const
static cl::opt< std::string > StoreCheckProfile("store-check-profile", cl::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 llvm::StringRef toString(SpecialMemberFunctionsCheck::SpecialMemberFunctionKind K)
static const StringRef Message
Contains options for clang-tidy.
std::vector< ClangTidyError > runClangTidy(clang::tidy::ClangTidyContext &Context, const CompilationDatabase &Compilations, ArrayRef< std::string > InputFiles, llvm::IntrusiveRefCntPtr< llvm::vfs::FileSystem > BaseFS, bool EnableCheckProfile, llvm::StringRef StoreCheckProfile)
ClangTidyOptions::OptionMap getCheckOptions(const ClangTidyOptions &Options, bool AllowEnablingAnalyzerAlphaCheckers)
Returns the effective check-specific options.
A collection of ClangTidyCheckFactory instances.
OptionMap CheckOptions
Key-value mapping used to store check-specific options.
void handleErrors(llvm::ArrayRef< ClangTidyError > Errors, ClangTidyContext &Context, bool Fix, unsigned &WarningsAsErrorsCount, llvm::IntrusiveRefCntPtr< llvm::vfs::FileSystem > BaseFS)
Displays the found Errors to the users.
llvm::Optional< ArgList > ExtraArgsBefore
Add extra compilation arguments to the start of the list.
void setCurrentFile(StringRef File)
Should be called when starting to process new translation unit.
std::string Filename
Filename as a string.
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.
DiagnosticBuilder diag(StringRef CheckName, SourceLocation Loc, StringRef Message, DiagnosticIDs::Level Level=DiagnosticIDs::Warning)
Report any errors detected using this method.
std::vector< ClangTidyError > take()
llvm::unique_function< void()> Action
llvm::Optional< ClangTidyProfiling::StorageParams > getProfileStorageParams() const
ClangTidyOptions getOptionsForFile(StringRef File) const
Returns options for File.
const ClangTidyOptions & getOptions() const
Returns options for CurrentFile.
void setASTContext(ASTContext *Context)
Sets ASTContext for the current translation unit.
static cl::opt< std::string > WarningsAsErrors("warnings-as-errors", cl::desc(R"(
Upgrades warnings to errors. Same format as
'-checks'.
This option's value is appended to the value of
the 'WarningsAsErrors' option in .clang-tidy
file, if any.
)"), cl::init(""), cl::cat(ClangTidyCategory))
A diagnostic consumer that turns each Diagnostic into a SourceManager-independent ClangTidyError...
static constexpr llvm::StringLiteral Name
std::map< std::string, std::string > OptionMap
llvm::Optional< llvm::Expected< tooling::AtomicChanges > > Result
void setProfileStoragePrefix(StringRef ProfilePrefix)
Control storage of profile date.
static cl::opt< bool > EnableCheckProfile("enable-check-profile", cl::desc(R"(
Enable per-check timing profiles, and print a
report to stderr.
)"), cl::init(false), cl::cat(ClangTidyCategory))
void setSourceManager(SourceManager *SourceMgr)
Sets the SourceManager of the used DiagnosticsEngine.
OptionsView(StringRef CheckName, const ClangTidyOptions::OptionMap &CheckOptions)
Initializes the instance using CheckName + "." as a prefix.
===– Representation.cpp - ClangDoc Representation --------—*- C++ -*-===//
void setDiagnosticsEngine(DiagnosticsEngine *DiagEngine)
Sets the DiagnosticsEngine that diag() will emit diagnostics to.
void exportReplacements(const llvm::StringRef MainFilePath, const std::vector< ClangTidyError > &Errors, raw_ostream &OS)
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.
CharSourceRange Range
SourceRange for the file name.
A detected error complete with information to display diagnostic and automatic fix.
static cl::opt< std::string > Checks("checks", cl::desc(R"(
Comma-separated list of globs with optional '-'
prefix. Globs are processed in order of
appearance in the list. Globs without '-'
prefix add checks with matching names to the
set, globs with the '-' prefix remove checks
with matching names from the set of enabled
checks. This option's value is appended to the
value of the 'Checks' option in .clang-tidy
file, if any.
)"), cl::init(""), cl::cat(ClangTidyCategory))
Every ClangTidyCheck reports errors through a DiagnosticsEngine provided by this context.
llvm::Registry< ClangTidyModule > ClangTidyModuleRegistry
std::unique_ptr< clang::ASTConsumer > CreateASTConsumer(clang::CompilerInstance &Compiler, StringRef File)
Returns an ASTConsumer that runs the specified clang-tidy checks.
static cl::opt< bool > Fix("fix", cl::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))
void setCurrentBuildDirectory(StringRef BuildDirectory)
Should be called when starting to process new translation unit.
void setEnableProfiling(bool Profile)
Control profile collection in clang-tidy.
DiagnosticBuilder diag(SourceLocation Loc, StringRef Description, DiagnosticIDs::Level Level=DiagnosticIDs::Warning)
Add a diagnostic with the check's name.