clang-tools
8.0.0
llvm.src
tools
clang
tools
extra
clang-tidy
readability
FunctionSizeCheck.h
Go to the documentation of this file.
1
//===--- FunctionSizeCheck.h - clang-tidy -----------------------*- C++ -*-===//
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
#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_READABILITY_FUNCTIONSIZECHECK_H
11
#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_READABILITY_FUNCTIONSIZECHECK_H
12
13
#include "../ClangTidy.h"
14
15
namespace
clang
{
16
namespace
tidy {
17
namespace
readability {
18
19
/// Checks for large functions based on various metrics.
20
///
21
/// These options are supported:
22
///
23
/// * `LineThreshold` - flag functions exceeding this number of lines. The
24
/// default is `-1` (ignore the number of lines).
25
/// * `StatementThreshold` - flag functions exceeding this number of
26
/// statements. This may differ significantly from the number of lines for
27
/// macro-heavy code. The default is `800`.
28
/// * `BranchThreshold` - flag functions exceeding this number of control
29
/// statements. The default is `-1` (ignore the number of branches).
30
/// * `ParameterThreshold` - flag functions having a high number of
31
/// parameters. The default is `-1` (ignore the number of parameters).
32
/// * `NestingThreshold` - flag compound statements which create next nesting
33
/// level after `NestingThreshold`. This may differ significantly from the
34
/// expected value for macro-heavy code. The default is `-1` (ignore the
35
/// nesting level).
36
/// * `VariableThreshold` - flag functions having a high number of variable
37
/// declarations. The default is `-1` (ignore the number of variables).
38
class
FunctionSizeCheck
:
public
ClangTidyCheck
{
39
public
:
40
FunctionSizeCheck
(StringRef
Name
,
ClangTidyContext
*Context);
41
42
void
storeOptions
(
ClangTidyOptions::OptionMap
&Opts)
override
;
43
void
registerMatchers
(ast_matchers::MatchFinder *Finder)
override
;
44
void
check
(
const
ast_matchers::MatchFinder::MatchResult &
Result
)
override
;
45
46
private
:
47
const
unsigned
LineThreshold;
48
const
unsigned
StatementThreshold;
49
const
unsigned
BranchThreshold;
50
const
unsigned
ParameterThreshold;
51
const
unsigned
NestingThreshold;
52
const
unsigned
VariableThreshold;
53
};
54
55
}
// namespace readability
56
}
// namespace tidy
57
}
// namespace clang
58
59
#endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_READABILITY_FUNCTIONSIZECHECK_H
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:138
clang::tidy::ClangTidyCheck
Base class for all clang-tidy checks.
Definition:
ClangTidy.h:127
clang::tidy::readability::FunctionSizeCheck::FunctionSizeCheck
FunctionSizeCheck(StringRef Name, ClangTidyContext *Context)
Definition:
FunctionSizeCheck.cpp:129
clang::tidy::readability::FunctionSizeCheck
Checks for large functions based on various metrics.
Definition:
FunctionSizeCheck.h:38
Name
static constexpr llvm::StringLiteral Name
Definition:
UppercaseLiteralSuffixCheck.cpp:28
clang::tidy::ClangTidyOptions::OptionMap
std::map< std::string, std::string > OptionMap
Definition:
ClangTidyOptions.h:98
Result
llvm::Optional< llvm::Expected< tooling::AtomicChanges > > Result
Definition:
ClangdServer.cpp:60
clang
===– Representation.cpp - ClangDoc Representation --------—*- C++ -*-===//
Definition:
ChangeNamespace.cpp:18
clang::tidy::ClangTidyContext
Every ClangTidyCheck reports errors through a DiagnosticsEngine provided by this context.
Definition:
ClangTidyDiagnosticConsumer.h:100
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:156
clang::tidy::readability::FunctionSizeCheck::registerMatchers
void registerMatchers(ast_matchers::MatchFinder *Finder) override
Override this to register AST matchers with Finder.
Definition:
FunctionSizeCheck.cpp:147
Generated on Tue Mar 12 2019 12:25:46 for clang-tools by
1.8.13