@@ -521,6 +521,8 @@ namespace {
521
521
522
522
private:
523
523
524
+ void emitSelfConsumedDiagnostic (SILInstruction *Inst);
525
+
524
526
LiveOutBlockState &getBlockInfo (SILBasicBlock *BB) {
525
527
return PerBlockInfo.insert ({BB,
526
528
LiveOutBlockState (TheMemory.NumElements )}).first ->second ;
@@ -920,18 +922,21 @@ void LifetimeChecker::handleLoadUse(unsigned UseID) {
920
922
}
921
923
}
922
924
925
+ void LifetimeChecker::emitSelfConsumedDiagnostic (SILInstruction *Inst) {
926
+ if (!shouldEmitError (Inst))
927
+ return ;
928
+
929
+ diagnose (Module, Inst->getLoc (),
930
+ diag::self_inside_catch_superselfinit,
931
+ (unsigned )TheMemory.isDelegatingInit ());
932
+ }
933
+
923
934
void LifetimeChecker::handleStoreUse (unsigned UseID) {
924
935
DIMemoryUse &InstInfo = Uses[UseID];
925
936
926
937
if (TheMemory.isAnyInitSelf ()) {
927
938
if (getSelfConsumedAtInst (InstInfo.Inst ) != DIKind::No) {
928
- // FIXME: more specific diagnostics here, handle this case gracefully below.
929
- if (!shouldEmitError (InstInfo.Inst ))
930
- return ;
931
-
932
- diagnose (Module, InstInfo.Inst ->getLoc (),
933
- diag::self_inside_catch_superselfinit,
934
- (unsigned )TheMemory.isDelegatingInit ());
939
+ emitSelfConsumedDiagnostic (InstInfo.Inst );
935
940
return ;
936
941
}
937
942
}
@@ -1027,13 +1032,7 @@ void LifetimeChecker::handleInOutUse(const DIMemoryUse &Use) {
1027
1032
// before the "address" is passed as an l-value.
1028
1033
if (!isInitializedAtUse (Use, &IsSuperInitDone, &FailedSelfUse)) {
1029
1034
if (FailedSelfUse) {
1030
- // FIXME: more specific diagnostics here, handle this case gracefully below.
1031
- if (!shouldEmitError (Use.Inst ))
1032
- return ;
1033
-
1034
- diagnose (Module, Use.Inst ->getLoc (),
1035
- diag::self_inside_catch_superselfinit,
1036
- (unsigned )TheMemory.isDelegatingInit ());
1035
+ emitSelfConsumedDiagnostic (Use.Inst );
1037
1036
return ;
1038
1037
}
1039
1038
@@ -1135,13 +1134,7 @@ void LifetimeChecker::handleEscapeUse(const DIMemoryUse &Use) {
1135
1134
auto Inst = Use.Inst ;
1136
1135
1137
1136
if (FailedSelfUse) {
1138
- // FIXME: more specific diagnostics here, handle this case gracefully below.
1139
- if (!shouldEmitError (Inst))
1140
- return ;
1141
-
1142
- diagnose (Module, Inst->getLoc (),
1143
- diag::self_inside_catch_superselfinit,
1144
- (unsigned )TheMemory.isDelegatingInit ());
1137
+ emitSelfConsumedDiagnostic (Inst);
1145
1138
return ;
1146
1139
}
1147
1140
@@ -1502,13 +1495,7 @@ void LifetimeChecker::handleLoadUseFailure(const DIMemoryUse &Use,
1502
1495
SILInstruction *Inst = Use.Inst ;
1503
1496
1504
1497
if (FailedSelfUse) {
1505
- // FIXME: more specific diagnostics here, handle this case gracefully below.
1506
- if (!shouldEmitError (Inst))
1507
- return ;
1508
-
1509
- diagnose (Module, Inst->getLoc (),
1510
- diag::self_inside_catch_superselfinit,
1511
- (unsigned )TheMemory.isDelegatingInit ());
1498
+ emitSelfConsumedDiagnostic (Inst);
1512
1499
return ;
1513
1500
}
1514
1501
@@ -1670,13 +1657,7 @@ void LifetimeChecker::handleSelfInitUse(DIMemoryUse &InstInfo) {
1670
1657
assert (TheMemory.getType ()->hasReferenceSemantics ());
1671
1658
1672
1659
if (getSelfConsumedAtInst (Inst) != DIKind::No) {
1673
- // FIXME: more specific diagnostics here, handle this case gracefully below.
1674
- if (!shouldEmitError (Inst))
1675
- return ;
1676
-
1677
- diagnose (Module, Inst->getLoc (),
1678
- diag::self_inside_catch_superselfinit,
1679
- (unsigned )TheMemory.isDelegatingInit ());
1660
+ emitSelfConsumedDiagnostic (Inst);
1680
1661
return ;
1681
1662
}
1682
1663
0 commit comments