29
29
bool initialize_goto_model (
30
30
goto_modelt &goto_model,
31
31
const cmdlinet &cmdline,
32
- bool generate_start_function,
33
32
message_handlert &message_handler)
34
33
{
35
34
messaget msg (message_handler);
@@ -54,12 +53,11 @@ bool initialize_goto_model(
54
53
sources.push_back (file);
55
54
}
56
55
56
+ language_filest language_files;
57
+ language_files.set_message_handler (message_handler);
58
+
57
59
if (!sources.empty ())
58
60
{
59
- language_filest language_files;
60
-
61
- language_files.set_message_handler (message_handler);
62
-
63
61
for (const auto &filename : sources)
64
62
{
65
63
#ifdef _MSC_VER
@@ -115,17 +113,6 @@ bool initialize_goto_model(
115
113
msg.error () << " CONVERSION ERROR" << messaget::eom;
116
114
return true ;
117
115
}
118
-
119
- if (binaries.empty ())
120
- {
121
- if (language_files.final (
122
- goto_model.symbol_table ,
123
- generate_start_function))
124
- {
125
- msg.error () << " CONVERSION ERROR" << messaget::eom;
126
- return true ;
127
- }
128
- }
129
116
}
130
117
131
118
for (const auto &file : binaries)
@@ -136,18 +123,39 @@ bool initialize_goto_model(
136
123
return true ;
137
124
}
138
125
139
- if (cmdline.isset (" function" ))
126
+ bool binaries_provided_start=
127
+ goto_model.symbol_table .has_symbol (goto_functionst::entry_point ());
128
+
129
+ bool entry_point_generation_failed=false ;
130
+
131
+ if (binaries_provided_start && cmdline.isset (" function" ))
140
132
{
141
- const std::string &function_id=cmdline.get_value (" function" );
142
- rebuild_goto_start_functiont start_function_rebuilder (
133
+ // Rebuild the entry-point, using the language annotation of the
134
+ // existing __CPROVER_start function:
135
+ rebuild_goto_start_functiont rebuild_existing_start (
143
136
msg.get_message_handler (),
144
137
goto_model.symbol_table ,
145
138
goto_model.goto_functions );
139
+ entry_point_generation_failed=rebuild_existing_start ();
140
+ }
141
+ else if (!binaries_provided_start)
142
+ {
143
+ // Allow all language front-ends to try to provide the user-specified
144
+ // (--function) entry-point, or some language-specific default:
145
+ entry_point_generation_failed=
146
+ language_files.generate_support_functions (goto_model.symbol_table );
147
+ }
146
148
147
- if (start_function_rebuilder (function_id))
148
- {
149
- return 6 ;
150
- }
149
+ if (entry_point_generation_failed)
150
+ {
151
+ msg.error () << " SUPPORT FUNCTION GENERATION ERROR" << messaget::eom;
152
+ return true ;
153
+ }
154
+
155
+ if (language_files.final (goto_model.symbol_table ))
156
+ {
157
+ msg.error () << " FINAL STAGE CONVERSION ERROR" << messaget::eom;
158
+ return true ;
151
159
}
152
160
153
161
msg.status () << " Generating GOTO Program" << messaget::eom;
0 commit comments