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