@@ -169,11 +169,14 @@ bool ci_lazy_methodst::operator()(
169169 << " callsites)"
170170 << eom;
171171
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)
173177 {
174- // This will also create a stub if a virtual callsite has no targets.
175178 get_virtual_method_targets (
176- *callsite ,
179+ function ,
177180 needed_classes,
178181 method_worklist2,
179182 symbol_table);
@@ -397,21 +400,20 @@ void ci_lazy_methodst::gather_virtual_callsites(
397400
398401// / Find possible callees, excluding types that are not known to be
399402// / 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.
402405// / \param needed_classes: set of classes that can be instantiated. Any
403406// / potential callee not in this set will be ignored.
404407// / \param symbol_table: global symbol table
405408// / \param [out] needed_methods: Populated with all possible `c` callees, taking
406409// / `needed_classes` into account (virtual function overrides defined on
407410// / classes that are not 'needed' are ignored)
408411void ci_lazy_methodst::get_virtual_method_targets (
409- const code_function_callt &c ,
412+ const exprt &called_function ,
410413 const std::set<irep_idt> &needed_classes,
411414 std::vector<irep_idt> &needed_methods,
412415 symbol_tablet &symbol_table)
413416{
414- const auto &called_function=c.function ();
415417 PRECONDITION (called_function.id ()==ID_virtual_function);
416418
417419 const auto &call_class=called_function.get (ID_C_class);
@@ -453,7 +455,7 @@ void ci_lazy_methodst::get_virtual_method_targets(
453455 symbolt symbol;
454456 symbol.name =stubname;
455457 symbol.base_name =call_basename;
456- symbol.type =c. function () .type ();
458+ symbol.type =called_function .type ();
457459 symbol.value .make_nil ();
458460 symbol.mode =ID_java;
459461 symbol_table.add (symbol);
0 commit comments