Richard Smith | f74d946 | 2017-04-28 01:49:42 +0000 | [diff] [blame] | 1 | // RUN: rm -rf %t |
| 2 | |
| 3 | // RUN: not %clang_cc1 -fmodules -fmodule-name=file -I%S/Inputs/preprocess -x c++-module-map %S/Inputs/preprocess/module.modulemap -E 2>&1 | FileCheck %s --check-prefix=MISSING-FWD |
| 4 | // MISSING-FWD: module 'fwd' is needed |
| 5 | |
Richard Smith | d138630 | 2017-05-04 00:29:54 +0000 | [diff] [blame^] | 6 | // RUN: %clang_cc1 -fmodules -fmodule-name=file -fmodules-cache-path=%t -I%S/Inputs/preprocess -x c++-module-map %S/Inputs/preprocess/module.modulemap -E | FileCheck %s --check-prefix=CHECK --check-prefix=NO-REWRITE |
| 7 | // RUN: %clang_cc1 -fmodules -fmodule-name=file -fmodules-cache-path=%t -I%S/Inputs/preprocess -x c++-module-map %S/Inputs/preprocess/module.modulemap -E -frewrite-includes | FileCheck %s --check-prefix=CHECK --check-prefix=REWRITE |
| 8 | |
| 9 | // == file.h |
Richard Smith | f74d946 | 2017-04-28 01:49:42 +0000 | [diff] [blame] | 10 | // CHECK: # 1 "<module-includes>" |
Richard Smith | d138630 | 2017-05-04 00:29:54 +0000 | [diff] [blame^] | 11 | // REWRITE: #if 0 |
| 12 | // REWRITE: #include "file.h" |
| 13 | // REWRITE: #endif |
| 14 | // |
| 15 | // FIXME: It would be preferable to consistently put the module begin/end in |
| 16 | // the same file, but the relative ordering of PP callbacks and module |
| 17 | // begin/end tokens makes that difficult. |
| 18 | // |
| 19 | // REWRITE: #pragma clang module begin file |
Richard Smith | f74d946 | 2017-04-28 01:49:42 +0000 | [diff] [blame] | 20 | // CHECK: # 1 "{{.*}}file.h" 1 |
Richard Smith | d138630 | 2017-05-04 00:29:54 +0000 | [diff] [blame^] | 21 | // NO-REWRITE: #pragma clang module begin file |
| 22 | // NO-REWRITE: # 1 "{{.*}}file.h"{{$}} |
| 23 | // |
Richard Smith | f74d946 | 2017-04-28 01:49:42 +0000 | [diff] [blame] | 24 | // CHECK: struct __FILE; |
Richard Smith | d138630 | 2017-05-04 00:29:54 +0000 | [diff] [blame^] | 25 | // CHECK: #pragma clang module import fwd /* clang {{-E|-frewrite-includes}}: implicit import |
Richard Smith | f74d946 | 2017-04-28 01:49:42 +0000 | [diff] [blame] | 26 | // CHECK: typedef struct __FILE FILE; |
Richard Smith | d138630 | 2017-05-04 00:29:54 +0000 | [diff] [blame^] | 27 | // |
| 28 | // REWRITE: #pragma clang module end |
Richard Smith | f74d946 | 2017-04-28 01:49:42 +0000 | [diff] [blame] | 29 | // CHECK: # 2 "<module-includes>" 2 |
Richard Smith | d138630 | 2017-05-04 00:29:54 +0000 | [diff] [blame^] | 30 | // NO-REWRITE: #pragma clang module end |
| 31 | |
| 32 | // == file2.h |
| 33 | // REWRITE: #if 0 |
| 34 | // REWRITE: #include "file2.h" |
| 35 | // REWRITE: #endif |
| 36 | // |
| 37 | // REWRITE: #pragma clang module begin file |
| 38 | // CHECK: # 1 "{{.*}}file2.h" 1 |
| 39 | // NO-REWRITE: #pragma clang module begin file |
| 40 | // |
| 41 | // ==== recursively re-enter file.h |
| 42 | // REWRITE: #if 0 |
| 43 | // REWRITE: #include "file.h" |
| 44 | // REWRITE: #endif |
| 45 | // |
| 46 | // REWRITE: #pragma clang module begin file |
| 47 | // CHECK: # 1 "{{.*}}file.h" 1 |
| 48 | // NO-REWRITE: #pragma clang module begin file |
| 49 | // NO-REWRITE: # 1 "{{.*}}file.h"{{$}} |
| 50 | // |
| 51 | // CHECK: struct __FILE; |
| 52 | // CHECK: #pragma clang module import fwd /* clang {{-E|-frewrite-includes}}: implicit import |
| 53 | // CHECK: typedef struct __FILE FILE; |
| 54 | // |
| 55 | // REWRITE: #pragma clang module end |
| 56 | // CHECK: # 2 "{{.*}}file2.h" 2 |
| 57 | // NO-REWRITE: #pragma clang module end |
| 58 | // NO-REWRITE: # 2 "{{.*}}file2.h"{{$}} |
| 59 | // ==== return to file2.h |
| 60 | // |
| 61 | // CHECK: extern int file2; |
| 62 | // |
| 63 | // REWRITE: #pragma clang module end |
| 64 | // CHECK: # 3 "<module-includes>" 2 |
| 65 | // NO-REWRITE: #pragma clang module end |