clang 20.0.0git
|
This class handles creating a valid SARIF document given various input attributes. More...
#include "clang/Basic/Sarif.h"
Public Member Functions | |
SarifDocumentWriter ()=delete | |
SarifDocumentWriter (const SourceManager &SourceMgr) | |
Create a new empty SARIF document with the given source manager. | |
~SarifDocumentWriter ()=default | |
Release resources held by this SARIF document. | |
void | createRun (const llvm::StringRef ShortToolName, const llvm::StringRef LongToolName, const llvm::StringRef ToolVersion=CLANG_VERSION_STRING) |
Create a new run with which any upcoming analysis will be associated. | |
void | endRun () |
If there is a current run, end it. | |
size_t | createRule (const SarifRule &Rule) |
Associate the given rule with the current run. | |
void | appendResult (const SarifResult &SarifResult) |
Append a new result to the currently in-flight run. | |
llvm::json::Object | createDocument () |
Return the SARIF document in its current state. | |
This class handles creating a valid SARIF document given various input attributes.
However, it requires an ordering among certain method calls:
run
, callers must ensure that SarifDocumentWriter::createRun is called before any other methods.
|
delete |
|
inline |
|
default |
Release resources held by this SARIF document.
void SarifDocumentWriter::appendResult | ( | const SarifResult & | SarifResult | ) |
Append a new result to the currently in-flight run.
RuleIdx
used to create the result must correspond to a rule known by the SARIF document. It must be the value returned by a previous call to createRule. Definition at line 385 of file Sarif.cpp.
References createLocation(), createMessage(), Range, clang::Result, and resultLevelToStr().
Referenced by clang::SARIFDiagnostic::emitDiagnosticMessage().
json::Object SarifDocumentWriter::createDocument | ( | ) |
Associate the given rule with the current run.
Returns an integer rule index for the created rule that is unique within the current run, which can then be used to create a SarifResult to add to the current run. Note that a rule must exist before being referenced by a result.
Definition at line 379 of file Sarif.cpp.
Referenced by createRuleMapping(), and clang::SARIFDiagnostic::emitDiagnosticMessage().
void SarifDocumentWriter::createRun | ( | const llvm::StringRef | ShortToolName, |
const llvm::StringRef | LongToolName, | ||
const llvm::StringRef | ToolVersion = CLANG_VERSION_STRING |
||
) |
void SarifDocumentWriter::endRun | ( | ) |
If there is a current run, end it.
This method collects various book-keeping required to clear and close resources associated with the current run, but may also allocate some for the next run.
Calling endRun before associating a run through createRun leads to undefined behaviour.
Definition at line 261 of file Sarif.cpp.
References clang::if(), Loc, resultLevelToStr(), and V.
Referenced by createDocument(), and createRun().