[PATCH] D121424: [VFS] Revert RedirectingFileSystem to having a single responsibility

Ben Barham via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Mar 10 15:36:16 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.

`RedirectingFileSystem` has grown significantly over time. When it was
added it simply performed a path remapping and then used that path in
the filesystem it was passed. The functionality provided by
`-ivfsoverlay` was handled by `OverlayFileSystem`, which would run
operations on the contained filesystems in reverse order.

Since then, "fallthrough" and "redirecting-with" options were added to
the overlay YAML format. As part of these changes, `OverlayFileSystem`
stopped being used in the handling of `-ivfsoverlay` and this was
instead handled by nesting `RedirectingFileSystem` together. The
right-most overlay would use the next-to-the-left
`RedirectingFileSystem` as its external filesystem, etc.

This allowed:

1. Overlay paths to be dependent on previous `-ivfsoverlay`, ie. a second `-ivfsoverlay` could specify a virtual path for its overlay if that path is in the first overlay.
2. Paths from one overlay to affect those in an earlier, ie. if the right-most overlay specified a mapping from A -> B and the left-most a mapping from B -> C, A could now map to C.
3. The real filesystem to be skipped, ie. all specified paths have to be contained in an overlay (which would still map to the real filesystem).

`FileSystem` also had a get/set added for the current working directory
to allow for filesystem-specific CWD rather than a process-wide CWD,
further complicating the `RedirectingFileSystem` implementation.

This change reverts `RedirectingFileSystem` to a single responsibility -
mapping paths and passing that path to the underlying filesystem. A
later change implements (1) and (3) through the `OverlayFileSystem`. (2)
is no longer possible, which fixes llvm-project#53306 as a side-effect.

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


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D121424

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: D121424.414517.patch
Type: text/x-patch
Size: 36308 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220310/7a5636ae/attachment.bin>


More information about the llvm-commits mailing list