diff options
author | Douglas Gregor <dgregor@apple.com> | 2009-01-20 04:25:11 +0000 |
---|---|---|
committer | Douglas Gregor <dgregor@apple.com> | 2009-01-20 04:25:11 +0000 |
commit | 00447933f6654ed83434cc06c68acd33b375bb0f (patch) | |
tree | 3389c9955db8673450407cfb31abf1139658014f /clang/lib/AST/DeclBase.cpp | |
parent | d42b0a4dc97fd0b5bfb0552559a1eeff1c39f050 (diff) | |
download | bcm5719-llvm-00447933f6654ed83434cc06c68acd33b375bb0f.tar.gz bcm5719-llvm-00447933f6654ed83434cc06c68acd33b375bb0f.zip |
Remove the TopLevelDecls from TranslationUnit, since all of those decls are owned by the ASTContext's TranslationUnitDecl. There are definitely some leaking Decls now that I'll tackle tomorrow
llvm-svn: 62568
Diffstat (limited to 'clang/lib/AST/DeclBase.cpp')
-rw-r--r-- | clang/lib/AST/DeclBase.cpp | 25 |
1 files changed, 10 insertions, 15 deletions
diff --git a/clang/lib/AST/DeclBase.cpp b/clang/lib/AST/DeclBase.cpp index 70792c4efdf..5526be091f4 100644 --- a/clang/lib/AST/DeclBase.cpp +++ b/clang/lib/AST/DeclBase.cpp @@ -358,25 +358,26 @@ void Decl::swapAttrs(Decl *RHS) { void Decl::Destroy(ASTContext& C) { #if 0 - // FIXME: This causes double-destroys in some cases, so it is - // disabled at the moment. + // FIXME: Once ownership is fully understood, we can enable this code + if (DeclContext *DC = dyn_cast<DeclContext>(this)) + DC->decls_begin()->Destroy(C); - // Observe the unrolled recursion. By setting N->NextDeclarator = 0x0 + // Observe the unrolled recursion. By setting N->NextDeclInScope = 0x0 // within the loop, only the Destroy method for the first Decl // will deallocate all of the Decls in a chain. - Decl* N = SD->getNextDeclarator(); + Decl* N = NextDeclInScope; while (N) { - Decl* Tmp = N->getNextDeclarator(); - N->NextDeclarator = 0x0; + Decl* Tmp = N->NextDeclInScope; + N->NextDeclInScope = 0; N->Destroy(C); N = Tmp; } -#endif this->~Decl(); C.getAllocator().Deallocate((void *)this); +#endif } Decl *Decl::castFromDeclContext (const DeclContext *D) { @@ -427,14 +428,8 @@ DeclContext::~DeclContext() { } void DeclContext::DestroyDecls(ASTContext &C) { - for (decl_iterator D = decls_begin(); D != decls_end(); ) { - // FIXME: assert that this condition holds. - if ((*D)->getLexicalDeclContext() == this) - // Advance the cursor (via NextDeclInScope) *before* doing the Destroy. - (*D++)->Destroy(C); - else - ++D; - } + for (decl_iterator D = decls_begin(); D != decls_end(); ) + (*D++)->Destroy(C); } bool DeclContext::isTransparentContext() const { |