Skip to content

Commit 70da606

Browse files
authored
Merge pull request diffblue#2251 from tautschnig/rename-cleanup
Cleanup of uses of get_new_name
2 parents 49429cf + 4215f21 commit 70da606

14 files changed

+39
-93
lines changed

src/goto-instrument/accelerate/acceleration_utils.cpp

-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ Author: Matt Lewis
3636
#include <util/std_expr.h>
3737
#include <util/std_code.h>
3838
#include <util/find_symbols.h>
39-
#include <util/rename.h>
4039
#include <util/simplify_expr.h>
4140
#include <util/replace_expr.h>
4241
#include <util/arith_tools.h>

src/goto-instrument/accelerate/disjunctive_polynomial_acceleration.cpp

-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ Author: Matt Lewis
3636
#include <util/std_expr.h>
3737
#include <util/std_code.h>
3838
#include <util/find_symbols.h>
39-
#include <util/rename.h>
4039
#include <util/simplify_expr.h>
4140
#include <util/replace_expr.h>
4241
#include <util/arith_tools.h>

src/goto-instrument/accelerate/polynomial_accelerator.cpp

-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ Author: Matt Lewis
3333
#include <util/std_expr.h>
3434
#include <util/std_code.h>
3535
#include <util/find_symbols.h>
36-
#include <util/rename.h>
3736
#include <util/simplify_expr.h>
3837
#include <util/replace_expr.h>
3938
#include <util/arith_tools.h>

src/goto-instrument/accelerate/sat_path_enumerator.cpp

-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ Author: Matt Lewis
3636
#include <util/std_expr.h>
3737
#include <util/std_code.h>
3838
#include <util/find_symbols.h>
39-
#include <util/rename.h>
4039
#include <util/simplify_expr.h>
4140
#include <util/replace_expr.h>
4241
#include <util/arith_tools.h>

src/goto-programs/goto_clean_expr.cpp

-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ Author: Daniel Kroening, [email protected]
1414
#include <util/fresh_symbol.h>
1515
#include <util/simplify_expr.h>
1616
#include <util/std_expr.h>
17-
#include <util/rename.h>
1817
#include <util/cprover_prefix.h>
1918

2019
#include <util/c_types.h>

src/goto-programs/goto_convert.cpp

+1-22
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ Author: Daniel Kroening, [email protected]
2020
#include <util/std_expr.h>
2121
#include <util/symbol_table.h>
2222
#include <util/simplify_expr.h>
23-
#include <util/rename.h>
2423

2524
#include <util/c_types.h>
2625

@@ -669,7 +668,7 @@ void goto_convertt::convert_decl(
669668

670669
const irep_idt &identifier=op0.get(ID_identifier);
671670

672-
const symbolt &symbol=lookup(identifier);
671+
const symbolt &symbol = ns.lookup(identifier);
673672

674673
if(symbol.is_static_lifetime ||
675674
symbol.type.id()==ID_code)
@@ -2059,26 +2058,6 @@ void goto_convertt::make_temp_symbol(
20592058
expr=new_symbol.symbol_expr();
20602059
}
20612060

2062-
void goto_convertt::new_name(symbolt &symbol)
2063-
{
2064-
// rename it
2065-
get_new_name(symbol, ns);
2066-
2067-
// store in symbol_table
2068-
symbol_table.add(symbol);
2069-
}
2070-
2071-
const symbolt &goto_convertt::lookup(const irep_idt &identifier)
2072-
{
2073-
const symbolt *symbol;
2074-
if(ns.lookup(identifier, symbol))
2075-
{
2076-
error() << "failed to find symbol " << identifier << eom;
2077-
throw 0;
2078-
}
2079-
return *symbol;
2080-
}
2081-
20822061
void goto_convert(
20832062
const codet &code,
20842063
symbol_table_baset &symbol_table,

src/goto-programs/goto_convert_class.h

-3
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,6 @@ class goto_convertt:public messaget
5656
//
5757
// tools for symbols
5858
//
59-
void new_name(symbolt &symbol);
60-
const symbolt &lookup(const irep_idt &identifier);
61-
6259
symbolt &new_tmp_symbol(
6360
const typet &type,
6461
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

+29-40
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);
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);
383378

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/goto-symex/goto_symex.h

-2
Original file line numberDiff line numberDiff line change
@@ -232,8 +232,6 @@ class goto_symext
232232

233233
friend class symex_dereference_statet;
234234

235-
void new_name(symbolt &symbol, statet &state);
236-
237235
// this does the following:
238236
// a) rename non-det choices
239237
// b) remove pointer dereferencing

src/goto-symex/symex_dead.cpp

-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ Author: Daniel Kroening, [email protected]
1313

1414
#include <cassert>
1515

16-
#include <util/rename.h>
1716
#include <util/std_expr.h>
1817

1918
#include <pointer-analysis/add_failed_symbols.h>

src/goto-symex/symex_decl.cpp

-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ Author: Daniel Kroening, [email protected]
1313

1414
#include <cassert>
1515

16-
#include <util/rename.h>
1716
#include <util/std_expr.h>
1817

1918
#include <pointer-analysis/add_failed_symbols.h>

src/goto-symex/symex_main.cpp

-7
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ Author: Daniel Kroening, [email protected]
1515
#include <memory>
1616

1717
#include <util/std_expr.h>
18-
#include <util/rename.h>
1918
#include <util/symbol_table.h>
2019
#include <util/replace_symbol.h>
2120
#include <util/make_unique.h>
@@ -46,12 +45,6 @@ void goto_symext::symex_transition(
4645
state.source.pc=to;
4746
}
4847

49-
void goto_symext::new_name(symbolt &symbol, statet &state)
50-
{
51-
get_new_name(symbol, ns);
52-
state.symbol_table.add(symbol);
53-
}
54-
5548
void goto_symext::vcc(
5649
const exprt &vcc_expr,
5750
const std::string &msg,

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)