From f0c740b38285ace936401dc735e7e4e511aad8aa Mon Sep 17 00:00:00 2001 From: Alexander Kornienko Date: Thu, 19 Dec 2013 19:57:05 +0000 Subject: 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 git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@197717 91177308-0d34-0410-b5e6-96231b3b80d8 --- clang-tidy/ClangTidyModule.cpp | 20 ++++++-------------- 1 file changed, 6 insertions(+), 14 deletions(-) (limited to 'clang-tidy/ClangTidyModule.cpp') diff --git a/clang-tidy/ClangTidyModule.cpp b/clang-tidy/ClangTidyModule.cpp index a81213ce..dc3a11d0 100644 --- a/clang-tidy/ClangTidyModule.cpp +++ b/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::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::addCheckFactory(StringRef Name, } void ClangTidyCheckFactories::createChecks( - StringRef CheckRegexString, SmallVectorImpl &Checks) { - llvm::Regex CheckRegex(CheckRegexString); - for (std::map::iterator - I = Factories.begin(), - E = Factories.end(); - I != E; ++I) { - if (CheckRegex.match(I->first)) + ChecksFilter &Filter, SmallVectorImpl &Checks) { + for (FactoryMap::iterator I = Factories.begin(), E = Factories.end(); I != E; + ++I) { + if (Filter.IsCheckEnabled(I->first)) Checks.push_back(I->second->createCheck()); } } -- cgit v1.2.3