@@ -394,63 +394,25 @@ bool ai_baset::do_function_call_rec(
394
394
{
395
395
PRECONDITION (!goto_functions.function_map .empty ());
396
396
397
- // We can't really do this here -- we rely on
398
- // these being removed by some previous analysis.
399
- PRECONDITION (function.id () != ID_dereference);
400
-
401
- // Can't be a function
397
+ // This is quite a strong assumption on the well-formedness of the program.
398
+ // It means function pointers must be removed before use.
402
399
DATA_INVARIANT (
403
- function.id () != " NULL-object" , " Function cannot be null object" );
404
- DATA_INVARIANT (function.id () != ID_member, " Function cannot be struct field" );
405
- DATA_INVARIANT (function.id () != ID_index, " Function cannot be array element" );
400
+ function.id () == ID_symbol,
401
+ " Function pointers and indirect calls must be removed before analysis." );
406
402
407
403
bool new_data=false ;
408
404
409
- if (function.id ()==ID_symbol)
410
- {
411
- const irep_idt &identifier = to_symbol_expr (function).get_identifier ();
405
+ const irep_idt &identifier = to_symbol_expr (function).get_identifier ();
412
406
413
- goto_functionst::function_mapt::const_iterator it=
414
- goto_functions.function_map .find (identifier);
407
+ goto_functionst::function_mapt::const_iterator it =
408
+ goto_functions.function_map .find (identifier);
415
409
416
- if (it==goto_functions.function_map .end ())
417
- throw " failed to find function " +id2string (identifier);
410
+ DATA_INVARIANT (
411
+ it != goto_functions.function_map .end (),
412
+ " Function " + id2string (identifier) + " not in function map" );
418
413
419
- new_data=do_function_call (
420
- l_call, l_return,
421
- goto_functions,
422
- it,
423
- arguments,
424
- ns);
425
- }
426
- else if (function.id ()==ID_if)
427
- {
428
- DATA_INVARIANT (function.operands ().size () != 3 , " if has three operands" );
429
-
430
- bool new_data1=
431
- do_function_call_rec (
432
- l_call, l_return,
433
- function.op1 (),
434
- arguments,
435
- goto_functions,
436
- ns);
437
-
438
- bool new_data2=
439
- do_function_call_rec (
440
- l_call, l_return,
441
- function.op2 (),
442
- arguments,
443
- goto_functions,
444
- ns);
445
-
446
- if (new_data1 || new_data2)
447
- new_data=true ;
448
- }
449
- else
450
- {
451
- throw " unexpected function_call argument: " +
452
- function.id_string ();
453
- }
414
+ new_data =
415
+ do_function_call (l_call, l_return, goto_functions, it, arguments, ns);
454
416
455
417
return new_data;
456
418
}
0 commit comments