clang-tools
9.0.0
|
Every ClangTidyCheck
reports errors through a DiagnosticsEngine
provided by this context.
More...
#include <ClangTidyDiagnosticConsumer.h>
Classes | |
class | CachedGlobList |
Public Types | |
using | DiagLevelAndFormatString = std::pair< DiagnosticIDs::Level, std::string > |
Public Member Functions | |
ClangTidyContext (std::unique_ptr< ClangTidyOptionsProvider > OptionsProvider, bool AllowEnablingAnalyzerAlphaCheckers=false) | |
Initializes ClangTidyContext instance. More... | |
void | setDiagnosticsEngine (DiagnosticsEngine *DiagEngine) |
Sets the DiagnosticsEngine that diag() will emit diagnostics to. More... | |
~ClangTidyContext () | |
DiagnosticBuilder | diag (StringRef CheckName, SourceLocation Loc, StringRef Message, DiagnosticIDs::Level Level=DiagnosticIDs::Warning) |
Report any errors detected using this method. More... | |
void | setSourceManager (SourceManager *SourceMgr) |
Sets the SourceManager of the used DiagnosticsEngine . More... | |
void | setCurrentFile (StringRef File) |
Should be called when starting to process new translation unit. More... | |
StringRef | getCurrentFile () const |
Returns the main file name of the current translation unit. More... | |
void | setASTContext (ASTContext *Context) |
Sets ASTContext for the current translation unit. More... | |
const LangOptions & | getLangOpts () const |
Gets the language options from the AST context. More... | |
std::string | getCheckName (unsigned DiagnosticID) const |
Returns the name of the clang-tidy check which produced this diagnostic ID. More... | |
bool | isCheckEnabled (StringRef CheckName) const |
Returns true if the check is enabled for the CurrentFile . More... | |
bool | treatAsError (StringRef CheckName) const |
Returns true if the check should be upgraded to error for the CurrentFile . More... | |
const ClangTidyGlobalOptions & | getGlobalOptions () const |
Returns global options. More... | |
const ClangTidyOptions & | getOptions () const |
Returns options for CurrentFile . More... | |
ClangTidyOptions | getOptionsForFile (StringRef File) const |
Returns options for File . More... | |
const ClangTidyStats & | getStats () const |
Returns ClangTidyStats containing issued and ignored diagnostic counters. More... | |
void | setEnableProfiling (bool Profile) |
Control profile collection in clang-tidy. More... | |
bool | getEnableProfiling () const |
void | setProfileStoragePrefix (StringRef ProfilePrefix) |
Control storage of profile date. More... | |
llvm::Optional< ClangTidyProfiling::StorageParams > | getProfileStorageParams () const |
void | setCurrentBuildDirectory (StringRef BuildDirectory) |
Should be called when starting to process new translation unit. More... | |
const std::string & | getCurrentBuildDirectory () |
Returns build directory of the current translation unit. More... | |
bool | canEnableAnalyzerAlphaCheckers () const |
If the experimental alpha checkers from the static analyzer can be enabled. More... | |
DiagLevelAndFormatString | getDiagLevelAndFormatString (unsigned DiagnosticID, SourceLocation Loc) |
Friends | |
class | ClangTidyDiagnosticConsumer |
Every ClangTidyCheck
reports errors through a DiagnosticsEngine
provided by this context.
A ClangTidyCheck
always has access to the active context to report warnings like:
Definition at line 99 of file ClangTidyDiagnosticConsumer.h.
using clang::tidy::ClangTidyContext::DiagLevelAndFormatString = std::pair<DiagnosticIDs::Level, std::string> |
Definition at line 193 of file ClangTidyDiagnosticConsumer.h.
ClangTidyContext::ClangTidyContext | ( | std::unique_ptr< ClangTidyOptionsProvider > | OptionsProvider, |
bool | AllowEnablingAnalyzerAlphaCheckers = false |
||
) |
Initializes ClangTidyContext
instance.
Definition at line 186 of file ClangTidyDiagnosticConsumer.cpp.
References setCurrentFile(), and ~ClangTidyContext().
|
default |
Referenced by ClangTidyContext().
|
inline |
If the experimental alpha checkers from the static analyzer can be enabled.
Definition at line 189 of file ClangTidyDiagnosticConsumer.h.
References AllowEnablingAnalyzerAlphaCheckers().
Referenced by clang::tidy::ClangTidyASTConsumerFactory::getCheckNames().
DiagnosticBuilder ClangTidyContext::diag | ( | StringRef | CheckName, |
SourceLocation | Loc, | ||
StringRef | Message, | ||
DiagnosticIDs::Level | Level = DiagnosticIDs::Warning |
||
) |
Report any errors detected using this method.
This is still under heavy development and will likely change towards using tablegen'd diagnostic IDs. FIXME: Figure out a way to manage ID spaces.
Definition at line 199 of file ClangTidyDiagnosticConsumer.cpp.
Referenced by clang::tidy::ClangTidyCheck::diag().
std::string ClangTidyContext::getCheckName | ( | unsigned | DiagnosticID | ) | const |
Returns the name of the clang-tidy check which produced this diagnostic ID.
Definition at line 265 of file ClangTidyDiagnosticConsumer.cpp.
Referenced by IsNOLINTFound(), and clang::clangd::StoreDiags::take().
|
inline |
Returns build directory of the current translation unit.
Definition at line 183 of file ClangTidyDiagnosticConsumer.h.
|
inline |
Returns the main file name of the current translation unit.
Definition at line 131 of file ClangTidyDiagnosticConsumer.h.
Referenced by clang::tidy::ClangTidyCheck::getCurrentMainFile().
|
inline |
Definition at line 194 of file ClangTidyDiagnosticConsumer.h.
|
inline |
Definition at line 170 of file ClangTidyDiagnosticConsumer.h.
const ClangTidyGlobalOptions & ClangTidyContext::getGlobalOptions | ( | ) | const |
Returns global options.
Definition at line 226 of file ClangTidyDiagnosticConsumer.cpp.
|
inline |
Gets the language options from the AST context.
Definition at line 137 of file ClangTidyDiagnosticConsumer.h.
Referenced by clang::tidy::ClangTidyCheck::getLangOpts().
const ClangTidyOptions & ClangTidyContext::getOptions | ( | ) | const |
Returns options for CurrentFile
.
The CurrentFile
can be changed using setCurrentFile
.
Definition at line 230 of file ClangTidyDiagnosticConsumer.cpp.
Referenced by setCurrentFile().
ClangTidyOptions ClangTidyContext::getOptionsForFile | ( | StringRef | File | ) | const |
Returns options for File
.
Does not change or depend on CurrentFile
.
Definition at line 234 of file ClangTidyDiagnosticConsumer.cpp.
References clang::tidy::ClangTidyOptions::getDefaults(), and clang::tidy::ClangTidyOptions::mergeWith().
Referenced by setCurrentFile().
llvm::Optional< ClangTidyProfiling::StorageParams > ClangTidyContext::getProfileStorageParams | ( | ) | const |
Definition at line 248 of file ClangTidyDiagnosticConsumer.cpp.
|
inline |
Returns ClangTidyStats
containing issued and ignored diagnostic counters.
Definition at line 166 of file ClangTidyDiagnosticConsumer.h.
bool ClangTidyContext::isCheckEnabled | ( | StringRef | CheckName | ) | const |
Returns true
if the check is enabled for the CurrentFile
.
The CurrentFile
can be changed using setCurrentFile
.
Definition at line 255 of file ClangTidyDiagnosticConsumer.cpp.
Referenced by clang::tidy::ClangTidyASTConsumerFactory::getCheckNames().
void ClangTidyContext::setASTContext | ( | ASTContext * | Context | ) |
Sets ASTContext for the current translation unit.
Definition at line 221 of file ClangTidyDiagnosticConsumer.cpp.
|
inline |
Should be called when starting to process new translation unit.
Definition at line 178 of file ClangTidyDiagnosticConsumer.h.
void ClangTidyContext::setCurrentFile | ( | StringRef | File | ) |
Should be called when starting to process new translation unit.
Definition at line 213 of file ClangTidyDiagnosticConsumer.cpp.
References clang::tidy::ClangTidyOptions::Checks, getOptions(), getOptionsForFile(), and clang::tidy::ClangTidyOptions::WarningsAsErrors.
Referenced by ClangTidyContext().
|
inline |
Sets the DiagnosticsEngine that diag() will emit diagnostics to.
Definition at line 107 of file ClangTidyDiagnosticConsumer.h.
References Loc, and clang::tidy::modernize::Message.
void ClangTidyContext::setEnableProfiling | ( | bool | Profile | ) |
Control profile collection in clang-tidy.
Definition at line 241 of file ClangTidyDiagnosticConsumer.cpp.
void ClangTidyContext::setProfileStoragePrefix | ( | StringRef | ProfilePrefix | ) |
Control storage of profile date.
Definition at line 243 of file ClangTidyDiagnosticConsumer.cpp.
void ClangTidyContext::setSourceManager | ( | SourceManager * | SourceMgr | ) |
Sets the SourceManager
of the used DiagnosticsEngine
.
This is called from the ClangTidyCheck
base class.
Definition at line 209 of file ClangTidyDiagnosticConsumer.cpp.
bool ClangTidyContext::treatAsError | ( | StringRef | CheckName | ) | const |
Returns true
if the check should be upgraded to error for the CurrentFile
.
Definition at line 260 of file ClangTidyDiagnosticConsumer.cpp.
|
friend |
Definition at line 204 of file ClangTidyDiagnosticConsumer.h.