Skip to content
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