[PATCH] D19451: [clang-tidy] New checker for redundant expressions.
Etienne Bergeron via cfe-commits
cfe-commits at lists.llvm.org
Fri Apr 22 19:21:15 PDT 2016
etienneb created this revision.
etienneb added a reviewer: alexfh.
etienneb added a subscriber: cfe-commits.
This checker finds redundant expression on both side of a binary operator.
The current implementation provide a function to check whether expression
are the equivalent. This implementation is able to recognize the frequent
subset encounter in C++ program. Side-effects like "x++" are not considered
to be equivalent.
There are many False Positives related to macros and to floating point
computations (detecting NaN). The checker is ignoring these cases.
Example:
```
if( !dst || dst->depth != desired_depth ||
dst->nChannels != desired_num_channels ||
dst_size.width != src_size.width ||
dst_size.height != dst_size.height ) <<--- bug
{
```
http://reviews.llvm.org/D19451
Files:
clang-tidy/misc/CMakeLists.txt
clang-tidy/misc/MiscTidyModule.cpp
clang-tidy/misc/RedundantExpressionCheck.cpp
clang-tidy/misc/RedundantExpressionCheck.h
docs/clang-tidy/checks/list.rst
docs/clang-tidy/checks/misc-redundant-expression.rst
test/clang-tidy/misc-redundant-expression.cpp
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D19451.54759.patch
Type: text/x-patch
Size: 13080 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20160423/5d77ae38/attachment-0001.bin>
More information about the cfe-commits
mailing list