|
| 1 | +// RUN: rm -rf %t |
| 2 | +// RUN: mkdir %t |
| 3 | +// RUN: split-file %s %t |
| 4 | +// |
| 5 | +// RUN: %clang_cc1 -std=c++20 -triple %itanium_abi_triple %t/d.cppm \ |
| 6 | +// RUN: -emit-module-interface -o %t/d.pcm |
| 7 | +// RUN: %clang_cc1 -std=c++20 -triple %itanium_abi_triple %t/c.cppm \ |
| 8 | +// RUN: -emit-module-interface -o %t/c.pcm -fmodule-file=%t/d.pcm |
| 9 | +// RUN: %clang_cc1 -std=c++20 -triple %itanium_abi_triple %t/b.cppm \ |
| 10 | +// RUN: -emit-module-interface -o %t/b.pcm -fmodule-file=%t/d.pcm |
| 11 | +// RUN: %clang_cc1 -std=c++20 -triple %itanium_abi_triple %t/a.cppm \ |
| 12 | +// RUN: -emit-module-interface -o %t/a.pcm -fmodule-file=%t/d.pcm \ |
| 13 | +// RUN: -fmodule-file=%t/c.pcm -fmodule-file=%t/b.pcm |
| 14 | +// RUN: %clang_cc1 -std=c++20 -triple %itanium_abi_triple %t/a.pcm \ |
| 15 | +// RUN: -S -emit-llvm -disable-llvm-passes -o - | FileCheck %t/a.cppm |
| 16 | +// |
| 17 | +// Use -fmodule-file=<module-name>=<BMI-path> |
| 18 | +// RUN: %clang_cc1 -std=c++20 -triple %itanium_abi_triple %t/d.cppm \ |
| 19 | +// RUN: -emit-module-interface -o %t/d.pcm |
| 20 | +// RUN: %clang_cc1 -std=c++20 -triple %itanium_abi_triple %t/c.cppm \ |
| 21 | +// RUN: -emit-module-interface -o %t/c.pcm -fmodule-file=%t/d.pcm |
| 22 | +// RUN: %clang_cc1 -std=c++20 -triple %itanium_abi_triple %t/b.cppm \ |
| 23 | +// RUN: -emit-module-interface -o %t/b.pcm -fmodule-file=%t/d.pcm |
| 24 | +// RUN: %clang_cc1 -std=c++20 -triple %itanium_abi_triple %t/a.cppm \ |
| 25 | +// RUN: -emit-module-interface -o %t/a.pcm -fmodule-file=%t/d.pcm \ |
| 26 | +// RUN: -fmodule-file=%t/c.pcm -fmodule-file=%t/b.pcm |
| 27 | +// RUN: %clang_cc1 -std=c++20 -triple %itanium_abi_triple %t/a.pcm \ |
| 28 | +// RUN: -S -emit-llvm -disable-llvm-passes -o - | FileCheck %t/a.cppm |
| 29 | + |
| 30 | +//--- d.cppm |
| 31 | +export module d; |
| 32 | + |
| 33 | +export template<typename> |
| 34 | +struct integer { |
| 35 | + using type = int; |
| 36 | + |
| 37 | + static constexpr auto value() { |
| 38 | + return 0; |
| 39 | + } |
| 40 | + |
| 41 | + friend constexpr void f(integer const x) { |
| 42 | + x.value(); |
| 43 | + } |
| 44 | +}; |
| 45 | + |
| 46 | +export constexpr void ddd(auto const value) { |
| 47 | + f(value); |
| 48 | +} |
| 49 | + |
| 50 | + |
| 51 | +template<typename T> |
| 52 | +constexpr auto dd = T(); |
| 53 | + |
| 54 | +export template<typename T> |
| 55 | +constexpr auto d() { |
| 56 | + dd<T>; |
| 57 | +} |
| 58 | + |
| 59 | +//--- c.cppm |
| 60 | +export module c; |
| 61 | + |
| 62 | +import d; |
| 63 | + |
| 64 | +template<typename T> |
| 65 | +auto cc = T(); |
| 66 | + |
| 67 | +auto c() { |
| 68 | + cc<integer<int>>; |
| 69 | + integer<int>().value(); |
| 70 | +} |
| 71 | + |
| 72 | +//--- b.cppm |
| 73 | +export module b; |
| 74 | + |
| 75 | +import d; |
| 76 | + |
| 77 | +auto b() { |
| 78 | + integer<int>::type; |
| 79 | +} |
| 80 | + |
| 81 | +//--- a.cppm |
| 82 | +export module a; |
| 83 | + |
| 84 | +import b; |
| 85 | +import c; |
| 86 | +import d; |
| 87 | + |
| 88 | +constexpr void aa() { |
| 89 | + d<integer<unsigned>>(); |
| 90 | + ddd(integer<int>()); |
| 91 | +} |
| 92 | + |
| 93 | +export extern "C" void a() { |
| 94 | + aa(); |
| 95 | +} |
| 96 | + |
| 97 | +// Checks that we emit the IR successfully. |
| 98 | +// CHECK: define{{.*}}@a( |
0 commit comments