diff options
author | John McCall <rjmccall@apple.com> | 2010-12-02 01:19:52 +0000 |
---|---|---|
committer | John McCall <rjmccall@apple.com> | 2010-12-02 01:19:52 +0000 |
commit | 12f78a6741a4cb3d904340f8d3d2714568b50e7a (patch) | |
tree | 7d3c0d003eb7060d7a7a985d6f4fa284f9207c35 /lib/Rewrite/RewriteObjC.cpp | |
parent | 9d0b2b728b9a431546b11252793844bf7506ec84 (diff) |
Simplify the ASTs by consolidating ObjCImplicitGetterSetterExpr and ObjCPropertyRefExpr
into the latter.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@120643 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Rewrite/RewriteObjC.cpp')
-rw-r--r-- | lib/Rewrite/RewriteObjC.cpp | 82 |
1 files changed, 33 insertions, 49 deletions
diff --git a/lib/Rewrite/RewriteObjC.cpp b/lib/Rewrite/RewriteObjC.cpp index 1ecde6a7fa..286ac0f638 100644 --- a/lib/Rewrite/RewriteObjC.cpp +++ b/lib/Rewrite/RewriteObjC.cpp @@ -1230,30 +1230,24 @@ Stmt *RewriteObjC::RewritePropertyOrImplicitSetter(BinaryOperator *BinOp, Expr * SourceLocation SuperLocation; // Synthesize a ObjCMessageExpr from a ObjCPropertyRefExpr or ObjCImplicitSetterGetterRefExpr. // This allows us to reuse all the fun and games in SynthMessageExpr(). - if (ObjCPropertyRefExpr *PropRefExpr = dyn_cast<ObjCPropertyRefExpr>(BinOp->getLHS())) { - ObjCPropertyDecl *PDecl = PropRefExpr->getProperty(); - OMD = PDecl->getSetterMethodDecl(); - Ty = PDecl->getType(); - Sel = PDecl->getSetterName(); + if (ObjCPropertyRefExpr *PropRefExpr = + dyn_cast<ObjCPropertyRefExpr>(BinOp->getLHS())) { + if (PropRefExpr->isExplicitProperty()) { + ObjCPropertyDecl *PDecl = PropRefExpr->getExplicitProperty(); + OMD = PDecl->getSetterMethodDecl(); + Ty = PDecl->getType(); + Sel = PDecl->getSetterName(); + } else { + OMD = PropRefExpr->getImplicitPropertySetter(); + Sel = OMD->getSelector(); + Ty = PropRefExpr->getType(); + } Super = PropRefExpr->isSuperReceiver(); - if (!Super) + if (!Super) { Receiver = PropRefExpr->getBase(); - else { - SuperTy = PropRefExpr->getSuperType(); - SuperLocation = PropRefExpr->getSuperLocation(); - } - } - else if (ObjCImplicitSetterGetterRefExpr *ImplicitRefExpr = - dyn_cast<ObjCImplicitSetterGetterRefExpr>(BinOp->getLHS())) { - OMD = ImplicitRefExpr->getSetterMethod(); - Sel = OMD->getSelector(); - Ty = ImplicitRefExpr->getType(); - Super = ImplicitRefExpr->isSuperReceiver(); - if (!Super) - Receiver = ImplicitRefExpr->getBase(); - else { - SuperTy = ImplicitRefExpr->getSuperType(); - SuperLocation = ImplicitRefExpr->getSuperLocation(); + } else { + SuperTy = PropRefExpr->getSuperReceiverType(); + SuperLocation = PropRefExpr->getReceiverLocation(); } } @@ -1314,29 +1308,22 @@ Stmt *RewriteObjC::RewritePropertyOrImplicitGetter(Expr *PropOrGetterRefExpr) { SourceLocation SuperLocation; if (ObjCPropertyRefExpr *PropRefExpr = dyn_cast<ObjCPropertyRefExpr>(PropOrGetterRefExpr)) { - ObjCPropertyDecl *PDecl = PropRefExpr->getProperty(); - OMD = PDecl->getGetterMethodDecl(); - Ty = PDecl->getType(); - Sel = PDecl->getGetterName(); + if (PropRefExpr->isExplicitProperty()) { + ObjCPropertyDecl *PDecl = PropRefExpr->getExplicitProperty(); + OMD = PDecl->getGetterMethodDecl(); + Ty = PDecl->getType(); + Sel = PDecl->getGetterName(); + } else { + OMD = PropRefExpr->getImplicitPropertyGetter(); + Sel = OMD->getSelector(); + Ty = PropRefExpr->getType(); + } Super = PropRefExpr->isSuperReceiver(); if (!Super) Receiver = PropRefExpr->getBase(); else { - SuperTy = PropRefExpr->getSuperType(); - SuperLocation = PropRefExpr->getSuperLocation(); - } - } - else if (ObjCImplicitSetterGetterRefExpr *ImplicitRefExpr = - dyn_cast<ObjCImplicitSetterGetterRefExpr>(PropOrGetterRefExpr)) { - OMD = ImplicitRefExpr->getGetterMethod(); - Sel = OMD->getSelector(); - Ty = ImplicitRefExpr->getType(); - Super = ImplicitRefExpr->isSuperReceiver(); - if (!Super) - Receiver = ImplicitRefExpr->getBase(); - else { - SuperTy = ImplicitRefExpr->getSuperType(); - SuperLocation = ImplicitRefExpr->getSuperLocation(); + SuperTy = PropRefExpr->getSuperReceiverType(); + SuperLocation = PropRefExpr->getReceiverLocation(); } } @@ -1376,8 +1363,7 @@ Stmt *RewriteObjC::RewritePropertyOrImplicitGetter(Expr *PropOrGetterRefExpr) { PropParentMap = new ParentMap(CurrentBody); Stmt *Parent = PropParentMap->getParent(PropOrGetterRefExpr); - if (Parent && (isa<ObjCPropertyRefExpr>(Parent) || - isa<ObjCImplicitSetterGetterRefExpr>(Parent))) { + if (Parent && isa<ObjCPropertyRefExpr>(Parent)) { // We stash away the ReplacingStmt since actually doing the // replacement/rewrite won't work for nested getters (e.g. obj.p.i) PropGetters[PropOrGetterRefExpr] = ReplacingStmt; @@ -5495,9 +5481,8 @@ void RewriteObjC::CollectPropertySetters(Stmt *S) { if (BinaryOperator *BinOp = dyn_cast<BinaryOperator>(S)) { if (BinOp->isAssignmentOp()) { - if (isa<ObjCPropertyRefExpr>(BinOp->getLHS()) || - isa<ObjCImplicitSetterGetterRefExpr>(BinOp->getLHS())) - PropSetters[BinOp->getLHS()] = BinOp; + if (isa<ObjCPropertyRefExpr>(BinOp->getLHS())) + PropSetters[BinOp->getLHS()] = BinOp; } } } @@ -5539,8 +5524,7 @@ Stmt *RewriteObjC::RewriteFunctionBodyOrGlobalInitializer(Stmt *S) { // setter messaging. This involvs the RHS too. Do not attempt to rewrite // RHS again. if (Expr *Exp = dyn_cast<Expr>(S)) - if (isa<ObjCPropertyRefExpr>(Exp) || - isa<ObjCImplicitSetterGetterRefExpr>(Exp)) { + if (isa<ObjCPropertyRefExpr>(Exp)) { if (PropSetters[Exp]) { ++CI; continue; @@ -5577,7 +5561,7 @@ Stmt *RewriteObjC::RewriteFunctionBodyOrGlobalInitializer(Stmt *S) { if (ObjCEncodeExpr *AtEncode = dyn_cast<ObjCEncodeExpr>(S)) return RewriteAtEncode(AtEncode); - if (isa<ObjCPropertyRefExpr>(S) || isa<ObjCImplicitSetterGetterRefExpr>(S)) { + if (isa<ObjCPropertyRefExpr>(S)) { Expr *PropOrImplicitRefExpr = dyn_cast<Expr>(S); assert(PropOrImplicitRefExpr && "Property or implicit setter/getter is null"); |