Skip to content

Commit 082b6a3

Browse files
committed
Use non-deprecated variants of read_goto_binary
The 4-parameter variant is deprecated.
1 parent 5256e2a commit 082b6a3

File tree

5 files changed

+29
-53
lines changed

5 files changed

+29
-53
lines changed

jbmc/src/jdiff/jdiff_parse_options.cpp

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -292,13 +292,15 @@ int jdiff_parse_optionst::get_goto_program(
292292

293293
if(is_goto_binary(cmdline.args[0]))
294294
{
295-
if(read_goto_binary(
296-
cmdline.args[0],
297-
goto_model.symbol_table,
298-
goto_model.goto_functions,
299-
languages.get_message_handler()))
295+
auto tmp_goto_model =
296+
read_goto_binary(
297+
cmdline.args[0],
298+
languages.get_message_handler());
299+
if(!tmp_goto_model.has_value())
300300
return CPROVER_EXIT_INCORRECT_TASK;
301301

302+
goto_model = std::move(*tmp_goto_model);
303+
302304
config.set(cmdline);
303305

304306
// This one is done.

src/goto-cc/linker_script_merge.cpp

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -57,22 +57,19 @@ int linker_script_merget::add_linker_script_definitions()
5757
return fail;
5858
}
5959

60-
goto_modelt original_goto_model;
60+
auto original_goto_model = read_goto_binary(goto_binary, get_message_handler());
6161

62-
fail =
63-
read_goto_binary(goto_binary, original_goto_model, get_message_handler());
64-
65-
if(fail!=0)
62+
if(!original_goto_model.has_value())
6663
{
6764
error() << "Unable to read goto binary for linker script merging" << eom;
68-
return fail;
65+
return 1;
6966
}
7067

7168
fail=1;
7269
linker_valuest linker_values;
7370
const auto &pair =
74-
original_goto_model.goto_functions.function_map.find(INITIALIZE_FUNCTION);
75-
if(pair == original_goto_model.goto_functions.function_map.end())
71+
original_goto_model->goto_functions.function_map.find(INITIALIZE_FUNCTION);
72+
if(pair == original_goto_model->goto_functions.function_map.end())
7673
{
7774
error() << "No " << INITIALIZE_FUNCTION << " found in goto_functions"
7875
<< eom;
@@ -82,7 +79,7 @@ int linker_script_merget::add_linker_script_definitions()
8279
data,
8380
cmdline.get_value('T'),
8481
pair->second.body,
85-
original_goto_model.symbol_table,
82+
original_goto_model->symbol_table,
8683
linker_values);
8784
if(fail!=0)
8885
{
@@ -97,15 +94,15 @@ int linker_script_merget::add_linker_script_definitions()
9794
// The keys of linker_values are exactly the elements of
9895
// linker_defined_symbols, so iterate over linker_values from now on.
9996

100-
fail = pointerize_linker_defined_symbols(original_goto_model, linker_values);
97+
fail = pointerize_linker_defined_symbols(*original_goto_model, linker_values);
10198

10299
if(fail!=0)
103100
{
104101
error() << "Could not pointerize all linker-defined expressions" << eom;
105102
return fail;
106103
}
107104

108-
fail = compiler.write_bin_object_file(goto_binary, original_goto_model);
105+
fail = compiler.write_bin_object_file(goto_binary, *original_goto_model);
109106

110107
if(fail!=0)
111108
error() << "Could not write linkerscript-augmented binary" << eom;

src/goto-diff/goto_diff_parse_options.cpp

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -332,13 +332,15 @@ int goto_diff_parse_optionst::get_goto_program(
332332

333333
if(is_goto_binary(cmdline.args[0]))
334334
{
335-
if(read_goto_binary(
335+
auto tmp_goto_model =
336+
read_goto_binary(
336337
cmdline.args[0],
337-
goto_model.symbol_table,
338-
goto_model.goto_functions,
339-
languages.get_message_handler()))
338+
languages.get_message_handler());
339+
if(!tmp_goto_model.has_value())
340340
return CPROVER_EXIT_INCORRECT_TASK;
341341

342+
goto_model = std::move(*tmp_goto_model);
343+
342344
config.set(cmdline);
343345

344346
// This one is done.

src/goto-programs/read_goto_binary.cpp

Lines changed: 8 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -27,20 +27,11 @@ Module: Read Goto Programs
2727
#include "elf_reader.h"
2828
#include "osx_fat_reader.h"
2929

30-
/// \brief Read a goto binary from a file, but do not update \ref config
31-
/// \param filename: the file name of the goto binary
32-
/// \param dest: the goto model returned
33-
/// \param message_handler: for diagnostics
34-
/// \deprecated Use read_goto_binary(file, message_handler) instead
35-
/// \return true on failure, false on success
36-
bool read_goto_binary(
30+
static bool read_goto_binary(
3731
const std::string &filename,
38-
goto_modelt &dest,
39-
message_handlert &message_handler)
40-
{
41-
return read_goto_binary(
42-
filename, dest.symbol_table, dest.goto_functions, message_handler);
43-
}
32+
symbol_tablet &,
33+
goto_functionst &,
34+
message_handlert &);
4435

4536
/// \brief Read a goto binary from a file, but do not update \ref config
4637
/// \param filename: the file name of the goto binary
@@ -66,7 +57,7 @@ read_goto_binary(const std::string &filename, message_handlert &message_handler)
6657
/// \param goto_functions: the goto functions from the goto binary
6758
/// \param message_handler: for diagnostics
6859
/// \return true on failure, false on success
69-
bool read_goto_binary(
60+
static bool read_goto_binary(
7061
const std::string &filename,
7162
symbol_tablet &symbol_table,
7263
goto_functionst &goto_functions,
@@ -240,17 +231,13 @@ bool read_object_and_link(
240231
<< file_name << messaget::eom;
241232

242233
// we read into a temporary model
243-
goto_modelt temp_model;
244-
245-
if(read_goto_binary(
246-
file_name,
247-
temp_model,
248-
message_handler))
234+
auto temp_model = read_goto_binary(file_name, message_handler);
235+
if(!temp_model.has_value())
249236
return true;
250237

251238
try
252239
{
253-
link_goto_model(dest, temp_model, message_handler);
240+
link_goto_model(dest, *temp_model, message_handler);
254241
}
255242
catch(...)
256243
{

src/goto-programs/read_goto_binary.h

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -22,18 +22,6 @@ class goto_modelt;
2222
class message_handlert;
2323
class symbol_tablet;
2424

25-
bool read_goto_binary(
26-
const std::string &filename,
27-
symbol_tablet &,
28-
goto_functionst &,
29-
message_handlert &);
30-
31-
DEPRECATED("use two-parameter variant instead")
32-
bool read_goto_binary(
33-
const std::string &filename,
34-
goto_modelt &dest,
35-
message_handlert &);
36-
3725
optionalt<goto_modelt>
3826
read_goto_binary(const std::string &filename, message_handlert &);
3927

0 commit comments

Comments
 (0)