[clang] [clang] Implement P2582R1: CTAD from inherited constructors (PR #98788)
Haojian Wu via cfe-commits
cfe-commits at lists.llvm.org
Mon Jul 22 02:38:48 PDT 2024
================
@@ -1957,17 +1957,26 @@ class CXXDeductionGuideDecl : public FunctionDecl {
ExplicitSpecifier ES,
const DeclarationNameInfo &NameInfo, QualType T,
TypeSourceInfo *TInfo, SourceLocation EndLocation,
- CXXConstructorDecl *Ctor, DeductionCandidate Kind)
+ CXXConstructorDecl *Ctor, DeductionCandidate Kind,
+ CXXDeductionGuideDecl *GeneratedFrom,
+ bool IsGeneratedFromInheritedConstructor)
: FunctionDecl(CXXDeductionGuide, C, DC, StartLoc, NameInfo, T, TInfo,
SC_None, false, false, ConstexprSpecKind::Unspecified),
- Ctor(Ctor), ExplicitSpec(ES) {
+ Ctor(Ctor), ExplicitSpec(ES),
+ SourceDeductionGuide(GeneratedFrom,
+ IsGeneratedFromInheritedConstructor) {
if (EndLocation.isValid())
setRangeEnd(EndLocation);
setDeductionCandidateKind(Kind);
}
CXXConstructorDecl *Ctor;
ExplicitSpecifier ExplicitSpec;
+ // The deduction guide, if any, that this deduction guide was generated from,
+ // in the case of alias template deduction or CTAD from inherited
+ // constructors. The bool member indicates whether this deduction guide is
+ // generated from an inherited constructor.
----------------
hokein wrote:
I'd suggest using an enum type for the the source kind of the deduction, rather than using a `bool`.
```
enum SourceKind : bool {
Alias,
InheritedConstructor,
};
```
This also allows us to have a generic getter API `getSourceKind()`/`setSourceKind()`.
https://github.com/llvm/llvm-project/pull/98788
More information about the cfe-commits
mailing list