Index: lib/Basic/FileManager.cpp =================================================================== --- lib/Basic/FileManager.cpp +++ lib/Basic/FileManager.cpp @@ -316,9 +316,16 @@ UFE.File = std::move(F); UFE.IsValid = true; - SmallString<128> RealPathName; - if (!FS->getRealPath(InterndFileName, RealPathName)) - UFE.RealPathName = RealPathName.str(); + if (UFE.File) { + if (auto Path = UFE.File->getName()) { + llvm::SmallString<128> AbsPath(*Path); + // This is not the same as `real_path()` system call, which also resolves + // symlinks. + makeAbsolutePath(AbsPath); + llvm::sys::path::remove_dots(AbsPath, /*remove_dot_dot=*/true); + UFE.RealPathName = AbsPath.str(); + } + } return &UFE; }