summaryrefslogtreecommitdiffstats
path: root/clang/lib/Analysis/CheckDeadStores.cpp
diff options
context:
space:
mode:
authorTed Kremenek <kremenek@apple.com>2008-07-23 22:19:56 +0000
committerTed Kremenek <kremenek@apple.com>2008-07-23 22:19:56 +0000
commit9572cae92b224e34a790f99ef8431939e36c493c (patch)
treef8bd224b16c5a757a5b8882c07d4052669599128 /clang/lib/Analysis/CheckDeadStores.cpp
parent1692342e58012fe7b1600273fb85035f8169518a (diff)
downloadbcm5719-llvm-9572cae92b224e34a790f99ef8431939e36c493c.tar.gz
bcm5719-llvm-9572cae92b224e34a790f99ef8431939e36c493c.zip
Don't flag dead stores when the result of a preincrement/predecrement is used in an enclosing expression.
llvm-svn: 53964
Diffstat (limited to 'clang/lib/Analysis/CheckDeadStores.cpp')
-rw-r--r--clang/lib/Analysis/CheckDeadStores.cpp7
1 files changed, 6 insertions, 1 deletions
diff --git a/clang/lib/Analysis/CheckDeadStores.cpp b/clang/lib/Analysis/CheckDeadStores.cpp
index 005c71a5806..433e61154f9 100644
--- a/clang/lib/Analysis/CheckDeadStores.cpp
+++ b/clang/lib/Analysis/CheckDeadStores.cpp
@@ -153,6 +153,11 @@ public:
if (!U->isIncrementOp())
return;
+ // Don't flag dead stores when the result of a preincrement/predecrement
+ // is used in an enclosing expression.
+ if (U->isPrefix() && Parents.isSubExpr(U))
+ return;
+
Expr *Ex = U->getSubExpr()->IgnoreParenCasts();
if (DeclRefExpr* DR = dyn_cast<DeclRefExpr>(Ex))
@@ -161,7 +166,7 @@ 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 (ScopedDecl* SD = DS->getDecl(); SD; SD = SD->getNextDeclarator()) {
+ for (ScopedDecl* SD = DS->getDecl(); SD; SD = SD->getNextDeclarator()) {
VarDecl* V = dyn_cast<VarDecl>(SD);
if (!V) continue;
OpenPOWER on IntegriCloud