Richard Smith | 06e767d | 2012-06-21 02:52:27 +0000 | [diff] [blame] | 1 | // RUN: %clang_cc1 -fms-extensions -fblocks -emit-llvm %s -o - -cxx-abi microsoft -triple=i386-pc-win32 | FileCheck %s |
| 2 | |
| 3 | void f1(const char* a, const char* b) {} |
| 4 | // CHECK: "\01?f1@@YAXPBD0@Z" |
| 5 | |
| 6 | void f2(const char* a, char* b) {} |
| 7 | // CHECK: "\01?f2@@YAXPBDPAD@Z" |
| 8 | |
| 9 | void f3(int a, const char* b, const char* c) {} |
| 10 | // CHECK: "\01?f3@@YAXHPBD0@Z" |
| 11 | |
Timur Iskhodzhanov | 4285f84 | 2012-06-26 22:29:50 +0000 | [diff] [blame^] | 12 | const char *f4(const char* a, const char* b) { return 0; } |
Richard Smith | 06e767d | 2012-06-21 02:52:27 +0000 | [diff] [blame] | 13 | // CHECK: "\01?f4@@YAPBDPBD0@Z" |
| 14 | |
Timur Iskhodzhanov | 3f83568 | 2012-06-23 00:54:17 +0000 | [diff] [blame] | 15 | void f5(char const* a, unsigned int b, char c, void const* d, char const* e, unsigned int f) {} |
| 16 | // CHECK: "\01?f5@@YAXPBDIDPBX0I@Z" |
| 17 | |
| 18 | void f6(bool a, bool b) {} |
| 19 | // CHECK: "\01?f6@@YAX_N0@Z" |
| 20 | |
| 21 | void f7(int a, int* b, int c, int* d, bool e, bool f, bool* g) {} |
| 22 | // CHECK: "\01?f7@@YAXHPAHH0_N1PA_N@Z" |
| 23 | |
Richard Smith | 06e767d | 2012-06-21 02:52:27 +0000 | [diff] [blame] | 24 | // FIXME: tests for more than 10 types? |
| 25 | |
Timur Iskhodzhanov | 3f83568 | 2012-06-23 00:54:17 +0000 | [diff] [blame] | 26 | struct S { |
| 27 | void mbb(bool a, bool b) {} |
| 28 | }; |
Richard Smith | 06e767d | 2012-06-21 02:52:27 +0000 | [diff] [blame] | 29 | |
Timur Iskhodzhanov | 3f83568 | 2012-06-23 00:54:17 +0000 | [diff] [blame] | 30 | void g1(struct S a) {} |
| 31 | // CHECK: "\01?g1@@YAXUS@@@Z" |
| 32 | |
| 33 | void g2(struct S a, struct S b) {} |
| 34 | // CHECK: "\01?g2@@YAXUS@@0@Z" |
| 35 | |
| 36 | void g3(struct S a, struct S b, struct S* c, struct S* d) {} |
| 37 | // CHECK: "\01?g3@@YAXUS@@0PAU1@1@Z" |
| 38 | |
| 39 | void g4(const char* a, struct S* b, const char* c, struct S* d) { |
Richard Smith | 06e767d | 2012-06-21 02:52:27 +0000 | [diff] [blame] | 40 | // CHECK: "\01?g4@@YAXPBDPAUS@@01@Z" |
Timur Iskhodzhanov | 3f83568 | 2012-06-23 00:54:17 +0000 | [diff] [blame] | 41 | b->mbb(false, false); |
| 42 | // CHECK: "\01?mbb@S@@QAEX_N0@Z" |
| 43 | } |
Richard Smith | 06e767d | 2012-06-21 02:52:27 +0000 | [diff] [blame] | 44 | |
| 45 | // Make sure that different aliases of built-in types end up mangled as the |
| 46 | // built-ins. |
| 47 | typedef unsigned int uintptr_t; |
| 48 | typedef unsigned int size_t; |
Timur Iskhodzhanov | 4285f84 | 2012-06-26 22:29:50 +0000 | [diff] [blame^] | 49 | void *h(size_t a, uintptr_t b) { return 0; } |
Richard Smith | 06e767d | 2012-06-21 02:52:27 +0000 | [diff] [blame] | 50 | // CHECK: "\01?h@@YAPAXII@Z" |
Timur Iskhodzhanov | 3f83568 | 2012-06-23 00:54:17 +0000 | [diff] [blame] | 51 | |
| 52 | // Function pointers might be mangled in a complex way. |
| 53 | typedef void (*VoidFunc)(); |
| 54 | typedef int* (*PInt3Func)(int* a, int* b); |
| 55 | |
| 56 | void h1(const char* a, const char* b, VoidFunc c, VoidFunc d) {} |
| 57 | // CHECK: "\01?h1@@YAXPBD0P6AXXZ1@Z" |
| 58 | |
| 59 | void h2(void (*f_ptr)(void *), void *arg) {} |
| 60 | // CHECK: "\01?h2@@YAXP6AXPAX@Z0@Z" |
| 61 | |
| 62 | PInt3Func h3(PInt3Func x, PInt3Func y, int* z) { return 0; } |
| 63 | // CHECK: "\01?h3@@YAP6APAHPAH0@ZP6APAH00@Z10@Z" |
Timur Iskhodzhanov | 4285f84 | 2012-06-26 22:29:50 +0000 | [diff] [blame^] | 64 | |
| 65 | namespace PR13207 { |
| 66 | class A {}; |
| 67 | class B {}; |
| 68 | class C {}; |
| 69 | |
| 70 | template<class X> |
| 71 | class I {}; |
| 72 | template<class X, class Y> |
| 73 | class J {}; |
| 74 | template<class X, class Y, class Z> |
| 75 | class K {}; |
| 76 | |
| 77 | class L { |
| 78 | public: |
| 79 | void foo(I<A> x) {} |
| 80 | }; |
| 81 | // CHECK: "\01?foo@L@PR13207@@QAEXV?$I@VA@PR13207@@@2@@Z" |
| 82 | |
| 83 | void call_l_foo(L* l) { l->foo(I<A>()); } |
| 84 | |
| 85 | void foo(I<A> x) {} |
| 86 | // CHECK: "\01?foo@PR13207@@YAXV?$I@VA@PR13207@@@1@@Z" |
| 87 | void foo2(I<A> x, I<A> y) { } |
| 88 | // CHECK "\01?foo2@PR13207@@YAXV?$I@VA@PR13207@@@1@0@Z" |
| 89 | void bar(J<A,B> x) {} |
| 90 | // CHECK: "\01?bar@PR13207@@YAXV?$J@VA@PR13207@@VB@2@@1@@Z" |
| 91 | void spam(K<A,B,C> x) {} |
| 92 | // CHECK: "\01?spam@PR13207@@YAXV?$K@VA@PR13207@@VB@2@VC@2@@1@@Z" |
| 93 | |
| 94 | namespace NA { |
| 95 | class X {}; |
| 96 | template<class T> class Y {}; |
| 97 | void foo(Y<X> x) {} |
| 98 | // CHECK: "\01?foo@NA@PR13207@@YAXV?$Y@VX@NA@PR13207@@@12@@Z" |
| 99 | } |
| 100 | |
| 101 | namespace NB { |
| 102 | class X {}; |
| 103 | template<class T> class Y {}; |
| 104 | void foo(Y<NA::X> x) {} |
| 105 | // CHECK: "\01?foo@NB@PR13207@@YAXV?$Y@VX@NA@PR13207@@@12@@Z" |
| 106 | |
| 107 | void bar(NA::Y<X> x) {} |
| 108 | // CHECK: "\01?bar@NB@PR13207@@YAXV?$Y@VX@NB@PR13207@@@NA@2@@Z" |
| 109 | |
| 110 | void spam(NA::Y<NA::X> x) {} |
| 111 | // CHECK: "\01?spam@NB@PR13207@@YAXV?$Y@VX@NA@PR13207@@@NA@2@@Z" |
| 112 | } |
| 113 | |
| 114 | namespace NC { |
| 115 | class X {}; |
| 116 | template<class T> class Y {}; |
| 117 | |
| 118 | void foo(Y<NB::X> x) {} |
| 119 | // CHECK: "\01?foo@NC@PR13207@@YAXV?$Y@VX@NB@PR13207@@@12@@Z" |
| 120 | |
| 121 | void foobar(NC::Y<NB::Y<NA::Y<NA::X> > > x) {} |
| 122 | // CHECK: "\01?foobar@NC@PR13207@@YAXV?$Y@V?$Y@V?$Y@VX@NA@PR13207@@@NA@PR13207@@@NB@PR13207@@@12@@Z" |
| 123 | } |
| 124 | } |