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