diff options
author | Ted Kremenek <kremenek@apple.com> | 2008-10-15 05:23:41 +0000 |
---|---|---|
committer | Ted Kremenek <kremenek@apple.com> | 2008-10-15 05:23:41 +0000 |
commit | bb7818b666101e6471aaa857f78750f151afbb0c (patch) | |
tree | 36e52add13c86406458817f1c99f318b84c2e638 /clang/lib/Analysis/CheckDeadStores.cpp | |
parent | e388725aefff3f7dbbbd1245eeb2baf29c06f2ea (diff) | |
download | bcm5719-llvm-bb7818b666101e6471aaa857f78750f151afbb0c.tar.gz bcm5719-llvm-bb7818b666101e6471aaa857f78750f151afbb0c.zip |
Enhance dead store checker to not flag preincrements to dead variables where the preincrement is a subexpression, e.g. foo(++x); This can cause false negatives, but will remove a whole class of false positives.
llvm-svn: 57554
Diffstat (limited to 'clang/lib/Analysis/CheckDeadStores.cpp')
-rw-r--r-- | clang/lib/Analysis/CheckDeadStores.cpp | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/clang/lib/Analysis/CheckDeadStores.cpp b/clang/lib/Analysis/CheckDeadStores.cpp index d87bfb1964e..2afc7e0235f 100644 --- a/clang/lib/Analysis/CheckDeadStores.cpp +++ b/clang/lib/Analysis/CheckDeadStores.cpp @@ -149,6 +149,13 @@ public: else if (UnaryOperator* U = dyn_cast<UnaryOperator>(S)) { if (!U->isIncrementOp()) return; + + // Handle: ++x within a subexpression. The solution is not warn + // about preincrements to dead variables when the preincrement occurs + // as a subexpression. This can lead to false negatives, e.g. "(++x);" + // A generalized dead code checker should find such issues. + if (U->isPrefix() && Parents.isSubExpr(U)) + return; Expr *Ex = U->getSubExpr()->IgnoreParenCasts(); |