[llvm] r214379 - A std::unique_ptr case I missed in the previous patch.
Rafael EspĂndola
rafael.espindola at gmail.com
Thu Jul 31 12:51:48 PDT 2014
On 31 July 2014 14:58, David Blaikie <dblaikie at gmail.com> wrote:
> On Wed, Jul 30, 2014 at 8:36 PM, Rafael Espindola
> <rafael.espindola at gmail.com> wrote:
>> Author: rafael
>> Date: Wed Jul 30 22:36:00 2014
>> New Revision: 214379
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=214379&view=rev
>> Log:
>> A std::unique_ptr case I missed in the previous patch.
>>
>> Modified:
>> llvm/trunk/include/llvm/Object/Archive.h
>> llvm/trunk/lib/Object/Archive.cpp
>> llvm/trunk/lib/Object/MachOUniversal.cpp
>>
>> Modified: llvm/trunk/include/llvm/Object/Archive.h
>> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Object/Archive.h?rev=214379&r1=214378&r2=214379&view=diff
>> ==============================================================================
>> --- llvm/trunk/include/llvm/Object/Archive.h (original)
>> +++ llvm/trunk/include/llvm/Object/Archive.h Wed Jul 30 22:36:00 2014
>> @@ -165,7 +165,8 @@ public:
>> };
>>
>> Archive(std::unique_ptr<MemoryBuffer> Source, std::error_code &EC);
>> - static ErrorOr<Archive *> create(std::unique_ptr<MemoryBuffer> Source);
>> + static ErrorOr<std::unique_ptr<Archive>>
>> + create(std::unique_ptr<MemoryBuffer> Source);
>>
>> enum Kind {
>> K_GNU,
>>
>> Modified: llvm/trunk/lib/Object/Archive.cpp
>> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Object/Archive.cpp?rev=214379&r1=214378&r2=214379&view=diff
>> ==============================================================================
>> --- llvm/trunk/lib/Object/Archive.cpp (original)
>> +++ llvm/trunk/lib/Object/Archive.cpp Wed Jul 30 22:36:00 2014
>> @@ -184,12 +184,13 @@ Archive::Child::getAsBinary(LLVMContext
>> return createBinary(std::move(*BuffOrErr), Context);
>> }
>>
>> -ErrorOr<Archive *> Archive::create(std::unique_ptr<MemoryBuffer> Source) {
>> +ErrorOr<std::unique_ptr<Archive>>
>> +Archive::create(std::unique_ptr<MemoryBuffer> Source) {
>> std::error_code EC;
>> std::unique_ptr<Archive> Ret(new Archive(std::move(Source), EC));
>> if (EC)
>> return EC;
>> - return Ret.release();
>> + return std::move(Ret);
>
> Unnecessary/pessimizing (disables NRVO) std::move here.
I don't think so. Just removing the std::move causes:
call to deleted constructor of
'std::unique_ptr<llvm::object::Archive,
std::default_delete<llvm::object::Archive> >'
return Ret;
A bigger refactoring would be to not have a Archive constructor that
can fail, but that is quite a bit more complex.
Cheers,
Rafael
More information about the llvm-commits
mailing list