From d77588df4553f0e93a74e6eab33e1ce87b576320 Mon Sep 17 00:00:00 2001 From: Jan Svoboda Date: Mon, 10 Jul 2023 10:10:38 -0700 Subject: [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 --- llvm/unittests/Support/VirtualFileSystemTest.cpp | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'llvm/unittests/Support/VirtualFileSystemTest.cpp') 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 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), -- cgit v1.1