Fix a crash where PI.TypeInfo has not been filled in case of missing ObjCInterfaceDecl.

Happens with Xcode 2.4.1 headers on test
Parser/objc-foreach-error-1.m

llvm-svn: 47767
This commit is contained in:
Gabor Greif 2008-02-29 20:35:55 +00:00
parent 17f4dbde36
commit 05fdaeaed2
1 changed files with 7 additions and 6 deletions

View File

@ -43,17 +43,18 @@ void Sema::ObjCActOnStartOfMethodDef(Scope *FnBodyScope, DeclTy *D) {
PI.IdentLoc = SourceLocation(); // synthesized vars have a null location.
PI.InvalidType = false;
PI.AttrList = 0;
PI.TypeInfo = Context.getObjCIdType().getAsOpaquePtr();
if (MDecl->isInstance()) {
ObjCInterfaceDecl *OID = MDecl->getClassInterface();
// There may be no interface context due to error in declaration of the
// interface (which has been reported). Recover gracefully
if (OID) {
if (ObjCInterfaceDecl *OID = MDecl->getClassInterface()) {
// There may be no interface context due to error in declaration of the
// interface (which has been reported). Recover gracefully
QualType selfTy = Context.getObjCInterfaceType(OID);
selfTy = Context.getPointerType(selfTy);
PI.TypeInfo = selfTy.getAsOpaquePtr();
}
} else
PI.TypeInfo = Context.getObjCIdType().getAsOpaquePtr();
}
CurMethodDecl->setSelfDecl(ActOnParamDeclarator(PI, FnBodyScope));
PI.Ident = &Context.Idents.get("_cmd");