Skip to content

Commit 4a96ec9

Browse files
authored
Merge pull request #3691 from tautschnig/move_to_operands
Replace all uses of move_to_operands
2 parents 6d407d3 + b2eff7e commit 4a96ec9

38 files changed

+727
-778
lines changed

jbmc/src/java_bytecode/character_refine_preprocess.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1191,9 +1191,8 @@ exprt character_refine_preprocesst::expr_of_to_chars(
11911191
array_exprt case2(array_type);
11921192
exprt low_surrogate=expr_of_low_surrogate(chr, char_type);
11931193
case1.copy_to_operands(low_surrogate);
1194-
case2.move_to_operands(low_surrogate);
1195-
exprt high_surrogate=expr_of_high_surrogate(chr, char_type);
1196-
case2.move_to_operands(high_surrogate);
1194+
case2.add_to_operands(
1195+
std::move(low_surrogate), expr_of_high_surrogate(chr, char_type));
11971196
return if_exprt(expr_of_is_bmp_code_point(chr, type), case1, case2);
11981197
}
11991198

jbmc/src/java_bytecode/java_bytecode_convert_class.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -879,9 +879,8 @@ void java_bytecode_convert_classt::add_array_types(symbol_tablet &symbol_table)
879879
// TODO use this instead of a loop.
880880
codet array_copy;
881881
array_copy.set_statement(ID_array_copy);
882-
array_copy.move_to_operands(new_data);
883-
array_copy.move_to_operands(old_data);
884-
clone_body.move_to_operands(array_copy);
882+
array_copy.add_to_operands(std::move(new_data), std::move(old_data));
883+
clone_body.add_to_operands(std::move(array_copy));
885884
*/
886885

887886
// Begin for-loop to replace:

jbmc/src/java_bytecode/java_string_literals.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -173,8 +173,8 @@ symbol_exprt get_or_create_string_literal_symbol(
173173
// _return_value global for its side-effects.
174174
exprt init_comma_expr(ID_comma);
175175
init_comma_expr.type() = literal_init.type();
176-
init_comma_expr.copy_to_operands(return_symbol.symbol_expr());
177-
init_comma_expr.move_to_operands(literal_init);
176+
init_comma_expr.add_to_operands(
177+
return_symbol.symbol_expr(), std::move(literal_init));
178178
new_symbol.value = init_comma_expr;
179179
}
180180
else if(jls_struct.components().size()>=1 &&

jbmc/unit/util/expr_iterator.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -176,8 +176,8 @@ SCENARIO("depth_iterator_mutate_root", "[core][utils][depth_iterator]")
176176
exprt test_root;
177177
// This is the expression we might mutate when we find it
178178
exprt test_operand(ID_1);
179-
test_root.move_to_operands(test_operand);
180-
test_expr.move_to_operands(test_root);
179+
test_root.add_to_operands(std::move(test_operand));
180+
test_expr.add_to_operands(std::move(test_root));
181181
WHEN("Iteration occurs without mutation")
182182
{
183183
// Create shared copies

src/analyses/goto_check.cpp

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1413,10 +1413,7 @@ void goto_checkt::add_guarded_claim(
14131413
if(guard.is_true())
14141414
new_expr.swap(expr);
14151415
else
1416-
{
1417-
new_expr=exprt(ID_implies, bool_typet());
1418-
new_expr.add_to_operands(guard.as_expr(), std::move(expr));
1419-
}
1416+
new_expr = implies_exprt(guard.as_expr(), std::move(expr));
14201417

14211418
if(assertions.insert(new_expr).second)
14221419
{

src/ansi-c/c_typecheck_expr.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -943,7 +943,7 @@ void c_typecheck_baset::typecheck_side_effect_statement_expression(
943943
{
944944
side_effect_exprt assign(
945945
ID_assign, sideeffect.type(), fc.source_location());
946-
assign.move_to_operands(fc.lhs(), sideeffect);
946+
assign.add_to_operands(fc.lhs(), std::move(sideeffect));
947947

948948
code_expressiont code_expr(assign);
949949
code_expr.add_source_location() = fc.source_location();
@@ -1302,7 +1302,7 @@ void c_typecheck_baset::typecheck_expr_index(exprt &expr)
13021302
typecheck_arithmetic_pointer(expr.op0());
13031303
exprt addition(ID_plus, array_expr.type());
13041304
addition.operands().swap(expr.operands());
1305-
expr.move_to_operands(addition);
1305+
expr.add_to_operands(std::move(addition));
13061306
expr.id(ID_dereference);
13071307
expr.set(ID_C_lvalue, true);
13081308
expr.type() = final_array_type.subtype();

src/ansi-c/parser.y

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -442,8 +442,7 @@ offsetof_member_designator:
442442
{
443443
$$=$1;
444444
set($2, ID_index);
445-
exprt tmp=convert_integer_literal("0");
446-
stack($2).move_to_operands(tmp);
445+
stack($2).add_to_operands(convert_integer_literal("0"));
447446
mto($$, $2);
448447
set($2, ID_member);
449448
stack($2).set(ID_component_name, stack($3).get(ID_C_base_name));
@@ -574,7 +573,7 @@ postfix_expression:
574573
tmp.operands().swap(stack($5).operands());
575574
$$=$1;
576575
set($$, ID_typecast);
577-
stack($$).move_to_operands(tmp);
576+
stack($$).add_to_operands(std::move(tmp));
578577
stack($$).type().swap(stack($2));
579578
}
580579
| '(' type_name ')' '{' initializer_list ',' '}'
@@ -585,7 +584,7 @@ postfix_expression:
585584
tmp.operands().swap(stack($5).operands());
586585
$$=$1;
587586
set($$, ID_typecast);
588-
stack($$).move_to_operands(tmp);
587+
stack($$).add_to_operands(std::move(tmp));
589588
stack($$).type().swap(stack($2));
590589
}
591590
;
@@ -2080,7 +2079,7 @@ initializer_list:
20802079
exprt tmp;
20812080
tmp.swap(stack($$));
20822081
stack($$).clear();
2083-
stack($$).move_to_operands(tmp);
2082+
stack($$).add_to_operands(std::move(tmp));
20842083
}
20852084
| initializer_list ',' designated_initializer
20862085
{
@@ -2123,7 +2122,7 @@ designated_initializer:
21232122
exprt designator;
21242123
exprt member(ID_member);
21252124
member.set(ID_component_name, stack($1).get(ID_C_base_name));
2126-
designator.move_to_operands(member);
2125+
designator.add_to_operands(std::move(member));
21272126
stack($$).add(ID_designator).swap(designator);
21282127
mto($$, $3);
21292128
}
@@ -2638,14 +2637,14 @@ gcc_asm_output:
26382637
{
26392638
$$=$2;
26402639
stack($$).id(ID_gcc_asm_output);
2641-
stack($$).move_to_operands(stack($1), stack($3));
2640+
stack($$).add_to_operands(std::move(stack($1)), std::move(stack($3)));
26422641
}
26432642
| '[' identifier_or_typedef_name ']'
26442643
string '(' comma_expression ')'
26452644
{
26462645
$$=$5;
26472646
stack($$).id(ID_gcc_asm_output);
2648-
stack($$).move_to_operands(stack($4), stack($6));
2647+
stack($$).add_to_operands(std::move(stack($4)), std::move(stack($6)));
26492648
}
26502649
;
26512650

@@ -2675,14 +2674,14 @@ gcc_asm_input:
26752674
{
26762675
$$=$2;
26772676
stack($$).id(ID_gcc_asm_input);
2678-
stack($$).move_to_operands(stack($1), stack($3));
2677+
stack($$).add_to_operands(std::move(stack($1)), std::move(stack($3)));
26792678
}
26802679
| '[' identifier_or_typedef_name ']'
26812680
string '(' comma_expression ')'
26822681
{
26832682
$$=$5;
26842683
stack($$).id(ID_gcc_asm_input);
2685-
stack($$).move_to_operands(stack($4), stack($6));
2684+
stack($$).add_to_operands(std::move(stack($4)), std::move(stack($6)));
26862685
}
26872686
;
26882687

src/ansi-c/parser_static.inc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
#define YYSTYPE unsigned
1010
#define YYSTYPE_IS_TRIVIAL 1
1111

12-
#define mto(x, y) stack(x).move_to_operands(stack(y))
12+
#define mto(x, y) stack(x).add_to_operands(std::move(stack(y)))
1313
#define mts(x, y) (to_type_with_subtypes(stack_type(x)).move_to_subtypes(stack_type(y)))
1414
#define binary(x, y, l, id, z) { init(x, id); \
1515
stack(x).add_source_location()=stack(l).source_location(); \

src/cpp/cpp_constructor.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ optionalt<codet> cpp_typecheckt::cpp_constructor(
190190
val=true_exprt();
191191

192192
side_effect_exprt assign(ID_assign, typet(), source_location);
193-
assign.move_to_operands(member, val);
193+
assign.add_to_operands(std::move(member), std::move(val));
194194
typecheck_side_effect_assignment(assign);
195195
block.add(code_expressiont(std::move(assign)));
196196
}
@@ -285,7 +285,7 @@ void cpp_typecheckt::new_temporary(
285285
if(new_code.has_value())
286286
{
287287
if(new_code->get_statement() == ID_assign)
288-
tmp_object_expr.move_to_operands(new_code->op1());
288+
tmp_object_expr.add_to_operands(std::move(new_code->op1()));
289289
else
290290
tmp_object_expr.add(ID_initializer) = *new_code;
291291
}

src/cpp/cpp_destructor.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ optionalt<codet> cpp_typecheckt::cpp_destructor(
6868

6969
auto i_code = cpp_destructor(source_location, index);
7070
if(i_code.has_value())
71-
new_code.move_to_operands(i_code.value());
71+
new_code.add_to_operands(std::move(i_code.value()));
7272
}
7373
}
7474
else

src/cpp/cpp_typecheck.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -196,8 +196,6 @@ void cpp_typecheckt::static_and_dynamic_initialization()
196196

197197
dynamic_initializations.clear();
198198

199-
// block_sini.move_to_operands(block_dini);
200-
201199
// Create the dynamic initialization procedure
202200
symbolt init_symbol;
203201

src/cpp/cpp_typecheck_code.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -418,7 +418,7 @@ void cpp_typecheckt::typecheck_decl(codet &code)
418418
"declarator type should match symbol type");
419419
}
420420

421-
new_code.move_to_operands(decl_statement);
421+
new_code.add_to_operands(std::move(decl_statement));
422422

423423
// is there a constructor to be called?
424424
if(symbol.value.is_not_nil())
@@ -439,7 +439,7 @@ void cpp_typecheckt::typecheck_decl(codet &code)
439439
symbol.location, object_expr, declarator.init_args().operands());
440440

441441
if(constructor_call.has_value())
442-
new_code.move_to_operands(constructor_call.value());
442+
new_code.add_to_operands(std::move(constructor_call.value()));
443443
}
444444
}
445445

src/cpp/cpp_typecheck_compound_type.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -668,14 +668,14 @@ void cpp_typecheckt::typecheck_compound_declarator(
668668
{
669669
expr_call.type()=to_code_type(component.type()).return_type();
670670
exprt already_typechecked(ID_already_typechecked);
671-
already_typechecked.move_to_operands(expr_call);
671+
already_typechecked.add_to_operands(std::move(expr_call));
672672

673673
func_symb.value = code_returnt(already_typechecked).make_block();
674674
}
675675
else
676676
{
677677
exprt already_typechecked(ID_already_typechecked);
678-
already_typechecked.move_to_operands(expr_call);
678+
already_typechecked.add_to_operands(std::move(expr_call));
679679

680680
func_symb.value = code_expressiont(already_typechecked).make_block();
681681
}
@@ -1103,12 +1103,12 @@ void cpp_typecheckt::typecheck_compound_body(symbolt &symbol)
11031103
{
11041104
// it's public!
11051105
exprt cpp_public("cpp-public");
1106-
body.move_to_operands(cpp_public);
1106+
body.add_to_operands(std::move(cpp_public));
11071107

11081108
// build declaration
11091109
cpp_declarationt ctor;
11101110
default_ctor(symbol.type.source_location(), symbol.base_name, ctor);
1111-
body.move_to_operands(ctor);
1111+
body.add_to_operands(std::move(ctor));
11121112
}
11131113

11141114
// Reset the access type

src/cpp/cpp_typecheck_constructor.cpp

Lines changed: 11 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ void cpp_typecheckt::default_ctor(
136136

137137
ctor.type().id(ID_constructor);
138138
ctor.add(ID_storage_spec).id(ID_cpp_storage_spec);
139-
ctor.move_to_operands(decl);
139+
ctor.add_to_operands(std::move(decl));
140140
ctor.add_source_location()=source_location;
141141
}
142142

@@ -178,7 +178,7 @@ void cpp_typecheckt::default_cpctor(
178178
sub.push_back(cppcomp.as_type());
179179
irept constnd(ID_const);
180180
sub.push_back(static_cast<const typet &>(constnd));
181-
parameter_decl.move_to_operands(parameter_tor);
181+
parameter_decl.add_to_operands(std::move(parameter_tor));
182182
parameter_decl.add_source_location()=source_location;
183183

184184
// Add parameter to function type
@@ -271,7 +271,7 @@ void cpp_typecheckt::default_cpctor(
271271
if(mem_c.type().id() == ID_array)
272272
memberexpr.set(ID_C_array_ini, true);
273273

274-
mem_init.move_to_operands(memberexpr);
274+
mem_init.add_to_operands(std::move(memberexpr));
275275
initializers.move_to_sub(mem_init);
276276
}
277277
}
@@ -568,12 +568,6 @@ void cpp_typecheckt::full_member_initialization(
568568

569569
if(!vbases.empty())
570570
{
571-
// TODO(tautschnig): this code doesn't seem to make much sense as the
572-
// ifthenelse only gets to have two operands (instead of three)
573-
codet cond(ID_ifthenelse);
574-
575-
cond.copy_to_operands(cpp_namet("@most_derived").as_expr());
576-
577571
code_blockt block;
578572

579573
while(!vbases.empty())
@@ -590,7 +584,9 @@ void cpp_typecheckt::full_member_initialization(
590584
}
591585
vbases.pop_front();
592586
}
593-
cond.move_to_operands(block);
587+
588+
code_ifthenelset cond(
589+
cpp_namet("@most_derived").as_expr(), std::move(block));
594590
final_initializers.move_to_sub(cond);
595591
}
596592

@@ -671,18 +667,13 @@ void cpp_typecheckt::full_member_initialization(
671667

672668
if(b.get_bool(ID_virtual))
673669
{
674-
// TODO(tautschnig): this code doesn't seem to make much sense as the
675-
// ifthenelse only gets to have two operands (instead of three)
676-
codet cond(ID_ifthenelse);
670+
codet tmp(ID_member_initializer);
671+
tmp.swap(final_initializers.get_sub().back());
677672

678-
cond.copy_to_operands(cpp_namet("@most_derived").as_expr());
673+
code_ifthenelset cond(
674+
cpp_namet("@most_derived").as_expr(), std::move(tmp));
679675

680-
{
681-
codet tmp(ID_member_initializer);
682-
tmp.swap(final_initializers.get_sub().back());
683-
cond.move_to_operands(tmp);
684-
final_initializers.get_sub().back().swap(cond);
685-
}
676+
final_initializers.get_sub().back().swap(cond);
686677
}
687678
}
688679
}

src/cpp/cpp_typecheck_conversions.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1398,7 +1398,7 @@ bool cpp_typecheckt::reference_binding(
13981398
tmp.set(ID_statement, ID_temporary_object);
13991399
tmp.add_source_location()=expr.source_location();
14001400
// tmp.set(ID_C_lvalue, true);
1401-
tmp.move_to_operands(new_expr);
1401+
tmp.add_to_operands(std::move(new_expr));
14021402
new_expr.swap(tmp);
14031403
}
14041404

src/cpp/cpp_typecheck_declaration.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,7 @@ void cpp_typecheckt::convert_anonymous_union(
5757
throw 0;
5858
}
5959

60-
code_declt decl_statement(cpp_symbol_expr(symbol));
61-
62-
new_code.move_to_operands(decl_statement);
60+
new_code.add_to_operands(code_declt(cpp_symbol_expr(symbol)));
6361

6462
// do scoping
6563
symbolt union_symbol=

src/cpp/cpp_typecheck_destructor.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ void cpp_typecheckt::default_dtor(
4545

4646
dtor.add(ID_type).id(ID_destructor);
4747
dtor.add(ID_storage_spec).id(ID_cpp_storage_spec);
48-
dtor.move_to_operands(decl);
48+
dtor.add_to_operands(std::move(decl));
4949
}
5050

5151
/// produces destructor code for a class object

0 commit comments

Comments
 (0)