[llvm] b439a08 - [llvm][vfs] NFC: Promote `InMemoryDirIterator` to nested class
Jan Svoboda via llvm-commits
llvm-commits at lists.llvm.org
Tue Jun 21 07:30:05 PDT 2022
Author: Jan Svoboda
Date: 2022-06-21T16:29:54+02:00
New Revision: b439a08dfc1054cb4d1226b84516b5cc13e41178
URL: https://github.com/llvm/llvm-project/commit/b439a08dfc1054cb4d1226b84516b5cc13e41178
DIFF: https://github.com/llvm/llvm-project/commit/b439a08dfc1054cb4d1226b84516b5cc13e41178.diff
LOG: [llvm][vfs] NFC: Promote `InMemoryDirIterator` to nested class
Added:
Modified:
llvm/include/llvm/Support/VirtualFileSystem.h
llvm/lib/Support/VirtualFileSystem.cpp
Removed:
################################################################################
diff --git a/llvm/include/llvm/Support/VirtualFileSystem.h b/llvm/include/llvm/Support/VirtualFileSystem.h
index d1f5dbf6465f..d310305b14e1 100644
--- a/llvm/include/llvm/Support/VirtualFileSystem.h
+++ b/llvm/include/llvm/Support/VirtualFileSystem.h
@@ -498,6 +498,8 @@ class InMemoryFileSystem : public FileSystem {
ErrorOr<const detail::InMemoryNode *> lookupNode(const Twine &P) const;
+ class DirIterator;
+
public:
explicit InMemoryFileSystem(bool UseNormalizedPaths = true);
~InMemoryFileSystem() override;
diff --git a/llvm/lib/Support/VirtualFileSystem.cpp b/llvm/lib/Support/VirtualFileSystem.cpp
index 9dc77b953ddf..2f457e15d577 100644
--- a/llvm/lib/Support/VirtualFileSystem.cpp
+++ b/llvm/lib/Support/VirtualFileSystem.cpp
@@ -980,10 +980,8 @@ InMemoryFileSystem::openFileForRead(const Twine &Path) {
return make_error_code(llvm::errc::invalid_argument);
}
-namespace {
-
/// Adaptor from InMemoryDir::iterator to directory_iterator.
-class InMemoryDirIterator : public llvm::vfs::detail::DirIterImpl {
+class InMemoryFileSystem::DirIterator : public llvm::vfs::detail::DirIterImpl {
detail::InMemoryDirectory::const_iterator I;
detail::InMemoryDirectory::const_iterator E;
std::string RequestedDirName;
@@ -1011,10 +1009,10 @@ class InMemoryDirIterator : public llvm::vfs::detail::DirIterImpl {
}
public:
- InMemoryDirIterator() = default;
+ DirIterator() = default;
- explicit InMemoryDirIterator(const detail::InMemoryDirectory &Dir,
- std::string RequestedDirName)
+ explicit DirIterator(const detail::InMemoryDirectory &Dir,
+ std::string RequestedDirName)
: I(Dir.begin()), E(Dir.end()),
RequestedDirName(std::move(RequestedDirName)) {
setCurrentEntry();
@@ -1027,22 +1025,20 @@ class InMemoryDirIterator : public llvm::vfs::detail::DirIterImpl {
}
};
-} // namespace
-
directory_iterator InMemoryFileSystem::dir_begin(const Twine &Dir,
std::error_code &EC) {
auto Node = lookupNode(Dir);
if (!Node) {
EC = Node.getError();
- return directory_iterator(std::make_shared<InMemoryDirIterator>());
+ return directory_iterator(std::make_shared<DirIterator>());
}
if (auto *DirNode = dyn_cast<detail::InMemoryDirectory>(*Node))
return directory_iterator(
- std::make_shared<InMemoryDirIterator>(*DirNode, Dir.str()));
+ std::make_shared<DirIterator>(*DirNode, Dir.str()));
EC = make_error_code(llvm::errc::not_a_directory);
- return directory_iterator(std::make_shared<InMemoryDirIterator>());
+ return directory_iterator(std::make_shared<DirIterator>());
}
std::error_code InMemoryFileSystem::setCurrentWorkingDirectory(const Twine &P) {
More information about the llvm-commits
mailing list