summaryrefslogtreecommitdiffstats
path: root/clang/lib/AST
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
commit9a2d50e7fdcf5e76fd3205ee500114a17be642da (patch)
tree4099ee5f0a146bf01516cfd73034f5bf89411db5 /clang/lib/AST
parentf22fa28522283f3aa7d621ac1bf90c1ec8ed0ab7 (diff)
downloadbcm5719-llvm-9a2d50e7fdcf5e76fd3205ee500114a17be642da.tar.gz
bcm5719-llvm-9a2d50e7fdcf5e76fd3205ee500114a17be642da.zip
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. llvm-svn: 66020
Diffstat (limited to 'clang/lib/AST')
-rw-r--r--clang/lib/AST/DeclBase.cpp23
1 files changed, 13 insertions, 10 deletions
diff --git a/clang/lib/AST/DeclBase.cpp b/clang/lib/AST/DeclBase.cpp
index ca67e28c717..3e968c78962 100644
--- a/clang/lib/AST/DeclBase.cpp
+++ b/clang/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))
OpenPOWER on IntegriCloud