File tree 8 files changed +53
-19
lines changed
8 files changed +53
-19
lines changed Original file line number Diff line number Diff line change @@ -76,7 +76,7 @@ void dep_graph_domaint::control_dependencies(
76
76
from->is_assume ())
77
77
control_deps.insert (from);
78
78
79
- const irep_idt id=goto_programt::get_function_id ( from) ;
79
+ const irep_idt id=from-> function ;
80
80
const cfg_post_dominatorst &pd=dep_graph.cfg_post_dominators ().at (id);
81
81
82
82
// check all candidates for M
Original file line number Diff line number Diff line change @@ -150,7 +150,7 @@ void full_slicert::add_jumps(
150
150
continue ;
151
151
}
152
152
153
- const irep_idt id=goto_programt::get_function_id ( j.PC ) ;
153
+ const irep_idt id=j.PC -> function ;
154
154
const cfg_post_dominatorst &pd=post_dominators.at (id);
155
155
156
156
cfg_post_dominatorst::cfgt::entry_mapt::const_iterator e=
@@ -184,7 +184,7 @@ void full_slicert::add_jumps(
184
184
185
185
if (cfg[entry->second ].node_required )
186
186
{
187
- const irep_idt id2=goto_programt::get_function_id (*d_it);
187
+ const irep_idt id2=(*d_it)-> function ;
188
188
INVARIANT (id==id2,
189
189
" goto/jump expected to be within a single function" );
190
190
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 @@ -386,21 +386,12 @@ class goto_program_templatet
386
386
return t;
387
387
}
388
388
389
- static const irep_idt get_function_id (
390
- const_targett l)
391
- {
392
- while (!l->is_end_function ())
393
- ++l;
394
-
395
- return l->function ;
396
- }
397
-
398
389
static const irep_idt get_function_id (
399
390
const goto_program_templatet<codeT, guardT> &p)
400
391
{
401
- assert (!p.empty ());
392
+ PRECONDITION (!p.empty ());
402
393
403
- return get_function_id (-- p.instructions .end ()) ;
394
+ return p.instructions .back (). function ;
404
395
}
405
396
406
397
template <typename Target>
@@ -521,6 +512,22 @@ class goto_program_templatet
521
512
}
522
513
}
523
514
515
+ // / Sets the `function` member of each instruction if not yet set
516
+ // / Note that a goto program need not be a goto function and therefore,
517
+ // / we cannot do this in update(), but only at the level of
518
+ // / of goto_functionst where goto programs are guaranteed to be
519
+ // / named functions.
520
+ void update_instructions_function (const irep_idt &function_id)
521
+ {
522
+ for (auto &instruction : instructions)
523
+ {
524
+ if (instruction.function .empty ())
525
+ {
526
+ instruction.function = function_id;
527
+ }
528
+ }
529
+ }
530
+
524
531
// / Compute location numbers
525
532
void compute_location_numbers ()
526
533
{
Original file line number Diff line number Diff line change @@ -244,8 +244,7 @@ void remove_returnst::operator()(
244
244
if (goto_function.body .empty ())
245
245
return ;
246
246
247
- replace_returns (
248
- goto_programt::get_function_id (goto_function.body ), goto_function);
247
+ replace_returns (model_function.get_function_id (), goto_function);
249
248
do_function_calls (function_is_stub, goto_function.body );
250
249
}
251
250
Original file line number Diff line number Diff line change @@ -721,6 +721,9 @@ void jbmc_parse_optionst::process_goto_function(
721
721
symbol_table.lookup_ref (new_symbol_name),
722
722
symbol_table);
723
723
}
724
+
725
+ // update the function member in each instruction
726
+ function.update_instructions_function ();
724
727
}
725
728
726
729
catch (const char *e)
You can’t perform that action at this time.
0 commit comments