Skip to content

new interface for read_goto_binary() #2965

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 17, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions src/goto-instrument/goto_instrument_parse_options.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -898,10 +898,13 @@ void goto_instrument_parse_optionst::get_goto_program()
{
status() << "Reading GOTO program from `" << cmdline.args[0] << "'" << eom;

if(read_goto_binary(cmdline.args[0],
goto_model, get_message_handler()))
auto result = read_goto_binary(cmdline.args[0], get_message_handler());

if(!result.has_value())
throw 0;

goto_model = std::move(result.value());

config.set(cmdline);
}

Expand Down
14 changes: 14 additions & 0 deletions src/goto-programs/read_goto_binary.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,20 @@ bool read_goto_binary(
filename, dest.symbol_table, dest.goto_functions, message_handler);
}

optionalt<goto_modelt>
read_goto_binary(const std::string &filename, message_handlert &message_handler)
{
goto_modelt dest;

if(read_goto_binary(
filename, dest.symbol_table, dest.goto_functions, message_handler))
{
return {};
}
else
return std::move(dest);
}

bool read_goto_binary(
const std::string &filename,
symbol_tablet &symbol_table,
Expand Down
7 changes: 7 additions & 0 deletions src/goto-programs/read_goto_binary.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ Author: Daniel Kroening, [email protected]

#include <string>

#include <util/deprecate.h>
#include <util/optional.h>

class goto_functionst;
class goto_modelt;
class message_handlert;
Expand All @@ -25,11 +28,15 @@ bool read_goto_binary(
goto_functionst &,
message_handlert &);

DEPRECATED("use two-parameter variant instead")
bool read_goto_binary(
const std::string &filename,
goto_modelt &dest,
message_handlert &);

optionalt<goto_modelt>
read_goto_binary(const std::string &filename, message_handlert &);

bool is_goto_binary(const std::string &filename);

bool read_object_and_link(
Expand Down