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