1 //===--- tools/extra/clang-tidy/ClangTidyModule.cpp - Clang tidy tool -----===//
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
7 //===----------------------------------------------------------------------===//
9 /// \file Implements classes required to build clang-tidy modules.
11 //===----------------------------------------------------------------------===//
13 #include "ClangTidyModule.h"
14 #include "ClangTidyCheck.h"
16 namespace clang::tidy
{
18 void ClangTidyCheckFactories::registerCheckFactory(StringRef Name
,
19 CheckFactory Factory
) {
20 Factories
.insert_or_assign(Name
, std::move(Factory
));
23 std::vector
<std::unique_ptr
<ClangTidyCheck
>>
24 ClangTidyCheckFactories::createChecks(ClangTidyContext
*Context
) const {
25 std::vector
<std::unique_ptr
<ClangTidyCheck
>> Checks
;
26 for (const auto &Factory
: Factories
) {
27 if (Context
->isCheckEnabled(Factory
.getKey()))
28 Checks
.emplace_back(Factory
.getValue()(Factory
.getKey(), Context
));
33 std::vector
<std::unique_ptr
<ClangTidyCheck
>>
34 ClangTidyCheckFactories::createChecksForLanguage(
35 ClangTidyContext
*Context
) const {
36 std::vector
<std::unique_ptr
<ClangTidyCheck
>> Checks
;
37 const LangOptions
&LO
= Context
->getLangOpts();
38 for (const auto &Factory
: Factories
) {
39 if (!Context
->isCheckEnabled(Factory
.getKey()))
41 std::unique_ptr
<ClangTidyCheck
> Check
=
42 Factory
.getValue()(Factory
.getKey(), Context
);
43 if (Check
->isLanguageVersionSupported(LO
))
44 Checks
.push_back(std::move(Check
));
49 ClangTidyOptions
ClangTidyModule::getModuleOptions() { return {}; }
51 } // namespace clang::tidy