From: Ted Kremenek Date: Fri, 14 Nov 2008 01:58:12 +0000 (+0000) Subject: Handle the case where 'element' in ObjCforCollectionstmt is not a DeclStmt or DeclRef... X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=8f646002d8493ad7647d28b0acc7be425360f990;p=clang Handle the case where 'element' in ObjCforCollectionstmt is not a DeclStmt or DeclRefExpr. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@59290 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Analysis/LiveVariables.cpp b/lib/Analysis/LiveVariables.cpp index 98b1ee2820..7b04beb2b5 100644 --- a/lib/Analysis/LiveVariables.cpp +++ b/lib/Analysis/LiveVariables.cpp @@ -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(Element)) VD = cast(DS->getSolitaryDecl()); else { - DR = cast(Element); - VD = cast(DR->getDecl()); + Expr* ElemExpr = cast(Element)->IgnoreParens(); + if ((DR = dyn_cast(ElemExpr))) + VD = cast(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); } + } }