]> granicus.if.org Git - clang/commitdiff
Fix a crash where PI.TypeInfo has not been filled in case of missing ObjCInterfaceDecl.
authorGabor Greif <ggreif@gmail.com>
Fri, 29 Feb 2008 20:35:55 +0000 (20:35 +0000)
committerGabor Greif <ggreif@gmail.com>
Fri, 29 Feb 2008 20:35:55 +0000 (20:35 +0000)
Happens with Xcode 2.4.1 headers on test
Parser/objc-foreach-error-1.m

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@47767 91177308-0d34-0410-b5e6-96231b3b80d8

Sema/SemaDeclObjC.cpp

index 85797a5373e0d57781236de692507f84c90262ca..267a9ef789640c2dca574d5cf32f2875cc6a5bf4 100644 (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");