Add transfer function support for ObjCForCollectionStmt to LiveVariables.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@59053 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Analysis/LiveVariables.cpp b/lib/Analysis/LiveVariables.cpp
index e0b3f19..9b0f09e 100644
--- a/lib/Analysis/LiveVariables.cpp
+++ b/lib/Analysis/LiveVariables.cpp
@@ -121,8 +121,9 @@
void VisitBinaryOperator(BinaryOperator* B);
void VisitAssign(BinaryOperator* B);
void VisitDeclStmt(DeclStmt* DS);
+ void VisitObjCForCollectionStmt(ObjCForCollectionStmt* S);
void VisitUnaryOperator(UnaryOperator* U);
- void Visit(Stmt *S);
+ void Visit(Stmt *S);
void VisitTerminator(CFGBlock* B);
void SetTopValue(LiveVariables::ValTy& V) {
@@ -175,6 +176,21 @@
else VisitStmt(B);
}
+void TransferFuncs::VisitObjCForCollectionStmt(ObjCForCollectionStmt* S) {
+ Stmt* Element = S->getElement();
+
+ if (DeclStmt* DS = dyn_cast<DeclStmt>(Element)) {
+ VisitDeclStmt(DS);
+ return;
+ }
+
+ // 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); }
+}
+
+
void TransferFuncs::VisitUnaryOperator(UnaryOperator* U) {
Expr *E = U->getSubExpr();