Go to the documentation of this file.
30 const irept &sizeof_type=expr.
find(ID_C_c_sizeof_type);
34 return static_cast<const typet &
>(sizeof_type);
36 else if(expr.
id()==ID_mult)
64 INVARIANT(function_symbol,
"function associated with allocation not found");
65 const irep_idt &mode = function_symbol->mode;
69 code.
type().
id() == ID_pointer &&
84 if(tmp_type.has_value())
88 const auto alloc_size = numeric_cast<mp_integer>(tmp_size);
90 if(!elem_size.has_value() || *elem_size==0)
94 !alloc_size.has_value() && tmp_size.
id() == ID_mult &&
112 else if(alloc_size.has_value())
114 if(*alloc_size == *elem_size)
115 object_type = *tmp_type;
118 mp_integer elements = *alloc_size / (*elem_size);
120 if(elements * (*elem_size) == *alloc_size)
128 if(!object_type.has_value())
135 object_type->id() == ID_array &&
147 size_symbol.
mode = mode;
148 size_symbol.
type.
set(ID_C_constant,
true);
149 size_symbol.
value = array_size;
153 auto array_size_rhs = array_size;
166 value_symbol.
type = *object_type;
167 value_symbol.
type.
set(ID_C_dynamic,
true);
168 value_symbol.
mode = mode;
177 zero_init.
is_constant(),
"allocate expects constant as second argument");
181 const auto zero_value =
196 if(object_type->id() == ID_array)
228 auto parameter_size =
size_of_expr(parameter_expr.type(), ns);
267 bool parameter_id_found =
false;
270 if(!parameter_id_found)
272 parameter_id_found = parameter == start_parameter;
276 va_arg_operands.push_back(
279 const std::size_t va_arg_size = va_arg_operands.
size();
293 va_array.
value = array;
295 array =
clean_expr(std::move(array), state,
false);
296 array = state.
rename(std::move(array),
ns).get();
302 rhs = state.
rename(std::move(rhs),
ns).get();
308 if(src.
id()==ID_typecast)
312 else if(src.
id()==ID_address_of)
316 if(
object.
id() == ID_index)
321 index_expr.array().id() == ID_string_constant &&
322 index_expr.index().is_zero())
324 const exprt &fmt_str = index_expr.array();
328 else if(
object.
id() == ID_string_constant)
348 if(operands.size() != 2)
352 if(second_op.
id() != ID_address_of)
359 if(
object.
id() != ID_index)
366 return index_expr.
array();
377 tmp_rhs = state.
rename(std::move(tmp_rhs),
ns).get();
381 std::list<exprt> args;
386 if(!va_args.has_value())
388 args.insert(args.end(), std::next(operands.begin()), operands.end());
394 *va_args = state.
rename(*va_args,
ns).get();
395 if(va_args->id() != ID_array)
402 for(
const auto &op : va_args->operands())
405 if(parameter.
id() == ID_address_of)
408 parameter = state.
rename(std::move(parameter),
ns).get();
411 args.push_back(std::move(parameter));
418 if(!format_string.
empty())
421 state.
source,
"printf", format_string, args);
432 std::list<exprt> args;
434 for(std::size_t i=1; i<code.
operands().size(); i++)
438 args.emplace_back(std::move(l2_arg));
453 std::list<renamedt<exprt, L2>> args;
455 for(std::size_t i=1; i<code.
operands().size(); i++)
460 args.emplace_back(l2_arg);
480 (code.
get(ID_statement) == ID_cpp_new_array ||
481 code.
get(ID_statement) == ID_java_new_array_data);
490 do_array?
"dynamic_"+count_string+
"_array":
491 "dynamic_"+count_string+
"_value";
494 if(code.
get(ID_statement)==ID_cpp_new_array ||
495 code.
get(ID_statement)==ID_cpp_new)
497 else if(code.
get(ID_statement) == ID_java_new_array_data)
511 symbol.
type.
set(ID_C_dynamic,
true);
537 bool do_array=code.get(ID_statement)==ID_cpp_delete_array;
void copy_to_operands(const exprt &expr)
Copy the given argument to the end of exprt's operands.
exprt clean_expr(exprt expr, statet &state, bool write)
Clean up an expression.
dstringt has one field, an unsigned integer no which is an index into a static table of strings.
static exprt conditional_cast(const exprt &expr, const typet &type)
const unary_exprt & to_unary_expr(const exprt &expr)
Cast an exprt to a unary_exprt.
const exprt & skip_typecast(const exprt &expr)
find the expression nested inside typecasts, if any
symex_nondet_generatort build_symex_nondet
Counter for nondet objects, which require unique names.
static unsigned dynamic_counter
A monotonically increasing index for each created dynamic object.
#define CHECK_RETURN(CONDITION)
The type of an expression, extends irept.
goto_programt::const_targett pc
virtual void symex_printf(statet &state, const exprt &rhs)
Symbolically execute an OTHER instruction that does a CPP printf
const index_exprt & to_index_expr(const exprt &expr)
Cast an exprt to an index_exprt.
const irept & find(const irep_idt &name) const
symex_target_equationt & target
The equation that this execution is building up.
typet type
Type of symbol.
path_storaget & path_storage
Symbolic execution paths to be resumed later.
Central data structure: state.
The trinary if-then-else operator.
void simplify(const namespacet &ns)
virtual void symex_cpp_new(statet &state, const exprt &lhs, const side_effect_exprt &code)
Handles side effects of type 'new' for C++ and 'new array' for C++ and Java language modes.
const string_constantt & to_string_constant(const exprt &expr)
Base class for all expressions.
irep_idt get_object_name() const
symex_targett::sourcet source
irep_idt base_name
Base (non-scoped) name.
static optionalt< exprt > get_va_args(const exprt::operandst &operands)
Return an expression if operands fulfills all criteria that we expect of the expression to be a varia...
std::string to_string(const string_not_contains_constraintt &expr)
Used for debug printing.
Internally generated symbol table entry.
unsignedbv_typet unsigned_char_type()
Expression to hold a symbol (variable)
exprt apply(const namespacet &ns, goto_symex_statet &state, exprt expr, bool write) const
Turn an expression expr into a field-sensitive SSA expression.
Storage of symbolic execution paths to resume.
optionalt< exprt > zero_initializer(const typet &type, const source_locationt &source_location, const namespacet &ns)
Create the equivalent of zero for type type.
bool is_false() const
Return whether the expression is a constant representing false.
const irep_idt & get(const irep_idt &name) const
const binary_exprt & to_binary_expr(const exprt &expr)
Cast an exprt to a binary_exprt.
const exprt & size() const
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.
bool lookup(const irep_idt &name, const symbolt *&symbol) const override
See documentation for namespace_baset::lookup().
std::vector< irep_idt > parameter_names
call_stackt & call_stack()
irep_idt mode
Language mode.
const symbol_tablet & outer_symbol_table
The symbol table associated with the goto-program being executed.
const mult_exprt & to_mult_expr(const exprt &expr)
Cast an exprt to a mult_exprt.
const ssa_exprt & to_ssa_expr(const exprt &expr)
Cast a generic exprt to an ssa_exprt.
static irep_idt get_string_argument_rec(const exprt &src)
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.
virtual void symex_cpp_delete(statet &state, const codet &code)
Symbolically execute an OTHER instruction that does a CPP delete
static optionalt< typet > c_sizeof_type_rec(const exprt &expr)
#define forall_operands(it, expr)
#define SYMEX_DYNAMIC_PREFIX
void set(const irep_idt &name, const irep_idt &value)
A base class for expressions that are predicates, i.e., Boolean-typed, and that take exactly two argu...
#define PRECONDITION(CONDITION)
virtual void symex_allocate(statet &state, const exprt &lhs, const side_effect_exprt &code)
Symbolically execute an assignment instruction that has an allocate on the right hand side.
virtual void symex_va_start(statet &, const exprt &lhs, const side_effect_exprt &)
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...
class symbol_exprt symbol_expr() const
Produces a symbol_exprt for a symbol.
virtual void symex_input(statet &state, const codet &code)
Symbolically execute an OTHER instruction that does a CPP input.
static exprt va_list_entry(const irep_idt ¶meter, const pointer_typet &lhs_type, const namespacet &ns)
Construct an entry for the var args array.
bool simplify(exprt &expr, const namespacet &ns)
const pointer_typet & to_pointer_type(const typet &type)
Cast a typet to a pointer_typet.
pointer_typet pointer_type(const typet &subtype)
const irep_idt & id() const
std::vector< exprt > operandst
nonstd::optional< T > optionalt
virtual void do_simplify(exprt &expr)
field_sensitivityt field_sensitivity
std::size_t get_width() const
bool is_zero() const
Return whether the expression is a constant representing 0.
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.
Deprecated expression utility functions.
exprt value
Initial value of symbol.
virtual void output_fmt(const exprt &guard, const sourcet &source, const irep_idt &output_id, const irep_idt &fmt, const std::list< exprt > &args)
Record formatted output.
optionalt< mp_integer > pointer_offset_size(const typet &type, const namespacet &ns)
Compute the size of a type in bytes, rounding up to full bytes.
const typecast_exprt & to_typecast_expr(const exprt &expr)
Cast an exprt to a typecast_exprt.
bool is_constant() const
Return whether the expression is a constant.
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.
static irep_idt get_string_argument(const exprt &src, const namespacet &ns)
const array_typet & to_array_type(const typet &type)
Cast a typet to an array_typet.
void add_to_operands(const exprt &expr)
Add the given argument to the end of exprt's operands.
const symbolt * lookup(const irep_idt &name) const
Find a symbol in the symbol table for read-only access.
optionalt< exprt > size_of_expr(const typet &type, const namespacet &ns)
There are a large number of kinds of tree structured or tree-like data in CPROVER.
const address_of_exprt & to_address_of_expr(const exprt &expr)
Cast an exprt to an address_of_exprt.
Operator to return the address of an object.
The pointer type These are both 'bitvector_typet' (they have a width) and 'type_with_subtypet' (they ...
unsignedbv_typet size_type()
bool is_constant(const typet &type)
This method tests, if the given typet is a constant.
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.
const source_locationt & source_location() const
typet index_type() const
The type of the index expressions into any instance of this type.
Array constructor from list of elements.
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 ...
irep_idt name
The unique identifier.
virtual void symex_output(statet &state, const codet &code)
Symbolically execute an OTHER instruction that does a CPP output.
Wrapper for expressions or types which have been renamed up to a given level.
const irep_idt & get_value() const
#define INVARIANT_WITH_IREP(CONDITION, DESCRIPTION, IREP)
Equivalent to INVARIANT_STRUCTURED(CONDITION, invariant_failedt, pretty_print_invariant_with_irep(IRE...
An expression containing a side effect.
virtual void input(const exprt &guard, const sourcet &source, const irep_idt &input_id, const std::list< exprt > &args)
Record an input.
virtual void output(const exprt &guard, const sourcet &source, const irep_idt &output_id, const std::list< renamedt< exprt, L2 >> &args)
Record an output.
Data structure for representing an arbitrary statement in a program.