clang-tools 22.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 MinimumLoopCounterNameLength;
31 const unsigned MinimumExceptionNameLength;
32 const unsigned MinimumParameterNameLength;
33
34 std::string IgnoredVariableNamesInput;
35 llvm::Regex IgnoredVariableNames;
36
37 std::string IgnoredLoopCounterNamesInput;
38 llvm::Regex IgnoredLoopCounterNames;
39
40 std::string IgnoredExceptionVariableNamesInput;
41 llvm::Regex IgnoredExceptionVariableNames;
42
43 std::string IgnoredParameterNamesInput;
44 llvm::Regex IgnoredParameterNames;
45};
46
47} // namespace clang::tidy::readability
48
49#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