#include "IdentifierNamingCheck.h"
#include "../GlobList.h"
#include "../utils/ASTUtils.h"
#include "clang/AST/CXXInheritance.h"
#include "clang/Lex/PPCallbacks.h"
#include "clang/Lex/Preprocessor.h"
#include "llvm/ADT/ArrayRef.h"
#include "llvm/ADT/DenseMapInfo.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/Support/Debug.h"
#include "llvm/Support/Error.h"
#include "llvm/Support/FormatVariadic.h"
#include "llvm/Support/Path.h"
#include "llvm/Support/Regex.h"
#include "llvm/Support/YAMLParser.h"
#include <optional>
#define DEBUG_TYPE …
usingnamespaceclang::ast_matchers;
namespace clang::tidy {
llvm::ArrayRef<
std::pair<readability::IdentifierNamingCheck::CaseType, StringRef>>
OptionEnumMapping<
readability::IdentifierNamingCheck::CaseType>::getEnumMapping() { … }
template <>
struct OptionEnumMapping<
readability::IdentifierNamingCheck::HungarianPrefixType> { … };
namespace readability {
#define NAMING_KEYS … \
enum StyleKind : int { … };
static StringRef const StyleNames[] = …;
#define HUNGARIAN_NOTATION_PRIMITIVE_TYPES(m) … \
static StringRef const HungarainNotationPrimitiveTypes[] = …;
#define HUNGARIAN_NOTATION_USER_DEFINED_TYPES(m) … \
static StringRef const HungarainNotationUserDefinedTypes[] = …;
#undef NAMING_KEYS
IdentifierNamingCheck::NamingStyle::NamingStyle(
std::optional<IdentifierNamingCheck::CaseType> Case, StringRef Prefix,
StringRef Suffix, StringRef IgnoredRegexpStr, HungarianPrefixType HPType)
: … { … }
IdentifierNamingCheck::FileStyle IdentifierNamingCheck::getFileStyleFromOptions(
const ClangTidyCheck::OptionsView &Options) const { … }
std::string IdentifierNamingCheck::HungarianNotation::getDeclTypeName(
const NamedDecl *ND) const { … }
IdentifierNamingCheck::IdentifierNamingCheck(StringRef Name,
ClangTidyContext *Context)
: … { … }
IdentifierNamingCheck::~IdentifierNamingCheck() = default;
bool IdentifierNamingCheck::HungarianNotation::checkOptionValid(
int StyleKindIndex) const { … }
bool IdentifierNamingCheck::HungarianNotation::isOptionEnabled(
StringRef OptionKey, const llvm::StringMap<std::string> &StrMap) const { … }
void IdentifierNamingCheck::HungarianNotation::loadFileConfig(
const ClangTidyCheck::OptionsView &Options,
IdentifierNamingCheck::HungarianNotationOption &HNOption) const { … }
std::string IdentifierNamingCheck::HungarianNotation::getPrefix(
const Decl *D,
const IdentifierNamingCheck::HungarianNotationOption &HNOption) const { … }
bool IdentifierNamingCheck::HungarianNotation::removeDuplicatedPrefix(
SmallVector<StringRef, 8> &Words,
const IdentifierNamingCheck::HungarianNotationOption &HNOption) const { … }
std::string IdentifierNamingCheck::HungarianNotation::getDataTypePrefix(
StringRef TypeName, const NamedDecl *ND,
const IdentifierNamingCheck::HungarianNotationOption &HNOption) const { … }
std::string IdentifierNamingCheck::HungarianNotation::getClassPrefix(
const CXXRecordDecl *CRD,
const IdentifierNamingCheck::HungarianNotationOption &HNOption) const { … }
std::string IdentifierNamingCheck::HungarianNotation::getEnumPrefix(
const EnumConstantDecl *ECD) const { … }
size_t IdentifierNamingCheck::HungarianNotation::getAsteriskCount(
const std::string &TypeName) const { … }
size_t IdentifierNamingCheck::HungarianNotation::getAsteriskCount(
const std::string &TypeName, const NamedDecl *ND) const { … }
void IdentifierNamingCheck::HungarianNotation::loadDefaultConfig(
IdentifierNamingCheck::HungarianNotationOption &HNOption) const { … }
void IdentifierNamingCheck::storeOptions(ClangTidyOptions::OptionMap &Opts) { … }
bool IdentifierNamingCheck::matchesStyle(
StringRef Type, StringRef Name,
const IdentifierNamingCheck::NamingStyle &Style,
const IdentifierNamingCheck::HungarianNotationOption &HNOption,
const NamedDecl *Decl) const { … }
std::string IdentifierNamingCheck::fixupWithCase(
StringRef Type, StringRef Name, const Decl *D,
const IdentifierNamingCheck::NamingStyle &Style,
const IdentifierNamingCheck::HungarianNotationOption &HNOption,
IdentifierNamingCheck::CaseType Case) const { … }
bool IdentifierNamingCheck::isParamInMainLikeFunction(
const ParmVarDecl &ParmDecl, bool IncludeMainLike) const { … }
std::string IdentifierNamingCheck::fixupWithStyle(
StringRef Type, StringRef Name,
const IdentifierNamingCheck::NamingStyle &Style,
const IdentifierNamingCheck::HungarianNotationOption &HNOption,
const Decl *D) const { … }
StyleKind IdentifierNamingCheck::findStyleKind(
const NamedDecl *D,
ArrayRef<std::optional<IdentifierNamingCheck::NamingStyle>> NamingStyles,
bool IgnoreMainLikeFunctions, bool CheckAnonFieldInParentScope) const { … }
std::optional<RenamerClangTidyCheck::FailureInfo>
IdentifierNamingCheck::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::optional<RenamerClangTidyCheck::FailureInfo>
IdentifierNamingCheck::getDeclFailureInfo(const NamedDecl *Decl,
const SourceManager &SM) const { … }
std::optional<RenamerClangTidyCheck::FailureInfo>
IdentifierNamingCheck::getMacroFailureInfo(const Token &MacroNameTok,
const SourceManager &SM) const { … }
RenamerClangTidyCheck::DiagInfo
IdentifierNamingCheck::getDiagInfo(const NamingCheckId &ID,
const NamingCheckFailure &Failure) const { … }
StringRef IdentifierNamingCheck::getRealFileName(StringRef FileName) const { … }
const IdentifierNamingCheck::FileStyle &
IdentifierNamingCheck::getStyleForFile(StringRef FileName) const { … }
StyleKind IdentifierNamingCheck::findStyleKindForAnonField(
const FieldDecl *AnonField,
ArrayRef<std::optional<NamingStyle>> NamingStyles) const { … }
StyleKind IdentifierNamingCheck::findStyleKindForField(
const FieldDecl *Field, QualType Type,
ArrayRef<std::optional<NamingStyle>> NamingStyles) const { … }
StyleKind IdentifierNamingCheck::findStyleKindForVar(
const VarDecl *Var, QualType Type,
ArrayRef<std::optional<NamingStyle>> NamingStyles) const { … }
}
}