clang-tools
4.0.0
|
Every ClangTidyCheck
reports errors through a DiagnosticsEngine
provided by this context.
More...
#include <ClangTidyDiagnosticConsumer.h>
Public Member Functions | |
ClangTidyContext (std::unique_ptr< ClangTidyOptionsProvider > OptionsProvider) | |
Initializes ClangTidyContext instance. More... | |
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... | |
StringRef | getCheckName (unsigned DiagnosticID) const |
Returns the name of the clang-tidy check which produced this diagnostic ID. More... | |
GlobList & | getChecksFilter () |
Returns check filter for the CurrentFile . More... | |
GlobList & | getWarningAsErrorFilter () |
Returns check filter for the CurrentFile which selects checks for upgrade to error. 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... | |
const std::vector < ClangTidyError > & | getErrors () const |
Returns all collected errors. More... | |
void | clearErrors () |
Clears collected errors. More... | |
void | setCheckProfileData (ProfileData *Profile) |
Set the output struct for profile data. More... | |
ProfileData * | getCheckProfileData () 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... | |
Friends | |
class | ClangTidyDiagnosticConsumer |
class | ClangTidyPluginAction |
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 104 of file ClangTidyDiagnosticConsumer.h.
ClangTidyContext::ClangTidyContext | ( | std::unique_ptr< ClangTidyOptionsProvider > | OptionsProvider | ) |
Initializes ClangTidyContext
instance.
Definition at line 159 of file ClangTidyDiagnosticConsumer.cpp.
References setCurrentFile().
|
inline |
Clears collected errors.
Definition at line 168 of file ClangTidyDiagnosticConsumer.h.
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 168 of file ClangTidyDiagnosticConsumer.cpp.
Referenced by clang::tidy::ClangTidyCheck::diag().
StringRef ClangTidyContext::getCheckName | ( | unsigned | DiagnosticID | ) | const |
Returns the name of the clang-tidy check which produced this diagnostic ID.
Definition at line 230 of file ClangTidyDiagnosticConsumer.cpp.
Referenced by clang::tidy::ClangTidyDiagnosticConsumer::HandleDiagnostic().
|
inline |
Definition at line 175 of file ClangTidyDiagnosticConsumer.h.
Referenced by clang::tidy::ClangTidyASTConsumerFactory::CreateASTConsumer().
GlobList & ClangTidyContext::getChecksFilter | ( | ) |
Returns check filter for the CurrentFile
.
The CurrentFile
can be changed using setCurrentFile
.
Definition at line 215 of file ClangTidyDiagnosticConsumer.cpp.
Referenced by clang::tidy::ClangTidyASTConsumerFactory::CreateASTConsumer(), clang::tidy::ClangTidyCheckFactories::createChecks(), and clang::tidy::ClangTidyASTConsumerFactory::getCheckNames().
|
inline |
Returns build directory of the current translation unit.
Definition at line 183 of file ClangTidyDiagnosticConsumer.h.
Referenced by clang::tidy::ClangTidyDiagnosticConsumer::HandleDiagnostic().
|
inline |
Returns the main file name of the current translation unit.
Definition at line 127 of file ClangTidyDiagnosticConsumer.h.
Referenced by clang::tidy::ClangTidyCheck::getCurrentMainFile().
|
inline |
Returns all collected errors.
Definition at line 165 of file ClangTidyDiagnosticConsumer.h.
Referenced by clang::tidy::runClangTidy().
const ClangTidyGlobalOptions & ClangTidyContext::getGlobalOptions | ( | ) | const |
Returns global options.
Definition at line 198 of file ClangTidyDiagnosticConsumer.cpp.
|
inline |
Gets the language options from the AST context.
Definition at line 133 of file ClangTidyDiagnosticConsumer.h.
Referenced by clang::tidy::ClangTidyCheck::getLangOpts(), and clang::tidy::ClangTidyDiagnosticConsumer::HandleDiagnostic().
const ClangTidyOptions & ClangTidyContext::getOptions | ( | ) | const |
Returns options for CurrentFile
.
The CurrentFile
can be changed using setCurrentFile
.
Definition at line 202 of file ClangTidyDiagnosticConsumer.cpp.
Referenced by clang::tidy::ClangTidyASTConsumerFactory::CreateASTConsumer(), and setCurrentFile().
ClangTidyOptions ClangTidyContext::getOptionsForFile | ( | StringRef | File | ) | const |
Returns options for File
.
Does not change or depend on CurrentFile
.
Definition at line 206 of file ClangTidyDiagnosticConsumer.cpp.
References clang::tidy::ClangTidyOptions::getDefaults(), and clang::tidy::ClangTidyOptions::mergeWith().
Referenced by clang::tidy::runClangTidy(), and setCurrentFile().
|
inline |
Returns ClangTidyStats
containing issued and ignored diagnostic counters.
Definition at line 162 of file ClangTidyDiagnosticConsumer.h.
Referenced by clang::tidy::runClangTidy().
GlobList & ClangTidyContext::getWarningAsErrorFilter | ( | ) |
Returns check filter for the CurrentFile
which selects checks for upgrade to error.
Definition at line 220 of file ClangTidyDiagnosticConsumer.cpp.
Referenced by clang::tidy::ClangTidyDiagnosticConsumer::HandleDiagnostic().
void ClangTidyContext::setASTContext | ( | ASTContext * | Context | ) |
Sets ASTContext for the current translation unit.
Definition at line 193 of file ClangTidyDiagnosticConsumer.cpp.
Referenced by clang::tidy::ClangTidyASTConsumerFactory::CreateASTConsumer().
void ClangTidyContext::setCheckProfileData | ( | ProfileData * | Profile | ) |
Set the output struct for profile data.
Setting a non-null pointer here will enable profile collection in clang-tidy.
Definition at line 213 of file ClangTidyDiagnosticConsumer.cpp.
Referenced by clang::tidy::runClangTidy().
|
inline |
Should be called when starting to process new translation unit.
Definition at line 178 of file ClangTidyDiagnosticConsumer.h.
Referenced by clang::tidy::ClangTidyASTConsumerFactory::CreateASTConsumer().
void ClangTidyContext::setCurrentFile | ( | StringRef | File | ) |
Should be called when starting to process new translation unit.
Definition at line 186 of file ClangTidyDiagnosticConsumer.cpp.
References Checks, File, getOptions(), getOptionsForFile(), and WarningsAsErrors.
Referenced by ClangTidyContext(), and clang::tidy::ClangTidyASTConsumerFactory::CreateASTConsumer().
void ClangTidyContext::setSourceManager | ( | SourceManager * | SourceMgr | ) |
Sets the SourceManager
of the used DiagnosticsEngine
.
This is called from the ClangTidyCheck
base class.
Definition at line 182 of file ClangTidyDiagnosticConsumer.cpp.
Referenced by clang::tidy::ClangTidyASTConsumerFactory::CreateASTConsumer().
|
friend |
Definition at line 189 of file ClangTidyDiagnosticConsumer.h.
|
friend |
Definition at line 190 of file ClangTidyDiagnosticConsumer.h.