clang  6.0.0svn
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 "clang/Frontend/DiagnosticRenderer.h"

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

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 Member Functions

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

Protected Attributes

const LangOptionsLangOpts
 
IntrusiveRefCntPtr< DiagnosticOptionsDiagOpts
 
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 45 of file DiagnosticRenderer.h.

Constructor & Destructor Documentation

◆ DiagnosticRenderer()

DiagnosticRenderer::DiagnosticRenderer ( const LangOptions LangOpts,
DiagnosticOptions DiagOpts 
)
protected

Definition at line 24 of file DiagnosticRenderer.cpp.

◆ ~DiagnosticRenderer()

DiagnosticRenderer::~DiagnosticRenderer ( )
protectedvirtual

Member Function Documentation

◆ beginDiagnostic()

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

Definition at line 95 of file DiagnosticRenderer.h.

Referenced by emitDiagnostic().

◆ emitBuildingModuleLocation()

virtual void clang::DiagnosticRenderer::emitBuildingModuleLocation ( FullSourceLoc  Loc,
PresumedLoc  PLoc,
StringRef  ModuleName 
)
protectedpure virtual

◆ emitCodeContext()

virtual void clang::DiagnosticRenderer::emitCodeContext ( FullSourceLoc  Loc,
DiagnosticsEngine::Level  Level,
SmallVectorImpl< CharSourceRange > &  Ranges,
ArrayRef< FixItHint Hints 
)
protectedpure virtual

Implemented in clang::TextDiagnostic.

◆ emitDiagnostic()

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.

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.

Definition at line 79 of file DiagnosticRenderer.cpp.

References beginDiagnostic(), emitDiagnosticMessage(), clang::FullSourceLoc::getManager(), clang::FullSourceLoc::hasManager(), clang::SourceLocation::isInvalid(), clang::SourceLocation::isValid(), LangOpts, and mergeFixits().

Referenced by emitStoredDiagnostic(), and endDiagnostic().

◆ emitDiagnosticLoc()

virtual void clang::DiagnosticRenderer::emitDiagnosticLoc ( FullSourceLoc  Loc,
PresumedLoc  PLoc,
DiagnosticsEngine::Level  Level,
ArrayRef< CharSourceRange Ranges 
)
protectedpure virtual

Implemented in clang::TextDiagnostic.

◆ emitDiagnosticMessage()

virtual void clang::DiagnosticRenderer::emitDiagnosticMessage ( FullSourceLoc  Loc,
PresumedLoc  PLoc,
DiagnosticsEngine::Level  Level,
StringRef  Message,
ArrayRef< CharSourceRange Ranges,
DiagOrStoredDiag  Info 
)
protectedpure virtual

Implemented in clang::TextDiagnostic.

Referenced by emitDiagnostic(), and emitStoredDiagnostic().

◆ emitImportLocation()

virtual void clang::DiagnosticRenderer::emitImportLocation ( FullSourceLoc  Loc,
PresumedLoc  PLoc,
StringRef  ModuleName 
)
protectedpure virtual

◆ emitIncludeLocation()

virtual void clang::DiagnosticRenderer::emitIncludeLocation ( FullSourceLoc  Loc,
PresumedLoc  PLoc 
)
protectedpure virtual

◆ emitStoredDiagnostic()

void DiagnosticRenderer::emitStoredDiagnostic ( StoredDiagnostic Diag)

◆ endDiagnostic()

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

Definition at line 97 of file DiagnosticRenderer.h.

References Diag(), emitDiagnostic(), emitStoredDiagnostic(), and SM.

Member Data Documentation

◆ DiagOpts

IntrusiveRefCntPtr<DiagnosticOptions> clang::DiagnosticRenderer::DiagOpts
protected

◆ LangOpts

const LangOptions& clang::DiagnosticRenderer::LangOpts
protected

◆ LastIncludeLoc

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 61 of file DiagnosticRenderer.h.

Referenced by emitStoredDiagnostic().

◆ LastLevel

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 67 of file DiagnosticRenderer.h.

◆ LastLoc

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 55 of file DiagnosticRenderer.h.


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