27#include "llvm/ADT/SmallVector.h"
28#include "llvm/ADT/StringExtras.h"
58 struct CastOperation {
60 :
Self(S), SrcExpr(src), DestType(destType),
63 Kind(CK_Dependent), IsARCUnbridgedCast(
false) {
74 !DestType->isArrayType()) {
75 DestType = DestType.getAtomicUnqualifiedType();
80 PlaceholderKind = placeholder->getKind();
94 bool IsARCUnbridgedCast;
100 void CheckConstCast();
101 void CheckReinterpretCast();
102 void CheckStaticCast();
103 void CheckDynamicCast();
104 void CheckCXXCStyleCast(
bool FunctionalCast,
bool ListInitialization);
105 void CheckCStyleCast();
106 void CheckBuiltinBitCast();
107 void CheckAddrspaceCast();
109 void updatePartOfExplicitCastFlags(
CastExpr *CE) {
113 for (;
auto *ICE = dyn_cast<ImplicitCastExpr>(CE->
getSubExpr()); CE = ICE)
114 ICE->setIsPartOfExplicitCast(
true);
122 if (IsARCUnbridgedCast) {
124 Self.Context,
Self.Context.ARCUnbridgedCastTy, CK_Dependent,
126 Self.CurFPFeatureOverrides());
128 updatePartOfExplicitCastFlags(
castExpr);
138 if (PlaceholderKind != K)
return false;
144 bool isPlaceholder()
const {
145 return PlaceholderKind != 0;
148 return PlaceholderKind == K;
154 void checkCastAlign() {
155 Self.CheckCastAlign(SrcExpr.
get(), DestType, OpRange);
159 assert(
Self.getLangOpts().allowsNonTrivialObjCLifetimeQualifiers());
162 if (
Self.CheckObjCConversion(OpRange, DestType, src, CCK) ==
164 IsARCUnbridgedCast =
true;
169 void checkNonOverloadPlaceholders() {
170 if (!isPlaceholder() || isPlaceholder(BuiltinType::Overload))
173 SrcExpr =
Self.CheckPlaceholderExpr(SrcExpr.
get());
182 if (
const auto *PtrType = dyn_cast<PointerType>(FromType)) {
183 if (PtrType->getPointeeType()->hasAttr(attr::NoDeref)) {
184 if (
const auto *DestType = dyn_cast<PointerType>(ToType)) {
185 if (!DestType->getPointeeType()->hasAttr(attr::NoDeref)) {
186 S.
Diag(OpLoc, diag::warn_noderef_to_dereferenceable_pointer);
193 struct CheckNoDerefRAII {
194 CheckNoDerefRAII(CastOperation &Op) : Op(Op) {}
195 ~CheckNoDerefRAII() {
196 if (!Op.SrcExpr.isInvalid())
197 CheckNoDeref(Op.Self, Op.SrcExpr.get()->getType(), Op.ResultType,
198 Op.OpRange.getBegin());
240 QualType OrigDestType,
unsigned &msg,
256 bool ListInitialization);
263 bool ListInitialization);
311 CastOperation Op(*
this, DestType, E);
313 Op.DestRange = AngleBrackets;
316 default: llvm_unreachable(
"Unknown C++ cast!");
318 case tok::kw_addrspace_cast:
319 if (!TypeDependent) {
320 Op.CheckAddrspaceCast();
321 if (Op.SrcExpr.isInvalid())
325 Context, Op.ResultType, Op.ValueKind, Op.Kind, Op.SrcExpr.get(),
326 DestTInfo, OpLoc,
Parens.getEnd(), AngleBrackets));
328 case tok::kw_const_cast:
329 if (!TypeDependent) {
331 if (Op.SrcExpr.isInvalid())
336 Op.ValueKind, Op.SrcExpr.get(), DestTInfo,
340 case tok::kw_dynamic_cast: {
343 return ExprError(
Diag(OpLoc, diag::err_openclcxx_not_supported)
347 if (!TypeDependent) {
348 Op.CheckDynamicCast();
349 if (Op.SrcExpr.isInvalid())
353 Op.ValueKind, Op.Kind, Op.SrcExpr.get(),
354 &Op.BasePath, DestTInfo,
358 case tok::kw_reinterpret_cast: {
359 if (!TypeDependent) {
360 Op.CheckReinterpretCast();
361 if (Op.SrcExpr.isInvalid())
366 Op.ValueKind, Op.Kind, Op.SrcExpr.get(),
367 nullptr, DestTInfo, OpLoc,
371 case tok::kw_static_cast: {
372 if (!TypeDependent) {
373 Op.CheckStaticCast();
374 if (Op.SrcExpr.isInvalid())
380 Context, Op.ResultType, Op.ValueKind, Op.Kind, Op.SrcExpr.get(),
382 Parens.getEnd(), AngleBrackets));
402 CastOperation Op(*
this, TSI->
getType(), Operand);
408 Op.CheckBuiltinBitCast();
409 if (Op.SrcExpr.isInvalid())
415 Op.SrcExpr.get(), TSI, KWLoc, RParenLoc);
416 return Op.complete(BCE);
424 bool listInitialization) {
447 range, listInitialization)
453 assert(sequence.
Failed() &&
"initialization succeeded on second try?");
455 default:
return false;
487 case OR_Success: llvm_unreachable(
"successful failed overload");
489 if (candidates.
empty())
490 msg = diag::err_ovl_no_conversion_in_cast;
492 msg = diag::err_ovl_no_viable_conversion_in_cast;
497 msg = diag::err_ovl_ambiguous_conversion_in_cast;
502 msg = diag::err_ovl_deleted_conversion_in_cast;
509 S.
PDiag(msg) << CT << srcType << destType << range
511 S, howManyCandidates, src);
519 bool listInitialization) {
520 if (msg == diag::err_bad_cxx_cast_generic &&
529 int DifferentPtrness = 0;
540 if (!DifferentPtrness) {
543 if (RecFrom && RecTo) {
545 if (!DeclFrom->isCompleteDefinition())
546 S.
Diag(DeclFrom->getLocation(), diag::note_type_incomplete) << DeclFrom;
548 if (!DeclTo->isCompleteDefinition())
549 S.
Diag(DeclTo->getLocation(), diag::note_type_incomplete) << DeclTo;
557enum CastAwayConstnessKind {
564 CACK_SimilarKind = 2,
583static CastAwayConstnessKind
585 enum {
None, Ptr, MemPtr, BlockPtr, Array };
587 if (T->isAnyPointerType())
return Ptr;
588 if (T->isMemberPointerType())
return MemPtr;
589 if (T->isBlockPointerType())
return BlockPtr;
592 if (T->isConstantArrayType() || T->isIncompleteArrayType())
return Array;
598 return AT->getElementType();
599 return T->getPointeeType();
602 CastAwayConstnessKind Kind;
610 Kind = CastAwayConstnessKind::CACK_Similar;
612 Kind = CastAwayConstnessKind::CACK_Similar;
615 int T1Class = Classify(T1);
617 return CastAwayConstnessKind::CACK_None;
619 int T2Class = Classify(T2);
621 return CastAwayConstnessKind::CACK_None;
625 Kind = T1Class == T2Class ? CastAwayConstnessKind::CACK_SimilarKind
626 : CastAwayConstnessKind::CACK_Incoherent;
636 if (Classify(T1) != Array)
639 auto T2Class = Classify(T2);
643 if (T2Class != Array)
644 Kind = CastAwayConstnessKind::CACK_Incoherent;
645 else if (Kind != CastAwayConstnessKind::CACK_Incoherent)
646 Kind = CastAwayConstnessKind::CACK_SimilarKind;
661static CastAwayConstnessKind
663 bool CheckCVR,
bool CheckObjCLifetime,
664 QualType *TheOffendingSrcType =
nullptr,
665 QualType *TheOffendingDestType =
nullptr,
669 if (!CheckCVR && CheckObjCLifetime && !
Self.Context.getLangOpts().ObjC)
670 return CastAwayConstnessKind::CACK_None;
675 "Source type is not pointer or pointer to member.");
678 "Destination type is not pointer or pointer to member.");
681 QualType UnwrappedSrcType =
Self.Context.getCanonicalType(SrcType),
682 UnwrappedDestType =
Self.Context.getCanonicalType(DestType);
687 QualType PrevUnwrappedSrcType = UnwrappedSrcType;
688 QualType PrevUnwrappedDestType = UnwrappedDestType;
689 auto WorstKind = CastAwayConstnessKind::CACK_Similar;
690 bool AllConstSoFar =
true;
692 Self.Context, UnwrappedSrcType, UnwrappedDestType)) {
695 if (Kind > WorstKind)
700 Self.Context.getUnqualifiedArrayType(UnwrappedSrcType, SrcQuals);
701 Self.Context.getUnqualifiedArrayType(UnwrappedDestType, DestQuals);
707 UnwrappedDestType->isObjCObjectType())
716 if (SrcCvrQuals != DestCvrQuals) {
717 if (CastAwayQualifiers)
718 *CastAwayQualifiers = SrcCvrQuals - DestCvrQuals;
721 if (!DestCvrQuals.compatiblyIncludes(SrcCvrQuals)) {
722 if (TheOffendingSrcType)
723 *TheOffendingSrcType = PrevUnwrappedSrcType;
724 if (TheOffendingDestType)
725 *TheOffendingDestType = PrevUnwrappedDestType;
736 if (CheckObjCLifetime &&
742 if (AllConstSoFar && !DestQuals.
hasConst()) {
743 AllConstSoFar =
false;
744 if (TheOffendingSrcType)
745 *TheOffendingSrcType = PrevUnwrappedSrcType;
746 if (TheOffendingDestType)
747 *TheOffendingDestType = PrevUnwrappedDestType;
750 PrevUnwrappedSrcType = UnwrappedSrcType;
751 PrevUnwrappedDestType = UnwrappedDestType;
754 return CastAwayConstnessKind::CACK_None;
760 case CastAwayConstnessKind::CACK_None:
761 llvm_unreachable(
"did not cast away constness");
763 case CastAwayConstnessKind::CACK_Similar:
765 case CastAwayConstnessKind::CACK_SimilarKind:
766 DiagID = diag::err_bad_cxx_cast_qualifiers_away;
769 case CastAwayConstnessKind::CACK_Incoherent:
770 DiagID = diag::ext_bad_cxx_cast_qualifiers_away_incoherent;
774 llvm_unreachable(
"unexpected cast away constness kind");
780void CastOperation::CheckDynamicCast() {
781 CheckNoDerefRAII NoderefCheck(*
this);
784 SrcExpr =
Self.DefaultFunctionArrayLvalueConversion(SrcExpr.get());
785 else if (isPlaceholder())
786 SrcExpr =
Self.CheckPlaceholderExpr(SrcExpr.get());
787 if (SrcExpr.isInvalid())
790 QualType OrigSrcType = SrcExpr.get()->getType();
791 QualType DestType =
Self.Context.getCanonicalType(this->DestType);
804 Self.Diag(OpRange.getBegin(), diag::err_bad_dynamic_cast_not_ref_or_ptr)
805 << this->DestType << DestRange;
812 assert(DestPointer &&
"Reference to void is not possible");
813 }
else if (DestRecord) {
814 if (
Self.RequireCompleteType(OpRange.getBegin(), DestPointee,
815 diag::err_bad_cast_incomplete,
821 Self.Diag(OpRange.getBegin(), diag::err_bad_dynamic_cast_not_class)
831 QualType SrcType =
Self.Context.getCanonicalType(OrigSrcType);
837 Self.Diag(OpRange.getBegin(), diag::err_bad_dynamic_cast_not_ptr)
838 << OrigSrcType << this->DestType << SrcExpr.get()->getSourceRange();
842 }
else if (DestReference->isLValueReferenceType()) {
843 if (!SrcExpr.get()->isLValue()) {
844 Self.Diag(OpRange.getBegin(), diag::err_bad_cxx_cast_rvalue)
845 <<
CT_Dynamic << OrigSrcType << this->DestType << OpRange;
847 SrcPointee = SrcType;
851 if (SrcExpr.get()->isPRValue())
852 SrcExpr =
Self.CreateMaterializeTemporaryExpr(
853 SrcType, SrcExpr.get(),
false);
854 SrcPointee = SrcType;
859 if (
Self.RequireCompleteType(OpRange.getBegin(), SrcPointee,
860 diag::err_bad_cast_incomplete,
866 Self.Diag(OpRange.getBegin(), diag::err_bad_dynamic_cast_not_class)
872 assert((DestPointer || DestReference) &&
873 "Bad destination non-ptr/ref slipped through.");
874 assert((DestRecord || DestPointee->
isVoidType()) &&
875 "Bad destination pointee slipped through.");
876 assert(SrcRecord &&
"Bad source pointee slipped through.");
880 Self.Diag(OpRange.getBegin(), diag::err_bad_cxx_cast_qualifiers_away)
881 <<
CT_Dynamic << OrigSrcType << this->DestType << OpRange;
888 if (DestRecord == SrcRecord) {
896 Self.IsDerivedFrom(OpRange.getBegin(), SrcPointee, DestPointee)) {
897 if (
Self.CheckDerivedToBaseConversion(SrcPointee, DestPointee,
898 OpRange.getBegin(), OpRange,
904 Kind = CK_DerivedToBase;
910 assert(SrcDecl &&
"Definition missing");
911 if (!cast<CXXRecordDecl>(SrcDecl)->isPolymorphic()) {
912 Self.Diag(OpRange.getBegin(), diag::err_bad_dynamic_cast_not_polymorphic)
921 Self.Diag(OpRange.getBegin(), diag::err_no_dynamic_cast_with_fno_rtti);
927 if (!
Self.getLangOpts().RTTIData) {
929 Self.getASTContext().getTargetInfo().getCXXABI().isMicrosoft();
930 bool isClangCL =
Self.getDiagnostics().getDiagnosticOptions().getFormat() ==
932 if (MicrosoftABI || !DestPointee->
isVoidType())
933 Self.Diag(OpRange.getBegin(),
934 diag::warn_no_dynamic_cast_with_rtti_disabled)
942 if (DestDecl->isEffectivelyFinal())
943 Self.MarkVTableUsed(OpRange.getBegin(), DestDecl);
955void CastOperation::CheckConstCast() {
956 CheckNoDerefRAII NoderefCheck(*
this);
959 SrcExpr =
Self.DefaultFunctionArrayLvalueConversion(SrcExpr.get());
960 else if (isPlaceholder())
961 SrcExpr =
Self.CheckPlaceholderExpr(SrcExpr.get());
962 if (SrcExpr.isInvalid())
965 unsigned msg = diag::err_bad_cxx_cast_generic;
969 << SrcExpr.get()->getType() << DestType << OpRange;
975void CastOperation::CheckAddrspaceCast() {
976 unsigned msg = diag::err_bad_cxx_cast_generic;
980 Self.Diag(OpRange.getBegin(), msg)
981 <<
CT_Addrspace << SrcExpr.get()->getType() << DestType << OpRange;
1018 ReinterpretKind = ReinterpretUpcast;
1020 ReinterpretKind = ReinterpretDowncast;
1025 bool NonZeroOffset =
false;
1027 E = BasePaths.
end();
1031 bool IsVirtual =
false;
1032 for (CXXBasePath::const_iterator IElem = Path.begin(), EElem = Path.end();
1033 IElem != EElem; ++IElem) {
1034 IsVirtual = IElem->Base->isVirtual();
1037 const CXXRecordDecl *BaseRD = IElem->Base->getType()->getAsCXXRecordDecl();
1038 assert(BaseRD &&
"Base type should be a valid unqualified class type");
1042 *ClassDefinition =
Class->getDefinition();
1043 if (
Class->isInvalidDecl() || !ClassDefinition ||
1044 !ClassDefinition->isCompleteDefinition())
1053 if (Offset.isZero())
1057 NonZeroOffset =
true;
1062 (void) NonZeroOffset;
1064 "Should have returned if has non-virtual base with zero offset");
1067 ReinterpretKind == ReinterpretUpcast? DestType : SrcType;
1069 ReinterpretKind == ReinterpretUpcast? SrcType : DestType;
1072 Self.Diag(BeginLoc, diag::warn_reinterpret_different_from_static)
1073 << DerivedType << BaseType << !
VirtualBase <<
int(ReinterpretKind)
1075 Self.Diag(BeginLoc, diag::note_reinterpret_updowncast_use_static)
1076 <<
int(ReinterpretKind)
1096 unsigned int DiagID = 0;
1097 const unsigned int DiagList[] = {diag::warn_cast_function_type_strict,
1098 diag::warn_cast_function_type};
1123 assert(SrcFTy && DstFTy);
1125 if (
Self.Context.hasSameType(SrcFTy, DstFTy))
1129 if (DiagID == diag::warn_cast_function_type_strict)
1133 if (!T->getReturnType()->isVoidType())
1136 return !PT->isVariadic() && PT->getNumParams() == 0;
1141 if (IsVoidVoid(SrcFTy) || IsVoidVoid(DstFTy))
1155 const auto *SrcFPTy = cast<FunctionProtoType>(SrcFTy);
1156 const auto *DstFPTy = cast<FunctionProtoType>(DstFTy);
1160 unsigned NumParams = SrcFPTy->getNumParams();
1161 unsigned DstNumParams = DstFPTy->getNumParams();
1162 if (NumParams > DstNumParams) {
1163 if (!DstFPTy->isVariadic())
1165 NumParams = DstNumParams;
1166 }
else if (NumParams < DstNumParams) {
1167 if (!SrcFPTy->isVariadic())
1171 for (
unsigned i = 0; i < NumParams; ++i)
1173 DstFPTy->getParamType(i),
Self.Context))
1184void CastOperation::CheckReinterpretCast() {
1185 if (ValueKind ==
VK_PRValue && !isPlaceholder(BuiltinType::Overload))
1186 SrcExpr =
Self.DefaultFunctionArrayLvalueConversion(SrcExpr.get());
1188 checkNonOverloadPlaceholders();
1189 if (SrcExpr.isInvalid())
1192 unsigned msg = diag::err_bad_cxx_cast_generic;
1195 false, OpRange, msg, Kind);
1197 if (SrcExpr.isInvalid())
1199 if (SrcExpr.get()->getType() ==
Self.Context.OverloadTy) {
1201 Self.Diag(OpRange.getBegin(), diag::err_bad_reinterpret_cast_overload)
1203 << DestType << OpRange;
1204 Self.NoteAllOverloadCandidates(SrcExpr.get());
1213 if (
Self.getLangOpts().allowsNonTrivialObjCLifetimeQualifiers())
1218 Self.Diag(OpRange.getBegin(), DiagID)
1219 << SrcExpr.get()->getType() << DestType << OpRange;
1229void CastOperation::CheckStaticCast() {
1230 CheckNoDerefRAII NoderefCheck(*
this);
1232 if (isPlaceholder()) {
1233 checkNonOverloadPlaceholders();
1234 if (SrcExpr.isInvalid())
1244 if (claimPlaceholder(BuiltinType::Overload)) {
1245 Self.ResolveAndFixSingleFunctionTemplateSpecialization(SrcExpr,
1248 OpRange, DestType, diag::err_bad_static_cast_overload);
1249 if (SrcExpr.isInvalid())
1253 SrcExpr =
Self.IgnoredValueConversions(SrcExpr.get());
1258 !isPlaceholder(BuiltinType::Overload)) {
1259 SrcExpr =
Self.DefaultFunctionArrayLvalueConversion(SrcExpr.get());
1260 if (SrcExpr.isInvalid())
1264 unsigned msg = diag::err_bad_cxx_cast_generic;
1267 Kind, BasePath,
false);
1269 if (SrcExpr.isInvalid())
1271 if (SrcExpr.get()->getType() ==
Self.Context.OverloadTy) {
1273 Self.Diag(OpRange.getBegin(), diag::err_bad_static_cast_overload)
1274 << oe->
getName() << DestType << OpRange
1276 Self.NoteAllOverloadCandidates(SrcExpr.get());
1284 if (Kind == CK_BitCast)
1286 if (
Self.getLangOpts().allowsNonTrivialObjCLifetimeQualifiers())
1301 DestPtrType->getPointeeType().getAddressSpace();
1312 bool ListInitialization) {
1338 OpRange, msg, Kind, BasePath);
1353 Kind, ListInitialization);
1375 if (
Enum->getDecl()->isScoped()) {
1377 Kind = CK_IntegralToBoolean;
1380 Kind = CK_IntegralCast;
1383 Kind = CK_IntegralToFloating;
1398 if (
Self.RequireCompleteType(OpRange.
getBegin(), DestType,
1399 diag::err_bad_cast_incomplete)) {
1407 Kind =
Enum->getDecl()->isFixed() &&
1408 Enum->getDecl()->getIntegerType()->isBooleanType()
1409 ? CK_IntegralToBoolean
1413 Kind = CK_FloatingToIntegral;
1429 OpRange, msg, Kind, BasePath);
1452 if (DestPointeeQuals != SrcPointeeQuals &&
1454 msg = diag::err_bad_cxx_cast_qualifiers_away;
1459 ? CK_AddressSpaceConversion
1466 if (!CStyle &&
Self.getLangOpts().MSVCCompat &&
1468 Self.Diag(OpRange.
getBegin(), diag::ext_ms_cast_fn_obj) << OpRange;
1476 Kind = CK_CPointerToObjCPointerCast;
1481 Kind = CK_AnyPointerToBlockPointerCast;
1495 Self.CheckTollFreeBridgeStaticCast(DestType, SrcExpr.
get(), Kind))
1502 if (SrcPointer->getPointeeType()->getAs<
RecordType>() &&
1504 msg = diag::err_bad_cxx_cast_unrelated_class;
1507 if (
Self.CheckMatrixCast(OpRange, DestType, SrcType, Kind)) {
1545 SrcExpr->
getBeginLoc(), ToType, FromType, &RefConv);
1552 msg = SrcExpr->
isLValue() ? diag::err_bad_lvalue_to_rvalue_cast
1553 : diag::err_bad_rvalue_to_rvalue_cast;
1557 if (RefConv & Sema::ReferenceConversions::DerivedToBase) {
1558 Kind = CK_DerivedToBase;
1565 Self.BuildBasePathArray(Paths, BasePath);
1588 if (!DestReference) {
1592 if (!RValueRef && !SrcExpr->
isLValue()) {
1594 msg = diag::err_bad_cxx_cast_rvalue;
1604 Self.Context.getCanonicalType(SrcExpr->
getType()),
1605 Self.Context.getCanonicalType(DestPointee), CStyle,
1606 OpRange, SrcExpr->
getType(), DestType, msg, Kind,
1631 msg = diag::err_bad_static_cast_pointer_nonpointer;
1638 CStyle, OpRange, SrcType, DestType, msg, Kind,
1648 QualType OrigDestType,
unsigned &msg,
1651 if (!
Self.isCompleteType(OpRange.
getBegin(), SrcType) ||
1662 if (!
Self.IsDerivedFrom(OpRange.
getBegin(), DestType, SrcType, Paths)) {
1686 msg = diag::err_bad_cxx_cast_qualifiers_away;
1695 if (!Paths.isRecordingPaths()) {
1697 Paths.setRecordingPaths(
true);
1698 Self.IsDerivedFrom(OpRange.
getBegin(), DestType, SrcType, Paths);
1700 std::string PathDisplayStr;
1701 std::set<unsigned> DisplayedPaths;
1703 if (DisplayedPaths.insert(Path.back().SubobjectNumber).second) {
1706 PathDisplayStr +=
"\n ";
1708 PathDisplayStr += PE.Base->getType().getAsString() +
" -> ";
1713 Self.Diag(OpRange.
getBegin(), diag::err_ambiguous_base_to_derived_cast)
1716 << PathDisplayStr << OpRange;
1721 if (Paths.getDetectedVirtual() !=
nullptr) {
1723 Self.Diag(OpRange.
getBegin(), diag::err_static_downcast_via_virtual)
1724 << OrigSrcType << OrigDestType <<
VirtualBase << OpRange;
1733 diag::err_downcast_from_inaccessible_base)) {
1745 Self.BuildBasePathArray(Paths, BasePath);
1746 Kind = CK_BaseToDerived;
1767 bool WasOverloadedFunction =
false;
1771 =
Self.ResolveAddressOfOverloadedFunction(SrcExpr.
get(), DestType,
false,
1774 SrcType =
Self.Context.getMemberPointerType(Fn->getType(),
1776 WasOverloadedFunction =
true;
1782 msg = diag::err_bad_static_cast_member_pointer_nonmp;
1788 if (
Self.Context.getTargetInfo().getCXXABI().isMicrosoft()) {
1789 (void)
Self.isCompleteType(OpRange.
getBegin(), SrcType);
1790 (void)
Self.isCompleteType(OpRange.
getBegin(), DestType);
1803 if (!
Self.IsDerivedFrom(OpRange.
getBegin(), SrcClass, DestClass, Paths))
1807 if (Paths.isAmbiguous(
Self.Context.getCanonicalType(DestClass))) {
1809 Paths.setRecordingPaths(
true);
1811 Self.IsDerivedFrom(OpRange.
getBegin(), SrcClass, DestClass, Paths);
1814 std::string PathDisplayStr =
Self.getAmbiguousPathsDisplayString(Paths);
1815 Self.Diag(OpRange.
getBegin(), diag::err_ambiguous_memptr_conv)
1816 << 1 << SrcClass << DestClass << PathDisplayStr << OpRange;
1821 if (
const RecordType *VBase = Paths.getDetectedVirtual()) {
1822 Self.Diag(OpRange.
getBegin(), diag::err_memptr_conv_via_virtual)
1823 << SrcClass << DestClass <<
QualType(VBase, 0) << OpRange;
1830 DestClass, SrcClass,
1832 diag::err_upcast_to_inaccessible_base)) {
1846 if (WasOverloadedFunction) {
1858 SrcExpr =
Self.FixOverloadedFunctionReference(SrcExpr, FoundOverload, Fn);
1865 Self.BuildBasePathArray(Paths, BasePath);
1866 Kind = CK_DerivedToBaseMemberPointer;
1879 CastKind &Kind,
bool ListInitialization) {
1881 if (
Self.RequireCompleteType(OpRange.
getBegin(), DestType,
1882 diag::err_bad_cast_incomplete) ||
1883 Self.RequireNonAbstractType(OpRange.
getBegin(), DestType,
1884 diag::err_allocation_of_abstract_type)) {
1898 Expr *SrcExprRaw = SrcExpr.
get();
1915 if (
Result.isInvalid()) {
1921 Kind = CK_ConstructorConversion;
1934 DestType =
Self.Context.getCanonicalType(DestType);
1936 bool NeedToMaterializeTemporary =
false;
1950 if (isa<LValueReferenceType>(DestTypeTmp) && !SrcExpr.
get()->
isLValue()) {
1954 msg = diag::err_bad_cxx_cast_rvalue;
1958 if (isa<RValueReferenceType>(DestTypeTmp) && SrcExpr.
get()->
isPRValue()) {
1962 msg = diag::err_bad_cxx_cast_rvalue;
1968 NeedToMaterializeTemporary =
true;
1977 msg = diag::err_bad_cxx_cast_bitfield;
1981 DestType =
Self.Context.getPointerType(DestTypeTmp->getPointeeType());
1982 SrcType =
Self.Context.getPointerType(SrcType);
1997 msg = diag::err_bad_const_cast_dest;
2006 msg = diag::err_bad_const_cast_dest;
2016 if (!
Self.Context.hasCvrSimilarType(SrcType, DestType))
2019 if (NeedToMaterializeTemporary)
2022 SrcExpr =
Self.CreateMaterializeTemporaryExpr(SrcExpr.
get()->
getType(),
2037 unsigned DiagID = IsDereference ?
2038 diag::warn_pointer_indirection_from_incompatible_type :
2039 diag::warn_undefined_reinterpret_cast;
2045 if (IsDereference) {
2081 Diag(Range.getBegin(), DiagID) << SrcType << DestType << Range;
2087 if (
Self.Context.hasSameType(SrcType, DestType))
2090 if (SrcPtrTy->isObjCSelType()) {
2092 if (isa<PointerType>(DestType))
2096 diag::warn_cast_pointer_from_sel)
2108 if (
Self.Context.hasSameType(SrcType, DstType) ||
2111 const auto *SrcFTy =
2113 const auto *DstFTy =
2123 if (
auto *UO = dyn_cast<UnaryOperator>(Src))
2124 if (UO->getOpcode() == UO_AddrOf)
2126 auto *DRE = dyn_cast<DeclRefExpr>(Src);
2129 auto *FD = dyn_cast<FunctionDecl>(DRE->getDecl());
2137 CallingConv DefaultCC =
Self.getASTContext().getDefaultCallingConvention(
2138 FD->isVariadic(), FD->isCXXInstanceMember());
2139 if (DstCC == DefaultCC || SrcCC != DefaultCC)
2145 Self.Diag(OpRange.
getBegin(), diag::warn_cast_calling_conv)
2146 << SrcCCName << DstCCName << OpRange;
2151 if (
Self.Diags.isIgnored(diag::warn_cast_calling_conv, OpRange.
getBegin()))
2158 SourceLocation NameLoc = FD->getFirstDecl()->getNameInfo().getLoc();
2162 llvm::raw_svector_ostream OS(CCAttrText);
2163 if (
Self.getLangOpts().MicrosoftExt) {
2165 OS <<
"__" << DstCCName;
2172 OS <<
"__attribute__((" << DstCCName <<
"))";
2173 AttrTokens.push_back(tok::kw___attribute);
2174 AttrTokens.push_back(tok::l_paren);
2175 AttrTokens.push_back(tok::l_paren);
2180 AttrTokens.push_back(tok::r_paren);
2181 AttrTokens.push_back(tok::r_paren);
2184 if (!AttrSpelling.empty())
2185 CCAttrText = AttrSpelling;
2187 Self.Diag(NameLoc, diag::note_change_calling_conv_fixit)
2203 &&
Self.Context.getTypeSize(DestType) >
2204 Self.Context.getTypeSize(SrcType)) {
2211 diag::warn_int_to_void_pointer_cast
2212 : diag::warn_int_to_pointer_cast;
2228 if (
Self.ResolveAndFixSingleFunctionTemplateSpecialization(
2239 if (!
Self.resolveAndFixAddressOfSingleOverloadCandidate(
2242 return Result.isUsable();
2250 bool IsLValueCast =
false;
2252 DestType =
Self.Context.getCanonicalType(DestType);
2257 if (SrcType ==
Self.Context.OverloadTy) {
2262 assert(FixedExpr.
isUsable() &&
"Invalid result fixing overloaded expr");
2263 SrcExpr = FixedExpr;
2271 msg = diag::err_bad_cxx_cast_rvalue;
2276 Self.CheckCompatibleReinterpretCast(SrcType, DestType,
2284 const char *inappropriate =
nullptr;
2289 msg = diag::err_bad_cxx_cast_bitfield;
2294 inappropriate =
"matrix element";
2297 case OK_ObjCSubscript: inappropriate =
"container subscripting expression";
2300 if (inappropriate) {
2301 Self.Diag(OpRange.
getBegin(), diag::err_bad_reinterpret_cast_reference)
2302 << inappropriate << DestType
2309 DestType =
Self.Context.getPointerType(DestTypeTmp->getPointeeType());
2310 SrcType =
Self.Context.getPointerType(SrcType);
2312 IsLValueCast =
true;
2316 SrcType =
Self.Context.getCanonicalType(SrcType);
2320 if (DestMemPtr && SrcMemPtr) {
2326 SrcMemPtr->isMemberFunctionPointer())
2329 if (
Self.Context.getTargetInfo().getCXXABI().isMicrosoft()) {
2332 (void)
Self.isCompleteType(OpRange.
getBegin(), SrcType);
2333 (void)
Self.isCompleteType(OpRange.
getBegin(), DestType);
2337 if (
Self.Context.getTypeSize(DestMemPtr) !=
2338 Self.Context.getTypeSize(SrcMemPtr)) {
2339 msg = diag::err_bad_cxx_cast_member_pointer_size;
2353 assert(!IsLValueCast);
2354 Kind = CK_ReinterpretMemberPointer;
2364 if (
Self.Context.getTypeSize(SrcType) >
2365 Self.Context.getTypeSize(DestType)) {
2366 msg = diag::err_bad_reinterpret_cast_small_int;
2369 Kind = CK_PointerToIntegral;
2377 if (srcIsVector || destIsVector) {
2379 if (
Self.isValidSveBitcast(SrcType, DestType)) {
2385 if (
Self.isValidRVVBitcast(SrcType, DestType)) {
2399 if (
Self.areLaxCompatibleVectorTypes(SrcType, DestType)) {
2404 if (
Self.LangOpts.OpenCL && !CStyle) {
2407 if (
Self.areVectorTypesSameSize(SrcType, DestType)) {
2416 msg = diag::err_bad_cxx_cast_vector_to_scalar_different_size;
2417 else if (!srcIsVector)
2418 msg = diag::err_bad_cxx_cast_scalar_to_vector_different_size;
2420 msg = diag::err_bad_cxx_cast_vector_to_vector_different_size;
2425 if (SrcType == DestType) {
2449 if (!destIsPtr && !srcIsPtr) {
2456 assert(srcIsPtr &&
"One type must be a pointer");
2460 if ((
Self.Context.getTypeSize(SrcType) >
2461 Self.Context.getTypeSize(DestType))) {
2462 bool MicrosoftException =
2464 if (MicrosoftException) {
2466 ? diag::warn_void_pointer_to_int_cast
2467 : diag::warn_pointer_to_int_cast;
2470 msg = diag::err_bad_reinterpret_cast_small_int;
2474 Kind = CK_PointerToIntegral;
2479 assert(destIsPtr &&
"One type must be a pointer");
2485 Kind = CK_IntegralToPointer;
2489 if (!destIsPtr || !srcIsPtr) {
2509 Kind = CK_AddressSpaceConversion;
2516 }
else if (IsLValueCast) {
2517 Kind = CK_LValueBitCast;
2519 Kind =
Self.PrepareCastToObjCObjectPointer(SrcExpr);
2522 Kind = CK_AnyPointerToBlockPointerCast;
2533 return SuccessResult;
2547 return SuccessResult;
2557 Self.getLangOpts().CPlusPlus11 ?
2558 diag::warn_cxx98_compat_cast_fn_obj : diag::ext_cast_fn_obj)
2560 return SuccessResult;
2566 Self.getLangOpts().CPlusPlus11 ?
2567 diag::warn_cxx98_compat_cast_fn_obj : diag::ext_cast_fn_obj)
2569 return SuccessResult;
2582 diag::warn_bad_cxx_cast_nested_pointer_addr_space)
2595 return SuccessResult;
2601 if (!
Self.getLangOpts().OpenCL && !
Self.getLangOpts().SYCLIsDevice)
2618 auto SrcPointeeType = SrcPtrType->getPointeeType();
2619 auto DestPointeeType = DestPtrType->getPointeeType();
2620 if (!DestPointeeType.isAddressSpaceOverlapping(SrcPointeeType)) {
2621 msg = diag::err_bad_cxx_cast_addr_space_mismatch;
2624 auto SrcPointeeTypeWithoutAS =
2625 Self.Context.removeAddrSpaceQualType(SrcPointeeType.getCanonicalType());
2626 auto DestPointeeTypeWithoutAS =
2627 Self.Context.removeAddrSpaceQualType(DestPointeeType.getCanonicalType());
2628 if (
Self.Context.hasSameType(SrcPointeeTypeWithoutAS,
2629 DestPointeeTypeWithoutAS)) {
2630 Kind = SrcPointeeType.getAddressSpace() == DestPointeeType.getAddressSpace()
2632 : CK_AddressSpaceConversion;
2639void CastOperation::checkAddressSpaceCast(
QualType SrcType,
QualType DestType) {
2651 if (
Self.getLangOpts().OpenCL) {
2652 const Type *DestPtr, *SrcPtr;
2653 bool Nested =
false;
2654 unsigned DiagID = diag::err_typecheck_incompatible_address_space;
2655 DestPtr =
Self.getASTContext().getCanonicalType(DestType.
getTypePtr()),
2656 SrcPtr =
Self.getASTContext().getCanonicalType(SrcType.
getTypePtr());
2658 while (isa<PointerType>(DestPtr) && isa<PointerType>(SrcPtr)) {
2659 const PointerType *DestPPtr = cast<PointerType>(DestPtr);
2660 const PointerType *SrcPPtr = cast<PointerType>(SrcPtr);
2666 Self.Diag(OpRange.getBegin(), DiagID)
2668 << SrcExpr.get()->getSourceRange();
2677 DiagID = diag::ext_nested_pointer_qualifier_mismatch;
2683 bool SrcCompatXL = this->
getLangOpts().getAltivecSrcCompat() ==
2697 bool SrcCompatGCC = this->
getLangOpts().getAltivecSrcCompat() ==
2699 if (this->
getLangOpts().AltiVec && SrcCompatGCC) {
2701 diag::err_invalid_conversion_between_vector_and_integer)
2702 << VecTy << SrcTy << R;
2708void CastOperation::CheckCXXCStyleCast(
bool FunctionalStyle,
2709 bool ListInitialization) {
2710 assert(
Self.getLangOpts().CPlusPlus);
2713 if (isPlaceholder()) {
2715 if (claimPlaceholder(BuiltinType::UnknownAny)) {
2716 SrcExpr =
Self.checkUnknownAnyCast(DestRange, DestType,
2717 SrcExpr.get(), Kind,
2718 ValueKind, BasePath);
2722 checkNonOverloadPlaceholders();
2723 if (SrcExpr.isInvalid())
2733 if (claimPlaceholder(BuiltinType::Overload)) {
2734 Self.ResolveAndFixSingleFunctionTemplateSpecialization(
2736 true, DestRange, DestType,
2737 diag::err_bad_cstyle_cast_overload);
2738 if (SrcExpr.isInvalid())
2742 SrcExpr =
Self.IgnoredValueConversions(SrcExpr.get());
2747 if (DestType->
isDependentType() || SrcExpr.get()->isTypeDependent() ||
2748 SrcExpr.get()->isValueDependent()) {
2749 assert(Kind == CK_Dependent);
2754 !isPlaceholder(BuiltinType::Overload)) {
2755 SrcExpr =
Self.DefaultFunctionArrayLvalueConversion(SrcExpr.get());
2756 if (SrcExpr.isInvalid())
2762 if (
Self.CheckAltivecInitFromScalar(OpRange, DestType,
2763 SrcExpr.get()->getType())) {
2767 if (
Self.ShouldSplatAltivecScalarInCast(vecTy) &&
2768 (SrcExpr.get()->getType()->isIntegerType() ||
2769 SrcExpr.get()->getType()->isFloatingType())) {
2770 Kind = CK_VectorSplat;
2771 SrcExpr =
Self.prepareVectorSplat(DestType, SrcExpr.get());
2777 QualType SrcType = SrcExpr.get()->getType();
2779 Self.Diag(OpRange.getBegin(), diag::err_wasm_cast_table)
2780 << 1 << SrcExpr.get()->getSourceRange();
2797 unsigned msg = diag::err_bad_cxx_cast_generic;
2800 if (SrcExpr.isInvalid())
2810 if (SrcExpr.isInvalid())
2817 BasePath, ListInitialization);
2818 if (SrcExpr.isInvalid())
2824 OpRange, msg, Kind);
2825 if (SrcExpr.isInvalid())
2831 if (
Self.getLangOpts().allowsNonTrivialObjCLifetimeQualifiers() &&
2833 checkObjCConversion(CCK);
2836 if (SrcExpr.get()->getType() ==
Self.Context.OverloadTy) {
2847 Self.Diag(OpRange.getBegin(), diag::err_bad_cstyle_cast_overload)
2848 << OE->
getName() << DestType << OpRange
2850 Self.NoteAllOverloadCandidates(SrcExpr.get());
2854 OpRange, SrcExpr.get(), DestType, ListInitialization);
2859 if (Kind == CK_BitCast)
2863 Self.Diag(OpRange.getBegin(), DiagID)
2864 << SrcExpr.get()->getType() << DestType << OpRange;
2876 if (
Self.Diags.isIgnored(diag::warn_bad_function_cast,
2880 if (!isa<CallExpr>(SrcExpr.
get()))
2905 diag::warn_bad_function_cast)
2910void CastOperation::CheckCStyleCast() {
2911 assert(!
Self.getLangOpts().CPlusPlus);
2914 if (claimPlaceholder(BuiltinType::UnknownAny)) {
2915 SrcExpr =
Self.checkUnknownAnyCast(DestRange, DestType,
2916 SrcExpr.get(), Kind,
2917 ValueKind, BasePath);
2925 SrcExpr =
Self.IgnoredValueConversions(SrcExpr.get());
2926 if (SrcExpr.isInvalid())
2935 if (
Self.getASTContext().isDependenceAllowed() &&
2937 SrcExpr.get()->isValueDependent())) {
2938 assert((DestType->
containsErrors() || SrcExpr.get()->containsErrors() ||
2939 SrcExpr.get()->containsErrors()) &&
2940 "should only occur in error-recovery path.");
2941 assert(Kind == CK_Dependent);
2946 if (SrcExpr.get()->getType() ==
Self.Context.OverloadTy) {
2949 SrcExpr.get(), DestType,
true, DAP))
2950 SrcExpr =
Self.FixOverloadedFunctionReference(SrcExpr.get(), DAP, FD);
2953 assert(SrcExpr.isUsable());
2955 SrcExpr =
Self.DefaultFunctionArrayLvalueConversion(SrcExpr.get());
2956 if (SrcExpr.isInvalid())
2958 QualType SrcType = SrcExpr.get()->getType();
2961 Self.Diag(OpRange.getBegin(), diag::err_wasm_cast_table)
2962 << 1 << SrcExpr.get()->getSourceRange();
2969 checkAddressSpaceCast(SrcType, DestType);
2970 if (SrcExpr.isInvalid())
2973 if (
Self.RequireCompleteType(OpRange.getBegin(), DestType,
2974 diag::err_typecheck_cast_to_incomplete)) {
2981 Self.Context.hasSameUnqualifiedType(DestType, SrcType)) {
2988 Self.isValidSveBitcast(SrcType, DestType)) {
2995 Self.isValidRVVBitcast(SrcType, DestType)) {
3004 if (DestRecordTy &&
Self.Context.hasSameUnqualifiedType(DestType, SrcType)){
3006 Self.Diag(OpRange.getBegin(), diag::ext_typecheck_cast_nonscalar)
3007 << DestType << SrcExpr.get()->getSourceRange();
3016 Self.Diag(OpRange.getBegin(), diag::ext_typecheck_cast_to_union)
3017 << SrcExpr.get()->getSourceRange();
3021 Self.Diag(OpRange.getBegin(), diag::err_typecheck_cast_to_union_no_type)
3022 << SrcType << SrcExpr.get()->getSourceRange();
3029 if (
Self.getLangOpts().OpenCL && DestType->
isEventT()) {
3031 if (SrcExpr.get()->EvaluateAsInt(
Result,
Self.Context)) {
3032 llvm::APSInt CastInt =
Result.Val.getInt();
3034 Kind = CK_ZeroToOCLOpaqueType;
3037 Self.Diag(OpRange.getBegin(),
3038 diag::err_opencl_cast_non_zero_to_event_t)
3039 <<
toString(CastInt, 10) << SrcExpr.get()->getSourceRange();
3046 Self.Diag(OpRange.getBegin(), diag::err_typecheck_cond_expect_scalar)
3047 << DestType << SrcExpr.get()->getSourceRange();
3057 Self.Diag(SrcExpr.get()->getExprLoc(),
3058 diag::err_typecheck_expect_scalar_operand)
3059 << SrcType << SrcExpr.get()->getSourceRange();
3074 Self.Diag(SrcExpr.get()->getExprLoc(), diag::err_nullptr_cast)
3085 Self.CurFPFeatureOverrides());
3089 Self.Diag(SrcExpr.get()->getExprLoc(), diag::err_nullptr_cast)
3096 SrcExpr =
Self.CheckExtVectorCast(OpRange, DestType, SrcExpr.get(), Kind);
3101 if (
Self.CheckMatrixCast(OpRange, DestType, SrcType, Kind))
3107 if (
Self.CheckAltivecInitFromScalar(OpRange, DestType, SrcType)) {
3111 if (
Self.ShouldSplatAltivecScalarInCast(DestVecTy) &&
3113 Kind = CK_VectorSplat;
3114 SrcExpr =
Self.prepareVectorSplat(DestType, SrcExpr.get());
3115 }
else if (
Self.CheckVectorCast(OpRange, DestType, SrcType, Kind)) {
3122 if (
Self.CheckVectorCast(OpRange, SrcType, DestType, Kind))
3132 if (isa<ObjCSelectorExpr>(SrcExpr.get())) {
3133 Self.Diag(SrcExpr.get()->getExprLoc(), diag::err_cast_selector_expr);
3142 Self.Diag(SrcExpr.get()->getExprLoc(),
3143 diag::err_cast_pointer_from_non_pointer_int)
3144 << SrcType << SrcExpr.get()->getSourceRange();
3153 Self.Diag(SrcExpr.get()->getBeginLoc(),
3154 diag::err_cast_pointer_to_non_pointer_int)
3155 << DestType << SrcExpr.get()->getSourceRange();
3160 if ((
Self.Context.getTypeSize(SrcType) >
3161 Self.Context.getTypeSize(DestType)) &&
3171 : diag::warn_void_pointer_to_int_cast;
3173 Diag = diag::warn_pointer_to_enum_cast;
3175 Diag = diag::warn_pointer_to_int_cast;
3176 Self.Diag(OpRange.getBegin(),
Diag) << SrcType << DestType << OpRange;
3180 if (
Self.getLangOpts().OpenCL && !
Self.getOpenCLOptions().isAvailableOption(
3181 "cl_khr_fp16",
Self.getLangOpts())) {
3183 Self.Diag(SrcExpr.get()->getBeginLoc(), diag::err_opencl_cast_to_half)
3184 << DestType << SrcExpr.get()->getSourceRange();
3191 if (
Self.getLangOpts().allowsNonTrivialObjCLifetimeQualifiers()) {
3193 if (SrcExpr.isInvalid())
3197 if (
Self.getLangOpts().ObjCAutoRefCount && CastPtr) {
3200 Qualifiers ExprQuals = ExprPtr->getPointeeType().getQualifiers();
3202 ExprPtr->getPointeeType()->isObjCLifetimeType() &&
3204 Self.Diag(SrcExpr.get()->getBeginLoc(),
3205 diag::err_typecheck_incompatible_ownership)
3207 << SrcExpr.get()->getSourceRange();
3212 else if (!
Self.CheckObjCARCUnavailableWeakConversion(DestType, SrcType)) {
3213 Self.Diag(SrcExpr.get()->getBeginLoc(),
3214 diag::err_arc_convesion_of_weak_unavailable)
3215 << 1 << SrcType << DestType << SrcExpr.get()->getSourceRange();
3222 Self.Diag(OpRange.getBegin(), DiagID) << SrcType << DestType << OpRange;
3224 if (isa<PointerType>(SrcType) && isa<PointerType>(DestType)) {
3231 if (SrcRD && DestRD && SrcRD->
hasAttr<RandomizeLayoutAttr>() &&
3234 Self.Diag(OpRange.getBegin(), diag::err_cast_from_randomized_struct)
3235 << SrcType << DestType;
3244 Kind =
Self.PrepareScalarCast(SrcExpr, DestType);
3245 if (SrcExpr.isInvalid())
3248 if (Kind == CK_BitCast)
3252void CastOperation::CheckBuiltinBitCast() {
3253 QualType SrcType = SrcExpr.get()->getType();
3255 if (
Self.RequireCompleteType(OpRange.getBegin(), DestType,
3256 diag::err_typecheck_cast_to_incomplete) ||
3257 Self.RequireCompleteType(OpRange.getBegin(), SrcType,
3258 diag::err_incomplete_type)) {
3263 if (SrcExpr.get()->isPRValue())
3264 SrcExpr =
Self.CreateMaterializeTemporaryExpr(SrcType, SrcExpr.get(),
3267 CharUnits DestSize =
Self.Context.getTypeSizeInChars(DestType);
3268 CharUnits SourceSize =
Self.Context.getTypeSizeInChars(SrcType);
3269 if (DestSize != SourceSize) {
3270 Self.Diag(OpRange.getBegin(), diag::err_bit_cast_type_size_mismatch)
3277 Self.Diag(OpRange.getBegin(), diag::err_bit_cast_non_trivially_copyable)
3284 Self.Diag(OpRange.getBegin(), diag::err_bit_cast_non_trivially_copyable)
3290 Kind = CK_LValueToRValueBitCast;
3305 QualType TheOffendingSrcType, TheOffendingDestType;
3308 &TheOffendingSrcType, &TheOffendingDestType,
3309 &CastAwayQualifiers) !=
3310 CastAwayConstnessKind::CACK_Similar)
3314 int qualifiers = -1;
3317 }
else if (CastAwayQualifiers.
hasConst()) {
3323 if (qualifiers == -1)
3325 << SrcType << DestType;
3328 << TheOffendingSrcType << TheOffendingDestType << qualifiers;
3340 Op.CheckCXXCStyleCast(
false,
3343 Op.CheckCStyleCast();
3346 if (Op.SrcExpr.isInvalid())
3353 Context, Op.ResultType, Op.ValueKind, Op.Kind, Op.SrcExpr.get(),
3362 assert(LPLoc.
isValid() &&
"List-initialization shouldn't get here.");
3365 Op.OpRange =
SourceRange(Op.DestRange.getBegin(), RPLoc);
3367 Op.CheckCXXCStyleCast(
true,
false);
3368 if (Op.SrcExpr.isInvalid())
3371 auto *SubExpr = Op.SrcExpr.get();
3372 if (
auto *BindExpr = dyn_cast<CXXBindTemporaryExpr>(SubExpr))
3373 SubExpr = BindExpr->getSubExpr();
3374 if (
auto *ConstructExpr = dyn_cast<CXXConstructExpr>(SubExpr))
3375 ConstructExpr->setParenOrBraceRange(
SourceRange(LPLoc, RPLoc));
3381 Context, Op.ResultType, Op.ValueKind, CastTypeInfo, Op.Kind,
Defines the clang::ASTContext interface.
Defines the clang::Expr interface and subclasses for C++ expressions.
static DiagnosticBuilder Diag(DiagnosticsEngine *Diags, const LangOptions &Features, FullSourceLoc TokLoc, const char *TokBegin, const char *TokRangeBegin, const char *TokRangeEnd, unsigned DiagID)
Produce a diagnostic highlighting some portion of a literal.
Implements a partial diagnostic that can be emitted anwyhere in a DiagnosticBuilder stream.
Defines the clang::Preprocessor interface.
static std::string toString(const clang::SanitizerSet &Sanitizers)
Produce a string containing comma-separated names of sanitizers in Sanitizers set.
static void DiagnoseReinterpretUpDownCast(Sema &Self, const Expr *SrcExpr, QualType DestType, SourceRange OpRange)
Check that a reinterpret_cast<DestType>(SrcExpr) is not used as upcast or downcast between respective...
static CastAwayConstnessKind CastsAwayConstness(Sema &Self, QualType SrcType, QualType DestType, bool CheckCVR, bool CheckObjCLifetime, QualType *TheOffendingSrcType=nullptr, QualType *TheOffendingDestType=nullptr, Qualifiers *CastAwayQualifiers=nullptr)
Check if the pointer conversion from SrcType to DestType casts away constness as defined in C++ [expr...
static TryCastResult getCastAwayConstnessCastKind(CastAwayConstnessKind CACK, unsigned &DiagID)
static bool IsAddressSpaceConversion(QualType SrcType, QualType DestType)
@ CT_Reinterpret
reinterpret_cast
@ CT_Functional
Type(expr)
@ CT_Addrspace
addrspace_cast
static TryCastResult TryConstCast(Sema &Self, ExprResult &SrcExpr, QualType DestType, bool CStyle, unsigned &msg)
TryConstCast - See if a const_cast from source to destination is allowed, and perform it if it is.
static bool isValidCast(TryCastResult TCR)
static void diagnoseBadCast(Sema &S, unsigned msg, CastType castType, SourceRange opRange, Expr *src, QualType destType, bool listInitialization)
Diagnose a failed cast.
static bool tryDiagnoseOverloadedCast(Sema &S, CastType CT, SourceRange range, Expr *src, QualType destType, bool listInitialization)
Try to diagnose a failed overloaded cast.
static bool argTypeIsABIEquivalent(QualType SrcType, QualType DestType, ASTContext &Context)
static unsigned int checkCastFunctionType(Sema &Self, const ExprResult &SrcExpr, QualType DestType)
@ TC_Success
The cast method is appropriate and successful.
@ TC_Extension
The cast method is appropriate and accepted as a language extension.
@ TC_Failed
The cast method is appropriate, but failed.
@ TC_NotApplicable
The cast method is not applicable.
static TryCastResult TryStaticCast(Sema &Self, ExprResult &SrcExpr, QualType DestType, Sema::CheckedConversionKind CCK, SourceRange OpRange, unsigned &msg, CastKind &Kind, CXXCastPath &BasePath, bool ListInitialization)
TryStaticCast - Check if a static cast can be performed, and do so if possible.
static TryCastResult TryStaticImplicitCast(Sema &Self, ExprResult &SrcExpr, QualType DestType, Sema::CheckedConversionKind CCK, SourceRange OpRange, unsigned &msg, CastKind &Kind, bool ListInitialization)
TryStaticImplicitCast - Tests whether a conversion according to C++ 5.2.9p2 is valid:
static TryCastResult TryStaticReferenceDowncast(Sema &Self, Expr *SrcExpr, QualType DestType, bool CStyle, SourceRange OpRange, unsigned &msg, CastKind &Kind, CXXCastPath &BasePath)
Tests whether a conversion according to C++ 5.2.9p5 is valid.
static void DiagnoseCastQual(Sema &Self, const ExprResult &SrcExpr, QualType DestType)
DiagnoseCastQual - Warn whenever casts discards a qualifiers, be it either const, volatile or both.
static void DiagnoseCastOfObjCSEL(Sema &Self, const ExprResult &SrcExpr, QualType DestType)
static void DiagnoseBadFunctionCast(Sema &Self, const ExprResult &SrcExpr, QualType DestType)
DiagnoseBadFunctionCast - Warn whenever a function call is cast to a non-matching type.
static TryCastResult TryStaticDowncast(Sema &Self, CanQualType SrcType, CanQualType DestType, bool CStyle, SourceRange OpRange, QualType OrigSrcType, QualType OrigDestType, unsigned &msg, CastKind &Kind, CXXCastPath &BasePath)
TryStaticDowncast - Common functionality of TryStaticReferenceDowncast and TryStaticPointerDowncast.
static TryCastResult TryReinterpretCast(Sema &Self, ExprResult &SrcExpr, QualType DestType, bool CStyle, SourceRange OpRange, unsigned &msg, CastKind &Kind)
static bool fixOverloadedReinterpretCastExpr(Sema &Self, QualType DestType, ExprResult &Result)
static CastAwayConstnessKind unwrapCastAwayConstnessLevel(ASTContext &Context, QualType &T1, QualType &T2)
Unwrap one level of types for CastsAwayConstness.
static void DiagnoseCallingConvCast(Sema &Self, const ExprResult &SrcExpr, QualType DstType, SourceRange OpRange)
Diagnose casts that change the calling convention of a pointer to a function defined in the current T...
static TryCastResult TryLValueToRValueCast(Sema &Self, Expr *SrcExpr, QualType DestType, bool CStyle, CastKind &Kind, CXXCastPath &BasePath, unsigned &msg)
Tests whether a conversion according to N2844 is valid.
static TryCastResult TryStaticMemberPointerUpcast(Sema &Self, ExprResult &SrcExpr, QualType SrcType, QualType DestType, bool CStyle, SourceRange OpRange, unsigned &msg, CastKind &Kind, CXXCastPath &BasePath)
TryStaticMemberPointerUpcast - Tests whether a conversion according to C++ 5.2.9p9 is valid:
static void checkIntToPointerCast(bool CStyle, const SourceRange &OpRange, const Expr *SrcExpr, QualType DestType, Sema &Self)
static TryCastResult TryAddressSpaceCast(Sema &Self, ExprResult &SrcExpr, QualType DestType, bool CStyle, unsigned &msg, CastKind &Kind)
static TryCastResult TryStaticPointerDowncast(Sema &Self, QualType SrcType, QualType DestType, bool CStyle, SourceRange OpRange, unsigned &msg, CastKind &Kind, CXXCastPath &BasePath)
Tests whether a conversion according to C++ 5.2.9p8 is valid.
TextDiagnosticBuffer::DiagList DiagList
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
void UnwrapSimilarArrayTypes(QualType &T1, QualType &T2, bool AllowPiMismatch=true)
Attempt to unwrap two types that may both be array types with the same bound (or both be array types ...
const LangOptions & getLangOpts() const
TypeInfoChars getTypeInfoInChars(const Type *T) const
bool hasSameUnqualifiedType(QualType T1, QualType T2) const
Determine whether the given types are equivalent after cvr-qualifiers have been removed.
const ArrayType * getAsArrayType(QualType T) const
Type Query functions.
uint64_t getTypeSize(QualType T) const
Return the size of the specified (complete) type T, in bits.
bool UnwrapSimilarTypes(QualType &T1, QualType &T2, bool AllowPiMismatch=true)
Attempt to unwrap two types that may be similar (C++ [conv.qual]).
ASTRecordLayout - This class contains layout information for one RecordDecl, which is a struct/union/...
CharUnits getBaseClassOffset(const CXXRecordDecl *Base) const
getBaseClassOffset - Get the offset, in chars, for the given base class.
Represents a C++2a __builtin_bit_cast(T, v) expression.
This class is used for builtin types like 'int'.
static CStyleCastExpr * Create(const ASTContext &Context, QualType T, ExprValueKind VK, CastKind K, Expr *Op, const CXXCastPath *BasePath, FPOptionsOverride FPO, TypeSourceInfo *WrittenTy, SourceLocation L, SourceLocation R)
static CXXAddrspaceCastExpr * Create(const ASTContext &Context, QualType T, ExprValueKind VK, CastKind Kind, Expr *Op, TypeSourceInfo *WrittenTy, SourceLocation L, SourceLocation RParenLoc, SourceRange AngleBrackets)
Represents a path from a specific derived class (which is not represented as part of the path) to a p...
BasePaths - Represents the set of paths from a derived class to one of its (direct or indirect) bases...
std::list< CXXBasePath >::const_iterator const_paths_iterator
static CXXConstCastExpr * Create(const ASTContext &Context, QualType T, ExprValueKind VK, Expr *Op, TypeSourceInfo *WrittenTy, SourceLocation L, SourceLocation RParenLoc, SourceRange AngleBrackets)
static CXXDynamicCastExpr * Create(const ASTContext &Context, QualType T, ExprValueKind VK, CastKind Kind, Expr *Op, const CXXCastPath *Path, TypeSourceInfo *Written, SourceLocation L, SourceLocation RParenLoc, SourceRange AngleBrackets)
static CXXFunctionalCastExpr * Create(const ASTContext &Context, QualType T, ExprValueKind VK, TypeSourceInfo *Written, CastKind Kind, Expr *Op, const CXXCastPath *Path, FPOptionsOverride FPO, SourceLocation LPLoc, SourceLocation RPLoc)
Represents a static or instance method of a struct/union/class.
const CXXRecordDecl * getParent() const
Return the parent of this method declaration, which is the class in which this method is defined.
Represents a C++ struct/union/class.
bool isDerivedFrom(const CXXRecordDecl *Base) const
Determine whether this class is derived from the class Base.
static CXXReinterpretCastExpr * Create(const ASTContext &Context, QualType T, ExprValueKind VK, CastKind Kind, Expr *Op, const CXXCastPath *Path, TypeSourceInfo *WrittenTy, SourceLocation L, SourceLocation RParenLoc, SourceRange AngleBrackets)
static CXXStaticCastExpr * Create(const ASTContext &Context, QualType T, ExprValueKind VK, CastKind K, Expr *Op, const CXXCastPath *Path, TypeSourceInfo *Written, FPOptionsOverride FPO, SourceLocation L, SourceLocation RParenLoc, SourceRange AngleBrackets)
CanQual< T > getUnqualifiedType() const
Retrieve the unqualified form of this type.
CanProxy< U > getAs() const
Retrieve a canonical type pointer with a different static type, upcasting or downcasting as needed.
bool isAtLeastAsQualifiedAs(CanQual< T > Other) const
Determines whether this canonical type is at least as qualified as the Other canonical type.
CastExpr - Base class for type casts, including both implicit casts (ImplicitCastExpr) and explicit c...
static const FieldDecl * getTargetFieldForToUnionCast(QualType unionType, QualType opType)
CharUnits - This is an opaque type for sizes expressed in character units.
QuantityType getQuantity() const
getQuantity - Get the raw integer representation of this quantity.
static CharUnits Zero()
Zero - Construct a CharUnits quantity of zero.
A POD class for pairing a NamedDecl* with an access specifier.
bool isInvalidDecl() const
Information about one declarator, including the parsed type information and the identifier.
bool isInvalidType() const
bool isIgnored(unsigned DiagID, SourceLocation Loc) const
Determine whether the diagnostic is known to be ignored.
A helper class that allows the use of isa/cast/dyncast to detect TagType objects of enums.
This represents one expression.
bool isTypeDependent() const
Determines whether the type of this expression depends on.
Expr * IgnoreParenImpCasts() LLVM_READONLY
Skip past any parentheses and implicit casts which might surround this expression until reaching a fi...
bool isLValue() const
isLValue - True if this expression is an "l-value" according to the rules of the current language.
ExprObjectKind getObjectKind() const
getObjectKind - The object kind that this expression produces.
bool isIntegerConstantExpr(const ASTContext &Ctx, SourceLocation *Loc=nullptr) const
SourceLocation getExprLoc() const LLVM_READONLY
getExprLoc - Return the preferred location for the arrow when diagnosing a problem with a generic exp...
bool refersToBitField() const
Returns true if this expression is a gl-value that potentially refers to a bit-field.
static ExprValueKind getValueKindForType(QualType T)
getValueKindForType - Given a formal return or parameter type, give its value kind.
static FixItHint CreateReplacement(CharSourceRange RemoveRange, StringRef Code)
Create a code modification hint that replaces the given source range with the given code string.
static FixItHint CreateInsertion(SourceLocation InsertionLoc, StringRef Code, bool BeforePreviousInsertions=false)
Create a code modification hint that inserts the given code string at a specific location.
Represents a function declaration or definition.
Represents a prototype with parameter type info, e.g.
FunctionType - C99 6.7.5.3 - Function Declarators.
static StringRef getNameForCallConv(CallingConv CC)
CallingConv getCallConv() const
QualType getReturnType() const
One of these records is kept for each identifier that is lexed.
tok::TokenKind getTokenID() const
If this is a source-language token (e.g.
bool isKeyword(const LangOptions &LangOpts) const
Return true if this token is a keyword in the specified language.
static ImplicitCastExpr * Create(const ASTContext &Context, QualType T, CastKind Kind, Expr *Operand, const CXXCastPath *BasePath, ExprValueKind Cat, FPOptionsOverride FPO)
Describes the kind of initialization being performed, along with location information for tokens rela...
static InitializationKind CreateCast(SourceRange TypeRange)
Create a direct initialization due to a cast that isn't a C-style or functional cast.
static InitializationKind CreateFunctionalCast(SourceRange TypeRange, bool InitList)
Create a direct initialization for a functional cast.
static InitializationKind CreateCStyleCast(SourceLocation StartLoc, SourceRange TypeRange, bool InitList)
Create a direct initialization for a C-style cast.
Describes the sequence of initializations required to initialize a given object or reference with a s...
ExprResult Perform(Sema &S, const InitializedEntity &Entity, const InitializationKind &Kind, MultiExprArg Args, QualType *ResultType=nullptr)
Perform the actual initialization of the given entity based on the computed initialization sequence.
FailureKind getFailureKind() const
Determine why initialization failed.
OverloadingResult getFailedOverloadResult() const
Get the overloading result, for when the initialization sequence failed due to a bad overload.
bool Failed() const
Determine whether the initialization sequence is invalid.
@ FK_UserConversionOverloadFailed
Overloading for a user-defined conversion failed.
@ FK_ConstructorOverloadFailed
Overloading for initialization by constructor failed.
@ FK_ParenthesizedListInitFailed
Parenthesized list initialization failed at some point.
bool isConstructorInitialization() const
Determine whether this initialization is direct call to a constructor.
OverloadCandidateSet & getFailedCandidateSet()
Retrieve a reference to the candidate set when overload resolution fails.
Describes an entity that is being initialized.
static InitializedEntity InitializeTemporary(QualType Type)
Create the initialization entity for a temporary.
Represents a matrix type, as defined in the Matrix Types clang extensions.
A pointer to member type per C++ 8.3.3 - Pointers to members.
QualType getPointeeType() const
bool isMemberFunctionPointer() const
Returns true if the member type (i.e.
const Type * getClass() const
SourceRange getSourceRange() const LLVM_READONLY
Retrieve the source range covering the entirety of this nested-name-specifier.
OverloadCandidateSet - A set of overload candidates, used in C++ overload resolution (C++ 13....
void NoteCandidates(PartialDiagnosticAt PA, Sema &S, OverloadCandidateDisplayKind OCD, ArrayRef< Expr * > Args, StringRef Opc="", SourceLocation Loc=SourceLocation(), llvm::function_ref< bool(OverloadCandidate &)> Filter=[](OverloadCandidate &) { return true;})
When overload resolution fails, prints diagnostic messages containing the candidates in the candidate...
A reference to an overloaded function set, either an UnresolvedLookupExpr or an UnresolvedMemberExpr.
static FindResult find(Expr *E)
Finds the overloaded expression in the given expression E of OverloadTy.
NestedNameSpecifierLoc getQualifierLoc() const
Fetches the nested-name qualifier with source-location information, if one was given.
DeclarationName getName() const
Gets the name looked up.
PointerType - C99 6.7.5.1 - Pointer Declarators.
QualType getPointeeType() const
Engages in a tight little dance with the lexer to efficiently preprocess tokens.
IdentifierInfo * getIdentifierInfo(StringRef Name) const
Return information about the specified preprocessor identifier token.
StringRef getLastMacroWithSpelling(SourceLocation Loc, ArrayRef< TokenValue > Tokens) const
Return the name of the macro defined before Loc that has spelling Tokens.
A (possibly-)qualified type.
bool isTriviallyCopyableType(const ASTContext &Context) const
Return true if this is a trivially copyable type (C++0x [basic.types]p9)
QualType getNonLValueExprType(const ASTContext &Context) const
Determine the type of a (typically non-lvalue) expression with the specified result type.
bool isAtLeastAsQualifiedAs(QualType Other) const
Determine whether this type is at least as qualified as the other given type, requiring exact equalit...
bool isNull() const
Return true if this QualType doesn't point to a type yet.
const Type * getTypePtr() const
Retrieves a pointer to the underlying (unqualified) type.
LangAS getAddressSpace() const
Return the address space of this type.
Qualifiers getQualifiers() const
Retrieve the set of qualifiers applied to this type.
bool isAddressSpaceOverlapping(QualType T) const
Returns true if address space qualifiers overlap with T address space qualifiers.
QualType getNonReferenceType() const
If Type is a reference type (e.g., const int&), returns the type that the reference refers to ("const...
QualType getUnqualifiedType() const
Retrieve the unqualified variant of the given type, removing as little sugar as possible.
QualType withCVRQualifiers(unsigned CVR) const
unsigned getCVRQualifiers() const
Retrieve the set of CVR (const-volatile-restrict) qualifiers applied to this type.
static std::string getAsString(SplitQualType split, const PrintingPolicy &Policy)
The collection of all-type qualifiers we support.
unsigned getCVRQualifiers() const
void removeObjCLifetime()
static Qualifiers fromCVRMask(unsigned CVR)
static bool isAddressSpaceSupersetOf(LangAS A, LangAS B)
Returns true if address space A is equal to or a superset of B.
bool compatiblyIncludes(Qualifiers other) const
Determines if these qualifiers compatibly include another set.
bool compatiblyIncludesObjCLifetime(Qualifiers other) const
Determines if these qualifiers compatibly include another set of qualifiers from the narrow perspecti...
An rvalue reference type, per C++11 [dcl.ref].
Represents a struct/union/class.
RecordDecl * getDefinition() const
Returns the RecordDecl that actually defines this struct/union/class.
A helper class that allows the use of isa/cast/dyncast to detect TagType objects of structs/unions/cl...
RecordDecl * getDecl() const
Base for LValueReferenceType and RValueReferenceType.
QualType getPointeeType() const
Sema - This implements semantic analysis and AST building for C.
SemaDiagnosticBuilder Diag(SourceLocation Loc, unsigned DiagID, bool DeferHint=false)
Emit a diagnostic.
ReferenceCompareResult
ReferenceCompareResult - Expresses the result of comparing two types (cv1 T1 and cv2 T2) to determine...
@ Ref_Incompatible
Ref_Incompatible - The two types are incompatible, so direct reference binding is not possible.
@ Ref_Compatible
Ref_Compatible - The two types are reference-compatible.
ExprResult BuildCXXFunctionalCastExpr(TypeSourceInfo *TInfo, QualType Type, SourceLocation LParenLoc, Expr *CastExpr, SourceLocation RParenLoc)
ExprResult BuildBuiltinBitCastExpr(SourceLocation KWLoc, TypeSourceInfo *TSI, Expr *Operand, SourceLocation RParenLoc)
FPOptionsOverride CurFPFeatureOverrides()
bool ShouldSplatAltivecScalarInCast(const VectorType *VecTy)
ExprResult ActOnBuiltinBitCastExpr(SourceLocation KWLoc, Declarator &Dcl, ExprResult Operand, SourceLocation RParenLoc)
const LangOptions & getLangOpts() const
void CheckExtraCXXDefaultArguments(Declarator &D)
CheckExtraCXXDefaultArguments - Check for any extra default arguments in the declarator,...
ExprResult BuildCStyleCastExpr(SourceLocation LParenLoc, TypeSourceInfo *Ty, SourceLocation RParenLoc, Expr *Op)
ExprResult ActOnCXXNamedCast(SourceLocation OpLoc, tok::TokenKind Kind, SourceLocation LAngleBracketLoc, Declarator &D, SourceLocation RAngleBracketLoc, SourceLocation LParenLoc, Expr *E, SourceLocation RParenLoc)
ActOnCXXNamedCast - Parse {dynamic,static,reinterpret,const,addrspace}_cast's.
CheckedConversionKind
The kind of conversion being performed.
@ CCK_OtherCast
A cast other than a C-style cast.
@ CCK_CStyleCast
A C-style cast.
@ CCK_FunctionalCast
A functional-style cast.
void DiscardMisalignedMemberAddress(const Type *T, Expr *E)
This function checks if the expression is in the sef of potentially misaligned members and it is conv...
void CheckCompatibleReinterpretCast(QualType SrcType, QualType DestType, bool IsDereference, SourceRange Range)
TypeSourceInfo * GetTypeForDeclaratorCast(Declarator &D, QualType FromTy)
PartialDiagnostic PDiag(unsigned DiagID=0)
Build a partial diagnostic.
DiagnosticsEngine & Diags
ExprResult BuildCXXNamedCast(SourceLocation OpLoc, tok::TokenKind Kind, TypeSourceInfo *Ty, Expr *E, SourceRange AngleBrackets, SourceRange Parens)
bool CheckAltivecInitFromScalar(SourceRange R, QualType VecTy, QualType SrcTy)
Encodes a location in the source.
bool isValid() const
Return true if this is a valid SourceLocation object.
A trivial tuple used to represent a source range.
SourceLocation getBegin() const
SourceLocation getEndLoc() const LLVM_READONLY
SourceRange getSourceRange() const LLVM_READONLY
SourceLocation tokens are not useful in isolation - they are low level value objects created/interpre...
SourceLocation getBeginLoc() const LLVM_READONLY
bool isCompleteDefinition() const
Return true if this decl has its body fully specified.
Stores token information for comparing actual tokens with predefined values.
Base wrapper for a particular "section" of type source info.
SourceRange getSourceRange() const LLVM_READONLY
Get the full source range.
SourceLocation getEndLoc() const
Get the end source location.
SourceLocation getBeginLoc() const
Get the begin source location.
A container of type source information.
TypeLoc getTypeLoc() const
Return the TypeLoc wrapper for the type source info.
QualType getType() const
Return the type wrapped by this type source info.
The base class of the type hierarchy.
bool isIncompleteOrObjectType() const
Return true if this is an incomplete or object type, in other words, not a function type.
CXXRecordDecl * getAsCXXRecordDecl() const
Retrieves the CXXRecordDecl that this type refers to, either because the type is a RecordType or beca...
bool isBlockPointerType() const
bool isBooleanType() const
bool isFunctionReferenceType() const
bool isPlaceholderType() const
Test for a type which does not represent an actual type-system type but is instead used as a placehol...
bool isSignedIntegerType() const
Return true if this is an integer type that is signed, according to C99 6.2.5p4 [char,...
bool isComplexType() const
isComplexType() does not include complex integers (a GCC extension).
bool isRValueReferenceType() const
bool isVoidPointerType() const
bool isFunctionPointerType() const
bool isArithmeticType() const
bool isPointerType() const
bool isIntegerType() const
isIntegerType() does not include complex integers (a GCC extension).
const T * castAs() const
Member-template castAs<specific type>.
bool isReferenceType() const
bool isEnumeralType() const
bool isScalarType() const
const CXXRecordDecl * getPointeeCXXRecordDecl() const
If this is a pointer or reference to a RecordType, return the CXXRecordDecl that the type refers to.
bool isSizelessBuiltinType() const
bool isIntegralType(const ASTContext &Ctx) const
Determine whether this type is an integral type.
QualType getPointeeType() const
If this is a pointer, ObjC object pointer, or block pointer, this returns the respective pointee.
bool isIntegralOrEnumerationType() const
Determine whether this type is an integral or enumeration type.
bool isExtVectorType() const
bool isAnyCharacterType() const
Determine whether this type is any of the built-in character types.
bool isLValueReferenceType() const
bool isDependentType() const
Whether this type is a dependent type, meaning that its definition somehow depends on a template para...
bool isFixedPointType() const
Return true if this is a fixed point type according to ISO/IEC JTC1 SC22 WG14 N1169.
const BuiltinType * getAsPlaceholderType() const
bool isWebAssemblyTableType() const
Returns true if this is a WebAssembly table type: either an array of reference types,...
bool containsErrors() const
Whether this type is an error type.
bool isMemberPointerType() const
bool isMatrixType() const
bool isComplexIntegerType() const
bool isObjCObjectType() const
bool isObjCLifetimeType() const
Returns true if objects of this type have lifetime semantics under ARC.
bool isFunctionType() const
bool isObjCObjectPointerType() const
bool isMemberFunctionPointerType() const
bool isVectorType() const
bool isRealFloatingType() const
Floating point categories.
bool isFloatingType() const
bool isUnsignedIntegerType() const
Return true if this is an integer type that is unsigned, according to C99 6.2.5p6 [which returns true...
bool isAnyPointerType() const
const T * getAs() const
Member-template getAs<specific type>'.
bool isNullPtrType() const
bool isRecordType() const
bool isFunctionNoProtoType() const
RecordDecl * getAsRecordDecl() const
Retrieves the RecordDecl this type refers to.
Represents a GCC generic vector type.
VectorKind getVectorKind() const
Defines the clang::TargetInfo interface.
const internal::VariadicDynCastAllOfMatcher< Stmt, CastExpr > castExpr
Matches any cast nodes of Clang's AST.
TokenKind
Provides a simple uniform namespace for tokens from all C languages.
The JSON file list parser is used to communicate input to InstallAPI.
@ Self
'self' clause, allowed on Compute and Combined Constructs, plus 'update'.
@ OR_Deleted
Succeeded, but refers to a deleted function.
@ OR_Success
Overload resolution succeeded.
@ OR_Ambiguous
Ambiguous candidates found.
@ OR_No_Viable_Function
No viable function found.
OverloadCandidateDisplayKind
@ OCD_AmbiguousCandidates
Requests that only tied-for-best candidates be shown.
@ OCD_ViableCandidates
Requests that only viable candidates be shown.
@ OCD_AllCandidates
Requests that all candidates be shown.
@ OK_VectorComponent
A vector component is an element or range of elements on a vector.
@ OK_ObjCProperty
An Objective-C property is a logical field of an Objective-C object which is read and written via Obj...
@ OK_ObjCSubscript
An Objective-C array/dictionary subscripting which reads an object or writes at the subscripted array...
@ OK_Ordinary
An ordinary object is located at an address in memory.
@ OK_BitField
A bitfield object is a bitfield on a C or C++ record.
@ OK_MatrixComponent
A matrix component is a single element of a matrix.
@ Result
The result type of a method or function.
CastKind
CastKind - The kind of operation required for a conversion.
ExprValueKind
The categorization of expression values, currently following the C++11 scheme.
@ VK_PRValue
A pr-value expression (in the C++11 taxonomy) produces a temporary value.
std::pair< SourceLocation, PartialDiagnostic > PartialDiagnosticAt
A partial diagnostic along with the source location where this diagnostic occurs.
CallingConv
CallingConv - Specifies the calling convention that a function uses.
@ AltiVecBool
is AltiVec 'vector bool ...'
@ AltiVecVector
is AltiVec vector
@ AltiVecPixel
is AltiVec 'vector Pixel'
@ None
The alignment was not explicit in code.
@ Class
The "class" keyword introduces the elaborated-type-specifier.
@ Enum
The "enum" keyword introduces the elaborated-type-specifier.
@ Parens
New-expression has a C++98 paren-delimited initializer.
Represents an element in a path from a derived class to a base class.
EvalResult is a struct with detailed info about an evaluated expression.
OverloadExpr * Expression
ReferenceConversions
The conversions that would be performed on an lvalue of type T2 when binding a reference of type T1 t...