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
diff --git a/clang-tools-extra/clang-tidy/ClangTidyModule.cpp b/clang-tools-extra/clang-tidy/ClangTidyModule.cpp
index a81213c..dc3a11d 100644
--- a/clang-tools-extra/clang-tidy/ClangTidyModule.cpp
+++ b/clang-tools-extra/clang-tidy/ClangTidyModule.cpp
@@ -12,18 +12,13 @@
//===----------------------------------------------------------------------===//
#include "ClangTidyModule.h"
-#include "llvm/Support/Regex.h"
namespace clang {
namespace tidy {
-CheckFactoryBase::~CheckFactoryBase() {}
-
ClangTidyCheckFactories::~ClangTidyCheckFactories() {
- for (std::map<std::string, CheckFactoryBase *>::iterator
- I = Factories.begin(),
- E = Factories.end();
- I != E; ++I) {
+ for (FactoryMap::iterator I = Factories.begin(), E = Factories.end(); I != E;
+ ++I) {
delete I->second;
}
}
@@ -34,13 +29,10 @@
}
void ClangTidyCheckFactories::createChecks(
- StringRef CheckRegexString, SmallVectorImpl<ClangTidyCheck *> &Checks) {
- llvm::Regex CheckRegex(CheckRegexString);
- for (std::map<std::string, CheckFactoryBase *>::iterator
- I = Factories.begin(),
- E = Factories.end();
- I != E; ++I) {
- if (CheckRegex.match(I->first))
+ ChecksFilter &Filter, SmallVectorImpl<ClangTidyCheck *> &Checks) {
+ for (FactoryMap::iterator I = Factories.begin(), E = Factories.end(); I != E;
+ ++I) {
+ if (Filter.IsCheckEnabled(I->first))
Checks.push_back(I->second->createCheck());
}
}