1 //===--- ReadabilityTidyModule.cpp - clang-tidy ---------------------------===// 2 // 3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4 // See https://llvm.org/LICENSE.txt for license information. 5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 // 7 //===----------------------------------------------------------------------===// 8 9 #include "../ClangTidy.h" 10 #include "../ClangTidyModule.h" 11 #include "../ClangTidyModuleRegistry.h" 12 #include "AvoidConstParamsInDecls.h" 13 #include "BracesAroundStatementsCheck.h" 14 #include "ConstReturnTypeCheck.h" 15 #include "ContainerSizeEmptyCheck.h" 16 #include "ConvertMemberFunctionsToStatic.h" 17 #include "DeleteNullPointerCheck.h" 18 #include "DeletedDefaultCheck.h" 19 #include "ElseAfterReturnCheck.h" 20 #include "FunctionSizeCheck.h" 21 #include "IdentifierNamingCheck.h" 22 #include "ImplicitBoolConversionCheck.h" 23 #include "InconsistentDeclarationParameterNameCheck.h" 24 #include "IsolateDeclarationCheck.h" 25 #include "MagicNumbersCheck.h" 26 #include "MisleadingIndentationCheck.h" 27 #include "MisplacedArrayIndexCheck.h" 28 #include "NamedParameterCheck.h" 29 #include "NonConstParameterCheck.h" 30 #include "RedundantControlFlowCheck.h" 31 #include "RedundantDeclarationCheck.h" 32 #include "RedundantFunctionPtrDereferenceCheck.h" 33 #include "RedundantMemberInitCheck.h" 34 #include "RedundantPreprocessorCheck.h" 35 #include "RedundantSmartptrGetCheck.h" 36 #include "RedundantStringCStrCheck.h" 37 #include "RedundantStringInitCheck.h" 38 #include "SimplifyBooleanExprCheck.h" 39 #include "SimplifySubscriptExprCheck.h" 40 #include "StaticAccessedThroughInstanceCheck.h" 41 #include "StaticDefinitionInAnonymousNamespaceCheck.h" 42 #include "StringCompareCheck.h" 43 #include "UniqueptrDeleteReleaseCheck.h" 44 #include "UppercaseLiteralSuffixCheck.h" 45 46 namespace clang { 47 namespace tidy { 48 namespace readability { 49 50 class ReadabilityModule : public ClangTidyModule { 51 public: 52 void addCheckFactories(ClangTidyCheckFactories &CheckFactories) override { 53 CheckFactories.registerCheck<AvoidConstParamsInDecls>( 54 "readability-avoid-const-params-in-decls"); 55 CheckFactories.registerCheck<BracesAroundStatementsCheck>( 56 "readability-braces-around-statements"); 57 CheckFactories.registerCheck<ConstReturnTypeCheck>( 58 "readability-const-return-type"); 59 CheckFactories.registerCheck<ContainerSizeEmptyCheck>( 60 "readability-container-size-empty"); 61 CheckFactories.registerCheck<ConvertMemberFunctionsToStatic>( 62 "readability-convert-member-functions-to-static"); 63 CheckFactories.registerCheck<DeleteNullPointerCheck>( 64 "readability-delete-null-pointer"); 65 CheckFactories.registerCheck<DeletedDefaultCheck>( 66 "readability-deleted-default"); 67 CheckFactories.registerCheck<ElseAfterReturnCheck>( 68 "readability-else-after-return"); 69 CheckFactories.registerCheck<FunctionSizeCheck>( 70 "readability-function-size"); 71 CheckFactories.registerCheck<IdentifierNamingCheck>( 72 "readability-identifier-naming"); 73 CheckFactories.registerCheck<ImplicitBoolConversionCheck>( 74 "readability-implicit-bool-conversion"); 75 CheckFactories.registerCheck<InconsistentDeclarationParameterNameCheck>( 76 "readability-inconsistent-declaration-parameter-name"); 77 CheckFactories.registerCheck<IsolateDeclarationCheck>( 78 "readability-isolate-declaration"); 79 CheckFactories.registerCheck<MagicNumbersCheck>( 80 "readability-magic-numbers"); 81 CheckFactories.registerCheck<MisleadingIndentationCheck>( 82 "readability-misleading-indentation"); 83 CheckFactories.registerCheck<MisplacedArrayIndexCheck>( 84 "readability-misplaced-array-index"); 85 CheckFactories.registerCheck<RedundantFunctionPtrDereferenceCheck>( 86 "readability-redundant-function-ptr-dereference"); 87 CheckFactories.registerCheck<RedundantMemberInitCheck>( 88 "readability-redundant-member-init"); 89 CheckFactories.registerCheck<RedundantPreprocessorCheck>( 90 "readability-redundant-preprocessor"); 91 CheckFactories.registerCheck<SimplifySubscriptExprCheck>( 92 "readability-simplify-subscript-expr"); 93 CheckFactories.registerCheck<StaticAccessedThroughInstanceCheck>( 94 "readability-static-accessed-through-instance"); 95 CheckFactories.registerCheck<StaticDefinitionInAnonymousNamespaceCheck>( 96 "readability-static-definition-in-anonymous-namespace"); 97 CheckFactories.registerCheck<StringCompareCheck>( 98 "readability-string-compare"); 99 CheckFactories.registerCheck<readability::NamedParameterCheck>( 100 "readability-named-parameter"); 101 CheckFactories.registerCheck<NonConstParameterCheck>( 102 "readability-non-const-parameter"); 103 CheckFactories.registerCheck<RedundantControlFlowCheck>( 104 "readability-redundant-control-flow"); 105 CheckFactories.registerCheck<RedundantDeclarationCheck>( 106 "readability-redundant-declaration"); 107 CheckFactories.registerCheck<RedundantSmartptrGetCheck>( 108 "readability-redundant-smartptr-get"); 109 CheckFactories.registerCheck<RedundantStringCStrCheck>( 110 "readability-redundant-string-cstr"); 111 CheckFactories.registerCheck<RedundantStringInitCheck>( 112 "readability-redundant-string-init"); 113 CheckFactories.registerCheck<SimplifyBooleanExprCheck>( 114 "readability-simplify-boolean-expr"); 115 CheckFactories.registerCheck<UniqueptrDeleteReleaseCheck>( 116 "readability-uniqueptr-delete-release"); 117 CheckFactories.registerCheck<UppercaseLiteralSuffixCheck>( 118 "readability-uppercase-literal-suffix"); 119 } 120 }; 121 122 // Register the ReadabilityModule using this statically initialized variable. 123 static ClangTidyModuleRegistry::Add<ReadabilityModule> 124 X("readability-module", "Adds readability-related checks."); 125 126 } // namespace readability 127 128 // This anchor is used to force the linker to link in the generated object file 129 // and thus register the ReadabilityModule. 130 volatile int ReadabilityModuleAnchorSource = 0; 131 132 } // namespace tidy 133 } // namespace clang 134