[all-commits] [llvm/llvm-project] 0db648: Support: Add move semantics to mapped_file_region

Duncan P. N. Exon Smith via All-commits all-commits at lists.llvm.org
Fri Apr 9 18:00:30 PDT 2021


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 0db6488a7704a322ae05f20ef3466bed3eb1bb98
      https://github.com/llvm/llvm-project/commit/0db6488a7704a322ae05f20ef3466bed3eb1bb98
  Author: Duncan P. N. Exon Smith <dexonsmith at apple.com>
  Date:   2021-04-09 (Fri, 09 Apr 2021)

  Changed paths:
    M llvm/include/llvm/Support/FileSystem.h
    M llvm/lib/Support/FileOutputBuffer.cpp
    M llvm/lib/Support/Unix/Path.inc
    M llvm/lib/Support/Windows/Path.inc
    M llvm/unittests/Support/Path.cpp

  Log Message:
  -----------
  Support: Add move semantics to mapped_file_region

Update llvm::sys::fs::mapped_file_region to have a move constructor and
a move assignment operator, allowing it to be used as an 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.

Differential Revision: https://reviews.llvm.org/D100159




More information about the All-commits mailing list