Skip to content

Commit 99ea448

Browse files
committed
Merge remote-tracking branch 'origin/master' into master-next
2 parents 876d1ef + 754c58d commit 99ea448

File tree

2 files changed

+16
-9
lines changed

2 files changed

+16
-9
lines changed

lib/SILGen/ArgumentSource.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -196,9 +196,7 @@ class ArgumentSource {
196196
return Storage.get<LValueStorage>(StoredKind).Loc;
197197
}
198198

199-
Expr *peekExpr() & {
200-
return Storage.get<Expr*>(StoredKind);
201-
}
199+
Expr *findStorageReferenceExprForBorrow() &&;
202200

203201
/// Given that this source is an expression, extract and clear
204202
/// that expression.

lib/SILGen/SILGenApply.cpp

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2459,6 +2459,20 @@ static Expr *findStorageReferenceExprForBorrow(Expr *e) {
24592459
return nullptr;
24602460
}
24612461

2462+
Expr *ArgumentSource::findStorageReferenceExprForBorrow() && {
2463+
if (!isExpr()) return nullptr;
2464+
2465+
auto argExpr = asKnownExpr();
2466+
auto lvExpr = ::findStorageReferenceExprForBorrow(argExpr);
2467+
2468+
// Claim the value of this argument if we found a storage reference.
2469+
if (lvExpr) {
2470+
(void) std::move(*this).asKnownExpr();
2471+
}
2472+
2473+
return lvExpr;
2474+
}
2475+
24622476
namespace {
24632477

24642478
/// A destination for an argument other than just "onto to the end
@@ -2894,14 +2908,9 @@ class ArgEmitter {
28942908
assert(paramsSlice.size() == 1);
28952909

28962910
// Try to find an expression we can emit as an l-value.
2897-
if (!arg.isExpr()) return false;
2898-
auto argExpr = arg.peekExpr();
2899-
auto lvExpr = findStorageReferenceExprForBorrow(argExpr);
2911+
auto lvExpr = std::move(arg).findStorageReferenceExprForBorrow();
29002912
if (!lvExpr) return false;
29012913

2902-
// Claim the argument.
2903-
(void) std::move(arg).asKnownExpr();
2904-
29052914
emitBorrowed(lvExpr, loweredSubstArgType, loweredSubstParamType,
29062915
origParamType, paramsSlice);
29072916
return true;

0 commit comments

Comments
 (0)