Skip to content

Commit 3e3262e

Browse files
Only add constraints on test function dependencies
Instead of adding all constraints corresponding to a string function call, we look at which strings may be used in a testing function (such as endsWith, equals, compare, etc...). We only add constraints for these function calls, since the other operation can not matter for the satisfiability problem.
1 parent adf0d68 commit 3e3262e

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

src/solvers/refinement/string_refinement_util.cpp

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
#include <util/graph.h>
1818
#include <util/magic.h>
1919
#include <util/make_unique.h>
20+
#include <unordered_set>
2021
#include "string_refinement_util.h"
2122

2223
bool is_char_type(const typet &type)
@@ -397,10 +398,26 @@ void string_dependenciest::output_dot(std::ostream &stream) const
397398
void string_dependenciest::add_constraints(
398399
string_constraint_generatort &generator)
399400
{
401+
std::unordered_set<nodet, node_hash> test_dependencies;
400402
for(const auto &builtin : builtin_function_nodes)
401403
{
402404
if(builtin.data->maybe_testing_function())
405+
test_dependencies.insert(nodet(builtin));
406+
}
407+
408+
get_reachable(
409+
test_dependencies,
410+
[&](
411+
const nodet &n,
412+
const std::function<void(const nodet &)> &f) { // NOLINT
413+
for_each_successor(n, f);
414+
});
415+
416+
for(const auto &node : test_dependencies)
417+
{
418+
if(node.kind == node.BUILTIN)
403419
{
420+
const auto &builtin = builtin_function_nodes[node.index];
404421
const exprt return_value = builtin.data->add_constraints(generator);
405422
generator.add_lemma(equal_exprt(return_value, builtin.data->return_code));
406423
}

0 commit comments

Comments
 (0)