[PATCH] D62497: [analyzer] print() JSONify: SVal implementation
Csaba Dabis via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Wed May 29 11:37:10 PDT 2019
This revision was automatically updated to reflect the committed changes.
Closed by commit rL362008: [analyzer] print() JSONify: SVal implementation (authored by Charusso, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.
Changed prior to commit:
https://reviews.llvm.org/D62497?vs=201582&id=202008#toc
Repository:
rL LLVM
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D62497/new/
https://reviews.llvm.org/D62497
Files:
cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/SVals.h
cfe/trunk/lib/StaticAnalyzer/Core/Environment.cpp
cfe/trunk/lib/StaticAnalyzer/Core/SVals.cpp
Index: cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/SVals.h
===================================================================
--- cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/SVals.h
+++ cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/SVals.h
@@ -190,6 +190,9 @@
const MemRegion *getAsRegion() const;
+ /// printJson - Pretty-prints in JSON format.
+ void printJson(raw_ostream &Out, bool AddQuotes) const;
+
void dumpToStream(raw_ostream &OS) const;
void dump() const;
Index: cfe/trunk/lib/StaticAnalyzer/Core/Environment.cpp
===================================================================
--- cfe/trunk/lib/StaticAnalyzer/Core/Environment.cpp
+++ cfe/trunk/lib/StaticAnalyzer/Core/Environment.cpp
@@ -263,10 +263,12 @@
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 << ',';
Index: cfe/trunk/lib/StaticAnalyzer/Core/SVals.cpp
===================================================================
--- cfe/trunk/lib/StaticAnalyzer/Core/SVals.cpp
+++ cfe/trunk/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 @@
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:
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D62497.202008.patch
Type: text/x-patch
Size: 2146 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20190529/f33b2efe/attachment.bin>
More information about the cfe-commits
mailing list