@@ -566,9 +566,9 @@ class LocalVariableInitialization : public SingleBufferInitialization {
566566 //
567567 // Only add a lexical lifetime to the box if the the variable it stores
568568 // requires one.
569- if (lifetime. isLexical ()) {
570- Box = SGF. B . createBeginBorrow ( decl, Box, /* isLexical=*/ true );
571- }
569+ Box = SGF. B . createBeginBorrow (
570+ decl, Box, /* isLexical=*/ lifetime. isLexical (),
571+ /* hasPointerEscape= */ false , /* fromVarDecl= */ true );
572572 }
573573
574574 Addr = SGF.B .createProjectBox (decl, Box, 0 );
@@ -835,16 +835,17 @@ class LetValueInitialization : public Initialization {
835835 // Otherwise, if we do not have a no implicit copy variable, just follow
836836 // the "normal path": perform a lexical borrow if the lifetime is lexical.
837837 if (!vd->isNoImplicitCopy ()) {
838- if ( SGF.F . getLifetime (vd, value-> getType ()). isLexical ())
839- return SGF. B . createBeginBorrow ( PrologueLoc, value, /* isLexical */ true );
840- else
841- return value ;
838+ return SGF.B . createBeginBorrow (
839+ PrologueLoc, value,
840+ /* isLexical= */ SGF. F . getLifetime (vd, value-> getType ()). isLexical (),
841+ /* hasPointerEscape= */ false , /* fromVarDecl= */ true ) ;
842842 }
843843
844844 // If we have a no implicit copy lexical, emit the instruction stream so
845845 // that the move checker knows to check this variable.
846- value = SGF.B .createBeginBorrow (PrologueLoc, value,
847- /* isLexical*/ true );
846+ value = SGF.B .createBeginBorrow (
847+ PrologueLoc, value,
848+ /* isLexical*/ true , /* hasPointerEscape=*/ false , /* fromVarDecl=*/ true );
848849 value = SGF.B .createCopyValue (PrologueLoc, value);
849850 value = SGF.B .createOwnedCopyableToMoveOnlyWrapperValue (PrologueLoc, value);
850851 return SGF.B .createMarkUnresolvedNonCopyableValueInst (
@@ -2166,11 +2167,6 @@ void SILGenFunction::destroyLocalVariable(SILLocation silLoc, VarDecl *vd) {
21662167 return ;
21672168 }
21682169
2169- if (!F.getLifetime (vd, Val->getType ()).isLexical ()) {
2170- B.emitDestroyValueOperation (silLoc, Val);
2171- return ;
2172- }
2173-
21742170 // This handles any case where we copy + begin_borrow or copyable_to_moveonly
21752171 // + begin_borrow. In either case we just need to end the lifetime of the
21762172 // begin_borrow's operand.
0 commit comments