[cfe-commits] r64699 - /cfe/branches/Apple/objective-rewrite/tools/clang/Driver/RewriteObjC.cpp

Steve Naroff snaroff at apple.com
Mon Feb 16 15:25:47 PST 2009


Author: snaroff
Date: Mon Feb 16 17:25:47 2009
New Revision: 64699

URL: http://llvm.org/viewvc/llvm-project?rev=64699&view=rev
Log:
Generate metadata for @protocol(expr) at the top of the file.
A little unconventional, however it avoids the extern/static, static/static rathole in C++.

Modified:
    cfe/branches/Apple/objective-rewrite/tools/clang/Driver/RewriteObjC.cpp

Modified: cfe/branches/Apple/objective-rewrite/tools/clang/Driver/RewriteObjC.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/Apple/objective-rewrite/tools/clang/Driver/RewriteObjC.cpp?rev=64699&r1=64698&r2=64699&view=diff

==============================================================================
--- cfe/branches/Apple/objective-rewrite/tools/clang/Driver/RewriteObjC.cpp (original)
+++ cfe/branches/Apple/objective-rewrite/tools/clang/Driver/RewriteObjC.cpp Mon Feb 16 17:25:47 2009
@@ -2835,8 +2835,8 @@
      char *method_types;
      }
      */
-    Result += "\nstruct protocol_methods {\n";
-    Result += "\tSEL _cmd;\n";
+    Result += "\nstruct _protocol_methods {\n";
+    Result += "\tstruct objc_selector *_cmd;\n";
     Result += "\tchar *method_types;\n";
     Result += "};\n";
     
@@ -2855,7 +2855,7 @@
      */
     Result += "\nstatic struct {\n";
     Result += "\tint protocol_method_count;\n";
-    Result += "\tstruct protocol_methods protocol_methods[";
+    Result += "\tstruct _protocol_methods protocol_methods[";
     Result += utostr(NumMethods);
     Result += "];\n} _OBJC_PROTOCOL_INSTANCE_METHODS_";
     Result += PDecl->getNameAsString();
@@ -2866,9 +2866,9 @@
     for (ObjCProtocolDecl::instmeth_iterator I = PDecl->instmeth_begin(), 
          E = PDecl->instmeth_end(); I != E; ++I) {
       if (I == PDecl->instmeth_begin())
-        Result += "\t  ,{{(SEL)\"";
+        Result += "\t  ,{{(struct objc_selector *)\"";
       else
-        Result += "\t  ,{(SEL)\"";
+        Result += "\t  ,{(struct objc_selector *)\"";
       Result += (*I)->getSelector().getAsString().c_str();
       std::string MethodTypeString;
       Context->getObjCEncodingForMethodDecl((*I), MethodTypeString);
@@ -2889,7 +2889,7 @@
      */
     Result += "\nstatic struct {\n";
     Result += "\tint protocol_method_count;\n";
-    Result += "\tstruct protocol_methods protocol_methods[";
+    Result += "\tstruct _protocol_methods protocol_methods[";
     Result += utostr(NumMethods);
     Result += "];\n} _OBJC_PROTOCOL_CLASS_METHODS_";
     Result += PDecl->getNameAsString();
@@ -2902,9 +2902,9 @@
     for (ObjCProtocolDecl::classmeth_iterator I = PDecl->classmeth_begin(), 
          E = PDecl->classmeth_end(); I != E; ++I) {
       if (I == PDecl->classmeth_begin())
-        Result += "\t  ,{{(SEL)\"";
+        Result += "\t  ,{{(struct objc_selector *)\"";
       else
-        Result += "\t  ,{(SEL)\"";
+        Result += "\t  ,{(struct objc_selector *)\"";
       Result += (*I)->getSelector().getAsString().c_str();
       std::string MethodTypeString;
       Context->getObjCEncodingForMethodDecl((*I), MethodTypeString);
@@ -3383,11 +3383,6 @@
   for (int i = 0; i < CatDefCount; i++)
     RewriteObjCCategoryImplDecl(CategoryImplementation[i], Result);
 
-  // Write out meta data for each @protocol(<expr>).
-  for (llvm::SmallPtrSet<ObjCProtocolDecl *,8>::iterator I = ProtocolExprDecls.begin(), 
-       E = ProtocolExprDecls.end(); I != E; ++I) {
-        RewriteObjCProtocolMetaData(*I, "", "", Result);
-  }
   // Write objc_symtab metadata
   /*
    struct _objc_symtab
@@ -4546,11 +4541,8 @@
   // Here's a great place to add any extra declarations that may be needed.
   // Write out meta data for each @protocol(<expr>).
   for (llvm::SmallPtrSet<ObjCProtocolDecl *,8>::iterator I = ProtocolExprDecls.begin(), 
-       E = ProtocolExprDecls.end(); I != E; ++I) {
-    Preamble += "\nextern struct _objc_protocol _OBJC_PROTOCOL_";
-    Preamble += (*I)->getNameAsString();
-    Preamble += ";\n";
-  }
+       E = ProtocolExprDecls.end(); I != E; ++I)
+    RewriteObjCProtocolMetaData(*I, "", "", Preamble);
 
   InsertText(SM->getLocForStartOfFile(MainFileID), 
              Preamble.c_str(), Preamble.size(), false);





More information about the cfe-commits mailing list