@@ -57,8 +57,11 @@ class remove_virtual_functionst
57
57
typedef std::vector<functiont> functionst;
58
58
void get_functions (const exprt &, functionst &);
59
59
void get_child_functions_rec (
60
- const irep_idt &, const symbol_exprt &,
61
- const irep_idt &, functionst &) const ;
60
+ const irep_idt &,
61
+ const symbol_exprt &,
62
+ const irep_idt &,
63
+ functionst &,
64
+ std::set<irep_idt> &visited) const ;
62
65
exprt get_method (
63
66
const irep_idt &class_id,
64
67
const irep_idt &component_name) const ;
@@ -254,14 +257,17 @@ void remove_virtual_functionst::get_child_functions_rec(
254
257
const irep_idt &this_id,
255
258
const symbol_exprt &last_method_defn,
256
259
const irep_idt &component_name,
257
- functionst &functions) const
260
+ functionst &functions,
261
+ std::set<irep_idt> &visited) const
258
262
{
259
263
auto findit=class_hierarchy.class_map .find (this_id);
260
264
if (findit==class_hierarchy.class_map .end ())
261
265
return ;
262
266
263
267
for (const auto &child : findit->second .children )
264
268
{
269
+ if (!visited.insert (child).second )
270
+ continue ;
265
271
exprt method=get_method (child, component_name);
266
272
functiont function (child);
267
273
if (method.is_not_nil ())
@@ -279,7 +285,8 @@ void remove_virtual_functionst::get_child_functions_rec(
279
285
child,
280
286
function.symbol_expr ,
281
287
component_name,
282
- functions);
288
+ functions,
289
+ visited);
283
290
}
284
291
}
285
292
@@ -333,11 +340,13 @@ void remove_virtual_functionst::get_functions(
333
340
}
334
341
335
342
// iterate over all children, transitively
343
+ std::set<irep_idt> visited;
336
344
get_child_functions_rec (
337
345
class_id,
338
346
root_function.symbol_expr ,
339
347
component_name,
340
- functions);
348
+ functions,
349
+ visited);
341
350
342
351
if (root_function.symbol_expr !=symbol_exprt ())
343
352
functions.push_back (root_function);
0 commit comments