From 103a1b45a9167ced1816101d9fb198848f05e2e4 Mon Sep 17 00:00:00 2001 From: Ted Kremenek Date: Mon, 29 Oct 2007 21:23:58 +0000 Subject: [PATCH] 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 --- AST/StmtIterator.cpp | 11 ++++++----- 1 file 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(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) -- 2.50.1