Skip to content

Commit 35a0ac3

Browse files
authored
Merge pull request #4341 from tautschnig/is_goto_binary
Pass a message handler to is_goto_binary [blocks: #3867]
2 parents 616a4b3 + a3afbcf commit 35a0ac3

File tree

6 files changed

+14
-11
lines changed

6 files changed

+14
-11
lines changed

src/cbmc/cbmc_parse_options.cpp

+3-2
Original file line numberDiff line numberDiff line change
@@ -485,8 +485,9 @@ int cbmc_parse_optionst::doit()
485485

486486
if(cmdline.isset("show-parse-tree"))
487487
{
488-
if(cmdline.args.size()!=1 ||
489-
is_goto_binary(cmdline.args[0]))
488+
if(
489+
cmdline.args.size() != 1 ||
490+
is_goto_binary(cmdline.args[0], ui_message_handler))
490491
{
491492
error() << "Please give exactly one source file" << eom;
492493
return CPROVER_EXIT_INCORRECT_TASK;

src/goto-cc/compile.cpp

+7-5
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,9 @@ enum class file_typet
126126
ELF_OBJECT
127127
};
128128

129-
static file_typet detect_file_type(const std::string &file_name)
129+
static file_typet detect_file_type(
130+
const std::string &file_name,
131+
message_handlert &message_handler)
130132
{
131133
// first of all, try to open the file
132134
std::ifstream in(file_name);
@@ -154,7 +156,7 @@ static file_typet detect_file_type(const std::string &file_name)
154156
if(ext == "a")
155157
return file_typet::NORMAL_ARCHIVE;
156158

157-
if(is_goto_binary(file_name))
159+
if(is_goto_binary(file_name, message_handler))
158160
return file_typet::GOTO_BINARY;
159161

160162
if(hdr[0] == 0x7f && memcmp(hdr + 1, "ELF", 3) == 0)
@@ -167,7 +169,7 @@ static file_typet detect_file_type(const std::string &file_name)
167169
/// \return false on success, true on error.
168170
bool compilet::add_input_file(const std::string &file_name)
169171
{
170-
switch(detect_file_type(file_name))
172+
switch(detect_file_type(file_name, get_message_handler()))
171173
{
172174
case file_typet::FAILED_TO_OPEN_FILE:
173175
warning() << "failed to open file `" << file_name
@@ -249,7 +251,7 @@ bool compilet::add_files_from_archive(
249251
{
250252
std::string t = concat_dir_file(tstr, line);
251253

252-
if(is_goto_binary(t))
254+
if(is_goto_binary(t, get_message_handler()))
253255
object_files.push_back(t);
254256
else
255257
debug() << "Object file is not a goto binary: " << line << eom;
@@ -280,7 +282,7 @@ bool compilet::find_library(const std::string &name)
280282
{
281283
library_file_name = concat_dir_file(library_path, "lib" + name + ".so");
282284

283-
switch(detect_file_type(library_file_name))
285+
switch(detect_file_type(library_file_name, get_message_handler()))
284286
{
285287
case file_typet::GOTO_BINARY:
286288
return !add_input_file(library_file_name);

src/goto-programs/initialize_goto_model.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ goto_modelt initialize_goto_model(
7575

7676
for(const auto &file : files)
7777
{
78-
if(is_goto_binary(file))
78+
if(is_goto_binary(file, message_handler))
7979
binaries.push_back(file);
8080
else
8181
sources.push_back(file);

src/goto-programs/lazy_goto_model.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ void lazy_goto_modelt::initialize(
128128

129129
for(const auto &file : files)
130130
{
131-
if(is_goto_binary(file))
131+
if(is_goto_binary(file, message_handler))
132132
binaries.push_back(file);
133133
else
134134
sources.push_back(file);

src/goto-programs/read_goto_binary.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ static bool read_goto_binary(
155155
return true;
156156
}
157157

158-
bool is_goto_binary(const std::string &filename)
158+
bool is_goto_binary(const std::string &filename, message_handlert &)
159159
{
160160
#ifdef _MSC_VER
161161
std::ifstream in(widen(filename), std::ios::binary);

src/goto-programs/read_goto_binary.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ class symbol_tablet;
2525
optionalt<goto_modelt>
2626
read_goto_binary(const std::string &filename, message_handlert &);
2727

28-
bool is_goto_binary(const std::string &filename);
28+
bool is_goto_binary(const std::string &filename, message_handlert &);
2929

3030
bool read_object_and_link(
3131
const std::string &file_name,

0 commit comments

Comments
 (0)