Skip to content

Commit ab537ef

Browse files
Correct the way symbol_resolve is computed
The data should be kept between calls to dec_solve because the set of equations from the last call are not recorded.
1 parent 64379dd commit ab537ef

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

src/solvers/refinement/string_refinement.cpp

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -301,20 +301,22 @@ void string_refinementt::set_to(const exprt &expr, bool value)
301301
}
302302

303303
/// Add association for each char pointer in the equation
304+
/// \param symbol_solver: a union_find_replacet object to keep track of
305+
/// char pointer equations
304306
/// \param equations: vector of equations
305307
/// \param ns: namespace
306308
/// \param stream: output stream
307309
/// \return union_find_replacet where char pointer that have been set equal
308310
/// by an equation are associated to the same element
309-
static union_find_replacet generate_symbol_resolution_from_equations(
311+
static void add_equations_for_symbol_resolution(
312+
union_find_replacet &symbol_solver,
310313
const std::vector<equal_exprt> &equations,
311314
const namespacet &ns,
312315
messaget::mstreamt &stream)
313316
{
314317
const auto eom = messaget::eom;
315318
const std::string log_message =
316319
"WARNING string_refinement.cpp generate_symbol_resolution_from_equations:";
317-
union_find_replacet solver;
318320
for(const equal_exprt &eq : equations)
319321
{
320322
const exprt &lhs = eq.lhs();
@@ -335,7 +337,7 @@ static union_find_replacet generate_symbol_resolution_from_equations(
335337

336338
if(is_char_pointer_type(rhs.type()))
337339
{
338-
solver.make_union(lhs, rhs);
340+
symbol_solver.make_union(lhs, rhs);
339341
}
340342
else if(rhs.id() == ID_function_application)
341343
{
@@ -355,7 +357,7 @@ static union_find_replacet generate_symbol_resolution_from_equations(
355357
const member_exprt lhs_data(lhs, comp.get_name(), comp.type());
356358
const exprt rhs_data = simplify_expr(
357359
member_exprt(rhs, comp.get_name(), comp.type()), ns);
358-
solver.make_union(lhs_data, rhs_data);
360+
symbol_solver.make_union(lhs_data, rhs_data);
359361
}
360362
}
361363
}
@@ -366,7 +368,6 @@ static union_find_replacet generate_symbol_resolution_from_equations(
366368
}
367369
}
368370
}
369-
return solver;
370371
}
371372

372373
/// This is meant to be used on the lhs of an equation with string subtype.
@@ -613,9 +614,9 @@ decision_proceduret::resultt string_refinementt::dec_solve()
613614
#endif
614615

615616
debug() << "dec_solve: Build symbol solver from equations" << eom;
616-
// This is used by get, that's why we use a class member here
617-
symbol_resolve =
618-
generate_symbol_resolution_from_equations(equations, ns, debug());
617+
// symbol_resolve is used by get and is kept between calls to dec_solve,
618+
// that's why we use a class member here
619+
add_equations_for_symbol_resolution(symbol_resolve, equations, ns, debug());
619620
#ifdef DEBUG
620621
debug() << "symbol resolve:" << eom;
621622
for(const auto &pair : symbol_resolve.to_vector())

0 commit comments

Comments
 (0)