Skip to content

Commit 699f042

Browse files
Separate pointer/function substitutions in solver
We make the solver do two passes on the equations: there is now one pass just for pointer and array associations before substituting function applications.
1 parent 9ed2ead commit 699f042

File tree

2 files changed

+20
-6
lines changed

2 files changed

+20
-6
lines changed

src/solvers/refinement/string_constraint_generator_main.cpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -558,10 +558,6 @@ exprt string_constraint_generatort::add_axioms_for_function_application(
558558
res=add_axioms_for_intern(expr);
559559
else if(id==ID_cprover_string_format_func)
560560
res=add_axioms_for_format(expr);
561-
else if(id == ID_cprover_associate_array_to_pointer_func)
562-
res = associate_array_to_pointer(expr);
563-
else if(id == ID_cprover_associate_length_to_array_func)
564-
res = associate_length_to_array(expr);
565561
else if(id == ID_cprover_string_constrain_characters_func)
566562
res = add_axioms_for_constrain_characters(expr);
567563
else

src/solvers/refinement/string_refinement.cpp

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -283,6 +283,23 @@ static void substitute_function_applications_in_equations(
283283
eq.rhs() = substitute_function_applications(eq.rhs(), generator);
284284
}
285285

286+
/// Fill the array_pointer correspondence and replace the right hand sides of
287+
/// the corresponding equations
288+
static void make_char_array_pointer_associations(
289+
string_constraint_generatort &generator,
290+
std::vector<equal_exprt> &equations)
291+
{
292+
for(equal_exprt &eq : equations)
293+
{
294+
if(
295+
const auto fun_app =
296+
expr_try_dynamic_cast<function_application_exprt>(eq.rhs()))
297+
{
298+
if(const auto result = generator.make_array_pointer_association(*fun_app))
299+
eq.rhs() = *result;
300+
}
301+
}
302+
}
286303

287304
void replace_symbols_in_equations(
288305
const union_find_replacet &symbol_resolve,
@@ -658,6 +675,8 @@ decision_proceduret::resultt string_refinementt::dec_solve()
658675
string_id_symbol_resolve.replace_expr(eq.rhs());
659676
}
660677

678+
make_char_array_pointer_associations(generator, equations);
679+
661680
#ifdef DEBUG
662681
output_equations(debug(), equations, ns);
663682
#endif
@@ -671,8 +690,7 @@ decision_proceduret::resultt string_refinementt::dec_solve()
671690

672691
#ifdef DEBUG
673692
debug() << "dec_solve: arrays_of_pointers:" << eom;
674-
for(auto pair :
675-
generator.array_pointer_correspondance.get_arrays_of_pointers())
693+
for(auto pair : generator.array_pool.get_arrays_of_pointers())
676694
{
677695
debug() << " * " << from_expr(ns, "", pair.first) << "\t--> "
678696
<< from_expr(ns, "", pair.second) << " : "

0 commit comments

Comments
 (0)