@@ -116,7 +116,7 @@ symbol_exprt allocate_objectst::allocate_automatic_local_object(
116116 symbol_mode,
117117 symbol_table);
118118
119- symbols_created. push_back (& aux_symbol);
119+ add_created_symbol ( aux_symbol);
120120
121121 return aux_symbol.symbol_expr ();
122122}
@@ -153,7 +153,7 @@ exprt allocate_objectst::allocate_dynamic_object_symbol(
153153 symbol_mode,
154154 symbol_table);
155155
156- symbols_created. push_back (& malloc_sym);
156+ add_created_symbol ( malloc_sym);
157157
158158 code_frontend_assignt assign =
159159 make_allocate_code (malloc_sym.symbol_expr (), object_size.value ());
@@ -194,7 +194,7 @@ exprt allocate_objectst::allocate_non_dynamic_object(
194194 symbol_table);
195195
196196 aux_symbol.is_static_lifetime = static_lifetime;
197- symbols_created. push_back (& aux_symbol);
197+ add_created_symbol ( aux_symbol);
198198
199199 exprt aoe = typecast_exprt::conditional_cast (
200200 address_of_exprt (aux_symbol.symbol_expr ()), target_expr.type ());
@@ -215,10 +215,10 @@ exprt allocate_objectst::allocate_non_dynamic_object(
215215
216216// / Add a pointer to a symbol to the list of pointers to symbols created so far
217217// /
218- // / \param symbol_ptr: pointer to a symbol in the symbol table
219- void allocate_objectst::add_created_symbol (const symbolt *symbol_ptr )
218+ // / \param symbol: symbol in the symbol table
219+ void allocate_objectst::add_created_symbol (const symbolt &symbol )
220220{
221- symbols_created.push_back (symbol_ptr );
221+ symbols_created.push_back (symbol. name );
222222}
223223
224224// / Adds declarations for all non-static symbols created
@@ -228,11 +228,12 @@ void allocate_objectst::declare_created_symbols(code_blockt &init_code)
228228{
229229 // Add the following code to init_code for each symbol that's been created:
230230 // <type> <identifier>;
231- for (const symbolt * const symbol_ptr : symbols_created)
231+ for (const auto &symbol_id : symbols_created)
232232 {
233- if (!symbol_ptr->is_static_lifetime )
233+ const symbolt &symbol = ns.lookup (symbol_id);
234+ if (!symbol.is_static_lifetime )
234235 {
235- code_declt decl (symbol_ptr-> symbol_expr ()) ;
236+ code_declt decl{symbol. symbol_expr ()} ;
236237 decl.add_source_location () = source_location;
237238 init_code.add (decl);
238239 }
@@ -246,10 +247,11 @@ void allocate_objectst::mark_created_symbols_as_input(code_blockt &init_code)
246247{
247248 // Add the following code to init_code for each symbol that's been created:
248249 // INPUT("<identifier>", <identifier>);
249- for (symbolt const *symbol_ptr : symbols_created)
250+ for (const auto &symbol_id : symbols_created)
250251 {
251- init_code.add (code_inputt{
252- symbol_ptr->base_name , symbol_ptr->symbol_expr (), source_location});
252+ const symbolt &symbol = ns.lookup (symbol_id);
253+ init_code.add (
254+ code_inputt{symbol.base_name , symbol.symbol_expr (), source_location});
253255 }
254256}
255257
0 commit comments