summaryrefslogtreecommitdiffstats
path: root/clang/lib/Basic/FileManager.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'clang/lib/Basic/FileManager.cpp')
-rw-r--r--clang/lib/Basic/FileManager.cpp8
1 files changed, 7 insertions, 1 deletions
diff --git a/clang/lib/Basic/FileManager.cpp b/clang/lib/Basic/FileManager.cpp
index 209abad6567..4c84f1b6ad2 100644
--- a/clang/lib/Basic/FileManager.cpp
+++ b/clang/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<char>(CanonicalNameBuf.size());
memcpy(Mem, CanonicalNameBuf.data(), CanonicalNameBuf.size());
CanonicalName = StringRef(Mem, CanonicalNameBuf.size());
OpenPOWER on IntegriCloud