clang 20.0.0git
Public Member Functions | Public Attributes | List of all members
clang::StandardConversionSequence Class Reference

StandardConversionSequence - represents a standard conversion sequence (C++ 13.3.3.1.1). More...

#include "clang/Sema/Overload.h"

Public Member Functions

void setFromType (QualType T)
 
void setToType (unsigned Idx, QualType T)
 
void setAllToTypes (QualType T)
 
QualType getFromType () const
 
QualType getToType (unsigned Idx) const
 
void setAsIdentityConversion ()
 StandardConversionSequence - Set the standard conversion sequence to the identity conversion.
 
bool isIdentityConversion () const
 
ImplicitConversionRank getRank () const
 getRank - Retrieve the rank of this standard conversion sequence (C++ 13.3.3.1.1p3).
 
NarrowingKind getNarrowingKind (ASTContext &Context, const Expr *Converted, APValue &ConstantValue, QualType &ConstantType, bool IgnoreFloatToIntegralConversion=false) const
 Check if this standard conversion sequence represents a narrowing conversion, according to C++11 [dcl.init.list]p7.
 
bool isPointerConversionToBool () const
 isPointerConversionToBool - Determines whether this conversion is a conversion of a pointer or pointer-to-member to bool.
 
bool isPointerConversionToVoidPointer (ASTContext &Context) const
 isPointerConversionToVoidPointer - Determines whether this conversion is a conversion of a pointer to a void pointer.
 
void dump () const
 dump - Print this standard conversion sequence to standard error.
 

Public Attributes

ImplicitConversionKind First: 8
 First – The first conversion can be an lvalue-to-rvalue conversion, array-to-pointer conversion, or function-to-pointer conversion.
 
ImplicitConversionKind Second: 8
 Second - The second conversion can be an integral promotion, floating point promotion, integral conversion, floating point conversion, floating-integral conversion, pointer conversion, pointer-to-member conversion, or boolean conversion.
 
ImplicitConversionKind Dimension: 8
 Dimension - Between the second and third conversion a vector or matrix dimension conversion may occur.
 
ImplicitConversionKind Third: 8
 Third - The third conversion can be a qualification conversion or a function conversion.
 
unsigned DeprecatedStringLiteralToCharPtr: 1
 Whether this is the deprecated conversion of a string literal to a pointer to non-const character data (C++ 4.2p2).
 
unsigned QualificationIncludesObjCLifetime: 1
 Whether the qualification conversion involves a change in the Objective-C lifetime (for automatic reference counting).
 
unsigned IncompatibleObjC: 1
 IncompatibleObjC - Whether this is an Objective-C conversion that we should warn about (if we actually use it).
 
unsigned ReferenceBinding: 1
 ReferenceBinding - True when this is a reference binding (C++ [over.ics.ref]).
 
unsigned DirectBinding: 1
 DirectBinding - True when this is a reference binding that is a direct binding (C++ [dcl.init.ref]).
 
unsigned IsLvalueReference: 1
 Whether this is an lvalue reference binding (otherwise, it's an rvalue reference binding).
 
unsigned BindsToFunctionLvalue: 1
 Whether we're binding to a function lvalue.
 
unsigned BindsToRvalue: 1
 Whether we're binding to an rvalue.
 
unsigned BindsImplicitObjectArgumentWithoutRefQualifier: 1
 Whether this binds an implicit object argument to a non-static member function without a ref-qualifier.
 
unsigned ObjCLifetimeConversionBinding: 1
 Whether this binds a reference to an object with a different Objective-C lifetime qualifier.
 
void * FromTypePtr
 FromType - The type that this conversion is converting from.
 
void * ToTypePtrs [3]
 ToType - The types that this conversion is converting to in each step.
 
CXXConstructorDeclCopyConstructor
 CopyConstructor - The copy constructor that is used to perform this conversion, when the conversion is actually just the initialization of an object via copy constructor.
 
DeclAccessPair FoundCopyConstructor
 

Detailed Description

StandardConversionSequence - represents a standard conversion sequence (C++ 13.3.3.1.1).

A standard conversion sequence contains between zero and three conversions. If a particular conversion is not needed, it will be set to the identity conversion (ICK_Identity).

Definition at line 292 of file Overload.h.

Member Function Documentation

◆ dump()

LLVM_DUMP_METHOD void StandardConversionSequence::dump ( ) const

dump - Print this standard conversion sequence to standard error.

Useful for debugging overloading issues.

Definition at line 613 of file SemaOverload.cpp.

References CopyConstructor, DirectBinding, First, GetImplicitConversionName(), clang::ICK_Identity, ReferenceBinding, Second, and Third.

Referenced by clang::UserDefinedConversionSequence::dump(), and clang::ImplicitConversionSequence::dump().

◆ getFromType()

QualType clang::StandardConversionSequence::getFromType ( ) const
inline

◆ getNarrowingKind()

NarrowingKind StandardConversionSequence::getNarrowingKind ( ASTContext Ctx,
const Expr Converted,
APValue ConstantValue,
QualType ConstantType,
bool  IgnoreFloatToIntegralConversion = false 
) const

Check if this standard conversion sequence represents a narrowing conversion, according to C++11 [dcl.init.list]p7.

Parameters
CtxThe AST context.
ConvertedThe result of applying this standard conversion sequence.
ConstantValueIf this is an NK_Constant_Narrowing conversion, the value of the expression prior to the narrowing conversion.
ConstantTypeIf this is an NK_Constant_Narrowing conversion, the type of the expression prior to the narrowing conversion.
IgnoreFloatToIntegralConversionIf true type-narrowing conversions from floating point types to integral types should be ignored.

Definition at line 362 of file SemaOverload.cpp.

References clang::Type::getAs(), clang::APValue::getFloat(), clang::ASTContext::getFloatingTypeOrder(), clang::ASTContext::getFloatTypeSemantics(), clang::ASTContext::getIntWidth(), clang::ASTContext::getLangOpts(), getToType(), clang::ICK_Boolean_Conversion, clang::ICK_Complex_Real, clang::ICK_Floating_Conversion, clang::ICK_Floating_Integral, clang::ICK_Floating_Promotion, clang::ICK_Integral_Conversion, IgnoreNarrowingConversion(), clang::Initializer, clang::Type::isComplexType(), clang::APValue::isFloat(), clang::Type::isIntegralOrUnscopedEnumerationType(), clang::Type::isIntegralType(), clang::Type::isRealFloatingType(), clang::Type::isSignedIntegerOrEnumerationType(), clang::NK_Constant_Narrowing, clang::NK_Dependent_Narrowing, clang::NK_Not_Narrowing, clang::NK_Type_Narrowing, clang::NK_Variable_Narrowing, clang::Result, Second, and clang::Expr::EvalResult::Val.

Referenced by BuildConvertedConstantExpression(), CheckC23ConstexprInitConversion(), checkThreeWayNarrowingConversion(), and DiagnoseNarrowingInInitList().

◆ getRank()

ImplicitConversionRank StandardConversionSequence::getRank ( ) const

getRank - Retrieve the rank of this standard conversion sequence (C++ 13.3.3.1.1p3).

The rank is the largest rank of each of the implicit conversions.

Definition at line 261 of file SemaOverload.cpp.

References Dimension, First, clang::GetConversionRank(), clang::GetDimensionConversionRank(), clang::ICR_Exact_Match, Second, and Third.

Referenced by CompareStandardConversionSequences().

◆ getToType()

QualType clang::StandardConversionSequence::getToType ( unsigned  Idx) const
inline

◆ isIdentityConversion()

bool clang::StandardConversionSequence::isIdentityConversion ( ) const
inline

Definition at line 405 of file Overload.h.

References Dimension, clang::ICK_Identity, Second, and Third.

Referenced by compareStandardConversionSubsets().

◆ isPointerConversionToBool()

bool StandardConversionSequence::isPointerConversionToBool ( ) const

isPointerConversionToBool - Determines whether this conversion is a conversion of a pointer or pointer-to-member to bool.

This is used as part of the ranking of standard conversion sequences (C++ 13.3.3.2p4).

Definition at line 278 of file SemaOverload.cpp.

References First, getFromType(), getToType(), clang::ICK_Array_To_Pointer, clang::ICK_Function_To_Pointer, and isBooleanType().

Referenced by CompareStandardConversionSequences().

◆ isPointerConversionToVoidPointer()

bool StandardConversionSequence::isPointerConversionToVoidPointer ( ASTContext Context) const

isPointerConversionToVoidPointer - Determines whether this conversion is a conversion of a pointer to a void pointer.

This is used as part of the ranking of standard conversion sequences (C++ 13.3.3.2p4).

Definition at line 299 of file SemaOverload.cpp.

References First, clang::ASTContext::getArrayDecayedType(), clang::Type::getAs(), getFromType(), clang::Type::getPointeeType(), getToType(), clang::ICK_Array_To_Pointer, clang::ICK_Pointer_Conversion, clang::Type::isAnyPointerType(), clang::Type::isVoidType(), and Second.

Referenced by CompareStandardConversionSequences().

◆ setAllToTypes()

void clang::StandardConversionSequence::setAllToTypes ( QualType  T)
inline

◆ setAsIdentityConversion()

void StandardConversionSequence::setAsIdentityConversion ( )

◆ setFromType()

void clang::StandardConversionSequence::setFromType ( QualType  T)
inline

◆ setToType()

void clang::StandardConversionSequence::setToType ( unsigned  Idx,
QualType  T 
)
inline

Member Data Documentation

◆ BindsImplicitObjectArgumentWithoutRefQualifier

unsigned clang::StandardConversionSequence::BindsImplicitObjectArgumentWithoutRefQualifier

Whether this binds an implicit object argument to a non-static member function without a ref-qualifier.

Definition at line 356 of file Overload.h.

Referenced by isBetterReferenceBindingKind(), setAsIdentityConversion(), TryListConversion(), TryObjectArgumentInitialization(), and TryReferenceInit().

◆ BindsToFunctionLvalue

unsigned clang::StandardConversionSequence::BindsToFunctionLvalue

Whether we're binding to a function lvalue.

Definition at line 347 of file Overload.h.

Referenced by isBetterReferenceBindingKind(), setAsIdentityConversion(), TryListConversion(), TryObjectArgumentInitialization(), and TryReferenceInit().

◆ BindsToRvalue

unsigned clang::StandardConversionSequence::BindsToRvalue

Whether we're binding to an rvalue.

Definition at line 351 of file Overload.h.

Referenced by isBetterReferenceBindingKind(), setAsIdentityConversion(), TryListConversion(), TryObjectArgumentInitialization(), and TryReferenceInit().

◆ CopyConstructor

CXXConstructorDecl* clang::StandardConversionSequence::CopyConstructor

CopyConstructor - The copy constructor that is used to perform this conversion, when the conversion is actually just the initialization of an object via copy constructor.

Such conversions are either identity conversions or derived-to-base conversions.

Definition at line 378 of file Overload.h.

Referenced by dump(), IsStandardConversion(), clang::Sema::PerformImplicitConversion(), setAsIdentityConversion(), TryImplicitConversion(), TryReferenceInit(), and TryUserDefinedConversion().

◆ DeprecatedStringLiteralToCharPtr

unsigned clang::StandardConversionSequence::DeprecatedStringLiteralToCharPtr

Whether this is the deprecated conversion of a string literal to a pointer to non-const character data (C++ 4.2p2).

Definition at line 318 of file Overload.h.

Referenced by CompareQualificationConversions(), hasDeprecatedStringLiteralToCharPtrConversion(), IsStandardConversion(), clang::Sema::PerformImplicitConversion(), setAsIdentityConversion(), and TryReferenceInit().

◆ Dimension

ImplicitConversionKind clang::StandardConversionSequence::Dimension

Dimension - Between the second and third conversion a vector or matrix dimension conversion may occur.

If this is not ICK_Identity this conversion truncates the vector or matrix, or extends a scalar.

Definition at line 308 of file Overload.h.

Referenced by dropPointerConversion(), getRank(), isIdentityConversion(), IsStandardConversion(), clang::Sema::PerformImplicitConversion(), setAsIdentityConversion(), and TryReferenceInit().

◆ DirectBinding

unsigned clang::StandardConversionSequence::DirectBinding

DirectBinding - True when this is a reference binding that is a direct binding (C++ [dcl.init.ref]).

Definition at line 338 of file Overload.h.

Referenced by BuildConvertedConstantExpression(), dump(), FindConversionForRefInit(), setAsIdentityConversion(), TryObjectArgumentInitialization(), and TryReferenceInit().

◆ First

ImplicitConversionKind clang::StandardConversionSequence::First

◆ FoundCopyConstructor

DeclAccessPair clang::StandardConversionSequence::FoundCopyConstructor

Definition at line 379 of file Overload.h.

Referenced by clang::Sema::PerformImplicitConversion(), and TryUserDefinedConversion().

◆ FromTypePtr

void* clang::StandardConversionSequence::FromTypePtr

FromType - The type that this conversion is converting from.

This is an opaque pointer that can be translated into a QualType.

Definition at line 366 of file Overload.h.

Referenced by getFromType(), and setFromType().

◆ IncompatibleObjC

unsigned clang::StandardConversionSequence::IncompatibleObjC

IncompatibleObjC - Whether this is an Objective-C conversion that we should warn about (if we actually use it).

Definition at line 328 of file Overload.h.

Referenced by IsStandardConversion(), and clang::Sema::PerformImplicitConversion().

◆ IsLvalueReference

unsigned clang::StandardConversionSequence::IsLvalueReference

Whether this is an lvalue reference binding (otherwise, it's an rvalue reference binding).

Definition at line 343 of file Overload.h.

Referenced by isBetterReferenceBindingKind(), setAsIdentityConversion(), TryListConversion(), TryObjectArgumentInitialization(), and TryReferenceInit().

◆ ObjCLifetimeConversionBinding

unsigned clang::StandardConversionSequence::ObjCLifetimeConversionBinding

Whether this binds a reference to an object with a different Objective-C lifetime qualifier.

Definition at line 361 of file Overload.h.

Referenced by CompareStandardConversionSequences(), setAsIdentityConversion(), TryListConversion(), and TryReferenceInit().

◆ QualificationIncludesObjCLifetime

unsigned clang::StandardConversionSequence::QualificationIncludesObjCLifetime

Whether the qualification conversion involves a change in the Objective-C lifetime (for automatic reference counting).

Definition at line 323 of file Overload.h.

Referenced by CompareQualificationConversions(), IsStandardConversion(), setAsIdentityConversion(), and tryAtomicConversion().

◆ ReferenceBinding

unsigned clang::StandardConversionSequence::ReferenceBinding

ReferenceBinding - True when this is a reference binding (C++ [over.ics.ref]).

Definition at line 333 of file Overload.h.

Referenced by BuildConvertedConstantExpression(), CompareStandardConversionSequences(), dump(), FindConversionForRefInit(), setAsIdentityConversion(), TryListConversion(), TryObjectArgumentInitialization(), and TryReferenceInit().

◆ Second

ImplicitConversionKind clang::StandardConversionSequence::Second

◆ Third

ImplicitConversionKind clang::StandardConversionSequence::Third

◆ ToTypePtrs

void* clang::StandardConversionSequence::ToTypePtrs[3]

ToType - The types that this conversion is converting to in each step.

This is an opaque pointer that can be translated into a QualType.

Definition at line 371 of file Overload.h.

Referenced by dropPointerConversion(), getToType(), setAllToTypes(), and setToType().


The documentation for this class was generated from the following files: