clang API Documentation
Class to encapsulate the logic for formatting a diagnostic message. More...
#include <DiagnosticRenderer.h>
Class to encapsulate the logic for formatting a diagnostic message.
Actual "printing" logic is implemented by subclasses.
This class provides an interface for building and emitting diagnostic, including all of the macro backtraces, caret diagnostics, FixIt Hints, and code snippets. In the presence of macros this involves a recursive process, synthesizing notes for each macro expansion.
A brief worklist: FIXME: Sink the recursive printing of template instantiations into this class.
Definition at line 46 of file DiagnosticRenderer.h.
DiagnosticRenderer::DiagnosticRenderer | ( | const LangOptions & | LangOpts, |
DiagnosticOptions * | DiagOpts | ||
) | [protected] |
Definition at line 68 of file DiagnosticRenderer.cpp.
DiagnosticRenderer::~DiagnosticRenderer | ( | ) | [protected, virtual] |
Definition at line 72 of file DiagnosticRenderer.cpp.
virtual void clang::DiagnosticRenderer::beginDiagnostic | ( | DiagOrStoredDiag | D, |
DiagnosticsEngine::Level | Level | ||
) | [inline, protected, virtual] |
Definition at line 102 of file DiagnosticRenderer.h.
Referenced by emitDiagnostic().
virtual void clang::DiagnosticRenderer::emitBuildingModuleLocation | ( | SourceLocation | Loc, |
PresumedLoc | PLoc, | ||
StringRef | ModuleName, | ||
const SourceManager & | SM | ||
) | [protected, pure virtual] |
Implemented in clang::DiagnosticNoteRenderer, and clang::TextDiagnostic.
virtual void clang::DiagnosticRenderer::emitCodeContext | ( | SourceLocation | Loc, |
DiagnosticsEngine::Level | Level, | ||
SmallVectorImpl< CharSourceRange > & | Ranges, | ||
ArrayRef< FixItHint > | Hints, | ||
const SourceManager & | SM | ||
) | [protected, pure virtual] |
Implemented in clang::TextDiagnostic.
void DiagnosticRenderer::emitDiagnostic | ( | SourceLocation | Loc, |
DiagnosticsEngine::Level | Level, | ||
StringRef | Message, | ||
ArrayRef< CharSourceRange > | Ranges, | ||
ArrayRef< FixItHint > | FixItHints, | ||
const SourceManager * | SM, | ||
DiagOrStoredDiag | D = (Diagnostic *)nullptr |
||
) |
Emit a diagnostic.
This is the primary entry point for emitting diagnostic messages. It handles formatting and rendering the message as well as any ancillary information needed based on macros whose expansions impact the diagnostic.
Loc | The location for this caret. |
Level | The level of the diagnostic to be emitted. |
Message | The diagnostic message to emit. |
Ranges | The underlined ranges for this code snippet. |
FixItHints | The FixIt hints active for this diagnostic. |
SM | The SourceManager; will be null if the diagnostic came from the frontend, thus Loc will be invalid. |
Definition at line 123 of file DiagnosticRenderer.cpp.
References beginDiagnostic(), DiagOpts, emitDiagnosticMessage(), endDiagnostic(), clang::SourceLocation::isInvalid(), clang::SourceLocation::isMacroID(), clang::SourceLocation::isValid(), LangOpts, LastLevel, LastLoc, mergeFixits(), Ranges, and SM.
Referenced by emitStoredDiagnostic().
virtual void clang::DiagnosticRenderer::emitDiagnosticLoc | ( | SourceLocation | Loc, |
PresumedLoc | PLoc, | ||
DiagnosticsEngine::Level | Level, | ||
ArrayRef< CharSourceRange > | Ranges, | ||
const SourceManager & | SM | ||
) | [protected, pure virtual] |
Implemented in clang::TextDiagnostic.
virtual void clang::DiagnosticRenderer::emitDiagnosticMessage | ( | SourceLocation | Loc, |
PresumedLoc | PLoc, | ||
DiagnosticsEngine::Level | Level, | ||
StringRef | Message, | ||
ArrayRef< CharSourceRange > | Ranges, | ||
const SourceManager * | SM, | ||
DiagOrStoredDiag | Info | ||
) | [protected, pure virtual] |
Implemented in clang::TextDiagnostic.
Referenced by emitDiagnostic().
virtual void clang::DiagnosticRenderer::emitImportLocation | ( | SourceLocation | Loc, |
PresumedLoc | PLoc, | ||
StringRef | ModuleName, | ||
const SourceManager & | SM | ||
) | [protected, pure virtual] |
Implemented in clang::DiagnosticNoteRenderer, and clang::TextDiagnostic.
virtual void clang::DiagnosticRenderer::emitIncludeLocation | ( | SourceLocation | Loc, |
PresumedLoc | PLoc, | ||
const SourceManager & | SM | ||
) | [protected, pure virtual] |
Implemented in clang::DiagnosticNoteRenderer, and clang::TextDiagnostic.
void DiagnosticRenderer::emitStoredDiagnostic | ( | StoredDiagnostic & | Diag | ) |
Definition at line 185 of file DiagnosticRenderer.cpp.
References Diag(), emitDiagnostic(), clang::StoredDiagnostic::getFixIts(), clang::StoredDiagnostic::getLevel(), clang::StoredDiagnostic::getLocation(), clang::FullSourceLoc::getManager(), clang::StoredDiagnostic::getMessage(), clang::StoredDiagnostic::getRanges(), and clang::SourceLocation::isValid().
virtual void clang::DiagnosticRenderer::endDiagnostic | ( | DiagOrStoredDiag | D, |
DiagnosticsEngine::Level | Level | ||
) | [inline, protected, virtual] |
Definition at line 104 of file DiagnosticRenderer.h.
Referenced by emitDiagnostic().
IntrusiveRefCntPtr<DiagnosticOptions> clang::DiagnosticRenderer::DiagOpts [protected] |
Definition at line 49 of file DiagnosticRenderer.h.
Referenced by clang::TextDiagnostic::emitBuildingModuleLocation(), emitDiagnostic(), clang::TextDiagnostic::emitDiagnosticLoc(), clang::TextDiagnostic::emitDiagnosticMessage(), clang::TextDiagnostic::emitImportLocation(), and clang::TextDiagnostic::emitIncludeLocation().
const LangOptions& clang::DiagnosticRenderer::LangOpts [protected] |
Definition at line 48 of file DiagnosticRenderer.h.
Referenced by emitDiagnostic(), and clang::TextDiagnostic::emitDiagnosticLoc().
The location of the last include whose stack was printed if known.
Same restriction as LastLoc essentially, but tracking include stack root locations rather than diagnostic locations.
Definition at line 62 of file DiagnosticRenderer.h.
The level of the last diagnostic emitted.
The level of the last diagnostic emitted. Used to detect level changes which change the amount of information displayed.
Definition at line 68 of file DiagnosticRenderer.h.
Referenced by emitDiagnostic().
SourceLocation clang::DiagnosticRenderer::LastLoc [protected] |
The location of the previous diagnostic if known.
This will be invalid in cases where there is no (known) previous diagnostic location, or that location itself is invalid or comes from a different source manager than SM.
Definition at line 56 of file DiagnosticRenderer.h.
Referenced by emitDiagnostic().