| 1 |
// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -Wno-unused-value -fclangir -emit-cir %s -o %t.cir |
| 2 |
// RUN: FileCheck --input-file=%t.cir %s -check-prefix=CIR |
| 3 |
// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -Wno-unused-value -fclangir -emit-llvm %s -o %t-cir.ll |
| 4 |
// RUN: FileCheck --input-file=%t-cir.ll %s -check-prefix=LLVM |
| 5 |
// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -Wno-unused-value -emit-llvm %s -o %t.ll |
| 6 |
// RUN: FileCheck --input-file=%t.ll %s -check-prefix=OGCG |
| 7 |
|
| 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 |
|
| 25 |
template<class T> |
| 26 |
class X { |
| 27 |
public: |
| 28 |
int f() { return 0; } |
| 29 |
}; |
| 30 |
|
| 31 |
template<> class X<int> { |
| 32 |
public: |
| 33 |
int f() { return 1; } |
| 34 |
}; |
| 35 |
|
| 36 |
void test_double() { |
| 37 |
X<double> d; |
| 38 |
d.f(); |
| 39 |
} |
| 40 |
|
| 41 |
// CIR: cir.func{{.*}} @_ZN1XIdE1fEv |
| 42 |
// CIR: cir.const #cir.int<0> |
| 43 |
// |
| 44 |
// CIR: cir.func{{.*}} @_Z11test_doublev() |
| 45 |
// CIR: cir.call @_ZN1XIdE1fEv |
| 46 |
|
| 47 |
// LLVM: define{{.*}} i32 @_ZN1XIdE1fEv |
| 48 |
// LLVM: store i32 0 |
| 49 |
// |
| 50 |
// LLVM: define{{.*}} void @_Z11test_doublev() |
| 51 |
// LLVM: call i32 @_ZN1XIdE1fEv |
| 52 |
|
| 53 |
// OGCG: define{{.*}} void @_Z11test_doublev() |
| 54 |
// OGCG: call{{.*}} i32 @_ZN1XIdE1fEv |
| 55 |
// |
| 56 |
// OGCG: define{{.*}} i32 @_ZN1XIdE1fEv |
| 57 |
// OGCG: ret i32 0 |
| 58 |
|
| 59 |
void test_int() { |
| 60 |
X<int> n; |
| 61 |
n.f(); |
| 62 |
} |
| 63 |
|
| 64 |
// CIR: cir.func{{.*}} @_ZN1XIiE1fEv |
| 65 |
// CIR: cir.const #cir.int<1> |
| 66 |
// |
| 67 |
// CIR: cir.func{{.*}} @_Z8test_intv() |
| 68 |
// CIR: cir.call @_ZN1XIiE1fEv |
| 69 |
|
| 70 |
// LLVM: define{{.*}} i32 @_ZN1XIiE1fEv |
| 71 |
// LLVM: store i32 1 |
| 72 |
// |
| 73 |
// LLVM: define{{.*}} void @_Z8test_intv() |
| 74 |
// LLVM: call i32 @_ZN1XIiE1fEv |
| 75 |
|
| 76 |
// OGCG: define{{.*}} void @_Z8test_intv() |
| 77 |
// OGCG: call{{.*}} i32 @_ZN1XIiE1fEv |
| 78 |
// |
| 79 |
// OGCG: define{{.*}} i32 @_ZN1XIiE1fEv |
| 80 |
// OGCG: ret i32 1 |
| 81 |
|
| 82 |
void test_short() { |
| 83 |
X<short> s; |
| 84 |
s.f(); |
| 85 |
} |
| 86 |
|
| 87 |
// CIR: cir.func{{.*}} @_ZN1XIsE1fEv |
| 88 |
// CIR: cir.const #cir.int<0> |
| 89 |
// |
| 90 |
// CIR: cir.func{{.*}} @_Z10test_shortv() |
| 91 |
// CIR: cir.call @_ZN1XIsE1fEv |
| 92 |
|
| 93 |
// LLVM: define{{.*}} i32 @_ZN1XIsE1fEv |
| 94 |
// LLVM: store i32 0 |
| 95 |
// |
| 96 |
// LLVM: define{{.*}} void @_Z10test_shortv() |
| 97 |
// LLVM: call i32 @_ZN1XIsE1fEv |
| 98 |
|
| 99 |
// OGCG: define{{.*}} void @_Z10test_shortv() |
| 100 |
// OGCG: call{{.*}} i32 @_ZN1XIsE1fEv |
| 101 |
// |
| 102 |
// OGCG: define{{.*}} i32 @_ZN1XIsE1fEv |
| 103 |
// OGCG: ret i32 0 |