blob: 337cafbf65bfd8a17e80b6ae0b50233d13789d65 [file] [log] [blame]
Richard Smithf74d9462017-04-28 01:49:42 +00001// 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 Smithd1386302017-05-04 00:29:54 +00006// 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 Smithf74d9462017-04-28 01:49:42 +000010// CHECK: # 1 "<module-includes>"
Richard Smithd1386302017-05-04 00:29:54 +000011// 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 Smithf74d9462017-04-28 01:49:42 +000020// CHECK: # 1 "{{.*}}file.h" 1
Richard Smithd1386302017-05-04 00:29:54 +000021// NO-REWRITE: #pragma clang module begin file
22// NO-REWRITE: # 1 "{{.*}}file.h"{{$}}
23//
Richard Smithf74d9462017-04-28 01:49:42 +000024// CHECK: struct __FILE;
Richard Smithd1386302017-05-04 00:29:54 +000025// CHECK: #pragma clang module import fwd /* clang {{-E|-frewrite-includes}}: implicit import
Richard Smithf74d9462017-04-28 01:49:42 +000026// CHECK: typedef struct __FILE FILE;
Richard Smithd1386302017-05-04 00:29:54 +000027//
28// REWRITE: #pragma clang module end
Richard Smithf74d9462017-04-28 01:49:42 +000029// CHECK: # 2 "<module-includes>" 2
Richard Smithd1386302017-05-04 00:29:54 +000030// 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