Commit Graph

61 Commits

Author SHA1 Message Date
Eric Liu 267034ca9c Changes related to new implementation of tooling::Replacements as class.
Summary: See http://reviews.llvm.org/D21748 for details.

Reviewers: djasper, klimek

Subscribers: cfe-commits

Differential Revision: https://reviews.llvm.org/D21749

llvm-svn: 277336
2016-08-01 10:16:39 +00:00
Justin Lebar 41e9dad437 [Typo police] s/proccess/process/, s/auxiliary/auxilliary/.
llvm-svn: 277113
2016-07-29 05:26:58 +00:00
Benjamin Kramer 7035cbf8eb [clang-tidy] Avoid duplicated DenseMap lookup.
The std::string is still constructed on demand. No functionality change
intended.

llvm-svn: 276282
2016-07-21 14:13:45 +00:00
Alexander Kornienko 5d08bb72d9 [clang-tidy] Switch to a more common way of customizing check behavior.
This should have been done this way from the start, however I somehow missed
r257177.

llvm-svn: 270215
2016-05-20 13:42:40 +00:00
Alexander Kornienko dbefbdb6d1 [clang-tidy] Apply NOLINT filtering to Clang warnings.
llvm-svn: 268555
2016-05-04 21:18:31 +00:00
Haojian Wu f7692a2792 [clang-tidy] Fix a crash issue when clang-tidy runs with compilation database.
Summary:
The clang-tidy will trigger an assertion if it's not in the building directory.

TEST:
cd <llvm-repo>/
./build/bin/clang-tidy --checks=-*,modernize-use-nullptr -p build tools/clang/tools/extra/clang-tidy/ClangTidy.cpp

The crash issue is gone after applying this patch.

Fixes PR24834, PR26241

Reviewers: bkramer, alexfh

Subscribers: rizsotto.mailinglist, cfe-commits

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

llvm-svn: 261991
2016-02-26 09:19:33 +00:00
Alexander Kornienko 1612fa07d3 Add a new check, readability-redundant-string-init, that checks unnecessary string initializations.
Reviewers: hokein, alexfh

Subscribers: cfe-commits

Patch by Shuai Wang!

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

llvm-svn: 261939
2016-02-25 23:57:23 +00:00
Alexander Kornienko 33c2494b69 [clang-tidy] Fix a copy-paste error.
llvm-svn: 257900
2016-01-15 16:16:47 +00:00
Jonathan Roelofs d60388a985 Teach clang-tidy how to upgrade warnings into errors.
Similar in format to the `-checks=` argument, this new `-warnings-as-errors=`
argument upgrades any warnings emitted by the former to errors.

http://reviews.llvm.org/D15528

llvm-svn: 257642
2016-01-13 17:36:41 +00:00
Aaron Ballman c00ad6c5fb Disable part of the misc-move-constructor-init checker when the check is enabled through cert-oop11-cpp. The CERT guideline does not cover moveable parameters as part of the OOP11-CPP recommendation, just copy construction from move constructors.
llvm-svn: 257177
2016-01-08 15:50:51 +00:00
Alexander Kornienko 58fe57a92b [clang-tidy] Test commit (playing with git-svn)
llvm-svn: 253203
2015-11-16 13:06:15 +00:00
Alexander Kornienko 64956b5e9a Add ExtraArgs and ExtraArgsBefore options to enable clang warnings via configuration files.
Summary: This patch depends on http://reviews.llvm.org/D14191

Reviewers: djasper, klimek

Subscribers: cfe-commits

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

llvm-svn: 252485
2015-11-09 16:28:11 +00:00
Angel Garcia Gomez 2918904673 Replacements in different files do not overlap.
Summary: Prevent clang-tidy from discarding fixes that are in different files but happen to have the same file offset.

Reviewers: klimek, bkramer

Subscribers: bkramer, alexfh, cfe-commits

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

llvm-svn: 250523
2015-10-16 16:15:27 +00:00
Benjamin Kramer 1487a3de40 Empty undefined static variable -> local variable.
Resolves a -Wundefined-internal warning from clang.

llvm-svn: 250510
2015-10-16 12:11:15 +00:00
Angel Garcia Gomez 166935764b Fix overlapping replacements in clang-tidy.
Summary: Prevent clang-tidy from applying fixes to errors that overlap with other errors' fixes, with one exception: if one fix is completely contained inside another one, then we can apply the big one.

Reviewers: bkramer, klimek

Subscribers: djasper, cfe-commits, alexfh

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

llvm-svn: 250509
2015-10-16 11:43:49 +00:00
Alexander Kornienko c7a6b40d10 [clang-tidy] Ignore spaces in -checks=
llvm-svn: 247812
2015-09-16 16:16:53 +00:00
Marek Kurdej 099227a270 Test commit.
llvm-svn: 247536
2015-09-14 08:05:12 +00:00
Aaron Ballman f36a425eba Reapplying r246209, which exposed language options to the checkers. This time disable UseNullptrCheck when not compiling in C++ mode, but still allow in C++11 mode since it's likely the user wishes to modernize their code.
llvm-svn: 246298
2015-08-28 13:20:46 +00:00
Aaron Ballman 46c9ae3578 Reverting r246209 while I investigate a build bot failure: http://lab.llvm.org:8011/builders/clang-x86_64-debian-fast/builds/30516
llvm-svn: 246224
2015-08-27 22:19:50 +00:00
Aaron Ballman ed916fa458 Expose language options to the checkers; disable UseNullptrCheck when not compiling in C++11 mode.
llvm-svn: 246209
2015-08-27 21:17:47 +00:00
Daniel Jasper 4d871f99c7 Lazily initialize HeaderFilter in ClangTidyDiagnosticConsumer. This
removes a corner case in tests that don't set the diagnostic consumer.
In tests, it is good, not to set the diagnostic consumer so that Clang's
parsing diagnostics are still displayed in the test output and only
ClangTidy's output is analyzed differently.

llvm-svn: 244745
2015-08-12 13:16:41 +00:00
Alexander Kornienko fc1dafba60 [clang-tidy] Count errors in ClangTidyDiagnosticConsumer
This re-applies r222363 reverted in r222390 after compilation errors in our
out-of-tree clang-tidy tests were fixed.

llvm-svn: 222427
2014-11-20 12:05:51 +00:00
Hans Wennborg b4986e5a44 Revert r222363: "[clang-tidy] Count errors in ClangTidyDiagnosticConsumer"
This was causing clang-tidy invocations that would previously pass despite
source errors to fail.

llvm-svn: 222390
2014-11-19 22:02:11 +00:00
Alexander Kornienko efa443429d [clang-tidy] Count errors in ClangTidyDiagnosticConsumer
llvm-svn: 222363
2014-11-19 16:07:26 +00:00
Alexander Kornienko 37f7abe424 [clang-tidy] Added -system-headers option.
Added -system-headers option to allow display of warnings from system headers.
This is needed for testing libcxx, for example.

llvm-svn: 220826
2014-10-28 22:16:13 +00:00
Samuel Benzaquen aedd994560 Add flag --enable-check-profile to clang-tidy.
Summary:
Add flag --enable-check-profile to clang-tidy.
It turns on per-matcher profiles in MatchFinder and prints a report to
stderr at the end.

Reviewers: alexfh

Subscribers: curdeius, cfe-commits

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

llvm-svn: 220491
2014-10-23 17:23:20 +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
Alexander Kornienko b3d331d18d Rename ChecksFilter to GlobList, as there's nothing specific to checks in it.
Summary:
Rename ChecksFilter to GlobList, as there's nothing specific to checks in it.
It's a rather generic way to represent sets of strings (or patterns), so it may
be used for something else in ClangTidy. The new name would not look strange
when used to filter other entities.

Reviewers: klimek

Reviewed By: klimek

Subscribers: cfe-commits

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

llvm-svn: 214961
2014-08-06 11:49:10 +00:00
Alexander Kornienko ad21688625 Set up clang-tidy diagnostic consumer to print types etc.
Reviewers: bkramer

Reviewed By: bkramer

Subscribers: cfe-commits

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

llvm-svn: 212941
2014-07-14 14:10:03 +00:00
Alexander Kornienko 742790cd9f Consistently handle clang-tidy check names in ClangTidyError.
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
2014-07-02 15:05:04 +00:00
Alexander Kornienko 94a656477d Initialize ClangTidyMessage::FileOffset field to avoid unitialized variable access when sorting errors on output.
llvm-svn: 212042
2014-06-30 14:29:03 +00:00
Alp Toker b5fbfa2bab Track changes from clang r211448.
llvm-svn: 211450
2014-06-21 23:33:00 +00:00
Alexander Kornienko a46952221e Allow per-file clang-tidy options.
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
2014-06-05 13:31:45 +00:00
Alexander Kornienko 348cae8e2b Never filter-out compile errors in clang-tidy, display them as errors.
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
2014-06-02 20:44:32 +00:00
Alexander Kornienko e1f62eca2d Update the code according to the changes in r209468.
llvm-svn: 209470
2014-05-22 20:19:46 +00:00
Alexander Kornienko dad4acbc52 Add clang-tidy -line-filter option to filter findings by line ranges.
Summary:
This is going to be used for a clang-tidy-diff script to display
warnings in changed lines only. The option uses JSON, as its value is not
intended to be entered manually.

Reviewers: klimek

Reviewed By: klimek

Subscribers: cfe-commits

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

llvm-svn: 209450
2014-05-22 16:07:11 +00:00
Alexander Kornienko 6262d2349c Fixed incorrect StringRef::find usage.
llvm-svn: 208898
2014-05-15 15:56:58 +00:00
Alexander Kornienko 23fe95904c Change the behavior of clang-tidy -checks=, remove -disable-checks.
Summary:
Make checks filtering more intuitive and easy to use. Remove
-disable-checks and change the format of -checks= to a comma-separated list of
globs with optional '-' prefix to denote exclusion. The -checks= option is now
cumulative, so it modifies defaults, not overrides them. Each glob adds or
removes to the current set of checks, so the filter can be refined or overriden
by adding globs.

Example:
  The default value for -checks= is
  '*,-clang-analyzer-alpha*,-llvm-include-order,-llvm-namespace-comment,-google-*',
  which allows all checks except for the ones named clang-analyzer-alpha* and
  others specified with the leading '-'. To allow all google-* checks one can
  write:
    clang-tidy -checks=google-* ...
  If one needs only google-* checks, we first need to remove everything (-*):
    clang-tidy -checks=-*,google-*
  etc.

I'm not sure if we need to change something here, so I didn't touch the docs
yet.

Reviewers: klimek, alexfh

Reviewed By: alexfh

Subscribers: cfe-commits

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

llvm-svn: 208883
2014-05-15 14:27:36 +00:00
Benjamin Kramer 281f9d0e97 Update for Clang API change and move ClangTidyDiagnosticRenderer into an anonymous namespace while there.
llvm-svn: 208471
2014-05-10 16:32:07 +00:00
Alexander Kornienko 826b5adb6c Store Errors inside ClangTidyContext instead of just pointer to an external
array. This simplifies usage of ClangTidyContext a bit and seems to be more
consistent.

Reviewers: klimek

Reviewed By: klimek

Subscribers: cfe-commits

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

llvm-svn: 208407
2014-05-09 12:24:09 +00:00
Alexander Kornienko 5d174547a9 Print stats on displayed and ignored warnings.
Summary:
Also displays a hint to use -header-filter='.*' in case any warnings
are in non-user code. This will help discoverability of this option.

Reviewers: klimek

Reviewed By: klimek

Subscribers: cfe-commits

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

llvm-svn: 208174
2014-05-07 09:06:53 +00:00
Alexander Kornienko 238795e9c6 Fix a crash when diagnostic points to a macro definition on command line.
Reviewers: klimek

Reviewed By: klimek

Subscribers: cfe-commits

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

llvm-svn: 208068
2014-05-06 08:10:00 +00:00
Alexander Kornienko 9ff5b6f3ca Add clang-tidy -header-filter option
Summary:
Add clang-tidy -header-filter option to specify from which headers we
want diagnostics to be printed. By default we don't print diagnostics from
headers. We always print diagnostics from the main file of each translation
unit.

Reviewers: djasper, klimek

Reviewed By: klimek

Subscribers: klimek, cfe-commits

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

llvm-svn: 207970
2014-05-05 14:54:47 +00:00
Alexander Kornienko 33a9bcce29 Add ClangTidyOptions to encapsulate all clang-tidy options.
Reviewers: djasper

Reviewed By: djasper

Subscribers: cfe-commits

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

llvm-svn: 207532
2014-04-29 15:20:10 +00:00
Alexander Kornienko 9eb8c92b52 Output clang-tidy errors in a consistent order.
Summary: Sort errors by path, file offset and message.

Reviewers: djasper, klimek

Reviewed By: djasper

CC: cfe-commits

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

llvm-svn: 205759
2014-04-08 12:27:49 +00:00
NAKAMURA Takumi 338eee1964 ClangTidyContext: Don't use initializer on non-static member.
llvm-svn: 204333
2014-03-20 10:53:03 +00:00
Alexander Kornienko 09952d2d71 Post-filter clang-tidy diagnostic messages.
Summary:
This patch implements filtering of clang-tidy diagnostic messages by
the check name, so that "clang-tidy -checks=^llvm-" won't output any clang
warnings, for example. This is also helpful to run specific static-analyzer
checks: static analyzer always needs core checks to be enabled, but the user may
be interested only in the checks he asked for.

This patch also exposes warning option names for built-in diagnostics. We need
to have a namespace for these names to avoid collisions and to allow convenient
filtering, so I prefix them with "-W". I'm not sure it's the best thing to do,
and maybe "W" or "clang-diagnostic-" or something like this would be better.

Reviewers: klimek

Reviewed By: klimek

CC: cfe-commits

Differential Revision: http://llvm-reviews.chandlerc.com/D3121

llvm-svn: 204321
2014-03-20 09:38:22 +00:00
Alexander Kornienko 6fbc619ab9 Use DiagnosticRenderer to convert clang diagnostics to clang-tidy ones.
Summary:
This is immediately useful for generating macro expansion notes, and
may be useful for other things later on.

Reviewers: klimek, djasper

Reviewed By: klimek

CC: cfe-commits

Differential Revision: http://llvm-reviews.chandlerc.com/D2950

llvm-svn: 203457
2014-03-10 13:11:17 +00:00
Alexander Kornienko 33a0bce133 Deduplicate clang-tidy error messages by file, offset and message.
Summary: Peter, I guess, this can help you in testing your check.

Reviewers: djasper, pcc, klimek

Reviewed By: klimek

CC: cfe-commits

Differential Revision: http://llvm-reviews.chandlerc.com/D2989

llvm-svn: 203451
2014-03-10 09:45:49 +00:00
Alexander Kornienko df1e3cb157 Use range-based for loops for better readability. No functional changes intended.
Reviewers: chandlerc

Reviewed By: chandlerc

CC: cfe-commits

Differential Revision: http://llvm-reviews.chandlerc.com/D2979

llvm-svn: 203101
2014-03-06 10:17:46 +00:00