Skip to content

Commit b7abd8f

Browse files
committed
---
yaml --- r: 345526 b: refs/heads/master c: 99ea448 h: refs/heads/master
1 parent e737c0a commit b7abd8f

File tree

3 files changed

+17
-10
lines changed

3 files changed

+17
-10
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
refs/heads/master: 876d1ef645118ee365f3010f19eb71e3503c0b31
2+
refs/heads/master: 99ea4485c711b529a4719ec32335f51ee81af018
33
refs/heads/master-next: 203b3026584ecad859eb328b2e12490099409cd5
44
refs/tags/osx-passed: b6b74147ef8a386f532cf9357a1bde006e552c54
55
refs/tags/swift-2.2-SNAPSHOT-2015-12-01-a: 6bb18e013c2284f2b45f5f84f2df2887dc0f7dea

trunk/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.

trunk/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)