about summary refs log tree commit diff homepage
path: root/lib/Module/ModuleUtil.cpp
diff options
context:
space:
mode:
authorJiri Slaby <jirislaby@gmail.com>2017-02-22 15:57:55 +0100
committerMartinNowack <martin.nowack@gmail.com>2018-09-14 09:59:29 +0100
commitc27f225e79b82d3de4f70578cb80d0603fbff6f1 (patch)
tree2876832b7148c93bb6b835f8265382a9f56061ae /lib/Module/ModuleUtil.cpp
parentc97526d0fff13e098b284369e2fc40c256b268d5 (diff)
downloadklee-c27f225e79b82d3de4f70578cb80d0603fbff6f1.tar.gz
llvm: make KLEE compile against LLVM 3.9
Signed-off-by: Jiri Slaby <jirislaby@gmail.com>
Diffstat (limited to 'lib/Module/ModuleUtil.cpp')
-rw-r--r--lib/Module/ModuleUtil.cpp33
1 files changed, 30 insertions, 3 deletions
diff --git a/lib/Module/ModuleUtil.cpp b/lib/Module/ModuleUtil.cpp
index 5f9a12b7..79395da6 100644
--- a/lib/Module/ModuleUtil.cpp
+++ b/lib/Module/ModuleUtil.cpp
@@ -285,7 +285,11 @@ Function *klee::getDirectCallTarget(CallSite cs, bool moduleIsFullyLinked) {
     if (Function *f = dyn_cast<Function>(v)) {
       return f;
     } else if (llvm::GlobalAlias *ga = dyn_cast<GlobalAlias>(v)) {
+#if LLVM_VERSION_CODE >= LLVM_VERSION(3, 9)
+      if (moduleIsFullyLinked || !(ga->isInterposable())) {
+#else
       if (moduleIsFullyLinked || !(ga->mayBeOverridden())) {
+#endif
         v = ga->getAliasee();
       } else {
         v = NULL;
@@ -394,7 +398,13 @@ bool klee::loadFile(const std::string &fileName, LLVMContext &context,
   }
 
   if (magic == sys::fs::file_magic::archive) {
-#if LLVM_VERSION_CODE >= LLVM_VERSION(3, 6)
+#if LLVM_VERSION_CODE >= LLVM_VERSION(3, 9)
+    Expected<std::unique_ptr<object::Binary> > archOwner =
+      object::createBinary(Buffer, &context);
+    if (!archOwner)
+      ec = errorToErrorCode(archOwner.takeError());
+    llvm::object::Binary *arch = archOwner.get().get();
+#elif LLVM_VERSION_CODE >= LLVM_VERSION(3, 6)
     ErrorOr<std::unique_ptr<object::Binary>> archOwner =
         object::createBinary(Buffer, &context);
     ec = archOwner.getError();
@@ -415,7 +425,12 @@ bool klee::loadFile(const std::string &fileName, LLVMContext &context,
 
     if (auto archive = dyn_cast<object::Archive>(arch)) {
 // Load all bitcode files into memory
-#if LLVM_VERSION_CODE >= LLVM_VERSION(3, 5)
+#if LLVM_VERSION_CODE >= LLVM_VERSION(3, 9)
+      Error Err;
+      for (object::Archive::child_iterator AI = archive->child_begin(Err),
+                                           AE = archive->child_end();
+           AI != AE; ++AI)
+#elif LLVM_VERSION_CODE >= LLVM_VERSION(3, 5)
       for (object::Archive::child_iterator AI = archive->child_begin(),
                                            AE = archive->child_end();
            AI != AE; ++AI)
@@ -456,7 +471,12 @@ bool klee::loadFile(const std::string &fileName, LLVMContext &context,
           return false;
         }
 
-#if LLVM_VERSION_CODE >= LLVM_VERSION(3, 5)
+#if LLVM_VERSION_CODE >= LLVM_VERSION(3, 9)
+        Expected<std::unique_ptr<llvm::object::Binary> > child =
+            childOrErr->getAsBinary();
+        if (!child)
+          ec = errorToErrorCode(child.takeError());
+#elif LLVM_VERSION_CODE >= LLVM_VERSION(3, 5)
         ErrorOr<std::unique_ptr<llvm::object::Binary>> child =
             childOrErr->getAsBinary();
         ec = child.getError();
@@ -520,7 +540,14 @@ bool klee::loadFile(const std::string &fileName, LLVMContext &context,
           return false;
         }
       }
+#if LLVM_VERSION_CODE >= LLVM_VERSION(3, 9)
+      if (Err) {
+        errorMsg = "Cannot iterate over archive";
+        return false;
+      }
+#endif
     }
+
     return true;
   }
   if (magic.is_object()) {