From 3264dcd97024250729183ed6398c5d8a9aa7472d Mon Sep 17 00:00:00 2001 From: Daniel Dunbar Date: Sun, 25 Oct 2009 00:08:19 +0000 Subject: Update source to build against LLVM 2.6 git-svn-id: https://llvm.org/svn/llvm-project/klee/trunk@85024 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Module/InstructionInfoTable.cpp | 1 - lib/Module/KModule.cpp | 36 ++++++++++++++++++++++++++++++++++++ 2 files changed, 36 insertions(+), 1 deletion(-) (limited to 'lib/Module') diff --git a/lib/Module/InstructionInfoTable.cpp b/lib/Module/InstructionInfoTable.cpp index 7573f51c..196d9dc7 100644 --- a/lib/Module/InstructionInfoTable.cpp +++ b/lib/Module/InstructionInfoTable.cpp @@ -18,7 +18,6 @@ #include "llvm/Support/CFG.h" #include "llvm/Support/InstIterator.h" #include "llvm/Support/raw_ostream.h" -#include "llvm/Support/raw_os_ostream.h" #include "llvm/Analysis/ValueTracking.h" #include diff --git a/lib/Module/KModule.cpp b/lib/Module/KModule.cpp index c880cba3..108adabd 100644 --- a/lib/Module/KModule.cpp +++ b/lib/Module/KModule.cpp @@ -27,7 +27,9 @@ #include "llvm/ValueSymbolTable.h" #include "llvm/Support/CommandLine.h" #include "llvm/Support/raw_ostream.h" +#if (LLVM_VERSION_MAJOR == 2 && LLVM_VERSION_MINOR == 6) #include "llvm/Support/raw_os_ostream.h" +#endif #include "llvm/System/Path.h" #include "llvm/Target/TargetData.h" #include "llvm/Transforms/Scalar.h" @@ -327,6 +329,38 @@ void KModule::prepare(const Interpreter::ModuleOptions &opts, std::ostream *os = ih->openOutputFile("assembly.ll"); assert(os && os->good() && "unable to open source output"); +#if (LLVM_VERSION_MAJOR == 2 && LLVM_VERSION_MINOR == 6) + // We have an option for this in case the user wants a .ll they + // can compile. + if (NoTruncateSourceLines) { + os << *module; + } else { + bool truncated = false; + std::string string; + llvm::raw_string_ostream rss(string); + rss << *module; + rss.flush(); + const char *position = string.c_str(); + + for (;;) { + const char *end = index(position, '\n'); + if (!end) { + os << position; + break; + } else { + unsigned count = (end - position) + 1; + if (count<255) { + os->write(position, count); + } else { + os->write(position, 254); + os << "\n"; + truncated = true; + } + position = end+1; + } + } + } +#else llvm::raw_os_ostream *ros = new llvm::raw_os_ostream(*os); // We have an option for this in case the user wants a .ll they @@ -360,6 +394,8 @@ void KModule::prepare(const Interpreter::ModuleOptions &opts, } } delete ros; +#endif + delete os; } -- cgit 1.4.1