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 23export module a; 24 25export template<typename T> 26int x = 0; 27 28export template<> 29int x<int> = 0; 30 31export template<typename T> 32struct Y { 33 static int value; 34}; 35 36template <typename T> 37int Y<T>::value = 0; 38 39export template<> 40struct Y<int> { 41 static int value; 42}; 43 44int Y<int>::value = 0; 45 46// CHECK-NOT: @_ZW1a1xIiE = {{.*}}external{{.*}}global 47// CHECK-NOT: @_ZNW1a1YIiE5valueE = {{.*}}external{{.*}}global 48 49//--- use.cpp 50import a; 51int foo() { 52 return x<int> + Y<int>::value; 53} 54 55// CHECK: @_ZW1a1xIiE = {{.*}}external{{.*}}global 56// CHECK: @_ZNW1a1YIiE5valueE = {{.*}}external{{.*}}global 57