30 exprt object_tc=object;
40 if(tmp_type.id()==ID_array)
49 if(!operands.empty() && !operands.front().get_bool(ID_C_array_ini))
52 error() <<
"bad array initializer" <<
eom;
56 assert(operands.empty() || operands.size()==1);
61 const exprt &size_expr=
64 if(size_expr.
id() == ID_infinity)
67 exprt tmp_size=size_expr;
75 <<
"' is not a constant" <<
eom;
109 if(!operands.empty())
113 tmp_operands.push_back(operand);
118 if(i_code.has_value())
119 new_code.
add(std::move(i_code.value()));
121 return std::move(new_code);
128 for(
auto &op : operands_tc)
134 if(operands_tc.empty())
139 else if(operands_tc.size()==1)
142 object_tc.
type().
set(ID_C_constant,
false);
143 object_tc.
set(ID_C_lvalue,
true);
149 return std::move(new_code);
154 error() <<
"initialization of POD requires one argument, " 155 "but got " << operands.size() <<
eom;
159 else if(tmp_type.id()==ID_union)
163 else if(tmp_type.id()==ID_struct)
167 for(
auto &op : operands_tc)
180 if(
component.get_base_name() !=
"@most_derived")
185 member.
set(ID_C_lvalue, object_tc.
get_bool(ID_C_lvalue));
208 for(
const auto &c : components)
210 const typet &type = c.type();
213 !c.get_bool(ID_from_base) && type.
id() == ID_code &&
216 constructor_name = c.get_base_name();
222 assert(constructor_name!=
"");
225 cpp_namet(constructor_name, source_location).as_expr(),
231 assert(function_call.
get(ID_statement)==ID_temporary_object);
234 static_cast<exprt &
>(function_call.
add(ID_initializer));
236 assert(initializer.id()==ID_code &&
237 initializer.get(ID_statement)==ID_expression);
242 exprt &tmp_this=func_ini.arguments().front();
245 "expected new_object operand in address_of expression");
249 const auto &initializer_code=
to_code(initializer);
252 return initializer_code;
255 block.
add(initializer_code);
256 return std::move(block);
272 exprt tmp_object_expr=
exprt(ID_side_effect, type);
273 tmp_object_expr.
set(ID_statement, ID_temporary_object);
276 exprt new_object(ID_new_object);
278 new_object.
set(ID_C_lvalue,
true);
279 new_object.
type()=tmp_object_expr.
type();
285 if(new_code.has_value())
287 if(new_code->get_statement() == ID_assign)
290 tmp_object_expr.
add(ID_initializer) = *new_code;
293 temporary.
swap(tmp_object_expr);
side_effect_expr_function_callt & to_side_effect_expr_function_call(exprt &expr)
The type of an expression, extends irept.
void new_temporary(const source_locationt &source_location, const typet &, const exprt::operandst &ops, exprt &temporary)
optionalt< codet > cpp_constructor(const source_locationt &source_location, const exprt &object, const exprt::operandst &operands)
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())
code_operandst & statements()
std::vector< componentt > componentst
void move_to_operands(exprt &expr)
Move the given argument to the end of exprt's operands.
void typecheck_expr(exprt &) override
void already_typechecked(irept &irep)
const componentst & components() const
typet & type()
Return the type of the expression.
const address_of_exprt & to_address_of_expr(const exprt &expr)
Cast an exprt to an address_of_exprt.
Structure type, corresponds to C style structs.
bool get_bool(const irep_namet &name) const
codet representation of an expression statement.
void typecheck_side_effect_assignment(side_effect_exprt &) override
Extract member of struct or union.
const irep_idt & id() const
void elaborate_class_template(const typet &type)
elaborate class template instances
void add(const codet &code)
The Boolean constant true.
source_locationt source_location
bool cpp_is_pod(const typet &type) const
nonstd::optional< T > optionalt
bool is_reference(const typet &type)
Returns true if the type is a reference.
const irep_idt & get(const irep_namet &name) const
const exprt & size() const
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.
dstringt has one field, an unsigned integer no which is an index into a static table of strings...
Operator to return the address of an object.
The Boolean constant false.
std::vector< exprt > operandst
cpp_scopet & set_scope(const irep_idt &identifier)
A side_effect_exprt representation of a function call side effect.
const array_typet & to_array_type(const typet &type)
Cast a typet to an array_typet.
Base class for all expressions.
const source_locationt & source_location() const
#define UNREACHABLE
This should be used to mark dead code.
const exprt & expression() const
virtual void make_constant_index(exprt &expr)
irept & add(const irep_namet &name)
source_locationt & add_source_location()
A codet representing sequential composition of program statements.
const codet & to_code(const exprt &expr)
#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.
void typecheck_side_effect_function_call(side_effect_expr_function_callt &) override
std::string to_string(const typet &) override
const typet & return_type() const
void add_implicit_dereference(exprt &)
void set(const irep_namet &name, const irep_idt &value)