Skip to content

Commit 4a7e45c

Browse files
Make node point to builtin func they result from
This make finding the function the string results from easier.
1 parent ceff3a4 commit 4a7e45c

File tree

2 files changed

+12
-10
lines changed

2 files changed

+12
-10
lines changed

src/solvers/refinement/string_refinement_util.cpp

+10-10
Original file line numberDiff line numberDiff line change
@@ -479,17 +479,12 @@ optionalt<exprt> string_dependenciest::eval(
479479
return eval_string_cache[it->second];
480480

481481
const auto node = string_nodes[it->second];
482-
483-
if(node.dependencies.size() == 1)
482+
const auto &f = node.result_from;
483+
if(f && node.dependencies.size() == 1 && !node.depends_on_unknown_builtin_function)
484484
{
485-
const auto &f = get_builtin_function(node.dependencies[0]);
486-
const auto result = f.string_result();
487-
if(result && *result == s)
488-
{
489-
const auto value_opt = f.eval(get_value);
490-
eval_string_cache[it->second] = value_opt;
491-
return value_opt;
492-
}
485+
const auto value_opt = get_builtin_function(*f).eval(get_value);
486+
eval_string_cache[it->second] = value_opt;
487+
return value_opt;
493488
}
494489
return {};
495490
}
@@ -526,7 +521,12 @@ bool add_node(
526521
if(
527522
const auto &string_result =
528523
dependencies.get_builtin_function(builtin_function_node).string_result())
524+
{
529525
dependencies.add_dependency(*string_result, builtin_function_node);
526+
auto &node = dependencies.get_node(*string_result);
527+
node.result_from = builtin_function_node;
528+
529+
}
530530
else
531531
add_dependency_to_string_subexprs(
532532
dependencies, *fun_app, builtin_function_node, array_pool);

src/solvers/refinement/string_refinement_util.h

+2
Original file line numberDiff line numberDiff line change
@@ -309,6 +309,8 @@ class string_dependenciest
309309
std::size_t index;
310310
// builtin functions on which it depends
311311
std::vector<builtin_function_nodet> dependencies;
312+
// builtin function of which it is the result
313+
optionalt<builtin_function_nodet> result_from;
312314
// In case it depends on a builtin_function we don't support yet
313315
bool depends_on_unknown_builtin_function = false;
314316

0 commit comments

Comments
 (0)