[PATCH] D40291: [Support] Add WritableMemoryBuffer class

Rafael Avila de Espindola via llvm-commits llvm-commits at lists.llvm.org
Tue Nov 21 09:58:34 PST 2017


When should a MutableMemoryBuffer (or MemoryBuffer) be used instead of
mapped_file_region?

My original understanding was that mapped_file_region is for when the
user needs a real mmap (readwrite maping) or as a MemoryBuffer
implementation detail.

All other uses should use the MemoryBuffer indirection as it handles
small files, "volatile" files, etc.

But I see a few direct uses of mapped_file_region in the code
base. Assuming those uses are a mistake, this patch is probably fine.

> +ErrorOr<std::unique_ptr<WritableMemoryBuffer>>
> +WritableMemoryBuffer::getFile(const Twine &Filename, int64_t FileSize,
> +                              bool RequiresNullTerminator, bool IsVolatile) {

Do you need RequiresNullTerminator and IsVolatile for rw buffers? If not
I would suggest leaving those out first and seeing if anyone requests
them.

Cheers,
Rafael


More information about the llvm-commits mailing list