35
35
#include " java_root_class.h"
36
36
#include " generic_parameter_specialization_map_keys.h"
37
37
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
-
53
38
class java_object_factoryt
54
39
{
55
40
// / Every new variable initialized by the code emitted by the methods of this
@@ -195,6 +180,7 @@ exprt allocate_dynamic_object(
195
180
const typet &allocate_type,
196
181
symbol_table_baset &symbol_table,
197
182
const source_locationt &loc,
183
+ const irep_idt &function_id,
198
184
code_blockt &output_code,
199
185
std::vector<const symbolt *> &symbols_created,
200
186
bool cast_needed)
@@ -212,11 +198,13 @@ exprt allocate_dynamic_object(
212
198
// create a symbol for the malloc expression so we can initialize
213
199
// without having to do it potentially through a double-deref, which
214
200
// 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 (
218
202
pointer_type (allocate_type),
219
- " malloc_site" );
203
+ id2string (function_id),
204
+ " malloc_site" ,
205
+ loc,
206
+ ID_java,
207
+ symbol_table);
220
208
symbols_created.push_back (&malloc_sym);
221
209
code_assignt assign=code_assignt (malloc_sym.symbol_expr (), malloc_expr);
222
210
assign.add_source_location ()=loc;
@@ -253,6 +241,7 @@ exprt allocate_dynamic_object_with_decl(
253
241
const exprt &target_expr,
254
242
symbol_table_baset &symbol_table,
255
243
const source_locationt &loc,
244
+ const irep_idt &function_id,
256
245
code_blockt &output_code)
257
246
{
258
247
std::vector<const symbolt *> symbols_created;
@@ -263,6 +252,7 @@ exprt allocate_dynamic_object_with_decl(
263
252
allocate_type,
264
253
symbol_table,
265
254
loc,
255
+ function_id,
266
256
tmp_block,
267
257
symbols_created,
268
258
false );
@@ -306,7 +296,13 @@ exprt java_object_factoryt::allocate_object(
306
296
case allocation_typet::LOCAL:
307
297
case allocation_typet::GLOBAL:
308
298
{
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);
310
306
if (alloc_type==allocation_typet::GLOBAL)
311
307
aux_symbol.is_static_lifetime =true ;
312
308
symbols_created.push_back (&aux_symbol);
@@ -327,6 +323,7 @@ exprt java_object_factoryt::allocate_object(
327
323
allocate_type,
328
324
symbol_table,
329
325
loc,
326
+ object_factory_parameters.function_id ,
330
327
assignments,
331
328
symbols_created,
332
329
cast_needed);
@@ -569,6 +566,7 @@ codet initialize_nondet_string_struct(
569
566
const exprt &obj,
570
567
const std::size_t &max_nondet_string_length,
571
568
const source_locationt &loc,
569
+ const irep_idt &function_id,
572
570
symbol_table_baset &symbol_table,
573
571
bool printable)
574
572
{
@@ -608,8 +606,13 @@ codet initialize_nondet_string_struct(
608
606
{
609
607
// / \todo Refactor with make_nondet_string_expr
610
608
// 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);
613
616
const symbol_exprt length_expr = length_sym.symbol_expr ();
614
617
const side_effect_expr_nondett nondet_length (length_expr.type ());
615
618
code.add (code_declt (length_expr));
@@ -646,7 +649,7 @@ codet initialize_nondet_string_struct(
646
649
// data_expr = nondet(char[INFINITY]) // we use infinity for variable size
647
650
const dereference_exprt data_expr (data_pointer);
648
651
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);
650
653
code.add (code_assignt (data_expr, nondet_array));
651
654
652
655
struct_expr.copy_to_operands (length_expr);
@@ -692,6 +695,7 @@ static bool add_nondet_string_pointer_initialization(
692
695
bool printable,
693
696
symbol_table_baset &symbol_table,
694
697
const source_locationt &loc,
698
+ const irep_idt &function_id,
695
699
code_blockt &code)
696
700
{
697
701
const namespacet ns (symbol_table);
@@ -703,13 +707,14 @@ static bool add_nondet_string_pointer_initialization(
703
707
return true ;
704
708
705
709
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);
707
711
708
712
code.add (
709
713
initialize_nondet_string_struct (
710
714
dereference_exprt (malloc_site, struct_type),
711
715
max_nondet_string_length,
712
716
loc,
717
+ function_id,
713
718
symbol_table,
714
719
printable));
715
720
return false ;
@@ -862,6 +867,7 @@ void java_object_factoryt::gen_nondet_pointer_init(
862
867
object_factory_parameters.string_printable ,
863
868
symbol_table,
864
869
loc,
870
+ object_factory_parameters.function_id ,
865
871
assignments);
866
872
}
867
873
else
@@ -967,7 +973,13 @@ symbol_exprt java_object_factoryt::gen_nondet_subtype_pointer_init(
967
973
const pointer_typet &replacement_pointer,
968
974
size_t depth)
969
975
{
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);
971
983
972
984
// Generate a new object into this new symbol
973
985
gen_nondet_init (
@@ -1253,11 +1265,13 @@ void java_object_factoryt::allocate_nondet_length_array(
1253
1265
const exprt &max_length_expr,
1254
1266
const typet &element_type)
1255
1267
{
1256
- symbolt &length_sym=new_tmp_symbol (
1257
- symbol_table,
1258
- loc,
1268
+ symbolt &length_sym = get_fresh_aux_symbol (
1259
1269
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);
1261
1275
symbols_created.push_back (&length_sym);
1262
1276
const auto &length_sym_expr=length_sym.symbol_expr ();
1263
1277
@@ -1347,11 +1361,13 @@ void java_object_factoryt::gen_nondet_array_init(
1347
1361
1348
1362
// Interpose a new symbol, as the goto-symex stage can't handle array indexing
1349
1363
// 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 (
1353
1365
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);
1355
1371
symbols_created.push_back (&array_init_symbol);
1356
1372
const auto &array_init_symexpr=array_init_symbol.symbol_expr ();
1357
1373
codet data_assign=code_assignt (array_init_symexpr, init_array_expr);
@@ -1360,11 +1376,13 @@ void java_object_factoryt::gen_nondet_array_init(
1360
1376
1361
1377
// Emit init loop for(array_init_iter=0; array_init_iter!=array.length;
1362
1378
// ++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 (
1366
1380
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);
1368
1386
symbols_created.push_back (&counter);
1369
1387
exprt counter_expr=counter.symbol_expr ();
1370
1388
0 commit comments