clang-tools 22.0.0git
clang::tidy::readability Namespace Reference

Classes

class  AmbiguousSmartptrResetCallCheck
 Finds potentially erroneous calls to 'reset' method on smart pointers when the pointee type also has a 'reset' method. More...
class  AvoidConstParamsInDecls
class  AvoidNestedConditionalOperatorCheck
 Identifies instances of nested conditional operators in the code. More...
class  AvoidReturnWithVoidValueCheck
 Finds return statements with void values used within functions with void result types. More...
class  AvoidUnconditionalPreprocessorIfCheck
 Finds code blocks that are constantly enabled or disabled in preprocessor directives by analyzing #if conditions, such as #if 0 and #if 1, etc. More...
class  BracesAroundStatementsCheck
 Checks that bodies of if statements and loops (for, range-for, do-while, and while) are inside braces. More...
class  ConstReturnTypeCheck
 For any function whose return type is const-qualified, suggests removal of the const qualifier from that return type. More...
class  ContainerContainsCheck
 Finds usages of container.count() and container.find() == container.end() which should be replaced by a call to the container.contains() method. More...
class  ContainerDataPointerCheck
 Checks whether a call to operator[] and & can be replaced with a call to data(). More...
class  ContainerSizeEmptyCheck
 Checks whether a call to the size()/length() method can be replaced with a call to empty(). More...
class  ConvertMemberFunctionsToStatic
 This check finds C++ class methods than can be made static because they don't use the 'this' pointer. More...
class  DeleteNullPointerCheck
 Check whether the 'if' statement is unnecessary before calling 'delete' on a pointer. More...
class  DuplicateIncludeCheck
 Find and remove duplicate #include directives. More...
class  ElseAfterReturnCheck
 Flags the usages of else after return. More...
class  EnumInitialValueCheck
 Enforces consistent style for enumerators' initialization, covering three styles: none, first only, or all initialized explicitly. More...
class  FunctionCognitiveComplexityCheck
 Checks function Cognitive Complexity metric. More...
class  FunctionSizeCheck
 Checks for large functions based on various metrics. More...
class  IdentifierLengthCheck
 Warns about identifiers names whose length is too short. More...
class  IdentifierNamingCheck
 Checks for identifiers naming style mismatch. More...
class  ImplicitBoolConversionCheck
 Checks for use of implicit bool conversions in expressions. More...
class  InconsistentDeclarationParameterNameCheck
 Checks for declarations of functions which differ in parameter names. More...
class  IsolateDeclarationCheck
 This check diagnoses all DeclStmt's declaring more than one variable and tries to refactor the code to one statement per declaration. More...
class  MagicNumbersCheck
 Detects magic numbers, integer and floating point literals embedded in code. More...
class  MakeMemberFunctionConstCheck
 Finds non-static member functions that can be made 'const'. More...
class  MathMissingParenthesesCheck
 Check for mising parantheses in mathematical expressions that involve operators of different priorities. More...
class  MisleadingIndentationCheck
 Checks the code for dangling else, and possible misleading indentations due to missing braces. More...
class  MisplacedArrayIndexCheck
 Warn about unusual array index syntax (index[array] instead of array[index]). More...
class  NamedParameterCheck
 Find functions with unnamed arguments. More...
class  NamespaceCommentCheck
 Checks that long namespaces have a closing comment. More...
class  NonConstParameterCheck
 Warn when a pointer function parameter can be const. More...
class  OperatorsRepresentationCheck
 Enforces consistent token representation for invoked binary, unary and overloaded operators in C++ code. More...
class  QualifiedAutoCheck
 Finds variables declared as auto that could be declared as: 'auto*' or 'const auto *' and reference variables declared as: 'const auto &'. More...
class  ReadabilityModule
class  RedundantAccessSpecifiersCheck
 Detects redundant access specifiers inside classes, structs, and unions. More...
class  RedundantCastingCheck
 Detects explicit type casting operations that involve the same source and destination types, and subsequently recommend their removal. More...
class  RedundantControlFlowCheck
 Eliminates redundant return statements at the end of a function that returns void. More...
class  RedundantDeclarationCheck
 Find redundant variable declarations. More...
class  RedundantFunctionPtrDereferenceCheck
 Eliminate redundant dereferences of a function pointer. More...
class  RedundantInlineSpecifierCheck
 Detects redundant inline specifiers on function and variable declarations. More...
class  RedundantMemberInitCheck
 Finds member initializations that are unnecessary because the same default constructor would be called if they were not present. More...
class  RedundantParenthesesCheck
 Detect redundant parentheses. More...
class  RedundantPreprocessorCheck
 This check flags redundant preprocessor directives: nested directives with the same condition. More...
class  RedundantSmartptrGetCheck
 Find and remove redundant calls to smart pointer's .get() method. More...
class  RedundantStringCStrCheck
 Finds unnecessary calls to std::string::c_str(). More...
class  RedundantStringInitCheck
 Finds unnecessary string initializations. More...
class  ReferenceToConstructedTemporaryCheck
 Detects C++ code where a reference variable is used to extend the lifetime of a temporary object that has just been constructed. More...
class  SimplifyBooleanExprCheck
 Looks for boolean expressions involving boolean constants and simplifies them to use the appropriate boolean expression directly. More...
class  SimplifySubscriptExprCheck
 Simplifies subscript expressions. More...
class  StaticAccessedThroughInstanceCheck
 Checks for member expressions that access static members through instances and replaces them with uses of the appropriate qualified-id. More...
class  StaticDefinitionInAnonymousNamespaceCheck
 Finds static function and variable definitions in anonymous namespace. More...
class  StringCompareCheck
 This check flags all calls compare when used to check for string equality or inequality. More...
class  SuspiciousCallArgumentCheck
 Finds function calls where the arguments passed are provided out of order, based on the difference between the argument name and the parameter names of the function. More...
class  UniqueptrDeleteReleaseCheck
 Flags statements of the form delete <unique_ptr expr>.release(); and / replaces them with: <unique_ptr expr> = nullptr; More...
class  UppercaseLiteralSuffixCheck
 Detects when the integral literal or floating point literal has non-uppercase suffix, and suggests to make the suffix uppercase. More...
class  UseAnyOfAllOfCheck
 Finds ranged-based for loops that can be replaced by a call to std::any_of or std::all_of. More...
class  UseConcisePreprocessorDirectivesCheck
 Finds uses of #if that can be simplified to #ifdef or #ifndef / and, since C23 and C++23, uses of #elif that can be simplified to / #elifdef or #elifndef. More...
class  UseStdMinMaxCheck
 Replaces certain conditional statements with equivalent calls to std::min or std::max. More...

Enumerations

enum  StyleKind : int { SK_Count , SK_Invalid }

Functions

static tok::TokenKind getTokenKind (SourceLocation Loc, const SourceManager &SM, const LangOptions &LangOpts)
static SourceLocation forwardSkipWhitespaceAndComments (SourceLocation Loc, const SourceManager &SM, const LangOptions &LangOpts)
static std::optional< Token > findConstToRemove (const FunctionDecl *Def, const MatchFinder::MatchResult &Result)
static CheckResult checkDef (const clang::FunctionDecl *Def, const MatchFinder::MatchResult &MatchResult)
static StringRef getStringFromRange (SourceManager &SourceMgr, const LangOptions &LangOpts, SourceRange Range)
 Obtain the original source code text from a SourceRange.
static SourceRange getLocationOfConst (const TypeSourceInfo *TSI, SourceManager &SourceMgr, const LangOptions &LangOpts)
static SourceLocation advanceBeyondCurrentLine (const SourceManager &SM, SourceLocation Start, int Offset)
static const DeclRefExpr * findUsage (const Stmt *Node, int64_t DeclIdentifier)
static const DeclRefExpr * findUsageRange (const Stmt *Node, const llvm::ArrayRef< int64_t > &DeclIdentifiers)
static const DeclRefExpr * checkInitDeclUsageInElse (const IfStmt *If)
static const DeclRefExpr * checkConditionVarUsageInElse (const IfStmt *If)
static bool containsDeclInScope (const Stmt *Node)
static void removeElseAndBrackets (DiagnosticBuilder &Diag, ASTContext &Context, const Stmt *Else, SourceLocation ElseLoc)
static bool hasPreprocessorBranchEndBetweenLocations (const ElseAfterReturnCheck::ConditionalBranchMap &ConditionalBranchMap, const SourceManager &SM, SourceLocation StartLoc, SourceLocation EndLoc)
static StringRef getControlFlowString (const Stmt &Stmt)
static bool isNoneEnumeratorsInitialized (const EnumDecl &Node)
static bool isOnlyFirstEnumeratorInitialized (const EnumDecl &Node)
static bool areAllEnumeratorsInitialized (const EnumDecl &Node)
static bool isInitializedByLiteral (const EnumConstantDecl *Enumerator)
 Check if Enumerator is initialized with a (potentially negated) IntegerLiteral.
static void cleanInitialValue (DiagnosticBuilder &Diag, const EnumConstantDecl *ECD, const SourceManager &SM, const LangOptions &LangOpts)
static std::string getName (const EnumDecl *Decl)
static CognitiveComplexity::Criteria operator| (CognitiveComplexity::Criteria LHS, CognitiveComplexity::Criteria RHS)
static CognitiveComplexity::Criteria operator& (CognitiveComplexity::Criteria LHS, CognitiveComplexity::Criteria RHS)
static CognitiveComplexity::Criteria & operator|= (CognitiveComplexity::Criteria &LHS, CognitiveComplexity::Criteria RHS)
static CognitiveComplexity::Criteria & operator&= (CognitiveComplexity::Criteria &LHS, CognitiveComplexity::Criteria RHS)
static StringRef getZeroLiteralToCompareWithForType (CastKind CastExprKind, QualType Type, ASTContext &Context)
static bool isUnaryLogicalNotOperator (const Stmt *Statement)
static void fixGenericExprCastToBool (DiagnosticBuilder &Diag, const ImplicitCastExpr *Cast, const Stmt *Parent, ASTContext &Context, bool UseUpperCaseLiteralSuffix)
static StringRef getEquivalentBoolLiteralForExpr (const Expr *Expression, ASTContext &Context)
static bool needsSpacePrefix (SourceLocation Loc, ASTContext &Context)
static void fixGenericExprCastFromBool (DiagnosticBuilder &Diag, const ImplicitCastExpr *Cast, ASTContext &Context, StringRef OtherType)
static StringRef getEquivalentForBoolLiteral (const CXXBoolLiteralExpr *BoolLiteral, QualType DestType, ASTContext &Context)
static bool isCastAllowedInCondition (const ImplicitCastExpr *Cast, ASTContext &Context)
static SourceLocation findStartOfIndirection (SourceLocation Start, int Indirections, const SourceManager &SM, const LangOptions &LangOpts)
static bool isMacroID (SourceRange R)
static int countIndirections (const Type *T, int Indirections=0)
 This function counts the number of written indirections for the given Type T.
static bool typeIsMemberPointer (const Type *T)
static std::optional< std::vector< SourceRange > > declRanges (const DeclStmt *DS, const SourceManager &SM, const LangOptions &LangOpts)
 This function tries to extract the SourceRanges that make up all declarations in this DeclStmt.
static std::optional< std::vector< StringRef > > collectSourceRanges (llvm::ArrayRef< SourceRange > Ranges, const SourceManager &SM, const LangOptions &LangOpts)
static std::vector< std::string > createIsolatedDecls (llvm::ArrayRef< StringRef > Snippets)
 Expects a vector {TypeSnippet, Firstdecl, SecondDecl, ...}.
static SourceLocation getConstInsertionPoint (const CXXMethodDecl *M)
static int getPrecedence (const BinaryOperator *BinOp)
static void addParentheses (const BinaryOperator *BinOp, const BinaryOperator *ParentBinOp, ClangTidyCheck *Check, const clang::SourceManager &SM, const clang::LangOptions &LangOpts)
static const IfStmt * getPrecedingIf (const SourceManager &SM, ASTContext *Context, const IfStmt *If)
static bool isAtStartOfLineIncludingEmptyMacro (SourceLocation NextLoc, const SourceManager &SM, const LangOptions &LangOpts)
static bool locationsInSameFile (const SourceManager &Sources, SourceLocation Loc1, SourceLocation Loc2)
static std::optional< std::string > getNamespaceNameAsWritten (SourceLocation &Loc, const SourceManager &Sources, const LangOptions &LangOpts)
static StringRef getOperatorSpelling (SourceLocation Loc, ASTContext &Context)
static llvm::StringRef translate (llvm::StringRef Value)
static bool isNotOperatorStr (llvm::StringRef Value)
static bool isSeparator (char C) noexcept
static bool needEscaping (llvm::StringRef Operator)
static llvm::StringRef getRepresentation (const std::vector< llvm::StringRef > &Config, llvm::StringRef Traditional, llvm::StringRef Alternative)
template<typename T>
static bool isAnyOperatorEnabled (const std::vector< llvm::StringRef > &Config, const T &Operators)
static std::optional< Token > findQualToken (const VarDecl *Decl, Qualifier Qual, const MatchFinder::MatchResult &Result)
static std::optional< SourceRange > getTypeSpecifierLocation (const VarDecl *Var, const MatchFinder::MatchResult &Result)
static std::optional< SourceRange > mergeReplacementRange (SourceRange &TypeSpecifier, const Token &ConstToken)
static bool isPointerConst (QualType QType)
static bool isAutoPointerConst (QualType QType)
static ClangTidyModuleRegistry::Add< ReadabilityModuleX ("readability-module", "Adds readability-related checks.")
static bool areTypesEqual (QualType S, QualType D)
static bool areTypesEqual (QualType TypeS, QualType TypeD, bool IgnoreTypeAliases)
static bool areBinaryOperatorOperandsTypesEqualToOperatorResultType (const Expr *E, bool IgnoreTypeAliases)
static const Decl * getSourceExprDecl (const Expr *SourceExpr)
static bool isLocationInMacroExpansion (const SourceManager &SM, SourceLocation Loc)
static SourceLocation getInlineTokenLocation (SourceRange RangeLocation, const SourceManager &Sources, const LangOptions &LangOpts)
static SourceRange getFullInitRangeInclWhitespaces (SourceRange Range, const SourceManager &SM, const LangOptions &LangOpts)
static std::vector< StringRef > removeNamespaces (ArrayRef< StringRef > Names)
static const CXXConstructExpr * getConstructExpr (const CXXCtorInitializer &CtorInit)
static std::optional< SourceRange > getConstructExprArgRange (const CXXConstructExpr &Construct)
static bool needsParensAfterUnaryNegation (const Expr *E)
static StringRef negatedOperator (const BinaryOperator *BinOp)
static StringRef getOperatorName (OverloadedOperatorKind OpKind)
static StringRef negatedOperator (const CXXOperatorCallExpr *OpCall)
static std::string asBool (StringRef Text, bool NeedsStaticCast)
static bool needsNullPtrComparison (const Expr *E)
static bool needsZeroComparison (const Expr *E)
static bool needsStaticCast (const Expr *E)
static std::string compareExpressionToConstant (const ASTContext &Context, const Expr *E, bool Negated, const char *Constant)
static std::string compareExpressionToNullPtr (const ASTContext &Context, const Expr *E, bool Negated)
static std::string compareExpressionToZero (const ASTContext &Context, const Expr *E, bool Negated)
static std::string replacementExpression (const ASTContext &Context, bool Negated, const Expr *E)
static bool containsDiscardedTokens (const ASTContext &Context, CharSourceRange CharRange)
static bool containsBoolLiteral (const Expr *E)
static bool flipDemorganOperator (llvm::SmallVectorImpl< FixItHint > &Output, const BinaryOperator *BO)
 Swaps a BinaryOperator opcode from && to || or vice-versa.
static BinaryOperatorKind getDemorganFlippedOperator (BinaryOperatorKind BO)
static bool flipDemorganSide (SmallVectorImpl< FixItHint > &Fixes, const ASTContext &Ctx, const Expr *E, std::optional< BinaryOperatorKind > OuterBO)
static bool flipDemorganBinaryOperator (SmallVectorImpl< FixItHint > &Fixes, const ASTContext &Ctx, const BinaryOperator *BinOp, std::optional< BinaryOperatorKind > OuterBO, const ParenExpr *Parens=nullptr)
 Inverts BinOp, Removing Parens if they exist and are safe to remove.
static bool shouldRemoveParens (const Stmt *Parent, BinaryOperatorKind NewOuterBinary, const ParenExpr *Parens)
static unsigned getNameSpecifierNestingLevel (QualType QType)
static double percentage (double X, double Y)
 Returns how many % X is of Y.
static bool applyEqualityHeuristic (StringRef Arg, StringRef Param)
static bool applyAbbreviationHeuristic (const llvm::StringMap< std::string > &AbbreviationDictionary, StringRef Arg, StringRef Param)
static bool applyPrefixHeuristic (StringRef Arg, StringRef Param, int8_t Threshold)
 Check whether the shorter String is a prefix of the longer String.
static bool applySuffixHeuristic (StringRef Arg, StringRef Param, int8_t Threshold)
 Check whether the shorter String is a suffix of the longer String.
static bool applySubstringHeuristic (StringRef Arg, StringRef Param, int8_t Threshold)
static bool applyLevenshteinHeuristic (StringRef Arg, StringRef Param, int8_t Threshold)
static bool applyJaroWinklerHeuristic (StringRef Arg, StringRef Param, int8_t Threshold)
static bool applyDiceHeuristic (StringRef Arg, StringRef Param, int8_t Threshold)
static bool areRefAndQualCompatible (QualType ArgType, QualType ParamType, const ASTContext &Ctx)
 Checks if ArgType binds to ParamType regarding reference-ness and cv-qualifiers.
static bool isPointerOrArray (QualType TypeToCheck)
static bool isCompatibleWithArrayReference (QualType ArgType, QualType ParamType, const ASTContext &Ctx)
 Checks whether ArgType is an array type identical to ParamType's array type.
static QualType convertToPointeeOrArrayElementQualType (QualType TypeToConvert)
static bool arePointersStillQualCompatible (QualType ArgType, QualType ParamType, bool &IsParamContinuouslyConst, const ASTContext &Ctx)
 Checks if multilevel pointers' qualifiers compatibility continues on the current pointer level.
static bool arePointerTypesCompatible (QualType ArgType, QualType ParamType, bool IsParamContinuouslyConst, const ASTContext &Ctx)
 Checks whether multilevel pointers are compatible in terms of levels, qualifiers and pointee type.
static bool areTypesCompatible (QualType ArgType, QualType ParamType, const ASTContext &Ctx)
 Checks whether ArgType converts implicitly to ParamType.
static bool isOverloadedUnaryOrBinarySymbolOperator (const FunctionDecl *FD)
static bool isViableLoop (const CXXForRangeStmt &S, ASTContext &Context)
static const llvm::StringRef AlgorithmHeader ("<algorithm>")
static bool minCondition (const BinaryOperator::Opcode Op, const Expr *CondLhs, const Expr *CondRhs, const Expr *AssignLhs, const Expr *AssignRhs, const ASTContext &Context)
static bool maxCondition (const BinaryOperator::Opcode Op, const Expr *CondLhs, const Expr *CondRhs, const Expr *AssignLhs, const Expr *AssignRhs, const ASTContext &Context)
static QualType getNonTemplateAlias (QualType QT)
static QualType getReplacementCastType (const Expr *CondLhs, const Expr *CondRhs, QualType ComparedType)
static std::string createReplacement (const Expr *CondLhs, const Expr *CondRhs, const Expr *AssignLhs, const SourceManager &Source, const LangOptions &LO, StringRef FunctionName, const BinaryOperator *BO)
bool isBinaryOrTernary (const Expr *E)

Variables

static constexpr char IgnoreMacrosName [] = "IgnoreMacros"
static const bool IgnoreMacrosDefault = true
static constexpr char StrictModeName [] = "StrictMode"
static const bool StrictModeDefault = true
constexpr llvm::StringLiteral ContainerExprName = "container-expr"
constexpr llvm::StringLiteral DerefContainerExprName = "deref-container-expr"
constexpr llvm::StringLiteral AddrOfContainerExprName
constexpr llvm::StringLiteral AddressOfName = "address-of"
static const char InterruptingStr [] = "interrupting"
static const char WarningMessage [] = "do not use 'else' after '%0'"
static const char WarnOnUnfixableStr [] = "WarnOnUnfixable"
static const char WarnOnConditionVariablesStr [] = "WarnOnConditionVariables"
static const std::array< const StringRef, 4 > Msgs
const unsigned DefaultMinimumVariableNameLength = 3
const unsigned DefaultMinimumLoopCounterNameLength = 2
const unsigned DefaultMinimumExceptionNameLength = 2
const unsigned DefaultMinimumParameterNameLength = 3
const char DefaultIgnoredLoopCounterNames [] = "^[ijk_]$"
const char DefaultIgnoredVariableNames [] = ""
const char DefaultIgnoredExceptionVariableNames [] = "^[e]$"
const char DefaultIgnoredParameterNames [] = "^[n]$"
const char ErrorMessage []
static StringRef const StyleNames []
static StringRef const HungarianNotationPrimitiveTypes []
static StringRef const HungarianNotationUserDefinedTypes []
const char DefaultIgnoredIntegerValues [] = "1;2;3;4;"
const char DefaultIgnoredFloatingPointValues [] = "1.0;100.0;"
constexpr std::array< std::pair< llvm::StringRef, llvm::StringRef >, 2U > UnaryRepresentation {{{"!", "not"}, {"~", "compl"}}}
constexpr std::array< std::pair< llvm::StringRef, llvm::StringRef >, 9U > OperatorsRepresentation
static const char *const RedundantReturnDiag
static const char *const RedundantContinueDiag
const char DefaultStringNames []
static constexpr char SimplifyOperatorDiagnostic []
static constexpr char SimplifyConditionDiagnostic []
static constexpr char SimplifyConditionalReturnDiagnostic []
static std::pair< BinaryOperatorKind, BinaryOperatorKind > Opposites []
static std::pair< OverloadedOperatorKind, StringRef > OperatorNames []
static std::pair< OverloadedOperatorKind, OverloadedOperatorKind > OppositeOverloads []
static const char KDefaultTypes []
static const StringRef CompareMessage
static const StringRef DefaultStringLikeClasses
static constexpr std::size_t DefaultMinimumIdentifierNameLength = 3
static constexpr StringRef HeuristicToString []
static constexpr DefaultHeuristicConfiguration Defaults []
static constexpr llvm::StringLiteral DefaultAbbreviations
static constexpr std::size_t SmallVectorSize

Enumeration Type Documentation

◆ StyleKind

Enumerator
SK_Count 
SK_Invalid 

Definition at line 128 of file IdentifierNamingCheck.cpp.

Function Documentation

◆ addParentheses()

void clang::tidy::readability::addParentheses ( const BinaryOperator * BinOp,
const BinaryOperator * ParentBinOp,
ClangTidyCheck * Check,
const clang::SourceManager & SM,
const clang::LangOptions & LangOpts )
static

◆ advanceBeyondCurrentLine()

SourceLocation clang::tidy::readability::advanceBeyondCurrentLine ( const SourceManager & SM,
SourceLocation Start,
int Offset )
static

Definition at line 18 of file DuplicateIncludeCheck.cpp.

◆ AlgorithmHeader()

const llvm::StringRef clang::tidy::readability::AlgorithmHeader ( "<algorithm>" )
static

◆ applyAbbreviationHeuristic()

bool clang::tidy::readability::applyAbbreviationHeuristic ( const llvm::StringMap< std::string > & AbbreviationDictionary,
StringRef Arg,
StringRef Param )
static

Definition at line 136 of file SuspiciousCallArgumentCheck.cpp.

◆ applyDiceHeuristic()

bool clang::tidy::readability::applyDiceHeuristic ( StringRef Arg,
StringRef Param,
int8_t Threshold )
static

Definition at line 273 of file SuspiciousCallArgumentCheck.cpp.

References percentage().

◆ applyEqualityHeuristic()

bool clang::tidy::readability::applyEqualityHeuristic ( StringRef Arg,
StringRef Param )
static

Definition at line 132 of file SuspiciousCallArgumentCheck.cpp.

◆ applyJaroWinklerHeuristic()

bool clang::tidy::readability::applyJaroWinklerHeuristic ( StringRef Arg,
StringRef Param,
int8_t Threshold )
static

Definition at line 212 of file SuspiciousCallArgumentCheck.cpp.

◆ applyLevenshteinHeuristic()

bool clang::tidy::readability::applyLevenshteinHeuristic ( StringRef Arg,
StringRef Param,
int8_t Threshold )
static

Definition at line 203 of file SuspiciousCallArgumentCheck.cpp.

◆ applyPrefixHeuristic()

bool clang::tidy::readability::applyPrefixHeuristic ( StringRef Arg,
StringRef Param,
int8_t Threshold )
static

Check whether the shorter String is a prefix of the longer String.

Definition at line 151 of file SuspiciousCallArgumentCheck.cpp.

References percentage().

◆ applySubstringHeuristic()

bool clang::tidy::readability::applySubstringHeuristic ( StringRef Arg,
StringRef Param,
int8_t Threshold )
static

Definition at line 174 of file SuspiciousCallArgumentCheck.cpp.

References percentage().

◆ applySuffixHeuristic()

bool clang::tidy::readability::applySuffixHeuristic ( StringRef Arg,
StringRef Param,
int8_t Threshold )
static

Check whether the shorter String is a suffix of the longer String.

Definition at line 163 of file SuspiciousCallArgumentCheck.cpp.

References percentage().

◆ areAllEnumeratorsInitialized()

bool clang::tidy::readability::areAllEnumeratorsInitialized ( const EnumDecl & Node)
static

Definition at line 40 of file EnumInitialValueCheck.cpp.

◆ areBinaryOperatorOperandsTypesEqualToOperatorResultType()

bool clang::tidy::readability::areBinaryOperatorOperandsTypesEqualToOperatorResultType ( const Expr * E,
bool IgnoreTypeAliases )
static

◆ arePointersStillQualCompatible()

bool clang::tidy::readability::arePointersStillQualCompatible ( QualType ArgType,
QualType ParamType,
bool & IsParamContinuouslyConst,
const ASTContext & Ctx )
static

Checks if multilevel pointers' qualifiers compatibility continues on the current pointer level.

For multilevel pointers, C++ permits conversion, if every cv-qualifier in ArgType also appears in the corresponding position in ParamType, and if PramType has a cv-qualifier that's not in ArgType, then every * in ParamType to the right of that cv-qualifier, except the last one, must also be const-qualified.

Definition at line 344 of file SuspiciousCallArgumentCheck.cpp.

Referenced by arePointerTypesCompatible().

◆ arePointerTypesCompatible()

bool clang::tidy::readability::arePointerTypesCompatible ( QualType ArgType,
QualType ParamType,
bool IsParamContinuouslyConst,
const ASTContext & Ctx )
static

Checks whether multilevel pointers are compatible in terms of levels, qualifiers and pointee type.

Definition at line 362 of file SuspiciousCallArgumentCheck.cpp.

References arePointersStillQualCompatible(), and convertToPointeeOrArrayElementQualType().

Referenced by areTypesCompatible().

◆ areRefAndQualCompatible()

bool clang::tidy::readability::areRefAndQualCompatible ( QualType ArgType,
QualType ParamType,
const ASTContext & Ctx )
static

Checks if ArgType binds to ParamType regarding reference-ness and cv-qualifiers.

Definition at line 301 of file SuspiciousCallArgumentCheck.cpp.

Referenced by areTypesCompatible().

◆ areTypesCompatible()

bool clang::tidy::readability::areTypesCompatible ( QualType ArgType,
QualType ParamType,
const ASTContext & Ctx )
static

◆ areTypesEqual() [1/2]

bool clang::tidy::readability::areTypesEqual ( QualType S,
QualType D )
static

◆ areTypesEqual() [2/2]

bool clang::tidy::readability::areTypesEqual ( QualType TypeS,
QualType TypeD,
bool IgnoreTypeAliases )
static

Definition at line 41 of file RedundantCastingCheck.cpp.

References areTypesEqual().

◆ asBool()

std::string clang::tidy::readability::asBool ( StringRef Text,
bool NeedsStaticCast )
static

Definition at line 100 of file SimplifyBooleanExprCheck.cpp.

Referenced by replacementExpression().

◆ checkConditionVarUsageInElse()

const DeclRefExpr * clang::tidy::readability::checkConditionVarUsageInElse ( const IfStmt * If)
static

◆ checkDef()

CheckResult clang::tidy::readability::checkDef ( const clang::FunctionDecl * Def,
const MatchFinder::MatchResult & MatchResult )
static

◆ checkInitDeclUsageInElse()

const DeclRefExpr * clang::tidy::readability::checkInitDeclUsageInElse ( const IfStmt * If)
static

◆ cleanInitialValue()

void clang::tidy::readability::cleanInitialValue ( DiagnosticBuilder & Diag,
const EnumConstantDecl * ECD,
const SourceManager & SM,
const LangOptions & LangOpts )
static

◆ collectSourceRanges()

std::optional< std::vector< StringRef > > clang::tidy::readability::collectSourceRanges ( llvm::ArrayRef< SourceRange > Ranges,
const SourceManager & SM,
const LangOptions & LangOpts )
static

◆ compareExpressionToConstant()

std::string clang::tidy::readability::compareExpressionToConstant ( const ASTContext & Context,
const Expr * E,
bool Negated,
const char * Constant )
static

◆ compareExpressionToNullPtr()

std::string clang::tidy::readability::compareExpressionToNullPtr ( const ASTContext & Context,
const Expr * E,
bool Negated )
static

Definition at line 152 of file SimplifyBooleanExprCheck.cpp.

References compareExpressionToConstant().

Referenced by replacementExpression().

◆ compareExpressionToZero()

std::string clang::tidy::readability::compareExpressionToZero ( const ASTContext & Context,
const Expr * E,
bool Negated )
static

Definition at line 158 of file SimplifyBooleanExprCheck.cpp.

References compareExpressionToConstant().

Referenced by replacementExpression().

◆ containsBoolLiteral()

bool clang::tidy::readability::containsBoolLiteral ( const Expr * E)
static

Definition at line 609 of file SimplifyBooleanExprCheck.cpp.

References containsBoolLiteral().

Referenced by containsBoolLiteral().

◆ containsDeclInScope()

bool clang::tidy::readability::containsDeclInScope ( const Stmt * Node)
static

◆ containsDiscardedTokens()

bool clang::tidy::readability::containsDiscardedTokens ( const ASTContext & Context,
CharSourceRange CharRange )
static

Definition at line 241 of file SimplifyBooleanExprCheck.cpp.

◆ convertToPointeeOrArrayElementQualType()

QualType clang::tidy::readability::convertToPointeeOrArrayElementQualType ( QualType TypeToConvert)
static

◆ countIndirections()

int clang::tidy::readability::countIndirections ( const Type * T,
int Indirections = 0 )
static

This function counts the number of written indirections for the given Type T.

It does NOT resolve typedefs as it's a helper for lexing the source code.

See also
declRanges

Definition at line 59 of file IsolateDeclarationCheck.cpp.

References countIndirections().

Referenced by countIndirections(), and declRanges().

◆ createIsolatedDecls()

std::vector< std::string > clang::tidy::readability::createIsolatedDecls ( llvm::ArrayRef< StringRef > Snippets)
static

Expects a vector {TypeSnippet, Firstdecl, SecondDecl, ...}.

Definition at line 231 of file IsolateDeclarationCheck.cpp.

Referenced by clang::tidy::readability::IsolateDeclarationCheck::check().

◆ createReplacement()

std::string clang::tidy::readability::createReplacement ( const Expr * CondLhs,
const Expr * CondRhs,
const Expr * AssignLhs,
const SourceManager & Source,
const LangOptions & LO,
StringRef FunctionName,
const BinaryOperator * BO )
static

◆ declRanges()

std::optional< std::vector< SourceRange > > clang::tidy::readability::declRanges ( const DeclStmt * DS,
const SourceManager & SM,
const LangOptions & LangOpts )
static

This function tries to extract the SourceRanges that make up all declarations in this DeclStmt.

The resulting vector has the structure {UnderlyingType, Decl1, Decl2, ...}. Each SourceRange is of the form [Begin, End). If any of the create ranges is invalid or in a macro the result will be None. If the DeclStmt contains only one declaration, the result is None. If the DeclStmt contains declarations other than VarDecl the result is None.

int * ptr1 = nullptr, value = 42;
// [ ][ ] [ ] - The ranges here are inclusive
Todo
Generalize this function to take other declarations than VarDecl.

Definition at line 108 of file IsolateDeclarationCheck.cpp.

References countIndirections(), clang::tidy::utils::lexer::findNextTerminator(), clang::tidy::utils::lexer::findPreviousTokenKind(), clang::tidy::utils::lexer::findPreviousTokenStart(), findStartOfIndirection(), clang::tidy::utils::lexer::getPreviousToken(), isMacroID(), clang::tidy::utils::lexer::rangeContainsExpansionsOrDirectives(), and typeIsMemberPointer().

Referenced by clang::tidy::readability::IsolateDeclarationCheck::check().

◆ findConstToRemove()

std::optional< Token > clang::tidy::readability::findConstToRemove ( const FunctionDecl * Def,
const MatchFinder::MatchResult & Result )
static

◆ findQualToken()

std::optional< Token > clang::tidy::readability::findQualToken ( const VarDecl * Decl,
Qualifier Qual,
const MatchFinder::MatchResult & Result )
static

◆ findStartOfIndirection()

SourceLocation clang::tidy::readability::findStartOfIndirection ( SourceLocation Start,
int Indirections,
const SourceManager & SM,
const LangOptions & LangOpts )
static

◆ findUsage()

const DeclRefExpr * clang::tidy::readability::findUsage ( const Stmt * Node,
int64_t DeclIdentifier )
static

◆ findUsageRange()

const DeclRefExpr * clang::tidy::readability::findUsageRange ( const Stmt * Node,
const llvm::ArrayRef< int64_t > & DeclIdentifiers )
static

Definition at line 65 of file ElseAfterReturnCheck.cpp.

References findUsageRange().

Referenced by checkInitDeclUsageInElse(), and findUsageRange().

◆ fixGenericExprCastFromBool()

void clang::tidy::readability::fixGenericExprCastFromBool ( DiagnosticBuilder & Diag,
const ImplicitCastExpr * Cast,
ASTContext & Context,
StringRef OtherType )
static

Definition at line 178 of file ImplicitBoolConversionCheck.cpp.

References needsSpacePrefix().

◆ fixGenericExprCastToBool()

void clang::tidy::readability::fixGenericExprCastToBool ( DiagnosticBuilder & Diag,
const ImplicitCastExpr * Cast,
const Stmt * Parent,
ASTContext & Context,
bool UseUpperCaseLiteralSuffix )
static

◆ flipDemorganBinaryOperator()

bool clang::tidy::readability::flipDemorganBinaryOperator ( SmallVectorImpl< FixItHint > & Fixes,
const ASTContext & Ctx,
const BinaryOperator * BinOp,
std::optional< BinaryOperatorKind > OuterBO,
const ParenExpr * Parens = nullptr )
static

Inverts BinOp, Removing Parens if they exist and are safe to remove.

returns true if there is any issue building the Fixes, false otherwise.

Definition at line 836 of file SimplifyBooleanExprCheck.cpp.

References flipDemorganOperator(), flipDemorganSide(), and getDemorganFlippedOperator().

Referenced by flipDemorganSide().

◆ flipDemorganOperator()

bool clang::tidy::readability::flipDemorganOperator ( llvm::SmallVectorImpl< FixItHint > & Output,
const BinaryOperator * BO )
static

Swaps a BinaryOperator opcode from && to || or vice-versa.

Definition at line 813 of file SimplifyBooleanExprCheck.cpp.

Referenced by flipDemorganBinaryOperator().

◆ flipDemorganSide()

bool clang::tidy::readability::flipDemorganSide ( SmallVectorImpl< FixItHint > & Fixes,
const ASTContext & Ctx,
const Expr * E,
std::optional< BinaryOperatorKind > OuterBO )
static

Definition at line 914 of file SimplifyBooleanExprCheck.cpp.

References flipDemorganBinaryOperator(), and isMacroID().

Referenced by flipDemorganBinaryOperator().

◆ forwardSkipWhitespaceAndComments()

SourceLocation clang::tidy::readability::forwardSkipWhitespaceAndComments ( SourceLocation Loc,
const SourceManager & SM,
const LangOptions & LangOpts )
static

Definition at line 34 of file BracesAroundStatementsCheck.cpp.

References getTokenKind().

◆ getConstInsertionPoint()

SourceLocation clang::tidy::readability::getConstInsertionPoint ( const CXXMethodDecl * M)
static

◆ getConstructExpr()

const CXXConstructExpr * clang::tidy::readability::getConstructExpr ( const CXXCtorInitializer & CtorInit)
static

◆ getConstructExprArgRange()

std::optional< SourceRange > clang::tidy::readability::getConstructExprArgRange ( const CXXConstructExpr & Construct)
static

◆ getControlFlowString()

StringRef clang::tidy::readability::getControlFlowString ( const Stmt & Stmt)
static

◆ getDemorganFlippedOperator()

BinaryOperatorKind clang::tidy::readability::getDemorganFlippedOperator ( BinaryOperatorKind BO)
static

Definition at line 823 of file SimplifyBooleanExprCheck.cpp.

Referenced by flipDemorganBinaryOperator().

◆ getEquivalentBoolLiteralForExpr()

StringRef clang::tidy::readability::getEquivalentBoolLiteralForExpr ( const Expr * Expression,
ASTContext & Context )
static

Definition at line 138 of file ImplicitBoolConversionCheck.cpp.

◆ getEquivalentForBoolLiteral()

StringRef clang::tidy::readability::getEquivalentForBoolLiteral ( const CXXBoolLiteralExpr * BoolLiteral,
QualType DestType,
ASTContext & Context )
static

Definition at line 207 of file ImplicitBoolConversionCheck.cpp.

◆ getFullInitRangeInclWhitespaces()

SourceRange clang::tidy::readability::getFullInitRangeInclWhitespaces ( SourceRange Range,
const SourceManager & SM,
const LangOptions & LangOpts )
static

◆ getInlineTokenLocation()

SourceLocation clang::tidy::readability::getInlineTokenLocation ( SourceRange RangeLocation,
const SourceManager & Sources,
const LangOptions & LangOpts )
static

◆ getLocationOfConst()

SourceRange clang::tidy::readability::getLocationOfConst ( const TypeSourceInfo * TSI,
SourceManager & SourceMgr,
const LangOptions & LangOpts )
static

◆ getName()

std::string clang::tidy::readability::getName ( const EnumDecl * Decl)
static

◆ getNamespaceNameAsWritten()

std::optional< std::string > clang::tidy::readability::getNamespaceNameAsWritten ( SourceLocation & Loc,
const SourceManager & Sources,
const LangOptions & LangOpts )
static

◆ getNameSpecifierNestingLevel()

unsigned clang::tidy::readability::getNameSpecifierNestingLevel ( QualType QType)
static

◆ getNonTemplateAlias()

QualType clang::tidy::readability::getNonTemplateAlias ( QualType QT)
static

Definition at line 62 of file UseStdMinMaxCheck.cpp.

Referenced by getReplacementCastType().

◆ getOperatorName()

StringRef clang::tidy::readability::getOperatorName ( OverloadedOperatorKind OpKind)
static

Definition at line 75 of file SimplifyBooleanExprCheck.cpp.

References OperatorNames.

Referenced by negatedOperator().

◆ getOperatorSpelling()

StringRef clang::tidy::readability::getOperatorSpelling ( SourceLocation Loc,
ASTContext & Context )
static

Definition at line 22 of file OperatorsRepresentationCheck.cpp.

◆ getPrecedence()

int clang::tidy::readability::getPrecedence ( const BinaryOperator * BinOp)
static

Definition at line 30 of file MathMissingParenthesesCheck.cpp.

Referenced by addParentheses().

◆ getPrecedingIf()

const IfStmt * clang::tidy::readability::getPrecedingIf ( const SourceManager & SM,
ASTContext * Context,
const IfStmt * If )
static

Definition at line 18 of file MisleadingIndentationCheck.cpp.

◆ getReplacementCastType()

QualType clang::tidy::readability::getReplacementCastType ( const Expr * CondLhs,
const Expr * CondRhs,
QualType ComparedType )
static

Definition at line 78 of file UseStdMinMaxCheck.cpp.

References getNonTemplateAlias().

Referenced by createReplacement().

◆ getRepresentation()

llvm::StringRef clang::tidy::readability::getRepresentation ( const std::vector< llvm::StringRef > & Config,
llvm::StringRef Traditional,
llvm::StringRef Alternative )
static

Definition at line 127 of file OperatorsRepresentationCheck.cpp.

References Config().

Referenced by isAnyOperatorEnabled().

◆ getSourceExprDecl()

const Decl * clang::tidy::readability::getSourceExprDecl ( const Expr * SourceExpr)
static

◆ getStringFromRange()

StringRef clang::tidy::readability::getStringFromRange ( SourceManager & SourceMgr,
const LangOptions & LangOpts,
SourceRange Range )
static

Obtain the original source code text from a SourceRange.

Definition at line 103 of file ConvertMemberFunctionsToStatic.cpp.

Referenced by getLocationOfConst().

◆ getTokenKind()

tok::TokenKind clang::tidy::readability::getTokenKind ( SourceLocation Loc,
const SourceManager & SM,
const LangOptions & LangOpts )
static

Definition at line 20 of file BracesAroundStatementsCheck.cpp.

Referenced by forwardSkipWhitespaceAndComments().

◆ getTypeSpecifierLocation()

std::optional< SourceRange > clang::tidy::readability::getTypeSpecifierLocation ( const VarDecl * Var,
const MatchFinder::MatchResult & Result )
static

◆ getZeroLiteralToCompareWithForType()

StringRef clang::tidy::readability::getZeroLiteralToCompareWithForType ( CastKind CastExprKind,
QualType Type,
ASTContext & Context )
static

Definition at line 46 of file ImplicitBoolConversionCheck.cpp.

Referenced by fixGenericExprCastToBool().

◆ hasPreprocessorBranchEndBetweenLocations()

bool clang::tidy::readability::hasPreprocessorBranchEndBetweenLocations ( const ElseAfterReturnCheck::ConditionalBranchMap & ConditionalBranchMap,
const SourceManager & SM,
SourceLocation StartLoc,
SourceLocation EndLoc )
static

◆ isAnyOperatorEnabled()

template<typename T>
bool clang::tidy::readability::isAnyOperatorEnabled ( const std::vector< llvm::StringRef > & Config,
const T & Operators )
static

Definition at line 137 of file OperatorsRepresentationCheck.cpp.

References Config(), and getRepresentation().

◆ isAtStartOfLineIncludingEmptyMacro()

bool clang::tidy::readability::isAtStartOfLineIncludingEmptyMacro ( SourceLocation NextLoc,
const SourceManager & SM,
const LangOptions & LangOpts )
static

◆ isAutoPointerConst()

bool clang::tidy::readability::isAutoPointerConst ( QualType QType)
static

◆ isBinaryOrTernary()

bool clang::tidy::utils::isBinaryOrTernary ( const Expr * E)

◆ isCastAllowedInCondition()

bool clang::tidy::readability::isCastAllowedInCondition ( const ImplicitCastExpr * Cast,
ASTContext & Context )
static

Definition at line 229 of file ImplicitBoolConversionCheck.cpp.

References isUnaryLogicalNotOperator().

◆ isCompatibleWithArrayReference()

bool clang::tidy::readability::isCompatibleWithArrayReference ( QualType ArgType,
QualType ParamType,
const ASTContext & Ctx )
static

Checks whether ArgType is an array type identical to ParamType's array type.

Enforces array elements' qualifier compatibility as well.

Definition at line 314 of file SuspiciousCallArgumentCheck.cpp.

Referenced by areTypesCompatible().

◆ isInitializedByLiteral()

bool clang::tidy::readability::isInitializedByLiteral ( const EnumConstantDecl * Enumerator)
static

Check if Enumerator is initialized with a (potentially negated) IntegerLiteral.

Definition at line 48 of file EnumInitialValueCheck.cpp.

◆ isLocationInMacroExpansion()

bool clang::tidy::readability::isLocationInMacroExpansion ( const SourceManager & SM,
SourceLocation Loc )
static

Definition at line 24 of file RedundantControlFlowCheck.cpp.

◆ isMacroID()

bool clang::tidy::readability::isMacroID ( SourceRange R)
static

Definition at line 51 of file IsolateDeclarationCheck.cpp.

Referenced by declRanges(), and flipDemorganSide().

◆ isNoneEnumeratorsInitialized()

bool clang::tidy::readability::isNoneEnumeratorsInitialized ( const EnumDecl & Node)
static

Definition at line 23 of file EnumInitialValueCheck.cpp.

◆ isNotOperatorStr()

bool clang::tidy::readability::isNotOperatorStr ( llvm::StringRef Value)
static

◆ isOnlyFirstEnumeratorInitialized()

bool clang::tidy::readability::isOnlyFirstEnumeratorInitialized ( const EnumDecl & Node)
static

Definition at line 29 of file EnumInitialValueCheck.cpp.

◆ isOverloadedUnaryOrBinarySymbolOperator()

bool clang::tidy::readability::isOverloadedUnaryOrBinarySymbolOperator ( const FunctionDecl * FD)
static

◆ isPointerConst()

bool clang::tidy::readability::isPointerConst ( QualType QType)
static

◆ isPointerOrArray()

bool clang::tidy::readability::isPointerOrArray ( QualType TypeToCheck)
static

Definition at line 308 of file SuspiciousCallArgumentCheck.cpp.

Referenced by areTypesCompatible().

◆ isSeparator()

bool clang::tidy::readability::isSeparator ( char C)
staticnoexcept

◆ isUnaryLogicalNotOperator()

bool clang::tidy::readability::isUnaryLogicalNotOperator ( const Stmt * Statement)
static

◆ isViableLoop()

bool clang::tidy::readability::isViableLoop ( const CXXForRangeStmt & S,
ASTContext & Context )
static

◆ locationsInSameFile()

bool clang::tidy::readability::locationsInSameFile ( const SourceManager & Sources,
SourceLocation Loc1,
SourceLocation Loc2 )
static

◆ maxCondition()

bool clang::tidy::readability::maxCondition ( const BinaryOperator::Opcode Op,
const Expr * CondLhs,
const Expr * CondRhs,
const Expr * AssignLhs,
const Expr * AssignRhs,
const ASTContext & Context )
static

◆ mergeReplacementRange()

std::optional< SourceRange > clang::tidy::readability::mergeReplacementRange ( SourceRange & TypeSpecifier,
const Token & ConstToken )
static

◆ minCondition()

bool clang::tidy::readability::minCondition ( const BinaryOperator::Opcode Op,
const Expr * CondLhs,
const Expr * CondRhs,
const Expr * AssignLhs,
const Expr * AssignRhs,
const ASTContext & Context )
static

◆ needEscaping()

bool clang::tidy::readability::needEscaping ( llvm::StringRef Operator)
static

◆ needsNullPtrComparison()

bool clang::tidy::readability::needsNullPtrComparison ( const Expr * E)
static

Definition at line 107 of file SimplifyBooleanExprCheck.cpp.

Referenced by replacementExpression().

◆ needsParensAfterUnaryNegation()

bool clang::tidy::readability::needsParensAfterUnaryNegation ( const Expr * E)
static

Definition at line 45 of file SimplifyBooleanExprCheck.cpp.

Referenced by replacementExpression().

◆ needsSpacePrefix()

bool clang::tidy::readability::needsSpacePrefix ( SourceLocation Loc,
ASTContext & Context )
static

Definition at line 166 of file ImplicitBoolConversionCheck.cpp.

Referenced by fixGenericExprCastFromBool().

◆ needsStaticCast()

bool clang::tidy::readability::needsStaticCast ( const Expr * E)
static

Definition at line 122 of file SimplifyBooleanExprCheck.cpp.

Referenced by replacementExpression().

◆ needsZeroComparison()

bool clang::tidy::readability::needsZeroComparison ( const Expr * E)
static

Definition at line 115 of file SimplifyBooleanExprCheck.cpp.

Referenced by replacementExpression().

◆ negatedOperator() [1/2]

StringRef clang::tidy::readability::negatedOperator ( const BinaryOperator * BinOp)
static

Definition at line 60 of file SimplifyBooleanExprCheck.cpp.

References Opposites.

Referenced by replacementExpression().

◆ negatedOperator() [2/2]

StringRef clang::tidy::readability::negatedOperator ( const CXXOperatorCallExpr * OpCall)
static

Definition at line 89 of file SimplifyBooleanExprCheck.cpp.

References getOperatorName(), and OppositeOverloads.

◆ operator&()

CognitiveComplexity::Criteria clang::tidy::readability::operator& ( CognitiveComplexity::Criteria LHS,
CognitiveComplexity::Criteria RHS )
static

Definition at line 175 of file FunctionCognitiveComplexityCheck.cpp.

Referenced by operator&=().

◆ operator&=()

CognitiveComplexity::Criteria & clang::tidy::readability::operator&= ( CognitiveComplexity::Criteria & LHS,
CognitiveComplexity::Criteria RHS )
static

Definition at line 187 of file FunctionCognitiveComplexityCheck.cpp.

References operator&().

◆ operator|()

CognitiveComplexity::Criteria clang::tidy::readability::operator| ( CognitiveComplexity::Criteria LHS,
CognitiveComplexity::Criteria RHS )
static

Definition at line 169 of file FunctionCognitiveComplexityCheck.cpp.

Referenced by operator|=().

◆ operator|=()

CognitiveComplexity::Criteria & clang::tidy::readability::operator|= ( CognitiveComplexity::Criteria & LHS,
CognitiveComplexity::Criteria RHS )
static

Definition at line 181 of file FunctionCognitiveComplexityCheck.cpp.

References operator|().

◆ percentage()

double clang::tidy::readability::percentage ( double X,
double Y )
inlinestatic

Returns how many % X is of Y.

Definition at line 130 of file SuspiciousCallArgumentCheck.cpp.

References X().

Referenced by applyDiceHeuristic(), applyPrefixHeuristic(), applySubstringHeuristic(), and applySuffixHeuristic().

◆ removeElseAndBrackets()

void clang::tidy::readability::removeElseAndBrackets ( DiagnosticBuilder & Diag,
ASTContext & Context,
const Stmt * Else,
SourceLocation ElseLoc )
static

◆ removeNamespaces()

std::vector< StringRef > clang::tidy::readability::removeNamespaces ( ArrayRef< StringRef > Names)
static

◆ replacementExpression()

std::string clang::tidy::readability::replacementExpression ( const ASTContext & Context,
bool Negated,
const Expr * E )
static

◆ shouldRemoveParens()

bool clang::tidy::readability::shouldRemoveParens ( const Stmt * Parent,
BinaryOperatorKind NewOuterBinary,
const ParenExpr * Parens )
static

Definition at line 940 of file SimplifyBooleanExprCheck.cpp.

◆ translate()

llvm::StringRef clang::tidy::readability::translate ( llvm::StringRef Value)
static

◆ typeIsMemberPointer()

bool clang::tidy::readability::typeIsMemberPointer ( const Type * T)
static

Definition at line 80 of file IsolateDeclarationCheck.cpp.

References typeIsMemberPointer().

Referenced by declRanges(), and typeIsMemberPointer().

◆ X()

ClangTidyModuleRegistry::Add< ReadabilityModule > clang::tidy::readability::X ( "readability-module" ,
"Adds readability-related checks."  )
static

Referenced by percentage().

Variable Documentation

◆ AddressOfName

llvm::StringLiteral clang::tidy::readability::AddressOfName = "address-of"
constexpr

◆ AddrOfContainerExprName

llvm::StringLiteral clang::tidy::readability::AddrOfContainerExprName
constexpr

◆ CompareMessage

const StringRef clang::tidy::readability::CompareMessage
static
Initial value:
= "do not use 'compare' to test equality "
"of strings; use the string equality "
"operator instead"

Definition at line 22 of file StringCompareCheck.cpp.

Referenced by clang::tidy::readability::StringCompareCheck::check().

◆ ContainerExprName

llvm::StringLiteral clang::tidy::readability::ContainerExprName = "container-expr"
constexpr

◆ DefaultAbbreviations

llvm::StringLiteral clang::tidy::readability::DefaultAbbreviations
staticconstexpr

◆ DefaultIgnoredExceptionVariableNames

const char clang::tidy::readability::DefaultIgnoredExceptionVariableNames[] = "^[e]$"

◆ DefaultIgnoredFloatingPointValues

const char clang::tidy::readability::DefaultIgnoredFloatingPointValues[] = "1.0;100.0;"

◆ DefaultIgnoredIntegerValues

const char clang::tidy::readability::DefaultIgnoredIntegerValues[] = "1;2;3;4;"

◆ DefaultIgnoredLoopCounterNames

const char clang::tidy::readability::DefaultIgnoredLoopCounterNames[] = "^[ijk_]$"

◆ DefaultIgnoredParameterNames

const char clang::tidy::readability::DefaultIgnoredParameterNames[] = "^[n]$"

◆ DefaultIgnoredVariableNames

const char clang::tidy::readability::DefaultIgnoredVariableNames[] = ""

◆ DefaultMinimumExceptionNameLength

const unsigned clang::tidy::readability::DefaultMinimumExceptionNameLength = 2

◆ DefaultMinimumIdentifierNameLength

std::size_t clang::tidy::readability::DefaultMinimumIdentifierNameLength = 3
staticconstexpr

◆ DefaultMinimumLoopCounterNameLength

const unsigned clang::tidy::readability::DefaultMinimumLoopCounterNameLength = 2

◆ DefaultMinimumParameterNameLength

const unsigned clang::tidy::readability::DefaultMinimumParameterNameLength = 3

◆ DefaultMinimumVariableNameLength

const unsigned clang::tidy::readability::DefaultMinimumVariableNameLength = 3

◆ Defaults

DefaultHeuristicConfiguration clang::tidy::readability::Defaults[]
staticconstexpr
Initial value:
= {
{true, -1, -1},
{true, -1, -1},
{true, 25, 30},
{true, 25, 30},
{true, 40, 50},
{true, 50, 66},
{true, 75, 85},
{true, 60, 70},
}

Definition at line 49 of file SuspiciousCallArgumentCheck.cpp.

Referenced by clang::tidy::readability::SuspiciousCallArgumentCheck::storeOptions(), and clang::tidy::readability::SuspiciousCallArgumentCheck::SuspiciousCallArgumentCheck().

◆ DefaultStringLikeClasses

const StringRef clang::tidy::readability::DefaultStringLikeClasses
static
Initial value:
= "::std::basic_string;"
"::std::basic_string_view"

Definition at line 26 of file StringCompareCheck.cpp.

Referenced by clang::tidy::readability::StringCompareCheck::StringCompareCheck().

◆ DefaultStringNames

const char clang::tidy::readability::DefaultStringNames[]
Initial value:
=
"::std::basic_string_view;::std::basic_string"

Definition at line 20 of file RedundantStringInitCheck.cpp.

Referenced by clang::tidy::readability::RedundantStringInitCheck::RedundantStringInitCheck(), and clang::tidy::readability::RedundantStringInitCheck::storeOptions().

◆ DerefContainerExprName

llvm::StringLiteral clang::tidy::readability::DerefContainerExprName = "deref-container-expr"
constexpr

◆ ErrorMessage

const char clang::tidy::readability::ErrorMessage[]
Initial value:
=
"%select{variable|exception variable|loop variable|"
"parameter}0 name %1 is too short, expected at least %2 characters"

Definition at line 25 of file IdentifierLengthCheck.cpp.

Referenced by clang::tidy::readability::IdentifierLengthCheck::check().

◆ HeuristicToString

StringRef clang::tidy::readability::HeuristicToString[]
staticconstexpr
Initial value:
= {
"Equality", "Abbreviation", "Prefix", "Suffix",
"Substring", "Levenshtein", "JaroWinkler", "Dice"}

Definition at line 45 of file SuspiciousCallArgumentCheck.cpp.

Referenced by clang::tidy::readability::SuspiciousCallArgumentCheck::storeOptions(), and clang::tidy::readability::SuspiciousCallArgumentCheck::SuspiciousCallArgumentCheck().

◆ HungarianNotationPrimitiveTypes

StringRef const clang::tidy::readability::HungarianNotationPrimitiveTypes[]
static
Initial value:
= {
#define STRINGIZE(v)
}

Definition at line 189 of file IdentifierNamingCheck.cpp.

Referenced by clang::tidy::readability::IdentifierNamingCheck::HungarianNotation::loadFileConfig().

◆ HungarianNotationUserDefinedTypes

StringRef const clang::tidy::readability::HungarianNotationUserDefinedTypes[]
static
Initial value:
= {
#define STRINGIZE(v)
}

Definition at line 225 of file IdentifierNamingCheck.cpp.

Referenced by clang::tidy::readability::IdentifierNamingCheck::HungarianNotation::loadFileConfig().

◆ IgnoreMacrosDefault

const bool clang::tidy::readability::IgnoreMacrosDefault = true
static

◆ IgnoreMacrosName

char clang::tidy::readability::IgnoreMacrosName[] = "IgnoreMacros"
staticconstexpr

◆ InterruptingStr

const char clang::tidy::readability::InterruptingStr[] = "interrupting"
static

◆ KDefaultTypes

const char clang::tidy::readability::KDefaultTypes[]
static
Initial value:
=
"::std::basic_string;::std::basic_string_view;::std::vector;::std::array;::"
"std::span"

Definition at line 18 of file SimplifySubscriptExprCheck.cpp.

Referenced by clang::tidy::readability::SimplifySubscriptExprCheck::SimplifySubscriptExprCheck().

◆ Msgs

const std::array<const StringRef, 4> clang::tidy::readability::Msgs
static
Initial value:
= {{
"+%0, including nesting penalty of %1, nesting level increased to %2",
"+%0, nesting level increased to %2",
"+%0",
"nesting level increased to %2",
}}

Definition at line 153 of file FunctionCognitiveComplexityCheck.cpp.

Referenced by clang::tidy::readability::FunctionCognitiveComplexityCheck::check().

◆ OperatorNames

std::pair<OverloadedOperatorKind, StringRef> clang::tidy::readability::OperatorNames[]
static
Initial value:
= {
{OO_EqualEqual, "=="}, {OO_ExclaimEqual, "!="}, {OO_Less, "<"},
{OO_GreaterEqual, ">="}, {OO_Greater, ">"}, {OO_LessEqual, "<="}}

Definition at line 71 of file SimplifyBooleanExprCheck.cpp.

Referenced by getOperatorName().

◆ OperatorsRepresentation

std::array<std::pair<llvm::StringRef, llvm::StringRef>, 9U> clang::tidy::readability::OperatorsRepresentation
constexpr
Initial value:
{{{"&&", "and"},
{"||", "or"},
{"^", "xor"},
{"&", "bitand"},
{"|", "bitor"},
{"&=", "and_eq"},
{"|=", "or_eq"},
{"!=", "not_eq"},
{"^=", "xor_eq"}}}

Definition at line 77 of file OperatorsRepresentationCheck.cpp.

Referenced by translate().

◆ OppositeOverloads

std::pair<OverloadedOperatorKind, OverloadedOperatorKind> clang::tidy::readability::OppositeOverloads[]
static
Initial value:
= {{OO_EqualEqual, OO_ExclaimEqual},
{OO_Less, OO_GreaterEqual},
{OO_Greater, OO_LessEqual}}

Definition at line 85 of file SimplifyBooleanExprCheck.cpp.

Referenced by negatedOperator().

◆ Opposites

std::pair<BinaryOperatorKind, BinaryOperatorKind> clang::tidy::readability::Opposites[]
static
Initial value:
= {
{BO_LT, BO_GE}, {BO_GT, BO_LE}, {BO_EQ, BO_NE}}

Definition at line 57 of file SimplifyBooleanExprCheck.cpp.

Referenced by negatedOperator().

◆ RedundantContinueDiag

const char* const clang::tidy::readability::RedundantContinueDiag
static
Initial value:
=
"redundant continue statement at the "
"end of loop statement"

Definition at line 20 of file RedundantControlFlowCheck.cpp.

◆ RedundantReturnDiag

const char* const clang::tidy::readability::RedundantReturnDiag
static
Initial value:
=
"redundant return statement at the end "
"of a function with a void return type"

Definition at line 17 of file RedundantControlFlowCheck.cpp.

◆ SimplifyConditionalReturnDiagnostic

char clang::tidy::readability::SimplifyConditionalReturnDiagnostic[]
staticconstexpr
Initial value:
=
"redundant boolean literal in conditional return statement"

Definition at line 42 of file SimplifyBooleanExprCheck.cpp.

◆ SimplifyConditionDiagnostic

char clang::tidy::readability::SimplifyConditionDiagnostic[]
staticconstexpr
Initial value:
=
"redundant boolean literal in if statement condition"

Definition at line 40 of file SimplifyBooleanExprCheck.cpp.

◆ SimplifyOperatorDiagnostic

char clang::tidy::readability::SimplifyOperatorDiagnostic[]
staticconstexpr
Initial value:
=
"redundant boolean literal supplied to boolean operator"

Definition at line 38 of file SimplifyBooleanExprCheck.cpp.

◆ SmallVectorSize

std::size_t clang::tidy::readability::SmallVectorSize
staticconstexpr

◆ StrictModeDefault

const bool clang::tidy::readability::StrictModeDefault = true
static

◆ StrictModeName

char clang::tidy::readability::StrictModeName[] = "StrictMode"
staticconstexpr

◆ StyleNames

StringRef const clang::tidy::readability::StyleNames[]
static

◆ UnaryRepresentation

std::array<std::pair<llvm::StringRef, llvm::StringRef>, 2U> clang::tidy::readability::UnaryRepresentation {{{"!", "not"}, {"~", "compl"}}}
constexpr

Definition at line 74 of file OperatorsRepresentationCheck.cpp.

Referenced by translate().

◆ WarningMessage

const char clang::tidy::readability::WarningMessage[] = "do not use 'else' after '%0'"
static

◆ WarnOnConditionVariablesStr

const char clang::tidy::readability::WarnOnConditionVariablesStr[] = "WarnOnConditionVariables"
static

◆ WarnOnUnfixableStr

const char clang::tidy::readability::WarnOnUnfixableStr[] = "WarnOnUnfixable"
static