[PATCH] D73219: [objc_direct] do not add direct properties to the serialization array

Pierre Habouzit via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Jan 22 12:15:06 PST 2020


MadCoder created this revision.
MadCoder added reviewers: ahatanak, arphaman, dexonsmith, erik.pilkington.
MadCoder added a project: clang.
Herald added a subscriber: cfe-commits.

If we do, then the property_list_t length is wrong
and class_getProperty gets very sad.

Radar-Id: rdar://problem/58804805


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D73219

Files:
  clang/lib/CodeGen/CGObjCMac.cpp
  clang/test/CodeGenObjC/direct-properties.m


Index: clang/test/CodeGenObjC/direct-properties.m
===================================================================
--- /dev/null
+++ clang/test/CodeGenObjC/direct-properties.m
@@ -0,0 +1,23 @@
+// RUN: %clang_cc1 -emit-llvm -fobjc-arc -triple x86_64-apple-darwin10 %s -o - | FileCheck %s
+
+__attribute__((objc_root_class))
+ at interface A
+ at property(direct, readonly) int i;
+ at end
+
+__attribute__((objc_root_class))
+ at interface B
+ at property(direct, readonly) int i;
+ at property(readonly) int j;
+ at end
+
+// CHECK-NOT: @"__OBJC_$_PROP_LIST_A"
+ at implementation A
+ at synthesize i = _i;
+ at end
+
+// CHECK: @"_OBJC_$_PROP_LIST_B" = internal global { i32, i32, [1 x %struct._prop_t] } { i32 16, i32 1
+ at implementation B
+ at synthesize i = _i;
+ at synthesize j = _j;
+ at end
Index: clang/lib/CodeGen/CGObjCMac.cpp
===================================================================
--- clang/lib/CodeGen/CGObjCMac.cpp
+++ clang/lib/CodeGen/CGObjCMac.cpp
@@ -3291,6 +3291,8 @@
       for (auto *PD : ClassExt->properties()) {
         if (IsClassProperty != PD->isClassProperty())
           continue;
+        if (PD->isDirectProperty())
+          continue;
         PropertySet.insert(PD->getIdentifier());
         Properties.push_back(PD);
       }
@@ -3302,6 +3304,8 @@
     // class extension.
     if (!PropertySet.insert(PD->getIdentifier()).second)
       continue;
+    if (PD->isDirectProperty())
+      continue;
     Properties.push_back(PD);
   }
 
@@ -3327,8 +3331,6 @@
   values.addInt(ObjCTypes.IntTy, Properties.size());
   auto propertiesArray = values.beginArray(ObjCTypes.PropertyTy);
   for (auto PD : Properties) {
-    if (PD->isDirectProperty())
-      continue;
     auto property = propertiesArray.beginStruct(ObjCTypes.PropertyTy);
     property.add(GetPropertyName(PD->getIdentifier()));
     property.add(GetPropertyTypeString(PD, Container));


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D73219.239667.patch
Type: text/x-patch
Size: 1862 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20200122/11391072/attachment-0001.bin>


More information about the cfe-commits mailing list