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