clang  3.9.0
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
clang::DiagnosticRenderer Class Referenceabstract

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

#include <DiagnosticRenderer.h>

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

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. More...
 
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. More...
 
SourceLocation LastIncludeLoc
 The location of the last include whose stack was printed if known. More...
 
DiagnosticsEngine::Level LastLevel
 The level of the last diagnostic emitted. More...
 

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 26 of file DiagnosticRenderer.cpp.

DiagnosticRenderer::~DiagnosticRenderer ( )
protectedvirtual

Definition at line 30 of file DiagnosticRenderer.cpp.

Member Function Documentation

virtual void clang::DiagnosticRenderer::beginDiagnostic ( DiagOrStoredDiag  D,
DiagnosticsEngine::Level  Level 
)
inlineprotectedvirtual

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 
)
protectedpure virtual
virtual void clang::DiagnosticRenderer::emitCodeContext ( SourceLocation  Loc,
DiagnosticsEngine::Level  Level,
SmallVectorImpl< CharSourceRange > &  Ranges,
ArrayRef< FixItHint Hints,
const SourceManager SM 
)
protectedpure 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 81 of file DiagnosticRenderer.cpp.

References beginDiagnostic(), DiagOpts, E, emitDiagnosticMessage(), endDiagnostic(), I, clang::SourceLocation::isInvalid(), clang::SourceLocation::isMacroID(), clang::SourceLocation::isValid(), LangOpts, LastLevel, LastLoc, mergeFixits(), and SM.

Referenced by emitStoredDiagnostic().

virtual void clang::DiagnosticRenderer::emitDiagnosticLoc ( SourceLocation  Loc,
PresumedLoc  PLoc,
DiagnosticsEngine::Level  Level,
ArrayRef< CharSourceRange Ranges,
const SourceManager SM 
)
protectedpure 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 
)
protectedpure virtual

Implemented in clang::TextDiagnostic.

Referenced by emitDiagnostic().

virtual void clang::DiagnosticRenderer::emitImportLocation ( SourceLocation  Loc,
PresumedLoc  PLoc,
StringRef  ModuleName,
const SourceManager SM 
)
protectedpure virtual
virtual void clang::DiagnosticRenderer::emitIncludeLocation ( SourceLocation  Loc,
PresumedLoc  PLoc,
const SourceManager SM 
)
protectedpure virtual
void DiagnosticRenderer::emitStoredDiagnostic ( StoredDiagnostic Diag)
virtual void clang::DiagnosticRenderer::endDiagnostic ( DiagOrStoredDiag  D,
DiagnosticsEngine::Level  Level 
)
inlineprotectedvirtual

Definition at line 104 of file DiagnosticRenderer.h.

Referenced by emitDiagnostic().

Member Data Documentation

IntrusiveRefCntPtr<DiagnosticOptions> clang::DiagnosticRenderer::DiagOpts
protected
const LangOptions& clang::DiagnosticRenderer::LangOpts
protected
SourceLocation clang::DiagnosticRenderer::LastIncludeLoc
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.

DiagnosticsEngine::Level clang::DiagnosticRenderer::LastLevel
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 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().


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