summaryrefslogtreecommitdiffstats
path: root/clang/lib/AST
diff options
context:
space:
mode:
authorNuno Lopes <nunoplopes@sapo.pt>2008-06-01 22:53:53 +0000
committerNuno Lopes <nunoplopes@sapo.pt>2008-06-01 22:53:53 +0000
commit3fe4651e2ebc5f94dcefb0691c7bcd93ccd827d9 (patch)
tree6b7e4faaea7d260e4af1a38ed65a26a275d6bda0 /clang/lib/AST
parent38099c1b6ef26fb6651f2aaa700c3c1de6e1c2ee (diff)
downloadbcm5719-llvm-3fe4651e2ebc5f94dcefb0691c7bcd93ccd827d9.tar.gz
bcm5719-llvm-3fe4651e2ebc5f94dcefb0691c7bcd93ccd827d9.zip
fix decl attributes cleaning
this plugs the leak of attributes and also fixes a crash in the test llvm-svn: 51862
Diffstat (limited to 'clang/lib/AST')
-rw-r--r--clang/lib/AST/Decl.cpp24
1 files changed, 16 insertions, 8 deletions
diff --git a/clang/lib/AST/Decl.cpp b/clang/lib/AST/Decl.cpp
index 8d87d1cb4a2..8d9913b1aae 100644
--- a/clang/lib/AST/Decl.cpp
+++ b/clang/lib/AST/Decl.cpp
@@ -336,14 +336,9 @@ Decl::~Decl() {
DeclAttrMapTy::iterator it = DeclAttrs->find(this);
assert(it != DeclAttrs->end() && "No attrs found but HasAttrs is true!");
- // FIXME: Properly release attributes.
- // delete it->second;
- DeclAttrs->erase(it);
-
- if (DeclAttrs->empty()) {
- delete DeclAttrs;
- DeclAttrs = 0;
- }
+ // release attributes.
+ delete it->second;
+ invalidateAttrs();
}
void Decl::addAttr(Attr *NewAttr) {
@@ -358,6 +353,19 @@ void Decl::addAttr(Attr *NewAttr) {
HasAttrs = true;
}
+void Decl::invalidateAttrs() {
+ if (!HasAttrs) return;
+
+ HasAttrs = false;
+ (*DeclAttrs)[this] = 0;
+ DeclAttrs->erase(this);
+
+ if (DeclAttrs->empty()) {
+ delete DeclAttrs;
+ DeclAttrs = 0;
+ }
+}
+
const Attr *Decl::getAttrs() const {
if (!HasAttrs)
return 0;
OpenPOWER on IntegriCloud