clang-tools 23.0.0git
IdentifierLengthCheck.h
Go to the documentation of this file.
1//===----------------------------------------------------------------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
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
12#include "../ClangTidyCheck.h"
13#include "llvm/Support/Regex.h"
14
16
17/// Warns about identifiers names whose length is too short.
18///
19/// For the user-facing documentation see:
20/// https://clang.llvm.org/extra/clang-tidy/checks/readability/identifier-length.html
22public:
23 IdentifierLengthCheck(StringRef Name, ClangTidyContext *Context);
24 void storeOptions(ClangTidyOptions::OptionMap &Opts) override;
25 void registerMatchers(ast_matchers::MatchFinder *Finder) override;
26 void check(const ast_matchers::MatchFinder::MatchResult &Result) override;
27
28private:
29 const unsigned MinimumVariableNameLength;
30 const unsigned MinimumBindingNameLength;
31 const unsigned MinimumLoopCounterNameLength;
32 const unsigned MinimumExceptionNameLength;
33 const unsigned MinimumParameterNameLength;
34
35 StringRef IgnoredVariableNamesInput;
36 llvm::Regex IgnoredVariableNames;
37
38 StringRef IgnoredBindingNamesInput;
39 llvm::Regex IgnoredBindingNames;
40
41 StringRef IgnoredLoopCounterNamesInput;
42 llvm::Regex IgnoredLoopCounterNames;
43
44 StringRef IgnoredExceptionVariableNamesInput;
45 llvm::Regex IgnoredExceptionVariableNames;
46
47 StringRef IgnoredParameterNamesInput;
48 llvm::Regex IgnoredParameterNames;
49
50 const unsigned LineCountThreshold;
51};
52
53} // namespace clang::tidy::readability
54
55#endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_READABILITY_IDENTIFIERLENGTHCHECK_H
Every ClangTidyCheck reports errors through a DiagnosticsEngine provided by this context.
void registerMatchers(ast_matchers::MatchFinder *Finder) override
void storeOptions(ClangTidyOptions::OptionMap &Opts) override
IdentifierLengthCheck(StringRef Name, ClangTidyContext *Context)
void check(const ast_matchers::MatchFinder::MatchResult &Result) override
llvm::StringMap< ClangTidyValue > OptionMap