[clang] [clang] Implement P2582R1: CTAD from inherited constructors (PR #98788)

Matheus Izvekov via cfe-commits cfe-commits at lists.llvm.org
Wed Nov 6 15:02:43 PST 2024


================
@@ -1173,25 +1276,52 @@ void DeclareImplicitDeductionGuidesForTypeAlias(
         NewParam->setScopeInfo(0, I);
         FPTL.setParam(I, NewParam);
       }
-      auto *Transformed = cast<FunctionDecl>(buildDeductionGuide(
-          SemaRef, AliasTemplate, /*TemplateParams=*/nullptr,
+
+      QualType ReturnType =
+          cast<FunctionProtoType>(FunctionType->getType())->getReturnType();
+      if (FromInheritedCtor) {
+        FunctionType = buildInheritedConstructorDeductionGuideType(
+            SemaRef, *FromInheritedCtor, FunctionType);
+        if (!FunctionType)
+          continue;
+        ReturnType = FunctionType->getType()
+                         .getTypePtr()
+                         ->getAs<FunctionProtoType>()
+                         ->getReturnType();
+      }
----------------
mizvekov wrote:

There is a lot of commonality with this block here and another that appears in `BuildDeductionGuideForTypeAlias`, can we factor it out?

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


More information about the cfe-commits mailing list