Skip to content

Commit aeb03cf

Browse files
author
Joel Allred
committed
Use global symbol generator
Using a const symbol generator doesn't make sense and results in several symbols having the same name, thus messing up the bool_bv map.
1 parent 4cf13df commit aeb03cf

File tree

2 files changed

+9
-24
lines changed

2 files changed

+9
-24
lines changed

src/solvers/strings/string_refinement.cpp

Lines changed: 8 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -113,8 +113,7 @@ static optionalt<exprt> get_array(
113113

114114
static exprt substitute_array_access(
115115
const index_exprt &index_expr,
116-
const std::function<symbol_exprt(const irep_idt &, const typet &)>
117-
&symbol_generator,
116+
symbol_generatort &symbol_generator,
118117
const bool left_propagate);
119118

120119
/// Convert index-value map to a vector of values. If a value for an
@@ -1183,8 +1182,7 @@ static exprt substitute_array_access(
11831182
static exprt substitute_array_access(
11841183
const array_exprt &array_expr,
11851184
const exprt &index,
1186-
const std::function<symbol_exprt(const irep_idt &, const typet &)>
1187-
&symbol_generator)
1185+
symbol_generatort &symbol_generator)
11881186
{
11891187
const typet &char_type = array_expr.type().subtype();
11901188
const exprt default_val = symbol_generator("out_of_bound_access", char_type);
@@ -1195,8 +1193,7 @@ static exprt substitute_array_access(
11951193
static exprt substitute_array_access(
11961194
const if_exprt &if_expr,
11971195
const exprt &index,
1198-
const std::function<symbol_exprt(const irep_idt &, const typet &)>
1199-
&symbol_generator,
1196+
symbol_generatort &symbol_generator,
12001197
const bool left_propagate)
12011198
{
12021199
// Substitute recursively in branches of conditional expressions
@@ -1210,8 +1207,7 @@ static exprt substitute_array_access(
12101207

12111208
static exprt substitute_array_access(
12121209
const index_exprt &index_expr,
1213-
const std::function<symbol_exprt(const irep_idt &, const typet &)>
1214-
&symbol_generator,
1210+
symbol_generatort &symbol_generator,
12151211
const bool left_propagate)
12161212
{
12171213
const exprt &array = index_expr.array();
@@ -1240,8 +1236,7 @@ static exprt substitute_array_access(
12401236
/// the resulting expression.
12411237
static void substitute_array_access_in_place(
12421238
exprt &expr,
1243-
const std::function<symbol_exprt(const irep_idt &, const typet &)>
1244-
&symbol_generator,
1239+
symbol_generatort &symbol_generator,
12451240
const bool left_propagate)
12461241
{
12471242
if(const auto index_expr = expr_try_dynamic_cast<index_exprt>(expr))
@@ -1269,15 +1264,13 @@ static void substitute_array_access_in_place(
12691264
/// Note that if left_propagate is set to true, the `with` case will result in
12701265
/// something like: `index <= 0 ? 24 : index <= 2 ? 42 : 12`
12711266
/// \param expr: an expression containing array accesses
1272-
/// \param symbol_generator: function which given a prefix and a type generates
1273-
/// a fresh symbol of the given type
1267+
/// \param symbol_generator: a symbol generator
12741268
/// \param left_propagate: should values be propagated to the left in with
12751269
/// expressions
12761270
/// \return an expression containing no array access
12771271
exprt substitute_array_access(
12781272
exprt expr,
1279-
const std::function<symbol_exprt(const irep_idt &, const typet &)>
1280-
&symbol_generator,
1273+
symbol_generatort &symbol_generator,
12811274
const bool left_propagate)
12821275
{
12831276
substitute_array_access_in_place(expr, symbol_generator, left_propagate);
@@ -1366,13 +1359,6 @@ static std::pair<bool, std::vector<exprt>> check_axioms(
13661359
const std::unordered_map<string_not_contains_constraintt, symbol_exprt>
13671360
&not_contain_witnesses)
13681361
{
1369-
// clang-format off
1370-
const auto gen_symbol = [&](const irep_idt &id, const typet &type)
1371-
{
1372-
return generator.fresh_symbol(id, type);
1373-
};
1374-
// clang-format on
1375-
13761362
stream << "string_refinementt::check_axioms:" << messaget::eom;
13771363

13781364
stream << "symbol_resolve:" << messaget::eom;
@@ -1410,7 +1396,7 @@ static std::pair<bool, std::vector<exprt>> check_axioms(
14101396

14111397
stream << std::string(2, ' ') << i << ".\n";
14121398
const exprt with_concretized_arrays =
1413-
substitute_array_access(negaxiom, gen_symbol, true);
1399+
substitute_array_access(negaxiom, generator.fresh_symbol, true);
14141400
debug_check_axioms_step(
14151401
stream, axiom, axiom_in_model, negaxiom, with_concretized_arrays);
14161402

src/solvers/strings/string_refinement.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -129,8 +129,7 @@ union_find_replacet string_identifiers_resolution_from_equations(
129129
// Declaration required for unit-test:
130130
exprt substitute_array_access(
131131
exprt expr,
132-
const std::function<symbol_exprt(const irep_idt &, const typet &)>
133-
&symbol_generator,
132+
symbol_generatort &symbol_generator,
134133
const bool left_propagate);
135134

136135
#endif

0 commit comments

Comments
 (0)