[PATCH] D121423: [VFS] OverlayFileSystem should consistently use the last-added FS first

Ben Barham via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Mar 10 15:34:06 PST 2022


bnbarham created this revision.
bnbarham added reviewers: keith, dexonsmith, JDevlieghere, vsapsai.
Herald added a subscriber: hiraditya.
Herald added a project: All.
bnbarham requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Rather than checking whether a file exists before running an operation
and using the result of the first FS where it exists, always run
operations on the most recently added FS's first. If there's any error
other than missing file, return it immediately.

This refactoring also makes it clear that the CWD *cannot* be synced
across contained filesystems - it's always possible that a particular
implementation doesn't set it, eg. `RealFileSystem` only sets the CWD if
it actually exists. Previously this would result in eg. an overlaid FS
having the new CWD, the real filesystem having the old, and
`getCurrentWorkingDirectory` to return the old (assuming it's the
first-added FS in the overlay).

To fix this, instead of assuming the CWD is synced across all
filesystems, add one to `OverlayFileSystem` itself. Set it if any
contained FS sets it successfully and use that for
`getCurrentWorkingDirectory`. Note that this still allows the contained
FS to have separate CWD.

Depends on D121421 <https://reviews.llvm.org/D121421>


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D121423

Files:
  llvm/include/llvm/Support/VirtualFileSystem.h
  llvm/lib/Support/VirtualFileSystem.cpp
  llvm/unittests/Support/VirtualFileSystemTest.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D121423.414516.patch
Type: text/x-patch
Size: 9273 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220310/a02e20d1/attachment.bin>


More information about the llvm-commits mailing list