From 2b34877c5dbf24eabf331a124b1e68d901a72cba Mon Sep 17 00:00:00 2001 From: Julian Büning Date: Wed, 3 Oct 2018 14:42:37 +0200 Subject: refactor klee_open_output_file to return std::unique_ptr and introduce klee_open_compressed_output_file with similar behavior along some other minor improvements --- lib/Solver/QueryLoggingSolver.cpp | 25 +++++++++---------------- 1 file changed, 9 insertions(+), 16 deletions(-) (limited to 'lib/Solver/QueryLoggingSolver.cpp') diff --git a/lib/Solver/QueryLoggingSolver.cpp b/lib/Solver/QueryLoggingSolver.cpp index 7e4d8fe0..0fb145d7 100644 --- a/lib/Solver/QueryLoggingSolver.cpp +++ b/lib/Solver/QueryLoggingSolver.cpp @@ -7,18 +7,11 @@ // //===----------------------------------------------------------------------===// #include "QueryLoggingSolver.h" -#include "klee/Config/config.h" -#include "klee/Internal/System/Time.h" #include "klee/Statistics.h" -#ifdef HAVE_ZLIB_H -#include "klee/Internal/Support/CompressionStream.h" +#include "klee/Config/config.h" #include "klee/Internal/Support/ErrorHandling.h" #include "klee/Internal/Support/FileHandling.h" -#endif - -#if LLVM_VERSION_CODE >= LLVM_VERSION(3, 5) -#include "llvm/Support/FileSystem.h" -#endif +#include "klee/Internal/System/Time.h" using namespace klee::util; @@ -37,9 +30,9 @@ llvm::cl::opt CreateCompressedQueryLog( QueryLoggingSolver::QueryLoggingSolver(Solver *_solver, std::string path, const std::string &commentSign, int queryTimeToLog) - : solver(_solver), os(0), BufferString(""), logBuffer(BufferString), - queryCount(0), minQueryTimeToLog(queryTimeToLog), startTime(0.0f), - lastQueryTime(0.0f), queryCommentSign(commentSign) { + : solver(_solver), BufferString(""), logBuffer(BufferString), queryCount(0), + minQueryTimeToLog(queryTimeToLog), startTime(0.0f), lastQueryTime(0.0f), + queryCommentSign(commentSign) { std::string error; #ifdef HAVE_ZLIB_H if (!CreateCompressedQueryLog) { @@ -47,18 +40,18 @@ QueryLoggingSolver::QueryLoggingSolver(Solver *_solver, std::string path, os = klee_open_output_file(path, error); #ifdef HAVE_ZLIB_H } else { - os = new compressed_fd_ostream((path + ".gz").c_str(), error); + path.append(".gz"); + os = klee_open_compressed_output_file(path, error); } - if (!error.empty()) { +#endif + if (!os) { klee_error("Could not open file %s : %s", path.c_str(), error.c_str()); } -#endif assert(0 != solver); } QueryLoggingSolver::~QueryLoggingSolver() { delete solver; - delete os; } void QueryLoggingSolver::flushBufferConditionally(bool writeToFile) { -- cgit 1.4.1