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 | 3b4e1d5cc62a2c29871cd2c7262143a3a5b30d04 (patch) | |
tree | 0638a1095a225efff37663246e5d0accaff1850f /clang/lib | |
parent | 38c9a14a889f05e17ab4269e8894ce540f3c1723 (diff) | |
download | bcm5719-llvm-3b4e1d5cc62a2c29871cd2c7262143a3a5b30d04.tar.gz bcm5719-llvm-3b4e1d5cc62a2c29871cd2c7262143a3a5b30d04.zip |
Accesses to a collection within a fast enumeration 'for' statement constitute a 'use'.
llvm-svn: 59075
Diffstat (limited to 'clang/lib')
-rw-r--r-- | clang/lib/Analysis/LiveVariables.cpp | 24 |
1 files changed, 15 insertions, 9 deletions
diff --git a/clang/lib/Analysis/LiveVariables.cpp b/clang/lib/Analysis/LiveVariables.cpp index 07fda99166c..83a0115429a 100644 --- a/clang/lib/Analysis/LiveVariables.cpp +++ b/clang/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); } } |