Skip to content

Commit 36922aa

Browse files
nate-chandlerktoso
authored andcommitted
[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 16ff49c commit 36922aa

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
@@ -426,15 +426,14 @@ void TBDGenVisitor::addSymbol(SILDeclRef declRef) {
426426
addSymbol(declRef.mangle(), SymbolSource::forSILDeclRef(declRef));
427427
}
428428

429-
void TBDGenVisitor::addAsyncFunctionPointerSymbol(AbstractFunctionDecl *AFD) {
430-
auto declRef = SILDeclRef(AFD);
429+
void TBDGenVisitor::addAsyncFunctionPointerSymbol(SILDeclRef declRef) {
431430
auto silLinkage = effectiveLinkageForClassMember(
432431
declRef.getLinkage(ForDefinition),
433432
declRef.getSubclassScope());
434433
if (Opts.PublicSymbolsOnly && silLinkage != SILLinkage::Public)
435434
return;
436435

437-
auto entity = LinkEntity::forAsyncFunctionPointer(AFD);
436+
auto entity = LinkEntity::forAsyncFunctionPointer(declRef);
438437
auto linkage =
439438
LinkInfo::get(UniversalLinkInfo, SwiftModule, entity, ForDefinition);
440439
addSymbol(linkage.getName(), SymbolSource::forSILDeclRef(declRef));
@@ -753,7 +752,7 @@ void TBDGenVisitor::visitAbstractFunctionDecl(AbstractFunctionDecl *AFD) {
753752
visitDefaultArguments(AFD, AFD->getParameters());
754753

755754
if (AFD->hasAsync()) {
756-
addAsyncFunctionPointerSymbol(AFD);
755+
addAsyncFunctionPointerSymbol(SILDeclRef(AFD));
757756
}
758757
}
759758

lib/TBDGen/TBDGenVisitor.h

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

124124
void addSymbol(SILDeclRef declRef);
125-
void addAsyncFunctionPointerSymbol(AbstractFunctionDecl *AFD);
125+
void addAsyncFunctionPointerSymbol(SILDeclRef declRef);
126126

127127
void addSymbol(LinkEntity entity);
128128

0 commit comments

Comments
 (0)