clang-tools 20.0.0git
IdentifierLengthCheck.h
Go to the documentation of this file.
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
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
23public:
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
29private:
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
llvm::SmallString< 256U > Name
Base class for all clang-tidy checks.
Every ClangTidyCheck reports errors through a DiagnosticsEngine provided by this context.
Warns about identifiers names whose length is too short.
void registerMatchers(ast_matchers::MatchFinder *Finder) override
Override this to register AST matchers with Finder.
void storeOptions(ClangTidyOptions::OptionMap &Opts) override
Should store all options supported by this check with their current values or default values for opti...
void check(const ast_matchers::MatchFinder::MatchResult &Result) override
ClangTidyChecks that register ASTMatchers should do the actual work in here.
llvm::StringMap< ClangTidyValue > OptionMap