diff options
Diffstat (limited to 'clang/lib/AST')
-rw-r--r-- | clang/lib/AST/DeclObjC.cpp | 47 |
1 files changed, 43 insertions, 4 deletions
diff --git a/clang/lib/AST/DeclObjC.cpp b/clang/lib/AST/DeclObjC.cpp index 6536df6e1e1..f3d81a1aa50 100644 --- a/clang/lib/AST/DeclObjC.cpp +++ b/clang/lib/AST/DeclObjC.cpp @@ -35,6 +35,21 @@ ObjCMethodDecl *ObjCMethodDecl::Create(ASTContext &C, isVariadic, isSynthesized, impControl); } +ObjCMethodDecl::~ObjCMethodDecl() { + delete [] ParamInfo; + //delete [] MethodAttrs; // FIXME: Also destroy the stored Expr*. +} + +void ObjCMethodDecl::Destroy(ASTContext& C) { + if (Body) Body->Destroy(C); + if (SelfDecl) SelfDecl->Destroy(C); + + for (param_iterator I=param_begin(), E=param_end(); I!=E; ++I) + if (*I) (*I)->Destroy(C); + + Decl::Destroy(C); +} + ObjCInterfaceDecl *ObjCInterfaceDecl::Create(ASTContext &C, SourceLocation atLoc, unsigned numRefProtos, @@ -47,6 +62,34 @@ ObjCInterfaceDecl *ObjCInterfaceDecl::Create(ASTContext &C, isInternal); } +ObjCInterfaceDecl::~ObjCInterfaceDecl() { + delete [] Ivars; + delete [] InstanceMethods; + delete [] ClassMethods; + delete [] PropertyDecl; + // FIXME: CategoryList? +} + +void ObjCInterfaceDecl::Destroy(ASTContext& C) { + for (ivar_iterator I=ivar_begin(), E=ivar_end(); I!=E; ++I) + if (*I) (*I)->Destroy(C); + + for (instmeth_iterator I=instmeth_begin(), E=instmeth_end(); I!=E; ++I) + if (*I) (*I)->Destroy(C); + + for (classmeth_iterator I=classmeth_begin(), E=classmeth_end(); I!=E; ++I) + if (*I) (*I)->Destroy(C); + + // FIXME: Cannot destroy properties right now because the properties of + // both the super class and this class are in this array. This can + // cause double-deletions. + //for (classprop_iterator I=classprop_begin(), E=classprop_end(); I!=E; ++I) +// if (*I) (*I)->Destroy(C); +// + Decl::Destroy(C); +} + + ObjCIvarDecl *ObjCIvarDecl::Create(ASTContext &C, SourceLocation L, IdentifierInfo *Id, QualType T) { void *Mem = C.getAllocator().Allocate<ObjCIvarDecl>(); @@ -135,10 +178,6 @@ void ObjCMethodDecl::setMethodParams(ParmVarDecl **NewParamInfo, } } -ObjCMethodDecl::~ObjCMethodDecl() { - delete[] ParamInfo; -} - /// FindPropertyDeclaration - Finds declaration of the property given its name /// in 'PropertyId' and returns it. It returns 0, if not found. /// |