r364193 - [analyzer] Fix JSON dumps for ExplodedNodes

Csaba Dabis via cfe-commits cfe-commits at lists.llvm.org
Mon Jun 24 09:06:44 PDT 2019


Author: charusso
Date: Mon Jun 24 09:06:44 2019
New Revision: 364193

URL: http://llvm.org/viewvc/llvm-project?rev=364193&view=rev
Log:
[analyzer] Fix JSON dumps for ExplodedNodes

Summary:
- Now we could see the `has_report` property in `trim-egraph` mode.
- This patch also removes the trailing comma after each node.

Reviewers: NoQ

Reviewed By: NoQ

Subscribers: xazax.hun, baloghadamsoftware, szepet, a.sidorin,
             mikhail.ramalho, Szelethus, donat.nagy, dkrupp, cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D63436

Modified:
    cfe/trunk/lib/StaticAnalyzer/Core/ExprEngine.cpp
    cfe/trunk/test/Analysis/dump_egraph.c

Modified: cfe/trunk/lib/StaticAnalyzer/Core/ExprEngine.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Core/ExprEngine.cpp?rev=364193&r1=364192&r2=364193&view=diff
==============================================================================
--- cfe/trunk/lib/StaticAnalyzer/Core/ExprEngine.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Core/ExprEngine.cpp Mon Jun 24 09:06:44 2019
@@ -3009,7 +3009,7 @@ struct DOTGraphTraits<ExplodedGraph*> :
 
     for (const auto &EQ : EQClasses) {
       for (const BugReport &Report : EQ) {
-        if (Report.getErrorNode() == N)
+        if (Report.getErrorNode()->getState() == N->getState())
           return true;
       }
     }
@@ -3109,11 +3109,7 @@ struct DOTGraphTraits<ExplodedGraph*> :
       Indent(Out, Space, IsDot) << "\"program_state\": null";
     }
 
-    Out << "\\l}";
-    if (!N->succ_empty())
-      Out << ',';
-    Out << "\\l";
-
+    Out << "\\l}\\l";
     return Out.str();
   }
 };

Modified: cfe/trunk/test/Analysis/dump_egraph.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/dump_egraph.c?rev=364193&r1=364192&r2=364193&view=diff
==============================================================================
--- cfe/trunk/test/Analysis/dump_egraph.c (original)
+++ cfe/trunk/test/Analysis/dump_egraph.c Mon Jun 24 09:06:44 2019
@@ -1,6 +1,12 @@
-// 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
+
+// RUN: %clang_analyze_cc1 -analyzer-checker=core \
+// RUN:  -analyzer-dump-egraph=%t.dot \
+// RUN:  -trim-egraph %s
+// RUN: cat %t.dot | FileCheck %s
+
 // REQUIRES: asserts
 
 int getJ();
@@ -10,8 +16,6 @@ int foo() {
   return *x + *y;
 }
 
-// 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\": \"BlockEntrance\", \"block_id\": 1




More information about the cfe-commits mailing list