clang-tools 17.0.0git
Go to the documentation of this file.
1//===--- LLVMTidyModule.cpp - clang-tidy ----------------------------------===//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
9#include "../ClangTidy.h"
10#include "../ClangTidyModule.h"
11#include "../ClangTidyModuleRegistry.h"
12#include "../readability/ElseAfterReturnCheck.h"
13#include "../readability/NamespaceCommentCheck.h"
14#include "../readability/QualifiedAutoCheck.h"
15#include "HeaderGuardCheck.h"
16#include "IncludeOrderCheck.h"
19#include "TwineLocalCheck.h"
21namespace clang::tidy {
22namespace llvm_check {
26 void addCheckFactories(ClangTidyCheckFactories &CheckFactories) override {
28 "llvm-else-after-return");
29 CheckFactories.registerCheck<LLVMHeaderGuardCheck>("llvm-header-guard");
30 CheckFactories.registerCheck<IncludeOrderCheck>("llvm-include-order");
32 "llvm-namespace-comment");
34 "llvm-prefer-isa-or-dyn-cast-in-conditionals");
36 "llvm-prefer-register-over-unsigned");
38 "llvm-qualified-auto");
39 CheckFactories.registerCheck<TwineLocalCheck>("llvm-twine-local");
40 }
43 ClangTidyOptions Options;
44 Options.CheckOptions["llvm-qualified-auto.AddConstToQualified"] = "false";
45 Options.CheckOptions["llvm-else-after-return.WarnOnUnfixable"] = "false";
46 Options.CheckOptions["llvm-else-after-return.WarnOnConditionVariables"] =
47 "false";
48 return Options;
49 }
52// Register the LLVMTidyModule using this statically initialized variable.
53static ClangTidyModuleRegistry::Add<LLVMModule> X("llvm-module",
54 "Adds LLVM lint checks.");
56} // namespace llvm_check
58// This anchor is used to force the linker to link in the generated object file
59// and thus register the LLVMModule.
60volatile int LLVMModuleAnchorSource = 0;
62} // namespace clang::tidy
int X
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 a ...
Historically, LLVM has used unsigned to represent registers.
Looks for local Twine variables which are prone to use after frees and should be generally avoided.
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...
volatile int LLVMModuleAnchorSource
Contains options for clang-tidy.
OptionMap CheckOptions
Key-value mapping used to store check-specific options.