[SourceKit] Don't forget to check for nullptr

After 7400d484 we tried to walk into enum elements, but forgot to check
for missing types (which caused an assertion in getType) or element
decls (which caused an assertion or crash inside passReference).

rdar://problem/24634223
This commit is contained in:
Ben Langmuir
2016-02-18 13:43:09 -08:00
parent e3e107b46a
commit 9418b32b2a
3 changed files with 39 additions and 1 deletions

View File

@@ -311,7 +311,11 @@ bool SemaAnnotator::walkToTypeReprPost(TypeRepr *T) {
std::pair<bool, Pattern *> SemaAnnotator::walkToPatternPre(Pattern *P) {
if (auto *EP = dyn_cast<EnumElementPattern>(P)) {
return { passReference(EP->getElementDecl(), EP->getType(), DeclNameLoc(EP->getLoc())), P };
auto *Element = EP->getElementDecl();
if (!Element)
return { true, P };
Type T = EP->hasType() ? EP->getType() : Type();
return { passReference(Element, T, DeclNameLoc(EP->getLoc())), P };
}
auto *TP = dyn_cast<TypedPattern>(P);