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"
15#include "HeaderGuardCheck.h"
16#include "IncludeOrderCheck.h"
20#include "TwineLocalCheck.h"
22#include "UseRangesCheck.h"
23
24namespace clang::tidy {
25namespace llvm_check {
26
28public:
29 void addCheckFactories(ClangTidyCheckFactories &CheckFactories) override {
31 "llvm-else-after-return");
32 CheckFactories.registerCheck<LLVMHeaderGuardCheck>("llvm-header-guard");
33 CheckFactories.registerCheck<IncludeOrderCheck>("llvm-include-order");
35 "llvm-namespace-comment");
37 "llvm-prefer-isa-or-dyn-cast-in-conditionals");
39 "llvm-prefer-register-over-unsigned");
41 "llvm-prefer-static-over-anonymous-namespace");
43 "llvm-qualified-auto");
44 CheckFactories.registerCheck<TwineLocalCheck>("llvm-twine-local");
46 "llvm-use-new-mlir-op-builder");
47 CheckFactories.registerCheck<UseRangesCheck>("llvm-use-ranges");
48 }
49
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// Register the LLVMTidyModule using this statically initialized variable.
61static ClangTidyModuleRegistry::Add<LLVMModule> X("llvm-module",
62 "Adds LLVM lint checks.");
63
64} // namespace llvm_check
65
66// This anchor is used to force the linker to link in the generated object file
67// and thus register the LLVMModule.
68volatile int LLVMModuleAnchorSource = 0; // NOLINT(misc-use-internal-linkage)
69
70} // namespace clang::tidy
A collection of ClangTidyCheckFactory instances.
void registerCheck(llvm::StringRef CheckName)
Registers the CheckType with the name Name.
A clang-tidy module groups a number of ClangTidyChecks and gives them a prefixed name.
Checks the correct order of #includes.
Finds and fixes header guards that do not adhere to LLVM style.
void addCheckFactories(ClangTidyCheckFactories &CheckFactories) override
Implement this function in order to register all CheckFactories belonging to this module.
ClangTidyOptions getModuleOptions() override
Gets default options for checks defined in this module.
Looks at conditionals and finds and replaces cases of cast<>, which will / assert rather than return ...
Historically, LLVM has used unsigned to represent registers.
Finds function and variable declarations inside anonymous namespace and suggests replacing them with ...
Looks for local Twine variables which are prone to use after frees and should be generally avoided.
Checks for uses of MLIR's old/to be deprecated OpBuilder::create<T> form and suggests using T::create...
Finds calls to STL iterator algorithms that can be replaced with LLVM range-based algorithms from llv...
Flags the usages of else after return.
Checks that long namespaces have a closing comment.
Finds variables declared as auto that could be declared as: 'auto*' or 'const auto *' and reference v...
static ClangTidyModuleRegistry::Add< LLVMModule > X("llvm-module", "Adds LLVM lint checks.")
volatile int LLVMModuleAnchorSource
Contains options for clang-tidy.
OptionMap CheckOptions
Key-value mapping used to store check-specific options.