1 //===--- ReadabilityTidyModule.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 "AvoidConstParamsInDecls.h" 14 #include "BracesAroundStatementsCheck.h" 15 #include "ContainerSizeEmptyCheck.h" 16 #include "DeleteNullPointerCheck.h" 17 #include "DeletedDefaultCheck.h" 18 #include "ElseAfterReturnCheck.h" 19 #include "FunctionSizeCheck.h" 20 #include "IdentifierNamingCheck.h" 21 #include "ImplicitBoolConversionCheck.h" 22 #include "InconsistentDeclarationParameterNameCheck.h" 23 #include "MagicNumbersCheck.h" 24 #include "MisleadingIndentationCheck.h" 25 #include "MisplacedArrayIndexCheck.h" 26 #include "NamedParameterCheck.h" 27 #include "NonConstParameterCheck.h" 28 #include "RedundantControlFlowCheck.h" 29 #include "RedundantDeclarationCheck.h" 30 #include "RedundantFunctionPtrDereferenceCheck.h" 31 #include "RedundantMemberInitCheck.h" 32 #include "RedundantSmartptrGetCheck.h" 33 #include "RedundantStringCStrCheck.h" 34 #include "RedundantStringInitCheck.h" 35 #include "SimplifyBooleanExprCheck.h" 36 #include "SimplifySubscriptExprCheck.h" 37 #include "StaticAccessedThroughInstanceCheck.h" 38 #include "StaticDefinitionInAnonymousNamespaceCheck.h" 39 #include "StringCompareCheck.h" 40 #include "UniqueptrDeleteReleaseCheck.h" 41 42 namespace clang { 43 namespace tidy { 44 namespace readability { 45 46 class ReadabilityModule : public ClangTidyModule { 47 public: 48 void addCheckFactories(ClangTidyCheckFactories &CheckFactories) override { 49 CheckFactories.registerCheck<AvoidConstParamsInDecls>( 50 "readability-avoid-const-params-in-decls"); 51 CheckFactories.registerCheck<BracesAroundStatementsCheck>( 52 "readability-braces-around-statements"); 53 CheckFactories.registerCheck<ContainerSizeEmptyCheck>( 54 "readability-container-size-empty"); 55 CheckFactories.registerCheck<DeleteNullPointerCheck>( 56 "readability-delete-null-pointer"); 57 CheckFactories.registerCheck<DeletedDefaultCheck>( 58 "readability-deleted-default"); 59 CheckFactories.registerCheck<ElseAfterReturnCheck>( 60 "readability-else-after-return"); 61 CheckFactories.registerCheck<FunctionSizeCheck>( 62 "readability-function-size"); 63 CheckFactories.registerCheck<IdentifierNamingCheck>( 64 "readability-identifier-naming"); 65 CheckFactories.registerCheck<ImplicitBoolConversionCheck>( 66 "readability-implicit-bool-conversion"); 67 CheckFactories.registerCheck<InconsistentDeclarationParameterNameCheck>( 68 "readability-inconsistent-declaration-parameter-name"); 69 CheckFactories.registerCheck<MagicNumbersCheck>( 70 "readability-magic-numbers"); 71 CheckFactories.registerCheck<MisleadingIndentationCheck>( 72 "readability-misleading-indentation"); 73 CheckFactories.registerCheck<MisplacedArrayIndexCheck>( 74 "readability-misplaced-array-index"); 75 CheckFactories.registerCheck<RedundantFunctionPtrDereferenceCheck>( 76 "readability-redundant-function-ptr-dereference"); 77 CheckFactories.registerCheck<RedundantMemberInitCheck>( 78 "readability-redundant-member-init"); 79 CheckFactories.registerCheck<SimplifySubscriptExprCheck>( 80 "readability-simplify-subscript-expr"); 81 CheckFactories.registerCheck<StaticAccessedThroughInstanceCheck>( 82 "readability-static-accessed-through-instance"); 83 CheckFactories.registerCheck<StaticDefinitionInAnonymousNamespaceCheck>( 84 "readability-static-definition-in-anonymous-namespace"); 85 CheckFactories.registerCheck<StringCompareCheck>( 86 "readability-string-compare"); 87 CheckFactories.registerCheck<readability::NamedParameterCheck>( 88 "readability-named-parameter"); 89 CheckFactories.registerCheck<NonConstParameterCheck>( 90 "readability-non-const-parameter"); 91 CheckFactories.registerCheck<RedundantControlFlowCheck>( 92 "readability-redundant-control-flow"); 93 CheckFactories.registerCheck<RedundantDeclarationCheck>( 94 "readability-redundant-declaration"); 95 CheckFactories.registerCheck<RedundantSmartptrGetCheck>( 96 "readability-redundant-smartptr-get"); 97 CheckFactories.registerCheck<RedundantStringCStrCheck>( 98 "readability-redundant-string-cstr"); 99 CheckFactories.registerCheck<RedundantStringInitCheck>( 100 "readability-redundant-string-init"); 101 CheckFactories.registerCheck<SimplifyBooleanExprCheck>( 102 "readability-simplify-boolean-expr"); 103 CheckFactories.registerCheck<UniqueptrDeleteReleaseCheck>( 104 "readability-uniqueptr-delete-release"); 105 } 106 }; 107 108 // Register the ReadabilityModule using this statically initialized variable. 109 static ClangTidyModuleRegistry::Add<ReadabilityModule> 110 X("readability-module", "Adds readability-related checks."); 111 112 } // namespace readability 113 114 // This anchor is used to force the linker to link in the generated object file 115 // and thus register the ReadabilityModule. 116 volatile int ReadabilityModuleAnchorSource = 0; 117 118 } // namespace tidy 119 } // namespace clang 120