Lines Matching refs:DestType
50 CastOperation(Sema &S, QualType destType, ExprResult src)
51 : Self(S), SrcExpr(src), DestType(destType),
52 ResultType(destType.getNonLValueExprType(S.Context)),
53 ValueKind(Expr::getValueKindForType(destType)),
66 QualType DestType;
119 Self.CheckCastAlign(SrcExpr.get(), DestType, OpRange);
126 if (Self.CheckObjCARCConversion(OpRange, DestType, src, CCK) ==
157 QualType DestType, bool CStyle,
162 QualType DestType, bool CStyle,
168 QualType DestType, bool CStyle,
174 CanQualType DestType, bool CStyle,
182 QualType DestType,bool CStyle,
189 QualType DestType,
195 QualType DestType,
202 QualType DestType, bool CStyle,
205 QualType DestType, bool CStyle,
240 QualType DestType = DestTInfo->getType();
244 DestType->isDependentType() || Ex.get()->isTypeDependent();
246 CastOperation Op(*this, DestType, E);
308 QualType destType,
325 if (!destType->isRecordType() && !srcType->isRecordType())
328 InitializedEntity entity = InitializedEntity::InitializeTemporary(destType);
373 << CT << srcType << destType
383 SourceRange opRange, Expr *src, QualType destType,
386 tryDiagnoseOverloadedCast(S, castType, opRange, src, destType,
391 << src->getType() << destType << opRange << src->getSourceRange();
395 QualType From = destType;
478 /// DestType casts away constness as defined in C++ 5.2.11p8ff. This is used by
486 CastsAwayConstness(Sema &Self, QualType SrcType, QualType DestType,
504 assert((DestType->isAnyPointerType() || DestType->isMemberPointerType() ||
505 DestType->isBlockPointerType()) &&
509 UnwrappedDestType = Self.Context.getCanonicalType(DestType);
570 /// CheckDynamicCast - Check that a dynamic_cast\<DestType\>(SrcExpr) is valid.
582 QualType DestType = Self.Context.getCanonicalType(this->DestType);
588 const PointerType *DestPointer = DestType->getAs<PointerType>();
592 } else if ((DestReference = DestType->getAs<ReferenceType>())) {
596 << this->DestType << DestRange;
636 << CT_Dynamic << OrigSrcType << this->DestType << OpRange;
672 << CT_Dynamic << OrigSrcType << this->DestType << OpRange;
721 /// CheckConstCast - Check that a const_cast\<DestType\>(SrcExpr) is valid.
735 if (TryConstCast(Self, SrcExpr, DestType, /*CStyle*/false, msg) != TC_Success
738 << SrcExpr.get()->getType() << DestType << OpRange;
743 /// Check that a reinterpret_cast\<DestType\>(SrcExpr) is not used as upcast
746 QualType DestType,
761 const CXXRecordDecl *DestRD = DestType->getPointeeCXXRecordDecl();
823 ReinterpretKind == ReinterpretUpcast? DestType : SrcType;
825 ReinterpretKind == ReinterpretUpcast? SrcType : DestType;
836 /// CheckReinterpretCast - Check that a reinterpret_cast\<DestType\>(SrcExpr) is
851 TryReinterpretCast(Self, SrcExpr, DestType,
861 << DestType << OpRange;
866 DestType, /*listInitialization=*/false);
872 DiagnoseReinterpretUpDownCast(Self, SrcExpr.get(), DestType, OpRange);
877 /// CheckStaticCast - Check that a static_cast\<DestType\>(SrcExpr) is valid.
890 if (DestType->isVoidType()) {
897 OpRange, DestType, diag::err_bad_static_cast_overload);
906 if (ValueKind == VK_RValue && !DestType->isRecordType() &&
915 = TryStaticCast(Self, SrcExpr, DestType, Sema::CCK_OtherCast, OpRange, msg,
923 << oe->getName() << DestType << OpRange
927 diagnoseBadCast(Self, msg, CT_Static, OpRange, SrcExpr.get(), DestType,
945 QualType DestType,
974 tcr = TryStaticReferenceDowncast(Self, SrcExpr.get(), DestType, CStyle,
982 tcr = TryLValueToRValueCast(Self, SrcExpr.get(), DestType, CStyle, Kind,
989 tcr = TryStaticImplicitCast(Self, SrcExpr, DestType, CCK, OpRange, msg,
1011 if (DestType->isBooleanType()) {
1014 } else if (DestType->isIntegralType(Self.Context)) {
1017 } else if (DestType->isRealFloatingType()) {
1032 if (DestType->isEnumeralType()) {
1044 tcr = TryStaticPointerDowncast(Self, SrcType, DestType, CStyle, OpRange, msg,
1052 tcr = TryStaticMemberPointerUpcast(Self, SrcExpr, SrcType, DestType, CStyle,
1063 if (const PointerType *DestPointer = DestType->getAs<PointerType>()) {
1095 else if (DestType->isObjCObjectPointerType()) {
1101 else if (CStyle && DestType->isBlockPointerType()) {
1110 DestType->isObjCObjectPointerType()) {
1117 Self.CheckTollFreeBridgeStaticCast(DestType, SrcExpr.get(), Kind))
1123 if (auto DestPointer = DestType->getAs<PointerType>())
1134 TryLValueToRValueCast(Sema &Self, Expr *SrcExpr, QualType DestType,
1140 const RValueReferenceType *R = DestType->getAs<RValueReferenceType>();
1188 TryStaticReferenceDowncast(Sema &Self, Expr *SrcExpr, QualType DestType,
1201 const ReferenceType *DestReference = DestType->getAs<ReferenceType>();
1220 OpRange, SrcExpr->getType(), DestType, msg, Kind,
1226 TryStaticPointerDowncast(Sema &Self, QualType SrcType, QualType DestType,
1238 const PointerType *DestPointer = DestType->getAs<PointerType>();
1252 CStyle, OpRange, SrcType, DestType, msg, Kind,
1258 /// DestType is possible and allowed.
1260 TryStaticDowncast(Sema &Self, CanQualType SrcType, CanQualType DestType,
1266 !Self.isCompleteType(OpRange.getBegin(), DestType))
1270 if (!DestType->getAs<RecordType>() || !SrcType->getAs<RecordType>()) {
1276 if (!Self.IsDerivedFrom(OpRange.getBegin(), DestType, SrcType, Paths)) {
1299 if (!CStyle && !DestType.isAtLeastAsQualifiedAs(SrcType)) {
1312 Self.IsDerivedFrom(OpRange.getBegin(), DestType, SrcType, Paths);
1326 PathDisplayStr += QualType(DestType).getAsString();
1332 << QualType(DestType).getUnqualifiedType()
1348 SrcType, DestType,
1376 QualType DestType, bool CStyle,
1380 const MemberPointerType *DestMemPtr = DestType->getAs<MemberPointerType>();
1388 = Self.ResolveAddressOfOverloadedFunction(SrcExpr.get(), DestType, false,
1465 DestType,
1491 TryStaticImplicitCast(Sema &Self, ExprResult &SrcExpr, QualType DestType,
1495 if (DestType->isRecordType()) {
1496 if (Self.RequireCompleteType(OpRange.getBegin(), DestType,
1498 Self.RequireNonAbstractType(OpRange.getBegin(), DestType,
1505 InitializedEntity Entity = InitializedEntity::InitializeTemporary(DestType);
1523 if (InitSeq.Failed() && (CStyle || !DestType->isReferenceType()))
1544 QualType DestType, bool CStyle,
1546 DestType = Self.Context.getCanonicalType(DestType);
1550 if (const ReferenceType *DestTypeTmp =DestType->getAs<ReferenceType>()) {
1593 DestType = Self.Context.getPointerType(DestTypeTmp->getPointeeType());
1600 if (!DestType->isPointerType() &&
1601 !DestType->isMemberPointerType() &&
1602 !DestType->isObjCObjectPointerType()) {
1603 // Cannot cast to non-pointer, non-reference type. Note that, if DestType
1612 if (DestType->isFunctionPointerType() ||
1613 DestType->isMemberFunctionPointerType()) {
1628 while (SrcType != DestType &&
1629 Self.Context.UnwrapSimilarPointerTypes(SrcType, DestType)) {
1632 DestType = Self.Context.getUnqualifiedArrayType(DestType, DestQuals);
1643 if (SrcType != DestType)
1660 void Sema::CheckCompatibleReinterpretCast(QualType SrcType, QualType DestType,
1672 if (!SrcType->getAs<PointerType>() || !DestType->getAs<PointerType>()) {
1676 DestTy = DestType->getPointeeType();
1678 if (!DestType->getAs<ReferenceType>()) {
1682 DestTy = DestType->getPointeeType();
1707 Diag(Range.getBegin(), DiagID) << SrcType << DestType << Range;
1711 QualType DestType) {
1713 if (Self.Context.hasSameType(SrcType, DestType))
1717 QualType DT = DestType;
1718 if (isa<PointerType>(DestType))
1719 DT = DestType->getPointeeType();
1723 << SrcType << DestType << SrcExpr.get()->getSourceRange();
1728 const Expr *SrcExpr, QualType DestType,
1739 && Self.Context.getTypeSize(DestType) >
1746 unsigned Diag = DestType->isVoidPointerType() ?
1749 Self.Diag(Loc, Diag) << SrcType << DestType;
1754 QualType DestType, bool CStyle,
1760 DestType = Self.Context.getCanonicalType(DestType);
1772 Expr::getValueKindForType(DestType) == VK_RValue // Convert Fun to Ptr
1781 if (const ReferenceType *DestTypeTmp = DestType->getAs<ReferenceType>()) {
1790 Self.CheckCompatibleReinterpretCast(SrcType, DestType,
1810 << inappropriate << DestType
1817 DestType = Self.Context.getPointerType(DestTypeTmp->getPointeeType());
1826 const MemberPointerType *DestMemPtr = DestType->getAs<MemberPointerType>(),
1841 if (CastsAwayConstness(Self, SrcType, DestType, /*CheckCVR=*/!CStyle,
1851 (void)Self.isCompleteType(OpRange.getBegin(), DestType);
1868 if (SrcType->isNullPtrType() && DestType->isIntegralType(Self.Context)) {
1874 Self.Context.getTypeSize(DestType)) {
1884 bool destIsVector = DestType->isVectorType();
1890 if ((!destIsVector && !DestType->isIntegralType(Self.Context)) ||
1896 if (Self.areLaxCompatibleVectorTypes(SrcType, DestType)) {
1912 if (SrcType == DestType) {
1932 bool destIsPtr = DestType->isAnyPointerType() ||
1933 DestType->isBlockPointerType();
1942 if (DestType->isIntegralType(Self.Context)) {
1948 !DestType->isBooleanType();
1950 Self.Context.getTypeSize(DestType)) &&
1961 checkIntToPointerCast(CStyle, OpRange.getBegin(), SrcExpr.get(), DestType,
1979 if (CastsAwayConstness(Self, SrcType, DestType, /*CheckCVR=*/!CStyle,
1986 if ((SrcType->isBlockPointerType() && DestType->isObjCObjectPointerType()) ||
1987 (DestType->isBlockPointerType() && SrcType->isObjCObjectPointerType()))
1992 } else if (DestType->isObjCObjectPointerType()) {
1994 } else if (DestType->isBlockPointerType()) {
2006 if (CStyle && DestType->isObjCObjectPointerType()) {
2010 DiagnoseCastOfObjCSEL(Self, SrcExpr, DestType);
2016 if (DestType->isFunctionPointerType()) {
2035 if (DestType->isFunctionPointerType()) {
2058 SrcExpr = Self.checkUnknownAnyCast(DestRange, DestType,
2072 if (DestType->isVoidType()) {
2078 /* Complain */ true, DestRange, DestType,
2089 if (DestType->isDependentType() || SrcExpr.get()->isTypeDependent() ||
2095 if (ValueKind == VK_RValue && !DestType->isRecordType() &&
2103 if (const VectorType *vecTy = DestType->getAs<VectorType>())
2123 TryCastResult tcr = TryConstCast(Self, SrcExpr, DestType,
2135 tcr = TryStaticCast(Self, SrcExpr, DestType, CCK, OpRange,
2142 tcr = TryReinterpretCast(Self, SrcExpr, DestType, /*CStyle*/true,
2156 DestType,
2160 // If DestType is a function type (not to be confused with the function
2165 << OE->getName() << DestType << OpRange
2171 OpRange, SrcExpr.get(), DestType, ListInitialization);
2186 QualType DestType) {
2195 if (DestType.getUnqualifiedType()->isVoidType())
2198 && (DestType->isAnyPointerType() || DestType->isBlockPointerType()))
2200 if (SrcType->isIntegerType() && DestType->isIntegerType() &&
2201 (SrcType->isBooleanType() == DestType->isBooleanType()) &&
2202 (SrcType->isEnumeralType() == DestType->isEnumeralType()))
2204 if (SrcType->isRealFloatingType() && DestType->isRealFloatingType())
2206 if (SrcType->isEnumeralType() && DestType->isEnumeralType())
2208 if (SrcType->isComplexType() && DestType->isComplexType())
2210 if (SrcType->isComplexIntegerType() && DestType->isComplexIntegerType())
2215 << SrcType << DestType << SrcExpr.get()->getSourceRange();
2224 SrcExpr = Self.checkUnknownAnyCast(DestRange, DestType,
2232 if (DestType->isVoidType()) {
2247 SrcExpr.get(), DestType, /*Complain=*/true, DAP))
2262 if (Self.getLangOpts().OpenCL && DestType->isPointerType() &&
2264 const PointerType *DestPtr = DestType->getAs<PointerType>();
2268 << SrcType << DestType << Sema::AA_Casting
2275 if (Self.RequireCompleteType(OpRange.getBegin(), DestType,
2281 if (!DestType->isScalarType() && !DestType->isVectorType()) {
2282 const RecordType *DestRecordTy = DestType->getAs<RecordType>();
2284 if (DestRecordTy && Self.Context.hasSameUnqualifiedType(DestType, SrcType)){
2287 << DestType << SrcExpr.get()->getSourceRange();
2317 << DestType << SrcExpr.get()->getSourceRange();
2333 if (DestType->isExtVectorType()) {
2334 SrcExpr = Self.CheckExtVectorCast(OpRange, DestType, SrcExpr.get(), Kind);
2338 if (const VectorType *DestVecTy = DestType->getAs<VectorType>()) {
2342 } else if (Self.CheckVectorCast(OpRange, DestType, SrcType, Kind)) {
2349 if (Self.CheckVectorCast(OpRange, SrcType, DestType, Kind))
2367 if (!DestType->isArithmeticType()) {
2376 DestType, Self);
2378 if (!DestType->isIntegralType(Self.Context) &&
2379 DestType->isArithmeticType()) {
2382 << DestType << SrcExpr.get()->getSourceRange();
2389 if (DestType->isHalfType()) {
2391 << DestType << SrcExpr.get()->getSourceRange();
2403 if (const PointerType *CastPtr = DestType->getAs<PointerType>()) {
2412 << SrcType << DestType << Sema::AA_Casting
2418 else if (!Self.CheckObjCARCUnavailableWeakConversion(DestType, SrcType)) {
2421 << 1 << SrcType << DestType << SrcExpr.get()->getSourceRange();
2427 DiagnoseCastOfObjCSEL(Self, SrcExpr, DestType);
2428 DiagnoseBadFunctionCast(Self, SrcExpr, DestType);
2429 Kind = Self.PrepareScalarCast(SrcExpr, DestType);
2439 if (SrcType->isAnyPointerType() && DestType->isAnyPointerType() &&
2440 CastsAwayConstness(Self, SrcType, DestType, true, false,
2454 SrcType << DestType;