Skip to content

Commit 8af67d1

Browse files
authored
Merge pull request #3883 from tautschnig/deprecation-read_goto_binary
Use non-deprecated variants of read_goto_binary [blocks: #3800]
2 parents 20f17ad + e0deb51 commit 8af67d1

File tree

5 files changed

+27
-54
lines changed

5 files changed

+27
-54
lines changed

jbmc/src/jdiff/jdiff_parse_options.cpp

+5-5
Original file line numberDiff line numberDiff line change
@@ -292,13 +292,13 @@ 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(cmdline.args[0], languages.get_message_handler());
297+
if(!tmp_goto_model.has_value())
300298
return CPROVER_EXIT_INCORRECT_TASK;
301299

300+
goto_model = std::move(*tmp_goto_model);
301+
302302
config.set(cmdline);
303303

304304
// This one is done.

src/goto-cc/linker_script_merge.cpp

+9-11
Original file line numberDiff line numberDiff line change
@@ -57,22 +57,20 @@ int linker_script_merget::add_linker_script_definitions()
5757
return fail;
5858
}
5959

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

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

7169
fail=1;
7270
linker_valuest linker_values;
7371
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())
72+
original_goto_model->goto_functions.function_map.find(INITIALIZE_FUNCTION);
73+
if(pair == original_goto_model->goto_functions.function_map.end())
7674
{
7775
error() << "No " << INITIALIZE_FUNCTION << " found in goto_functions"
7876
<< eom;
@@ -82,7 +80,7 @@ int linker_script_merget::add_linker_script_definitions()
8280
data,
8381
cmdline.get_value('T'),
8482
pair->second.body,
85-
original_goto_model.symbol_table,
83+
original_goto_model->symbol_table,
8684
linker_values);
8785
if(fail!=0)
8886
{
@@ -97,15 +95,15 @@ int linker_script_merget::add_linker_script_definitions()
9795
// The keys of linker_values are exactly the elements of
9896
// linker_defined_symbols, so iterate over linker_values from now on.
9997

100-
fail = pointerize_linker_defined_symbols(original_goto_model, linker_values);
98+
fail = pointerize_linker_defined_symbols(*original_goto_model, linker_values);
10199

102100
if(fail!=0)
103101
{
104102
error() << "Could not pointerize all linker-defined expressions" << eom;
105103
return fail;
106104
}
107105

108-
fail = compiler.write_bin_object_file(goto_binary, original_goto_model);
106+
fail = compiler.write_bin_object_file(goto_binary, *original_goto_model);
109107

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

src/goto-diff/goto_diff_parse_options.cpp

+5-5
Original file line numberDiff line numberDiff line change
@@ -332,13 +332,13 @@ int goto_diff_parse_optionst::get_goto_program(
332332

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

340+
goto_model = std::move(*tmp_goto_model);
341+
342342
config.set(cmdline);
343343

344344
// This one is done.

src/goto-programs/read_goto_binary.cpp

+8-21
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

-12
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)