summaryrefslogtreecommitdiffstats
path: root/clang-tools-extra
Commit message (Collapse)AuthorAgeFilesLines
* [clang-tidy] Fix unnamed parameter comment insertion with multiple parameters.Benjamin Kramer2014-08-042-4/+11
| | | | llvm-svn: 214703
* [clang-tidy] Make the named parameter check only warn on declarations if a ↵Benjamin Kramer2014-08-042-32/+56
| | | | | | | | | | | | | | | | definition is visible. Summary: This allows us to copy the parameter name from the definition (as a comment) or insert /*unused*/ in both places. Reviewers: alexfh, klimek Subscribers: cfe-commits Differential Revision: http://reviews.llvm.org/D4772 llvm-svn: 214701
* Changed tool-template to use CommonOptionsParser.Alexander Kornienko2014-08-021-33/+14
| | | | | | | | | | | | Reviewers: pcc, klimek Reviewed By: klimek Subscribers: cfe-commits Differential Revision: http://reviews.llvm.org/D4765 llvm-svn: 214621
* Use CommonOptionsParser in clang-query. This fixes its support of the fixedAlexander Kornienko2014-08-021-26/+11
| | | | | | | | | | | | | | compilation database and makes it behave consistently with other clang tools. Reviewers: klimek, pcc Reviewed By: pcc Subscribers: cfe-commits Differential Revision: http://reviews.llvm.org/D4763 llvm-svn: 214607
* [clang-tidy] Add a checker for code that looks like a delegate constructors ↵Benjamin Kramer2014-07-315-0/+165
| | | | | | | | | | | | | | | | | | | | | | | | | | | 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-302-12/+25
| | | | | | | | | | | | | | 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-283-19/+19
| | | | | | | | 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
* Plug memory leaks.Benjamin Kramer2014-07-2410-20/+26
| | | | | | | Most of the changes are mechanic std::unique_ptr insertions. All leaks were detected by LeakSanitizer. llvm-svn: 213851
* [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
* check_clang_tidy_fix.sh: Fail immediately if clang-tidy crashes.Benjamin Kramer2014-07-231-1/+1
| | | | | | Otherwise we'll get confusing messages from FileCheck instead of seeing the real issue. llvm-svn: 213739
* Reapply r213647 with a fix.Benjamin Kramer2014-07-235-0/+196
| | | | | | | | | | | | | | | | | | | | | | | | | | | 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-235-196/+0
| | | | llvm-svn: 213722
* [clang-tidy] Add a check for RAII temporaries.Benjamin Kramer2014-07-225-0/+196
| | | | | | | | | | | | | | | | | | | | | | | | 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] Fix a false positive in the make_pair checker if an argument ↵Benjamin Kramer2014-07-212-2/+17
| | | | | | | | | has a explicit template argument. This required a rather ugly workaround for a problem in ASTMatchers where callee() is only overloaded for Stmt and Decl but not for Expr. llvm-svn: 213509
* 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
* Revert "unique_ptr-ify ownership of ASTConsumers"David Blaikie2014-07-177-32/+28
| | | | | | | | | This reverts commit r213308. Reverting to have some on-list discussion/confirmation about the ongoing direction of smart pointer usage in the LLVM project. llvm-svn: 213324
* unique_ptr-ify ownership of ASTConsumersDavid Blaikie2014-07-177-28/+32
| | | | llvm-svn: 213308
* Make the diagnostic message more complete to check the check name.Alexander Kornienko2014-07-171-1/+1
| | | | llvm-svn: 213245
* [clang-tidy] MemsetZeroLenghtChecker: Don't crash trying to evaluate ↵Benjamin Kramer2014-07-172-4/+10
| | | | | | dependent values. llvm-svn: 213238
* [clang-tidy] Provide links to the google style guide for checks derived from it.Benjamin Kramer2014-07-174-0/+4
| | | | llvm-svn: 213233
* Track clang r213171Alp Toker2014-07-1613-15/+13
| | | | | | The clang rewriter is now a core facility. llvm-svn: 213172
* [clang-tidy] As a simple heuristic don't emit a swap fixit that would createBenjamin Kramer2014-07-162-1/+6
| | | | | | | | | negative-sized memsets. memset(x, -1, 0) is still useless but swapping makes no sense here. Just emit a warning. llvm-svn: 213157
* [clang-tidy] Also emit a warning for memset(x, 0, 0)Benjamin Kramer2014-07-162-4/+10
| | | | | | | It doesn't make sense to suggest swapping the arguments here but it's still useless code llvm-svn: 213156
* [clang-tidy] Add a checker for zero-length memset.Benjamin Kramer2014-07-165-0/+176
| | | | | | | | | | | | If there's memset(x, y, 0) in the code it's most likely a mistake. The checker suggests a fix-it to swap 'y' and '0'. I think this has the potential to be promoted into a general clang warning after some testing in clang-tidy. Differential Revision: http://reviews.llvm.org/D4535 llvm-svn: 213155
* [clang-tidy] Add namespaces checkers.Benjamin Kramer2014-07-168-0/+181
| | | | | | | | | | This change contains of two checkers that warn about 1. anonymous namespaces in header files. 2. 'using namespace' directives everywhere. Differential Revision: http://reviews.llvm.org/D4523 llvm-svn: 213153
* Avoid adding redundant parens.Alexander Kornienko2014-07-162-10/+28
| | | | | | | | | | | | Reviewers: bkramer Reviewed By: bkramer Subscribers: cfe-commits, sbenza Differential Revision: http://reviews.llvm.org/D4534 llvm-svn: 213149
* Added documentation on how clang diagnostics are reported by clang-tidy.Alexander Kornienko2014-07-161-2/+13
| | | | llvm-svn: 213147
* [clang-tidy] Add a checker that warns on const string & members.Benjamin Kramer2014-07-165-0/+152
| | | | | | | | | | | | | | Summary: Those are considered unsafe and should be replaced with simple pointers or full copies. It recognizes both std::string and ::string. Reviewers: alexfh, djasper Subscribers: cfe-commits Differential Revision: http://reviews.llvm.org/D4522 llvm-svn: 213133
* Fix the diagnostic.cpp test to explicitly disable more google checksReid Kleckner2014-07-151-1/+1
| | | | | | | | | Imagine, hypothetically, that you had a build of clang-tidy that enabled the google-* checks by default. If you had such a binary, then this test would fail. Making it pass in that configuration isn't such a bad thing. llvm-svn: 213085
* [clang-tidy] Add a checker that flags unnamed parameters.Benjamin Kramer2014-07-155-0/+207
| | | | | | | | | | | | | | | | Summary: We still allow the escape hatch foo(int /*x*/) and also suggest this in a fixit. This is more powerful than the corresponding cpplint.py check it also flags functions with multiple arguments as naming all arguments is recommended by the google style guide. Reviewers: alexfh, djasper Subscribers: cfe-commits Differential Revision: http://reviews.llvm.org/D4518 llvm-svn: 213075
* [clang-tidy] extend make_pair test for fixits in template definitions.Benjamin Kramer2014-07-151-0/+4
| | | | llvm-svn: 213068
* [clang-tidy] Add a checker that flags all instances of overloaded unary ↵Benjamin Kramer2014-07-155-0/+106
| | | | | | | | | | operator& This handles both methods and freestanding overloads. Differential Revision: http://reviews.llvm.org/D4498 llvm-svn: 213067
* Prune Redundant libdeps in CMake's target_link_libraries and LLVMBuild.txt.NAKAMURA Takumi2014-07-152-3/+0
| | | | | | I checked this with Release+Asserts on x86_64-mingw32. Please restore partially if this were overkill. llvm-svn: 213064
* [clang-tidy] Add a checker that removes deducible arguments from std::make_pairBenjamin Kramer2014-07-155-0/+155
| | | | | | | | | | | Those may be incompatible with C++11 and are unnecessary. We suggest removing the template arguments when they match the types of the make_pair arguments or replace it with std::pair and explicit template arguments when not. Differential Revision: http://reviews.llvm.org/D4497 llvm-svn: 213058
* Fix build when various clang feature flags are enabled/disabledAlp Toker2014-07-141-3/+11
| | | | llvm-svn: 212994
* [clang-tidy] Add a checker for swapped arguments.Benjamin Kramer2014-07-145-0/+204
| | | | | | | | | 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
* Set up clang-tidy diagnostic consumer to print types etc.Alexander Kornienko2014-07-143-0/+10
| | | | | | | | | | | | Reviewers: bkramer Reviewed By: bkramer Subscribers: cfe-commits Differential Revision: http://reviews.llvm.org/D4494 llvm-svn: 212941
* Suggest automated replacements of C-style casts with C++ casts.Alexander Kornienko2014-07-142-18/+183
| | | | | | | | | | | | | | | | | | Summary: This patch implements a subset of possible replacements of C-style casts with const_cast/static_cast/reinterpret_cast. This should cover a large portion of cases in real code. Handling of a few more cases may be implemented eventually. Reviewers: sbenza, djasper Reviewed By: djasper Subscribers: cfe-commits Differential Revision: http://reviews.llvm.org/D4478 llvm-svn: 212924
* [CMake] Update libdeps.NAKAMURA Takumi2014-07-147-0/+14
| | | | llvm-svn: 212920
* [CMake] Reorder libdeps by alphabetical order.NAKAMURA Takumi2014-07-141-1/+1
| | | | llvm-svn: 212919
* Fixed compilation errors in tests, enforce checking for errors in ↵Alexander Kornienko2014-07-123-8/+16
| | | | | | | | | | | | | | check_clang_tidy_fix.sh. Reviewers: sbenza, djasper Reviewed By: djasper Subscribers: cfe-commits Differential Revision: http://reviews.llvm.org/D4480 llvm-svn: 212876
* Modify the tests to use FileCheck -implicit-check-not option being proposed ↵Alexander Kornienko2014-07-114-14/+13
| | | | | | | | | | | | | | in D4462 Reviewers: djasper, sbenza, bkramer Reviewed By: bkramer Subscribers: cfe-commits Differential Revision: http://reviews.llvm.org/D4463 llvm-svn: 212814
* Fixed the test to work with -implicit-check-not.Alexander Kornienko2014-07-111-5/+3
| | | | llvm-svn: 212811
* [clang-tidy] Add a checker for implicit bool conversion of a bool*.Benjamin Kramer2014-07-115-0/+195
| | | | | | | | | | | | | | | | | 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
* [doc] Fix incorrect reference to clang-format -> clang-tidyTobias Grosser2014-07-101-1/+1
| | | | llvm-svn: 212755
* Removed the "-fix" suffix from tests that verify both fixes and messages.Alexander Kornienko2014-07-092-0/+0
| | | | llvm-svn: 212658
* Check messages and fixes in the same test.Alexander Kornienko2014-07-097-202/+177
| | | | | | | | | | | | | | Summary: This reduces duplication of test code and improves locality of checks. Reviewers: sbenza, djasper Reviewed By: sbenza, djasper Subscribers: cfe-commits Differential Revision: http://reviews.llvm.org/D4437 llvm-svn: 212653
* Delete removed formatting option.Daniel Jasper2014-07-091-1/+0
| | | | llvm-svn: 212593
* As funny as it might look, this wasn't what I intended to test.Benjamin Kramer2014-07-081-3/+3
| | | | llvm-svn: 212549
OpenPOWER on IntegriCloud