Skip to content

Commit 2e7057a

Browse files
Remove use of unknown_dependency
unknown dependencies on a builtin function are now using string_builtin_function_with_no_evalt.
1 parent 408adbe commit 2e7057a

File tree

2 files changed

+2
-51
lines changed

2 files changed

+2
-51
lines changed

src/solvers/refinement/string_refinement_util.cpp

Lines changed: 2 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -250,41 +250,6 @@ void string_dependenciest::add_dependency(
250250
string_node.dependencies.push_back(builtin_function_node);
251251
}
252252

253-
void string_dependenciest::add_unknown_dependency(const array_string_exprt &e)
254-
{
255-
if(e.id() == ID_if)
256-
{
257-
const auto if_expr = to_if_expr(e);
258-
const auto &true_case = to_array_string_expr(if_expr.true_case());
259-
const auto &false_case = to_array_string_expr(if_expr.false_case());
260-
add_unknown_dependency(true_case);
261-
add_unknown_dependency(false_case);
262-
return;
263-
}
264-
string_nodet &string_node = get_node(e);
265-
string_node.depends_on_unknown_builtin_function = true;
266-
}
267-
268-
static void add_unknown_dependency_to_string_subexprs(
269-
string_dependenciest &dependencies,
270-
const function_application_exprt &fun_app,
271-
array_poolt &array_pool)
272-
{
273-
for(const auto &expr : fun_app.arguments())
274-
{
275-
std::for_each(
276-
expr.depth_begin(), expr.depth_end(), [&](const exprt &e) { // NOLINT
277-
if(is_refined_string_type(e.type()))
278-
{
279-
const auto &string_struct = expr_checked_cast<struct_exprt>(e);
280-
const array_string_exprt string =
281-
array_pool.find(string_struct.op1(), string_struct.op0());
282-
dependencies.add_unknown_dependency(string);
283-
}
284-
});
285-
}
286-
}
287-
288253
static void add_dependency_to_string_subexprs(
289254
string_dependenciest &dependencies,
290255
const function_application_exprt &fun_app,
@@ -331,9 +296,7 @@ optionalt<exprt> string_dependenciest::eval(
331296

332297
const auto node = string_nodes[it->second];
333298
const auto &f = node.result_from;
334-
if(
335-
f && node.dependencies.size() == 1 &&
336-
!node.depends_on_unknown_builtin_function)
299+
if(f && node.dependencies.size() == 1)
337300
{
338301
const auto value_opt = get_builtin_function(*f).eval(get_value);
339302
eval_string_cache[it->second] = value_opt;
@@ -360,14 +323,7 @@ bool add_node(
360323
return false;
361324

362325
auto builtin_function = to_string_builtin_function(*fun_app, array_pool);
363-
364-
if(!builtin_function)
365-
{
366-
add_unknown_dependency_to_string_subexprs(
367-
dependencies, *fun_app, array_pool);
368-
return true;
369-
}
370-
326+
CHECK_RETURN(builtin_function != nullptr);
371327
const auto &builtin_function_node = dependencies.make_node(builtin_function);
372328
// Warning: `builtin_function` has been emptied and should not be used anymore
373329

src/solvers/refinement/string_refinement_util.h

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -172,8 +172,6 @@ class string_dependenciest
172172
std::vector<builtin_function_nodet> dependencies;
173173
// builtin function of which it is the result
174174
optionalt<builtin_function_nodet> result_from;
175-
// In case it depends on a builtin_function we don't support yet
176-
bool depends_on_unknown_builtin_function = false;
177175

178176
explicit string_nodet(array_string_exprt e, const std::size_t index)
179177
: expr(std::move(e)), index(index)
@@ -201,9 +199,6 @@ class string_dependenciest
201199
const array_string_exprt &e,
202200
const builtin_function_nodet &builtin_function);
203201

204-
/// Mark node for `e` as depending on unknown builtin_function
205-
void add_unknown_dependency(const array_string_exprt &e);
206-
207202
/// Attempt to evaluate the given string from the dependencies and valuation
208203
/// of strings on which it depends
209204
/// Warning: eval uses a cache which must be cleaned everytime the valuations

0 commit comments

Comments
 (0)