Skip to content

Commit 67f9069

Browse files
author
Davide Italiano
committed
[SILGen] Create a new debug scope for top-level code.
<rdar://problem/46686369>
1 parent 1d10a6a commit 67f9069

File tree

6 files changed

+7
-5
lines changed

6 files changed

+7
-5
lines changed

lib/SILGen/SILGen.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1487,6 +1487,8 @@ void SILGenModule::visitTopLevelCodeDecl(TopLevelCodeDecl *td) {
14871487

14881488
TopLevelSGF->emitProfilerIncrement(td->getBody());
14891489

1490+
DebugScope DS(*TopLevelSGF, CleanupLocation(td));
1491+
14901492
for (auto &ESD : td->getBody()->getElements()) {
14911493
if (!TopLevelSGF->B.hasValidInsertionPoint()) {
14921494
if (auto *S = ESD.dyn_cast<Stmt*>()) {

test/DebugInfo/for.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ for i in 0 ..< 3 {
77
}
88

99
for i in 0 ..< 3 {
10-
// CHECK-DAG: ![[SCOPE2:[0-9]+]] = {{.*}}Block(scope: ![[MAIN]],{{.*}}line: [[@LINE-1]]
10+
// CHECK-DAG: ![[SCOPE2:[0-9]+]] = {{.*}}Block(scope: ![[MAIN2:[0-9]+]],{{.*}}line: [[@LINE-1]]
1111
// CHECK-DAG: !DILocalVariable(name: "i", scope: ![[SCOPE1]]
1212
// CHECK-DAG: !DILocalVariable(name: "i", scope: ![[SCOPE2]]
1313
}

test/DebugInfo/foreach.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
// Verify that variables bound in the foreach statements are in distinct scopes.
44
let values = [1, 2, 3]
55
// CHECK-DAG: ![[SCOPE1:[0-9]+]] ={{.*}}Block(scope: ![[MAIN:[0-9]+]],{{.*}}line: 7,
6-
// CHECK-DAG: ![[SCOPE2:[0-9]+]] ={{.*}}Block(scope: ![[MAIN]], {{.*}}line: 10,
6+
// CHECK-DAG: ![[SCOPE2:[0-9]+]] ={{.*}}Block(scope: ![[MAIN2:[0-9]+]], {{.*}}line: 10,
77
for val in values {
88
// CHECK-DAG: !DILocalVariable(name: "val", scope: ![[SCOPE1]]
99
}

test/DebugInfo/if.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,5 @@ if let val = yieldValue() {
99
}
1010
if let val = yieldValue() {
1111
// CHECK: !DILocalVariable(name: "val", scope: ![[SCOPE2:[0-9]+]]
12-
// CHECK: ![[SCOPE2]] = distinct !DILexicalBlock(scope: ![[MAIN]]
12+
// CHECK: ![[SCOPE2]] = distinct !DILexicalBlock(scope: ![[MAIN2:[0-9]+]]
1313
}

test/DebugInfo/transparent.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@ use(z)
2222
// CHECK-NEXT: !dbg ![[ZERO]]
2323
// CHECK-NEXT: }
2424

25+
// CHECK: ![[FILE:[0-9]+]] = {{.*}}"<compiler-generated>"
2526
// CHECK: ![[SP]] = {{.*}}name: "transparent"
2627
// CHECK-SAME: file: ![[FILE:[0-9]+]]
2728
// CHECK-NOT: line:
28-
// CHECK: ![[FILE]] = {{.*}}"<compiler-generated>"
2929
// CHECK: ![[ZERO]] = !DILocation(line: 0,

test/DebugInfo/while.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,5 @@ while let val = yieldValues() {
99
}
1010
while let val = yieldValues() {
1111
// CHECK: !DILocalVariable(name: "val", scope: ![[SCOPE2:[0-9]+]]
12-
// CHECK: ![[SCOPE2]] = distinct !DILexicalBlock(scope: ![[MAIN]]
12+
// CHECK: ![[SCOPE2]] = distinct !DILexicalBlock(scope: ![[MAIN2:[0-9]+]]
1313
}

0 commit comments

Comments
 (0)