[PATCH] D51159: [FileManager] Do not call 'real_path' in getFile().

Eric Liu via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Aug 23 06:23:16 PDT 2018


ioeric created this revision.
ioeric added reviewers: ilya-biryukov, simark.
Herald added a subscriber: cfe-commits.

This partially rolls back the change in https://reviews.llvm.org/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.


Repository:
  rC Clang

https://reviews.llvm.org/D51159

Files:
  lib/Basic/FileManager.cpp


Index: lib/Basic/FileManager.cpp
===================================================================
--- lib/Basic/FileManager.cpp
+++ lib/Basic/FileManager.cpp
@@ -316,9 +316,14 @@
   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);
+      makeAbsolutePath(AbsPath);
+      llvm::sys::path::remove_dots(AbsPath, /*remove_dot_dot=*/true);
+      UFE.RealPathName = AbsPath.str();
+    }
+  }
 
   return &UFE;
 }


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D51159.162165.patch
Type: text/x-patch
Size: 657 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20180823/41c77486/attachment.bin>


More information about the cfe-commits mailing list