summaryrefslogtreecommitdiffstats
path: root/clang-tools-extra/clang-tidy/readability/SimplifyBooleanExprCheck.cpp
Commit message (Collapse)AuthorAgeFilesLines
* [clang-tidy] Handle member variables in readability-simplify-boolean-exprJonas Toth2019-05-161-18/+17
| | | | | | | | | | | | | | | | | - Add readability-simplify-boolean-expr test cases for member variables Fixes PR40179 Patch by LegalizeAdulthood. Reviewers: alexfh, hokein, aaron.ballman, JonasToth Reviewed By: JonasToth Subscribers: jdoerfert, xazax.hun, cfe-commits Differential Revision: https://reviews.llvm.org/D56323 llvm-svn: 360882
* Fix file headers. NFCFangrui Song2019-03-011-1/+1
| | | | llvm-svn: 355188
* 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
* Fix warning about unused variable [NFC]Bjorn Pettersson2018-12-211-1/+1
| | | | llvm-svn: 349891
* [clang-tidy] Use translationUnitDecl() instead of a custom matcher.Alexander Kornienko2018-12-201-17/+5
| | | | llvm-svn: 349758
* A bit of AST matcher cleanup, NFC.Alexander Kornienko2018-11-251-5/+5
| | | | | | | | | Removed the uses of the allOf() matcher inside node matchers that are implicit allOf(). Replaced uses of allOf() with the explicit node matcher where it makes matchers more readable. Replace anyOf(hasName(), hasName(), ...) with the more efficient and readable hasAnyName(). llvm-svn: 347520
* [clang-tidy] Update checks to play nicely with limited traversal scope added ↵Sam McCall2018-11-151-3/+13
| | | | | | | | | | | | | | in r346847 Summary: (See D54204 for original review) Reviewers: hokein Subscribers: xazax.hun, cfe-commits Differential Revision: https://reviews.llvm.org/D54579 llvm-svn: 346961
* 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-11/+11
| | | | | | | | | | 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] SimplifyBoolenExpr doesn't add parens if unary negotiation is ↵Zinovy Nis2018-05-221-0/+3
| | | | | | | | | | | | | | | | | | | | | | | | of ExprWithCleanups type bool foo(A &S) { if (S != (A)S) return false; return true; } is fixed into (w/o this patch) ... return !S != (A)S; // negotiation affects first operand only } instead of (with this patch) ... return S == (A)S; // note == instead of != } Differential Revision: https://reviews.llvm.org/D47122 llvm-svn: 333003
* [clang-tidy] make readability-simplify-bool-expr completely ignore macrosAlexander Kornienko2017-11-291-4/+1
| | | | llvm-svn: 319325
* [clang-tidy] Partly rewrite readability-simplify-boolean-expr using RAVAlexander Kornienko2017-05-151-105/+98
| | | | | | | | | | The check was using AST matchers in a very inefficient manner. By rewriting the BinaryOperator-related parts using RAV, the check was sped up by a factor of up to 10000 on some files (mostly, generated code using binary operators in tables), but also significantly sped up for regular large files. As a side effect, the code became clearer and more readable. llvm-svn: 303081
* [clang-tidy] Cleaning up language options.Gabor Horvath2016-09-241-3/+3
| | | | | | Differential Revision: https://reviews.llvm.org/D24881 llvm-svn: 282319
* [ASTMatchers] Added ignoringParenImpCasts to has matchersPiotr Padlewski2016-05-311-1/+2
| | | | | | | | | has matcher changed behaviour, and now it matches "as is" and doesn't skip implicit and paren casts http://reviews.llvm.org/D20801 llvm-svn: 271289
* Reapply r260096.Aaron Ballman2016-02-121-93/+138
| | | | | | | | | | | | Expand the simplify boolean expression check to handle implicit conversion of integral types to bool and improve the handling of implicit conversion of member pointers to bool. Implicit conversion of member pointers are replaced with explicit comparisons to nullptr. Implicit conversions of integral types are replaced with explicit comparisons to 0. Patch by Richard Thomson. llvm-svn: 260681
* Reverting r260096; it causes build bot failures:Aaron Ballman2016-02-081-136/+93
| | | | | | | http://bb.pgr.jp/builders/cmake-clang-tools-x86_64-linux/builds/23351 http://lab.llvm.org:8011/builders/clang-s390x-linux/builds/492 llvm-svn: 260097
* Expand the simplify boolean expression check to handle implicit conversion ↵Aaron Ballman2016-02-081-93/+136
| | | | | | | | | | | | of integral types to bool and improve the handling of implicit conversion of member pointers to bool. Implicit conversion of member pointers are replaced with explicit comparisons to nullptr. Implicit conversions of integral types are replaced with explicit comparisons to 0. Patch by Richard Thomson. llvm-svn: 260096
* [clang-tidy] Fix a use-after-free bug found by asanAlexander Kornienko2015-12-291-2/+3
| | | | llvm-svn: 256562
* [clang-tidy] Preserve comments and preprocessor directives when simplifying ↵Alexander Kornienko2015-12-281-39/+68
| | | | | | | | | | | | | | | | | | boolean expressions This changeset still emits the diagnostic that the expression could be simplified, but it doesn't generate any fix-its that would lose comments or preprocessor directives within the text that would be replaced. Fixes PR25842 Reviewers: alexfh Subscribers: xazax.hun, cfe-commits Patch by Richard Thomson! (+a naming style fix) Differential Revision: http://reviews.llvm.org/D15737 llvm-svn: 256492
* Refactors AST matching code to use the new AST matcher names. This patch ↵Aaron Ballman2015-09-171-22/+25
| | | | | | correlates to r247885 which performs the AST matcher rename in Clang. llvm-svn: 247886
* [clang-tidy] Enhance clang-tidy readability-simplify-boolean-expr...Alexander Kornienko2015-07-011-27/+230
| | | | | | | | | | | | | | | | | | | | Enhance clang-tidy readability-simplify-boolean-expr to handle 'if (e) return true; return false;' and improve replacement expressions. This changeset extends the simplify boolean expression check in clang-tidy to simplify if (e) return true; return false; to return e; (note the lack of an else clause on the if statement.) By default, chained conditional assignment is left unchanged, unless a configuration parameter is set to non-zero to override this behavior. It also improves the handling of replacement expressions to apply static_cast<bool>(expr) when expr is not of type bool. http://reviews.llvm.org/D9810 Patch by Richard Thomson! llvm-svn: 241155
* [clang-tidy] Enhance clang-tidy readability-simplify-boolean-expr check...Alexander Kornienko2015-05-171-11/+37
| | | | | | | | | | | | | | | | Enhance clang-tidy readability-simplify-boolean-expr check to handle chained conditional assignment and chained conditional return. Based on feedback from applying this tool to the clang/LLVM codebase, this changeset improves the readability-simplify-boolean-expr check so that conditional assignment or return statements at the end of a chain of if/else if statements are left unchanged unless a configuration option is supplied. http://reviews.llvm.org/D8996 Patch by Richard Thomson! llvm-svn: 237541
* [clang-tidy] Add readability-simplify-boolean-expr check to clang-tidyAlexander Kornienko2015-04-101-0/+375
This check looks for comparisons between boolean expressions and boolean constants and simplifies them to just use the appropriate boolean expression directly. if (b == true) becomes if (b) if (b == false) becomes if (!b) if (b && true) becomes if (b) if (b && false) becomes if (false) if (b || true) becomes if (true) if (b || false) becomes if (b) e ? true : false becomes e e ? false : true becomes !e if (true) t(); else f(); becomes t(); if (false) t(); else f(); becomes f(); if (e) return true; else return false; becomes return (e); if (e) return false; else return true; becomes return !(e); if (e) b = true; else b = false; becomes b = e; if (e) b = false; else b = true; becomes b = !(e); http://reviews.llvm.org/D7648 Patch by Richard Thomson! llvm-svn: 234626
OpenPOWER on IntegriCloud