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