]> granicus.if.org Git - clang/commitdiff
Class Property: Fix a crash with old ABI when generating metadata in classes.
authorManman Ren <manman.ren@gmail.com>
Sun, 21 Feb 2016 05:31:05 +0000 (05:31 +0000)
committerManman Ren <manman.ren@gmail.com>
Sun, 21 Feb 2016 05:31:05 +0000 (05:31 +0000)
rdar://23891898

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@261466 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/CGObjCMac.cpp
test/CodeGenObjC/metadata-class-properties.m

index 1f81324d929d5ad43e70082e589ada005860d832..bdaa222f28d4803b60e009ffb0916c16a67b0c2a 100644 (file)
@@ -3446,8 +3446,10 @@ CGObjCMac::EmitClassExtension(const ObjCImplementationDecl *ID,
 
   llvm::Constant *Values[3];
   Values[0] = llvm::ConstantInt::get(ObjCTypes.IntTy, Size);
-  Values[1] = nullptr;
-  if (!isClassProperty)
+  if (isClassProperty) {
+    llvm::Type *PtrTy = CGM.Int8PtrTy;
+    Values[1] = llvm::Constant::getNullValue(PtrTy);
+  } else
     Values[1] = BuildWeakIvarLayout(ID, CharUnits::Zero(), InstanceSize,
                                     hasMRCWeakIvars);
   if (isClassProperty)
index 93557662355fe2800e366c8b900dd61765532503..aa5ed02ebe1b452cc23460d1657ee00b1a263254 100644 (file)
@@ -6,6 +6,9 @@
 // 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_$_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
+
 // CHECK: !{i32 1, !"Objective-C Class Properties", i32 64}
 
 // CHECK-FRAGILE: @"OBJC_$_CLASS_PROP_PROTO_LIST_Proto" = private global {{.*}} section "__OBJC,__property,regular,no_dead_strip", align 8
@@ -13,6 +16,9 @@
 // CHECK-FRAGILE: @"\01l_OBJC_$_CLASS_PROP_LIST_Foo_Category" = private global {{.*}} section "__OBJC,__property,regular,no_dead_strip", align 8
 // CHECK-FRAGILE: @OBJC_CATEGORY_Foo_Category = private global %struct._objc_category { {{.*}}, i32 64, {{.*}} @"\01l_OBJC_$_CLASS_PROP_LIST_Foo_Category" {{.*}} }, section "__OBJC,__category,regular,no_dead_strip", align 8
 
+// CHECK-FRAGILE: @"\01l_OBJC_$_CLASS_PROP_LIST_C" = private global {{.*}} section "__OBJC,__property,regular,no_dead_strip", align 8
+// CHECK-FRAGILE: @OBJC_CLASSEXT_C = private global %struct._objc_class_extension { {{.*}} @"\01l_OBJC_$_CLASS_PROP_LIST_C" {{.*}} }, section "__OBJC,__class_ext,regular,no_dead_strip", align 8
+
 // CHECK-FRAGILE: !{i32 1, !"Objective-C Class Properties", i32 64}
 
 @interface Foo @end
 @implementation Foo (Category)
 +(int)proto_property { return 0; }
 @end
+
+__attribute__((objc_root_class))
+@interface C
+@property(class, readonly) int p;
+@end
+@implementation C
++(int)p { return 1; }
+@end