]> granicus.if.org Git - clang/commitdiff
Rework Parser-Sema interface for Objective-C @catch exception object
authorDouglas Gregor <dgregor@apple.com>
Fri, 23 Apr 2010 23:01:43 +0000 (23:01 +0000)
committerDouglas Gregor <dgregor@apple.com>
Fri, 23 Apr 2010 23:01:43 +0000 (23:01 +0000)
arguments. Rather than having the parser call ActOnParamDeclarator
(which is a bit of a hack), call a new ActOnObjCExceptionDecl
action. We'll be moving more functionality into this handler to
perform earlier checking of @catch.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@102222 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/Parse/Action.h
lib/Parse/ParseObjc.cpp
lib/Sema/Sema.h
lib/Sema/SemaDecl.cpp
lib/Sema/SemaDeclObjC.cpp

index dd12fdfe3ecf53ed815411824e7b9c360c5ed377..6b1652284821ce29f28218264ae028e7bff85da5 100644 (file)
@@ -468,7 +468,11 @@ public:
   virtual DeclPtrTy ActOnParamDeclarator(Scope *S, Declarator &D) {
     return DeclPtrTy();
   }
-  virtual void ActOnObjCCatchParam(DeclPtrTy D) {
+
+  /// \brief Parsed an exception object declaration within an Objective-C
+  /// @catch statement.
+  virtual DeclPtrTy ActOnObjCExceptionDecl(Scope *S, Declarator &D) {
+    return DeclPtrTy();
   }
 
   /// AddInitializerToDecl - This action is called immediately after
index 4846dad7b09b82795f211c17ce1e367e89d10df9..e30ec83d8421f299b40dd9cb9475632f203cf217 100644 (file)
@@ -1542,11 +1542,9 @@ Parser::OwningStmtResult Parser::ParseObjCTryStmt(SourceLocation atLoc) {
           Declarator ParmDecl(DS, Declarator::PrototypeContext);
           ParseDeclarator(ParmDecl);
 
-          // Inform the actions module about the parameter declarator, so it
+          // Inform the actions module about the declarator, so it
           // gets added to the current scope.
-          // FIXME. Probably can build a VarDecl and avoid setting DeclContext.
-          FirstPart = Actions.ActOnParamDeclarator(CurScope, ParmDecl);
-          Actions.ActOnObjCCatchParam(FirstPart);
+          FirstPart = Actions.ActOnObjCExceptionDecl(CurScope, ParmDecl);
         } else
           ConsumeToken(); // consume '...'
 
index e9cd6ca7d64eeadf91f8f60225d5276e811967d1..64afd56a40f17589720c6581ad2e405bfa0cafaf 100644 (file)
@@ -812,7 +812,7 @@ public:
                               SourceLocation NameLoc,
                               VarDecl::StorageClass StorageClass,
                               VarDecl::StorageClass StorageClassAsWritten);
-  virtual void ActOnObjCCatchParam(DeclPtrTy D);
+  virtual DeclPtrTy ActOnObjCExceptionDecl(Scope *S, Declarator &D);
   virtual void ActOnParamDefaultArgument(DeclPtrTy param,
                                          SourceLocation EqualLoc,
                                          ExprArg defarg);
index 4800337383c3c83da041af685b611185414759b8..83796ba65ff9d5815113ea36f863c53b89c1cb0e 100644 (file)
@@ -4258,11 +4258,6 @@ ParmVarDecl *Sema::CheckParameter(DeclContext *DC,
   return New;
 }
 
-void Sema::ActOnObjCCatchParam(DeclPtrTy D) {
-  ParmVarDecl *Param = cast<ParmVarDecl>(D.getAs<Decl>());
-  Param->setDeclContext(CurContext);
-}
-
 void Sema::ActOnFinishKNRParamDeclarations(Scope *S, Declarator &D,
                                            SourceLocation LocAfterDecls) {
   assert(D.getTypeObject(0).Kind == DeclaratorChunk::Function &&
index e1973fa5c208a9c04901f69a7bc464fb36323562..9a223e91dc3c08ef50df07fbdecfddc7052e010b 100644 (file)
@@ -1707,3 +1707,10 @@ void Sema::ActOnDefs(Scope *S, DeclPtrTy TagD, SourceLocation DeclStart,
   }
 }
 
+Sema::DeclPtrTy Sema::ActOnObjCExceptionDecl(Scope *S, Declarator &D) {
+  // FIXME: Perform checking on the declaration here.
+  DeclPtrTy Dcl = ActOnParamDeclarator(S, D);
+  if (Dcl.get())
+    cast<ParmVarDecl>(Dcl.getAs<Decl>())->setDeclContext(CurContext);
+  return Dcl;
+}