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 #include "ClangTidyCheck.h" 15 16 namespace clang { 17 namespace tidy { 18 19 void ClangTidyCheckFactories::registerCheckFactory(StringRef Name, 20 CheckFactory Factory) { 21 Factories[std::string(Name)] = std::move(Factory); 22 } 23 24 std::vector<std::unique_ptr<ClangTidyCheck>> 25 ClangTidyCheckFactories::createChecks(ClangTidyContext *Context) { 26 std::vector<std::unique_ptr<ClangTidyCheck>> Checks; 27 for (const auto &Factory : Factories) { 28 if (Context->isCheckEnabled(Factory.first)) 29 Checks.emplace_back(Factory.second(Factory.first, Context)); 30 } 31 return Checks; 32 } 33 34 ClangTidyOptions ClangTidyModule::getModuleOptions() { 35 return ClangTidyOptions(); 36 } 37 38 } // namespace tidy 39 } // namespace clang 40