summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Object/Binary.cpp
diff options
context:
space:
mode:
authorDavid Blaikie <dblaikie@gmail.com>2014-07-21 16:26:24 +0000
committerDavid Blaikie <dblaikie@gmail.com>2014-07-21 16:26:24 +0000
commit4b9ae52ac1b936cefa2a9ec4b9b7db6a103182ca (patch)
tree5d8f0dd9bc326a94134766f94b8789629448578a /llvm/lib/Object/Binary.cpp
parentdc01ca18966e91793d8e7ca14be6dfc12a662f38 (diff)
downloadbcm5719-llvm-4b9ae52ac1b936cefa2a9ec4b9b7db6a103182ca.tar.gz
bcm5719-llvm-4b9ae52ac1b936cefa2a9ec4b9b7db6a103182ca.zip
Correct the ownership passing semantics of object::createBinary and make them explicit in the type system.
createBinary documented that it destroyed the parameter in error cases, though by observation it does not. By passing the unique_ptr by value rather than lvalue reference, callers are now explicit about passing ownership and the function implements the documented contract. Remove the explicit documentation, since now the behavior cannot be anything other than what was documented, so it's redundant. Also drops a unique_ptr::release in llvm-nm that was always run on a null unique_ptr anyway. llvm-svn: 213557
Diffstat (limited to 'llvm/lib/Object/Binary.cpp')
-rw-r--r--llvm/lib/Object/Binary.cpp4
1 files changed, 2 insertions, 2 deletions
diff --git a/llvm/lib/Object/Binary.cpp b/llvm/lib/Object/Binary.cpp
index 9f6a68556f9..552d5db89c5 100644
--- a/llvm/lib/Object/Binary.cpp
+++ b/llvm/lib/Object/Binary.cpp
@@ -38,7 +38,7 @@ StringRef Binary::getFileName() const {
return Data->getBufferIdentifier();
}
-ErrorOr<Binary *> object::createBinary(std::unique_ptr<MemoryBuffer> &Buffer,
+ErrorOr<Binary *> object::createBinary(std::unique_ptr<MemoryBuffer> Buffer,
LLVMContext *Context) {
sys::fs::file_magic Type = sys::fs::identify_magic(Buffer->getBuffer());
@@ -79,5 +79,5 @@ ErrorOr<Binary *> object::createBinary(StringRef Path) {
MemoryBuffer::getFileOrSTDIN(Path);
if (std::error_code EC = FileOrErr.getError())
return EC;
- return createBinary(FileOrErr.get());
+ return createBinary(std::move(*FileOrErr));
}
OpenPOWER on IntegriCloud