Skip to content

Commit 529abf2

Browse files
Decompose if_expr when adding dependencies
We add the dependencies on atomic string expressions, instead of the if_expr directly.
1 parent 0f78f98 commit 529abf2

File tree

2 files changed

+21
-1
lines changed

2 files changed

+21
-1
lines changed

src/solvers/refinement/string_refinement_util.cpp

+18
Original file line numberDiff line numberDiff line change
@@ -434,12 +434,30 @@ void string_dependenciest::add_dependency(
434434
const array_string_exprt &e,
435435
const builtin_function_nodet &builtin_function_node)
436436
{
437+
if(e.id() == ID_if)
438+
{
439+
const auto if_expr = to_if_expr(e);
440+
const auto &true_case = to_array_string_expr(if_expr.true_case());
441+
const auto &false_case = to_array_string_expr(if_expr.false_case());
442+
add_dependency(true_case, builtin_function_node);
443+
add_dependency(false_case, builtin_function_node);
444+
return;
445+
}
437446
string_nodet &string_node = get_node(e);
438447
string_node.dependencies.push_back(builtin_function_node);
439448
}
440449

441450
void string_dependenciest::add_unknown_dependency(const array_string_exprt &e)
442451
{
452+
if(e.id() == ID_if)
453+
{
454+
const auto if_expr = to_if_expr(e);
455+
const auto &true_case = to_array_string_expr(if_expr.true_case());
456+
const auto &false_case = to_array_string_expr(if_expr.false_case());
457+
add_unknown_dependency(true_case);
458+
add_unknown_dependency(false_case);
459+
return;
460+
}
443461
string_nodet &string_node = get_node(e);
444462
string_node.depends_on_unknown_builtin_function = true;
445463
}

src/solvers/refinement/string_refinement_util.h

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