summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lib/Rewrite/RewriteModernObjC.cpp9
-rw-r--r--test/Rewriter/rewrite-modern-protocol-1.mm14
2 files changed, 16 insertions, 7 deletions
diff --git a/lib/Rewrite/RewriteModernObjC.cpp b/lib/Rewrite/RewriteModernObjC.cpp
index b783c92dc7..b3d85a4ad3 100644
--- a/lib/Rewrite/RewriteModernObjC.cpp
+++ b/lib/Rewrite/RewriteModernObjC.cpp
@@ -5616,13 +5616,11 @@ void RewriteModernObjC::Initialize(ASTContext &context) {
// 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 @@ void RewriteModernObjC::RewriteObjCProtocolMetaData(ObjCProtocolDecl *PDecl,
// 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 @@ void RewriteModernObjC::RewriteObjCProtocolMetaData(ObjCProtocolDecl *PDecl,
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();
diff --git a/test/Rewriter/rewrite-modern-protocol-1.mm b/test/Rewriter/rewrite-modern-protocol-1.mm
new file mode 100644
index 0000000000..7b737fe61d
--- /dev/null
+++ b/test/Rewriter/rewrite-modern-protocol-1.mm
@@ -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
+
+@protocol NSCopying @end
+
+@interface INTF<NSCopying>
+@end
+
+@implementation INTF @end
+
+// CHECK: static struct _protocol_t _OBJC_PROTOCOL_NSCopying
+// CHECK: static struct _protocol_t *_OBJC_LABEL_PROTOCOL_$_NSCopying = &_OBJC_PROTOCOL_NSCopying;
+