Go to the documentation of this file.
27 exprt object_tc=object;
37 if(tmp_type.
id()==ID_array)
46 if(!operands.empty() && !operands.front().get_bool(ID_C_array_ini))
49 error() <<
"bad array initializer" <<
eom;
53 assert(operands.empty() || operands.size()==1);
58 const exprt &size_expr=
61 if(size_expr.
id() == ID_infinity)
64 exprt tmp_size=size_expr;
71 error() <<
"array size '" <<
to_string(size_expr) <<
"' is not a constant"
106 if(!operands.empty())
110 tmp_operands.push_back(operand);
115 if(i_code.has_value())
116 new_code.
add(std::move(i_code.value()));
118 return std::move(new_code);
125 for(
auto &op : operands_tc)
131 if(operands_tc.empty())
136 else if(operands_tc.size()==1)
139 object_tc.
type().
set(ID_C_constant,
false);
140 object_tc.
set(ID_C_lvalue,
true);
142 object_tc, operands_tc.front(),
typet(), source_location);
149 error() <<
"initialization of POD requires one argument, "
150 "but got " << operands.size() <<
eom;
154 else if(tmp_type.
id()==ID_union)
158 else if(tmp_type.
id()==ID_struct)
162 for(
auto &op : operands_tc)
175 if(
component.get_base_name() !=
"@most_derived")
180 member.
set(ID_C_lvalue, object_tc.
get_bool(ID_C_lvalue));
188 std::move(member), std::move(val),
typet(), source_location);
205 for(
const auto &c : components)
207 const typet &type = c.type();
210 !c.get_bool(ID_from_base) && type.
id() == ID_code &&
213 constructor_name = c.get_base_name();
218 INVARIANT(!constructor_name.
empty(),
"non-PODs should have a constructor");
221 cpp_namet(constructor_name, source_location).as_expr(),
227 assert(function_call.
get(ID_statement)==ID_temporary_object);
230 static_cast<exprt &
>(function_call.
add(ID_initializer));
232 assert(initializer.
id()==ID_code &&
233 initializer.
get(ID_statement)==ID_expression);
243 "expected new_object operand in address_of expression");
247 const auto &initializer_code=
to_code(initializer);
250 return initializer_code;
253 block.
add(initializer_code);
254 return std::move(block);
271 tmp_object_expr.
set(ID_mode, ID_cpp);
273 exprt new_object(ID_new_object);
275 new_object.
set(ID_C_lvalue,
true);
276 new_object.
type()=tmp_object_expr.
type();
282 if(new_code.has_value())
284 if(new_code->get_statement() == ID_assign)
287 tmp_object_expr.
add(ID_initializer) = *new_code;
290 temporary.
swap(tmp_object_expr);
#define UNREACHABLE
This should be used to mark dead code.
const componentst & components() const
dstringt has one field, an unsigned integer no which is an index into a static table of strings.
A codet representing sequential composition of program statements.
code_expressiont & to_code_expression(codet &code)
side_effect_expr_function_callt & to_side_effect_expr_function_call(exprt &expr)
void elaborate_class_template(const typet &type)
elaborate class template instances
const struct_typet & to_struct_type(const typet &type)
Cast a typet to a struct_typet.
The type of an expression, extends irept.
void typecheck_side_effect_assignment(side_effect_exprt &) override
A side_effect_exprt representation of a function call side effect.
void new_temporary(const source_locationt &source_location, const typet &, const exprt::operandst &ops, exprt &temporary)
Base class for all expressions.
std::vector< componentt > componentst
optionalt< codet > cpp_constructor(const source_locationt &source_location, const exprt &object, const exprt::operandst &operands)
auto component(T &struct_expr, const irep_idt &name, const namespacet &ns) -> decltype(struct_expr.op0())
const irep_idt & get(const irep_idt &name) const
const exprt & size() const
code_operandst & statements()
bool cpp_is_pod(const typet &type) const
const codet & to_code(const exprt &expr)
typet & type()
Return the type of the expression.
const code_typet & to_code_type(const typet &type)
Cast a typet to a code_typet.
void typecheck_side_effect_function_call(side_effect_expr_function_callt &) override
static void make_already_typechecked(exprt &expr)
#define DATA_INVARIANT(CONDITION, REASON)
This condition should be used to document that assumptions that are made on goto_functions,...
void add_implicit_dereference(exprt &)
source_locationt source_location
void set(const irep_idt &name, const irep_idt &value)
A side_effect_exprt that performs an assignment.
virtual void make_constant_index(exprt &expr)
const irep_idt & id() const
std::vector< exprt > operandst
void add(const codet &code)
The Boolean constant false.
nonstd::optional< T > optionalt
Extract member of struct or union.
void typecheck_expr(exprt &) override
bool is_reference(const typet &type)
Returns true if the type is a reference.
Structure type, corresponds to C style structs.
irept & add(const irep_idt &name)
const typet & follow(const typet &) const
Resolve type symbol to the type it points to.
exprt::operandst & arguments()
const array_typet & to_array_type(const typet &type)
Cast a typet to an array_typet.
void add_to_operands(const exprt &expr)
Add the given argument to the end of exprt's operands.
std::string to_string(const typet &) override
const address_of_exprt & to_address_of_expr(const exprt &expr)
Cast an exprt to an address_of_exprt.
Operator to return the address of an object.
source_locationt & add_source_location()
The Boolean constant true.
bitvector_typet c_index_type()
const source_locationt & source_location() const
cpp_scopet & set_scope(const irep_idt &identifier)
bool get_bool(const irep_idt &name) const
An expression containing a side effect.
codet representation of an expression statement.
const constant_exprt & to_constant_expr(const exprt &expr)
Cast an exprt to a constant_exprt.