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