Handle the case where 'element' in ObjCforCollectionstmt is not a DeclStmt or DeclRefExpr.

llvm-svn: 59290
This commit is contained in:
Ted Kremenek
2008-11-14 01:58:12 +00:00
parent 5cf87ff564
commit 99d4ff3c7a

View File

@@ -184,18 +184,21 @@ TransferFuncs::BlockStmt_VisitObjCForCollectionStmt(ObjCForCollectionStmt* S) {
// This represents a 'kill' for the variable.
Stmt* Element = S->getElement();
DeclRefExpr *DR = 0;
DeclRefExpr* DR = 0;
VarDecl* VD = 0;
if (DeclStmt* DS = dyn_cast<DeclStmt>(Element))
VD = cast<VarDecl>(DS->getSolitaryDecl());
else {
DR = cast<DeclRefExpr>(Element);
VD = cast<VarDecl>(DR->getDecl());
Expr* ElemExpr = cast<Expr>(Element)->IgnoreParens();
if ((DR = dyn_cast<DeclRefExpr>(ElemExpr)))
VD = cast<VarDecl>(DR->getDecl());
}
LiveState(VD, AD) = Dead;
if (AD.Observer && DR) { AD.Observer->ObserverKill(DR); }
if (VD) {
LiveState(VD, AD) = Dead;
if (AD.Observer && DR) { AD.Observer->ObserverKill(DR); }
}
}