Emit updated debug info when inout parameters are consumed and reinitialized.

Change SILGen to emit the `debug_value` instruction using the original inout
parameter address, instead of the `mark_must_check` inserted for move-only
parameters, because code in the MoveOnlyAddressChecker did not expect to
find the debug_value anywhere but on the original address. Update move-only
diagnostics so that they pick up the declaration name for a memory location
from any debug_value instruction if there are more than one. rdar://109740281
This commit is contained in:
Joe Groff
2023-05-23 15:06:29 -07:00
parent 90fd254d74
commit 9db359985d
5 changed files with 62 additions and 16 deletions

View File

@@ -77,7 +77,7 @@ static void getVariableNameForValue(SILValue value2,
SmallString<64> &resultingString) {
// Before we do anything, lets see if we have an exact debug_value on our
// mmci. In such a case, we can end early and are done.
if (auto *use = getSingleDebugUse(value2)) {
if (auto *use = getAnyDebugUse(value2)) {
if (auto debugVar = DebugVarCarryingInst(use->getUser())) {
assert(debugVar.getKind() == DebugVarCarryingInst::Kind::DebugValue);
resultingString += debugVar.getName();
@@ -112,7 +112,7 @@ static void getVariableNameForValue(SILValue value2,
// If we do not do an exact match, see if we can find a debug_var inst. If
// we do, we always break since we have a root value.
if (auto *use = getSingleDebugUse(searchValue)) {
if (auto *use = getAnyDebugUse(searchValue)) {
if (auto debugVar = DebugVarCarryingInst(use->getUser())) {
assert(debugVar.getKind() == DebugVarCarryingInst::Kind::DebugValue);
variableNamePath.push_back(use->getUser());