r243625 - Add a comment explaining differing Windows behavior.

Sean Silva chisophugis at gmail.com
Thu Jul 30 00:30:25 PDT 2015


Author: silvas
Date: Thu Jul 30 02:30:24 2015
New Revision: 243625

URL: http://llvm.org/viewvc/llvm-project?rev=243625&view=rev
Log:
Add a comment explaining differing Windows behavior.

Modified:
    cfe/trunk/lib/Basic/FileManager.cpp

Modified: cfe/trunk/lib/Basic/FileManager.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/FileManager.cpp?rev=243625&r1=243624&r2=243625&view=diff
==============================================================================
--- cfe/trunk/lib/Basic/FileManager.cpp (original)
+++ cfe/trunk/lib/Basic/FileManager.cpp Thu Jul 30 02:30:24 2015
@@ -568,7 +568,13 @@ StringRef FileManager::getCanonicalName(
   SmallString<256> CanonicalNameBuf(CanonicalName);
   llvm::sys::fs::make_absolute(CanonicalNameBuf);
   llvm::sys::path::native(CanonicalNameBuf);
-  removeDotPaths(CanonicalNameBuf, true);
+  // We've run into needing to remove '..' here in the wild though, so
+  // remove it.
+  // On Windows, symlinks are significantly less prevalent, so removing
+  // '..' is pretty safe.
+  // Ideally we'd have an equivalent of `realpath` and could implement
+  // sys::fs::canonical across all the platforms.
+  removeDotPaths(CanonicalNameBuf, /*RemoveDotDot*/true);
   char *Mem = CanonicalNameStorage.Allocate<char>(CanonicalNameBuf.size());
   memcpy(Mem, CanonicalNameBuf.data(), CanonicalNameBuf.size());
   CanonicalName = StringRef(Mem, CanonicalNameBuf.size());





More information about the cfe-commits mailing list