@@ -149,17 +149,16 @@ static std::optional<SILDeclRef> getDeclRefForCallee(SILInstruction *inst) {
149
149
}
150
150
}
151
151
152
- static std::optional<std::pair<DescriptiveDeclKind, DeclName>>
153
- getSendingApplyCalleeInfo (SILInstruction *inst) {
152
+ static std::optional<ValueDecl *> getSendingApplyCallee (SILInstruction *inst) {
154
153
auto declRef = getDeclRefForCallee (inst);
155
154
if (!declRef)
156
155
return {};
157
156
158
157
auto *decl = declRef->getDecl ();
159
- if (!decl || !decl-> hasName () )
158
+ if (!decl)
160
159
return {};
161
160
162
- return {{ decl-> getDescriptiveKind (), decl-> getName ()}} ;
161
+ return decl;
163
162
}
164
163
165
164
static Expr *inferArgumentExprFromApplyExpr (ApplyExpr *sourceApply,
@@ -672,10 +671,9 @@ class UseAfterSendDiagnosticEmitter {
672
671
getFunction ());
673
672
}
674
673
675
- // / If we can find a callee decl name, return that. None otherwise.
676
- std::optional<std::pair<DescriptiveDeclKind, DeclName>>
677
- getSendingCalleeInfo () const {
678
- return getSendingApplyCalleeInfo (sendingOp->getUser ());
674
+ // / Attempts to retrieve and return the callee declaration.
675
+ std::optional<const ValueDecl *> getSendingCallee () const {
676
+ return getSendingApplyCallee (sendingOp->getUser ());
679
677
}
680
678
681
679
void
@@ -697,12 +695,11 @@ class UseAfterSendDiagnosticEmitter {
697
695
}
698
696
}
699
697
700
- if (auto calleeInfo = getSendingCalleeInfo ()) {
698
+ if (auto callee = getSendingCallee ()) {
701
699
diagnoseNote (
702
700
loc, diag::regionbasedisolation_named_info_send_yields_race_callee,
703
701
name, descriptiveKindStr, isolationCrossing.getCalleeIsolation (),
704
- calleeInfo->first , calleeInfo->second ,
705
- isolationCrossing.getCallerIsolation ());
702
+ callee.value (), isolationCrossing.getCallerIsolation ());
706
703
} else {
707
704
diagnoseNote (loc, diag::regionbasedisolation_named_info_send_yields_race,
708
705
name, descriptiveKindStr,
@@ -716,8 +713,7 @@ class UseAfterSendDiagnosticEmitter {
716
713
emitNamedIsolationCrossingError (SILLocation loc, Identifier name,
717
714
SILIsolationInfo namedValuesIsolationInfo,
718
715
ApplyIsolationCrossing isolationCrossing,
719
- DeclName calleeDeclName,
720
- DescriptiveDeclKind calleeDeclKind) {
716
+ const ValueDecl *callee) {
721
717
// Emit the short error.
722
718
diagnoseError (loc, diag::regionbasedisolation_named_send_yields_race, name)
723
719
.highlight (loc.getSourceRange ())
@@ -736,7 +732,7 @@ class UseAfterSendDiagnosticEmitter {
736
732
diagnoseNote (
737
733
loc, diag::regionbasedisolation_named_info_send_yields_race_callee,
738
734
name, descriptiveKindStr, isolationCrossing.getCalleeIsolation (),
739
- calleeDeclKind, calleeDeclName , isolationCrossing.getCallerIsolation ());
735
+ callee , isolationCrossing.getCallerIsolation ());
740
736
emitRequireInstDiagnostics ();
741
737
}
742
738
@@ -759,11 +755,10 @@ class UseAfterSendDiagnosticEmitter {
759
755
.highlight (loc.getSourceRange ())
760
756
.limitBehaviorIf (getBehaviorLimit ());
761
757
762
- if (auto calleeInfo = getSendingCalleeInfo ()) {
758
+ if (auto callee = getSendingCallee ()) {
763
759
diagnoseNote (loc, diag::regionbasedisolation_type_use_after_send_callee,
764
760
inferredType, isolationCrossing.getCalleeIsolation (),
765
- calleeInfo->first , calleeInfo->second ,
766
- isolationCrossing.getCallerIsolation ());
761
+ callee.value (), isolationCrossing.getCallerIsolation ());
767
762
} else {
768
763
diagnoseNote (loc, diag::regionbasedisolation_type_use_after_send,
769
764
inferredType, isolationCrossing.getCalleeIsolation (),
@@ -793,10 +788,10 @@ class UseAfterSendDiagnosticEmitter {
793
788
inferredType)
794
789
.highlight (loc.getSourceRange ())
795
790
.limitBehaviorIf (getBehaviorLimit ());
796
- if (auto calleeInfo = getSendingCalleeInfo ()) {
791
+ if (auto callee = getSendingCallee ()) {
797
792
diagnoseNote (loc,
798
793
diag::regionbasedisolation_typed_use_after_sending_callee,
799
- inferredType, calleeInfo-> first , calleeInfo-> second );
794
+ inferredType, callee. value () );
800
795
} else {
801
796
diagnoseNote (loc, diag::regionbasedisolation_typed_use_after_sending,
802
797
inferredType);
@@ -1106,8 +1101,7 @@ struct UseAfterSendDiagnosticInferrer::AutoClosureWalker : ASTWalker {
1106
1101
if (valueDecl->hasName ()) {
1107
1102
foundTypeInfo.diagnosticEmitter .emitNamedIsolationCrossingError (
1108
1103
foundTypeInfo.baseLoc , targetDecl->getBaseIdentifier (),
1109
- targetDeclIsolationInfo, *isolationCrossing,
1110
- valueDecl->getName (), valueDecl->getDescriptiveKind ());
1104
+ targetDeclIsolationInfo, *isolationCrossing, valueDecl);
1111
1105
continue ;
1112
1106
}
1113
1107
@@ -1341,10 +1335,9 @@ class SendNeverSentDiagnosticEmitter {
1341
1335
getOperand ()->getFunction ());
1342
1336
}
1343
1337
1344
- // / If we can find a callee decl name, return that. None otherwise.
1345
- std::optional<std::pair<DescriptiveDeclKind, DeclName>>
1346
- getSendingCalleeInfo () const {
1347
- return getSendingApplyCalleeInfo (sendingOperand->getUser ());
1338
+ // / Attempts to retrieve and return the callee declaration.
1339
+ std::optional<const ValueDecl *> getSendingCallee () const {
1340
+ return getSendingApplyCallee (sendingOperand->getUser ());
1348
1341
}
1349
1342
1350
1343
SILLocation getLoc () const { return sendingOperand->getUser ()->getLoc (); }
@@ -1384,12 +1377,12 @@ class SendNeverSentDiagnosticEmitter {
1384
1377
getIsolationRegionInfo ().printForDiagnostics (os);
1385
1378
}
1386
1379
1387
- if (auto calleeInfo = getSendingCalleeInfo ()) {
1380
+ if (auto callee = getSendingCallee ()) {
1388
1381
diagnoseNote (
1389
1382
loc,
1390
1383
diag::regionbasedisolation_typed_sendneversendable_via_arg_callee,
1391
1384
descriptiveKindStr, inferredType, crossing.getCalleeIsolation (),
1392
- calleeInfo-> first , calleeInfo-> second );
1385
+ callee. value () );
1393
1386
} else {
1394
1387
diagnoseNote (
1395
1388
loc, diag::regionbasedisolation_typed_sendneversendable_via_arg,
@@ -1428,11 +1421,10 @@ class SendNeverSentDiagnosticEmitter {
1428
1421
getIsolationRegionInfo ().printForDiagnostics (os);
1429
1422
}
1430
1423
1431
- if (auto calleeInfo = getSendingCalleeInfo ()) {
1424
+ if (auto callee = getSendingCallee ()) {
1432
1425
diagnoseNote (
1433
1426
loc, diag::regionbasedisolation_typed_tns_passed_to_sending_callee,
1434
- descriptiveKindStr, inferredType, calleeInfo->first ,
1435
- calleeInfo->second );
1427
+ descriptiveKindStr, inferredType, callee.value ());
1436
1428
} else {
1437
1429
diagnoseNote (loc, diag::regionbasedisolation_typed_tns_passed_to_sending,
1438
1430
descriptiveKindStr, inferredType);
@@ -1494,8 +1486,7 @@ class SendNeverSentDiagnosticEmitter {
1494
1486
fArg ->getType ().is <SILBoxType>()) {
1495
1487
auto diag = diag::
1496
1488
regionbasedisolation_typed_tns_passed_to_sending_closure_helper_have_boxed_value_task_isolated;
1497
- diagnoseNote (actualUse, diag, fArg ->getDecl ()->getName (),
1498
- fArg ->getDecl ()->getDescriptiveKind ());
1489
+ diagnoseNote (actualUse, diag, fArg ->getDecl ());
1499
1490
return ;
1500
1491
}
1501
1492
@@ -1632,12 +1623,12 @@ class SendNeverSentDiagnosticEmitter {
1632
1623
descriptiveKindStrWithSpace.push_back (' ' );
1633
1624
}
1634
1625
}
1635
- if (auto calleeInfo = getSendingCalleeInfo ()) {
1626
+ if (auto callee = getSendingCallee ()) {
1636
1627
diagnoseNote (loc,
1637
1628
diag::regionbasedisolation_named_send_never_sendable_callee,
1638
1629
name, descriptiveKindStrWithSpace,
1639
- isolationCrossing.getCalleeIsolation (), calleeInfo-> first ,
1640
- calleeInfo-> second , descriptiveKindStr);
1630
+ isolationCrossing.getCalleeIsolation (), callee. value () ,
1631
+ descriptiveKindStr);
1641
1632
} else {
1642
1633
diagnoseNote (loc, diag::regionbasedisolation_named_send_never_sendable,
1643
1634
name, descriptiveKindStrWithSpace,
0 commit comments