Skip to content

Commit d19448a

Browse files
committed
Style fixes
1 parent d932cfd commit d19448a

File tree

3 files changed

+73
-36
lines changed

3 files changed

+73
-36
lines changed

src/java_bytecode/java_bytecode_convert_method.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ void java_bytecode_convert_method_lazy(
215215
{
216216
method_symbol.pretty_name=id2string(class_symbol.pretty_name)+"."+
217217
id2string(class_symbol.base_name)+"()";
218-
member_type.set(ID_constructor,true);
218+
member_type.set(ID_constructor, true);
219219
}
220220
else
221221
method_symbol.pretty_name=id2string(class_symbol.pretty_name)+"."+
@@ -1167,7 +1167,8 @@ codet java_bytecode_convert_methodt::convert_instructions(
11671167
assert(use_this);
11681168
assert(!call.arguments().empty());
11691169
call.function()=arg0;
1170-
// Populate needed methods later, once we know what object types can exist.
1170+
// Populate needed methods later,
1171+
// once we know what object types can exist.
11711172
}
11721173
else
11731174
{

src/java_bytecode/java_bytecode_language.cpp

Lines changed: 65 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -257,17 +257,25 @@ static void get_virtual_method_targets(
257257
auto child_classes=class_hierarchy.get_children_trans(call_class);
258258
for(const auto& child_class : child_classes)
259259
{
260-
auto child_method=get_virtual_method_target(needed_classes,call_basename,
261-
child_class,symbol_table);
260+
auto child_method=
261+
get_virtual_method_target(
262+
needed_classes,
263+
call_basename,
264+
child_class,
265+
symbol_table);
262266
if(child_method!=irep_idt())
263267
needed_methods.push_back(child_method);
264268
}
265269

266270
irep_idt parent_class_id=call_class;
267271
while(1)
268272
{
269-
auto parent_method=get_virtual_method_target(needed_classes,call_basename,
270-
parent_class_id,symbol_table);
273+
auto parent_method=
274+
get_virtual_method_target(
275+
needed_classes,
276+
call_basename,
277+
parent_class_id,
278+
symbol_table);
271279
if(parent_method!=irep_idt())
272280
{
273281
needed_methods.push_back(parent_method);
@@ -301,7 +309,6 @@ static void get_virtual_method_targets(
301309
symbol.mode=ID_java;
302310
symbol_table.add(symbol);
303311
}
304-
305312
}
306313

307314
/*******************************************************************\
@@ -317,7 +324,9 @@ Function: gather_virtual_callsites
317324
318325
\*******************************************************************/
319326

320-
static void gather_virtual_callsites(const exprt& e, std::vector<const code_function_callt*>& result)
327+
static void gather_virtual_callsites(
328+
const exprt& e,
329+
std::vector<const code_function_callt*>& result)
321330
{
322331
if(e.id()!=ID_code)
323332
return;
@@ -326,8 +335,8 @@ static void gather_virtual_callsites(const exprt& e, std::vector<const code_func
326335
to_code_function_call(c).function().id()==ID_virtual_function)
327336
result.push_back(&to_code_function_call(c));
328337
else
329-
forall_operands(it,e)
330-
gather_virtual_callsites(*it,result);
338+
forall_operands(it, e)
339+
gather_virtual_callsites(*it, result);
331340
}
332341

333342
/*******************************************************************\
@@ -344,7 +353,10 @@ Function: gather_needed_globals
344353
345354
\*******************************************************************/
346355

347-
static void gather_needed_globals(const exprt& e, const symbol_tablet& symbol_table, symbol_tablet& needed)
356+
static void gather_needed_globals(
357+
const exprt& e,
358+
const symbol_tablet& symbol_table,
359+
symbol_tablet& needed)
348360
{
349361
if(e.id()==ID_symbol)
350362
{
@@ -353,8 +365,8 @@ static void gather_needed_globals(const exprt& e, const symbol_tablet& symbol_ta
353365
needed.add(sym);
354366
}
355367
else
356-
forall_operands(opit,e)
357-
gather_needed_globals(*opit,symbol_table,needed);
368+
forall_operands(opit, e)
369+
gather_needed_globals(*opit, symbol_table, needed);
358370
}
359371

360372
/*******************************************************************\
@@ -383,15 +395,16 @@ static void gather_field_types(
383395
for(const auto& field : underlying_type.components())
384396
{
385397
if(field.type().id()==ID_struct || field.type().id()==ID_symbol)
386-
gather_field_types(field.type(),ns,needed_classes);
398+
gather_field_types(field.type(), ns, needed_classes);
387399
else if(field.type().id()==ID_pointer)
388400
{
389401
// Skip array primitive pointers, for example:
390402
if(field.type().subtype().id()!=ID_symbol)
391-
continue;
392-
const auto& field_classid=to_symbol_type(field.type().subtype()).get_identifier();
403+
continue;
404+
const auto& field_classid=
405+
to_symbol_type(field.type().subtype()).get_identifier();
393406
if(needed_classes.insert(field_classid).second)
394-
gather_field_types(field.type().subtype(),ns,needed_classes);
407+
gather_field_types(field.type().subtype(), ns, needed_classes);
395408
}
396409
}
397410
}
@@ -427,12 +440,14 @@ static void initialise_needed_classes(
427440
{
428441
if(param.type().id()==ID_pointer)
429442
{
430-
const auto& param_classid=to_symbol_type(param.type().subtype()).get_identifier();
431-
std::vector<irep_idt> class_and_parents=ch.get_parents_trans(param_classid);
443+
const auto& param_classid=
444+
to_symbol_type(param.type().subtype()).get_identifier();
445+
std::vector<irep_idt> class_and_parents=
446+
ch.get_parents_trans(param_classid);
432447
class_and_parents.push_back(param_classid);
433448
for(const auto& classid : class_and_parents)
434449
needed_classes.insert(classid);
435-
gather_field_types(param.type().subtype(),ns,needed_classes);
450+
gather_field_types(param.type().subtype(), ns, needed_classes);
436451
}
437452
}
438453
}
@@ -483,7 +498,8 @@ bool java_bytecode_languaget::typecheck(
483498
return true;
484499
}
485500

486-
// Now incrementally elaborate methods that are reachable from this entry point.
501+
// Now incrementally elaborate methods
502+
// that are reachable from this entry point.
487503
if(lazy_methods_mode==LAZY_METHODS_MODE_CONTEXT_INSENSITIVE)
488504
{
489505
if(do_ci_lazy_method_conversion(symbol_table, lazy_methods))
@@ -508,7 +524,8 @@ bool java_bytecode_languaget::do_ci_lazy_method_conversion(
508524
std::vector<irep_idt> method_worklist1;
509525
std::vector<irep_idt> method_worklist2;
510526

511-
auto main_function=get_main_symbol(symbol_table,main_class,get_message_handler(),true);
527+
auto main_function=
528+
get_main_symbol(symbol_table, main_class, get_message_handler(), true);
512529
if(main_function.stop_convert)
513530
{
514531
// Failed, mark all functions in the given main class(es) reachable.
@@ -519,7 +536,8 @@ bool java_bytecode_languaget::do_ci_lazy_method_conversion(
519536
reachable_classes=main_jar_classes;
520537
for(const auto& classname : reachable_classes)
521538
{
522-
const auto& methods=java_class_loader.class_map.at(classname).parsed_class.methods;
539+
const auto& methods=
540+
java_class_loader.class_map.at(classname).parsed_class.methods;
523541
for(const auto& method : methods)
524542
{
525543
const irep_idt methodid="java::"+id2string(classname)+"."+
@@ -533,18 +551,22 @@ bool java_bytecode_languaget::do_ci_lazy_method_conversion(
533551
method_worklist2.push_back(main_function.main_function.name);
534552

535553
std::set<irep_idt> needed_classes;
536-
initialise_needed_classes(method_worklist2,namespacet(symbol_table),ch,needed_classes);
554+
initialise_needed_classes(
555+
method_worklist2,
556+
namespacet(symbol_table),
557+
ch,
558+
needed_classes);
537559

538560
std::set<irep_idt> methods_already_populated;
539561
std::vector<const code_function_callt*> virtual_callsites;
540562

541563
bool any_new_methods;
542-
do {
543-
564+
do
565+
{
544566
any_new_methods=false;
545567
while(method_worklist2.size()!=0)
546568
{
547-
std::swap(method_worklist1,method_worklist2);
569+
std::swap(method_worklist1, method_worklist2);
548570
for(const auto& mname : method_worklist1)
549571
{
550572
if(!methods_already_populated.insert(mname).second)
@@ -566,7 +588,9 @@ bool java_bytecode_languaget::do_ci_lazy_method_conversion(
566588
max_user_array_length,
567589
&method_worklist2,
568590
&needed_classes);
569-
gather_virtual_callsites(symbol_table.lookup(mname).value,virtual_callsites);
591+
gather_virtual_callsites(
592+
symbol_table.lookup(mname).value,
593+
virtual_callsites);
570594
any_new_methods=true;
571595
}
572596
method_worklist1.clear();
@@ -575,14 +599,16 @@ bool java_bytecode_languaget::do_ci_lazy_method_conversion(
575599
// Given the object types we now know may be created, populate more
576600
// possible virtual function call targets:
577601

578-
debug() << "CI lazy methods: add virtual method targets (" << virtual_callsites.size() <<
579-
" callsites)" << eom;
602+
debug() << "CI lazy methods: add virtual method targets ("
603+
<< virtual_callsites.size()
604+
<< " callsites)"
605+
<< eom;
580606

581607
for(const auto& callsite : virtual_callsites)
582608
{
583609
// This will also create a stub if a virtual callsite has no targets.
584-
get_virtual_method_targets(*callsite,needed_classes,method_worklist2,
585-
symbol_table,ch);
610+
get_virtual_method_targets(*callsite, needed_classes, method_worklist2,
611+
symbol_table, ch);
586612
}
587613

588614
} while(any_new_methods);
@@ -594,14 +620,20 @@ bool java_bytecode_languaget::do_ci_lazy_method_conversion(
594620
{
595621
if(sym.second.is_static_lifetime)
596622
continue;
597-
if(lazy_methods.count(sym.first) && !methods_already_populated.count(sym.first))
623+
if(lazy_methods.count(sym.first) &&
624+
!methods_already_populated.count(sym.first))
625+
{
598626
continue;
627+
}
599628
if(sym.second.type.id()==ID_code)
600-
gather_needed_globals(sym.second.value,symbol_table,keep_symbols);
629+
gather_needed_globals(sym.second.value, symbol_table, keep_symbols);
601630
keep_symbols.add(sym.second);
602631
}
603632

604-
debug() << "CI lazy methods: removed " << symbol_table.symbols.size() - keep_symbols.symbols.size() << " unreachable methods and globals" << eom;
633+
debug() << "CI lazy methods: removed "
634+
<< symbol_table.symbols.size() - keep_symbols.symbols.size()
635+
<< " unreachable methods and globals"
636+
<< eom;
605637

606638
symbol_table.swap(keep_symbols);
607639

src/java_bytecode/java_bytecode_language.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,11 @@ enum lazy_methods_modet
2323
LAZY_METHODS_MODE_CONTEXT_SENSITIVE
2424
};
2525

26-
typedef std::map<irep_idt, std::pair<const symbolt*, const java_bytecode_parse_treet::methodt*> >
26+
typedef std::pair<
27+
const symbolt*,
28+
const java_bytecode_parse_treet::methodt*>
29+
lazy_method_valuet;
30+
typedef std::map<irep_idt, lazy_method_valuet>
2731
lazy_methodst;
2832

2933
class java_bytecode_languaget:public languaget

0 commit comments

Comments
 (0)