[cfe-commits] r49710 - /cfe/trunk/include/clang/Analysis/Visitors/CFGStmtVisitor.h

Ted Kremenek kremenek at apple.com
Mon Apr 14 22:11:28 PDT 2008


Author: kremenek
Date: Tue Apr 15 00:11:28 2008
New Revision: 49710

URL: http://llvm.org/viewvc/llvm-project?rev=49710&view=rev
Log:
Bug fix in VisitChildren: Only visit the last statement in a StmtExpr and the RHS of a comma expression, as the other Stmts will be visited elsewhere in a CFGBlock.

Modified:
    cfe/trunk/include/clang/Analysis/Visitors/CFGStmtVisitor.h

Modified: cfe/trunk/include/clang/Analysis/Visitors/CFGStmtVisitor.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Analysis/Visitors/CFGStmtVisitor.h?rev=49710&r1=49709&r2=49710&view=diff

==============================================================================
--- cfe/trunk/include/clang/Analysis/Visitors/CFGStmtVisitor.h (original)
+++ cfe/trunk/include/clang/Analysis/Visitors/CFGStmtVisitor.h Tue Apr 15 00:11:28 2008
@@ -118,6 +118,26 @@
     
   /// VisitChildren: Call "Visit" on each child of S.
   void VisitChildren(Stmt* S) {
+    
+    switch (S->getStmtClass()) {
+      default:
+        break;
+        
+      case Stmt::StmtExprClass: {
+        CompoundStmt* CS = cast<StmtExpr>(S)->getSubStmt();
+        if (CS->body_empty()) return;
+        static_cast<ImplClass*>(this)->Visit(CS->body_back());
+        return;
+      }
+        
+      case Stmt::BinaryOperatorClass: {
+        BinaryOperator* B = cast<BinaryOperator>(S);
+        if (B->getOpcode() != BinaryOperator::Comma) break;
+        static_cast<ImplClass*>(this)->Visit(B->getRHS());
+        return;
+      }
+    }
+        
     for (Stmt::child_iterator I=S->child_begin(), E=S->child_end(); I != E;++I)
       if (*I) static_cast<ImplClass*>(this)->Visit(*I);    
   }





More information about the cfe-commits mailing list