clang-tools 20.0.0git
|
Classes | |
struct | ConversionSequence |
The results of the steps of an Implicit Conversion Sequence is saved in an instance of this record. More... | |
struct | Mix |
A named tuple that contains the information for a mix between two concrete parameters. More... | |
struct | MixableParameterRange |
struct | MixData |
Contains the metadata for the mixability result between two types, independently of which parameters they were calculated from. More... | |
Enumerations | |
enum class | MixFlags : unsigned char { Invalid = 0 , WorkaroundDisableCanonicalEquivalence = 1 , None = 2 , Trivial = 4 , Canonical = 8 , TypeAlias = 16 , ReferenceBind = 32 , Qualifiers = 64 , ImplicitConversion = 128 } |
The language features involved in allowing the mix between two parameters. More... | |
enum class | ImplicitConversionModellingMode : unsigned char { None , All , OneWaySingleStandardOnly } |
Helper enum for the recursive calls in the modelling that toggle what kinds of implicit conversions are to be modelled. More... | |
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) |
|
strong |
Helper enum for the recursive calls in the modelling that toggle what kinds of implicit conversions are to be modelled.
Definition at line 556 of file EasilySwappableParametersCheck.cpp.
|
strong |
The language features involved in allowing the mix between two parameters.
Enumerator | |
---|---|
Invalid | Sentinel bit pattern. DO NOT USE! |
WorkaroundDisableCanonicalEquivalence | Certain constructs (such as pointers to noexcept/non-noexcept functions) have the same CanonicalType, which would result in false positives. During the recursive modelling call, this flag is set if a later diagnosed canonical type equivalence should be thrown away. |
None | Mix between the two parameters is not possible. |
Trivial | The two mix trivially, and are the exact same type. |
Canonical | The two mix because the types refer to the same CanonicalType, but we do not elaborate as to how. |
TypeAlias | The path from one type to the other involves desugaring type aliases. |
ReferenceBind | The mix involves the binding power of "const &". |
Qualifiers | The mix involves change in the qualifiers. |
ImplicitConversion | The mixing of the parameters is possible through implicit conversions between the types. |
Definition at line 110 of file EasilySwappableParametersCheck.cpp.
|
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 1299 of file EasilySwappableParametersCheck.cpp.
References clang::tidy::bugprone::model::ConversionSequence::AfterFirstStandard, All, approximateImplicitConversion(), approximateStandardConversionSequence(), clang::tidy::bugprone::model::MixData::Conversion, ImplicitConversion, clang::tidy::bugprone::model::MixData::indicatesMixability(), None, OneWaySingleStandardOnly, Trivial, tryConversionOperators(), and tryConvertingConstructors().
Referenced by approximateImplicitConversion(), and calculateMixability().
|
static |
Definition at line 955 of file EasilySwappableParametersCheck.cpp.
References calculateMixability(), clang::tidy::bugprone::model::MixData::Flags, hasFlag(), isDerivedToBase(), None, Qualifiers, and clang::tidy::bugprone::model::MixData::sanitize().
Referenced by approximateImplicitConversion().
|
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 644 of file EasilySwappableParametersCheck.cpp.
References clang::tidy::bugprone::model::ConversionSequence::AfterFirstStandard, clang::tidy::bugprone::model::ConversionSequence::AfterSecondStandard, approximateImplicitConversion(), calculateMixability(), Canonical, clang::tidy::bugprone::model::MixData::Conversion, clang::tidy::bugprone::model::MixData::Flags, getNonCVRQualifiers(), hasFlag(), ImplicitConversion, clang::tidy::bugprone::model::MixData::indicatesMixability(), isLRefEquallyBindingToType(), isUselessSugar(), None, OneWaySingleStandardOnly, Qualifiers, ReferenceBind, clang::tidy::bugprone::model::MixData::sanitize(), Trivial, TypeAlias, clang::tidy::bugprone::model::ConversionSequence::UDCK_None, clang::tidy::bugprone::model::ConversionSequence::UDConvKind, clang::tidy::bugprone::model::MixData::withCommonTypeTransformed(), and WorkaroundDisableCanonicalEquivalence.
Referenced by approximateStandardConversionSequence(), calculateMixability(), isLRefEquallyBindingToType(), and modelMixingRange().
|
inlinestatic |
Formats the MixFlags enum into a useful, user-readable representation.
Definition at line 151 of file EasilySwappableParametersCheck.cpp.
References Canonical, hasFlag(), ImplicitConversion, Invalid, None, Qualifiers, ReferenceBind, Trivial, TypeAlias, and WorkaroundDisableCanonicalEquivalence.
Referenced by modelMixingRange().
|
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 603 of file EasilySwappableParametersCheck.cpp.
References Qualifiers.
Referenced by calculateMixability().
|
inlinestatic |
Returns whether the SearchedFlag is turned on in the Data.
Definition at line 135 of file EasilySwappableParametersCheck.cpp.
References Invalid.
Referenced by approximateStandardConversionSequence(), calculateMixability(), formatMixFlags(), and clang::tidy::bugprone::model::MixData::sanitize().
|
inlinestatic |
Definition at line 948 of file EasilySwappableParametersCheck.cpp.
Referenced by approximateStandardConversionSequence().
|
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'.
ImplicitMode | is forwarded in the possible recursive call to calculateMixability. |
Definition at line 892 of file EasilySwappableParametersCheck.cpp.
References calculateMixability(), None, and Trivial.
Referenced by calculateMixability().
|
inlinestatic |
Definition at line 579 of file EasilySwappableParametersCheck.cpp.
Referenced by calculateMixability().
clang::tidy::bugprone::model::LLVM_ENABLE_BITMASK_ENUMS_IN_NAMESPACE | ( | ) |
|
static |
Definition at line 1412 of file EasilySwappableParametersCheck.cpp.
References All, calculateMixability(), formatMixFlags(), clang::tidy::bugprone::filter::isIgnoredParameter(), M, clang::tidy::bugprone::model::MixableParameterRange::Mixes, None, clang::tidy::bugprone::model::MixableParameterRange::NumParamsChecked, and clang::tidy::bugprone::filter::prefixSuffixCoverUnderThreshold().
|
static |
Definition at line 1195 of file EasilySwappableParametersCheck.cpp.
References clang::tidy::bugprone::model::ConversionSequence::UserDefinedConversionOperator::ConversionOperatorResultType, clang::tidy::bugprone::model::ConversionSequence::UserDefinedConversionOperator::Fun, and clang::tidy::bugprone::model::ConversionSequence::UserDefinedConversionOperator::UserDefinedType.
Referenced by approximateImplicitConversion().
|
static |
Definition at line 1246 of file EasilySwappableParametersCheck.cpp.
References clang::tidy::bugprone::model::ConversionSequence::UserDefinedConvertingConstructor::ConstructorParameterType, clang::tidy::bugprone::model::ConversionSequence::UserDefinedConvertingConstructor::Fun, and clang::tidy::bugprone::model::ConversionSequence::UserDefinedConvertingConstructor::UserDefinedType.
Referenced by approximateImplicitConversion().