aboutsummaryrefslogtreecommitdiff
path: root/lib/AST/DeclBase.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2009-03-04 06:05:19 +0000
committerChris Lattner <sabre@nondot.org>2009-03-04 06:05:19 +0000
commitcc5814732edc0c382d0136ab57ec6149566043e2 (patch)
treef732f78e4d3f1f8e03cf08ebf2cd605ba4681b3a /lib/AST/DeclBase.cpp
parentcdf00290c8988b54073775c9442615a23df405fc (diff)
add an a Attr::Destroy method and force clients to go through it. As part of
this, make DeclBase::Destroy destroy attributes instead of the DeclBase dtor. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@66020 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/AST/DeclBase.cpp')
-rw-r--r--lib/AST/DeclBase.cpp23
1 files changed, 13 insertions, 10 deletions
diff --git a/lib/AST/DeclBase.cpp b/lib/AST/DeclBase.cpp
index ca67e28c71..3e968c7896 100644
--- a/lib/AST/DeclBase.cpp
+++ b/lib/AST/DeclBase.cpp
@@ -121,15 +121,7 @@ Decl::~Decl() {
if (isOutOfSemaDC())
delete getMultipleDC();
- if (!HasAttrs)
- return;
-
- DeclAttrMapTy::iterator it = DeclAttrs->find(this);
- assert(it != DeclAttrs->end() && "No attrs found but HasAttrs is true!");
-
- // release attributes.
- delete it->second;
- invalidateAttrs();
+ assert(!HasAttrs && "attributes should have been freed by Destroy");
}
void Decl::addAttr(Attr *NewAttr) {
@@ -189,7 +181,18 @@ void Decl::swapAttrs(Decl *RHS) {
}
-void Decl::Destroy(ASTContext& C) {
+void Decl::Destroy(ASTContext &C) {
+ // Free attributes for this decl.
+ if (HasAttrs) {
+ DeclAttrMapTy::iterator it = DeclAttrs->find(this);
+ assert(it != DeclAttrs->end() && "No attrs found but HasAttrs is true!");
+
+ // release attributes.
+ it->second->Destroy(C);
+ invalidateAttrs();
+ HasAttrs = false;
+ }
+
#if 0
// FIXME: Once ownership is fully understood, we can enable this code
if (DeclContext *DC = dyn_cast<DeclContext>(this))