Skip to content

Commit 5a8e79d

Browse files
author
Daniel Kroening
committed
use code_blockt::add and ::move for adding a statement
1 parent 2c451e9 commit 5a8e79d

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
}
@@ -2252,8 +2252,8 @@ void java_bytecode_convert_methodt::convert_invoke(
22522252
if(clinit_call.get_statement() != ID_skip)
22532253
{
22542254
code_blockt ret_block;
2255-
ret_block.move_to_operands(clinit_call);
2256-
ret_block.move_to_operands(c);
2255+
ret_block.move(clinit_call);
2256+
ret_block.move(c);
22572257
c = std::move(ret_block);
22582258
}
22592259
}
@@ -2319,8 +2319,8 @@ void java_bytecode_convert_methodt::convert_athrow(
23192319
assume_code.add_source_location() = assume_location;
23202320

23212321
code_blockt ret_block;
2322-
ret_block.move_to_operands(assert_code);
2323-
ret_block.move_to_operands(assume_code);
2322+
ret_block.move(assert_code);
2323+
ret_block.move(assume_code);
23242324
c = ret_block;
23252325
}
23262326
else
@@ -2393,8 +2393,8 @@ codet &java_bytecode_convert_methodt::do_exception_handling(
23932393
}
23942394

23952395
code_blockt try_block;
2396-
try_block.move_to_operands(catch_push);
2397-
try_block.move_to_operands(c);
2396+
try_block.move(catch_push);
2397+
try_block.move(c);
23982398
c = try_block;
23992399
}
24002400
else
@@ -2434,8 +2434,8 @@ codet &java_bytecode_convert_methodt::do_exception_handling(
24342434
// add CATCH_POP instruction
24352435
code_pop_catcht catch_pop;
24362436
code_blockt end_try_block;
2437-
end_try_block.move_to_operands(c);
2438-
end_try_block.move_to_operands(catch_pop);
2437+
end_try_block.move(c);
2438+
end_try_block.move(catch_pop);
24392439
c = end_try_block;
24402440
}
24412441
}
@@ -2462,11 +2462,11 @@ void java_bytecode_convert_methodt::convert_multianewarray(
24622462
constant_exprt size_limit = from_integer(max_array_length, java_int_type());
24632463
binary_relation_exprt le_max_size(op[0], ID_le, size_limit);
24642464
code_assumet assume_le_max_size(le_max_size);
2465-
create.move_to_operands(assume_le_max_size);
2465+
create.move(assume_le_max_size);
24662466
}
24672467

24682468
const exprt tmp = tmp_variable("newarray", ref_type);
2469-
create.copy_to_operands(code_assignt(tmp, java_new_array));
2469+
create.add(code_assignt(tmp, java_new_array));
24702470
c = std::move(create);
24712471
results[0] = tmp;
24722472
}
@@ -2519,10 +2519,10 @@ void java_bytecode_convert_methodt::convert_newarray(
25192519
constant_exprt size_limit = from_integer(max_array_length, java_int_type());
25202520
binary_relation_exprt le_max_size(op[0], ID_le, size_limit);
25212521
code_assumet assume_le_max_size(le_max_size);
2522-
c.move_to_operands(assume_le_max_size);
2522+
to_code_block(c).move(assume_le_max_size);
25232523
}
25242524
const exprt tmp = tmp_variable("newarray", ref_type);
2525-
c.copy_to_operands(code_assignt(tmp, java_new_array));
2525+
to_code_block(c).add(code_assignt(tmp, java_new_array));
25262526
results[0] = tmp;
25272527
}
25282528

@@ -2546,8 +2546,8 @@ void java_bytecode_convert_methodt::convert_new(
25462546
if(clinit_call.get_statement() != ID_skip)
25472547
{
25482548
code_blockt ret_block;
2549-
ret_block.move_to_operands(clinit_call);
2550-
ret_block.move_to_operands(c);
2549+
ret_block.move(clinit_call);
2550+
ret_block.move(c);
25512551
c = std::move(ret_block);
25522552
}
25532553
results[0] = tmp;
@@ -2573,15 +2573,15 @@ codet java_bytecode_convert_methodt::convert_putstatic(
25732573
// the field.
25742574
codet clinit_call = get_clinit_call(arg0.get_string(ID_class));
25752575
if(clinit_call.get_statement() != ID_skip)
2576-
block.move_to_operands(clinit_call);
2576+
block.move(clinit_call);
25772577

25782578
save_stack_entries(
25792579
"stack_static_field",
25802580
symbol_expr.type(),
25812581
block,
25822582
bytecode_write_typet::STATIC_FIELD,
25832583
symbol_expr.get_identifier());
2584-
block.copy_to_operands(code_assignt(symbol_expr, op[0]));
2584+
block.add(code_assignt(symbol_expr, op[0]));
25852585
return block;
25862586
}
25872587

@@ -2596,7 +2596,7 @@ codet java_bytecode_convert_methodt::convert_putfield(
25962596
block,
25972597
bytecode_write_typet::FIELD,
25982598
arg0.get(ID_component_name));
2599-
block.copy_to_operands(code_assignt(to_member(op[0], arg0), op[1]));
2599+
block.add(code_assignt(to_member(op[0], arg0), op[1]));
26002600
return block;
26012601
}
26022602

@@ -2738,7 +2738,7 @@ codet java_bytecode_convert_methodt::convert_iinc(
27382738
arg1_int_type.make_typecast(java_int_type());
27392739
code_assign.rhs() =
27402740
plus_exprt(variable(arg0, 'i', address, CAST_AS_NEEDED), arg1_int_type);
2741-
block.copy_to_operands(code_assign);
2741+
block.add(code_assign);
27422742
return block;
27432743
}
27442744

@@ -2839,7 +2839,7 @@ code_blockt java_bytecode_convert_methodt::convert_ret(
28392839
code_gotot g(label(number));
28402840
g.add_source_location() = location;
28412841
if(idx == idxlim - 1)
2842-
c.move_to_operands(g);
2842+
c.move(g);
28432843
else
28442844
{
28452845
code_ifthenelset branch;
@@ -2850,7 +2850,7 @@ code_blockt java_bytecode_convert_methodt::convert_ret(
28502850
branch.cond().add_source_location() = location;
28512851
branch.then_case() = g;
28522852
branch.add_source_location() = location;
2853-
c.move_to_operands(branch);
2853+
c.move(branch);
28542854
}
28552855
}
28562856
return c;
@@ -3263,6 +3263,6 @@ void java_bytecode_convert_methodt::create_stack_tmp_var(
32633263
{
32643264
const exprt tmp_var=
32653265
tmp_variable(tmp_var_prefix, tmp_var_type);
3266-
block.copy_to_operands(code_assignt(tmp_var, stack_entry));
3266+
block.add(code_assignt(tmp_var, stack_entry));
32673267
stack_entry=tmp_var;
32683268
}

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)