mangle-lambda-explicit-template-params.cpp 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. // RUN: %clang_cc1 -std=c++2a -triple %itanium_abi_triple -emit-llvm -o - %s -w | FileCheck %s
  2. template<class, int, class>
  3. struct DummyType { };
  4. inline void inline_func() {
  5. // CHECK: UlvE
  6. []{}();
  7. // CHECK: UlTyvE
  8. []<class>{}.operator()<int>();
  9. // CHECK: UlTyT_E
  10. []<class T>(T){}(1);
  11. // CHECK: UlTyTyT_T0_E
  12. []<class T1, class T2>(T1, T2){}(1, 2);
  13. // CHECK: UlTyTyT0_T_E
  14. []<class T1, class T2>(T2, T1){}(2, 1);
  15. // CHECK: UlTniTyTnjT0_E
  16. []<int I, class T, unsigned U>(T){}.operator()<1, int, 2>(3);
  17. // CHECK: UlTyTtTyTniTyETniTyvE
  18. []<class,
  19. template<class, int, class> class,
  20. int,
  21. class>{}.operator()<unsigned, DummyType, 5, int>();
  22. }
  23. void call_inline_func() {
  24. inline_func();
  25. }
  26. template<typename T, int> struct X {};
  27. inline auto pack = []<typename ...T, T ...N>(T (&...)[N]) {};
  28. int arr1[] = {1};
  29. int arr2[] = {1, 2};
  30. // CHECK: @_ZNK4packMUlTpTyTpTnT_DpRAT0__S_E_clIJiiEJLi1ELi2EEEEDaS2_(
  31. void use_pack() { pack(arr1, arr2); }
  32. inline void collision() {
  33. auto a = []<typename T, template<typename U, T> typename>{};
  34. auto b = []<typename T, template<typename U, U> typename>{};
  35. auto c = []<typename T, template<typename U, T> typename>{};
  36. a.operator()<int, X>();
  37. // CHECK: @_ZZ9collisionvENKUlTyTtTyTnT_EvE_clIi1XEEDav
  38. b.operator()<int, X>();
  39. // CHECK: @_ZZ9collisionvENKUlTyTtTyTnTL0__EvE_clIi1XEEDav
  40. c.operator()<int, X>();
  41. // CHECK: @_ZZ9collisionvENKUlTyTtTyTnT_EvE0_clIi1XEEDav
  42. }
  43. void use_collision() { collision(); }
  44. namespace pack_not_pack_expansion {
  45. template<typename T, int, T...> struct X;
  46. // CHECK: @_ZNK23pack_not_pack_expansion1xMUlTyTtTyTnT_TpTnTL0__ETpTyvE_clIiNS_1XEJfEEEDav
  47. inline auto x = []<typename T, template<typename U, T, U...> typename, typename ...V>(){}; void f() { x.operator()<int, X, float>(); }
  48. }
  49. template<typename> void f() {
  50. // CHECK: define linkonce_odr {{.*}} @_ZZ1fIiEvvENKUlT_E_clIiEEDaS0_(
  51. auto x = [](auto){};
  52. x(0);
  53. }
  54. void use_f() { f<int>(); }
  55. template<typename> struct Y {
  56. template<int> struct Z {};
  57. };
  58. template<typename ...T> void expanded() {
  59. auto x = []<T..., template<T> typename...>{};
  60. auto y = []<int, template<int> typename>{};
  61. auto z = []<int, int, template<int> typename, template<int> typename>{};
  62. // FIXME: Should we really require 'template' for y and z?
  63. x.template operator()<(T())..., Y<T>::template Z...>();
  64. y.template operator()<0, Y<int>::Z>();
  65. y.template operator()<1, Y<int>::Z>();
  66. z.template operator()<1, 2, Y<int>::Z, Y<float>::Z>();
  67. }
  68. void use_expanded() {
  69. // CHECK: @_ZZ8expandedIJEEvvENKUlvE_clIJEJEEEDav(
  70. // CHECK: @_ZZ8expandedIJEEvvENKUlTniTtTniEvE_clILi0EN1YIiE1ZEEEDav(
  71. // CHECK: @_ZZ8expandedIJEEvvENKUlTniTtTniEvE_clILi1EN1YIiE1ZEEEDav(
  72. // CHECK: @_ZZ8expandedIJEEvvENKUlTniTniTtTniETtTniEvE_clILi1ELi2EN1YIiE1ZENS2_IfE1ZEEEDav(
  73. expanded<>();
  74. // FIXME: Should we really be using J...E for arguments corresponding to an
  75. // expanded parameter pack?
  76. // Note that the <lambda-sig>s of 'x' and 'y' collide here, after pack expansion.
  77. // CHECK: @_ZZ8expandedIJiEEvvENKUlTniTtTniEvE_clIJLi0EEJN1YIiE1ZEEEEDav(
  78. // CHECK: @_ZZ8expandedIJiEEvvENKUlTniTtTniEvE0_clILi0EN1YIiE1ZEEEDav(
  79. // CHECK: @_ZZ8expandedIJiEEvvENKUlTniTtTniEvE0_clILi1EN1YIiE1ZEEEDav(
  80. // CHECK: @_ZZ8expandedIJiEEvvENKUlTniTniTtTniETtTniEvE_clILi1ELi2EN1YIiE1ZENS2_IfE1ZEEEDav(
  81. expanded<int>();
  82. // Note that the <lambda-sig>s of 'x' and 'z' collide here, after pack expansion.
  83. // CHECK: @_ZZ8expandedIJiiEEvvENKUlTniTniTtTniETtTniEvE_clIJLi0ELi0EEJN1YIiE1ZES4_EEEDav(
  84. // CHECK: @_ZZ8expandedIJiiEEvvENKUlTniTtTniEvE_clILi0EN1YIiE1ZEEEDav(
  85. // CHECK: @_ZZ8expandedIJiiEEvvENKUlTniTtTniEvE_clILi1EN1YIiE1ZEEEDav(
  86. // CHECK: @_ZZ8expandedIJiiEEvvENKUlTniTniTtTniETtTniEvE0_clILi1ELi2EN1YIiE1ZENS2_IfE1ZEEEDav(
  87. expanded<int, int>();
  88. }