about summary refs log tree commit diff homepage
diff options
context:
space:
mode:
authorMartin Nowack <martin.nowack@gmail.com>2015-08-10 08:59:00 +0200
committerDan Liew <daniel.liew@imperial.ac.uk>2015-12-17 19:30:14 +0000
commit771cdf39d9c1e142269e2cafc4365d0d68e05f9a (patch)
treee4d0c7a9eb9a5aee2ed350d77625aec89cc05ed5
parentd8f9c929f69cdfb739f03b6512035071c02108c9 (diff)
downloadklee-771cdf39d9c1e142269e2cafc4365d0d68e05f9a.tar.gz
Refactoring: Moving klee_warning/_error functions to ErrorHandling in Support directory
-rw-r--r--include/klee/Internal/Support/ErrorHandling.h51
-rw-r--r--lib/Core/Common.h56
-rw-r--r--lib/Core/Executor.cpp2
-rw-r--r--lib/Core/ExecutorTimers.cpp3
-rw-r--r--lib/Core/Memory.cpp3
-rw-r--r--lib/Core/MemoryManager.cpp3
-rw-r--r--lib/Core/Searcher.cpp3
-rw-r--r--lib/Core/SeedInfo.cpp3
-rw-r--r--lib/Core/SpecialFunctionHandler.cpp3
-rw-r--r--lib/Core/StatsTracker.cpp3
-rw-r--r--lib/Core/UserSearcher.cpp3
-rw-r--r--lib/Module/KModule.cpp4
-rw-r--r--lib/Module/ModuleUtil.cpp4
-rw-r--r--lib/Solver/CexCachingSolver.cpp2
-rw-r--r--lib/Support/ErrorHandling.cpp (renamed from lib/Core/Common.cpp)64
-rw-r--r--tools/klee/main.cpp4
16 files changed, 96 insertions, 115 deletions
diff --git a/include/klee/Internal/Support/ErrorHandling.h b/include/klee/Internal/Support/ErrorHandling.h
new file mode 100644
index 00000000..330985e9
--- /dev/null
+++ b/include/klee/Internal/Support/ErrorHandling.h
@@ -0,0 +1,51 @@
+//===-- ErrorHandling.h -----------------------------------------*- C++ -*-===//
+//
+//                     The KLEE Symbolic Virtual Machine
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef __KLEE_ERROR_HANDLING_H__
+#define __KLEE_ERROR_HANDLING_H__
+
+#ifdef __CYGWIN__
+#ifndef WINDOWS
+#define WINDOWS
+#endif
+#endif
+
+#include <stdio.h>
+
+namespace klee {
+
+extern FILE *klee_warning_file;
+extern FILE *klee_message_file;
+
+/// Print "KLEE: ERROR" followed by the msg in printf format and a
+/// newline on stderr and to warnings.txt, then exit with an error.
+void klee_error(const char *msg, ...)
+    __attribute__((format(printf, 1, 2), noreturn));
+
+/// Print "KLEE: " followed by the msg in printf format and a
+/// newline on stderr and to messages.txt.
+void klee_message(const char *msg, ...) __attribute__((format(printf, 1, 2)));
+
+/// Print "KLEE: " followed by the msg in printf format and a
+/// newline to messages.txt.
+void klee_message_to_file(const char *msg, ...)
+    __attribute__((format(printf, 1, 2)));
+
+/// Print "KLEE: WARNING" followed by the msg in printf format and a
+/// newline on stderr and to warnings.txt.
+void klee_warning(const char *msg, ...) __attribute__((format(printf, 1, 2)));
+
+/// Print "KLEE: WARNING" followed by the msg in printf format and a
+/// newline on stderr and to warnings.txt. However, the warning is only
+/// printed once for each unique (id, msg) pair (as pointers).
+void klee_warning_once(const void *id, const char *msg, ...)
+    __attribute__((format(printf, 2, 3)));
+}
+
+#endif /* __KLEE_ERROR_HANDLING_H__ */
diff --git a/lib/Core/Common.h b/lib/Core/Common.h
deleted file mode 100644
index ce05b536..00000000
--- a/lib/Core/Common.h
+++ /dev/null
@@ -1,56 +0,0 @@
-//===-- Common.h ------------------------------------------------*- C++ -*-===//
-//
-//                     The KLEE Symbolic Virtual Machine
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-
-#ifndef __KLEE_COMMON_H__
-#define __KLEE_COMMON_H__
-
-#ifdef __CYGWIN__
-#ifndef WINDOWS
-#define WINDOWS
-#endif
-#endif
-
-#include <stdio.h>
-
-// XXX ugh
-namespace klee {
-  class Solver;
-
-  extern FILE* klee_warning_file;
-  extern FILE* klee_message_file;
-
-  /// Print "KLEE: ERROR" followed by the msg in printf format and a
-  /// newline on stderr and to warnings.txt, then exit with an error.
-  void klee_error(const char *msg, ...)
-    __attribute__ ((format (printf, 1, 2), noreturn));
-
-  /// Print "KLEE: " followed by the msg in printf format and a
-  /// newline on stderr and to messages.txt.
-  void klee_message(const char *msg, ...)
-    __attribute__ ((format (printf, 1, 2)));
-
-  /// Print "KLEE: " followed by the msg in printf format and a
-  /// newline to messages.txt.
-  void klee_message_to_file(const char *msg, ...)
-    __attribute__ ((format (printf, 1, 2)));
-
-  /// Print "KLEE: WARNING" followed by the msg in printf format and a
-  /// newline on stderr and to warnings.txt.
-  void klee_warning(const char *msg, ...)
-    __attribute__ ((format (printf, 1, 2)));
-
-  /// Print "KLEE: WARNING" followed by the msg in printf format and a
-  /// newline on stderr and to warnings.txt. However, the warning is only 
-  /// printed once for each unique (id, msg) pair (as pointers).
-  void klee_warning_once(const void *id,
-                         const char *msg, ...)
-    __attribute__ ((format (printf, 2, 3)));
-}
-
-#endif /* __KLEE_COMMON_H__ */
diff --git a/lib/Core/Executor.cpp b/lib/Core/Executor.cpp
index 49e526f5..0b34c357 100644
--- a/lib/Core/Executor.cpp
+++ b/lib/Core/Executor.cpp
@@ -7,7 +7,6 @@
 //
 //===----------------------------------------------------------------------===//
 
-#include "Common.h"
 #include "Executor.h"
 #include "Context.h"
 #include "CoreStats.h"
@@ -44,6 +43,7 @@
 #include "klee/Internal/Module/InstructionInfoTable.h"
 #include "klee/Internal/Module/KInstruction.h"
 #include "klee/Internal/Module/KModule.h"
+#include "klee/Internal/Support/ErrorHandling.h"
 #include "klee/Internal/Support/FloatEvaluation.h"
 #include "klee/Internal/System/Time.h"
 #include "klee/Internal/System/MemoryUsage.h"
diff --git a/lib/Core/ExecutorTimers.cpp b/lib/Core/ExecutorTimers.cpp
index e4622d85..38411c4f 100644
--- a/lib/Core/ExecutorTimers.cpp
+++ b/lib/Core/ExecutorTimers.cpp
@@ -7,8 +7,6 @@
 //
 //===----------------------------------------------------------------------===//
 
-#include "Common.h"
-
 #include "CoreStats.h"
 #include "Executor.h"
 #include "PTree.h"
@@ -20,6 +18,7 @@
 #include "klee/Internal/Module/KInstruction.h"
 #include "klee/Internal/Module/KModule.h"
 #include "klee/Internal/System/Time.h"
+#include "klee/Internal/Support/ErrorHandling.h"
 
 #if LLVM_VERSION_CODE >= LLVM_VERSION(3, 3)
 #include "llvm/IR/Function.h"
diff --git a/lib/Core/Memory.cpp b/lib/Core/Memory.cpp
index 07c292a0..50e9aa9f 100644
--- a/lib/Core/Memory.cpp
+++ b/lib/Core/Memory.cpp
@@ -7,14 +7,13 @@
 //
 //===----------------------------------------------------------------------===//
 
-#include "Common.h"
-
 #include "Memory.h"
 
 #include "Context.h"
 #include "klee/Expr.h"
 #include "klee/Solver.h"
 #include "klee/util/BitArray.h"
+#include "klee/Internal/Support/ErrorHandling.h"
 
 #include "ObjectHolder.h"
 #include "MemoryManager.h"
diff --git a/lib/Core/MemoryManager.cpp b/lib/Core/MemoryManager.cpp
index a1198007..7c76d480 100644
--- a/lib/Core/MemoryManager.cpp
+++ b/lib/Core/MemoryManager.cpp
@@ -7,8 +7,6 @@
 //
 //===----------------------------------------------------------------------===//
 
-#include "Common.h"
-
 #include "CoreStats.h"
 #include "Memory.h"
 #include "MemoryManager.h"
@@ -16,6 +14,7 @@
 #include "klee/ExecutionState.h"
 #include "klee/Expr.h"
 #include "klee/Solver.h"
+#include "klee/Internal/Support/ErrorHandling.h"
 
 #include "llvm/Support/CommandLine.h"
 
diff --git a/lib/Core/Searcher.cpp b/lib/Core/Searcher.cpp
index e33d2a56..cbb88727 100644
--- a/lib/Core/Searcher.cpp
+++ b/lib/Core/Searcher.cpp
@@ -7,8 +7,6 @@
 //
 //===----------------------------------------------------------------------===//
 
-#include "Common.h"
-
 #include "Searcher.h"
 
 #include "CoreStats.h"
@@ -25,6 +23,7 @@
 #include "klee/Internal/ADT/RNG.h"
 #include "klee/Internal/Support/ModuleUtil.h"
 #include "klee/Internal/System/Time.h"
+#include "klee/Internal/Support/ErrorHandling.h"
 #if LLVM_VERSION_CODE >= LLVM_VERSION(3, 3)
 #include "llvm/IR/Constants.h"
 #include "llvm/IR/Instructions.h"
diff --git a/lib/Core/SeedInfo.cpp b/lib/Core/SeedInfo.cpp
index b540d271..90de17ff 100644
--- a/lib/Core/SeedInfo.cpp
+++ b/lib/Core/SeedInfo.cpp
@@ -7,8 +7,6 @@
 //
 //===----------------------------------------------------------------------===//
 
-#include "Common.h"
-
 #include "Memory.h"
 #include "SeedInfo.h"
 #include "TimingSolver.h"
@@ -17,6 +15,7 @@
 #include "klee/Expr.h"
 #include "klee/util/ExprUtil.h"
 #include "klee/Internal/ADT/KTest.h"
+#include "klee/Internal/Support/ErrorHandling.h"
 
 using namespace klee;
 
diff --git a/lib/Core/SpecialFunctionHandler.cpp b/lib/Core/SpecialFunctionHandler.cpp
index fdd4cdd9..caec5e39 100644
--- a/lib/Core/SpecialFunctionHandler.cpp
+++ b/lib/Core/SpecialFunctionHandler.cpp
@@ -7,8 +7,6 @@
 //
 //===----------------------------------------------------------------------===//
 
-#include "Common.h"
-
 #include "Memory.h"
 #include "SpecialFunctionHandler.h"
 #include "TimingSolver.h"
@@ -18,6 +16,7 @@
 #include "klee/Internal/Module/KInstruction.h"
 #include "klee/Internal/Module/KModule.h"
 #include "klee/Internal/Support/Debug.h"
+#include "klee/Internal/Support/ErrorHandling.h"
 
 #include "Executor.h"
 #include "MemoryManager.h"
diff --git a/lib/Core/StatsTracker.cpp b/lib/Core/StatsTracker.cpp
index cf8a1654..4633a5c5 100644
--- a/lib/Core/StatsTracker.cpp
+++ b/lib/Core/StatsTracker.cpp
@@ -7,8 +7,6 @@
 //
 //===----------------------------------------------------------------------===//
 
-#include "Common.h"
-
 #include "StatsTracker.h"
 
 #include "klee/ExecutionState.h"
@@ -19,6 +17,7 @@
 #include "klee/Internal/Module/KInstruction.h"
 #include "klee/Internal/Support/ModuleUtil.h"
 #include "klee/Internal/System/Time.h"
+#include "klee/Internal/Support/ErrorHandling.h"
 
 #include "CallPathManager.h"
 #include "CoreStats.h"
diff --git a/lib/Core/UserSearcher.cpp b/lib/Core/UserSearcher.cpp
index 72f3351f..fcda26f2 100644
--- a/lib/Core/UserSearcher.cpp
+++ b/lib/Core/UserSearcher.cpp
@@ -7,13 +7,12 @@
 //
 //===----------------------------------------------------------------------===//
 
-#include "Common.h"
-
 #include "UserSearcher.h"
 
 #include "Searcher.h"
 #include "Executor.h"
 
+#include "klee/Internal/Support/ErrorHandling.h"
 #include "llvm/Support/CommandLine.h"
 
 using namespace llvm;
diff --git a/lib/Module/KModule.cpp b/lib/Module/KModule.cpp
index 1334b58c..01165e94 100644
--- a/lib/Module/KModule.cpp
+++ b/lib/Module/KModule.cpp
@@ -7,11 +7,9 @@
 //
 //===----------------------------------------------------------------------===//
 
-// FIXME: This does not belong here.
-#include "../Core/Common.h"
-
 #define DEBUG_TYPE "KModule"
 #include "klee/Internal/Module/KModule.h"
+#include "klee/Internal/Support/ErrorHandling.h"
 
 #include "Passes.h"
 
diff --git a/lib/Module/ModuleUtil.cpp b/lib/Module/ModuleUtil.cpp
index 1cf9c35c..aabc0a57 100644
--- a/lib/Module/ModuleUtil.cpp
+++ b/lib/Module/ModuleUtil.cpp
@@ -11,9 +11,7 @@
 
 #include "klee/Config/Version.h"
 #include "klee/Internal/Support/Debug.h"
-
-// FIXME: This does not belong here.
-#include "../Core/Common.h"
+#include "klee/Internal/Support/ErrorHandling.h"
 #include "../Core/SpecialFunctionHandler.h"
 
 #if LLVM_VERSION_CODE >= LLVM_VERSION(3, 4)
diff --git a/lib/Solver/CexCachingSolver.cpp b/lib/Solver/CexCachingSolver.cpp
index d51c1695..8b626c04 100644
--- a/lib/Solver/CexCachingSolver.cpp
+++ b/lib/Solver/CexCachingSolver.cpp
@@ -20,6 +20,8 @@
 
 #include "SolverStats.h"
 
+#include "klee/Internal/Support/ErrorHandling.h"
+
 #include "llvm/Support/CommandLine.h"
 
 using namespace klee;
diff --git a/lib/Core/Common.cpp b/lib/Support/ErrorHandling.cpp
index c58e121a..7ca223e5 100644
--- a/lib/Core/Common.cpp
+++ b/lib/Support/ErrorHandling.cpp
@@ -1,4 +1,4 @@
-//===-- Common.cpp --------------------------------------------------------===//
+//===-- ErrorHandling.cpp -------------------------------------------------===//
 //
 //                     The KLEE Symbolic Virtual Machine
 //
@@ -7,7 +7,7 @@
 //
 //===----------------------------------------------------------------------===//
 
-#include "Common.h"
+#include "klee/Internal/Support/ErrorHandling.h"
 #include "llvm/ADT/StringRef.h"
 #include "llvm/Support/raw_ostream.h"
 
@@ -21,16 +21,16 @@
 
 using namespace klee;
 
-FILE* klee::klee_warning_file = NULL;
-FILE* klee::klee_message_file = NULL;
+FILE *klee::klee_warning_file = NULL;
+FILE *klee::klee_message_file = NULL;
 
-static const char* warningPrefix = "WARNING";
-static const char* warningOncePrefix = "WARNING ONCE";
-static const char* errorPrefix = "ERROR";
-static const char* notePrefix = "NOTE";
+static const char *warningPrefix = "WARNING";
+static const char *warningOncePrefix = "WARNING ONCE";
+static const char *errorPrefix = "ERROR";
+static const char *notePrefix = "NOTE";
 
-static bool shouldSetColor(const char* pfx, const char* msg, const char* prefixToSearchFor)
-{
+static bool shouldSetColor(const char *pfx, const char *msg,
+                           const char *prefixToSearchFor) {
   if (pfx && strcmp(pfx, prefixToSearchFor) == 0)
     return true;
 
@@ -45,7 +45,8 @@ static void klee_vfmessage(FILE *fp, const char *pfx, const char *msg,
   if (!fp)
     return;
 
-  llvm::raw_fd_ostream fdos(fileno(fp), /*shouldClose=*/false, /*unbuffered=*/ true);
+  llvm::raw_fd_ostream fdos(fileno(fp), /*shouldClose=*/false,
+                            /*unbuffered=*/true);
   bool modifyConsoleColor = fdos.is_displayed() && (fp == stderr);
 
   if (modifyConsoleColor) {
@@ -53,31 +54,31 @@ static void klee_vfmessage(FILE *fp, const char *pfx, const char *msg,
     // Warnings
     if (shouldSetColor(pfx, msg, warningPrefix))
       fdos.changeColor(llvm::raw_ostream::MAGENTA,
-                       /*bold=*/ false,
-                       /*bg=*/ false);
+                       /*bold=*/false,
+                       /*bg=*/false);
 
     // Once warning
     if (shouldSetColor(pfx, msg, warningOncePrefix))
       fdos.changeColor(llvm::raw_ostream::MAGENTA,
-                       /*bold=*/ true,
-                       /*bg=*/ false);
+                       /*bold=*/true,
+                       /*bg=*/false);
 
     // Errors
     if (shouldSetColor(pfx, msg, errorPrefix))
       fdos.changeColor(llvm::raw_ostream::RED,
-                       /*bold=*/ true,
-                       /*bg=*/ false);
+                       /*bold=*/true,
+                       /*bg=*/false);
 
     // Notes
     if (shouldSetColor(pfx, msg, notePrefix))
       fdos.changeColor(llvm::raw_ostream::WHITE,
-                       /*bold=*/ true,
-                       /*bg=*/ false);
-
+                       /*bold=*/true,
+                       /*bg=*/false);
   }
 
   fdos << "KLEE: ";
-  if (pfx) fdos << pfx << ": ";
+  if (pfx)
+    fdos << pfx << ": ";
 
   // FIXME: Can't use fdos here because we need to print
   // a variable number of arguments and do substitution
@@ -87,20 +88,20 @@ static void klee_vfmessage(FILE *fp, const char *pfx, const char *msg,
   fdos << "\n";
 
   if (modifyConsoleColor)
-      fdos.resetColor();
+    fdos.resetColor();
 
   fdos.flush();
 }
 
 /* Prints a message/warning.
-   
+
    If pfx is NULL, this is a regular message, and it's sent to
-   klee_message_file (messages.txt).  Otherwise, it is sent to 
+   klee_message_file (messages.txt).  Otherwise, it is sent to
    klee_warning_file (warnings.txt).
 
    Iff onlyToFile is false, the message is also printed on stderr.
 */
-static void klee_vmessage(const char *pfx, bool onlyToFile, const char *msg, 
+static void klee_vmessage(const char *pfx, bool onlyToFile, const char *msg,
                           va_list ap) {
   if (!onlyToFile) {
     va_list ap2;
@@ -112,7 +113,6 @@ static void klee_vmessage(const char *pfx, bool onlyToFile, const char *msg,
   klee_vfmessage(pfx ? klee_warning_file : klee_message_file, pfx, msg, ap);
 }
 
-
 void klee::klee_message(const char *msg, ...) {
   va_list ap;
   va_start(ap, msg);
@@ -143,23 +143,21 @@ void klee::klee_warning(const char *msg, ...) {
   va_end(ap);
 }
 
-
 /* Prints a warning once per message. */
 void klee::klee_warning_once(const void *id, const char *msg, ...) {
-  static std::set< std::pair<const void*, const char*> > keys;
-  std::pair<const void*, const char*> key;
-
+  static std::set<std::pair<const void *, const char *> > keys;
+  std::pair<const void *, const char *> key;
 
   /* "calling external" messages contain the actual arguments with
      which we called the external function, so we need to ignore them
      when computing the key. */
   if (strncmp(msg, "calling external", strlen("calling external")) != 0)
     key = std::make_pair(id, msg);
-  else key = std::make_pair(id, "calling external");
-  
+  else
+    key = std::make_pair(id, "calling external");
+
   if (!keys.count(key)) {
     keys.insert(key);
-    
     va_list ap;
     va_start(ap, msg);
     klee_vmessage(warningOncePrefix, false, msg, ap);
diff --git a/tools/klee/main.cpp b/tools/klee/main.cpp
index 0a292500..debbe7d2 100644
--- a/tools/klee/main.cpp
+++ b/tools/klee/main.cpp
@@ -1,8 +1,5 @@
 /* -*- mode: c++; c-basic-offset: 2; -*- */
 
-// FIXME: This does not belong here.
-#include "../lib/Core/Common.h"
-
 #include "klee/ExecutionState.h"
 #include "klee/Expr.h"
 #include "klee/Interpreter.h"
@@ -14,6 +11,7 @@
 #include "klee/Internal/Support/ModuleUtil.h"
 #include "klee/Internal/System/Time.h"
 #include "klee/Internal/Support/PrintVersion.h"
+#include "klee/Internal/Support/ErrorHandling.h"
 
 #if LLVM_VERSION_CODE > LLVM_VERSION(3, 2)
 #include "llvm/IR/Constants.h"