aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2008-03-16 20:53:07 +0000
committerChris Lattner <sabre@nondot.org>2008-03-16 20:53:07 +0000
commit75c9cae5f85c72cbb1649e93849e16ede3f07522 (patch)
treeb2df5fb8ba5877b81749e8d36c4fc2e1564c8667
parent68c82cf61228102aba1194efef222fa1478af2a8 (diff)
add two more Create methods.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@48428 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--include/clang/AST/DeclObjC.h14
-rw-r--r--lib/AST/DeclObjC.cpp15
-rw-r--r--lib/Sema/SemaDeclObjC.cpp8
3 files changed, 32 insertions, 5 deletions
diff --git a/include/clang/AST/DeclObjC.h b/include/clang/AST/DeclObjC.h
index 35bc0146d0..048661cdf8 100644
--- a/include/clang/AST/DeclObjC.h
+++ b/include/clang/AST/DeclObjC.h
@@ -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);
diff --git a/lib/AST/DeclObjC.cpp b/lib/AST/DeclObjC.cpp
index cd4c6fff9f..4f1671ef07 100644
--- a/lib/AST/DeclObjC.cpp
+++ b/lib/AST/DeclObjC.cpp
@@ -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
diff --git a/lib/Sema/SemaDeclObjC.cpp b/lib/Sema/SemaDeclObjC.cpp
index e07d3c59e6..f9da77ff2c 100644
--- a/lib/Sema/SemaDeclObjC.cpp
+++ b/lib/Sema/SemaDeclObjC.cpp
@@ -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;