@@ -15,7 +15,7 @@ void label_function_pointer_call_sites(goto_modelt &goto_model)
1515 for (auto &goto_function : goto_model.goto_functions .function_map )
1616 {
1717 std::size_t function_pointer_call_counter = 0 ;
18- for_each_goto_location_if (
18+ for_each_instruction_if (
1919 goto_function.second ,
2020 [](const goto_programt::targett it) {
2121 return it->is_function_call () && can_cast_expr<dereference_exprt>(
@@ -28,22 +28,30 @@ void label_function_pointer_call_sites(goto_modelt &goto_model)
2828 auto const &source_location = function_call.source_location ();
2929 auto const &goto_function_symbol_mode =
3030 goto_model.symbol_table .lookup_ref (goto_function.first ).mode ;
31- auto const new_symbol_name =
31+
32+ auto const call_site_symbol_name =
3233 irep_idt{id2string (goto_function.first ) + " .function_pointer_call." +
3334 std::to_string (++function_pointer_call_counter)};
35+
36+ // insert new function pointer variable into the symbol table
3437 goto_model.symbol_table .insert ([&] {
3538 symbolt function_call_site_symbol{};
3639 function_call_site_symbol.name = function_call_site_symbol.base_name =
37- function_call_site_symbol.pretty_name = new_symbol_name ;
40+ function_call_site_symbol.pretty_name = call_site_symbol_name ;
3841 function_call_site_symbol.type =
3942 function_pointer_dereference.pointer ().type ();
4043 function_call_site_symbol.location = function_call.source_location ();
4144 function_call_site_symbol.is_lvalue = true ;
4245 function_call_site_symbol.mode = goto_function_symbol_mode;
4346 return function_call_site_symbol;
4447 }());
48+
4549 auto const new_function_pointer =
46- goto_model.symbol_table .lookup_ref (new_symbol_name).symbol_expr ();
50+ goto_model.symbol_table .lookup_ref (call_site_symbol_name)
51+ .symbol_expr ();
52+
53+ // add assignment to the new function pointer variable, followed by a
54+ // call of the new variable
4755 auto const assign_instruction = goto_programt::make_assignment (
4856 code_assignt{new_function_pointer,
4957 function_pointer_dereference.pointer ()},
0 commit comments