summaryrefslogtreecommitdiffstats
path: root/lib/Basic/FileManager.cpp
diff options
context:
space:
mode:
authorNico Weber <nicolasweber@gmx.de>2018-04-27 20:29:57 +0000
committerNico Weber <nicolasweber@gmx.de>2018-04-27 20:29:57 +0000
commitcbcc820b8ebdebab93b57347d9555f91c4af0639 (patch)
tree2f7a78535407a3546941609dc91312b586aed90a /lib/Basic/FileManager.cpp
parent3ffe6de5f1d998c5c443d459501b8304c9c75ad6 (diff)
Revert r329698 (and r329702).
Speculative. ClangMoveTests started failing on http://lab.llvm.org:8011/builders/clang-x64-ninja-win7/builds/9958 after this change. I can't reproduce on my machine, let's see if it was due to this change. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@331077 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Basic/FileManager.cpp')
-rw-r--r--lib/Basic/FileManager.cpp18
1 files changed, 16 insertions, 2 deletions
diff --git a/lib/Basic/FileManager.cpp b/lib/Basic/FileManager.cpp
index 6fc00d9f41..719b2f6651 100644
--- a/lib/Basic/FileManager.cpp
+++ b/lib/Basic/FileManager.cpp
@@ -534,9 +534,23 @@ StringRef FileManager::getCanonicalName(const DirectoryEntry *Dir) {
StringRef CanonicalName(Dir->getName());
- SmallString<256> CanonicalNameBuf;
- if (!llvm::sys::fs::real_path(Dir->getName(), CanonicalNameBuf))
+#ifdef LLVM_ON_UNIX
+ char CanonicalNameBuf[PATH_MAX];
+ if (realpath(Dir->getName().str().c_str(), CanonicalNameBuf))
CanonicalName = StringRef(CanonicalNameBuf).copy(CanonicalNameStorage);
+#else
+ SmallString<256> CanonicalNameBuf(CanonicalName);
+ llvm::sys::fs::make_absolute(CanonicalNameBuf);
+ llvm::sys::path::native(CanonicalNameBuf);
+ // 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.
+ llvm::sys::path::remove_dots(CanonicalNameBuf, /* remove_dot_dot */ true);
+ CanonicalName = StringRef(CanonicalNameBuf).copy(CanonicalNameStorage);
+#endif
CanonicalDirNames.insert(std::make_pair(Dir, CanonicalName));
return CanonicalName;