summaryrefslogtreecommitdiffstats
path: root/clang/Analysis/DeadStores.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'clang/Analysis/DeadStores.cpp')
-rw-r--r--clang/Analysis/DeadStores.cpp13
1 files changed, 13 insertions, 0 deletions
diff --git a/clang/Analysis/DeadStores.cpp b/clang/Analysis/DeadStores.cpp
index e7077ecae31..f79aa6ae047 100644
--- a/clang/Analysis/DeadStores.cpp
+++ b/clang/Analysis/DeadStores.cpp
@@ -47,6 +47,19 @@ public:
}
}
}
+ else if(DeclStmt* DS = dyn_cast<DeclStmt>(S)) {
+ // Iterate through the decls. Warn if any of them (which have
+ // initializers) are not live.
+ for (Decl* D = DS->getDecl() ; D != NULL ; D = D->getNextDeclarator())
+ if (VarDecl* V = dyn_cast<VarDecl>(D))
+ if (Expr* E = V->getInit())
+ if (!L.isLive(Live,D)) {
+ SourceRange R = E->getSourceRange();
+ PP.getDiagnostics().Report(D->getLocation(),
+ diag::warn_dead_store, 0, 0,
+ &R,1);
+ }
+ }
}
};
OpenPOWER on IntegriCloud