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(
213
213
// add "end of function"
214
214
f.body .destructive_append (tmp_end_function);
215
215
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);
219
218
220
219
f.body .update ();
221
220
Original file line number Diff line number Diff line change @@ -62,6 +62,14 @@ class goto_function_templatet
62
62
parameter_identifiers.clear ();
63
63
}
64
64
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
+
65
73
void swap (goto_function_templatet &other)
66
74
{
67
75
body.swap (other.body );
@@ -149,12 +157,23 @@ class goto_functions_templatet
149
157
void compute_target_numbers ();
150
158
void compute_incoming_edges ();
151
159
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
+
152
170
void update ()
153
171
{
154
172
compute_incoming_edges ();
155
173
compute_target_numbers ();
156
174
compute_location_numbers ();
157
175
compute_loop_numbers ();
176
+ update_instructions_function ();
158
177
}
159
178
160
179
static inline irep_idt entry_point ()
Original file line number Diff line number Diff line change @@ -103,6 +103,13 @@ class goto_model_functiont
103
103
goto_functions.compute_location_numbers (goto_function.body );
104
104
}
105
105
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
+
106
113
// / Get symbol table
107
114
// / \return journalling symbol table that (a) wraps the global symbol table,
108
115
// / 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
521
521
}
522
522
}
523
523
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
+
524
540
// / Compute location numbers
525
541
void compute_location_numbers ()
526
542
{
Original file line number Diff line number Diff line change @@ -708,6 +708,9 @@ void jbmc_parse_optionst::process_goto_function(
708
708
symbol_table.lookup_ref (new_symbol_name),
709
709
symbol_table);
710
710
}
711
+
712
+ // update the function member in each instruction
713
+ function.update_instructions_function ();
711
714
}
712
715
713
716
catch (const char *e)
You can’t perform that action at this time.
0 commit comments