38#include "llvm/ADT/DenseSet.h"
39#include "llvm/ADT/STLExtras.h"
40#include "llvm/ADT/STLForwardCompat.h"
41#include "llvm/ADT/ScopeExit.h"
42#include "llvm/ADT/SmallPtrSet.h"
43#include "llvm/ADT/SmallVector.h"
57 return P->hasAttr<PassObjectSizeAttr>();
78 if (HadMultipleCandidates)
89 CK_FunctionToPointerDecay);
93 bool InOverloadResolution,
96 bool AllowObjCWritebackConversion);
100 bool InOverloadResolution,
108 bool AllowObjCConversionOnExplicit);
169 return Rank[(int)Kind];
194 static const char *
const Name[] = {
198 "Function-to-pointer",
199 "Function pointer conversion",
201 "Integral promotion",
202 "Floating point promotion",
204 "Integral conversion",
205 "Floating conversion",
206 "Complex conversion",
207 "Floating-integral conversion",
208 "Pointer conversion",
209 "Pointer-to-member conversion",
210 "Boolean conversion",
211 "Compatible-types conversion",
212 "Derived-to-base conversion",
214 "SVE Vector conversion",
215 "RVV Vector conversion",
217 "Complex-real conversion",
218 "Block Pointer conversion",
219 "Transparent Union Conversion",
220 "Writeback conversion",
221 "OpenCL Zero Event Conversion",
222 "OpenCL Zero Queue Conversion",
223 "C specific type conversion",
224 "Incompatible pointer conversion",
225 "Fixed point conversion",
226 "HLSL vector truncation",
227 "Non-decaying array conversion",
304 FromType = Context.getArrayDecayedType(FromType);
316 const Expr *Converted) {
319 if (
auto *EWC = dyn_cast<ExprWithCleanups>(Converted)) {
326 while (
auto *ICE = dyn_cast<ImplicitCastExpr>(Converted)) {
327 switch (ICE->getCastKind()) {
329 case CK_IntegralCast:
330 case CK_IntegralToBoolean:
331 case CK_IntegralToFloating:
332 case CK_BooleanToSignedIntegral:
333 case CK_FloatingToIntegral:
334 case CK_FloatingToBoolean:
335 case CK_FloatingCast:
336 Converted = ICE->getSubExpr();
360 QualType &ConstantType,
bool IgnoreFloatToIntegralConversion)
const {
362 "narrowing check outside C++");
373 ToType = ED->getIntegerType();
379 goto FloatingIntegralConversion;
381 goto IntegralConversion;
392 FloatingIntegralConversion:
397 if (IgnoreFloatToIntegralConversion)
400 assert(
Initializer &&
"Unknown conversion expression");
406 if (std::optional<llvm::APSInt> IntConstantValue =
410 Result.convertFromAPInt(*IntConstantValue, IntConstantValue->isSigned(),
411 llvm::APFloat::rmNearestTiesToEven);
413 llvm::APSInt ConvertedValue = *IntConstantValue;
415 llvm::APFloat::opStatus Status =
Result.convertToInteger(
416 ConvertedValue, llvm::APFloat::rmTowardZero, &ignored);
419 if (Status == llvm::APFloat::opInvalidOp ||
420 *IntConstantValue != ConvertedValue) {
421 ConstantValue =
APValue(*IntConstantValue);
448 Initializer->isCXX11ConstantExpr(Ctx, &ConstantValue)) {
451 ConstantValue = R.
Val;
452 assert(ConstantValue.
isFloat());
453 llvm::APFloat FloatVal = ConstantValue.
getFloat();
456 llvm::APFloat Converted = FloatVal;
457 llvm::APFloat::opStatus ConvertStatus =
459 llvm::APFloat::rmNearestTiesToEven, &ignored);
461 llvm::APFloat::rmNearestTiesToEven, &ignored);
463 if (FloatVal.isNaN() && Converted.isNaN() &&
464 !FloatVal.isSignaling() && !Converted.isSignaling()) {
470 if (!Converted.bitwiseIsEqual(FloatVal)) {
477 if (ConvertStatus & llvm::APFloat::opOverflow) {
499 IntegralConversion: {
507 constexpr auto CanRepresentAll = [](
bool FromSigned,
unsigned FromWidth,
508 bool ToSigned,
unsigned ToWidth) {
509 return (FromWidth < ToWidth + (FromSigned == ToSigned)) &&
510 !(FromSigned && !ToSigned);
513 if (CanRepresentAll(FromSigned, FromWidth, ToSigned, ToWidth))
519 bool DependentBitField =
false;
521 if (BitField->getBitWidth()->isValueDependent())
522 DependentBitField =
true;
523 else if (
unsigned BitFieldWidth = BitField->getBitWidthValue();
524 BitFieldWidth < FromWidth) {
525 if (CanRepresentAll(FromSigned, BitFieldWidth, ToSigned, ToWidth))
529 FromWidth = BitFieldWidth;
537 std::optional<llvm::APSInt> OptInitializerValue =
539 if (!OptInitializerValue) {
543 if (DependentBitField && !(FromSigned && !ToSigned))
549 llvm::APSInt &InitializerValue = *OptInitializerValue;
550 bool Narrowing =
false;
551 if (FromWidth < ToWidth) {
554 if (InitializerValue.isSigned() && InitializerValue.isNegative())
560 InitializerValue.extend(InitializerValue.getBitWidth() + 1);
562 llvm::APSInt ConvertedValue = InitializerValue;
563 ConvertedValue = ConvertedValue.trunc(ToWidth);
564 ConvertedValue.setIsSigned(ToSigned);
565 ConvertedValue = ConvertedValue.extend(InitializerValue.getBitWidth());
566 ConvertedValue.setIsSigned(InitializerValue.isSigned());
568 if (ConvertedValue != InitializerValue)
573 ConstantValue =
APValue(InitializerValue);
589 ConstantValue = R.
Val;
590 assert(ConstantValue.
isFloat());
591 llvm::APFloat FloatVal = ConstantValue.
getFloat();
596 if (FloatVal.isNaN() && FloatVal.isSignaling()) {
612 raw_ostream &OS = llvm::errs();
613 bool PrintedSomething =
false;
616 PrintedSomething =
true;
620 if (PrintedSomething) {
626 OS <<
" (by copy constructor)";
628 OS <<
" (direct reference binding)";
630 OS <<
" (reference binding)";
632 PrintedSomething =
true;
636 if (PrintedSomething) {
640 PrintedSomething =
true;
643 if (!PrintedSomething) {
644 OS <<
"No conversions required";
651 raw_ostream &OS = llvm::errs();
659 OS <<
"aggregate initialization";
669 raw_ostream &OS = llvm::errs();
671 OS <<
"Worst list element conversion: ";
672 switch (ConversionKind) {
674 OS <<
"Standard conversion: ";
678 OS <<
"User-defined conversion: ";
682 OS <<
"Ellipsis conversion";
685 OS <<
"Ambiguous conversion";
688 OS <<
"Bad conversion";
713 struct DFIArguments {
719 struct DFIParamWithArguments : DFIArguments {
724 struct DFIDeducedMismatchArgs : DFIArguments {
725 TemplateArgumentList *TemplateArgs;
726 unsigned CallArgIndex;
731 TemplateArgumentList *TemplateArgs;
732 ConstraintSatisfaction Satisfaction;
743 Result.Result =
static_cast<unsigned>(TDK);
744 Result.HasDiagnostic =
false;
763 auto *Saved =
new (Context) DFIDeducedMismatchArgs;
774 DFIArguments *Saved =
new (Context) DFIArguments;
786 DFIParamWithArguments *Saved =
new (Context) DFIParamWithArguments;
787 Saved->Param = Info.
Param;
800 Result.HasDiagnostic =
true;
805 CNSInfo *Saved =
new (Context) CNSInfo;
815 llvm_unreachable(
"not a deduction failure");
848 Diag->~PartialDiagnosticAt();
855 static_cast<CNSInfo *
>(
Data)->Satisfaction.~ConstraintSatisfaction();
858 Diag->~PartialDiagnosticAt();
894 return TemplateParameter::getFromOpaqueValue(
Data);
899 return static_cast<DFIParamWithArguments*
>(
Data)->Param;
929 return static_cast<DFIDeducedMismatchArgs*
>(
Data)->TemplateArgs;
935 return static_cast<CNSInfo*
>(
Data)->TemplateArgs;
967 return &
static_cast<DFIArguments*
>(
Data)->FirstArg;
999 return &
static_cast<DFIArguments*
>(
Data)->SecondArg;
1014 return static_cast<DFIDeducedMismatchArgs*
>(
Data)->CallArgIndex;
1017 return std::nullopt;
1030 for (
unsigned I = 0; I <
X->getNumParams(); ++I)
1034 if (
auto *FTX =
X->getDescribedFunctionTemplate()) {
1039 FTY->getTemplateParameters()))
1048 OverloadedOperatorKind::OO_EqualEqual);
1060 OverloadedOperatorKind::OO_ExclaimEqual);
1078 auto *NotEqFD = Op->getAsFunction();
1079 if (
auto *UD = dyn_cast<UsingShadowDecl>(Op))
1080 NotEqFD = UD->getUnderlyingDecl()->getAsFunction();
1093 return Op == OO_EqualEqual || Op == OO_Spaceship;
1101 if (Op == OverloadedOperatorKind::OO_EqualEqual) {
1102 assert(OriginalArgs.size() == 2);
1104 S,
OpLoc, OriginalArgs[1], FD))
1115void OverloadCandidateSet::destroyCandidates() {
1116 for (
iterator i = Candidates.begin(), e = Candidates.end(); i != e; ++i) {
1117 for (
auto &
C : i->Conversions)
1118 C.~ImplicitConversionSequence();
1120 i->DeductionFailure.Destroy();
1125 destroyCandidates();
1126 SlabAllocator.Reset();
1127 NumInlineBytesUsed = 0;
1131 FirstDeferredCandidate =
nullptr;
1132 DeferredCandidatesCount = 0;
1133 HasDeferredTemplateConstructors =
false;
1134 ResolutionByPerfectCandidateIsDisabled =
false;
1138 class UnbridgedCastsSet {
1148 Entry entry = { &E, E };
1149 Entries.push_back(entry);
1154 for (SmallVectorImpl<Entry>::iterator
1155 i = Entries.begin(), e = Entries.end(); i != e; ++i)
1156 *i->Addr = i->Saved;
1170 UnbridgedCastsSet *unbridgedCasts =
nullptr) {
1174 if (placeholder->getKind() == BuiltinType::Overload)
return false;
1178 if (placeholder->getKind() == BuiltinType::ARCUnbridgedCast &&
1180 unbridgedCasts->save(S, E);
1200 UnbridgedCastsSet &unbridged) {
1201 for (
unsigned i = 0, e = Args.size(); i != e; ++i)
1210 bool NewIsUsingDecl) {
1215 bool OldIsUsingDecl =
false;
1217 OldIsUsingDecl =
true;
1221 if (NewIsUsingDecl)
continue;
1228 if ((OldIsUsingDecl || NewIsUsingDecl) && !
isVisible(*I))
1236 bool UseMemberUsingDeclRules =
1237 (OldIsUsingDecl || NewIsUsingDecl) &&
CurContext->isRecord() &&
1238 !
New->getFriendObjectKind();
1242 if (UseMemberUsingDeclRules && OldIsUsingDecl) {
1248 !shouldLinkPossiblyHiddenDecl(*I,
New))
1267 }
else if (
auto *UUD = dyn_cast<UnresolvedUsingValueDecl>(OldD)) {
1274 if (UUD->getQualifier().isDependent() && !UUD->isCXXClassMember()) {
1302 if (
New->getFriendObjectKind() &&
New->getQualifier() &&
1303 !
New->getDescribedFunctionTemplate() &&
1304 !
New->getDependentSpecializationInfo() &&
1305 !
New->getType()->isDependentType()) {
1310 New->setInvalidDecl();
1322 assert(D &&
"function decl should not be null");
1323 if (
auto *A = D->
getAttr<AttrT>())
1324 return !A->isImplicit();
1330 bool UseMemberUsingDeclRules,
1331 bool ConsiderCudaAttrs,
1332 bool UseOverrideRules =
false) {
1338 if (
New->isMSVCRTEntryPoint())
1349 if ((OldTemplate ==
nullptr) != (NewTemplate ==
nullptr))
1372 if (OldQType != NewQType && OldType->isVariadic() != NewType->isVariadic())
1376 if ((
New->isMemberLikeConstrainedFriend() ||
1387 OldDecl = OldTemplate;
1388 NewDecl = NewTemplate;
1406 bool ConstraintsInTemplateHead =
1417 if (UseMemberUsingDeclRules && ConstraintsInTemplateHead &&
1418 !SameTemplateParameterList)
1420 if (!UseMemberUsingDeclRules &&
1421 (!SameTemplateParameterList || !SameReturnType))
1425 const auto *OldMethod = dyn_cast<CXXMethodDecl>(Old);
1426 const auto *NewMethod = dyn_cast<CXXMethodDecl>(
New);
1428 int OldParamsOffset = 0;
1429 int NewParamsOffset = 0;
1437 if (ThisType.isConstQualified())
1457 BS.
Quals = NormalizeQualifiers(OldMethod, BS.
Quals);
1458 DS.Quals = NormalizeQualifiers(NewMethod, DS.Quals);
1460 if (OldMethod->isExplicitObjectMemberFunction()) {
1462 DS.Quals.removeVolatile();
1465 return BS.
Quals == DS.Quals;
1469 auto BS =
Base.getNonReferenceType().getCanonicalType().split();
1470 auto DS = D.getNonReferenceType().getCanonicalType().split();
1472 if (!AreQualifiersEqual(BS, DS))
1475 if (OldMethod->isImplicitObjectMemberFunction() &&
1476 OldMethod->getParent() != NewMethod->getParent()) {
1488 if (
Base->isLValueReferenceType())
1489 return D->isLValueReferenceType();
1490 return Base->isRValueReferenceType() == D->isRValueReferenceType();
1495 auto DiagnoseInconsistentRefQualifiers = [&]() {
1496 if (SemaRef.
LangOpts.CPlusPlus23 && !UseOverrideRules)
1498 if (OldMethod->getRefQualifier() == NewMethod->getRefQualifier())
1500 if (OldMethod->isExplicitObjectMemberFunction() ||
1501 NewMethod->isExplicitObjectMemberFunction())
1503 if (!UseMemberUsingDeclRules && (OldMethod->getRefQualifier() ==
RQ_None ||
1504 NewMethod->getRefQualifier() ==
RQ_None)) {
1505 SemaRef.
Diag(NewMethod->getLocation(), diag::err_ref_qualifier_overload)
1506 << NewMethod->getRefQualifier() << OldMethod->getRefQualifier();
1507 SemaRef.
Diag(OldMethod->getLocation(), diag::note_previous_declaration);
1513 if (OldMethod && OldMethod->isExplicitObjectMemberFunction())
1515 if (NewMethod && NewMethod->isExplicitObjectMemberFunction())
1518 if (OldType->getNumParams() - OldParamsOffset !=
1519 NewType->getNumParams() - NewParamsOffset ||
1521 {OldType->param_type_begin() + OldParamsOffset,
1522 OldType->param_type_end()},
1523 {NewType->param_type_begin() + NewParamsOffset,
1524 NewType->param_type_end()},
1529 if (OldMethod && NewMethod && !OldMethod->isStatic() &&
1530 !NewMethod->isStatic()) {
1531 bool HaveCorrespondingObjectParameters = [&](
const CXXMethodDecl *Old,
1533 auto NewObjectType =
New->getFunctionObjectParameterReferenceType();
1537 return F->getRefQualifier() ==
RQ_None &&
1538 !F->isExplicitObjectMemberFunction();
1541 if (IsImplicitWithNoRefQual(Old) != IsImplicitWithNoRefQual(
New) &&
1542 CompareType(OldObjectType.getNonReferenceType(),
1543 NewObjectType.getNonReferenceType()))
1545 return CompareType(OldObjectType, NewObjectType);
1546 }(OldMethod, NewMethod);
1548 if (!HaveCorrespondingObjectParameters) {
1549 if (DiagnoseInconsistentRefQualifiers())
1554 if (!UseOverrideRules || (!NewMethod->isExplicitObjectMemberFunction() &&
1555 !OldMethod->isExplicitObjectMemberFunction()))
1560 if (!UseOverrideRules &&
1564 if (!NewRC != !OldRC)
1574 if (NewMethod && OldMethod && OldMethod->isImplicitObjectMemberFunction() &&
1575 NewMethod->isImplicitObjectMemberFunction()) {
1576 if (DiagnoseInconsistentRefQualifiers())
1590 NewI =
New->specific_attr_begin<EnableIfAttr>(),
1591 NewE =
New->specific_attr_end<EnableIfAttr>(),
1594 NewI != NewE || OldI != OldE; ++NewI, ++OldI) {
1595 if (NewI == NewE || OldI == OldE)
1597 llvm::FoldingSetNodeID NewID, OldID;
1598 NewI->getCond()->Profile(NewID, SemaRef.
Context,
true);
1599 OldI->getCond()->Profile(OldID, SemaRef.
Context,
true);
1605 if (SemaRef.
getLangOpts().CUDA && ConsiderCudaAttrs) {
1613 "Unexpected invalid target.");
1617 if (NewTarget != OldTarget) {
1620 if (OldMethod && NewMethod && OldMethod->isVirtual() &&
1621 OldMethod->isConstexpr() && !NewMethod->isConstexpr() &&
1639 bool UseMemberUsingDeclRules,
bool ConsiderCudaAttrs) {
1645 bool UseMemberUsingDeclRules,
bool ConsiderCudaAttrs) {
1658 bool SuppressUserConversions,
1660 bool InOverloadResolution,
1662 bool AllowObjCWritebackConversion,
1663 bool AllowObjCConversionOnExplicit) {
1666 if (SuppressUserConversions) {
1677 Conversions, AllowExplicit,
1678 AllowObjCConversionOnExplicit)) {
1699 bool FromListInit =
false;
1700 if (
const auto *InitList = dyn_cast<InitListExpr>(From);
1701 InitList && InitList->getNumInits() == 1 &&
1703 const Expr *SingleInit = InitList->getInit(0);
1704 FromType = SingleInit->
getType();
1706 FromListInit =
true;
1715 if ((FromCanon == ToCanon ||
1727 if (ToCanon != FromCanon)
1738 Cand != Conversions.
end(); ++Cand)
1779static ImplicitConversionSequence
1781 bool SuppressUserConversions,
1783 bool InOverloadResolution,
1785 bool AllowObjCWritebackConversion,
1786 bool AllowObjCConversionOnExplicit) {
1789 ICS.
Standard, CStyle, AllowObjCWritebackConversion)){
1833 FromResType->getWrappedType()) &&
1835 FromResType->getContainedType()) &&
1836 ToResType->getAttrs() == FromResType->getAttrs()) {
1846 AllowExplicit, InOverloadResolution, CStyle,
1847 AllowObjCWritebackConversion,
1848 AllowObjCConversionOnExplicit);
1851ImplicitConversionSequence
1853 bool SuppressUserConversions,
1855 bool InOverloadResolution,
1857 bool AllowObjCWritebackConversion) {
1858 return ::TryImplicitConversion(*
this, From, ToType, SuppressUserConversions,
1859 AllowExplicit, InOverloadResolution, CStyle,
1860 AllowObjCWritebackConversion,
1866 bool AllowExplicit) {
1871 bool AllowObjCWritebackConversion =
1878 *
this, From, ToType,
1880 AllowExplicit ? AllowedExplicit::All : AllowedExplicit::None,
1882 false, AllowObjCWritebackConversion,
1896 if (
Context.hasSameUnqualifiedType(FromType, ToType))
1909 if (TyClass != CanFrom->getTypeClass())
return false;
1910 if (TyClass != Type::FunctionProto && TyClass != Type::FunctionNoProto) {
1911 if (TyClass == Type::Pointer) {
1914 }
else if (TyClass == Type::BlockPointer) {
1917 }
else if (TyClass == Type::MemberPointer) {
1924 CanTo = ToMPT->getPointeeType();
1930 TyClass = CanTo->getTypeClass();
1931 if (TyClass != CanFrom->getTypeClass())
return false;
1932 if (TyClass != Type::FunctionProto && TyClass != Type::FunctionNoProto)
1942 bool Changed =
false;
1950 const auto *FromFPT = dyn_cast<FunctionProtoType>(FromFn);
1951 const auto *ToFPT = dyn_cast<FunctionProtoType>(ToFn);
1953 if (FromFPT && ToFPT) {
1954 if (FromFPT->hasCFIUncheckedCallee() != ToFPT->hasCFIUncheckedCallee()) {
1956 FromFPT->getReturnType(), FromFPT->getParamTypes(),
1957 FromFPT->getExtProtoInfo().withCFIUncheckedCallee(
1958 ToFPT->hasCFIUncheckedCallee()));
1966 if (FromFPT && ToFPT) {
1967 if (FromFPT->isNothrow() && !ToFPT->isNothrow()) {
1979 bool CanUseToFPT, CanUseFromFPT;
1980 if (
Context.mergeExtParameterInfo(ToFPT, FromFPT, CanUseToFPT,
1981 CanUseFromFPT, NewParamInfos) &&
1982 CanUseToFPT && !CanUseFromFPT) {
1985 NewParamInfos.empty() ?
nullptr : NewParamInfos.data();
1987 FromFPT->getParamTypes(), ExtInfo);
1992 if (
Context.hasAnyFunctionEffects()) {
1997 const auto FromFX = FromFPT->getFunctionEffects();
1998 const auto ToFX = ToFPT->getFunctionEffects();
1999 if (FromFX != ToFX) {
2003 FromFPT->getReturnType(), FromFPT->getParamTypes(), ExtInfo);
2013 assert(
QualType(FromFn, 0).isCanonical());
2014 if (
QualType(FromFn, 0) != CanTo)
return false;
2041 if ((&FromSem == &llvm::APFloat::PPCDoubleDouble() &&
2042 &ToSem == &llvm::APFloat::IEEEquad()) ||
2043 (&FromSem == &llvm::APFloat::IEEEquad() &&
2044 &ToSem == &llvm::APFloat::PPCDoubleDouble()))
2099 bool InOverloadResolution,
bool CStyle) {
2116 if (ToExtType && FromExtType) {
2118 unsigned ToElts = ToExtType->getNumElements();
2119 if (FromElts < ToElts)
2121 if (FromElts == ToElts)
2127 QualType ToElTy = ToExtType->getElementType();
2132 if (FromExtType && !ToExtType) {
2146 if (ToExtType->getNumElements() != FromExtType->getNumElements())
2151 FromExtType->getElementType()->isIntegerType()) {
2163 QualType ToElTy = ToExtType->getElementType();
2197 !ToType->
hasAttr(attr::ArmMveStrictPolymorphism))) {
2202 !InOverloadResolution && !CStyle) {
2204 << FromType << ToType;
2215 bool InOverloadResolution,
2216 StandardConversionSequence &SCS,
2228 bool InOverloadResolution,
2231 bool AllowObjCWritebackConversion) {
2257 FromType = Fn->getType();
2277 if (Method && !Method->isStatic() &&
2278 !Method->isExplicitObjectMemberFunction()) {
2280 "Non-unary operator on non-static member address");
2283 "Non-address-of operator on non-static member address");
2285 FromType, std::nullopt, Method->getParent());
2289 "Non-address-of operator for overloaded function expression");
2335 FromType =
Atomic->getValueType();
2370 if (
auto *FD = dyn_cast<FunctionDecl>(DRE->getDecl()))
2390 bool IncompatibleObjC =
false;
2445 }
else if (AllowObjCWritebackConversion &&
2449 FromType, IncompatibleObjC)) {
2455 InOverloadResolution, FromType)) {
2459 From, InOverloadResolution, CStyle)) {
2469 S, From, ToType, InOverloadResolution, SCS, CStyle)) {
2505 bool ObjCLifetimeConversion;
2511 ObjCLifetimeConversion)) {
2530 CanonFrom = CanonTo;
2543 if ((S.
getLangOpts().CPlusPlus || !InOverloadResolution))
2555 case AssignConvertType::
2556 CompatibleVoidPtrToNonVoidPtr:
2589 bool InOverloadResolution,
2597 const RecordDecl *UD = UT->getDecl()->getDefinitionOrSelf();
2598 if (!UD->
hasAttr<TransparentUnionAttr>())
2601 for (
const auto *it : UD->
fields()) {
2604 ToType = it->getType();
2630 return To->
getKind() == BuiltinType::Int;
2633 return To->
getKind() == BuiltinType::UInt;
2657 if (FromED->isScoped())
2664 if (FromED->isFixed()) {
2665 QualType Underlying = FromED->getIntegerType();
2666 return Context.hasSameUnqualifiedType(Underlying, ToType) ||
2673 return Context.hasSameUnqualifiedType(ToType, FromED->getPromotionType());
2698 uint64_t FromSize =
Context.getTypeSize(FromType);
2707 for (
int Idx = 0; Idx < 6; ++Idx) {
2708 uint64_t ToSize =
Context.getTypeSize(PromoteTypes[Idx]);
2709 if (FromSize < ToSize ||
2710 (FromSize == ToSize &&
2711 FromIsSigned == PromoteTypes[Idx]->isSignedIntegerType())) {
2715 return Context.hasSameUnqualifiedType(ToType, PromoteTypes[Idx]);
2736 std::optional<llvm::APSInt> BitWidth;
2739 MemberDecl->getBitWidth()->getIntegerConstantExpr(
Context))) {
2740 llvm::APSInt ToSize(BitWidth->getBitWidth(), BitWidth->isUnsigned());
2741 ToSize =
Context.getTypeSize(ToType);
2744 if (*BitWidth < ToSize ||
2746 return To->
getKind() == BuiltinType::Int;
2752 return To->
getKind() == BuiltinType::UInt;
2770 return Context.getTypeSize(FromType) <
Context.getTypeSize(ToType);
2780 if (FromBuiltin->getKind() == BuiltinType::Float &&
2781 ToBuiltin->getKind() == BuiltinType::Double)
2788 (FromBuiltin->getKind() == BuiltinType::Float ||
2789 FromBuiltin->getKind() == BuiltinType::Double) &&
2790 (ToBuiltin->getKind() == BuiltinType::LongDouble ||
2791 ToBuiltin->getKind() == BuiltinType::Float128 ||
2792 ToBuiltin->getKind() == BuiltinType::Ibm128))
2797 if (
getLangOpts().
HLSL && FromBuiltin->getKind() == BuiltinType::Half &&
2798 (ToBuiltin->getKind() == BuiltinType::Float ||
2799 ToBuiltin->getKind() == BuiltinType::Double))
2804 FromBuiltin->getKind() == BuiltinType::Half &&
2805 ToBuiltin->getKind() == BuiltinType::Float)
2837 bool StripObjCLifetime =
false) {
2840 "Invalid similarly-qualified pointer type");
2851 if (StripObjCLifetime)
2863 return Context.getObjCObjectPointerType(ToPointee);
2864 return Context.getPointerType(ToPointee);
2872 return Context.getObjCObjectPointerType(QualifiedCanonToPointee);
2873 return Context.getPointerType(QualifiedCanonToPointee);
2877 bool InOverloadResolution,
2883 return !InOverloadResolution;
2891 bool InOverloadResolution,
2893 bool &IncompatibleObjC) {
2894 IncompatibleObjC =
false;
2902 ConvertedType = ToType;
2909 ConvertedType = ToType;
2916 ConvertedType = ToType;
2924 ConvertedType = ToType;
2934 ConvertedType = ToType;
2956 if (
Context.hasSameUnqualifiedType(FromPointeeType, ToPointeeType))
2983 Context.typesAreCompatible(FromPointeeType, ToPointeeType)) {
3005 !
Context.hasSameUnqualifiedType(FromPointeeType, ToPointeeType) &&
3014 Context.areCompatibleVectorTypes(FromPointeeType, ToPointeeType)) {
3033 return Context.getQualifiedType(
T, Qs);
3035 return Context.getQualifiedType(
T.getUnqualifiedType(), Qs);
3040 bool &IncompatibleObjC) {
3053 if (ToObjCPtr && FromObjCPtr) {
3061 if (
Context.canAssignObjCInterfaces(ToObjCPtr, FromObjCPtr)) {
3075 if (
Context.canAssignObjCInterfaces(FromObjCPtr, ToObjCPtr)) {
3079 IncompatibleObjC =
true;
3095 if (FromObjCPtr && FromObjCPtr->isObjCBuiltinType()) {
3124 IncompatibleObjC)) {
3126 IncompatibleObjC =
true;
3127 ConvertedType =
Context.getPointerType(ConvertedType);
3136 IncompatibleObjC)) {
3138 ConvertedType =
Context.getPointerType(ConvertedType);
3151 if (FromFunctionType && ToFunctionType) {
3154 if (
Context.getCanonicalType(FromPointeeType)
3155 ==
Context.getCanonicalType(ToPointeeType))
3160 if (FromFunctionType->
getNumParams() != ToFunctionType->getNumParams() ||
3161 FromFunctionType->
isVariadic() != ToFunctionType->isVariadic() ||
3162 FromFunctionType->
getMethodQuals() != ToFunctionType->getMethodQuals())
3165 bool HasObjCConversion =
false;
3167 Context.getCanonicalType(ToFunctionType->getReturnType())) {
3170 ToFunctionType->getReturnType(),
3171 ConvertedType, IncompatibleObjC)) {
3173 HasObjCConversion =
true;
3180 for (
unsigned ArgIdx = 0, NumArgs = FromFunctionType->
getNumParams();
3181 ArgIdx != NumArgs; ++ArgIdx) {
3183 QualType ToArgType = ToFunctionType->getParamType(ArgIdx);
3184 if (
Context.getCanonicalType(FromArgType)
3185 ==
Context.getCanonicalType(ToArgType)) {
3188 ConvertedType, IncompatibleObjC)) {
3190 HasObjCConversion =
true;
3197 if (HasObjCConversion) {
3201 IncompatibleObjC =
true;
3233 if (!FromFunctionType || !ToFunctionType)
3236 if (
Context.hasSameType(FromPointeeType, ToPointeeType))
3241 if (FromFunctionType->
getNumParams() != ToFunctionType->getNumParams() ||
3242 FromFunctionType->
isVariadic() != ToFunctionType->isVariadic())
3247 if (FromEInfo != ToEInfo)
3250 bool IncompatibleObjC =
false;
3252 ToFunctionType->getReturnType())) {
3256 QualType LHS = ToFunctionType->getReturnType();
3261 if (
Context.hasSameType(RHS,LHS)) {
3264 ConvertedType, IncompatibleObjC)) {
3265 if (IncompatibleObjC)
3274 for (
unsigned ArgIdx = 0, NumArgs = FromFunctionType->
getNumParams();
3275 ArgIdx != NumArgs; ++ArgIdx) {
3276 IncompatibleObjC =
false;
3278 QualType ToArgType = ToFunctionType->getParamType(ArgIdx);
3279 if (
Context.hasSameType(FromArgType, ToArgType)) {
3282 ConvertedType, IncompatibleObjC)) {
3283 if (IncompatibleObjC)
3292 bool CanUseToFPT, CanUseFromFPT;
3293 if (!
Context.mergeExtParameterInfo(ToFunctionType, FromFunctionType,
3294 CanUseToFPT, CanUseFromFPT,
3298 ConvertedType = ToType;
3337 ToMember->getMostRecentCXXRecordDecl())) {
3339 if (ToMember->isSugared())
3341 ToMember->getMostRecentCXXRecordDecl());
3343 PDiag << ToMember->getQualifier();
3344 if (FromMember->isSugared())
3346 FromMember->getMostRecentCXXRecordDecl());
3348 PDiag << FromMember->getQualifier();
3366 !FromType->
getAs<TemplateSpecializationType>()) {
3372 if (
Context.hasSameType(FromType, ToType)) {
3381 if (!FromFunction || !ToFunction) {
3386 if (FromFunction->
getNumParams() != ToFunction->getNumParams()) {
3396 << ToFunction->getParamType(ArgPos)
3403 ToFunction->getReturnType())) {
3409 if (FromFunction->
getMethodQuals() != ToFunction->getMethodQuals()) {
3432 assert(llvm::size(Old) == llvm::size(
New) &&
3433 "Can't compare parameters of functions with different number of "
3436 for (
auto &&[Idx,
Type] : llvm::enumerate(Old)) {
3438 size_t J =
Reversed ? (llvm::size(
New) - Idx - 1) : Idx;
3443 Context.removePtrSizeAddrSpace(
Type.getUnqualifiedType());
3445 Context.removePtrSizeAddrSpace((
New.begin() + J)->getUnqualifiedType());
3447 if (!
Context.hasSameType(OldType, NewType)) {
3472 unsigned OldIgnore =
3474 unsigned NewIgnore =
3481 NewPT->param_types().slice(NewIgnore),
3488 bool IgnoreBaseAccess,
3491 bool IsCStyleOrFunctionalCast = IgnoreBaseAccess;
3500 PDiag(diag::warn_impcast_bool_to_null_pointer)
3511 if (FromPointeeType->
isRecordType() && ToPointeeType->isRecordType() &&
3512 !
Context.hasSameUnqualifiedType(FromPointeeType, ToPointeeType)) {
3515 unsigned InaccessibleID = 0;
3516 unsigned AmbiguousID = 0;
3518 InaccessibleID = diag::err_upcast_to_inaccessible_base;
3519 AmbiguousID = diag::err_ambiguous_derived_to_base_conv;
3522 FromPointeeType, ToPointeeType, InaccessibleID, AmbiguousID,
3524 &BasePath, IgnoreBaseAccess))
3528 Kind = CK_DerivedToBase;
3531 if (
Diagnose && !IsCStyleOrFunctionalCast &&
3532 FromPointeeType->
isFunctionType() && ToPointeeType->isVoidType()) {
3534 "this should only be possible with MSVCCompat!");
3546 if (FromPtrType->isObjCBuiltinType() || ToPtrType->isObjCBuiltinType())
3549 Kind = CK_BlockPointerToObjCPointerCast;
3551 Kind = CK_CPointerToObjCPointerCast;
3555 Kind = CK_AnyPointerToBlockPointerCast;
3561 Kind = CK_NullToPointer;
3568 bool InOverloadResolution,
3578 ConvertedType = ToType;
3594 ConvertedType =
Context.getMemberPointerType(
3608 if (
Context.getTargetInfo().getCXXABI().isMicrosoft()) {
3616 Kind = CK_NullToMemberPointer;
3634 PD <<
Context.getCanonicalTagType(Cls);
3644 std::swap(
Base, Derived);
3653 PD <<
int(Direction);
3661 DiagFromTo(PD) <<
QualType(VBase, 0) << OpRange;
3669 ? CK_DerivedToBaseMemberPointer
3670 : CK_BaseToDerivedMemberPointer;
3672 if (!IgnoreBaseAccess)
3676 ? diag::err_upcast_to_inaccessible_base
3677 : diag::err_downcast_from_inaccessible_base,
3679 NestedNameSpecifier BaseQual = FromPtrType->getQualifier(),
3680 DerivedQual = ToPtrType->getQualifier();
3681 if (Direction == MemberPointerConversionDirection::Upcast)
3682 std::swap(BaseQual, DerivedQual);
3683 DiagCls(PD, DerivedQual, Derived);
3684 DiagCls(PD, BaseQual, Base);
3719 bool CStyle,
bool IsTopLevel,
3720 bool &PreviousToQualsIncludeConst,
3721 bool &ObjCLifetimeConversion,
3734 ObjCLifetimeConversion =
true;
3774 !PreviousToQualsIncludeConst)
3792 PreviousToQualsIncludeConst =
3793 PreviousToQualsIncludeConst && ToQuals.
hasConst();
3799 bool CStyle,
bool &ObjCLifetimeConversion) {
3800 FromType =
Context.getCanonicalType(FromType);
3801 ToType =
Context.getCanonicalType(ToType);
3802 ObjCLifetimeConversion =
false;
3812 bool PreviousToQualsIncludeConst =
true;
3813 bool UnwrappedAnyPointer =
false;
3814 while (
Context.UnwrapSimilarTypes(FromType, ToType)) {
3816 !UnwrappedAnyPointer,
3817 PreviousToQualsIncludeConst,
3820 UnwrappedAnyPointer =
true;
3828 return UnwrappedAnyPointer &&
Context.hasSameUnqualifiedType(FromType,ToType);
3837 bool InOverloadResolution,
3846 InOverloadResolution, InnerSCS,
3863 if (CtorType->getNumParams() > 0) {
3864 QualType FirstArg = CtorType->getParamType(0);
3876 bool AllowExplicit) {
3883 bool Usable = !Info.Constructor->isInvalidDecl() &&
3886 bool SuppressUserConversions =
false;
3887 if (Info.ConstructorTmpl)
3890 CandidateSet, SuppressUserConversions,
3895 CandidateSet, SuppressUserConversions,
3896 false, AllowExplicit);
3900 bool HadMultipleCandidates = (CandidateSet.
size() > 1);
3903 switch (
auto Result =
3927 llvm_unreachable(
"Invalid OverloadResult!");
3949 bool AllowObjCConversionOnExplicit) {
3950 assert(AllowExplicit != AllowedExplicit::None ||
3951 !AllowObjCConversionOnExplicit);
3955 bool ConstructorsOnly =
false;
3959 if (
const RecordType *ToRecordType = ToType->
getAsCanonical<RecordType>()) {
3971 ConstructorsOnly =
true;
3975 }
else if (
auto *ToRecordDecl =
3976 dyn_cast<CXXRecordDecl>(ToRecordType->getDecl())) {
3977 ToRecordDecl = ToRecordDecl->getDefinitionOrSelf();
3979 Expr **Args = &From;
3980 unsigned NumArgs = 1;
3981 bool ListInitializing =
false;
3982 if (
InitListExpr *InitList = dyn_cast<InitListExpr>(From)) {
3985 S, From, ToType, ToRecordDecl, User, CandidateSet,
3986 AllowExplicit == AllowedExplicit::All);
3995 Args = InitList->getInits();
3996 NumArgs = InitList->getNumInits();
3997 ListInitializing =
true;
4005 bool Usable = !Info.Constructor->isInvalidDecl();
4006 if (!ListInitializing)
4007 Usable = Usable && Info.Constructor->isConvertingConstructor(
4010 bool SuppressUserConversions = !ConstructorsOnly;
4018 if (SuppressUserConversions && ListInitializing) {
4019 SuppressUserConversions =
4024 if (Info.ConstructorTmpl)
4026 Info.ConstructorTmpl, Info.FoundDecl,
4028 CandidateSet, SuppressUserConversions,
4030 AllowExplicit == AllowedExplicit::All);
4036 SuppressUserConversions,
4038 AllowExplicit == AllowedExplicit::All);
4048 }
else if (
const RecordType *FromRecordType =
4050 if (
auto *FromRecordDecl =
4051 dyn_cast<CXXRecordDecl>(FromRecordType->getDecl())) {
4052 FromRecordDecl = FromRecordDecl->getDefinitionOrSelf();
4054 const auto &Conversions = FromRecordDecl->getVisibleConversionFunctions();
4055 for (
auto I = Conversions.begin(), E = Conversions.end(); I != E; ++I) {
4064 if ((ConvTemplate = dyn_cast<FunctionTemplateDecl>(D)))
4071 ConvTemplate, FoundDecl, ActingContext, From, ToType,
4072 CandidateSet, AllowObjCConversionOnExplicit,
4073 AllowExplicit != AllowedExplicit::None);
4076 CandidateSet, AllowObjCConversionOnExplicit,
4077 AllowExplicit != AllowedExplicit::None);
4082 bool HadMultipleCandidates = (CandidateSet.
size() > 1);
4085 switch (
auto Result =
4091 = dyn_cast<CXXConstructorDecl>(Best->Function)) {
4103 if (Best->Conversions[0].isEllipsis())
4106 User.
Before = Best->Conversions[0].Standard;
4119 = dyn_cast<CXXConversionDecl>(Best->Function)) {
4121 assert(Best->HasFinalConversion);
4129 User.
Before = Best->Conversions[0].Standard;
4144 User.
After = Best->FinalConversion;
4147 llvm_unreachable(
"Not a constructor or conversion function?");
4156 llvm_unreachable(
"Invalid OverloadResult!");
4166 CandidateSet, AllowedExplicit::None,
false);
4181 diag::err_typecheck_nonviable_condition_incomplete,
4188 *
this, From, Cands);
4214 if (!Conv1 || !Conv2)
4229 if (Block1 != Block2)
4242 if (Conv1FuncRet && Conv2FuncRet &&
4251 CallOp->getType()->castAs<
FunctionType>()->getCallConv();
4253 CallOpProto->isVariadic(),
false);
4255 CallOpProto->isVariadic(),
true);
4257 CallingConv PrefOrder[] = {DefaultFree, DefaultMember, CallOpCC};
4352 if (!ICS1.
isBad()) {
4353 bool StdInit1 =
false, StdInit2 =
false;
4360 if (StdInit1 != StdInit2)
4371 CAT2->getElementType())) {
4373 if (CAT1->getSize() != CAT2->getSize())
4375 return CAT1->getSize().ult(CAT2->getSize())
4410 if (ConvFunc1 == ConvFunc2)
4512 if (!
Enum->isFixed())
4548 else if (Rank2 < Rank1)
4583 bool SCS1ConvertsToVoid
4585 bool SCS2ConvertsToVoid
4587 if (SCS1ConvertsToVoid != SCS2ConvertsToVoid) {
4592 }
else if (!SCS1ConvertsToVoid && !SCS2ConvertsToVoid) {
4598 }
else if (SCS1ConvertsToVoid && SCS2ConvertsToVoid &&
4627 if (FromObjCPtr1 && FromObjCPtr2) {
4632 if (AssignLeft != AssignRight) {
4667 if (UnqualT1 == UnqualT2) {
4729 if (SCS1IsCompatibleVectorConversion != SCS2IsCompatibleVectorConversion)
4730 return SCS1IsCompatibleVectorConversion
4737 bool SCS1IsCompatibleSVEVectorConversion =
4739 bool SCS2IsCompatibleSVEVectorConversion =
4742 if (SCS1IsCompatibleSVEVectorConversion !=
4743 SCS2IsCompatibleSVEVectorConversion)
4744 return SCS1IsCompatibleSVEVectorConversion
4751 bool SCS1IsCompatibleRVVVectorConversion =
4753 bool SCS2IsCompatibleRVVVectorConversion =
4756 if (SCS1IsCompatibleRVVVectorConversion !=
4757 SCS2IsCompatibleRVVVectorConversion)
4758 return SCS1IsCompatibleRVVVectorConversion
4798 if (UnqualT1 == UnqualT2)
4816 bool ObjCLifetimeConversion;
4826 if (CanPick1 != CanPick2)
4880 if (FromPointee1 == FromPointee2 && ToPointee1 != ToPointee2) {
4888 if (FromPointee1 != FromPointee2 && ToPointee1 == ToPointee2) {
4905 if (FromPtr1 && FromPtr2 && ToPtr1 && ToPtr2) {
4912 bool FromAssignRight
4921 if (ToPtr1->isObjCIdType() &&
4922 (ToPtr2->isObjCQualifiedIdType() || ToPtr2->getInterfaceDecl()))
4924 if (ToPtr2->isObjCIdType() &&
4925 (ToPtr1->isObjCQualifiedIdType() || ToPtr1->getInterfaceDecl()))
4930 if (ToPtr1->isObjCQualifiedIdType() && ToPtr2->getInterfaceDecl())
4932 if (ToPtr2->isObjCQualifiedIdType() && ToPtr1->getInterfaceDecl())
4937 if (ToPtr1->isObjCClassType() &&
4938 (ToPtr2->isObjCQualifiedClassType() || ToPtr2->getInterfaceDecl()))
4940 if (ToPtr2->isObjCClassType() &&
4941 (ToPtr1->isObjCQualifiedClassType() || ToPtr1->getInterfaceDecl()))
4946 if (ToPtr1->isObjCQualifiedClassType() && ToPtr2->getInterfaceDecl())
4948 if (ToPtr2->isObjCQualifiedClassType() && ToPtr1->getInterfaceDecl())
4954 (ToAssignLeft != ToAssignRight)) {
4965 }
else if (IsSecondSame)
4974 (FromAssignLeft != FromAssignRight))
4988 CXXRecordDecl *FromPointee1 = FromMemPointer1->getMostRecentCXXRecordDecl();
4993 if (FromPointee1 == FromPointee2 && ToPointee1 != ToPointee2) {
5000 if (ToPointee1 == ToPointee2 && FromPointee1 != FromPointee2) {
5038 if (!
T.getQualifiers().hasUnaligned())
5052 "T1 must be the pointee type of the reference type");
5053 assert(!OrigT2->
isReferenceType() &&
"T2 cannot be a reference type");
5076 if (UnqualT1 == UnqualT2) {
5080 Conv |= ReferenceConversions::DerivedToBase;
5083 Context.canBindObjCObjectType(UnqualT1, UnqualT2))
5084 Conv |= ReferenceConversions::ObjC;
5087 Conv |= ReferenceConversions::Function;
5091 bool ConvertedReferent = Conv != 0;
5095 bool PreviousToQualsIncludeConst =
true;
5096 bool TopLevel =
true;
5102 Conv |= ReferenceConversions::Qualification;
5108 Conv |= ReferenceConversions::NestedQualification;
5116 bool ObjCLifetimeConversion =
false;
5118 PreviousToQualsIncludeConst,
5120 return (ConvertedReferent ||
Context.hasSimilarType(T1, T2))
5125 if (ObjCLifetimeConversion)
5126 Conv |= ReferenceConversions::ObjCLifetime;
5129 }
while (
Context.UnwrapSimilarTypes(T1, T2));
5134 return (ConvertedReferent ||
Context.hasSameUnqualifiedType(T1, T2))
5145 bool AllowExplicit) {
5146 assert(T2->
isRecordType() &&
"Can only find conversions of record types.");
5150 const auto &Conversions = T2RecordDecl->getVisibleConversionFunctions();
5151 for (
auto I = Conversions.begin(), E = Conversions.end(); I != E; ++I) {
5158 = dyn_cast<FunctionTemplateDecl>(D);
5175 if (!ConvTemplate &&
5199 ConvTemplate, I.getPair(), ActingDC,
Init, DeclType, CandidateSet,
5200 false, AllowExplicit);
5203 Conv, I.getPair(), ActingDC,
Init, DeclType, CandidateSet,
5204 false, AllowExplicit);
5207 bool HadMultipleCandidates = (CandidateSet.
size() > 1);
5213 assert(Best->HasFinalConversion);
5225 if (!Best->FinalConversion.DirectBinding)
5237 "Expected a direct reference binding!");
5243 Cand != CandidateSet.
end(); ++Cand)
5255 llvm_unreachable(
"Invalid OverloadResult!");
5260static ImplicitConversionSequence
5263 bool SuppressUserConversions,
5264 bool AllowExplicit) {
5265 assert(DeclType->
isReferenceType() &&
"Reference init needs a reference");
5292 auto SetAsReferenceBinding = [&](
bool BindsDirectly) {
5297 ICS.
Standard.
Second = (RefConv & Sema::ReferenceConversions::DerivedToBase)
5299 : (RefConv & Sema::ReferenceConversions::ObjC)
5307 Sema::ReferenceConversions::NestedQualification)
5321 (RefConv & Sema::ReferenceConversions::ObjCLifetime) != 0;
5345 SetAsReferenceBinding(
true);
5394 SetAsReferenceBinding(S.
getLangOpts().CPlusPlus11 ||
5485 AllowedExplicit::None,
5510 if (isRValRef && LValRefType) {
5527static ImplicitConversionSequence
5529 bool SuppressUserConversions,
5530 bool InOverloadResolution,
5531 bool AllowObjCWritebackConversion,
5532 bool AllowExplicit =
false);
5536static ImplicitConversionSequence
5538 bool SuppressUserConversions,
5539 bool InOverloadResolution,
5540 bool AllowObjCWritebackConversion) {
5553 if (
const auto *IAT = dyn_cast<IncompleteArrayType>(AT))
5555 InitTy = IAT->getElementType();
5581 if (From->
getNumInits() == 1 && !IsDesignatedInit) {
5587 SuppressUserConversions,
5588 InOverloadResolution,
5589 AllowObjCWritebackConversion);
5597 Result.setStandard();
5598 Result.Standard.setAsIdentityConversion();
5599 Result.Standard.setFromType(ToType);
5600 Result.Standard.setAllToTypes(ToType);
5625 bool IsUnbounded =
false;
5629 if (CT->getSize().ult(e)) {
5633 Result.setInitializerListContainerType(ContTy, IsUnbounded);
5636 if (CT->getSize().ugt(e)) {
5642 S, &EmptyList, InitTy, SuppressUserConversions,
5643 InOverloadResolution, AllowObjCWritebackConversion);
5644 if (DfltElt.
isBad()) {
5648 Result.setInitializerListContainerType(ContTy, IsUnbounded);
5659 Result.setInitializerListContainerType(ContTy, IsUnbounded);
5668 Result.setStandard();
5669 Result.Standard.setAsIdentityConversion();
5670 Result.Standard.setFromType(InitTy);
5671 Result.Standard.setAllToTypes(InitTy);
5672 for (
unsigned i = 0; i < e; ++i) {
5675 S,
Init, InitTy, SuppressUserConversions, InOverloadResolution,
5676 AllowObjCWritebackConversion);
5686 if (Result.isBad()) {
5687 Result.setInitializerListContainerType(ContTy, IsUnbounded);
5697 S, From->
getEndLoc(), DfltElt, Result) ==
5715 AllowedExplicit::None,
5716 InOverloadResolution,
false,
5717 AllowObjCWritebackConversion,
5735 Result.setUserDefined();
5736 Result.UserDefined.Before.setAsIdentityConversion();
5738 Result.UserDefined.Before.setFromType(
QualType());
5739 Result.UserDefined.Before.setAllToTypes(
QualType());
5741 Result.UserDefined.After.setAsIdentityConversion();
5742 Result.UserDefined.After.setFromType(ToType);
5743 Result.UserDefined.After.setAllToTypes(ToType);
5744 Result.UserDefined.ConversionFunction =
nullptr;
5761 if (From->
getNumInits() == 1 && !IsDesignatedInit) {
5782 SuppressUserConversions,
5790 InOverloadResolution,
5791 AllowObjCWritebackConversion);
5792 if (Result.isFailure())
5794 assert(!Result.isEllipsis() &&
5795 "Sub-initialization cannot result in ellipsis conversion.");
5801 Result.UserDefined.After;
5829 S, From->
getInit(0), ToType, SuppressUserConversions,
5830 InOverloadResolution, AllowObjCWritebackConversion);
5831 if (Result.isStandard())
5832 Result.Standard.FromBracedInitList =
true;
5836 else if (NumInits == 0) {
5837 Result.setStandard();
5838 Result.Standard.setAsIdentityConversion();
5839 Result.Standard.setFromType(ToType);
5840 Result.Standard.setAllToTypes(ToType);
5857static ImplicitConversionSequence
5859 bool SuppressUserConversions,
5860 bool InOverloadResolution,
5861 bool AllowObjCWritebackConversion,
5862 bool AllowExplicit) {
5863 if (
InitListExpr *FromInitList = dyn_cast<InitListExpr>(From))
5865 InOverloadResolution,AllowObjCWritebackConversion);
5870 SuppressUserConversions, AllowExplicit);
5873 SuppressUserConversions,
5874 AllowedExplicit::None,
5875 InOverloadResolution,
5877 AllowObjCWritebackConversion,
5890 return !ICS.
isBad();
5899 const CXXRecordDecl *ActingContext,
bool InOverloadResolution =
false,
5901 bool SuppressUserConversion =
false) {
5909 assert(FromClassification.
isLValue());
5920 if (Method->isExplicitObjectMemberFunction()) {
5921 if (ExplicitParameterType.isNull())
5922 ExplicitParameterType = Method->getFunctionObjectParameterReferenceType();
5924 ValueKindFromClassification(FromClassification));
5926 S, &TmpExpr, ExplicitParameterType, SuppressUserConversion,
5943 Qualifiers Quals = Method->getMethodQualifiers();
5981 FromType, ImplicitParamType);
5991 FromType, ImplicitParamType);
6004 }
else if (!Method->isExplicitObjectMemberFunction()) {
6006 FromType, ImplicitParamType);
6011 switch (Method->getRefQualifier()) {
6026 if (!FromClassification.
isRValue()) {
6048 = (Method->getRefQualifier() ==
RQ_None);
6059 QualType ImplicitParamRecordType =
Method->getFunctionObjectParameterType();
6064 DestType =
Method->getThisType();
6067 FromRecordType = From->
getType();
6068 DestType = ImplicitParamRecordType;
6076 Method->getRefQualifier() !=
6094 <<
Method->getDeclName() << FromRecordType << (CVR - 1)
6096 Diag(
Method->getLocation(), diag::note_previous_decl)
6097 <<
Method->getDeclName();
6105 bool IsRValueQualified =
6109 << IsRValueQualified;
6110 Diag(
Method->getLocation(), diag::note_previous_decl)
6111 <<
Method->getDeclName();
6121 llvm_unreachable(
"Lists are not objects");
6124 return Diag(From->
getBeginLoc(), diag::err_member_function_call_bad_type)
6125 << ImplicitParamRecordType << FromRecordType
6134 From = FromRes.
get();
6143 CK = CK_AddressSpaceConversion;
6168 AllowedExplicit::Conversions,
6249 llvm_unreachable(
"found a first conversion kind in Second");
6253 llvm_unreachable(
"found a third conversion kind in Second");
6259 llvm_unreachable(
"unknown conversion kind");
6269 [[maybe_unused]]
bool isCCEAllowedPreCXX11 =
6271 assert((S.
getLangOpts().CPlusPlus11 || isCCEAllowedPreCXX11) &&
6272 "converted constant expression outside C++11 or TTP matching");
6296 if (
T->isRecordType())
6305 diag::err_typecheck_converted_constant_expression)
6311 llvm_unreachable(
"bad conversion in converted constant expression");
6317 diag::err_typecheck_converted_constant_expression_disallowed)
6323 diag::err_typecheck_converted_constant_expression_indirect)
6333 diag::err_reference_bind_to_bitfield_in_cce)
6341 bool IsTemplateArgument =
6343 if (
T->isRecordType()) {
6344 assert(IsTemplateArgument &&
6345 "unexpected class type converted constant expr");
6354 if (Result.isInvalid())
6361 IsTemplateArgument);
6362 if (Result.isInvalid())
6366 bool ReturnPreNarrowingValue =
false;
6369 PreNarrowingType)) {
6379 PreNarrowingValue.
isInt()) {
6382 ReturnPreNarrowingValue =
true;
6402 << CCE << 0 << From->
getType() <<
T;
6405 if (!ReturnPreNarrowingValue)
6406 PreNarrowingValue = {};
6422 if (Result.isInvalid() || Result.get()->isValueDependent()) {
6427 RequireInt, PreNarrowingValue);
6434 return ::BuildConvertedConstantExpression(*
this, From,
T, CCE, Dest,
6441 return ::CheckConvertedConstantExpression(*
this, From,
T,
Value, CCE,
false,
6446 llvm::APSInt &
Value,
6448 assert(
T->isIntegralOrEnumerationType() &&
"unexpected converted const type");
6453 if (!R.isInvalid() && !R.get()->isValueDependent())
6461 const APValue &PreNarrowingValue) {
6473 Kind = ConstantExprKind::ClassTemplateArgument;
6475 Kind = ConstantExprKind::NonClassTemplateArgument;
6477 Kind = ConstantExprKind::Normal;
6480 (RequireInt && !Eval.
Val.
isInt())) {
6487 if (Notes.empty()) {
6490 if (
const auto *CE = dyn_cast<ConstantExpr>(E)) {
6494 "ConstantExpr has no value associated with it");
6500 Value = std::move(PreNarrowingValue);
6506 if (Notes.size() == 1 &&
6507 Notes[0].second.getDiagID() == diag::note_invalid_subexpr_in_const_expr) {
6508 Diag(Notes[0].first, diag::err_expr_not_cce) << CCE;
6509 }
else if (!Notes.empty() && Notes[0].second.getDiagID() ==
6510 diag::note_constexpr_invalid_template_arg) {
6511 Notes[0].second.setDiagID(diag::err_constexpr_invalid_template_arg);
6512 for (
unsigned I = 0; I < Notes.size(); ++I)
6513 Diag(Notes[I].first, Notes[I].second);
6517 for (
unsigned I = 0; I < Notes.size(); ++I)
6518 Diag(Notes[I].first, Notes[I].second);
6537static ImplicitConversionSequence
6545 AllowedExplicit::Conversions,
6587 "expected a member expression");
6589 if (
const auto M = dyn_cast<UnresolvedMemberExpr>(MemExprE);
6590 M && !M->isImplicitAccess())
6591 Base = M->getBase();
6592 else if (
const auto M = dyn_cast<MemberExpr>(MemExprE);
6593 M && !M->isImplicitAccess())
6594 Base = M->getBase();
6598 if (
T->isPointerType())
6599 T =
T->getPointeeType();
6627 assert(Method->isExplicitObjectMemberFunction() &&
6628 "Method is not an explicit member function");
6629 assert(NewArgs.empty() &&
"NewArgs should be empty");
6631 NewArgs.reserve(Args.size() + 1);
6633 NewArgs.push_back(
This);
6634 NewArgs.append(Args.begin(), Args.end());
6637 Method, Object->getBeginLoc());
6643 return AllowScopedEnumerations ?
T->isIntegralOrEnumerationType()
6644 :
T->isIntegralOrUnscopedEnumerationType();
6656 for (
unsigned I = 0, N = ViableConversions.
size(); I != N; ++I) {
6670 if (ExplicitConversions.
size() == 1 && !Converter.
Suppress) {
6678 std::string TypeStr;
6683 "static_cast<" + TypeStr +
">(")
6695 HadMultipleCandidates);
6696 if (Result.isInvalid())
6702 From, Result.get()->
getType());
6703 if (Result.isInvalid())
6705 From = Result.get();
6728 HadMultipleCandidates);
6729 if (Result.isInvalid())
6733 CK_UserDefinedConversion, Result.get(),
6734 nullptr, Result.get()->getValueKind(),
6759 if (
auto *ConvTemplate = dyn_cast<FunctionTemplateDecl>(D)) {
6761 ConvTemplate, FoundDecl, ActingContext, From, ToType, CandidateSet,
6767 Conv, FoundDecl, ActingContext, From, ToType, CandidateSet,
6801 From = result.
get();
6815 const RecordType *RecordTy =
T->getAsCanonical<RecordType>();
6828 : Converter(Converter), From(From) {}
6833 } IncompleteDiagnoser(Converter, From);
6844 ->getDefinitionOrSelf()
6845 ->getVisibleConversionFunctions();
6847 bool HadMultipleCandidates =
6852 bool HasUniqueTargetType =
true;
6868 "Conversion operator templates are considered potentially "
6872 if (Converter.
match(CurToType) || ConvTemplate) {
6878 ExplicitConversions.
addDecl(I.getDecl(), I.getAccess());
6883 else if (HasUniqueTargetType &&
6885 HasUniqueTargetType =
false;
6887 ViableConversions.
addDecl(I.getDecl(), I.getAccess());
6905 HadMultipleCandidates,
6906 ExplicitConversions))
6912 if (!HasUniqueTargetType)
6931 HadMultipleCandidates,
Found))
6940 HadMultipleCandidates,
6941 ExplicitConversions))
6949 switch (ViableConversions.
size()) {
6952 HadMultipleCandidates,
6953 ExplicitConversions))
6963 HadMultipleCandidates,
Found))
6994 if (Proto->getNumParams() < 1)
6998 QualType ArgType = Proto->getParamType(0).getNonReferenceType();
6999 if (Context.hasSameUnqualifiedType(T1, ArgType))
7003 if (Proto->getNumParams() < 2)
7007 QualType ArgType = Proto->getParamType(1).getNonReferenceType();
7008 if (Context.hasSameUnqualifiedType(T2, ArgType))
7027 unsigned SeenAt = 0;
7029 bool HasDefault =
false;
7038 return HasDefault || SeenAt != 0;
7044 bool PartialOverloading,
bool AllowExplicit,
bool AllowExplicitConversions,
7047 bool StrictPackMatch) {
7050 assert(Proto &&
"Functions without a prototype cannot be overloaded");
7051 assert(!
Function->getDescribedFunctionTemplate() &&
7052 "Use AddTemplateOverloadCandidate for function templates");
7065 CandidateSet, SuppressUserConversions,
7066 PartialOverloading, EarlyConversions, PO,
7102 CandidateSet.
addCandidate(Args.size(), EarlyConversions);
7116 Candidate.
Viable =
false;
7129 bool IsImplicitlyInstantiated =
false;
7130 if (
auto *SpecInfo =
Function->getTemplateSpecializationInfo()) {
7131 ND = SpecInfo->getTemplate();
7132 IsImplicitlyInstantiated = SpecInfo->getTemplateSpecializationKind() ==
7143 const bool IsInlineFunctionInGMF =
7145 (IsImplicitlyInstantiated ||
Function->isInlined());
7148 Candidate.
Viable =
false;
7155 Candidate.
Viable =
false;
7166 if (Args.size() == 1 &&
Constructor->isSpecializationCopyingObject() &&
7167 (
Context.hasSameUnqualifiedType(ClassType, Args[0]->getType()) ||
7170 Candidate.
Viable =
false;
7182 auto *Shadow = dyn_cast<ConstructorUsingShadowDecl>(FoundDecl.
getDecl());
7183 if (Shadow && Args.size() == 1 &&
Constructor->getNumParams() >= 1 &&
7184 Constructor->getParamDecl(0)->getType()->isReferenceType()) {
7191 Candidate.
Viable =
false;
7200 Constructor->getMethodQualifiers().getAddressSpace(),
7202 Candidate.
Viable =
false;
7215 Candidate.
Viable =
false;
7225 unsigned MinRequiredArgs =
Function->getMinRequiredArguments();
7226 if (!AggregateCandidateDeduction && Args.size() < MinRequiredArgs &&
7227 !PartialOverloading) {
7229 Candidate.
Viable =
false;
7243 Candidate.
Viable =
false;
7249 if (
Function->getTrailingRequiresClause()) {
7254 Candidate.
Viable =
false;
7263 for (
unsigned ArgIdx = 0; ArgIdx < Args.size(); ++ArgIdx) {
7266 if (Candidate.
Conversions[ConvIdx].isInitialized()) {
7269 }
else if (ArgIdx < NumParams) {
7280 *
this, Args[ArgIdx], ParamType, SuppressUserConversions,
7283 getLangOpts().ObjCAutoRefCount, AllowExplicitConversions);
7285 Candidate.
Viable =
false;
7297 if (EnableIfAttr *FailedAttr =
7299 Candidate.
Viable =
false;
7309 if (Methods.size() <= 1)
7312 for (
unsigned b = 0, e = Methods.size();
b < e;
b++) {
7318 if (
Method->param_size() > NumNamedArgs)
7319 NumNamedArgs =
Method->param_size();
7320 if (Args.size() < NumNamedArgs)
7323 for (
unsigned i = 0; i < NumNamedArgs; i++) {
7325 if (Args[i]->isTypeDependent()) {
7331 Expr *argExpr = Args[i];
7332 assert(argExpr &&
"SelectBestMethod(): missing expression");
7337 !param->
hasAttr<CFConsumedAttr>())
7338 argExpr =
ObjC().stripARCUnbridgedCast(argExpr);
7355 if (ConversionState.
isBad() ||
7365 for (
unsigned i = NumNamedArgs, e = Args.size(); i < e; ++i) {
7366 if (Args[i]->isTypeDependent()) {
7379 if (Args.size() != NumNamedArgs)
7381 else if (
Match && NumNamedArgs == 0 && Methods.size() > 1) {
7384 for (
unsigned b = 0, e = Methods.size();
b < e;
b++) {
7385 QualType ReturnT = Methods[
b]->getReturnType();
7405 "Shouldn't have `this` for ctors!");
7406 assert(!Method->isStatic() &&
"Shouldn't have `this` for static methods!");
7408 ThisArg, std::nullopt, Method, Method);
7411 ConvertedThis = R.
get();
7413 if (
auto *MD = dyn_cast<CXXMethodDecl>(Function)) {
7415 assert((MissingImplicitThis || MD->isStatic() ||
7417 "Expected `this` for non-ctor instance methods");
7419 ConvertedThis =
nullptr;
7424 unsigned ArgSizeNoVarargs = std::min(Function->param_size(), Args.size());
7427 for (
unsigned I = 0; I != ArgSizeNoVarargs; ++I) {
7430 S.
Context, Function->getParamDecl(I)),
7436 ConvertedArgs.push_back(R.
get());
7443 if (!Function->isVariadic() && Args.size() < Function->getNumParams()) {
7444 for (
unsigned i = Args.size(), e = Function->getNumParams(); i != e; ++i) {
7451 ConvertedArgs.push_back(R.
get());
7463 bool MissingImplicitThis) {
7464 auto EnableIfAttrs =
Function->specific_attrs<EnableIfAttr>();
7465 if (EnableIfAttrs.begin() == EnableIfAttrs.end())
7471 Expr *DiscardedThis;
7473 *
this,
Function,
nullptr, CallLoc, Args, Trap,
7474 true, DiscardedThis, ConvertedArgs))
7475 return *EnableIfAttrs.begin();
7477 for (
auto *EIA : EnableIfAttrs) {
7481 if (EIA->getCond()->isValueDependent() ||
7482 !EIA->getCond()->EvaluateWithSubstitution(
7486 if (!
Result.isInt() || !
Result.getInt().getBoolValue())
7492template <
typename CheckFn>
7495 CheckFn &&IsSuccessful) {
7498 if (ArgDependent == DIA->getArgDependent())
7499 Attrs.push_back(DIA);
7506 auto WarningBegin = std::stable_partition(
7507 Attrs.begin(), Attrs.end(), [](
const DiagnoseIfAttr *DIA) {
7508 return DIA->getDefaultSeverity() == DiagnoseIfAttr::DS_error &&
7509 DIA->getWarningGroup().empty();
7514 auto ErrAttr = llvm::find_if(llvm::make_range(Attrs.begin(), WarningBegin),
7516 if (ErrAttr != WarningBegin) {
7517 const DiagnoseIfAttr *DIA = *ErrAttr;
7518 S.
Diag(Loc, diag::err_diagnose_if_succeeded) << DIA->getMessage();
7519 S.
Diag(DIA->getLocation(), diag::note_from_diagnose_if)
7520 << DIA->getParent() << DIA->getCond()->getSourceRange();
7524 auto ToSeverity = [](DiagnoseIfAttr::DefaultSeverity Sev) {
7526 case DiagnoseIfAttr::DS_warning:
7528 case DiagnoseIfAttr::DS_error:
7531 llvm_unreachable(
"Fully covered switch above!");
7534 for (
const auto *DIA : llvm::make_range(WarningBegin, Attrs.end()))
7535 if (IsSuccessful(DIA)) {
7536 if (DIA->getWarningGroup().empty() &&
7537 DIA->getDefaultSeverity() == DiagnoseIfAttr::DS_warning) {
7538 S.
Diag(Loc, diag::warn_diagnose_if_succeeded) << DIA->getMessage();
7539 S.
Diag(DIA->getLocation(), diag::note_from_diagnose_if)
7540 << DIA->getParent() << DIA->getCond()->getSourceRange();
7543 DIA->getWarningGroup());
7546 {ToSeverity(DIA->getDefaultSeverity()),
"%0",
7548 S.
Diag(Loc, DiagID) << DIA->getMessage();
7556 const Expr *ThisArg,
7561 [&](
const DiagnoseIfAttr *DIA) {
7566 if (!DIA->getCond()->EvaluateWithSubstitution(
7569 return Result.isInt() &&
Result.getInt().getBoolValue();
7576 *
this, ND,
false, Loc,
7577 [&](
const DiagnoseIfAttr *DIA) {
7579 return DIA->getCond()->EvaluateAsBooleanCondition(
Result,
Context) &&
7588 bool SuppressUserConversions,
7589 bool PartialOverloading,
7590 bool FirstArgumentIsBase) {
7602 if (Args.size() > 0) {
7603 if (
Expr *E = Args[0]) {
7613 FunctionArgs = Args.slice(1);
7617 FunTmpl, F.getPair(),
7619 ExplicitTemplateArgs, ObjectType, ObjectClassification,
7620 FunctionArgs, CandidateSet, SuppressUserConversions,
7621 PartialOverloading);
7625 ObjectClassification, FunctionArgs, CandidateSet,
7626 SuppressUserConversions, PartialOverloading);
7633 if (Args.size() > 0 &&
7637 FunctionArgs = Args.slice(1);
7641 ExplicitTemplateArgs, FunctionArgs,
7642 CandidateSet, SuppressUserConversions,
7643 PartialOverloading);
7646 SuppressUserConversions, PartialOverloading);
7656 bool SuppressUserConversions,
7666 "Expected a member function template");
7668 nullptr, ObjectType,
7669 ObjectClassification, Args, CandidateSet,
7670 SuppressUserConversions,
false, PO);
7673 ObjectType, ObjectClassification, Args, CandidateSet,
7674 SuppressUserConversions,
false, {}, PO);
7687 assert(Proto &&
"Methods without a prototype cannot be overloaded");
7689 "Use AddOverloadCandidate for constructors");
7698 Method->isMoveAssignmentOperator())
7705 bool IgnoreExplicitObject =
7706 (
Method->isExplicitObjectMemberFunction() &&
7709 bool ImplicitObjectMethodTreatedAsStatic =
7712 Method->isImplicitObjectMemberFunction();
7714 unsigned ExplicitOffset =
7715 !IgnoreExplicitObject &&
Method->isExplicitObjectMemberFunction() ? 1 : 0;
7717 unsigned NumParams =
Method->getNumParams() - ExplicitOffset +
7718 int(ImplicitObjectMethodTreatedAsStatic);
7720 unsigned ExtraArgs =
7727 CandidateSet.
addCandidate(Args.size() + ExtraArgs, EarlyConversions);
7743 Candidate.
Viable =
false;
7753 unsigned MinRequiredArgs =
Method->getMinRequiredArguments() -
7755 int(ImplicitObjectMethodTreatedAsStatic);
7757 if (Args.size() < MinRequiredArgs && !PartialOverloading) {
7759 Candidate.
Viable =
false;
7767 if (!IgnoreExplicitObject) {
7770 else if (
Method->isStatic()) {
7780 Candidate.
Conversions[FirstConvIdx].setStaticObjectArgument();
7785 *
this, CandidateSet.
getLocation(), ObjectType, ObjectClassification,
7786 Method, ActingContext,
true);
7787 if (Candidate.
Conversions[FirstConvIdx].isBad()) {
7788 Candidate.
Viable =
false;
7799 Candidate.
Viable =
false;
7804 if (
Method->getTrailingRequiresClause()) {
7809 Candidate.
Viable =
false;
7817 for (
unsigned ArgIdx = 0; ArgIdx < Args.size(); ++ArgIdx) {
7820 if (Candidate.
Conversions[ConvIdx].isInitialized()) {
7823 }
else if (ArgIdx < NumParams) {
7829 if (ImplicitObjectMethodTreatedAsStatic) {
7830 ParamType = ArgIdx == 0
7831 ?
Method->getFunctionObjectParameterReferenceType()
7834 ParamType = Proto->
getParamType(ArgIdx + ExplicitOffset);
7838 SuppressUserConversions,
7843 Candidate.
Viable =
false;
7855 if (EnableIfAttr *FailedAttr =
7857 Candidate.
Viable =
false;
7864 Candidate.
Viable =
false;
7875 bool SuppressUserConversions,
bool PartialOverloading,
7893 PartialOverloading,
false,
7894 false, ObjectType, ObjectClassification,
7898 bool OnlyInitializeNonUserDefinedConversions) {
7899 return S.CheckNonDependentConversions(
7900 MethodTmpl, ParamTypes, Args, CandidateSet, Conversions,
7901 Sema::CheckNonDependentConversionsFlag(
7902 SuppressUserConversions,
7903 OnlyInitializeNonUserDefinedConversions),
7904 ActingContext, ObjectType, ObjectClassification, PO);
7908 CandidateSet.
addCandidate(Conversions.size(), Conversions);
7911 Candidate.
Viable =
false;
7920 Method->isStatic() ||
7921 (!Method->isExplicitObjectMemberFunction() && ObjectType.
isNull());
7935 assert(
Specialization &&
"Missing member function template specialization?");
7937 "Specialization is not a member function?");
7940 ObjectClassification, Args, CandidateSet, SuppressUserConversions,
7954 if (ExplicitTemplateArgs ||
7957 *
this, CandidateSet, MethodTmpl, FoundDecl, ActingContext,
7958 ExplicitTemplateArgs, ObjectType, ObjectClassification, Args,
7959 SuppressUserConversions, PartialOverloading, PO);
7964 MethodTmpl, FoundDecl, ActingContext, ObjectType, ObjectClassification,
7965 Args, SuppressUserConversions, PartialOverloading, PO);
7983 bool SuppressUserConversions,
bool PartialOverloading,
bool AllowExplicit,
7985 bool AggregateCandidateDeduction) {
7994 Candidate.
Viable =
false;
8014 PartialOverloading, AggregateCandidateDeduction,
8021 bool OnlyInitializeNonUserDefinedConversions) {
8022 return S.CheckNonDependentConversions(
8023 FunctionTemplate, ParamTypes, Args, CandidateSet, Conversions,
8024 Sema::CheckNonDependentConversionsFlag(
8025 SuppressUserConversions,
8026 OnlyInitializeNonUserDefinedConversions),
8027 nullptr, QualType(), {}, PO);
8030 OverloadCandidate &Candidate =
8031 CandidateSet.addCandidate(Conversions.size(), Conversions);
8034 Candidate.
Viable =
false;
8036 CandidateSet.getRewriteInfo().getRewriteKind(Candidate.
Function, PO);
8042 CandidateSet.getKind() ==
8048 ->isExplicitObjectMemberFunction() &&
8064 assert(
Specialization &&
"Missing function template specialization?");
8066 Specialization, FoundDecl, Args, CandidateSet, SuppressUserConversions,
8067 PartialOverloading, AllowExplicit,
8068 false, IsADLCandidate, Conversions, PO,
8069 Info.AggregateDeductionCandidateHasMismatchedArity,
8070 Info.hasStrictPackMatch());
8077 bool PartialOverloading,
bool AllowExplicit,
ADLCallKind IsADLCandidate,
8084 if (ExplicitTemplateArgs ||
8087 DependentExplicitSpecifier)) {
8091 Args, SuppressUserConversions, PartialOverloading, AllowExplicit,
8092 IsADLCandidate, PO, AggregateCandidateDeduction);
8094 if (DependentExplicitSpecifier)
8101 PartialOverloading, AllowExplicit, IsADLCandidate, PO,
8102 AggregateCandidateDeduction);
8115 const bool AllowExplicit =
false;
8117 bool ForOverloadSetAddressResolution =
8120 auto *
Method = dyn_cast<CXXMethodDecl>(FD);
8121 bool HasThisConversion = !ForOverloadSetAddressResolution &&
Method &&
8123 unsigned ThisConversions = HasThisConversion ? 1 : 0;
8139 if (!FD->hasCXXExplicitFunctionObjectParameter() ||
8140 !ParamTypes[0]->isDependentType()) {
8142 *
this, CandidateSet.
getLocation(), ObjectType, ObjectClassification,
8143 Method, ActingContext,
true,
8144 FD->hasCXXExplicitFunctionObjectParameter() ? ParamTypes[0]
8154 auto MaybeInvolveUserDefinedConversion = [&](
QualType ParamType,
8178 if (
auto *RD =
ArgType->getAsCXXRecordDecl();
8179 RD && RD->hasDefinition() &&
8180 !RD->getVisibleConversionFunctions().empty())
8187 HasThisConversion &&
Method->hasCXXExplicitFunctionObjectParameter() ? 1
8190 for (
unsigned I = 0, N = std::min(ParamTypes.size() - Offset, Args.size());
8192 QualType ParamType = ParamTypes[I + Offset];
8196 ConvIdx = Args.size() - 1 - I;
8197 assert(Args.size() + ThisConversions == 2 &&
8198 "number of args (including 'this') must be exactly 2 for "
8202 assert(!HasThisConversion || (ConvIdx == 0 && I == 0));
8205 ConvIdx = ThisConversions + I;
8210 MaybeInvolveUserDefinedConversion(ParamType, Args[I]->
getType()))
8239 bool AllowObjCPointerConversion) {
8247 bool ObjCLifetimeConversion;
8249 ObjCLifetimeConversion))
8254 if (!AllowObjCPointerConversion)
8258 bool IncompatibleObjC =
false;
8268 bool AllowExplicit,
bool AllowResultConversion,
bool StrictPackMatch) {
8270 "Conversion function templates use AddTemplateConversionCandidate");
8285 if (!AllowResultConversion &&
8297 AllowObjCConversionOnExplicit))
8319 if (!AllowExplicit && Conversion->
isExplicit()) {
8320 Candidate.
Viable =
false;
8347 Candidate.
Viable =
false;
8356 Candidate.
Viable =
false;
8367 QualType ToCanon =
Context.getCanonicalType(ToType).getUnqualifiedType();
8368 if (FromCanon == ToCanon ||
8370 Candidate.
Viable =
false;
8387 CK_FunctionToPointerDecay, &ConversionRef,
8392 Candidate.
Viable =
false;
8422 Candidate.
Viable =
false;
8434 Candidate.
Viable =
false;
8441 Candidate.
Viable =
false;
8447 "Can only end up with a standard conversion sequence or failure");
8450 if (EnableIfAttr *FailedAttr =
8452 Candidate.
Viable =
false;
8459 Candidate.
Viable =
false;
8468 bool AllowObjCConversionOnExplicit,
bool AllowExplicit,
8469 bool AllowResultConversion) {
8478 Candidate.
Viable =
false;
8495 Candidate.
Viable =
false;
8505 assert(
Specialization &&
"Missing function template specialization?");
8507 ToType, CandidateSet, AllowObjCConversionOnExplicit,
8508 AllowExplicit, AllowResultConversion,
8516 bool AllowExplicit,
bool AllowResultConversion) {
8518 "Only conversion function templates permitted here");
8529 ToType, AllowObjCConversionOnExplicit, AllowExplicit,
8530 AllowResultConversion);
8538 AllowObjCConversionOnExplicit, AllowExplicit, AllowResultConversion);
8573 *
this, CandidateSet.
getLocation(), Object->getType(),
8574 Object->Classify(
Context), Conversion, ActingContext);
8577 if (ObjectInit.
isBad()) {
8578 Candidate.
Viable =
false;
8589 Candidate.
Conversions[0].UserDefined.EllipsisConversion =
false;
8590 Candidate.
Conversions[0].UserDefined.HadMultipleCandidates =
false;
8591 Candidate.
Conversions[0].UserDefined.ConversionFunction = Conversion;
8592 Candidate.
Conversions[0].UserDefined.FoundConversionFunction = FoundDecl;
8595 Candidate.
Conversions[0].UserDefined.After.setAsIdentityConversion();
8603 if (Args.size() > NumParams && !Proto->
isVariadic()) {
8604 Candidate.
Viable =
false;
8611 if (Args.size() < NumParams) {
8613 Candidate.
Viable =
false;
8620 for (
unsigned ArgIdx = 0, N = Args.size(); ArgIdx != N; ++ArgIdx) {
8621 if (ArgIdx < NumParams) {
8634 Candidate.
Viable =
false;
8651 Candidate.
Viable =
false;
8657 if (EnableIfAttr *FailedAttr =
8659 Candidate.
Viable =
false;
8683 "unqualified operator lookup found a member function");
8687 FunctionArgs, CandidateSet);
8693 FunctionArgs[1], FunctionArgs[0]);
8695 Reversed, CandidateSet,
false,
false,
true,
8696 ADLCallKind::NotADL,
8700 if (ExplicitTemplateArgs)
8705 {FunctionArgs[1], FunctionArgs[0]}, CandidateSet,
8706 false,
false,
true,
false, ADLCallKind::NotADL, {},
8738 if (!T1RD || (!IsComplete && !T1RD->isBeingDefined()))
8746 OperEnd = Operators.
end();
8747 Oper != OperEnd; ++Oper) {
8748 if (Oper->getAsFunction() &&
8751 *
this, {Args[1], Args[0]}, Oper->getAsFunction()))
8754 Args[0]->Classify(
Context), Args.slice(1),
8755 CandidateSet,
false, PO);
8762 bool IsAssignmentOperator,
8763 unsigned NumContextualBoolArguments) {
8778 for (
unsigned ArgIdx = 0, N = Args.size(); ArgIdx != N; ++ArgIdx) {
8791 if (ArgIdx < NumContextualBoolArguments) {
8792 assert(ParamTys[ArgIdx] ==
Context.BoolTy &&
8793 "Contextual conversion to bool requires bool type");
8799 ArgIdx == 0 && IsAssignmentOperator,
8805 Candidate.
Viable =
false;
8818class BuiltinCandidateTypeSet {
8824 TypeSet PointerTypes;
8828 TypeSet MemberPointerTypes;
8832 TypeSet EnumerationTypes;
8836 TypeSet VectorTypes;
8840 TypeSet MatrixTypes;
8843 TypeSet BitIntTypes;
8846 bool HasNonRecordTypes;
8850 bool HasArithmeticOrEnumeralTypes;
8854 bool HasNullPtrType;
8863 bool AddPointerWithMoreQualifiedTypeVariants(
QualType Ty,
8865 bool AddMemberPointerWithMoreQualifiedTypeVariants(
QualType Ty);
8869 typedef TypeSet::iterator
iterator;
8871 BuiltinCandidateTypeSet(
Sema &SemaRef)
8872 : HasNonRecordTypes(
false),
8873 HasArithmeticOrEnumeralTypes(
false),
8874 HasNullPtrType(
false),
8876 Context(SemaRef.Context) { }
8878 void AddTypesConvertedFrom(
QualType Ty,
8880 bool AllowUserConversions,
8881 bool AllowExplicitConversions,
8882 const Qualifiers &VisibleTypeConversionsQuals);
8884 llvm::iterator_range<iterator> pointer_types() {
return PointerTypes; }
8885 llvm::iterator_range<iterator> member_pointer_types() {
8886 return MemberPointerTypes;
8888 llvm::iterator_range<iterator> enumeration_types() {
8889 return EnumerationTypes;
8891 llvm::iterator_range<iterator> vector_types() {
return VectorTypes; }
8892 llvm::iterator_range<iterator> matrix_types() {
return MatrixTypes; }
8893 llvm::iterator_range<iterator> bitint_types() {
return BitIntTypes; }
8895 bool containsMatrixType(QualType Ty)
const {
return MatrixTypes.count(Ty); }
8896 bool hasNonRecordTypes() {
return HasNonRecordTypes; }
8897 bool hasArithmeticOrEnumeralTypes() {
return HasArithmeticOrEnumeralTypes; }
8898 bool hasNullPtrType()
const {
return HasNullPtrType; }
8913BuiltinCandidateTypeSet::AddPointerWithMoreQualifiedTypeVariants(QualType Ty,
8914 const Qualifiers &VisibleQuals) {
8917 if (!PointerTypes.insert(Ty))
8921 const PointerType *PointerTy = Ty->
getAs<PointerType>();
8922 bool buildObjCPtr =
false;
8924 const ObjCObjectPointerType *PTy = Ty->
castAs<ObjCObjectPointerType>();
8926 buildObjCPtr =
true;
8938 unsigned BaseCVR = PointeeTy.getCVRQualifiers();
8944 if ((CVR | BaseCVR) != CVR)
continue;
8959 QualType QPointerTy;
8966 PointerTypes.insert(QPointerTy);
8982BuiltinCandidateTypeSet::AddMemberPointerWithMoreQualifiedTypeVariants(
8985 if (!MemberPointerTypes.insert(Ty))
8988 const MemberPointerType *PointerTy = Ty->
getAs<MemberPointerType>();
8989 assert(PointerTy &&
"type was not a member pointer type!");
9004 if ((CVR | BaseCVR) != CVR)
continue;
9008 QPointeeTy, std::nullopt, Cls));
9023BuiltinCandidateTypeSet::AddTypesConvertedFrom(QualType Ty,
9025 bool AllowUserConversions,
9026 bool AllowExplicitConversions,
9027 const Qualifiers &VisibleQuals) {
9033 if (
const ReferenceType *RefTy = Ty->
getAs<ReferenceType>())
9038 Ty = SemaRef.Context.getArrayDecayedType(Ty);
9045 HasNonRecordTypes = HasNonRecordTypes || !TyIsRec;
9048 HasArithmeticOrEnumeralTypes =
9052 PointerTypes.insert(Ty);
9053 else if (Ty->
getAs<PointerType>() || Ty->
getAs<ObjCObjectPointerType>()) {
9056 if (!AddPointerWithMoreQualifiedTypeVariants(Ty, VisibleQuals))
9060 if (!AddMemberPointerWithMoreQualifiedTypeVariants(Ty))
9063 HasArithmeticOrEnumeralTypes =
true;
9064 EnumerationTypes.insert(Ty);
9066 HasArithmeticOrEnumeralTypes =
true;
9067 BitIntTypes.insert(Ty);
9071 HasArithmeticOrEnumeralTypes =
true;
9072 VectorTypes.insert(Ty);
9076 HasArithmeticOrEnumeralTypes =
true;
9077 MatrixTypes.insert(Ty);
9079 HasNullPtrType =
true;
9080 }
else if (AllowUserConversions && TyIsRec) {
9082 if (!SemaRef.isCompleteType(Loc, Ty))
9086 for (NamedDecl *D : ClassDecl->getVisibleConversionFunctions()) {
9096 if (AllowExplicitConversions || !Conv->
isExplicit()) {
9144 ClassDecl = RHSMPType->getMostRecentCXXRecordDecl();
9192 if (Available.hasAtomic()) {
9193 Available.removeAtomic();
9200 if (Available.hasVolatile()) {
9201 Available.removeVolatile();
9235class BuiltinOperatorOverloadBuilder {
9238 ArrayRef<Expr *> Args;
9239 QualifiersAndAtomic VisibleTypeConversionsQuals;
9240 bool HasArithmeticOrEnumeralCandidateType;
9241 SmallVectorImpl<BuiltinCandidateTypeSet> &CandidateTypes;
9242 OverloadCandidateSet &CandidateSet;
9244 static constexpr int ArithmeticTypesCap = 26;
9245 SmallVector<CanQualType, ArithmeticTypesCap> ArithmeticTypes;
9250 unsigned FirstIntegralType,
9252 unsigned FirstPromotedIntegralType,
9253 LastPromotedIntegralType;
9254 unsigned FirstPromotedArithmeticType,
9255 LastPromotedArithmeticType;
9256 unsigned NumArithmeticTypes;
9258 void InitArithmeticTypes() {
9260 FirstPromotedArithmeticType = 0;
9270 FirstIntegralType = ArithmeticTypes.size();
9271 FirstPromotedIntegralType = ArithmeticTypes.size();
9293 llvm::SmallSetVector<CanQualType, 2> BitIntCandidates;
9294 for (BuiltinCandidateTypeSet &Candidate : CandidateTypes) {
9295 for (QualType BitTy : Candidate.bitint_types())
9298 llvm::move(BitIntCandidates, std::back_inserter(ArithmeticTypes));
9299 LastPromotedIntegralType = ArithmeticTypes.size();
9300 LastPromotedArithmeticType = ArithmeticTypes.size();
9314 LastIntegralType = ArithmeticTypes.size();
9315 NumArithmeticTypes = ArithmeticTypes.size();
9322 assert(ArithmeticTypes.size() - BitIntCandidates.size() <=
9323 ArithmeticTypesCap &&
9324 "Enough inline storage for all arithmetic types.");
9329 void addPlusPlusMinusMinusStyleOverloads(QualType CandidateTy,
9332 QualType ParamTypes[2] = {
9372 void AddCandidate(QualType L, QualType R) {
9373 QualType LandR[2] = {L, R};
9378 BuiltinOperatorOverloadBuilder(
9379 Sema &S, ArrayRef<Expr *> Args,
9380 QualifiersAndAtomic VisibleTypeConversionsQuals,
9381 bool HasArithmeticOrEnumeralCandidateType,
9382 SmallVectorImpl<BuiltinCandidateTypeSet> &CandidateTypes,
9383 OverloadCandidateSet &CandidateSet)
9385 VisibleTypeConversionsQuals(VisibleTypeConversionsQuals),
9386 HasArithmeticOrEnumeralCandidateType(
9387 HasArithmeticOrEnumeralCandidateType),
9388 CandidateTypes(CandidateTypes),
9389 CandidateSet(CandidateSet) {
9391 InitArithmeticTypes();
9414 if (!HasArithmeticOrEnumeralCandidateType)
9417 for (
unsigned Arith = 0; Arith < NumArithmeticTypes; ++Arith) {
9418 const auto TypeOfT = ArithmeticTypes[Arith];
9420 if (Op == OO_MinusMinus)
9422 if (Op == OO_PlusPlus && S.
getLangOpts().CPlusPlus17)
9425 addPlusPlusMinusMinusStyleOverloads(
9442 void addPlusPlusMinusMinusPointerOverloads() {
9443 for (QualType PtrTy : CandidateTypes[0].pointer_types()) {
9445 if (!PtrTy->getPointeeType()->isObjectType())
9448 addPlusPlusMinusMinusStyleOverloads(
9450 (!PtrTy.isVolatileQualified() &&
9452 (!PtrTy.isRestrictQualified() &&
9467 void addUnaryStarPointerOverloads() {
9468 for (QualType ParamTy : CandidateTypes[0].pointer_types()) {
9473 if (
const FunctionProtoType *Proto =PointeeTy->
getAs<FunctionProtoType>())
9474 if (Proto->getMethodQuals() || Proto->getRefQualifier())
9487 void addUnaryPlusOrMinusArithmeticOverloads() {
9488 if (!HasArithmeticOrEnumeralCandidateType)
9491 for (
unsigned Arith = FirstPromotedArithmeticType;
9492 Arith < LastPromotedArithmeticType; ++Arith) {
9493 QualType ArithTy = ArithmeticTypes[Arith];
9498 for (QualType VecTy : CandidateTypes[0].vector_types())
9507 void addUnaryPlusPointerOverloads() {
9508 for (QualType ParamTy : CandidateTypes[0].pointer_types())
9517 void addUnaryTildePromotedIntegralOverloads() {
9518 if (!HasArithmeticOrEnumeralCandidateType)
9521 for (
unsigned Int = FirstPromotedIntegralType;
9522 Int < LastPromotedIntegralType; ++
Int) {
9523 QualType IntTy = ArithmeticTypes[
Int];
9528 for (QualType VecTy : CandidateTypes[0].vector_types())
9538 void addEqualEqualOrNotEqualMemberPointerOrNullptrOverloads() {
9540 llvm::SmallPtrSet<QualType, 8> AddedTypes;
9542 for (
unsigned ArgIdx = 0, N = Args.size(); ArgIdx != N; ++ArgIdx) {
9543 for (QualType MemPtrTy : CandidateTypes[ArgIdx].member_pointer_types()) {
9548 QualType ParamTypes[2] = {MemPtrTy, MemPtrTy};
9552 if (CandidateTypes[ArgIdx].hasNullPtrType()) {
9554 if (AddedTypes.insert(NullPtrTy).second) {
9555 QualType ParamTypes[2] = { NullPtrTy, NullPtrTy };
9574 void addGenericBinaryPointerOrEnumeralOverloads(
bool IsSpaceship) {
9587 llvm::DenseSet<std::pair<CanQualType, CanQualType> >
9588 UserDefinedBinaryOperators;
9590 for (
unsigned ArgIdx = 0, N = Args.size(); ArgIdx != N; ++ArgIdx) {
9591 if (!CandidateTypes[ArgIdx].enumeration_types().empty()) {
9593 CEnd = CandidateSet.
end();
9595 if (!
C->Viable || !
C->Function ||
C->Function->getNumParams() != 2)
9598 if (
C->Function->isFunctionTemplateSpecialization())
9605 QualType FirstParamType =
C->Function->getParamDecl(
Reversed ? 1 : 0)
9607 .getUnqualifiedType();
9608 QualType SecondParamType =
C->Function->getParamDecl(
Reversed ? 0 : 1)
9610 .getUnqualifiedType();
9618 UserDefinedBinaryOperators.insert(
9626 llvm::SmallPtrSet<QualType, 8> AddedTypes;
9628 for (
unsigned ArgIdx = 0, N = Args.size(); ArgIdx != N; ++ArgIdx) {
9629 for (QualType PtrTy : CandidateTypes[ArgIdx].pointer_types()) {
9633 if (IsSpaceship && PtrTy->isFunctionPointerType())
9636 QualType ParamTypes[2] = {PtrTy, PtrTy};
9639 for (QualType EnumTy : CandidateTypes[ArgIdx].enumeration_types()) {
9644 if (!AddedTypes.insert(CanonType).second ||
9645 UserDefinedBinaryOperators.count(std::make_pair(CanonType,
9648 QualType ParamTypes[2] = {EnumTy, EnumTy};
9673 llvm::SmallPtrSet<QualType, 8> AddedTypes;
9675 for (
int Arg = 0; Arg < 2; ++Arg) {
9676 QualType AsymmetricParamTypes[2] = {
9680 for (QualType PtrTy : CandidateTypes[Arg].pointer_types()) {
9685 AsymmetricParamTypes[Arg] = PtrTy;
9686 if (Arg == 0 || Op == OO_Plus) {
9691 if (Op == OO_Minus) {
9696 QualType ParamTypes[2] = {PtrTy, PtrTy};
9732 void addGenericBinaryArithmeticOverloads() {
9733 if (!HasArithmeticOrEnumeralCandidateType)
9736 for (
unsigned Left = FirstPromotedArithmeticType;
9737 Left < LastPromotedArithmeticType; ++
Left) {
9738 for (
unsigned Right = FirstPromotedArithmeticType;
9739 Right < LastPromotedArithmeticType; ++
Right) {
9740 QualType LandR[2] = { ArithmeticTypes[
Left],
9741 ArithmeticTypes[
Right] };
9748 for (QualType Vec1Ty : CandidateTypes[0].vector_types())
9749 for (QualType Vec2Ty : CandidateTypes[1].vector_types()) {
9750 QualType LandR[2] = {Vec1Ty, Vec2Ty};
9760 void addMatrixBinaryArithmeticOverloads() {
9761 if (!HasArithmeticOrEnumeralCandidateType)
9764 for (QualType M1 : CandidateTypes[0].matrix_types()) {
9766 AddCandidate(M1, M1);
9769 for (QualType M2 : CandidateTypes[1].matrix_types()) {
9771 if (!CandidateTypes[0].containsMatrixType(M2))
9772 AddCandidate(M2, M2);
9807 void addThreeWayArithmeticOverloads() {
9808 addGenericBinaryArithmeticOverloads();
9825 void addBinaryBitwiseArithmeticOverloads() {
9826 if (!HasArithmeticOrEnumeralCandidateType)
9829 for (
unsigned Left = FirstPromotedIntegralType;
9830 Left < LastPromotedIntegralType; ++
Left) {
9831 for (
unsigned Right = FirstPromotedIntegralType;
9833 QualType LandR[2] = { ArithmeticTypes[
Left],
9834 ArithmeticTypes[
Right] };
9847 void addAssignmentMemberPointerOrEnumeralOverloads() {
9849 llvm::SmallPtrSet<QualType, 8> AddedTypes;
9851 for (
unsigned ArgIdx = 0; ArgIdx < 2; ++ArgIdx) {
9852 for (QualType EnumTy : CandidateTypes[ArgIdx].enumeration_types()) {
9859 for (QualType MemPtrTy : CandidateTypes[ArgIdx].member_pointer_types()) {
9884 void addAssignmentPointerOverloads(
bool isEqualOp) {
9886 llvm::SmallPtrSet<QualType, 8> AddedTypes;
9888 for (QualType PtrTy : CandidateTypes[0].pointer_types()) {
9892 else if (!PtrTy->getPointeeType()->isObjectType())
9896 QualType ParamTypes[2] = {
9903 bool NeedVolatile = !PtrTy.isVolatileQualified() &&
9913 if (!PtrTy.isRestrictQualified() &&
9933 for (QualType PtrTy : CandidateTypes[1].pointer_types()) {
9938 QualType ParamTypes[2] = {
9947 bool NeedVolatile = !PtrTy.isVolatileQualified() &&
9957 if (!PtrTy.isRestrictQualified() &&
9990 void addAssignmentArithmeticOverloads(
bool isEqualOp) {
9991 if (!HasArithmeticOrEnumeralCandidateType)
9994 for (
unsigned Left = 0;
Left < NumArithmeticTypes; ++
Left) {
9995 for (
unsigned Right = FirstPromotedArithmeticType;
9996 Right < LastPromotedArithmeticType; ++
Right) {
9997 QualType ParamTypes[2];
9998 ParamTypes[1] = ArithmeticTypes[
Right];
10000 S, ArithmeticTypes[Left], Args[0]);
10003 VisibleTypeConversionsQuals, [&](QualifiersAndAtomic Quals) {
10013 for (QualType Vec1Ty : CandidateTypes[0].vector_types())
10014 for (QualType Vec2Ty : CandidateTypes[0].vector_types()) {
10015 QualType ParamTypes[2];
10016 ParamTypes[1] = Vec2Ty;
10044 void addAssignmentIntegralOverloads() {
10045 if (!HasArithmeticOrEnumeralCandidateType)
10048 for (
unsigned Left = FirstIntegralType;
Left < LastIntegralType; ++
Left) {
10049 for (
unsigned Right = FirstPromotedIntegralType;
10050 Right < LastPromotedIntegralType; ++
Right) {
10051 QualType ParamTypes[2];
10052 ParamTypes[1] = ArithmeticTypes[
Right];
10054 S, ArithmeticTypes[Left], Args[0]);
10057 VisibleTypeConversionsQuals, [&](QualifiersAndAtomic Quals) {
10073 void addExclaimOverload() {
10079 void addAmpAmpOrPipePipeOverload() {
10096 void addSubscriptOverloads() {
10097 for (QualType PtrTy : CandidateTypes[0].pointer_types()) {
10107 for (QualType PtrTy : CandidateTypes[1].pointer_types()) {
10127 void addArrowStarOverloads() {
10128 for (QualType PtrTy : CandidateTypes[0].pointer_types()) {
10129 QualType C1Ty = PtrTy;
10131 QualifierCollector Q1;
10142 for (QualType MemPtrTy : CandidateTypes[1].member_pointer_types()) {
10149 QualType ParamTypes[2] = {PtrTy, MemPtrTy};
10152 if (!VisibleTypeConversionsQuals.
hasVolatile() &&
10153 T.isVolatileQualified())
10155 if (!VisibleTypeConversionsQuals.
hasRestrict() &&
10156 T.isRestrictQualified())
10174 void addConditionalOperatorOverloads() {
10176 llvm::SmallPtrSet<QualType, 8> AddedTypes;
10178 for (
unsigned ArgIdx = 0; ArgIdx < 2; ++ArgIdx) {
10179 for (QualType PtrTy : CandidateTypes[ArgIdx].pointer_types()) {
10183 QualType ParamTypes[2] = {PtrTy, PtrTy};
10187 for (QualType MemPtrTy : CandidateTypes[ArgIdx].member_pointer_types()) {
10191 QualType ParamTypes[2] = {MemPtrTy, MemPtrTy};
10196 for (QualType EnumTy : CandidateTypes[ArgIdx].enumeration_types()) {
10197 if (!EnumTy->castAsCanonical<EnumType>()->getDecl()->isScoped())
10203 QualType ParamTypes[2] = {EnumTy, EnumTy};
10222 VisibleTypeConversionsQuals.
addConst();
10223 for (
unsigned ArgIdx = 0, N = Args.size(); ArgIdx != N; ++ArgIdx) {
10225 if (Args[ArgIdx]->
getType()->isAtomicType())
10226 VisibleTypeConversionsQuals.
addAtomic();
10229 bool HasNonRecordCandidateType =
false;
10230 bool HasArithmeticOrEnumeralCandidateType =
false;
10232 for (
unsigned ArgIdx = 0, N = Args.size(); ArgIdx != N; ++ArgIdx) {
10233 CandidateTypes.emplace_back(*
this);
10234 CandidateTypes[ArgIdx].AddTypesConvertedFrom(Args[ArgIdx]->
getType(),
10237 (Op == OO_Exclaim ||
10239 Op == OO_PipePipe),
10240 VisibleTypeConversionsQuals);
10241 HasNonRecordCandidateType = HasNonRecordCandidateType ||
10242 CandidateTypes[ArgIdx].hasNonRecordTypes();
10243 HasArithmeticOrEnumeralCandidateType =
10244 HasArithmeticOrEnumeralCandidateType ||
10245 CandidateTypes[ArgIdx].hasArithmeticOrEnumeralTypes();
10253 if (!HasNonRecordCandidateType &&
10254 !(Op == OO_Exclaim || Op == OO_AmpAmp || Op == OO_PipePipe))
10258 BuiltinOperatorOverloadBuilder OpBuilder(*
this, Args,
10259 VisibleTypeConversionsQuals,
10260 HasArithmeticOrEnumeralCandidateType,
10261 CandidateTypes, CandidateSet);
10267 llvm_unreachable(
"Expected an overloaded operator");
10272 case OO_Array_Delete:
10275 "Special operators don't use AddBuiltinOperatorCandidates");
10287 if (Args.size() == 1)
10288 OpBuilder.addUnaryPlusPointerOverloads();
10292 if (Args.size() == 1) {
10293 OpBuilder.addUnaryPlusOrMinusArithmeticOverloads();
10295 OpBuilder.addBinaryPlusOrMinusPointerOverloads(Op);
10296 OpBuilder.addGenericBinaryArithmeticOverloads();
10297 OpBuilder.addMatrixBinaryArithmeticOverloads();
10302 if (Args.size() == 1)
10303 OpBuilder.addUnaryStarPointerOverloads();
10305 OpBuilder.addGenericBinaryArithmeticOverloads();
10306 OpBuilder.addMatrixBinaryArithmeticOverloads();
10311 OpBuilder.addGenericBinaryArithmeticOverloads();
10315 case OO_MinusMinus:
10316 OpBuilder.addPlusPlusMinusMinusArithmeticOverloads(Op);
10317 OpBuilder.addPlusPlusMinusMinusPointerOverloads();
10320 case OO_EqualEqual:
10321 case OO_ExclaimEqual:
10322 OpBuilder.addEqualEqualOrNotEqualMemberPointerOrNullptrOverloads();
10323 OpBuilder.addGenericBinaryPointerOrEnumeralOverloads(
false);
10324 OpBuilder.addGenericBinaryArithmeticOverloads();
10330 case OO_GreaterEqual:
10331 OpBuilder.addGenericBinaryPointerOrEnumeralOverloads(
false);
10332 OpBuilder.addGenericBinaryArithmeticOverloads();
10336 OpBuilder.addGenericBinaryPointerOrEnumeralOverloads(
true);
10337 OpBuilder.addThreeWayArithmeticOverloads();
10344 case OO_GreaterGreater:
10345 OpBuilder.addBinaryBitwiseArithmeticOverloads();
10349 if (Args.size() == 1)
10355 OpBuilder.addBinaryBitwiseArithmeticOverloads();
10359 OpBuilder.addUnaryTildePromotedIntegralOverloads();
10363 OpBuilder.addAssignmentMemberPointerOrEnumeralOverloads();
10367 case OO_MinusEqual:
10368 OpBuilder.addAssignmentPointerOverloads(Op == OO_Equal);
10372 case OO_SlashEqual:
10373 OpBuilder.addAssignmentArithmeticOverloads(Op == OO_Equal);
10376 case OO_PercentEqual:
10377 case OO_LessLessEqual:
10378 case OO_GreaterGreaterEqual:
10380 case OO_CaretEqual:
10382 OpBuilder.addAssignmentIntegralOverloads();
10386 OpBuilder.addExclaimOverload();
10391 OpBuilder.addAmpAmpOrPipePipeOverload();
10395 if (Args.size() == 2)
10396 OpBuilder.addSubscriptOverloads();
10400 OpBuilder.addArrowStarOverloads();
10403 case OO_Conditional:
10404 OpBuilder.addConditionalOperatorOverloads();
10405 OpBuilder.addGenericBinaryArithmeticOverloads();
10416 bool PartialOverloading) {
10433 CandEnd = CandidateSet.
end();
10434 Cand != CandEnd; ++Cand)
10435 if (Cand->Function) {
10439 Fns.
erase(FunTmpl);
10448 if (ExplicitTemplateArgs)
10452 FD, FoundDecl, Args, CandidateSet,
false,
10453 PartialOverloading,
true,
10454 false, ADLCallKind::UsesADL);
10457 FD, FoundDecl, {Args[1], Args[0]}, CandidateSet,
10458 false, PartialOverloading,
10465 FTD, FoundDecl, ExplicitTemplateArgs, Args, CandidateSet,
10466 false, PartialOverloading,
10467 true, ADLCallKind::UsesADL);
10469 *
this, Args, FTD->getTemplatedDecl())) {
10473 if (ReversedArgs.empty())
10477 FTD, FoundDecl, ExplicitTemplateArgs, ReversedArgs, CandidateSet,
10478 false, PartialOverloading,
10479 true, ADLCallKind::UsesADL,
10504 bool Cand1Attr = Cand1->
hasAttr<EnableIfAttr>();
10505 bool Cand2Attr = Cand2->
hasAttr<EnableIfAttr>();
10506 if (!Cand1Attr || !Cand2Attr) {
10507 if (Cand1Attr == Cand2Attr)
10508 return Comparison::Equal;
10509 return Cand1Attr ? Comparison::Better : Comparison::Worse;
10515 llvm::FoldingSetNodeID Cand1ID, Cand2ID;
10516 for (
auto Pair : zip_longest(Cand1Attrs, Cand2Attrs)) {
10517 std::optional<EnableIfAttr *> Cand1A = std::get<0>(Pair);
10518 std::optional<EnableIfAttr *> Cand2A = std::get<1>(Pair);
10523 return Comparison::Worse;
10525 return Comparison::Better;
10530 (*Cand1A)->getCond()->Profile(Cand1ID, S.
getASTContext(),
true);
10531 (*Cand2A)->getCond()->Profile(Cand2ID, S.
getASTContext(),
true);
10532 if (Cand1ID != Cand2ID)
10533 return Comparison::Worse;
10536 return Comparison::Equal;
10544 return Comparison::Equal;
10550 return Comparison::Equal;
10551 return Comparison::Worse;
10554 return Comparison::Better;
10560 const auto *Cand1CPUSpec = Cand1.
Function->
getAttr<CPUSpecificAttr>();
10561 const auto *Cand2CPUSpec = Cand2.
Function->
getAttr<CPUSpecificAttr>();
10563 if (!Cand1CPUDisp && !Cand2CPUDisp && !Cand1CPUSpec && !Cand2CPUSpec)
10564 return Comparison::Equal;
10566 if (Cand1CPUDisp && !Cand2CPUDisp)
10567 return Comparison::Better;
10568 if (Cand2CPUDisp && !Cand1CPUDisp)
10569 return Comparison::Worse;
10571 if (Cand1CPUSpec && Cand2CPUSpec) {
10572 if (Cand1CPUSpec->cpus_size() != Cand2CPUSpec->cpus_size())
10573 return Cand1CPUSpec->cpus_size() < Cand2CPUSpec->cpus_size()
10574 ? Comparison::Better
10575 : Comparison::Worse;
10577 std::pair<CPUSpecificAttr::cpus_iterator, CPUSpecificAttr::cpus_iterator>
10578 FirstDiff = std::mismatch(
10579 Cand1CPUSpec->cpus_begin(), Cand1CPUSpec->cpus_end(),
10580 Cand2CPUSpec->cpus_begin(),
10582 return LHS->getName() == RHS->getName();
10585 assert(FirstDiff.first != Cand1CPUSpec->cpus_end() &&
10586 "Two different cpu-specific versions should not have the same "
10587 "identifier list, otherwise they'd be the same decl!");
10588 return (*FirstDiff.first)->getName() < (*FirstDiff.second)->getName()
10589 ? Comparison::Better
10590 : Comparison::Worse;
10592 llvm_unreachable(
"No way to get here unless both had cpu_dispatch");
10598static std::optional<QualType>
10601 return std::nullopt;
10607 return M->getFunctionObjectParameterReferenceType();
10621 PT2->getInstantiatedFromMemberTemplate()))
10632 assert(I < F->getNumParams());
10639 if (F1NumParams != F2NumParams)
10642 unsigned I1 = 0, I2 = 0;
10643 for (
unsigned I = 0; I != F1NumParams; ++I) {
10644 QualType T1 = NextParam(F1, I1, I == 0);
10645 QualType T2 = NextParam(F2, I2, I == 0);
10646 assert(!T1.
isNull() && !T2.
isNull() &&
"Unexpected null param types");
10647 if (!Context.hasSameUnqualifiedType(T1, T2))
10660 bool IsFn1Reversed,
10661 bool IsFn2Reversed) {
10662 assert(Fn1 && Fn2);
10667 IsFn1Reversed ^ IsFn2Reversed))
10670 auto *Mem1 = dyn_cast<CXXMethodDecl>(Fn1);
10671 auto *Mem2 = dyn_cast<CXXMethodDecl>(Fn2);
10672 if (Mem1 && Mem2) {
10675 if (Mem1->getParent() != Mem2->getParent())
10679 if (Mem1->isInstance() && Mem2->isInstance() &&
10681 Mem1->getFunctionObjectParameterReferenceType(),
10682 Mem1->getFunctionObjectParameterReferenceType()))
10688static FunctionDecl *
10690 bool IsFn1Reversed,
bool IsFn2Reversed) {
10700 if (Cand1IsSpecialization || Cand2IsSpecialization)
10717 bool PartialOverloading) {
10763 bool IsCand1ImplicitHD =
10765 bool IsCand2ImplicitHD =
10780 auto EmitThreshold =
10781 (S.
getLangOpts().CUDAIsDevice && IsCallerImplicitHD &&
10782 (IsCand1ImplicitHD || IsCand2ImplicitHD))
10785 auto Cand1Emittable = P1 > EmitThreshold;
10786 auto Cand2Emittable = P2 > EmitThreshold;
10787 if (Cand1Emittable && !Cand2Emittable)
10789 if (!Cand1Emittable && Cand2Emittable)
10800 unsigned StartArg = 0;
10808 return ICS.isStandard() &&
10820 assert(Cand2.
Conversions.size() == NumArgs &&
"Overload candidate mismatch");
10821 bool HasBetterConversion =
false;
10822 for (
unsigned ArgIdx = StartArg; ArgIdx < NumArgs; ++ArgIdx) {
10823 bool Cand1Bad = IsIllFormedConversion(Cand1.
Conversions[ArgIdx]);
10824 bool Cand2Bad = IsIllFormedConversion(Cand2.
Conversions[ArgIdx]);
10825 if (Cand1Bad != Cand2Bad) {
10828 HasBetterConversion =
true;
10832 if (HasBetterConversion)
10839 bool HasWorseConversion =
false;
10840 for (
unsigned ArgIdx = StartArg; ArgIdx < NumArgs; ++ArgIdx) {
10846 HasBetterConversion =
true;
10865 HasWorseConversion =
true;
10880 if (HasBetterConversion && !HasWorseConversion)
10931 bool Cand1IsSpecialization = Cand1.
Function &&
10933 bool Cand2IsSpecialization = Cand2.
Function &&
10935 if (Cand1IsSpecialization != Cand2IsSpecialization)
10936 return Cand2IsSpecialization;
10942 if (Cand1IsSpecialization && Cand2IsSpecialization) {
10943 const auto *Obj1Context =
10945 const auto *Obj2Context =
10974 bool Cand1IsInherited =
10976 bool Cand2IsInherited =
10978 if (Cand1IsInherited != Cand2IsInherited)
10979 return Cand2IsInherited;
10980 else if (Cand1IsInherited) {
10981 assert(Cand2IsInherited);
10984 if (Cand1Class->isDerivedFrom(Cand2Class))
10986 if (Cand2Class->isDerivedFrom(Cand1Class))
11003 auto *Guide1 = dyn_cast_or_null<CXXDeductionGuideDecl>(Cand1.
Function);
11004 auto *Guide2 = dyn_cast_or_null<CXXDeductionGuideDecl>(Cand2.
Function);
11005 if (Guide1 && Guide2) {
11007 if (Guide1->isImplicit() != Guide2->isImplicit())
11008 return Guide2->isImplicit();
11018 const auto *Constructor1 = Guide1->getCorrespondingConstructor();
11019 const auto *Constructor2 = Guide2->getCorrespondingConstructor();
11020 if (Constructor1 && Constructor2) {
11021 bool isC1Templated = Constructor1->getTemplatedKind() !=
11023 bool isC2Templated = Constructor2->getTemplatedKind() !=
11025 if (isC1Templated != isC2Templated)
11026 return isC2Templated;
11034 if (Cmp != Comparison::Equal)
11035 return Cmp == Comparison::Better;
11038 bool HasPS1 = Cand1.
Function !=
nullptr &&
11040 bool HasPS2 = Cand2.
Function !=
nullptr &&
11042 if (HasPS1 != HasPS2 && HasPS1)
11046 if (MV == Comparison::Better)
11048 if (MV == Comparison::Worse)
11063 const auto *CD1 = dyn_cast_or_null<CXXConstructorDecl>(Cand1.
Function);
11064 const auto *CD2 = dyn_cast_or_null<CXXConstructorDecl>(Cand2.
Function);
11066 LangAS AS1 = CD1->getMethodQualifiers().getAddressSpace();
11067 LangAS AS2 = CD2->getMethodQualifiers().getAddressSpace();
11088 auto *VA = dyn_cast_or_null<ValueDecl>(A);
11089 auto *VB = dyn_cast_or_null<ValueDecl>(B);
11095 if (!VA->getDeclContext()->getRedeclContext()->Equals(
11096 VB->getDeclContext()->getRedeclContext()) ||
11098 VA->isExternallyVisible() || VB->isExternallyVisible())
11106 if (
Context.hasSameType(VA->getType(), VB->getType()))
11111 if (
auto *EA = dyn_cast<EnumConstantDecl>(VA)) {
11112 if (
auto *EB = dyn_cast<EnumConstantDecl>(VB)) {
11117 if (EnumA->hasNameForLinkage() || EnumB->hasNameForLinkage() ||
11118 !
Context.hasSameType(EnumA->getIntegerType(),
11119 EnumB->getIntegerType()))
11122 return llvm::APSInt::isSameValue(EA->getInitVal(), EB->getInitVal());
11132 assert(D &&
"Unknown declaration");
11133 Diag(Loc, diag::ext_equivalent_internal_linkage_decl_in_modules) << D;
11139 for (
auto *E : Equiv) {
11141 Diag(E->getLocation(), diag::note_equivalent_internal_linkage_decl)
11151 ->Satisfaction.ContainsErrors;
11157 bool PartialOverloading,
bool AllowExplicit,
11159 bool AggregateCandidateDeduction) {
11162 allocateDeferredCandidate<DeferredFunctionTemplateOverloadCandidate>();
11167 false, AllowExplicit, SuppressUserConversions,
11168 PartialOverloading, AggregateCandidateDeduction},
11175 HasDeferredTemplateConstructors |=
11183 bool SuppressUserConversions,
bool PartialOverloading,
11189 allocateDeferredCandidate<DeferredMethodTemplateOverloadCandidate>();
11195 false, SuppressUserConversions, PartialOverloading,
11201 ObjectClassification,
11209 bool AllowObjCConversionOnExplicit,
bool AllowExplicit,
11210 bool AllowResultConversion) {
11213 allocateDeferredCandidate<DeferredConversionTemplateOverloadCandidate>();
11217 AllowObjCConversionOnExplicit, AllowResultConversion,
11234 S, CandidateSet,
C.FunctionTemplate,
C.FoundDecl,
C.ActingContext,
11235 nullptr,
C.ObjectType,
C.ObjectClassification,
11236 C.Args,
C.SuppressUserConversions,
C.PartialOverloading,
C.PO);
11243 S, CandidateSet,
C.FunctionTemplate,
C.FoundDecl,
11244 nullptr,
C.Args,
C.SuppressUserConversions,
11245 C.PartialOverloading,
C.AllowExplicit,
C.IsADLCandidate,
C.PO,
11246 C.AggregateCandidateDeduction);
11253 S, CandidateSet,
C.FunctionTemplate,
C.FoundDecl,
C.ActingContext,
C.From,
11254 C.ToType,
C.AllowObjCConversionOnExplicit,
C.AllowExplicit,
11255 C.AllowResultConversion);
11259 Candidates.reserve(Candidates.size() + DeferredCandidatesCount);
11262 switch (Cand->
Kind) {
11281 FirstDeferredCandidate =
nullptr;
11282 DeferredCandidatesCount = 0;
11286OverloadCandidateSet::ResultForBestCandidate(
const iterator &Best) {
11288 if (Best->Function && Best->Function->isDeleted())
11293void OverloadCandidateSet::CudaExcludeWrongSideCandidates(
11310 bool ContainsSameSideCandidate =
11318 if (!ContainsSameSideCandidate)
11321 auto IsWrongSideCandidate = [&](
const OverloadCandidate *Cand) {
11327 llvm::erase_if(Candidates, IsWrongSideCandidate);
11345 DeferredCandidatesCount == 0) &&
11346 "Unexpected deferred template candidates");
11348 bool TwoPhaseResolution =
11349 DeferredCandidatesCount != 0 && !ResolutionByPerfectCandidateIsDisabled;
11351 if (TwoPhaseResolution) {
11353 if (Best !=
end() && Best->isPerfectMatch(S.
Context)) {
11354 if (!(HasDeferredTemplateConstructors &&
11355 isa_and_nonnull<CXXConversionDecl>(Best->Function)))
11361 return BestViableFunctionImpl(S, Loc, Best);
11368 Candidates.reserve(this->Candidates.size());
11369 std::transform(this->Candidates.begin(), this->Candidates.end(),
11370 std::back_inserter(Candidates),
11374 CudaExcludeWrongSideCandidates(S, Candidates);
11377 for (
auto *Cand : Candidates) {
11378 Cand->
Best =
false;
11380 if (Best ==
end() ||
11397 llvm::SmallVector<OverloadCandidate *, 4> PendingBest;
11398 llvm::SmallVector<const NamedDecl *, 4> EquivalentCands;
11399 PendingBest.push_back(&*Best);
11404 while (!PendingBest.empty()) {
11405 auto *Curr = PendingBest.pop_back_val();
11406 for (
auto *Cand : Candidates) {
11409 PendingBest.push_back(Cand);
11414 EquivalentCands.push_back(Cand->
Function);
11426 if (!EquivalentCands.empty())
11434enum OverloadCandidateKind {
11437 oc_reversed_binary_operator,
11439 oc_implicit_default_constructor,
11440 oc_implicit_copy_constructor,
11441 oc_implicit_move_constructor,
11442 oc_implicit_copy_assignment,
11443 oc_implicit_move_assignment,
11444 oc_implicit_equality_comparison,
11445 oc_inherited_constructor
11448enum OverloadCandidateSelect {
11451 ocs_described_template,
11454static std::pair<OverloadCandidateKind, OverloadCandidateSelect>
11455ClassifyOverloadCandidate(Sema &S,
const NamedDecl *
Found,
11456 const FunctionDecl *Fn,
11458 std::string &Description) {
11461 if (FunctionTemplateDecl *FunTmpl =
Fn->getPrimaryTemplate()) {
11464 FunTmpl->getTemplateParameters(), *
Fn->getTemplateSpecializationArgs());
11467 OverloadCandidateSelect Select = [&]() {
11468 if (!Description.empty())
11469 return ocs_described_template;
11470 return isTemplate ? ocs_template : ocs_non_template;
11473 OverloadCandidateKind Kind = [&]() {
11474 if (
Fn->isImplicit() &&
Fn->getOverloadedOperator() == OO_EqualEqual)
11475 return oc_implicit_equality_comparison;
11478 return oc_reversed_binary_operator;
11480 if (
const auto *Ctor = dyn_cast<CXXConstructorDecl>(Fn)) {
11481 if (!Ctor->isImplicit()) {
11483 return oc_inherited_constructor;
11485 return oc_constructor;
11488 if (Ctor->isDefaultConstructor())
11489 return oc_implicit_default_constructor;
11491 if (Ctor->isMoveConstructor())
11492 return oc_implicit_move_constructor;
11494 assert(Ctor->isCopyConstructor() &&
11495 "unexpected sort of implicit constructor");
11496 return oc_implicit_copy_constructor;
11499 if (
const auto *Meth = dyn_cast<CXXMethodDecl>(Fn)) {
11502 if (!Meth->isImplicit())
11505 if (Meth->isMoveAssignmentOperator())
11506 return oc_implicit_move_assignment;
11508 if (Meth->isCopyAssignmentOperator())
11509 return oc_implicit_copy_assignment;
11515 return oc_function;
11518 return std::make_pair(Kind, Select);
11521void MaybeEmitInheritedConstructorNote(Sema &S,
const Decl *FoundDecl) {
11524 if (
const auto *Shadow = dyn_cast<ConstructorUsingShadowDecl>(FoundDecl))
11526 diag::note_ovl_candidate_inherited_constructor)
11527 << Shadow->getNominatedBaseClass();
11536 if (EnableIf->getCond()->isValueDependent() ||
11537 !EnableIf->getCond()->EvaluateAsBooleanCondition(AlwaysTrue, Ctx))
11554 bool InOverloadResolution,
11558 if (InOverloadResolution)
11560 diag::note_addrof_ovl_candidate_disabled_by_enable_if_attr);
11562 S.
Diag(Loc, diag::err_addrof_function_disabled_by_enable_if_attr) << FD;
11573 if (InOverloadResolution) {
11576 TemplateArgString +=
" ";
11578 FunTmpl->getTemplateParameters(),
11583 diag::note_ovl_candidate_unsatisfied_constraints)
11584 << TemplateArgString;
11586 S.
Diag(Loc, diag::err_addrof_function_constraints_not_satisfied)
11595 return P->hasAttr<PassObjectSizeAttr>();
11602 unsigned ParamNo = std::distance(FD->
param_begin(), I) + 1;
11603 if (InOverloadResolution)
11605 diag::note_ovl_candidate_has_pass_object_size_params)
11608 S.
Diag(Loc, diag::err_address_of_function_with_pass_object_size_params)
11624 return ::checkAddressOfFunctionIsAvailable(*
this,
Function, Complain,
11632 const auto *ConvD = dyn_cast<CXXConversionDecl>(Fn);
11637 if (!RD->isLambda())
11642 CallOp->getType()->castAs<
FunctionType>()->getCallConv();
11647 return ConvToCC != CallOpCC;
11653 QualType DestType,
bool TakingAddress) {
11656 if (Fn->isMultiVersion() && Fn->hasAttr<TargetAttr>() &&
11657 !Fn->getAttr<TargetAttr>()->isDefaultVersion())
11659 if (Fn->isMultiVersion() && Fn->hasAttr<TargetVersionAttr>() &&
11660 !Fn->getAttr<TargetVersionAttr>()->isDefaultVersion())
11665 std::string FnDesc;
11666 std::pair<OverloadCandidateKind, OverloadCandidateSelect> KSPair =
11667 ClassifyOverloadCandidate(*
this,
Found, Fn, RewriteKind, FnDesc);
11669 << (
unsigned)KSPair.first << (
unsigned)KSPair.second
11673 Diag(Fn->getLocation(), PD);
11674 MaybeEmitInheritedConstructorNote(*
this,
Found);
11692 FunctionDecl *FirstCand =
nullptr, *SecondCand =
nullptr;
11693 for (
auto I = Cands.begin(), E = Cands.end(); I != E; ++I) {
11697 if (
auto *
Template = I->Function->getPrimaryTemplate())
11698 Template->getAssociatedConstraints(AC);
11700 I->Function->getAssociatedConstraints(AC);
11703 if (FirstCand ==
nullptr) {
11704 FirstCand = I->Function;
11706 }
else if (SecondCand ==
nullptr) {
11707 SecondCand = I->Function;
11720 SecondCand, SecondAC))
11729 bool TakingAddress) {
11739 dyn_cast<FunctionTemplateDecl>((*I)->getUnderlyingDecl()) ) {
11743 = dyn_cast<FunctionDecl>((*I)->getUnderlyingDecl()) ) {
11756 S.
Diag(CaretLoc, PDiag)
11758 unsigned CandsShown = 0;
11772 unsigned I,
bool TakingCandidateAddress) {
11774 assert(Conv.
isBad());
11775 assert(Cand->
Function &&
"for now, candidate must be a function");
11781 bool isObjectArgument =
false;
11785 isObjectArgument =
true;
11786 else if (!Fn->hasCXXExplicitFunctionObjectParameter())
11790 std::string FnDesc;
11791 std::pair<OverloadCandidateKind, OverloadCandidateSelect> FnKindPair =
11802 bool HasParamPack =
11803 llvm::any_of(Fn->parameters().take_front(I), [](
const ParmVarDecl *Parm) {
11804 return Parm->isParameterPack();
11806 if (!isObjectArgument && !HasParamPack)
11807 ToParamRange = Fn->getParamDecl(I)->getSourceRange();
11810 assert(FromExpr &&
"overload set argument came from implicit argument?");
11816 S.
Diag(Fn->getLocation(), diag::note_ovl_candidate_bad_overload)
11817 << (
unsigned)FnKindPair.first << (
unsigned)FnKindPair.second << FnDesc
11818 << ToParamRange << ToTy << Name << I + 1;
11819 MaybeEmitInheritedConstructorNote(S, Cand->
FoundDecl);
11828 CToTy = RT->getPointeeType();
11833 CFromTy = FromPT->getPointeeType();
11834 CToTy = ToPT->getPointeeType();
11844 if (isObjectArgument)
11845 S.
Diag(Fn->getLocation(), diag::note_ovl_candidate_bad_addrspace_this)
11846 << (
unsigned)FnKindPair.first << (
unsigned)FnKindPair.second
11849 S.
Diag(Fn->getLocation(), diag::note_ovl_candidate_bad_addrspace)
11850 << (
unsigned)FnKindPair.first << (
unsigned)FnKindPair.second
11853 MaybeEmitInheritedConstructorNote(S, Cand->
FoundDecl);
11858 S.
Diag(Fn->getLocation(), diag::note_ovl_candidate_bad_ownership)
11859 << (
unsigned)FnKindPair.first << (
unsigned)FnKindPair.second << FnDesc
11862 MaybeEmitInheritedConstructorNote(S, Cand->
FoundDecl);
11867 S.
Diag(Fn->getLocation(), diag::note_ovl_candidate_bad_gc)
11868 << (
unsigned)FnKindPair.first << (
unsigned)FnKindPair.second << FnDesc
11871 MaybeEmitInheritedConstructorNote(S, Cand->
FoundDecl);
11876 S.
Diag(Fn->getLocation(), diag::note_ovl_candidate_bad_ptrauth)
11877 << (
unsigned)FnKindPair.first << (
unsigned)FnKindPair.second << FnDesc
11882 MaybeEmitInheritedConstructorNote(S, Cand->
FoundDecl);
11887 assert(CVR &&
"expected qualifiers mismatch");
11889 if (isObjectArgument) {
11890 S.
Diag(Fn->getLocation(), diag::note_ovl_candidate_bad_cvr_this)
11891 << (
unsigned)FnKindPair.first << (
unsigned)FnKindPair.second << FnDesc
11892 << FromTy << (CVR - 1);
11894 S.
Diag(Fn->getLocation(), diag::note_ovl_candidate_bad_cvr)
11895 << (
unsigned)FnKindPair.first << (
unsigned)FnKindPair.second << FnDesc
11896 << ToParamRange << FromTy << (CVR - 1) << I + 1;
11898 MaybeEmitInheritedConstructorNote(S, Cand->
FoundDecl);
11904 S.
Diag(Fn->getLocation(), diag::note_ovl_candidate_bad_value_category)
11905 << (
unsigned)FnKindPair.first << (
unsigned)FnKindPair.second << FnDesc
11906 << (
unsigned)isObjectArgument << I + 1
11909 MaybeEmitInheritedConstructorNote(S, Cand->
FoundDecl);
11916 S.
Diag(Fn->getLocation(), diag::note_ovl_candidate_bad_list_argument)
11917 << (
unsigned)FnKindPair.first << (
unsigned)FnKindPair.second << FnDesc
11918 << ToParamRange << FromTy << ToTy << (
unsigned)isObjectArgument << I + 1
11923 MaybeEmitInheritedConstructorNote(S, Cand->
FoundDecl);
11935 S.
Diag(Fn->getLocation(), diag::note_ovl_candidate_bad_conv_incomplete)
11936 << (
unsigned)FnKindPair.first << (
unsigned)FnKindPair.second << FnDesc
11937 << ToParamRange << FromTy << ToTy << (
unsigned)isObjectArgument << I + 1
11938 << (
unsigned)(Cand->
Fix.
Kind);
11940 MaybeEmitInheritedConstructorNote(S, Cand->
FoundDecl);
11945 unsigned BaseToDerivedConversion = 0;
11948 if (ToPtrTy->getPointeeType().isAtLeastAsQualifiedAs(
11950 !FromPtrTy->getPointeeType()->isIncompleteType() &&
11951 !ToPtrTy->getPointeeType()->isIncompleteType() &&
11953 FromPtrTy->getPointeeType()))
11954 BaseToDerivedConversion = 1;
11962 if (ToPtrTy->getPointeeType().isAtLeastAsQualifiedAs(
11964 FromIface->isSuperClassOf(ToIface))
11965 BaseToDerivedConversion = 2;
11967 if (ToRefTy->getPointeeType().isAtLeastAsQualifiedAs(FromTy,
11970 !ToRefTy->getPointeeType()->isIncompleteType() &&
11972 BaseToDerivedConversion = 3;
11976 if (BaseToDerivedConversion) {
11977 S.
Diag(Fn->getLocation(), diag::note_ovl_candidate_bad_base_to_derived_conv)
11978 << (
unsigned)FnKindPair.first << (
unsigned)FnKindPair.second << FnDesc
11979 << ToParamRange << (BaseToDerivedConversion - 1) << FromTy << ToTy
11981 MaybeEmitInheritedConstructorNote(S, Cand->
FoundDecl);
11990 S.
Diag(Fn->getLocation(), diag::note_ovl_candidate_bad_arc_conv)
11991 << (
unsigned)FnKindPair.first << (
unsigned)FnKindPair.second << FnDesc
11992 << ToParamRange << FromTy << ToTy << (
unsigned)isObjectArgument
11994 MaybeEmitInheritedConstructorNote(S, Cand->
FoundDecl);
12004 FDiag << (
unsigned)FnKindPair.first << (
unsigned)FnKindPair.second << FnDesc
12005 << ToParamRange << FromTy << ToTy << (
unsigned)isObjectArgument << I + 1
12006 << (
unsigned)(Cand->
Fix.
Kind);
12015 S.
Diag(Fn->getLocation(), FDiag);
12017 MaybeEmitInheritedConstructorNote(S, Cand->
FoundDecl);
12024 unsigned NumArgs,
bool IsAddressOf =
false) {
12025 assert(Cand->
Function &&
"Candidate is required to be a function.");
12027 unsigned MinParams = Fn->getMinRequiredExplicitArguments() +
12028 ((IsAddressOf && !Fn->isStatic()) ? 1 : 0);
12035 if (Fn->isInvalidDecl() &&
12039 if (NumArgs < MinParams) {
12056 unsigned NumFormalArgs,
12057 bool IsAddressOf =
false) {
12059 "The templated declaration should at least be a function"
12060 " when diagnosing bad template argument deduction due to too many"
12061 " or too few arguments");
12067 unsigned MinParams = Fn->getMinRequiredExplicitArguments() +
12068 ((IsAddressOf && !Fn->isStatic()) ? 1 : 0);
12071 bool HasExplicitObjectParam =
12072 !IsAddressOf && Fn->hasCXXExplicitFunctionObjectParameter();
12074 unsigned ParamCount =
12075 Fn->getNumNonObjectParams() + ((IsAddressOf && !Fn->isStatic()) ? 1 : 0);
12076 unsigned mode, modeCount;
12078 if (NumFormalArgs < MinParams) {
12079 if (MinParams != ParamCount || FnTy->isVariadic() ||
12080 FnTy->isTemplateVariadic())
12084 modeCount = MinParams;
12086 if (MinParams != ParamCount)
12090 modeCount = ParamCount;
12093 std::string Description;
12094 std::pair<OverloadCandidateKind, OverloadCandidateSelect> FnKindPair =
12095 ClassifyOverloadCandidate(S,
Found, Fn,
CRK_None, Description);
12097 if (modeCount == 1 && !IsAddressOf &&
12098 Fn->getParamDecl(HasExplicitObjectParam ? 1 : 0)->getDeclName())
12099 S.
Diag(Fn->getLocation(), diag::note_ovl_candidate_arity_one)
12100 << (
unsigned)FnKindPair.first << (
unsigned)FnKindPair.second
12101 << Description << mode
12102 << Fn->getParamDecl(HasExplicitObjectParam ? 1 : 0) << NumFormalArgs
12103 << HasExplicitObjectParam << Fn->getParametersSourceRange();
12105 S.
Diag(Fn->getLocation(), diag::note_ovl_candidate_arity)
12106 << (
unsigned)FnKindPair.first << (
unsigned)FnKindPair.second
12107 << Description << mode << modeCount << NumFormalArgs
12108 << HasExplicitObjectParam << Fn->getParametersSourceRange();
12110 MaybeEmitInheritedConstructorNote(S,
Found);
12115 unsigned NumFormalArgs) {
12116 assert(Cand->
Function &&
"Candidate must be a function");
12126 llvm_unreachable(
"Unsupported: Getting the described template declaration"
12127 " for bad deduction diagnosis");
12134 bool TakingCandidateAddress) {
12140 switch (DeductionFailure.
getResult()) {
12143 "TemplateDeductionResult::Success while diagnosing bad deduction");
12145 llvm_unreachable(
"TemplateDeductionResult::NonDependentConversionFailure "
12146 "while diagnosing bad deduction");
12152 assert(ParamD &&
"no parameter found for incomplete deduction result");
12154 diag::note_ovl_candidate_incomplete_deduction)
12156 MaybeEmitInheritedConstructorNote(S,
Found);
12161 assert(ParamD &&
"no parameter found for incomplete deduction result");
12163 diag::note_ovl_candidate_incomplete_deduction_pack)
12165 << (DeductionFailure.
getFirstArg()->pack_size() + 1)
12167 MaybeEmitInheritedConstructorNote(S,
Found);
12172 assert(ParamD &&
"no parameter found for bad qualifiers deduction result");
12190 S.
Diag(Templated->
getLocation(), diag::note_ovl_candidate_underqualified)
12191 << ParamD->
getDeclName() << Arg << NonCanonParam;
12192 MaybeEmitInheritedConstructorNote(S,
Found);
12197 assert(ParamD &&
"no parameter found for inconsistent deduction result");
12211 diag::note_ovl_candidate_inconsistent_deduction_types)
12214 MaybeEmitInheritedConstructorNote(S,
Found);
12234 diag::note_ovl_candidate_inconsistent_deduction)
12237 MaybeEmitInheritedConstructorNote(S,
Found);
12242 assert(ParamD &&
"no parameter found for invalid explicit arguments");
12245 diag::note_ovl_candidate_explicit_arg_mismatch_named)
12250 index = TTP->getIndex();
12252 = dyn_cast<NonTypeTemplateParmDecl>(ParamD))
12253 index = NTTP->getIndex();
12257 diag::note_ovl_candidate_explicit_arg_mismatch_unnamed)
12260 MaybeEmitInheritedConstructorNote(S,
Found);
12267 TemplateArgString =
" ";
12270 if (TemplateArgString.size() == 1)
12271 TemplateArgString.clear();
12273 diag::note_ovl_candidate_unsatisfied_constraints)
12274 << TemplateArgString;
12277 static_cast<CNSInfo*
>(DeductionFailure.
Data)->Satisfaction);
12287 diag::note_ovl_candidate_instantiation_depth);
12288 MaybeEmitInheritedConstructorNote(S,
Found);
12296 TemplateArgString =
" ";
12299 if (TemplateArgString.size() == 1)
12300 TemplateArgString.clear();
12305 if (PDiag && PDiag->second.getDiagID() ==
12306 diag::err_typename_nested_not_found_enable_if) {
12309 S.
Diag(PDiag->first, diag::note_ovl_candidate_disabled_by_enable_if)
12310 <<
"'enable_if'" << TemplateArgString;
12315 if (PDiag && PDiag->second.getDiagID() ==
12316 diag::err_typename_nested_not_found_requirement) {
12318 diag::note_ovl_candidate_disabled_by_requirement)
12319 << PDiag->second.getStringArg(0) << TemplateArgString;
12329 SFINAEArgString =
": ";
12331 PDiag->second.EmitToString(S.
getDiagnostics(), SFINAEArgString);
12335 diag::note_ovl_candidate_substitution_failure)
12336 << TemplateArgString << SFINAEArgString << R;
12337 MaybeEmitInheritedConstructorNote(S,
Found);
12347 TemplateArgString =
" ";
12350 if (TemplateArgString.size() == 1)
12351 TemplateArgString.clear();
12354 S.
Diag(Templated->
getLocation(), diag::note_ovl_candidate_deduced_mismatch)
12357 << TemplateArgString
12382 diag::note_ovl_candidate_non_deduced_mismatch_qualified)
12398 diag::note_ovl_candidate_non_deduced_mismatch)
12399 << FirstTA << SecondTA;
12405 S.
Diag(Templated->
getLocation(), diag::note_ovl_candidate_bad_deduction);
12406 MaybeEmitInheritedConstructorNote(S,
Found);
12410 diag::note_cuda_ovl_candidate_target_mismatch);
12418 bool TakingCandidateAddress) {
12419 assert(Cand->
Function &&
"Candidate must be a function");
12434 assert(Cand->
Function &&
"Candidate must be a Function.");
12440 std::string FnDesc;
12441 std::pair<OverloadCandidateKind, OverloadCandidateSelect> FnKindPair =
12442 ClassifyOverloadCandidate(S, Cand->
FoundDecl, Callee,
12445 S.
Diag(Callee->getLocation(), diag::note_ovl_candidate_bad_target)
12446 << (
unsigned)FnKindPair.first << (
unsigned)ocs_non_template
12448 << CalleeTarget << CallerTarget;
12453 if (Meth !=
nullptr && Meth->
isImplicit()) {
12457 switch (FnKindPair.first) {
12460 case oc_implicit_default_constructor:
12463 case oc_implicit_copy_constructor:
12466 case oc_implicit_move_constructor:
12469 case oc_implicit_copy_assignment:
12472 case oc_implicit_move_assignment:
12477 bool ConstRHS =
false;
12481 ConstRHS = RT->getPointeeType().isConstQualified();
12492 assert(Cand->
Function &&
"Candidate must be a function");
12496 S.
Diag(Callee->getLocation(),
12497 diag::note_ovl_candidate_disabled_by_function_cond_attr)
12498 <<
Attr->getCond()->getSourceRange() <<
Attr->getMessage();
12502 assert(Cand->
Function &&
"Candidate must be a function");
12505 assert(ES.
isExplicit() &&
"not an explicit candidate");
12508 switch (Fn->getDeclKind()) {
12509 case Decl::Kind::CXXConstructor:
12512 case Decl::Kind::CXXConversion:
12515 case Decl::Kind::CXXDeductionGuide:
12516 Kind = Fn->isImplicit() ? 0 : 2;
12519 llvm_unreachable(
"invalid Decl");
12528 First = Pattern->getFirstDecl();
12531 diag::note_ovl_candidate_explicit)
12532 << Kind << (ES.
getExpr() ? 1 : 0)
12537 auto *DG = dyn_cast<CXXDeductionGuideDecl>(Fn);
12544 if (!(DG->isImplicit() || (OriginTemplate && OriginTemplate->
isTypeAlias())))
12546 std::string FunctionProto;
12547 llvm::raw_string_ostream OS(FunctionProto);
12560 "Non-template implicit deduction guides are only possible for "
12563 S.
Diag(DG->getLocation(), diag::note_implicit_deduction_guide)
12568 assert(
Template &&
"Cannot find the associated function template of "
12569 "CXXDeductionGuideDecl?");
12572 S.
Diag(DG->getLocation(), diag::note_implicit_deduction_guide)
12593 bool TakingCandidateAddress,
12595 assert(Cand->
Function &&
"Candidate must be a function");
12603 if (S.
getLangOpts().OpenCL && Fn->isImplicit() &&
12610 !Fn->hasCXXExplicitFunctionObjectParameter() && !Fn->isStatic())
12615 if (Fn->isDeleted()) {
12616 std::string FnDesc;
12617 std::pair<OverloadCandidateKind, OverloadCandidateSelect> FnKindPair =
12618 ClassifyOverloadCandidate(S, Cand->
FoundDecl, Fn,
12621 S.
Diag(Fn->getLocation(), diag::note_ovl_candidate_deleted)
12622 << (
unsigned)FnKindPair.first << (
unsigned)FnKindPair.second << FnDesc
12623 << (Fn->isDeleted() ? (Fn->isDeletedAsWritten() ? 1 : 2) : 0);
12624 MaybeEmitInheritedConstructorNote(S, Cand->
FoundDecl);
12651 TakingCandidateAddress);
12654 S.
Diag(Fn->getLocation(), diag::note_ovl_candidate_illegal_constructor)
12655 << (Fn->getPrimaryTemplate() ? 1 : 0);
12656 MaybeEmitInheritedConstructorNote(S, Cand->
FoundDecl);
12663 S.
Diag(Fn->getLocation(),
12664 diag::note_ovl_candidate_illegal_constructor_adrspace_mismatch)
12665 << QualsForPrinting;
12666 MaybeEmitInheritedConstructorNote(S, Cand->
FoundDecl);
12677 for (
unsigned N = Cand->
Conversions.size(); I != N; ++I)
12700 S.
Diag(Fn->getLocation(),
12701 diag::note_ovl_candidate_inherited_constructor_slice)
12702 << (Fn->getPrimaryTemplate() ? 1 : 0)
12703 << Fn->getParamDecl(0)->getType()->isRValueReferenceType();
12704 MaybeEmitInheritedConstructorNote(S, Cand->
FoundDecl);
12710 assert(!Available);
12718 std::string FnDesc;
12719 std::pair<OverloadCandidateKind, OverloadCandidateSelect> FnKindPair =
12720 ClassifyOverloadCandidate(S, Cand->
FoundDecl, Fn,
12723 S.
Diag(Fn->getLocation(),
12724 diag::note_ovl_candidate_constraints_not_satisfied)
12725 << (
unsigned)FnKindPair.first << (
unsigned)ocs_non_template
12744 bool isLValueReference =
false;
12745 bool isRValueReference =
false;
12746 bool isPointer =
false;
12750 isLValueReference =
true;
12754 isRValueReference =
true;
12770 diag::note_ovl_surrogate_constraints_not_satisfied)
12784 assert(Cand->
Conversions.size() <= 2 &&
"builtin operator is not binary");
12785 std::string TypeStr(
"operator");
12791 S.
Diag(OpLoc, diag::note_ovl_builtin_candidate) << TypeStr;
12796 S.
Diag(OpLoc, diag::note_ovl_builtin_candidate) << TypeStr;
12803 if (ICS.
isBad())
break;
12807 S, OpLoc, S.
PDiag(diag::note_ambiguous_type_conversion));
12824 llvm_unreachable(
"non-deduction failure while diagnosing bad deduction");
12854 llvm_unreachable(
"Unhandled deduction result");
12859struct CompareOverloadCandidatesForDisplay {
12861 SourceLocation Loc;
12865 CompareOverloadCandidatesForDisplay(
12866 Sema &S, SourceLocation Loc,
size_t NArgs,
12868 : S(S), NumArgs(NArgs), CSK(CSK) {}
12878 if (NumArgs >
C->Function->getNumParams() && !
C->Function->isVariadic())
12880 if (NumArgs < C->
Function->getMinRequiredArguments())
12887 bool operator()(
const OverloadCandidate *L,
12888 const OverloadCandidate *R) {
12890 if (L == R)
return false;
12894 if (!R->
Viable)
return true;
12896 if (
int Ord = CompareConversions(*L, *R))
12916 if (LDist == RDist) {
12917 if (LFailureKind == RFailureKind)
12925 return LDist < RDist;
12943 numLFixes = (numLFixes == 0) ?
UINT_MAX : numLFixes;
12944 numRFixes = (numRFixes == 0) ?
UINT_MAX : numRFixes;
12945 if (numLFixes != numRFixes) {
12946 return numLFixes < numRFixes;
12950 if (
int Ord = CompareConversions(*L, *R))
12962 if (LRank != RRank)
12963 return LRank < RRank;
12989 struct ConversionSignals {
12990 unsigned KindRank = 0;
12993 static ConversionSignals ForSequence(ImplicitConversionSequence &
Seq) {
12994 ConversionSignals Sig;
12995 Sig.KindRank =
Seq.getKindRank();
12996 if (
Seq.isStandard())
12997 Sig.Rank =
Seq.Standard.getRank();
12998 else if (
Seq.isUserDefined())
12999 Sig.Rank =
Seq.UserDefined.After.getRank();
13005 static ConversionSignals ForObjectArgument() {
13015 int CompareConversions(
const OverloadCandidate &L,
13016 const OverloadCandidate &R) {
13021 for (
unsigned I = 0, N = L.
Conversions.size(); I != N; ++I) {
13023 ? ConversionSignals::ForObjectArgument()
13024 : ConversionSignals::ForSequence(L.Conversions[I]);
13026 ? ConversionSignals::ForObjectArgument()
13027 : ConversionSignals::ForSequence(R.Conversions[I]);
13028 if (std::tie(LS.KindRank, LS.Rank) != std::tie(RS.KindRank, RS.Rank))
13029 return std::tie(LS.KindRank, LS.Rank) < std::tie(RS.KindRank, RS.Rank)
13054 bool Unfixable =
false;
13060 for (
unsigned ConvIdx =
13064 assert(ConvIdx != ConvCount &&
"no bad conversion in candidate");
13065 if (Cand->
Conversions[ConvIdx].isInitialized() &&
13074 bool SuppressUserConversions =
false;
13076 unsigned ConvIdx = 0;
13077 unsigned ArgIdx = 0;
13106 assert(ConvCount <= 3);
13112 ConvIdx != ConvCount && ArgIdx < Args.size();
13114 if (Cand->
Conversions[ConvIdx].isInitialized()) {
13116 }
else if (
ParamIdx < ParamTypes.size()) {
13117 if (ParamTypes[
ParamIdx]->isDependentType())
13118 Cand->
Conversions[ConvIdx].setAsIdentityConversion(
13123 SuppressUserConversions,
13128 if (!Unfixable && Cand->
Conversions[ConvIdx].isBad())
13147 for (
iterator Cand = Candidates.begin(), LastCand = Candidates.end();
13148 Cand != LastCand; ++Cand) {
13149 if (!Filter(*Cand))
13174 Cands.push_back(Cand);
13178 Cands, CompareOverloadCandidatesForDisplay(S, OpLoc, Args.size(), Kind));
13185 bool DeferHint =
false;
13189 auto WrongSidedCands =
13191 return (Cand.
Viable ==
false &&
13197 DeferHint = !WrongSidedCands.empty();
13215 bool NoteCands =
true;
13216 for (
const Expr *Arg : Args) {
13217 if (Arg->getType()->isWebAssemblyTableType())
13226 {Candidates.begin(), Candidates.end()});
13232 bool ReportedAmbiguousConversions =
false;
13235 unsigned CandsShown = 0;
13236 auto I = Cands.begin(), E = Cands.end();
13237 for (; I != E; ++I) {
13253 "Non-viable built-in candidates are not added to Cands.");
13260 if (!ReportedAmbiguousConversions) {
13262 ReportedAmbiguousConversions =
true;
13275 S.
Diag(OpLoc, diag::note_ovl_too_many_candidates,
13287struct CompareTemplateSpecCandidatesForDisplay {
13289 CompareTemplateSpecCandidatesForDisplay(Sema &S) : S(S) {}
13291 bool operator()(
const TemplateSpecCandidate *L,
13292 const TemplateSpecCandidate *R) {
13323 bool ForTakingAddress) {
13328void TemplateSpecCandidateSet::destroyCandidates() {
13330 i->DeductionFailure.Destroy();
13335 destroyCandidates();
13336 Candidates.clear();
13349 Cands.reserve(
size());
13350 for (
iterator Cand =
begin(), LastCand =
end(); Cand != LastCand; ++Cand) {
13351 if (Cand->Specialization)
13352 Cands.push_back(Cand);
13357 llvm::sort(Cands, CompareTemplateSpecCandidatesForDisplay(S));
13364 unsigned CandsShown = 0;
13365 for (I = Cands.begin(), E = Cands.end(); I != E; ++I) {
13371 if (CandsShown >= 4 && ShowOverloads ==
Ovl_Best)
13376 "Non-matching built-in candidates are not added to Cands.");
13381 S.
Diag(Loc, diag::note_ovl_too_many_candidates) <<
int(E - I);
13391 QualType Ret = PossiblyAFunctionType;
13394 Ret = ToTypePtr->getPointeeType();
13397 Ret = ToTypeRef->getPointeeType();
13400 Ret = MemTypePtr->getPointeeType();
13402 Context.getCanonicalType(Ret).getUnqualifiedType();
13407 bool Complain =
true) {
13424class AddressOfFunctionResolver {
13427 const QualType& TargetType;
13428 QualType TargetFunctionType;
13432 ASTContext& Context;
13434 bool TargetTypeIsNonStaticMemberFunction;
13435 bool FoundNonTemplateFunction;
13436 bool StaticMemberFunctionFromBoundPointer;
13437 bool HasComplained;
13439 OverloadExpr::FindResult OvlExprInfo;
13440 OverloadExpr *OvlExpr;
13441 TemplateArgumentListInfo OvlExplicitTemplateArgs;
13442 SmallVector<std::pair<DeclAccessPair, FunctionDecl*>, 4> Matches;
13443 TemplateSpecCandidateSet FailedCandidates;
13446 AddressOfFunctionResolver(Sema &S, Expr *SourceExpr,
13447 const QualType &TargetType,
bool Complain)
13448 : S(S), SourceExpr(SourceExpr), TargetType(TargetType),
13449 Complain(Complain), Context(S.getASTContext()),
13450 TargetTypeIsNonStaticMemberFunction(
13451 !!TargetType->getAs<MemberPointerType>()),
13452 FoundNonTemplateFunction(
false),
13453 StaticMemberFunctionFromBoundPointer(
false),
13454 HasComplained(
false),
13455 OvlExprInfo(OverloadExpr::find(SourceExpr)),
13457 FailedCandidates(OvlExpr->getNameLoc(),
true) {
13458 ExtractUnqualifiedFunctionTypeFromTargetType();
13461 if (UnresolvedMemberExpr *UME = dyn_cast<UnresolvedMemberExpr>(OvlExpr))
13462 if (!UME->isImplicitAccess() &&
13464 StaticMemberFunctionFromBoundPointer =
true;
13466 DeclAccessPair dap;
13468 OvlExpr,
false, &dap)) {
13469 if (CXXMethodDecl *
Method = dyn_cast<CXXMethodDecl>(Fn))
13470 if (!
Method->isStatic()) {
13474 TargetTypeIsNonStaticMemberFunction =
true;
13482 Matches.push_back(std::make_pair(dap, Fn));
13490 if (FindAllFunctionsThatMatchTargetTypeExactly()) {
13493 if (Matches.size() > 1 && !eliminiateSuboptimalOverloadCandidates()) {
13494 if (FoundNonTemplateFunction) {
13495 EliminateAllTemplateMatches();
13496 EliminateLessPartialOrderingConstrainedMatches();
13498 EliminateAllExceptMostSpecializedTemplate();
13503 EliminateSuboptimalCudaMatches();
13506 bool hasComplained()
const {
return HasComplained; }
13509 bool candidateHasExactlyCorrectType(
const FunctionDecl *FD) {
13516 bool isBetterCandidate(
const FunctionDecl *A,
const FunctionDecl *B) {
13520 return candidateHasExactlyCorrectType(A) &&
13521 (!candidateHasExactlyCorrectType(B) ||
13527 bool eliminiateSuboptimalOverloadCandidates() {
13530 auto Best = Matches.begin();
13531 for (
auto I = Matches.begin()+1, E = Matches.end(); I != E; ++I)
13532 if (isBetterCandidate(I->second, Best->second))
13535 const FunctionDecl *BestFn = Best->second;
13536 auto IsBestOrInferiorToBest = [
this, BestFn](
13537 const std::pair<DeclAccessPair, FunctionDecl *> &Pair) {
13538 return BestFn == Pair.second || isBetterCandidate(BestFn, Pair.second);
13543 if (!llvm::all_of(Matches, IsBestOrInferiorToBest))
13545 Matches[0] = *Best;
13550 bool isTargetTypeAFunction()
const {
13559 void inline ExtractUnqualifiedFunctionTypeFromTargetType() {
13565 const DeclAccessPair& CurAccessFunPair) {
13566 if (CXXMethodDecl *
Method
13570 bool CanConvertToFunctionPointer =
13571 Method->isStatic() ||
Method->isExplicitObjectMemberFunction();
13572 if (CanConvertToFunctionPointer == TargetTypeIsNonStaticMemberFunction)
13575 else if (TargetTypeIsNonStaticMemberFunction)
13585 TemplateDeductionInfo Info(FailedCandidates.
getLocation());
13589 Result != TemplateDeductionResult::Success) {
13607 Matches.push_back(std::make_pair(CurAccessFunPair,
Specialization));
13611 bool AddMatchingNonTemplateFunction(NamedDecl* Fn,
13612 const DeclAccessPair& CurAccessFunPair) {
13613 if (CXXMethodDecl *
Method = dyn_cast<CXXMethodDecl>(Fn)) {
13616 bool CanConvertToFunctionPointer =
13617 Method->isStatic() ||
Method->isExplicitObjectMemberFunction();
13618 if (CanConvertToFunctionPointer == TargetTypeIsNonStaticMemberFunction)
13621 else if (TargetTypeIsNonStaticMemberFunction)
13624 if (FunctionDecl *FunDecl = dyn_cast<FunctionDecl>(Fn)) {
13631 if (FunDecl->isMultiVersion()) {
13632 const auto *TA = FunDecl->getAttr<TargetAttr>();
13633 if (TA && !TA->isDefaultVersion())
13635 const auto *TVA = FunDecl->getAttr<TargetVersionAttr>();
13636 if (TVA && !TVA->isDefaultVersion())
13644 HasComplained |= Complain;
13653 candidateHasExactlyCorrectType(FunDecl)) {
13654 Matches.push_back(std::make_pair(
13656 FoundNonTemplateFunction =
true;
13664 bool FindAllFunctionsThatMatchTargetTypeExactly() {
13669 if (IsInvalidFormOfPointerToMemberFunction())
13672 for (UnresolvedSetIterator I = OvlExpr->
decls_begin(),
13676 NamedDecl *
Fn = (*I)->getUnderlyingDecl();
13685 = dyn_cast<FunctionTemplateDecl>(Fn)) {
13691 AddMatchingNonTemplateFunction(Fn, I.getPair()))
13694 assert(Ret || Matches.empty());
13698 void EliminateAllExceptMostSpecializedTemplate() {
13710 UnresolvedSet<4> MatchesCopy;
13711 for (
unsigned I = 0, E = Matches.size(); I != E; ++I)
13712 MatchesCopy.
addDecl(Matches[I].second, Matches[I].first.getAccess());
13717 MatchesCopy.
begin(), MatchesCopy.
end(), FailedCandidates,
13719 S.
PDiag(diag::err_addr_ovl_ambiguous)
13720 << Matches[0].second->getDeclName(),
13721 S.
PDiag(diag::note_ovl_candidate)
13722 << (
unsigned)oc_function << (
unsigned)ocs_described_template,
13723 Complain, TargetFunctionType);
13727 Matches[0].first = Matches[
Result - MatchesCopy.
begin()].first;
13731 HasComplained |= Complain;
13734 void EliminateAllTemplateMatches() {
13737 for (
unsigned I = 0, N = Matches.size(); I != N; ) {
13738 if (Matches[I].second->getPrimaryTemplate() ==
nullptr)
13741 Matches[I] = Matches[--N];
13747 void EliminateLessPartialOrderingConstrainedMatches() {
13752 assert(Matches[0].second->getPrimaryTemplate() ==
nullptr &&
13753 "Call EliminateAllTemplateMatches() first");
13754 SmallVector<std::pair<DeclAccessPair, FunctionDecl *>, 4> Results;
13755 Results.push_back(Matches[0]);
13756 for (
unsigned I = 1, N = Matches.size(); I < N; ++I) {
13757 assert(Matches[I].second->getPrimaryTemplate() ==
nullptr);
13759 S, Matches[I].second, Results[0].second,
13763 Results.push_back(Matches[I]);
13766 if (F == Matches[I].second) {
13768 Results.push_back(Matches[I]);
13771 std::swap(Matches, Results);
13774 void EliminateSuboptimalCudaMatches() {
13780 void ComplainNoMatchesFound()
const {
13781 assert(Matches.empty());
13783 << OvlExpr->
getName() << TargetFunctionType
13785 if (FailedCandidates.
empty())
13792 for (UnresolvedSetIterator I = OvlExpr->
decls_begin(),
13795 if (FunctionDecl *Fun =
13796 dyn_cast<FunctionDecl>((*I)->getUnderlyingDecl()))
13804 bool IsInvalidFormOfPointerToMemberFunction()
const {
13805 return TargetTypeIsNonStaticMemberFunction &&
13809 void ComplainIsInvalidFormOfPointerToMemberFunction()
const {
13817 bool IsStaticMemberFunctionFromBoundPointer()
const {
13818 return StaticMemberFunctionFromBoundPointer;
13821 void ComplainIsStaticMemberFunctionFromBoundPointer()
const {
13823 diag::err_invalid_form_pointer_member_function)
13827 void ComplainOfInvalidConversion()
const {
13829 << OvlExpr->
getName() << TargetType;
13832 void ComplainMultipleMatchesFound()
const {
13833 assert(Matches.size() > 1);
13840 bool hadMultipleCandidates()
const {
return (OvlExpr->
getNumDecls() > 1); }
13842 int getNumMatches()
const {
return Matches.size(); }
13844 FunctionDecl* getMatchingFunctionDecl()
const {
13845 if (Matches.size() != 1)
return nullptr;
13846 return Matches[0].second;
13849 const DeclAccessPair* getMatchingFunctionAccessPair()
const {
13850 if (Matches.size() != 1)
return nullptr;
13851 return &Matches[0].first;
13861 bool *pHadMultipleCandidates) {
13864 AddressOfFunctionResolver Resolver(*
this, AddressOfExpr, TargetType,
13866 int NumMatches = Resolver.getNumMatches();
13868 bool ShouldComplain = Complain && !Resolver.hasComplained();
13869 if (NumMatches == 0 && ShouldComplain) {
13870 if (Resolver.IsInvalidFormOfPointerToMemberFunction())
13871 Resolver.ComplainIsInvalidFormOfPointerToMemberFunction();
13873 Resolver.ComplainNoMatchesFound();
13875 else if (NumMatches > 1 && ShouldComplain)
13876 Resolver.ComplainMultipleMatchesFound();
13877 else if (NumMatches == 1) {
13878 Fn = Resolver.getMatchingFunctionDecl();
13882 FoundResult = *Resolver.getMatchingFunctionAccessPair();
13884 if (Resolver.IsStaticMemberFunctionFromBoundPointer())
13885 Resolver.ComplainIsStaticMemberFunctionFromBoundPointer();
13891 if (pHadMultipleCandidates)
13892 *pHadMultipleCandidates = Resolver.hadMultipleCandidates();
13900 bool IsResultAmbiguous =
false;
13908 return static_cast<int>(
CUDA().IdentifyPreference(Caller, FD1)) -
13909 static_cast<int>(
CUDA().IdentifyPreference(Caller, FD2));
13916 auto *FD = dyn_cast<FunctionDecl>(I->getUnderlyingDecl());
13924 auto FoundBetter = [&]() {
13925 IsResultAmbiguous =
false;
13937 int PreferenceByCUDA = CheckCUDAPreference(FD,
Result);
13939 if (PreferenceByCUDA != 0) {
13941 if (PreferenceByCUDA > 0)
13957 if (MoreConstrained != FD) {
13958 if (!MoreConstrained) {
13959 IsResultAmbiguous =
true;
13960 AmbiguousDecls.push_back(FD);
13969 if (IsResultAmbiguous)
13990 ExprResult &SrcExpr,
bool DoFunctionPointerConversion) {
13992 assert(E->
getType() ==
Context.OverloadTy &&
"SrcExpr must be an overload");
13996 if (!
Found ||
Found->isCPUDispatchMultiVersion() ||
13997 Found->isCPUSpecificMultiVersion())
14045 dyn_cast<FunctionTemplateDecl>((*I)->getUnderlyingDecl());
14076 if (ForTypeDeduction &&
14090 if (FoundResult) *FoundResult = I.getPair();
14101 ExprResult &SrcExpr,
bool doFunctionPointerConversion,
bool complain,
14103 unsigned DiagIDForComplaining) {
14124 if (!complain)
return false;
14127 diag::err_bound_member_function)
14140 SingleFunctionExpression =
14144 if (doFunctionPointerConversion) {
14145 SingleFunctionExpression =
14147 if (SingleFunctionExpression.
isInvalid()) {
14154 if (!SingleFunctionExpression.
isUsable()) {
14156 Diag(OpRangeForComplaining.
getBegin(), DiagIDForComplaining)
14158 << DestTypeForComplaining
14159 << OpRangeForComplaining
14170 SrcExpr = SingleFunctionExpression;
14180 bool PartialOverloading,
14187 if (ExplicitTemplateArgs) {
14188 assert(!KnownValid &&
"Explicit template arguments?");
14197 PartialOverloading);
14202 = dyn_cast<FunctionTemplateDecl>(Callee)) {
14204 ExplicitTemplateArgs, Args, CandidateSet,
14206 PartialOverloading);
14210 assert(!KnownValid &&
"unhandled case in overloaded call candidate");
14216 bool PartialOverloading) {
14239 assert(!(*I)->getDeclContext()->isRecord());
14241 !(*I)->getDeclContext()->isFunctionOrMethod());
14242 assert((*I)->getUnderlyingDecl()->isFunctionOrFunctionTemplate());
14252 ExplicitTemplateArgs = &TABuffer;
14258 CandidateSet, PartialOverloading,
14263 Args, ExplicitTemplateArgs,
14264 CandidateSet, PartialOverloading);
14272 CandidateSet,
false,
false);
14279 case OO_New:
case OO_Array_New:
14280 case OO_Delete:
case OO_Array_Delete:
14303 if (DC->isTransparentContext())
14319 if (
auto *RD = dyn_cast<CXXRecordDecl>(DC)) {
14324 if (FoundInClass) {
14325 *FoundInClass = RD;
14328 R.
addDecl(Best->FoundDecl.getDecl(), Best->FoundDecl.getAccess());
14345 AssociatedNamespaces,
14346 AssociatedClasses);
14350 for (Sema::AssociatedNamespaceSet::iterator
14351 it = AssociatedNamespaces.begin(),
14352 end = AssociatedNamespaces.end(); it !=
end; ++it) {
14364 SuggestedNamespaces.insert(*it);
14368 SemaRef.
Diag(R.
getNameLoc(), diag::err_not_found_by_two_phase_lookup)
14370 if (SuggestedNamespaces.empty()) {
14371 SemaRef.
Diag(Best->Function->getLocation(),
14372 diag::note_not_found_by_two_phase_lookup)
14374 }
else if (SuggestedNamespaces.size() == 1) {
14375 SemaRef.
Diag(Best->Function->getLocation(),
14376 diag::note_not_found_by_two_phase_lookup)
14382 SemaRef.
Diag(Best->Function->getLocation(),
14383 diag::note_not_found_by_two_phase_lookup)
14415class BuildRecoveryCallExprRAII {
14417 Sema::SatisfactionStackResetRAII SatStack;
14420 BuildRecoveryCallExprRAII(Sema &S) : SemaRef(S), SatStack(S) {
14442 bool EmptyLookup,
bool AllowTypoCorrection) {
14450 BuildRecoveryCallExprRAII RCE(SemaRef);
14460 ExplicitTemplateArgs = &TABuffer;
14468 ExplicitTemplateArgs, Args, &FoundInClass)) {
14470 }
else if (EmptyLookup) {
14475 ExplicitTemplateArgs !=
nullptr,
14476 dyn_cast<MemberExpr>(Fn));
14478 AllowTypoCorrection
14484 }
else if (FoundInClass && SemaRef.
getLangOpts().MSVCCompat) {
14499 assert(!R.
empty() &&
"lookup results empty despite recovery");
14510 if ((*R.
begin())->isCXXClassMember())
14512 ExplicitTemplateArgs, S);
14513 else if (ExplicitTemplateArgs || TemplateKWLoc.
isValid())
14515 ExplicitTemplateArgs);
14539 assert(!ULE->
getQualifier() &&
"qualified name with ADL");
14546 (F = dyn_cast<FunctionDecl>(*ULE->
decls_begin())) &&
14548 llvm_unreachable(
"performing ADL for builtin");
14555 UnbridgedCastsSet UnbridgedCasts;
14570 if (CandidateSet->
empty() ||
14586 if (CandidateSet->
empty())
14589 UnbridgedCasts.restore();
14596 std::optional<QualType> Result;
14608 else if (Result !=
T)
14616 if (Best && *Best != CS.
end())
14617 ConsiderCandidate(**Best);
14620 for (
const auto &
C : CS)
14622 ConsiderCandidate(
C);
14625 for (
const auto &
C : CS)
14626 ConsiderCandidate(
C);
14630 auto Value = *Result;
14631 if (
Value.isNull() ||
Value->isUndeducedType())
14648 bool AllowTypoCorrection) {
14649 switch (OverloadResult) {
14660 Res.
get(), FDecl, LParenLoc, Args, RParenLoc, ExecConfig,
14666 if (*Best != CandidateSet->
end() &&
14670 dyn_cast_if_present<CXXMethodDecl>((*Best)->Function);
14675 SemaRef.
PDiag(diag::err_member_call_without_object) << 0 << M),
14685 CandidateSet->
empty(),
14686 AllowTypoCorrection);
14693 for (
const Expr *Arg : Args) {
14694 if (!Arg->getType()->isFunctionType())
14696 if (
auto *DRE = dyn_cast<DeclRefExpr>(Arg->IgnoreParenImpCasts())) {
14697 auto *FD = dyn_cast<FunctionDecl>(DRE->getDecl());
14700 Arg->getExprLoc()))
14708 SemaRef.
PDiag(diag::err_ovl_no_viable_function_in_call)
14709 << ULE->
getName() << Fn->getSourceRange()),
14717 SemaRef.
PDiag(diag::err_ovl_ambiguous_call)
14718 << ULE->
getName() << Fn->getSourceRange()),
14725 Fn->getSourceRange(), ULE->
getName(),
14726 *CandidateSet, FDecl, Args);
14735 Res.
get(), FDecl, LParenLoc, Args, RParenLoc, ExecConfig,
14743 SubExprs.append(Args.begin(), Args.end());
14750 for (
auto I = CS.
begin(), E = CS.
end(); I != E; ++I) {
14765 bool AllowTypoCorrection,
14766 bool CalleesAddressIsTaken) {
14781 if (CalleesAddressIsTaken)
14792 Best != CandidateSet.
end()) {
14793 if (
auto *M = dyn_cast_or_null<CXXMethodDecl>(Best->Function);
14794 M && M->isImplicitObjectMemberFunction()) {
14805 CUDA().recordPotentialODRUsedVariable(Args, CandidateSet);
14823 if (
const auto *TP =
14833 ExecConfig, &CandidateSet, &Best,
14834 OverloadResult, AllowTypoCorrection);
14843 Context, NamingClass, NNSLoc, DNI, PerformADL, Fns.
begin(), Fns.
end(),
14849 bool HadMultipleCandidates) {
14859 if (
Method->isExplicitObjectMemberFunction())
14863 E, std::nullopt, FoundDecl,
Method);
14867 if (
Method->getParent()->isLambda() &&
14868 Method->getConversionType()->isBlockPointerType()) {
14872 auto *CE = dyn_cast<CastExpr>(SubE);
14873 if (CE && CE->getCastKind() == CK_NoOp)
14874 SubE = CE->getSubExpr();
14876 if (
auto *BE = dyn_cast<CXXBindTemporaryExpr>(SubE))
14877 SubE = BE->getSubExpr();
14900 if (
Method->isExplicitObjectMemberFunction()) {
14906 Expr *ObjectParam = Exp.
get();
14920 Exp.
get()->getEndLoc(),
14934 Expr *Input,
bool PerformADL) {
14936 assert(Op !=
OO_None &&
"Invalid opcode for overloaded unary operator");
14944 Expr *Args[2] = { Input,
nullptr };
14945 unsigned NumArgs = 1;
14950 if (Opc == UO_PostInc || Opc == UO_PostDec) {
14964 if (Opc == UO_PreDec || Opc == UO_PreInc || Opc == UO_Deref)
14975 if (Fn.isInvalid())
15001 bool HadMultipleCandidates = (CandidateSet.
size() > 1);
15020 if (
Method->isExplicitObjectMemberFunction())
15024 Input, std::nullopt, Best->FoundDecl,
Method);
15027 Base = Input = InputInit.
get();
15038 Input = InputInit.
get();
15043 Base, HadMultipleCandidates,
15055 Context, Op, FnExpr.
get(), ArgsArray, ResultTy,
VK, OpLoc,
15071 Input, Best->BuiltinParamTypes[0], Best->Conversions[0],
15076 Input = InputRes.
get();
15096 PDiag(diag::err_ovl_ambiguous_oper_unary)
15113 << (Msg !=
nullptr)
15114 << (Msg ? Msg->
getString() : StringRef())
15167 if (Op != OO_Equal && PerformADL) {
15174 Context.DeclarationNames.getCXXOperatorName(ExtraOp);
15200 Expr *RHS,
bool PerformADL,
15201 bool AllowRewrittenCandidates,
15203 Expr *Args[2] = { LHS, RHS };
15207 AllowRewrittenCandidates =
false;
15213 if (Args[0]->isTypeDependent() || Args[1]->isTypeDependent()) {
15234 if (Fn.isInvalid())
15243 if (Opc == BO_PtrMemD) {
15244 auto CheckPlaceholder = [&](
Expr *&Arg) {
15253 if (CheckPlaceholder(Args[0]) || CheckPlaceholder(Args[1]))
15274 if (Opc == BO_Assign && !Args[0]->
getType()->isOverloadableType())
15280 Op, OpLoc, AllowRewrittenCandidates));
15282 CandidateSet.
exclude(DefaultedFn);
15285 bool HadMultipleCandidates = (CandidateSet.
size() > 1);
15294 bool IsReversed = Best->isReversed();
15296 std::swap(Args[0], Args[1]);
15313 if (Best->RewriteKind && ChosenOp == OO_EqualEqual &&
15317 Diag(OpLoc, IsExtension ? diag::ext_ovl_rewrite_equalequal_not_bool
15318 : diag::err_ovl_rewrite_equalequal_not_bool)
15326 if (AllowRewrittenCandidates && !IsReversed &&
15336 for (
unsigned ArgIdx = 0; ArgIdx < 2; ++ArgIdx) {
15339 Best->Conversions[ArgIdx]) ==
15341 AmbiguousWith.push_back(Cand.
Function);
15348 if (!AmbiguousWith.empty()) {
15349 bool AmbiguousWithSelf =
15350 AmbiguousWith.size() == 1 &&
15352 Diag(OpLoc, diag::ext_ovl_ambiguous_oper_binary_reversed)
15354 << Args[0]->
getType() << Args[1]->
getType() << AmbiguousWithSelf
15356 if (AmbiguousWithSelf) {
15358 diag::note_ovl_ambiguous_oper_binary_reversed_self);
15363 if (
auto *MD = dyn_cast<CXXMethodDecl>(FnDecl))
15364 if (Op == OverloadedOperatorKind::OO_EqualEqual &&
15366 !MD->hasCXXExplicitFunctionObjectParameter() &&
15367 Context.hasSameUnqualifiedType(
15368 MD->getFunctionObjectParameterType(),
15369 MD->getParamDecl(0)->getType().getNonReferenceType()) &&
15370 Context.hasSameUnqualifiedType(
15371 MD->getFunctionObjectParameterType(),
15373 Context.hasSameUnqualifiedType(
15374 MD->getFunctionObjectParameterType(),
15377 diag::note_ovl_ambiguous_eqeq_reversed_self_non_const);
15380 diag::note_ovl_ambiguous_oper_binary_selected_candidate);
15381 for (
auto *F : AmbiguousWith)
15383 diag::note_ovl_ambiguous_oper_binary_reversed_candidate);
15391 if (Op == OO_Equal)
15402 if (
Method->isExplicitObjectMemberFunction()) {
15407 Args[0], std::nullopt, Best->FoundDecl,
Method);
15440 Best->FoundDecl,
Base,
15441 HadMultipleCandidates, OpLoc);
15452 const Expr *ImplicitThis =
nullptr;
15457 Context, ChosenOp, FnExpr.
get(), Args, ResultTy,
VK, OpLoc,
15461 if (
const auto *
Method = dyn_cast<CXXMethodDecl>(FnDecl);
15464 ImplicitThis = ArgsArray[0];
15465 ArgsArray = ArgsArray.slice(1);
15472 if (Op == OO_Equal) {
15477 *
this,
AssignedEntity{Args[0], dyn_cast<CXXMethodDecl>(FnDecl)},
15480 if (ImplicitThis) {
15485 CheckArgAlignment(OpLoc, FnDecl,
"'this'", ThisType,
15489 checkCall(FnDecl,
nullptr, ImplicitThis, ArgsArray,
15504 (Op == OO_Spaceship && IsReversed)) {
15505 if (Op == OO_ExclaimEqual) {
15506 assert(ChosenOp == OO_EqualEqual &&
"unexpected operator name");
15509 assert(ChosenOp == OO_Spaceship &&
"unexpected operator name");
15511 Expr *ZeroLiteral =
15520 OpLoc, Opc, Fns, IsReversed ? ZeroLiteral : R.
get(),
15521 IsReversed ? R.
get() : ZeroLiteral,
true,
15529 assert(ChosenOp == Op &&
"unexpected operator name");
15533 if (Best->RewriteKind !=
CRK_None)
15542 Args[0], Best->BuiltinParamTypes[0], Best->Conversions[0],
15547 Args[0] = ArgsRes0.
get();
15550 Args[1], Best->BuiltinParamTypes[1], Best->Conversions[1],
15555 Args[1] = ArgsRes1.
get();
15565 if (Opc == BO_Comma)
15570 if (DefaultedFn && Opc == BO_Cmp) {
15572 Args[1], DefaultedFn);
15587 Opc >= BO_Assign && Opc <= BO_OrAssign) {
15588 Diag(OpLoc, diag::err_ovl_no_viable_oper)
15591 if (Args[0]->
getType()->isIncompleteType()) {
15592 Diag(OpLoc, diag::note_assign_lhs_incomplete)
15608 assert(
Result.isInvalid() &&
15609 "C++ binary operator overloading is missing candidates!");
15620 << Args[0]->getSourceRange()
15621 << Args[1]->getSourceRange()),
15631 Diag(OpLoc, diag::err_ovl_deleted_special_oper)
15635 Diag(OpLoc, diag::err_ovl_deleted_comparison)
15636 << Args[0]->
getType() << DeletedFD;
15649 PDiag(diag::err_ovl_deleted_oper)
15651 .getCXXOverloadedOperator())
15652 << (Msg !=
nullptr) << (Msg ? Msg->
getString() : StringRef())
15653 << Args[0]->getSourceRange() << Args[1]->getSourceRange()),
15677 "cannot use prvalue expressions more than once");
15678 Expr *OrigLHS = LHS;
15679 Expr *OrigRHS = RHS;
15696 true, DefaultedFn);
15697 if (
Less.isInvalid())
15724 for (; I >= 0; --I) {
15726 auto *VI = Info->lookupValueInfo(Comparisons[I].
Result);
15749 Context, OrigLHS, OrigRHS, BO_Cmp,
Result.get()->getType(),
15750 Result.get()->getValueKind(),
Result.get()->getObjectKind(), OpLoc,
15752 Expr *SemanticForm[] = {LHS, RHS,
Result.get()};
15762 unsigned NumArgsSlots =
15763 MethodArgs.size() + std::max<unsigned>(Args.size(), NumParams);
15766 MethodArgs.reserve(MethodArgs.size() + NumArgsSlots);
15767 bool IsError =
false;
15770 for (
unsigned i = 0; i != NumParams; i++) {
15772 if (i < Args.size()) {
15776 S.
Context, Method->getParamDecl(i)),
15790 MethodArgs.push_back(Arg);
15800 Args.push_back(
Base);
15801 for (
auto *e : ArgExpr) {
15805 Context.DeclarationNames.getCXXOperatorName(OO_Subscript);
15810 ArgExpr.back()->getEndLoc());
15822 if (Fn.isInvalid())
15832 UnbridgedCastsSet UnbridgedCasts;
15845 if (Args.size() == 2)
15848 bool HadMultipleCandidates = (CandidateSet.
size() > 1);
15868 if (
Method->isExplicitObjectMemberFunction()) {
15873 Args[0] = Res.
get();
15877 Args[0], std::nullopt, Best->FoundDecl,
Method);
15881 MethodArgs.push_back(Arg0.
get());
15885 *
this, MethodArgs,
Method, ArgExpr, LLoc);
15893 *
this, FnDecl, Best->FoundDecl,
Base, HadMultipleCandidates,
15904 Context, OO_Subscript, FnExpr.
get(), MethodArgs, ResultTy,
VK, RLoc,
15921 Args[0], Best->BuiltinParamTypes[0], Best->Conversions[0],
15926 Args[0] = ArgsRes0.
get();
15929 Args[1], Best->BuiltinParamTypes[1], Best->Conversions[1],
15934 Args[1] = ArgsRes1.
get();
15942 CandidateSet.
empty()
15943 ? (
PDiag(diag::err_ovl_no_oper)
15944 << Args[0]->getType() << 0
15945 << Args[0]->getSourceRange() << Range)
15946 : (
PDiag(diag::err_ovl_no_viable_subscript)
15947 << Args[0]->getType() << Args[0]->getSourceRange() << Range);
15954 if (Args.size() == 2) {
15957 LLoc,
PDiag(diag::err_ovl_ambiguous_oper_binary)
15959 << Args[0]->getSourceRange() << Range),
15964 PDiag(diag::err_ovl_ambiguous_subscript_call)
15966 << Args[0]->getSourceRange() << Range),
15975 PDiag(diag::err_ovl_deleted_oper)
15976 <<
"[]" << (Msg !=
nullptr)
15977 << (Msg ? Msg->
getString() : StringRef())
15978 << Args[0]->getSourceRange() << Range),
15992 Expr *ExecConfig,
bool IsExecConfig,
15993 bool AllowRecovery) {
16002 if (
BinaryOperator *op = dyn_cast<BinaryOperator>(NakedMemExpr)) {
16003 assert(op->getType() ==
Context.BoundMemberTy);
16004 assert(op->getOpcode() == BO_PtrMemD || op->getOpcode() == BO_PtrMemI);
16017 QualType objectType = op->getLHS()->getType();
16018 if (op->getOpcode() == BO_PtrMemI)
16022 Qualifiers difference = objectQuals - funcQuals;
16026 std::string qualsString = difference.
getAsString();
16027 Diag(LParenLoc, diag::err_pointer_to_member_call_drops_quals)
16030 << (qualsString.find(
' ') == std::string::npos ? 1 : 2);
16034 Context, MemExprE, Args, resultType, valueKind, RParenLoc,
16044 if (CheckOtherCall(call, proto))
16054 if (!AllowRecovery)
16056 std::vector<Expr *> SubExprs = {MemExprE};
16057 llvm::append_range(SubExprs, Args);
16065 UnbridgedCastsSet UnbridgedCasts;
16071 bool HadMultipleCandidates =
false;
16079 UnbridgedCasts.restore();
16097 TemplateArgs = &TemplateArgsBuffer;
16101 E = UnresExpr->
decls_end(); I != E; ++I) {
16103 QualType ExplicitObjectType = ObjectType;
16110 bool HasExplicitParameter =
false;
16111 if (
const auto *M = dyn_cast<FunctionDecl>(
Func);
16112 M && M->hasCXXExplicitFunctionObjectParameter())
16113 HasExplicitParameter =
true;
16114 else if (
const auto *M = dyn_cast<FunctionTemplateDecl>(
Func);
16116 M->getTemplatedDecl()->hasCXXExplicitFunctionObjectParameter())
16117 HasExplicitParameter =
true;
16119 if (HasExplicitParameter)
16127 }
else if ((
Method = dyn_cast<CXXMethodDecl>(
Func))) {
16134 ObjectClassification, Args, CandidateSet,
16138 I.getPair(), ActingDC, TemplateArgs,
16139 ExplicitObjectType, ObjectClassification,
16140 Args, CandidateSet,
16145 HadMultipleCandidates = (CandidateSet.
size() > 1);
16149 UnbridgedCasts.restore();
16152 bool Succeeded =
false;
16157 FoundDecl = Best->FoundDecl;
16177 PDiag(diag::err_ovl_no_viable_member_function_in_call)
16184 PDiag(diag::err_ovl_ambiguous_member_call)
16191 CandidateSet, Best->Function, Args,
true);
16202 MemExprE = Res.
get();
16206 if (
Method->isStatic()) {
16208 ExecConfig, IsExecConfig);
16218 assert(
Method &&
"Member call to something that isn't a method?");
16223 if (
Method->isExplicitObjectMemberFunction()) {
16231 HadMultipleCandidates, MemExpr->
getExprLoc());
16238 TheCall->setUsesMemberSyntax(
true);
16248 Proto->getNumParams());
16254 return BuildRecoveryExpr(ResultType);
16259 return BuildRecoveryExpr(ResultType);
16269 if (
auto *MemE = dyn_cast<MemberExpr>(NakedMemExpr)) {
16270 if (
const EnableIfAttr *
Attr =
16272 Diag(MemE->getMemberLoc(),
16273 diag::err_ovl_no_viable_member_function_in_call)
16276 diag::note_ovl_candidate_disabled_by_function_cond_attr)
16277 <<
Attr->getCond()->getSourceRange() <<
Attr->getMessage();
16283 TheCall->getDirectCallee()->isPureVirtual()) {
16289 diag::warn_call_to_pure_virtual_member_function_from_ctor_dtor)
16300 if (
auto *DD = dyn_cast<CXXDestructorDecl>(TheCall->getDirectCallee())) {
16304 CallCanBeVirtual,
true,
16309 TheCall->getDirectCallee());
16321 UnbridgedCastsSet UnbridgedCasts;
16325 assert(Object.get()->getType()->isRecordType() &&
16326 "Requires object type argument");
16340 diag::err_incomplete_object_call, Object.get()))
16343 auto *
Record = Object.get()->getType()->castAsCXXRecordDecl();
16349 Oper != OperEnd; ++Oper) {
16351 Object.get()->Classify(
Context), Args, CandidateSet,
16363 bool IgnoreSurrogateFunctions =
false;
16366 if (!Candidate.
Viable &&
16368 IgnoreSurrogateFunctions =
true;
16390 !IgnoreSurrogateFunctions && I != E; ++I) {
16412 Object.get(), Args, CandidateSet);
16417 bool HadMultipleCandidates = (CandidateSet.
size() > 1);
16430 CandidateSet.
empty()
16431 ? (
PDiag(diag::err_ovl_no_oper)
16432 << Object.get()->getType() << 1
16433 << Object.get()->getSourceRange())
16434 : (
PDiag(diag::err_ovl_no_viable_object_call)
16435 << Object.get()->getType() << Object.get()->getSourceRange());
16445 PDiag(diag::err_ovl_ambiguous_object_call)
16446 << Object.get()->getType()
16447 << Object.get()->getSourceRange()),
16458 PDiag(diag::err_ovl_deleted_object_call)
16459 << Object.get()->getType() << (Msg !=
nullptr)
16460 << (Msg ? Msg->
getString() : StringRef())
16461 << Object.get()->getSourceRange()),
16467 if (Best == CandidateSet.
end())
16470 UnbridgedCasts.restore();
16472 if (Best->Function ==
nullptr) {
16477 Best->Conversions[0].UserDefined.ConversionFunction);
16483 assert(Conv == Best->FoundDecl.getDecl() &&
16484 "Found Decl & conversion-to-functionptr should be same, right?!");
16492 Conv, HadMultipleCandidates);
16493 if (
Call.isInvalid())
16497 Context,
Call.get()->getType(), CK_UserDefinedConversion,
Call.get(),
16511 if (
Method->isInvalidDecl())
16518 Context.DeclarationNames.getCXXOperatorName(OO_Call), LParenLoc);
16521 Obj, HadMultipleCandidates,
16528 MethodArgs.reserve(NumParams + 1);
16530 bool IsError =
false;
16534 if (
Method->isExplicitObjectMemberFunction()) {
16538 Object.get(), std::nullopt, Best->FoundDecl,
Method);
16543 MethodArgs.push_back(Object.get());
16547 *
this, MethodArgs,
Method, Args, LParenLoc);
16550 if (Proto->isVariadic()) {
16552 for (
unsigned i = NumParams, e = Args.size(); i < e; i++) {
16556 MethodArgs.push_back(Arg.
get());
16571 Context, OO_Call, NewFn.
get(), MethodArgs, ResultTy,
VK, RParenLoc,
16585 bool *NoArrowOperatorFound) {
16586 assert(
Base->getType()->isRecordType() &&
16587 "left-hand side must have class type");
16601 Context.DeclarationNames.getCXXOperatorName(OO_Arrow);
16605 diag::err_typecheck_incomplete_tag,
Base))
16613 Oper != OperEnd; ++Oper) {
16619 bool HadMultipleCandidates = (CandidateSet.
size() > 1);
16630 if (CandidateSet.
empty()) {
16632 if (NoArrowOperatorFound) {
16635 *NoArrowOperatorFound =
true;
16638 Diag(OpLoc, diag::err_typecheck_member_reference_arrow)
16639 << BaseType <<
Base->getSourceRange();
16640 if (BaseType->isRecordType() && !BaseType->isPointerType()) {
16641 Diag(OpLoc, diag::note_typecheck_member_reference_suggestion)
16645 Diag(OpLoc, diag::err_ovl_no_viable_oper)
16646 <<
"operator->" <<
Base->getSourceRange();
16654 <<
"->" <<
Base->getType()
16655 <<
Base->getSourceRange()),
16663 <<
"->" << (Msg !=
nullptr)
16664 << (Msg ? Msg->
getString() : StringRef())
16665 <<
Base->getSourceRange()),
16676 if (
Method->isExplicitObjectMemberFunction()) {
16683 Base, std::nullopt, Best->FoundDecl,
Method);
16691 Base, HadMultipleCandidates, OpLoc);
16725 bool HadMultipleCandidates = (CandidateSet.
size() > 1);
16738 PDiag(diag::err_ovl_no_viable_function_in_call)
16753 nullptr, HadMultipleCandidates,
16756 if (Fn.isInvalid())
16762 for (
unsigned ArgIdx = 0, N = Args.size(); ArgIdx != N; ++ArgIdx) {
16768 ConvArgs[ArgIdx] = InputInit.
get();
16795 Scope *S =
nullptr;
16798 if (!MemberLookup.
empty()) {
16825 if (CandidateSet->
empty() || CandidateSetError) {
16838 Loc,
nullptr, CandidateSet, &Best,
16851 if (
ParenExpr *PE = dyn_cast<ParenExpr>(E)) {
16856 if (SubExpr.
get() == PE->getSubExpr())
16860 ParenExpr(PE->getLParen(), PE->getRParen(), SubExpr.
get());
16868 assert(
Context.hasSameType(ICE->getSubExpr()->getType(),
16870 "Implicit cast type cannot be determined from overload");
16871 assert(ICE->path_empty() &&
"fixing up hierarchy conversion?");
16872 if (SubExpr.
get() == ICE->getSubExpr())
16880 if (
auto *GSE = dyn_cast<GenericSelectionExpr>(E)) {
16881 if (!GSE->isResultDependent()) {
16886 if (SubExpr.
get() == GSE->getResultExpr())
16893 unsigned ResultIdx = GSE->getResultIndex();
16894 AssocExprs[ResultIdx] = SubExpr.
get();
16896 if (GSE->isExprPredicate())
16898 Context, GSE->getGenericLoc(), GSE->getControllingExpr(),
16899 GSE->getAssocTypeSourceInfos(), AssocExprs, GSE->getDefaultLoc(),
16900 GSE->getRParenLoc(), GSE->containsUnexpandedParameterPack(),
16903 Context, GSE->getGenericLoc(), GSE->getControllingType(),
16904 GSE->getAssocTypeSourceInfos(), AssocExprs, GSE->getDefaultLoc(),
16905 GSE->getRParenLoc(), GSE->containsUnexpandedParameterPack(),
16914 assert(UnOp->getOpcode() == UO_AddrOf &&
16915 "Can only take the address of an overloaded function");
16917 if (!
Method->isImplicitObjectMemberFunction()) {
16928 if (SubExpr.
get() == UnOp->getSubExpr())
16936 "fixed to something other than a decl ref");
16939 assert(Qualifier &&
16940 "fixed to a member ref with no nested name qualifier");
16946 Fn->getType(), Qualifier,
16949 if (
Context.getTargetInfo().getCXXABI().isMicrosoft())
16954 UnOp->getOperatorLoc(),
false,
16962 if (SubExpr.
get() == UnOp->getSubExpr())
16975 if (ULE->hasExplicitTemplateArgs()) {
16976 ULE->copyTemplateArgumentsInto(TemplateArgsBuffer);
16977 TemplateArgs = &TemplateArgsBuffer;
16982 getLangOpts().CPlusPlus && !Fn->hasCXXExplicitFunctionObjectParameter()
16987 if (
unsigned BID = Fn->getBuiltinID()) {
16988 if (!
Context.BuiltinInfo.isDirectlyAddressable(BID)) {
16995 Fn,
Type, ValueKind, ULE->getNameInfo(), ULE->getQualifierLoc(),
16996 Found.getDecl(), ULE->getTemplateKeywordLoc(), TemplateArgs);
17004 if (MemExpr->hasExplicitTemplateArgs()) {
17005 MemExpr->copyTemplateArgumentsInto(TemplateArgsBuffer);
17006 TemplateArgs = &TemplateArgsBuffer;
17013 if (MemExpr->isImplicitAccess()) {
17016 Fn, Fn->getType(),
VK_LValue, MemExpr->getNameInfo(),
17017 MemExpr->getQualifierLoc(),
Found.getDecl(),
17018 MemExpr->getTemplateKeywordLoc(), TemplateArgs);
17023 if (MemExpr->getQualifier())
17024 Loc = MemExpr->getQualifierLoc().getBeginLoc();
17029 Base = MemExpr->getBase();
17035 type = Fn->getType();
17042 Base, MemExpr->isArrow(), MemExpr->getOperatorLoc(),
17043 MemExpr->getQualifierLoc(), MemExpr->getTemplateKeywordLoc(), Fn,
Found,
17044 true, MemExpr->getMemberNameInfo(),
17048 llvm_unreachable(
"Invalid reference to overloaded function");
17059 if (!PartialOverloading || !
Function)
17063 if (
const auto *Proto =
17064 dyn_cast<FunctionProtoType>(
Function->getFunctionType()))
17065 if (Proto->isTemplateVariadic())
17067 if (
auto *Pattern =
Function->getTemplateInstantiationPattern())
17068 if (
const auto *Proto =
17069 dyn_cast<FunctionProtoType>(Pattern->getFunctionType()))
17070 if (Proto->isTemplateVariadic())
17083 << IsMember << Name << (Msg !=
nullptr)
17084 << (Msg ? Msg->
getString() : StringRef())
Defines the clang::ASTContext interface.
Defines the Diagnostic-related interfaces.
static bool isBooleanType(QualType Ty)
Defines the C++ Decl subclasses, other than those for templates (found in DeclTemplate....
Defines the clang::Expr interface and subclasses for C++ expressions.
static const GlobalDecl isTemplate(GlobalDecl GD, const TemplateArgumentList *&TemplateArgs)
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.
llvm::MachO::Record Record
Defines an enumeration for C++ overloaded operators.
Implements a partial diagnostic that can be emitted anwyhere in a DiagnosticBuilder stream.
This file declares semantic analysis functions specific to ARM.
static bool hasAttr(const Decl *D, bool IgnoreImplicitAttr)
static bool hasExplicitAttr(const VarDecl *D)
This file declares semantic analysis for CUDA constructs.
static void BuildBasePathArray(const CXXBasePath &Path, CXXCastPath &BasePathArray)
static bool isRecordType(QualType T)
static void TryUserDefinedConversion(Sema &S, QualType DestType, const InitializationKind &Kind, Expr *Initializer, InitializationSequence &Sequence, bool TopLevelOfInitList)
Attempt a user-defined conversion between two types (C++ [dcl.init]), which enumerates all conversion...
This file declares semantic analysis for Objective-C.
static ImplicitConversionSequence::CompareKind CompareStandardConversionSequences(Sema &S, SourceLocation Loc, const StandardConversionSequence &SCS1, const StandardConversionSequence &SCS2)
CompareStandardConversionSequences - Compare two standard conversion sequences to determine whether o...
static bool sameFunctionParameterTypeLists(Sema &S, FunctionDecl *Fn1, FunctionDecl *Fn2, bool IsFn1Reversed, bool IsFn2Reversed)
We're allowed to use constraints partial ordering only if the candidates have the same parameter type...
static bool isNullPointerConstantForConversion(Expr *Expr, bool InOverloadResolution, ASTContext &Context)
static bool shouldSkipNotingLambdaConversionDecl(const FunctionDecl *Fn)
static const FunctionType * getConversionOpReturnTyAsFunction(CXXConversionDecl *Conv)
static bool functionHasPassObjectSizeParams(const FunctionDecl *FD)
static Comparison compareEnableIfAttrs(const Sema &S, const FunctionDecl *Cand1, const FunctionDecl *Cand2)
Compares the enable_if attributes of two FunctionDecls, for the purposes of overload resolution.
static Qualifiers CollectVRQualifiers(ASTContext &Context, Expr *ArgExpr)
CollectVRQualifiers - This routine returns Volatile/Restrict qualifiers, if any, found in visible typ...
@ ToPromotedUnderlyingType
static void AddOverloadedCallCandidate(Sema &S, DeclAccessPair FoundDecl, TemplateArgumentListInfo *ExplicitTemplateArgs, ArrayRef< Expr * > Args, OverloadCandidateSet &CandidateSet, bool PartialOverloading, bool KnownValid)
Add a single candidate to the overload set.
static void AddTemplateOverloadCandidateImmediately(Sema &S, OverloadCandidateSet &CandidateSet, FunctionTemplateDecl *FunctionTemplate, DeclAccessPair FoundDecl, TemplateArgumentListInfo *ExplicitTemplateArgs, ArrayRef< Expr * > Args, bool SuppressUserConversions, bool PartialOverloading, bool AllowExplicit, Sema::ADLCallKind IsADLCandidate, OverloadCandidateParamOrder PO, bool AggregateCandidateDeduction)
static ExprResult FinishOverloadedCallExpr(Sema &SemaRef, Scope *S, Expr *Fn, UnresolvedLookupExpr *ULE, SourceLocation LParenLoc, MultiExprArg Args, SourceLocation RParenLoc, Expr *ExecConfig, OverloadCandidateSet *CandidateSet, OverloadCandidateSet::iterator *Best, OverloadingResult OverloadResult, bool AllowTypoCorrection)
FinishOverloadedCallExpr - given an OverloadCandidateSet, builds and returns the completed call expre...
static bool isQualificationConversionStep(QualType FromType, QualType ToType, bool CStyle, bool IsTopLevel, bool &PreviousToQualsIncludeConst, bool &ObjCLifetimeConversion, const ASTContext &Ctx)
Perform a single iteration of the loop for checking if a qualification conversion is valid.
static ImplicitConversionSequence::CompareKind CompareQualificationConversions(Sema &S, const StandardConversionSequence &SCS1, const StandardConversionSequence &SCS2)
CompareQualificationConversions - Compares two standard conversion sequences to determine whether the...
static void dropPointerConversion(StandardConversionSequence &SCS)
dropPointerConversions - If the given standard conversion sequence involves any pointer conversions,...
static SourceLocation GetLocationForCandidate(const OverloadCandidate *Cand)
static void DiagnoseArityMismatch(Sema &S, NamedDecl *Found, Decl *D, unsigned NumFormalArgs, bool IsAddressOf=false)
General arity mismatch diagnosis over a candidate in a candidate set.
static const Expr * IgnoreNarrowingConversion(ASTContext &Ctx, const Expr *Converted)
Skip any implicit casts which could be either part of a narrowing conversion or after one in an impli...
static bool allowAmbiguity(ASTContext &Context, const FunctionDecl *F1, const FunctionDecl *F2)
static unsigned RankDeductionFailure(const DeductionFailureInfo &DFI)
static QualType BuildSimilarlyQualifiedPointerType(const Type *FromPtr, QualType ToPointee, QualType ToType, ASTContext &Context, bool StripObjCLifetime=false)
BuildSimilarlyQualifiedPointerType - In a pointer conversion from the pointer type FromPtr to a point...
static void forAllQualifierCombinations(QualifiersAndAtomic Quals, llvm::function_ref< void(QualifiersAndAtomic)> Callback)
static bool FindConversionForRefInit(Sema &S, ImplicitConversionSequence &ICS, QualType DeclType, SourceLocation DeclLoc, Expr *Init, QualType T2, bool AllowRvalues, bool AllowExplicit)
Look for a user-defined conversion to a value reference-compatible with DeclType.
static bool tryAtomicConversion(Sema &S, Expr *From, QualType ToType, bool InOverloadResolution, StandardConversionSequence &SCS, bool CStyle)
static Expr * GetExplicitObjectExpr(Sema &S, Expr *Obj, const FunctionDecl *Fun)
static bool hasDeprecatedStringLiteralToCharPtrConversion(const ImplicitConversionSequence &ICS)
static void AddBuiltinAssignmentOperatorCandidates(Sema &S, QualType T, ArrayRef< Expr * > Args, OverloadCandidateSet &CandidateSet)
Helper function for AddBuiltinOperatorCandidates() that adds the volatile- and non-volatile-qualified...
static bool CheckConvertedConstantConversions(Sema &S, StandardConversionSequence &SCS)
Check that the specified conversion is permitted in a converted constant expression,...
static void NoteBuiltinOperatorCandidate(Sema &S, StringRef Opc, SourceLocation OpLoc, OverloadCandidate *Cand)
static ImplicitConversionSequence::CompareKind compareConversionFunctions(Sema &S, FunctionDecl *Function1, FunctionDecl *Function2)
Compare the user-defined conversion functions or constructors of two user-defined conversion sequence...
static void forAllQualifierCombinationsImpl(QualifiersAndAtomic Available, QualifiersAndAtomic Applied, llvm::function_ref< void(QualifiersAndAtomic)> Callback)
static const char * GetImplicitConversionName(ImplicitConversionKind Kind)
GetImplicitConversionName - Return the name of this kind of implicit conversion.
static bool checkAddressOfFunctionIsAvailable(Sema &S, const FunctionDecl *FD, bool Complain, bool InOverloadResolution, SourceLocation Loc)
Returns true if we can take the address of the function.
static ImplicitConversionSequence::CompareKind CompareDerivedToBaseConversions(Sema &S, SourceLocation Loc, const StandardConversionSequence &SCS1, const StandardConversionSequence &SCS2)
CompareDerivedToBaseConversions - Compares two standard conversion sequences to determine whether the...
static bool convertArgsForAvailabilityChecks(Sema &S, FunctionDecl *Function, Expr *ThisArg, SourceLocation CallLoc, ArrayRef< Expr * > Args, Sema::SFINAETrap &Trap, bool MissingImplicitThis, Expr *&ConvertedThis, SmallVectorImpl< Expr * > &ConvertedArgs)
static TemplateDecl * getDescribedTemplate(Decl *Templated)
static void CompleteNonViableCandidate(Sema &S, OverloadCandidate *Cand, ArrayRef< Expr * > Args, OverloadCandidateSet::CandidateSetKind CSK)
CompleteNonViableCandidate - Normally, overload resolution only computes up to the first bad conversi...
static QualType AdoptQualifiers(ASTContext &Context, QualType T, Qualifiers Qs)
Adopt the given qualifiers for the given type.
static void NoteAmbiguousUserConversions(Sema &S, SourceLocation OpLoc, OverloadCandidate *Cand)
static bool CheckArityMismatch(Sema &S, OverloadCandidate *Cand, unsigned NumArgs, bool IsAddressOf=false)
Additional arity mismatch diagnosis specific to a function overload candidates.
static ImplicitConversionSequence::CompareKind compareStandardConversionSubsets(ASTContext &Context, const StandardConversionSequence &SCS1, const StandardConversionSequence &SCS2)
static bool hasDependentExplicit(FunctionTemplateDecl *FTD)
static bool IsVectorConversion(Sema &S, QualType FromType, QualType ToType, ImplicitConversionKind &ICK, ImplicitConversionKind &ElConv, Expr *From, bool InOverloadResolution, bool CStyle)
Determine whether the conversion from FromType to ToType is a valid vector conversion.
static ImplicitConversionSequence TryContextuallyConvertToObjCPointer(Sema &S, Expr *From)
TryContextuallyConvertToObjCPointer - Attempt to contextually convert the expression From to an Objec...
static ExprResult CheckConvertedConstantExpression(Sema &S, Expr *From, QualType T, APValue &Value, CCEKind CCE, bool RequireInt, NamedDecl *Dest)
CheckConvertedConstantExpression - Check that the expression From is a converted constant expression ...
static ExprResult CreateFunctionRefExpr(Sema &S, FunctionDecl *Fn, NamedDecl *FoundDecl, const Expr *Base, bool HadMultipleCandidates, SourceLocation Loc=SourceLocation(), const DeclarationNameLoc &LocInfo=DeclarationNameLoc())
A convenience routine for creating a decayed reference to a function.
static std::optional< QualType > getImplicitObjectParamType(ASTContext &Context, const FunctionDecl *F)
Compute the type of the implicit object parameter for the given function, if any.
static bool checkPlaceholderForOverload(Sema &S, Expr *&E, UnbridgedCastsSet *unbridgedCasts=nullptr)
checkPlaceholderForOverload - Do any interesting placeholder-like preprocessing on the given expressi...
static FixedEnumPromotion getFixedEnumPromtion(Sema &S, const StandardConversionSequence &SCS)
Returns kind of fixed enum promotion the SCS uses.
static bool isAllowableExplicitConversion(Sema &S, QualType ConvType, QualType ToType, bool AllowObjCPointerConversion)
Determine whether this is an allowable conversion from the result of an explicit conversion operator ...
static bool isNonViableMultiVersionOverload(FunctionDecl *FD)
static bool FunctionsCorrespond(ASTContext &Ctx, const FunctionDecl *X, const FunctionDecl *Y)
static ImplicitConversionSequence TryImplicitConversion(Sema &S, Expr *From, QualType ToType, bool SuppressUserConversions, AllowedExplicit AllowExplicit, bool InOverloadResolution, bool CStyle, bool AllowObjCWritebackConversion, bool AllowObjCConversionOnExplicit)
TryImplicitConversion - Attempt to perform an implicit conversion from the given expression (Expr) to...
static ExprResult BuildConvertedConstantExpression(Sema &S, Expr *From, QualType T, CCEKind CCE, NamedDecl *Dest, APValue &PreNarrowingValue)
BuildConvertedConstantExpression - Check that the expression From is a converted constant expression ...
static bool IsVectorElementConversion(Sema &S, QualType FromType, QualType ToType, ImplicitConversionKind &ICK, Expr *From)
static ImplicitConversionSequence TryListConversion(Sema &S, InitListExpr *From, QualType ToType, bool SuppressUserConversions, bool InOverloadResolution, bool AllowObjCWritebackConversion)
TryListConversion - Try to copy-initialize a value of type ToType from the initializer list From.
static bool IsOverloadOrOverrideImpl(Sema &SemaRef, FunctionDecl *New, FunctionDecl *Old, bool UseMemberUsingDeclRules, bool ConsiderCudaAttrs, bool UseOverrideRules=false)
static QualType withoutUnaligned(ASTContext &Ctx, QualType T)
static void DiagnoseBadTarget(Sema &S, OverloadCandidate *Cand)
CUDA: diagnose an invalid call across targets.
static void MaybeDiagnoseAmbiguousConstraints(Sema &S, ArrayRef< OverloadCandidate > Cands)
static bool diagnoseNoViableConversion(Sema &SemaRef, SourceLocation Loc, Expr *&From, Sema::ContextualImplicitConverter &Converter, QualType T, bool HadMultipleCandidates, UnresolvedSetImpl &ExplicitConversions)
static void AddMethodTemplateCandidateImmediately(Sema &S, OverloadCandidateSet &CandidateSet, FunctionTemplateDecl *MethodTmpl, DeclAccessPair FoundDecl, CXXRecordDecl *ActingContext, TemplateArgumentListInfo *ExplicitTemplateArgs, QualType ObjectType, Expr::Classification ObjectClassification, ArrayRef< Expr * > Args, bool SuppressUserConversions, bool PartialOverloading, OverloadCandidateParamOrder PO)
static void AddTemplateConversionCandidateImmediately(Sema &S, OverloadCandidateSet &CandidateSet, FunctionTemplateDecl *FunctionTemplate, DeclAccessPair FoundDecl, CXXRecordDecl *ActingContext, Expr *From, QualType ToType, bool AllowObjCConversionOnExplicit, bool AllowExplicit, bool AllowResultConversion)
static ImplicitConversionSequence TryContextuallyConvertToBool(Sema &S, Expr *From)
TryContextuallyConvertToBool - Attempt to contextually convert the expression From to bool (C++0x [co...
static ImplicitConversionSequence TryObjectArgumentInitialization(Sema &S, SourceLocation Loc, QualType FromType, Expr::Classification FromClassification, CXXMethodDecl *Method, const CXXRecordDecl *ActingContext, bool InOverloadResolution=false, QualType ExplicitParameterType=QualType(), bool SuppressUserConversion=false)
TryObjectArgumentInitialization - Try to initialize the object parameter of the given member function...
static bool recordConversion(Sema &SemaRef, SourceLocation Loc, Expr *&From, Sema::ContextualImplicitConverter &Converter, QualType T, bool HadMultipleCandidates, DeclAccessPair &Found)
static ImplicitConversionSequence::CompareKind CompareImplicitConversionSequences(Sema &S, SourceLocation Loc, const ImplicitConversionSequence &ICS1, const ImplicitConversionSequence &ICS2)
CompareImplicitConversionSequences - Compare two implicit conversion sequences to determine whether o...
static void NoteFunctionCandidate(Sema &S, OverloadCandidate *Cand, unsigned NumArgs, bool TakingCandidateAddress, LangAS CtorDestAS=LangAS::Default)
Generates a 'note' diagnostic for an overload candidate.
static ImplicitConversionSequence TryCopyInitialization(Sema &S, Expr *From, QualType ToType, bool SuppressUserConversions, bool InOverloadResolution, bool AllowObjCWritebackConversion, bool AllowExplicit=false)
TryCopyInitialization - Try to copy-initialize a value of type ToType from the expression From.
static ExprResult diagnoseAmbiguousConversion(Sema &SemaRef, SourceLocation Loc, Expr *From, Sema::ContextualImplicitConverter &Converter, QualType T, UnresolvedSetImpl &ViableConversions)
static void markUnaddressableCandidatesUnviable(Sema &S, OverloadCandidateSet &CS)
static QualType GetExplicitObjectType(Sema &S, const Expr *MemExprE)
Sema::AllowedExplicit AllowedExplicit
static QualType AdjustAddressSpaceForBuiltinOperandType(Sema &S, QualType T, Expr *Arg)
Helper function for adjusting address spaces for the pointer or reference operands of builtin operato...
static void DiagnoseFailedExplicitSpec(Sema &S, OverloadCandidate *Cand)
static bool DiagnoseTwoPhaseLookup(Sema &SemaRef, SourceLocation FnLoc, const CXXScopeSpec &SS, LookupResult &R, OverloadCandidateSet::CandidateSetKind CSK, TemplateArgumentListInfo *ExplicitTemplateArgs, ArrayRef< Expr * > Args, CXXRecordDecl **FoundInClass=nullptr)
Attempt to recover from an ill-formed use of a non-dependent name in a template, where the non-depend...
static bool isBetterReferenceBindingKind(const StandardConversionSequence &SCS1, const StandardConversionSequence &SCS2)
Determine whether one of the given reference bindings is better than the other based on what kind of ...
static bool canBeDeclaredInNamespace(const DeclarationName &Name)
Determine whether a declaration with the specified name could be moved into a different namespace.
static ExprResult finishContextualImplicitConversion(Sema &SemaRef, SourceLocation Loc, Expr *From, Sema::ContextualImplicitConverter &Converter)
static bool IsStandardConversion(Sema &S, Expr *From, QualType ToType, bool InOverloadResolution, StandardConversionSequence &SCS, bool CStyle, bool AllowObjCWritebackConversion)
IsStandardConversion - Determines whether there is a standard conversion sequence (C++ [conv],...
static bool DiagnoseTwoPhaseOperatorLookup(Sema &SemaRef, OverloadedOperatorKind Op, SourceLocation OpLoc, ArrayRef< Expr * > Args)
Attempt to recover from ill-formed use of a non-dependent operator in a template, where the non-depen...
static bool isNonTrivialObjCLifetimeConversion(Qualifiers FromQuals, Qualifiers ToQuals)
Determine whether the lifetime conversion between the two given qualifiers sets is nontrivial.
static void DiagnoseBadConversion(Sema &S, OverloadCandidate *Cand, unsigned I, bool TakingCandidateAddress)
static bool completeFunctionType(Sema &S, FunctionDecl *FD, SourceLocation Loc, bool Complain=true)
static bool shouldAddReversedEqEq(Sema &S, SourceLocation OpLoc, Expr *FirstOperand, FunctionDecl *EqFD)
static bool isFunctionAlwaysEnabled(const ASTContext &Ctx, const FunctionDecl *FD)
static bool PrepareExplicitObjectArgument(Sema &S, CXXMethodDecl *Method, Expr *Object, MultiExprArg &Args, SmallVectorImpl< Expr * > &NewArgs)
static OverloadingResult IsInitializerListConstructorConversion(Sema &S, Expr *From, QualType ToType, CXXRecordDecl *To, UserDefinedConversionSequence &User, OverloadCandidateSet &CandidateSet, bool AllowExplicit)
static bool checkAddressOfCandidateIsAvailable(Sema &S, const FunctionDecl *FD)
static bool IsFloatingPointConversion(Sema &S, QualType FromType, QualType ToType)
Determine whether the conversion from FromType to ToType is a valid floating point conversion.
static bool isFirstArgumentCompatibleWithType(ASTContext &Context, CXXConstructorDecl *Constructor, QualType Type)
static Comparison isBetterMultiversionCandidate(const OverloadCandidate &Cand1, const OverloadCandidate &Cand2)
static void NoteImplicitDeductionGuide(Sema &S, FunctionDecl *Fn)
static void collectViableConversionCandidates(Sema &SemaRef, Expr *From, QualType ToType, UnresolvedSetImpl &ViableConversions, OverloadCandidateSet &CandidateSet)
static ImplicitConversionSequence TryReferenceInit(Sema &S, Expr *Init, QualType DeclType, SourceLocation DeclLoc, bool SuppressUserConversions, bool AllowExplicit)
Compute an implicit conversion sequence for reference initialization.
static bool isNonDependentlyExplicit(FunctionTemplateDecl *FTD)
Determine whether a given function template has a simple explicit specifier or a non-value-dependent ...
static bool checkArgPlaceholdersForOverload(Sema &S, MultiExprArg Args, UnbridgedCastsSet &unbridged)
checkArgPlaceholdersForOverload - Check a set of call operands for placeholders.
static QualType makeQualifiedLValueReferenceType(QualType Base, QualifiersAndAtomic Quals, Sema &S)
static QualType chooseRecoveryType(OverloadCandidateSet &CS, OverloadCandidateSet::iterator *Best)
static void AddTemplateOverloadCandidate(Sema &S, OverloadCandidateSet &CandidateSet, DeferredMethodTemplateOverloadCandidate &C)
static void NoteSurrogateCandidate(Sema &S, OverloadCandidate *Cand)
static ExprResult BuildRecoveryCallExpr(Sema &SemaRef, Scope *S, Expr *Fn, UnresolvedLookupExpr *ULE, SourceLocation LParenLoc, MutableArrayRef< Expr * > Args, SourceLocation RParenLoc, bool EmptyLookup, bool AllowTypoCorrection)
Attempts to recover from a call where no functions were found.
static void DiagnoseFailedEnableIfAttr(Sema &S, OverloadCandidate *Cand)
static bool diagnoseDiagnoseIfAttrsWith(Sema &S, const NamedDecl *ND, bool ArgDependent, SourceLocation Loc, CheckFn &&IsSuccessful)
static OverloadingResult IsUserDefinedConversion(Sema &S, Expr *From, QualType ToType, UserDefinedConversionSequence &User, OverloadCandidateSet &Conversions, AllowedExplicit AllowExplicit, bool AllowObjCConversionOnExplicit)
Determines whether there is a user-defined conversion sequence (C++ [over.ics.user]) that converts ex...
static bool IsAcceptableNonMemberOperatorCandidate(ASTContext &Context, FunctionDecl *Fn, ArrayRef< Expr * > Args)
IsAcceptableNonMemberOperatorCandidate - Determine whether Fn is an acceptable non-member overloaded ...
static FunctionDecl * getMorePartialOrderingConstrained(Sema &S, FunctionDecl *Fn1, FunctionDecl *Fn2, bool IsFn1Reversed, bool IsFn2Reversed)
static void DiagnoseBadDeduction(Sema &S, NamedDecl *Found, Decl *Templated, DeductionFailureInfo &DeductionFailure, unsigned NumArgs, bool TakingCandidateAddress)
Diagnose a failed template-argument deduction.
static bool IsTransparentUnionStandardConversion(Sema &S, Expr *From, QualType &ToType, bool InOverloadResolution, StandardConversionSequence &SCS, bool CStyle)
static const FunctionProtoType * tryGetFunctionProtoType(QualType FromType)
Attempts to get the FunctionProtoType from a Type.
static bool PrepareArgumentsForCallToObjectOfClassType(Sema &S, SmallVectorImpl< Expr * > &MethodArgs, CXXMethodDecl *Method, MultiExprArg Args, SourceLocation LParenLoc)
static TemplateDeductionResult DeduceTemplateArguments(Sema &S, TemplateParameterList *TemplateParams, ArrayRef< TemplateArgument > Ps, ArrayRef< TemplateArgument > As, TemplateDeductionInfo &Info, SmallVectorImpl< DeducedTemplateArgument > &Deduced, bool NumberOfArgumentsMustMatch, bool PartialOrdering, PackFold PackFold, bool *HasDeducedAnyParam)
Defines the SourceManager interface.
static QualType getPointeeType(const MemRegion *R)
C Language Family Type Representation.
a trap message and trap category.
A class for storing results from argument-dependent lookup.
void erase(NamedDecl *D)
Removes any data associated with a given decl.
llvm::mapped_iterator< decltype(Decls)::iterator, select_second > iterator
APValue - This class implements a discriminated union of [uninitialized] [APSInt] [APFloat],...
std::string getAsString(const ASTContext &Ctx, QualType Ty) const
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
const ConstantArrayType * getAsConstantArrayType(QualType T) const
QualType getAtomicType(QualType T) const
Return the uniqued reference to the atomic type for the specified type.
QualType getRValueReferenceType(QualType T) const
Return the uniqued reference to the type for an rvalue reference to the specified type.
unsigned getIntWidth(QualType T) const
bool areCompatibleRVVTypes(QualType FirstType, QualType SecondType)
Return true if the given types are an RISC-V vector builtin type and a VectorType that is a fixed-len...
const llvm::fltSemantics & getFloatTypeSemantics(QualType T) const
Return the APFloat 'semantics' for the specified scalar floating point type.
static CanQualType getCanonicalType(QualType T)
Return the canonical (structural) type corresponding to the specified potentially non-canonical type ...
DeclarationNameTable DeclarationNames
QualType getArrayParameterType(QualType Ty) const
Return the uniqued reference to a specified array parameter type from the original array type.
QualType getPointerType(QualType T) const
Return the uniqued reference to the type for a pointer to the specified type.
bool canAssignObjCInterfaces(const ObjCObjectPointerType *LHSOPT, const ObjCObjectPointerType *RHSOPT)
canAssignObjCInterfaces - Return true if the two interface types are compatible for assignment from R...
QualType getLValueReferenceType(QualType T, bool SpelledAsLValue=true) const
Return the uniqued reference to the type for an lvalue reference to the specified type.
QualType getConstantArrayType(QualType EltTy, const llvm::APInt &ArySize, const Expr *SizeExpr, ArraySizeModifier ASM, unsigned IndexTypeQuals) const
Return the unique reference to the type for a constant array of the specified element type.
const LangOptions & getLangOpts() const
bool areLaxCompatibleRVVTypes(QualType FirstType, QualType SecondType)
Return true if the given vector types are lax-compatible RISC-V vector types as defined by -flax-vect...
CallingConv getDefaultCallingConvention(bool IsVariadic, bool IsCXXMethod) const
Retrieves the default calling convention for the current context.
void forEachMultiversionedFunctionVersion(const FunctionDecl *FD, llvm::function_ref< void(FunctionDecl *)> Pred) const
Visits all versions of a multiversioned function with the passed predicate.
QualType getPointerDiffType() const
Return the unique type for "ptrdiff_t" (C99 7.17) defined in <stddef.h>.
int getFloatingTypeOrder(QualType LHS, QualType RHS) const
Compare the rank of the two specified floating point types, ignoring the domain of the type (i....
const TargetInfo * getAuxTargetInfo() const
CanQualType UnsignedLongTy
QualType getRestrictType(QualType T) const
Return the uniqued reference to the type for a restrict qualified type.
QualType getQualifiedType(SplitQualType split) const
Un-split a SplitQualType.
QualType getObjCObjectPointerType(QualType OIT) const
Return a ObjCObjectPointerType type for the given ObjCObjectType.
QualType getObjCIdType() const
Represents the Objective-CC id type.
const ArrayType * getAsArrayType(QualType T) const
Type Query functions.
bool isSameTemplateParameterList(const TemplateParameterList *X, const TemplateParameterList *Y) const
Determine whether two template parameter lists are similar enough that they may be used in declaratio...
uint64_t getTypeSize(QualType T) const
Return the size of the specified (complete) type T, in bits.
CanQualType UnsignedInt128Ty
CanQualType UnsignedCharTy
CanQualType UnsignedIntTy
QualType getVolatileType(QualType T) const
Return the uniqued reference to the type for a volatile qualified type.
CanQualType UnsignedLongLongTy
QualType getArrayDecayedType(QualType T) const
Return the properly qualified result of decaying the specified array type to a pointer.
CanQualType UnsignedShortTy
QualType getMemberPointerType(QualType T, NestedNameSpecifier Qualifier, const CXXRecordDecl *Cls) const
Return the uniqued reference to the type for a member pointer to the specified type in the specified ...
static bool hasSameType(QualType T1, QualType T2)
Determine whether the given types T1 and T2 are equivalent.
QualType getSizeType() const
Return the unique type for "size_t" (C99 7.17), defined in <stddef.h>.
QualType getCVRQualifiedType(QualType T, unsigned CVR) const
Return a type with additional const, volatile, or restrict qualifiers.
bool areCompatibleVectorTypes(QualType FirstVec, QualType SecondVec)
Return true if the given vector types are of the same unqualified type or if they are equivalent to t...
const TargetInfo & getTargetInfo() const
bool typesAreCompatible(QualType T1, QualType T2, bool CompareUnqualified=false)
Compatibility predicates used to check assignment expressions.
QualType getAddrSpaceQualType(QualType T, LangAS AddressSpace) const
Return the uniqued reference to the type for an address space qualified type with the specified type ...
CanQualType getCanonicalTagType(const TagDecl *TD) const
static bool hasSameUnqualifiedType(QualType T1, QualType T2)
Determine whether the given types are equivalent after cvr-qualifiers have been removed.
QualType getUnqualifiedArrayType(QualType T, Qualifiers &Quals) const
Return this type as a completely-unqualified array type, capturing the qualifiers in Quals.
Represents a constant array type that does not decay to a pointer when used as a function parameter.
QualType getConstantArrayType(const ASTContext &Ctx) const
Represents an array type, per C99 6.7.5.2 - Array Declarators.
QualType getElementType() const
QualType getValueType() const
Gets the type contained by this atomic type, i.e.
Attr - This represents one attribute.
A builtin binary operation expression such as "x + y" or "x <= y".
static OverloadedOperatorKind getOverloadedOperator(Opcode Opc)
Retrieve the overloaded operator kind that corresponds to the given binary opcode.
StringRef getOpcodeStr() const
static StringRef getOpcodeStr(Opcode Op)
getOpcodeStr - Turn an Opcode enum value into the punctuation char it corresponds to,...
static BinaryOperator * Create(const ASTContext &C, Expr *lhs, Expr *rhs, Opcode opc, QualType ResTy, ExprValueKind VK, ExprObjectKind OK, SourceLocation opLoc, FPOptionsOverride FPFeatures)
static bool isCompoundAssignmentOp(Opcode Opc)
This class is used for builtin types like 'int'.
BasePaths - Represents the set of paths from a derived class to one of its (direct or indirect) bases...
const RecordType * getDetectedVirtual() const
The virtual base discovered on the path (if we are merely detecting virtuals).
bool isAmbiguous(CanQualType BaseType)
Determine whether the path from the most-derived type to the given base type is ambiguous (i....
Represents a C++ constructor within a class.
bool isCopyOrMoveConstructor(unsigned &TypeQuals) const
Determine whether this is a copy or move constructor.
bool isConvertingConstructor(bool AllowExplicit) const
Whether this constructor is a converting constructor (C++ [class.conv.ctor]), which can be used for u...
Represents a C++ conversion function within a class.
bool isExplicit() const
Return true if the declaration is already resolved to be explicit.
QualType getConversionType() const
Returns the type that this conversion function is converting to.
Represents a call to a member function that may be written either with member call syntax (e....
static CXXMemberCallExpr * Create(const ASTContext &Ctx, Expr *Fn, ArrayRef< Expr * > Args, QualType Ty, ExprValueKind VK, SourceLocation RP, FPOptionsOverride FPFeatures, unsigned MinNumArgs=0)
Represents a static or instance method of a struct/union/class.
bool isExplicitObjectMemberFunction() const
[C++2b][dcl.fct]/p7 An explicit object member function is a non-static member function with an explic...
bool isImplicitObjectMemberFunction() const
[C++2b][dcl.fct]/p7 An implicit object member function is a non-static member function without an exp...
QualType getFunctionObjectParameterReferenceType() const
Return the type of the object pointed by this.
const CXXRecordDecl * getParent() const
Return the parent of this method declaration, which is the class in which this method is defined.
static CXXOperatorCallExpr * Create(const ASTContext &Ctx, OverloadedOperatorKind OpKind, Expr *Fn, ArrayRef< Expr * > Args, QualType Ty, ExprValueKind VK, SourceLocation OperatorLoc, FPOptionsOverride FPFeatures, ADLCallKind UsesADL=NotADL)
Represents a C++ struct/union/class.
bool isLambda() const
Determine whether this class describes a lambda function object.
llvm::iterator_range< conversion_iterator > getVisibleConversionFunctions() const
Get all conversion functions visible in current class, including conversion function templates.
bool hasDefinition() const
CXXMethodDecl * getLambdaCallOperator() const
Retrieve the lambda call operator of the closure type if this is a closure type.
A rewritten comparison expression that was originally written using operator syntax.
Represents a C++ nested-name-specifier or a global scope specifier.
bool isEmpty() const
No scope specifier.
void Adopt(NestedNameSpecifierLoc Other)
Adopt an existing nested-name-specifier (with source-range information).
CallExpr - Represents a function call (C99 6.5.2.2, C++ [expr.call]).
static CallExpr * Create(const ASTContext &Ctx, Expr *Fn, ArrayRef< Expr * > Args, QualType Ty, ExprValueKind VK, SourceLocation RParenLoc, FPOptionsOverride FPFeatures, unsigned MinNumArgs=0, ADLCallKind UsesADL=NotADL)
Create a call expression.
FunctionDecl * getDirectCallee()
If the callee is a FunctionDecl, return it. Otherwise return null.
void setUsesMemberSyntax(bool V=true)
void markDependentForPostponedNameLookup()
Used by Sema to implement MSVC-compatible delayed name lookup.
Represents a canonical, potentially-qualified type.
bool isAtLeastAsQualifiedAs(CanQual< T > Other, const ASTContext &Ctx) const
Determines whether this canonical type is at least as qualified as the Other canonical type.
static CanQual< Type > CreateUnsafe(QualType Other)
CanProxy< U > castAs() const
CanQual< T > getUnqualifiedType() const
Retrieve the unqualified form of this type.
Qualifiers getQualifiers() const
Retrieve all qualifiers.
CanProxy< U > getAs() const
Retrieve a canonical type pointer with a different static type, upcasting or downcasting as needed.
bool isVolatileQualified() const
const T * getTypePtr() const
Retrieve the underlying type pointer, which refers to a canonical type.
bool isPartial() const
True iff the comparison is not totally ordered.
bool isStrong() const
True iff the comparison is "strong".
Complex values, per C99 6.2.5p11.
QualType getElementType() const
static CompoundAssignOperator * Create(const ASTContext &C, Expr *lhs, Expr *rhs, Opcode opc, QualType ResTy, ExprValueKind VK, ExprObjectKind OK, SourceLocation opLoc, FPOptionsOverride FPFeatures, QualType CompLHSType=QualType(), QualType CompResultType=QualType())
Represents the canonical version of C arrays with a specified constant size.
static ConstantExpr * Create(const ASTContext &Context, Expr *E, const APValue &Result)
The result of a constraint satisfaction check, containing the necessary information to diagnose an un...
Base class for callback objects used by Sema::CorrectTypo to check the validity of a potential typo c...
A POD class for pairing a NamedDecl* with an access specifier.
static DeclAccessPair make(NamedDecl *D, AccessSpecifier AS)
NamedDecl * getDecl() const
DeclContext - This is used only as base class of specific decl types that can act as declaration cont...
DeclContext * getParent()
getParent - Returns the containing DeclContext.
lookup_result lookup(DeclarationName Name) const
lookup - Find the declarations (if any) with the given Name in this context.
DeclContext * getEnclosingNamespaceContext()
Retrieve the nearest enclosing namespace context.
bool Encloses(const DeclContext *DC) const
Determine whether this declaration context semantically encloses the declaration context DC.
A reference to a declared variable, function, enum, etc.
void setHadMultipleCandidates(bool V=true)
Sets the flag telling whether this expression refers to a function that was resolved from an overload...
Decl - This represents one declaration (or definition), e.g.
TemplateDecl * getDescribedTemplate() const
If this is a declaration that describes some template, this method returns that template declaration.
ASTContext & getASTContext() const LLVM_READONLY
bool isImplicit() const
isImplicit - Indicates whether the declaration was implicitly generated by the implementation.
const FunctionType * getFunctionType(bool BlocksToo=true) const
Looks through the Decl's underlying type to extract a FunctionType when possible.
FunctionDecl * getAsFunction() LLVM_READONLY
Returns the function itself, or the templated function if this is a function template.
bool isInvalidDecl() const
llvm::iterator_range< specific_attr_iterator< T > > specific_attrs() const
SourceLocation getLocation() const
DeclContext * getDeclContext()
AccessSpecifier getAccess() const
specific_attr_iterator< T > specific_attr_end() const
specific_attr_iterator< T > specific_attr_begin() const
DeclContext * getLexicalDeclContext()
getLexicalDeclContext - The declaration context where this Decl was lexically declared (LexicalDC).
DeclarationNameLoc - Additional source/type location info for a declaration name.
The name of a declaration.
TemplateDecl * getCXXDeductionGuideTemplate() const
If this name is the name of a C++ deduction guide, return the template associated with that name.
OverloadedOperatorKind getCXXOverloadedOperator() const
If this name is the name of an overloadable operator in C++ (e.g., operator+), retrieve the kind of o...
SourceLocation getBeginLoc() const LLVM_READONLY
const AssociatedConstraint & getTrailingRequiresClause() const
Get the constraint-expression introduced by the trailing requires-clause in the function/member decla...
void overloadCandidatesShown(unsigned N)
Call this after showing N overload candidates.
unsigned getNumOverloadCandidatesToShow() const
When a call or operator fails, print out up to this many candidate overloads as suggestions.
OverloadsShown getShowOverloads() const
const IntrusiveRefCntPtr< DiagnosticIDs > & getDiagnosticIDs() const
RAII object that enters a new expression evaluation context.
Store information needed for an explicit specifier.
bool isExplicit() const
Determine whether this specifier is known to correspond to an explicit declaration.
ExplicitSpecKind getKind() const
const Expr * getExpr() const
static ExplicitSpecifier getFromDecl(FunctionDecl *Function)
static ExprWithCleanups * Create(const ASTContext &C, EmptyShell empty, unsigned numObjects)
The return type of classify().
static Classification makeSimpleLValue()
Create a simple, modifiable lvalue.
This represents one expression.
bool isIntegerConstantExpr(const ASTContext &Ctx) const
Expr * IgnoreParenCasts() LLVM_READONLY
Skip past any parentheses and casts which might surround this expression until reaching a fixed point...
bool isValueDependent() const
Determines whether the value of this expression depends on.
ExprValueKind getValueKind() const
getValueKind - The value kind that this expression produces.
bool isTypeDependent() const
Determines whether the type of this expression depends on.
llvm::APSInt EvaluateKnownConstInt(const ASTContext &Ctx) const
EvaluateKnownConstInt - Call EvaluateAsRValue and return the folded integer.
Expr * IgnoreParens() LLVM_READONLY
Skip past any parentheses which might surround this expression until reaching a fixed point.
static bool hasAnyTypeDependentArguments(ArrayRef< Expr * > Exprs)
hasAnyTypeDependentArguments - Determines if any of the expressions in Exprs is type-dependent.
FieldDecl * getSourceBitField()
If this expression refers to a bit-field, retrieve the declaration of that bit-field.
@ NPC_ValueDependentIsNull
Specifies that a value-dependent expression of integral or dependent type should be considered a null...
@ NPC_ValueDependentIsNotNull
Specifies that a value-dependent expression should be considered to never be a null pointer constant.
ExprObjectKind getObjectKind() const
getObjectKind - The object kind that this expression produces.
bool EvaluateAsConstantExpr(EvalResult &Result, const ASTContext &Ctx, ConstantExprKind Kind=ConstantExprKind::Normal) const
Evaluate an expression that is required to be a constant expression.
@ NPCK_ZeroExpression
Expression is a Null pointer constant built from a zero integer expression that is not a simple,...
NullPointerConstantKind isNullPointerConstant(ASTContext &Ctx, NullPointerConstantValueDependence NPC) const
isNullPointerConstant - C99 6.3.2.3p3 - Test if this reduces down to a Null pointer constant.
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.
Classification Classify(ASTContext &Ctx) const
Classify - Classify this expression according to the C++11 expression taxonomy.
bool hasPlaceholderType() const
Returns whether this expression has a placeholder type.
static ExprValueKind getValueKindForType(QualType T)
getValueKindForType - Given a formal return or parameter type, give its value kind.
ExtVectorType - Extended vector type.
Represents difference between two FPOptions values.
Represents a member of a struct/union/class.
Annotates a diagnostic with some code that should be inserted, removed, or replaced to fix the proble...
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.
bool isMultiVersion() const
True if this function is considered a multiversioned function.
const ParmVarDecl * getParamDecl(unsigned i) const
FunctionTemplateDecl * getDescribedFunctionTemplate() const
Retrieves the function template that is described by this function declaration.
unsigned getBuiltinID(bool ConsiderWrapperFunctions=false) const
Returns a value indicating whether this function corresponds to a builtin function.
param_iterator param_end()
bool isMemberLikeConstrainedFriend() const
Determine whether a function is a friend function that cannot be redeclared outside of its class,...
bool hasCXXExplicitFunctionObjectParameter() const
QualType getReturnType() const
ArrayRef< ParmVarDecl * > parameters() const
FunctionDecl * getTemplateInstantiationPattern(bool ForDefinition=true) const
Retrieve the function declaration from which this function could be instantiated, if it is an instant...
FunctionTemplateDecl * getPrimaryTemplate() const
Retrieve the primary template that this function template specialization either specializes or was in...
FunctionDecl * getCanonicalDecl() override
Retrieves the "canonical" declaration of the given declaration.
param_iterator param_begin()
bool isVariadic() const
Whether this function is variadic.
const TemplateArgumentList * getTemplateSpecializationArgs() const
Retrieve the template arguments used to produce this function template specialization from the primar...
bool isTemplateInstantiation() const
Determines if the given function was instantiated from a function template.
unsigned getNumNonObjectParams() const
bool isConstexpr() const
Whether this is a (C++11) constexpr function or constexpr constructor.
OverloadedOperatorKind getOverloadedOperator() const
getOverloadedOperator - Which C++ overloaded operator this function represents, if any.
bool isTargetMultiVersion() const
True if this function is a multiversioned dispatch function as a part of the target functionality.
QualType getDeclaredReturnType() const
Get the declared return type, which may differ from the actual return type if the return type is dedu...
bool isTargetMultiVersionDefault() const
True if this function is the default version of a multiversioned dispatch function as a part of the t...
unsigned getNumParams() const
Return the number of parameters this function must have based on its FunctionType.
bool willHaveBody() const
True if this function will eventually have a body, once it's fully parsed.
Represents a prototype with parameter type info, e.g.
ExtParameterInfo getExtParameterInfo(unsigned I) const
unsigned getNumParams() const
Qualifiers getMethodQuals() const
QualType getParamType(unsigned i) const
bool isVariadic() const
Whether this function prototype is variadic.
ArrayRef< QualType > param_types() const
Declaration of a template function.
FunctionDecl * getTemplatedDecl() const
Get the underlying function declaration of the template.
A class which abstracts out some details necessary for making a call.
ExtInfo withNoReturn(bool noReturn) const
ParameterABI getABI() const
Return the ABI treatment of this parameter.
FunctionType - C99 6.7.5.3 - Function Declarators.
ExtInfo getExtInfo() const
CallingConv getCallConv() const
QualType getReturnType() const
QualType getCallResultType(const ASTContext &Context) const
Determine the type of an expression that calls a function of this type.
static GenericSelectionExpr * Create(const ASTContext &Context, SourceLocation GenericLoc, Expr *ControllingExpr, ArrayRef< TypeSourceInfo * > AssocTypes, ArrayRef< Expr * > AssocExprs, SourceLocation DefaultLoc, SourceLocation RParenLoc, bool ContainsUnexpandedParameterPack, unsigned ResultIndex)
Create a non-result-dependent generic selection expression accepting an expression predicate.
One of these records is kept for each identifier that is lexed.
ImplicitCastExpr - Allows us to explicitly represent implicit type conversions, which have no direct ...
static ImplicitCastExpr * Create(const ASTContext &Context, QualType T, CastKind Kind, Expr *Operand, const CXXCastPath *BasePath, ExprValueKind Cat, FPOptionsOverride FPO)
ImplicitConversionSequence - Represents an implicit conversion sequence, which may be a standard conv...
void dump() const
dump - Print this implicit conversion sequence to standard error.
bool isUserDefined() const
@ StaticObjectArgumentConversion
StandardConversionSequence Standard
When ConversionKind == StandardConversion, provides the details of the standard conversion sequence.
void setBad(BadConversionSequence::FailureKind Failure, Expr *FromExpr, QualType ToType)
Sets this sequence as a bad conversion for an explicit argument.
UserDefinedConversionSequence UserDefined
When ConversionKind == UserDefinedConversion, provides the details of the user-defined conversion seq...
static ImplicitConversionSequence getNullptrToBool(QualType SourceType, QualType DestType, bool NeedLValToRVal)
Form an "implicit" conversion sequence from nullptr_t to bool, for a direct-initialization of a bool ...
AmbiguousConversionSequence Ambiguous
When ConversionKind == AmbiguousConversion, provides the details of the ambiguous conversion.
void setInitializerListContainerType(QualType T, bool IA)
bool hasInitializerListContainerType() const
unsigned getKindRank() const
Return a ranking of the implicit conversion sequence kind, where smaller ranks represent better conve...
bool isInitializerListOfIncompleteArray() const
BadConversionSequence Bad
When ConversionKind == BadConversion, provides the details of the bad conversion.
QualType getInitializerListContainerType() const
void DiagnoseAmbiguousConversion(Sema &S, SourceLocation CaretLoc, const PartialDiagnostic &PDiag) const
Diagnoses an ambiguous conversion.
Describes an C or C++ initializer list.
bool hasDesignatedInit() const
Determine whether this initializer list contains a designated initializer.
unsigned getNumInits() const
SourceLocation getBeginLoc() const LLVM_READONLY
const Expr * getInit(unsigned Init) const
SourceLocation getEndLoc() const LLVM_READONLY
Describes an entity that is being initialized.
static InitializedEntity InitializeParameter(ASTContext &Context, ParmVarDecl *Parm)
Create the initialization entity for a parameter.
static InitializedEntity InitializeTemplateParameter(QualType T, NamedDecl *Param)
Create the initialization entity for a template parameter.
static IntegerLiteral * Create(const ASTContext &C, const llvm::APInt &V, QualType type, SourceLocation l)
Returns a new integer literal with value 'V' and type 'type'.
An lvalue reference type, per C++11 [dcl.ref].
bool isCompatibleWithMSVC(MSVCMajorVersion MajorVersion) const
Represents the results of name lookup.
void addAllDecls(const LookupResult &Other)
Add all the declarations from another set of lookup results.
LLVM_ATTRIBUTE_REINITIALIZES void clear()
Clears out any current state.
DeclClass * getAsSingle() const
void addDecl(NamedDecl *D)
Add a declaration to these results with its natural access.
bool empty() const
Return true if no decls were found.
void resolveKind()
Resolves the result kind of the lookup, possibly hiding decls.
SourceLocation getNameLoc() const
Gets the location of the identifier.
Sema::LookupNameKind getLookupKind() const
Gets the kind of lookup to perform.
void suppressAccessDiagnostics()
Suppress the diagnostics that would normally fire because of this lookup due to access control violat...
const UnresolvedSetImpl & asUnresolvedSet() const
UnresolvedSetImpl::iterator iterator
void suppressDiagnostics()
Suppress the diagnostics that would normally fire because of this lookup.
DeclarationName getLookupName() const
Gets the name to look up.
MemberExpr - [C99 6.5.2.3] Structure and Union Members.
SourceLocation getMemberLoc() const
getMemberLoc - Return the location of the "member", in X->F, it is the location of 'F'.
NestedNameSpecifier getQualifier() const
If the member name was qualified, retrieves the nested-name-specifier that precedes the member name.
ValueDecl * getMemberDecl() const
Retrieve the member declaration to which this expression refers.
bool hasQualifier() const
Determines whether this member expression actually had a C++ nested-name-specifier prior to the name ...
bool performsVirtualDispatch(const LangOptions &LO) const
Returns true if virtual dispatch is performed.
SourceLocation getBeginLoc() const LLVM_READONLY
SourceLocation getExprLoc() const LLVM_READONLY
DeclAccessPair getFoundDecl() const
Retrieves the declaration found by lookup.
A pointer to member type per C++ 8.3.3 - Pointers to members.
NestedNameSpecifier getQualifier() const
CXXRecordDecl * getMostRecentCXXRecordDecl() const
Note: this can trigger extra deserialization when external AST sources are used.
QualType getPointeeType() const
Describes a module or submodule.
std::string getFullModuleName(bool AllowStringLiterals=false) const
Retrieve the full name of this module, including the path from its top-level module.
This represents a decl that may have a name.
NamedDecl * getUnderlyingDecl()
Looks through UsingDecls and ObjCCompatibleAliasDecls for the underlying named decl.
StringRef getName() const
Get the name of identifier for this declaration as a StringRef.
DeclarationName getDeclName() const
Get the actual, stored name of the declaration, which may be a special name.
std::string getQualifiedNameAsString() const
Linkage getFormalLinkage() const
Get the linkage from a semantic point of view.
Represent a C++ namespace.
A C++ nested-name-specifier augmented with source location information.
SourceRange getSourceRange() const LLVM_READONLY
Retrieve the source range covering the entirety of this nested-name-specifier.
Represents a C++ nested name specifier, such as "\::std::vector<int>::".
NonTypeTemplateParmDecl - Declares a non-type template parameter, e.g., "Size" in.
Represents an ObjC class declaration.
Represents typeof(type), a C23 feature and GCC extension, or `typeof_unqual(type),...
ObjCMethodDecl - Represents an instance or class method declaration.
Represents a pointer to an Objective C object.
bool isSpecialized() const
Whether this type is specialized, meaning that it has type arguments.
bool isObjCIdType() const
True if this is equivalent to the 'id' type, i.e.
QualType getPointeeType() const
Gets the type pointed to by this ObjC pointer.
ObjCInterfaceDecl * getInterfaceDecl() const
If this pointer points to an Objective @interface type, gets the declaration for that interface.
const ObjCInterfaceType * getInterfaceType() const
If this pointer points to an Objective C @interface type, gets the type for that interface.
bool isObjCClassType() const
True if this is equivalent to the 'Class' type, i.e.
OpaqueValueExpr - An expression referring to an opaque object of a fixed type and value class.
OverloadCandidateSet - A set of overload candidates, used in C++ overload resolution (C++ 13....
void clear(CandidateSetKind CSK)
Clear out all of the candidates.
void AddDeferredTemplateCandidate(FunctionTemplateDecl *FunctionTemplate, DeclAccessPair FoundDecl, ArrayRef< Expr * > Args, bool SuppressUserConversions, bool PartialOverloading, bool AllowExplicit, CallExpr::ADLCallKind IsADLCandidate, OverloadCandidateParamOrder PO, bool AggregateCandidateDeduction)
bool isNewCandidate(Decl *F, OverloadCandidateParamOrder PO=OverloadCandidateParamOrder::Normal)
Determine when this overload candidate will be new to the overload set.
void AddDeferredConversionTemplateCandidate(FunctionTemplateDecl *FunctionTemplate, DeclAccessPair FoundDecl, CXXRecordDecl *ActingContext, Expr *From, QualType ToType, bool AllowObjCConversionOnExplicit, bool AllowExplicit, bool AllowResultConversion)
void AddDeferredMethodTemplateCandidate(FunctionTemplateDecl *MethodTmpl, DeclAccessPair FoundDecl, CXXRecordDecl *ActingContext, QualType ObjectType, Expr::Classification ObjectClassification, ArrayRef< Expr * > Args, bool SuppressUserConversions, bool PartialOverloading, OverloadCandidateParamOrder PO)
void DisableResolutionByPerfectCandidate()
ConversionSequenceList allocateConversionSequences(unsigned NumConversions)
Allocate storage for conversion sequences for NumConversions conversions.
llvm::MutableArrayRef< Expr * > getPersistentArgsArray(unsigned N)
Provide storage for any Expr* arg that must be preserved until deferred template candidates are deduc...
OperatorRewriteInfo getRewriteInfo() const
bool shouldDeferTemplateArgumentDeduction(const LangOptions &Opts) const
@ CSK_AddressOfOverloadSet
C++ [over.match.call.general] Resolve a call through the address of an overload set.
@ CSK_InitByConstructor
C++ [over.match.ctor], [over.match.list] Initialization of an object of class type by constructor,...
@ CSK_InitByUserDefinedConversion
C++ [over.match.copy]: Copy-initialization of an object of class type by user-defined conversion.
@ CSK_Normal
Normal lookup.
@ CSK_Operator
C++ [over.match.oper]: Lookup of operator function candidates in a call using operator syntax.
SmallVectorImpl< OverloadCandidate >::iterator iterator
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...
bool shouldDeferDiags(Sema &S, ArrayRef< Expr * > Args, SourceLocation OpLoc)
Whether diagnostics should be deferred.
OverloadingResult BestViableFunction(Sema &S, SourceLocation Loc, OverloadCandidateSet::iterator &Best)
Find the best viable function on this overload set, if it exists.
void exclude(Decl *F)
Exclude a function from being considered by overload resolution.
SourceLocation getLocation() const
OverloadCandidate & addCandidate(unsigned NumConversions=0, ConversionSequenceList Conversions={})
Add a new candidate with NumConversions conversion sequence slots to the overload set.
void InjectNonDeducedTemplateCandidates(Sema &S)
CandidateSetKind getKind() const
size_t nonDeferredCandidatesCount() const
SmallVector< OverloadCandidate *, 32 > CompleteCandidates(Sema &S, OverloadCandidateDisplayKind OCD, ArrayRef< Expr * > Args, SourceLocation OpLoc=SourceLocation(), llvm::function_ref< bool(OverloadCandidate &)> Filter=[](OverloadCandidate &) { return true;})
A reference to an overloaded function set, either an UnresolvedLookupExpr or an UnresolvedMemberExpr.
bool hasExplicitTemplateArgs() const
Determines whether this expression had explicit template arguments.
static FindResult find(Expr *E)
Finds the overloaded expression in the given expression E of OverloadTy.
NestedNameSpecifier getQualifier() const
Fetches the nested-name qualifier, if one was given.
SourceLocation getNameLoc() const
Gets the location of the name.
UnresolvedSetImpl::iterator decls_iterator
decls_iterator decls_begin() const
unsigned getNumDecls() const
Gets the number of declarations in the unresolved set.
SourceLocation getTemplateKeywordLoc() const
Retrieve the location of the template keyword preceding this name, if any.
NestedNameSpecifierLoc getQualifierLoc() const
Fetches the nested-name qualifier with source-location information, if one was given.
void copyTemplateArgumentsInto(TemplateArgumentListInfo &List) const
Copies the template arguments into the given structure.
decls_iterator decls_end() const
DeclarationName getName() const
Gets the name looked up.
A single parameter index whose accessors require each use to make explicit the parameter index encodi...
ParenExpr - This represents a parenthesized expression, e.g.
Represents a parameter to a function.
bool hasDefaultArg() const
Determines whether this parameter has a default argument, either parsed or not.
bool isEquivalent(PointerAuthQualifier Other) const
std::string getAsString() const
PointerType - C99 6.7.5.1 - Pointer Declarators.
QualType getPointeeType() const
static PseudoObjectExpr * Create(const ASTContext &Context, Expr *syntactic, ArrayRef< Expr * > semantic, unsigned resultIndex)
A (possibly-)qualified type.
bool isVolatileQualified() const
Determine whether this type is volatile-qualified.
bool isRestrictQualified() const
Determine whether this type is restrict-qualified.
bool hasQualifiers() const
Determine whether this type has any qualifiers.
QualType getNonLValueExprType(const ASTContext &Context) const
Determine the type of a (typically non-lvalue) expression with the specified result type.
QualType getLocalUnqualifiedType() const
Return this type with all of the instance-specific qualifiers removed, but without removing any quali...
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.
void getAsStringInternal(std::string &Str, const PrintingPolicy &Policy) const
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.
unsigned getLocalCVRQualifiers() const
Retrieve the set of CVR (const-volatile-restrict) qualifiers local to this particular QualType instan...
bool isMoreQualifiedThan(QualType Other, const ASTContext &Ctx) const
Determine whether this type is more qualified than the other given type, requiring exact equality for...
bool isConstQualified() const
Determine whether this type is const-qualified.
bool hasAddressSpace() const
Check if this type has any address space qualifier.
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)
bool isAtLeastAsQualifiedAs(QualType Other, const ASTContext &Ctx) const
Determine whether this type is at least as qualified as the other given type, requiring exact equalit...
Qualifiers getLocalQualifiers() const
Retrieve the set of qualifiers local to this particular QualType instance, not including any qualifie...
A qualifier set is used to build a set of qualifiers.
const Type * strip(QualType type)
Collect any qualifiers on the given type and return an unqualified type.
QualType apply(const ASTContext &Context, QualType QT) const
Apply the collected qualifiers to the given type.
QualifiersAndAtomic withVolatile()
QualifiersAndAtomic withAtomic()
The collection of all-type qualifiers we support.
unsigned getCVRQualifiers() const
bool hasOnlyConst() const
@ OCL_ExplicitNone
This object can be modified without requiring retains or releases.
void removeObjCLifetime()
bool compatiblyIncludes(Qualifiers other, const ASTContext &Ctx) const
Determines if these qualifiers compatibly include another set.
static bool isAddressSpaceSupersetOf(LangAS A, LangAS B, const ASTContext &Ctx)
Returns true if address space A is equal to or a superset of B.
void removeAddressSpace()
void setAddressSpace(LangAS space)
PointerAuthQualifier getPointerAuth() const
bool hasObjCGCAttr() const
ObjCLifetime getObjCLifetime() const
std::string getAsString() const
LangAS getAddressSpace() const
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.
field_range fields() const
Base for LValueReferenceType and RValueReferenceType.
QualType getPointeeType() const
Scope - A scope is a transient data structure that is used while parsing the program.
Smart pointer class that efficiently represents Objective-C method names.
unsigned getNumArgs() const
bool areCompatibleSveTypes(QualType FirstType, QualType SecondType)
Return true if the given types are an SVE builtin and a VectorType that is a fixed-length representat...
bool areLaxCompatibleSveTypes(QualType FirstType, QualType SecondType)
Return true if the given vector types are lax-compatible SVE vector types, false otherwise.
SemaDiagnosticBuilder Diag(SourceLocation Loc, unsigned DiagID, bool DeferHint=false)
Emit a diagnostic.
PartialDiagnostic PDiag(unsigned DiagID=0)
Build a partial diagnostic.
bool IsAllowedCall(const FunctionDecl *Caller, const FunctionDecl *Callee)
Determines whether Caller may invoke Callee, based on their CUDA host/device attributes.
CUDAFunctionTarget IdentifyTarget(const FunctionDecl *D, bool IgnoreImplicitHDAttr=false)
Determines whether the given function is a CUDA device/host/kernel/etc.
bool inferTargetForImplicitSpecialMember(CXXRecordDecl *ClassDecl, CXXSpecialMemberKind CSM, CXXMethodDecl *MemberDecl, bool ConstRHS, bool Diagnose)
Given a implicit special member, infer its CUDA target from the calls it needs to make to underlying ...
static bool isImplicitHostDeviceFunction(const FunctionDecl *D)
void EraseUnwantedMatches(const FunctionDecl *Caller, llvm::SmallVectorImpl< std::pair< DeclAccessPair, FunctionDecl * > > &Matches)
Finds a function in Matches with highest calling priority from Caller context and erases all function...
CUDAFunctionPreference IdentifyPreference(const FunctionDecl *Caller, const FunctionDecl *Callee)
Identifies relative preference of a given Caller/Callee combination, based on their host/device attri...
bool isObjCWritebackConversion(QualType FromType, QualType ToType, QualType &ConvertedType)
Determine whether this is an Objective-C writeback conversion, used for parameter passing when perfor...
Expr * stripARCUnbridgedCast(Expr *e)
stripARCUnbridgedCast - Given an expression of ARCUnbridgedCast type, remove the placeholder cast.
Abstract base class used to perform a contextual implicit conversion from an expression to any type p...
virtual SemaDiagnosticBuilder noteAmbiguous(Sema &S, CXXConversionDecl *Conv, QualType ConvTy)=0
Emits a note for one of the candidate conversions.
virtual SemaDiagnosticBuilder diagnoseNoMatch(Sema &S, SourceLocation Loc, QualType T)=0
Emits a diagnostic complaining that the expression does not have integral or enumeration type.
virtual SemaDiagnosticBuilder noteExplicitConv(Sema &S, CXXConversionDecl *Conv, QualType ConvTy)=0
Emits a note for the explicit conversion function.
virtual SemaDiagnosticBuilder diagnoseExplicitConv(Sema &S, SourceLocation Loc, QualType T, QualType ConvTy)=0
Emits a diagnostic when the only matching conversion function is explicit.
virtual SemaDiagnosticBuilder diagnoseConversion(Sema &S, SourceLocation Loc, QualType T, QualType ConvTy)=0
Emits a diagnostic when we picked a conversion function (for cases when we are not allowed to pick a ...
virtual SemaDiagnosticBuilder diagnoseAmbiguous(Sema &S, SourceLocation Loc, QualType T)=0
Emits a diagnostic when there are multiple possible conversion functions.
virtual bool match(QualType T)=0
Determine whether the specified type is a valid destination type for this conversion.
virtual SemaDiagnosticBuilder diagnoseIncomplete(Sema &S, SourceLocation Loc, QualType T)=0
Emits a diagnostic when the expression has incomplete class type.
For a defaulted function, the kind of defaulted function that it is.
bool isSpecialMember() const
bool isComparison() const
CXXSpecialMemberKind asSpecialMember() const
RAII class to control scope of DeferDiags.
bool match(QualType T) override
Match an integral or (possibly scoped) enumeration type.
RAII class used to determine whether SFINAE has trapped any errors that occur during template argumen...
bool hasErrorOccurred() const
Determine whether any SFINAE errors have been trapped.
Sema - This implements semantic analysis and AST building for C.
bool TryFunctionConversion(QualType FromType, QualType ToType, QualType &ResultTy) const
Same as IsFunctionConversion, but if this would return true, it sets ResultTy to ToType.
QualType getCurrentThisType()
Try to retrieve the type of the 'this' pointer.
ExprResult BuildBlockForLambdaConversion(SourceLocation CurrentLocation, SourceLocation ConvLocation, CXXConversionDecl *Conv, Expr *Src)
bool diagnoseArgDependentDiagnoseIfAttrs(const FunctionDecl *Function, const Expr *ThisArg, ArrayRef< const Expr * > Args, SourceLocation Loc)
Emit diagnostics for the diagnose_if attributes on Function, ignoring any non-ArgDependent DiagnoseIf...
ExprResult PerformContextuallyConvertToObjCPointer(Expr *From)
PerformContextuallyConvertToObjCPointer - Perform a contextual conversion of the expression From to a...
bool buildOverloadedCallSet(Scope *S, Expr *Fn, UnresolvedLookupExpr *ULE, MultiExprArg Args, SourceLocation RParenLoc, OverloadCandidateSet *CandidateSet, ExprResult *Result)
Constructs and populates an OverloadedCandidateSet from the given function.
void HideUsingShadowDecl(Scope *S, UsingShadowDecl *Shadow)
Hides a using shadow declaration.
bool IsBuildingRecoveryCallExpr
Flag indicating if Sema is building a recovery call expression.
DefaultedFunctionKind getDefaultedFunctionKind(const FunctionDecl *FD)
Determine the kind of defaulting that would be done for a given function.
ExprResult BuildMemberReferenceExpr(Expr *Base, QualType BaseType, SourceLocation OpLoc, bool IsArrow, CXXScopeSpec &SS, SourceLocation TemplateKWLoc, NamedDecl *FirstQualifierInScope, const DeclarationNameInfo &NameInfo, const TemplateArgumentListInfo *TemplateArgs, const Scope *S, ActOnMemberAccessExtraArgs *ExtraArgs=nullptr)
bool IsOverload(FunctionDecl *New, FunctionDecl *Old, bool UseMemberUsingDeclRules, bool ConsiderCudaAttrs=true)
ExprResult CreateBuiltinUnaryOp(SourceLocation OpLoc, UnaryOperatorKind Opc, Expr *InputExpr, bool IsAfterAmp=false)
@ LookupOrdinaryName
Ordinary name lookup, which finds ordinary names (functions, variables, typedefs, etc....
@ LookupUsingDeclName
Look up all declarations in a scope with the given name, including resolved using declarations.
@ LookupOperatorName
Look up of an operator name (e.g., operator+) for use with operator overloading.
@ LookupMemberName
Member name lookup, which finds the names of class/struct/union members.
void DiagnoseSentinelCalls(const NamedDecl *D, SourceLocation Loc, ArrayRef< Expr * > Args)
DiagnoseSentinelCalls - This routine checks whether a call or message-send is to a declaration with t...
ImplicitConversionSequence TryImplicitConversion(Expr *From, QualType ToType, bool SuppressUserConversions, AllowedExplicit AllowExplicit, bool InOverloadResolution, bool CStyle, bool AllowObjCWritebackConversion)
ExprResult BuildLiteralOperatorCall(LookupResult &R, DeclarationNameInfo &SuffixInfo, ArrayRef< Expr * > Args, SourceLocation LitEndLoc, TemplateArgumentListInfo *ExplicitTemplateArgs=nullptr)
BuildLiteralOperatorCall - Build a UserDefinedLiteral by creating a call to a literal operator descri...
bool IsStringInit(Expr *Init, const ArrayType *AT)
ExprResult CreateBuiltinBinOp(SourceLocation OpLoc, BinaryOperatorKind Opc, Expr *LHSExpr, Expr *RHSExpr, bool ForFoldExpression=false)
CreateBuiltinBinOp - Creates a new built-in binary operation with operator Opc at location TokLoc.
ExprResult CreateOverloadedArraySubscriptExpr(SourceLocation LLoc, SourceLocation RLoc, Expr *Base, MultiExprArg Args)
void LookupOverloadedBinOp(OverloadCandidateSet &CandidateSet, OverloadedOperatorKind Op, const UnresolvedSetImpl &Fns, ArrayRef< Expr * > Args, bool RequiresADL=true)
Perform lookup for an overloaded binary operator.
bool isImplicitlyDeleted(FunctionDecl *FD)
Determine whether the given function is an implicitly-deleted special member function.
void PushExpressionEvaluationContext(ExpressionEvaluationContext NewContext, Decl *LambdaContextDecl=nullptr, ExpressionEvaluationContextRecord::ExpressionKind Type=ExpressionEvaluationContextRecord::EK_Other)
bool TemplateParameterListsAreEqual(const TemplateCompareNewDeclInfo &NewInstFrom, TemplateParameterList *New, const NamedDecl *OldInstFrom, TemplateParameterList *Old, bool Complain, TemplateParameterListEqualKind Kind, SourceLocation TemplateArgLoc=SourceLocation())
Determine whether the given template parameter lists are equivalent.
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.
@ Ref_Related
Ref_Related - The two types are reference-related, which means that their unqualified forms (T1 and T...
void AddTemplateConversionCandidate(FunctionTemplateDecl *FunctionTemplate, DeclAccessPair FoundDecl, CXXRecordDecl *ActingContext, Expr *From, QualType ToType, OverloadCandidateSet &CandidateSet, bool AllowObjCConversionOnExplicit, bool AllowExplicit, bool AllowResultConversion=true)
Adds a conversion function template specialization candidate to the overload set, using template argu...
FunctionDecl * getMoreConstrainedFunction(FunctionDecl *FD1, FunctionDecl *FD2)
Returns the more constrained function according to the rules of partial ordering by constraints (C++ ...
void AddBuiltinCandidate(QualType *ParamTys, ArrayRef< Expr * > Args, OverloadCandidateSet &CandidateSet, bool IsAssignmentOperator=false, unsigned NumContextualBoolArguments=0)
AddBuiltinCandidate - Add a candidate for a built-in operator.
ExprResult MaybeBindToTemporary(Expr *E)
MaybeBindToTemporary - If the passed in expression has a record type with a non-trivial destructor,...
void AddArgumentDependentLookupCandidates(DeclarationName Name, SourceLocation Loc, ArrayRef< Expr * > Args, TemplateArgumentListInfo *ExplicitTemplateArgs, OverloadCandidateSet &CandidateSet, bool PartialOverloading=false)
Add function candidates found via argument-dependent lookup to the set of overloading candidates.
ExprResult EvaluateConvertedConstantExpression(Expr *E, QualType T, APValue &Value, CCEKind CCE, bool RequireInt, const APValue &PreNarrowingValue)
EvaluateConvertedConstantExpression - Evaluate an Expression That is a converted constant expression ...
FPOptionsOverride CurFPFeatureOverrides()
ExprResult BuildOverloadedArrowExpr(Scope *S, Expr *Base, SourceLocation OpLoc, bool *NoArrowOperatorFound=nullptr)
BuildOverloadedArrowExpr - Build a call to an overloaded operator-> (if one exists),...
ExprResult BuildCallToMemberFunction(Scope *S, Expr *MemExpr, SourceLocation LParenLoc, MultiExprArg Args, SourceLocation RParenLoc, Expr *ExecConfig=nullptr, bool IsExecConfig=false, bool AllowRecovery=false)
BuildCallToMemberFunction - Build a call to a member function.
AssignConvertType CheckSingleAssignmentConstraints(QualType LHSType, ExprResult &RHS, bool Diagnose=true, bool DiagnoseCFAudited=false, bool ConvertRHS=true)
Check assignment constraints for an assignment of RHS to LHSType.
FunctionDecl * getCurFunctionDecl(bool AllowLambda=false) const
Returns a pointer to the innermost enclosing function, or nullptr if the current context is not insid...
ExprResult PerformContextualImplicitConversion(SourceLocation Loc, Expr *FromE, ContextualImplicitConverter &Converter)
Perform a contextual implicit conversion.
ExprResult DefaultVariadicArgumentPromotion(Expr *E, VariadicCallType CT, FunctionDecl *FDecl)
bool DeduceReturnType(FunctionDecl *FD, SourceLocation Loc, bool Diagnose=true)
bool IsQualificationConversion(QualType FromType, QualType ToType, bool CStyle, bool &ObjCLifetimeConversion)
IsQualificationConversion - Determines whether the conversion from an rvalue of type FromType to ToTy...
void diagnoseNullableToNonnullConversion(QualType DstType, QualType SrcType, SourceLocation Loc)
Warn if we're implicitly casting from a _Nullable pointer type to a _Nonnull one.
DiagnosticsEngine & getDiagnostics() const
bool checkAddressOfFunctionIsAvailable(const FunctionDecl *Function, bool Complain=false, SourceLocation Loc=SourceLocation())
Returns whether the given function's address can be taken or not, optionally emitting a diagnostic if...
bool CheckNonDependentConversions(FunctionTemplateDecl *FunctionTemplate, ArrayRef< QualType > ParamTypes, ArrayRef< Expr * > Args, OverloadCandidateSet &CandidateSet, ConversionSequenceList &Conversions, CheckNonDependentConversionsFlag UserConversionFlag, CXXRecordDecl *ActingContext=nullptr, QualType ObjectType=QualType(), Expr::Classification ObjectClassification={}, OverloadCandidateParamOrder PO={})
Check that implicit conversion sequences can be formed for each argument whose corresponding paramete...
bool isObjCPointerConversion(QualType FromType, QualType ToType, QualType &ConvertedType, bool &IncompatibleObjC)
isObjCPointerConversion - Determines whether this is an Objective-C pointer conversion.
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....
bool FunctionParamTypesAreEqual(ArrayRef< QualType > Old, ArrayRef< QualType > New, unsigned *ArgPos=nullptr, bool Reversed=false)
FunctionParamTypesAreEqual - This routine checks two function proto types for equality of their param...
ExprResult PerformImplicitObjectArgumentInitialization(Expr *From, NestedNameSpecifier Qualifier, NamedDecl *FoundDecl, CXXMethodDecl *Method)
PerformObjectArgumentInitialization - Perform initialization of the implicit object parameter for the...
ExprResult DefaultFunctionArrayLvalueConversion(Expr *E, bool Diagnose=true)
ASTContext & getASTContext() const
UnresolvedSetIterator getMostSpecialized(UnresolvedSetIterator SBegin, UnresolvedSetIterator SEnd, TemplateSpecCandidateSet &FailedCandidates, SourceLocation Loc, const PartialDiagnostic &NoneDiag, const PartialDiagnostic &AmbigDiag, const PartialDiagnostic &CandidateDiag, bool Complain=true, QualType TargetType=QualType())
Retrieve the most specialized of the given function template specializations.
bool IsIntegralPromotion(Expr *From, QualType FromType, QualType ToType)
IsIntegralPromotion - Determines whether the conversion from the expression From (whose potentially-a...
bool IsFloatingPointPromotion(QualType FromType, QualType ToType)
IsFloatingPointPromotion - Determines whether the conversion from FromType to ToType is a floating po...
ExprResult BuildTemplateIdExpr(const CXXScopeSpec &SS, SourceLocation TemplateKWLoc, LookupResult &R, bool RequiresADL, const TemplateArgumentListInfo *TemplateArgs)
void PopExpressionEvaluationContext()
ExprResult CreateOverloadedBinOp(SourceLocation OpLoc, BinaryOperatorKind Opc, const UnresolvedSetImpl &Fns, Expr *LHS, Expr *RHS, bool RequiresADL=true, bool AllowRewrittenCandidates=true, FunctionDecl *DefaultedFn=nullptr)
Create a binary operation that may resolve to an overloaded operator.
ExprResult ImpCastExprToType(Expr *E, QualType Type, CastKind CK, ExprValueKind VK=VK_PRValue, const CXXCastPath *BasePath=nullptr, CheckedConversionKind CCK=CheckedConversionKind::Implicit)
ImpCastExprToType - If Expr is not of type 'Type', insert an implicit cast.
bool FunctionNonObjectParamTypesAreEqual(const FunctionDecl *OldFunction, const FunctionDecl *NewFunction, unsigned *ArgPos=nullptr, bool Reversed=false)
bool isInitListConstructor(const FunctionDecl *Ctor)
Determine whether Ctor is an initializer-list constructor, as defined in [dcl.init....
llvm::SmallSetVector< CXXRecordDecl *, 16 > AssociatedClassSet
std::string getAmbiguousPathsDisplayString(CXXBasePaths &Paths)
Builds a string representing ambiguous paths from a specific derived class to different subobjects of...
AccessResult CheckMemberOperatorAccess(SourceLocation Loc, Expr *ObjectExpr, const SourceRange &, DeclAccessPair FoundDecl)
OverloadKind CheckOverload(Scope *S, FunctionDecl *New, const LookupResult &OldDecls, NamedDecl *&OldDecl, bool UseMemberUsingDeclRules)
Determine whether the given New declaration is an overload of the declarations in Old.
QualType ExtractUnqualifiedFunctionType(QualType PossiblyAFunctionType)
bool IsPointerConversion(Expr *From, QualType FromType, QualType ToType, bool InOverloadResolution, QualType &ConvertedType, bool &IncompatibleObjC)
IsPointerConversion - Determines whether the conversion of the expression From, which has the (possib...
@ Conversions
Allow explicit conversion functions but not explicit constructors.
void DiagnoseUseOfDeletedFunction(SourceLocation Loc, SourceRange Range, DeclarationName Name, OverloadCandidateSet &CandidateSet, FunctionDecl *Fn, MultiExprArg Args, bool IsMember=false)
PrintingPolicy getPrintingPolicy() const
Retrieve a suitable printing policy for diagnostics.
bool IsComplexPromotion(QualType FromType, QualType ToType)
Determine if a conversion is a complex promotion.
bool pushCodeSynthesisContext(CodeSynthesisContext Ctx)
Module * getOwningModule(const Decl *Entity)
Get the module owning an entity.
DeclRefExpr * BuildDeclRefExpr(ValueDecl *D, QualType Ty, ExprValueKind VK, SourceLocation Loc, const CXXScopeSpec *SS=nullptr)
ExprResult CheckConvertedConstantExpression(Expr *From, QualType T, llvm::APSInt &Value, CCEKind CCE)
@ TPL_TemplateMatch
We are matching the template parameter lists of two templates that might be redeclarations.
bool AddingCFIUncheckedCallee(QualType From, QualType To) const
Returns true if From is a function or pointer to a function without the cfi_unchecked_callee attribut...
void AddConversionCandidate(CXXConversionDecl *Conversion, DeclAccessPair FoundDecl, CXXRecordDecl *ActingContext, Expr *From, QualType ToType, OverloadCandidateSet &CandidateSet, bool AllowObjCConversionOnExplicit, bool AllowExplicit, bool AllowResultConversion=true, bool StrictPackMatch=false)
AddConversionCandidate - Add a C++ conversion function as a candidate in the candidate set (C++ [over...
bool IsBlockPointerConversion(QualType FromType, QualType ToType, QualType &ConvertedType)
bool CheckFunctionTemplateSpecialization(FunctionDecl *FD, TemplateArgumentListInfo *ExplicitTemplateArgs, LookupResult &Previous, bool QualifiedFriend=false)
Perform semantic analysis for the given function template specialization.
void FindAssociatedClassesAndNamespaces(SourceLocation InstantiationLoc, ArrayRef< Expr * > Args, AssociatedNamespaceSet &AssociatedNamespaces, AssociatedClassSet &AssociatedClasses)
Find the associated classes and namespaces for argument-dependent lookup for a call with the given se...
void AddMethodTemplateCandidate(FunctionTemplateDecl *MethodTmpl, DeclAccessPair FoundDecl, CXXRecordDecl *ActingContext, TemplateArgumentListInfo *ExplicitTemplateArgs, QualType ObjectType, Expr::Classification ObjectClassification, ArrayRef< Expr * > Args, OverloadCandidateSet &CandidateSet, bool SuppressUserConversions=false, bool PartialOverloading=false, OverloadCandidateParamOrder PO={})
Add a C++ member function template as a candidate to the candidate set, using template argument deduc...
void DiagnoseSelfMove(const Expr *LHSExpr, const Expr *RHSExpr, SourceLocation OpLoc)
DiagnoseSelfMove - Emits a warning if a value is moved to itself.
bool isSameOrCompatibleFunctionType(QualType Param, QualType Arg)
Compare types for equality with respect to possibly compatible function types (noreturn adjustment,...
void AddTemplateOverloadCandidate(FunctionTemplateDecl *FunctionTemplate, DeclAccessPair FoundDecl, TemplateArgumentListInfo *ExplicitTemplateArgs, ArrayRef< Expr * > Args, OverloadCandidateSet &CandidateSet, bool SuppressUserConversions=false, bool PartialOverloading=false, bool AllowExplicit=true, ADLCallKind IsADLCandidate=ADLCallKind::NotADL, OverloadCandidateParamOrder PO={}, bool AggregateCandidateDeduction=false)
Add a C++ function template specialization as a candidate in the candidate set, using template argume...
Sema(Preprocessor &pp, ASTContext &ctxt, ASTConsumer &consumer, TranslationUnitKind TUKind=TU_Complete, CodeCompleteConsumer *CompletionConsumer=nullptr)
SourceLocation getLocForEndOfToken(SourceLocation Loc, unsigned Offset=0)
Calls Lexer::getLocForEndOfToken()
const LangOptions & getLangOpts() const
const FunctionProtoType * ResolveExceptionSpec(SourceLocation Loc, const FunctionProtoType *FPT)
bool isEquivalentInternalLinkageDeclaration(const NamedDecl *A, const NamedDecl *B)
Determine if A and B are equivalent internal linkage declarations from different modules,...
bool DiagnoseEmptyLookup(Scope *S, CXXScopeSpec &SS, LookupResult &R, CorrectionCandidateCallback &CCC, TemplateArgumentListInfo *ExplicitTemplateArgs=nullptr, ArrayRef< Expr * > Args={}, DeclContext *LookupCtx=nullptr)
Diagnose an empty lookup.
ExprResult BuildCallExpr(Scope *S, Expr *Fn, SourceLocation LParenLoc, MultiExprArg ArgExprs, SourceLocation RParenLoc, Expr *ExecConfig=nullptr, bool IsExecConfig=false, bool AllowRecovery=false)
BuildCallExpr - Handle a call to Fn with the specified array of arguments.
ExprResult BuildSynthesizedThreeWayComparison(SourceLocation OpLoc, const UnresolvedSetImpl &Fns, Expr *LHS, Expr *RHS, FunctionDecl *DefaultedFn)
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 CheckUseOfCXXMethodAsAddressOfOperand(SourceLocation OpLoc, const Expr *Op, const CXXMethodDecl *MD)
AccessResult CheckUnresolvedMemberAccess(UnresolvedMemberExpr *E, DeclAccessPair FoundDecl)
Perform access-control checking on a previously-unresolved member access which has now been resolved ...
void AddBuiltinOperatorCandidates(OverloadedOperatorKind Op, SourceLocation OpLoc, ArrayRef< Expr * > Args, OverloadCandidateSet &CandidateSet)
AddBuiltinOperatorCandidates - Add the appropriate built-in operator overloads to the candidate set (...
void AddOverloadCandidate(FunctionDecl *Function, DeclAccessPair FoundDecl, ArrayRef< Expr * > Args, OverloadCandidateSet &CandidateSet, bool SuppressUserConversions=false, bool PartialOverloading=false, bool AllowExplicit=true, bool AllowExplicitConversion=false, ADLCallKind IsADLCandidate=ADLCallKind::NotADL, ConversionSequenceList EarlyConversions={}, OverloadCandidateParamOrder PO={}, bool AggregateCandidateDeduction=false, bool StrictPackMatch=false)
AddOverloadCandidate - Adds the given function to the set of candidate functions, using the given fun...
const LangOptions & LangOpts
bool IsMemberPointerConversion(Expr *From, QualType FromType, QualType ToType, bool InOverloadResolution, QualType &ConvertedType)
IsMemberPointerConversion - Determines whether the conversion of the expression From,...
ExprResult BuildResolvedCallExpr(Expr *Fn, NamedDecl *NDecl, SourceLocation LParenLoc, ArrayRef< Expr * > Arg, SourceLocation RParenLoc, Expr *Config=nullptr, bool IsExecConfig=false, ADLCallKind UsesADL=ADLCallKind::NotADL)
BuildResolvedCallExpr - Build a call to a resolved expression, i.e.
ExprResult BuildCXXMemberCallExpr(Expr *Exp, NamedDecl *FoundDecl, CXXConversionDecl *Method, bool HadMultipleCandidates)
ExprResult CheckForImmediateInvocation(ExprResult E, FunctionDecl *Decl)
Wrap the expression in a ConstantExpr if it is a potential immediate invocation.
llvm::SmallSetVector< DeclContext *, 16 > AssociatedNamespaceSet
MemberPointerConversionDirection
bool diagnoseArgIndependentDiagnoseIfAttrs(const NamedDecl *ND, SourceLocation Loc)
Emit diagnostics for the diagnose_if attributes on Function, ignoring any ArgDependent DiagnoseIfAttr...
ExprResult BuildConvertedConstantExpression(Expr *From, QualType T, CCEKind CCE, NamedDecl *Dest=nullptr)
void popCodeSynthesisContext()
bool AreConstraintExpressionsEqual(const NamedDecl *Old, const Expr *OldConstr, const TemplateCompareNewDeclInfo &New, const Expr *NewConstr)
ReferenceConversionsScope::ReferenceConversions ReferenceConversions
MemberPointerConversionResult CheckMemberPointerConversion(QualType FromType, const MemberPointerType *ToPtrType, CastKind &Kind, CXXCastPath &BasePath, SourceLocation CheckLoc, SourceRange OpRange, bool IgnoreBaseAccess, MemberPointerConversionDirection Direction)
CheckMemberPointerConversion - Check the member pointer conversion from the expression From to the ty...
Expr * BuildCXXThisExpr(SourceLocation Loc, QualType Type, bool IsImplicit)
Build a CXXThisExpr and mark it referenced in the current context.
ExprResult CreateOverloadedUnaryOp(SourceLocation OpLoc, UnaryOperatorKind Opc, const UnresolvedSetImpl &Fns, Expr *input, bool RequiresADL=true)
Create a unary operation that may resolve to an overloaded operator.
std::optional< sema::TemplateDeductionInfo * > isSFINAEContext() const
Determines whether we are currently in a context where template argument substitution failures are no...
void AddOverloadedCallCandidates(UnresolvedLookupExpr *ULE, ArrayRef< Expr * > Args, OverloadCandidateSet &CandidateSet, bool PartialOverloading=false)
Add the overload candidates named by callee and/or found by argument dependent lookup to the given ov...
ExprResult DefaultLvalueConversion(Expr *E)
ExprResult BuildDeclarationNameExpr(const CXXScopeSpec &SS, LookupResult &R, bool NeedsADL, bool AcceptInvalidDecl=false)
bool isVisible(const NamedDecl *D)
Determine whether a declaration is visible to name lookup.
bool CheckDerivedToBaseConversion(QualType Derived, QualType Base, SourceLocation Loc, SourceRange Range, CXXCastPath *BasePath=nullptr, bool IgnoreAccess=false)
void NoteOverloadCandidate(const NamedDecl *Found, const FunctionDecl *Fn, OverloadCandidateRewriteKind RewriteKind=OverloadCandidateRewriteKind(), QualType DestType=QualType(), bool TakingAddress=false)
bool DiagnoseMultipleUserDefinedConversion(Expr *From, QualType ToType)
bool DiagnoseUseOfOverloadedDecl(NamedDecl *D, SourceLocation Loc)
void ArgumentDependentLookup(DeclarationName Name, SourceLocation Loc, ArrayRef< Expr * > Args, ADLResult &Functions)
FunctionDecl * resolveAddressOfSingleOverloadCandidate(Expr *E, DeclAccessPair &FoundResult)
Given an expression that refers to an overloaded function, try to resolve that function to a single f...
DeclContext * CurContext
CurContext - This is the current declaration context of parsing.
MaterializeTemporaryExpr * CreateMaterializeTemporaryExpr(QualType T, Expr *Temporary, bool BoundToLvalueReference)
void DiagnoseUnsatisfiedConstraint(const ConstraintSatisfaction &Satisfaction, SourceLocation Loc={}, bool First=true)
Emit diagnostics explaining why a constraint expression was deemed unsatisfied.
ExprResult PerformContextuallyConvertToBool(Expr *From)
PerformContextuallyConvertToBool - Perform a contextual conversion of the expression From to bool (C+...
bool CheckFunctionConstraints(const FunctionDecl *FD, ConstraintSatisfaction &Satisfaction, SourceLocation UsageLoc=SourceLocation(), bool ForOverloadResolution=false)
Check whether the given function decl's trailing requires clause is satisfied, if any.
bool IsDerivedFrom(SourceLocation Loc, CXXRecordDecl *Derived, CXXRecordDecl *Base, CXXBasePaths &Paths)
Determine whether the type Derived is a C++ class that is derived from the type Base.
bool isUnevaluatedContext() const
Determines whether we are currently in a context that is not evaluated as per C++ [expr] p5.
ObjCMethodDecl * SelectBestMethod(Selector Sel, MultiExprArg Args, bool IsInstance, SmallVectorImpl< ObjCMethodDecl * > &Methods)
FunctionDecl * ResolveSingleFunctionTemplateSpecialization(OverloadExpr *ovl, bool Complain=false, DeclAccessPair *Found=nullptr, TemplateSpecCandidateSet *FailedTSC=nullptr, bool ForTypeDeduction=false)
Given an expression that refers to an overloaded function, try to resolve that overloaded function ex...
AccessResult CheckAddressOfMemberAccess(Expr *OvlExpr, DeclAccessPair FoundDecl)
void MarkDeclRefReferenced(DeclRefExpr *E, const Expr *Base=nullptr)
Perform reference-marking and odr-use handling for a DeclRefExpr.
ExprResult CheckPlaceholderExpr(Expr *E)
Check for operands with placeholder types and complain if found.
EnableIfAttr * CheckEnableIf(FunctionDecl *Function, SourceLocation CallLoc, ArrayRef< Expr * > Args, bool MissingImplicitThis=false)
Check the enable_if expressions on the given function.
ExprResult CreateUnresolvedLookupExpr(CXXRecordDecl *NamingClass, NestedNameSpecifierLoc NNSLoc, DeclarationNameInfo DNI, const UnresolvedSetImpl &Fns, bool PerformADL=true)
bool inTemplateInstantiation() const
Determine whether we are currently performing template instantiation.
void AddMethodCandidate(DeclAccessPair FoundDecl, QualType ObjectType, Expr::Classification ObjectClassification, ArrayRef< Expr * > Args, OverloadCandidateSet &CandidateSet, bool SuppressUserConversion=false, OverloadCandidateParamOrder PO={})
AddMethodCandidate - Adds a named decl (which is some kind of method) as a method candidate to the gi...
void diagnoseEquivalentInternalLinkageDeclarations(SourceLocation Loc, const NamedDecl *D, ArrayRef< const NamedDecl * > Equiv)
ExprResult FixOverloadedFunctionReference(Expr *E, DeclAccessPair FoundDecl, FunctionDecl *Fn)
FixOverloadedFunctionReference - E is an expression that refers to a C++ overloaded function (possibl...
ExprResult ActOnConditionalOp(SourceLocation QuestionLoc, SourceLocation ColonLoc, Expr *CondExpr, Expr *LHSExpr, Expr *RHSExpr)
ActOnConditionalOp - Parse a ?
ExprResult BuildPossibleImplicitMemberExpr(const CXXScopeSpec &SS, SourceLocation TemplateKWLoc, LookupResult &R, const TemplateArgumentListInfo *TemplateArgs, const Scope *S)
Builds an expression which might be an implicit member expression.
bool resolveAndFixAddressOfSingleOverloadCandidate(ExprResult &SrcExpr, bool DoFunctionPointerConversion=false)
Given an overloaded function, tries to turn it into a non-overloaded function reference using resolve...
CallExpr::ADLCallKind ADLCallKind
bool DiagRuntimeBehavior(SourceLocation Loc, const Stmt *Statement, const PartialDiagnostic &PD)
Conditionally issue a diagnostic based on the current evaluation context.
ExprResult BuildCXXDefaultArgExpr(SourceLocation CallLoc, FunctionDecl *FD, ParmVarDecl *Param, Expr *Init=nullptr)
BuildCXXDefaultArgExpr - Creates a CXXDefaultArgExpr, instantiating the default expr if needed.
bool anyAltivecTypes(QualType srcType, QualType destType)
bool isLaxVectorConversion(QualType srcType, QualType destType)
Is this a legal conversion between two types, one of which is known to be a vector type?
ExprResult BuildOverloadedCallExpr(Scope *S, Expr *Fn, UnresolvedLookupExpr *ULE, SourceLocation LParenLoc, MultiExprArg Args, SourceLocation RParenLoc, Expr *ExecConfig, bool AllowTypoCorrection=true, bool CalleesAddressIsTaken=false)
BuildOverloadedCallExpr - Given the call expression that calls Fn (which eventually refers to the dec...
ExprResult PerformImplicitConversion(Expr *From, QualType ToType, const ImplicitConversionSequence &ICS, AssignmentAction Action, CheckedConversionKind CCK=CheckedConversionKind::Implicit)
PerformImplicitConversion - Perform an implicit conversion of the expression From to the type ToType ...
bool DiagnoseUseOfDecl(NamedDecl *D, ArrayRef< SourceLocation > Locs, const ObjCInterfaceDecl *UnknownObjCClass=nullptr, bool ObjCPropertyAccess=false, bool AvoidPartialAvailabilityChecks=false, ObjCInterfaceDecl *ClassReciever=nullptr, bool SkipTrailingRequiresClause=false)
Determine whether the use of this declaration is valid, and emit any corresponding diagnostics.
ExprResult BuildCallToObjectOfClassType(Scope *S, Expr *Object, SourceLocation LParenLoc, MultiExprArg Args, SourceLocation RParenLoc)
BuildCallToObjectOfClassType - Build a call to an object of class type (C++ [over....
bool isCompleteType(SourceLocation Loc, QualType T, CompleteTypeKind Kind=CompleteTypeKind::Default)
bool CanPerformAggregateInitializationForOverloadResolution(const InitializedEntity &Entity, InitListExpr *From)
Determine whether we can perform aggregate initialization for the purposes of overload resolution.
bool IsOverride(FunctionDecl *MD, FunctionDecl *BaseMD, bool UseMemberUsingDeclRules, bool ConsiderCudaAttrs=true)
bool isStdInitializerList(QualType Ty, QualType *Element)
Tests whether Ty is an instance of std::initializer_list and, if it is and Element is not NULL,...
void AddFunctionCandidates(const UnresolvedSetImpl &Functions, ArrayRef< Expr * > Args, OverloadCandidateSet &CandidateSet, TemplateArgumentListInfo *ExplicitTemplateArgs=nullptr, bool SuppressUserConversions=false, bool PartialOverloading=false, bool FirstArgumentIsBase=false)
Add all of the function declarations in the given function set to the overload candidate set.
bool CheckPointerConversion(Expr *From, QualType ToType, CastKind &Kind, CXXCastPath &BasePath, bool IgnoreBaseAccess, bool Diagnose=true)
CheckPointerConversion - Check the pointer conversion from the expression From to the type ToType.
void NoteDeletedFunction(FunctionDecl *FD)
Emit a note explaining that this function is deleted.
ExprResult CreateBuiltinArraySubscriptExpr(Expr *Base, SourceLocation LLoc, Expr *Idx, SourceLocation RLoc)
void NoteAllOverloadCandidates(Expr *E, QualType DestType=QualType(), bool TakingAddress=false)
AccessResult CheckUnresolvedLookupAccess(UnresolvedLookupExpr *E, DeclAccessPair FoundDecl)
void AddNonMemberOperatorCandidates(const UnresolvedSetImpl &Functions, ArrayRef< Expr * > Args, OverloadCandidateSet &CandidateSet, TemplateArgumentListInfo *ExplicitTemplateArgs=nullptr)
Add all of the non-member operator function declarations in the given function set to the overload ca...
@ PotentiallyEvaluated
The current expression is potentially evaluated at run time, which means that code may be generated t...
@ Unevaluated
The current expression and its subexpressions occur within an unevaluated operand (C++11 [expr]p7),...
bool CheckCallReturnType(QualType ReturnType, SourceLocation Loc, CallExpr *CE, FunctionDecl *FD)
CheckCallReturnType - Checks that a call expression's return type is complete.
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...
bool LookupQualifiedName(LookupResult &R, DeclContext *LookupCtx, bool InUnqualifiedLookup=false)
Perform qualified name lookup into a given context.
ExprResult PerformObjectMemberConversion(Expr *From, NestedNameSpecifier Qualifier, NamedDecl *FoundDecl, NamedDecl *Member)
Cast a base object to a member's actual type.
MemberPointerConversionResult
SourceManager & SourceMgr
bool DiagnoseDependentMemberLookup(const LookupResult &R)
Diagnose a lookup that found results in an enclosing class during error recovery.
DiagnosticsEngine & Diags
NamespaceDecl * getStdNamespace() const
ExprResult DefaultFunctionArrayConversion(Expr *E, bool Diagnose=true)
DefaultFunctionArrayConversion (C99 6.3.2.1p3, C99 6.3.2.1p4).
ExprResult PerformCopyInitialization(const InitializedEntity &Entity, SourceLocation EqualLoc, ExprResult Init, bool TopLevelOfInitList=false, bool AllowExplicit=false)
bool ResolveAndFixSingleFunctionTemplateSpecialization(ExprResult &SrcExpr, bool DoFunctionPointerConversion=false, bool Complain=false, SourceRange OpRangeForComplaining=SourceRange(), QualType DestTypeForComplaining=QualType(), unsigned DiagIDForComplaining=0)
TemplateDeductionResult DeduceTemplateArguments(ClassTemplatePartialSpecializationDecl *Partial, ArrayRef< TemplateArgument > TemplateArgs, sema::TemplateDeductionInfo &Info)
void AddSurrogateCandidate(CXXConversionDecl *Conversion, DeclAccessPair FoundDecl, CXXRecordDecl *ActingContext, const FunctionProtoType *Proto, Expr *Object, ArrayRef< Expr * > Args, OverloadCandidateSet &CandidateSet)
AddSurrogateCandidate - Adds a "surrogate" candidate function that converts the given Object to a fun...
MemberExpr * BuildMemberExpr(Expr *Base, bool IsArrow, SourceLocation OpLoc, NestedNameSpecifierLoc NNS, SourceLocation TemplateKWLoc, ValueDecl *Member, DeclAccessPair FoundDecl, bool HadMultipleCandidates, const DeclarationNameInfo &MemberNameInfo, QualType Ty, ExprValueKind VK, ExprObjectKind OK, const TemplateArgumentListInfo *TemplateArgs=nullptr)
ExprResult CreateRecoveryExpr(SourceLocation Begin, SourceLocation End, ArrayRef< Expr * > SubExprs, QualType T=QualType())
Attempts to produce a RecoveryExpr after some AST node cannot be created.
bool IsFunctionConversion(QualType FromType, QualType ToType) const
Determine whether the conversion from FromType to ToType is a valid conversion of ExtInfo/ExtProtoInf...
std::string getTemplateArgumentBindingsText(const TemplateParameterList *Params, const TemplateArgumentList &Args)
Produces a formatted string that describes the binding of template parameters to template arguments.
bool MaybeEmitAmbiguousAtomicConstraintsDiagnostic(const NamedDecl *D1, ArrayRef< AssociatedConstraint > AC1, const NamedDecl *D2, ArrayRef< AssociatedConstraint > AC2)
If D1 was not at least as constrained as D2, but would've been if a pair of atomic constraints involv...
ForRangeStatus BuildForRangeBeginEndCall(SourceLocation Loc, SourceLocation RangeLoc, const DeclarationNameInfo &NameInfo, LookupResult &MemberLookup, OverloadCandidateSet *CandidateSet, Expr *Range, ExprResult *CallExpr)
Build a call to 'begin' or 'end' for a C++11 for-range statement.
@ Diagnose
Diagnose issues that are non-constant or that are extensions.
ExprResult InitializeExplicitObjectArgument(Sema &S, Expr *Obj, FunctionDecl *Fun)
bool CanPerformCopyInitialization(const InitializedEntity &Entity, ExprResult Init)
bool DiagnoseInvalidExplicitObjectParameterInLambda(CXXMethodDecl *Method, SourceLocation CallLoc)
Returns true if the explicit object parameter was invalid.
bool IsStringLiteralToNonConstPointerConversion(Expr *From, QualType ToType)
Helper function to determine whether this is the (deprecated) C++ conversion from a string literal to...
void HandleFunctionTypeMismatch(PartialDiagnostic &PDiag, QualType FromType, QualType ToType)
HandleFunctionTypeMismatch - Gives diagnostic information for differeing function types.
bool ConvertArgumentsForCall(CallExpr *Call, Expr *Fn, FunctionDecl *FDecl, const FunctionProtoType *Proto, ArrayRef< Expr * > Args, SourceLocation RParenLoc, bool ExecConfig=false)
ConvertArgumentsForCall - Converts the arguments specified in Args/NumArgs to the parameter types of ...
DeclContextLookupResult LookupConstructors(CXXRecordDecl *Class)
Look up the constructors for the given class.
FunctionTemplateDecl * getMoreSpecializedTemplate(FunctionTemplateDecl *FT1, FunctionTemplateDecl *FT2, SourceLocation Loc, TemplatePartialOrderingContext TPOC, unsigned NumCallArguments1, QualType RawObj1Ty={}, QualType RawObj2Ty={}, bool Reversed=false, bool PartialOverloading=false)
Returns the more specialized function template according to the rules of function template partial or...
bool CheckFunctionCall(FunctionDecl *FDecl, CallExpr *TheCall, const FunctionProtoType *Proto)
CheckFunctionCall - Check a direct function call for various correctness and safety properties not st...
void AddMemberOperatorCandidates(OverloadedOperatorKind Op, SourceLocation OpLoc, ArrayRef< Expr * > Args, OverloadCandidateSet &CandidateSet, OverloadCandidateParamOrder PO={})
Add overload candidates for overloaded operators that are member functions.
void CheckVirtualDtorCall(CXXDestructorDecl *dtor, SourceLocation Loc, bool IsDelete, bool CallCanBeVirtual, bool WarnOnNonAbstractTypes, SourceLocation DtorLoc)
ExprResult ActOnFinishFullExpr(Expr *Expr, bool DiscardedValue)
void checkCall(NamedDecl *FDecl, const FunctionProtoType *Proto, const Expr *ThisArg, ArrayRef< const Expr * > Args, bool IsMemberFunction, SourceLocation Loc, SourceRange Range, VariadicCallType CallType)
Handles the checks for format strings, non-POD arguments to vararg functions, NULL arguments passed t...
Encodes a location in the source.
bool isValid() const
Return true if this is a valid SourceLocation object.
bool isInSystemHeader(SourceLocation Loc) const
Returns if a SourceLocation is in a system header.
bool isBeforeInTranslationUnit(SourceLocation LHS, SourceLocation RHS) const
Determines the order of 2 source locations in the translation unit.
A trivial tuple used to represent a source range.
SourceLocation getBegin() const
StandardConversionSequence - represents a standard conversion sequence (C++ 13.3.3....
void dump() const
dump - Print this standard conversion sequence to standard error.
void setFromType(QualType T)
DeclAccessPair FoundCopyConstructor
bool isIdentityConversion() const
unsigned BindsToRvalue
Whether we're binding to an rvalue.
ImplicitConversionKind Second
Second - The second conversion can be an integral promotion, floating point promotion,...
QualType getFromType() const
ImplicitConversionKind First
First – The first conversion can be an lvalue-to-rvalue conversion, array-to-pointer conversion,...
unsigned BindsImplicitObjectArgumentWithoutRefQualifier
Whether this binds an implicit object argument to a non-static member function without a ref-qualifie...
unsigned ReferenceBinding
ReferenceBinding - True when this is a reference binding (C++ [over.ics.ref]).
void setAsIdentityConversion()
StandardConversionSequence - Set the standard conversion sequence to the identity conversion.
unsigned DeprecatedStringLiteralToCharPtr
Whether this is the deprecated conversion of a string literal to a pointer to non-const character dat...
CXXConstructorDecl * CopyConstructor
CopyConstructor - The copy constructor that is used to perform this conversion, when the conversion i...
unsigned IncompatibleObjC
IncompatibleObjC - Whether this is an Objective-C conversion that we should warn about (if we actuall...
unsigned ObjCLifetimeConversionBinding
Whether this binds a reference to an object with a different Objective-C lifetime qualifier.
ImplicitConversionKind Third
Third - The third conversion can be a qualification conversion or a function conversion.
unsigned QualificationIncludesObjCLifetime
Whether the qualification conversion involves a change in the Objective-C lifetime (for automatic ref...
void setToType(unsigned Idx, QualType T)
bool isPointerConversionToBool() const
isPointerConversionToBool - Determines whether this conversion is a conversion of a pointer or pointe...
void * ToTypePtrs[3]
ToType - The types that this conversion is converting to in each step.
NarrowingKind getNarrowingKind(ASTContext &Context, const Expr *Converted, APValue &ConstantValue, QualType &ConstantType, bool IgnoreFloatToIntegralConversion=false) const
Check if this standard conversion sequence represents a narrowing conversion, according to C++11 [dcl...
unsigned IsLvalueReference
Whether this is an lvalue reference binding (otherwise, it's an rvalue reference binding).
ImplicitConversionKind Dimension
Dimension - Between the second and third conversion a vector or matrix dimension conversion may occur...
unsigned BindsToFunctionLvalue
Whether we're binding to a function lvalue.
unsigned DirectBinding
DirectBinding - True when this is a reference binding that is a direct binding (C++ [dcl....
ImplicitConversionRank getRank() const
getRank - Retrieve the rank of this standard conversion sequence (C++ 13.3.3.1.1p3).
bool isPointerConversionToVoidPointer(ASTContext &Context) const
isPointerConversionToVoidPointer - Determines whether this conversion is a conversion of a pointer to...
void setAllToTypes(QualType T)
unsigned FromBracedInitList
Whether the source expression was originally a single element braced-init-list.
QualType getToType(unsigned Idx) 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
StringLiteral - This represents a string literal expression, e.g.
StringRef getString() const
const llvm::Triple & getTriple() const
Returns the target triple of the primary target.
virtual bool hasInt128Type() const
Determine whether the __int128 type is supported on this target.
virtual bool hasIbm128Type() const
Determine whether the __ibm128 type is supported on this target.
virtual bool hasFloat128Type() const
Determine whether the __float128 type is supported on this target.
A convenient class for passing around template argument information.
A template argument list.
Represents a template argument.
QualType getNonTypeTemplateArgumentType() const
If this is a non-type template argument, get its type.
QualType getAsType() const
Retrieve the type for a type template argument.
TemplateName getAsTemplate() const
Retrieve the template name for a template name argument.
unsigned pack_size() const
The number of template arguments in the given template argument pack.
@ Template
The template argument is a template name that was provided for a template template parameter.
@ Pack
The template argument is actually a parameter pack.
ArgKind getKind() const
Return the kind of stored template argument.
The base class of all kinds of template declarations (e.g., class, function, etc.).
TemplateParameterList * getTemplateParameters() const
Get the list of template parameters.
Represents a C++ template name within the type system.
TemplateDecl * getAsTemplateDecl(bool IgnoreDeduced=false) const
Retrieve the underlying template declaration that this template name refers to, if known.
@ Template
A single template declaration.
bool hasAssociatedConstraints() const
TemplateSpecCandidateSet - A set of generalized overload candidates, used in template specializations...
SmallVector< TemplateSpecCandidate, 16 >::iterator iterator
void NoteCandidates(Sema &S, SourceLocation Loc)
NoteCandidates - When no template specialization match is found, prints diagnostic messages containin...
void clear()
Clear out all of the candidates.
SourceLocation getLocation() const
TemplateSpecCandidate & addCandidate()
Add a new candidate with NumConversions conversion sequence slots to the overload set.
TemplateTemplateParmDecl - Declares a template template parameter, e.g., "T" in.
Declaration of a template type parameter.
const Type * getTypeForDecl() const
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.
bool isBlockPointerType() const
bool isBooleanType() const
bool isObjCBuiltinType() const
bool isSignedIntegerOrEnumerationType() const
Determines whether this is an integer type that is signed or an enumeration types whose underlying ty...
bool hasAttr(attr::Kind AK) const
Determine whether this type had the specified attribute applied to it (looking through top-level type...
const RecordType * getAsUnionType() const
NOTE: getAs*ArrayType are methods on ASTContext.
bool isIncompleteArrayType() const
bool isSignedIntegerType() const
Return true if this is an integer type that is signed, according to C99 6.2.5p4 [char,...
bool isFloat16Type() const
bool isComplexType() const
isComplexType() does not include complex integers (a GCC extension).
bool isIntegralOrUnscopedEnumerationType() const
Determine whether this type is an integral or unscoped enumeration type.
bool isRValueReferenceType() const
CXXRecordDecl * getAsCXXRecordDecl() const
Retrieves the CXXRecordDecl that this type refers to, either because the type is a RecordType or beca...
bool isConstantArrayType() const
bool canDecayToPointerType() const
Determines whether this type can decay to a pointer type.
bool isConvertibleToFixedPointType() const
Return true if this can be converted to (or from) a fixed point type.
CXXRecordDecl * castAsCXXRecordDecl() const
bool isArithmeticType() const
bool isPointerType() const
bool isArrayParameterType() const
CanQualType getCanonicalTypeUnqualified() const
bool isIntegerType() const
isIntegerType() does not include complex integers (a GCC extension).
bool isSVESizelessBuiltinType() const
Returns true for SVE scalable vector types.
const T * castAs() const
Member-template castAs<specific type>.
bool isReferenceType() const
bool isEnumeralType() const
bool isIntegralType(const ASTContext &Ctx) const
Determine whether this type is an integral type.
bool isObjCQualifiedIdType() const
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 isAnyCharacterType() const
Determine whether this type is any of the built-in character types.
bool isExtVectorBoolType() const
bool isObjCObjectOrInterfaceType() const
bool isInstantiationDependentType() const
Determine whether this type is an instantiation-dependent type, meaning that the type involves a temp...
bool isLValueReferenceType() const
bool isBitIntType() const
bool isDependentType() const
Whether this type is a dependent type, meaning that its definition somehow depends on a template para...
bool isAggregateType() const
Determines whether the type is a C++ aggregate type or C aggregate or union type.
bool isAnyComplexType() const
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 isMemberPointerType() const
bool isObjCIdType() const
bool isMatrixType() const
bool isUndeducedType() const
Determine whether this type is an undeduced type, meaning that it somehow involves a C++11 'auto' typ...
bool isObjectType() const
Determine whether this type is an object type.
EnumDecl * getAsEnumDecl() const
Retrieves the EnumDecl this type refers to.
bool isBFloat16Type() const
bool isIncompleteType(NamedDecl **Def=nullptr) const
Types are partitioned into 3 broad categories (C99 6.2.5p1): object types, function types,...
bool isFunctionType() const
bool isObjCObjectPointerType() const
bool isVectorType() const
bool isObjCClassType() const
bool isRealFloatingType() const
Floating point categories.
bool isRVVSizelessBuiltinType() const
Returns true for RVV scalable vector types.
const T * getAsCanonical() const
If this type is canonically the specified type, return its canonical type cast to that specified type...
bool isHLSLAttributedResourceType() 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
TypeClass getTypeClass() const
const T * getAs() const
Member-template getAs<specific type>'.
bool isNullPtrType() const
bool isRecordType() const
UnaryOperator - This represents the unary-expression's (except sizeof and alignof),...
static OverloadedOperatorKind getOverloadedOperator(Opcode Opc)
Retrieve the overloaded operator kind that corresponds to the given unary opcode.
static UnaryOperator * Create(const ASTContext &C, Expr *input, Opcode opc, QualType type, ExprValueKind VK, ExprObjectKind OK, SourceLocation l, bool CanOverflow, FPOptionsOverride FPFeatures)
static StringRef getOpcodeStr(Opcode Op)
getOpcodeStr - Turn an Opcode enum value into the punctuation char it corresponds to,...
A reference to a name which we were able to look up during parsing but could not resolve to a specifi...
bool requiresADL() const
True if this declaration should be extended by argument-dependent lookup.
static UnresolvedLookupExpr * Create(const ASTContext &Context, CXXRecordDecl *NamingClass, NestedNameSpecifierLoc QualifierLoc, const DeclarationNameInfo &NameInfo, bool RequiresADL, UnresolvedSetIterator Begin, UnresolvedSetIterator End, bool KnownDependent, bool KnownInstantiationDependent)
Represents a C++ member access expression for which lookup produced a set of overloaded functions.
DeclarationName getMemberName() const
Retrieve the name of the member that this expression refers to.
QualType getBaseType() const
bool isArrow() const
Determine whether this member expression used the '->' operator; otherwise, it used the '.
Expr * getBase()
Retrieve the base object of this member expressions, e.g., the x in x.m.
SourceLocation getBeginLoc() const LLVM_READONLY
SourceLocation getMemberLoc() const
Retrieve the location of the name of the member that this expression refers to.
A set of unresolved declarations.
ArrayRef< DeclAccessPair > pairs() const
void addDecl(NamedDecl *D)
The iterator over UnresolvedSets.
A set of unresolved declarations.
A call to a literal operator (C++11 [over.literal]) written as a user-defined literal (C++11 [lit....
static UserDefinedLiteral * Create(const ASTContext &Ctx, Expr *Fn, ArrayRef< Expr * > Args, QualType Ty, ExprValueKind VK, SourceLocation LitEndLoc, SourceLocation SuffixLoc, FPOptionsOverride FPFeatures)
unsigned getNumElements() const
QualType getElementType() const
Provides information about an attempted template argument deduction, whose success or failure was des...
TemplateArgumentList * takeSugared()
Take ownership of the deduced template argument lists.
TemplateArgument SecondArg
The second template argument to which the template argument deduction failure refers.
TemplateParameter Param
The template parameter to which a template argument deduction failure refers.
bool hasSFINAEDiagnostic() const
Is a SFINAE diagnostic available?
TemplateArgument FirstArg
The first template argument to which the template argument deduction failure refers.
ConstraintSatisfaction AssociatedConstraintsSatisfaction
The constraint satisfaction details resulting from the associated constraints satisfaction tests.
void takeSFINAEDiagnostic(PartialDiagnosticAt &PD)
Take ownership of the SFINAE diagnostic.
unsigned CallArgIndex
The index of the function argument that caused a deduction failure.
bool hasStrictPackMatch() const
specific_attr_iterator - Iterates over a subrange of an AttrVec, only providing attributes that are o...
Defines the clang::TargetInfo interface.
const internal::VariadicAllOfMatcher< Type > type
Matches Types in the clang AST.
@ Warning
Present this diagnostic as a warning.
@ Error
Present this diagnostic as an error.
bool Ret(InterpState &S, CodePtr &PC)
void checkAssignmentLifetime(Sema &SemaRef, const AssignedEntity &Entity, Expr *Init)
Check that the lifetime of the given expr (and its subobjects) is sufficient for assigning to the ent...
The JSON file list parser is used to communicate input to InstallAPI.
ImplicitConversionRank GetDimensionConversionRank(ImplicitConversionRank Base, ImplicitConversionKind Dimension)
CanQual< Type > CanQualType
Represents a canonical, potentially-qualified type.
OverloadedOperatorKind
Enumeration specifying the different kinds of C++ overloaded operators.
@ OO_None
Not an overloaded operator.
@ NUM_OVERLOADED_OPERATORS
@ NonFunction
This is not an overload because the lookup results contain a non-function.
@ Match
This is not an overload because the signature exactly matches an existing declaration.
@ Overload
This is a legitimate overload: the existing declarations are functions or function templates with dif...
bool isa(CodeGen::Address addr)
OverloadingResult
OverloadingResult - Capture the result of performing overload resolution.
@ 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.
@ Specialization
We are substituting template parameters for template arguments in order to form a template specializa...
bool isBetterOverloadCandidate(Sema &S, const OverloadCandidate &Cand1, const OverloadCandidate &Cand2, SourceLocation Loc, OverloadCandidateSet::CandidateSetKind Kind, bool PartialOverloading=false)
isBetterOverloadCandidate - Determines whether the first overload candidate is a better candidate tha...
bool isUnresolvedExceptionSpec(ExceptionSpecificationType ESpecType)
@ ovl_fail_final_conversion_not_exact
This conversion function template specialization candidate is not viable because the final conversion...
@ ovl_fail_enable_if
This candidate function was not viable because an enable_if attribute disabled it.
@ ovl_fail_illegal_constructor
This conversion candidate was not considered because it is an illegal instantiation of a constructor ...
@ ovl_fail_bad_final_conversion
This conversion candidate is not viable because its result type is not implicitly convertible to the ...
@ ovl_fail_module_mismatched
This candidate was not viable because it has internal linkage and is from a different module unit tha...
@ ovl_fail_too_few_arguments
@ ovl_fail_addr_not_available
This candidate was not viable because its address could not be taken.
@ ovl_fail_too_many_arguments
@ ovl_non_default_multiversion_function
This candidate was not viable because it is a non-default multiversioned function.
@ ovl_fail_constraints_not_satisfied
This candidate was not viable because its associated constraints were not satisfied.
@ ovl_fail_bad_conversion
@ ovl_fail_bad_target
(CUDA) This candidate was not viable because the callee was not accessible from the caller's target (...
@ ovl_fail_inhctor_slice
This inherited constructor is not viable because it would slice the argument.
@ ovl_fail_object_addrspace_mismatch
This constructor/conversion candidate fail due to an address space mismatch between the object being ...
@ ovl_fail_explicit
This candidate constructor or conversion function is explicit but the context doesn't permit explicit...
@ ovl_fail_trivial_conversion
This conversion candidate was not considered because it duplicates the work of a trivial or derived-t...
@ Comparison
A comparison.
@ RQ_None
No ref-qualifier was provided.
@ RQ_LValue
An lvalue ref-qualifier was provided (&).
@ RQ_RValue
An rvalue ref-qualifier was provided (&&).
ImplicitConversionRank
ImplicitConversionRank - The rank of an implicit conversion kind.
@ ICR_Conversion
Conversion.
@ ICR_Writeback_Conversion
ObjC ARC writeback conversion.
@ ICR_HLSL_Dimension_Reduction
HLSL Matching Dimension Reduction.
@ ICR_HLSL_Dimension_Reduction_Conversion
HLSL Dimension reduction with conversion.
@ ICR_HLSL_Scalar_Widening
HLSL Scalar Widening.
@ ICR_C_Conversion
Conversion only allowed in the C standard (e.g. void* to char*).
@ ICR_OCL_Scalar_Widening
OpenCL Scalar Widening.
@ ICR_Complex_Real_Conversion
Complex <-> Real conversion.
@ ICR_HLSL_Scalar_Widening_Conversion
HLSL Scalar Widening with conversion.
@ ICR_HLSL_Dimension_Reduction_Promotion
HLSL Dimension reduction with promotion.
@ ICR_Promotion
Promotion.
@ ICR_Exact_Match
Exact Match.
@ ICR_C_Conversion_Extension
Conversion not allowed by the C standard, but that we accept as an extension anyway.
@ ICR_HLSL_Scalar_Widening_Promotion
HLSL Scalar Widening with promotion.
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_ObjCProperty
An Objective-C property is a logical field of an Objective-C object which is read and written via Obj...
@ OK_Ordinary
An ordinary object is located at an address in memory.
Expr::ConstantExprKind ConstantExprKind
OverloadCandidateParamOrder
The parameter ordering that will be used for the candidate.
@ Seq
'seq' clause, allowed on 'loop' and 'routine' directives.
nullptr
This class represents a compute construct, representing a 'Kind' of ‘parallel’, 'serial',...
OverloadsShown
Specifies which overload candidates to display when overload resolution fails.
@ Ovl_Best
Show just the "best" overload candidates.
llvm::MutableArrayRef< ImplicitConversionSequence > ConversionSequenceList
A list of implicit conversion sequences for the arguments of an OverloadCandidate.
ComparisonCategoryResult
An enumeration representing the possible results of a three-way comparison.
OverloadCandidateRewriteKind
The kinds of rewrite we perform on overload candidates.
@ CRK_Reversed
Candidate is a rewritten candidate with a reversed order of parameters.
@ CRK_None
Candidate is not a rewritten candidate.
@ CRK_DifferentOperator
Candidate is a rewritten candidate with a different operator name.
MutableArrayRef< Expr * > MultiExprArg
@ Internal
Internal linkage, which indicates that the entity can be referred to from within the translation unit...
@ Result
The result type of a method or function.
const FunctionProtoType * T
ImplicitConversionKind
ImplicitConversionKind - The kind of implicit conversion used to convert an argument to a parameter's...
@ ICK_Complex_Conversion
Complex conversions (C99 6.3.1.6)
@ ICK_Floating_Promotion
Floating point promotions (C++ [conv.fpprom])
@ ICK_Boolean_Conversion
Boolean conversions (C++ [conv.bool])
@ ICK_Integral_Conversion
Integral conversions (C++ [conv.integral])
@ ICK_Fixed_Point_Conversion
Fixed point type conversions according to N1169.
@ ICK_Vector_Conversion
Vector conversions.
@ ICK_Block_Pointer_Conversion
Block Pointer conversions.
@ ICK_Pointer_Member
Pointer-to-member conversions (C++ [conv.mem])
@ ICK_Floating_Integral
Floating-integral conversions (C++ [conv.fpint])
@ ICK_HLSL_Array_RValue
HLSL non-decaying array rvalue cast.
@ ICK_SVE_Vector_Conversion
Arm SVE Vector conversions.
@ ICK_HLSL_Vector_Truncation
HLSL vector truncation.
@ ICK_Incompatible_Pointer_Conversion
C-only conversion between pointers with incompatible types.
@ ICK_Array_To_Pointer
Array-to-pointer conversion (C++ [conv.array])
@ ICK_RVV_Vector_Conversion
RISC-V RVV Vector conversions.
@ ICK_Complex_Promotion
Complex promotions (Clang extension)
@ ICK_Num_Conversion_Kinds
The number of conversion kinds.
@ ICK_Function_Conversion
Function pointer conversion (C++17 [conv.fctptr])
@ ICK_Vector_Splat
A vector splat from an arithmetic type.
@ ICK_Zero_Queue_Conversion
Zero constant to queue.
@ ICK_Identity
Identity conversion (no conversion)
@ ICK_Derived_To_Base
Derived-to-base (C++ [over.best.ics])
@ ICK_Lvalue_To_Rvalue
Lvalue-to-rvalue conversion (C++ [conv.lval])
@ ICK_Qualification
Qualification conversions (C++ [conv.qual])
@ ICK_Pointer_Conversion
Pointer conversions (C++ [conv.ptr])
@ ICK_TransparentUnionConversion
Transparent Union Conversions.
@ ICK_Integral_Promotion
Integral promotions (C++ [conv.prom])
@ ICK_Floating_Conversion
Floating point conversions (C++ [conv.double].
@ ICK_Compatible_Conversion
Conversions between compatible types in C99.
@ ICK_C_Only_Conversion
Conversions allowed in C, but not C++.
@ ICK_Writeback_Conversion
Objective-C ARC writeback conversion.
@ ICK_Zero_Event_Conversion
Zero constant to event (OpenCL1.2 6.12.10)
@ ICK_Complex_Real
Complex-real conversions (C99 6.3.1.7)
@ ICK_Function_To_Pointer
Function-to-pointer (C++ [conv.array])
@ Template
We are parsing a template declaration.
ActionResult< CXXBaseSpecifier * > BaseResult
AssignConvertType
AssignConvertType - All of the 'assignment' semantic checks return this enum to indicate whether the ...
@ IncompatiblePointer
IncompatiblePointer - The assignment is between two pointers types that are not compatible,...
@ CompatiblePointerDiscardsQualifiers
CompatiblePointerDiscardsQualifiers - The assignment discards c/v/r qualifiers, which we accept as an...
@ Compatible
Compatible - the types are compatible according to the standard.
@ IncompatiblePointerSign
IncompatiblePointerSign - The assignment is between two pointers types which point to integers which ...
DeductionFailureInfo MakeDeductionFailureInfo(ASTContext &Context, TemplateDeductionResult TDK, sema::TemplateDeductionInfo &Info)
Convert from Sema's representation of template deduction information to the form used in overload-can...
@ FunctionTemplate
The name was classified as a function template name.
LangAS
Defines the address space values used by the address space qualifier of QualType.
CastKind
CastKind - The kind of operation required for a conversion.
CXXSpecialMemberKind
Kinds of C++ special members.
OverloadedOperatorKind getRewrittenOverloadedOperator(OverloadedOperatorKind Kind)
Get the other overloaded operator that the given operator can be rewritten into, if any such operator...
std::pair< SourceLocation, PartialDiagnostic > PartialDiagnosticAt
A partial diagnostic along with the source location where this diagnostic occurs.
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.
@ VK_XValue
An x-value expression is a reference to an object with independent storage but which can be "moved",...
@ VK_LValue
An l-value expression is a reference to an object with independent storage.
bool shouldEnforceArgLimit(bool PartialOverloading, FunctionDecl *Function)
SmallVector< CXXBaseSpecifier *, 4 > CXXCastPath
A simple array of base specifiers.
llvm::PointerUnion< TemplateTypeParmDecl *, NonTypeTemplateParmDecl *, TemplateTemplateParmDecl * > TemplateParameter
Stores a template parameter of any kind.
NarrowingKind
NarrowingKind - The kind of narrowing conversion being performed by a standard conversion sequence ac...
@ NK_Not_Narrowing
Not a narrowing conversion.
@ NK_Constant_Narrowing
A narrowing conversion, because a constant expression got narrowed.
@ NK_Dependent_Narrowing
Cannot tell whether this is a narrowing conversion because the expression is value-dependent.
@ NK_Type_Narrowing
A narrowing conversion by virtue of the source and destination types.
@ NK_Variable_Narrowing
A narrowing conversion, because a non-constant-expression variable might have got narrowed.
@ TPOC_Conversion
Partial ordering of function templates for a call to a conversion function.
@ TPOC_Call
Partial ordering of function templates for a function call.
bool declaresSameEntity(const Decl *D1, const Decl *D2)
Determine whether two declarations declare the same entity.
TemplateDeductionResult
Describes the result of template argument deduction.
@ MiscellaneousDeductionFailure
Deduction failed; that's all we know.
@ NonDependentConversionFailure
Checking non-dependent argument conversions failed.
@ ConstraintsNotSatisfied
The deduced arguments did not satisfy the constraints associated with the template.
@ Underqualified
Template argument deduction failed due to inconsistent cv-qualifiers on a template parameter type tha...
@ InstantiationDepth
Template argument deduction exceeded the maximum template instantiation depth (which has already been...
@ InvalidExplicitArguments
The explicitly-specified template arguments were not valid template arguments for the given template.
@ CUDATargetMismatch
CUDA Target attributes do not match.
@ TooFewArguments
When performing template argument deduction for a function template, there were too few call argument...
@ Incomplete
Template argument deduction did not deduce a value for every template parameter.
@ Invalid
The declaration was invalid; do nothing.
@ Success
Template argument deduction was successful.
@ SubstitutionFailure
Substitution of the deduced template argument values resulted in an error.
@ IncompletePack
Template argument deduction did not deduce a value for every expansion of an expanded template parame...
@ DeducedMismatch
After substituting deduced template arguments, a dependent parameter type did not match the correspon...
@ Inconsistent
Template argument deduction produced inconsistent deduced values for the given template parameter.
@ TooManyArguments
When performing template argument deduction for a function template, there were too many call argumen...
@ AlreadyDiagnosed
Some error which was already diagnosed.
@ DeducedMismatchNested
After substituting deduced template arguments, an element of a dependent parameter type did not match...
@ NonDeducedMismatch
A non-depnedent component of the parameter did not match the corresponding component of the argument.
@ TSK_ExplicitSpecialization
This template specialization was declared or defined by an explicit specialization (C++ [temp....
@ TSK_ImplicitInstantiation
This template specialization was implicitly instantiated from a template.
CallingConv
CallingConv - Specifies the calling convention that a function uses.
const char * getOperatorSpelling(OverloadedOperatorKind Operator)
Retrieve the spelling of the given overloaded operator, without the preceding "operator" keyword.
U cast(CodeGen::Address addr)
ConstructorInfo getConstructorInfo(NamedDecl *ND)
CCEKind
Contexts in which a converted constant expression is required.
@ TemplateArg
Value of a non-type template parameter.
@ Noexcept
Condition in a noexcept(bool) specifier.
@ ArrayBound
Array bound in array declarator or new-expression.
@ TempArgStrict
As above, but applies strict template checking rules.
@ ExplicitBool
Condition in an explicit(bool) specifier.
ImplicitConversionRank GetConversionRank(ImplicitConversionKind Kind)
GetConversionRank - Retrieve the implicit conversion rank corresponding to the given implicit convers...
@ Enum
The "enum" keyword introduces the elaborated-type-specifier.
ActionResult< Expr * > ExprResult
@ EST_None
no exception specification
@ ForBuiltinOverloadedOp
A conversion for an operand of a builtin overloaded operator.
__DEVICE__ _Tp abs(const std::complex< _Tp > &__c)
Represents an ambiguous user-defined conversion sequence.
ConversionSet::const_iterator const_iterator
ConversionSet & conversions()
SmallVector< std::pair< NamedDecl *, FunctionDecl * >, 4 > ConversionSet
void setFromType(QualType T)
void setToType(QualType T)
void addConversion(NamedDecl *Found, FunctionDecl *D)
void copyFrom(const AmbiguousConversionSequence &)
const Expr * ConstraintExpr
UnsignedOrNone ArgPackSubstIndex
QualType getToType() const
QualType getFromType() const
OverloadFixItKind Kind
The type of fix applied.
unsigned NumConversionsFixed
The number of Conversions fixed.
void setConversionChecker(TypeComparisonFuncTy Foo)
Resets the default conversion checker method.
std::vector< FixItHint > Hints
The list of Hints generated so far.
DeclarationNameInfo - A collector data type for bundling together a DeclarationName and the correspon...
SourceLocation getLoc() const
getLoc - Returns the main location of the declaration name.
void setCXXOperatorNameRange(SourceRange R)
setCXXOperatorNameRange - Sets the range of the operator name (without the operator keyword).
const DeclarationNameLoc & getInfo() const
SourceLocation getCXXLiteralOperatorNameLoc() const
getCXXLiteralOperatorNameLoc - Returns the location of the literal operator name (not the operator ke...
A structure used to record information about a failed template argument deduction,...
void * Data
Opaque pointer containing additional data about this deduction failure.
const TemplateArgument * getSecondArg()
Return the second template argument this deduction failure refers to, if any.
unsigned Result
A Sema::TemplateDeductionResult.
PartialDiagnosticAt * getSFINAEDiagnostic()
Retrieve the diagnostic which caused this deduction failure, if any.
unsigned HasDiagnostic
Indicates whether a diagnostic is stored in Diagnostic.
TemplateDeductionResult getResult() const
void Destroy()
Free any memory associated with this deduction failure.
char Diagnostic[sizeof(PartialDiagnosticAt)]
A diagnostic indicating why deduction failed.
UnsignedOrNone getCallArgIndex()
Return the index of the call argument that this deduction failure refers to, if any.
TemplateParameter getTemplateParameter()
Retrieve the template parameter this deduction failure refers to, if any.
TemplateArgumentList * getTemplateArgumentList()
Retrieve the template argument list associated with this deduction failure, if any.
const TemplateArgument * getFirstArg()
Return the first template argument this deduction failure refers to, if any.
DeferredTemplateOverloadCandidate * Next
EvalResult is a struct with detailed info about an evaluated expression.
APValue Val
Val - This is the value the expression can be folded to.
SmallVectorImpl< PartialDiagnosticAt > * Diag
Diag - If this is non-null, it will be filled in with a stack of notes indicating why evaluation fail...
Extra information about a function prototype.
FunctionEffectsRef FunctionEffects
const ExtParameterInfo * ExtParameterInfos
Information about operator rewrites to consider when adding operator functions to a candidate set.
bool allowsReversed(OverloadedOperatorKind Op) const
Determine whether reversing parameter order is allowed for operator Op.
bool shouldAddReversed(Sema &S, ArrayRef< Expr * > OriginalArgs, FunctionDecl *FD) const
Determine whether we should add a rewritten candidate for FD with reversed parameter order.
bool isAcceptableCandidate(const FunctionDecl *FD) const
bool isReversible() const
Determines whether this operator could be implemented by a function with reversed parameter order.
SourceLocation OpLoc
The source location of the operator.
bool AllowRewrittenCandidates
Whether we should include rewritten candidates in the overload set.
OverloadCandidateRewriteKind getRewriteKind(const FunctionDecl *FD, OverloadCandidateParamOrder PO)
Determine the kind of rewrite that should be performed for this candidate.
OverloadCandidate - A single candidate in an overload set (C++ 13.3).
unsigned StrictPackMatch
Have we matched any packs on the parameter side, versus any non-packs on the argument side,...
unsigned IgnoreObjectArgument
IgnoreObjectArgument - True to indicate that the first argument's conversion, which for this function...
bool TryToFixBadConversion(unsigned Idx, Sema &S)
bool NotValidBecauseConstraintExprHasError() const
unsigned IsADLCandidate
True if the candidate was found using ADL.
unsigned IsSurrogate
IsSurrogate - True to indicate that this candidate is a surrogate for a conversion to a function poin...
QualType BuiltinParamTypes[3]
BuiltinParamTypes - Provides the parameter types of a built-in overload candidate.
DeclAccessPair FoundDecl
FoundDecl - The original declaration that was looked up / invented / otherwise found,...
FunctionDecl * Function
Function - The actual function that this candidate represents.
unsigned RewriteKind
Whether this is a rewritten candidate, and if so, of what kind?
ConversionFixItGenerator Fix
The FixIt hints which can be used to fix the Bad candidate.
unsigned Best
Whether this candidate is the best viable function, or tied for being the best viable function.
StandardConversionSequence FinalConversion
FinalConversion - For a conversion function (where Function is a CXXConversionDecl),...
unsigned getNumParams() const
unsigned HasFinalConversion
Whether FinalConversion has been set.
unsigned TookAddressOfOverload
unsigned FailureKind
FailureKind - The reason why this candidate is not viable.
unsigned ExplicitCallArguments
The number of call arguments that were explicitly provided, to be used while performing partial order...
ConversionSequenceList Conversions
The conversion sequences used to convert the function arguments to the function parameters.
DeductionFailureInfo DeductionFailure
unsigned Viable
Viable - True to indicate that this overload candidate is viable.
CXXConversionDecl * Surrogate
Surrogate - The conversion function for which this candidate is a surrogate, but only if IsSurrogate ...
OverloadCandidateRewriteKind getRewriteKind() const
Get RewriteKind value in OverloadCandidateRewriteKind type (This function is to workaround the spurio...
bool HasFormOfMemberPointer
OverloadExpr * Expression
bool SuppressUserConversions
Do not consider any user-defined conversions when constructing the initializing sequence.
bool OnlyInitializeNonUserDefinedConversions
Before constructing the initializing sequence, we check whether the parameter type and argument type ...
A context in which code is being synthesized (where a source location alone is not sufficient to iden...
enum clang::Sema::CodeSynthesisContext::SynthesisKind Kind
@ RewritingOperatorAsSpaceship
We are rewriting a comparison operator in terms of an operator<=>.
Decl * Entity
The entity that is being synthesized.
Abstract class used to diagnose incomplete types.
A std::pair-like structure for storing a qualified type split into its local qualifiers and its local...
const Type * Ty
The locally-unqualified type.
Qualifiers Quals
The local qualifiers.
TemplateSpecCandidate - This is a generalization of OverloadCandidate which keeps track of template a...
void NoteDeductionFailure(Sema &S, bool ForTakingAddress)
Diagnose a template argument deduction failure.
DeductionFailureInfo DeductionFailure
Template argument deduction info.
Decl * Specialization
Specialization - The actual specialization that this candidate represents.
DeclAccessPair FoundDecl
The declaration that was looked up, together with its access.
void set(DeclAccessPair Found, Decl *Spec, DeductionFailureInfo Info)
UserDefinedConversionSequence - Represents a user-defined conversion sequence (C++ 13....
StandardConversionSequence Before
Represents the standard conversion that occurs before the actual user-defined conversion.
FunctionDecl * ConversionFunction
ConversionFunction - The function that will perform the user-defined conversion.
bool HadMultipleCandidates
HadMultipleCandidates - When this is true, it means that the conversion function was resolved from an...
StandardConversionSequence After
After - Represents the standard conversion that occurs after the actual user-defined conversion.
bool EllipsisConversion
EllipsisConversion - When this is true, it means user-defined conversion sequence starts with a ....
DeclAccessPair FoundConversionFunction
The declaration that we found via name lookup, which might be the same as ConversionFunction or it mi...
void dump() const
dump - Print this user-defined conversion sequence to standard error.
Describes an entity that is being assigned.