[clang] 6876514 - Fix assertion failure mangling an unresolved template argument that

Richard Smith via cfe-commits cfe-commits at lists.llvm.org
Sun Sep 24 11:53:10 PDT 2023


Author: Richard Smith
Date: 2023-09-24T11:52:58-07:00
New Revision: 68765143c6765a694d40d4c3fea43893cc025433

URL: https://github.com/llvm/llvm-project/commit/68765143c6765a694d40d4c3fea43893cc025433
DIFF: https://github.com/llvm/llvm-project/commit/68765143c6765a694d40d4c3fea43893cc025433.diff

LOG: Fix assertion failure mangling an unresolved template argument that
corresponds to a parameter pack.

Fixes #67244.

Added: 
    

Modified: 
    clang/lib/AST/ItaniumMangle.cpp
    clang/test/CodeGenCXX/mangle-concept.cpp

Removed: 
    


################################################################################
diff  --git a/clang/lib/AST/ItaniumMangle.cpp b/clang/lib/AST/ItaniumMangle.cpp
index e7a5a6b6b8119c0..4cb1ab56a1e618a 100644
--- a/clang/lib/AST/ItaniumMangle.cpp
+++ b/clang/lib/AST/ItaniumMangle.cpp
@@ -5788,13 +5788,14 @@ struct CXXNameMangler::TemplateArgManglingInfo {
              "no parameter for argument");
       Param = ResolvedTemplate->getTemplateParameters()->getParam(ParamIdx);
 
-      // If we reach an expanded parameter pack whose argument isn't in pack
-      // form, that means Sema couldn't figure out which arguments belonged to
-      // it, because it contains a pack expansion. Track the expanded pack for
-      // all further template arguments until we hit that pack expansion.
+      // If we reach a parameter pack whose argument isn't in pack form, that
+      // means Sema couldn't or didn't figure out which arguments belonged to
+      // it, because it contains a pack expansion or because Sema bailed out of
+      // computing parameter / argument correspondence before this point. Track
+      // the pack as the corresponding parameter for all further template
+      // arguments until we hit a pack expansion, at which point we don't know
+      // the correspondence between parameters and arguments at all.
       if (Param->isParameterPack() && Arg.getKind() != TemplateArgument::Pack) {
-        assert(getExpandedPackSize(Param) &&
-               "failed to form pack argument for parameter pack");
         UnresolvedExpandedPack = Param;
       }
     }

diff  --git a/clang/test/CodeGenCXX/mangle-concept.cpp b/clang/test/CodeGenCXX/mangle-concept.cpp
index dec26aeaeca464c..391cf09ede8555d 100644
--- a/clang/test/CodeGenCXX/mangle-concept.cpp
+++ b/clang/test/CodeGenCXX/mangle-concept.cpp
@@ -220,3 +220,11 @@ namespace test7 {
   }
   template void f<int>();
 }
+
+namespace gh67244 {
+  template<typename T, typename ...Ts> constexpr bool B = true;
+  template<typename T, typename ...Ts> concept C = B<T, Ts...>;
+  template<C<int, float> T> void f(T) {}
+  // CHECK: define {{.*}} @_ZN7gh672441fITkNS_1CIifEEiEEvT_(
+  template void f(int);
+}


        


More information about the cfe-commits mailing list