32 assert(symbol.
type.
id()==ID_struct ||
33 symbol.
type.
id()==ID_union);
37 decl.type().id(ID_function_type);
38 decl.type().subtype().make_nil();
40 decl.value().id(ID_code);
41 decl.value().add(ID_type).id(ID_code);
42 decl.value().set(ID_statement, ID_block);
43 decl.add(ID_cv).make_nil();
44 decl.add(ID_throw_decl).make_nil();
47 dtor.
add(ID_storage_spec).
id(ID_cpp_storage_spec);
56 assert(symbol.
type.
id()==ID_struct ||
57 symbol.
type.
id()==ID_union);
71 for(
const auto &c : components)
73 if(c.get_bool(ID_is_vtptr))
75 const cpp_namet cppname(c.get_base_name());
77 const symbolt &virtual_table_symbol_type =
78 lookup(c.type().subtype().get(ID_identifier));
81 id2string(virtual_table_symbol_type.name) +
"@" +
84 exprt var=virtual_table_symbol_var.symbol_expr();
86 assert(address.
type() == c.type());
90 exprt ptrmember(ID_ptrmember);
91 ptrmember.
set(ID_component_name, c.get_name());
101 for(struct_union_typet::componentst::const_reverse_iterator
102 cit=components.rbegin();
103 cit!=components.rend();
106 const typet &type=cit->type();
108 if(cit->get_bool(ID_from_base) ||
109 cit->get_bool(ID_is_type) ||
110 cit->get_bool(ID_is_static) ||
111 type.
id()==ID_code ||
116 const cpp_namet cppname(cit->get_base_name(), source_location);
118 exprt member(ID_ptrmember, type);
119 member.set(ID_component_cpp_name, cppname);
120 member.operands().push_back(
122 member.add_source_location() = source_location;
129 if(dtor_code.has_value())
130 block.
add(dtor_code.value());
133 if(symbol.
type.
id() == ID_union)
134 return std::move(block);
139 for(class_typet::basest::const_reverse_iterator bit = bases.rbegin();
143 DATA_INVARIANT(bit->id() == ID_base,
"base class expression expected");
148 object.add_source_location() = source_location;
155 if(dtor_code.has_value())
156 block.
add(dtor_code.value());
159 return std::move(block);
The type of an expression, extends irept.
irep_idt name
The unique identifier.
void set_function(const irep_idt &function)
codet dtor(const symbolt &symb)
produces destructor code for a class object
const std::string & id2string(const irep_idt &d)
pointer_typet pointer_type(const typet &subtype)
std::vector< componentt > componentst
void move_to_operands(exprt &expr)
Move the given argument to the end of exprt's operands.
void already_typechecked(irept &irep)
const componentst & components() const
typet & type()
Return the type of the expression.
void default_dtor(const symbolt &symb, cpp_declarationt &dtor)
Note:
const irep_idt & id() const
void add(const codet &code)
optionalt< codet > cpp_destructor(const source_locationt &source_location, const exprt &object)
const basest & bases() const
Get the collection of base classes/structs.
bool cpp_is_pod(const typet &type) const
Operator to dereference a pointer.
bool is_reference(const typet &type)
Returns true if the type is a reference.
C++ Language Type Checking.
const struct_typet & to_struct_type(const typet &type)
Cast a typet to a struct_typet.
Operator to return the address of an object.
bool find_dtor(const symbolt &symbol) const
const source_locationt & source_location() const
typet type
Type of symbol.
source_locationt location
Source code location of definition of symbol.
Base class for all expressions.
irep_idt base_name
Base (non-scoped) name.
const struct_union_typet & to_struct_union_type(const typet &type)
Cast a typet to a struct_union_typet.
irept & add(const irep_namet &name)
bool disable_access_control
A codet representing sequential composition of program statements.
Expression to hold a symbol (variable)
Data structure for representing an arbitrary statement in a program.
#define DATA_INVARIANT(CONDITION, REASON)
This condition should be used to document that assumptions that are made on goto_functions, goto_programs, exprts, etc.
bool lookup(const irep_idt &name, const symbolt *&symbol) const override
See documentation for namespace_baset::lookup().
A codet representing an assignment in the program.
void set(const irep_namet &name, const irep_idt &value)