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