diff options
| author | John McCall <rjmccall@apple.com> | 2011-07-27 01:07:15 +0000 |
|---|---|---|
| committer | John McCall <rjmccall@apple.com> | 2011-07-27 01:07:15 +0000 |
| commit | 538482373bba8f268b179eabde85652f630af826 (patch) | |
| tree | 6ec28341ca229e59b56dde319ce3b726a6d17b1c /clang/lib/Sema/TreeTransform.h | |
| parent | b23dc0950b61d560b276d25654a4627dbbb666e7 (diff) | |
| download | bcm5719-llvm-538482373bba8f268b179eabde85652f630af826.tar.gz bcm5719-llvm-538482373bba8f268b179eabde85652f630af826.zip | |
Clean up the analysis of the collection operand to ObjC
for-in statements; specifically, make sure to close over any
temporaries or cleanups it might require. In ARC, this has
implications for the lifetime of the collection, so emit it
with a retain and release it upon exit from the loop.
rdar://problem/9817306
llvm-svn: 136204
Diffstat (limited to 'clang/lib/Sema/TreeTransform.h')
| -rw-r--r-- | clang/lib/Sema/TreeTransform.h | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/clang/lib/Sema/TreeTransform.h b/clang/lib/Sema/TreeTransform.h index 2221fc0c211..373339a2cb8 100644 --- a/clang/lib/Sema/TreeTransform.h +++ b/clang/lib/Sema/TreeTransform.h @@ -1200,7 +1200,16 @@ public: Stmt *Body) { return getSema().ActOnObjCAutoreleasePoolStmt(AtLoc, Body); } - + + /// \brief Build the collection operand to a new Objective-C fast + /// enumeration statement. + /// + /// By default, performs semantic analysis to build the new statement. + /// Subclasses may override this routine to provide different behavior. + ExprResult RebuildObjCForCollectionOperand(SourceLocation forLoc, + Expr *collection) { + return getSema().ActOnObjCForCollectionOperand(forLoc, collection); + } /// \brief Build a new Objective-C fast enumeration statement. /// @@ -5519,6 +5528,10 @@ TreeTransform<Derived>::TransformObjCForCollectionStmt( ExprResult Collection = getDerived().TransformExpr(S->getCollection()); if (Collection.isInvalid()) return StmtError(); + Collection = getDerived().RebuildObjCForCollectionOperand(S->getForLoc(), + Collection.take()); + if (Collection.isInvalid()) + return StmtError(); // Transform the body. StmtResult Body = getDerived().TransformStmt(S->getBody()); |

