27 exprt object_tc=object;
35 if(object_tc.
type().
id() == ID_array)
44 if(!operands.empty() && !operands.front().get_bool(ID_C_array_ini))
47 error() <<
"bad array initializer" <<
eom;
52 operands.empty() || operands.size() == 1,
53 "array constructor must have at most one operand");
60 if(size_expr.
id() == ID_infinity)
63 exprt tmp_size=size_expr;
70 error() <<
"array size '" <<
to_string(size_expr) <<
"' is not a constant"
105 if(!operands.empty())
109 tmp_operands.push_back(operand);
114 if(i_code.has_value())
115 new_code.
add(std::move(i_code.value()));
117 return std::move(new_code);
124 for(
auto &op : operands_tc)
130 if(operands_tc.empty())
135 else if(operands_tc.size()==1)
138 object_tc.
type().
set(ID_C_constant,
false);
139 object_tc.
set(ID_C_lvalue,
true);
141 object_tc, operands_tc.front(),
typet(), source_location);
148 error() <<
"initialization of POD requires one argument, "
149 "but got " << operands.size() <<
eom;
153 else if(object_tc.
type().
id() == ID_union_tag)
157 else if(object_tc.
type().
id() == ID_struct_tag)
161 for(
auto &op : operands_tc)
174 if(
component.get_base_name() !=
"@most_derived")
179 member.
set(ID_C_lvalue, object_tc.
get_bool(ID_C_lvalue));
187 std::move(member), std::move(val),
typet(), source_location);
204 for(
const auto &c : components)
206 const typet &type = c.type();
209 !c.get_bool(ID_from_base) && type.
id() == ID_code &&
212 constructor_name = c.get_base_name();
217 INVARIANT(!constructor_name.
empty(),
"non-PODs should have a constructor");
220 cpp_namet(constructor_name, source_location).as_expr(),
229 static_cast<exprt &
>(function_call.
add(ID_initializer));
232 initializer.
id() == ID_code &&
233 initializer.
get(ID_statement) == ID_expression,
234 "initializer must be expression statement");
244 "expected new_object operand in address_of expression");
248 const auto &initializer_code=
to_code(initializer);
251 return initializer_code;
254 block.
add(initializer_code);
255 return std::move(block);
272 tmp_object_expr.
set(ID_mode, ID_cpp);
274 exprt new_object(ID_new_object);
276 new_object.
set(ID_C_lvalue,
true);
277 new_object.
type()=tmp_object_expr.
type();
283 if(new_code.has_value())
285 if(new_code->get_statement() == ID_assign)
288 tmp_object_expr.
add(ID_initializer) = *new_code;
291 temporary.
swap(tmp_object_expr);
bitvector_typet c_index_type()
Operator to return the address of an object.
static void make_already_typechecked(exprt &expr)
const exprt & size() const
virtual void make_constant_index(exprt &expr)
A codet representing sequential composition of program statements.
void add(const codet &code)
code_operandst & statements()
codet representation of an expression statement.
cpp_scopet & set_scope(const irep_idt &identifier)
void typecheck_side_effect_assignment(side_effect_exprt &) override
void typecheck_side_effect_function_call(side_effect_expr_function_callt &) override
bool cpp_is_pod(const typet &type) const
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 elaborate_class_template(const typet &type)
elaborate class template instances
void add_implicit_dereference(exprt &)
void typecheck_expr(exprt &) override
std::string to_string(const typet &) override
dstringt has one field, an unsigned integer no which is an index into a static table of strings.
Base class for all expressions.
std::vector< exprt > operandst
source_locationt & add_source_location()
const source_locationt & source_location() const
typet & type()
Return the type of the expression.
void add_to_operands(const exprt &expr)
Add the given argument to the end of exprt's operands.
The Boolean constant false.
bool get_bool(const irep_idt &name) const
const irep_idt & get(const irep_idt &name) const
void set(const irep_idt &name, const irep_idt &value)
const irep_idt & id() const
irept & add(const irep_idt &name)
Extract member of struct or union.
source_locationt source_location
const union_typet & follow_tag(const union_tag_typet &) const
Follow type tag of union type.
A side_effect_exprt that performs an assignment.
A side_effect_exprt representation of a function call side effect.
exprt::operandst & arguments()
An expression containing a side effect.
Structure type, corresponds to C style structs.
const componentst & components() const
std::vector< componentt > componentst
The Boolean constant true.
The type of an expression, extends irept.
C++ Language Type Checking.
API to expression classes for Pointers.
bool is_reference(const typet &type)
Returns true if the type is a reference.
const address_of_exprt & to_address_of_expr(const exprt &expr)
Cast an exprt to an address_of_exprt.
#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,...
side_effect_expr_function_callt & to_side_effect_expr_function_call(exprt &expr)
code_expressiont & to_code_expression(codet &code)
const codet & to_code(const exprt &expr)
auto component(T &struct_expr, const irep_idt &name, const namespacet &ns) -> decltype(struct_expr.op0())
const constant_exprt & to_constant_expr(const exprt &expr)
Cast an exprt to a constant_exprt.
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.