Skip to content

Commit 71c0eae

Browse files
committed
[TBD] Pass decl ref when adding AFP symbols.
Previously, adding a symbol for an async function pointer to the TBD entailed passing an AbstractFunctionDecl to TBDGenVisitor::addAsyncFunctionPointerSymbol. That arrangment limited clients from specifying a different SILDeclRef::Kind than the one which could be inferred from the type of the decl which was passed to the visitor's function. In particular, it prevented clients from specifying that the symbol for an initializer corresponding to a ConstructorDecl should be added to the TBD. Here, the arrangement is changed so that the visitor's function takes a SILDeclRef.
1 parent 2c7fb70 commit 71c0eae

File tree

2 files changed

+4
-5
lines changed

2 files changed

+4
-5
lines changed

lib/TBDGen/TBDGen.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -411,15 +411,14 @@ void TBDGenVisitor::addSymbol(SILDeclRef declRef) {
411411
addSymbol(declRef.mangle(), SymbolSource::forSILDeclRef(declRef));
412412
}
413413

414-
void TBDGenVisitor::addAsyncFunctionPointerSymbol(AbstractFunctionDecl *AFD) {
415-
auto declRef = SILDeclRef(AFD);
414+
void TBDGenVisitor::addAsyncFunctionPointerSymbol(SILDeclRef declRef) {
416415
auto silLinkage = effectiveLinkageForClassMember(
417416
declRef.getLinkage(ForDefinition),
418417
declRef.getSubclassScope());
419418
if (Opts.PublicSymbolsOnly && silLinkage != SILLinkage::Public)
420419
return;
421420

422-
auto entity = LinkEntity::forAsyncFunctionPointer(AFD);
421+
auto entity = LinkEntity::forAsyncFunctionPointer(declRef);
423422
auto linkage =
424423
LinkInfo::get(UniversalLinkInfo, SwiftModule, entity, ForDefinition);
425424
addSymbol(linkage.getName(), SymbolSource::forSILDeclRef(declRef));
@@ -742,7 +741,7 @@ void TBDGenVisitor::visitAbstractFunctionDecl(AbstractFunctionDecl *AFD) {
742741
visitDefaultArguments(AFD, AFD->getParameters());
743742

744743
if (AFD->hasAsync()) {
745-
addAsyncFunctionPointerSymbol(AFD);
744+
addAsyncFunctionPointerSymbol(SILDeclRef(AFD));
746745
}
747746
}
748747

lib/TBDGen/TBDGenVisitor.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ class TBDGenVisitor : public ASTVisitor<TBDGenVisitor> {
121121
SymbolKind kind = SymbolKind::GlobalSymbol);
122122

123123
void addSymbol(SILDeclRef declRef);
124-
void addAsyncFunctionPointerSymbol(AbstractFunctionDecl *AFD);
124+
void addAsyncFunctionPointerSymbol(SILDeclRef declRef);
125125

126126
void addSymbol(LinkEntity entity);
127127

0 commit comments

Comments
 (0)