Skip to content

Commit 61d3748

Browse files
authored
Merge pull request #3918 from apple/revert-3909-cherry-redirecting-with
Revert "[VFS] Add a "redirecting-with" field to overlays"
2 parents 39db93a + 27cb2ed commit 61d3748

File tree

7 files changed

+84
-496
lines changed

7 files changed

+84
-496
lines changed

clang/test/VFS/Inputs/redirect-and-fallthrough.yaml

Lines changed: 0 additions & 11 deletions
This file was deleted.

clang/test/VFS/Inputs/unknown-redirect.yaml

Lines changed: 0 additions & 10 deletions
This file was deleted.

clang/test/VFS/fallback.c

Lines changed: 0 additions & 86 deletions
This file was deleted.

clang/test/VFS/parse-errors.c

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,3 @@
1212
// RUN: not %clang_cc1 -ivfsoverlay %S/Inputs/unknown-value.yaml -fsyntax-only %s 2>&1 | FileCheck -check-prefix=CHECK-UNKNOWN-VALUE %s
1313
// CHECK-UNKNOWN-VALUE: expected boolean value
1414
// CHECK-UNKNOWN-VALUE: invalid virtual filesystem overlay file
15-
16-
// RUN: not %clang_cc1 -ivfsoverlay %S/Inputs/unknown-redirect.yaml -fsyntax-only %s 2>&1 | FileCheck -check-prefix=CHECK-REDIRECT %s
17-
// CHECK-REDIRECT: expected valid redirect kind
18-
// CHECK-REDIRECT: invalid virtual filesystem overlay file
19-
20-
// RUN: not %clang_cc1 -ivfsoverlay %S/Inputs/redirect-and-fallthrough.yaml -fsyntax-only %s 2>&1 | FileCheck -check-prefix=CHECK-EXCLUSIVE-KEYS %s
21-
// CHECK-EXCLUSIVE-KEYS: 'fallthrough' and 'redirecting-with' are mutually exclusive
22-
// CHECK-EXCLUSIVE-KEYS: invalid virtual filesystem overlay file

llvm/include/llvm/Support/VirtualFileSystem.h

Lines changed: 10 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -549,10 +549,7 @@ class RedirectingFileSystemParser;
549549
/// 'case-sensitive': <boolean, default=(true for Posix, false for Windows)>
550550
/// 'use-external-names': <boolean, default=true>
551551
/// 'overlay-relative': <boolean, default=false>
552-
/// 'fallthrough': <boolean, default=true, deprecated - use 'redirecting-with'
553-
/// instead>
554-
/// 'redirecting-with': <string, one of 'fallthrough', 'fallback', or
555-
/// 'redirect-only', default='fallthrough'>
552+
/// 'fallthrough': <boolean, default=true>
556553
///
557554
/// Virtual directories that list their contents are represented as
558555
/// \verbatim
@@ -623,20 +620,6 @@ class RedirectingFileSystem : public vfs::FileSystem {
623620
enum EntryKind { EK_Directory, EK_DirectoryRemap, EK_File };
624621
enum NameKind { NK_NotSet, NK_External, NK_Virtual };
625622

626-
/// The type of redirection to perform.
627-
enum class RedirectKind {
628-
/// Lookup the redirected path first (ie. the one specified in
629-
/// 'external-contents') and if that fails "fallthrough" to a lookup of the
630-
/// originally provided path.
631-
Fallthrough,
632-
/// Lookup the provided path first and if that fails, "fallback" to a
633-
/// lookup of the redirected path.
634-
Fallback,
635-
/// Only lookup the redirected path, do not lookup the originally provided
636-
/// path.
637-
RedirectOnly
638-
};
639-
640623
/// A single file or directory in the VFS.
641624
class Entry {
642625
EntryKind Kind;
@@ -771,11 +754,17 @@ class RedirectingFileSystem : public vfs::FileSystem {
771754
friend class RedirectingFSDirIterImpl;
772755
friend class RedirectingFileSystemParser;
773756

757+
bool shouldUseExternalFS() const { return IsFallthrough; }
758+
774759
/// Canonicalize path by removing ".", "..", "./", components. This is
775760
/// a VFS request, do not bother about symlinks in the path components
776761
/// but canonicalize in order to perform the correct entry search.
777762
std::error_code makeCanonical(SmallVectorImpl<char> &Path) const;
778763

764+
/// Whether to fall back to the external file system when an operation fails
765+
/// with the given error code on a path associated with the provided Entry.
766+
bool shouldFallBackToExternalFS(std::error_code EC, Entry *E = nullptr) const;
767+
779768
/// Get the File status, or error, from the underlying external file system.
780769
/// This returns the status with the originally requested name, while looking
781770
/// up the entry using the canonical path.
@@ -828,9 +817,9 @@ class RedirectingFileSystem : public vfs::FileSystem {
828817
/// names of files. This global value is overridable on a per-file basis.
829818
bool UseExternalNames = true;
830819

831-
/// Determines the lookups to perform, as well as their order. See
832-
/// \c RedirectKind for details.
833-
RedirectKind Redirection = RedirectKind::Fallthrough;
820+
/// Whether to attempt a file lookup in external file system after it wasn't
821+
/// found in VFS.
822+
bool IsFallthrough = true;
834823
/// @}
835824

836825
RedirectingFileSystem(IntrusiveRefCntPtr<FileSystem> ExternalFS);
@@ -885,12 +874,8 @@ class RedirectingFileSystem : public vfs::FileSystem {
885874

886875
StringRef getExternalContentsPrefixDir() const;
887876

888-
/// Sets the redirection kind to \c Fallthrough if true or \c RedirectOnly
889-
/// otherwise. Will removed in the future, use \c setRedirection instead.
890877
void setFallthrough(bool Fallthrough);
891878

892-
void setRedirection(RedirectingFileSystem::RedirectKind Kind);
893-
894879
std::vector<llvm::StringRef> getRoots() const;
895880

896881
void dump(raw_ostream &OS) const;

0 commit comments

Comments
 (0)