diff options
author | Ted Kremenek <kremenek@apple.com> | 2008-11-11 19:40:47 +0000 |
---|---|---|
committer | Ted Kremenek <kremenek@apple.com> | 2008-11-11 19:40:47 +0000 |
commit | e97d9db35c5a4589718ba76e6caa14cd6919f789 (patch) | |
tree | 260813f33fef15c589b52f902ecaf0765a6837a1 /lib/Analysis/LiveVariables.cpp | |
parent | 7fdee87c203f8e9b6feed63e85256a8f8bc2bbc0 (diff) |
Accesses to a collection within a fast enumeration 'for' statement constitute a 'use'.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@59075 91177308-0d34-0410-b5e6-96231b3b80d8
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); } } |