Skip to content
This repository was archived by the owner on Nov 1, 2021. It is now read-only.

Commit 0fd4a68

Browse files
committed
[arcmt] Fix a bug where a property in a class extension, that did not exist
in the interface, got its attribute rewritten twice, resulting in 'weakweak' or 'strongstrong'. rdar://11047179 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@153621 91177308-0d34-0410-b5e6-96231b3b80d8
1 parent dde3bdb commit 0fd4a68

File tree

3 files changed

+12
-5
lines changed

3 files changed

+12
-5
lines changed

lib/ARCMigrate/TransProperties.cpp

+8-3
Original file line numberDiff line numberDiff line change
@@ -73,13 +73,18 @@ class PropertiesRewriter {
7373
explicit PropertiesRewriter(MigrationContext &MigrateCtx)
7474
: MigrateCtx(MigrateCtx), Pass(MigrateCtx.Pass) { }
7575

76-
static void collectProperties(ObjCContainerDecl *D, AtPropDeclsTy &AtProps) {
76+
static void collectProperties(ObjCContainerDecl *D, AtPropDeclsTy &AtProps,
77+
AtPropDeclsTy *PrevAtProps = 0) {
7778
for (ObjCInterfaceDecl::prop_iterator
7879
propI = D->prop_begin(),
7980
propE = D->prop_end(); propI != propE; ++propI) {
8081
if (propI->getAtLoc().isInvalid())
8182
continue;
82-
PropsTy &props = AtProps[propI->getAtLoc().getRawEncoding()];
83+
unsigned RawLoc = propI->getAtLoc().getRawEncoding();
84+
if (PrevAtProps)
85+
if (PrevAtProps->find(RawLoc) != PrevAtProps->end())
86+
continue;
87+
PropsTy &props = AtProps[RawLoc];
8388
props.push_back(*propI);
8489
}
8590
}
@@ -139,7 +144,7 @@ class PropertiesRewriter {
139144
for (ObjCCategoryDecl *Cat = iface->getCategoryList();
140145
Cat; Cat = Cat->getNextClassCategory())
141146
if (Cat->IsClassExtension())
142-
collectProperties(Cat, AtExtProps);
147+
collectProperties(Cat, AtExtProps, &AtProps);
143148

144149
for (AtPropDeclsTy::iterator
145150
I = AtExtProps.begin(), E = AtExtProps.end(); I != E; ++I) {

test/ARCMT/assign-prop-with-arc-runtime.m

+2-1
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,9 @@ @interface TestExt
6565
@interface TestExt()
6666
@property (retain,readwrite) TestExt *x1;
6767
@property (readwrite) TestExt *x2;
68+
@property (retain) TestExt *x3;
6869
@end
6970

7071
@implementation TestExt
71-
@synthesize x1, x2;
72+
@synthesize x1, x2, x3;
7273
@end

test/ARCMT/assign-prop-with-arc-runtime.m.result

+2-1
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,9 @@ typedef _NSCachedAttributedString *BadClassForWeak;
6565
@interface TestExt()
6666
@property (strong,readwrite) TestExt *x1;
6767
@property (weak, readwrite) TestExt *x2;
68+
@property (strong) TestExt *x3;
6869
@end
6970

7071
@implementation TestExt
71-
@synthesize x1, x2;
72+
@synthesize x1, x2, x3;
7273
@end

0 commit comments

Comments
 (0)