@@ -221,19 +221,20 @@ void SILGenFunction::destroyClassMember(SILLocation cleanupLoc,
221
221
}
222
222
}
223
223
224
- // Finds stored properties that have the same type as `cd` and thus form
225
- // a recursive structure.
226
- //
227
- // Example:
228
- //
229
- // class Node<T> {
230
- // let element: T
231
- // let next: Node<T>?
232
- // }
233
- //
234
- // In the above example `next` is a recursive link and would be recognized
235
- // by this function and added to the result set.
236
- void findRecursiveLinks (ClassDecl *cd, llvm::SmallSetVector<VarDecl*, 4 > &result) {
224
+ // / Finds stored properties that have the same type as `cd` and thus form
225
+ // / a recursive structure.
226
+ // /
227
+ // / Example:
228
+ // /
229
+ // / class Node<T> {
230
+ // / let element: T
231
+ // / let next: Node<T>?
232
+ // / }
233
+ // /
234
+ // / In the above example `next` is a recursive link and would be recognized
235
+ // / by this function and added to the result set.
236
+ static void findRecursiveLinks (ClassDecl *cd,
237
+ llvm::SmallSetVector<VarDecl *, 4 > &result) {
237
238
auto selfTy = cd->getDeclaredInterfaceType ();
238
239
239
240
// Collect all stored properties that would form a recursive structure,
@@ -309,11 +310,6 @@ void SILGenFunction::emitRecursiveChainDestruction(ManagedValue selfValue,
309
310
{
310
311
B.emitBlock (uniqueBB);
311
312
312
- // NOTE: We increment the ref count of the tail instead of unlinking it,
313
- // because custom deinit implementations of subclasses may access
314
- // it and it would be semantically wrong to unset it before that.
315
- // Making the tail non-uniquely referenced prevents the recursion.
316
-
317
313
// let tail = iter.unsafelyUnwrapped.next
318
314
// iter = tail
319
315
SILValue iterBorrow = B.createLoadBorrow (cleanupLoc, iterAddr);
@@ -373,10 +369,10 @@ void SILGenFunction::emitClassMemberDestruction(ManagedValue selfValue,
373
369
// / For other cases, the basic blocks are not necessary and the destructor
374
370
// / can just emit all the normal destruction code right into the current block.
375
371
// If set, used as the basic block for the destroying of all members.
376
- SILBasicBlock* normalMemberDestroyBB = nullptr ;
372
+ SILBasicBlock * normalMemberDestroyBB = nullptr ;
377
373
// If set, used as the basic block after members have been destroyed,
378
374
// and we're ready to perform final cleanups before returning.
379
- SILBasicBlock* finishBB = nullptr ;
375
+ SILBasicBlock * finishBB = nullptr ;
380
376
381
377
// / A distributed actor may be 'remote' in which case there is no need to
382
378
// / destroy "all" members, because they never had storage to begin with.
@@ -393,7 +389,8 @@ void SILGenFunction::emitClassMemberDestruction(ManagedValue selfValue,
393
389
// recursively the same type as `self`, so we can iteratively
394
390
// deinitialize them, to prevent deep recursion and potential
395
391
// stack overflows.
396
- llvm::SmallSetVector<VarDecl*, 4 > recursiveLinks;
392
+
393
+ llvm::SmallSetVector<VarDecl *, 4 > recursiveLinks;
397
394
findRecursiveLinks (cd, recursiveLinks);
398
395
399
396
// / Destroy all members.
0 commit comments