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

Eric Liu via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Aug 24 02:01:10 PDT 2018


This revision was automatically updated to reflect the committed changes.
Closed by commit rC340598: [FileManager] Do not call 'real_path' in getFile(). (authored by ioeric, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D51159?vs=162337&id=162344#toc

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,10 +316,14 @@
   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;
 }
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D51159.162344.patch
Type: text/x-patch
Size: 843 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20180824/83f6b6e9/attachment.bin>


More information about the cfe-commits mailing list