[cfe-commits] r55395 - /cfe/trunk/lib/CodeGen/CGObjCMac.cpp

Daniel Dunbar daniel at zuster.org
Tue Aug 26 16:03:11 PDT 2008


Author: ddunbar
Date: Tue Aug 26 18:03:11 2008
New Revision: 55395

URL: http://llvm.org/viewvc/llvm-project?rev=55395&view=rev
Log:
NeXT: Emit correct properties for category.
 - Was emitting duplicates of class properties instead of the category
   properties.

Modified:
    cfe/trunk/lib/CodeGen/CGObjCMac.cpp

Modified: cfe/trunk/lib/CodeGen/CGObjCMac.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGObjCMac.cpp?rev=55395&r1=55394&r2=55395&view=diff

==============================================================================
--- cfe/trunk/lib/CodeGen/CGObjCMac.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGObjCMac.cpp Tue Aug 26 18:03:11 2008
@@ -787,7 +787,14 @@
 void CGObjCMac::GenerateCategory(const ObjCCategoryImplDecl *OCD) {
   unsigned Size = CGM.getTargetData().getABITypeSize(ObjCTypes.CategoryTy);
 
+  // FIXME: This is poor design, the OCD should have a pointer to the
+  // category decl. Additionally, note that Category can be null for
+  // the @implementation w/o an @interface case. Sema should just
+  // create one for us as it does for @implementation so everyone else
+  // can live life under a clear blue sky.
   const ObjCInterfaceDecl *Interface = OCD->getClassInterface();
+  const ObjCCategoryDecl *Category = 
+    Interface->FindCategoryDeclaration(OCD->getIdentifier());
   std::string ExtName(std::string(Interface->getName()) +
                       "_" +
                       OCD->getName());
@@ -821,9 +828,15 @@
                      Interface->protocol_begin(),
                      Interface->protocol_end());
   Values[5] = llvm::ConstantInt::get(ObjCTypes.IntTy, Size);
-  Values[6] = EmitPropertyList(std::string("\01L_OBJC_$_PROP_LIST_") + ExtName,
-                               Interface->classprop_begin(),
-                               Interface->classprop_end());
+
+  // If there is no category @interface then there can be no properties.
+  if (Category) {
+    Values[6] = EmitPropertyList(std::string("\01L_OBJC_$_PROP_LIST_") + ExtName,
+                                 Category->classprop_begin(),
+                                 Category->classprop_end());
+  } else {
+    Values[6] = llvm::Constant::getNullValue(ObjCTypes.PropertyListPtrTy);
+  }
   
   llvm::Constant *Init = llvm::ConstantStruct::get(ObjCTypes.CategoryTy,
                                                    Values);





More information about the cfe-commits mailing list