@@ -53,12 +53,12 @@ void flow_insensitive_analysis_baset::operator()(
53
53
fixedpoint (goto_functions);
54
54
}
55
55
56
- void flow_insensitive_analysis_baset::operator ()(
57
- const goto_programt &goto_program)
56
+ void flow_insensitive_analysis_baset::
57
+ operator ()( const irep_idt &function_id, const goto_programt &goto_program)
58
58
{
59
59
initialize (goto_program);
60
60
goto_functionst goto_functions;
61
- fixedpoint (goto_program, goto_functions);
61
+ fixedpoint (function_id, goto_program, goto_functions);
62
62
}
63
63
64
64
void flow_insensitive_analysis_baset::output (
@@ -69,14 +69,14 @@ void flow_insensitive_analysis_baset::output(
69
69
{
70
70
out << " ////\n " << " //// Function: " << f_it->first << " \n ////\n\n " ;
71
71
72
- output (f_it->second . body , f_it->first , out);
72
+ output (f_it->first , f_it->second . body , out);
73
73
}
74
74
}
75
75
76
76
void flow_insensitive_analysis_baset::output (
77
- const goto_programt &,
78
77
const irep_idt &,
79
- std::ostream &out) const
78
+ const goto_programt &,
79
+ std::ostream &out)
80
80
{
81
81
get_state ().output (ns, out);
82
82
}
@@ -99,6 +99,7 @@ flow_insensitive_analysis_baset::get_next(
99
99
}
100
100
101
101
bool flow_insensitive_analysis_baset::fixedpoint (
102
+ const irep_idt &function_id,
102
103
const goto_programt &goto_program,
103
104
const goto_functionst &goto_functions)
104
105
{
@@ -119,14 +120,15 @@ bool flow_insensitive_analysis_baset::fixedpoint(
119
120
{
120
121
locationt l=get_next (working_set);
121
122
122
- if (visit (l, working_set, goto_program, goto_functions))
123
+ if (visit (function_id, l, working_set, goto_program, goto_functions))
123
124
new_data=true ;
124
125
}
125
126
126
127
return new_data;
127
128
}
128
129
129
130
bool flow_insensitive_analysis_baset::visit (
131
+ const irep_idt &function_id,
130
132
locationt l,
131
133
working_sett &working_set,
132
134
const goto_programt &goto_program,
@@ -157,16 +159,16 @@ bool flow_insensitive_analysis_baset::visit(
157
159
// this is a big special case
158
160
const code_function_callt &code = to_code_function_call (l->code );
159
161
160
- changed=
161
- do_function_call_rec (
162
- l,
163
- code.function (),
164
- code.arguments (),
165
- get_state (),
166
- goto_functions);
162
+ changed = do_function_call_rec (
163
+ function_id,
164
+ l,
165
+ code.function (),
166
+ code.arguments (),
167
+ get_state (),
168
+ goto_functions);
167
169
}
168
170
else
169
- changed = get_state ().transform (ns, l , to_l);
171
+ changed = get_state ().transform (ns, function_id, l, function_id , to_l);
170
172
171
173
if (changed || !seen (to_l))
172
174
{
@@ -193,6 +195,7 @@ bool flow_insensitive_analysis_baset::visit(
193
195
}
194
196
195
197
bool flow_insensitive_analysis_baset::do_function_call (
198
+ const irep_idt &calling_function,
196
199
locationt l_call,
197
200
const goto_functionst &goto_functions,
198
201
const goto_functionst::function_mapt::const_iterator f_it,
@@ -221,9 +224,15 @@ bool flow_insensitive_analysis_baset::do_function_call(
221
224
t->location_number =1 ;
222
225
223
226
locationt l_next=l_call; l_next++;
224
- bool new_data=state.transform (ns, l_call, r);
225
- new_data = state.transform (ns, r, t) || new_data;
226
- new_data = state.transform (ns, t, l_next) || new_data;
227
+ // do the edge from the call site to the simulated function (the artificial
228
+ // return statement that we just generated)
229
+ bool new_data =
230
+ state.transform (ns, calling_function, l_call, f_it->first , r);
231
+ // do the edge from the return to the artificial end-of-function
232
+ new_data = state.transform (ns, f_it->first , r, f_it->first , t) || new_data;
233
+ // do edge from (artificial) end of function to instruction after call
234
+ new_data =
235
+ state.transform (ns, f_it->first , t, calling_function, l_next) || new_data;
227
236
228
237
return new_data;
229
238
}
@@ -240,7 +249,8 @@ bool flow_insensitive_analysis_baset::do_function_call(
240
249
l_begin->function == f_it->first , " function names have to match" );
241
250
242
251
// do the edge from the call site to the beginning of the function
243
- new_data=state.transform (ns, l_call, l_begin);
252
+ new_data =
253
+ state.transform (ns, calling_function, l_call, f_it->first , l_begin);
244
254
245
255
// do each function at least once
246
256
if (functions_done.find (f_it->first )==
@@ -254,7 +264,7 @@ bool flow_insensitive_analysis_baset::do_function_call(
254
264
if (new_data)
255
265
{
256
266
// recursive call
257
- fixedpoint (goto_function.body , goto_functions);
267
+ fixedpoint (f_it-> first , goto_function.body , goto_functions);
258
268
new_data=true ; // could be reset by fixedpoint
259
269
}
260
270
}
@@ -268,13 +278,16 @@ bool flow_insensitive_analysis_baset::do_function_call(
268
278
// do edge from end of function to instruction after call
269
279
locationt l_next=l_call;
270
280
l_next++;
271
- new_data = state.transform (ns, l_end, l_next) || new_data;
281
+ new_data =
282
+ state.transform (ns, f_it->first , l_end, calling_function, l_next) ||
283
+ new_data;
272
284
}
273
285
274
286
return new_data;
275
287
}
276
288
277
289
bool flow_insensitive_analysis_baset::do_function_call_rec (
290
+ const irep_idt &calling_function,
278
291
locationt l_call,
279
292
const exprt &function,
280
293
const exprt::operandst &arguments,
@@ -301,13 +314,8 @@ bool flow_insensitive_analysis_baset::do_function_call_rec(
301
314
if (it==goto_functions.function_map .end ())
302
315
throw " failed to find function " +id2string (identifier);
303
316
304
- new_data =
305
- do_function_call (
306
- l_call,
307
- goto_functions,
308
- it,
309
- arguments,
310
- state);
317
+ new_data = do_function_call (
318
+ calling_function, l_call, goto_functions, it, arguments, state);
311
319
312
320
recursion_set.erase (identifier);
313
321
}
@@ -316,12 +324,21 @@ bool flow_insensitive_analysis_baset::do_function_call_rec(
316
324
const auto &if_expr = to_if_expr (function);
317
325
318
326
new_data = do_function_call_rec (
319
- l_call, if_expr.true_case (), arguments, state, goto_functions);
327
+ calling_function,
328
+ l_call,
329
+ if_expr.true_case (),
330
+ arguments,
331
+ state,
332
+ goto_functions);
320
333
321
- new_data =
322
- do_function_call_rec (
323
- l_call, if_expr.false_case (), arguments, state, goto_functions) ||
324
- new_data;
334
+ new_data = do_function_call_rec (
335
+ calling_function,
336
+ l_call,
337
+ if_expr.false_case (),
338
+ arguments,
339
+ state,
340
+ goto_functions) ||
341
+ new_data;
325
342
}
326
343
else if (function.id ()==ID_dereference)
327
344
{
@@ -343,13 +360,14 @@ bool flow_insensitive_analysis_baset::do_function_call_rec(
343
360
344
361
if (it!=goto_functions.function_map .end ())
345
362
{
346
- new_data =
347
- do_function_call_rec (
348
- l_call,
349
- o.object (),
350
- arguments,
351
- state,
352
- goto_functions) || new_data;
363
+ new_data = do_function_call_rec (
364
+ calling_function,
365
+ l_call,
366
+ o.object (),
367
+ arguments,
368
+ state,
369
+ goto_functions) ||
370
+ new_data;
353
371
}
354
372
}
355
373
}
@@ -392,7 +410,7 @@ bool flow_insensitive_analysis_baset::fixedpoint(
392
410
const goto_functionst &goto_functions)
393
411
{
394
412
functions_done.insert (it->first );
395
- return fixedpoint (it->second .body , goto_functions);
413
+ return fixedpoint (it->first , it-> second .body , goto_functions);
396
414
}
397
415
398
416
void flow_insensitive_analysis_baset::update (const goto_functionst &)
0 commit comments