[cfe-commits] r90249 - in /cfe/trunk: lib/CodeGen/CGObjCMac.cpp test/CodeGenObjC/objc2-weak-import-attribute.m
Fariborz Jahanian
fjahanian at apple.com
Tue Dec 1 10:25:24 PST 2009
Author: fjahanian
Date: Tue Dec 1 12:25:24 2009
New Revision: 90249
URL: http://llvm.org/viewvc/llvm-project?rev=90249&view=rev
Log:
(objc2 nonfragile-abi specific). If the translation unit includes an implementation
of a subclass (direct or indirect) of a weak_import root class, emit a weak reference
for the root class's metaclass (should complete radar 6815425).
Modified:
cfe/trunk/lib/CodeGen/CGObjCMac.cpp
cfe/trunk/test/CodeGenObjC/objc2-weak-import-attribute.m
Modified: cfe/trunk/lib/CodeGen/CGObjCMac.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGObjCMac.cpp?rev=90249&r1=90248&r2=90249&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGObjCMac.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGObjCMac.cpp Tue Dec 1 12:25:24 2009
@@ -4134,23 +4134,19 @@
"\01L_OBJC_LABEL_CLASS_$",
"__DATA, __objc_classlist, regular, no_dead_strip");
- bool hasWeakImport = false;
for (unsigned i = 0; i < DefinedClasses.size(); i++) {
llvm::GlobalValue *IMPLGV = DefinedClasses[i];
if (IMPLGV->getLinkage() != llvm::GlobalValue::ExternalWeakLinkage)
continue;
IMPLGV->setLinkage(llvm::GlobalValue::ExternalLinkage);
- hasWeakImport = true;
}
- if (hasWeakImport) {
- for (unsigned i = 0; i < DefinedMetaClasses.size(); i++) {
- llvm::GlobalValue *IMPLGV = DefinedMetaClasses[i];
- if (IMPLGV->getLinkage() != llvm::GlobalValue::ExternalWeakLinkage)
- continue;
- IMPLGV->setLinkage(llvm::GlobalValue::ExternalLinkage);
- }
- }
+ for (unsigned i = 0; i < DefinedMetaClasses.size(); i++) {
+ llvm::GlobalValue *IMPLGV = DefinedMetaClasses[i];
+ if (IMPLGV->getLinkage() != llvm::GlobalValue::ExternalWeakLinkage)
+ continue;
+ IMPLGV->setLinkage(llvm::GlobalValue::ExternalLinkage);
+ }
AddModuleClassList(DefinedNonLazyClasses,
"\01L_OBJC_LABEL_NONLAZY_CLASS_$",
@@ -4437,9 +4433,12 @@
while (const ObjCInterfaceDecl *Super = Root->getSuperClass())
Root = Super;
IsAGV = GetClassGlobal(ObjCMetaClassName + Root->getNameAsString());
+ if (Root->hasAttr<WeakImportAttr>())
+ IsAGV->setLinkage(llvm::GlobalValue::ExternalWeakLinkage);
// work on super class metadata symbol.
std::string SuperClassName =
- ObjCMetaClassName + ID->getClassInterface()->getSuperClass()->getNameAsString();
+ ObjCMetaClassName +
+ ID->getClassInterface()->getSuperClass()->getNameAsString();
SuperClassGV = GetClassGlobal(SuperClassName);
if (ID->getClassInterface()->getSuperClass()->hasAttr<WeakImportAttr>())
SuperClassGV->setLinkage(llvm::GlobalValue::ExternalWeakLinkage);
Modified: cfe/trunk/test/CodeGenObjC/objc2-weak-import-attribute.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenObjC/objc2-weak-import-attribute.m?rev=90249&r1=90248&r2=90249&view=diff
==============================================================================
--- cfe/trunk/test/CodeGenObjC/objc2-weak-import-attribute.m (original)
+++ cfe/trunk/test/CodeGenObjC/objc2-weak-import-attribute.m Tue Dec 1 12:25:24 2009
@@ -1,6 +1,8 @@
// RUN: clang-cc -fobjc-nonfragile-abi -triple x86_64-apple-darwin10 -emit-llvm -o - %s | FileCheck -check-prefix=CHECK-X86-64 %s
-__attribute__((weak_import)) @interface WeakClass
+__attribute__((weak_import)) @interface WeakRootClass @end
+
+__attribute__((weak_import)) @interface WeakClass : WeakRootClass
@end
@interface MySubclass : WeakClass @end
@@ -26,9 +28,21 @@
[WeakClass3 message];
}
+// CHECK-X86-64: OBJC_METACLASS_$_WeakRootClass" = extern_weak global
// CHECK-X86-64: OBJC_METACLASS_$_WeakClass" = extern_weak global
// CHECK-X86-64: OBJC_CLASS_$_WeakClass" = extern_weak global
// CHECK-X86-64: OBJC_CLASS_$_WeakClass1" = extern_weak global
// CHECK-X86-64: OBJC_CLASS_$_WeakClass3" = extern_weak global
+// Root is being implemented here. No extern_weak.
+__attribute__((weak_import)) @interface Root @end
+
+ at interface Super : Root @end
+
+ at interface Sub : Super @end
+
+ at implementation Sub @end
+
+ at implementation Root @end
+// CHECK-NOT-X86-64: OBJC_METACLASS_$_Root" = extern_weak global
More information about the cfe-commits
mailing list