summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBruno Cardoso Lopes <bruno.cardoso@gmail.com>2016-08-12 01:51:04 +0000
committerBruno Cardoso Lopes <bruno.cardoso@gmail.com>2016-08-12 01:51:04 +0000
commit1dc8a422812cdbc23edbf4856a49a2e15d3cc591 (patch)
tree5ccf2c9dee75aa7f8485f9170860e4514d2a0dc7
parentb40d8ad225a376d8032b261963113242a8d8102f (diff)
downloadbcm5719-llvm-1dc8a422812cdbc23edbf4856a49a2e15d3cc591.tar.gz
bcm5719-llvm-1dc8a422812cdbc23edbf4856a49a2e15d3cc591.zip
[VFS] Skip non existent files from the VFS tree
When the VFS uses a YAML file, the real file path for a virtual file is described in the "external-contents" field. Example: ... { 'type': 'file', 'name': 'a.h', 'external-contents': '/a/b/c/a.h' } Currently, when parsing umbrella directories, we use vfs::recursive_directory_iterator to gather the header files to generate the equivalent modules for. If the external contents for a header does not exist, we currently are unable to build a module, since the VFS vfs::recursive_directory_iterator will fail when it finds an entry without a reliable real path. Since the YAML file could be prepared ahead of time and shared among different compiler invocations, an entry might not yet have a reliable path in 'external-contents', breaking the iteration. Give the VFS the capability to skip such entries whenever 'ignore-non-existent-contents' property is set in the YAML file. rdar://problem/27531549 llvm-svn: 278457
-rw-r--r--clang/lib/Basic/VirtualFileSystem.cpp34
-rw-r--r--clang/test/VFS/Inputs/Bar.framework/Headers/A.h1
-rw-r--r--clang/test/VFS/Inputs/Bar.framework/Headers/B.h1
-rw-r--r--clang/test/VFS/Inputs/Bar.framework/Headers/C.h1
-rw-r--r--clang/test/VFS/Inputs/Bar.framework/Modules/module.modulemap6
-rw-r--r--clang/test/VFS/Inputs/bar-headers.yaml39
-rw-r--r--clang/test/VFS/umbrella-framework-import-skipnonexist.m14
7 files changed, 88 insertions, 8 deletions
diff --git a/clang/lib/Basic/VirtualFileSystem.cpp b/clang/lib/Basic/VirtualFileSystem.cpp
index 62a386b7352..a56c9115fb1 100644
--- a/clang/lib/Basic/VirtualFileSystem.cpp
+++ b/clang/lib/Basic/VirtualFileSystem.cpp
@@ -1778,29 +1778,47 @@ VFSFromYamlDirIterImpl::VFSFromYamlDirIterImpl(
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 (FS.ignoreNonExistentContents() &&
+ 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 (FS.ignoreNonExistentContents() &&
+ 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/clang/test/VFS/Inputs/Bar.framework/Headers/A.h b/clang/test/VFS/Inputs/Bar.framework/Headers/A.h
new file mode 100644
index 00000000000..975f1f0437b
--- /dev/null
+++ b/clang/test/VFS/Inputs/Bar.framework/Headers/A.h
@@ -0,0 +1 @@
+// A.h
diff --git a/clang/test/VFS/Inputs/Bar.framework/Headers/B.h b/clang/test/VFS/Inputs/Bar.framework/Headers/B.h
new file mode 100644
index 00000000000..761540b09cb
--- /dev/null
+++ b/clang/test/VFS/Inputs/Bar.framework/Headers/B.h
@@ -0,0 +1 @@
+// B.h
diff --git a/clang/test/VFS/Inputs/Bar.framework/Headers/C.h b/clang/test/VFS/Inputs/Bar.framework/Headers/C.h
new file mode 100644
index 00000000000..a0121d46b41
--- /dev/null
+++ b/clang/test/VFS/Inputs/Bar.framework/Headers/C.h
@@ -0,0 +1 @@
+// C.h
diff --git a/clang/test/VFS/Inputs/Bar.framework/Modules/module.modulemap b/clang/test/VFS/Inputs/Bar.framework/Modules/module.modulemap
new file mode 100644
index 00000000000..d5c759aceb7
--- /dev/null
+++ b/clang/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/clang/test/VFS/Inputs/bar-headers.yaml b/clang/test/VFS/Inputs/bar-headers.yaml
new file mode 100644
index 00000000000..846d55cc9ec
--- /dev/null
+++ b/clang/test/VFS/Inputs/bar-headers.yaml
@@ -0,0 +1,39 @@
+{
+ 'version': 0,
+ 'case-sensitive': 'false',
+ 'ignore-non-existent-contents': 'true',
+ '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/clang/test/VFS/umbrella-framework-import-skipnonexist.m b/clang/test/VFS/umbrella-framework-import-skipnonexist.m
new file mode 100644
index 00000000000..39af83139a7
--- /dev/null
+++ b/clang/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;
OpenPOWER on IntegriCloud