[PATCH] D18815: [ObjC] Enter a new evaluation context before calling BuildBlockForLambdaConversion.

Akira Hatanaka via cfe-commits cfe-commits at lists.llvm.org
Tue May 3 21:24:00 PDT 2016


ahatanak added reviewers: manmanren, doug.gregor, rjmccall.
ahatanak updated this revision to Diff 56092.
ahatanak added a comment.

Rebase and add reviewers.


http://reviews.llvm.org/D18815

Files:
  lib/Sema/SemaExprCXX.cpp
  test/SemaObjCXX/block-cleanup.mm

Index: test/SemaObjCXX/block-cleanup.mm
===================================================================
--- /dev/null
+++ test/SemaObjCXX/block-cleanup.mm
@@ -0,0 +1,16 @@
+// RUN: %clang_cc1 -triple x86_64-apple-macosx10.11.0 -std=gnu++11 -o /dev/null -x objective-c++ -fblocks -ast-dump %s 2>&1 | FileCheck %s
+
+// CHECK:      -FunctionDecl {{.*}} test 'id (void)'
+// CHECK-NEXT:   -CompoundStmt
+// CHECK-NEXT:     -ReturnStmt
+// CHECK-NEXT:       -ExprWithCleanups
+// CHECK-NEXT:         -cleanup Block
+// CHECK-NEXT:         -cleanup Block
+
+ at interface NSDictionary
++ (id)dictionaryWithObjects:(const id [])objects forKeys:(const id [])keys count:(unsigned long)cnt;
+ at end
+
+id test() {
+  return @{@"a": [](){}, @"b": [](){}};
+}
Index: lib/Sema/SemaExprCXX.cpp
===================================================================
--- lib/Sema/SemaExprCXX.cpp
+++ lib/Sema/SemaExprCXX.cpp
@@ -6229,9 +6229,12 @@
       // follows the normal lifetime rules for block literals instead of being
       // autoreleased.
       DiagnosticErrorTrap Trap(Diags);
+      PushExpressionEvaluationContext(PotentiallyEvaluated);
       ExprResult Exp = BuildBlockForLambdaConversion(E->getExprLoc(),
                                                      E->getExprLoc(),
                                                      Method, E);
+      PopExpressionEvaluationContext();
+
       if (Exp.isInvalid())
         Diag(E->getExprLoc(), diag::note_lambda_to_block_conv);
       return Exp;


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D18815.56092.patch
Type: text/x-patch
Size: 1498 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20160504/a4c345c8/attachment-0001.bin>


More information about the cfe-commits mailing list