Skip to content

Commit

Permalink
Merge pull request diffblue#2186 from smowton/smowton/fix/call-graph-…
Browse files Browse the repository at this point in the history
…uninit-field

Fix uninitialised collect_callsites field in call_grapht
  • Loading branch information
smowton authored May 16, 2018
2 parents ead0aa3 + 4447be0 commit 2ad157f
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/analyses/call_graph.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,8 @@ static void forall_callsites(
call_grapht::call_grapht(
const goto_functionst &goto_functions,
const irep_idt &root,
bool collect_callsites)
bool collect_callsites):
collect_callsites(collect_callsites)
{
std::stack<irep_idt, std::vector<irep_idt>> pending_stack;
pending_stack.push(root);
Expand Down
22 changes: 22 additions & 0 deletions unit/analyses/call_graph.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,28 @@ SCENARIO("call_graph",
}
}

WHEN("A call graph is constructed from a root and callsite tracking is on")
{
call_grapht call_graph_with_specific_root =
call_grapht::create_from_root_function(goto_model, "B", true);

THEN("The graph should contain nodes for only B, C and D")
{
call_grapht::nodest correct_value {"B", "C", "D"};
REQUIRE(call_graph_with_specific_root.nodes == correct_value);
}
THEN("Only B -> C and B -> D edges should exist, each with one callsite")
{
const auto &check_callsites=call_graph_with_specific_root.callsites;
call_grapht::edgest correct_value { {"B", "C"}, {"B", "D"} };
REQUIRE(call_graph_with_specific_root.edges == correct_value);
for(const auto &edge : call_graph_with_specific_root.edges)
{
REQUIRE(check_callsites.at(edge).size()==1);
}
}
}

WHEN("A call-graph is constructed rooted at B")
{
call_grapht call_graph_from_b =
Expand Down

0 comments on commit 2ad157f

Please sign in to comment.