clang 8.0.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 "clang/Frontend/DiagnosticRenderer.h"`

Inheritance diagram for clang::DiagnosticRenderer:
[legend]
Collaboration diagram for clang::DiagnosticRenderer:
[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 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...

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

## Constructor & Destructor Documentation

## ◆ DiagnosticRenderer()

DiagnosticRenderer::DiagnosticRenderer | ( | const LangOptions & | LangOpts,
|  | DiagnosticOptions * | DiagOpts
| ) |  |
| protected

Definition at line 34 of file DiagnosticRenderer.cpp.

References clang::FixItHint::CreateInsertion(), clang::FixItHint::CreateReplacement(), clang::comments::tok::text, and ~DiagnosticRenderer().

## ◆ ~DiagnosticRenderer()

DiagnosticRenderer::~DiagnosticRenderer | ( |  | ) |
| protected virtual default

Referenced by DiagnosticRenderer().

## Member Function Documentation

## ◆ beginDiagnostic()

virtual void clang::DiagnosticRenderer::beginDiagnostic | ( | DiagOrStoredDiag | D,
|  | DiagnosticsEngine::Level | Level
| ) |  |
| inline protected virtual

Definition at line 98 of file DiagnosticRenderer.h.

Referenced by emitDiagnostic().

## ◆ emitBuildingModuleLocation()

virtual void clang::DiagnosticRenderer::emitBuildingModuleLocation | ( | FullSourceLoc | Loc,
|  | PresumedLoc | PLoc,
|  | StringRef | ModuleName
| ) |  |
| protected pure virtual

Implemented in clang::DiagnosticNoteRenderer, and clang::TextDiagnostic.

Referenced by clang::DiagnosticNoteRenderer::DiagnosticNoteRenderer().

## ◆ emitCodeContext()

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

Implemented in clang::TextDiagnostic.

Referenced by mapDiagnosticRanges().

## ◆ 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

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

## ◆ emitDiagnosticLoc()

virtual void clang::DiagnosticRenderer::emitDiagnosticLoc | ( | FullSourceLoc | Loc,
|  | PresumedLoc | PLoc,
|  | DiagnosticsEngine::Level | Level,
|  | ArrayRef< CharSourceRange > | Ranges
| ) |  |
| protected pure 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
| ) |  |
| protected pure virtual

Implemented in clang::TextDiagnostic.

Referenced by emitDiagnostic(), and emitStoredDiagnostic().

## ◆ emitImportLocation()

virtual void clang::DiagnosticRenderer::emitImportLocation | ( | FullSourceLoc | Loc,
|  | PresumedLoc | PLoc,
|  | StringRef | ModuleName
| ) |  |
| protected pure virtual

Implemented in clang::DiagnosticNoteRenderer, and clang::TextDiagnostic.

Referenced by clang::DiagnosticNoteRenderer::DiagnosticNoteRenderer(), and emitStoredDiagnostic().

## ◆ emitIncludeLocation()

virtual void clang::DiagnosticRenderer::emitIncludeLocation | ( | FullSourceLoc | Loc,
|  | PresumedLoc | PLoc
| ) |  |
| protected pure virtual

Implemented in clang::DiagnosticNoteRenderer, and clang::TextDiagnostic.

Referenced by clang::DiagnosticNoteRenderer::DiagnosticNoteRenderer(), and emitStoredDiagnostic().

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

## ◆ endDiagnostic()

virtual void clang::DiagnosticRenderer::endDiagnostic | ( | DiagOrStoredDiag | D,
|  | DiagnosticsEngine::Level | Level
| ) |  |
| inline protected virtual

Definition at line 100 of file DiagnosticRenderer.h.

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

Referenced by emitDiagnostic().

## Member Data Documentation

## ◆ DiagOpts

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

## ◆ LangOpts

const LangOptions& clang::DiagnosticRenderer::LangOpts
| protected

Definition at line 50 of file DiagnosticRenderer.h.

Referenced by buildFixItInsertionLine(), emitDiagnostic(), clang::TextDiagnostic::emitDiagnosticLoc(), and mapDiagnosticRanges().

## ◆ 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 64 of file DiagnosticRenderer.h.

Referenced by emitStoredDiagnostic().

## ◆ LastLevel

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

## ◆ 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 58 of file DiagnosticRenderer.h.

Referenced by buildFixItInsertionLine(), and emitDiagnostic().

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

- include/clang/Frontend/DiagnosticRenderer.h
- lib/Frontend/DiagnosticRenderer.cpp