From 1c9b9823da0797e5e9a2942c4efc3c63edfbbbba Mon Sep 17 00:00:00 2001 From: Rafael Espindola Date: Thu, 31 Jul 2014 03:36:00 +0000 Subject: [PATCH] A std::unique_ptr case I missed in the previous patch. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@214379 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/Object/Archive.h | 3 ++- lib/Object/Archive.cpp | 5 +++-- lib/Object/MachOUniversal.cpp | 5 +++-- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/include/llvm/Object/Archive.h b/include/llvm/Object/Archive.h index af6c995c1d0..d6f9ab06549 100644 --- a/include/llvm/Object/Archive.h +++ b/include/llvm/Object/Archive.h @@ -165,7 +165,8 @@ public: }; Archive(std::unique_ptr Source, std::error_code &EC); - static ErrorOr create(std::unique_ptr Source); + static ErrorOr> + create(std::unique_ptr Source); enum Kind { K_GNU, diff --git a/lib/Object/Archive.cpp b/lib/Object/Archive.cpp index e32bdd5c5be..45156f1311e 100644 --- a/lib/Object/Archive.cpp +++ b/lib/Object/Archive.cpp @@ -184,12 +184,13 @@ Archive::Child::getAsBinary(LLVMContext *Context) const { return createBinary(std::move(*BuffOrErr), Context); } -ErrorOr Archive::create(std::unique_ptr Source) { +ErrorOr> +Archive::create(std::unique_ptr Source) { std::error_code EC; std::unique_ptr Ret(new Archive(std::move(Source), EC)); if (EC) return EC; - return Ret.release(); + return std::move(Ret); } Archive::Archive(std::unique_ptr Source, std::error_code &ec) diff --git a/lib/Object/MachOUniversal.cpp b/lib/Object/MachOUniversal.cpp index 4ba5d968649..ece652b4c09 100644 --- a/lib/Object/MachOUniversal.cpp +++ b/lib/Object/MachOUniversal.cpp @@ -88,10 +88,11 @@ std::error_code MachOUniversalBinary::ObjectForArch::getAsArchive( std::string ObjectName = Parent->getFileName().str(); std::unique_ptr ObjBuffer( MemoryBuffer::getMemBuffer(ObjectData, ObjectName, false)); - ErrorOr Obj = Archive::create(std::move(ObjBuffer)); + ErrorOr> Obj = + Archive::create(std::move(ObjBuffer)); if (std::error_code EC = Obj.getError()) return EC; - Result.reset(Obj.get()); + Result = std::move(Obj.get()); return object_error::success; } return object_error::parse_failed; -- 2.34.1