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