@@ -232,7 +232,7 @@ static void clinit_wrapper_do_recursive_calls(
232
232
symbol_table.symbols .end (),
233
233
[&](const std::pair<irep_idt, symbolt> &symbol) {
234
234
if (
235
- symbol.second . type . get (ID_C_class ) == class_name &&
235
+ declaring_class ( symbol.second ) == class_name &&
236
236
symbol.second .is_static_lifetime &&
237
237
!symbol.second .type .get_bool (ID_C_constant))
238
238
{
@@ -352,10 +352,9 @@ static void create_clinit_wrapper_symbols(
352
352
wrapper_method_symbol.pretty_name = wrapper_method_symbol.name ;
353
353
wrapper_method_symbol.base_name = " clinit_wrapper" ;
354
354
wrapper_method_symbol.type = wrapper_method_type;
355
- // Note this use of a type-comment to provide a back-link from a method
356
- // to its associated class is the same one used in
357
- // java_bytecode_convert_methodt::convert
358
- wrapper_method_symbol.type .set (ID_C_class, class_name);
355
+ // This provides a back-link from a method to its associated class, as is done
356
+ // for java_bytecode_convert_methodt::convert.
357
+ set_declaring_class (wrapper_method_symbol, class_name);
359
358
wrapper_method_symbol.mode = ID_java;
360
359
bool failed = symbol_table.add (wrapper_method_symbol);
361
360
INVARIANT (!failed, " clinit-wrapper symbol should be fresh" );
@@ -453,21 +452,20 @@ code_blockt get_thread_safe_clinit_wrapper_body(
453
452
message_handlert &message_handler)
454
453
{
455
454
const symbolt &wrapper_method_symbol = symbol_table.lookup_ref (function_id);
456
- irep_idt class_name = wrapper_method_symbol.type .get (ID_C_class);
457
- INVARIANT (
458
- !class_name.empty (), " wrapper function should be annotated with its class" );
455
+ const auto class_name = declaring_class (wrapper_method_symbol);
456
+ INVARIANT (class_name, " Wrapper function should have an owning class." );
459
457
460
458
const symbolt &clinit_state_sym =
461
- symbol_table.lookup_ref (clinit_state_var_name (class_name));
459
+ symbol_table.lookup_ref (clinit_state_var_name (* class_name));
462
460
const symbolt &clinit_thread_local_state_sym =
463
- symbol_table.lookup_ref (clinit_thread_local_state_var_name (class_name));
461
+ symbol_table.lookup_ref (clinit_thread_local_state_var_name (* class_name));
464
462
465
463
// Create a function-local variable "init_complete". This variable is used to
466
464
// avoid inspecting the global state (clinit_state_sym) outside of
467
465
// the critical-section.
468
466
const symbolt &init_complete = add_new_variable_symbol (
469
467
symbol_table,
470
- clinit_local_init_complete_var_name (class_name),
468
+ clinit_local_init_complete_var_name (* class_name),
471
469
bool_typet (),
472
470
nil_exprt (),
473
471
true ,
@@ -598,7 +596,7 @@ code_blockt get_thread_safe_clinit_wrapper_body(
598
596
code_blockt init_body;
599
597
clinit_wrapper_do_recursive_calls (
600
598
symbol_table,
601
- class_name,
599
+ * class_name,
602
600
init_body,
603
601
nondet_static,
604
602
object_factory_parameters,
@@ -666,12 +664,11 @@ code_ifthenelset get_clinit_wrapper_body(
666
664
// }
667
665
// }
668
666
const symbolt &wrapper_method_symbol = symbol_table.lookup_ref (function_id);
669
- irep_idt class_name = wrapper_method_symbol.type .get (ID_C_class);
670
- INVARIANT (
671
- !class_name.empty (), " wrapper function should be annotated with its class" );
667
+ const auto class_name = declaring_class (wrapper_method_symbol);
668
+ INVARIANT (class_name, " Wrapper function should have an owning class." );
672
669
673
670
const symbolt &already_run_symbol =
674
- symbol_table.lookup_ref (clinit_already_run_variable_name (class_name));
671
+ symbol_table.lookup_ref (clinit_already_run_variable_name (* class_name));
675
672
676
673
equal_exprt check_already_run (
677
674
already_run_symbol.symbol_expr (),
@@ -683,7 +680,7 @@ code_ifthenelset get_clinit_wrapper_body(
683
680
684
681
clinit_wrapper_do_recursive_calls (
685
682
symbol_table,
686
- class_name,
683
+ * class_name,
687
684
init_body,
688
685
nondet_static,
689
686
object_factory_parameters,
@@ -766,12 +763,9 @@ void stub_global_initializer_factoryt::create_stub_global_initializer_symbols(
766
763
continue ;
767
764
}
768
765
769
- const irep_idt class_id =
770
- global_symbol.type .get (ID_C_class);
771
- INVARIANT (
772
- !class_id.empty (),
773
- " static field should be annotated with its defining class" );
774
- stub_globals_by_class.insert ({class_id, stub_global});
766
+ const auto class_id = declaring_class (global_symbol);
767
+ INVARIANT (class_id, " Static field should have a defining class." );
768
+ stub_globals_by_class.insert ({*class_id, stub_global});
775
769
}
776
770
777
771
// For each distinct class that has stub globals, create a clinit symbol:
@@ -799,10 +793,9 @@ void stub_global_initializer_factoryt::create_stub_global_initializer_symbols(
799
793
static_init_symbol.base_name = " clinit():V" ;
800
794
static_init_symbol.mode = ID_java;
801
795
static_init_symbol.type = thunk_type;
802
- // Note this use of a type-comment to provide a back-link from a method
803
- // to its associated class is the same one used in
804
- // java_bytecode_convert_methodt::convert
805
- static_init_symbol.type .set (ID_C_class, it->first );
796
+ // This provides a back-link from a method to its associated class, as is
797
+ // done for java_bytecode_convert_methodt::convert.
798
+ set_declaring_class (static_init_symbol, it->first );
806
799
807
800
bool failed = symbol_table.add (static_init_symbol);
808
801
INVARIANT (!failed, " symbol should not already exist" );
@@ -839,17 +832,16 @@ code_blockt stub_global_initializer_factoryt::get_stub_initializer_body(
839
832
message_handlert &message_handler)
840
833
{
841
834
const symbolt &stub_initializer_symbol = symbol_table.lookup_ref (function_id);
842
- irep_idt class_id = stub_initializer_symbol. type . get (ID_C_class );
835
+ const auto class_id = declaring_class (stub_initializer_symbol );
843
836
INVARIANT (
844
- !class_id.empty (),
845
- " synthetic static initializer should be annotated with its class" );
837
+ class_id, " Synthetic static initializer should have an owning class." );
846
838
code_blockt static_init_body;
847
839
848
840
// Add a standard nondet initialisation for each global declared on this
849
841
// class. Note this is the same invocation used in
850
842
// java_static_lifetime_init.
851
843
852
- auto class_globals = stub_globals_by_class.equal_range (class_id);
844
+ auto class_globals = stub_globals_by_class.equal_range (* class_id);
853
845
INVARIANT (
854
846
class_globals.first != class_globals.second ,
855
847
" class with synthetic clinit should have at least one global to init" );
0 commit comments