Skip to content

Commit e818b25

Browse files
committed
[mv-func-addr-check] Refactor unsupported move diagnostics into helper function.
I want to over time expand this and improve QoI by adding better error messages by using pattern matching here. So it makes sense just to take care of the refactoring now before making further changes.
1 parent 0e5a620 commit e818b25

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

lib/SILOptimizer/Mandatory/MoveKillsCopyableValuesChecker.cpp

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -419,6 +419,18 @@ bool MoveKillsCopyableValuesChecker::check() {
419419
return false;
420420
}
421421

422+
//===----------------------------------------------------------------------===//
423+
// Unsupported Use Case Errors
424+
//===----------------------------------------------------------------------===//
425+
426+
static void emitUnsupportedUseCaseError(MoveValueInst *mvi) {
427+
auto &astContext = mvi->getModule().getASTContext();
428+
auto diag = diag::
429+
sil_movekillscopyablevalue_move_applied_to_unsupported_move;
430+
diagnose(astContext, mvi->getLoc().getSourceLoc(), diag);
431+
mvi->setAllowsDiagnostics(false);
432+
}
433+
422434
//===----------------------------------------------------------------------===//
423435
// Top Level Entrypoint
424436
//===----------------------------------------------------------------------===//
@@ -455,10 +467,7 @@ class MoveKillsCopyableValuesCheckerPass : public SILFunctionTransform {
455467
for (auto &inst : block) {
456468
if (auto *mvi = dyn_cast<MoveValueInst>(&inst)) {
457469
if (mvi->getAllowDiagnostics()) {
458-
auto diag = diag::
459-
sil_movekillscopyablevalue_move_applied_to_unsupported_move;
460-
diagnose(astContext, mvi->getLoc().getSourceLoc(), diag);
461-
mvi->setAllowsDiagnostics(false);
470+
emitUnsupportedUseCaseError(mvi);
462471
}
463472
}
464473
}

0 commit comments

Comments
 (0)