mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
Merge remote-tracking branch 'origin/main' into rebranch
This commit is contained in:
@@ -507,7 +507,7 @@ bool ConsumeOperatorCopyableValuesChecker::check() {
|
||||
}
|
||||
|
||||
//===----------------------------------------------------------------------===//
|
||||
// Unsupported Use Case Errors
|
||||
// MARK: Unsupported Use Case Errors
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
static void emitUnsupportedUseCaseError(MoveValueInst *mvi) {
|
||||
@@ -517,6 +517,25 @@ static void emitUnsupportedUseCaseError(MoveValueInst *mvi) {
|
||||
mvi->setAllowsDiagnostics(false);
|
||||
}
|
||||
|
||||
/// Try to pattern match if we were trying to move a global. In such a case,
|
||||
/// emit a better error.
|
||||
static bool tryEmitCannotConsumeNonLocalMemoryError(MoveValueInst *mvi) {
|
||||
auto *li = dyn_cast<LoadInst>(mvi->getOperand());
|
||||
if (!li)
|
||||
return false;
|
||||
|
||||
auto &astContext = mvi->getModule().getASTContext();
|
||||
if (auto *gai =
|
||||
dyn_cast<GlobalAddrInst>(stripAccessMarkers(li->getOperand()))) {
|
||||
auto diag = diag::sil_movekillscopyable_move_applied_to_nonlocal_memory;
|
||||
diagnose(astContext, mvi->getLoc().getSourceLoc(), diag, 0);
|
||||
mvi->setAllowsDiagnostics(false);
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
//===----------------------------------------------------------------------===//
|
||||
// Top Level Entrypoint
|
||||
//===----------------------------------------------------------------------===//
|
||||
@@ -579,6 +598,10 @@ class ConsumeOperatorCopyableValuesCheckerPass : public SILFunctionTransform {
|
||||
continue;
|
||||
}
|
||||
|
||||
// Try to emit a better error if we try to consume a global.
|
||||
if (tryEmitCannotConsumeNonLocalMemoryError(mvi))
|
||||
continue;
|
||||
|
||||
if (!DisableUnhandledMoveDiagnostic)
|
||||
emitUnsupportedUseCaseError(mvi);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user