@@ -537,8 +537,11 @@ class UseAfterTransferDiagnosticEmitter {
537
537
// Then emit the note with greater context.
538
538
SmallString<64 > descriptiveKindStr;
539
539
{
540
- llvm::raw_svector_ostream os (descriptiveKindStr);
541
- namedValuesIsolationInfo.printForDiagnostics (os);
540
+ if (!namedValuesIsolationInfo.isDisconnected ()) {
541
+ llvm::raw_svector_ostream os (descriptiveKindStr);
542
+ namedValuesIsolationInfo.printForDiagnostics (os);
543
+ os << ' ' ;
544
+ }
542
545
}
543
546
544
547
if (auto calleeInfo = getTransferringCalleeInfo ()) {
@@ -619,8 +622,11 @@ class UseAfterTransferDiagnosticEmitter {
619
622
620
623
SmallString<64 > descriptiveKindStr;
621
624
{
622
- llvm::raw_svector_ostream os (descriptiveKindStr);
623
- namedValuesIsolationInfo.printForDiagnostics (os);
625
+ if (!namedValuesIsolationInfo.isDisconnected ()) {
626
+ llvm::raw_svector_ostream os (descriptiveKindStr);
627
+ namedValuesIsolationInfo.printForDiagnostics (os);
628
+ os << ' ' ;
629
+ }
624
630
}
625
631
626
632
diagnoseNote (
@@ -1081,8 +1087,7 @@ class TransferNonTransferrableDiagnosticEmitter {
1081
1087
getIsolationRegionInfo ().printForDiagnostics (os);
1082
1088
}
1083
1089
diagnoseError (loc, diag::regionbasedisolation_arg_transferred,
1084
- StringRef (descriptiveKindStr), type,
1085
- crossing.getCalleeIsolation ())
1090
+ descriptiveKindStr, type, crossing.getCalleeIsolation ())
1086
1091
.highlight (getOperand ()->getUser ()->getLoc ().getSourceRange ())
1087
1092
.limitBehaviorIf (getBehaviorLimit ());
1088
1093
}
@@ -1092,8 +1097,11 @@ class TransferNonTransferrableDiagnosticEmitter {
1092
1097
emitNamedOnlyError (loc, name);
1093
1098
SmallString<64 > descriptiveKindStr;
1094
1099
{
1095
- llvm::raw_svector_ostream os (descriptiveKindStr);
1096
- getIsolationRegionInfo ().printForDiagnostics (os);
1100
+ if (!getIsolationRegionInfo ().isDisconnected ()) {
1101
+ llvm::raw_svector_ostream os (descriptiveKindStr);
1102
+ getIsolationRegionInfo ().printForDiagnostics (os);
1103
+ os << ' ' ;
1104
+ }
1097
1105
}
1098
1106
diagnoseNote (loc,
1099
1107
diag::regionbasedisolation_named_isolated_closure_yields_race,
@@ -1127,20 +1135,29 @@ class TransferNonTransferrableDiagnosticEmitter {
1127
1135
ApplyIsolationCrossing isolationCrossing) {
1128
1136
emitNamedOnlyError (loc, name);
1129
1137
SmallString<64 > descriptiveKindStr;
1138
+ SmallString<64 > descriptiveKindStrWithSpace;
1130
1139
{
1131
- llvm::raw_svector_ostream os (descriptiveKindStr);
1132
- getIsolationRegionInfo ().printForDiagnostics (os);
1140
+ if (!getIsolationRegionInfo ().isDisconnected ()) {
1141
+ {
1142
+ llvm::raw_svector_ostream os (descriptiveKindStr);
1143
+ getIsolationRegionInfo ().printForDiagnostics (os);
1144
+ }
1145
+ descriptiveKindStrWithSpace = descriptiveKindStr;
1146
+ descriptiveKindStrWithSpace.push_back (' ' );
1147
+ }
1133
1148
}
1134
1149
if (auto calleeInfo = getTransferringCalleeInfo ()) {
1135
1150
diagnoseNote (
1136
1151
loc,
1137
1152
diag::regionbasedisolation_named_transfer_non_transferrable_callee,
1138
- name, descriptiveKindStr, isolationCrossing.getCalleeIsolation (),
1139
- calleeInfo->first , calleeInfo->second );
1153
+ name, descriptiveKindStrWithSpace,
1154
+ isolationCrossing.getCalleeIsolation (), calleeInfo->first ,
1155
+ calleeInfo->second , descriptiveKindStr);
1140
1156
} else {
1141
- diagnoseNote (
1142
- loc, diag::regionbasedisolation_named_transfer_non_transferrable,
1143
- name, descriptiveKindStr, isolationCrossing.getCalleeIsolation ());
1157
+ diagnoseNote (loc,
1158
+ diag::regionbasedisolation_named_transfer_non_transferrable,
1159
+ name, descriptiveKindStrWithSpace,
1160
+ isolationCrossing.getCalleeIsolation (), descriptiveKindStr);
1144
1161
}
1145
1162
}
1146
1163
@@ -1149,8 +1166,11 @@ class TransferNonTransferrableDiagnosticEmitter {
1149
1166
emitNamedOnlyError (loc, varName);
1150
1167
SmallString<64 > descriptiveKindStr;
1151
1168
{
1152
- llvm::raw_svector_ostream os (descriptiveKindStr);
1153
- getIsolationRegionInfo ().printForDiagnostics (os);
1169
+ if (!getIsolationRegionInfo ().isDisconnected ()) {
1170
+ llvm::raw_svector_ostream os (descriptiveKindStr);
1171
+ getIsolationRegionInfo ().printForDiagnostics (os);
1172
+ os << ' ' ;
1173
+ }
1154
1174
}
1155
1175
auto diag =
1156
1176
diag::regionbasedisolation_named_transfer_into_transferring_param;
@@ -1160,13 +1180,21 @@ class TransferNonTransferrableDiagnosticEmitter {
1160
1180
void emitNamedTransferringReturn (SILLocation loc, Identifier varName) {
1161
1181
emitNamedOnlyError (loc, varName);
1162
1182
SmallString<64 > descriptiveKindStr;
1183
+ SmallString<64 > descriptiveKindStrWithSpace;
1163
1184
{
1164
- llvm::raw_svector_ostream os (descriptiveKindStr);
1165
- getIsolationRegionInfo ().printForDiagnostics (os);
1185
+ if (!getIsolationRegionInfo ().isDisconnected ()) {
1186
+ {
1187
+ llvm::raw_svector_ostream os (descriptiveKindStr);
1188
+ getIsolationRegionInfo ().printForDiagnostics (os);
1189
+ }
1190
+ descriptiveKindStrWithSpace = descriptiveKindStr;
1191
+ descriptiveKindStrWithSpace.push_back (' ' );
1192
+ }
1166
1193
}
1167
1194
auto diag =
1168
1195
diag::regionbasedisolation_named_notransfer_transfer_into_result;
1169
- diagnoseNote (loc, diag, descriptiveKindStr, varName);
1196
+ diagnoseNote (loc, diag, descriptiveKindStrWithSpace, varName,
1197
+ descriptiveKindStr);
1170
1198
}
1171
1199
1172
1200
private:
0 commit comments