clang-tools 20.0.0git
Classes | Enumerations | Functions | Variables
clang::tidy::readability Namespace Reference

Classes

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 find() == end() which should be replaced by a call to the container.contains() method introduced in C++20. 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  FindUsageOfThis
 
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  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  UseStdMinMaxCheck
 Replaces certain conditional statements with equivalent calls to std::min or std::max. More...
 

Enumerations

enum  StyleKind : int { SK_Count , SK_Invalid }
 
enum  UsageKind { Unused , Const , NonConst }
 

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)
 
 AST_MATCHER (CXXMethodDecl, isStatic)
 
 AST_MATCHER (CXXMethodDecl, hasTrivialBody)
 
 AST_MATCHER (CXXMethodDecl, isOverloadedOperator)
 
 AST_MATCHER (CXXRecordDecl, hasAnyDependentBases)
 
 AST_MATCHER (CXXMethodDecl, isTemplate)
 
 AST_MATCHER (CXXMethodDecl, isDependentContext)
 
 AST_MATCHER (CXXMethodDecl, isInsideMacroDefinition)
 
 AST_MATCHER_P (CXXMethodDecl, hasCanonicalDecl, ast_matchers::internal::Matcher< CXXMethodDecl >, InnerMatcher)
 
 AST_MATCHER (CXXMethodDecl, usesThis)
 
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 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, ...}.
 
 AST_MATCHER (CXXMethodDecl, usesThisAsConst)
 
static SourceLocation getConstInsertionPoint (const CXXMethodDecl *M)
 
static int getPrecedence (const BinaryOperator *BinOp)
 
static void addParantheses (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 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 DeclgetSourceExprDecl (const Expr *SourceExpr)
 
 AST_MATCHER (FunctionDecl, doesDeclarationForceExternallyVisibleDefinition)
 
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 (const 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)
 Checks if ArgType binds to ParamType regarding reference-ness and cv-qualifiers.
 
static bool isPointerOrArray (QualType TypeToCheck)
 
static bool isCompatibleWithArrayReference (QualType ArgType, QualType ParamType)
 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)
 Checks if multilevel pointers' qualifiers compatibility continues on the current pointer level.
 
static bool arePointerTypesCompatible (QualType ArgType, QualType ParamType, bool IsParamContinuouslyConst)
 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)
 
QualType getNonTemplateAlias (QualType QT)
 
static std::string createReplacement (const Expr *CondLhs, const Expr *CondRhs, const Expr *AssignLhs, const SourceManager &Source, const LangOptions &LO, StringRef FunctionName, const BinaryOperator *BO)
 

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"
 
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 HungarainNotationPrimitiveTypes []
 
static StringRef const HungarainNotationUserDefinedTypes []
 
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
 
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 130 of file IdentifierNamingCheck.cpp.

◆ UsageKind

Enumerator
Unused 
Const 
NonConst 

Definition at line 50 of file MakeMemberFunctionConstCheck.cpp.

Function Documentation

◆ addParantheses()

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

◆ advanceBeyondCurrentLine()

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

Definition at line 18 of file DuplicateIncludeCheck.cpp.

References Id, and Offset.

◆ AlgorithmHeader()

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

◆ applyAbbreviationHeuristic()

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

Definition at line 137 of file SuspiciousCallArgumentCheck.cpp.

◆ applyDiceHeuristic()

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

Definition at line 274 of file SuspiciousCallArgumentCheck.cpp.

References percentage().

◆ applyEqualityHeuristic()

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

Definition at line 133 of file SuspiciousCallArgumentCheck.cpp.

◆ applyJaroWinklerHeuristic()

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

Definition at line 213 of file SuspiciousCallArgumentCheck.cpp.

References Dist, and Range.

◆ applyLevenshteinHeuristic()

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

Definition at line 204 of file SuspiciousCallArgumentCheck.cpp.

References Dist.

◆ applyPrefixHeuristic()

static 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 152 of file SuspiciousCallArgumentCheck.cpp.

References percentage().

◆ applySubstringHeuristic()

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

Definition at line 175 of file SuspiciousCallArgumentCheck.cpp.

References percentage().

◆ applySuffixHeuristic()

static 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 164 of file SuspiciousCallArgumentCheck.cpp.

References percentage().

◆ areAllEnumeratorsInitialized()

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

Definition at line 40 of file EnumInitialValueCheck.cpp.

References Node.

◆ areBinaryOperatorOperandsTypesEqualToOperatorResultType()

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

◆ arePointersStillQualCompatible()

static bool clang::tidy::readability::arePointersStillQualCompatible ( QualType  ArgType,
QualType  ParamType,
bool &  IsParamContinuouslyConst 
)
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()

static bool clang::tidy::readability::arePointerTypesCompatible ( QualType  ArgType,
QualType  ParamType,
bool  IsParamContinuouslyConst 
)
static

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

Definition at line 361 of file SuspiciousCallArgumentCheck.cpp.

References arePointersStillQualCompatible(), and convertToPointeeOrArrayElementQualType().

Referenced by areTypesCompatible().

◆ areRefAndQualCompatible()

static bool clang::tidy::readability::areRefAndQualCompatible ( QualType  ArgType,
QualType  ParamType 
)
static

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

Definition at line 302 of file SuspiciousCallArgumentCheck.cpp.

Referenced by areTypesCompatible().

◆ areTypesCompatible()

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

◆ areTypesEqual() [1/2]

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

◆ areTypesEqual() [2/2]

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

Definition at line 41 of file RedundantCastingCheck.cpp.

References areTypesEqual().

◆ asBool()

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

Definition at line 100 of file SimplifyBooleanExprCheck.cpp.

References Text.

Referenced by replacementExpression().

◆ AST_MATCHER() [1/10]

clang::tidy::readability::AST_MATCHER ( CXXMethodDecl  ,
hasTrivialBody   
)

Definition at line 23 of file ConvertMemberFunctionsToStatic.cpp.

References Node.

◆ AST_MATCHER() [2/10]

clang::tidy::readability::AST_MATCHER ( CXXMethodDecl  ,
isDependentContext   
)

Definition at line 37 of file ConvertMemberFunctionsToStatic.cpp.

References Node.

◆ AST_MATCHER() [3/10]

clang::tidy::readability::AST_MATCHER ( CXXMethodDecl  ,
isInsideMacroDefinition   
)

Definition at line 41 of file ConvertMemberFunctionsToStatic.cpp.

References Node.

◆ AST_MATCHER() [4/10]

clang::tidy::readability::AST_MATCHER ( CXXMethodDecl  ,
isOverloadedOperator   
)

Definition at line 25 of file ConvertMemberFunctionsToStatic.cpp.

References Node.

◆ AST_MATCHER() [5/10]

clang::tidy::readability::AST_MATCHER ( CXXMethodDecl  ,
isStatic   
)

Definition at line 21 of file ConvertMemberFunctionsToStatic.cpp.

References Node.

◆ AST_MATCHER() [6/10]

clang::tidy::readability::AST_MATCHER ( CXXMethodDecl  ,
isTemplate   
)

Definition at line 33 of file ConvertMemberFunctionsToStatic.cpp.

References Node.

◆ AST_MATCHER() [7/10]

clang::tidy::readability::AST_MATCHER ( CXXMethodDecl  ,
usesThis   
)

◆ AST_MATCHER() [8/10]

clang::tidy::readability::AST_MATCHER ( CXXMethodDecl  ,
usesThisAsConst   
)

◆ AST_MATCHER() [9/10]

clang::tidy::readability::AST_MATCHER ( CXXRecordDecl  ,
hasAnyDependentBases   
)

Definition at line 29 of file ConvertMemberFunctionsToStatic.cpp.

References Node.

◆ AST_MATCHER() [10/10]

clang::tidy::readability::AST_MATCHER ( FunctionDecl  ,
doesDeclarationForceExternallyVisibleDefinition   
)

Definition at line 18 of file RedundantDeclarationCheck.cpp.

References Node.

◆ AST_MATCHER_P()

clang::tidy::readability::AST_MATCHER_P ( CXXMethodDecl  ,
hasCanonicalDecl  ,
ast_matchers::internal::Matcher< CXXMethodDecl >  ,
InnerMatcher   
)

Definition at line 50 of file ConvertMemberFunctionsToStatic.cpp.

References Builder, and Node.

◆ checkConditionVarUsageInElse()

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

◆ checkDef()

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

◆ checkInitDeclUsageInElse()

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

◆ cleanInitialValue()

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

◆ collectSourceRanges()

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

◆ compareExpressionToConstant()

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

Definition at line 141 of file SimplifyBooleanExprCheck.cpp.

References E.

Referenced by compareExpressionToNullPtr(), and compareExpressionToZero().

◆ compareExpressionToNullPtr()

static 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(), and E.

Referenced by replacementExpression().

◆ compareExpressionToZero()

static 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(), and E.

Referenced by replacementExpression().

◆ containsBoolLiteral()

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

Definition at line 609 of file SimplifyBooleanExprCheck.cpp.

References containsBoolLiteral(), and E.

Referenced by containsBoolLiteral().

◆ containsDeclInScope()

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

Definition at line 105 of file ElseAfterReturnCheck.cpp.

References Node.

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

◆ containsDiscardedTokens()

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

Definition at line 241 of file SimplifyBooleanExprCheck.cpp.

◆ convertToPointeeOrArrayElementQualType()

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

◆ countIndirections()

static 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()

static 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()

static 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()

static 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(), Decl, 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()

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

◆ findStartOfIndirection()

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

◆ findUsage()

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

◆ findUsageRange()

static 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 DeclRef, findUsageRange(), and Node.

Referenced by checkInitDeclUsageInElse(), and findUsageRange().

◆ flipDemorganBinaryOperator()

static 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()

static 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.

References Output.

Referenced by flipDemorganBinaryOperator().

◆ flipDemorganSide()

static 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 E, flipDemorganBinaryOperator(), and isMacroID().

Referenced by flipDemorganBinaryOperator().

◆ forwardSkipWhitespaceAndComments()

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

Definition at line 34 of file BracesAroundStatementsCheck.cpp.

References getTokenKind(), and Loc.

◆ getConstInsertionPoint()

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

◆ getConstructExpr()

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

◆ getConstructExprArgRange()

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

Definition at line 43 of file RedundantStringInitCheck.cpp.

References E.

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

◆ getControlFlowString()

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

◆ getDemorganFlippedOperator()

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

Definition at line 823 of file SimplifyBooleanExprCheck.cpp.

Referenced by flipDemorganBinaryOperator().

◆ getFullInitRangeInclWhitespaces()

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

◆ getInlineTokenLocation()

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

◆ getLocationOfConst()

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

◆ getNamespaceNameAsWritten()

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

◆ getNameSpecifierNestingLevel()

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

◆ getNonTemplateAlias()

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

Definition at line 62 of file UseStdMinMaxCheck.cpp.

Referenced by createReplacement().

◆ getOperatorName()

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

Definition at line 75 of file SimplifyBooleanExprCheck.cpp.

References Name, and OperatorNames.

Referenced by negatedOperator().

◆ getOperatorSpelling()

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

Definition at line 23 of file OperatorsRepresentationCheck.cpp.

References Loc.

◆ getPrecedence()

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

Definition at line 28 of file MathMissingParenthesesCheck.cpp.

Referenced by addParantheses().

◆ getPrecedingIf()

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

Definition at line 18 of file MisleadingIndentationCheck.cpp.

◆ getRepresentation()

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

Definition at line 128 of file OperatorsRepresentationCheck.cpp.

References Config().

Referenced by isAnyOperatorEnabled().

◆ getSourceExprDecl()

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

Definition at line 77 of file RedundantCastingCheck.cpp.

References E.

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

◆ getStringFromRange()

static 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 98 of file ConvertMemberFunctionsToStatic.cpp.

References Range.

Referenced by getLocationOfConst().

◆ getTokenKind()

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

Definition at line 20 of file BracesAroundStatementsCheck.cpp.

References Loc.

Referenced by forwardSkipWhitespaceAndComments().

◆ hasPreprocessorBranchEndBetweenLocations()

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

◆ isAnyOperatorEnabled()

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

Definition at line 138 of file OperatorsRepresentationCheck.cpp.

References Config(), and getRepresentation().

◆ isAtStartOfLineIncludingEmptyMacro()

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

◆ isCompatibleWithArrayReference()

static bool clang::tidy::readability::isCompatibleWithArrayReference ( QualType  ArgType,
QualType  ParamType 
)
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()

static 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.

◆ isMacroID()

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

Definition at line 51 of file IsolateDeclarationCheck.cpp.

Referenced by declRanges(), and flipDemorganSide().

◆ isNoneEnumeratorsInitialized()

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

Definition at line 23 of file EnumInitialValueCheck.cpp.

References Node.

◆ isNotOperatorStr()

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

◆ isOnlyFirstEnumeratorInitialized()

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

Definition at line 29 of file EnumInitialValueCheck.cpp.

References Node.

◆ isOverloadedUnaryOrBinarySymbolOperator()

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

◆ isPointerOrArray()

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

Definition at line 308 of file SuspiciousCallArgumentCheck.cpp.

Referenced by areTypesCompatible().

◆ isSeparator()

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

◆ isViableLoop()

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

Definition at line 73 of file UseAnyOfAllOfCheck.cpp.

References DeclRef.

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

◆ locationsInSameFile()

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

◆ maxCondition()

static 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

◆ minCondition()

static 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()

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

◆ needsNullPtrComparison()

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

Definition at line 107 of file SimplifyBooleanExprCheck.cpp.

References E.

Referenced by replacementExpression().

◆ needsParensAfterUnaryNegation()

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

Definition at line 45 of file SimplifyBooleanExprCheck.cpp.

References E.

Referenced by replacementExpression().

◆ needsStaticCast()

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

Definition at line 122 of file SimplifyBooleanExprCheck.cpp.

References E.

Referenced by replacementExpression().

◆ needsZeroComparison()

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

Definition at line 115 of file SimplifyBooleanExprCheck.cpp.

References E.

Referenced by replacementExpression().

◆ negatedOperator() [1/2]

static 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]

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

Definition at line 89 of file SimplifyBooleanExprCheck.cpp.

References getOperatorName(), and OppositeOverloads.

◆ percentage()

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

Returns how many % X is of Y.

Definition at line 131 of file SuspiciousCallArgumentCheck.cpp.

References X.

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

◆ removeElseAndBrackets()

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

Definition at line 115 of file ElseAfterReturnCheck.cpp.

References Loc.

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

◆ removeNamespaces()

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

◆ replacementExpression()

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

◆ shouldRemoveParens()

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

Definition at line 940 of file SimplifyBooleanExprCheck.cpp.

References Parent.

◆ translate()

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

◆ typeIsMemberPointer()

static 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()

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

Variable Documentation

◆ AddressOfName

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

◆ AddrOfContainerExprName

constexpr 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

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

◆ DefaultAbbreviations

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

◆ DefaultIgnoredExceptionVariableNames

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

Definition at line 25 of file IdentifierLengthCheck.cpp.

◆ DefaultIgnoredFloatingPointValues

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

Definition at line 74 of file MagicNumbersCheck.cpp.

◆ DefaultIgnoredIntegerValues

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

Definition at line 73 of file MagicNumbersCheck.cpp.

◆ DefaultIgnoredLoopCounterNames

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

Definition at line 23 of file IdentifierLengthCheck.cpp.

◆ DefaultIgnoredParameterNames

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

Definition at line 26 of file IdentifierLengthCheck.cpp.

◆ DefaultIgnoredVariableNames

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

Definition at line 24 of file IdentifierLengthCheck.cpp.

◆ DefaultMinimumExceptionNameLength

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

Definition at line 21 of file IdentifierLengthCheck.cpp.

◆ DefaultMinimumIdentifierNameLength

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

Definition at line 44 of file SuspiciousCallArgumentCheck.cpp.

◆ DefaultMinimumLoopCounterNameLength

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

Definition at line 20 of file IdentifierLengthCheck.cpp.

◆ DefaultMinimumParameterNameLength

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

Definition at line 22 of file IdentifierLengthCheck.cpp.

◆ DefaultMinimumVariableNameLength

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

Definition at line 19 of file IdentifierLengthCheck.cpp.

◆ Defaults

constexpr 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 50 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.

◆ 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::storeOptions().

◆ DerefContainerExprName

constexpr 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 28 of file IdentifierLengthCheck.cpp.

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

◆ HeuristicToString

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

Definition at line 46 of file SuspiciousCallArgumentCheck.cpp.

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

◆ HungarainNotationPrimitiveTypes

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

Definition at line 191 of file IdentifierNamingCheck.cpp.

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

◆ HungarainNotationUserDefinedTypes

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

Definition at line 227 of file IdentifierNamingCheck.cpp.

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

◆ IgnoreMacrosDefault

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

Definition at line 18 of file AvoidReturnWithVoidValueCheck.cpp.

◆ IgnoreMacrosName

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

Definition at line 17 of file AvoidReturnWithVoidValueCheck.cpp.

◆ 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.

◆ 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

constexpr 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 78 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().

◆ SimplifyConditionalReturnDiagnostic

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

Definition at line 42 of file SimplifyBooleanExprCheck.cpp.

◆ SimplifyConditionDiagnostic

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

Definition at line 40 of file SimplifyBooleanExprCheck.cpp.

◆ SimplifyOperatorDiagnostic

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

Definition at line 38 of file SimplifyBooleanExprCheck.cpp.

◆ SmallVectorSize

constexpr std::size_t clang::tidy::readability::SmallVectorSize
staticconstexpr
Initial value:
=
SuspiciousCallArgumentCheck::SmallVectorSize

Definition at line 127 of file SuspiciousCallArgumentCheck.cpp.

◆ StrictModeDefault

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

Definition at line 21 of file AvoidReturnWithVoidValueCheck.cpp.

◆ StrictModeName

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

Definition at line 20 of file AvoidReturnWithVoidValueCheck.cpp.

◆ StyleNames

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

◆ UnaryRepresentation

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

Definition at line 75 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