clang-tools 6.0.0

CppCoreGuidelinesTidyModule.cpp
Go to the documentation of this file.
1 //===--- CppCoreGuidelinesModule.cpp - clang-tidy -------------------------===//
2 //
3 // The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9
10 #include "../ClangTidy.h"
11 #include "../ClangTidyModule.h"
12 #include "../ClangTidyModuleRegistry.h"
13 #include "../misc/UnconventionalAssignOperatorCheck.h"
14 #include "InterfacesGlobalInitCheck.h"
15 #include "NoMallocCheck.h"
16 #include "OwningMemoryCheck.h"
17 #include "ProBoundsArrayToPointerDecayCheck.h"
18 #include "ProBoundsConstantArrayIndexCheck.h"
19 #include "ProBoundsPointerArithmeticCheck.h"
20 #include "ProTypeConstCastCheck.h"
21 #include "ProTypeCstyleCastCheck.h"
22 #include "ProTypeMemberInitCheck.h"
23 #include "ProTypeReinterpretCastCheck.h"
24 #include "ProTypeStaticCastDowncastCheck.h"
25 #include "ProTypeUnionAccessCheck.h"
26 #include "ProTypeVarargCheck.h"
27 #include "SlicingCheck.h"
28 #include "SpecialMemberFunctionsCheck.h"
29
30 namespace clang {
31 namespace tidy {
32 namespace cppcoreguidelines {
33
34 /// A module containing checks of the C++ Core Guidelines
35 class CppCoreGuidelinesModule : public ClangTidyModule {
36 public:
37 void addCheckFactories(ClangTidyCheckFactories &CheckFactories) override {
38 CheckFactories.registerCheck<InterfacesGlobalInitCheck>(
39 "cppcoreguidelines-interfaces-global-init");
40 CheckFactories.registerCheck<NoMallocCheck>("cppcoreguidelines-no-malloc");
41 CheckFactories.registerCheck<OwningMemoryCheck>(
42 "cppcoreguidelines-owning-memory");
43 CheckFactories.registerCheck<ProBoundsArrayToPointerDecayCheck>(
44 "cppcoreguidelines-pro-bounds-array-to-pointer-decay");
45 CheckFactories.registerCheck<ProBoundsConstantArrayIndexCheck>(
46 "cppcoreguidelines-pro-bounds-constant-array-index");
47 CheckFactories.registerCheck<ProBoundsPointerArithmeticCheck>(
48 "cppcoreguidelines-pro-bounds-pointer-arithmetic");
49 CheckFactories.registerCheck<ProTypeConstCastCheck>(
50 "cppcoreguidelines-pro-type-const-cast");
51 CheckFactories.registerCheck<ProTypeCstyleCastCheck>(
52 "cppcoreguidelines-pro-type-cstyle-cast");
53 CheckFactories.registerCheck<ProTypeMemberInitCheck>(
54 "cppcoreguidelines-pro-type-member-init");
55 CheckFactories.registerCheck<ProTypeReinterpretCastCheck>(
56 "cppcoreguidelines-pro-type-reinterpret-cast");
57 CheckFactories.registerCheck<ProTypeStaticCastDowncastCheck>(
58 "cppcoreguidelines-pro-type-static-cast-downcast");
59 CheckFactories.registerCheck<ProTypeUnionAccessCheck>(
60 "cppcoreguidelines-pro-type-union-access");
61 CheckFactories.registerCheck<ProTypeVarargCheck>(
62 "cppcoreguidelines-pro-type-vararg");
63 CheckFactories.registerCheck<SpecialMemberFunctionsCheck>(
64 "cppcoreguidelines-special-member-functions");
65 CheckFactories.registerCheck<SlicingCheck>("cppcoreguidelines-slicing");
66 CheckFactories.registerCheck<misc::UnconventionalAssignOperatorCheck>(
67 "cppcoreguidelines-c-copy-assignment-signature");
68 }
69 };
70
71 // Register the LLVMTidyModule using this statically initialized variable.
72 static ClangTidyModuleRegistry::Add<CppCoreGuidelinesModule>
73 X("cppcoreguidelines-module", "Adds checks for the C++ Core Guidelines.");
74
75 } // namespace cppcoreguidelines
76
77 // This anchor is used to force the linker to link in the generated object file
78 // and thus register the CppCoreGuidelinesModule.
79 volatile int CppCoreGuidelinesModuleAnchorSource = 0;
80
81 } // namespace tidy
82 } // namespace clang
InterfacesGlobalInitCheck.h
clang::tidy::cppcoreguidelines::InterfacesGlobalInitCheck
Flags possible initialization order issues of static variables.
Definition: InterfacesGlobalInitCheck.h:23
clang::tidy::cppcoreguidelines::SpecialMemberFunctionsCheck
Checks for classes where some, but not all, of the special member functions are defined.
Definition: SpecialMemberFunctionsCheck.h:26
ProBoundsConstantArrayIndexCheck.h
clang::tidy::cppcoreguidelines::ProTypeUnionAccessCheck
This check flags all access to members of unions.
Definition: ProTypeUnionAccessCheck.h:24
SpecialMemberFunctionsCheck.h
clang::tidy::ClangTidyCheckFactories::registerCheck
void registerCheck(StringRef CheckName)
Registers the CheckType with the name Name.
Definition: ClangTidyModule.h:59
clang::tidy::cppcoreguidelines::ProTypeMemberInitCheck
Implements C++ Core Guidelines Type.6.
Definition: ProTypeMemberInitCheck.h:34
clang::tidy::cppcoreguidelines::CppCoreGuidelinesModule
A module containing checks of the C++ Core Guidelines.
Definition: CppCoreGuidelinesTidyModule.cpp:35
clang::tidy::cppcoreguidelines::NoMallocCheck
This checker is concerned with C-style memory management and suggest modern alternatives to it...
Definition: NoMallocCheck.h:28
clang::tidy::ClangTidyCheckFactories
A collection of ClangTidyCheckFactory instances.
Definition: ClangTidyModule.h:27
clang::tidy::cppcoreguidelines::ProTypeConstCastCheck
This check flags all instances of const_cast.
Definition: ProTypeConstCastCheck.h:23
ProTypeUnionAccessCheck.h
clang::tidy::cppcoreguidelines::SlicingCheck
Flags slicing (incomplete copying of an object&#39;s state) of member variables or vtable.
Definition: SlicingCheck.h:28
ProTypeStaticCastDowncastCheck.h
NoMallocCheck.h
SlicingCheck.h
clang::tidy::CppCoreGuidelinesModuleAnchorSource
volatile int CppCoreGuidelinesModuleAnchorSource
Definition: CppCoreGuidelinesTidyModule.cpp:79
clang::tidy::cppcoreguidelines::ProTypeCstyleCastCheck
This check flags all use of C-style casts that perform a static_cast downcast, const_cast, or reinterpret_cast.
Definition: ProTypeCstyleCastCheck.h:24
clang::tidy::ClangTidyModule
A clang-tidy module groups a number of ClangTidyChecks and gives them a prefixed name.
Definition: ClangTidyModule.h:84
ProTypeCstyleCastCheck.h
OwningMemoryCheck.h
clang::tidy::cppcoreguidelines::ProTypeReinterpretCastCheck
Flags all occurrences of reinterpret_cast.
Definition: ProTypeReinterpretCastCheck.h:23
clang::tidy::cppcoreguidelines::OwningMemoryCheck
Checks for common use cases for gsl::owner and enforces the unique owner nature of it whenever possib...
Definition: OwningMemoryCheck.h:24
ProBoundsArrayToPointerDecayCheck.h
ProTypeReinterpretCastCheck.h
ProTypeVarargCheck.h
clang::tidy::cppcoreguidelines::X
static ClangTidyModuleRegistry::Add< CppCoreGuidelinesModule > X("cppcoreguidelines-module", "Adds checks for the C++ Core Guidelines.")
clang::tidy::misc::UnconventionalAssignOperatorCheck
Finds declarations of assignment operators with the wrong return and/or argument types and definition...
Definition: UnconventionalAssignOperatorCheck.h:30
clang
Definition: AndroidTidyModule.cpp:28
ProTypeMemberInitCheck.h
clang::tidy::cppcoreguidelines::CppCoreGuidelinesModule::addCheckFactories
void addCheckFactories(ClangTidyCheckFactories &CheckFactories) override
Implement this function in order to register all CheckFactories belonging to this module...
Definition: CppCoreGuidelinesTidyModule.cpp:37
clang::tidy::cppcoreguidelines::ProBoundsArrayToPointerDecayCheck
This check flags all array to pointer decays.
Definition: ProBoundsArrayToPointerDecayCheck.h:23
clang::tidy::cppcoreguidelines::ProTypeStaticCastDowncastCheck
Checks for usages of static_cast, where a base class is downcasted to a derived class.
Definition: ProTypeStaticCastDowncastCheck.h:24
clang::tidy::cppcoreguidelines::ProTypeVarargCheck
This check flags all calls to c-style variadic functions and all use of va_arg.
Definition: ProTypeVarargCheck.h:24
ProBoundsPointerArithmeticCheck.h
clang::tidy::cppcoreguidelines::ProBoundsConstantArrayIndexCheck
This checks that all array subscriptions on static arrays and std::arrays have a constant index and a...
Definition: ProBoundsConstantArrayIndexCheck.h:25
ProTypeConstCastCheck.h
clang::tidy::cppcoreguidelines::ProBoundsPointerArithmeticCheck
Flags all kinds of pointer arithmetic that have result of pointer type, i.e.
Definition: ProBoundsPointerArithmeticCheck.h:25