diff options
Diffstat (limited to 'lib/Analysis/LiveVariables.cpp')
-rw-r--r-- | lib/Analysis/LiveVariables.cpp | 24 |
1 files changed, 15 insertions, 9 deletions
diff --git a/lib/Analysis/LiveVariables.cpp b/lib/Analysis/LiveVariables.cpp index 07fda99166..83a0115429 100644 --- a/lib/Analysis/LiveVariables.cpp +++ b/lib/Analysis/LiveVariables.cpp @@ -176,18 +176,24 @@ void TransferFuncs::VisitBinaryOperator(BinaryOperator* B) { 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); } } |