xref: /llvm-project/clang/test/Modules/pr61892.cppm (revision da00c60dae0040185dc45039c4397f6e746548e9)
1// RUN: rm -rf %t
2// RUN: mkdir -p %t
3// RUN: split-file %s %t
4//
5// RUNX: %clang_cc1 -std=c++20 -triple %itanium_abi_triple \
6// RUNX:     -emit-module-interface %t/a.cppm -o %t/a.pcm
7// RUNX: %clang_cc1 -std=c++20 -triple %itanium_abi_triple \
8// RUNX:     %t/b.cpp -fmodule-file=a=%t/a.pcm -disable-llvm-passes \
9// RUNX:     -emit-llvm -o - | FileCheck %t/b.cpp
10// RUNX: %clang_cc1 -std=c++20 -triple %itanium_abi_triple \
11// RUNX:     %t/c.cpp -fmodule-file=a=%t/a.pcm -disable-llvm-passes \
12// RUNX:     -emit-llvm -o - | FileCheck %t/c.cpp
13
14// Test again with reduced BMI.
15// RUN: rm -rf %t
16// RUN: mkdir -p %t
17// RUN: split-file %s %t
18//
19// RUN: %clang_cc1 -std=c++20 -triple %itanium_abi_triple \
20// RUN:     -emit-reduced-module-interface %t/a.cppm -o %t/a.pcm
21// RUNX: %clang_cc1 -std=c++20 -triple %itanium_abi_triple \
22// RUNX:     %t/b.cpp -fmodule-file=a=%t/a.pcm -disable-llvm-passes \
23// RUNX:     -emit-llvm -o - | FileCheck %t/b.cpp
24// RUN: %clang_cc1 -std=c++20 -triple %itanium_abi_triple \
25// RUN:     %t/c.cpp -fmodule-file=a=%t/a.pcm -disable-llvm-passes \
26// RUN:     -emit-llvm -o - | FileCheck %t/c.cpp
27
28//--- a.cppm
29export module a;
30
31struct integer {
32	explicit operator int() const {
33		return 0;
34	}
35};
36
37export template<typename>
38int a = static_cast<int>(integer());
39
40int aa() {
41	return a<void>;
42}
43
44
45//--- b.cpp
46import a;
47
48void b() {}
49
50// CHECK-NOT: @_ZW1a1dIvE =
51// CHECK-NOT: @_ZGVW1a1dIvE =
52// CHECK-NOT: @_ZW1a11dynamic_var =
53// CHECK-NOT: @_ZGVW1a11dynamic_var =
54// CHECK-NOT: @_ZW1a1aIvE =
55// CHECK-NOT: @_ZGVW1a1aIvE =
56
57//--- c.cpp
58import a;
59int c() {
60    return a<void>;
61}
62
63// The used variables are generated normally
64// CHECK-DAG: @_ZW1a1aIvE =
65// CHECK-DAG: @_ZGVW1a1aIvE =
66