@@ -3053,11 +3053,16 @@ class LLVM_LIBRARY_VISIBILITY SILGenBorrowedBaseVisitor
30533053 SILGenLValue &SGL;
30543054 SILGenFunction &SGF;
30553055 AbstractionPattern Orig;
3056+ bool forGuaranteedReturn;
3057+ bool forGuaranteedAddressReturn;
30563058
3057- SILGenBorrowedBaseVisitor (SILGenLValue &SGL,
3058- SILGenFunction &SGF,
3059- AbstractionPattern Orig)
3060- : SGL(SGL), SGF(SGF), Orig(Orig) {}
3059+ SILGenBorrowedBaseVisitor (SILGenLValue &SGL, SILGenFunction &SGF,
3060+ AbstractionPattern Orig,
3061+ bool forGuaranteedReturn = false ,
3062+ bool forGuaranteedAddressReturn = false )
3063+ : SGL(SGL), SGF(SGF), Orig(Orig),
3064+ forGuaranteedReturn (forGuaranteedReturn),
3065+ forGuaranteedAddressReturn(forGuaranteedAddressReturn) {}
30613066
30623067 static bool isNonCopyableBaseBorrow (SILGenFunction &SGF, Expr *e) {
30633068 if (auto *m = dyn_cast<MemberRefExpr>(e)) {
@@ -3261,8 +3266,9 @@ LValue SILGenLValue::visitRec(Expr *e, SGFAccessKind accessKind,
32613266 // apply the lvalue within a formal access to the original value instead of
32623267 // an actual loaded copy.
32633268 if (SILGenBorrowedBaseVisitor::isNonCopyableBaseBorrow (SGF, e) ||
3264- options.NeedsBorrow ) {
3265- SILGenBorrowedBaseVisitor visitor (*this , SGF, orig);
3269+ options.ForGuaranteedReturn ) {
3270+ SILGenBorrowedBaseVisitor visitor (*this , SGF, orig,
3271+ options.ForGuaranteedReturn );
32663272 auto accessKind = SGFAccessKind::BorrowedObjectRead;
32673273 assert (!e->getType ()->is <LValueType>()
32683274 && " maybe need SGFAccessKind::BorrowedAddressRead ?" );
0 commit comments