Skip to content

Commit 4ac5bd4

Browse files
committed
---
yaml --- r: 348579 b: refs/heads/master c: cf8e534 h: refs/heads/master i: 348577: 753b667 348575: cee0d57
1 parent 1312a05 commit 4ac5bd4

File tree

4 files changed

+18
-7
lines changed

4 files changed

+18
-7
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: 28d1852c3e1f25b3b2d8f9eafb97f36f05d580e7
2+
refs/heads/master: cf8e5349f62cbccd1c86c3dc6add261bbc899327
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/include/swift/SIL/OwnershipUtils.h

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,18 @@ class LinearLifetimeChecker {
170170
ArrayRef<BranchPropagatedUser> nonConsumingUses,
171171
ownership::ErrorBehaviorKind errorBehavior,
172172
SmallVectorImpl<SILBasicBlock *> *leakingBlocks = nullptr);
173+
174+
/// Returns true that \p value forms a linear lifetime with consuming uses \p
175+
/// consumingUses, non consuming uses \p nonConsumingUses. Returns false
176+
/// otherwise.
177+
bool validateLifetime(SILValue value,
178+
ArrayRef<BranchPropagatedUser> consumingUses,
179+
ArrayRef<BranchPropagatedUser> nonConsumingUses) {
180+
return !checkValue(value, consumingUses, nonConsumingUses,
181+
ownership::ErrorBehaviorKind::ReturnFalse,
182+
nullptr /*leakingBlocks*/)
183+
.getFoundError();
184+
}
173185
};
174186

175187
/// Returns true if v is an address or trivial.

trunk/lib/SIL/OwnershipUtils.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,5 @@ bool BorrowScopeIntroducingValue::areInstructionsWithinScope(
207207
[&scratchSpace](SILInstruction *i) { scratchSpace.emplace_back(i); });
208208

209209
LinearLifetimeChecker checker(visitedBlocks, deadEndBlocks);
210-
auto result = checker.checkValue(value, scratchSpace, instructions,
211-
ownership::ErrorBehaviorKind::ReturnFalse);
212-
return !result.getFoundError();
210+
return checker.validateLifetime(value, scratchSpace, instructions);
213211
}

trunk/lib/SILOptimizer/Mandatory/SemanticARCOpts.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -673,9 +673,10 @@ class StorageGuaranteesLoadVisitor
673673
SmallPtrSet<SILBasicBlock *, 4> visitedBlocks;
674674

675675
LinearLifetimeChecker checker(visitedBlocks, ARCOpt.getDeadEndBlocks());
676-
auto result = checker.checkValue(baseObject, baseEndBorrows, valueDestroys,
677-
ownership::ErrorBehaviorKind::ReturnFalse);
678-
return answer(result.getFoundError());
676+
// Returns true on success. So we invert.
677+
bool foundError =
678+
!checker.validateLifetime(baseObject, baseEndBorrows, valueDestroys);
679+
return answer(foundError);
679680
}
680681

681682
// TODO: Handle other access kinds?

0 commit comments

Comments
 (0)