[cfe-commits] r95164 - in /cfe/trunk: include/clang/Parse/Action.h lib/Parse/ParseObjc.cpp lib/Sema/Sema.h lib/Sema/SemaDecl.cpp test/CodeGenObjC/blocks-4.m

Fariborz Jahanian fjahanian at apple.com
Tue Feb 2 16:01:44 PST 2010


Author: fjahanian
Date: Tue Feb  2 18:01:43 2010
New Revision: 95164

URL: http://llvm.org/viewvc/llvm-project?rev=95164&view=rev
Log:
Fix DeclContext of an objective-c @catch variable
declaration. Fixes radar 7590273.


Added:
    cfe/trunk/test/CodeGenObjC/blocks-4.m
Modified:
    cfe/trunk/include/clang/Parse/Action.h
    cfe/trunk/lib/Parse/ParseObjc.cpp
    cfe/trunk/lib/Sema/Sema.h
    cfe/trunk/lib/Sema/SemaDecl.cpp

Modified: cfe/trunk/include/clang/Parse/Action.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Parse/Action.h?rev=95164&r1=95163&r2=95164&view=diff

==============================================================================
--- cfe/trunk/include/clang/Parse/Action.h (original)
+++ cfe/trunk/include/clang/Parse/Action.h Tue Feb  2 18:01:43 2010
@@ -459,6 +459,8 @@
   virtual DeclPtrTy ActOnParamDeclarator(Scope *S, Declarator &D) {
     return DeclPtrTy();
   }
+  virtual void ActOnObjCCatchParam(DeclPtrTy D) {
+  }
 
   /// AddInitializerToDecl - This action is called immediately after
   /// ActOnDeclarator (when an initializer is present). The code is factored

Modified: cfe/trunk/lib/Parse/ParseObjc.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseObjc.cpp?rev=95164&r1=95163&r2=95164&view=diff

==============================================================================
--- cfe/trunk/lib/Parse/ParseObjc.cpp (original)
+++ cfe/trunk/lib/Parse/ParseObjc.cpp Tue Feb  2 18:01:43 2010
@@ -1482,6 +1482,7 @@
           // Inform the actions module about the parameter declarator, so it
           // gets added to the current scope.
           FirstPart = Actions.ActOnParamDeclarator(CurScope, ParmDecl);
+          Actions.ActOnObjCCatchParam(FirstPart);
         } else
           ConsumeToken(); // consume '...'
 

Modified: cfe/trunk/lib/Sema/Sema.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/Sema.h?rev=95164&r1=95163&r2=95164&view=diff

==============================================================================
--- cfe/trunk/lib/Sema/Sema.h (original)
+++ cfe/trunk/lib/Sema/Sema.h Tue Feb  2 18:01:43 2010
@@ -676,6 +676,7 @@
                                 bool &OverloadableAttrRequired);
   void CheckMain(FunctionDecl *FD);
   virtual DeclPtrTy ActOnParamDeclarator(Scope *S, Declarator &D);
+  virtual void ActOnObjCCatchParam(DeclPtrTy D);
   virtual void ActOnParamDefaultArgument(DeclPtrTy param,
                                          SourceLocation EqualLoc,
                                          ExprArg defarg);

Modified: cfe/trunk/lib/Sema/SemaDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=95164&r1=95163&r2=95164&view=diff

==============================================================================
--- cfe/trunk/lib/Sema/SemaDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDecl.cpp Tue Feb  2 18:01:43 2010
@@ -3934,6 +3934,19 @@
   return DeclPtrTy::make(New);
 }
 
+void Sema::ActOnObjCCatchParam(DeclPtrTy D) {
+  ParmVarDecl *Param = cast<ParmVarDecl>(D.getAs<Decl>());
+  
+  if (FunctionDecl *Function = dyn_cast<FunctionDecl>(CurContext))
+    Param->setDeclContext(Function);
+  else if (CXXMethodDecl *MD = dyn_cast<CXXMethodDecl>(CurContext))
+    Param->setDeclContext(MD);
+  else if (BlockDecl *BD = dyn_cast<BlockDecl>(CurContext))
+    Param->setDeclContext(BD);
+  // FIXME. Other contexts?
+  
+}
+
 void Sema::ActOnFinishKNRParamDeclarations(Scope *S, Declarator &D,
                                            SourceLocation LocAfterDecls) {
   assert(D.getTypeObject(0).Kind == DeclaratorChunk::Function &&

Added: cfe/trunk/test/CodeGenObjC/blocks-4.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenObjC/blocks-4.m?rev=95164&view=auto

==============================================================================
--- cfe/trunk/test/CodeGenObjC/blocks-4.m (added)
+++ cfe/trunk/test/CodeGenObjC/blocks-4.m Tue Feb  2 18:01:43 2010
@@ -0,0 +1,21 @@
+// RUN: %clang_cc1 -triple i386-apple-darwin9 -emit-llvm -fblocks -o %t %s
+// rdar://7590273
+
+void EXIT(id e);
+
+ at interface NSBlockOperation {
+}
++(id)blockOperationWithBlock:(void (^)(void))block ;
+ at end
+
+void FUNC() {
+        [NSBlockOperation blockOperationWithBlock:^{
+            @try {
+
+            }
+            @catch (id exception) {
+		EXIT(exception);
+            }
+        }];
+
+}





More information about the cfe-commits mailing list