unique_ptrify IRObjectFile::createIRObjectFile
authorDavid Blaikie <dblaikie@gmail.com>
Wed, 3 Sep 2014 17:59:23 +0000 (17:59 +0000)
committerDavid Blaikie <dblaikie@gmail.com>
Wed, 3 Sep 2014 17:59:23 +0000 (17:59 +0000)
I took a guess at the changes to the gold plugin, because that doesn't
seem to build by default for me. Not sure what dependencies I might be
missing for that.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@217056 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/Object/IRObjectFile.h
lib/Object/IRObjectFile.cpp
lib/Object/SymbolicFile.cpp
tools/gold/gold-plugin.cpp

index 60a85981b7f15ed8c4763d1c2d79b893baf5301c..2b6fa2c779fbbc1b79ea05be0906d1f23c7748b4 100644 (file)
@@ -49,8 +49,8 @@ public:
     return v->isIR();
   }
 
-  static ErrorOr<IRObjectFile *> createIRObjectFile(MemoryBufferRef Object,
-                                                    LLVMContext &Context);
+  static ErrorOr<std::unique_ptr<IRObjectFile>>
+  createIRObjectFile(MemoryBufferRef Object, LLVMContext &Context);
 };
 }
 }
index 0259b46c70c25a239a12858f86dc07febca5f33e..856f4c6c278ce6e69cb42fc8f2d2c26d7e9e4e25 100644 (file)
@@ -264,7 +264,7 @@ basic_symbol_iterator IRObjectFile::symbol_end_impl() const {
   return basic_symbol_iterator(BasicSymbolRef(Ret, this));
 }
 
-ErrorOr<IRObjectFile *>
+ErrorOr<std::unique_ptr<IRObjectFile>>
 llvm::object::IRObjectFile::createIRObjectFile(MemoryBufferRef Object,
                                                LLVMContext &Context) {
 
@@ -275,5 +275,5 @@ llvm::object::IRObjectFile::createIRObjectFile(MemoryBufferRef Object,
     return EC;
 
   std::unique_ptr<Module> M(MOrErr.get());
-  return new IRObjectFile(Object, std::move(M));
+  return llvm::make_unique<IRObjectFile>(Object, std::move(M));
 }
index 17624a307ec3378fa4fceb7a72e99e7c69cb5bba..f8dd4b33a393ec9e748da5ced8144957dec0d587 100644 (file)
@@ -33,8 +33,7 @@ ErrorOr<std::unique_ptr<SymbolicFile>> SymbolicFile::createSymbolicFile(
   switch (Type) {
   case sys::fs::file_magic::bitcode:
     if (Context)
-      return ErrorOr<std::unique_ptr<SymbolicFile>>(
-          IRObjectFile::createIRObjectFile(Object, *Context));
+      return IRObjectFile::createIRObjectFile(Object, *Context);
   // Fallthrough
   case sys::fs::file_magic::unknown:
   case sys::fs::file_magic::archive:
index bdbf0263dcaff3c046f36a752f3babaae3b11daf..f2eeb7e8c4f1476dad6a78a488cb2f3b04a9f7e5 100644 (file)
@@ -296,7 +296,7 @@ static ld_plugin_status claim_file_hook(const ld_plugin_input_file *file,
     BufferRef = Buffer->getMemBufferRef();
   }
 
-  ErrorOr<object::IRObjectFile *> ObjOrErr =
+  ErrorOr<std::unique_ptr<object::IRObjectFile>> ObjOrErr =
       object::IRObjectFile::createIRObjectFile(BufferRef, Context);
   std::error_code EC = ObjOrErr.getError();
   if (EC == BitcodeError::InvalidBitcodeSignature)
@@ -309,7 +309,7 @@ static ld_plugin_status claim_file_hook(const ld_plugin_input_file *file,
             EC.message().c_str());
     return LDPS_ERR;
   }
-  std::unique_ptr<object::IRObjectFile> Obj(ObjOrErr.get());
+  std::unique_ptr<object::IRObjectFile> Obj = std::move(*ObjOrErr);
 
   Modules.resize(Modules.size() + 1);
   claimed_file &cf = Modules.back();