Merge remote-tracking branch 'origin/swift-3.0-branch' into stable
* origin/swift-3.0-branch:
[VFS] Skip non existent files from the VFS tree
diff --git a/lib/Basic/VirtualFileSystem.cpp b/lib/Basic/VirtualFileSystem.cpp
index 5a83424..ba10186 100644
--- a/lib/Basic/VirtualFileSystem.cpp
+++ b/lib/Basic/VirtualFileSystem.cpp
@@ -1756,29 +1756,45 @@
RedirectingDirectoryEntry::iterator Begin,
RedirectingDirectoryEntry::iterator End, std::error_code &EC)
: Dir(_Path.str()), FS(FS), Current(Begin), End(End) {
- if (Current != 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)
+ if (S) {
CurrentEntry = *S;
- else
+ return;
+ }
+ // Skip entries which do not map to a reliable external content.
+ if (S.getError() == llvm::errc::no_such_file_or_directory) {
+ ++Current;
+ continue;
+ } else {
EC = S.getError();
+ break;
+ }
}
}
std::error_code VFSFromYamlDirIterImpl::increment() {
assert(Current != End && "cannot iterate past end");
- if (++Current != 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)
- return S.getError();
+ if (!S) {
+ // Skip entries which do not map to a reliable external content.
+ if (S.getError() == llvm::errc::no_such_file_or_directory) {
+ continue;
+ } else {
+ return S.getError();
+ }
+ }
CurrentEntry = *S;
- } else {
- CurrentEntry = Status();
+ break;
}
+
+ if (Current == End)
+ CurrentEntry = Status();
return std::error_code();
}
diff --git a/test/VFS/Inputs/Bar.framework/Headers/A.h b/test/VFS/Inputs/Bar.framework/Headers/A.h
new file mode 100644
index 0000000..975f1f0
--- /dev/null
+++ b/test/VFS/Inputs/Bar.framework/Headers/A.h
@@ -0,0 +1 @@
+// A.h
diff --git a/test/VFS/Inputs/Bar.framework/Headers/B.h b/test/VFS/Inputs/Bar.framework/Headers/B.h
new file mode 100644
index 0000000..761540b
--- /dev/null
+++ b/test/VFS/Inputs/Bar.framework/Headers/B.h
@@ -0,0 +1 @@
+// B.h
diff --git a/test/VFS/Inputs/Bar.framework/Headers/C.h b/test/VFS/Inputs/Bar.framework/Headers/C.h
new file mode 100644
index 0000000..a0121d4
--- /dev/null
+++ b/test/VFS/Inputs/Bar.framework/Headers/C.h
@@ -0,0 +1 @@
+// C.h
diff --git a/test/VFS/Inputs/Bar.framework/Modules/module.modulemap b/test/VFS/Inputs/Bar.framework/Modules/module.modulemap
new file mode 100644
index 0000000..d5c759a
--- /dev/null
+++ b/test/VFS/Inputs/Bar.framework/Modules/module.modulemap
@@ -0,0 +1,6 @@
+framework module Bar [extern_c] {
+ umbrella "Headers"
+ export *
+ module * { export * }
+}
+
diff --git a/test/VFS/Inputs/bar-headers.yaml b/test/VFS/Inputs/bar-headers.yaml
new file mode 100644
index 0000000..710e6cb
--- /dev/null
+++ b/test/VFS/Inputs/bar-headers.yaml
@@ -0,0 +1,38 @@
+{
+ 'version': 0,
+ 'case-sensitive': 'false',
+ 'roots': [
+ {
+ 'type': 'directory',
+ 'name': "VDIR/Bar.framework/Headers",
+ 'contents': [
+ {
+ 'type': 'file',
+ 'name': "A.h",
+ 'external-contents': "OUT_DIR/Bar.framework/Headers/A.h"
+ },
+ {
+ 'type': 'file',
+ 'name': "B.h",
+ 'external-contents': "OUT_DIR/Bar.framework/Headers/B.h"
+ },
+ {
+ 'type': 'file',
+ 'name': "C.h",
+ 'external-contents': "OUT_DIR/Bar.framework/Headers/C.h"
+ }
+ ]
+ },
+ {
+ 'type': 'directory',
+ 'name': "VDIR/Bar.framework/Modules",
+ 'contents': [
+ {
+ 'type': 'file',
+ 'name': "module.modulemap",
+ 'external-contents': "OUT_DIR/Bar.framework/Modules/module.modulemap"
+ }
+ ]
+ },
+ ]
+}
diff --git a/test/VFS/umbrella-framework-import-skipnonexist.m b/test/VFS/umbrella-framework-import-skipnonexist.m
new file mode 100644
index 0000000..39af831
--- /dev/null
+++ b/test/VFS/umbrella-framework-import-skipnonexist.m
@@ -0,0 +1,14 @@
+// REQUIRES: crash-recovery, shell
+
+// FIXME: This XFAIL is cargo-culted from crash-report.c. Do we need it?
+// XFAIL: mingw32
+
+// RUN: rm -rf %t
+// RUN: mkdir -p %t/vdir %t/outdir %t/cache
+// RUN: cp -a %S/Inputs/Bar.Framework %t/outdir
+//
+// RUN: sed -e "s:VDIR:%t/vdir:g" -e "s:OUT_DIR:%t/outdir:g" %S/Inputs/bar-headers.yaml > %t/vdir/bar-headers.yaml
+// RUN: rm -f %t/outdir/Bar.framework/Headers/B.h
+// RUN: %clang_cc1 -fmodules -fimplicit-module-maps -fmodules-cache-path=%t/cache -ivfsoverlay %t/vdir/bar-headers.yaml -F %t/vdir -fsyntax-only %s
+
+@import Bar;