Home | History | Annotate | Download | only in CodeGenCXX
      1 // RUN: %clang_cc1 -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 { };
      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 
     12 // CHECK: define weak_odr void @_Z2f0IJEEv1XIXsZT_EJDpRT_EE
     13 template<typename ...Types>
     14 void f0(X<sizeof...(Types), Types&...>) { }
     15 
     16 template void f0(X<0>);
     17 
     18 // CHECK: define weak_odr void @_Z2f0IJifdEEv1XIXsZT_EJDpRT_EE
     19 template void f0<int, float, double>(X<3, int&, float&, double&>);
     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...) {}
     32 // CHECK: define weak_odr void @_Z2f2IJEEvDpT_
     33 template void f2<>();
     34 // CHECK: define weak_odr void @_Z2f2IJiEEvDpT_
     35 template void f2<int>(int);
     36 // CHECK: define weak_odr void @_Z2f2IJifEEvDpT_
     37 template void f2<int, float>(int, float);
     38 
     39 // Mangling non-trivial function parameter packs
     40 template<typename ...Types> void f3(const Types *...) {}
     41 // CHECK: define weak_odr void @_Z2f3IJEEvDpPKT_
     42 template void f3<>();
     43 // CHECK: define weak_odr void @_Z2f3IJiEEvDpPKT_
     44 template void f3<int>(const int*);
     45 // CHECK: define weak_odr void @_Z2f3IJifEEvDpPKT_
     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() {}
     50 // CHECK: define weak_odr void @_Z2f4IJifdEE5tupleIJDpT_EEv
     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() {}
     55 // CHECK: define weak_odr void @_Z2f5IiJifdEE8identityIFT_DpT0_EEv
     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();
     68