فهرست منبع

[objc migrator]: More knobs to do migration to
use of objc's properties.


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

Fariborz Jahanian 12 سال پیش
والد
کامیت
afcb16f9cf
3فایلهای تغییر یافته به همراه15 افزوده شده و 8 حذف شده
  1. 5 0
      include/clang/Edit/Rewriters.h
  2. 4 8
      lib/ARCMigrate/ObjCMT.cpp
  3. 6 0
      lib/Edit/RewriteObjCFoundationAPI.cpp

+ 5 - 0
include/clang/Edit/Rewriters.h

@@ -12,6 +12,7 @@
 
 namespace clang {
   class ObjCMessageExpr;
+  class ObjCMethodDecl;
   class NSAPI;
   class ParentMap;
 
@@ -24,6 +25,10 @@ bool rewriteObjCRedundantCallWithLiteral(const ObjCMessageExpr *Msg,
 bool rewriteToObjCLiteralSyntax(const ObjCMessageExpr *Msg,
                                 const NSAPI &NS, Commit &commit,
                                 const ParentMap *PMap);
+  
+bool rewriteToObjCProperty(const ObjCMethodDecl *Getter,
+                           const ObjCMethodDecl *Setter,
+                           const NSAPI &NS, Commit &commit);
 
 bool rewriteToObjCSubscriptSyntax(const ObjCMessageExpr *Msg,
                                   const NSAPI &NS, Commit &commit);

+ 4 - 8
lib/ARCMigrate/ObjCMT.cpp

@@ -212,15 +212,11 @@ void ObjCMigrateASTConsumer::migrateObjCInterfaceDecl(ASTContext &Ctx,
         continue;
       const ParmVarDecl *argDecl = *SetterMethod->param_begin();
       QualType ArgType = argDecl->getType();
-      if (!Ctx.hasSameType(ArgType, GRT)) {
-        bool Valid =
-          ((GRT->isObjCIdType() && ArgType->isObjCObjectPointerType())
-            || (ArgType->isObjCIdType() && GRT->isObjCObjectPointerType()));
-        if (!Valid)
+      if (!Ctx.hasSameType(ArgType, GRT))
           continue;
-      }
-      // we have a matching setter/getter pair.
-      // TODO. synthesize a suitable property declaration here.
+        edit::Commit commit(*Editor);
+        edit::rewriteToObjCProperty(Method, SetterMethod, *NSAPIObj, commit);
+        Editor->commit(commit);
       }
   }
 }

+ 6 - 0
lib/Edit/RewriteObjCFoundationAPI.cpp

@@ -355,6 +355,12 @@ bool edit::rewriteToObjCLiteralSyntax(const ObjCMessageExpr *Msg,
   return false;
 }
 
+bool edit::rewriteToObjCProperty(const ObjCMethodDecl *Getter,
+                                 const ObjCMethodDecl *Setter,
+                                 const NSAPI &NS, Commit &commit) {
+  return false;
+}
+
 /// \brief Returns true if the immediate message arguments of \c Msg should not
 /// be rewritten because it will interfere with the rewrite of the parent
 /// message expression. e.g.