[cfe-commits] r47767 - /cfe/trunk/Sema/SemaDeclObjC.cpp

Gabor Greif ggreif at gmail.com
Fri Feb 29 12:35:55 PST 2008


Author: ggreif
Date: Fri Feb 29 14:35:55 2008
New Revision: 47767

URL: http://llvm.org/viewvc/llvm-project?rev=47767&view=rev
Log:
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

Modified:
    cfe/trunk/Sema/SemaDeclObjC.cpp

Modified: cfe/trunk/Sema/SemaDeclObjC.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Sema/SemaDeclObjC.cpp?rev=47767&r1=47766&r2=47767&view=diff

==============================================================================
--- cfe/trunk/Sema/SemaDeclObjC.cpp (original)
+++ cfe/trunk/Sema/SemaDeclObjC.cpp Fri Feb 29 14:35:55 2008
@@ -43,17 +43,18 @@
   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");





More information about the cfe-commits mailing list