Daniel Jasper | d07c840 | 2013-07-29 08:19:24 +0000 | [diff] [blame] | 1 | //===--- tools/extra/clang-tidy/ClangTidyModule.cpp - Clang tidy tool -----===// |
| 2 | // |
| 3 | // The LLVM Compiler Infrastructure |
| 4 | // |
| 5 | // This file is distributed under the University of Illinois Open Source |
| 6 | // License. See LICENSE.TXT for details. |
| 7 | // |
| 8 | //===----------------------------------------------------------------------===// |
| 9 | /// |
| 10 | /// \file Implements classes required to build clang-tidy modules. |
| 11 | /// |
| 12 | //===----------------------------------------------------------------------===// |
| 13 | |
| 14 | #include "ClangTidyModule.h" |
Daniel Jasper | d07c840 | 2013-07-29 08:19:24 +0000 | [diff] [blame] | 15 | |
| 16 | namespace clang { |
| 17 | namespace tidy { |
| 18 | |
Daniel Jasper | d07c840 | 2013-07-29 08:19:24 +0000 | [diff] [blame] | 19 | ClangTidyCheckFactories::~ClangTidyCheckFactories() { |
Alexander Kornienko | df1e3cb | 2014-03-06 10:17:46 +0000 | [diff] [blame^] | 20 | for (const auto &Factory : Factories) |
| 21 | delete Factory.second; |
Daniel Jasper | d07c840 | 2013-07-29 08:19:24 +0000 | [diff] [blame] | 22 | } |
Alexander Kornienko | df1e3cb | 2014-03-06 10:17:46 +0000 | [diff] [blame^] | 23 | |
Daniel Jasper | d07c840 | 2013-07-29 08:19:24 +0000 | [diff] [blame] | 24 | void ClangTidyCheckFactories::addCheckFactory(StringRef Name, |
| 25 | CheckFactoryBase *Factory) { |
Daniel Jasper | d07c840 | 2013-07-29 08:19:24 +0000 | [diff] [blame] | 26 | Factories[Name] = Factory; |
| 27 | } |
| 28 | |
| 29 | void ClangTidyCheckFactories::createChecks( |
Alexander Kornienko | fb9e92b | 2013-12-19 19:57:05 +0000 | [diff] [blame] | 30 | ChecksFilter &Filter, SmallVectorImpl<ClangTidyCheck *> &Checks) { |
Alexander Kornienko | df1e3cb | 2014-03-06 10:17:46 +0000 | [diff] [blame^] | 31 | for (const auto &Factory : Factories) { |
| 32 | if (Filter.IsCheckEnabled(Factory.first)) { |
| 33 | ClangTidyCheck *Check = Factory.second->createCheck(); |
| 34 | Check->setName(Factory.first); |
Alexander Kornienko | 41bfe8d | 2014-01-13 10:50:51 +0000 | [diff] [blame] | 35 | Checks.push_back(Check); |
| 36 | } |
Daniel Jasper | d07c840 | 2013-07-29 08:19:24 +0000 | [diff] [blame] | 37 | } |
| 38 | } |
| 39 | |
| 40 | } // namespace tidy |
| 41 | } // namespace clang |