1*f4a2713aSLionel Sambuc // RUN: %clang_cc1 -emit-llvm %s -o - -cxx-abi microsoft -triple=i386-pc-win32 | FileCheck %s 2*f4a2713aSLionel Sambuc 3*f4a2713aSLionel Sambuc template<class X, class Y, class Z> 4*f4a2713aSLionel Sambuc class A {}; 5*f4a2713aSLionel Sambuc template<class X> 6*f4a2713aSLionel Sambuc class B {}; 7*f4a2713aSLionel Sambuc template<class X> 8*f4a2713aSLionel Sambuc class C {}; 9*f4a2713aSLionel Sambuc 10*f4a2713aSLionel Sambuc void foo_abbb(A<B<char>, B<char>, B<char> >) {} 11*f4a2713aSLionel Sambuc // CHECK: "\01?foo_abbb@@YAXV?$A@V?$B@D@@V1@V1@@@@Z" 12*f4a2713aSLionel Sambuc void foo_abb(A<char, B<char>, B<char> >) {} 13*f4a2713aSLionel Sambuc // CHECK: "\01?foo_abb@@YAXV?$A@DV?$B@D@@V1@@@@Z" 14*f4a2713aSLionel Sambuc void foo_abc(A<char, B<char>, C<char> >) {} 15*f4a2713aSLionel Sambuc // CHECK: "\01?foo_abc@@YAXV?$A@DV?$B@D@@V?$C@D@@@@@Z" 16*f4a2713aSLionel Sambuc void foo_bt(bool a, B<bool(bool)> b) {} 17*f4a2713aSLionel Sambuc // CHECK: "\01?foo_bt@@YAX_NV?$B@$$A6A_N_N@Z@@@Z" 18*f4a2713aSLionel Sambuc 19*f4a2713aSLionel Sambuc namespace N { 20*f4a2713aSLionel Sambuc template<class X, class Y, class Z> 21*f4a2713aSLionel Sambuc class A {}; 22*f4a2713aSLionel Sambuc template<class X> 23*f4a2713aSLionel Sambuc class B {}; 24*f4a2713aSLionel Sambuc template<class X> 25*f4a2713aSLionel Sambuc class C {}; 26*f4a2713aSLionel Sambuc template<class X, class Y> 27*f4a2713aSLionel Sambuc class D {}; 28*f4a2713aSLionel Sambuc class Z {}; 29*f4a2713aSLionel Sambuc } 30*f4a2713aSLionel Sambuc 31*f4a2713aSLionel Sambuc void foo_abbb(N::A<N::B<char>, N::B<char>, N::B<char> >) {} 32*f4a2713aSLionel Sambuc // CHECK: "\01?foo_abbb@@YAXV?$A@V?$B@D@N@@V12@V12@@N@@@Z" 33*f4a2713aSLionel Sambuc void foo_abb(N::A<char, N::B<char>, N::B<char> >) {} 34*f4a2713aSLionel Sambuc // CHECK: "\01?foo_abb@@YAXV?$A@DV?$B@D@N@@V12@@N@@@Z" 35*f4a2713aSLionel Sambuc void foo_abc(N::A<char, N::B<char>, N::C<char> >) {} 36*f4a2713aSLionel Sambuc // CHECK: "\01?foo_abc@@YAXV?$A@DV?$B@D@N@@V?$C@D@2@@N@@@Z" 37*f4a2713aSLionel Sambuc 38*f4a2713aSLionel Sambuc N::A<char, N::B<char>, N::C<char> > abc_foo() { 39*f4a2713aSLionel Sambuc // CHECK: ?abc_foo@@YA?AV?$A@DV?$B@D@N@@V?$C@D@2@@N@@XZ 40*f4a2713aSLionel Sambuc return N::A<char, N::B<char>, N::C<char> >(); 41*f4a2713aSLionel Sambuc } 42*f4a2713aSLionel Sambuc 43*f4a2713aSLionel Sambuc N::Z z_foo(N::Z arg) { 44*f4a2713aSLionel Sambuc // CHECK: ?z_foo@@YA?AVZ@N@@V12@@Z 45*f4a2713aSLionel Sambuc return arg; 46*f4a2713aSLionel Sambuc } 47*f4a2713aSLionel Sambuc 48*f4a2713aSLionel Sambuc N::B<char> b_foo(N::B<char> arg) { 49*f4a2713aSLionel Sambuc // CHECK: ?b_foo@@YA?AV?$B@D@N@@V12@@Z 50*f4a2713aSLionel Sambuc return arg; 51*f4a2713aSLionel Sambuc } 52*f4a2713aSLionel Sambuc 53*f4a2713aSLionel Sambuc N::D<char, char> d_foo(N::D<char, char> arg) { 54*f4a2713aSLionel Sambuc // CHECK: ?d_foo@@YA?AV?$D@DD@N@@V12@@Z 55*f4a2713aSLionel Sambuc return arg; 56*f4a2713aSLionel Sambuc } 57*f4a2713aSLionel Sambuc 58*f4a2713aSLionel Sambuc N::A<char, N::B<char>, N::C<char> > abc_foo_abc(N::A<char, N::B<char>, N::C<char> >) { 59*f4a2713aSLionel Sambuc // CHECK: ?abc_foo_abc@@YA?AV?$A@DV?$B@D@N@@V?$C@D@2@@N@@V12@@Z 60*f4a2713aSLionel Sambuc return N::A<char, N::B<char>, N::C<char> >(); 61*f4a2713aSLionel Sambuc } 62*f4a2713aSLionel Sambuc 63*f4a2713aSLionel Sambuc namespace NA { 64*f4a2713aSLionel Sambuc class X {}; 65*f4a2713aSLionel Sambuc template<class T> class Y {}; 66*f4a2713aSLionel Sambuc } 67*f4a2713aSLionel Sambuc 68*f4a2713aSLionel Sambuc namespace NB { 69*f4a2713aSLionel Sambuc class X {}; 70*f4a2713aSLionel Sambuc template<class T> class Y {}; 71*f4a2713aSLionel Sambuc } 72*f4a2713aSLionel Sambuc 73*f4a2713aSLionel Sambuc void foo5(NA::Y<NB::Y<NA::Y<NB::Y<NA::X> > > > arg) {} 74*f4a2713aSLionel Sambuc // CHECK: "\01?foo5@@YAXV?$Y@V?$Y@V?$Y@V?$Y@VX@NA@@@NB@@@NA@@@NB@@@NA@@@Z" 75*f4a2713aSLionel Sambuc 76*f4a2713aSLionel Sambuc void foo11(NA::Y<NA::X>, NB::Y<NA::X>) {} 77*f4a2713aSLionel Sambuc // CHECK: "\01?foo11@@YAXV?$Y@VX@NA@@@NA@@V1NB@@@Z" 78*f4a2713aSLionel Sambuc 79*f4a2713aSLionel Sambuc void foo112(NA::Y<NA::X>, NB::Y<NB::X>) {} 80*f4a2713aSLionel Sambuc // CHECK: "\01?foo112@@YAXV?$Y@VX@NA@@@NA@@V?$Y@VX@NB@@@NB@@@Z" 81*f4a2713aSLionel Sambuc 82*f4a2713aSLionel Sambuc void foo22(NA::Y<NB::Y<NA::X> >, NB::Y<NA::Y<NA::X> >) {} 83*f4a2713aSLionel Sambuc // CHECK: "\01?foo22@@YAXV?$Y@V?$Y@VX@NA@@@NB@@@NA@@V?$Y@V?$Y@VX@NA@@@NA@@@NB@@@Z" 84*f4a2713aSLionel Sambuc 85*f4a2713aSLionel Sambuc namespace PR13207 { 86*f4a2713aSLionel Sambuc class A {}; 87*f4a2713aSLionel Sambuc class B {}; 88*f4a2713aSLionel Sambuc class C {}; 89*f4a2713aSLionel Sambuc 90*f4a2713aSLionel Sambuc template<class X> 91*f4a2713aSLionel Sambuc class F {}; 92*f4a2713aSLionel Sambuc template<class X> 93*f4a2713aSLionel Sambuc class I {}; 94*f4a2713aSLionel Sambuc template<class X, class Y> 95*f4a2713aSLionel Sambuc class J {}; 96*f4a2713aSLionel Sambuc template<class X, class Y, class Z> 97*f4a2713aSLionel Sambuc class K {}; 98*f4a2713aSLionel Sambuc 99*f4a2713aSLionel Sambuc class L { 100*f4a2713aSLionel Sambuc public: 101*f4a2713aSLionel Sambuc void foo(I<A> x) {} 102*f4a2713aSLionel Sambuc }; 103*f4a2713aSLionel Sambuc // CHECK: "\01?foo@L@PR13207@@QAEXV?$I@VA@PR13207@@@2@@Z" 104*f4a2713aSLionel Sambuc 105*f4a2713aSLionel Sambuc void call_l_foo(L* l) { l->foo(I<A>()); } 106*f4a2713aSLionel Sambuc 107*f4a2713aSLionel Sambuc void foo(I<A> x) {} 108*f4a2713aSLionel Sambuc // CHECK: "\01?foo@PR13207@@YAXV?$I@VA@PR13207@@@1@@Z" 109*f4a2713aSLionel Sambuc void foo2(I<A> x, I<A> y) { } 110*f4a2713aSLionel Sambuc // CHECK: "\01?foo2@PR13207@@YAXV?$I@VA@PR13207@@@1@0@Z" 111*f4a2713aSLionel Sambuc void bar(J<A,B> x) {} 112*f4a2713aSLionel Sambuc // CHECK: "\01?bar@PR13207@@YAXV?$J@VA@PR13207@@VB@2@@1@@Z" 113*f4a2713aSLionel Sambuc void spam(K<A,B,C> x) {} 114*f4a2713aSLionel Sambuc // CHECK: "\01?spam@PR13207@@YAXV?$K@VA@PR13207@@VB@2@VC@2@@1@@Z" 115*f4a2713aSLionel Sambuc 116*f4a2713aSLionel Sambuc void baz(K<char, F<char>, I<char> >) {} 117*f4a2713aSLionel Sambuc // CHECK: "\01?baz@PR13207@@YAXV?$K@DV?$F@D@PR13207@@V?$I@D@2@@1@@Z" 118*f4a2713aSLionel Sambuc void qux(K<char, I<char>, I<char> >) {} 119*f4a2713aSLionel Sambuc // CHECK: "\01?qux@PR13207@@YAXV?$K@DV?$I@D@PR13207@@V12@@1@@Z" 120*f4a2713aSLionel Sambuc 121*f4a2713aSLionel Sambuc namespace NA { 122*f4a2713aSLionel Sambuc class X {}; 123*f4a2713aSLionel Sambuc template<class T> class Y {}; 124*f4a2713aSLionel Sambuc void foo(Y<X> x) {} 125*f4a2713aSLionel Sambuc // CHECK: "\01?foo@NA@PR13207@@YAXV?$Y@VX@NA@PR13207@@@12@@Z" 126*f4a2713aSLionel Sambuc void foofoo(Y<Y<X> > x) {} 127*f4a2713aSLionel Sambuc // CHECK: "\01?foofoo@NA@PR13207@@YAXV?$Y@V?$Y@VX@NA@PR13207@@@NA@PR13207@@@12@@Z" 128*f4a2713aSLionel Sambuc } 129*f4a2713aSLionel Sambuc 130*f4a2713aSLionel Sambuc namespace NB { 131*f4a2713aSLionel Sambuc class X {}; 132*f4a2713aSLionel Sambuc template<class T> class Y {}; 133*f4a2713aSLionel Sambuc void foo(Y<NA::X> x) {} 134*f4a2713aSLionel Sambuc // CHECK: "\01?foo@NB@PR13207@@YAXV?$Y@VX@NA@PR13207@@@12@@Z" 135*f4a2713aSLionel Sambuc 136*f4a2713aSLionel Sambuc void bar(NA::Y<X> x) {} 137*f4a2713aSLionel Sambuc // CHECK: "\01?bar@NB@PR13207@@YAXV?$Y@VX@NB@PR13207@@@NA@2@@Z" 138*f4a2713aSLionel Sambuc 139*f4a2713aSLionel Sambuc void spam(NA::Y<NA::X> x) {} 140*f4a2713aSLionel Sambuc // CHECK: "\01?spam@NB@PR13207@@YAXV?$Y@VX@NA@PR13207@@@NA@2@@Z" 141*f4a2713aSLionel Sambuc 142*f4a2713aSLionel Sambuc void foobar(NA::Y<Y<X> > a, Y<Y<X> >) {} 143*f4a2713aSLionel Sambuc // CHECK: "\01?foobar@NB@PR13207@@YAXV?$Y@V?$Y@VX@NB@PR13207@@@NB@PR13207@@@NA@2@V312@@Z" 144*f4a2713aSLionel Sambuc 145*f4a2713aSLionel Sambuc void foobarspam(Y<X> a, NA::Y<Y<X> > b, Y<Y<X> >) {} 146*f4a2713aSLionel Sambuc // CHECK: "\01?foobarspam@NB@PR13207@@YAXV?$Y@VX@NB@PR13207@@@12@V?$Y@V?$Y@VX@NB@PR13207@@@NB@PR13207@@@NA@2@V412@@Z" 147*f4a2713aSLionel Sambuc 148*f4a2713aSLionel Sambuc void foobarbaz(Y<X> a, NA::Y<Y<X> > b, Y<Y<X> >, Y<Y<X> > c) {} 149*f4a2713aSLionel Sambuc // CHECK: "\01?foobarbaz@NB@PR13207@@YAXV?$Y@VX@NB@PR13207@@@12@V?$Y@V?$Y@VX@NB@PR13207@@@NB@PR13207@@@NA@2@V412@2@Z" 150*f4a2713aSLionel Sambuc 151*f4a2713aSLionel Sambuc void foobarbazqux(Y<X> a, NA::Y<Y<X> > b, Y<Y<X> >, Y<Y<X> > c , NA::Y<Y<Y<X> > > d) {} 152*f4a2713aSLionel Sambuc // CHECK: "\01?foobarbazqux@NB@PR13207@@YAXV?$Y@VX@NB@PR13207@@@12@V?$Y@V?$Y@VX@NB@PR13207@@@NB@PR13207@@@NA@2@V412@2V?$Y@V?$Y@V?$Y@VX@NB@PR13207@@@NB@PR13207@@@NB@PR13207@@@52@@Z" 153*f4a2713aSLionel Sambuc } 154*f4a2713aSLionel Sambuc 155*f4a2713aSLionel Sambuc namespace NC { 156*f4a2713aSLionel Sambuc class X {}; 157*f4a2713aSLionel Sambuc template<class T> class Y {}; 158*f4a2713aSLionel Sambuc 159*f4a2713aSLionel Sambuc void foo(Y<NB::X> x) {} 160*f4a2713aSLionel Sambuc // CHECK: "\01?foo@NC@PR13207@@YAXV?$Y@VX@NB@PR13207@@@12@@Z" 161*f4a2713aSLionel Sambuc 162*f4a2713aSLionel Sambuc void foobar(NC::Y<NB::Y<NA::Y<NA::X> > > x) {} 163*f4a2713aSLionel Sambuc // CHECK: "\01?foobar@NC@PR13207@@YAXV?$Y@V?$Y@V?$Y@VX@NA@PR13207@@@NA@PR13207@@@NB@PR13207@@@12@@Z" 164*f4a2713aSLionel Sambuc } 165*f4a2713aSLionel Sambuc } 166*f4a2713aSLionel Sambuc 167*f4a2713aSLionel Sambuc // Function template names are not considered for backreferencing, but normal 168*f4a2713aSLionel Sambuc // function names are. 169*f4a2713aSLionel Sambuc namespace fn_space { 170*f4a2713aSLionel Sambuc struct RetVal { int hash; }; 171*f4a2713aSLionel Sambuc template <typename T> 172*f4a2713aSLionel Sambuc RetVal fun_tmpl(const T &t) { return RetVal(); } 173*f4a2713aSLionel Sambuc RetVal fun_normal(int t) { return RetVal(); } 174*f4a2713aSLionel Sambuc void fun_instantiate() { 175*f4a2713aSLionel Sambuc fun_normal(1); 176*f4a2713aSLionel Sambuc fun_tmpl(1); 177*f4a2713aSLionel Sambuc } 178*f4a2713aSLionel Sambuc // CHECK: "\01?fun_normal@fn_space@@YA?AURetVal@1@H@Z" 179*f4a2713aSLionel Sambuc // CHECK: "\01??$fun_tmpl@H@fn_space@@YA?AURetVal@0@ABH@Z" 180*f4a2713aSLionel Sambuc 181*f4a2713aSLionel Sambuc template <typename T, RetVal (*F)(T)> 182*f4a2713aSLionel Sambuc RetVal fun_tmpl_recurse(T t) { 183*f4a2713aSLionel Sambuc if (!t) 184*f4a2713aSLionel Sambuc return RetVal(); 185*f4a2713aSLionel Sambuc return F(t - 1); 186*f4a2713aSLionel Sambuc } 187*f4a2713aSLionel Sambuc RetVal ident(int x) { return RetVal(); } 188*f4a2713aSLionel Sambuc void fun_instantiate2() { 189*f4a2713aSLionel Sambuc fun_tmpl_recurse<int, fun_tmpl_recurse<int, ident> >(10); 190*f4a2713aSLionel Sambuc } 191*f4a2713aSLionel Sambuc // CHECK: "\01??$fun_tmpl_recurse@H$1??$fun_tmpl_recurse@H$1?ident@fn_space@@YA?AURetVal@2@H@Z@fn_space@@YA?AURetVal@1@H@Z@fn_space@@YA?AURetVal@0@H@Z" 192*f4a2713aSLionel Sambuc // CHECK: "\01??$fun_tmpl_recurse@H$1?ident@fn_space@@YA?AURetVal@2@H@Z@fn_space@@YA?AURetVal@0@H@Z" 193*f4a2713aSLionel Sambuc } 194