Skip to content

Commit 2212cd6

Browse files
authored
Merge pull request #8448 from tautschnig/move-make_with_expr
Move make_with_expr to update_exprt
2 parents e08b025 + 1aa2d83 commit 2212cd6

File tree

4 files changed

+36
-27
lines changed

4 files changed

+36
-27
lines changed

src/util/expr_util.cpp

+1-27
Original file line numberDiff line numberDiff line change
@@ -68,33 +68,7 @@ exprt make_binary(const exprt &expr)
6868

6969
with_exprt make_with_expr(const update_exprt &src)
7070
{
71-
const exprt::operandst &designator=src.designator();
72-
PRECONDITION(!designator.empty());
73-
74-
with_exprt result{exprt{}, exprt{}, exprt{}};
75-
exprt *dest=&result;
76-
77-
for(const auto &expr : designator)
78-
{
79-
with_exprt tmp{exprt{}, exprt{}, exprt{}};
80-
81-
if(expr.id() == ID_index_designator)
82-
{
83-
tmp.where() = to_index_designator(expr).index();
84-
}
85-
else if(expr.id() == ID_member_designator)
86-
{
87-
// irep_idt component_name=
88-
// to_member_designator(*it).get_component_name();
89-
}
90-
else
91-
UNREACHABLE;
92-
93-
*dest=tmp;
94-
dest=&to_with_expr(*dest).new_value();
95-
}
96-
97-
return result;
71+
return src.make_with_expr();
9872
}
9973

10074
exprt is_not_zero(

src/util/expr_util.h

+1
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ bool is_assignable(const exprt &);
4141
exprt make_binary(const exprt &);
4242

4343
/// converts an update expr into a (possibly nested) with expression
44+
DEPRECATED(SINCE(2024, 9, 10, "use update_exprt::make_with_expr() instead"))
4445
with_exprt make_with_expr(const update_exprt &);
4546

4647
/// converts a scalar/float expression to C/C++ Booleans

src/util/std_expr.cpp

+31
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,37 @@ void let_exprt::validate(const exprt &expr, const validation_modet vm)
191191
}
192192
}
193193

194+
with_exprt update_exprt::make_with_expr() const
195+
{
196+
const exprt::operandst &designators = designator();
197+
PRECONDITION(!designators.empty());
198+
199+
with_exprt result{exprt{}, exprt{}, exprt{}};
200+
exprt *dest = &result;
201+
202+
for(const auto &expr : designators)
203+
{
204+
with_exprt tmp{exprt{}, exprt{}, exprt{}};
205+
206+
if(expr.id() == ID_index_designator)
207+
{
208+
tmp.where() = to_index_designator(expr).index();
209+
}
210+
else if(expr.id() == ID_member_designator)
211+
{
212+
// irep_idt component_name=
213+
// to_member_designator(*it).get_component_name();
214+
}
215+
else
216+
UNREACHABLE;
217+
218+
*dest = tmp;
219+
dest = &to_with_expr(*dest).new_value();
220+
}
221+
222+
return result;
223+
}
224+
194225
exprt binding_exprt::instantiate(const operandst &values) const
195226
{
196227
// number of values must match the number of bound variables

src/util/std_expr.h

+3
Original file line numberDiff line numberDiff line change
@@ -2698,6 +2698,9 @@ class update_exprt : public ternary_exprt
26982698
return op2();
26992699
}
27002700

2701+
/// converts an update expr into a (possibly nested) with expression
2702+
with_exprt make_with_expr() const;
2703+
27012704
static void check(
27022705
const exprt &expr,
27032706
const validation_modet vm = validation_modet::INVARIANT)

0 commit comments

Comments
 (0)