summaryrefslogtreecommitdiffstats
path: root/clang/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
commit5de9b58bd25f8139e1885772e47ef21d89714d80 (patch)
tree61733d596ddefe85f978fc19c7fa01658961a3f2 /clang/lib/AST/DeclBase.cpp
parenta63b7f396ab8167ca12d9bd65e9adc48e3b0408d (diff)
downloadbcm5719-llvm-5de9b58bd25f8139e1885772e47ef21d89714d80.tar.gz
bcm5719-llvm-5de9b58bd25f8139e1885772e47ef21d89714d80.zip
Fix a subtle bug in DeclContext::DestroyDecls().
llvm-svn: 62205
Diffstat (limited to 'clang/lib/AST/DeclBase.cpp')
-rw-r--r--clang/lib/AST/DeclBase.cpp12
1 files changed, 8 insertions, 4 deletions
diff --git a/clang/lib/AST/DeclBase.cpp b/clang/lib/AST/DeclBase.cpp
index 7363bd02478..860a65a1e3e 100644
--- a/clang/lib/AST/DeclBase.cpp
+++ b/clang/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;
}
}
OpenPOWER on IntegriCloud