Debian Codegraph @

clang/test/Modules/pr59780.cppm

raw
1 // https://github.com/llvm/llvm-project/issues/59780
2 //
3 // RUN: rm -rf %t
4 // RUN: mkdir %t
5 // RUN: split-file %s %t
6 //
7 // RUN: %clang_cc1 -std=c++20 %t/a.cppm -triple %itanium_abi_triple -emit-module-interface -o %t/a.pcm
8 // RUN: %clang_cc1 -std=c++20 %t/use.cpp -fprebuilt-module-path=%t \
9 // RUN: -triple %itanium_abi_triple -emit-llvm -o - | FileCheck %t/use.cpp
10 // RUN: %clang_cc1 -std=c++20 %t/a.pcm -triple %itanium_abi_triple -emit-llvm -o - | FileCheck %t/a.cppm
11
12 // Test again with reduced BMI.
13 // RUN: %clang_cc1 -std=c++20 %t/a.cppm -triple %itanium_abi_triple -emit-module-interface \
14 // RUN: -o %t/a.full.pcm
15 // RUN: %clang_cc1 -std=c++20 %t/a.cppm -triple %itanium_abi_triple -emit-reduced-module-interface \
16 // RUN: -o %t/a.pcm
17 // RUN: %clang_cc1 -std=c++20 %t/use.cpp -fprebuilt-module-path=%t \
18 // RUN: -triple %itanium_abi_triple -emit-llvm -o - | FileCheck %t/use.cpp
19 // RUN: %clang_cc1 -std=c++20 %t/a.full.pcm -triple %itanium_abi_triple -emit-llvm -o - | FileCheck %t/a.cppm
20
21
22 //--- a.cppm
23 export module a;
24
25 export template<typename T>
26 int x = 0;
27
28 export template<>
29 int x<int> = 0;
30
31 export template<typename T>
32 struct Y {
33 static int value;
34 };
35
36 template <typename T>
37 int Y<T>::value = 0;
38
39 export template<>
40 struct Y<int> {
41 static int value;
42 };
43
44 int Y<int>::value = 0;
45
46 // CHECK-NOT: @_ZW1a1xIiE = {{.*}}external{{.*}}global
47 // CHECK-NOT: @_ZNW1a1YIiE5valueE = {{.*}}external{{.*}}global
48
49 //--- use.cpp
50 import a;
51 int foo() {
52 return x<int> + Y<int>::value;
53 }
54
55 // CHECK: @_ZW1a1xIiE = {{.*}}external{{.*}}global
56 // CHECK: @_ZNW1a1YIiE5valueE = {{.*}}external{{.*}}global