diff options
author | Fariborz Jahanian <fjahanian@apple.com> | 2010-10-20 16:07:20 +0000 |
---|---|---|
committer | Fariborz Jahanian <fjahanian@apple.com> | 2010-10-20 16:07:20 +0000 |
commit | e0f83863595f5725791d88a799d20dbae38bed4a (patch) | |
tree | b29d0e01acea8ea89b943c7ac62d440856245a3b /lib/Rewrite/RewriteObjC.cpp | |
parent | d9d2a876a523352952e8b38eb5d5275cae9998c6 (diff) |
Fixes a potential crash in rewriter when sending message
to 'super'.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@116928 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Rewrite/RewriteObjC.cpp')
-rw-r--r-- | lib/Rewrite/RewriteObjC.cpp | 29 |
1 files changed, 17 insertions, 12 deletions
diff --git a/lib/Rewrite/RewriteObjC.cpp b/lib/Rewrite/RewriteObjC.cpp index eac652c103..3d54816c4c 100644 --- a/lib/Rewrite/RewriteObjC.cpp +++ b/lib/Rewrite/RewriteObjC.cpp @@ -1250,11 +1250,6 @@ Stmt *RewriteObjC::RewritePropertyOrImplicitSetter(BinaryOperator *BinOp, Expr * llvm::SmallVector<Expr *, 1> ExprVec; ExprVec.push_back(newStmt); - if (Expr *Exp = dyn_cast<Expr>(Receiver)) - if (PropGetters[Exp]) - // This allows us to handle chain/nested property/implicit getters. - Receiver = PropGetters[Exp]; - ObjCMessageExpr *MsgExpr; if (Super) MsgExpr = ObjCMessageExpr::Create(*Context, @@ -1266,7 +1261,15 @@ Stmt *RewriteObjC::RewritePropertyOrImplicitSetter(BinaryOperator *BinOp, Expr * Sel, OMD, &ExprVec[0], 1, /*FIXME:*/SourceLocation()); - else + else { + // FIXME. Refactor this into common code with that in + // RewritePropertyOrImplicitGetter + assert(Receiver && "RewritePropertyOrImplicitSetter - null Receiver"); + if (Expr *Exp = dyn_cast<Expr>(Receiver)) + if (PropGetters[Exp]) + // This allows us to handle chain/nested property/implicit getters. + Receiver = PropGetters[Exp]; + MsgExpr = ObjCMessageExpr::Create(*Context, Ty.getNonReferenceType(), /*FIXME: */SourceLocation(), @@ -1274,6 +1277,7 @@ Stmt *RewriteObjC::RewritePropertyOrImplicitSetter(BinaryOperator *BinOp, Expr * Sel, OMD, &ExprVec[0], 1, /*FIXME:*/SourceLocation()); + } Stmt *ReplacingStmt = SynthMessageExpr(MsgExpr); // Now do the actual rewrite. @@ -1325,11 +1329,6 @@ Stmt *RewriteObjC::RewritePropertyOrImplicitGetter(Expr *PropOrGetterRefExpr) { assert (OMD && "RewritePropertyOrImplicitGetter - OMD is null"); - if (Expr *Exp = dyn_cast<Expr>(Receiver)) - if (PropGetters[Exp]) - // This allows us to handle chain/nested property/implicit getters. - Receiver = PropGetters[Exp]; - ObjCMessageExpr *MsgExpr; if (Super) MsgExpr = ObjCMessageExpr::Create(*Context, @@ -1341,7 +1340,12 @@ Stmt *RewriteObjC::RewritePropertyOrImplicitGetter(Expr *PropOrGetterRefExpr) { Sel, OMD, 0, 0, /*FIXME:*/SourceLocation()); - else + else { + assert (Receiver && "RewritePropertyOrImplicitGetter - Receiver is null"); + if (Expr *Exp = dyn_cast<Expr>(Receiver)) + if (PropGetters[Exp]) + // This allows us to handle chain/nested property/implicit getters. + Receiver = PropGetters[Exp]; MsgExpr = ObjCMessageExpr::Create(*Context, Ty.getNonReferenceType(), /*FIXME:*/SourceLocation(), @@ -1349,6 +1353,7 @@ Stmt *RewriteObjC::RewritePropertyOrImplicitGetter(Expr *PropOrGetterRefExpr) { Sel, OMD, 0, 0, /*FIXME:*/SourceLocation()); + } Stmt *ReplacingStmt = SynthMessageExpr(MsgExpr); |