Skip to content

Commit 805f45f

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 61b3910 commit 805f45f

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

src/solvers/refinement/string_refinement_util.cpp

+4-2
Original file line numberDiff line numberDiff line change
@@ -442,13 +442,15 @@ void string_dependenciest::add_constraints(
442442
for_each_successor(n, f);
443443
});
444444

445-
for(const auto &node : test_dependencies)
445+
for(const auto &node : builtin_function_nodes)
446446
{
447-
if(node.kind == node.BUILTIN)
447+
if(test_dependencies.count(nodet(node)))
448448
{
449449
const auto &builtin = builtin_function_nodes[node.index];
450450
const exprt return_value = builtin.data->add_constraints(generator);
451451
generator.add_lemma(equal_exprt(return_value, builtin.data->return_code));
452452
}
453+
else
454+
generator.add_lemma(node.data->length_constraint());
453455
}
454456
}

src/solvers/refinement/string_refinement_util.h

+3
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)