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
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)
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 &&
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 ||
492 if(sub_from.
id()==ID_nullptr)
496 if(sub_from.
id()!=ID_code && sub_to.
id()==ID_empty)
506 if(sub_from.
id() == ID_struct_tag && sub_to.
id() == ID_struct_tag)
613 static_cast<const typet &
>(expr.
type().
find(ID_to_member))));
643 expr.
type().
id() != ID_signedbv && expr.
type().
id() != ID_unsignedbv &&
645 expr.
type().
id() != ID_c_enum_tag)
654 qual_from.
write(Bool);
688 exprt curr_expr=expr;
691 if(type.
id()==ID_c_bit_field)
696 if(curr_expr.
type().
id()==ID_c_bit_field)
700 if(curr_expr.
type().
id()==ID_array)
702 if(type.
id()==ID_pointer)
708 else if(curr_expr.
type().
id()==ID_code &&
709 type.
id()==ID_pointer)
714 else if(curr_expr.
get_bool(ID_C_lvalue))
722 curr_expr.
swap(new_expr);
726 if(type.
id() == ID_c_enum_tag && curr_expr.
type().
id() == ID_c_enum_tag)
744 curr_expr.
type() != type ||
745 curr_expr.
type().
get(ID_C_c_type) != type.
get(ID_C_c_type))
748 type.
id() == ID_signedbv || type.
id() == ID_unsignedbv ||
749 type.
id() == ID_c_enum_tag)
752 new_expr.
type() != type)
757 curr_expr, type, new_expr))
766 else if(type.
id()==ID_floatbv || type.
id()==ID_fixedbv)
769 new_expr.
type() != type)
772 curr_expr, type, new_expr) &&
774 curr_expr, type, new_expr))
782 else if(type.
id()==ID_pointer)
785 expr.
type().
id() == ID_pointer &&
799 else if(type.
id() == ID_c_bool)
806 else if(type.
id() == ID_bool)
818 curr_expr.
swap(new_expr);
820 if(curr_expr.
type().
id()==ID_pointer)
828 sub_from.
swap(tmp_from);
833 qual_from.
read(sub_from);
836 qual_to.
read(sub_to);
838 if(qual_from!=qual_to)
844 while(sub_from.
id()==ID_pointer);
852 new_expr.
type()=type;
885 if(to.
id() == ID_struct_tag)
891 if(from.
id() == ID_struct_tag)
904 if(expr.
id()==ID_dereference)
919 tmp_object_expr.
set(ID_C_lvalue,
true);
920 tmp_object_expr.
set(ID_mode, ID_cpp);
922 new_expr.
swap(tmp_object_expr);
932 for(
const auto &
component : struct_type_to.components())
942 if(comp_type.
id() !=ID_code)
952 if(parameters.size() != 2)
955 exprt curr_arg1 = parameters[1];
965 if(arg1_type.
id() != ID_struct_tag)
969 expr, arg1_type, tmp_expr, tmp_rank))
977 tmp_expr.
set(ID_C_lvalue,
true);
982 func_symb.
type()=comp_type;
987 std::move(func_symb),
994 new_expr.
swap(ctor_expr);
996 if(struct_type_to.get_bool(ID_C_constant))
997 new_expr.
type().
set(ID_C_constant,
true);
1002 else if(from.
id() == ID_struct_tag && arg1_type.
id() == ID_struct_tag)
1011 expr_pfrom, pto, expr_ptmp, tmp_rank))
1022 expr_deref.
set(ID_C_lvalue,
true);
1025 exprt new_object(ID_new_object, to);
1026 new_object.
set(ID_C_lvalue,
true);
1027 new_object.
type().
set(ID_C_constant,
false);
1030 func_symb.
type()=comp_type;
1034 std::move(func_symb),
1040 new_expr.
swap(ctor_expr);
1043 new_expr.
get(ID_statement)==ID_temporary_object,
1046 if(struct_type_to.get_bool(ID_C_constant))
1047 new_expr.
type().
set(ID_C_constant,
true);
1057 if(from.
id() == ID_struct_tag)
1066 if(!
component.get_bool(ID_is_cast_operator))
1071 comp_type.
parameters().size() == 1,
"expected exactly one parameter");
1074 this_type.
set(ID_C_reference,
true);
1076 exprt this_expr(expr);
1077 this_type.
set(ID_C_this,
true);
1079 unsigned tmp_rank=0;
1083 this_expr, this_type, tmp_expr, tmp_rank))
1089 exprt member_func(ID_member);
1090 member_func.
add(ID_component_cpp_name)=cpp_func_name;
1094 std::move(member_func),
1108 new_expr.
swap(tmp_expr);
1130 const typet &from_followed =
1131 from.
id() == ID_struct_tag
1133 : from.
id() == ID_union_tag
1137 const typet &to_followed =
1138 to.
id() == ID_struct_tag
1140 : to.
id() == ID_union_tag
1145 if(from_followed.
get(ID_C_c_type) != to_followed.
get(ID_C_c_type))
1151 if(from.
id() == ID_struct_tag && to.id() == ID_struct_tag)
1159 to.id() == ID_empty)
1175 unsigned &rank)
const
1191 if(qual_from!=qual_to)
1242 unsigned backup_rank=rank;
1247 if(expr.
get(ID_statement)==ID_temporary_object)
1248 expr.
set(ID_C_lvalue,
true);
1249 else if(expr.
get(ID_statement)==ID_function_call)
1250 expr.
set(ID_C_lvalue,
true);
1251 else if(expr.
get_bool(ID_C_temporary_avoided))
1253 expr.
remove(ID_C_temporary_avoided);
1256 expr.
swap(temporary);
1257 expr.
set(ID_C_lvalue,
true);
1273 ID_temporary_object,
1277 tmp.
set(ID_mode, ID_cpp);
1302 if(expr.
type().
id() == ID_struct_tag)
1310 if(!
component.get_bool(ID_is_cast_operator))
1320 component_type.
parameters().size() == 1,
"exactly one parameter");
1324 this_type.
set(ID_C_reference,
true);
1326 exprt this_expr(expr);
1328 this_type.
set(ID_C_this,
true);
1330 unsigned tmp_rank=0;
1334 this_expr, this_type, tmp_expr, tmp_rank))
1340 exprt member_func(ID_member);
1341 member_func.
add(ID_component_cpp_name)=cpp_func_name;
1345 std::move(member_func),
1352 exprt returned_value=func_expr;
1356 returned_value.
get_bool(ID_C_lvalue) &&
1362 "the returned value must be pointer to reference");
1369 qual_from.
read(returned_value.
type());
1395 exprt arg_expr=expr;
1397 if(arg_expr.
type().
id() == ID_struct_tag)
1400 arg_expr.
set(ID_C_lvalue,
true);
1419 ID_temporary_object,
1422 tmp.
set(ID_mode, ID_cpp);
1429 tmp.
type().
set(ID_C_reference,
true);
1451 unsigned backup_rank=rank;
1464 new_expr.
type().
set(ID_C_reference,
true);
1473 type.
id() == ID_integer &&
1474 (expr.
type().
id() == ID_signedbv || expr.
type().
id() == ID_unsignedbv))
1483 (type.
id() == ID_signedbv || type.
id() == ID_unsignedbv) &&
1484 expr.
type().
id() == ID_integer)
1553 str <<
"\n " << type.
pretty() <<
'\n';
1611 expr.
swap(new_expr);
1616 error() <<
"bad reference initializer" <<
eom;
1622 const typet &t2)
const
1629 nt1.
remove(ID_C_reference);
1630 nt1.
remove(ID_to_member);
1633 nt2.
remove(ID_C_reference);
1634 nt2.
remove(ID_to_member);
1637 std::vector<typet> snt1;
1638 snt1.push_back(nt1);
1640 while(snt1.back().has_subtype())
1642 snt1.reserve(snt1.size()+1);
1647 q1.
read(snt1.back());
1653 std::vector<typet> snt2;
1654 snt2.push_back(nt2);
1655 while(snt2.back().has_subtype())
1657 snt2.reserve(snt2.size()+1);
1662 q2.
read(snt2.back());
1668 const std::size_t k=snt1.size() < snt2.size() ? snt1.size() : snt2.size();
1670 for(std::size_t i=k; i > 1; i--)
1673 snt1[snt1.size() - 1];
1677 snt2[snt2.size() - 1];
1681 exprt e1(
"Dummy", snt1.back());
1694 exprt curr_expr=expr;
1696 if(curr_expr.
type().
id()==ID_array)
1698 if(type.
id()==ID_pointer)
1704 else if(curr_expr.
type().
id()==ID_code &&
1705 type.
id()==ID_pointer)
1710 else if(curr_expr.
get_bool(ID_C_lvalue))
1728 new_expr=address_of;
1731 else if(type.
id()==ID_pointer)
1733 if(type!=new_expr.
type())
1738 new_expr.
swap(typecast_expr);
1752 if(type.
id()==ID_pointer)
1754 if(e.
id()==ID_dereference && e.
get_bool(ID_C_implicit))
1757 if(e.
type().
id()==ID_pointer &&
1769 else if(type.
id()==ID_pointer)
1801 bool check_constantness)
1805 if(check_constantness && type.
id()==ID_pointer)
1807 if(e.
id()==ID_dereference && e.
get_bool(ID_C_implicit))
1810 if(e.
type().
id()==ID_pointer &&
1829 if(e.
type().
id()==ID_array)
1846 if(e.
type().
id()==ID_pointer &&
1847 (type.
id()==ID_unsignedbv || type.
id()==ID_signedbv))
1855 (e.
type().
id() == ID_unsignedbv || e.
type().
id() == ID_signedbv ||
1864 new_expr.
set(ID_value, ID_NULL);
1865 new_expr.
type()=type;
1874 if(e.
type().
id()==ID_pointer &&
1875 type.
id()==ID_pointer &&
1897 bool check_constantness)
1901 if(check_constantness && type.
id()==ID_pointer)
1903 if(e.
id()==ID_dereference && e.
get_bool(ID_C_implicit))
1906 if(e.
type().
id()==ID_pointer &&
1923 if(subto.
id() == ID_struct_tag && from.
id() == ID_struct_tag)
1932 qual_to.
read(subto);
1942 if(e.
id()==ID_dereference)
1951 new_expr.
swap(address_of);
1958 if(type.
id()==ID_empty)
1965 if(type.
id()==ID_c_enum_tag &&
1966 (e.
type().
id()==ID_signedbv ||
1967 e.
type().
id()==ID_unsignedbv ||
1968 e.
type().
id()==ID_c_enum_tag))
1971 new_expr.
remove(ID_C_lvalue);
1985 new_expr.
swap(temporary);
1990 new_expr.
set(ID_C_temporary_avoided,
true);
1992 new_expr.
remove(ID_C_lvalue);
1998 if(type.
id()==ID_pointer && e.
type().
id()==ID_pointer)
2006 if(from.
id()==ID_empty)
2012 if(to.
id() == ID_struct_tag && from.
id() == ID_struct_tag)
2044 static_cast<const typet &
>(type.
find(ID_to_member))));
2065 new_expr.
type().
add(ID_to_member) = from_struct_tag;
const floatbv_typet & to_floatbv_type(const typet &type)
Cast a typet to a floatbv_typet.
const signedbv_typet & to_signedbv_type(const typet &type)
Cast a typet to a signedbv_typet.
const unsignedbv_typet & to_unsignedbv_type(const typet &type)
Cast a typet to an unsignedbv_typet.
floatbv_typet float_type()
reference_typet reference_type(const typet &subtype)
signedbv_typet signed_int_type()
pointer_typet pointer_type(const typet &subtype)
bitvector_typet c_index_type()
floatbv_typet double_type()
const union_tag_typet & to_union_tag_type(const typet &type)
Cast a typet to a union_tag_typet.
const c_bit_field_typet & to_c_bit_field_type(const typet &type)
Cast a typet to a c_bit_field_typet.
const union_typet & to_union_type(const typet &type)
Cast a typet to a union_typet.
Operator to return the address of an object.
static void make_already_typechecked(exprt &expr)
std::size_t get_width() const
const typet & underlying_type() const
virtual void write(typet &src) const
virtual void read(const typet &src)
bool is_subset_of(const c_qualifierst &other) const
const typet & return_type() const
const parameterst & parameters() const
struct configt::ansi_ct ansi_c
bool reference_compatible(const exprt &expr, const reference_typet &type, unsigned &rank) const
Reference-compatible.
bool implicit_conversion_sequence(const exprt &expr, const typet &type, exprt &new_expr, unsigned &rank)
implicit conversion sequence
bool standard_conversion_floating_point_conversion(const exprt &expr, const typet &type, exprt &new_expr) const
Floating-point conversion.
bool reinterpret_typecast(const exprt &expr, const typet &type, exprt &new_expr, bool check_constantness=true)
bool standard_conversion_boolean(const exprt &expr, exprt &new_expr) const
Boolean conversion.
bool standard_conversion_pointer(const exprt &expr, const typet &type, exprt &new_expr)
Pointer conversion.
void implicit_typecast(exprt &expr, const typet &type) override
bool reference_related(const exprt &expr, const reference_typet &type) const
Reference-related.
bool standard_conversion_integral_conversion(const exprt &expr, const typet &type, exprt &new_expr) const
Integral conversion.
bool standard_conversion_sequence(const exprt &expr, const typet &type, exprt &new_expr, unsigned &rank)
Standard Conversion Sequence.
bool standard_conversion_qualification(const exprt &expr, const typet &, exprt &new_expr) const
Qualification conversion.
void typecheck_side_effect_function_call(side_effect_expr_function_callt &) override
bool cpp_is_pod(const typet &type) const
bool standard_conversion_floating_point_promotion(const exprt &expr, exprt &new_expr) const
Floating-point-promotion conversion.
bool standard_conversion_floating_integral_conversion(const exprt &expr, const typet &type, exprt &new_expr) const
Floating-integral conversion.
bool const_typecast(const exprt &expr, const typet &type, exprt &new_expr)
void new_temporary(const source_locationt &source_location, const typet &, const exprt::operandst &ops, exprt &temporary)
void show_instantiation_stack(std::ostream &)
bool standard_conversion_function_to_pointer(const exprt &expr, exprt &new_expr) const
Function-to-pointer conversion.
bool standard_conversion_array_to_pointer(const exprt &expr, exprt &new_expr) const
Array-to-pointer conversion.
bool dynamic_typecast(const exprt &expr, const typet &type, exprt &new_expr)
bool user_defined_conversion_sequence(const exprt &expr, const typet &type, exprt &new_expr, unsigned &rank)
User-defined conversion sequence.
bool standard_conversion_lvalue_to_rvalue(const exprt &expr, exprt &new_expr) const
Lvalue-to-rvalue conversion.
bool cast_away_constness(const typet &t1, const typet &t2) const
void add_implicit_dereference(exprt &)
bool static_typecast(const exprt &expr, const typet &type, exprt &new_expr, bool check_constantness=true)
bool subtype_typecast(const struct_typet &from, const struct_typet &to) const
void make_ptr_typecast(exprt &expr, const pointer_typet &dest_type)
bool standard_conversion_integral_promotion(const exprt &expr, exprt &new_expr) const
Integral-promotion conversion.
std::string to_string(const typet &) override
bool standard_conversion_pointer_to_member(const exprt &expr, const typet &type, exprt &new_expr)
Pointer-to-member conversion.
void reference_initializer(exprt &expr, const reference_typet &type)
A reference to type "cv1 T1" is initialized by an expression of type "cv2 T2" as follows:
bool reference_binding(exprt expr, const reference_typet &type, exprt &new_expr, unsigned &rank)
Reference binding.
Operator to dereference a pointer.
Base class for all expressions.
const source_locationt & find_source_location() const
Get a source_locationt from the expression or from its operands (non-recursively).
void copy_to_operands(const exprt &expr)
Copy the given argument to the end of exprt's operands.
source_locationt & add_source_location()
bool is_boolean() const
Return whether the expression represents a Boolean.
const source_locationt & source_location() const
typet & type()
Return the type of the expression.
bool is_constant() const
Return whether the expression is a constant.
void add_to_operands(const exprt &expr)
Add the given argument to the end of exprt's operands.
bool get_bool(const irep_idt &name) const
std::string pretty(unsigned indent=0, unsigned max_indent=0) const
const irept & find(const irep_idt &name) const
const irep_idt & get(const irep_idt &name) const
void remove(const irep_idt &name)
void set(const irep_idt &name, const irep_idt &value)
const irep_idt & id() const
irept & add(const irep_idt &name)
source_locationt source_location
const union_typet & follow_tag(const union_tag_typet &) const
Follow type tag of union type.
const symbolt & lookup(const irep_idt &name) const
Lookup a symbol in the namespace.
The pointer type These are both 'bitvector_typet' (they have a width) and 'type_with_subtypet' (they ...
const typet & base_type() const
The type of the data what we point to.
A side_effect_exprt representation of a function call side effect.
An expression containing a side effect.
A struct tag type, i.e., struct_typet with an identifier.
Structure type, corresponds to C style structs.
bool is_incomplete() const
A struct/union may be incomplete.
const componentst & components() const
const irep_idt & get_identifier() const
const typet & subtype() const
Semantic type conversion.
static exprt conditional_cast(const exprt &expr, const typet &type)
The type of an expression, extends irept.
C++ Language Type Checking.
symbol_exprt cpp_symbol_expr(const symbolt &symbol)
exprt is_not_zero(const exprt &src, const namespacet &ns)
converts a scalar/float expression to C/C++ Booleans
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...
Deprecated expression utility functions.
API to expression classes for Pointers.
bool is_reference(const typet &type)
Returns true if the type is a reference.
const dereference_exprt & to_dereference_expr(const exprt &expr)
Cast an exprt to a dereference_exprt.
const pointer_typet & to_pointer_type(const typet &type)
Cast a typet to a pointer_typet.
const reference_typet & to_reference_type(const typet &type)
Cast a typet to a reference_typet.
bool simplify(exprt &expr, const namespacet &ns)
exprt simplify_expr(exprt src, const namespacet &ns)
#define CHECK_RETURN(CONDITION)
#define UNREACHABLE
This should be used to mark dead code.
#define DATA_INVARIANT(CONDITION, REASON)
This condition should be used to document that assumptions that are made on goto_functions,...
#define PRECONDITION(CONDITION)
auto component(T &struct_expr, const irep_idt &name, const namespacet &ns) -> decltype(struct_expr.op0())
API to expression classes.
const constant_exprt & to_constant_expr(const exprt &expr)
Cast an exprt to a constant_exprt.
const multi_ary_exprt & to_multi_ary_expr(const exprt &expr)
Cast an exprt to a multi_ary_exprt.
const unary_exprt & to_unary_expr(const exprt &expr)
Cast an exprt to a unary_exprt.
const struct_typet & to_struct_type(const typet &type)
Cast a typet to a struct_typet.
const code_typet & to_code_type(const typet &type)
Cast a typet to a code_typet.
const struct_tag_typet & to_struct_tag_type(const typet &type)
Cast a typet to a struct_tag_typet.
const tag_typet & to_tag_type(const typet &type)
Cast a typet to a tag_typet.
const type_with_subtypet & to_type_with_subtype(const typet &type)