summaryrefslogtreecommitdiffstats
path: root/clang-tools-extra/clang-tidy
Commit message (Collapse)AuthorAgeFilesLines
* [clangd] Fix modernize-loop-convert "multiple diag in flight" crash.Haojian Wu2020-06-101-9/+8
| | | | | | | | | | | | | | | | | Summary: this maybe not ideal, but it is trivial and does fix the crash. Fixes https://github.com/clangd/clangd/issues/156. Reviewers: sammccall Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, kadircet, usaxena95, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D78715 (cherry picked from commit a466e4be3831848d7ff6ffbe4f57d99de8fb66af)
* Fix crash in InfinteLoopCheckNathan James2020-02-171-0/+2
| | | | (cherry picked from commit 8c4cf23dee1ac3f259c4795b275cc9bb1234aa29)
* [clang-tidy] Added check to disable bugprone-infinite-loop on known false ↵Nathan James2020-02-121-0/+10
| | | | | | | | | | | | | | | | | | condition Summary: Addresses [[ https://bugs.llvm.org/show_bug.cgi?id=44816 | bugprone-infinite-loop false positive with CATCH2 ]] by disabling the check on loops where the condition is known to always eval as false, in other words not a loop. Reviewers: aaron.ballman, alexfh, hokein, gribozavr2, JonasToth Reviewed By: gribozavr2 Subscribers: xazax.hun, cfe-commits Tags: #clang, #clang-tools-extra Differential Revision: https://reviews.llvm.org/D74374 (cherry picked from commit c69ec6476806147e46bf09b693acb24177982dc2)
* [clang-tidy] Fix false positive for cppcoreguidelines-init-variablesNathan James2020-02-101-5/+9
| | | | | | | | | | | | | | | | Summary: Fixes [[ https://bugs.llvm.org/show_bug.cgi?id=44746 | False positive for cppcoreguidelines-init-variables in range based for loop in template function ]] Reviewers: aaron.ballman, alexfh, hokein, JonasToth, gribozavr2 Reviewed By: aaron.ballman Subscribers: merge_guards_bot, xazax.hun, wuzish, nemanjai, kbarton, cfe-commits Tags: #clang, #clang-tools-extra Differential Revision: https://reviews.llvm.org/D73843 (cherry picked from commit efcd09cea9a51c522954aa24e4b5513266daf6c3)
* [clang-tidy] Fixed crash 44745 in readability-else-after-returnNathan James2020-02-031-0/+4
| | | | | | | | | | | | | | | | Summary: Fixes [[ https://bugs.llvm.org/show_bug.cgi?id=44745 | readability-else-after-return crashes ]] Reviewers: aaron.ballman, alexfh, hokein, JonasToth, gribozavr2 Reviewed By: alexfh Subscribers: merge_guards_bot, xazax.hun, cfe-commits Tags: #clang, #clang-tools-extra Differential Revision: https://reviews.llvm.org/D73841 (cherry picked from commit d591bdce6d623208d4aeb335a762d839f0f8f0f7)
* [clan-tidy] Fix false positive in bugprone-infinite-loopAdam Balogh2020-01-291-4/+20
| | | | | | | | | | | | | | The checker bugprone-infinite-loop does not track changes of variables in the initialization expression of a variable declared inside the condition of the while statement. This leads to false positives, similarly to the one in the bug report https://bugs.llvm.org/show_bug.cgi?id=44618. This patch fixes this issue by enabling tracking of the variables of this expression as well. Differential Revision: https://reviews.llvm.org/D73270 (cherry picked from commit 70f4c6e7b14f225f9628fbdab3620ce037613351)
* [clang-tidy] Fix check for generic lambda invented template parametersSaar Raz2020-01-241-1/+1
| | | | | | | | | clang-tidy previously relied on there being no identifier for a TemplateTypeParmDecl for checking whether 'decltype(x)' should be inserted, instead of checking whether or not it is implicit. D65042 added new names for invented generic lambda template parameters, rendering that check incorrect. (cherry picked from commit 5fdad8e3f803adce501ca25118f325184e54018d)
* [clang-tidy] Disable Checks on If constexpr statements in template ↵Nathan2020-01-232-2/+6
| | | | | | | | | | | | | | | | | | Instantiations for BugproneBranchClone and ReadabilityBracesAroundStatements Summary: fixes [[ https://bugs.llvm.org/show_bug.cgi?id=32203 | readability-braces-around-statements broken for if constexpr]] and [[ https://bugs.llvm.org/show_bug.cgi?id=44229 | bugprone-branch-clone false positive with template functions and constexpr ]] by disabling the relevant checks on if constexpr statements while inside an instantiated template. This is due to how the else branch of an if constexpr statement is folded away to a null statement if the condition evaluates to false Reviewers: alexfh, hokein, aaron.ballman, xazax.hun Reviewed By: aaron.ballman, xazax.hun Subscribers: rnkovacs, JonasToth, Jim, lebedev.ri, xazax.hun, cfe-commits Tags: #clang-tools-extra, #clang Differential Revision: https://reviews.llvm.org/D71980 (cherry picked from commit f9c46229e4ac29053747c96e08c574c6c48d544b)
* Added readability-qualified-auto checkNathan James2020-01-145-0/+337
| | | | | | | | 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] Match InitListExpr in modernize-use-default-member-initMalcolm Parsons2020-01-141-1/+1
| | | | | | | | | | | | | | | | | | Summary: modernize-use-default-member-init wasn't warning about redundant initialisers when the initialiser was an InitListExpr. Add initListExpr to the matcher. Fixes: PR44439 Reviewers: aaron.ballman, alexfh, JonasToth Reviewed By: aaron.ballman Subscribers: xazax.hun, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D72691
* [clang-tidy] Ignore implicit casts in modernize-use-default-member-initMalcolm Parsons2020-01-141-1/+1
| | | | | | | | | | | | | | | | | | Summary: Initialising a pointer from nullptr involves an implicit cast. Ignore it after getting initialiser from InitListExpr. Fixes: PR44440 Reviewers: aaron.ballman, alexfh, JonasToth Reviewed By: JonasToth Subscribers: xazax.hun, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D72630
* Fix readability-identifier-naming missing member variablesNathan James2020-01-131-6/+26
| | | | | Fixes PR41122 (missing fixes for member variables in a destructor) and PR29005 (does not rename class members in all locations).
* clang-tidy doc: Refresh the list of checkers and polish the scriptSylvestre Ledru2020-01-101-4/+2
|
* MakeUniqueCheck.cpp: explicit the fact that there is an autofix for this checkerSylvestre Ledru2020-01-101-0/+2
|
* [clang-tidy] Refresh the add_new_check.py now that we use a table + autofixSylvestre Ledru2020-01-091-12/+67
| | | | | | | | | | | | Reviewers: alexfh Reviewed By: alexfh Subscribers: njames93, xazax.hun, mgorny, cfe-commits Tags: #clang, #clang-tools-extra Differential Revision: https://reviews.llvm.org/D72421
* [APFloat] Fix checked error assert failuresEhud Katz2020-01-091-6/+8
| | | | | | | | | | | `APFLoat::convertFromString` returns `Expected` result, which must be "checked" if the LLVM_ENABLE_ABI_BREAKING_CHECKS preprocessor flag is set. To mark an `Expected` result as "checked" we must consume the `Error` within. In many cases, we are only interested in knowing if an error occured, without the need to examine the error info. This is achieved, easily, with the `errorToBool()` API.
* [clang-tidy] Disable match on `if constexpr` statements in template ↵Andi-Bogdan Postelnicu2020-01-081-1/+5
| | | | | | | | | | | | | | instantiation for `readability-misleading-indentation` check. Summary: Fixes fixes `readability-misleading-identation` for `if constexpr`. This is very similar to D71980. Reviewers: alexfh Subscribers: xazax.hun, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D72333
* [clang-tidy] modernize-use-using uses AST and now supports struct defintions ↵Mitchell Balan2020-01-072-84/+69
| | | | | | | | | | | | | | | | | | | | | | | | | | | | and multiple types in a typedef Summary: It now handles `typedef`s that include comma-separated multiple types, and handles embedded struct definitions, which previously could not be automatically converted. For example, with this patch `modernize-use-using` now can convert: typedef struct { int a; } R_t, *R_p; to: using R_t = struct { int a; }; using R_p = R_t*; `-ast-dump` showed that the `CXXRecordDecl` definitions and multiple `TypedefDecl`s come consecutively in the tree, so `check()` stores information between calls to determine when it is receiving a second or additional `TypedefDecl` within a single `typedef`, or when the current `TypedefDecl` refers to an embedded `CXXRecordDecl` like a `struct`. Reviewers: alexfh, aaron.ballman Patch by: poelmanc Subscribers: riccibruno, sammccall, cfe-commits, aaron.ballman Tags: clang-tools-extra, clang Differential Revision: https://reviews.llvm.org/D70270
* [clang-tidy] new check: bugprone-signed-char-misuseTamás Zolnai2020-01-064-0/+152
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: This check searches for signed char -> integer conversions which might indicate programming error, because of the misinterpretation of char values. A signed char might store the non-ASCII characters as negative values. The human programmer probably expects that after an integer conversion the converted value matches with the character code (a value from [0..255]), however, the actual value is in [-128..127] interval. See also: STR34-C. Cast characters to unsigned char before converting to larger integer sizes <https://wiki.sei.cmu.edu/confluence/display/c/STR34-C.+Cast+characters+to+unsigned+char+before+converting+to+larger+integer+sizes> By now this check is limited to assignment / variable declarations. If we would catch all signed char -> integer conversion, then it would produce a lot of findings and also false positives. So I added only this use case now, but this check can be extended with additional use cases later. The CERT documentation mentions another use case when the char is used for array subscript. Next to that a third use case can be the signed char - unsigned char comparison, which also a use case where things happen unexpectedly because of conversion to integer. Reviewers: alexfh, hokein, aaron.ballman Reviewed By: aaron.ballman Subscribers: sylvestre.ledru, whisperity, Eugene.Zelenko, mgorny, xazax.hun, cfe-commits Tags: #clang, #clang-tools-extra Differential Revision: https://reviews.llvm.org/D71174
* Fix MSVC "not all control paths return a value" warning. NFCI.Simon Pilgrim2020-01-061-0/+1
|
* [APFloat] Fix compilation warningsEhud Katz2020-01-061-2/+6
|
* NFC: Fix trivial typos in commentsKazuaki Ishizaki2020-01-0418-19/+19
|
* [clang-tidy] fix linkage with clangSema for FixitHintUtils, undo previous ↵Jonas Toth2020-01-031-0/+1
| | | | wrong fix
* [clang-tidy] implement utility-function to add 'const' to variablesJonas Toth2020-01-037-15/+257
| | | | | | | | | | | | | | | | | | | | | | | Summary: This patch extends the already existing facility to add 'const' to variables to be more flexible and correct. The previous version did not consider pointers as value AND pointee. For future automatic introduction for const-correctness this shortcoming needs to be fixed. It always allows configuration where the 'const' token is inserted, either on the left side (if possible) or the right side. It adds many unit-tests to the utility-function that did not exist before, as the function was implicitly tested through clang-tidy checks. These tests were not changed, as the API is still compatible. Reviewers: aaron.ballman, hokein, alexfh, shuaiwang, lebedev.ri Reviewed By: aaron.ballman Subscribers: jdoerfert, mgorny, xazax.hun, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D54395
* Fix trivial typos in comments; NFCKazuaki Ishizaki2020-01-024-4/+4
|
* Handle init statements in readability-else-after-returnNathan James2020-01-022-30/+216
| | | | | | | | | | Adds a new ASTMatcher condition called 'hasInitStatement()' that matches if, switch and range-for statements with an initializer. Reworked clang-tidy readability-else-after-return to handle variables in the if condition or init statements in c++17 ifs. Also checks if removing the else would affect object lifetimes in the else branch. Fixes PR44364.
* [NFC] Fixes -Wrange-loop-analysis warningsMark de Wever2020-01-014-4/+4
| | | | | | This avoids new warnings due to D68912 adds -Wrange-loop-analysis to -Wall. Differential Revision: https://reviews.llvm.org/D71857
* Fix readability-const-return-type identifying the wrong `const` tokenIlya Mirsky2019-12-243-19/+32
| | | | | | | Replace tidy::utils::lexer::getConstQualifyingToken with a corrected and also generalized to other qualifiers variant - getQualifyingToken. Fixes PR44326
* Fix false positive in magic number checker.Florin Iucha2019-12-241-3/+15
| | | | | cppcoreguidelines-avoid-magic-numbers should not warn about enum class. Fixes PR40640.
* [clang-tools-extra] Fix linking dylib for LLVMFrontendOpenMPMichał Górny2019-12-181-2/+3
| | | | | | | | Use LLVM_LINK_COMPONENTS to link the FrontendOpenMP library instead of passing it explicitly to LINK_LIBS. This fixes duplicating the library when clang-tidy is linked to LLVM dylib. Differential Revision: https://reviews.llvm.org/D71674
* [clang-tidy] Add cert-oop58-cpp checkGabor Bencze2019-12-154-0/+122
| | | | | | | | The check warns when (a member of) the copied object is assigned to in a copy constructor or copy assignment operator. Based on https://wiki.sei.cmu.edu/confluence/display/cplusplus/OOP58-CPP.+Copy+operations+must+not+mutate+the+source+object Differential Revision: https://reviews.llvm.org/D70052
* Fix -Wswitch-coverage warning in clang-tidy after ak_addrspace introduction.Eric Christopher2019-12-131-0/+3
| | | | | Differential Revision: https://reviews.llvm.org/D71486 Reviewed By: rsmith
* [clang-tidy] Use early returns to make the code easier to read and ↵Alexander Kornienko2019-12-121-6/+5
| | | | potentially run faster
* Fix naming style. NFC.Alexander Kornienko2019-12-122-21/+21
|
* [clang-tidy] Link shared library clangTidyOpenMPModule to library ↵Adam Balogh2019-12-111-0/+1
| | | | | | LLVMFrontendOpenMP Building shared libs was broken, it is fixed now.
* Magic number checker shouldn't warn on user defined string literalsTibor Brunner2019-12-091-4/+15
| | | | Fixes a false positive brought up by PR40633.
* Optionally exclude bitfield definitions from magic numbers checkFlorin Iucha2019-12-072-8/+39
| | | | Adds the IgnoreBitFieldsWidths option to readability-magic-numbers.
* Remove Expr.h include from ASTContext.h, NFCReid Kleckner2019-12-061-0/+1
| | | | | | | ASTContext.h is popular, prune its includes. Expr.h brings in Attr.h, which is also expensive. Move BlockVarCopyInit to Expr.h to accomplish this.
* [clang-tidy] Fix PR26274Alexander Kornienko2019-12-061-64/+70
| | | | | | | | | | | | | | | | | Summary: This commit fixes http://llvm.org/PR26274 in a simpler and more correct way than 4736d63f752f8d13f4c6a9afd558565c32119718 did. See https://reviews.llvm.org/D69855#1767089 for details. Reviewers: gribozavr, aaron.ballman, gribozavr2 Reviewed By: aaron.ballman, gribozavr2 Subscribers: gribozavr2, merge_guards_bot, xazax.hun, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D70974
* Revert "Fix llvm-namespace-comment for macro expansions"Alexander Kornienko2019-12-032-135/+13
| | | | | This reverts commit 4736d63f752f8d13f4c6a9afd558565c32119718. This commit introduces a ton of false positives and incorrect fixes. See https://reviews.llvm.org/D69855#1767089 for details.
* AvoidBindCheck.cpp: Fix unused variables warningHans Wennborg2019-12-031-2/+2
|
* AvoidBindCheck.cpp: Fix GCC 5.3 build errorsHans Wennborg2019-12-031-17/+17
| | | | | | | | | | | | | It was failing with: clang-tools-extra/clang-tidy/modernize/AvoidBindCheck.cpp:61:29: error: declaration of ‘clang::tidy::modernize::{anonymous}::CaptureMode clang::tidy::modernize::{anonymous}::BindArgument::CaptureMode’ [-fpermissive] CaptureMode CaptureMode = CM_None; ^ clang-tools-extra/clang-tidy/modernize/AvoidBindCheck.cpp:38:6: error: changes meaning of ‘CaptureMode’ from ‘enum clang::tidy::modernize::{anonymous}::CaptureMode’ [-fpermissive] enum CaptureMode { CM_None, CM_ByRef, CM_ByValue, CM_InitExpression }; ^
* [clang-tidy] Rewrite modernize-avoid-bind check.Zachary Turner2019-12-022-60/+544
| | | | | | | | | | | | | | | | | | | This represents largely a full re-write of modernize-avoid-bind, adding significant new functionality in the process. In particular: * Both boost::bind and std::bind are now supported * Function objects are supported in addition to functions * Member functions are supported * Nested calls are supported using capture-init syntax * std::ref() and boost::ref() are now recognized, and will capture by reference. * Rather than capturing with a global =, we now build up an individual capture list that is both necessary and sufficient for the call. * Fixits are supported in a much larger variety of scenarios than before. All previous tests pass under the re-write, but a large number of new tests have been added as well. Differential Revision: https://reviews.llvm.org/D70368
* [Clang-Tidy] Quick fix for bug in bugprone-macro-parentheses 43804Adam Balogh2019-12-021-1/+1
| | | | | | | | | Applying parentheses for statement leads to compilation error. Bug [[ 43804 | https://bugs.llvm.org/show_bug.cgi?id=43804 ]] is a compilation error suggested by a wrong fix of this checker. This patch is a quick fix for this issue. Differential Revision: https://reviews.llvm.org/D70850
* Use InitLLVM in clang-tidyRui Ueyama2019-11-281-1/+2
| | | | | | | | | | | | | Update clang-tidy to use InitLLVM, like several other llvm tools that were previously updated. On Windows, this allows clang-tidy to operate on arguments containing characters which cannot be represented in the system's ANSI code page such as filenames with Unicode characters. Fixes bugzilla bug 43751. Patch by Tristan Labelle. Differential Revision: https://reviews.llvm.org/D70694
* [clang-tidy] Fix PR35824Gabor Horvath2019-11-271-1/+2
| | | | Differential Revision: https://reviews.llvm.org/D46027
* [clang-tidy] Use range-for for check registration. NFCAlexander Kornienko2019-11-261-4/+2
| | | | Actually, just testing GitHub commit rights.
* Revert "Use InitLLVM to setup a pretty stack printer"Nico Weber2019-11-251-2/+1
| | | | | | | This reverts commit 3f76260dc0674cc0acb25f550a0f0c594cf537ea. Breaks at least these tests on Windows: Clang :: Driver/clang-offload-bundler.c Clang :: Driver/clang-offload-wrapper.c
* Use InitLLVM to setup a pretty stack printerRui Ueyama2019-11-261-1/+2
| | | | | | | | | | | | | | InitLLVM does not only save a few lines from main() but also makes the commands do the right thing for multibyte character pathnames on Windows (i.e. canonicalize argv's to UTF-8) because of the code we have in this file: https://github.com/llvm/llvm-project/blob/master/llvm/lib/Support/InitLLVM.cpp#L32 For many LLVM commands, we already have calls of InitLLVM, but there are still remainings. Differential Revision: https://reviews.llvm.org/D70702
* Fix llvm-namespace-comment for macro expansionsMarcin Twardak2019-11-232-13/+135
| | | | | If a namespace is a macro name, it should be allowed to close the namespace with the same name.
OpenPOWER on IntegriCloud