diff options
author | Fariborz Jahanian <fjahanian@apple.com> | 2009-11-17 22:42:00 +0000 |
---|---|---|
committer | Fariborz Jahanian <fjahanian@apple.com> | 2009-11-17 22:42:00 +0000 |
commit | 269f8bc10a33e29e2951df7720cad0abb45c74cb (patch) | |
tree | 41f3435111fcd6d3cec2fe7c3964e02b5f935a9a | |
parent | 5fae856de2520b63fd371c281a9d36c1547e17f3 (diff) |
This patch finalizes implementatin of weak_import
objective-c2 classes (radar 6815425).
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@89157 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | lib/CodeGen/CGObjCMac.cpp | 6 | ||||
-rw-r--r-- | test/CodeGenObjC/objc2-weak-import-attribute.m | 34 |
2 files changed, 40 insertions, 0 deletions
diff --git a/lib/CodeGen/CGObjCMac.cpp b/lib/CodeGen/CGObjCMac.cpp index 2a89620ce9..4355e66fee 100644 --- a/lib/CodeGen/CGObjCMac.cpp +++ b/lib/CodeGen/CGObjCMac.cpp @@ -5243,6 +5243,12 @@ llvm::Value *CGObjCNonFragileABIMac::EmitMetaClassRef(CGBuilderTy &Builder, /// decl. llvm::Value *CGObjCNonFragileABIMac::GetClass(CGBuilderTy &Builder, const ObjCInterfaceDecl *ID) { + if (ID->hasAttr<WeakImportAttr>()) { + std::string ClassName(getClassSymbolPrefix() + ID->getNameAsString()); + llvm::GlobalVariable *ClassGV = GetClassGlobal(ClassName); + ClassGV->setLinkage(llvm::GlobalValue::ExternalWeakLinkage); + } + return EmitClassRef(Builder, ID); } diff --git a/test/CodeGenObjC/objc2-weak-import-attribute.m b/test/CodeGenObjC/objc2-weak-import-attribute.m new file mode 100644 index 0000000000..4a5f14e2e0 --- /dev/null +++ b/test/CodeGenObjC/objc2-weak-import-attribute.m @@ -0,0 +1,34 @@ +// 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 +@end + +@interface MySubclass : WeakClass @end + +@implementation MySubclass @end + +@implementation WeakClass(MyCategory) @end + + +__attribute__((weak_import)) +@interface WeakClass1 @end + +@implementation WeakClass1(MyCategory) @end + +@implementation WeakClass1(YourCategory) @end + + __attribute__((weak_import)) +@interface WeakClass3 ++ message; +@end + +int main() { + [WeakClass3 message]; +} + +// 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 + + |