@@ -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
@@ -1322,10 +1316,9 @@ class SendNeverSentDiagnosticEmitter {
1322
1316
getOperand ()->getFunction ());
1323
1317
}
1324
1318
1325
- // / If we can find a callee decl name, return that. None otherwise.
1326
- std::optional<std::pair<DescriptiveDeclKind, DeclName>>
1327
- getSendingCalleeInfo () const {
1328
- return getSendingApplyCalleeInfo (sendingOperand->getUser ());
1319
+ // / Attempts to retrieve and return the callee declaration.
1320
+ std::optional<const ValueDecl *> getSendingCallee () const {
1321
+ return getSendingApplyCallee (sendingOperand->getUser ());
1329
1322
}
1330
1323
1331
1324
SILLocation getLoc () const { return sendingOperand->getUser ()->getLoc (); }
@@ -1365,12 +1358,12 @@ class SendNeverSentDiagnosticEmitter {
1365
1358
getIsolationRegionInfo ().printForDiagnostics (os);
1366
1359
}
1367
1360
1368
- if (auto calleeInfo = getSendingCalleeInfo ()) {
1361
+ if (auto callee = getSendingCallee ()) {
1369
1362
diagnoseNote (
1370
1363
loc,
1371
1364
diag::regionbasedisolation_typed_sendneversendable_via_arg_callee,
1372
1365
descriptiveKindStr, inferredType, crossing.getCalleeIsolation (),
1373
- calleeInfo-> first , calleeInfo-> second );
1366
+ callee. value () );
1374
1367
} else {
1375
1368
diagnoseNote (
1376
1369
loc, diag::regionbasedisolation_typed_sendneversendable_via_arg,
@@ -1409,11 +1402,10 @@ class SendNeverSentDiagnosticEmitter {
1409
1402
getIsolationRegionInfo ().printForDiagnostics (os);
1410
1403
}
1411
1404
1412
- if (auto calleeInfo = getSendingCalleeInfo ()) {
1405
+ if (auto callee = getSendingCallee ()) {
1413
1406
diagnoseNote (
1414
1407
loc, diag::regionbasedisolation_typed_tns_passed_to_sending_callee,
1415
- descriptiveKindStr, inferredType, calleeInfo->first ,
1416
- calleeInfo->second );
1408
+ descriptiveKindStr, inferredType, callee.value ());
1417
1409
} else {
1418
1410
diagnoseNote (loc, diag::regionbasedisolation_typed_tns_passed_to_sending,
1419
1411
descriptiveKindStr, inferredType);
@@ -1475,8 +1467,7 @@ class SendNeverSentDiagnosticEmitter {
1475
1467
fArg ->getType ().is <SILBoxType>()) {
1476
1468
auto diag = diag::
1477
1469
regionbasedisolation_typed_tns_passed_to_sending_closure_helper_have_boxed_value_task_isolated;
1478
- diagnoseNote (actualUse, diag, fArg ->getDecl ()->getName (),
1479
- fArg ->getDecl ()->getDescriptiveKind ());
1470
+ diagnoseNote (actualUse, diag, fArg ->getDecl ());
1480
1471
return ;
1481
1472
}
1482
1473
@@ -1614,12 +1605,12 @@ class SendNeverSentDiagnosticEmitter {
1614
1605
descriptiveKindStrWithSpace.push_back (' ' );
1615
1606
}
1616
1607
}
1617
- if (auto calleeInfo = getSendingCalleeInfo ()) {
1608
+ if (auto callee = getSendingCallee ()) {
1618
1609
diagnoseNote (loc,
1619
1610
diag::regionbasedisolation_named_send_never_sendable_callee,
1620
1611
name, descriptiveKindStrWithSpace,
1621
- isolationCrossing.getCalleeIsolation (), calleeInfo-> first ,
1622
- calleeInfo-> second , descriptiveKindStr);
1612
+ isolationCrossing.getCalleeIsolation (), callee. value () ,
1613
+ descriptiveKindStr);
1623
1614
} else {
1624
1615
diagnoseNote (loc, diag::regionbasedisolation_named_send_never_sendable,
1625
1616
name, descriptiveKindStrWithSpace,
0 commit comments