================
@@ -3216,6 +3226,44 @@ void DeclareImplicitDeductionGuidesForTypeAlias(
   Guides.suppressDiagnostics();
 
   for (auto *G : Guides) {
+    if (auto *DG = dyn_cast<CXXDeductionGuideDecl>(G)) {
+      // The deduction guide is a non-template function decl, we just clone it.
+      auto *FunctionType =
+          SemaRef.Context.getTrivialTypeSourceInfo(DG->getType());
+      FunctionProtoTypeLoc FPTL =
+          FunctionType->getTypeLoc().castAs<FunctionProtoTypeLoc>();
+
+      // Clone the parameters.
+      unsigned ProcessedParamIndex = 0;
+      for (auto *P : DG->parameters()) {
+        auto *TSI = SemaRef.Context.getTrivialTypeSourceInfo(P->getType());
+        ParmVarDecl *NewParam = ParmVarDecl::Create(
+            SemaRef.Context, G->getDeclContext(), P->getBeginLoc(),
+            P->getLocation(), nullptr, TSI->getType(), TSI, SC_None, nullptr);
+        NewParam->setScopeInfo(0, ProcessedParamIndex);
+        FPTL.setParam(ProcessedParamIndex, NewParam);
+        ProcessedParamIndex++;
----------------
zyn0217 wrote:

Do we need to inject the `NewParam` into the new `DeductionGuide` later? i.e. 
call `NewParam->setOwningFunction()` somewhere below.

https://github.com/llvm/llvm-project/pull/96686
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to