12
12
#include " goto_convert_class.h"
13
13
14
14
#include < util/arith_tools.h>
15
+ #include < util/cprover_prefix.h>
15
16
#include < util/expr_util.h>
17
+ #include < util/fresh_symbol.h>
16
18
#include < util/std_expr.h>
17
- #include < util/rename.h>
18
- #include < util/cprover_prefix.h>
19
19
#include < util/symbol.h>
20
20
21
21
#include < util/c_types.h>
@@ -351,12 +351,6 @@ void goto_convertt::remove_function_call(
351
351
return ;
352
352
}
353
353
354
- auxiliary_symbolt new_symbol;
355
-
356
- new_symbol.base_name =" return_value" ;
357
- new_symbol.type =expr.type ();
358
- new_symbol.location =expr.find_source_location ();
359
-
360
354
// get name of function, if available
361
355
362
356
if (expr.id ()!=ID_side_effect ||
@@ -374,25 +368,26 @@ void goto_convertt::remove_function_call(
374
368
throw 0 ;
375
369
}
376
370
371
+ std::string new_base_name = " return_value" ;
372
+ irep_idt new_symbol_mode = mode;
373
+
377
374
if (expr.op0 ().id ()==ID_symbol)
378
375
{
379
376
const irep_idt &identifier=expr.op0 ().get (ID_identifier);
380
- const symbolt &symbol=lookup (identifier);
381
-
382
- std::string new_base_name=id2string (new_symbol.base_name );
377
+ const symbolt &symbol = ns.lookup (identifier);
383
378
384
379
new_base_name+=' _' ;
385
380
new_base_name+=id2string (symbol.base_name );
386
- new_base_name += " $0" ;
387
-
388
- new_symbol.base_name =new_base_name;
389
- new_symbol.mode =symbol.mode ;
381
+ new_symbol_mode = symbol.mode ;
390
382
}
391
383
392
- new_symbol.name =tmp_symbol_prefix+id2string (new_symbol.base_name );
393
-
394
- // ensure that the name is unique
395
- new_name (new_symbol);
384
+ const symbolt &new_symbol = get_fresh_aux_symbol (
385
+ expr.type (),
386
+ tmp_symbol_prefix,
387
+ new_base_name,
388
+ expr.find_source_location (),
389
+ new_symbol_mode,
390
+ symbol_table);
396
391
397
392
{
398
393
code_declt decl;
@@ -432,15 +427,13 @@ void goto_convertt::remove_cpp_new(
432
427
{
433
428
codet call;
434
429
435
- auxiliary_symbolt new_symbol;
436
-
437
- new_symbol.base_name = " new_ptr$0" ;
438
- new_symbol.type =expr.type ();
439
- new_symbol.name =tmp_symbol_prefix+id2string (new_symbol.base_name );
440
- new_symbol.mode = ID_cpp;
441
-
442
- // ensure that the name is unique
443
- new_name (new_symbol);
430
+ const symbolt &new_symbol = get_fresh_aux_symbol (
431
+ expr.type (),
432
+ tmp_symbol_prefix,
433
+ " new_ptr" ,
434
+ expr.find_source_location (),
435
+ ID_cpp,
436
+ symbol_table);
444
437
445
438
code_declt decl;
446
439
decl.symbol ()=new_symbol.symbol_expr ();
@@ -486,19 +479,15 @@ void goto_convertt::remove_malloc(
486
479
487
480
if (result_is_used)
488
481
{
489
- auxiliary_symbolt new_symbol;
490
-
491
- new_symbol. base_name = " malloc_value$0 " ;
492
- new_symbol. type =expr. type ();
493
- new_symbol. name =tmp_symbol_prefix+ id2string (new_symbol. base_name );
494
- new_symbol. location =expr. source_location ();
495
- new_symbol. mode = mode ;
482
+ const symbolt & new_symbol = get_fresh_aux_symbol (
483
+ expr. type (),
484
+ tmp_symbol_prefix,
485
+ " malloc_value " ,
486
+ expr. source_location (),
487
+ mode,
488
+ symbol_table) ;
496
489
497
- // ensure that the name is unique
498
- new_name (new_symbol);
499
-
500
- code_declt decl;
501
- decl.symbol ()=new_symbol.symbol_expr ();
490
+ code_declt decl (new_symbol.symbol_expr ());
502
491
decl.add_source_location ()=new_symbol.location ;
503
492
convert_decl (decl, dest, mode);
504
493
0 commit comments