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