From afcb16f9cff8d5ccd57a6386d65ddc055368d0bc Mon Sep 17 00:00:00 2001 From: Fariborz Jahanian Date: Fri, 5 Jul 2013 20:46:03 +0000 Subject: [PATCH] [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 --- include/clang/Edit/Rewriters.h | 5 +++++ lib/ARCMigrate/ObjCMT.cpp | 12 ++++-------- lib/Edit/RewriteObjCFoundationAPI.cpp | 6 ++++++ 3 files changed, 15 insertions(+), 8 deletions(-) diff --git a/include/clang/Edit/Rewriters.h b/include/clang/Edit/Rewriters.h index 292878e756..cfb59dfa32 100644 --- a/include/clang/Edit/Rewriters.h +++ b/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); diff --git a/lib/ARCMigrate/ObjCMT.cpp b/lib/ARCMigrate/ObjCMT.cpp index 696666ecde..ec19f6e8f0 100644 --- a/lib/ARCMigrate/ObjCMT.cpp +++ b/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); } } } diff --git a/lib/Edit/RewriteObjCFoundationAPI.cpp b/lib/Edit/RewriteObjCFoundationAPI.cpp index f4206fbd8f..9af53037ea 100644 --- a/lib/Edit/RewriteObjCFoundationAPI.cpp +++ b/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. -- 2.50.1