Go to the documentation of this file.
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;
74 error() <<
"array size '" <<
to_string(size_expr) <<
"' is not a constant"
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);
145 object_tc, operands_tc.front(),
typet(), source_location);
152 error() <<
"initialization of POD requires one argument, "
153 "but got " << operands.size() <<
eom;
157 else if(tmp_type.
id()==ID_union)
161 else if(tmp_type.
id()==ID_struct)
165 for(
auto &op : operands_tc)
178 if(
component.get_base_name() !=
"@most_derived")
183 member.
set(ID_C_lvalue, object_tc.
get_bool(ID_C_lvalue));
191 std::move(member), std::move(val),
typet(), source_location);
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();
221 INVARIANT(!constructor_name.
empty(),
"non-PODs should have a constructor");
224 cpp_namet(constructor_name, source_location).as_expr(),
230 assert(function_call.
get(ID_statement)==ID_temporary_object);
233 static_cast<exprt &
>(function_call.
add(ID_initializer));
235 assert(initializer.
id()==ID_code &&
236 initializer.
get(ID_statement)==ID_expression);
246 "expected new_object operand in address_of expression");
250 const auto &initializer_code=
to_code(initializer);
253 return initializer_code;
256 block.
add(initializer_code);
257 return std::move(block);
274 tmp_object_expr.
set(ID_mode, ID_cpp);
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);
#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.
irept & add(const irep_namet &name)
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())
bitvector_typet index_type()
const codet & to_code(const exprt &expr)
const exprt & size() const
code_operandst & statements()
bool cpp_is_pod(const typet &type) const
typet & type()
Return the type of the expression.
bool get_bool(const irep_namet &name) const
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,...
const address_of_exprt & to_address_of_expr(const exprt &expr)
Cast an exprt to an address_of_exprt.
void add_implicit_dereference(exprt &)
source_locationt source_location
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
C++ Language Type Checking.
Extract member of struct or union.
void typecheck_expr(exprt &) override
Structure type, corresponds to C style structs.
const typet & follow(const typet &) const
Resolve type symbol to the type it points to.
bool is_reference(const typet &type)
Returns true if the type is a reference.
const irep_idt & get(const irep_namet &name) const
void set(const irep_namet &name, const irep_idt &value)
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
Operator to return the address of an object.
source_locationt & add_source_location()
The Boolean constant true.
const source_locationt & source_location() const
cpp_scopet & set_scope(const irep_idt &identifier)
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.