[PATCH] D50118: [VFS] Unify iteration code for VFSFromYamlDirIterImpl, NFC intended.
Volodymyr Sapsai via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Tue Jul 31 16:43:54 PDT 2018
vsapsai created this revision.
vsapsai added reviewers: bruno, benlangmuir.
Herald added a subscriber: dexonsmith.
First and subsequent iteration steps are similar, capture this similarity.
https://reviews.llvm.org/D50118
Files:
clang/lib/Basic/VirtualFileSystem.cpp
Index: clang/lib/Basic/VirtualFileSystem.cpp
===================================================================
--- clang/lib/Basic/VirtualFileSystem.cpp
+++ clang/lib/Basic/VirtualFileSystem.cpp
@@ -896,6 +896,8 @@
RedirectingFileSystem &FS;
RedirectingDirectoryEntry::iterator Current, End;
+ std::error_code incrementImpl();
+
public:
VFSFromYamlDirIterImpl(const Twine &Path, RedirectingFileSystem &FS,
RedirectingDirectoryEntry::iterator Begin,
@@ -1948,36 +1950,25 @@
RedirectingDirectoryEntry::iterator Begin,
RedirectingDirectoryEntry::iterator End, std::error_code &EC)
: Dir(_Path.str()), FS(FS), Current(Begin), End(End) {
- while (Current != End) {
- SmallString<128> PathStr(Dir);
- llvm::sys::path::append(PathStr, (*Current)->getName());
- llvm::ErrorOr<vfs::Status> S = FS.status(PathStr);
- if (S) {
- CurrentEntry = *S;
- return;
- }
- // Skip entries which do not map to a reliable external content.
- if (FS.ignoreNonExistentContents() &&
- S.getError() == llvm::errc::no_such_file_or_directory) {
- ++Current;
- continue;
- } else {
- EC = S.getError();
- break;
- }
- }
+ EC = incrementImpl();
}
std::error_code VFSFromYamlDirIterImpl::increment() {
assert(Current != End && "cannot iterate past end");
- while (++Current != End) {
+ ++Current;
+ return incrementImpl();
+}
+
+std::error_code VFSFromYamlDirIterImpl::incrementImpl() {
+ while (Current != End) {
SmallString<128> PathStr(Dir);
llvm::sys::path::append(PathStr, (*Current)->getName());
llvm::ErrorOr<vfs::Status> S = FS.status(PathStr);
if (!S) {
// Skip entries which do not map to a reliable external content.
if (FS.ignoreNonExistentContents() &&
S.getError() == llvm::errc::no_such_file_or_directory) {
+ ++Current;
continue;
} else {
return S.getError();
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D50118.158420.patch
Type: text/x-patch
Size: 1956 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20180731/02d36fbb/attachment-0001.bin>
More information about the cfe-commits
mailing list