Handle explicit lifetime dependence specifiers in initializers

This commit is contained in:
Meghana Gupta
2024-02-01 10:25:34 -08:00
parent a6dbfa9c53
commit c8ece100ba
19 changed files with 191 additions and 50 deletions

View File

@@ -3577,6 +3577,8 @@ TypeRepr *ValueDecl::getResultTypeRepr() const {
returnRepr = SD->getElementTypeRepr();
} else if (auto *MD = dyn_cast<MacroDecl>(this)) {
returnRepr = MD->resultType.getTypeRepr();
} else if (auto *CD = dyn_cast<ConstructorDecl>(this)) {
returnRepr = CD->getResultTypeRepr();
}
return returnRepr;
@@ -10383,7 +10385,7 @@ ConstructorDecl::ConstructorDecl(DeclName Name, SourceLoc ConstructorLoc,
TypeLoc ThrownType,
ParameterList *BodyParams,
GenericParamList *GenericParams,
DeclContext *Parent)
DeclContext *Parent, TypeRepr *ResultTyR)
: AbstractFunctionDecl(DeclKind::Constructor, Parent, Name, ConstructorLoc,
Async, AsyncLoc, Throws, ThrowsLoc, ThrownType,
/*HasImplicitSelfDecl=*/true,
@@ -10393,7 +10395,8 @@ ConstructorDecl::ConstructorDecl(DeclName Name, SourceLoc ConstructorLoc,
{
if (BodyParams)
setParameters(BodyParams);
InitRetType = TypeLoc(ResultTyR);
Bits.ConstructorDecl.HasStubImplementation = 0;
Bits.ConstructorDecl.Failable = Failable;
@@ -10414,7 +10417,8 @@ ConstructorDecl *ConstructorDecl::createImported(
failable, failabilityLoc,
async, asyncLoc,
throws, throwsLoc, TypeLoc::withoutLoc(thrownType),
bodyParams, genericParams, parent);
bodyParams, genericParams, parent,
/*LifetimeDependenceTypeRepr*/ nullptr);
ctor->setClangNode(clangNode);
return ctor;
}
@@ -10432,6 +10436,10 @@ bool ConstructorDecl::isObjCZeroParameterWithLongSelector() const {
return params->get(0)->getInterfaceType()->isVoid();
}
bool ConstructorDecl::hasLifetimeDependentReturn() const {
return isa_and_nonnull<LifetimeDependentReturnTypeRepr>(getResultTypeRepr());
}
DestructorDecl::DestructorDecl(SourceLoc DestructorLoc, DeclContext *Parent)
: AbstractFunctionDecl(DeclKind::Destructor, Parent,
DeclBaseName::createDestructor(), DestructorLoc,