[cfe-commits] r59075 - /cfe/trunk/lib/Analysis/LiveVariables.cpp

Ted Kremenek kremenek at apple.com
Tue Nov 11 11:40:47 PST 2008


Author: kremenek
Date: Tue Nov 11 13:40:47 2008
New Revision: 59075

URL: http://llvm.org/viewvc/llvm-project?rev=59075&view=rev
Log:
Accesses to a collection within a fast enumeration 'for' statement constitute a 'use'.

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

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

==============================================================================
--- cfe/trunk/lib/Analysis/LiveVariables.cpp (original)
+++ cfe/trunk/lib/Analysis/LiveVariables.cpp Tue Nov 11 13:40:47 2008
@@ -176,18 +176,24 @@
   else VisitStmt(B);
 }
 
-void TransferFuncs::VisitObjCForCollectionStmt(ObjCForCollectionStmt* S) {
+void TransferFuncs::VisitObjCForCollectionStmt(ObjCForCollectionStmt* S) {  
+  // This represents a 'use' of the collection.
+  Visit(S->getCollection());
+  
+  // This represents a 'kill' for the variable.
   Stmt* Element = S->getElement();
+  DeclRefExpr *DR;
+  VarDecl* VD = 0;
   
-  if (DeclStmt* DS = dyn_cast<DeclStmt>(Element)) {
-    VisitDeclStmt(DS);
-    return;
+  if (DeclStmt* DS = dyn_cast<DeclStmt>(Element))
+    VD = cast<VarDecl>(DS->getSolitaryDecl());
+  else {
+    DR = cast<DeclRefExpr>(Element);
+    VD = cast<VarDecl>(DR->getDecl());
   }
-  
-  // This represents a 'kill' for the variable.
-  DeclRefExpr* DR = cast<DeclRefExpr>(Element);
-  LiveState(cast<VarDecl>(DR->getDecl()), AD) = Dead;
-  if (AD.Observer) { AD.Observer->ObserverKill(DR); }
+
+  LiveState(VD, AD) = Dead;
+  if (AD.Observer && DR) { AD.Observer->ObserverKill(DR); }
 }
 
   





More information about the cfe-commits mailing list