[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
diff --git a/lib/ARCMigrate/TransProperties.cpp b/lib/ARCMigrate/TransProperties.cpp
index 7eb2a9b..cc85fe2 100644
--- a/lib/ARCMigrate/TransProperties.cpp
+++ b/lib/ARCMigrate/TransProperties.cpp
@@ -73,13 +73,18 @@
explicit PropertiesRewriter(MigrationContext &MigrateCtx)
: MigrateCtx(MigrateCtx), Pass(MigrateCtx.Pass) { }
- static void collectProperties(ObjCContainerDecl *D, AtPropDeclsTy &AtProps) {
+ static void collectProperties(ObjCContainerDecl *D, AtPropDeclsTy &AtProps,
+ AtPropDeclsTy *PrevAtProps = 0) {
for (ObjCInterfaceDecl::prop_iterator
propI = D->prop_begin(),
propE = D->prop_end(); propI != propE; ++propI) {
if (propI->getAtLoc().isInvalid())
continue;
- PropsTy &props = AtProps[propI->getAtLoc().getRawEncoding()];
+ unsigned RawLoc = propI->getAtLoc().getRawEncoding();
+ if (PrevAtProps)
+ if (PrevAtProps->find(RawLoc) != PrevAtProps->end())
+ continue;
+ PropsTy &props = AtProps[RawLoc];
props.push_back(*propI);
}
}
@@ -139,7 +144,7 @@
for (ObjCCategoryDecl *Cat = iface->getCategoryList();
Cat; Cat = Cat->getNextClassCategory())
if (Cat->IsClassExtension())
- collectProperties(Cat, AtExtProps);
+ collectProperties(Cat, AtExtProps, &AtProps);
for (AtPropDeclsTy::iterator
I = AtExtProps.begin(), E = AtExtProps.end(); I != E; ++I) {
diff --git a/test/ARCMT/assign-prop-with-arc-runtime.m b/test/ARCMT/assign-prop-with-arc-runtime.m
index 0221afa..c357eeb 100644
--- a/test/ARCMT/assign-prop-with-arc-runtime.m
+++ b/test/ARCMT/assign-prop-with-arc-runtime.m
@@ -65,8 +65,9 @@
@interface TestExt()
@property (retain,readwrite) TestExt *x1;
@property (readwrite) TestExt *x2;
+@property (retain) TestExt *x3;
@end
@implementation TestExt
-@synthesize x1, x2;
+@synthesize x1, x2, x3;
@end
diff --git a/test/ARCMT/assign-prop-with-arc-runtime.m.result b/test/ARCMT/assign-prop-with-arc-runtime.m.result
index 30a9caa..a255a36 100644
--- a/test/ARCMT/assign-prop-with-arc-runtime.m.result
+++ b/test/ARCMT/assign-prop-with-arc-runtime.m.result
@@ -65,8 +65,9 @@
@interface TestExt()
@property (strong,readwrite) TestExt *x1;
@property (weak, readwrite) TestExt *x2;
+@property (strong) TestExt *x3;
@end
@implementation TestExt
-@synthesize x1, x2;
+@synthesize x1, x2, x3;
@end