IdentifierLengthCheck.h 1.8 KB

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