mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
Fix handling of implicit locations for variables
This commit is contained in:
@@ -176,7 +176,7 @@ SILGenFunction::getSILDebugLocation(SILBuilder &B, SILLocation Loc,
|
|||||||
const SILDebugScope *Scope = B.getCurrentDebugScope();
|
const SILDebugScope *Scope = B.getCurrentDebugScope();
|
||||||
if (!Scope)
|
if (!Scope)
|
||||||
Scope = F.getDebugScope();
|
Scope = F.getDebugScope();
|
||||||
if (auto *SILScope = getScopeOrNull(Loc)) {
|
if (auto *SILScope = getScopeOrNull(Loc, ForMetaInstruction)) {
|
||||||
Scope = SILScope;
|
Scope = SILScope;
|
||||||
// Metainstructions such as a debug_value may break the flow of scopes and
|
// Metainstructions such as a debug_value may break the flow of scopes and
|
||||||
// should not change the state of the builder.
|
// should not change the state of the builder.
|
||||||
@@ -187,14 +187,16 @@ SILGenFunction::getSILDebugLocation(SILBuilder &B, SILLocation Loc,
|
|||||||
return SILDebugLocation(overriddenLoc, Scope);
|
return SILDebugLocation(overriddenLoc, Scope);
|
||||||
}
|
}
|
||||||
|
|
||||||
const SILDebugScope *SILGenFunction::getScopeOrNull(SILLocation Loc) {
|
const SILDebugScope *SILGenFunction::getScopeOrNull(SILLocation Loc,
|
||||||
if (Loc.getKind() == SILLocation::CleanupKind ||
|
bool ForMetaInstruction) {
|
||||||
Loc.getKind() == SILLocation::ImplicitReturnKind ||
|
if (!ForMetaInstruction) {
|
||||||
// The source locations produced by the ResultBuilder transformation are
|
if (Loc.getKind() == SILLocation::CleanupKind ||
|
||||||
// all over the place.
|
Loc.getKind() == SILLocation::ImplicitReturnKind ||
|
||||||
Loc.isImplicit() ||
|
// The source locations produced by the ResultBuilder transformation are
|
||||||
Loc.isAutoGenerated())
|
// all over the place.
|
||||||
return nullptr;
|
Loc.isImplicit() || Loc.isAutoGenerated())
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
SourceLoc SLoc = Loc.getSourceLoc();//ForDebugging();
|
SourceLoc SLoc = Loc.getSourceLoc();//ForDebugging();
|
||||||
if (!SF || LastSourceLoc == SLoc)
|
if (!SF || LastSourceLoc == SLoc)
|
||||||
|
|||||||
@@ -713,7 +713,8 @@ public:
|
|||||||
Optional<SILLocation> CurDebugLocOverride,
|
Optional<SILLocation> CurDebugLocOverride,
|
||||||
bool ForMetaInstruction);
|
bool ForMetaInstruction);
|
||||||
|
|
||||||
const SILDebugScope *getScopeOrNull(SILLocation Loc);
|
const SILDebugScope *getScopeOrNull(SILLocation Loc,
|
||||||
|
bool ForMetaInstruction = false);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
const SILDebugScope *getOrCreateScope(SourceLoc SLoc);
|
const SILDebugScope *getOrCreateScope(SourceLoc SLoc);
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
// RUN: %target-swift-frontend -module-name a -parse-as-library -emit-sil -g %s | %FileCheck %s
|
// RUN: %target-swift-frontend -module-name a -parse-as-library -emit-sil -g %s | %FileCheck %s
|
||||||
|
|
||||||
|
|
||||||
public enum E<T> {
|
public enum E<T> {
|
||||||
case A(T)
|
case A(T)
|
||||||
case B(T)
|
case B(T)
|
||||||
@@ -13,15 +12,15 @@ func sink<T>(_ t: T) {}
|
|||||||
public func f<T>(_ e: E<T>) -> [T] {
|
public func f<T>(_ e: E<T>) -> [T] {
|
||||||
switch e {
|
switch e {
|
||||||
case .A(let a), .B(let a): return [a]
|
case .A(let a), .B(let a): return [a]
|
||||||
case .D(let a, _, let c): return [a, c]
|
case .D(let a, _, let c): return [a, c]
|
||||||
default:
|
default: return []
|
||||||
return []
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// CHECK: sil_scope [[F:[0-9]+]] { loc "{{.*}}":13:13 parent @$s1a1fySayxGAA1EOyxGlF
|
|
||||||
// CHECK: sil_scope [[S0:[0-9]+]] { loc "{{.*}}":14:3 parent [[F]] }
|
// CHECK: sil_scope [[F:[0-9]+]] { loc "{{.*}}":12:13 parent @$s1a1fySayxGAA1EOyxGlF
|
||||||
// CHECK: sil_scope [[A0:[0-9]+]] { loc "{{.*}}":15:3 parent [[S0]] }
|
// CHECK: sil_scope [[S0:[0-9]+]] { loc "{{.*}}":13:3 parent [[F]] }
|
||||||
// CHECK: sil_scope [[A1:[0-9]+]] { loc "{{.*}}":16:3 parent [[S0]] }
|
// CHECK: sil_scope [[A0:[0-9]+]] { loc "{{.*}}":14:3 parent [[S0]] }
|
||||||
// CHECK: alloc_stack {{.*}} $T, let, name "a", {{.*}}:15:15, scope [[A0]]
|
// CHECK: sil_scope [[A1:[0-9]+]] { loc "{{.*}}":15:3 parent [[S0]] }
|
||||||
// CHECK: alloc_stack {{.*}} $T, let, name "a", {{.*}}:15:26, scope [[A0]]
|
// CHECK: alloc_stack {{.*}} $T, let, name "a", {{.*}}:14:15, scope [[A0]]
|
||||||
// CHECK: alloc_stack {{.*}} $T, let, name "a", {{.*}}:16:15, scope [[A1]]
|
// CHECK: alloc_stack {{.*}} $T, let, name "a", {{.*}}:14:26, scope [[A0]]
|
||||||
|
// CHECK: alloc_stack {{.*}} $T, let, name "a", {{.*}}:15:15, scope [[A1]]
|
||||||
|
|||||||
18
test/DebugInfo/case-scope2.swift
Normal file
18
test/DebugInfo/case-scope2.swift
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
// RUN: %target-swift-frontend -module-name a -parse-as-library -emit-sil -g %s | %FileCheck %s
|
||||||
|
func consume<T>(_ t: T) {}
|
||||||
|
|
||||||
|
// CHECK: sil_scope [[F:[0-9]+]] { loc "{{.*}}":9:13 parent @$s1a1fyyShySiGSg_ADtF
|
||||||
|
// CHECK: sil_scope [[S0:[0-9]+]] { loc "{{.*}}":10:3 parent [[F]] }
|
||||||
|
// CHECK: sil_scope [[S1:[0-9]+]] { loc "{{.*}}":11:3 parent [[S0]] }
|
||||||
|
// CHECK: sil_scope [[S2:[0-9]+]] { loc "{{.*}}":13:5 parent [[S1]] }
|
||||||
|
// CHECK: sil_scope [[S3:[0-9]+]] { loc "{{.*}}":14:3 parent [[S0]] }
|
||||||
|
public func f(_ s1: Set<Int>?, _ s2: Set<Int>?) {
|
||||||
|
switch (s1, s2) {
|
||||||
|
case (nil, let a), (let a, nil):
|
||||||
|
// CHECK: debug_value {{.*}} $Optional<Set<Int>>, let, name "a", {{.*}}:[[@LINE-1]]:18, scope [[S1]]
|
||||||
|
consume(a)
|
||||||
|
case (let a?, _):
|
||||||
|
// CHECK: debug_value {{.*}} $Set<Int>, let, name "a", {{.*}}:[[@LINE-1]]:13, scope [[S3]]
|
||||||
|
consume((a))
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user