about summary refs log tree commit diff homepage
diff options
context:
space:
mode:
authorDaniel Dunbar <daniel@zuster.org>2009-10-25 00:08:19 +0000
committerDaniel Dunbar <daniel@zuster.org>2009-10-25 00:08:19 +0000
commit3264dcd97024250729183ed6398c5d8a9aa7472d (patch)
tree46a8db8e8a76f88ecfaac68981d33797134a8b97
parentfa2455723d00587c4478ac876cf5a824d5394cc5 (diff)
downloadklee-3264dcd97024250729183ed6398c5d8a9aa7472d.tar.gz
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
-rw-r--r--lib/Module/InstructionInfoTable.cpp1
-rw-r--r--lib/Module/KModule.cpp36
-rw-r--r--tools/klee/main.cpp4
3 files changed, 40 insertions, 1 deletions
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 <map>
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;
   }
 
diff --git a/tools/klee/main.cpp b/tools/klee/main.cpp
index 2c418fc8..8b788b9d 100644
--- a/tools/klee/main.cpp
+++ b/tools/klee/main.cpp
@@ -523,7 +523,11 @@ void KleeHandler::getOutFiles(std::string path,
   }
   for (std::set<llvm::sys::Path>::iterator it = contents.begin(),
          ie = contents.end(); it != ie; ++it) {
+#if (LLVM_VERSION_MAJOR == 2 && LLVM_VERSION_MINOR == 6)
+    std::string f = it->toString();
+#else
     std::string f = it->str();
+#endif
     if (f.substr(f.size()-6,f.size()) == ".ktest") {
       results.push_back(f);
     }