diff options
author | Fariborz Jahanian <fjahanian@apple.com> | 2012-08-08 23:41:08 +0000 |
---|---|---|
committer | Fariborz Jahanian <fjahanian@apple.com> | 2012-08-08 23:41:08 +0000 |
commit | 8c6cb462946b8be19167fad7ff21d4f9fbaebfef (patch) | |
tree | 5ca654c9523aac745873e0334e68f172fb89fac4 | |
parent | 817a8866b900458d88d13d8ba10829eaef493040 (diff) |
objective-C: refactor/simplify parsing of delayed
method/c-funcs defined in objc class implementation.
No intended functionality change.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@161540 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | include/clang/Sema/Sema.h | 3 | ||||
-rw-r--r-- | lib/Parse/ParseObjc.cpp | 5 | ||||
-rw-r--r-- | lib/Sema/SemaDeclObjC.cpp | 32 |
3 files changed, 9 insertions, 31 deletions
diff --git a/include/clang/Sema/Sema.h b/include/clang/Sema/Sema.h index e2f9e71f53..07dc4b4aeb 100644 --- a/include/clang/Sema/Sema.h +++ b/include/clang/Sema/Sema.h @@ -1318,8 +1318,7 @@ public: 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); } diff --git a/lib/Parse/ParseObjc.cpp b/lib/Parse/ParseObjc.cpp index 9d21c42b44..e401983a7e 100644 --- a/lib/Parse/ParseObjc.cpp +++ b/lib/Parse/ParseObjc.cpp @@ -2880,7 +2880,10 @@ void Parser::ParseLexedObjCMethodDefs(LexedMethod &LM, bool parseMethod) { // 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(); diff --git a/lib/Sema/SemaDeclObjC.cpp b/lib/Sema/SemaDeclObjC.cpp index 4a34095c1f..9da4d69382 100644 --- a/lib/Sema/SemaDeclObjC.cpp +++ b/lib/Sema/SemaDeclObjC.cpp @@ -282,34 +282,10 @@ void Sema::AddAnyMethodToGlobalPool(Decl *D) { 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. |