Author: nico Date: Fri Apr 27 13:29:57 2018 New Revision: 331077 URL: http://llvm.org/viewvc/llvm-project?rev=331077&view=rev Log: 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. Modified: cfe/trunk/lib/Basic/FileManager.cpp cfe/trunk/lib/Frontend/ModuleDependencyCollector.cpp Modified: cfe/trunk/lib/Basic/FileManager.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/FileManager.cpp?rev=331077&r1=331076&r2=331077&view=diff ============================================================================== --- cfe/trunk/lib/Basic/FileManager.cpp (original) +++ cfe/trunk/lib/Basic/FileManager.cpp Fri Apr 27 13:29:57 2018 @@ -534,9 +534,23 @@ StringRef FileManager::getCanonicalName( 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; Modified: cfe/trunk/lib/Frontend/ModuleDependencyCollector.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/ModuleDependencyCollector.cpp?rev=331077&r1=331076&r2=331077&view=diff ============================================================================== --- cfe/trunk/lib/Frontend/ModuleDependencyCollector.cpp (original) +++ cfe/trunk/lib/Frontend/ModuleDependencyCollector.cpp Fri Apr 27 13:29:57 2018 @@ -97,6 +97,24 @@ struct ModuleDependencyMMCallbacks : pub } +// 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::attachTo 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(StringRe // 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::getRealP // 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 { _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits