diff options
author | Rafael Espindola <rafael.espindola@gmail.com> | 2014-06-23 22:00:37 +0000 |
---|---|---|
committer | Rafael Espindola <rafael.espindola@gmail.com> | 2014-06-23 22:00:37 +0000 |
commit | 6304e941082cc97240856ff602f4ae0dfcc08230 (patch) | |
tree | b41276453a57d065caf55cb342366b79ac81b11b /llvm/lib/Object/Object.cpp | |
parent | aed5c966849821b5368f0e742439bae579f42da3 (diff) | |
download | bcm5719-llvm-6304e941082cc97240856ff602f4ae0dfcc08230.tar.gz bcm5719-llvm-6304e941082cc97240856ff602f4ae0dfcc08230.zip |
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
Diffstat (limited to 'llvm/lib/Object/Object.cpp')
-rw-r--r-- | llvm/lib/Object/Object.cpp | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/llvm/lib/Object/Object.cpp b/llvm/lib/Object/Object.cpp index 7282f468b08..567d87f7a0e 100644 --- a/llvm/lib/Object/Object.cpp +++ b/llvm/lib/Object/Object.cpp @@ -59,7 +59,9 @@ wrap(const relocation_iterator *SI) { // ObjectFile creation LLVMObjectFileRef LLVMCreateObjectFile(LLVMMemoryBufferRef MemBuf) { - ErrorOr<ObjectFile*> ObjOrErr(ObjectFile::createObjectFile(unwrap(MemBuf))); + std::unique_ptr<MemoryBuffer> Buf(unwrap(MemBuf)); + ErrorOr<ObjectFile *> ObjOrErr(ObjectFile::createObjectFile(Buf)); + Buf.release(); ObjectFile *Obj = ObjOrErr ? ObjOrErr.get() : nullptr; return wrap(Obj); } |