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::tidy::readability { 17 18 /// Warns about identifiers names whose length is too short. 19 /// 20 /// For the user-facing documentation see: 21 /// http://clang.llvm.org/extra/clang-tidy/checks/readability/identifier-length.html 22 class IdentifierLengthCheck : public ClangTidyCheck { 23 public: 24 IdentifierLengthCheck(StringRef Name, ClangTidyContext *Context); 25 void storeOptions(ClangTidyOptions::OptionMap &Opts) override; 26 void registerMatchers(ast_matchers::MatchFinder *Finder) override; 27 void check(const ast_matchers::MatchFinder::MatchResult &Result) override; 28 29 private: 30 const unsigned MinimumVariableNameLength; 31 const unsigned MinimumLoopCounterNameLength; 32 const unsigned MinimumExceptionNameLength; 33 const unsigned MinimumParameterNameLength; 34 35 std::string IgnoredVariableNamesInput; 36 llvm::Regex IgnoredVariableNames; 37 38 std::string IgnoredLoopCounterNamesInput; 39 llvm::Regex IgnoredLoopCounterNames; 40 41 std::string IgnoredExceptionVariableNamesInput; 42 llvm::Regex IgnoredExceptionVariableNames; 43 44 std::string IgnoredParameterNamesInput; 45 llvm::Regex IgnoredParameterNames; 46 }; 47 48 } // namespace clang::tidy::readability 49 50 #endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_READABILITY_IDENTIFIERLENGTHCHECK_H 51