@@ -527,6 +527,20 @@ class PartitionAnalysis {
527
527
}
528
528
}
529
529
530
+ // track the AST exprs that have already had diagnostics emitted about
531
+ llvm::DenseSet<Expr *> emittedExprs;
532
+
533
+ // check if a diagnostic has already been emitted about expr, only
534
+ // returns true false for each expr
535
+ bool hasBeenEmitted (Expr *expr) {
536
+ if (auto castExpr = dyn_cast<ImplicitConversionExpr>(expr))
537
+ return hasBeenEmitted (castExpr->getSubExpr ());
538
+
539
+ if (emittedExprs.contains (expr)) return true ;
540
+ emittedExprs.insert (expr);
541
+ return false ;
542
+ }
543
+
530
544
// once the fixpoint has been solved for, run one more pass over each basic
531
545
// block, reporting any failures due to requiring consumed regions in the
532
546
// fixpoint state
@@ -538,9 +552,12 @@ class PartitionAnalysis {
538
552
SILInstruction *sourceInstr = partitionOp.getSourceInst ();
539
553
assert (sourceInstr && " PartitionOps used in PartitionAnalysis should "
540
554
" always have been generated with a sourceInst" );
555
+ Expr *expr = sourceInstr->getLoc ().getAsASTNode <Expr>();
556
+ assert (expr && " PartitionOp's source location should correspond to"
557
+ " an AST node" );
558
+ if (hasBeenEmitted (expr)) return ;
541
559
function->getASTContext ().Diags .diagnose (
542
- sourceInstr->getLoc ().getSourceLoc (),
543
- diag::send_non_sendable, consumedVal);
560
+ expr->getLoc (), diag::send_non_sendable, consumedVal);
544
561
});
545
562
}
546
563
}
0 commit comments