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"
15namespace readability {
59 std::optional<CaseType>
Case;
78 std::optional<CaseType>
Case;
93 const llvm::StringMap<std::string> &StrMap)
const;
101 SmallVector<StringRef, 8> &Words,
109 StringRef TypeName,
const NamedDecl *ND,
113 const CXXRecordDecl *CRD,
116 std::string
getEnumPrefix(
const EnumConstantDecl *ECD)
const;
121 FileStyle() : IsActive(false), IgnoreMainLikeFunctions(false) {}
122 FileStyle(SmallVectorImpl<std::optional<NamingStyle>> &&Styles,
124 : Styles(std::move(Styles)), HNOption(std::move(HNOption)),
125 IsActive(true), IgnoreMainLikeFunctions(IgnoreMainLike) {}
127 ArrayRef<std::optional<NamingStyle>>
getStyles()
const {
141 SmallVector<std::optional<NamingStyle>, 0> Styles;
144 bool IgnoreMainLikeFunctions;
154 const NamedDecl *
Decl)
const;
166 const Decl *D)
const;
170 ArrayRef<std::optional<IdentifierNamingCheck::NamingStyle>> NamingStyles,
171 bool IgnoreMainLikeFunctions)
const;
174 StringRef
Type, StringRef
Name,
const NamedDecl *ND,
176 ArrayRef<std::optional<IdentifierNamingCheck::NamingStyle>> NamingStyles,
178 StyleKind SK,
const SourceManager &SM,
bool IgnoreFailedSplit)
const;
181 bool IncludeMainLike)
const;
184 std::optional<FailureInfo>
185 getDeclFailureInfo(
const NamedDecl *
Decl,
186 const SourceManager &SM)
const override;
187 std::optional<FailureInfo>
188 getMacroFailureInfo(
const Token &MacroNameTok,
189 const SourceManager &SM)
const override;
191 const NamingCheckFailure &Failure)
const override;
193 const FileStyle &getStyleForFile(StringRef
FileName)
const;
197 mutable llvm::StringMap<FileStyle> NamingStylesCache;
198 FileStyle *MainFileStyle;
200 const StringRef CheckName;
201 const bool GetConfigPerFile;
202 const bool IgnoreFailedSplit;
203 HungarianNotation HungarianNotation;
209 static llvm::ArrayRef<
210 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, std::string > 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
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
llvm::StringMap< std::string > UserDefinedType
std::optional< CaseType > Case
HungarianPrefixType HPType
llvm::StringMap< std::string > DerivedType
HungarianNotationOption()
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
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