mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
The previous code made the assumption that the ASTScope for a variable declaration should be the one of the declaration's source location. That is not necessarily the case, in some cases it should be an ancestor scope. This patch introduces a map from ValueDecl -> ASTScope that is derived from querying each ASTScope for its locals, which matches also what happens in name lookup. This patch also fixes the nesting of SILDebugScopes created for guard statement bodies, which are incorrectly nested in the ASTScope hierarchy. rdar://108940570
23 lines
1.0 KiB
Swift
23 lines
1.0 KiB
Swift
// RUN: %target-swift-frontend %s -parse-as-library -emit-ir -g -o - \
|
|
// RUN: -module-name main | %FileCheck %s
|
|
// RUN: %target-swift-frontend %s -parse-as-library -emit-sil \
|
|
// RUN: -Xllvm -sil-print-debuginfo -o - \
|
|
// RUN: -module-name main | %FileCheck %s --check-prefix=SIL
|
|
|
|
// The variable i and the argument i must be in different scopes or the debugger
|
|
// doesn't know which one shadows the other.
|
|
public func f(i: Int) {
|
|
let i = [i, i]
|
|
print(i)
|
|
}
|
|
|
|
// CHECK: ![[S1:[0-9]+]] = distinct !DISubprogram(name: "f",
|
|
// CHECK: !DILocalVariable(name: "i", arg: 1, scope: ![[S1]],
|
|
// CHECK: !DILocalVariable(name: "i", scope: ![[S3:[0-9]+]],
|
|
// CHECK: ![[S3]] = distinct !DILexicalBlock(scope: ![[S1]],
|
|
// SIL: sil_scope [[S1:[0-9]+]] { {{.*}} parent @$s4main1f1iySi_tF
|
|
// SIL: sil_scope [[S2:[0-9]+]] { {{.*}} parent [[S1]] }
|
|
// SIL: sil_scope [[S3:[0-9]+]] { {{.*}} parent [[S1]] }
|
|
// SIL: debug_value %0 : $Int, let, name "i", argno 1,{{.*}}, scope [[S1]]
|
|
// SIL: debug_value {{.*}} : $Array<Int>, let, name "i", {{.*}}, scope [[S3]]
|