@@ -174,6 +174,11 @@ class remove_function_pointerst
174
174
void remove_function_pointer_log (
175
175
goto_programt::targett target,
176
176
const functionst &functions) const ;
177
+
178
+ // / Extract function name from \p called_functions
179
+ // / \param: called_function: the function call expression
180
+ // / \return function identifier
181
+ irep_idt get_callee_id (const exprt &called_function) const ;
177
182
};
178
183
179
184
remove_function_pointerst::remove_function_pointerst (
@@ -723,3 +728,40 @@ void remove_function_pointerst::remove_function_pointer_log(
723
728
mstream << messaget::eom;
724
729
});
725
730
}
731
+
732
+ irep_idt
733
+ remove_function_pointerst::get_callee_id (const exprt &called_function) const
734
+ {
735
+ irep_idt callee_id;
736
+ bool contains_code = false ;
737
+ auto type_contains_code = [&contains_code](const typet &t) {
738
+ if (t.id () == ID_code)
739
+ contains_code = true ;
740
+ };
741
+
742
+ called_function.visit_post (
743
+ [&callee_id, &type_contains_code, &contains_code](const exprt &e) {
744
+ if (e.id () == ID_symbol)
745
+ {
746
+ e.type ().visit (type_contains_code);
747
+ if (contains_code)
748
+ {
749
+ callee_id = to_symbol_expr (e).get_identifier ();
750
+ return ;
751
+ }
752
+ }
753
+ if (e.id () == ID_dereference)
754
+ {
755
+ const auto &pointer = to_dereference_expr (e).pointer ();
756
+ if (pointer.id () == ID_symbol)
757
+ callee_id = to_symbol_expr (pointer).get_identifier ();
758
+ if (pointer.id () == ID_member)
759
+ {
760
+ pointer.type ().visit (type_contains_code);
761
+ if (contains_code)
762
+ callee_id = to_member_expr (pointer).get_component_name ();
763
+ }
764
+ }
765
+ });
766
+ return callee_id;
767
+ }
0 commit comments