clang API Documentation

Public Member Functions | Protected Member Functions | Protected Attributes
clang::DiagnosticRenderer Class Reference

Class to encapsulate the logic for formatting a diagnostic message. More...

#include <DiagnosticRenderer.h>

Inheritance diagram for clang::DiagnosticRenderer:
Inheritance graph
[legend]
Collaboration diagram for clang::DiagnosticRenderer:
Collaboration graph
[legend]

List of all members.

Public Member Functions

void emitDiagnostic (SourceLocation Loc, DiagnosticsEngine::Level Level, StringRef Message, ArrayRef< CharSourceRange > Ranges, ArrayRef< FixItHint > FixItHints, const SourceManager *SM, DiagOrStoredDiag D=(Diagnostic *) nullptr)
 Emit a diagnostic.
void emitStoredDiagnostic (StoredDiagnostic &Diag)

Protected Member Functions

 DiagnosticRenderer (const LangOptions &LangOpts, DiagnosticOptions *DiagOpts)
virtual ~DiagnosticRenderer ()
virtual void emitDiagnosticMessage (SourceLocation Loc, PresumedLoc PLoc, DiagnosticsEngine::Level Level, StringRef Message, ArrayRef< CharSourceRange > Ranges, const SourceManager *SM, DiagOrStoredDiag Info)=0
virtual void emitDiagnosticLoc (SourceLocation Loc, PresumedLoc PLoc, DiagnosticsEngine::Level Level, ArrayRef< CharSourceRange > Ranges, const SourceManager &SM)=0
virtual void emitCodeContext (SourceLocation Loc, DiagnosticsEngine::Level Level, SmallVectorImpl< CharSourceRange > &Ranges, ArrayRef< FixItHint > Hints, const SourceManager &SM)=0
virtual void emitIncludeLocation (SourceLocation Loc, PresumedLoc PLoc, const SourceManager &SM)=0
virtual void emitImportLocation (SourceLocation Loc, PresumedLoc PLoc, StringRef ModuleName, const SourceManager &SM)=0
virtual void emitBuildingModuleLocation (SourceLocation Loc, PresumedLoc PLoc, StringRef ModuleName, const SourceManager &SM)=0
virtual void beginDiagnostic (DiagOrStoredDiag D, DiagnosticsEngine::Level Level)
virtual void endDiagnostic (DiagOrStoredDiag D, DiagnosticsEngine::Level Level)

Protected Attributes

const LangOptionsLangOpts
IntrusiveRefCntPtr
< DiagnosticOptions
DiagOpts
SourceLocation LastLoc
 The location of the previous diagnostic if known.
SourceLocation LastIncludeLoc
 The location of the last include whose stack was printed if known.
DiagnosticsEngine::Level LastLevel
 The level of the last diagnostic emitted.

Detailed Description

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.


Constructor & Destructor Documentation

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.


Member Function Documentation

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]
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.

Parameters:
LocThe location for this caret.
LevelThe level of the diagnostic to be emitted.
MessageThe diagnostic message to emit.
RangesThe underlined ranges for this code snippet.
FixItHintsThe FixIt hints active for this diagnostic.
SMThe 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]
virtual void clang::DiagnosticRenderer::emitIncludeLocation ( SourceLocation  Loc,
PresumedLoc  PLoc,
const SourceManager SM 
) [protected, pure virtual]
virtual void clang::DiagnosticRenderer::endDiagnostic ( DiagOrStoredDiag  D,
DiagnosticsEngine::Level  Level 
) [inline, protected, virtual]

Definition at line 104 of file DiagnosticRenderer.h.

Referenced by emitDiagnostic().


Member Data Documentation

IntrusiveRefCntPtr<DiagnosticOptions> clang::DiagnosticRenderer::DiagOpts [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 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().

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().


The documentation for this class was generated from the following files: