diff options
author | Cristian Cadar <cristic@cs.stanford.edu> | 2011-04-23 19:22:22 +0000 |
---|---|---|
committer | Cristian Cadar <cristic@cs.stanford.edu> | 2011-04-23 19:22:22 +0000 |
commit | 930ae7d06fc1d8cc3117397cb3fd168a0a1090b7 (patch) | |
tree | ac1ff2162b5ea6d51bbf6a1ac35f350a297234ac /tools | |
parent | 2ec715a7e08724e54cd8c14904446d1b91b42121 (diff) | |
download | klee-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')
-rw-r--r-- | tools/kleaver/main.cpp | 42 | ||||
-rw-r--r-- | tools/klee/main.cpp | 24 |
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; |