diff options
Diffstat (limited to 'tools/kleaver/main.cpp')
-rw-r--r-- | tools/kleaver/main.cpp | 42 |
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; } |