Go to the documentation of this file.
26 const exprt &new_expr)
30 "types to be replaced should match. old type:\n" +
32 expr_map.insert(std::pair<irep_idt, exprt>(
51 s.
type() == it->second.type(),
52 "types to be replaced should match. s.type:\n" + s.
type().
pretty() +
53 "\nit->second.type:\n" + it->second.type().pretty());
54 static_cast<exprt &
>(s) = it->second;
65 const exprt &const_dest(dest);
75 if(dest.
id()==ID_member)
82 else if(dest.
id()==ID_index)
92 else if(dest.
id()==ID_address_of)
99 else if(dest.
id()==ID_symbol)
104 else if(dest.
id() == ID_let)
109 for(
auto &op : let_expr.values())
115 for(
auto &variable : let_expr.variables())
116 bindings.insert(variable.get_identifier());
125 dest.
id() == ID_array_comprehension || dest.
id() == ID_exists ||
126 dest.
id() == ID_forall || dest.
id() == ID_lambda)
131 for(
auto &binding : binding_expr.variables())
132 bindings.insert(binding.get_identifier());
134 if(!
replace(binding_expr.where()))
146 const typet &c_sizeof_type =
147 static_cast<const typet&
>(dest.
find(ID_C_c_sizeof_type));
151 const typet &va_arg_type =
152 static_cast<const typet&
>(dest.
find(ID_C_va_arg_type));
171 if(dest.
id()==ID_symbol)
184 const irept &c_sizeof_type=dest.
find(ID_C_c_sizeof_type);
190 const irept &va_arg_type=dest.
find(ID_C_va_arg_type);
216 if(dest.
id()==ID_struct ||
225 else if(dest.
id()==ID_code)
235 const exprt &spec_assigns =
236 static_cast<const exprt &
>(dest.
find(ID_C_spec_assigns));
240 const exprt &spec_ensures =
241 static_cast<const exprt &
>(dest.
find(ID_C_spec_ensures));
245 const exprt &spec_ensures_contract =
246 static_cast<const exprt &
>(dest.
find(ID_C_spec_ensures_contract));
255 const exprt &spec_requires =
256 static_cast<const exprt &
>(dest.
find(ID_C_spec_requires));
260 const exprt &spec_requires_contract =
261 static_cast<const exprt &
>(dest.
find(ID_C_spec_requires_contract));
270 else if(dest.
id()==ID_array)
295 if(dest.
id()==ID_struct ||
301 for(
const auto &c : struct_union_type.
components())
305 else if(dest.
id()==ID_code)
315 const exprt &spec_assigns =
316 static_cast<const exprt &
>(dest.
find(ID_C_spec_assigns));
320 const exprt &spec_ensures =
321 static_cast<const exprt &
>(dest.
find(ID_C_spec_ensures));
325 const exprt &spec_ensures_contract =
326 static_cast<const exprt &
>(dest.
find(ID_C_spec_ensures_contract));
334 const exprt &spec_requires =
335 static_cast<const exprt &
>(dest.
find(ID_C_spec_requires));
339 const exprt &spec_requires_contract =
340 static_cast<const exprt &
>(dest.
find(ID_C_spec_requires_contract));
348 else if(dest.
id()==ID_array)
356 const exprt &new_expr)
368 static_cast<exprt &
>(s) = it->second;
375 const exprt &const_dest(dest);
394 if(dest.
id() == ID_index)
406 else if(dest.
id() == ID_address_of)
422 const typet &c_sizeof_type =
423 static_cast<const typet &
>(dest.
find(ID_C_c_sizeof_type));
426 static_cast<typet &
>(dest.
add(ID_C_c_sizeof_type)));
428 const typet &va_arg_type =
429 static_cast<const typet &
>(dest.
find(ID_C_va_arg_type));
432 static_cast<typet &
>(dest.
add(ID_C_va_arg_type)));
const componentst & components() const
dstringt has one field, an unsigned integer no which is an index into a static table of strings.
virtual ~replace_symbolt()
bool is_assignable(const exprt &expr)
Returns true iff the argument is one of the following:
bool have_to_replace(const exprt &dest) const
bool replaces_symbol(const irep_idt &id) const
#define Forall_operands(it, expr)
const struct_union_typet & to_struct_union_type(const typet &type)
Cast a typet to a struct_union_typet.
The type of an expression, extends irept.
std::string pretty(unsigned indent=0, unsigned max_indent=0) const
const index_exprt & to_index_expr(const exprt &expr)
Cast an exprt to an index_exprt.
const irept & find(const irep_idt &name) const
Base type for structs and unions.
const type_with_subtypet & to_type_with_subtype(const typet &type)
const type_with_subtypest & to_type_with_subtypes(const typet &type)
Base class for all expressions.
Expression to hold a symbol (variable)
const exprt & size() const
typet & type()
Return the type of the expression.
virtual bool replace_symbol_expr(symbol_exprt &dest) const
const code_typet & to_code_type(const typet &type)
Cast a typet to a code_typet.
#define DATA_INVARIANT(CONDITION, REASON)
This condition should be used to document that assumptions that are made on goto_functions,...
#define forall_operands(it, expr)
const exprt & struct_op() const
#define PRECONDITION(CONDITION)
const irep_idt & get_identifier() const
bool replace(exprt &dest) const override
const let_exprt & to_let_expr(const exprt &expr)
Cast an exprt to a let_exprt.
virtual bool replace(exprt &dest) const
const symbol_exprt & to_symbol_expr(const exprt &expr)
Cast an exprt to a symbol_exprt.
const irep_idt & id() const
void insert(const class symbol_exprt &old_expr, const exprt &new_expr)
Sets old_expr to be replaced by new_expr if we don't already have a replacement; otherwise does nothi...
const parameterst & parameters() const
Extract member of struct or union.
Deprecated expression utility functions.
std::set< irep_idt > bindings
irept & add(const irep_idt &name)
void insert(const symbol_exprt &old_expr, const exprt &new_expr)
#define PRECONDITION_WITH_DIAGNOSTICS(CONDITION,...)
const array_typet & to_array_type(const typet &type)
Cast a typet to an array_typet.
const typet & return_type() const
const member_exprt & to_member_expr(const exprt &expr)
Cast an exprt to a member_exprt.
There are a large number of kinds of tree structured or tree-like data in CPROVER.
bool replace_symbol_expr(symbol_exprt &dest) const override
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.
const binding_exprt & to_binding_expr(const exprt &expr)
Cast an exprt to a binding_exprt.
bool replace_symbol_expr(symbol_exprt &dest) const override
void set(const class symbol_exprt &old_expr, const exprt &new_expr)
Sets old_expr to be replaced by new_expr.