summaryrefslogtreecommitdiffstats
path: root/clang/lib/StaticAnalyzer/Core
diff options
context:
space:
mode:
Diffstat (limited to 'clang/lib/StaticAnalyzer/Core')
-rw-r--r--clang/lib/StaticAnalyzer/Core/Environment.cpp6
-rw-r--r--clang/lib/StaticAnalyzer/Core/SVals.cpp10
2 files changed, 14 insertions, 2 deletions
diff --git a/clang/lib/StaticAnalyzer/Core/Environment.cpp b/clang/lib/StaticAnalyzer/Core/Environment.cpp
index 3ebb66c6af1..94cc4d6dbb2 100644
--- a/clang/lib/StaticAnalyzer/Core/Environment.cpp
+++ b/clang/lib/StaticAnalyzer/Core/Environment.cpp
@@ -263,10 +263,12 @@ void Environment::printJson(raw_ostream &Out, const ASTContext &Ctx,
Indent(Out, InnerSpace, IsDot)
<< "{ \"lctx_id\": " << LC->getID()
<< ", \"stmt_id\": " << S->getID(Ctx) << ", \"pretty\": ";
-
S->printJson(Out, nullptr, PP, /*AddQuotes=*/true);
- Out << ", \"value\": \"" << I->second << "\" }";
+ Out << ", \"value\": ";
+ I->second.printJson(Out, /*AddQuotes=*/true);
+
+ Out << " }";
if (I != LastI)
Out << ',';
diff --git a/clang/lib/StaticAnalyzer/Core/SVals.cpp b/clang/lib/StaticAnalyzer/Core/SVals.cpp
index b3c83e7792d..9b5de6c3eb9 100644
--- a/clang/lib/StaticAnalyzer/Core/SVals.cpp
+++ b/clang/lib/StaticAnalyzer/Core/SVals.cpp
@@ -16,6 +16,7 @@
#include "clang/AST/DeclCXX.h"
#include "clang/AST/Expr.h"
#include "clang/AST/Type.h"
+#include "clang/Basic/JsonSupport.h"
#include "clang/Basic/LLVM.h"
#include "clang/StaticAnalyzer/Core/PathSensitive/BasicValueFactory.h"
#include "clang/StaticAnalyzer/Core/PathSensitive/MemRegion.h"
@@ -283,6 +284,15 @@ SVal loc::ConcreteInt::evalBinOp(BasicValueFactory& BasicVals,
LLVM_DUMP_METHOD void SVal::dump() const { dumpToStream(llvm::errs()); }
+void SVal::printJson(raw_ostream &Out, bool AddQuotes) const {
+ std::string Buf;
+ llvm::raw_string_ostream TempOut(Buf);
+
+ dumpToStream(TempOut);
+
+ Out << JsonFormat(TempOut.str(), AddQuotes);
+}
+
void SVal::dumpToStream(raw_ostream &os) const {
switch (getBaseKind()) {
case UnknownValKind:
OpenPOWER on IntegriCloud