[clang] [clang] Implement P2582R1: CTAD from inherited constructors (PR #98788)
Haojian Wu via cfe-commits
cfe-commits at lists.llvm.org
Tue Oct 22 01:43:31 PDT 2024
================
@@ -1107,8 +1172,32 @@ BuildDeductionGuideForTypeAlias(Sema &SemaRef,
Sema::CodeSynthesisContext::BuildingDeductionGuides)) {
auto *GG = cast<CXXDeductionGuideDecl>(FPrime);
- Expr *IsDeducible = buildIsDeducibleConstraint(
- SemaRef, AliasTemplate, FPrime->getReturnType(), FPrimeTemplateParams);
+ TypeSourceInfo *TSI = GG->getTypeSourceInfo();
+ QualType ReturnType = FPrime->getReturnType();
+ TemplateDecl *DeducedTemplate =
+ FromInheritedCtor ? FromInheritedCtor->DerivedClassTemplate
+ : AliasTemplate;
+ if (FromInheritedCtor) {
+ TSI = buildInheritedConstructorDeductionGuideType(
+ SemaRef, *FromInheritedCtor, TSI);
+ if (!TSI)
+ return nullptr;
+ ReturnType = TSI->getType()
+ .getTypePtr()
+ ->getAs<FunctionProtoType>()
+ ->getReturnType();
+ }
+
+ // We omit the deducible constraint for inherited constructor deduction
+ // guides because they would take precedence over the derived class' own
+ // deduction guides due to [over.match.best.general]p2.5 and
+ // [temp.func.order]p6.4 If the alias were not deducible in this case, the
+ // deduction guide would already not be deducible due to the partial
+ // specialization `CC<>` failing substitution.
----------------
hokein wrote:
Not yet, there's been no response from the CWG on the [issue](https://github.com/cplusplus/CWG/issues/607). The current implementation follows the suggestion outlined in that issue, and I think it's fine as is. However, we should probably reference this issue in a comment for clarity.
You can also check our related [discussion](https://github.com/llvm/llvm-project/pull/98788#discussion_r1686255752).
https://github.com/llvm/llvm-project/pull/98788
More information about the cfe-commits
mailing list