@@ -1015,6 +1015,9 @@ class Partition {
1015
1015
1016
1016
// / Swift style enum we use to decouple and reduce boilerplate in between the
1017
1017
// / diagnostic and non-diagnostic part of the infrastructure.
1018
+ // /
1019
+ // / NOTE: This is a noncopyable type so that we can store Partitions in these
1020
+ // / errors without copying them all over the place.
1018
1021
class PartitionOpError {
1019
1022
public:
1020
1023
using Element = PartitionPrimitives::Element;
@@ -1029,6 +1032,9 @@ class PartitionOpError {
1029
1032
const PartitionOp *op;
1030
1033
1031
1034
UnknownCodePatternError (const PartitionOp &op) : op(&op) {}
1035
+ UnknownCodePatternError (UnknownCodePatternError &&other) = default ;
1036
+ UnknownCodePatternError &
1037
+ operator =(UnknownCodePatternError &&other) = default ;
1032
1038
1033
1039
void print (llvm::raw_ostream &os, RegionAnalysisValueMap &valueMap) const ;
1034
1040
@@ -1046,6 +1052,9 @@ class PartitionOpError {
1046
1052
Operand *sendingOp)
1047
1053
: op(&op), sentElement(elt), sendingOp(sendingOp) {}
1048
1054
1055
+ LocalUseAfterSendError (LocalUseAfterSendError &&other) = default ;
1056
+ LocalUseAfterSendError &operator =(LocalUseAfterSendError &&other) = default ;
1057
+
1049
1058
void print (llvm::raw_ostream &os, RegionAnalysisValueMap &valueMap) const ;
1050
1059
1051
1060
SWIFT_DEBUG_DUMPER (dump(RegionAnalysisValueMap &valueMap)) {
@@ -1063,6 +1072,9 @@ class PartitionOpError {
1063
1072
: op(&op), sentElement(sentElement),
1064
1073
isolationRegionInfo (isolationRegionInfo) {}
1065
1074
1075
+ SentNeverSendableError (SentNeverSendableError &&other) = default;
1076
+ SentNeverSendableError &operator =(SentNeverSendableError &&other) = default ;
1077
+
1066
1078
void print (llvm::raw_ostream &os, RegionAnalysisValueMap &valueMap) const ;
1067
1079
1068
1080
SWIFT_DEBUG_DUMPER (dump(RegionAnalysisValueMap &valueMap)) {
@@ -1086,6 +1098,11 @@ class PartitionOpError {
1086
1098
srcElement (srcElement), srcValue(srcValue),
1087
1099
srcIsolationRegionInfo(srcIsolationRegionInfo) {}
1088
1100
1101
+ AssignNeverSendableIntoSendingResultError (
1102
+ AssignNeverSendableIntoSendingResultError &&other) = default;
1103
+ AssignNeverSendableIntoSendingResultError &
1104
+ operator =(AssignNeverSendableIntoSendingResultError &&other) = default ;
1105
+
1089
1106
void print (llvm::raw_ostream &os, RegionAnalysisValueMap &valueMap) const ;
1090
1107
1091
1108
SWIFT_DEBUG_DUMPER (dump(RegionAnalysisValueMap &valueMap)) {
@@ -1102,6 +1119,11 @@ class PartitionOpError {
1102
1119
Operand *sendingOp)
1103
1120
: op(&op), sentElement(elt), sendingOp(sendingOp) {}
1104
1121
1122
+ InOutSendingNotInitializedAtExitError (
1123
+ InOutSendingNotInitializedAtExitError &&other) = default ;
1124
+ InOutSendingNotInitializedAtExitError &
1125
+ operator =(InOutSendingNotInitializedAtExitError &&other) = default ;
1126
+
1105
1127
void print (llvm::raw_ostream &os, RegionAnalysisValueMap &valueMap) const ;
1106
1128
1107
1129
SWIFT_DEBUG_DUMPER (dump(RegionAnalysisValueMap &valueMap)) {
@@ -1119,6 +1141,11 @@ class PartitionOpError {
1119
1141
SILDynamicMergedIsolationInfo isolation)
1120
1142
: op(&op), inoutSendingElement(elt), isolationInfo(isolation) {}
1121
1143
1144
+ InOutSendingNotDisconnectedAtExitError (
1145
+ InOutSendingNotDisconnectedAtExitError &&other) = default ;
1146
+ InOutSendingNotDisconnectedAtExitError &
1147
+ operator =(InOutSendingNotDisconnectedAtExitError &&other) = default ;
1148
+
1122
1149
void print (llvm::raw_ostream &os, RegionAnalysisValueMap &valueMap) const ;
1123
1150
1124
1151
SWIFT_DEBUG_DUMPER (dump(RegionAnalysisValueMap &valueMap)) {
@@ -1153,6 +1180,10 @@ class PartitionOpError {
1153
1180
: InOutSendingReturnedError(op, inoutSendingElement,
1154
1181
inoutSendingElement, isolationInfo) {}
1155
1182
1183
+ InOutSendingReturnedError (InOutSendingReturnedError &&other) = default;
1184
+ InOutSendingReturnedError &
1185
+ operator =(InOutSendingReturnedError &&other) = default ;
1186
+
1156
1187
void print (llvm::raw_ostream &os, RegionAnalysisValueMap &valueMap) const ;
1157
1188
1158
1189
SWIFT_DEBUG_DUMPER (dump(RegionAnalysisValueMap &valueMap)) {
@@ -1169,6 +1200,11 @@ class PartitionOpError {
1169
1200
Element returnValue)
1170
1201
: op(&op), returnValueElement(returnValue) {}
1171
1202
1203
+ NonSendableIsolationCrossingResultError (
1204
+ NonSendableIsolationCrossingResultError &&other) = default ;
1205
+ NonSendableIsolationCrossingResultError &
1206
+ operator =(NonSendableIsolationCrossingResultError &&other) = default ;
1207
+
1172
1208
void print (llvm::raw_ostream &os, RegionAnalysisValueMap &valueMap) const ;
1173
1209
1174
1210
SWIFT_DEBUG_DUMPER (dump(RegionAnalysisValueMap &valueMap)) {
@@ -1177,12 +1213,14 @@ class PartitionOpError {
1177
1213
};
1178
1214
1179
1215
#define PARTITION_OP_ERROR (NAME ) \
1180
- static_assert (std::is_copy_constructible_v<NAME##Error>, \
1181
- #NAME " must be copy constructable" );
1182
- #include " PartitionOpError.def"
1183
- #define PARTITION_OP_ERROR (NAME ) \
1184
- static_assert (std::is_copy_assignable_v<NAME##Error>, \
1185
- #NAME " must be copy assignable" );
1216
+ static_assert (!std::is_copy_constructible_v<NAME##Error>, \
1217
+ #NAME " must not be copy constructable" ); \
1218
+ static_assert (std::is_move_constructible_v<NAME##Error>, \
1219
+ #NAME " must be move constructable" ); \
1220
+ static_assert (!std::is_copy_assignable_v<NAME##Error>, \
1221
+ #NAME " must not be copy assignable" ); \
1222
+ static_assert (std::is_move_assignable_v<NAME##Error>, \
1223
+ #NAME " must be move assignable" );
1186
1224
#include " PartitionOpError.def"
1187
1225
1188
1226
private:
@@ -1196,11 +1234,12 @@ class PartitionOpError {
1196
1234
1197
1235
public:
1198
1236
#define PARTITION_OP_ERROR (NAME ) \
1199
- PartitionOpError (NAME##Error error) : kind(Kind::NAME), data(error) {}
1237
+ PartitionOpError (NAME##Error &&error) \
1238
+ : kind(Kind::NAME), data(std::move(error)) {}
1200
1239
#include " PartitionOpError.def"
1201
1240
1202
- PartitionOpError (const PartitionOpError &error)
1203
- : kind(error.kind), data(error.data) {
1241
+ PartitionOpError (PartitionOpError & &error)
1242
+ : kind(error.kind), data(std::move( error.data) ) {
1204
1243
switch (getKind ()) {
1205
1244
#define PARTITION_OP_ERROR (NAME ) \
1206
1245
case NAME: \
@@ -1211,9 +1250,9 @@ class PartitionOpError {
1211
1250
}
1212
1251
}
1213
1252
1214
- PartitionOpError &operator =(const PartitionOpError &error) {
1253
+ PartitionOpError &operator =(PartitionOpError & &error) {
1215
1254
kind = error.kind ;
1216
- data = error.data ;
1255
+ data = std::move ( error.data ) ;
1217
1256
1218
1257
switch (getKind ()) {
1219
1258
#define PARTITION_OP_ERROR (NAME ) \
@@ -1232,7 +1271,7 @@ class PartitionOpError {
1232
1271
switch (getKind ()) {
1233
1272
#define PARTITION_OP_ERROR (NAME ) \
1234
1273
case NAME: \
1235
- return get## NAME##Error ( ).print (os, valueMap);
1274
+ return std:: get< NAME##Error>(data ).print (os, valueMap);
1236
1275
#include " PartitionOpError.def"
1237
1276
}
1238
1277
llvm_unreachable (" Covered switch isn't covered?!" );
@@ -1243,9 +1282,9 @@ class PartitionOpError {
1243
1282
}
1244
1283
1245
1284
#define PARTITION_OP_ERROR (NAME ) \
1246
- NAME##Error get##NAME##Error() const { \
1285
+ NAME##Error get##NAME##Error() && { \
1247
1286
assert (getKind () == Kind::NAME); \
1248
- return std::get<NAME##Error>(data); \
1287
+ return std::get<NAME##Error>(std::move ( data)); \
1249
1288
}
1250
1289
#include " PartitionOpError.def"
1251
1290
};
@@ -1288,7 +1327,9 @@ struct PartitionOpEvaluator {
1288
1327
return asImpl ().shouldEmitVerboseLogging ();
1289
1328
}
1290
1329
1291
- void handleError (PartitionOpError error) { asImpl ().handleError (error); }
1330
+ void handleError (PartitionOpError &&error) {
1331
+ asImpl ().handleError (std::move (error));
1332
+ }
1292
1333
1293
1334
// / Call isActorDerived on our CRTP subclass.
1294
1335
bool isActorDerived (Element elt) const {
@@ -1900,7 +1941,7 @@ struct PartitionOpEvaluatorBaseImpl : PartitionOpEvaluator<Subclass> {
1900
1941
SILValue getInOutSendingParameter (Element elt) const { return {}; }
1901
1942
1902
1943
// / By default, do nothing upon error.
1903
- void handleError (PartitionOpError error) {}
1944
+ void handleError (PartitionOpError && error) {}
1904
1945
1905
1946
// / Returns the information about \p elt's isolation that we ascertained from
1906
1947
// / SIL and the AST.
0 commit comments