Skip to content

Commit 8edb3a1

Browse files
Make get_original_name return the expression
This avoids having an input that is also an output and make the calls to get_original_name clearer.
1 parent 1fd40af commit 8edb3a1

File tree

6 files changed

+23
-21
lines changed

6 files changed

+23
-21
lines changed

src/goto-symex/postcondition.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -130,8 +130,8 @@ void postconditiont::strengthen(exprt &dest)
130130
SSA_step.ssa_lhs.type().id()==ID_struct)
131131
return;
132132

133-
equal_exprt equality(SSA_step.ssa_lhs, SSA_step.ssa_rhs);
134-
get_original_name(equality);
133+
exprt equality =
134+
get_original_name(equal_exprt{SSA_step.ssa_lhs, SSA_step.ssa_rhs});
135135

136136
if(dest.is_true())
137137
dest.swap(equality);
@@ -169,8 +169,7 @@ bool postconditiont::is_used(
169169
it!=expr_set.end();
170170
it++)
171171
{
172-
exprt tmp(*it);
173-
get_original_name(tmp);
172+
const exprt tmp = get_original_name(*it);
174173
find_symbols(tmp, symbols);
175174
}
176175

src/goto-symex/precondition.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -140,8 +140,7 @@ void preconditiont::compute_rec(exprt &dest)
140140
}
141141
else if(dest==SSA_step.ssa_lhs.get_original_expr())
142142
{
143-
dest=SSA_step.ssa_rhs;
144-
get_original_name(dest);
143+
dest = get_original_name(SSA_step.ssa_rhs);
145144
}
146145
else
147146
Forall_operands(it, dest)

src/goto-symex/renaming_level.cpp

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -91,37 +91,42 @@ void symex_level1t::restore_from(const current_namest &other)
9191
}
9292
}
9393

94-
void get_original_name(exprt &expr)
94+
exprt get_original_name(exprt expr)
9595
{
96-
get_original_name(expr.type());
96+
expr.type() = get_original_name(std::move(expr.type()));
9797

9898
if(expr.id() == ID_symbol && expr.get_bool(ID_C_SSA_symbol))
99-
expr = to_ssa_expr(expr).get_original_expr();
99+
return to_ssa_expr(expr).get_original_expr();
100100
else
101+
{
101102
Forall_operands(it, expr)
102-
get_original_name(*it);
103+
*it = get_original_name(std::move(*it));
104+
return expr;
105+
}
103106
}
104107

105-
void get_original_name(typet &type)
108+
typet get_original_name(typet type)
106109
{
107110
// rename all the symbols with their last known value
108111

109112
if(type.id() == ID_array)
110113
{
111114
auto &array_type = to_array_type(type);
112-
get_original_name(array_type.subtype());
113-
get_original_name(array_type.size());
115+
array_type.subtype() = get_original_name(std::move(array_type.subtype()));
116+
array_type.size() = get_original_name(std::move(array_type.size()));
114117
}
115118
else if(type.id() == ID_struct || type.id() == ID_union)
116119
{
117120
struct_union_typet &s_u_type = to_struct_union_type(type);
118121
struct_union_typet::componentst &components = s_u_type.components();
119122

120123
for(auto &component : components)
121-
get_original_name(component.type());
124+
component.type() = get_original_name(std::move(component.type()));
122125
}
123126
else if(type.id() == ID_pointer)
124127
{
125-
get_original_name(to_pointer_type(type).subtype());
128+
type.subtype() =
129+
get_original_name(std::move(to_pointer_type(type).subtype()));
126130
}
131+
return type;
127132
}

src/goto-symex/renaming_level.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -148,9 +148,9 @@ struct symex_level2t : public symex_renaming_levelt
148148
};
149149

150150
/// Undo all levels of renaming
151-
void get_original_name(exprt &expr);
151+
exprt get_original_name(exprt expr);
152152

153153
/// Undo all levels of renaming
154-
void get_original_name(typet &type);
154+
typet get_original_name(typet type);
155155

156156
#endif // CPROVER_GOTO_SYMEX_RENAMING_LEVEL_H

src/goto-symex/symex_assign.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -491,8 +491,7 @@ void goto_symext::symex_assign_symbol(
491491
// Temporarily add the state guard
492492
guard.emplace_back(state.guard.as_expr());
493493

494-
exprt original_lhs = l2_full_lhs;
495-
get_original_name(original_lhs);
494+
const exprt original_lhs = get_original_name(l2_full_lhs);
496495
target.assignment(
497496
conjunction(guard),
498497
l2_lhs,

src/goto-symex/symex_dereference.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -202,15 +202,15 @@ void goto_symext::dereference_rec(exprt &expr, statet &state, bool write)
202202
{
203203
if(expr.id()==ID_dereference)
204204
{
205-
dereference_exprt to_check = to_dereference_expr(expr);
206205
bool expr_is_not_null = false;
207206

208207
if(state.threads.size() == 1)
209208
{
210209
const irep_idt &expr_function = state.source.function_id;
211210
if(!expr_function.empty())
212211
{
213-
get_original_name(to_check);
212+
const dereference_exprt to_check =
213+
to_dereference_expr(get_original_name(expr));
214214

215215
expr_is_not_null = path_storage.safe_pointers.at(expr_function)
216216
.is_safe_dereference(to_check, state.source.pc);

0 commit comments

Comments
 (0)