Skip to content

Commit 5cd6ba7

Browse files
committed
merge similar diagnostics together under a unified naming scheme for more consistent word tense
sil_movekillscopyablevalue_* and sil_moveonlychecker_* can share diagnostics. rdar://109281444 (cherry picked from commit 71763a1)
1 parent 51955d5 commit 5cd6ba7

13 files changed

+572
-584
lines changed

include/swift/AST/DiagnosticsSIL.def

Lines changed: 29 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -747,77 +747,65 @@ NOTE(discard_nontrivial_implicit_storage_note,none,
747747
"type %0 implicitly contains %1 which cannot be trivially destroyed",
748748
(Type, Type))
749749

750-
// move only checker diagnostics
751-
ERROR(sil_moveonlychecker_owned_value_consumed_more_than_once, none,
750+
751+
/// Move Checking / Noncopyable types diagnostics
752+
753+
ERROR(sil_movechecking_owned_value_consumed_more_than_once, none,
752754
"'%0' consumed more than once", (StringRef))
753-
ERROR(sil_moveonlychecker_owned_value_consumed_and_used_at_same_time, none,
755+
ERROR(sil_movechecking_owned_value_consumed_and_used_at_same_time, none,
754756
"'%0' consumed and used at the same time", (StringRef))
755-
ERROR(sil_moveonlychecker_value_used_after_consume, none,
757+
ERROR(sil_movechecking_value_used_after_consume, none,
756758
"'%0' used after consume", (StringRef))
757-
ERROR(sil_moveonlychecker_guaranteed_value_consumed, none,
759+
ERROR(sil_movechecking_guaranteed_value_consumed, none,
758760
"'%0' is borrowed and cannot be consumed", (StringRef))
759761

760762
// FIXME: this diagnostic shouldn't ever be emitted now. rdar://109742587 (closures may still try to consume captures, e.g., borrowed parameters)
761-
ERROR(sil_moveonlychecker_guaranteed_value_captured_by_closure, none,
763+
ERROR(sil_movechecking_guaranteed_value_captured_by_closure, none,
762764
"'%0' is borrowed and cannot be consumed by closure capture", (StringRef))
763765

764-
ERROR(sil_moveonlychecker_capture_consumed, none,
766+
ERROR(sil_movechecking_capture_consumed, none,
765767
"noncopyable '%0' cannot be consumed when captured by a closure", (StringRef))
766-
ERROR(sil_moveonlychecker_inout_not_reinitialized_before_end_of_function, none,
768+
ERROR(sil_movechecking_inout_not_reinitialized_before_end_of_function, none,
767769
"missing reinitialization of inout parameter '%0' after consume", (StringRef))
768-
ERROR(sil_moveonlychecker_value_consumed_in_a_loop, none,
770+
ERROR(sil_movechecking_value_consumed_in_a_loop, none,
769771
"'%0' consumed in a loop", (StringRef))
770-
771-
ERROR(sil_moveonlychecker_use_after_partial_consume, none,
772+
ERROR(sil_movechecking_use_after_partial_consume, none,
772773
"cannot use '%0' after partial consume", (StringRef))
773-
774-
ERROR(sil_moveonlychecker_notconsumable_but_assignable_was_consumed, none,
774+
ERROR(sil_movechecking_notconsumable_but_assignable_was_consumed, none,
775775
"cannot consume noncopyable stored property '%0' %select{of a class|that is global}1",
776776
(StringRef, bool))
777-
778-
ERROR(sil_moveonlychecker_cannot_destructure_has_deinit, none,
777+
ERROR(sil_movechecking_cannot_destructure_has_deinit, none,
779778
"cannot partially consume '%0' when it has a deinitializer",
780779
(StringRef))
781780

782-
NOTE(sil_moveonlychecker_partial_consume_here, none,
781+
NOTE(sil_movechecking_partial_consume_here, none,
783782
"partially consumed here", ())
784-
NOTE(sil_moveonlychecker_consuming_use_here, none,
783+
NOTE(sil_movechecking_consuming_use_here, none,
785784
"consumed here", ())
786-
NOTE(sil_moveonlychecker_other_consuming_use_here, none,
785+
NOTE(sil_movechecking_other_consuming_use_here, none,
787786
"other consume here", ())
788-
NOTE(sil_moveonlychecker_two_consuming_uses_here, none,
787+
NOTE(sil_movechecking_two_consuming_uses_here, none,
789788
"multiple consumes here", ())
790-
NOTE(sil_moveonlychecker_consuming_and_non_consuming_uses_here, none,
789+
NOTE(sil_movechecking_consuming_and_non_consuming_uses_here, none,
791790
"consumed and used here", ())
792-
NOTE(sil_moveonlychecker_consuming_closure_use_here, none,
791+
NOTE(sil_movechecking_consuming_closure_use_here, none,
793792
"closure capturing '%0' here", (StringRef))
794-
NOTE(sil_moveonlychecker_nonconsuming_use_here, none,
793+
NOTE(sil_movechecking_nonconsuming_use_here, none,
795794
"used here", ())
796-
797-
NOTE(sil_movekillscopyablevalue_value_cyclic_consumed_in_loop_here, none,
798-
"consuming in loop use here", ())
799-
NOTE(sil_moveonlychecker_deinit_here, none,
800-
"deinit declared here", ())
801-
802-
// move kills copyable values checker diagnostics
803-
ERROR(sil_movekillscopyablevalue_value_consumed_more_than_once, none,
804-
"'%0' used after being consumed", (StringRef))
805-
NOTE(sil_movekillscopyablevalue_move_here, none,
806-
"consume here", ())
807-
NOTE(sil_movekillscopyablevalue_use_here, none,
808-
"use here", ())
809-
NOTE(sil_movekillscopyablevalue_value_consumed_in_loop, none,
810-
"consume here would occur multiple times in loop", ())
795+
NOTE(sil_movechecking_consumed_in_loop_here, none,
796+
"consumed in loop here", ())
797+
NOTE(sil_movechecking_deinit_here, none,
798+
"deinitializer declared here", ())
811799

812800
// errors involving noncopyables that are considered to be bugs in the compiler
813-
ERROR(sil_moveonlychecker_not_understand_consumable_and_assignable, none,
801+
ERROR(sil_movechecking_not_understand_consumable_and_assignable, none,
814802
"usage of no-implicit-copy value that the compiler can't verify. This is a compiler bug. Please file a bug with a small example of the bug", ())
815-
ERROR(sil_moveonlychecker_not_understand_moveonly, none,
803+
ERROR(sil_movechecking_not_understand_moveonly, none,
816804
"usage of a noncopyable type that compiler can't verify. This is a compiler bug. Please file a bug with a small example of the bug"
817805
"check!", ())
818-
ERROR(sil_moveonlychecker_bug_missed_copy, none,
806+
ERROR(sil_movechecking_bug_missed_copy, none,
819807
"copy of noncopyable typed value. This is a compiler bug. Please file a bug with a small example of the bug", ())
820-
ERROR(sil_moveonlychecker_bug_exclusivity_violation, none,
808+
ERROR(sil_movechecking_bug_exclusivity_violation, none,
821809
"'%0' has an unexpected exclusivity violation. This is a compiler bug. Please file a bug with a small example of the bug", (StringRef))
822810
ERROR(sil_movekillscopyablevalue_move_applied_to_unsupported_move, none,
823811
"'consume' applied to value that the compiler does not support. This is a compiler bug. Please file a bug with a small example of the bug",

lib/SILOptimizer/Mandatory/ConsumeOperatorCopyableAddressesChecker.cpp

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1655,18 +1655,18 @@ bool DataflowState::process(
16551655
auto &astContext = fn->getASTContext();
16561656
{
16571657
auto diag =
1658-
diag::sil_movekillscopyablevalue_value_consumed_more_than_once;
1658+
diag::sil_movechecking_value_used_after_consume;
16591659
StringRef name = getDebugVarName(address);
16601660
diagnose(astContext, getSourceLocFromValue(address), diag, name);
16611661
}
16621662

16631663
{
1664-
auto diag = diag::sil_movekillscopyablevalue_move_here;
1664+
auto diag = diag::sil_movechecking_consuming_use_here;
16651665
diagnose(astContext, mvi->getLoc().getSourceLoc(), diag);
16661666
}
16671667

16681668
{
1669-
auto diag = diag::sil_movekillscopyablevalue_use_here;
1669+
auto diag = diag::sil_movechecking_nonconsuming_use_here;
16701670
diagnose(astContext, iter->second->getLoc().getSourceLoc(), diag);
16711671
}
16721672

@@ -1685,18 +1685,18 @@ bool DataflowState::process(
16851685
auto &astContext = fn->getASTContext();
16861686
{
16871687
auto diag =
1688-
diag::sil_movekillscopyablevalue_value_consumed_more_than_once;
1688+
diag::sil_movechecking_value_used_after_consume;
16891689
StringRef name = getDebugVarName(address);
16901690
diagnose(astContext, getSourceLocFromValue(address), diag, name);
16911691
}
16921692

16931693
{
1694-
auto diag = diag::sil_movekillscopyablevalue_move_here;
1694+
auto diag = diag::sil_movechecking_consuming_use_here;
16951695
diagnose(astContext, mvi->getLoc().getSourceLoc(), diag);
16961696
}
16971697

16981698
{
1699-
auto diag = diag::sil_movekillscopyablevalue_use_here;
1699+
auto diag = diag::sil_movechecking_nonconsuming_use_here;
17001700
for (auto *user : iter->second->pairedUseInsts) {
17011701
diagnose(astContext, user->getLoc().getSourceLoc(), diag);
17021702
}
@@ -2114,16 +2114,16 @@ bool ConsumeOperatorCopyableAddressesChecker::performSingleBasicBlockAnalysis(
21142114
auto &astCtx = mvi->getFunction()->getASTContext();
21152115
{
21162116
auto diag =
2117-
diag::sil_movekillscopyablevalue_value_consumed_more_than_once;
2117+
diag::sil_movechecking_value_used_after_consume;
21182118
StringRef name = getDebugVarName(address);
21192119
diagnose(astCtx, getSourceLocFromValue(address), diag, name);
21202120
}
21212121

2122-
auto diag = diag::sil_movekillscopyablevalue_move_here;
2122+
auto diag = diag::sil_movechecking_consuming_use_here;
21232123
diagnose(astCtx, mvi->getLoc().getSourceLoc(), diag);
21242124

21252125
{
2126-
auto diag = diag::sil_movekillscopyablevalue_use_here;
2126+
auto diag = diag::sil_movechecking_nonconsuming_use_here;
21272127
for (auto *user : interestingClosureUsers) {
21282128
diagnose(astCtx, user->getLoc().getSourceLoc(), diag);
21292129
}
@@ -2155,18 +2155,18 @@ bool ConsumeOperatorCopyableAddressesChecker::performSingleBasicBlockAnalysis(
21552155
auto &astCtx = mvi->getFunction()->getASTContext();
21562156
{
21572157
auto diag =
2158-
diag::sil_movekillscopyablevalue_value_consumed_more_than_once;
2158+
diag::sil_movechecking_value_used_after_consume;
21592159
StringRef name = getDebugVarName(address);
21602160
diagnose(astCtx, getSourceLocFromValue(address), diag, name);
21612161
}
21622162

21632163
{
2164-
auto diag = diag::sil_movekillscopyablevalue_move_here;
2164+
auto diag = diag::sil_movechecking_consuming_use_here;
21652165
diagnose(astCtx, mvi->getLoc().getSourceLoc(), diag);
21662166
}
21672167

21682168
{
2169-
auto diag = diag::sil_movekillscopyablevalue_use_here;
2169+
auto diag = diag::sil_movechecking_nonconsuming_use_here;
21702170
diagnose(astCtx, interestingUser->getLoc().getSourceLoc(), diag);
21712171
}
21722172

lib/SILOptimizer/Mandatory/ConsumeOperatorCopyableValuesChecker.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -248,10 +248,10 @@ void ConsumeOperatorCopyableValuesChecker::emitDiagnosticForMove(
248248

249249
// First we emit the main error and then the note on where the move was.
250250
diagnose(astContext, getSourceLocFromValue(borrowedValue),
251-
diag::sil_movekillscopyablevalue_value_consumed_more_than_once,
251+
diag::sil_movechecking_value_used_after_consume,
252252
borrowedValueName);
253253
diagnose(astContext, mvi->getLoc().getSourceLoc(),
254-
diag::sil_movekillscopyablevalue_move_here);
254+
diag::sil_movechecking_consuming_use_here);
255255

256256
// Then we do a bit of work to figure out where /all/ of the later uses than
257257
// mvi are so we can emit notes to the user telling them this is a problem
@@ -282,7 +282,7 @@ void ConsumeOperatorCopyableValuesChecker::emitDiagnosticForMove(
282282
case PrunedLiveness::LifetimeEndingUse:
283283
LLVM_DEBUG(llvm::dbgs() << "Emitting note for in block use: " << inst);
284284
diagnose(astContext, inst.getLoc().getSourceLoc(),
285-
diag::sil_movekillscopyablevalue_use_here);
285+
diag::sil_movechecking_nonconsuming_use_here);
286286
break;
287287
}
288288
}
@@ -341,7 +341,7 @@ void ConsumeOperatorCopyableValuesChecker::emitDiagnosticForMove(
341341
LLVM_DEBUG(llvm::dbgs()
342342
<< "(3) Emitting diagnostic for user: " << inst);
343343
diagnose(astContext, inst.getLoc().getSourceLoc(),
344-
diag::sil_movekillscopyablevalue_use_here);
344+
diag::sil_movechecking_nonconsuming_use_here);
345345
break;
346346
}
347347
}
@@ -367,7 +367,7 @@ void ConsumeOperatorCopyableValuesChecker::emitDiagnosticForMove(
367367
LLVM_DEBUG(llvm::dbgs()
368368
<< "(1) Emitting diagnostic for user: " << inst);
369369
diagnose(astContext, inst.getLoc().getSourceLoc(),
370-
diag::sil_movekillscopyablevalue_use_here);
370+
diag::sil_movechecking_nonconsuming_use_here);
371371
continue;
372372
}
373373

@@ -378,7 +378,7 @@ void ConsumeOperatorCopyableValuesChecker::emitDiagnosticForMove(
378378
// carry dataflow violation.
379379
if (mvi == &inst) {
380380
diagnose(astContext, inst.getLoc().getSourceLoc(),
381-
diag::sil_movekillscopyablevalue_value_consumed_in_loop);
381+
diag::sil_movechecking_consumed_in_loop_here);
382382
continue;
383383
}
384384
// We ignore consuming uses that are destroy_value since in our model
@@ -389,7 +389,7 @@ void ConsumeOperatorCopyableValuesChecker::emitDiagnosticForMove(
389389
LLVM_DEBUG(llvm::dbgs()
390390
<< "(2) Emitting diagnostic for user: " << inst);
391391
diagnose(astContext, inst.getLoc().getSourceLoc(),
392-
diag::sil_movekillscopyablevalue_use_here);
392+
diag::sil_movechecking_nonconsuming_use_here);
393393
}
394394
}
395395
}

0 commit comments

Comments
 (0)