Skip to content

Commit a10a5db

Browse files
committed
[move-only] Ensure that resilient deinits take their self argument as an address argument instead of an object.
The signature was already correct, just the logic in the deinit code assumed that we would always have an object. rdar://109170069 (cherry picked from commit 12e1db4)
1 parent f634acf commit a10a5db

File tree

3 files changed

+42
-1
lines changed

3 files changed

+42
-1
lines changed

lib/SILGen/SILGenProlog.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,12 @@ static void diagnose(ASTContext &Context, SourceLoc loc, Diag<T...> diag,
3939
}
4040

4141
SILValue SILGenFunction::emitSelfDeclForDestructor(VarDecl *selfDecl) {
42+
SILFunctionConventions conventions = F.getConventionsInContext();
43+
4244
// Emit the implicit 'self' argument.
43-
SILType selfType = getLoweredType(selfDecl->getType());
45+
SILType selfType = conventions.getSILArgumentType(
46+
conventions.getNumSILArguments() - 1, F.getTypeExpansionContext());
47+
selfType = F.mapTypeIntoContext(selfType);
4448
SILValue selfValue = F.begin()->createFunctionArgument(selfType, selfDecl);
4549

4650
// If we have a move only type, then mark it with mark_must_check so we can't
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
// RUN: %target-swift-emit-silgen -enable-experimental-feature NoImplicitCopy -enable-library-evolution %s | %FileCheck %s
2+
3+
//////////////////////
4+
// MARK: DeinitTest //
5+
//////////////////////
6+
7+
// CHECK-LABEL: sil [ossa] @$s26moveonly_library_evolution10DeinitTestVfD : $@convention(method) (@in DeinitTest) -> () {
8+
// CHECK: bb0([[ARG:%.*]] : $*DeinitTest):
9+
// CHECK: drop_deinit [[ARG]]
10+
// CHECK: } // end sil function '$s26moveonly_library_evolution10DeinitTestVfD'
11+
public struct DeinitTest : ~Copyable {
12+
deinit {
13+
}
14+
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
// RUN: %target-swift-emit-sil -sil-verify-all -verify -enable-library-evolution %s
2+
3+
// This test is used to validate that we properly handle library evolution code
4+
// until we can get all of the normal moveonly_addresschecker_diagnostics test
5+
// case to pass.
6+
7+
////////////////////////
8+
// MARK: Deinit Tests //
9+
////////////////////////
10+
11+
public struct DeinitTest : ~Copyable {
12+
deinit {}
13+
}
14+
15+
public protocol P {}
16+
17+
// Once rdar://109170600 is fixed (which tracks us being unable to do this), we
18+
// should be able to use the : ~Copyable syntax.
19+
@_moveOnly
20+
public struct GenericDeinitTest<T : P> {
21+
deinit {}
22+
}
23+

0 commit comments

Comments
 (0)