forked from OSchip/llvm-project
Objective-C IRGen. Patch to generate a weak symbol reference when
'super' dispatches a class method in category for OBJC_METACLASS. This is when class is a weak_import class. // rdar://16529125 llvm-svn: 210547
This commit is contained in:
parent
063d4fba36
commit
0b3bc24e39
|
@ -1389,7 +1389,7 @@ private:
|
||||||
/// EmitMetaClassRef - Return a Value * of the address of _class_t
|
/// EmitMetaClassRef - Return a Value * of the address of _class_t
|
||||||
/// meta-data
|
/// meta-data
|
||||||
llvm::Value *EmitMetaClassRef(CodeGenFunction &CGF,
|
llvm::Value *EmitMetaClassRef(CodeGenFunction &CGF,
|
||||||
const ObjCInterfaceDecl *ID);
|
const ObjCInterfaceDecl *ID, bool Weak);
|
||||||
|
|
||||||
/// ObjCIvarOffsetVariable - Returns the ivar offset variable for
|
/// ObjCIvarOffsetVariable - Returns the ivar offset variable for
|
||||||
/// the given ivar.
|
/// the given ivar.
|
||||||
|
@ -6702,13 +6702,15 @@ CGObjCNonFragileABIMac::EmitSuperClassRef(CodeGenFunction &CGF,
|
||||||
/// meta-data
|
/// meta-data
|
||||||
///
|
///
|
||||||
llvm::Value *CGObjCNonFragileABIMac::EmitMetaClassRef(CodeGenFunction &CGF,
|
llvm::Value *CGObjCNonFragileABIMac::EmitMetaClassRef(CodeGenFunction &CGF,
|
||||||
const ObjCInterfaceDecl *ID) {
|
const ObjCInterfaceDecl *ID,
|
||||||
|
bool Weak) {
|
||||||
llvm::GlobalVariable * &Entry = MetaClassReferences[ID->getIdentifier()];
|
llvm::GlobalVariable * &Entry = MetaClassReferences[ID->getIdentifier()];
|
||||||
if (!Entry) {
|
if (!Entry) {
|
||||||
|
|
||||||
std::string MetaClassName(getMetaclassSymbolPrefix() +
|
std::string MetaClassName(getMetaclassSymbolPrefix() +
|
||||||
ID->getNameAsString());
|
ID->getNameAsString());
|
||||||
llvm::GlobalVariable *MetaClassGV = GetClassGlobal(MetaClassName);
|
llvm::GlobalVariable *MetaClassGV =
|
||||||
|
GetClassGlobal(MetaClassName, Weak);
|
||||||
Entry = new llvm::GlobalVariable(CGM.getModule(), ObjCTypes.ClassnfABIPtrTy,
|
Entry = new llvm::GlobalVariable(CGM.getModule(), ObjCTypes.ClassnfABIPtrTy,
|
||||||
false, llvm::GlobalValue::PrivateLinkage,
|
false, llvm::GlobalValue::PrivateLinkage,
|
||||||
MetaClassGV,
|
MetaClassGV,
|
||||||
|
@ -6766,7 +6768,8 @@ CGObjCNonFragileABIMac::GenerateMessageSendSuper(CodeGen::CodeGenFunction &CGF,
|
||||||
// If this is a class message the metaclass is passed as the target.
|
// If this is a class message the metaclass is passed as the target.
|
||||||
llvm::Value *Target;
|
llvm::Value *Target;
|
||||||
if (IsClassMessage)
|
if (IsClassMessage)
|
||||||
Target = EmitMetaClassRef(CGF, Class);
|
Target = EmitMetaClassRef(CGF, Class,
|
||||||
|
(isCategoryImpl && Class->isWeakImported()));
|
||||||
else
|
else
|
||||||
Target = EmitSuperClassRef(CGF, Class);
|
Target = EmitSuperClassRef(CGF, Class);
|
||||||
|
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
|
|
||||||
@interface NSObject
|
@interface NSObject
|
||||||
- (void) finalize;
|
- (void) finalize;
|
||||||
|
+ (void) class;
|
||||||
@end
|
@end
|
||||||
|
|
||||||
__attribute__((availability(macosx,introduced=9876.5)))
|
__attribute__((availability(macosx,introduced=9876.5)))
|
||||||
|
@ -31,3 +32,14 @@ void kit()
|
||||||
// CHECK: @"OBJC_METACLASS_$_MyClass" = global %struct._class_t
|
// CHECK: @"OBJC_METACLASS_$_MyClass" = global %struct._class_t
|
||||||
// CHECK: @"OBJC_CLASS_$_NSObject" = external global %struct._class_t
|
// CHECK: @"OBJC_CLASS_$_NSObject" = external global %struct._class_t
|
||||||
|
|
||||||
|
// rdar://16529125
|
||||||
|
__attribute__((weak_import))
|
||||||
|
@interface NSURLQueryItem : NSObject
|
||||||
|
@end
|
||||||
|
|
||||||
|
@implementation NSURLQueryItem (hax)
|
||||||
|
+(void)classmethod { [super class]; }
|
||||||
|
@end
|
||||||
|
|
||||||
|
// CHECK: @"OBJC_METACLASS_$_NSURLQueryItem" = extern_weak global
|
||||||
|
// CHECK: @"OBJC_CLASS_$_NSURLQueryItem" = extern_weak global
|
||||||
|
|
Loading…
Reference in New Issue