about summary refs log tree commit diff homepage
path: root/lib/Module/ModuleUtil.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'lib/Module/ModuleUtil.cpp')
-rw-r--r--lib/Module/ModuleUtil.cpp30
1 files changed, 26 insertions, 4 deletions
diff --git a/lib/Module/ModuleUtil.cpp b/lib/Module/ModuleUtil.cpp
index a86adc98..b07d3d2f 100644
--- a/lib/Module/ModuleUtil.cpp
+++ b/lib/Module/ModuleUtil.cpp
@@ -258,13 +258,21 @@ static bool linkBCA(object::Archive* archive, Module* composite, std::string& er
         Module *Result = 0;
         // FIXME: Maybe load bitcode file lazily? Then if we need to link, materialise the module
 #if LLVM_VERSION_CODE >= LLVM_VERSION(3, 5)
-        ErrorOr<Module *> resultErr = parseBitcodeFile(buff.get(),
-	    composite->getContext());
+#if LLVM_VERSION_CODE >= LLVM_VERSION(3, 7)
+        ErrorOr<std::unique_ptr<Module> > resultErr =
+#else
+        ErrorOr<Module *> resultErr =
+#endif
+	    parseBitcodeFile(buff.get(), composite->getContext());
         ec = resultErr.getError();
         if (ec)
           errorMessage = ec.message();
         else
+#if LLVM_VERSION_CODE >= LLVM_VERSION(3, 7)
+          Result = resultErr->release();
+#else
           Result = resultErr.get();
+#endif
 #else
         Result = ParseBitcodeFile(buff.get(), composite->getContext(),
 	    &errorMessage);
@@ -421,7 +429,12 @@ Module *klee::linkWithLibrary(Module *module,
   if (magic == sys::fs::file_magic::bitcode) {
     Module *Result = 0;
 #if LLVM_VERSION_CODE >= LLVM_VERSION(3, 5)
-    ErrorOr<Module *> ResultErr = parseBitcodeFile(Buffer, Context);
+#if LLVM_VERSION_CODE >= LLVM_VERSION(3, 7)
+    ErrorOr<std::unique_ptr<Module> > ResultErr =
+#else
+    ErrorOr<Module *> ResultErr =
+#endif
+	parseBitcodeFile(Buffer, Context);
     if ((ec = ResultErr.getError())) {
       ErrorMessage = ec.message();
 #else
@@ -432,7 +445,9 @@ Module *klee::linkWithLibrary(Module *module,
           ErrorMessage.c_str());
     }
 
-#if LLVM_VERSION_CODE >= LLVM_VERSION(3, 5)
+#if LLVM_VERSION_CODE >= LLVM_VERSION(3, 7)
+    Result = ResultErr->release();
+#elif LLVM_VERSION_CODE >= LLVM_VERSION(3, 5)
     Result = ResultErr.get();
 #endif
 
@@ -446,7 +461,10 @@ Module *klee::linkWithLibrary(Module *module,
           ErrorMessage.c_str());
     }
 
+// unique_ptr owns the Module, we don't have to delete it
+#if LLVM_VERSION_CODE < LLVM_VERSION(3, 7)
     delete Result;
+#endif
 
   } else if (magic == sys::fs::file_magic::archive) {
 #if LLVM_VERSION_CODE >= LLVM_VERSION(3, 6)
@@ -615,7 +633,11 @@ Module *klee::loadModule(LLVMContext &ctx, const std::string &path, std::string
   // The module has taken ownership of the MemoryBuffer so release it
   // from the std::unique_ptr
   buffer->release();
+#if LLVM_VERSION_CODE >= LLVM_VERSION(3, 7)
+  auto module = errorOrModule->release();
+#else
   auto module = *errorOrModule;
+#endif
 
   if (auto ec = module->materializeAllPermanently()) {
     errorMsg = ec.message();