xref: /llvm-project/clang-tools-extra/clang-tidy/ClangTidyModule.cpp (revision a46952221e44cb53b707bca433b5177191de779d)
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"
15 
16 namespace clang {
17 namespace tidy {
18 
19 ClangTidyCheckFactories::~ClangTidyCheckFactories() {
20   for (const auto &Factory : Factories)
21     delete Factory.second;
22 }
23 
24 void ClangTidyCheckFactories::addCheckFactory(StringRef Name,
25                                               CheckFactoryBase *Factory) {
26   Factories[Name] = Factory;
27 }
28 
29 void ClangTidyCheckFactories::createChecks(
30     ChecksFilter &Filter,
31     std::vector<std::unique_ptr<ClangTidyCheck>> &Checks) {
32   for (const auto &Factory : Factories) {
33     if (Filter.isCheckEnabled(Factory.first)) {
34       ClangTidyCheck *Check = Factory.second->createCheck();
35       Check->setName(Factory.first);
36       Checks.emplace_back(Check);
37     }
38   }
39 }
40 
41 } // namespace tidy
42 } // namespace clang
43