[cfe-commits] r43473 - /cfe/trunk/AST/StmtIterator.cpp

Ted Kremenek kremenek at apple.com
Mon Oct 29 14:23:59 PDT 2007


Author: kremenek
Date: Mon Oct 29 16:23:58 2007
New Revision: 43473

URL: http://llvm.org/viewvc/llvm-project?rev=43473&view=rev
Log:
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.

Modified:
    cfe/trunk/AST/StmtIterator.cpp

Modified: cfe/trunk/AST/StmtIterator.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/AST/StmtIterator.cpp?rev=43473&r1=43472&r2=43473&view=diff

==============================================================================
--- cfe/trunk/AST/StmtIterator.cpp (original)
+++ cfe/trunk/AST/StmtIterator.cpp Mon Oct 29 16:23:58 2007
@@ -31,6 +31,7 @@
 
 void StmtIteratorBase::NextVA() {
   assert (getVAPtr());
+  assert (decl);
 
   VariableArrayType* p = getVAPtr();
   p = FindVA(p->getElementType().getTypePtr());
@@ -59,11 +60,6 @@
   }    
   
   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 @@
       if (ECD->getInitExpr())
         return;  
   }
+  
+  if (!decl) {
+    RawVAPtr = 0;
+    return;
+  }
 }
 
 StmtIteratorBase::StmtIteratorBase(ScopedDecl* d)





More information about the cfe-commits mailing list