[cfe-commits] r161540 - in /cfe/trunk: include/clang/Sema/Sema.h lib/Parse/ParseObjc.cpp lib/Sema/SemaDeclObjC.cpp

Fariborz Jahanian fjahanian at apple.com
Wed Aug 8 16:41:08 PDT 2012


Author: fjahanian
Date: Wed Aug  8 18:41:08 2012
New Revision: 161540

URL: http://llvm.org/viewvc/llvm-project?rev=161540&view=rev
Log:
objective-C: refactor/simplify parsing of delayed
method/c-funcs defined in objc class implementation.
No intended functionality change.

Modified:
    cfe/trunk/include/clang/Sema/Sema.h
    cfe/trunk/lib/Parse/ParseObjc.cpp
    cfe/trunk/lib/Sema/SemaDeclObjC.cpp

Modified: cfe/trunk/include/clang/Sema/Sema.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Sema.h?rev=161540&r1=161539&r2=161540&view=diff
==============================================================================
--- cfe/trunk/include/clang/Sema/Sema.h (original)
+++ cfe/trunk/include/clang/Sema/Sema.h Wed Aug  8 18:41:08 2012
@@ -1318,8 +1318,7 @@
   void CheckForFunctionRedefinition(FunctionDecl *FD);
   Decl *ActOnStartOfFunctionDef(Scope *S, Declarator &D);
   Decl *ActOnStartOfFunctionDef(Scope *S, Decl *D);
-  void ActOnStartOfObjCMethodOrCFunctionDef(Scope *S, Decl *D,
-                                            bool parseMethod);
+  void ActOnStartOfObjCMethodDef(Scope *S, Decl *D);
   bool isObjCMethodDecl(Decl *D) {
     return D && isa<ObjCMethodDecl>(D);
   }

Modified: cfe/trunk/lib/Parse/ParseObjc.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseObjc.cpp?rev=161540&r1=161539&r2=161540&view=diff
==============================================================================
--- cfe/trunk/lib/Parse/ParseObjc.cpp (original)
+++ cfe/trunk/lib/Parse/ParseObjc.cpp Wed Aug  8 18:41:08 2012
@@ -2880,7 +2880,10 @@
     
   // Tell the actions module that we have entered a method or c-function definition 
   // with the specified Declarator for the method/function.
-  Actions.ActOnStartOfObjCMethodOrCFunctionDef(getCurScope(), MCDecl, parseMethod);
+  if (parseMethod)
+    Actions.ActOnStartOfObjCMethodDef(getCurScope(), MCDecl);
+  else
+    Actions.ActOnStartOfFunctionDef(getCurScope(), MCDecl);
     
   if (SkipFunctionBodies && trySkippingFunctionBody()) {
     BodyScope.Exit();

Modified: cfe/trunk/lib/Sema/SemaDeclObjC.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclObjC.cpp?rev=161540&r1=161539&r2=161540&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaDeclObjC.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclObjC.cpp Wed Aug  8 18:41:08 2012
@@ -282,34 +282,10 @@
     AddFactoryMethodToGlobalPool(MDecl, true);
 }
 
-/// ActOnStartOfObjCMethodOrCFunctionDef - This routine sets up parameters; invisible
-/// and user declared, in the method definition's AST. This routine is also  called
-/// for C-functions defined in an Objective-c class implementation.
-void Sema::ActOnStartOfObjCMethodOrCFunctionDef(Scope *FnBodyScope, Decl *D,
-                                                bool parseMethod) {
-  assert((getCurMethodDecl() == 0 && getCurFunctionDecl() == 0) &&
-         "Method/c-function parsing confused");
-  if (!parseMethod) {
-    FunctionDecl *FDecl = dyn_cast_or_null<FunctionDecl>(D);
-    // If we don't have a valid c-function decl, simply return.
-    if (!FDecl)
-      return;
-    PushDeclContext(FnBodyScope, FDecl);
-    PushFunctionScope();
-    
-    for (FunctionDecl::param_const_iterator PI = FDecl->param_begin(),
-         E = FDecl->param_end(); PI != E; ++PI) {
-      ParmVarDecl *Param = (*PI);
-      if (!Param->isInvalidDecl() &&
-          RequireCompleteType(Param->getLocation(), Param->getType(),
-                              diag::err_typecheck_decl_incomplete_type))
-        Param->setInvalidDecl();
-      if ((*PI)->getIdentifier())
-        PushOnScopeChains(*PI, FnBodyScope);
-    }
-    return;
-  }
-  
+/// ActOnStartOfObjCMethodDef - This routine sets up parameters; invisible
+/// and user declared, in the method definition's AST.
+void Sema::ActOnStartOfObjCMethodDef(Scope *FnBodyScope, Decl *D) {
+  assert((getCurMethodDecl() == 0) && "Methodparsing confused");
   ObjCMethodDecl *MDecl = dyn_cast_or_null<ObjCMethodDecl>(D);
   
   // If we don't have a valid method decl, simply return.





More information about the cfe-commits mailing list