1c5247e67SRichard Smith // RUN: rm -rf %t 2c5247e67SRichard Smith // RUN: mkdir %t 3c5247e67SRichard Smith 4c5247e67SRichard Smith // 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 5c5247e67SRichard Smith // 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 6c5247e67SRichard Smith 7c5247e67SRichard Smith // RUN: FileCheck %s --input-file %t/no-rewrite.ii --check-prefix=CHECK --check-prefix=NO-REWRITE 8c5247e67SRichard Smith // RUN: FileCheck %s --input-file %t/rewrite.ii --check-prefix=CHECK --check-prefix=REWRITE 9c5247e67SRichard Smith 10c5247e67SRichard Smith // Check that we can build a module from the preprocessed output. 11c5247e67SRichard Smith // 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 12c5247e67SRichard Smith // 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 13c5247e67SRichard Smith 14c5247e67SRichard Smith // Check the module we built works. 15c5247e67SRichard Smith // RUN: %clang_cc1 -fmodules -fmodule-file=%t/no-rewrite.pcm %s -I%t -verify -fno-modules-error-recovery 16c5247e67SRichard Smith // RUN: %clang_cc1 -fmodules -fmodule-file=%t/rewrite.pcm %s -I%t -verify -fno-modules-error-recovery -DREWRITE 17c5247e67SRichard Smith 18c5247e67SRichard Smith // == module map 19c5247e67SRichard Smith // CHECK: # 1 "{{.*}}module.modulemap" 20c5247e67SRichard Smith // CHECK: module nested { 21c5247e67SRichard Smith // CHECK: module a { 22c5247e67SRichard Smith // CHECK: header "a.h" 23c5247e67SRichard Smith // CHECK: } 24c5247e67SRichard Smith // CHECK: module b { 25c5247e67SRichard Smith // CHECK: header "b.h" 26c5247e67SRichard Smith // CHECK: } 27c5247e67SRichard Smith // CHECK: module c { 28c5247e67SRichard Smith // CHECK: header "c.h" 29c5247e67SRichard Smith // CHECK: } 30c5247e67SRichard Smith // CHECK: } 31c5247e67SRichard Smith 32*98768babSFangrui Song // NO-REWRITE-NOT: #include 33*98768babSFangrui Song // REWRITE: #include "a.h" 34*98768babSFangrui Song 35c5247e67SRichard Smith // CHECK: #pragma clang module begin nested.a 36*98768babSFangrui Song // NO-REWRITE-NOT: #include 37*98768babSFangrui Song // REWRITE: #include "c.h" 38c5247e67SRichard Smith // CHECK: #pragma clang module begin nested.c 39c5247e67SRichard Smith // CHECK: using T = int; 40c5247e67SRichard Smith // CHECK: #pragma clang module end 41c5247e67SRichard Smith // CHECK: T a(); 42c5247e67SRichard Smith // CHECK: #pragma clang module end 43c5247e67SRichard Smith 44c5247e67SRichard Smith // CHECK: #pragma clang module begin nested.b 45c5247e67SRichard Smith // CHECK: #pragma clang module import nested.c 46c5247e67SRichard Smith // CHECK-NOT: #pragma clang module begin nested.c 47c5247e67SRichard Smith // CHECK-NOT: using T = int; 48c5247e67SRichard Smith // CHECK-NOT: #pragma clang module end 49c5247e67SRichard Smith // CHECK: T b(); 50c5247e67SRichard Smith // CHECK: #pragma clang module end 51c5247e67SRichard Smith 52c5247e67SRichard Smith // CHECK: #pragma clang module import nested.c 53c5247e67SRichard Smith 54c5247e67SRichard Smith #pragma clang module import nested.b 55c5247e67SRichard Smith 56c5247e67SRichard Smith int n = b(); 57c5247e67SRichard Smith T c; // expected-error {{must be imported}} 58c5247e67SRichard Smith #ifdef REWRITE 59c5247e67SRichard Smith // [email protected]:* {{declar}} 60c5247e67SRichard Smith #else 61c5247e67SRichard Smith // [email protected]:* {{declar}} 62c5247e67SRichard Smith #endif 63