@@ -123,12 +123,11 @@ void call_grapht::output_dot(std::ostream &out) const
123
123
124
124
125
125
void call_grapht::output_dot (
126
- goto_functionst const & functions,
127
- std::ostream &out
128
- ) const
126
+ goto_functionst const &functions,
127
+ std::ostream &out) const
129
128
{
130
129
out << " digraph call_graph {\n " ;
131
- for (auto const & elem : functions.function_map )
130
+ for (auto const & elem : functions.function_map )
132
131
out << " \" " << elem.first << " \" ;\n " ;
133
132
for (grapht::const_iterator it=graph.begin ();
134
133
it!=graph.end ();
@@ -189,31 +188,29 @@ void call_grapht::output_xml(std::ostream &out) const
189
188
190
189
191
190
call_grapht::call_edges_ranget
192
- call_grapht::out_edges (irep_idt const & caller) const
191
+ call_grapht::out_edges (irep_idt const & caller) const
193
192
{
194
193
return graph.equal_range (caller);
195
194
}
196
195
197
196
198
197
void inverted_partial_topological_order (
199
- call_grapht const & call_graph,
200
- irep_idt const & start_function,
201
- std::unordered_set<irep_idt,dstring_hash>& processed_functions,
202
- std::vector<irep_idt>& output
203
- )
198
+ call_grapht const &call_graph,
199
+ irep_idt const &start_function,
200
+ std::unordered_set<irep_idt, dstring_hash> &processed_functions,
201
+ std::vector<irep_idt> &output)
204
202
{
205
- if (processed_functions.count (start_function) != 0ULL )
203
+ if (processed_functions.count (start_function) != 0ULL )
206
204
return ;
207
205
processed_functions.insert (start_function);
208
206
call_grapht::call_edges_ranget const range =
209
- call_graph.out_edges (start_function);
210
- for (auto it = range.first ; it != range.second ; ++it)
207
+ call_graph.out_edges (start_function);
208
+ for (auto it = range.first ; it != range.second ; ++it)
211
209
inverted_partial_topological_order (
212
- call_graph,
213
- it->second ,
214
- processed_functions,
215
- output
216
- );
210
+ call_graph,
211
+ it->second ,
212
+ processed_functions,
213
+ output);
217
214
output.push_back (start_function);
218
215
}
219
216
@@ -222,99 +219,94 @@ void get_inverted_topological_order(
222
219
goto_functionst const & functions,
223
220
std::vector<irep_idt>& output)
224
221
{
225
- std::unordered_set<irep_idt,dstring_hash> processed;
226
- for (auto const & elem : functions.function_map )
222
+ std::unordered_set<irep_idt, dstring_hash> processed;
223
+ for (auto const & elem : functions.function_map )
227
224
inverted_partial_topological_order (
228
225
call_graph,
229
226
elem.first ,
230
227
processed,
231
228
output);
232
229
}
233
230
234
- bool exists_direct_call (
235
- call_grapht const & call_graph,
236
- irep_idt const & caller,
237
- irep_idt const & callee
238
- )
231
+ bool exists_direct_call (
232
+ call_grapht const &call_graph,
233
+ irep_idt const &caller,
234
+ irep_idt const &callee)
239
235
{
240
236
call_grapht::call_edges_ranget const range =
241
- call_graph.out_edges (caller);
242
- for (auto it = range.first ; it != range.second ; ++it)
243
- if (callee == it->second )
237
+ call_graph.out_edges (caller);
238
+ for (auto it = range.first ; it != range.second ; ++it)
239
+ if (callee == it->second )
244
240
return true ;
245
241
return false ;
246
242
}
247
243
248
- bool exists_direct_or_indirect_call (
249
- call_grapht const & call_graph,
250
- irep_idt const & caller,
251
- irep_idt const & callee,
252
- std::unordered_set<irep_idt,dstring_hash>& ignored_functions
253
- )
244
+ bool exists_direct_or_indirect_call (
245
+ call_grapht const &call_graph,
246
+ irep_idt const &caller,
247
+ irep_idt const &callee,
248
+ std::unordered_set<irep_idt, dstring_hash> &ignored_functions)
254
249
{
255
- if (ignored_functions.count (caller) != 0UL )
250
+ if (ignored_functions.count (caller) != 0UL )
256
251
return false ;
257
252
ignored_functions.insert (caller);
258
- if (exists_direct_call (call_graph,caller,callee))
253
+ if (exists_direct_call (call_graph, caller, callee))
259
254
return ignored_functions.count (callee) == 0UL ;
260
255
call_grapht::call_edges_ranget const range =
261
- call_graph.out_edges (caller);
262
- for (auto it = range.first ; it != range.second ; ++it)
263
- if (exists_direct_or_indirect_call (
256
+ call_graph.out_edges (caller);
257
+ for (auto it = range.first ; it != range.second ; ++it)
258
+ if (exists_direct_or_indirect_call (
264
259
call_graph,
265
260
it->second ,
266
261
callee,
267
- ignored_functions
268
- ))
262
+ ignored_functions))
269
263
return true ;
270
264
return false ;
271
265
}
272
266
273
- bool exists_direct_or_indirect_call (
274
- call_grapht const & call_graph,
275
- irep_idt const & caller,
276
- irep_idt const & callee
277
- )
267
+ bool exists_direct_or_indirect_call (
268
+ call_grapht const &call_graph,
269
+ irep_idt const &caller,
270
+ irep_idt const &callee)
278
271
{
279
- std::unordered_set<irep_idt,dstring_hash> ignored;
280
- return exists_direct_or_indirect_call (call_graph,caller,callee,ignored);
272
+ std::unordered_set<irep_idt, dstring_hash> ignored;
273
+ return exists_direct_or_indirect_call (call_graph, caller, callee, ignored);
281
274
}
282
275
283
276
void compute_inverted_call_graph (
284
- call_grapht const & original_call_graph,
285
- call_grapht& output_inverted_call_graph
286
- )
277
+ call_grapht const &original_call_graph,
278
+ call_grapht &output_inverted_call_graph)
287
279
{
288
280
assert (output_inverted_call_graph.graph .empty ());
289
- for (auto const & elem : original_call_graph.graph )
290
- output_inverted_call_graph.add (elem.second ,elem.first );
281
+ for (auto const & elem : original_call_graph.graph )
282
+ output_inverted_call_graph.add (elem.second , elem.first );
291
283
}
292
284
293
285
void find_leaves_bellow_function (
294
- call_grapht const & call_graph,
295
- irep_idt const & function,
296
- std::unordered_set<irep_idt,dstring_hash>& to_avoid,
297
- std::unordered_set<irep_idt,dstring_hash>& output
298
- )
286
+ call_grapht const &call_graph,
287
+ irep_idt const &function,
288
+ std::unordered_set<irep_idt, dstring_hash> &to_avoid,
289
+ std::unordered_set<irep_idt, dstring_hash> &output)
299
290
{
300
- if (to_avoid.count (function) != 0UL )
291
+ if (to_avoid.count (function) != 0UL )
301
292
return ;
302
293
to_avoid.insert (function);
303
294
call_grapht::call_edges_ranget const range =
304
- call_graph.out_edges (function);
305
- if (range.first == range.second )
295
+ call_graph.out_edges (function);
296
+ if (range.first == range.second )
306
297
output.insert (function);
307
298
else
308
- for (auto it = range.first ; it != range.second ; ++it)
309
- find_leaves_bellow_function (call_graph,it->second ,to_avoid,output);
299
+ {
300
+ for (auto it = range.first ; it != range.second ; ++it)
301
+ find_leaves_bellow_function (call_graph, it->second , to_avoid, output);
302
+ }
310
303
}
311
304
312
- void find_leaves_bellow_function (
313
- call_grapht const & call_graph,
314
- irep_idt const & function,
315
- std::unordered_set<irep_idt,dstring_hash>& output
316
- )
305
+ void find_leaves_below_function (
306
+ call_grapht const &call_graph,
307
+ irep_idt const &function,
308
+ std::unordered_set<irep_idt, dstring_hash> &output)
317
309
{
318
- std::unordered_set<irep_idt,dstring_hash> to_avoid;
319
- find_leaves_bellow_function (call_graph,function,to_avoid,output);
310
+ std::unordered_set<irep_idt, dstring_hash> to_avoid;
311
+ find_leaves_bellow_function (call_graph, function, to_avoid, output);
320
312
}
0 commit comments