diff options
author | Rafael Espindola <rafael.espindola@gmail.com> | 2014-06-24 13:56:32 +0000 |
---|---|---|
committer | Rafael Espindola <rafael.espindola@gmail.com> | 2014-06-24 13:56:32 +0000 |
commit | 2e60ca964ccb6a8531559238b28658e1aa4b0d75 (patch) | |
tree | 5842ce349e814931985e4734f521de90e0b90913 /llvm/lib/Object/Binary.cpp | |
parent | e8b1f91afb850bdfcd4770caeb6ff9897c33ccbe (diff) | |
download | bcm5719-llvm-2e60ca964ccb6a8531559238b28658e1aa4b0d75.tar.gz bcm5719-llvm-2e60ca964ccb6a8531559238b28658e1aa4b0d75.zip |
Pass a unique_ptr<MemoryBuffer> to the constructors in the Binary hierarchy.
Once the objects are constructed, they own the buffer. Passing a unique_ptr
makes that clear.
llvm-svn: 211595
Diffstat (limited to 'llvm/lib/Object/Binary.cpp')
-rw-r--r-- | llvm/lib/Object/Binary.cpp | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/llvm/lib/Object/Binary.cpp b/llvm/lib/Object/Binary.cpp index ee6f58cd750..8d79a96662f 100644 --- a/llvm/lib/Object/Binary.cpp +++ b/llvm/lib/Object/Binary.cpp @@ -27,8 +27,8 @@ using namespace object; Binary::~Binary() {} -Binary::Binary(unsigned int Type, MemoryBuffer *Source) - : TypeID(Type), Data(Source) {} +Binary::Binary(unsigned int Type, std::unique_ptr<MemoryBuffer> Source) + : TypeID(Type), Data(std::move(Source)) {} StringRef Binary::getData() const { return Data->getBuffer(); @@ -44,7 +44,7 @@ ErrorOr<Binary *> object::createBinary(std::unique_ptr<MemoryBuffer> &Buffer, switch (Type) { case sys::fs::file_magic::archive: - return Archive::create(Buffer.release()); + return Archive::create(std::move(Buffer)); case sys::fs::file_magic::elf_relocatable: case sys::fs::file_magic::elf_executable: case sys::fs::file_magic::elf_shared_object: @@ -65,7 +65,7 @@ ErrorOr<Binary *> object::createBinary(std::unique_ptr<MemoryBuffer> &Buffer, case sys::fs::file_magic::bitcode: return ObjectFile::createSymbolicFile(Buffer, Type, Context); case sys::fs::file_magic::macho_universal_binary: - return MachOUniversalBinary::create(Buffer.release()); + return MachOUniversalBinary::create(std::move(Buffer)); case sys::fs::file_magic::unknown: case sys::fs::file_magic::windows_resource: // Unrecognized object file format. |