@@ -634,51 +634,10 @@ void goto_convertt::do_java_new_array(
634
634
deref,
635
635
struct_type.components ()[2 ].get_name (),
636
636
struct_type.components ()[2 ].type ());
637
-
638
- // Allocate a (struct realtype**) instead of a (void**) if possible.
639
- const irept &given_element_type=object_type.find (ID_C_element_type);
640
- typet allocate_data_type;
641
- if (given_element_type.is_not_nil ())
642
- {
643
- allocate_data_type=
644
- pointer_type (static_cast <const typet &>(given_element_type));
645
- }
646
- else
647
- allocate_data_type=data.type ();
648
-
649
- side_effect_exprt data_java_new_expr (
650
- ID_java_new_array_data, allocate_data_type);
651
-
652
- // The instruction may specify a (hopefully small) upper bound on the
653
- // array size, in which case we allocate a fixed-length array that may
654
- // be larger than the `length` member rather than use a true variable-
655
- // length array, which produces a more complex formula in the current
656
- // backend.
657
- const irept size_bound=rhs.find (ID_length_upper_bound);
658
- if (size_bound.is_nil ())
659
- data_java_new_expr.set (ID_size, rhs.op0 ());
660
- else
661
- data_java_new_expr.set (ID_size, size_bound);
662
-
663
- // Must directly assign the new array to a temporary
664
- // because goto-symex will notice `x=side_effect_exprt` but not
665
- // `x=typecast_exprt(side_effect_exprt(...))`
666
- symbol_exprt new_array_data_symbol=
667
- new_tmp_symbol (
668
- data_java_new_expr.type (),
669
- " new_array_data" ,
670
- dest,
671
- location)
672
- .symbol_expr ();
673
- goto_programt::targett t_p2=dest.add_instruction (ASSIGN);
674
- t_p2->code =code_assignt (new_array_data_symbol, data_java_new_expr);
675
- t_p2->source_location =location;
676
-
637
+ side_effect_exprt data_cpp_new_expr (ID_cpp_new_array, data.type ());
638
+ data_cpp_new_expr.set (ID_size, rhs.op0 ());
677
639
goto_programt::targett t_p=dest.add_instruction (ASSIGN);
678
- exprt cast_java_new=new_array_data_symbol;
679
- if (cast_java_new.type ()!=data.type ())
680
- cast_java_new=typecast_exprt (cast_java_new, data.type ());
681
- t_p->code =code_assignt (data, cast_java_new);
640
+ t_p->code =code_assignt (data, data_cpp_new_expr);
682
641
t_p->source_location =location;
683
642
684
643
// zero-initialize the data
@@ -691,7 +650,7 @@ void goto_convertt::do_java_new_array(
691
650
ns,
692
651
get_message_handler ());
693
652
codet array_set (ID_array_set);
694
- array_set.copy_to_operands (new_array_data_symbol , zero_element);
653
+ array_set.copy_to_operands (data , zero_element);
695
654
goto_programt::targett t_d=dest.add_instruction (OTHER);
696
655
t_d->code =array_set;
697
656
t_d->source_location =location;
0 commit comments