Skip to content

Commit faf9746

Browse files
authored
Merge pull request #3117 from tautschnig/goto-analyzer-binary
goto-analyzer --simplify must write files in binary mode
2 parents 4ef3dc5 + 1099d48 commit faf9746

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

src/goto-analyzer/goto_analyzer_parse_options.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ Author: Daniel Kroening, [email protected]
5151
#include <langapi/language.h>
5252

5353
#include <util/config.h>
54+
#include <util/exception_utils.h>
5455
#include <util/exit_codes.h>
5556
#include <util/options.h>
5657
#include <util/unicode.h>
@@ -197,6 +198,10 @@ void goto_analyzer_parse_optionst::get_command_line_options(optionst &options)
197198
}
198199
else if(cmdline.isset("simplify"))
199200
{
201+
if(cmdline.get_value("simplify") == "-")
202+
throw invalid_command_line_argument_exceptiont(
203+
"cannot output goto binary to stdout", "--simplify");
204+
200205
options.set_option("simplify", true);
201206
options.set_option("outfile", cmdline.get_value("simplify"));
202207
options.set_option("general-analysis", true);
@@ -634,6 +639,9 @@ int goto_analyzer_parse_optionst::perform_analysis(const optionst &options)
634639
}
635640
else if(options.get_bool_option("simplify"))
636641
{
642+
PRECONDITION(!outfile.empty() && outfile != "-");
643+
output_stream.close();
644+
output_stream.open(outfile, std::ios::binary);
637645
result = static_simplifier(goto_model,
638646
*analyzer,
639647
options,

0 commit comments

Comments
 (0)