summaryrefslogtreecommitdiffstats
path: root/clang-tools-extra/clang-tidy
Commit message (Collapse)AuthorAgeFilesLines
...
* 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] Fix a false positive in the make_pair checker if an argument ↵Benjamin Kramer2014-07-211-2/+13
| | | | | | | | | 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-172-16/+15
| | | | | | | | | 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-172-15/+16
| | | | llvm-svn: 213308
* [clang-tidy] MemsetZeroLenghtChecker: Don't crash trying to evaluate ↵Benjamin Kramer2014-07-171-2/+4
| | | | | | 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-162-2/+2
| | | | | | 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-161-1/+2
| | | | | | | | | 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-161-4/+8
| | | | | | | 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-164-0/+125
| | | | | | | | | | | | 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-166-0/+166
| | | | | | | | | | 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-161-9/+13
| | | | | | | | | | | | Reviewers: bkramer Reviewed By: bkramer Subscribers: cfe-commits, sbenza Differential Revision: http://reviews.llvm.org/D4534 llvm-svn: 213149
* [clang-tidy] Add a checker that warns on const string & members.Benjamin Kramer2014-07-164-0/+103
| | | | | | | | | | | | | | 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
* [clang-tidy] Add a checker that flags unnamed parameters.Benjamin Kramer2014-07-154-0/+135
| | | | | | | | | | | | | | | | 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] Add a checker that flags all instances of overloaded unary ↵Benjamin Kramer2014-07-154-0/+82
| | | | | | | | | | operator& This handles both methods and freestanding overloads. Differential Revision: http://reviews.llvm.org/D4498 llvm-svn: 213067
* [clang-tidy] Add a checker that removes deducible arguments from std::make_pairBenjamin Kramer2014-07-154-0/+111
| | | | | | | | | | | 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
* [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
* 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-141-10/+92
| | | | | | | | | | | | | | | | | | 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-143-0/+4
| | | | 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] Address review comments for the Twine checker.Benjamin Kramer2014-07-082-3/+1
| | | | | | | | | - Remove unused includes. - Minor wording fix. - Added support to check for clang-tidy messages to check_clang_tidy_fix.sh = Updated test case. llvm-svn: 212540
* [clang-tidy] Add a little checker for Twine locals in LLVM.Benjamin Kramer2014-07-084-0/+100
| | | | | | | | | | | Those often cause use after free bugs and should be generally avoided. Technically it is safe to have a Twine with >=2 components in a variable but I don't think it is a good pattern to follow. The almost trivial checker comes with elaborated fix-it hints that turn the Twine into a std::string if necessary and otherwise fall back to the original type if the Twine is created from a single value. llvm-svn: 212535
* clang-tidy: Instantiate llvm::Registry<clang::tidy::ClangTidyModule>.NAKAMURA Takumi2014-07-032-0/+4
| | | | llvm-svn: 212271
* Consistently handle clang-tidy check names in ClangTidyError.Alexander Kornienko2014-07-022-27/+54
| | | | | | | | | | | | | | | | | | | Summary: This patch removes " [check-name]" from the end of ClangTidyMessage::Message. The " [check-name]" part is only appended when printing diagnostics on the console. Clang errors are now marked with "clang-diagnostic-error" check name, remarks and unknown warnings are marked with "clang-diagnostic-unknown". Reviewers: djasper Reviewed By: djasper Subscribers: cfe-commits Differential Revision: http://reviews.llvm.org/D4356 llvm-svn: 212180
* Initialize ClangTidyMessage::FileOffset field to avoid unitialized variable ↵Alexander Kornienko2014-06-301-1/+2
| | | | | | access when sorting errors on output. llvm-svn: 212042
* Added a comment to document relation of this check to -Wold-style-cast.Alexander Kornienko2014-06-301-0/+4
| | | | llvm-svn: 212033
* Another attempt to add a clang-tidy check for flagging C-style casts.Alexander Kornienko2014-06-294-0/+90
| | | | | | | | | | | | | | | | | | | Summary: The first version failed the SubstNonTypeTempateParmExpr-related test on some buildbots. This one uses the new substNonTypeTempateParmExpr matcher to filter out implicit C-style casts. This patch depends on D4327. Reviewers: djasper Reviewed By: djasper Subscribers: aemerson, cfe-commits Differential Revision: http://reviews.llvm.org/D4328 llvm-svn: 212002
* Make clang-tidy-diff.py py3-compatible.NAKAMURA Takumi2014-06-271-1/+1
| | | | llvm-svn: 211834
* Rolling back, as the test fails on one of the buildbots:Alexander Kornienko2014-06-254-90/+0
| | | | | | http://lab.llvm.org:8011/builders/clang-hexagon-elf/builds/13505/steps/check-all/logs/Clang%20Tools%3A%3Ac-style-casts.cpp llvm-svn: 211708
* Add a check to flag the usage of C-style casts (Google Style).Alexander Kornienko2014-06-254-0/+90
| | | | | | | | | | | | | | | | | Summary: Add a check to flag the usage of C-style casts, as per Google Style Guide: http://google-styleguide.googlecode.com/svn/trunk/cppguide.xml?showone=Casting#Casting Reviewers: djasper Reviewed By: djasper Subscribers: cfe-commits Differential Revision: http://reviews.llvm.org/D4189 llvm-svn: 211702
* Add clang-tidy-diff.py script to run clang-tidy and display warnings on ↵Alexander Kornienko2014-06-251-0/+115
| | | | | | | | | | | | | | changed lines only. Reviewers: djasper Reviewed By: djasper Subscribers: cfe-commits Differential Revision: http://reviews.llvm.org/D4288 llvm-svn: 211698
* Track changes from clang r211448.Alp Toker2014-06-211-4/+0
| | | | llvm-svn: 211450
* clang-tidy: [misc-use-override] Correctly handle defaulted destructors.Daniel Jasper2014-06-201-6/+4
| | | | | | Also, minor implementation and test fixes. llvm-svn: 211345
* Move google-explicit-constructor check to a separate source file.Alexander Kornienko2014-06-184-76/+91
| | | | | | | | | | | | | | Summary: No functional changes. Reviewers: djasper Reviewed By: djasper Subscribers: cfe-commits Differential Revision: http://reviews.llvm.org/D4188 llvm-svn: 211154
* include system_error directly.Rafael Espindola2014-06-121-1/+1
| | | | llvm-svn: 210797
* Replace llvm::error_code with std::error_code.Rafael Espindola2014-06-123-9/+9
| | | | llvm-svn: 210776
* A follow-up to r210260: updated a comment. No functional changes.Alexander Kornienko2014-06-121-2/+2
| | | | llvm-svn: 210767
* 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
* [C++11] Use 'nullptr'.Craig Topper2014-06-091-1/+1
| | | | llvm-svn: 210447
* Allow per-file clang-tidy options.Alexander Kornienko2014-06-059-98/+249
| | | | | | | | | | | | | | | | | | Summary: This patch makes it possible for clang-tidy clients to provide different options for different translation units. The option, which doesn't make sense to be file-dependent, was moved to a separate ClangTidyGlobalOptions struct. Added parsing of ClangTidyOptions. Reviewers: klimek Reviewed By: klimek Subscribers: cfe-commits Differential Revision: http://reviews.llvm.org/D3979 llvm-svn: 210260
* 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
* Never filter-out compile errors in clang-tidy, display them as errors.Alexander Kornienko2014-06-023-6/+24
| | | | | | | | | | | | | | | | | | Summary: No filters should affect the display of errors. Fixed a few tests, which had compile errors. We need to think what we should do with mapped errors (-Werror). Reviewers: klimek Reviewed By: klimek Subscribers: cfe-commits Differential Revision: http://reviews.llvm.org/D3982 llvm-svn: 210044
* Exit with error when no checks enabled.Alexander Kornienko2014-06-021-1/+9
| | | | | | | | | | | | | | | | Summary: This seems like a more appropriate reaction to the user specifying a single check with a wrong name, for example. Reviewers: klimek Reviewed By: klimek Subscribers: cfe-commits Differential Revision: http://reviews.llvm.org/D3981 llvm-svn: 210043
* 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
OpenPOWER on IntegriCloud