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