@@ -169,11 +169,14 @@ bool ci_lazy_methodst::operator()(
169
169
<< " callsites)"
170
170
<< eom;
171
171
172
- for (const auto &callsite : virtual_callsites)
172
+ std::unordered_set<exprt, irep_hash> unique_functions;
173
+ for (const code_function_callt *virtual_callsite : virtual_callsites)
174
+ unique_functions.insert (virtual_callsite->function ());
175
+
176
+ for (const exprt &function : unique_functions)
173
177
{
174
- // This will also create a stub if a virtual callsite has no targets.
175
178
get_virtual_method_targets (
176
- *callsite ,
179
+ function ,
177
180
needed_classes,
178
181
method_worklist2,
179
182
symbol_table);
@@ -397,21 +400,20 @@ void ci_lazy_methodst::gather_virtual_callsites(
397
400
398
401
// / Find possible callees, excluding types that are not known to be
399
402
// / instantiated.
400
- // / \param c: function call whose potential target functions should
401
- // / be determined.
403
+ // / \param called_function: virtual function call whose concrete function calls
404
+ // / should be determined.
402
405
// / \param needed_classes: set of classes that can be instantiated. Any
403
406
// / potential callee not in this set will be ignored.
404
407
// / \param symbol_table: global symbol table
405
408
// / \param [out] needed_methods: Populated with all possible `c` callees, taking
406
409
// / `needed_classes` into account (virtual function overrides defined on
407
410
// / classes that are not 'needed' are ignored)
408
411
void ci_lazy_methodst::get_virtual_method_targets (
409
- const code_function_callt &c ,
412
+ const exprt &called_function ,
410
413
const std::set<irep_idt> &needed_classes,
411
414
std::vector<irep_idt> &needed_methods,
412
415
symbol_tablet &symbol_table)
413
416
{
414
- const auto &called_function=c.function ();
415
417
PRECONDITION (called_function.id ()==ID_virtual_function);
416
418
417
419
const auto &call_class=called_function.get (ID_C_class);
@@ -453,7 +455,7 @@ void ci_lazy_methodst::get_virtual_method_targets(
453
455
symbolt symbol;
454
456
symbol.name =stubname;
455
457
symbol.base_name =call_basename;
456
- symbol.type =c. function () .type ();
458
+ symbol.type =called_function .type ();
457
459
symbol.value .make_nil ();
458
460
symbol.mode =ID_java;
459
461
symbol_table.add (symbol);
0 commit comments