aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/Basic/FileManager.cpp
diff options
context:
space:
mode:
authorEric Liu <ioeric@google.com>2018-08-24 08:59:54 +0000
committerEric Liu <ioeric@google.com>2018-08-24 08:59:54 +0000
commit411e710074db74ce3430543e1399a45813952f85 (patch)
tree91b6036aae27ccc44880c4d41ea0be4e4ff36e15 /clang/lib/Basic/FileManager.cpp
parent562811a86d7e5c279e543cbd164db8adc2208a46 (diff)
downloadllvm-411e710074db74ce3430543e1399a45813952f85.zip
llvm-411e710074db74ce3430543e1399a45813952f85.tar.gz
llvm-411e710074db74ce3430543e1399a45813952f85.tar.bz2
[FileManager] Do not call 'real_path' in getFile().
Summary: This partially rolls back the change in D48903: https://github.com/llvm-mirror/clang/commit/89aa7f45a1f728144935289d4ce69d8522999de0#diff-0025af005307891b5429b6a834823d5eR318 `real_path` can be very expensive on real file systems, and calling it on each opened file can slow down the compilation. This also slows down deserialized ASTs for which real paths need to be recalculated for each input files again. For clangd code completion latency (using preamble): Before {F7039629} After {F7039630} Reviewers: ilya-biryukov, simark Reviewed By: ilya-biryukov Subscribers: kadircet, cfe-commits Differential Revision: https://reviews.llvm.org/D51159 llvm-svn: 340598
Diffstat (limited to 'clang/lib/Basic/FileManager.cpp')
-rw-r--r--clang/lib/Basic/FileManager.cpp12
1 files changed, 8 insertions, 4 deletions
diff --git a/clang/lib/Basic/FileManager.cpp b/clang/lib/Basic/FileManager.cpp
index 5f783a7..060d3a6 100644
--- a/clang/lib/Basic/FileManager.cpp
+++ b/clang/lib/Basic/FileManager.cpp
@@ -316,10 +316,14 @@ const FileEntry *FileManager::getFile(StringRef Filename, bool openFile,
UFE.File = std::move(F);
UFE.IsValid = true;
- SmallString<128> RealPathName;
- if (!FS->getRealPath(InterndFileName, RealPathName))
- UFE.RealPathName = RealPathName.str();
-
+ 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();
return &UFE;
}