Skip to content

Commit 9ff5303

Browse files
Make set_l1_indices return a renamedt
This carries the information about which renaming the expression has been through. This requires a change in symex_level1t::operator() so that it takes care of the non-empty level 2 case.
1 parent 4ac4b70 commit 9ff5303

File tree

3 files changed

+18
-15
lines changed

3 files changed

+18
-15
lines changed

src/goto-symex/goto_symex_state.cpp

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -242,17 +242,11 @@ renamedt<ssa_exprt, L0> goto_symex_statet::set_l0_indices(
242242
return level0(std::move(ssa_expr), ns, source.thread_nr);
243243
}
244244

245-
void goto_symex_statet::set_l1_indices(
246-
ssa_exprt &ssa_expr,
245+
renamedt<ssa_exprt, L1> goto_symex_statet::set_l1_indices(
246+
ssa_exprt ssa_expr,
247247
const namespacet &ns)
248248
{
249-
if(!ssa_expr.get_level_2().empty())
250-
return;
251-
if(!ssa_expr.get_level_1().empty())
252-
return;
253-
renamedt<ssa_exprt, L1> l1 =
254-
level1(level0(std::move(ssa_expr), ns, source.thread_nr));
255-
ssa_expr = l1.get();
249+
return level1(level0(std::move(ssa_expr), ns, source.thread_nr));
256250
}
257251

258252
void goto_symex_statet::set_l2_indices(
@@ -278,7 +272,10 @@ ssa_exprt goto_symex_statet::rename_ssa(ssa_exprt ssa, const namespacet &ns)
278272
ssa = ssa_l0.get();
279273
}
280274
else if(level == L1)
281-
set_l1_indices(ssa, ns);
275+
{
276+
const renamedt<ssa_exprt, L1> ssa_l1 = set_l1_indices(std::move(ssa), ns);
277+
ssa = ssa_l1.get();
278+
}
282279
else
283280
UNREACHABLE;
284281

@@ -313,7 +310,8 @@ exprt goto_symex_statet::rename(exprt expr, const namespacet &ns)
313310
}
314311
else if(level==L2)
315312
{
316-
set_l1_indices(ssa, ns);
313+
const renamedt<ssa_exprt, L1> ssa_l1 = set_l1_indices(std::move(ssa), ns);
314+
ssa = ssa_l1.get();
317315
rename<level>(expr.type(), ssa.get_identifier(), ns);
318316
ssa.update_type();
319317

@@ -564,8 +562,8 @@ void goto_symex_statet::rename_address(exprt &expr, const namespacet &ns)
564562
ssa_exprt &ssa=to_ssa_expr(expr);
565563

566564
// only do L1!
567-
set_l1_indices(ssa, ns);
568-
565+
const renamedt<ssa_exprt, L1> ssa_l1 = set_l1_indices(std::move(ssa), ns);
566+
ssa = ssa_l1.get();
569567
rename<level>(expr.type(), ssa.get_identifier(), ns);
570568
ssa.update_type();
571569
}

src/goto-symex/goto_symex_state.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ class goto_symex_statet final : public goto_statet
117117
renamedt<ssa_exprt, L0> set_l0_indices(ssa_exprt expr, const namespacet &ns);
118118

119119
/// Update level 0 and 1 values.
120-
void set_l1_indices(ssa_exprt &expr, const namespacet &ns);
120+
renamedt<ssa_exprt, L1> set_l1_indices(ssa_exprt expr, const namespacet &ns);
121121

122122
/// Update level 0, 1 and 2 values.
123123
void set_l2_indices(ssa_exprt &expr, const namespacet &ns);

src/goto-symex/renaming_level.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,13 @@ operator()(ssa_exprt ssa_expr, const namespacet &ns, unsigned thread_nr) const
4646
renamedt<ssa_exprt, L1> symex_level1t::
4747
operator()(renamedt<ssa_exprt, L0> l0_expr) const
4848
{
49-
if(!l0_expr.get().get_level_1().empty())
49+
if(!l0_expr.get().get_level_1().empty() ||
50+
!l0_expr.get().get_level_2().empty())
51+
{
52+
// TODO reaching here means the information that l0_expr was L1 or L2 has
53+
// TODO been lost somewhere during execution, which should be avoided
5054
return renamedt<ssa_exprt, L1>{std::move(l0_expr.value)};
55+
}
5156

5257
const irep_idt l0_name = l0_expr.get().get_l1_object_identifier();
5358

0 commit comments

Comments
 (0)