@@ -363,17 +363,7 @@ bool MoveKillsCopyableValuesChecker::check() {
363363
364364 // Before we do anything, see if we can find a name for our value. We do
365365 // this early since we need this for all of our diagnostics below.
366- StringRef varName = " unknown" ;
367- if (auto *use = getSingleDebugUse (lexicalValue)) {
368- DebugVarCarryingInst debugVar (use->getUser ());
369- if (auto varInfo = debugVar.getVarInfo ()) {
370- varName = varInfo->Name ;
371- } else {
372- if (auto *decl = debugVar.getDecl ()) {
373- varName = decl->getBaseName ().userFacingName ();
374- }
375- }
376- }
366+ StringRef varName = getDebugVarName (lexicalValue);
377367
378368 // Then compute liveness.
379369 SWIFT_DEFER { livenessInfo.clear (); };
@@ -419,6 +409,18 @@ bool MoveKillsCopyableValuesChecker::check() {
419409 return false ;
420410}
421411
412+ // ===----------------------------------------------------------------------===//
413+ // Unsupported Use Case Errors
414+ // ===----------------------------------------------------------------------===//
415+
416+ static void emitUnsupportedUseCaseError (MoveValueInst *mvi) {
417+ auto &astContext = mvi->getModule ().getASTContext ();
418+ auto diag = diag::
419+ sil_movekillscopyablevalue_move_applied_to_unsupported_move;
420+ diagnose (astContext, mvi->getLoc ().getSourceLoc (), diag);
421+ mvi->setAllowsDiagnostics (false );
422+ }
423+
422424// ===----------------------------------------------------------------------===//
423425// Top Level Entrypoint
424426// ===----------------------------------------------------------------------===//
@@ -455,10 +457,7 @@ class MoveKillsCopyableValuesCheckerPass : public SILFunctionTransform {
455457 for (auto &inst : block) {
456458 if (auto *mvi = dyn_cast<MoveValueInst>(&inst)) {
457459 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 );
460+ emitUnsupportedUseCaseError (mvi);
462461 }
463462 }
464463 }
0 commit comments