[PATCH] D63436: [analyzer] Fix JSON dumps for ExplodedNodes
Csaba Dabis via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Mon Jun 17 08:43:18 PDT 2019
Charusso created this revision.
Charusso added a reviewer: NoQ.
Charusso added a project: clang.
Herald added subscribers: cfe-commits, dkrupp, donat.nagy, Szelethus, mikhail.ramalho, a.sidorin, szepet, baloghadamsoftware, xazax.hun.
- Now we apply the `has_report` on the proper `ProgramPoint`.
- This patch also removes the trailing comma after each node.
Repository:
rC Clang
https://reviews.llvm.org/D63436
Files:
clang/lib/StaticAnalyzer/Core/ExprEngine.cpp
clang/test/Analysis/dump_egraph.c
Index: clang/test/Analysis/dump_egraph.c
===================================================================
--- clang/test/Analysis/dump_egraph.c
+++ clang/test/Analysis/dump_egraph.c
@@ -1,6 +1,6 @@
-// RUN: %clang_analyze_cc1 -analyzer-checker=core -analyzer-dump-egraph=%t.dot %s
+// RUN: %clang_analyze_cc1 -analyzer-checker=core \
+// RUN: -analyzer-dump-egraph=%t.dot %s
// RUN: cat %t.dot | FileCheck %s
-// RUN: %clang_analyze_cc1 -analyzer-checker=core -analyzer-dump-egraph=%t.dot -trim-egraph %s
// REQUIRES: asserts
int getJ();
@@ -12,7 +12,7 @@
// CHECK: digraph "Exploded Graph" {
-// CHECK: \"program_points\": [\l \{ \"kind\": \"Edge\", \"src_id\": 2, \"dst_id\": 1, \"terminator\": null, \"term_kind\": null, \"tag\": null \}\l ],\l \"program_state\": null
+// CHECK: \"program_points\": [\l \{ \"kind\": \"Edge\", \"src_id\": 2, \"dst_id\": 1, \"terminator\": null, \"term_kind\": null, \"has_report\": false, \"tag\": null \}\l ],\l \"program_state\": null
// CHECK: \"program_points\": [\l \{ \"kind\": \"BlockEntrance\", \"block_id\": 1
Index: clang/lib/StaticAnalyzer/Core/ExprEngine.cpp
===================================================================
--- clang/lib/StaticAnalyzer/Core/ExprEngine.cpp
+++ clang/lib/StaticAnalyzer/Core/ExprEngine.cpp
@@ -3076,9 +3076,7 @@
ProgramStateRef State = N->getState();
Out << "{ \"node_id\": " << N->getID(G) << ", \"pointer\": \""
- << (const void *)N << "\", \"state_id\": " << State->getID()
- << ", \"has_report\": " << (nodeHasBugReport(N) ? "true" : "false")
- << ",\\l";
+ << (const void *)N << "\", \"state_id\": " << State->getID() << ",\\l";
Indent(Out, Space, IsDot) << "\"program_points\": [\\l";
@@ -3088,7 +3086,9 @@
[&](const ExplodedNode *OtherNode) {
Indent(Out, Space + 1, IsDot) << "{ ";
OtherNode->getLocation().printJson(Out, /*NL=*/"\\l");
- Out << ", \"tag\": ";
+ Out << ", \"has_report\": "
+ << (nodeHasBugReport(OtherNode) ? "true" : "false")
+ << ", \"tag\": ";
if (const ProgramPointTag *Tag = OtherNode->getLocation().getTag())
Out << '\"' << Tag->getTagDescription() << "\" }";
else
@@ -3112,11 +3112,7 @@
Indent(Out, Space, IsDot) << "\"program_state\": null";
}
- Out << "\\l}";
- if (!N->succ_empty())
- Out << ',';
- Out << "\\l";
-
+ Out << "\\l}\\l";
return Out.str();
}
};
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D63436.205086.patch
Type: text/x-patch
Size: 2608 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20190617/42b373c1/attachment.bin>
More information about the cfe-commits
mailing list