]> granicus.if.org Git - clang/commitdiff
ObjectiveC migrator. Infer property in categories
authorFariborz Jahanian <fjahanian@apple.com>
Tue, 17 Sep 2013 19:00:30 +0000 (19:00 +0000)
committerFariborz Jahanian <fjahanian@apple.com>
Tue, 17 Sep 2013 19:00:30 +0000 (19:00 +0000)
declared as getter with or without setter method.
// rdar://15010020

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@190878 91177308-0d34-0410-b5e6-96231b3b80d8

lib/ARCMigrate/ObjCMT.cpp
test/ARCMT/objcmt-property.m
test/ARCMT/objcmt-property.m.result

index 35739f1f216c872655c32e86ed282c5291f60bff..b859c0b19d689fca59e2f0a1f8adf6f2881d50d7 100644 (file)
@@ -43,7 +43,7 @@ class ObjCMigrateASTConsumer : public ASTConsumer {
   };
   
   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 ASTConsumer {
   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 ObjCMethodDecl *Getter,
 }
 
 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 T) {
 }
 
 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::migrateProperty(ASTContext &Ctx,
   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::migrateProperty(ASTContext &Ctx,
         SelectorTable::constructSetterSelector(PP.getIdentifierTable(),
                                                PP.getSelectorTable(),
                                                getterName);
-        SetterMethod = D->lookupMethod(SetterSelector, true);
+        SetterMethod = D->getInstanceMethod(SetterSelector);
       }
     }
   }
@@ -1237,6 +1237,8 @@ void ObjCMigrateASTConsumer::HandleTranslationUnit(ASTContext &Ctx) {
           
       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 =
index 60346d7631b3660fbd4373d7a9a696394cb7fd24..9ddd9edb9b321adada07639366e9ac25514c891f 100644 (file)
@@ -115,3 +115,46 @@ typedef char BOOL;
 @end
 
 
+@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;
+@end
index 7066a50a60a4ff76f077967f941b16a6bc12c1e7..eff89294cf3bb3e180cb6c6109e0d81ce809a883 100644 (file)
@@ -115,3 +115,46 @@ typedef char BOOL;
 @end
 
 
+@interface NSInvocation(CAT)
+@property(nonatomic, unsafe_unretained) id target;
+
+
+@property(nonatomic, unsafe_unretained) id dataSource;
+
+@property(nonatomic, unsafe_unretained) id xxxdelegateYYY;
+
+
+
+
+@property(nonatomic, retain) id MYtarget;
+
+
+@property(nonatomic, retain) id targetX;
+
+
+@property(nonatomic) int value;
+
+
+@property(nonatomic, getter=isContinuous) BOOL continuous;
+
+
+@property(nonatomic, readonly) id isAnObject;
+- (void)setAnObject : (id) object;
+
+@property(nonatomic, getter=isinValid, readonly) BOOL inValid;
+- (void) setInValid : (BOOL) arg;
+
+- (void) Nothing;
+@property(nonatomic, readonly) int Length;
+@property(nonatomic, readonly) id object;
++ (double) D;
+
+- (BOOL)is3bar; // watch out
+- (NSString *)get3foo; // watch out
+
+@property(nonatomic, getter=getM, readonly) BOOL m;
+@property(nonatomic, getter=getMA, readonly) BOOL MA;
+@property(nonatomic, getter=getALL, readonly) BOOL ALL;
+@property(nonatomic, getter=getMANY, readonly) BOOL MANY;
+@property(nonatomic, getter=getSome, readonly) BOOL some;
+@end