blob: 264cc113cd57e50770f3eeda550afb4a019fd209 [file] [log] [blame]
Richard Smith9ca5c422011-10-13 22:29:44 +00001// RUN: %clang_cc1 -std=c++11 -emit-llvm -triple=x86_64-apple-darwin9 -o - %s | FileCheck %s
Douglas Gregorad6edc12011-01-04 22:16:00 +00002
3template<unsigned I, typename ...Types>
4struct X { };
5
Douglas Gregord81c7c12011-01-13 16:39:34 +00006template<typename T> struct identity { };
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 { };
11
Stephen Lin43622612013-08-15 06:47:53 +000012// CHECK-LABEL: define weak_odr void @_Z2f0IJEEv1XIXsZT_EJDpRT_EE
Douglas Gregorad6edc12011-01-04 22:16:00 +000013template<typename ...Types>
14void f0(X<sizeof...(Types), Types&...>) { }
15
16template void f0(X<0>);
17
Stephen Lin43622612013-08-15 06:47:53 +000018// CHECK-LABEL: define weak_odr void @_Z2f0IJifdEEv1XIXsZT_EJDpRT_EE
Douglas Gregorad6edc12011-01-04 22:16:00 +000019template void f0<int, float, double>(X<3, int&, float&, double&>);
Douglas Gregord81c7c12011-01-13 16:39:34 +000020
21// Mangling for template argument packs
22template<typename ...Types> void f1() {}
Stephen Lin43622612013-08-15 06:47:53 +000023// CHECK-LABEL: define weak_odr void @_Z2f1IJEEvv
Douglas Gregord81c7c12011-01-13 16:39:34 +000024template void f1<>();
Stephen Lin43622612013-08-15 06:47:53 +000025// CHECK-LABEL: define weak_odr void @_Z2f1IJiEEvv
Douglas Gregord81c7c12011-01-13 16:39:34 +000026template void f1<int>();
Stephen Lin43622612013-08-15 06:47:53 +000027// CHECK-LABEL: define weak_odr void @_Z2f1IJifEEvv
Douglas Gregord81c7c12011-01-13 16:39:34 +000028template void f1<int, float>();
29
30// Mangling function parameter packs
31template<typename ...Types> void f2(Types...) {}
Stephen Lin43622612013-08-15 06:47:53 +000032// CHECK-LABEL: define weak_odr void @_Z2f2IJEEvDpT_
Douglas Gregord81c7c12011-01-13 16:39:34 +000033template void f2<>();
Stephen Lin43622612013-08-15 06:47:53 +000034// CHECK-LABEL: define weak_odr void @_Z2f2IJiEEvDpT_
Douglas Gregord81c7c12011-01-13 16:39:34 +000035template void f2<int>(int);
Stephen Lin43622612013-08-15 06:47:53 +000036// CHECK-LABEL: define weak_odr void @_Z2f2IJifEEvDpT_
Douglas Gregord81c7c12011-01-13 16:39:34 +000037template void f2<int, float>(int, float);
38
39// Mangling non-trivial function parameter packs
40template<typename ...Types> void f3(const Types *...) {}
Stephen Lin43622612013-08-15 06:47:53 +000041// CHECK-LABEL: define weak_odr void @_Z2f3IJEEvDpPKT_
Douglas Gregord81c7c12011-01-13 16:39:34 +000042template void f3<>();
Stephen Lin43622612013-08-15 06:47:53 +000043// CHECK-LABEL: define weak_odr void @_Z2f3IJiEEvDpPKT_
Douglas Gregord81c7c12011-01-13 16:39:34 +000044template void f3<int>(const int*);
Stephen Lin43622612013-08-15 06:47:53 +000045// CHECK-LABEL: define weak_odr void @_Z2f3IJifEEvDpPKT_
Douglas Gregord81c7c12011-01-13 16:39:34 +000046template void f3<int, float>(const int*, const float*);
47
48// Mangling of type pack expansions in a template argument
49template<typename ...Types> tuple<Types...> f4() {}
Stephen Lin43622612013-08-15 06:47:53 +000050// CHECK-LABEL: define weak_odr void @_Z2f4IJifdEE5tupleIJDpT_EEv
Douglas Gregord81c7c12011-01-13 16:39:34 +000051template tuple<int, float, double> f4();
52
53// Mangling of type pack expansions in a function type
54template<typename R, typename ...ArgTypes> identity<R(ArgTypes...)> f5() {}
Stephen Lin43622612013-08-15 06:47:53 +000055// CHECK-LABEL: define weak_odr void @_Z2f5IiJifdEE8identityIFT_DpT0_EEv
Douglas Gregord81c7c12011-01-13 16:39:34 +000056template identity<int(int, float, double)> f5();
57
58// Mangling of non-type template argument expansions
59template<int ...Values> int_tuple<Values...> f6() {}
Stephen Lin43622612013-08-15 06:47:53 +000060// CHECK-LABEL: define weak_odr void @_Z2f6IJLi1ELi2ELi3EEE9int_tupleIJXspT_EEEv
Douglas Gregord81c7c12011-01-13 16:39:34 +000061template int_tuple<1, 2, 3> f6();
62
63// Mangling of template template argument expansions
64template<template<typename> class ...Templates>
65template_tuple<Templates...> f7() {}
Stephen Lin43622612013-08-15 06:47:53 +000066// CHECK-LABEL: define weak_odr void @_Z2f7IJ8identity13add_referenceEE14template_tupleIJDpT_EEv
Douglas Gregord81c7c12011-01-13 16:39:34 +000067template template_tuple<identity, add_reference> f7();