Skip to content

split up remove_function_pointerst::remove_function_pointer #2870

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Sep 3, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions src/goto-programs/remove_function_pointers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,20 @@ class remove_function_pointerst:public messaget

bool remove_function_pointers(goto_programt &goto_program);

// a set of function symbols
using functionst = remove_const_function_pointerst::functionst;

/// Replace a call to a dynamic function at location
/// target in the given goto-program by a case-split
/// over a given set of functions
/// \param goto_program The goto program that contains target
/// \param target location with function call with function pointer
/// \param functions The set of functions to consider
void remove_function_pointer(
goto_programt &goto_program,
goto_programt::targett target,
const functionst &functions);

protected:
const namespacet ns;
symbol_tablet &symbol_table;
Expand All @@ -57,6 +71,11 @@ class remove_function_pointerst:public messaget
// --remove-const-function-pointers instead of --remove-function-pointers
bool only_resolve_const_fps;

/// Replace a call to a dynamic function at location
/// target in the given goto-program by determining
/// functions that have a compatible signature
/// \param goto_program The goto program that contains target
/// \param target location with function call with function pointer
void remove_function_pointer(
goto_programt &goto_program,
goto_programt::targett target);
Expand Down Expand Up @@ -348,6 +367,19 @@ void remove_function_pointerst::remove_function_pointer(
}
}

remove_function_pointer(goto_program, target, functions);
}

void remove_function_pointerst::remove_function_pointer(
goto_programt &goto_program,
goto_programt::targett target,
const functionst &functions)
{
const code_function_callt &code = to_code_function_call(target->code);

const exprt &function = code.function();
const exprt &pointer = to_dereference_expr(function).pointer();

// the final target is a skip
goto_programt final_skip;

Expand Down