class DiagnosticRenderer

Declaration

class DiagnosticRenderer { /* full declaration omitted */ };

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.

Declared at: clang/include/clang/Frontend/DiagnosticRenderer.h:47

Member Variables

protected const clang::LangOptions& LangOpts
protected IntrusiveRefCntPtr<clang::DiagnosticOptions> DiagOpts
protected clang::SourceLocation LastLoc
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.
protected clang::SourceLocation LastIncludeLoc
Same restriction as LastLoc essentially, but tracking include stack root locations rather than diagnostic locations.
protected DiagnosticsEngine::Level LastLevel = DiagnosticsEngine::Ignored
The level of the last diagnostic emitted. Used to detect level changes which change the amount of information displayed.

Method Overview

  • protected DiagnosticRenderer(const clang::LangOptions & LangOpts, clang::DiagnosticOptions * DiagOpts)
  • protected virtual void beginDiagnostic(clang::DiagOrStoredDiag D, DiagnosticsEngine::Level Level)
  • private void emitBasicNote(llvm::StringRef Message)
  • protected virtual void emitBuildingModuleLocation(clang::FullSourceLoc Loc, clang::PresumedLoc PLoc, llvm::StringRef ModuleName)
  • private void emitCaret(clang::FullSourceLoc Loc, DiagnosticsEngine::Level Level, ArrayRef<clang::CharSourceRange> Ranges, ArrayRef<clang::FixItHint> Hints)
  • protected virtual void emitCodeContext(clang::FullSourceLoc Loc, DiagnosticsEngine::Level Level, SmallVectorImpl<clang::CharSourceRange> & Ranges, ArrayRef<clang::FixItHint> Hints)
  • public void emitDiagnostic(clang::FullSourceLoc Loc, DiagnosticsEngine::Level Level, llvm::StringRef Message, ArrayRef<clang::CharSourceRange> Ranges, ArrayRef<clang::FixItHint> FixItHints, clang::DiagOrStoredDiag D = (clang::Diagnostic *)nullptr)
  • protected virtual void emitDiagnosticLoc(clang::FullSourceLoc Loc, clang::PresumedLoc PLoc, DiagnosticsEngine::Level Level, ArrayRef<clang::CharSourceRange> Ranges)
  • protected virtual void emitDiagnosticMessage(clang::FullSourceLoc Loc, clang::PresumedLoc PLoc, DiagnosticsEngine::Level Level, llvm::StringRef Message, ArrayRef<clang::CharSourceRange> Ranges, clang::DiagOrStoredDiag Info)
  • protected virtual void emitImportLocation(clang::FullSourceLoc Loc, clang::PresumedLoc PLoc, llvm::StringRef ModuleName)
  • private void emitImportStack(clang::FullSourceLoc Loc)
  • private void emitImportStackRecursively(clang::FullSourceLoc Loc, llvm::StringRef ModuleName)
  • protected virtual void emitIncludeLocation(clang::FullSourceLoc Loc, clang::PresumedLoc PLoc)
  • private void emitIncludeStack(clang::FullSourceLoc Loc, clang::PresumedLoc PLoc, DiagnosticsEngine::Level Level)
  • private void emitIncludeStackRecursively(clang::FullSourceLoc Loc)
  • private void emitMacroExpansions(clang::FullSourceLoc Loc, DiagnosticsEngine::Level Level, ArrayRef<clang::CharSourceRange> Ranges, ArrayRef<clang::FixItHint> Hints)
  • private void emitModuleBuildStack(const clang::SourceManager & SM)
  • private void emitSingleMacroExpansion(clang::FullSourceLoc Loc, DiagnosticsEngine::Level Level, ArrayRef<clang::CharSourceRange> Ranges)
  • public void emitStoredDiagnostic(clang::StoredDiagnostic & Diag)
  • protected virtual void endDiagnostic(clang::DiagOrStoredDiag D, DiagnosticsEngine::Level Level)
  • protected virtual ~DiagnosticRenderer()

Methods

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

Declared at: clang/include/clang/Frontend/DiagnosticRenderer.h:71

Parameters

const clang::LangOptions& LangOpts
clang::DiagnosticOptions* DiagOpts

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

Declared at: clang/include/clang/Frontend/DiagnosticRenderer.h:97

Parameters

clang::DiagOrStoredDiag D
DiagnosticsEngine::Level Level

void emitBasicNote(llvm::StringRef Message)

Declared at: clang/include/clang/Frontend/DiagnosticRenderer.h:103

Parameters

llvm::StringRef Message

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

Declared at: clang/include/clang/Frontend/DiagnosticRenderer.h:94

Parameters

clang::FullSourceLoc Loc
clang::PresumedLoc PLoc
llvm::StringRef ModuleName

void emitCaret(
    clang::FullSourceLoc Loc,
    DiagnosticsEngine::Level Level,
    ArrayRef<clang::CharSourceRange> Ranges,
    ArrayRef<clang::FixItHint> Hints)

Declared at: clang/include/clang/Frontend/DiagnosticRenderer.h:110

Parameters

clang::FullSourceLoc Loc
DiagnosticsEngine::Level Level
ArrayRef<clang::CharSourceRange> Ranges
ArrayRef<clang::FixItHint> Hints

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

Declared at: clang/include/clang/Frontend/DiagnosticRenderer.h:86

Parameters

clang::FullSourceLoc Loc
DiagnosticsEngine::Level Level
SmallVectorImpl<clang::CharSourceRange>& Ranges
ArrayRef<clang::FixItHint> Hints

void emitDiagnostic(
    clang::FullSourceLoc Loc,
    DiagnosticsEngine::Level Level,
    llvm::StringRef Message,
    ArrayRef<clang::CharSourceRange> Ranges,
    ArrayRef<clang::FixItHint> FixItHints,
    clang::DiagOrStoredDiag D =
        (clang::Diagnostic*)nullptr)

Description

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.

Declared at: clang/include/clang/Frontend/DiagnosticRenderer.h:132

Parameters

clang::FullSourceLoc Loc
The location for this caret.
DiagnosticsEngine::Level Level
The level of the diagnostic to be emitted.
llvm::StringRef Message
The diagnostic message to emit.
ArrayRef<clang::CharSourceRange> Ranges
The underlined ranges for this code snippet.
ArrayRef<clang::FixItHint> FixItHints
The FixIt hints active for this diagnostic.
clang::DiagOrStoredDiag D = (clang::Diagnostic *)nullptr

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

Declared at: clang/include/clang/Frontend/DiagnosticRenderer.h:82

Parameters

clang::FullSourceLoc Loc
clang::PresumedLoc PLoc
DiagnosticsEngine::Level Level
ArrayRef<clang::CharSourceRange> Ranges

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

Declared at: clang/include/clang/Frontend/DiagnosticRenderer.h:76

Parameters

clang::FullSourceLoc Loc
clang::PresumedLoc PLoc
DiagnosticsEngine::Level Level
llvm::StringRef Message
ArrayRef<clang::CharSourceRange> Ranges
clang::DiagOrStoredDiag Info

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

Declared at: clang/include/clang/Frontend/DiagnosticRenderer.h:92

Parameters

clang::FullSourceLoc Loc
clang::PresumedLoc PLoc
llvm::StringRef ModuleName

void emitImportStack(clang::FullSourceLoc Loc)

Declared at: clang/include/clang/Frontend/DiagnosticRenderer.h:107

Parameters

clang::FullSourceLoc Loc

void emitImportStackRecursively(
    clang::FullSourceLoc Loc,
    llvm::StringRef ModuleName)

Declared at: clang/include/clang/Frontend/DiagnosticRenderer.h:108

Parameters

clang::FullSourceLoc Loc
llvm::StringRef ModuleName

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

Declared at: clang/include/clang/Frontend/DiagnosticRenderer.h:91

Parameters

clang::FullSourceLoc Loc
clang::PresumedLoc PLoc

void emitIncludeStack(
    clang::FullSourceLoc Loc,
    clang::PresumedLoc PLoc,
    DiagnosticsEngine::Level Level)

Declared at: clang/include/clang/Frontend/DiagnosticRenderer.h:104

Parameters

clang::FullSourceLoc Loc
clang::PresumedLoc PLoc
DiagnosticsEngine::Level Level

void emitIncludeStackRecursively(
    clang::FullSourceLoc Loc)

Declared at: clang/include/clang/Frontend/DiagnosticRenderer.h:106

Parameters

clang::FullSourceLoc Loc

void emitMacroExpansions(
    clang::FullSourceLoc Loc,
    DiagnosticsEngine::Level Level,
    ArrayRef<clang::CharSourceRange> Ranges,
    ArrayRef<clang::FixItHint> Hints)

Declared at: clang/include/clang/Frontend/DiagnosticRenderer.h:115

Parameters

clang::FullSourceLoc Loc
DiagnosticsEngine::Level Level
ArrayRef<clang::CharSourceRange> Ranges
ArrayRef<clang::FixItHint> Hints

void emitModuleBuildStack(
    const clang::SourceManager& SM)

Declared at: clang/include/clang/Frontend/DiagnosticRenderer.h:109

Parameters

const clang::SourceManager& SM

void emitSingleMacroExpansion(
    clang::FullSourceLoc Loc,
    DiagnosticsEngine::Level Level,
    ArrayRef<clang::CharSourceRange> Ranges)

Declared at: clang/include/clang/Frontend/DiagnosticRenderer.h:112

Parameters

clang::FullSourceLoc Loc
DiagnosticsEngine::Level Level
ArrayRef<clang::CharSourceRange> Ranges

void emitStoredDiagnostic(
    clang::StoredDiagnostic& Diag)

Declared at: clang/include/clang/Frontend/DiagnosticRenderer.h:137

Parameters

clang::StoredDiagnostic& Diag

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

Declared at: clang/include/clang/Frontend/DiagnosticRenderer.h:99

Parameters

clang::DiagOrStoredDiag D
DiagnosticsEngine::Level Level

virtual ~DiagnosticRenderer()

Declared at: clang/include/clang/Frontend/DiagnosticRenderer.h:74