Skip to content

Commit 1cc4dd4

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 7f0130d commit 1cc4dd4

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
@@ -959,6 +959,25 @@ void SILGenFunction::emitAsyncMainThreadStart(SILDeclRef entryPoint) {
959959

960960
// Start Main loop!
961961
FuncDecl *drainQueueFuncDecl = SGM.getAsyncMainDrainQueue();
962+
if (!drainQueueFuncDecl) {
963+
// If it doesn't exist, we can conjure one up instead of crashing
964+
// @available(SwiftStdlib 5.5, *)
965+
// @_silgen_name("swift_task_asyncMainDrainQueue")
966+
// internal func _asyncMainDrainQueue() -> Never
967+
ParameterList *emptyParams = ParameterList::createEmpty(getASTContext());
968+
drainQueueFuncDecl = FuncDecl::createImplicit(
969+
getASTContext(), StaticSpellingKind::None,
970+
DeclName(
971+
getASTContext(),
972+
DeclBaseName(getASTContext().getIdentifier("_asyncMainDrainQueue")),
973+
/*Arguments*/ emptyParams),
974+
{}, /*async*/ false, /*throws*/ false, {}, emptyParams,
975+
getASTContext().getNeverType(),
976+
entryPoint.getDecl()->getModuleContext());
977+
drainQueueFuncDecl->getAttrs().add(new (getASTContext()) SILGenNameAttr(
978+
"swift_task_asyncMainDrainQueue", /*implicit*/ true));
979+
}
980+
962981
SILFunction *drainQueueSILFunc = SGM.getFunction(
963982
SILDeclRef(drainQueueFuncDecl, SILDeclRef::Kind::Func), NotForDefinition);
964983
SILValue drainQueueFunc =

0 commit comments

Comments
 (0)