r190878 - ObjectiveC migrator. Infer property in categories
Fariborz Jahanian
fjahanian at apple.com
Tue Sep 17 12:00:31 PDT 2013
Author: fjahanian
Date: Tue Sep 17 14:00:30 2013
New Revision: 190878
URL: http://llvm.org/viewvc/llvm-project?rev=190878&view=rev
Log:
ObjectiveC migrator. Infer property in categories
declared as getter with or without setter method.
// rdar://15010020
Modified:
cfe/trunk/lib/ARCMigrate/ObjCMT.cpp
cfe/trunk/test/ARCMT/objcmt-property.m
cfe/trunk/test/ARCMT/objcmt-property.m.result
Modified: cfe/trunk/lib/ARCMigrate/ObjCMT.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/ARCMigrate/ObjCMT.cpp?rev=190878&r1=190877&r2=190878&view=diff
==============================================================================
--- cfe/trunk/lib/ARCMigrate/ObjCMT.cpp (original)
+++ cfe/trunk/lib/ARCMigrate/ObjCMT.cpp Tue Sep 17 14:00:30 2013
@@ -43,7 +43,7 @@ class ObjCMigrateASTConsumer : public AS
};
void migrateDecl(Decl *D);
- void migrateObjCInterfaceDecl(ASTContext &Ctx, ObjCInterfaceDecl *D);
+ void migrateObjCInterfaceDecl(ASTContext &Ctx, ObjCContainerDecl *D);
void migrateProtocolConformance(ASTContext &Ctx,
const ObjCImplementationDecl *ImpDecl);
void migrateNSEnumDecl(ASTContext &Ctx, const EnumDecl *EnumDcl,
@@ -51,7 +51,7 @@ class ObjCMigrateASTConsumer : public AS
void migrateMethods(ASTContext &Ctx, ObjCContainerDecl *CDecl);
void migrateMethodInstanceType(ASTContext &Ctx, ObjCContainerDecl *CDecl,
ObjCMethodDecl *OM);
- bool migrateProperty(ASTContext &Ctx, ObjCInterfaceDecl *D, ObjCMethodDecl *OM);
+ bool migrateProperty(ASTContext &Ctx, ObjCContainerDecl *D, ObjCMethodDecl *OM);
void migrateNsReturnsInnerPointer(ASTContext &Ctx, ObjCMethodDecl *OM);
void migrateFactoryMethod(ASTContext &Ctx, ObjCContainerDecl *CDecl,
ObjCMethodDecl *OM,
@@ -339,7 +339,7 @@ static bool rewriteToObjCProperty(const
}
void ObjCMigrateASTConsumer::migrateObjCInterfaceDecl(ASTContext &Ctx,
- ObjCInterfaceDecl *D) {
+ ObjCContainerDecl *D) {
for (ObjCContainerDecl::method_iterator M = D->meth_begin(), MEnd = D->meth_end();
M != MEnd; ++M) {
ObjCMethodDecl *Method = (*M);
@@ -716,7 +716,7 @@ static bool TypeIsInnerPointer(QualType
}
bool ObjCMigrateASTConsumer::migrateProperty(ASTContext &Ctx,
- ObjCInterfaceDecl *D,
+ ObjCContainerDecl *D,
ObjCMethodDecl *Method) {
if (Method->isPropertyAccessor() || !Method->isInstanceMethod() ||
Method->param_size() != 0)
@@ -735,7 +735,7 @@ bool ObjCMigrateASTConsumer::migrateProp
SelectorTable::constructSetterSelector(PP.getIdentifierTable(),
PP.getSelectorTable(),
getterName);
- ObjCMethodDecl *SetterMethod = D->lookupMethod(SetterSelector, true);
+ ObjCMethodDecl *SetterMethod = D->getInstanceMethod(SetterSelector);
unsigned LengthOfPrefix = 0;
if (!SetterMethod) {
// try a different naming convention for getter: isXxxxx
@@ -755,7 +755,7 @@ bool ObjCMigrateASTConsumer::migrateProp
SelectorTable::constructSetterSelector(PP.getIdentifierTable(),
PP.getSelectorTable(),
getterName);
- SetterMethod = D->lookupMethod(SetterSelector, true);
+ SetterMethod = D->getInstanceMethod(SetterSelector);
}
}
}
@@ -1237,6 +1237,8 @@ void ObjCMigrateASTConsumer::HandleTrans
if (ObjCInterfaceDecl *CDecl = dyn_cast<ObjCInterfaceDecl>(*D))
migrateObjCInterfaceDecl(Ctx, CDecl);
+ if (ObjCCategoryDecl *CatDecl = dyn_cast<ObjCCategoryDecl>(*D))
+ migrateObjCInterfaceDecl(Ctx, CatDecl);
else if (ObjCProtocolDecl *PDecl = dyn_cast<ObjCProtocolDecl>(*D))
ObjCProtocolDecls.insert(PDecl);
else if (const ObjCImplementationDecl *ImpDecl =
Modified: cfe/trunk/test/ARCMT/objcmt-property.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/ARCMT/objcmt-property.m?rev=190878&r1=190877&r2=190878&view=diff
==============================================================================
--- cfe/trunk/test/ARCMT/objcmt-property.m (original)
+++ cfe/trunk/test/ARCMT/objcmt-property.m Tue Sep 17 14:00:30 2013
@@ -115,3 +115,46 @@ typedef char BOOL;
@end
+ at interface NSInvocation(CAT)
+- (id)target;
+- (void)setTarget:(id)target;
+
+- (id) dataSource;
+
+- (id)xxxdelegateYYY;
+- (void)setXxxdelegateYYY:(id)delegate;
+
+- (void)setDataSource:(id)source;
+
+- (id)MYtarget;
+- (void)setMYtarget: (id)target;
+
+- (id)targetX;
+- (void)setTargetX: (id)t;
+
+- (int)value;
+- (void)setValue: (int)val;
+
+-(BOOL) isContinuous;
+-(void) setContinuous:(BOOL)value;
+
+- (id) isAnObject;
+- (void)setAnObject : (id) object;
+
+- (BOOL) isinValid;
+- (void) setInValid : (BOOL) arg;
+
+- (void) Nothing;
+- (int) Length;
+- (id) object;
++ (double) D;
+
+- (BOOL)is3bar; // watch out
+- (NSString *)get3foo; // watch out
+
+- (BOOL) getM;
+- (BOOL) getMA;
+- (BOOL) getALL;
+- (BOOL) getMANY;
+- (BOOL) getSome;
+ at end
Modified: cfe/trunk/test/ARCMT/objcmt-property.m.result
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/ARCMT/objcmt-property.m.result?rev=190878&r1=190877&r2=190878&view=diff
==============================================================================
--- cfe/trunk/test/ARCMT/objcmt-property.m.result (original)
+++ cfe/trunk/test/ARCMT/objcmt-property.m.result Tue Sep 17 14:00:30 2013
@@ -115,3 +115,46 @@ typedef char BOOL;
@end
+ at interface NSInvocation(CAT)
+ at property(nonatomic, unsafe_unretained) id target;
+
+
+ at property(nonatomic, unsafe_unretained) id dataSource;
+
+ at property(nonatomic, unsafe_unretained) id xxxdelegateYYY;
+
+
+
+
+ at property(nonatomic, retain) id MYtarget;
+
+
+ at property(nonatomic, retain) id targetX;
+
+
+ at property(nonatomic) int value;
+
+
+ at property(nonatomic, getter=isContinuous) BOOL continuous;
+
+
+ at property(nonatomic, readonly) id isAnObject;
+- (void)setAnObject : (id) object;
+
+ at property(nonatomic, getter=isinValid, readonly) BOOL inValid;
+- (void) setInValid : (BOOL) arg;
+
+- (void) Nothing;
+ at property(nonatomic, readonly) int Length;
+ at property(nonatomic, readonly) id object;
++ (double) D;
+
+- (BOOL)is3bar; // watch out
+- (NSString *)get3foo; // watch out
+
+ at property(nonatomic, getter=getM, readonly) BOOL m;
+ at property(nonatomic, getter=getMA, readonly) BOOL MA;
+ at property(nonatomic, getter=getALL, readonly) BOOL ALL;
+ at property(nonatomic, getter=getMANY, readonly) BOOL MANY;
+ at property(nonatomic, getter=getSome, readonly) BOOL some;
+ at end
More information about the cfe-commits
mailing list