@@ -714,9 +714,9 @@ void java_bytecode_convert_methodt::replace_goto_target(
714
714
code_blockt &java_bytecode_convert_methodt::get_block_for_pcrange (
715
715
block_tree_nodet &tree,
716
716
code_blockt &this_block,
717
- unsigned address_start,
718
- unsigned address_limit,
719
- unsigned next_block_start_address)
717
+ method_offsett address_start,
718
+ method_offsett address_limit,
719
+ method_offsett next_block_start_address)
720
720
{
721
721
address_mapt dummy;
722
722
return get_or_create_block_for_pcrange (
@@ -746,9 +746,9 @@ code_blockt &java_bytecode_convert_methodt::get_block_for_pcrange(
746
746
code_blockt &java_bytecode_convert_methodt::get_or_create_block_for_pcrange (
747
747
block_tree_nodet &tree,
748
748
code_blockt &this_block,
749
- unsigned address_start,
750
- unsigned address_limit,
751
- unsigned next_block_start_address,
749
+ method_offsett address_start,
750
+ method_offsett address_limit,
751
+ method_offsett next_block_start_address,
752
752
const address_mapt &amap,
753
753
bool allow_merge)
754
754
{
@@ -778,10 +778,9 @@ code_blockt &java_bytecode_convert_methodt::get_or_create_block_for_pcrange(
778
778
tree.branch_addresses .begin (),
779
779
tree.branch_addresses .end (),
780
780
address_limit);
781
- unsigned findlim_block_start_address=
782
- findlim==tree.branch_addresses .end () ?
783
- next_block_start_address :
784
- (*findlim);
781
+ const auto findlim_block_start_address =
782
+ findlim == tree.branch_addresses .end () ? next_block_start_address
783
+ : (*findlim);
785
784
786
785
// If all children are in scope, return this.
787
786
if (findstart==tree.branch_addresses .begin () &&
@@ -924,7 +923,7 @@ code_blockt &java_bytecode_convert_methodt::get_or_create_block_for_pcrange(
924
923
}
925
924
926
925
static void gather_symbol_live_ranges (
927
- unsigned pc,
926
+ java_bytecode_convert_methodt::method_offsett pc,
928
927
const exprt &e,
929
928
std::map<irep_idt, java_bytecode_convert_methodt::variablet> &result)
930
929
{
@@ -1002,9 +1001,9 @@ codet java_bytecode_convert_methodt::convert_instructions(
1002
1001
// first pass: get targets and map addresses to instructions
1003
1002
1004
1003
address_mapt address_map;
1005
- std::set<unsigned > targets;
1004
+ std::set<method_offsett > targets;
1006
1005
1007
- std::vector<unsigned > jsr_ret_targets;
1006
+ std::vector<method_offsett > jsr_ret_targets;
1008
1007
std::vector<instructionst::const_iterator> ret_instructions;
1009
1008
1010
1009
for (auto i_it = instructions.begin (); i_it != instructions.end (); i_it++)
@@ -1049,9 +1048,9 @@ codet java_bytecode_convert_methodt::convert_instructions(
1049
1048
(threading_support && (i_it->statement ==" monitorenter" ||
1050
1049
i_it->statement ==" monitorexit" )))
1051
1050
{
1052
- const std::vector<unsigned int > handler =
1051
+ const std::vector<method_offsett > handler =
1053
1052
try_catch_handler (i_it->address , method.exception_table );
1054
- std::list<unsigned int > &successors = a_entry.first ->second .successors ;
1053
+ std::list<method_offsett > &successors = a_entry.first ->second .successors ;
1055
1054
successors.insert (successors.end (), handler.begin (), handler.end ());
1056
1055
targets.insert (handler.begin (), handler.end ());
1057
1056
}
@@ -1110,7 +1109,7 @@ codet java_bytecode_convert_methodt::convert_instructions(
1110
1109
1111
1110
for (const auto &address : address_map)
1112
1111
{
1113
- for (unsigned s : address.second .successors )
1112
+ for (auto s : address.second .successors )
1114
1113
{
1115
1114
const auto a_it = address_map.find (s);
1116
1115
CHECK_RETURN (a_it != address_map.end ());
@@ -1128,7 +1127,7 @@ codet java_bytecode_convert_methodt::convert_instructions(
1128
1127
// (these require the graph to determine live ranges)
1129
1128
setup_local_variables (method, address_map);
1130
1129
1131
- std::set<unsigned > working_set;
1130
+ std::set<method_offsett > working_set;
1132
1131
1133
1132
if (!instructions.empty ())
1134
1133
working_set.insert (instructions.front ().address );
@@ -1139,7 +1138,7 @@ codet java_bytecode_convert_methodt::convert_instructions(
1139
1138
auto address_it = address_map.find (*cur);
1140
1139
CHECK_RETURN (address_it != address_map.end ());
1141
1140
auto &instruction = address_it->second ;
1142
- unsigned cur_pc= *cur;
1141
+ const method_offsett cur_pc = *cur;
1143
1142
working_set.erase (cur);
1144
1143
1145
1144
if (instruction.done )
@@ -1698,7 +1697,7 @@ codet java_bytecode_convert_methodt::convert_instructions(
1698
1697
push (results);
1699
1698
1700
1699
instruction.done = true ;
1701
- for (const unsigned address : instruction.successors )
1700
+ for (const auto address : instruction.successors )
1702
1701
{
1703
1702
address_mapt::iterator a_it2=address_map.find (address);
1704
1703
CHECK_RETURN (a_it2 != address_map.end ());
@@ -1807,10 +1806,10 @@ codet java_bytecode_convert_methodt::convert_instructions(
1807
1806
// constructs as variable live-ranges require next.
1808
1807
bool start_new_block=true ;
1809
1808
bool has_seen_previous_address=false ;
1810
- unsigned previous_address= 0 ;
1809
+ method_offsett previous_address = 0 ;
1811
1810
for (const auto &address_pair : address_map)
1812
1811
{
1813
- const unsigned address= address_pair.first ;
1812
+ const method_offsett address = address_pair.first ;
1814
1813
assert (address_pair.first ==address_pair.second .source ->address );
1815
1814
const codet &c=address_pair.second .code ;
1816
1815
@@ -1890,8 +1889,8 @@ codet java_bytecode_convert_methodt::convert_instructions(
1890
1889
root,
1891
1890
root_block,
1892
1891
v.start_pc ,
1893
- v.start_pc + v.length ,
1894
- std::numeric_limits<unsigned >::max (),
1892
+ v.start_pc + v.length ,
1893
+ std::numeric_limits<method_offsett >::max (),
1895
1894
address_map);
1896
1895
}
1897
1896
for (const auto vp : vars_to_process)
@@ -1902,12 +1901,12 @@ codet java_bytecode_convert_methodt::convert_instructions(
1902
1901
// Skip anonymous variables:
1903
1902
if (v.symbol_expr .get_identifier ().empty ())
1904
1903
continue ;
1905
- auto &block= get_block_for_pcrange (
1904
+ auto &block = get_block_for_pcrange (
1906
1905
root,
1907
1906
root_block,
1908
1907
v.start_pc ,
1909
- v.start_pc + v.length ,
1910
- std::numeric_limits<unsigned >::max ());
1908
+ v.start_pc + v.length ,
1909
+ std::numeric_limits<method_offsett >::max ());
1911
1910
code_declt d (v.symbol_expr );
1912
1911
block.operands ().insert (block.operands ().begin (), d);
1913
1912
}
@@ -1963,7 +1962,9 @@ codet java_bytecode_convert_methodt::convert_switch(
1963
1962
// to the jump target of the tableswitch/lookupswitch case at
1964
1963
// hand. Therefore we consider this code to belong to the source bytecode
1965
1964
// instruction and not the target instruction.
1966
- code_case.code () = code_gotot (label (integer2string (number)));
1965
+ const method_offsett label_number =
1966
+ numeric_cast_v<method_offsett>(number);
1967
+ code_case.code () = code_gotot (label (std::to_string (label_number)));
1967
1968
code_case.code ().add_source_location () = location;
1968
1969
1969
1970
if (a_it == args.begin ())
@@ -2338,8 +2339,8 @@ void java_bytecode_convert_methodt::convert_athrow(
2338
2339
2339
2340
codet &java_bytecode_convert_methodt::do_exception_handling (
2340
2341
const java_bytecode_convert_methodt::methodt &method,
2341
- const std::set<unsigned int > &working_set,
2342
- unsigned int cur_pc,
2342
+ const std::set<method_offsett > &working_set,
2343
+ method_offsett cur_pc,
2343
2344
codet &c)
2344
2345
{
2345
2346
std::vector<irep_idt> exception_ids;
@@ -2350,8 +2351,8 @@ codet &java_bytecode_convert_methodt::do_exception_handling(
2350
2351
// together with a list of all the exception ids
2351
2352
2352
2353
// be aware of different try-catch blocks with the same starting pc
2353
- std:: size_t pos = 0 ;
2354
- std:: size_t end_pc = 0 ;
2354
+ method_offsett pos = 0 ;
2355
+ method_offsett end_pc = 0 ;
2355
2356
while (pos < method.exception_table .size ())
2356
2357
{
2357
2358
// check if this is the beginning of a try block
@@ -2722,7 +2723,7 @@ codet java_bytecode_convert_methodt::convert_iinc(
2722
2723
const exprt &arg0,
2723
2724
const exprt &arg1,
2724
2725
const source_locationt &location,
2725
- const unsigned address)
2726
+ const method_offsett address)
2726
2727
{
2727
2728
code_blockt block;
2728
2729
block.add_source_location () = location;
@@ -2756,9 +2757,10 @@ codet java_bytecode_convert_methodt::convert_ifnull(
2756
2757
const typecast_exprt lhs (op[0 ], java_reference_type (empty_typet ()));
2757
2758
const exprt rhs (null_pointer_exprt (to_pointer_type (lhs.type ())));
2758
2759
code_branch.cond () = binary_relation_exprt (lhs, ID_equal, rhs);
2759
- code_branch.then_case () = code_gotot (label (integer2string (number)));
2760
+ const method_offsett label_number = numeric_cast_v<method_offsett>(number);
2761
+ code_branch.then_case () = code_gotot (label (std::to_string (label_number)));
2760
2762
code_branch.then_case ().add_source_location () =
2761
- address_map.at (integer2unsigned (number) ).source ->source_location ;
2763
+ address_map.at (label_number ).source ->source_location ;
2762
2764
code_branch.add_source_location () = location;
2763
2765
return code_branch;
2764
2766
}
@@ -2773,9 +2775,10 @@ codet java_bytecode_convert_methodt::convert_ifnonull(
2773
2775
const typecast_exprt lhs (op[0 ], java_reference_type (empty_typet ()));
2774
2776
const exprt rhs (null_pointer_exprt (to_pointer_type (lhs.type ())));
2775
2777
code_branch.cond () = binary_relation_exprt (lhs, ID_notequal, rhs);
2776
- code_branch.then_case () = code_gotot (label (integer2string (number)));
2778
+ const method_offsett label_number = numeric_cast_v<method_offsett>(number);
2779
+ code_branch.then_case () = code_gotot (label (std::to_string (label_number)));
2777
2780
code_branch.then_case ().add_source_location () =
2778
- address_map.at (integer2unsigned (number) ).source ->source_location ;
2781
+ address_map.at (label_number ).source ->source_location ;
2779
2782
code_branch.add_source_location () = location;
2780
2783
return code_branch;
2781
2784
}
@@ -2792,9 +2795,10 @@ codet java_bytecode_convert_methodt::convert_if(
2792
2795
binary_relation_exprt (op[0 ], id, from_integer (0 , op[0 ].type ()));
2793
2796
code_branch.cond ().add_source_location () = location;
2794
2797
code_branch.cond ().add_source_location ().set_function (method_id);
2795
- code_branch.then_case () = code_gotot (label (integer2string (number)));
2798
+ const method_offsett label_number = numeric_cast_v<method_offsett>(number);
2799
+ code_branch.then_case () = code_gotot (label (std::to_string (label_number)));
2796
2800
code_branch.then_case ().add_source_location () =
2797
- address_map.at (integer2unsigned (number) ).source ->source_location ;
2801
+ address_map.at (label_number ).source ->source_location ;
2798
2802
code_branch.then_case ().add_source_location ().set_function (method_id);
2799
2803
code_branch.add_source_location () = location;
2800
2804
code_branch.add_source_location ().set_function (method_id);
@@ -2821,19 +2825,20 @@ codet java_bytecode_convert_methodt::convert_if_cmp(
2821
2825
2822
2826
code_branch.cond () = condition;
2823
2827
code_branch.cond ().add_source_location () = location;
2824
- code_branch.then_case () = code_gotot (label (integer2string (number)));
2828
+ const method_offsett label_number = numeric_cast_v<method_offsett>(number);
2829
+ code_branch.then_case () = code_gotot (label (std::to_string (label_number)));
2825
2830
code_branch.then_case ().add_source_location () =
2826
- address_map.at (integer2unsigned (number) ).source ->source_location ;
2831
+ address_map.at (label_number ).source ->source_location ;
2827
2832
code_branch.add_source_location () = location;
2828
2833
2829
2834
return code_branch;
2830
2835
}
2831
2836
2832
2837
code_blockt java_bytecode_convert_methodt::convert_ret (
2833
- const std::vector<unsigned int > &jsr_ret_targets,
2838
+ const std::vector<method_offsett > &jsr_ret_targets,
2834
2839
const exprt &arg0,
2835
2840
const source_locationt &location,
2836
- const unsigned address)
2841
+ const method_offsett address)
2837
2842
{
2838
2843
code_blockt c;
2839
2844
auto retvar = variable (arg0, ' a' , address, NO_CAST);
@@ -2885,7 +2890,7 @@ codet java_bytecode_convert_methodt::convert_store(
2885
2890
const irep_idt &statement,
2886
2891
const exprt &arg0,
2887
2892
const exprt::operandst &op,
2888
- const unsigned address,
2893
+ const method_offsett address,
2889
2894
const source_locationt &location)
2890
2895
{
2891
2896
const exprt var = variable (arg0, statement[0 ], address, NO_CAST);
@@ -2974,7 +2979,7 @@ optionalt<exprt> java_bytecode_convert_methodt::convert_invoke_dynamic(
2974
2979
2975
2980
void java_bytecode_convert_methodt::draw_edges_from_ret_to_jsr (
2976
2981
java_bytecode_convert_methodt::address_mapt &address_map,
2977
- const std::vector<unsigned int > &jsr_ret_targets,
2982
+ const std::vector<method_offsett > &jsr_ret_targets,
2978
2983
const std::vector<
2979
2984
std::vector<java_bytecode_parse_treet::instructiont>::const_iterator>
2980
2985
&ret_instructions) const
@@ -2988,12 +2993,13 @@ void java_bytecode_convert_methodt::draw_edges_from_ret_to_jsr(
2988
2993
}
2989
2994
}
2990
2995
2991
- std::vector<unsigned > java_bytecode_convert_methodt::try_catch_handler (
2992
- const unsigned int address,
2996
+ std::vector<java_bytecode_convert_methodt::method_offsett>
2997
+ java_bytecode_convert_methodt::try_catch_handler (
2998
+ const method_offsett address,
2993
2999
const java_bytecode_parse_treet::methodt::exception_tablet &exception_table)
2994
3000
const
2995
3001
{
2996
- std::vector<unsigned > result;
3002
+ std::vector<method_offsett > result;
2997
3003
for (const auto &exception_row : exception_table)
2998
3004
{
2999
3005
if (address >= exception_row.start_pc && address < exception_row.end_pc )
0 commit comments