Skip to content

Commit 2900b71

Browse files
Correct add_constraints in string_dependencies
When the result of a function is not tested we don't need to add full constraints, but constraints about the length may still be necessary as the length field of the string can be accessed directly.
1 parent 4860a63 commit 2900b71

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

src/solvers/refinement/string_refinement_util.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -441,13 +441,15 @@ void string_dependenciest::add_constraints(
441441
for_each_successor(n, f);
442442
});
443443

444-
for(const auto &node : test_dependencies)
444+
for(const auto &node : builtin_function_nodes)
445445
{
446-
if(node.kind == node.BUILTIN)
446+
if(test_dependencies.count(nodet(node)))
447447
{
448448
const auto &builtin = builtin_function_nodes[node.index];
449449
const exprt return_value = builtin.data->add_constraints(generator);
450450
generator.add_lemma(equal_exprt(return_value, builtin.data->return_code));
451451
}
452+
else
453+
generator.add_lemma(node.data->length_constraint());
452454
}
453455
}

src/solvers/refinement/string_refinement_util.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,9 @@ class string_dependenciest
238238

239239
void output_dot(std::ostream &stream) const;
240240

241+
/// For all builtin call on which a test (or an unsupported buitin)
242+
/// result depends, add the corresponding constraints. For the other builtin
243+
/// only add constraints on the length.
241244
void add_constraints(string_constraint_generatort &generatort);
242245

243246
private:

0 commit comments

Comments
 (0)