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
diff --git a/Sema/SemaDecl.cpp b/Sema/SemaDecl.cpp
index 3933963..05a9f61 100644
--- a/Sema/SemaDecl.cpp
+++ b/Sema/SemaDecl.cpp
@@ -544,46 +544,6 @@
   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 @@
   
   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 @@
     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