Skip to content

Commit e98f352

Browse files
committed
[NFC] Rename LVOptions::withBorrow -> LVOptions::forGuaranteedReturn
Also add forGuaranteedAddressReturn
1 parent e421305 commit e98f352

File tree

3 files changed

+23
-10
lines changed

3 files changed

+23
-10
lines changed

lib/SILGen/SILGenFunction.h

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,8 @@ class ExecutorBreadcrumb;
5858
struct LValueOptions {
5959
bool IsNonAccessing = false;
6060
bool TryAddressable = false;
61-
bool NeedsBorrow = false;
61+
bool ForGuaranteedReturn = false;
62+
bool ForGuaranteedAddressReturn = false;
6263

6364
/// Derive options for accessing the base of an l-value, given that
6465
/// applying the derived component might touch the memory.
@@ -83,9 +84,15 @@ struct LValueOptions {
8384
return copy;
8485
}
8586

86-
LValueOptions withBorrow(bool borrow) const {
87+
LValueOptions forGuaranteedReturn(bool value) const {
8788
auto copy = *this;
88-
copy.NeedsBorrow = borrow;
89+
copy.ForGuaranteedReturn = value;
90+
return copy;
91+
}
92+
93+
LValueOptions forGuaranteedAddressReturn(bool value) const {
94+
auto copy = *this;
95+
copy.ForGuaranteedAddressReturn = value;
8996
return copy;
9097
}
9198
};

lib/SILGen/SILGenLValue.cpp

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -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 ?");

lib/SILGen/SILGenStmt.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -772,7 +772,7 @@ void SILGenFunction::emitReturnExpr(SILLocation branchLoc,
772772
F.getConventions().hasGuaranteedResult()
773773
? SGFAccessKind::BorrowedObjectRead
774774
: SGFAccessKind::BorrowedAddressRead,
775-
options.withBorrow(true));
775+
options.forGuaranteedReturn(true));
776776
auto result =
777777
tryEmitProjectedLValue(ret, std::move(lvalue), TSanKind::None);
778778
if (!result) {

0 commit comments

Comments
 (0)