summaryrefslogtreecommitdiffstats
path: root/clang-tools-extra/test/clang-tidy/misc-redundant-expression.cpp
Commit message (Collapse)AuthorAgeFilesLines
* [ClangTidy] Separate tests for infrastructure and checkersDmitri Gribenko2019-10-111-753/+0
| | | | | | | | | | | | | | | | | | | | Summary: This change moves tests for checkers and infrastructure into separate directories, making it easier to find infrastructure tests. Tests for checkers are already easy to find because they are named after the checker. Tests for infrastructure were difficult to find because they were outnumbered by tests for checkers. Now they are in a separate directory. Reviewers: jfb, jdoerfert, lebedev.ri Subscribers: srhines, nemanjai, aheejin, kbarton, christof, mgrang, arphaman, jfb, lebedev.ri, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D68807 llvm-svn: 374540
* Attempt to fix a few clang-tidy tests on Windows, see PR43593.Nico Weber2019-10-071-1/+1
| | | | llvm-svn: 373951
* Fixed a crash in misc-redundant-expression ClangTidy checkerDmitri Gribenko2019-06-121-1/+15
| | | | | | | | | | | | | | Summary: It was trying to pass a dependent expression into constant evaluator. Reviewers: ilya-biryukov Subscribers: cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D63188 llvm-svn: 363133
* [clang-tidy] Fix an assertion failure in misc-redundant-expression.Haojian Wu2019-06-061-0/+12
| | | | | | | | | | | | | | | | | Summary: The assertion "isIntegerConstantExpr" is triggered in the isIntegerConstantExpr(), we should not call it if the expression is value dependent. Reviewers: gribozavr Subscribers: xazax.hun, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D62947 llvm-svn: 362701
* Run ClangTidy tests in all C++ language modesDmitri Gribenko2019-05-201-1/+1
| | | | | | | | | | | | | | | | | | | | | | | Summary: I inspected every test and did one of the following: - changed the test to run in all language modes, - added a comment explaining why the test is only applicable in a certain mode, - limited the test to language modes where it passes and added a FIXME to fix the checker or the test. Reviewers: alexfh, lebedev.ri Subscribers: nemanjai, kbarton, arphaman, jdoerfert, lebedev.ri, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D62125 llvm-svn: 361131
* [clang-tidy] misc-redundant-expression: fix a crash under ubsanAlexander Kornienko2018-02-011-2/+7
| | | | llvm-svn: 323980
* [clang-tidy] Misc redundant expression checker updated for ineffective ↵Gabor Horvath2017-12-201-0/+58
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | bitwise operator expressions Examples: * Always evaluates to 0: ``` int X; if (0 & X) return; ``` * Always evaluates to ~0: ``` int Y; if (Y | ~0) return; ``` * The symbol is unmodified: ``` int Z; Z &= ~0; ``` Patch by: Lilla Barancsuk! Differential Revision: https://reviews.llvm.org/D39285 llvm-svn: 321168
* [clang-tidy] Misc redundant expressions check updated for overloaded operatorsGabor Horvath2017-11-271-5/+80
| | | | | | | | Patch by: Lilla Barancsuk Differential Revision: https://reviews.llvm.org/D39243 llvm-svn: 319033
* [clang-tidy] Misc redundant expressions checker updated for macrosGabor Horvath2017-11-071-54/+154
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | Redundant Expression Checker is updated to be able to detect expressions that contain macros. Also, other small details are modified to improve the current implementation. The improvements in detail are as follows: * Binary and ternary operator expressions containing two constants, with at least one of them from a macro, are detected and tested for redundancy. Macro expressions are treated somewhat differently from other expressions, because the particular values of macros can vary across builds. They can be considered correct and intentional, even if macro values equal, produce ranges that exclude each other or fully overlap, etc. * The code structure is slightly modified: typos are corrected, comments are added and some functions are renamed to improve comprehensibility, both in the checker and the test file. A few test cases are moved to another function. * The checker is now able to detect redundant CXXFunctionalCastExprs as well. A corresponding test case is added. Patch by: Lilla Barancsuk! Differential Revision: https://reviews.llvm.org/D38688 llvm-svn: 317570
* [clang-tidy] Catch trivially true statements like a != 1 || a != 3Alexander Kornienko2017-03-231-0/+4
| | | | | | | | | | | | | | | | | | | | | | Catch trivially true statements of the form a != 1 || a != 3. Statements like these are likely errors. They are particularly easy to miss when handling enums: enum State { RUNNING, STOPPED, STARTING, ENDING } ... if (state != RUNNING || state != STARTING) ... Patch by Blaise Watson! Differential revision: https://reviews.llvm.org/D29858 llvm-svn: 298607
* Remove trailing whitespace in docs and clang-tidy sources.Alexander Kornienko2016-12-131-13/+13
| | | | llvm-svn: 289547
* [clang-tidy] Enhance redundant-expression checkEtienne Bergeron2016-07-071-3/+326
| | | | | | | | | | | | Summary: This patch is adding support to recognize more complex redundant expressions. Reviewers: alexfh Subscribers: aaron.ballman, cfe-commits, chrisha Differential Revision: http://reviews.llvm.org/D21392 llvm-svn: 274731
* [clang-tidy] Improve misc-redundant-expression and decrease false-positiveEtienne Bergeron2016-05-121-4/+46
| | | | | | | | | | | | | | | | | | Summary: This patch is adding support for conditional expression and overloaded operators. To decrease false-positive, this patch is adding a list of banned macro names that has multiple variant with same integer value. Also fixed support for template instantiation and added an unittest. Reviewers: alexfh Subscribers: klimek, Sarcasm, cfe-commits Differential Revision: http://reviews.llvm.org/D19703 llvm-svn: 269275
* [clang-tidy] New checker for redundant expressions.Etienne Bergeron2016-04-261-0/+120
Summary: This checker finds redundant expression on both side of a binary operator. The current implementation provide a function to check whether expressions are equivalent. This implementation is able to recognize the common 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 { ``` Reviewers: alexfh Subscribers: danielmarjamaki, fahlgren, jordan_rose, zaks.anna, Eugene.Zelenko, cfe-commits Differential Revision: http://reviews.llvm.org/D19451 llvm-svn: 267574
OpenPOWER on IntegriCloud