Index: clang-tools-extra/clangd/SourceCode.cpp =================================================================== --- clang-tools-extra/clangd/SourceCode.cpp +++ clang-tools-extra/clangd/SourceCode.cpp @@ -635,6 +635,13 @@ } } + SmallString<128> RealPath; + if (SourceMgr.getFileManager().getVirtualFileSystem().getRealPath(FilePath, + RealPath)) { + log("Could not compute real path: {0}", FilePath); + return FilePath.str().str(); + } + // Handle the symbolic link path case where the current working directory // (getCurrentWorkingDirectory) is a symlink. We always want to the real // file path (instead of the symlink path) for the C++ symbols. @@ -647,15 +654,15 @@ // The file path of Symbol is "/project/src/foo.h" instead of // "/tmp/build/foo.h" if (auto Dir = SourceMgr.getFileManager().getDirectory( - llvm::sys::path::parent_path(FilePath))) { - llvm::SmallString<128> RealPath; + llvm::sys::path::parent_path(RealPath))) { + llvm::SmallString<128> DirRealPath; llvm::StringRef DirName = SourceMgr.getFileManager().getCanonicalName(*Dir); - llvm::sys::path::append(RealPath, DirName, - llvm::sys::path::filename(FilePath)); - return RealPath.str().str(); + llvm::sys::path::append(DirRealPath, DirName, + llvm::sys::path::filename(RealPath)); + return DirRealPath.str().str(); } - return FilePath.str().str(); + return RealPath.str().str(); } TextEdit toTextEdit(const FixItHint &FixIt, const SourceManager &M,