Commit Graph

728 Commits

Author SHA1 Message Date
Alexander Kornienko f5a57c9c24 Clang-tidy google-readability-function check: don't warn on gmock
testing::Unused parameters.

Reviewers: bkramer, klimek

Reviewed By: klimek

Subscribers: curdeius, cfe-commits

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

llvm-svn: 218443
2014-09-25 08:16:24 +00:00
Alexander Kornienko e995154ac2 Provide user name in ClangTidyOptions.
Summary:
This adds the ClangTidyOptions::User field and fills it from the USER
or the USERNAME environment variable, if possible. The FileOptionsProvider now
takes "default" options instead of "fallback" options, as it now uses these when
an option is not set in the configuration file (one exception is the checks
list).

Reviewers: bkramer, klimek

Reviewed By: klimek

Subscribers: cfe-commits

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

llvm-svn: 218402
2014-09-24 18:36:03 +00:00
Benjamin Kramer 39e40cccc6 Drop superfluous semicolon. GCC's -pedantic warns about this.
llvm-svn: 218310
2014-09-23 14:46:55 +00:00
NAKAMURA Takumi 9e0d592838 ClangTidyTests: Add dependency on clangTidyUtils.
I missed to add it since I suppressed checks on win32 in r215590.

llvm-svn: 218289
2014-09-23 00:53:38 +00:00
Benjamin Kramer d15514a8bd Try to pacify dash-using linux distros with a very old-school shell variable compare.
While there fix the cmake shared build.

llvm-svn: 218274
2014-09-22 21:01:04 +00:00
Alexander Kornienko 451567ac43 Add missing dependency.
llvm-svn: 218249
2014-09-22 14:56:43 +00:00
Alexander Kornienko 33fc3db9a1 Add NamespaceCommentCheck to the Google module.
Summary:
This uses a bit hacky way to set the defaults for the spaces before
comments, but it's also one of the simplest ways. Fixed a bug with how the
SpacesBeforeComments option was used.

Reviewers: djasper

Reviewed By: djasper

Subscribers: cfe-commits

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

llvm-svn: 218240
2014-09-22 10:41:39 +00:00
NAKAMURA Takumi 52002ee5bb ClangRenameTests: Prune redundant libdeps.
llvm-svn: 218235
2014-09-22 05:45:11 +00:00
NAKAMURA Takumi 44a3731281 Add newline at eof.
llvm-svn: 218234
2014-09-22 05:45:01 +00:00
Alexander Kornienko f73fe3a04e run-clang-tidy.py: don't fail when running without -checks=.
llvm-svn: 218227
2014-09-22 00:07:07 +00:00
Alexander Kornienko 02bd018aeb Disable most of the google-readability-casting check for non-C++ files (only
leave the "redundant cast to the same type" part).

llvm-svn: 218225
2014-09-21 23:39:28 +00:00
Hans Wennborg dfd8c74a98 [clang-tidy] Don't leak the TodoCommentHandler object
Preprocessor:addCommentHandler() does not take ownership,
so we'd end up leaking the TodoCommentHandler.

This patch makes it owned by the Check object.

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

llvm-svn: 218068
2014-09-18 18:59:50 +00:00
Benjamin Kramer 6be414da26 [clang-tidy] Add a checker that warns on TODO comments without username.
It also suggests a fix-it, taking the name from $USER. This will be made
configurable eventually.

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

llvm-svn: 218049
2014-09-18 12:53:13 +00:00
Benjamin Kramer ebdf90ca00 Make a variable local so it's lifetime becomes more obvious.
NFC

llvm-svn: 217952
2014-09-17 13:12:51 +00:00
Benjamin Kramer ae8fc52237 [clang-tidy] Don't emit the same fixit multiple times.
If we had many header files we would attach the fix-it for all files to all
warnings, oops. This is harmless 99.9% of the time but can confuse the rewriter
in some edge cases. Sadly I failed to create a small test case for this.

While there move fix-its instead of copying.

llvm-svn: 217951
2014-09-17 11:48:34 +00:00
Benjamin Kramer 31a1024b93 Rename unit test argument and add argument comments for clarity.
NFC

llvm-svn: 217947
2014-09-17 09:05:07 +00:00
Benjamin Kramer eb213cb1cd [clang-tidy] When emitting header guard fixes bundle all fix-its into one
warning.

Before we would emit two warnings if the header guard was wrong and the comment
on a trailing #endif also needed fixing.

llvm-svn: 217890
2014-09-16 17:41:19 +00:00
Benjamin Kramer 6e195426e7 [clang-tidy] Add a checker for long functions.
As this is very dependent on the code base it has some ways of configuration.
It's possible to pick between 3 modes of operation:

- Line counting: number of lines including whitespace and comments
- Statement counting: number of statements within compoundStmts.
- Branch counter

In addition a threshold can be picked, warnings are only emitted when it is met.
The thresholds can be configured via a .clang-tidy file.

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

llvm-svn: 217768
2014-09-15 12:48:25 +00:00
Alexander Kornienko 6e0cbc8947 Implemented clang-tidy-check-specific options.
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
2014-09-12 08:53:36 +00:00
Alexander Kornienko c28c32ddc7 Moved main() to the clang::tidy namespace, no functional changes.
llvm-svn: 217493
2014-09-10 11:43:09 +00:00
Alexander Kornienko d3fdcf89ef std::function-ize ClangTidyCheckFactories.
Reviewers: djasper

Reviewed By: djasper

Subscribers: cfe-commits

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

llvm-svn: 217492
2014-09-10 11:25:43 +00:00
Alexander Kornienko be8c143dd6 Unique-ptrify ClangTidyCheckFactories. Add a more convenient alternative to
addCheckFactory: registerCheck.

Reviewers: djasper

Reviewed By: djasper

Subscribers: cfe-commits

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

llvm-svn: 217489
2014-09-10 11:06:43 +00:00
Benjamin Kramer ad335cf690 [clang-tidy] Don't try to fix header guard #endif comments if there are escaped
newlines involved.

Getting that right is just not worth it.

llvm-svn: 217480
2014-09-10 08:48:30 +00:00
Craig Topper 775862a277 Unique_ptrify PPCallbacks ownership. Goes with clang r217474.
llvm-svn: 217475
2014-09-10 05:07:57 +00:00
Benjamin Kramer 91ea478d7c clang-apply-replacements: For-rangify.
No functionality change.

llvm-svn: 217442
2014-09-09 14:09:48 +00:00
Benjamin Kramer ab7cefc36b clang-apply-replacements: Deduplicate paths with FileManager.
Bucket replacements by FileEntry instead of path. The same file with
different paths is very common, relative #include paths and symlinks can
easily create them. When that occurs we would apply the fix twice.

llvm-svn: 217440
2014-09-09 13:53:51 +00:00
Alexander Kornienko 09d811c575 Fixed a typo.
llvm-svn: 217377
2014-09-08 15:04:35 +00:00
Benjamin Kramer 815dbadb16 run-clang-tidy: Make clang-tidy path configurable and don't fail as horribly
when it's not around.

llvm-svn: 217374
2014-09-08 14:56:40 +00:00
Benjamin Kramer 13460075b3 [clang-tidy] Add a couple of paragraphs on run-clang-tidy.py to the docs.
Happy tidying.

llvm-svn: 217373
2014-09-08 14:56:37 +00:00
Benjamin Kramer 044ade8549 Move clang-tools-extra docs 1.5 years into the future.
llvm-svn: 217369
2014-09-08 14:04:49 +00:00
Benjamin Kramer a9d9a4d55a [clang-tidy] Add a little python script that can run clang-tidy and apply fixes over an entire codebase.
Ever wanted to fix all the header guards in clang? Now it's easy.
  Make sure clang-tidy is in $PATH and a compilation database is available.
  $ ./run-clang-tidy.py -checks=-*,llvm-header-guard -fix
  ... get coffee (or more CPU cores) ...
  $ svn diff

Some may argue that this is just a glorified xargs -P, but it does a bit more ;)

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

llvm-svn: 217368
2014-09-08 14:01:31 +00:00
Hans Wennborg fece4c6cd5 Try to make VS 2012 happy after r217155
It was failing with:

C:\bb-win7\ninja-clang-i686-msc17-R\llvm-project\llvm\include\llvm/Support/ErrorOr.h(102) : error C3861: 'make_error_code': identifier not found

        C:\bb-win7\ninja-clang-i686-msc17-R\llvm-project\clang-tools-extra\clang-tidy\ClangTidyOptions.cpp(153) : see reference to function template instantiation 'llvm::ErrorOr<T>::ErrorOr<std::errc::errc>(E,void *)' being compiled

        with
        [
            T=clang::tidy::ClangTidyOptions,
            E=std::errc::errc
        ]

llvm-svn: 217201
2014-09-04 22:41:03 +00:00
Alexander Kornienko 4153da2264 Don't write files with no fixes.
llvm-svn: 217163
2014-09-04 15:19:49 +00:00
Benjamin Kramer 4e3f971f58 Plug a unit test memory leak.
MatchFinder.addMatcher doesn't take ownership.

llvm-svn: 217162
2014-09-04 15:15:27 +00:00
Alexander Kornienko d53d2686b3 Implemented clang-tidy configurability via .clang-tidy files.
Summary:
This adds a support for the .clang-tidy file reading using
FileOptionsProvider, -dump-config option, and changes tests to not depend on
default checks set.

Reviewers: klimek, bkramer, djasper

Reviewed By: djasper

Subscribers: cfe-commits

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

llvm-svn: 217155
2014-09-04 14:23:36 +00:00
Benjamin Kramer fb98b74f8e [clang-tidy] Add an option to export suggested fixes into a file.
Allows gathering fixes and applying them with clang-apply-fixes.

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

llvm-svn: 217139
2014-09-04 10:31:23 +00:00
Alexander Kornienko 805b44d124 ClangTidy misc-argument-comment check: don't check arguments to template
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
2014-09-03 14:56:30 +00:00
Benjamin Kramer 6bcbe6e04d [clang-tidy] Eliminate inline copies of InTemplateInstantiation matcher.
llvm-svn: 217036
2014-09-03 13:30:28 +00:00
Benjamin Kramer b7f59d6bbd [clang-tidy] Use new ASTMatchers to identify template instantiations instead of copying it everywhere.
No intended functionality change.

llvm-svn: 217035
2014-09-03 13:21:51 +00:00
Benjamin Kramer 3500845f07 Remove unused AST matcher.
llvm-svn: 216901
2014-09-02 09:46:43 +00:00
Benjamin Kramer fec6705db0 [clang-tidy] Don't suggest naming the dummy argument of a post-inc operator overload.
llvm-svn: 216868
2014-09-01 09:11:48 +00:00
Benjamin Kramer 041c138ba5 Try to fix test on msvc and 32 bit hosts.
llvm-svn: 216727
2014-08-29 14:47:30 +00:00
Benjamin Kramer 06e323a6ee [clang-tidy] Add a checker that suggests replacing short/long/long long with fixed-size types.
Differential Revision: http://reviews.llvm.org/D5119

llvm-svn: 216726
2014-08-29 14:38:46 +00:00
Benjamin Kramer e59cd6e6ff [clang-tidy] Don't suggest naming unnamed parameters on deleted/defaulted functions.
llvm-svn: 216718
2014-08-29 08:58:35 +00:00
Craig Topper ae926ad24d Remove call to llvm::makeArrayRef. Implicit conversion is sufficient.
llvm-svn: 216711
2014-08-29 06:05:20 +00:00
David Blaikie 715c98aeec Update for Clang API change.
llvm-svn: 216615
2014-08-27 20:54:50 +00:00
Rafael Espindola 7fa030330c Update for LLVM api change.
llvm-svn: 216584
2014-08-27 20:03:22 +00:00
Ted Kremenek 4d1692f613 Adjust call 'CreateAnalysisConsumer' due to API tweak.
llvm-svn: 216551
2014-08-27 15:14:47 +00:00
Craig Topper 2f020e5497 Simplify creation of a couple ArrayRefs by using None and makeArrayRef.
llvm-svn: 216529
2014-08-27 06:29:07 +00:00
Benjamin Kramer d5fef8198b [clang-tidy] If we're going to change the header guard in the #endif comment
we can also fix the original header guard.

We still allow an _ at the end of a header guard since it's so common, but
remove it now when the #endif comment is changed.

llvm-svn: 216462
2014-08-26 16:28:35 +00:00