clang-tools 6.0.0

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 class FunctionSizeCheck : public ClangTidyCheck {
37 public:
38 FunctionSizeCheck(StringRef Name, ClangTidyContext *Context);
39
40 void storeOptions(ClangTidyOptions::OptionMap &Opts) override;
41 void registerMatchers(ast_matchers::MatchFinder *Finder) override;
42 void check(const ast_matchers::MatchFinder::MatchResult &Result) override;
43
44 private:
45 const unsigned LineThreshold;
46 const unsigned StatementThreshold;
47 const unsigned BranchThreshold;
48 const unsigned ParameterThreshold;
49 const unsigned NestingThreshold;
50 };
51
52 } // namespace readability
53 } // namespace tidy
54 } // namespace clang
55
56 #endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_READABILITY_FUNCTIONSIZECHECK_H
Name
StringHandle Name
Definition: PreprocessorTracker.cpp:525
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:99
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:91
clang::tidy::readability::FunctionSizeCheck
Checks for large functions based on various metrics.
Definition: FunctionSizeCheck.h:36
clang::tidy::ClangTidyOptions::OptionMap
std::map< std::string, std::string > OptionMap
Definition: ClangTidyOptions.h:99
clang
Definition: AndroidTidyModule.cpp:28
clang::tidy::ClangTidyContext
Every ClangTidyCheck reports errors through a DiagnosticsEngine provided by this context.
Definition: ClangTidyDiagnosticConsumer.h:104
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:111
clang::tidy::readability::FunctionSizeCheck::registerMatchers
void registerMatchers(ast_matchers::MatchFinder *Finder) override
Override this to register AST matchers with Finder.
Definition: FunctionSizeCheck.cpp:107