diff options
author | Ted Kremenek <kremenek@apple.com> | 2008-06-06 19:48:57 +0000 |
---|---|---|
committer | Ted Kremenek <kremenek@apple.com> | 2008-06-06 19:48:57 +0000 |
commit | 1c8a413c1e00636c77666ddf1e3b0311f3fa8c81 (patch) | |
tree | 8371600bcea60959c72efe38331f58e74111dffb /lib/AST/TranslationUnit.cpp | |
parent | e6f058fa6df30e7d68d1fbabcc363d21da41cd5f (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/TranslationUnit.cpp')
-rw-r--r-- | lib/AST/TranslationUnit.cpp | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/lib/AST/TranslationUnit.cpp b/lib/AST/TranslationUnit.cpp index e78502f267..a683625789 100644 --- a/lib/AST/TranslationUnit.cpp +++ b/lib/AST/TranslationUnit.cpp @@ -46,11 +46,24 @@ TranslationUnit::~TranslationUnit() { if (ObjCInterfaceDecl* IDecl = dyn_cast<ObjCInterfaceDecl>(*I)) for (ObjCInterfaceDecl::classprop_iterator ID=IDecl->classprop_begin(), ED=IDecl->classprop_end(); ID!=ED; ++ID) { - if (Killed.count(*ID)) continue; + if (!*ID || Killed.count(*ID)) continue; Killed.insert(*ID); (*ID)->Destroy(*Context); } + // FIXME: This is a horrible hack. Because there is no clear ownership + // role between ObjCProtocolDecls and the ObjCPropertyDecls that they + // reference, we need to destroy ObjCPropertyDecls here. This will + // eventually be fixed when the ownership of ObjCPropertyDecls gets + // cleaned up. + if (ObjCProtocolDecl* PDecl = dyn_cast<ObjCProtocolDecl>(*I)) + for (ObjCInterfaceDecl::classprop_iterator PD=PDecl->classprop_begin(), + ED=PDecl->classprop_end(); PD!=ED; ++PD) { + if (!*PD || Killed.count(*PD)) continue; + Killed.insert(*PD); + (*PD)->Destroy(*Context); + } + (*I)->Destroy(*Context); } } |