2525#include < linking/static_lifetime_init.h>
2626
2727#include " ansi_c_entry_point.h"
28+ #include " ansi_c_language.h"
2829#include " c_nondet_symbol_factory.h"
2930
3031exprt::operandst build_function_environment (
@@ -121,7 +122,8 @@ void record_function_outputs(
121122bool ansi_c_entry_point (
122123 symbol_tablet &symbol_table,
123124 const std::string &standard_main,
124- message_handlert &message_handler)
125+ message_handlert &message_handler,
126+ bool wrap_entry_point)
125127{
126128 // check if entry point is already there
127129 if (symbol_table.symbols .find (goto_functionst::entry_point ())!=
@@ -444,7 +446,12 @@ bool ansi_c_entry_point(
444446 message_handler);
445447 }
446448
447- init_code.move_to_operands (call_main);
449+ if (wrap_entry_point) {
450+ auto wrapped_main = wrap_entry_point_in_while (call_main);
451+ init_code.move_to_operands (wrapped_main);
452+ } else {
453+ init_code.move_to_operands (call_main);
454+ }
448455
449456 // TODO: add read/modified (recursively in call graph) globals as INPUT/OUTPUT
450457
@@ -471,3 +478,16 @@ bool ansi_c_entry_point(
471478
472479 return false ;
473480}
481+
482+ // Build and return a while(true) statement nesting the function call
483+ // passed as a parameter.
484+ code_whilet wrap_entry_point_in_while (code_function_callt &call_main)
485+ {
486+ exprt true_expr;
487+ code_whilet while_expr;
488+ true_expr.make_true ();
489+ while_expr.cond () = true_expr;
490+ while_expr.body () = call_main;
491+
492+ return while_expr;
493+ }
0 commit comments