@@ -329,12 +329,54 @@ solver_factoryt::get_string_refinement()
329
329
std::move (decision_procedure), std::move (prop));
330
330
}
331
331
332
+ std::unique_ptr<std::ofstream> open_outfile_and_check (
333
+ const std::string &filename,
334
+ message_handlert &message_handler)
335
+ {
336
+ if (filename.empty ())
337
+ return nullptr ;
338
+
339
+ #ifdef _MSC_VER
340
+ auto out = util_make_unique<std::ofstream>(widen (filename));
341
+ #else
342
+ auto out = util_make_unique<std::ofstream>(filename);
343
+ #endif
344
+
345
+ if (!*out)
346
+ {
347
+ throw invalid_command_line_argument_exceptiont (
348
+ " failed to open file: " + filename, " --outfile" );
349
+ }
350
+
351
+ messaget log (message_handler);
352
+ log .status () << " Outputting SMTLib formula to file: " << filename
353
+ << messaget::eom;
354
+ return out;
355
+ }
356
+
332
357
std::unique_ptr<solver_factoryt::solvert>
333
358
solver_factoryt::get_incremental_smt2 (std::string solver_command)
334
359
{
335
360
no_beautification ();
336
- auto solver_process = util_make_unique<smt_piped_solver_processt>(
337
- std::move (solver_command), message_handler);
361
+
362
+ const std::string outfile_arg = options.get_option (" outfile" );
363
+
364
+ std::unique_ptr<smt_base_solver_processt> solver_process = nullptr ;
365
+
366
+ if (!outfile_arg.empty ())
367
+ {
368
+ bool on_std_out = outfile_arg == " -" ;
369
+ std::unique_ptr<std::ostream> outfile =
370
+ on_std_out ? nullptr
371
+ : open_outfile_and_check (outfile_arg, message_handler);
372
+ solver_process = util_make_unique<smt_incremental_dry_run_solvert>(
373
+ message_handler, on_std_out ? std::cout : *outfile, std::move (outfile));
374
+ }
375
+ else
376
+ {
377
+ solver_process = util_make_unique<smt_piped_solver_processt>(
378
+ std::move (solver_command), message_handler);
379
+ }
338
380
339
381
return util_make_unique<solvert>(
340
382
util_make_unique<smt2_incremental_decision_proceduret>(
@@ -390,17 +432,7 @@ solver_factoryt::get_smt2(smt2_dect::solvert solver)
390
432
}
391
433
else
392
434
{
393
- #ifdef _MSC_VER
394
- auto out = util_make_unique<std::ofstream>(widen (filename));
395
- #else
396
- auto out = util_make_unique<std::ofstream>(filename);
397
- #endif
398
-
399
- if (!*out)
400
- {
401
- throw invalid_command_line_argument_exceptiont (
402
- " failed to open file: " + filename, " --outfile" );
403
- }
435
+ auto out = open_outfile_and_check (filename, message_handler);
404
436
405
437
auto smt2_conv = util_make_unique<smt2_convt>(
406
438
ns,
0 commit comments