Skip to content

Commit b5351f2

Browse files
committed
Return converted code by value for consistency
All other methods in this API that always return a value did so via the return value, and thus this change adds consistency.
1 parent 51236f2 commit b5351f2

File tree

2 files changed

+13
-14
lines changed

2 files changed

+13
-14
lines changed

jbmc/src/java_bytecode/java_bytecode_convert_method.cpp

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1614,7 +1614,7 @@ codet java_bytecode_convert_methodt::convert_instructions(
16141614
{
16151615
// the op is the array size
16161616
PRECONDITION(op.size() == 1 && results.size() == 1);
1617-
convert_newarray(i_it->source_location, statement, arg0, op, c, results);
1617+
c = convert_newarray(i_it->source_location, statement, arg0, op, results);
16181618
}
16191619
else if(statement=="multianewarray")
16201620
{
@@ -1627,7 +1627,7 @@ codet java_bytecode_convert_methodt::convert_instructions(
16271627

16281628
op=pop(dimension);
16291629
assert(results.size()==1);
1630-
convert_multianewarray(i_it->source_location, arg0, op, c, results);
1630+
c = convert_multianewarray(i_it->source_location, arg0, op, results);
16311631
}
16321632
else if(statement=="arraylength")
16331633
{
@@ -2430,11 +2430,10 @@ codet &java_bytecode_convert_methodt::do_exception_handling(
24302430
return c;
24312431
}
24322432

2433-
void java_bytecode_convert_methodt::convert_multianewarray(
2433+
code_blockt java_bytecode_convert_methodt::convert_multianewarray(
24342434
const source_locationt &location,
24352435
const exprt &arg0,
24362436
const exprt::operandst &op,
2437-
codet &c,
24382437
exprt::operandst &results)
24392438
{
24402439
PRECONDITION(!location.get_line().empty());
@@ -2454,16 +2453,16 @@ void java_bytecode_convert_methodt::convert_multianewarray(
24542453

24552454
const exprt tmp = tmp_variable("newarray", ref_type);
24562455
create.add(code_assignt(tmp, java_new_array));
2457-
c = std::move(create);
24582456
results[0] = tmp;
2457+
2458+
return create;
24592459
}
24602460

2461-
void java_bytecode_convert_methodt::convert_newarray(
2461+
code_blockt java_bytecode_convert_methodt::convert_newarray(
24622462
const source_locationt &location,
24632463
const irep_idt &statement,
24642464
const exprt &arg0,
24652465
const exprt::operandst &op,
2466-
codet &c,
24672466
exprt::operandst &results)
24682467
{
24692468
char element_type;
@@ -2499,18 +2498,20 @@ void java_bytecode_convert_methodt::convert_newarray(
24992498
side_effect_exprt java_new_array(ID_java_new_array, ref_type, location);
25002499
java_new_array.copy_to_operands(op[0]);
25012500

2502-
c = code_blockt();
2501+
code_blockt block;
25032502

25042503
if(max_array_length != 0)
25052504
{
25062505
constant_exprt size_limit = from_integer(max_array_length, java_int_type());
25072506
binary_relation_exprt le_max_size(op[0], ID_le, size_limit);
25082507
code_assumet assume_le_max_size(le_max_size);
2509-
to_code_block(c).add(assume_le_max_size);
2508+
block.add(assume_le_max_size);
25102509
}
25112510
const exprt tmp = tmp_variable("newarray", ref_type);
2512-
to_code_block(c).add(code_assignt(tmp, java_new_array));
2511+
block.add(code_assignt(tmp, java_new_array));
25132512
results[0] = tmp;
2513+
2514+
return block;
25142515
}
25152516

25162517
void java_bytecode_convert_methodt::convert_new(

jbmc/src/java_bytecode/java_bytecode_convert_method_class.h

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -408,19 +408,17 @@ class java_bytecode_convert_methodt:public messaget
408408
codet &c,
409409
exprt::operandst &results);
410410

411-
void convert_newarray(
411+
code_blockt convert_newarray(
412412
const source_locationt &location,
413413
const irep_idt &statement,
414414
const exprt &arg0,
415415
const exprt::operandst &op,
416-
codet &c,
417416
exprt::operandst &results);
418417

419-
void convert_multianewarray(
418+
code_blockt convert_multianewarray(
420419
const source_locationt &location,
421420
const exprt &arg0,
422421
const exprt::operandst &op,
423-
codet &c,
424422
exprt::operandst &results);
425423

426424
codet &do_exception_handling(

0 commit comments

Comments
 (0)