summaryrefslogtreecommitdiffstats
path: root/clang-tools-extra/clang-tidy/readability/ReadabilityTidyModule.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Added readability-qualified-auto checkNathan James2020-01-141-0/+3
| | | | | | | | Adds a check that detects any auto variables that are deduced to a pointer or a const pointer then adds in the const and asterisk according. Will also check auto L value references that could be written as const. This relates to the coding standard https://llvm.org/docs/CodingStandards.html#beware-unnecessary-copies-with-auto
* [clang-tidy] Add readability-make-member-function-constMatthias Gehre2019-11-061-0/+3
| | | | | | | | | | | | | | | | | | Summary: Finds non-static member functions that can be made ``const`` because the functions don't use ``this`` in a non-const way. The check conservatively tries to preserve logical costness in favor of physical costness. See readability-make-member-function-const.rst for more details. Reviewers: aaron.ballman, gribozavr, hokein, alexfh Subscribers: mgorny, xazax.hun, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D68074
* Add the readability-redundant-access-specifiers check.Aaron Ballman2019-10-301-0/+3
| | | | | | This finds redundant access specifier declarations inside classes, structs, and unions. Patch by Mateusz Mackowski.
* [clang-tidy] initial version of readability-convert-member-functions-to-staticMatthias Gehre2019-07-161-0/+3
| | | | | | | | | | | | | | | | | | | | | | | | Summary: Finds non-static member functions that can be made ``static``. I have run this check (repeatedly) over llvm-project. It made 1708 member functions ``static``. Out of those, I had to exclude 22 via ``NOLINT`` because their address was taken and stored in a variable of pointer-to-member type (e.g. passed to llvm::StringSwitch). It also made 243 member functions ``const``. (This is currently very conservative to have no false-positives and can hopefully be extended in the future.) You can find the results here: https://github.com/mgehre/llvm-project/commits/static_const_eval Reviewers: alexfh, aaron.ballman Subscribers: mgorny, xazax.hun, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D61749 llvm-svn: 366265
* 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
* [clang-tidy] new check 'readability-redundant-preprocessor'Miklos Vajna2019-01-111-0/+3
| | | | | | | | | | Finds potentially redundant preprocessor directives. Reviewed By: aaron.ballman Differential Revision: https://reviews.llvm.org/D54349 llvm-svn: 350922
* Implement the readability-const-return-type check.Aaron Ballman2018-10-311-0/+3
| | | | | | | | This check flags function top-level const-qualified return types and suggests removing the mostly-superfluous const qualifier where possible. Patch by Yitzhak Mandelbaum. llvm-svn: 345764
* [clang-tidy] new check 'readability-isolate-declaration'Jonas Toth2018-10-311-0/+3
| | | | | | | | | | | | | | | | | | | | | Summary: This patch introduces a new clang-tidy check that matches on all `declStmt` that declare more then one variable and transform them into one statement per declaration if possible. It currently only focusses on variable declarations but should be extended to cover more kinds of declarations in the future. It is related to https://reviews.llvm.org/D27621 and does use it's extensive test-suite. Thank you to firolino for his work! Reviewers: rsmith, aaron.ballman, alexfh, hokein, kbobyrev Reviewed By: aaron.ballman Subscribers: ZaMaZaN4iK, mgehre, nemanjai, kbarton, lebedev.ri, Eugene.Zelenko, mgorny, xazax.hun, cfe-commits Tags: #clang-tools-extra Differential Revision: https://reviews.llvm.org/D51949 llvm-svn: 345735
* [clang-tidy] Re-commit: Add new 'readability-uppercase-literal-suffix' check ↵Roman Lebedev2018-10-261-0/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | (CERT DCL16-C, MISRA C:2012, 7.3, MISRA C++:2008, 2-13-4) Summary: Detects when the integral literal or floating point (decimal or hexadecimal) literal has non-uppercase suffix, and suggests to make the suffix uppercase, with fix-it. All valid combinations of suffixes are supported. ``` auto x = 1; // OK, no suffix. auto x = 1u; // warning: integer literal suffix 'u' is not upper-case auto x = 1U; // OK, suffix is uppercase. ... ``` This is a re-commit, the original was reverted by me in rL345305 due to discovered bugs. (implicit code, template instantiation) Tests were added, and the bugs were fixed. I'm unable to find any further bugs, hopefully there aren't any.. References: * [[ https://wiki.sei.cmu.edu/confluence/pages/viewpage.action?pageId=87152241 | CERT DCL16-C ]] * MISRA C:2012, 7.3 - The lowercase character "l" shall not be used in a literal suffix * MISRA C++:2008, 2-13-4 - Literal suffixes shall be upper case Reviewers: JonasToth, aaron.ballman, alexfh, hokein, xazax.hun Reviewed By: aaron.ballman Subscribers: Eugene.Zelenko, mgorny, rnkovacs, cfe-commits Tags: #clang-tools-extra Differential Revision: https://reviews.llvm.org/D52670 llvm-svn: 345381
* [clang-tidy] Revert my readability-uppercase-literal-suffix check.Roman Lebedev2018-10-251-3/+0
| | | | | | | | | | There are some lurking issues with the handling of the SourceManager. Somehow sometimes we end up extracting completely wrong portions of the source buffer. Reverts r344772, r44760, r344758, r344755. llvm-svn: 345305
* [clang-tidy] Add new 'readability-uppercase-literal-suffix' check (CERT ↵Roman Lebedev2018-10-181-0/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | DCL16-C, MISRA C:2012, 7.3, MISRA C++:2008, 2-13-4) Summary: Detects when the integral literal or floating point (decimal or hexadecimal) literal has non-uppercase suffix, and suggests to make the suffix uppercase, with fix-it. All valid combinations of suffixes are supported. ``` auto x = 1; // OK, no suffix. auto x = 1u; // warning: integer literal suffix 'u' is not upper-case auto x = 1U; // OK, suffix is uppercase. ... ``` References: * [[ https://wiki.sei.cmu.edu/confluence/pages/viewpage.action?pageId=87152241 | CERT DCL16-C ]] * MISRA C:2012, 7.3 - The lowercase character "l" shall not be used in a literal suffix * MISRA C++:2008, 2-13-4 - Literal suffixes shall be upper case Reviewers: JonasToth, aaron.ballman, alexfh, hokein, xazax.hun Reviewed By: aaron.ballman Subscribers: Eugene.Zelenko, mgorny, rnkovacs, cfe-commits Tags: #clang-tools-extra Differential Revision: https://reviews.llvm.org/D52670 llvm-svn: 344755
* Add a new check to the readability module that flags uses of "magic numbers" ↵Aaron Ballman2018-08-121-0/+3
| | | | | | | | (both floating-point and integral). Patch by Florin Iucha <florin@signbit.net> llvm-svn: 339516
* Add a new check, readability-simplify-subscript-expr, that diagnoses array ↵Aaron Ballman2018-05-161-0/+3
| | | | | | | | | | subscript expressions that can be simplified. Currently, diagnoses code that calls container.data()[some_index] when the container exposes a suitable operator[]() method that can be used directly. Patch by Shuai Wang. llvm-svn: 332519
* [clang-tidy] Add "portability" module and rename readability-simd-intrinsics ↵Fangrui Song2018-03-071-3/+0
| | | | | | | | | | | | to portability-simd-intrinsics Reviewers: alexfh Subscribers: klimek, nemanjai, mgorny, xazax.hun, kbarton, cfe-commits Differential Revision: https://reviews.llvm.org/D44173 llvm-svn: 326909
* [clang-tidy] Add `readability-simd-intrinsics` check.Fangrui Song2018-02-151-0/+3
| | | | | | | | | | | | | | | | | | | | | Summary: Many architectures provide SIMD operations (e.g. x86 SSE/AVX, Power AltiVec/VSX, ARM NEON). It is common that SIMD code implementing the same algorithm, is written in multiple target-dispatching pieces to optimize for different architectures or micro-architectures. The C++ standard proposal P0214 and its extensions cover many common SIMD operations. By migrating from target-dependent intrinsics to P0214 operations, the SIMD code can be simplified and pieces for different targets can be unified. Refer to http://wg21.link/p0214 for introduction and motivation for the data-parallel standard library. Subscribers: klimek, aemerson, mgorny, xazax.hun, kristof.beyls, hintonda, cfe-commits Differential Revision: https://reviews.llvm.org/D42983 llvm-svn: 325272
* clang-tidy/rename_check.py misc-string-compare readability-string-compareAlexander Kornienko2018-01-301-0/+3
| | | | llvm-svn: 323766
* [clang-tidy] Add new readability non-idiomatic static access checkGabor Horvath2017-08-081-0/+3
| | | | | | | | Patch by: Lilla Barancsuk Differential Revision: https://reviews.llvm.org/D35937 llvm-svn: 310371
* [clang-tidy] 'implicit cast' -> 'implicit conversion'Alexander Kornienko2017-08-081-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | | Summary: This patch renames checks, check options and changes messages to use correct term "implicit conversion" instead of "implicit cast" (which has been in use in Clang AST since ~10 years, but it's still technically incorrect w.r.t. C++ standard). * performance-implicit-cast-in-loop -> performance-implicit-conversion-in-loop * readability-implicit-bool-cast -> readability-implicit-bool-conversion - readability-implicit-bool-cast.AllowConditionalIntegerCasts -> readability-implicit-bool-conversion.AllowIntegerConditions - readability-implicit-bool-cast.AllowConditionalPointerCasts -> readability-implicit-bool-conversion.AllowPointerConditions Reviewers: hokein, jdennett Reviewed By: hokein Subscribers: mgorny, JDevlieghere, xazax.hun, cfe-commits Differential Revision: https://reviews.llvm.org/D36456 llvm-svn: 310366
* [clang-tidy] Add readability-misleading-indentation check.Gabor Horvath2017-02-141-0/+3
| | | | | | Differential Revision: https://reviews.llvm.org/D19586 llvm-svn: 295041
* [clang-tidy] Add delete null pointer check.Gabor Horvath2016-12-311-0/+3
| | | | | | | | | | This check detects and fixes redundant null checks before deletes. Patch by: Gergely Angeli! Differential Revision: https://reviews.llvm.org/D21298 llvm-svn: 290784
* [clang-tidy] Add check for redundant function pointer dereferencesMalcolm Parsons2016-12-131-0/+3
| | | | | | | | | | Reviewers: alexfh, aaron.ballman, hokein Subscribers: mgorny, JDevlieghere, cfe-commits Differential Revision: https://reviews.llvm.org/D27520 llvm-svn: 289524
* [clang-tidy] Add check readability-redundant-declarationDaniel Marjamaki2016-11-011-0/+3
| | | | | | | | | | | Finds redundant variable and function declarations. extern int X; extern int X; // <- redundant Differential Revision: https://reviews.llvm.org/D24656 llvm-svn: 285689
* [clang-tidy] Add check 'readability-redundant-member-init'Malcolm Parsons2016-10-201-0/+3
| | | | | | | | | | | | Summary: The check emits a warning if a member-initializer calls the member's default constructor with no arguments. Reviewers: sbenza, alexfh, aaron.ballman Subscribers: modocache, mgorny, Eugene.Zelenko, etienneb, Prazek, hokein, cfe-commits, beanz Differential Revision: https://reviews.llvm.org/D24339 llvm-svn: 284742
* [clang-tidy] readability-misplaced-array-index: add new check that warns ↵Daniel Marjamaki2016-09-121-0/+3
| | | | | | | | | | when array index is misplaced. Reviewers: alexfh Differential Revision: https://reviews.llvm.org/D21134 llvm-svn: 281206
* [clang-tidy] readability-non-const-parameter: add new check that warns when ↵Daniel Marjamaki2016-08-231-0/+3
| | | | | | | | | | | | | | function parameters should be const The check will warn when the constness will make the function interface safer. Reviewers: alexfh Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D15332 llvm-svn: 279507
* [clang-tidy] Add a readability-deleted-default clang-tidy check.Alexander Kornienko2016-04-131-0/+3
| | | | | | | | | | | Checks if constructors and assignment operators that are marked '= default' are actually deleted by the compiler. Patch by Alex Pilkiewicz! Differential Revision: http://reviews.llvm.org/D18961 llvm-svn: 266190
* [clang-tidy] Add a check to detect static definitions in anonymous namespace.Haojian Wu2016-04-051-0/+3
| | | | | | | | | | | | Summary: Fixes PR26595 Reviewers: alexfh Subscribers: cfe-commits Differential Revision: http://reviews.llvm.org/D18180 llvm-svn: 265384
* [clang-tidy] readability check for const params in declarationsAlexander Kornienko2016-03-301-0/+3
| | | | | | | | | | | | | | Summary: Adds a clang-tidy warning for top-level consts in function declarations. Reviewers: hokein, sbenza, alexfh Subscribers: cfe-commits Patch by Matt Kulukundis! Differential Revision: http://reviews.llvm.org/D18408 llvm-svn: 264856
* Add a new check, readability-redundant-string-init, that checks unnecessary ↵Alexander Kornienko2016-02-251-0/+3
| | | | | | | | | | | | | | string initializations. Reviewers: hokein, alexfh Subscribers: cfe-commits Patch by Shuai Wang! Differential Revision: http://reviews.llvm.org/D17586 llvm-svn: 261939
* Sort checks alphabetically in ReadabilityTidyModule.cpp.Eugene Zelenko2016-02-011-4/+4
| | | | llvm-svn: 259393
* Add a new check, readability-redundant-control-flow, that check for some ↵Aaron Ballman2016-02-011-0/+3
| | | | | | | | forms of redundant control flow statements. Currently checks for return statements at the end of a function with a void return type and continue statements at the end of looping statements. Patch by Richard Thomson. llvm-svn: 259362
* [clang-tidy] Add check readability-implicit-bool-castPiotr Dziwinski2015-10-251-0/+3
| | | | | | | | | | | | | | | | | | | | | Summary: This is another check that I ported to clang-tidy from colobot-lint tool. As previously discussed on cfe-dev mailing list, this is one of those checks that I think is general and useful enough for contribution to clang-tidy. This patch contains implementation of check taken from colobot-lint, but it is extended a great deal, including FixIt hints for automated refactoring, exhaustive testcases, and user documentation. Reviewers: sbenza, aaron.ballman, alexfh Subscribers: Eugene.Zelenko Differential Revision: http://reviews.llvm.org/D13635 llvm-svn: 251235
* Added check uniqueptr-delete-release to replace "delete x.release()" with "x ↵Samuel Benzaquen2015-10-191-0/+3
| | | | | | | | | | = nullptr" Reviewers: alexfh Differential Revision: http://reviews.llvm.org/D13179 llvm-svn: 250742
* [clang-tidy] Add inconsistent declaration parameter name checkAlexander Kornienko2015-09-101-0/+3
| | | | | | | | | | | | | | | | | | | | This is first of series of patches, porting code from my project colobot-lint, as I mentioned recently in cfe-dev mailing list. This patch adds a new check in readability module: readability-inconsistent-declaration-parameter-name. I also added appropriate testcases and documentation. I chose readability module, as it seems it is the best place for it. I think I followed the rules of LLVM coding guideline, but I may have missed something, as I usually use other code formatting style. http://reviews.llvm.org/D12462 Patch by Piotr Dziwinski! llvm-svn: 247261
* [clang-tidy] Move misc-use-override and readability-shrink-to-fit to ↵Alexander Kornienko2015-08-311-3/+0
| | | | | | | | | "modernize/" These checks are focusing on migrating the code from C++98/03 to C++11, so they belong to the modernize module. llvm-svn: 246437
* [clang-tidy] Add new IdentifierNaming checkAlexander Kornienko2015-08-191-0/+3
| | | | | | | | | | | | | | | | | | | | This check will try to enforce coding guidelines on the identifiers naming. It supports lower_case, UPPER_CASE, camelBack and CamelCase casing and tries to convert from one to another if a mismatch is detected. It also supports a fixed prefix and suffix that will be prepended or appended to the identifiers, regardless of the casing. Many configuration options are available, in order to be able to create different rules for different kind of identifier. In general, the rules are falling back to a more generic rule if the specific case is not configured. http://reviews.llvm.org/D10933 Patch by Beren Minor! llvm-svn: 245429
* [clang-tidy] Add readability-simplify-boolean-expr check to clang-tidyAlexander Kornienko2015-04-101-1/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* [clang-tidy] Move google-readability-function check to ↵Alexander Kornienko2015-03-161-0/+3
| | | | | | | | | | | | | | | | readability-named-parameter. Summary: The relevant style rule is going to be removed, thus the check is no longer needed in the Google module. Leaving the check in readability/ in case someone needs it. Reviewers: djasper Reviewed By: djasper Subscribers: curdeius, cfe-commits Differential Revision: http://reviews.llvm.org/D8261 llvm-svn: 232431
* Move remove-cstr-calls from a standalone executable to a clang-tidy check ↵Alexander Kornienko2015-03-161-7/+9
| | | | | | | | | | readability-redundant-string-cstr http://reviews.llvm.org/D7318 Patch by Richard Thomson! llvm-svn: 232338
* [clang-tidy] Refactor: Rename clang-tidy readability check files and classes ↵Alexander Kornienko2015-03-091-4/+4
| | | | | | | | | | | | | to follow naming conventions Classes are named WhateverCheck, files are WhateverCheck.cpp and` WhateverCheck.h` http://reviews.llvm.org/D8144 Patch by Richard Thomson! llvm-svn: 231650
* [clang-tidy] Use shrink_to_fit instead of copy and swap trickAlexander Kornienko2015-01-231-0/+3
| | | | | | | | | | | | | | | | The shrink_to_fit() method is more readable and more effective than the copy and swap trick to reduce the capacity of a shrinkable container. Note that, the shrink_to_fit() method is only available in C++11 and up. Example: std::vector<int>(v).swap(v); will be replaced with v.shrink_to_fit(); http://reviews.llvm.org/D7087 Patch by Gábor Horváth! llvm-svn: 226912
* clang-tidy: 'size' call that could be replaced with 'empty' on STL containersAlexander Kornienko2015-01-151-0/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | We are porting some of the checkers at a company we developed to the Clang Tidy infrastructure. We would like to open source the checkers that may be useful for the community as well. This patch is the first checker that is being ported to Clang Tidy. We also added fix-it hints, and applied them to LLVM: http://reviews.llvm.org/D6924 The code compiled and the unit tests are passed after the fixits was applied. The documentation of the checker: /// The emptiness of a container should be checked using the empty method /// instead of the size method. It is not guaranteed that size is a /// constant-time function, and it is generally more efficient and also shows /// clearer intent to use empty. Furthermore some containers may implement the /// empty method but not implement the size method. Using empty whenever /// possible makes it easier to switch to another container in the future. It also uses some custom ASTMatchers. In case you find them useful I can submit them as separate patches to clang. I will apply your suggestions to this patch. http://reviews.llvm.org/D6925 Patch by Gábor Horváth! llvm-svn: 226172
* clang-tidy: Add initial check for "Don't use else after return".Daniel Jasper2015-01-141-0/+3
| | | | | | | | | | | As per the LLVM coding standards: http://llvm.org/docs/CodingStandards.html#don-t-use-else-after-a-return Initial version, probably still quite a bit to do until this is really useful. Review: http://reviews.llvm.org/D6927 llvm-svn: 226025
* [clang-tidy] Bring order to check registration.Alexander Kornienko2014-10-261-0/+44
Summary: Register readability checks in a separate module. Renamed the checks and test file names accordingly. Reviewers: djasper, klimek Reviewed By: klimek Subscribers: curdeius, cfe-commits Differential Revision: http://reviews.llvm.org/D5936 llvm-svn: 220631
OpenPOWER on IntegriCloud