Skip to content

Commit 61212a0

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 (cherry picked from commit 52311d0)
1 parent 85b9220 commit 61212a0

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
@@ -3292,6 +3292,8 @@ llvm::Constant *CGObjCCommonMac::EmitPropertyList(Twine Name,
32923292
for (auto *PD : ClassExt->properties()) {
32933293
if (IsClassProperty != PD->isClassProperty())
32943294
continue;
3295+
if (PD->isDirectProperty())
3296+
continue;
32953297
PropertySet.insert(PD->getIdentifier());
32963298
Properties.push_back(PD);
32973299
}
@@ -3303,6 +3305,8 @@ llvm::Constant *CGObjCCommonMac::EmitPropertyList(Twine Name,
33033305
// class extension.
33043306
if (!PropertySet.insert(PD->getIdentifier()).second)
33053307
continue;
3308+
if (PD->isDirectProperty())
3309+
continue;
33063310
Properties.push_back(PD);
33073311
}
33083312

@@ -3328,8 +3332,6 @@ llvm::Constant *CGObjCCommonMac::EmitPropertyList(Twine Name,
33283332
values.addInt(ObjCTypes.IntTy, Properties.size());
33293333
auto propertiesArray = values.beginArray(ObjCTypes.PropertyTy);
33303334
for (auto PD : Properties) {
3331-
if (PD->isDirectProperty())
3332-
continue;
33333335
auto property = propertiesArray.beginStruct(ObjCTypes.PropertyTy);
33343336
property.add(GetPropertyName(PD->getIdentifier()));
33353337
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)