[cfe-commits] r48405 - in /cfe/trunk: include/clang/AST/DeclObjC.h lib/AST/DeclObjC.cpp lib/Sema/SemaDeclObjC.cpp

Chris Lattner sabre at nondot.org
Sat Mar 15 17:49:28 PDT 2008


Author: lattner
Date: Sat Mar 15 19:49:28 2008
New Revision: 48405

URL: http://llvm.org/viewvc/llvm-project?rev=48405&view=rev
Log:
Give ObjCMethodDecl a Create method.

Modified:
    cfe/trunk/include/clang/AST/DeclObjC.h
    cfe/trunk/lib/AST/DeclObjC.cpp
    cfe/trunk/lib/Sema/SemaDeclObjC.cpp

Modified: cfe/trunk/include/clang/AST/DeclObjC.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/DeclObjC.h?rev=48405&r1=48404&r2=48405&view=diff

==============================================================================
--- cfe/trunk/include/clang/AST/DeclObjC.h (original)
+++ cfe/trunk/include/clang/AST/DeclObjC.h Sat Mar 15 19:49:28 2008
@@ -88,7 +88,7 @@
   // FIXME: space savings opportunity, consider a sub-class.
   Stmt *Body;
   ParmVarDecl *SelfDecl;
-public:
+  
   ObjCMethodDecl(SourceLocation beginLoc, SourceLocation endLoc,
                  Selector SelInfo, QualType T,
                  Decl *contextDecl,
@@ -104,6 +104,17 @@
     SelName(SelInfo), MethodDeclType(T), 
     ParamInfo(paramInfo), NumMethodParams(numParams),
     MethodAttrs(M), EndLoc(endLoc), Body(0), SelfDecl(0) {}
+public:
+
+  static ObjCMethodDecl *Create(ASTContext &C, SourceLocation beginLoc, 
+                                SourceLocation endLoc, Selector SelInfo,
+                                QualType T, Decl *contextDecl,
+                                ParmVarDecl **paramInfo = 0, int numParams=-1,
+                                AttributeList *M = 0, bool isInstance = true,
+                                bool isVariadic = false,
+                                ImplementationControl impControl = None,
+                                Decl *PrevDecl = 0);
+  
   virtual ~ObjCMethodDecl();
   
   ObjCDeclQualifier getObjCDeclQualifier() const {

Modified: cfe/trunk/lib/AST/DeclObjC.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/DeclObjC.cpp?rev=48405&r1=48404&r2=48405&view=diff

==============================================================================
--- cfe/trunk/lib/AST/DeclObjC.cpp (original)
+++ cfe/trunk/lib/AST/DeclObjC.cpp Sat Mar 15 19:49:28 2008
@@ -15,6 +15,26 @@
 #include "clang/AST/ASTContext.h"
 using namespace clang;
 
+//===----------------------------------------------------------------------===//
+// ObjC Decl Allocation/Deallocation Method Implementations
+//===----------------------------------------------------------------------===//
+
+ObjCMethodDecl *ObjCMethodDecl::Create(ASTContext &C, SourceLocation beginLoc, 
+                                       SourceLocation endLoc,
+                                       Selector SelInfo, QualType T,
+                                       Decl *contextDecl,
+                                       ParmVarDecl **paramInfo, int numParams,
+                                       AttributeList *M, bool isInstance,
+                                       bool isVariadic,
+                                       ImplementationControl impControl,
+                                       Decl *PrevDecl) {
+  void *Mem = C.getAllocator().Allocate<ObjCMethodDecl>();
+  return new (Mem) ObjCMethodDecl(beginLoc, endLoc, SelInfo, T, contextDecl,
+                                  paramInfo, numParams, M, isInstance, 
+                                  isVariadic, impControl, PrevDecl);
+
+}
+
 
 //===----------------------------------------------------------------------===//
 // Objective-C Decl Implementation

Modified: cfe/trunk/lib/Sema/SemaDeclObjC.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclObjC.cpp?rev=48405&r1=48404&r2=48405&view=diff

==============================================================================
--- cfe/trunk/lib/Sema/SemaDeclObjC.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclObjC.cpp Sat Mar 15 19:49:28 2008
@@ -799,7 +799,7 @@
 
 Sema::DeclTy *Sema::ActOnMethodDeclaration(
     SourceLocation MethodLoc, SourceLocation EndLoc,
-    tok::TokenKind MethodType, DeclTy *ClassDecl,
+    tok::TokenKind MethodType, DeclTy *classDecl,
     ObjCDeclSpec &ReturnQT, TypeTy *ReturnType,
     Selector Sel,
     // optional arguments. The number of types/arguments is obtained
@@ -807,6 +807,7 @@
     ObjCDeclSpec *ArgQT, TypeTy **ArgTypes, IdentifierInfo **ArgNames,
     AttributeList *AttrList, tok::ObjCKeywordKind MethodDeclKind,
     bool isVariadic) {
+  Decl *ClassDecl = static_cast<Decl*>(classDecl);
 
   // Make sure we can establish a context for the method.
   if (!ClassDecl) {
@@ -837,15 +838,14 @@
   else // get the type for "id".
     resultDeclType = Context.getObjCIdType();
   
-  Decl *CDecl = static_cast<Decl*>(ClassDecl);
-  ObjCMethodDecl* ObjCMethod =  new ObjCMethodDecl(MethodLoc, EndLoc, Sel,
-                                      resultDeclType,
-                                      CDecl,
-                                      0, -1, AttrList, 
-                                      MethodType == tok::minus, isVariadic,
-                                      MethodDeclKind == tok::objc_optional ? 
-                                      ObjCMethodDecl::Optional : 
-                                      ObjCMethodDecl::Required);
+  ObjCMethodDecl* ObjCMethod = 
+    ObjCMethodDecl::Create(Context, MethodLoc, EndLoc, Sel, resultDeclType,
+                           ClassDecl, 0, -1, AttrList, 
+                           MethodType == tok::minus, isVariadic,
+                           MethodDeclKind == tok::objc_optional ? 
+                           ObjCMethodDecl::Optional : 
+                           ObjCMethodDecl::Required);
+  
   ObjCMethod->setMethodParams(&Params[0], Sel.getNumArgs());
   ObjCMethod->setObjCDeclQualifier(
     CvtQTToAstBitMask(ReturnQT.getObjCDeclQualifier()));
@@ -856,7 +856,7 @@
   // incrementally (without waiting until we parse the @end). It also allows 
   // us to flag multiple declaration errors as they occur.
   if (ObjCImplementationDecl *ImpDecl = 
-        dyn_cast<ObjCImplementationDecl>(CDecl)) {
+        dyn_cast<ObjCImplementationDecl>(ClassDecl)) {
     if (MethodType == tok::minus) {
       PrevMethod = ImpDecl->getInstanceMethod(Sel);
       ImpDecl->addInstanceMethod(ObjCMethod);
@@ -866,7 +866,7 @@
     }
   } 
   else if (ObjCCategoryImplDecl *CatImpDecl = 
-            dyn_cast<ObjCCategoryImplDecl>(CDecl)) {
+            dyn_cast<ObjCCategoryImplDecl>(ClassDecl)) {
     if (MethodType == tok::minus) {
       PrevMethod = CatImpDecl->getInstanceMethod(Sel);
       CatImpDecl->addInstanceMethod(ObjCMethod);





More information about the cfe-commits mailing list