23
23
#include < util/numbering.h>
24
24
25
25
26
- // / Function call graph inherits from grapht to allow forward and
26
+ // / \brief Function call graph: each node represents a function
27
+ // / in the GOTO model, a directed edge from A to B indicates
28
+ // / that function A calls function B.
29
+ // / Inherits from grapht to allow forward and
27
30
// / backward traversal of the function call graph
28
-
29
31
struct call_graph_nodet : public graph_nodet <empty_edget>
30
32
{
31
33
typedef graph_nodet<empty_edget>::edget edget;
@@ -43,11 +45,28 @@ class call_grapht: public grapht<call_graph_nodet>
43
45
44
46
void add (const irep_idt &caller, const irep_idt &callee);
45
47
void output_xml (std::ostream &out) const ;
48
+
49
+ // / \return the inverted call graph
46
50
call_grapht get_inverted () const ;
51
+
52
+ // / \brief get the names of all functions reachable from a start function
53
+ // / \param start name of initial function
54
+ // / \return set of all names of the reachable functions
47
55
std::unordered_set<irep_idt, irep_id_hash>
48
56
reachable_functions (irep_idt start);
57
+
58
+ // / \brief Function returns the shortest path on the function call graph
59
+ // / between a source and a destination function
60
+ // / \param src name of the starting function
61
+ // / \param dest name of the destination function
62
+ // / \return list of function names on the shortest path between src and dest
49
63
std::list<irep_idt>shortest_function_path (irep_idt src, irep_idt dest);
50
64
65
+ // / get the index of the node that corresponds to a function name
66
+ // / \param[in] function_name function_name passed by reference
67
+ // / \param[out] n variable for the node index to be written to
68
+ // / \return true if a node with the given function name exists,
69
+ // / false if it does not exist
51
70
bool get_node_index (const irep_idt& function_name, node_indext &n) const
52
71
{
53
72
for (node_indext idx = 0 ; idx < nodes.size (); idx++)
@@ -61,6 +80,9 @@ class call_grapht: public grapht<call_graph_nodet>
61
80
return false ;
62
81
}
63
82
83
+ // / \brief get a list of functions called by a function
84
+ // / \param function_name the irep_idt of the function
85
+ // / \return an unordered set of all functions called by function_name
64
86
std::unordered_set<irep_idt, irep_id_hash> get_successors (
65
87
const irep_idt& function_name) const
66
88
{
0 commit comments