[PATCH] D115397: Support: Extract sys::fs::readNativeFileToEOF() from MemoryBuffer

Duncan P. N. Exon Smith via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Dec 8 13:48:48 PST 2021


dexonsmith created this revision.
dexonsmith added a reviewer: dblaikie.
Herald added a subscriber: hiraditya.
dexonsmith requested review of this revision.
Herald added a project: LLVM.

Extract the `readNativeFile()` loop from
`MemoryBuffer::getMemoryBufferForStream()` into `readNativeFileToEOF()`
to allow reuse. The chunk size is configurable; the default of `4*4096`
is exposed as `sys::fs::DefaultReadChunkSize` to allow sizing of
SmallVectors.

There's somewhere I'd like to read a usually small file without overhead of a MemoryBuffer; extracting existing logic rather than duplicating it.

Test depends on https://reviews.llvm.org/D115395 (built on top of https://reviews.llvm.org/D115384, but they could be reordered...).


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D115397

Files:
  llvm/include/llvm/Support/FileSystem.h
  llvm/lib/Support/MemoryBuffer.cpp
  llvm/lib/Support/Path.cpp
  llvm/unittests/Support/Path.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D115397.392923.patch
Type: text/x-patch
Size: 5910 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20211208/1b0bfc50/attachment.bin>


More information about the llvm-commits mailing list