27#include "llvm/ADT/SmallVector.h"
57 struct CastOperation {
59 : Self(S), SrcExpr(src), DestType(destType),
62 Kind(CK_Dependent), IsARCUnbridgedCast(
false) {
73 !DestType->isArrayType()) {
74 DestType = DestType.getAtomicUnqualifiedType();
79 PlaceholderKind = placeholder->getKind();
93 bool IsARCUnbridgedCast;
99 void CheckConstCast();
100 void CheckReinterpretCast();
101 void CheckStaticCast();
102 void CheckDynamicCast();
103 void CheckCXXCStyleCast(
bool FunctionalCast,
bool ListInitialization);
104 void CheckCStyleCast();
105 void CheckBuiltinBitCast();
106 void CheckAddrspaceCast();
108 void updatePartOfExplicitCastFlags(
CastExpr *CE) {
112 for (;
auto *ICE = dyn_cast<ImplicitCastExpr>(CE->
getSubExpr()); CE = ICE)
113 ICE->setIsPartOfExplicitCast(
true);
121 if (IsARCUnbridgedCast) {
127 updatePartOfExplicitCastFlags(
castExpr);
137 if (PlaceholderKind != K)
return false;
143 bool isPlaceholder()
const {
144 return PlaceholderKind != 0;
147 return PlaceholderKind == K;
153 void checkCastAlign() {
163 IsARCUnbridgedCast =
true;
168 void checkNonOverloadPlaceholders() {
169 if (!isPlaceholder() || isPlaceholder(BuiltinType::Overload))
181 if (
const auto *PtrType = dyn_cast<PointerType>(FromType)) {
182 if (PtrType->getPointeeType()->hasAttr(attr::NoDeref)) {
183 if (
const auto *DestType = dyn_cast<PointerType>(ToType)) {
184 if (!DestType->getPointeeType()->hasAttr(attr::NoDeref)) {
185 S.
Diag(OpLoc, diag::warn_noderef_to_dereferenceable_pointer);
192 struct CheckNoDerefRAII {
193 CheckNoDerefRAII(CastOperation &Op) : Op(Op) {}
194 ~CheckNoDerefRAII() {
195 if (!Op.SrcExpr.isInvalid())
196 CheckNoDeref(Op.Self, Op.SrcExpr.get()->getType(), Op.ResultType,
197 Op.OpRange.getBegin());
239 QualType OrigDestType,
unsigned &msg,
255 bool ListInitialization);
262 bool ListInitialization);
310 CastOperation Op(*
this, DestType, E);
312 Op.DestRange = AngleBrackets;
315 default: llvm_unreachable(
"Unknown C++ cast!");
317 case tok::kw_addrspace_cast:
318 if (!TypeDependent) {
319 Op.CheckAddrspaceCast();
320 if (Op.SrcExpr.isInvalid())
324 Context, Op.ResultType, Op.ValueKind, Op.Kind, Op.SrcExpr.get(),
325 DestTInfo, OpLoc, Parens.getEnd(), AngleBrackets));
327 case tok::kw_const_cast:
328 if (!TypeDependent) {
330 if (Op.SrcExpr.isInvalid())
335 Op.ValueKind, Op.SrcExpr.get(), DestTInfo,
336 OpLoc, Parens.getEnd(),
339 case tok::kw_dynamic_cast: {
342 return ExprError(
Diag(OpLoc, diag::err_openclcxx_not_supported)
346 if (!TypeDependent) {
347 Op.CheckDynamicCast();
348 if (Op.SrcExpr.isInvalid())
352 Op.ValueKind, Op.Kind, Op.SrcExpr.get(),
353 &Op.BasePath, DestTInfo,
354 OpLoc, Parens.getEnd(),
357 case tok::kw_reinterpret_cast: {
358 if (!TypeDependent) {
359 Op.CheckReinterpretCast();
360 if (Op.SrcExpr.isInvalid())
365 Op.ValueKind, Op.Kind, Op.SrcExpr.get(),
366 nullptr, DestTInfo, OpLoc,
370 case tok::kw_static_cast: {
371 if (!TypeDependent) {
372 Op.CheckStaticCast();
373 if (Op.SrcExpr.isInvalid())
379 Context, Op.ResultType, Op.ValueKind, Op.Kind, Op.SrcExpr.get(),
381 Parens.getEnd(), AngleBrackets));
401 CastOperation Op(*
this, TSI->
getType(), Operand);
407 Op.CheckBuiltinBitCast();
408 if (Op.SrcExpr.isInvalid())
414 Op.SrcExpr.get(), TSI, KWLoc, RParenLoc);
415 return Op.complete(BCE);
423 bool listInitialization) {
446 range, listInitialization)
452 assert(sequence.
Failed() &&
"initialization succeeded on second try?");
454 default:
return false;
468 case OR_Success: llvm_unreachable(
"successful failed overload");
470 if (candidates.
empty())
471 msg = diag::err_ovl_no_conversion_in_cast;
473 msg = diag::err_ovl_no_viable_conversion_in_cast;
478 msg = diag::err_ovl_ambiguous_conversion_in_cast;
483 msg = diag::err_ovl_deleted_conversion_in_cast;
490 S.
PDiag(msg) << CT << srcType << destType << range
492 S, howManyCandidates, src);
500 bool listInitialization) {
501 if (msg == diag::err_bad_cxx_cast_generic &&
510 int DifferentPtrness = 0;
521 if (!DifferentPtrness) {
524 if (RecFrom && RecTo) {
526 if (!DeclFrom->isCompleteDefinition())
527 S.
Diag(DeclFrom->getLocation(), diag::note_type_incomplete) << DeclFrom;
529 if (!DeclTo->isCompleteDefinition())
530 S.
Diag(DeclTo->getLocation(), diag::note_type_incomplete) << DeclTo;
538enum CastAwayConstnessKind {
545 CACK_SimilarKind = 2,
564static CastAwayConstnessKind
566 enum {
None, Ptr, MemPtr, BlockPtr, Array };
568 if (T->isAnyPointerType())
return Ptr;
569 if (T->isMemberPointerType())
return MemPtr;
570 if (T->isBlockPointerType())
return BlockPtr;
573 if (T->isConstantArrayType() || T->isIncompleteArrayType())
return Array;
579 return AT->getElementType();
580 return T->getPointeeType();
583 CastAwayConstnessKind Kind;
591 Kind = CastAwayConstnessKind::CACK_Similar;
593 Kind = CastAwayConstnessKind::CACK_Similar;
596 int T1Class = Classify(T1);
598 return CastAwayConstnessKind::CACK_None;
600 int T2Class = Classify(T2);
602 return CastAwayConstnessKind::CACK_None;
606 Kind = T1Class == T2Class ? CastAwayConstnessKind::CACK_SimilarKind
607 : CastAwayConstnessKind::CACK_Incoherent;
617 if (Classify(T1) != Array)
620 auto T2Class = Classify(T2);
624 if (T2Class != Array)
625 Kind = CastAwayConstnessKind::CACK_Incoherent;
626 else if (Kind != CastAwayConstnessKind::CACK_Incoherent)
627 Kind = CastAwayConstnessKind::CACK_SimilarKind;
642static CastAwayConstnessKind
644 bool CheckCVR,
bool CheckObjCLifetime,
645 QualType *TheOffendingSrcType =
nullptr,
646 QualType *TheOffendingDestType =
nullptr,
651 return CastAwayConstnessKind::CACK_None;
656 "Source type is not pointer or pointer to member.");
659 "Destination type is not pointer or pointer to member.");
668 QualType PrevUnwrappedSrcType = UnwrappedSrcType;
669 QualType PrevUnwrappedDestType = UnwrappedDestType;
670 auto WorstKind = CastAwayConstnessKind::CACK_Similar;
671 bool AllConstSoFar =
true;
673 Self.
Context, UnwrappedSrcType, UnwrappedDestType)) {
676 if (Kind > WorstKind)
688 UnwrappedDestType->isObjCObjectType())
697 if (SrcCvrQuals != DestCvrQuals) {
698 if (CastAwayQualifiers)
699 *CastAwayQualifiers = SrcCvrQuals - DestCvrQuals;
702 if (!DestCvrQuals.compatiblyIncludes(SrcCvrQuals)) {
703 if (TheOffendingSrcType)
704 *TheOffendingSrcType = PrevUnwrappedSrcType;
705 if (TheOffendingDestType)
706 *TheOffendingDestType = PrevUnwrappedDestType;
717 if (CheckObjCLifetime &&
723 if (AllConstSoFar && !DestQuals.
hasConst()) {
724 AllConstSoFar =
false;
725 if (TheOffendingSrcType)
726 *TheOffendingSrcType = PrevUnwrappedSrcType;
727 if (TheOffendingDestType)
728 *TheOffendingDestType = PrevUnwrappedDestType;
731 PrevUnwrappedSrcType = UnwrappedSrcType;
732 PrevUnwrappedDestType = UnwrappedDestType;
735 return CastAwayConstnessKind::CACK_None;
741 case CastAwayConstnessKind::CACK_None:
742 llvm_unreachable(
"did not cast away constness");
744 case CastAwayConstnessKind::CACK_Similar:
746 case CastAwayConstnessKind::CACK_SimilarKind:
747 DiagID = diag::err_bad_cxx_cast_qualifiers_away;
750 case CastAwayConstnessKind::CACK_Incoherent:
751 DiagID = diag::ext_bad_cxx_cast_qualifiers_away_incoherent;
755 llvm_unreachable(
"unexpected cast away constness kind");
761void CastOperation::CheckDynamicCast() {
762 CheckNoDerefRAII NoderefCheck(*
this);
765 SrcExpr = Self.DefaultFunctionArrayLvalueConversion(SrcExpr.get());
766 else if (isPlaceholder())
767 SrcExpr = Self.CheckPlaceholderExpr(SrcExpr.get());
768 if (SrcExpr.isInvalid())
771 QualType OrigSrcType = SrcExpr.get()->getType();
785 Self.Diag(OpRange.getBegin(), diag::err_bad_dynamic_cast_not_ref_or_ptr)
786 << this->DestType << DestRange;
793 assert(DestPointer &&
"Reference to void is not possible");
794 }
else if (DestRecord) {
795 if (Self.RequireCompleteType(OpRange.getBegin(), DestPointee,
796 diag::err_bad_cast_incomplete,
802 Self.Diag(OpRange.getBegin(), diag::err_bad_dynamic_cast_not_class)
818 Self.Diag(OpRange.getBegin(), diag::err_bad_dynamic_cast_not_ptr)
819 << OrigSrcType << this->DestType << SrcExpr.get()->getSourceRange();
823 }
else if (DestReference->isLValueReferenceType()) {
824 if (!SrcExpr.get()->isLValue()) {
825 Self.Diag(OpRange.getBegin(), diag::err_bad_cxx_cast_rvalue)
826 <<
CT_Dynamic << OrigSrcType << this->DestType << OpRange;
828 SrcPointee = SrcType;
832 if (SrcExpr.get()->isPRValue())
833 SrcExpr = Self.CreateMaterializeTemporaryExpr(
834 SrcType, SrcExpr.get(),
false);
835 SrcPointee = SrcType;
840 if (Self.RequireCompleteType(OpRange.getBegin(), SrcPointee,
841 diag::err_bad_cast_incomplete,
847 Self.Diag(OpRange.getBegin(), diag::err_bad_dynamic_cast_not_class)
853 assert((DestPointer || DestReference) &&
854 "Bad destination non-ptr/ref slipped through.");
855 assert((DestRecord || DestPointee->
isVoidType()) &&
856 "Bad destination pointee slipped through.");
857 assert(SrcRecord &&
"Bad source pointee slipped through.");
861 Self.Diag(OpRange.getBegin(), diag::err_bad_cxx_cast_qualifiers_away)
862 <<
CT_Dynamic << OrigSrcType << this->DestType << OpRange;
869 if (DestRecord == SrcRecord) {
877 Self.IsDerivedFrom(OpRange.getBegin(), SrcPointee, DestPointee)) {
878 if (Self.CheckDerivedToBaseConversion(SrcPointee, DestPointee,
879 OpRange.getBegin(), OpRange,
885 Kind = CK_DerivedToBase;
891 assert(SrcDecl &&
"Definition missing");
892 if (!cast<CXXRecordDecl>(SrcDecl)->isPolymorphic()) {
893 Self.Diag(OpRange.getBegin(), diag::err_bad_dynamic_cast_not_polymorphic)
901 if (!Self.getLangOpts().RTTI && !DestPointee->
isVoidType()) {
902 Self.Diag(OpRange.getBegin(), diag::err_no_dynamic_cast_with_fno_rtti);
908 if (!Self.getLangOpts().RTTIData) {
910 Self.getASTContext().getTargetInfo().getCXXABI().isMicrosoft();
911 bool isClangCL = Self.getDiagnostics().getDiagnosticOptions().getFormat() ==
913 if (MicrosoftABI || !DestPointee->
isVoidType())
914 Self.Diag(OpRange.getBegin(),
915 diag::warn_no_dynamic_cast_with_rtti_disabled)
928void CastOperation::CheckConstCast() {
929 CheckNoDerefRAII NoderefCheck(*
this);
932 SrcExpr = Self.DefaultFunctionArrayLvalueConversion(SrcExpr.get());
933 else if (isPlaceholder())
934 SrcExpr = Self.CheckPlaceholderExpr(SrcExpr.get());
935 if (SrcExpr.isInvalid())
938 unsigned msg = diag::err_bad_cxx_cast_generic;
939 auto TCR =
TryConstCast(Self, SrcExpr, DestType,
false, msg);
941 Self.Diag(OpRange.getBegin(), msg) <<
CT_Const
942 << SrcExpr.get()->getType() << DestType << OpRange;
948void CastOperation::CheckAddrspaceCast() {
949 unsigned msg = diag::err_bad_cxx_cast_generic;
953 Self.Diag(OpRange.getBegin(), msg)
954 <<
CT_Addrspace << SrcExpr.get()->getType() << DestType << OpRange;
991 ReinterpretKind = ReinterpretUpcast;
993 ReinterpretKind = ReinterpretDowncast;
997 bool VirtualBase =
true;
998 bool NonZeroOffset =
false;
1000 E = BasePaths.
end();
1004 bool IsVirtual =
false;
1005 for (CXXBasePath::const_iterator IElem = Path.begin(), EElem = Path.end();
1006 IElem != EElem; ++IElem) {
1007 IsVirtual = IElem->Base->isVirtual();
1010 const CXXRecordDecl *BaseRD = IElem->Base->getType()->getAsCXXRecordDecl();
1011 assert(BaseRD &&
"Base type should be a valid unqualified class type");
1015 *ClassDefinition = Class->getDefinition();
1016 if (Class->isInvalidDecl() || !ClassDefinition ||
1017 !ClassDefinition->isCompleteDefinition())
1030 NonZeroOffset =
true;
1032 VirtualBase = VirtualBase && IsVirtual;
1035 (void) NonZeroOffset;
1036 assert((VirtualBase || NonZeroOffset) &&
1037 "Should have returned if has non-virtual base with zero offset");
1040 ReinterpretKind == ReinterpretUpcast? DestType : SrcType;
1042 ReinterpretKind == ReinterpretUpcast? SrcType : DestType;
1045 Self.
Diag(BeginLoc, diag::warn_reinterpret_different_from_static)
1046 << DerivedType << BaseType << !VirtualBase <<
int(ReinterpretKind)
1048 Self.
Diag(BeginLoc, diag::note_reinterpret_updowncast_use_static)
1049 <<
int(ReinterpretKind)
1069 unsigned int DiagID = 0;
1070 const unsigned int DiagList[] = {diag::warn_cast_function_type_strict,
1071 diag::warn_cast_function_type};
1096 assert(SrcFTy && DstFTy);
1102 if (DiagID == diag::warn_cast_function_type_strict)
1106 if (!T->getReturnType()->isVoidType())
1109 return !PT->isVariadic() && PT->getNumParams() == 0;
1114 if (IsVoidVoid(SrcFTy) || IsVoidVoid(DstFTy))
1128 const auto *SrcFPTy = cast<FunctionProtoType>(SrcFTy);
1129 const auto *DstFPTy = cast<FunctionProtoType>(DstFTy);
1133 unsigned NumParams = SrcFPTy->getNumParams();
1134 unsigned DstNumParams = DstFPTy->getNumParams();
1135 if (NumParams > DstNumParams) {
1136 if (!DstFPTy->isVariadic())
1138 NumParams = DstNumParams;
1139 }
else if (NumParams < DstNumParams) {
1140 if (!SrcFPTy->isVariadic())
1144 for (
unsigned i = 0; i < NumParams; ++i)
1146 DstFPTy->getParamType(i), Self.
Context))
1157void CastOperation::CheckReinterpretCast() {
1158 if (ValueKind ==
VK_PRValue && !isPlaceholder(BuiltinType::Overload))
1159 SrcExpr = Self.DefaultFunctionArrayLvalueConversion(SrcExpr.get());
1161 checkNonOverloadPlaceholders();
1162 if (SrcExpr.isInvalid())
1165 unsigned msg = diag::err_bad_cxx_cast_generic;
1168 false, OpRange, msg, Kind);
1170 if (SrcExpr.isInvalid())
1172 if (SrcExpr.get()->getType() == Self.Context.OverloadTy) {
1174 Self.Diag(OpRange.getBegin(), diag::err_bad_reinterpret_cast_overload)
1176 << DestType << OpRange;
1177 Self.NoteAllOverloadCandidates(SrcExpr.get());
1186 if (Self.getLangOpts().allowsNonTrivialObjCLifetimeQualifiers())
1191 Self.Diag(OpRange.getBegin(), DiagID)
1192 << SrcExpr.get()->getType() << DestType << OpRange;
1202void CastOperation::CheckStaticCast() {
1203 CheckNoDerefRAII NoderefCheck(*
this);
1205 if (isPlaceholder()) {
1206 checkNonOverloadPlaceholders();
1207 if (SrcExpr.isInvalid())
1217 if (claimPlaceholder(BuiltinType::Overload)) {
1218 Self.ResolveAndFixSingleFunctionTemplateSpecialization(SrcExpr,
1221 OpRange, DestType, diag::err_bad_static_cast_overload);
1222 if (SrcExpr.isInvalid())
1226 SrcExpr = Self.IgnoredValueConversions(SrcExpr.get());
1231 !isPlaceholder(BuiltinType::Overload)) {
1232 SrcExpr = Self.DefaultFunctionArrayLvalueConversion(SrcExpr.get());
1233 if (SrcExpr.isInvalid())
1237 unsigned msg = diag::err_bad_cxx_cast_generic;
1240 Kind, BasePath,
false);
1242 if (SrcExpr.isInvalid())
1244 if (SrcExpr.get()->getType() == Self.Context.OverloadTy) {
1246 Self.Diag(OpRange.getBegin(), diag::err_bad_static_cast_overload)
1247 << oe->
getName() << DestType << OpRange
1249 Self.NoteAllOverloadCandidates(SrcExpr.get());
1257 if (Kind == CK_BitCast)
1259 if (Self.getLangOpts().allowsNonTrivialObjCLifetimeQualifiers())
1274 DestPtrType->getPointeeType().getAddressSpace();
1285 bool ListInitialization) {
1311 OpRange, msg, Kind, BasePath);
1326 Kind, ListInitialization);
1348 if (
Enum->getDecl()->isScoped()) {
1350 Kind = CK_IntegralToBoolean;
1353 Kind = CK_IntegralCast;
1356 Kind = CK_IntegralToFloating;
1372 diag::err_bad_cast_incomplete)) {
1380 Kind =
Enum->getDecl()->isFixed() &&
1381 Enum->getDecl()->getIntegerType()->isBooleanType()
1382 ? CK_IntegralToBoolean
1386 Kind = CK_FloatingToIntegral;
1402 OpRange, msg, Kind, BasePath);
1425 if (DestPointeeQuals != SrcPointeeQuals &&
1427 msg = diag::err_bad_cxx_cast_qualifiers_away;
1432 ? CK_AddressSpaceConversion
1441 Self.
Diag(OpRange.
getBegin(), diag::ext_ms_cast_fn_obj) << OpRange;
1449 Kind = CK_CPointerToObjCPointerCast;
1454 Kind = CK_AnyPointerToBlockPointerCast;
1475 if (SrcPointer->getPointeeType()->getAs<
RecordType>() &&
1477 msg = diag::err_bad_cxx_cast_unrelated_class;
1518 SrcExpr->
getBeginLoc(), ToType, FromType, &RefConv);
1525 msg = SrcExpr->
isLValue() ? diag::err_bad_lvalue_to_rvalue_cast
1526 : diag::err_bad_rvalue_to_rvalue_cast;
1530 if (RefConv & Sema::ReferenceConversions::DerivedToBase) {
1531 Kind = CK_DerivedToBase;
1561 if (!DestReference) {
1565 if (!RValueRef && !SrcExpr->
isLValue()) {
1567 msg = diag::err_bad_cxx_cast_rvalue;
1579 OpRange, SrcExpr->
getType(), DestType, msg, Kind,
1604 msg = diag::err_bad_static_cast_pointer_nonpointer;
1611 CStyle, OpRange, SrcType, DestType, msg, Kind,
1621 QualType OrigDestType,
unsigned &msg,
1659 msg = diag::err_bad_cxx_cast_qualifiers_away;
1668 if (!Paths.isRecordingPaths()) {
1670 Paths.setRecordingPaths(
true);
1673 std::string PathDisplayStr;
1674 std::set<unsigned> DisplayedPaths;
1676 if (DisplayedPaths.insert(Path.back().SubobjectNumber).second) {
1679 PathDisplayStr +=
"\n ";
1681 PathDisplayStr += PE.Base->getType().getAsString() +
" -> ";
1686 Self.
Diag(OpRange.
getBegin(), diag::err_ambiguous_base_to_derived_cast)
1689 << PathDisplayStr << OpRange;
1694 if (Paths.getDetectedVirtual() !=
nullptr) {
1695 QualType VirtualBase(Paths.getDetectedVirtual(), 0);
1696 Self.
Diag(OpRange.
getBegin(), diag::err_static_downcast_via_virtual)
1697 << OrigSrcType << OrigDestType << VirtualBase << OpRange;
1706 diag::err_downcast_from_inaccessible_base)) {
1719 Kind = CK_BaseToDerived;
1740 bool WasOverloadedFunction =
false;
1749 WasOverloadedFunction =
true;
1755 msg = diag::err_bad_static_cast_member_pointer_nonmp;
1782 Paths.setRecordingPaths(
true);
1788 Self.
Diag(OpRange.
getBegin(), diag::err_ambiguous_memptr_conv)
1789 << 1 << SrcClass << DestClass << PathDisplayStr << OpRange;
1794 if (
const RecordType *VBase = Paths.getDetectedVirtual()) {
1795 Self.
Diag(OpRange.
getBegin(), diag::err_memptr_conv_via_virtual)
1796 << SrcClass << DestClass <<
QualType(VBase, 0) << OpRange;
1803 DestClass, SrcClass,
1805 diag::err_upcast_to_inaccessible_base)) {
1819 if (WasOverloadedFunction) {
1839 Kind = CK_DerivedToBaseMemberPointer;
1852 CastKind &Kind,
bool ListInitialization) {
1855 diag::err_bad_cast_incomplete) ||
1857 diag::err_allocation_of_abstract_type)) {
1871 Expr *SrcExprRaw = SrcExpr.
get();
1888 if (
Result.isInvalid()) {
1894 Kind = CK_ConstructorConversion;
1909 bool NeedToMaterializeTemporary =
false;
1923 if (isa<LValueReferenceType>(DestTypeTmp) && !SrcExpr.
get()->
isLValue()) {
1927 msg = diag::err_bad_cxx_cast_rvalue;
1931 if (isa<RValueReferenceType>(DestTypeTmp) && SrcExpr.
get()->
isPRValue()) {
1935 msg = diag::err_bad_cxx_cast_rvalue;
1941 NeedToMaterializeTemporary =
true;
1950 msg = diag::err_bad_cxx_cast_bitfield;
1970 msg = diag::err_bad_const_cast_dest;
1979 msg = diag::err_bad_const_cast_dest;
1992 if (NeedToMaterializeTemporary)
2010 unsigned DiagID = IsDereference ?
2011 diag::warn_pointer_indirection_from_incompatible_type :
2012 diag::warn_undefined_reinterpret_cast;
2018 if (IsDereference) {
2054 Diag(Range.getBegin(), DiagID) << SrcType << DestType << Range;
2063 if (SrcPtrTy->isObjCSelType()) {
2065 if (isa<PointerType>(DestType))
2069 diag::warn_cast_pointer_from_sel)
2084 const auto *SrcFTy =
2086 const auto *DstFTy =
2096 if (
auto *UO = dyn_cast<UnaryOperator>(Src))
2097 if (UO->getOpcode() == UO_AddrOf)
2099 auto *DRE = dyn_cast<DeclRefExpr>(Src);
2102 auto *FD = dyn_cast<FunctionDecl>(DRE->getDecl());
2111 FD->isVariadic(), FD->isCXXInstanceMember());
2112 if (DstCC == DefaultCC || SrcCC != DefaultCC)
2118 Self.
Diag(OpRange.
getBegin(), diag::warn_cast_calling_conv)
2119 << SrcCCName << DstCCName << OpRange;
2131 SourceLocation NameLoc = FD->getFirstDecl()->getNameInfo().getLoc();
2135 llvm::raw_svector_ostream OS(CCAttrText);
2138 OS <<
"__" << DstCCName;
2145 OS <<
"__attribute__((" << DstCCName <<
"))";
2146 AttrTokens.push_back(tok::kw___attribute);
2147 AttrTokens.push_back(tok::l_paren);
2148 AttrTokens.push_back(tok::l_paren);
2153 AttrTokens.push_back(tok::r_paren);
2154 AttrTokens.push_back(tok::r_paren);
2157 if (!AttrSpelling.empty())
2158 CCAttrText = AttrSpelling;
2160 Self.
Diag(NameLoc, diag::note_change_calling_conv_fixit)
2184 diag::warn_int_to_void_pointer_cast
2185 : diag::warn_int_to_pointer_cast;
2215 return Result.isUsable();
2223 bool IsLValueCast =
false;
2235 assert(FixedExpr.
isUsable() &&
"Invalid result fixing overloaded expr");
2236 SrcExpr = FixedExpr;
2244 msg = diag::err_bad_cxx_cast_rvalue;
2257 const char *inappropriate =
nullptr;
2262 msg = diag::err_bad_cxx_cast_bitfield;
2267 inappropriate =
"matrix element";
2270 case OK_ObjCSubscript: inappropriate =
"container subscripting expression";
2273 if (inappropriate) {
2274 Self.
Diag(OpRange.
getBegin(), diag::err_bad_reinterpret_cast_reference)
2275 << inappropriate << DestType
2285 IsLValueCast =
true;
2293 if (DestMemPtr && SrcMemPtr) {
2299 SrcMemPtr->isMemberFunctionPointer())
2312 msg = diag::err_bad_cxx_cast_member_pointer_size;
2326 assert(!IsLValueCast);
2327 Kind = CK_ReinterpretMemberPointer;
2339 msg = diag::err_bad_reinterpret_cast_small_int;
2342 Kind = CK_PointerToIntegral;
2350 if (srcIsVector || destIsVector) {
2377 if (Self.
LangOpts.OpenCL && !CStyle) {
2389 msg = diag::err_bad_cxx_cast_vector_to_scalar_different_size;
2390 else if (!srcIsVector)
2391 msg = diag::err_bad_cxx_cast_scalar_to_vector_different_size;
2393 msg = diag::err_bad_cxx_cast_vector_to_vector_different_size;
2398 if (SrcType == DestType) {
2422 if (!destIsPtr && !srcIsPtr) {
2429 assert(srcIsPtr &&
"One type must be a pointer");
2435 bool MicrosoftException =
2437 if (MicrosoftException) {
2439 ? diag::warn_void_pointer_to_int_cast
2440 : diag::warn_pointer_to_int_cast;
2443 msg = diag::err_bad_reinterpret_cast_small_int;
2447 Kind = CK_PointerToIntegral;
2452 assert(destIsPtr &&
"One type must be a pointer");
2458 Kind = CK_IntegralToPointer;
2462 if (!destIsPtr || !srcIsPtr) {
2482 Kind = CK_AddressSpaceConversion;
2489 }
else if (IsLValueCast) {
2490 Kind = CK_LValueBitCast;
2495 Kind = CK_AnyPointerToBlockPointerCast;
2506 return SuccessResult;
2520 return SuccessResult;
2531 diag::warn_cxx98_compat_cast_fn_obj : diag::ext_cast_fn_obj)
2533 return SuccessResult;
2540 diag::warn_cxx98_compat_cast_fn_obj : diag::ext_cast_fn_obj)
2542 return SuccessResult;
2555 diag::warn_bad_cxx_cast_nested_pointer_addr_space)
2568 return SuccessResult;
2591 auto SrcPointeeType = SrcPtrType->getPointeeType();
2592 auto DestPointeeType = DestPtrType->getPointeeType();
2593 if (!DestPointeeType.isAddressSpaceOverlapping(SrcPointeeType)) {
2594 msg = diag::err_bad_cxx_cast_addr_space_mismatch;
2597 auto SrcPointeeTypeWithoutAS =
2599 auto DestPointeeTypeWithoutAS =
2602 DestPointeeTypeWithoutAS)) {
2603 Kind = SrcPointeeType.getAddressSpace() == DestPointeeType.getAddressSpace()
2605 : CK_AddressSpaceConversion;
2612void CastOperation::checkAddressSpaceCast(
QualType SrcType,
QualType DestType) {
2624 if (Self.getLangOpts().OpenCL) {
2625 const Type *DestPtr, *SrcPtr;
2626 bool Nested =
false;
2627 unsigned DiagID = diag::err_typecheck_incompatible_address_space;
2628 DestPtr = Self.getASTContext().getCanonicalType(DestType.
getTypePtr()),
2629 SrcPtr = Self.getASTContext().getCanonicalType(SrcType.
getTypePtr());
2631 while (isa<PointerType>(DestPtr) && isa<PointerType>(SrcPtr)) {
2632 const PointerType *DestPPtr = cast<PointerType>(DestPtr);
2633 const PointerType *SrcPPtr = cast<PointerType>(SrcPtr);
2639 Self.Diag(OpRange.getBegin(), DiagID)
2641 << SrcExpr.get()->getSourceRange();
2650 DiagID = diag::ext_nested_pointer_qualifier_mismatch;
2656 bool SrcCompatXL = this->
getLangOpts().getAltivecSrcCompat() ==
2670 bool SrcCompatGCC = this->
getLangOpts().getAltivecSrcCompat() ==
2672 if (this->
getLangOpts().AltiVec && SrcCompatGCC) {
2674 diag::err_invalid_conversion_between_vector_and_integer)
2675 << VecTy << SrcTy << R;
2681void CastOperation::CheckCXXCStyleCast(
bool FunctionalStyle,
2682 bool ListInitialization) {
2683 assert(Self.getLangOpts().CPlusPlus);
2686 if (isPlaceholder()) {
2688 if (claimPlaceholder(BuiltinType::UnknownAny)) {
2689 SrcExpr = Self.checkUnknownAnyCast(DestRange, DestType,
2690 SrcExpr.get(), Kind,
2691 ValueKind, BasePath);
2695 checkNonOverloadPlaceholders();
2696 if (SrcExpr.isInvalid())
2706 if (claimPlaceholder(BuiltinType::Overload)) {
2707 Self.ResolveAndFixSingleFunctionTemplateSpecialization(
2709 true, DestRange, DestType,
2710 diag::err_bad_cstyle_cast_overload);
2711 if (SrcExpr.isInvalid())
2715 SrcExpr = Self.IgnoredValueConversions(SrcExpr.get());
2720 if (DestType->
isDependentType() || SrcExpr.get()->isTypeDependent() ||
2721 SrcExpr.get()->isValueDependent()) {
2722 assert(Kind == CK_Dependent);
2727 !isPlaceholder(BuiltinType::Overload)) {
2728 SrcExpr = Self.DefaultFunctionArrayLvalueConversion(SrcExpr.get());
2729 if (SrcExpr.isInvalid())
2735 if (Self.CheckAltivecInitFromScalar(OpRange, DestType,
2736 SrcExpr.get()->getType())) {
2740 if (Self.ShouldSplatAltivecScalarInCast(vecTy) &&
2741 (SrcExpr.get()->getType()->isIntegerType() ||
2742 SrcExpr.get()->getType()->isFloatingType())) {
2743 Kind = CK_VectorSplat;
2744 SrcExpr = Self.prepareVectorSplat(DestType, SrcExpr.get());
2761 unsigned msg = diag::err_bad_cxx_cast_generic;
2764 if (SrcExpr.isInvalid())
2774 if (SrcExpr.isInvalid())
2780 tcr =
TryStaticCast(Self, SrcExpr, DestType, CCK, OpRange, msg, Kind,
2781 BasePath, ListInitialization);
2782 if (SrcExpr.isInvalid())
2788 OpRange, msg, Kind);
2789 if (SrcExpr.isInvalid())
2795 if (Self.getLangOpts().allowsNonTrivialObjCLifetimeQualifiers() &&
2797 checkObjCConversion(CCK);
2800 if (SrcExpr.get()->getType() == Self.Context.OverloadTy) {
2802 FunctionDecl *Fn = Self.ResolveAddressOfOverloadedFunction(SrcExpr.get(),
2811 Self.Diag(OpRange.getBegin(), diag::err_bad_cstyle_cast_overload)
2812 << OE->
getName() << DestType << OpRange
2814 Self.NoteAllOverloadCandidates(SrcExpr.get());
2818 OpRange, SrcExpr.get(), DestType, ListInitialization);
2823 if (Kind == CK_BitCast)
2827 Self.Diag(OpRange.getBegin(), DiagID)
2828 << SrcExpr.get()->getType() << DestType << OpRange;
2844 if (!isa<CallExpr>(SrcExpr.
get()))
2869 diag::warn_bad_function_cast)
2874void CastOperation::CheckCStyleCast() {
2875 assert(!Self.getLangOpts().CPlusPlus);
2878 if (claimPlaceholder(BuiltinType::UnknownAny)) {
2879 SrcExpr = Self.checkUnknownAnyCast(DestRange, DestType,
2880 SrcExpr.get(), Kind,
2881 ValueKind, BasePath);
2889 SrcExpr = Self.IgnoredValueConversions(SrcExpr.get());
2890 if (SrcExpr.isInvalid())
2899 if (Self.getASTContext().isDependenceAllowed() &&
2901 SrcExpr.get()->isValueDependent())) {
2902 assert((DestType->
containsErrors() || SrcExpr.get()->containsErrors() ||
2903 SrcExpr.get()->containsErrors()) &&
2904 "should only occur in error-recovery path.");
2905 assert(Kind == CK_Dependent);
2910 if (SrcExpr.get()->getType() == Self.Context.OverloadTy) {
2912 if (
FunctionDecl *FD = Self.ResolveAddressOfOverloadedFunction(
2913 SrcExpr.get(), DestType,
true, DAP))
2914 SrcExpr = Self.FixOverloadedFunctionReference(SrcExpr.get(), DAP, FD);
2917 assert(SrcExpr.isUsable());
2919 SrcExpr = Self.DefaultFunctionArrayLvalueConversion(SrcExpr.get());
2920 if (SrcExpr.isInvalid())
2922 QualType SrcType = SrcExpr.get()->getType();
2926 checkAddressSpaceCast(SrcType, DestType);
2927 if (SrcExpr.isInvalid())
2930 if (Self.RequireCompleteType(OpRange.getBegin(), DestType,
2931 diag::err_typecheck_cast_to_incomplete)) {
2938 Self.Context.hasSameUnqualifiedType(DestType, SrcType)) {
2945 Self.isValidSveBitcast(SrcType, DestType)) {
2952 Self.isValidRVVBitcast(SrcType, DestType)) {
2961 if (DestRecordTy && Self.Context.hasSameUnqualifiedType(DestType, SrcType)){
2963 Self.Diag(OpRange.getBegin(), diag::ext_typecheck_cast_nonscalar)
2964 << DestType << SrcExpr.get()->getSourceRange();
2973 Self.Diag(OpRange.getBegin(), diag::ext_typecheck_cast_to_union)
2978 Self.Diag(OpRange.getBegin(), diag::err_typecheck_cast_to_union_no_type)
2979 << SrcType << SrcExpr.get()->getSourceRange();
2986 if (Self.getLangOpts().OpenCL && DestType->
isEventT()) {
2988 if (SrcExpr.get()->EvaluateAsInt(
Result, Self.Context)) {
2989 llvm::APSInt CastInt =
Result.Val.getInt();
2991 Kind = CK_ZeroToOCLOpaqueType;
2994 Self.Diag(OpRange.getBegin(),
2995 diag::err_opencl_cast_non_zero_to_event_t)
2996 <<
toString(CastInt, 10) << SrcExpr.get()->getSourceRange();
3003 Self.Diag(OpRange.getBegin(), diag::err_typecheck_cond_expect_scalar)
3004 << DestType << SrcExpr.get()->getSourceRange();
3014 Self.Diag(SrcExpr.get()->getExprLoc(),
3015 diag::err_typecheck_expect_scalar_operand)
3016 << SrcType << SrcExpr.get()->getSourceRange();
3031 Self.Diag(SrcExpr.get()->getExprLoc(), diag::err_nullptr_cast)
3042 Self.CurFPFeatureOverrides());
3046 Self.Diag(SrcExpr.get()->getExprLoc(), diag::err_nullptr_cast)
3053 SrcExpr = Self.CheckExtVectorCast(OpRange, DestType, SrcExpr.get(), Kind);
3058 if (Self.CheckMatrixCast(OpRange, DestType, SrcType, Kind))
3064 if (Self.CheckAltivecInitFromScalar(OpRange, DestType, SrcType)) {
3068 if (Self.ShouldSplatAltivecScalarInCast(DestVecTy) &&
3070 Kind = CK_VectorSplat;
3071 SrcExpr = Self.prepareVectorSplat(DestType, SrcExpr.get());
3072 }
else if (Self.CheckVectorCast(OpRange, DestType, SrcType, Kind)) {
3079 if (Self.CheckVectorCast(OpRange, SrcType, DestType, Kind))
3089 if (isa<ObjCSelectorExpr>(SrcExpr.get())) {
3090 Self.Diag(SrcExpr.get()->getExprLoc(), diag::err_cast_selector_expr);
3099 Self.Diag(SrcExpr.get()->getExprLoc(),
3100 diag::err_cast_pointer_from_non_pointer_int)
3101 << SrcType << SrcExpr.get()->getSourceRange();
3110 Self.Diag(SrcExpr.get()->getBeginLoc(),
3111 diag::err_cast_pointer_to_non_pointer_int)
3112 << DestType << SrcExpr.get()->getSourceRange();
3117 if ((Self.Context.getTypeSize(SrcType) >
3118 Self.Context.getTypeSize(DestType)) &&
3128 : diag::warn_void_pointer_to_int_cast;
3130 Diag = diag::warn_pointer_to_enum_cast;
3132 Diag = diag::warn_pointer_to_int_cast;
3133 Self.Diag(OpRange.getBegin(),
Diag) << SrcType << DestType << OpRange;
3137 if (Self.getLangOpts().OpenCL && !Self.getOpenCLOptions().isAvailableOption(
3138 "cl_khr_fp16", Self.getLangOpts())) {
3140 Self.Diag(SrcExpr.get()->getBeginLoc(), diag::err_opencl_cast_to_half)
3141 << DestType << SrcExpr.get()->getSourceRange();
3148 if (Self.getLangOpts().allowsNonTrivialObjCLifetimeQualifiers()) {
3150 if (SrcExpr.isInvalid())
3154 if (Self.getLangOpts().ObjCAutoRefCount && CastPtr) {
3157 Qualifiers ExprQuals = ExprPtr->getPointeeType().getQualifiers();
3159 ExprPtr->getPointeeType()->isObjCLifetimeType() &&
3161 Self.Diag(SrcExpr.get()->getBeginLoc(),
3162 diag::err_typecheck_incompatible_ownership)
3164 << SrcExpr.get()->getSourceRange();
3169 else if (!Self.CheckObjCARCUnavailableWeakConversion(DestType, SrcType)) {
3170 Self.Diag(SrcExpr.get()->getBeginLoc(),
3171 diag::err_arc_convesion_of_weak_unavailable)
3172 << 1 << SrcType << DestType << SrcExpr.get()->getSourceRange();
3179 Self.Diag(OpRange.getBegin(), DiagID) << SrcType << DestType << OpRange;
3181 if (isa<PointerType>(SrcType) && isa<PointerType>(DestType)) {
3188 if (SrcRD && DestRD && SrcRD->
hasAttr<RandomizeLayoutAttr>() &&
3191 Self.Diag(OpRange.getBegin(), diag::err_cast_from_randomized_struct)
3192 << SrcType << DestType;
3201 Kind = Self.PrepareScalarCast(SrcExpr, DestType);
3202 if (SrcExpr.isInvalid())
3205 if (Kind == CK_BitCast)
3209void CastOperation::CheckBuiltinBitCast() {
3210 QualType SrcType = SrcExpr.get()->getType();
3212 if (Self.RequireCompleteType(OpRange.getBegin(), DestType,
3213 diag::err_typecheck_cast_to_incomplete) ||
3214 Self.RequireCompleteType(OpRange.getBegin(), SrcType,
3215 diag::err_incomplete_type)) {
3220 if (SrcExpr.get()->isPRValue())
3221 SrcExpr = Self.CreateMaterializeTemporaryExpr(SrcType, SrcExpr.get(),
3224 CharUnits DestSize = Self.Context.getTypeSizeInChars(DestType);
3225 CharUnits SourceSize = Self.Context.getTypeSizeInChars(SrcType);
3226 if (DestSize != SourceSize) {
3227 Self.Diag(OpRange.getBegin(), diag::err_bit_cast_type_size_mismatch)
3234 Self.Diag(OpRange.getBegin(), diag::err_bit_cast_non_trivially_copyable)
3241 Self.Diag(OpRange.getBegin(), diag::err_bit_cast_non_trivially_copyable)
3247 Kind = CK_LValueToRValueBitCast;
3262 QualType TheOffendingSrcType, TheOffendingDestType;
3265 &TheOffendingSrcType, &TheOffendingDestType,
3266 &CastAwayQualifiers) !=
3267 CastAwayConstnessKind::CACK_Similar)
3271 int qualifiers = -1;
3274 }
else if (CastAwayQualifiers.
hasConst()) {
3280 if (qualifiers == -1)
3282 << SrcType << DestType;
3285 << TheOffendingSrcType << TheOffendingDestType << qualifiers;
3297 Op.CheckCXXCStyleCast(
false,
3300 Op.CheckCStyleCast();
3303 if (Op.SrcExpr.isInvalid())
3310 Context, Op.ResultType, Op.ValueKind, Op.Kind, Op.SrcExpr.get(),
3319 assert(LPLoc.
isValid() &&
"List-initialization shouldn't get here.");
3324 Op.CheckCXXCStyleCast(
true,
false);
3325 if (Op.SrcExpr.isInvalid())
3328 auto *SubExpr = Op.SrcExpr.get();
3329 if (
auto *BindExpr = dyn_cast<CXXBindTemporaryExpr>(SubExpr))
3330 SubExpr = BindExpr->getSubExpr();
3331 if (
auto *ConstructExpr = dyn_cast<CXXConstructExpr>(SubExpr))
3332 ConstructExpr->setParenOrBraceRange(
SourceRange(LPLoc, RPLoc));
3335 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 ...
CanQualType ARCUnbridgedCastTy
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 ...
QualType getMemberPointerType(QualType T, const Type *Cls) const
Return the uniqued reference to the type for a member pointer to the specified type in the specified ...
const ASTRecordLayout & getASTRecordLayout(const RecordDecl *D) const
Get or compute information about the layout of the specified record (struct/union/class) D,...
CanQualType getCanonicalType(QualType T) const
Return the canonical (structural) type corresponding to the specified potentially non-canonical type ...
bool hasSameType(QualType T1, QualType T2) const
Determine whether the given types T1 and T2 are equivalent.
CallingConv getDefaultCallingConvention(bool IsVariadic, bool IsCXXMethod, bool IsBuiltin=false) const
Retrieves the default calling convention for the current target.
QualType getPointerType(QualType T) const
Return the uniqued reference to the type for a pointer to the specified type.
QualType getTypeDeclType(const TypeDecl *Decl, const TypeDecl *PrevDecl=nullptr) const
Return the unique reference to the type for the specified type declaration.
const LangOptions & getLangOpts() const
QualType removeAddrSpaceQualType(QualType T) const
Remove any existing address space on the type and returns the type with qualifiers intact (or that's ...
QualType getUnqualifiedArrayType(QualType T, Qualifiers &Quals)
Return this type as a completely-unqualified array type, capturing the qualifiers in Quals.
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]).
const TargetInfo & getTargetInfo() const
bool hasCvrSimilarType(QualType T1, QualType T2)
Determine if two types are similar, ignoring only CVR qualifiers.
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.
bool allowsNonTrivialObjCLifetimeQualifiers() const
True if any ObjC types may have non-trivial lifetime qualifiers.
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 getCanonicalType() 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.
bool isValidRVVBitcast(QualType srcType, QualType destType)
Are the two types RVV-bitcast-compatible types? I.e.
void BuildBasePathArray(const CXXBasePaths &Paths, CXXCastPath &BasePath)
bool areVectorTypesSameSize(QualType srcType, QualType destType)
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)
Preprocessor & getPreprocessor() const
ExprResult BuildBuiltinBitCastExpr(SourceLocation KWLoc, TypeSourceInfo *TSI, Expr *Operand, SourceLocation RParenLoc)
FPOptionsOverride CurFPFeatureOverrides()
bool isValidSveBitcast(QualType srcType, QualType destType)
Are the two types SVE-bitcast-compatible types? I.e.
bool CheckMatrixCast(SourceRange R, QualType DestTy, QualType SrcTy, CastKind &Kind)
bool ShouldSplatAltivecScalarInCast(const VectorType *VecTy)
FunctionDecl * ResolveAddressOfOverloadedFunction(Expr *AddressOfExpr, QualType TargetType, bool Complain, DeclAccessPair &Found, bool *pHadMultipleCandidates=nullptr)
ResolveAddressOfOverloadedFunction - Try to resolve the address of an overloaded function (C++ [over....
ASTContext & getASTContext() const
std::string getAmbiguousPathsDisplayString(CXXBasePaths &Paths)
Builds a string representing ambiguous paths from a specific derived class to different subobjects of...
CastKind PrepareCastToObjCObjectPointer(ExprResult &E)
Prepare a conversion of the given expression to an ObjC object pointer type.
ExprResult ActOnBuiltinBitCastExpr(SourceLocation KWLoc, Declarator &Dcl, ExprResult Operand, SourceLocation RParenLoc)
const LangOptions & getLangOpts() const
void CheckCastAlign(Expr *Op, QualType T, SourceRange TRange)
CheckCastAlign - Implements -Wcast-align, which warns when a pointer cast increases the alignment req...
AccessResult CheckBaseClassAccess(SourceLocation AccessLoc, QualType Base, QualType Derived, const CXXBasePath &Path, unsigned DiagID, bool ForceCheck=false, bool ForceUnprivileged=false)
Checks access for a hierarchy conversion.
bool RequireNonAbstractType(SourceLocation Loc, QualType T, TypeDiagnoser &Diagnoser)
void CheckExtraCXXDefaultArguments(Declarator &D)
CheckExtraCXXDefaultArguments - Check for any extra default arguments in the declarator,...
const LangOptions & LangOpts
ExprResult BuildCStyleCastExpr(SourceLocation LParenLoc, TypeSourceInfo *Ty, SourceLocation RParenLoc, Expr *Op)
bool CheckTollFreeBridgeStaticCast(QualType castType, Expr *castExpr, CastKind &Kind)
MaterializeTemporaryExpr * CreateMaterializeTemporaryExpr(QualType T, Expr *Temporary, bool BoundToLvalueReference)
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.
ExprResult CheckPlaceholderExpr(Expr *E)
Check for operands with placeholder types and complain if found.
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...
bool resolveAndFixAddressOfSingleOverloadCandidate(ExprResult &SrcExpr, bool DoFunctionPointerConversion=false)
Given an overloaded function, tries to turn it into a non-overloaded function reference using resolve...
ARCConversionResult CheckObjCConversion(SourceRange castRange, QualType castType, Expr *&op, CheckedConversionKind CCK, bool Diagnose=true, bool DiagnoseCFAudited=false, BinaryOperatorKind Opc=BO_PtrMemD)
Checks for invalid conversions and casts between retainable pointers and other pointer kinds for ARC ...
bool isCompleteType(SourceLocation Loc, QualType T, CompleteTypeKind Kind=CompleteTypeKind::Default)
void CheckCompatibleReinterpretCast(QualType SrcType, QualType DestType, bool IsDereference, SourceRange Range)
TypeSourceInfo * GetTypeForDeclaratorCast(Declarator &D, QualType FromTy)
bool RequireCompleteType(SourceLocation Loc, QualType T, CompleteTypeKind Kind, TypeDiagnoser &Diagnoser)
Ensure that the type T is a complete type.
ReferenceCompareResult CompareReferenceRelationship(SourceLocation Loc, QualType T1, QualType T2, ReferenceConversions *Conv=nullptr)
CompareReferenceRelationship - Compare the two types T1 and T2 to determine whether they are referenc...
PartialDiagnostic PDiag(unsigned DiagID=0)
Build a partial diagnostic.
DiagnosticsEngine & Diags
bool areLaxCompatibleVectorTypes(QualType srcType, QualType destType)
Are the two types lax-compatible vector types? That is, given that one of them is a vector,...
bool ResolveAndFixSingleFunctionTemplateSpecialization(ExprResult &SrcExpr, bool DoFunctionPointerConversion=false, bool Complain=false, SourceRange OpRangeForComplaining=SourceRange(), QualType DestTypeForComplaining=QualType(), unsigned DiagIDForComplaining=0)
Expr * FixOverloadedFunctionReference(Expr *E, DeclAccessPair FoundDecl, FunctionDecl *Fn)
FixOverloadedFunctionReference - E is an expression that refers to a C++ overloaded function (possibl...
ExprResult BuildCXXNamedCast(SourceLocation OpLoc, tok::TokenKind Kind, TypeSourceInfo *Ty, Expr *E, SourceRange AngleBrackets, SourceRange Parens)
bool IsDerivedFrom(SourceLocation Loc, QualType Derived, QualType Base)
Determine whether the type Derived is a C++ class that is derived from the type Base.
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.
SourceRange getSourceRange() const override LLVM_READONLY
Source range that this declaration covers.
bool isMicrosoft() const
Is this ABI an MSVC-compatible ABI?
TargetCXXABI getCXXABI() const
Get the C++ ABI currently in use.
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 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.
@ AltiVecBool
is AltiVec 'vector bool ...'
@ AltiVecPixel
is AltiVec 'vector Pixel'
@ AltiVecVector
is AltiVec vector
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.
@ 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.
@ None
The alignment was not explicit in code.
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...