@@ -53,12 +53,11 @@ bool initialize_goto_model(
53
53
sources.push_back (file);
54
54
}
55
55
56
+ language_filest language_files;
57
+ language_files.set_message_handler (message_handler);
58
+
56
59
if (!sources.empty ())
57
60
{
58
- language_filest language_files;
59
-
60
- language_files.set_message_handler (message_handler);
61
-
62
61
for (const auto &filename : sources)
63
62
{
64
63
#ifdef _MSC_VER
@@ -114,19 +113,6 @@ bool initialize_goto_model(
114
113
msg.error () << " CONVERSION ERROR" << messaget::eom;
115
114
return true ;
116
115
}
117
-
118
- if (binaries.empty ())
119
- {
120
- // Enable/disable stub generation for opaque methods
121
- bool stubs_enabled=cmdline.isset (" generate-opaque-stubs" );
122
- language_files.set_should_generate_opaque_method_stubs (stubs_enabled);
123
-
124
- if (language_files.final (goto_model.symbol_table ))
125
- {
126
- msg.error () << " CONVERSION ERROR" << messaget::eom;
127
- return true ;
128
- }
129
- }
130
116
}
131
117
132
118
for (const auto &file : binaries)
@@ -137,17 +123,49 @@ bool initialize_goto_model(
137
123
return true ;
138
124
}
139
125
140
- 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" ))
141
132
{
142
- const std::string &function_id=cmdline.get_value (" function" );
143
- 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 (
144
136
msg.get_message_handler (),
145
137
cmdline,
146
138
goto_model.symbol_table ,
147
139
goto_model.goto_functions );
140
+ entry_point_generation_failed=rebuild_existing_start ();
141
+ }
142
+ else if (!binaries_provided_start)
143
+ {
144
+ // Unsure of the rationale for only generating stubs when there are no
145
+ // GOTO binaries in play; simply mirroring old code in language_uit here.
146
+ if (binaries.empty ())
147
+ {
148
+ // Enable/disable stub generation for opaque methods
149
+ bool stubs_enabled=cmdline.isset (" generate-opaque-stubs" );
150
+ language_files.set_should_generate_opaque_method_stubs (stubs_enabled);
151
+ }
148
152
149
- if (start_function_rebuilder (function_id))
150
- return true ;
153
+ // Allow all language front-ends to try to provide the user-specified
154
+ // (--function) entry-point, or some language-specific default:
155
+ entry_point_generation_failed=
156
+ language_files.generate_support_functions (goto_model.symbol_table );
157
+ }
158
+
159
+ if (entry_point_generation_failed)
160
+ {
161
+ msg.error () << " SUPPORT FUNCTION GENERATION ERROR" << messaget::eom;
162
+ return true ;
163
+ }
164
+
165
+ if (language_files.final (goto_model.symbol_table ))
166
+ {
167
+ msg.error () << " FINAL STAGE CONVERSION ERROR" << messaget::eom;
168
+ return true ;
151
169
}
152
170
153
171
msg.status () << " Generating GOTO Program" << messaget::eom;
0 commit comments