clang-tools 10.0.0

MiscTidyModule.cpp
Go to the documentation of this file.
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 "MisplacedConstCheck.h"
14 #include "NewDeleteOverloadsCheck.h"
15 #include "NonCopyableObjects.h"
16 #include "NonPrivateMemberVariablesInClassesCheck.h"
17 #include "RedundantExpressionCheck.h"
18 #include "StaticAssertCheck.h"
19 #include "ThrowByValueCatchByReferenceCheck.h"
20 #include "UnconventionalAssignOperatorCheck.h"
21 #include "UniqueptrResetReleaseCheck.h"
22 #include "UnusedAliasDeclsCheck.h"
23 #include "UnusedParametersCheck.h"
24 #include "UnusedUsingDeclsCheck.h"
25
26 namespace clang {
27 namespace tidy {
28 namespace misc {
29
30 class MiscModule : public ClangTidyModule {
31 public:
32 void addCheckFactories(ClangTidyCheckFactories &CheckFactories) override {
33 CheckFactories.registerCheck<DefinitionsInHeadersCheck>(
34 "misc-definitions-in-headers");
35 CheckFactories.registerCheck<MisplacedConstCheck>("misc-misplaced-const");
36 CheckFactories.registerCheck<NewDeleteOverloadsCheck>(
37 "misc-new-delete-overloads");
38 CheckFactories.registerCheck<NonCopyableObjectsCheck>(
39 "misc-non-copyable-objects");
40 CheckFactories.registerCheck<NonPrivateMemberVariablesInClassesCheck>(
41 "misc-non-private-member-variables-in-classes");
42 CheckFactories.registerCheck<RedundantExpressionCheck>(
43 "misc-redundant-expression");
44 CheckFactories.registerCheck<StaticAssertCheck>("misc-static-assert");
45 CheckFactories.registerCheck<ThrowByValueCatchByReferenceCheck>(
46 "misc-throw-by-value-catch-by-reference");
47 CheckFactories.registerCheck<UnconventionalAssignOperatorCheck>(
48 "misc-unconventional-assign-operator");
49 CheckFactories.registerCheck<UniqueptrResetReleaseCheck>(
50 "misc-uniqueptr-reset-release");
51 CheckFactories.registerCheck<UnusedAliasDeclsCheck>(
52 "misc-unused-alias-decls");
53 CheckFactories.registerCheck<UnusedParametersCheck>(
54 "misc-unused-parameters");
55 CheckFactories.registerCheck<UnusedUsingDeclsCheck>(
56 "misc-unused-using-decls");
57 }
58 };
59
60 } // namespace misc
61
62 // Register the MiscTidyModule using this statically initialized variable.
63 static ClangTidyModuleRegistry::Add<misc::MiscModule>
64 X("misc-module", "Adds miscellaneous lint checks.");
65
66 // This anchor is used to force the linker to link in the generated object file
67 // and thus register the MiscModule.
68 volatile int MiscModuleAnchorSource = 0;
69
70 } // namespace tidy
71 } // namespace clang
NonCopyableObjects.h
clang::tidy::misc::MisplacedConstCheck
This check diagnoses when a const qualifier is applied to a typedef to a pointer type rather than to ...
Definition: MisplacedConstCheck.h:23
UnconventionalAssignOperatorCheck.h
ThrowByValueCatchByReferenceCheck.h
StaticAssertCheck.h
clang::tidy::misc::UniqueptrResetReleaseCheck
Find and replace unique_ptr::reset(release()) with std::move().
Definition: UniqueptrResetReleaseCheck.h:29
clang::tidy::misc::ThrowByValueCatchByReferenceCheck
checks for locations that do not throw by value
Definition: ThrowByValueCatchByReferenceCheck.h:29
clang::tidy::ClangTidyCheckFactories::registerCheck
void registerCheck(StringRef CheckName)
Registers the CheckType with the name Name.
Definition: ClangTidyModule.h:58
clang::tidy::misc::StaticAssertCheck
Replaces assert() with static_assert() if the condition is evaluatable at compile time...
Definition: StaticAssertCheck.h:25
clang::tidy::misc::UnusedAliasDeclsCheck
Finds unused namespace alias declarations.
Definition: UnusedAliasDeclsCheck.h:20
RedundantExpressionCheck.h
clang::tidy::misc::NonPrivateMemberVariablesInClassesCheck
This checker finds classes that not only contain the data (non-static member variables), but also have logic (non-static member functions), and diagnoses all member variables that have any other scope other than private.
Definition: NonPrivateMemberVariablesInClassesCheck.h:29
NewDeleteOverloadsCheck.h
clang::tidy::misc::MiscModule::addCheckFactories
void addCheckFactories(ClangTidyCheckFactories &CheckFactories) override
Implement this function in order to register all CheckFactories belonging to this module...
Definition: MiscTidyModule.cpp:32
clang::tidy::ClangTidyCheckFactories
A collection of ClangTidyCheckFactory instances.
Definition: ClangTidyModule.h:27
clang::tidy::misc::MiscModule
Definition: MiscTidyModule.cpp:30
MisplacedConstCheck.h
clang::tidy::misc::UnusedUsingDeclsCheck
Finds unused using declarations.
Definition: UnusedUsingDeclsCheck.h:24
clang::tidy::ClangTidyModule
A clang-tidy module groups a number of ClangTidyChecks and gives them a prefixed name.
Definition: ClangTidyModule.h:80
clang::tidy::misc::NewDeleteOverloadsCheck
Definition: NewDeleteOverloadsCheck.h:20
clang::tidy::misc::NonCopyableObjectsCheck
The check flags dereferences and non-pointer declarations of objects that are not meant to be passed ...
Definition: NonCopyableObjects.h:20
UnusedAliasDeclsCheck.h
clang::tidy::X
static ClangTidyModuleRegistry::Add< bugprone::BugproneModule > X("bugprone-module", "Adds checks for bugprone code constructs.")
clang::tidy::misc::RedundantExpressionCheck
The checker detects expressions that are redundant, because they contain ineffective, useless parts.
Definition: RedundantExpressionCheck.h:23
UnusedParametersCheck.h
clang::tidy::MiscModuleAnchorSource
volatile int MiscModuleAnchorSource
Definition: MiscTidyModule.cpp:68
clang::tidy::misc::DefinitionsInHeadersCheck
Finds non-extern non-inline function and variable definitions in header files, which can lead to pote...
Definition: DefinitionsInHeadersCheck.h:33
UniqueptrResetReleaseCheck.h
clang::tidy::misc::UnconventionalAssignOperatorCheck
Finds declarations of assignment operators with the wrong return and/or argument types and definition...
Definition: UnconventionalAssignOperatorCheck.h:29
clang
===– Representation.cpp - ClangDoc Representation --------—*- C++ -*-===//
Definition: ApplyReplacements.h:27
clang::tidy::misc::UnusedParametersCheck
Finds unused parameters and fixes them, so that -Wunused-parameter can be turned on.
Definition: UnusedParametersCheck.h:20
DefinitionsInHeadersCheck.h
UnusedUsingDeclsCheck.h
NonPrivateMemberVariablesInClassesCheck.h