13
13
14
14
/* ******************************************************************\
15
15
16
- Function: call_grapht::call_grapht
16
+ Function: call_grapht::operator()
17
17
18
18
Inputs:
19
19
@@ -23,23 +23,7 @@ Function: call_grapht::call_grapht
23
23
24
24
\*******************************************************************/
25
25
26
- call_grapht::call_grapht ()
27
- {
28
- }
29
-
30
- /* ******************************************************************\
31
-
32
- Function: call_grapht::call_grapht
33
-
34
- Inputs:
35
-
36
- Outputs:
37
-
38
- Purpose:
39
-
40
- \*******************************************************************/
41
-
42
- call_grapht::call_grapht (const goto_functionst &goto_functions)
26
+ void call_grapht::operator ()()
43
27
{
44
28
forall_goto_functions (f_it, goto_functions)
45
29
{
@@ -96,6 +80,53 @@ void call_grapht::add(
96
80
97
81
/* ******************************************************************\
98
82
83
+ Function: call_grapht::compute_reachable
84
+
85
+ Inputs:
86
+
87
+ Outputs:
88
+
89
+ Purpose:
90
+
91
+ \*******************************************************************/
92
+
93
+ void call_grapht::compute_reachable (
94
+ const irep_idt entry_point,
95
+ std::unordered_set<irep_idt, irep_id_hash> &reachable_functions)
96
+ {
97
+ assert (reachable_functions.empty ());
98
+
99
+ std::list<irep_idt> worklist;
100
+
101
+ const goto_functionst::function_mapt::const_iterator e_it=
102
+ goto_functions.function_map .find (entry_point);
103
+
104
+ assert (e_it!=goto_functions.function_map .end ());
105
+
106
+ worklist.push_back (entry_point);
107
+
108
+ do
109
+ {
110
+ const irep_idt id=worklist.front ();
111
+ worklist.pop_front ();
112
+
113
+ reachable_functions.insert (id);
114
+
115
+ const auto &p=graph.equal_range (id);
116
+
117
+ for (auto it=p.first ; it!=p.second ; it++)
118
+ {
119
+ const irep_idt callee=it->second ;
120
+
121
+ if (reachable_functions.find (callee)==reachable_functions.end ())
122
+ worklist.push_back (callee);
123
+ }
124
+ }
125
+ while (!worklist.empty ());
126
+ }
127
+
128
+ /* ******************************************************************\
129
+
99
130
Function: call_grapht::output_dot
100
131
101
132
Inputs:
0 commit comments