kadircet created this revision. kadircet added a reviewer: ilya-biryukov. Herald added subscribers: cfe-commits, arphaman, jkorous, MaskRay, ioeric.
When canonicalizing paths do not look at tryGetRealPathName, which contains the resolved path for files that are symlinks. Instead first build the absolute path even if it contains some symlinks on the path. Then resolve only the smylinks on the path and leave it as it is if the file itself is a symlink. Repository: rCTE Clang Tools Extra https://reviews.llvm.org/D56263 Files: clangd/SourceCode.cpp Index: clangd/SourceCode.cpp =================================================================== --- clangd/SourceCode.cpp +++ clangd/SourceCode.cpp @@ -187,15 +187,8 @@ const SourceManager &SourceMgr) { if (!F) return None; - // Ideally, we get the real path from the FileEntry object. - SmallString<128> FilePath = F->tryGetRealPathName(); - if (!FilePath.empty() && sys::path::is_absolute(FilePath)) - return FilePath.str().str(); - - // Otherwise, we try to compute ourselves. - FilePath = F->getName(); - vlog("FileEntry for {0} did not contain the real path.", FilePath); + SmallString<128> FilePath = F->getName(); if (!sys::path::is_absolute(FilePath)) { if (auto EC = SourceMgr.getFileManager().getVirtualFileSystem()->makeAbsolute(
Index: clangd/SourceCode.cpp =================================================================== --- clangd/SourceCode.cpp +++ clangd/SourceCode.cpp @@ -187,15 +187,8 @@ const SourceManager &SourceMgr) { if (!F) return None; - // Ideally, we get the real path from the FileEntry object. - SmallString<128> FilePath = F->tryGetRealPathName(); - if (!FilePath.empty() && sys::path::is_absolute(FilePath)) - return FilePath.str().str(); - - // Otherwise, we try to compute ourselves. - FilePath = F->getName(); - vlog("FileEntry for {0} did not contain the real path.", FilePath); + SmallString<128> FilePath = F->getName(); if (!sys::path::is_absolute(FilePath)) { if (auto EC = SourceMgr.getFileManager().getVirtualFileSystem()->makeAbsolute(
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits