Skip to content

Commit d4d00ab

Browse files
author
Daniel Kroening
authored
Merge pull request #3278 from tautschnig/no-codet-move
Replace uses of codet::move by codet::add(std::move(...)) [blocks: #2310]
2 parents e29fd12 + a7cff47 commit d4d00ab

11 files changed

+54
-64
lines changed

jbmc/src/java_bytecode/java_bytecode_instrument.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -329,7 +329,7 @@ void java_bytecode_instrumentt::add_expr_instrumentation(
329329
if(expr_instrumentation->get_statement() == ID_block)
330330
block.append(to_code_block(*expr_instrumentation));
331331
else
332-
block.move(*expr_instrumentation);
332+
block.add(std::move(*expr_instrumentation));
333333
}
334334
}
335335

@@ -476,7 +476,7 @@ optionalt<codet> java_bytecode_instrumentt::instrument_expr(const exprt &expr)
476476
forall_operands(it, expr)
477477
{
478478
if(optionalt<codet> op_result = instrument_expr(*it))
479-
result.move(*op_result);
479+
result.add(std::move(*op_result));
480480
}
481481

482482
// Add any check due at this node:
@@ -498,7 +498,7 @@ optionalt<codet> java_bytecode_instrumentt::instrument_expr(const exprt &expr)
498498
dereference_expr,
499499
plus_expr.op1(),
500500
expr.source_location());
501-
result.move(bounds_check);
501+
result.add(std::move(bounds_check));
502502
}
503503
}
504504
}
@@ -534,7 +534,7 @@ optionalt<codet> java_bytecode_instrumentt::instrument_expr(const exprt &expr)
534534
check_null_dereference(
535535
dereference_expr.op0(),
536536
dereference_expr.source_location());
537-
result.move(null_dereference_check);
537+
result.add(std::move(null_dereference_check));
538538
}
539539

540540
if(result==code_blockt())
@@ -598,7 +598,7 @@ void java_bytecode_instrument_uncaught_exceptions(
598598
assert_location.set_comment("no uncaught exception");
599599
assert_no_exception.add_source_location() = assert_location;
600600

601-
init_code.move(assert_no_exception);
601+
init_code.add(std::move(assert_no_exception));
602602
}
603603

604604
/// Instruments all the code in the symbol_table with

jbmc/src/java_bytecode/java_entry_point.cpp

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -204,10 +204,11 @@ static void java_static_lifetime_init(
204204
set_class_identifier(
205205
to_struct_expr(*zero_object), ns, to_symbol_type(sym.type));
206206

207-
code_block.add(code_assignt(sym.symbol_expr(), *zero_object));
207+
code_block.add(
208+
std::move(code_assignt(sym.symbol_expr(), *zero_object)));
208209

209210
// Then call the init function:
210-
code_block.move(initializer_call);
211+
code_block.add(std::move(initializer_call));
211212
}
212213
else if(sym.value.is_nil() && sym.type!=empty_typet())
213214
{
@@ -415,7 +416,7 @@ exprt::operandst java_build_arguments(
415416
input.op1()=main_arguments[param_number];
416417
input.add_source_location()=function.location;
417418

418-
init_code.move(input);
419+
init_code.add(std::move(input));
419420
}
420421

421422
return main_arguments;
@@ -453,7 +454,7 @@ void java_record_outputs(
453454
output.op1()=return_symbol.symbol_expr();
454455
output.add_source_location()=function.location;
455456

456-
init_code.move(output);
457+
init_code.add(std::move(output));
457458
}
458459

459460
for(std::size_t param_number=0;
@@ -476,7 +477,7 @@ void java_record_outputs(
476477
output.op1()=main_arguments[param_number];
477478
output.add_source_location()=function.location;
478479

479-
init_code.move(output);
480+
init_code.add(std::move(output));
480481
}
481482
}
482483

@@ -494,7 +495,7 @@ void java_record_outputs(
494495
output.op1()=exc_symbol.symbol_expr();
495496
output.add_source_location()=function.location;
496497

497-
init_code.move(output);
498+
init_code.add(std::move(output));
498499
}
499500

500501
main_function_resultt get_main_symbol(
@@ -674,7 +675,7 @@ bool generate_java_start_function(
674675
code_function_callt call_init(init_it->second.symbol_expr());
675676
call_init.add_source_location()=symbol.location;
676677

677-
init_code.move(call_init);
678+
init_code.add(std::move(call_init));
678679
}
679680

680681
// build call to the main method, of the form
@@ -747,26 +748,26 @@ bool generate_java_start_function(
747748
irept catch_type_list(ID_exception_list);
748749
irept catch_target_list(ID_label);
749750

750-
call_block.move(push_universal_handler);
751+
call_block.add(std::move(push_universal_handler));
751752

752753
// we insert the call to the method AFTER the argument initialization code
753-
call_block.move(call_main);
754+
call_block.add(std::move(call_main));
754755

755756
// Pop the handler:
756757
code_pop_catcht pop_handler;
757-
call_block.move(pop_handler);
758-
init_code.move(call_block);
758+
call_block.add(std::move(pop_handler));
759+
init_code.add(std::move(call_block));
759760

760761
// Normal return: skip the exception handler:
761762
init_code.add(code_gotot(after_catch.get_label()));
762763

763764
// Exceptional return: catch and assign to exc_symbol.
764765
code_landingpadt landingpad(exc_symbol.symbol_expr());
765-
init_code.add(toplevel_catch);
766-
init_code.move(landingpad);
766+
init_code.add(std::move(toplevel_catch));
767+
init_code.add(std::move(landingpad));
767768

768769
// Converge normal and exceptional return:
769-
init_code.move(after_catch);
770+
init_code.add(std::move(after_catch));
770771

771772
// declare certain (which?) variables as test outputs
772773
java_record_outputs(symbol, main_arguments, init_code, symbol_table);

jbmc/src/java_bytecode/java_object_factory.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1396,7 +1396,7 @@ void java_object_factoryt::gen_nondet_array_init(
13961396
code_labelt init_head_label(head_name, code_skipt());
13971397
code_gotot goto_head(head_name);
13981398

1399-
assignments.move(init_head_label);
1399+
assignments.add(std::move(init_head_label));
14001400

14011401
std::string done_name = id2string(counter.base_name) + "_done";
14021402
code_labelt init_done_label(done_name, code_skipt());
@@ -1406,7 +1406,7 @@ void java_object_factoryt::gen_nondet_array_init(
14061406
done_test.cond()=equal_exprt(counter_expr, length_expr);
14071407
done_test.then_case()=goto_done;
14081408

1409-
assignments.move(done_test);
1409+
assignments.add(std::move(done_test));
14101410

14111411
if(update_in_place!=update_in_placet::MUST_UPDATE_IN_PLACE)
14121412
{
@@ -1416,7 +1416,7 @@ void java_object_factoryt::gen_nondet_array_init(
14161416
max_test.cond()=equal_exprt(counter_expr, max_length_expr);
14171417
max_test.then_case()=goto_done;
14181418

1419-
assignments.move(max_test);
1419+
assignments.add(std::move(max_test));
14201420
}
14211421

14221422
const dereference_exprt arraycellref(
@@ -1447,9 +1447,9 @@ void java_object_factoryt::gen_nondet_array_init(
14471447
exprt java_one=from_integer(1, java_int_type());
14481448
code_assignt incr(counter_expr, plus_exprt(counter_expr, java_one));
14491449

1450-
assignments.move(incr);
1451-
assignments.move(goto_head);
1452-
assignments.move(init_done_label);
1450+
assignments.add(std::move(incr));
1451+
assignments.add(std::move(goto_head));
1452+
assignments.add(std::move(init_done_label));
14531453
}
14541454

14551455
/// We nondet-initialize enums to be equal to one of the constants defined

jbmc/src/java_bytecode/java_static_initializers.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -687,9 +687,8 @@ code_ifthenelset get_clinit_wrapper_body(
687687
wrapper_body.cond() = check_already_run;
688688

689689
// add the "already-run = false" statement
690-
code_blockt init_body;
691690
code_assignt set_already_run(already_run_symbol.symbol_expr(), true_exprt());
692-
init_body.move(set_already_run);
691+
code_blockt init_body({set_already_run});
693692

694693
clinit_wrapper_do_recursive_calls(
695694
symbol_table,

jbmc/src/java_bytecode/remove_java_new.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -296,13 +296,13 @@ goto_programt::targett remove_java_newt::lower_java_new_array(
296296
.symbol_expr();
297297
code_declt init_decl(init_sym);
298298
init_decl.add_source_location() = location;
299-
for_body.move(init_decl);
299+
for_body.add(std::move(init_decl));
300300

301301
code_assignt init_subarray(init_sym, sub_java_new);
302+
for_body.add(std::move(init_subarray));
302303
code_assignt assign_subarray(
303304
deref_expr, typecast_exprt(init_sym, deref_expr.type()));
304-
for_body.move(init_subarray);
305-
for_body.move(assign_subarray);
305+
for_body.add(std::move(assign_subarray));
306306

307307
for_loop.init() = code_assignt(tmp_i, from_integer(0, tmp_i.type()));
308308
for_loop.cond() = binary_relation_exprt(tmp_i, ID_lt, rhs.op0());

src/ansi-c/ansi_c_entry_point.cpp

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ void record_function_outputs(
7373
output.op1()=return_symbol.symbol_expr();
7474
output.add_source_location()=function.location;
7575

76-
init_code.move(output);
76+
init_code.add(std::move(output));
7777
}
7878

7979
#if 0
@@ -101,7 +101,7 @@ void record_function_outputs(
101101
output.op1()=symbol.symbol_expr();
102102
output.add_source_location()=p.source_location();
103103

104-
init_code.move_to_operands(output);
104+
init_code.add(std::move(output));
105105
}
106106

107107
i++;
@@ -215,7 +215,7 @@ bool generate_ansi_c_start_function(
215215
code_function_callt call_init(init_it->second.symbol_expr());
216216
call_init.add_source_location()=symbol.location;
217217

218-
init_code.move(call_init);
218+
init_code.add(std::move(call_init));
219219
}
220220

221221
// build call to main function
@@ -260,7 +260,7 @@ bool generate_ansi_c_start_function(
260260
const binary_relation_exprt ge(argc_symbol.symbol_expr(), ID_ge, one);
261261

262262
code_assumet assumption(ge);
263-
init_code.move(assumption);
263+
init_code.add(std::move(assumption));
264264
}
265265

266266
{
@@ -274,7 +274,7 @@ bool generate_ansi_c_start_function(
274274
argc_symbol.symbol_expr(), ID_le, bound_expr);
275275

276276
code_assumet assumption(le);
277-
init_code.move(assumption);
277+
init_code.add(std::move(assumption));
278278
}
279279

280280
{
@@ -284,7 +284,7 @@ bool generate_ansi_c_start_function(
284284
input.op0()=address_of_exprt(
285285
index_exprt(string_constantt("argc"), from_integer(0, index_type())));
286286
input.op1()=argc_symbol.symbol_expr();
287-
init_code.move(input);
287+
init_code.add(std::move(input));
288288
}
289289

290290
if(parameters.size()==3)
@@ -311,7 +311,7 @@ bool generate_ansi_c_start_function(
311311
envp_size_symbol.symbol_expr(), ID_le, max_minus_one);
312312

313313
code_assumet assumption(le);
314-
init_code.move(assumption);
314+
init_code.add(std::move(assumption));
315315
}
316316

317317
{
@@ -366,7 +366,7 @@ bool generate_ansi_c_start_function(
366366
const equal_exprt is_null(index_expr, null);
367367

368368
code_assumet assumption2(is_null);
369-
init_code.move(assumption2);
369+
init_code.add(std::move(assumption2));
370370
}
371371

372372
{
@@ -430,7 +430,7 @@ bool generate_ansi_c_start_function(
430430
symbol_table);
431431
}
432432

433-
init_code.move(call_main);
433+
init_code.add(std::move(call_main));
434434

435435
// TODO: add read/modified (recursively in call graph) globals as INPUT/OUTPUT
436436

src/ansi-c/c_nondet_symbol_factory.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ exprt symbol_factoryt::allocate_object(
117117
// <target_expr> = &tmp$<temporary_counter>
118118
code_assignt assign(target_expr, aoe);
119119
assign.add_source_location()=loc;
120-
assignments.move(assign);
120+
assignments.add(std::move(assign));
121121

122122
return aoe;
123123
}
@@ -178,7 +178,7 @@ void symbol_factoryt::gen_nondet_init(
178178
null_check.then_case()=set_null_inst;
179179
null_check.else_case()=non_null_inst;
180180

181-
assignments.move(null_check);
181+
assignments.add(std::move(null_check));
182182
}
183183
}
184184
// TODO(OJones): Add support for structs and arrays
@@ -193,7 +193,7 @@ void symbol_factoryt::gen_nondet_init(
193193
code_assignt assign(expr, rhs);
194194
assign.add_source_location()=loc;
195195

196-
assignments.move(assign);
196+
assignments.add(std::move(assign));
197197
}
198198
}
199199

@@ -249,7 +249,7 @@ symbol_exprt c_nondet_symbol_factory(
249249
{
250250
code_declt decl(symbol_ptr->symbol_expr());
251251
decl.add_source_location()=loc;
252-
init_code.move(decl);
252+
init_code.add(std::move(decl));
253253
}
254254

255255
init_code.append(assignments);
@@ -266,7 +266,7 @@ symbol_exprt c_nondet_symbol_factory(
266266
from_integer(0, index_type())));
267267
input_code.op1()=symbol_ptr->symbol_expr();
268268
input_code.add_source_location()=loc;
269-
init_code.move(input_code);
269+
init_code.add(std::move(input_code));
270270
}
271271

272272
return main_symbol_expr;

src/ansi-c/c_typecheck_code.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -433,7 +433,7 @@ void c_typecheck_baset::typecheck_for(codet &code)
433433
code_blockt code_block;
434434
code_block.add_source_location()=code.op3().source_location();
435435

436-
code_block.move(to_code(code.op3()));
436+
code_block.add(std::move(to_code(code.op3())));
437437
code.op3().swap(code_block);
438438
}
439439
typecheck_code(to_code(code.op3()));
@@ -461,9 +461,9 @@ void c_typecheck_baset::typecheck_for(codet &code)
461461
}
462462

463463
code_block.reserve_operands(2);
464-
code_block.move(to_code(code.op0()));
464+
code_block.add(std::move(to_code(code.op0())));
465465
code.op0().make_nil();
466-
code_block.move(code);
466+
code_block.add(std::move(code));
467467
code.swap(code_block);
468468
typecheck_code(code); // recursive call
469469
}

src/cpp/cpp_constructor.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ optionalt<codet> cpp_typecheckt::cpp_constructor(
116116
auto i_code = cpp_constructor(source_location, index, tmp_operands);
117117

118118
if(i_code.has_value())
119-
new_code.move(i_code.value());
119+
new_code.add(std::move(i_code.value()));
120120
}
121121
return std::move(new_code);
122122
}
@@ -192,8 +192,7 @@ optionalt<codet> cpp_typecheckt::cpp_constructor(
192192
side_effect_exprt assign(ID_assign, typet(), source_location);
193193
assign.move_to_operands(member, val);
194194
typecheck_side_effect_assignment(assign);
195-
code_expressiont code_exp(assign);
196-
block.move(code_exp);
195+
block.add(std::move(code_expressiont(assign)));
197196
}
198197

199198
// enter struct scope

0 commit comments

Comments
 (0)