r202761 - Objective-C. Fixes a regression when figuring out linkage
Fariborz Jahanian
fjahanian at apple.com
Mon Mar 3 13:53:57 PST 2014
Author: fjahanian
Date: Mon Mar 3 15:53:57 2014
New Revision: 202761
URL: http://llvm.org/viewvc/llvm-project?rev=202761&view=rev
Log:
Objective-C. Fixes a regression when figuring out linkage
for metadata symbols for forward referenced protocols which
are never defined. // rdar://16203115
Added:
cfe/trunk/test/CodeGenObjC/forward-protocol-metadata-symbols.m
Modified:
cfe/trunk/lib/CodeGen/CGObjCMac.cpp
Modified: cfe/trunk/lib/CodeGen/CGObjCMac.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGObjCMac.cpp?rev=202761&r1=202760&r2=202761&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGObjCMac.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGObjCMac.cpp Mon Mar 3 15:53:57 2014
@@ -2660,6 +2660,7 @@ llvm::Constant *CGObjCMac::GetOrEmitProt
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::
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 =
Added: cfe/trunk/test/CodeGenObjC/forward-protocol-metadata-symbols.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenObjC/forward-protocol-metadata-symbols.m?rev=202761&view=auto
==============================================================================
--- cfe/trunk/test/CodeGenObjC/forward-protocol-metadata-symbols.m (added)
+++ cfe/trunk/test/CodeGenObjC/forward-protocol-metadata-symbols.m Mon Mar 3 15:53:57 2014
@@ -0,0 +1,24 @@
+// RUN: %clang_cc1 -emit-llvm -x objective-c %s -o - | FileCheck %s
+// rdar://16203115
+
+ at interface NSObject @end
+
+ at protocol P0;
+
+ at interface A : NSObject <P0>
++(Class) getClass;
+ at end
+
+ at implementation A
++(Class) getClass { return self; }
+ at 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
More information about the cfe-commits
mailing list