diff options
author | Ted Kremenek <kremenek@apple.com> | 2008-04-14 17:52:13 +0000 |
---|---|---|
committer | Ted Kremenek <kremenek@apple.com> | 2008-04-14 17:52:13 +0000 |
commit | c967c9d9011a9907e05a5c908ec0b7d2e7f3a11d (patch) | |
tree | 086be74c69339d6484529fc2846be92f47d57285 /lib | |
parent | 7ded73c1cbb34802f67cb7df96617529d3f78145 (diff) |
Bug fix in dead-store checker when walking the Decls in a DeclStmt: don't
assume that DeclStmts only have VarDecls; they can have TypedefDecls.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@49662 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r-- | lib/Analysis/DeadStores.cpp | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/lib/Analysis/DeadStores.cpp b/lib/Analysis/DeadStores.cpp index 2e57757f5c..e64214e694 100644 --- a/lib/Analysis/DeadStores.cpp +++ b/lib/Analysis/DeadStores.cpp @@ -54,8 +54,11 @@ public: else if(DeclStmt* DS = dyn_cast<DeclStmt>(S)) // Iterate through the decls. Warn if any initializers are complex // expressions that are not live (never used). - for (VarDecl* V = cast<VarDecl>(DS->getDecl()); V != NULL ; - V = cast_or_null<VarDecl>(V->getNextDeclarator())) { + for (ScopedDecl* SD = DS->getDecl(); SD; SD = SD->getNextDeclarator()) { + + VarDecl* V = dyn_cast<VarDecl>(SD); + if (!V) continue; + if (V->hasLocalStorage()) if (Expr* E = V->getInit()) { if (!Live(DS->getDecl(),AD)) { |