r371476 - Fix crash mangling an explicit lambda non-type template parameter pack

Richard Smith via cfe-commits cfe-commits at lists.llvm.org
Mon Sep 9 17:39:53 PDT 2019


Author: rsmith
Date: Mon Sep  9 17:39:53 2019
New Revision: 371476

URL: http://llvm.org/viewvc/llvm-project?rev=371476&view=rev
Log:
Fix crash mangling an explicit lambda non-type template parameter pack
that is not a pack expansion.

Modified:
    cfe/trunk/lib/AST/ItaniumMangle.cpp
    cfe/trunk/test/CodeGenCXX/mangle-lambda-explicit-template-params.cpp

Modified: cfe/trunk/lib/AST/ItaniumMangle.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ItaniumMangle.cpp?rev=371476&r1=371475&r2=371476&view=diff
==============================================================================
--- cfe/trunk/lib/AST/ItaniumMangle.cpp (original)
+++ cfe/trunk/lib/AST/ItaniumMangle.cpp Mon Sep  9 17:39:53 2019
@@ -1704,7 +1704,8 @@ void CXXNameMangler::mangleTemplateParam
       QualType T = Tn->getType();
       if (Tn->isParameterPack()) {
         Out << "Tp";
-        T = T->castAs<PackExpansionType>()->getPattern();
+        if (auto *PackExpansion = T->getAs<PackExpansionType>())
+          T = PackExpansion->getPattern();
       }
       Out << "Tn";
       mangleType(T);

Modified: cfe/trunk/test/CodeGenCXX/mangle-lambda-explicit-template-params.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/mangle-lambda-explicit-template-params.cpp?rev=371476&r1=371475&r2=371476&view=diff
==============================================================================
--- cfe/trunk/test/CodeGenCXX/mangle-lambda-explicit-template-params.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/mangle-lambda-explicit-template-params.cpp Mon Sep  9 17:39:53 2019
@@ -54,6 +54,12 @@ inline void collision() {
 }
 void use_collision() { collision(); }
 
+namespace pack_not_pack_expansion {
+  template<typename T, int, T...> struct X;
+  // CHECK: @_ZNK23pack_not_pack_expansion1xMUlTyTtTyTnT_TpTnTL0__ETpTyvE_clIiNS_1XEJfEEEDav
+  inline auto x = []<typename T, template<typename U, T, U...> typename, typename ...V>(){}; void f() { x.operator()<int, X, float>(); }
+}
+
 template<typename> void f() {
   // CHECK: define linkonce_odr {{.*}} @_ZZ1fIiEvvENKUlT_E_clIiEEDaS0_(
   auto x = [](auto){};




More information about the cfe-commits mailing list