[PATCH] D100159: Support: Allow mapped_file_region to be used in an Optional

Duncan P. N. Exon Smith via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Apr 8 18:52:29 PDT 2021


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

Update llvm::sys::fs::mapped_file_region to have a move constructor and
a move assignment operator, allowing it to be used with Optional. Also,
update FileOutputBuffer's OnDiskBuffer to take advantage of this,
avoiding an extra allocation from the unique_ptr.

A nice follow-up would be to make the mapped_file_region constructor
private and replace its use with a factory function, such as
mapped_file_region::create(), that returns an Expected (or ErrorOr). I
don't plan on doing that immediately, but I might swing back later.

No functionality change, besides the saved allocation in OnDiskBuffer.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D100159

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

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D100159.336291.patch
Type: text/x-patch
Size: 4733 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210409/f3b5c480/attachment.bin>


More information about the llvm-commits mailing list