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();
   }
 };


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&nbsp;&nbsp;&nbsp;&nbsp;\{ \"kind\": \"Edge\", \"src_id\": 2, \"dst_id\": 1, \"terminator\": null, \"term_kind\": null, \"tag\": null \}\l&nbsp;&nbsp;],\l&nbsp;&nbsp;\"program_state\": null
+// CHECK: \"program_points\": [\l&nbsp;&nbsp;&nbsp;&nbsp;\{ \"kind\": \"Edge\", \"src_id\": 2, \"dst_id\": 1, \"terminator\": null, \"term_kind\": null, \"has_report\": false, \"tag\": null \}\l&nbsp;&nbsp;],\l&nbsp;&nbsp;\"program_state\": null
 
 // CHECK: \"program_points\": [\l&nbsp;&nbsp;&nbsp;&nbsp;\{ \"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();
   }
 };
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to