@@ -173,54 +173,58 @@ void goto_symext::parameter_assignments(
173
173
void goto_symext::symex_function_call (
174
174
const get_goto_functiont &get_goto_function,
175
175
statet &state,
176
- const code_function_callt &code )
176
+ const goto_programt::instructiont &instruction )
177
177
{
178
- const exprt &function=code. function ();
178
+ const exprt &function = instruction. call_function ();
179
179
180
180
// If at some point symex_function_call can support more
181
181
// expression ids(), like ID_Dereference, please expand the
182
182
// precondition appropriately.
183
183
PRECONDITION (function.id () == ID_symbol);
184
- symex_function_call_symbol (get_goto_function, state, code);
184
+
185
+ symex_function_call_symbol (
186
+ get_goto_function,
187
+ state,
188
+ instruction.call_lhs (),
189
+ to_symbol_expr (instruction.call_function ()),
190
+ instruction.call_arguments ());
185
191
}
186
192
187
193
void goto_symext::symex_function_call_symbol (
188
194
const get_goto_functiont &get_goto_function,
189
195
statet &state,
190
- const code_function_callt &original_code)
196
+ const exprt &lhs,
197
+ const symbol_exprt &function,
198
+ const exprt::operandst &arguments)
191
199
{
192
- code_function_callt code = original_code;
193
-
194
- if (code.lhs ().is_not_nil ())
195
- code.lhs () = clean_expr (std::move (code.lhs ()), state, true );
200
+ exprt cleaned_lhs;
196
201
197
- code.function () = clean_expr (std::move (code.function ()), state, false );
202
+ if (lhs.is_nil ())
203
+ cleaned_lhs = lhs;
204
+ else
205
+ cleaned_lhs = clean_expr (lhs, state, true );
198
206
199
- for (auto &argument : code.arguments ())
200
- argument = clean_expr (std::move (argument), state, false );
207
+ // no need to clean the function, which is a symbol only
201
208
202
- target. location (state. guard . as_expr (), state. source ) ;
209
+ exprt::operandst cleaned_arguments ;
203
210
204
- PRECONDITION (code.function ().id () == ID_symbol);
211
+ for (auto &argument : arguments)
212
+ cleaned_arguments.push_back (clean_expr (argument, state, false ));
205
213
206
- const irep_idt &identifier=
207
- to_symbol_expr (code.function ()).get_identifier ();
214
+ target.location (state.guard .as_expr (), state.source );
208
215
209
- if (has_prefix (id2string (identifier), CPROVER_FKT_PREFIX))
210
- {
211
- symex_fkt (state, code);
212
- }
213
- else
214
- symex_function_call_code (get_goto_function, state, code);
216
+ symex_function_call_post_clean (
217
+ get_goto_function, state, cleaned_lhs, function, cleaned_arguments);
215
218
}
216
219
217
- void goto_symext::symex_function_call_code (
220
+ void goto_symext::symex_function_call_post_clean (
218
221
const get_goto_functiont &get_goto_function,
219
222
statet &state,
220
- const code_function_callt &call)
223
+ const exprt &cleaned_lhs,
224
+ const symbol_exprt &function,
225
+ const exprt::operandst &cleaned_arguments)
221
226
{
222
- const irep_idt &identifier=
223
- to_symbol_expr (call.function ()).get_identifier ();
227
+ const irep_idt &identifier = function.get_identifier ();
224
228
225
229
const goto_functionst::goto_functiont &goto_function =
226
230
get_goto_function (identifier);
@@ -258,10 +262,10 @@ void goto_symext::symex_function_call_code(
258
262
}
259
263
260
264
// read the arguments -- before the locality renaming
261
- const exprt::operandst &arguments = call.arguments ();
262
265
const std::vector<renamedt<exprt, L2>> renamed_arguments =
263
- make_range (arguments).map (
264
- [&](const exprt &a) { return state.rename (a, ns); });
266
+ make_range (cleaned_arguments).map ([&](const exprt &a) {
267
+ return state.rename (a, ns);
268
+ });
265
269
266
270
// we hide the call if the caller and callee are both hidden
267
271
const bool hidden =
@@ -279,18 +283,18 @@ void goto_symext::symex_function_call_code(
279
283
target.function_return (
280
284
state.guard .as_expr (), identifier, state.source , hidden);
281
285
282
- if (call. lhs () .is_not_nil ())
286
+ if (cleaned_lhs .is_not_nil ())
283
287
{
284
- const auto rhs =
285
- side_effect_expr_nondett (call. lhs (). type (), call. source_location ());
286
- symex_assign (state, call. lhs () , rhs);
288
+ const auto rhs = side_effect_expr_nondett (
289
+ cleaned_lhs. type (), state. source . pc -> source_location ());
290
+ symex_assign (state, cleaned_lhs , rhs);
287
291
}
288
292
289
293
if (symex_config.havoc_undefined_functions )
290
294
{
291
295
// assign non det to function arguments if pointers
292
296
// are not const
293
- for (const auto &arg : call. arguments () )
297
+ for (const auto &arg : cleaned_arguments )
294
298
{
295
299
if (
296
300
arg.type ().id () == ID_pointer &&
@@ -325,10 +329,10 @@ void goto_symext::symex_function_call_code(
325
329
locality (identifier, state, path_storage, goto_function, ns);
326
330
327
331
// assign actuals to formal parameters
328
- parameter_assignments (identifier, goto_function, state, arguments );
332
+ parameter_assignments (identifier, goto_function, state, cleaned_arguments );
329
333
330
334
frame.end_of_function =--goto_function.body .instructions .end ();
331
- frame.return_value =call. lhs () ;
335
+ frame.return_value = cleaned_lhs ;
332
336
frame.function_identifier =identifier;
333
337
frame.hidden_function = goto_function.is_hidden ();
334
338
0 commit comments