[PATCH] D86780: Copy blocks in variadic methods

酷酷的哀殿 via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Aug 28 05:48:41 PDT 2020


sunbohong created this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.
sunbohong requested review of this revision.

This commit will fix https://bugs.llvm.org/show_bug.cgi?id=46399.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D86780

Files:
  clang/lib/Sema/SemaExprObjC.cpp


Index: clang/lib/Sema/SemaExprObjC.cpp
===================================================================
--- clang/lib/Sema/SemaExprObjC.cpp
+++ clang/lib/Sema/SemaExprObjC.cpp
@@ -1777,6 +1777,17 @@
     }
   }
 
+  for (unsigned i = NumNamedArgs, e = Args.size(); i < e; ++i) {
+    if (Args[i]->isTypeDependent())
+      continue;
+    // copy blocks [NSArray arrayWithObjects:^(){NSLog(@"blk0:%d", val);},^(){NSLog(@"blk1:%d", val);}, nil];
+    if (Args[i]->getType()->isBlockPointerType()) {
+      ExprResult arg = Args[i];
+      maybeExtendBlockObject(arg);
+      Args[i] = arg.get();
+    }
+  }
+
   DiagnoseSentinelCalls(Method, SelLoc, Args);
 
   // Do additional checkings on method.


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D86780.288588.patch
Type: text/x-patch
Size: 702 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20200828/55fdd344/attachment.bin>


More information about the cfe-commits mailing list