forked from OSchip/llvm-project
Objective-C: Add a size field to non-fragile category metadata.
This is mainly for extensibility. Note that fragile category metadata, metadata for classes and protocols all have a size field. Initial patch was provided by Greg Parker. rdar://problem/24804226 llvm-svn: 261756
This commit is contained in:
parent
6c317515e4
commit
42ff39051d
|
@ -5581,6 +5581,7 @@ ObjCNonFragileABITypesHelper::ObjCNonFragileABITypesHelper(CodeGen::CodeGenModul
|
|||
// const struct _protocol_list_t * const protocols;
|
||||
// const struct _prop_list_t * const properties;
|
||||
// const struct _prop_list_t * const class_properties;
|
||||
// const uint32_t size;
|
||||
// }
|
||||
CategorynfABITy = llvm::StructType::create("struct._category_t",
|
||||
Int8PtrTy, ClassnfABIPtrTy,
|
||||
|
@ -5589,6 +5590,7 @@ ObjCNonFragileABITypesHelper::ObjCNonFragileABITypesHelper(CodeGen::CodeGenModul
|
|||
ProtocolListnfABIPtrTy,
|
||||
PropertyListPtrTy,
|
||||
PropertyListPtrTy,
|
||||
IntTy,
|
||||
nullptr);
|
||||
|
||||
// New types for nonfragile abi messaging.
|
||||
|
@ -6140,6 +6142,7 @@ llvm::Value *CGObjCNonFragileABIMac::GenerateProtocolRef(CodeGenFunction &CGF,
|
|||
/// const struct _protocol_list_t * const protocols;
|
||||
/// const struct _prop_list_t * const properties;
|
||||
/// const struct _prop_list_t * const class_properties;
|
||||
/// const uint32_t size;
|
||||
/// }
|
||||
///
|
||||
void CGObjCNonFragileABIMac::GenerateCategory(const ObjCCategoryImplDecl *OCD) {
|
||||
|
@ -6154,7 +6157,7 @@ void CGObjCNonFragileABIMac::GenerateCategory(const ObjCCategoryImplDecl *OCD) {
|
|||
llvm::SmallString<64> ExtClassName(getClassSymbolPrefix());
|
||||
ExtClassName += Interface->getObjCRuntimeNameAsString();
|
||||
|
||||
llvm::Constant *Values[7];
|
||||
llvm::Constant *Values[8];
|
||||
Values[0] = GetClassName(OCD->getIdentifier()->getName());
|
||||
// meta-class entry symbol
|
||||
llvm::GlobalVariable *ClassGV =
|
||||
|
@ -6212,6 +6215,9 @@ void CGObjCNonFragileABIMac::GenerateCategory(const ObjCCategoryImplDecl *OCD) {
|
|||
Values[6] = llvm::Constant::getNullValue(ObjCTypes.PropertyListPtrTy);
|
||||
}
|
||||
|
||||
unsigned Size = CGM.getDataLayout().getTypeAllocSize(ObjCTypes.CategorynfABITy);
|
||||
Values[7] = llvm::ConstantInt::get(ObjCTypes.IntTy, Size);
|
||||
|
||||
llvm::Constant *Init =
|
||||
llvm::ConstantStruct::get(ObjCTypes.CategorynfABITy,
|
||||
Values);
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
// CHECK: @"\01l_OBJC_$_CLASS_PROP_LIST_Proto" = private global {{.*}} section "__DATA, __objc_const", align 8
|
||||
// CHECK: @"\01l_OBJC_PROTOCOL_$_Proto" = {{.*}} global %struct._protocol_t { {{.*}} i32 96, i32 {{.*}} @"\01l_OBJC_$_CLASS_PROP_LIST_Proto" {{.*}} }
|
||||
// CHECK: @"\01l_OBJC_$_CLASS_PROP_LIST_Foo_$_Category" = private global {{.*}} section "__DATA, __objc_const", align 8
|
||||
// CHECK: @"\01l_OBJC_$_CATEGORY_Foo_$_Category" = private global %struct._category_t { {{.*}} @"\01l_OBJC_$_CLASS_PROP_LIST_Foo_$_Category" {{.*}} }, section "__DATA, __objc_const", align 8
|
||||
// CHECK: @"\01l_OBJC_$_CATEGORY_Foo_$_Category" = private global %struct._category_t { {{.*}} @"\01l_OBJC_$_CLASS_PROP_LIST_Foo_$_Category" {{.*}}, i32 64 }, section "__DATA, __objc_const", align 8
|
||||
|
||||
// CHECK: @"\01l_OBJC_$_CLASS_PROP_LIST_C" = private global {{.*}} section "__DATA, __objc_const", align 8
|
||||
// CHECK: @"\01l_OBJC_METACLASS_RO_$_C" = private global %struct._class_ro_t { {{.*}} @"\01l_OBJC_$_CLASS_PROP_LIST_C" {{.*}} }, section "__DATA, __objc_const", align 8
|
||||
|
|
Loading…
Reference in New Issue