Skip to content

Commit e65cb9f

Browse files
committed
Fix uninitialised collect_callsites field in call_grapht
This only affected people using both collect_callsites and a call graph restricted to those functions reachable from a particular root function, hence slipping through the net.
1 parent ac6eb21 commit e65cb9f

File tree

2 files changed

+24
-1
lines changed

2 files changed

+24
-1
lines changed

src/analyses/call_graph.cpp

+2-1
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,8 @@ static void forall_callsites(
7474
call_grapht::call_grapht(
7575
const goto_functionst &goto_functions,
7676
const irep_idt &root,
77-
bool collect_callsites)
77+
bool collect_callsites):
78+
collect_callsites(collect_callsites)
7879
{
7980
std::stack<irep_idt, std::vector<irep_idt>> pending_stack;
8081
pending_stack.push(root);

unit/analyses/call_graph.cpp

+22
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,28 @@ SCENARIO("call_graph",
164164
}
165165
}
166166

167+
WHEN("A call graph is constructed with both a specific root and call-site tracking")
168+
{
169+
call_grapht call_graph_with_specific_root =
170+
call_grapht::create_from_root_function(goto_model, "B", true);
171+
172+
THEN("The graph should contain nodes for only B, C and D")
173+
{
174+
call_grapht::nodest correct_value {"B", "C", "D"};
175+
REQUIRE(call_graph_with_specific_root.nodes == correct_value);
176+
}
177+
THEN("Only B -> C and B -> D edges should exist, each with one callsite")
178+
{
179+
const auto &check_callsites=call_graph_with_specific_root.callsites;
180+
call_grapht::edgest correct_value { {"B", "C"}, {"B", "D"} };
181+
REQUIRE(call_graph_with_specific_root.edges == correct_value);
182+
for(const auto &edge : call_graph_with_specific_root.edges)
183+
{
184+
REQUIRE(check_callsites.at(edge).size()==1);
185+
}
186+
}
187+
}
188+
167189
WHEN("A call-graph is constructed rooted at B")
168190
{
169191
call_grapht call_graph_from_b =

0 commit comments

Comments
 (0)