summaryrefslogtreecommitdiffstats
path: root/clang/lib/Analysis
diff options
context:
space:
mode:
authorTed Kremenek <kremenek@apple.com>2008-04-14 17:52:13 +0000
committerTed Kremenek <kremenek@apple.com>2008-04-14 17:52:13 +0000
commit75ff623e2e119bfeeefb1a3f64fc28b76a5a1572 (patch)
treee8aa4b829dbcafeb468046da1cd0a03978b031f8 /clang/lib/Analysis
parentc22ede25c4db43b68ddee4efb473d527436fa806 (diff)
downloadbcm5719-llvm-75ff623e2e119bfeeefb1a3f64fc28b76a5a1572.tar.gz
bcm5719-llvm-75ff623e2e119bfeeefb1a3f64fc28b76a5a1572.zip
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. llvm-svn: 49662
Diffstat (limited to 'clang/lib/Analysis')
-rw-r--r--clang/lib/Analysis/DeadStores.cpp7
1 files changed, 5 insertions, 2 deletions
diff --git a/clang/lib/Analysis/DeadStores.cpp b/clang/lib/Analysis/DeadStores.cpp
index 2e57757f5c2..e64214e6948 100644
--- a/clang/lib/Analysis/DeadStores.cpp
+++ b/clang/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)) {
OpenPOWER on IntegriCloud