@@ -476,16 +476,23 @@ struct MoveOnlyChecker {
476
476
MoveOnlyChecker (SILFunction *fn, DeadEndBlocks *deBlocks)
477
477
: fn(fn), copyOfBorrowedProjectionChecker(deBlocks) {}
478
478
479
+ // / Search through the current function for candidate mark_must_check
480
+ // / [noimplicitcopy]. If we find one that does not fit a pattern that we
481
+ // / understand, emit an error diagnostic telling the programmer that the move
482
+ // / checker did not know how to recognize this code pattern.
483
+ // /
484
+ // / \returns true if we deleted a mark_must_check inst that we didn't
485
+ // / recognize after emitting the diagnostic.
486
+ bool searchForCandidateMarkMustChecks ();
487
+
479
488
bool check (NonLocalAccessBlockAnalysis *accessBlockAnalysis,
480
489
DominanceInfo *domTree);
481
490
};
482
491
483
492
} // namespace
484
493
485
- bool MoveOnlyChecker::check (NonLocalAccessBlockAnalysis *accessBlockAnalysis,
486
- DominanceInfo *domTree) {
494
+ bool MoveOnlyChecker::searchForCandidateMarkMustChecks () {
487
495
bool changed = false ;
488
-
489
496
for (auto &block : *fn) {
490
497
for (auto ii = block.begin (), ie = block.end (); ii != ie;) {
491
498
auto *mmci = dyn_cast<MarkMustCheckInst>(&*ii);
@@ -530,6 +537,24 @@ bool MoveOnlyChecker::check(NonLocalAccessBlockAnalysis *accessBlockAnalysis,
530
537
changed = true ;
531
538
}
532
539
}
540
+ return changed;
541
+ }
542
+
543
+ bool MoveOnlyChecker::check (NonLocalAccessBlockAnalysis *accessBlockAnalysis,
544
+ DominanceInfo *domTree) {
545
+ bool changed = false ;
546
+
547
+ // First search for candidates to process and emit diagnostics on any
548
+ // mark_must_check [noimplicitcopy] we didn't recognize.
549
+ changed |= searchForCandidateMarkMustChecks ();
550
+
551
+ // If we didn't find any introducers to check, just return changed.
552
+ //
553
+ // NOTE: changed /can/ be true here if we had any mark_must_check
554
+ // [noimplicitcopy] that we didn't understand and emitting a diagnostic upon
555
+ // and then deleting.
556
+ if (moveIntroducersToProcess.empty ())
557
+ return changed;
533
558
534
559
auto callbacks =
535
560
InstModCallbacks ().onDelete ([&](SILInstruction *instToDelete) {
0 commit comments