1 //===--- MiscTidyModule.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 "ConfusableIdentifierCheck.h"
13 #include "ConstCorrectnessCheck.h"
14 #include "DefinitionsInHeadersCheck.h"
15 #include "MisleadingBidirectional.h"
16 #include "MisleadingIdentifier.h"
17 #include "MisplacedConstCheck.h"
18 #include "NewDeleteOverloadsCheck.h"
19 #include "NoRecursionCheck.h"
20 #include "NonCopyableObjects.h"
21 #include "NonPrivateMemberVariablesInClassesCheck.h"
22 #include "RedundantExpressionCheck.h"
23 #include "StaticAssertCheck.h"
24 #include "ThrowByValueCatchByReferenceCheck.h"
25 #include "UnconventionalAssignOperatorCheck.h"
26 #include "UniqueptrResetReleaseCheck.h"
27 #include "UnusedAliasDeclsCheck.h"
28 #include "UnusedParametersCheck.h"
29 #include "UnusedUsingDeclsCheck.h"
30 
31 namespace clang {
32 namespace tidy {
33 namespace misc {
34 
35 class MiscModule : public ClangTidyModule {
36 public:
addCheckFactories(ClangTidyCheckFactories & CheckFactories)37   void addCheckFactories(ClangTidyCheckFactories &CheckFactories) override {
38     CheckFactories.registerCheck<ConfusableIdentifierCheck>(
39         "misc-confusable-identifiers");
40     CheckFactories.registerCheck<ConstCorrectnessCheck>(
41         "misc-const-correctness");
42     CheckFactories.registerCheck<DefinitionsInHeadersCheck>(
43         "misc-definitions-in-headers");
44     CheckFactories.registerCheck<MisleadingBidirectionalCheck>(
45         "misc-misleading-bidirectional");
46     CheckFactories.registerCheck<MisleadingIdentifierCheck>(
47         "misc-misleading-identifier");
48     CheckFactories.registerCheck<MisplacedConstCheck>("misc-misplaced-const");
49     CheckFactories.registerCheck<NewDeleteOverloadsCheck>(
50         "misc-new-delete-overloads");
51     CheckFactories.registerCheck<NoRecursionCheck>("misc-no-recursion");
52     CheckFactories.registerCheck<NonCopyableObjectsCheck>(
53         "misc-non-copyable-objects");
54     CheckFactories.registerCheck<NonPrivateMemberVariablesInClassesCheck>(
55         "misc-non-private-member-variables-in-classes");
56     CheckFactories.registerCheck<RedundantExpressionCheck>(
57         "misc-redundant-expression");
58     CheckFactories.registerCheck<StaticAssertCheck>("misc-static-assert");
59     CheckFactories.registerCheck<ThrowByValueCatchByReferenceCheck>(
60         "misc-throw-by-value-catch-by-reference");
61     CheckFactories.registerCheck<UnconventionalAssignOperatorCheck>(
62         "misc-unconventional-assign-operator");
63     CheckFactories.registerCheck<UniqueptrResetReleaseCheck>(
64         "misc-uniqueptr-reset-release");
65     CheckFactories.registerCheck<UnusedAliasDeclsCheck>(
66         "misc-unused-alias-decls");
67     CheckFactories.registerCheck<UnusedParametersCheck>(
68         "misc-unused-parameters");
69     CheckFactories.registerCheck<UnusedUsingDeclsCheck>(
70         "misc-unused-using-decls");
71   }
72 };
73 
74 } // namespace misc
75 
76 // Register the MiscTidyModule using this statically initialized variable.
77 static ClangTidyModuleRegistry::Add<misc::MiscModule>
78     X("misc-module", "Adds miscellaneous lint checks.");
79 
80 // This anchor is used to force the linker to link in the generated object file
81 // and thus register the MiscModule.
82 volatile int MiscModuleAnchorSource = 0;
83 
84 } // namespace tidy
85 } // namespace clang
86