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/AssignOperatorSignatureCheck.h"
14 #include "ProBoundsPointerArithmeticCheck.h"
15 #include "ProTypeConstCastCheck.h"
16 #include "ProTypeReinterpretCastCheck.h"
17 #include "ProTypeStaticCastDowncastCheck.h"
18 #include "ProTypeUnionAccessCheck.h"
19 #include "ProTypeVarargCheck.h"
20 
21 namespace clang {
22 namespace tidy {
23 namespace cppcoreguidelines {
24 
25 /// A module containing checks of the C++ Core Guidelines
26 class CppCoreGuidelinesModule : public ClangTidyModule {
27 public:
28   void addCheckFactories(ClangTidyCheckFactories &CheckFactories) override {
29     CheckFactories.registerCheck<ProBoundsPointerArithmeticCheck>(
30         "cppcoreguidelines-pro-bounds-pointer-arithmetic");
31     CheckFactories.registerCheck<ProTypeConstCastCheck>(
32         "cppcoreguidelines-pro-type-const-cast");
33     CheckFactories.registerCheck<ProTypeReinterpretCastCheck>(
34         "cppcoreguidelines-pro-type-reinterpret-cast");
35     CheckFactories.registerCheck<ProTypeStaticCastDowncastCheck>(
36         "cppcoreguidelines-pro-type-static-cast-downcast");
37     CheckFactories.registerCheck<ProTypeUnionAccessCheck>(
38         "cppcoreguidelines-pro-type-union-access");
39     CheckFactories.registerCheck<ProTypeVarargCheck>(
40         "cppcoreguidelines-pro-type-vararg");
41     CheckFactories.registerCheck<misc::AssignOperatorSignatureCheck>(
42         "cppcoreguidelines-c-copy-assignment-signature");
43   }
44 };
45 
46 // Register the LLVMTidyModule using this statically initialized variable.
47 static ClangTidyModuleRegistry::Add<CppCoreGuidelinesModule>
48     X("cppcoreguidelines-module", "Adds checks for the C++ Core Guidelines.");
49 
50 } // namespace cppcoreguidelines
51 
52 // This anchor is used to force the linker to link in the generated object file
53 // and thus register the CppCoreGuidelinesModule.
54 volatile int CppCoreGuidelinesModuleAnchorSource = 0;
55 
56 } // namespace tidy
57 } // namespace clang
58