Skip to content

Commit f249139

Browse files
committed
[silgen] check if the body is not null before accessing it
1 parent 4e3278e commit f249139

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

lib/SILGen/SILGenProlog.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -434,9 +434,11 @@ void SILGenFunction::emitProlog(AnyFunctionRef TheClosure,
434434
unreachableLoc.markAsPrologue();
435435
B.createUnreachable(unreachableLoc);
436436

437-
if (!TheClosure.getBody()->getElements().empty()) {
438-
auto &ctx = SGM.M.getASTContext();
439-
ctx.Diags.diagnose(TheClosure.getBody()->getStartLoc(), diag::unreachable_code_uninhabited_param_note);
437+
if (auto body = TheClosure.getBody()) {
438+
if (!body->getElements().empty()) {
439+
auto &ctx = SGM.M.getASTContext();
440+
ctx.Diags.diagnose(body->getStartLoc(), diag::unreachable_code_uninhabited_param_note);
441+
}
440442
}
441443
break;
442444
}

0 commit comments

Comments
 (0)