Lines Matching refs:ToType
54 static bool IsStandardConversion(Sema &S, Expr* From, QualType ToType,
61 QualType &ToType,
66 IsUserDefinedConversion(Sema &S, Expr *From, QualType ToType,
246 QualType ToType = getToType(1);
255 if (const PointerType* ToPtrType = ToType->getAs<PointerType>())
303 QualType ToType = getToType(1);
312 if (FromType->isRealFloatingType() && ToType->isIntegralType(Ctx)) {
314 } else if (FromType->isIntegralType(Ctx) && ToType->isRealFloatingType()) {
320 llvm::APFloat Result(Ctx.getFloatTypeSemantics(ToType));
346 if (FromType->isRealFloatingType() && ToType->isRealFloatingType() &&
347 Ctx.getFloatingTypeOrder(FromType, ToType) == 1) {
348 // FromType is larger than ToType.
357 Ctx.getFloatTypeSemantics(ToType),
384 assert(ToType->isIntegralOrUnscopedEnumerationType());
387 const bool ToSigned = ToType->isSignedIntegerOrEnumerationType();
388 const unsigned ToWidth = Ctx.getIntWidth(ToType);
392 // Not all values of FromType can be represented in ToType.
997 /// \brief Tries a user-defined conversion from From to ToType.
1002 TryUserDefinedConversion(Sema &S, Expr *From, QualType ToType,
1013 ICS.setBad(BadConversionSequence::no_conversion, From, ToType);
1020 = IsUserDefinedConversion(S, From, ToType, ICS.UserDefined, Conversions,
1037 = S.Context.getCanonicalType(ToType).getUnqualifiedType();
1045 ICS.Standard.setAllToTypes(ToType);
1060 ICS.setBad(BadConversionSequence::suppressed_user, From, ToType);
1065 ICS.Ambiguous.setToType(ToType);
1071 ICS.setBad(BadConversionSequence::no_conversion, From, ToType);
1078 /// from the given expression (Expr) to the given type (ToType). This
1105 TryImplicitConversion(Sema &S, Expr *From, QualType ToType,
1112 if (IsStandardConversion(S, From, ToType, InOverloadResolution,
1119 ICS.setBad(BadConversionSequence::no_conversion, From, ToType);
1131 if (ToType->getAs<RecordType>() && FromType->getAs<RecordType>() &&
1132 (S.Context.hasSameUnqualifiedType(FromType, ToType) ||
1133 S.IsDerivedFrom(FromType, ToType))) {
1137 ICS.Standard.setAllToTypes(ToType);
1146 if (!S.Context.hasSameUnqualifiedType(FromType, ToType))
1152 return TryUserDefinedConversion(S, From, ToType, SuppressUserConversions,
1158 Sema::TryImplicitConversion(Expr *From, QualType ToType,
1164 return clang::TryImplicitConversion(*this, From, ToType,
1171 /// expression From to the type ToType. Returns the
1176 Sema::PerformImplicitConversion(Expr *From, QualType ToType,
1179 return PerformImplicitConversion(From, ToType, Action, AllowExplicit, ICS);
1183 Sema::PerformImplicitConversion(Expr *From, QualType ToType,
1194 ICS = clang::TryImplicitConversion(*this, From, ToType,
1200 return PerformImplicitConversion(From, ToType, ICS, Action);
1203 /// \brief Determine whether the conversion from FromType to ToType is a valid
1205 bool Sema::IsNoReturnConversion(QualType FromType, QualType ToType,
1207 if (Context.hasSameUnqualifiedType(FromType, ToType))
1215 CanQualType CanTo = Context.getCanonicalType(ToType);
1247 ResultTy = ToType;
1251 /// \brief Determine whether the conversion from FromType to ToType is a valid
1257 QualType ToType, ImplicitConversionKind &ICK) {
1260 if (!ToType->isVectorType() && !FromType->isVectorType())
1264 if (Context.hasSameUnqualifiedType(FromType, ToType))
1268 if (ToType->isExtVectorType()) {
1285 if (ToType->isVectorType() && FromType->isVectorType()) {
1286 if (Context.areCompatibleVectorTypes(FromType, ToType) ||
1288 (Context.getTypeSize(FromType) == Context.getTypeSize(ToType)))) {
1297 static bool tryAtomicConversion(Sema &S, Expr *From, QualType ToType,
1304 /// expression From to the type ToType. Standard conversion sequences
1310 static bool IsStandardConversion(Sema &S, Expr* From, QualType ToType,
1326 if (FromType->isRecordType() || ToType->isRecordType()) {
1340 = S.ResolveAddressOfOverloadedFunction(From, ToType, false,
1346 // we can sometimes resolve &foo<int> regardless of ToType, so check
1349 S.ExtractUnqualifiedFunctionType(ToType), FromType)) {
1353 S.ExtractUnqualifiedFunctionType(ToType), resultTy))
1355 if (!ToType->isBooleanType())
1417 if (S.IsStringLiteralToNonConstPointerConversion(From, ToType)) {
1453 if (S.Context.hasSameUnqualifiedType(FromType, ToType)) {
1457 } else if (S.IsIntegralPromotion(From, FromType, ToType)) {
1460 FromType = ToType.getUnqualifiedType();
1461 } else if (S.IsFloatingPointPromotion(FromType, ToType)) {
1464 FromType = ToType.getUnqualifiedType();
1465 } else if (S.IsComplexPromotion(FromType, ToType)) {
1468 FromType = ToType.getUnqualifiedType();
1469 } else if (ToType->isBooleanType() &&
1479 ToType->isIntegralType(S.Context)) {
1482 FromType = ToType.getUnqualifiedType();
1483 } else if (FromType->isAnyComplexType() && ToType->isComplexType()) {
1486 FromType = ToType.getUnqualifiedType();
1487 } else if ((FromType->isAnyComplexType() && ToType->isArithmeticType()) ||
1488 (ToType->isAnyComplexType() && FromType->isArithmeticType())) {
1491 FromType = ToType.getUnqualifiedType();
1492 } else if (FromType->isRealFloatingType() && ToType->isRealFloatingType()) {
1495 FromType = ToType.getUnqualifiedType();
1497 ToType->isIntegralType(S.Context)) ||
1499 ToType->isRealFloatingType())) {
1502 FromType = ToType.getUnqualifiedType();
1503 } else if (S.IsBlockPointerConversion(FromType, ToType, FromType)) {
1506 S.isObjCWritebackConversion(FromType, ToType, FromType)) {
1508 } else if (S.IsPointerConversion(From, FromType, ToType, InOverloadResolution,
1514 } else if (S.IsMemberPointerConversion(From, FromType, ToType,
1518 } else if (IsVectorConversion(S.Context, FromType, ToType, SecondICK)) {
1520 FromType = ToType.getUnqualifiedType();
1522 S.Context.typesAreCompatible(ToType, FromType)) {
1525 FromType = ToType.getUnqualifiedType();
1526 } else if (S.IsNoReturnConversion(FromType, ToType, FromType)) {
1529 } else if (IsTransparentUnionStandardConversion(S, From, ToType,
1533 FromType = ToType;
1534 } else if (tryAtomicConversion(S, From, ToType, InOverloadResolution, SCS,
1549 if (S.IsQualificationConversion(FromType, ToType, CStyle,
1553 FromType = ToType;
1555 CanonTo = S.Context.getCanonicalType(ToType);
1565 CanonTo = S.Context.getCanonicalType(ToType);
1571 FromType = ToType;
1587 QualType &ToType,
1592 const RecordType *UT = ToType->getAsUnionType();
1603 ToType = it->getType();
1612 /// ToType is an integral promotion (C++ 4.5). If so, returns true and
1614 bool Sema::IsIntegralPromotion(Expr *From, QualType FromType, QualType ToType) {
1615 const BuiltinType *To = ToType->getAs<BuiltinType>();
1633 Context.getTypeSize(FromType) < Context.getTypeSize(ToType)))) {
1659 if (ToType->isIntegerType() &&
1661 return Context.hasSameUnqualifiedType(ToType,
1675 ToType->isIntegerType()) {
1696 return Context.hasSameUnqualifiedType(ToType, PromoteTypes[Idx]);
1717 ToSize = Context.getTypeSize(ToType);
1745 /// FromType to ToType is a floating point promotion (C++ 4.6). If so,
1747 bool Sema::IsFloatingPointPromotion(QualType FromType, QualType ToType) {
1749 if (const BuiltinType *ToBuiltin = ToType->getAs<BuiltinType>()) {
1779 bool Sema::IsComplexPromotion(QualType FromType, QualType ToType) {
1784 const ComplexType *ToComplex = ToType->getAs<ComplexType>();
1796 /// same type qualifiers as FromPtr has on its pointee type. ToType,
1797 /// if non-empty, will be a pointer to ToType that may or may not have
1802 QualType ToPointee, QualType ToType,
1810 if (ToType->isObjCIdType() || ToType->isObjCQualifiedIdType())
1811 return ToType.getUnqualifiedType();
1823 // ToType is exactly what we need. Return it.
1824 if (!ToType.isNull())
1825 return ToType.getUnqualifiedType();
1829 if (isa<ObjCObjectPointerType>(ToType))
1838 if (isa<ObjCObjectPointerType>(ToType))
1859 /// can be converted to the type ToType via a pointer conversion (C++
1861 /// might differ from ToType in its cv-qualifiers at some level) into
1873 bool Sema::IsPointerConversion(Expr *From, QualType FromType, QualType ToType,
1878 if (isObjCPointerConversion(FromType, ToType, ConvertedType,
1883 if (ToType->isObjCObjectPointerType() &&
1885 ConvertedType = ToType;
1890 if (FromType->isBlockPointerType() && ToType->isPointerType() &&
1891 ToType->getAs<PointerType>()->getPointeeType()->isVoidType()) {
1892 ConvertedType = ToType;
1897 if (ToType->isBlockPointerType() &&
1899 ConvertedType = ToType;
1905 if (ToType->isNullPtrType() &&
1907 ConvertedType = ToType;
1911 const PointerType* ToTypePtr = ToType->getAs<PointerType>();
1917 ConvertedType = ToType;
1929 ToType, Context);
1950 ToType, Context,
1960 ToType, Context);
1970 ToType, Context);
1994 ToType, Context);
2002 ToType, Context);
2026 bool Sema::isObjCPointerConversion(QualType FromType, QualType ToType,
2037 ToType->getAs<ObjCObjectPointerType>();
2052 ConvertedType = AdoptQualifiers(Context, ToType, FromQualifiers);
2058 Context.ObjCQualifiedIdTypesAreCompatible(ToType, FromType,
2060 ConvertedType = AdoptQualifiers(Context, ToType, FromQualifiers);
2074 ToType, Context);
2086 ToType, Context);
2093 if (const PointerType *ToCPtr = ToType->getAs<PointerType>())
2096 ToType->getAs<BlockPointerType>()) {
2100 ConvertedType = AdoptQualifiers(Context, ToType, FromQualifiers);
2109 ConvertedType = AdoptQualifiers(Context, ToType, FromQualifiers);
2204 ConvertedType = AdoptQualifiers(Context, ToType, FromQualifiers);
2218 /// \param ToType The type we're converting to.
2222 bool Sema::isObjCWritebackConversion(QualType FromType, QualType ToType,
2225 Context.hasSameUnqualifiedType(FromType, ToType))
2230 if (const PointerType *ToPointer = ToType->getAs<PointerType>())
2280 bool Sema::IsBlockPointerConversion(QualType FromType, QualType ToType,
2284 ToType->getAs<BlockPointerType>())
2366 ConvertedType = ToType;
2383 QualType FromType, QualType ToType) {
2385 if (FromType.isNull() || ToType.isNull()) {
2391 if (FromType->isMemberPointerType() && ToType->isMemberPointerType()) {
2393 *ToMember = ToType->getAs<MemberPointerType>();
2400 ToType = ToMember->getPointeeType();
2405 if (ToType->isPointerType())
2406 ToType = ToType->getPointeeType();
2410 ToType = ToType.getNonReferenceType();
2420 if (Context.hasSameType(FromType, ToType)) {
2426 *ToFunction = ToType->getAs<FunctionProtoType>();
2492 ToType = (*O);
2494 if (!Context.hasSameType(ToType, FromType)) {
2495 if (const PointerType *PTTo = ToType->getAs<PointerType>()) {
2504 ToType->getAs<ObjCObjectPointerType>()) {
2520 /// expression From to the type ToType. This routine checks for
2525 bool Sema::CheckPointerConversion(Expr *From, QualType ToType,
2539 << ToType << From->getSourceRange());
2541 if (const PointerType *ToPtrType = ToType->getAs<PointerType>()) {
2561 ToType->getAs<ObjCObjectPointerType>()) {
2574 } else if (ToType->isBlockPointerType()) {
2589 /// converted to the type ToType via a member pointer conversion (C++ 4.11).
2591 /// ToType in its cv-qualifiers at some level) into ConvertedType.
2593 QualType ToType,
2596 const MemberPointerType *ToTypePtr = ToType->getAs<MemberPointerType>();
2604 ConvertedType = ToType;
2630 /// expression From to the type ToType. This routine checks for ambiguous or
2635 bool Sema::CheckMemberPointerConversion(Expr *From, QualType ToType,
2650 const MemberPointerType *ToPtrType = ToType->getAs<MemberPointerType>();
2695 /// an rvalue of type FromType to ToType is a qualification conversion
2702 Sema::IsQualificationConversion(QualType FromType, QualType ToType,
2705 ToType = Context.getCanonicalType(ToType);
2708 // If FromType and ToType are the same type, this is not a
2710 if (FromType.getUnqualifiedType() == ToType.getUnqualifiedType())
2718 while (Context.UnwrapSimilarPointerTypes(FromType, ToType)) {
2728 Qualifiers ToQuals = ToType.getQualifiers();
2769 // We are left with FromType and ToType being the pointee types
2770 // after unwrapping the original FromType and ToType the same number
2772 // ToType have the same unqualified type (since we checked
2774 return UnwrappedAnyPointer && Context.hasSameUnqualifiedType(FromType,ToType);
2782 static bool tryAtomicConversion(Sema &S, Expr *From, QualType ToType,
2786 const AtomicType *ToAtomic = ToType->getAs<AtomicType>();
2819 IsInitializerListConstructorConversion(Sema &S, Expr *From, QualType ToType,
2847 isFirstArgumentCompatibleWithType(S.Context, Constructor, ToType);
2877 User.After.setAllToTypes(ToType);
2894 /// ToType. If such a conversion exists, User will contain the
2903 IsUserDefinedConversion(Sema &S, Expr *From, QualType ToType,
2912 if (const RecordType *ToRecordType = ToType->getAs<RecordType>()) {
2921 if (S.Context.hasSameUnqualifiedType(ToType, From->getType()) ||
2923 S.IsDerivedFrom(From->getType(), ToType)))
2926 S.RequireCompleteType(From->getLocStart(), ToType, S.PDiag());
2928 // during template instantiation, but ToType may be complete enough now
2930 if (ToType->isIncompleteType()) {
2941 S, From, ToType, ToRecordDecl, User, CandidateSet, AllowExplicit);
2983 S.Context, Constructor, ToType);
2993 // From->ToType conversion via an static cast (c-style, etc).
3032 ActingContext, From, ToType,
3036 From, ToType, CandidateSet);
3075 User.After.setAllToTypes(ToType);
3122 Sema::DiagnoseMultipleUserDefinedConversion(Expr *From, QualType ToType) {
3126 IsUserDefinedConversion(*this, From, ToType, ICS.UserDefined,
3131 << From->getType() << ToType << From->getSourceRange();
3135 << From->getType() << ToType << From->getSourceRange();
4293 TryCopyInitialization(Sema &S, Expr *From, QualType ToType,
4299 /// TryListConversion - Try to copy-initialize a value of type ToType from the
4302 TryListConversion(Sema &S, InitListExpr *From, QualType ToType,
4311 Result.setBad(BadConversionSequence::no_conversion, From, ToType);
4316 if (S.RequireCompleteType(From->getLocStart(), ToType, S.PDiag()))
4326 if (ToType->isArrayType())
4327 X = S.Context.getBaseElementType(ToType);
4329 toStdInitializerList = S.isStdInitializerList(ToType, &X);
4354 ToType);
4355 Result.Standard.setAllToTypes(ToType);
4369 if (ToType->isRecordType() && !ToType->isAggregateType()) {
4371 Result = TryUserDefinedConversion(S, From, ToType, SuppressUserConversions,
4383 if (ToType->isAggregateType()) {
4388 InitializedEntity::InitializeParameter(S.Context, ToType,
4398 Result.UserDefined.After.setFromType(ToType);
4399 Result.UserDefined.After.setAllToTypes(ToType);
4407 if (ToType->isReferenceType()) {
4412 QualType T1 = ToType->getAs<ReferenceType>()->getPointeeType();
4427 Init, ToType, false, Found))
4440 return TryReferenceInit(S, Init, ToType,
4457 if (ToType->isRValueReferenceType() ||
4462 SCS.IsLvalueReference = ToType->isLValueReferenceType();
4469 From, ToType);
4475 if (!ToType->isRecordType()) {
4481 Result = TryCopyInitialization(S, From->getInit(0), ToType,
4490 Result.Standard.setFromType(ToType);
4491 Result.Standard.setAllToTypes(ToType);
4503 /// ToType from the expression From. Return the implicit conversion
4509 TryCopyInitialization(Sema &S, Expr *From, QualType ToType,
4515 return TryListConversion(S, FromInitList, ToType, SuppressUserConversions,
4518 if (ToType->isReferenceType())
4519 return TryReferenceInit(S, From, ToType,
4524 return TryImplicitConversion(S, From, ToType,
5594 /// and ToType is the type that we're eventually trying to convert to
5601 Expr *From, QualType ToType,
5620 Candidate.FinalConversion.setAllToTypes(ToType);
5653 QualType ToCanon = Context.getCanonicalType(ToType).getUnqualifiedType();
5662 // convert to (ToType), we need to synthesize a call to the
5691 TryCopyInitialization(*this, &Call, ToType,
5715 if (ToType->isRValueReferenceType() &&
5742 Expr *From, QualType ToType,
5753 = DeduceTemplateArguments(FunctionTemplate, ToType,
5771 AddConversionCandidate(Specialization, FoundDecl, ActingDC, From, ToType,
8807 // [ToType] [Return]
9021 /// expression with overloaded function type and @p ToType is the type