Skip to content

Commit 7a17f19

Browse files
committed
[analyzer] Fix hidden node traversal in exploded graph dumps.
The joined nodes now actually have the same state. That was intended from the start but the original implementation turned out to be buggy. Differential Revision: https://reviews.llvm.org/D69150 llvm-svn: 375278
1 parent 9f9151d commit 7a17f19

File tree

2 files changed

+29
-15
lines changed

2 files changed

+29
-15
lines changed

clang/lib/StaticAnalyzer/Core/ExprEngine.cpp

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3030,22 +3030,16 @@ struct DOTGraphTraits<ExplodedGraph*> : public DefaultDOTGraphTraits {
30303030
llvm::function_ref<void(const ExplodedNode *)> PreCallback,
30313031
llvm::function_ref<void(const ExplodedNode *)> PostCallback,
30323032
llvm::function_ref<bool(const ExplodedNode *)> Stop) {
3033-
const ExplodedNode *FirstHiddenNode = N;
3034-
while (FirstHiddenNode->pred_size() == 1 &&
3035-
isNodeHidden(*FirstHiddenNode->pred_begin())) {
3036-
FirstHiddenNode = *FirstHiddenNode->pred_begin();
3037-
}
3038-
const ExplodedNode *OtherNode = FirstHiddenNode;
30393033
while (true) {
3040-
PreCallback(OtherNode);
3041-
if (Stop(OtherNode))
3034+
PreCallback(N);
3035+
if (Stop(N))
30423036
return true;
30433037

3044-
if (OtherNode == N)
3038+
if (N->succ_size() != 1 || !isNodeHidden(N->getFirstSucc()))
30453039
break;
3046-
PostCallback(OtherNode);
3040+
PostCallback(N);
30473041

3048-
OtherNode = *OtherNode->succ_begin();
3042+
N = N->getFirstSucc();
30493043
}
30503044
return false;
30513045
}

clang/test/Analysis/dump_egraph.c

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,30 @@ int foo() {
1818
return *x + *y;
1919
}
2020

21-
// CHECK: \"program_points\": [\l&nbsp;&nbsp;&nbsp;&nbsp;\{ \"kind\": \"Edge\", \"src_id\": 2, \"dst_id\": 1, \"terminator\": null, \"term_kind\": null, \"tag\": null, \"node_id\": 1, \"is_sink\": 0, \"has_report\": 0 \}\l&nbsp;&nbsp;],\l&nbsp;&nbsp;\"program_state\": null
22-
23-
// CHECK: \"program_points\": [\l&nbsp;&nbsp;&nbsp;&nbsp;\{ \"kind\": \"BlockEntrance\", \"block_id\": 1
24-
21+
// CHECK: \"program_points\": [\l
22+
// CHECK-SAME: \{ \"kind\": \"Edge\", \"src_id\": 2, \"dst_id\": 1,
23+
// CHECK-SAME: \"terminator\": null, \"term_kind\": null, \"tag\": null,
24+
// CHECK-SAME: \"node_id\": 1, \"is_sink\": 0, \"has_report\": 0
25+
// CHECK-SAME: \},
26+
// CHECK-SAME: \{ \"kind\": \"BlockEntrance\", \"block_id\": 1, \"tag\": null,
27+
// CHECK-SAME: \"node_id\": 2, \"is_sink\": 0, \"has_report\": 0
28+
// CHECK-SAME: \},
29+
// CHECK-SAME: \{ \"kind\": \"Statement\", \"stmt_kind\": \"IntegerLiteral\",
30+
// CHECK-SAME: \"stmt_id\": 597, \"pointer\": \"0x{{[0-9a-f]*}}\",
31+
// CHECK-SAME: \"pretty\": \"0\", \"location\": \{
32+
// CHECK-SAME: \"line\": 15, \"column\": 12, \"file\":
33+
// CHECK-SAME: \}, \"stmt_point_kind\": \"PreStmtPurgeDeadSymbols\",
34+
// CHECK-SAME: \"tag\": \"ExprEngine : Clean Node\", \"node_id\": 3,
35+
// CHECK-SAME: \"is_sink\": 0, \"has_report\": 0
36+
// CHECK-SAME: \},
37+
// CHECK-SAME: \{ \"kind\": \"Statement\", \"stmt_kind\": \"IntegerLiteral\",
38+
// CHECK-SAME: \"stmt_id\": 597, \"pointer\": \"0x{{[0-9a-f]*}}\",
39+
// CHECK-SAME: \"pretty\": \"0\", \"location\": \{
40+
// CHECK-SAME: \"line\": 15, \"column\": 12, \"file\":
41+
// CHECK-SAME: \}, \"stmt_point_kind\": \"PostStmt\", \"tag\": null,
42+
// CHECK-SAME: \"node_id\": 4, \"is_sink\": 0, \"has_report\": 0
43+
// CHECK-SAME: \}
44+
// CHECK-SAME: ]
2545

2646
// CHECK: \"pretty\": \"*x\", \"location\": \{ \"line\": 18, \"column\": 10, \"file\": \"{{(.+)}}dump_egraph.c\" \}
2747

0 commit comments

Comments
 (0)