From 6093fea79d46ed6f9846e7f069317ae996149c69 Mon Sep 17 00:00:00 2001 From: Eric Liu Date: Fri, 24 Aug 2018 09:53:44 +0000 Subject: [PATCH] Fix build bot after r340598. Revert to the original behavior: only calculate real file path when file is opened and avoid using InterndPath for real path calculation. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@340602 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Basic/FileManager.cpp | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/lib/Basic/FileManager.cpp b/lib/Basic/FileManager.cpp index 060d3a687a..a45a8f239a 100644 --- a/lib/Basic/FileManager.cpp +++ b/lib/Basic/FileManager.cpp @@ -316,14 +316,18 @@ const FileEntry *FileManager::getFile(StringRef Filename, bool openFile, UFE.File = std::move(F); UFE.IsValid = true; - llvm::SmallString<128> AbsPath(InterndFileName); - // This is not the same as `VFS::getRealPath()`, which resolves symlinks but - // can be very expensive on real file systems. - // FIXME: the semantic of RealPathName is unclear, and the name might be - // misleading. We need to clean up the interface here. - makeAbsolutePath(AbsPath); - llvm::sys::path::remove_dots(AbsPath, /*remove_dot_dot=*/true); - UFE.RealPathName = AbsPath.str(); + if (UFE.File) { + if (auto PathName = UFE.File->getName()) { + llvm::SmallString<128> AbsPath(*PathName); + // This is not the same as `VFS::getRealPath()`, which resolves symlinks + // but can be very expensive on real file systems. + // FIXME: the semantic of RealPathName is unclear, and the name might be + // misleading. We need to clean up the interface here. + makeAbsolutePath(AbsPath); + llvm::sys::path::remove_dots(AbsPath, /*remove_dot_dot=*/true); + UFE.RealPathName = AbsPath.str(); + } + } return &UFE; } -- 2.40.0