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
This commit is contained in:
Rafael Espindola 2014-06-24 13:56:32 +00:00
parent e8b1f91afb
commit 2e60ca964c
21 changed files with 104 additions and 88 deletions

View File

@ -164,8 +164,8 @@ public:
}
};
Archive(MemoryBuffer *source, std::error_code &ec);
static ErrorOr<Archive *> create(MemoryBuffer *Source);
Archive(std::unique_ptr<MemoryBuffer> Source, std::error_code &EC);
static ErrorOr<Archive *> create(std::unique_ptr<MemoryBuffer> Source);
enum Kind {
K_GNU,

View File

@ -36,7 +36,7 @@ private:
protected:
std::unique_ptr<MemoryBuffer> Data;
Binary(unsigned int Type, MemoryBuffer *Source);
Binary(unsigned int Type, std::unique_ptr<MemoryBuffer> Source);
enum {
ID_Archive,

View File

@ -420,7 +420,7 @@ protected:
StringRef &Result) const override;
public:
COFFObjectFile(MemoryBuffer *Object, std::error_code &EC);
COFFObjectFile(std::unique_ptr<MemoryBuffer> Object, std::error_code &EC);
basic_symbol_iterator symbol_begin_impl() const override;
basic_symbol_iterator symbol_end_impl() const override;
library_iterator needed_library_begin() const override;

View File

@ -177,7 +177,7 @@ protected:
bool isDyldELFObject;
public:
ELFObjectFile(MemoryBuffer *Object, std::error_code &EC);
ELFObjectFile(std::unique_ptr<MemoryBuffer> Object, std::error_code &EC);
const Elf_Sym *getSymbol(DataRefImpl Symb) const;
@ -773,12 +773,13 @@ ELFObjectFile<ELFT>::getRela(DataRefImpl Rela) const {
}
template <class ELFT>
ELFObjectFile<ELFT>::ELFObjectFile(MemoryBuffer *Object, std::error_code &ec)
ELFObjectFile<ELFT>::ELFObjectFile(std::unique_ptr<MemoryBuffer> Object,
std::error_code &EC)
: ObjectFile(getELFType(static_cast<endianness>(ELFT::TargetEndianness) ==
support::little,
ELFT::Is64Bits),
Object),
EF(Object, ec) {}
std::move(Object)),
EF(Data.get(), EC) {}
template <class ELFT>
basic_symbol_iterator ELFObjectFile<ELFT>::symbol_begin_impl() const {

View File

@ -27,7 +27,8 @@ class IRObjectFile : public SymbolicFile {
std::unique_ptr<Mangler> Mang;
public:
IRObjectFile(MemoryBuffer *Object, std::error_code &EC, LLVMContext &Context);
IRObjectFile(std::unique_ptr<MemoryBuffer> Object, std::error_code &EC,
LLVMContext &Context);
~IRObjectFile();
void moveSymbolNext(DataRefImpl &Symb) const override;
std::error_code printSymbolName(raw_ostream &OS,

View File

@ -56,8 +56,8 @@ public:
MachO::load_command C; // The command itself.
};
MachOObjectFile(MemoryBuffer *Object, bool IsLittleEndian, bool Is64Bits,
std::error_code &EC);
MachOObjectFile(std::unique_ptr<MemoryBuffer> Object, bool IsLittleEndian,
bool Is64Bits, std::error_code &EC);
void moveSymbolNext(DataRefImpl &Symb) const override;
std::error_code getSymbolName(DataRefImpl Symb,

View File

@ -83,8 +83,10 @@ public:
}
};
MachOUniversalBinary(MemoryBuffer *Source, std::error_code &ec);
static ErrorOr<MachOUniversalBinary*> create(MemoryBuffer *Source);
MachOUniversalBinary(std::unique_ptr<MemoryBuffer> Source,
std::error_code &ec);
static ErrorOr<MachOUniversalBinary *>
create(std::unique_ptr<MemoryBuffer> Source);
object_iterator begin_objects() const {
return ObjectForArch(this, 0);

View File

@ -208,7 +208,7 @@ class ObjectFile : public SymbolicFile {
ObjectFile(const ObjectFile &other) LLVM_DELETED_FUNCTION;
protected:
ObjectFile(unsigned int Type, MemoryBuffer *Source);
ObjectFile(unsigned int Type, std::unique_ptr<MemoryBuffer> Source);
const uint8_t *base() const {
return reinterpret_cast<const uint8_t *>(Data->getBufferStart());
@ -347,7 +347,8 @@ public:
}
public:
static ErrorOr<ObjectFile *> createCOFFObjectFile(MemoryBuffer *Object);
static ErrorOr<ObjectFile *>
createCOFFObjectFile(std::unique_ptr<MemoryBuffer> Object);
static ErrorOr<ObjectFile *>
createELFObjectFile(std::unique_ptr<MemoryBuffer> &Object);
static ErrorOr<ObjectFile *>

View File

@ -115,7 +115,7 @@ const uint64_t UnknownAddressOrSize = ~0ULL;
class SymbolicFile : public Binary {
public:
virtual ~SymbolicFile();
SymbolicFile(unsigned int Type, MemoryBuffer *Source);
SymbolicFile(unsigned int Type, std::unique_ptr<MemoryBuffer> Source);
// virtual interface.
virtual void moveSymbolNext(DataRefImpl &Symb) const = 0;
@ -142,8 +142,9 @@ public:
}
// construction aux.
static ErrorOr<SymbolicFile *> createIRObjectFile(MemoryBuffer *Object,
LLVMContext &Context);
static ErrorOr<SymbolicFile *>
createIRObjectFile(std::unique_ptr<MemoryBuffer> Object,
LLVMContext &Context);
static ErrorOr<SymbolicFile *>
createSymbolicFile(std::unique_ptr<MemoryBuffer> &Object,

View File

@ -55,9 +55,9 @@ template <class ELFT> class DyldELFObject : public ELFObjectFile<ELFT> {
public:
DyldELFObject(std::unique_ptr<ObjectFile> UnderlyingFile,
MemoryBuffer *Wrapper, std::error_code &ec);
std::unique_ptr<MemoryBuffer> Wrapper, std::error_code &ec);
DyldELFObject(MemoryBuffer *Wrapper, std::error_code &ec);
DyldELFObject(std::unique_ptr<MemoryBuffer> Wrapper, std::error_code &ec);
void updateSectionAddress(const SectionRef &Sec, uint64_t Addr);
void updateSymbolAddress(const SymbolRef &Sym, uint64_t Addr);
@ -109,15 +109,17 @@ public:
// actual memory. Ultimately, the Binary parent class will take ownership of
// this MemoryBuffer object but not the underlying memory.
template <class ELFT>
DyldELFObject<ELFT>::DyldELFObject(MemoryBuffer *Wrapper, std::error_code &ec)
: ELFObjectFile<ELFT>(Wrapper, ec) {
DyldELFObject<ELFT>::DyldELFObject(std::unique_ptr<MemoryBuffer> Wrapper,
std::error_code &EC)
: ELFObjectFile<ELFT>(std::move(Wrapper), EC) {
this->isDyldELFObject = true;
}
template <class ELFT>
DyldELFObject<ELFT>::DyldELFObject(std::unique_ptr<ObjectFile> UnderlyingFile,
MemoryBuffer *Wrapper, std::error_code &ec)
: ELFObjectFile<ELFT>(Wrapper, ec),
std::unique_ptr<MemoryBuffer> Wrapper,
std::error_code &EC)
: ELFObjectFile<ELFT>(std::move(Wrapper), EC),
UnderlyingFile(std::move(UnderlyingFile)) {
this->isDyldELFObject = true;
}
@ -183,29 +185,29 @@ RuntimeDyldELF::createObjectImageFromFile(std::unique_ptr<object::ObjectFile> Ob
return nullptr;
std::error_code ec;
MemoryBuffer *Buffer =
MemoryBuffer::getMemBuffer(ObjFile->getData(), "", false);
std::unique_ptr<MemoryBuffer> Buffer(
MemoryBuffer::getMemBuffer(ObjFile->getData(), "", false));
if (ObjFile->getBytesInAddress() == 4 && ObjFile->isLittleEndian()) {
auto Obj =
llvm::make_unique<DyldELFObject<ELFType<support::little, 2, false>>>(
std::move(ObjFile), Buffer, ec);
std::move(ObjFile), std::move(Buffer), ec);
return new ELFObjectImage<ELFType<support::little, 2, false>>(
nullptr, std::move(Obj));
} else if (ObjFile->getBytesInAddress() == 4 && !ObjFile->isLittleEndian()) {
auto Obj =
llvm::make_unique<DyldELFObject<ELFType<support::big, 2, false>>>(
std::move(ObjFile), Buffer, ec);
std::move(ObjFile), std::move(Buffer), ec);
return new ELFObjectImage<ELFType<support::big, 2, false>>(nullptr, std::move(Obj));
} else if (ObjFile->getBytesInAddress() == 8 && !ObjFile->isLittleEndian()) {
auto Obj = llvm::make_unique<DyldELFObject<ELFType<support::big, 2, true>>>(
std::move(ObjFile), Buffer, ec);
std::move(ObjFile), std::move(Buffer), ec);
return new ELFObjectImage<ELFType<support::big, 2, true>>(nullptr,
std::move(Obj));
} else if (ObjFile->getBytesInAddress() == 8 && ObjFile->isLittleEndian()) {
auto Obj =
llvm::make_unique<DyldELFObject<ELFType<support::little, 2, true>>>(
std::move(ObjFile), Buffer, ec);
std::move(ObjFile), std::move(Buffer), ec);
return new ELFObjectImage<ELFType<support::little, 2, true>>(
nullptr, std::move(Obj));
} else
@ -220,29 +222,31 @@ ObjectImage *RuntimeDyldELF::createObjectImage(ObjectBuffer *Buffer) {
(uint8_t)Buffer->getBufferStart()[ELF::EI_DATA]);
std::error_code ec;
std::unique_ptr<MemoryBuffer> Buf(Buffer->getMemBuffer());
if (Ident.first == ELF::ELFCLASS32 && Ident.second == ELF::ELFDATA2LSB) {
auto Obj =
llvm::make_unique<DyldELFObject<ELFType<support::little, 4, false>>>(
Buffer->getMemBuffer(), ec);
std::move(Buf), ec);
return new ELFObjectImage<ELFType<support::little, 4, false>>(
Buffer, std::move(Obj));
} else if (Ident.first == ELF::ELFCLASS32 &&
Ident.second == ELF::ELFDATA2MSB) {
auto Obj =
llvm::make_unique<DyldELFObject<ELFType<support::big, 4, false>>>(
Buffer->getMemBuffer(), ec);
std::move(Buf), ec);
return new ELFObjectImage<ELFType<support::big, 4, false>>(Buffer,
std::move(Obj));
} else if (Ident.first == ELF::ELFCLASS64 &&
Ident.second == ELF::ELFDATA2MSB) {
auto Obj = llvm::make_unique<DyldELFObject<ELFType<support::big, 8, true>>>(
Buffer->getMemBuffer(), ec);
std::move(Buf), ec);
return new ELFObjectImage<ELFType<support::big, 8, true>>(Buffer, std::move(Obj));
} else if (Ident.first == ELF::ELFCLASS64 &&
Ident.second == ELF::ELFDATA2LSB) {
auto Obj =
llvm::make_unique<DyldELFObject<ELFType<support::little, 8, true>>>(
Buffer->getMemBuffer(), ec);
std::move(Buf), ec);
return new ELFObjectImage<ELFType<support::little, 8, true>>(Buffer, std::move(Obj));
} else
llvm_unreachable("Unexpected ELF format");

View File

@ -186,20 +186,19 @@ Archive::Child::getAsBinary(LLVMContext *Context) const {
return createBinary(Buff, Context);
}
ErrorOr<Archive*> Archive::create(MemoryBuffer *Source) {
ErrorOr<Archive *> Archive::create(std::unique_ptr<MemoryBuffer> Source) {
std::error_code EC;
std::unique_ptr<Archive> Ret(new Archive(Source, EC));
std::unique_ptr<Archive> Ret(new Archive(std::move(Source), EC));
if (EC)
return EC;
return Ret.release();
}
Archive::Archive(MemoryBuffer *source, std::error_code &ec)
: Binary(Binary::ID_Archive, source), SymbolTable(child_end()) {
Archive::Archive(std::unique_ptr<MemoryBuffer> Source, std::error_code &ec)
: Binary(Binary::ID_Archive, std::move(Source)), SymbolTable(child_end()) {
// Check for sufficient magic.
assert(source);
if (source->getBufferSize() < 8 ||
StringRef(source->getBufferStart(), 8) != Magic) {
if (Data->getBufferSize() < 8 ||
StringRef(Data->getBufferStart(), 8) != Magic) {
ec = object_error::invalid_file_type;
return;
}

View File

@ -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.

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();

View File

@ -34,7 +34,7 @@ ObjectFile::createELFObjectFile(std::unique_ptr<MemoryBuffer> &Obj) {
#endif
if (MaxAlignment >= 2)
R.reset(new ELFObjectFile<ELFType<support::little, 2, false>>(
Obj.release(), EC));
std::move(Obj), EC));
else
return object_error::parse_failed;
else if (Ident.first == ELF::ELFCLASS32 && Ident.second == ELF::ELFDATA2MSB)
@ -45,32 +45,32 @@ ObjectFile::createELFObjectFile(std::unique_ptr<MemoryBuffer> &Obj) {
else
#endif
if (MaxAlignment >= 2)
R.reset(new ELFObjectFile<ELFType<support::big, 2, false>>(Obj.release(),
R.reset(new ELFObjectFile<ELFType<support::big, 2, false>>(std::move(Obj),
EC));
else
return object_error::parse_failed;
else if (Ident.first == ELF::ELFCLASS64 && Ident.second == ELF::ELFDATA2MSB)
#if !LLVM_IS_UNALIGNED_ACCESS_FAST
if (MaxAlignment >= 8)
R.reset(
new ELFObjectFile<ELFType<support::big, 8, true>>(Obj.release(), EC));
R.reset(new ELFObjectFile<ELFType<support::big, 8, true>>(std::move(Obj),
EC));
else
#endif
if (MaxAlignment >= 2)
R.reset(
new ELFObjectFile<ELFType<support::big, 2, true>>(Obj.release(), EC));
R.reset(new ELFObjectFile<ELFType<support::big, 2, true>>(std::move(Obj),
EC));
else
return object_error::parse_failed;
else if (Ident.first == ELF::ELFCLASS64 && Ident.second == ELF::ELFDATA2LSB) {
#if !LLVM_IS_UNALIGNED_ACCESS_FAST
if (MaxAlignment >= 8)
R.reset(new ELFObjectFile<ELFType<support::little, 8, true>>(
Obj.release(), EC));
std::move(Obj), EC));
else
#endif
if (MaxAlignment >= 2)
R.reset(new ELFObjectFile<ELFType<support::little, 2, true>>(
Obj.release(), EC));
std::move(Obj), EC));
else
return object_error::parse_failed;
}

View File

@ -17,14 +17,15 @@
#include "llvm/IR/Mangler.h"
#include "llvm/IR/Module.h"
#include "llvm/Object/IRObjectFile.h"
#include "llvm/Support/MemoryBuffer.h"
#include "llvm/Support/raw_ostream.h"
using namespace llvm;
using namespace object;
IRObjectFile::IRObjectFile(MemoryBuffer *Object, std::error_code &EC,
LLVMContext &Context)
: SymbolicFile(Binary::ID_IR, Object) {
ErrorOr<Module *> MOrErr = getLazyBitcodeModule(Object, Context);
IRObjectFile::IRObjectFile(std::unique_ptr<MemoryBuffer> Object,
std::error_code &EC, LLVMContext &Context)
: SymbolicFile(Binary::ID_IR, std::move(Object)) {
ErrorOr<Module *> MOrErr = getLazyBitcodeModule(Data.get(), Context);
if ((EC = MOrErr.getError()))
return;
@ -153,11 +154,11 @@ basic_symbol_iterator IRObjectFile::symbol_end_impl() const {
return basic_symbol_iterator(BasicSymbolRef(Ret, this));
}
ErrorOr<SymbolicFile *>
llvm::object::SymbolicFile::createIRObjectFile(MemoryBuffer *Object,
LLVMContext &Context) {
ErrorOr<SymbolicFile *> llvm::object::SymbolicFile::createIRObjectFile(
std::unique_ptr<MemoryBuffer> Object, LLVMContext &Context) {
std::error_code EC;
std::unique_ptr<IRObjectFile> Ret(new IRObjectFile(Object, EC, Context));
std::unique_ptr<IRObjectFile> Ret(
new IRObjectFile(std::move(Object), EC, Context));
if (EC)
return EC;
return Ret.release();

View File

@ -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;

View File

@ -86,9 +86,9 @@ std::error_code MachOUniversalBinary::ObjectForArch::getAsArchive(
StringRef ParentData = Parent->getData();
StringRef ObjectData = ParentData.substr(Header.offset, Header.size);
std::string ObjectName = Parent->getFileName().str();
MemoryBuffer *ObjBuffer = MemoryBuffer::getMemBuffer(
ObjectData, ObjectName, false);
ErrorOr<Archive *> Obj = Archive::create(ObjBuffer);
std::unique_ptr<MemoryBuffer> ObjBuffer(
MemoryBuffer::getMemBuffer(ObjectData, ObjectName, false));
ErrorOr<Archive *> Obj = Archive::create(std::move(ObjBuffer));
if (std::error_code EC = Obj.getError())
return EC;
Result.reset(Obj.get());
@ -100,19 +100,20 @@ std::error_code MachOUniversalBinary::ObjectForArch::getAsArchive(
void MachOUniversalBinary::anchor() { }
ErrorOr<MachOUniversalBinary *>
MachOUniversalBinary::create(MemoryBuffer *Source) {
MachOUniversalBinary::create(std::unique_ptr<MemoryBuffer> Source) {
std::error_code EC;
std::unique_ptr<MachOUniversalBinary> Ret(
new MachOUniversalBinary(Source, EC));
new MachOUniversalBinary(std::move(Source), EC));
if (EC)
return EC;
return Ret.release();
}
MachOUniversalBinary::MachOUniversalBinary(MemoryBuffer *Source,
MachOUniversalBinary::MachOUniversalBinary(std::unique_ptr<MemoryBuffer> Source,
std::error_code &ec)
: Binary(Binary::ID_MachOUniversalBinary, Source), NumberOfObjects(0) {
if (Source->getBufferSize() < sizeof(MachO::fat_header)) {
: Binary(Binary::ID_MachOUniversalBinary, std::move(Source)),
NumberOfObjects(0) {
if (Data->getBufferSize() < sizeof(MachO::fat_header)) {
ec = object_error::invalid_file_type;
return;
}

View File

@ -23,8 +23,8 @@ using namespace object;
void ObjectFile::anchor() { }
ObjectFile::ObjectFile(unsigned int Type, MemoryBuffer *Source)
: SymbolicFile(Type, Source) {}
ObjectFile::ObjectFile(unsigned int Type, std::unique_ptr<MemoryBuffer> Source)
: SymbolicFile(Type, std::move(Source)) {}
std::error_code ObjectFile::printSymbolName(raw_ostream &OS,
DataRefImpl Symb) const {
@ -77,7 +77,7 @@ ObjectFile::createObjectFile(std::unique_ptr<MemoryBuffer> &Object,
case sys::fs::file_magic::coff_object:
case sys::fs::file_magic::coff_import_library:
case sys::fs::file_magic::pecoff_executable:
return createCOFFObjectFile(Object.release());
return createCOFFObjectFile(std::move(Object));
}
llvm_unreachable("Unexpected Object File Type");
}

View File

@ -19,8 +19,9 @@
using namespace llvm;
using namespace object;
SymbolicFile::SymbolicFile(unsigned int Type, MemoryBuffer *Source)
: Binary(Type, Source) {}
SymbolicFile::SymbolicFile(unsigned int Type,
std::unique_ptr<MemoryBuffer> Source)
: Binary(Type, std::move(Source)) {}
SymbolicFile::~SymbolicFile() {}
@ -34,7 +35,7 @@ SymbolicFile::createSymbolicFile(std::unique_ptr<MemoryBuffer> &Object,
switch (Type) {
case sys::fs::file_magic::bitcode:
if (Context)
return IRObjectFile::createIRObjectFile(Object.release(), *Context);
return IRObjectFile::createIRObjectFile(std::move(Object), *Context);
// Fallthrough
case sys::fs::file_magic::unknown:
case sys::fs::file_magic::archive:

View File

@ -545,7 +545,7 @@ int main(int argc, char **argv, char * const *envp) {
Err.print(argv[0], errs());
return 1;
}
object::Archive *Ar = new object::Archive(ArBuf.release(), ec);
object::Archive *Ar = new object::Archive(std::move(ArBuf), ec);
if (ec || !Ar) {
Err.print(argv[0], errs());
return 1;

View File

@ -938,7 +938,7 @@ static int performOperation(ArchiveOperation Operation) {
}
if (!EC) {
object::Archive Archive(Buf.release(), EC);
object::Archive Archive(std::move(Buf), EC);
if (EC) {
errs() << ToolName << ": error loading '" << ArchiveName