]> granicus.if.org Git - clang/commitdiff
Don't crash if defining -dealloc in a category.
authorJohn McCall <rjmccall@apple.com>
Wed, 13 Jul 2011 18:26:47 +0000 (18:26 +0000)
committerJohn McCall <rjmccall@apple.com>
Wed, 13 Jul 2011 18:26:47 +0000 (18:26 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@135054 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/CGObjC.cpp
test/CodeGenObjC/arc.m

index f64ff9766f9cb3c5f1ab238be9d4089cbb4e90f6..426cca00140c724b24c73afa6cbf939db600b5ad 100644 (file)
@@ -220,11 +220,13 @@ namespace {
 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 @@ struct FinishARCDealloc : EHScopeStack::Cleanup {
                                                       CGF.getContext().VoidTy,
                                                       method->getSelector(),
                                                       iface,
-                                                      /*is category*/ false,
+                                                      isCategory,
                                                       self,
                                                       /*is class msg*/ false,
                                                       args,
index 2431866ef0fab848250aef1c16de15faf40f085e..407b3eb771673b951a53efd0abdab9770f7cbf97 100644 (file)
@@ -1542,3 +1542,13 @@ void test54(int first, ...) {
   // CHECK: call void @objc_release
   // CHECK: ret void
 }
+
+// PR10228
+@interface Test55Base @end
+@interface Test55 : Test55Base @end
+@implementation Test55 (Category)
+- (void) dealloc {}
+@end
+// CHECK:   define internal void @"\01-[Test55(Category) dealloc]"(
+// CHECK-NOT: ret
+// CHECK:     call void bitcast (i8* ({{%.*}}*, i8*, ...)* @objc_msgSendSuper2 to void ({{%.*}}*, i8*)*)(