42 const irep_idt &
id = b.type().get_identifier();
43 if(
lookup(
id).base_name == base_name)
56 if(expr.
id()==ID_cpp_name)
58 else if(expr.
id()==
"cpp-this")
60 else if(expr.
id() == ID_pointer_to_member)
62 else if(expr.
id() == ID_new_object)
68 else if(expr.
id()==
"explicit-typecast")
70 else if(expr.
id()==
"explicit-constructor-call")
72 else if(expr.
id()==ID_code)
75 std::cerr <<
"E: " << expr.
pretty() <<
'\n';
76 std::cerr <<
"cpp_typecheckt::typecheck_expr_main got code\n";
80 else if(expr.
id()==ID_symbol)
84 std::cerr <<
"E: " << expr.
pretty() <<
'\n';
85 std::cerr <<
"cpp_typecheckt::typecheck_expr_main got symbol\n";
88 else if(expr.
id()==
"__is_base_of")
99 if(base.
id() != ID_struct_tag || deriv.
id() != ID_struct_tag)
113 else if(expr.
id()==ID_msc_uuidof)
118 expr.
set(ID_C_lvalue,
true);
120 else if(expr.
id()==ID_noexcept)
125 else if(expr.
id()==ID_initializer_list)
127 expr.
type().
id(ID_initializer_list);
148 error() <<
"lvalue to rvalue conversion" <<
eom;
159 error() <<
"array to pointer conversion" <<
eom;
170 error() <<
"function to pointer conversion" <<
eom;
181 error() <<
"lvalue to rvalue conversion" <<
eom;
192 error() <<
"array to pointer conversion" <<
eom;
203 error() <<
"function to pointer conversion" <<
eom;
208 if(expr.
op1().
get(ID_statement)==ID_throw &&
209 expr.
op2().
get(ID_statement)!=ID_throw)
211 else if(expr.
op2().
get(ID_statement)==ID_throw &&
212 expr.
op1().
get(ID_statement)!=ID_throw)
214 else if(expr.
op1().
type().
id()==ID_empty &&
220 error() <<
"bad types for operands" <<
eom;
275 error() <<
"types are incompatible.\n"
284 expr.
set(ID_C_lvalue,
true);
304 static_cast<const typet &
>(expr.
find(ID_type_arg));
306 if(type.
id()==ID_cpp_name)
318 if(symbol_expr.
id()!=ID_type)
324 else if(type.
id()==ID_array)
338 if(symbol_expr.
id()!=ID_type)
361 if(expr.
id()==ID_cpp_name)
363 else if(expr.
id()==ID_member)
368 else if(expr.
id()==ID_ptrmember)
376 std::string op_name=
"operator->";
384 {to_unary_expr(expr).op()},
408 for(
const auto &op : expr.
operands())
416 t.
id() == ID_struct || t.
id() == ID_union || t.
id() == ID_c_enum ||
417 t.
id() == ID_c_enum_tag || t.
id() == ID_struct_tag ||
418 t.
id() == ID_union_tag)
442 { ID_unary_minus,
"-" },
454 { ID_notequal,
"!=" },
455 { ID_dereference,
"*" },
456 { ID_ptrmember,
"->" },
467 else if(expr.
id()==ID_dereference &&
473 if(expr.
id()==
"explicit-typecast")
479 std::string op_name=std::string(
"operator")+
"("+
cpp_type2name(t)+
")";
485 bool found_in_struct=
false;
489 if(t0.
id() == ID_struct_tag)
493 if(!c.get_bool(ID_from_base) && c.get_base_name() == op_name)
495 found_in_struct=
true;
504 exprt member(ID_member);
505 member.
add(ID_component_cpp_name) = cpp_name;
516 for(exprt::operandst::const_iterator
518 it!=(expr).operands().end();
520 function_call.
arguments().push_back(*it);
525 if(expr.
id()==ID_ptrmember)
534 expr.
swap(function_call);
545 expr.
id() != ID_dereference || !expr.
get_bool(ID_C_implicit),
546 "no implicit dereference");
548 std::string op_name=std::string(
"operator")+e->op_name;
588 exprt member(ID_member);
589 member.
add(ID_component_cpp_name) = cpp_name;
604 for(exprt::operandst::const_iterator
608 function_call.
arguments().push_back(*it);
640 for(
const auto &op :
as_const(expr).operands())
645 if(expr.
id()==ID_ptrmember)
670 error() <<
"address_of expects one operand" <<
eom;
679 error() <<
"expr not an lvalue" <<
eom;
683 if(op.
type().
id() == ID_code)
689 address.
set(ID_C_implicit,
true);
693 if(op.
id() == ID_address_of && op.
get_bool(ID_C_implicit))
700 if(!args.empty() && args.front().get_this())
704 op.
type().
add(ID_to_member) = symbol;
706 if(code_type.
get_bool(ID_C_is_virtual))
709 error() <<
"pointers to virtual methods"
710 <<
" are currently not implemented" <<
eom;
715 else if(op.
id() == ID_ptrmember &&
to_unary_expr(op).op().
id() ==
"cpp-this")
741 if(exception_type.
id() == ID_empty)
744 error() <<
"cannot throw void" <<
eom;
749 expr.
set(ID_exception_list,
758 if(expr.
type().
id()==ID_array)
767 bool size_is_unsigned=(size.
type().
id()==ID_unsignedbv);
772 expr.
set(ID_statement, ID_cpp_new_array);
787 expr.
set(ID_statement, ID_cpp_new);
794 object_expr.
set(ID_C_lvalue,
true);
799 exprt &initializer=
static_cast<exprt &
>(expr.
add(ID_initializer));
802 if(!initializer.
operands().empty() &&
803 expr.
get(ID_statement)==ID_cpp_new_array)
807 error() <<
"new with array type must not use initializer" <<
eom;
815 expr.
add(ID_initializer).
swap(code.value());
824 if(size_of_opt.has_value())
826 auto &sizeof_expr =
static_cast<exprt &
>(expr.
add(ID_sizeof));
827 sizeof_expr = size_of_opt.value();
828 sizeof_expr.
add(ID_C_c_sizeof_type) =
837 if(src.
id()==ID_comma)
859 if(!new_expr.has_value())
880 if(expr.
type().
id()==ID_cpp_name)
891 if(symbol_expr.
id()==ID_type)
898 static_cast<const exprt &
>(
static_cast<const irept &
>(expr.
type())),
915 if(op.id() == ID_initializer_list)
924 exprt tmp(ID_compound_literal, expr.
type());
927 expr.
set(ID_C_lvalue,
true);
944 error() <<
"invalid explicit cast:\n"
945 <<
"operand type: '" <<
to_string(op.type()) <<
"'\n"
953 error() <<
"explicit typecast expects 0 or 1 operands" <<
eom;
964 expr.
id(
"explicit-typecast");
984 error() <<
"`this' is not allowed here" <<
eom;
1003 error() <<
"delete expects one operand" <<
eom;
1009 if(statement==ID_cpp_delete)
1012 else if(statement==ID_cpp_delete_array)
1023 error() <<
"delete takes a pointer type operand, but got '"
1039 new_object.
set(ID_C_lvalue,
true);
1045 if(destructor_code.has_value())
1049 expr.
set(ID_destructor, destructor_code.value());
1059 std::cout <<
"E: " << expr.pretty() <<
'\n';
1071 error() <<
"member operator expects one operand" <<
eom;
1086 op0.
type().
id() != ID_struct && op0.
type().
id() != ID_struct_tag)
1088 exprt tmp(ID_cpp_dummy_destructor);
1097 if(op0.
type().
id() != ID_struct_tag && op0.
type().
id() != ID_union_tag)
1100 error() <<
"member operator requires struct/union type "
1101 <<
"on left hand side but got '" <<
to_string(op0.
type()) <<
"'"
1107 op0.
type().
id() == ID_struct_tag
1116 error() <<
"member operator got incomplete type "
1117 <<
"on left hand side" <<
eom;
1141 if(symbol_expr.
id()==ID_dereference)
1145 symbol_expr.
swap(tmp);
1149 symbol_expr.
id() == ID_symbol || symbol_expr.
id() == ID_member ||
1151 "expression kind unexpected");
1157 if(symbol_expr.
id()==ID_symbol)
1160 symbol_expr.
type().
id() == ID_code &&
1164 error() <<
"member '"
1166 <<
"' is a constructor" <<
eom;
1178 error() <<
"'" << symbol_expr.
get(ID_identifier)
1179 <<
"' is not static member "
1194 const irep_idt component_name=symbol_expr.
get(ID_component_name);
1196 expr.
remove(ID_component_cpp_name);
1197 expr.
set(ID_component_name, component_name);
1200 const irep_idt &component_name=expr.
get(ID_component_name);
1201 INVARIANT(!component_name.
empty(),
"component name should not be empty");
1207 op0.
type().
id() == ID_struct || op0.
type().
id() == ID_union ||
1208 op0.
type().
id() == ID_struct_tag || op0.
type().
id() == ID_union_tag);
1220 error() <<
"member '" << component_name <<
"' of '" <<
to_string(type)
1221 <<
"' not found" <<
eom;
1227 if(expr.
type().
id()==ID_code)
1232 if(component_symbol.
value.
id() == ID_cpp_not_typechecked)
1233 component_symbol.
value.
set(ID_is_used,
true);
1246 error() <<
"ptrmember operator expects one operand" <<
eom;
1254 if(op.type().id() != ID_pointer)
1257 error() <<
"ptrmember operator requires pointer type "
1258 <<
"on left hand side, but got '" <<
to_string(op.type()) <<
"'"
1266 op.id(ID_dereference);
1267 op.add_to_operands(std::move(tmp));
1283 error() <<
"cast expressions expect one operand" <<
eom;
1293 f_op.
get_sub().front().get(ID_identifier);
1295 if(f_op.
get_sub().size()!=2 ||
1296 f_op.
get_sub()[1].id()!=ID_template_args)
1299 error() <<
id <<
" expects template argument" <<
eom;
1303 irept &template_arguments=f_op.
get_sub()[1].add(ID_arguments);
1305 if(template_arguments.
get_sub().size()!=1)
1308 error() <<
id <<
" expects one template argument" <<
eom;
1312 irept &template_arg=template_arguments.
get_sub().front();
1314 if(template_arg.
id() != ID_type && template_arg.
id() != ID_ambiguous)
1317 error() <<
id <<
" expects a type as template argument" <<
eom;
1322 template_arguments.
get_sub().front().add(ID_type));
1329 if(
id==ID_const_cast)
1334 error() <<
"type mismatch on const_cast:\n"
1340 else if(
id==ID_dynamic_cast)
1345 error() <<
"type mismatch on dynamic_cast:\n"
1351 else if(
id==ID_reinterpret_cast)
1356 error() <<
"type mismatch on reinterpret_cast:\n"
1362 else if(
id==ID_static_cast)
1367 error() <<
"type mismatch on static_cast:\n"
1376 expr.
swap(new_expr);
1386 if(expr.
get_sub().size()==1 &&
1387 expr.
get_sub()[0].id()==ID_name)
1393 identifier, fargs.
operands, source_location))
1395 expr = std::move(*gcc_polymorphic);
1400 for(std::size_t i=0; i<expr.
get_sub().size(); i++)
1402 if(expr.
get_sub()[i].id()==ID_cpp_name)
1409 typet name(ID_name);
1410 name.
set(ID_identifier, tmp);
1417 if(expr.
get_sub().size()>=1 &&
1418 expr.
get_sub().front().id()==ID_name)
1422 if(
id==ID_const_cast ||
1423 id==ID_dynamic_cast ||
1424 id==ID_reinterpret_cast ||
1427 expr.
id(ID_cast_expression);
1441 if(symbol_expr.
id()==ID_member)
1451 if(symbol_expr.
type().
id()!=ID_code)
1454 error() <<
"object missing" <<
eom;
1463 exprt ptrmem(ID_ptrmember);
1467 ptrmem.
add(ID_component_cpp_name)=expr;
1471 symbol_expr.
swap(ptrmem);
1480 if(expr.
id()==ID_symbol)
1492 tmp.
set(ID_C_implicit,
true);
1494 tmp.
set(ID_C_lvalue,
true);
1505 bool is_qualified=
false;
1510 if(expr.
function().
get(ID_component_cpp_name)==ID_cpp_name)
1529 if(expr.
function().
id() == ID_pod_constructor)
1541 exprt typecast(
"explicit-typecast");
1542 typecast.
type()=pod;
1547 expr.
swap(typecast);
1552 error() <<
"zero or one argument expected" <<
eom;
1558 else if(expr.
function().
id() == ID_cast_expression)
1566 else if(expr.
function().
id() == ID_cpp_dummy_destructor)
1580 const exprt &bound =
1586 error() <<
"pointer-to-member not bound" <<
eom;
1616 error() <<
"expecting code as argument" <<
eom;
1625 if(op0.
id()==ID_member || op0.
id()==ID_ptrmember)
1627 vtptr_member.
id(op0.
id());
1632 vtptr_member.
id(ID_ptrmember);
1633 exprt this_expr(
"cpp-this");
1641 this_type.base_type().get_string(ID_identifier) +
"::@vtable_pointer";
1651 vtptr_member.
set(ID_component_name, vtable_name);
1658 exprt vtentry_member(ID_ptrmember);
1660 vtentry_member.
set(ID_component_name, vtentry_component_name);
1668 vtentry_member.
swap(tmp);
1691 exprt member(ID_member);
1692 member.
add(ID_component_cpp_name)=cppname;
1704 error() <<
"function call expects function or function "
1705 <<
"pointer as argument, but got '"
1713 if(expr.
type().
id()==ID_constructor)
1725 expr.
type() = this_type.base_type();
1730 tmp_object_expr.
set(ID_C_lvalue,
true);
1731 tmp_object_expr.
set(ID_mode, ID_cpp);
1735 exprt new_object(ID_new_object, tmp_object_expr.
type());
1736 new_object.
set(ID_C_lvalue,
true);
1746 if(member.
get_bool(ID_C_not_accessible))
1749 tmp_object_expr.
set(ID_C_not_accessible,
true);
1750 tmp_object_expr.
set(ID_C_access, member.
get(ID_C_access));
1760 for(
const auto &c : components)
1762 const typet &type = c.type();
1765 !c.get_bool(ID_from_base) && type.
id() == ID_code &&
1780 tmp_object_expr.
add(ID_initializer)=new_code;
1781 expr.
swap(tmp_object_expr);
1799 !parameters.empty() && parameters.front().get_this() &&
1806 parameter.
type().
id() == ID_pointer,
1807 "`this' parameter should be a pointer");
1810 operand.
type().
id() != ID_pointer &&
1844 if(parameters.size()>expr.
arguments().size())
1848 for(; i<parameters.size(); i++)
1850 if(!parameters[i].has_default_value())
1853 const exprt &value=parameters[i].default_value();
1858 exprt::operandst::iterator arg_it=expr.
arguments().begin();
1859 for(
const auto ¶meter : parameters)
1861 if(parameter.get_bool(ID_C_call_by_value))
1865 if(arg_it->id()!=ID_temporary_object)
1871 arg_it->source_location(),
1875 arg_it->swap(temporary);
1890 if(statement==ID_cpp_new ||
1891 statement==ID_cpp_new_array)
1895 else if(statement==ID_cpp_delete ||
1896 statement==ID_cpp_delete_array)
1900 else if(statement==ID_preincrement ||
1901 statement==ID_predecrement ||
1902 statement==ID_postincrement ||
1903 statement==ID_postdecrement)
1907 else if(statement==ID_throw)
1911 else if(statement==ID_temporary_object)
1941 const irept &template_type = tag_symbol.
type.
find(ID_C_template);
1942 const irept &template_args = tag_symbol.
type.
find(ID_C_template_arguments);
1948 std::cout <<
"MAP for " << method_symbol <<
":\n";
1967 this_type.
set(ID_C_reference,
true);
1968 this_type.
set(ID_C_this,
true);
1980 "argument should be reference");
1981 expr.
arguments().front().type().remove(ID_C_reference);
1996 method_symbol.
value.
id() == ID_cpp_not_typechecked &&
1999 method_symbol.
value.
set(ID_is_used,
true);
2008 error() <<
"assignment side effect expected to have two operands"
2022 if(type0.
id() == ID_struct_tag)
2029 expr.
set(ID_C_lvalue,
true);
2036 std::string strop=
"operator";
2040 if(statement==ID_assign)
2042 else if(statement==ID_assign_shl)
2044 else if(statement==ID_assign_shr)
2046 else if(statement==ID_assign_plus)
2048 else if(statement==ID_assign_minus)
2050 else if(statement==ID_assign_mult)
2052 else if(statement==ID_assign_div)
2054 else if(statement==ID_assign_bitand)
2056 else if(statement==ID_assign_bitor)
2058 else if(statement==ID_assign_bitxor)
2063 error() <<
"bad assignment operator '" << statement <<
"'" <<
eom;
2070 exprt member(ID_member);
2071 member.
set(ID_component_cpp_name, cpp_name);
2092 <<
" expected to have one operand" <<
eom;
2100 const typet &tmp_type = op.type();
2103 tmp_type.
id()==ID_pointer)
2112 std::string str_op=
"operator";
2115 if(expr.
get(ID_statement)==ID_preincrement)
2117 else if(expr.
get(ID_statement)==ID_predecrement)
2119 else if(expr.
get(ID_statement)==ID_postincrement)
2124 else if(expr.
get(ID_statement)==ID_postdecrement)
2139 exprt member(ID_member);
2140 member.
set(ID_component_cpp_name, cpp_name);
2152 expr.
swap(new_expr);
2160 error() <<
"unary operator * expects one operand" <<
eom;
2170 error() <<
"pointer-to-member must use "
2171 <<
"the .* or ->* operators" <<
eom;
2186 if(op1.type().id() != ID_pointer || op1.type().find(ID_to_member).is_nil())
2189 error() <<
"pointer-to-member expected" <<
eom;
2193 typet t0 = op0.type().
id() == ID_pointer
2197 typet t1((
const typet &)op1.type().find(ID_to_member));
2199 if(t0.
id() != ID_struct_tag)
2202 error() <<
"pointer-to-member type error" <<
eom;
2212 error() <<
"pointer-to-member type error" <<
eom;
2218 if(op0.type().id() != ID_pointer)
2220 if(op0.id() == ID_dereference)
2227 op0.get_bool(ID_C_lvalue),
2228 "pointer-to-member must have lvalue operand");
2234 tmp.
type().
set(ID_C_bound, op0);
2241 if(expr.
id()==ID_symbol)
2247 if(function_symbol.
value.
id() == ID_cpp_not_typechecked)
2248 function_symbol.
value.
set(ID_is_used,
true);
2256 bool override_constantness = expr.
get_bool(ID_C_override_constantness);
2263 if(expr.
id()==ID_cpp_name)
2271 if(override_constantness)
2272 expr.
type().
set(ID_C_constant,
false);
2285 if(expr.
id()!=
"explicit-typecast")
2293 expr.
type().
id() == ID_cpp_name &&
2295 (op0_id == ID_unary_plus || op0_id == ID_unary_minus ||
2296 op0_id == ID_address_of || op0_id == ID_dereference))
2298 exprt resolve_result=
2304 if(resolve_result.
id()!=ID_type)
2308 exprt new_binary_expr;
2310 new_binary_expr.
operands().resize(2);
2316 if(op0_id==ID_unary_plus)
2317 new_binary_expr.
id(ID_plus);
2318 else if(op0_id==ID_unary_minus)
2319 new_binary_expr.
id(ID_minus);
2320 else if(op0_id==ID_address_of)
2321 new_binary_expr.
id(ID_bitand);
2322 else if(op0_id==ID_dereference)
2323 new_binary_expr.
id(ID_mult);
2327 expr.
swap(new_binary_expr);
2337 error() <<
"operator '" << expr.
id() <<
"' expects two operands" <<
eom;
2357 error() <<
"comma operator expects two operands" <<
eom;
2363 if(op0_type.id() == ID_struct || op0_type.id() == ID_struct_tag)
const T & as_const(T &value)
Return a reference to the same object but ensures the type is const.
reference_typet reference_type(const typet &subtype)
signedbv_typet signed_int_type()
pointer_typet pointer_type(const typet &subtype)
bitvector_typet c_index_type()
const union_tag_typet & to_union_tag_type(const typet &type)
Cast a typet to a union_tag_typet.
Operator to return the address of an object.
static void make_already_typechecked(exprt &expr)
const typet & element_type() const
The type of the elements of the array.
const exprt & size() const
A base class for relations, i.e., binary predicates whose two operands have the same type.
Base class of fixed-width bit-vector types.
virtual void read(const typet &src)
bool is_subset_of(const c_qualifierst &other) const
virtual void typecheck_expr_main(exprt &expr)
symbol_table_baset & symbol_table
virtual void typecheck_expr_address_of(exprt &expr)
virtual void typecheck_expr(exprt &expr)
virtual void do_initializer(exprt &initializer, const typet &type, bool force_constant)
virtual void typecheck_expr_binary_arithmetic(exprt &expr)
virtual void typecheck_expr_sizeof(exprt &expr)
virtual void typecheck_expr_side_effect(side_effect_exprt &expr)
virtual void typecheck_expr_index(exprt &expr)
virtual void typecheck_expr_function_identifier(exprt &expr)
virtual void typecheck_expr_comma(exprt &expr)
virtual exprt do_special_functions(side_effect_expr_function_callt &expr)
virtual void typecheck_side_effect_assignment(side_effect_exprt &expr)
virtual void typecheck_expr_operands(exprt &expr)
virtual std::optional< symbol_exprt > typecheck_gcc_polymorphic_builtin(const irep_idt &identifier, const exprt::operandst &arguments, const source_locationt &source_location)
virtual void typecheck_function_call_arguments(side_effect_expr_function_callt &expr)
Typecheck the parameters in a function call expression, and where necessary, make implicit casts arou...
virtual void typecheck_expr_dereference(exprt &expr)
virtual void typecheck_expr_rel(binary_relation_exprt &expr)
codet representation of an expression statement.
std::vector< parametert > parameterst
const typet & return_type() const
const parameterst & parameters() const
struct configt::ansi_ct ansi_c
irep_idt class_identifier
bool is_qualified() const
const source_locationt & source_location() const
bool is_destructor() const
const exprt & as_expr() const
cpp_scopet & current_scope()
cpp_scopet & set_scope(const irep_idt &identifier)
exprt::operandst operands
void add_object(const exprt &expr)
bool find_parent(const symbolt &symb, const irep_idt &base_name, irep_idt &identifier)
void typecheck_expr_typecast(exprt &) override
void typecheck_side_effect_assignment(side_effect_exprt &) override
bool implicit_conversion_sequence(const exprt &expr, const typet &type, exprt &new_expr, unsigned &rank)
implicit conversion sequence
void typecheck_type(typet &) override
void explicit_typecast_ambiguity(exprt &)
template_mapt template_map
bool reinterpret_typecast(const exprt &expr, const typet &type, exprt &new_expr, bool check_constantness=true)
void convert_pmop(exprt &expr)
void typecheck_expr_sizeof(exprt &) override
void typecheck_code(codet &) override
void typecheck_expr_explicit_typecast(exprt &)
void implicit_typecast(exprt &expr, const typet &type) override
void typecheck_cast_expr(exprt &)
void typecheck_expr_dereference(exprt &) override
void typecheck_side_effect_function_call(side_effect_expr_function_callt &) override
bool cpp_is_pod(const typet &type) const
bool get_component(const source_locationt &source_location, const exprt &object, const irep_idt &component_name, exprt &member)
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)
std::optional< codet > cpp_constructor(const source_locationt &source_location, const exprt &object, const exprt::operandst &operands)
void typecheck_expr_trinary(if_exprt &) override
void typecheck_expr_rel(binary_relation_exprt &) override
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)
void add_method_body(symbolt *_method_symbol)
void typecheck_expr_binary_arithmetic(exprt &) override
void typecheck_expr_delete(exprt &)
void typecheck_expr_main(exprt &) override
Called after the operands are done.
void elaborate_class_template(const typet &type)
elaborate class template instances
bool operator_is_overloaded(exprt &)
bool standard_conversion_lvalue_to_rvalue(const exprt &expr, exprt &new_expr) const
Lvalue-to-rvalue conversion.
void typecheck_expr_new(exprt &)
void add_implicit_dereference(exprt &)
void typecheck_expr_cpp_name(exprt &, const cpp_typecheck_fargst &)
void typecheck_expr(exprt &) override
void typecheck_expr_side_effect(side_effect_exprt &) override
void typecheck_expr_comma(exprt &) override
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
std::optional< codet > cpp_destructor(const source_locationt &source_location, const exprt &object)
void typecheck_expr_explicit_constructor_call(exprt &)
void typecheck_function_expr(exprt &, const cpp_typecheck_fargst &)
void typecheck_method_application(side_effect_expr_function_callt &)
std::string to_string(const typet &) override
void typecheck_expr_this(exprt &)
void typecheck_expr_throw(exprt &)
bool overloadable(const exprt &)
void typecheck_expr_index(exprt &) override
void typecheck_side_effect_inc_dec(side_effect_exprt &)
void zero_initializer(const exprt &object, const typet &type, const source_locationt &source_location, exprt::operandst &ops)
void typecheck_function_call_arguments(side_effect_expr_function_callt &) override
void typecheck_expr_ptrmember(exprt &) override
exprt resolve(const cpp_namet &cpp_name, const cpp_typecheck_resolvet::wantt want, const cpp_typecheck_fargst &fargs, bool fail_with_exception=true)
void typecheck_expr_address_of(exprt &) override
void typecheck_expr_function_identifier(exprt &) override
void typecheck_expr_member(exprt &) override
Operator to dereference a pointer.
dstringt has one field, an unsigned integer no which is an index into a static table of strings.
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()
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.
The Boolean constant false.
The trinary if-then-else operator.
There are a large number of kinds of tree structured or tree-like data in CPROVER.
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
const std::string & get_string(const irep_idt &name) const
irept & add(const irep_idt &name)
const exprt & compound() const
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.
exprt::operandst & arguments()
An expression containing a side effect.
const irep_idt & get_statement() const
A struct tag type, i.e., struct_typet with an identifier.
Structure type, corresponds to C style structs.
bool has_base(const irep_idt &id) const
Test whether id is a base class/struct.
const basest & bases() const
Get the collection of base classes/structs.
Base type for structs and unions.
const componentt & get_component(const irep_idt &component_name) const
Get the reference to a component with given name.
bool is_incomplete() const
A struct/union may be incomplete.
const componentst & components() const
std::vector< componentt > componentst
symbolt & get_writeable_ref(const irep_idt &name)
Find a symbol in the symbol table for read-write access.
irep_idt base_name
Base (non-scoped) name.
typet type
Type of symbol.
exprt value
Initial value of symbol.
void build(const template_typet &template_type, const cpp_template_args_tct &template_args)
void print(std::ostream &out) const
The Boolean constant true.
Semantic type conversion.
The type of an expression, extends irept.
source_locationt & add_source_location()
irept cpp_exception_list(const typet &src, const namespacet &ns)
turns a type into a list of relevant exception IDs
C++ Language Type Checking.
cpp_namet & to_cpp_name(irept &cpp_name)
std::string cpp_type2name(const typet &type)
C++ Language Type Checking.
static exprt collect_comma_expression(const exprt &src)
struct operator_entryt operators[]
C++ Language Type Checking.
symbol_exprt cpp_symbol_expr(const symbolt &symbol)
std::string type2cpp(const typet &type, const namespacet &ns)
Expression Initialization.
bool is_number(const typet &type)
Returns true if the type is a rational, real, integer, natural, complex, unsignedbv,...
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.
const address_of_exprt & to_address_of_expr(const exprt &expr)
Cast an exprt to an address_of_exprt.
std::optional< exprt > size_of_expr(const typet &type, 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)
side_effect_expr_function_callt & to_side_effect_expr_function_call(exprt &expr)
auto component(T &struct_expr, const irep_idt &name, const namespacet &ns) -> decltype(struct_expr.op0())
const symbol_exprt & to_symbol_expr(const exprt &expr)
Cast an exprt to a symbol_exprt.
const multi_ary_exprt & to_multi_ary_expr(const exprt &expr)
Cast an exprt to a multi_ary_exprt.
const binary_exprt & to_binary_expr(const exprt &expr)
Cast an exprt to a binary_exprt.
const member_exprt & to_member_expr(const exprt &expr)
Cast an exprt to a member_exprt.
const unary_exprt & to_unary_expr(const exprt &expr)
Cast an exprt to a unary_exprt.
const class_typet & to_class_type(const typet &type)
Cast a typet to a class_typet.
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 array_typet & to_array_type(const typet &type)
Cast a typet to an array_typet.
const struct_tag_typet & to_struct_tag_type(const typet &type)
Cast a typet to a struct_tag_typet.