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: |
| 6 | void method() {} |
| 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; |
| 35 | c1.method(); |
| 36 | // CHECK: call {{.*}} @"\01?method@?$Class@VTypename@@@@QAEXXZ" |
| 37 | |
Reid Kleckner | cb5949d | 2013-04-09 12:47:38 +0000 | [diff] [blame] | 38 | Class<const Typename> c1_const; |
| 39 | Class<volatile Typename> c1_volatile; |
| 40 | Class<const volatile Typename> c1_cv; |
| 41 | c1_const.method(); |
| 42 | c1_volatile.method(); |
| 43 | c1_cv.method(); |
| 44 | // Types with qualifiers have an extra $$C escape when used as template |
| 45 | // arguments. Not sure why. |
| 46 | // CHECK: call {{.*}} @"\01?method@?$Class@$$CBVTypename@@@@QAEXXZ" |
| 47 | // CHECK: call {{.*}} @"\01?method@?$Class@$$CCVTypename@@@@QAEXXZ" |
| 48 | // CHECK: call {{.*}} @"\01?method@?$Class@$$CDVTypename@@@@QAEXXZ" |
| 49 | |
Charles Davis | 9fd2359 | 2012-05-26 23:12:19 +0000 | [diff] [blame] | 50 | Class<Nested<Typename> > c2; |
| 51 | c2.method(); |
| 52 | // CHECK: call {{.*}} @"\01?method@?$Class@V?$Nested@VTypename@@@@@@QAEXXZ" |
| 53 | |
| 54 | BoolTemplate<false> _false; |
| 55 | // CHECK: call {{.*}} @"\01??0?$BoolTemplate@$0A@@@QAE@XZ" |
| 56 | |
| 57 | BoolTemplate<true> _true; |
Charles Davis | 3facb62 | 2012-06-23 00:27:49 +0000 | [diff] [blame] | 58 | // PR13158 |
| 59 | _true.Foo(1); |
Charles Davis | 9fd2359 | 2012-05-26 23:12:19 +0000 | [diff] [blame] | 60 | // CHECK: call {{.*}} @"\01??0?$BoolTemplate@$00@@QAE@XZ" |
Charles Davis | 3facb62 | 2012-06-23 00:27:49 +0000 | [diff] [blame] | 61 | // CHECK: call {{.*}} @"\01??$Foo@H@?$BoolTemplate@$00@@QAEXH@Z" |
Charles Davis | fb527dc | 2012-05-28 00:43:56 +0000 | [diff] [blame] | 62 | |
Nico Weber | e95b46b | 2012-11-08 23:38:59 +0000 | [diff] [blame] | 63 | IntTemplate<0> zero; |
| 64 | // CHECK: call {{.*}} @"\01??0?$IntTemplate@$0A@@@QAE@XZ" |
| 65 | |
Charles Davis | c1fd52b | 2012-05-28 16:53:33 +0000 | [diff] [blame] | 66 | IntTemplate<5> five; |
| 67 | // CHECK: call {{.*}} @"\01??0?$IntTemplate@$04@@QAE@XZ" |
| 68 | |
Charles Davis | fb527dc | 2012-05-28 00:43:56 +0000 | [diff] [blame] | 69 | IntTemplate<11> eleven; |
| 70 | // CHECK: call {{.*}} @"\01??0?$IntTemplate@$0L@@@QAE@XZ" |
| 71 | |
Nico Weber | 385b91f | 2012-10-03 13:39:49 +0000 | [diff] [blame] | 72 | IntTemplate<256> _256; |
| 73 | // CHECK: call {{.*}} @"\01??0?$IntTemplate@$0BAA@@@QAE@XZ" |
| 74 | |
| 75 | IntTemplate<513> _513; |
| 76 | // CHECK: call {{.*}} @"\01??0?$IntTemplate@$0CAB@@@QAE@XZ" |
| 77 | |
| 78 | IntTemplate<1026> _1026; |
| 79 | // CHECK: call {{.*}} @"\01??0?$IntTemplate@$0EAC@@@QAE@XZ" |
| 80 | |
Charles Davis | fb527dc | 2012-05-28 00:43:56 +0000 | [diff] [blame] | 81 | IntTemplate<65535> ffff; |
| 82 | // CHECK: call {{.*}} @"\01??0?$IntTemplate@$0PPPP@@@QAE@XZ" |
Charles Davis | 9fd2359 | 2012-05-26 23:12:19 +0000 | [diff] [blame] | 83 | } |
| 84 | |
| 85 | namespace space { |
| 86 | template<class T> const T& foo(const T& l) { return l; } |
| 87 | } |
| 88 | // CHECK: "\01??$foo@H@space@@YAABHABH@Z" |
| 89 | |
| 90 | void use() { |
| 91 | space::foo(42); |
| 92 | } |
Reid Kleckner | ff430f6 | 2013-03-20 22:29:42 +0000 | [diff] [blame] | 93 | |
| 94 | // PR13455 |
| 95 | typedef void (*FunctionPointer)(void); |
| 96 | |
| 97 | template <FunctionPointer function> |
| 98 | void FunctionPointerTemplate() { |
| 99 | function(); |
| 100 | } |
| 101 | |
| 102 | void spam() { |
| 103 | FunctionPointerTemplate<spam>(); |
| 104 | // CHECK: "\01??$FunctionPointerTemplate@$1?spam@@YAXXZ@@YAXXZ" |
| 105 | } |