clang-tools  14.0.0git
LLVMTidyModule.cpp
Go to the documentation of this file.
1 //===--- LLVMTidyModule.cpp - clang-tidy ----------------------------------===//
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"
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"
20 
21 namespace clang {
22 namespace tidy {
23 namespace llvm_check {
24 
25 class LLVMModule : public ClangTidyModule {
26 public:
27  void addCheckFactories(ClangTidyCheckFactories &CheckFactories) override {
29  "llvm-else-after-return");
30  CheckFactories.registerCheck<LLVMHeaderGuardCheck>("llvm-header-guard");
31  CheckFactories.registerCheck<IncludeOrderCheck>("llvm-include-order");
33  "llvm-namespace-comment");
35  "llvm-prefer-isa-or-dyn-cast-in-conditionals");
37  "llvm-prefer-register-over-unsigned");
39  "llvm-qualified-auto");
40  CheckFactories.registerCheck<TwineLocalCheck>("llvm-twine-local");
41  }
42 
44  ClangTidyOptions Options;
45  Options.CheckOptions["llvm-qualified-auto.AddConstToQualified"] = "false";
46  Options.CheckOptions["llvm-else-after-return.WarnOnUnfixable"] = "false";
47  Options.CheckOptions["llvm-else-after-return.WarnOnConditionVariables"] =
48  "false";
49  return Options;
50  }
51 };
52 
53 // Register the LLVMTidyModule using this statically initialized variable.
54 static ClangTidyModuleRegistry::Add<LLVMModule> X("llvm-module",
55  "Adds LLVM lint checks.");
56 
57 } // namespace llvm_check
58 
59 // This anchor is used to force the linker to link in the generated object file
60 // and thus register the LLVMModule.
61 volatile int LLVMModuleAnchorSource = 0;
62 
63 } // namespace tidy
64 } // namespace clang
clang::tidy::readability::NamespaceCommentCheck
Checks that long namespaces have a closing comment.
Definition: NamespaceCommentCheck.h:24
clang::tidy::llvm_check::LLVMModule
Definition: LLVMTidyModule.cpp:25
clang::tidy::ClangTidyOptions::CheckOptions
OptionMap CheckOptions
Key-value mapping used to store check-specific options.
Definition: ClangTidyOptions.h:118
IncludeOrderCheck.h
clang::tidy::llvm_check::X
static ClangTidyModuleRegistry::Add< LLVMModule > X("llvm-module", "Adds LLVM lint checks.")
clang::tidy::ClangTidyOptions
Contains options for clang-tidy.
Definition: ClangTidyOptions.h:50
clang::tidy::ClangTidyCheckFactories
A collection of ClangTidyCheckFactory instances.
Definition: ClangTidyModule.h:28
clang::tidy::llvm_check::PreferIsaOrDynCastInConditionalsCheck
Looks at conditionals and finds and replaces cases of cast<>, which will assert rather than return a ...
Definition: PreferIsaOrDynCastInConditionalsCheck.h:51
TwineLocalCheck.h
clang::tidy::LLVMModuleAnchorSource
volatile int LLVMModuleAnchorSource
Definition: LLVMTidyModule.cpp:61
HeaderGuardCheck.h
PreferRegisterOverUnsignedCheck.h
clang::tidy::llvm_check::LLVMHeaderGuardCheck
Finds and fixes header guards that do not adhere to LLVM style.
Definition: HeaderGuardCheck.h:28
clang::tidy::llvm_check::IncludeOrderCheck
Checks the correct order of #includes.
Definition: IncludeOrderCheck.h:21
clang::tidy::llvm_check::PreferRegisterOverUnsignedCheck
Historically, LLVM has used unsigned to represent registers.
Definition: PreferRegisterOverUnsignedCheck.h:24
clang::tidy::readability::ElseAfterReturnCheck
Flags the usages of else after return.
Definition: ElseAfterReturnCheck.h:22
clang::tidy::llvm_check::TwineLocalCheck
Looks for local Twine variables which are prone to use after frees and should be generally avoided.
Definition: TwineLocalCheck.h:20
clang::tidy::llvm_check::LLVMModule::getModuleOptions
ClangTidyOptions getModuleOptions() override
Gets default options for checks defined in this module.
Definition: LLVMTidyModule.cpp:43
clang
===– Representation.cpp - ClangDoc Representation --------—*- C++ -*-===//
Definition: ApplyReplacements.h:27
clang::tidy::readability::QualifiedAutoCheck
Finds variables declared as auto that could be declared as: 'auto*' or 'const auto *' and reference v...
Definition: QualifiedAutoCheck.h:24
PreferIsaOrDynCastInConditionalsCheck.h
clang::tidy::ClangTidyModule
A clang-tidy module groups a number of ClangTidyChecks and gives them a prefixed name.
Definition: ClangTidyModule.h:81
clang::tidy::llvm_check::LLVMModule::addCheckFactories
void addCheckFactories(ClangTidyCheckFactories &CheckFactories) override
Implement this function in order to register all CheckFactories belonging to this module.
Definition: LLVMTidyModule.cpp:27
clang::tidy::ClangTidyCheckFactories::registerCheck
void registerCheck(llvm::StringRef CheckName)
Registers the CheckType with the name Name.
Definition: ClangTidyModule.h:59