20#include "llvm/ADT/SmallString.h"
21#include "llvm/Support/ErrorHandling.h"
22#include "llvm/Support/JSON.h"
23#include "llvm/Support/raw_ostream.h"
30 : OS(OS), DiagOpts(Diags) {}
36 assert(!SARIFDiag &&
"SARIFDiagnostic already set.");
37 SARIFDiag = std::make_unique<SARIFDiagnostic>(OS, LO, &*DiagOpts, &*Writer);
39 Writer->createRun(
"clang", Prefix);
43 assert(SARIFDiag &&
"SARIFDiagnostic has not been set.");
45 llvm::json::Value
Value(Writer->createDocument());
46 OS <<
"\n" <<
Value <<
"\n\n";
53 assert(SARIFDiag &&
"SARIFDiagnostic has not been set.");
63 llvm::raw_svector_ostream DiagMessageStream(OutStr);
75 assert(DiagOpts &&
"Unexpected diagnostic without options set");
77 "Unexpected diagnostic with no source manager");
79 SARIFDiag->emitDiagnostic(
Defines clang::SarifDocumentWriter, clang::SarifRule, clang::SarifResult.
Defines the SourceManager interface.
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.
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.
SARIFDiagnosticPrinter(raw_ostream &OS, DiagnosticOptions *Diags)
The JSON file list parser is used to communicate input to InstallAPI.