@@ -15,6 +15,7 @@ Module: Read Goto Programs
1515
1616#include < util/config.h>
1717#include < util/message.h>
18+ #include < util/replace_symbol.h>
1819#include < util/tempfile.h>
1920
2021#ifdef _MSC_VER
@@ -270,59 +271,46 @@ bool is_goto_binary(
270271// / \param file_name: file name of the goto binary
271272// / \param dest: the goto model returned
272273// / \param message_handler: for diagnostics
273- // / \return true on error, false otherwise
274- bool read_object_and_link (
274+ // / \return nullopt on error, type replacements to be applied otherwise
275+ static optionalt<replace_symbolt::expr_mapt> read_object_and_link (
275276 const std::string &file_name,
276277 goto_modelt &dest,
277278 message_handlert &message_handler)
278279{
279- messaget (message_handler).statistics () << " Reading: "
280- << file_name << messaget::eom;
280+ messaget (message_handler).status ()
281+ << " Reading GOTO program from file " << file_name << messaget::eom;
281282
282283 // we read into a temporary model
283284 auto temp_model = read_goto_binary (file_name, message_handler);
284285 if (!temp_model.has_value ())
285- return true ;
286-
287- try
288- {
289- link_goto_model (dest, *temp_model, message_handler);
290- }
291- catch (...)
292- {
293- return true ;
294- }
295-
296- // reading successful, let's update config
297- config.set_from_symbol_table (dest.symbol_table );
286+ return {};
298287
299- return false ;
288+ return link_goto_model (dest, std::move (*temp_model), message_handler) ;
300289}
301290
302- // / \brief reads an object file, and also updates the config
303- // / \param file_name: file name of the goto binary
304- // / \param dest_symbol_table: symbol table to update
305- // / \param dest_functions: collection of goto functions to update
306- // / \param message_handler: for diagnostics
307- // / \return true on error, false otherwise
308- bool read_object_and_link (
309- const std::string &file_name,
310- symbol_tablet &dest_symbol_table,
311- goto_functionst &dest_functions,
291+ bool read_objects_and_link (
292+ const std::list<std::string> &file_names,
293+ goto_modelt &dest,
312294 message_handlert &message_handler)
313295{
314- goto_modelt goto_model;
296+ if (file_names.empty ())
297+ return false ;
298+
299+ replace_symbolt::expr_mapt object_type_updates;
315300
316- goto_model.symbol_table .swap (dest_symbol_table);
317- goto_model.goto_functions .swap (dest_functions);
301+ for (const auto &file_name : file_names)
302+ {
303+ auto updates_opt = read_object_and_link (file_name, dest, message_handler);
304+ if (!updates_opt.has_value ())
305+ return true ;
306+
307+ object_type_updates.insert (updates_opt->begin (), updates_opt->end ());
308+ }
318309
319- bool result=read_object_and_link (
320- file_name,
321- goto_model,
322- message_handler);
310+ finalize_linking (dest, object_type_updates);
323311
324- goto_model. symbol_table . swap (dest_symbol_table);
325- goto_model. goto_functions . swap (dest_functions );
312+ // reading successful, let's update config
313+ config. set_from_symbol_table (dest. symbol_table );
326314
327- return result ;
315+ return false ;
328316}
0 commit comments