19#include "llvm/Support/ErrorHandling.h"
20#include "llvm/Support/JSON.h"
21#include "llvm/Support/raw_ostream.h"
27 : OS(OS), DiagOpts(DiagOpts) {}
33 assert(!SARIFDiag &&
"SARIFDiagnostic already set.");
34 SARIFDiag = std::make_unique<SARIFDiagnostic>(OS, LO, DiagOpts, &*Writer);
36 Writer->createRun(
"clang", Prefix);
40 assert(SARIFDiag &&
"SARIFDiagnostic has not been set.");
42 llvm::json::Value
Value(Writer->createDocument());
43 OS <<
"\n" <<
Value <<
"\n\n";
50 assert(SARIFDiag &&
"SARIFDiagnostic has not been set.");
60 llvm::raw_svector_ostream DiagMessageStream(OutStr);
73 "Unexpected diagnostic with no source manager");
75 SARIFDiag->emitDiagnostic(
Defines clang::SarifDocumentWriter, clang::SarifRule, clang::SarifResult.
virtual void HandleDiagnostic(DiagnosticsEngine::Level DiagLevel, const Diagnostic &Info)
Handle this diagnostic, reporting it to the user or capturing it to a log as needed.
Options for controlling the compiler diagnostics engine.
A little helper class (which is basically a smart pointer that forwards info from DiagnosticsEngine a...
const SourceLocation & getLocation() const
void FormatDiagnostic(SmallVectorImpl< char > &OutStr) const
Format this diagnostic into a string, substituting the formal arguments into the %0 slots.
SourceManager & getSourceManager() const
ArrayRef< FixItHint > getFixItHints() const
bool hasSourceManager() const
ArrayRef< CharSourceRange > getRanges() const
Return an array reference for this diagnostic's ranges.
Level
The level of the diagnostic, after it has been through mapping.
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...
Engages in a tight little dance with the lexer to efficiently preprocess tokens.
SARIFDiagnosticPrinter(raw_ostream &OS, DiagnosticOptions &DiagOpts)
void EndSourceFile() override
Callback to inform the diagnostic client that processing of a source file has ended.
bool hasSarifWriter() const
void HandleDiagnostic(DiagnosticsEngine::Level Level, const Diagnostic &Info) override
Handle this diagnostic, reporting it to the user or capturing it to a log as needed.
void BeginSourceFile(const LangOptions &LO, const Preprocessor *PP) override
Callback to inform the diagnostic client that processing of a source file is beginning.
The JSON file list parser is used to communicate input to InstallAPI.