blob: ed40330c3cdc3f53189054ccd2043734baf31568 [file] [log] [blame]
Alexander Kornienko1b677db2015-03-09 12:18:39 +00001//===--- FunctionSizeCheck.h - clang-tidy -----------------------*- C++ -*-===//
Benjamin Kramer6e195422014-09-15 12:48:25 +00002//
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
Alexander Kornienko1b677db2015-03-09 12:18:39 +000010#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_READABILITY_FUNCTIONSIZECHECK_H
11#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_READABILITY_FUNCTIONSIZECHECK_H
Benjamin Kramer6e195422014-09-15 12:48:25 +000012
13#include "../ClangTidy.h"
14
15namespace clang {
16namespace tidy {
Alexander Kornienko35ddae42014-10-15 10:51:57 +000017namespace readability {
Benjamin Kramer6e195422014-09-15 12:48:25 +000018
Alexander Kornienkof8ed0a82015-08-27 18:01:58 +000019/// 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).
Benjamin Kramer6e195422014-09-15 12:48:25 +000030class FunctionSizeCheck : public ClangTidyCheck {
31public:
32 FunctionSizeCheck(StringRef Name, ClangTidyContext *Context);
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;
Benjamin Kramer6e195422014-09-15 12:48:25 +000037
38private:
Benjamin Kramer6e195422014-09-15 12:48:25 +000039 const unsigned LineThreshold;
40 const unsigned StatementThreshold;
41 const unsigned BranchThreshold;
Benjamin Kramer6e195422014-09-15 12:48:25 +000042};
43
Alexander Kornienko35ddae42014-10-15 10:51:57 +000044} // namespace readability
Benjamin Kramer6e195422014-09-15 12:48:25 +000045} // namespace tidy
46} // namespace clang
47
Alexander Kornienko1b677db2015-03-09 12:18:39 +000048#endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_READABILITY_FUNCTIONSIZECHECK_H