Skip to content

Commit 4215f21

Browse files
committed
Consistently use get_fresh_aux_symbol instead of local implementations
1 parent e6cd488 commit 4215f21

File tree

5 files changed

+37
-62
lines changed

5 files changed

+37
-62
lines changed

src/goto-programs/goto_convert.cpp

-9
Original file line numberDiff line numberDiff line change
@@ -2058,15 +2058,6 @@ void goto_convertt::make_temp_symbol(
20582058
expr=new_symbol.symbol_expr();
20592059
}
20602060

2061-
void goto_convertt::new_name(symbolt &symbol)
2062-
{
2063-
// rename it
2064-
get_new_name(symbol, ns);
2065-
2066-
// store in symbol_table
2067-
symbol_table.add(symbol);
2068-
}
2069-
20702061
void goto_convert(
20712062
const codet &code,
20722063
symbol_table_baset &symbol_table,

src/goto-programs/goto_convert_class.h

-2
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,6 @@ class goto_convertt:public messaget
5656
//
5757
// tools for symbols
5858
//
59-
void new_name(symbolt &symbol);
60-
6159
symbolt &new_tmp_symbol(
6260
const typet &type,
6361
const std::string &suffix,

src/goto-programs/goto_convert_functions.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ void goto_convert_functionst::convert_function(
147147
return; // already converted
148148

149149
// make tmp variables local to function
150-
tmp_symbol_prefix=id2string(symbol.name)+"::$tmp::";
150+
tmp_symbol_prefix=id2string(symbol.name)+"::$tmp";
151151

152152
f.type=to_code_type(symbol.type);
153153

src/goto-programs/goto_convert_side_effect.cpp

+28-39
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@ Author: Daniel Kroening, [email protected]
1212
#include "goto_convert_class.h"
1313

1414
#include <util/arith_tools.h>
15+
#include <util/cprover_prefix.h>
1516
#include <util/expr_util.h>
17+
#include <util/fresh_symbol.h>
1618
#include <util/std_expr.h>
17-
#include <util/rename.h>
18-
#include <util/cprover_prefix.h>
1919
#include <util/symbol.h>
2020

2121
#include <util/c_types.h>
@@ -351,12 +351,6 @@ void goto_convertt::remove_function_call(
351351
return;
352352
}
353353

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-
360354
// get name of function, if available
361355

362356
if(expr.id()!=ID_side_effect ||
@@ -374,25 +368,26 @@ void goto_convertt::remove_function_call(
374368
throw 0;
375369
}
376370

371+
std::string new_base_name = "return_value";
372+
irep_idt new_symbol_mode = mode;
373+
377374
if(expr.op0().id()==ID_symbol)
378375
{
379376
const irep_idt &identifier=expr.op0().get(ID_identifier);
380377
const symbolt &symbol = ns.lookup(identifier);
381378

382-
std::string new_base_name=id2string(new_symbol.base_name);
383-
384379
new_base_name+='_';
385380
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;
390382
}
391383

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);
396391

397392
{
398393
code_declt decl;
@@ -432,15 +427,13 @@ void goto_convertt::remove_cpp_new(
432427
{
433428
codet call;
434429

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);
444437

445438
code_declt decl;
446439
decl.symbol()=new_symbol.symbol_expr();
@@ -486,19 +479,15 @@ void goto_convertt::remove_malloc(
486479

487480
if(result_is_used)
488481
{
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);
496489

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());
502491
decl.add_source_location()=new_symbol.location;
503492
convert_decl(decl, dest, mode);
504493

src/pointer-analysis/value_set_dereference.cpp

+8-11
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,11 @@ Author: Daniel Kroening, [email protected]
2424
#include <util/config.h>
2525
#include <util/cprover_prefix.h>
2626
#include <util/format_type.h>
27+
#include <util/fresh_symbol.h>
2728
#include <util/guard.h>
2829
#include <util/options.h>
2930
#include <util/pointer_offset_size.h>
3031
#include <util/pointer_predicates.h>
31-
#include <util/rename.h>
3232
#include <util/ssa_expr.h>
3333

3434
#include <ansi-c/c_typecast.h>
@@ -148,22 +148,19 @@ exprt value_set_dereferencet::dereference(
148148
else
149149
{
150150
// else: produce new symbol
151-
152-
symbolt symbol;
153-
symbol.name="symex::invalid_object"+std::to_string(invalid_counter++);
154-
symbol.base_name="invalid_object";
155-
symbol.type=type;
156-
symbol.mode = language_mode;
151+
symbolt &symbol = get_fresh_aux_symbol(
152+
type,
153+
"symex",
154+
"invalid_object",
155+
pointer.source_location(),
156+
language_mode,
157+
new_symbol_table);
157158

158159
// make it a lvalue, so we can assign to it
159160
symbol.is_lvalue=true;
160161

161-
get_new_name(symbol, ns);
162-
163162
failure_value=symbol.symbol_expr();
164163
failure_value.set(ID_C_invalid_object, true);
165-
166-
new_symbol_table.insert(std::move(symbol));
167164
}
168165

169166
valuet value;

0 commit comments

Comments
 (0)