@@ -149,17 +149,16 @@ static std::optional<SILDeclRef> getDeclRefForCallee(SILInstruction *inst) {
149149 }
150150}
151151
152- static std::optional<std::pair<DescriptiveDeclKind, DeclName>>
153- getSendingApplyCalleeInfo (SILInstruction *inst) {
152+ static std::optional<ValueDecl *> getSendingApplyCallee (SILInstruction *inst) {
154153 auto declRef = getDeclRefForCallee (inst);
155154 if (!declRef)
156155 return {};
157156
158157 auto *decl = declRef->getDecl ();
159- if (!decl || !decl-> hasName () )
158+ if (!decl)
160159 return {};
161160
162- return {{ decl-> getDescriptiveKind (), decl-> getName ()}} ;
161+ return decl;
163162}
164163
165164static Expr *inferArgumentExprFromApplyExpr (ApplyExpr *sourceApply,
@@ -672,10 +671,9 @@ class UseAfterSendDiagnosticEmitter {
672671 getFunction ());
673672 }
674673
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 ());
679677 }
680678
681679 void
@@ -697,12 +695,11 @@ class UseAfterSendDiagnosticEmitter {
697695 }
698696 }
699697
700- if (auto calleeInfo = getSendingCalleeInfo ()) {
698+ if (auto callee = getSendingCallee ()) {
701699 diagnoseNote (
702700 loc, diag::regionbasedisolation_named_info_send_yields_race_callee,
703701 name, descriptiveKindStr, isolationCrossing.getCalleeIsolation (),
704- calleeInfo->first , calleeInfo->second ,
705- isolationCrossing.getCallerIsolation ());
702+ callee.value (), isolationCrossing.getCallerIsolation ());
706703 } else {
707704 diagnoseNote (loc, diag::regionbasedisolation_named_info_send_yields_race,
708705 name, descriptiveKindStr,
@@ -716,8 +713,7 @@ class UseAfterSendDiagnosticEmitter {
716713 emitNamedIsolationCrossingError (SILLocation loc, Identifier name,
717714 SILIsolationInfo namedValuesIsolationInfo,
718715 ApplyIsolationCrossing isolationCrossing,
719- DeclName calleeDeclName,
720- DescriptiveDeclKind calleeDeclKind) {
716+ const ValueDecl *callee) {
721717 // Emit the short error.
722718 diagnoseError (loc, diag::regionbasedisolation_named_send_yields_race, name)
723719 .highlight (loc.getSourceRange ())
@@ -736,7 +732,7 @@ class UseAfterSendDiagnosticEmitter {
736732 diagnoseNote (
737733 loc, diag::regionbasedisolation_named_info_send_yields_race_callee,
738734 name, descriptiveKindStr, isolationCrossing.getCalleeIsolation (),
739- calleeDeclKind, calleeDeclName , isolationCrossing.getCallerIsolation ());
735+ callee , isolationCrossing.getCallerIsolation ());
740736 emitRequireInstDiagnostics ();
741737 }
742738
@@ -759,11 +755,10 @@ class UseAfterSendDiagnosticEmitter {
759755 .highlight (loc.getSourceRange ())
760756 .limitBehaviorIf (getBehaviorLimit ());
761757
762- if (auto calleeInfo = getSendingCalleeInfo ()) {
758+ if (auto callee = getSendingCallee ()) {
763759 diagnoseNote (loc, diag::regionbasedisolation_type_use_after_send_callee,
764760 inferredType, isolationCrossing.getCalleeIsolation (),
765- calleeInfo->first , calleeInfo->second ,
766- isolationCrossing.getCallerIsolation ());
761+ callee.value (), isolationCrossing.getCallerIsolation ());
767762 } else {
768763 diagnoseNote (loc, diag::regionbasedisolation_type_use_after_send,
769764 inferredType, isolationCrossing.getCalleeIsolation (),
@@ -793,10 +788,10 @@ class UseAfterSendDiagnosticEmitter {
793788 inferredType)
794789 .highlight (loc.getSourceRange ())
795790 .limitBehaviorIf (getBehaviorLimit ());
796- if (auto calleeInfo = getSendingCalleeInfo ()) {
791+ if (auto callee = getSendingCallee ()) {
797792 diagnoseNote (loc,
798793 diag::regionbasedisolation_typed_use_after_sending_callee,
799- inferredType, calleeInfo-> first , calleeInfo-> second );
794+ inferredType, callee. value () );
800795 } else {
801796 diagnoseNote (loc, diag::regionbasedisolation_typed_use_after_sending,
802797 inferredType);
@@ -1106,8 +1101,7 @@ struct UseAfterSendDiagnosticInferrer::AutoClosureWalker : ASTWalker {
11061101 if (valueDecl->hasName ()) {
11071102 foundTypeInfo.diagnosticEmitter .emitNamedIsolationCrossingError (
11081103 foundTypeInfo.baseLoc , targetDecl->getBaseIdentifier (),
1109- targetDeclIsolationInfo, *isolationCrossing,
1110- valueDecl->getName (), valueDecl->getDescriptiveKind ());
1104+ targetDeclIsolationInfo, *isolationCrossing, valueDecl);
11111105 continue ;
11121106 }
11131107
@@ -1322,10 +1316,9 @@ class SendNeverSentDiagnosticEmitter {
13221316 getOperand ()->getFunction ());
13231317 }
13241318
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 ());
13291322 }
13301323
13311324 SILLocation getLoc () const { return sendingOperand->getUser ()->getLoc (); }
@@ -1365,12 +1358,12 @@ class SendNeverSentDiagnosticEmitter {
13651358 getIsolationRegionInfo ().printForDiagnostics (os);
13661359 }
13671360
1368- if (auto calleeInfo = getSendingCalleeInfo ()) {
1361+ if (auto callee = getSendingCallee ()) {
13691362 diagnoseNote (
13701363 loc,
13711364 diag::regionbasedisolation_typed_sendneversendable_via_arg_callee,
13721365 descriptiveKindStr, inferredType, crossing.getCalleeIsolation (),
1373- calleeInfo-> first , calleeInfo-> second );
1366+ callee. value () );
13741367 } else {
13751368 diagnoseNote (
13761369 loc, diag::regionbasedisolation_typed_sendneversendable_via_arg,
@@ -1409,11 +1402,10 @@ class SendNeverSentDiagnosticEmitter {
14091402 getIsolationRegionInfo ().printForDiagnostics (os);
14101403 }
14111404
1412- if (auto calleeInfo = getSendingCalleeInfo ()) {
1405+ if (auto callee = getSendingCallee ()) {
14131406 diagnoseNote (
14141407 loc, diag::regionbasedisolation_typed_tns_passed_to_sending_callee,
1415- descriptiveKindStr, inferredType, calleeInfo->first ,
1416- calleeInfo->second );
1408+ descriptiveKindStr, inferredType, callee.value ());
14171409 } else {
14181410 diagnoseNote (loc, diag::regionbasedisolation_typed_tns_passed_to_sending,
14191411 descriptiveKindStr, inferredType);
@@ -1475,8 +1467,7 @@ class SendNeverSentDiagnosticEmitter {
14751467 fArg ->getType ().is <SILBoxType>()) {
14761468 auto diag = diag::
14771469 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 ());
14801471 return ;
14811472 }
14821473
@@ -1614,12 +1605,12 @@ class SendNeverSentDiagnosticEmitter {
16141605 descriptiveKindStrWithSpace.push_back (' ' );
16151606 }
16161607 }
1617- if (auto calleeInfo = getSendingCalleeInfo ()) {
1608+ if (auto callee = getSendingCallee ()) {
16181609 diagnoseNote (loc,
16191610 diag::regionbasedisolation_named_send_never_sendable_callee,
16201611 name, descriptiveKindStrWithSpace,
1621- isolationCrossing.getCalleeIsolation (), calleeInfo-> first ,
1622- calleeInfo-> second , descriptiveKindStr);
1612+ isolationCrossing.getCalleeIsolation (), callee. value () ,
1613+ descriptiveKindStr);
16231614 } else {
16241615 diagnoseNote (loc, diag::regionbasedisolation_named_send_never_sendable,
16251616 name, descriptiveKindStrWithSpace,
0 commit comments