@@ -2036,9 +2036,20 @@ namespace {
2036
2036
}
2037
2037
2038
2038
void markReturnsUnsafeNonescapable (AbstractFunctionDecl *fd) {
2039
- fd->getAttrs ().add (new (Impl.SwiftContext )
2040
- UnsafeNonEscapableResultAttr (/* Implicit=*/ true ));
2041
2039
fd->getAttrs ().add (new (Impl.SwiftContext ) UnsafeAttr (/* Implicit=*/ true ));
2040
+
2041
+ unsigned resultIndex = fd->getParameters ()->size ();
2042
+ if (fd->hasImplicitSelfDecl ()) {
2043
+ ++resultIndex;
2044
+ }
2045
+ SmallVector<LifetimeDependenceInfo, 1 > lifetimeDependencies;
2046
+ LifetimeDependenceInfo immortalLifetime (nullptr , nullptr , resultIndex,
2047
+ /* isImmortal*/ true );
2048
+ lifetimeDependencies.push_back (immortalLifetime);
2049
+ Impl.SwiftContext .evaluator .cacheOutput (
2050
+ LifetimeDependenceInfoRequest{fd},
2051
+ Impl.SwiftContext .AllocateCopy (lifetimeDependencies));
2052
+ return ;
2042
2053
}
2043
2054
2044
2055
Decl *VisitRecordDecl (const clang::RecordDecl *decl) {
@@ -4060,6 +4071,9 @@ namespace {
4060
4071
CxxEscapability::Unknown) != CxxEscapability::NonEscapable;
4061
4072
};
4062
4073
4074
+ // FIXME: this uses '0' as the result index. That only works for
4075
+ // standalone functions with no parameters.
4076
+ // See markReturnsUnsafeNonescapable() for a general approach.
4063
4077
auto &ASTContext = result->getASTContext ();
4064
4078
SmallVector<LifetimeDependenceInfo, 1 > lifetimeDependencies;
4065
4079
LifetimeDependenceInfo immortalLifetime (nullptr , nullptr , 0 ,
0 commit comments