1*f4a2713aSLionel Sambuc // RUN: %clang_cc1 -std=c++11 -emit-llvm -triple=x86_64-apple-darwin9 -o - %s | FileCheck %s
2*f4a2713aSLionel Sambuc
3*f4a2713aSLionel Sambuc template<unsigned I, typename ...Types>
4*f4a2713aSLionel Sambuc struct X { };
5*f4a2713aSLionel Sambuc
6*f4a2713aSLionel Sambuc template<typename T> struct identity { };
7*f4a2713aSLionel Sambuc template<typename T> struct add_reference;
8*f4a2713aSLionel Sambuc template<typename ...Types> struct tuple { };
9*f4a2713aSLionel Sambuc template<int ...Values> struct int_tuple { };
10*f4a2713aSLionel Sambuc template<template<typename> class ...Templates> struct template_tuple { };
11*f4a2713aSLionel Sambuc
12*f4a2713aSLionel Sambuc // CHECK-LABEL: define weak_odr void @_Z2f0IJEEv1XIXsZT_EJDpRT_EE
13*f4a2713aSLionel Sambuc template<typename ...Types>
f0(X<sizeof...(Types),Types &...>)14*f4a2713aSLionel Sambuc void f0(X<sizeof...(Types), Types&...>) { }
15*f4a2713aSLionel Sambuc
16*f4a2713aSLionel Sambuc template void f0(X<0>);
17*f4a2713aSLionel Sambuc
18*f4a2713aSLionel Sambuc // CHECK-LABEL: define weak_odr void @_Z2f0IJifdEEv1XIXsZT_EJDpRT_EE
19*f4a2713aSLionel Sambuc template void f0<int, float, double>(X<3, int&, float&, double&>);
20*f4a2713aSLionel Sambuc
21*f4a2713aSLionel Sambuc // Mangling for template argument packs
f1()22*f4a2713aSLionel Sambuc template<typename ...Types> void f1() {}
23*f4a2713aSLionel Sambuc // CHECK-LABEL: define weak_odr void @_Z2f1IJEEvv
24*f4a2713aSLionel Sambuc template void f1<>();
25*f4a2713aSLionel Sambuc // CHECK-LABEL: define weak_odr void @_Z2f1IJiEEvv
26*f4a2713aSLionel Sambuc template void f1<int>();
27*f4a2713aSLionel Sambuc // CHECK-LABEL: define weak_odr void @_Z2f1IJifEEvv
28*f4a2713aSLionel Sambuc template void f1<int, float>();
29*f4a2713aSLionel Sambuc
30*f4a2713aSLionel Sambuc // Mangling function parameter packs
f2(Types...)31*f4a2713aSLionel Sambuc template<typename ...Types> void f2(Types...) {}
32*f4a2713aSLionel Sambuc // CHECK-LABEL: define weak_odr void @_Z2f2IJEEvDpT_
33*f4a2713aSLionel Sambuc template void f2<>();
34*f4a2713aSLionel Sambuc // CHECK-LABEL: define weak_odr void @_Z2f2IJiEEvDpT_
35*f4a2713aSLionel Sambuc template void f2<int>(int);
36*f4a2713aSLionel Sambuc // CHECK-LABEL: define weak_odr void @_Z2f2IJifEEvDpT_
37*f4a2713aSLionel Sambuc template void f2<int, float>(int, float);
38*f4a2713aSLionel Sambuc
39*f4a2713aSLionel Sambuc // Mangling non-trivial function parameter packs
f3(const Types * ...)40*f4a2713aSLionel Sambuc template<typename ...Types> void f3(const Types *...) {}
41*f4a2713aSLionel Sambuc // CHECK-LABEL: define weak_odr void @_Z2f3IJEEvDpPKT_
42*f4a2713aSLionel Sambuc template void f3<>();
43*f4a2713aSLionel Sambuc // CHECK-LABEL: define weak_odr void @_Z2f3IJiEEvDpPKT_
44*f4a2713aSLionel Sambuc template void f3<int>(const int*);
45*f4a2713aSLionel Sambuc // CHECK-LABEL: define weak_odr void @_Z2f3IJifEEvDpPKT_
46*f4a2713aSLionel Sambuc template void f3<int, float>(const int*, const float*);
47*f4a2713aSLionel Sambuc
48*f4a2713aSLionel Sambuc // Mangling of type pack expansions in a template argument
f4()49*f4a2713aSLionel Sambuc template<typename ...Types> tuple<Types...> f4() {}
50*f4a2713aSLionel Sambuc // CHECK-LABEL: define weak_odr void @_Z2f4IJifdEE5tupleIJDpT_EEv
51*f4a2713aSLionel Sambuc template tuple<int, float, double> f4();
52*f4a2713aSLionel Sambuc
53*f4a2713aSLionel Sambuc // Mangling of type pack expansions in a function type
f5()54*f4a2713aSLionel Sambuc template<typename R, typename ...ArgTypes> identity<R(ArgTypes...)> f5() {}
55*f4a2713aSLionel Sambuc // CHECK-LABEL: define weak_odr void @_Z2f5IiJifdEE8identityIFT_DpT0_EEv
56*f4a2713aSLionel Sambuc template identity<int(int, float, double)> f5();
57*f4a2713aSLionel Sambuc
58*f4a2713aSLionel Sambuc // Mangling of non-type template argument expansions
f6()59*f4a2713aSLionel Sambuc template<int ...Values> int_tuple<Values...> f6() {}
60*f4a2713aSLionel Sambuc // CHECK-LABEL: define weak_odr void @_Z2f6IJLi1ELi2ELi3EEE9int_tupleIJXspT_EEEv
61*f4a2713aSLionel Sambuc template int_tuple<1, 2, 3> f6();
62*f4a2713aSLionel Sambuc
63*f4a2713aSLionel Sambuc // Mangling of template template argument expansions
64*f4a2713aSLionel Sambuc template<template<typename> class ...Templates>
f7()65*f4a2713aSLionel Sambuc template_tuple<Templates...> f7() {}
66*f4a2713aSLionel Sambuc // CHECK-LABEL: define weak_odr void @_Z2f7IJ8identity13add_referenceEE14template_tupleIJDpT_EEv
67*f4a2713aSLionel Sambuc template template_tuple<identity, add_reference> f7();
68