Go to the documentation of this file.
36 bool _add_safety_assertion,
93 bool return_value_used,
98 const typet &call_type,
99 const typet &function_type);
111 bool _add_safety_assertion,
112 bool only_resolve_const_fps,
114 : log(_message_handler),
116 symbol_table(_symbol_table),
117 add_safety_assertion(_add_safety_assertion),
118 only_resolve_const_fps(only_resolve_const_fps)
134 const typet &call_type,
135 const typet &function_type)
137 if(call_type == function_type)
142 call_type.
id() == ID_signedbv || call_type.
id() == ID_unsigned ||
143 call_type.
id() == ID_bool || call_type.
id() == ID_c_bool ||
144 call_type.
id() == ID_c_enum_tag || call_type.
id() == ID_c_enum ||
145 call_type.
id() == ID_pointer)
147 return function_type.
id() == ID_signedbv ||
148 function_type.
id() == ID_unsigned || function_type.
id() == ID_bool ||
149 function_type.
id() == ID_c_bool ||
150 function_type.
id() == ID_pointer ||
151 function_type.
id() == ID_c_enum ||
152 function_type.
id() == ID_c_enum_tag;
160 bool return_value_used,
166 if(!return_value_used)
185 function_parameters.empty())
190 call_parameters.empty())
197 if(call_parameters.size()!=function_parameters.size())
200 for(std::size_t i=0; i<call_parameters.size(); i++)
202 function_parameters[i].type()))
220 for(std::size_t i=0; i<function_parameters.size(); i++)
222 if(i<call_arguments.size())
224 if(call_arguments[i].type() != function_parameters[i].type())
248 const symbolt &function_symbol =
256 function_symbol.
mode,
262 function_call.
lhs()=tmp_symbol_expr;
285 for(
const auto &argument : code.
arguments())
291 bool found_functions;
293 const exprt &pointer =
function.pointer();
296 const auto does_remove_const = const_removal_check();
297 if(does_remove_const.first)
300 log.
warning() <<
"cast from const to non-const pointer found, "
301 <<
"only worst case function pointer removal will be done."
303 found_functions=
false;
310 found_functions=fpr(pointer, functions);
318 if(functions.size()==1)
320 auto call = target->get_function_call();
321 call.function() = *functions.cbegin();
322 target->set_function_call(call);
354 if(t.first==
"pthread_mutex_cleanup")
358 functions.insert(expr);
386 for(
const auto &fun : functions)
389 auto new_call = code;
407 const auto casted_address =
419 t->source_location.set_property_class(
"pointer dereference");
420 t->source_location.set_comment(
"invalid function pointer");
438 source_location = target->source_location;
439 if(!property_class.
empty())
454 target->code_nonconst().
swap(code_expression);
459 log.
statistics() <<
"replacing function pointer by " << functions.size()
465 mstream <<
"targets: ";
468 for(const auto &function : functions)
473 mstream << function.get_identifier();
485 bool did_something=
false;
488 if(target->is_function_call())
502 return did_something;
507 bool did_something=
false;
509 for(goto_functionst::function_mapt::iterator f_it=
530 bool add_safety_assertion,
531 bool only_remove_const_fps)
537 add_safety_assertion,
538 only_remove_const_fps,
548 bool add_safety_assertion,
549 bool only_remove_const_fps)
555 add_safety_assertion,
556 only_remove_const_fps,
564 bool add_safety_assertion,
565 bool only_remove_const_fps)
571 add_safety_assertion,
572 only_remove_const_fps);
Class that provides messages with a built-in verbosity 'level'.
#define Forall_goto_program_instructions(it, program)
dstringt has one field, an unsigned integer no which is an index into a static table of strings.
const irep_idt & get_comment() const
bool has_ellipsis() const
static exprt conditional_cast(const exprt &expr, const typet &type)
const irep_idt & get_property_class() const
void operator()(goto_functionst &goto_functions)
void set_comment(const irep_idt &comment)
std::unordered_set< irep_idt > address_taken
const dereference_exprt & to_dereference_expr(const exprt &expr)
Cast an exprt to a dereference_exprt.
#define CHECK_RETURN(CONDITION)
The type of an expression, extends irept.
std::vector< parametert > parameterst
Fresh auxiliary symbol creation.
remove_function_pointerst(message_handlert &_message_handler, symbol_tablet &_symbol_table, bool _add_safety_assertion, bool only_resolve_const_fps, const goto_functionst &goto_functions)
void remove_skip(goto_programt &goto_program, goto_programt::targett begin, goto_programt::targett end)
remove unnecessary skip statements
void fix_return_type(const irep_idt &in_function_id, code_function_callt &function_call, goto_programt &dest)
remove_const_function_pointerst::functionst functionst
targett add(instructiont &&instruction)
Adds a given instruction at the end.
void compute_location_numbers()
Base class for all expressions.
irep_idt base_name
Base (non-scoped) name.
function_mapt function_map
Expression to hold a symbol (variable)
void fix_argument_types(code_function_callt &function_call)
static instructiont make_assignment(const code_assignt &_code, const source_locationt &l=source_locationt::nil())
Create an assignment instruction.
static instructiont make_goto(targett _target, const source_locationt &l=source_locationt::nil())
std::unordered_set< symbol_exprt, irep_hash > functionst
A namespacet is essentially one or two symbol tables bound together, to allow for symbol lookups in t...
static instructiont make_function_call(const code_function_callt &_code, const source_locationt &l=source_locationt::nil())
Create a function call instruction.
bool arg_is_type_compatible(const typet &call_type, const typet &function_type)
typet & type()
Return the type of the expression.
bool lookup(const irep_idt &name, const symbolt *&symbol) const override
See documentation for namespace_baset::lookup().
codet representation of a function call statement.
const code_typet & to_code_type(const typet &type)
Cast a typet to a code_typet.
void remove_function_pointer(goto_programt &goto_program, const irep_idt &function_id, goto_programt::targett target, const functionst &functions)
Replace a call to a dynamic function at location target in the given goto-program by a case-split ove...
symbol_tablet & symbol_table
static instructiont make_assertion(const exprt &g, const source_locationt &l=source_locationt::nil())
irep_idt mode
Language mode.
void destructive_insert(const_targett target, goto_programt &p)
Inserts the given program p before target.
const std::string & id2string(const irep_idt &d)
source_locationt source_location
static instructiont make_skip(const source_locationt &l=source_locationt::nil())
const irep_idt & get_identifier() const
optionalt< mp_integer > pointer_offset_bits(const typet &type, const namespacet &ns)
class symbol_exprt symbol_expr() const
Produces a symbol_exprt for a symbol.
API to expression classes for Pointers.
pointer_typet pointer_type(const typet &subtype)
const symbol_exprt & to_symbol_expr(const exprt &expr)
Cast an exprt to a symbol_exprt.
const irep_idt & id() const
exprt::operandst argumentst
The Boolean constant false.
const parameterst & parameters() const
void destructive_append(goto_programt &p)
Appends the given program p to *this. p is destroyed.
instructionst instructions
The list of instructions in the goto program.
A collection of goto functions.
message_handlert & get_message_handler()
goto_functionst goto_functions
GOTO functions.
void compute_address_taken_functions(const exprt &src, std::unordered_set< irep_idt > &address_taken)
get all functions whose address is taken
const symbolst & symbols
Read-only field, used to look up symbols given their names.
void conditional_output(mstreamt &mstream, const std::function< void(mstreamt &)> &output_generator) const
Generate output to message_stream using output_generator if the configured verbosity is at least as h...
bool only_resolve_const_fps
A generic container class for the GOTO intermediate representation of one function.
bool add_safety_assertion
const typet & return_type() const
static instructiont make_assumption(const exprt &g, const source_locationt &l=source_locationt::nil())
Operator to return the address of an object.
source_locationt & add_source_location()
bool is_type_compatible(bool return_value_used, const code_typet &call_type, const code_typet &function_type)
Semantic type conversion.
A codet representing an assignment in the program.
The Boolean constant true.
bool remove_function_pointers(message_handlert &_message_handler, symbol_tablet &symbol_table, const goto_functionst &goto_functions, goto_programt &goto_program, const irep_idt &function_id, bool add_safety_assertion, bool only_remove_const_fps)
mstreamt & warning() const
static std::string comment(const rw_set_baset::entryt &entry, bool write)
API to expression classes.
Remove Indirect Function Calls.
const source_locationt & source_location() const
symbol_tablet symbol_table
Symbol table.
symbolt & get_fresh_aux_symbol(const typet &type, const std::string &name_prefix, const std::string &basename_prefix, const source_locationt &source_location, const irep_idt &symbol_mode, const namespacet &ns, symbol_table_baset &symbol_table)
Installs a fresh-named symbol with respect to the given namespace ns with the requested name pattern ...
std::map< irep_idt, code_typet > type_mapt
instructionst::iterator targett
codet representation of an expression statement.
mstreamt & statistics() const
bool remove_function_pointers(goto_programt &goto_program, const irep_idt &function_id)
void set_property_class(const irep_idt &property_class)