Skip to content

Commit 1e9f987

Browse files
committed
Remove a stateful workaround for ResultBuilders.
In an earlier version of the ASTScope -> SILdebugScope translation a wrokaround was put into place that would select the current debug scope if an ASTScope was marked as ignoreInDebugInfo. Removing this workaround makes the translation more predictable as it eliminated the dependency on the current SILBuilder state. The result builder tests still pass without this. rdar://108736443
1 parent 3901219 commit 1e9f987

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

lib/SILGen/SILGenFunction.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -383,6 +383,7 @@ SILGenFunction::getOrCreateScope(const ast_scope::ASTScopeImpl *ASTScope,
383383
// argument b is in the scope of v, but the call to Constructor
384384
// isn't, which correctly triggers the scope hole verifier.
385385
auto *CurScope = B.getCurrentDebugScope();
386+
CurScope = getOrCreateScope(ASTScope->getParent().getPtrOrNull(), FnScope, InlinedAt);
386387
return CurScope->InlinedCallSite != InlinedAt ? FnScope : CurScope;
387388
}
388389

test/DebugInfo/guard-let-scope3.swift

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
// RUN: %target-swift-frontend -g -emit-sil %s -parse-as-library -module-name a | %FileCheck %s
2+
public class C {}
3+
public enum MyError : Error {
4+
init() { self.init() }
5+
}
6+
public class S {
7+
private var c = [Int : C?]()
8+
public func f(_ i: Int) throws -> C {
9+
guard let x = c[i], let x else {
10+
// CHECK: sil_scope [[X1:[0-9]+]] { loc "{{.*}}":[[@LINE-1]]:5
11+
// CHECK: sil_scope [[X2:[0-9]+]] { loc "{{.*}}":[[@LINE-2]]:29
12+
// CHECK: debug_value {{.*}} : $Optional<C>, let, name "x", {{.*}}, scope [[X1]]
13+
// CHECK: debug_value %29 : $C, let, name "x", {{.*}}, scope [[X2]]
14+
// CHECK-NEXT: scope [[X2]]
15+
throw MyError()
16+
}
17+
return x
18+
}
19+
}

0 commit comments

Comments
 (0)