diff options
Diffstat (limited to 'include/llvm/Object')
-rw-r--r-- | include/llvm/Object/Binary.h | 6 | ||||
-rw-r--r-- | include/llvm/Object/COFF.h | 3 | ||||
-rw-r--r-- | include/llvm/Object/ELFObjectFile.h | 8 | ||||
-rw-r--r-- | include/llvm/Object/IRObjectFile.h | 4 | ||||
-rw-r--r-- | include/llvm/Object/MachO.h | 2 | ||||
-rw-r--r-- | include/llvm/Object/ObjectFile.h | 14 | ||||
-rw-r--r-- | include/llvm/Object/SymbolicFile.h | 9 |
7 files changed, 18 insertions, 28 deletions
diff --git a/include/llvm/Object/Binary.h b/include/llvm/Object/Binary.h index 8ac84e78d4..a87a006450 100644 --- a/include/llvm/Object/Binary.h +++ b/include/llvm/Object/Binary.h @@ -32,12 +32,11 @@ private: Binary(const Binary &other) LLVM_DELETED_FUNCTION; unsigned int TypeID; - bool BufferOwned; protected: - MemoryBuffer *Data; + std::unique_ptr<MemoryBuffer> Data; - Binary(unsigned int Type, MemoryBuffer *Source, bool BufferOwned = true); + Binary(unsigned int Type, MemoryBuffer *Source); enum { ID_Archive, @@ -79,6 +78,7 @@ public: virtual ~Binary(); StringRef getData() const; + MemoryBuffer *releaseBuffer() { return Data.release(); } StringRef getFileName() const; // Cast methods. diff --git a/include/llvm/Object/COFF.h b/include/llvm/Object/COFF.h index f0f2793a92..1f45ab05db 100644 --- a/include/llvm/Object/COFF.h +++ b/include/llvm/Object/COFF.h @@ -420,8 +420,7 @@ protected: StringRef &Result) const override; public: - COFFObjectFile(MemoryBuffer *Object, std::error_code &EC, - bool BufferOwned = true); + COFFObjectFile(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; diff --git a/include/llvm/Object/ELFObjectFile.h b/include/llvm/Object/ELFObjectFile.h index 876206b38a..72f7216110 100644 --- a/include/llvm/Object/ELFObjectFile.h +++ b/include/llvm/Object/ELFObjectFile.h @@ -177,8 +177,7 @@ protected: bool isDyldELFObject; public: - ELFObjectFile(MemoryBuffer *Object, std::error_code &EC, - bool BufferOwned = true); + ELFObjectFile(MemoryBuffer *Object, std::error_code &EC); const Elf_Sym *getSymbol(DataRefImpl Symb) const; @@ -774,12 +773,11 @@ ELFObjectFile<ELFT>::getRela(DataRefImpl Rela) const { } template <class ELFT> -ELFObjectFile<ELFT>::ELFObjectFile(MemoryBuffer *Object, std::error_code &ec, - bool BufferOwned) +ELFObjectFile<ELFT>::ELFObjectFile(MemoryBuffer *Object, std::error_code &ec) : ObjectFile(getELFType(static_cast<endianness>(ELFT::TargetEndianness) == support::little, ELFT::Is64Bits), - Object, BufferOwned), + Object), EF(Object, ec) {} template <class ELFT> diff --git a/include/llvm/Object/IRObjectFile.h b/include/llvm/Object/IRObjectFile.h index c87fe1519a..97a75b763d 100644 --- a/include/llvm/Object/IRObjectFile.h +++ b/include/llvm/Object/IRObjectFile.h @@ -27,8 +27,8 @@ class IRObjectFile : public SymbolicFile { std::unique_ptr<Mangler> Mang; public: - IRObjectFile(MemoryBuffer *Object, std::error_code &EC, LLVMContext &Context, - bool BufferOwned); + IRObjectFile(MemoryBuffer *Object, std::error_code &EC, LLVMContext &Context); + ~IRObjectFile(); void moveSymbolNext(DataRefImpl &Symb) const override; std::error_code printSymbolName(raw_ostream &OS, DataRefImpl Symb) const override; diff --git a/include/llvm/Object/MachO.h b/include/llvm/Object/MachO.h index 6e1ab253ec..182815f49a 100644 --- a/include/llvm/Object/MachO.h +++ b/include/llvm/Object/MachO.h @@ -57,7 +57,7 @@ public: }; MachOObjectFile(MemoryBuffer *Object, bool IsLittleEndian, bool Is64Bits, - std::error_code &EC, bool BufferOwned = true); + std::error_code &EC); void moveSymbolNext(DataRefImpl &Symb) const override; std::error_code getSymbolName(DataRefImpl Symb, diff --git a/include/llvm/Object/ObjectFile.h b/include/llvm/Object/ObjectFile.h index 152bb7e10c..62c5b9b771 100644 --- a/include/llvm/Object/ObjectFile.h +++ b/include/llvm/Object/ObjectFile.h @@ -208,7 +208,7 @@ class ObjectFile : public SymbolicFile { ObjectFile(const ObjectFile &other) LLVM_DELETED_FUNCTION; protected: - ObjectFile(unsigned int Type, MemoryBuffer *Source, bool BufferOwned = true); + ObjectFile(unsigned int Type, MemoryBuffer *Source); const uint8_t *base() const { return reinterpret_cast<const uint8_t *>(Data->getBufferStart()); @@ -334,10 +334,9 @@ public: /// @brief Create ObjectFile from path. static ErrorOr<ObjectFile *> createObjectFile(StringRef ObjectPath); static ErrorOr<ObjectFile *> createObjectFile(MemoryBuffer *Object, - bool BufferOwned, sys::fs::file_magic Type); static ErrorOr<ObjectFile *> createObjectFile(MemoryBuffer *Object) { - return createObjectFile(Object, true, sys::fs::file_magic::unknown); + return createObjectFile(Object, sys::fs::file_magic::unknown); } @@ -346,12 +345,9 @@ public: } public: - static ErrorOr<ObjectFile *> createCOFFObjectFile(MemoryBuffer *Object, - bool BufferOwned = true); - static ErrorOr<ObjectFile *> createELFObjectFile(MemoryBuffer *Object, - bool BufferOwned = true); - static ErrorOr<ObjectFile *> createMachOObjectFile(MemoryBuffer *Object, - bool BufferOwned = true); + static ErrorOr<ObjectFile *> createCOFFObjectFile(MemoryBuffer *Object); + static ErrorOr<ObjectFile *> createELFObjectFile(MemoryBuffer *Object); + static ErrorOr<ObjectFile *> createMachOObjectFile(MemoryBuffer *Object); }; // Inline function definitions. diff --git a/include/llvm/Object/SymbolicFile.h b/include/llvm/Object/SymbolicFile.h index 40015ec9f6..5c2d956d69 100644 --- a/include/llvm/Object/SymbolicFile.h +++ b/include/llvm/Object/SymbolicFile.h @@ -115,7 +115,7 @@ const uint64_t UnknownAddressOrSize = ~0ULL; class SymbolicFile : public Binary { public: virtual ~SymbolicFile(); - SymbolicFile(unsigned int Type, MemoryBuffer *Source, bool BufferOwned); + SymbolicFile(unsigned int Type, MemoryBuffer *Source); // virtual interface. virtual void moveSymbolNext(DataRefImpl &Symb) const = 0; @@ -143,17 +143,14 @@ public: // construction aux. static ErrorOr<SymbolicFile *> createIRObjectFile(MemoryBuffer *Object, - LLVMContext &Context, - bool BufferOwned = true); + LLVMContext &Context); static ErrorOr<SymbolicFile *> createSymbolicFile(MemoryBuffer *Object, - bool BufferOwned, sys::fs::file_magic Type, LLVMContext *Context); static ErrorOr<SymbolicFile *> createSymbolicFile(MemoryBuffer *Object) { - return createSymbolicFile(Object, true, sys::fs::file_magic::unknown, - nullptr); + return createSymbolicFile(Object, sys::fs::file_magic::unknown, nullptr); } static ErrorOr<SymbolicFile *> createSymbolicFile(StringRef ObjectPath); |