Skip to content

Commit ee63610

Browse files
committed
batch 2
1 parent 74bed5e commit ee63610

7 files changed

+218
-250
lines changed

include/swift/AST/DiagnosticsSIL.def

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -754,20 +754,22 @@ ERROR(sil_moveonlychecker_value_used_after_consume, none,
754754
"'%0' used after consume", (StringRef))
755755
ERROR(sil_moveonlychecker_guaranteed_value_consumed, none,
756756
"'%0' is borrowed and cannot be consumed", (StringRef))
757+
758+
// FIXME: this diagnostic shouldn't ever be emitted now. rdar://109742587 (closures may still try to consume captures, e.g., borrowed parameters)
757759
ERROR(sil_moveonlychecker_guaranteed_value_captured_by_closure, none,
758760
"'%0' is borrowed and cannot be consumed by closure capture", (StringRef))
761+
759762
ERROR(sil_moveonlychecker_let_value_consumed_in_closure, none,
760763
"captured '%0' cannot be consumed within a closure", (StringRef))
761764
ERROR(sil_moveonlychecker_inout_not_reinitialized_before_end_of_function, none,
762-
"'%0' consumed but not reinitialized before end of function", (StringRef))
763-
ERROR(sil_moveonlychecker_inout_not_reinitialized_before_end_of_closure, none,
764-
"'%0' consumed in closure but not reinitialized before end of closure", (StringRef))
765+
"missing reinitialization of '$0' after consume", (StringRef))
765766
ERROR(sil_moveonlychecker_value_consumed_in_a_loop, none,
766767
"'%0' consumed by a use in a loop", (StringRef))
767-
ERROR(sil_moveonlychecker_exclusivity_violation, none,
768-
"'%0' has consuming use that cannot be eliminated due to a tight exclusivity scope", (StringRef))
768+
769+
// FIXME: feels like the situations where these are emitted aren't suppose to be
770+
// treated as a consume at all. Leaving the message mostly as-is for now.
769771
ERROR(sil_moveonlychecker_moveonly_field_consumed, none,
770-
"'%0' has a move only field that was consumed before later uses", (StringRef))
772+
"'%0' has a noncopyable field that was consumed before later uses", (StringRef))
771773

772774
ERROR(sil_moveonlychecker_notconsumable_but_assignable_was_consumed_classfield_let, none,
773775
"'%0' was consumed but it is illegal to consume a noncopyable class let field. One can only read from it",
@@ -820,8 +822,12 @@ ERROR(sil_moveonlychecker_not_understand_consumable_and_assignable, none,
820822
ERROR(sil_moveonlychecker_not_understand_moveonly, none,
821823
"Usage of a move only type that the move checker does not know how to "
822824
"check!", ())
823-
ERROR(sil_moveonlychecker_missed_copy, none,
825+
826+
ERROR(sil_moveonlychecker_bug_missed_copy, none,
824827
"copy of noncopyable typed value. This is a compiler bug. Please file a bug with a small example of the bug", ())
828+
ERROR(sil_moveonlychecker_bug_exclusivity_violation, none,
829+
"'%0' has an unexpected exclusivity violation. This is a compiler bug. Please file a bug with a small example of the bug", (StringRef))
830+
825831

826832
// move kills copyable values checker diagnostics
827833
ERROR(sil_movekillscopyablevalue_value_consumed_more_than_once, none,

lib/SILOptimizer/Mandatory/MoveOnlyDiagnostics.cpp

Lines changed: 2 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ void DiagnosticEmitter::emitCheckerDoesntUnderstandDiagnostic(
187187

188188
void DiagnosticEmitter::emitCheckedMissedCopyError(SILInstruction *copyInst) {
189189
diagnose(copyInst->getFunction()->getASTContext(), copyInst,
190-
diag::sil_moveonlychecker_missed_copy);
190+
diag::sil_moveonlychecker_bug_missed_copy);
191191
}
192192

193193
//===----------------------------------------------------------------------===//
@@ -417,7 +417,7 @@ void DiagnosticEmitter::emitAddressExclusivityHazardDiagnostic(
417417
LLVM_DEBUG(llvm::dbgs() << " Consuming use: " << *consumingUser);
418418

419419
diagnose(astContext, markedValue,
420-
diag::sil_moveonlychecker_exclusivity_violation, varName);
420+
diag::sil_moveonlychecker_bug_exclusivity_violation, varName);
421421
diagnose(astContext, consumingUser,
422422
diag::sil_moveonlychecker_consuming_use_here);
423423
}
@@ -453,32 +453,6 @@ void DiagnosticEmitter::emitAddressDiagnostic(MarkMustCheckInst *markedValue,
453453
}
454454

455455
if (isInOutEndOfFunction) {
456-
if (auto *pbi = dyn_cast<ProjectBoxInst>(markedValue->getOperand())) {
457-
if (auto *fArg = dyn_cast<SILFunctionArgument>(pbi->getOperand())) {
458-
if (fArg->isClosureCapture()) {
459-
diagnose(
460-
astContext, markedValue,
461-
diag::
462-
sil_moveonlychecker_inout_not_reinitialized_before_end_of_closure,
463-
varName);
464-
diagnose(astContext, violatingUser,
465-
diag::sil_moveonlychecker_consuming_use_here);
466-
return;
467-
}
468-
}
469-
}
470-
if (auto *fArg = dyn_cast<SILFunctionArgument>(markedValue->getOperand())) {
471-
if (fArg->isClosureCapture()) {
472-
diagnose(
473-
astContext, markedValue,
474-
diag::
475-
sil_moveonlychecker_inout_not_reinitialized_before_end_of_closure,
476-
varName);
477-
diagnose(astContext, violatingUser,
478-
diag::sil_moveonlychecker_consuming_use_here);
479-
return;
480-
}
481-
}
482456
diagnose(
483457
astContext, markedValue,
484458
diag::
@@ -531,18 +505,6 @@ void DiagnosticEmitter::emitInOutEndOfFunctionDiagnostic(
531505

532506
// Otherwise, we need to do no implicit copy semantics. If our last use was
533507
// consuming message:
534-
if (auto *fArg = dyn_cast<SILFunctionArgument>(markedValue->getOperand())) {
535-
if (fArg->isClosureCapture()) {
536-
diagnose(
537-
astContext, markedValue,
538-
diag::
539-
sil_moveonlychecker_inout_not_reinitialized_before_end_of_closure,
540-
varName);
541-
diagnose(astContext, violatingUser,
542-
diag::sil_moveonlychecker_consuming_use_here);
543-
return;
544-
}
545-
}
546508
diagnose(
547509
astContext, markedValue,
548510
diag::sil_moveonlychecker_inout_not_reinitialized_before_end_of_function,

test/SILOptimizer/moveonly_addresschecker_diagnostics.sil

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -304,7 +304,7 @@ sil [ossa] @classSimpleChainArgTest : $@convention(thin) (@inout Klass) -> () {
304304
bb0(%0 : $*Klass):
305305
%1 = mark_must_check [consumable_and_assignable] %0 : $*Klass
306306
// expected-error @-1 {{'x2' consumed more than once}}
307-
// expected-error @-2 {{'x2' consumed but not reinitialized before end of function}}
307+
// expected-error @-2 {{missing reinitialization of 'x2' after consume}}
308308
debug_value %1 : $*Klass, var, name "x2", argno 1, expr op_deref
309309
%3 = alloc_stack [lexical] $Klass, var, name "y2"
310310
%4 = mark_must_check [consumable_and_assignable] %3 : $*Klass

0 commit comments

Comments
 (0)