summaryrefslogtreecommitdiffstats
path: root/clang-tools-extra/clang-tidy/misc
Commit message (Collapse)AuthorAgeFilesLines
...
* Implemented clang-tidy-check-specific options.Alexander Kornienko2014-09-128-3/+17
| | | | | | | | | | | | | | | | | Summary: Each check can implement readOptions and storeOptions methods to read and store custom options. Each check's options are stored in a local namespace to avoid name collisions and provide some sort of context to the user. Reviewers: bkramer, klimek Reviewed By: klimek Subscribers: cfe-commits Differential Revision: http://reviews.llvm.org/D5296 llvm-svn: 217661
* Unique-ptrify ClangTidyCheckFactories. Add a more convenient alternative toAlexander Kornienko2014-09-101-21/+11
| | | | | | | | | | | | | | addCheckFactory: registerCheck. Reviewers: djasper Reviewed By: djasper Subscribers: cfe-commits Differential Revision: http://reviews.llvm.org/D5288 llvm-svn: 217489
* ClangTidy misc-argument-comment check: don't check arguments to templateAlexander Kornienko2014-09-031-0/+9
| | | | | | | | | | | | | | | | | | | parameter packs. Summary: This disables this check for std::bind and similar functions that use parameter packs to forward arguments to a different function. Name of the parameter pack argument doesn't matter. Reviewers: klimek Reviewed By: klimek Subscribers: cfe-commits Differential Revision: http://reviews.llvm.org/D5168 llvm-svn: 217039
* [clang-tidy] Eliminate inline copies of InTemplateInstantiation matcher.Benjamin Kramer2014-09-032-11/+6
| | | | llvm-svn: 217036
* [clang-tidy] Use new ASTMatchers to identify template instantiations instead ↵Benjamin Kramer2014-09-031-4/+1
| | | | | | | | of copying it everywhere. No intended functionality change. llvm-svn: 217035
* [clang-tidy] Disable the warning on implicit bool* to bool conversion in macros.Benjamin Kramer2014-08-121-1/+9
| | | | | | It's just too noisy and the warning isn't very helpful in those cases. llvm-svn: 215439
* [clang-tidy] Rewrite a for-range loop in the old style.Benjamin Kramer2014-08-041-3/+3
| | | | | | | | Haven't thought that I ever needed to do this, but in this case comparing the index using pointer arithmetic turns out to be really ugly. It also generates nasty sign-compare warnings on 32 bit targets. llvm-svn: 214705
* [clang-tidy] Add a checker for code that looks like a delegate constructors ↵Benjamin Kramer2014-07-314-0/+111
| | | | | | | | | | | | | | | | | | | | | | | | | | | but doesn't delegate. Summary: class Foo { Foo() { Foo(42); // oops } Foo(int); }; This is valid code but it does nothing and we can't emit a warning in clang because there might be side effects. The checker emits a warning for this pattern and also for base class initializers written in this style. There is some overlap with the unused-rtti checker but they follow different goals and fire in different places most of the time. Reviewers: alexfh, djasper Subscribers: cfe-commits Differential Revision: http://reviews.llvm.org/D4667 llvm-svn: 214397
* Don't warn on NewCallback argument comments, as they are arguments for theAlexander Kornienko2014-07-301-4/+9
| | | | | | | | | | | | | | function the callback points to. Reviewers: djasper Reviewed By: djasper Subscribers: cfe-commits Differential Revision: http://reviews.llvm.org/D4722 llvm-svn: 214307
* clang-tidy: [use-override] Tweak messages.Daniel Jasper2014-07-281-2/+2
| | | | | | | | It doesn't make sense to suggest 'virtual' as clang-tidy would complain about that on the next iteration (we are never issuing warnings for the base function). llvm-svn: 214063
* [clang-tidy] Fix a heap use-after-free bug detected by asan.Benjamin Kramer2014-07-241-4/+4
| | | | llvm-svn: 213845
* Add the fix that should've accompanied r213738.Benjamin Kramer2014-07-231-3/+6
| | | | llvm-svn: 213740
* Reapply r213647 with a fix.Benjamin Kramer2014-07-234-0/+135
| | | | | | | | | | | | | | | | | | | | | | | | | | | ASTMatchers currently have problems mixing bound TypeLoc nodes with Decl/Stmt nodes. That should be fixed soon but for this checker there we only need the TypeLoc to generate a fixit so postpone the potentially heavyweight AST walking until after we know that we're going to emit a warning. This is covered by existing test cases. Original message: [clang-tidy] Add a check for RAII temporaries. This tries to find code similar that immediately destroys an object that looks like it's trying to follow RAII. { scoped_lock(&global_mutex); critical_section(); } This checker will have false positives if someone uses this pattern to legitimately invoke a destructor immediately (or the statement is at the end of a scope anyway). To reduce the number we ignore this pattern in macros (this is heavily used by gtest) and ignore objects with no user-defined destructor. llvm-svn: 213738
* Revert r213647; the added test triggers an assertion.Richard Smith2014-07-234-135/+0
| | | | llvm-svn: 213722
* [clang-tidy] Add a check for RAII temporaries.Benjamin Kramer2014-07-224-0/+135
| | | | | | | | | | | | | | | | | | | | | | | | Summary: This tries to find code similar that immediately destroys an object that looks like it's trying to follow RAII. { scoped_lock(&global_mutex); critical_section(); } This checker will have false positives if someone uses this pattern to legitimately invoke a destructor immediately (or the statement is at the end of a scope anyway). To reduce the number we ignore this pattern in macros (this is heavily used by gtest) and ignore objects with no user-defined destructor. Reviewers: alexfh, djasper Subscribers: cfe-commits Differential Revision: http://reviews.llvm.org/D4615 llvm-svn: 213647
* clang-tidy: [misc-use-override] Slightly tweak the wording of warning.Daniel Jasper2014-07-211-5/+5
| | | | | | 'final' should really be used with care. llvm-svn: 213501
* [clang-tidy] Add a checker for swapped arguments.Benjamin Kramer2014-07-144-0/+160
| | | | | | | | | This looks for swapped arguments by looking at implicit conversions of arguments void Foo(int, double); Foo(1.0, 3); // Most likely a bug llvm-svn: 212942
* [CMake] Update libdeps.NAKAMURA Takumi2014-07-141-0/+1
| | | | llvm-svn: 212920
* [clang-tidy] Add a checker for implicit bool conversion of a bool*.Benjamin Kramer2014-07-114-0/+109
| | | | | | | | | | | | | | | | | The goal is to find code like the example below, which is likely a typo where someone meant to write "if (*b)". bool *b = SomeFunction(); if (b) { // b never dereferenced } This checker naturally has a relatively high false positive rate so it applies some heuristics to avoid cases where the pointer is checked for nullptr before being written. Differential Revision: http://reviews.llvm.org/D4458 llvm-svn: 212797
* clang-tidy: [misc-use-override] Correctly handle defaulted destructors.Daniel Jasper2014-06-201-6/+4
| | | | | | Also, minor implementation and test fixes. llvm-svn: 211345
* clang-tidy: [use-override] Remove 'override' if 'final' is also present.Daniel Jasper2014-06-111-6/+18
| | | | | | Also, make warning more precise by distinguishing different cases. llvm-svn: 210651
* clang-tidy use override: Don't generate incorrect warnings without fixesDaniel Jasper2014-06-041-1/+2
| | | | | | Add basic testing for the emitted diagnostics. llvm-svn: 210171
* clang-tidy: Extend the use-override check to understand 'final'.Daniel Jasper2014-06-021-3/+5
| | | | llvm-svn: 210031
* Revert "Remove redundant check discovered in post-commit review of r209505."Daniel Jasper2014-05-301-1/+3
| | | | | | | | | This breaks with MSVC. With IsLateTemplateParsed, FunctionDecl::doesThisDeclarationHaveABody() returns true regardless of Body. This reinstates what was fixed in r208985. llvm-svn: 209896
* Remove redundant check discovered in post-commit review of r209505.Daniel Jasper2014-05-301-3/+1
| | | | llvm-svn: 209882
* clang-tidy: Only add 'override' before inlined bodies.Daniel Jasper2014-05-231-1/+2
| | | | llvm-svn: 209505
* Address review comments on r208954. No functional changes.Daniel Jasper2014-05-191-7/+6
| | | | llvm-svn: 209111
* Initializer list is unavailable. Use the constructor instead.NAKAMURA Takumi2014-05-161-2/+3
| | | | llvm-svn: 208986
* clang-tidy/misc/UseOverride.cpp: Appease targeting msvc.NAKAMURA Takumi2014-05-161-1/+1
| | | | | | With IsLateTemplateParsed, FunctionDecl::doesThisDeclarationHaveABody() returns True regardless of Body. llvm-svn: 208985
* Initial version of clang-tidy check to use override instead of virual.Daniel Jasper2014-05-164-0/+165
| | | | | Review: http://reviews.llvm.org/D3688 llvm-svn: 208954
* Do not touch get() calls on 'this' object.Samuel Benzaquen2014-04-291-0/+1
| | | | | | | | | | | | | | | | Summary: These calls are part of the implementation of the smart pointer itself and chaning it is likely to be wrong. Example: T& operator*() const { return *get(); } Reviewers: djasper Subscribers: cfe-commits Differential Revision: http://reviews.llvm.org/D3540 llvm-svn: 207525
* Extend the check to detect patterns like 'ptr.get() == nullptr'Samuel Benzaquen2014-04-091-23/+55
| | | | | | | | | | | | | | | | | Summary: Extend the check to detect patterns like 'ptr.get() == nullptr' It detects == and != when any argument is a ptr.get() and the other is a nullptr. Only supports standard smart pointer types std::unique_ptr and std::shared_ptr. Does not support the case 'ptr.get() == other.get()' yet. Reviewers: djasper CC: cfe-commits, alexfh Differential Revision: http://llvm-reviews.chandlerc.com/D3294 llvm-svn: 205854
* Add clang-tidy check to remove redundant .get() calls on smart pointers.Samuel Benzaquen2014-03-274-3/+130
| | | | | | | | | | | | | | | Summary: This check finds and removes redundant .get() calls on smart pointers. Example: ptr.get()->Foo() ==> ptr->Foo() Reviewers: alexfh CC: cfe-commits Differential Revision: http://llvm-reviews.chandlerc.com/D3186 llvm-svn: 204947
* clang-tidy/ArgumentCommentCheck: Initializer list in non-static members is ↵NAKAMURA Takumi2014-03-182-1/+6
| | | | | | unavailable on msc17. llvm-svn: 204121
* Add an argument comment checker to clang-tidy.Peter Collingbourne2014-03-184-0/+211
| | | | | | | | | | | | | | | | | | | | | | | | | | | This checks that parameters named in comments that appear before arguments in function and constructor calls match the parameter name used in the callee's declaration. For example: void f(int x, int y); void g() { f(/*y=*/0, /*z=*/0); } contains two violations of the policy, as the names 'x' and 'y' used in the declaration do not match names 'y' and 'z' used at the call site. I think there is significant value in being able to check/enforce this policy as a way of guarding against accidental API misuse and silent breakages caused by API changes. Although this pattern appears somewhat frequently in the LLVM codebase, this policy is not prescribed by the LLVM coding standards at the moment, so it lives under 'misc'. Differential Revision: http://llvm-reviews.chandlerc.com/D2914 llvm-svn: 204113
* Added a module for checks not related to LLVM or Google coding style.Alexander Kornienko2014-03-053-0/+55
llvm-svn: 202970
OpenPOWER on IntegriCloud