Charles Davis | 9fd2359 | 2012-05-26 23:12:19 +0000 | [diff] [blame] | 1 | // RUN: %clang_cc1 -fms-extensions -emit-llvm %s -o - -cxx-abi microsoft -triple=i386-pc-win32 | FileCheck %s |
| 2 | |
| 3 | template<typename T> |
| 4 | class Class { |
| 5 | public: |
Peter Collingbourne | b70d1c3 | 2013-04-25 04:25:40 +0000 | [diff] [blame] | 6 | Class() {} |
Charles Davis | 9fd2359 | 2012-05-26 23:12:19 +0000 | [diff] [blame] | 7 | }; |
| 8 | |
| 9 | class Typename { }; |
| 10 | |
| 11 | template<typename T> |
| 12 | class Nested { }; |
| 13 | |
| 14 | template<bool flag> |
| 15 | class BoolTemplate { |
| 16 | public: |
| 17 | BoolTemplate() {} |
| 18 | }; |
| 19 | |
Charles Davis | fb527dc | 2012-05-28 00:43:56 +0000 | [diff] [blame] | 20 | template<int param> |
| 21 | class IntTemplate { |
| 22 | public: |
| 23 | IntTemplate() {} |
| 24 | }; |
| 25 | |
Charles Davis | 3facb62 | 2012-06-23 00:27:49 +0000 | [diff] [blame] | 26 | template<> |
| 27 | class BoolTemplate<true> { |
| 28 | public: |
| 29 | BoolTemplate() {} |
| 30 | template<class T> void Foo(T arg) {} |
| 31 | }; |
| 32 | |
Charles Davis | 9fd2359 | 2012-05-26 23:12:19 +0000 | [diff] [blame] | 33 | void template_mangling() { |
| 34 | Class<Typename> c1; |
Peter Collingbourne | b70d1c3 | 2013-04-25 04:25:40 +0000 | [diff] [blame] | 35 | // CHECK: call {{.*}} @"\01??0?$Class@VTypename@@@@QAE@XZ" |
Charles Davis | 9fd2359 | 2012-05-26 23:12:19 +0000 | [diff] [blame] | 36 | |
Reid Kleckner | cb5949d | 2013-04-09 12:47:38 +0000 | [diff] [blame] | 37 | Class<const Typename> c1_const; |
Peter Collingbourne | b70d1c3 | 2013-04-25 04:25:40 +0000 | [diff] [blame] | 38 | // CHECK: call {{.*}} @"\01??0?$Class@$$CBVTypename@@@@QAE@XZ" |
Reid Kleckner | cb5949d | 2013-04-09 12:47:38 +0000 | [diff] [blame] | 39 | Class<volatile Typename> c1_volatile; |
Peter Collingbourne | b70d1c3 | 2013-04-25 04:25:40 +0000 | [diff] [blame] | 40 | // CHECK: call {{.*}} @"\01??0?$Class@$$CCVTypename@@@@QAE@XZ" |
Reid Kleckner | cb5949d | 2013-04-09 12:47:38 +0000 | [diff] [blame] | 41 | Class<const volatile Typename> c1_cv; |
Peter Collingbourne | b70d1c3 | 2013-04-25 04:25:40 +0000 | [diff] [blame] | 42 | // CHECK: call {{.*}} @"\01??0?$Class@$$CDVTypename@@@@QAE@XZ" |
Reid Kleckner | cb5949d | 2013-04-09 12:47:38 +0000 | [diff] [blame] | 43 | |
Charles Davis | 9fd2359 | 2012-05-26 23:12:19 +0000 | [diff] [blame] | 44 | Class<Nested<Typename> > c2; |
Peter Collingbourne | b70d1c3 | 2013-04-25 04:25:40 +0000 | [diff] [blame] | 45 | // CHECK: call {{.*}} @"\01??0?$Class@V?$Nested@VTypename@@@@@@QAE@XZ" |
| 46 | |
| 47 | Class<int * const> c_intpc; |
| 48 | // CHECK: call {{.*}} @"\01??0?$Class@QAH@@QAE@XZ" |
| 49 | Class<int()> c_ft; |
| 50 | // CHECK: call {{.*}} @"\01??0?$Class@$$A6AHXZ@@QAE@XZ" |
| 51 | Class<int[]> c_inti; |
| 52 | // CHECK: call {{.*}} @"\01??0?$Class@$$BY0A@H@@QAE@XZ" |
| 53 | Class<int[5]> c_int5; |
| 54 | // CHECK: call {{.*}} @"\01??0?$Class@$$BY04H@@QAE@XZ" |
| 55 | Class<const int[5]> c_intc5; |
| 56 | // CHECK: call {{.*}} @"\01??0?$Class@$$BY04$$CBH@@QAE@XZ" |
| 57 | Class<int * const[5]> c_intpc5; |
| 58 | // CHECK: call {{.*}} @"\01??0?$Class@$$BY04QAH@@QAE@XZ" |
Charles Davis | 9fd2359 | 2012-05-26 23:12:19 +0000 | [diff] [blame] | 59 | |
| 60 | BoolTemplate<false> _false; |
| 61 | // CHECK: call {{.*}} @"\01??0?$BoolTemplate@$0A@@@QAE@XZ" |
| 62 | |
| 63 | BoolTemplate<true> _true; |
Charles Davis | 3facb62 | 2012-06-23 00:27:49 +0000 | [diff] [blame] | 64 | // PR13158 |
| 65 | _true.Foo(1); |
Charles Davis | 9fd2359 | 2012-05-26 23:12:19 +0000 | [diff] [blame] | 66 | // CHECK: call {{.*}} @"\01??0?$BoolTemplate@$00@@QAE@XZ" |
Charles Davis | 3facb62 | 2012-06-23 00:27:49 +0000 | [diff] [blame] | 67 | // CHECK: call {{.*}} @"\01??$Foo@H@?$BoolTemplate@$00@@QAEXH@Z" |
Charles Davis | fb527dc | 2012-05-28 00:43:56 +0000 | [diff] [blame] | 68 | |
Nico Weber | e95b46b | 2012-11-08 23:38:59 +0000 | [diff] [blame] | 69 | IntTemplate<0> zero; |
| 70 | // CHECK: call {{.*}} @"\01??0?$IntTemplate@$0A@@@QAE@XZ" |
| 71 | |
Charles Davis | c1fd52b | 2012-05-28 16:53:33 +0000 | [diff] [blame] | 72 | IntTemplate<5> five; |
| 73 | // CHECK: call {{.*}} @"\01??0?$IntTemplate@$04@@QAE@XZ" |
| 74 | |
Charles Davis | fb527dc | 2012-05-28 00:43:56 +0000 | [diff] [blame] | 75 | IntTemplate<11> eleven; |
| 76 | // CHECK: call {{.*}} @"\01??0?$IntTemplate@$0L@@@QAE@XZ" |
| 77 | |
Nico Weber | 385b91f | 2012-10-03 13:39:49 +0000 | [diff] [blame] | 78 | IntTemplate<256> _256; |
| 79 | // CHECK: call {{.*}} @"\01??0?$IntTemplate@$0BAA@@@QAE@XZ" |
| 80 | |
| 81 | IntTemplate<513> _513; |
| 82 | // CHECK: call {{.*}} @"\01??0?$IntTemplate@$0CAB@@@QAE@XZ" |
| 83 | |
| 84 | IntTemplate<1026> _1026; |
| 85 | // CHECK: call {{.*}} @"\01??0?$IntTemplate@$0EAC@@@QAE@XZ" |
| 86 | |
Charles Davis | fb527dc | 2012-05-28 00:43:56 +0000 | [diff] [blame] | 87 | IntTemplate<65535> ffff; |
| 88 | // CHECK: call {{.*}} @"\01??0?$IntTemplate@$0PPPP@@@QAE@XZ" |
Charles Davis | 9fd2359 | 2012-05-26 23:12:19 +0000 | [diff] [blame] | 89 | } |
| 90 | |
| 91 | namespace space { |
| 92 | template<class T> const T& foo(const T& l) { return l; } |
| 93 | } |
| 94 | // CHECK: "\01??$foo@H@space@@YAABHABH@Z" |
| 95 | |
| 96 | void use() { |
| 97 | space::foo(42); |
| 98 | } |
Reid Kleckner | ff430f6 | 2013-03-20 22:29:42 +0000 | [diff] [blame] | 99 | |
| 100 | // PR13455 |
| 101 | typedef void (*FunctionPointer)(void); |
| 102 | |
| 103 | template <FunctionPointer function> |
| 104 | void FunctionPointerTemplate() { |
| 105 | function(); |
| 106 | } |
| 107 | |
| 108 | void spam() { |
| 109 | FunctionPointerTemplate<spam>(); |
| 110 | // CHECK: "\01??$FunctionPointerTemplate@$1?spam@@YAXXZ@@YAXXZ" |
| 111 | } |