Skip to content

Fix uninitialised collect_callsites field in call_grapht #2186

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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