Commit Graph

121 Commits

Author SHA1 Message Date
Alexander Kornienko 7bca3db8b9 [clang-tidy] Fix a typo in my latest commit.
llvm-svn: 254074
2015-11-25 16:38:22 +00:00
Alexander Kornienko e4ac60d7bc [clang-tidy] Const std::move() argument ClangTidy check
ClangTidy check for finding cases when std::move() is called with const or
trivially copyable arguments, that doesn't lead to any move or argument but it
makes copy. FixIt generates patch for removing call of std::move().

Patch by Vadym Doroshenko! (+ a couple of minor fixes)

Differential Revision: http://reviews.llvm.org/D12031

llvm-svn: 254070
2015-11-25 15:56:11 +00:00
Daniel Marjamaki 8ade8d2efd [clang-tidy] code cleanup using isAssignmentOp()
llvm-svn: 254066
2015-11-25 11:30:00 +00:00
Samuel Benzaquen b43962768a Fix bug in suggested fix that truncated variable names to 1 character.
Summary:
Fix bug in suggested fix that truncated variable names to 1 character.
Also, rework the suggested fix to try to remove unnecessary whitespace.

Reviewers: alexfh, aaron.ballman

Subscribers: cfe-commits

Differential Revision: http://reviews.llvm.org/D13899

llvm-svn: 252773
2015-11-11 18:40:36 +00:00
Daniel Marjamaki 1e9ef81187 [clang-tidy] misc-macro-parentheses: fix fp when using object member pointers
Fixes http://llvm.org/PR25208.

llvm-svn: 252608
2015-11-10 14:32:25 +00:00
Craig Topper 45857d4b58 Make a bunch of static arrays const.
llvm-svn: 250641
2015-10-18 05:14:41 +00:00
Aaron Ballman 17b6feef69 Expose the clang-tidy misc-assign-operator-signature checker as cppcoreguidelines-c-copy-assignment-signature.
llvm-svn: 250165
2015-10-13 15:24:33 +00:00
Aaron Ballman fd78cc88cf Add a new checker that tests whether a throw expression throws by value, and whether a catch statement catches by reference.
Patch by Tobias Langner!

llvm-svn: 249899
2015-10-09 20:42:44 +00:00
Aaron Ballman b92b47c6ff Attempting to appease the CMake build bots after r249429.
llvm-svn: 249430
2015-10-06 16:32:50 +00:00
Aaron Ballman fc4e042bf5 Improved the misc-move-constructor-init check to identify arguments that are passed by value but copy assigned to class data members when the non-deleted move constructor is a better fit.
Patch by Felix Berger!

llvm-svn: 249429
2015-10-06 16:27:03 +00:00
Aaron Ballman 8db15e4a4d Adding a checker (misc-non-copyable-objects) that detects situations where a non-copyable C type is being dereferenced, such as FILE or pthread_mutex_t. Corresponds to the CERT C++ secure coding rule: https://www.securecoding.cert.org/confluence/display/c/FIO38-C.+Do+not+copy+a+FILE+object
llvm-svn: 248907
2015-09-30 14:09:38 +00:00
Aaron Ballman de34985caa Adding a checker (misc-new-delete-overloads) that detects mismatched overloads of operator new and operator delete. Corresponds to the CERT C++ secure coding rule: https://www.securecoding.cert.org/confluence/display/cplusplus/DCL54-CPP.+Overload+allocation+and+deallocation+functions+as+a+pair+in+the+same+scope
llvm-svn: 248791
2015-09-29 13:12:21 +00:00
Alexander Kornienko 91b53846f7 [clang-tidy] Updated misc-unused-raii documentation.
llvm-svn: 248594
2015-09-25 17:50:11 +00:00
Daniel Jasper f631191305 misc-unused-parameter: Ignore lambda static invokers.
llvm-svn: 248252
2015-09-22 09:20:20 +00:00
Aaron Ballman b9ea09c445 Refactors AST matching code to use the new AST matcher names. This patch correlates to r247885 which performs the AST matcher rename in Clang.
llvm-svn: 247886
2015-09-17 13:31:25 +00:00
Alexander Kornienko 6ae0a630b8 [clang-tidy] misc-sizeof-container: remove fix-it hints
This turned out to be a rather noisy check, so automated fixes will only do
harm. Remove them completely.

llvm-svn: 247578
2015-09-14 16:51:52 +00:00
Alexander Kornienko 4cd7ad9727 [clang-tidy] misc-sizeof-container: whitelist std::array
llvm-svn: 247559
2015-09-14 13:55:29 +00:00
Alexander Kornienko 541de378ce [clang-tidy] misc-sizeof-container: whitelist std::bitset<>.
It's fine to use sizeof on std::bitset<>, since it doesn't have any external
storage, everything's inside.

llvm-svn: 247489
2015-09-11 22:54:44 +00:00
Alexander Kornienko 7532d3e93d [clang-tidy] Add misc-sizeof-container check to find sizeof() uses on stl
containers.

Summary:
sizeof(some_std_string) is likely to be an error. This check finds this
pattern and suggests using .size() instead.

Reviewers: djasper, klimek, aaron.ballman

Subscribers: aaron.ballman, cfe-commits

Differential Revision: http://reviews.llvm.org/D12759

llvm-svn: 247297
2015-09-10 16:37:46 +00:00
Aaron Ballman c0dc76c251 Allow the static assert clang-tidy checker to run over C code.
llvm-svn: 246495
2015-08-31 21:54:42 +00:00
Aaron Ballman bf89109013 Using an early return as it is more clear; NFC.
llvm-svn: 246447
2015-08-31 15:28:57 +00:00
Alexander Kornienko 54f3657448 [clang-tidy] misc-assert-side-effect: support assert macros defined through other macros
llvm-svn: 246446
2015-08-31 14:47:14 +00:00
Aaron Ballman a96b33b1b1 Using an early return as it is more clear; NFC.
llvm-svn: 246444
2015-08-31 14:23:21 +00:00
Alexander Kornienko 0ed6c478a4 [clang-tidy] Move misc-use-override and readability-shrink-to-fit to "modernize/"
These checks are focusing on migrating the code from C++98/03 to C++11, so they
belong to the modernize module.

llvm-svn: 246437
2015-08-31 13:17:43 +00:00
Aaron Ballman ed5e4ef853 Updated to make use of the AST matcher instead of a custom matcher; NFC.
llvm-svn: 246325
2015-08-28 19:40:30 +00:00
Aaron Ballman 327e97bb37 Disable clang-tidy misc checkers when not compiling in C++ mode. Many of the checkers do not require additional testing as the tests will not compile for other languages or modes, or the checkers would never match a valid construct.
llvm-svn: 246318
2015-08-28 19:27:19 +00:00
Alexander Kornienko f8ed0a8d35 [clang-tidy] Update docs for clang-tidy checks. NFC
Changes mostly address formatting and unification of the style. Use
MarkDown style for inline code snippets and lists. Added some text
for a few checks.

The idea is to move most of the documentation out to separate rST files and have
implementation files refer to the corresponding documentation files.

llvm-svn: 246169
2015-08-27 18:01:58 +00:00
Aaron Ballman 9392ced263 Add a new clang-tidy check (misc-move-constructor-init) that diagnoses move constructor initializations that call copy constructors instead of move constructors.
llvm-svn: 245571
2015-08-20 15:52:52 +00:00
Ehsan Akhgari c62c639610 Insert override at the same line as the end of the function declaration
Summary:
The existing check converts the code pattern below:

  void f()
  {
  }

to:

  void f()
  override {
  }

which is fairly sub-optimal.  This patch fixes this by inserting the
override keyword on the same line as the function declaration if
possible, so that we instead get:

  void f() override
  {
  }

We do this by looking for the last token before the start of the body
and inserting the override keyword at the end of its location.  Note
that we handle const, volatile and ref-qualifiers correctly.

Test Plan: Includes an automated test.

Reviewers: alexfh

Subscribers: cfe-commits

Differential Revision: http://reviews.llvm.org/D9286

llvm-svn: 245401
2015-08-19 02:05:37 +00:00
Alexander Kornienko fc8cd685e1 [clang-tidy] Fixed typos and formatting in a comment. NFC
llvm-svn: 245310
2015-08-18 16:43:07 +00:00
Daniel Jasper ea223a7a6a misc-unused-parameters: Fix crasher with C forward declarations that
can leave out the parameter list.

llvm-svn: 245048
2015-08-14 13:39:57 +00:00
Daniel Jasper b3a74c659b misc-unused-parameters: Don't touch K&R style functions.
We couldn't calculate the removal ranges properly at this point.

llvm-svn: 244454
2015-08-10 15:45:46 +00:00
Alexander Kornienko 2644cae3d5 [clang-tidy] Improve the misc-unused-alias-decl message
"this namespace alias decl is unused" -> "namespace alias decl '...' is unused"

llvm-svn: 243906
2015-08-03 22:02:08 +00:00
Daniel Jasper cf452e5501 Replace callback-if with isExpansionInMainFile as suggested in post
commit review.

llvm-svn: 243871
2015-08-03 10:52:27 +00:00
Daniel Jasper 0aeed7c0b8 Add missing 'override'.
llvm-svn: 243773
2015-07-31 18:32:38 +00:00
Daniel Jasper bb42b03021 Add misc-unused-alias-decls check that currently finds unused namespace
alias declarations. In the future, we might want to reuse it to also
fine unsed using declarations and such.

llvm-svn: 243754
2015-07-31 16:08:10 +00:00
Alexander Kornienko b4fbb173f0 [clang-tidy] Support replacements in macro arguments in misc-inefficient-algorithm
Summary:
Support replacements in macro arguments in the
misc-inefficient-algorithm check.

Reviewers: klimek

Subscribers: cfe-commits

Differential Revision: http://reviews.llvm.org/D11677

llvm-svn: 243747
2015-07-31 13:34:58 +00:00
Daniel Jasper 542482e63d misc-unused-parameters: Only remove parameters in the main source file.
In headers, they might always be pulled in to different TUs, even if
they are declared static or nested in an unnamed namespace.

llvm-svn: 243414
2015-07-28 13:19:12 +00:00
Daniel Jasper 718029ba6b misc-unused-parameters: Properly handle static class members.
Not sure why I wrote what I wrote before.

llvm-svn: 243403
2015-07-28 10:39:25 +00:00
Daniel Jasper 9fe55a32b7 misc-unused-parameters: Don't warn on ParmVarDecls in the return type.
As there don't seem to be a good way of formulating a matcher that
finds all pairs of functions and their ParmVarDecls, just match on
functionDecls and iterate over their parameters. This should also be
more efficient as some checks are only performed once per function.

llvm-svn: 243267
2015-07-27 13:46:37 +00:00
Daniel Jasper 1c6fc3b8f0 misc-unused-parameters: Fix bug where the check was looking at
ParmVarDecls of function types.

llvm-svn: 243026
2015-07-23 17:26:36 +00:00
Daniel Jasper 9b46e9c5de misc-unused-parameters: Fix handling of parameters in template functions.
The parameters of the function templates were being marked as
incorrectly be marked as unused. Added a test for this and changed the
check to use the same

  isReferenced() || !getDeclName()

logic as Sema::DiagnoseUnusedParameters.
Patch Scott Wallace, thank you!

llvm-svn: 242912
2015-07-22 17:30:35 +00:00
Daniel Jasper 82efabbb27 Extend misc-unused-parameters to delete parameters of local functions.
Also see: llvm.org/PR24180.

llvm-svn: 242659
2015-07-20 03:42:38 +00:00
Daniel Jasper 9c6df889c4 Initial version of clang-tidy check to find and fix unused parameters.
Also see: llvm.org/PR24180.

llvm-svn: 242654
2015-07-20 01:06:44 +00:00
Daniel Marjamaki e0384e51b0 [clang-tidy] Enhance clang-tidy misc-macro-repeated-side-effects...
Enhance clang-tidy misc-macro-repeated-side-effects to handle ? and : better.

When ? is used in a macro, there are 2 possible control flow paths through the macro.
These paths are tracked separately so problems can be detected properly.

http://reviews.llvm.org/D10653

llvm-svn: 241245
2015-07-02 07:49:55 +00:00
Daniel Marjamaki bf5e59c78b [clang-tidy] minor coding style tweak. make functions static.
llvm-svn: 241160
2015-07-01 13:29:27 +00:00
Daniel Marjamaki 4a38b0b493 [clang-tidy] Fix false positives in the macro parentheses checker
Summary:
There were false positives in C++ code where macro argument was a type.

Reviewers: alexfh

Differential Revision: http://reviews.llvm.org/D10801

llvm-svn: 240938
2015-06-29 12:18:11 +00:00
Daniel Marjamaki 91d35a5e22 [clang-tidy] Fix false positives in misc-macro-parentheses checker
llvm-svn: 240399
2015-06-23 12:45:14 +00:00
Justin Bogner 7b92cac037 clang-tidy: Remove an unused private field. NFC
Clang was warning on this.

llvm-svn: 239988
2015-06-18 04:15:04 +00:00
Daniel Marjamaki 71c9257f07 clang-tidy: Add checker that warn when macro argument with side effects is repeated in the macro
llvm-svn: 239909
2015-06-17 14:19:35 +00:00