@@ -31,6 +31,7 @@ void cpp_typecheckt::convert_parameter(
31
31
parameter.set_base_name (base_name);
32
32
}
33
33
34
+ PRECONDITION (!cpp_scopes.current_scope ().prefix .empty ());
34
35
irep_idt identifier=cpp_scopes.current_scope ().prefix +
35
36
id2string (base_name);
36
37
@@ -90,22 +91,6 @@ void cpp_typecheckt::convert_function(symbolt &symbol)
90
91
if (symbol.value .is_nil ())
91
92
return ;
92
93
93
- // if it is a destructor, add the implicit code
94
- if (to_code_type (symbol.type ).return_type ().id () == ID_destructor)
95
- {
96
- const symbolt &msymb=lookup (symbol.type .get (ID_C_member_name));
97
-
98
- assert (symbol.value .id ()==ID_code);
99
- assert (symbol.value .get (ID_statement)==ID_block);
100
-
101
- if (
102
- !symbol.value .has_operands () || !symbol.value .op0 ().has_operands () ||
103
- symbol.value .op0 ().op0 ().id () != ID_already_typechecked)
104
- {
105
- symbol.value .copy_to_operands (dtor (msymb));
106
- }
107
- }
108
-
109
94
// enter appropriate scope
110
95
cpp_save_scopet saved_scope (cpp_scopes);
111
96
cpp_scopet &function_scope=cpp_scopes.set_scope (symbol.name );
@@ -123,13 +108,29 @@ void cpp_typecheckt::convert_function(symbolt &symbol)
123
108
code_typet::parameterst ¶meters=function_type.parameters ();
124
109
assert (parameters.size ()>=1 );
125
110
code_typet::parametert &this_parameter_expr=parameters.front ();
126
- function_scope.this_expr =exprt (ID_symbol, this_parameter_expr.type ());
127
- function_scope.this_expr .set (
128
- ID_identifier, this_parameter_expr.get_identifier ());
111
+ function_scope.this_expr = symbol_exprt{
112
+ this_parameter_expr.get_identifier (), this_parameter_expr.type ()};
129
113
}
130
114
else
131
115
function_scope.this_expr .make_nil ();
132
116
117
+ // if it is a destructor, add the implicit code
118
+ if (to_code_type (symbol.type ).return_type ().id () == ID_destructor)
119
+ {
120
+ const symbolt &msymb = lookup (symbol.type .get (ID_C_member_name));
121
+
122
+ PRECONDITION (symbol.value .id () == ID_code);
123
+ PRECONDITION (symbol.value .get (ID_statement) == ID_block);
124
+
125
+ if (
126
+ !symbol.value .has_operands () || !symbol.value .op0 ().has_operands () ||
127
+ symbol.value .op0 ().op0 ().id () != ID_already_typechecked)
128
+ {
129
+ symbol.value .copy_to_operands (
130
+ dtor (msymb, to_symbol_expr (function_scope.this_expr )));
131
+ }
132
+ }
133
+
133
134
// do the function body
134
135
start_typecheck_code ();
135
136
@@ -147,6 +148,8 @@ void cpp_typecheckt::convert_function(symbolt &symbol)
147
148
symbol.value .type ()=symbol.type ;
148
149
149
150
return_type = old_return_type;
151
+
152
+ deferred_typechecking.erase (symbol.name );
150
153
}
151
154
152
155
// / for function overloading
@@ -171,8 +174,7 @@ irep_idt cpp_typecheckt::function_identifier(const typet &type)
171
174
code_typet::parameterst::const_iterator it=
172
175
parameters.begin ();
173
176
174
- if (it!=parameters.end () &&
175
- it->get_identifier ()==ID_this)
177
+ if (it != parameters.end () && it->get_this ())
176
178
{
177
179
const typet &pointer=it->type ();
178
180
const typet &symbol =pointer.subtype ();
0 commit comments