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.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@211595 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Rafael Espindola
2014-06-24 13:56:32 +00:00
parent d3aaad2d26
commit 0d50598d71
21 changed files with 104 additions and 88 deletions

View File

@ -511,8 +511,9 @@ std::error_code COFFObjectFile::initExportTablePtr() {
return object_error::success;
}
COFFObjectFile::COFFObjectFile(MemoryBuffer *Object, std::error_code &EC)
: ObjectFile(Binary::ID_COFF, Object), COFFHeader(nullptr),
COFFObjectFile::COFFObjectFile(std::unique_ptr<MemoryBuffer> Object,
std::error_code &EC)
: ObjectFile(Binary::ID_COFF, std::move(Object)), COFFHeader(nullptr),
PE32Header(nullptr), PE32PlusHeader(nullptr), DataDirectory(nullptr),
SectionTable(nullptr), SymbolTable(nullptr), StringTable(nullptr),
StringTableSize(0), ImportDirectory(nullptr), NumberOfImportDirectory(0),
@ -1111,9 +1112,11 @@ ExportDirectoryEntryRef::getSymbolName(StringRef &Result) const {
return object_error::success;
}
ErrorOr<ObjectFile *> ObjectFile::createCOFFObjectFile(MemoryBuffer *Object) {
ErrorOr<ObjectFile *>
ObjectFile::createCOFFObjectFile(std::unique_ptr<MemoryBuffer> Object) {
std::error_code EC;
std::unique_ptr<COFFObjectFile> Ret(new COFFObjectFile(Object, EC));
std::unique_ptr<COFFObjectFile> Ret(
new COFFObjectFile(std::move(Object), EC));
if (EC)
return EC;
return Ret.release();