summaryrefslogtreecommitdiff
path: root/lib/Frontend/ModuleDependencyCollector.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/Frontend/ModuleDependencyCollector.cpp
parent3ffe6de5f1d998c5c443d459501b8304c9c75ad6 (diff)
downloadclang-cbcc820b8ebdebab93b57347d9555f91c4af0639.tar.gz
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/Frontend/ModuleDependencyCollector.cpp')
-rw-r--r--lib/Frontend/ModuleDependencyCollector.cpp24
1 files changed, 21 insertions, 3 deletions
diff --git a/lib/Frontend/ModuleDependencyCollector.cpp b/lib/Frontend/ModuleDependencyCollector.cpp
index 5fa0e13c77..3546508a89 100644
--- a/lib/Frontend/ModuleDependencyCollector.cpp
+++ b/lib/Frontend/ModuleDependencyCollector.cpp
@@ -97,6 +97,24 @@ struct ModuleDependencyMMCallbacks : public ModuleMapCallbacks {
}
+// TODO: move this to Support/Path.h and check for HAVE_REALPATH?
+static bool real_path(StringRef SrcPath, SmallVectorImpl<char> &RealPath) {
+#ifdef LLVM_ON_UNIX
+ char CanonicalPath[PATH_MAX];
+
+ // TODO: emit a warning in case this fails...?
+ if (!realpath(SrcPath.str().c_str(), CanonicalPath))
+ return false;
+
+ SmallString<256> RPath(CanonicalPath);
+ RealPath.swap(RPath);
+ return true;
+#else
+ // FIXME: Add support for systems without realpath.
+ return false;
+#endif
+}
+
void ModuleDependencyCollector::attachToASTReader(ASTReader &R) {
R.addListener(llvm::make_unique<ModuleDependencyListener>(*this));
}
@@ -111,7 +129,7 @@ void ModuleDependencyCollector::attachToPreprocessor(Preprocessor &PP) {
static bool isCaseSensitivePath(StringRef Path) {
SmallString<256> TmpDest = Path, UpperDest, RealDest;
// Remove component traversals, links, etc.
- if (llvm::sys::fs::real_path(Path, TmpDest))
+ if (!real_path(Path, TmpDest))
return true; // Current default value in vfs.yaml
Path = TmpDest;
@@ -121,7 +139,7 @@ static bool isCaseSensitivePath(StringRef Path) {
// already expects when sensitivity isn't setup.
for (auto &C : Path)
UpperDest.push_back(toUppercase(C));
- if (!llvm::sys::fs::real_path(UpperDest, RealDest) && Path.equals(RealDest))
+ if (real_path(UpperDest, RealDest) && Path.equals(RealDest))
return false;
return true;
}
@@ -171,7 +189,7 @@ bool ModuleDependencyCollector::getRealPath(StringRef SrcPath,
// Computing the real path is expensive, cache the search through the
// parent path directory.
if (DirWithSymLink == SymLinkMap.end()) {
- if (llvm::sys::fs::real_path(Dir, RealPath))
+ if (!real_path(Dir, RealPath))
return false;
SymLinkMap[Dir] = RealPath.str();
} else {