mangle-variadic-templates.cpp revision 762bb9d0ad20320b9f97a841dce57ba5e8e48b07
1762bb9d0ad20320b9f97a841dce57ba5e8e48b07Richard Smith// RUN: %clang_cc1 -std=c++11 -emit-llvm -triple=x86_64-apple-darwin9 -o - %s | FileCheck %s
246268675d3f8900b1b2c1392601aa50918bfef88Douglas Gregor
346268675d3f8900b1b2c1392601aa50918bfef88Douglas Gregortemplate<unsigned I, typename ...Types>
446268675d3f8900b1b2c1392601aa50918bfef88Douglas Gregorstruct X { };
546268675d3f8900b1b2c1392601aa50918bfef88Douglas Gregor
64fc4866945de9b0f1f77a17557060f0ff959b0b1Douglas Gregortemplate<typename T> struct identity { };
74fc4866945de9b0f1f77a17557060f0ff959b0b1Douglas Gregortemplate<typename T> struct add_reference;
84fc4866945de9b0f1f77a17557060f0ff959b0b1Douglas Gregortemplate<typename ...Types> struct tuple { };
94fc4866945de9b0f1f77a17557060f0ff959b0b1Douglas Gregortemplate<int ...Values> struct int_tuple { };
104fc4866945de9b0f1f77a17557060f0ff959b0b1Douglas Gregortemplate<template<typename> class ...Templates> struct template_tuple { };
114fc4866945de9b0f1f77a17557060f0ff959b0b1Douglas Gregor
12255c269f35928a8194fb591656c67ec4ebd846ebDouglas Gregor// CHECK: define weak_odr void @_Z2f0IJEEv1XIXsZT_EJDpRT_EE
1346268675d3f8900b1b2c1392601aa50918bfef88Douglas Gregortemplate<typename ...Types>
1446268675d3f8900b1b2c1392601aa50918bfef88Douglas Gregorvoid f0(X<sizeof...(Types), Types&...>) { }
1546268675d3f8900b1b2c1392601aa50918bfef88Douglas Gregor
1646268675d3f8900b1b2c1392601aa50918bfef88Douglas Gregortemplate void f0(X<0>);
1746268675d3f8900b1b2c1392601aa50918bfef88Douglas Gregor
18255c269f35928a8194fb591656c67ec4ebd846ebDouglas Gregor// CHECK: define weak_odr void @_Z2f0IJifdEEv1XIXsZT_EJDpRT_EE
1946268675d3f8900b1b2c1392601aa50918bfef88Douglas Gregortemplate void f0<int, float, double>(X<3, int&, float&, double&>);
204fc4866945de9b0f1f77a17557060f0ff959b0b1Douglas Gregor
214fc4866945de9b0f1f77a17557060f0ff959b0b1Douglas Gregor// Mangling for template argument packs
224fc4866945de9b0f1f77a17557060f0ff959b0b1Douglas Gregortemplate<typename ...Types> void f1() {}
234fc4866945de9b0f1f77a17557060f0ff959b0b1Douglas Gregor// CHECK: define weak_odr void @_Z2f1IJEEvv
244fc4866945de9b0f1f77a17557060f0ff959b0b1Douglas Gregortemplate void f1<>();
254fc4866945de9b0f1f77a17557060f0ff959b0b1Douglas Gregor// CHECK: define weak_odr void @_Z2f1IJiEEvv
264fc4866945de9b0f1f77a17557060f0ff959b0b1Douglas Gregortemplate void f1<int>();
274fc4866945de9b0f1f77a17557060f0ff959b0b1Douglas Gregor// CHECK: define weak_odr void @_Z2f1IJifEEvv
284fc4866945de9b0f1f77a17557060f0ff959b0b1Douglas Gregortemplate void f1<int, float>();
294fc4866945de9b0f1f77a17557060f0ff959b0b1Douglas Gregor
304fc4866945de9b0f1f77a17557060f0ff959b0b1Douglas Gregor// Mangling function parameter packs
314fc4866945de9b0f1f77a17557060f0ff959b0b1Douglas Gregortemplate<typename ...Types> void f2(Types...) {}
32255c269f35928a8194fb591656c67ec4ebd846ebDouglas Gregor// CHECK: define weak_odr void @_Z2f2IJEEvDpT_
334fc4866945de9b0f1f77a17557060f0ff959b0b1Douglas Gregortemplate void f2<>();
34255c269f35928a8194fb591656c67ec4ebd846ebDouglas Gregor// CHECK: define weak_odr void @_Z2f2IJiEEvDpT_
354fc4866945de9b0f1f77a17557060f0ff959b0b1Douglas Gregortemplate void f2<int>(int);
36255c269f35928a8194fb591656c67ec4ebd846ebDouglas Gregor// CHECK: define weak_odr void @_Z2f2IJifEEvDpT_
374fc4866945de9b0f1f77a17557060f0ff959b0b1Douglas Gregortemplate void f2<int, float>(int, float);
384fc4866945de9b0f1f77a17557060f0ff959b0b1Douglas Gregor
394fc4866945de9b0f1f77a17557060f0ff959b0b1Douglas Gregor// Mangling non-trivial function parameter packs
404fc4866945de9b0f1f77a17557060f0ff959b0b1Douglas Gregortemplate<typename ...Types> void f3(const Types *...) {}
41255c269f35928a8194fb591656c67ec4ebd846ebDouglas Gregor// CHECK: define weak_odr void @_Z2f3IJEEvDpPKT_
424fc4866945de9b0f1f77a17557060f0ff959b0b1Douglas Gregortemplate void f3<>();
43255c269f35928a8194fb591656c67ec4ebd846ebDouglas Gregor// CHECK: define weak_odr void @_Z2f3IJiEEvDpPKT_
444fc4866945de9b0f1f77a17557060f0ff959b0b1Douglas Gregortemplate void f3<int>(const int*);
45255c269f35928a8194fb591656c67ec4ebd846ebDouglas Gregor// CHECK: define weak_odr void @_Z2f3IJifEEvDpPKT_
464fc4866945de9b0f1f77a17557060f0ff959b0b1Douglas Gregortemplate void f3<int, float>(const int*, const float*);
474fc4866945de9b0f1f77a17557060f0ff959b0b1Douglas Gregor
484fc4866945de9b0f1f77a17557060f0ff959b0b1Douglas Gregor// Mangling of type pack expansions in a template argument
494fc4866945de9b0f1f77a17557060f0ff959b0b1Douglas Gregortemplate<typename ...Types> tuple<Types...> f4() {}
50255c269f35928a8194fb591656c67ec4ebd846ebDouglas Gregor// CHECK: define weak_odr void @_Z2f4IJifdEE5tupleIJDpT_EEv
514fc4866945de9b0f1f77a17557060f0ff959b0b1Douglas Gregortemplate tuple<int, float, double> f4();
524fc4866945de9b0f1f77a17557060f0ff959b0b1Douglas Gregor
534fc4866945de9b0f1f77a17557060f0ff959b0b1Douglas Gregor// Mangling of type pack expansions in a function type
544fc4866945de9b0f1f77a17557060f0ff959b0b1Douglas Gregortemplate<typename R, typename ...ArgTypes> identity<R(ArgTypes...)> f5() {}
55255c269f35928a8194fb591656c67ec4ebd846ebDouglas Gregor// CHECK: define weak_odr void @_Z2f5IiJifdEE8identityIFT_DpT0_EEv
564fc4866945de9b0f1f77a17557060f0ff959b0b1Douglas Gregortemplate identity<int(int, float, double)> f5();
574fc4866945de9b0f1f77a17557060f0ff959b0b1Douglas Gregor
584fc4866945de9b0f1f77a17557060f0ff959b0b1Douglas Gregor// Mangling of non-type template argument expansions
594fc4866945de9b0f1f77a17557060f0ff959b0b1Douglas Gregortemplate<int ...Values> int_tuple<Values...> f6() {}
604fc4866945de9b0f1f77a17557060f0ff959b0b1Douglas Gregor// CHECK: define weak_odr void @_Z2f6IJLi1ELi2ELi3EEE9int_tupleIJXspT_EEEv
614fc4866945de9b0f1f77a17557060f0ff959b0b1Douglas Gregortemplate int_tuple<1, 2, 3> f6();
624fc4866945de9b0f1f77a17557060f0ff959b0b1Douglas Gregor
634fc4866945de9b0f1f77a17557060f0ff959b0b1Douglas Gregor// Mangling of template template argument expansions
644fc4866945de9b0f1f77a17557060f0ff959b0b1Douglas Gregortemplate<template<typename> class ...Templates>
654fc4866945de9b0f1f77a17557060f0ff959b0b1Douglas Gregortemplate_tuple<Templates...> f7() {}
664fc4866945de9b0f1f77a17557060f0ff959b0b1Douglas Gregor// CHECK: define weak_odr void @_Z2f7IJ8identity13add_referenceEE14template_tupleIJDpT_EEv
674fc4866945de9b0f1f77a17557060f0ff959b0b1Douglas Gregortemplate template_tuple<identity, add_reference> f7();
68