1+ // This test checks that imports of headers that appeared in a different submodule than
2+ // what is imported by the current TU don't affect the compilation.
3+
4+ // RUN: rm -rf %t
5+ // RUN: split-file %s %t
6+
7+ //--- C/C.h
8+ #include "Textual.h"
9+ //--- C/module.modulemap
10+ module C { header "C.h" }
11+
12+ //--- D/D1.h
13+ #include "Textual.h"
14+ //--- D/D2.h
15+ //--- D/module.modulemap
16+ module D {
17+ module D1 { header "D1.h" }
18+ module D2 { header "D2.h" }
19+ }
20+
21+ //--- E/E1.h
22+ #include "E2.h"
23+ //--- E/E2.h
24+ #include "Textual.h"
25+ //--- E/module.modulemap
26+ module E {
27+ module E1 { header "E1.h" }
28+ module E2 { header "E2.h" }
29+ }
30+
31+ //--- Textual.h
32+ #define MACRO_TEXTUAL 1
33+
34+ //--- test_top.c
35+ #import "Textual.h"
36+ static int x = MACRO_TEXTUAL ;
37+
38+ //--- test_sub.c
39+ #import "D/D2.h"
40+ #import "Textual.h"
41+ static int x = MACRO_TEXTUAL ;
42+
43+ //--- test_transitive.c
44+ #import "E/E1.h"
45+ #import "Textual.h"
46+ static int x = MACRO_TEXTUAL ;
47+
48+ // Simply loading a PCM file containing top-level module including a header does
49+ // not prevent inclusion of that header in the TU.
50+ //
51+ // RUN: %clang_cc1 -fmodules -I %t -emit-module %t/C/module.modulemap -fmodule-name=C -o %t/C.pcm
52+ // RUN: %clang_cc1 -fmodules -I %t -fsyntax-only %t/test_top.c -fmodule-file=%t/C.pcm
53+
54+ // Loading a PCM file and importing its empty submodule does not prevent
55+ // inclusion of headers included by invisible sibling submodules.
56+ //
57+ // RUN: %clang_cc1 -fmodules -I %t -emit-module %t/D/module.modulemap -fmodule-name=D -o %t/D.pcm
58+ // RUN: %clang_cc1 -fmodules -I %t -fsyntax-only %t/test_sub.c -fmodule-file=%t/D.pcm
59+
60+ // Loading a PCM file and importing a submodule does not prevent inclusion of
61+ // headers included by some of its transitive un-exported dependencies.
62+ //
63+ // RUN: %clang_cc1 -fmodules -I %t -emit-module %t/E/module.modulemap -fmodule-name=E -o %t/E.pcm
64+ // RUN: %clang_cc1 -fmodules -I %t -fsyntax-only %t/test_transitive.c -fmodule-file=%t/E.pcm
0 commit comments