@@ -521,34 +521,8 @@ void c_typecheck_baset::typecheck_function_body(symbolt &symbol)
521521 // set return type
522522 return_type=code_type.return_type ();
523523
524- unsigned anon_counter=0 ;
525-
526- // Add the parameter declarations into the symbol table.
527- for (auto &p : code_type.parameters ())
528- {
529- // may be anonymous
530- if (p.get_base_name ().empty ())
531- {
532- irep_idt base_name=" #anon" +std::to_string (anon_counter++);
533- p.set_base_name (base_name);
534- }
535-
536- // produce identifier
537- irep_idt base_name = p.get_base_name ();
538- irep_idt identifier=id2string (symbol.name )+" ::" +id2string (base_name);
539-
540- p.set_identifier (identifier);
541-
542- parameter_symbolt p_symbol;
543-
544- p_symbol.type = p.type ();
545- p_symbol.name =identifier;
546- p_symbol.base_name =base_name;
547- p_symbol.location = p.source_location ();
548-
549- symbolt *new_p_symbol;
550- move_symbol (p_symbol, new_p_symbol);
551- }
524+ // Add the parameter declarations into the symbol table
525+ add_parameters_to_symbol_table (symbol);
552526
553527 // typecheck the body code
554528 typecheck_code (to_code (symbol.value ));
@@ -774,3 +748,39 @@ void c_typecheck_baset::typecheck_declaration(
774748 }
775749 }
776750}
751+
752+ void c_typecheck_baset::add_parameters_to_symbol_table (symbolt &symbol)
753+ {
754+ PRECONDITION (can_cast_type<code_typet>(symbol.type ));
755+
756+ code_typet &code_type = to_code_type (symbol.type );
757+
758+ unsigned anon_counter = 0 ;
759+
760+ // Add the parameter declarations into the symbol table.
761+ for (auto &p : code_type.parameters ())
762+ {
763+ // may be anonymous
764+ if (p.get_base_name ().empty ())
765+ {
766+ irep_idt base_name = " #anon" + std::to_string (anon_counter++);
767+ p.set_base_name (base_name);
768+ }
769+
770+ // produce identifier
771+ irep_idt base_name = p.get_base_name ();
772+ irep_idt identifier = id2string (symbol.name ) + " ::" + id2string (base_name);
773+
774+ p.set_identifier (identifier);
775+
776+ parameter_symbolt p_symbol;
777+
778+ p_symbol.type = p.type ();
779+ p_symbol.name = identifier;
780+ p_symbol.base_name = base_name;
781+ p_symbol.location = p.source_location ();
782+
783+ symbolt *new_p_symbol;
784+ move_symbol (p_symbol, new_p_symbol);
785+ }
786+ }
0 commit comments