Skip to content

Avoid emitting variable debug info for closure captures. … @adrian-prantl #66479

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/SILGen/RValue.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -547,7 +547,7 @@ SILValue RValue::forwardAsSingleStorageValue(SILGenFunction &SGF,
return SGF.emitConversionFromSemanticValue(l, result, storageType);
}

void RValue::forwardInto(SILGenFunction &SGF, SILLocation loc,
void RValue::forwardInto(SILGenFunction &SGF, SILLocation loc,
Initialization *I) && {
assert(isComplete() && "rvalue is not complete");
assert(isPlusOneOrTrivial(SGF) && "Can not forward borrowed RValues");
Expand Down
6 changes: 4 additions & 2 deletions lib/SILGen/SILGenDecl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1789,8 +1789,10 @@ void SILGenFunction::emitStmtCondition(StmtCondition Cond, JumpDest FalseDest,

InitializationPtr SILGenFunction::emitPatternBindingInitialization(
Pattern *P, JumpDest failureDest, bool generateDebugInfo) {
return InitializationForPattern(*this, failureDest, generateDebugInfo)
.visit(P);
auto init =
InitializationForPattern(*this, failureDest, generateDebugInfo).visit(P);
init->setEmitDebugValueOnInit(generateDebugInfo);
return init;
}

/// Enter a cleanup to deallocate the given location.
Expand Down
26 changes: 26 additions & 0 deletions test/DebugInfo/captures.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
// RUN: %target-swift-frontend %s -parse-as-library -module-name a -emit-sil -g -o - | %FileCheck %s
struct S {}
public class UIView {}
public protocol View {}
public final class Signal<Value> {
public func map<U>(_ transform: @escaping (Value) -> U) -> Signal<U> {
return Signal<U>()
}
}
public final class C<V: View, V1: View>: UIView {
private let t1: C<V, V1>? = nil
private let t2: C<V1, V>? = nil
func foo() -> Signal<(S, UIView)> {
// CHECK: sil {{.*}}s1a1CC3foo
// CHECK: debug_value {{.*}} name "self"
// CHECK-NOT: debug_value {{.*}} name "view"
// CHECK: return %
return (
Signal<S>()
.map { [view = t1!] in ($0, view) },
Signal<S>()
.map { [view = t2!] in ($0, view) }
).0
}
}