clang-tools 20.0.0git
|
The results of the steps of an Implicit Conversion Sequence is saved in an instance of this record. More...
Classes | |
struct | UserDefinedConversionOperator |
struct | UserDefinedConvertingConstructor |
Public Types | |
enum | UserDefinedConversionKind { UDCK_None , UDCK_Ctor , UDCK_Oper } |
Public Member Functions | |
ConversionSequence () | |
ConversionSequence (QualType From, QualType To) | |
operator bool () const | |
SmallVector< QualType, 4 > | getInvolvedTypesInSequence () const |
Returns all the "steps" (non-unique and non-similar) types involved in the conversion sequence. | |
ConversionSequence & | update (const ConversionSequence &RHS) |
Updates the steps of the conversion sequence with the steps from the other instance. | |
void | setConversion (const UserDefinedConvertingConstructor &UDCC) |
Sets the user-defined conversion to the given constructor. | |
void | setConversion (const UserDefinedConversionOperator &UDCO) |
Sets the user-defined conversion to the given operator. | |
QualType | getTypeAfterUserDefinedConversion () const |
Returns the type in the conversion that's formally "in our hands" once the user-defined conversion is executed. | |
const CXXMethodDecl * | getUserDefinedConversionFunction () const |
SourceRange | getUserDefinedConversionHighlight () const |
Returns the SourceRange in the text that corresponds to the interesting part of the user-defined conversion. | |
Public Attributes | |
QualType | Begin |
The type the conversion stared from. | |
QualType | AfterFirstStandard |
The intermediate type after the first Standard Conversion Sequence. | |
union { | |
char None | |
UserDefinedConvertingConstructor UDConvCtor | |
UserDefinedConversionOperator UDConvOp | |
}; | |
The details of the user-defined conversion involved, as a tagged union. | |
UserDefinedConversionKind | UDConvKind |
QualType | AfterSecondStandard |
The intermediate type after performing the second Standard Conversion Sequence. | |
QualType | End |
The result type the conversion targeted. | |
The results of the steps of an Implicit Conversion Sequence is saved in an instance of this record.
A ConversionSequence maps the steps of the conversion with a member for each type involved in the conversion. Imagine going from a hypothetical Complex class to projecting it to the real part as a const double.
I.e., given:
struct Complex { operator double() const; };
void functionBeingAnalysed(Complex C, const double R);
we will get the following sequence:
(Begin=) Complex
The first standard conversion is a qualification adjustment.
(AfterFirstStandard=) const Complex
Then the user-defined conversion is executed.
(UDConvOp.ConversionOperatorResultType=) double
Then this 'double' is qualifier-adjusted to 'const double'.
(AfterSecondStandard=) double
The conversion's result has now been calculated, so it ends here. (End=) double.
Explicit storing of Begin and End in this record is needed, because getting to what Begin and End here are needs further resolution of types, e.g. in the case of typedefs:
using Comp = Complex; using CD = const double; void functionBeingAnalysed2(Comp C, CD R);
In this case, the user will be diagnosed with a potential conversion between the two typedefs as written in the code, but to elaborate the reasoning behind this conversion, we also need to show what the typedefs mean. See FormattedConversionSequence towards the bottom of this file!
Definition at line 225 of file EasilySwappableParametersCheck.cpp.
Enumerator | |
---|---|
UDCK_None | |
UDCK_Ctor | |
UDCK_Oper |
Definition at line 226 of file EasilySwappableParametersCheck.cpp.
|
inline |
Definition at line 261 of file EasilySwappableParametersCheck.cpp.
|
inline |
Definition at line 262 of file EasilySwappableParametersCheck.cpp.
|
inline |
Returns all the "steps" (non-unique and non-similar) types involved in the conversion sequence.
This method does NOT return Begin and End.
Definition at line 272 of file EasilySwappableParametersCheck.cpp.
References AfterFirstStandard, AfterSecondStandard, clang::tidy::bugprone::model::ConversionSequence::UserDefinedConvertingConstructor::ConstructorParameterType, clang::tidy::bugprone::model::ConversionSequence::UserDefinedConversionOperator::ConversionOperatorResultType, UDCK_Ctor, UDCK_None, UDCK_Oper, UDConvCtor, UDConvKind, UDConvOp, clang::tidy::bugprone::model::ConversionSequence::UserDefinedConvertingConstructor::UserDefinedType, and clang::tidy::bugprone::model::ConversionSequence::UserDefinedConversionOperator::UserDefinedType.
|
inline |
Returns the type in the conversion that's formally "in our hands" once the user-defined conversion is executed.
Definition at line 341 of file EasilySwappableParametersCheck.cpp.
References clang::tidy::bugprone::model::ConversionSequence::UserDefinedConversionOperator::ConversionOperatorResultType, UDCK_Ctor, UDCK_None, UDCK_Oper, UDConvCtor, UDConvKind, UDConvOp, and clang::tidy::bugprone::model::ConversionSequence::UserDefinedConvertingConstructor::UserDefinedType.
|
inline |
Definition at line 353 of file EasilySwappableParametersCheck.cpp.
References clang::tidy::bugprone::model::ConversionSequence::UserDefinedConvertingConstructor::Fun, clang::tidy::bugprone::model::ConversionSequence::UserDefinedConversionOperator::Fun, UDCK_Ctor, UDCK_None, UDCK_Oper, UDConvCtor, UDConvKind, and UDConvOp.
Referenced by clang::tidy::bugprone::EasilySwappableParametersCheck::check().
|
inline |
Returns the SourceRange in the text that corresponds to the interesting part of the user-defined conversion.
This is either the parameter type in a converting constructor, or the conversion result type in a conversion operator.
Definition at line 369 of file EasilySwappableParametersCheck.cpp.
References clang::tidy::bugprone::model::ConversionSequence::UserDefinedConvertingConstructor::Fun, clang::tidy::bugprone::model::ConversionSequence::UserDefinedConversionOperator::Fun, UDCK_Ctor, UDCK_None, UDCK_Oper, UDConvCtor, UDConvKind, and UDConvOp.
Referenced by clang::tidy::bugprone::EasilySwappableParametersCheck::check().
|
inlineexplicit |
Definition at line 265 of file EasilySwappableParametersCheck.cpp.
References AfterFirstStandard, AfterSecondStandard, UDCK_None, and UDConvKind.
|
inline |
Sets the user-defined conversion to the given operator.
Definition at line 334 of file EasilySwappableParametersCheck.cpp.
References UDCK_Oper, UDConvKind, and UDConvOp.
|
inline |
Sets the user-defined conversion to the given constructor.
Definition at line 328 of file EasilySwappableParametersCheck.cpp.
References UDCK_Ctor, UDConvCtor, and UDConvKind.
|
inline |
Updates the steps of the conversion sequence with the steps from the other instance.
Definition at line 306 of file EasilySwappableParametersCheck.cpp.
References AfterFirstStandard, AfterSecondStandard, UDCK_Ctor, UDCK_None, UDCK_Oper, UDConvCtor, UDConvKind, and UDConvOp.
union { ... } clang::tidy::bugprone::model::ConversionSequence::@1 |
The details of the user-defined conversion involved, as a tagged union.
QualType clang::tidy::bugprone::model::ConversionSequence::AfterFirstStandard |
The intermediate type after the first Standard Conversion Sequence.
Definition at line 244 of file EasilySwappableParametersCheck.cpp.
Referenced by clang::tidy::bugprone::model::approximateImplicitConversion(), clang::tidy::bugprone::model::calculateMixability(), getInvolvedTypesInSequence(), operator bool(), and update().
QualType clang::tidy::bugprone::model::ConversionSequence::AfterSecondStandard |
The intermediate type after performing the second Standard Conversion Sequence.
Definition at line 256 of file EasilySwappableParametersCheck.cpp.
Referenced by clang::tidy::bugprone::model::calculateMixability(), getInvolvedTypesInSequence(), operator bool(), and update().
QualType clang::tidy::bugprone::model::ConversionSequence::Begin |
The type the conversion stared from.
Definition at line 241 of file EasilySwappableParametersCheck.cpp.
QualType clang::tidy::bugprone::model::ConversionSequence::End |
The result type the conversion targeted.
Definition at line 259 of file EasilySwappableParametersCheck.cpp.
char clang::tidy::bugprone::model::ConversionSequence::None |
Definition at line 248 of file EasilySwappableParametersCheck.cpp.
UserDefinedConvertingConstructor clang::tidy::bugprone::model::ConversionSequence::UDConvCtor |
Definition at line 249 of file EasilySwappableParametersCheck.cpp.
Referenced by getInvolvedTypesInSequence(), getTypeAfterUserDefinedConversion(), getUserDefinedConversionFunction(), getUserDefinedConversionHighlight(), setConversion(), and update().
UserDefinedConversionKind clang::tidy::bugprone::model::ConversionSequence::UDConvKind |
Definition at line 252 of file EasilySwappableParametersCheck.cpp.
Referenced by clang::tidy::bugprone::model::calculateMixability(), clang::tidy::bugprone::EasilySwappableParametersCheck::check(), getInvolvedTypesInSequence(), getTypeAfterUserDefinedConversion(), getUserDefinedConversionFunction(), getUserDefinedConversionHighlight(), operator bool(), setConversion(), and update().
UserDefinedConversionOperator clang::tidy::bugprone::model::ConversionSequence::UDConvOp |
Definition at line 250 of file EasilySwappableParametersCheck.cpp.
Referenced by getInvolvedTypesInSequence(), getTypeAfterUserDefinedConversion(), getUserDefinedConversionFunction(), getUserDefinedConversionHighlight(), setConversion(), and update().