From: Sean Silva Date: Thu, 30 Jul 2015 07:30:24 +0000 (+0000) Subject: Add a comment explaining differing Windows behavior. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=86a53c5e8ae938968b26deb87222bdb1501d61ca;p=clang Add a comment explaining differing Windows behavior. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@243625 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Basic/FileManager.cpp b/lib/Basic/FileManager.cpp index 209abad656..4c84f1b6ad 100644 --- a/lib/Basic/FileManager.cpp +++ b/lib/Basic/FileManager.cpp @@ -568,7 +568,13 @@ StringRef FileManager::getCanonicalName(const DirectoryEntry *Dir) { 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(CanonicalNameBuf.size()); memcpy(Mem, CanonicalNameBuf.data(), CanonicalNameBuf.size()); CanonicalName = StringRef(Mem, CanonicalNameBuf.size());