clang-tools  4.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).
31 public:
33 
34  void storeOptions(ClangTidyOptions::OptionMap &Opts) override;
35  void registerMatchers(ast_matchers::MatchFinder *Finder) override;
36  void check(const ast_matchers::MatchFinder::MatchResult &Result) override;
37 
38 private:
39  const unsigned LineThreshold;
40  const unsigned StatementThreshold;
41  const unsigned BranchThreshold;
42 };
43 
44 } // namespace readability
45 } // namespace tidy
46 } // namespace clang
47 
48 #endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_READABILITY_FUNCTIONSIZECHECK_H
const std::string Name
Definition: USRFinder.cpp:164
std::unique_ptr< ast_matchers::MatchFinder > Finder
Definition: ClangTidy.cpp:262
void storeOptions(ClangTidyOptions::OptionMap &Opts) override
Should store all options supported by this check with their current values or default values for opti...
Base class for all clang-tidy checks.
Definition: ClangTidy.h:127
FunctionSizeCheck(StringRef Name, ClangTidyContext *Context)
Checks for large functions based on various metrics.
std::map< std::string, std::string > OptionMap
ClangTidyContext & Context
Definition: ClangTidy.cpp:87
Every ClangTidyCheck reports errors through a DiagnosticsEngine provided by this context.
void check(const ast_matchers::MatchFinder::MatchResult &Result) override
ClangTidyChecks that register ASTMatchers should do the actual work in here.
void registerMatchers(ast_matchers::MatchFinder *Finder) override
Override this to register AST matchers with Finder.
const NamedDecl * Result
Definition: USRFinder.cpp:162