Skip to content

Commit 1809fc8

Browse files
committed
AST: Map closure types out of context when mangling
1 parent b43c395 commit 1809fc8

File tree

5 files changed

+8
-7
lines changed

5 files changed

+8
-7
lines changed

lib/AST/Mangle.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1478,6 +1478,7 @@ void Mangler::mangleClosureComponents(Type Ty, unsigned discriminator,
14781478
if (!Ty)
14791479
Ty = ErrorType::get(localContext->getASTContext());
14801480

1481+
Ty = ArchetypeBuilder::mapTypeOutOfContext(parentContext, Ty);
14811482
mangleType(Ty->getCanonicalType(), /*uncurry*/ 0);
14821483
}
14831484

test/DebugInfo/generic_arg3.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ func apply<Type>(_ T : Type, fn: (Type) -> Type) -> Type { return fn(T) }
44

55
public func f<Type>(_ value : Type)
66
{
7-
// CHECK: define {{.*}}_TFF12generic_arg31furFxT_U_FQ_Q_
7+
// CHECK: define {{.*}}_TFF12generic_arg31furFxT_U_Fxx
88
// CHECK: store %swift.opaque* %1, %swift.opaque** %[[ALLOCA:.*]], align
99
// CHECK: call void @llvm.dbg.declare(metadata %swift.opaque** %[[ALLOCA]],
1010
// CHECK-SAME: metadata ![[ARG:.*]], metadata ![[EXPR:.*]])

test/DebugInfo/generic_arg5.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ public struct S<Type>
66

77
public func foo<Type>(_ values : [S<Type>])
88
{
9-
// CHECK: define {{.*}}_TFF12generic_arg53foourFGSaGVS_1Sx__T_U_FGS0_Q__GSqGS0_Q___
9+
// CHECK: define {{.*}}_TFF12generic_arg53foourFGSaGVS_1Sx__T_U_FGS0_x_GSqGS0_x__
1010
// CHECK: store %[[TY:.*]]* %1, %[[TY]]** %[[ALLOCA:.*]], align
1111
// CHECK: call void @llvm.dbg.declare(metadata %[[TY]]** %[[ALLOCA]],
1212
// CHECK-SAME: metadata ![[ARG:.*]], metadata ![[EXPR:.*]])

test/IRGen/mangle-anonclosure.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ class TestHeapStorage<T> : HeapStorage<CountAndCapacity,T> {
1212
deinit {
1313
withUnsafeMutablePointerToElements {
1414
// Don't crash when mangling this closure's name.
15-
// CHECK: _TFFC4main15TestHeapStoragedU_FGSpQ__T_
15+
// CHECK: _TFFC4main15TestHeapStoragedU_FGSpx_T_
1616
// ---> main.TestHeapStorage.deinit.(closure #1)
1717
(p: UnsafeMutablePointer<T>) -> () in
1818
}

test/SILGen/generic_closures.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -120,10 +120,10 @@ class NestedGeneric<U> {
120120
// Ensure that nested closures capture the generic parameters of their nested
121121
// context.
122122

123-
// CHECK: sil hidden @_TF16generic_closures25nested_closure_in_generic{{.*}} : $@convention(thin) <T> (@in T) -> @out T
124-
// CHECK: function_ref [[OUTER_CLOSURE:@_TFF16generic_closures25nested_closure_in_genericurFxxU_FT_Q_]]
123+
// CHECK: sil hidden @_TF16generic_closures25nested_closure_in_genericurFxx : $@convention(thin) <T> (@in T) -> @out T
124+
// CHECK: function_ref [[OUTER_CLOSURE:@_TFF16generic_closures25nested_closure_in_genericurFxxU_FT_x]]
125125
// CHECK: sil shared [[OUTER_CLOSURE]] : $@convention(thin) <T> (@inout_aliasable T) -> @out T
126-
// CHECK: function_ref [[INNER_CLOSURE:@_TFFF16generic_closures25nested_closure_in_genericurFxxU_FT_Q_U_FT_Q_]]
126+
// CHECK: function_ref [[INNER_CLOSURE:@_TFFF16generic_closures25nested_closure_in_genericurFxxU_FT_xU_FT_x]]
127127
// CHECK: sil shared [[INNER_CLOSURE]] : $@convention(thin) <T> (@inout_aliasable T) -> @out T {
128128
func nested_closure_in_generic<T>(_ x:T) -> T {
129129
return { { x }() }()
@@ -186,7 +186,7 @@ protocol HasClassAssoc { associatedtype Assoc : Class }
186186

187187
// CHECK-LABEL: sil hidden @_TF16generic_closures34captures_class_constrained_genericuRxS_13HasClassAssocrFTx1fFwx5AssocwxS1__T_
188188
// CHECK: bb0([[ARG1:%.*]] : $*T, [[ARG2:%.*]] : $@callee_owned (@owned T.Assoc) -> @owned T.Assoc):
189-
// CHECK: [[GENERIC_FN:%.*]] = function_ref @_TFF16generic_closures34captures_class_constrained_genericuRxS_13HasClassAssocrFTx1fFwx5AssocwxS1__T_U_FT_FQQ_5AssocS2_
189+
// CHECK: [[GENERIC_FN:%.*]] = function_ref @_TFF16generic_closures34captures_class_constrained_genericuRxS_13HasClassAssocrFTx1fFwx5AssocwxS1__T_U_FT_FwxS1_wxS1_
190190
// CHECK: [[ARG2_COPY:%.*]] = copy_value [[ARG2]]
191191
// CHECK: [[CONCRETE_FN:%.*]] = partial_apply [[GENERIC_FN]]<T>([[ARG2_COPY]])
192192

0 commit comments

Comments
 (0)