summaryrefslogtreecommitdiffstats
path: root/clang-tools-extra/clang-tidy/readability
Commit message (Collapse)AuthorAgeFilesLines
...
* [clang-tidy] Add new readability non-idiomatic static access checkGabor Horvath2017-08-084-0/+137
| | | | | | | | Patch by: Lilla Barancsuk Differential Revision: https://reviews.llvm.org/D35937 llvm-svn: 310371
* [clang-tidy] 'implicit cast' -> 'implicit conversion'Alexander Kornienko2017-08-084-42/+40
| | | | | | | | | | | | | | | | | | | | | | | | | 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
* Adapt clang-tidy checks to changing semantics of hasDeclaration.Manuel Klimek2017-08-023-12/+16
| | | | | | Differential Revision: https://reviews.llvm.org/D36154 llvm-svn: 309810
* [clang-tidy] Handle anonymous structs/unions in member init checks.Malcolm Parsons2017-08-011-2/+3
| | | | | | | | | | | | Use getAnyMember() instead of getMember() to avoid crash on anonymous structs/unions. Don't warn about initializing members of an anonymous union. Fixes PR32966. Reviewed by alexfh. llvm-svn: 309668
* [clang-tidy] readability-redundant-declaration: ignore friends and macrosAlexander Kornienko2017-07-282-5/+19
| | | | llvm-svn: 309379
* [clang-tidy] readability-function-size: fix nesting level calculationRoman Lebedev2017-06-161-10/+15
| | | | | | | | | | | | | | | | | | | | | | | | | Summary: A followup for D32942. Malcolm Parsons has provided a valid testcase that the initial version of the check complained about nested `if`'s. As it turns out, the culprit is the **partially** un-intentional `switch` fallthrough. So rewrite the NestingThreshold logic without ab-using+mis-using that switch with fallthrough, and add testcases with nested `if`' where there should be a warning and shouldn't be a warning. This results in a cleaner, simpler code, too. I guess, now it would be actually possible to pick some reasonable default for `NestingThreshold` setting. Fixes PR33454. Reviewers: malcolm.parsons, alexfh Reviewed By: malcolm.parsons Subscribers: sbenza, xazax.hun, cfe-commits, aaron.ballman Tags: #clang-tools-extra Differential Revision: https://reviews.llvm.org/D34202 llvm-svn: 305554
* [clang-tidy] readability-function-size: add NestingThreshold param.Roman Lebedev2017-06-092-8/+35
| | | | | | | | | | | | | | | | | | | | | | | | Summary: Finds compound statements which create next nesting level after `NestingThreshold` and emits a warning. Do note that it warns about each compound statement that breaches the threshold, but not any of it's sub-statements, to have readable warnings. I was able to find only one coding style referencing nesting: - https://www.kernel.org/doc/html/v4.10/process/coding-style.html#indentation > In short, 8-char indents make things easier to read, and have the added benefit of warning you when you’re nesting your functions too deep. This seems too basic, i'm not sure what else to test. Are more tests needed? Reviewers: alexfh, aaron.ballman, sbenza Reviewed By: alexfh, aaron.ballman Subscribers: xazax.hun Tags: #clang-tools-extra Differential Revision: https://reviews.llvm.org/D32942 llvm-svn: 305082
* (no commit message)Florian Gross2017-05-251-1/+1
| | | | llvm-svn: 303849
* [clang-tidy] readability-redundant-declaration false positive for defaulted ↵Alexander Kornienko2017-05-221-5/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | function Summary: ``` template <class T> struct C { C(); }; template <class T> C<T>::C() = default; ``` Causes a readability-redundant-declaration diagnostic. This is caused by `isDefinition` not matching defaulted functions. Reviewers: alexfh, danielmarjamaki Reviewed By: alexfh Subscribers: xazax.hun, cfe-commits Patch by Florian Gross! Differential Revision: https://reviews.llvm.org/D33358 llvm-svn: 303552
* [clang-tidy] readability-braces-around-statements false positive with char ↵Alexander Kornienko2017-05-221-2/+3
| | | | | | | | | | | | | | | | | | | | | | | | | literals Summary: Single-line if statements cause a false positive when the last token in the conditional statement is a char constant: ``` if (condition) return 'a'; ``` For some reason `findEndLocation` seems to skips too many (vertical) whitespaces in this case. The same problem already occured with string literals (https://reviews.llvm.org/D25558), and was fixed by adding a special check for this very case. I just extended the condition to also include char constants. No idea what really causes the issue though. Reviewers: alexfh Reviewed By: alexfh Subscribers: xazax.hun, cfe-commits Patch by Florian Gross! Differential Revision: https://reviews.llvm.org/D33354 llvm-svn: 303551
* [clang-tidy] Optimize readability-implicit-bool-cast, NFCAlexander Kornienko2017-05-161-10/+10
| | | | | | | Rearrange matchers to put the most expensive ones closer to the end. Speed up another 3-5x on some files. llvm-svn: 303187
* [clang-tidy] Optimize matchers in readability-implicit-bool-cast. NFCAlexander Kornienko2017-05-161-8/+10
| | | | | | | Don't repeat `isInTemplateInstantiation()` and `hasAncestor()` unnecessarily. This speeds up the check by a factor of up to 3 on some large files. llvm-svn: 303180
* [clang-tidy] Partly rewrite readability-simplify-boolean-expr using RAVAlexander Kornienko2017-05-152-120/+101
| | | | | | | | | | 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] Minor cleanup + a disabled test case for PR26228. NFCAlexander Kornienko2017-05-091-5/+5
| | | | llvm-svn: 302522
* [clang-tidy] Fix readability-implicit-bool-cast false positivesAlexander Kornienko2017-05-081-1/+2
| | | | | | | | The patch makes the check treat binary conditional operator (`x ?: y`), `while` and regular `for` loops as conditional statements for the purpose of AllowConditional*Cast options. llvm-svn: 302431
* [clang-tidy] fix readability-implicit-bool-cast false positive with xorAlexander Kornienko2017-05-041-15/+17
| | | | llvm-svn: 302164
* [clang-tidy] fix readability-implicit-bool-cast false alarm on |=, &=Alexander Kornienko2017-05-041-24/+24
| | | | llvm-svn: 302161
* [clang-tidy] Code cleanup, (almost) NFC (*).Alexander Kornienko2017-05-041-148/+91
| | | | | | | (*) Printed types of member pointers don't use elaborated type specifiers (`int struct S::*` -> `int S::*`). llvm-svn: 302160
* [clang-tidy] Expand AllowConditional*Casts to binary logical operatorsAlexander Kornienko2017-04-291-12/+22
| | | | llvm-svn: 301743
* [clang-tidy] Update IdentifierNamingCheck to remove extra leading/trailing ↵Alexander Kornienko2017-04-261-4/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | underscores Summary: The goal of this change is to fix the following suboptimal replacements currently suggested by clang-tidy: ``` // with MemberPrefix == "_" int __foo; // accepted without complaint ``` ``` // with MemberPrefix == "m_" int _foo; ^~~~~~ m__foo ``` I fixed this by - updating `matchesStyle()` to reject names which have a leading underscore after a prefix has already been stripped, or a trailing underscore if a suffix has already been stripped; - updating `fixupWithStyle()` to strip leading & trailing underscores before adding the user-defined prefix and suffix. The replacements are now: ``` // MemberPrefix == "_" int __foo; ^~~~~~ _foo ``` ``` // MemberPrefix == "m_" int _foo; ^~~~~ m_foo ``` Future improvements might elect to add .clang-tidy flags to improve what is being stripped. For instance, stripping `m_` could allow `m_foo` to be automatically replaced with `_foo`. Reviewers: alexfh Reviewed By: alexfh Subscribers: cfe-commits Patch by Jacob Bandes-Storch! Differential Revision: https://reviews.llvm.org/D32333 llvm-svn: 301431
* Extend readability-container-size-empty to add comparisons to empty-state ↵Aaron Ballman2017-04-241-5/+63
| | | | | | | | objects. Patch by Josh Zimmerman. llvm-svn: 301185
* [clang-tidy] clang-format the last patch. NFCAlexander Kornienko2017-03-222-24/+15
| | | | llvm-svn: 298500
* [clang-tidy] modified identifier naming case to use CT_AnyCase for ignoring ↵Alexander Kornienko2017-03-222-82/+103
| | | | | | | | | | | | | | | | | | | | | case style Summary: Using CaseType::CT_AnyCase for selected identifier results in inheriting case style setting from more basic identifier type. This patch changes CT_AnyCase behavior to ignore case style of specified identifier. If case style was not set, llvm::Optional will be used for keeping this information (llvm::Optional<>::hasVal), thus CT_AnyCase will no longer mean more general identifier style should be used. This eliminates false-positives when naming convention is not clear for specific areas of code (legacy, third party) or for selected types. Reviewers: berenm, alexfh Reviewed By: alexfh Subscribers: cfe-commits, JDevlieghere Differential Revision: https://reviews.llvm.org/D30931 llvm-svn: 298499
* Apply clang-tidy's performance-unnecessary-value-param to clang-tidy.Benjamin Kramer2017-03-211-1/+1
| | | | | | No functionality change intended. llvm-svn: 298442
* [clang-tidy] readability-container-size-empty fix for (*x).size()Alexander Kornienko2017-03-201-3/+2
| | | | llvm-svn: 298316
* [clang-tidy] Small cleanup. NFC.Alexander Kornienko2017-03-201-10/+4
| | | | llvm-svn: 298315
* [clang-tidy] readability-misleading-indentation: fix chained ifAlexander Kornienko2017-03-172-2/+23
| | | | | | | | | | | | | | | | | | | | | | | | | | Summary: Fixed erroneously flagging of chained if statements when styled like this: ``` if (cond) { } else if (cond) { } else { } ``` Reviewers: xazax.hun, alexfh Reviewed By: xazax.hun, alexfh Subscribers: JDevlieghere, cfe-commits Patch by Florian Gross! Differential Revision: https://reviews.llvm.org/D30841 llvm-svn: 298059
* [clang-tidy] readability-function-size: remove default param count thresholdAlexander Kornienko2017-03-081-1/+1
| | | | llvm-svn: 297311
* [clang-tidy] Add parametercount for readibility-function-sizeAlexander Kornienko2017-03-012-2/+16
| | | | | | | | | | | | | | | | | | | Summary: Add an option to function-size to warn about high parameter counts. This might be relevant for cppcoreguidelines and the safety module as well. Since the safety module is not landed in master already, i did not create an alias, but that can be done later as well. Reviewers: sbenza, alexfh, hokein Reviewed By: alexfh, hokein Subscribers: JDevlieghere Patch by Jonas Toth! Differential Revision: https://reviews.llvm.org/D29561 llvm-svn: 296599
* [clang-tidy] Fix readability-redundant-declaration false positiveDaniel Marjamaki2017-02-241-8/+4
| | | | | | Differential Revision: https://reviews.llvm.org/D27048 llvm-svn: 296100
* [clang-tidy] Add readability-misleading-indentation check.Gabor Horvath2017-02-144-0/+148
| | | | | | Differential Revision: https://reviews.llvm.org/D19586 llvm-svn: 295041
* [clang-tidy] Fix for bug 31838: readability-delete-null-pointer does not ↵Mads Ravn2017-02-121-1/+1
| | | | | | | | work for class members Fix for commit r294912 which had a small error in the AST matcher. llvm-svn: 294913
* [clang-tidy] Fix for bug 31838: readability-delete-null-pointer does not ↵Mads Ravn2017-02-122-6/+16
| | | | | | | | | | | | | | | | | | | | | | | | | work for class members I have made a small fix for readability-delete-null-pointer check so it also checks for class members. Example of case that it fixes ``` struct A { void foo() { if(mp) delete mp; } int *mp; }; ``` Reviewers: JDevlieghere, aaron.ballman, alexfh, malcolm.parsons Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D29726 llvm-svn: 294912
* [clang-tidy] Add delete null pointer check.Gabor Horvath2016-12-314-0/+115
| | | | | | | | | | 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] Make 2 checks register matchers for C++ only.Malcolm Parsons2016-12-271-0/+3
| | | | llvm-svn: 290633
* [clang-tidy] Ignore `size() == 0` in the container implementation.Alexander Kornienko2016-12-211-1/+3
| | | | llvm-svn: 290289
* modernize-use-auto NFC fixesPiotr Padlewski2016-12-144-5/+5
| | | | llvm-svn: 289656
* Remove deprecated methods ast_matchers::BoundNodes::{getStmtAs,getDeclAs}Alexander Kornienko2016-12-131-3/+3
| | | | llvm-svn: 289542
* [clang-tidy] Add check for redundant function pointer dereferencesMalcolm Parsons2016-12-134-0/+76
| | | | | | | | | | Reviewers: alexfh, aaron.ballman, hokein Subscribers: mgorny, JDevlieghere, cfe-commits Differential Revision: https://reviews.llvm.org/D27520 llvm-svn: 289524
* readability-redundant-declaration: Fix crashDaniel Marjamaki2016-11-211-0/+2
| | | | | | Differential Revision: https://reviews.llvm.org/D26911 llvm-svn: 287540
* [clang-tidy] Fix identifier naming for initializer list member initializers.Eric Fiselier2016-11-161-0/+9
| | | | | | | | | | | | | | | | | | | | | | | | Summary: This patch adds handling for member initializers in a constructors initializer list. Previously we only handled base-class and delegating initializers, which are transformed by the `TypeLoc` matcher. For Example: ``` // Style options: All identifiers should start with an upper case letter. struct base { ... }; struct der : base { int field; // FIXES: int Field; der() : der(42) {} // FIXES: Der() : Der(42) {} der(int X) : base(), field(X) {} // FIXES: Der(int X) : Base(), field(X) // Note that `field` doesn't get replaced }; ``` Reviewers: alexfh, hokein, aaron.ballman Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D26744 llvm-svn: 287153
* [clang-tidy] Change readability-redundant-member-init to get base type from ↵Malcolm Parsons2016-11-151-1/+1
| | | | | | | | | | | | | | constructor Summary: Fixes PR30835 Reviewers: alexfh, hokein, aaron.ballman Subscribers: Prazek, cfe-commits Differential Revision: https://reviews.llvm.org/D26118 llvm-svn: 286990
* [clang-tools-extra] Format sources with clang-format. NFC.Mandeep Singh Grang2016-11-0815-81/+72
| | | | | | | | | | | | | | | | Summary: Ran clang-format on all .c/.cpp/.h files in clang-tools-extra. Excluded the test, unittests, clang-reorder-fields, include-fixer, modularize and pptrace directories. Reviewers: klimek, alexfh Subscribers: nemanjai Tags: #clang-tools-extra Differential Revision: https://reviews.llvm.org/D26329 llvm-svn: 286221
* [clang-tidy] Fixed readability-else-after-return for cascade statementsMalcolm Parsons2016-11-041-1/+1
| | | | | | | | | | | | | | | | | | Summary: Fix generated by this check changed program semantics in the case where 'if' was a part (direct child) of other statement. Fixes PR30652. Patch by Paweł Żukowski. Reviewers: malcolm.parsons, alexfh, djasper Subscribers: mgehre, omtcyfz, cfe-commits Differential Revision: https://reviews.llvm.org/D26125 llvm-svn: 285999
* [clang-tidy] Ignore forward declarations without definitions in the same ↵Jonathan Coe2016-11-031-0/+3
| | | | | | | | | | | | | | translation unit in readability-identifier-naming Summary: This change ensures that forward declarations of classes are not considered for identifier naming checks within a translation unit. Reviewers: alexfh, aaron.ballman Subscribers: mgehre Differential Revision: https://reviews.llvm.org/D22571 llvm-svn: 285907
* [clang-tidy] Handle data() in readability-redundant-string-cstrMalcolm Parsons2016-11-031-3/+5
| | | | | | | | | | | | | | | Summary: std::string::data() and std::string::c_str() are equivalent. Enhance the readability-redundant-string-cstr check to also handle calls to data(). Reviewers: etienneb, alexfh, aaron.ballman Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D26279 llvm-svn: 285901
* [clang-tidy] Add check readability-redundant-declarationDaniel Marjamaki2016-11-014-0/+110
| | | | | | | | | | | 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] Fix identifier naming in macro args.Jason Henline2016-10-241-7/+37
| | | | | | | | | | | | | | | | | | | | | | Summary: clang-tidy should fix identifier naming even when the identifier is referenced inside a macro expansion, provided that the identifier enters the macro expansion completely within a macro argument. For example, this will allow fixes to the naming of the identifier 'global' when it is declared and used as follows: int global; #define USE_IN_MACRO(m) auto use_##m = m USE_IN_MACRO(global); Reviewers: alexfh Subscribers: jlebar, cfe-commits Differential Revision: https://reviews.llvm.org/D25450 llvm-svn: 284992
* [clang-tidy] Add check 'readability-redundant-member-init'Malcolm Parsons2016-10-204-0/+105
| | | | | | | | | | | | 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] Fix readability-braces-around-statements false positiveMarek Kurdej2016-10-141-1/+1
| | | | | | | | | | | | | | | | | Summary: This fixes a false-positive e.g. when string literals are returned from if statement. This patch includes as well a small fix to includes and renames of the test suite that collided with the name of the check. Reviewers: alexfh, hokein Subscribers: hokein Tags: #clang-tools-extra Differential Revision: https://reviews.llvm.org/D25558 llvm-svn: 284212
OpenPOWER on IntegriCloud