diff options
author | Ben Barham <ben_barham@apple.com> | 2022-03-27 14:08:48 -0700 |
---|---|---|
committer | Ben Barham <ben_barham@apple.com> | 2022-03-30 11:52:41 -0700 |
commit | 3fda0edc51fd68192a30e302d45db081bb02d7f9 (patch) | |
tree | 343d86238d3259d5574a9a990c5f2a5f0523df5e /llvm/unittests/Support/VirtualFileSystemTest.cpp | |
parent | 4477500533281c90c6ce70eb87271f61fd6a415f (diff) | |
download | llvm-3fda0edc51fd68192a30e302d45db081bb02d7f9.zip llvm-3fda0edc51fd68192a30e302d45db081bb02d7f9.tar.gz llvm-3fda0edc51fd68192a30e302d45db081bb02d7f9.tar.bz2 |
[VFS] RedirectingFileSystem only replace path if not already mapped
If the `ExternalFS` has already remapped a path then the
`RedirectingFileSystem` should not change it to the originally provided
path. This fixes the original path always being used if multiple VFS
overlays were provided and the path wasn't found in the highest (ie.
first in the chain).
This also renames `IsVFSMapped` to `ExposesExternalVFSPath` and only
sets it if `UseExternalName` is true. This flag then represents that the
`Status` has an external path that's different from its virtual path.
Right now the contained path is still the external path, but further PRs
will change this to *always* be the virtual path. Clients that need the
external can then request it specifically.
Note that even though `ExposesExternalVFSPath` isn't set for all
VFS-mapped paths, `IsVFSMapped` was only being used by a hack in
`FileManager` that was specific to module searching. In that case
`UseExternalNames` is always `true` and so that hack still applies.
Resolves rdar://90578880 and llvm-project#53306.
Differential Revision: https://reviews.llvm.org/D122549
Diffstat (limited to 'llvm/unittests/Support/VirtualFileSystemTest.cpp')
-rw-r--r-- | llvm/unittests/Support/VirtualFileSystemTest.cpp | 44 |
1 files changed, 22 insertions, 22 deletions
diff --git a/llvm/unittests/Support/VirtualFileSystemTest.cpp b/llvm/unittests/Support/VirtualFileSystemTest.cpp index 1eb7fe6..61cc37a 100644 --- a/llvm/unittests/Support/VirtualFileSystemTest.cpp +++ b/llvm/unittests/Support/VirtualFileSystemTest.cpp @@ -1442,12 +1442,12 @@ TEST_F(VFSFromYAMLTest, MappedFiles) { ErrorOr<vfs::Status> S = O->status("//root/file1"); ASSERT_FALSE(S.getError()); EXPECT_EQ("//root/foo/bar/a", S->getName()); - EXPECT_TRUE(S->IsVFSMapped); + EXPECT_TRUE(S->ExposesExternalVFSPath); ErrorOr<vfs::Status> SLower = O->status("//root/foo/bar/a"); EXPECT_EQ("//root/foo/bar/a", SLower->getName()); EXPECT_TRUE(S->equivalent(*SLower)); - EXPECT_FALSE(SLower->IsVFSMapped); + EXPECT_FALSE(SLower->ExposesExternalVFSPath); // file after opening auto OpenedF = O->openFileForRead("//root/file1"); @@ -1455,7 +1455,7 @@ TEST_F(VFSFromYAMLTest, MappedFiles) { auto OpenedS = (*OpenedF)->status(); ASSERT_FALSE(OpenedS.getError()); EXPECT_EQ("//root/foo/bar/a", OpenedS->getName()); - EXPECT_TRUE(OpenedS->IsVFSMapped); + EXPECT_TRUE(OpenedS->ExposesExternalVFSPath); // directory S = O->status("//root/"); @@ -1467,27 +1467,27 @@ TEST_F(VFSFromYAMLTest, MappedFiles) { S = O->status("//root/mappeddir"); ASSERT_FALSE(S.getError()); EXPECT_TRUE(S->isDirectory()); - EXPECT_TRUE(S->IsVFSMapped); + EXPECT_TRUE(S->ExposesExternalVFSPath); EXPECT_TRUE(S->equivalent(*O->status("//root/foo/bar"))); SLower = O->status("//root/foo/bar"); EXPECT_EQ("//root/foo/bar", SLower->getName()); EXPECT_TRUE(S->equivalent(*SLower)); - EXPECT_FALSE(SLower->IsVFSMapped); + EXPECT_FALSE(SLower->ExposesExternalVFSPath); // file in remapped directory S = O->status("//root/mappeddir/a"); ASSERT_FALSE(S.getError()); - ASSERT_FALSE(S->isDirectory()); - ASSERT_TRUE(S->IsVFSMapped); - ASSERT_EQ("//root/foo/bar/a", S->getName()); + EXPECT_FALSE(S->isDirectory()); + EXPECT_TRUE(S->ExposesExternalVFSPath); + EXPECT_EQ("//root/foo/bar/a", S->getName()); // file in remapped directory, with use-external-name=false S = O->status("//root/mappeddir2/a"); ASSERT_FALSE(S.getError()); - ASSERT_FALSE(S->isDirectory()); - ASSERT_TRUE(S->IsVFSMapped); - ASSERT_EQ("//root/mappeddir2/a", S->getName()); + EXPECT_FALSE(S->isDirectory()); + EXPECT_FALSE(S->ExposesExternalVFSPath); + EXPECT_EQ("//root/mappeddir2/a", S->getName()); // file contents in remapped directory OpenedF = O->openFileForRead("//root/mappeddir/a"); @@ -1495,7 +1495,7 @@ TEST_F(VFSFromYAMLTest, MappedFiles) { OpenedS = (*OpenedF)->status(); ASSERT_FALSE(OpenedS.getError()); EXPECT_EQ("//root/foo/bar/a", OpenedS->getName()); - EXPECT_TRUE(OpenedS->IsVFSMapped); + EXPECT_TRUE(OpenedS->ExposesExternalVFSPath); // file contents in remapped directory, with use-external-name=false OpenedF = O->openFileForRead("//root/mappeddir2/a"); @@ -1503,7 +1503,7 @@ TEST_F(VFSFromYAMLTest, MappedFiles) { OpenedS = (*OpenedF)->status(); ASSERT_FALSE(OpenedS.getError()); EXPECT_EQ("//root/mappeddir2/a", OpenedS->getName()); - EXPECT_TRUE(OpenedS->IsVFSMapped); + EXPECT_FALSE(OpenedS->ExposesExternalVFSPath); // broken mapping EXPECT_EQ(O->status("//root/file2").getError(), @@ -1535,12 +1535,12 @@ TEST_F(VFSFromYAMLTest, MappedRoot) { ErrorOr<vfs::Status> S = O->status("//mappedroot/a"); ASSERT_FALSE(S.getError()); EXPECT_EQ("//root/foo/bar/a", S->getName()); - EXPECT_TRUE(S->IsVFSMapped); + EXPECT_TRUE(S->ExposesExternalVFSPath); ErrorOr<vfs::Status> SLower = O->status("//root/foo/bar/a"); EXPECT_EQ("//root/foo/bar/a", SLower->getName()); EXPECT_TRUE(S->equivalent(*SLower)); - EXPECT_FALSE(SLower->IsVFSMapped); + EXPECT_FALSE(SLower->ExposesExternalVFSPath); // file after opening auto OpenedF = O->openFileForRead("//mappedroot/a"); @@ -1548,7 +1548,7 @@ TEST_F(VFSFromYAMLTest, MappedRoot) { auto OpenedS = (*OpenedF)->status(); ASSERT_FALSE(OpenedS.getError()); EXPECT_EQ("//root/foo/bar/a", OpenedS->getName()); - EXPECT_TRUE(OpenedS->IsVFSMapped); + EXPECT_TRUE(OpenedS->ExposesExternalVFSPath); EXPECT_EQ(0, NumDiagnostics); } @@ -1696,12 +1696,12 @@ TEST_F(VFSFromYAMLTest, ReturnsRequestedPathVFSMiss) { auto OpenedS = (*OpenedF)->status(); ASSERT_FALSE(OpenedS.getError()); EXPECT_EQ("a", OpenedS->getName()); - EXPECT_FALSE(OpenedS->IsVFSMapped); + EXPECT_FALSE(OpenedS->ExposesExternalVFSPath); auto DirectS = RemappedFS->status("a"); ASSERT_FALSE(DirectS.getError()); EXPECT_EQ("a", DirectS->getName()); - EXPECT_FALSE(DirectS->IsVFSMapped); + EXPECT_FALSE(DirectS->ExposesExternalVFSPath); EXPECT_EQ(0, NumDiagnostics); } @@ -1736,12 +1736,12 @@ TEST_F(VFSFromYAMLTest, ReturnsExternalPathVFSHit) { auto OpenedS = (*OpenedF)->status(); ASSERT_FALSE(OpenedS.getError()); EXPECT_EQ("realname", OpenedS->getName()); - EXPECT_TRUE(OpenedS->IsVFSMapped); + EXPECT_TRUE(OpenedS->ExposesExternalVFSPath); auto DirectS = FS->status("vfsname"); ASSERT_FALSE(DirectS.getError()); EXPECT_EQ("realname", DirectS->getName()); - EXPECT_TRUE(DirectS->IsVFSMapped); + EXPECT_TRUE(DirectS->ExposesExternalVFSPath); EXPECT_EQ(0, NumDiagnostics); } @@ -1776,12 +1776,12 @@ TEST_F(VFSFromYAMLTest, ReturnsInternalPathVFSHit) { auto OpenedS = (*OpenedF)->status(); ASSERT_FALSE(OpenedS.getError()); EXPECT_EQ("vfsname", OpenedS->getName()); - EXPECT_TRUE(OpenedS->IsVFSMapped); + EXPECT_FALSE(OpenedS->ExposesExternalVFSPath); auto DirectS = FS->status("vfsname"); ASSERT_FALSE(DirectS.getError()); EXPECT_EQ("vfsname", DirectS->getName()); - EXPECT_TRUE(DirectS->IsVFSMapped); + EXPECT_FALSE(DirectS->ExposesExternalVFSPath); EXPECT_EQ(0, NumDiagnostics); } |