1 | // RUN: rm -rf %t |
2 | // RUN: mkdir %t |
3 | |
4 | // RUN: %clang_cc1 -fmodules -fmodules-local-submodule-visibility -fmodule-name=nested -I%S/Inputs/preprocess -x c++-module-map %S/Inputs/preprocess/module.modulemap -E -o %t/no-rewrite.ii |
5 | // RUN: %clang_cc1 -fmodules -fmodules-local-submodule-visibility -fmodule-name=nested -I%S/Inputs/preprocess -x c++-module-map %S/Inputs/preprocess/module.modulemap -E -frewrite-includes -o %t/rewrite.ii |
6 | |
7 | // RUN: FileCheck %s --input-file %t/no-rewrite.ii --check-prefix=CHECK --check-prefix=NO-REWRITE |
8 | // RUN: FileCheck %s --input-file %t/rewrite.ii --check-prefix=CHECK --check-prefix=REWRITE |
9 | |
10 | // Check that we can build a module from the preprocessed output. |
11 | // RUN: %clang_cc1 -fmodules -fmodules-local-submodule-visibility -fmodule-name=nested -x c++-module-map-cpp-output %t/no-rewrite.ii -emit-module -o %t/no-rewrite.pcm |
12 | // RUN: %clang_cc1 -fmodules -fmodules-local-submodule-visibility -fmodule-name=nested -x c++-module-map-cpp-output %t/rewrite.ii -emit-module -o %t/rewrite.pcm |
13 | |
14 | // Check the module we built works. |
15 | // RUN: %clang_cc1 -fmodules -fmodule-file=%t/no-rewrite.pcm %s -I%t -verify -fno-modules-error-recovery |
16 | // RUN: %clang_cc1 -fmodules -fmodule-file=%t/rewrite.pcm %s -I%t -verify -fno-modules-error-recovery -DREWRITE |
17 | |
18 | // == module map |
19 | // CHECK: # 1 "{{.*}}module.modulemap" |
20 | // CHECK: module nested { |
21 | // CHECK: module a { |
22 | // CHECK: header "a.h" |
23 | // CHECK: } |
24 | // CHECK: module b { |
25 | // CHECK: header "b.h" |
26 | // CHECK: } |
27 | // CHECK: module c { |
28 | // CHECK: header "c.h" |
29 | // CHECK: } |
30 | // CHECK: } |
31 | |
32 | // CHECK: #pragma clang module begin nested.a |
33 | // CHECK: #pragma clang module begin nested.c |
34 | // CHECK: using T = int; |
35 | // CHECK: #pragma clang module end |
36 | // CHECK: T a(); |
37 | // CHECK: #pragma clang module end |
38 | |
39 | // CHECK: #pragma clang module begin nested.b |
40 | // CHECK: #pragma clang module import nested.c |
41 | // CHECK-NOT: #pragma clang module begin nested.c |
42 | // CHECK-NOT: using T = int; |
43 | // CHECK-NOT: #pragma clang module end |
44 | // CHECK: T b(); |
45 | // CHECK: #pragma clang module end |
46 | |
47 | // CHECK: #pragma clang module import nested.c |
48 | |
49 | #pragma clang module import nested.b |
50 | |
51 | int n = b(); |
52 | T c; // expected-error {{must be imported}} |
53 | #ifdef REWRITE |
54 | // expected-note@rewrite.ii:* {{declar}} |
55 | #else |
56 | // expected-note@no-rewrite.ii:* {{declar}} |
57 | #endif |
58 | |