Skip to content

Commit a73bba5

Browse files
author
Daniel Kroening
committed
avoid use of deprecated expression constructors
The constructors have been deprecated since Nov 2019 or earlier, and there are straight-forward replacements.
1 parent 6cfbec2 commit a73bba5

File tree

6 files changed

+30
-33
lines changed

6 files changed

+30
-33
lines changed

src/analyses/goto_check.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -829,8 +829,8 @@ void goto_checkt::integer_overflow_check(
829829
return;
830830
}
831831

832-
multi_ary_exprt overflow("overflow-" + expr.id_string(), bool_typet());
833-
overflow.operands()=expr.operands();
832+
multi_ary_exprt overflow(
833+
"overflow-" + expr.id_string(), expr.operands(), bool_typet());
834834

835835
if(expr.operands().size()>=3)
836836
{

src/goto-instrument/accelerate/overflow_instrumenter.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -211,8 +211,8 @@ void overflow_instrumentert::overflow_expr(
211211
expr.id()==ID_mult)
212212
{
213213
// A generic arithmetic operation.
214-
multi_ary_exprt overflow("overflow-" + expr.id_string(), bool_typet());
215-
overflow.operands()=expr.operands();
214+
multi_ary_exprt overflow(
215+
"overflow-" + expr.id_string(), expr.operands(), bool_typet());
216216

217217
if(expr.operands().size()>=3)
218218
{

src/goto-symex/field_sensitivity.cpp

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -154,8 +154,8 @@ exprt field_sensitivityt::get_fields(
154154
const struct_typet &type = to_struct_type(ns.follow(ssa_expr.type()));
155155
const struct_union_typet::componentst &components = type.components();
156156

157-
struct_exprt result(ssa_expr.type());
158-
result.reserve_operands(components.size());
157+
struct_exprt::operandst fields;
158+
fields.reserve(components.size());
159159

160160
const exprt &struct_op = ssa_expr.get_original_expr();
161161

@@ -168,14 +168,13 @@ exprt field_sensitivityt::get_fields(
168168
tmp.set_expression(member);
169169
if(was_l2)
170170
{
171-
result.add_to_operands(
172-
state.rename(get_fields(ns, state, tmp), ns).get());
171+
fields.push_back(state.rename(get_fields(ns, state, tmp), ns).get());
173172
}
174173
else
175-
result.add_to_operands(get_fields(ns, state, tmp));
174+
fields.push_back(get_fields(ns, state, tmp));
176175
}
177176

178-
return std::move(result);
177+
return struct_exprt(std::move(fields), ssa_expr.type());
179178
}
180179
#ifdef ENABLE_ARRAY_FIELD_SENSITIVITY
181180
else if(
@@ -190,8 +189,8 @@ exprt field_sensitivityt::get_fields(
190189
const array_typet &type = to_array_type(ssa_expr.type());
191190
const std::size_t array_size = numeric_cast_v<std::size_t>(mp_array_size);
192191

193-
array_exprt result(type);
194-
result.reserve_operands(array_size);
192+
array_exprt::operandst elements;
193+
elements.reserve(array_size);
195194

196195
const exprt &array = ssa_expr.get_original_expr();
197196

@@ -204,14 +203,13 @@ exprt field_sensitivityt::get_fields(
204203
tmp.set_expression(index);
205204
if(was_l2)
206205
{
207-
result.add_to_operands(
208-
state.rename(get_fields(ns, state, tmp), ns).get());
206+
elements.push_back(state.rename(get_fields(ns, state, tmp), ns).get());
209207
}
210208
else
211-
result.add_to_operands(get_fields(ns, state, tmp));
209+
elements.push_back(get_fields(ns, state, tmp));
212210
}
213211

214-
return std::move(result);
212+
return array_exprt(std::move(elements), type);
215213
}
216214
#endif // ENABLE_ARRAY_FIELD_SENSITIVITY
217215
else

src/goto-symex/goto_symex.cpp

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1019,8 +1019,8 @@ bool goto_symext::constant_propagate_replace(
10191019
auto &new_data = f_l1.arguments().at(4);
10201020
auto &old_data = f_l1.arguments().at(3);
10211021

1022-
array_exprt characters_to_find(s_data_opt->get().type());
1023-
array_exprt characters_to_replace(s_data_opt->get().type());
1022+
array_exprt::operandst characters_to_find;
1023+
array_exprt::operandst characters_to_replace;
10241024

10251025
// Two main ways to perform a replace: characters or strings.
10261026
bool is_single_character = new_data.type().id() == ID_unsignedbv &&
@@ -1035,8 +1035,8 @@ bool goto_symext::constant_propagate_replace(
10351035
return {};
10361036
}
10371037

1038-
characters_to_find.operands().emplace_back(old_char_pointer->get());
1039-
characters_to_replace.operands().emplace_back(new_char_pointer->get());
1038+
characters_to_find.emplace_back(old_char_pointer->get());
1039+
characters_to_replace.emplace_back(new_char_pointer->get());
10401040
}
10411041
else
10421042
{
@@ -1054,23 +1054,23 @@ bool goto_symext::constant_propagate_replace(
10541054
return {};
10551055
}
10561056

1057-
characters_to_find = old_char_array_opt->get();
1058-
characters_to_replace = new_char_array_opt->get();
1057+
characters_to_find = old_char_array_opt->get().operands();
1058+
characters_to_replace = new_char_array_opt->get().operands();
10591059
}
10601060

10611061
// Copy data, then do initial search for a replace sequence.
10621062
array_exprt existing_data = s_data_opt->get();
10631063
auto found_pattern = std::search(
10641064
existing_data.operands().begin(),
10651065
existing_data.operands().end(),
1066-
characters_to_find.operands().begin(),
1067-
characters_to_find.operands().end());
1066+
characters_to_find.begin(),
1067+
characters_to_find.end());
10681068

10691069
// If we've found a match, proceed to perform a replace on all instances.
10701070
while(found_pattern != existing_data.operands().end())
10711071
{
10721072
// Find the difference between our first/last match iterator.
1073-
auto match_end = found_pattern + characters_to_find.operands().size();
1073+
auto match_end = found_pattern + characters_to_find.size();
10741074

10751075
// Erase them.
10761076
found_pattern = existing_data.operands().erase(found_pattern, match_end);
@@ -1079,16 +1079,16 @@ bool goto_symext::constant_propagate_replace(
10791079
// our new sequence.
10801080
found_pattern = existing_data.operands().insert(
10811081
found_pattern,
1082-
characters_to_replace.operands().begin(),
1083-
characters_to_replace.operands().end()) +
1084-
characters_to_replace.operands().size();
1082+
characters_to_replace.begin(),
1083+
characters_to_replace.end()) +
1084+
characters_to_replace.size();
10851085

10861086
// Then search from there for any additional matches.
10871087
found_pattern = std::search(
10881088
found_pattern,
10891089
existing_data.operands().end(),
1090-
characters_to_find.operands().begin(),
1091-
characters_to_find.operands().end());
1090+
characters_to_find.begin(),
1091+
characters_to_find.end());
10921092
}
10931093

10941094
const constant_exprt new_char_array_length =

unit/goto-symex/expr_skeleton.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ SCENARIO("expr skeleton", "[core][goto-symex][symex-assign][expr-skeleton]")
2323
const signedbv_typet int_type{32};
2424
const expr_skeletont index_skeleton =
2525
expr_skeletont::remove_op0(index_exprt{
26-
array_exprt{array_typet{int_type, from_integer(2, size_type())}},
26+
array_exprt{{}, array_typet{int_type, from_integer(2, size_type())}},
2727
from_integer(1, size_type())});
2828
const expr_skeletont member_skeleton = expr_skeletont::remove_op0(
2929
member_exprt{symbol_exprt{"struct1", typet{}}, "field1", int_type});

unit/goto-symex/symex_assign.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -248,8 +248,7 @@ SCENARIO(
248248
member_exprt{struct1_sym, "field1", int_type}};
249249
struct1_v0_field1.set_level_0(0);
250250
struct1_v0_field1.set_level_2(0);
251-
struct_exprt struct_expr(struct_type);
252-
struct_expr.add_to_operands(struct1_v0_field1);
251+
struct_exprt struct_expr({struct1_v0_field1}, struct_type);
253252
with_exprt struct1_v0_with_field_set = rhs;
254253
struct1_v0_with_field_set.old() = struct_expr;
255254
REQUIRE(assign_step.ssa_rhs == struct1_v0_with_field_set);

0 commit comments

Comments
 (0)