@@ -409,3 +409,39 @@ require_goto_statements::require_entry_point_argument_assignment(
409
409
.get_identifier ();
410
410
return argument_tmp_name;
411
411
}
412
+
413
+ // / Verify that a collection of statements contains a function call to a
414
+ // / function whose symbol identifier matches the provided identifier
415
+ // / \param statements: The collection of statements to inspect
416
+ // / \param function_call_identifier: The symbol identifier of the function
417
+ // / that should have been called
418
+ // / \return The first code_function_callt to the relevant function or throws a
419
+ // / no_matching_function_callt if no call is found
420
+ code_function_callt require_goto_statements::require_function_call (
421
+ const std::vector<codet> &statements,
422
+ const irep_idt &function_call_identifier)
423
+ {
424
+ // TODO: Would appreciate some review comments on whether it makes the most sense:
425
+ // - return a vector of matching code_function_calls
426
+ // - return an optionalt with the first matching call
427
+ // - return a code_function_callt throwing an exception if none found
428
+ for (const codet &statement : statements)
429
+ {
430
+ if (statement.get_statement () == ID_function_call)
431
+ {
432
+ const code_function_callt &function_call =
433
+ to_code_function_call (statement);
434
+
435
+ if (function_call.function ().id () == ID_symbol)
436
+ {
437
+ if (
438
+ to_symbol_expr (function_call.function ()).get_identifier () ==
439
+ function_call_identifier)
440
+ {
441
+ return function_call;
442
+ }
443
+ }
444
+ }
445
+ }
446
+ throw no_matching_function_callt (function_call_identifier);
447
+ }
0 commit comments