aboutsummaryrefslogtreecommitdiff
path: root/lib/AST/DeclBase.cpp
diff options
context:
space:
mode:
authorSteve Naroff <snaroff@apple.com>2009-01-14 01:27:31 +0000
committerSteve Naroff <snaroff@apple.com>2009-01-14 01:27:31 +0000
commit4c92fea0c838e0df95f7aa53c0c592b659ea1b10 (patch)
tree14191173eefe3b239e38630d37b787321f34cdde /lib/AST/DeclBase.cpp
parent33a5d6136687359ad8d3d66872fb3e274e73a891 (diff)
Fix a subtle bug in DeclContext::DestroyDecls().
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@62205 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/AST/DeclBase.cpp')
-rw-r--r--lib/AST/DeclBase.cpp12
1 files changed, 8 insertions, 4 deletions
diff --git a/lib/AST/DeclBase.cpp b/lib/AST/DeclBase.cpp
index 7363bd0247..860a65a1e3 100644
--- a/lib/AST/DeclBase.cpp
+++ b/lib/AST/DeclBase.cpp
@@ -88,6 +88,7 @@ const char *Decl::getDeclKindName() const {
case CXXRecord: return "CXXRecord";
case Enum: return "Enum";
case Block: return "Block";
+ case Field: return "Field";
}
}
@@ -405,10 +406,13 @@ DeclContext::~DeclContext() {
}
void DeclContext::DestroyDecls(ASTContext &C) {
- for (decl_iterator D = decls_begin(); D != decls_end(); ++D) {
- // FIXME: assert that this condition holds.
- if ((*D)->getLexicalDeclContext() == this)
- (*D)->Destroy(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;
}
}