@@ -56,40 +56,78 @@ using Region = PartitionPrimitives::Region;
56
56
// ===----------------------------------------------------------------------===//
57
57
58
58
template <typename ... T, typename ... U>
59
- static InFlightDiagnostic diagnose (ASTContext &context, SourceLoc loc,
60
- Diag<T...> diag, U &&...args) {
59
+ static InFlightDiagnostic diagnoseError (ASTContext &context, SourceLoc loc,
60
+ Diag<T...> diag, U &&...args) {
61
+ return std::move (context.Diags .diagnose (loc, diag, std::forward<U>(args)...)
62
+ .warnUntilSwiftVersion (6 ));
63
+ }
64
+
65
+ template <typename ... T, typename ... U>
66
+ static InFlightDiagnostic diagnoseError (ASTContext &context, SILLocation loc,
67
+ Diag<T...> diag, U &&...args) {
68
+ return ::diagnoseError (context, loc.getSourceLoc (), diag,
69
+ std::forward<U>(args)...);
70
+ }
71
+
72
+ template <typename ... T, typename ... U>
73
+ static InFlightDiagnostic diagnoseError (const PartitionOp &op, Diag<T...> diag,
74
+ U &&...args) {
75
+ return ::diagnoseError (op.getSourceInst ()->getFunction ()->getASTContext (),
76
+ op.getSourceLoc ().getSourceLoc (), diag,
77
+ std::forward<U>(args)...);
78
+ }
79
+
80
+ template <typename ... T, typename ... U>
81
+ static InFlightDiagnostic diagnoseError (const Operand *op, Diag<T...> diag,
82
+ U &&...args) {
83
+ return ::diagnoseError (op->getUser ()->getFunction ()->getASTContext (),
84
+ op->getUser ()->getLoc ().getSourceLoc (), diag,
85
+ std::forward<U>(args)...);
86
+ }
87
+
88
+ template <typename ... T, typename ... U>
89
+ static InFlightDiagnostic diagnoseError (const SILInstruction *inst,
90
+ Diag<T...> diag, U &&...args) {
91
+ return ::diagnoseError (inst->getFunction ()->getASTContext (),
92
+ inst->getLoc ().getSourceLoc (), diag,
93
+ std::forward<U>(args)...);
94
+ }
95
+
96
+ template <typename ... T, typename ... U>
97
+ static InFlightDiagnostic diagnoseNote (ASTContext &context, SourceLoc loc,
98
+ Diag<T...> diag, U &&...args) {
61
99
return context.Diags .diagnose (loc, diag, std::forward<U>(args)...);
62
100
}
63
101
64
102
template <typename ... T, typename ... U>
65
- static InFlightDiagnostic diagnose (ASTContext &context, SILLocation loc,
66
- Diag<T...> diag, U &&...args) {
67
- return ::diagnose (context, loc.getSourceLoc (), diag,
68
- std::forward<U>(args)...);
103
+ static InFlightDiagnostic diagnoseNote (ASTContext &context, SILLocation loc,
104
+ Diag<T...> diag, U &&...args) {
105
+ return ::diagnoseNote (context, loc.getSourceLoc (), diag,
106
+ std::forward<U>(args)...);
69
107
}
70
108
71
109
template <typename ... T, typename ... U>
72
- static InFlightDiagnostic diagnose (const PartitionOp &op, Diag<T...> diag,
73
- U &&...args) {
74
- return ::diagnose (op.getSourceInst ()->getFunction ()->getASTContext (),
75
- op.getSourceLoc ().getSourceLoc (), diag,
76
- std::forward<U>(args)...);
110
+ static InFlightDiagnostic diagnoseNote (const PartitionOp &op, Diag<T...> diag,
111
+ U &&...args) {
112
+ return ::diagnoseNote (op.getSourceInst ()->getFunction ()->getASTContext (),
113
+ op.getSourceLoc ().getSourceLoc (), diag,
114
+ std::forward<U>(args)...);
77
115
}
78
116
79
117
template <typename ... T, typename ... U>
80
- static InFlightDiagnostic diagnose (const Operand *op, Diag<T...> diag,
81
- U &&...args) {
82
- return ::diagnose (op->getUser ()->getFunction ()->getASTContext (),
83
- op->getUser ()->getLoc ().getSourceLoc (), diag,
84
- std::forward<U>(args)...);
118
+ static InFlightDiagnostic diagnoseNote (const Operand *op, Diag<T...> diag,
119
+ U &&...args) {
120
+ return ::diagnoseNote (op->getUser ()->getFunction ()->getASTContext (),
121
+ op->getUser ()->getLoc ().getSourceLoc (), diag,
122
+ std::forward<U>(args)...);
85
123
}
86
124
87
125
template <typename ... T, typename ... U>
88
- static InFlightDiagnostic diagnose (const SILInstruction *inst, Diag<T...> diag ,
89
- U &&...args) {
90
- return ::diagnose (inst->getFunction ()->getASTContext (),
91
- inst->getLoc ().getSourceLoc (), diag,
92
- std::forward<U>(args)...);
126
+ static InFlightDiagnostic diagnoseNote (const SILInstruction *inst,
127
+ Diag<T...> diag, U &&...args) {
128
+ return ::diagnoseNote (inst->getFunction ()->getASTContext (),
129
+ inst->getLoc ().getSourceLoc (), diag,
130
+ std::forward<U>(args)...);
93
131
}
94
132
95
133
// ===----------------------------------------------------------------------===//
@@ -944,7 +982,7 @@ void TransferNonSendableImpl::emitUseAfterTransferDiagnostics() {
944
982
// editor UIs providing a more actionable error message.
945
983
auto applyUses = diagnosticInferrer.getApplyUses ();
946
984
if (applyUses.empty ()) {
947
- diagnose (transferOp, diag::regionbasedisolation_unknown_pattern);
985
+ diagnoseError (transferOp, diag::regionbasedisolation_unknown_pattern);
948
986
continue ;
949
987
}
950
988
@@ -956,29 +994,31 @@ void TransferNonSendableImpl::emitUseAfterTransferDiagnostics() {
956
994
llvm_unreachable (" Should never see this!" );
957
995
case UseDiagnosticInfoKind::IsolationCrossing: {
958
996
auto isolation = info.diagInfo .getIsolationCrossing ();
959
- diagnose (astContext, info.loc ,
960
- diag::regionbasedisolation_transfer_yields_race_with_isolation,
961
- info.inferredType , isolation.getCallerIsolation (),
962
- isolation.getCalleeIsolation ())
997
+ diagnoseError (
998
+ astContext, info.loc ,
999
+ diag::regionbasedisolation_transfer_yields_race_with_isolation,
1000
+ info.inferredType , isolation.getCallerIsolation (),
1001
+ isolation.getCalleeIsolation ())
963
1002
.highlight (info.loc .getSourceRange ());
964
1003
break ;
965
1004
}
966
1005
case UseDiagnosticInfoKind::RaceWithoutKnownIsolationCrossing:
967
- diagnose (astContext, info.loc ,
968
- diag::regionbasedisolation_transfer_yields_race_no_isolation,
969
- info.inferredType )
1006
+ diagnoseError (
1007
+ astContext, info.loc ,
1008
+ diag::regionbasedisolation_transfer_yields_race_no_isolation,
1009
+ info.inferredType )
970
1010
.highlight (info.loc .getSourceRange ());
971
1011
break ;
972
1012
case UseDiagnosticInfoKind::UseOfStronglyTransferredValue:
973
- diagnose (
1013
+ diagnoseError (
974
1014
astContext, info.loc ,
975
1015
diag::
976
1016
regionbasedisolation_transfer_yields_race_stronglytransferred_binding,
977
1017
info.inferredType )
978
1018
.highlight (info.loc .getSourceRange ());
979
1019
break ;
980
1020
case UseDiagnosticInfoKind::AssignmentIntoTransferringParameter:
981
- diagnose (
1021
+ diagnoseError (
982
1022
astContext, info.loc ,
983
1023
diag::
984
1024
regionbasedisolation_transfer_yields_race_transferring_parameter,
@@ -987,10 +1027,10 @@ void TransferNonSendableImpl::emitUseAfterTransferDiagnostics() {
987
1027
break ;
988
1028
case UseDiagnosticInfoKind::IsolationCrossingDueToCapture:
989
1029
auto isolation = info.diagInfo .getIsolationCrossing ();
990
- diagnose (astContext, info.loc ,
991
- diag::regionbasedisolation_isolated_capture_yields_race,
992
- info.inferredType , isolation.getCalleeIsolation (),
993
- isolation.getCallerIsolation ())
1030
+ diagnoseError (astContext, info.loc ,
1031
+ diag::regionbasedisolation_isolated_capture_yields_race,
1032
+ info.inferredType , isolation.getCalleeIsolation (),
1033
+ isolation.getCallerIsolation ())
994
1034
.highlight (info.loc .getSourceRange ());
995
1035
break ;
996
1036
}
@@ -1011,7 +1051,7 @@ void TransferNonSendableImpl::emitUseAfterTransferDiagnostics() {
1011
1051
if (!liveness.finalRequires .contains (require))
1012
1052
continue ;
1013
1053
1014
- diagnose (require, diag::regionbasedisolation_maybe_race)
1054
+ diagnoseNote (require, diag::regionbasedisolation_maybe_race)
1015
1055
.highlight (require->getLoc ().getSourceRange ());
1016
1056
didEmitRequire = true ;
1017
1057
}
@@ -1041,13 +1081,13 @@ void TransferNonSendableImpl::emitTransferredNonTransferrableDiagnostics() {
1041
1081
case UseDiagnosticInfoKind::Invalid:
1042
1082
llvm_unreachable (" Should never see this" );
1043
1083
case UseDiagnosticInfoKind::MiscUse:
1044
- diagnose (astContext, loc,
1045
- diag::regionbasedisolation_selforargtransferred);
1084
+ diagnoseError (astContext, loc,
1085
+ diag::regionbasedisolation_selforargtransferred);
1046
1086
break ;
1047
1087
case UseDiagnosticInfoKind::FunctionArgumentApply: {
1048
- diagnose (astContext, loc, diag::regionbasedisolation_arg_transferred,
1049
- op->get ()->getType ().getASTType (),
1050
- diagnosticInfo.transferredIsolation .value ())
1088
+ diagnoseError (astContext, loc, diag::regionbasedisolation_arg_transferred,
1089
+ op->get ()->getType ().getASTType (),
1090
+ diagnosticInfo.transferredIsolation .value ())
1051
1091
.highlight (op->getUser ()->getLoc ().getSourceRange ());
1052
1092
// Only emit the note if our value is different from the function
1053
1093
// argument.
@@ -1057,16 +1097,16 @@ void TransferNonSendableImpl::emitTransferredNonTransferrableDiagnostics() {
1057
1097
if (rep.maybeGetValue () == info.nonTransferrableValue )
1058
1098
continue ;
1059
1099
auto *fArg = cast<SILFunctionArgument>(info.nonTransferrableValue );
1060
- diagnose (
1100
+ diagnoseNote (
1061
1101
astContext, fArg ->getDecl ()->getLoc (),
1062
1102
diag::regionbasedisolation_isolated_since_in_same_region_basename,
1063
1103
" task isolated" , fArg ->getDecl ()->getBaseName ());
1064
1104
break ;
1065
1105
}
1066
1106
case UseDiagnosticInfoKind::FunctionArgumentClosure: {
1067
- diagnose (astContext, loc, diag::regionbasedisolation_arg_transferred,
1068
- op->get ()->getType ().getASTType (),
1069
- diagnosticInfo.transferredIsolation .value ())
1107
+ diagnoseError (astContext, loc, diag::regionbasedisolation_arg_transferred,
1108
+ op->get ()->getType ().getASTType (),
1109
+ diagnosticInfo.transferredIsolation .value ())
1070
1110
.highlight (op->getUser ()->getLoc ().getSourceRange ());
1071
1111
// Only emit the note if our value is different from the function
1072
1112
// argument.
@@ -1076,7 +1116,7 @@ void TransferNonSendableImpl::emitTransferredNonTransferrableDiagnostics() {
1076
1116
if (rep.maybeGetValue () == info.nonTransferrableValue )
1077
1117
continue ;
1078
1118
auto *fArg = cast<SILFunctionArgument>(info.nonTransferrableValue );
1079
- diagnose (
1119
+ diagnoseNote (
1080
1120
astContext, fArg ->getDecl ()->getLoc (),
1081
1121
diag::regionbasedisolation_isolated_since_in_same_region_basename,
1082
1122
" task isolated" , fArg ->getDecl ()->getBaseName ());
0 commit comments