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

Chris Lattner sabre at nondot.org
Sat Mar 15 18:15:50 PDT 2008


Author: lattner
Date: Sat Mar 15 20:15:50 2008
New Revision: 48408

URL: http://llvm.org/viewvc/llvm-project?rev=48408&view=rev
Log:
Add create methods for ObjCIvarDecl and ObjCInterfaceDecl

Modified:
    cfe/trunk/include/clang/AST/DeclObjC.h
    cfe/trunk/lib/AST/DeclObjC.cpp
    cfe/trunk/lib/Sema/Sema.cpp
    cfe/trunk/lib/Sema/SemaDecl.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=48408&r1=48407&r2=48408&view=diff

==============================================================================
--- cfe/trunk/include/clang/AST/DeclObjC.h (original)
+++ cfe/trunk/include/clang/AST/DeclObjC.h Sat Mar 15 20:15:50 2008
@@ -224,7 +224,7 @@
   
   SourceLocation EndLoc; // marks the '>', '}', or identifier.
   SourceLocation AtEndLoc; // marks the end of the entire interface.
-public:
+
   ObjCInterfaceDecl(SourceLocation atLoc, unsigned numRefProtos,
                     IdentifierInfo *Id, bool FD = false, 
                     bool isInternal = false)
@@ -237,6 +237,12 @@
       ForwardDecl(FD), InternalInterface(isInternal) {
         AllocIntfRefProtocols(numRefProtos);
       }
+public:
+
+  static ObjCInterfaceDecl *Create(ASTContext &C, SourceLocation atLoc,
+                                   unsigned numRefProtos, IdentifierInfo *Id,
+                                   bool ForwardDecl = false,
+                                   bool isInternal = false);
   
   // This is necessary when converting a forward declaration to a definition.
   void AllocIntfRefProtocols(unsigned numRefProtos) {
@@ -303,20 +309,20 @@
   // Get the local instance method declared in this interface.
   ObjCMethodDecl *getInstanceMethod(Selector &Sel) {
     for (instmeth_iterator I = instmeth_begin(), E = instmeth_end(); 
-             I != E; ++I) {
+         I != E; ++I) {
       if ((*I)->getSelector() == Sel)
         return *I;
     }
-        return 0;
+    return 0;
   }
   // Get the local class method declared in this interface.
   ObjCMethodDecl *getClassMethod(Selector &Sel) {
     for (classmeth_iterator I = classmeth_begin(), E = classmeth_end(); 
-             I != E; ++I) {
+         I != E; ++I) {
       if ((*I)->getSelector() == Sel)
         return *I;
     }
-        return 0;
+    return 0;
   }
   // Lookup a method. First, we search locally. If a method isn't
   // found, we search referenced protocols and class categories.
@@ -365,9 +371,11 @@
 ///   }
 ///
 class ObjCIvarDecl : public FieldDecl {
-public:
   ObjCIvarDecl(SourceLocation L, IdentifierInfo *Id, QualType T) 
     : FieldDecl(ObjCIvar, L, Id, T) {}
+public:
+  static ObjCIvarDecl *Create(ASTContext &C, SourceLocation L,
+                              IdentifierInfo *Id, QualType T);
     
   enum AccessControl {
     None, Private, Protected, Public, Package

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

==============================================================================
--- cfe/trunk/lib/AST/DeclObjC.cpp (original)
+++ cfe/trunk/lib/AST/DeclObjC.cpp Sat Mar 15 20:15:50 2008
@@ -30,7 +30,21 @@
   return new (Mem) ObjCMethodDecl(beginLoc, endLoc, SelInfo, T, contextDecl,
                                   M, isInstance, 
                                   isVariadic, impControl);
+}
+
+ObjCInterfaceDecl *ObjCInterfaceDecl::Create(ASTContext &C,SourceLocation atLoc,
+                                             unsigned numRefProtos,
+                                             IdentifierInfo *Id,
+                                             bool ForwardDecl, bool isInternal){
+  void *Mem = C.getAllocator().Allocate<ObjCInterfaceDecl>();
+  return new (Mem) ObjCInterfaceDecl(atLoc, numRefProtos, Id, ForwardDecl,
+                                     isInternal);
+}
 
+ObjCIvarDecl *ObjCIvarDecl::Create(ASTContext &C, SourceLocation L,
+                                   IdentifierInfo *Id, QualType T) {
+  void *Mem = C.getAllocator().Allocate<ObjCIvarDecl>();
+  return new (Mem) ObjCIvarDecl(L, Id, T);
 }
 
 

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

==============================================================================
--- cfe/trunk/lib/Sema/Sema.cpp (original)
+++ cfe/trunk/lib/Sema/Sema.cpp Sat Mar 15 20:15:50 2008
@@ -108,8 +108,9 @@
     Context.setObjCClassType(ClassTypedef);
     
     // Synthesize "@class Protocol;
-    ObjCInterfaceDecl *ProtocolDecl = new ObjCInterfaceDecl(SourceLocation(), 0, 
-                                        &Context.Idents.get("Protocol"), true);
+    ObjCInterfaceDecl *ProtocolDecl =
+      ObjCInterfaceDecl::Create(Context, SourceLocation(), 0, 
+                                &Context.Idents.get("Protocol"), true);
     Context.setObjCProtoType(Context.getObjCInterfaceType(ProtocolDecl));
     
     // Synthesize "typedef struct objc_object { Class isa; } *id;"

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

==============================================================================
--- cfe/trunk/lib/Sema/SemaDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDecl.cpp Sat Mar 15 20:15:50 2008
@@ -1340,7 +1340,7 @@
            // properties can appear within a protocol.
            // See corresponding FIXME in DeclObjC.h:ObjCPropertyDecl.
            isa<ObjCProtocolDecl>(static_cast<Decl *>(TagDecl)))
-    NewFD = new ObjCIvarDecl(Loc, II, T);
+    NewFD = ObjCIvarDecl::Create(Context, Loc, II, T);
   else
     assert(0 && "Sema::ActOnField(): Unknown TagDecl");
     

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

==============================================================================
--- cfe/trunk/lib/Sema/SemaDeclObjC.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclObjC.cpp Sat Mar 15 20:15:50 2008
@@ -98,7 +98,8 @@
     }
   }
   else {
-    IDecl = new ObjCInterfaceDecl(AtInterfaceLoc, NumProtocols, ClassName);
+    IDecl = ObjCInterfaceDecl::Create(Context, AtInterfaceLoc, NumProtocols,
+                                      ClassName);
   
     // Chain & install the interface decl into the identifier.
     IDecl->setNext(ClassName->getFETokenInfo<ScopedDecl>());
@@ -382,8 +383,8 @@
   if (!IDecl) {
     // Legacy case of @implementation with no corresponding @interface.
     // Build, chain & install the interface decl into the identifier.
-    IDecl = new ObjCInterfaceDecl(AtClassImplLoc, 0, ClassName, 
-                                  false, true);
+    IDecl = ObjCInterfaceDecl::Create(Context, AtClassImplLoc, 0, ClassName, 
+                                      false, true);
     IDecl->setNext(ClassName->getFETokenInfo<ScopedDecl>());
     ClassName->setFETokenInfo(IDecl);
     IDecl->setSuperClass(SDecl);
@@ -589,7 +590,8 @@
     }
     ObjCInterfaceDecl *IDecl = dyn_cast_or_null<ObjCInterfaceDecl>(PrevDecl); 
     if (!IDecl) {  // Not already seen?  Make a forward decl.
-      IDecl = new ObjCInterfaceDecl(AtClassLoc, 0, IdentList[i], true);
+      IDecl = ObjCInterfaceDecl::Create(Context, AtClassLoc, 0, IdentList[i],
+                                        true);
       // Chain & install the interface decl into the identifier.
       IDecl->setNext(IdentList[i]->getFETokenInfo<ScopedDecl>());
       IdentList[i]->setFETokenInfo(IDecl);





More information about the cfe-commits mailing list