12#include "llvm/ADT/StringMap.h"
13#include "llvm/Support/Error.h"
14#include "llvm/Support/FileSystem.h"
15#include "llvm/Support/FormatVariadic.h"
16#include "llvm/Support/JSON.h"
17#include "llvm/Support/raw_ostream.h"
23 llvm::StringRef Path) {
25 llvm::raw_fd_ostream OS(Path, EC, llvm::sys::fs::OF_None);
27 return llvm::createStringError(EC,
"failed to open '" + Path +
"'");
30 std::string LongToolName =
31 "clang ScalableStaticAnalysisFramework source transformation (" +
33 Writer.
createRun(
"clang-ssaf", LongToolName, CLANG_VERSION_STRING);
35 llvm::StringMap<size_t> RuleIndex;
37 if (RuleIndex.contains(R.RuleId))
48 if (R.Range.isValid())
54 OS << llvm::formatv(
"{0:2}", Document) <<
"\n";
55 return llvm::Error::success();
Defines clang::SarifDocumentWriter, clang::SarifRule, clang::SarifResult.
Defines version macros and version-related utility functions for Clang.
This class handles creating a valid SARIF document given various input attributes.
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.
size_t createRule(const SarifRule &Rule)
Associate the given rule with the current run.
llvm::json::Object createDocument()
Return the SARIF document in its current state.
void appendResult(const SarifResult &SarifResult)
Append a new result to the currently in-flight run.
A SARIF result (also called a "reporting item") is a unit of output produced when one of the tool's r...
SarifResult setDiagnosticMessage(llvm::StringRef Message)
SarifResult setRuleId(llvm::StringRef Id)
SarifResult setDiagnosticLevel(const SarifResultLevel &TheLevel)
static SarifResult create(uint32_t RuleIdx)
static SarifRule create()
llvm::Error writeSARIFTransformationReport(const ReportDocument &Doc, llvm::StringRef Path)
Writes Doc to Path as a SARIF JSON document.
The JSON file list parser is used to communicate input to InstallAPI.
@ Result
The result type of a method or function.
std::string TransformationName
const clang::SourceManager & SM
std::vector< ReportResult > Results