37 if(comp.type().id()==ID_c_bit_field)
49 const typet &subtype=comp.type();
68 for(struct_typet::componentst::const_iterator
69 it=components.begin();
70 it!=components.end() && offsets->second!=-1;
73 if(it->get_name()==member)
77 return offsets->second;
88 for(
const auto &comp : components)
90 if(comp.get_name()==member)
118 if(type.
id()==ID_array)
135 else if(type.
id()==ID_vector)
152 else if(type.
id()==ID_complex)
160 else if(type.
id()==ID_struct)
168 for(struct_typet::componentst::const_iterator
169 it=components.begin();
170 it!=components.end();
173 const typet &subtype=it->type();
182 else if(type.
id()==ID_union)
192 for(union_typet::componentst::const_iterator
193 it=components.begin();
194 it!=components.end();
197 const typet &subtype=it->type();
207 else if(type.
id()==ID_signedbv ||
208 type.
id()==ID_unsignedbv ||
209 type.
id()==ID_fixedbv ||
210 type.
id()==ID_floatbv ||
212 type.
id()==ID_c_bool ||
213 type.
id()==ID_c_bit_field)
217 else if(type.
id()==ID_c_enum)
221 else if(type.
id()==ID_c_enum_tag)
225 else if(type.
id()==ID_bool)
229 else if(type.
id()==ID_pointer)
237 else if(type.
id()==ID_symbol)
241 else if(type.
id()==ID_code)
245 else if(type.
id()==ID_string)
259 if(type.
id()==ID_struct)
262 else if(type.
id()==ID_union)
276 std::size_t bit_field_bits=0;
278 for(struct_typet::componentst::const_iterator
279 it=components.begin();
280 it!=components.end();
283 if(it->get_name()==member)
286 if(it->type().id()==ID_c_bit_field)
290 const std::size_t bytes = bit_field_bits / 8;
297 bit_field_bits == 0,
"padding ensures offset at byte boundaries");
298 const typet &subtype=it->type();
315 if(type.
id()==ID_array)
335 else if(type.
id()==ID_vector)
355 else if(type.
id()==ID_complex)
368 else if(type.
id()==ID_struct)
375 std::size_t bit_field_bits=0;
377 for(struct_typet::componentst::const_iterator
378 it=components.begin();
379 it!=components.end();
382 if(it->type().id()==ID_c_bit_field)
386 const std::size_t bytes = bit_field_bits / 8;
393 bit_field_bits == 0,
"padding ensures offset at byte boundaries");
394 const typet &subtype=it->type();
407 else if(type.
id()==ID_union)
418 for(union_typet::componentst::const_iterator
419 it=components.begin();
420 it!=components.end();
423 const typet &subtype=it->type();
442 if(max_bytes<sub_bytes)
463 else if(type.
id()==ID_signedbv ||
464 type.
id()==ID_unsignedbv ||
465 type.
id()==ID_fixedbv ||
466 type.
id()==ID_floatbv ||
468 type.
id()==ID_c_bool ||
469 type.
id()==ID_c_bit_field)
472 std::size_t bytes=width/8;
477 else if(type.
id()==ID_c_enum)
480 std::size_t bytes=width/8;
485 else if(type.
id()==ID_c_enum_tag)
489 else if(type.
id()==ID_bool)
493 else if(type.
id()==ID_pointer)
500 std::size_t bytes=width/8;
505 else if(type.
id()==ID_symbol)
509 else if(type.
id()==ID_code)
513 else if(type.
id()==ID_string)
525 if(expr.
id()==ID_symbol)
533 else if(expr.
id()==ID_index)
538 array_type.
id()==ID_array,
539 "index into array expected, found "+array_type.
id_string());
556 else if(expr.
id()==ID_member)
566 if(type.
id()==ID_union)
573 else if(expr.
id()==ID_string_constant)
584 static_cast<const typet &
>(expr.
find(ID_C_c_sizeof_type));
594 (type_size==0 && val>0))
600 "sizeof value does not fit size_type");
605 remainder=val%type_size;
610 exprt result(ID_sizeof, t);
611 result.
set(ID_type_arg, type);
627 const typet &target_type_raw,
631 const typet &target_type=ns.
follow(target_type_raw);
633 if(offset==0 && source_type==target_type)
636 if(source_type.
id()==ID_struct)
641 while(offsets->first<components.size() &&
642 offsets->second!=-1 &&
643 offsets->second<=offset)
647 if((offsets->first+1)==components.size() || offset<nextit->second)
653 components[offsets->first].get_name(),
654 components[offsets->first].
type());
657 result, offset-offsets->second, target_type, ns);
663 else if(source_type.
id()==ID_array)
672 if(cellidx < 0 || !cellidx.is_long())
674 offset=offset%elem_size;
685 const typet &target_type,
The type of an expression.
exprt size_of_expr(const typet &type, const namespacet &ns)
Fixed-width bit-vector with unsigned binary interpretation.
const struct_typet & type
exprt member_offset_expr(const member_exprt &member_expr, const namespacet &ns)
A generic base class for relations, i.e., binary predicates.
const bitvector_typet & to_bitvector_type(const typet &type)
Cast a generic typet to a bitvector_typet.
member_offset_iterator(const struct_typet &_type, const namespacet &_ns)
mp_integer member_offset(const struct_typet &type, const irep_idt &member, const namespacet &ns)
std::vector< componentt > componentst
exprt build_sizeof_expr(const constant_exprt &expr, const namespacet &ns)
const componentst & components() const
The trinary if-then-else operator.
mp_integer pointer_offset_bits(const typet &type, const namespacet &ns)
unsignedbv_typet size_type()
A constant literal expression.
bool get_bool(const irep_namet &name) const
const typet & follow_tag(const union_tag_typet &) const
mp_integer pointer_offset_size(const typet &type, const namespacet &ns)
Compute the size of a type in bytes, rounding up to full bytes.
Extract member of struct or union.
const irep_idt & id() const
const ssa_exprt & to_ssa_expr(const exprt &expr)
Cast a generic exprt to an ssa_exprt.
bool get_subexpression_at_offset(exprt &result, mp_integer offset, const typet &target_type_raw, const namespacet &ns)
API to expression classes.
const exprt & size() const
const member_exprt & to_member_expr(const exprt &expr)
Cast a generic exprt to a member_exprt.
const vector_typet & to_vector_type(const typet &type)
Cast a generic typet to a vector_typet.
const exprt & size() const
const typet & follow(const typet &) const
const struct_typet & to_struct_type(const typet &type)
Cast a generic typet to a struct_typet.
std::size_t get_width() const
const c_enum_tag_typet & to_c_enum_tag_type(const typet &type)
Cast a generic typet to a c_enum_tag_typet.
mp_integer compute_pointer_offset(const exprt &expr, const namespacet &ns)
Base type of C structs and unions, and C++ classes.
const array_typet & to_array_type(const typet &type)
Cast a generic typet to an array_typet.
Base class for all expressions.
const exprt & struct_op() const
const struct_union_typet & to_struct_union_type(const typet &type)
Cast a generic typet to a struct_union_typet.
const union_typet & to_union_type(const typet &type)
Cast a generic typet to a union_typet.
const exprt & get_original_expr() const
irep_idt get_component_name() const
bool is_ssa_expr(const exprt &expr)
member_offset_iterator & operator++()
const std::string & id_string() const
const c_bit_field_typet & to_c_bit_field_type(const typet &type)
Cast a generic typet to a c_bit_field_typet.
const typet & subtype() const
#define DATA_INVARIANT(CONDITION, REASON)
mp_integer member_offset_bits(const struct_typet &type, const irep_idt &member, const namespacet &ns)
void make_typecast(const typet &_type)
const index_exprt & to_index_expr(const exprt &expr)
Cast a generic exprt to an index_exprt.
const irept & find(const irep_namet &name) const
void set(const irep_namet &name, const irep_idt &value)
bool simplify(exprt &expr, const namespacet &ns)