summaryrefslogtreecommitdiffstats
path: root/test/VFS
diff options
context:
space:
mode:
authorBen Langmuir <blangmuir@apple.com>2014-05-23 18:15:47 +0000
committerBen Langmuir <blangmuir@apple.com>2014-05-23 18:15:47 +0000
commit68d890da0854b4257c2fc2ab461cd6bfacf05c82 (patch)
tree2702f6f054f8e91180832ce9a82338f0b598ad95 /test/VFS
parent4c92d444ffb0c65cfc85e60edca08d32fb10fdae (diff)
Stopgap fix for finding module for a file mapped in the VFS
If we lookup a path using its 'real' path first, we need to ensure that when we run header search we still use the VFS-mapped path or we will not be able to find the corresponding module for the header. The real problem is that we tie the name of a file to its underlying FileEntry, which is uniqued by inode, so we only ever get the first name it is looked up by. This doesn't work with modules, which rely on a specific file system structure. I'm hoping to have time to write up a proposal for fixing this more permanently soon, but as a stopgap this patch updates the name of the file's directory if it comes from a VFS mapping. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@209534 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/VFS')
-rw-r--r--test/VFS/Inputs/actual_module.map4
-rw-r--r--test/VFS/Inputs/import_some_frame.h2
-rw-r--r--test/VFS/Inputs/public_header.h1
-rw-r--r--test/VFS/Inputs/public_header2.h1
-rw-r--r--test/VFS/Inputs/some_frame_module.map5
-rw-r--r--test/VFS/Inputs/vfsoverlay.yaml16
-rw-r--r--test/VFS/real-path-found-first.m74
7 files changed, 101 insertions, 2 deletions
diff --git a/test/VFS/Inputs/actual_module.map b/test/VFS/Inputs/actual_module.map
index 282dac37c7..d2f5b64a38 100644
--- a/test/VFS/Inputs/actual_module.map
+++ b/test/VFS/Inputs/actual_module.map
@@ -2,3 +2,7 @@ module not_real {
header "not_real.h"
export *
}
+module import_some_frame {
+ header "import_some_frame.h"
+ export *
+}
diff --git a/test/VFS/Inputs/import_some_frame.h b/test/VFS/Inputs/import_some_frame.h
new file mode 100644
index 0000000000..c1f68c83fc
--- /dev/null
+++ b/test/VFS/Inputs/import_some_frame.h
@@ -0,0 +1,2 @@
+#import <SomeFramework/public_header.h>
+#import <SomeFramework/public_header2.h>
diff --git a/test/VFS/Inputs/public_header.h b/test/VFS/Inputs/public_header.h
index 471107762b..09d9969d31 100644
--- a/test/VFS/Inputs/public_header.h
+++ b/test/VFS/Inputs/public_header.h
@@ -1 +1,2 @@
+#import <SomeFramework/public_header2.h>
void from_framework(void);
diff --git a/test/VFS/Inputs/public_header2.h b/test/VFS/Inputs/public_header2.h
new file mode 100644
index 0000000000..d883613ac1
--- /dev/null
+++ b/test/VFS/Inputs/public_header2.h
@@ -0,0 +1 @@
+// public_header2.h
diff --git a/test/VFS/Inputs/some_frame_module.map b/test/VFS/Inputs/some_frame_module.map
new file mode 100644
index 0000000000..3ce59b254d
--- /dev/null
+++ b/test/VFS/Inputs/some_frame_module.map
@@ -0,0 +1,5 @@
+framework module SomeFramework {
+ umbrella header "public_header.h"
+ export *
+ module * { export * }
+}
diff --git a/test/VFS/Inputs/vfsoverlay.yaml b/test/VFS/Inputs/vfsoverlay.yaml
index 5c1380870d..0aa8cd619a 100644
--- a/test/VFS/Inputs/vfsoverlay.yaml
+++ b/test/VFS/Inputs/vfsoverlay.yaml
@@ -6,14 +6,26 @@
{ 'name': 'not_real.h', 'type': 'file',
'external-contents': 'INPUT_DIR/actual_header.h'
},
+ { 'name': 'import_some_frame.h', 'type': 'file',
+ 'external-contents': 'INPUT_DIR/import_some_frame.h'
+ },
{ 'name': 'module.map', 'type': 'file',
'external-contents': 'INPUT_DIR/actual_module.map'
},
{ 'name': 'include_real.h', 'type': 'file',
'external-contents': 'INPUT_DIR/include_real.h'
},
- { 'name': 'SomeFramework.framework/Headers/public_header.h', 'type': 'file',
- 'external-contents': 'INPUT_DIR/public_header.h'
+ { 'name': 'SomeFramework.framework', 'type': 'directory',
+ 'contents': [
+ { 'name': 'Headers', 'type': 'directory',
+ 'contents': [
+ { 'name': 'public_header.h', 'type': 'file',
+ 'external-contents': 'INPUT_DIR/public_header.h' },
+ { 'name': 'public_header2.h', 'type': 'file',
+ 'external-contents': 'INPUT_DIR/public_header2.h' }
+ ]
+ }
+ ]
},
{ 'name': 'Foo.framework/Headers/Foo.h', 'type': 'file',
'external-contents': 'INPUT_DIR/Foo.h'
diff --git a/test/VFS/real-path-found-first.m b/test/VFS/real-path-found-first.m
new file mode 100644
index 0000000000..f494c6eb15
--- /dev/null
+++ b/test/VFS/real-path-found-first.m
@@ -0,0 +1,74 @@
+// This test is for cases where we lookup a file by its 'real' path before we
+// use its VFS-mapped path. If we accidentally use the real path in header
+// search, we will not find a module for the headers. To test that we
+// intentionally rebuild modules, since the precompiled module file refers to
+// the dependency files by real path.
+
+// REQUIRES: shell
+// RUN: rm -rf %t %t-cache %t.pch
+// RUN: mkdir -p %t/SomeFramework.framework/Modules
+// RUN: cp %S/Inputs/some_frame_module.map %t/SomeFramework.framework/Modules/module.modulemap
+// RUN: sed -e "s:INPUT_DIR:%S/Inputs:g" -e "s:OUT_DIR:%t:g" %S/Inputs/vfsoverlay.yaml > %t.yaml
+
+// Build
+// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t-cache -F %t \
+// RUN: -ivfsoverlay %t.yaml -fsyntax-only %s -verify -Wauto-import \
+// RUN: -Werror=non-modular-include-in-framework-module
+
+// Rebuild
+// RUN: echo ' ' >> %t/SomeFramework.framework/Modules/module.modulemap
+// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t-cache -F %t \
+// RUN: -ivfsoverlay %t.yaml -fsyntax-only %s -verify -Wauto-import \
+// RUN: -Werror=non-modular-include-in-framework-module
+
+// Load from PCH
+// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t-cache -F %t \
+// RUN: -ivfsoverlay %t.yaml -emit-pch %s -o %t.pch \
+// RUN: -Werror=non-modular-include-in-framework-module \
+// RUN: -fmodules-ignore-macro=WITH_PREFIX
+// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t-cache -F %t \
+// RUN: -ivfsoverlay %t.yaml -include-pch %t.pch -fsyntax-only %s \
+// RUN: -Werror=non-modular-include-in-framework-module -DWITH_PREFIX \
+// RUN: -fmodules-ignore-macro=WITH_PREFIX
+
+// While indexing
+// RUN: c-index-test -index-file %s -fmodules -fmodules-cache-path=%t-cache -F %t \
+// RUN: -ivfsoverlay %t.yaml -fsyntax-only -Wauto-import \
+// RUN: -Werror=non-modular-include-in-framework-module | FileCheck %s
+// RUN: echo ' ' >> %t/SomeFramework.framework/Modules/module.modulemap
+// RUN: c-index-test -index-file %s -fmodules -fmodules-cache-path=%t-cache -F %t \
+// RUN: -ivfsoverlay %t.yaml -fsyntax-only -Wauto-import \
+// RUN: -Werror=non-modular-include-in-framework-module | FileCheck %s
+// CHECK: warning: treating
+// CHECK-NOT: error
+
+// With a VFS-mapped module map file
+// RUN: mv %t/SomeFramework.framework/Modules/module.modulemap %t/hide_module.map
+// RUN: echo "{ 'version': 0, 'roots': [ { " > %t2.yaml
+// RUN: echo "'name': '%t/SomeFramework.framework/Modules/module.modulemap'," >> %t2.yaml
+// RUN: echo "'type': 'file', 'external-contents': '%t/hide_module.map' } ] }" >> %t2.yaml
+
+// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t-cache -F %t \
+// RUN: -ivfsoverlay %t.yaml -ivfsoverlay %t2.yaml -fsyntax-only %s -verify \
+// RUN: -Wauto-import -Werror=non-modular-include-in-framework-module
+// RUN: echo ' ' >> %t/hide_module.map
+// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t-cache -F %t \
+// RUN: -ivfsoverlay %t.yaml -ivfsoverlay %t2.yaml -fsyntax-only %s -verify \
+// RUN: -Wauto-import -Werror=non-modular-include-in-framework-module
+
+// Within a module build
+// RUN: echo '@import import_some_frame;' | \
+// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t-cache -F %t \
+// RUN: -ivfsoverlay %t.yaml -ivfsoverlay %t2.yaml -fsyntax-only - \
+// RUN: -Werror=non-modular-include-in-framework-module -x objective-c -I %t
+// RUN: echo ' ' >> %t/hide_module.map
+// RUN: echo '@import import_some_frame;' | \
+// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t-cache -F %t \
+// RUN: -ivfsoverlay %t.yaml -ivfsoverlay %t2.yaml -fsyntax-only - \
+// RUN: -Werror=non-modular-include-in-framework-module -x objective-c -I %t
+
+#ifndef WITH_PREFIX
+#import <SomeFramework/public_header.h> // expected-warning{{treating}}
+#import <SomeFramework/public_header2.h> // expected-warning{{treating}}
+@import SomeFramework.public_header2;
+#endif