Commit Graph

424 Commits

Author SHA1 Message Date
Aaron Ballman 7fc9feac3e Change the test to use the new python script instead of the more verbose RUN line.
llvm-svn: 245600
2015-08-20 19:21:07 +00:00
Alexander Kornienko 43556bb7f0 [clang-tidy] Use a python script instead of a shell script to run clang-tidy tests.
Summary:
Add check_clang_tidy.py script that is functionally identical to the
check_clang_tidy.py, but should also be functional on windows.

I've verified that the script works on linux. Would be nice if folks using
Windows could test the patch before I break windows bots ;)

Reviewers: chapuni, aaron.ballman

Subscribers: cfe-commits

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

llvm-svn: 245583
2015-08-20 17:58:07 +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
NAKAMURA Takumi ae6b329c8f Tweak clang-tidy-diff.py to pass JSON argument correctly to clang-tidy on win32 arg parser.
- Single quotation is not recognized.
  - Use """ to pass a double quotation.

It also reverts r211831.

llvm-svn: 245567
2015-08-20 15:04:46 +00:00
NAKAMURA Takumi 1544a819b7 Tweak clang-tools-extra/test/clang-tidy/file-filter.cpp to pass on win32.
FIXME: "-I %S/Inputs/file-filter/system/.." must be redundant.
On Win32, file-filter/system\system-header1.h precedes file-filter\header*.h due to code order between '/' and '\\'.

We should remove such a tweak to introduce the *right* path canonicalization.

Posix:
  file-filter/header*.h
  file-filter/system/system-header1.h

Win32:
  file-filter/system\system-header1.h
  file-filter\header*.h

Win32, tweaked:
  file-filter/system/..\header*.h
  file-filter/system\system-header1.h

It had been disabled since r220837.

llvm-svn: 245566
2015-08-20 15:04:39 +00:00
NAKAMURA Takumi ba598b5581 clang-tools-extra/test/lit.cfg: Prune an obsolete feature, python27. Now we requires python>=2.7.
clang-tools-extra/test/clang-tidy/clang-tidy-diff.cpp was the only user.

llvm-svn: 245565
2015-08-20 15:04:32 +00:00
Alexander Kornienko 74a44d9133 [clang-tidy] Fix bug in modernize-loop-convert check.
http://reviews.llvm.org/D12186

Patch by Angel Garcia!

llvm-svn: 245561
2015-08-20 13:18:23 +00:00
Alexander Kornienko 20ce95f294 [clang-tidy] Add back a test with a custom NULL macro. Remove redundant default.
llvm-svn: 245533
2015-08-20 01:44:14 +00:00
Alexander Kornienko 1b7bf7a2a7 [clang-tidy] Add modernize-use-nullptr check, attempt 2.
This patch re-applies r245434 and r245471 reverted in r245493, and changes the
way custom null macros are configured. The test for custom null macros is
temporarily excluded and will be committed separately to reduce chances of
breakages.

Initial patches by Angel Garcia.

llvm-svn: 245511
2015-08-19 22:21:37 +00:00
Justin Bogner 71e1a579b2 Revert "[clang-tidy] Add use-nullptr check to clang-tidy."
The new test is failing on darwin:

http://lab.llvm.org:8080/green/job/clang-stage1-configure-RA_check/10339/

This reverts r245434 and its follow up r245471.

llvm-svn: 245493
2015-08-19 20:30:07 +00:00
NAKAMURA Takumi bc224b8049 clang-tools-extra/test/clang-tidy/readability-identifier-naming.cpp: Appease targeting msvc.
llvm-svn: 245435
2015-08-19 13:22:58 +00:00
Alexander Kornienko bd725b4537 [clang-tidy] Add use-nullptr check to clang-tidy.
Move UseNullptr from clang-modernize to modernize module in clang-tidy.

http://reviews.llvm.org/D12081

Patch by Angel Garcia!

llvm-svn: 245434
2015-08-19 13:13:12 +00:00
Alexander Kornienko 76c288062a [clang-tidy] Add new IdentifierNaming check
This check will try to enforce coding guidelines on the identifiers naming.
It supports lower_case, UPPER_CASE, camelBack and CamelCase casing and
tries to convert from one to another if a mismatch is detected.

It also supports a fixed prefix and suffix that will be prepended or appended
to the identifiers, regardless of the casing.

Many configuration options are available, in order to be able to create
different rules for different kind of identifier. In general, the
rules are falling back to a more generic rule if the specific case is not
configured.

http://reviews.llvm.org/D10933

Patch by Beren Minor!

llvm-svn: 245429
2015-08-19 11:15:36 +00:00
Alexander Kornienko 0497084b69 [clang-tidy] Add loop-convert check to clang-tidy.
Move LoopConvert from clang-modernize to modernize module in clang-tidy.

http://reviews.llvm.org/D12076

Patch by Angel Garcia!

llvm-svn: 245427
2015-08-19 09:11:46 +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 65eccb463d [clang-tidy] Allow use of -list-checks option without need to pass source files.
Initialize CommonOptionsParser with ZeroOrOne NumOccurrenceFlag so callers can
pass -list-checks without the need to pass additional positional parameters,
then add dummy file if none were supplied.

http://reviews.llvm.org/D12070

Patch by Don Hinton!

llvm-svn: 245205
2015-08-17 10:03:27 +00:00
NAKAMURA Takumi caad877d3e clang-tools-extra/test/clang-tidy/modernize-pass-by-value.cpp: Tweak not to override -std=c++11.
llvm-svn: 245147
2015-08-15 02:27:22 +00:00
NAKAMURA Takumi 654c2bbaf5 clang-tools-extra/test/clang-tidy/modernize-pass-by-value.cpp: Appease targeting MS to give -fno-delayed-template-parsing.
llvm-svn: 245146
2015-08-15 02:05:49 +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
Alexander Kornienko fc650864ef [clang-tidy] Create clang-tidy module modernize. Add pass-by-value check.
This is the first step for migrating cppmodernize to clang-tidy.

http://reviews.llvm.org/D11946

Patch by Angel Garcia!

llvm-svn: 245045
2015-08-14 13:17:11 +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 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
NAKAMURA Takumi 0dae64a554 Move an extra switch to clang-tools-extra/test/clang-tidy/misc-unused-parameters.cpp from check_clang_tidy.sh.
It also rolls back r242984 and r242985.

llvm-svn: 243491
2015-07-28 22:41:04 +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
Aaron Ballman 6db02dd8f0 Trying again to a failing test the bots found with r243266.
llvm-svn: 243269
2015-07-27 13:59:24 +00:00
Aaron Ballman 84b1b00926 Fixing a failing test the bots found with r243266.
llvm-svn: 243268
2015-07-27 13:47:35 +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
NAKAMURA Takumi 4c8342b73e Fix the shell script check_clang_tidy.sh in r242984.
llvm-svn: 242985
2015-07-23 06:03:40 +00:00
NAKAMURA Takumi d4ed83aae7 Appease test/clang-tidy/misc-unused-parameters.cpp for targeting *-win32, to add -fno-delayed-template-parsing.
Note, clang-tidy tests wouldn't run on Windows hosts since they are disabled with REQUIRES:shell.
The failure would be raised with cross building.

llvm-svn: 242984
2015-07-23 05:52:02 +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
John Thompson 4018c62428 Added mechanism to modularize for doing a compilation precheck
to determine files that have comnpilation or dependency problems.
A new -display-file-lists option use this to display lists of good files
(no compile errors), problem files, and a combined list with
problem files preceded by a '#'.  The problem files list can be
used in the module map generation assistant mode to exclude
problem files.  The combined files list can be used during module
map development.  See added docs.

llvm-svn: 241880
2015-07-10 00:37:25 +00:00
John Thompson 8b629f585d Fixed line-endings.
llvm-svn: 241744
2015-07-08 22:00:56 +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
Alexander Kornienko 6ae400d122 [clang-tidy] Enhance clang-tidy readability-simplify-boolean-expr...
Enhance clang-tidy readability-simplify-boolean-expr to handle 'if (e) return
true; return false;' and improve replacement expressions.

This changeset extends the simplify boolean expression check in clang-tidy to
simplify if (e) return true; return false; to return e; (note the lack of an
else clause on the if statement.) By default, chained conditional assignment is
left unchanged, unless a configuration parameter is set to non-zero to override
this behavior.

It also improves the handling of replacement expressions to apply
static_cast<bool>(expr) when expr is not of type bool.

http://reviews.llvm.org/D9810

Patch by Richard Thomson!

llvm-svn: 241155
2015-07-01 12:39:40 +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
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
Daniel Marjamaki 302275a938 clang-tidy: Add checker that warns about missing parentheses in macros
* calculations in the replacement list should be inside parentheses
* macro arguments should be inside parentheses

llvm-svn: 239820
2015-06-16 14:27:31 +00:00
John Thompson 96f5551b03 Fixed modularize to warn about missing headers referenced in a module map.
llvm-svn: 239122
2015-06-04 23:35:19 +00:00
Szabolcs Sipos 43a298cb36 [clang-tidy] Fix for llvm.org/PR23355
misc-static-assert and misc-assert-side-effect will handle __builtin_expect based asserts correctly.

llvm-svn: 238548
2015-05-29 09:49:59 +00:00
Alexander Kornienko 7ed89bcd3b [clang-tidy] Renamed misc-noexcept-move-ctors to misc-noexcept-move-constructor
llvm-svn: 238326
2015-05-27 14:24:11 +00:00
Alexander Kornienko bf5bd94142 [clang-tidy] misc-noexcept-move-ctors should ignore implicit constructors and assignments.
llvm-svn: 238202
2015-05-26 14:35:09 +00:00
Alexander Kornienko 2b56649cd2 [clang-tidy] Don't issue most google-readability-casting warnings on .c files included in other files.
This is done sometimes for testing purposes, and the check needs to handle this
consistently.

llvm-svn: 238193
2015-05-26 10:47:48 +00:00
Szabolcs Sipos 0acf19ed53 [clang-tidy] Fix for llvm.org/PR23572
misc-static-assert won't report asserts whose conditions contain calls to non constexpr functions.

llvm-svn: 238098
2015-05-23 14:21:01 +00:00