Commit Graph

56 Commits

Author SHA1 Message Date
Benjamin Kramer e71037123b Make helpers static. clang-tools edition.
Also purge dead code found by it. NFC.

llvm-svn: 232948
2015-03-23 12:49:15 +00:00
NAKAMURA Takumi 0c1e8452cc Add clangBasic to libdeps according to r232051 since the interface of ASTMatchers was changed.
llvm-svn: 232138
2015-03-13 03:47:43 +00:00
Adrian Prantl b97f5c1eb2 Revert "Adapt clang-tools-extra to clang module format changes."
This reverts commit 230424.

llvm-svn: 230456
2015-02-25 02:46:37 +00:00
Adrian Prantl e95edbf5a9 Adapt clang-tools-extra to clang module format changes.
- add clangCodeGen.a to the tools that need it
- tweak pp-trace command line handling to not conflict with clang's.

llvm-svn: 230424
2015-02-25 01:32:04 +00:00
Adrian Prantl a22fd38174 Revert "Adapt Makefile dependencies for the clang module format change in r230089."
llvm-svn: 230104
2015-02-21 00:29:43 +00:00
Adrian Prantl 6897e3e456 Adapt Makefile dependencies for the clang module format change in r230089.
llvm-svn: 230090
2015-02-20 23:35:07 +00:00
Alexander Kornienko b0a9b70373 [clang-tidy] Fix a typo.
llvm-svn: 223777
2014-12-09 15:02:17 +00:00
Alexander Kornienko 5c423318c9 [clang-tidy] Update help messages and docs.
Fixed incorrect examples of configuration, clarified the usage of -dump-config.

llvm-svn: 223235
2014-12-03 14:03:03 +00:00
Alexander Kornienko 5eac3c6a44 [clang-tidy] Added -fix-errors option
Summary:
Added -fix-errors option to allow applying fixes when compiler errors
are present. Without this flag -fix would bail out if there are compiler errors.
This is needed to avoid applying wrong fixes if Clang fails to recover from
compilation errors correctly.

Reviewers: djasper, klimek

Reviewed By: klimek

Subscribers: curdeius, cfe-commits

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

llvm-svn: 221152
2014-11-03 14:06:31 +00:00
Daniel Jasper c1de000e22 Fix Makefiles after r220867.
llvm-svn: 220868
2014-10-29 18:55:41 +00:00
Alexander Kornienko 50ab15654e Shrink the set of checks enabled by default.
Summary:
Enable only compiler diagnostics and safe static analyzer checks by
default. Let the defaults be conservative and safe for an average project.

Reviewers: djasper

Reviewed By: djasper

Subscribers: cfe-commits

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

llvm-svn: 220865
2014-10-29 18:25:09 +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
Alexander Kornienko 2192a8e519 [clang-tidy] Bring order to check registration.
Summary:
Register readability checks in a separate module. Renamed the checks
and test file names accordingly.

Reviewers: djasper, klimek

Reviewed By: klimek

Subscribers: curdeius, cfe-commits

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

llvm-svn: 220631
2014-10-26 01:41:14 +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 7165e89892 Fix a typo
llvm-svn: 218512
2014-09-26 11:48:53 +00:00
Alexander Kornienko eff4e9232a [clang-tidy] Add a -config={YAML} option.
Summary:
Add -config option to allow specifying configuration in YAML/JSON
format on the command line.

Reviewers: klimek

Reviewed By: klimek

Subscribers: curdeius, cfe-commits

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

llvm-svn: 218511
2014-09-26 11:42:29 +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
Alexander Kornienko 451567ac43 Add missing dependency.
llvm-svn: 218249
2014-09-22 14:56:43 +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 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
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 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
Alexander Kornienko 4153da2264 Don't write files with no fixes.
llvm-svn: 217163
2014-09-04 15:19:49 +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
Benjamin Kramer 5eddaac17f Fix linking in the Makefile build.
llvm-svn: 215550
2014-08-13 14:14:38 +00:00
Alp Toker e208dfc2af Track clang r213171
The clang rewriter is now a core facility.

llvm-svn: 213172
2014-07-16 16:50:17 +00:00
NAKAMURA Takumi 360096e701 Make clang-tidy-diff.py py3-compatible.
llvm-svn: 211834
2014-06-27 01:10:18 +00:00
Alexander Kornienko 1de35e719f Add clang-tidy-diff.py script to run clang-tidy and display warnings on changed lines only.
Reviewers: djasper

Reviewed By: djasper

Subscribers: cfe-commits

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

llvm-svn: 211698
2014-06-25 14:09:52 +00:00
Rafael Espindola 15c5784d3c Replace llvm::error_code with std::error_code.
llvm-svn: 210776
2014-06-12 13:32:11 +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 fbf9258582 Exit with error when no checks enabled.
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
2014-06-02 20:32:06 +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 bef51cdf05 Improved llvm-namespace-comment check.
Summary:
Handle various forms of existing namespace closing comments, fix
existing comments with wrong namespace name, ignore short namespaces.

The state of this check now seems to be enough to enable it by default to gather
user feedback ;)

Reviewers: klimek

Reviewed By: klimek

Subscribers: cfe-commits

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

llvm-svn: 209141
2014-05-19 16:39:08 +00:00
Alexander Kornienko 3ab3467cef Update clang-tidy documentation.
Summary:
Updated the help message, updated description of -checks=, removed
mentions of -disable-checks.

Reviewers: klimek

Reviewed By: klimek

Subscribers: cfe-commits

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

llvm-svn: 208979
2014-05-16 13:07:18 +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
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 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
Alex McCarthy fec08c72be Add a clang-tidy flag to support temporary destructor-aware analysis (workaround for bug 15599).
Reviewers: alexfh

Subscribers: jordan_rose, klimek, djasper, cfe-commits

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

llvm-svn: 207652
2014-04-30 14:09:24 +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
Alex McCarthy 5bc902e8e1 Fix typo (first commit to test commit access).
llvm-svn: 207490
2014-04-29 02:33:58 +00:00
Daniel Jasper 7b8d263998 Fix regex bug in clang-tidy.
Also make tests slightly less dependent on default flags. Once we have
implemented configuration file support, we might want to store the
clang-tidy configuration for the tests there.

llvm-svn: 205408
2014-04-02 08:52:06 +00:00
Daniel Jasper a3b8f0cf7d Disable a few clang-tidy checks by default.
The goal is to be able to run clang-tidy on LLVM files without further
configuration for now. Once llvm.org/PR19306 is addressed, we can add a
configuration file instead and choose other defaults.

llvm-svn: 205407
2014-04-02 08:27:12 +00:00
Alexander Kornienko 16ac6cebcf Added a module for checks not related to LLVM or Google coding style.
llvm-svn: 202970
2014-03-05 13:14:32 +00:00
Alexander Kornienko 99c9d6a0f6 Make the OptionCategory variable static.
llvm-svn: 200841
2014-02-05 13:43:27 +00:00
Alexander Kornienko fb9e92b167 Clang-tidy: added --disable-checks, --list-checks options.
Summary:
Allow disabling checks by regex. By default, disable alpha.* checks,
that are not particularly good tested (e.g. IdempotentOperationChecker, see
http://llvm-reviews.chandlerc.com/D2427).

Fixed a bug, that would disable all analyzer checks, when using a regex more
strict, than 'clang-analyzer-', for example --checks='clang-analyzer-deadcode-'.

Added --list-checks to list all enabled checks. This is useful to test specific
values in --checks/--disable-checks.

Reviewers: djasper, klimek

Reviewed By: klimek

CC: cfe-commits, klimek

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

llvm-svn: 197717
2013-12-19 19:57:05 +00:00
Alexander Kornienko 06ff5a7235 Fix the usage of the CommonOptionsParser ctor changed in r197139.
llvm-svn: 197141
2013-12-12 10:01:39 +00:00
NAKAMURA Takumi 78f534d689 [CMake] clang-tools-extra: Update dependencies.
llvm-svn: 196860
2013-12-10 01:41:10 +00:00