236
|
1 // Test generation and import of simple C++20 Header Units.
|
|
2
|
|
3 // RUN: rm -rf %t
|
|
4 // RUN: mkdir -p %t
|
|
5 // RUN: split-file %s %t
|
|
6
|
|
7 // RUN: %clang_cc1 -std=c++20 -emit-header-unit -xc++-header %t/hu-01.h \
|
|
8 // RUN: -o %t/hu-01.pcm
|
|
9
|
|
10 // RUN: %clang_cc1 -std=c++20 -module-file-info %t/hu-01.pcm | \
|
|
11 // RUN: FileCheck --check-prefix=CHECK-HU %s -DTDIR=%t
|
|
12
|
|
13 // RUN: %clang_cc1 -std=c++20 -emit-module-interface %t/imp-hu-01.cpp \
|
|
14 // RUN: -fmodule-file=%t/hu-01.pcm -o %t/B.pcm -Rmodule-import 2>&1 | \
|
|
15 // RUN: FileCheck --check-prefix=CHECK-IMP %s -DTDIR=%t
|
|
16
|
|
17 // RUN: %clang_cc1 -std=c++20 -emit-module-interface %t/imp-hu-02.cpp \
|
|
18 // RUN: -fmodule-file=%t/hu-01.pcm -o %t/C.pcm -Rmodule-import 2>&1 | \
|
|
19 // RUN: FileCheck --check-prefix=CHECK-GMF-IMP %s -DTDIR=%t
|
|
20
|
|
21 // RUN: %clang_cc1 -std=c++20 -emit-header-unit -xc++-header %t/hu-02.h \
|
|
22 // RUN: -o %t/hu-02.pcm
|
|
23
|
|
24 // RUN: %clang_cc1 -std=c++20 -emit-module-interface %t/imp-hu-03.cpp \
|
|
25 // RUN: -fmodule-file=%t/hu-01.pcm -fmodule-file=%t/hu-02.pcm -o %t/D.pcm \
|
|
26 // RUN: -Rmodule-import 2>&1 | \
|
|
27 // RUN: FileCheck --check-prefix=CHECK-BOTH %s -DTDIR=%t
|
|
28
|
|
29 // RUN: %clang_cc1 -std=c++20 -emit-header-unit -xc++-header %t/hu-03.h \
|
|
30 // RUN: -fmodule-file=%t/hu-01.pcm -o %t/hu-03.pcm
|
|
31
|
|
32 // RUN: %clang_cc1 -std=c++20 -module-file-info %t/hu-03.pcm | \
|
|
33 // RUN: FileCheck --check-prefix=CHECK-HU-HU %s -DTDIR=%t
|
|
34
|
|
35 // RUN: %clang_cc1 -std=c++20 -emit-module-interface %t/imp-hu-04.cpp \
|
|
36 // RUN: -fmodule-file=%t/hu-03.pcm -o %t/E.pcm -Rmodule-import 2>&1 | \
|
|
37 // RUN: FileCheck --check-prefix=CHECK-NESTED %s -DTDIR=%t
|
|
38
|
|
39 //--- hu-01.h
|
|
40 int foo(int);
|
|
41
|
|
42 // CHECK-HU: ====== C++20 Module structure ======
|
|
43 // CHECK-HU-NEXT: Header Unit '[[TDIR]]/hu-01.h' is the Primary Module at index #1
|
|
44
|
|
45 //--- imp-hu-01.cpp
|
|
46 export module B;
|
|
47 import "hu-01.h";
|
|
48
|
|
49 int bar(int x) {
|
|
50 return foo(x);
|
|
51 }
|
|
52 // CHECK-IMP: remark: importing module '[[TDIR]]/hu-01.h' from '[[TDIR]]/hu-01.pcm'
|
|
53 // expected-no-diagnostics
|
|
54
|
|
55 //--- imp-hu-02.cpp
|
|
56 module;
|
|
57 import "hu-01.h";
|
|
58
|
|
59 export module C;
|
|
60
|
|
61 int bar(int x) {
|
|
62 return foo(x);
|
|
63 }
|
|
64 // CHECK-GMF-IMP: remark: importing module '[[TDIR]]/hu-01.h' from '[[TDIR]]/hu-01.pcm'
|
|
65 // expected-no-diagnostics
|
|
66
|
|
67 //--- hu-02.h
|
|
68 int baz(int);
|
|
69
|
|
70 //--- imp-hu-03.cpp
|
|
71 module;
|
|
72 export import "hu-01.h";
|
|
73
|
|
74 export module D;
|
|
75 import "hu-02.h";
|
|
76
|
|
77 int bar(int x) {
|
|
78 return foo(x) + baz(x);
|
|
79 }
|
|
80 // CHECK-BOTH: remark: importing module '[[TDIR]]/hu-01.h' from '[[TDIR]]/hu-01.pcm'
|
|
81 // CHECK-BOTH: remark: importing module '[[TDIR]]/hu-02.h' from '[[TDIR]]/hu-02.pcm'
|
|
82 // expected-no-diagnostics
|
|
83
|
|
84 //--- hu-03.h
|
|
85 export import "hu-01.h";
|
|
86 int baz(int);
|
|
87 // CHECK-HU-HU: ====== C++20 Module structure ======
|
|
88 // CHECK-HU-HU-NEXT: Header Unit '[[TDIR]]/hu-03.h' is the Primary Module at index #2
|
|
89 // CHECK-HU-HU-NEXT: Exports:
|
|
90 // CHECK-HU-HU-NEXT: Header Unit '[[TDIR]]/hu-01.h' is at index #1
|
|
91
|
|
92 // expected-no-diagnostics
|
|
93
|
|
94 //--- imp-hu-04.cpp
|
|
95 module;
|
|
96 import "hu-03.h";
|
|
97
|
|
98 export module E;
|
|
99
|
|
100 int bar(int x) {
|
|
101 return foo(x) + baz(x);
|
|
102 }
|
|
103 // CHECK-NESTED: remark: importing module '[[TDIR]]/hu-03.h' from '[[TDIR]]/hu-03.pcm'
|
|
104 // expected-no-diagnostics
|