[cfe-commits] r59162 - /cfe/trunk/lib/Analysis/GRExprEngine.cpp

Ted Kremenek kremenek at apple.com
Wed Nov 12 13:12:48 PST 2008


Author: kremenek
Date: Wed Nov 12 15:12:46 2008
New Revision: 59162

URL: http://llvm.org/viewvc/llvm-project?rev=59162&view=rev
Log:
Shore up transfer function for ObjCForCollectionStmt.

Modified:
    cfe/trunk/lib/Analysis/GRExprEngine.cpp

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

==============================================================================
--- cfe/trunk/lib/Analysis/GRExprEngine.cpp (original)
+++ cfe/trunk/lib/Analysis/GRExprEngine.cpp Wed Nov 12 15:12:46 2008
@@ -1383,12 +1383,12 @@
   
   Stmt* elem = S->getElement();  
   VarDecl* ElemD;
-  bool bindDecl = false;
+  bool newDecl = false;
     
   if (DeclStmt* DS = dyn_cast<DeclStmt>(elem)) {
     ElemD = cast<VarDecl>(DS->getSolitaryDecl());
     assert (ElemD->getInit() == 0);
-    bindDecl = true;
+    newDecl = true;
   }
   else
     ElemD = cast<VarDecl>(cast<DeclRefExpr>(elem)->getDecl());
@@ -1408,18 +1408,26 @@
   unsigned Count = Builder->getCurrentBlockCount();
   loc::SymbolVal SymV(SymMgr.getConjuredSymbol(elem, ElemTy, Count));
   
-  if (bindDecl)
+  if (newDecl)
     hasElems = hasElems.BindDecl(ElemD, &SymV, Count);
   else
     hasElems = hasElems.BindLoc(hasElems.GetLValue(ElemD), SymV);
   
-  
   // Handle the case where the container has no elements.
-  
-    
-  
-  
-  
+  SVal FalseV = NonLoc::MakeVal(getBasicVals(), 0, IntTy);
+  GRStateRef noElems = state.BindExpr(S, FalseV);
+
+  if (!newDecl) {
+    // We only need to bind nil to an existing variable, since out of the
+    // loop the VarDecl won't exist and there will be no chance to get it's
+    // address via the '&' operator.
+    SVal nilV = loc::ConcreteInt(getBasicVals().getValue(0, ElemTy));
+    noElems.BindLoc(noElems.GetLValue(ElemD), nilV);
+  }
+
+  // Create the new nodes.
+  MakeNode(Dst, S, Pred, hasElems);
+  MakeNode(Dst, S, Pred, noElems);
 }
 
 //===----------------------------------------------------------------------===//





More information about the cfe-commits mailing list