[cfe-commits] r44072 - in /cfe/trunk: Driver/RewriteTest.cpp test/Sema/metadata-test-1.m

Fariborz Jahanian fjahanian at apple.com
Tue Nov 13 14:09:49 PST 2007


Author: fjahanian
Date: Tue Nov 13 16:09:49 2007
New Revision: 44072

URL: http://llvm.org/viewvc/llvm-project?rev=44072&view=rev
Log:
Fixed a rewrite of metadata bug when category implementation has no matching interface.

Added:
    cfe/trunk/test/Sema/metadata-test-1.m
Modified:
    cfe/trunk/Driver/RewriteTest.cpp

Modified: cfe/trunk/Driver/RewriteTest.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Driver/RewriteTest.cpp?rev=44072&r1=44071&r2=44072&view=diff

==============================================================================
--- cfe/trunk/Driver/RewriteTest.cpp (original)
+++ cfe/trunk/Driver/RewriteTest.cpp Tue Nov 13 16:09:49 2007
@@ -1221,7 +1221,6 @@
     Result += MethodInternalNames[Methods[0]];
     Result += "}\n";
     for (int i = 1; i < NumMethods; i++) {
-      // TODO: Need method address as 3rd initializer.
       Result += "\t  ,{(SEL)\"";
       Result += Methods[i]->getSelector().getName().c_str();
       std::string MethodTypeString;
@@ -1415,8 +1414,7 @@
        CDecl = CDecl->getNextClassCategory())
     if (CDecl->getIdentifier() == IDecl->getIdentifier())
       break;
-  assert(CDecl && "RewriteObjcCategoryImplDecl - bad category");
-  
+    
   char *FullCategoryName = (char*)alloca(
     strlen(ClassDecl->getName()) + strlen(IDecl->getName()) + 2);
   sprintf(FullCategoryName, "%s_%s", ClassDecl->getName(), IDecl->getName());
@@ -1434,10 +1432,12 @@
                              "CATEGORY_", FullCategoryName, Result);
   
   // Protocols referenced in class declaration?
-  RewriteObjcProtocolsMetaData(CDecl->getReferencedProtocols(),
-                               CDecl->getNumReferencedProtocols(),
-                               "CATEGORY",
-                               FullCategoryName, Result);
+  // Null CDecl is case of a category implementation with no category interface
+  if (CDecl)
+    RewriteObjcProtocolsMetaData(CDecl->getReferencedProtocols(),
+                                 CDecl->getNumReferencedProtocols(),
+                                 "CATEGORY",
+                                 FullCategoryName, Result);
   
   /* struct _objc_category {
    char *category_name;
@@ -1490,7 +1490,7 @@
   else
     Result += "\t, 0\n";
   
-  if (CDecl->getNumReferencedProtocols() > 0) {
+  if (CDecl && CDecl->getNumReferencedProtocols() > 0) {
     Result += "\t, (struct _objc_protocol_list *)&_OBJC_CATEGORY_PROTOCOLS_"; 
     Result += FullCategoryName;
     Result += "\n";

Added: cfe/trunk/test/Sema/metadata-test-1.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/metadata-test-1.m?rev=44072&view=auto

==============================================================================
--- cfe/trunk/test/Sema/metadata-test-1.m (added)
+++ cfe/trunk/test/Sema/metadata-test-1.m Tue Nov 13 16:09:49 2007
@@ -0,0 +1,12 @@
+// RUN: clang -rewrite-test %s
+
+ at interface Intf 
+ at end
+
+ at implementation Intf(Category)
+- (void) CatMeth {}
+ at end
+
+ at implementation Another
+- (void) CatMeth {}
+ at end





More information about the cfe-commits mailing list