summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--clang/include/clang/Basic/FileManager.h3
-rw-r--r--clang/lib/Basic/FileManager.cpp35
-rw-r--r--clang/lib/Basic/VirtualFileSystem.cpp4
-rw-r--r--clang/lib/Frontend/ModuleDependencyCollector.cpp2
-rw-r--r--clang/lib/Serialization/ASTWriter.cpp2
5 files changed, 5 insertions, 41 deletions
diff --git a/clang/include/clang/Basic/FileManager.h b/clang/include/clang/Basic/FileManager.h
index c76da25dd54..cf74d4951d8 100644
--- a/clang/include/clang/Basic/FileManager.h
+++ b/clang/include/clang/Basic/FileManager.h
@@ -273,9 +273,6 @@ public:
static void modifyFileEntry(FileEntry *File, off_t Size,
time_t ModificationTime);
- /// \brief Remove any './' components from a path.
- static bool removeDotPaths(SmallVectorImpl<char> &Path, bool RemoveDotDot = false);
-
/// \brief Retrieve the canonical name for a given directory.
///
/// This is a very expensive operation, despite its results being cached,
diff --git a/clang/lib/Basic/FileManager.cpp b/clang/lib/Basic/FileManager.cpp
index 21e6ea3ab4b..8a523d26dec 100644
--- a/clang/lib/Basic/FileManager.cpp
+++ b/clang/lib/Basic/FileManager.cpp
@@ -526,39 +526,6 @@ void FileManager::modifyFileEntry(FileEntry *File,
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<char> &Path, bool RemoveDotDot) {
- using namespace llvm::sys;
-
- SmallVector<StringRef, 16> 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<const DirectoryEntry *, llvm::StringRef>::iterator Known
@@ -582,7 +549,7 @@ StringRef FileManager::getCanonicalName(const DirectoryEntry *Dir) {
// '..' 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
diff --git a/clang/lib/Basic/VirtualFileSystem.cpp b/clang/lib/Basic/VirtualFileSystem.cpp
index a20132b3de8..8acf0a997d5 100644
--- a/clang/lib/Basic/VirtualFileSystem.cpp
+++ b/clang/lib/Basic/VirtualFileSystem.cpp
@@ -499,7 +499,7 @@ bool InMemoryFileSystem::addFile(const Twine &P, time_t ModificationTime,
(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 @@ lookupInMemoryNode(const InMemoryFileSystem &FS, detail::InMemoryDirectory *Dir,
(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;
diff --git a/clang/lib/Frontend/ModuleDependencyCollector.cpp b/clang/lib/Frontend/ModuleDependencyCollector.cpp
index 78bb0279d90..9768a164acb 100644
--- a/clang/lib/Frontend/ModuleDependencyCollector.cpp
+++ b/clang/lib/Frontend/ModuleDependencyCollector.cpp
@@ -67,7 +67,7 @@ std::error_code ModuleDependencyListener::copyToRoot(StringRef Src) {
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();
diff --git a/clang/lib/Serialization/ASTWriter.cpp b/clang/lib/Serialization/ASTWriter.cpp
index 8fc32eaaa93..5508b6eceac 100644
--- a/clang/lib/Serialization/ASTWriter.cpp
+++ b/clang/lib/Serialization/ASTWriter.cpp
@@ -1112,7 +1112,7 @@ void ASTWriter::WriteBlockInfoBlock() {
static bool cleanPathForOutput(FileManager &FileMgr,
SmallVectorImpl<char> &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
OpenPOWER on IntegriCloud