aboutsummaryrefslogtreecommitdiff
path: root/lib/AST/TranslationUnit.cpp
diff options
context:
space:
mode:
authorTed Kremenek <kremenek@apple.com>2008-06-06 20:11:53 +0000
committerTed Kremenek <kremenek@apple.com>2008-06-06 20:11:53 +0000
commit400d95fb7bb9fac609f8613862b84f3a2a7d510f (patch)
treef496098847865f208b099e6369a615f13c97c636 /lib/AST/TranslationUnit.cpp
parent1c8a413c1e00636c77666ddf1e3b0311f3fa8c81 (diff)
Implement "Destroy" and destructor for ObjCClassDecl, 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@52059 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/AST/TranslationUnit.cpp')
-rw-r--r--lib/AST/TranslationUnit.cpp27
1 files changed, 21 insertions, 6 deletions
diff --git a/lib/AST/TranslationUnit.cpp b/lib/AST/TranslationUnit.cpp
index a683625789..5e644cf983 100644
--- a/lib/AST/TranslationUnit.cpp
+++ b/lib/AST/TranslationUnit.cpp
@@ -57,13 +57,28 @@ TranslationUnit::~TranslationUnit() {
// 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);
+ for (ObjCProtocolDecl::classprop_iterator ID=PDecl->classprop_begin(),
+ ED=PDecl->classprop_end(); ID!=ED; ++ID) {
+ if (!*ID || Killed.count(*ID)) continue;
+ Killed.insert(*ID);
+ (*ID)->Destroy(*Context);
}
-
+
+ // FIXME: There is no clear ownership policy now for ObjCInterfaceDecls
+ // referenced by ObjCClassDecls. Some of them can be forward decls that
+ // are never later defined (in which case the ObjCClassDecl owns them)
+ // or the ObjCInterfaceDecl later becomes a real definition later.
+ // Ideally we should have separate objects for forward declarations and
+ // definitions, obviating this problem. Because of this situation,
+ // referenced ObjCInterfaceDecls are destroyed here.
+ if (ObjCClassDecl* CDecl = dyn_cast<ObjCClassDecl>(*I))
+ for (ObjCClassDecl::iterator ID=CDecl->begin(),
+ ED=CDecl->end(); ID!=ED; ++ID) {
+ if (!*ID || Killed.count(*ID)) continue;
+ Killed.insert(*ID);
+ (*ID)->Destroy(*Context);
+ }
+
(*I)->Destroy(*Context);
}
}