10 #ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_CLANGTIDYDIAGNOSTICCONSUMER_H
11 #define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_CLANGTIDYDIAGNOSTICCONSUMER_H
14 #include "clang/Basic/Diagnostic.h"
15 #include "clang/Basic/SourceManager.h"
16 #include "clang/Tooling/Refactoring.h"
17 #include "llvm/ADT/DenseMap.h"
18 #include "llvm/ADT/StringMap.h"
19 #include "llvm/Support/Regex.h"
20 #include "llvm/Support/Timer.h"
25 class CompilerInstance;
26 namespace ast_matchers {
30 class CompilationDatabase;
57 Error = DiagnosticsEngine::Error
64 tooling::Replacements
Fix;
65 SmallVector<ClangTidyMessage, 1>
Notes;
84 bool contains(StringRef S,
bool Contains);
88 std::unique_ptr<GlobList> NextGlob;
127 ClangTidyContext(std::unique_ptr<ClangTidyOptionsProvider> OptionsProvider);
134 DiagnosticBuilder
diag(StringRef CheckName, SourceLocation
Loc,
136 DiagnosticIDs::Level Level = DiagnosticIDs::Warning);
184 const std::vector<ClangTidyError> &
getErrors()
const {
return Errors; }
202 void setDiagnosticsEngine(DiagnosticsEngine *Engine);
207 std::vector<ClangTidyError> Errors;
208 DiagnosticsEngine *DiagEngine;
209 std::unique_ptr<ClangTidyOptionsProvider> OptionsProvider;
211 std::string CurrentFile;
213 std::unique_ptr<GlobList> CheckFilter;
219 llvm::DenseMap<unsigned, std::string> CheckNamesByDiagnosticID;
237 const Diagnostic &Info)
override;
243 void finalizeLastError();
245 void removeIncompatibleErrors(SmallVectorImpl<ClangTidyError> &Errors)
const;
249 llvm::Regex *getHeaderFilter();
253 void checkFilters(SourceLocation
Location);
254 bool passesLineFilter(StringRef FileName,
unsigned LineNumber)
const;
257 std::unique_ptr<DiagnosticsEngine> Diags;
258 SmallVector<ClangTidyError, 8> Errors;
259 std::unique_ptr<llvm::Regex> HeaderFilter;
260 bool LastErrorRelatesToUserCode;
261 bool LastErrorPassesLineFilter;
267 #endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_CLANGTIDYDIAGNOSTICCONSUMER_H
SourceLocation Loc
'#' location in the include directive
Read-only set of strings represented as a list of positive and negative globs.
GlobList(StringRef Globs)
GlobList is a comma-separated list of globs (only '*' metacharacter is supported) with optional '-' p...
void finish() override
Flushes the internal diagnostics buffer to the ClangTidyContext.
bool contains(StringRef S)
Returns true if the pattern matches S.
A message from a clang-tidy check.
ClangTidyMessage(StringRef Message="")
Contains options for clang-tidy.
unsigned ErrorsIgnoredCheckFilter
ClangTidyDiagnosticConsumer(ClangTidyContext &Ctx)
ProfileData * getCheckProfileData() const
llvm::StringMap< llvm::TimeRecord > Records
unsigned ErrorsIgnoredNOLINT
StringRef getCurrentFile() const
Returns the main file name of the current translation unit.
const std::vector< ClangTidyError > & getErrors() const
Returns all collected errors.
SmallVector< ClangTidyMessage, 1 > Notes
ClangTidyOptions getOptionsForFile(StringRef File) const
Returns options for File.
LangOptions getLangOpts() const
Gets the language options from the AST context.
void setCurrentFile(StringRef File)
Should be called when starting to process new translation unit.
const ClangTidyOptions & getOptions() const
Returns options for CurrentFile.
DiagnosticBuilder diag(StringRef CheckName, SourceLocation Loc, StringRef Message, DiagnosticIDs::Level Level=DiagnosticIDs::Warning)
Report any errors detected using this method.
unsigned ErrorsIgnoredNonUserCode
void setCheckProfileData(ProfileData *Profile)
Set the output struct for profile data.
ClangTidyContext(std::unique_ptr< ClangTidyOptionsProvider > OptionsProvider)
Initializes ClangTidyContext instance.
void setASTContext(ASTContext *Context)
Sets ASTContext for the current translation unit.
A diagnostic consumer that turns each Diagnostic into a SourceManager-independent ClangTidyError...
unsigned ErrorsIgnoredLineFilter
ClangTidyError(StringRef CheckName, Level DiagLevel)
const ClangTidyGlobalOptions & getGlobalOptions() const
Returns global options.
void setSourceManager(SourceManager *SourceMgr)
Sets the SourceManager of the used DiagnosticsEngine.
void clearErrors()
Clears collected errors.
const ClangTidyStats & getStats() const
Returns ClangTidyStats containing issued and ignored diagnostic counters.
unsigned errorsIgnored() const
StringRef getCheckName(unsigned DiagnosticID) const
Returns the name of the clang-tidy check which produced this diagnostic ID.
A detected error complete with information to display diagnostic and automatic fix.
Contains displayed and ignored diagnostic counters for a ClangTidy run.
ClangTidyContext & Context
Every ClangTidyCheck reports errors through a DiagnosticsEngine provided by this context.
tooling::Replacements Fix
void HandleDiagnostic(DiagnosticsEngine::Level DiagLevel, const Diagnostic &Info) override
bool isCheckEnabled(StringRef CheckName) const
Returns true if the check name is enabled for the CurrentFile.
GlobList & getChecksFilter()
Returns check filter for the CurrentFile.
Container for clang-tidy profiling data.