Skip to content

Commit 29bd494

Browse files
author
Daniel Kroening
committed
use code_blockt::add and ::move for adding a statement
1 parent 63bf323 commit 29bd494

20 files changed

+136
-149
lines changed

jbmc/src/java_bytecode/java_bytecode_concurrency_instrumentation.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ static void monitor_exits(codet &code, const codet &monitorexit)
141141
// Replace the return with a monitor exit plus return block
142142
code_blockt return_block;
143143
return_block.add(monitorexit);
144-
return_block.move_to_operands(code);
144+
return_block.move(code);
145145
code = return_block;
146146
}
147147
else if(
@@ -262,11 +262,11 @@ static void instrument_synchronized_code(
262262

263263
// Wrap the code into a try finally
264264
code_blockt try_block;
265-
try_block.move_to_operands(monitorenter);
266-
try_block.move_to_operands(catch_push);
267-
try_block.move_to_operands(code);
268-
try_block.move_to_operands(catch_pop);
269-
try_block.move_to_operands(catch_label);
265+
try_block.move(monitorenter);
266+
try_block.move(catch_push);
267+
try_block.move(code);
268+
try_block.move(catch_pop);
269+
try_block.move(catch_label);
270270
code = try_block;
271271
}
272272

jbmc/src/java_bytecode/java_bytecode_convert_class.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -856,7 +856,7 @@ void java_bytecode_convert_classt::add_array_types(symbol_tablet &symbol_table)
856856
code_blockt clone_body;
857857

858858
code_declt declare_cloned(local_symexpr);
859-
clone_body.move_to_operands(declare_cloned);
859+
clone_body.move(declare_cloned);
860860

861861
source_locationt location;
862862
location.set_function(local_name);
@@ -868,7 +868,7 @@ void java_bytecode_convert_classt::add_array_types(symbol_tablet &symbol_table)
868868
old_array, length_component.get_name(), length_component.type());
869869
java_new_array.copy_to_operands(old_length);
870870
code_assignt create_blank(local_symexpr, java_new_array);
871-
clone_body.move_to_operands(create_blank);
871+
clone_body.move(create_blank);
872872

873873
member_exprt old_data(
874874
old_array, data_component.get_name(), data_component.type());
@@ -898,7 +898,7 @@ void java_bytecode_convert_classt::add_array_types(symbol_tablet &symbol_table)
898898
const auto &index_symexpr=index_symbol.symbol_expr();
899899

900900
code_declt declare_index(index_symexpr);
901-
clone_body.move_to_operands(declare_index);
901+
clone_body.move(declare_index);
902902

903903
code_fort copy_loop;
904904

@@ -921,13 +921,13 @@ void java_bytecode_convert_classt::add_array_types(symbol_tablet &symbol_table)
921921
copy_loop.body()=copy_cell;
922922

923923
// End for-loop
924-
clone_body.move_to_operands(copy_loop);
924+
clone_body.move(copy_loop);
925925

926926
member_exprt new_base_class(
927927
new_array, base_class_component.get_name(), base_class_component.type());
928928
address_of_exprt retval(new_base_class);
929929
code_returnt return_inst(retval);
930-
clone_body.move_to_operands(return_inst);
930+
clone_body.move(return_inst);
931931

932932
symbolt clone_symbol;
933933
clone_symbol.name=clone_name;

jbmc/src/java_bytecode/java_bytecode_convert_method.cpp

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -873,7 +873,7 @@ code_blockt &java_bytecode_convert_methodt::get_or_create_block_for_pcrange(
873873
for(auto blockidx=child_offset, blocklim=child_offset+nblocks;
874874
blockidx!=blocklim;
875875
++blockidx)
876-
newblock.move_to_operands(this_block_children[blockidx]);
876+
newblock.move(to_code(this_block_children[blockidx]));
877877

878878
// Relabel the inner header:
879879
to_code_label(to_code(newblock.operands()[0])).set_label(new_label_irep);
@@ -1728,7 +1728,7 @@ codet java_bytecode_convert_methodt::convert_instructions(
17281728
{
17291729
symbol_exprt lhs=tmp_variable("$stack", s_it->type());
17301730
code_assignt a(lhs, *s_it);
1731-
more_code.copy_to_operands(a);
1731+
more_code.add(a);
17321732

17331733
s_it->swap(lhs);
17341734
}
@@ -1744,7 +1744,7 @@ codet java_bytecode_convert_methodt::convert_instructions(
17441744
assert(has_prefix(os_it->get_string(ID_C_base_name), "$stack"));
17451745
symbol_exprt lhs=to_symbol_expr(*os_it);
17461746
code_assignt a(lhs, expr);
1747-
more_code.copy_to_operands(a);
1747+
more_code.add(a);
17481748

17491749
expr.swap(lhs);
17501750
++os_it;
@@ -1753,7 +1753,7 @@ codet java_bytecode_convert_methodt::convert_instructions(
17531753

17541754
if(results.empty())
17551755
{
1756-
more_code.copy_to_operands(c);
1756+
more_code.add(c);
17571757
c.swap(more_code);
17581758
}
17591759
else
@@ -1835,7 +1835,7 @@ codet java_bytecode_convert_methodt::convert_instructions(
18351835
if(start_new_block)
18361836
{
18371837
code_labelt newlabel(label(std::to_string(address)), code_blockt());
1838-
root_block.move_to_operands(newlabel);
1838+
root_block.move(newlabel);
18391839
root.branch.push_back(block_tree_nodet::get_leaf());
18401840
assert((root.branch_addresses.empty() ||
18411841
root.branch_addresses.back()<address) &&
@@ -1913,7 +1913,7 @@ codet java_bytecode_convert_methodt::convert_instructions(
19131913
}
19141914

19151915
for(auto &block : root_block.operands())
1916-
code.move_to_operands(block);
1916+
code.move(to_code(block));
19171917

19181918
return code;
19191919
}
@@ -2258,8 +2258,8 @@ void java_bytecode_convert_methodt::convert_invoke(
22582258
if(clinit_call.get_statement() != ID_skip)
22592259
{
22602260
code_blockt ret_block;
2261-
ret_block.move_to_operands(clinit_call);
2262-
ret_block.move_to_operands(c);
2261+
ret_block.move(clinit_call);
2262+
ret_block.move(c);
22632263
c = std::move(ret_block);
22642264
}
22652265
}
@@ -2325,8 +2325,8 @@ void java_bytecode_convert_methodt::convert_athrow(
23252325
assume_code.add_source_location() = assume_location;
23262326

23272327
code_blockt ret_block;
2328-
ret_block.move_to_operands(assert_code);
2329-
ret_block.move_to_operands(assume_code);
2328+
ret_block.move(assert_code);
2329+
ret_block.move(assume_code);
23302330
c = ret_block;
23312331
}
23322332
else
@@ -2399,8 +2399,8 @@ codet &java_bytecode_convert_methodt::do_exception_handling(
23992399
}
24002400

24012401
code_blockt try_block;
2402-
try_block.move_to_operands(catch_push);
2403-
try_block.move_to_operands(c);
2402+
try_block.move(catch_push);
2403+
try_block.move(c);
24042404
c = try_block;
24052405
}
24062406
else
@@ -2440,8 +2440,8 @@ codet &java_bytecode_convert_methodt::do_exception_handling(
24402440
// add CATCH_POP instruction
24412441
code_pop_catcht catch_pop;
24422442
code_blockt end_try_block;
2443-
end_try_block.move_to_operands(c);
2444-
end_try_block.move_to_operands(catch_pop);
2443+
end_try_block.move(c);
2444+
end_try_block.move(catch_pop);
24452445
c = end_try_block;
24462446
}
24472447
}
@@ -2468,11 +2468,11 @@ void java_bytecode_convert_methodt::convert_multianewarray(
24682468
constant_exprt size_limit = from_integer(max_array_length, java_int_type());
24692469
binary_relation_exprt le_max_size(op[0], ID_le, size_limit);
24702470
code_assumet assume_le_max_size(le_max_size);
2471-
create.move_to_operands(assume_le_max_size);
2471+
create.move(assume_le_max_size);
24722472
}
24732473

24742474
const exprt tmp = tmp_variable("newarray", ref_type);
2475-
create.copy_to_operands(code_assignt(tmp, java_new_array));
2475+
create.add(code_assignt(tmp, java_new_array));
24762476
c = std::move(create);
24772477
results[0] = tmp;
24782478
}
@@ -2525,10 +2525,10 @@ void java_bytecode_convert_methodt::convert_newarray(
25252525
constant_exprt size_limit = from_integer(max_array_length, java_int_type());
25262526
binary_relation_exprt le_max_size(op[0], ID_le, size_limit);
25272527
code_assumet assume_le_max_size(le_max_size);
2528-
c.move_to_operands(assume_le_max_size);
2528+
to_code_block(c).move(assume_le_max_size);
25292529
}
25302530
const exprt tmp = tmp_variable("newarray", ref_type);
2531-
c.copy_to_operands(code_assignt(tmp, java_new_array));
2531+
to_code_block(c).add(code_assignt(tmp, java_new_array));
25322532
results[0] = tmp;
25332533
}
25342534

@@ -2552,8 +2552,8 @@ void java_bytecode_convert_methodt::convert_new(
25522552
if(clinit_call.get_statement() != ID_skip)
25532553
{
25542554
code_blockt ret_block;
2555-
ret_block.move_to_operands(clinit_call);
2556-
ret_block.move_to_operands(c);
2555+
ret_block.move(clinit_call);
2556+
ret_block.move(c);
25572557
c = std::move(ret_block);
25582558
}
25592559
results[0] = tmp;
@@ -2579,15 +2579,15 @@ codet java_bytecode_convert_methodt::convert_putstatic(
25792579
// the field.
25802580
codet clinit_call = get_clinit_call(arg0.get_string(ID_class));
25812581
if(clinit_call.get_statement() != ID_skip)
2582-
block.move_to_operands(clinit_call);
2582+
block.move(clinit_call);
25832583

25842584
save_stack_entries(
25852585
"stack_static_field",
25862586
symbol_expr.type(),
25872587
block,
25882588
bytecode_write_typet::STATIC_FIELD,
25892589
symbol_expr.get_identifier());
2590-
block.copy_to_operands(code_assignt(symbol_expr, op[0]));
2590+
block.add(code_assignt(symbol_expr, op[0]));
25912591
return block;
25922592
}
25932593

@@ -2602,7 +2602,7 @@ codet java_bytecode_convert_methodt::convert_putfield(
26022602
block,
26032603
bytecode_write_typet::FIELD,
26042604
arg0.get(ID_component_name));
2605-
block.copy_to_operands(code_assignt(to_member(op[0], arg0), op[1]));
2605+
block.add(code_assignt(to_member(op[0], arg0), op[1]));
26062606
return block;
26072607
}
26082608

@@ -2744,7 +2744,7 @@ codet java_bytecode_convert_methodt::convert_iinc(
27442744
arg1_int_type.make_typecast(java_int_type());
27452745
code_assign.rhs() =
27462746
plus_exprt(variable(arg0, 'i', address, CAST_AS_NEEDED), arg1_int_type);
2747-
block.copy_to_operands(code_assign);
2747+
block.add(code_assign);
27482748
return block;
27492749
}
27502750

@@ -2849,7 +2849,7 @@ code_blockt java_bytecode_convert_methodt::convert_ret(
28492849
code_gotot g(label(number));
28502850
g.add_source_location() = location;
28512851
if(idx == idxlim - 1)
2852-
c.move_to_operands(g);
2852+
c.move(g);
28532853
else
28542854
{
28552855
code_ifthenelset branch;
@@ -2860,7 +2860,7 @@ code_blockt java_bytecode_convert_methodt::convert_ret(
28602860
branch.cond().add_source_location() = location;
28612861
branch.then_case() = g;
28622862
branch.add_source_location() = location;
2863-
c.move_to_operands(branch);
2863+
c.move(branch);
28642864
}
28652865
}
28662866
return c;
@@ -3274,6 +3274,6 @@ void java_bytecode_convert_methodt::create_stack_tmp_var(
32743274
{
32753275
const exprt tmp_var=
32763276
tmp_variable(tmp_var_prefix, tmp_var_type);
3277-
block.copy_to_operands(code_assignt(tmp_var, stack_entry));
3277+
block.add(code_assignt(tmp_var, stack_entry));
32783278
stack_entry=tmp_var;
32793279
}

jbmc/src/java_bytecode/java_bytecode_instrument.cpp

Lines changed: 15 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -129,8 +129,8 @@ codet java_bytecode_instrumentt::throw_exception(
129129
throw_expr.copy_to_operands(new_symbol.symbol_expr());
130130

131131
code_blockt throw_code;
132-
throw_code.move_to_operands(assign_new);
133-
throw_code.copy_to_operands(code_expressiont(throw_expr));
132+
throw_code.move(assign_new);
133+
throw_code.add(code_expressiont(throw_expr));
134134

135135
code_ifthenelset if_code;
136136
if_code.add_source_location()=original_loc;
@@ -333,7 +333,7 @@ void java_bytecode_instrumentt::add_expr_instrumentation(
333333
if(expr_instrumentation->get_statement() == ID_block)
334334
block.append(to_code_block(*expr_instrumentation));
335335
else
336-
block.move_to_operands(*expr_instrumentation);
336+
block.move(*expr_instrumentation);
337337
}
338338
}
339339

@@ -350,7 +350,7 @@ void java_bytecode_instrumentt::prepend_instrumentation(
350350
if(code.get_statement()==ID_block)
351351
instrumentation.append(to_code_block(code));
352352
else
353-
instrumentation.copy_to_operands(code);
353+
instrumentation.add(code);
354354
code=instrumentation;
355355
}
356356
}
@@ -452,10 +452,9 @@ void java_bytecode_instrumentt::instrument_code(codet &code)
452452
// Check for a null this-argument of a virtual call:
453453
if(function_type.has_this())
454454
{
455-
block.copy_to_operands(
456-
check_null_dereference(
457-
code_function_call.arguments()[0],
458-
code_function_call.source_location()));
455+
block.add(check_null_dereference(
456+
code_function_call.arguments()[0],
457+
code_function_call.source_location()));
459458
}
460459

461460
for(const auto &arg : code_function_call.arguments())
@@ -481,7 +480,7 @@ optionalt<codet> java_bytecode_instrumentt::instrument_expr(const exprt &expr)
481480
forall_operands(it, expr)
482481
{
483482
if(optionalt<codet> op_result = instrument_expr(*it))
484-
result.move_to_operands(*op_result);
483+
result.move(*op_result);
485484
}
486485

487486
// Add any check due at this node:
@@ -503,7 +502,7 @@ optionalt<codet> java_bytecode_instrumentt::instrument_expr(const exprt &expr)
503502
dereference_expr,
504503
plus_expr.op1(),
505504
expr.source_location());
506-
result.move_to_operands(bounds_check);
505+
result.move(bounds_check);
507506
}
508507
}
509508
}
@@ -515,29 +514,20 @@ optionalt<codet> java_bytecode_instrumentt::instrument_expr(const exprt &expr)
515514
{
516515
// this corresponds to a throw and so we check that
517516
// we don't throw null
518-
result.copy_to_operands(
519-
check_null_dereference(
520-
expr.op0(),
521-
expr.source_location()));
517+
result.add(check_null_dereference(expr.op0(), expr.source_location()));
522518
}
523519
else if(statement==ID_java_new_array)
524520
{
525521
// this corresponds to new array so we check that
526522
// length is >=0
527-
result.copy_to_operands(
528-
check_array_length(
529-
expr.op0(),
530-
expr.source_location()));
523+
result.add(check_array_length(expr.op0(), expr.source_location()));
531524
}
532525
}
533526
else if((expr.id()==ID_div || expr.id()==ID_mod) &&
534527
expr.type().id()==ID_signedbv)
535528
{
536529
// check division by zero (for integer types only)
537-
result.copy_to_operands(
538-
check_arithmetic_exception(
539-
expr.op1(),
540-
expr.source_location()));
530+
result.add(check_arithmetic_exception(expr.op1(), expr.source_location()));
541531
}
542532
else if(expr.id()==ID_dereference &&
543533
expr.get_bool(ID_java_member_access))
@@ -548,7 +538,7 @@ optionalt<codet> java_bytecode_instrumentt::instrument_expr(const exprt &expr)
548538
check_null_dereference(
549539
dereference_expr.op0(),
550540
dereference_expr.source_location());
551-
result.move_to_operands(null_dereference_check);
541+
result.move(null_dereference_check);
552542
}
553543

554544
if(result==code_blockt())
@@ -599,7 +589,7 @@ void java_bytecode_instrument_symbol(
599589
/// \param exc_symbol: the top-level exception symbol
600590
/// \param source_location: the source location to attach to the assertion
601591
void java_bytecode_instrument_uncaught_exceptions(
602-
codet &init_code,
592+
code_blockt &init_code,
603593
const symbolt &exc_symbol,
604594
const source_locationt &source_location)
605595
{
@@ -612,7 +602,7 @@ void java_bytecode_instrument_uncaught_exceptions(
612602
assert_location.set_comment("no uncaught exception");
613603
assert_no_exception.add_source_location() = assert_location;
614604

615-
init_code.move_to_operands(assert_no_exception);
605+
init_code.move(assert_no_exception);
616606
}
617607

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

0 commit comments

Comments
 (0)