blob: f39e4a1e5f6058c82a72b0cc9430f656ce0df00e [file] [log] [blame]
Alexander Kornienko2192a8e2014-10-26 01:41:14 +00001//===--- 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"
Alexander Kornienkoe3ae0c62016-03-30 11:31:33 +000013#include "AvoidConstParamsInDecls.h"
Alexander Kornienko2192a8e2014-10-26 01:41:14 +000014#include "BracesAroundStatementsCheck.h"
Alexander Kornienko1b677db2015-03-09 12:18:39 +000015#include "ContainerSizeEmptyCheck.h"
Gabor Horvath7510d9a2016-12-31 12:45:59 +000016#include "DeleteNullPointerCheck.h"
Alexander Kornienko4191b902016-04-13 11:33:40 +000017#include "DeletedDefaultCheck.h"
Daniel Jasper3b6018b2015-01-14 19:37:54 +000018#include "ElseAfterReturnCheck.h"
Alexander Kornienko1b677db2015-03-09 12:18:39 +000019#include "FunctionSizeCheck.h"
Alexander Kornienko76c28802015-08-19 11:15:36 +000020#include "IdentifierNamingCheck.h"
Alexander Kornienkof1a65522017-08-08 14:53:52 +000021#include "ImplicitBoolConversionCheck.h"
Alexander Kornienko11d4d642015-09-10 10:07:11 +000022#include "InconsistentDeclarationParameterNameCheck.h"
Gabor Horvathe647bd52017-02-14 10:03:27 +000023#include "MisleadingIndentationCheck.h"
Daniel Marjamaki03ea4682016-09-12 12:04:13 +000024#include "MisplacedArrayIndexCheck.h"
Alexander Kornienkoc5bc68e2015-03-16 22:31:16 +000025#include "NamedParameterCheck.h"
Daniel Marjamaki9e4ecfa2016-08-23 10:09:08 +000026#include "NonConstParameterCheck.h"
Aaron Ballmanc3975b72016-02-01 15:31:15 +000027#include "RedundantControlFlowCheck.h"
Daniel Marjamaki399a50c2016-11-01 13:26:15 +000028#include "RedundantDeclarationCheck.h"
Malcolm Parsonse7be4a02016-12-13 08:04:11 +000029#include "RedundantFunctionPtrDereferenceCheck.h"
Malcolm Parsons5c24a112016-10-20 16:08:03 +000030#include "RedundantMemberInitCheck.h"
Alexander Kornienko1b677db2015-03-09 12:18:39 +000031#include "RedundantSmartptrGetCheck.h"
Alexander Kornienko57a5c6b2015-03-16 00:32:25 +000032#include "RedundantStringCStrCheck.h"
Alexander Kornienko1612fa02016-02-25 23:57:23 +000033#include "RedundantStringInitCheck.h"
Alexander Kornienkof5e72b02015-04-10 19:26:43 +000034#include "SimplifyBooleanExprCheck.h"
Gabor Horvath40b65122017-08-08 15:33:48 +000035#include "StaticAccessedThroughInstanceCheck.h"
Haojian Wuc253f8b2016-04-05 11:42:08 +000036#include "StaticDefinitionInAnonymousNamespaceCheck.h"
Alexander Kornienko5c9c0422018-01-30 14:55:50 +000037#include "StringCompareCheck.h"
Samuel Benzaquendaef1632015-10-19 21:49:51 +000038#include "UniqueptrDeleteReleaseCheck.h"
Alexander Kornienko2192a8e2014-10-26 01:41:14 +000039
40namespace clang {
41namespace tidy {
42namespace readability {
43
44class ReadabilityModule : public ClangTidyModule {
45public:
46 void addCheckFactories(ClangTidyCheckFactories &CheckFactories) override {
Alexander Kornienkoe3ae0c62016-03-30 11:31:33 +000047 CheckFactories.registerCheck<AvoidConstParamsInDecls>(
48 "readability-avoid-const-params-in-decls");
Alexander Kornienko2192a8e2014-10-26 01:41:14 +000049 CheckFactories.registerCheck<BracesAroundStatementsCheck>(
50 "readability-braces-around-statements");
Alexander Kornienko4babd682015-01-15 15:46:58 +000051 CheckFactories.registerCheck<ContainerSizeEmptyCheck>(
52 "readability-container-size-empty");
Gabor Horvath7510d9a2016-12-31 12:45:59 +000053 CheckFactories.registerCheck<DeleteNullPointerCheck>(
54 "readability-delete-null-pointer");
Alexander Kornienko4191b902016-04-13 11:33:40 +000055 CheckFactories.registerCheck<DeletedDefaultCheck>(
56 "readability-deleted-default");
Daniel Jasper3b6018b2015-01-14 19:37:54 +000057 CheckFactories.registerCheck<ElseAfterReturnCheck>(
58 "readability-else-after-return");
Alexander Kornienko2192a8e2014-10-26 01:41:14 +000059 CheckFactories.registerCheck<FunctionSizeCheck>(
60 "readability-function-size");
Alexander Kornienko76c28802015-08-19 11:15:36 +000061 CheckFactories.registerCheck<IdentifierNamingCheck>(
62 "readability-identifier-naming");
Alexander Kornienkof1a65522017-08-08 14:53:52 +000063 CheckFactories.registerCheck<ImplicitBoolConversionCheck>(
64 "readability-implicit-bool-conversion");
Alexander Kornienko11d4d642015-09-10 10:07:11 +000065 CheckFactories.registerCheck<InconsistentDeclarationParameterNameCheck>(
66 "readability-inconsistent-declaration-parameter-name");
Gabor Horvathe647bd52017-02-14 10:03:27 +000067 CheckFactories.registerCheck<MisleadingIndentationCheck>(
68 "readability-misleading-indentation");
Daniel Marjamaki03ea4682016-09-12 12:04:13 +000069 CheckFactories.registerCheck<MisplacedArrayIndexCheck>(
70 "readability-misplaced-array-index");
Malcolm Parsonse7be4a02016-12-13 08:04:11 +000071 CheckFactories.registerCheck<RedundantFunctionPtrDereferenceCheck>(
72 "readability-redundant-function-ptr-dereference");
Malcolm Parsons5c24a112016-10-20 16:08:03 +000073 CheckFactories.registerCheck<RedundantMemberInitCheck>(
74 "readability-redundant-member-init");
Gabor Horvath40b65122017-08-08 15:33:48 +000075 CheckFactories.registerCheck<StaticAccessedThroughInstanceCheck>(
76 "readability-static-accessed-through-instance");
Haojian Wuc253f8b2016-04-05 11:42:08 +000077 CheckFactories.registerCheck<StaticDefinitionInAnonymousNamespaceCheck>(
78 "readability-static-definition-in-anonymous-namespace");
Alexander Kornienko5c9c0422018-01-30 14:55:50 +000079 CheckFactories.registerCheck<StringCompareCheck>(
80 "readability-string-compare");
Alexander Kornienkoc5bc68e2015-03-16 22:31:16 +000081 CheckFactories.registerCheck<readability::NamedParameterCheck>(
82 "readability-named-parameter");
Daniel Marjamaki9e4ecfa2016-08-23 10:09:08 +000083 CheckFactories.registerCheck<NonConstParameterCheck>(
84 "readability-non-const-parameter");
Eugene Zelenkodde3cd02016-02-01 19:47:24 +000085 CheckFactories.registerCheck<RedundantControlFlowCheck>(
86 "readability-redundant-control-flow");
Daniel Marjamaki399a50c2016-11-01 13:26:15 +000087 CheckFactories.registerCheck<RedundantDeclarationCheck>(
88 "readability-redundant-declaration");
Alexander Kornienko1b677db2015-03-09 12:18:39 +000089 CheckFactories.registerCheck<RedundantSmartptrGetCheck>(
Alexander Kornienko2192a8e2014-10-26 01:41:14 +000090 "readability-redundant-smartptr-get");
Alexander Kornienko57a5c6b2015-03-16 00:32:25 +000091 CheckFactories.registerCheck<RedundantStringCStrCheck>(
92 "readability-redundant-string-cstr");
Alexander Kornienko1612fa02016-02-25 23:57:23 +000093 CheckFactories.registerCheck<RedundantStringInitCheck>(
94 "readability-redundant-string-init");
Alexander Kornienkof5e72b02015-04-10 19:26:43 +000095 CheckFactories.registerCheck<SimplifyBooleanExprCheck>(
96 "readability-simplify-boolean-expr");
Eugene Zelenkodde3cd02016-02-01 19:47:24 +000097 CheckFactories.registerCheck<UniqueptrDeleteReleaseCheck>(
98 "readability-uniqueptr-delete-release");
Alexander Kornienko2192a8e2014-10-26 01:41:14 +000099 }
100};
101
Alexander Kornienko57a5c6b2015-03-16 00:32:25 +0000102// Register the ReadabilityModule using this statically initialized variable.
103static ClangTidyModuleRegistry::Add<ReadabilityModule>
104 X("readability-module", "Adds readability-related checks.");
105
Alexander Kornienko2192a8e2014-10-26 01:41:14 +0000106} // namespace readability
107
Alexander Kornienko2192a8e2014-10-26 01:41:14 +0000108// This anchor is used to force the linker to link in the generated object file
Alexander Kornienko57a5c6b2015-03-16 00:32:25 +0000109// and thus register the ReadabilityModule.
Alexander Kornienko2192a8e2014-10-26 01:41:14 +0000110volatile int ReadabilityModuleAnchorSource = 0;
111
112} // namespace tidy
113} // namespace clang