From 1f659329b63aa1d1af2b2bfc8b174a8ccdaba2c0 Mon Sep 17 00:00:00 2001 From: Rafael Espindola Date: Mon, 23 Jun 2014 21:53:12 +0000 Subject: Make ObjectFile and BitcodeReader always own the MemoryBuffer. This allows us to just use a std::unique_ptr to store the pointer to the buffer. The flip side is that they have to support releasing the buffer back to the caller. Overall this looks like a more efficient and less brittle api. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@211542 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/Object/Binary.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'include/llvm/Object/Binary.h') 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 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. -- cgit v1.2.3