@@ -363,17 +363,7 @@ bool MoveKillsCopyableValuesChecker::check() {
363
363
364
364
// Before we do anything, see if we can find a name for our value. We do
365
365
// 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);
377
367
378
368
// Then compute liveness.
379
369
SWIFT_DEFER { livenessInfo.clear (); };
@@ -419,6 +409,18 @@ bool MoveKillsCopyableValuesChecker::check() {
419
409
return false ;
420
410
}
421
411
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
+
422
424
// ===----------------------------------------------------------------------===//
423
425
// Top Level Entrypoint
424
426
// ===----------------------------------------------------------------------===//
@@ -455,10 +457,7 @@ class MoveKillsCopyableValuesCheckerPass : public SILFunctionTransform {
455
457
for (auto &inst : block) {
456
458
if (auto *mvi = dyn_cast<MoveValueInst>(&inst)) {
457
459
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);
462
461
}
463
462
}
464
463
}
0 commit comments