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