clang-tools
18.0.0git
llvm-project
clang-tools-extra
clang-tidy
readability
FunctionSizeCheck.h
Go to the documentation of this file.
1
//===--- FunctionSizeCheck.h - clang-tidy -----------------------*- C++ -*-===//
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
#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_READABILITY_FUNCTIONSIZECHECK_H
10
#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_READABILITY_FUNCTIONSIZECHECK_H
11
12
#include "../ClangTidyCheck.h"
13
14
namespace
clang::tidy::readability
{
15
16
/// Checks for large functions based on various metrics.
17
///
18
/// These options are supported:
19
///
20
/// * `LineThreshold` - flag functions exceeding this number of lines. The
21
/// default is `-1` (ignore the number of lines).
22
/// * `StatementThreshold` - flag functions exceeding this number of
23
/// statements. This may differ significantly from the number of lines for
24
/// macro-heavy code. The default is `800`.
25
/// * `BranchThreshold` - flag functions exceeding this number of control
26
/// statements. The default is `-1` (ignore the number of branches).
27
/// * `ParameterThreshold` - flag functions having a high number of
28
/// parameters. The default is `-1` (ignore the number of parameters).
29
/// * `NestingThreshold` - flag compound statements which create next nesting
30
/// level after `NestingThreshold`. This may differ significantly from the
31
/// expected value for macro-heavy code. The default is `-1` (ignore the
32
/// nesting level).
33
/// * `VariableThreshold` - flag functions having a high number of variable
34
/// declarations. The default is `-1` (ignore the number of variables).
35
class
FunctionSizeCheck
:
public
ClangTidyCheck
{
36
public
:
37
FunctionSizeCheck
(StringRef
Name
,
ClangTidyContext
*Context);
38
39
void
storeOptions
(
ClangTidyOptions::OptionMap
&Opts)
override
;
40
void
registerMatchers
(ast_matchers::MatchFinder *Finder)
override
;
41
void
check
(
const
ast_matchers::MatchFinder::MatchResult &Result)
override
;
42
43
private
:
44
const
unsigned
LineThreshold;
45
const
unsigned
StatementThreshold;
46
const
unsigned
BranchThreshold;
47
const
unsigned
ParameterThreshold;
48
const
unsigned
NestingThreshold;
49
const
unsigned
VariableThreshold;
50
};
51
52
}
// namespace clang::tidy::readability
53
54
#endif
// LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_READABILITY_FUNCTIONSIZECHECK_H
Name
llvm::StringRef Name
Definition:
HeaderIncludeCycleCheck.cpp:30
clang::tidy::ClangTidyCheck
Base class for all clang-tidy checks.
Definition:
ClangTidyCheck.h:53
clang::tidy::ClangTidyContext
Every ClangTidyCheck reports errors through a DiagnosticsEngine provided by this context.
Definition:
ClangTidyDiagnosticConsumer.h:69
clang::tidy::readability::FunctionSizeCheck
Checks for large functions based on various metrics.
Definition:
FunctionSizeCheck.h:35
clang::tidy::readability::FunctionSizeCheck::check
void check(const ast_matchers::MatchFinder::MatchResult &Result) override
ClangTidyChecks that register ASTMatchers should do the actual work in here.
Definition:
FunctionSizeCheck.cpp:154
clang::tidy::readability::FunctionSizeCheck::storeOptions
void storeOptions(ClangTidyOptions::OptionMap &Opts) override
Should store all options supported by this check with their current values or default values for opti...
Definition:
FunctionSizeCheck.cpp:136
clang::tidy::readability::FunctionSizeCheck::registerMatchers
void registerMatchers(ast_matchers::MatchFinder *Finder) override
Override this to register AST matchers with Finder.
Definition:
FunctionSizeCheck.cpp:145
clang::tidy::readability
Definition:
AvoidConstParamsInDecls.cpp:17
clang::tidy::ClangTidyOptions::OptionMap
llvm::StringMap< ClangTidyValue > OptionMap
Definition:
ClangTidyOptions.h:122
Generated on Sat Sep 23 2023 18:22:09 for clang-tools by
1.9.6