Fix handling of implicit locations for variables

This commit is contained in:
Adrian Prantl
2023-04-10 17:44:44 -07:00
parent c877a4a802
commit bccc080888
4 changed files with 41 additions and 21 deletions

View File

@@ -176,7 +176,7 @@ SILGenFunction::getSILDebugLocation(SILBuilder &B, SILLocation Loc,
const SILDebugScope *Scope = B.getCurrentDebugScope();
if (!Scope)
Scope = F.getDebugScope();
if (auto *SILScope = getScopeOrNull(Loc)) {
if (auto *SILScope = getScopeOrNull(Loc, ForMetaInstruction)) {
Scope = SILScope;
// Metainstructions such as a debug_value may break the flow of scopes and
// should not change the state of the builder.
@@ -187,14 +187,16 @@ SILGenFunction::getSILDebugLocation(SILBuilder &B, SILLocation Loc,
return SILDebugLocation(overriddenLoc, Scope);
}
const SILDebugScope *SILGenFunction::getScopeOrNull(SILLocation Loc) {
if (Loc.getKind() == SILLocation::CleanupKind ||
Loc.getKind() == SILLocation::ImplicitReturnKind ||
// The source locations produced by the ResultBuilder transformation are
// all over the place.
Loc.isImplicit() ||
Loc.isAutoGenerated())
return nullptr;
const SILDebugScope *SILGenFunction::getScopeOrNull(SILLocation Loc,
bool ForMetaInstruction) {
if (!ForMetaInstruction) {
if (Loc.getKind() == SILLocation::CleanupKind ||
Loc.getKind() == SILLocation::ImplicitReturnKind ||
// The source locations produced by the ResultBuilder transformation are
// all over the place.
Loc.isImplicit() || Loc.isAutoGenerated())
return nullptr;
}
SourceLoc SLoc = Loc.getSourceLoc();//ForDebugging();
if (!SF || LastSourceLoc == SLoc)