Skip to content

Commit 7bb5aff

Browse files
Make node point to builtin func they result from
This make finding the function the string results from easier.
1 parent a89ceb0 commit 7bb5aff

File tree

2 files changed

+13
-10
lines changed

2 files changed

+13
-10
lines changed

src/solvers/refinement/string_refinement_util.cpp

+11-10
Original file line numberDiff line numberDiff line change
@@ -497,17 +497,14 @@ optionalt<exprt> string_dependenciest::eval(
497497
return eval_string_cache[it->second];
498498

499499
const auto node = string_nodes[it->second];
500-
501-
if(node.dependencies.size() == 1)
500+
const auto &f = node.result_from;
501+
if(
502+
f && node.dependencies.size() == 1 &&
503+
!node.depends_on_unknown_builtin_function)
502504
{
503-
const auto &f = get_builtin_function(node.dependencies[0]);
504-
const auto result = f.string_result();
505-
if(result && *result == s)
506-
{
507-
const auto value_opt = f.eval(get_value);
508-
eval_string_cache[it->second] = value_opt;
509-
return value_opt;
510-
}
505+
const auto value_opt = get_builtin_function(*f).eval(get_value);
506+
eval_string_cache[it->second] = value_opt;
507+
return value_opt;
511508
}
512509
return {};
513510
}
@@ -544,7 +541,11 @@ bool add_node(
544541
if(
545542
const auto &string_result =
546543
dependencies.get_builtin_function(builtin_function_node).string_result())
544+
{
547545
dependencies.add_dependency(*string_result, builtin_function_node);
546+
auto &node = dependencies.get_node(*string_result);
547+
node.result_from = builtin_function_node;
548+
}
548549
else
549550
add_dependency_to_string_subexprs(
550551
dependencies, *fun_app, builtin_function_node, array_pool);

src/solvers/refinement/string_refinement_util.h

+2
Original file line numberDiff line numberDiff line change
@@ -316,6 +316,8 @@ class string_dependenciest
316316
std::size_t index;
317317
// builtin functions on which it depends
318318
std::vector<builtin_function_nodet> dependencies;
319+
// builtin function of which it is the result
320+
optionalt<builtin_function_nodet> result_from;
319321
// In case it depends on a builtin_function we don't support yet
320322
bool depends_on_unknown_builtin_function = false;
321323

0 commit comments

Comments
 (0)