9#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_READABILITY_IDENTIFIERNAMINGCHECK_H
10#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_READABILITY_IDENTIFIERNAMINGCHECK_H
12#include "../utils/RenamerClangTidyCheck.h"
16namespace readability {
61 std::optional<CaseType>
Case;
80 std::optional<CaseType>
Case;
95 const llvm::StringMap<std::string> &StrMap)
const;
99 const NamedDecl *ND)
const;
108 SmallVector<StringRef, 8> &Words,
116 StringRef TypeName,
const NamedDecl *ND,
120 const CXXRecordDecl *CRD,
123 std::string
getEnumPrefix(
const EnumConstantDecl *ECD)
const;
128 FileStyle() : IsActive(false), IgnoreMainLikeFunctions(false) {}
129 FileStyle(SmallVectorImpl<std::optional<NamingStyle>> &&Styles,
131 : Styles(std::move(Styles)), HNOption(std::move(HNOption)),
132 IsActive(true), IgnoreMainLikeFunctions(IgnoreMainLike) {}
134 ArrayRef<std::optional<NamingStyle>>
getStyles()
const {
148 SmallVector<std::optional<NamingStyle>, 0> Styles;
151 bool IgnoreMainLikeFunctions;
161 const NamedDecl *
Decl)
const;
173 const Decl *D)
const;
177 ArrayRef<std::optional<IdentifierNamingCheck::NamingStyle>> NamingStyles,
178 bool IgnoreMainLikeFunctions)
const;
181 StringRef
Type, StringRef
Name,
const NamedDecl *ND,
183 ArrayRef<std::optional<IdentifierNamingCheck::NamingStyle>> NamingStyles,
185 StyleKind SK,
const SourceManager &SM,
bool IgnoreFailedSplit)
const;
188 bool IncludeMainLike)
const;
191 std::optional<FailureInfo>
192 getDeclFailureInfo(
const NamedDecl *
Decl,
193 const SourceManager &SM)
const override;
194 std::optional<FailureInfo>
195 getMacroFailureInfo(
const Token &MacroNameTok,
196 const SourceManager &SM)
const override;
198 const NamingCheckFailure &Failure)
const override;
200 const FileStyle &getStyleForFile(StringRef
FileName)
const;
204 mutable llvm::StringMap<FileStyle> NamingStylesCache;
205 FileStyle *MainFileStyle;
207 const bool GetConfigPerFile;
208 const bool IgnoreFailedSplit;
209 HungarianNotation HungarianNotation;
215 static llvm::ArrayRef<
216 std::pair<readability::IdentifierNamingCheck::CaseType, StringRef>>
const FunctionDecl * Decl
Provides access to the ClangTidyCheck options via check-local names.
Every ClangTidyCheck reports errors through a DiagnosticsEngine provided by this context.
Base class for clang-tidy checks that want to flag declarations and/or macros for renaming based on c...
std::pair< SourceLocation, StringRef > NamingCheckId
Checks for identifiers naming style mismatch.
std::string fixupWithCase(StringRef Type, StringRef Name, const Decl *D, const IdentifierNamingCheck::NamingStyle &Style, const IdentifierNamingCheck::HungarianNotationOption &HNOption, IdentifierNamingCheck::CaseType Case) const
std::optional< RenamerClangTidyCheck::FailureInfo > getFailureInfo(StringRef Type, StringRef Name, const NamedDecl *ND, SourceLocation Location, ArrayRef< std::optional< IdentifierNamingCheck::NamingStyle > > NamingStyles, const IdentifierNamingCheck::HungarianNotationOption &HNOption, StyleKind SK, const SourceManager &SM, bool IgnoreFailedSplit) const
StyleKind findStyleKind(const NamedDecl *D, ArrayRef< std::optional< IdentifierNamingCheck::NamingStyle > > NamingStyles, bool IgnoreMainLikeFunctions) const
std::string fixupWithStyle(StringRef Type, StringRef Name, const IdentifierNamingCheck::NamingStyle &Style, const IdentifierNamingCheck::HungarianNotationOption &HNOption, const Decl *D) const
IdentifierNamingCheck::FileStyle getFileStyleFromOptions(const ClangTidyCheck::OptionsView &Options) const
bool isParamInMainLikeFunction(const ParmVarDecl &ParmDecl, bool IncludeMainLike) const
bool matchesStyle(StringRef Type, StringRef Name, const IdentifierNamingCheck::NamingStyle &Style, const IdentifierNamingCheck::HungarianNotationOption &HNOption, const NamedDecl *Decl) const
@ CT_LeadingUpperSnakeCase
void storeOptions(ClangTidyOptions::OptionMap &Opts) override
Should store all options supported by this check with their current values or default values for opti...
llvm::StringMap< ClangTidyValue > OptionMap
This class should be specialized by any enum type that needs to be converted to and from an llvm::Str...
static ArrayRef< std::pair< T, StringRef > > getEnumMapping()=delete
FileStyle(SmallVectorImpl< std::optional< NamingStyle > > &&Styles, HungarianNotationOption HNOption, bool IgnoreMainLike)
bool isIgnoringMainLikeFunction() const
ArrayRef< std::optional< NamingStyle > > getStyles() const
const HungarianNotationOption & getHNOption() const
HungarianNotationOption()=default
llvm::StringMap< std::string > UserDefinedType
std::optional< CaseType > Case
HungarianPrefixType HPType
llvm::StringMap< std::string > DerivedType
llvm::StringMap< std::string > CString
llvm::StringMap< std::string > General
llvm::StringMap< std::string > PrimitiveType
std::string getDeclTypeName(const NamedDecl *ND) const
bool isOptionEnabled(StringRef OptionKey, const llvm::StringMap< std::string > &StrMap) const
bool removeDuplicatedPrefix(SmallVector< StringRef, 8 > &Words, const IdentifierNamingCheck::HungarianNotationOption &HNOption) const
void loadFileConfig(const ClangTidyCheck::OptionsView &Options, IdentifierNamingCheck::HungarianNotationOption &HNOption) const
void loadDefaultConfig(IdentifierNamingCheck::HungarianNotationOption &HNOption) const
std::string getEnumPrefix(const EnumConstantDecl *ECD) const
std::string getClassPrefix(const CXXRecordDecl *CRD, const IdentifierNamingCheck::HungarianNotationOption &HNOption) const
bool checkOptionValid(int StyleKindIndex) const
std::string getPrefix(const Decl *D, const IdentifierNamingCheck::HungarianNotationOption &HNOption) const
size_t getAsteriskCount(const std::string &TypeName) const
std::string getDataTypePrefix(StringRef TypeName, const NamedDecl *ND, const IdentifierNamingCheck::HungarianNotationOption &HNOption) const
NamingStyle(const NamingStyle &O)=delete
llvm::Regex IgnoredRegexp
NamingStyle(std::optional< CaseType > Case, StringRef Prefix, StringRef Suffix, StringRef IgnoredRegexpStr, HungarianPrefixType HPType)
NamingStyle(NamingStyle &&O)=default
std::string IgnoredRegexpStr
NamingStyle & operator=(NamingStyle &&O)=default
HungarianPrefixType HPType
std::optional< CaseType > Case