xref: /llvm-project/clang-tools-extra/clang-tidy/ClangTidyModule.cpp (revision 2946cd701067404b99c39fb29dc9c74bd7193eb3)
1 //===--- tools/extra/clang-tidy/ClangTidyModule.cpp - Clang tidy tool -----===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 ///
9 ///  \file Implements classes required to build clang-tidy modules.
10 ///
11 //===----------------------------------------------------------------------===//
12 
13 #include "ClangTidyModule.h"
14 
15 namespace clang {
16 namespace tidy {
17 
18 void ClangTidyCheckFactories::registerCheckFactory(StringRef Name,
19                                                    CheckFactory Factory) {
20   Factories[Name] = std::move(Factory);
21 }
22 
23 void ClangTidyCheckFactories::createChecks(
24     ClangTidyContext *Context,
25     std::vector<std::unique_ptr<ClangTidyCheck>> &Checks) {
26   for (const auto &Factory : Factories) {
27     if (Context->isCheckEnabled(Factory.first))
28       Checks.emplace_back(Factory.second(Factory.first, Context));
29   }
30 }
31 
32 ClangTidyOptions ClangTidyModule::getModuleOptions() {
33   return ClangTidyOptions();
34 }
35 
36 } // namespace tidy
37 } // namespace clang
38