summaryrefslogtreecommitdiffstats
path: root/clang/lib/Basic/VirtualFileSystem.cpp
diff options
context:
space:
mode:
authorVolodymyr Sapsai <vsapsai@apple.com>2018-08-07 23:00:40 +0000
committerVolodymyr Sapsai <vsapsai@apple.com>2018-08-07 23:00:40 +0000
commit3aa88b5bd9f9cae8e910c2344af7cd14ad93df19 (patch)
tree34fc533c67cf18b5b1ed623f196c930f9b892a14 /clang/lib/Basic/VirtualFileSystem.cpp
parent9f9462acf6d95c204849492e5a997f26465ecd0f (diff)
downloadbcm5719-llvm-3aa88b5bd9f9cae8e910c2344af7cd14ad93df19.tar.gz
bcm5719-llvm-3aa88b5bd9f9cae8e910c2344af7cd14ad93df19.zip
[VFS] Unify iteration code for VFSFromYamlDirIterImpl, NFC intended.
First and subsequent iteration steps are similar, capture this similarity. Reviewers: bruno, benlangmuir Reviewed By: bruno Subscribers: dexonsmith, cfe-commits Differential Revision: https://reviews.llvm.org/D50118 llvm-svn: 339199
Diffstat (limited to 'clang/lib/Basic/VirtualFileSystem.cpp')
-rw-r--r--clang/lib/Basic/VirtualFileSystem.cpp29
1 files changed, 10 insertions, 19 deletions
diff --git a/clang/lib/Basic/VirtualFileSystem.cpp b/clang/lib/Basic/VirtualFileSystem.cpp
index c0cf48d3660..c0dc619129b 100644
--- a/clang/lib/Basic/VirtualFileSystem.cpp
+++ b/clang/lib/Basic/VirtualFileSystem.cpp
@@ -933,6 +933,8 @@ class VFSFromYamlDirIterImpl : public clang::vfs::detail::DirIterImpl {
RedirectingFileSystem &FS;
RedirectingDirectoryEntry::iterator Current, End;
+ std::error_code incrementImpl();
+
public:
VFSFromYamlDirIterImpl(const Twine &Path, RedirectingFileSystem &FS,
RedirectingDirectoryEntry::iterator Begin,
@@ -1997,29 +1999,17 @@ VFSFromYamlDirIterImpl::VFSFromYamlDirIterImpl(
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);
@@ -2027,6 +2017,7 @@ std::error_code VFSFromYamlDirIterImpl::increment() {
// 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();
OpenPOWER on IntegriCloud