[cfe-commits] r154753 - in /cfe/trunk: lib/Rewrite/RewriteModernObjC.cpp test/Rewriter/rewrite-modern-protocol-1.mm

Fariborz Jahanian fjahanian at apple.com
Sat Apr 14 10:13:08 PDT 2012


Author: fjahanian
Date: Sat Apr 14 12:13:08 2012
New Revision: 154753

URL: http://llvm.org/viewvc/llvm-project?rev=154753&view=rev
Log:
objective-c modern translator: Make metadata
definition for protocols static. // rdar://11248048


Added:
    cfe/trunk/test/Rewriter/rewrite-modern-protocol-1.mm
Modified:
    cfe/trunk/lib/Rewrite/RewriteModernObjC.cpp

Modified: cfe/trunk/lib/Rewrite/RewriteModernObjC.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Rewrite/RewriteModernObjC.cpp?rev=154753&r1=154752&r2=154753&view=diff
==============================================================================
--- cfe/trunk/lib/Rewrite/RewriteModernObjC.cpp (original)
+++ cfe/trunk/lib/Rewrite/RewriteModernObjC.cpp Sat Apr 14 12:13:08 2012
@@ -5616,13 +5616,11 @@
     // These are currently generated.
     Preamble += "\n#pragma section(\".objc_classlist$B\", long, read, write)\n";
     Preamble += "#pragma section(\".objc_catlist$B\", long, read, write)\n";
-    Preamble += "#pragma section(\".objc_protolist$B\", long, read, write)\n";
     Preamble += "#pragma section(\".objc_imageinfo$B\", long, read, write)\n";
     Preamble += "#pragma section(\".objc_nlclslist$B\", long, read, write)\n";
     Preamble += "#pragma section(\".objc_nlcatlist$B\", long, read, write)\n";
     Preamble += "#pragma section(\".objc_protorefs$B\", long, read, write)\n";
     // These are generated but not necessary for functionality.
-    Preamble += "#pragma section(\".datacoal_nt$B\", long, read, write)\n";
     Preamble += "#pragma section(\".cat_cls_meth$B\", long, read, write)\n";
     Preamble += "#pragma section(\".inst_meth$B\", long, read, write)\n";
     Preamble += "#pragma section(\".cls_meth$B\", long, read, write)\n";
@@ -6593,7 +6591,7 @@
   // Writer out root metadata for current protocol: struct _protocol_t
   Result += "\n";
   if (LangOpts.MicrosoftExt)
-    Result += "__declspec(allocate(\".datacoal_nt$B\")) ";
+    Result += "static ";
   Result += "struct _protocol_t _OBJC_PROTOCOL_";
   Result += PDecl->getNameAsString();
   Result += " __attribute__ ((used, section (\"__DATA,__datacoal_nt,coalesced\"))) = {\n";
@@ -6651,11 +6649,8 @@
   else
     Result += "\t0\n};\n";
   
-  // Use this protocol meta-data to build protocol list table in section
-  // .objc_protolist$B
-  // Unspecified visibility means 'private extern'.
   if (LangOpts.MicrosoftExt)
-    Result += "__declspec(allocate(\".objc_protolist$B\")) ";
+    Result += "static ";
   Result += "struct _protocol_t *";
   Result += "_OBJC_LABEL_PROTOCOL_$_"; Result += PDecl->getNameAsString();
   Result += " = &_OBJC_PROTOCOL_"; Result += PDecl->getNameAsString();

Added: cfe/trunk/test/Rewriter/rewrite-modern-protocol-1.mm
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Rewriter/rewrite-modern-protocol-1.mm?rev=154753&view=auto
==============================================================================
--- cfe/trunk/test/Rewriter/rewrite-modern-protocol-1.mm (added)
+++ cfe/trunk/test/Rewriter/rewrite-modern-protocol-1.mm Sat Apr 14 12:13:08 2012
@@ -0,0 +1,14 @@
+// RUN: %clang_cc1 -E %s -o %t.mm
+// RUN: %clang_cc1 -x objective-c++ -fblocks -fms-extensions -rewrite-objc %t.mm -o - | FileCheck %s
+// rdar://11248048
+
+ at protocol NSCopying @end
+
+ at interface INTF<NSCopying>
+ at end
+
+ at implementation INTF @end
+
+// CHECK: static struct _protocol_t _OBJC_PROTOCOL_NSCopying
+// CHECK: static struct _protocol_t *_OBJC_LABEL_PROTOCOL_$_NSCopying = &_OBJC_PROTOCOL_NSCopying;
+





More information about the cfe-commits mailing list