|
@@ -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) {
|
|
void ModuleDependencyCollector::attachToASTReader(ASTReader &R) {
|
|
R.addListener(llvm::make_unique<ModuleDependencyListener>(*this));
|
|
R.addListener(llvm::make_unique<ModuleDependencyListener>(*this));
|
|
}
|
|
}
|
|
@@ -111,7 +129,7 @@ void ModuleDependencyCollector::attachToPreprocessor(Preprocessor &PP) {
|
|
static bool isCaseSensitivePath(StringRef Path) {
|
|
static bool isCaseSensitivePath(StringRef Path) {
|
|
SmallString<256> TmpDest = Path, UpperDest, RealDest;
|
|
SmallString<256> TmpDest = Path, UpperDest, RealDest;
|
|
// Remove component traversals, links, etc.
|
|
// 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
|
|
return true; // Current default value in vfs.yaml
|
|
Path = TmpDest;
|
|
Path = TmpDest;
|
|
|
|
|
|
@@ -121,7 +139,7 @@ static bool isCaseSensitivePath(StringRef Path) {
|
|
// already expects when sensitivity isn't setup.
|
|
// already expects when sensitivity isn't setup.
|
|
for (auto &C : Path)
|
|
for (auto &C : Path)
|
|
UpperDest.push_back(toUppercase(C));
|
|
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 false;
|
|
return true;
|
|
return true;
|
|
}
|
|
}
|
|
@@ -171,7 +189,7 @@ bool ModuleDependencyCollector::getRealPath(StringRef SrcPath,
|
|
// Computing the real path is expensive, cache the search through the
|
|
// Computing the real path is expensive, cache the search through the
|
|
// parent path directory.
|
|
// parent path directory.
|
|
if (DirWithSymLink == SymLinkMap.end()) {
|
|
if (DirWithSymLink == SymLinkMap.end()) {
|
|
- if (llvm::sys::fs::real_path(Dir, RealPath))
|
|
|
|
|
|
+ if (!real_path(Dir, RealPath))
|
|
return false;
|
|
return false;
|
|
SymLinkMap[Dir] = RealPath.str();
|
|
SymLinkMap[Dir] = RealPath.str();
|
|
} else {
|
|
} else {
|