xref: /llvm-project/clang/test/Modules/cxx20-module-file-info.cpp (revision dc4e85bd79ff17014cbbe4a9db1d9b91929e91ce)
15a74e6a2SIain Sandoe // Test output from -module-file-info about C++20 modules.
25a74e6a2SIain Sandoe 
35a74e6a2SIain Sandoe // RUN: rm -rf %t
45a74e6a2SIain Sandoe // RUN: mkdir -p %t
55a74e6a2SIain Sandoe // RUN: split-file %s %t
65a74e6a2SIain Sandoe 
75a74e6a2SIain Sandoe // RUN: %clang_cc1 -std=c++20 -emit-module-interface %t/mod-info-tu1.cpp \
85a74e6a2SIain Sandoe // RUN:  -o %t/A.pcm
95a74e6a2SIain Sandoe 
105a74e6a2SIain Sandoe // RUN: %clang_cc1 -std=c++20 -module-file-info %t/A.pcm | FileCheck \
115a74e6a2SIain Sandoe // RUN:  --check-prefix=CHECK-A %s
125a74e6a2SIain Sandoe 
135a74e6a2SIain Sandoe // RUN: %clang_cc1 -std=c++20 -emit-module-interface %t/mod-info-tu2.cpp \
145a74e6a2SIain Sandoe // RUN:  -o %t/B.pcm
155a74e6a2SIain Sandoe 
165a74e6a2SIain Sandoe // RUN: %clang_cc1 -std=c++20 -module-file-info %t/B.pcm | FileCheck \
175a74e6a2SIain Sandoe // RUN:     --check-prefix=CHECK-B %s
185a74e6a2SIain Sandoe 
195a74e6a2SIain Sandoe // RUN: %clang_cc1 -std=c++20 -emit-module-interface %t/mod-info-tu3.cpp \
20*dc4e85bdSChuanqi Xu // RUN:     -fmodule-file=A=%t/A.pcm -fmodule-file=B=%t/B.pcm -o %t/Foo.pcm
215a74e6a2SIain Sandoe 
22*dc4e85bdSChuanqi Xu // RUN: %clang_cc1 -std=c++20 -module-file-info %t/Foo.pcm -fmodule-file=A=%t/A.pcm \
23*dc4e85bdSChuanqi Xu // RUN:     -fmodule-file=B=%t/B.pcm  | FileCheck \
245a74e6a2SIain Sandoe // RUN:     --check-prefix=CHECK-FOO %s
255a74e6a2SIain Sandoe 
265a74e6a2SIain Sandoe // expected-no-diagnostics
275a74e6a2SIain Sandoe 
285a74e6a2SIain Sandoe //--- mod-info-tu1.cpp
295a74e6a2SIain Sandoe export module A;
305a74e6a2SIain Sandoe 
315a74e6a2SIain Sandoe void a();
325a74e6a2SIain Sandoe 
335a74e6a2SIain Sandoe // CHECK-A: ====== C++20
345a74e6a2SIain Sandoe // CHECK-A-NEXT: Interface Unit 'A' is the Primary Module at index #1
355a74e6a2SIain Sandoe 
365a74e6a2SIain Sandoe //--- mod-info-tu2.cpp
375a74e6a2SIain Sandoe export module B;
385a74e6a2SIain Sandoe 
395a74e6a2SIain Sandoe void b();
405a74e6a2SIain Sandoe 
415a74e6a2SIain Sandoe // CHECK-B: ====== C++20
425a74e6a2SIain Sandoe // CHECK-B-NEXT: Interface Unit 'B' is the Primary Module at index #1
435a74e6a2SIain Sandoe 
445a74e6a2SIain Sandoe //--- mod-info-tu3.cpp
455a74e6a2SIain Sandoe module;
465a74e6a2SIain Sandoe 
475a74e6a2SIain Sandoe export module Foo;
485a74e6a2SIain Sandoe 
495a74e6a2SIain Sandoe import A;
505a74e6a2SIain Sandoe export import B;
515a74e6a2SIain Sandoe 
525a74e6a2SIain Sandoe namespace hello {
535a74e6a2SIain Sandoe export void say(const char *);
545a74e6a2SIain Sandoe }
555a74e6a2SIain Sandoe 
foo()565a74e6a2SIain Sandoe void foo() {}
575a74e6a2SIain Sandoe 
585a74e6a2SIain Sandoe // CHECK-FOO: ====== C++20
595a74e6a2SIain Sandoe // CHECK-FOO-NEXT:  Interface Unit 'Foo' is the Primary Module at index #3
605a74e6a2SIain Sandoe // CHECK-FOO-NEXT:   Sub Modules:
615a74e6a2SIain Sandoe // CHECK-FOO-NEXT:    Global Module Fragment '<global>' is at index #4
625a74e6a2SIain Sandoe // CHECK-FOO-NEXT:   Imports:
635a74e6a2SIain Sandoe // CHECK-FOO-NEXT:    Interface Unit 'A' is at index #1
645a74e6a2SIain Sandoe // CHECK-FOO-NEXT:   Exports:
655a74e6a2SIain Sandoe // CHECK-FOO-NEXT:    Interface Unit 'B' is at index #2
66