]> granicus.if.org Git - clang/commitdiff
Minor tweaks to liveness analysis:
authorTed Kremenek <kremenek@apple.com>
Fri, 14 Nov 2008 21:07:14 +0000 (21:07 +0000)
committerTed Kremenek <kremenek@apple.com>
Fri, 14 Nov 2008 21:07:14 +0000 (21:07 +0000)
- Block-expression for 'ObjCForCollectionStmt' is not alive before it occurs
- Recursively visit 'element' expression for ObjCForCollectionStmt to get liveness for referenced block-level expressions and variables.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@59316 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Analysis/LiveVariables.cpp

index 7b04beb2b5c66b8480a926fef95ac5b76e03cb84..4b181a954c0e9cee42587ca9ff1ee1905b9c4f83 100644 (file)
@@ -179,6 +179,9 @@ void TransferFuncs::VisitBinaryOperator(BinaryOperator* B) {
 void
 TransferFuncs::BlockStmt_VisitObjCForCollectionStmt(ObjCForCollectionStmt* S) {
   
+  // This is a block-level expression.  Its value is 'dead' before this point.
+  LiveState(S, AD) = Dead;
+
   // This represents a 'use' of the collection.
   Visit(S->getCollection());
   
@@ -193,6 +196,10 @@ TransferFuncs::BlockStmt_VisitObjCForCollectionStmt(ObjCForCollectionStmt* S) {
     Expr* ElemExpr = cast<Expr>(Element)->IgnoreParens();    
     if ((DR = dyn_cast<DeclRefExpr>(ElemExpr)))
       VD = cast<VarDecl>(DR->getDecl());
+    else {
+      Visit(ElemExpr);
+      return;
+    }
   }
 
   if (VD) {