Index: cfe/trunk/include/clang/Basic/FileManager.h =================================================================== --- cfe/trunk/include/clang/Basic/FileManager.h +++ cfe/trunk/include/clang/Basic/FileManager.h @@ -273,9 +273,6 @@ static void modifyFileEntry(FileEntry *File, off_t Size, time_t ModificationTime); - /// \brief Remove any './' components from a path. - static bool removeDotPaths(SmallVectorImpl &Path, bool RemoveDotDot = false); - /// \brief Retrieve the canonical name for a given directory. /// /// This is a very expensive operation, despite its results being cached, Index: cfe/trunk/lib/Basic/FileManager.cpp =================================================================== --- cfe/trunk/lib/Basic/FileManager.cpp +++ cfe/trunk/lib/Basic/FileManager.cpp @@ -526,39 +526,6 @@ File->ModTime = ModificationTime; } -/// Remove '.' and '..' path components from the given absolute path. -/// \return \c true if any changes were made. -// FIXME: Move this to llvm::sys::path. -bool FileManager::removeDotPaths(SmallVectorImpl &Path, bool RemoveDotDot) { - using namespace llvm::sys; - - SmallVector ComponentStack; - StringRef P(Path.data(), Path.size()); - - // Skip the root path, then look for traversal in the components. - StringRef Rel = path::relative_path(P); - for (StringRef C : llvm::make_range(path::begin(Rel), path::end(Rel))) { - if (C == ".") - continue; - if (RemoveDotDot) { - if (C == "..") { - if (!ComponentStack.empty()) - ComponentStack.pop_back(); - continue; - } - } - ComponentStack.push_back(C); - } - - SmallString<256> Buffer = path::root_path(P); - for (StringRef C : ComponentStack) - path::append(Buffer, C); - - bool Changed = (Path != Buffer); - Path.swap(Buffer); - return Changed; -} - StringRef FileManager::getCanonicalName(const DirectoryEntry *Dir) { // FIXME: use llvm::sys::fs::canonical() when it gets implemented llvm::DenseMap::iterator Known @@ -582,7 +549,7 @@ // '..' is pretty safe. // Ideally we'd have an equivalent of `realpath` and could implement // sys::fs::canonical across all the platforms. - removeDotPaths(CanonicalNameBuf, /*RemoveDotDot*/true); + llvm::sys::path::remove_dots(CanonicalNameBuf, /* remove_dot_dot */ true); CanonicalName = StringRef(CanonicalNameBuf).copy(CanonicalNameStorage); #endif Index: cfe/trunk/lib/Basic/VirtualFileSystem.cpp =================================================================== --- cfe/trunk/lib/Basic/VirtualFileSystem.cpp +++ cfe/trunk/lib/Basic/VirtualFileSystem.cpp @@ -499,7 +499,7 @@ (void)EC; if (useNormalizedPaths()) - FileManager::removeDotPaths(Path, /*RemoveDotDot=*/true); + llvm::sys::path::remove_dots(Path, /*remove_dot_dot=*/true); if (Path.empty()) return false; @@ -572,7 +572,7 @@ (void)EC; if (FS.useNormalizedPaths()) - FileManager::removeDotPaths(Path, /*RemoveDotDot=*/true); + llvm::sys::path::remove_dots(Path, /*remove_dot_dot=*/true); if (Path.empty()) return Dir; Index: cfe/trunk/lib/Frontend/ModuleDependencyCollector.cpp =================================================================== --- cfe/trunk/lib/Frontend/ModuleDependencyCollector.cpp +++ cfe/trunk/lib/Frontend/ModuleDependencyCollector.cpp @@ -67,7 +67,7 @@ path::native(AbsoluteSrc); // TODO: We probably need to handle .. as well as . in order to have valid // input to the YAMLVFSWriter. - FileManager::removeDotPaths(AbsoluteSrc); + path::remove_dots(AbsoluteSrc); // Build the destination path. SmallString<256> Dest = Collector.getDest(); Index: cfe/trunk/lib/Serialization/ASTWriter.cpp =================================================================== --- cfe/trunk/lib/Serialization/ASTWriter.cpp +++ cfe/trunk/lib/Serialization/ASTWriter.cpp @@ -1112,7 +1112,7 @@ static bool cleanPathForOutput(FileManager &FileMgr, SmallVectorImpl &Path) { bool Changed = FileMgr.makeAbsolutePath(Path); - return Changed | FileMgr.removeDotPaths(Path); + return Changed | llvm::sys::path::remove_dots(Path); } /// \brief Adjusts the given filename to only write out the portion of the