[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

llvm-svn: 350306
This commit is contained in:
Kadir Cetinkaya 2019-01-03 13:46:10 +00:00
parent b39a97c8f6
commit 41f98c834b
1 changed files with 1 additions and 8 deletions

View File

@ -187,15 +187,8 @@ Optional<std::string> getCanonicalPath(const FileEntry *F,
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(