[cfe-commits] r55487 - in /cfe/trunk: include/clang/Analysis/PathSensitive/GRExprEngine.h lib/Analysis/GRExprEngine.cpp

Ted Kremenek kremenek at apple.com
Thu Aug 28 11:34:26 PDT 2008


Author: kremenek
Date: Thu Aug 28 13:34:26 2008
New Revision: 55487

URL: http://llvm.org/viewvc/llvm-project?rev=55487&view=rev
Log:
Fixed analyzer caching bug in DeclStmt.

Modified:
    cfe/trunk/include/clang/Analysis/PathSensitive/GRExprEngine.h
    cfe/trunk/lib/Analysis/GRExprEngine.cpp

Modified: cfe/trunk/include/clang/Analysis/PathSensitive/GRExprEngine.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Analysis/PathSensitive/GRExprEngine.h?rev=55487&r1=55486&r2=55487&view=diff

==============================================================================
--- cfe/trunk/include/clang/Analysis/PathSensitive/GRExprEngine.h (original)
+++ cfe/trunk/include/clang/Analysis/PathSensitive/GRExprEngine.h Thu Aug 28 13:34:26 2008
@@ -494,9 +494,6 @@
   /// VisitDeclStmt - Transfer function logic for DeclStmts.
   void VisitDeclStmt(DeclStmt* DS, NodeTy* Pred, NodeSet& Dst); 
   
-  void VisitDeclStmtAux(DeclStmt* DS, ScopedDecl* D,
-                        NodeTy* Pred, NodeSet& Dst);
-  
   /// VisitGuardedExpr - Transfer function logic for ?, __builtin_choose
   void VisitGuardedExpr(Expr* Ex, Expr* L, Expr* R, NodeTy* Pred, NodeSet& Dst);
   

Modified: cfe/trunk/lib/Analysis/GRExprEngine.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Analysis/GRExprEngine.cpp?rev=55487&r1=55486&r2=55487&view=diff

==============================================================================
--- cfe/trunk/lib/Analysis/GRExprEngine.cpp (original)
+++ cfe/trunk/lib/Analysis/GRExprEngine.cpp Thu Aug 28 13:34:26 2008
@@ -1452,25 +1452,19 @@
 }
 
 void GRExprEngine::VisitDeclStmt(DeclStmt* DS, NodeTy* Pred, NodeSet& Dst) {  
-  VisitDeclStmtAux(DS, DS->getDecl(), Pred, Dst);
-}
-
-void GRExprEngine::VisitDeclStmtAux(DeclStmt* DS, ScopedDecl* D,
-                                    NodeTy* Pred, NodeSet& Dst) {
 
-  if (!D)
-    return;
+  // The CFG has one DeclStmt per Decl, so we don't need to walk the 
+  // Decl chain.
+  
+  ScopedDecl* D = DS->getDecl();
   
-  if (!isa<VarDecl>(D)) {
-    VisitDeclStmtAux(DS, D->getNextDeclarator(), Pred, Dst);
+  if (!D || !isa<VarDecl>(D))
     return;
-  }
   
   const VarDecl* VD = dyn_cast<VarDecl>(D);
   
   // FIXME: Add support for local arrays.
   if (VD->getType()->isArrayType()) {
-    VisitDeclStmtAux(DS, D->getNextDeclarator(), Pred, Dst);
     return;
   }
   
@@ -1480,21 +1474,16 @@
   //  time a function is called those values may not be current.
   NodeSet Tmp;
 
-  if (Ex) Visit(Ex, Pred, Tmp);
-  if (Tmp.empty()) Tmp.Add(Pred);
+  if (Ex)
+    Visit(Ex, Pred, Tmp);
+
+  if (Tmp.empty())
+    Tmp.Add(Pred);
   
   for (NodeSet::iterator I=Tmp.begin(), E=Tmp.end(); I!=E; ++I) {
     const GRState* St = GetState(*I);
     St = StateMgr.AddDecl(St, VD, Ex, Builder->getCurrentBlockCount());
-    
-    // Create a new node.  We don't really need to create a new NodeSet
-    // here, but it simplifies things and doesn't cost much.
-    NodeSet Tmp2;    
-    MakeNode(Tmp2, DS, *I, St);
-    if (Tmp2.empty()) Tmp2.Add(*I);
-    
-    for (NodeSet::iterator I2=Tmp2.begin(), E2=Tmp2.end(); I2!=E2; ++I2)
-      VisitDeclStmtAux(DS, D->getNextDeclarator(), *I2, Dst);
+    MakeNode(Dst, DS, *I, St);
   }
 }
 





More information about the cfe-commits mailing list