clang-tools 24.0.0git
LLVMTidyModule.cpp
Go to the documentation of this file.
1//===----------------------------------------------------------------------===//
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#include "../ClangTidy.h"
10#include "../ClangTidyModule.h"
14#include "FormatvStringCheck.h"
15#include "HeaderGuardCheck.h"
16#include "IncludeOrderCheck.h"
22#include "TwineLocalCheck.h"
25#include "UseRangesCheck.h"
26#include "UseVectorUtilsCheck.h"
27
28namespace clang::tidy {
29namespace llvm_check {
30namespace {
31
32class LLVMModule : public ClangTidyModule {
33public:
34 void addCheckFactories(ClangTidyCheckFactories &CheckFactories) override {
35 CheckFactories.registerCheck<readability::ElseAfterReturnCheck>(
36 "llvm-else-after-return");
37 CheckFactories.registerCheck<FormatvStringCheck>("llvm-formatv-string");
38 CheckFactories.registerCheck<LLVMHeaderGuardCheck>("llvm-header-guard");
39 CheckFactories.registerCheck<IncludeOrderCheck>("llvm-include-order");
40 CheckFactories.registerCheck<readability::NamespaceCommentCheck>(
41 "llvm-namespace-comment");
42 CheckFactories.registerCheck<PreferIsaOrDynCastInConditionalsCheck>(
43 "llvm-prefer-isa-or-dyn-cast-in-conditionals");
44 CheckFactories.registerCheck<PreferRegisterOverUnsignedCheck>(
45 "llvm-prefer-register-over-unsigned");
46 CheckFactories.registerCheck<PreferStaticOverAnonymousNamespaceCheck>(
47 "llvm-prefer-static-over-anonymous-namespace");
48 CheckFactories.registerCheck<readability::QualifiedAutoCheck>(
49 "llvm-qualified-auto");
50 CheckFactories.registerCheck<RedundantCastingCheck>(
51 "llvm-redundant-casting");
52 CheckFactories.registerCheck<InvalidRegexPatternCheck>(
53 "llvm-invalid-regex-pattern");
54 CheckFactories.registerCheck<TwineLocalCheck>("llvm-twine-local");
55 CheckFactories.registerCheck<TypeSwitchCaseTypesCheck>(
56 "llvm-type-switch-case-types");
57 CheckFactories.registerCheck<UseNewMlirOpBuilderCheck>(
58 "llvm-use-new-mlir-op-builder");
59 CheckFactories.registerCheck<UseRangesCheck>("llvm-use-ranges");
60 CheckFactories.registerCheck<UseVectorUtilsCheck>("llvm-use-vector-utils");
61 }
62
63 ClangTidyOptions getModuleOptions() override {
64 ClangTidyOptions Options;
65 Options.CheckOptions["llvm-qualified-auto.AddConstToQualified"] = "false";
66 Options.CheckOptions["llvm-else-after-return.WarnOnUnfixable"] = "false";
67 Options.CheckOptions["llvm-else-after-return.WarnOnConditionVariables"] =
68 "false";
69 return Options;
70 }
71};
72
73} // namespace
74
75// Register the LLVMTidyModule using this statically initialized variable.
76static ClangTidyModuleRegistry::Add<LLVMModule> X("llvm-module",
77 "Adds LLVM lint checks.");
78
79} // namespace llvm_check
80
81// This anchor is used to force the linker to link in the generated object file
82// and thus register the LLVMModule.
83volatile int LLVMModuleAnchorSource = 0; // NOLINT(misc-use-internal-linkage)
84
85} // namespace clang::tidy
static ClangTidyModuleRegistry::Add< LLVMModule > X("llvm-module", "Adds LLVM lint checks.")
volatile int LLVMModuleAnchorSource
OptionMap CheckOptions
Key-value mapping used to store check-specific options.