diff options
author | Dimitry Andric <dim@FreeBSD.org> | 2020-07-26 19:36:28 +0000 |
---|---|---|
committer | Dimitry Andric <dim@FreeBSD.org> | 2020-07-26 19:36:28 +0000 |
commit | cfca06d7963fa0909f90483b42a6d7d194d01e08 (patch) | |
tree | 209fb2a2d68f8f277793fc8df46c753d31bc853b /clang/lib/StaticAnalyzer/Core/SarifDiagnostics.cpp | |
parent | 706b4fc47bbc608932d3b491ae19a3b9cde9497b (diff) |
Notes
Diffstat (limited to 'clang/lib/StaticAnalyzer/Core/SarifDiagnostics.cpp')
-rw-r--r-- | clang/lib/StaticAnalyzer/Core/SarifDiagnostics.cpp | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/clang/lib/StaticAnalyzer/Core/SarifDiagnostics.cpp b/clang/lib/StaticAnalyzer/Core/SarifDiagnostics.cpp index 12332aaf936fa..8c2e856015768 100644 --- a/clang/lib/StaticAnalyzer/Core/SarifDiagnostics.cpp +++ b/clang/lib/StaticAnalyzer/Core/SarifDiagnostics.cpp @@ -11,6 +11,7 @@ //===----------------------------------------------------------------------===// #include "clang/Analysis/PathDiagnostic.h" +#include "clang/Basic/FileManager.h" #include "clang/Basic/Version.h" #include "clang/Lex/Preprocessor.h" #include "clang/StaticAnalyzer/Core/AnalyzerOptions.h" @@ -49,8 +50,14 @@ public: void ento::createSarifDiagnosticConsumer( AnalyzerOptions &AnalyzerOpts, PathDiagnosticConsumers &C, const std::string &Output, const Preprocessor &PP, - const cross_tu::CrossTranslationUnitContext &) { + const cross_tu::CrossTranslationUnitContext &CTU) { + + // TODO: Emit an error here. + if (Output.empty()) + return; + C.push_back(new SarifDiagnostics(AnalyzerOpts, Output, PP.getLangOpts())); + createTextMinimalPathDiagnosticConsumer(AnalyzerOpts, C, Output, PP, CTU); } static StringRef getFileName(const FileEntry &FE) { @@ -106,7 +113,7 @@ static std::string fileNameToURI(StringRef Filename) { } }); - return Ret.str().str(); + return std::string(Ret); } static json::Object createArtifactLocation(const FileEntry &FE) { @@ -322,7 +329,7 @@ static json::Object createRule(const PathDiagnostic &Diag) { {"name", CheckName}, {"id", CheckName}}; - std::string RuleURI = getRuleHelpURIStr(CheckName); + std::string RuleURI = std::string(getRuleHelpURIStr(CheckName)); if (!RuleURI.empty()) Ret["helpUri"] = RuleURI; |