Skip to content

Commit 2f36a94

Browse files
committed
SILGen: Don't ask for captures of things that can't have captures
1 parent c3f7288 commit 2f36a94

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

lib/SILGen/SILGenFunction.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1002,7 +1002,7 @@ SILGenFunction::emitClosureValue(SILLocation loc, SILDeclRef constant,
10021002
// If we're in top-level code, we don't need to physically capture script
10031003
// globals, but we still need to mark them as escaping so that DI can flag
10041004
// uninitialized uses.
1005-
if (isEmittingTopLevelCode()) {
1005+
if (isEmittingTopLevelCode() && dc->getParentSourceFile()) {
10061006
auto captureInfo = closure.getCaptureInfo();
10071007
emitMarkFunctionEscapeForTopLevelCodeGlobals(loc, captureInfo);
10081008
}

lib/SILGen/SILGenTopLevel.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -369,6 +369,8 @@ static void emitMarkFunctionEscape(SILGenFunction &SGF,
369369
if (AFD->getDeclContext()->isLocalContext())
370370
return;
371371
auto CaptureInfo = AFD->getCaptureInfo();
372+
if (!CaptureInfo.hasBeenComputed())
373+
return;
372374
SGF.emitMarkFunctionEscapeForTopLevelCodeGlobals(AFD, std::move(CaptureInfo));
373375
}
374376

0 commit comments

Comments
 (0)