25#include "llvm/ADT/SmallPtrSet.h"
26#include "llvm/ADT/SmallVector.h"
27#include "llvm/Support/Casting.h"
31using namespace tooling;
41 bool ShouldDisplayPathNotes;
46 bool ShouldDisplayPathNotes)
47 : DiagOpts(
std::move(DiagOpts)), DiagEng(DiagEng), LO(LO),
48 ShouldDisplayPathNotes(ShouldDisplayPathNotes) {}
49 ~TextDiagnostics()
override {}
51 StringRef
getName()
const override {
return "TextDiagnostics"; }
61 FilesMade *filesMade)
override {
74 DiagEng.
Report(
Loc, ID) << String << Ranges << Fixits;
78 DiagEng.
Report(
Loc, ID) << String << Ranges;
82 if (llvm::Error Err = Repls.
add(Repl)) {
83 llvm::errs() <<
"Error applying replacement " << Repl.toString()
84 <<
": " << Err <<
"\n";
91 ?
" [" + PD->getCheckerName() +
"]"
95 reportPiece(WarnID, PD->getLocation().asLocation(),
96 (PD->getShortDescription() + WarningMsg).str(),
97 PD->path.back()->getRanges(), PD->path.back()->getFixits());
100 for (
const auto &Piece : PD->path) {
101 if (!isa<PathDiagnosticNotePiece>(Piece.get()))
104 reportPiece(NoteID, Piece->getLocation().asLocation(),
105 Piece->getString(), Piece->getRanges(),
109 if (!ShouldDisplayPathNotes)
114 for (
const auto &Piece : FlatPath) {
115 if (isa<PathDiagnosticNotePiece>(Piece.get()))
118 reportPiece(NoteID, Piece->getLocation().asLocation(),
119 Piece->getString(), Piece->getRanges(),
129 llvm::errs() <<
"An error occurred during applying fix-it.\n";
132 Rewrite.overwriteChangedFiles();
137void ento::createTextPathDiagnosticConsumer(
142 C.emplace_back(
new TextDiagnostics(std::move(DiagOpts), PP.
getDiagnostics(),
147void ento::createTextMinimalPathDiagnosticConsumer(
152 C.emplace_back(
new TextDiagnostics(std::move(DiagOpts), PP.
getDiagnostics(),
Defines the clang::Preprocessor interface.
Defines the SourceManager interface.
Defines version macros and version-related utility functions for Clang.
Concrete class used by the front-end to report problems and issues.
DiagnosticBuilder Report(SourceLocation Loc, unsigned DiagID)
Issue the message to the client.
unsigned getCustomDiagID(Level L, const char(&FormatString)[N])
Return an ID for a diagnostic with the specified format string and level.
SourceManager & getSourceManager() const
Annotates a diagnostic with some code that should be inserted, removed, or replaced to fix the proble...
A SourceLocation and its associated SourceManager.
Keeps track of the various options that can be enabled, which controls the dialect of C or C++ that i...
MacroExpansionContext tracks the macro expansions processed by the Preprocessor.
Engages in a tight little dance with the lexer to efficiently preprocess tokens.
const LangOptions & getLangOpts() const
DiagnosticsEngine & getDiagnostics() const
Rewriter - This is the main interface to the rewrite buffers.
This class handles loading and caching of source files into memory.
This class is used for tools that requires cross translation unit capability.
@ None
Only runs visitors, no output generated.
@ Minimal
Used for SARIF and text output.
virtual bool supportsLogicalOpControlFlow() const
virtual void FlushDiagnosticsImpl(std::vector< const PathDiagnostic * > &Diags, FilesMade *filesMade)=0
virtual bool supportsCrossFileDiagnostics() const
Return true if the PathDiagnosticConsumer supports individual PathDiagnostics that span multiple file...
virtual StringRef getName() const =0
virtual PathGenerationScheme getGenerationScheme() const
PathDiagnostic - PathDiagnostic objects represent a single path-sensitive diagnostic.
PathPieces flatten(bool ShouldFlattenMacros) const
std::vector< PathDiagnosticConsumer * > PathDiagnosticConsumers
The JSON file list parser is used to communicate input to InstallAPI.
@ Rewrite
We are substituting template parameters for (typically) other template parameters in order to rewrite...
These options tweak the behavior of path diangostic consumers.
bool ShouldDisplayWarningsAsErrors
Whether the consumer should treat consumed diagnostics as hard errors.
bool ShouldApplyFixIts
Whether the consumer should attempt to rewrite the source file with fix-it hints attached to the diag...
bool ShouldDisplayDiagnosticName
Whether the consumer should present the name of the entity that emitted the diagnostic (eg....