Fixed potential NULL dereference when iterating over a chain of Decls.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@41848 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/Analysis/DeadStores.cpp b/Analysis/DeadStores.cpp
index a9a42a8..e547989 100644
--- a/Analysis/DeadStores.cpp
+++ b/Analysis/DeadStores.cpp
@@ -50,7 +50,7 @@
// Iterate through the decls. Warn if any of them (which have
// initializers) are not live.
for (VarDecl* V = cast<VarDecl>(DS->getDecl()); V != NULL ;
- V = cast<VarDecl>(V->getNextDeclarator()))
+ V = cast_or_null<VarDecl>(V->getNextDeclarator()))
if (Expr* E = V->getInit())
if (!L.isLive(Live,V)) {
SourceRange R = E->getSourceRange();