[cfe-commits] r154566 - in /cfe/trunk: lib/Rewrite/RewriteModernObjC.cpp test/Rewriter/rewrite-modern-block.mm
Fariborz Jahanian
fjahanian at apple.com
Wed Apr 11 16:57:12 PDT 2012
Author: fjahanian
Date: Wed Apr 11 18:57:12 2012
New Revision: 154566
URL: http://llvm.org/viewvc/llvm-project?rev=154566&view=rev
Log:
modern objective-c translator. Fixes a mis-translation when
of a __block struct object. // rdar://11230308
Added:
cfe/trunk/test/Rewriter/rewrite-modern-block.mm
Modified:
cfe/trunk/lib/Rewrite/RewriteModernObjC.cpp
Modified: cfe/trunk/lib/Rewrite/RewriteModernObjC.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Rewrite/RewriteModernObjC.cpp?rev=154566&r1=154565&r2=154566&view=diff
==============================================================================
--- cfe/trunk/lib/Rewrite/RewriteModernObjC.cpp (original)
+++ cfe/trunk/lib/Rewrite/RewriteModernObjC.cpp Wed Apr 11 18:57:12 2012
@@ -4812,6 +4812,10 @@
// {0, &ND, some_flag, __size=sizeof(struct __Block_byref_ND),
// initializer-if-any};
bool hasInit = (ND->getInit() != 0);
+ // FIXME. rewriter does not support __block c++ objects which
+ // require construction.
+ if (hasInit && dyn_cast<CXXConstructExpr>(ND->getInit()))
+ hasInit = false;
unsigned flags = 0;
if (HasCopyAndDispose)
flags |= BLOCK_HAS_COPY_DISPOSE;
Added: cfe/trunk/test/Rewriter/rewrite-modern-block.mm
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Rewriter/rewrite-modern-block.mm?rev=154566&view=auto
==============================================================================
--- cfe/trunk/test/Rewriter/rewrite-modern-block.mm (added)
+++ cfe/trunk/test/Rewriter/rewrite-modern-block.mm Wed Apr 11 18:57:12 2012
@@ -0,0 +1,18 @@
+// RUN: %clang_cc1 -x objective-c++ -fblocks -fms-extensions -rewrite-objc %s -o %t-rw.cpp
+// RUN: %clang_cc1 -fsyntax-only -fblocks -Wno-address-of-temporary -D"Class=void*" -D"id=void*" -D"SEL=void*" -D"__declspec(X)=" %t-rw.cpp
+// rdar://11230308
+
+typedef struct {
+ char byte0;
+ char byte1;
+} CFUUIDBytes;
+
+void x(void *);
+
+void y() {
+ __block CFUUIDBytes bytes;
+
+ void (^bar)() = ^{
+ x(&bytes);
+ };
+}
More information about the cfe-commits
mailing list