2013-05-15 04:30:42 +08:00
|
|
|
// RUN: %clang_cc1 -emit-llvm %s -o - -cxx-abi microsoft -triple=i386-pc-win32 | FileCheck %s
|
|
|
|
// RUN: %clang_cc1 -emit-llvm %s -o - -cxx-abi microsoft -triple=x86_64-pc-win32 | FileCheck -check-prefix X64 %s
|
2012-05-27 07:12:19 +08:00
|
|
|
|
|
|
|
template<typename T>
|
|
|
|
class Class {
|
|
|
|
public:
|
2013-04-25 12:25:40 +08:00
|
|
|
Class() {}
|
2012-05-27 07:12:19 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
class Typename { };
|
|
|
|
|
|
|
|
template<typename T>
|
|
|
|
class Nested { };
|
|
|
|
|
|
|
|
template<bool flag>
|
|
|
|
class BoolTemplate {
|
|
|
|
public:
|
|
|
|
BoolTemplate() {}
|
|
|
|
};
|
|
|
|
|
2012-05-28 08:43:56 +08:00
|
|
|
template<int param>
|
|
|
|
class IntTemplate {
|
|
|
|
public:
|
|
|
|
IntTemplate() {}
|
|
|
|
};
|
|
|
|
|
2012-06-23 08:27:49 +08:00
|
|
|
template<>
|
|
|
|
class BoolTemplate<true> {
|
|
|
|
public:
|
|
|
|
BoolTemplate() {}
|
|
|
|
template<class T> void Foo(T arg) {}
|
|
|
|
};
|
|
|
|
|
2012-05-27 07:12:19 +08:00
|
|
|
void template_mangling() {
|
|
|
|
Class<Typename> c1;
|
2013-04-25 12:25:40 +08:00
|
|
|
// CHECK: call {{.*}} @"\01??0?$Class@VTypename@@@@QAE@XZ"
|
2013-05-15 04:30:42 +08:00
|
|
|
// X64: call {{.*}} @"\01??0?$Class@VTypename@@@@QEAA@XZ"
|
2012-05-27 07:12:19 +08:00
|
|
|
|
2013-04-09 20:47:38 +08:00
|
|
|
Class<const Typename> c1_const;
|
2013-04-25 12:25:40 +08:00
|
|
|
// CHECK: call {{.*}} @"\01??0?$Class@$$CBVTypename@@@@QAE@XZ"
|
2013-05-15 04:30:42 +08:00
|
|
|
// X64: call {{.*}} @"\01??0?$Class@$$CBVTypename@@@@QEAA@XZ"
|
2013-04-09 20:47:38 +08:00
|
|
|
Class<volatile Typename> c1_volatile;
|
2013-04-25 12:25:40 +08:00
|
|
|
// CHECK: call {{.*}} @"\01??0?$Class@$$CCVTypename@@@@QAE@XZ"
|
2013-05-15 04:30:42 +08:00
|
|
|
// X64: call {{.*}} @"\01??0?$Class@$$CCVTypename@@@@QEAA@XZ"
|
2013-04-09 20:47:38 +08:00
|
|
|
Class<const volatile Typename> c1_cv;
|
2013-04-25 12:25:40 +08:00
|
|
|
// CHECK: call {{.*}} @"\01??0?$Class@$$CDVTypename@@@@QAE@XZ"
|
2013-05-15 04:30:42 +08:00
|
|
|
// X64: call {{.*}} @"\01??0?$Class@$$CDVTypename@@@@QEAA@XZ"
|
2013-04-09 20:47:38 +08:00
|
|
|
|
2012-05-27 07:12:19 +08:00
|
|
|
Class<Nested<Typename> > c2;
|
2013-04-25 12:25:40 +08:00
|
|
|
// CHECK: call {{.*}} @"\01??0?$Class@V?$Nested@VTypename@@@@@@QAE@XZ"
|
2013-05-15 04:30:42 +08:00
|
|
|
// X64: call {{.*}} @"\01??0?$Class@V?$Nested@VTypename@@@@@@QEAA@XZ"
|
2013-04-25 12:25:40 +08:00
|
|
|
|
|
|
|
Class<int * const> c_intpc;
|
|
|
|
// CHECK: call {{.*}} @"\01??0?$Class@QAH@@QAE@XZ"
|
2013-05-15 04:30:42 +08:00
|
|
|
// X64: call {{.*}} @"\01??0?$Class@QEAH@@QEAA@XZ"
|
2013-04-25 12:25:40 +08:00
|
|
|
Class<int()> c_ft;
|
|
|
|
// CHECK: call {{.*}} @"\01??0?$Class@$$A6AHXZ@@QAE@XZ"
|
2013-05-15 04:30:42 +08:00
|
|
|
// X64: call {{.*}} @"\01??0?$Class@$$A6AHXZ@@QEAA@XZ"
|
2013-04-25 12:25:40 +08:00
|
|
|
Class<int[]> c_inti;
|
|
|
|
// CHECK: call {{.*}} @"\01??0?$Class@$$BY0A@H@@QAE@XZ"
|
2013-05-15 04:30:42 +08:00
|
|
|
// X64: call {{.*}} @"\01??0?$Class@$$BY0A@H@@QEAA@XZ"
|
2013-04-25 12:25:40 +08:00
|
|
|
Class<int[5]> c_int5;
|
|
|
|
// CHECK: call {{.*}} @"\01??0?$Class@$$BY04H@@QAE@XZ"
|
2013-05-15 04:30:42 +08:00
|
|
|
// X64: call {{.*}} @"\01??0?$Class@$$BY04H@@QEAA@XZ"
|
2013-04-25 12:25:40 +08:00
|
|
|
Class<const int[5]> c_intc5;
|
|
|
|
// CHECK: call {{.*}} @"\01??0?$Class@$$BY04$$CBH@@QAE@XZ"
|
2013-05-15 04:30:42 +08:00
|
|
|
// X64: call {{.*}} @"\01??0?$Class@$$BY04$$CBH@@QEAA@XZ"
|
2013-04-25 12:25:40 +08:00
|
|
|
Class<int * const[5]> c_intpc5;
|
|
|
|
// CHECK: call {{.*}} @"\01??0?$Class@$$BY04QAH@@QAE@XZ"
|
2013-05-15 04:30:42 +08:00
|
|
|
// X64: call {{.*}} @"\01??0?$Class@$$BY04QEAH@@QEAA@XZ"
|
2012-05-27 07:12:19 +08:00
|
|
|
|
|
|
|
BoolTemplate<false> _false;
|
|
|
|
// CHECK: call {{.*}} @"\01??0?$BoolTemplate@$0A@@@QAE@XZ"
|
2013-05-15 04:30:42 +08:00
|
|
|
// X64: call {{.*}} @"\01??0?$BoolTemplate@$0A@@@QEAA@XZ"
|
2012-05-27 07:12:19 +08:00
|
|
|
|
|
|
|
BoolTemplate<true> _true;
|
2012-06-23 08:27:49 +08:00
|
|
|
// PR13158
|
|
|
|
_true.Foo(1);
|
2012-05-27 07:12:19 +08:00
|
|
|
// CHECK: call {{.*}} @"\01??0?$BoolTemplate@$00@@QAE@XZ"
|
2013-05-15 04:30:42 +08:00
|
|
|
// X64: call {{.*}} @"\01??0?$BoolTemplate@$00@@QEAA@XZ"
|
2012-06-23 08:27:49 +08:00
|
|
|
// CHECK: call {{.*}} @"\01??$Foo@H@?$BoolTemplate@$00@@QAEXH@Z"
|
2013-05-15 04:30:42 +08:00
|
|
|
// X64: call {{.*}} @"\01??$Foo@H@?$BoolTemplate@$00@@QEAAXH@Z"
|
2012-05-28 08:43:56 +08:00
|
|
|
|
2012-11-09 07:38:59 +08:00
|
|
|
IntTemplate<0> zero;
|
|
|
|
// CHECK: call {{.*}} @"\01??0?$IntTemplate@$0A@@@QAE@XZ"
|
2013-05-15 04:30:42 +08:00
|
|
|
// X64: call {{.*}} @"\01??0?$IntTemplate@$0A@@@QEAA@XZ"
|
2012-11-09 07:38:59 +08:00
|
|
|
|
2012-05-29 00:53:33 +08:00
|
|
|
IntTemplate<5> five;
|
|
|
|
// CHECK: call {{.*}} @"\01??0?$IntTemplate@$04@@QAE@XZ"
|
2013-05-15 04:30:42 +08:00
|
|
|
// X64: call {{.*}} @"\01??0?$IntTemplate@$04@@QEAA@XZ"
|
2012-05-29 00:53:33 +08:00
|
|
|
|
2012-05-28 08:43:56 +08:00
|
|
|
IntTemplate<11> eleven;
|
|
|
|
// CHECK: call {{.*}} @"\01??0?$IntTemplate@$0L@@@QAE@XZ"
|
2013-05-15 04:30:42 +08:00
|
|
|
// X64: call {{.*}} @"\01??0?$IntTemplate@$0L@@@QEAA@XZ"
|
2012-05-28 08:43:56 +08:00
|
|
|
|
2012-10-03 21:39:49 +08:00
|
|
|
IntTemplate<256> _256;
|
|
|
|
// CHECK: call {{.*}} @"\01??0?$IntTemplate@$0BAA@@@QAE@XZ"
|
2013-05-15 04:30:42 +08:00
|
|
|
// X64: call {{.*}} @"\01??0?$IntTemplate@$0BAA@@@QEAA@XZ"
|
2012-10-03 21:39:49 +08:00
|
|
|
|
|
|
|
IntTemplate<513> _513;
|
|
|
|
// CHECK: call {{.*}} @"\01??0?$IntTemplate@$0CAB@@@QAE@XZ"
|
2013-05-15 04:30:42 +08:00
|
|
|
// X64: call {{.*}} @"\01??0?$IntTemplate@$0CAB@@@QEAA@XZ"
|
2012-10-03 21:39:49 +08:00
|
|
|
|
|
|
|
IntTemplate<1026> _1026;
|
|
|
|
// CHECK: call {{.*}} @"\01??0?$IntTemplate@$0EAC@@@QAE@XZ"
|
2013-05-15 04:30:42 +08:00
|
|
|
// X64: call {{.*}} @"\01??0?$IntTemplate@$0EAC@@@QEAA@XZ"
|
2012-10-03 21:39:49 +08:00
|
|
|
|
2012-05-28 08:43:56 +08:00
|
|
|
IntTemplate<65535> ffff;
|
|
|
|
// CHECK: call {{.*}} @"\01??0?$IntTemplate@$0PPPP@@@QAE@XZ"
|
2013-05-15 04:30:42 +08:00
|
|
|
// X64: call {{.*}} @"\01??0?$IntTemplate@$0PPPP@@@QEAA@XZ"
|
2012-05-27 07:12:19 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
namespace space {
|
|
|
|
template<class T> const T& foo(const T& l) { return l; }
|
|
|
|
}
|
|
|
|
// CHECK: "\01??$foo@H@space@@YAABHABH@Z"
|
2013-05-15 04:30:42 +08:00
|
|
|
// X64: "\01??$foo@H@space@@YAAEBHAEBH@Z"
|
2012-05-27 07:12:19 +08:00
|
|
|
|
|
|
|
void use() {
|
|
|
|
space::foo(42);
|
|
|
|
}
|
2013-03-21 06:29:42 +08:00
|
|
|
|
|
|
|
// PR13455
|
|
|
|
typedef void (*FunctionPointer)(void);
|
|
|
|
|
|
|
|
template <FunctionPointer function>
|
|
|
|
void FunctionPointerTemplate() {
|
|
|
|
function();
|
|
|
|
}
|
|
|
|
|
|
|
|
void spam() {
|
|
|
|
FunctionPointerTemplate<spam>();
|
|
|
|
// CHECK: "\01??$FunctionPointerTemplate@$1?spam@@YAXXZ@@YAXXZ"
|
2013-05-15 04:30:42 +08:00
|
|
|
// X64: "\01??$FunctionPointerTemplate@$1?spam@@YAXXZ@@YAXXZ"
|
2013-03-21 06:29:42 +08:00
|
|
|
}
|