42 if(ns.lookup(name,
sym))
53 found->second.body_available();
85 const std::string &base_name,
106 const std::string &prefix,
107 const std::string &base_name,
111 const exprt &initial_value,
115 type, prefix, base_name, source_location, mode, symbol_table);
116 symbol.module =
module;
118 symbol.
value = initial_value;
127 const std::string &base_name,
152 auto ¶meters =
code_type.parameters();
153 parameters.insert(parameters.end(),
parameter);
173 const std::string &base_name,
195 std::size_t anon_counter = 0;
202 ?
"#anon" + std::to_string(anon_counter++)
320 return ::clone_and_rename_function(
332 auto old_function = goto_functions.function_map.find(function_id);
335 "DFCC: function to wrap " +
id2string(function_id) +
336 " must exist in the program");
348 sl.set_file(
"wrapped functions for code contracts");
358 " already exists in the symbol table");
390 "DFCC: could not remove wrapped function '" +
id2string(function_id) +
391 "' from the symbol table");
397 "DFCC: could not insert wrapper symbol '" +
id2string(function_id) +
398 "' in the symbol table");
415 if(!size.has_value())
432 goto_function.body_available(),
433 "dfcc_utilst::inline_function: '" +
id2string(function_id) +
434 "' must have a body");
475 decorated.get_recursive_call_set().begin(),
476 decorated.get_recursive_call_set().end());
478 decorated.get_missing_function_set().begin(),
479 decorated.get_missing_function_set().end());
481 decorated.get_not_enough_arguments_set().begin(),
482 decorated.get_not_enough_arguments_set().end());
502 decorated.get_recursive_call_set().begin(),
503 decorated.get_recursive_call_set().end());
505 decorated.get_missing_function_set().begin(),
506 decorated.get_missing_function_set().end());
508 decorated.get_not_enough_arguments_set().begin(),
509 decorated.get_not_enough_arguments_set().end());
ait supplies three of the four components needed: an abstract interpreter (in this case handling func...
std::vector< parametert > parameterst
dstringt has one field, an unsigned integer no which is an index into a static table of strings.
Base class for all expressions.
typet & type()
Return the type of the expression.
const source_locationt & source_location() const
function_mapt function_map
A goto function, consisting of function body (see body) and parameter identifiers (see parameter_iden...
symbol_tablet symbol_table
Symbol table.
goto_functionst goto_functions
GOTO functions.
A generic container class for the GOTO intermediate representation of one function.
static instructiont make_end_function(const source_locationt &l=source_locationt::nil())
Decorator for a message_handlert used during function inlining that collect names of GOTO functions c...
Thrown when we can't handle something in an input source file.
void set(const irep_idt &name, const irep_idt &value)
Class that provides messages with a built-in verbosity 'level'.
A namespacet is essentially one or two symbol tables bound together, to allow for symbol lookups in t...
The null pointer constant.
Symbol table entry of function parameterThis is a symbol generated as part of type checking.
Expression to hold a symbol (variable)
The symbol table base class interface.
symbolt & get_writeable_ref(const irep_idt &name)
Find a symbol in the symbol table for read-write access.
bool remove(const irep_idt &name)
Remove a symbol from the symbol table.
const symbolt * lookup(const irep_idt &name) const
Find a symbol in the symbol table for read-only access.
virtual std::pair< symbolt &, bool > insert(symbolt symbol)=0
Move or copy a new symbol to the symbol table.
bool add(const symbolt &symbol)
Add a new symbol to the symbol table.
const symbolt & lookup_ref(const irep_idt &name) const
Find a symbol in the symbol table for read-only access.
class symbol_exprt symbol_expr() const
Produces a symbol_exprt for a symbol.
typet type
Type of symbol.
irep_idt name
The unique identifier.
irep_idt irep_idt base_name
Name of module the symbol belongs to.
exprt value
Initial value of symbol.
The type of an expression, extends irept.
static void clone_parameters(symbol_table_baset &symbol_table, const code_typet::parameterst &old_params, const irep_idt &mode, const irep_idt &module, const source_locationt &location, std::function< const irep_idt(const irep_idt &)> &trans_param, const irep_idt &new_function_id, code_typet::parameterst &new_params)
Clones the old_params into the new_params list, applying the trans_param function to generate the nam...
static const symbolt & clone_and_rename_function(goto_modelt &goto_model, const irep_idt &function_id, std::function< const irep_idt(const irep_idt &)> &trans_fun, std::function< const irep_idt(const irep_idt &)> &trans_param, std::function< const typet(const typet &)> &trans_ret_type, std::function< const source_locationt(const source_locationt &)> &trans_loc)
Creates a new symbol in the symbol_table by cloning the given function_id function and transforming t...
static inlining_decoratort inline_function(goto_modelt &goto_model, const irep_idt &function_id, message_handlert &message_handler)
static bool symbol_exists(const goto_modelt &goto_model, const irep_idt &name, const bool require_has_code_type, const bool require_body_available)
Returns true iff the given symbol exists and satisfies requirements.
static void add_parameter(const symbolt &symbol, code_typet &code_type)
Adds the given symbol as parameter to the given code_typet.
Dynamic frame condition checking utility functions.
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 ...
Fresh auxiliary symbol creation.
Goto Programs with Functions.
void goto_program_inline(goto_functionst &goto_functions, goto_programt &goto_program, const namespacet &ns, message_handlert &message_handler, bool adjust_function, bool caching)
Transitively inline all function calls found in a particular program.
void goto_function_inline(goto_modelt &goto_model, const irep_idt function, message_handlert &message_handler, bool adjust_function, bool caching)
Transitively inline all function calls made from a particular function.
Function Inlining This gives a number of different interfaces to the function inlining functionality ...
const std::string & id2string(const irep_idt &d)
API to expression classes for Pointers.
const pointer_typet & to_pointer_type(const typet &type)
Cast a typet to a pointer_typet.
std::optional< exprt > size_of_expr(const typet &type, const namespacet &ns)
#define PRECONDITION_WITH_DIAGNOSTICS(CONDITION,...)
#define CHECK_RETURN(CONDITION)
#define PRECONDITION(CONDITION)
#define INVARIANT(CONDITION, REASON)
This macro uses the wrapper function 'invariant_violated_string'.
API to expression classes.
const code_typet & to_code_type(const typet &type)
Cast a typet to a code_typet.
static symbolt & get_function_symbol(symbol_table_baset &, const irep_idt &function_id)
Returns the symbolt for function_id.
static void inline_function(goto_modelt &goto_model, const irep_idt &function_id, message_handlert &message_handler)
Inlines the given function, aborts on recursive calls during inlining.
static bool function_symbol_with_body_exists(const goto_modelt &, const irep_idt &function_id)
static const exprt make_null_check_expr(const exprt &ptr)
Returns the expression expr == NULL.
static bool function_symbol_exists(const goto_modelt &, const irep_idt &function_id)
Returns true iff the given symbol exists and satisfies requirements.
static exprt make_sizeof_expr(const exprt &expr, const namespacet &)
Returns the expression sizeof(expr).
static const symbolt & create_new_parameter_symbol(symbol_table_baset &, const irep_idt &function_id, const std::string &base_name, const typet &type)
Creates a new parameter symbol for the given function_id.
static void wrap_function(goto_modelt &goto_model, const irep_idt &function_id, const irep_idt &wrapped_function_id)
Given a function to wrap foo and a new name wrapped_foo
static const symbolt & create_static_symbol(symbol_table_baset &, const typet &type, const std::string &prefix, const std::string &base_name, const source_locationt &source_location, const irep_idt &mode, const irep_idt &module, const exprt &initial_value, const bool no_nondet_initialization=true)
Adds a new static symbol named prefix::base_name of type type with value initial_value in the symbol ...
static const symbolt & clone_and_rename_function(goto_modelt &goto_model, const irep_idt &function_id, const irep_idt &new_function_id, std::optional< typet > new_return_type)
Creates a new function symbol and goto_function entry in the goto_functions_map by cloning the given ...
static void add_parameter(goto_modelt &, const symbolt &symbol, const irep_idt &function_id)
Adds the given symbol as parameter to the function symbol's code_type.
static void inline_program(goto_modelt &goto_model, goto_programt &goto_program, std::set< irep_idt > &no_body, std::set< irep_idt > &recursive_call, std::set< irep_idt > &missing_function, std::set< irep_idt > ¬_enough_arguments, message_handlert &message_handler)
Inlines the given program, and returns function symbols that caused warnings.
static symbol_exprt create_symbol(symbol_table_baset &, const typet &type, const irep_idt &function_id, const std::string &base_name, const source_locationt &source_location)
Adds a new symbol named function_id::base_name of type type with given attributes in the symbol table...