[cfe-commits] r154876 - in /cfe/trunk: lib/Rewrite/RewriteModernObjC.cpp test/Rewriter/rewrite-block-literal-1.mm

Fariborz Jahanian fjahanian at apple.com
Mon Apr 16 16:00:57 PDT 2012


Author: fjahanian
Date: Mon Apr 16 18:00:57 2012
New Revision: 154876

URL: http://llvm.org/viewvc/llvm-project?rev=154876&view=rev
Log:
Modern objective-c translator:'self' used inside
block literal is imported. // rdar://11259664

Modified:
    cfe/trunk/lib/Rewrite/RewriteModernObjC.cpp
    cfe/trunk/test/Rewriter/rewrite-block-literal-1.mm

Modified: cfe/trunk/lib/Rewrite/RewriteModernObjC.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Rewrite/RewriteModernObjC.cpp?rev=154876&r1=154875&r2=154876&view=diff
==============================================================================
--- cfe/trunk/lib/Rewrite/RewriteModernObjC.cpp (original)
+++ cfe/trunk/lib/Rewrite/RewriteModernObjC.cpp Mon Apr 16 18:00:57 2012
@@ -4156,11 +4156,15 @@
         GetBlockDeclRefExprs(*CI);
     }
   // Handle specific things.
-  if (DeclRefExpr *DRE = dyn_cast<DeclRefExpr>(S))
-    if (DRE->refersToEnclosingLocal() &&
-        HasLocalVariableExternalStorage(DRE->getDecl())) {
-      BlockDeclRefs.push_back(DRE);
+  if (DeclRefExpr *DRE = dyn_cast<DeclRefExpr>(S)) {
+    if (DRE->refersToEnclosingLocal()) {
+      // FIXME: Handle enums.
+      if (!isa<FunctionDecl>(DRE->getDecl()))
+        BlockDeclRefs.push_back(DRE);
+      if (HasLocalVariableExternalStorage(DRE->getDecl()))
+        BlockDeclRefs.push_back(DRE);
     }
+  }
   
   return;
 }

Modified: cfe/trunk/test/Rewriter/rewrite-block-literal-1.mm
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Rewriter/rewrite-block-literal-1.mm?rev=154876&r1=154875&r2=154876&view=diff
==============================================================================
--- cfe/trunk/test/Rewriter/rewrite-block-literal-1.mm (original)
+++ cfe/trunk/test/Rewriter/rewrite-block-literal-1.mm Mon Apr 16 18:00:57 2012
@@ -1,6 +1,9 @@
 // RUN: %clang_cc1 -x objective-c++ -Wno-return-type -fblocks -fms-extensions -rewrite-objc -fobjc-fragile-abi %s -o %t-rw.cpp
 // RUN: %clang_cc1 -fsyntax-only -Wno-address-of-temporary -Did="void *" -D"SEL=void*" -D"__declspec(X)=" %t-rw.cpp
 // radar 9254348
+// RUN: %clang_cc1 -x objective-c++ -Wno-return-type -fblocks -fms-extensions -rewrite-objc %s -o %t-modern-rw.cpp
+// RUN: %clang_cc1 -fsyntax-only -Wno-address-of-temporary -Did="void *" -D"SEL=void*" -D"__declspec(X)=" %t-modern-rw.cpp
+// rdar://11259664
 
 void *sel_registerName(const char *);
 typedef void (^BLOCK_TYPE)(void);





More information about the cfe-commits mailing list