Skip to content

Commit e9e2378

Browse files
author
Brian King
committed
Fix a crash with a nil pattern returned from StmtConditionElement
1 parent 3c4fec8 commit e9e2378

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

lib/Sema/MiscDiagnostics.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2019,9 +2019,11 @@ class VarDeclUsageChecker : public ASTWalker {
20192019
GuardStmt *GS = dyn_cast<GuardStmt>(S);
20202020
if (!GS) continue;
20212021
for (StmtConditionElement SCE : GS->getCond()) {
2022-
SCE.getPattern()->forEachVariable([&](VarDecl *VD) {
2023-
VarDecls[VD] = RK_Read|RK_Written;
2024-
});
2022+
if (auto pattern = SCE.getPatternOrNull()) {
2023+
pattern->forEachVariable([&](VarDecl *VD) {
2024+
VarDecls[VD] = RK_Read|RK_Written;
2025+
});
2026+
}
20252027
}
20262028
}
20272029
}

0 commit comments

Comments
 (0)