aboutsummaryrefslogtreecommitdiff
path: root/lib/AST/DeclObjC.cpp
diff options
context:
space:
mode:
authorTed Kremenek <kremenek@apple.com>2008-06-06 19:48:57 +0000
committerTed Kremenek <kremenek@apple.com>2008-06-06 19:48:57 +0000
commit1c8a413c1e00636c77666ddf1e3b0311f3fa8c81 (patch)
tree8371600bcea60959c72efe38331f58e74111dffb /lib/AST/DeclObjC.cpp
parente6f058fa6df30e7d68d1fbabcc363d21da41cd5f (diff)
Implement "Destroy" and destructor for ObjCProtocolDecl, allowing us to reclaim its memory and the memory of the Decls it owns.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@52055 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/AST/DeclObjC.cpp')
-rw-r--r--lib/AST/DeclObjC.cpp25
1 files changed, 25 insertions, 0 deletions
diff --git a/lib/AST/DeclObjC.cpp b/lib/AST/DeclObjC.cpp
index b3fc131330..a0d281808e 100644
--- a/lib/AST/DeclObjC.cpp
+++ b/lib/AST/DeclObjC.cpp
@@ -102,6 +102,31 @@ ObjCProtocolDecl *ObjCProtocolDecl::Create(ASTContext &C,
return new (Mem) ObjCProtocolDecl(L, numRefProtos, Id);
}
+ObjCProtocolDecl::~ObjCProtocolDecl() {
+ delete [] ReferencedProtocols;
+ delete [] InstanceMethods;
+ delete [] ClassMethods;
+ delete [] PropertyDecl;
+}
+
+void ObjCProtocolDecl::Destroy(ASTContext& C) {
+
+ // Referenced Protocols are not owned, so don't Destroy them.
+
+ 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: Because there is no clear ownership
+ // role between ObjCProtocolDecls and the ObjCPropertyDecls that they
+ // reference, we destroy ObjCPropertyDecls in ~TranslationUnit.
+
+ Decl::Destroy(C);
+}
+
+
ObjCClassDecl *ObjCClassDecl::Create(ASTContext &C,
SourceLocation L,
ObjCInterfaceDecl **Elts, unsigned nElts) {