add two more Create methods.

llvm-svn: 48428
This commit is contained in:
Chris Lattner 2008-03-16 20:53:07 +00:00
parent d77aff8232
commit 36ac1cae1f
3 changed files with 32 additions and 5 deletions

View File

@ -729,10 +729,14 @@ class ObjCCategoryImplDecl : public NamedDecl {
llvm::SmallVector<ObjCMethodDecl*, 32> ClassMethods;
SourceLocation EndLoc;
public:
ObjCCategoryImplDecl(SourceLocation L, IdentifierInfo *Id,
ObjCInterfaceDecl *classInterface)
: NamedDecl(ObjCCategoryImpl, L, Id), ClassInterface(classInterface) {}
public:
static ObjCCategoryImplDecl *Create(ASTContext &C, SourceLocation L,
IdentifierInfo *Id,
ObjCInterfaceDecl *classInterface);
ObjCInterfaceDecl *getClassInterface() const { return ClassInterface; }
@ -804,13 +808,19 @@ class ObjCImplementationDecl : public NamedDecl {
llvm::SmallVector<ObjCMethodDecl*, 32> ClassMethods;
SourceLocation EndLoc;
public:
ObjCImplementationDecl(SourceLocation L, IdentifierInfo *Id,
ObjCInterfaceDecl *classInterface,
ObjCInterfaceDecl *superDecl)
: NamedDecl(ObjCImplementation, L, Id),
ClassInterface(classInterface), SuperClass(superDecl),
Ivars(0), NumIvars(-1) {}
public:
static ObjCImplementationDecl *Create(ASTContext &C, SourceLocation L,
IdentifierInfo *Id,
ObjCInterfaceDecl *classInterface,
ObjCInterfaceDecl *superDecl);
void ObjCAddInstanceVariablesToClassImpl(ObjCIvarDecl **ivars,
unsigned numIvars);

View File

@ -73,6 +73,21 @@ ObjCCategoryDecl *ObjCCategoryDecl::Create(ASTContext &C, SourceLocation L,
return new (Mem) ObjCCategoryDecl(L, Id);
}
ObjCCategoryImplDecl *
ObjCCategoryImplDecl::Create(ASTContext &C, SourceLocation L,IdentifierInfo *Id,
ObjCInterfaceDecl *ClassInterface) {
void *Mem = C.getAllocator().Allocate<ObjCCategoryImplDecl>();
return new (Mem) ObjCCategoryImplDecl(L, Id, ClassInterface);
}
ObjCImplementationDecl *
ObjCImplementationDecl::Create(ASTContext &C, SourceLocation L,
IdentifierInfo *Id,
ObjCInterfaceDecl *ClassInterface,
ObjCInterfaceDecl *SuperDecl) {
void *Mem = C.getAllocator().Allocate<ObjCImplementationDecl>();
return new (Mem) ObjCImplementationDecl(L, Id, ClassInterface, SuperDecl);
}
//===----------------------------------------------------------------------===//
// Objective-C Decl Implementation

View File

@ -330,8 +330,8 @@ Sema::DeclTy *Sema::ActOnStartCategoryImplementation(
IdentifierInfo *ClassName, SourceLocation ClassLoc,
IdentifierInfo *CatName, SourceLocation CatLoc) {
ObjCInterfaceDecl *IDecl = getObjCInterfaceDecl(ClassName);
ObjCCategoryImplDecl *CDecl = new ObjCCategoryImplDecl(AtCatImplLoc,
CatName, IDecl);
ObjCCategoryImplDecl *CDecl =
ObjCCategoryImplDecl::Create(Context, AtCatImplLoc, CatName, IDecl);
/// Check that class of this category is already completely declared.
if (!IDecl || IDecl->isForwardDecl())
Diag(ClassLoc, diag::err_undef_interface, ClassName->getName());
@ -401,10 +401,12 @@ Sema::DeclTy *Sema::ActOnStartClassImplementation(
}
ObjCImplementationDecl* IMPDecl =
new ObjCImplementationDecl(AtClassImplLoc, ClassName, IDecl, SDecl);
ObjCImplementationDecl::Create(Context, AtClassImplLoc, ClassName,
IDecl, SDecl);
// Check that there is no duplicate implementation of this class.
if (ObjCImplementations[ClassName])
// FIXME: Don't leak everything!
Diag(ClassLoc, diag::err_dup_implementation_class, ClassName->getName());
else // add it to the list.
ObjCImplementations[ClassName] = IMPDecl;