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 // NO-REWRITE-NOT: #include 33 // REWRITE: #include "a.h" 34 35 // CHECK: #pragma clang module begin nested.a 36 // NO-REWRITE-NOT: #include 37 // REWRITE: #include "c.h" 38 // CHECK: #pragma clang module begin nested.c 39 // CHECK: using T = int; 40 // CHECK: #pragma clang module end 41 // CHECK: T a(); 42 // CHECK: #pragma clang module end 43 44 // CHECK: #pragma clang module begin nested.b 45 // CHECK: #pragma clang module import nested.c 46 // CHECK-NOT: #pragma clang module begin nested.c 47 // CHECK-NOT: using T = int; 48 // CHECK-NOT: #pragma clang module end 49 // CHECK: T b(); 50 // CHECK: #pragma clang module end 51 52 // CHECK: #pragma clang module import nested.c 53 54 #pragma clang module import nested.b 55 56 int n = b(); 57 T c; // expected-error {{must be imported}} 58 #ifdef REWRITE 59 // expected-note@rewrite.ii:* {{declar}} 60 #else 61 // expected-note@no-rewrite.ii:* {{declar}} 62 #endif 63