about summary refs log tree commit diff homepage
path: root/tools
diff options
context:
space:
mode:
Diffstat (limited to 'tools')
-rw-r--r--tools/kleaver/main.cpp42
-rw-r--r--tools/klee/main.cpp24
2 files changed, 61 insertions, 5 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;
 }
diff --git a/tools/klee/main.cpp b/tools/klee/main.cpp
index c3188259..e37eb00a 100644
--- a/tools/klee/main.cpp
+++ b/tools/klee/main.cpp
@@ -37,7 +37,12 @@
 #undef PACKAGE_TARNAME
 #undef PACKAGE_VERSION
 #include "llvm/Target/TargetSelect.h"
+#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
 #include <iostream>
 #include <fstream>
 #include <cerrno>
@@ -1157,14 +1162,25 @@ int main(int argc, char **argv, char **envp) {
   Module *mainModule = MP->materializeModule();
   MP->releaseModule();
   delete MP;
-#else
+#endif
   std::string ErrorMsg;
   Module *mainModule = 0;
+#if (LLVM_VERSION_MAJOR == 2 && LLVM_VERSION_MINOR < 9)
   MemoryBuffer *Buffer = MemoryBuffer::getFileOrSTDIN(InputFile, &ErrorMsg);
   if (Buffer) {
     mainModule = getLazyBitcodeModule(Buffer, getGlobalContext(), &ErrorMsg);
     if (!mainModule) delete Buffer;
   }
+#else
+  OwningPtr<MemoryBuffer> BufferPtr;
+  error_code ec=MemoryBuffer::getFileOrSTDIN(InputFile.c_str(), BufferPtr);
+  if (ec) {
+    klee_error("error loading program '%s': %s", InputFile.c_str(),
+               ec.message().c_str());
+  }
+  mainModule = getLazyBitcodeModule(BufferPtr.get(), getGlobalContext(), &ErrorMsg);
+
+#endif
   if (mainModule) {
     if (mainModule->MaterializeAllPermanently(&ErrorMsg)) {
       delete mainModule;
@@ -1174,8 +1190,7 @@ int main(int argc, char **argv, char **envp) {
   if (!mainModule)
     klee_error("error loading program '%s': %s", InputFile.c_str(),
                ErrorMsg.c_str());
-#endif
-  
+
   if (WithPOSIXRuntime)
     InitEnv = true;
 
@@ -1449,6 +1464,9 @@ int main(int argc, char **argv, char **envp) {
   std::cerr << stats.str();
   handler->getInfoStream() << stats.str();
 
+#if !(LLVM_VERSION_MAJOR == 2 && LLVM_VERSION_MINOR < 9)
+  BufferPtr.take();
+#endif
   delete handler;
 
   return 0;