From 930ae7d06fc1d8cc3117397cb3fd168a0a1090b7 Mon Sep 17 00:00:00 2001 From: Cristian Cadar Date: Sat, 23 Apr 2011 19:22:22 +0000 Subject: 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 --- tools/kleaver/main.cpp | 42 ++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 40 insertions(+), 2 deletions(-) (limited to 'tools/kleaver') 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 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=="-" ? "" : InputFile.c_str(), MB, Builder); +#else + success = PrintInputAST(InputFile=="-" ? "" : InputFile.c_str(), MB.get(), + Builder); +#endif break; case Evaluate: +#if (LLVM_VERSION_MAJOR == 2 && LLVM_VERSION_MINOR < 9) success = EvaluateInputAST(InputFile=="-" ? "" : InputFile.c_str(), MB, Builder); +#else + success = EvaluateInputAST(InputFile=="-" ? "" : 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; } -- cgit 1.4.1