Index: lib/Basic/VirtualFileSystem.cpp =================================================================== --- lib/Basic/VirtualFileSystem.cpp +++ lib/Basic/VirtualFileSystem.cpp @@ -933,6 +933,8 @@ RedirectingFileSystem &FS; RedirectingDirectoryEntry::iterator Current, End; + std::error_code incrementImpl(); + public: VFSFromYamlDirIterImpl(const Twine &Path, RedirectingFileSystem &FS, RedirectingDirectoryEntry::iterator Begin, @@ -1997,29 +1999,17 @@ 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 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 S = FS.status(PathStr); @@ -2027,6 +2017,7 @@ // 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();