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",
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 Result.convertToInteger(ConvertedValue,
416 llvm::APFloat::rmTowardZero, &ignored);
418 if (*IntConstantValue != ConvertedValue) {
419 ConstantValue =
APValue(*IntConstantValue);
446 Initializer->isCXX11ConstantExpr(Ctx, &ConstantValue)) {
449 ConstantValue = R.
Val;
450 assert(ConstantValue.
isFloat());
451 llvm::APFloat FloatVal = ConstantValue.
getFloat();
454 llvm::APFloat Converted = FloatVal;
455 llvm::APFloat::opStatus ConvertStatus =
457 llvm::APFloat::rmNearestTiesToEven, &ignored);
459 llvm::APFloat::rmNearestTiesToEven, &ignored);
461 if (FloatVal.isNaN() && Converted.isNaN() &&
462 !FloatVal.isSignaling() && !Converted.isSignaling()) {
468 if (!Converted.bitwiseIsEqual(FloatVal)) {
475 if (ConvertStatus & llvm::APFloat::opOverflow) {
497 IntegralConversion: {
505 constexpr auto CanRepresentAll = [](
bool FromSigned,
unsigned FromWidth,
506 bool ToSigned,
unsigned ToWidth) {
507 return (FromWidth < ToWidth + (FromSigned == ToSigned)) &&
508 !(FromSigned && !ToSigned);
511 if (CanRepresentAll(FromSigned, FromWidth, ToSigned, ToWidth))
517 bool DependentBitField =
false;
519 if (BitField->getBitWidth()->isValueDependent())
520 DependentBitField =
true;
521 else if (
unsigned BitFieldWidth = BitField->getBitWidthValue();
522 BitFieldWidth < FromWidth) {
523 if (CanRepresentAll(FromSigned, BitFieldWidth, ToSigned, ToWidth))
527 FromWidth = BitFieldWidth;
535 std::optional<llvm::APSInt> OptInitializerValue =
537 if (!OptInitializerValue) {
541 if (DependentBitField && !(FromSigned && !ToSigned))
547 llvm::APSInt &InitializerValue = *OptInitializerValue;
548 bool Narrowing =
false;
549 if (FromWidth < ToWidth) {
552 if (InitializerValue.isSigned() && InitializerValue.isNegative())
558 InitializerValue.extend(InitializerValue.getBitWidth() + 1);
560 llvm::APSInt ConvertedValue = InitializerValue;
561 ConvertedValue = ConvertedValue.trunc(ToWidth);
562 ConvertedValue.setIsSigned(ToSigned);
563 ConvertedValue = ConvertedValue.extend(InitializerValue.getBitWidth());
564 ConvertedValue.setIsSigned(InitializerValue.isSigned());
566 if (ConvertedValue != InitializerValue)
571 ConstantValue =
APValue(InitializerValue);
587 ConstantValue = R.
Val;
588 assert(ConstantValue.
isFloat());
589 llvm::APFloat FloatVal = ConstantValue.
getFloat();
594 if (FloatVal.isNaN() && FloatVal.isSignaling()) {
610 raw_ostream &OS = llvm::errs();
611 bool PrintedSomething =
false;
614 PrintedSomething =
true;
618 if (PrintedSomething) {
624 OS <<
" (by copy constructor)";
626 OS <<
" (direct reference binding)";
628 OS <<
" (reference binding)";
630 PrintedSomething =
true;
634 if (PrintedSomething) {
638 PrintedSomething =
true;
641 if (!PrintedSomething) {
642 OS <<
"No conversions required";
649 raw_ostream &OS = llvm::errs();
657 OS <<
"aggregate initialization";
667 raw_ostream &OS = llvm::errs();
669 OS <<
"Worst list element conversion: ";
670 switch (ConversionKind) {
672 OS <<
"Standard conversion: ";
676 OS <<
"User-defined conversion: ";
680 OS <<
"Ellipsis conversion";
683 OS <<
"Ambiguous conversion";
686 OS <<
"Bad conversion";
711 struct DFIArguments {
717 struct DFIParamWithArguments : DFIArguments {
722 struct DFIDeducedMismatchArgs : DFIArguments {
724 unsigned CallArgIndex;
741 Result.Result =
static_cast<unsigned>(TDK);
742 Result.HasDiagnostic =
false;
761 auto *Saved =
new (Context) DFIDeducedMismatchArgs;
772 DFIArguments *Saved =
new (Context) DFIArguments;
784 DFIParamWithArguments *Saved =
new (Context) DFIParamWithArguments;
785 Saved->Param = Info.
Param;
798 Result.HasDiagnostic =
true;
803 CNSInfo *Saved =
new (Context) CNSInfo;
813 llvm_unreachable(
"not a deduction failure");
846 Diag->~PartialDiagnosticAt();
855 Diag->~PartialDiagnosticAt();
891 return TemplateParameter::getFromOpaqueValue(
Data);
896 return static_cast<DFIParamWithArguments*
>(
Data)->Param;
926 return static_cast<DFIDeducedMismatchArgs*
>(
Data)->TemplateArgs;
932 return static_cast<CNSInfo*
>(
Data)->TemplateArgs;
964 return &
static_cast<DFIArguments*
>(
Data)->FirstArg;
996 return &
static_cast<DFIArguments*
>(
Data)->SecondArg;
1011 return static_cast<DFIDeducedMismatchArgs*
>(
Data)->CallArgIndex;
1014 return std::nullopt;
1027 for (
unsigned I = 0; I <
X->getNumParams(); ++I)
1031 if (
auto *FTX =
X->getDescribedFunctionTemplate()) {
1036 FTY->getTemplateParameters()))
1045 OverloadedOperatorKind::OO_EqualEqual);
1057 OverloadedOperatorKind::OO_ExclaimEqual);
1058 if (isa<CXXMethodDecl>(EqFD)) {
1075 auto *NotEqFD = Op->getAsFunction();
1076 if (
auto *UD = dyn_cast<UsingShadowDecl>(Op))
1077 NotEqFD = UD->getUnderlyingDecl()->getAsFunction();
1080 cast<Decl>(Op->getLexicalDeclContext())))
1090 return Op == OO_EqualEqual || Op == OO_Spaceship;
1096 if (!allowsReversed(Op))
1098 if (Op == OverloadedOperatorKind::OO_EqualEqual) {
1099 assert(OriginalArgs.size() == 2);
1101 S, OpLoc, OriginalArgs[1], FD))
1112void OverloadCandidateSet::destroyCandidates() {
1113 for (
iterator i = Candidates.begin(), e = Candidates.end(); i != e; ++i) {
1114 for (
auto &
C : i->Conversions)
1115 C.~ImplicitConversionSequence();
1117 i->DeductionFailure.Destroy();
1122 destroyCandidates();
1123 SlabAllocator.Reset();
1124 NumInlineBytesUsed = 0;
1128 FirstDeferredCandidate =
nullptr;
1129 DeferredCandidatesCount = 0;
1130 HasDeferredTemplateConstructors =
false;
1131 ResolutionByPerfectCandidateIsDisabled =
false;
1135 class UnbridgedCastsSet {
1145 Entry entry = { &
E,
E };
1146 Entries.push_back(entry);
1152 i = Entries.begin(), e = Entries.end(); i != e; ++i)
1153 *i->Addr = i->Saved;
1167 UnbridgedCastsSet *unbridgedCasts =
nullptr) {
1171 if (placeholder->getKind() == BuiltinType::Overload)
return false;
1175 if (placeholder->getKind() == BuiltinType::ARCUnbridgedCast &&
1177 unbridgedCasts->save(S,
E);
1197 UnbridgedCastsSet &unbridged) {
1198 for (
unsigned i = 0, e = Args.size(); i != e; ++i)
1207 bool NewIsUsingDecl) {
1212 bool OldIsUsingDecl =
false;
1213 if (isa<UsingShadowDecl>(OldD)) {
1214 OldIsUsingDecl =
true;
1218 if (NewIsUsingDecl)
continue;
1220 OldD = cast<UsingShadowDecl>(OldD)->getTargetDecl();
1225 if ((OldIsUsingDecl || NewIsUsingDecl) && !isVisible(*I))
1233 bool UseMemberUsingDeclRules =
1234 (OldIsUsingDecl || NewIsUsingDecl) && CurContext->isRecord() &&
1235 !
New->getFriendObjectKind();
1238 if (!IsOverload(
New, OldF, UseMemberUsingDeclRules)) {
1239 if (UseMemberUsingDeclRules && OldIsUsingDecl) {
1240 HideUsingShadowDecl(S, cast<UsingShadowDecl>(*I));
1244 if (!isa<FunctionTemplateDecl>(OldD) &&
1245 !shouldLinkPossiblyHiddenDecl(*I,
New))
1254 if (!getASTContext().canBuiltinBeRedeclared(OldF)) {
1258 }
else if (isa<UsingDecl>(OldD) || isa<UsingPackDecl>(OldD)) {
1262 }
else if (isa<TagDecl>(OldD)) {
1264 }
else if (
auto *UUD = dyn_cast<UnresolvedUsingValueDecl>(OldD)) {
1271 if (UUD->getQualifier().isDependent() && !UUD->isCXXClassMember()) {
1299 if (
New->getFriendObjectKind() &&
New->getQualifier() &&
1300 !
New->getDescribedFunctionTemplate() &&
1301 !
New->getDependentSpecializationInfo() &&
1302 !
New->getType()->isDependentType()) {
1305 if (CheckFunctionTemplateSpecialization(
New,
nullptr, TemplateSpecResult,
1307 New->setInvalidDecl();
1319 assert(
D &&
"function decl should not be null");
1321 return !A->isImplicit();
1327 bool UseMemberUsingDeclRules,
1328 bool ConsiderCudaAttrs,
1329 bool UseOverrideRules =
false) {
1335 if (
New->isMSVCRTEntryPoint())
1346 if ((OldTemplate ==
nullptr) != (NewTemplate ==
nullptr))
1359 if (isa<FunctionNoProtoType>(OldQType.
getTypePtr()) ||
1360 isa<FunctionNoProtoType>(NewQType.
getTypePtr()))
1363 const auto *OldType = cast<FunctionProtoType>(OldQType);
1364 const auto *NewType = cast<FunctionProtoType>(NewQType);
1369 if (OldQType != NewQType && OldType->isVariadic() != NewType->isVariadic())
1373 if ((
New->isMemberLikeConstrainedFriend() ||
1384 OldDecl = OldTemplate;
1385 NewDecl = NewTemplate;
1403 bool ConstraintsInTemplateHead =
1414 if (UseMemberUsingDeclRules && ConstraintsInTemplateHead &&
1415 !SameTemplateParameterList)
1417 if (!UseMemberUsingDeclRules &&
1418 (!SameTemplateParameterList || !SameReturnType))
1422 const auto *OldMethod = dyn_cast<CXXMethodDecl>(Old);
1423 const auto *NewMethod = dyn_cast<CXXMethodDecl>(
New);
1425 int OldParamsOffset = 0;
1426 int NewParamsOffset = 0;
1434 if (ThisType.isConstQualified())
1448 !isa<CXXConstructorDecl>(NewMethod))
1454 BS.
Quals = NormalizeQualifiers(OldMethod, BS.
Quals);
1455 DS.Quals = NormalizeQualifiers(NewMethod, DS.Quals);
1457 if (OldMethod->isExplicitObjectMemberFunction()) {
1459 DS.Quals.removeVolatile();
1462 return BS.
Quals == DS.Quals;
1466 auto BS =
Base.getNonReferenceType().getCanonicalType().split();
1467 auto DS =
D.getNonReferenceType().getCanonicalType().split();
1469 if (!AreQualifiersEqual(BS, DS))
1472 if (OldMethod->isImplicitObjectMemberFunction() &&
1473 OldMethod->getParent() != NewMethod->getParent()) {
1485 if (
Base->isLValueReferenceType())
1486 return D->isLValueReferenceType();
1487 return Base->isRValueReferenceType() ==
D->isRValueReferenceType();
1492 auto DiagnoseInconsistentRefQualifiers = [&]() {
1493 if (SemaRef.
LangOpts.CPlusPlus23 && !UseOverrideRules)
1495 if (OldMethod->getRefQualifier() == NewMethod->getRefQualifier())
1497 if (OldMethod->isExplicitObjectMemberFunction() ||
1498 NewMethod->isExplicitObjectMemberFunction())
1500 if (!UseMemberUsingDeclRules && (OldMethod->getRefQualifier() ==
RQ_None ||
1501 NewMethod->getRefQualifier() ==
RQ_None)) {
1502 SemaRef.
Diag(NewMethod->getLocation(), diag::err_ref_qualifier_overload)
1503 << NewMethod->getRefQualifier() << OldMethod->getRefQualifier();
1504 SemaRef.
Diag(OldMethod->getLocation(), diag::note_previous_declaration);
1510 if (OldMethod && OldMethod->isExplicitObjectMemberFunction())
1512 if (NewMethod && NewMethod->isExplicitObjectMemberFunction())
1515 if (OldType->getNumParams() - OldParamsOffset !=
1516 NewType->getNumParams() - NewParamsOffset ||
1518 {OldType->param_type_begin() + OldParamsOffset,
1519 OldType->param_type_end()},
1520 {NewType->param_type_begin() + NewParamsOffset,
1521 NewType->param_type_end()},
1526 if (OldMethod && NewMethod && !OldMethod->isStatic() &&
1527 !NewMethod->isStatic()) {
1528 bool HaveCorrespondingObjectParameters = [&](
const CXXMethodDecl *Old,
1530 auto NewObjectType =
New->getFunctionObjectParameterReferenceType();
1534 return F->getRefQualifier() ==
RQ_None &&
1535 !F->isExplicitObjectMemberFunction();
1538 if (IsImplicitWithNoRefQual(Old) != IsImplicitWithNoRefQual(
New) &&
1539 CompareType(OldObjectType.getNonReferenceType(),
1540 NewObjectType.getNonReferenceType()))
1542 return CompareType(OldObjectType, NewObjectType);
1543 }(OldMethod, NewMethod);
1545 if (!HaveCorrespondingObjectParameters) {
1546 if (DiagnoseInconsistentRefQualifiers())
1551 if (!UseOverrideRules || (!NewMethod->isExplicitObjectMemberFunction() &&
1552 !OldMethod->isExplicitObjectMemberFunction()))
1557 if (!UseOverrideRules &&
1561 if (!NewRC != !OldRC)
1571 if (NewMethod && OldMethod && OldMethod->isImplicitObjectMemberFunction() &&
1572 NewMethod->isImplicitObjectMemberFunction()) {
1573 if (DiagnoseInconsistentRefQualifiers())
1587 NewI =
New->specific_attr_begin<EnableIfAttr>(),
1588 NewE =
New->specific_attr_end<EnableIfAttr>(),
1591 NewI != NewE || OldI != OldE; ++NewI, ++OldI) {
1592 if (NewI == NewE || OldI == OldE)
1594 llvm::FoldingSetNodeID NewID, OldID;
1595 NewI->getCond()->Profile(NewID, SemaRef.
Context,
true);
1596 OldI->getCond()->Profile(OldID, SemaRef.
Context,
true);
1602 if (SemaRef.
getLangOpts().CUDA && ConsiderCudaAttrs) {
1605 if (!isa<CXXDestructorDecl>(
New)) {
1610 "Unexpected invalid target.");
1614 if (NewTarget != OldTarget) {
1617 if (OldMethod && NewMethod && OldMethod->isVirtual() &&
1618 OldMethod->isConstexpr() && !NewMethod->isConstexpr() &&
1619 !hasExplicitAttr<CUDAHostAttr>(Old) &&
1620 !hasExplicitAttr<CUDADeviceAttr>(Old) &&
1621 !hasExplicitAttr<CUDAHostAttr>(
New) &&
1622 !hasExplicitAttr<CUDADeviceAttr>(
New)) {
1636 bool UseMemberUsingDeclRules,
bool ConsiderCudaAttrs) {
1642 bool UseMemberUsingDeclRules,
bool ConsiderCudaAttrs) {
1655 bool SuppressUserConversions,
1657 bool InOverloadResolution,
1659 bool AllowObjCWritebackConversion,
1660 bool AllowObjCConversionOnExplicit) {
1663 if (SuppressUserConversions) {
1674 Conversions, AllowExplicit,
1675 AllowObjCConversionOnExplicit)) {
1696 bool FromListInit =
false;
1697 if (
const auto *InitList = dyn_cast<InitListExpr>(From);
1698 InitList && InitList->getNumInits() == 1 &&
1700 const Expr *SingleInit = InitList->getInit(0);
1701 FromType = SingleInit->
getType();
1703 FromListInit =
true;
1712 if ((FromCanon == ToCanon ||
1724 if (ToCanon != FromCanon)
1735 Cand != Conversions.
end(); ++Cand)
1778 bool SuppressUserConversions,
1780 bool InOverloadResolution,
1782 bool AllowObjCWritebackConversion,
1783 bool AllowObjCConversionOnExplicit) {
1786 ICS.
Standard, CStyle, AllowObjCWritebackConversion)){
1827 auto *ToResType = cast<HLSLAttributedResourceType>(ToType);
1828 auto *FromResType = cast<HLSLAttributedResourceType>(FromType);
1830 FromResType->getWrappedType()) &&
1832 FromResType->getContainedType()) &&
1833 ToResType->getAttrs() == FromResType->getAttrs()) {
1843 AllowExplicit, InOverloadResolution, CStyle,
1844 AllowObjCWritebackConversion,
1845 AllowObjCConversionOnExplicit);
1850 bool SuppressUserConversions,
1852 bool InOverloadResolution,
1854 bool AllowObjCWritebackConversion) {
1855 return ::TryImplicitConversion(*
this, From, ToType, SuppressUserConversions,
1856 AllowExplicit, InOverloadResolution, CStyle,
1857 AllowObjCWritebackConversion,
1863 bool AllowExplicit) {
1868 bool AllowObjCWritebackConversion =
1871 if (getLangOpts().ObjC)
1875 *
this, From, ToType,
1877 AllowExplicit ? AllowedExplicit::All : AllowedExplicit::None,
1879 false, AllowObjCWritebackConversion,
1881 return PerformImplicitConversion(From, ToType, ICS, Action);
1886 bool Changed = IsFunctionConversion(FromType, ToType);
1893 bool *DiscardingCFIUncheckedCallee,
1894 bool *AddingCFIUncheckedCallee)
const {
1895 if (DiscardingCFIUncheckedCallee)
1896 *DiscardingCFIUncheckedCallee =
false;
1897 if (AddingCFIUncheckedCallee)
1898 *AddingCFIUncheckedCallee =
false;
1913 if (TyClass != CanFrom->getTypeClass())
return false;
1914 if (TyClass != Type::FunctionProto && TyClass != Type::FunctionNoProto) {
1915 if (TyClass == Type::Pointer) {
1918 }
else if (TyClass == Type::BlockPointer) {
1921 }
else if (TyClass == Type::MemberPointer) {
1928 CanTo = ToMPT->getPointeeType();
1934 TyClass = CanTo->getTypeClass();
1935 if (TyClass != CanFrom->getTypeClass())
return false;
1936 if (TyClass != Type::FunctionProto && TyClass != Type::FunctionNoProto)
1940 const auto *FromFn = cast<FunctionType>(CanFrom);
1943 const auto *ToFn = cast<FunctionType>(CanTo);
1946 bool Changed =
false;
1954 const auto *FromFPT = dyn_cast<FunctionProtoType>(FromFn);
1955 const auto *ToFPT = dyn_cast<FunctionProtoType>(ToFn);
1957 if (FromFPT && ToFPT) {
1958 if (FromFPT->hasCFIUncheckedCallee() && !ToFPT->hasCFIUncheckedCallee()) {
1960 FromFPT->getReturnType(), FromFPT->getParamTypes(),
1961 FromFPT->getExtProtoInfo().withCFIUncheckedCallee(
false));
1962 FromFPT = cast<FunctionProtoType>(NewTy.
getTypePtr());
1965 if (DiscardingCFIUncheckedCallee)
1966 *DiscardingCFIUncheckedCallee =
true;
1967 }
else if (!FromFPT->hasCFIUncheckedCallee() &&
1968 ToFPT->hasCFIUncheckedCallee()) {
1970 FromFPT->getReturnType(), FromFPT->getParamTypes(),
1971 FromFPT->getExtProtoInfo().withCFIUncheckedCallee(
true));
1972 FromFPT = cast<FunctionProtoType>(NewTy.
getTypePtr());
1975 if (AddingCFIUncheckedCallee)
1976 *AddingCFIUncheckedCallee =
true;
1981 if (FromFPT && ToFPT) {
1982 if (FromFPT->isNothrow() && !ToFPT->isNothrow()) {
1983 FromFn = cast<FunctionType>(
1994 bool CanUseToFPT, CanUseFromFPT;
1996 CanUseFromFPT, NewParamInfos) &&
1997 CanUseToFPT && !CanUseFromFPT) {
2000 NewParamInfos.empty() ? nullptr : NewParamInfos.data();
2002 FromFPT->getParamTypes(), ExtInfo);
2012 FromFPT = cast<FunctionProtoType>(FromFn);
2016 const auto FromFX = FromFPT->getFunctionEffects();
2017 const auto ToFX = ToFPT->getFunctionEffects();
2018 if (FromFX != ToFX) {
2022 FromFPT->getReturnType(), FromFPT->getParamTypes(), ExtInfo);
2032 assert(
QualType(FromFn, 0).isCanonical());
2033 if (
QualType(FromFn, 0) != CanTo)
return false;
2060 if ((&FromSem == &llvm::APFloat::PPCDoubleDouble() &&
2061 &ToSem == &llvm::APFloat::IEEEquad()) ||
2062 (&FromSem == &llvm::APFloat::IEEEquad() &&
2063 &ToSem == &llvm::APFloat::PPCDoubleDouble()))
2118 bool InOverloadResolution,
bool CStyle) {
2135 if (ToExtType && FromExtType) {
2137 unsigned ToElts = ToExtType->getNumElements();
2138 if (FromElts < ToElts)
2140 if (FromElts == ToElts)
2146 QualType ToElTy = ToExtType->getElementType();
2151 if (FromExtType && !ToExtType) {
2173 QualType ToElTy = ToExtType->getElementType();
2207 !ToType->
hasAttr(attr::ArmMveStrictPolymorphism))) {
2212 !InOverloadResolution && !CStyle) {
2214 << FromType << ToType;
2225 bool InOverloadResolution,
2238 bool InOverloadResolution,
2241 bool AllowObjCWritebackConversion) {
2267 FromType = Fn->getType();
2288 !
Method->isExplicitObjectMemberFunction()) {
2290 "Non-unary operator on non-static member address");
2291 assert(cast<UnaryOperator>(From->
IgnoreParens())->getOpcode()
2293 "Non-address-of operator on non-static member address");
2295 FromType, std::nullopt,
Method->getParent());
2297 assert(cast<UnaryOperator>(From->
IgnoreParens())->getOpcode() ==
2299 "Non-address-of operator for overloaded function expression");
2345 FromType =
Atomic->getValueType();
2380 if (
auto *FD = dyn_cast<FunctionDecl>(DRE->getDecl()))
2400 bool IncompatibleObjC =
false;
2455 }
else if (AllowObjCWritebackConversion &&
2459 FromType, IncompatibleObjC)) {
2465 InOverloadResolution, FromType)) {
2469 From, InOverloadResolution, CStyle)) {
2479 S, From, ToType, InOverloadResolution, SCS, CStyle)) {
2515 bool ObjCLifetimeConversion;
2521 ObjCLifetimeConversion)) {
2540 CanonFrom = CanonTo;
2553 if ((S.
getLangOpts().CPlusPlus || !InOverloadResolution))
2599 bool InOverloadResolution,
2608 if (!UD->
hasAttr<TransparentUnionAttr>())
2611 for (
const auto *it : UD->
fields()) {
2614 ToType = it->getType();
2640 return To->
getKind() == BuiltinType::Int;
2643 return To->
getKind() == BuiltinType::UInt;
2667 if (FromED->isScoped())
2674 if (FromED->isFixed()) {
2675 QualType Underlying = FromED->getIntegerType();
2677 IsIntegralPromotion(
nullptr, Underlying, ToType);
2708 uint64_t FromSize = Context.
getTypeSize(FromType);
2717 for (
int Idx = 0; Idx < 6; ++Idx) {
2718 uint64_t ToSize = Context.
getTypeSize(PromoteTypes[Idx]);
2719 if (FromSize < ToSize ||
2720 (FromSize == ToSize &&
2721 FromIsSigned == PromoteTypes[Idx]->isSignedIntegerType())) {
2746 std::optional<llvm::APSInt> BitWidth;
2749 MemberDecl->getBitWidth()->getIntegerConstantExpr(Context))) {
2750 llvm::APSInt ToSize(BitWidth->getBitWidth(), BitWidth->isUnsigned());
2754 if (*BitWidth < ToSize ||
2756 return To->
getKind() == BuiltinType::Int;
2762 return To->
getKind() == BuiltinType::UInt;
2790 if (FromBuiltin->getKind() == BuiltinType::Float &&
2791 ToBuiltin->getKind() == BuiltinType::Double)
2798 (FromBuiltin->getKind() == BuiltinType::Float ||
2799 FromBuiltin->getKind() == BuiltinType::Double) &&
2800 (ToBuiltin->getKind() == BuiltinType::LongDouble ||
2801 ToBuiltin->getKind() == BuiltinType::Float128 ||
2802 ToBuiltin->getKind() == BuiltinType::Ibm128))
2807 if (getLangOpts().
HLSL && FromBuiltin->getKind() == BuiltinType::Half &&
2808 (ToBuiltin->getKind() == BuiltinType::Float ||
2809 ToBuiltin->getKind() == BuiltinType::Double))
2813 if (!getLangOpts().NativeHalfType &&
2814 FromBuiltin->getKind() == BuiltinType::Half &&
2815 ToBuiltin->getKind() == BuiltinType::Float)
2847 bool StripObjCLifetime =
false) {
2850 "Invalid similarly-qualified pointer type");
2861 if (StripObjCLifetime)
2872 if (isa<ObjCObjectPointerType>(ToType))
2881 if (isa<ObjCObjectPointerType>(ToType))
2887 bool InOverloadResolution,
2893 return !InOverloadResolution;
2901 bool InOverloadResolution,
2903 bool &IncompatibleObjC) {
2904 IncompatibleObjC =
false;
2905 if (isObjCPointerConversion(FromType, ToType, ConvertedType,
2912 ConvertedType = ToType;
2919 ConvertedType = ToType;
2926 ConvertedType = ToType;
2934 ConvertedType = ToType;
2944 ConvertedType = ToType;
2952 !getLangOpts().ObjCAutoRefCount) {
2982 if (getLangOpts().MSVCCompat && FromPointeeType->
isFunctionType() &&
3016 IsDerivedFrom(From->
getBeginLoc(), FromPointeeType, ToPointeeType)) {
3050 bool &IncompatibleObjC) {
3051 if (!getLangOpts().
ObjC)
3063 if (ToObjCPtr && FromObjCPtr) {
3074 if (getLangOpts().CPlusPlus && LHS && RHS &&
3076 FromObjCPtr->getPointeeType(), getASTContext()))
3081 ConvertedType =
AdoptQualifiers(Context, ConvertedType, FromQualifiers);
3089 IncompatibleObjC =
true;
3093 ConvertedType =
AdoptQualifiers(Context, ConvertedType, FromQualifiers);
3105 if (FromObjCPtr && FromObjCPtr->isObjCBuiltinType()) {
3133 isObjCPointerConversion(FromPointeeType, ToPointeeType, ConvertedType,
3134 IncompatibleObjC)) {
3136 IncompatibleObjC =
true;
3138 ConvertedType =
AdoptQualifiers(Context, ConvertedType, FromQualifiers);
3145 isObjCPointerConversion(FromPointeeType, ToPointeeType, ConvertedType,
3146 IncompatibleObjC)) {
3149 ConvertedType =
AdoptQualifiers(Context, ConvertedType, FromQualifiers);
3161 if (FromFunctionType && ToFunctionType) {
3170 if (FromFunctionType->
getNumParams() != ToFunctionType->getNumParams() ||
3171 FromFunctionType->
isVariadic() != ToFunctionType->isVariadic() ||
3172 FromFunctionType->
getMethodQuals() != ToFunctionType->getMethodQuals())
3175 bool HasObjCConversion =
false;
3179 }
else if (isObjCPointerConversion(FromFunctionType->
getReturnType(),
3180 ToFunctionType->getReturnType(),
3181 ConvertedType, IncompatibleObjC)) {
3183 HasObjCConversion =
true;
3190 for (
unsigned ArgIdx = 0, NumArgs = FromFunctionType->
getNumParams();
3191 ArgIdx != NumArgs; ++ArgIdx) {
3193 QualType ToArgType = ToFunctionType->getParamType(ArgIdx);
3197 }
else if (isObjCPointerConversion(FromArgType, ToArgType,
3198 ConvertedType, IncompatibleObjC)) {
3200 HasObjCConversion =
true;
3207 if (HasObjCConversion) {
3211 IncompatibleObjC =
true;
3243 if (!FromFunctionType || !ToFunctionType)
3246 if (Context.
hasSameType(FromPointeeType, ToPointeeType))
3251 if (FromFunctionType->
getNumParams() != ToFunctionType->getNumParams() ||
3252 FromFunctionType->
isVariadic() != ToFunctionType->isVariadic())
3257 if (FromEInfo != ToEInfo)
3260 bool IncompatibleObjC =
false;
3262 ToFunctionType->getReturnType())) {
3266 QualType LHS = ToFunctionType->getReturnType();
3267 if ((!getLangOpts().CPlusPlus || !RHS->
isRecordType()) &&
3273 }
else if (isObjCPointerConversion(RHS, LHS,
3274 ConvertedType, IncompatibleObjC)) {
3275 if (IncompatibleObjC)
3284 for (
unsigned ArgIdx = 0, NumArgs = FromFunctionType->
getNumParams();
3285 ArgIdx != NumArgs; ++ArgIdx) {
3286 IncompatibleObjC =
false;
3288 QualType ToArgType = ToFunctionType->getParamType(ArgIdx);
3289 if (Context.
hasSameType(FromArgType, ToArgType)) {
3291 }
else if (isObjCPointerConversion(ToArgType, FromArgType,
3292 ConvertedType, IncompatibleObjC)) {
3293 if (IncompatibleObjC)
3302 bool CanUseToFPT, CanUseFromFPT;
3304 CanUseToFPT, CanUseFromFPT,
3308 ConvertedType = ToType;
3347 ToMember->getMostRecentCXXRecordDecl())) {
3349 if (ToMember->isSugared())
3351 ToMember->getMostRecentCXXRecordDecl());
3353 PDiag << ToMember->getQualifier();
3354 if (FromMember->isSugared())
3356 FromMember->getMostRecentCXXRecordDecl());
3358 PDiag << FromMember->getQualifier();
3391 if (!FromFunction || !ToFunction) {
3396 if (FromFunction->
getNumParams() != ToFunction->getNumParams()) {
3404 if (!FunctionParamTypesAreEqual(FromFunction, ToFunction, &ArgPos)) {
3406 << ToFunction->getParamType(ArgPos)
3413 ToFunction->getReturnType())) {
3419 if (FromFunction->
getMethodQuals() != ToFunction->getMethodQuals()) {
3429 cast<FunctionProtoType>(ToFunction->getCanonicalTypeUnqualified())
3442 assert(llvm::size(Old) == llvm::size(
New) &&
3443 "Can't compare parameters of functions with different number of "
3446 for (
auto &&[Idx,
Type] : llvm::enumerate(Old)) {
3448 size_t J =
Reversed ? (llvm::size(
New) - Idx - 1) : Idx;
3469 return FunctionParamTypesAreEqual(OldType->
param_types(),
3482 unsigned OldIgnore =
3484 unsigned NewIgnore =
3487 auto *OldPT = cast<FunctionProtoType>(OldFunction->
getFunctionType());
3488 auto *NewPT = cast<FunctionProtoType>(NewFunction->
getFunctionType());
3490 return FunctionParamTypesAreEqual(OldPT->param_types().slice(OldIgnore),
3491 NewPT->param_types().slice(NewIgnore),
3498 bool IgnoreBaseAccess,
3501 bool IsCStyleOrFunctionalCast = IgnoreBaseAccess;
3505 if (Diagnose && !IsCStyleOrFunctionalCast && !FromType->
isAnyPointerType() &&
3509 DiagRuntimeBehavior(From->
getExprLoc(), From,
3510 PDiag(diag::warn_impcast_bool_to_null_pointer)
3512 else if (!isUnevaluatedContext())
3521 if (FromPointeeType->
isRecordType() && ToPointeeType->isRecordType() &&
3525 unsigned InaccessibleID = 0;
3526 unsigned AmbiguousID = 0;
3528 InaccessibleID = diag::err_upcast_to_inaccessible_base;
3529 AmbiguousID = diag::err_ambiguous_derived_to_base_conv;
3531 if (CheckDerivedToBaseConversion(
3532 FromPointeeType, ToPointeeType, InaccessibleID, AmbiguousID,
3534 &BasePath, IgnoreBaseAccess))
3538 Kind = CK_DerivedToBase;
3541 if (Diagnose && !IsCStyleOrFunctionalCast &&
3542 FromPointeeType->
isFunctionType() && ToPointeeType->isVoidType()) {
3543 assert(getLangOpts().MSVCCompat &&
3544 "this should only be possible with MSVCCompat!");
3556 if (FromPtrType->isObjCBuiltinType() || ToPtrType->isObjCBuiltinType())
3559 Kind = CK_BlockPointerToObjCPointerCast;
3561 Kind = CK_CPointerToObjCPointerCast;
3565 Kind = CK_AnyPointerToBlockPointerCast;
3571 Kind = CK_NullToPointer;
3578 bool InOverloadResolution,
3588 ConvertedType = ToType;
3603 IsDerivedFrom(From->
getBeginLoc(), ToClass, FromClass)) {
3619 (void)isCompleteType(CheckLoc, FromType);
3620 (void)isCompleteType(CheckLoc,
QualType(ToPtrType, 0));
3626 Kind = CK_NullToMemberPointer;
3627 return MemberPointerConversionResult::Success;
3631 if (Direction == MemberPointerConversionDirection::Upcast &&
3634 return MemberPointerConversionResult::DifferentPointee;
3653 if (Direction == MemberPointerConversionDirection::Upcast)
3654 std::swap(
Base, Derived);
3658 if (!IsDerivedFrom(OpRange.
getBegin(), Derived,
Base, Paths))
3659 return MemberPointerConversionResult::NotDerived;
3663 PD <<
int(Direction);
3664 DiagFromTo(PD) << getAmbiguousPathsDisplayString(Paths) << OpRange;
3666 return MemberPointerConversionResult::Ambiguous;
3669 if (
const RecordType *VBase = Paths.getDetectedVirtual()) {
3671 DiagFromTo(PD) <<
QualType(VBase, 0) << OpRange;
3673 return MemberPointerConversionResult::Virtual;
3678 Kind = Direction == MemberPointerConversionDirection::Upcast
3679 ? CK_DerivedToBaseMemberPointer
3680 : CK_BaseToDerivedMemberPointer;
3682 if (!IgnoreBaseAccess)
3683 switch (CheckBaseClassAccess(
3684 CheckLoc,
Base, Derived, Paths.front(),
3685 Direction == MemberPointerConversionDirection::Upcast
3686 ? diag::err_upcast_to_inaccessible_base
3687 : diag::err_downcast_from_inaccessible_base,
3689 NestedNameSpecifier BaseQual = FromPtrType->getQualifier(),
3690 DerivedQual = ToPtrType->getQualifier();
3691 if (Direction == MemberPointerConversionDirection::Upcast)
3692 std::swap(BaseQual, DerivedQual);
3693 DiagCls(PD, DerivedQual, Derived);
3694 DiagCls(PD, BaseQual, Base);
3704 return MemberPointerConversionResult::Inaccessible;
3707 return MemberPointerConversionResult::Success;
3729 bool CStyle,
bool IsTopLevel,
3730 bool &PreviousToQualsIncludeConst,
3731 bool &ObjCLifetimeConversion,
3744 ObjCLifetimeConversion =
true;
3784 !PreviousToQualsIncludeConst)
3802 PreviousToQualsIncludeConst =
3803 PreviousToQualsIncludeConst && ToQuals.
hasConst();
3809 bool CStyle,
bool &ObjCLifetimeConversion) {
3812 ObjCLifetimeConversion =
false;
3822 bool PreviousToQualsIncludeConst =
true;
3823 bool UnwrappedAnyPointer =
false;
3826 !UnwrappedAnyPointer,
3827 PreviousToQualsIncludeConst,
3828 ObjCLifetimeConversion, getASTContext()))
3830 UnwrappedAnyPointer =
true;
3847 bool InOverloadResolution,
3856 InOverloadResolution, InnerSCS,
3873 if (CtorType->getNumParams() > 0) {
3874 QualType FirstArg = CtorType->getParamType(0);
3886 bool AllowExplicit) {
3893 bool Usable = !Info.Constructor->isInvalidDecl() &&
3896 bool SuppressUserConversions =
false;
3897 if (Info.ConstructorTmpl)
3900 CandidateSet, SuppressUserConversions,
3905 CandidateSet, SuppressUserConversions,
3906 false, AllowExplicit);
3910 bool HadMultipleCandidates = (CandidateSet.
size() > 1);
3937 llvm_unreachable(
"Invalid OverloadResult!");
3959 bool AllowObjCConversionOnExplicit) {
3960 assert(AllowExplicit != AllowedExplicit::None ||
3961 !AllowObjCConversionOnExplicit);
3965 bool ConstructorsOnly =
false;
3981 ConstructorsOnly =
true;
3985 }
else if (
auto *ToRecordDecl =
3986 dyn_cast<CXXRecordDecl>(ToRecordType->getOriginalDecl())) {
3987 ToRecordDecl = ToRecordDecl->getDefinitionOrSelf();
3989 Expr **Args = &From;
3990 unsigned NumArgs = 1;
3991 bool ListInitializing =
false;
3992 if (
InitListExpr *InitList = dyn_cast<InitListExpr>(From)) {
3995 S, From, ToType, ToRecordDecl, User, CandidateSet,
3996 AllowExplicit == AllowedExplicit::All);
4005 Args = InitList->getInits();
4006 NumArgs = InitList->getNumInits();
4007 ListInitializing =
true;
4015 bool Usable = !Info.Constructor->isInvalidDecl();
4016 if (!ListInitializing)
4017 Usable = Usable && Info.Constructor->isConvertingConstructor(
4020 bool SuppressUserConversions = !ConstructorsOnly;
4028 if (SuppressUserConversions && ListInitializing) {
4029 SuppressUserConversions =
4030 NumArgs == 1 && isa<InitListExpr>(Args[0]) &&
4034 if (Info.ConstructorTmpl)
4036 Info.ConstructorTmpl, Info.FoundDecl,
4038 CandidateSet, SuppressUserConversions,
4040 AllowExplicit == AllowedExplicit::All);
4046 SuppressUserConversions,
4048 AllowExplicit == AllowedExplicit::All);
4055 if (ConstructorsOnly || isa<InitListExpr>(From)) {
4058 }
else if (
const RecordType *FromRecordType =
4060 if (
auto *FromRecordDecl =
4061 dyn_cast<CXXRecordDecl>(FromRecordType->getOriginalDecl())) {
4062 FromRecordDecl = FromRecordDecl->getDefinitionOrSelf();
4064 const auto &Conversions = FromRecordDecl->getVisibleConversionFunctions();
4065 for (
auto I = Conversions.begin(),
E = Conversions.end(); I !=
E; ++I) {
4069 if (isa<UsingShadowDecl>(
D))
4070 D = cast<UsingShadowDecl>(
D)->getTargetDecl();
4074 if ((ConvTemplate = dyn_cast<FunctionTemplateDecl>(
D)))
4077 Conv = cast<CXXConversionDecl>(
D);
4081 ConvTemplate, FoundDecl, ActingContext, From, ToType,
4082 CandidateSet, AllowObjCConversionOnExplicit,
4083 AllowExplicit != AllowedExplicit::None);
4086 CandidateSet, AllowObjCConversionOnExplicit,
4087 AllowExplicit != AllowedExplicit::None);
4092 bool HadMultipleCandidates = (CandidateSet.
size() > 1);
4101 = dyn_cast<CXXConstructorDecl>(Best->Function)) {
4108 if (isa<InitListExpr>(From)) {
4113 if (Best->Conversions[0].isEllipsis())
4116 User.
Before = Best->Conversions[0].Standard;
4129 = dyn_cast<CXXConversionDecl>(Best->Function)) {
4131 assert(Best->HasFinalConversion);
4139 User.
Before = Best->Conversions[0].Standard;
4154 User.
After = Best->FinalConversion;
4157 llvm_unreachable(
"Not a constructor or conversion function?");
4166 llvm_unreachable(
"Invalid OverloadResult!");
4176 CandidateSet, AllowedExplicit::None,
false);
4190 if (!RequireCompleteType(From->
getBeginLoc(), ToType,
4191 diag::err_typecheck_nonviable_condition_incomplete,
4198 *
this, From, Cands);
4224 if (!Conv1 || !Conv2)
4239 if (Block1 != Block2)
4252 if (Conv1FuncRet && Conv2FuncRet &&
4263 CallOpProto->isVariadic(),
false);
4265 CallOpProto->isVariadic(),
true);
4267 CallingConv PrefOrder[] = {DefaultFree, DefaultMember, CallOpCC};
4362 if (!ICS1.
isBad()) {
4363 bool StdInit1 =
false, StdInit2 =
false;
4370 if (StdInit1 != StdInit2)
4381 CAT2->getElementType())) {
4383 if (CAT1->getSize() != CAT2->getSize())
4385 return CAT1->getSize().ult(CAT2->getSize())
4507 return FixedEnumPromotion::None;
4511 return FixedEnumPromotion::None;
4513 if (!
Enum->isFixed())
4514 return FixedEnumPromotion::None;
4518 return FixedEnumPromotion::ToUnderlyingType;
4520 return FixedEnumPromotion::ToPromotedUnderlyingType;
4549 else if (Rank2 < Rank1)
4572 if (FEP1 != FixedEnumPromotion::None && FEP2 != FixedEnumPromotion::None &&
4574 return FEP1 == FixedEnumPromotion::ToUnderlyingType
4584 bool SCS1ConvertsToVoid
4586 bool SCS2ConvertsToVoid
4588 if (SCS1ConvertsToVoid != SCS2ConvertsToVoid) {
4593 }
else if (!SCS1ConvertsToVoid && !SCS2ConvertsToVoid) {
4599 }
else if (SCS1ConvertsToVoid && SCS2ConvertsToVoid &&
4628 if (FromObjCPtr1 && FromObjCPtr2) {
4633 if (AssignLeft != AssignRight) {
4668 if (UnqualT1 == UnqualT2) {
4680 if (isa<ArrayType>(T1) && T1Quals)
4682 if (isa<ArrayType>(T2) && T2Quals)
4730 if (SCS1IsCompatibleVectorConversion != SCS2IsCompatibleVectorConversion)
4731 return SCS1IsCompatibleVectorConversion
4738 bool SCS1IsCompatibleSVEVectorConversion =
4740 bool SCS2IsCompatibleSVEVectorConversion =
4743 if (SCS1IsCompatibleSVEVectorConversion !=
4744 SCS2IsCompatibleSVEVectorConversion)
4745 return SCS1IsCompatibleSVEVectorConversion
4752 bool SCS1IsCompatibleRVVVectorConversion =
4754 bool SCS2IsCompatibleRVVVectorConversion =
4757 if (SCS1IsCompatibleRVVVectorConversion !=
4758 SCS2IsCompatibleRVVVectorConversion)
4759 return SCS1IsCompatibleRVVVectorConversion
4799 if (UnqualT1 == UnqualT2)
4817 bool ObjCLifetimeConversion;
4827 if (CanPick1 != CanPick2)
4881 if (FromPointee1 == FromPointee2 && ToPointee1 != ToPointee2) {
4889 if (FromPointee1 != FromPointee2 && ToPointee1 == ToPointee2) {
4906 if (FromPtr1 && FromPtr2 && ToPtr1 && ToPtr2) {
4913 bool FromAssignRight
4922 if (ToPtr1->isObjCIdType() &&
4923 (ToPtr2->isObjCQualifiedIdType() || ToPtr2->getInterfaceDecl()))
4925 if (ToPtr2->isObjCIdType() &&
4926 (ToPtr1->isObjCQualifiedIdType() || ToPtr1->getInterfaceDecl()))
4931 if (ToPtr1->isObjCQualifiedIdType() && ToPtr2->getInterfaceDecl())
4933 if (ToPtr2->isObjCQualifiedIdType() && ToPtr1->getInterfaceDecl())
4938 if (ToPtr1->isObjCClassType() &&
4939 (ToPtr2->isObjCQualifiedClassType() || ToPtr2->getInterfaceDecl()))
4941 if (ToPtr2->isObjCClassType() &&
4942 (ToPtr1->isObjCQualifiedClassType() || ToPtr1->getInterfaceDecl()))
4947 if (ToPtr1->isObjCQualifiedClassType() && ToPtr2->getInterfaceDecl())
4949 if (ToPtr2->isObjCQualifiedClassType() && ToPtr1->getInterfaceDecl())
4955 (ToAssignLeft != ToAssignRight)) {
4966 }
else if (IsSecondSame)
4975 (FromAssignLeft != FromAssignRight))
4989 CXXRecordDecl *FromPointee1 = FromMemPointer1->getMostRecentCXXRecordDecl();
4994 if (FromPointee1 == FromPointee2 && ToPointee1 != ToPointee2) {
5001 if (ToPointee1 == ToPointee2 && FromPointee1 != FromPointee2) {
5039 if (!
T.getQualifiers().hasUnaligned())
5053 "T1 must be the pointee type of the reference type");
5054 assert(!OrigT2->
isReferenceType() &&
"T2 cannot be a reference type");
5077 if (UnqualT1 == UnqualT2) {
5079 }
else if (isCompleteType(
Loc, OrigT2) &&
5080 IsDerivedFrom(
Loc, UnqualT2, UnqualT1))
5081 Conv |= ReferenceConversions::DerivedToBase;
5085 Conv |= ReferenceConversions::ObjC;
5087 IsFunctionConversion(UnqualT2, UnqualT1)) {
5088 Conv |= ReferenceConversions::Function;
5090 return Ref_Compatible;
5092 bool ConvertedReferent = Conv != 0;
5096 bool PreviousToQualsIncludeConst =
true;
5097 bool TopLevel =
true;
5103 Conv |= ReferenceConversions::Qualification;
5109 Conv |= ReferenceConversions::NestedQualification;
5117 bool ObjCLifetimeConversion =
false;
5119 PreviousToQualsIncludeConst,
5120 ObjCLifetimeConversion, getASTContext()))
5126 if (ObjCLifetimeConversion)
5127 Conv |= ReferenceConversions::ObjCLifetime;
5146 bool AllowExplicit) {
5147 assert(T2->
isRecordType() &&
"Can only find conversions of record types.");
5151 const auto &Conversions = T2RecordDecl->getVisibleConversionFunctions();
5152 for (
auto I = Conversions.begin(),
E = Conversions.end(); I !=
E; ++I) {
5155 if (isa<UsingShadowDecl>(
D))
5156 D = cast<UsingShadowDecl>(
D)->getTargetDecl();
5159 = dyn_cast<FunctionTemplateDecl>(
D);
5164 Conv = cast<CXXConversionDecl>(
D);
5176 if (!ConvTemplate &&
5200 ConvTemplate, I.getPair(), ActingDC,
Init, DeclType, CandidateSet,
5201 false, AllowExplicit);
5204 Conv, I.getPair(), ActingDC,
Init, DeclType, CandidateSet,
5205 false, AllowExplicit);
5208 bool HadMultipleCandidates = (CandidateSet.
size() > 1);
5214 assert(Best->HasFinalConversion);
5226 if (!Best->FinalConversion.DirectBinding)
5238 "Expected a direct reference binding!");
5244 Cand != CandidateSet.
end(); ++Cand)
5256 llvm_unreachable(
"Invalid OverloadResult!");
5264 bool SuppressUserConversions,
5265 bool AllowExplicit) {
5266 assert(DeclType->
isReferenceType() &&
"Reference init needs a reference");
5293 auto SetAsReferenceBinding = [&](
bool BindsDirectly) {
5298 ICS.
Standard.
Second = (RefConv & Sema::ReferenceConversions::DerivedToBase)
5300 : (RefConv & Sema::ReferenceConversions::ObjC)
5308 Sema::ReferenceConversions::NestedQualification)
5322 (RefConv & Sema::ReferenceConversions::ObjCLifetime) != 0;
5346 SetAsReferenceBinding(
true);
5395 SetAsReferenceBinding(S.
getLangOpts().CPlusPlus11 ||
5486 AllowedExplicit::None,
5511 if (isRValRef && LValRefType) {
5530 bool SuppressUserConversions,
5531 bool InOverloadResolution,
5532 bool AllowObjCWritebackConversion,
5533 bool AllowExplicit =
false);
5539 bool SuppressUserConversions,
5540 bool InOverloadResolution,
5541 bool AllowObjCWritebackConversion) {
5554 if (
const auto *IAT = dyn_cast<IncompleteArrayType>(AT))
5556 InitTy = IAT->getElementType();
5582 if (From->
getNumInits() == 1 && !IsDesignatedInit) {
5588 SuppressUserConversions,
5589 InOverloadResolution,
5590 AllowObjCWritebackConversion);
5599 Result.Standard.setAsIdentityConversion();
5600 Result.Standard.setFromType(ToType);
5601 Result.Standard.setAllToTypes(ToType);
5626 bool IsUnbounded =
false;
5630 if (CT->getSize().ult(e)) {
5634 Result.setInitializerListContainerType(ContTy, IsUnbounded);
5637 if (CT->getSize().ugt(e)) {
5643 S, &EmptyList, InitTy, SuppressUserConversions,
5644 InOverloadResolution, AllowObjCWritebackConversion);
5645 if (DfltElt.
isBad()) {
5649 Result.setInitializerListContainerType(ContTy, IsUnbounded);
5654 assert(isa<IncompleteArrayType>(AT) &&
"Expected incomplete array");
5660 Result.setInitializerListContainerType(ContTy, IsUnbounded);
5670 Result.Standard.setAsIdentityConversion();
5671 Result.Standard.setFromType(InitTy);
5672 Result.Standard.setAllToTypes(InitTy);
5673 for (
unsigned i = 0; i < e; ++i) {
5676 S,
Init, InitTy, SuppressUserConversions, InOverloadResolution,
5677 AllowObjCWritebackConversion);
5688 Result.setInitializerListContainerType(ContTy, IsUnbounded);
5702 Result.setInitializerListContainerType(ContTy, IsUnbounded);
5716 AllowedExplicit::None,
5717 InOverloadResolution,
false,
5718 AllowObjCWritebackConversion,
5737 Result.UserDefined.Before.setAsIdentityConversion();
5742 Result.UserDefined.After.setAsIdentityConversion();
5743 Result.UserDefined.After.setFromType(ToType);
5744 Result.UserDefined.After.setAllToTypes(ToType);
5745 Result.UserDefined.ConversionFunction =
nullptr;
5762 if (From->
getNumInits() == 1 && !IsDesignatedInit) {
5783 SuppressUserConversions,
5791 InOverloadResolution,
5792 AllowObjCWritebackConversion);
5795 assert(!
Result.isEllipsis() &&
5796 "Sub-initialization cannot result in ellipsis conversion.");
5802 Result.UserDefined.After;
5827 if (NumInits == 1 && !isa<InitListExpr>(From->
getInit(0)) &&
5828 !isa<EmbedExpr>(From->
getInit(0))) {
5830 S, From->
getInit(0), ToType, SuppressUserConversions,
5831 InOverloadResolution, AllowObjCWritebackConversion);
5833 Result.Standard.FromBracedInitList =
true;
5837 else if (NumInits == 0) {
5839 Result.Standard.setAsIdentityConversion();
5840 Result.Standard.setFromType(ToType);
5841 Result.Standard.setAllToTypes(ToType);
5860 bool SuppressUserConversions,
5861 bool InOverloadResolution,
5862 bool AllowObjCWritebackConversion,
5863 bool AllowExplicit) {
5864 if (
InitListExpr *FromInitList = dyn_cast<InitListExpr>(From))
5866 InOverloadResolution,AllowObjCWritebackConversion);
5871 SuppressUserConversions, AllowExplicit);
5874 SuppressUserConversions,
5875 AllowedExplicit::None,
5876 InOverloadResolution,
5878 AllowObjCWritebackConversion,
5891 return !ICS.
isBad();
5900 const CXXRecordDecl *ActingContext,
bool InOverloadResolution =
false,
5902 bool SuppressUserConversion =
false) {
5910 assert(FromClassification.
isLValue());
5921 if (
Method->isExplicitObjectMemberFunction()) {
5922 if (ExplicitParameterType.isNull())
5923 ExplicitParameterType =
Method->getFunctionObjectParameterReferenceType();
5925 ValueKindFromClassification(FromClassification));
5927 S, &TmpExpr, ExplicitParameterType, SuppressUserConversion,
5945 if (isa<CXXDestructorDecl>(
Method) ||
Method->isStatic()) {
5982 FromType, ImplicitParamType);
5992 FromType, ImplicitParamType);
6005 }
else if (!
Method->isExplicitObjectMemberFunction()) {
6007 FromType, ImplicitParamType);
6012 switch (
Method->getRefQualifier()) {
6027 if (!FromClassification.
isRValue()) {
6060 QualType ImplicitParamRecordType =
Method->getFunctionObjectParameterType();
6065 DestType =
Method->getThisType();
6068 FromRecordType = From->
getType();
6069 DestType = ImplicitParamRecordType;
6070 FromClassification = From->
Classify(Context);
6076 From = CreateMaterializeTemporaryExpr(FromRecordType, From,
6077 Method->getRefQualifier() !=
6095 <<
Method->getDeclName() << FromRecordType << (CVR - 1)
6097 Diag(
Method->getLocation(), diag::note_previous_decl)
6098 <<
Method->getDeclName();
6106 bool IsRValueQualified =
6110 << IsRValueQualified;
6111 Diag(
Method->getLocation(), diag::note_previous_decl)
6112 <<
Method->getDeclName();
6122 llvm_unreachable(
"Lists are not objects");
6125 return Diag(From->
getBeginLoc(), diag::err_member_function_call_bad_type)
6126 << ImplicitParamRecordType << FromRecordType
6132 PerformObjectMemberConversion(From, Qualifier, FoundDecl,
Method);
6135 From = FromRes.
get();
6144 CK = CK_AddressSpaceConversion;
6147 From = ImpCastExprToType(From, DestType, CK, From->
getValueKind()).get();
6169 AllowedExplicit::Conversions,
6182 return PerformImplicitConversion(From, Context.
BoolTy, ICS,
6185 if (!DiagnoseMultipleUserDefinedConversion(From, Context.
BoolTy))
6250 llvm_unreachable(
"found a first conversion kind in Second");
6254 llvm_unreachable(
"found a third conversion kind in Second");
6260 llvm_unreachable(
"unknown conversion kind");
6270 [[maybe_unused]]
bool isCCEAllowedPreCXX11 =
6272 assert((S.
getLangOpts().CPlusPlus11 || isCCEAllowedPreCXX11) &&
6273 "converted constant expression outside C++11 or TTP matching");
6306 diag::err_typecheck_converted_constant_expression)
6312 llvm_unreachable(
"bad conversion in converted constant expression");
6318 diag::err_typecheck_converted_constant_expression_disallowed)
6324 diag::err_typecheck_converted_constant_expression_indirect)
6334 diag::err_reference_bind_to_bitfield_in_cce)
6342 bool IsTemplateArgument =
6345 assert(IsTemplateArgument &&
6346 "unexpected class type converted constant expr");
6349 T, cast<NonTypeTemplateParmDecl>(Dest)),
6362 IsTemplateArgument);
6367 bool ReturnPreNarrowingValue =
false;
6370 PreNarrowingType)) {
6380 PreNarrowingValue.
isInt()) {
6383 ReturnPreNarrowingValue =
true;
6403 << CCE << 0 << From->
getType() <<
T;
6406 if (!ReturnPreNarrowingValue)
6407 PreNarrowingValue = {};
6423 if (
Result.isInvalid() ||
Result.get()->isValueDependent()) {
6428 RequireInt, PreNarrowingValue);
6435 return ::BuildConvertedConstantExpression(*
this, From,
T, CCE, Dest,
6442 return ::CheckConvertedConstantExpression(*
this, From,
T,
Value, CCE,
false,
6447 llvm::APSInt &
Value,
6454 if (!R.isInvalid() && !R.get()->isValueDependent())
6462 const APValue &PreNarrowingValue) {
6474 Kind = ConstantExprKind::ClassTemplateArgument;
6476 Kind = ConstantExprKind::NonClassTemplateArgument;
6478 Kind = ConstantExprKind::Normal;
6481 (RequireInt && !Eval.
Val.
isInt())) {
6488 if (Notes.empty()) {
6491 if (
const auto *CE = dyn_cast<ConstantExpr>(
E)) {
6495 "ConstantExpr has no value associated with it");
6501 Value = std::move(PreNarrowingValue);
6507 if (Notes.size() == 1 &&
6508 Notes[0].second.getDiagID() == diag::note_invalid_subexpr_in_const_expr) {
6509 Diag(Notes[0].first, diag::err_expr_not_cce) << CCE;
6510 }
else if (!Notes.empty() && Notes[0].second.getDiagID() ==
6511 diag::note_constexpr_invalid_template_arg) {
6512 Notes[0].second.setDiagID(diag::err_constexpr_invalid_template_arg);
6513 for (
unsigned I = 0; I < Notes.size(); ++I)
6514 Diag(Notes[I].first, Notes[I].second);
6518 for (
unsigned I = 0; I < Notes.size(); ++I)
6519 Diag(Notes[I].first, Notes[I].second);
6546 AllowedExplicit::Conversions,
6580 return PerformImplicitConversion(From, Ty, ICS,
6587 assert((isa<UnresolvedMemberExpr, MemberExpr>(MemExprE)) &&
6588 "expected a member expression");
6590 if (
const auto M = dyn_cast<UnresolvedMemberExpr>(MemExprE);
6591 M && !M->isImplicitAccess())
6592 Base = M->getBase();
6593 else if (
const auto M = dyn_cast<MemberExpr>(MemExprE);
6594 M && !M->isImplicitAccess())
6595 Base = M->getBase();
6628 assert(
Method->isExplicitObjectMemberFunction() &&
6629 "Method is not an explicit member function");
6630 assert(NewArgs.empty() &&
"NewArgs should be empty");
6632 NewArgs.reserve(Args.size() + 1);
6634 NewArgs.push_back(
This);
6635 NewArgs.append(Args.begin(), Args.end());
6638 Method, Object->getBeginLoc());
6657 for (
unsigned I = 0, N = ViableConversions.
size(); I != N; ++I) {
6659 cast<CXXConversionDecl>(ViableConversions[I]->getUnderlyingDecl());
6671 if (ExplicitConversions.
size() == 1 && !Converter.
Suppress) {
6674 cast<CXXConversionDecl>(
Found->getUnderlyingDecl());
6679 std::string TypeStr;
6684 "static_cast<" + TypeStr +
">(")
6696 HadMultipleCandidates);
6703 From,
Result.get()->getType());
6716 cast<CXXConversionDecl>(
Found->getUnderlyingDecl());
6729 HadMultipleCandidates);
6734 CK_UserDefinedConversion,
Result.get(),
6735 nullptr,
Result.get()->getValueKind(),
6757 if (isa<UsingShadowDecl>(
D))
6758 D = cast<UsingShadowDecl>(
D)->getTargetDecl();
6760 if (
auto *ConvTemplate = dyn_cast<FunctionTemplateDecl>(
D)) {
6762 ConvTemplate, FoundDecl, ActingContext, From, ToType, CandidateSet,
6768 Conv, FoundDecl, ActingContext, From, ToType, CandidateSet,
6799 ExprResult result = CheckPlaceholderExpr(From);
6802 From = result.
get();
6806 ExprResult Converted = DefaultLvalueConversion(From);
6817 if (!RecordTy || !getLangOpts().CPlusPlus) {
6829 : Converter(Converter), From(From) {}
6834 } IncompleteDiagnoser(Converter, From);
6837 : RequireCompleteType(
Loc,
T, IncompleteDiagnoser))
6844 const auto &Conversions = cast<CXXRecordDecl>(RecordTy->
getOriginalDecl())
6845 ->getDefinitionOrSelf()
6846 ->getVisibleConversionFunctions();
6848 bool HadMultipleCandidates =
6849 (std::distance(Conversions.begin(), Conversions.end()) > 1);
6853 bool HasUniqueTargetType =
true;
6856 for (
auto I = Conversions.begin(),
E = Conversions.end(); I !=
E; ++I) {
6866 Conversion = cast<CXXConversionDecl>(
D);
6868 assert((!ConvTemplate || getLangOpts().
CPlusPlus14) &&
6869 "Conversion operator templates are considered potentially "
6873 if (Converter.
match(CurToType) || ConvTemplate) {
6879 ExplicitConversions.
addDecl(I.getDecl(), I.getAccess());
6884 else if (HasUniqueTargetType &&
6886 HasUniqueTargetType =
false;
6888 ViableConversions.
addDecl(I.getDecl(), I.getAccess());
6906 HadMultipleCandidates,
6907 ExplicitConversions))
6913 if (!HasUniqueTargetType)
6932 HadMultipleCandidates,
Found))
6941 HadMultipleCandidates,
6942 ExplicitConversions))
6950 switch (ViableConversions.
size()) {
6953 HadMultipleCandidates,
6954 ExplicitConversions))
6964 HadMultipleCandidates,
Found))
6995 if (Proto->getNumParams() < 1)
6999 QualType ArgType = Proto->getParamType(0).getNonReferenceType();
7004 if (Proto->getNumParams() < 2)
7008 QualType ArgType = Proto->getParamType(1).getNonReferenceType();
7028 unsigned SeenAt = 0;
7030 bool HasDefault =
false;
7039 return HasDefault || SeenAt != 0;
7045 bool PartialOverloading,
bool AllowExplicit,
bool AllowExplicitConversions,
7048 bool StrictPackMatch) {
7051 assert(Proto &&
"Functions without a prototype cannot be overloaded");
7052 assert(!
Function->getDescribedFunctionTemplate() &&
7053 "Use AddTemplateOverloadCandidate for function templates");
7056 if (!isa<CXXConstructorDecl>(
Method)) {
7066 CandidateSet, SuppressUserConversions,
7067 PartialOverloading, EarlyConversions, PO,
7103 CandidateSet.
addCandidate(Args.size(), EarlyConversions);
7117 Candidate.
Viable =
false;
7123 if (getLangOpts().CPlusPlusModules &&
Function->isInAnotherModuleUnit()) {
7130 bool IsImplicitlyInstantiated =
false;
7131 if (
auto *SpecInfo =
Function->getTemplateSpecializationInfo()) {
7132 ND = SpecInfo->getTemplate();
7133 IsImplicitlyInstantiated = SpecInfo->getTemplateSpecializationKind() ==
7144 const bool IsInlineFunctionInGMF =
7146 (IsImplicitlyInstantiated ||
Function->isInlined());
7149 Candidate.
Viable =
false;
7156 Candidate.
Viable =
false;
7167 if (Args.size() == 1 &&
Constructor->isSpecializationCopyingObject() &&
7169 IsDerivedFrom(Args[0]->getBeginLoc(), Args[0]->getType(),
7171 Candidate.
Viable =
false;
7183 auto *Shadow = dyn_cast<ConstructorUsingShadowDecl>(FoundDecl.getDecl());
7184 if (Shadow && Args.size() == 1 &&
Constructor->getNumParams() >= 1 &&
7185 Constructor->getParamDecl(0)->getType()->isReferenceType()) {
7192 Candidate.
Viable =
false;
7201 Constructor->getMethodQualifiers().getAddressSpace(),
7202 CandidateSet.
getDestAS(), getASTContext())) {
7203 Candidate.
Viable =
false;
7216 Candidate.
Viable =
false;
7226 unsigned MinRequiredArgs =
Function->getMinRequiredArguments();
7227 if (!AggregateCandidateDeduction && Args.size() < MinRequiredArgs &&
7228 !PartialOverloading) {
7230 Candidate.
Viable =
false;
7236 if (getLangOpts().
CUDA) {
7244 Candidate.
Viable =
false;
7250 if (
Function->getTrailingRequiresClause()) {
7252 if (CheckFunctionConstraints(
Function, Satisfaction, {},
7255 Candidate.
Viable =
false;
7264 for (
unsigned ArgIdx = 0; ArgIdx < Args.size(); ++ArgIdx) {
7267 if (Candidate.
Conversions[ConvIdx].isInitialized()) {
7270 }
else if (ArgIdx < NumParams) {
7281 *
this, Args[ArgIdx], ParamType, SuppressUserConversions,
7284 getLangOpts().ObjCAutoRefCount, AllowExplicitConversions);
7286 Candidate.
Viable =
false;
7298 if (EnableIfAttr *FailedAttr =
7300 Candidate.
Viable =
false;
7310 if (Methods.size() <= 1)
7313 for (
unsigned b = 0, e = Methods.size();
b < e;
b++) {
7319 if (
Method->param_size() > NumNamedArgs)
7320 NumNamedArgs =
Method->param_size();
7321 if (Args.size() < NumNamedArgs)
7324 for (
unsigned i = 0; i < NumNamedArgs; i++) {
7326 if (Args[i]->isTypeDependent()) {
7332 Expr *argExpr = Args[i];
7333 assert(argExpr &&
"SelectBestMethod(): missing expression");
7338 !param->
hasAttr<CFConsumedAttr>())
7339 argExpr =
ObjC().stripARCUnbridgedCast(argExpr);
7352 getLangOpts().ObjCAutoRefCount,
7356 if (ConversionState.
isBad() ||
7366 for (
unsigned i = NumNamedArgs, e = Args.size(); i < e; ++i) {
7367 if (Args[i]->isTypeDependent()) {
7371 ExprResult Arg = DefaultVariadicArgumentPromotion(
7380 if (Args.size() != NumNamedArgs)
7382 else if (
Match && NumNamedArgs == 0 && Methods.size() > 1) {
7385 for (
unsigned b = 0, e = Methods.size();
b < e;
b++) {
7386 QualType ReturnT = Methods[
b]->getReturnType();
7405 assert(!isa<CXXConstructorDecl>(
Method) &&
7406 "Shouldn't have `this` for ctors!");
7407 assert(!
Method->isStatic() &&
"Shouldn't have `this` for static methods!");
7412 ConvertedThis = R.
get();
7414 if (
auto *MD = dyn_cast<CXXMethodDecl>(
Function)) {
7416 assert((MissingImplicitThis || MD->isStatic() ||
7417 isa<CXXConstructorDecl>(MD)) &&
7418 "Expected `this` for non-ctor instance methods");
7420 ConvertedThis =
nullptr;
7425 unsigned ArgSizeNoVarargs = std::min(
Function->param_size(), Args.size());
7428 for (
unsigned I = 0; I != ArgSizeNoVarargs; ++I) {
7437 ConvertedArgs.push_back(R.
get());
7445 for (
unsigned i = Args.size(), e =
Function->getNumParams(); i != e; ++i) {
7447 if (!
P->hasDefaultArg())
7452 ConvertedArgs.push_back(R.
get());
7464 bool MissingImplicitThis) {
7465 auto EnableIfAttrs =
Function->specific_attrs<EnableIfAttr>();
7466 if (EnableIfAttrs.begin() == EnableIfAttrs.end())
7472 Expr *DiscardedThis;
7474 *
this,
Function,
nullptr, CallLoc, Args, Trap,
7475 true, DiscardedThis, ConvertedArgs))
7476 return *EnableIfAttrs.begin();
7478 for (
auto *EIA : EnableIfAttrs) {
7482 if (EIA->getCond()->isValueDependent() ||
7483 !EIA->getCond()->EvaluateWithSubstitution(
7487 if (!
Result.isInt() || !
Result.getInt().getBoolValue())
7493template <
typename CheckFn>
7496 CheckFn &&IsSuccessful) {
7499 if (ArgDependent == DIA->getArgDependent())
7500 Attrs.push_back(DIA);
7507 auto WarningBegin = std::stable_partition(
7508 Attrs.begin(), Attrs.end(), [](
const DiagnoseIfAttr *DIA) {
7509 return DIA->getDefaultSeverity() == DiagnoseIfAttr::DS_error &&
7510 DIA->getWarningGroup().empty();
7515 auto ErrAttr = llvm::find_if(llvm::make_range(Attrs.begin(), WarningBegin),
7517 if (ErrAttr != WarningBegin) {
7518 const DiagnoseIfAttr *DIA = *ErrAttr;
7519 S.
Diag(
Loc, diag::err_diagnose_if_succeeded) << DIA->getMessage();
7520 S.
Diag(DIA->getLocation(), diag::note_from_diagnose_if)
7521 << DIA->getParent() << DIA->getCond()->getSourceRange();
7525 auto ToSeverity = [](DiagnoseIfAttr::DefaultSeverity Sev) {
7527 case DiagnoseIfAttr::DS_warning:
7529 case DiagnoseIfAttr::DS_error:
7532 llvm_unreachable(
"Fully covered switch above!");
7535 for (
const auto *DIA : llvm::make_range(WarningBegin, Attrs.end()))
7536 if (IsSuccessful(DIA)) {
7537 if (DIA->getWarningGroup().empty() &&
7538 DIA->getDefaultSeverity() == DiagnoseIfAttr::DS_warning) {
7539 S.
Diag(
Loc, diag::warn_diagnose_if_succeeded) << DIA->getMessage();
7540 S.
Diag(DIA->getLocation(), diag::note_from_diagnose_if)
7541 << DIA->getParent() << DIA->getCond()->getSourceRange();
7544 DIA->getWarningGroup());
7547 {ToSeverity(DIA->getDefaultSeverity()),
"%0",
7549 S.
Diag(
Loc, DiagID) << DIA->getMessage();
7557 const Expr *ThisArg,
7562 [&](
const DiagnoseIfAttr *DIA) {
7567 if (!DIA->getCond()->EvaluateWithSubstitution(
7568 Result, Context, cast<FunctionDecl>(DIA->getParent()), Args, ThisArg))
7570 return Result.isInt() &&
Result.getInt().getBoolValue();
7577 *
this, ND,
false,
Loc,
7578 [&](
const DiagnoseIfAttr *DIA) {
7589 bool SuppressUserConversions,
7590 bool PartialOverloading,
7591 bool FirstArgumentIsBase) {
7593 NamedDecl *
D = F.getDecl()->getUnderlyingDecl();
7600 if (isa<CXXMethodDecl>(FD) && !cast<CXXMethodDecl>(FD)->isStatic()) {
7603 if (Args.size() > 0) {
7604 if (
Expr *
E = Args[0]) {
7612 ObjectClassification =
E->
Classify(Context);
7614 FunctionArgs = Args.slice(1);
7617 AddMethodTemplateCandidate(
7618 FunTmpl, F.getPair(),
7620 ExplicitTemplateArgs, ObjectType, ObjectClassification,
7621 FunctionArgs, CandidateSet, SuppressUserConversions,
7622 PartialOverloading);
7624 AddMethodCandidate(cast<CXXMethodDecl>(FD), F.getPair(),
7625 cast<CXXMethodDecl>(FD)->getParent(), ObjectType,
7626 ObjectClassification, FunctionArgs, CandidateSet,
7627 SuppressUserConversions, PartialOverloading);
7634 if (Args.size() > 0 &&
7635 (!Args[0] || (FirstArgumentIsBase && isa<CXXMethodDecl>(FD) &&
7636 !isa<CXXConstructorDecl>(FD)))) {
7637 assert(cast<CXXMethodDecl>(FD)->isStatic());
7638 FunctionArgs = Args.slice(1);
7642 ExplicitTemplateArgs, FunctionArgs,
7643 CandidateSet, SuppressUserConversions,
7644 PartialOverloading);
7646 AddOverloadCandidate(FD, F.getPair(), FunctionArgs, CandidateSet,
7647 SuppressUserConversions, PartialOverloading);
7657 bool SuppressUserConversions,
7662 if (isa<UsingShadowDecl>(
Decl))
7663 Decl = cast<UsingShadowDecl>(
Decl)->getTargetDecl();
7666 assert(isa<CXXMethodDecl>(TD->getTemplatedDecl()) &&
7667 "Expected a member function template");
7668 AddMethodTemplateCandidate(TD, FoundDecl, ActingContext,
7669 nullptr, ObjectType,
7670 ObjectClassification, Args, CandidateSet,
7671 SuppressUserConversions,
false, PO);
7673 AddMethodCandidate(cast<CXXMethodDecl>(
Decl), FoundDecl, ActingContext,
7674 ObjectType, ObjectClassification, Args, CandidateSet,
7675 SuppressUserConversions,
false, {}, PO);
7688 assert(Proto &&
"Methods without a prototype cannot be overloaded");
7689 assert(!isa<CXXConstructorDecl>(
Method) &&
7690 "Use AddOverloadCandidate for constructors");
7699 Method->isMoveAssignmentOperator())
7706 bool IgnoreExplicitObject =
7707 (
Method->isExplicitObjectMemberFunction() &&
7710 bool ImplicitObjectMethodTreatedAsStatic =
7713 Method->isImplicitObjectMemberFunction();
7715 unsigned ExplicitOffset =
7716 !IgnoreExplicitObject &&
Method->isExplicitObjectMemberFunction() ? 1 : 0;
7718 unsigned NumParams =
Method->getNumParams() - ExplicitOffset +
7719 int(ImplicitObjectMethodTreatedAsStatic);
7721 unsigned ExtraArgs =
7728 CandidateSet.
addCandidate(Args.size() + ExtraArgs, EarlyConversions);
7744 Candidate.
Viable =
false;
7754 unsigned MinRequiredArgs =
Method->getMinRequiredArguments() -
7756 int(ImplicitObjectMethodTreatedAsStatic);
7758 if (Args.size() < MinRequiredArgs && !PartialOverloading) {
7760 Candidate.
Viable =
false;
7768 if (!IgnoreExplicitObject) {
7771 else if (
Method->isStatic()) {
7781 Candidate.
Conversions[FirstConvIdx].setStaticObjectArgument();
7786 *
this, CandidateSet.
getLocation(), ObjectType, ObjectClassification,
7787 Method, ActingContext,
true);
7788 if (Candidate.
Conversions[FirstConvIdx].isBad()) {
7789 Candidate.
Viable =
false;
7797 if (getLangOpts().
CUDA)
7798 if (!
CUDA().IsAllowedCall(getCurFunctionDecl(
true),
7800 Candidate.
Viable =
false;
7805 if (
Method->getTrailingRequiresClause()) {
7807 if (CheckFunctionConstraints(
Method, Satisfaction, {},
7810 Candidate.
Viable =
false;
7818 for (
unsigned ArgIdx = 0; ArgIdx < Args.size(); ++ArgIdx) {
7821 if (Candidate.
Conversions[ConvIdx].isInitialized()) {
7824 }
else if (ArgIdx < NumParams) {
7830 if (ImplicitObjectMethodTreatedAsStatic) {
7831 ParamType = ArgIdx == 0
7832 ?
Method->getFunctionObjectParameterReferenceType()
7835 ParamType = Proto->
getParamType(ArgIdx + ExplicitOffset);
7839 SuppressUserConversions,
7842 getLangOpts().ObjCAutoRefCount);
7844 Candidate.
Viable =
false;
7856 if (EnableIfAttr *FailedAttr =
7858 Candidate.
Viable =
false;
7865 Candidate.
Viable =
false;
7876 bool SuppressUserConversions,
bool PartialOverloading,
7894 PartialOverloading,
false,
7895 false, ObjectType, ObjectClassification,
7899 bool OnlyInitializeNonUserDefinedConversions) {
7900 return S.CheckNonDependentConversions(
7901 MethodTmpl, ParamTypes, Args, CandidateSet, Conversions,
7902 Sema::CheckNonDependentConversionsFlag(
7903 SuppressUserConversions,
7904 OnlyInitializeNonUserDefinedConversions),
7905 ActingContext, ObjectType, ObjectClassification, PO);
7909 CandidateSet.
addCandidate(Conversions.size(), Conversions);
7912 Candidate.
Viable =
false;
7922 (!
Method->isExplicitObjectMemberFunction() && ObjectType.
isNull());
7936 assert(
Specialization &&
"Missing member function template specialization?");
7938 "Specialization is not a member function?");
7940 cast<CXXMethodDecl>(
Specialization), FoundDecl, ActingContext, ObjectType,
7941 ObjectClassification, Args, CandidateSet, SuppressUserConversions,
7955 if (ExplicitTemplateArgs ||
7958 *
this, CandidateSet, MethodTmpl, FoundDecl, ActingContext,
7959 ExplicitTemplateArgs, ObjectType, ObjectClassification, Args,
7960 SuppressUserConversions, PartialOverloading, PO);
7965 MethodTmpl, FoundDecl, ActingContext, ObjectType, ObjectClassification,
7966 Args, SuppressUserConversions, PartialOverloading, PO);
7984 bool SuppressUserConversions,
bool PartialOverloading,
bool AllowExplicit,
7986 bool AggregateCandidateDeduction) {
7995 Candidate.
Viable =
false;
8015 PartialOverloading, AggregateCandidateDeduction,
8022 bool OnlyInitializeNonUserDefinedConversions) {
8023 return S.CheckNonDependentConversions(
8024 FunctionTemplate, ParamTypes, Args, CandidateSet, Conversions,
8025 Sema::CheckNonDependentConversionsFlag(
8026 SuppressUserConversions,
8027 OnlyInitializeNonUserDefinedConversions),
8028 nullptr, QualType(), {}, PO);
8032 CandidateSet.addCandidate(Conversions.size(), Conversions);
8035 Candidate.
Viable =
false;
8037 CandidateSet.getRewriteInfo().getRewriteKind(Candidate.
Function, PO);
8043 CandidateSet.getKind() ==
8047 isa<CXXMethodDecl>(Candidate.
Function) &&
8048 !cast<CXXMethodDecl>(Candidate.
Function)
8049 ->isExplicitObjectMemberFunction() &&
8050 !isa<CXXConstructorDecl>(Candidate.
Function);
8065 assert(
Specialization &&
"Missing function template specialization?");
8067 Specialization, FoundDecl, Args, CandidateSet, SuppressUserConversions,
8068 PartialOverloading, AllowExplicit,
8069 false, IsADLCandidate, Conversions, PO,
8070 Info.AggregateDeductionCandidateHasMismatchedArity,
8071 Info.hasStrictPackMatch());
8078 bool PartialOverloading,
bool AllowExplicit,
ADLCallKind IsADLCandidate,
8085 if (ExplicitTemplateArgs ||
8088 DependentExplicitSpecifier)) {
8092 Args, SuppressUserConversions, PartialOverloading, AllowExplicit,
8093 IsADLCandidate, PO, AggregateCandidateDeduction);
8095 if (DependentExplicitSpecifier)
8102 PartialOverloading, AllowExplicit, IsADLCandidate, PO,
8103 AggregateCandidateDeduction);
8116 const bool AllowExplicit =
false;
8118 bool ForOverloadSetAddressResolution =
8121 auto *
Method = dyn_cast<CXXMethodDecl>(FD);
8122 bool HasThisConversion = !ForOverloadSetAddressResolution &&
Method &&
8123 !isa<CXXConstructorDecl>(
Method);
8124 unsigned ThisConversions = HasThisConversion ? 1 : 0;
8126 if (Conversions.empty())
8137 if (HasThisConversion && !cast<CXXMethodDecl>(FD)->isStatic() &&
8140 if (!FD->hasCXXExplicitFunctionObjectParameter() ||
8141 !ParamTypes[0]->isDependentType()) {
8143 *
this, CandidateSet.
getLocation(), ObjectType, ObjectClassification,
8144 Method, ActingContext,
true,
8145 FD->hasCXXExplicitFunctionObjectParameter() ? ParamTypes[0]
8147 if (Conversions[ConvIdx].isBad())
8155 auto MaybeInvolveUserDefinedConversion = [&](
QualType ParamType,
8159 bool PointerConv = ParamType->
isPointerType() && ArgType->isPointerType();
8167 llvm::any_of(LookupConstructors(RD), [](
NamedDecl *ND) {
8179 if (
auto *RD = ArgType->getAsCXXRecordDecl();
8180 RD && RD->hasDefinition() &&
8181 !RD->getVisibleConversionFunctions().empty())
8188 HasThisConversion &&
Method->hasCXXExplicitFunctionObjectParameter() ? 1
8191 for (
unsigned I = 0, N = std::min(ParamTypes.size() - Offset, Args.size());
8193 QualType ParamType = ParamTypes[I + Offset];
8197 ConvIdx = Args.size() - 1 - I;
8198 assert(Args.size() + ThisConversions == 2 &&
8199 "number of args (including 'this') must be exactly 2 for "
8203 assert(!HasThisConversion || (ConvIdx == 0 && I == 0));
8206 ConvIdx = ThisConversions + I;
8208 if (Conversions[ConvIdx].isInitialized())
8211 MaybeInvolveUserDefinedConversion(ParamType, Args[I]->getType()))
8217 getLangOpts().ObjCAutoRefCount, AllowExplicit);
8218 if (Conversions[ConvIdx].isBad())
8240 bool AllowObjCPointerConversion) {
8248 bool ObjCLifetimeConversion;
8250 ObjCLifetimeConversion))
8255 if (!AllowObjCPointerConversion)
8259 bool IncompatibleObjC =
false;
8269 bool AllowExplicit,
bool AllowResultConversion,
bool StrictPackMatch) {
8271 "Conversion function templates use AddTemplateConversionCandidate");
8279 if (DeduceReturnType(Conversion, From->
getExprLoc()))
8286 if (!AllowResultConversion &&
8298 AllowObjCConversionOnExplicit))
8320 if (!AllowExplicit && Conversion->
isExplicit()) {
8321 Candidate.
Viable =
false;
8343 From->
Classify(Context), Conversion, ConversionContext,
8348 Candidate.
Viable =
false;
8355 if (CheckFunctionConstraints(Conversion, Satisfaction) ||
8357 Candidate.
Viable =
false;
8369 if (FromCanon == ToCanon ||
8370 IsDerivedFrom(CandidateSet.
getLocation(), FromCanon, ToCanon)) {
8371 Candidate.
Viable =
false;
8388 CK_FunctionToPointerDecay, &ConversionRef,
8392 if (!isCompleteType(From->
getBeginLoc(), ConversionType)) {
8393 Candidate.
Viable =
false;
8423 Candidate.
Viable =
false;
8435 Candidate.
Viable =
false;
8442 Candidate.
Viable =
false;
8448 "Can only end up with a standard conversion sequence or failure");
8451 if (EnableIfAttr *FailedAttr =
8452 CheckEnableIf(Conversion, CandidateSet.
getLocation(), {})) {
8453 Candidate.
Viable =
false;
8460 Candidate.
Viable =
false;
8469 bool AllowObjCConversionOnExplicit,
bool AllowExplicit,
8470 bool AllowResultConversion) {
8479 Candidate.
Viable =
false;
8496 Candidate.
Viable =
false;
8506 assert(
Specialization &&
"Missing function template specialization?");
8508 ToType, CandidateSet, AllowObjCConversionOnExplicit,
8509 AllowExplicit, AllowResultConversion,
8517 bool AllowExplicit,
bool AllowResultConversion) {
8519 "Only conversion function templates permitted here");
8530 ToType, AllowObjCConversionOnExplicit, AllowExplicit,
8531 AllowResultConversion);
8539 AllowObjCConversionOnExplicit, AllowExplicit, AllowResultConversion);
8574 *
this, CandidateSet.
getLocation(), Object->getType(),
8575 Object->Classify(Context), Conversion, ActingContext);
8578 if (ObjectInit.
isBad()) {
8579 Candidate.
Viable =
false;
8590 Candidate.
Conversions[0].UserDefined.EllipsisConversion =
false;
8591 Candidate.
Conversions[0].UserDefined.HadMultipleCandidates =
false;
8592 Candidate.
Conversions[0].UserDefined.ConversionFunction = Conversion;
8593 Candidate.
Conversions[0].UserDefined.FoundConversionFunction = FoundDecl;
8596 Candidate.
Conversions[0].UserDefined.After.setAsIdentityConversion();
8604 if (Args.size() > NumParams && !Proto->
isVariadic()) {
8605 Candidate.
Viable =
false;
8612 if (Args.size() < NumParams) {
8614 Candidate.
Viable =
false;
8621 for (
unsigned ArgIdx = 0, N = Args.size(); ArgIdx != N; ++ArgIdx) {
8622 if (ArgIdx < NumParams) {
8633 getLangOpts().ObjCAutoRefCount);
8635 Candidate.
Viable =
false;
8649 if (CheckFunctionConstraints(Conversion, Satisfaction, {},
8652 Candidate.
Viable =
false;
8658 if (EnableIfAttr *FailedAttr =
8659 CheckEnableIf(Conversion, CandidateSet.
getLocation(), {})) {
8660 Candidate.
Viable =
false;
8672 NamedDecl *
D = F.getDecl()->getUnderlyingDecl();
8683 assert(!isa<CXXMethodDecl>(FD) &&
8684 "unqualified operator lookup found a member function");
8688 FunctionArgs, CandidateSet);
8694 FunctionArgs[1], FunctionArgs[0]);
8696 Reversed, CandidateSet,
false,
false,
true,
8697 ADLCallKind::NotADL,
8701 if (ExplicitTemplateArgs)
8703 AddOverloadCandidate(FD, F.getPair(), FunctionArgs, CandidateSet);
8705 AddOverloadCandidate(FD, F.getPair(),
8706 {FunctionArgs[1], FunctionArgs[0]}, CandidateSet,
8707 false,
false,
true,
false, ADLCallKind::NotADL, {},
8735 bool IsComplete = isCompleteType(OpLoc, T1);
8739 if (!T1RD || (!IsComplete && !T1RD->isBeingDefined()))
8742 LookupResult Operators(*
this, OpName, OpLoc, LookupOrdinaryName);
8743 LookupQualifiedName(Operators, T1RD);
8747 OperEnd = Operators.
end();
8748 Oper != OperEnd; ++Oper) {
8749 if (Oper->getAsFunction() &&
8752 *
this, {Args[1], Args[0]}, Oper->getAsFunction()))
8754 AddMethodCandidate(Oper.getPair(), Args[0]->getType(),
8755 Args[0]->Classify(Context), Args.slice(1),
8756 CandidateSet,
false, PO);
8763 bool IsAssignmentOperator,
8764 unsigned NumContextualBoolArguments) {
8779 for (
unsigned ArgIdx = 0, N = Args.size(); ArgIdx != N; ++ArgIdx) {
8792 if (ArgIdx < NumContextualBoolArguments) {
8793 assert(ParamTys[ArgIdx] == Context.
BoolTy &&
8794 "Contextual conversion to bool requires bool type");
8800 ArgIdx == 0 && IsAssignmentOperator,
8803 getLangOpts().ObjCAutoRefCount);
8806 Candidate.
Viable =
false;
8819class BuiltinCandidateTypeSet {
8825 TypeSet PointerTypes;
8829 TypeSet MemberPointerTypes;
8833 TypeSet EnumerationTypes;
8837 TypeSet VectorTypes;
8841 TypeSet MatrixTypes;
8844 TypeSet BitIntTypes;
8847 bool HasNonRecordTypes;
8851 bool HasArithmeticOrEnumeralTypes;
8855 bool HasNullPtrType;
8864 bool AddPointerWithMoreQualifiedTypeVariants(
QualType Ty,
8866 bool AddMemberPointerWithMoreQualifiedTypeVariants(
QualType Ty);
8870 typedef TypeSet::iterator iterator;
8872 BuiltinCandidateTypeSet(
Sema &SemaRef)
8873 : HasNonRecordTypes(
false),
8874 HasArithmeticOrEnumeralTypes(
false),
8875 HasNullPtrType(
false),
8877 Context(SemaRef.Context) { }
8879 void AddTypesConvertedFrom(
QualType Ty,
8881 bool AllowUserConversions,
8882 bool AllowExplicitConversions,
8883 const Qualifiers &VisibleTypeConversionsQuals);
8885 llvm::iterator_range<iterator> pointer_types() {
return PointerTypes; }
8886 llvm::iterator_range<iterator> member_pointer_types() {
8887 return MemberPointerTypes;
8889 llvm::iterator_range<iterator> enumeration_types() {
8890 return EnumerationTypes;
8892 llvm::iterator_range<iterator> vector_types() {
return VectorTypes; }
8893 llvm::iterator_range<iterator> matrix_types() {
return MatrixTypes; }
8894 llvm::iterator_range<iterator> bitint_types() {
return BitIntTypes; }
8896 bool containsMatrixType(
QualType Ty)
const {
return MatrixTypes.count(Ty); }
8897 bool hasNonRecordTypes() {
return HasNonRecordTypes; }
8898 bool hasArithmeticOrEnumeralTypes() {
return HasArithmeticOrEnumeralTypes; }
8899 bool hasNullPtrType()
const {
return HasNullPtrType; }
8914BuiltinCandidateTypeSet::AddPointerWithMoreQualifiedTypeVariants(
QualType Ty,
8918 if (!PointerTypes.insert(Ty))
8923 bool buildObjCPtr =
false;
8927 buildObjCPtr =
true;
8939 unsigned BaseCVR = PointeeTy.getCVRQualifiers();
8945 if ((CVR | BaseCVR) != CVR)
continue;
8967 PointerTypes.insert(QPointerTy);
8983BuiltinCandidateTypeSet::AddMemberPointerWithMoreQualifiedTypeVariants(
8986 if (!MemberPointerTypes.insert(Ty))
8990 assert(PointerTy &&
"type was not a member pointer type!");
9005 if ((CVR | BaseCVR) != CVR)
continue;
9009 QPointeeTy, std::nullopt, Cls));
9024BuiltinCandidateTypeSet::AddTypesConvertedFrom(
QualType Ty,
9026 bool AllowUserConversions,
9027 bool AllowExplicitConversions,
9039 Ty = SemaRef.Context.getArrayDecayedType(Ty);
9046 HasNonRecordTypes = HasNonRecordTypes || !TyIsRec;
9049 HasArithmeticOrEnumeralTypes =
9053 PointerTypes.insert(Ty);
9057 if (!AddPointerWithMoreQualifiedTypeVariants(Ty, VisibleQuals))
9061 if (!AddMemberPointerWithMoreQualifiedTypeVariants(Ty))
9064 HasArithmeticOrEnumeralTypes =
true;
9065 EnumerationTypes.insert(Ty);
9067 HasArithmeticOrEnumeralTypes =
true;
9068 BitIntTypes.insert(Ty);
9072 HasArithmeticOrEnumeralTypes =
true;
9073 VectorTypes.insert(Ty);
9077 HasArithmeticOrEnumeralTypes =
true;
9078 MatrixTypes.insert(Ty);
9080 HasNullPtrType =
true;
9081 }
else if (AllowUserConversions && TyIsRec) {
9083 if (!SemaRef.isCompleteType(Loc, Ty))
9087 for (
NamedDecl *
D : ClassDecl->getVisibleConversionFunctions()) {
9088 if (isa<UsingShadowDecl>(
D))
9089 D = cast<UsingShadowDecl>(
D)->getTargetDecl();
9093 if (isa<FunctionTemplateDecl>(
D))
9097 if (AllowExplicitConversions || !Conv->
isExplicit()) {
9145 ClassDecl = RHSMPType->getMostRecentCXXRecordDecl();
9158 if (isa<UsingShadowDecl>(
D))
9159 D = cast<UsingShadowDecl>(
D)->getTargetDecl();
9193 if (Available.hasAtomic()) {
9194 Available.removeAtomic();
9201 if (Available.hasVolatile()) {
9202 Available.removeVolatile();
9236class BuiltinOperatorOverloadBuilder {
9241 bool HasArithmeticOrEnumeralCandidateType;
9245 static constexpr int ArithmeticTypesCap = 26;
9251 unsigned FirstIntegralType,
9253 unsigned FirstPromotedIntegralType,
9254 LastPromotedIntegralType;
9255 unsigned FirstPromotedArithmeticType,
9256 LastPromotedArithmeticType;
9257 unsigned NumArithmeticTypes;
9259 void InitArithmeticTypes() {
9261 FirstPromotedArithmeticType = 0;
9271 FirstIntegralType = ArithmeticTypes.size();
9272 FirstPromotedIntegralType = ArithmeticTypes.size();
9295 for (BuiltinCandidateTypeSet &Candidate : CandidateTypes) {
9296 for (
QualType BitTy : Candidate.bitint_types())
9299 llvm::move(BitIntCandidates, std::back_inserter(ArithmeticTypes));
9300 LastPromotedIntegralType = ArithmeticTypes.size();
9301 LastPromotedArithmeticType = ArithmeticTypes.size();
9315 LastIntegralType = ArithmeticTypes.size();
9316 NumArithmeticTypes = ArithmeticTypes.size();
9323 assert(ArithmeticTypes.size() - BitIntCandidates.size() <=
9324 ArithmeticTypesCap &&
9325 "Enough inline storage for all arithmetic types.");
9330 void addPlusPlusMinusMinusStyleOverloads(
QualType CandidateTy,
9379 BuiltinOperatorOverloadBuilder(
9382 bool HasArithmeticOrEnumeralCandidateType,
9386 VisibleTypeConversionsQuals(VisibleTypeConversionsQuals),
9387 HasArithmeticOrEnumeralCandidateType(
9388 HasArithmeticOrEnumeralCandidateType),
9389 CandidateTypes(CandidateTypes),
9390 CandidateSet(CandidateSet) {
9392 InitArithmeticTypes();
9415 if (!HasArithmeticOrEnumeralCandidateType)
9418 for (
unsigned Arith = 0; Arith < NumArithmeticTypes; ++Arith) {
9419 const auto TypeOfT = ArithmeticTypes[Arith];
9421 if (Op == OO_MinusMinus)
9423 if (Op == OO_PlusPlus && S.
getLangOpts().CPlusPlus17)
9426 addPlusPlusMinusMinusStyleOverloads(
9443 void addPlusPlusMinusMinusPointerOverloads() {
9444 for (
QualType PtrTy : CandidateTypes[0].pointer_types()) {
9446 if (!PtrTy->getPointeeType()->isObjectType())
9449 addPlusPlusMinusMinusStyleOverloads(
9451 (!PtrTy.isVolatileQualified() &&
9453 (!PtrTy.isRestrictQualified() &&
9468 void addUnaryStarPointerOverloads() {
9469 for (
QualType ParamTy : CandidateTypes[0].pointer_types()) {
9475 if (Proto->getMethodQuals() || Proto->getRefQualifier())
9488 void addUnaryPlusOrMinusArithmeticOverloads() {
9489 if (!HasArithmeticOrEnumeralCandidateType)
9492 for (
unsigned Arith = FirstPromotedArithmeticType;
9493 Arith < LastPromotedArithmeticType; ++Arith) {
9494 QualType ArithTy = ArithmeticTypes[Arith];
9499 for (
QualType VecTy : CandidateTypes[0].vector_types())
9508 void addUnaryPlusPointerOverloads() {
9509 for (
QualType ParamTy : CandidateTypes[0].pointer_types())
9518 void addUnaryTildePromotedIntegralOverloads() {
9519 if (!HasArithmeticOrEnumeralCandidateType)
9522 for (
unsigned Int = FirstPromotedIntegralType;
9523 Int < LastPromotedIntegralType; ++
Int) {
9529 for (
QualType VecTy : CandidateTypes[0].vector_types())
9539 void addEqualEqualOrNotEqualMemberPointerOrNullptrOverloads() {
9543 for (
unsigned ArgIdx = 0, N = Args.size(); ArgIdx != N; ++ArgIdx) {
9544 for (
QualType MemPtrTy : CandidateTypes[ArgIdx].member_pointer_types()) {
9549 QualType ParamTypes[2] = {MemPtrTy, MemPtrTy};
9553 if (CandidateTypes[ArgIdx].hasNullPtrType()) {
9555 if (AddedTypes.insert(NullPtrTy).second) {
9556 QualType ParamTypes[2] = { NullPtrTy, NullPtrTy };
9575 void addGenericBinaryPointerOrEnumeralOverloads(
bool IsSpaceship) {
9588 llvm::DenseSet<std::pair<CanQualType, CanQualType> >
9589 UserDefinedBinaryOperators;
9591 for (
unsigned ArgIdx = 0, N = Args.size(); ArgIdx != N; ++ArgIdx) {
9592 if (!CandidateTypes[ArgIdx].enumeration_types().empty()) {
9594 CEnd = CandidateSet.
end();
9596 if (!
C->Viable || !
C->Function ||
C->Function->getNumParams() != 2)
9599 if (
C->Function->isFunctionTemplateSpecialization())
9608 .getUnqualifiedType();
9611 .getUnqualifiedType();
9619 UserDefinedBinaryOperators.insert(
9629 for (
unsigned ArgIdx = 0, N = Args.size(); ArgIdx != N; ++ArgIdx) {
9630 for (
QualType PtrTy : CandidateTypes[ArgIdx].pointer_types()) {
9634 if (IsSpaceship && PtrTy->isFunctionPointerType())
9637 QualType ParamTypes[2] = {PtrTy, PtrTy};
9640 for (
QualType EnumTy : CandidateTypes[ArgIdx].enumeration_types()) {
9645 if (!AddedTypes.insert(CanonType).second ||
9646 UserDefinedBinaryOperators.count(std::make_pair(CanonType,
9649 QualType ParamTypes[2] = {EnumTy, EnumTy};
9676 for (
int Arg = 0; Arg < 2; ++Arg) {
9677 QualType AsymmetricParamTypes[2] = {
9681 for (
QualType PtrTy : CandidateTypes[Arg].pointer_types()) {
9686 AsymmetricParamTypes[Arg] = PtrTy;
9687 if (Arg == 0 || Op == OO_Plus) {
9692 if (Op == OO_Minus) {
9697 QualType ParamTypes[2] = {PtrTy, PtrTy};
9733 void addGenericBinaryArithmeticOverloads() {
9734 if (!HasArithmeticOrEnumeralCandidateType)
9737 for (
unsigned Left = FirstPromotedArithmeticType;
9738 Left < LastPromotedArithmeticType; ++
Left) {
9739 for (
unsigned Right = FirstPromotedArithmeticType;
9740 Right < LastPromotedArithmeticType; ++
Right) {
9742 ArithmeticTypes[
Right] };
9749 for (
QualType Vec1Ty : CandidateTypes[0].vector_types())
9750 for (
QualType Vec2Ty : CandidateTypes[1].vector_types()) {
9751 QualType LandR[2] = {Vec1Ty, Vec2Ty};
9761 void addMatrixBinaryArithmeticOverloads() {
9762 if (!HasArithmeticOrEnumeralCandidateType)
9765 for (
QualType M1 : CandidateTypes[0].matrix_types()) {
9766 AddCandidate(M1, cast<MatrixType>(M1)->getElementType());
9767 AddCandidate(M1, M1);
9770 for (
QualType M2 : CandidateTypes[1].matrix_types()) {
9771 AddCandidate(cast<MatrixType>(M2)->getElementType(), M2);
9772 if (!CandidateTypes[0].containsMatrixType(M2))
9773 AddCandidate(M2, M2);
9808 void addThreeWayArithmeticOverloads() {
9809 addGenericBinaryArithmeticOverloads();
9826 void addBinaryBitwiseArithmeticOverloads() {
9827 if (!HasArithmeticOrEnumeralCandidateType)
9830 for (
unsigned Left = FirstPromotedIntegralType;
9831 Left < LastPromotedIntegralType; ++
Left) {
9832 for (
unsigned Right = FirstPromotedIntegralType;
9835 ArithmeticTypes[
Right] };
9848 void addAssignmentMemberPointerOrEnumeralOverloads() {
9852 for (
unsigned ArgIdx = 0; ArgIdx < 2; ++ArgIdx) {
9853 for (
QualType EnumTy : CandidateTypes[ArgIdx].enumeration_types()) {
9860 for (
QualType MemPtrTy : CandidateTypes[ArgIdx].member_pointer_types()) {
9885 void addAssignmentPointerOverloads(
bool isEqualOp) {
9889 for (
QualType PtrTy : CandidateTypes[0].pointer_types()) {
9893 else if (!PtrTy->getPointeeType()->isObjectType())
9904 bool NeedVolatile = !PtrTy.isVolatileQualified() &&
9914 if (!PtrTy.isRestrictQualified() &&
9934 for (
QualType PtrTy : CandidateTypes[1].pointer_types()) {
9948 bool NeedVolatile = !PtrTy.isVolatileQualified() &&
9958 if (!PtrTy.isRestrictQualified() &&
9991 void addAssignmentArithmeticOverloads(
bool isEqualOp) {
9992 if (!HasArithmeticOrEnumeralCandidateType)
9995 for (
unsigned Left = 0;
Left < NumArithmeticTypes; ++
Left) {
9996 for (
unsigned Right = FirstPromotedArithmeticType;
9997 Right < LastPromotedArithmeticType; ++
Right) {
9999 ParamTypes[1] = ArithmeticTypes[
Right];
10001 S, ArithmeticTypes[Left], Args[0]);
10014 for (
QualType Vec1Ty : CandidateTypes[0].vector_types())
10015 for (
QualType Vec2Ty : CandidateTypes[0].vector_types()) {
10017 ParamTypes[1] = Vec2Ty;
10045 void addAssignmentIntegralOverloads() {
10046 if (!HasArithmeticOrEnumeralCandidateType)
10049 for (
unsigned Left = FirstIntegralType;
Left < LastIntegralType; ++
Left) {
10050 for (
unsigned Right = FirstPromotedIntegralType;
10051 Right < LastPromotedIntegralType; ++
Right) {
10053 ParamTypes[1] = ArithmeticTypes[
Right];
10055 S, ArithmeticTypes[Left], Args[0]);
10074 void addExclaimOverload() {
10080 void addAmpAmpOrPipePipeOverload() {
10097 void addSubscriptOverloads() {
10098 for (
QualType PtrTy : CandidateTypes[0].pointer_types()) {
10108 for (
QualType PtrTy : CandidateTypes[1].pointer_types()) {
10128 void addArrowStarOverloads() {
10129 for (
QualType PtrTy : CandidateTypes[0].pointer_types()) {
10134 if (!isa<RecordType>(C1))
10143 for (
QualType MemPtrTy : CandidateTypes[1].member_pointer_types()) {
10150 QualType ParamTypes[2] = {PtrTy, MemPtrTy};
10153 if (!VisibleTypeConversionsQuals.
hasVolatile() &&
10154 T.isVolatileQualified())
10156 if (!VisibleTypeConversionsQuals.
hasRestrict() &&
10157 T.isRestrictQualified())
10175 void addConditionalOperatorOverloads() {
10179 for (
unsigned ArgIdx = 0; ArgIdx < 2; ++ArgIdx) {
10180 for (
QualType PtrTy : CandidateTypes[ArgIdx].pointer_types()) {
10184 QualType ParamTypes[2] = {PtrTy, PtrTy};
10188 for (
QualType MemPtrTy : CandidateTypes[ArgIdx].member_pointer_types()) {
10192 QualType ParamTypes[2] = {MemPtrTy, MemPtrTy};
10197 for (
QualType EnumTy : CandidateTypes[ArgIdx].enumeration_types()) {
10198 if (!EnumTy->castAsCanonical<
EnumType>()
10206 QualType ParamTypes[2] = {EnumTy, EnumTy};
10225 VisibleTypeConversionsQuals.
addConst();
10226 for (
unsigned ArgIdx = 0, N = Args.size(); ArgIdx != N; ++ArgIdx) {
10228 if (Args[ArgIdx]->getType()->isAtomicType())
10229 VisibleTypeConversionsQuals.
addAtomic();
10232 bool HasNonRecordCandidateType =
false;
10233 bool HasArithmeticOrEnumeralCandidateType =
false;
10235 for (
unsigned ArgIdx = 0, N = Args.size(); ArgIdx != N; ++ArgIdx) {
10236 CandidateTypes.emplace_back(*
this);
10237 CandidateTypes[ArgIdx].AddTypesConvertedFrom(Args[ArgIdx]->getType(),
10240 (Op == OO_Exclaim ||
10242 Op == OO_PipePipe),
10243 VisibleTypeConversionsQuals);
10244 HasNonRecordCandidateType = HasNonRecordCandidateType ||
10245 CandidateTypes[ArgIdx].hasNonRecordTypes();
10246 HasArithmeticOrEnumeralCandidateType =
10247 HasArithmeticOrEnumeralCandidateType ||
10248 CandidateTypes[ArgIdx].hasArithmeticOrEnumeralTypes();
10256 if (!HasNonRecordCandidateType &&
10257 !(Op == OO_Exclaim || Op == OO_AmpAmp || Op == OO_PipePipe))
10261 BuiltinOperatorOverloadBuilder OpBuilder(*
this, Args,
10262 VisibleTypeConversionsQuals,
10263 HasArithmeticOrEnumeralCandidateType,
10264 CandidateTypes, CandidateSet);
10270 llvm_unreachable(
"Expected an overloaded operator");
10275 case OO_Array_Delete:
10278 "Special operators don't use AddBuiltinOperatorCandidates");
10290 if (Args.size() == 1)
10291 OpBuilder.addUnaryPlusPointerOverloads();
10295 if (Args.size() == 1) {
10296 OpBuilder.addUnaryPlusOrMinusArithmeticOverloads();
10298 OpBuilder.addBinaryPlusOrMinusPointerOverloads(Op);
10299 OpBuilder.addGenericBinaryArithmeticOverloads();
10300 OpBuilder.addMatrixBinaryArithmeticOverloads();
10305 if (Args.size() == 1)
10306 OpBuilder.addUnaryStarPointerOverloads();
10308 OpBuilder.addGenericBinaryArithmeticOverloads();
10309 OpBuilder.addMatrixBinaryArithmeticOverloads();
10314 OpBuilder.addGenericBinaryArithmeticOverloads();
10318 case OO_MinusMinus:
10319 OpBuilder.addPlusPlusMinusMinusArithmeticOverloads(Op);
10320 OpBuilder.addPlusPlusMinusMinusPointerOverloads();
10323 case OO_EqualEqual:
10324 case OO_ExclaimEqual:
10325 OpBuilder.addEqualEqualOrNotEqualMemberPointerOrNullptrOverloads();
10326 OpBuilder.addGenericBinaryPointerOrEnumeralOverloads(
false);
10327 OpBuilder.addGenericBinaryArithmeticOverloads();
10333 case OO_GreaterEqual:
10334 OpBuilder.addGenericBinaryPointerOrEnumeralOverloads(
false);
10335 OpBuilder.addGenericBinaryArithmeticOverloads();
10339 OpBuilder.addGenericBinaryPointerOrEnumeralOverloads(
true);
10340 OpBuilder.addThreeWayArithmeticOverloads();
10347 case OO_GreaterGreater:
10348 OpBuilder.addBinaryBitwiseArithmeticOverloads();
10352 if (Args.size() == 1)
10358 OpBuilder.addBinaryBitwiseArithmeticOverloads();
10362 OpBuilder.addUnaryTildePromotedIntegralOverloads();
10366 OpBuilder.addAssignmentMemberPointerOrEnumeralOverloads();
10370 case OO_MinusEqual:
10371 OpBuilder.addAssignmentPointerOverloads(Op == OO_Equal);
10375 case OO_SlashEqual:
10376 OpBuilder.addAssignmentArithmeticOverloads(Op == OO_Equal);
10379 case OO_PercentEqual:
10380 case OO_LessLessEqual:
10381 case OO_GreaterGreaterEqual:
10383 case OO_CaretEqual:
10385 OpBuilder.addAssignmentIntegralOverloads();
10389 OpBuilder.addExclaimOverload();
10394 OpBuilder.addAmpAmpOrPipePipeOverload();
10398 if (Args.size() == 2)
10399 OpBuilder.addSubscriptOverloads();
10403 OpBuilder.addArrowStarOverloads();
10406 case OO_Conditional:
10407 OpBuilder.addConditionalOperatorOverloads();
10408 OpBuilder.addGenericBinaryArithmeticOverloads();
10419 bool PartialOverloading) {
10430 ArgumentDependentLookup(Name,
Loc, Args, Fns);
10436 CandEnd = CandidateSet.
end();
10437 Cand != CandEnd; ++Cand)
10438 if (Cand->Function) {
10442 Fns.
erase(FunTmpl);
10451 if (ExplicitTemplateArgs)
10454 AddOverloadCandidate(
10455 FD, FoundDecl, Args, CandidateSet,
false,
10456 PartialOverloading,
true,
10457 false, ADLCallKind::UsesADL);
10459 AddOverloadCandidate(
10460 FD, FoundDecl, {Args[1], Args[0]}, CandidateSet,
10461 false, PartialOverloading,
10466 auto *FTD = cast<FunctionTemplateDecl>(*I);
10468 FTD, FoundDecl, ExplicitTemplateArgs, Args, CandidateSet,
10469 false, PartialOverloading,
10470 true, ADLCallKind::UsesADL);
10472 *
this, Args, FTD->getTemplatedDecl())) {
10476 if (ReversedArgs.empty())
10480 FTD, FoundDecl, ExplicitTemplateArgs, ReversedArgs, CandidateSet,
10481 false, PartialOverloading,
10482 true, ADLCallKind::UsesADL,
10490enum class Comparison {
Equal, Better, Worse };
10507 bool Cand1Attr = Cand1->
hasAttr<EnableIfAttr>();
10508 bool Cand2Attr = Cand2->
hasAttr<EnableIfAttr>();
10509 if (!Cand1Attr || !Cand2Attr) {
10510 if (Cand1Attr == Cand2Attr)
10511 return Comparison::Equal;
10512 return Cand1Attr ? Comparison::Better : Comparison::Worse;
10518 llvm::FoldingSetNodeID Cand1ID, Cand2ID;
10519 for (
auto Pair : zip_longest(Cand1Attrs, Cand2Attrs)) {
10520 std::optional<EnableIfAttr *> Cand1A = std::get<0>(Pair);
10521 std::optional<EnableIfAttr *> Cand2A = std::get<1>(Pair);
10526 return Comparison::Worse;
10528 return Comparison::Better;
10533 (*Cand1A)->getCond()->Profile(Cand1ID, S.
getASTContext(),
true);
10534 (*Cand2A)->getCond()->Profile(Cand2ID, S.
getASTContext(),
true);
10535 if (Cand1ID != Cand2ID)
10536 return Comparison::Worse;
10539 return Comparison::Equal;
10547 return Comparison::Equal;
10553 return Comparison::Equal;
10554 return Comparison::Worse;
10557 return Comparison::Better;
10563 const auto *Cand1CPUSpec = Cand1.
Function->
getAttr<CPUSpecificAttr>();
10564 const auto *Cand2CPUSpec = Cand2.
Function->
getAttr<CPUSpecificAttr>();
10566 if (!Cand1CPUDisp && !Cand2CPUDisp && !Cand1CPUSpec && !Cand2CPUSpec)
10567 return Comparison::Equal;
10569 if (Cand1CPUDisp && !Cand2CPUDisp)
10570 return Comparison::Better;
10571 if (Cand2CPUDisp && !Cand1CPUDisp)
10572 return Comparison::Worse;
10574 if (Cand1CPUSpec && Cand2CPUSpec) {
10575 if (Cand1CPUSpec->cpus_size() != Cand2CPUSpec->cpus_size())
10576 return Cand1CPUSpec->cpus_size() < Cand2CPUSpec->cpus_size()
10577 ? Comparison::Better
10578 : Comparison::Worse;
10580 std::pair<CPUSpecificAttr::cpus_iterator, CPUSpecificAttr::cpus_iterator>
10581 FirstDiff = std::mismatch(
10582 Cand1CPUSpec->cpus_begin(), Cand1CPUSpec->cpus_end(),
10583 Cand2CPUSpec->cpus_begin(),
10585 return LHS->getName() == RHS->getName();
10588 assert(FirstDiff.first != Cand1CPUSpec->cpus_end() &&
10589 "Two different cpu-specific versions should not have the same "
10590 "identifier list, otherwise they'd be the same decl!");
10591 return (*FirstDiff.first)->getName() < (*FirstDiff.second)->getName()
10592 ? Comparison::Better
10593 : Comparison::Worse;
10595 llvm_unreachable(
"No way to get here unless both had cpu_dispatch");
10601static std::optional<QualType>
10603 if (!isa<CXXMethodDecl>(F) || isa<CXXConstructorDecl>(F))
10604 return std::nullopt;
10606 auto *M = cast<CXXMethodDecl>(F);
10610 return M->getFunctionObjectParameterReferenceType();
10624 PT2->getInstantiatedFromMemberTemplate()))
10635 assert(I < F->getNumParams());
10639 unsigned F1NumParams = F1->
getNumParams() + isa<CXXMethodDecl>(F1);
10640 unsigned F2NumParams = F2->
getNumParams() + isa<CXXMethodDecl>(F2);
10642 if (F1NumParams != F2NumParams)
10645 unsigned I1 = 0, I2 = 0;
10646 for (
unsigned I = 0; I != F1NumParams; ++I) {
10647 QualType T1 = NextParam(F1, I1, I == 0);
10648 QualType T2 = NextParam(F2, I2, I == 0);
10649 assert(!T1.
isNull() && !T2.
isNull() &&
"Unexpected null param types");
10663 bool IsFn1Reversed,
10664 bool IsFn2Reversed) {
10665 assert(Fn1 && Fn2);
10670 IsFn1Reversed ^ IsFn2Reversed))
10673 auto *Mem1 = dyn_cast<CXXMethodDecl>(Fn1);
10674 auto *Mem2 = dyn_cast<CXXMethodDecl>(Fn2);
10675 if (Mem1 && Mem2) {
10678 if (Mem1->getParent() != Mem2->getParent())
10682 if (Mem1->isInstance() && Mem2->isInstance() &&
10684 Mem1->getFunctionObjectParameterReferenceType(),
10685 Mem1->getFunctionObjectParameterReferenceType()))
10693 bool IsFn1Reversed,
bool IsFn2Reversed) {
10703 if (Cand1IsSpecialization || Cand2IsSpecialization)
10720 bool PartialOverloading) {
10766 bool IsCand1ImplicitHD =
10768 bool IsCand2ImplicitHD =
10783 auto EmitThreshold =
10784 (S.
getLangOpts().CUDAIsDevice && IsCallerImplicitHD &&
10785 (IsCand1ImplicitHD || IsCand2ImplicitHD))
10788 auto Cand1Emittable = P1 > EmitThreshold;
10789 auto Cand2Emittable = P2 > EmitThreshold;
10790 if (Cand1Emittable && !Cand2Emittable)
10792 if (!Cand1Emittable && Cand2Emittable)
10803 unsigned StartArg = 0;
10811 return ICS.isStandard() &&
10823 assert(Cand2.
Conversions.size() == NumArgs &&
"Overload candidate mismatch");
10824 bool HasBetterConversion =
false;
10825 for (
unsigned ArgIdx = StartArg; ArgIdx < NumArgs; ++ArgIdx) {
10826 bool Cand1Bad = IsIllFormedConversion(Cand1.
Conversions[ArgIdx]);
10827 bool Cand2Bad = IsIllFormedConversion(Cand2.
Conversions[ArgIdx]);
10828 if (Cand1Bad != Cand2Bad) {
10831 HasBetterConversion =
true;
10835 if (HasBetterConversion)
10842 bool HasWorseConversion =
false;
10843 for (
unsigned ArgIdx = StartArg; ArgIdx < NumArgs; ++ArgIdx) {
10849 HasBetterConversion =
true;
10868 HasWorseConversion =
true;
10883 if (HasBetterConversion && !HasWorseConversion)
10894 isa<CXXConversionDecl>(Cand1.
Function) &&
10895 isa<CXXConversionDecl>(Cand2.
Function)) {
10925 isa<CXXConstructorDecl>(Cand1.
Function) !=
10926 isa<CXXConstructorDecl>(Cand2.
Function))
10927 return isa<CXXConstructorDecl>(Cand1.
Function);
10934 bool Cand1IsSpecialization = Cand1.
Function &&
10936 bool Cand2IsSpecialization = Cand2.
Function &&
10938 if (Cand1IsSpecialization != Cand2IsSpecialization)
10939 return Cand2IsSpecialization;
10945 if (Cand1IsSpecialization && Cand2IsSpecialization) {
10946 const auto *Obj1Context =
10948 const auto *Obj2Context =
10977 bool Cand1IsInherited =
10979 bool Cand2IsInherited =
10981 if (Cand1IsInherited != Cand2IsInherited)
10982 return Cand2IsInherited;
10983 else if (Cand1IsInherited) {
10984 assert(Cand2IsInherited);
10987 if (Cand1Class->isDerivedFrom(Cand2Class))
10989 if (Cand2Class->isDerivedFrom(Cand1Class))
11006 auto *Guide1 = dyn_cast_or_null<CXXDeductionGuideDecl>(Cand1.
Function);
11007 auto *Guide2 = dyn_cast_or_null<CXXDeductionGuideDecl>(Cand2.
Function);
11008 if (Guide1 && Guide2) {
11010 if (Guide1->isImplicit() != Guide2->isImplicit())
11011 return Guide2->isImplicit();
11021 const auto *Constructor1 = Guide1->getCorrespondingConstructor();
11022 const auto *Constructor2 = Guide2->getCorrespondingConstructor();
11023 if (Constructor1 && Constructor2) {
11024 bool isC1Templated = Constructor1->getTemplatedKind() !=
11026 bool isC2Templated = Constructor2->getTemplatedKind() !=
11028 if (isC1Templated != isC2Templated)
11029 return isC2Templated;
11037 if (Cmp != Comparison::Equal)
11038 return Cmp == Comparison::Better;
11041 bool HasPS1 = Cand1.
Function !=
nullptr &&
11043 bool HasPS2 = Cand2.
Function !=
nullptr &&
11045 if (HasPS1 != HasPS2 && HasPS1)
11049 if (MV == Comparison::Better)
11051 if (MV == Comparison::Worse)
11066 const auto *CD1 = dyn_cast_or_null<CXXConstructorDecl>(Cand1.
Function);
11067 const auto *CD2 = dyn_cast_or_null<CXXConstructorDecl>(Cand2.
Function);
11069 LangAS AS1 = CD1->getMethodQualifiers().getAddressSpace();
11070 LangAS AS2 = CD2->getMethodQualifiers().getAddressSpace();
11091 auto *VA = dyn_cast_or_null<ValueDecl>(A);
11092 auto *VB = dyn_cast_or_null<ValueDecl>(B);
11098 if (!VA->getDeclContext()->getRedeclContext()->Equals(
11099 VB->getDeclContext()->getRedeclContext()) ||
11100 getOwningModule(VA) == getOwningModule(VB) ||
11101 VA->isExternallyVisible() || VB->isExternallyVisible())
11109 if (Context.
hasSameType(VA->getType(), VB->getType()))
11114 if (
auto *EA = dyn_cast<EnumConstantDecl>(VA)) {
11115 if (
auto *EB = dyn_cast<EnumConstantDecl>(VB)) {
11118 auto *EnumA = cast<EnumDecl>(EA->getDeclContext());
11119 auto *EnumB = cast<EnumDecl>(EB->getDeclContext());
11120 if (EnumA->hasNameForLinkage() || EnumB->hasNameForLinkage() ||
11122 EnumB->getIntegerType()))
11125 return llvm::APSInt::isSameValue(EA->getInitVal(), EB->getInitVal());
11135 assert(
D &&
"Unknown declaration");
11136 Diag(
Loc, diag::ext_equivalent_internal_linkage_decl_in_modules) <<
D;
11138 Module *M = getOwningModule(
D);
11142 for (
auto *
E : Equiv) {
11143 Module *M = getOwningModule(
E);
11144 Diag(
E->getLocation(), diag::note_equivalent_internal_linkage_decl)
11153 static_cast<CNSInfo *
>(DeductionFailure.Data)
11154 ->Satisfaction.ContainsErrors;
11160 bool PartialOverloading,
bool AllowExplicit,
11162 bool AggregateCandidateDeduction) {
11165 allocateDeferredCandidate<DeferredFunctionTemplateOverloadCandidate>();
11170 false, AllowExplicit, SuppressUserConversions,
11171 PartialOverloading, AggregateCandidateDeduction},
11178 HasDeferredTemplateConstructors |=
11186 bool SuppressUserConversions,
bool PartialOverloading,
11192 allocateDeferredCandidate<DeferredMethodTemplateOverloadCandidate>();
11198 false, SuppressUserConversions, PartialOverloading,
11204 ObjectClassification,
11212 bool AllowObjCConversionOnExplicit,
bool AllowExplicit,
11213 bool AllowResultConversion) {
11216 allocateDeferredCandidate<DeferredConversionTemplateOverloadCandidate>();
11220 AllowObjCConversionOnExplicit, AllowResultConversion,
11237 S, CandidateSet,
C.FunctionTemplate,
C.FoundDecl,
C.ActingContext,
11238 nullptr,
C.ObjectType,
C.ObjectClassification,
11239 C.Args,
C.SuppressUserConversions,
C.PartialOverloading,
C.PO);
11246 S, CandidateSet,
C.FunctionTemplate,
C.FoundDecl,
11247 nullptr,
C.Args,
C.SuppressUserConversions,
11248 C.PartialOverloading,
C.AllowExplicit,
C.IsADLCandidate,
C.PO,
11249 C.AggregateCandidateDeduction);
11256 S, CandidateSet,
C.FunctionTemplate,
C.FoundDecl,
C.ActingContext,
C.From,
11257 C.ToType,
C.AllowObjCConversionOnExplicit,
C.AllowExplicit,
11258 C.AllowResultConversion);
11262 Candidates.reserve(Candidates.size() + DeferredCandidatesCount);
11265 switch (Cand->
Kind) {
11284 FirstDeferredCandidate =
nullptr;
11285 DeferredCandidatesCount = 0;
11289OverloadCandidateSet::ResultForBestCandidate(
const iterator &Best) {
11291 if (Best->Function && Best->Function->isDeleted())
11296void OverloadCandidateSet::CudaExcludeWrongSideCandidates(
11313 bool ContainsSameSideCandidate =
11317 S.
CUDA().IdentifyPreference(Caller, Cand->
Function) ==
11321 if (!ContainsSameSideCandidate)
11330 llvm::erase_if(Candidates, IsWrongSideCandidate);
11348 DeferredCandidatesCount == 0) &&
11349 "Unexpected deferred template candidates");
11351 bool TwoPhaseResolution =
11352 DeferredCandidatesCount != 0 && !ResolutionByPerfectCandidateIsDisabled;
11354 if (TwoPhaseResolution) {
11356 if (Best !=
end() && Best->isPerfectMatch(S.
Context)) {
11357 if (!(HasDeferredTemplateConstructors &&
11358 isa_and_nonnull<CXXConversionDecl>(Best->Function)))
11364 return BestViableFunctionImpl(S,
Loc, Best);
11371 Candidates.reserve(this->Candidates.size());
11372 std::transform(this->Candidates.begin(), this->Candidates.end(),
11373 std::back_inserter(Candidates),
11377 CudaExcludeWrongSideCandidates(S, Candidates);
11380 for (
auto *Cand : Candidates) {
11381 Cand->
Best =
false;
11383 if (Best ==
end() ||
11402 PendingBest.push_back(&*Best);
11407 while (!PendingBest.empty()) {
11408 auto *Curr = PendingBest.pop_back_val();
11409 for (
auto *Cand : Candidates) {
11412 PendingBest.push_back(Cand);
11417 EquivalentCands.push_back(Cand->
Function);
11429 if (!EquivalentCands.empty())
11437enum OverloadCandidateKind {
11440 oc_reversed_binary_operator,
11442 oc_implicit_default_constructor,
11443 oc_implicit_copy_constructor,
11444 oc_implicit_move_constructor,
11445 oc_implicit_copy_assignment,
11446 oc_implicit_move_assignment,
11447 oc_implicit_equality_comparison,
11448 oc_inherited_constructor
11451enum OverloadCandidateSelect {
11454 ocs_described_template,
11457static std::pair<OverloadCandidateKind, OverloadCandidateSelect>
11461 std::string &Description) {
11467 FunTmpl->getTemplateParameters(), *
Fn->getTemplateSpecializationArgs());
11470 OverloadCandidateSelect Select = [&]() {
11471 if (!Description.empty())
11472 return ocs_described_template;
11473 return isTemplate ? ocs_template : ocs_non_template;
11476 OverloadCandidateKind Kind = [&]() {
11477 if (
Fn->isImplicit() &&
Fn->getOverloadedOperator() == OO_EqualEqual)
11478 return oc_implicit_equality_comparison;
11481 return oc_reversed_binary_operator;
11483 if (
const auto *Ctor = dyn_cast<CXXConstructorDecl>(Fn)) {
11484 if (!Ctor->isImplicit()) {
11485 if (isa<ConstructorUsingShadowDecl>(
Found))
11486 return oc_inherited_constructor;
11488 return oc_constructor;
11491 if (Ctor->isDefaultConstructor())
11492 return oc_implicit_default_constructor;
11494 if (Ctor->isMoveConstructor())
11495 return oc_implicit_move_constructor;
11497 assert(Ctor->isCopyConstructor() &&
11498 "unexpected sort of implicit constructor");
11499 return oc_implicit_copy_constructor;
11502 if (
const auto *Meth = dyn_cast<CXXMethodDecl>(Fn)) {
11505 if (!Meth->isImplicit())
11508 if (Meth->isMoveAssignmentOperator())
11509 return oc_implicit_move_assignment;
11511 if (Meth->isCopyAssignmentOperator())
11512 return oc_implicit_copy_assignment;
11514 assert(isa<CXXConversionDecl>(Meth) &&
"expected conversion");
11518 return oc_function;
11521 return std::make_pair(Kind, Select);
11524void MaybeEmitInheritedConstructorNote(
Sema &S,
const Decl *FoundDecl) {
11527 if (
const auto *Shadow = dyn_cast<ConstructorUsingShadowDecl>(FoundDecl))
11529 diag::note_ovl_candidate_inherited_constructor)
11530 << Shadow->getNominatedBaseClass();
11539 if (EnableIf->getCond()->isValueDependent() ||
11540 !EnableIf->getCond()->EvaluateAsBooleanCondition(AlwaysTrue, Ctx))
11557 bool InOverloadResolution,
11561 if (InOverloadResolution)
11563 diag::note_addrof_ovl_candidate_disabled_by_enable_if_attr);
11565 S.
Diag(
Loc, diag::err_addrof_function_disabled_by_enable_if_attr) << FD;
11576 if (InOverloadResolution) {
11579 TemplateArgString +=
" ";
11581 FunTmpl->getTemplateParameters(),
11586 diag::note_ovl_candidate_unsatisfied_constraints)
11587 << TemplateArgString;
11589 S.
Diag(
Loc, diag::err_addrof_function_constraints_not_satisfied)
11598 return P->hasAttr<PassObjectSizeAttr>();
11605 unsigned ParamNo = std::distance(FD->
param_begin(), I) + 1;
11606 if (InOverloadResolution)
11608 diag::note_ovl_candidate_has_pass_object_size_params)
11611 S.
Diag(
Loc, diag::err_address_of_function_with_pass_object_size_params)
11627 return ::checkAddressOfFunctionIsAvailable(*
this,
Function, Complain,
11635 const auto *ConvD = dyn_cast<CXXConversionDecl>(Fn);
11639 const auto *RD = cast<CXXRecordDecl>(Fn->getParent());
11640 if (!RD->isLambda())
11650 return ConvToCC != CallOpCC;
11656 QualType DestType,
bool TakingAddress) {
11659 if (Fn->isMultiVersion() && Fn->hasAttr<TargetAttr>() &&
11660 !Fn->getAttr<TargetAttr>()->isDefaultVersion())
11662 if (Fn->isMultiVersion() && Fn->hasAttr<TargetVersionAttr>() &&
11663 !Fn->getAttr<TargetVersionAttr>()->isDefaultVersion())
11668 std::string FnDesc;
11669 std::pair<OverloadCandidateKind, OverloadCandidateSelect> KSPair =
11670 ClassifyOverloadCandidate(*
this,
Found, Fn, RewriteKind, FnDesc);
11672 << (
unsigned)KSPair.first << (
unsigned)KSPair.second
11675 HandleFunctionTypeMismatch(PD, Fn->getType(), DestType);
11676 Diag(Fn->getLocation(), PD);
11677 MaybeEmitInheritedConstructorNote(*
this,
Found);
11695 FunctionDecl *FirstCand =
nullptr, *SecondCand =
nullptr;
11696 for (
auto I = Cands.begin(),
E = Cands.end(); I !=
E; ++I) {
11700 if (
auto *
Template = I->Function->getPrimaryTemplate())
11701 Template->getAssociatedConstraints(AC);
11703 I->Function->getAssociatedConstraints(AC);
11706 if (FirstCand ==
nullptr) {
11707 FirstCand = I->Function;
11709 }
else if (SecondCand ==
nullptr) {
11710 SecondCand = I->Function;
11723 SecondCand, SecondAC))
11732 bool TakingAddress) {
11742 dyn_cast<FunctionTemplateDecl>((*I)->getUnderlyingDecl()) ) {
11743 NoteOverloadCandidate(*I, FunTmpl->getTemplatedDecl(),
CRK_None, DestType,
11746 = dyn_cast<FunctionDecl>((*I)->getUnderlyingDecl()) ) {
11747 NoteOverloadCandidate(*I, Fun,
CRK_None, DestType, TakingAddress);
11759 S.
Diag(CaretLoc, PDiag)
11761 unsigned CandsShown = 0;
11775 unsigned I,
bool TakingCandidateAddress) {
11777 assert(Conv.
isBad());
11778 assert(Cand->
Function &&
"for now, candidate must be a function");
11784 bool isObjectArgument =
false;
11785 if (!TakingCandidateAddress && isa<CXXMethodDecl>(Fn) &&
11786 !isa<CXXConstructorDecl>(Fn)) {
11788 isObjectArgument =
true;
11789 else if (!Fn->hasCXXExplicitFunctionObjectParameter())
11793 std::string FnDesc;
11794 std::pair<OverloadCandidateKind, OverloadCandidateSelect> FnKindPair =
11805 bool HasParamPack =
11806 llvm::any_of(Fn->parameters().take_front(I), [](
const ParmVarDecl *Parm) {
11807 return Parm->isParameterPack();
11809 if (!isObjectArgument && !HasParamPack)
11810 ToParamRange = Fn->getParamDecl(I)->getSourceRange();
11813 assert(FromExpr &&
"overload set argument came from implicit argument?");
11815 if (isa<UnaryOperator>(
E))
11819 S.
Diag(Fn->getLocation(), diag::note_ovl_candidate_bad_overload)
11820 << (
unsigned)FnKindPair.first << (
unsigned)FnKindPair.second << FnDesc
11821 << ToParamRange << ToTy << Name << I + 1;
11822 MaybeEmitInheritedConstructorNote(S, Cand->
FoundDecl);
11831 CToTy = RT->getPointeeType();
11836 CFromTy = FromPT->getPointeeType();
11837 CToTy = ToPT->getPointeeType();
11847 if (isObjectArgument)
11848 S.
Diag(Fn->getLocation(), diag::note_ovl_candidate_bad_addrspace_this)
11849 << (
unsigned)FnKindPair.first << (
unsigned)FnKindPair.second
11852 S.
Diag(Fn->getLocation(), diag::note_ovl_candidate_bad_addrspace)
11853 << (
unsigned)FnKindPair.first << (
unsigned)FnKindPair.second
11856 MaybeEmitInheritedConstructorNote(S, Cand->
FoundDecl);
11861 S.
Diag(Fn->getLocation(), diag::note_ovl_candidate_bad_ownership)
11862 << (
unsigned)FnKindPair.first << (
unsigned)FnKindPair.second << FnDesc
11865 MaybeEmitInheritedConstructorNote(S, Cand->
FoundDecl);
11870 S.
Diag(Fn->getLocation(), diag::note_ovl_candidate_bad_gc)
11871 << (
unsigned)FnKindPair.first << (
unsigned)FnKindPair.second << FnDesc
11874 MaybeEmitInheritedConstructorNote(S, Cand->
FoundDecl);
11879 S.
Diag(Fn->getLocation(), diag::note_ovl_candidate_bad_ptrauth)
11880 << (
unsigned)FnKindPair.first << (
unsigned)FnKindPair.second << FnDesc
11885 MaybeEmitInheritedConstructorNote(S, Cand->
FoundDecl);
11890 assert(CVR &&
"expected qualifiers mismatch");
11892 if (isObjectArgument) {
11893 S.
Diag(Fn->getLocation(), diag::note_ovl_candidate_bad_cvr_this)
11894 << (
unsigned)FnKindPair.first << (
unsigned)FnKindPair.second << FnDesc
11895 << FromTy << (CVR - 1);
11897 S.
Diag(Fn->getLocation(), diag::note_ovl_candidate_bad_cvr)
11898 << (
unsigned)FnKindPair.first << (
unsigned)FnKindPair.second << FnDesc
11899 << ToParamRange << FromTy << (CVR - 1) << I + 1;
11901 MaybeEmitInheritedConstructorNote(S, Cand->
FoundDecl);
11907 S.
Diag(Fn->getLocation(), diag::note_ovl_candidate_bad_value_category)
11908 << (
unsigned)FnKindPair.first << (
unsigned)FnKindPair.second << FnDesc
11909 << (
unsigned)isObjectArgument << I + 1
11912 MaybeEmitInheritedConstructorNote(S, Cand->
FoundDecl);
11918 if (FromExpr && isa<InitListExpr>(FromExpr)) {
11919 S.
Diag(Fn->getLocation(), diag::note_ovl_candidate_bad_list_argument)
11920 << (
unsigned)FnKindPair.first << (
unsigned)FnKindPair.second << FnDesc
11921 << ToParamRange << FromTy << ToTy << (
unsigned)isObjectArgument << I + 1
11926 MaybeEmitInheritedConstructorNote(S, Cand->
FoundDecl);
11938 S.
Diag(Fn->getLocation(), diag::note_ovl_candidate_bad_conv_incomplete)
11939 << (
unsigned)FnKindPair.first << (
unsigned)FnKindPair.second << FnDesc
11940 << ToParamRange << FromTy << ToTy << (
unsigned)isObjectArgument << I + 1
11941 << (
unsigned)(Cand->
Fix.
Kind);
11943 MaybeEmitInheritedConstructorNote(S, Cand->
FoundDecl);
11948 unsigned BaseToDerivedConversion = 0;
11951 if (ToPtrTy->getPointeeType().isAtLeastAsQualifiedAs(
11953 !FromPtrTy->getPointeeType()->isIncompleteType() &&
11954 !ToPtrTy->getPointeeType()->isIncompleteType() &&
11956 FromPtrTy->getPointeeType()))
11957 BaseToDerivedConversion = 1;
11965 if (ToPtrTy->getPointeeType().isAtLeastAsQualifiedAs(
11967 FromIface->isSuperClassOf(ToIface))
11968 BaseToDerivedConversion = 2;
11970 if (ToRefTy->getPointeeType().isAtLeastAsQualifiedAs(FromTy,
11973 !ToRefTy->getPointeeType()->isIncompleteType() &&
11975 BaseToDerivedConversion = 3;
11979 if (BaseToDerivedConversion) {
11980 S.
Diag(Fn->getLocation(), diag::note_ovl_candidate_bad_base_to_derived_conv)
11981 << (
unsigned)FnKindPair.first << (
unsigned)FnKindPair.second << FnDesc
11982 << ToParamRange << (BaseToDerivedConversion - 1) << FromTy << ToTy
11984 MaybeEmitInheritedConstructorNote(S, Cand->
FoundDecl);
11988 if (isa<ObjCObjectPointerType>(CFromTy) &&
11989 isa<PointerType>(CToTy)) {
11993 S.
Diag(Fn->getLocation(), diag::note_ovl_candidate_bad_arc_conv)
11994 << (
unsigned)FnKindPair.first << (
unsigned)FnKindPair.second << FnDesc
11995 << ToParamRange << FromTy << ToTy << (
unsigned)isObjectArgument
11997 MaybeEmitInheritedConstructorNote(S, Cand->
FoundDecl);
12007 FDiag << (
unsigned)FnKindPair.first << (
unsigned)FnKindPair.second << FnDesc
12008 << ToParamRange << FromTy << ToTy << (
unsigned)isObjectArgument << I + 1
12009 << (
unsigned)(Cand->
Fix.
Kind);
12018 S.
Diag(Fn->getLocation(), FDiag);
12020 MaybeEmitInheritedConstructorNote(S, Cand->
FoundDecl);
12027 unsigned NumArgs,
bool IsAddressOf =
false) {
12028 assert(Cand->
Function &&
"Candidate is required to be a function.");
12030 unsigned MinParams = Fn->getMinRequiredExplicitArguments() +
12031 ((IsAddressOf && !Fn->isStatic()) ? 1 : 0);
12038 if (Fn->isInvalidDecl() &&
12042 if (NumArgs < MinParams) {
12059 unsigned NumFormalArgs,
12060 bool IsAddressOf =
false) {
12061 assert(isa<FunctionDecl>(
D) &&
12062 "The templated declaration should at least be a function"
12063 " when diagnosing bad template argument deduction due to too many"
12064 " or too few arguments");
12070 unsigned MinParams = Fn->getMinRequiredExplicitArguments() +
12071 ((IsAddressOf && !Fn->isStatic()) ? 1 : 0);
12074 bool HasExplicitObjectParam =
12075 !IsAddressOf && Fn->hasCXXExplicitFunctionObjectParameter();
12077 unsigned ParamCount =
12078 Fn->getNumNonObjectParams() + ((IsAddressOf && !Fn->isStatic()) ? 1 : 0);
12079 unsigned mode, modeCount;
12081 if (NumFormalArgs < MinParams) {
12082 if (MinParams != ParamCount || FnTy->isVariadic() ||
12083 FnTy->isTemplateVariadic())
12087 modeCount = MinParams;
12089 if (MinParams != ParamCount)
12093 modeCount = ParamCount;
12096 std::string Description;
12097 std::pair<OverloadCandidateKind, OverloadCandidateSelect> FnKindPair =
12098 ClassifyOverloadCandidate(S,
Found, Fn,
CRK_None, Description);
12100 if (modeCount == 1 && !IsAddressOf &&
12101 Fn->getParamDecl(HasExplicitObjectParam ? 1 : 0)->getDeclName())
12102 S.
Diag(Fn->getLocation(), diag::note_ovl_candidate_arity_one)
12103 << (
unsigned)FnKindPair.first << (
unsigned)FnKindPair.second
12104 << Description << mode
12105 << Fn->getParamDecl(HasExplicitObjectParam ? 1 : 0) << NumFormalArgs
12106 << HasExplicitObjectParam << Fn->getParametersSourceRange();
12108 S.
Diag(Fn->getLocation(), diag::note_ovl_candidate_arity)
12109 << (
unsigned)FnKindPair.first << (
unsigned)FnKindPair.second
12110 << Description << mode << modeCount << NumFormalArgs
12111 << HasExplicitObjectParam << Fn->getParametersSourceRange();
12113 MaybeEmitInheritedConstructorNote(S,
Found);
12118 unsigned NumFormalArgs) {
12119 assert(Cand->
Function &&
"Candidate must be a function");
12129 llvm_unreachable(
"Unsupported: Getting the described template declaration"
12130 " for bad deduction diagnosis");
12137 bool TakingCandidateAddress) {
12143 switch (DeductionFailure.
getResult()) {
12146 "TemplateDeductionResult::Success while diagnosing bad deduction");
12148 llvm_unreachable(
"TemplateDeductionResult::NonDependentConversionFailure "
12149 "while diagnosing bad deduction");
12155 assert(ParamD &&
"no parameter found for incomplete deduction result");
12157 diag::note_ovl_candidate_incomplete_deduction)
12159 MaybeEmitInheritedConstructorNote(S,
Found);
12164 assert(ParamD &&
"no parameter found for incomplete deduction result");
12166 diag::note_ovl_candidate_incomplete_deduction_pack)
12170 MaybeEmitInheritedConstructorNote(S,
Found);
12175 assert(ParamD &&
"no parameter found for bad qualifiers deduction result");
12193 S.
Diag(Templated->
getLocation(), diag::note_ovl_candidate_underqualified)
12194 << ParamD->
getDeclName() << Arg << NonCanonParam;
12195 MaybeEmitInheritedConstructorNote(S,
Found);
12200 assert(ParamD &&
"no parameter found for inconsistent deduction result");
12202 if (isa<TemplateTypeParmDecl>(ParamD))
12204 else if (isa<NonTypeTemplateParmDecl>(ParamD)) {
12214 diag::note_ovl_candidate_inconsistent_deduction_types)
12217 MaybeEmitInheritedConstructorNote(S,
Found);
12237 diag::note_ovl_candidate_inconsistent_deduction)
12240 MaybeEmitInheritedConstructorNote(S,
Found);
12245 assert(ParamD &&
"no parameter found for invalid explicit arguments");
12248 diag::note_ovl_candidate_explicit_arg_mismatch_named)
12253 index = TTP->getIndex();
12255 = dyn_cast<NonTypeTemplateParmDecl>(ParamD))
12256 index = NTTP->getIndex();
12258 index = cast<TemplateTemplateParmDecl>(ParamD)->getIndex();
12260 diag::note_ovl_candidate_explicit_arg_mismatch_unnamed)
12263 MaybeEmitInheritedConstructorNote(S,
Found);
12270 TemplateArgString =
" ";
12273 if (TemplateArgString.size() == 1)
12274 TemplateArgString.clear();
12276 diag::note_ovl_candidate_unsatisfied_constraints)
12277 << TemplateArgString;
12280 static_cast<CNSInfo*
>(DeductionFailure.
Data)->Satisfaction);
12290 diag::note_ovl_candidate_instantiation_depth);
12291 MaybeEmitInheritedConstructorNote(S,
Found);
12299 TemplateArgString =
" ";
12302 if (TemplateArgString.size() == 1)
12303 TemplateArgString.clear();
12308 if (PDiag && PDiag->second.getDiagID() ==
12309 diag::err_typename_nested_not_found_enable_if) {
12312 S.
Diag(PDiag->first, diag::note_ovl_candidate_disabled_by_enable_if)
12313 <<
"'enable_if'" << TemplateArgString;
12318 if (PDiag && PDiag->second.getDiagID() ==
12319 diag::err_typename_nested_not_found_requirement) {
12321 diag::note_ovl_candidate_disabled_by_requirement)
12322 << PDiag->second.getStringArg(0) << TemplateArgString;
12332 SFINAEArgString =
": ";
12334 PDiag->second.EmitToString(S.
getDiagnostics(), SFINAEArgString);
12338 diag::note_ovl_candidate_substitution_failure)
12339 << TemplateArgString << SFINAEArgString << R;
12340 MaybeEmitInheritedConstructorNote(S,
Found);
12350 TemplateArgString =
" ";
12353 if (TemplateArgString.size() == 1)
12354 TemplateArgString.clear();
12357 S.
Diag(Templated->
getLocation(), diag::note_ovl_candidate_deduced_mismatch)
12360 << TemplateArgString
12385 diag::note_ovl_candidate_non_deduced_mismatch_qualified)
12392 if (TakingCandidateAddress && isa<FunctionDecl>(Templated) &&
12401 diag::note_ovl_candidate_non_deduced_mismatch)
12402 << FirstTA << SecondTA;
12408 S.
Diag(Templated->
getLocation(), diag::note_ovl_candidate_bad_deduction);
12409 MaybeEmitInheritedConstructorNote(S,
Found);
12413 diag::note_cuda_ovl_candidate_target_mismatch);
12421 bool TakingCandidateAddress) {
12422 assert(Cand->
Function &&
"Candidate must be a function");
12437 assert(Cand->
Function &&
"Candidate must be a Function.");
12443 std::string FnDesc;
12444 std::pair<OverloadCandidateKind, OverloadCandidateSelect> FnKindPair =
12445 ClassifyOverloadCandidate(S, Cand->
FoundDecl, Callee,
12448 S.
Diag(Callee->getLocation(), diag::note_ovl_candidate_bad_target)
12449 << (
unsigned)FnKindPair.first << (
unsigned)ocs_non_template
12451 << CalleeTarget << CallerTarget;
12456 if (Meth !=
nullptr && Meth->
isImplicit()) {
12460 switch (FnKindPair.first) {
12463 case oc_implicit_default_constructor:
12466 case oc_implicit_copy_constructor:
12469 case oc_implicit_move_constructor:
12472 case oc_implicit_copy_assignment:
12475 case oc_implicit_move_assignment:
12480 bool ConstRHS =
false;
12484 ConstRHS = RT->getPointeeType().isConstQualified();
12495 assert(Cand->
Function &&
"Candidate must be a function");
12499 S.
Diag(Callee->getLocation(),
12500 diag::note_ovl_candidate_disabled_by_function_cond_attr)
12501 <<
Attr->getCond()->getSourceRange() <<
Attr->getMessage();
12505 assert(Cand->
Function &&
"Candidate must be a function");
12508 assert(ES.
isExplicit() &&
"not an explicit candidate");
12511 switch (Fn->getDeclKind()) {
12512 case Decl::Kind::CXXConstructor:
12515 case Decl::Kind::CXXConversion:
12518 case Decl::Kind::CXXDeductionGuide:
12519 Kind = Fn->isImplicit() ? 0 : 2;
12522 llvm_unreachable(
"invalid Decl");
12531 First = Pattern->getFirstDecl();
12534 diag::note_ovl_candidate_explicit)
12535 << Kind << (ES.
getExpr() ? 1 : 0)
12540 auto *DG = dyn_cast<CXXDeductionGuideDecl>(Fn);
12547 if (!(DG->isImplicit() || (OriginTemplate && OriginTemplate->
isTypeAlias())))
12549 std::string FunctionProto;
12550 llvm::raw_string_ostream OS(FunctionProto);
12563 "Non-template implicit deduction guides are only possible for "
12566 S.
Diag(DG->getLocation(), diag::note_implicit_deduction_guide)
12571 assert(
Template &&
"Cannot find the associated function template of "
12572 "CXXDeductionGuideDecl?");
12575 S.
Diag(DG->getLocation(), diag::note_implicit_deduction_guide)
12596 bool TakingCandidateAddress,
12598 assert(Cand->
Function &&
"Candidate must be a function");
12606 if (S.
getLangOpts().OpenCL && Fn->isImplicit() &&
12613 !Fn->hasCXXExplicitFunctionObjectParameter() && !Fn->isStatic())
12618 if (Fn->isDeleted()) {
12619 std::string FnDesc;
12620 std::pair<OverloadCandidateKind, OverloadCandidateSelect> FnKindPair =
12621 ClassifyOverloadCandidate(S, Cand->
FoundDecl, Fn,
12624 S.
Diag(Fn->getLocation(), diag::note_ovl_candidate_deleted)
12625 << (
unsigned)FnKindPair.first << (
unsigned)FnKindPair.second << FnDesc
12626 << (Fn->isDeleted() ? (Fn->isDeletedAsWritten() ? 1 : 2) : 0);
12627 MaybeEmitInheritedConstructorNote(S, Cand->
FoundDecl);
12654 TakingCandidateAddress);
12657 S.
Diag(Fn->getLocation(), diag::note_ovl_candidate_illegal_constructor)
12658 << (Fn->getPrimaryTemplate() ? 1 : 0);
12659 MaybeEmitInheritedConstructorNote(S, Cand->
FoundDecl);
12666 S.
Diag(Fn->getLocation(),
12667 diag::note_ovl_candidate_illegal_constructor_adrspace_mismatch)
12668 << QualsForPrinting;
12669 MaybeEmitInheritedConstructorNote(S, Cand->
FoundDecl);
12680 for (
unsigned N = Cand->
Conversions.size(); I != N; ++I)
12701 if (cast<CXXConstructorDecl>(Fn)->isCopyOrMoveConstructor())
12703 S.
Diag(Fn->getLocation(),
12704 diag::note_ovl_candidate_inherited_constructor_slice)
12705 << (Fn->getPrimaryTemplate() ? 1 : 0)
12706 << Fn->getParamDecl(0)->getType()->isRValueReferenceType();
12707 MaybeEmitInheritedConstructorNote(S, Cand->
FoundDecl);
12713 assert(!Available);
12721 std::string FnDesc;
12722 std::pair<OverloadCandidateKind, OverloadCandidateSelect> FnKindPair =
12723 ClassifyOverloadCandidate(S, Cand->
FoundDecl, Fn,
12726 S.
Diag(Fn->getLocation(),
12727 diag::note_ovl_candidate_constraints_not_satisfied)
12728 << (
unsigned)FnKindPair.first << (
unsigned)ocs_non_template
12746 bool isLValueReference =
false;
12747 bool isRValueReference =
false;
12748 bool isPointer =
false;
12752 isLValueReference =
true;
12756 isRValueReference =
true;
12772 diag::note_ovl_surrogate_constraints_not_satisfied)
12786 assert(Cand->
Conversions.size() <= 2 &&
"builtin operator is not binary");
12787 std::string TypeStr(
"operator");
12793 S.
Diag(OpLoc, diag::note_ovl_builtin_candidate) << TypeStr;
12798 S.
Diag(OpLoc, diag::note_ovl_builtin_candidate) << TypeStr;
12805 if (ICS.
isBad())
break;
12809 S, OpLoc, S.
PDiag(diag::note_ambiguous_type_conversion));
12826 llvm_unreachable(
"non-deduction failure while diagnosing bad deduction");
12856 llvm_unreachable(
"Unhandled deduction result");
12861struct CompareOverloadCandidatesForDisplay {
12867 CompareOverloadCandidatesForDisplay(
12870 : S(S), NumArgs(NArgs), CSK(CSK) {}
12880 if (NumArgs >
C->Function->getNumParams() && !
C->Function->isVariadic())
12882 if (NumArgs < C->
Function->getMinRequiredArguments())
12892 if (L == R)
return false;
12896 if (!R->
Viable)
return true;
12898 if (
int Ord = CompareConversions(*L, *R))
12918 if (LDist == RDist) {
12919 if (LFailureKind == RFailureKind)
12927 return LDist < RDist;
12945 numLFixes = (numLFixes == 0) ?
UINT_MAX : numLFixes;
12946 numRFixes = (numRFixes == 0) ?
UINT_MAX : numRFixes;
12947 if (numLFixes != numRFixes) {
12948 return numLFixes < numRFixes;
12952 if (
int Ord = CompareConversions(*L, *R))
12964 if (LRank != RRank)
12965 return LRank < RRank;
12991 struct ConversionSignals {
12992 unsigned KindRank = 0;
12996 ConversionSignals Sig;
12997 Sig.KindRank =
Seq.getKindRank();
12998 if (
Seq.isStandard())
12999 Sig.Rank =
Seq.Standard.getRank();
13000 else if (
Seq.isUserDefined())
13001 Sig.Rank =
Seq.UserDefined.After.getRank();
13007 static ConversionSignals ForObjectArgument() {
13023 for (
unsigned I = 0, N = L.
Conversions.size(); I != N; ++I) {
13025 ? ConversionSignals::ForObjectArgument()
13026 : ConversionSignals::ForSequence(L.Conversions[I]);
13028 ? ConversionSignals::ForObjectArgument()
13029 : ConversionSignals::ForSequence(R.Conversions[I]);
13030 if (std::tie(LS.KindRank, LS.Rank) != std::tie(RS.KindRank, RS.Rank))
13031 return std::tie(LS.KindRank, LS.Rank) < std::tie(RS.KindRank, RS.Rank)
13056 bool Unfixable =
false;
13062 for (
unsigned ConvIdx =
13066 assert(ConvIdx != ConvCount &&
"no bad conversion in candidate");
13067 if (Cand->
Conversions[ConvIdx].isInitialized() &&
13076 bool SuppressUserConversions =
false;
13078 unsigned ConvIdx = 0;
13079 unsigned ArgIdx = 0;
13094 if (isa<CXXMethodDecl>(Cand->
Function) &&
13108 assert(ConvCount <= 3);
13114 ConvIdx != ConvCount && ArgIdx < Args.size();
13116 if (Cand->
Conversions[ConvIdx].isInitialized()) {
13118 }
else if (
ParamIdx < ParamTypes.size()) {
13119 if (ParamTypes[
ParamIdx]->isDependentType())
13120 Cand->
Conversions[ConvIdx].setAsIdentityConversion(
13121 Args[ArgIdx]->getType());
13125 SuppressUserConversions,
13130 if (!Unfixable && Cand->
Conversions[ConvIdx].isBad())
13149 for (
iterator Cand = Candidates.begin(), LastCand = Candidates.end();
13150 Cand != LastCand; ++Cand) {
13151 if (!Filter(*Cand))
13176 Cands.push_back(Cand);
13180 Cands, CompareOverloadCandidatesForDisplay(S, OpLoc, Args.size(), Kind));
13187 bool DeferHint =
false;
13191 auto WrongSidedCands =
13193 return (Cand.
Viable ==
false &&
13196 Cand.
Function->template hasAttr<CUDAHostAttr>() &&
13197 Cand.
Function->template hasAttr<CUDADeviceAttr>());
13199 DeferHint = !WrongSidedCands.empty();
13217 bool NoteCands =
true;
13218 for (
const Expr *Arg : Args) {
13219 if (Arg->getType()->isWebAssemblyTableType())
13228 {Candidates.begin(), Candidates.end()});
13234 bool ReportedAmbiguousConversions =
false;
13237 unsigned CandsShown = 0;
13238 auto I = Cands.begin(),
E = Cands.end();
13239 for (; I !=
E; ++I) {
13255 "Non-viable built-in candidates are not added to Cands.");
13262 if (!ReportedAmbiguousConversions) {
13264 ReportedAmbiguousConversions =
true;
13277 S.
Diag(OpLoc, diag::note_ovl_too_many_candidates,
13289struct CompareTemplateSpecCandidatesForDisplay {
13291 CompareTemplateSpecCandidatesForDisplay(
Sema &S) : S(S) {}
13325 bool ForTakingAddress) {
13327 DeductionFailure, 0, ForTakingAddress);
13330void TemplateSpecCandidateSet::destroyCandidates() {
13332 i->DeductionFailure.Destroy();
13337 destroyCandidates();
13338 Candidates.clear();
13351 Cands.reserve(
size());
13352 for (
iterator Cand =
begin(), LastCand =
end(); Cand != LastCand; ++Cand) {
13353 if (Cand->Specialization)
13354 Cands.push_back(Cand);
13359 llvm::sort(Cands, CompareTemplateSpecCandidatesForDisplay(S));
13366 unsigned CandsShown = 0;
13367 for (I = Cands.begin(),
E = Cands.end(); I !=
E; ++I) {
13373 if (CandsShown >= 4 && ShowOverloads ==
Ovl_Best)
13378 "Non-matching built-in candidates are not added to Cands.");
13383 S.
Diag(
Loc, diag::note_ovl_too_many_candidates) <<
int(
E - I);
13393 QualType Ret = PossiblyAFunctionType;
13396 Ret = ToTypePtr->getPointeeType();
13399 Ret = ToTypeRef->getPointeeType();
13402 Ret = MemTypePtr->getPointeeType();
13409 bool Complain =
true) {
13426class AddressOfFunctionResolver {
13436 bool TargetTypeIsNonStaticMemberFunction;
13437 bool FoundNonTemplateFunction;
13438 bool StaticMemberFunctionFromBoundPointer;
13439 bool HasComplained;
13448 AddressOfFunctionResolver(
Sema &S,
Expr *SourceExpr,
13449 const QualType &TargetType,
bool Complain)
13450 : S(S), SourceExpr(SourceExpr), TargetType(TargetType),
13451 Complain(Complain), Context(S.getASTContext()),
13452 TargetTypeIsNonStaticMemberFunction(
13454 FoundNonTemplateFunction(
false),
13455 StaticMemberFunctionFromBoundPointer(
false),
13456 HasComplained(
false),
13459 FailedCandidates(OvlExpr->getNameLoc(),
true) {
13460 ExtractUnqualifiedFunctionTypeFromTargetType();
13464 if (!UME->isImplicitAccess() &&
13466 StaticMemberFunctionFromBoundPointer =
true;
13470 OvlExpr,
false, &dap)) {
13472 if (!
Method->isStatic()) {
13476 TargetTypeIsNonStaticMemberFunction =
true;
13484 Matches.push_back(std::make_pair(dap, Fn));
13492 if (FindAllFunctionsThatMatchTargetTypeExactly()) {
13495 if (Matches.size() > 1 && !eliminiateSuboptimalOverloadCandidates()) {
13496 if (FoundNonTemplateFunction) {
13497 EliminateAllTemplateMatches();
13498 EliminateLessPartialOrderingConstrainedMatches();
13500 EliminateAllExceptMostSpecializedTemplate();
13505 EliminateSuboptimalCudaMatches();
13508 bool hasComplained()
const {
return HasComplained; }
13511 bool candidateHasExactlyCorrectType(
const FunctionDecl *FD) {
13522 return candidateHasExactlyCorrectType(A) &&
13523 (!candidateHasExactlyCorrectType(B) ||
13529 bool eliminiateSuboptimalOverloadCandidates() {
13532 auto Best = Matches.begin();
13533 for (
auto I = Matches.begin()+1,
E = Matches.end(); I !=
E; ++I)
13534 if (isBetterCandidate(I->second, Best->second))
13538 auto IsBestOrInferiorToBest = [
this, BestFn](
13539 const std::pair<DeclAccessPair, FunctionDecl *> &Pair) {
13540 return BestFn == Pair.second || isBetterCandidate(BestFn, Pair.second);
13545 if (!llvm::all_of(Matches, IsBestOrInferiorToBest))
13547 Matches[0] = *Best;
13552 bool isTargetTypeAFunction()
const {
13561 void inline ExtractUnqualifiedFunctionTypeFromTargetType() {
13572 bool CanConvertToFunctionPointer =
13573 Method->isStatic() ||
Method->isExplicitObjectMemberFunction();
13574 if (CanConvertToFunctionPointer == TargetTypeIsNonStaticMemberFunction)
13577 else if (TargetTypeIsNonStaticMemberFunction)
13591 Result != TemplateDeductionResult::Success) {
13609 Matches.push_back(std::make_pair(CurAccessFunPair,
Specialization));
13613 bool AddMatchingNonTemplateFunction(
NamedDecl* Fn,
13618 bool CanConvertToFunctionPointer =
13619 Method->isStatic() ||
Method->isExplicitObjectMemberFunction();
13620 if (CanConvertToFunctionPointer == TargetTypeIsNonStaticMemberFunction)
13623 else if (TargetTypeIsNonStaticMemberFunction)
13626 if (
FunctionDecl *FunDecl = dyn_cast<FunctionDecl>(Fn)) {
13633 if (FunDecl->isMultiVersion()) {
13634 const auto *TA = FunDecl->
getAttr<TargetAttr>();
13635 if (TA && !TA->isDefaultVersion())
13637 const auto *TVA = FunDecl->getAttr<TargetVersionAttr>();
13638 if (TVA && !TVA->isDefaultVersion())
13646 HasComplained |= Complain;
13655 candidateHasExactlyCorrectType(FunDecl)) {
13656 Matches.push_back(std::make_pair(
13657 CurAccessFunPair, cast<FunctionDecl>(FunDecl->getCanonicalDecl())));
13658 FoundNonTemplateFunction =
true;
13666 bool FindAllFunctionsThatMatchTargetTypeExactly() {
13671 if (IsInvalidFormOfPointerToMemberFunction())
13687 = dyn_cast<FunctionTemplateDecl>(Fn)) {
13693 AddMatchingNonTemplateFunction(Fn, I.getPair()))
13696 assert(Ret || Matches.empty());
13700 void EliminateAllExceptMostSpecializedTemplate() {
13713 for (
unsigned I = 0,
E = Matches.size(); I !=
E; ++I)
13714 MatchesCopy.
addDecl(Matches[I].second, Matches[I].first.getAccess());
13719 MatchesCopy.
begin(), MatchesCopy.
end(), FailedCandidates,
13721 S.
PDiag(diag::err_addr_ovl_ambiguous)
13722 << Matches[0].second->getDeclName(),
13723 S.
PDiag(diag::note_ovl_candidate)
13724 << (
unsigned)oc_function << (
unsigned)ocs_described_template,
13725 Complain, TargetFunctionType);
13727 if (Result != MatchesCopy.
end()) {
13729 Matches[0].first = Matches[Result - MatchesCopy.
begin()].first;
13730 Matches[0].second = cast<FunctionDecl>(*Result);
13733 HasComplained |= Complain;
13736 void EliminateAllTemplateMatches() {
13739 for (
unsigned I = 0, N = Matches.size(); I != N; ) {
13740 if (Matches[I].second->getPrimaryTemplate() ==
nullptr)
13743 Matches[I] = Matches[--N];
13749 void EliminateLessPartialOrderingConstrainedMatches() {
13754 assert(Matches[0].second->getPrimaryTemplate() ==
nullptr &&
13755 "Call EliminateAllTemplateMatches() first");
13757 Results.push_back(Matches[0]);
13758 for (
unsigned I = 1, N = Matches.size(); I < N; ++I) {
13759 assert(Matches[I].second->getPrimaryTemplate() ==
nullptr);
13761 S, Matches[I].second, Results[0].second,
13765 Results.push_back(Matches[I]);
13768 if (F == Matches[I].second) {
13770 Results.push_back(Matches[I]);
13773 std::swap(Matches, Results);
13776 void EliminateSuboptimalCudaMatches() {
13782 void ComplainNoMatchesFound()
const {
13783 assert(Matches.empty());
13785 << OvlExpr->
getName() << TargetFunctionType
13787 if (FailedCandidates.
empty())
13798 dyn_cast<FunctionDecl>((*I)->getUnderlyingDecl()))
13806 bool IsInvalidFormOfPointerToMemberFunction()
const {
13807 return TargetTypeIsNonStaticMemberFunction &&
13811 void ComplainIsInvalidFormOfPointerToMemberFunction()
const {
13819 bool IsStaticMemberFunctionFromBoundPointer()
const {
13820 return StaticMemberFunctionFromBoundPointer;
13823 void ComplainIsStaticMemberFunctionFromBoundPointer()
const {
13825 diag::err_invalid_form_pointer_member_function)
13829 void ComplainOfInvalidConversion()
const {
13831 << OvlExpr->
getName() << TargetType;
13834 void ComplainMultipleMatchesFound()
const {
13835 assert(Matches.size() > 1);
13842 bool hadMultipleCandidates()
const {
return (OvlExpr->
getNumDecls() > 1); }
13844 int getNumMatches()
const {
return Matches.size(); }
13847 if (Matches.size() != 1)
return nullptr;
13848 return Matches[0].second;
13852 if (Matches.size() != 1)
return nullptr;
13853 return &Matches[0].first;
13863 bool *pHadMultipleCandidates) {
13866 AddressOfFunctionResolver Resolver(*
this, AddressOfExpr, TargetType,
13868 int NumMatches = Resolver.getNumMatches();
13870 bool ShouldComplain = Complain && !Resolver.hasComplained();
13871 if (NumMatches == 0 && ShouldComplain) {
13872 if (Resolver.IsInvalidFormOfPointerToMemberFunction())
13873 Resolver.ComplainIsInvalidFormOfPointerToMemberFunction();
13875 Resolver.ComplainNoMatchesFound();
13877 else if (NumMatches > 1 && ShouldComplain)
13878 Resolver.ComplainMultipleMatchesFound();
13879 else if (NumMatches == 1) {
13880 Fn = Resolver.getMatchingFunctionDecl();
13883 ResolveExceptionSpec(AddressOfExpr->
getExprLoc(), FPT);
13884 FoundResult = *Resolver.getMatchingFunctionAccessPair();
13886 if (Resolver.IsStaticMemberFunctionFromBoundPointer())
13887 Resolver.ComplainIsStaticMemberFunctionFromBoundPointer();
13889 CheckAddressOfMemberAccess(AddressOfExpr, FoundResult);
13893 if (pHadMultipleCandidates)
13894 *pHadMultipleCandidates = Resolver.hadMultipleCandidates();
13902 bool IsResultAmbiguous =
false;
13910 return static_cast<int>(
CUDA().IdentifyPreference(Caller, FD1)) -
13911 static_cast<int>(
CUDA().IdentifyPreference(Caller, FD2));
13918 auto *FD = dyn_cast<FunctionDecl>(I->getUnderlyingDecl());
13926 auto FoundBetter = [&]() {
13927 IsResultAmbiguous =
false;
13938 if (getLangOpts().CUDA) {
13939 int PreferenceByCUDA = CheckCUDAPreference(FD,
Result);
13941 if (PreferenceByCUDA != 0) {
13943 if (PreferenceByCUDA > 0)
13959 if (MoreConstrained != FD) {
13960 if (!MoreConstrained) {
13961 IsResultAmbiguous =
true;
13962 AmbiguousDecls.push_back(FD);
13971 if (IsResultAmbiguous)
13981 if (getLangOpts().
CUDA && CheckCUDAPreference(Skipped,
Result) != 0)
13983 if (!getMoreConstrainedFunction(Skipped,
Result))
13992 ExprResult &SrcExpr,
bool DoFunctionPointerConversion) {
13998 if (!
Found ||
Found->isCPUDispatchMultiVersion() ||
13999 Found->isCPUSpecificMultiVersion())
14006 CheckAddressOfMemberAccess(
E, DAP);
14012 SrcExpr = DefaultFunctionArrayConversion(Fixed,
false);
14047 dyn_cast<FunctionTemplateDecl>((*I)->getUnderlyingDecl());
14078 if (ForTypeDeduction &&
14079 isSameOrCompatibleFunctionType(Matched->
getType(),
14086 NoteAllOverloadCandidates(ovl);
14092 if (FoundResult) *FoundResult = I.getPair();
14103 ExprResult &SrcExpr,
bool doFunctionPointerConversion,
bool complain,
14105 unsigned DiagIDForComplaining) {
14112 if (
FunctionDecl *fn = ResolveSingleFunctionTemplateSpecialization(
14124 isa<CXXMethodDecl>(fn) &&
14125 cast<CXXMethodDecl>(fn)->isInstance()) {
14126 if (!complain)
return false;
14129 diag::err_bound_member_function)
14142 SingleFunctionExpression =
14143 FixOverloadedFunctionReference(SrcExpr.
get(), found, fn);
14146 if (doFunctionPointerConversion) {
14147 SingleFunctionExpression =
14148 DefaultFunctionArrayLvalueConversion(SingleFunctionExpression.
get());
14149 if (SingleFunctionExpression.
isInvalid()) {
14156 if (!SingleFunctionExpression.
isUsable()) {
14158 Diag(OpRangeForComplaining.
getBegin(), DiagIDForComplaining)
14160 << DestTypeForComplaining
14161 << OpRangeForComplaining
14163 NoteAllOverloadCandidates(SrcExpr.
get());
14172 SrcExpr = SingleFunctionExpression;
14182 bool PartialOverloading,
14184 NamedDecl *Callee = FoundDecl.getDecl();
14185 if (isa<UsingShadowDecl>(Callee))
14186 Callee = cast<UsingShadowDecl>(Callee)->getTargetDecl();
14189 if (ExplicitTemplateArgs) {
14190 assert(!KnownValid &&
"Explicit template arguments?");
14199 PartialOverloading);
14204 = dyn_cast<FunctionTemplateDecl>(Callee)) {
14206 ExplicitTemplateArgs, Args, CandidateSet,
14208 PartialOverloading);
14212 assert(!KnownValid &&
"unhandled case in overloaded call candidate");
14218 bool PartialOverloading) {
14241 assert(!(*I)->getDeclContext()->isRecord());
14242 assert(isa<UsingShadowDecl>(*I) ||
14243 !(*I)->getDeclContext()->isFunctionOrMethod());
14244 assert((*I)->getUnderlyingDecl()->isFunctionOrFunctionTemplate());
14254 ExplicitTemplateArgs = &TABuffer;
14260 CandidateSet, PartialOverloading,
14265 Args, ExplicitTemplateArgs,
14266 CandidateSet, PartialOverloading);
14274 CandidateSet,
false,
false);
14280 switch (Name.getCXXOverloadedOperator()) {
14281 case OO_New:
case OO_Array_New:
14282 case OO_Delete:
case OO_Array_Delete:
14305 if (DC->isTransparentContext())
14321 if (
auto *RD = dyn_cast<CXXRecordDecl>(DC)) {
14326 if (FoundInClass) {
14327 *FoundInClass = RD;
14330 R.
addDecl(Best->FoundDecl.getDecl(), Best->FoundDecl.getAccess());
14347 AssociatedNamespaces,
14348 AssociatedClasses);
14352 for (Sema::AssociatedNamespaceSet::iterator
14353 it = AssociatedNamespaces.begin(),
14354 end = AssociatedNamespaces.end(); it !=
end; ++it) {
14356 if (
Std &&
Std->Encloses(*it))
14366 SuggestedNamespaces.insert(*it);
14370 SemaRef.
Diag(R.
getNameLoc(), diag::err_not_found_by_two_phase_lookup)
14372 if (SuggestedNamespaces.empty()) {
14373 SemaRef.
Diag(Best->Function->getLocation(),
14374 diag::note_not_found_by_two_phase_lookup)
14376 }
else if (SuggestedNamespaces.size() == 1) {
14377 SemaRef.
Diag(Best->Function->getLocation(),
14378 diag::note_not_found_by_two_phase_lookup)
14384 SemaRef.
Diag(Best->Function->getLocation(),
14385 diag::note_not_found_by_two_phase_lookup)
14417class BuildRecoveryCallExprRAII {
14422 BuildRecoveryCallExprRAII(
Sema &S) : SemaRef(S), SatStack(S) {
14444 bool EmptyLookup,
bool AllowTypoCorrection) {
14452 BuildRecoveryCallExprRAII RCE(SemaRef);
14462 ExplicitTemplateArgs = &TABuffer;
14470 ExplicitTemplateArgs, Args, &FoundInClass)) {
14472 }
else if (EmptyLookup) {
14477 ExplicitTemplateArgs !=
nullptr,
14478 dyn_cast<MemberExpr>(Fn));
14480 AllowTypoCorrection
14486 }
else if (FoundInClass && SemaRef.
getLangOpts().MSVCCompat) {
14501 assert(!R.
empty() &&
"lookup results empty despite recovery");
14512 if ((*R.
begin())->isCXXClassMember())
14514 ExplicitTemplateArgs, S);
14515 else if (ExplicitTemplateArgs || TemplateKWLoc.
isValid())
14517 ExplicitTemplateArgs);
14541 assert(!ULE->
getQualifier() &&
"qualified name with ADL");
14548 (F = dyn_cast<FunctionDecl>(*ULE->
decls_begin())) &&
14550 llvm_unreachable(
"performing ADL for builtin");
14553 assert(getLangOpts().
CPlusPlus &&
"ADL enabled in C");
14557 UnbridgedCastsSet UnbridgedCasts;
14565 AddOverloadedCallCandidates(ULE, Args, *CandidateSet);
14567 if (getLangOpts().MSVCCompat &&
14568 CurContext->isDependentContext() && !isSFINAEContext() &&
14569 (isa<FunctionDecl>(CurContext) || isa<CXXRecordDecl>(CurContext))) {
14572 if (CandidateSet->
empty() ||
14581 RParenLoc, CurFPFeatureOverrides());
14588 if (CandidateSet->
empty())
14591 UnbridgedCasts.restore();
14598 std::optional<QualType>
Result;
14618 if (Best && *Best != CS.
end())
14619 ConsiderCandidate(**Best);
14622 for (
const auto &
C : CS)
14624 ConsiderCandidate(
C);
14627 for (
const auto &
C : CS)
14628 ConsiderCandidate(
C);
14633 if (
Value.isNull() ||
Value->isUndeducedType())
14650 bool AllowTypoCorrection) {
14651 switch (OverloadResult) {
14662 Res.
get(), FDecl, LParenLoc, Args, RParenLoc, ExecConfig,
14668 if (*Best != CandidateSet->
end() &&
14672 dyn_cast_if_present<CXXMethodDecl>((*Best)->Function);
14677 SemaRef.
PDiag(diag::err_member_call_without_object) << 0 << M),
14687 CandidateSet->
empty(),
14688 AllowTypoCorrection);
14695 for (
const Expr *Arg : Args) {
14696 if (!Arg->getType()->isFunctionType())
14698 if (
auto *DRE = dyn_cast<DeclRefExpr>(Arg->IgnoreParenImpCasts())) {
14699 auto *FD = dyn_cast<FunctionDecl>(DRE->getDecl());
14702 Arg->getExprLoc()))
14710 SemaRef.
PDiag(diag::err_ovl_no_viable_function_in_call)
14711 << ULE->
getName() << Fn->getSourceRange()),
14719 SemaRef.
PDiag(diag::err_ovl_ambiguous_call)
14720 << ULE->
getName() << Fn->getSourceRange()),
14727 Fn->getSourceRange(), ULE->
getName(),
14728 *CandidateSet, FDecl, Args);
14737 Res.
get(), FDecl, LParenLoc, Args, RParenLoc, ExecConfig,
14745 SubExprs.append(Args.begin(), Args.end());
14752 for (
auto I = CS.
begin(),
E = CS.
end(); I !=
E; ++I) {
14767 bool AllowTypoCorrection,
14768 bool CalleesAddressIsTaken) {
14777 if (buildOverloadedCallSet(S, Fn, ULE, Args, LParenLoc, &CandidateSet,
14783 if (CalleesAddressIsTaken)
14794 Best != CandidateSet.
end()) {
14795 if (
auto *M = dyn_cast_or_null<CXXMethodDecl>(Best->Function);
14796 M && M->isImplicitObjectMemberFunction()) {
14807 CUDA().recordPotentialODRUsedVariable(Args, CandidateSet);
14825 if (
const auto *TP =
14827 TP && TP->
willHaveBody() && CurContext->isDependentContext()) {
14829 VK_PRValue, RParenLoc, CurFPFeatureOverrides());
14835 ExecConfig, &CandidateSet, &Best,
14836 OverloadResult, AllowTypoCorrection);
14845 Context, NamingClass, NNSLoc, DNI, PerformADL, Fns.
begin(), Fns.
end(),
14851 bool HadMultipleCandidates) {
14856 if (FoundDecl->getUnderlyingDecl() == FoundDecl)
14861 if (
Method->isExplicitObjectMemberFunction())
14862 Exp = InitializeExplicitObjectArgument(*
this,
E,
Method);
14864 Exp = PerformImplicitObjectArgumentInitialization(
14865 E, std::nullopt, FoundDecl,
Method);
14869 if (
Method->getParent()->isLambda() &&
14870 Method->getConversionType()->isBlockPointerType()) {
14874 auto *CE = dyn_cast<CastExpr>(SubE);
14875 if (CE && CE->getCastKind() == CK_NoOp)
14876 SubE = CE->getSubExpr();
14878 if (
auto *BE = dyn_cast<CXXBindTemporaryExpr>(SubE))
14879 SubE = BE->getSubExpr();
14880 if (isa<LambdaExpr>(SubE)) {
14886 PushExpressionEvaluationContext(
14887 ExpressionEvaluationContext::PotentiallyEvaluated);
14888 ExprResult BlockExp = BuildBlockForLambdaConversion(
14890 PopExpressionEvaluationContext();
14902 if (
Method->isExplicitObjectMemberFunction()) {
14908 Expr *ObjectParam = Exp.
get();
14911 CurFPFeatureOverrides());
14922 Exp.
get()->getEndLoc(),
14923 CurFPFeatureOverrides());
14926 if (CheckFunctionCall(
Method, CE,
14936 Expr *Input,
bool PerformADL) {
14938 assert(Op !=
OO_None &&
"Invalid opcode for overloaded unary operator");
14946 Expr *Args[2] = { Input,
nullptr };
14947 unsigned NumArgs = 1;
14952 if (Opc == UO_PostInc || Opc == UO_PostDec) {
14966 if (Opc == UO_PreDec || Opc == UO_PreInc || Opc == UO_Deref)
14972 CurFPFeatureOverrides());
14977 if (Fn.isInvalid())
14981 CurFPFeatureOverrides());
14988 AddNonMemberOperatorCandidates(Fns, ArgsArray, CandidateSet);
14991 AddMemberOperatorCandidates(Op, OpLoc, ArgsArray, CandidateSet);
14995 AddArgumentDependentLookupCandidates(OpName, OpLoc, ArgsArray,
15001 AddBuiltinOperatorCandidates(Op, OpLoc, ArgsArray, CandidateSet);
15003 bool HadMultipleCandidates = (CandidateSet.
size() > 1);
15019 CheckMemberOperatorAccess(OpLoc, Input,
nullptr, Best->FoundDecl);
15022 if (
Method->isExplicitObjectMemberFunction())
15023 InputInit = InitializeExplicitObjectArgument(*
this, Input,
Method);
15025 InputInit = PerformImplicitObjectArgumentInitialization(
15026 Input, std::nullopt, Best->FoundDecl,
Method);
15029 Base = Input = InputInit.
get();
15040 Input = InputInit.
get();
15045 Base, HadMultipleCandidates,
15057 Context, Op, FnExpr.
get(), ArgsArray, ResultTy,
VK, OpLoc,
15058 CurFPFeatureOverrides(),
15061 if (CheckCallReturnType(FnDecl->
getReturnType(), OpLoc, TheCall, FnDecl))
15064 if (CheckFunctionCall(FnDecl, TheCall,
15067 return CheckForImmediateInvocation(MaybeBindToTemporary(TheCall), FnDecl);
15072 ExprResult InputRes = PerformImplicitConversion(
15073 Input, Best->BuiltinParamTypes[0], Best->Conversions[0],
15078 Input = InputRes.
get();
15098 PDiag(diag::err_ovl_ambiguous_oper_unary)
15115 << (Msg !=
nullptr)
15116 << (Msg ? Msg->
getString() : StringRef())
15127 return CreateBuiltinUnaryOp(OpLoc, Opc, Input);
15143 AddNonMemberOperatorCandidates(Fns, Args, CandidateSet);
15153 AddMemberOperatorCandidates(Op, OpLoc, Args, CandidateSet);
15155 AddMemberOperatorCandidates(Op, OpLoc, ReversedArgs, CandidateSet,
15160 AddMemberOperatorCandidates(ExtraOp, OpLoc, Args, CandidateSet);
15162 AddMemberOperatorCandidates(ExtraOp, OpLoc, ReversedArgs, CandidateSet,
15169 if (Op != OO_Equal && PerformADL) {
15171 AddArgumentDependentLookupCandidates(OpName, OpLoc, Args,
15177 AddArgumentDependentLookupCandidates(ExtraOpName, OpLoc, Args,
15196 AddBuiltinOperatorCandidates(Op, OpLoc, Args, CandidateSet);
15202 Expr *RHS,
bool PerformADL,
15203 bool AllowRewrittenCandidates,
15205 Expr *Args[2] = { LHS, RHS };
15209 AllowRewrittenCandidates =
false;
15215 if (Args[0]->isTypeDependent() || Args[1]->isTypeDependent()) {
15236 if (Fn.isInvalid())
15240 CurFPFeatureOverrides());
15245 if (Opc == BO_PtrMemD) {
15246 auto CheckPlaceholder = [&](
Expr *&Arg) {
15255 if (CheckPlaceholder(Args[0]) || CheckPlaceholder(Args[1]))
15257 return CreateBuiltinBinOp(OpLoc, Opc, Args[0], Args[1]);
15276 if (Opc == BO_Assign && !Args[0]->getType()->isOverloadableType())
15277 return CreateBuiltinBinOp(OpLoc, Opc, Args[0], Args[1]);
15282 Op, OpLoc, AllowRewrittenCandidates));
15284 CandidateSet.
exclude(DefaultedFn);
15285 LookupOverloadedBinOp(CandidateSet, Op, Fns, Args, PerformADL);
15287 bool HadMultipleCandidates = (CandidateSet.
size() > 1);
15296 bool IsReversed = Best->isReversed();
15298 std::swap(Args[0], Args[1]);
15315 if (Best->RewriteKind && ChosenOp == OO_EqualEqual &&
15319 Diag(OpLoc, IsExtension ? diag::ext_ovl_rewrite_equalequal_not_bool
15320 : diag::err_ovl_rewrite_equalequal_not_bool)
15328 if (AllowRewrittenCandidates && !IsReversed &&
15338 for (
unsigned ArgIdx = 0; ArgIdx < 2; ++ArgIdx) {
15341 Best->Conversions[ArgIdx]) ==
15343 AmbiguousWith.push_back(Cand.
Function);
15350 if (!AmbiguousWith.empty()) {
15351 bool AmbiguousWithSelf =
15352 AmbiguousWith.size() == 1 &&
15354 Diag(OpLoc, diag::ext_ovl_ambiguous_oper_binary_reversed)
15356 << Args[0]->
getType() << Args[1]->
getType() << AmbiguousWithSelf
15358 if (AmbiguousWithSelf) {
15360 diag::note_ovl_ambiguous_oper_binary_reversed_self);
15365 if (
auto *MD = dyn_cast<CXXMethodDecl>(FnDecl))
15366 if (Op == OverloadedOperatorKind::OO_EqualEqual &&
15368 !MD->hasCXXExplicitFunctionObjectParameter() &&
15370 MD->getFunctionObjectParameterType(),
15371 MD->getParamDecl(0)->getType().getNonReferenceType()) &&
15373 MD->getFunctionObjectParameterType(),
15376 MD->getFunctionObjectParameterType(),
15379 diag::note_ovl_ambiguous_eqeq_reversed_self_non_const);
15382 diag::note_ovl_ambiguous_oper_binary_selected_candidate);
15383 for (
auto *F : AmbiguousWith)
15385 diag::note_ovl_ambiguous_oper_binary_reversed_candidate);
15393 if (Op == OO_Equal)
15394 diagnoseNullableToNonnullConversion(Args[0]->getType(),
15395 Args[1]->getType(), OpLoc);
15400 CheckMemberOperatorAccess(OpLoc, Args[0], Args[1], Best->FoundDecl);
15404 if (
Method->isExplicitObjectMemberFunction()) {
15405 Arg0 = InitializeExplicitObjectArgument(*
this, Args[0], FnDecl);
15408 Arg0 = PerformImplicitObjectArgumentInitialization(
15409 Args[0], std::nullopt, Best->FoundDecl,
Method);
15411 Arg1 = PerformCopyInitialization(
15422 ExprResult Arg0 = PerformCopyInitialization(
15430 PerformCopyInitialization(
15442 Best->FoundDecl,
Base,
15443 HadMultipleCandidates, OpLoc);
15454 const Expr *ImplicitThis =
nullptr;
15459 Context, ChosenOp, FnExpr.
get(), Args, ResultTy,
VK, OpLoc,
15460 CurFPFeatureOverrides(),
15463 if (
const auto *
Method = dyn_cast<CXXMethodDecl>(FnDecl);
15466 ImplicitThis = ArgsArray[0];
15467 ArgsArray = ArgsArray.slice(1);
15470 if (CheckCallReturnType(FnDecl->
getReturnType(), OpLoc, TheCall,
15474 if (Op == OO_Equal) {
15476 DiagnoseSelfMove(Args[0], Args[1], OpLoc);
15479 *
this,
AssignedEntity{Args[0], dyn_cast<CXXMethodDecl>(FnDecl)},
15482 if (ImplicitThis) {
15485 cast<CXXMethodDecl>(FnDecl)->getFunctionObjectParameterType());
15487 CheckArgAlignment(OpLoc, FnDecl,
"'this'", ThisType,
15491 checkCall(FnDecl,
nullptr, ImplicitThis, ArgsArray,
15495 ExprResult R = MaybeBindToTemporary(TheCall);
15499 R = CheckForImmediateInvocation(R, FnDecl);
15506 (Op == OO_Spaceship && IsReversed)) {
15507 if (Op == OO_ExclaimEqual) {
15508 assert(ChosenOp == OO_EqualEqual &&
"unexpected operator name");
15509 R = CreateBuiltinUnaryOp(OpLoc, UO_LNot, R.
get());
15511 assert(ChosenOp == OO_Spaceship &&
"unexpected operator name");
15513 Expr *ZeroLiteral =
15518 Ctx.Entity = FnDecl;
15519 pushCodeSynthesisContext(Ctx);
15521 R = CreateOverloadedBinOp(
15522 OpLoc, Opc, Fns, IsReversed ? ZeroLiteral : R.
get(),
15523 IsReversed ? R.
get() : ZeroLiteral,
true,
15526 popCodeSynthesisContext();
15531 assert(ChosenOp == Op &&
"unexpected operator name");
15535 if (Best->RewriteKind !=
CRK_None)
15543 ExprResult ArgsRes0 = PerformImplicitConversion(
15544 Args[0], Best->BuiltinParamTypes[0], Best->Conversions[0],
15549 Args[0] = ArgsRes0.
get();
15551 ExprResult ArgsRes1 = PerformImplicitConversion(
15552 Args[1], Best->BuiltinParamTypes[1], Best->Conversions[1],
15557 Args[1] = ArgsRes1.
get();
15567 if (Opc == BO_Comma)
15572 if (DefaultedFn && Opc == BO_Cmp) {
15573 ExprResult E = BuildSynthesizedThreeWayComparison(OpLoc, Fns, Args[0],
15574 Args[1], DefaultedFn);
15575 if (
E.isInvalid() ||
E.isUsable())
15589 Opc >= BO_Assign && Opc <= BO_OrAssign) {
15590 Diag(OpLoc, diag::err_ovl_no_viable_oper)
15593 if (Args[0]->getType()->isIncompleteType()) {
15594 Diag(OpLoc, diag::note_assign_lhs_incomplete)
15608 Result = CreateBuiltinBinOp(OpLoc, Opc, Args[0], Args[1]);
15610 assert(
Result.isInvalid() &&
15611 "C++ binary operator overloading is missing candidates!");
15620 << Args[0]->getType()
15621 << Args[1]->getType()
15622 << Args[0]->getSourceRange()
15623 << Args[1]->getSourceRange()),
15629 if (isImplicitlyDeleted(Best->Function)) {
15633 Diag(OpLoc, diag::err_ovl_deleted_special_oper)
15637 Diag(OpLoc, diag::err_ovl_deleted_comparison)
15638 << Args[0]->
getType() << DeletedFD;
15643 NoteDeletedFunction(DeletedFD);
15651 PDiag(diag::err_ovl_deleted_oper)
15653 .getCXXOverloadedOperator())
15654 << (Msg !=
nullptr) << (Msg ? Msg->
getString() : StringRef())
15655 << Args[0]->getSourceRange() << Args[1]->getSourceRange()),
15663 return CreateBuiltinBinOp(OpLoc, Opc, Args[0], Args[1]);
15679 "cannot use prvalue expressions more than once");
15680 Expr *OrigLHS = LHS;
15681 Expr *OrigRHS = RHS;
15685 LHS =
new (Context)
15688 RHS =
new (Context)
15692 ExprResult Eq = CreateOverloadedBinOp(OpLoc, BO_EQ, Fns, LHS, RHS,
true,
true,
15694 if (
Eq.isInvalid())
15697 ExprResult Less = CreateOverloadedBinOp(OpLoc, BO_LT, Fns, LHS, RHS,
true,
15698 true, DefaultedFn);
15699 if (
Less.isInvalid())
15704 Greater = CreateOverloadedBinOp(OpLoc, BO_LT, Fns, RHS, LHS,
true,
true,
15711 struct Comparison {
15726 for (; I >= 0; --I) {
15728 auto *VI = Info->lookupValueInfo(Comparisons[I].
Result);
15739 Result = ActOnConditionalOp(OpLoc, OpLoc, Comparisons[I].Cmp.get(),
15751 Context, OrigLHS, OrigRHS, BO_Cmp,
Result.get()->getType(),
15752 Result.get()->getValueKind(),
Result.get()->getObjectKind(), OpLoc,
15753 CurFPFeatureOverrides());
15754 Expr *SemanticForm[] = {LHS, RHS,
Result.get()};
15764 unsigned NumArgsSlots =
15765 MethodArgs.size() + std::max<unsigned>(Args.size(), NumParams);
15768 MethodArgs.reserve(MethodArgs.size() + NumArgsSlots);
15769 bool IsError =
false;
15772 for (
unsigned i = 0; i != NumParams; i++) {
15774 if (i < Args.size()) {
15792 MethodArgs.push_back(Arg);
15802 Args.push_back(
Base);
15803 for (
auto *e : ArgExpr) {
15812 ArgExpr.back()->getEndLoc());
15824 if (Fn.isInvalid())
15830 CurFPFeatureOverrides());
15834 UnbridgedCastsSet UnbridgedCasts;
15844 AddMemberOperatorCandidates(OO_Subscript, LLoc, Args, CandidateSet);
15847 if (Args.size() == 2)
15848 AddBuiltinOperatorCandidates(OO_Subscript, LLoc, Args, CandidateSet);
15850 bool HadMultipleCandidates = (CandidateSet.
size() > 1);
15863 CheckMemberOperatorAccess(LLoc, Args[0], ArgExpr, Best->FoundDecl);
15870 if (
Method->isExplicitObjectMemberFunction()) {
15872 InitializeExplicitObjectArgument(*
this, Args[0],
Method);
15875 Args[0] = Res.
get();
15878 ExprResult Arg0 = PerformImplicitObjectArgumentInitialization(
15879 Args[0], std::nullopt, Best->FoundDecl,
Method);
15883 MethodArgs.push_back(Arg0.
get());
15887 *
this, MethodArgs,
Method, ArgExpr, LLoc);
15895 *
this, FnDecl, Best->FoundDecl,
Base, HadMultipleCandidates,
15906 Context, OO_Subscript, FnExpr.
get(), MethodArgs, ResultTy,
VK, RLoc,
15907 CurFPFeatureOverrides());
15909 if (CheckCallReturnType(FnDecl->
getReturnType(), LLoc, TheCall, FnDecl))
15912 if (CheckFunctionCall(
Method, TheCall,
15916 return CheckForImmediateInvocation(MaybeBindToTemporary(TheCall),
15922 ExprResult ArgsRes0 = PerformImplicitConversion(
15923 Args[0], Best->BuiltinParamTypes[0], Best->Conversions[0],
15928 Args[0] = ArgsRes0.
get();
15930 ExprResult ArgsRes1 = PerformImplicitConversion(
15931 Args[1], Best->BuiltinParamTypes[1], Best->Conversions[1],
15936 Args[1] = ArgsRes1.
get();
15944 CandidateSet.
empty()
15945 ? (PDiag(diag::err_ovl_no_oper)
15946 << Args[0]->getType() << 0
15947 << Args[0]->getSourceRange() <<
Range)
15948 : (PDiag(diag::err_ovl_no_viable_subscript)
15949 << Args[0]->getType() << Args[0]->getSourceRange() <<
Range);
15956 if (Args.size() == 2) {
15959 LLoc, PDiag(diag::err_ovl_ambiguous_oper_binary)
15960 <<
"[]" << Args[0]->getType() << Args[1]->getType()
15961 << Args[0]->getSourceRange() <<
Range),
15966 PDiag(diag::err_ovl_ambiguous_subscript_call)
15967 << Args[0]->getType()
15968 << Args[0]->getSourceRange() <<
Range),
15977 PDiag(diag::err_ovl_deleted_oper)
15978 <<
"[]" << (Msg !=
nullptr)
15979 << (Msg ? Msg->
getString() : StringRef())
15980 << Args[0]->getSourceRange() <<
Range),
15987 return CreateBuiltinArraySubscriptExpr(Args[0], LLoc, Args[1], RLoc);
15994 Expr *ExecConfig,
bool IsExecConfig,
15995 bool AllowRecovery) {
16004 if (
BinaryOperator *op = dyn_cast<BinaryOperator>(NakedMemExpr)) {
16006 assert(op->getOpcode() == BO_PtrMemD || op->getOpcode() == BO_PtrMemI);
16019 QualType objectType = op->getLHS()->getType();
16020 if (op->getOpcode() == BO_PtrMemI)
16024 Qualifiers difference = objectQuals - funcQuals;
16028 std::string qualsString = difference.
getAsString();
16029 Diag(LParenLoc, diag::err_pointer_to_member_call_drops_quals)
16032 << (qualsString.find(
' ') == std::string::npos ? 1 : 2);
16036 Context, MemExprE, Args, resultType, valueKind, RParenLoc,
16039 if (CheckCallReturnType(proto->
getReturnType(), op->getRHS()->getBeginLoc(),
16043 if (ConvertArgumentsForCall(call, op,
nullptr, proto, Args, RParenLoc))
16046 if (CheckOtherCall(call, proto))
16049 return MaybeBindToTemporary(call);
16056 if (!AllowRecovery)
16058 std::vector<Expr *> SubExprs = {MemExprE};
16059 llvm::append_range(SubExprs, Args);
16060 return CreateRecoveryExpr(MemExprE->
getBeginLoc(), RParenLoc, SubExprs,
16063 if (isa<CXXPseudoDestructorExpr>(NakedMemExpr))
16065 RParenLoc, CurFPFeatureOverrides());
16067 UnbridgedCastsSet UnbridgedCasts;
16073 bool HadMultipleCandidates =
false;
16076 if (isa<MemberExpr>(NakedMemExpr)) {
16077 MemExpr = cast<MemberExpr>(NakedMemExpr);
16081 UnbridgedCasts.restore();
16099 TemplateArgs = &TemplateArgsBuffer;
16105 QualType ExplicitObjectType = ObjectType;
16109 if (isa<UsingShadowDecl>(
Func))
16110 Func = cast<UsingShadowDecl>(
Func)->getTargetDecl();
16112 bool HasExplicitParameter =
false;
16113 if (
const auto *M = dyn_cast<FunctionDecl>(
Func);
16114 M && M->hasCXXExplicitFunctionObjectParameter())
16115 HasExplicitParameter =
true;
16116 else if (
const auto *M = dyn_cast<FunctionTemplateDecl>(
Func);
16118 M->getTemplatedDecl()->hasCXXExplicitFunctionObjectParameter())
16119 HasExplicitParameter =
true;
16121 if (HasExplicitParameter)
16125 if (getLangOpts().MicrosoftExt && isa<CXXConstructorDecl>(
Func)) {
16126 AddOverloadCandidate(cast<CXXConstructorDecl>(
Func), I.getPair(), Args,
16129 }
else if ((
Method = dyn_cast<CXXMethodDecl>(
Func))) {
16135 AddMethodCandidate(
Method, I.getPair(), ActingDC, ExplicitObjectType,
16136 ObjectClassification, Args, CandidateSet,
16139 AddMethodTemplateCandidate(cast<FunctionTemplateDecl>(
Func),
16140 I.getPair(), ActingDC, TemplateArgs,
16141 ExplicitObjectType, ObjectClassification,
16142 Args, CandidateSet,
16147 HadMultipleCandidates = (CandidateSet.
size() > 1);
16151 UnbridgedCasts.restore();
16154 bool Succeeded =
false;
16158 Method = cast<CXXMethodDecl>(Best->Function);
16159 FoundDecl = Best->FoundDecl;
16160 CheckUnresolvedMemberAccess(UnresExpr, Best->FoundDecl);
16161 if (DiagnoseUseOfOverloadedDecl(Best->FoundDecl, UnresExpr->
getNameLoc()))
16169 if (
Method != FoundDecl.getDecl() &&
16179 PDiag(diag::err_ovl_no_viable_member_function_in_call)
16186 PDiag(diag::err_ovl_ambiguous_member_call)
16191 DiagnoseUseOfDeletedFunction(
16193 CandidateSet, Best->Function, Args,
true);
16201 FixOverloadedFunctionReference(MemExprE, FoundDecl,
Method);
16204 MemExprE = Res.
get();
16208 if (
Method->isStatic()) {
16209 return BuildResolvedCallExpr(MemExprE,
Method, LParenLoc, Args, RParenLoc,
16210 ExecConfig, IsExecConfig);
16220 assert(
Method &&
"Member call to something that isn't a method?");
16225 if (
Method->isExplicitObjectMemberFunction()) {
16233 HadMultipleCandidates, MemExpr->
getExprLoc());
16239 CurFPFeatureOverrides(), Proto->getNumParams());
16240 TheCall->setUsesMemberSyntax(
true);
16243 ExprResult ObjectArg = PerformImplicitObjectArgumentInitialization(
16249 RParenLoc, CurFPFeatureOverrides(),
16250 Proto->getNumParams());
16256 return BuildRecoveryExpr(ResultType);
16259 if (ConvertArgumentsForCall(TheCall, MemExpr,
Method, Proto, Args,
16261 return BuildRecoveryExpr(ResultType);
16263 DiagnoseSentinelCalls(
Method, LParenLoc, Args);
16265 if (CheckFunctionCall(
Method, TheCall, Proto))
16271 if (
auto *MemE = dyn_cast<MemberExpr>(NakedMemExpr)) {
16272 if (
const EnableIfAttr *
Attr =
16273 CheckEnableIf(
Method, LParenLoc, Args,
true)) {
16274 Diag(MemE->getMemberLoc(),
16275 diag::err_ovl_no_viable_member_function_in_call)
16278 diag::note_ovl_candidate_disabled_by_function_cond_attr)
16279 <<
Attr->getCond()->getSourceRange() <<
Attr->getMessage();
16284 if (isa<CXXConstructorDecl, CXXDestructorDecl>(CurContext) &&
16285 TheCall->getDirectCallee()->isPureVirtual()) {
16291 diag::warn_call_to_pure_virtual_member_function_from_ctor_dtor)
16292 << MD->
getDeclName() << isa<CXXDestructorDecl>(CurContext)
16296 if (getLangOpts().AppleKext)
16302 if (
auto *DD = dyn_cast<CXXDestructorDecl>(TheCall->getDirectCallee())) {
16304 bool CallCanBeVirtual = !MemExpr->
hasQualifier() || getLangOpts().AppleKext;
16305 CheckVirtualDtorCall(DD, MemExpr->
getBeginLoc(),
false,
16306 CallCanBeVirtual,
true,
16310 return CheckForImmediateInvocation(MaybeBindToTemporary(TheCall),
16311 TheCall->getDirectCallee());
16323 UnbridgedCastsSet UnbridgedCasts;
16327 assert(Object.get()->getType()->isRecordType() &&
16328 "Requires object type argument");
16341 if (RequireCompleteType(LParenLoc, Object.get()->getType(),
16342 diag::err_incomplete_object_call, Object.get()))
16345 auto *
Record = Object.get()->getType()->castAsCXXRecordDecl();
16346 LookupResult R(*
this, OpName, LParenLoc, LookupOrdinaryName);
16347 LookupQualifiedName(R,
Record);
16351 Oper != OperEnd; ++Oper) {
16352 AddMethodCandidate(Oper.getPair(), Object.get()->getType(),
16353 Object.get()->Classify(Context), Args, CandidateSet,
16365 bool IgnoreSurrogateFunctions =
false;
16368 if (!Candidate.
Viable &&
16370 IgnoreSurrogateFunctions =
true;
16390 const auto &Conversions =
Record->getVisibleConversionFunctions();
16391 for (
auto I = Conversions.begin(),
E = Conversions.end();
16392 !IgnoreSurrogateFunctions && I !=
E; ++I) {
16395 if (isa<UsingShadowDecl>(
D))
16396 D = cast<UsingShadowDecl>(
D)->getTargetDecl();
16400 if (isa<FunctionTemplateDecl>(
D))
16413 AddSurrogateCandidate(Conv, I.getPair(), ActingContext, Proto,
16414 Object.get(), Args, CandidateSet);
16419 bool HadMultipleCandidates = (CandidateSet.
size() > 1);
16432 CandidateSet.
empty()
16433 ? (PDiag(diag::err_ovl_no_oper)
16434 << Object.get()->getType() << 1
16435 << Object.get()->getSourceRange())
16436 : (PDiag(diag::err_ovl_no_viable_object_call)
16437 << Object.get()->getType() << Object.get()->getSourceRange());
16447 PDiag(diag::err_ovl_ambiguous_object_call)
16448 << Object.get()->getType()
16449 << Object.get()->getSourceRange()),
16460 PDiag(diag::err_ovl_deleted_object_call)
16461 << Object.get()->getType() << (Msg !=
nullptr)
16462 << (Msg ? Msg->
getString() : StringRef())
16463 << Object.get()->getSourceRange()),
16469 if (Best == CandidateSet.
end())
16472 UnbridgedCasts.restore();
16474 if (Best->Function ==
nullptr) {
16478 = cast<CXXConversionDecl>(
16479 Best->Conversions[0].UserDefined.ConversionFunction);
16481 CheckMemberOperatorAccess(LParenLoc, Object.get(),
nullptr,
16483 if (DiagnoseUseOfDecl(Best->FoundDecl, LParenLoc))
16485 assert(Conv == Best->FoundDecl.getDecl() &&
16486 "Found Decl & conversion-to-functionptr should be same, right?!");
16493 ExprResult Call = BuildCXXMemberCallExpr(Object.get(), Best->FoundDecl,
16494 Conv, HadMultipleCandidates);
16495 if (
Call.isInvalid())
16499 Context,
Call.get()->getType(), CK_UserDefinedConversion,
Call.get(),
16500 nullptr,
VK_PRValue, CurFPFeatureOverrides());
16502 return BuildCallExpr(S,
Call.get(), LParenLoc, Args, RParenLoc);
16505 CheckMemberOperatorAccess(LParenLoc, Object.get(),
nullptr, Best->FoundDecl);
16513 if (
Method->isInvalidDecl())
16523 Obj, HadMultipleCandidates,
16530 MethodArgs.reserve(NumParams + 1);
16532 bool IsError =
false;
16536 if (
Method->isExplicitObjectMemberFunction()) {
16539 ExprResult ObjRes = PerformImplicitObjectArgumentInitialization(
16540 Object.get(), std::nullopt, Best->FoundDecl,
Method);
16545 MethodArgs.push_back(Object.get());
16549 *
this, MethodArgs,
Method, Args, LParenLoc);
16552 if (Proto->isVariadic()) {
16554 for (
unsigned i = NumParams, e = Args.size(); i < e; i++) {
16555 ExprResult Arg = DefaultVariadicArgumentPromotion(
16558 MethodArgs.push_back(Arg.
get());
16565 DiagnoseSentinelCalls(
Method, LParenLoc, Args);
16573 Context, OO_Call, NewFn.
get(), MethodArgs, ResultTy,
VK, RParenLoc,
16574 CurFPFeatureOverrides());
16576 if (CheckCallReturnType(
Method->getReturnType(), LParenLoc, TheCall,
Method))
16579 if (CheckFunctionCall(
Method, TheCall, Proto))
16582 return CheckForImmediateInvocation(MaybeBindToTemporary(TheCall),
Method);
16587 bool *NoArrowOperatorFound) {
16588 assert(
Base->getType()->isRecordType() &&
16589 "left-hand side must have class type");
16606 if (RequireCompleteType(
Loc,
Base->getType(),
16607 diag::err_typecheck_incomplete_tag,
Base))
16610 LookupResult R(*
this, OpName, OpLoc, LookupOrdinaryName);
16611 LookupQualifiedName(R,
Base->getType()->castAsRecordDecl());
16615 Oper != OperEnd; ++Oper) {
16616 AddMethodCandidate(Oper.getPair(),
Base->getType(),
Base->Classify(Context),
16621 bool HadMultipleCandidates = (CandidateSet.
size() > 1);
16632 if (CandidateSet.
empty()) {
16634 if (NoArrowOperatorFound) {
16637 *NoArrowOperatorFound =
true;
16640 Diag(OpLoc, diag::err_typecheck_member_reference_arrow)
16641 << BaseType <<
Base->getSourceRange();
16643 Diag(OpLoc, diag::note_typecheck_member_reference_suggestion)
16647 Diag(OpLoc, diag::err_ovl_no_viable_oper)
16648 <<
"operator->" <<
Base->getSourceRange();
16656 <<
"->" <<
Base->getType()
16657 <<
Base->getSourceRange()),
16665 <<
"->" << (Msg !=
nullptr)
16666 << (Msg ? Msg->
getString() : StringRef())
16667 <<
Base->getSourceRange()),
16673 CheckMemberOperatorAccess(OpLoc,
Base,
nullptr, Best->FoundDecl);
16678 if (
Method->isExplicitObjectMemberFunction()) {
16685 Base, std::nullopt, Best->FoundDecl,
Method);
16693 Base, HadMultipleCandidates, OpLoc);
16703 ResultTy,
VK, OpLoc, CurFPFeatureOverrides());
16705 if (CheckCallReturnType(
Method->getReturnType(), OpLoc, TheCall,
Method))
16708 if (CheckFunctionCall(
Method, TheCall,
16712 return CheckForImmediateInvocation(MaybeBindToTemporary(TheCall),
Method);
16724 AddNonMemberOperatorCandidates(R.
asUnresolvedSet(), Args, CandidateSet,
16727 bool HadMultipleCandidates = (CandidateSet.
size() > 1);
16740 PDiag(diag::err_ovl_no_viable_function_in_call)
16755 nullptr, HadMultipleCandidates,
16758 if (Fn.isInvalid())
16764 for (
unsigned ArgIdx = 0, N = Args.size(); ArgIdx != N; ++ArgIdx) {
16765 ExprResult InputInit = PerformCopyInitialization(
16770 ConvArgs[ArgIdx] = InputInit.
get();
16779 LitEndLoc, UDSuffixLoc, CurFPFeatureOverrides());
16781 if (CheckCallReturnType(FD->
getReturnType(), UDSuffixLoc, UDL, FD))
16784 if (CheckFunctionCall(FD, UDL,
nullptr))
16787 return CheckForImmediateInvocation(MaybeBindToTemporary(UDL), FD);
16797 Scope *S =
nullptr;
16800 if (!MemberLookup.
empty()) {
16810 return FRS_DiagnosticIssued;
16815 return FRS_DiagnosticIssued;
16818 ExprResult FnR = CreateUnresolvedLookupExpr(
nullptr,
16822 return FRS_DiagnosticIssued;
16825 bool CandidateSetError = buildOverloadedCallSet(S, Fn, Fn,
Range,
Loc,
16827 if (CandidateSet->
empty() || CandidateSetError) {
16829 return FRS_NoViableFunction;
16837 return FRS_NoViableFunction;
16840 Loc,
nullptr, CandidateSet, &Best,
16845 return FRS_DiagnosticIssued;
16848 return FRS_Success;
16853 if (
ParenExpr *PE = dyn_cast<ParenExpr>(
E)) {
16855 FixOverloadedFunctionReference(PE->getSubExpr(),
Found, Fn);
16858 if (SubExpr.
get() == PE->getSubExpr())
16861 return new (Context)
16862 ParenExpr(PE->getLParen(), PE->getRParen(), SubExpr.
get());
16867 FixOverloadedFunctionReference(ICE->getSubExpr(),
Found, Fn);
16870 assert(Context.
hasSameType(ICE->getSubExpr()->getType(),
16872 "Implicit cast type cannot be determined from overload");
16873 assert(ICE->path_empty() &&
"fixing up hierarchy conversion?");
16874 if (SubExpr.
get() == ICE->getSubExpr())
16879 CurFPFeatureOverrides());
16882 if (
auto *GSE = dyn_cast<GenericSelectionExpr>(
E)) {
16883 if (!GSE->isResultDependent()) {
16885 FixOverloadedFunctionReference(GSE->getResultExpr(),
Found, Fn);
16888 if (SubExpr.
get() == GSE->getResultExpr())
16895 unsigned ResultIdx = GSE->getResultIndex();
16896 AssocExprs[ResultIdx] = SubExpr.
get();
16898 if (GSE->isExprPredicate())
16900 Context, GSE->getGenericLoc(), GSE->getControllingExpr(),
16901 GSE->getAssocTypeSourceInfos(), AssocExprs, GSE->getDefaultLoc(),
16902 GSE->getRParenLoc(), GSE->containsUnexpandedParameterPack(),
16905 Context, GSE->getGenericLoc(), GSE->getControllingType(),
16906 GSE->getAssocTypeSourceInfos(), AssocExprs, GSE->getDefaultLoc(),
16907 GSE->getRParenLoc(), GSE->containsUnexpandedParameterPack(),
16916 assert(UnOp->getOpcode() == UO_AddrOf &&
16917 "Can only take the address of an overloaded function");
16919 if (!
Method->isImplicitObjectMemberFunction()) {
16927 FixOverloadedFunctionReference(UnOp->getSubExpr(),
Found, Fn);
16930 if (SubExpr.
get() == UnOp->getSubExpr())
16933 if (CheckUseOfCXXMethodAsAddressOfOperand(UnOp->getBeginLoc(),
16937 assert(isa<DeclRefExpr>(SubExpr.
get()) &&
16938 "fixed to something other than a decl ref");
16940 cast<DeclRefExpr>(SubExpr.
get())->getQualifier();
16941 assert(Qualifier &&
16942 "fixed to a member ref with no nested name qualifier");
16948 Fn->getType(), Qualifier,
16949 cast<CXXRecordDecl>(
Method->getDeclContext()));
16952 (void)isCompleteType(UnOp->getOperatorLoc(), MemPtrType);
16956 UnOp->getOperatorLoc(),
false,
16957 CurFPFeatureOverrides());
16961 FixOverloadedFunctionReference(UnOp->getSubExpr(),
Found, Fn);
16964 if (SubExpr.
get() == UnOp->getSubExpr())
16967 return CreateBuiltinUnaryOp(UnOp->getOperatorLoc(), UO_AddrOf,
16973 CheckUnresolvedLookupAccess(ULE,
Found);
16977 if (ULE->hasExplicitTemplateArgs()) {
16978 ULE->copyTemplateArgumentsInto(TemplateArgsBuffer);
16979 TemplateArgs = &TemplateArgsBuffer;
16984 getLangOpts().CPlusPlus && !Fn->hasCXXExplicitFunctionObjectParameter()
16989 if (
unsigned BID = Fn->getBuiltinID()) {
16997 Fn,
Type, ValueKind, ULE->getNameInfo(), ULE->getQualifierLoc(),
16998 Found.getDecl(), ULE->getTemplateKeywordLoc(), TemplateArgs);
17006 if (MemExpr->hasExplicitTemplateArgs()) {
17007 MemExpr->copyTemplateArgumentsInto(TemplateArgsBuffer);
17008 TemplateArgs = &TemplateArgsBuffer;
17015 if (MemExpr->isImplicitAccess()) {
17016 if (cast<CXXMethodDecl>(Fn)->isStatic()) {
17018 Fn, Fn->getType(),
VK_LValue, MemExpr->getNameInfo(),
17019 MemExpr->getQualifierLoc(),
Found.getDecl(),
17020 MemExpr->getTemplateKeywordLoc(), TemplateArgs);
17025 if (MemExpr->getQualifier())
17026 Loc = MemExpr->getQualifierLoc().getBeginLoc();
17028 BuildCXXThisExpr(
Loc, MemExpr->getBaseType(),
true);
17031 Base = MemExpr->getBase();
17035 if (cast<CXXMethodDecl>(Fn)->isStatic()) {
17037 type = Fn->getType();
17043 return BuildMemberExpr(
17044 Base, MemExpr->isArrow(), MemExpr->getOperatorLoc(),
17045 MemExpr->getQualifierLoc(), MemExpr->getTemplateKeywordLoc(), Fn,
Found,
17046 true, MemExpr->getMemberNameInfo(),
17050 llvm_unreachable(
"Invalid reference to overloaded function");
17056 return FixOverloadedFunctionReference(
E.get(),
Found, Fn);
17061 if (!PartialOverloading || !
Function)
17065 if (
const auto *Proto =
17066 dyn_cast<FunctionProtoType>(
Function->getFunctionType()))
17067 if (Proto->isTemplateVariadic())
17069 if (
auto *Pattern =
Function->getTemplateInstantiationPattern())
17070 if (
const auto *Proto =
17071 dyn_cast<FunctionProtoType>(Pattern->getFunctionType()))
17072 if (Proto->isTemplateVariadic())
17085 << IsMember << Name << (Msg !=
nullptr)
17086 << (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 bool EvaluateAsBooleanCondition(const Expr *E, bool &Result, EvalInfo &Info)
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 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)
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
const FunctionType * adjustFunctionType(const FunctionType *Fn, FunctionType::ExtInfo EInfo)
Change the ExtInfo on a function type.
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.
DeclarationNameTable DeclarationNames
QualType getArrayParameterType(QualType Ty) const
Return the uniqued reference to a specified array parameter type from the original array type.
CanQualType getCanonicalType(QualType T) const
Return the canonical (structural) type corresponding to the specified potentially non-canonical type ...
bool mergeExtParameterInfo(const FunctionProtoType *FirstFnType, const FunctionProtoType *SecondFnType, bool &CanUseFirst, bool &CanUseSecond, SmallVectorImpl< FunctionProtoType::ExtParameterInfo > &NewParamInfos)
This function merges the ExtParameterInfo lists of two functions.
bool hasSameType(QualType T1, QualType T2) const
Determine whether the given types T1 and T2 are equivalent.
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.
Builtin::Context & BuiltinInfo
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
QualType removePtrSizeAddrSpace(QualType T) const
Remove the existing address space on the type if it is a pointer size address space and return the ty...
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.
bool canBindObjCObjectType(QualType To, QualType From)
QualType getFunctionTypeWithExceptionSpec(QualType Orig, const FunctionProtoType::ExceptionSpecInfo &ESI) const
Get a function type and produce the equivalent function type with the specified exception specificati...
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>.
ComparisonCategories CompCategories
Types and expressions required to build C++2a three-way comparisons using operator<=>,...
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
bool hasAnyFunctionEffects() const
QualType getRestrictType(QualType T) const
Return the uniqued reference to the type for a restrict qualified type.
CanQualType BoundMemberTy
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.
bool hasSameUnqualifiedType(QualType T1, QualType T2) const
Determine whether the given types are equivalent after cvr-qualifiers have been removed.
const ArrayType * getAsArrayType(QualType T) const
Type Query functions.
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 getFunctionType(QualType ResultTy, ArrayRef< QualType > Args, const FunctionProtoType::ExtProtoInfo &EPI) const
Return a normal function type with a typed argument list.
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 ...
bool hasSimilarType(QualType T1, QualType T2) const
Determine if two types are similar, according to the C++ rules.
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.
bool UnwrapSimilarTypes(QualType &T1, QualType &T2, bool AllowPiMismatch=true) const
Attempt to unwrap two types that may be similar (C++ [conv.qual]).
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
bool isPromotableIntegerType(QualType T) const
More type predicates useful for type checking/promotion.
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
bool isCompoundAssignmentOp() const
static BinaryOperator * Create(const ASTContext &C, Expr *lhs, Expr *rhs, Opcode opc, QualType ResTy, ExprValueKind VK, ExprObjectKind OK, SourceLocation opLoc, FPOptionsOverride FPFeatures)
This class is used for builtin types like 'int'.
bool isDirectlyAddressable(unsigned ID) const
Determines whether this builtin can have its address taken with no special action required.
BasePaths - Represents the set of paths from a derived class to one of its (direct or indirect) bases...
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.
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)
Builds a canonical type from a QualType.
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.
const ComparisonCategoryInfo * lookupInfoForType(QualType Ty) const
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.
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.
bool isScoped() const
Returns true if this is a C++11 scoped enumeration.
A helper class that allows the use of isa/cast/dyncast to detect TagType objects of enums.
EnumDecl * getOriginalDecl() const
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, SmallVectorImpl< PartialDiagnosticAt > *Diag=nullptr) 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...
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.
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
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.
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.
Interfaces are the core concept in Objective-C for object oriented design.
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.
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 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...
void addConst()
Add the const type qualifier to this QualType.
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
RecordDecl * getDefinitionOrSelf() const
A helper class that allows the use of isa/cast/dyncast to detect TagType objects of structs/unions/cl...
RecordDecl * getOriginalDecl() 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.
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.
bool IsBuildingRecoveryCallExpr
Flag indicating if Sema is building a recovery call expression.
bool IsOverload(FunctionDecl *New, FunctionDecl *Old, bool UseMemberUsingDeclRules, bool ConsiderCudaAttrs=true)
@ LookupOrdinaryName
Ordinary name lookup, which finds ordinary names (functions, variables, typedefs, etc....
@ 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.
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 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 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.
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.
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...
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...
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)
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....
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...
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.
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)
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...
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...
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)
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)
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)
bool AreConstraintExpressionsEqual(const NamedDecl *Old, const Expr *OldConstr, const TemplateCompareNewDeclInfo &New, const Expr *NewConstr)
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...
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.
void NoteOverloadCandidate(const NamedDecl *Found, const FunctionDecl *Fn, OverloadCandidateRewriteKind RewriteKind=OverloadCandidateRewriteKind(), QualType DestType=QualType(), bool TakingAddress=false)
bool DiagnoseMultipleUserDefinedConversion(Expr *From, QualType ToType)
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.
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.
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...
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...
bool IsFunctionConversion(QualType FromType, QualType ToType, bool *DiscardingCFIUncheckedCallee=nullptr, bool *AddingCFIUncheckedCallee=nullptr) const
Determine whether the conversion from FromType to ToType is a valid conversion that strips "noexcept"...
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...
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 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...
@ Unevaluated
The current expression and its subexpressions occur within an unevaluated operand (C++11 [expr]p7),...
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.
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 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...
ExprResult CreateRecoveryExpr(SourceLocation Begin, SourceLocation End, ArrayRef< Expr * > SubExprs, QualType T=QualType())
Attempts to produce a RecoveryExpr after some AST node cannot be created.
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...
void DiagnoseUnsatisfiedConstraint(const ConstraintSatisfaction &Satisfaction, bool First=true)
Emit diagnostics explaining why a constraint expression was deemed unsatisfied.
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.
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.
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...
void AddMemberOperatorCandidates(OverloadedOperatorKind Op, SourceLocation OpLoc, ArrayRef< Expr * > Args, OverloadCandidateSet &CandidateSet, OverloadCandidateParamOrder PO={})
Add overload candidates for overloaded operators that are member functions.
ExprResult ActOnFinishFullExpr(Expr *Expr, bool DiscardedValue)
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
bool isMicrosoft() const
Is this ABI an MSVC-compatible ABI?
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.
TargetCXXABI getCXXABI() const
Get the C++ ABI currently in use.
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.
Represents a type template specialization; the template must be a class template, a type alias templa...
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 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)
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...
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)
@ Ambiguous
Name lookup results in an ambiguity; use getAmbiguityKind to figure out what kind of ambiguity we hav...
@ 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...
@ 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.
OverloadCandidateParamOrder
The parameter ordering that will be used for the candidate.
@ Seq
'seq' clause, allowed on 'loop' and 'routine' directives.
OverloadsShown
Specifies which overload candidates to display when overload resolution fails.
@ Ovl_Best
Show just the "best" overload candidates.
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.
@ 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.
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.
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,...
@ CompatibleVoidPtrToNonVoidPtr
CompatibleVoidPtrToNonVoidPtr - The types are compatible in C because a void * can implicitly convert...
@ 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 ...
ActionResult< Expr * > ExprResult
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.
llvm::PointerUnion< TemplateTypeParmDecl *, NonTypeTemplateParmDecl *, TemplateTemplateParmDecl * > TemplateParameter
Stores a template parameter of any kind.
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...
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.
const FunctionProtoType * T
bool shouldEnforceArgLimit(bool PartialOverloading, FunctionDecl *Function)
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.
std::pair< SourceLocation, PartialDiagnostic > PartialDiagnosticAt
A partial diagnostic along with the source location where this diagnostic occurs.
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.
ConstructorInfo getConstructorInfo(NamedDecl *ND)
@ None
The alignment was not explicit in code.
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.
@ 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()
void setFromType(QualType T)
void setToType(QualType T)
void addConversion(NamedDecl *Found, FunctionDecl *D)
SmallVector< std::pair< NamedDecl *, FunctionDecl * >, 4 > ConversionSet
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 shouldAddReversed(Sema &S, ArrayRef< Expr * > OriginalArgs, FunctionDecl *FD)
Determine whether we should add a rewritten candidate for FD with reversed parameter order.
bool allowsReversed(OverloadedOperatorKind Op)
Determine whether reversing parameter order is allowed for operator Op.
bool AllowRewrittenCandidates
Whether we should include rewritten candidates in the overload set.
bool isReversible()
Determines whether this operator could be implemented by a function with reversed parameter order.
bool isAcceptableCandidate(const FunctionDecl *FD)
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...
@ RewritingOperatorAsSpaceship
We are rewriting a comparison operator in terms of an operator<=>.
ReferenceConversions
The conversions that would be performed on an lvalue of type T2 when binding a reference of type T1 t...
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.
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.