xref: /aosp_15_r20/external/clang/test/Modules/require-modular-includes.m (revision 67e74705e28f6214e480b399dd47ea732279e315)
1*67e74705SXin Li// RUN: rm -rf %t
2*67e74705SXin Li
3*67e74705SXin Li// Including a header from the imported module
4*67e74705SXin Li// RUN: echo '@import FromImportedModuleOK;' | \
5*67e74705SXin Li// RUN:   %clang_cc1 -Wnon-modular-include-in-framework-module -fmodules -fimplicit-module-maps \
6*67e74705SXin Li// RUN:     -fmodules-cache-path=%t -F %S/Inputs/require-modular-includes \
7*67e74705SXin Li// RUN:     -Werror -fsyntax-only -x objective-c -
8*67e74705SXin Li
9*67e74705SXin Li// Including a non-modular header
10*67e74705SXin Li// RUN: echo '@import FromImportedModuleFail;' | \
11*67e74705SXin Li// RUN:   %clang_cc1 -Wnon-modular-include-in-framework-module -fmodules -fimplicit-module-maps \
12*67e74705SXin Li// RUN:     -fmodules-cache-path=%t -F %S/Inputs/require-modular-includes \
13*67e74705SXin Li// RUN:     -I %S/Inputs/require-modular-includes \
14*67e74705SXin Li// RUN:     -fsyntax-only -x objective-c - 2>&1 | FileCheck %s
15*67e74705SXin Li
16*67e74705SXin Li// Including a header from a subframework
17*67e74705SXin Li// RUN: echo '@import FromSubframework;' | \
18*67e74705SXin Li// RUN:   %clang_cc1 -Wnon-modular-include-in-framework-module -fmodules -fimplicit-module-maps \
19*67e74705SXin Li// RUN:     -fmodules-cache-path=%t -F %S/Inputs/require-modular-includes \
20*67e74705SXin Li// RUN:     -Werror -fsyntax-only -x objective-c -
21*67e74705SXin Li
22*67e74705SXin Li// Including a header from a subframework (fail)
23*67e74705SXin Li// RUN: echo '@import FromNonModularSubframework;' | \
24*67e74705SXin Li// RUN:   %clang_cc1 -Wnon-modular-include-in-framework-module -fmodules -fimplicit-module-maps \
25*67e74705SXin Li// RUN:     -fmodules-cache-path=%t -F %S/Inputs/require-modular-includes \
26*67e74705SXin Li// RUN:     -I %S/Inputs/require-modular-includes \
27*67e74705SXin Li// RUN:     -fsyntax-only -x objective-c - 2>&1 | FileCheck %s
28*67e74705SXin Li
29*67e74705SXin Li// Including a non-modular header from a submodule
30*67e74705SXin Li// RUN: echo '@import FromImportedSubModule;' | \
31*67e74705SXin Li// RUN:   %clang_cc1 -Wnon-modular-include-in-framework-module -fmodules -fimplicit-module-maps \
32*67e74705SXin Li// RUN:     -fmodules-cache-path=%t -F %S/Inputs/require-modular-includes \
33*67e74705SXin Li// RUN:     -I %S/Inputs/require-modular-includes \
34*67e74705SXin Li// RUN:     -fsyntax-only -x objective-c - 2>&1 | FileCheck %s
35*67e74705SXin Li
36*67e74705SXin Li// Including a non-modular header (directly) with -fmodule-name set
37*67e74705SXin Li// RUN: echo '#include "NotInModule.h"' | \
38*67e74705SXin Li// RUN:   %clang_cc1 -Wnon-modular-include-in-framework-module -fmodules -fimplicit-module-maps \
39*67e74705SXin Li// RUN:     -fmodules-cache-path=%t -I %S/Inputs/require-modular-includes \
40*67e74705SXin Li// RUN:     -Werror -fmodule-name=A -fsyntax-only -x objective-c -
41*67e74705SXin Li
42*67e74705SXin Li// Including an excluded header
43*67e74705SXin Li// RUN: echo '@import IncludeExcluded;' | \
44*67e74705SXin Li// RUN:   %clang_cc1 -Wnon-modular-include-in-framework-module -fmodules -fimplicit-module-maps \
45*67e74705SXin Li// RUN:     -fmodules-cache-path=%t -F %S/Inputs/require-modular-includes \
46*67e74705SXin Li// RUN:     -Werror -fsyntax-only -x objective-c -
47*67e74705SXin Li
48*67e74705SXin Li// Including a header from another module
49*67e74705SXin Li// RUN: echo '@import FromAnotherModule;' | \
50*67e74705SXin Li// RUN:   %clang_cc1 -Wnon-modular-include-in-framework-module -fmodules -fimplicit-module-maps \
51*67e74705SXin Li// RUN:     -fmodules-cache-path=%t -F %S/Inputs/require-modular-includes \
52*67e74705SXin Li// RUN:     -I %S/Inputs/require-modular-includes \
53*67e74705SXin Li// RUN:     -Werror -fsyntax-only -x objective-c -
54*67e74705SXin Li
55*67e74705SXin Li// Including an excluded header from another module
56*67e74705SXin Li// RUN: echo '@import ExcludedFromAnotherModule;' | \
57*67e74705SXin Li// RUN:   %clang_cc1 -Wnon-modular-include-in-framework-module -fmodules -fimplicit-module-maps \
58*67e74705SXin Li// RUN:     -fmodules-cache-path=%t -F %S/Inputs/require-modular-includes \
59*67e74705SXin Li// RUN:     -I %S/Inputs/require-modular-includes \
60*67e74705SXin Li// RUN:     -Werror -fsyntax-only -x objective-c -
61*67e74705SXin Li
62*67e74705SXin Li// Including a header from an umbrella directory
63*67e74705SXin Li// RUN: echo '@import FromUmbrella;' | \
64*67e74705SXin Li// RUN:   %clang_cc1 -Wnon-modular-include-in-framework-module -fmodules -fimplicit-module-maps \
65*67e74705SXin Li// RUN:     -fmodules-cache-path=%t -F %S/Inputs/require-modular-includes \
66*67e74705SXin Li// RUN:     -I %S/Inputs/require-modular-includes \
67*67e74705SXin Li// RUN:     -Werror -fsyntax-only -x objective-c -
68*67e74705SXin Li
69*67e74705SXin Li// A includes B includes non-modular C
70*67e74705SXin Li// RUN: echo '@import A;' | \
71*67e74705SXin Li// RUN:   %clang_cc1 -Wnon-modular-include-in-framework-module -fmodules -fimplicit-module-maps \
72*67e74705SXin Li// RUN:     -fmodules-cache-path=%t -F %S/Inputs/require-modular-includes \
73*67e74705SXin Li// RUN:     -I %S/Inputs/require-modular-includes \
74*67e74705SXin Li// RUN:     -fsyntax-only -x objective-c - 2>&1 | FileCheck %s
75*67e74705SXin Li
76*67e74705SXin Li// Non-framework module (pass)
77*67e74705SXin Li// RUN: echo '@import NotFramework;' | \
78*67e74705SXin Li// RUN:   %clang_cc1 -Wnon-modular-include-in-framework-module -fmodules -fimplicit-module-maps \
79*67e74705SXin Li// RUN:     -fmodules-cache-path=%t -I %S/Inputs/require-modular-includes \
80*67e74705SXin Li// RUN:     -Werror -fsyntax-only -x objective-c -
81*67e74705SXin Li
82*67e74705SXin Li// CHECK: include of non-modular header
83