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

Simon Marchi via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Aug 23 10:35:17 PDT 2018


simark added inline comments.


================
Comment at: lib/Basic/FileManager.cpp:319
 
-  SmallString<128> RealPathName;
-  if (!FS->getRealPath(InterndFileName, RealPathName))
-    UFE.RealPathName = RealPathName.str();
+  if (UFE.File) {
+    if (auto Path = UFE.File->getName()) {
----------------
What's the rationale for only computing the field if `UFE.File` is non-null?

Previously, if you looked up the file with `openFile == false` and then later `openFile == true`, the `RealPathName` field would not be set because of this.  That doesn't seem right.


================
Comment at: lib/Basic/FileManager.cpp:326
+      llvm::sys::path::remove_dots(AbsPath, /*remove_dot_dot=*/true);
+      UFE.RealPathName = AbsPath.str();
+    }
----------------
If the path contains symlinks, doesn't this put a non-real path in the RealPathName field?  Won't users (e.g. clangd) use this value thinking it is a real path, when it is actually not?


Repository:
  rC Clang

https://reviews.llvm.org/D51159





More information about the cfe-commits mailing list