Skip to content

Commit ba7578d

Browse files
Make the string ids replacement look for function_application
This make it handle the cases where the function application is not directly the right hand side of the equation but may be deeper inside the expression.
1 parent 2fc646c commit ba7578d

File tree

1 file changed

+17
-5
lines changed

1 file changed

+17
-5
lines changed

src/solvers/strings/string_refinement.cpp

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -640,14 +640,26 @@ decision_proceduret::resultt string_refinementt::dec_solve()
640640
}
641641
#endif
642642

643-
log.debug() << "dec_solve: Replacing string ids in function applications"
643+
log.debug() << "dec_solve: Replacing string ids and simplifying arguments"
644+
" in function applications"
644645
<< messaget::eom;
645-
for(equal_exprt &eq : equations)
646+
for(equal_exprt &expr : equations)
646647
{
647-
if(can_cast_expr<function_application_exprt>(eq.rhs()))
648+
auto it = expr.depth_begin();
649+
while(it != expr.depth_end())
648650
{
649-
simplify(eq.rhs(), ns);
650-
string_id_symbol_resolve.replace_expr(eq.rhs());
651+
if(can_cast_expr<function_application_exprt>(*it))
652+
{
653+
// Simplification is required because the array pool may not realize
654+
// that an expression like
655+
// `(unsignedbv[16]*)((signedbv[8]*)&constarray[0] + 0)` is the
656+
// same pointer as `&constarray[0]
657+
simplify(it.mutate(), ns);
658+
string_id_symbol_resolve.replace_expr(it.mutate());
659+
it.next_sibling_or_parent();
660+
}
661+
else
662+
++it;
651663
}
652664
}
653665

0 commit comments

Comments
 (0)