[cfe-commits] r48426 - in /cfe/trunk: include/clang/AST/DeclObjC.h lib/AST/DeclObjC.cpp lib/Sema/SemaDeclObjC.cpp
Chris Lattner
sabre at nondot.org
Sun Mar 16 13:34:23 PDT 2008
Author: lattner
Date: Sun Mar 16 15:34:23 2008
New Revision: 48426
URL: http://llvm.org/viewvc/llvm-project?rev=48426&view=rev
Log:
Add create methods for ObjCCategoryDecl, ObjCForwardProtocolDecl, ObjCClassDecl.
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=48426&r1=48425&r2=48426&view=diff
==============================================================================
--- cfe/trunk/include/clang/AST/DeclObjC.h (original)
+++ cfe/trunk/include/clang/AST/DeclObjC.h Sun Mar 16 15:34:23 2008
@@ -523,7 +523,7 @@
class ObjCClassDecl : public Decl {
ObjCInterfaceDecl **ForwardDecls;
unsigned NumForwardDecls;
-public:
+
ObjCClassDecl(SourceLocation L, ObjCInterfaceDecl **Elts, unsigned nElts)
: Decl(ObjCClass, L) {
if (nElts) {
@@ -534,6 +534,10 @@
}
NumForwardDecls = nElts;
}
+public:
+ static ObjCClassDecl *Create(ASTContext &C, SourceLocation L,
+ ObjCInterfaceDecl **Elts, unsigned nElts);
+
void setInterfaceDecl(unsigned idx, ObjCInterfaceDecl *OID) {
assert(idx < NumForwardDecls && "index out of range");
ForwardDecls[idx] = OID;
@@ -553,7 +557,7 @@
class ObjCForwardProtocolDecl : public Decl {
ObjCProtocolDecl **ReferencedProtocols;
unsigned NumReferencedProtocols;
-public:
+
ObjCForwardProtocolDecl(SourceLocation L,
ObjCProtocolDecl **Elts, unsigned nElts)
: Decl(ObjCForwardProtocol, L) {
@@ -565,6 +569,11 @@
ReferencedProtocols = 0;
}
}
+public:
+ static ObjCForwardProtocolDecl *Create(ASTContext &C, SourceLocation L,
+ ObjCProtocolDecl **Elts, unsigned Num);
+
+
void setForwardProtocolDecl(unsigned idx, ObjCProtocolDecl *OID) {
assert(idx < NumReferencedProtocols && "index out of range");
ReferencedProtocols[idx] = OID;
@@ -625,7 +634,7 @@
SourceLocation EndLoc; // marks the '>' or identifier.
SourceLocation AtEndLoc; // marks the end of the entire interface.
-public:
+
ObjCCategoryDecl(SourceLocation L, unsigned numRefProtocol,IdentifierInfo *Id)
: NamedDecl(ObjCCategory, L, Id),
ClassInterface(0), ReferencedProtocols(0), NumReferencedProtocols(0),
@@ -639,7 +648,12 @@
NumReferencedProtocols = numRefProtocol;
}
}
+public:
+
+ static ObjCCategoryDecl *Create(ASTContext &C, SourceLocation L,
+ unsigned numRefProtocol, IdentifierInfo *Id);
+
ObjCInterfaceDecl *getClassInterface() const { return ClassInterface; }
void setClassInterface(ObjCInterfaceDecl *IDecl) { ClassInterface = IDecl; }
Modified: cfe/trunk/lib/AST/DeclObjC.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/DeclObjC.cpp?rev=48426&r1=48425&r2=48426&view=diff
==============================================================================
--- cfe/trunk/lib/AST/DeclObjC.cpp (original)
+++ cfe/trunk/lib/AST/DeclObjC.cpp Sun Mar 16 15:34:23 2008
@@ -54,6 +54,26 @@
return new (Mem) ObjCProtocolDecl(L, numRefProtos, Id);
}
+ObjCClassDecl *ObjCClassDecl::Create(ASTContext &C, SourceLocation L,
+ ObjCInterfaceDecl **Elts, unsigned nElts) {
+ void *Mem = C.getAllocator().Allocate<ObjCClassDecl>();
+ return new (Mem) ObjCClassDecl(L, Elts, nElts);
+}
+
+ObjCForwardProtocolDecl *
+ObjCForwardProtocolDecl::Create(ASTContext &C, SourceLocation L,
+ ObjCProtocolDecl **Elts, unsigned NumElts) {
+ void *Mem = C.getAllocator().Allocate<ObjCForwardProtocolDecl>();
+ return new (Mem) ObjCForwardProtocolDecl(L, Elts, NumElts);
+}
+
+ObjCCategoryDecl *ObjCCategoryDecl::Create(ASTContext &C, SourceLocation L,
+ unsigned numRefProtocol,
+ IdentifierInfo *Id) {
+ void *Mem = C.getAllocator().Allocate<ObjCCategoryDecl>();
+ return new (Mem) ObjCCategoryDecl(L, numRefProtocol, Id);
+}
+
//===----------------------------------------------------------------------===//
// 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=48426&r1=48425&r2=48426&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaDeclObjC.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclObjC.cpp Sun Mar 16 15:34:23 2008
@@ -268,8 +268,8 @@
Protocols.push_back(PDecl);
}
- return new ObjCForwardProtocolDecl(AtProtocolLoc,
- &Protocols[0], Protocols.size());
+ return ObjCForwardProtocolDecl::Create(Context, AtProtocolLoc,
+ &Protocols[0], Protocols.size());
}
Sema::DeclTy *Sema::ActOnStartCategoryInterface(
@@ -280,8 +280,9 @@
SourceLocation EndProtoLoc) {
ObjCInterfaceDecl *IDecl = getObjCInterfaceDecl(ClassName);
- ObjCCategoryDecl *CDecl = new ObjCCategoryDecl(AtInterfaceLoc, NumProtoRefs,
- CategoryName);
+ ObjCCategoryDecl *CDecl =
+ ObjCCategoryDecl::Create(Context, AtInterfaceLoc, NumProtoRefs,
+ CategoryName);
CDecl->setClassInterface(IDecl);
/// Check that class of this category is already completely declared.
@@ -605,7 +606,8 @@
Interfaces.push_back(IDecl);
}
- return new ObjCClassDecl(AtClassLoc, &Interfaces[0], Interfaces.size());
+ return ObjCClassDecl::Create(Context, AtClassLoc,
+ &Interfaces[0], Interfaces.size());
}
More information about the cfe-commits
mailing list