Skip to content

Commit 52311d0

Browse files
committed
[objc_direct] do not add direct properties to the serialization array
If we do, then the property_list_t length is wrong and class_getProperty gets very sad. Signed-off-by: Pierre Habouzit <[email protected]> Radar-Id: rdar://problem/58804805 Differential Revision: https://reviews.llvm.org/D73219
1 parent 7596d3c commit 52311d0

File tree

2 files changed

+27
-2
lines changed

2 files changed

+27
-2
lines changed

clang/lib/CodeGen/CGObjCMac.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3291,6 +3291,8 @@ llvm::Constant *CGObjCCommonMac::EmitPropertyList(Twine Name,
32913291
for (auto *PD : ClassExt->properties()) {
32923292
if (IsClassProperty != PD->isClassProperty())
32933293
continue;
3294+
if (PD->isDirectProperty())
3295+
continue;
32943296
PropertySet.insert(PD->getIdentifier());
32953297
Properties.push_back(PD);
32963298
}
@@ -3302,6 +3304,8 @@ llvm::Constant *CGObjCCommonMac::EmitPropertyList(Twine Name,
33023304
// class extension.
33033305
if (!PropertySet.insert(PD->getIdentifier()).second)
33043306
continue;
3307+
if (PD->isDirectProperty())
3308+
continue;
33053309
Properties.push_back(PD);
33063310
}
33073311

@@ -3327,8 +3331,6 @@ llvm::Constant *CGObjCCommonMac::EmitPropertyList(Twine Name,
33273331
values.addInt(ObjCTypes.IntTy, Properties.size());
33283332
auto propertiesArray = values.beginArray(ObjCTypes.PropertyTy);
33293333
for (auto PD : Properties) {
3330-
if (PD->isDirectProperty())
3331-
continue;
33323334
auto property = propertiesArray.beginStruct(ObjCTypes.PropertyTy);
33333335
property.add(GetPropertyName(PD->getIdentifier()));
33343336
property.add(GetPropertyTypeString(PD, Container));
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
// RUN: %clang_cc1 -emit-llvm -fobjc-arc -triple x86_64-apple-darwin10 %s -o - | FileCheck %s
2+
3+
__attribute__((objc_root_class))
4+
@interface A
5+
@property(direct, readonly) int i;
6+
@end
7+
8+
__attribute__((objc_root_class))
9+
@interface B
10+
@property(direct, readonly) int i;
11+
@property(readonly) int j;
12+
@end
13+
14+
// CHECK-NOT: @"__OBJC_$_PROP_LIST_A"
15+
@implementation A
16+
@synthesize i = _i;
17+
@end
18+
19+
// CHECK: @"_OBJC_$_PROP_LIST_B" = internal global { i32, i32, [1 x %struct._prop_t] } { i32 16, i32 1
20+
@implementation B
21+
@synthesize i = _i;
22+
@synthesize j = _j;
23+
@end

0 commit comments

Comments
 (0)