xref: /llvm-project/clang/test/Modules/cxx20-module-file-info.cpp (revision dc4e85bd79ff17014cbbe4a9db1d9b91929e91ce)
1 // Test output from -module-file-info about C++20 modules.
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-module-interface %t/mod-info-tu1.cpp \
8 // RUN:  -o %t/A.pcm
9 
10 // RUN: %clang_cc1 -std=c++20 -module-file-info %t/A.pcm | FileCheck \
11 // RUN:  --check-prefix=CHECK-A %s
12 
13 // RUN: %clang_cc1 -std=c++20 -emit-module-interface %t/mod-info-tu2.cpp \
14 // RUN:  -o %t/B.pcm
15 
16 // RUN: %clang_cc1 -std=c++20 -module-file-info %t/B.pcm | FileCheck \
17 // RUN:     --check-prefix=CHECK-B %s
18 
19 // RUN: %clang_cc1 -std=c++20 -emit-module-interface %t/mod-info-tu3.cpp \
20 // RUN:     -fmodule-file=A=%t/A.pcm -fmodule-file=B=%t/B.pcm -o %t/Foo.pcm
21 
22 // RUN: %clang_cc1 -std=c++20 -module-file-info %t/Foo.pcm -fmodule-file=A=%t/A.pcm \
23 // RUN:     -fmodule-file=B=%t/B.pcm  | FileCheck \
24 // RUN:     --check-prefix=CHECK-FOO %s
25 
26 // expected-no-diagnostics
27 
28 //--- mod-info-tu1.cpp
29 export module A;
30 
31 void a();
32 
33 // CHECK-A: ====== C++20
34 // CHECK-A-NEXT: Interface Unit 'A' is the Primary Module at index #1
35 
36 //--- mod-info-tu2.cpp
37 export module B;
38 
39 void b();
40 
41 // CHECK-B: ====== C++20
42 // CHECK-B-NEXT: Interface Unit 'B' is the Primary Module at index #1
43 
44 //--- mod-info-tu3.cpp
45 module;
46 
47 export module Foo;
48 
49 import A;
50 export import B;
51 
52 namespace hello {
53 export void say(const char *);
54 }
55 
foo()56 void foo() {}
57 
58 // CHECK-FOO: ====== C++20
59 // CHECK-FOO-NEXT:  Interface Unit 'Foo' is the Primary Module at index #3
60 // CHECK-FOO-NEXT:   Sub Modules:
61 // CHECK-FOO-NEXT:    Global Module Fragment '<global>' is at index #4
62 // CHECK-FOO-NEXT:   Imports:
63 // CHECK-FOO-NEXT:    Interface Unit 'A' is at index #1
64 // CHECK-FOO-NEXT:   Exports:
65 // CHECK-FOO-NEXT:    Interface Unit 'B' is at index #2
66