File tree Expand file tree Collapse file tree 5 files changed +47
-3
lines changed Expand file tree Collapse file tree 5 files changed +47
-3
lines changed Original file line number Diff line number Diff line change @@ -213,9 +213,8 @@ void goto_convert_functionst::convert_function(
213213 // add "end of function"
214214 f.body .destructive_append (tmp_end_function);
215215
216- // do function tags
217- Forall_goto_program_instructions (i_it, f.body )
218- i_it->function =identifier;
216+ // do function tags (they are empty at this point)
217+ f.update_instructions_function (identifier);
219218
220219 f.body .update ();
221220
Original file line number Diff line number Diff line change @@ -62,6 +62,14 @@ class goto_function_templatet
6262 parameter_identifiers.clear ();
6363 }
6464
65+ // / update the function member in each instruction
66+ // / \param function_id: the `function_id` used for assigning empty function
67+ // / members
68+ void update_instructions_function (const irep_idt &function_id)
69+ {
70+ body.update_instructions_function (function_id);
71+ }
72+
6573 void swap (goto_function_templatet &other)
6674 {
6775 body.swap (other.body );
@@ -149,12 +157,23 @@ class goto_functions_templatet
149157 void compute_target_numbers ();
150158 void compute_incoming_edges ();
151159
160+ // / update the function member in each instruction by setting it to
161+ // / the goto function's identifier
162+ void update_instructions_function ()
163+ {
164+ for (auto &func : function_map)
165+ {
166+ func.second .update_instructions_function (func.first );
167+ }
168+ }
169+
152170 void update ()
153171 {
154172 compute_incoming_edges ();
155173 compute_target_numbers ();
156174 compute_location_numbers ();
157175 compute_loop_numbers ();
176+ update_instructions_function ();
158177 }
159178
160179 static inline irep_idt entry_point ()
Original file line number Diff line number Diff line change @@ -103,6 +103,13 @@ class goto_model_functiont
103103 goto_functions.compute_location_numbers (goto_function.body );
104104 }
105105
106+ // / Updates the empty function member of each instruction by setting them
107+ // / to `function_id`
108+ void update_instructions_function ()
109+ {
110+ goto_function.update_instructions_function (function_id);
111+ }
112+
106113 // / Get symbol table
107114 // / \return journalling symbol table that (a) wraps the global symbol table,
108115 // / and (b) has recorded all symbol mutations (insertions, updates and
Original file line number Diff line number Diff line change @@ -521,6 +521,22 @@ class goto_program_templatet
521521 }
522522 }
523523
524+ // / Sets the `function` member of each instruction if not yet set
525+ // / Note that a goto program need not be a goto function and therefore,
526+ // / we cannot do this in update(), but only at the level of
527+ // / of goto_functionst where goto programs are guaranteed to be
528+ // / named functions.
529+ void update_instructions_function (const irep_idt &function_id)
530+ {
531+ for (auto &instruction : instructions)
532+ {
533+ if (instruction.function .empty ())
534+ {
535+ instruction.function = function_id;
536+ }
537+ }
538+ }
539+
524540 // / Compute location numbers
525541 void compute_location_numbers ()
526542 {
Original file line number Diff line number Diff line change @@ -708,6 +708,9 @@ void jbmc_parse_optionst::process_goto_function(
708708 symbol_table.lookup_ref (new_symbol_name),
709709 symbol_table);
710710 }
711+
712+ // update the function member in each instruction
713+ function.update_instructions_function ();
711714 }
712715
713716 catch (const char *e)
You can’t perform that action at this time.
0 commit comments