43 if(comp.type().id()==ID_c_bit_field)
52 const typet &subtype=comp.type();
71 for(struct_typet::componentst::const_iterator
72 it=components.begin();
73 it!=components.end() && offsets->second!=-1;
76 if(it->get_name()==member)
80 return offsets->second;
90 return bits/8+(((bits%8)==0)?0:1);
97 if(type.
id()==ID_array)
114 else if(type.
id()==ID_vector)
131 else if(type.
id()==ID_complex)
139 else if(type.
id()==ID_struct)
147 for(struct_typet::componentst::const_iterator
148 it=components.begin();
149 it!=components.end();
152 const typet &subtype=it->type();
161 else if(type.
id()==ID_union)
171 for(union_typet::componentst::const_iterator
172 it=components.begin();
173 it!=components.end();
176 const typet &subtype=it->type();
186 else if(type.
id()==ID_signedbv ||
187 type.
id()==ID_unsignedbv ||
188 type.
id()==ID_fixedbv ||
189 type.
id()==ID_floatbv ||
191 type.
id()==ID_c_bool)
195 else if(type.
id()==ID_c_bit_field)
199 else if(type.
id()==ID_c_enum)
203 else if(type.
id()==ID_c_enum_tag)
207 else if(type.
id()==ID_bool)
211 else if(type.
id()==ID_pointer)
215 else if(type.
id()==ID_symbol)
219 else if(type.
id()==ID_code)
223 else if(type.
id()==ID_string)
237 if(type.
id()==ID_struct)
240 else if(type.
id()==ID_union)
254 std::size_t bit_field_bits=0;
256 for(struct_typet::componentst::const_iterator
257 it=components.begin();
258 it!=components.end();
261 if(it->get_name()==member)
264 if(it->type().id()==ID_c_bit_field)
268 for(bytes=0; w>bit_field_bits; ++bytes, bit_field_bits+=8) {}
274 const typet &subtype=it->type();
291 if(type.
id()==ID_array)
312 else if(type.
id()==ID_vector)
332 else if(type.
id()==ID_complex)
345 else if(type.
id()==ID_struct)
352 std::size_t bit_field_bits=0;
354 for(struct_typet::componentst::const_iterator
355 it=components.begin();
356 it!=components.end();
359 if(it->type().id()==ID_c_bit_field)
363 for(bytes=0; w>bit_field_bits; ++bytes, bit_field_bits+=8) {}
369 const typet &subtype=it->type();
382 else if(type.
id()==ID_union)
392 for(union_typet::componentst::const_iterator
393 it=components.begin();
394 it!=components.end();
397 const typet &subtype=it->type();
400 if(subtype.
id()==ID_c_bit_field)
421 else if(type.
id()==ID_signedbv ||
422 type.
id()==ID_unsignedbv ||
423 type.
id()==ID_fixedbv ||
424 type.
id()==ID_floatbv ||
426 type.
id()==ID_c_bool)
429 std::size_t bytes=width/8;
434 else if(type.
id()==ID_c_enum)
437 std::size_t bytes=width/8;
442 else if(type.
id()==ID_c_enum_tag)
446 else if(type.
id()==ID_bool)
450 else if(type.
id()==ID_pointer)
453 std::size_t bytes=width/8;
458 else if(type.
id()==ID_symbol)
462 else if(type.
id()==ID_code)
466 else if(type.
id()==ID_string)
478 if(expr.
id()==ID_symbol)
486 else if(expr.
id()==ID_index)
491 assert(array_type.id()==ID_array);
508 else if(expr.
id()==ID_member)
513 assert(type.id()==ID_struct ||
514 type.id()==ID_union);
520 if(type.id()==ID_union)
527 else if(expr.
id()==ID_string_constant)
538 static_cast<const typet &
>(expr.
find(ID_C_c_sizeof_type));
548 (type_size==0 && val>0))
557 remainder=val%type_size;
562 exprt result(ID_sizeof, t);
563 result.
set(ID_type_arg, type);
579 const typet &target_type_raw,
583 const typet &target_type=ns.
follow(target_type_raw);
585 if(offset==0 && source_type==target_type)
588 if(source_type.
id()==ID_struct)
593 while(offsets->first<components.size() &&
594 offsets->second!=-1 &&
595 offsets->second<=offset)
599 if((offsets->first+1)==components.size() || offset<nextit->second)
605 components[offsets->first].get_name(),
606 components[offsets->first].
type());
609 result, offset-offsets->second, target_type, ns);
615 else if(source_type.
id()==ID_array)
624 if(cellidx < 0 || !cellidx.is_long())
626 offset=offset%elem_size;
637 const typet &target_type,
The type of an expression.
exprt size_of_expr(const typet &type, const namespacet &ns)
const typet & follow(const typet &src) const
struct configt::ansi_ct ansi_c
Fixed-width bit-vector with unsigned binary interpretation.
const struct_typet & type
exprt member_offset_expr(const member_exprt &member_expr, const namespacet &ns)
member_offset_iterator(const struct_typet &_type, const namespacet &_ns)
Deprecated expression utility functions.
const union_typet & to_union_type(const typet &type)
Cast a generic typet to a union_typet.
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
mp_integer pointer_offset_bits(const typet &type, const namespacet &ns)
unsignedbv_typet size_type()
A constant literal expression.
mp_integer pointer_offset_size(const typet &type, const namespacet &ns)
Extract member of struct or union.
const typet & follow_tag(const union_tag_typet &src) const
const irep_idt & id() const
const array_typet & to_array_type(const typet &type)
Cast a generic typet to an array_typet.
const c_enum_tag_typet & to_c_enum_tag_type(const typet &type)
Cast a generic typet to a c_enum_tag_typet.
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 irep_idt & get(const irep_namet &name) const
const exprt & size() const
const exprt & size() const
const c_bit_field_typet & to_c_bit_field_type(const typet &type)
Cast a generic typet to a c_bit_field_typet.
std::size_t get_width() const
const struct_typet & to_struct_type(const typet &type)
Cast a generic typet to a struct_typet.
mp_integer compute_pointer_offset(const exprt &expr, const namespacet &ns)
Base class for all expressions.
const exprt & struct_op() const
const exprt & get_original_expr() const
irep_idt get_component_name() const
bool is_ssa_expr(const exprt &expr)
member_offset_iterator & operator++()
const typet & subtype() const
const vector_typet & to_vector_type(const typet &type)
Cast a generic typet to a vector_typet.
void make_typecast(const typet &_type)
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)
const bitvector_typet & to_bitvector_type(const typet &type)
Cast a generic typet to a bitvector_typet.