[cfe-commits] r155673 - in /cfe/trunk: lib/Rewrite/RewriteModernObjC.cpp test/Rewriter/rewrite-modern-block.mm
Fariborz Jahanian
fjahanian at apple.com
Thu Apr 26 16:20:25 PDT 2012
Author: fjahanian
Date: Thu Apr 26 18:20:25 2012
New Revision: 155673
URL: http://llvm.org/viewvc/llvm-project?rev=155673&view=rev
Log:
modern objective-c transltion: Fixes a translation bug
of writing a __block variable being initialized with
a constructed object. // rdar://11326988
Modified:
cfe/trunk/lib/Rewrite/RewriteModernObjC.cpp
cfe/trunk/test/Rewriter/rewrite-modern-block.mm
Modified: cfe/trunk/lib/Rewrite/RewriteModernObjC.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Rewrite/RewriteModernObjC.cpp?rev=155673&r1=155672&r2=155673&view=diff
==============================================================================
--- cfe/trunk/lib/Rewrite/RewriteModernObjC.cpp (original)
+++ cfe/trunk/lib/Rewrite/RewriteModernObjC.cpp Thu Apr 26 18:20:25 2012
@@ -4814,8 +4814,13 @@
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;
+ if (hasInit)
+ if (CXXConstructExpr *CExp = dyn_cast<CXXConstructExpr>(ND->getInit())) {
+ CXXConstructorDecl *CXXDecl = CExp->getConstructor();
+ if (CXXDecl && CXXDecl->isDefaultConstructor())
+ hasInit = false;
+ }
+
unsigned flags = 0;
if (HasCopyAndDispose)
flags |= BLOCK_HAS_COPY_DISPOSE;
Modified: cfe/trunk/test/Rewriter/rewrite-modern-block.mm
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Rewriter/rewrite-modern-block.mm?rev=155673&r1=155672&r2=155673&view=diff
==============================================================================
--- cfe/trunk/test/Rewriter/rewrite-modern-block.mm (original)
+++ cfe/trunk/test/Rewriter/rewrite-modern-block.mm Thu Apr 26 18:20:25 2012
@@ -46,3 +46,19 @@
return BI2;
}
+// rdar://11326988
+typedef struct _z {
+ int location;
+ int length;
+} z;
+
+z w(int loc, int len);
+
+ at interface rdar11326988
+ at end
+ at implementation rdar11326988
+- (void)y:(int)options {
+ __attribute__((__blocks__(byref))) z firstRange = w(1, 0);
+ options &= ~(1 | 2);
+}
+ at end
More information about the cfe-commits
mailing list