Pass a std::unique_ptr& to the create??? methods is lib/Object.
This makes the buffer ownership on error conditions very natural. The buffer
is only moved out of the argument if an object is constructed that now
owns the buffer.
llvm-svn: 211546
diff --git a/llvm/lib/Object/Archive.cpp b/llvm/lib/Object/Archive.cpp
index cd89249..cdf987a 100644
--- a/llvm/lib/Object/Archive.cpp
+++ b/llvm/lib/Object/Archive.cpp
@@ -183,10 +183,7 @@
return EC;
std::unique_ptr<MemoryBuffer> Buff(BuffOrErr.get().release());
- ErrorOr<std::unique_ptr<Binary>> Ret = createBinary(Buff.get(), Context);
- if (!Ret.getError())
- Buff.release();
- return Ret;
+ return createBinary(Buff, Context);
}
ErrorOr<Archive*> Archive::create(MemoryBuffer *Source) {