[cfe-commits] r128410 - in /cfe/trunk: lib/Sema/SemaExprObjC.cpp test/SemaObjC/self-in-function.m

Fariborz Jahanian fjahanian at apple.com
Mon Mar 28 09:23:34 PDT 2011


Author: fjahanian
Date: Mon Mar 28 11:23:34 2011
New Revision: 128410

URL: http://llvm.org/viewvc/llvm-project?rev=128410&view=rev
Log:
Also 'self' in blocks need be handled specially.
// rdar://9181463

Modified:
    cfe/trunk/lib/Sema/SemaExprObjC.cpp
    cfe/trunk/test/SemaObjC/self-in-function.m

Modified: cfe/trunk/lib/Sema/SemaExprObjC.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExprObjC.cpp?rev=128410&r1=128409&r2=128410&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaExprObjC.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExprObjC.cpp Mon Mar 28 11:23:34 2011
@@ -325,7 +325,10 @@
 
 bool Sema::isSelfExpr(Expr *RExpr) {
   // 'self' is objc 'self' in an objc method only.
-  if (!isa<ObjCMethodDecl>(CurContext))
+  DeclContext *DC = CurContext;
+  while (isa<BlockDecl>(DC))
+    DC = DC->getParent();
+  if (DC && !isa<ObjCMethodDecl>(DC))
     return false;
   if (ImplicitCastExpr *ICE = dyn_cast<ImplicitCastExpr>(RExpr))
     if (ICE->getCastKind() == CK_LValueToRValue)

Modified: cfe/trunk/test/SemaObjC/self-in-function.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjC/self-in-function.m?rev=128410&r1=128409&r2=128410&view=diff
==============================================================================
--- cfe/trunk/test/SemaObjC/self-in-function.m (original)
+++ cfe/trunk/test/SemaObjC/self-in-function.m Mon Mar 28 11:23:34 2011
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1  -fsyntax-only -verify %s
+// RUN: %clang_cc1  -fsyntax-only -fblocks -verify %s
 // rdar://9181463
 
 typedef struct objc_class *Class;
@@ -14,6 +14,9 @@
 
 void foo(Class self) {
   [self alloc];
+  (^() {
+    [self alloc];
+   })();
 }
 
 void bar(Class self) {





More information about the cfe-commits mailing list