[patch] Pass a MemoryBufferRef when we can avoid taking ownership

David Blaikie dblaikie at gmail.com
Tue Aug 26 11:30:27 PDT 2014

This patch essentially supercedes one I sent out for review a few
weeks ago? (that had to play games with ownership/unique_ptrs around
these functions due to the split ownership, etc) and takes the stance
of "construct a new shallow MemoryBuffer rather than lying to 'share'
unique ownership"?

Might be worth changing getLazyBitcodeModuleImpl to take a
unique_ptr<MemoryBuffer>&& before you commit this patch? (that way you
don't have to play games with get/release after the successful call)

On Tue, Aug 26, 2014 at 11:22 AM, Rafael EspĂ­ndola
<rafael.espindola at gmail.com> wrote:
> Hi David,
> The attached patch simplifies a few interfaces that don't need to take
> ownership of a buffer.
> For example, both parseAssembly and parseBitcodeFile will parse the
> entire buffer before returning. There is no need to take ownership.
> Using a MemoryBufferRef makes it obvious in the type signature that
> there is no ownership transfer.
> Cheers,
> Rafael

More information about the llvm-commits mailing list