|
|
|||
File indexing completed on 2026-05-10 08:36:21
0001 //===--- FunctionSizeCheck.h - clang-tidy -----------------------*- C++ -*-===// 0002 // 0003 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 0004 // See https://llvm.org/LICENSE.txt for license information. 0005 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 0006 // 0007 //===----------------------------------------------------------------------===// 0008 0009 #ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_READABILITY_FUNCTIONSIZECHECK_H 0010 #define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_READABILITY_FUNCTIONSIZECHECK_H 0011 0012 #include "../ClangTidyCheck.h" 0013 0014 namespace clang::tidy::readability { 0015 0016 /// Checks for large functions based on various metrics. 0017 /// 0018 /// These options are supported: 0019 /// 0020 /// * `LineThreshold` - flag functions exceeding this number of lines. The 0021 /// default is `-1` (ignore the number of lines). 0022 /// * `StatementThreshold` - flag functions exceeding this number of 0023 /// statements. This may differ significantly from the number of lines for 0024 /// macro-heavy code. The default is `800`. 0025 /// * `BranchThreshold` - flag functions exceeding this number of control 0026 /// statements. The default is `-1` (ignore the number of branches). 0027 /// * `ParameterThreshold` - flag functions having a high number of 0028 /// parameters. The default is `-1` (ignore the number of parameters). 0029 /// * `NestingThreshold` - flag compound statements which create next nesting 0030 /// level after `NestingThreshold`. This may differ significantly from the 0031 /// expected value for macro-heavy code. The default is `-1` (ignore the 0032 /// nesting level). 0033 /// * `VariableThreshold` - flag functions having a high number of variable 0034 /// declarations. The default is `-1` (ignore the number of variables). 0035 class FunctionSizeCheck : public ClangTidyCheck { 0036 public: 0037 FunctionSizeCheck(StringRef Name, ClangTidyContext *Context); 0038 0039 void storeOptions(ClangTidyOptions::OptionMap &Opts) override; 0040 void registerMatchers(ast_matchers::MatchFinder *Finder) override; 0041 void check(const ast_matchers::MatchFinder::MatchResult &Result) override; 0042 0043 private: 0044 const std::optional<unsigned> LineThreshold; 0045 const std::optional<unsigned> StatementThreshold; 0046 const std::optional<unsigned> BranchThreshold; 0047 const std::optional<unsigned> ParameterThreshold; 0048 const std::optional<unsigned> NestingThreshold; 0049 const std::optional<unsigned> VariableThreshold; 0050 0051 static constexpr std::optional<unsigned> DefaultLineThreshold = std::nullopt; 0052 static constexpr std::optional<unsigned> DefaultStatementThreshold = 800U; 0053 static constexpr std::optional<unsigned> DefaultBranchThreshold = 0054 std::nullopt; 0055 static constexpr std::optional<unsigned> DefaultParameterThreshold = 0056 std::nullopt; 0057 static constexpr std::optional<unsigned> DefaultNestingThreshold = 0058 std::nullopt; 0059 static constexpr std::optional<unsigned> DefaultVariableThreshold = 0060 std::nullopt; 0061 }; 0062 0063 } // namespace clang::tidy::readability 0064 0065 #endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_READABILITY_FUNCTIONSIZECHECK_H
| [ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
|
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |
|