@@ -221,8 +221,12 @@ OwnershipLifetimeExtender::copyBorrowAndExtendForRAUW(SILValue newValue,
221
221
while (!frontier.empty ()) {
222
222
auto *insertPt = frontier.pop_back_val ();
223
223
SILBuilderWithScope frontierBuilder (insertPt);
224
- auto *ebi = frontierBuilder.createEndBorrow (insertPt->getLoc (), borrow);
225
- auto *dvi = frontierBuilder.createDestroyValue (insertPt->getLoc (), copy);
224
+ // Use an auto-generated location here, because insertPt may have an
225
+ // incompatible LocationKind
226
+ auto loc = RegularLocation::getAutoGeneratedLocation (
227
+ insertPt->getLoc ().getSourceLoc ());
228
+ auto *ebi = frontierBuilder.createEndBorrow (loc, borrow);
229
+ auto *dvi = frontierBuilder.createDestroyValue (loc, copy);
226
230
if (ctx.newInstNotify ) {
227
231
ctx.newInstNotify (ebi);
228
232
ctx.newInstNotify (dvi);
@@ -460,10 +464,13 @@ void OwnershipRAUWUtility::eliminateReborrowsOfRecursiveBorrows(
460
464
SILValue value = borrowingOperand->get ();
461
465
auto *bi = cast<BranchInst>(borrowingOperand->getUser ());
462
466
SILBuilderWithScope reborrowBuilder (bi);
463
- auto *innerCopy = reborrowBuilder.createCopyValue (bi->getLoc (), value);
464
- auto *innerBorrow =
465
- reborrowBuilder.createBeginBorrow (bi->getLoc (), innerCopy);
466
- auto *outerEndBorrow = reborrowBuilder.createEndBorrow (bi->getLoc (), value);
467
+ // Use an auto-generated location here, because the branch may have an
468
+ // incompatible LocationKind
469
+ auto loc =
470
+ RegularLocation::getAutoGeneratedLocation (bi->getLoc ().getSourceLoc ());
471
+ auto *innerCopy = reborrowBuilder.createCopyValue (loc, value);
472
+ auto *innerBorrow = reborrowBuilder.createBeginBorrow (loc, innerCopy);
473
+ auto *outerEndBorrow = reborrowBuilder.createEndBorrow (loc, value);
467
474
if (ctx.newInstNotify ) {
468
475
ctx.newInstNotify (innerCopy);
469
476
ctx.newInstNotify (innerBorrow);
@@ -526,12 +533,14 @@ void OwnershipRAUWUtility::rewriteReborrows(
526
533
for (auto reborrow : foundReborrows) {
527
534
auto *bi = cast<BranchInst>(reborrow.op ->getUser ());
528
535
SILBuilderWithScope reborrowBuilder (bi);
529
- auto *innerCopy =
530
- reborrowBuilder.createCopyValue (bi->getLoc (), newBorrowedValue);
531
- auto *innerBorrow =
532
- reborrowBuilder.createBeginBorrow (bi->getLoc (), innerCopy);
536
+ // Use an auto-generated location here, because the branch may have an
537
+ // incompatible LocationKind
538
+ auto loc =
539
+ RegularLocation::getAutoGeneratedLocation (bi->getLoc ().getSourceLoc ());
540
+ auto *innerCopy = reborrowBuilder.createCopyValue (loc, newBorrowedValue);
541
+ auto *innerBorrow = reborrowBuilder.createBeginBorrow (loc, innerCopy);
533
542
auto *outerEndBorrow =
534
- reborrowBuilder.createEndBorrow (bi-> getLoc () , reborrow.op ->get ());
543
+ reborrowBuilder.createEndBorrow (loc , reborrow.op ->get ());
535
544
if (ctx.newInstNotify ) {
536
545
ctx.newInstNotify (innerCopy);
537
546
ctx.newInstNotify (innerBorrow);
0 commit comments