@@ -103,15 +103,26 @@ class goto_functions_templatet
103
103
typedef std::map<irep_idt, goto_functiont> function_mapt;
104
104
function_mapt function_map;
105
105
106
- goto_functions_templatet ()
106
+ private:
107
+ // / A location number such that numbers in the interval
108
+ // / [unused_location_number, MAX_UINT] are all unused. There might still be
109
+ // / unused numbers below this.
110
+ // / If numbering a new function or renumbering a function, starting from this
111
+ // / number is safe.
112
+ unsigned unused_location_number;
113
+
114
+ public:
115
+ goto_functions_templatet ():
116
+ unused_location_number (0 )
107
117
{
108
118
}
109
119
110
120
goto_functions_templatet (const goto_functions_templatet &)=delete ;
111
121
goto_functions_templatet &operator =(const goto_functions_templatet &)=delete ;
112
122
113
123
goto_functions_templatet (goto_functions_templatet &&other):
114
- function_map (std::move(other.function_map))
124
+ function_map (std::move(other.function_map)),
125
+ unused_location_number (other.unused_location_number)
115
126
{
116
127
}
117
128
@@ -133,6 +144,7 @@ class goto_functions_templatet
133
144
std::ostream &out) const ;
134
145
135
146
void compute_location_numbers ();
147
+ void compute_location_numbers (goto_programt &);
136
148
void compute_loop_numbers ();
137
149
void compute_target_numbers ();
138
150
void compute_incoming_edges ();
@@ -186,13 +198,23 @@ void goto_functions_templatet<bodyT>::output(
186
198
template <class bodyT >
187
199
void goto_functions_templatet<bodyT>::compute_location_numbers()
188
200
{
189
- unsigned nr= 0 ;
201
+ unused_location_number = 0 ;
190
202
for (auto &func : function_map)
191
203
{
192
- func.second .body .compute_location_numbers (nr);
204
+ // Side-effect: bumps unused_location_number.
205
+ func.second .body .compute_location_numbers (unused_location_number);
193
206
}
194
207
}
195
208
209
+ template <class bodyT >
210
+ void goto_functions_templatet<bodyT>::compute_location_numbers(
211
+ goto_programt &program)
212
+ {
213
+ // Renumber just this single function. Use fresh numbers in case it has
214
+ // grown since it was last numbered.
215
+ program.compute_location_numbers (unused_location_number);
216
+ }
217
+
196
218
template <class bodyT >
197
219
void goto_functions_templatet<bodyT>::compute_incoming_edges()
198
220
{
0 commit comments