Fix crash on invalid code. I've tried to produce a reduced test case, but when I do the specific crash is hidden. Fixes <rdar://problem/11063594>.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@152968 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Ted Kremenek 2012-03-17 00:53:39 +00:00
Родитель fbd58743fa
Коммит 2c085ede8d
1 изменённых файлов: 10 добавлений и 1 удалений

Просмотреть файл

@ -1127,7 +1127,7 @@ Sema::LookupMemberExpr(LookupResult &R, ExprResult &BaseExpr,
<< BaseExpr.get()->getSourceRange()))
return ExprError();
ObjCInterfaceDecl *ClassDeclared;
ObjCInterfaceDecl *ClassDeclared = 0;
ObjCIvarDecl *IV = IDecl->lookupInstanceVariable(Member, ClassDeclared);
if (!IV) {
@ -1145,6 +1145,13 @@ Sema::LookupMemberExpr(LookupResult &R, ExprResult &BaseExpr,
IV->getNameAsString());
Diag(IV->getLocation(), diag::note_previous_decl)
<< IV->getDeclName();
// Figure out the class that declares the ivar.
assert(!ClassDeclared);
Decl *D = cast<Decl>(IV->getDeclContext());
if (ObjCCategoryDecl *CAT = dyn_cast<ObjCCategoryDecl>(D))
D = CAT->getClassInterface();
ClassDeclared = cast<ObjCInterfaceDecl>(D);
} else {
if (IsArrow && IDecl->FindPropertyDeclaration(Member)) {
Diag(MemberLoc,
@ -1160,6 +1167,8 @@ Sema::LookupMemberExpr(LookupResult &R, ExprResult &BaseExpr,
return ExprError();
}
}
assert(ClassDeclared);
// If the decl being referenced had an error, return an error for this
// sub-expr without emitting another error, in order to avoid cascading