Skip to content

Commit 8d4a057

Browse files
Decompose if_expr when adding dependencies
We add the dependencies on atomic string expressions, instead of the if_expr directly.
1 parent cb72bb7 commit 8d4a057

File tree

2 files changed

+21
-1
lines changed

2 files changed

+21
-1
lines changed

src/solvers/refinement/string_refinement_util.cpp

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -436,12 +436,30 @@ void string_dependenciest::add_dependency(
436436
const array_string_exprt &e,
437437
const builtin_function_nodet &builtin_function_node)
438438
{
439+
if(e.id() == ID_if)
440+
{
441+
const auto if_expr = to_if_expr(e);
442+
const auto &true_case = to_array_string_expr(if_expr.true_case());
443+
const auto &false_case = to_array_string_expr(if_expr.false_case());
444+
add_dependency(true_case, builtin_function_node);
445+
add_dependency(false_case, builtin_function_node);
446+
return;
447+
}
439448
string_nodet &string_node = get_node(e);
440449
string_node.dependencies.push_back(builtin_function_node);
441450
}
442451

443452
void string_dependenciest::add_unknown_dependency(const array_string_exprt &e)
444453
{
454+
if(e.id() == ID_if)
455+
{
456+
const auto if_expr = to_if_expr(e);
457+
const auto &true_case = to_array_string_expr(if_expr.true_case());
458+
const auto &false_case = to_array_string_expr(if_expr.false_case());
459+
add_unknown_dependency(true_case);
460+
add_unknown_dependency(false_case);
461+
return;
462+
}
445463
string_nodet &string_node = get_node(e);
446464
string_node.depends_on_unknown_builtin_function = true;
447465
}

src/solvers/refinement/string_refinement_util.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -343,7 +343,9 @@ class string_dependenciest
343343
const string_builtin_functiont &
344344
get_builtin_function(const builtin_function_nodet &node) const;
345345

346-
/// Add edge from node for `e` to node for `builtin_function`
346+
/// Add edge from node for `e` to node for `builtin_function` if `e` is a
347+
/// simple array expression. If it is an `if_exprt` we add the sub-expressions
348+
/// that are not `if_exprt`s instead.
347349
void add_dependency(
348350
const array_string_exprt &e,
349351
const builtin_function_nodet &builtin_function);

0 commit comments

Comments
 (0)