CBMC
call_graph_helpers.h File Reference

Function Call Graph Helpers. More...

#include "call_graph.h"
+ Include dependency graph for call_graph_helpers.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

std::set< irep_idtget_callees (const call_grapht::directed_grapht &graph, const irep_idt &function)
 Get functions directly callable from a given function. More...
 
std::set< irep_idtget_callers (const call_grapht::directed_grapht &graph, const irep_idt &function)
 Get functions that call a given function. More...
 
std::set< irep_idtget_reachable_functions (const call_grapht::directed_grapht &graph, const irep_idt &function)
 Get functions reachable from a given function. More...
 
std::set< irep_idtget_reaching_functions (const call_grapht::directed_grapht &graph, const irep_idt &function)
 Get functions that can reach a given function. More...
 
std::set< irep_idtget_functions_reachable_within_n_steps (const call_grapht::directed_grapht &graph, const std::set< irep_idt > &start_functions, std::size_t n)
 Get either callers or callees reachable from a given list of functions within N steps. More...
 
std::set< irep_idtget_functions_reachable_within_n_steps (const call_grapht::directed_grapht &graph, const irep_idt &start_function, std::size_t n)
 Get either callers or callees reachable from a given list of functions within N steps. More...
 
std::list< irep_idtget_shortest_function_path (const call_grapht::directed_grapht &graph, const irep_idt &src, const irep_idt &dest)
 Get list of functions on the shortest path between two functions. More...
 
void disconnect_unreachable_functions (call_grapht::directed_grapht &graph, const irep_idt &function)
 Disconnects all functions in the call graph that are unreachable from a given start function. More...
 

Detailed Description

Function Call Graph Helpers.

Definition in file call_graph_helpers.h.

Function Documentation

◆ disconnect_unreachable_functions()

void disconnect_unreachable_functions ( call_grapht::directed_grapht graph,
const irep_idt function 
)

Disconnects all functions in the call graph that are unreachable from a given start function.

Removing nodes requires re-indexing, so instead we disconnect them, removing all in and out edges from those nodes. This speeds up backwards reachability.

Parameters
graphcall graph
functionstart function

Definition at line 100 of file call_graph_helpers.cpp.

◆ get_callees()

std::set<irep_idt> get_callees ( const call_grapht::directed_grapht graph,
const irep_idt function 
)

Get functions directly callable from a given function.

Parameters
graphcall graph
functionfunction to query
Returns
set of called functions

Definition at line 31 of file call_graph_helpers.cpp.

◆ get_callers()

std::set<irep_idt> get_callers ( const call_grapht::directed_grapht graph,
const irep_idt function 
)

Get functions that call a given function.

Parameters
graphcall graph
functionfunction to query
Returns
set of caller functions

Definition at line 37 of file call_graph_helpers.cpp.

◆ get_functions_reachable_within_n_steps() [1/2]

std::set<irep_idt> get_functions_reachable_within_n_steps ( const call_grapht::directed_grapht graph,
const irep_idt start_function,
std::size_t  n 
)

Get either callers or callees reachable from a given list of functions within N steps.

Parameters
graphcall graph
start_functionsingle start function
nnumber of steps to consider
Returns
set of functions that can be reached from the start function including the start function

Definition at line 91 of file call_graph_helpers.cpp.

◆ get_functions_reachable_within_n_steps() [2/2]

std::set<irep_idt> get_functions_reachable_within_n_steps ( const call_grapht::directed_grapht graph,
const std::set< irep_idt > &  start_functions,
std::size_t  n 
)

Get either callers or callees reachable from a given list of functions within N steps.

Parameters
graphcall graph
start_functionsset of start functions
nnumber of steps to consider
Returns
set of functions that can be reached from the start function including the start function

Definition at line 74 of file call_graph_helpers.cpp.

◆ get_reachable_functions()

std::set<irep_idt> get_reachable_functions ( const call_grapht::directed_grapht graph,
const irep_idt function 
)

Get functions reachable from a given function.

Parameters
graphcall graph
functionfunction to query
Returns
set of reachable functions, including function

Definition at line 62 of file call_graph_helpers.cpp.

◆ get_reaching_functions()

std::set<irep_idt> get_reaching_functions ( const call_grapht::directed_grapht graph,
const irep_idt function 
)

Get functions that can reach a given function.

Parameters
graphcall graph
functionfunction to query
Returns
set of functions that can reach the target, including function

Definition at line 68 of file call_graph_helpers.cpp.

◆ get_shortest_function_path()

std::list<irep_idt> get_shortest_function_path ( const call_grapht::directed_grapht graph,
const irep_idt src,
const irep_idt dest 
)

Get list of functions on the shortest path between two functions.

Parameters
graphcall graph
srcfunction to start from
destfunction to reach
Returns
list of functions on shortest path

Definition at line 107 of file call_graph_helpers.cpp.