Skip to content

Commit 48024c7

Browse files
committed
Replace function applications: don't break irep sharing
Previously this always broke sharing; now it only does it to equations that involve string functions.
1 parent 86bf547 commit 48024c7

File tree

1 file changed

+16
-11
lines changed

1 file changed

+16
-11
lines changed

src/solvers/refinement/string_refinement.cpp

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -257,18 +257,23 @@ static std::vector<exprt> generate_instantiations(
257257
/// \param expr: an expression possibly containing function applications
258258
/// \param generator: generator for the string constraints
259259
/// \return an expression containing no function application
260-
static exprt substitute_function_applications(
261-
exprt expr,
260+
static void substitute_function_applications(
261+
exprt &expr,
262262
string_constraint_generatort &generator)
263263
{
264-
for(auto &operand : expr.operands())
265-
operand = substitute_function_applications(operand, generator);
266-
267-
if(expr.id() == ID_function_application)
268-
return generator.add_axioms_for_function_application(
269-
to_function_application_expr(expr));
270-
271-
return expr;
264+
for(auto it = expr.depth_begin(), itend = expr.depth_end();
265+
it != itend;) // No ++it
266+
{
267+
if(it->id() == ID_function_application)
268+
{
269+
it.mutate() =
270+
generator.add_axioms_for_function_application(
271+
to_function_application_expr(expr));
272+
it.next_sibling_or_parent();
273+
}
274+
else
275+
++it;
276+
}
272277
}
273278

274279
/// Remove functions applications and create the necessary axioms.
@@ -280,7 +285,7 @@ static void substitute_function_applications_in_equations(
280285
string_constraint_generatort &generator)
281286
{
282287
for(auto &eq : equations)
283-
eq.rhs() = substitute_function_applications(eq.rhs(), generator);
288+
substitute_function_applications(eq.rhs(), generator);
284289
}
285290

286291
/// For now, any unsigned bitvector type of width smaller or equal to 16 is

0 commit comments

Comments
 (0)