32 if(pointer.
type().
id()!=ID_pointer)
33 throw "dereference expected pointer type, but got "+
40 std::cout <<
"DEREF: " <<
format(pointer) <<
'\n';
76 if(
object.
id()==ID_index)
86 throw "dereference failed to get object size for index";
95 else if(
object.
id()==ID_member)
99 const typet &compound_type=
102 if(compound_type.
id()==ID_struct)
111 throw "dereference failed to get member offset";
119 else if(compound_type.
id()==ID_union)
128 if(object_type.
id()==ID_array &&
138 !
to_integer(simplified_offset, offset_constant) &&
139 (offset_constant%size_constant)==0)
142 mp_integer index_constant=offset_constant/size_constant;
155 const exprt &address,
159 if(address.
id()==ID_address_of)
167 else if(address.
id()==ID_typecast)
173 else if(address.
id()==ID_plus)
177 throw "plus with less than two operands";
181 else if(address.
id()==ID_if)
187 else if(address.
id()==ID_constant)
200 throw "dereferencet: unexpected pointer constant "+address.
pretty();
204 throw "failed to dereference `"+address.
id_string()+
"'";
231 assert(expr.
op0().
type().
id()==ID_pointer);
239 std::swap(pointer, integer);
244 throw "dereference failed to get object size for pointer arithmetic";
264 if(op_type.
id()==ID_pointer)
266 else if(op_type.
id()==ID_signedbv || op_type.
id()==ID_unsignedbv)
281 throw "dereferencet: unexpected cast";
285 const typet &object_type,
286 const typet &dereference_type)
const 288 if(dereference_type.
id()==ID_empty)
296 if(object_type.
id()==ID_struct &&
297 dereference_type.
id()==ID_struct)
305 if(dereference_type.
id()==ID_code &&
306 object_type.
id()==ID_code)
310 if((object_type.
id()==ID_signedbv || object_type.
id()==ID_unsignedbv) &&
311 (dereference_type.
id()==ID_signedbv ||
312 dereference_type.
id()==ID_unsignedbv))
314 return object_type.
get(ID_width)==dereference_type.
get(ID_width);
319 if(object_type.
id()==ID_pointer &&
320 dereference_type.
id()==ID_pointer)
const if_exprt & to_if_expr(const exprt &expr)
Cast a generic exprt to an if_exprt.
The type of an expression.
exprt size_of_expr(const typet &type, const namespacet &ns)
exprt member_offset_expr(const member_exprt &member_expr, const namespacet &ns)
std::string pretty(unsigned indent=0, unsigned max_indent=0) const
exprt simplify_expr(const exprt &src, const namespacet &ns)
exprt dereference_rec(const exprt &address, const exprt &offset, const typet &type)
bool base_type_eq(const typet &type1, const typet &type2, const namespacet &ns)
mp_integer member_offset(const struct_typet &type, const irep_idt &member, const namespacet &ns)
exprt dereference_if(const if_exprt &expr, const exprt &offset, const typet &type)
const irep_idt & get_value() const
The trinary if-then-else operator.
const address_of_exprt & to_address_of_expr(const exprt &expr)
Cast a generic exprt to an address_of_exprt.
exprt dereference_typecast(const typecast_exprt &expr, const exprt &offset, const typet &type)
Extract member of struct or union.
const irep_idt & id() const
Expression classes for byte-level operators.
bool type_compatible(const typet &object_type, const typet &dereference_type) const
API to expression classes.
const irep_idt & get(const irep_namet &name) const
Generic base class for unary expressions.
irep_idt byte_extract_id()
const member_exprt & to_member_expr(const exprt &expr)
Cast a generic exprt to a member_exprt.
const typet & follow(const typet &) const
bitvector_typet index_type()
const struct_typet & to_struct_type(const typet &type)
Cast a generic typet to a struct_typet.
Operator to return the address of an object.
const constant_exprt & to_constant_expr(const exprt &expr)
Cast a generic exprt to a constant_exprt.
std::vector< exprt > operandst
bool is_prefix_of(const struct_typet &other) const
Base class for all expressions.
const exprt & struct_op() const
exprt dereference_plus(const exprt &expr, const exprt &offset, const typet &type)
irep_idt get_component_name() const
const typecast_exprt & to_typecast_expr(const exprt &expr)
Cast a generic exprt to a typecast_exprt.
const std::string & id_string() const
const typet & subtype() const
exprt operator()(const exprt &pointer)
void make_typecast(const typet &_type)
const index_exprt & to_index_expr(const exprt &expr)
Cast a generic exprt to an index_exprt.
exprt read_object(const exprt &object, const exprt &offset, const typet &type)