[all-commits] [llvm/llvm-project] 502f14: [VFS] Add a "redirecting-with" field to overlays

Ben Barham via All-commits all-commits at lists.llvm.org
Thu Feb 3 13:10:44 PST 2022


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 502f14d6f2eee10d2993ed22d820f12cf52462d6
      https://github.com/llvm/llvm-project/commit/502f14d6f2eee10d2993ed22d820f12cf52462d6
  Author: Ben Barham <ben_barham at apple.com>
  Date:   2022-02-03 (Thu, 03 Feb 2022)

  Changed paths:
    A clang/test/VFS/Inputs/redirect-and-fallthrough.yaml
    A clang/test/VFS/Inputs/unknown-redirect.yaml
    A clang/test/VFS/fallback.c
    M clang/test/VFS/parse-errors.c
    M llvm/include/llvm/Support/VirtualFileSystem.h
    M llvm/lib/Support/VirtualFileSystem.cpp
    M llvm/unittests/Support/VirtualFileSystemTest.cpp

  Log Message:
  -----------
  [VFS] Add a "redirecting-with" field to overlays

Extend "fallthrough" to allow a third option: "fallback". Fallthrough
allows the original path to used if the redirected (or mapped) path
fails. Fallback is the reverse of this, ie. use the original path and
fallback to the mapped path otherwise.

While this result *can* be achieved today using multiple overlays, this
adds a much more intuitive option. As an example, take two directories
"A" and "B". We would like files from "A" to be used, unless they don't
exist, in which case the VFS should fallback to those in "B".

With the current fallthrough option this is possible by adding two
overlays: one mapping from A -> B and another mapping from B -> A. Since
the frontend *nests* the two RedirectingFileSystems, the result will
be that "A" is mapped to "B" and back to "A", unless it isn't in "A" in
which case it fallsthrough to "B" (or fails if it exists in neither).

Using "fallback" semantics allows a single overlay instead: one mapping
from "A" to "B" but only using that mapping if the operation in "A"
fails first.

"redirect-only" is used to represent the current "fallthrough: false"
case.

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




More information about the All-commits mailing list