Skip to content

Commit f0c5c4b

Browse files
committed
Conjure up asyncMainDrainQueue
The asyncMainDrainQueue is also declared `internal`, so it won't show up in the swiftinterface file. The expected declaration is: ``` @available(SwiftStdlib 5.5, *) @_silgen_name("swift_task_asyncMainDrainQueue") internal func _asyncMainDrainQueue() -> Never ```
1 parent 2133aa7 commit f0c5c4b

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

lib/SILGen/SILGenFunction.cpp

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1005,6 +1005,25 @@ void SILGenFunction::emitAsyncMainThreadStart(SILDeclRef entryPoint) {
10051005

10061006
// Start Main loop!
10071007
FuncDecl *drainQueueFuncDecl = SGM.getAsyncMainDrainQueue();
1008+
if (!drainQueueFuncDecl) {
1009+
// If it doesn't exist, we can conjure one up instead of crashing
1010+
// @available(SwiftStdlib 5.5, *)
1011+
// @_silgen_name("swift_task_asyncMainDrainQueue")
1012+
// internal func _asyncMainDrainQueue() -> Never
1013+
ParameterList *emptyParams = ParameterList::createEmpty(getASTContext());
1014+
drainQueueFuncDecl = FuncDecl::createImplicit(
1015+
getASTContext(), StaticSpellingKind::None,
1016+
DeclName(
1017+
getASTContext(),
1018+
DeclBaseName(getASTContext().getIdentifier("_asyncMainDrainQueue")),
1019+
/*Arguments*/emptyParams),
1020+
{}, /*async*/ false, /*throws*/ false, {}, emptyParams,
1021+
getASTContext().getNeverType(),
1022+
entryPoint.getDecl()->getModuleContext());
1023+
drainQueueFuncDecl->getAttrs().add(
1024+
new (getASTContext()) SILGenNameAttr("swift_task_asyncMainDrainQueue", /*implicit*/ true));
1025+
}
1026+
10081027
SILFunction *drainQueueSILFunc = SGM.getFunction(
10091028
SILDeclRef(drainQueueFuncDecl, SILDeclRef::Kind::Func), NotForDefinition);
10101029
SILValue drainQueueFunc =

0 commit comments

Comments
 (0)