[cfe-commits] r48428 - 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:53:07 PDT 2008
Author: lattner
Date: Sun Mar 16 15:53:07 2008
New Revision: 48428
URL: http://llvm.org/viewvc/llvm-project?rev=48428&view=rev
Log:
add two more Create methods.
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=48428&r1=48427&r2=48428&view=diff
==============================================================================
--- cfe/trunk/include/clang/AST/DeclObjC.h (original)
+++ cfe/trunk/include/clang/AST/DeclObjC.h Sun Mar 16 15:53:07 2008
@@ -729,10 +729,14 @@
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 @@
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);
Modified: cfe/trunk/lib/AST/DeclObjC.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/DeclObjC.cpp?rev=48428&r1=48427&r2=48428&view=diff
==============================================================================
--- cfe/trunk/lib/AST/DeclObjC.cpp (original)
+++ cfe/trunk/lib/AST/DeclObjC.cpp Sun Mar 16 15:53:07 2008
@@ -73,6 +73,21 @@
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
Modified: cfe/trunk/lib/Sema/SemaDeclObjC.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclObjC.cpp?rev=48428&r1=48427&r2=48428&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaDeclObjC.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclObjC.cpp Sun Mar 16 15:53:07 2008
@@ -330,8 +330,8 @@
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 @@
}
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;
More information about the cfe-commits
mailing list