aboutsummaryrefslogtreecommitdiff
path: root/llvm/unittests/Support/VirtualFileSystemTest.cpp
diff options
context:
space:
mode:
authorJan Svoboda <jan_svoboda@apple.com>2023-07-10 10:10:38 -0700
committerJan Svoboda <jan_svoboda@apple.com>2023-07-10 10:41:15 -0700
commitd77588df4553f0e93a74e6eab33e1ce87b576320 (patch)
tree24369c5c127207334d49ac7a411f3a0eab5a41fa /llvm/unittests/Support/VirtualFileSystemTest.cpp
parent7436d4b930bf012166fbd68f408ff6d8840bdcb6 (diff)
downloadllvm-d77588df4553f0e93a74e6eab33e1ce87b576320.zip
llvm-d77588df4553f0e93a74e6eab33e1ce87b576320.tar.gz
llvm-d77588df4553f0e93a74e6eab33e1ce87b576320.tar.bz2
[llvm][vfs] For virtual directories, use the virtual path as the real path
A follow-up to D135841. This patch returns the virtual path for directories from `RedirectingFileSystem`. This ensures the contents of `Path` are the same as the contents of `FS->getRealPath(Path)`. This also means we can drop the workaround in Clang's module map canonicalization, where we couldn't use the real path for a directory if it resolved to a different `DirectoryEntry`. In addition to that, we can also avoid introducing new workaround for a bug triggered by the newly introduced test case. Reviewed By: benlangmuir Differential Revision: https://reviews.llvm.org/D135849
Diffstat (limited to 'llvm/unittests/Support/VirtualFileSystemTest.cpp')
-rw-r--r--llvm/unittests/Support/VirtualFileSystemTest.cpp12
1 files changed, 9 insertions, 3 deletions
diff --git a/llvm/unittests/Support/VirtualFileSystemTest.cpp b/llvm/unittests/Support/VirtualFileSystemTest.cpp
index e1b3ab6..bd4048f 100644
--- a/llvm/unittests/Support/VirtualFileSystemTest.cpp
+++ b/llvm/unittests/Support/VirtualFileSystemTest.cpp
@@ -2580,6 +2580,7 @@ TEST_F(VFSFromYAMLTest, GetRealPath) {
Lower->addSymlink("/link");
IntrusiveRefCntPtr<vfs::FileSystem> FS = getFromYAMLString(
"{ 'use-external-names': false,\n"
+ " 'case-sensitive': false,\n"
" 'roots': [\n"
"{\n"
" 'type': 'directory',\n"
@@ -2588,6 +2589,11 @@ TEST_F(VFSFromYAMLTest, GetRealPath) {
" 'type': 'file',\n"
" 'name': 'bar',\n"
" 'external-contents': '/link'\n"
+ " },\n"
+ " {\n"
+ " 'type': 'directory',\n"
+ " 'name': 'baz',\n"
+ " 'contents': []\n"
" }\n"
" ]\n"
"},\n"
@@ -2610,9 +2616,9 @@ TEST_F(VFSFromYAMLTest, GetRealPath) {
EXPECT_FALSE(FS->getRealPath("//root/bar", RealPath));
EXPECT_EQ(RealPath.str(), "/symlink");
- // Directories should fall back to the underlying file system is possible.
- EXPECT_FALSE(FS->getRealPath("//dir/", RealPath));
- EXPECT_EQ(RealPath.str(), "//dir/");
+ // Directories should return the virtual path as written in the definition.
+ EXPECT_FALSE(FS->getRealPath("//ROOT/baz", RealPath));
+ EXPECT_EQ(RealPath.str(), "//root/baz");
// Try a non-existing file.
EXPECT_EQ(FS->getRealPath("/non_existing", RealPath),