[move-only] Combine the address/object checker in the same pass so that we only run cleanups once.

Otherwise, sometimes when the object checker emits a diagnostic and cleans up
the IR, some of the cleaned up copies are copies that should have been handled
by the address checker. The end result is that the address checker does not emit
diagnostics for that IR. I found this problem was exascerbated when writing code
for escaping closures.

This commit also cleans up the passes in preparation for at a future time moving
some of the transformations into the utils folder.
This commit is contained in:
Michael Gottesman
2023-02-18 13:59:58 -08:00
parent ecb864c159
commit 6c922af8aa
17 changed files with 887 additions and 459 deletions

View File

@@ -196,6 +196,8 @@ void DiagnosticEmitter::emitObjectGuaranteedDiagnostic(
if (!getCanonicalizer().hasNonPartialApplyConsumingUse())
return;
registerDiagnosticEmitted(markedValue);
// Check if this value is closure captured. In such a case, emit a special
// error.
if (auto *fArg = dyn_cast<SILFunctionArgument>(
@@ -215,11 +217,12 @@ void DiagnosticEmitter::emitObjectGuaranteedDiagnostic(
diag::sil_moveonlychecker_guaranteed_value_consumed, varName);
emitObjectDiagnosticsForGuaranteedUses(true /*ignore partial apply uses*/);
registerDiagnosticEmitted(markedValue);
}
void DiagnosticEmitter::emitObjectOwnedDiagnostic(
MarkMustCheckInst *markedValue) {
registerDiagnosticEmitted(markedValue);
auto &astContext = fn->getASTContext();
SmallString<64> varName;
getVariableNameForValue(markedValue, varName);
@@ -339,8 +342,6 @@ void DiagnosticEmitter::emitObjectOwnedDiagnostic(
}
}
}
registerDiagnosticEmitted(markedValue);
}
void DiagnosticEmitter::emitObjectDiagnosticsForGuaranteedUses(