Skip to content

Commit c2dfc2f

Browse files
committed
[NFC] Comment on the use of unchecked_ownership
1 parent 59a040f commit c2dfc2f

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

lib/SILGen/SILGenApply.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5482,6 +5482,9 @@ ManagedValue SILGenFunction::applyBorrowMutateAccessor(
54825482
if (fn.getFunction()->getConventions().hasGuaranteedResult()) {
54835483
auto selfArg = args.back().getValue();
54845484
if (isa<LoadBorrowInst>(selfArg)) {
5485+
// unchecked_ownership is used to silence the ownership verifier for
5486+
// returning a value produced within a load_borrow scope. SILGenCleanup
5487+
// eliminates it and introduces return_borrow appropriately.
54855488
rawResult = B.createUncheckedOwnership(loc, rawResult);
54865489
}
54875490
}

lib/SILGen/SILGenStmt.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -720,6 +720,9 @@ bool SILGenFunction::emitBorrowOrMutateAccessorResult(
720720
assert(F.getConventions().hasGuaranteedResult());
721721
auto regularLoc = RegularLocation::getAutoGeneratedLocation();
722722
auto load = B.createLoadBorrow(regularLoc, guaranteedAddress).getValue();
723+
// unchecked_ownership is used to silence the ownership verifier for
724+
// returning a value produced within a load_borrow scope. SILGenCleanup
725+
// eliminates it and introduces return_borrow appropriately.
723726
return B.createUncheckedOwnership(regularLoc, load);
724727
};
725728

0 commit comments

Comments
 (0)