[cfe-commits] r154679 - in /cfe/trunk: lib/Rewrite/RewriteModernObjC.cpp test/Rewriter/objc-modern-implicit-cast.mm test/Rewriter/rewrite-modern-typeof.mm

Fariborz Jahanian fjahanian at apple.com
Fri Apr 13 11:00:54 PDT 2012


Author: fjahanian
Date: Fri Apr 13 13:00:54 2012
New Revision: 154679

URL: http://llvm.org/viewvc/llvm-project?rev=154679&view=rev
Log:
modern objective-c translator: Fixes translation of
__typeof which is a regression by reverting
r154360. // rdar://11233924

Added:
    cfe/trunk/test/Rewriter/rewrite-modern-typeof.mm
Modified:
    cfe/trunk/lib/Rewrite/RewriteModernObjC.cpp
    cfe/trunk/test/Rewriter/objc-modern-implicit-cast.mm

Modified: cfe/trunk/lib/Rewrite/RewriteModernObjC.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Rewrite/RewriteModernObjC.cpp?rev=154679&r1=154678&r2=154679&view=diff
==============================================================================
--- cfe/trunk/lib/Rewrite/RewriteModernObjC.cpp (original)
+++ cfe/trunk/lib/Rewrite/RewriteModernObjC.cpp Fri Apr 13 13:00:54 2012
@@ -5357,10 +5357,13 @@
   if (CStyleCastExpr *CE = dyn_cast<CStyleCastExpr>(S)) {
     RewriteCastExpr(CE);
   }
+#if 0
+  // FIXME. Cannot safely rewrite ImplicitCasts. This is the 2nd failed
+  // attempt: (id)((__typeof(z))_Block_copy((const void *)(z)));
   if (ImplicitCastExpr *ICE = dyn_cast<ImplicitCastExpr>(S)) {
     RewriteImplicitCastObjCExpr(ICE);
   }
-#if 0
+
   if (ImplicitCastExpr *ICE = dyn_cast<ImplicitCastExpr>(S)) {
     CastExpr *Replacement = new (Context) CastExpr(ICE->getType(),
                                                    ICE->getSubExpr(),

Modified: cfe/trunk/test/Rewriter/objc-modern-implicit-cast.mm
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Rewriter/objc-modern-implicit-cast.mm?rev=154679&r1=154678&r2=154679&view=diff
==============================================================================
--- cfe/trunk/test/Rewriter/objc-modern-implicit-cast.mm (original)
+++ cfe/trunk/test/Rewriter/objc-modern-implicit-cast.mm Fri Apr 13 13:00:54 2012
@@ -1,6 +1,7 @@
 // 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://11202764
+// XFAIL: *
 
 typedef void(^BL)(void);
 

Added: cfe/trunk/test/Rewriter/rewrite-modern-typeof.mm
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Rewriter/rewrite-modern-typeof.mm?rev=154679&view=auto
==============================================================================
--- cfe/trunk/test/Rewriter/rewrite-modern-typeof.mm (added)
+++ cfe/trunk/test/Rewriter/rewrite-modern-typeof.mm Fri Apr 13 13:00:54 2012
@@ -0,0 +1,46 @@
+// RUN: %clang_cc1 -x objective-c++ -fblocks -fms-extensions -rewrite-objc %s -o %t-rw.cpp
+// RUN: FileCheck -check-prefix LP --input-file=%t-rw.cpp %s
+// RUN: %clang_cc1 -fsyntax-only -Wno-address-of-temporary -Wno-attributes -D"Class=void*" -D"id=void*" -D"SEL=void*" -D"__declspec(X)=" %t-rw.cpp
+
+extern "C" {
+extern "C" void *_Block_copy(const void *aBlock);
+extern "C" void _Block_release(const void *aBlock);
+}
+
+int main() {
+    __attribute__((__blocks__(byref))) int a = 42;
+    int save_a = a;
+
+    void (^b)(void) = ^{
+        ((__typeof(^{ a = 2; }))_Block_copy((const void *)(^{ a = 2; })));
+    };
+
+    ((__typeof(b))_Block_copy((const void *)(b)));
+
+    return 0;
+}
+
+// CHECK-LP: ((void (^)(void))_Block_copy((const void *)(b)))
+
+// radar 7628153
+void f() {
+	int a;	
+	__typeof__(a) aVal = a;
+	char *a1t = (char *)@encode(__typeof__(a));
+        __typeof__(aVal) bVal;
+	char *a2t = (char *)@encode(__typeof__(bVal));
+        __typeof__(bVal) cVal = bVal;
+	char *a3t = (char *)@encode(__typeof__(cVal));
+
+}
+
+// rdar://11239324
+void x() {
+    id y;
+    void (^z)() = ^{ };
+    y = (id)((__typeof(z))_Block_copy((const void *)(z)));
+}
+
+// CHECK-LP: int aVal =  a;
+
+// CHECK-LP: int bVal;





More information about the cfe-commits mailing list