clang-tools 22.0.0git
clang::tidy::bugprone::model Namespace Reference

Functions

 LLVM_ENABLE_BITMASK_ENUMS_IN_NAMESPACE ()
static bool hasFlag (MixFlags Data, MixFlags SearchedFlag)
 Returns whether the SearchedFlag is turned on in the Data.
static std::string formatMixFlags (MixFlags F)
 Formats the MixFlags enum into a useful, user-readable representation.
static MixData isLRefEquallyBindingToType (const TheCheck &Check, const LValueReferenceType *LRef, QualType Ty, const ASTContext &Ctx, bool IsRefRHS, ImplicitConversionModellingMode ImplicitMode)
 Calculates if the reference binds an expression of the given type.
static MixData approximateImplicitConversion (const TheCheck &Check, QualType LType, QualType RType, const ASTContext &Ctx, ImplicitConversionModellingMode ImplicitMode)
 Returns whether an expression of LType can be used in an RType context, as per the implicit conversion rules.
static bool isUselessSugar (const Type *T)
static NonCVRQualifiersResult getNonCVRQualifiers (const ASTContext &Ctx, QualType LType, QualType RType)
 Returns if the two types are qualified in a way that ever after equating or removing local CVR qualification, even if the unqualified types would mix, the qualified ones don't, because there are some other local qualifiers that aren't equal.
static MixData calculateMixability (const TheCheck &Check, QualType LType, QualType RType, const ASTContext &Ctx, ImplicitConversionModellingMode ImplicitMode)
 Approximate the way how LType and RType might refer to "essentially the same" type, in a sense that at a particular call site, an expression of type LType and RType might be successfully passed to a variable (in our specific case, a parameter) of type RType and LType, respectively.
static bool isDerivedToBase (const CXXRecordDecl *Derived, const CXXRecordDecl *Base)
static std::optional< QualType > approximateStandardConversionSequence (const TheCheck &Check, QualType From, QualType To, const ASTContext &Ctx)
static std::optional< ConversionSequence > tryConversionOperators (const TheCheck &Check, const CXXRecordDecl *RD, QualType ToType)
static std::optional< ConversionSequence > tryConvertingConstructors (const TheCheck &Check, QualType FromType, const CXXRecordDecl *RD)
static MixableParameterRange modelMixingRange (const TheCheck &Check, const FunctionDecl *FD, std::size_t StartIndex, const filter::SimilarlyUsedParameterPairSuppressor &UsageBasedSuppressor)

Function Documentation

◆ approximateImplicitConversion()

MixData clang::tidy::bugprone::model::approximateImplicitConversion ( const TheCheck & Check,
QualType LType,
QualType RType,
const ASTContext & Ctx,
ImplicitConversionModellingMode ImplicitMode )
static

Returns whether an expression of LType can be used in an RType context, as per the implicit conversion rules.

Note: the result of this operation, unlike that of calculateMixability, is NOT symmetric.

Definition at line 1310 of file EasilySwappableParametersCheck.cpp.

References approximateImplicitConversion(), approximateStandardConversionSequence(), tryConversionOperators(), and tryConvertingConstructors().

Referenced by approximateImplicitConversion(), and calculateMixability().

◆ approximateStandardConversionSequence()

std::optional< QualType > clang::tidy::bugprone::model::approximateStandardConversionSequence ( const TheCheck & Check,
QualType From,
QualType To,
const ASTContext & Ctx )
static

◆ calculateMixability()

MixData clang::tidy::bugprone::model::calculateMixability ( const TheCheck & Check,
QualType LType,
QualType RType,
const ASTContext & Ctx,
ImplicitConversionModellingMode ImplicitMode )
static

Approximate the way how LType and RType might refer to "essentially the same" type, in a sense that at a particular call site, an expression of type LType and RType might be successfully passed to a variable (in our specific case, a parameter) of type RType and LType, respectively.

Note the swapped order!

The returned data structure is not guaranteed to be properly set, as this function is potentially recursive. It is the caller's responsibility to call sanitize() on the result once the recursion is over.

Definition at line 653 of file EasilySwappableParametersCheck.cpp.

References approximateImplicitConversion(), calculateMixability(), getNonCVRQualifiers(), hasFlag(), isLRefEquallyBindingToType(), isUselessSugar(), and clang::tidy::bugprone::EasilySwappableParametersCheck::QualifiersMix.

Referenced by approximateStandardConversionSequence(), calculateMixability(), isLRefEquallyBindingToType(), and modelMixingRange().

◆ formatMixFlags()

std::string clang::tidy::bugprone::model::formatMixFlags ( MixFlags F)
inlinestatic

Formats the MixFlags enum into a useful, user-readable representation.

Definition at line 156 of file EasilySwappableParametersCheck.cpp.

References hasFlag().

Referenced by modelMixingRange().

◆ getNonCVRQualifiers()

NonCVRQualifiersResult clang::tidy::bugprone::model::getNonCVRQualifiers ( const ASTContext & Ctx,
QualType LType,
QualType RType )
static

Returns if the two types are qualified in a way that ever after equating or removing local CVR qualification, even if the unqualified types would mix, the qualified ones don't, because there are some other local qualifiers that aren't equal.

Definition at line 612 of file EasilySwappableParametersCheck.cpp.

Referenced by calculateMixability().

◆ hasFlag()

bool clang::tidy::bugprone::model::hasFlag ( MixFlags Data,
MixFlags SearchedFlag )
inlinestatic

Returns whether the SearchedFlag is turned on in the Data.

Definition at line 140 of file EasilySwappableParametersCheck.cpp.

Referenced by approximateStandardConversionSequence(), calculateMixability(), formatMixFlags(), and clang::tidy::bugprone::needsToElaborateImplicitConversion().

◆ isDerivedToBase()

bool clang::tidy::bugprone::model::isDerivedToBase ( const CXXRecordDecl * Derived,
const CXXRecordDecl * Base )
inlinestatic

◆ isLRefEquallyBindingToType()

MixData clang::tidy::bugprone::model::isLRefEquallyBindingToType ( const TheCheck & Check,
const LValueReferenceType * LRef,
QualType Ty,
const ASTContext & Ctx,
bool IsRefRHS,
ImplicitConversionModellingMode ImplicitMode )
static

Calculates if the reference binds an expression of the given type.

This is true iff 'LRef' is some 'const T &' type, and the 'Ty' is 'T' or 'const T'.

Parameters
ImplicitModeis forwarded in the possible recursive call to calculateMixability.

Definition at line 901 of file EasilySwappableParametersCheck.cpp.

References calculateMixability().

Referenced by calculateMixability().

◆ isUselessSugar()

bool clang::tidy::bugprone::model::isUselessSugar ( const Type * T)
inlinestatic

Definition at line 588 of file EasilySwappableParametersCheck.cpp.

Referenced by calculateMixability().

◆ LLVM_ENABLE_BITMASK_ENUMS_IN_NAMESPACE()

clang::tidy::bugprone::model::LLVM_ENABLE_BITMASK_ENUMS_IN_NAMESPACE ( )

◆ modelMixingRange()

◆ tryConversionOperators()

std::optional< ConversionSequence > clang::tidy::bugprone::model::tryConversionOperators ( const TheCheck & Check,
const CXXRecordDecl * RD,
QualType ToType )
static

Definition at line 1206 of file EasilySwappableParametersCheck.cpp.

Referenced by approximateImplicitConversion().

◆ tryConvertingConstructors()

std::optional< ConversionSequence > clang::tidy::bugprone::model::tryConvertingConstructors ( const TheCheck & Check,
QualType FromType,
const CXXRecordDecl * RD )
static

Definition at line 1257 of file EasilySwappableParametersCheck.cpp.

Referenced by approximateImplicitConversion().