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 "ProBoundsArrayToPointerDecayCheck.h"
17 #include "ProBoundsConstantArrayIndexCheck.h"
18 #include "ProBoundsPointerArithmeticCheck.h"
19 #include "ProTypeConstCastCheck.h"
20 #include "ProTypeCstyleCastCheck.h"
21 #include "ProTypeMemberInitCheck.h"
22 #include "ProTypeReinterpretCastCheck.h"
23 #include "ProTypeStaticCastDowncastCheck.h"
24 #include "ProTypeUnionAccessCheck.h"
25 #include "ProTypeVarargCheck.h"
26 #include "SlicingCheck.h"
27 #include "SpecialMemberFunctionsCheck.h"
28 
29 namespace clang {
30 namespace tidy {
31 namespace cppcoreguidelines {
32 
33 /// A module containing checks of the C++ Core Guidelines
34 class CppCoreGuidelinesModule : public ClangTidyModule {
35 public:
36   void addCheckFactories(ClangTidyCheckFactories &CheckFactories) override {
37     CheckFactories.registerCheck<InterfacesGlobalInitCheck>(
38         "cppcoreguidelines-interfaces-global-init");
39     CheckFactories.registerCheck<NoMallocCheck>("cppcoreguidelines-no-malloc");
40     CheckFactories.registerCheck<ProBoundsArrayToPointerDecayCheck>(
41         "cppcoreguidelines-pro-bounds-array-to-pointer-decay");
42     CheckFactories.registerCheck<ProBoundsConstantArrayIndexCheck>(
43         "cppcoreguidelines-pro-bounds-constant-array-index");
44     CheckFactories.registerCheck<ProBoundsPointerArithmeticCheck>(
45         "cppcoreguidelines-pro-bounds-pointer-arithmetic");
46     CheckFactories.registerCheck<ProTypeConstCastCheck>(
47         "cppcoreguidelines-pro-type-const-cast");
48     CheckFactories.registerCheck<ProTypeCstyleCastCheck>(
49         "cppcoreguidelines-pro-type-cstyle-cast");
50     CheckFactories.registerCheck<ProTypeMemberInitCheck>(
51         "cppcoreguidelines-pro-type-member-init");
52     CheckFactories.registerCheck<ProTypeReinterpretCastCheck>(
53         "cppcoreguidelines-pro-type-reinterpret-cast");
54     CheckFactories.registerCheck<ProTypeStaticCastDowncastCheck>(
55         "cppcoreguidelines-pro-type-static-cast-downcast");
56     CheckFactories.registerCheck<ProTypeUnionAccessCheck>(
57         "cppcoreguidelines-pro-type-union-access");
58     CheckFactories.registerCheck<ProTypeVarargCheck>(
59         "cppcoreguidelines-pro-type-vararg");
60     CheckFactories.registerCheck<SpecialMemberFunctionsCheck>(
61         "cppcoreguidelines-special-member-functions");
62     CheckFactories.registerCheck<SlicingCheck>("cppcoreguidelines-slicing");
63     CheckFactories.registerCheck<misc::UnconventionalAssignOperatorCheck>(
64         "cppcoreguidelines-c-copy-assignment-signature");
65   }
66 };
67 
68 // Register the LLVMTidyModule using this statically initialized variable.
69 static ClangTidyModuleRegistry::Add<CppCoreGuidelinesModule>
70     X("cppcoreguidelines-module", "Adds checks for the C++ Core Guidelines.");
71 
72 } // namespace cppcoreguidelines
73 
74 // This anchor is used to force the linker to link in the generated object file
75 // and thus register the CppCoreGuidelinesModule.
76 volatile int CppCoreGuidelinesModuleAnchorSource = 0;
77 
78 } // namespace tidy
79 } // namespace clang
80