diff options
author | Steve Naroff <snaroff@apple.com> | 2007-11-12 04:59:00 +0000 |
---|---|---|
committer | Steve Naroff <snaroff@apple.com> | 2007-11-12 04:59:00 +0000 |
commit | 0755aba7dadbcd2b49a0b376a3c70dbaa8145bd3 (patch) | |
tree | f6872f817308563c63b2bb8a03a4b2eb75a46013 /Sema/SemaDecl.cpp | |
parent | eaf5f419a50a8a5297a0815f987c4dbf6c247017 (diff) |
Remove Action::ObjcActOnMethodDefinition(). Rationale:
- It is not an "action" - it is never called by the parser.
- It was only used by one method, Sema::ObjcActOnStartOfMethodDef().
As a result, the logic it embodied is now directly implemented in Sema::ObjcActOnStartOfMethodDef().
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@44008 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'Sema/SemaDecl.cpp')
-rw-r--r-- | Sema/SemaDecl.cpp | 65 |
1 files changed, 20 insertions, 45 deletions
diff --git a/Sema/SemaDecl.cpp b/Sema/SemaDecl.cpp index 3933963a71..05a9f6130d 100644 --- a/Sema/SemaDecl.cpp +++ b/Sema/SemaDecl.cpp @@ -544,46 +544,6 @@ bool Sema::CheckInitializer(Expr *&Init, QualType &DeclType, bool isStatic) { return hadError; } -/// ObjcActOnMethodDefinition - Build the AST node for a method definition -/// header. Return this AST. -Sema::DeclTy * -Sema::ObjcActOnMethodDefinition(Scope *S, DeclTy *D, DeclTy *lastDecl) { - ObjcMethodDecl *MDecl = dyn_cast<ObjcMethodDecl>(static_cast<Decl *>(D)); - - ScopedDecl *LastDeclarator = dyn_cast_or_null<ScopedDecl>((Decl *)lastDecl); - // build [classname selector-name] for the name of method. - std::string Name = "["; - Name += MDecl->getClassInterface()->getName(); - Name += " "; - Name += MDecl->getSelector().getName(); - Name += "]"; - IdentifierInfo *II = &Context.Idents.get(Name); - assert (II && "ObjcActOnMethodDefinition - selector name is missing"); - - // The scope passed in may not be a decl scope. Zip up the scope tree until - // we find one that is. - while ((S->getFlags() & Scope::DeclScope) == 0) - S = S->getParent(); - - ScopedDecl *New; - QualType R = ObjcGetTypeForMethodDefinition(MDecl, S); - assert(!R.isNull() && "ObjcGetTypeForMethodDefinition() returned null type"); - - FunctionDecl *NewFD = new FunctionDecl(MDecl->getLocation(), II, R, - FunctionDecl::Static, - false, LastDeclarator); - New = NewFD; - - New->setNext(II->getFETokenInfo<ScopedDecl>()); - II->setFETokenInfo(New); - S->AddDecl(New); - - if (S->getParent() == 0) - AddTopLevelDecl(New, LastDeclarator); - - return New; -} - Sema::DeclTy * Sema::ActOnDeclarator(Scope *S, Declarator &D, DeclTy *lastDecl) { ScopedDecl *LastDeclarator = dyn_cast_or_null<ScopedDecl>((Decl *)lastDecl); @@ -990,10 +950,26 @@ void Sema::ObjcActOnStartOfMethodDef(Scope *FnBodyScope, DeclTy *D) { Scope *GlobalScope = FnBodyScope->getParent(); - FunctionDecl *FD = - static_cast<FunctionDecl*>(ObjcActOnMethodDefinition(GlobalScope, D, 0)); - CurFunctionDecl = FD; + // build [classname selector-name] for the name of method. + std::string Name = "["; + Name += MDecl->getClassInterface()->getName(); + Name += " "; + Name += MDecl->getSelector().getName(); + Name += "]"; + IdentifierInfo *II = &Context.Idents.get(Name); + assert (II && "ObjcActOnMethodDefinition - selector name is missing"); + QualType R = ObjcGetTypeForMethodDefinition(MDecl, GlobalScope); + assert(!R.isNull() && "ObjcGetTypeForMethodDefinition() returned null type"); + + FunctionDecl *NewFD = new FunctionDecl(MDecl->getLocation(), II, R, + FunctionDecl::Static, false, 0); + NewFD->setNext(II->getFETokenInfo<ScopedDecl>()); + II->setFETokenInfo(NewFD); + GlobalScope->AddDecl(NewFD); + AddTopLevelDecl(NewFD, 0); + CurFunctionDecl = NewFD; + // Create Decl objects for each parameter, adding them to the FunctionDecl. llvm::SmallVector<ParmVarDecl*, 16> Params; struct DeclaratorChunk::ParamInfo PI; @@ -1023,8 +999,7 @@ void Sema::ObjcActOnStartOfMethodDef(Scope *FnBodyScope, DeclTy *D) { PI.TypeInfo = PDecl->getType().getAsOpaquePtr(); Params.push_back(ParseParamDeclarator(PI, FnBodyScope)); } - - FD->setParams(&Params[0], Params.size()); + NewFD->setParams(&Params[0], Params.size()); } /// ImplicitlyDefineFunction - An undeclared identifier was used in a function |