From: Jonas Devlieghere Date: Wed, 30 Jan 2019 06:26:26 +0000 (+0000) Subject: [ModuleDependencyCollector] Use llvm::sys::fs::real_path (NFC) X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=ad352e87e1e0d50554cf62cc7356bc322b8ac219;p=clang [ModuleDependencyCollector] Use llvm::sys::fs::real_path (NFC) Use the real_path implementation from llvm::sys::fs::real_path instead of having a custom implementation in the ModuleDependencyCollector. Differential revision: https://reviews.llvm.org/D57411 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@352605 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Frontend/ModuleDependencyCollector.cpp b/lib/Frontend/ModuleDependencyCollector.cpp index efc289f051..c1d8c0d9eb 100644 --- a/lib/Frontend/ModuleDependencyCollector.cpp +++ b/lib/Frontend/ModuleDependencyCollector.cpp @@ -98,24 +98,6 @@ struct ModuleDependencyMMCallbacks : public ModuleMapCallbacks { } -// TODO: move this to Support/Path.h and check for HAVE_REALPATH? -static bool real_path(StringRef SrcPath, SmallVectorImpl &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(*this)); } @@ -130,7 +112,7 @@ void ModuleDependencyCollector::attachToPreprocessor(Preprocessor &PP) { static bool isCaseSensitivePath(StringRef Path) { SmallString<256> TmpDest = Path, UpperDest, RealDest; // Remove component traversals, links, etc. - if (!real_path(Path, TmpDest)) + if (llvm::sys::fs::real_path(Path, TmpDest)) return true; // Current default value in vfs.yaml Path = TmpDest; @@ -140,7 +122,7 @@ static bool isCaseSensitivePath(StringRef Path) { // already expects when sensitivity isn't setup. for (auto &C : Path) UpperDest.push_back(toUppercase(C)); - if (real_path(UpperDest, RealDest) && Path.equals(RealDest)) + if (!llvm::sys::fs::real_path(UpperDest, RealDest) && Path.equals(RealDest)) return false; return true; } @@ -186,7 +168,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 (!real_path(Dir, RealPath)) + if (llvm::sys::fs::real_path(Dir, RealPath)) return false; SymLinkMap[Dir] = RealPath.str(); } else {