]> granicus.if.org Git - clang/commitdiff
Remove Action::ObjcActOnMethodDefinition(). Rationale:
authorSteve Naroff <snaroff@apple.com>
Mon, 12 Nov 2007 04:59:00 +0000 (04:59 +0000)
committerSteve Naroff <snaroff@apple.com>
Mon, 12 Nov 2007 04:59:00 +0000 (04:59 +0000)
- 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

Sema/Sema.h
Sema/SemaDecl.cpp

index 34f82e125d96c640e50b928f254e00ad5476e2ea..395adbc312850904abaf2237c2812971a8f78193 100644 (file)
@@ -184,8 +184,6 @@ private:
   //
   virtual DeclTy *isTypeName(const IdentifierInfo &II, Scope *S) const;
   virtual DeclTy *ActOnDeclarator(Scope *S, Declarator &D, DeclTy *LastInGroup);
-  virtual DeclTy *ObjcActOnMethodDefinition(Scope *S, DeclTy *D, 
-                                           DeclTy *LastInGroup);
   void AddInitializerToDecl(DeclTy *dcl, ExprTy *init);
   virtual DeclTy *FinalizeDeclaratorGroup(Scope *S, DeclTy *Group);
 
index 3933963a7171604f74ee9ce572f423f1f8db5803..05a9f6130d2e1c856036180c0e978587c50c1b2c 100644 (file)
@@ -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