Skip to content

Commit c269ca5

Browse files
authored
Merge pull request #2870 from diffblue/split_remove_function_pointer
split up remove_function_pointerst::remove_function_pointer
2 parents 6bf1b49 + 10d8b2f commit c269ca5

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

src/goto-programs/remove_function_pointers.cpp

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,20 @@ class remove_function_pointerst:public messaget
4444

4545
bool remove_function_pointers(goto_programt &goto_program);
4646

47+
// a set of function symbols
48+
using functionst = remove_const_function_pointerst::functionst;
49+
50+
/// Replace a call to a dynamic function at location
51+
/// target in the given goto-program by a case-split
52+
/// over a given set of functions
53+
/// \param goto_program The goto program that contains target
54+
/// \param target location with function call with function pointer
55+
/// \param functions The set of functions to consider
56+
void remove_function_pointer(
57+
goto_programt &goto_program,
58+
goto_programt::targett target,
59+
const functionst &functions);
60+
4761
protected:
4862
const namespacet ns;
4963
symbol_tablet &symbol_table;
@@ -57,6 +71,11 @@ class remove_function_pointerst:public messaget
5771
// --remove-const-function-pointers instead of --remove-function-pointers
5872
bool only_resolve_const_fps;
5973

74+
/// Replace a call to a dynamic function at location
75+
/// target in the given goto-program by determining
76+
/// functions that have a compatible signature
77+
/// \param goto_program The goto program that contains target
78+
/// \param target location with function call with function pointer
6079
void remove_function_pointer(
6180
goto_programt &goto_program,
6281
goto_programt::targett target);
@@ -348,6 +367,19 @@ void remove_function_pointerst::remove_function_pointer(
348367
}
349368
}
350369

370+
remove_function_pointer(goto_program, target, functions);
371+
}
372+
373+
void remove_function_pointerst::remove_function_pointer(
374+
goto_programt &goto_program,
375+
goto_programt::targett target,
376+
const functionst &functions)
377+
{
378+
const code_function_callt &code = to_code_function_call(target->code);
379+
380+
const exprt &function = code.function();
381+
const exprt &pointer = to_dereference_expr(function).pointer();
382+
351383
// the final target is a skip
352384
goto_programt final_skip;
353385

0 commit comments

Comments
 (0)