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 ||
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 &&
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),
990 new_expr.
swap(ctor_expr);
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))
1305 component_type.
parameters().size() == 1,
"exactly one parameter");
1309 this_type.
set(ID_C_reference,
true);
1311 exprt this_expr(expr);
1313 this_type.
set(ID_C_this,
true);
1315 unsigned tmp_rank=0;
1319 this_expr, this_type, tmp_expr, tmp_rank))
1325 exprt member_func(ID_member);
1326 member_func.
add(ID_component_cpp_name)=cpp_func_name;
1330 std::move(member_func),
1337 exprt returned_value=func_expr;
1340 if(returned_value.
get_bool(ID_C_lvalue) &&
1346 "the returned value must be pointer to reference");
1353 qual_from.
read(returned_value.
type());
1379 exprt arg_expr=expr;
1381 if(arg_expr.
type().
id() == ID_struct_tag)
1384 arg_expr.
set(ID_C_lvalue,
true);
1403 ID_temporary_object,
1406 tmp.
set(ID_mode, ID_cpp);
1413 tmp.
type().
set(ID_C_reference,
true);
1435 unsigned backup_rank=rank;
1448 new_expr.
type().
set(ID_C_reference,
true);
1457 type.
id() == ID_integer &&
1458 (expr.
type().
id() == ID_signedbv || expr.
type().
id() == ID_unsignedbv))
1467 (type.
id() == ID_signedbv || type.
id() == ID_unsignedbv) &&
1468 expr.
type().
id() == ID_integer)
1537 str <<
"\n " << type.
pretty() <<
'\n';
1596 expr.
swap(new_expr);
1601 error() <<
"bad reference initializer" <<
eom;
1607 const typet &t2)
const
1614 nt1.
remove(ID_C_reference);
1615 nt1.
remove(ID_to_member);
1618 nt2.
remove(ID_C_reference);
1619 nt2.
remove(ID_to_member);
1622 std::vector<typet> snt1;
1623 snt1.push_back(nt1);
1625 while(snt1.back().has_subtype())
1627 snt1.reserve(snt1.size()+1);
1632 q1.
read(snt1.back());
1638 std::vector<typet> snt2;
1639 snt2.push_back(nt2);
1640 while(snt2.back().has_subtype())
1642 snt2.reserve(snt2.size()+1);
1647 q2.
read(snt2.back());
1653 const std::size_t k=snt1.size() < snt2.size() ? snt1.size() : snt2.size();
1655 for(std::size_t i=k; i > 1; i--)
1658 snt1[snt1.size() - 1];
1662 snt2[snt2.size() - 1];
1666 exprt e1(
"Dummy", snt1.back());
1679 exprt curr_expr=expr;
1681 if(curr_expr.
type().
id()==ID_array)
1683 if(type.
id()==ID_pointer)
1689 else if(curr_expr.
type().
id()==ID_code &&
1690 type.
id()==ID_pointer)
1695 else if(curr_expr.
get_bool(ID_C_lvalue))
1713 new_expr=address_of;
1716 else if(type.
id()==ID_pointer)
1718 if(type!=new_expr.
type())
1723 new_expr.
swap(typecast_expr);
1737 if(type.
id()==ID_pointer)
1739 if(e.
id()==ID_dereference && e.
get_bool(ID_C_implicit))
1742 if(e.
type().
id()==ID_pointer &&
1754 else if(type.
id()==ID_pointer)
1786 bool check_constantness)
1790 if(check_constantness && type.
id()==ID_pointer)
1792 if(e.
id()==ID_dereference && e.
get_bool(ID_C_implicit))
1795 if(e.
type().
id()==ID_pointer &&
1814 if(e.
type().
id()==ID_array)
1831 if(e.
type().
id()==ID_pointer &&
1832 (type.
id()==ID_unsignedbv || type.
id()==ID_signedbv))
1840 (e.
type().
id() == ID_unsignedbv || e.
type().
id() == ID_signedbv ||
1849 new_expr.
set(ID_value, ID_NULL);
1850 new_expr.
type()=type;
1859 if(e.
type().
id()==ID_pointer &&
1860 type.
id()==ID_pointer &&
1882 bool check_constantness)
1886 if(check_constantness && type.
id()==ID_pointer)
1888 if(e.
id()==ID_dereference && e.
get_bool(ID_C_implicit))
1891 if(e.
type().
id()==ID_pointer &&
1907 if(subto.
id()==ID_struct && from.
id()==ID_struct)
1926 if(e.
id()==ID_dereference)
1935 new_expr.
swap(address_of);
1942 if(type.
id()==ID_empty)
1949 if(type.
id()==ID_c_enum_tag &&
1950 (e.
type().
id()==ID_signedbv ||
1951 e.
type().
id()==ID_unsignedbv ||
1952 e.
type().
id()==ID_c_enum_tag))
1955 new_expr.
remove(ID_C_lvalue);
1969 new_expr.
swap(temporary);
1974 new_expr.
set(ID_C_temporary_avoided,
true);
1976 new_expr.
remove(ID_C_lvalue);
1982 if(type.
id()==ID_pointer && e.
type().
id()==ID_pointer)
1989 if(from.
id()==ID_empty)
1995 if(to.
id()==ID_struct && from.
id()==ID_struct)
2052 new_expr.
type().
add(ID_to_member) = from_struct;
const floatbv_typet & to_floatbv_type(const typet &type)
Cast a typet to a floatbv_typet.
const unsignedbv_typet & to_unsignedbv_type(const typet &type)
Cast a typet to an unsignedbv_typet.
const signedbv_typet & to_signedbv_type(const typet &type)
Cast a typet to a signedbv_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 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 override
virtual void read(const typet &src) override
virtual bool is_subset_of(const qualifierst &other) const override
const parameterst & parameters() const
const typet & return_type() const
struct configt::ansi_ct ansi_c
bool implicit_conversion_sequence(const exprt &expr, const typet &type, exprt &new_expr, unsigned &rank)
implicit conversion sequence
bool reference_compatible(const exprt &expr, const typet &type, unsigned &rank) const
Reference-compatible.
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 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
bool standard_conversion_integral_promotion(const exprt &expr, exprt &new_expr) const
Integral-promotion conversion.
std::string to_string(const typet &) override
void make_ptr_typecast(exprt &expr, const typet &dest_type)
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 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 typet &type, exprt &new_expr, unsigned &rank)
Reference binding.
bool reference_related(const exprt &expr, const typet &type) const
Reference-related.
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.
bool is_boolean() const
Return whether the expression represents a Boolean.
bool is_constant() const
Return whether the expression is a constant.
typet & type()
Return the type of the expression.
const source_locationt & source_location() const
source_locationt & add_source_location()
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 typet & follow(const typet &) const
Resolve type symbol to the type it points to.
bool lookup(const irep_idt &name, const symbolt *&symbol) const override
See documentation for namespace_baset::lookup().
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.
Structure type, corresponds to C style structs.
const componentst & components() const
bool is_incomplete() const
A struct/union may be incomplete.
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.
std::string from_type(const namespacet &ns, const irep_idt &identifier, const typet &type)
API to expression classes for Pointers.
bool is_reference(const typet &type)
Returns true if the type is a reference.
const reference_typet & to_reference_type(const typet &type)
Cast a typet to a reference_typet.
const pointer_typet & to_pointer_type(const typet &type)
Cast a typet to a pointer_typet.
const dereference_exprt & to_dereference_expr(const exprt &expr)
Cast an exprt to a dereference_exprt.
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)
#define INVARIANT(CONDITION, REASON)
This macro uses the wrapper function 'invariant_violated_string'.
auto component(T &struct_expr, const irep_idt &name, const namespacet &ns) -> decltype(struct_expr.op0())
API to expression classes.
const unary_exprt & to_unary_expr(const exprt &expr)
Cast an exprt to a unary_exprt.
const multi_ary_exprt & to_multi_ary_expr(const exprt &expr)
Cast an exprt to a multi_ary_exprt.
const constant_exprt & to_constant_expr(const exprt &expr)
Cast an exprt to a constant_exprt.
const code_typet & to_code_type(const typet &type)
Cast a typet to a code_typet.
const struct_typet & to_struct_type(const typet &type)
Cast a typet to a struct_typet.
const type_with_subtypet & to_type_with_subtype(const typet &type)