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 --- clang/lib/Lex/ModuleMap.cpp | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) (limited to 'clang/lib/Lex/ModuleMap.cpp') diff --git a/clang/lib/Lex/ModuleMap.cpp b/clang/lib/Lex/ModuleMap.cpp index cf546c4..7a22fea 100644 --- a/clang/lib/Lex/ModuleMap.cpp +++ b/clang/lib/Lex/ModuleMap.cpp @@ -1325,18 +1325,8 @@ ModuleMap::canonicalizeModuleMapPath(SmallVectorImpl &Path) { // Canonicalize the directory. StringRef CanonicalDir = FM.getCanonicalName(*DirEntry); - if (CanonicalDir != Dir) { - auto CanonicalDirEntry = FM.getDirectory(CanonicalDir); - // Only use the canonicalized path if it resolves to the same entry as the - // original. This is not true if there's a VFS overlay on top of a FS where - // the directory is a symlink. The overlay would not remap the target path - // of the symlink to the same directory entry in that case. - if (CanonicalDirEntry && *CanonicalDirEntry == *DirEntry) { - bool Done = llvm::sys::path::replace_path_prefix(Path, Dir, CanonicalDir); - (void)Done; - assert(Done && "Path should always start with Dir"); - } - } + if (CanonicalDir != Dir) + llvm::sys::path::replace_path_prefix(Path, Dir, CanonicalDir); // In theory, the filename component should also be canonicalized if it // on a case-insensitive filesystem. However, the extra canonicalization is -- cgit v1.1