Skip to content

Commit 92e1e4a

Browse files
committed
Style fixes for local variable table
1 parent 41f3d5e commit 92e1e4a

File tree

1 file changed

+45
-44
lines changed

1 file changed

+45
-44
lines changed

src/java_bytecode/java_local_variable_table.cpp

+45-44
Original file line numberDiff line numberDiff line change
@@ -30,25 +30,26 @@ struct procedure_local_cfg_baset<
3030

3131
procedure_local_cfg_baset() {}
3232

33-
void operator()(const method_with_amapt& args)
33+
void operator()(const method_with_amapt &args)
3434
{
3535
const auto &method=args.first;
36-
const auto& amap=args.second;
37-
for(const auto& inst : amap)
36+
const auto &amap=args.second;
37+
for(const auto &inst : amap)
3838
{
3939
// Map instruction PCs onto node indices:
4040
entry_map[inst.first]=this->add_node();
4141
// Map back:
4242
(*this)[entry_map[inst.first]].PC=inst.first;
4343
}
44-
for(const auto& inst : amap)
44+
// Add edges declared in the address map:
45+
for(const auto &inst : amap)
4546
{
4647
for(auto succ : inst.second.successors)
4748
this->add_edge(entry_map.at(inst.first), entry_map.at(succ));
4849
}
49-
// Add edges declared in the exception table, which don't figure
50-
// in the address map successors/predecessors as yet.
51-
for(const auto& table_entry : method.exception_table)
50+
// Next, add edges declared in the exception table, which
51+
// don't figure in the address map successors/predecessors as yet:
52+
for(const auto &table_entry : method.exception_table)
5253
{
5354
auto findit=amap.find(table_entry.start_pc);
5455
assert(findit!=amap.end() &&
@@ -61,9 +62,9 @@ struct procedure_local_cfg_baset<
6162
++succit;
6263
if(succit==amap.end())
6364
continue;
64-
const auto& thisinst=findit->second;
65+
const auto &thisinst=findit->second;
6566
if(thisinst.successors.size()==1 &&
66-
*thisinst.successors.begin()==succit->first)
67+
thisinst.successors.back()==succit->first)
6768
{
6869
this->add_edge(
6970
entry_map.at(findit->first),
@@ -73,15 +74,15 @@ struct procedure_local_cfg_baset<
7374
}
7475
}
7576

76-
unsigned get_first_node(const method_with_amapt& args) const
77+
unsigned get_first_node(const method_with_amapt &args) const
7778
{
7879
return args.second.begin()->first;
7980
}
80-
unsigned get_last_node(const method_with_amapt& args) const
81+
unsigned get_last_node(const method_with_amapt &args) const
8182
{
8283
return (--args.second.end())->first;
8384
}
84-
unsigned nodes_empty(const method_with_amapt& args) const
85+
unsigned nodes_empty(const method_with_amapt &args) const
8586
{
8687
return args.second.empty();
8788
}
@@ -102,8 +103,8 @@ typedef java_bytecode_convert_methodt::java_cfg_dominatorst
102103
// Comparators for local variables:
103104

104105
static bool lt_index(
105-
const local_variable_with_holest& a,
106-
const local_variable_with_holest& b)
106+
const local_variable_with_holest &a,
107+
const local_variable_with_holest &b)
107108
{
108109
return a.var.index<b.var.index;
109110
}
@@ -123,9 +124,9 @@ typedef std::map<
123124

124125
struct is_predecessor_oft
125126
{
126-
const predecessor_mapt& order;
127+
const predecessor_mapt &order;
127128

128-
explicit is_predecessor_oft(const predecessor_mapt& _order) : order(_order) {}
129+
explicit is_predecessor_oft(const predecessor_mapt &_order) : order(_order) {}
129130

130131
bool operator()(
131132
local_variable_with_holest* a,
@@ -156,7 +157,7 @@ Function: gather_transitive_predecessors
156157

157158
static void gather_transitive_predecessors(
158159
local_variable_with_holest* start,
159-
const predecessor_mapt& predecessor_map,
160+
const predecessor_mapt &predecessor_map,
160161
std::set<local_variable_with_holest*>& result)
161162
{
162163
if(!result.insert(start).second)
@@ -183,7 +184,7 @@ Function: is_store_to_slot
183184
\*******************************************************************/
184185

185186
static bool is_store_to_slot(
186-
const java_bytecode_convert_methodt::instructiont& inst,
187+
const java_bytecode_convert_methodt::instructiont &inst,
187188
unsigned slotidx)
188189
{
189190
const std::string prevstatement=id2string(inst.statement);
@@ -194,7 +195,7 @@ static bool is_store_to_slot(
194195
if(inst.args.size()==1)
195196
{
196197
// Store with an argument:
197-
const auto& arg=inst.args[0];
198+
const auto &arg=inst.args[0];
198199
storeslot=id2string(to_constant_expr(arg).get_value());
199200
}
200201
else
@@ -222,7 +223,7 @@ Function: maybe_add_hole
222223
\*******************************************************************/
223224

224225
static void maybe_add_hole(
225-
local_variable_with_holest& var,
226+
local_variable_with_holest &var,
226227
unsigned from,
227228
unsigned to)
228229
{
@@ -298,9 +299,9 @@ static void populate_predecessor_map(
298299
local_variable_table_with_holest::iterator firstvar,
299300
local_variable_table_with_holest::iterator varlimit,
300301
const std::vector<local_variable_with_holest*>& live_variable_at_address,
301-
const address_mapt& amap,
302-
predecessor_mapt& predecessor_map,
303-
message_handlert& msg_handler)
302+
const address_mapt &amap,
303+
predecessor_mapt &predecessor_map,
304+
message_handlert &msg_handler)
304305
{
305306
messaget msg(msg_handler);
306307
for(auto it=firstvar, itend=varlimit; it!=itend; ++it)
@@ -412,7 +413,7 @@ Function: get_common_dominator
412413

413414
static unsigned get_common_dominator(
414415
const std::set<local_variable_with_holest*>& merge_vars,
415-
const java_cfg_dominatorst& dominator_analysis)
416+
const java_cfg_dominatorst &dominator_analysis)
416417
{
417418
assert(!merge_vars.empty());
418419

@@ -426,9 +427,9 @@ static unsigned get_common_dominator(
426427
std::vector<unsigned> candidate_dominators;
427428
for(auto v : merge_vars)
428429
{
429-
const auto& dominator_nodeidx=
430+
const auto &dominator_nodeidx=
430431
dominator_analysis.cfg.entry_map.at(v->var.start_pc);
431-
const auto& this_var_doms=
432+
const auto &this_var_doms=
432433
dominator_analysis.cfg[dominator_nodeidx].dominators;
433434
for(const auto this_var_dom : this_var_doms)
434435
if(this_var_dom<=first_pc)
@@ -478,7 +479,7 @@ Function: populate_live_range_holes
478479
\*******************************************************************/
479480

480481
static void populate_live_range_holes(
481-
local_variable_with_holest& merge_into,
482+
local_variable_with_holest &merge_into,
482483
const std::set<local_variable_with_holest*>& merge_vars,
483484
unsigned expanded_live_range_start)
484485
{
@@ -516,10 +517,10 @@ Function: merge_variable_table_entries
516517
\*******************************************************************/
517518

518519
static void merge_variable_table_entries(
519-
local_variable_with_holest& merge_into,
520+
local_variable_with_holest &merge_into,
520521
const std::set<local_variable_with_holest*>& merge_vars,
521-
const java_cfg_dominatorst& dominator_analysis,
522-
std::ostream& debug_out)
522+
const java_cfg_dominatorst &dominator_analysis,
523+
std::ostream &debug_out)
523524
{
524525
// Because we need a lexically-scoped declaration,
525526
// we must have the merged variable
@@ -554,7 +555,7 @@ static void merge_variable_table_entries(
554555
#endif
555556

556557
// Nuke the now-subsumed var-table entries:
557-
for(auto& v : merge_vars)
558+
for(auto &v : merge_vars)
558559
if(v!=&merge_into)
559560
v->var.length=0;
560561
}
@@ -584,8 +585,8 @@ Function: find_initialisers_for_slot
584585
void java_bytecode_convert_methodt::find_initialisers_for_slot(
585586
local_variable_table_with_holest::iterator firstvar,
586587
local_variable_table_with_holest::iterator varlimit,
587-
const address_mapt& amap,
588-
const java_cfg_dominatorst& dominator_analysis)
588+
const address_mapt &amap,
589+
const java_cfg_dominatorst &dominator_analysis)
589590
{
590591
// Build a simple map from instruction PC to the variable
591592
// live in this slot at that PC, and a map from each variable
@@ -609,7 +610,7 @@ void java_bytecode_convert_methodt::find_initialisers_for_slot(
609610
// Now merge vartable entries according to the predecessor_map:
610611

611612
// Take the transitive closure of the predecessor map:
612-
for(auto& kv : predecessor_map)
613+
for(auto &kv : predecessor_map)
613614
{
614615
std::set<local_variable_with_holest*> closed_preds;
615616
gather_transitive_predecessors(kv.first, predecessor_map, closed_preds);
@@ -636,7 +637,7 @@ void java_bytecode_convert_methodt::find_initialisers_for_slot(
636637
if(findit==predecessor_map.end())
637638
continue;
638639

639-
const auto& merge_vars=findit->second;
640+
const auto &merge_vars=findit->second;
640641
assert(merge_vars.size()>=2);
641642

642643
merge_variable_table_entries(
@@ -665,8 +666,8 @@ Function: walk_to_next_index
665666
\*******************************************************************/
666667

667668
static void walk_to_next_index(
668-
local_variable_table_with_holest::iterator& it1,
669-
local_variable_table_with_holest::iterator& it2,
669+
local_variable_table_with_holest::iterator &it1,
670+
local_variable_table_with_holest::iterator &it2,
670671
local_variable_table_with_holest::iterator itend)
671672
{
672673
if(it2==itend)
@@ -698,9 +699,9 @@ Function: find_initialisers
698699
\*******************************************************************/
699700

700701
void java_bytecode_convert_methodt::find_initialisers(
701-
local_variable_table_with_holest& vars,
702-
const address_mapt& amap,
703-
const java_cfg_dominatorst& dominator_analysis)
702+
local_variable_table_with_holest &vars,
703+
const address_mapt &amap,
704+
const java_cfg_dominatorst &dominator_analysis)
704705
{
705706
// Sort table entries by local slot index:
706707
std::sort(vars.begin(), vars.end(), lt_index);
@@ -766,18 +767,18 @@ Function: setup_local_variables
766767
\*******************************************************************/
767768

768769
void java_bytecode_convert_methodt::setup_local_variables(
769-
const methodt& m,
770-
const address_mapt& amap)
770+
const methodt &m,
771+
const address_mapt &amap)
771772
{
772773
// Compute CFG dominator tree
773774
java_cfg_dominatorst dominator_analysis;
774-
method_with_amapt dominator_args(m,amap);
775+
method_with_amapt dominator_args(m, amap);
775776
dominator_analysis(dominator_args);
776777

777778
// Find out which local variable table entries should be merged:
778779
// Wrap each entry so we have somewhere to record live ranges with holes:
779780
std::vector<local_variable_with_holest> vars_with_holes;
780-
for(const auto& v : m.local_variable_table)
781+
for(const auto &v : m.local_variable_table)
781782
vars_with_holes.push_back({v, {}});
782783

783784
// Merge variable records:

0 commit comments

Comments
 (0)