diff options
author | Ted Kremenek <kremenek@apple.com> | 2007-10-29 21:23:58 +0000 |
---|---|---|
committer | Ted Kremenek <kremenek@apple.com> | 2007-10-29 21:23:58 +0000 |
commit | 103a1b45a9167ced1816101d9fb198848f05e2e4 (patch) | |
tree | 9e3660dd0ef4aaf707985524d474ea833a7c8a90 | |
parent | 86522b9e84d0c39f09b54e888538ad64e89788c4 (diff) |
Fixed deadcode bug where check for NULL decl occured within a block
where the decl would always be non-NULL. Moved the check to after the
block to properly tidy up the iterator's state.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@43473 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | AST/StmtIterator.cpp | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/AST/StmtIterator.cpp b/AST/StmtIterator.cpp index 9db5f6134f..89d17bd340 100644 --- a/AST/StmtIterator.cpp +++ b/AST/StmtIterator.cpp @@ -31,6 +31,7 @@ static inline VariableArrayType* FindVA(Type* t) { void StmtIteratorBase::NextVA() { assert (getVAPtr()); + assert (decl); VariableArrayType* p = getVAPtr(); p = FindVA(p->getElementType().getTypePtr()); @@ -59,11 +60,6 @@ void StmtIteratorBase::NextDecl(bool ImmediateAdvance) { } for ( ; decl ; decl = decl->getNextDeclarator()) { - if (!decl) { - RawVAPtr = 0; - return; - } - if (VarDecl* VD = dyn_cast<VarDecl>(decl)) { if (VariableArrayType* VAPtr = FindVA(VD->getType().getTypePtr())) { setVAPtr(VAPtr); @@ -77,6 +73,11 @@ void StmtIteratorBase::NextDecl(bool ImmediateAdvance) { if (ECD->getInitExpr()) return; } + + if (!decl) { + RawVAPtr = 0; + return; + } } StmtIteratorBase::StmtIteratorBase(ScopedDecl* d) |