[clang] [Clang][Sema] fix outline member function template with default align crash (PR #78400)

Shafik Yaghmour via cfe-commits cfe-commits at lists.llvm.org
Fri Jan 26 14:32:10 PST 2024


================
@@ -3061,11 +3062,19 @@ bool Sema::SubstDefaultArgument(
           /*ForDefinition*/ false);
       if (addInstantiatedParametersToScope(FD, PatternFD, *LIS, TemplateArgs))
         return true;
+      if (FD->isOutOfLine()) {
+        TemplateArgumentList *CurrentTemplateArgumentList =
+            TemplateArgumentList::CreateCopy(getASTContext(),
+                                             TemplateArgs.getInnermost());
+        NewTemplateArgs = getTemplateInstantiationArgs(
+            FD, FD->getDeclContext(), /*Final=*/false,
+            CurrentTemplateArgumentList, /*RelativeToPrimary=*/true);
+      }
     }
 
     runWithSufficientStackSpace(Loc, [&] {
-      Result = SubstInitializer(PatternExpr, TemplateArgs,
-                                /*DirectInit*/false);
+      Result = SubstInitializer(PatternExpr, NewTemplateArgs,
+                                /*DirectInit*/ false);
----------------
shafik wrote:

`/*DirectInit=*/false)`

https://github.com/llvm/llvm-project/pull/78400


More information about the cfe-commits mailing list