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