202 lines · cpp
1//===----------------------------------------------------------------------===//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-exception6//7//===----------------------------------------------------------------------===//8 9#include "../ClangTidy.h"10#include "../ClangTidyModule.h"11#include "../ClangTidyModuleRegistry.h"12#include "AmbiguousSmartptrResetCallCheck.h"13#include "AvoidConstParamsInDeclsCheck.h"14#include "AvoidNestedConditionalOperatorCheck.h"15#include "AvoidReturnWithVoidValueCheck.h"16#include "AvoidUnconditionalPreprocessorIfCheck.h"17#include "BracesAroundStatementsCheck.h"18#include "ConstReturnTypeCheck.h"19#include "ContainerContainsCheck.h"20#include "ContainerDataPointerCheck.h"21#include "ContainerSizeEmptyCheck.h"22#include "ConvertMemberFunctionsToStaticCheck.h"23#include "DeleteNullPointerCheck.h"24#include "DuplicateIncludeCheck.h"25#include "ElseAfterReturnCheck.h"26#include "EnumInitialValueCheck.h"27#include "FunctionCognitiveComplexityCheck.h"28#include "FunctionSizeCheck.h"29#include "IdentifierLengthCheck.h"30#include "IdentifierNamingCheck.h"31#include "ImplicitBoolConversionCheck.h"32#include "InconsistentDeclarationParameterNameCheck.h"33#include "IsolateDeclarationCheck.h"34#include "MagicNumbersCheck.h"35#include "MakeMemberFunctionConstCheck.h"36#include "MathMissingParenthesesCheck.h"37#include "MisleadingIndentationCheck.h"38#include "MisplacedArrayIndexCheck.h"39#include "NamedParameterCheck.h"40#include "NonConstParameterCheck.h"41#include "OperatorsRepresentationCheck.h"42#include "QualifiedAutoCheck.h"43#include "RedundantAccessSpecifiersCheck.h"44#include "RedundantCastingCheck.h"45#include "RedundantControlFlowCheck.h"46#include "RedundantDeclarationCheck.h"47#include "RedundantFunctionPtrDereferenceCheck.h"48#include "RedundantInlineSpecifierCheck.h"49#include "RedundantMemberInitCheck.h"50#include "RedundantParenthesesCheck.h"51#include "RedundantPreprocessorCheck.h"52#include "RedundantSmartptrGetCheck.h"53#include "RedundantStringCStrCheck.h"54#include "RedundantStringInitCheck.h"55#include "RedundantTypenameCheck.h"56#include "ReferenceToConstructedTemporaryCheck.h"57#include "SimplifyBooleanExprCheck.h"58#include "SimplifySubscriptExprCheck.h"59#include "StaticAccessedThroughInstanceCheck.h"60#include "StaticDefinitionInAnonymousNamespaceCheck.h"61#include "StringCompareCheck.h"62#include "SuspiciousCallArgumentCheck.h"63#include "UniqueptrDeleteReleaseCheck.h"64#include "UppercaseLiteralSuffixCheck.h"65#include "UseAnyOfAllOfCheck.h"66#include "UseConcisePreprocessorDirectivesCheck.h"67#include "UseStdMinMaxCheck.h"68 69namespace clang::tidy {70namespace readability {71 72class ReadabilityModule : public ClangTidyModule {73public:74 void addCheckFactories(ClangTidyCheckFactories &CheckFactories) override {75 CheckFactories.registerCheck<AmbiguousSmartptrResetCallCheck>(76 "readability-ambiguous-smartptr-reset-call");77 CheckFactories.registerCheck<AvoidConstParamsInDeclsCheck>(78 "readability-avoid-const-params-in-decls");79 CheckFactories.registerCheck<AvoidNestedConditionalOperatorCheck>(80 "readability-avoid-nested-conditional-operator");81 CheckFactories.registerCheck<AvoidReturnWithVoidValueCheck>(82 "readability-avoid-return-with-void-value");83 CheckFactories.registerCheck<AvoidUnconditionalPreprocessorIfCheck>(84 "readability-avoid-unconditional-preprocessor-if");85 CheckFactories.registerCheck<BracesAroundStatementsCheck>(86 "readability-braces-around-statements");87 CheckFactories.registerCheck<ConstReturnTypeCheck>(88 "readability-const-return-type");89 CheckFactories.registerCheck<ContainerContainsCheck>(90 "readability-container-contains");91 CheckFactories.registerCheck<ContainerDataPointerCheck>(92 "readability-container-data-pointer");93 CheckFactories.registerCheck<ContainerSizeEmptyCheck>(94 "readability-container-size-empty");95 CheckFactories.registerCheck<ConvertMemberFunctionsToStaticCheck>(96 "readability-convert-member-functions-to-static");97 CheckFactories.registerCheck<DeleteNullPointerCheck>(98 "readability-delete-null-pointer");99 CheckFactories.registerCheck<DuplicateIncludeCheck>(100 "readability-duplicate-include");101 CheckFactories.registerCheck<ElseAfterReturnCheck>(102 "readability-else-after-return");103 CheckFactories.registerCheck<EnumInitialValueCheck>(104 "readability-enum-initial-value");105 CheckFactories.registerCheck<FunctionCognitiveComplexityCheck>(106 "readability-function-cognitive-complexity");107 CheckFactories.registerCheck<FunctionSizeCheck>(108 "readability-function-size");109 CheckFactories.registerCheck<IdentifierLengthCheck>(110 "readability-identifier-length");111 CheckFactories.registerCheck<IdentifierNamingCheck>(112 "readability-identifier-naming");113 CheckFactories.registerCheck<ImplicitBoolConversionCheck>(114 "readability-implicit-bool-conversion");115 CheckFactories.registerCheck<MathMissingParenthesesCheck>(116 "readability-math-missing-parentheses");117 CheckFactories.registerCheck<RedundantInlineSpecifierCheck>(118 "readability-redundant-inline-specifier");119 CheckFactories.registerCheck<InconsistentDeclarationParameterNameCheck>(120 "readability-inconsistent-declaration-parameter-name");121 CheckFactories.registerCheck<IsolateDeclarationCheck>(122 "readability-isolate-declaration");123 CheckFactories.registerCheck<MagicNumbersCheck>(124 "readability-magic-numbers");125 CheckFactories.registerCheck<MakeMemberFunctionConstCheck>(126 "readability-make-member-function-const");127 CheckFactories.registerCheck<MisleadingIndentationCheck>(128 "readability-misleading-indentation");129 CheckFactories.registerCheck<MisplacedArrayIndexCheck>(130 "readability-misplaced-array-index");131 CheckFactories.registerCheck<OperatorsRepresentationCheck>(132 "readability-operators-representation");133 CheckFactories.registerCheck<QualifiedAutoCheck>(134 "readability-qualified-auto");135 CheckFactories.registerCheck<RedundantAccessSpecifiersCheck>(136 "readability-redundant-access-specifiers");137 CheckFactories.registerCheck<RedundantCastingCheck>(138 "readability-redundant-casting");139 CheckFactories.registerCheck<RedundantFunctionPtrDereferenceCheck>(140 "readability-redundant-function-ptr-dereference");141 CheckFactories.registerCheck<RedundantMemberInitCheck>(142 "readability-redundant-member-init");143 CheckFactories.registerCheck<RedundantParenthesesCheck>(144 "readability-redundant-parentheses");145 CheckFactories.registerCheck<RedundantPreprocessorCheck>(146 "readability-redundant-preprocessor");147 CheckFactories.registerCheck<RedundantTypenameCheck>(148 "readability-redundant-typename");149 CheckFactories.registerCheck<ReferenceToConstructedTemporaryCheck>(150 "readability-reference-to-constructed-temporary");151 CheckFactories.registerCheck<SimplifySubscriptExprCheck>(152 "readability-simplify-subscript-expr");153 CheckFactories.registerCheck<StaticAccessedThroughInstanceCheck>(154 "readability-static-accessed-through-instance");155 CheckFactories.registerCheck<StaticDefinitionInAnonymousNamespaceCheck>(156 "readability-static-definition-in-anonymous-namespace");157 CheckFactories.registerCheck<StringCompareCheck>(158 "readability-string-compare");159 CheckFactories.registerCheck<readability::NamedParameterCheck>(160 "readability-named-parameter");161 CheckFactories.registerCheck<NonConstParameterCheck>(162 "readability-non-const-parameter");163 CheckFactories.registerCheck<RedundantControlFlowCheck>(164 "readability-redundant-control-flow");165 CheckFactories.registerCheck<RedundantDeclarationCheck>(166 "readability-redundant-declaration");167 CheckFactories.registerCheck<RedundantSmartptrGetCheck>(168 "readability-redundant-smartptr-get");169 CheckFactories.registerCheck<RedundantStringCStrCheck>(170 "readability-redundant-string-cstr");171 CheckFactories.registerCheck<RedundantStringInitCheck>(172 "readability-redundant-string-init");173 CheckFactories.registerCheck<SimplifyBooleanExprCheck>(174 "readability-simplify-boolean-expr");175 CheckFactories.registerCheck<SuspiciousCallArgumentCheck>(176 "readability-suspicious-call-argument");177 CheckFactories.registerCheck<UniqueptrDeleteReleaseCheck>(178 "readability-uniqueptr-delete-release");179 CheckFactories.registerCheck<UppercaseLiteralSuffixCheck>(180 "readability-uppercase-literal-suffix");181 CheckFactories.registerCheck<UseAnyOfAllOfCheck>(182 "readability-use-anyofallof");183 CheckFactories.registerCheck<UseConcisePreprocessorDirectivesCheck>(184 "readability-use-concise-preprocessor-directives");185 CheckFactories.registerCheck<UseStdMinMaxCheck>(186 "readability-use-std-min-max");187 }188};189 190// Register the ReadabilityModule using this statically initialized variable.191static ClangTidyModuleRegistry::Add<ReadabilityModule>192 X("readability-module", "Adds readability-related checks.");193 194} // namespace readability195 196// This anchor is used to force the linker to link in the generated object file197// and thus register the ReadabilityModule.198// NOLINTNEXTLINE(misc-use-internal-linkage)199volatile int ReadabilityModuleAnchorSource = 0;200 201} // namespace clang::tidy202