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/MachOObjectFile.cpp | |
parent | e8b1f91afb850bdfcd4770caeb6ff9897c33ccbe (diff) | |
download | llvm-2e60ca964ccb6a8531559238b28658e1aa4b0d75.zip llvm-2e60ca964ccb6a8531559238b28658e1aa4b0d75.tar.gz llvm-2e60ca964ccb6a8531559238b28658e1aa4b0d75.tar.bz2 |
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/MachOObjectFile.cpp')
-rw-r--r-- | llvm/lib/Object/MachOObjectFile.cpp | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/llvm/lib/Object/MachOObjectFile.cpp b/llvm/lib/Object/MachOObjectFile.cpp index 45fc5ea..09c842c 100644 --- a/llvm/lib/Object/MachOObjectFile.cpp +++ b/llvm/lib/Object/MachOObjectFile.cpp @@ -422,9 +422,10 @@ static uint32_t getSectionFlags(const MachOObjectFile *O, return Sect.flags; } -MachOObjectFile::MachOObjectFile(MemoryBuffer *Object, bool IsLittleEndian, - bool Is64bits, std::error_code &EC) - : ObjectFile(getMachOType(IsLittleEndian, Is64bits), Object), +MachOObjectFile::MachOObjectFile(std::unique_ptr<MemoryBuffer> Object, + bool IsLittleEndian, bool Is64bits, + std::error_code &EC) + : ObjectFile(getMachOType(IsLittleEndian, Is64bits), std::move(Object)), SymtabLoadCmd(nullptr), DysymtabLoadCmd(nullptr), DataInCodeLoadCmd(nullptr) { uint32_t LoadCommandCount = this->getHeader().ncmds; @@ -1817,13 +1818,13 @@ ObjectFile::createMachOObjectFile(std::unique_ptr<MemoryBuffer> &Buffer) { std::error_code EC; std::unique_ptr<MachOObjectFile> Ret; if (Magic == "\xFE\xED\xFA\xCE") - Ret.reset(new MachOObjectFile(Buffer.release(), false, false, EC)); + Ret.reset(new MachOObjectFile(std::move(Buffer), false, false, EC)); else if (Magic == "\xCE\xFA\xED\xFE") - Ret.reset(new MachOObjectFile(Buffer.release(), true, false, EC)); + Ret.reset(new MachOObjectFile(std::move(Buffer), true, false, EC)); else if (Magic == "\xFE\xED\xFA\xCF") - Ret.reset(new MachOObjectFile(Buffer.release(), false, true, EC)); + Ret.reset(new MachOObjectFile(std::move(Buffer), false, true, EC)); else if (Magic == "\xCF\xFA\xED\xFE") - Ret.reset(new MachOObjectFile(Buffer.release(), true, true, EC)); + Ret.reset(new MachOObjectFile(std::move(Buffer), true, true, EC)); else return object_error::parse_failed; |