[cfe-commits] r135054 - in /cfe/trunk: lib/CodeGen/CGObjC.cpp test/CodeGenObjC/arc.m

John McCall rjmccall at apple.com
Wed Jul 13 11:26:47 PDT 2011


Author: rjmccall
Date: Wed Jul 13 13:26:47 2011
New Revision: 135054

URL: http://llvm.org/viewvc/llvm-project?rev=135054&view=rev
Log:
Don't crash if defining -dealloc in a category.


Modified:
    cfe/trunk/lib/CodeGen/CGObjC.cpp
    cfe/trunk/test/CodeGenObjC/arc.m

Modified: cfe/trunk/lib/CodeGen/CGObjC.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGObjC.cpp?rev=135054&r1=135053&r2=135054&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGObjC.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGObjC.cpp Wed Jul 13 13:26:47 2011
@@ -220,11 +220,13 @@
 struct FinishARCDealloc : EHScopeStack::Cleanup {
   void Emit(CodeGenFunction &CGF, Flags flags) {
     const ObjCMethodDecl *method = cast<ObjCMethodDecl>(CGF.CurCodeDecl);
-    const ObjCImplementationDecl *impl
-      = cast<ObjCImplementationDecl>(method->getDeclContext());
+
+    const ObjCImplDecl *impl = cast<ObjCImplDecl>(method->getDeclContext());
     const ObjCInterfaceDecl *iface = impl->getClassInterface();
     if (!iface->getSuperClass()) return;
 
+    bool isCategory = isa<ObjCCategoryImplDecl>(impl);
+
     // Call [super dealloc] if we have a superclass.
     llvm::Value *self = CGF.LoadObjCSelf();
 
@@ -233,7 +235,7 @@
                                                       CGF.getContext().VoidTy,
                                                       method->getSelector(),
                                                       iface,
-                                                      /*is category*/ false,
+                                                      isCategory,
                                                       self,
                                                       /*is class msg*/ false,
                                                       args,

Modified: cfe/trunk/test/CodeGenObjC/arc.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenObjC/arc.m?rev=135054&r1=135053&r2=135054&view=diff
==============================================================================
--- cfe/trunk/test/CodeGenObjC/arc.m (original)
+++ cfe/trunk/test/CodeGenObjC/arc.m Wed Jul 13 13:26:47 2011
@@ -1542,3 +1542,13 @@
   // CHECK: call void @objc_release
   // CHECK: ret void
 }
+
+// PR10228
+ at interface Test55Base @end
+ at interface Test55 : Test55Base @end
+ at implementation Test55 (Category)
+- (void) dealloc {}
+ at end
+// CHECK:   define internal void @"\01-[Test55(Category) dealloc]"(
+// CHECK-NOT: ret
+// CHECK:     call void bitcast (i8* ({{%.*}}*, i8*, ...)* @objc_msgSendSuper2 to void ({{%.*}}*, i8*)*)(





More information about the cfe-commits mailing list