From 9ec4b635373ee45fb0ca0721d40347910452a4dd Mon Sep 17 00:00:00 2001 From: David Blaikie Date: Wed, 3 Sep 2014 17:59:23 +0000 Subject: [PATCH] unique_ptrify IRObjectFile::createIRObjectFile 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. llvm-svn: 217056 --- include/llvm/Object/IRObjectFile.h | 4 ++-- lib/Object/IRObjectFile.cpp | 4 ++-- lib/Object/SymbolicFile.cpp | 3 +-- tools/gold/gold-plugin.cpp | 4 ++-- 4 files changed, 7 insertions(+), 8 deletions(-) diff --git a/include/llvm/Object/IRObjectFile.h b/include/llvm/Object/IRObjectFile.h index 60a85981b7f..2b6fa2c779f 100644 --- a/include/llvm/Object/IRObjectFile.h +++ b/include/llvm/Object/IRObjectFile.h @@ -49,8 +49,8 @@ public: return v->isIR(); } - static ErrorOr createIRObjectFile(MemoryBufferRef Object, - LLVMContext &Context); + static ErrorOr> + createIRObjectFile(MemoryBufferRef Object, LLVMContext &Context); }; } } diff --git a/lib/Object/IRObjectFile.cpp b/lib/Object/IRObjectFile.cpp index 0259b46c70c..856f4c6c278 100644 --- a/lib/Object/IRObjectFile.cpp +++ b/lib/Object/IRObjectFile.cpp @@ -264,7 +264,7 @@ basic_symbol_iterator IRObjectFile::symbol_end_impl() const { return basic_symbol_iterator(BasicSymbolRef(Ret, this)); } -ErrorOr +ErrorOr> llvm::object::IRObjectFile::createIRObjectFile(MemoryBufferRef Object, LLVMContext &Context) { @@ -275,5 +275,5 @@ llvm::object::IRObjectFile::createIRObjectFile(MemoryBufferRef Object, return EC; std::unique_ptr M(MOrErr.get()); - return new IRObjectFile(Object, std::move(M)); + return llvm::make_unique(Object, std::move(M)); } diff --git a/lib/Object/SymbolicFile.cpp b/lib/Object/SymbolicFile.cpp index 17624a307ec..f8dd4b33a39 100644 --- a/lib/Object/SymbolicFile.cpp +++ b/lib/Object/SymbolicFile.cpp @@ -33,8 +33,7 @@ ErrorOr> SymbolicFile::createSymbolicFile( switch (Type) { case sys::fs::file_magic::bitcode: if (Context) - return ErrorOr>( - IRObjectFile::createIRObjectFile(Object, *Context)); + return IRObjectFile::createIRObjectFile(Object, *Context); // Fallthrough case sys::fs::file_magic::unknown: case sys::fs::file_magic::archive: diff --git a/tools/gold/gold-plugin.cpp b/tools/gold/gold-plugin.cpp index bdbf0263dca..f2eeb7e8c4f 100644 --- a/tools/gold/gold-plugin.cpp +++ b/tools/gold/gold-plugin.cpp @@ -296,7 +296,7 @@ static ld_plugin_status claim_file_hook(const ld_plugin_input_file *file, BufferRef = Buffer->getMemBufferRef(); } - ErrorOr ObjOrErr = + ErrorOr> 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 Obj(ObjOrErr.get()); + std::unique_ptr Obj = std::move(*ObjOrErr); Modules.resize(Modules.size() + 1); claimed_file &cf = Modules.back();