30 if(pointer.
type().
id()!=ID_pointer)
31 throw "dereference expected pointer type, but got "+
38 std::cout <<
"DEREF: " <<
format(pointer) <<
'\n';
77 if(
object.
id()==ID_index)
87 throw "dereference failed to get object size for index";
96 else if(
object.
id()==ID_member)
100 const typet &compound_type=
103 if(compound_type.
id()==ID_struct)
112 throw "dereference failed to get member offset";
120 else if(compound_type.
id()==ID_union)
129 if(object_type.
id()==ID_array &&
139 !
to_integer(simplified_offset, offset_constant) &&
140 (offset_constant%size_constant)==0)
143 mp_integer index_constant=offset_constant/size_constant;
158 const exprt &address,
162 if(address.
id()==ID_address_of)
170 else if(address.
id()==ID_typecast)
176 else if(address.
id()==ID_plus)
180 throw "plus with less than two operands";
184 else if(address.
id()==ID_if)
190 else if(address.
id()==ID_constant)
203 throw "dereferencet: unexpected pointer constant "+address.
pretty();
207 throw "failed to dereference `"+address.
id_string()+
"'";
244 assert(expr.
op0().
type().
id()==ID_pointer);
252 std::swap(pointer, integer);
257 throw "dereference failed to get object size for pointer arithmetic";
285 if(op_type.
id()==ID_pointer)
287 else if(op_type.
id()==ID_signedbv || op_type.
id()==ID_unsignedbv)
302 throw "dereferencet: unexpected cast";
308 const typet &object_type,
309 const typet &dereference_type)
const 311 if(dereference_type.
id()==ID_empty)
319 if(object_type.
id()==ID_struct &&
320 dereference_type.
id()==ID_struct)
328 if(dereference_type.
id()==ID_code &&
329 object_type.
id()==ID_code)
333 if((object_type.
id()==ID_signedbv || object_type.
id()==ID_unsignedbv) &&
334 (dereference_type.
id()==ID_signedbv ||
335 dereference_type.
id()==ID_unsignedbv))
337 return object_type.
get(ID_width)==dereference_type.
get(ID_width);
342 if(object_type.
id()==ID_pointer &&
343 dereference_type.
id()==ID_pointer)
const if_exprt & to_if_expr(const exprt &expr)
Cast an exprt to an if_exprt.
The type of an expression, extends irept.
exprt size_of_expr(const typet &type, const namespacet &ns)
Semantic type conversion.
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)
Attempt to dereference the object at address address + offset and of type type.
bool base_type_eq(const typet &type1, const typet &type2, const namespacet &ns)
Check types for equality across all levels of hierarchy.
exprt dereference_if(const if_exprt &expr, const exprt &offset, const typet &type)
Attempt to dereference the object at address expr + offset and of type type.
const irep_idt & get_value() const
The trinary if-then-else operator.
typet & type()
Return the type of the expression.
const address_of_exprt & to_address_of_expr(const exprt &expr)
Cast an exprt to an address_of_exprt.
Structure type, corresponds to C style structs.
exprt dereference_typecast(const typecast_exprt &expr, const exprt &offset, const typet &type)
Attempt to dereference the object at address expr + offset and of type 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
Check that it is ok to cast an object of type object_type to deference_type.
API to expression classes.
const irep_idt & get(const irep_namet &name) const
Generic base class for unary expressions.
const member_exprt & to_member_expr(const exprt &expr)
Cast an exprt to a member_exprt.
The plus expression Associativity is not specified.
const typet & follow(const typet &) const
Resolve type symbol to the type it points to.
bitvector_typet index_type()
const struct_typet & to_struct_type(const typet &type)
Cast a typet to a struct_typet.
Operator to return the address of an object.
const constant_exprt & to_constant_expr(const exprt &expr)
Cast an exprt to a constant_exprt.
std::vector< exprt > operandst
Binary multiplication Associativity is not specified.
optionalt< mp_integer > member_offset(const struct_typet &type, const irep_idt &member, const namespacet &ns)
bool is_prefix_of(const struct_typet &other) const
Returns true if the struct is a prefix of other, i.e., if this struct has n components then the compo...
Base class for all expressions.
const exprt & struct_op() const
exprt dereference_plus(const exprt &expr, const exprt &offset, const typet &type)
Attempt to dereference the object at address expr + offset and of type type.
irep_idt get_component_name() const
const typecast_exprt & to_typecast_expr(const exprt &expr)
Cast an exprt to a typecast_exprt.
const std::string & id_string() const
bool is_zero() const
Return whether the expression is a constant representing 0.
const typet & subtype() const
exprt operator()(const exprt &pointer)
Dereference the given pointer-expression.
void make_typecast(const typet &_type)
Create a typecast_exprt to the given type.
const index_exprt & to_index_expr(const exprt &expr)
Cast an exprt to an index_exprt.
exprt read_object(const exprt &object, const exprt &offset, const typet &type)
irep_idt byte_extract_id()