aboutsummaryrefslogtreecommitdiff
path: root/clang/test/Modules/pr61892.cppm
blob: 7b8905036cd449f0dd2b6131fe64bbf2a16aa748 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
// RUN: rm -rf %t
// RUN: mkdir -p %t
// RUN: split-file %s %t
//
// RUNX: %clang_cc1 -std=c++20 -triple %itanium_abi_triple \
// RUNX:     -emit-module-interface %t/a.cppm -o %t/a.pcm
// RUNX: %clang_cc1 -std=c++20 -triple %itanium_abi_triple \
// RUNX:     %t/b.cpp -fmodule-file=a=%t/a.pcm -disable-llvm-passes \
// RUNX:     -emit-llvm -o - | FileCheck %t/b.cpp
// RUNX: %clang_cc1 -std=c++20 -triple %itanium_abi_triple \
// RUNX:     %t/c.cpp -fmodule-file=a=%t/a.pcm -disable-llvm-passes \
// RUNX:     -emit-llvm -o - | FileCheck %t/c.cpp

// Test again with reduced BMI.
// RUN: rm -rf %t
// RUN: mkdir -p %t
// RUN: split-file %s %t
//
// RUN: %clang_cc1 -std=c++20 -triple %itanium_abi_triple \
// RUN:     -emit-reduced-module-interface %t/a.cppm -o %t/a.pcm
// RUNX: %clang_cc1 -std=c++20 -triple %itanium_abi_triple \
// RUNX:     %t/b.cpp -fmodule-file=a=%t/a.pcm -disable-llvm-passes \
// RUNX:     -emit-llvm -o - | FileCheck %t/b.cpp
// RUN: %clang_cc1 -std=c++20 -triple %itanium_abi_triple \
// RUN:     %t/c.cpp -fmodule-file=a=%t/a.pcm -disable-llvm-passes \
// RUN:     -emit-llvm -o - | FileCheck %t/c.cpp

//--- a.cppm
export module a;

struct integer {
	explicit operator int() const {
		return 0;
	}
};

export template<typename>
int a = static_cast<int>(integer());

int aa() {
	return a<void>;
}


//--- b.cpp
import a;

void b() {}

// CHECK-NOT: @_ZW1a1dIvE =
// CHECK-NOT: @_ZGVW1a1dIvE =
// CHECK-NOT: @_ZW1a11dynamic_var =
// CHECK-NOT: @_ZGVW1a11dynamic_var =
// CHECK-NOT: @_ZW1a1aIvE =
// CHECK-NOT: @_ZGVW1a1aIvE =

//--- c.cpp
import a;
int c() {
    return a<void>;
}

// The used variables are generated normally
// CHECK-DAG: @_ZW1a1aIvE =
// CHECK-DAG: @_ZGVW1a1aIvE =