summaryrefslogtreecommitdiffstats
path: root/clang-tools-extra/clang-tidy/misc/RedundantExpressionCheck.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Fix a false positive in misc-redundant-expression checkAaron Ballman2019-10-301-7/+60
| | | | | | | | Do not warn for redundant conditional expressions when the true and false branches are expanded from different macros even when they are defined by one another. Patch by Daniel Krupp.
* clang-tidy - silence static analyzer getAs<> null dereference warnings. NFCI.Simon Pilgrim2019-10-171-1/+1
| | | | | | The static analyzer is warning about potential null dereferences, but in these cases we should be able to use castAs<> directly and if not assert will fire for us. llvm-svn: 375102
* Fixed a crash in misc-redundant-expression ClangTidy checkerDmitri Gribenko2019-06-121-10/+16
| | | | | | | | | | | | | | 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] Another attempt to fix misc-redundant-expression check.Haojian Wu2019-06-061-5/+6
| | | | | | Correct the fix of rL3627011, the isValueDependent guard was added in a wrong place in rL362701. llvm-svn: 362706
* [clang-tidy] Fix an assertion failure in misc-redundant-expression.Haojian Wu2019-06-061-1/+1
| | | | | | | | | | | | | | | | | 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
* Update the file headers across all of the LLVM projects in the monorepoChandler Carruth2019-01-191-4/+3
| | | | | | | | | | | | | | | | | to reflect the new license. We understand that people may be surprised that we're moving the header entirely to discuss the new license. We checked this carefully with the Foundation's lawyer and we believe this is the correct approach. Essentially, all code in the project is now made available by the LLVM project under our new license, so you will see that the license headers include that license only. Some of our contributors have contributed code under our old license, and accordingly, we have retained a copy of our old license notice in the top-level files in each project and repository. llvm-svn: 351636
* Port getLocEnd -> getEndLocStephen Kelly2018-08-091-2/+2
| | | | | | | | Subscribers: nemanjai, ioeric, kbarton, cfe-commits Differential Revision: https://reviews.llvm.org/D50355 llvm-svn: 339401
* Port getLocStart -> getBeginLocStephen Kelly2018-08-091-2/+2
| | | | | | | | | | Reviewers: javed.absar Subscribers: nemanjai, kbarton, ilya-biryukov, ioeric, jkorous, arphaman, jfb, cfe-commits Differential Revision: https://reviews.llvm.org/D50354 llvm-svn: 339400
* [clang-tidy] Widen anonymous namespace.Benjamin Kramer2018-02-021-2/+1
| | | | | | | The matchers in this check are prone to create ODR violations otherwise. No functionality change. llvm-svn: 324083
* [clang-tidy] Remove global constructor. No functionality change intended.Benjamin Kramer2018-02-021-4/+8
| | | | llvm-svn: 324080
* [clang-tidy] Don't reinvent the wheel, use existing log2 functions.Benjamin Kramer2018-02-021-8/+1
| | | | | | | This also makes the code ready for int128, even though I think it's currently impossible to get an int128 into this code path. llvm-svn: 324079
* [clang-tidy] misc-redundant-expression: fix a crash under ubsanAlexander Kornienko2018-02-011-3/+9
| | | | llvm-svn: 323980
* [clang-tidy] Misc redundant expression checker updated for ineffective ↵Gabor Horvath2017-12-201-2/+126
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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-17/+88
| | | | | | | | 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-74/+213
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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/+5
| | | | | | | | | | | | | | | | | | | | | | 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
* [Clang-tidy] Fix copy-paste error in misc-redundant-expression detected by ↵Eugene Zelenko2016-11-011-2/+15
| | | | | | | | | | PVS-Studio Also fix some Include What You Use and modernize-use-bool-literals warnings. Differential revision: https://reviews.llvm.org/D26176 llvm-svn: 285721
* [clang-tidy] Enhance redundant-expression checkEtienne Bergeron2016-07-071-0/+511
| | | | | | | | | | | | 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-13/+96
| | | | | | | | | | | | | | | | | | 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/+133
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