summaryrefslogtreecommitdiffstats
path: root/clang-tools-extra/clang-tidy/readability
Commit message (Collapse)AuthorAgeFilesLines
...
* [clang-tidy][NFC] Test commit. Add missing comma.Yitzhak Mandelbaum2019-02-081-2/+2
| | | | llvm-svn: 353523
* [clang-tidy] Work around http://llvm.org/PR40392Alexander Kornienko2019-01-211-4/+10
| | | | | | | | | The readability-else-after-return check should be smarter about cases where the variable defined in the condition is used in the `else` branch. This patch makes it just ignore such cases, but alternative solutions may be better (added a FIXME). llvm-svn: 351751
* Update the file headers across all of the LLVM projects in the monorepoChandler Carruth2019-01-1967-268/+201
| | | | | | | | | | | | | | | | | 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
* Convert two more files that were using Windows line endings and removeChandler Carruth2019-01-191-58/+58
| | | | | | | a stray single '\r' from one file. These are the last line ending issues I can find in the files containing parts of LLVM's file headers. llvm-svn: 351634
* [clang-tidy] update FunctionSizeCheck for D56444Sam McCall2019-01-141-1/+6
| | | | | | | | | | Reviewers: JonasToth, aaron.ballman Subscribers: xazax.hun, cfe-commits Differential Revision: https://reviews.llvm.org/D56552 llvm-svn: 351048
* [clang-tidy] new check 'readability-redundant-preprocessor'Miklos Vajna2019-01-114-0/+148
| | | | | | | | | | Finds potentially redundant preprocessor directives. Reviewed By: aaron.ballman Differential Revision: https://reviews.llvm.org/D54349 llvm-svn: 350922
* [clang-tidy] add IgnoreMacros option to readability-uppercase-literal-suffixMiklos Vajna2018-12-242-1/+6
| | | | | | | | | | | | | | And also enable it by default to be consistent with e.g. modernize-use-using. This helps e.g. when running this check on client code where the macro is provided by the system, so there is no easy way to modify it. Reviewed By: JonasToth, lebedev.ri Differential Revision: https://reviews.llvm.org/D56025 llvm-svn: 350056
* 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-202-18/+5
| | | | llvm-svn: 349758
* [clang-tidy] Remove duplicated getText implementation, NFCHaojian Wu2018-12-071-11/+7
| | | | llvm-svn: 348583
* [clang-tidy] Ignore bool -> single bit bitfield conversion in ↵Malcolm Parsons2018-11-271-4/+10
| | | | | | | | | | | | | | | | readability-implicit-bool-conversion Summary: There is no ambiguity / information loss in this conversion Reviewers: alexfh, aaron.ballman, hokein Reviewed By: alexfh Subscribers: xazax.hun, cfe-commits Differential Revision: https://reviews.llvm.org/D54941 llvm-svn: 347671
* [clang-tidy] Avoid inconsistent notes in readability-container-size-emptyAlexander Kornienko2018-11-271-0/+8
| | | | | | | | | When a warning is issued in a template instantiation, the check would previously use template arguments in a note, which would result in inconsistent or duplicate warnings (depending on how deduplication was done). This patch removes template arguments from the note. llvm-svn: 347652
* A bit of AST matcher cleanup, NFC.Alexander Kornienko2018-11-253-15/+14
| | | | | | | | | 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-152-3/+14
| | | | | | | | | | | | | | 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
* Implement the readability-const-return-type check.Aaron Ballman2018-10-314-0/+167
| | | | | | | | 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-314-0/+319
| | | | | | | | | | | | | | | | | | | | | 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-265-19/+288
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | (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-255-286/+19
| | | | | | | | | | 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 IgnoreMacros option to readability-redundant-smartptr-getMiklos Vajna2018-10-212-1/+14
| | | | | | | | | | | | | And also enable it by default to be consistent with e.g. modernize-use-using. This helps e.g. when running this check on client code where the macro is provided by the system, so there is no easy way to modify it. Reviewed By: JonasToth Differential Revision: https://reviews.llvm.org/D53454 llvm-svn: 344871
* [clang-tidy] Resolve readability-else-after-return false positive for ↵Marek Kurdej2018-10-191-57/+58
| | | | | | | | | | | | | | | | | | | | | | | | | | | constexpr if. Summary: It fixes the false positive when using constexpr if and where else cannot be removed: Example: ``` if constexpr (sizeof(int) > 4) // ... return /* ... */; else // This else cannot be removed. // ... return /* ... */; ``` Reviewers: alexfh, aaron.ballman Reviewed By: aaron.ballman Subscribers: lebedev.ri, xazax.hun, cfe-commits Differential Revision: https://reviews.llvm.org/D53372 llvm-svn: 344785
* [clang-tidy] Add new 'readability-uppercase-literal-suffix' check (CERT ↵Roman Lebedev2018-10-185-19/+286
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* [clang-tidy] Added pointer types to clang-tidy readability-identifier-naming ↵Jonas Toth2018-10-041-0/+24
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | check. Summary: Option to check for different naming conventions on the following types: - GlobalConstantPointer - GlobalPointer - LocalConstantPointer - LocalPointer - PointerParameter - ConstantPointerParameter When not specified, the conventions for the non pointer types will be applied (GlobalConstant, GlobalVariable, LocalConstant, ...). Patch by ffigueras! Reviewers: alexfh, kbobyrev Reviewed By: alexfh Subscribers: xazax.hun, cfe-commits Differential Revision: https://reviews.llvm.org/D52882 llvm-svn: 343788
* [clang-tidy] Ignore singe bit bitfield -> bool conversion in ↵Alexander Kornienko2018-10-021-0/+1
| | | | | | readability-implicit-bool-conversion llvm-svn: 343578
* llvm::sort(C.begin(), C.end()) -> llvm::sort(C)Fangrui Song2018-09-271-1/+1
| | | | | | The convenience wrapper in STLExtras is available since rL342102. llvm-svn: 343166
* [Clang-tidy] Alphabetical sort of files/checks. Add space after clang-tidy ↵Eugene Zelenko2018-09-201-1/+1
| | | | | | in source code headers. llvm-svn: 342601
* [clang-tidy] Replace redundant checks with an assert().Artem Belevich2018-09-181-2/+3
| | | | | | | | | | findStyleKind is only called if D is an explicit identifier with a name, so the checks for operators will never return true. The explicit assert() enforces this invariant. Differential Revision: https://reviews.llvm.org/D52179 llvm-svn: 342514
* Add a new check to the readability module that flags uses of "magic numbers" ↵Aaron Ballman2018-08-124-0/+272
| | | | | | | | (both floating-point and integral). Patch by Florin Iucha <florin@signbit.net> llvm-svn: 339516
* Port getLocEnd -> getEndLocStephen Kelly2018-08-0910-16/+16
| | | | | | | | Subscribers: nemanjai, ioeric, kbarton, cfe-commits Differential Revision: https://reviews.llvm.org/D50355 llvm-svn: 339401
* Port getLocStart -> getBeginLocStephen Kelly2018-08-0922-56/+56
| | | | | | | | | | 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] readability-inconsistent-declaration-parameter-name: accept ↵Sam McCall2018-07-132-10/+22
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | approximate name matches. Summary: The goal is to reduce false positives when the difference is intentional, like: foo(StringRef name); foo(StringRef name_ref) { string name = cleanup(name_ref); ... } Or semantically unimportant, like: foo(StringRef full_name); foo(StringRef name) { ... } There are other matching names we won't recognise (e.g. syns vs synonyms) but this catches many that we see in practice, and gives people a systematic workaround. The old behavior is available as a 'Strict' option. Subscribers: xazax.hun, cfe-commits Differential Revision: https://reviews.llvm.org/D49285 llvm-svn: 336992
* [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
* Add a new check, readability-simplify-subscript-expr, that diagnoses array ↵Aaron Ballman2018-05-164-0/+118
| | | | | | | | | | 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-tools-extra] Update uses of DEBUG macro to LLVM_DEBUG.Nicola Zaghen2018-05-151-8/+8
| | | | | | | | | | | The DEBUG() macro is very generic so it might clash with other projects. The renaming was done as follows: - git grep -l 'DEBUG' | xargs sed -i 's/\bDEBUG\s\?(/LLVM_DEBUG(/g' - git diff -U0 master | ../clang/tools/clang-format/clang-format-diff.py -i -p1 -style LLVM Differential Revision: https://reviews.llvm.org/D44976 llvm-svn: 332371
* update test to use ivar in implementation instead of class extensionYan Zhang2018-04-231-0/+4
| | | | | | | | | | | | | | Summary: using ivar in class extension is not supported in 32-bit architecture of MacOS. Reviewers: alexfh, hokein Reviewed By: alexfh Subscribers: klimek, cfe-commits Differential Revision: https://reviews.llvm.org/D45912 llvm-svn: 330559
* Revert r330492: [clang-tidy] add new check to find out objc ivars which do ↵Chandler Carruth2018-04-211-4/+0
| | | | | | | | | | not have prefix '_' This commit has been breaking most bots for a day now. There is a fix proposed in https://reviews.llvm.org/D45912 but when I applied that I just got different errors. Reverting to get our bots back to green. llvm-svn: 330528
* [clang-tidy] add new check to find out objc ivars which do not have prefix '_'Yan Zhang2018-04-201-0/+4
| | | | | | | | | | | | | | | | | | | | | | | Summary: For code of ivar declaration: int barWithoutPrefix; The fix will be: int _barWithoutPrefix; Reviewers: benhamilton, hokein, alexfh, aaron.ballman, ilya-biryukov Reviewed By: alexfh Subscribers: Eugene.Zelenko, xazax.hun, klimek, mgorny, cfe-commits Tags: #clang-tools-extra Differential Revision: https://reviews.llvm.org/D45392 llvm-svn: 330492
* [clang-tidy] readability-function-size: add VariableThreshold param.Roman Lebedev2018-04-122-2/+51
| | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: Pretty straight-forward, just count all the variable declarations in the function's body, and if more than the configured threshold - do complain. Note that this continues perverse practice of disabling the new option by default. I'm not certain where is the balance point between not being too noisy, and actually enforcing the good practice. If we really want to not disable this by default, but also to not cause too many new warnings, we could default to 50 or so. But that is a lot of variables too... I was able to find one coding style referencing variable count: - https://www.kernel.org/doc/html/v4.15/process/coding-style.html#functions > Another measure of the function is the number of local variables. They shouldn’t exceed 5-10, or you’re doing something wrong. Reviewers: hokein, xazax.hun, JonasToth, aaron.ballman, alexfh Reviewed By: aaron.ballman Subscribers: kimgr, Eugene.Zelenko, rnkovacs, cfe-commits Tags: #clang-tools-extra Differential Revision: https://reviews.llvm.org/D44602 llvm-svn: 329902
* [clang-tidy] Add "portability" module and rename readability-simd-intrinsics ↵Fangrui Song2018-03-074-196/+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-154-0/+196
| | | | | | | | | | | | | | | | | | | | | 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-304-0/+122
| | | | llvm-svn: 323766
* [clang-tidy] Expand readability-redundant-smartptr-get to understand ↵Samuel Benzaquen2018-01-151-5/+14
| | | | | | | | | | | | | | implicit converions to bool in more contexts. Summary: Expand readability-redundant-smartptr-get to understand implicit converions to bool in more contexts. Reviewers: hokein Subscribers: klimek, xazax.hun, cfe-commits Differential Revision: https://reviews.llvm.org/D41998 llvm-svn: 322497
* [clang-tidy] Fix google-readability-namespace-comments handling of C++17 ↵Alexander Kornienko2018-01-112-10/+60
| | | | | | | | | | | | | | | | | | | | | | | | | nested namespaces Summary: Fixes bug 34701 When we encounter a namespace find the location of the left bracket. Then if the text between the name and the left bracket contains a ':' then it's a C++17 nested namespace. Reviewers: #clang-tools-extra, alexfh, aaron.ballman Reviewed By: aaron.ballman Subscribers: curdeius, cfe-commits, krasimir, JonasToth, JDevlieghere, xazax.hun Tags: #clang-tools-extra Patch by Alexandru Octavian Buțiu! Differential Revision: https://reviews.llvm.org/D38284 llvm-svn: 322274
* clang-tidy: add IgnoreMacros option to ↵Miklos Vajna2018-01-052-1/+15
| | | | | | | | | | | | | | | | | readability-inconsistent-declaration-parameter-name And also enable it by default to be consistent with e.g. modernize-use-using. This helps e.g. when running this check on client code where the macro is provided by the system, so there is no easy way to modify it. Reviewers: alexfh, piotrdz, hokein, ilya-biryukov Reviewed By: alexfh Differential Revision: https://reviews.llvm.org/D41716 llvm-svn: 321913
* [clang-tidy] Correctly classify constant arrays and constant strings as ↵Alexander Kornienko2017-12-111-33/+31
| | | | | | | | | | | | | | | | | | | | constants when checking identifiers naming Summary: They are not locally const qualified so they weren't classified as constants by the readability-identifier-naming check. Reviewers: alexfh Reviewed By: alexfh Subscribers: klimek, cfe-commits, xazax.hun Patch by Beren Minor! Differential Revision: https://reviews.llvm.org/D39363 llvm-svn: 320406
* [clang-tidy] make readability-simplify-bool-expr completely ignore macrosAlexander Kornienko2017-11-291-4/+1
| | | | llvm-svn: 319325
* [clang-tidy] Ignore ExprWithCleanups when looking for else-after-throwMalcolm Parsons2017-11-281-1/+2
| | | | | | | | | | | | | | | | | Summary: The readability-else-after-return check was not warning about an else after a throw of an exception that had arguments that needed to be cleaned up. Reviewers: aaron.ballman, alexfh, djasper Reviewed By: aaron.ballman Subscribers: lebedev.ri, klimek, xazax.hun, cfe-commits Differential Revision: https://reviews.llvm.org/D40505 llvm-svn: 319174
* [clang-tidy] readability-non-const-parameter fixes should update all ↵Alexander Kornienko2017-11-271-2/+11
| | | | | | | | declarations Fixes http://llvm.org/PR34410. llvm-svn: 319021
* Revert "Fix nested namespaces in google-readability-nested-namespace-comments."Alexander Kornienko2017-10-122-54/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This reverts r315057. The revision introduces assertion failures: assertion failed at llvm/tools/clang/include/clang/Basic/SourceManager.h:428 in const clang::SrcMgr::ExpansionInfo &clang::SrcMgr::SLocEntry::getExpansion() const: isExpansion() && "Not a macro expansion SLocEntry!" Stack trace: __assert_fail clang::SrcMgr::SLocEntry::getExpansion() clang::SourceManager::getExpansionLocSlowCase() clang::SourceManager::getExpansionLoc() clang::Lexer::getRawToken() clang::tidy::readability::NamespaceCommentCheck::check() clang::ast_matchers::internal::(anonymous namespace)::MatchASTVisitor::MatchVisitor::visitMatch() clang::ast_matchers::internal::BoundNodesTreeBuilder::visitMatches() clang::ast_matchers::internal::(anonymous namespace)::MatchASTVisitor::matchWithFilter() clang::ast_matchers::internal::(anonymous namespace)::MatchASTVisitor::matchDispatch() clang::ast_matchers::internal::(anonymous namespace)::MatchASTVisitor::TraverseDecl() clang::RecursiveASTVisitor<>::TraverseDeclContextHelper() clang::RecursiveASTVisitor<>::TraverseDecl() clang::RecursiveASTVisitor<>::TraverseDeclContextHelper() clang::RecursiveASTVisitor<>::TraverseDecl() clang::RecursiveASTVisitor<>::TraverseDeclContextHelper() clang::RecursiveASTVisitor<>::TraverseDecl() clang::ast_matchers::MatchFinder::matchAST() clang::MultiplexConsumer::HandleTranslationUnit() clang::ParseAST() clang::FrontendAction::Execute() clang::CompilerInstance::ExecuteAction() clang::tooling::FrontendActionFactory::runInvocation() clang::tooling::ToolInvocation::runInvocation() clang::tooling::ToolInvocation::run() Still working on an isolated test case. llvm-svn: 315580
* Fix nested namespaces in google-readability-nested-namespace-comments.Aaron Ballman2017-10-062-10/+54
| | | | | | | | Fixes PR34701. Patch by Alexandru Octavian Buțiu. llvm-svn: 315057
* [clang-tidy] FunctionSizeCheck: wrap FunctionASTVisitor into anon namespace, NFCRoman Lebedev2017-09-111-0/+3
| | | | | | | | | | | | | This check is relatively simple, and is often being used as an example. I'm aware of at least two cases, when simply copying the FunctionASTVisitor class to a new check resulted in a rather unobvious segfault. Having it in anonymous namespace prevents such a problem. No functionality change, so i opted to avoid phabricator, especially since clang-tidy reviews are seriously jammed. llvm-svn: 312912
OpenPOWER on IntegriCloud