diff options
author | Fariborz Jahanian <fjahanian@apple.com> | 2012-07-02 23:37:09 +0000 |
---|---|---|
committer | Fariborz Jahanian <fjahanian@apple.com> | 2012-07-02 23:37:09 +0000 |
commit | 6c89eafc90f5c51a0bf185a993961170aee530c2 (patch) | |
tree | 1c52effa180188efec187d7271e24009d3c1d36a /lib/Sema/SemaDeclObjC.cpp | |
parent | a9e8b9e3e90fcfe10a04624a89c39b63c32614d1 (diff) |
objective-c: just as we have done for method definitions,
c-functions declared in implementation should have their
parsing delayed until the end so, they can access forward
declared private methods. // rdar://10387088
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@159626 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaDeclObjC.cpp')
-rw-r--r-- | lib/Sema/SemaDeclObjC.cpp | 34 |
1 files changed, 29 insertions, 5 deletions
diff --git a/lib/Sema/SemaDeclObjC.cpp b/lib/Sema/SemaDeclObjC.cpp index a673d247ed..7342128715 100644 --- a/lib/Sema/SemaDeclObjC.cpp +++ b/lib/Sema/SemaDeclObjC.cpp @@ -265,12 +265,36 @@ void Sema::AddAnyMethodToGlobalPool(Decl *D) { AddFactoryMethodToGlobalPool(MDecl, true); } -/// 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 && "Method parsing confused"); +/// 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 = 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; + } + ObjCMethodDecl *MDecl = dyn_cast_or_null<ObjCMethodDecl>(D); - + // If we don't have a valid method decl, simply return. if (!MDecl) return; |