Skip to content

Commit ba0de89

Browse files
committed
Addressed more review feedback
1 parent 06aa334 commit ba0de89

File tree

2 files changed

+19
-22
lines changed

2 files changed

+19
-22
lines changed

lib/SILGen/SILGenDestructor.cpp

Lines changed: 18 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -221,19 +221,20 @@ void SILGenFunction::destroyClassMember(SILLocation cleanupLoc,
221221
}
222222
}
223223

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) {
237238
auto selfTy = cd->getDeclaredInterfaceType();
238239

239240
// Collect all stored properties that would form a recursive structure,
@@ -309,11 +310,6 @@ void SILGenFunction::emitRecursiveChainDestruction(ManagedValue selfValue,
309310
{
310311
B.emitBlock(uniqueBB);
311312

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-
317313
// let tail = iter.unsafelyUnwrapped.next
318314
// iter = tail
319315
SILValue iterBorrow = B.createLoadBorrow(cleanupLoc, iterAddr);
@@ -373,10 +369,10 @@ void SILGenFunction::emitClassMemberDestruction(ManagedValue selfValue,
373369
/// For other cases, the basic blocks are not necessary and the destructor
374370
/// can just emit all the normal destruction code right into the current block.
375371
// If set, used as the basic block for the destroying of all members.
376-
SILBasicBlock* normalMemberDestroyBB = nullptr;
372+
SILBasicBlock *normalMemberDestroyBB = nullptr;
377373
// If set, used as the basic block after members have been destroyed,
378374
// and we're ready to perform final cleanups before returning.
379-
SILBasicBlock* finishBB = nullptr;
375+
SILBasicBlock *finishBB = nullptr;
380376

381377
/// A distributed actor may be 'remote' in which case there is no need to
382378
/// destroy "all" members, because they never had storage to begin with.
@@ -393,7 +389,8 @@ void SILGenFunction::emitClassMemberDestruction(ManagedValue selfValue,
393389
// recursively the same type as `self`, so we can iteratively
394390
// deinitialize them, to prevent deep recursion and potential
395391
// stack overflows.
396-
llvm::SmallSetVector<VarDecl*, 4> recursiveLinks;
392+
393+
llvm::SmallSetVector<VarDecl *, 4> recursiveLinks;
397394
findRecursiveLinks(cd, recursiveLinks);
398395

399396
/// Destroy all members.

lib/SILGen/SILGenFunction.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -683,7 +683,7 @@ class LLVM_LIBRARY_VISIBILITY SILGenFunction
683683
/// Generates code to destroy linearly recursive data structures, without
684684
/// building up the call stack.
685685
///
686-
/// Example:
686+
/// E.x.: In the following we want to deinit next without recursing into next.
687687
///
688688
/// class Node<A> {
689689
/// let value: A

0 commit comments

Comments
 (0)