Go to the documentation of this file.
48 exprt &new_expr)
const
52 if(expr.
type().
id() == ID_code)
56 expr.
type().
id() == ID_struct &&
64 new_expr.
remove(ID_C_lvalue);
79 exprt &new_expr)
const
81 assert(expr.
type().
id()==ID_array);
85 index.
set(ID_C_lvalue,
true);
118 exprt &new_expr)
const
120 if(expr.
type().
id()!=ID_pointer ||
127 if(expr.
type()!=type)
134 while(sub_from.
id()==ID_pointer)
145 if(qual_from!=qual_to && !const_to)
161 new_expr.
type()=type;
195 exprt &new_expr)
const
204 qual_from.
write(int_type);
206 if(expr.
type().
id()==ID_signedbv)
215 if(expr.
type().
id()==ID_unsignedbv)
224 if(expr.
type().
id() == ID_bool || expr.
type().
id() == ID_c_bool)
230 if(expr.
type().
id()==ID_c_enum_tag)
248 exprt &new_expr)
const
303 exprt &new_expr)
const
305 if(type.
id()!=ID_signedbv &&
306 type.
id()!=ID_unsignedbv)
310 expr.
type().
id() != ID_signedbv && expr.
type().
id() != ID_unsignedbv &&
311 expr.
type().
id() != ID_c_bool && expr.
type().
id() != ID_bool &&
312 expr.
type().
id() != ID_c_enum_tag)
350 exprt &new_expr)
const
355 if(expr.
type().
id()==ID_floatbv ||
356 expr.
type().
id()==ID_fixedbv)
358 if(type.
id()!=ID_signedbv &&
359 type.
id()!=ID_unsignedbv)
362 else if(expr.
type().
id()==ID_signedbv ||
363 expr.
type().
id()==ID_unsignedbv ||
364 expr.
type().
id()==ID_c_enum_tag)
366 if(type.
id()!=ID_fixedbv &&
367 type.
id()!=ID_floatbv)
401 exprt &new_expr)
const
403 if(expr.
type().
id()!=ID_floatbv &&
404 expr.
type().
id()!=ID_fixedbv)
407 if(type.
id()!=ID_floatbv &&
408 type.
id()!=ID_fixedbv)
460 if(type.
id()!=ID_pointer ||
469 expr.
type().
id()!=ID_pointer)
472 new_expr.
set(ID_value, ID_NULL);
473 new_expr.
type()=type;
481 expr.
type().
id() != ID_pointer ||
491 if(sub_from.
id()==ID_nullptr)
495 if(sub_from.
id()!=ID_code && sub_to.
id()==ID_empty)
505 if(sub_from.
id()==ID_struct && sub_to.
id()==ID_struct)
642 expr.
type().
id() != ID_signedbv && expr.
type().
id() != ID_unsignedbv &&
643 expr.
type().
id() != ID_pointer && expr.
type().
id() != ID_bool &&
644 expr.
type().
id() != ID_c_enum_tag)
653 qual_from.
write(Bool);
687 exprt curr_expr=expr;
690 if(type.
id()==ID_c_bit_field)
695 if(curr_expr.
type().
id()==ID_c_bit_field)
699 if(curr_expr.
type().
id()==ID_array)
701 if(type.
id()==ID_pointer)
707 else if(curr_expr.
type().
id()==ID_code &&
708 type.
id()==ID_pointer)
713 else if(curr_expr.
get_bool(ID_C_lvalue))
721 curr_expr.
swap(new_expr);
725 if(
follow(type).
id()==ID_c_enum &&
728 if(
follow(type).find(ID_tag)==
741 curr_expr.
type().
get(ID_C_c_type)!=type.
get(ID_C_c_type))
743 if(type.
id()==ID_signedbv ||
744 type.
id()==ID_unsignedbv ||
745 follow(type).
id()==ID_c_enum)
748 new_expr.
type() != type)
753 curr_expr, type, new_expr))
762 else if(type.
id()==ID_floatbv || type.
id()==ID_fixedbv)
765 new_expr.
type() != type)
768 curr_expr, type, new_expr) &&
770 curr_expr, type, new_expr))
778 else if(type.
id()==ID_pointer)
781 expr.
type().
id() == ID_pointer &&
795 else if(type.
id() == ID_c_bool)
802 else if(type.
id() == ID_bool)
814 curr_expr.
swap(new_expr);
816 if(curr_expr.
type().
id()==ID_pointer)
824 sub_from.
swap(tmp_from);
829 qual_from.
read(sub_from);
832 qual_to.
read(sub_to);
834 if(qual_from!=qual_to)
840 while(sub_from.
id()==ID_pointer);
848 new_expr.
type()=type;
882 if(to.
id()==ID_struct)
888 if(from.
id()==ID_struct)
901 if(expr.
id()==ID_dereference)
916 tmp_object_expr.
set(ID_C_lvalue,
true);
917 tmp_object_expr.
set(ID_mode, ID_cpp);
919 new_expr.
swap(tmp_object_expr);
938 if(comp_type.
id() !=ID_code)
948 if(parameters.size() != 2)
951 exprt curr_arg1 = parameters[1];
961 if(arg1_type.
id() != ID_struct_tag)
965 expr, arg1_type, tmp_expr, tmp_rank))
973 tmp_expr.
set(ID_C_lvalue,
true);
978 func_symb.
type()=comp_type;
983 std::move(func_symb),
989 new_expr.
swap(ctor_expr);
990 assert(new_expr.
get(ID_statement)==ID_temporary_object);
993 new_expr.
type().
set(ID_C_constant,
true);
998 else if(from.
id() == ID_struct && arg1_type.
id() == ID_struct_tag)
1007 expr_pfrom, pto, expr_ptmp, tmp_rank))
1018 expr_deref.
set(ID_C_lvalue,
true);
1021 exprt new_object(ID_new_object, type);
1022 new_object.
set(ID_C_lvalue,
true);
1023 new_object.
type().
set(ID_C_constant,
false);
1026 func_symb.
type()=comp_type;
1030 std::move(func_symb),
1036 new_expr.
swap(ctor_expr);
1039 new_expr.
get(ID_statement)==ID_temporary_object,
1043 new_expr.
type().
set(ID_C_constant,
true);
1053 if(from.
id()==ID_struct)
1061 if(!
component.get_bool(ID_is_cast_operator))
1066 comp_type.
parameters().size() == 1,
"expected exactly one parameter");
1069 this_type.
set(ID_C_reference,
true);
1071 exprt this_expr(expr);
1072 this_type.
set(ID_C_this,
true);
1074 unsigned tmp_rank=0;
1078 this_expr, this_type, tmp_expr, tmp_rank))
1084 exprt member_func(ID_member);
1085 member_func.
add(ID_component_cpp_name)=cpp_func_name;
1089 std::move(member_func),
1103 new_expr.
swap(tmp_expr);
1120 const typet &type)
const
1129 if(from.
get(ID_C_c_type)!=to.
get(ID_C_c_type))
1135 if(from.
id()==ID_struct &&
1141 from.
id() == ID_struct && type.
get_bool(ID_C_this) &&
1158 unsigned &rank)
const
1175 if(qual_from!=qual_to)
1227 unsigned backup_rank=rank;
1233 if(expr.
get(ID_statement)==ID_temporary_object)
1234 expr.
set(ID_C_lvalue,
true);
1235 else if(expr.
get(ID_statement)==ID_function_call)
1236 expr.
set(ID_C_lvalue,
true);
1237 else if(expr.
get_bool(ID_C_temporary_avoided))
1239 expr.
remove(ID_C_temporary_avoided);
1242 expr.
swap(temporary);
1243 expr.
set(ID_C_lvalue,
true);
1262 tmp.
set(ID_mode, ID_cpp);
1295 if(!
component.get_bool(ID_is_cast_operator))
1304 assert(component_type.
parameters().size()==1);
1308 this_type.
set(ID_C_reference,
true);
1310 exprt this_expr(expr);
1312 this_type.
set(ID_C_this,
true);
1314 unsigned tmp_rank=0;
1318 this_expr, this_type, tmp_expr, tmp_rank))
1324 exprt member_func(ID_member);
1325 member_func.
add(ID_component_cpp_name)=cpp_func_name;
1329 std::move(member_func),
1336 exprt returned_value=func_expr;
1339 if(returned_value.
get_bool(ID_C_lvalue) &&
1345 "the returned value must be pointer to reference");
1352 qual_from.
read(returned_value.
type());
1378 exprt arg_expr=expr;
1380 if(arg_expr.
type().
id() == ID_struct_tag)
1383 arg_expr.
set(ID_C_lvalue,
true);
1402 ID_temporary_object,
1405 tmp.
set(ID_mode, ID_cpp);
1412 tmp.
type().
set(ID_C_reference,
true);
1434 unsigned backup_rank=rank;
1447 new_expr.
type().
set(ID_C_reference,
true);
1512 str <<
"\n " << type.
pretty() <<
'\n';
1571 expr.
swap(new_expr);
1576 error() <<
"bad reference initializer" <<
eom;
1582 const typet &t2)
const
1584 assert(t1.
id()==ID_pointer && t2.
id()==ID_pointer);
1589 nt1.
remove(ID_C_reference);
1590 nt1.
remove(ID_to_member);
1593 nt2.
remove(ID_C_reference);
1594 nt2.
remove(ID_to_member);
1597 std::vector<typet> snt1;
1598 snt1.push_back(nt1);
1600 while(snt1.back().has_subtype())
1602 snt1.reserve(snt1.size()+1);
1607 q1.
read(snt1.back());
1613 std::vector<typet> snt2;
1614 snt2.push_back(nt2);
1615 while(snt2.back().has_subtype())
1617 snt2.reserve(snt2.size()+1);
1622 q2.
read(snt2.back());
1628 const std::size_t k=snt1.size() < snt2.size() ? snt1.size() : snt2.size();
1630 for(std::size_t i=k; i > 1; i--)
1633 snt1[snt1.size() - 1];
1637 snt2[snt2.size() - 1];
1641 exprt e1(
"Dummy", snt1.back());
1654 exprt curr_expr=expr;
1656 if(curr_expr.
type().
id()==ID_array)
1658 if(type.
id()==ID_pointer)
1664 else if(curr_expr.
type().
id()==ID_code &&
1665 type.
id()==ID_pointer)
1670 else if(curr_expr.
get_bool(ID_C_lvalue))
1688 new_expr=address_of;
1691 else if(type.
id()==ID_pointer)
1693 if(type!=new_expr.
type())
1698 new_expr.
swap(typecast_expr);
1712 if(type.
id()==ID_pointer)
1714 if(e.
id()==ID_dereference && e.
get_bool(ID_C_implicit))
1717 if(e.
type().
id()==ID_pointer &&
1729 else if(type.
id()==ID_pointer)
1761 bool check_constantness)
1765 if(check_constantness && type.
id()==ID_pointer)
1767 if(e.
id()==ID_dereference && e.
get_bool(ID_C_implicit))
1770 if(e.
type().
id()==ID_pointer &&
1789 if(e.
type().
id()==ID_array)
1806 if(e.
type().
id()==ID_pointer &&
1807 (type.
id()==ID_unsignedbv || type.
id()==ID_signedbv))
1815 (e.
type().
id() == ID_unsignedbv || e.
type().
id() == ID_signedbv ||
1816 e.
type().
id() == ID_c_bool || e.
type().
id() == ID_bool) &&
1824 new_expr.
set(ID_value, ID_NULL);
1825 new_expr.
type()=type;
1834 if(e.
type().
id()==ID_pointer &&
1835 type.
id()==ID_pointer &&
1857 bool check_constantness)
1861 if(check_constantness && type.
id()==ID_pointer)
1863 if(e.
id()==ID_dereference && e.
get_bool(ID_C_implicit))
1866 if(e.
type().
id()==ID_pointer &&
1882 if(subto.
id()==ID_struct && from.
id()==ID_struct)
1901 if(e.
id()==ID_dereference)
1910 new_expr.
swap(address_of);
1917 if(type.
id()==ID_empty)
1924 if(type.
id()==ID_c_enum_tag &&
1925 (e.
type().
id()==ID_signedbv ||
1926 e.
type().
id()==ID_unsignedbv ||
1927 e.
type().
id()==ID_c_enum_tag))
1930 new_expr.
remove(ID_C_lvalue);
1944 new_expr.
swap(temporary);
1949 new_expr.
set(ID_C_temporary_avoided,
true);
1951 new_expr.
remove(ID_C_lvalue);
1957 if(type.
id()==ID_pointer && e.
type().
id()==ID_pointer)
1964 if(from.
id()==ID_empty)
1970 if(to.
id()==ID_struct && from.
id()==ID_struct)
2027 new_expr.
type().
add(ID_to_member) = from_struct;
virtual void read(const typet &src) override
void copy_to_operands(const exprt &expr)
Copy the given argument to the end of exprt's operands.
#define UNREACHABLE
This should be used to mark dead code.
const union_typet & to_union_type(const typet &type)
Cast a typet to a union_typet.
const unsignedbv_typet & to_unsignedbv_type(const typet &type)
Cast a typet to an unsignedbv_typet.
static exprt conditional_cast(const exprt &expr, const typet &type)
const unary_exprt & to_unary_expr(const exprt &expr)
Cast an exprt to a unary_exprt.
bool standard_conversion_floating_point_promotion(const exprt &expr, exprt &new_expr) const
Floating-point-promotion conversion.
bool standard_conversion_boolean(const exprt &expr, exprt &new_expr) const
Boolean conversion.
const struct_typet & to_struct_type(const typet &type)
Cast a typet to a struct_typet.
const dereference_exprt & to_dereference_expr(const exprt &expr)
Cast an exprt to a dereference_exprt.
bool reference_binding(exprt expr, const typet &type, exprt &new_expr, unsigned &rank)
Reference binding.
The type of an expression, extends irept.
void show_instantiation_stack(std::ostream &)
std::string pretty(unsigned indent=0, unsigned max_indent=0) const
const floatbv_typet & to_floatbv_type(const typet &type)
Cast a typet to a floatbv_typet.
bool reinterpret_typecast(const exprt &expr, const typet &type, exprt &new_expr, bool check_constantness=true)
const irept & find(const irep_idt &name) const
Operator to dereference a pointer.
A side_effect_exprt representation of a function call side effect.
bool standard_conversion_integral_promotion(const exprt &expr, exprt &new_expr) const
Integral-promotion conversion.
void new_temporary(const source_locationt &source_location, const typet &, const exprt::operandst &ops, exprt &temporary)
bool standard_conversion_lvalue_to_rvalue(const exprt &expr, exprt &new_expr) const
Lvalue-to-rvalue conversion.
const type_with_subtypet & to_type_with_subtype(const typet &type)
bool standard_conversion_sequence(const exprt &expr, const typet &type, exprt &new_expr, unsigned &rank)
Standard Conversion Sequence.
Base class for all expressions.
std::string from_type(const namespacet &ns, const irep_idt &identifier, const typet &type)
auto component(T &struct_expr, const irep_idt &name, const namespacet &ns) -> decltype(struct_expr.op0())
bool reference_compatible(const exprt &expr, const typet &type, unsigned &rank) const
Reference-compatible.
struct configt::ansi_ct ansi_c
virtual bool is_subset_of(const qualifierst &other) const override
bool standard_conversion_array_to_pointer(const exprt &expr, exprt &new_expr) const
Array-to-pointer conversion.
const irep_idt & get(const irep_idt &name) const
bool cpp_is_pod(const typet &type) const
typet & type()
Return the type of the expression.
bool lookup(const irep_idt &name, const symbolt *&symbol) const override
See documentation for namespace_baset::lookup().
bool standard_conversion_floating_point_conversion(const exprt &expr, const typet &type, exprt &new_expr) const
Floating-point conversion.
const code_typet & to_code_type(const typet &type)
Cast a typet to a code_typet.
void typecheck_side_effect_function_call(side_effect_expr_function_callt &) override
signedbv_typet signed_int_type()
static void make_already_typechecked(exprt &expr)
#define DATA_INVARIANT(CONDITION, REASON)
This condition should be used to document that assumptions that are made on goto_functions,...
void add_implicit_dereference(exprt &)
source_locationt source_location
void reference_initializer(exprt &expr, const typet &type)
A reference to type "cv1 T1" is initialized by an expression of type "cv2 T2" as follows:
void set(const irep_idt &name, const irep_idt &value)
#define PRECONDITION(CONDITION)
const source_locationt & find_source_location() const
Get a source_locationt from the expression or from its operands (non-recursively).
symbol_exprt cpp_symbol_expr(const symbolt &symbol)
virtual void write(typet &src) const override
floatbv_typet float_type()
bool simplify(exprt &expr, const namespacet &ns)
void make_ptr_typecast(exprt &expr, const typet &dest_type)
const pointer_typet & to_pointer_type(const typet &type)
Cast a typet to a pointer_typet.
exprt simplify_expr(exprt src, const namespacet &ns)
const reference_typet & to_reference_type(const typet &type)
Cast a typet to a reference_typet.
pointer_typet pointer_type(const typet &subtype)
bool subtype_typecast(const struct_typet &from, const struct_typet &to) const
const irep_idt & id() const
bool standard_conversion_function_to_pointer(const exprt &expr, exprt &new_expr) const
Function-to-pointer conversion.
const parameterst & parameters() const
bool standard_conversion_pointer_to_member(const exprt &expr, const typet &type, exprt &new_expr)
Pointer-to-member conversion.
bool static_typecast(const exprt &expr, const typet &type, exprt &new_expr, bool check_constantness=true)
bool standard_conversion_integral_conversion(const exprt &expr, const typet &type, exprt &new_expr) const
Integral conversion.
floatbv_typet double_type()
const typet & underlying_type() const
const signedbv_typet & to_signedbv_type(const typet &type)
Cast a typet to a signedbv_typet.
std::size_t get_width() const
bool user_defined_conversion_sequence(const exprt &expr, const typet &type, exprt &new_expr, unsigned &rank)
User-defined conversion sequence.
bool reference_related(const exprt &expr, const typet &type) const
Reference-related.
reference_typet reference_type(const typet &subtype)
const c_bit_field_typet & to_c_bit_field_type(const typet &type)
Cast a typet to a c_bit_field_typet.
Deprecated expression utility functions.
bool standard_conversion_qualification(const exprt &expr, const typet &, exprt &new_expr) const
Qualification conversion.
bool is_reference(const typet &type)
Returns true if the type is a reference.
Structure type, corresponds to C style structs.
irept & add(const irep_idt &name)
bool const_typecast(const exprt &expr, const typet &type, exprt &new_expr)
const typet & follow(const typet &) const
Resolve type symbol to the type it points to.
exprt is_not_zero(const exprt &src, const namespacet &ns)
converts a scalar/float expression to C/C++ Booleans
bool cast_away_constness(const typet &t1, const typet &t2) const
const typet & base_type() const
The type of the data what we point to.
void implicit_typecast(exprt &expr, const typet &type) override
bool standard_conversion_pointer(const exprt &expr, const typet &type, exprt &new_expr)
Pointer conversion.
void add_to_operands(const exprt &expr)
Add the given argument to the end of exprt's operands.
const typet & subtype() const
const typet & return_type() const
bool standard_conversion_floating_integral_conversion(const exprt &expr, const typet &type, exprt &new_expr) const
Floating-integral conversion.
bool implicit_conversion_sequence(const exprt &expr, const typet &type, exprt &new_expr, unsigned &rank)
implicit conversion sequence
bool dynamic_typecast(const exprt &expr, const typet &type, exprt &new_expr)
std::string to_string(const typet &) override
bool is_null_pointer(const constant_exprt &expr)
Returns true if expr has a pointer type and a value NULL; it also returns true when expr has value ze...
void remove(const irep_idt &name)
Operator to return the address of an object.
source_locationt & add_source_location()
Semantic type conversion.
The pointer type These are both 'bitvector_typet' (they have a width) and 'type_with_subtypet' (they ...
bitvector_typet c_index_type()
const multi_ary_exprt & to_multi_ary_expr(const exprt &expr)
Cast an exprt to a multi_ary_exprt.
const source_locationt & source_location() const
bool is_incomplete() const
A struct/union may be incomplete.
bool get_bool(const irep_idt &name) const
An expression containing a side effect.
const constant_exprt & to_constant_expr(const exprt &expr)
Cast an exprt to a constant_exprt.