From 2e60ca964ccb6a8531559238b28658e1aa4b0d75 Mon Sep 17 00:00:00 2001 From: Rafael Espindola Date: Tue, 24 Jun 2014 13:56:32 +0000 Subject: Pass a unique_ptr 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 --- llvm/lib/Object/Binary.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'llvm/lib/Object/Binary.cpp') 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 Source) + : TypeID(Type), Data(std::move(Source)) {} StringRef Binary::getData() const { return Data->getBuffer(); @@ -44,7 +44,7 @@ ErrorOr object::createBinary(std::unique_ptr &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 object::createBinary(std::unique_ptr &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. -- cgit v1.2.3