clang
8.0.0
|
Class to encapsulate the logic for formatting a diagnostic message. More...
#include "clang/Frontend/DiagnosticRenderer.h"
Public Member Functions | |
void | emitDiagnostic (FullSourceLoc Loc, DiagnosticsEngine::Level Level, StringRef Message, ArrayRef< CharSourceRange > Ranges, ArrayRef< FixItHint > FixItHints, DiagOrStoredDiag D=(Diagnostic *) nullptr) |
Emit a diagnostic. More... | |
void | emitStoredDiagnostic (StoredDiagnostic &Diag) |
Protected Attributes | |
const LangOptions & | LangOpts |
IntrusiveRefCntPtr< DiagnosticOptions > | DiagOpts |
SourceLocation | LastLoc |
The location of the previous diagnostic if known. More... | |
SourceLocation | LastIncludeLoc |
The location of the last include whose stack was printed if known. More... | |
DiagnosticsEngine::Level | LastLevel = DiagnosticsEngine::Ignored |
The level of the last diagnostic emitted. More... | |
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 48 of file DiagnosticRenderer.h.
|
protected |
Definition at line 34 of file DiagnosticRenderer.cpp.
References clang::FixItHint::CreateInsertion(), clang::FixItHint::CreateReplacement(), clang::comments::tok::text, and ~DiagnosticRenderer().
|
protectedvirtualdefault |
Referenced by DiagnosticRenderer().
|
inlineprotectedvirtual |
Definition at line 98 of file DiagnosticRenderer.h.
Referenced by emitDiagnostic().
|
protectedpure virtual |
Implemented in clang::DiagnosticNoteRenderer, and clang::TextDiagnostic.
Referenced by clang::DiagnosticNoteRenderer::DiagnosticNoteRenderer().
|
protectedpure virtual |
Implemented in clang::TextDiagnostic.
Referenced by mapDiagnosticRanges().
void DiagnosticRenderer::emitDiagnostic | ( | FullSourceLoc | Loc, |
DiagnosticsEngine::Level | Level, | ||
StringRef | Message, | ||
ArrayRef< CharSourceRange > | Ranges, | ||
ArrayRef< FixItHint > | FixItHints, | ||
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. |
Definition at line 88 of file DiagnosticRenderer.cpp.
References beginDiagnostic(), DiagOpts, emitDiagnosticMessage(), endDiagnostic(), clang::FullSourceLoc::getFileLoc(), clang::FullSourceLoc::getManager(), clang::FullSourceLoc::getPresumedLoc(), clang::FullSourceLoc::hasManager(), clang::SourceLocation::isInvalid(), clang::SourceLocation::isMacroID(), clang::SourceLocation::isValid(), LangOpts, LastLevel, LastLoc, and mergeFixits().
Referenced by emitStoredDiagnostic(), endDiagnostic(), and mapDiagnosticRanges().
|
protectedpure virtual |
Implemented in clang::TextDiagnostic.
|
protectedpure virtual |
Implemented in clang::TextDiagnostic.
Referenced by emitDiagnostic(), and emitStoredDiagnostic().
|
protectedpure virtual |
Implemented in clang::DiagnosticNoteRenderer, and clang::TextDiagnostic.
Referenced by clang::DiagnosticNoteRenderer::DiagnosticNoteRenderer(), and emitStoredDiagnostic().
|
protectedpure virtual |
Implemented in clang::DiagnosticNoteRenderer, and clang::TextDiagnostic.
Referenced by clang::DiagnosticNoteRenderer::DiagnosticNoteRenderer(), and emitStoredDiagnostic().
void DiagnosticRenderer::emitStoredDiagnostic | ( | StoredDiagnostic & | Diag | ) |
Definition at line 144 of file DiagnosticRenderer.cpp.
References Diag(), DiagOpts, emitDiagnostic(), emitDiagnosticMessage(), emitImportLocation(), emitIncludeLocation(), clang::StoredDiagnostic::getFixIts(), clang::PresumedLoc::getIncludeLoc(), clang::StoredDiagnostic::getLevel(), clang::StoredDiagnostic::getLocation(), clang::FullSourceLoc::getManager(), clang::StoredDiagnostic::getMessage(), clang::FullSourceLoc::getModuleImportLoc(), clang::FullSourceLoc::getPresumedLoc(), clang::StoredDiagnostic::getRanges(), clang::SourceLocation::isInvalid(), clang::PresumedLoc::isInvalid(), clang::SourceLocation::isValid(), LastIncludeLoc, clang::None, clang::DiagnosticsEngine::Note, and SM.
Referenced by endDiagnostic().
|
inlineprotectedvirtual |
Definition at line 100 of file DiagnosticRenderer.h.
References Diag(), emitDiagnostic(), emitStoredDiagnostic(), and SM.
Referenced by emitDiagnostic().
|
protected |
Definition at line 51 of file DiagnosticRenderer.h.
Referenced by buildFixItInsertionLine(), checkRangesForMacroArgExpansion(), clang::TextDiagnostic::emitBuildingModuleLocation(), emitDiagnostic(), clang::TextDiagnostic::emitDiagnosticLoc(), clang::TextDiagnostic::emitDiagnosticMessage(), clang::TextDiagnostic::emitImportLocation(), clang::TextDiagnostic::emitIncludeLocation(), emitStoredDiagnostic(), and clang::TextDiagnostic::printDiagnosticMessage().
|
protected |
Definition at line 50 of file DiagnosticRenderer.h.
Referenced by buildFixItInsertionLine(), emitDiagnostic(), clang::TextDiagnostic::emitDiagnosticLoc(), and mapDiagnosticRanges().
|
protected |
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 64 of file DiagnosticRenderer.h.
Referenced by emitStoredDiagnostic().
|
protected |
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 70 of file DiagnosticRenderer.h.
Referenced by buildFixItInsertionLine(), and emitDiagnostic().
|
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 58 of file DiagnosticRenderer.h.
Referenced by buildFixItInsertionLine(), and emitDiagnostic().