summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--clang/lib/CodeGen/CGObjCMac.cpp3
-rw-r--r--clang/test/CodeGenObjC/forward-protocol-metadata-symbols.m24
2 files changed, 26 insertions, 1 deletions
diff --git a/clang/lib/CodeGen/CGObjCMac.cpp b/clang/lib/CodeGen/CGObjCMac.cpp
index 044bc18c1e7..7f2432c08c7 100644
--- a/clang/lib/CodeGen/CGObjCMac.cpp
+++ b/clang/lib/CodeGen/CGObjCMac.cpp
@@ -2660,6 +2660,7 @@ llvm::Constant *CGObjCMac::GetOrEmitProtocol(const ObjCProtocolDecl *PD) {
if (Entry) {
// Already created, fix the linkage and update the initializer.
+ Entry->setLinkage(llvm::GlobalValue::PrivateLinkage);
Entry->setInitializer(Init);
} else {
Entry =
@@ -6357,7 +6358,7 @@ llvm::Constant *CGObjCNonFragileABIMac::GetOrEmitProtocol(
if (Entry) {
// Already created, fix the linkage and update the initializer.
- assert(Entry->getLinkage() == llvm::GlobalValue::WeakAnyLinkage);
+ Entry->setLinkage(llvm::GlobalValue::WeakAnyLinkage);
Entry->setInitializer(Init);
} else {
Entry =
diff --git a/clang/test/CodeGenObjC/forward-protocol-metadata-symbols.m b/clang/test/CodeGenObjC/forward-protocol-metadata-symbols.m
new file mode 100644
index 00000000000..c28adb3f8aa
--- /dev/null
+++ b/clang/test/CodeGenObjC/forward-protocol-metadata-symbols.m
@@ -0,0 +1,24 @@
+// RUN: %clang_cc1 -emit-llvm -x objective-c %s -o - | FileCheck %s
+// rdar://16203115
+
+@interface NSObject @end
+
+@protocol P0;
+
+@interface A : NSObject <P0>
++(Class) getClass;
+@end
+
+@implementation A
++(Class) getClass { return self; }
+@end
+
+int main() {
+ Protocol *P0 = @protocol(P0);
+ return 0;
+}
+
+// CHECK: @"\01l_OBJC_PROTOCOL_$_P0" = weak hidden global
+// CHECK: @"\01l_OBJC_CLASS_PROTOCOLS_$_A" = private global
+// CHECK: @"\01l_OBJC_LABEL_PROTOCOL_$_P0" = weak hidden global
+// CHECK: @"\01l_OBJC_PROTOCOL_REFERENCE_$_P0" = weak hidden global
OpenPOWER on IntegriCloud