about summary refs log tree commit diff homepage
diff options
context:
space:
mode:
-rw-r--r--lib/Core/Executor.cpp24
-rw-r--r--lib/Solver/QueryLoggingSolver.cpp21
-rw-r--r--lib/Solver/QueryLoggingSolver.h1
3 files changed, 12 insertions, 34 deletions
diff --git a/lib/Core/Executor.cpp b/lib/Core/Executor.cpp
index ecebe916..475beacb 100644
--- a/lib/Core/Executor.cpp
+++ b/lib/Core/Executor.cpp
@@ -43,6 +43,7 @@
 #include "klee/Internal/Module/KInstruction.h"
 #include "klee/Internal/Module/KModule.h"
 #include "klee/Internal/Support/ErrorHandling.h"
+#include "klee/Internal/Support/FileHandling.h"
 #include "klee/Internal/Support/FloatEvaluation.h"
 #include "klee/Internal/Support/ModuleUtil.h"
 #include "klee/Internal/System/Time.h"
@@ -363,33 +364,20 @@ Executor::Executor(LLVMContext &ctx, const InterpreterOptions &opts,
       DebugPrintInstructions.isSet(FILE_SRC)) {
     std::string debug_file_name =
         interpreterHandler->getOutputFilename("instructions.txt");
-    std::string ErrorInfo;
+    std::string error;
 #ifdef HAVE_ZLIB_H
     if (!DebugCompressInstructions) {
 #endif
-
-#if LLVM_VERSION_CODE >= LLVM_VERSION(3, 6)
-    std::error_code ec;
-    debugInstFile = new llvm::raw_fd_ostream(debug_file_name.c_str(), ec,
-                                             llvm::sys::fs::OpenFlags::F_Text);
-    if (ec)
-	    ErrorInfo = ec.message();
-#elif LLVM_VERSION_CODE >= LLVM_VERSION(3, 5)
-    debugInstFile = new llvm::raw_fd_ostream(debug_file_name.c_str(), ErrorInfo,
-                                             llvm::sys::fs::OpenFlags::F_Text);
-#else
-    debugInstFile =
-        new llvm::raw_fd_ostream(debug_file_name.c_str(), ErrorInfo);
-#endif
+      debugInstFile = klee_open_output_file(debug_file_name, error);
 #ifdef HAVE_ZLIB_H
     } else {
       debugInstFile = new compressed_fd_ostream(
-          (debug_file_name + ".gz").c_str(), ErrorInfo);
+          (debug_file_name + ".gz").c_str(), error);
     }
 #endif
-    if (ErrorInfo != "") {
+    if (!error.empty()) {
       klee_error("Could not open file %s : %s", debug_file_name.c_str(),
-                 ErrorInfo.c_str());
+                 error.c_str());
     }
   }
 }
diff --git a/lib/Solver/QueryLoggingSolver.cpp b/lib/Solver/QueryLoggingSolver.cpp
index cf4966cd..7e4d8fe0 100644
--- a/lib/Solver/QueryLoggingSolver.cpp
+++ b/lib/Solver/QueryLoggingSolver.cpp
@@ -13,6 +13,7 @@
 #ifdef HAVE_ZLIB_H
 #include "klee/Internal/Support/CompressionStream.h"
 #include "klee/Internal/Support/ErrorHandling.h"
+#include "klee/Internal/Support/FileHandling.h"
 #endif
 
 #if LLVM_VERSION_CODE >= LLVM_VERSION(3, 5)
@@ -39,27 +40,17 @@ QueryLoggingSolver::QueryLoggingSolver(Solver *_solver, std::string path,
     : solver(_solver), os(0), BufferString(""), logBuffer(BufferString),
       queryCount(0), minQueryTimeToLog(queryTimeToLog), startTime(0.0f),
       lastQueryTime(0.0f), queryCommentSign(commentSign) {
+  std::string error;
 #ifdef HAVE_ZLIB_H
   if (!CreateCompressedQueryLog) {
 #endif
-#if LLVM_VERSION_CODE >= LLVM_VERSION(3, 6)
-    std::error_code ec;
-    os = new llvm::raw_fd_ostream(path.c_str(), ec,
-                                  llvm::sys::fs::OpenFlags::F_Text);
-    if (ec)
-      ErrorInfo = ec.message();
-#elif LLVM_VERSION_CODE >= LLVM_VERSION(3, 5)
-    os = new llvm::raw_fd_ostream(path.c_str(), ErrorInfo,
-                                  llvm::sys::fs::OpenFlags::F_Text);
-#else
-    os = new llvm::raw_fd_ostream(path.c_str(), ErrorInfo);
-#endif
+    os = klee_open_output_file(path, error);
 #ifdef HAVE_ZLIB_H
   } else {
-    os = new compressed_fd_ostream((path + ".gz").c_str(), ErrorInfo);
+    os = new compressed_fd_ostream((path + ".gz").c_str(), error);
   }
-  if (ErrorInfo != "") {
-    klee_error("Could not open file %s : %s", path.c_str(), ErrorInfo.c_str());
+  if (!error.empty()) {
+    klee_error("Could not open file %s : %s", path.c_str(), error.c_str());
   }
 #endif
   assert(0 != solver);
diff --git a/lib/Solver/QueryLoggingSolver.h b/lib/Solver/QueryLoggingSolver.h
index 7ac783d1..68edfe55 100644
--- a/lib/Solver/QueryLoggingSolver.h
+++ b/lib/Solver/QueryLoggingSolver.h
@@ -25,7 +25,6 @@ class QueryLoggingSolver : public SolverImpl {
 
 protected:
   Solver *solver;
-  std::string ErrorInfo;
   llvm::raw_ostream *os;
   // @brief Buffer used by logBuffer
   std::string BufferString;