clang-tools 10.0.0

ClangTidyModule.cpp
Go to the documentation of this file.
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 std::vector<std::unique_ptr<ClangTidyCheck>>
24 ClangTidyCheckFactories::createChecks(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 return Checks;
31 }
32
33 ClangTidyOptions ClangTidyModule::getModuleOptions() {
34 return ClangTidyOptions();
35 }
36
37 } // namespace tidy
38 } // namespace clang
clang::tidy::ClangTidyCheckFactories::registerCheckFactory
void registerCheckFactory(StringRef Name, CheckFactory Factory)
Registers check Factory with name Name.
Definition: ClangTidyModule.cpp:18
clang::tidy::ClangTidyContext::isCheckEnabled
bool isCheckEnabled(StringRef CheckName) const
Returns true if the check is enabled for the CurrentFile.
Definition: ClangTidyDiagnosticConsumer.cpp:216
ClangTidyModule.h
clang::tidy::ClangTidyOptions
Contains options for clang-tidy.
Definition: ClangTidyOptions.h:50
clang::tidy::ClangTidyModule::getModuleOptions
virtual ClangTidyOptions getModuleOptions()
Gets default options for checks defined in this module.
Definition: ClangTidyModule.cpp:33
clang::tidy::ClangTidyCheckFactories::CheckFactory
std::function< std::unique_ptr< ClangTidyCheck >(StringRef Name, ClangTidyContext *Context)> CheckFactory
Definition: ClangTidyModule.h:30
Name
static constexpr llvm::StringLiteral Name
Definition: UppercaseLiteralSuffixCheck.cpp:27
clang
===– Representation.cpp - ClangDoc Representation --------—*- C++ -*-===//
Definition: ApplyReplacements.h:27
Checks
static cl::opt< std::string > Checks("checks", cl::desc(R"( Comma-separated list of globs with optional '-' prefix. Globs are processed in order of appearance in the list. Globs without '-' prefix add checks with matching names to the set, globs with the '-' prefix remove checks with matching names from the set of enabled checks. This option's value is appended to the value of the 'Checks' option in .clang-tidy file, if any. )"), cl::init(""), cl::cat(ClangTidyCategory))
clang::tidy::ClangTidyContext
Every ClangTidyCheck reports errors through a DiagnosticsEngine provided by this context.
Definition: ClangTidyDiagnosticConsumer.h:77
clang::tidy::ClangTidyCheckFactories::createChecks
std::vector< std::unique_ptr< ClangTidyCheck > > createChecks(ClangTidyContext *Context)
Create instances of checks that are enabled.
Definition: ClangTidyModule.cpp:24