about summary refs log tree commit diff homepage
path: root/tools/kleaver
diff options
context:
space:
mode:
authorCristian Cadar <cristic@cs.stanford.edu>2011-04-23 19:22:22 +0000
committerCristian Cadar <cristic@cs.stanford.edu>2011-04-23 19:22:22 +0000
commit930ae7d06fc1d8cc3117397cb3fd168a0a1090b7 (patch)
treeac1ff2162b5ea6d51bbf6a1ac35f350a297234ac /tools/kleaver
parent2ec715a7e08724e54cd8c14904446d1b91b42121 (diff)
downloadklee-930ae7d06fc1d8cc3117397cb3fd168a0a1090b7.tar.gz
Patch by arrowdodger (http://keeda.stanford.edu/pipermail/klee-dev/2011-April/000617.html) for compiling KLEE with the latest LLVM changes. Tested against LLVM 2.7 and 2.8. The AsmAddresses test fails in 2.8 unless assertions are explicitely enabled (--enable-assertions).
git-svn-id: https://llvm.org/svn/llvm-project/klee/trunk@130065 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'tools/kleaver')
-rw-r--r--tools/kleaver/main.cpp42
1 files changed, 40 insertions, 2 deletions
diff --git a/tools/kleaver/main.cpp b/tools/kleaver/main.cpp
index c489612f..0581ea27 100644
--- a/tools/kleaver/main.cpp
+++ b/tools/kleaver/main.cpp
@@ -17,7 +17,20 @@
 #include "llvm/Support/ManagedStatic.h"
 #include "llvm/Support/MemoryBuffer.h"
 #include "llvm/Support/raw_ostream.h"
+
+// FIXME: Ugh, this is gross. But otherwise our config.h conflicts with LLVMs.
+#undef PACKAGE_BUGREPORT
+#undef PACKAGE_NAME
+#undef PACKAGE_STRING
+#undef PACKAGE_TARNAME
+#undef PACKAGE_VERSION
+
+#if (LLVM_VERSION_MAJOR == 2 && LLVM_VERSION_MINOR < 9)
 #include "llvm/System/Signals.h"
+#else
+#include "llvm/Support/Signals.h"
+#include "llvm/Support/system_error.h"
+#endif
 
 using namespace llvm;
 using namespace klee;
@@ -269,12 +282,22 @@ int main(int argc, char **argv) {
   llvm::cl::ParseCommandLineOptions(argc, argv);
 
   std::string ErrorStr;
+  
+#if (LLVM_VERSION_MAJOR == 2 && LLVM_VERSION_MINOR < 9)
   MemoryBuffer *MB = MemoryBuffer::getFileOrSTDIN(InputFile.c_str(), &ErrorStr);
   if (!MB) {
     std::cerr << argv[0] << ": error: " << ErrorStr << "\n";
     return 1;
   }
-
+#else
+  OwningPtr<MemoryBuffer> MB;
+  error_code ec=MemoryBuffer::getFileOrSTDIN(InputFile.c_str(), MB);
+  if (ec) {
+    std::cerr << argv[0] << ": error: " << ec.message() << "\n";
+    return 1;
+  }
+#endif
+  
   ExprBuilder *Builder = 0;
   switch (BuilderKind) {
   case DefaultBuilder:
@@ -293,23 +316,38 @@ int main(int argc, char **argv) {
 
   switch (ToolAction) {
   case PrintTokens:
+#if (LLVM_VERSION_MAJOR == 2 && LLVM_VERSION_MINOR < 9)
     PrintInputTokens(MB);
+#else
+    PrintInputTokens(MB.get());
+#endif
     break;
   case PrintAST:
+#if (LLVM_VERSION_MAJOR == 2 && LLVM_VERSION_MINOR < 9)
     success = PrintInputAST(InputFile=="-" ? "<stdin>" : InputFile.c_str(), MB,
                             Builder);
+#else
+    success = PrintInputAST(InputFile=="-" ? "<stdin>" : InputFile.c_str(), MB.get(),
+                            Builder);
+#endif
     break;
   case Evaluate:
+#if (LLVM_VERSION_MAJOR == 2 && LLVM_VERSION_MINOR < 9)
     success = EvaluateInputAST(InputFile=="-" ? "<stdin>" : InputFile.c_str(),
                                MB, Builder);
+#else
+    success = EvaluateInputAST(InputFile=="-" ? "<stdin>" : InputFile.c_str(),
+                               MB.get(), Builder);
+#endif
     break;
   default:
     std::cerr << argv[0] << ": error: Unknown program action!\n";
   }
 
   delete Builder;
+#if (LLVM_VERSION_MAJOR == 2 && LLVM_VERSION_MINOR < 9)
   delete MB;
-
+#endif
   llvm::llvm_shutdown();
   return success ? 0 : 1;
 }