@@ -2036,9 +2036,20 @@ namespace {
20362036 }
20372037
20382038 void markReturnsUnsafeNonescapable (AbstractFunctionDecl *fd) {
2039- fd->getAttrs ().add (new (Impl.SwiftContext )
2040- UnsafeNonEscapableResultAttr (/* Implicit=*/ true ));
20412039 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 ;
20422053 }
20432054
20442055 Decl *VisitRecordDecl (const clang::RecordDecl *decl) {
@@ -4060,6 +4071,9 @@ namespace {
40604071 CxxEscapability::Unknown) != CxxEscapability::NonEscapable;
40614072 };
40624073
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.
40634077 auto &ASTContext = result->getASTContext ();
40644078 SmallVector<LifetimeDependenceInfo, 1 > lifetimeDependencies;
40654079 LifetimeDependenceInfo immortalLifetime (nullptr , nullptr , 0 ,
0 commit comments