From 7ac42374abc01d89235c862cc44da0c6c930489c Mon Sep 17 00:00:00 2001 From: Richard Smith Date: Thu, 5 Sep 2019 01:23:47 +0000 Subject: [c++20] Fix some ambiguities in our mangling of lambdas with explicit template parameters. This finishes the implementation of the proposal described in https://github.com/itanium-cxx-abi/cxx-abi/issues/31. (We already implemented the extensions, but didn't take them into account when computing mangling numbers, and didn't deal properly with expanded parameter packs, and didn't disambiguate between different levels of template parameters in manglings.) llvm-svn: 371004 --- .../mangle-lambda-explicit-template-params.cpp | 59 ++++++++++++++++++++++ 1 file changed, 59 insertions(+) (limited to 'clang/test/CodeGenCXX/mangle-lambda-explicit-template-params.cpp') diff --git a/clang/test/CodeGenCXX/mangle-lambda-explicit-template-params.cpp b/clang/test/CodeGenCXX/mangle-lambda-explicit-template-params.cpp index b88b0d56fd9..dba10fbf01d 100644 --- a/clang/test/CodeGenCXX/mangle-lambda-explicit-template-params.cpp +++ b/clang/test/CodeGenCXX/mangle-lambda-explicit-template-params.cpp @@ -33,9 +33,68 @@ void call_inline_func() { inline_func(); } +template struct X {}; + +inline auto pack = [](T (&...)[N]) {}; +int arr1[] = {1}; +int arr2[] = {1, 2}; +// CHECK: @_ZNK4packMUlTpTyTpTnT_DpRAT0__S_E_clIJiiEJLi1ELi2EEEEDaS2_( +void use_pack() { pack(arr1, arr2); } + +inline void collision() { + auto a = [] typename>{}; + auto b = [] typename>{}; + auto c = [] typename>{}; + a.operator()(); + // CHECK: @_ZZ9collisionvENKUlTyTtTyTnT_EvE_clIi1XEEDav + b.operator()(); + // CHECK: @_ZZ9collisionvENKUlTyTtTyTnTL0__EvE_clIi1XEEDav + c.operator()(); + // CHECK: @_ZZ9collisionvENKUlTyTtTyTnT_EvE0_clIi1XEEDav +} +void use_collision() { collision(); } + template void f() { // CHECK: define linkonce_odr {{.*}} @_ZZ1fIiEvvENKUlT_E_clIiEEDaS0_( auto x = [](auto){}; x(0); } void use_f() { f(); } + +template struct Y { + template struct Z {}; +}; + +template void expanded() { + auto x = [] typename...>{}; + auto y = [] typename>{}; + auto z = [] typename, template typename>{}; + // FIXME: Should we really require 'template' for y and z? + x.template operator()<(T())..., Y::template Z...>(); + y.template operator()<0, Y::Z>(); + y.template operator()<1, Y::Z>(); + z.template operator()<1, 2, Y::Z, Y::Z>(); +} +void use_expanded() { + // CHECK: @_ZZ8expandedIJEEvvENKUlvE_clIJEJEEEDav( + // CHECK: @_ZZ8expandedIJEEvvENKUlTniTtTniEvE_clILi0EN1YIiE1ZEEEDav( + // CHECK: @_ZZ8expandedIJEEvvENKUlTniTtTniEvE_clILi1EN1YIiE1ZEEEDav( + // CHECK: @_ZZ8expandedIJEEvvENKUlTniTniTtTniETtTniEvE_clILi1ELi2EN1YIiE1ZENS2_IfE1ZEEEDav( + expanded<>(); + + // FIXME: Should we really be using J...E for arguments corresponding to an + // expanded parameter pack? + // Note that the s of 'x' and 'y' collide here, after pack expansion. + // CHECK: @_ZZ8expandedIJiEEvvENKUlTniTtTniEvE_clIJLi0EEJN1YIiE1ZEEEEDav( + // CHECK: @_ZZ8expandedIJiEEvvENKUlTniTtTniEvE0_clILi0EN1YIiE1ZEEEDav( + // CHECK: @_ZZ8expandedIJiEEvvENKUlTniTtTniEvE0_clILi1EN1YIiE1ZEEEDav( + // CHECK: @_ZZ8expandedIJiEEvvENKUlTniTniTtTniETtTniEvE_clILi1ELi2EN1YIiE1ZENS2_IfE1ZEEEDav( + expanded(); + + // Note that the s of 'x' and 'z' collide here, after pack expansion. + // CHECK: @_ZZ8expandedIJiiEEvvENKUlTniTniTtTniETtTniEvE_clIJLi0ELi0EEJN1YIiE1ZES4_EEEDav( + // CHECK: @_ZZ8expandedIJiiEEvvENKUlTniTtTniEvE_clILi0EN1YIiE1ZEEEDav( + // CHECK: @_ZZ8expandedIJiiEEvvENKUlTniTtTniEvE_clILi1EN1YIiE1ZEEEDav( + // CHECK: @_ZZ8expandedIJiiEEvvENKUlTniTniTtTniETtTniEvE0_clILi1ELi2EN1YIiE1ZENS2_IfE1ZEEEDav( + expanded(); +} -- cgit v1.2.3