@@ -501,33 +501,26 @@ class UseAfterTransferDiagnosticInferrer {
501
501
: valueMap(valueMap) {}
502
502
void init (const Operand *op);
503
503
504
- void addApplyUse (UseDiagnosticInfo diagnosticInfo) {
504
+ void appendUseInfo (UseDiagnosticInfo diagnosticInfo) {
505
505
applyUses.emplace_back (diagnosticInfo);
506
506
}
507
507
508
508
ArrayRef<UseDiagnosticInfo> getApplyUses () const { return applyUses; }
509
509
510
510
private:
511
- // / Init for an apply that does not have an associated apply expr.
512
- // /
513
- // / This should only occur when writing SIL test cases today. In the future,
514
- // / we may represent all of the actor isolation information at the SIL level,
515
- // / but we are not there yet today.
516
- void initForApply (ApplyIsolationCrossing isolationCrossing);
517
511
bool initForIsolatedPartialApply (Operand *op, AbstractClosureExpr *ace);
518
512
519
513
void initForApply (const Operand *op, ApplyExpr *expr);
520
- void initForApply (SILLocation valueLoc, Identifier valueName,
521
- ApplyIsolationCrossing isolationCrossing);
522
514
void initForAutoclosure (const Operand *op, AutoClosureExpr *expr);
523
515
524
516
void initForAssignmentToTransferringParameter (const Operand *op) {
525
- addApplyUse (UseDiagnosticInfo::forTypedAssignmentIntoTransferringParameter (
526
- baseLoc, op->get ()->getType ().getASTType ()));
517
+ appendUseInfo (
518
+ UseDiagnosticInfo::forTypedAssignmentIntoTransferringParameter (
519
+ baseLoc, op->get ()->getType ().getASTType ()));
527
520
}
528
521
529
522
void initForUseOfStronglyTransferredValue (const Operand *op) {
530
- addApplyUse (UseDiagnosticInfo::forTypedUseOfStronglyTransferredValue (
523
+ appendUseInfo (UseDiagnosticInfo::forTypedUseOfStronglyTransferredValue (
531
524
baseLoc, op->get ()->getType ().getASTType ()));
532
525
}
533
526
@@ -565,7 +558,7 @@ bool UseAfterTransferDiagnosticInferrer::initForIsolatedPartialApply(
565
558
unsigned opIndex = ApplySite (op->getUser ()).getAppliedArgIndex (*op);
566
559
for (auto &p : foundCapturedIsolationCrossing) {
567
560
if (std::get<1 >(p) == opIndex) {
568
- addApplyUse (UseDiagnosticInfo::forTypedIsolationCrossingDueToCapture (
561
+ appendUseInfo (UseDiagnosticInfo::forTypedIsolationCrossingDueToCapture (
569
562
RegularLocation (std::get<0 >(p).getLoc ()), baseInferredType,
570
563
std::get<2 >(p)));
571
564
return true ;
@@ -575,19 +568,6 @@ bool UseAfterTransferDiagnosticInferrer::initForIsolatedPartialApply(
575
568
return false ;
576
569
}
577
570
578
- void UseAfterTransferDiagnosticInferrer::initForApply (
579
- ApplyIsolationCrossing isolationCrossing) {
580
- addApplyUse (UseDiagnosticInfo::forTypedIsolationCrossing (
581
- baseLoc, baseInferredType, isolationCrossing));
582
- }
583
-
584
- void UseAfterTransferDiagnosticInferrer::initForApply (
585
- SILLocation valueLoc, Identifier valueName,
586
- ApplyIsolationCrossing isolationCrossing) {
587
- addApplyUse (UseDiagnosticInfo::forNamedIsolationCrossing (
588
- baseLoc, valueLoc, valueName, isolationCrossing));
589
- }
590
-
591
571
void UseAfterTransferDiagnosticInferrer::initForApply (const Operand *op,
592
572
ApplyExpr *sourceApply) {
593
573
auto isolationCrossing = sourceApply->getIsolationCrossing ().value ();
@@ -617,7 +597,7 @@ void UseAfterTransferDiagnosticInferrer::initForApply(const Operand *op,
617
597
618
598
auto inferredArgType =
619
599
foundExpr ? foundExpr->findOriginalType () : baseInferredType;
620
- addApplyUse (UseDiagnosticInfo::forTypedIsolationCrossing (
600
+ appendUseInfo (UseDiagnosticInfo::forTypedIsolationCrossing (
621
601
baseLoc, inferredArgType, isolationCrossing));
622
602
}
623
603
@@ -663,7 +643,7 @@ struct UseAfterTransferDiagnosticInferrer::Walker : ASTWalker {
663
643
if (!visitedCallExprDeclRefExprs.count (declRef)) {
664
644
if (declRef->getDecl () == targetDecl) {
665
645
visitedCallExprDeclRefExprs.insert (declRef);
666
- foundTypeInfo.addApplyUse (
646
+ foundTypeInfo.appendUseInfo (
667
647
UseDiagnosticInfo::forTypeIsolationCrossingWithUnknownIsolation (
668
648
foundTypeInfo.baseLoc , declRef->findOriginalType ()));
669
649
return Action::Continue (expr);
@@ -681,7 +661,7 @@ struct UseAfterTransferDiagnosticInferrer::Walker : ASTWalker {
681
661
if (declRef->getDecl () == targetDecl) {
682
662
// Found our target!
683
663
visitedCallExprDeclRefExprs.insert (declRef);
684
- foundTypeInfo.addApplyUse (
664
+ foundTypeInfo.appendUseInfo (
685
665
UseDiagnosticInfo::forTypedIsolationCrossing (
686
666
foundTypeInfo.baseLoc , declRef->findOriginalType (),
687
667
*isolationCrossing));
@@ -752,14 +732,14 @@ void UseAfterTransferDiagnosticInferrer::init(const Operand *op) {
752
732
if (auto rootValue =
753
733
inferrer.inferByWalkingUsesToDefsReturningRoot (op->get ())) {
754
734
if (auto *svi = dyn_cast<SingleValueInstruction>(rootValue)) {
755
- return addApplyUse (UseDiagnosticInfo::forNamedIsolationCrossing (
735
+ return appendUseInfo (UseDiagnosticInfo::forNamedIsolationCrossing (
756
736
baseLoc, svi->getLoc (),
757
737
astContext.getIdentifier (inferrer.getName ()),
758
738
*sourceApply->getIsolationCrossing ()));
759
739
}
760
740
761
741
if (auto *fArg = dyn_cast<SILFunctionArgument>(rootValue)) {
762
- return addApplyUse (UseDiagnosticInfo::forNamedIsolationCrossing (
742
+ return appendUseInfo (UseDiagnosticInfo::forNamedIsolationCrossing (
763
743
baseLoc, RegularLocation (fArg ->getDecl ()->getLoc ()),
764
744
astContext.getIdentifier (inferrer.getName ()),
765
745
*sourceApply->getIsolationCrossing ()));
@@ -772,7 +752,8 @@ void UseAfterTransferDiagnosticInferrer::init(const Operand *op) {
772
752
773
753
if (auto fas = FullApplySite::isa (nonConstOp->getUser ())) {
774
754
if (auto isolationCrossing = fas.getIsolationCrossing ()) {
775
- return initForApply (*isolationCrossing);
755
+ return appendUseInfo (UseDiagnosticInfo::forTypedIsolationCrossing (
756
+ baseLoc, baseInferredType, *isolationCrossing));
776
757
}
777
758
}
778
759
0 commit comments