Skip to content

Commit e24d8f4

Browse files
author
Daniel Kroening
committed
use code_blockt::add and ::move for adding a statement
1 parent 7797757 commit e24d8f4

21 files changed

+134
-133
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
@@ -812,7 +812,7 @@ void java_bytecode_convert_classt::add_array_types(symbol_tablet &symbol_table)
812812
code_blockt clone_body;
813813

814814
code_declt declare_cloned(local_symexpr);
815-
clone_body.move_to_operands(declare_cloned);
815+
clone_body.move(declare_cloned);
816816

817817
source_locationt location;
818818
location.set_function(local_name);
@@ -824,7 +824,7 @@ void java_bytecode_convert_classt::add_array_types(symbol_tablet &symbol_table)
824824
old_array, length_component.get_name(), length_component.type());
825825
java_new_array.copy_to_operands(old_length);
826826
code_assignt create_blank(local_symexpr, java_new_array);
827-
clone_body.move_to_operands(create_blank);
827+
clone_body.move(create_blank);
828828

829829
member_exprt old_data(
830830
old_array, data_component.get_name(), data_component.type());
@@ -854,7 +854,7 @@ void java_bytecode_convert_classt::add_array_types(symbol_tablet &symbol_table)
854854
const auto &index_symexpr=index_symbol.symbol_expr();
855855

856856
code_declt declare_index(index_symexpr);
857-
clone_body.move_to_operands(declare_index);
857+
clone_body.move(declare_index);
858858

859859
code_fort copy_loop;
860860

@@ -877,13 +877,13 @@ void java_bytecode_convert_classt::add_array_types(symbol_tablet &symbol_table)
877877
copy_loop.body()=copy_cell;
878878

879879
// End for-loop
880-
clone_body.move_to_operands(copy_loop);
880+
clone_body.move(copy_loop);
881881

882882
member_exprt new_base_class(
883883
new_array, base_class_component.get_name(), base_class_component.type());
884884
address_of_exprt retval(new_base_class);
885885
code_returnt return_inst(retval);
886-
clone_body.move_to_operands(return_inst);
886+
clone_body.move(return_inst);
887887

888888
symbolt clone_symbol;
889889
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
@@ -871,7 +871,7 @@ code_blockt &java_bytecode_convert_methodt::get_or_create_block_for_pcrange(
871871
for(auto blockidx=child_offset, blocklim=child_offset+nblocks;
872872
blockidx!=blocklim;
873873
++blockidx)
874-
newblock.move_to_operands(this_block_children[blockidx]);
874+
newblock.move(to_code(this_block_children[blockidx]));
875875

876876
// Relabel the inner header:
877877
to_code_label(to_code(newblock.operands()[0])).set_label(new_label_irep);
@@ -1726,7 +1726,7 @@ codet java_bytecode_convert_methodt::convert_instructions(
17261726
{
17271727
symbol_exprt lhs=tmp_variable("$stack", s_it->type());
17281728
code_assignt a(lhs, *s_it);
1729-
more_code.copy_to_operands(a);
1729+
more_code.add(a);
17301730

17311731
s_it->swap(lhs);
17321732
}
@@ -1742,7 +1742,7 @@ codet java_bytecode_convert_methodt::convert_instructions(
17421742
assert(has_prefix(os_it->get_string(ID_C_base_name), "$stack"));
17431743
symbol_exprt lhs=to_symbol_expr(*os_it);
17441744
code_assignt a(lhs, expr);
1745-
more_code.copy_to_operands(a);
1745+
more_code.add(a);
17461746

17471747
expr.swap(lhs);
17481748
++os_it;
@@ -1751,7 +1751,7 @@ codet java_bytecode_convert_methodt::convert_instructions(
17511751

17521752
if(results.empty())
17531753
{
1754-
more_code.copy_to_operands(c);
1754+
more_code.add(c);
17551755
c.swap(more_code);
17561756
}
17571757
else
@@ -1833,7 +1833,7 @@ codet java_bytecode_convert_methodt::convert_instructions(
18331833
if(start_new_block)
18341834
{
18351835
code_labelt newlabel(label(std::to_string(address)), code_blockt());
1836-
root_block.move_to_operands(newlabel);
1836+
root_block.move(newlabel);
18371837
root.branch.push_back(block_tree_nodet::get_leaf());
18381838
assert((root.branch_addresses.empty() ||
18391839
root.branch_addresses.back()<address) &&
@@ -1911,7 +1911,7 @@ codet java_bytecode_convert_methodt::convert_instructions(
19111911
}
19121912

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

19161916
return code;
19171917
}
@@ -2257,8 +2257,8 @@ void java_bytecode_convert_methodt::convert_invoke(
22572257
if(clinit_call.get_statement() != ID_skip)
22582258
{
22592259
code_blockt ret_block;
2260-
ret_block.move_to_operands(clinit_call);
2261-
ret_block.move_to_operands(c);
2260+
ret_block.move(clinit_call);
2261+
ret_block.move(c);
22622262
c = std::move(ret_block);
22632263
}
22642264
}
@@ -2324,8 +2324,8 @@ void java_bytecode_convert_methodt::convert_athrow(
23242324
assume_code.add_source_location() = assume_location;
23252325

23262326
code_blockt ret_block;
2327-
ret_block.move_to_operands(assert_code);
2328-
ret_block.move_to_operands(assume_code);
2327+
ret_block.move(assert_code);
2328+
ret_block.move(assume_code);
23292329
c = ret_block;
23302330
}
23312331
else
@@ -2398,8 +2398,8 @@ codet &java_bytecode_convert_methodt::do_exception_handling(
23982398
}
23992399

24002400
code_blockt try_block;
2401-
try_block.move_to_operands(catch_push);
2402-
try_block.move_to_operands(c);
2401+
try_block.move(catch_push);
2402+
try_block.move(c);
24032403
c = try_block;
24042404
}
24052405
else
@@ -2439,8 +2439,8 @@ codet &java_bytecode_convert_methodt::do_exception_handling(
24392439
// add CATCH_POP instruction
24402440
code_pop_catcht catch_pop;
24412441
code_blockt end_try_block;
2442-
end_try_block.move_to_operands(c);
2443-
end_try_block.move_to_operands(catch_pop);
2442+
end_try_block.move(c);
2443+
end_try_block.move(catch_pop);
24442444
c = end_try_block;
24452445
}
24462446
}
@@ -2467,11 +2467,11 @@ void java_bytecode_convert_methodt::convert_multianewarray(
24672467
constant_exprt size_limit = from_integer(max_array_length, java_int_type());
24682468
binary_relation_exprt le_max_size(op[0], ID_le, size_limit);
24692469
code_assumet assume_le_max_size(le_max_size);
2470-
create.move_to_operands(assume_le_max_size);
2470+
create.move(assume_le_max_size);
24712471
}
24722472

24732473
const exprt tmp = tmp_variable("newarray", ref_type);
2474-
create.copy_to_operands(code_assignt(tmp, java_new_array));
2474+
create.add(code_assignt(tmp, java_new_array));
24752475
c = std::move(create);
24762476
results[0] = tmp;
24772477
}
@@ -2524,10 +2524,10 @@ void java_bytecode_convert_methodt::convert_newarray(
25242524
constant_exprt size_limit = from_integer(max_array_length, java_int_type());
25252525
binary_relation_exprt le_max_size(op[0], ID_le, size_limit);
25262526
code_assumet assume_le_max_size(le_max_size);
2527-
c.move_to_operands(assume_le_max_size);
2527+
to_code_block(c).move(assume_le_max_size);
25282528
}
25292529
const exprt tmp = tmp_variable("newarray", ref_type);
2530-
c.copy_to_operands(code_assignt(tmp, java_new_array));
2530+
to_code_block(c).add(code_assignt(tmp, java_new_array));
25312531
results[0] = tmp;
25322532
}
25332533

@@ -2551,8 +2551,8 @@ void java_bytecode_convert_methodt::convert_new(
25512551
if(clinit_call.get_statement() != ID_skip)
25522552
{
25532553
code_blockt ret_block;
2554-
ret_block.move_to_operands(clinit_call);
2555-
ret_block.move_to_operands(c);
2554+
ret_block.move(clinit_call);
2555+
ret_block.move(c);
25562556
c = std::move(ret_block);
25572557
}
25582558
results[0] = tmp;
@@ -2578,15 +2578,15 @@ codet java_bytecode_convert_methodt::convert_putstatic(
25782578
// the field.
25792579
codet clinit_call = get_clinit_call(arg0.get_string(ID_class));
25802580
if(clinit_call.get_statement() != ID_skip)
2581-
block.move_to_operands(clinit_call);
2581+
block.move(clinit_call);
25822582

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

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

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

@@ -2844,7 +2844,7 @@ code_blockt java_bytecode_convert_methodt::convert_ret(
28442844
code_gotot g(label(number));
28452845
g.add_source_location() = location;
28462846
if(idx == idxlim - 1)
2847-
c.move_to_operands(g);
2847+
c.move(g);
28482848
else
28492849
{
28502850
code_ifthenelset branch;
@@ -2855,7 +2855,7 @@ code_blockt java_bytecode_convert_methodt::convert_ret(
28552855
branch.cond().add_source_location() = location;
28562856
branch.then_case() = g;
28572857
branch.add_source_location() = location;
2858-
c.move_to_operands(branch);
2858+
c.move(branch);
28592859
}
28602860
}
28612861
return c;
@@ -3268,6 +3268,6 @@ void java_bytecode_convert_methodt::create_stack_tmp_var(
32683268
{
32693269
const exprt tmp_var=
32703270
tmp_variable(tmp_var_prefix, tmp_var_type);
3271-
block.copy_to_operands(code_assignt(tmp_var, stack_entry));
3271+
block.add(code_assignt(tmp_var, stack_entry));
32723272
stack_entry=tmp_var;
32733273
}

jbmc/src/java_bytecode/java_bytecode_instrument.cpp

Lines changed: 13 additions & 13 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,7 +452,7 @@ 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(
455+
block.add(
456456
check_null_dereference(
457457
code_function_call.arguments()[0],
458458
code_function_call.source_location()));
@@ -481,7 +481,7 @@ optionalt<codet> java_bytecode_instrumentt::instrument_expr(const exprt &expr)
481481
forall_operands(it, expr)
482482
{
483483
if(optionalt<codet> op_result = instrument_expr(*it))
484-
result.move_to_operands(*op_result);
484+
result.move(*op_result);
485485
}
486486

487487
// Add any check due at this node:
@@ -503,7 +503,7 @@ optionalt<codet> java_bytecode_instrumentt::instrument_expr(const exprt &expr)
503503
dereference_expr,
504504
plus_expr.op1(),
505505
expr.source_location());
506-
result.move_to_operands(bounds_check);
506+
result.move(bounds_check);
507507
}
508508
}
509509
}
@@ -515,7 +515,7 @@ optionalt<codet> java_bytecode_instrumentt::instrument_expr(const exprt &expr)
515515
{
516516
// this corresponds to a throw and so we check that
517517
// we don't throw null
518-
result.copy_to_operands(
518+
result.add(
519519
check_null_dereference(
520520
expr.op0(),
521521
expr.source_location()));
@@ -524,7 +524,7 @@ optionalt<codet> java_bytecode_instrumentt::instrument_expr(const exprt &expr)
524524
{
525525
// this corresponds to new array so we check that
526526
// length is >=0
527-
result.copy_to_operands(
527+
result.add(
528528
check_array_length(
529529
expr.op0(),
530530
expr.source_location()));
@@ -534,7 +534,7 @@ optionalt<codet> java_bytecode_instrumentt::instrument_expr(const exprt &expr)
534534
expr.type().id()==ID_signedbv)
535535
{
536536
// check division by zero (for integer types only)
537-
result.copy_to_operands(
537+
result.add(
538538
check_arithmetic_exception(
539539
expr.op1(),
540540
expr.source_location()));
@@ -548,7 +548,7 @@ optionalt<codet> java_bytecode_instrumentt::instrument_expr(const exprt &expr)
548548
check_null_dereference(
549549
dereference_expr.op0(),
550550
dereference_expr.source_location());
551-
result.move_to_operands(null_dereference_check);
551+
result.move(null_dereference_check);
552552
}
553553

554554
if(result==code_blockt())
@@ -599,7 +599,7 @@ void java_bytecode_instrument_symbol(
599599
/// \param exc_symbol: the top-level exception symbol
600600
/// \param source_location: the source location to attach to the assertion
601601
void java_bytecode_instrument_uncaught_exceptions(
602-
codet &init_code,
602+
code_blockt &init_code,
603603
const symbolt &exc_symbol,
604604
const source_locationt &source_location)
605605
{
@@ -612,7 +612,7 @@ void java_bytecode_instrument_uncaught_exceptions(
612612
assert_location.set_comment("no uncaught exception");
613613
assert_no_exception.add_source_location() = assert_location;
614614

615-
init_code.move_to_operands(assert_no_exception);
615+
init_code.move(assert_no_exception);
616616
}
617617

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

jbmc/src/java_bytecode/java_bytecode_instrument.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ Date: June 2017
1515
#include <util/message.h>
1616
#include <util/irep.h>
1717

18-
class codet;
18+
class code_blockt;
1919

2020
void java_bytecode_instrument_symbol(
2121
symbol_table_baset &symbol_table,
@@ -29,7 +29,7 @@ void java_bytecode_instrument(
2929
message_handlert &_message_handler);
3030

3131
void java_bytecode_instrument_uncaught_exceptions(
32-
codet &init_code,
32+
code_blockt &init_code,
3333
const symbolt &exc_symbol,
3434
const source_locationt &source_location);
3535

0 commit comments

Comments
 (0)