48 exprt &new_expr)
const 52 if(expr.
type().
id()==ID_code ||
53 expr.
type().
id()==ID_incomplete_struct ||
54 expr.
type().
id()==ID_incomplete_union)
58 new_expr.
remove(ID_C_lvalue);
73 exprt &new_expr)
const 75 assert(expr.
type().
id()==ID_array);
81 index.set(ID_C_lvalue,
true);
114 exprt &new_expr)
const 116 if(expr.
type().
id()!=ID_pointer ||
123 if(expr.
type()!=type)
130 while(sub_from.
id()==ID_pointer)
141 if(qual_from!=qual_to && !const_to)
157 new_expr.
type()=type;
191 exprt &new_expr)
const 200 qual_from.
write(int_type);
202 if(expr.
type().
id()==ID_signedbv)
212 if(expr.
type().
id()==ID_unsignedbv)
219 int_type.
id(ID_unsignedbv);
224 if(expr.
type().
id() == ID_bool || expr.
type().
id() == ID_c_bool)
231 if(expr.
type().
id()==ID_c_enum_tag)
250 exprt &new_expr)
const 306 exprt &new_expr)
const 308 if(type.
id()!=ID_signedbv &&
309 type.
id()!=ID_unsignedbv)
313 expr.
type().
id() != ID_signedbv && expr.
type().
id() != ID_unsignedbv &&
314 expr.
type().
id() != ID_c_bool && expr.
type().
id() != ID_bool &&
315 expr.
type().
id() != ID_c_enum_tag)
354 exprt &new_expr)
const 359 if(expr.
type().
id()==ID_floatbv ||
360 expr.
type().
id()==ID_fixedbv)
362 if(type.
id()!=ID_signedbv &&
363 type.
id()!=ID_unsignedbv)
366 else if(expr.
type().
id()==ID_signedbv ||
367 expr.
type().
id()==ID_unsignedbv ||
368 expr.
type().
id()==ID_c_enum_tag)
370 if(type.
id()!=ID_fixedbv &&
371 type.
id()!=ID_floatbv)
406 exprt &new_expr)
const 408 if(expr.
type().
id()!=ID_floatbv &&
409 expr.
type().
id()!=ID_fixedbv)
412 if(type.
id()!=ID_floatbv &&
413 type.
id()!=ID_fixedbv)
466 if(type.
id()!=ID_pointer ||
475 expr.
type().
id()!=ID_pointer)
478 new_expr.
set(ID_value, ID_NULL);
479 new_expr.
type()=type;
486 if(expr.
type().
id() != ID_pointer ||
494 if(sub_from.
id()==ID_nullptr)
498 if(sub_from.
id()!=ID_code && sub_to.id()==ID_empty)
509 if(sub_from.
id()==ID_struct && sub_to.id()==ID_struct)
562 if(type.
id()!=ID_pointer ||
567 if(expr.
type().
id() != ID_pointer ||
580 assert(this1.get(ID_C_base_name)==ID_this);
586 assert(this2.get(ID_C_base_name)==ID_this);
589 if(this2.type().subtype().get_bool(ID_C_constant) &&
590 !this1.type().subtype().get_bool(ID_C_constant))
604 if(expr.
id()==ID_constant &&
605 expr.
get(ID_value)==ID_NULL)
618 (type.
find(
"to-member"))));
646 expr.
type().
id() != ID_signedbv && expr.
type().
id() != ID_unsignedbv &&
647 expr.
type().
id() != ID_pointer && expr.
type().
id() != ID_bool &&
648 expr.
type().
id() != ID_c_enum_tag)
657 qual_from.
write(Bool);
692 exprt curr_expr=expr;
695 if(type.
id()==ID_c_bit_field)
699 if(curr_expr.type().id()==ID_c_bit_field)
700 curr_expr.make_typecast(curr_expr.type().subtype());
702 if(curr_expr.type().id()==ID_array)
704 if(type.
id()==ID_pointer)
710 else if(curr_expr.type().id()==ID_code &&
711 type.
id()==ID_pointer)
716 else if(curr_expr.get_bool(ID_C_lvalue))
724 curr_expr.
swap(new_expr);
728 if(
follow(type).
id()==ID_c_enum &&
729 follow(curr_expr.type()).
id()==ID_c_enum)
732 follow(curr_expr.type()).find(ID_tag))
744 curr_expr.type().
get(ID_C_c_type)!=type.
get(ID_C_c_type))
746 if(type.
id()==ID_signedbv ||
747 type.
id()==ID_unsignedbv ||
751 new_expr.
type() != type)
756 curr_expr, type, new_expr))
765 else if(type.
id()==ID_floatbv || type.
id()==ID_fixedbv)
768 new_expr.
type() != type)
771 curr_expr, type, new_expr) &&
773 curr_expr, type, new_expr))
781 else if(type.
id()==ID_pointer)
796 else if(type.
id() == ID_c_bool)
803 else if(type.
id() == ID_bool)
815 curr_expr.
swap(new_expr);
817 if(curr_expr.type().id()==ID_pointer)
819 typet sub_from=curr_expr.type();
825 sub_from.
swap(tmp_from);
830 qual_from.
read(sub_from);
833 qual_to.
read(sub_to);
835 if(qual_from!=qual_to)
841 while(sub_from.
id()==ID_pointer);
849 new_expr.
type()=type;
883 if(to.id()==ID_struct)
889 if(from.
id()==ID_struct)
902 if(expr.
id()==ID_dereference)
917 tmp_object_expr.set(ID_C_lvalue,
true);
919 new_expr.
swap(tmp_object_expr);
929 if(from.
id()==ID_struct)
944 if(comp_type.
id() !=ID_code)
954 if(parameters.size() != 2)
957 exprt curr_arg1 = parameters[1];
970 if(tmp.
id()==ID_struct)
979 expr, arg1_type, tmp_expr, tmp_rank))
987 tmp_expr.
set(ID_C_lvalue,
true);
992 func_symb.
type()=comp_type;
994 exprt tmp(ID_already_typechecked);
996 func_symb.
swap(func_symb);
1003 ctor_expr.
arguments().push_back(tmp_expr);
1006 new_expr.
swap(ctor_expr);
1007 assert(new_expr.
get(ID_statement)==ID_temporary_object);
1009 if(to.get_bool(ID_C_constant))
1010 new_expr.
type().
set(ID_C_constant,
true);
1024 expr_pfrom, pto, expr_ptmp, tmp_rank))
1035 expr_deref.
set(ID_C_lvalue,
true);
1038 exprt new_object(ID_new_object, type);
1039 new_object.
set(ID_C_lvalue,
true);
1040 new_object.
type().
set(ID_C_constant,
false);
1043 func_symb.
type()=comp_type;
1045 exprt tmp(ID_already_typechecked);
1047 func_symb.
swap(func_symb);
1053 ctor_expr.
arguments().push_back(expr_deref);
1056 new_expr.
swap(ctor_expr);
1059 new_expr.
get(ID_statement)==ID_temporary_object,
1062 if(to.get_bool(ID_C_constant))
1063 new_expr.
type().
set(ID_C_constant,
true);
1073 if(from.
id()==ID_struct)
1081 if(!
component.get_bool(ID_is_cast_operator))
1086 comp_type.
parameters().size() == 1,
"expected exactly one parameter");
1089 this_type.set(ID_C_reference,
true);
1091 exprt this_expr(expr);
1092 this_type.set(ID_C_this,
true);
1094 unsigned tmp_rank=0;
1098 this_expr, this_type, tmp_expr, tmp_rank))
1104 exprt member_func(ID_member);
1105 member_func.add(ID_component_cpp_name)=cpp_func_name;
1106 exprt ac(ID_already_typechecked);
1108 member_func.copy_to_operands(ac);
1123 new_expr.
swap(tmp_expr);
1140 const typet &type)
const 1149 if(from.
get(ID_C_c_type)!=to.get(ID_C_c_type))
1155 if(from.
id()==ID_struct &&
1160 if(from.
id()==ID_struct &&
1178 unsigned &rank)
const 1195 if(qual_from!=qual_to)
1247 unsigned backup_rank=rank;
1253 if(expr.
get(ID_statement)==ID_temporary_object)
1254 expr.
set(ID_C_lvalue,
true);
1255 else if(expr.
get(ID_statement)==ID_function_call)
1256 expr.
set(ID_C_lvalue,
true);
1257 else if(expr.
get_bool(ID_C_temporary_avoided))
1259 expr.
remove(ID_C_temporary_avoided);
1262 expr.
swap(temporary);
1263 expr.
set(ID_C_lvalue,
true);
1302 if(!
component.get_bool(ID_is_cast_operator))
1311 assert(component_type.
parameters().size()==1);
1315 this_type.set(ID_C_reference,
true);
1317 exprt this_expr(expr);
1319 this_type.set(ID_C_this,
true);
1321 unsigned tmp_rank=0;
1325 this_expr, this_type, tmp_expr, tmp_rank))
1331 exprt member_func(ID_member);
1332 member_func.add(ID_component_cpp_name)=cpp_func_name;
1333 exprt ac(ID_already_typechecked);
1335 member_func.copy_to_operands(ac);
1343 exprt returned_value=func_expr;
1346 if(returned_value.
get_bool(ID_C_lvalue) &&
1350 assert(returned_value.
id()==ID_dereference &&
1353 new_expr=returned_value.
op0();
1358 qual_from.
read(returned_value.
type());
1382 exprt arg_expr=expr;
1387 arg_expr.
set(ID_C_lvalue,
true);
1404 tmp.
set(ID_statement, ID_temporary_object);
1412 tmp.
type().
set(ID_C_reference,
true);
1434 unsigned backup_rank=rank;
1447 new_expr.
type().
set(ID_C_reference,
true);
1508 error() <<
"invalid implicit conversion from `" 1512 str <<
"\n " <<
follow(e.
type()).pretty() <<
'\n';
1513 str <<
"\n " << type.
pretty() <<
'\n';
1572 expr.
swap(new_expr);
1577 error() <<
"bad reference initializer" <<
eom;
1583 const typet &t2)
const 1585 assert(t1.
id()==ID_pointer && t2.
id()==ID_pointer);
1590 nt1.
remove(ID_C_reference);
1591 nt1.remove(
"to-member");
1594 nt2.
remove(ID_C_reference);
1598 std::vector<typet> snt1;
1599 snt1.push_back(nt1);
1601 while(snt1.back().has_subtype())
1603 snt1.reserve(snt1.size()+1);
1604 snt1.push_back(snt1.back().subtype());
1608 q1.
read(snt1.back());
1614 std::vector<typet> snt2;
1615 snt2.push_back(nt2);
1616 while(snt2.back().has_subtype())
1618 snt2.reserve(snt2.size()+1);
1619 snt2.push_back(snt2.back().subtype());
1623 q2.
read(snt2.back());
1629 const std::size_t k=snt1.size() < snt2.size() ? snt1.size() : snt2.size();
1631 for(std::size_t i=k; i > 1; i--)
1633 snt1[snt1.size()-2].subtype()=snt1[snt1.size()-1];
1636 snt2[snt2.size()-2].subtype()=snt2[snt2.size()-1];
1640 exprt e1(
"Dummy", snt1.back());
1653 exprt curr_expr=expr;
1655 if(curr_expr.
type().
id()==ID_array)
1657 if(type.
id()==ID_pointer)
1663 else if(curr_expr.
type().
id()==ID_code &&
1664 type.
id()==ID_pointer)
1669 else if(curr_expr.
get_bool(ID_C_lvalue))
1687 new_expr=address_of;
1690 else if(type.
id()==ID_pointer)
1692 if(type!=new_expr.
type())
1697 new_expr.
swap(typecast_expr);
1711 if(type.
id()==ID_pointer)
1713 if(e.
id()==ID_dereference && e.
get_bool(ID_C_implicit))
1716 if(e.
type().
id()==ID_pointer &&
1728 else if(type.
id()==ID_pointer)
1760 bool check_constantness)
1764 if(check_constantness && type.
id()==ID_pointer)
1766 if(e.
id()==ID_dereference && e.
get_bool(ID_C_implicit))
1769 if(e.
type().
id()==ID_pointer &&
1788 if(e.
type().
id()==ID_array)
1805 if(e.
type().
id()==ID_pointer &&
1806 (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;
1835 if(e.
type().
id()==ID_pointer &&
1836 type.
id()==ID_pointer &&
1861 bool check_constantness)
1865 if(check_constantness && type.
id()==ID_pointer)
1867 if(e.
id()==ID_dereference && e.
get_bool(ID_C_implicit))
1870 if(e.
type().
id()==ID_pointer &&
1886 if(subto.
id()==ID_struct && from.id()==ID_struct)
1905 if(e.
id()==ID_dereference)
1914 new_expr.
swap(address_of);
1921 if(type.
id()==ID_empty)
1929 if(type.
id()==ID_c_enum_tag &&
1930 (e.
type().
id()==ID_signedbv ||
1931 e.
type().
id()==ID_unsignedbv ||
1932 e.
type().
id()==ID_c_enum_tag))
1936 new_expr.
remove(ID_C_lvalue);
1944 exprt tc(ID_already_typechecked);
1948 new_expr.
swap(temporary);
1953 new_expr.
set(ID_C_temporary_avoided,
true);
1955 new_expr.
remove(ID_C_lvalue);
1961 if(type.
id()==ID_pointer && e.
type().
id()==ID_pointer)
1969 if(from.id()==ID_empty)
1976 if(to.
id()==ID_struct && from.id()==ID_struct)
2009 follow(static_cast<const typet&>(type.
find(
"to-member"))));
2029 new_expr.
type().
add(
"to-member") = from_struct;
The type of an expression, extends irept.
struct configt::ansi_ct ansi_c
Semantic type conversion.
bool reference_binding(exprt expr, const typet &type, exprt &new_expr, unsigned &rank)
Reference binding.
pointer_typet pointer_type(const typet &subtype)
void new_temporary(const source_locationt &source_location, const typet &, const exprt::operandst &ops, exprt &temporary)
bool standard_conversion_floating_point_conversion(const exprt &expr, const typet &type, exprt &new_expr) const
Floating-point conversion.
const signedbv_typet & to_signedbv_type(const typet &type)
Cast a typet to a signedbv_typet.
std::string pretty(unsigned indent=0, unsigned max_indent=0) const
exprt simplify_expr(const exprt &src, const namespacet &ns)
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.
Deprecated expression utility functions.
const code_typet & to_code_type(const typet &type)
Cast a typet to a code_typet.
void copy_to_operands(const exprt &expr)
Copy the given argument to the end of exprt's operands.
auto component(T &struct_expr, const irep_idt &name, const namespacet &ns) -> decltype(struct_expr.op0())
bool user_defined_conversion_sequence(const exprt &expr, const typet &type, exprt &new_expr, unsigned &rank)
User-defined conversion sequence.
void move_to_operands(exprt &expr)
Move the given argument to the end of exprt's operands.
bool standard_conversion_qualification(const exprt &expr, const typet &, exprt &new_expr) const
Qualification conversion.
bool standard_conversion_floating_point_promotion(const exprt &expr, exprt &new_expr) const
Floating-point-promotion conversion.
void show_instantiation_stack(std::ostream &)
const componentst & components() const
typet & type()
Return the type of the expression.
Structure type, corresponds to C style structs.
bool standard_conversion_function_to_pointer(const exprt &expr, exprt &new_expr) const
Function-to-pointer conversion.
bool get_bool(const irep_namet &name) const
bool cast_away_constness(const typet &t1, const typet &t2) const
bool standard_conversion_integral_promotion(const exprt &expr, exprt &new_expr) const
Integral-promotion conversion.
bool reference_compatible(const exprt &expr, const typet &type, unsigned &rank) const
Reference-compatible.
bool dynamic_typecast(const exprt &expr, const typet &type, exprt &new_expr)
bool standard_conversion_floating_integral_conversion(const exprt &expr, const typet &type, exprt &new_expr) const
Floating-integral conversion.
bool reference_related(const exprt &expr, const typet &type) const
Reference-related.
const irep_idt & id() const
exprt is_not_zero(const exprt &src, const namespacet &ns)
converts a scalar/float expression to C/C++ Booleans
reference_typet reference_type(const typet &subtype)
The pointer type These are both 'bitvector_typet' (they have a width) and 'type_with_subtypet' (they ...
const source_locationt & find_source_location() const
Get a source_locationt from the expression or from its operands (non-recursively).
source_locationt source_location
bool cpp_is_pod(const typet &type) const
Operator to dereference a pointer.
bool reinterpret_typecast(const exprt &expr, const typet &type, exprt &new_expr, bool check_constantness=true)
API to expression classes.
bool is_reference(const typet &type)
Returns true if the type is a reference.
void implicit_typecast(exprt &expr, const typet &type) override
const irep_idt & get(const irep_namet &name) const
virtual void read(const typet &src) override
#define PRECONDITION(CONDITION)
bool standard_conversion_pointer_to_member(const exprt &expr, const typet &type, exprt &new_expr)
Pointer-to-member conversion.
C++ Language Type Checking.
const typet & follow(const typet &) const
Resolve type symbol to the type it points to.
bitvector_typet index_type()
const struct_typet & to_struct_type(const typet &type)
Cast a typet to a struct_typet.
symbol_exprt cpp_symbol_expr(const symbolt &symbol)
Operator to return the address of an object.
std::string from_type(const namespacet &ns, const irep_idt &identifier, const typet &type)
void make_ptr_typecast(exprt &expr, const typet &dest_type)
const unsignedbv_typet & to_unsignedbv_type(const typet &type)
Cast a typet to an unsignedbv_typet.
A side_effect_exprt representation of a function call side effect.
bool const_typecast(const exprt &expr, const typet &type, exprt &new_expr)
floatbv_typet float_type()
bool subtype_typecast(const struct_typet &from, const struct_typet &to) const
bool standard_conversion_lvalue_to_rvalue(const exprt &expr, exprt &new_expr) const
Lvalue-to-rvalue conversion.
const floatbv_typet & to_floatbv_type(const typet &type)
Cast a typet to a floatbv_typet.
virtual bool is_subset_of(const qualifierst &other) const override
bool standard_conversion_sequence(const exprt &expr, const typet &type, exprt &new_expr, unsigned &rank)
Standard Conversion Sequence.
Base class for all expressions.
floatbv_typet double_type()
const parameterst & parameters() const
const source_locationt & source_location() const
#define UNREACHABLE
This should be used to mark dead code.
irept & add(const irep_namet &name)
exprt::operandst & arguments()
virtual void write(typet &src) const override
bool is_zero() const
Return whether the expression is a constant representing 0.
source_locationt & add_source_location()
bool standard_conversion_array_to_pointer(const exprt &expr, exprt &new_expr) const
Array-to-pointer conversion.
const pointer_typet & to_pointer_type(const typet &type)
Cast a typet to a pointer_typet.
bool standard_conversion_pointer(const exprt &expr, const typet &type, exprt &new_expr)
Pointer conversion.
signedbv_typet signed_int_type()
void remove(const irep_namet &name)
const typet & subtype() const
#define DATA_INVARIANT(CONDITION, REASON)
This condition should be used to document that assumptions that are made on goto_functions, goto_programs, exprts, etc.
An expression containing a side effect.
bool implicit_conversion_sequence(const exprt &expr, const typet &type, exprt &new_expr, unsigned &rank)
implicit conversion sequence
void typecheck_side_effect_function_call(side_effect_expr_function_callt &) override
std::string to_string(const typet &) override
void make_typecast(const typet &_type)
Create a typecast_exprt to the given type.
const irept & find(const irep_namet &name) const
const typet & return_type() const
bool lookup(const irep_idt &name, const symbolt *&symbol) const override
See documentation for namespace_baset::lookup().
void add_implicit_dereference(exprt &)
void set(const irep_namet &name, const irep_idt &value)
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 standard_conversion_boolean(const exprt &expr, exprt &new_expr) const
Boolean conversion.
bool simplify(exprt &expr, const namespacet &ns)