mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-08-05 13:26:55 +00:00
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:
@@ -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,
|
||||
|
@@ -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,
|
||||
|
@@ -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;
|
||||
|
@@ -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 {
|
||||
|
@@ -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,
|
||||
|
@@ -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,
|
||||
|
@@ -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);
|
||||
|
@@ -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 *>
|
||||
|
@@ -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,
|
||||
|
Reference in New Issue
Block a user