clang-tools  14.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 
16 namespace clang {
17 namespace tidy {
18 namespace readability {
19 
20 /// Warns about identifiers names whose length is too short.
21 ///
22 /// For the user-facing documentation see:
23 /// http://clang.llvm.org/extra/clang-tidy/checks/readability-identifier-length.html
25 public:
26  IdentifierLengthCheck(StringRef Name, ClangTidyContext *Context);
27  void storeOptions(ClangTidyOptions::OptionMap &Opts) override;
28  void registerMatchers(ast_matchers::MatchFinder *Finder) override;
29  void check(const ast_matchers::MatchFinder::MatchResult &Result) override;
30 
31 private:
32  const unsigned MinimumVariableNameLength;
33  const unsigned MinimumLoopCounterNameLength;
34  const unsigned MinimumExceptionNameLength;
35  const unsigned MinimumParameterNameLength;
36 
37  std::string IgnoredVariableNamesInput;
38  llvm::Regex IgnoredVariableNames;
39 
40  std::string IgnoredLoopCounterNamesInput;
41  llvm::Regex IgnoredLoopCounterNames;
42 
43  std::string IgnoredExceptionVariableNamesInput;
44  llvm::Regex IgnoredExceptionVariableNames;
45 
46  std::string IgnoredParameterNamesInput;
47  llvm::Regex IgnoredParameterNames;
48 };
49 
50 } // namespace readability
51 } // namespace tidy
52 } // namespace clang
53 
54 #endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_READABILITY_IDENTIFIERLENGTHCHECK_H
clang::tidy::ClangTidyOptions::OptionMap
llvm::StringMap< ClangTidyValue > OptionMap
Definition: ClangTidyOptions.h:115
clang::tidy::readability::IdentifierLengthCheck::registerMatchers
void registerMatchers(ast_matchers::MatchFinder *Finder) override
Override this to register AST matchers with Finder.
Definition: IdentifierLengthCheck.cpp:72
clang::tidy::ClangTidyCheck
Base class for all clang-tidy checks.
Definition: ClangTidyCheck.h:54
clang::tidy::readability::IdentifierLengthCheck::storeOptions
void storeOptions(ClangTidyOptions::OptionMap &Opts) override
Should store all options supported by this check with their current values or default values for opti...
Definition: IdentifierLengthCheck.cpp:59
clang::tidy::readability::IdentifierLengthCheck
Warns about identifiers names whose length is too short.
Definition: IdentifierLengthCheck.h:24
clang::tidy::ClangTidyContext
Every ClangTidyCheck reports errors through a DiagnosticsEngine provided by this context.
Definition: ClangTidyDiagnosticConsumer.h:72
Name
static constexpr llvm::StringLiteral Name
Definition: UppercaseLiteralSuffixCheck.cpp:28
clang::tidy::readability::IdentifierLengthCheck::check
void check(const ast_matchers::MatchFinder::MatchResult &Result) override
ClangTidyChecks that register ASTMatchers should do the actual work in here.
Definition: IdentifierLengthCheck.cpp:93
clang
===– Representation.cpp - ClangDoc Representation --------—*- C++ -*-===//
Definition: ApplyReplacements.h:27
clang::tidy::readability::IdentifierLengthCheck::IdentifierLengthCheck
IdentifierLengthCheck(StringRef Name, ClangTidyContext *Context)
Definition: IdentifierLengthCheck.cpp:34