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 bool CheckAnonFieldInParent)
132 : Styles(std::move(Styles)), HNOption(std::move(HNOption)),
133 IsActive(true), IgnoreMainLikeFunctions(IgnoreMainLike),
134 CheckAnonFieldInParentScope(CheckAnonFieldInParent) {}
136 ArrayRef<std::optional<NamingStyle>>
getStyles()
const {
150 return CheckAnonFieldInParentScope;
154 SmallVector<std::optional<NamingStyle>, 0> Styles;
157 bool IgnoreMainLikeFunctions;
158 bool CheckAnonFieldInParentScope;
168 const NamedDecl *
Decl)
const;
180 const Decl *D)
const;
184 ArrayRef<std::optional<IdentifierNamingCheck::NamingStyle>> NamingStyles,
185 bool IgnoreMainLikeFunctions,
bool CheckAnonFieldInParentScope)
const;
188 StringRef
Type, StringRef
Name,
const NamedDecl *ND,
190 ArrayRef<std::optional<IdentifierNamingCheck::NamingStyle>> NamingStyles,
192 StyleKind SK,
const SourceManager &SM,
bool IgnoreFailedSplit)
const;
195 bool IncludeMainLike)
const;
198 std::optional<FailureInfo>
199 getDeclFailureInfo(
const NamedDecl *
Decl,
200 const SourceManager &SM)
const override;
201 std::optional<FailureInfo>
202 getMacroFailureInfo(
const Token &MacroNameTok,
203 const SourceManager &SM)
const override;
205 const NamingCheckFailure &Failure)
const override;
207 const FileStyle &getStyleForFile(StringRef
FileName)
const;
208 StringRef getRealFileName(StringRef
FileName)
const;
212 const FieldDecl *AnonField,
213 ArrayRef<std::optional<NamingStyle>> NamingStyles)
const;
216 const FieldDecl *Field, QualType
Type,
217 ArrayRef<std::optional<NamingStyle>> NamingStyles)
const;
220 findStyleKindForVar(
const VarDecl *Var, QualType
Type,
221 ArrayRef<std::optional<NamingStyle>> NamingStyles)
const;
225 mutable llvm::StringMap<FileStyle> NamingStylesCache;
226 mutable llvm::StringMap<SmallString<256U>> RealFileNameCache;
227 FileStyle *MainFileStyle;
229 const bool GetConfigPerFile;
230 const bool IgnoreFailedSplit;
231 HungarianNotation HungarianNotation;
237 static llvm::ArrayRef<
238 std::pair<readability::IdentifierNamingCheck::CaseType, StringRef>>
const FunctionDecl * Decl
llvm::SmallString< 256U > Name
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
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
StyleKind findStyleKind(const NamedDecl *D, ArrayRef< std::optional< IdentifierNamingCheck::NamingStyle > > NamingStyles, bool IgnoreMainLikeFunctions, bool CheckAnonFieldInParentScope) 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
bool isIgnoringMainLikeFunction() const
bool isCheckingAnonFieldInParentScope() const
FileStyle(SmallVectorImpl< std::optional< NamingStyle > > &&Styles, HungarianNotationOption HNOption, bool IgnoreMainLike, bool CheckAnonFieldInParent)
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