Skip to content

Isolated synchronous deinit #60057

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 57 commits into from
Sep 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
57 commits
Select commit Hold shift + click to select a range
b7e23c2
Runtime support for isolated deinit
nickolas-pohilets Jun 13, 2022
698e5e6
Enabled isolated deinit in Sema
nickolas-pohilets Apr 24, 2023
b189495
Introduced isolated deinit as a SIL entity
nickolas-pohilets Apr 24, 2023
d4e449b
SILGen for isolated deinit
nickolas-pohilets Apr 24, 2023
10ee948
Generating errors when isolation of the subclass deinit is not compat…
nickolas-pohilets Apr 24, 2023
952d4af
Added more tests. Implemented logic for inferring actor isolation for…
nickolas-pohilets Apr 24, 2023
8255539
Added checks for mangled names for isolated deinits
nickolas-pohilets Apr 24, 2023
a58f3fa
Updated SILGen for isolated deinit in @objc classes
nickolas-pohilets Apr 24, 2023
856a509
Fixed a bug in computing isolation of @objc actors. Added tests for @…
nickolas-pohilets Apr 24, 2023
63e538e
Import dealloc method as deinit
nickolas-pohilets Apr 24, 2023
10b43d7
Disable string processing
nickolas-pohilets Jan 8, 2024
95079af
Don't generate isolating destructor if dealloc was explicitly isolate…
nickolas-pohilets Apr 24, 2023
411cdb7
Added unit-tests for (not)copying task-local values. Fixed release af…
nickolas-pohilets Jun 13, 2024
b13da72
Removed declaration of the AdHocJob from the ABI headers
nickolas-pohilets Apr 24, 2023
62dbc6c
Fixed some tests. Using extract_executor SIL instruction instead of c…
nickolas-pohilets Apr 24, 2023
d7248e3
Fixed linkage logic for isolated deallocating deinit
nickolas-pohilets Apr 24, 2023
28a06fe
Added isolated deallocator to TBDGen
nickolas-pohilets Apr 24, 2023
72cad34
Don't hop to @MainActor if already running on the main thread.
nickolas-pohilets Apr 24, 2023
485965a
Reviewed code comments. Fixed typos and addressed some TODOs
nickolas-pohilets Apr 24, 2023
9005e9b
Removed some dead code
nickolas-pohilets Apr 24, 2023
b4a1aab
Updated Distributed/Runtime/distributed_actor_deinit.swift to check f…
nickolas-pohilets Apr 24, 2023
f04f1de
Fixed some typos
nickolas-pohilets Apr 24, 2023
cdba7b3
Removed explicit deinit from MainActor - not needed.
nickolas-pohilets Apr 24, 2023
c28df0d
Don't isolate deinit of remote actor proxies
nickolas-pohilets Apr 24, 2023
5437b31
Expanded test for SIL for distributed actor deinit, added isolated cases
nickolas-pohilets Apr 24, 2023
9dfa174
Don't add isolation attributes for deinit when they were inferred fro…
nickolas-pohilets Apr 24, 2023
a043ebf
Don't switch threads when running isolated deinit of the default actor.
nickolas-pohilets Apr 24, 2023
35f0334
Rename performOnExecutor into deinitOnExecutor.
nickolas-pohilets Apr 24, 2023
7505cd2
Updated unit tests
nickolas-pohilets Apr 24, 2023
f1e3002
Added more tests for isolated actor deinit:
nickolas-pohilets Apr 24, 2023
9dcea15
Fixed tests on Linux, Windows and older MacOS versions
nickolas-pohilets Apr 24, 2023
4d0b624
Make deinit non-isolated by default
nickolas-pohilets Apr 24, 2023
40c7c6b
Allow accessing let properties in deinit isolated on different actor
nickolas-pohilets Apr 24, 2023
ab4d338
Added flags to be able to control task-locals behaviour in the future
nickolas-pohilets Apr 24, 2023
2cb7e8d
Implemented suppressing isolated deinit for compatibility with older …
nickolas-pohilets May 14, 2023
1b69068
Keep current task executor when taking fast path in isolated deinit
nickolas-pohilets Jan 4, 2024
8dbddec
Don't read current task executor to avoid extra access of the task-lo…
nickolas-pohilets Jan 9, 2024
6b0ce0b
Added emitting precondition check in the isolated deinit
nickolas-pohilets Jun 25, 2024
e9173ff
Make sure legacy executor checking mode is always used in swift_task_…
nickolas-pohilets Jul 10, 2024
816d62c
Merge remote-tracking branch 'upstream/main' into mpokhylets/isolated…
nickolas-pohilets Jul 11, 2024
1304f81
Fixed CI builds
nickolas-pohilets Jul 11, 2024
da75f5f
Temporary disabled test failing on Linux
nickolas-pohilets Jul 19, 2024
1120bee
Reject isolation attributes on deinit in value types
nickolas-pohilets Aug 12, 2024
6243dfa
Using REQUIRES: swift_stdlib_asserts as a cleaner way to disable acto…
nickolas-pohilets Aug 12, 2024
6151731
Updated implementation to handle SWIFT_CONCURRENCY_ACTORS_AS_LOCKS
nickolas-pohilets Aug 13, 2024
66871b9
Deterministically crash in DefaultActorImpl::destroy() when self esca…
nickolas-pohilets Aug 15, 2024
50b1313
Merge branch 'main' into mpokhylets/isolated-deinit
nickolas-pohilets Aug 15, 2024
0412597
Added swift_retainCount to EmbeddedRuntime.swift
nickolas-pohilets Aug 19, 2024
9a0df5b
Don't add swift_retainCount() to RuntimeFunctions.def, but explicitly…
nickolas-pohilets Aug 21, 2024
6fa62f7
Revert allowing @preconcurrency on deinit declarations
nickolas-pohilets Aug 24, 2024
a7ac32f
Disabled isolated deinit for SWIFT_CONCURRENCY_ACTORS_AS_LOCKS in the…
nickolas-pohilets Aug 26, 2024
d6673c7
Implemented zombie actor state in SWIFT_CONCURRENCY_ACTORS_AS_LOCKS m…
nickolas-pohilets Aug 26, 2024
e0ad7bd
Merge branch 'main' into mpokhylets/isolated-deinit
nickolas-pohilets Aug 29, 2024
c55ad6f
Merge branch 'main' into mpokhylets/isolated-deinit
ktoso Sep 2, 2024
05b78ff
Merge branch 'main' into mpokhylets/isolated-deinit
nickolas-pohilets Sep 2, 2024
6d26514
Fixed test/SourceKit/InterfaceGen/gen_swift_module.swift
nickolas-pohilets Sep 2, 2024
56fca2a
Fixed test/Distributed/Runtime/distributed_actor_deinit.swift in opti…
nickolas-pohilets Sep 3, 2024
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
1 change: 1 addition & 0 deletions docs/ABI/Mangling.rst
Original file line number Diff line number Diff line change
Expand Up @@ -365,6 +365,7 @@ Entities
entity-spec ::= 'fP' // property wrapper backing initializer
entity-spec ::= 'fW' // property wrapper init from projected value
entity-spec ::= 'fD' // deallocating destructor; untyped
entity-spec ::= 'fZ' // isolated deallocating destructor; untyped
entity-spec ::= 'fd' // non-deallocating destructor; untyped
entity-spec ::= 'fE' // ivar destroyer; untyped
entity-spec ::= 'fe' // ivar initializer; untyped
Expand Down
1 change: 1 addition & 0 deletions include/swift/ABI/Executor.h
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,7 @@ using ThrowingTaskFutureWaitContinuationFunction =
SWIFT_CC(swiftasync)
void (SWIFT_ASYNC_CONTEXT AsyncContext *, SWIFT_CONTEXT void *);

using DeinitWorkFunction = SWIFT_CC(swift) void(void *);

template <class AsyncSignature>
class AsyncFunctionPointer;
Expand Down
3 changes: 2 additions & 1 deletion include/swift/ABI/MetadataValues.h
Original file line number Diff line number Diff line change
Expand Up @@ -2490,7 +2490,8 @@ enum class JobKind : size_t {
DefaultActorInline = First_Reserved,
DefaultActorSeparate,
DefaultActorOverride,
NullaryContinuation
NullaryContinuation,
IsolatedDeinit,
};

/// The priority of a job. Higher priorities are larger values.
Expand Down
12 changes: 9 additions & 3 deletions include/swift/AST/ASTMangler.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,12 @@ class RootProtocolConformance;

namespace Mangle {

enum class DestructorKind {
NonDeallocating,
Deallocating,
IsolatedDeallocating
};

/// The mangler for AST declarations.
class ASTMangler : public Mangler {
protected:
Expand Down Expand Up @@ -205,7 +211,7 @@ class ASTMangler : public Mangler {
SymbolKind SKind = SymbolKind::Default);

std::string mangleDestructorEntity(const DestructorDecl *decl,
bool isDeallocating,
DestructorKind kind,
SymbolKind SKind = SymbolKind::Default);

std::string mangleConstructorEntity(const ConstructorDecl *ctor,
Expand Down Expand Up @@ -703,8 +709,8 @@ class ASTMangler : public Mangler {
bool tryAppendStandardSubstitution(const GenericTypeDecl *type);

void appendConstructorEntity(const ConstructorDecl *ctor, bool isAllocating);
void appendDestructorEntity(const DestructorDecl *decl, bool isDeallocating);

void appendDestructorEntity(const DestructorDecl *decl, DestructorKind kind);

/// \param accessorKindCode The code to describe the accessor and addressor
/// kind. Usually retrieved using getCodeForAccessorKind.
Expand Down
12 changes: 12 additions & 0 deletions include/swift/AST/Decl.h
Original file line number Diff line number Diff line change
Expand Up @@ -1368,6 +1368,10 @@ class alignas(1 << DeclAlignInBits) Decl : public ASTAllocated<Decl> {
std::optional<std::pair<CustomAttr *, NominalTypeDecl *>>
getGlobalActorAttr() const;

/// Determine whether there is an explicit isolation attribute
/// of any kind.
bool hasExplicitIsolationAttribute() const;

/// If an alternative module name is specified for this decl, e.g. using
/// @_originalDefinedIn attribute, this function returns this module name.
StringRef getAlternateModuleName() const;
Expand Down Expand Up @@ -3143,6 +3147,10 @@ class ValueDecl : public Decl {
/// Retrieve the declaration that this declaration overrides, if any.
ValueDecl *getOverriddenDecl() const;

/// Retrieve the declaration that this declaration overrides, including super
/// deinit.
ValueDecl *getOverriddenDeclOrSuperDeinit() const;

/// Retrieve the declarations that this declaration overrides, if any.
llvm::TinyPtrVector<ValueDecl *> getOverriddenDecls() const;

Expand Down Expand Up @@ -8915,6 +8923,10 @@ class DestructorDecl : public AbstractFunctionDecl {
/// Retrieve the Objective-C selector for destructors.
ObjCSelector getObjCSelector() const;

/// Retrieves destructor decl from the superclass, or nil if there is no
/// superclass
DestructorDecl *getSuperDeinit() const;

static bool classof(const Decl *D) {
return D->getKind() == DeclKind::Destructor;
}
Expand Down
5 changes: 4 additions & 1 deletion include/swift/AST/DeclAttr.def
Original file line number Diff line number Diff line change
Expand Up @@ -434,14 +434,17 @@ SIMPLE_DECL_ATTR(rethrows, Rethrows,
CONTEXTUAL_SIMPLE_DECL_ATTR(indirect, Indirect,
DeclModifier | OnEnum | OnEnumElement | ABIBreakingToAdd | ABIBreakingToRemove | APIStableToAdd | APIStableToRemove,
60)
CONTEXTUAL_SIMPLE_DECL_ATTR(isolated, Isolated,
DeclModifier | OnDestructor | ABIBreakingToAdd | ABIBreakingToRemove | APIBreakingToAdd | APIBreakingToRemove,
103)
CONTEXTUAL_SIMPLE_DECL_ATTR(async, Async,
DeclModifier | OnVar | OnFunc | ABIBreakingToAdd | ABIBreakingToRemove | APIBreakingToAdd | APIBreakingToRemove,
106)
SIMPLE_DECL_ATTR(reasync, Reasync,
OnFunc | OnConstructor | RejectByParser | ABIBreakingToAdd | ABIBreakingToRemove | APIBreakingToAdd | APIBreakingToRemove,
109)
CONTEXTUAL_DECL_ATTR(nonisolated, Nonisolated,
DeclModifier | OnFunc | OnConstructor | OnVar | OnSubscript | ABIStableToAdd | ABIStableToRemove | APIBreakingToAdd | APIStableToRemove,
DeclModifier | OnFunc | OnConstructor | OnDestructor | OnVar | OnSubscript | ABIStableToAdd | ABIStableToRemove | APIBreakingToAdd | APIStableToRemove,
112)
CONTEXTUAL_SIMPLE_DECL_ATTR(distributed, DistributedActor,
DeclModifier | OnClass | OnFunc | OnAccessor | OnVar | ABIBreakingToAdd | ABIBreakingToRemove | APIBreakingToAdd | APIBreakingToRemove,
Expand Down
13 changes: 12 additions & 1 deletion include/swift/AST/DiagnosticsSema.def
Original file line number Diff line number Diff line change
Expand Up @@ -5883,9 +5883,12 @@ ERROR(global_actor_not_usable_from_inline,none,
NOTE(move_global_actor_attr_to_storage_decl,none,
"move global actor attribute to %kind0", (const ValueDecl *))

ERROR(actor_isolation_multiple_attr,none,
ERROR(actor_isolation_multiple_attr_2,none,
"%kind0 has multiple actor-isolation attributes ('%1' and '%2')",
(const Decl *, StringRef, StringRef))
ERROR(actor_isolation_multiple_attr_3,none,
"%0 %1 has multiple actor-isolation attributes ('%2', '%3' and '%4')",
(const Decl *, StringRef, StringRef, StringRef))
ERROR(actor_isolation_override_mismatch,none,
"%0 %kind1 has different actor isolation from %2 overridden declaration",
(ActorIsolation, const ValueDecl *, ActorIsolation))
Expand All @@ -5902,6 +5905,14 @@ ERROR(async_named_decl_must_be_available_from_async,none,
ERROR(async_unavailable_decl,none,
"%kindbase0 is unavailable from asynchronous contexts%select{|; %1}1",
(const ValueDecl *, StringRef))


ERROR(isolated_deinit_no_isolation,none,
"deinit is marked isolated, but containing class %0 is not isolated to an actor",
(DeclName))
ERROR(isolated_deinit_on_value_type,none,
"only classes and actors can have isolated deinit",
())

//------------------------------------------------------------------------------
// MARK: String Processing
Expand Down
13 changes: 12 additions & 1 deletion include/swift/AST/PrintOptions.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ class DeclContext;
class Type;
class ModuleDecl;
enum class DeclAttrKind : unsigned;
class DeclAttribute;
class CustomAttr;
class SynthesizedExtensionAnalyzer;
struct PrintOptions;
class SILPrintContext;
Expand Down Expand Up @@ -342,6 +344,10 @@ struct PrintOptions {
/// Suppress emitting @available(*, noasync)
bool SuppressNoAsyncAvailabilityAttr = false;

/// Suppress emitting isolated or async deinit, and emit open containing class
/// as public
bool SuppressIsolatedDeinit = false;

/// Whether to print the \c{/*not inherited*/} comment on factory initializers.
bool PrintFactoryInitializerComment = true;

Expand Down Expand Up @@ -393,6 +399,8 @@ struct PrintOptions {
DeclAttrKind::FixedLayout, DeclAttrKind::ShowInInterface,
};

std::vector<CustomAttr *> ExcludeCustomAttrList = {};

/// List of attribute kinds that should be printed exclusively.
/// Empty means allow all.
std::vector<AnyAttrKind> ExclusiveAttrList;
Expand Down Expand Up @@ -627,6 +635,8 @@ struct PrintOptions {
return false;
}

bool excludeAttr(const DeclAttribute *DA) const;

/// Retrieve the set of options for verbose printing to users.
static PrintOptions printVerbose() {
PrintOptions result;
Expand Down Expand Up @@ -682,7 +692,8 @@ struct PrintOptions {
result.SkipPrivateSystemDecls = true;
result.SkipUnderscoredSystemProtocols = true;
result.SkipUnsafeCXXMethods = true;
result.SkipDeinit = true;
result.SkipDeinit = false; // Deinit may have isolation attributes, which
// are part of the interface
result.EmptyLineBetweenDecls = true;
result.CascadeDocComment = true;
result.ShouldQualifyNestedDeclarations =
Expand Down
2 changes: 2 additions & 0 deletions include/swift/Basic/Features.def
Original file line number Diff line number Diff line change
Expand Up @@ -408,6 +408,8 @@ SUPPRESSIBLE_EXPERIMENTAL_FEATURE(AllowUnsafeAttribute, true)
/// Warn on use of unsafe constructs.
EXPERIMENTAL_FEATURE(WarnUnsafe, true)

SUPPRESSIBLE_LANGUAGE_FEATURE(IsolatedDeinit, 371, "isolated/async deinit")

#undef EXPERIMENTAL_FEATURE_EXCLUDED_FROM_MODULE_INTERFACE
#undef EXPERIMENTAL_FEATURE
#undef UPCOMING_FEATURE
Expand Down
1 change: 1 addition & 0 deletions include/swift/Demangling/DemangleNodes.def
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,7 @@ NODE(InfixOperator)
CONTEXT_NODE(Initializer)
CONTEXT_NODE(InitAccessor)
NODE(Isolated)
CONTEXT_NODE(IsolatedDeallocator)
NODE(Sending)
NODE(IsolatedAnyFunctionType)
NODE(SendingResultFunctionType)
Expand Down
5 changes: 5 additions & 0 deletions include/swift/Runtime/Concurrency.h
Original file line number Diff line number Diff line change
Expand Up @@ -605,6 +605,11 @@ swift_task_createNullaryContinuationJob(
size_t priority,
AsyncTask *continuation);

SWIFT_EXPORT_FROM(swift_Concurrency)
SWIFT_CC(swift)
void swift_task_deinitOnExecutor(void *object, DeinitWorkFunction *work,
SerialExecutorRef newExecutor, size_t flags);

/// Report error about attempting to bind a task-local value from an illegal context.
SWIFT_EXPORT_FROM(swift_Concurrency) SWIFT_CC(swift)
void swift_task_reportIllegalTaskLocalBindingWithinWithTaskGroup(
Expand Down
16 changes: 15 additions & 1 deletion include/swift/Runtime/RuntimeFunctions.def
Original file line number Diff line number Diff line change
Expand Up @@ -2278,7 +2278,7 @@ FUNCTION(GetTypeByMangledNameInContextInMetadataState2,
EFFECT(MetaData),
MEMEFFECTS(ArgMemOnly))

// AsyncTask *swift_task_getCurrent();s
// AsyncTask *swift_task_getCurrent();
FUNCTION(GetCurrentTask,
swift_task_getCurrent, SwiftCC,
ConcurrencyAvailability,
Expand Down Expand Up @@ -2347,6 +2347,20 @@ FUNCTION(TaskSwitchFunc,
ATTRS(NoUnwind),
EFFECT(Concurrency),
UNKNOWN_MEMEFFECTS)

// void swift_task_deinitOnExecutor(void *object,
// DeinitWorkFunction *work,
// SerialExecutorRef newExecutor,
// size_t flags);
FUNCTION(DeinitOnExecutorFunc,
swift_task_deinitOnExecutor, SwiftCC,
ConcurrencyAvailability,
RETURNS(VoidTy),
ARGS(Int8PtrTy, Int8PtrTy, ExecutorFirstTy, ExecutorSecondTy, SizeTy),
ATTRS(NoUnwind),
EFFECT(Concurrency),
UNKNOWN_MEMEFFECTS)


// AsyncTask *swift_continuation_init(AsyncContext *continuationContext,
// AsyncContinuationFlags);
Expand Down
13 changes: 9 additions & 4 deletions include/swift/SIL/SILDeclRef.h
Original file line number Diff line number Diff line change
Expand Up @@ -111,19 +111,23 @@ struct SILDeclRef {
/// Initializer - this constant references the initializing constructor
/// entry point of the class ConstructorDecl in loc.
Initializer,

/// EnumElement - this constant references the injection function for
/// an EnumElementDecl.
EnumElement,

/// Destroyer - this constant references the destroying destructor for the
/// DestructorDecl in loc.
Destroyer,

/// Deallocator - this constant references the deallocating
/// destructor for the DestructorDecl in loc.
Deallocator,


/// Deallocator - this constant references the isolated deallocating
/// destructor for the DestructorDecl in loc.
IsolatedDeallocator,

/// GlobalAccessor - this constant references the lazy-initializing
/// accessor for the global VarDecl in loc.
GlobalAccessor,
Expand Down Expand Up @@ -339,7 +343,8 @@ struct SILDeclRef {
}
/// True if the SILDeclRef references a destructor entry point.
bool isDestructor() const {
return kind == Kind::Destroyer || kind == Kind::Deallocator;
return kind == Kind::Destroyer || kind == Kind::Deallocator ||
kind == Kind::IsolatedDeallocator;
}
/// True if the SILDeclRef references an enum entry point.
bool isEnumElement() const {
Expand Down
3 changes: 3 additions & 0 deletions include/swift/SIL/SILModule.h
Original file line number Diff line number Diff line change
Expand Up @@ -1113,6 +1113,9 @@ namespace Lowering {
/// Determine whether the given class will be allocated/deallocated using the
/// Objective-C runtime, i.e., +alloc and -dealloc.
LLVM_LIBRARY_VISIBILITY bool usesObjCAllocator(ClassDecl *theClass);
/// Determine if isolating destructor is needed.
LLVM_LIBRARY_VISIBILITY bool needsIsolatingDestructor(DestructorDecl *dd);

} // namespace Lowering
} // namespace swift

Expand Down
26 changes: 18 additions & 8 deletions lib/AST/ASTMangler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -129,11 +129,11 @@ std::string ASTMangler::mangleEntity(const ValueDecl *decl, SymbolKind SKind) {
}

std::string ASTMangler::mangleDestructorEntity(const DestructorDecl *decl,
bool isDeallocating,
DestructorKind kind,
SymbolKind SKind) {
llvm::SaveAndRestore X(AllowInverses, inversesAllowed(decl));
beginMangling();
appendDestructorEntity(decl, isDeallocating);
appendDestructorEntity(decl, kind);
appendSymbolKind(SKind);
return finalize();
}
Expand Down Expand Up @@ -838,7 +838,7 @@ void ASTMangler::appendAnyDecl(const ValueDecl *Decl) {
if (auto Ctor = dyn_cast<ConstructorDecl>(Decl)) {
appendConstructorEntity(Ctor, /*isAllocating=*/false);
} else if (auto Dtor = dyn_cast<DestructorDecl>(Decl)) {
appendDestructorEntity(Dtor, /*isDeallocating=*/false);
appendDestructorEntity(Dtor, DestructorKind::NonDeallocating);
} else if (auto GTD = dyn_cast<GenericTypeDecl>(Decl)) {
appendAnyGenericType(GTD);
} else if (isa<AssociatedTypeDecl>(Decl)) {
Expand Down Expand Up @@ -940,7 +940,7 @@ std::string ASTMangler::mangleHasSymbolQuery(const ValueDecl *Decl) {
if (auto Ctor = dyn_cast<ConstructorDecl>(Decl)) {
appendConstructorEntity(Ctor, /*isAllocating=*/false);
} else if (auto Dtor = dyn_cast<DestructorDecl>(Decl)) {
appendDestructorEntity(Dtor, /*isDeallocating=*/false);
appendDestructorEntity(Dtor, DestructorKind::NonDeallocating);
} else if (auto GTD = dyn_cast<GenericTypeDecl>(Decl)) {
appendAnyGenericType(GTD);
} else if (isa<AssociatedTypeDecl>(Decl)) {
Expand Down Expand Up @@ -2447,8 +2447,8 @@ void ASTMangler::appendContext(const DeclContext *ctx,
}

if (auto dtor = dyn_cast<DestructorDecl>(fn))
return appendDestructorEntity(dtor, /*deallocating*/ false);
return appendDestructorEntity(dtor, DestructorKind::NonDeallocating);

return appendEntity(fn);
}

Expand Down Expand Up @@ -3953,10 +3953,20 @@ void ASTMangler::appendConstructorEntity(const ConstructorDecl *ctor,
}

void ASTMangler::appendDestructorEntity(const DestructorDecl *dtor,
bool isDeallocating) {
DestructorKind kind) {
BaseEntitySignature base(dtor);
appendContextOf(dtor, base);
appendOperator(isDeallocating ? "fD" : "fd");
switch (kind) {
case DestructorKind::NonDeallocating:
appendOperator("fd");
break;
case DestructorKind::Deallocating:
appendOperator("fD");
break;
case DestructorKind::IsolatedDeallocating:
appendOperator("fZ");
break;
}
}

void ASTMangler::appendAccessorEntity(StringRef accessorKindCode,
Expand Down
Loading