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