Go to the documentation of this file.
47 exprt::operandst::const_iterator it1=arguments.begin();
50 for(
const auto &identifier : goto_function.parameter_identifiers)
53 !identifier.empty(),
"function parameter must have an identifier");
60 const typet ¶meter_type = symbol.
type;
65 if(it1==arguments.end())
72 "not enough arguments, inserting non-deterministic value"
76 parameter_type, state.
source.
pc->source_location());
88 if(parameter_type != rhs.
type())
96 (parameter_type.
id() == ID_signedbv ||
97 parameter_type.
id() == ID_unsignedbv ||
98 parameter_type.
id() == ID_c_enum_tag ||
99 parameter_type.
id() == ID_bool ||
100 parameter_type.
id() == ID_pointer ||
101 parameter_type.
id() == ID_union ||
102 parameter_type.
id() == ID_union_tag) &&
103 (rhs_type.
id() == ID_signedbv ||
104 rhs_type.
id() == ID_unsignedbv ||
105 rhs_type.
id() == ID_c_bit_field ||
106 rhs_type.
id() == ID_c_enum_tag ||
107 rhs_type.
id() == ID_bool ||
108 rhs_type.
id() == ID_pointer ||
109 rhs_type.
id() == ID_union ||
110 rhs_type.
id() == ID_union_tag))
118 std::ostringstream error;
119 error << state.
source.
pc->source_location().as_string() <<
": "
120 <<
"function call: parameter \"" << identifier
121 <<
"\" type mismatch:\ngot " << rhs.
type().
pretty()
122 <<
"\nexpected " << parameter_type.
pretty();
138 rhs =
clean_expr(std::move(rhs), state,
false);
145 if(it1!=arguments.end())
152 for(; it1 != arguments.end(); it1++)
159 ns.
lookup(function_identifier).mode,
168 else if(it1!=arguments.end())
212 for(
auto &argument : arguments)
213 cleaned_arguments.push_back(
clean_expr(argument, state,
false));
224 const exprt &cleaned_lhs,
228 const irep_idt &identifier =
function.get_identifier();
235 auto emplace_safe_pointers_result =
237 if(emplace_safe_pointers_result.second)
238 emplace_safe_pointers_result.first->second(goto_function.body);
261 const std::vector<renamedt<exprt, L2>> renamed_arguments =
274 if(!goto_function.body_available())
285 cleaned_lhs.
type(), state.
source.
pc->source_location());
293 for(
const auto &arg : cleaned_arguments)
296 arg.type().id() == ID_pointer &&
339 irep_idt return_value_symbol_identifier =
340 "goto_symex::return_value::" +
id2string(identifier);
348 new_symbol.
name = return_value_symbol_identifier;
350 new_symbol.
mode = function_symbol.
mode;
355 ns.
lookup(return_value_symbol_identifier).symbol_expr();
361 if(pair.second.is_recursion)
377 bool doing_path_exploration)
402 if(state.
threads.size() == 1 && !doing_path_exploration)
412 l2_entry_opt.has_value() &&
414 !path_storage.
dirty(l2_entry_opt->get().first.get_object_name())))
443 if(state.
reachable && call_lhs.is_not_nil())
447 "must have return value symbol when assigning call lhs");
458 const irep_idt &function_identifier,
468 for(
const auto ¶m : goto_function.parameter_identifiers)
471 ns.
lookup(param).symbol_expr(),
472 [&path_storage, &frame_nr](
const irep_idt &l0_name) {
bool havoc_undefined_functions
exprt clean_expr(exprt expr, statet &state, bool write)
Clean up an expression.
bool has_symbol(const irep_idt &name) const
Check whether a symbol exists in the symbol table.
dstringt has one field, an unsigned integer no which is an index into a static table of strings.
bool has_ellipsis() const
byte_extract_exprt make_byte_extract(const exprt &_op, const exprt &_offset, const typet &_type)
Construct a byte_extract_exprt with endianness and byte width matching the current configuration.
static exprt conditional_cast(const exprt &expr, const typet &type)
void symex_assume_l2(statet &, const exprt &cond)
void restore_from(const symex_level1t &other)
Insert the content of other into this renaming.
virtual void function_return(const exprt &guard, const irep_idt &function_id, const sourcet &source, bool hidden)
Record return from a function.
The type of an expression, extends irept.
bool reachable
Is this code reachable? If not we can take shortcuts such as not entering function calls,...
std::string pretty(unsigned indent=0, unsigned max_indent=0) const
goto_programt::const_targett pc
symex_target_equationt & target
The equation that this execution is building up.
Storage for symbolic execution paths to be resumed later.
typet type
Type of symbol.
Operator to dereference a pointer.
path_storaget & path_storage
Symbolic execution paths to be resumed later.
Central data structure: state.
irep_idt function_identifier
Thrown when we encounter an instruction, parameters to an instruction etc.
symex_targett::sourcet calling_location
A very simple, cheap analysis to determine when dereference operations are trivially guarded by a che...
guard_managert & guard_manager
virtual void symex_function_call_post_clean(const get_goto_functiont &get_goto_function, statet &state, const exprt &cleaned_lhs, const symbol_exprt &function, const exprt::operandst &cleaned_arguments)
Symbolic execution of a function call by inlining.
Base class for all expressions.
guardt guard_at_function_start
symex_targett::sourcet source
irep_idt base_name
Base (non-scoped) name.
Functor for symex assignment.
Internally generated symbol table entry.
Expression to hold a symbol (variable)
const exprt::operandst & call_arguments() const
Get the arguments of a FUNCTION_CALL.
Storage of symbolic execution paths to resume.
virtual bool get_unwind_recursion(const irep_idt &identifier, unsigned thread_nr, unsigned unwind)
@ VISIBLE_ACTUAL_PARAMETER
messaget log
The messaget to write log messages to.
virtual void location(const exprt &guard, const sourcet &source)
Record a location.
A namespacet is essentially one or two symbol tables bound together, to allow for symbol lookups in t...
typet & type()
Return the type of the expression.
framet & new_frame(symex_targett::sourcet calling_location, const guardt &guard)
bool lookup(const irep_idt &name, const symbolt *&symbol) const override
See documentation for namespace_baset::lookup().
std::vector< threadt > threads
std::vector< irep_idt > parameter_names
std::shared_ptr< lexical_loopst > get_loop_analysis(const irep_idt &function_id)
void parameter_assignments(const irep_idt &function_identifier, const goto_functionst::goto_functiont &goto_function, statet &state, const exprt::operandst &arguments)
Iterates over arguments and assigns them to the parameters, which are symbols whose name and type are...
Expression classes for byte-level operators.
const code_typet & to_code_type(const typet &type)
Cast a typet to a code_typet.
std::shared_ptr< lexical_loopst > loops_info
call_stackt & call_stack()
irep_idt mode
Language mode.
optionalt< symbol_exprt > return_value_symbol
#define DATA_INVARIANT(CONDITION, REASON)
This condition should be used to document that assumptions that are made on goto_functions,...
const std::string & id2string(const irep_idt &d)
symbol_tablet symbol_table
contains symbols that are minted during symbolic execution, such as dynamically created objects etc.
@ HIDDEN_ACTUAL_PARAMETER
static void pop_frame(goto_symext::statet &state, const path_storaget &path_storage, bool doing_path_exploration)
pop one call frame
virtual void symex_function_call_symbol(const get_goto_functiont &get_goto_function, statet &state, const exprt &lhs, const symbol_exprt &function, const exprt::operandst &arguments)
Symbolic execution of a call to a function call.
#define PRECONDITION(CONDITION)
bool doing_path_exploration
bool unwinding_assertions
void populate_dirty_for_function(const irep_idt &id, const goto_functionst::goto_functiont &function)
Analyse the given function with dirtyt if it hasn't been seen before.
renamedt< exprt, level > rename(exprt expr, const namespacet &ns)
Rewrites symbol expressions in exprt, applying a suffix to each symbol reflecting its most recent ver...
std::unordered_map< irep_idt, loop_infot > loop_iterations
class symbol_exprt symbol_expr() const
Produces a symbol_exprt for a symbol.
virtual void symex_end_of_function(statet &)
Symbolically execute a END_FUNCTION instruction.
const pointer_typet & to_pointer_type(const typet &type)
Cast a typet to a pointer_typet.
incremental_dirtyt dirty
Local variables are considered 'dirty' if they've had an address taken and therefore may be referred ...
const symbol_exprt & to_symbol_expr(const exprt &expr)
Cast an exprt to a symbol_exprt.
const irep_idt & id() const
goto_programt::const_targett end_of_function
std::vector< exprt > operandst
void add_function_loops(const irep_idt &identifier, const goto_programt &body)
Generates a loop analysis for the instructions in goto_programt and keys it against function ID.
The Boolean constant false.
Stack frames – these are used for function calls and for exceptions.
const exprt & call_lhs() const
Get the lhs of a FUNCTION_CALL (may be nil)
virtual void symex_function_call(const get_goto_functiont &get_goto_function, statet &state, const goto_programt::instructiont &instruction)
Symbolically execute a FUNCTION_CALL instruction.
void symex_transition(goto_symext::statet &state)
Transition to the next instruction, which increments the internal program counter and initializes the...
A side_effect_exprt that returns a non-deterministically chosen value.
::goto_functiont goto_functiont
void havoc_rec(statet &state, const guardt &guard, const exprt &dest)
namespacet ns
Initialized just before symbolic execution begins, to point to both outer_symbol_table and the symbol...
bool add(const symbolt &symbol)
Add a new symbol to the symbol table.
bool complexity_limits_active
Whether this run of symex is under complexity limits.
const framet & previous_frame()
symex_renaming_levelt current_names
std::unordered_map< irep_idt, local_safe_pointerst > safe_pointers
Map function identifiers to local_safe_pointerst instances.
virtual void function_call(const exprt &guard, const irep_idt &function_id, const std::vector< renamedt< exprt, L2 >> &ssa_function_arguments, const sourcet &source, bool hidden)
Record a function call.
const symex_level2t & get_level2() const
virtual void vcc(const exprt &, const std::string &msg, statet &)
static get_goto_functiont get_goto_function(abstract_goto_modelt &goto_model)
Return a function to get/load a goto function from the given goto model Create a default delegate to ...
const symex_configt symex_config
The configuration to use for this symbolic execution.
const typet & base_type() const
The type of the data what we point to.
std::set< irep_idt > local_objects
std::size_t get_unique_l1_index(const irep_idt &id, std::size_t minimum_index)
Provide a unique L1 index for a given id, starting from minimum_index.
std::function< const goto_functionst::goto_functiont &(const irep_idt &)> get_goto_functiont
The type of delegate functions that retrieve a goto_functiont for a particular function identifier.
symbol_exprt return_value_symbol(const irep_idt &identifier, const namespacet &ns)
produces the symbol that is used to store the return value of the function with the given identifier
const typet & return_type() const
virtual void no_body(const irep_idt &identifier)
Log a warning that a function has no body.
static void locality(const irep_idt &function_identifier, goto_symext::statet &state, path_storaget &path_storage, const goto_functionst::goto_functiont &goto_function, const namespacet &ns)
Preserves locality of parameters of a given function by applying L1 renaming to them.
The Boolean constant true.
mstreamt & warning() const
bitvector_typet c_index_type()
This class represents an instruction in the GOTO intermediate representation.
void symex_assign(statet &state, const exprt &lhs, const exprt &rhs)
Symbolically execute an ASSIGN instruction or simulate such an execution for a synthetic assignment.
ssa_exprt add_object(const symbol_exprt &expr, std::function< std::size_t(const irep_idt &)> index_generator, const namespacet &ns)
Instantiate the object expr.
ranget< iteratort > make_range(iteratort begin, iteratort end)
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 ...
const exprt & call_function() const
Get the function that is called for FUNCTION_CALL.
irep_idt name
The unique identifier.
bool get_bool(const irep_idt &name) const
void drop_existing_l1_name(const irep_idt &l1_identifier)
Drops an L1 name from the local L2 map.
Expression in which some part is missing and can be substituted for another expression.
optionalt< std::reference_wrapper< const mapped_type > > find(const key_type &k) const
Find element.