]> granicus.if.org Git - clang/commitdiff
[analyzer] Fix JSON dumps for ExplodedNodes
authorCsaba Dabis <dabis.csaba98@gmail.com>
Mon, 24 Jun 2019 16:06:44 +0000 (16:06 +0000)
committerCsaba Dabis <dabis.csaba98@gmail.com>
Mon, 24 Jun 2019 16:06:44 +0000 (16:06 +0000)
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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@364193 91177308-0d34-0410-b5e6-96231b3b80d8

lib/StaticAnalyzer/Core/ExprEngine.cpp
test/Analysis/dump_egraph.c

index 2cef99157c7fe0fedcb60760b4b3d6bb4c407919..38422eb1b1beef162567fb17cde6b7dbee42d713 100644 (file)
@@ -3009,7 +3009,7 @@ struct DOTGraphTraits<ExplodedGraph*> : public DefaultDOTGraphTraits {
 
     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*> : public DefaultDOTGraphTraits {
       Indent(Out, Space, IsDot) << "\"program_state\": null";
     }
 
-    Out << "\\l}";
-    if (!N->succ_empty())
-      Out << ',';
-    Out << "\\l";
-
+    Out << "\\l}\\l";
     return Out.str();
   }
 };
index f1ac03b10cc94e0ef6d0b6f5aabe4e3b27ad0b10..701e9850798322d0eb3943d8d66b4881544bc2bf 100644 (file)
@@ -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&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\": \"BlockEntrance\", \"block_id\": 1