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
83