clang
7.0.0
|
Class to encapsulate the logic for formatting and printing a textual diagnostic message. More...
#include "clang/Frontend/TextDiagnostic.h"
Public Member Functions | |
TextDiagnostic (raw_ostream &OS, const LangOptions &LangOpts, DiagnosticOptions *DiagOpts) | |
~TextDiagnostic () override | |
![]() | |
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) |
Static Public Member Functions | |
static void | printDiagnosticLevel (raw_ostream &OS, DiagnosticsEngine::Level Level, bool ShowColors, bool CLFallbackMode=false) |
Print the diagonstic level to a raw_ostream. More... | |
static void | printDiagnosticMessage (raw_ostream &OS, bool IsSupplemental, StringRef Message, unsigned CurrentColumn, unsigned Columns, bool ShowColors) |
Pretty-print a diagnostic message to a raw_ostream. More... | |
Additional Inherited Members | |
![]() | |
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... | |
Class to encapsulate the logic for formatting and printing a textual diagnostic message.
This class provides an interface for building and emitting a textual 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.
The purpose of this class is to isolate the implementation of printing beautiful text diagnostics from any particular interfaces. The Clang DiagnosticClient is implemented through this class as is diagnostic printing coming out of libclang.
Definition at line 35 of file TextDiagnostic.h.
TextDiagnostic::TextDiagnostic | ( | raw_ostream & | OS, |
const LangOptions & | LangOpts, | ||
DiagnosticOptions * | DiagOpts | ||
) |
Definition at line 668 of file TextDiagnostic.cpp.
|
override |
Definition at line 673 of file TextDiagnostic.cpp.
|
overrideprotectedvirtual |
Implements clang::DiagnosticRenderer.
Definition at line 906 of file TextDiagnostic.cpp.
References clang::DiagnosticRenderer::DiagOpts, clang::PresumedLoc::getFilename(), clang::PresumedLoc::getLine(), and clang::PresumedLoc::isValid().
Referenced by emitCodeContext().
|
inlineoverrideprotectedvirtual |
Implements clang::DiagnosticRenderer.
Definition at line 87 of file TextDiagnostic.h.
References emitBuildingModuleLocation(), emitImportLocation(), emitIncludeLocation(), Filename, and SM.
|
overrideprotectedvirtual |
Print out the file/line/column information and include trace.
This method handlen the emission of the diagnostic location information. This includes extracting as much location information as is present for the diagnostic and printing it, as well as any include stack or source ranges necessary.
Implements clang::DiagnosticRenderer.
Definition at line 786 of file TextDiagnostic.cpp.
References clang::DiagnosticOptions::Clang, clang::DiagnosticRenderer::DiagOpts, clang::PresumedLoc::getColumn(), clang::FullSourceLoc::getExpansionLoc(), clang::SourceManager::getExpansionLoc(), clang::SourceManager::getExpansionRange(), clang::FullSourceLoc::getFileEntry(), clang::FullSourceLoc::getFileID(), clang::PresumedLoc::getFilename(), clang::PresumedLoc::getLine(), clang::FullSourceLoc::getManager(), clang::FileEntry::getName(), clang::LangOptions::isCompatibleWithMSVC(), clang::FileEntry::isInPCH(), clang::PresumedLoc::isInvalid(), clang::FileID::isValid(), clang::FileEntry::isValid(), clang::DiagnosticRenderer::LangOpts, clang::DiagnosticOptions::MSVC, clang::LangOptions::MSVC2012, clang::LangOptions::MSVC2015, savedColor, and clang::DiagnosticOptions::Vi.
Referenced by emitDiagnosticMessage().
|
overrideprotectedvirtual |
Implements clang::DiagnosticRenderer.
Definition at line 675 of file TextDiagnostic.cpp.
References clang::DiagnosticRenderer::DiagOpts, emitDiagnosticLoc(), clang::SourceLocation::isValid(), clang::DiagnosticsEngine::Note, printDiagnosticLevel(), and printDiagnosticMessage().
|
overrideprotectedvirtual |
Implements clang::DiagnosticRenderer.
Definition at line 897 of file TextDiagnostic.cpp.
References clang::DiagnosticRenderer::DiagOpts, clang::PresumedLoc::getFilename(), clang::PresumedLoc::getLine(), and clang::PresumedLoc::isValid().
Referenced by emitCodeContext().
|
overrideprotectedvirtual |
Implements clang::DiagnosticRenderer.
Definition at line 889 of file TextDiagnostic.cpp.
References clang::DiagnosticRenderer::DiagOpts, clang::PresumedLoc::getFilename(), clang::PresumedLoc::getLine(), and clang::PresumedLoc::isValid().
Referenced by emitCodeContext().
|
static |
Print the diagonstic level to a raw_ostream.
This is a static helper that handles colorizing the level and formatting it into an arbitrary output stream. This is used internally by the TextDiagnostic emission code, but it can also be used directly by consumers that don't have a source manager or other state that the full TextDiagnostic logic requires.
Definition at line 697 of file TextDiagnostic.cpp.
References clang::DiagnosticsEngine::Error, errorColor, clang::DiagnosticsEngine::Fatal, fatalColor, clang::DiagnosticsEngine::Ignored, clang::DiagnosticsEngine::Note, noteColor, clang::DiagnosticsEngine::Remark, remarkColor, clang::DiagnosticsEngine::Warning, and warningColor.
Referenced by emitDiagnosticMessage(), and clang::TextDiagnosticPrinter::HandleDiagnostic().
|
static |
Pretty-print a diagnostic message to a raw_ostream.
This is a static helper to handle the line wrapping, colorizing, and rendering of a diagnostic message to a particular ostream. It is publicly visible so that clients which do not have sufficient state to build a complete TextDiagnostic object can still get consistent formatting of their diagnostic messages.
OS | Where the message is printed |
IsSupplemental | true if this is a continuation note diagnostic |
Message | The text actually printed |
CurrentColumn | The starting column of the first line, accounting for any prefix. |
Columns | The number of columns to use in line-wrapping, 0 disables all line-wrapping. |
ShowColors | Enable colorizing of the message. |
Definition at line 738 of file TextDiagnostic.cpp.
References applyTemplateHighlighting(), clang::DiagnosticRenderer::DiagOpts, Filename, clang::FileManager::getCanonicalName(), clang::FileManager::getDirectory(), clang::SourceManager::getFileManager(), printWordWrapped(), savedColor, and SM.
Referenced by emitDiagnosticMessage(), and clang::TextDiagnosticPrinter::HandleDiagnostic().