[PATCH] D18618: [ObjC] Pop all cleanups created in CodeGenFunction::EmitObjCForCollectionStmt

Akira Hatanaka via cfe-commits cfe-commits at lists.llvm.org
Wed Mar 30 19:03:23 PDT 2016


ahatanak added a comment.

In CodeGenFunction::EmitARCRetainScalarExpr, if I move the declaration of "scope" above the call to enterFullExpression, the cleanup is popped before the loop body is entered right after the method returning the collection (foo1 in the test case) is called.

if (const ExprWithCleanups *cleanups = dyn_cast<ExprWithCleanups>(e)) {

  enterFullExpression(cleanups);
  RunCleanupsScope scope(*this);
  return EmitARCRetainScalarExpr(cleanups->getSubExpr());

}

The cleanup is entered in enterBlockScope which is transitively called from enterFullExpression. EmitARCRetainScalarExpr is called at CGObjC.cpp:1491. The Collection for ExprObjCForCollectionStmt is an ExprWithCleanups which has the Block passed to foo1 attached to it and the cleanups for the captures of the Block are entered in enterBlockScope.


http://reviews.llvm.org/D18618





More information about the cfe-commits mailing list