[clang-tools-extra] r350306 - [clangd] Always try to build absolute path

Kadir Cetinkaya via cfe-commits cfe-commits at lists.llvm.org
Thu Jan 3 05:46:10 PST 2019


Author: kadircet
Date: Thu Jan  3 05:46:10 2019
New Revision: 350306

URL: http://llvm.org/viewvc/llvm-project?rev=350306&view=rev
Log:
[clangd] Always try to build absolute path

Summary:
This only changes behavior in cases when the file itself is a symlink.

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 symlinks on the path and leave it as it is if the file itself is a symlink.

Reviewers: ilya-biryukov

Reviewed By: ilya-biryukov

Subscribers: ioeric, MaskRay, jkorous, arphaman, cfe-commits

Differential Revision: https://reviews.llvm.org/D56263

Modified:
    clang-tools-extra/trunk/clangd/SourceCode.cpp

Modified: clang-tools-extra/trunk/clangd/SourceCode.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/SourceCode.cpp?rev=350306&r1=350305&r2=350306&view=diff
==============================================================================
--- clang-tools-extra/trunk/clangd/SourceCode.cpp (original)
+++ clang-tools-extra/trunk/clangd/SourceCode.cpp Thu Jan  3 05:46:10 2019
@@ -187,15 +187,8 @@ Optional<std::string> getCanonicalPath(c
                                        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(




More information about the cfe-commits mailing list