[cfe-commits] r44008 - in /cfe/trunk/Sema: Sema.h SemaDecl.cpp

Steve Naroff snaroff at apple.com
Sun Nov 11 20:59:01 PST 2007


Author: snaroff
Date: Sun Nov 11 22:59:00 2007
New Revision: 44008

URL: http://llvm.org/viewvc/llvm-project?rev=44008&view=rev
Log:

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().


Modified:
    cfe/trunk/Sema/Sema.h
    cfe/trunk/Sema/SemaDecl.cpp

Modified: cfe/trunk/Sema/Sema.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Sema/Sema.h?rev=44008&r1=44007&r2=44008&view=diff

==============================================================================
--- cfe/trunk/Sema/Sema.h (original)
+++ cfe/trunk/Sema/Sema.h Sun Nov 11 22:59:00 2007
@@ -184,8 +184,6 @@
   //
   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);
 

Modified: cfe/trunk/Sema/SemaDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Sema/SemaDecl.cpp?rev=44008&r1=44007&r2=44008&view=diff

==============================================================================
--- cfe/trunk/Sema/SemaDecl.cpp (original)
+++ cfe/trunk/Sema/SemaDecl.cpp Sun Nov 11 22:59:00 2007
@@ -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





More information about the cfe-commits mailing list