3535#include " java_root_class.h"
3636#include " generic_parameter_specialization_map_keys.h"
3737
38- static symbolt &new_tmp_symbol (
39- symbol_table_baset &symbol_table,
40- const source_locationt &loc,
41- const typet &type,
42- const std::string &prefix = " tmp_object_factory" )
43- {
44- return get_fresh_aux_symbol (
45- type,
46- " " ,
47- prefix,
48- loc,
49- ID_java,
50- symbol_table);
51- }
52-
5338class java_object_factoryt
5439{
5540 // / Every new variable initialized by the code emitted by the methods of this
@@ -195,6 +180,7 @@ exprt allocate_dynamic_object(
195180 const typet &allocate_type,
196181 symbol_table_baset &symbol_table,
197182 const source_locationt &loc,
183+ const irep_idt &function_id,
198184 code_blockt &output_code,
199185 std::vector<const symbolt *> &symbols_created,
200186 bool cast_needed)
@@ -212,11 +198,13 @@ exprt allocate_dynamic_object(
212198 // create a symbol for the malloc expression so we can initialize
213199 // without having to do it potentially through a double-deref, which
214200 // breaks the to-SSA phase.
215- symbolt &malloc_sym=new_tmp_symbol (
216- symbol_table,
217- loc,
201+ symbolt &malloc_sym = get_fresh_aux_symbol (
218202 pointer_type (allocate_type),
219- " malloc_site" );
203+ id2string (function_id),
204+ " malloc_site" ,
205+ loc,
206+ ID_java,
207+ symbol_table);
220208 symbols_created.push_back (&malloc_sym);
221209 code_assignt assign=code_assignt (malloc_sym.symbol_expr (), malloc_expr);
222210 assign.add_source_location ()=loc;
@@ -253,6 +241,7 @@ exprt allocate_dynamic_object_with_decl(
253241 const exprt &target_expr,
254242 symbol_table_baset &symbol_table,
255243 const source_locationt &loc,
244+ const irep_idt &function_id,
256245 code_blockt &output_code)
257246{
258247 std::vector<const symbolt *> symbols_created;
@@ -263,6 +252,7 @@ exprt allocate_dynamic_object_with_decl(
263252 allocate_type,
264253 symbol_table,
265254 loc,
255+ function_id,
266256 tmp_block,
267257 symbols_created,
268258 false );
@@ -306,7 +296,13 @@ exprt java_object_factoryt::allocate_object(
306296 case allocation_typet::LOCAL:
307297 case allocation_typet::GLOBAL:
308298 {
309- symbolt &aux_symbol=new_tmp_symbol (symbol_table, loc, allocate_type);
299+ symbolt &aux_symbol = get_fresh_aux_symbol (
300+ allocate_type,
301+ id2string (object_factory_parameters.function_id ),
302+ " tmp_object_factory" ,
303+ loc,
304+ ID_java,
305+ symbol_table);
310306 if (alloc_type==allocation_typet::GLOBAL)
311307 aux_symbol.is_static_lifetime =true ;
312308 symbols_created.push_back (&aux_symbol);
@@ -327,6 +323,7 @@ exprt java_object_factoryt::allocate_object(
327323 allocate_type,
328324 symbol_table,
329325 loc,
326+ object_factory_parameters.function_id ,
330327 assignments,
331328 symbols_created,
332329 cast_needed);
@@ -569,6 +566,7 @@ codet initialize_nondet_string_struct(
569566 const exprt &obj,
570567 const std::size_t &max_nondet_string_length,
571568 const source_locationt &loc,
569+ const irep_idt &function_id,
572570 symbol_table_baset &symbol_table,
573571 bool printable)
574572{
@@ -608,8 +606,13 @@ codet initialize_nondet_string_struct(
608606 {
609607 // / \todo Refactor with make_nondet_string_expr
610608 // length_expr = nondet(int);
611- const symbolt length_sym =
612- new_tmp_symbol (symbol_table, loc, java_int_type ());
609+ const symbolt length_sym = get_fresh_aux_symbol (
610+ java_int_type (),
611+ id2string (function_id),
612+ " tmp_object_factory" ,
613+ loc,
614+ ID_java,
615+ symbol_table);
613616 const symbol_exprt length_expr = length_sym.symbol_expr ();
614617 const side_effect_expr_nondett nondet_length (length_expr.type ());
615618 code.add (code_declt (length_expr));
@@ -646,7 +649,7 @@ codet initialize_nondet_string_struct(
646649 // data_expr = nondet(char[INFINITY]) // we use infinity for variable size
647650 const dereference_exprt data_expr (data_pointer);
648651 const exprt nondet_array =
649- make_nondet_infinite_char_array (symbol_table, loc, code);
652+ make_nondet_infinite_char_array (symbol_table, loc, function_id, code);
650653 code.add (code_assignt (data_expr, nondet_array));
651654
652655 struct_expr.copy_to_operands (length_expr);
@@ -692,6 +695,7 @@ static bool add_nondet_string_pointer_initialization(
692695 bool printable,
693696 symbol_table_baset &symbol_table,
694697 const source_locationt &loc,
698+ const irep_idt &function_id,
695699 code_blockt &code)
696700{
697701 const namespacet ns (symbol_table);
@@ -703,13 +707,14 @@ static bool add_nondet_string_pointer_initialization(
703707 return true ;
704708
705709 const exprt malloc_site =
706- allocate_dynamic_object_with_decl (expr, symbol_table, loc, code);
710+ allocate_dynamic_object_with_decl (expr, symbol_table, loc, function_id, code);
707711
708712 code.add (
709713 initialize_nondet_string_struct (
710714 dereference_exprt (malloc_site, struct_type),
711715 max_nondet_string_length,
712716 loc,
717+ function_id,
713718 symbol_table,
714719 printable));
715720 return false ;
@@ -862,6 +867,7 @@ void java_object_factoryt::gen_nondet_pointer_init(
862867 object_factory_parameters.string_printable ,
863868 symbol_table,
864869 loc,
870+ object_factory_parameters.function_id ,
865871 assignments);
866872 }
867873 else
@@ -967,7 +973,13 @@ symbol_exprt java_object_factoryt::gen_nondet_subtype_pointer_init(
967973 const pointer_typet &replacement_pointer,
968974 size_t depth)
969975{
970- symbolt new_symbol=new_tmp_symbol (symbol_table, loc, replacement_pointer);
976+ symbolt new_symbol = get_fresh_aux_symbol (
977+ replacement_pointer,
978+ id2string (object_factory_parameters.function_id ),
979+ " tmp_object_factory" ,
980+ loc,
981+ ID_java,
982+ symbol_table);
971983
972984 // Generate a new object into this new symbol
973985 gen_nondet_init (
@@ -1253,11 +1265,13 @@ void java_object_factoryt::allocate_nondet_length_array(
12531265 const exprt &max_length_expr,
12541266 const typet &element_type)
12551267{
1256- symbolt &length_sym=new_tmp_symbol (
1257- symbol_table,
1258- loc,
1268+ symbolt &length_sym = get_fresh_aux_symbol (
12591269 java_int_type (),
1260- " nondet_array_length" );
1270+ id2string (object_factory_parameters.function_id ),
1271+ " nondet_array_length" ,
1272+ loc,
1273+ ID_java,
1274+ symbol_table);
12611275 symbols_created.push_back (&length_sym);
12621276 const auto &length_sym_expr=length_sym.symbol_expr ();
12631277
@@ -1347,11 +1361,13 @@ void java_object_factoryt::gen_nondet_array_init(
13471361
13481362 // Interpose a new symbol, as the goto-symex stage can't handle array indexing
13491363 // via a cast.
1350- symbolt &array_init_symbol=new_tmp_symbol (
1351- symbol_table,
1352- loc,
1364+ symbolt &array_init_symbol = get_fresh_aux_symbol (
13531365 init_array_expr.type (),
1354- " array_data_init" );
1366+ id2string (object_factory_parameters.function_id ),
1367+ " array_data_init" ,
1368+ loc,
1369+ ID_java,
1370+ symbol_table);
13551371 symbols_created.push_back (&array_init_symbol);
13561372 const auto &array_init_symexpr=array_init_symbol.symbol_expr ();
13571373 codet data_assign=code_assignt (array_init_symexpr, init_array_expr);
@@ -1360,11 +1376,13 @@ void java_object_factoryt::gen_nondet_array_init(
13601376
13611377 // Emit init loop for(array_init_iter=0; array_init_iter!=array.length;
13621378 // ++array_init_iter) init(array[array_init_iter]);
1363- symbolt &counter=new_tmp_symbol (
1364- symbol_table,
1365- loc,
1379+ symbolt &counter = get_fresh_aux_symbol (
13661380 length_expr.type (),
1367- " array_init_iter" );
1381+ id2string (object_factory_parameters.function_id ),
1382+ " array_init_iter" ,
1383+ loc,
1384+ ID_java,
1385+ symbol_table);
13681386 symbols_created.push_back (&counter);
13691387 exprt counter_expr=counter.symbol_expr ();
13701388
0 commit comments