r261466 - Class Property: Fix a crash with old ABI when generating metadata in classes.

Manman Ren via cfe-commits cfe-commits at lists.llvm.org
Sat Feb 20 21:31:06 PST 2016


Author: mren
Date: Sat Feb 20 23:31:05 2016
New Revision: 261466

URL: http://llvm.org/viewvc/llvm-project?rev=261466&view=rev
Log:
Class Property: Fix a crash with old ABI when generating metadata in classes.

rdar://23891898

Modified:
    cfe/trunk/lib/CodeGen/CGObjCMac.cpp
    cfe/trunk/test/CodeGenObjC/metadata-class-properties.m

Modified: cfe/trunk/lib/CodeGen/CGObjCMac.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGObjCMac.cpp?rev=261466&r1=261465&r2=261466&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGObjCMac.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGObjCMac.cpp Sat Feb 20 23:31:05 2016
@@ -3446,8 +3446,10 @@ CGObjCMac::EmitClassExtension(const ObjC
 
   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)

Modified: cfe/trunk/test/CodeGenObjC/metadata-class-properties.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenObjC/metadata-class-properties.m?rev=261466&r1=261465&r2=261466&view=diff
==============================================================================
--- cfe/trunk/test/CodeGenObjC/metadata-class-properties.m (original)
+++ cfe/trunk/test/CodeGenObjC/metadata-class-properties.m Sat Feb 20 23:31:05 2016
@@ -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
@@ -26,3 +32,11 @@
 @implementation Foo (Category)
 +(int)proto_property { return 0; }
 @end
+
+__attribute__((objc_root_class))
+ at interface C
+ at property(class, readonly) int p;
+ at end
+ at implementation C
++(int)p { return 1; }
+ at end




More information about the cfe-commits mailing list