diff options
author | Alexander Kornienko <alexfh@google.com> | 2014-05-15 14:27:36 +0000 |
---|---|---|
committer | Alexander Kornienko <alexfh@google.com> | 2014-05-15 14:27:36 +0000 |
commit | 87404e11b910161e379accc95ad4436066201e36 (patch) | |
tree | 7c695123616a1d05b7065fc3b472f214f2878eb5 /clang-tidy/tool/ClangTidyMain.cpp | |
parent | 63615c965c93d5c61bd66b8b44e7a212020d0b52 (diff) |
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
git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@208883 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'clang-tidy/tool/ClangTidyMain.cpp')
-rw-r--r-- | clang-tidy/tool/ClangTidyMain.cpp | 26 |
1 files changed, 12 insertions, 14 deletions
diff --git a/clang-tidy/tool/ClangTidyMain.cpp b/clang-tidy/tool/ClangTidyMain.cpp index 5c136bc3..4e815c0d 100644 --- a/clang-tidy/tool/ClangTidyMain.cpp +++ b/clang-tidy/tool/ClangTidyMain.cpp @@ -27,18 +27,17 @@ static cl::OptionCategory ClangTidyCategory("clang-tidy options"); static cl::extrahelp CommonHelp(CommonOptionsParser::HelpMessage); -static cl::opt<std::string> Checks( - "checks", - cl::desc("Regular expression matching the names of the checks to be run."), - cl::init(".*"), cl::cat(ClangTidyCategory)); -static cl::opt<std::string> DisableChecks( - "disable-checks", - cl::desc("Regular expression matching the names of the checks to disable."), - cl::init("(clang-analyzer-alpha.*" // Too many false positives. - "|llvm-include-order" // Not implemented yet. - "|llvm-namespace-comment" // Not complete. - "|google-.*)"), // Doesn't apply to LLVM. - cl::cat(ClangTidyCategory)); +const char DefaultChecks[] = + "*," // Enable all checks, except these: + "-clang-analyzer-alpha*," // Too many false positives. + "-llvm-include-order," // Not implemented yet. + "-llvm-namespace-comment," // Not complete. + "-google-*,"; // Doesn't apply to LLVM. +static cl::opt<std::string> +Checks("checks", + cl::desc("Comma-separated list of positive and negative globs matching\n" + "the names of the checks to be run."), + cl::init(""), cl::cat(ClangTidyCategory)); static cl::opt<std::string> HeaderFilter( "header-filter", cl::desc("Regular expression matching the names of the headers to output\n" @@ -88,8 +87,7 @@ int main(int argc, const char **argv) { CommonOptionsParser OptionsParser(argc, argv, ClangTidyCategory); clang::tidy::ClangTidyOptions Options; - Options.EnableChecksRegex = Checks; - Options.DisableChecksRegex = DisableChecks; + Options.Checks = DefaultChecks + Checks; Options.HeaderFilterRegex = HeaderFilter; Options.AnalyzeTemporaryDtors = AnalyzeTemporaryDtors; |