Skip to content

Commit 906d494

Browse files
author
Csaba Dabis
committed
[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 llvm-svn: 364193
1 parent e3a676e commit 906d494

File tree

2 files changed

+10
-10
lines changed

2 files changed

+10
-10
lines changed

clang/lib/StaticAnalyzer/Core/ExprEngine.cpp

+2-6
Original file line numberDiff line numberDiff line change
@@ -3009,7 +3009,7 @@ struct DOTGraphTraits<ExplodedGraph*> : public DefaultDOTGraphTraits {
30093009

30103010
for (const auto &EQ : EQClasses) {
30113011
for (const BugReport &Report : EQ) {
3012-
if (Report.getErrorNode() == N)
3012+
if (Report.getErrorNode()->getState() == N->getState())
30133013
return true;
30143014
}
30153015
}
@@ -3109,11 +3109,7 @@ struct DOTGraphTraits<ExplodedGraph*> : public DefaultDOTGraphTraits {
31093109
Indent(Out, Space, IsDot) << "\"program_state\": null";
31103110
}
31113111

3112-
Out << "\\l}";
3113-
if (!N->succ_empty())
3114-
Out << ',';
3115-
Out << "\\l";
3116-
3112+
Out << "\\l}\\l";
31173113
return Out.str();
31183114
}
31193115
};

clang/test/Analysis/dump_egraph.c

+8-4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
1-
// RUN: %clang_analyze_cc1 -analyzer-checker=core -analyzer-dump-egraph=%t.dot %s
1+
// RUN: %clang_analyze_cc1 -analyzer-checker=core \
2+
// RUN: -analyzer-dump-egraph=%t.dot %s
23
// RUN: cat %t.dot | FileCheck %s
3-
// RUN: %clang_analyze_cc1 -analyzer-checker=core -analyzer-dump-egraph=%t.dot -trim-egraph %s
4+
5+
// RUN: %clang_analyze_cc1 -analyzer-checker=core \
6+
// RUN: -analyzer-dump-egraph=%t.dot \
7+
// RUN: -trim-egraph %s
8+
// RUN: cat %t.dot | FileCheck %s
9+
410
// REQUIRES: asserts
511

612
int getJ();
@@ -10,8 +16,6 @@ int foo() {
1016
return *x + *y;
1117
}
1218

13-
// CHECK: digraph "Exploded Graph" {
14-
1519
// 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
1620

1721
// CHECK: \"program_points\": [\l&nbsp;&nbsp;&nbsp;&nbsp;\{ \"kind\": \"BlockEntrance\", \"block_id\": 1

0 commit comments

Comments
 (0)