clang 20.0.0git
|
#include "clang/Rewrite/Frontend/FixItRewriter.h"
Public Types | |
using | iterator = Rewriter::buffer_iterator |
Public Member Functions | |
FixItRewriter (DiagnosticsEngine &Diags, SourceManager &SourceMgr, const LangOptions &LangOpts, FixItOptions *FixItOpts) | |
Initialize a new fix-it rewriter. | |
~FixItRewriter () override | |
Destroy the fix-it rewriter. | |
bool | IsModified (FileID ID) const |
Check whether there are modifications for a given file. | |
iterator | buffer_begin () |
iterator | buffer_end () |
bool | WriteFixedFile (FileID ID, raw_ostream &OS) |
Write a single modified source file. | |
bool | WriteFixedFiles (std::vector< std::pair< std::string, std::string > > *RewrittenFiles=nullptr) |
Write the modified source files. | |
bool | IncludeInDiagnosticCounts () const override |
IncludeInDiagnosticCounts - This method (whose default implementation returns true) indicates whether the diagnostics handled by this DiagnosticConsumer should be included in the number of diagnostics reported by DiagnosticsEngine. | |
void | HandleDiagnostic (DiagnosticsEngine::Level DiagLevel, const Diagnostic &Info) override |
HandleDiagnostic - Handle this diagnostic, reporting it to the user or capturing it to a log as needed. | |
void | Diag (SourceLocation Loc, unsigned DiagID) |
Emit a diagnostic via the adapted diagnostic client. | |
Public Member Functions inherited from clang::DiagnosticConsumer | |
DiagnosticConsumer ()=default | |
virtual | ~DiagnosticConsumer () |
unsigned | getNumErrors () const |
unsigned | getNumWarnings () const |
virtual void | clear () |
virtual void | BeginSourceFile (const LangOptions &LangOpts, const Preprocessor *PP=nullptr) |
Callback to inform the diagnostic client that processing of a source file is beginning. | |
virtual void | EndSourceFile () |
Callback to inform the diagnostic client that processing of a source file has ended. | |
virtual void | finish () |
Callback to inform the diagnostic client that processing of all source files has ended. | |
virtual bool | IncludeInDiagnosticCounts () const |
Indicates whether the diagnostics handled by this DiagnosticConsumer should be included in the number of diagnostics reported by DiagnosticsEngine. | |
virtual void | HandleDiagnostic (DiagnosticsEngine::Level DiagLevel, const Diagnostic &Info) |
Handle this diagnostic, reporting it to the user or capturing it to a log as needed. | |
Additional Inherited Members | |
Protected Attributes inherited from clang::DiagnosticConsumer | |
unsigned | NumWarnings = 0 |
Number of warnings reported. | |
unsigned | NumErrors = 0 |
Number of errors reported. | |
Definition at line 62 of file FixItRewriter.h.
Definition at line 100 of file FixItRewriter.h.
FixItRewriter::FixItRewriter | ( | DiagnosticsEngine & | Diags, |
SourceManager & | SourceMgr, | ||
const LangOptions & | LangOpts, | ||
FixItOptions * | FixItOpts | ||
) |
Initialize a new fix-it rewriter.
Definition at line 37 of file FixItRewriter.cpp.
References clang::DiagnosticsEngine::getClient(), clang::DiagnosticsEngine::setClient(), and clang::DiagnosticsEngine::takeClient().
|
override |
Destroy the fix-it rewriter.
Definition at line 47 of file FixItRewriter.cpp.
References clang::DiagnosticsEngine::setClient().
|
inline |
Definition at line 103 of file FixItRewriter.h.
References clang::Rewrite.
Referenced by WriteFixedFiles().
|
inline |
Definition at line 104 of file FixItRewriter.h.
References clang::Rewrite.
Referenced by WriteFixedFiles().
void FixItRewriter::Diag | ( | SourceLocation | Loc, |
unsigned | DiagID | ||
) |
Emit a diagnostic via the adapted diagnostic client.
Definition at line 200 of file FixItRewriter.cpp.
References clang::DiagnosticsEngine::Clear(), Loc, clang::DiagnosticsEngine::Report(), and clang::DiagnosticsEngine::setClient().
Referenced by HandleDiagnostic(), and WriteFixedFiles().
|
overridevirtual |
HandleDiagnostic - Handle this diagnostic, reporting it to the user or capturing it to a log as needed.
Reimplemented from clang::DiagnosticConsumer.
Definition at line 129 of file FixItRewriter.cpp.
References clang::FixItHint::BeforePreviousInsertions, clang::FixItHint::CodeToInsert, clang::edit::EditedSource::commit(), Diag(), clang::DiagnosticsEngine::Error, clang::FixItOptions::FixOnlyWarnings, clang::CharSourceRange::getBegin(), clang::CharSourceRange::getEnd(), clang::Diagnostic::getFixItHint(), clang::Diagnostic::getLocation(), clang::Diagnostic::getNumFixItHints(), clang::DiagnosticConsumer::HandleDiagnostic(), clang::edit::Commit::insert(), clang::FixItHint::InsertFromRange, clang::edit::Commit::insertFromRange(), clang::edit::Commit::isCommitable(), clang::CharSourceRange::isTokenRange(), clang::CharSourceRange::isValid(), clang::Last, clang::DiagnosticsEngine::Note, clang::edit::Commit::remove(), clang::FixItHint::RemoveRange, clang::edit::Commit::replace(), and clang::FixItOptions::Silent.
|
overridevirtual |
IncludeInDiagnosticCounts - This method (whose default implementation returns true) indicates whether the diagnostics handled by this DiagnosticConsumer should be included in the number of diagnostics reported by DiagnosticsEngine.
Reimplemented from clang::DiagnosticConsumer.
Definition at line 125 of file FixItRewriter.cpp.
References clang::DiagnosticConsumer::IncludeInDiagnosticCounts().
Check whether there are modifications for a given file.
Definition at line 96 of file FixItRewriter.h.
References ID, and clang::Rewrite.
Write a single modified source file.
Definition at line 51 of file FixItRewriter.cpp.
References clang::Rewriter::getRewriteBufferFor(), and clang::RewriteBuffer::write().
bool FixItRewriter::WriteFixedFiles | ( | std::vector< std::pair< std::string, std::string > > * | RewrittenFiles = nullptr | ) |
Write the modified source files.
Definition at line 78 of file FixItRewriter.cpp.
References clang::edit::EditedSource::applyRewrites(), buffer_begin(), buffer_end(), Diag(), E, Filename, clang::FixItOptions::FixWhatYouCan, clang::FileEntryRef::getName(), clang::FixItOptions::InPlace, clang::DiagnosticsEngine::Report(), clang::Rewrite, clang::FixItOptions::RewriteFilename(), and clang::RewriteBuffer::write().