blob: f494c6eb1534fcffad6f2bd21894b7d897036b49 [file] [log] [blame]
Stephen Hines6bcf27b2014-05-29 04:14:42 -07001// This test is for cases where we lookup a file by its 'real' path before we
2// use its VFS-mapped path. If we accidentally use the real path in header
3// search, we will not find a module for the headers. To test that we
4// intentionally rebuild modules, since the precompiled module file refers to
5// the dependency files by real path.
6
7// REQUIRES: shell
8// RUN: rm -rf %t %t-cache %t.pch
9// RUN: mkdir -p %t/SomeFramework.framework/Modules
10// RUN: cp %S/Inputs/some_frame_module.map %t/SomeFramework.framework/Modules/module.modulemap
11// RUN: sed -e "s:INPUT_DIR:%S/Inputs:g" -e "s:OUT_DIR:%t:g" %S/Inputs/vfsoverlay.yaml > %t.yaml
12
13// Build
14// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t-cache -F %t \
15// RUN: -ivfsoverlay %t.yaml -fsyntax-only %s -verify -Wauto-import \
16// RUN: -Werror=non-modular-include-in-framework-module
17
18// Rebuild
19// RUN: echo ' ' >> %t/SomeFramework.framework/Modules/module.modulemap
20// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t-cache -F %t \
21// RUN: -ivfsoverlay %t.yaml -fsyntax-only %s -verify -Wauto-import \
22// RUN: -Werror=non-modular-include-in-framework-module
23
24// Load from PCH
25// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t-cache -F %t \
26// RUN: -ivfsoverlay %t.yaml -emit-pch %s -o %t.pch \
27// RUN: -Werror=non-modular-include-in-framework-module \
28// RUN: -fmodules-ignore-macro=WITH_PREFIX
29// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t-cache -F %t \
30// RUN: -ivfsoverlay %t.yaml -include-pch %t.pch -fsyntax-only %s \
31// RUN: -Werror=non-modular-include-in-framework-module -DWITH_PREFIX \
32// RUN: -fmodules-ignore-macro=WITH_PREFIX
33
34// While indexing
35// RUN: c-index-test -index-file %s -fmodules -fmodules-cache-path=%t-cache -F %t \
36// RUN: -ivfsoverlay %t.yaml -fsyntax-only -Wauto-import \
37// RUN: -Werror=non-modular-include-in-framework-module | FileCheck %s
38// RUN: echo ' ' >> %t/SomeFramework.framework/Modules/module.modulemap
39// RUN: c-index-test -index-file %s -fmodules -fmodules-cache-path=%t-cache -F %t \
40// RUN: -ivfsoverlay %t.yaml -fsyntax-only -Wauto-import \
41// RUN: -Werror=non-modular-include-in-framework-module | FileCheck %s
42// CHECK: warning: treating
43// CHECK-NOT: error
44
45// With a VFS-mapped module map file
46// RUN: mv %t/SomeFramework.framework/Modules/module.modulemap %t/hide_module.map
47// RUN: echo "{ 'version': 0, 'roots': [ { " > %t2.yaml
48// RUN: echo "'name': '%t/SomeFramework.framework/Modules/module.modulemap'," >> %t2.yaml
49// RUN: echo "'type': 'file', 'external-contents': '%t/hide_module.map' } ] }" >> %t2.yaml
50
51// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t-cache -F %t \
52// RUN: -ivfsoverlay %t.yaml -ivfsoverlay %t2.yaml -fsyntax-only %s -verify \
53// RUN: -Wauto-import -Werror=non-modular-include-in-framework-module
54// RUN: echo ' ' >> %t/hide_module.map
55// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t-cache -F %t \
56// RUN: -ivfsoverlay %t.yaml -ivfsoverlay %t2.yaml -fsyntax-only %s -verify \
57// RUN: -Wauto-import -Werror=non-modular-include-in-framework-module
58
59// Within a module build
60// RUN: echo '@import import_some_frame;' | \
61// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t-cache -F %t \
62// RUN: -ivfsoverlay %t.yaml -ivfsoverlay %t2.yaml -fsyntax-only - \
63// RUN: -Werror=non-modular-include-in-framework-module -x objective-c -I %t
64// RUN: echo ' ' >> %t/hide_module.map
65// RUN: echo '@import import_some_frame;' | \
66// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t-cache -F %t \
67// RUN: -ivfsoverlay %t.yaml -ivfsoverlay %t2.yaml -fsyntax-only - \
68// RUN: -Werror=non-modular-include-in-framework-module -x objective-c -I %t
69
70#ifndef WITH_PREFIX
71#import <SomeFramework/public_header.h> // expected-warning{{treating}}
72#import <SomeFramework/public_header2.h> // expected-warning{{treating}}
73@import SomeFramework.public_header2;
74#endif