Skip to content

Commit 2c7fb70

Browse files
committed
[IRGen] Give decl ref to LinkEntity::forAFP.
Previously, a LinkEntity for an AST async function pointer was built by passing an AbstractFunctionDecl. Later, decl was used to construct a SILDeclRef. That arrangement meant that clients could not construct such a LinkEntity whose SILDeclRef::Kind could not be inferred from the dynamic type of the decl from which the SILDeclRef was constructed. In particular, clients could not construct a LinkEntity for the initializer corresponding to a ConstructorDecl. Here, the arrangment is changed so that the LinkEntity for an AST async function pointer is built by passing a SILDeclRef.
1 parent a4992cf commit 2c7fb70

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

include/swift/IRGen/Linking.h

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1196,9 +1196,12 @@ class LinkEntity {
11961196
return entity;
11971197
}
11981198

1199-
static LinkEntity forAsyncFunctionPointer(AbstractFunctionDecl *decl) {
1199+
static LinkEntity forAsyncFunctionPointer(SILDeclRef declRef) {
12001200
LinkEntity entity;
1201-
entity.setForDecl(Kind::AsyncFunctionPointerAST, decl);
1201+
entity.setForDecl(Kind::AsyncFunctionPointerAST,
1202+
declRef.getAbstractFunctionDecl());
1203+
entity.SecondaryPointer =
1204+
reinterpret_cast<void *>(static_cast<uintptr_t>(declRef.kind));
12021205
return entity;
12031206
}
12041207

lib/IRGen/Linking.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -468,7 +468,10 @@ std::string LinkEntity::mangleAsString() const {
468468

469469
case Kind::AsyncFunctionPointerAST: {
470470
std::string Result;
471-
Result = SILDeclRef(const_cast<ValueDecl *>(getDecl())).mangle();
471+
Result = SILDeclRef(const_cast<ValueDecl *>(getDecl()),
472+
static_cast<SILDeclRef::Kind>(
473+
reinterpret_cast<uintptr_t>(SecondaryPointer)))
474+
.mangle();
472475
Result.append("Tu");
473476
return Result;
474477
}

0 commit comments

Comments
 (0)