diff options
author | Nico Weber <nicolasweber@gmx.de> | 2018-04-10 13:36:38 +0000 |
---|---|---|
committer | Nico Weber <nicolasweber@gmx.de> | 2018-04-10 13:36:38 +0000 |
commit | 148c8cb4bf0ce5f328a5bfac822e1b16353bbe8c (patch) | |
tree | 732829aa7be754e335525336195e10c177c6fd99 /clang/lib/Frontend/ModuleDependencyCollector.cpp | |
parent | b1cb0b7957ecb048955bda8f088e34c477938f7f (diff) | |
download | llvm-148c8cb4bf0ce5f328a5bfac822e1b16353bbe8c.zip llvm-148c8cb4bf0ce5f328a5bfac822e1b16353bbe8c.tar.gz llvm-148c8cb4bf0ce5f328a5bfac822e1b16353bbe8c.tar.bz2 |
Use llvm::sys::fs::real_path() in clang.
No expected behavior change.
https://reviews.llvm.org/D45165
llvm-svn: 329698
Diffstat (limited to 'clang/lib/Frontend/ModuleDependencyCollector.cpp')
-rw-r--r-- | clang/lib/Frontend/ModuleDependencyCollector.cpp | 24 |
1 files changed, 3 insertions, 21 deletions
diff --git a/clang/lib/Frontend/ModuleDependencyCollector.cpp b/clang/lib/Frontend/ModuleDependencyCollector.cpp index 3546508..5fa0e13 100644 --- a/clang/lib/Frontend/ModuleDependencyCollector.cpp +++ b/clang/lib/Frontend/ModuleDependencyCollector.cpp @@ -97,24 +97,6 @@ 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)); } @@ -129,7 +111,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; @@ -139,7 +121,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; } @@ -189,7 +171,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 { |