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