Skip to content

Commit 3a97766

Browse files
committed
Avoid emitting variable debug info for closure captures.
Variable debug info is triggered by pattern bindings, however, inside a closure capture list, this should be avoided by setting the appropriate flag in the initializer object. rdar://110329894
1 parent c4b6710 commit 3a97766

File tree

3 files changed

+31
-3
lines changed

3 files changed

+31
-3
lines changed

lib/SILGen/RValue.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -547,7 +547,7 @@ SILValue RValue::forwardAsSingleStorageValue(SILGenFunction &SGF,
547547
return SGF.emitConversionFromSemanticValue(l, result, storageType);
548548
}
549549

550-
void RValue::forwardInto(SILGenFunction &SGF, SILLocation loc,
550+
void RValue::forwardInto(SILGenFunction &SGF, SILLocation loc,
551551
Initialization *I) && {
552552
assert(isComplete() && "rvalue is not complete");
553553
assert(isPlusOneOrTrivial(SGF) && "Can not forward borrowed RValues");

lib/SILGen/SILGenDecl.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1789,8 +1789,10 @@ void SILGenFunction::emitStmtCondition(StmtCondition Cond, JumpDest FalseDest,
17891789

17901790
InitializationPtr SILGenFunction::emitPatternBindingInitialization(
17911791
Pattern *P, JumpDest failureDest, bool generateDebugInfo) {
1792-
return InitializationForPattern(*this, failureDest, generateDebugInfo)
1793-
.visit(P);
1792+
auto init =
1793+
InitializationForPattern(*this, failureDest, generateDebugInfo).visit(P);
1794+
init->setEmitDebugValueOnInit(generateDebugInfo);
1795+
return init;
17941796
}
17951797

17961798
/// Enter a cleanup to deallocate the given location.

test/DebugInfo/captures.swift

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
// RUN: %target-swift-frontend %s -parse-as-library -module-name a -emit-sil -g -o - | %FileCheck %s
2+
struct S {}
3+
public class UIView {}
4+
public protocol View {}
5+
public final class Signal<Value> {
6+
public func map<U>(_ transform: @escaping (Value) -> U) -> Signal<U> {
7+
return Signal<U>()
8+
}
9+
}
10+
public final class C<V: View, V1: View>: UIView {
11+
private let t1: C<V, V1>? = nil
12+
private let t2: C<V1, V>? = nil
13+
func foo() -> Signal<(S, UIView)> {
14+
// CHECK: sil {{.*}}s1a1CC3foo
15+
// CHECK: debug_value {{.*}} name "self"
16+
// CHECK-NOT: debug_value {{.*}} name "view"
17+
// CHECK: return %
18+
return (
19+
Signal<S>()
20+
.map { [view = t1!] in ($0, view) },
21+
Signal<S>()
22+
.map { [view = t2!] in ($0, view) }
23+
).0
24+
}
25+
}
26+

0 commit comments

Comments
 (0)