Skip to content

Commit 9f62e4f

Browse files
Move levelt to renaming_level.h
This seems a more appropriate to find it, and we could use the levelt type for templates we will define in this file.
1 parent 659d220 commit 9f62e4f

12 files changed

+30
-33
lines changed

src/goto-instrument/accelerate/scratch_program.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ bool scratch_programt::check_sat(bool do_slice)
6969

7070
exprt scratch_programt::eval(const exprt &e)
7171
{
72-
return checker->get(symex_state->rename<goto_symex_statet::L2>(e, ns));
72+
return checker->get(symex_state->rename<L2>(e, ns));
7373
}
7474

7575
void scratch_programt::append(goto_programt::instructionst &new_instructions)

src/goto-symex/goto_symex_state.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -280,7 +280,7 @@ goto_symex_statet::rename_level1_ssa(ssa_exprt ssa, const namespacet &ns)
280280
return ssa;
281281
}
282282

283-
template <goto_symex_statet::levelt level>
283+
template <levelt level>
284284
exprt goto_symex_statet::rename(exprt expr, const namespacet &ns)
285285
{
286286
// rename all the symbols with their last known value
@@ -538,7 +538,7 @@ bool goto_symex_statet::l2_thread_write_encoding(
538538
return threads.size()>1;
539539
}
540540

541-
template <goto_symex_statet::levelt level>
541+
template <levelt level>
542542
void goto_symex_statet::rename_address(exprt &expr, const namespacet &ns)
543543
{
544544
if(expr.id()==ID_symbol &&
@@ -669,7 +669,7 @@ static bool requires_renaming(const typet &type, const namespacet &ns)
669669
return false;
670670
}
671671

672-
template <goto_symex_statet::levelt level>
672+
template <levelt level>
673673
void goto_symex_statet::rename(
674674
typet &type,
675675
const irep_idt &l1_identifier,

src/goto-symex/goto_symex_state.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -152,9 +152,6 @@ class goto_symex_statet final : public goto_statet
152152
symex_level0t level0;
153153
symex_level1t level1;
154154

155-
// Symex renaming levels.
156-
enum levelt { L0=0, L1=1, L2=2 };
157-
158155
/// Rewrites symbol expressions in \ref exprt, applying a suffix to each
159156
/// symbol reflecting its most recent version, which differs depending on
160157
/// which level you requested. Each level also updates its predecessors, so

src/goto-symex/renaming_level.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@ Author: Romain Brenguier, [email protected]
1818
#include <util/irep.h>
1919
#include <util/ssa_expr.h>
2020

21+
/// Symex renaming level names.
22+
enum levelt { L0=0, L1=1, L2=2 };
23+
2124
/// Wrapper for a \c current_names map, which maps each identifier to an SSA
2225
/// expression and a counter.
2326
/// This is extended by the different symex_level structures which are used

src/goto-symex/symex_assign.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@ void goto_symext::symex_assign_symbol(
212212
tmp_ssa_rhs.swap(ssa_rhs);
213213
}
214214

215-
exprt l2_rhs = state.rename<goto_symex_statet::L2>(std::move(ssa_rhs), ns);
215+
exprt l2_rhs = state.rename<L2>(std::move(ssa_rhs), ns);
216216
do_simplify(l2_rhs);
217217

218218
ssa_exprt ssa_lhs=lhs;
@@ -228,8 +228,7 @@ void goto_symext::symex_assign_symbol(
228228
ssa_full_lhs=add_to_lhs(ssa_full_lhs, ssa_lhs);
229229
const bool record_events=state.record_events;
230230
state.record_events=false;
231-
exprt l2_full_lhs =
232-
state.rename<goto_symex_statet::L2>(std::move(ssa_full_lhs), ns);
231+
exprt l2_full_lhs = state.rename<L2>(std::move(ssa_full_lhs), ns);
233232
state.record_events=record_events;
234233

235234
guardt tmp_guard(state.guard);
@@ -408,7 +407,7 @@ void goto_symext::symex_assign_if(
408407

409408
guardt old_guard=guard;
410409

411-
exprt renamed_guard = state.rename<goto_symex_statet::L2>(lhs.cond(), ns);
410+
exprt renamed_guard = state.rename<L2>(lhs.cond(), ns);
412411
do_simplify(renamed_guard);
413412

414413
if(!renamed_guard.is_false())

src/goto-symex/symex_builtin_functions.cpp

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ void goto_symext::symex_allocate(
7171
else
7272
{
7373
// to allow constant propagation
74-
exprt tmp_size = state.rename<goto_symex_statet::L2>(size, ns);
74+
exprt tmp_size = state.rename<L2>(size, ns);
7575
simplify(tmp_size, ns);
7676

7777
// special treatment for sizeof(T)*x
@@ -163,7 +163,7 @@ void goto_symext::symex_allocate(
163163
state.symbol_table.add(value_symbol);
164164

165165
// to allow constant propagation
166-
exprt zero_init = state.rename<goto_symex_statet::L2>(code.op1(), ns);
166+
exprt zero_init = state.rename<L2>(code.op1(), ns);
167167
simplify(zero_init, ns);
168168

169169
INVARIANT(
@@ -232,7 +232,7 @@ void goto_symext::symex_gcc_builtin_va_arg_next(
232232
return; // ignore
233233

234234
// to allow constant propagation
235-
exprt tmp = state.rename<goto_symex_statet::L2>(code.op0(), ns);
235+
exprt tmp = state.rename<L2>(code.op0(), ns);
236236
do_simplify(tmp);
237237
irep_idt id=get_symbol(tmp);
238238

@@ -309,7 +309,7 @@ void goto_symext::symex_printf(
309309
{
310310
PRECONDITION(!rhs.operands().empty());
311311

312-
exprt tmp_rhs = state.rename<goto_symex_statet::L2>(rhs, ns);
312+
exprt tmp_rhs = state.rename<L2>(rhs, ns);
313313
do_simplify(tmp_rhs);
314314

315315
const exprt::operandst &operands = tmp_rhs.operands();
@@ -333,14 +333,14 @@ void goto_symext::symex_input(
333333
{
334334
PRECONDITION(code.operands().size() >= 2);
335335

336-
exprt id_arg = state.rename<goto_symex_statet::L2>(code.op0(), ns);
336+
exprt id_arg = state.rename<L2>(code.op0(), ns);
337337

338338
std::list<exprt> args;
339339

340340
for(std::size_t i=1; i<code.operands().size(); i++)
341341
{
342342
args.push_back(code.operands()[i]);
343-
exprt l2_arg = state.rename<goto_symex_statet::L2>(args.back(), ns);
343+
exprt l2_arg = state.rename<L2>(args.back(), ns);
344344
do_simplify(l2_arg);
345345
args.back() = std::move(l2_arg);
346346
}
@@ -355,14 +355,14 @@ void goto_symext::symex_output(
355355
const codet &code)
356356
{
357357
PRECONDITION(code.operands().size() >= 2);
358-
exprt id_arg = state.rename<goto_symex_statet::L2>(code.op0(), ns);
358+
exprt id_arg = state.rename<L2>(code.op0(), ns);
359359

360360
std::list<exprt> args;
361361

362362
for(std::size_t i=1; i<code.operands().size(); i++)
363363
{
364364
args.push_back(code.operands()[i]);
365-
exprt l2_arg = state.rename<goto_symex_statet::L2>(args.back(), ns);
365+
exprt l2_arg = state.rename<L2>(args.back(), ns);
366366
do_simplify(l2_arg);
367367
args.back() = std::move(l2_arg);
368368
}
@@ -475,8 +475,7 @@ void goto_symext::symex_trace(
475475
irep_idt event = to_string_constant(code.arguments()[1].op0()).get_value();
476476

477477
for(std::size_t j=2; j<code.arguments().size(); j++)
478-
vars.push_back(
479-
state.rename<goto_symex_statet::L2>(code.arguments()[j], ns));
478+
vars.push_back(state.rename<L2>(code.arguments()[j], ns));
480479

481480
target.output(state.guard.as_expr(), state.source, event, vars);
482481
}

src/goto-symex/symex_dead.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,7 @@ void goto_symext::symex_dead(statet &state)
3737
else
3838
rhs=exprt(ID_invalid);
3939

40-
const exprt l1_rhs =
41-
state.rename<goto_symex_statet::L1>(std::move(rhs), ns);
40+
const exprt l1_rhs = state.rename<L1>(std::move(rhs), ns);
4241
state.value_set.assign(ssa, l1_rhs, ns, true, false);
4342
}
4443

src/goto-symex/symex_decl.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ void goto_symext::symex_decl(statet &state, const symbol_exprt &expr)
4141
const irep_idt &l1_identifier = ssa.get_identifier();
4242

4343
// rename type to L2
44-
state.rename<goto_symex_statet::L2>(ssa.type(), l1_identifier, ns);
44+
state.rename<L2>(ssa.type(), l1_identifier, ns);
4545
ssa.update_type();
4646

4747
// in case of pointers, put something into the value set
@@ -53,7 +53,7 @@ void goto_symext::symex_decl(statet &state, const symbol_exprt &expr)
5353
else
5454
rhs=exprt(ID_invalid);
5555

56-
exprt l1_rhs = state.rename<goto_symex_statet::L1>(std::move(rhs), ns);
56+
exprt l1_rhs = state.rename<L1>(std::move(rhs), ns);
5757
state.value_set.assign(ssa, l1_rhs, ns, true, false);
5858
}
5959

@@ -69,7 +69,7 @@ void goto_symext::symex_decl(statet &state, const symbol_exprt &expr)
6969
symex_renaming_levelt::increase_counter(level2_it);
7070
const bool record_events=state.record_events;
7171
state.record_events=false;
72-
exprt expr_l2 = state.rename<statet::L2>(std::move(ssa), ns);
72+
exprt expr_l2 = state.rename<L2>(std::move(ssa), ns);
7373
INVARIANT(
7474
expr_l2.id() == ID_symbol && expr_l2.get_bool(ID_C_SSA_symbol),
7575
"symbol to declare should not be replaced by constant propagation");

src/goto-symex/symex_dereference.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -357,11 +357,11 @@ void goto_symext::dereference(exprt &expr, statet &state)
357357
// from different frames. Would be enough to rename
358358
// symbols whose address is taken.
359359
PRECONDITION(!state.call_stack().empty());
360-
exprt l1_expr = state.rename<goto_symex_statet::L1>(expr, ns);
360+
exprt l1_expr = state.rename<L1>(expr, ns);
361361

362362
// start the recursion!
363363
dereference_rec(l1_expr, state);
364364
// dereferencing may introduce new symbol_exprt
365365
// (like __CPROVER_memory)
366-
expr = state.rename<goto_symex_statet::L1>(std::move(l1_expr), ns);
366+
expr = state.rename<L1>(std::move(l1_expr), ns);
367367
}

src/goto-symex/symex_function_call.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,7 @@ void goto_symext::symex_function_call_code(
261261
// read the arguments -- before the locality renaming
262262
exprt::operandst arguments = call.arguments();
263263
for(auto &a : arguments)
264-
a = state.rename<statet::L2>(std::move(a), ns);
264+
a = state.rename<L2>(std::move(a), ns);
265265

266266
// we hide the call if the caller and callee are both hidden
267267
const bool hidden = state.top().hidden_function && goto_function.is_hidden();

src/goto-symex/symex_goto.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ void goto_symext::symex_goto(statet &state)
3737
exprt old_guard = instruction.get_condition();
3838
clean_expr(old_guard, state, false);
3939

40-
exprt new_guard = state.rename<goto_symex_statet::L2>(old_guard, ns);
40+
exprt new_guard = state.rename<L2>(old_guard, ns);
4141
do_simplify(new_guard);
4242

4343
if(new_guard.is_false())
@@ -268,7 +268,7 @@ void goto_symext::symex_goto(statet &state)
268268
original_source,
269269
symex_targett::assignment_typet::GUARD);
270270

271-
guard_expr = state.rename<goto_symex_statet::L2>(
271+
guard_expr = state.rename<L2>(
272272
boolean_negate(guard_symbol_expr), ns);
273273
}
274274

src/goto-symex/symex_main.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ void goto_symext::vcc(
9595
}
9696

9797
// now rename, enables propagation
98-
exprt l2_expr = state.rename<goto_symex_statet::L2>(std::move(expr), ns);
98+
exprt l2_expr = state.rename<L2>(std::move(expr), ns);
9999

100100
// now try simplifier on it
101101
do_simplify(l2_expr);
@@ -411,7 +411,7 @@ void goto_symext::symex_step(
411411
exprt tmp = instruction.get_condition();
412412
clean_expr(tmp, state, false);
413413
symex_assume(
414-
state, state.rename<goto_symex_statet::L2>(std::move(tmp), ns));
414+
state, state.rename<L2>(std::move(tmp), ns));
415415
}
416416

417417
symex_transition(state);

0 commit comments

Comments
 (0)