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