Skip to content

Commit 34ea2d6

Browse files
committed
Add partial template specialization test
1 parent be47b60 commit 34ea2d6

File tree

1 file changed

+23
-8
lines changed

1 file changed

+23
-8
lines changed

clang/test/CIR/CodeGen/template-specialization.cpp

Lines changed: 23 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,23 @@
55
// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -Wno-unused-value -emit-llvm %s -o %t.ll
66
// RUN: FileCheck --input-file=%t.ll %s -check-prefix=OGCG
77

8+
template<typename T, typename U>
9+
class Templ {};
10+
11+
template<typename T>
12+
class Templ<T, int>{};
13+
14+
Templ<int, int> t;
15+
16+
// CIR: !rec_Templ3Cint2C_int3E = !cir.record<class "Templ<int, int>" padded {!u8i}>
17+
// CIR: cir.global external @t = #cir.zero : !rec_Templ3Cint2C_int3E
18+
19+
// LLVM: %"class.Templ<int, int>" = type { i8 }
20+
// LLVM: @t = global %"class.Templ<int, int>" zeroinitializer
21+
22+
// OGCG: %class.Templ = type { i8 }
23+
// OGCG: @t = global %class.Templ zeroinitializer
24+
825
template<class T>
926
class X {
1027
public:
@@ -16,14 +33,6 @@ template<> class X<int> {
1633
int f() { return 1; }
1734
};
1835

19-
// TODO: This will get dropped when we are deferring functions
20-
// The speecialization is instantiated first
21-
// CIR: cir.func{{.*}} @_ZN1XIiE1fEv
22-
// CIR: cir.const #cir.int<1>
23-
24-
// LLVM: define{{.*}} i32 @_ZN1XIiE1fEv
25-
// LLVM: store i32 1
26-
2736
void test_double() {
2837
X<double> d;
2938
d.f();
@@ -52,9 +61,15 @@ void test_int() {
5261
n.f();
5362
}
5463

64+
// CIR: cir.func{{.*}} @_ZN1XIiE1fEv
65+
// CIR: cir.const #cir.int<1>
66+
//
5567
// CIR: cir.func{{.*}} @_Z8test_intv()
5668
// CIR: cir.call @_ZN1XIiE1fEv
5769

70+
// LLVM: define{{.*}} i32 @_ZN1XIiE1fEv
71+
// LLVM: store i32 1
72+
//
5873
// LLVM: define{{.*}} void @_Z8test_intv()
5974
// LLVM: call i32 @_ZN1XIiE1fEv
6075

0 commit comments

Comments
 (0)