1 //===--- IdentifierLengthCheck.h - clang-tidy ---------------------*- C++
2 //-*-===//
3 //
4 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
5 // See https://llvm.org/LICENSE.txt for license information.
6 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //
8 //===----------------------------------------------------------------------===//
9 
10 #ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_READABILITY_IDENTIFIERLENGTHCHECK_H
11 #define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_READABILITY_IDENTIFIERLENGTHCHECK_H
12 
13 #include "../ClangTidyCheck.h"
14 #include "llvm/Support/Regex.h"
15 
16 namespace clang {
17 namespace tidy {
18 namespace readability {
19 
20 /// Warns about identifiers names whose length is too short.
21 ///
22 /// For the user-facing documentation see:
23 /// http://clang.llvm.org/extra/clang-tidy/checks/readability/identifier-length.html
24 class IdentifierLengthCheck : public ClangTidyCheck {
25 public:
26   IdentifierLengthCheck(StringRef Name, ClangTidyContext *Context);
27   void storeOptions(ClangTidyOptions::OptionMap &Opts) override;
28   void registerMatchers(ast_matchers::MatchFinder *Finder) override;
29   void check(const ast_matchers::MatchFinder::MatchResult &Result) override;
30 
31 private:
32   const unsigned MinimumVariableNameLength;
33   const unsigned MinimumLoopCounterNameLength;
34   const unsigned MinimumExceptionNameLength;
35   const unsigned MinimumParameterNameLength;
36 
37   std::string IgnoredVariableNamesInput;
38   llvm::Regex IgnoredVariableNames;
39 
40   std::string IgnoredLoopCounterNamesInput;
41   llvm::Regex IgnoredLoopCounterNames;
42 
43   std::string IgnoredExceptionVariableNamesInput;
44   llvm::Regex IgnoredExceptionVariableNames;
45 
46   std::string IgnoredParameterNamesInput;
47   llvm::Regex IgnoredParameterNames;
48 };
49 
50 } // namespace readability
51 } // namespace tidy
52 } // namespace clang
53 
54 #endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_READABILITY_IDENTIFIERLENGTHCHECK_H
55