41#include "llvm/ADT/DenseSet.h"
42#include "llvm/ADT/STLExtras.h"
43#include "llvm/ADT/STLForwardCompat.h"
44#include "llvm/ADT/ScopeExit.h"
45#include "llvm/ADT/SmallPtrSet.h"
46#include "llvm/ADT/SmallString.h"
47#include "llvm/ADT/SmallVector.h"
48#include "llvm/Support/Casting.h"
62 return P->hasAttr<PassObjectSizeAttr>();
83 if (HadMultipleCandidates)
94 CK_FunctionToPointerDecay);
98 bool InOverloadResolution,
101 bool AllowObjCWritebackConversion);
105 bool InOverloadResolution,
113 bool AllowObjCConversionOnExplicit);
174 return Rank[(
int)Kind];
199 static const char *
const Name[] = {
203 "Function-to-pointer",
204 "Function pointer conversion",
206 "Integral promotion",
207 "Floating point promotion",
209 "Integral conversion",
210 "Floating conversion",
211 "Complex conversion",
212 "Floating-integral conversion",
213 "Pointer conversion",
214 "Pointer-to-member conversion",
215 "Boolean conversion",
216 "Compatible-types conversion",
217 "Derived-to-base conversion",
219 "SVE Vector conversion",
220 "RVV Vector conversion",
222 "Complex-real conversion",
223 "Block Pointer conversion",
224 "Transparent Union Conversion",
225 "Writeback conversion",
226 "OpenCL Zero Event Conversion",
227 "OpenCL Zero Queue Conversion",
228 "C specific type conversion",
229 "Incompatible pointer conversion",
230 "Fixed point conversion",
231 "HLSL vector truncation",
232 "Non-decaying array conversion",
320 const Expr *Converted) {
323 if (
auto *EWC = dyn_cast<ExprWithCleanups>(Converted)) {
330 while (
auto *ICE = dyn_cast<ImplicitCastExpr>(Converted)) {
331 switch (ICE->getCastKind()) {
333 case CK_IntegralCast:
334 case CK_IntegralToBoolean:
335 case CK_IntegralToFloating:
336 case CK_BooleanToSignedIntegral:
337 case CK_FloatingToIntegral:
338 case CK_FloatingToBoolean:
339 case CK_FloatingCast:
340 Converted = ICE->getSubExpr();
364 QualType &ConstantType,
bool IgnoreFloatToIntegralConversion)
const {
366 "narrowing check outside C++");
377 ToType = ET->getDecl()->getIntegerType();
383 goto FloatingIntegralConversion;
385 goto IntegralConversion;
396 FloatingIntegralConversion:
401 if (IgnoreFloatToIntegralConversion)
404 assert(
Initializer &&
"Unknown conversion expression");
410 if (std::optional<llvm::APSInt> IntConstantValue =
414 Result.convertFromAPInt(*IntConstantValue, IntConstantValue->isSigned(),
415 llvm::APFloat::rmNearestTiesToEven);
417 llvm::APSInt ConvertedValue = *IntConstantValue;
419 Result.convertToInteger(ConvertedValue,
420 llvm::APFloat::rmTowardZero, &ignored);
422 if (*IntConstantValue != ConvertedValue) {
423 ConstantValue =
APValue(*IntConstantValue);
450 Initializer->isCXX11ConstantExpr(Ctx, &ConstantValue)) {
453 ConstantValue = R.
Val;
454 assert(ConstantValue.
isFloat());
455 llvm::APFloat FloatVal = ConstantValue.
getFloat();
458 llvm::APFloat Converted = FloatVal;
459 llvm::APFloat::opStatus ConvertStatus =
461 llvm::APFloat::rmNearestTiesToEven, &ignored);
463 llvm::APFloat::rmNearestTiesToEven, &ignored);
465 if (FloatVal.isNaN() && Converted.isNaN() &&
466 !FloatVal.isSignaling() && !Converted.isSignaling()) {
472 if (!Converted.bitwiseIsEqual(FloatVal)) {
479 if (ConvertStatus & llvm::APFloat::opOverflow) {
496 IntegralConversion: {
500 const unsigned FromWidth = Ctx.
getIntWidth(FromType);
504 if (FromWidth > ToWidth ||
505 (FromWidth == ToWidth && FromSigned != ToSigned) ||
506 (FromSigned && !ToSigned)) {
514 std::optional<llvm::APSInt> OptInitializerValue;
515 if (!(OptInitializerValue =
Initializer->getIntegerConstantExpr(Ctx))) {
519 llvm::APSInt &InitializerValue = *OptInitializerValue;
520 bool Narrowing =
false;
521 if (FromWidth < ToWidth) {
524 if (InitializerValue.isSigned() && InitializerValue.isNegative())
529 InitializerValue = InitializerValue.extend(
530 InitializerValue.getBitWidth() + 1);
532 llvm::APSInt ConvertedValue = InitializerValue;
533 ConvertedValue = ConvertedValue.trunc(ToWidth);
534 ConvertedValue.setIsSigned(ToSigned);
535 ConvertedValue = ConvertedValue.extend(InitializerValue.getBitWidth());
536 ConvertedValue.setIsSigned(InitializerValue.isSigned());
538 if (ConvertedValue != InitializerValue)
543 ConstantValue =
APValue(InitializerValue);
559 ConstantValue = R.
Val;
560 assert(ConstantValue.
isFloat());
561 llvm::APFloat FloatVal = ConstantValue.
getFloat();
566 if (FloatVal.isNaN() && FloatVal.isSignaling()) {
582 raw_ostream &OS = llvm::errs();
583 bool PrintedSomething =
false;
586 PrintedSomething =
true;
590 if (PrintedSomething) {
596 OS <<
" (by copy constructor)";
598 OS <<
" (direct reference binding)";
600 OS <<
" (reference binding)";
602 PrintedSomething =
true;
606 if (PrintedSomething) {
610 PrintedSomething =
true;
613 if (!PrintedSomething) {
614 OS <<
"No conversions required";
621 raw_ostream &OS = llvm::errs();
629 OS <<
"aggregate initialization";
639 raw_ostream &OS = llvm::errs();
641 OS <<
"Worst list element conversion: ";
642 switch (ConversionKind) {
644 OS <<
"Standard conversion: ";
648 OS <<
"User-defined conversion: ";
652 OS <<
"Ellipsis conversion";
655 OS <<
"Ambiguous conversion";
658 OS <<
"Bad conversion";
683 struct DFIArguments {
689 struct DFIParamWithArguments : DFIArguments {
694 struct DFIDeducedMismatchArgs : DFIArguments {
696 unsigned CallArgIndex;
713 Result.Result =
static_cast<unsigned>(TDK);
714 Result.HasDiagnostic =
false;
733 auto *Saved =
new (Context) DFIDeducedMismatchArgs;
744 DFIArguments *Saved =
new (Context) DFIArguments;
756 DFIParamWithArguments *Saved =
new (Context) DFIParamWithArguments;
757 Saved->Param = Info.
Param;
770 Result.HasDiagnostic =
true;
775 CNSInfo *Saved =
new (Context) CNSInfo;
785 llvm_unreachable(
"not a deduction failure");
818 Diag->~PartialDiagnosticAt();
827 Diag->~PartialDiagnosticAt();
863 return TemplateParameter::getFromOpaqueValue(
Data);
868 return static_cast<DFIParamWithArguments*
>(
Data)->Param;
898 return static_cast<DFIDeducedMismatchArgs*
>(
Data)->TemplateArgs;
904 return static_cast<CNSInfo*
>(
Data)->TemplateArgs;
936 return &
static_cast<DFIArguments*
>(
Data)->FirstArg;
968 return &
static_cast<DFIArguments*
>(
Data)->SecondArg;
983 return static_cast<DFIDeducedMismatchArgs*
>(
Data)->CallArgIndex;
999 for (
unsigned I = 0; I <
X->getNumParams(); ++I)
1003 if (
auto *FTX =
X->getDescribedFunctionTemplate()) {
1008 FTY->getTemplateParameters()))
1017 OverloadedOperatorKind::OO_EqualEqual);
1029 OverloadedOperatorKind::OO_ExclaimEqual);
1030 if (isa<CXXMethodDecl>(EqFD)) {
1047 auto *NotEqFD = Op->getAsFunction();
1048 if (
auto *UD = dyn_cast<UsingShadowDecl>(Op))
1049 NotEqFD = UD->getUnderlyingDecl()->getAsFunction();
1052 cast<Decl>(Op->getLexicalDeclContext())))
1062 return Op == OO_EqualEqual || Op == OO_Spaceship;
1068 if (!allowsReversed(Op))
1070 if (Op == OverloadedOperatorKind::OO_EqualEqual) {
1071 assert(OriginalArgs.size() == 2);
1073 S, OpLoc, OriginalArgs[1], FD))
1084void OverloadCandidateSet::destroyCandidates() {
1086 for (
auto &
C : i->Conversions)
1087 C.~ImplicitConversionSequence();
1089 i->DeductionFailure.Destroy();
1094 destroyCandidates();
1095 SlabAllocator.Reset();
1096 NumInlineBytesUsed = 0;
1103 class UnbridgedCastsSet {
1113 Entry entry = { &
E,
E };
1114 Entries.push_back(entry);
1120 i = Entries.begin(), e = Entries.end(); i != e; ++i)
1121 *i->Addr = i->Saved;
1135 UnbridgedCastsSet *unbridgedCasts =
nullptr) {
1139 if (placeholder->getKind() == BuiltinType::Overload)
return false;
1143 if (placeholder->getKind() == BuiltinType::ARCUnbridgedCast &&
1145 unbridgedCasts->save(S,
E);
1165 UnbridgedCastsSet &unbridged) {
1166 for (
unsigned i = 0, e = Args.size(); i != e; ++i)
1175 NamedDecl *&Match,
bool NewIsUsingDecl) {
1180 bool OldIsUsingDecl =
false;
1181 if (isa<UsingShadowDecl>(OldD)) {
1182 OldIsUsingDecl =
true;
1186 if (NewIsUsingDecl)
continue;
1188 OldD = cast<UsingShadowDecl>(OldD)->getTargetDecl();
1193 if ((OldIsUsingDecl || NewIsUsingDecl) && !isVisible(*I))
1201 bool UseMemberUsingDeclRules =
1202 (OldIsUsingDecl || NewIsUsingDecl) && CurContext->isRecord() &&
1206 if (!IsOverload(New, OldF, UseMemberUsingDeclRules)) {
1207 if (UseMemberUsingDeclRules && OldIsUsingDecl) {
1208 HideUsingShadowDecl(S, cast<UsingShadowDecl>(*I));
1212 if (!isa<FunctionTemplateDecl>(OldD) &&
1213 !shouldLinkPossiblyHiddenDecl(*I, New))
1222 if (!getASTContext().canBuiltinBeRedeclared(OldF)) {
1224 return Ovl_NonFunction;
1226 }
else if (isa<UsingDecl>(OldD) || isa<UsingPackDecl>(OldD)) {
1230 }
else if (isa<TagDecl>(OldD)) {
1232 }
else if (
auto *UUD = dyn_cast<UnresolvedUsingValueDecl>(OldD)) {
1239 if (UUD->getQualifier()->isDependent() && !UUD->isCXXClassMember()) {
1241 return Ovl_NonFunction;
1248 return Ovl_NonFunction;
1273 if (CheckFunctionTemplateSpecialization(New,
nullptr, TemplateSpecResult,
1276 return Ovl_Overload;
1283 return Ovl_Overload;
1288 bool UseMemberUsingDeclRules,
1289 bool ConsiderCudaAttrs,
1290 bool UseOverrideRules =
false) {
1307 if ((OldTemplate ==
nullptr) != (NewTemplate ==
nullptr))
1320 if (isa<FunctionNoProtoType>(OldQType.
getTypePtr()) ||
1321 isa<FunctionNoProtoType>(NewQType.
getTypePtr()))
1324 const auto *OldType = cast<FunctionProtoType>(OldQType);
1325 const auto *NewType = cast<FunctionProtoType>(NewQType);
1330 if (OldQType != NewQType && OldType->isVariadic() != NewType->isVariadic())
1345 OldDecl = OldTemplate;
1346 NewDecl = NewTemplate;
1364 bool ConstraintsInTemplateHead =
1375 if (UseMemberUsingDeclRules && ConstraintsInTemplateHead &&
1376 !SameTemplateParameterList)
1378 if (!UseMemberUsingDeclRules &&
1379 (!SameTemplateParameterList || !SameReturnType))
1383 const auto *OldMethod = dyn_cast<CXXMethodDecl>(Old);
1384 const auto *NewMethod = dyn_cast<CXXMethodDecl>(New);
1386 int OldParamsOffset = 0;
1387 int NewParamsOffset = 0;
1405 !isa<CXXConstructorDecl>(NewMethod))
1411 auto BS =
Base.getNonReferenceType().getCanonicalType().split();
1412 BS.Quals = NormalizeQualifiers(OldMethod, BS.Quals);
1414 auto DS =
D.getNonReferenceType().getCanonicalType().split();
1415 DS.Quals = NormalizeQualifiers(NewMethod, DS.Quals);
1417 if (BS.Quals != DS.Quals)
1420 if (OldMethod->isImplicitObjectMemberFunction() &&
1421 OldMethod->getParent() != NewMethod->getParent()) {
1434 if (
Base->isLValueReferenceType())
1435 return D->isLValueReferenceType();
1436 return Base->isRValueReferenceType() ==
D->isRValueReferenceType();
1441 auto DiagnoseInconsistentRefQualifiers = [&]() {
1444 if (OldMethod->getRefQualifier() == NewMethod->getRefQualifier())
1446 if (OldMethod->isExplicitObjectMemberFunction() ||
1447 NewMethod->isExplicitObjectMemberFunction())
1449 if (!UseMemberUsingDeclRules && (OldMethod->getRefQualifier() ==
RQ_None ||
1450 NewMethod->getRefQualifier() ==
RQ_None)) {
1451 SemaRef.
Diag(NewMethod->getLocation(), diag::err_ref_qualifier_overload)
1452 << NewMethod->getRefQualifier() << OldMethod->getRefQualifier();
1453 SemaRef.
Diag(OldMethod->getLocation(), diag::note_previous_declaration);
1459 if (OldMethod && OldMethod->isExplicitObjectMemberFunction())
1461 if (NewMethod && NewMethod->isExplicitObjectMemberFunction())
1464 if (OldType->getNumParams() - OldParamsOffset !=
1465 NewType->getNumParams() - NewParamsOffset ||
1467 {OldType->param_type_begin() + OldParamsOffset,
1468 OldType->param_type_end()},
1469 {NewType->param_type_begin() + NewParamsOffset,
1470 NewType->param_type_end()},
1475 if (OldMethod && NewMethod && !OldMethod->isStatic() &&
1476 !NewMethod->isStatic()) {
1477 bool HaveCorrespondingObjectParameters = [&](
const CXXMethodDecl *Old,
1479 auto NewObjectType = New->getFunctionObjectParameterReferenceType();
1483 return F->getRefQualifier() ==
RQ_None &&
1484 !F->isExplicitObjectMemberFunction();
1487 if (IsImplicitWithNoRefQual(Old) != IsImplicitWithNoRefQual(New) &&
1488 CompareType(OldObjectType.getNonReferenceType(),
1489 NewObjectType.getNonReferenceType()))
1491 return CompareType(OldObjectType, NewObjectType);
1492 }(OldMethod, NewMethod);
1494 if (!HaveCorrespondingObjectParameters) {
1495 if (DiagnoseInconsistentRefQualifiers())
1500 if (!UseOverrideRules || (!NewMethod->isExplicitObjectMemberFunction() &&
1501 !OldMethod->isExplicitObjectMemberFunction()))
1506 if (!UseOverrideRules &&
1510 if ((NewRC !=
nullptr) != (OldRC !=
nullptr))
1517 if (NewMethod && OldMethod && OldMethod->isImplicitObjectMemberFunction() &&
1518 NewMethod->isImplicitObjectMemberFunction()) {
1519 if (DiagnoseInconsistentRefQualifiers())
1537 NewI != NewE || OldI != OldE; ++NewI, ++OldI) {
1538 if (NewI == NewE || OldI == OldE)
1540 llvm::FoldingSetNodeID NewID, OldID;
1542 OldI->getCond()->Profile(OldID, SemaRef.
Context,
true);
1547 if (SemaRef.
getLangOpts().CUDA && ConsiderCudaAttrs) {
1550 if (!isa<CXXDestructorDecl>(New)) {
1555 "Unexpected invalid target.");
1559 if (NewTarget != OldTarget)
1570 bool UseMemberUsingDeclRules,
bool ConsiderCudaAttrs) {
1576 bool UseMemberUsingDeclRules,
bool ConsiderCudaAttrs) {
1589 bool SuppressUserConversions,
1591 bool InOverloadResolution,
1593 bool AllowObjCWritebackConversion,
1594 bool AllowObjCConversionOnExplicit) {
1597 if (SuppressUserConversions) {
1608 Conversions, AllowExplicit,
1609 AllowObjCConversionOnExplicit)) {
1626 if (Constructor->isCopyConstructor() &&
1627 (FromCanon == ToCanon ||
1638 if (ToCanon != FromCanon)
1649 Cand != Conversions.
end(); ++Cand)
1692 bool SuppressUserConversions,
1694 bool InOverloadResolution,
1696 bool AllowObjCWritebackConversion,
1697 bool AllowObjCConversionOnExplicit) {
1700 ICS.
Standard, CStyle, AllowObjCWritebackConversion)){
1740 AllowExplicit, InOverloadResolution, CStyle,
1741 AllowObjCWritebackConversion,
1742 AllowObjCConversionOnExplicit);
1747 bool SuppressUserConversions,
1749 bool InOverloadResolution,
1751 bool AllowObjCWritebackConversion) {
1752 return ::TryImplicitConversion(*
this, From, ToType, SuppressUserConversions,
1753 AllowExplicit, InOverloadResolution, CStyle,
1754 AllowObjCWritebackConversion,
1760 bool AllowExplicit) {
1765 bool AllowObjCWritebackConversion
1766 = getLangOpts().ObjCAutoRefCount &&
1767 (Action == AA_Passing || Action == AA_Sending);
1768 if (getLangOpts().ObjC)
1772 *
this, From, ToType,
1774 AllowExplicit ? AllowedExplicit::All : AllowedExplicit::None,
1776 false, AllowObjCWritebackConversion,
1778 return PerformImplicitConversion(From, ToType, ICS, Action);
1796 if (TyClass != CanFrom->getTypeClass())
return false;
1797 if (TyClass != Type::FunctionProto && TyClass != Type::FunctionNoProto) {
1798 if (TyClass == Type::Pointer) {
1801 }
else if (TyClass == Type::BlockPointer) {
1804 }
else if (TyClass == Type::MemberPointer) {
1808 if (ToMPT->getClass() != FromMPT->
getClass())
1810 CanTo = ToMPT->getPointeeType();
1816 TyClass = CanTo->getTypeClass();
1817 if (TyClass != CanFrom->getTypeClass())
return false;
1818 if (TyClass != Type::FunctionProto && TyClass != Type::FunctionNoProto)
1822 const auto *FromFn = cast<FunctionType>(CanFrom);
1825 const auto *ToFn = cast<FunctionType>(CanTo);
1828 bool Changed =
false;
1837 if (
const auto *FromFPT = dyn_cast<FunctionProtoType>(FromFn)) {
1838 const auto *ToFPT = cast<FunctionProtoType>(ToFn);
1839 if (FromFPT->isNothrow() && !ToFPT->isNothrow()) {
1840 FromFn = cast<FunctionType>(
1851 bool CanUseToFPT, CanUseFromFPT;
1853 CanUseFromFPT, NewParamInfos) &&
1854 CanUseToFPT && !CanUseFromFPT) {
1857 NewParamInfos.empty() ? nullptr : NewParamInfos.data();
1859 FromFPT->getParamTypes(), ExtInfo);
1869 FromFPT = cast<FunctionProtoType>(FromFn);
1873 const auto FromFX = FromFPT->getFunctionEffects();
1874 const auto ToFX = ToFPT->getFunctionEffects();
1875 if (FromFX != ToFX) {
1879 FromFPT->getReturnType(), FromFPT->getParamTypes(), ExtInfo);
1889 assert(
QualType(FromFn, 0).isCanonical());
1890 if (
QualType(FromFn, 0) != CanTo)
return false;
1918 if ((&FromSem == &llvm::APFloat::PPCDoubleDouble() &&
1919 &ToSem == &llvm::APFloat::IEEEquad()) ||
1920 (&FromSem == &llvm::APFloat::IEEEquad() &&
1921 &ToSem == &llvm::APFloat::PPCDoubleDouble()))
1976 bool InOverloadResolution,
bool CStyle) {
1991 unsigned FromElts = FromExtType->getNumElements();
1992 unsigned ToElts = ToExtType->getNumElements();
1993 if (FromElts < ToElts)
1995 if (FromElts == ToElts)
2000 QualType FromElTy = FromExtType->getElementType();
2001 QualType ToElTy = ToExtType->getElementType();
2015 QualType ToElTy = ToExtType->getElementType();
2049 !ToType->
hasAttr(attr::ArmMveStrictPolymorphism))) {
2054 !InOverloadResolution && !CStyle) {
2056 << FromType << ToType;
2067 bool InOverloadResolution,
2080 bool InOverloadResolution,
2083 bool AllowObjCWritebackConversion) {
2109 FromType = Fn->getType();
2130 if (Method && !Method->
isStatic() &&
2133 "Non-unary operator on non-static member address");
2134 assert(cast<UnaryOperator>(From->
IgnoreParens())->getOpcode()
2136 "Non-address-of operator on non-static member address");
2137 const Type *ClassType
2141 assert(cast<UnaryOperator>(From->
IgnoreParens())->getOpcode() ==
2143 "Non-address-of operator for overloaded function expression");
2162 FromType =
Atomic->getValueType();
2210 if (
auto *FD = dyn_cast<FunctionDecl>(DRE->getDecl()))
2230 bool IncompatibleObjC =
false;
2285 }
else if (AllowObjCWritebackConversion &&
2289 FromType, IncompatibleObjC)) {
2295 InOverloadResolution, FromType)) {
2299 From, InOverloadResolution, CStyle)) {
2309 S, From, ToType, InOverloadResolution, SCS, CStyle)) {
2345 bool ObjCLifetimeConversion;
2351 ObjCLifetimeConversion)) {
2370 CanonFrom = CanonTo;
2375 if (CanonFrom == CanonTo)
2380 if (S.
getLangOpts().CPlusPlus || !InOverloadResolution)
2424 bool InOverloadResolution,
2434 for (
const auto *it : UD->
fields()) {
2437 ToType = it->getType();
2463 return To->
getKind() == BuiltinType::Int;
2466 return To->
getKind() == BuiltinType::UInt;
2490 if (FromEnumType->getDecl()->isScoped())
2497 if (FromEnumType->getDecl()->isFixed()) {
2498 QualType Underlying = FromEnumType->getDecl()->getIntegerType();
2500 IsIntegralPromotion(
nullptr, Underlying, ToType);
2507 ToType, FromEnumType->getDecl()->getPromotionType());
2532 uint64_t FromSize = Context.
getTypeSize(FromType);
2541 for (
int Idx = 0; Idx < 6; ++Idx) {
2542 uint64_t ToSize = Context.
getTypeSize(PromoteTypes[Idx]);
2543 if (FromSize < ToSize ||
2544 (FromSize == ToSize &&
2545 FromIsSigned == PromoteTypes[Idx]->isSignedIntegerType())) {
2570 std::optional<llvm::APSInt> BitWidth;
2573 MemberDecl->getBitWidth()->getIntegerConstantExpr(Context))) {
2574 llvm::APSInt ToSize(BitWidth->getBitWidth(), BitWidth->isUnsigned());
2578 if (*BitWidth < ToSize ||
2580 return To->
getKind() == BuiltinType::Int;
2586 return To->
getKind() == BuiltinType::UInt;
2614 if (FromBuiltin->getKind() == BuiltinType::Float &&
2615 ToBuiltin->getKind() == BuiltinType::Double)
2622 (FromBuiltin->getKind() == BuiltinType::Float ||
2623 FromBuiltin->getKind() == BuiltinType::Double) &&
2624 (ToBuiltin->getKind() == BuiltinType::LongDouble ||
2625 ToBuiltin->getKind() == BuiltinType::Float128 ||
2626 ToBuiltin->getKind() == BuiltinType::Ibm128))
2631 if (getLangOpts().
HLSL && FromBuiltin->getKind() == BuiltinType::Half &&
2632 (ToBuiltin->getKind() == BuiltinType::Float ||
2633 ToBuiltin->getKind() == BuiltinType::Double))
2637 if (!getLangOpts().NativeHalfType &&
2638 FromBuiltin->getKind() == BuiltinType::Half &&
2639 ToBuiltin->getKind() == BuiltinType::Float)
2671 bool StripObjCLifetime =
false) {
2674 "Invalid similarly-qualified pointer type");
2685 if (StripObjCLifetime)
2696 if (isa<ObjCObjectPointerType>(ToType))
2705 if (isa<ObjCObjectPointerType>(ToType))
2711 bool InOverloadResolution,
2717 return !InOverloadResolution;
2725 bool InOverloadResolution,
2727 bool &IncompatibleObjC) {
2728 IncompatibleObjC =
false;
2729 if (isObjCPointerConversion(FromType, ToType, ConvertedType,
2736 ConvertedType = ToType;
2743 ConvertedType = ToType;
2750 ConvertedType = ToType;
2758 ConvertedType = ToType;
2768 ConvertedType = ToType;
2776 !getLangOpts().ObjCAutoRefCount) {
2806 if (getLangOpts().MSVCCompat && FromPointeeType->
isFunctionType() &&
2840 IsDerivedFrom(From->
getBeginLoc(), FromPointeeType, ToPointeeType)) {
2874 bool &IncompatibleObjC) {
2875 if (!getLangOpts().
ObjC)
2887 if (ToObjCPtr && FromObjCPtr) {
2898 if (getLangOpts().CPlusPlus && LHS && RHS &&
2900 FromObjCPtr->getPointeeType()))
2905 ConvertedType =
AdoptQualifiers(Context, ConvertedType, FromQualifiers);
2913 IncompatibleObjC =
true;
2917 ConvertedType =
AdoptQualifiers(Context, ConvertedType, FromQualifiers);
2929 if (FromObjCPtr && FromObjCPtr->isObjCBuiltinType()) {
2957 isObjCPointerConversion(FromPointeeType, ToPointeeType, ConvertedType,
2958 IncompatibleObjC)) {
2960 IncompatibleObjC =
true;
2962 ConvertedType =
AdoptQualifiers(Context, ConvertedType, FromQualifiers);
2969 isObjCPointerConversion(FromPointeeType, ToPointeeType, ConvertedType,
2970 IncompatibleObjC)) {
2973 ConvertedType =
AdoptQualifiers(Context, ConvertedType, FromQualifiers);
2985 if (FromFunctionType && ToFunctionType) {
2994 if (FromFunctionType->
getNumParams() != ToFunctionType->getNumParams() ||
2995 FromFunctionType->
isVariadic() != ToFunctionType->isVariadic() ||
2996 FromFunctionType->
getMethodQuals() != ToFunctionType->getMethodQuals())
2999 bool HasObjCConversion =
false;
3003 }
else if (isObjCPointerConversion(FromFunctionType->
getReturnType(),
3004 ToFunctionType->getReturnType(),
3005 ConvertedType, IncompatibleObjC)) {
3007 HasObjCConversion =
true;
3014 for (
unsigned ArgIdx = 0, NumArgs = FromFunctionType->
getNumParams();
3015 ArgIdx != NumArgs; ++ArgIdx) {
3017 QualType ToArgType = ToFunctionType->getParamType(ArgIdx);
3021 }
else if (isObjCPointerConversion(FromArgType, ToArgType,
3022 ConvertedType, IncompatibleObjC)) {
3024 HasObjCConversion =
true;
3031 if (HasObjCConversion) {
3035 IncompatibleObjC =
true;
3067 if (!FromFunctionType || !ToFunctionType)
3070 if (Context.
hasSameType(FromPointeeType, ToPointeeType))
3075 if (FromFunctionType->
getNumParams() != ToFunctionType->getNumParams() ||
3076 FromFunctionType->
isVariadic() != ToFunctionType->isVariadic())
3081 if (FromEInfo != ToEInfo)
3084 bool IncompatibleObjC =
false;
3086 ToFunctionType->getReturnType())) {
3090 QualType LHS = ToFunctionType->getReturnType();
3091 if ((!getLangOpts().CPlusPlus || !RHS->
isRecordType()) &&
3097 }
else if (isObjCPointerConversion(RHS, LHS,
3098 ConvertedType, IncompatibleObjC)) {
3099 if (IncompatibleObjC)
3108 for (
unsigned ArgIdx = 0, NumArgs = FromFunctionType->
getNumParams();
3109 ArgIdx != NumArgs; ++ArgIdx) {
3110 IncompatibleObjC =
false;
3112 QualType ToArgType = ToFunctionType->getParamType(ArgIdx);
3113 if (Context.
hasSameType(FromArgType, ToArgType)) {
3115 }
else if (isObjCPointerConversion(ToArgType, FromArgType,
3116 ConvertedType, IncompatibleObjC)) {
3117 if (IncompatibleObjC)
3126 bool CanUseToFPT, CanUseFromFPT;
3128 CanUseToFPT, CanUseFromFPT,
3132 ConvertedType = ToType;
3170 if (!Context.
hasSameType(FromMember->getClass(), ToMember->getClass())) {
3172 <<
QualType(FromMember->getClass(), 0);
3205 if (!FromFunction || !ToFunction) {
3210 if (FromFunction->
getNumParams() != ToFunction->getNumParams()) {
3218 if (!FunctionParamTypesAreEqual(FromFunction, ToFunction, &ArgPos)) {
3220 << ToFunction->getParamType(ArgPos)
3227 ToFunction->getReturnType())) {
3233 if (FromFunction->
getMethodQuals() != ToFunction->getMethodQuals()) {
3243 cast<FunctionProtoType>(ToFunction->getCanonicalTypeUnqualified())
3256 assert(llvm::size(Old) == llvm::size(New) &&
3257 "Can't compare parameters of functions with different number of "
3260 for (
auto &&[Idx,
Type] : llvm::enumerate(Old)) {
3262 size_t J =
Reversed ? (llvm::size(New) - Idx - 1) : Idx;
3283 return FunctionParamTypesAreEqual(OldType->
param_types(),
3296 unsigned OldIgnore =
3298 unsigned NewIgnore =
3301 auto *OldPT = cast<FunctionProtoType>(OldFunction->
getFunctionType());
3302 auto *NewPT = cast<FunctionProtoType>(NewFunction->
getFunctionType());
3304 return FunctionParamTypesAreEqual(OldPT->param_types().slice(OldIgnore),
3305 NewPT->param_types().slice(NewIgnore),
3312 bool IgnoreBaseAccess,
3315 bool IsCStyleOrFunctionalCast = IgnoreBaseAccess;
3319 if (Diagnose && !IsCStyleOrFunctionalCast && !FromType->
isAnyPointerType() &&
3323 DiagRuntimeBehavior(From->
getExprLoc(), From,
3324 PDiag(diag::warn_impcast_bool_to_null_pointer)
3326 else if (!isUnevaluatedContext())
3335 if (FromPointeeType->
isRecordType() && ToPointeeType->isRecordType() &&
3339 unsigned InaccessibleID = 0;
3340 unsigned AmbiguousID = 0;
3342 InaccessibleID = diag::err_upcast_to_inaccessible_base;
3343 AmbiguousID = diag::err_ambiguous_derived_to_base_conv;
3345 if (CheckDerivedToBaseConversion(
3346 FromPointeeType, ToPointeeType, InaccessibleID, AmbiguousID,
3348 &BasePath, IgnoreBaseAccess))
3352 Kind = CK_DerivedToBase;
3355 if (Diagnose && !IsCStyleOrFunctionalCast &&
3356 FromPointeeType->
isFunctionType() && ToPointeeType->isVoidType()) {
3357 assert(getLangOpts().MSVCCompat &&
3358 "this should only be possible with MSVCCompat!");
3370 if (FromPtrType->isObjCBuiltinType() || ToPtrType->isObjCBuiltinType())
3373 Kind = CK_BlockPointerToObjCPointerCast;
3375 Kind = CK_CPointerToObjCPointerCast;
3379 Kind = CK_AnyPointerToBlockPointerCast;
3385 Kind = CK_NullToPointer;
3392 bool InOverloadResolution,
3402 ConvertedType = ToType;
3417 IsDerivedFrom(From->
getBeginLoc(), ToClass, FromClass)) {
3429 bool IgnoreBaseAccess) {
3436 "Expr must be null pointer constant!");
3437 Kind = CK_NullToMemberPointer;
3442 assert(ToPtrType &&
"No member pointer cast has a target type "
3443 "that is not a member pointer.");
3449 assert(FromClass->
isRecordType() &&
"Pointer into non-class.");
3450 assert(ToClass->
isRecordType() &&
"Pointer into non-class.");
3454 bool DerivationOkay =
3455 IsDerivedFrom(From->
getBeginLoc(), ToClass, FromClass, Paths);
3456 assert(DerivationOkay &&
3457 "Should not have been called if derivation isn't OK.");
3458 (void)DerivationOkay;
3461 getUnqualifiedType())) {
3462 std::string PathDisplayStr = getAmbiguousPathsDisplayString(Paths);
3464 << 0 << FromClass << ToClass << PathDisplayStr << From->
getSourceRange();
3468 if (
const RecordType *VBase = Paths.getDetectedVirtual()) {
3470 << FromClass << ToClass <<
QualType(VBase, 0)
3475 if (!IgnoreBaseAccess)
3476 CheckBaseClassAccess(From->
getExprLoc(), FromClass, ToClass,
3478 diag::err_downcast_from_inaccessible_base);
3482 Kind = CK_BaseToDerivedMemberPointer;
3505 bool CStyle,
bool IsTopLevel,
3506 bool &PreviousToQualsIncludeConst,
3507 bool &ObjCLifetimeConversion) {
3519 ObjCLifetimeConversion =
true;
3555 !PreviousToQualsIncludeConst)
3573 PreviousToQualsIncludeConst =
3574 PreviousToQualsIncludeConst && ToQuals.
hasConst();
3580 bool CStyle,
bool &ObjCLifetimeConversion) {
3583 ObjCLifetimeConversion =
false;
3593 bool PreviousToQualsIncludeConst =
true;
3594 bool UnwrappedAnyPointer =
false;
3597 FromType, ToType, CStyle, !UnwrappedAnyPointer,
3598 PreviousToQualsIncludeConst, ObjCLifetimeConversion))
3600 UnwrappedAnyPointer =
true;
3617 bool InOverloadResolution,
3626 InOverloadResolution, InnerSCS,
3643 if (CtorType->getNumParams() > 0) {
3644 QualType FirstArg = CtorType->getParamType(0);
3656 bool AllowExplicit) {
3663 bool Usable = !Info.Constructor->isInvalidDecl() &&
3666 bool SuppressUserConversions =
false;
3667 if (Info.ConstructorTmpl)
3670 CandidateSet, SuppressUserConversions,
3675 CandidateSet, SuppressUserConversions,
3676 false, AllowExplicit);
3680 bool HadMultipleCandidates = (CandidateSet.
size() > 1);
3689 QualType ThisType = Constructor->getFunctionObjectParameterType();
3707 llvm_unreachable(
"Invalid OverloadResult!");
3729 bool AllowObjCConversionOnExplicit) {
3730 assert(AllowExplicit != AllowedExplicit::None ||
3731 !AllowObjCConversionOnExplicit);
3735 bool ConstructorsOnly =
false;
3751 ConstructorsOnly =
true;
3756 = dyn_cast<CXXRecordDecl>(ToRecordType->getDecl())) {
3758 Expr **Args = &From;
3759 unsigned NumArgs = 1;
3760 bool ListInitializing =
false;
3761 if (
InitListExpr *InitList = dyn_cast<InitListExpr>(From)) {
3764 S, From, ToType, ToRecordDecl, User, CandidateSet,
3765 AllowExplicit == AllowedExplicit::All);
3774 Args = InitList->getInits();
3775 NumArgs = InitList->getNumInits();
3776 ListInitializing =
true;
3784 bool Usable = !Info.Constructor->isInvalidDecl();
3785 if (!ListInitializing)
3786 Usable = Usable && Info.Constructor->isConvertingConstructor(
3789 bool SuppressUserConversions = !ConstructorsOnly;
3797 if (SuppressUserConversions && ListInitializing) {
3798 SuppressUserConversions =
3799 NumArgs == 1 && isa<InitListExpr>(Args[0]) &&
3803 if (Info.ConstructorTmpl)
3805 Info.ConstructorTmpl, Info.FoundDecl,
3807 CandidateSet, SuppressUserConversions,
3809 AllowExplicit == AllowedExplicit::All);
3815 SuppressUserConversions,
3817 AllowExplicit == AllowedExplicit::All);
3824 if (ConstructorsOnly || isa<InitListExpr>(From)) {
3827 }
else if (
const RecordType *FromRecordType =
3830 = dyn_cast<CXXRecordDecl>(FromRecordType->getDecl())) {
3832 const auto &Conversions = FromRecordDecl->getVisibleConversionFunctions();
3833 for (
auto I = Conversions.begin(),
E = Conversions.end(); I !=
E; ++I) {
3837 if (isa<UsingShadowDecl>(
D))
3838 D = cast<UsingShadowDecl>(
D)->getTargetDecl();
3842 if ((ConvTemplate = dyn_cast<FunctionTemplateDecl>(
D)))
3845 Conv = cast<CXXConversionDecl>(
D);
3849 ConvTemplate, FoundDecl, ActingContext, From, ToType,
3850 CandidateSet, AllowObjCConversionOnExplicit,
3851 AllowExplicit != AllowedExplicit::None);
3854 CandidateSet, AllowObjCConversionOnExplicit,
3855 AllowExplicit != AllowedExplicit::None);
3860 bool HadMultipleCandidates = (CandidateSet.
size() > 1);
3869 = dyn_cast<CXXConstructorDecl>(Best->Function)) {
3876 if (isa<InitListExpr>(From)) {
3880 if (Best->Conversions[0].isEllipsis())
3883 User.
Before = Best->Conversions[0].Standard;
3896 = dyn_cast<CXXConversionDecl>(Best->Function)) {
3903 User.
Before = Best->Conversions[0].Standard;
3918 User.
After = Best->FinalConversion;
3921 llvm_unreachable(
"Not a constructor or conversion function?");
3930 llvm_unreachable(
"Invalid OverloadResult!");
3940 CandidateSet, AllowedExplicit::None,
false);
3954 if (!RequireCompleteType(From->
getBeginLoc(), ToType,
3955 diag::err_typecheck_nonviable_condition_incomplete,
3962 *
this, From, Cands);
3988 if (!Conv1 || !Conv2)
4003 if (Block1 != Block2)
4016 if (Conv1FuncRet && Conv2FuncRet &&
4027 CallOpProto->isVariadic(),
false);
4029 CallOpProto->isVariadic(),
true);
4031 CallingConv PrefOrder[] = {DefaultFree, DefaultMember, CallOpCC};
4126 if (!ICS1.
isBad()) {
4127 bool StdInit1 =
false, StdInit2 =
false;
4134 if (StdInit1 != StdInit2)
4145 CAT2->getElementType())) {
4147 if (CAT1->getSize() != CAT2->getSize())
4149 return CAT1->getSize().ult(CAT2->getSize())
4271 return FixedEnumPromotion::None;
4275 return FixedEnumPromotion::None;
4278 if (!
Enum->isFixed())
4279 return FixedEnumPromotion::None;
4283 return FixedEnumPromotion::ToUnderlyingType;
4285 return FixedEnumPromotion::ToPromotedUnderlyingType;
4314 else if (Rank2 < Rank1)
4337 if (FEP1 != FixedEnumPromotion::None && FEP2 != FixedEnumPromotion::None &&
4339 return FEP1 == FixedEnumPromotion::ToUnderlyingType
4349 bool SCS1ConvertsToVoid
4351 bool SCS2ConvertsToVoid
4353 if (SCS1ConvertsToVoid != SCS2ConvertsToVoid) {
4358 }
else if (!SCS1ConvertsToVoid && !SCS2ConvertsToVoid) {
4364 }
else if (SCS1ConvertsToVoid && SCS2ConvertsToVoid &&
4393 if (FromObjCPtr1 && FromObjCPtr2) {
4398 if (AssignLeft != AssignRight) {
4433 if (UnqualT1 == UnqualT2) {
4445 if (isa<ArrayType>(T1) && T1Quals)
4447 if (isa<ArrayType>(T2) && T2Quals)
4495 if (SCS1IsCompatibleVectorConversion != SCS2IsCompatibleVectorConversion)
4496 return SCS1IsCompatibleVectorConversion
4503 bool SCS1IsCompatibleSVEVectorConversion =
4505 bool SCS2IsCompatibleSVEVectorConversion =
4508 if (SCS1IsCompatibleSVEVectorConversion !=
4509 SCS2IsCompatibleSVEVectorConversion)
4510 return SCS1IsCompatibleSVEVectorConversion
4517 bool SCS1IsCompatibleRVVVectorConversion =
4519 bool SCS2IsCompatibleRVVVectorConversion =
4522 if (SCS1IsCompatibleRVVVectorConversion !=
4523 SCS2IsCompatibleRVVVectorConversion)
4524 return SCS1IsCompatibleRVVVectorConversion
4564 if (UnqualT1 == UnqualT2)
4582 bool ObjCLifetimeConversion;
4592 if (CanPick1 != CanPick2)
4646 if (FromPointee1 == FromPointee2 && ToPointee1 != ToPointee2) {
4654 if (FromPointee1 != FromPointee2 && ToPointee1 == ToPointee2) {
4671 if (FromPtr1 && FromPtr2 && ToPtr1 && ToPtr2) {
4678 bool FromAssignRight
4687 if (ToPtr1->isObjCIdType() &&
4688 (ToPtr2->isObjCQualifiedIdType() || ToPtr2->getInterfaceDecl()))
4690 if (ToPtr2->isObjCIdType() &&
4691 (ToPtr1->isObjCQualifiedIdType() || ToPtr1->getInterfaceDecl()))
4696 if (ToPtr1->isObjCQualifiedIdType() && ToPtr2->getInterfaceDecl())
4698 if (ToPtr2->isObjCQualifiedIdType() && ToPtr1->getInterfaceDecl())
4703 if (ToPtr1->isObjCClassType() &&
4704 (ToPtr2->isObjCQualifiedClassType() || ToPtr2->getInterfaceDecl()))
4706 if (ToPtr2->isObjCClassType() &&
4707 (ToPtr1->isObjCQualifiedClassType() || ToPtr1->getInterfaceDecl()))
4712 if (ToPtr1->isObjCQualifiedClassType() && ToPtr2->getInterfaceDecl())
4714 if (ToPtr2->isObjCQualifiedClassType() && ToPtr1->getInterfaceDecl())
4720 (ToAssignLeft != ToAssignRight)) {
4731 }
else if (IsSecondSame)
4740 (FromAssignLeft != FromAssignRight))
4754 const Type *FromPointeeType1 = FromMemPointer1->getClass();
4755 const Type *ToPointeeType1 = ToMemPointer1->
getClass();
4756 const Type *FromPointeeType2 = FromMemPointer2->
getClass();
4757 const Type *ToPointeeType2 = ToMemPointer2->
getClass();
4763 if (FromPointee1 == FromPointee2 && ToPointee1 != ToPointee2) {
4770 if (ToPointee1 == ToPointee2 && FromPointee1 != FromPointee2) {
4808 if (!
T.getQualifiers().hasUnaligned())
4822 "T1 must be the pointee type of the reference type");
4823 assert(!OrigT2->
isReferenceType() &&
"T2 cannot be a reference type");
4847 if (UnqualT1 == UnqualT2) {
4849 }
else if (isCompleteType(
Loc, OrigT2) &&
4850 IsDerivedFrom(
Loc, UnqualT2, UnqualT1))
4851 Conv |= ReferenceConversions::DerivedToBase;
4855 Conv |= ReferenceConversions::ObjC;
4857 IsFunctionConversion(UnqualT2, UnqualT1, ConvertedT2)) {
4858 Conv |= ReferenceConversions::Function;
4860 return Ref_Compatible;
4862 bool ConvertedReferent = Conv != 0;
4866 bool PreviousToQualsIncludeConst =
true;
4867 bool TopLevel =
true;
4873 Conv |= ReferenceConversions::Qualification;
4879 Conv |= ReferenceConversions::NestedQualification;
4887 bool ObjCLifetimeConversion =
false;
4889 PreviousToQualsIncludeConst,
4890 ObjCLifetimeConversion))
4896 if (ObjCLifetimeConversion)
4897 Conv |= ReferenceConversions::ObjCLifetime;
4916 bool AllowExplicit) {
4917 assert(T2->
isRecordType() &&
"Can only find conversions of record types.");
4922 const auto &Conversions = T2RecordDecl->getVisibleConversionFunctions();
4923 for (
auto I = Conversions.begin(),
E = Conversions.end(); I !=
E; ++I) {
4926 if (isa<UsingShadowDecl>(
D))
4927 D = cast<UsingShadowDecl>(
D)->getTargetDecl();
4930 = dyn_cast<FunctionTemplateDecl>(
D);
4935 Conv = cast<CXXConversionDecl>(
D);
4947 if (!ConvTemplate &&
4971 ConvTemplate, I.getPair(), ActingDC,
Init, DeclType, CandidateSet,
4972 false, AllowExplicit);
4975 Conv, I.getPair(), ActingDC,
Init, DeclType, CandidateSet,
4976 false, AllowExplicit);
4979 bool HadMultipleCandidates = (CandidateSet.
size() > 1);
4994 if (!Best->FinalConversion.DirectBinding)
5006 "Expected a direct reference binding!");
5012 Cand != CandidateSet.
end(); ++Cand)
5024 llvm_unreachable(
"Invalid OverloadResult!");
5032 bool SuppressUserConversions,
5033 bool AllowExplicit) {
5034 assert(DeclType->
isReferenceType() &&
"Reference init needs a reference");
5061 auto SetAsReferenceBinding = [&](
bool BindsDirectly) {
5066 ICS.
Standard.
Second = (RefConv & Sema::ReferenceConversions::DerivedToBase)
5068 : (RefConv & Sema::ReferenceConversions::ObjC)
5076 Sema::ReferenceConversions::NestedQualification)
5090 (RefConv & Sema::ReferenceConversions::ObjCLifetime) != 0;
5113 SetAsReferenceBinding(
true);
5162 SetAsReferenceBinding(S.
getLangOpts().CPlusPlus11 ||
5253 AllowedExplicit::None,
5278 if (isRValRef && LValRefType) {
5296 bool SuppressUserConversions,
5297 bool InOverloadResolution,
5298 bool AllowObjCWritebackConversion,
5299 bool AllowExplicit =
false);
5305 bool SuppressUserConversions,
5306 bool InOverloadResolution,
5307 bool AllowObjCWritebackConversion) {
5320 if (
const auto *IAT = dyn_cast<IncompleteArrayType>(AT))
5322 InitTy = IAT->getElementType();
5348 if (From->
getNumInits() == 1 && !IsDesignatedInit) {
5354 SuppressUserConversions,
5355 InOverloadResolution,
5356 AllowObjCWritebackConversion);
5365 Result.Standard.setAsIdentityConversion();
5366 Result.Standard.setFromType(ToType);
5367 Result.Standard.setAllToTypes(ToType);
5392 bool IsUnbounded =
false;
5396 if (CT->getSize().ult(e)) {
5400 Result.setInitializerListContainerType(ContTy, IsUnbounded);
5403 if (CT->getSize().ugt(e)) {
5409 S, &EmptyList, InitTy, SuppressUserConversions,
5410 InOverloadResolution, AllowObjCWritebackConversion);
5411 if (DfltElt.
isBad()) {
5415 Result.setInitializerListContainerType(ContTy, IsUnbounded);
5420 assert(isa<IncompleteArrayType>(AT) &&
"Expected incomplete array");
5426 Result.setInitializerListContainerType(ContTy, IsUnbounded);
5436 Result.Standard.setAsIdentityConversion();
5437 Result.Standard.setFromType(InitTy);
5438 Result.Standard.setAllToTypes(InitTy);
5439 for (
unsigned i = 0; i < e; ++i) {
5442 S,
Init, InitTy, SuppressUserConversions, InOverloadResolution,
5443 AllowObjCWritebackConversion);
5454 Result.setInitializerListContainerType(ContTy, IsUnbounded);
5468 Result.setInitializerListContainerType(ContTy, IsUnbounded);
5482 AllowedExplicit::None,
5483 InOverloadResolution,
false,
5484 AllowObjCWritebackConversion,
5503 Result.UserDefined.Before.setAsIdentityConversion();
5508 Result.UserDefined.After.setAsIdentityConversion();
5509 Result.UserDefined.After.setFromType(ToType);
5510 Result.UserDefined.After.setAllToTypes(ToType);
5511 Result.UserDefined.ConversionFunction =
nullptr;
5528 if (From->
getNumInits() == 1 && !IsDesignatedInit) {
5549 SuppressUserConversions,
5557 InOverloadResolution,
5558 AllowObjCWritebackConversion);
5561 assert(!
Result.isEllipsis() &&
5562 "Sub-initialization cannot result in ellipsis conversion.");
5568 Result.UserDefined.After;
5589 if (NumInits == 1 && !isa<InitListExpr>(From->
getInit(0)))
5591 SuppressUserConversions,
5592 InOverloadResolution,
5593 AllowObjCWritebackConversion);
5596 else if (NumInits == 0) {
5598 Result.Standard.setAsIdentityConversion();
5599 Result.Standard.setFromType(ToType);
5600 Result.Standard.setAllToTypes(ToType);
5619 bool SuppressUserConversions,
5620 bool InOverloadResolution,
5621 bool AllowObjCWritebackConversion,
5622 bool AllowExplicit) {
5623 if (
InitListExpr *FromInitList = dyn_cast<InitListExpr>(From))
5625 InOverloadResolution,AllowObjCWritebackConversion);
5630 SuppressUserConversions, AllowExplicit);
5633 SuppressUserConversions,
5634 AllowedExplicit::None,
5635 InOverloadResolution,
5637 AllowObjCWritebackConversion,
5650 return !ICS.
isBad();
5659 const CXXRecordDecl *ActingContext,
bool InOverloadResolution =
false,
5661 bool SuppressUserConversion =
false) {
5669 assert(FromClassification.
isLValue());
5681 if (ExplicitParameterType.isNull())
5684 ValueKindFromClassification(FromClassification));
5686 S, &TmpExpr, ExplicitParameterType, SuppressUserConversion,
5704 if (isa<CXXDestructorDecl>(Method) || Method->
isStatic()) {
5741 FromType, ImplicitParamType);
5750 FromType, ImplicitParamType);
5765 FromType, ImplicitParamType);
5785 if (!FromClassification.
isRValue()) {
5825 FromRecordType = From->
getType();
5826 DestType = ImplicitParamRecordType;
5827 FromClassification = From->
Classify(Context);
5831 From = CreateMaterializeTemporaryExpr(FromRecordType, From,
5850 << Method->
getDeclName() << FromRecordType << (CVR - 1)
5861 bool IsRValueQualified =
5865 << IsRValueQualified;
5877 llvm_unreachable(
"Lists are not objects");
5880 return Diag(From->
getBeginLoc(), diag::err_member_function_call_bad_type)
5881 << ImplicitParamRecordType << FromRecordType
5887 PerformObjectMemberConversion(From, Qualifier, FoundDecl, Method);
5890 From = FromRes.
get();
5899 CK = CK_AddressSpaceConversion;
5902 From = ImpCastExprToType(From, DestType, CK, From->
getValueKind()).get();
5924 AllowedExplicit::Conversions,
5937 return PerformImplicitConversion(From, Context.
BoolTy, ICS, AA_Converting);
5939 if (!DiagnoseMultipleUserDefinedConversion(From, Context.
BoolTy))
6004 llvm_unreachable(
"found a first conversion kind in Second");
6008 llvm_unreachable(
"found a third conversion kind in Second");
6014 llvm_unreachable(
"unknown conversion kind");
6026 "converted constant expression outside C++11");
6059 diag::err_typecheck_converted_constant_expression)
6065 llvm_unreachable(
"bad conversion in converted constant expression");
6071 diag::err_typecheck_converted_constant_expression_disallowed)
6077 diag::err_typecheck_converted_constant_expression_indirect)
6087 diag::err_reference_bind_to_bitfield_in_cce)
6097 "unexpected class type converted constant expr");
6100 T, cast<NonTypeTemplateParmDecl>(Dest)),
6117 bool ReturnPreNarrowingValue =
false;
6120 PreNarrowingType)) {
6133 PreNarrowingValue.
isInt()) {
6136 ReturnPreNarrowingValue =
true;
6148 << CCE << 0 << From->
getType() <<
T;
6151 if (!ReturnPreNarrowingValue)
6152 PreNarrowingValue = {};
6169 if (
Result.isInvalid() ||
Result.get()->isValueDependent()) {
6174 RequireInt, PreNarrowingValue);
6181 return ::BuildConvertedConstantExpression(*
this, From,
T, CCE, Dest,
6188 return ::CheckConvertedConstantExpression(*
this, From,
T,
Value, CCE,
false,
6193 llvm::APSInt &
Value,
6200 if (!R.isInvalid() && !R.get()->isValueDependent())
6208 const APValue &PreNarrowingValue) {
6218 Kind = ConstantExprKind::ClassTemplateArgument;
6220 Kind = ConstantExprKind::NonClassTemplateArgument;
6222 Kind = ConstantExprKind::Normal;
6225 (RequireInt && !Eval.
Val.
isInt())) {
6232 if (Notes.empty()) {
6235 if (
const auto *CE = dyn_cast<ConstantExpr>(
E)) {
6239 "ConstantExpr has no value associated with it");
6245 Value = std::move(PreNarrowingValue);
6251 if (Notes.size() == 1 &&
6252 Notes[0].second.getDiagID() == diag::note_invalid_subexpr_in_const_expr) {
6253 Diag(Notes[0].first, diag::err_expr_not_cce) << CCE;
6254 }
else if (!Notes.empty() && Notes[0].second.getDiagID() ==
6255 diag::note_constexpr_invalid_template_arg) {
6256 Notes[0].second.setDiagID(diag::err_constexpr_invalid_template_arg);
6257 for (
unsigned I = 0; I < Notes.size(); ++I)
6258 Diag(Notes[I].first, Notes[I].second);
6262 for (
unsigned I = 0; I < Notes.size(); ++I)
6263 Diag(Notes[I].first, Notes[I].second);
6290 AllowedExplicit::Conversions,
6324 return PerformImplicitConversion(From, Ty, ICS, AA_Converting);
6330 assert((isa<UnresolvedMemberExpr, MemberExpr>(MemExprE)) &&
6331 "expected a member expression");
6333 if (
const auto M = dyn_cast<UnresolvedMemberExpr>(MemExprE);
6334 M && !M->isImplicitAccess())
6335 Base = M->getBase();
6336 else if (
const auto M = dyn_cast<MemberExpr>(MemExprE);
6337 M && !M->isImplicitAccess())
6338 Base = M->getBase();
6377 "Method is not an explicit member function");
6378 assert(NewArgs.empty() &&
"NewArgs should be empty");
6380 NewArgs.reserve(Args.size() + 1);
6382 NewArgs.push_back(This);
6383 NewArgs.append(Args.begin(), Args.end());
6386 Method, Object->getBeginLoc());
6405 for (
unsigned I = 0, N = ViableConversions.
size(); I != N; ++I) {
6407 cast<CXXConversionDecl>(ViableConversions[I]->getUnderlyingDecl());
6419 if (ExplicitConversions.
size() == 1 && !Converter.
Suppress) {
6422 cast<CXXConversionDecl>(
Found->getUnderlyingDecl());
6427 std::string TypeStr;
6432 "static_cast<" + TypeStr +
">(")
6444 HadMultipleCandidates);
6451 From,
Result.get()->getType());
6464 cast<CXXConversionDecl>(
Found->getUnderlyingDecl());
6477 HadMultipleCandidates);
6482 CK_UserDefinedConversion,
Result.get(),
6483 nullptr,
Result.get()->getValueKind(),
6502 for (
unsigned I = 0, N = ViableConversions.
size(); I != N; ++I) {
6506 if (isa<UsingShadowDecl>(
D))
6507 D = cast<UsingShadowDecl>(
D)->getTargetDecl();
6511 if ((ConvTemplate = dyn_cast<FunctionTemplateDecl>(
D)))
6514 Conv = cast<CXXConversionDecl>(
D);
6518 ConvTemplate, FoundDecl, ActingContext, From, ToType, CandidateSet,
6522 ToType, CandidateSet,
6554 ExprResult result = CheckPlaceholderExpr(From);
6557 From = result.
get();
6561 ExprResult Converted = DefaultLvalueConversion(From);
6572 if (!RecordTy || !getLangOpts().CPlusPlus) {
6584 : Converter(Converter), From(From) {}
6589 } IncompleteDiagnoser(Converter, From);
6592 : RequireCompleteType(
Loc,
T, IncompleteDiagnoser))
6599 const auto &Conversions =
6600 cast<CXXRecordDecl>(RecordTy->
getDecl())->getVisibleConversionFunctions();
6602 bool HadMultipleCandidates =
6603 (std::distance(Conversions.begin(), Conversions.end()) > 1);
6607 bool HasUniqueTargetType =
true;
6610 for (
auto I = Conversions.begin(),
E = Conversions.end(); I !=
E; ++I) {
6620 Conversion = cast<CXXConversionDecl>(
D);
6622 assert((!ConvTemplate || getLangOpts().
CPlusPlus14) &&
6623 "Conversion operator templates are considered potentially "
6627 if (Converter.
match(CurToType) || ConvTemplate) {
6633 ExplicitConversions.
addDecl(I.getDecl(), I.getAccess());
6638 else if (HasUniqueTargetType &&
6640 HasUniqueTargetType =
false;
6642 ViableConversions.
addDecl(I.getDecl(), I.getAccess());
6660 HadMultipleCandidates,
6661 ExplicitConversions))
6667 if (!HasUniqueTargetType)
6686 HadMultipleCandidates,
Found))
6695 HadMultipleCandidates,
6696 ExplicitConversions))
6704 switch (ViableConversions.
size()) {
6707 HadMultipleCandidates,
6708 ExplicitConversions))
6718 HadMultipleCandidates,
Found))
6749 if (Proto->getNumParams() < 1)
6753 QualType ArgType = Proto->getParamType(0).getNonReferenceType();
6758 if (Proto->getNumParams() < 2)
6762 QualType ArgType = Proto->getParamType(1).getNonReferenceType();
6782 unsigned SeenAt = 0;
6784 bool HasDefault =
false;
6793 return HasDefault || SeenAt != 0;
6799 bool PartialOverloading,
bool AllowExplicit,
bool AllowExplicitConversions,
6804 assert(Proto &&
"Functions without a prototype cannot be overloaded");
6805 assert(!
Function->getDescribedFunctionTemplate() &&
6806 "Use AddTemplateOverloadCandidate for function templates");
6809 if (!isa<CXXConstructorDecl>(Method)) {
6819 CandidateSet, SuppressUserConversions,
6820 PartialOverloading, EarlyConversions, PO);
6834 if (Constructor && Constructor->isDefaulted() && Constructor->isDeleted() &&
6835 Constructor->isMoveConstructor())
6855 CandidateSet.
addCandidate(Args.size(), EarlyConversions);
6868 Candidate.
Viable =
false;
6874 if (getLangOpts().CPlusPlusModules &&
Function->isInAnotherModuleUnit()) {
6881 if (
auto *SpecInfo =
Function->getTemplateSpecializationInfo())
6882 ND = SpecInfo->getTemplate();
6885 Candidate.
Viable =
false;
6892 Candidate.
Viable =
false;
6902 if (Args.size() == 1 && Constructor->isSpecializationCopyingObject() &&
6904 IsDerivedFrom(Args[0]->getBeginLoc(), Args[0]->getType(),
6906 Candidate.
Viable =
false;
6918 auto *Shadow = dyn_cast<ConstructorUsingShadowDecl>(FoundDecl.getDecl());
6919 if (Shadow && Args.size() == 1 && Constructor->getNumParams() >= 1 &&
6920 Constructor->getParamDecl(0)->getType()->isReferenceType()) {
6921 QualType P = Constructor->getParamDecl(0)->getType()->getPointeeType();
6927 Candidate.
Viable =
false;
6936 Constructor->getMethodQualifiers().getAddressSpace(),
6938 Candidate.
Viable =
false;
6951 Candidate.
Viable =
false;
6961 unsigned MinRequiredArgs =
Function->getMinRequiredArguments();
6962 if (!AggregateCandidateDeduction && Args.size() < MinRequiredArgs &&
6963 !PartialOverloading) {
6965 Candidate.
Viable =
false;
6971 if (getLangOpts().
CUDA) {
6979 Candidate.
Viable =
false;
6985 if (
Function->getTrailingRequiresClause()) {
6987 if (CheckFunctionConstraints(
Function, Satisfaction, {},
6990 Candidate.
Viable =
false;
6998 for (
unsigned ArgIdx = 0; ArgIdx < Args.size(); ++ArgIdx) {
7001 if (Candidate.
Conversions[ConvIdx].isInitialized()) {
7004 }
else if (ArgIdx < NumParams) {
7011 *
this, Args[ArgIdx], ParamType, SuppressUserConversions,
7014 getLangOpts().ObjCAutoRefCount, AllowExplicitConversions);
7016 Candidate.
Viable =
false;
7028 if (EnableIfAttr *FailedAttr =
7030 Candidate.
Viable =
false;
7040 if (Methods.size() <= 1)
7043 for (
unsigned b = 0, e = Methods.size();
b < e;
b++) {
7051 if (Args.size() < NumNamedArgs)
7054 for (
unsigned i = 0; i < NumNamedArgs; i++) {
7056 if (Args[i]->isTypeDependent()) {
7062 Expr *argExpr = Args[i];
7063 assert(argExpr &&
"SelectBestMethod(): missing expression");
7068 !param->
hasAttr<CFConsumedAttr>())
7069 argExpr =
ObjC().stripARCUnbridgedCast(argExpr);
7082 getLangOpts().ObjCAutoRefCount,
7086 if (ConversionState.
isBad() ||
7096 for (
unsigned i = NumNamedArgs, e = Args.size(); i < e; ++i) {
7097 if (Args[i]->isTypeDependent()) {
7101 ExprResult Arg = DefaultVariadicArgumentPromotion(Args[i], VariadicMethod,
7110 if (Args.size() != NumNamedArgs)
7112 else if (Match && NumNamedArgs == 0 && Methods.size() > 1) {
7115 for (
unsigned b = 0, e = Methods.size();
b < e;
b++) {
7116 QualType ReturnT = Methods[
b]->getReturnType();
7135 assert(!isa<CXXConstructorDecl>(Method) &&
7136 "Shouldn't have `this` for ctors!");
7137 assert(!Method->
isStatic() &&
"Shouldn't have `this` for static methods!");
7139 ThisArg,
nullptr, Method, Method);
7142 ConvertedThis = R.
get();
7144 if (
auto *MD = dyn_cast<CXXMethodDecl>(
Function)) {
7146 assert((MissingImplicitThis || MD->isStatic() ||
7147 isa<CXXConstructorDecl>(MD)) &&
7148 "Expected `this` for non-ctor instance methods");
7150 ConvertedThis =
nullptr;
7155 unsigned ArgSizeNoVarargs = std::min(
Function->param_size(), Args.size());
7158 for (
unsigned I = 0; I != ArgSizeNoVarargs; ++I) {
7167 ConvertedArgs.push_back(R.
get());
7175 for (
unsigned i = Args.size(), e =
Function->getNumParams(); i != e; ++i) {
7177 if (!
P->hasDefaultArg())
7182 ConvertedArgs.push_back(R.
get());
7194 bool MissingImplicitThis) {
7195 auto EnableIfAttrs =
Function->specific_attrs<EnableIfAttr>();
7196 if (EnableIfAttrs.begin() == EnableIfAttrs.end())
7202 Expr *DiscardedThis;
7204 *
this,
Function,
nullptr, CallLoc, Args, Trap,
7205 true, DiscardedThis, ConvertedArgs))
7206 return *EnableIfAttrs.begin();
7208 for (
auto *EIA : EnableIfAttrs) {
7212 if (EIA->getCond()->isValueDependent() ||
7213 !EIA->getCond()->EvaluateWithSubstitution(
7217 if (!
Result.isInt() || !
Result.getInt().getBoolValue())
7223template <
typename CheckFn>
7226 CheckFn &&IsSuccessful) {
7229 if (ArgDependent == DIA->getArgDependent())
7230 Attrs.push_back(DIA);
7237 auto WarningBegin = std::stable_partition(
7238 Attrs.begin(), Attrs.end(),
7239 [](
const DiagnoseIfAttr *DIA) { return DIA->isError(); });
7243 auto ErrAttr = llvm::find_if(llvm::make_range(Attrs.begin(), WarningBegin),
7245 if (ErrAttr != WarningBegin) {
7246 const DiagnoseIfAttr *DIA = *ErrAttr;
7247 S.
Diag(
Loc, diag::err_diagnose_if_succeeded) << DIA->getMessage();
7248 S.
Diag(DIA->getLocation(), diag::note_from_diagnose_if)
7249 << DIA->getParent() << DIA->getCond()->getSourceRange();
7253 for (
const auto *DIA : llvm::make_range(WarningBegin, Attrs.end()))
7254 if (IsSuccessful(DIA)) {
7255 S.
Diag(
Loc, diag::warn_diagnose_if_succeeded) << DIA->getMessage();
7256 S.
Diag(DIA->getLocation(), diag::note_from_diagnose_if)
7257 << DIA->getParent() << DIA->getCond()->getSourceRange();
7264 const Expr *ThisArg,
7269 [&](
const DiagnoseIfAttr *DIA) {
7274 if (!DIA->getCond()->EvaluateWithSubstitution(
7275 Result, Context, cast<FunctionDecl>(DIA->getParent()), Args, ThisArg))
7277 return Result.isInt() &&
Result.getInt().getBoolValue();
7284 *
this, ND,
false,
Loc,
7285 [&](
const DiagnoseIfAttr *DIA) {
7296 bool SuppressUserConversions,
7297 bool PartialOverloading,
7298 bool FirstArgumentIsBase) {
7300 NamedDecl *
D = F.getDecl()->getUnderlyingDecl();
7307 if (isa<CXXMethodDecl>(FD) && !cast<CXXMethodDecl>(FD)->isStatic()) {
7310 if (Args.size() > 0) {
7311 if (
Expr *
E = Args[0]) {
7319 ObjectClassification =
E->
Classify(Context);
7321 FunctionArgs = Args.slice(1);
7324 AddMethodTemplateCandidate(
7325 FunTmpl, F.getPair(),
7327 ExplicitTemplateArgs, ObjectType, ObjectClassification,
7328 FunctionArgs, CandidateSet, SuppressUserConversions,
7329 PartialOverloading);
7331 AddMethodCandidate(cast<CXXMethodDecl>(FD), F.getPair(),
7332 cast<CXXMethodDecl>(FD)->getParent(), ObjectType,
7333 ObjectClassification, FunctionArgs, CandidateSet,
7334 SuppressUserConversions, PartialOverloading);
7341 if (Args.size() > 0 &&
7342 (!Args[0] || (FirstArgumentIsBase && isa<CXXMethodDecl>(FD) &&
7343 !isa<CXXConstructorDecl>(FD)))) {
7344 assert(cast<CXXMethodDecl>(FD)->isStatic());
7345 FunctionArgs = Args.slice(1);
7348 AddTemplateOverloadCandidate(FunTmpl, F.getPair(),
7349 ExplicitTemplateArgs, FunctionArgs,
7350 CandidateSet, SuppressUserConversions,
7351 PartialOverloading);
7353 AddOverloadCandidate(FD, F.getPair(), FunctionArgs, CandidateSet,
7354 SuppressUserConversions, PartialOverloading);
7364 bool SuppressUserConversions,
7369 if (isa<UsingShadowDecl>(
Decl))
7370 Decl = cast<UsingShadowDecl>(
Decl)->getTargetDecl();
7373 assert(isa<CXXMethodDecl>(TD->getTemplatedDecl()) &&
7374 "Expected a member function template");
7375 AddMethodTemplateCandidate(TD, FoundDecl, ActingContext,
7376 nullptr, ObjectType,
7377 ObjectClassification, Args, CandidateSet,
7378 SuppressUserConversions,
false, PO);
7380 AddMethodCandidate(cast<CXXMethodDecl>(
Decl), FoundDecl, ActingContext,
7381 ObjectType, ObjectClassification, Args, CandidateSet,
7382 SuppressUserConversions,
false, std::nullopt, PO);
7392 bool SuppressUserConversions,
7393 bool PartialOverloading,
7398 assert(Proto &&
"Methods without a prototype cannot be overloaded");
7399 assert(!isa<CXXConstructorDecl>(Method) &&
7400 "Use AddOverloadCandidate for constructors");
7418 CandidateSet.
addCandidate(Args.size() + 1, EarlyConversions);
7427 bool IgnoreExplicitObject =
7431 bool ImplicitObjectMethodTreatedAsStatic =
7436 unsigned ExplicitOffset =
7439 unsigned NumParams = Method->
getNumParams() - ExplicitOffset +
7440 int(ImplicitObjectMethodTreatedAsStatic);
7448 Candidate.
Viable =
false;
7460 int(ImplicitObjectMethodTreatedAsStatic);
7462 if (Args.size() < MinRequiredArgs && !PartialOverloading) {
7464 Candidate.
Viable =
false;
7484 Candidate.
Conversions[FirstConvIdx].setStaticObjectArgument();
7489 *
this, CandidateSet.
getLocation(), ObjectType, ObjectClassification,
7490 Method, ActingContext,
true);
7491 if (Candidate.
Conversions[FirstConvIdx].isBad()) {
7492 Candidate.
Viable =
false;
7499 if (getLangOpts().
CUDA)
7500 if (!
CUDA().IsAllowedCall(getCurFunctionDecl(
true),
7502 Candidate.
Viable =
false;
7509 if (CheckFunctionConstraints(Method, Satisfaction, {},
7512 Candidate.
Viable =
false;
7520 for (
unsigned ArgIdx = 0; ArgIdx < Args.size(); ++ArgIdx) {
7523 if (Candidate.
Conversions[ConvIdx].isInitialized()) {
7526 }
else if (ArgIdx < NumParams) {
7532 if (ImplicitObjectMethodTreatedAsStatic) {
7533 ParamType = ArgIdx == 0
7537 ParamType = Proto->
getParamType(ArgIdx + ExplicitOffset);
7541 SuppressUserConversions,
7544 getLangOpts().ObjCAutoRefCount);
7546 Candidate.
Viable =
false;
7558 if (EnableIfAttr *FailedAttr =
7559 CheckEnableIf(Method, CandidateSet.
getLocation(), Args,
true)) {
7560 Candidate.
Viable =
false;
7567 Candidate.
Viable =
false;
7596 PartialOverloading,
false, ObjectType,
7597 ObjectClassification,
7599 return CheckNonDependentConversions(
7600 MethodTmpl, ParamTypes, Args, CandidateSet, Conversions,
7601 SuppressUserConversions, ActingContext, ObjectType,
7602 ObjectClassification, PO);
7606 CandidateSet.
addCandidate(Conversions.size(), Conversions);
7609 Candidate.
Viable =
false;
7614 cast<CXXMethodDecl>(Candidate.
Function)->isStatic() ||
7629 assert(
Specialization &&
"Missing member function template specialization?");
7631 "Specialization is not a member function?");
7632 AddMethodCandidate(cast<CXXMethodDecl>(
Specialization), FoundDecl,
7633 ActingContext, ObjectType, ObjectClassification, Args,
7634 CandidateSet, SuppressUserConversions, PartialOverloading,
7648 bool PartialOverloading,
bool AllowExplicit,
ADLCallKind IsADLCandidate,
7660 Candidate.
Viable =
false;
7679 FunctionTemplate, ExplicitTemplateArgs, Args,
Specialization, Info,
7680 PartialOverloading, AggregateCandidateDeduction,
7684 return CheckNonDependentConversions(
7685 FunctionTemplate, ParamTypes, Args, CandidateSet, Conversions,
7686 SuppressUserConversions,
nullptr,
QualType(), {}, PO);
7690 CandidateSet.
addCandidate(Conversions.size(), Conversions);
7693 Candidate.
Viable =
false;
7701 isa<CXXMethodDecl>(Candidate.
Function) &&
7702 !isa<CXXConstructorDecl>(Candidate.
Function);
7716 assert(
Specialization &&
"Missing function template specialization?");
7717 AddOverloadCandidate(
7718 Specialization, FoundDecl, Args, CandidateSet, SuppressUserConversions,
7719 PartialOverloading, AllowExplicit,
7720 false, IsADLCandidate, Conversions, PO,
7733 const bool AllowExplicit =
false;
7736 auto *Method = dyn_cast<CXXMethodDecl>(FD);
7737 bool HasThisConversion = Method && !isa<CXXConstructorDecl>(Method);
7738 unsigned ThisConversions = HasThisConversion ? 1 : 0;
7750 if (HasThisConversion && !cast<CXXMethodDecl>(FD)->isStatic() &&
7753 if (!FD->hasCXXExplicitFunctionObjectParameter() ||
7754 !ParamTypes[0]->isDependentType()) {
7756 *
this, CandidateSet.
getLocation(), ObjectType, ObjectClassification,
7757 Method, ActingContext,
true,
7758 FD->hasCXXExplicitFunctionObjectParameter() ? ParamTypes[0]
7760 if (Conversions[ConvIdx].isBad())
7768 for (
unsigned I = 0, N = std::min(ParamTypes.size() - Offset, Args.size());
7770 QualType ParamType = ParamTypes[I + Offset];
7774 ConvIdx = Args.size() - 1 - I;
7775 assert(Args.size() + ThisConversions == 2 &&
7776 "number of args (including 'this') must be exactly 2 for "
7780 assert(!HasThisConversion || (ConvIdx == 0 && I == 0));
7783 ConvIdx = ThisConversions + I;
7785 Conversions[ConvIdx]
7787 SuppressUserConversions,
7790 getLangOpts().ObjCAutoRefCount,
7792 if (Conversions[ConvIdx].isBad())
7814 bool AllowObjCPointerConversion) {
7822 bool ObjCLifetimeConversion;
7824 ObjCLifetimeConversion))
7829 if (!AllowObjCPointerConversion)
7833 bool IncompatibleObjC =
false;
7843 bool AllowExplicit,
bool AllowResultConversion) {
7845 "Conversion function templates use AddTemplateConversionCandidate");
7853 if (DeduceReturnType(Conversion, From->
getExprLoc()))
7860 if (!AllowResultConversion &&
7872 AllowObjCConversionOnExplicit))
7892 if (!AllowExplicit && Conversion->
isExplicit()) {
7893 Candidate.
Viable =
false;
7908 const auto *ConversionContext =
7917 From->
Classify(Context), Conversion, ConversionContext,
7922 Candidate.
Viable =
false;
7929 if (CheckFunctionConstraints(Conversion, Satisfaction) ||
7931 Candidate.
Viable =
false;
7943 if (FromCanon == ToCanon ||
7944 IsDerivedFrom(CandidateSet.
getLocation(), FromCanon, ToCanon)) {
7945 Candidate.
Viable =
false;
7962 CK_FunctionToPointerDecay, &ConversionRef,
7966 if (!isCompleteType(From->
getBeginLoc(), ConversionType)) {
7967 Candidate.
Viable =
false;
7981 Buffer, &ConversionFn, CallResultType, VK, From->
getBeginLoc());
7999 Candidate.
Viable =
false;
8011 Candidate.
Viable =
false;
8018 Candidate.
Viable =
false;
8024 "Can only end up with a standard conversion sequence or failure");
8027 if (EnableIfAttr *FailedAttr =
8028 CheckEnableIf(Conversion, CandidateSet.
getLocation(), std::nullopt)) {
8029 Candidate.
Viable =
false;
8036 Candidate.
Viable =
false;
8045 bool AllowExplicit,
bool AllowResultConversion) {
8047 "Only conversion function templates permitted here");
8059 Candidate.
Viable =
false;
8070 FunctionTemplate, ObjectType, ObjectClassification, ToType,
8076 Candidate.
Viable =
false;
8086 assert(
Specialization &&
"Missing function template specialization?");
8087 AddConversionCandidate(
Specialization, FoundDecl, ActingDC, From, ToType,
8088 CandidateSet, AllowObjCConversionOnExplicit,
8089 AllowExplicit, AllowResultConversion);
8124 *
this, CandidateSet.
getLocation(), Object->getType(),
8125 Object->Classify(Context), Conversion, ActingContext);
8128 if (ObjectInit.
isBad()) {
8129 Candidate.
Viable =
false;
8140 Candidate.
Conversions[0].UserDefined.EllipsisConversion =
false;
8141 Candidate.
Conversions[0].UserDefined.HadMultipleCandidates =
false;
8142 Candidate.
Conversions[0].UserDefined.ConversionFunction = Conversion;
8143 Candidate.
Conversions[0].UserDefined.FoundConversionFunction = FoundDecl;
8146 Candidate.
Conversions[0].UserDefined.After.setAsIdentityConversion();
8154 if (Args.size() > NumParams && !Proto->
isVariadic()) {
8155 Candidate.
Viable =
false;
8162 if (Args.size() < NumParams) {
8164 Candidate.
Viable =
false;
8171 for (
unsigned ArgIdx = 0, N = Args.size(); ArgIdx != N; ++ArgIdx) {
8172 if (ArgIdx < NumParams) {
8183 getLangOpts().ObjCAutoRefCount);
8185 Candidate.
Viable =
false;
8199 if (CheckFunctionConstraints(Conversion, Satisfaction, {},
8202 Candidate.
Viable =
false;
8208 if (EnableIfAttr *FailedAttr =
8209 CheckEnableIf(Conversion, CandidateSet.
getLocation(), std::nullopt)) {
8210 Candidate.
Viable =
false;
8222 NamedDecl *
D = F.getDecl()->getUnderlyingDecl();
8233 assert(!isa<CXXMethodDecl>(FD) &&
8234 "unqualified operator lookup found a member function");
8237 AddTemplateOverloadCandidate(FunTmpl, F.getPair(), ExplicitTemplateArgs,
8238 FunctionArgs, CandidateSet);
8240 AddTemplateOverloadCandidate(
8241 FunTmpl, F.getPair(), ExplicitTemplateArgs,
8242 {FunctionArgs[1], FunctionArgs[0]}, CandidateSet,
false,
false,
8245 if (ExplicitTemplateArgs)
8247 AddOverloadCandidate(FD, F.getPair(), FunctionArgs, CandidateSet);
8249 AddOverloadCandidate(
8250 FD, F.getPair(), {FunctionArgs[1], FunctionArgs[0]}, CandidateSet,
8251 false,
false,
true,
false, ADLCallKind::NotADL, std::nullopt,
8280 if (!isCompleteType(OpLoc, T1) && !T1Rec->isBeingDefined())
8283 if (!T1Rec->getDecl()->getDefinition())
8286 LookupResult Operators(*
this, OpName, OpLoc, LookupOrdinaryName);
8287 LookupQualifiedName(Operators, T1Rec->getDecl());
8291 OperEnd = Operators.
end();
8292 Oper != OperEnd; ++Oper) {
8293 if (Oper->getAsFunction() &&
8296 *
this, {Args[1], Args[0]}, Oper->getAsFunction()))
8298 AddMethodCandidate(Oper.getPair(), Args[0]->getType(),
8299 Args[0]->Classify(Context), Args.slice(1),
8300 CandidateSet,
false, PO);
8307 bool IsAssignmentOperator,
8308 unsigned NumContextualBoolArguments) {
8323 for (
unsigned ArgIdx = 0, N = Args.size(); ArgIdx != N; ++ArgIdx) {
8336 if (ArgIdx < NumContextualBoolArguments) {
8337 assert(ParamTys[ArgIdx] == Context.
BoolTy &&
8338 "Contextual conversion to bool requires bool type");
8344 ArgIdx == 0 && IsAssignmentOperator,
8347 getLangOpts().ObjCAutoRefCount);
8350 Candidate.
Viable =
false;
8363class BuiltinCandidateTypeSet {
8369 TypeSet PointerTypes;
8373 TypeSet MemberPointerTypes;
8377 TypeSet EnumerationTypes;
8381 TypeSet VectorTypes;
8385 TypeSet MatrixTypes;
8388 TypeSet BitIntTypes;
8391 bool HasNonRecordTypes;
8395 bool HasArithmeticOrEnumeralTypes;
8399 bool HasNullPtrType;
8408 bool AddPointerWithMoreQualifiedTypeVariants(
QualType Ty,
8410 bool AddMemberPointerWithMoreQualifiedTypeVariants(
QualType Ty);
8414 typedef TypeSet::iterator iterator;
8416 BuiltinCandidateTypeSet(
Sema &SemaRef)
8417 : HasNonRecordTypes(
false),
8418 HasArithmeticOrEnumeralTypes(
false),
8419 HasNullPtrType(
false),
8421 Context(SemaRef.Context) { }
8423 void AddTypesConvertedFrom(
QualType Ty,
8425 bool AllowUserConversions,
8426 bool AllowExplicitConversions,
8427 const Qualifiers &VisibleTypeConversionsQuals);
8429 llvm::iterator_range<iterator> pointer_types() {
return PointerTypes; }
8430 llvm::iterator_range<iterator> member_pointer_types() {
8431 return MemberPointerTypes;
8433 llvm::iterator_range<iterator> enumeration_types() {
8434 return EnumerationTypes;
8436 llvm::iterator_range<iterator> vector_types() {
return VectorTypes; }
8437 llvm::iterator_range<iterator> matrix_types() {
return MatrixTypes; }
8438 llvm::iterator_range<iterator> bitint_types() {
return BitIntTypes; }
8440 bool containsMatrixType(
QualType Ty)
const {
return MatrixTypes.count(Ty); }
8441 bool hasNonRecordTypes() {
return HasNonRecordTypes; }
8442 bool hasArithmeticOrEnumeralTypes() {
return HasArithmeticOrEnumeralTypes; }
8443 bool hasNullPtrType()
const {
return HasNullPtrType; }
8458BuiltinCandidateTypeSet::AddPointerWithMoreQualifiedTypeVariants(
QualType Ty,
8462 if (!PointerTypes.insert(Ty))
8467 bool buildObjCPtr =
false;
8471 buildObjCPtr =
true;
8483 unsigned BaseCVR = PointeeTy.getCVRQualifiers();
8489 if ((CVR | BaseCVR) != CVR)
continue;
8511 PointerTypes.insert(QPointerTy);
8527BuiltinCandidateTypeSet::AddMemberPointerWithMoreQualifiedTypeVariants(
8530 if (!MemberPointerTypes.insert(Ty))
8534 assert(PointerTy &&
"type was not a member pointer type!");
8549 if ((CVR | BaseCVR) != CVR)
continue;
8552 MemberPointerTypes.insert(
8568BuiltinCandidateTypeSet::AddTypesConvertedFrom(
QualType Ty,
8570 bool AllowUserConversions,
8571 bool AllowExplicitConversions,
8583 Ty = SemaRef.Context.getArrayDecayedType(Ty);
8590 HasNonRecordTypes = HasNonRecordTypes || !TyRec;
8593 HasArithmeticOrEnumeralTypes =
8597 PointerTypes.insert(Ty);
8601 if (!AddPointerWithMoreQualifiedTypeVariants(Ty, VisibleQuals))
8605 if (!AddMemberPointerWithMoreQualifiedTypeVariants(Ty))
8608 HasArithmeticOrEnumeralTypes =
true;
8609 EnumerationTypes.insert(Ty);
8611 HasArithmeticOrEnumeralTypes =
true;
8612 BitIntTypes.insert(Ty);
8616 HasArithmeticOrEnumeralTypes =
true;
8617 VectorTypes.insert(Ty);
8621 HasArithmeticOrEnumeralTypes =
true;
8622 MatrixTypes.insert(Ty);
8624 HasNullPtrType =
true;
8625 }
else if (AllowUserConversions && TyRec) {
8627 if (!SemaRef.isCompleteType(Loc, Ty))
8632 if (isa<UsingShadowDecl>(
D))
8633 D = cast<UsingShadowDecl>(
D)->getTargetDecl();
8637 if (isa<FunctionTemplateDecl>(
D))
8641 if (AllowExplicitConversions || !Conv->
isExplicit()) {
8704 if (isa<UsingShadowDecl>(
D))
8705 D = cast<UsingShadowDecl>(
D)->getTargetDecl();
8739 if (Available.hasAtomic()) {
8740 Available.removeAtomic();
8747 if (Available.hasVolatile()) {
8748 Available.removeVolatile();
8782class BuiltinOperatorOverloadBuilder {
8787 bool HasArithmeticOrEnumeralCandidateType;
8791 static constexpr int ArithmeticTypesCap = 26;
8797 unsigned FirstIntegralType,
8799 unsigned FirstPromotedIntegralType,
8800 LastPromotedIntegralType;
8801 unsigned FirstPromotedArithmeticType,
8802 LastPromotedArithmeticType;
8803 unsigned NumArithmeticTypes;
8805 void InitArithmeticTypes() {
8807 FirstPromotedArithmeticType = 0;
8817 FirstIntegralType = ArithmeticTypes.size();
8818 FirstPromotedIntegralType = ArithmeticTypes.size();
8841 llvm::for_each(CandidateTypes, [&BitIntCandidates](
8842 BuiltinCandidateTypeSet &Candidate) {
8843 for (
QualType BitTy : Candidate.bitint_types())
8846 llvm::move(BitIntCandidates, std::back_inserter(ArithmeticTypes));
8847 LastPromotedIntegralType = ArithmeticTypes.size();
8848 LastPromotedArithmeticType = ArithmeticTypes.size();
8862 LastIntegralType = ArithmeticTypes.size();
8863 NumArithmeticTypes = ArithmeticTypes.size();
8870 assert(ArithmeticTypes.size() - BitIntCandidates.size() <=
8871 ArithmeticTypesCap &&
8872 "Enough inline storage for all arithmetic types.");
8877 void addPlusPlusMinusMinusStyleOverloads(
QualType CandidateTy,
8926 BuiltinOperatorOverloadBuilder(
8929 bool HasArithmeticOrEnumeralCandidateType,
8933 VisibleTypeConversionsQuals(VisibleTypeConversionsQuals),
8934 HasArithmeticOrEnumeralCandidateType(
8935 HasArithmeticOrEnumeralCandidateType),
8936 CandidateTypes(CandidateTypes),
8937 CandidateSet(CandidateSet) {
8939 InitArithmeticTypes();
8962 if (!HasArithmeticOrEnumeralCandidateType)
8965 for (
unsigned Arith = 0; Arith < NumArithmeticTypes; ++Arith) {
8966 const auto TypeOfT = ArithmeticTypes[Arith];
8968 if (Op == OO_MinusMinus)
8970 if (Op == OO_PlusPlus && S.
getLangOpts().CPlusPlus17)
8973 addPlusPlusMinusMinusStyleOverloads(
8990 void addPlusPlusMinusMinusPointerOverloads() {
8991 for (
QualType PtrTy : CandidateTypes[0].pointer_types()) {
8993 if (!PtrTy->getPointeeType()->isObjectType())
8996 addPlusPlusMinusMinusStyleOverloads(
8998 (!PtrTy.isVolatileQualified() &&
9000 (!PtrTy.isRestrictQualified() &&
9015 void addUnaryStarPointerOverloads() {
9016 for (
QualType ParamTy : CandidateTypes[0].pointer_types()) {
9022 if (Proto->getMethodQuals() || Proto->getRefQualifier())
9035 void addUnaryPlusOrMinusArithmeticOverloads() {
9036 if (!HasArithmeticOrEnumeralCandidateType)
9039 for (
unsigned Arith = FirstPromotedArithmeticType;
9040 Arith < LastPromotedArithmeticType; ++Arith) {
9041 QualType ArithTy = ArithmeticTypes[Arith];
9046 for (
QualType VecTy : CandidateTypes[0].vector_types())
9055 void addUnaryPlusPointerOverloads() {
9056 for (
QualType ParamTy : CandidateTypes[0].pointer_types())
9065 void addUnaryTildePromotedIntegralOverloads() {
9066 if (!HasArithmeticOrEnumeralCandidateType)
9069 for (
unsigned Int = FirstPromotedIntegralType;
9070 Int < LastPromotedIntegralType; ++
Int) {
9076 for (
QualType VecTy : CandidateTypes[0].vector_types())
9086 void addEqualEqualOrNotEqualMemberPointerOrNullptrOverloads() {
9090 for (
unsigned ArgIdx = 0, N = Args.size(); ArgIdx != N; ++ArgIdx) {
9091 for (
QualType MemPtrTy : CandidateTypes[ArgIdx].member_pointer_types()) {
9096 QualType ParamTypes[2] = {MemPtrTy, MemPtrTy};
9100 if (CandidateTypes[ArgIdx].hasNullPtrType()) {
9102 if (AddedTypes.insert(NullPtrTy).second) {
9103 QualType ParamTypes[2] = { NullPtrTy, NullPtrTy };
9122 void addGenericBinaryPointerOrEnumeralOverloads(
bool IsSpaceship) {
9136 UserDefinedBinaryOperators;
9138 for (
unsigned ArgIdx = 0, N = Args.size(); ArgIdx != N; ++ArgIdx) {
9139 if (!CandidateTypes[ArgIdx].enumeration_types().empty()) {
9141 CEnd = CandidateSet.
end();
9143 if (!
C->Viable || !
C->Function ||
C->Function->getNumParams() != 2)
9146 if (
C->Function->isFunctionTemplateSpecialization())
9155 .getUnqualifiedType();
9158 .getUnqualifiedType();
9166 UserDefinedBinaryOperators.insert(
9176 for (
unsigned ArgIdx = 0, N = Args.size(); ArgIdx != N; ++ArgIdx) {
9177 for (
QualType PtrTy : CandidateTypes[ArgIdx].pointer_types()) {
9181 if (IsSpaceship && PtrTy->isFunctionPointerType())
9184 QualType ParamTypes[2] = {PtrTy, PtrTy};
9187 for (
QualType EnumTy : CandidateTypes[ArgIdx].enumeration_types()) {
9192 if (!AddedTypes.insert(CanonType).second ||
9193 UserDefinedBinaryOperators.count(std::make_pair(CanonType,
9196 QualType ParamTypes[2] = {EnumTy, EnumTy};
9223 for (
int Arg = 0; Arg < 2; ++Arg) {
9224 QualType AsymmetricParamTypes[2] = {
9228 for (
QualType PtrTy : CandidateTypes[Arg].pointer_types()) {
9233 AsymmetricParamTypes[Arg] = PtrTy;
9234 if (Arg == 0 || Op == OO_Plus) {
9239 if (Op == OO_Minus) {
9244 QualType ParamTypes[2] = {PtrTy, PtrTy};
9280 void addGenericBinaryArithmeticOverloads() {
9281 if (!HasArithmeticOrEnumeralCandidateType)
9284 for (
unsigned Left = FirstPromotedArithmeticType;
9285 Left < LastPromotedArithmeticType; ++
Left) {
9286 for (
unsigned Right = FirstPromotedArithmeticType;
9287 Right < LastPromotedArithmeticType; ++
Right) {
9289 ArithmeticTypes[
Right] };
9296 for (
QualType Vec1Ty : CandidateTypes[0].vector_types())
9297 for (
QualType Vec2Ty : CandidateTypes[1].vector_types()) {
9298 QualType LandR[2] = {Vec1Ty, Vec2Ty};
9308 void addMatrixBinaryArithmeticOverloads() {
9309 if (!HasArithmeticOrEnumeralCandidateType)
9312 for (
QualType M1 : CandidateTypes[0].matrix_types()) {
9313 AddCandidate(M1, cast<MatrixType>(M1)->getElementType());
9314 AddCandidate(M1, M1);
9317 for (
QualType M2 : CandidateTypes[1].matrix_types()) {
9318 AddCandidate(cast<MatrixType>(M2)->getElementType(), M2);
9319 if (!CandidateTypes[0].containsMatrixType(M2))
9320 AddCandidate(M2, M2);
9355 void addThreeWayArithmeticOverloads() {
9356 addGenericBinaryArithmeticOverloads();
9373 void addBinaryBitwiseArithmeticOverloads() {
9374 if (!HasArithmeticOrEnumeralCandidateType)
9377 for (
unsigned Left = FirstPromotedIntegralType;
9378 Left < LastPromotedIntegralType; ++
Left) {
9379 for (
unsigned Right = FirstPromotedIntegralType;
9382 ArithmeticTypes[
Right] };
9395 void addAssignmentMemberPointerOrEnumeralOverloads() {
9399 for (
unsigned ArgIdx = 0; ArgIdx < 2; ++ArgIdx) {
9400 for (
QualType EnumTy : CandidateTypes[ArgIdx].enumeration_types()) {
9407 for (
QualType MemPtrTy : CandidateTypes[ArgIdx].member_pointer_types()) {
9432 void addAssignmentPointerOverloads(
bool isEqualOp) {
9436 for (
QualType PtrTy : CandidateTypes[0].pointer_types()) {
9440 else if (!PtrTy->getPointeeType()->isObjectType())
9451 bool NeedVolatile = !PtrTy.isVolatileQualified() &&
9461 if (!PtrTy.isRestrictQualified() &&
9481 for (
QualType PtrTy : CandidateTypes[1].pointer_types()) {
9495 bool NeedVolatile = !PtrTy.isVolatileQualified() &&
9505 if (!PtrTy.isRestrictQualified() &&
9538 void addAssignmentArithmeticOverloads(
bool isEqualOp) {
9539 if (!HasArithmeticOrEnumeralCandidateType)
9542 for (
unsigned Left = 0;
Left < NumArithmeticTypes; ++
Left) {
9543 for (
unsigned Right = FirstPromotedArithmeticType;
9544 Right < LastPromotedArithmeticType; ++
Right) {
9546 ParamTypes[1] = ArithmeticTypes[
Right];
9548 S, ArithmeticTypes[Left], Args[0]);
9561 for (
QualType Vec1Ty : CandidateTypes[0].vector_types())
9562 for (
QualType Vec2Ty : CandidateTypes[0].vector_types()) {
9564 ParamTypes[1] = Vec2Ty;
9592 void addAssignmentIntegralOverloads() {
9593 if (!HasArithmeticOrEnumeralCandidateType)
9596 for (
unsigned Left = FirstIntegralType;
Left < LastIntegralType; ++
Left) {
9597 for (
unsigned Right = FirstPromotedIntegralType;
9600 ParamTypes[1] = ArithmeticTypes[
Right];
9602 S, ArithmeticTypes[Left], Args[0]);
9621 void addExclaimOverload() {
9627 void addAmpAmpOrPipePipeOverload() {
9644 void addSubscriptOverloads() {
9645 for (
QualType PtrTy : CandidateTypes[0].pointer_types()) {
9655 for (
QualType PtrTy : CandidateTypes[1].pointer_types()) {
9675 void addArrowStarOverloads() {
9676 for (
QualType PtrTy : CandidateTypes[0].pointer_types()) {
9681 if (!isa<RecordType>(C1))
9690 for (
QualType MemPtrTy : CandidateTypes[1].member_pointer_types()) {
9696 QualType ParamTypes[2] = {PtrTy, MemPtrTy};
9700 T.isVolatileQualified())
9703 T.isRestrictQualified())
9721 void addConditionalOperatorOverloads() {
9725 for (
unsigned ArgIdx = 0; ArgIdx < 2; ++ArgIdx) {
9726 for (
QualType PtrTy : CandidateTypes[ArgIdx].pointer_types()) {
9730 QualType ParamTypes[2] = {PtrTy, PtrTy};
9734 for (
QualType MemPtrTy : CandidateTypes[ArgIdx].member_pointer_types()) {
9738 QualType ParamTypes[2] = {MemPtrTy, MemPtrTy};
9743 for (
QualType EnumTy : CandidateTypes[ArgIdx].enumeration_types()) {
9750 QualType ParamTypes[2] = {EnumTy, EnumTy};
9769 VisibleTypeConversionsQuals.
addConst();
9770 for (
unsigned ArgIdx = 0, N = Args.size(); ArgIdx != N; ++ArgIdx) {
9772 if (Args[ArgIdx]->getType()->isAtomicType())
9773 VisibleTypeConversionsQuals.
addAtomic();
9776 bool HasNonRecordCandidateType =
false;
9777 bool HasArithmeticOrEnumeralCandidateType =
false;
9779 for (
unsigned ArgIdx = 0, N = Args.size(); ArgIdx != N; ++ArgIdx) {
9780 CandidateTypes.emplace_back(*
this);
9781 CandidateTypes[ArgIdx].AddTypesConvertedFrom(Args[ArgIdx]->getType(),
9784 (Op == OO_Exclaim ||
9787 VisibleTypeConversionsQuals);
9788 HasNonRecordCandidateType = HasNonRecordCandidateType ||
9789 CandidateTypes[ArgIdx].hasNonRecordTypes();
9790 HasArithmeticOrEnumeralCandidateType =
9791 HasArithmeticOrEnumeralCandidateType ||
9792 CandidateTypes[ArgIdx].hasArithmeticOrEnumeralTypes();
9800 if (!HasNonRecordCandidateType &&
9801 !(Op == OO_Exclaim || Op == OO_AmpAmp || Op == OO_PipePipe))
9805 BuiltinOperatorOverloadBuilder OpBuilder(*
this, Args,
9806 VisibleTypeConversionsQuals,
9807 HasArithmeticOrEnumeralCandidateType,
9808 CandidateTypes, CandidateSet);
9814 llvm_unreachable(
"Expected an overloaded operator");
9819 case OO_Array_Delete:
9822 "Special operators don't use AddBuiltinOperatorCandidates");
9834 if (Args.size() == 1)
9835 OpBuilder.addUnaryPlusPointerOverloads();
9839 if (Args.size() == 1) {
9840 OpBuilder.addUnaryPlusOrMinusArithmeticOverloads();
9842 OpBuilder.addBinaryPlusOrMinusPointerOverloads(Op);
9843 OpBuilder.addGenericBinaryArithmeticOverloads();
9844 OpBuilder.addMatrixBinaryArithmeticOverloads();
9849 if (Args.size() == 1)
9850 OpBuilder.addUnaryStarPointerOverloads();
9852 OpBuilder.addGenericBinaryArithmeticOverloads();
9853 OpBuilder.addMatrixBinaryArithmeticOverloads();
9858 OpBuilder.addGenericBinaryArithmeticOverloads();
9863 OpBuilder.addPlusPlusMinusMinusArithmeticOverloads(Op);
9864 OpBuilder.addPlusPlusMinusMinusPointerOverloads();
9868 case OO_ExclaimEqual:
9869 OpBuilder.addEqualEqualOrNotEqualMemberPointerOrNullptrOverloads();
9870 OpBuilder.addGenericBinaryPointerOrEnumeralOverloads(
false);
9871 OpBuilder.addGenericBinaryArithmeticOverloads();
9877 case OO_GreaterEqual:
9878 OpBuilder.addGenericBinaryPointerOrEnumeralOverloads(
false);
9879 OpBuilder.addGenericBinaryArithmeticOverloads();
9883 OpBuilder.addGenericBinaryPointerOrEnumeralOverloads(
true);
9884 OpBuilder.addThreeWayArithmeticOverloads();
9891 case OO_GreaterGreater:
9892 OpBuilder.addBinaryBitwiseArithmeticOverloads();
9896 if (Args.size() == 1)
9902 OpBuilder.addBinaryBitwiseArithmeticOverloads();
9906 OpBuilder.addUnaryTildePromotedIntegralOverloads();
9910 OpBuilder.addAssignmentMemberPointerOrEnumeralOverloads();
9915 OpBuilder.addAssignmentPointerOverloads(Op == OO_Equal);
9920 OpBuilder.addAssignmentArithmeticOverloads(Op == OO_Equal);
9923 case OO_PercentEqual:
9924 case OO_LessLessEqual:
9925 case OO_GreaterGreaterEqual:
9929 OpBuilder.addAssignmentIntegralOverloads();
9933 OpBuilder.addExclaimOverload();
9938 OpBuilder.addAmpAmpOrPipePipeOverload();
9942 if (Args.size() == 2)
9943 OpBuilder.addSubscriptOverloads();
9947 OpBuilder.addArrowStarOverloads();
9950 case OO_Conditional:
9951 OpBuilder.addConditionalOperatorOverloads();
9952 OpBuilder.addGenericBinaryArithmeticOverloads();
9963 bool PartialOverloading) {
9974 ArgumentDependentLookup(Name,
Loc, Args, Fns);
9978 CandEnd = CandidateSet.
end();
9979 Cand != CandEnd; ++Cand)
9980 if (Cand->Function) {
9993 if (ExplicitTemplateArgs)
9996 AddOverloadCandidate(
9997 FD, FoundDecl, Args, CandidateSet,
false,
9998 PartialOverloading,
true,
9999 false, ADLCallKind::UsesADL);
10001 AddOverloadCandidate(
10002 FD, FoundDecl, {Args[1], Args[0]}, CandidateSet,
10003 false, PartialOverloading,
10005 ADLCallKind::UsesADL, std::nullopt,
10009 auto *FTD = cast<FunctionTemplateDecl>(*I);
10010 AddTemplateOverloadCandidate(
10011 FTD, FoundDecl, ExplicitTemplateArgs, Args, CandidateSet,
10012 false, PartialOverloading,
10013 true, ADLCallKind::UsesADL);
10015 *
this, Args, FTD->getTemplatedDecl())) {
10016 AddTemplateOverloadCandidate(
10017 FTD, FoundDecl, ExplicitTemplateArgs, {Args[1], Args[0]},
10018 CandidateSet,
false, PartialOverloading,
10019 true, ADLCallKind::UsesADL,
10027enum class Comparison {
Equal, Better, Worse };
10044 bool Cand1Attr = Cand1->
hasAttr<EnableIfAttr>();
10045 bool Cand2Attr = Cand2->
hasAttr<EnableIfAttr>();
10046 if (!Cand1Attr || !Cand2Attr) {
10047 if (Cand1Attr == Cand2Attr)
10048 return Comparison::Equal;
10049 return Cand1Attr ? Comparison::Better : Comparison::Worse;
10055 llvm::FoldingSetNodeID Cand1ID, Cand2ID;
10056 for (
auto Pair : zip_longest(Cand1Attrs, Cand2Attrs)) {
10057 std::optional<EnableIfAttr *> Cand1A = std::get<0>(Pair);
10058 std::optional<EnableIfAttr *> Cand2A = std::get<1>(Pair);
10063 return Comparison::Worse;
10065 return Comparison::Better;
10070 (*Cand1A)->getCond()->Profile(Cand1ID, S.
getASTContext(),
true);
10071 (*Cand2A)->getCond()->Profile(Cand2ID, S.
getASTContext(),
true);
10072 if (Cand1ID != Cand2ID)
10073 return Comparison::Worse;
10076 return Comparison::Equal;
10084 return Comparison::Equal;
10090 return Comparison::Equal;
10091 return Comparison::Worse;
10094 return Comparison::Better;
10100 const auto *Cand1CPUSpec = Cand1.
Function->
getAttr<CPUSpecificAttr>();
10101 const auto *Cand2CPUSpec = Cand2.
Function->
getAttr<CPUSpecificAttr>();
10103 if (!Cand1CPUDisp && !Cand2CPUDisp && !Cand1CPUSpec && !Cand2CPUSpec)
10104 return Comparison::Equal;
10106 if (Cand1CPUDisp && !Cand2CPUDisp)
10107 return Comparison::Better;
10108 if (Cand2CPUDisp && !Cand1CPUDisp)
10109 return Comparison::Worse;
10111 if (Cand1CPUSpec && Cand2CPUSpec) {
10112 if (Cand1CPUSpec->cpus_size() != Cand2CPUSpec->cpus_size())
10113 return Cand1CPUSpec->cpus_size() < Cand2CPUSpec->cpus_size()
10114 ? Comparison::Better
10115 : Comparison::Worse;
10117 std::pair<CPUSpecificAttr::cpus_iterator, CPUSpecificAttr::cpus_iterator>
10118 FirstDiff = std::mismatch(
10119 Cand1CPUSpec->cpus_begin(), Cand1CPUSpec->cpus_end(),
10120 Cand2CPUSpec->cpus_begin(),
10122 return LHS->getName() == RHS->getName();
10125 assert(FirstDiff.first != Cand1CPUSpec->cpus_end() &&
10126 "Two different cpu-specific versions should not have the same "
10127 "identifier list, otherwise they'd be the same decl!");
10128 return (*FirstDiff.first)->getName() < (*FirstDiff.second)->
getName()
10129 ? Comparison::Better
10130 : Comparison::Worse;
10132 llvm_unreachable(
"No way to get here unless both had cpu_dispatch");
10138static std::optional<QualType>
10140 if (!isa<CXXMethodDecl>(F) || isa<CXXConstructorDecl>(F))
10141 return std::nullopt;
10143 auto *M = cast<CXXMethodDecl>(F);
10147 return M->getFunctionObjectParameterReferenceType();
10161 PT2->getInstantiatedFromMemberTemplate()))
10172 assert(I < F->getNumParams());
10176 unsigned F1NumParams = F1->
getNumParams() + isa<CXXMethodDecl>(F1);
10177 unsigned F2NumParams = F2->
getNumParams() + isa<CXXMethodDecl>(F2);
10179 if (F1NumParams != F2NumParams)
10182 unsigned I1 = 0, I2 = 0;
10183 for (
unsigned I = 0; I != F1NumParams; ++I) {
10184 QualType T1 = NextParam(F1, I1, I == 0);
10185 QualType T2 = NextParam(F2, I2, I == 0);
10186 assert(!T1.
isNull() && !T2.
isNull() &&
"Unexpected null param types");
10214 auto *Mem1 = dyn_cast<CXXMethodDecl>(Fn1);
10215 auto *Mem2 = dyn_cast<CXXMethodDecl>(Fn2);
10216 if (Mem1 && Mem2) {
10219 if (Mem1->getParent() != Mem2->getParent())
10223 if (Mem1->isInstance() && Mem2->isInstance() &&
10225 Mem1->getFunctionObjectParameterReferenceType(),
10226 Mem1->getFunctionObjectParameterReferenceType()))
10282 bool IsCand1ImplicitHD =
10284 bool IsCand2ImplicitHD =
10299 auto EmitThreshold =
10300 (S.
getLangOpts().CUDAIsDevice && IsCallerImplicitHD &&
10301 (IsCand1ImplicitHD || IsCand2ImplicitHD))
10304 auto Cand1Emittable = P1 > EmitThreshold;
10305 auto Cand2Emittable = P2 > EmitThreshold;
10306 if (Cand1Emittable && !Cand2Emittable)
10308 if (!Cand1Emittable && Cand2Emittable)
10319 unsigned StartArg = 0;
10326 return ICS.isStandard() &&
10338 assert(Cand2.
Conversions.size() == NumArgs &&
"Overload candidate mismatch");
10339 bool HasBetterConversion =
false;
10340 for (
unsigned ArgIdx = StartArg; ArgIdx < NumArgs; ++ArgIdx) {
10341 bool Cand1Bad = IsIllFormedConversion(Cand1.
Conversions[ArgIdx]);
10342 bool Cand2Bad = IsIllFormedConversion(Cand2.
Conversions[ArgIdx]);
10343 if (Cand1Bad != Cand2Bad) {
10346 HasBetterConversion =
true;
10350 if (HasBetterConversion)
10357 bool HasWorseConversion =
false;
10358 for (
unsigned ArgIdx = StartArg; ArgIdx < NumArgs; ++ArgIdx) {
10364 HasBetterConversion =
true;
10383 HasWorseConversion =
true;
10398 if (HasBetterConversion && !HasWorseConversion)
10409 isa<CXXConversionDecl>(Cand1.
Function) &&
10410 isa<CXXConversionDecl>(Cand2.
Function)) {
10438 isa<CXXConstructorDecl>(Cand1.
Function) !=
10439 isa<CXXConstructorDecl>(Cand2.
Function))
10440 return isa<CXXConstructorDecl>(Cand1.
Function);
10444 bool Cand1IsSpecialization = Cand1.
Function &&
10446 bool Cand2IsSpecialization = Cand2.
Function &&
10448 if (Cand1IsSpecialization != Cand2IsSpecialization)
10449 return Cand2IsSpecialization;
10455 if (Cand1IsSpecialization && Cand2IsSpecialization) {
10456 const auto *Obj1Context =
10458 const auto *Obj2Context =
10466 Obj1Context ?
QualType(Obj1Context->getTypeForDecl(), 0)
10468 Obj2Context ?
QualType(Obj2Context->getTypeForDecl(), 0)
10477 if (!Cand1IsSpecialization && !Cand2IsSpecialization &&
10487 bool Cand1IsInherited =
10489 bool Cand2IsInherited =
10491 if (Cand1IsInherited != Cand2IsInherited)
10492 return Cand2IsInherited;
10493 else if (Cand1IsInherited) {
10494 assert(Cand2IsInherited);
10497 if (Cand1Class->isDerivedFrom(Cand2Class))
10499 if (Cand2Class->isDerivedFrom(Cand1Class))
10516 auto *Guide1 = dyn_cast_or_null<CXXDeductionGuideDecl>(Cand1.
Function);
10517 auto *Guide2 = dyn_cast_or_null<CXXDeductionGuideDecl>(Cand2.
Function);
10518 if (Guide1 && Guide2) {
10520 if (Guide1->isImplicit() != Guide2->isImplicit())
10521 return Guide2->isImplicit();
10531 const auto *Constructor1 = Guide1->getCorrespondingConstructor();
10532 const auto *Constructor2 = Guide2->getCorrespondingConstructor();
10533 if (Constructor1 && Constructor2) {
10534 bool isC1Templated = Constructor1->getTemplatedKind() !=
10536 bool isC2Templated = Constructor2->getTemplatedKind() !=
10538 if (isC1Templated != isC2Templated)
10539 return isC2Templated;
10547 if (Cmp != Comparison::Equal)
10548 return Cmp == Comparison::Better;
10551 bool HasPS1 = Cand1.
Function !=
nullptr &&
10553 bool HasPS2 = Cand2.
Function !=
nullptr &&
10555 if (HasPS1 != HasPS2 && HasPS1)
10559 if (MV == Comparison::Better)
10561 if (MV == Comparison::Worse)
10576 const auto *CD1 = dyn_cast_or_null<CXXConstructorDecl>(Cand1.
Function);
10577 const auto *CD2 = dyn_cast_or_null<CXXConstructorDecl>(Cand2.
Function);
10579 LangAS AS1 = CD1->getMethodQualifiers().getAddressSpace();
10580 LangAS AS2 = CD2->getMethodQualifiers().getAddressSpace();
10601 auto *VA = dyn_cast_or_null<ValueDecl>(A);
10602 auto *VB = dyn_cast_or_null<ValueDecl>(B);
10608 if (!VA->getDeclContext()->getRedeclContext()->Equals(
10609 VB->getDeclContext()->getRedeclContext()) ||
10610 getOwningModule(VA) == getOwningModule(VB) ||
10611 VA->isExternallyVisible() || VB->isExternallyVisible())
10619 if (Context.
hasSameType(VA->getType(), VB->getType()))
10624 if (
auto *EA = dyn_cast<EnumConstantDecl>(VA)) {
10625 if (
auto *EB = dyn_cast<EnumConstantDecl>(VB)) {
10628 auto *EnumA = cast<EnumDecl>(EA->getDeclContext());
10629 auto *EnumB = cast<EnumDecl>(EB->getDeclContext());
10630 if (EnumA->hasNameForLinkage() || EnumB->hasNameForLinkage() ||
10632 EnumB->getIntegerType()))
10635 return llvm::APSInt::isSameValue(EA->getInitVal(), EB->getInitVal());
10645 assert(
D &&
"Unknown declaration");
10646 Diag(
Loc, diag::ext_equivalent_internal_linkage_decl_in_modules) <<
D;
10648 Module *M = getOwningModule(
D);
10652 for (
auto *
E : Equiv) {
10653 Module *M = getOwningModule(
E);
10654 Diag(
E->getLocation(), diag::note_equivalent_internal_linkage_decl)
10663 static_cast<CNSInfo *
>(DeductionFailure.Data)
10664 ->Satisfaction.ContainsErrors;
10681 std::transform(
begin(),
end(), std::back_inserter(Candidates),
10697 bool ContainsSameSideCandidate =
10701 S.
CUDA().IdentifyPreference(Caller, Cand->
Function) ==
10704 if (ContainsSameSideCandidate) {
10711 llvm::erase_if(Candidates, IsWrongSideCandidate);
10717 for (
auto *Cand : Candidates) {
10718 Cand->
Best =
false;
10720 if (Best ==
end() ||
10740 PendingBest.push_back(&*Best);
10745 while (!PendingBest.empty()) {
10746 auto *Curr = PendingBest.pop_back_val();
10747 for (
auto *Cand : Candidates) {
10750 PendingBest.push_back(Cand);
10755 EquivalentCands.push_back(Cand->
Function);
10767 if (Best->Function && Best->Function->isDeleted())
10770 if (
auto *M = dyn_cast_or_null<CXXMethodDecl>(Best->Function);
10772 M->isImplicitObjectMemberFunction()) {
10776 if (!EquivalentCands.empty())
10785enum OverloadCandidateKind {
10788 oc_reversed_binary_operator,
10790 oc_implicit_default_constructor,
10791 oc_implicit_copy_constructor,
10792 oc_implicit_move_constructor,
10793 oc_implicit_copy_assignment,
10794 oc_implicit_move_assignment,
10795 oc_implicit_equality_comparison,
10796 oc_inherited_constructor
10799enum OverloadCandidateSelect {
10802 ocs_described_template,
10805static std::pair<OverloadCandidateKind, OverloadCandidateSelect>
10809 std::string &Description) {
10815 FunTmpl->getTemplateParameters(), *
Fn->getTemplateSpecializationArgs());
10818 OverloadCandidateSelect Select = [&]() {
10819 if (!Description.empty())
10820 return ocs_described_template;
10821 return isTemplate ? ocs_template : ocs_non_template;
10824 OverloadCandidateKind Kind = [&]() {
10825 if (
Fn->isImplicit() &&
Fn->getOverloadedOperator() == OO_EqualEqual)
10826 return oc_implicit_equality_comparison;
10829 return oc_reversed_binary_operator;
10831 if (
const auto *Ctor = dyn_cast<CXXConstructorDecl>(Fn)) {
10832 if (!Ctor->isImplicit()) {
10833 if (isa<ConstructorUsingShadowDecl>(
Found))
10834 return oc_inherited_constructor;
10836 return oc_constructor;
10839 if (Ctor->isDefaultConstructor())
10840 return oc_implicit_default_constructor;
10842 if (Ctor->isMoveConstructor())
10843 return oc_implicit_move_constructor;
10845 assert(Ctor->isCopyConstructor() &&
10846 "unexpected sort of implicit constructor");
10847 return oc_implicit_copy_constructor;
10850 if (
const auto *Meth = dyn_cast<CXXMethodDecl>(Fn)) {
10853 if (!Meth->isImplicit())
10856 if (Meth->isMoveAssignmentOperator())
10857 return oc_implicit_move_assignment;
10859 if (Meth->isCopyAssignmentOperator())
10860 return oc_implicit_copy_assignment;
10862 assert(isa<CXXConversionDecl>(Meth) &&
"expected conversion");
10866 return oc_function;
10869 return std::make_pair(Kind, Select);
10872void MaybeEmitInheritedConstructorNote(
Sema &S,
const Decl *FoundDecl) {
10875 if (
const auto *Shadow = dyn_cast<ConstructorUsingShadowDecl>(FoundDecl))
10877 diag::note_ovl_candidate_inherited_constructor)
10878 << Shadow->getNominatedBaseClass();
10887 if (EnableIf->getCond()->isValueDependent() ||
10888 !EnableIf->getCond()->EvaluateAsBooleanCondition(AlwaysTrue, Ctx))
10905 bool InOverloadResolution,
10909 if (InOverloadResolution)
10911 diag::note_addrof_ovl_candidate_disabled_by_enable_if_attr);
10913 S.
Diag(
Loc, diag::err_addrof_function_disabled_by_enable_if_attr) << FD;
10924 if (InOverloadResolution) {
10927 TemplateArgString +=
" ";
10929 FunTmpl->getTemplateParameters(),
10934 diag::note_ovl_candidate_unsatisfied_constraints)
10935 << TemplateArgString;
10937 S.
Diag(
Loc, diag::err_addrof_function_constraints_not_satisfied)
10946 return P->hasAttr<PassObjectSizeAttr>();
10953 unsigned ParamNo = std::distance(FD->
param_begin(), I) + 1;
10954 if (InOverloadResolution)
10956 diag::note_ovl_candidate_has_pass_object_size_params)
10959 S.
Diag(
Loc, diag::err_address_of_function_with_pass_object_size_params)
10975 return ::checkAddressOfFunctionIsAvailable(*
this,
Function, Complain,
10983 const auto *ConvD = dyn_cast<CXXConversionDecl>(Fn);
10987 const auto *RD = cast<CXXRecordDecl>(Fn->getParent());
10988 if (!RD->isLambda())
10998 return ConvToCC != CallOpCC;
11004 QualType DestType,
bool TakingAddress) {
11007 if (Fn->isMultiVersion() && Fn->hasAttr<TargetAttr>() &&
11008 !Fn->getAttr<TargetAttr>()->isDefaultVersion())
11010 if (Fn->isMultiVersion() && Fn->hasAttr<TargetVersionAttr>() &&
11011 !Fn->getAttr<TargetVersionAttr>()->isDefaultVersion())
11016 std::string FnDesc;
11017 std::pair<OverloadCandidateKind, OverloadCandidateSelect> KSPair =
11018 ClassifyOverloadCandidate(*
this,
Found, Fn, RewriteKind, FnDesc);
11020 << (
unsigned)KSPair.first << (
unsigned)KSPair.second
11023 HandleFunctionTypeMismatch(PD, Fn->getType(), DestType);
11024 Diag(Fn->getLocation(), PD);
11025 MaybeEmitInheritedConstructorNote(*
this,
Found);
11043 FunctionDecl *FirstCand =
nullptr, *SecondCand =
nullptr;
11044 for (
auto I = Cands.begin(),
E = Cands.end(); I !=
E; ++I) {
11048 if (
auto *Template = I->Function->getPrimaryTemplate())
11049 Template->getAssociatedConstraints(AC);
11051 I->Function->getAssociatedConstraints(AC);
11054 if (FirstCand ==
nullptr) {
11055 FirstCand = I->Function;
11057 }
else if (SecondCand ==
nullptr) {
11058 SecondCand = I->Function;
11071 SecondCand, SecondAC))
11080 bool TakingAddress) {
11090 dyn_cast<FunctionTemplateDecl>((*I)->getUnderlyingDecl()) ) {
11091 NoteOverloadCandidate(*I, FunTmpl->getTemplatedDecl(),
CRK_None, DestType,
11094 = dyn_cast<FunctionDecl>((*I)->getUnderlyingDecl()) ) {
11095 NoteOverloadCandidate(*I, Fun,
CRK_None, DestType, TakingAddress);
11107 S.
Diag(CaretLoc, PDiag)
11108 << Ambiguous.getFromType() << Ambiguous.getToType();
11109 unsigned CandsShown = 0;
11111 for (I = Ambiguous.begin(),
E = Ambiguous.end(); I !=
E; ++I) {
11123 unsigned I,
bool TakingCandidateAddress) {
11125 assert(Conv.
isBad());
11126 assert(Cand->
Function &&
"for now, candidate must be a function");
11132 bool isObjectArgument =
false;
11133 if (isa<CXXMethodDecl>(Fn) && !isa<CXXConstructorDecl>(Fn)) {
11135 isObjectArgument =
true;
11140 std::string FnDesc;
11141 std::pair<OverloadCandidateKind, OverloadCandidateSelect> FnKindPair =
11152 bool HasParamPack =
11153 llvm::any_of(Fn->parameters().take_front(I), [](
const ParmVarDecl *Parm) {
11154 return Parm->isParameterPack();
11156 if (!isObjectArgument && !HasParamPack)
11157 ToParamRange = Fn->getParamDecl(I)->getSourceRange();
11160 assert(FromExpr &&
"overload set argument came from implicit argument?");
11162 if (isa<UnaryOperator>(
E))
11166 S.
Diag(Fn->getLocation(), diag::note_ovl_candidate_bad_overload)
11167 << (
unsigned)FnKindPair.first << (
unsigned)FnKindPair.second << FnDesc
11168 << ToParamRange << ToTy << Name << I + 1;
11169 MaybeEmitInheritedConstructorNote(S, Cand->
FoundDecl);
11178 CToTy = RT->getPointeeType();
11183 CFromTy = FromPT->getPointeeType();
11184 CToTy = ToPT->getPointeeType();
11194 if (isObjectArgument)
11195 S.
Diag(Fn->getLocation(), diag::note_ovl_candidate_bad_addrspace_this)
11196 << (
unsigned)FnKindPair.first << (
unsigned)FnKindPair.second
11199 S.
Diag(Fn->getLocation(), diag::note_ovl_candidate_bad_addrspace)
11200 << (
unsigned)FnKindPair.first << (
unsigned)FnKindPair.second
11203 MaybeEmitInheritedConstructorNote(S, Cand->
FoundDecl);
11208 S.
Diag(Fn->getLocation(), diag::note_ovl_candidate_bad_ownership)
11209 << (
unsigned)FnKindPair.first << (
unsigned)FnKindPair.second << FnDesc
11212 MaybeEmitInheritedConstructorNote(S, Cand->
FoundDecl);
11217 S.
Diag(Fn->getLocation(), diag::note_ovl_candidate_bad_gc)
11218 << (
unsigned)FnKindPair.first << (
unsigned)FnKindPair.second << FnDesc
11221 MaybeEmitInheritedConstructorNote(S, Cand->
FoundDecl);
11226 assert(CVR &&
"expected qualifiers mismatch");
11228 if (isObjectArgument) {
11229 S.
Diag(Fn->getLocation(), diag::note_ovl_candidate_bad_cvr_this)
11230 << (
unsigned)FnKindPair.first << (
unsigned)FnKindPair.second << FnDesc
11231 << FromTy << (CVR - 1);
11233 S.
Diag(Fn->getLocation(), diag::note_ovl_candidate_bad_cvr)
11234 << (
unsigned)FnKindPair.first << (
unsigned)FnKindPair.second << FnDesc
11235 << ToParamRange << FromTy << (CVR - 1) << I + 1;
11237 MaybeEmitInheritedConstructorNote(S, Cand->
FoundDecl);
11243 S.
Diag(Fn->getLocation(), diag::note_ovl_candidate_bad_value_category)
11244 << (
unsigned)FnKindPair.first << (
unsigned)FnKindPair.second << FnDesc
11245 << (
unsigned)isObjectArgument << I + 1
11248 MaybeEmitInheritedConstructorNote(S, Cand->
FoundDecl);
11254 if (FromExpr && isa<InitListExpr>(FromExpr)) {
11255 S.
Diag(Fn->getLocation(), diag::note_ovl_candidate_bad_list_argument)
11256 << (
unsigned)FnKindPair.first << (
unsigned)FnKindPair.second << FnDesc
11257 << ToParamRange << FromTy << ToTy << (
unsigned)isObjectArgument << I + 1
11262 MaybeEmitInheritedConstructorNote(S, Cand->
FoundDecl);
11274 S.
Diag(Fn->getLocation(), diag::note_ovl_candidate_bad_conv_incomplete)
11275 << (
unsigned)FnKindPair.first << (
unsigned)FnKindPair.second << FnDesc
11276 << ToParamRange << FromTy << ToTy << (
unsigned)isObjectArgument << I + 1
11277 << (
unsigned)(Cand->
Fix.
Kind);
11279 MaybeEmitInheritedConstructorNote(S, Cand->
FoundDecl);
11284 unsigned BaseToDerivedConversion = 0;
11287 if (ToPtrTy->getPointeeType().isAtLeastAsQualifiedAs(
11288 FromPtrTy->getPointeeType()) &&
11289 !FromPtrTy->getPointeeType()->isIncompleteType() &&
11290 !ToPtrTy->getPointeeType()->isIncompleteType() &&
11292 FromPtrTy->getPointeeType()))
11293 BaseToDerivedConversion = 1;
11301 if (ToPtrTy->getPointeeType().isAtLeastAsQualifiedAs(
11302 FromPtrTy->getPointeeType()) &&
11303 FromIface->isSuperClassOf(ToIface))
11304 BaseToDerivedConversion = 2;
11306 if (ToRefTy->getPointeeType().isAtLeastAsQualifiedAs(FromTy) &&
11308 !ToRefTy->getPointeeType()->isIncompleteType() &&
11310 BaseToDerivedConversion = 3;
11314 if (BaseToDerivedConversion) {
11315 S.
Diag(Fn->getLocation(), diag::note_ovl_candidate_bad_base_to_derived_conv)
11316 << (
unsigned)FnKindPair.first << (
unsigned)FnKindPair.second << FnDesc
11317 << ToParamRange << (BaseToDerivedConversion - 1) << FromTy << ToTy
11319 MaybeEmitInheritedConstructorNote(S, Cand->
FoundDecl);
11323 if (isa<ObjCObjectPointerType>(CFromTy) &&
11324 isa<PointerType>(CToTy)) {
11328 S.
Diag(Fn->getLocation(), diag::note_ovl_candidate_bad_arc_conv)
11329 << (
unsigned)FnKindPair.first << (
unsigned)FnKindPair.second << FnDesc
11330 << ToParamRange << FromTy << ToTy << (
unsigned)isObjectArgument
11332 MaybeEmitInheritedConstructorNote(S, Cand->
FoundDecl);
11342 FDiag << (
unsigned)FnKindPair.first << (
unsigned)FnKindPair.second << FnDesc
11343 << ToParamRange << FromTy << ToTy << (
unsigned)isObjectArgument << I + 1
11344 << (
unsigned)(Cand->
Fix.
Kind);
11353 S.
Diag(Fn->getLocation(), FDiag);
11355 MaybeEmitInheritedConstructorNote(S, Cand->
FoundDecl);
11362 unsigned NumArgs,
bool IsAddressOf =
false) {
11363 assert(Cand->
Function &&
"Candidate is required to be a function.");
11365 unsigned MinParams = Fn->getMinRequiredExplicitArguments() +
11366 ((IsAddressOf && !Fn->isStatic()) ? 1 : 0);
11373 if (Fn->isInvalidDecl() &&
11377 if (NumArgs < MinParams) {
11394 unsigned NumFormalArgs,
11395 bool IsAddressOf =
false) {
11396 assert(isa<FunctionDecl>(
D) &&
11397 "The templated declaration should at least be a function"
11398 " when diagnosing bad template argument deduction due to too many"
11399 " or too few arguments");
11405 unsigned MinParams = Fn->getMinRequiredExplicitArguments() +
11406 ((IsAddressOf && !Fn->isStatic()) ? 1 : 0);
11409 bool HasExplicitObjectParam =
11410 !IsAddressOf && Fn->hasCXXExplicitFunctionObjectParameter();
11412 unsigned ParamCount =
11413 Fn->getNumNonObjectParams() + ((IsAddressOf && !Fn->isStatic()) ? 1 : 0);
11414 unsigned mode, modeCount;
11416 if (NumFormalArgs < MinParams) {
11417 if (MinParams != ParamCount || FnTy->isVariadic() ||
11418 FnTy->isTemplateVariadic())
11422 modeCount = MinParams;
11424 if (MinParams != ParamCount)
11428 modeCount = ParamCount;
11431 std::string Description;
11432 std::pair<OverloadCandidateKind, OverloadCandidateSelect> FnKindPair =
11433 ClassifyOverloadCandidate(S,
Found, Fn,
CRK_None, Description);
11435 if (modeCount == 1 && !IsAddressOf &&
11436 Fn->getParamDecl(HasExplicitObjectParam ? 1 : 0)->getDeclName())
11437 S.
Diag(Fn->getLocation(), diag::note_ovl_candidate_arity_one)
11438 << (
unsigned)FnKindPair.first << (
unsigned)FnKindPair.second
11439 << Description << mode
11440 << Fn->getParamDecl(HasExplicitObjectParam ? 1 : 0) << NumFormalArgs
11441 << HasExplicitObjectParam << Fn->getParametersSourceRange();
11443 S.
Diag(Fn->getLocation(), diag::note_ovl_candidate_arity)
11444 << (
unsigned)FnKindPair.first << (
unsigned)FnKindPair.second
11445 << Description << mode << modeCount << NumFormalArgs
11446 << HasExplicitObjectParam << Fn->getParametersSourceRange();
11448 MaybeEmitInheritedConstructorNote(S,
Found);
11453 unsigned NumFormalArgs) {
11454 assert(Cand->
Function &&
"Candidate must be a function");
11464 llvm_unreachable(
"Unsupported: Getting the described template declaration"
11465 " for bad deduction diagnosis");
11472 bool TakingCandidateAddress) {
11478 switch (DeductionFailure.
getResult()) {
11481 "TemplateDeductionResult::Success while diagnosing bad deduction");
11483 llvm_unreachable(
"TemplateDeductionResult::NonDependentConversionFailure "
11484 "while diagnosing bad deduction");
11490 assert(ParamD &&
"no parameter found for incomplete deduction result");
11492 diag::note_ovl_candidate_incomplete_deduction)
11494 MaybeEmitInheritedConstructorNote(S,
Found);
11499 assert(ParamD &&
"no parameter found for incomplete deduction result");
11501 diag::note_ovl_candidate_incomplete_deduction_pack)
11505 MaybeEmitInheritedConstructorNote(S,
Found);
11510 assert(ParamD &&
"no parameter found for bad qualifiers deduction result");
11528 S.
Diag(Templated->
getLocation(), diag::note_ovl_candidate_underqualified)
11529 << ParamD->
getDeclName() << Arg << NonCanonParam;
11530 MaybeEmitInheritedConstructorNote(S,
Found);
11535 assert(ParamD &&
"no parameter found for inconsistent deduction result");
11537 if (isa<TemplateTypeParmDecl>(ParamD))
11539 else if (isa<NonTypeTemplateParmDecl>(ParamD)) {
11549 diag::note_ovl_candidate_inconsistent_deduction_types)
11552 MaybeEmitInheritedConstructorNote(S,
Found);
11572 diag::note_ovl_candidate_inconsistent_deduction)
11575 MaybeEmitInheritedConstructorNote(S,
Found);
11580 assert(ParamD &&
"no parameter found for invalid explicit arguments");
11583 diag::note_ovl_candidate_explicit_arg_mismatch_named)
11588 index = TTP->getIndex();
11590 = dyn_cast<NonTypeTemplateParmDecl>(ParamD))
11591 index = NTTP->getIndex();
11593 index = cast<TemplateTemplateParmDecl>(ParamD)->getIndex();
11595 diag::note_ovl_candidate_explicit_arg_mismatch_unnamed)
11598 MaybeEmitInheritedConstructorNote(S,
Found);
11605 TemplateArgString =
" ";
11608 if (TemplateArgString.size() == 1)
11609 TemplateArgString.clear();
11611 diag::note_ovl_candidate_unsatisfied_constraints)
11612 << TemplateArgString;
11615 static_cast<CNSInfo*
>(DeductionFailure.
Data)->Satisfaction);
11625 diag::note_ovl_candidate_instantiation_depth);
11626 MaybeEmitInheritedConstructorNote(S,
Found);
11634 TemplateArgString =
" ";
11637 if (TemplateArgString.size() == 1)
11638 TemplateArgString.clear();
11643 if (PDiag && PDiag->second.getDiagID() ==
11644 diag::err_typename_nested_not_found_enable_if) {
11647 S.
Diag(PDiag->first, diag::note_ovl_candidate_disabled_by_enable_if)
11648 <<
"'enable_if'" << TemplateArgString;
11653 if (PDiag && PDiag->second.getDiagID() ==
11654 diag::err_typename_nested_not_found_requirement) {
11656 diag::note_ovl_candidate_disabled_by_requirement)
11657 << PDiag->second.getStringArg(0) << TemplateArgString;
11667 SFINAEArgString =
": ";
11669 PDiag->second.EmitToString(S.
getDiagnostics(), SFINAEArgString);
11673 diag::note_ovl_candidate_substitution_failure)
11674 << TemplateArgString << SFINAEArgString << R;
11675 MaybeEmitInheritedConstructorNote(S,
Found);
11685 TemplateArgString =
" ";
11688 if (TemplateArgString.size() == 1)
11689 TemplateArgString.clear();
11692 S.
Diag(Templated->
getLocation(), diag::note_ovl_candidate_deduced_mismatch)
11695 << TemplateArgString
11720 diag::note_ovl_candidate_non_deduced_mismatch_qualified)
11727 if (TakingCandidateAddress && isa<FunctionDecl>(Templated) &&
11736 diag::note_ovl_candidate_non_deduced_mismatch)
11737 << FirstTA << SecondTA;
11743 S.
Diag(Templated->
getLocation(), diag::note_ovl_candidate_bad_deduction);
11744 MaybeEmitInheritedConstructorNote(S,
Found);
11748 diag::note_cuda_ovl_candidate_target_mismatch);
11756 bool TakingCandidateAddress) {
11757 assert(Cand->
Function &&
"Candidate must be a function");
11772 assert(Cand->
Function &&
"Candidate must be a Function.");
11778 std::string FnDesc;
11779 std::pair<OverloadCandidateKind, OverloadCandidateSelect> FnKindPair =
11780 ClassifyOverloadCandidate(S, Cand->
FoundDecl, Callee,
11783 S.
Diag(Callee->getLocation(), diag::note_ovl_candidate_bad_target)
11784 << (
unsigned)FnKindPair.first << (
unsigned)ocs_non_template
11786 << llvm::to_underlying(CalleeTarget) << llvm::to_underlying(CallerTarget);
11791 if (Meth !=
nullptr && Meth->
isImplicit()) {
11795 switch (FnKindPair.first) {
11798 case oc_implicit_default_constructor:
11801 case oc_implicit_copy_constructor:
11804 case oc_implicit_move_constructor:
11807 case oc_implicit_copy_assignment:
11810 case oc_implicit_move_assignment:
11815 bool ConstRHS =
false;
11819 ConstRHS = RT->getPointeeType().isConstQualified();
11830 assert(Cand->
Function &&
"Candidate must be a function");
11834 S.
Diag(Callee->getLocation(),
11835 diag::note_ovl_candidate_disabled_by_function_cond_attr)
11836 <<
Attr->getCond()->getSourceRange() <<
Attr->getMessage();
11840 assert(Cand->
Function &&
"Candidate must be a function");
11843 assert(ES.
isExplicit() &&
"not an explicit candidate");
11846 switch (Fn->getDeclKind()) {
11847 case Decl::Kind::CXXConstructor:
11850 case Decl::Kind::CXXConversion:
11853 case Decl::Kind::CXXDeductionGuide:
11854 Kind = Fn->isImplicit() ? 0 : 2;
11857 llvm_unreachable(
"invalid Decl");
11866 First = Pattern->getFirstDecl();
11869 diag::note_ovl_candidate_explicit)
11870 << Kind << (ES.
getExpr() ? 1 : 0)
11875 auto *DG = dyn_cast<CXXDeductionGuideDecl>(Fn);
11882 if (!(DG->isImplicit() || (OriginTemplate && OriginTemplate->
isTypeAlias())))
11884 std::string FunctionProto;
11885 llvm::raw_string_ostream OS(FunctionProto);
11898 "Non-template implicit deduction guides are only possible for "
11901 S.
Diag(DG->getLocation(), diag::note_implicit_deduction_guide)
11906 assert(Template &&
"Cannot find the associated function template of "
11907 "CXXDeductionGuideDecl?");
11909 Template->
print(OS);
11910 S.
Diag(DG->getLocation(), diag::note_implicit_deduction_guide)
11931 bool TakingCandidateAddress,
11933 assert(Cand->
Function &&
"Candidate must be a function");
11941 if (S.
getLangOpts().OpenCL && Fn->isImplicit() &&
11948 !Fn->hasCXXExplicitFunctionObjectParameter() && !Fn->isStatic())
11953 if (Fn->isDeleted()) {
11954 std::string FnDesc;
11955 std::pair<OverloadCandidateKind, OverloadCandidateSelect> FnKindPair =
11956 ClassifyOverloadCandidate(S, Cand->
FoundDecl, Fn,
11959 S.
Diag(Fn->getLocation(), diag::note_ovl_candidate_deleted)
11960 << (
unsigned)FnKindPair.first << (
unsigned)FnKindPair.second << FnDesc
11961 << (Fn->isDeleted() ? (Fn->isDeletedAsWritten() ? 1 : 2) : 0);
11962 MaybeEmitInheritedConstructorNote(S, Cand->
FoundDecl);
11989 TakingCandidateAddress);
11992 S.
Diag(Fn->getLocation(), diag::note_ovl_candidate_illegal_constructor)
11993 << (Fn->getPrimaryTemplate() ? 1 : 0);
11994 MaybeEmitInheritedConstructorNote(S, Cand->
FoundDecl);
12001 S.
Diag(Fn->getLocation(),
12002 diag::note_ovl_candidate_illegal_constructor_adrspace_mismatch)
12003 << QualsForPrinting;
12004 MaybeEmitInheritedConstructorNote(S, Cand->
FoundDecl);
12015 for (
unsigned N = Cand->
Conversions.size(); I != N; ++I)
12036 if (cast<CXXConstructorDecl>(Fn)->isCopyOrMoveConstructor())
12038 S.
Diag(Fn->getLocation(),
12039 diag::note_ovl_candidate_inherited_constructor_slice)
12040 << (Fn->getPrimaryTemplate() ? 1 : 0)
12041 << Fn->getParamDecl(0)->getType()->isRValueReferenceType();
12042 MaybeEmitInheritedConstructorNote(S, Cand->
FoundDecl);
12048 assert(!Available);
12056 std::string FnDesc;
12057 std::pair<OverloadCandidateKind, OverloadCandidateSelect> FnKindPair =
12058 ClassifyOverloadCandidate(S, Cand->
FoundDecl, Fn,
12061 S.
Diag(Fn->getLocation(),
12062 diag::note_ovl_candidate_constraints_not_satisfied)
12063 << (
unsigned)FnKindPair.first << (
unsigned)ocs_non_template
12081 bool isLValueReference =
false;
12082 bool isRValueReference =
false;
12083 bool isPointer =
false;
12087 isLValueReference =
true;
12091 isRValueReference =
true;
12107 diag::note_ovl_surrogate_constraints_not_satisfied)
12121 assert(Cand->
Conversions.size() <= 2 &&
"builtin operator is not binary");
12122 std::string TypeStr(
"operator");
12128 S.
Diag(OpLoc, diag::note_ovl_builtin_candidate) << TypeStr;
12133 S.
Diag(OpLoc, diag::note_ovl_builtin_candidate) << TypeStr;
12140 if (ICS.
isBad())
break;
12144 S, OpLoc, S.
PDiag(diag::note_ambiguous_type_conversion));
12161 llvm_unreachable(
"non-deduction failure while diagnosing bad deduction");
12191 llvm_unreachable(
"Unhandled deduction result");
12196struct CompareOverloadCandidatesForDisplay {
12202 CompareOverloadCandidatesForDisplay(
12205 : S(S), NumArgs(NArgs), CSK(CSK) {}
12215 if (NumArgs >
C->Function->getNumParams() && !
C->Function->isVariadic())
12217 if (NumArgs < C->
Function->getMinRequiredArguments())
12227 if (L == R)
return false;
12231 if (!R->
Viable)
return true;
12233 if (
int Ord = CompareConversions(*L, *R))
12253 if (LDist == RDist) {
12254 if (LFailureKind == RFailureKind)
12262 return LDist < RDist;
12280 numLFixes = (numLFixes == 0) ?
UINT_MAX : numLFixes;
12281 numRFixes = (numRFixes == 0) ?
UINT_MAX : numRFixes;
12282 if (numLFixes != numRFixes) {
12283 return numLFixes < numRFixes;
12287 if (
int Ord = CompareConversions(*L, *R))
12299 if (LRank != RRank)
12300 return LRank < RRank;
12326 struct ConversionSignals {
12327 unsigned KindRank = 0;
12331 ConversionSignals Sig;
12332 Sig.KindRank =
Seq.getKindRank();
12333 if (
Seq.isStandard())
12334 Sig.Rank =
Seq.Standard.getRank();
12335 else if (
Seq.isUserDefined())
12336 Sig.Rank =
Seq.UserDefined.After.getRank();
12342 static ConversionSignals ForObjectArgument() {
12358 for (
unsigned I = 0, N = L.
Conversions.size(); I != N; ++I) {
12360 ? ConversionSignals::ForObjectArgument()
12361 : ConversionSignals::ForSequence(L.Conversions[I]);
12363 ? ConversionSignals::ForObjectArgument()
12364 : ConversionSignals::ForSequence(R.Conversions[I]);
12365 if (std::tie(LS.KindRank, LS.Rank) != std::tie(RS.KindRank, RS.Rank))
12366 return std::tie(LS.KindRank, LS.Rank) < std::tie(RS.KindRank, RS.Rank)
12391 bool Unfixable =
false;
12399 assert(ConvIdx != ConvCount &&
"no bad conversion in candidate");
12400 if (Cand->
Conversions[ConvIdx].isInitialized() &&
12409 bool SuppressUserConversions =
false;
12411 unsigned ConvIdx = 0;
12412 unsigned ArgIdx = 0;
12427 if (isa<CXXMethodDecl>(Cand->
Function) &&
12440 assert(ConvCount <= 3);
12446 ConvIdx != ConvCount;
12448 assert(ArgIdx < Args.size() &&
"no argument for this arg conversion");
12449 if (Cand->
Conversions[ConvIdx].isInitialized()) {
12451 }
else if (
ParamIdx < ParamTypes.size()) {
12452 if (ParamTypes[
ParamIdx]->isDependentType())
12453 Cand->
Conversions[ConvIdx].setAsIdentityConversion(
12454 Args[ArgIdx]->getType());
12458 SuppressUserConversions,
12463 if (!Unfixable && Cand->
Conversions[ConvIdx].isBad())
12479 for (
iterator Cand =
begin(), LastCand =
end(); Cand != LastCand; ++Cand) {
12480 if (!Filter(*Cand))
12484 if (!Cand->Viable) {
12485 if (!Cand->Function && !Cand->IsSurrogate) {
12505 Cands.push_back(Cand);
12509 Cands, CompareOverloadCandidatesForDisplay(S, OpLoc, Args.size(), Kind));
12516 bool DeferHint =
false;
12520 auto WrongSidedCands =
12522 return (Cand.Viable ==
false &&
12525 Cand.Function->template hasAttr<CUDAHostAttr>() &&
12526 Cand.Function->template hasAttr<CUDADeviceAttr>());
12528 DeferHint = !WrongSidedCands.empty();
12546 bool NoteCands =
true;
12547 for (
const Expr *Arg : Args) {
12548 if (Arg->getType()->isWebAssemblyTableType())
12562 bool ReportedAmbiguousConversions =
false;
12565 unsigned CandsShown = 0;
12566 auto I = Cands.begin(),
E = Cands.end();
12567 for (; I !=
E; ++I) {
12583 "Non-viable built-in candidates are not added to Cands.");
12590 if (!ReportedAmbiguousConversions) {
12592 ReportedAmbiguousConversions =
true;
12605 S.
Diag(OpLoc, diag::note_ovl_too_many_candidates,
12617struct CompareTemplateSpecCandidatesForDisplay {
12619 CompareTemplateSpecCandidatesForDisplay(
Sema &S) : S(S) {}
12653 bool ForTakingAddress) {
12655 DeductionFailure, 0, ForTakingAddress);
12658void TemplateSpecCandidateSet::destroyCandidates() {
12660 i->DeductionFailure.Destroy();
12665 destroyCandidates();
12666 Candidates.clear();
12679 Cands.reserve(
size());
12680 for (
iterator Cand =
begin(), LastCand =
end(); Cand != LastCand; ++Cand) {
12681 if (Cand->Specialization)
12682 Cands.push_back(Cand);
12687 llvm::sort(Cands, CompareTemplateSpecCandidatesForDisplay(S));
12694 unsigned CandsShown = 0;
12695 for (I = Cands.begin(),
E = Cands.end(); I !=
E; ++I) {
12701 if (CandsShown >= 4 && ShowOverloads ==
Ovl_Best)
12706 "Non-matching built-in candidates are not added to Cands.");
12711 S.
Diag(
Loc, diag::note_ovl_too_many_candidates) <<
int(
E - I);
12721 QualType Ret = PossiblyAFunctionType;
12724 Ret = ToTypePtr->getPointeeType();
12727 Ret = ToTypeRef->getPointeeType();
12730 Ret = MemTypePtr->getPointeeType();
12737 bool Complain =
true) {
12754class AddressOfFunctionResolver {
12764 bool TargetTypeIsNonStaticMemberFunction;
12765 bool FoundNonTemplateFunction;
12766 bool StaticMemberFunctionFromBoundPointer;
12767 bool HasComplained;
12776 AddressOfFunctionResolver(
Sema &S,
Expr *SourceExpr,
12777 const QualType &TargetType,
bool Complain)
12778 : S(S), SourceExpr(SourceExpr), TargetType(TargetType),
12779 Complain(Complain), Context(S.getASTContext()),
12780 TargetTypeIsNonStaticMemberFunction(
12782 FoundNonTemplateFunction(
false),
12783 StaticMemberFunctionFromBoundPointer(
false),
12784 HasComplained(
false),
12787 FailedCandidates(OvlExpr->getNameLoc(),
true) {
12788 ExtractUnqualifiedFunctionTypeFromTargetType();
12792 if (!UME->isImplicitAccess() &&
12794 StaticMemberFunctionFromBoundPointer =
true;
12798 OvlExpr,
false, &dap)) {
12804 TargetTypeIsNonStaticMemberFunction =
true;
12812 Matches.push_back(std::make_pair(dap, Fn));
12820 if (FindAllFunctionsThatMatchTargetTypeExactly()) {
12823 if (Matches.size() > 1 && !eliminiateSuboptimalOverloadCandidates()) {
12824 if (FoundNonTemplateFunction)
12825 EliminateAllTemplateMatches();
12827 EliminateAllExceptMostSpecializedTemplate();
12832 EliminateSuboptimalCudaMatches();
12835 bool hasComplained()
const {
return HasComplained; }
12838 bool candidateHasExactlyCorrectType(
const FunctionDecl *FD) {
12850 return candidateHasExactlyCorrectType(A) &&
12851 (!candidateHasExactlyCorrectType(B) ||
12857 bool eliminiateSuboptimalOverloadCandidates() {
12860 auto Best = Matches.begin();
12861 for (
auto I = Matches.begin()+1,
E = Matches.end(); I !=
E; ++I)
12862 if (isBetterCandidate(I->second, Best->second))
12866 auto IsBestOrInferiorToBest = [
this, BestFn](
12867 const std::pair<DeclAccessPair, FunctionDecl *> &Pair) {
12868 return BestFn == Pair.second || isBetterCandidate(BestFn, Pair.second);
12873 if (!llvm::all_of(Matches, IsBestOrInferiorToBest))
12875 Matches[0] = *Best;
12880 bool isTargetTypeAFunction()
const {
12889 void inline ExtractUnqualifiedFunctionTypeFromTargetType() {
12900 bool CanConvertToFunctionPointer =
12902 if (CanConvertToFunctionPointer == TargetTypeIsNonStaticMemberFunction)
12905 else if (TargetTypeIsNonStaticMemberFunction)
12917 FunctionTemplate, &OvlExplicitTemplateArgs, TargetFunctionType,
12919 Result != TemplateDeductionResult::Success) {
12937 Matches.push_back(std::make_pair(CurAccessFunPair,
Specialization));
12941 bool AddMatchingNonTemplateFunction(
NamedDecl* Fn,
12946 bool CanConvertToFunctionPointer =
12948 if (CanConvertToFunctionPointer == TargetTypeIsNonStaticMemberFunction)
12951 else if (TargetTypeIsNonStaticMemberFunction)
12954 if (
FunctionDecl *FunDecl = dyn_cast<FunctionDecl>(Fn)) {
12961 if (FunDecl->isMultiVersion()) {
12962 const auto *TA = FunDecl->
getAttr<TargetAttr>();
12963 if (TA && !TA->isDefaultVersion())
12965 const auto *TVA = FunDecl->getAttr<TargetVersionAttr>();
12966 if (TVA && !TVA->isDefaultVersion())
12974 HasComplained |= Complain;
12983 candidateHasExactlyCorrectType(FunDecl)) {
12984 Matches.push_back(std::make_pair(
12985 CurAccessFunPair, cast<FunctionDecl>(FunDecl->getCanonicalDecl())));
12986 FoundNonTemplateFunction =
true;
12994 bool FindAllFunctionsThatMatchTargetTypeExactly() {
12999 if (IsInvalidFormOfPointerToMemberFunction())
13015 = dyn_cast<FunctionTemplateDecl>(Fn)) {
13016 if (AddMatchingTemplateFunction(FunctionTemplate, I.getPair()))
13021 AddMatchingNonTemplateFunction(Fn, I.getPair()))
13024 assert(Ret || Matches.empty());
13028 void EliminateAllExceptMostSpecializedTemplate() {
13041 for (
unsigned I = 0,
E = Matches.size(); I !=
E; ++I)
13042 MatchesCopy.
addDecl(Matches[I].second, Matches[I].first.getAccess());
13047 MatchesCopy.
begin(), MatchesCopy.
end(), FailedCandidates,
13049 S.
PDiag(diag::err_addr_ovl_ambiguous)
13050 << Matches[0].second->getDeclName(),
13051 S.
PDiag(diag::note_ovl_candidate)
13052 << (
unsigned)oc_function << (
unsigned)ocs_described_template,
13053 Complain, TargetFunctionType);
13055 if (Result != MatchesCopy.
end()) {
13057 Matches[0].first = Matches[Result - MatchesCopy.
begin()].first;
13058 Matches[0].second = cast<FunctionDecl>(*Result);
13061 HasComplained |= Complain;
13064 void EliminateAllTemplateMatches() {
13067 for (
unsigned I = 0, N = Matches.size(); I != N; ) {
13068 if (Matches[I].second->getPrimaryTemplate() ==
nullptr)
13071 Matches[I] = Matches[--N];
13077 void EliminateSuboptimalCudaMatches() {
13083 void ComplainNoMatchesFound()
const {
13084 assert(Matches.empty());
13086 << OvlExpr->
getName() << TargetFunctionType
13088 if (FailedCandidates.
empty())
13099 dyn_cast<FunctionDecl>((*I)->getUnderlyingDecl()))
13107 bool IsInvalidFormOfPointerToMemberFunction()
const {
13108 return TargetTypeIsNonStaticMemberFunction &&
13112 void ComplainIsInvalidFormOfPointerToMemberFunction()
const {
13120 bool IsStaticMemberFunctionFromBoundPointer()
const {
13121 return StaticMemberFunctionFromBoundPointer;
13124 void ComplainIsStaticMemberFunctionFromBoundPointer()
const {
13126 diag::err_invalid_form_pointer_member_function)
13130 void ComplainOfInvalidConversion()
const {
13132 << OvlExpr->
getName() << TargetType;
13135 void ComplainMultipleMatchesFound()
const {
13136 assert(Matches.size() > 1);
13143 bool hadMultipleCandidates()
const {
return (OvlExpr->
getNumDecls() > 1); }
13145 int getNumMatches()
const {
return Matches.size(); }
13148 if (Matches.size() != 1)
return nullptr;
13149 return Matches[0].second;
13153 if (Matches.size() != 1)
return nullptr;
13154 return &Matches[0].first;
13164 bool *pHadMultipleCandidates) {
13167 AddressOfFunctionResolver Resolver(*
this, AddressOfExpr, TargetType,
13169 int NumMatches = Resolver.getNumMatches();
13171 bool ShouldComplain = Complain && !Resolver.hasComplained();
13172 if (NumMatches == 0 && ShouldComplain) {
13173 if (Resolver.IsInvalidFormOfPointerToMemberFunction())
13174 Resolver.ComplainIsInvalidFormOfPointerToMemberFunction();
13176 Resolver.ComplainNoMatchesFound();
13178 else if (NumMatches > 1 && ShouldComplain)
13179 Resolver.ComplainMultipleMatchesFound();
13180 else if (NumMatches == 1) {
13181 Fn = Resolver.getMatchingFunctionDecl();
13184 ResolveExceptionSpec(AddressOfExpr->
getExprLoc(), FPT);
13185 FoundResult = *Resolver.getMatchingFunctionAccessPair();
13187 if (Resolver.IsStaticMemberFunctionFromBoundPointer())
13188 Resolver.ComplainIsStaticMemberFunctionFromBoundPointer();
13190 CheckAddressOfMemberAccess(AddressOfExpr, FoundResult);
13194 if (pHadMultipleCandidates)
13195 *pHadMultipleCandidates = Resolver.hadMultipleCandidates();
13203 bool IsResultAmbiguous =
false;
13211 return static_cast<int>(
CUDA().IdentifyPreference(Caller, FD1)) -
13212 static_cast<int>(
CUDA().IdentifyPreference(Caller, FD2));
13219 auto *FD = dyn_cast<FunctionDecl>(I->getUnderlyingDecl());
13227 auto FoundBetter = [&]() {
13228 IsResultAmbiguous =
false;
13239 if (getLangOpts().CUDA) {
13240 int PreferenceByCUDA = CheckCUDAPreference(FD,
Result);
13242 if (PreferenceByCUDA != 0) {
13244 if (PreferenceByCUDA > 0)
13252 if (MoreConstrained != FD) {
13253 if (!MoreConstrained) {
13254 IsResultAmbiguous =
true;
13255 AmbiguousDecls.push_back(FD);
13264 if (IsResultAmbiguous)
13275 if (getLangOpts().
CUDA && CheckCUDAPreference(Skipped,
Result) != 0)
13277 if (!getMoreConstrainedFunction(Skipped,
Result))
13286 ExprResult &SrcExpr,
bool DoFunctionPointerConversion) {
13292 if (!
Found ||
Found->isCPUDispatchMultiVersion() ||
13293 Found->isCPUSpecificMultiVersion())
13300 CheckAddressOfMemberAccess(
E, DAP);
13306 SrcExpr = DefaultFunctionArrayConversion(Fixed,
false);
13341 = cast<FunctionTemplateDecl>((*I)->getUnderlyingDecl());
13370 NoteAllOverloadCandidates(ovl);
13376 if (FoundResult) *FoundResult = I.getPair();
13387 ExprResult &SrcExpr,
bool doFunctionPointerConversion,
bool complain,
13389 unsigned DiagIDForComplaining) {
13396 if (
FunctionDecl *fn = ResolveSingleFunctionTemplateSpecialization(
13408 isa<CXXMethodDecl>(fn) &&
13409 cast<CXXMethodDecl>(fn)->isInstance()) {
13410 if (!complain)
return false;
13413 diag::err_bound_member_function)
13426 SingleFunctionExpression =
13427 FixOverloadedFunctionReference(SrcExpr.
get(), found, fn);
13430 if (doFunctionPointerConversion) {
13431 SingleFunctionExpression =
13432 DefaultFunctionArrayLvalueConversion(SingleFunctionExpression.
get());
13433 if (SingleFunctionExpression.
isInvalid()) {
13440 if (!SingleFunctionExpression.
isUsable()) {
13442 Diag(OpRangeForComplaining.
getBegin(), DiagIDForComplaining)
13444 << DestTypeForComplaining
13445 << OpRangeForComplaining
13447 NoteAllOverloadCandidates(SrcExpr.
get());
13456 SrcExpr = SingleFunctionExpression;
13466 bool PartialOverloading,
13468 NamedDecl *Callee = FoundDecl.getDecl();
13469 if (isa<UsingShadowDecl>(Callee))
13470 Callee = cast<UsingShadowDecl>(Callee)->getTargetDecl();
13473 if (ExplicitTemplateArgs) {
13474 assert(!KnownValid &&
"Explicit template arguments?");
13483 PartialOverloading);
13488 = dyn_cast<FunctionTemplateDecl>(Callee)) {
13490 ExplicitTemplateArgs, Args, CandidateSet,
13492 PartialOverloading);
13496 assert(!KnownValid &&
"unhandled case in overloaded call candidate");
13502 bool PartialOverloading) {
13525 assert(!(*I)->getDeclContext()->isRecord());
13526 assert(isa<UsingShadowDecl>(*I) ||
13527 !(*I)->getDeclContext()->isFunctionOrMethod());
13528 assert((*I)->getUnderlyingDecl()->isFunctionOrFunctionTemplate());
13538 ExplicitTemplateArgs = &TABuffer;
13544 CandidateSet, PartialOverloading,
13549 Args, ExplicitTemplateArgs,
13550 CandidateSet, PartialOverloading);
13558 CandidateSet,
false,
false);
13564 switch (Name.getCXXOverloadedOperator()) {
13565 case OO_New:
case OO_Array_New:
13566 case OO_Delete:
case OO_Array_Delete:
13589 if (DC->isTransparentContext())
13605 if (
auto *RD = dyn_cast<CXXRecordDecl>(DC)) {
13610 if (FoundInClass) {
13611 *FoundInClass = RD;
13614 R.
addDecl(Best->FoundDecl.getDecl(), Best->FoundDecl.getAccess());
13631 AssociatedNamespaces,
13632 AssociatedClasses);
13636 for (Sema::AssociatedNamespaceSet::iterator
13637 it = AssociatedNamespaces.begin(),
13638 end = AssociatedNamespaces.end(); it !=
end; ++it) {
13640 if (
Std &&
Std->Encloses(*it))
13650 SuggestedNamespaces.insert(*it);
13654 SemaRef.
Diag(R.
getNameLoc(), diag::err_not_found_by_two_phase_lookup)
13656 if (SuggestedNamespaces.empty()) {
13657 SemaRef.
Diag(Best->Function->getLocation(),
13658 diag::note_not_found_by_two_phase_lookup)
13660 }
else if (SuggestedNamespaces.size() == 1) {
13661 SemaRef.
Diag(Best->Function->getLocation(),
13662 diag::note_not_found_by_two_phase_lookup)
13668 SemaRef.
Diag(Best->Function->getLocation(),
13669 diag::note_not_found_by_two_phase_lookup)
13701class BuildRecoveryCallExprRAII {
13706 BuildRecoveryCallExprRAII(
Sema &S) : SemaRef(S), SatStack(S) {
13728 bool EmptyLookup,
bool AllowTypoCorrection) {
13736 BuildRecoveryCallExprRAII RCE(SemaRef);
13746 ExplicitTemplateArgs = &TABuffer;
13754 ExplicitTemplateArgs, Args, &FoundInClass)) {
13756 }
else if (EmptyLookup) {
13761 ExplicitTemplateArgs !=
nullptr,
13762 dyn_cast<MemberExpr>(Fn));
13764 AllowTypoCorrection
13770 }
else if (FoundInClass && SemaRef.
getLangOpts().MSVCCompat) {
13785 assert(!R.
empty() &&
"lookup results empty despite recovery");
13796 if ((*R.
begin())->isCXXClassMember())
13798 ExplicitTemplateArgs, S);
13799 else if (ExplicitTemplateArgs || TemplateKWLoc.
isValid())
13801 ExplicitTemplateArgs);
13825 assert(!ULE->
getQualifier() &&
"qualified name with ADL");
13832 (F = dyn_cast<FunctionDecl>(*ULE->
decls_begin())) &&
13834 llvm_unreachable(
"performing ADL for builtin");
13837 assert(getLangOpts().
CPlusPlus &&
"ADL enabled in C");
13841 UnbridgedCastsSet UnbridgedCasts;
13849 AddOverloadedCallCandidates(ULE, Args, *CandidateSet);
13851 if (getLangOpts().MSVCCompat &&
13852 CurContext->isDependentContext() && !isSFINAEContext() &&
13853 (isa<FunctionDecl>(CurContext) || isa<CXXRecordDecl>(CurContext))) {
13856 if (CandidateSet->
empty() ||
13865 RParenLoc, CurFPFeatureOverrides());
13872 if (CandidateSet->
empty())
13875 UnbridgedCasts.restore();
13882 std::optional<QualType>
Result;
13885 if (!Candidate.Function)
13887 if (Candidate.Function->isInvalidDecl())
13889 QualType T = Candidate.Function->getReturnType();
13902 if (Best && *Best != CS.
end())
13903 ConsiderCandidate(**Best);
13906 for (
const auto &
C : CS)
13908 ConsiderCandidate(
C);
13911 for (
const auto &
C : CS)
13912 ConsiderCandidate(
C);
13917 if (
Value.isNull() ||
Value->isUndeducedType())
13934 bool AllowTypoCorrection) {
13935 switch (OverloadResult) {
13946 Res.
get(), FDecl, LParenLoc, Args, RParenLoc, ExecConfig,
13947 false, (*Best)->IsADLCandidate);
13951 if (*Best != CandidateSet->
end() &&
13955 dyn_cast_if_present<CXXMethodDecl>((*Best)->Function);
13960 SemaRef.
PDiag(diag::err_member_call_without_object) << 0 << M),
13970 CandidateSet->
empty(),
13971 AllowTypoCorrection);
13978 for (
const Expr *Arg : Args) {
13979 if (!Arg->getType()->isFunctionType())
13981 if (
auto *DRE = dyn_cast<DeclRefExpr>(Arg->IgnoreParenImpCasts())) {
13982 auto *FD = dyn_cast<FunctionDecl>(DRE->getDecl());
13985 Arg->getExprLoc()))
13993 SemaRef.
PDiag(diag::err_ovl_no_viable_function_in_call)
13994 << ULE->
getName() << Fn->getSourceRange()),
14002 SemaRef.
PDiag(diag::err_ovl_ambiguous_call)
14003 << ULE->
getName() << Fn->getSourceRange()),
14010 Fn->getSourceRange(), ULE->
getName(),
14011 *CandidateSet, FDecl, Args);
14020 Res.
get(), FDecl, LParenLoc, Args, RParenLoc, ExecConfig,
14021 false, (*Best)->IsADLCandidate);
14027 SubExprs.append(Args.begin(), Args.end());
14034 for (
auto I = CS.
begin(),
E = CS.
end(); I !=
E; ++I) {
14049 bool AllowTypoCorrection,
14050 bool CalleesAddressIsTaken) {
14052 Fn->getExprLoc(), CalleesAddressIsTaken
14057 if (buildOverloadedCallSet(S, Fn, ULE, Args, LParenLoc, &CandidateSet,
14063 if (CalleesAddressIsTaken)
14077 if (
const auto *TP =
14081 VK_PRValue, RParenLoc, CurFPFeatureOverrides());
14087 ExecConfig, &CandidateSet, &Best,
14088 OverloadResult, AllowTypoCorrection);
14097 PerformADL, Fns.
begin(), Fns.
end(),
14103 bool HadMultipleCandidates) {
14108 Exp = InitializeExplicitObjectArgument(*
this,
E, Method);
14110 Exp = PerformImplicitObjectArgumentInitialization(
E,
nullptr,
14111 FoundDecl, Method);
14120 auto *CE = dyn_cast<CastExpr>(SubE);
14121 if (CE && CE->getCastKind() == CK_NoOp)
14122 SubE = CE->getSubExpr();
14124 if (
auto *BE = dyn_cast<CXXBindTemporaryExpr>(SubE))
14125 SubE = BE->getSubExpr();
14126 if (isa<LambdaExpr>(SubE)) {
14132 PushExpressionEvaluationContext(
14133 ExpressionEvaluationContext::PotentiallyEvaluated);
14134 ExprResult BlockExp = BuildBlockForLambdaConversion(
14136 PopExpressionEvaluationContext();
14154 Expr *ObjectParam = Exp.
get();
14157 CurFPFeatureOverrides());
14167 Exp.
get()->getEndLoc(),
14168 CurFPFeatureOverrides());
14171 if (CheckFunctionCall(Method, CE,
14181 Expr *Input,
bool PerformADL) {
14183 assert(Op !=
OO_None &&
"Invalid opcode for overloaded unary operator");
14191 Expr *Args[2] = { Input,
nullptr };
14192 unsigned NumArgs = 1;
14197 if (Opc == UO_PostInc || Opc == UO_PostDec) {
14211 if (Opc == UO_PreDec || Opc == UO_PreInc || Opc == UO_Deref)
14217 CurFPFeatureOverrides());
14222 if (Fn.isInvalid())
14226 CurFPFeatureOverrides());
14233 AddNonMemberOperatorCandidates(Fns, ArgsArray, CandidateSet);
14236 AddMemberOperatorCandidates(Op, OpLoc, ArgsArray, CandidateSet);
14240 AddArgumentDependentLookupCandidates(OpName, OpLoc, ArgsArray,
14246 AddBuiltinOperatorCandidates(Op, OpLoc, ArgsArray, CandidateSet);
14248 bool HadMultipleCandidates = (CandidateSet.
size() > 1);
14263 if (
CXXMethodDecl *Method = dyn_cast<CXXMethodDecl>(FnDecl)) {
14264 CheckMemberOperatorAccess(OpLoc, Input,
nullptr, Best->FoundDecl);
14268 InputInit = InitializeExplicitObjectArgument(*
this, Input, Method);
14270 InputInit = PerformImplicitObjectArgumentInitialization(
14271 Input,
nullptr, Best->FoundDecl, Method);
14274 Base = Input = InputInit.
get();
14285 Input = InputInit.
get();
14290 Base, HadMultipleCandidates,
14302 Context, Op, FnExpr.
get(), ArgsArray, ResultTy, VK, OpLoc,
14303 CurFPFeatureOverrides(), Best->IsADLCandidate);
14305 if (CheckCallReturnType(FnDecl->
getReturnType(), OpLoc, TheCall, FnDecl))
14308 if (CheckFunctionCall(FnDecl, TheCall,
14311 return CheckForImmediateInvocation(MaybeBindToTemporary(TheCall), FnDecl);
14316 ExprResult InputRes = PerformImplicitConversion(
14317 Input, Best->BuiltinParamTypes[0], Best->Conversions[0], AA_Passing,
14321 Input = InputRes.
get();
14341 PDiag(diag::err_ovl_ambiguous_oper_unary)
14358 << (Msg !=
nullptr)
14359 << (Msg ? Msg->
getString() : StringRef())
14370 return CreateBuiltinUnaryOp(OpLoc, Opc, Input);
14386 AddNonMemberOperatorCandidates(Fns, Args, CandidateSet);
14389 AddMemberOperatorCandidates(Op, OpLoc, Args, CandidateSet);
14391 AddMemberOperatorCandidates(Op, OpLoc, {Args[1], Args[0]}, CandidateSet,
14396 AddMemberOperatorCandidates(ExtraOp, OpLoc, Args, CandidateSet);
14398 AddMemberOperatorCandidates(ExtraOp, OpLoc, {Args[1], Args[0]},
14406 if (Op != OO_Equal && PerformADL) {
14408 AddArgumentDependentLookupCandidates(OpName, OpLoc, Args,
14414 AddArgumentDependentLookupCandidates(ExtraOpName, OpLoc, Args,
14433 AddBuiltinOperatorCandidates(Op, OpLoc, Args, CandidateSet);
14439 Expr *RHS,
bool PerformADL,
14440 bool AllowRewrittenCandidates,
14442 Expr *Args[2] = { LHS, RHS };
14446 AllowRewrittenCandidates =
false;
14452 if (Args[0]->isTypeDependent() || Args[1]->isTypeDependent()) {
14473 if (Fn.isInvalid())
14477 CurFPFeatureOverrides());
14482 if (Opc == BO_PtrMemD) {
14483 auto CheckPlaceholder = [&](
Expr *&Arg) {
14492 if (CheckPlaceholder(Args[0]) || CheckPlaceholder(Args[1]))
14494 return CreateBuiltinBinOp(OpLoc, Opc, Args[0], Args[1]);
14513 if (Opc == BO_Assign && !Args[0]->getType()->isOverloadableType())
14514 return CreateBuiltinBinOp(OpLoc, Opc, Args[0], Args[1]);
14519 Op, OpLoc, AllowRewrittenCandidates));
14521 CandidateSet.
exclude(DefaultedFn);
14522 LookupOverloadedBinOp(CandidateSet, Op, Fns, Args, PerformADL);
14524 bool HadMultipleCandidates = (CandidateSet.
size() > 1);
14533 bool IsReversed = Best->isReversed();
14535 std::swap(Args[0], Args[1]);
14552 if (Best->RewriteKind && ChosenOp == OO_EqualEqual &&
14556 Diag(OpLoc, IsExtension ? diag::ext_ovl_rewrite_equalequal_not_bool
14557 : diag::err_ovl_rewrite_equalequal_not_bool)
14565 if (AllowRewrittenCandidates && !IsReversed &&
14573 if (Cand.Viable && Cand.Function && Cand.isReversed() &&
14575 for (
unsigned ArgIdx = 0; ArgIdx < 2; ++ArgIdx) {
14577 *
this, OpLoc, Cand.Conversions[ArgIdx],
14578 Best->Conversions[ArgIdx]) ==
14580 AmbiguousWith.push_back(Cand.Function);
14587 if (!AmbiguousWith.empty()) {
14588 bool AmbiguousWithSelf =
14589 AmbiguousWith.size() == 1 &&
14591 Diag(OpLoc, diag::ext_ovl_ambiguous_oper_binary_reversed)
14593 << Args[0]->
getType() << Args[1]->
getType() << AmbiguousWithSelf
14595 if (AmbiguousWithSelf) {
14597 diag::note_ovl_ambiguous_oper_binary_reversed_self);
14602 if (
auto *MD = dyn_cast<CXXMethodDecl>(FnDecl))
14603 if (Op == OverloadedOperatorKind::OO_EqualEqual &&
14605 !MD->hasCXXExplicitFunctionObjectParameter() &&
14607 MD->getFunctionObjectParameterType(),
14608 MD->getParamDecl(0)->getType().getNonReferenceType()) &&
14610 MD->getFunctionObjectParameterType(),
14613 MD->getFunctionObjectParameterType(),
14616 diag::note_ovl_ambiguous_eqeq_reversed_self_non_const);
14619 diag::note_ovl_ambiguous_oper_binary_selected_candidate);
14620 for (
auto *F : AmbiguousWith)
14621 Diag(F->getLocation(),
14622 diag::note_ovl_ambiguous_oper_binary_reversed_candidate);
14630 if (Op == OO_Equal)
14631 diagnoseNullableToNonnullConversion(Args[0]->getType(),
14632 Args[1]->getType(), OpLoc);
14635 if (
CXXMethodDecl *Method = dyn_cast<CXXMethodDecl>(FnDecl)) {
14637 CheckMemberOperatorAccess(OpLoc, Args[0], Args[1], Best->FoundDecl);
14642 Arg0 = InitializeExplicitObjectArgument(*
this, Args[0], FnDecl);
14645 Arg0 = PerformImplicitObjectArgumentInitialization(
14646 Args[0],
nullptr, Best->FoundDecl, Method);
14648 Arg1 = PerformCopyInitialization(
14659 ExprResult Arg0 = PerformCopyInitialization(
14667 PerformCopyInitialization(
14679 Best->FoundDecl,
Base,
14680 HadMultipleCandidates, OpLoc);
14691 const Expr *ImplicitThis =
nullptr;
14696 Context, ChosenOp, FnExpr.
get(), Args, ResultTy, VK, OpLoc,
14697 CurFPFeatureOverrides(), Best->IsADLCandidate);
14699 if (
const auto *Method = dyn_cast<CXXMethodDecl>(FnDecl);
14702 ImplicitThis = ArgsArray[0];
14703 ArgsArray = ArgsArray.slice(1);
14706 if (CheckCallReturnType(FnDecl->
getReturnType(), OpLoc, TheCall,
14710 if (Op == OO_Equal) {
14712 DiagnoseSelfMove(Args[0], Args[1], OpLoc);
14716 if (ImplicitThis) {
14719 cast<CXXMethodDecl>(FnDecl)->getFunctionObjectParameterType());
14721 CheckArgAlignment(OpLoc, FnDecl,
"'this'", ThisType,
14725 checkCall(FnDecl,
nullptr, ImplicitThis, ArgsArray,
14727 VariadicDoesNotApply);
14729 ExprResult R = MaybeBindToTemporary(TheCall);
14733 R = CheckForImmediateInvocation(R, FnDecl);
14740 (Op == OO_Spaceship && IsReversed)) {
14741 if (Op == OO_ExclaimEqual) {
14742 assert(ChosenOp == OO_EqualEqual &&
"unexpected operator name");
14743 R = CreateBuiltinUnaryOp(OpLoc, UO_LNot, R.
get());
14745 assert(ChosenOp == OO_Spaceship &&
"unexpected operator name");
14747 Expr *ZeroLiteral =
14753 pushCodeSynthesisContext(Ctx);
14755 R = CreateOverloadedBinOp(
14756 OpLoc, Opc, Fns, IsReversed ? ZeroLiteral : R.
get(),
14757 IsReversed ? R.
get() : ZeroLiteral,
true,
14760 popCodeSynthesisContext();
14765 assert(ChosenOp == Op &&
"unexpected operator name");
14769 if (Best->RewriteKind !=
CRK_None)
14777 ExprResult ArgsRes0 = PerformImplicitConversion(
14778 Args[0], Best->BuiltinParamTypes[0], Best->Conversions[0],
14782 Args[0] = ArgsRes0.
get();
14784 ExprResult ArgsRes1 = PerformImplicitConversion(
14785 Args[1], Best->BuiltinParamTypes[1], Best->Conversions[1],
14789 Args[1] = ArgsRes1.
get();
14799 if (Opc == BO_Comma)
14804 if (DefaultedFn && Opc == BO_Cmp) {
14805 ExprResult E = BuildSynthesizedThreeWayComparison(OpLoc, Fns, Args[0],
14806 Args[1], DefaultedFn);
14807 if (
E.isInvalid() ||
E.isUsable())
14821 Opc >= BO_Assign && Opc <= BO_OrAssign) {
14822 Diag(OpLoc, diag::err_ovl_no_viable_oper)
14825 if (Args[0]->getType()->isIncompleteType()) {
14826 Diag(OpLoc, diag::note_assign_lhs_incomplete)
14840 Result = CreateBuiltinBinOp(OpLoc, Opc, Args[0], Args[1]);
14842 assert(
Result.isInvalid() &&
14843 "C++ binary operator overloading is missing candidates!");
14852 << Args[0]->getType()
14853 << Args[1]->getType()
14854 << Args[0]->getSourceRange()
14855 << Args[1]->getSourceRange()),
14861 if (isImplicitlyDeleted(Best->Function)) {
14865 Diag(OpLoc, diag::err_ovl_deleted_special_oper)
14870 Diag(OpLoc, diag::err_ovl_deleted_comparison)
14871 << Args[0]->
getType() << DeletedFD;
14876 NoteDeletedFunction(DeletedFD);
14884 PDiag(diag::err_ovl_deleted_oper)
14886 .getCXXOverloadedOperator())
14887 << (Msg !=
nullptr) << (Msg ? Msg->
getString() : StringRef())
14888 << Args[0]->getSourceRange() << Args[1]->getSourceRange()),
14896 return CreateBuiltinBinOp(OpLoc, Opc, Args[0], Args[1]);
14912 "cannot use prvalue expressions more than once");
14913 Expr *OrigLHS = LHS;
14914 Expr *OrigRHS = RHS;
14918 LHS =
new (Context)
14921 RHS =
new (Context)
14925 ExprResult Eq = CreateOverloadedBinOp(OpLoc, BO_EQ, Fns, LHS, RHS,
true,
true,
14927 if (
Eq.isInvalid())
14930 ExprResult Less = CreateOverloadedBinOp(OpLoc, BO_LT, Fns, LHS, RHS,
true,
14931 true, DefaultedFn);
14932 if (
Less.isInvalid())
14937 Greater = CreateOverloadedBinOp(OpLoc, BO_LT, Fns, RHS, LHS,
true,
true,
14944 struct Comparison {
14959 for (; I >= 0; --I) {
14961 auto *VI = Info->lookupValueInfo(Comparisons[I].
Result);
14972 Result = ActOnConditionalOp(OpLoc, OpLoc, Comparisons[I].Cmp.get(),
14984 Context, OrigLHS, OrigRHS, BO_Cmp,
Result.get()->getType(),
14985 Result.get()->getValueKind(),
Result.get()->getObjectKind(), OpLoc,
14986 CurFPFeatureOverrides());
14987 Expr *SemanticForm[] = {LHS, RHS,
Result.get()};
14997 unsigned NumArgsSlots =
14998 MethodArgs.size() + std::max<unsigned>(Args.size(), NumParams);
15001 MethodArgs.reserve(MethodArgs.size() + NumArgsSlots);
15002 bool IsError =
false;
15005 for (
unsigned i = 0; i != NumParams; i++) {
15007 if (i < Args.size()) {
15025 MethodArgs.push_back(Arg);
15035 Args.push_back(
Base);
15036 for (
auto *e : ArgExpr) {
15045 ArgExpr.back()->getEndLoc());
15057 if (Fn.isInvalid())
15063 CurFPFeatureOverrides());
15067 UnbridgedCastsSet UnbridgedCasts;
15077 AddMemberOperatorCandidates(OO_Subscript, LLoc, Args, CandidateSet);
15080 if (Args.size() == 2)
15081 AddBuiltinOperatorCandidates(OO_Subscript, LLoc, Args, CandidateSet);
15083 bool HadMultipleCandidates = (CandidateSet.
size() > 1);
15096 CheckMemberOperatorAccess(LLoc, Args[0], ArgExpr, Best->FoundDecl);
15105 InitializeExplicitObjectArgument(*
this, Args[0], Method);
15108 Args[0] = Res.
get();
15111 ExprResult Arg0 = PerformImplicitObjectArgumentInitialization(
15112 Args[0],
nullptr, Best->FoundDecl, Method);
15116 MethodArgs.push_back(Arg0.
get());
15120 *
this, MethodArgs, Method, ArgExpr, LLoc);
15128 *
this, FnDecl, Best->FoundDecl,
Base, HadMultipleCandidates,
15139 Context, OO_Subscript, FnExpr.
get(), MethodArgs, ResultTy, VK, RLoc,
15140 CurFPFeatureOverrides());
15142 if (CheckCallReturnType(FnDecl->
getReturnType(), LLoc, TheCall, FnDecl))
15145 if (CheckFunctionCall(Method, TheCall,
15149 return CheckForImmediateInvocation(MaybeBindToTemporary(TheCall),
15155 ExprResult ArgsRes0 = PerformImplicitConversion(
15156 Args[0], Best->BuiltinParamTypes[0], Best->Conversions[0],
15160 Args[0] = ArgsRes0.
get();
15162 ExprResult ArgsRes1 = PerformImplicitConversion(
15163 Args[1], Best->BuiltinParamTypes[1], Best->Conversions[1],
15167 Args[1] = ArgsRes1.
get();
15175 CandidateSet.
empty()
15176 ? (PDiag(diag::err_ovl_no_oper)
15177 << Args[0]->getType() << 0
15178 << Args[0]->getSourceRange() <<
Range)
15179 : (PDiag(diag::err_ovl_no_viable_subscript)
15180 << Args[0]->getType() << Args[0]->getSourceRange() <<
Range);
15187 if (Args.size() == 2) {
15190 LLoc, PDiag(diag::err_ovl_ambiguous_oper_binary)
15191 <<
"[]" << Args[0]->getType() << Args[1]->getType()
15192 << Args[0]->getSourceRange() <<
Range),
15197 PDiag(diag::err_ovl_ambiguous_subscript_call)
15198 << Args[0]->getType()
15199 << Args[0]->getSourceRange() <<
Range),
15208 PDiag(diag::err_ovl_deleted_oper)
15209 <<
"[]" << (Msg !=
nullptr)
15210 << (Msg ? Msg->
getString() : StringRef())
15211 << Args[0]->getSourceRange() <<
Range),
15218 return CreateBuiltinArraySubscriptExpr(Args[0], LLoc, Args[1], RLoc);
15225 Expr *ExecConfig,
bool IsExecConfig,
15226 bool AllowRecovery) {
15235 if (
BinaryOperator *op = dyn_cast<BinaryOperator>(NakedMemExpr)) {
15237 assert(op->getOpcode() == BO_PtrMemD || op->getOpcode() == BO_PtrMemI);
15250 QualType objectType = op->getLHS()->getType();
15251 if (op->getOpcode() == BO_PtrMemI)
15255 Qualifiers difference = objectQuals - funcQuals;
15259 std::string qualsString = difference.
getAsString();
15260 Diag(LParenLoc, diag::err_pointer_to_member_call_drops_quals)
15263 << (qualsString.find(
' ') == std::string::npos ? 1 : 2);
15267 Context, MemExprE, Args, resultType, valueKind, RParenLoc,
15270 if (CheckCallReturnType(proto->
getReturnType(), op->getRHS()->getBeginLoc(),
15274 if (ConvertArgumentsForCall(call, op,
nullptr, proto, Args, RParenLoc))
15277 if (CheckOtherCall(call, proto))
15280 return MaybeBindToTemporary(call);
15287 if (!AllowRecovery)
15289 std::vector<Expr *> SubExprs = {MemExprE};
15290 llvm::append_range(SubExprs, Args);
15291 return CreateRecoveryExpr(MemExprE->
getBeginLoc(), RParenLoc, SubExprs,
15294 if (isa<CXXPseudoDestructorExpr>(NakedMemExpr))
15296 RParenLoc, CurFPFeatureOverrides());
15298 UnbridgedCastsSet UnbridgedCasts;
15304 bool HadMultipleCandidates =
false;
15307 if (isa<MemberExpr>(NakedMemExpr)) {
15308 MemExpr = cast<MemberExpr>(NakedMemExpr);
15312 UnbridgedCasts.restore();
15330 TemplateArgs = &TemplateArgsBuffer;
15336 QualType ExplicitObjectType = ObjectType;
15340 if (isa<UsingShadowDecl>(
Func))
15341 Func = cast<UsingShadowDecl>(
Func)->getTargetDecl();
15343 bool HasExplicitParameter =
false;
15344 if (
const auto *M = dyn_cast<FunctionDecl>(
Func);
15345 M && M->hasCXXExplicitFunctionObjectParameter())
15346 HasExplicitParameter =
true;
15347 else if (
const auto *M = dyn_cast<FunctionTemplateDecl>(
Func);
15349 M->getTemplatedDecl()->hasCXXExplicitFunctionObjectParameter())
15350 HasExplicitParameter =
true;
15352 if (HasExplicitParameter)
15356 if (getLangOpts().MicrosoftExt && isa<CXXConstructorDecl>(
Func)) {
15357 AddOverloadCandidate(cast<CXXConstructorDecl>(
Func), I.getPair(), Args,
15360 }
else if ((Method = dyn_cast<CXXMethodDecl>(
Func))) {
15366 AddMethodCandidate(Method, I.getPair(), ActingDC, ExplicitObjectType,
15367 ObjectClassification, Args, CandidateSet,
15370 AddMethodTemplateCandidate(cast<FunctionTemplateDecl>(
Func),
15371 I.getPair(), ActingDC, TemplateArgs,
15372 ExplicitObjectType, ObjectClassification,
15373 Args, CandidateSet,
15378 HadMultipleCandidates = (CandidateSet.
size() > 1);
15382 UnbridgedCasts.restore();
15385 bool Succeeded =
false;
15389 Method = cast<CXXMethodDecl>(Best->Function);
15390 FoundDecl = Best->FoundDecl;
15391 CheckUnresolvedMemberAccess(UnresExpr, Best->FoundDecl);
15392 if (DiagnoseUseOfOverloadedDecl(Best->FoundDecl, UnresExpr->
getNameLoc()))
15400 if (Method != FoundDecl.getDecl() &&
15401 DiagnoseUseOfOverloadedDecl(Method, UnresExpr->
getNameLoc()))
15410 PDiag(diag::err_ovl_no_viable_member_function_in_call)
15417 PDiag(diag::err_ovl_ambiguous_member_call)
15422 DiagnoseUseOfDeletedFunction(
15424 CandidateSet, Best->Function, Args,
true);
15432 FixOverloadedFunctionReference(MemExprE, FoundDecl, Method);
15435 MemExprE = Res.
get();
15440 return BuildResolvedCallExpr(MemExprE, Method, LParenLoc, Args, RParenLoc,
15441 ExecConfig, IsExecConfig);
15451 assert(Method &&
"Member call to something that isn't a method?");
15464 HadMultipleCandidates, MemExpr->
getExprLoc());
15470 CurFPFeatureOverrides(), Proto->getNumParams());
15475 ExprResult ObjectArg = PerformImplicitObjectArgumentInitialization(
15476 MemExpr->
getBase(), Qualifier, FoundDecl, Method);
15481 RParenLoc, CurFPFeatureOverrides(),
15482 Proto->getNumParams());
15488 return BuildRecoveryExpr(ResultType);
15491 if (ConvertArgumentsForCall(TheCall, MemExpr, Method, Proto, Args,
15493 return BuildRecoveryExpr(ResultType);
15495 DiagnoseSentinelCalls(Method, LParenLoc, Args);
15497 if (CheckFunctionCall(Method, TheCall, Proto))
15503 if (
auto *MemE = dyn_cast<MemberExpr>(NakedMemExpr)) {
15504 if (
const EnableIfAttr *
Attr =
15505 CheckEnableIf(Method, LParenLoc, Args,
true)) {
15506 Diag(MemE->getMemberLoc(),
15507 diag::err_ovl_no_viable_member_function_in_call)
15510 diag::note_ovl_candidate_disabled_by_function_cond_attr)
15511 <<
Attr->getCond()->getSourceRange() <<
Attr->getMessage();
15516 if (isa<CXXConstructorDecl, CXXDestructorDecl>(CurContext) &&
15517 TheCall->getDirectCallee()->isPureVirtual()) {
15523 diag::warn_call_to_pure_virtual_member_function_from_ctor_dtor)
15524 << MD->
getDeclName() << isa<CXXDestructorDecl>(CurContext)
15528 if (getLangOpts().AppleKext)
15534 if (
auto *DD = dyn_cast<CXXDestructorDecl>(TheCall->getDirectCallee())) {
15536 bool CallCanBeVirtual = !MemExpr->
hasQualifier() || getLangOpts().AppleKext;
15537 CheckVirtualDtorCall(DD, MemExpr->
getBeginLoc(),
false,
15538 CallCanBeVirtual,
true,
15542 return CheckForImmediateInvocation(MaybeBindToTemporary(TheCall),
15543 TheCall->getDirectCallee());
15555 UnbridgedCastsSet UnbridgedCasts;
15559 assert(Object.get()->getType()->isRecordType() &&
15560 "Requires object type argument");
15573 if (RequireCompleteType(LParenLoc, Object.get()->getType(),
15574 diag::err_incomplete_object_call, Object.get()))
15578 LookupResult R(*
this, OpName, LParenLoc, LookupOrdinaryName);
15579 LookupQualifiedName(R,
Record->getDecl());
15580 R.suppressAccessDiagnostics();
15583 Oper != OperEnd; ++Oper) {
15584 AddMethodCandidate(Oper.getPair(), Object.get()->getType(),
15585 Object.get()->Classify(Context), Args, CandidateSet,
15597 bool IgnoreSurrogateFunctions =
false;
15598 if (CandidateSet.
size() == 1 &&
Record->getAsCXXRecordDecl()->isLambda()) {
15600 if (!Candidate.
Viable &&
15602 IgnoreSurrogateFunctions =
true;
15622 const auto &Conversions =
15623 cast<CXXRecordDecl>(
Record->getDecl())->getVisibleConversionFunctions();
15624 for (
auto I = Conversions.begin(),
E = Conversions.end();
15625 !IgnoreSurrogateFunctions && I !=
E; ++I) {
15628 if (isa<UsingShadowDecl>(
D))
15629 D = cast<UsingShadowDecl>(
D)->getTargetDecl();
15633 if (isa<FunctionTemplateDecl>(
D))
15646 AddSurrogateCandidate(Conv, I.getPair(), ActingContext, Proto,
15647 Object.get(), Args, CandidateSet);
15652 bool HadMultipleCandidates = (CandidateSet.
size() > 1);
15665 CandidateSet.
empty()
15666 ? (PDiag(diag::err_ovl_no_oper)
15667 << Object.get()->getType() << 1
15668 << Object.get()->getSourceRange())
15669 : (PDiag(diag::err_ovl_no_viable_object_call)
15670 << Object.get()->getType() << Object.get()->getSourceRange());
15677 if (!R.isAmbiguous())
15680 PDiag(diag::err_ovl_ambiguous_object_call)
15681 << Object.get()->getType()
15682 << Object.get()->getSourceRange()),
15693 PDiag(diag::err_ovl_deleted_object_call)
15694 << Object.get()->getType() << (Msg !=
nullptr)
15695 << (Msg ? Msg->
getString() : StringRef())
15696 << Object.get()->getSourceRange()),
15702 if (Best == CandidateSet.
end())
15705 UnbridgedCasts.restore();
15707 if (Best->Function ==
nullptr) {
15711 = cast<CXXConversionDecl>(
15712 Best->Conversions[0].UserDefined.ConversionFunction);
15714 CheckMemberOperatorAccess(LParenLoc, Object.get(),
nullptr,
15716 if (DiagnoseUseOfDecl(Best->FoundDecl, LParenLoc))
15718 assert(Conv == Best->FoundDecl.getDecl() &&
15719 "Found Decl & conversion-to-functionptr should be same, right?!");
15726 ExprResult Call = BuildCXXMemberCallExpr(Object.get(), Best->FoundDecl,
15727 Conv, HadMultipleCandidates);
15728 if (
Call.isInvalid())
15732 Context,
Call.get()->getType(), CK_UserDefinedConversion,
Call.get(),
15733 nullptr,
VK_PRValue, CurFPFeatureOverrides());
15735 return BuildCallExpr(S,
Call.get(), LParenLoc, Args, RParenLoc);
15738 CheckMemberOperatorAccess(LParenLoc, Object.get(),
nullptr, Best->FoundDecl);
15743 CXXMethodDecl *Method = cast<CXXMethodDecl>(Best->Function);
15756 Obj, HadMultipleCandidates,
15763 MethodArgs.reserve(NumParams + 1);
15765 bool IsError =
false;
15772 ExprResult ObjRes = PerformImplicitObjectArgumentInitialization(
15773 Object.get(),
nullptr, Best->FoundDecl, Method);
15778 MethodArgs.push_back(Object.get());
15782 *
this, MethodArgs, Method, Args, LParenLoc);
15785 if (Proto->isVariadic()) {
15787 for (
unsigned i = NumParams, e = Args.size(); i < e; i++) {
15788 ExprResult Arg = DefaultVariadicArgumentPromotion(Args[i], VariadicMethod,
15791 MethodArgs.push_back(Arg.
get());
15798 DiagnoseSentinelCalls(Method, LParenLoc, Args);
15806 Context, OO_Call, NewFn.
get(), MethodArgs, ResultTy, VK, RParenLoc,
15807 CurFPFeatureOverrides());
15809 if (CheckCallReturnType(Method->
getReturnType(), LParenLoc, TheCall, Method))
15812 if (CheckFunctionCall(Method, TheCall, Proto))
15815 return CheckForImmediateInvocation(MaybeBindToTemporary(TheCall), Method);
15820 bool *NoArrowOperatorFound) {
15821 assert(
Base->getType()->isRecordType() &&
15822 "left-hand side must have class type");
15839 if (RequireCompleteType(
Loc,
Base->getType(),
15840 diag::err_typecheck_incomplete_tag,
Base))
15843 LookupResult R(*
this, OpName, OpLoc, LookupOrdinaryName);
15848 Oper != OperEnd; ++Oper) {
15849 AddMethodCandidate(Oper.getPair(),
Base->getType(),
Base->Classify(Context),
15850 std::nullopt, CandidateSet,
15854 bool HadMultipleCandidates = (CandidateSet.
size() > 1);
15865 if (CandidateSet.
empty()) {
15867 if (NoArrowOperatorFound) {
15870 *NoArrowOperatorFound =
true;
15873 Diag(OpLoc, diag::err_typecheck_member_reference_arrow)
15874 << BaseType <<
Base->getSourceRange();
15876 Diag(OpLoc, diag::note_typecheck_member_reference_suggestion)
15880 Diag(OpLoc, diag::err_ovl_no_viable_oper)
15881 <<
"operator->" <<
Base->getSourceRange();
15889 <<
"->" <<
Base->getType()
15890 <<
Base->getSourceRange()),
15898 <<
"->" << (Msg !=
nullptr)
15899 << (Msg ? Msg->
getString() : StringRef())
15900 <<
Base->getSourceRange()),
15906 CheckMemberOperatorAccess(OpLoc,
Base,
nullptr, Best->FoundDecl);
15909 CXXMethodDecl *Method = cast<CXXMethodDecl>(Best->Function);
15912 ExprResult R = InitializeExplicitObjectArgument(*
this,
Base, Method);
15918 Base,
nullptr, Best->FoundDecl, Method);
15926 Base, HadMultipleCandidates, OpLoc);
15936 ResultTy, VK, OpLoc, CurFPFeatureOverrides());
15938 if (CheckCallReturnType(Method->
getReturnType(), OpLoc, TheCall, Method))
15941 if (CheckFunctionCall(Method, TheCall,
15945 return CheckForImmediateInvocation(MaybeBindToTemporary(TheCall), Method);
15957 AddNonMemberOperatorCandidates(R.
asUnresolvedSet(), Args, CandidateSet,
15960 bool HadMultipleCandidates = (CandidateSet.
size() > 1);
15973 PDiag(diag::err_ovl_no_viable_function_in_call)
15988 nullptr, HadMultipleCandidates,
15991 if (Fn.isInvalid())
15997 for (
unsigned ArgIdx = 0, N = Args.size(); ArgIdx != N; ++ArgIdx) {
15998 ExprResult InputInit = PerformCopyInitialization(
16003 ConvArgs[ArgIdx] = InputInit.
get();
16011 Context, Fn.get(),
llvm::ArrayRef(ConvArgs, Args.size()), ResultTy, VK,
16012 LitEndLoc, UDSuffixLoc, CurFPFeatureOverrides());
16014 if (CheckCallReturnType(FD->
getReturnType(), UDSuffixLoc, UDL, FD))
16017 if (CheckFunctionCall(FD, UDL,
nullptr))
16020 return CheckForImmediateInvocation(MaybeBindToTemporary(UDL), FD);
16030 Scope *S =
nullptr;
16033 if (!MemberLookup.
empty()) {
16043 return FRS_DiagnosticIssued;
16046 BuildCallExpr(S, MemberRef.
get(),
Loc, std::nullopt,
Loc,
nullptr);
16049 return FRS_DiagnosticIssued;
16052 ExprResult FnR = CreateUnresolvedLookupExpr(
nullptr,
16056 return FRS_DiagnosticIssued;
16059 bool CandidateSetError = buildOverloadedCallSet(S, Fn, Fn,
Range,
Loc,
16061 if (CandidateSet->
empty() || CandidateSetError) {
16063 return FRS_NoViableFunction;
16071 return FRS_NoViableFunction;
16074 Loc,
nullptr, CandidateSet, &Best,
16079 return FRS_DiagnosticIssued;
16082 return FRS_Success;
16087 if (
ParenExpr *PE = dyn_cast<ParenExpr>(
E)) {
16089 FixOverloadedFunctionReference(PE->getSubExpr(),
Found, Fn);
16092 if (SubExpr.
get() == PE->getSubExpr())
16095 return new (Context)
16096 ParenExpr(PE->getLParen(), PE->getRParen(), SubExpr.
get());
16101 FixOverloadedFunctionReference(ICE->getSubExpr(),
Found, Fn);
16104 assert(Context.
hasSameType(ICE->getSubExpr()->getType(),
16106 "Implicit cast type cannot be determined from overload");
16107 assert(ICE->path_empty() &&
"fixing up hierarchy conversion?");
16108 if (SubExpr.
get() == ICE->getSubExpr())
16113 CurFPFeatureOverrides());
16116 if (
auto *GSE = dyn_cast<GenericSelectionExpr>(
E)) {
16117 if (!GSE->isResultDependent()) {
16119 FixOverloadedFunctionReference(GSE->getResultExpr(),
Found, Fn);
16122 if (SubExpr.
get() == GSE->getResultExpr())
16129 unsigned ResultIdx = GSE->getResultIndex();
16130 AssocExprs[ResultIdx] = SubExpr.
get();
16132 if (GSE->isExprPredicate())
16134 Context, GSE->getGenericLoc(), GSE->getControllingExpr(),
16135 GSE->getAssocTypeSourceInfos(), AssocExprs, GSE->getDefaultLoc(),
16136 GSE->getRParenLoc(), GSE->containsUnexpandedParameterPack(),
16139 Context, GSE->getGenericLoc(), GSE->getControllingType(),
16140 GSE->getAssocTypeSourceInfos(), AssocExprs, GSE->getDefaultLoc(),
16141 GSE->getRParenLoc(), GSE->containsUnexpandedParameterPack(),
16150 assert(UnOp->getOpcode() == UO_AddrOf &&
16151 "Can only take the address of an overloaded function");
16161 FixOverloadedFunctionReference(UnOp->getSubExpr(),
Found, Fn);
16164 if (SubExpr.
get() == UnOp->getSubExpr())
16167 if (CheckUseOfCXXMethodAsAddressOfOperand(UnOp->getBeginLoc(),
16168 SubExpr.
get(), Method))
16171 assert(isa<DeclRefExpr>(SubExpr.
get()) &&
16172 "fixed to something other than a decl ref");
16173 assert(cast<DeclRefExpr>(SubExpr.
get())->getQualifier() &&
16174 "fixed to a member ref with no nested name qualifier");
16185 (void)isCompleteType(UnOp->getOperatorLoc(), MemPtrType);
16189 UnOp->getOperatorLoc(),
false,
16190 CurFPFeatureOverrides());
16194 FixOverloadedFunctionReference(UnOp->getSubExpr(),
Found, Fn);
16197 if (SubExpr.
get() == UnOp->getSubExpr())
16200 return CreateBuiltinUnaryOp(UnOp->getOperatorLoc(), UO_AddrOf,
16207 if (ULE->hasExplicitTemplateArgs()) {
16208 ULE->copyTemplateArgumentsInto(TemplateArgsBuffer);
16209 TemplateArgs = &TemplateArgsBuffer;
16214 getLangOpts().CPlusPlus && !Fn->hasCXXExplicitFunctionObjectParameter()
16219 if (
unsigned BID = Fn->getBuiltinID()) {
16227 Fn,
Type, ValueKind, ULE->getNameInfo(), ULE->getQualifierLoc(),
16228 Found.getDecl(), ULE->getTemplateKeywordLoc(), TemplateArgs);
16236 if (MemExpr->hasExplicitTemplateArgs()) {
16237 MemExpr->copyTemplateArgumentsInto(TemplateArgsBuffer);
16238 TemplateArgs = &TemplateArgsBuffer;
16245 if (MemExpr->isImplicitAccess()) {
16246 if (cast<CXXMethodDecl>(Fn)->isStatic()) {
16248 Fn, Fn->getType(),
VK_LValue, MemExpr->getNameInfo(),
16249 MemExpr->getQualifierLoc(),
Found.getDecl(),
16250 MemExpr->getTemplateKeywordLoc(), TemplateArgs);
16255 if (MemExpr->getQualifier())
16256 Loc = MemExpr->getQualifierLoc().getBeginLoc();
16258 BuildCXXThisExpr(
Loc, MemExpr->getBaseType(),
true);
16261 Base = MemExpr->getBase();
16265 if (cast<CXXMethodDecl>(Fn)->isStatic()) {
16267 type = Fn->getType();
16273 return BuildMemberExpr(
16274 Base, MemExpr->isArrow(), MemExpr->getOperatorLoc(),
16275 MemExpr->getQualifierLoc(), MemExpr->getTemplateKeywordLoc(), Fn,
Found,
16276 true, MemExpr->getMemberNameInfo(),
16280 llvm_unreachable(
"Invalid reference to overloaded function");
16286 return FixOverloadedFunctionReference(
E.get(),
Found, Fn);
16291 if (!PartialOverloading || !
Function)
16295 if (
const auto *Proto =
16296 dyn_cast<FunctionProtoType>(
Function->getFunctionType()))
16297 if (Proto->isTemplateVariadic())
16299 if (
auto *Pattern =
Function->getTemplateInstantiationPattern())
16300 if (
const auto *Proto =
16301 dyn_cast<FunctionProtoType>(Pattern->getFunctionType()))
16302 if (Proto->isTemplateVariadic())
16315 << IsMember << Name << (Msg !=
nullptr)
16316 << (Msg ? Msg->
getString() : StringRef())
Defines the clang::ASTContext interface.
This file provides some common utility functions for processing Lambda related AST Constructs.
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.
static std::string getName(const CallEvent &Call)
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 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 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 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 isQualificationConversionStep(QualType FromType, QualType ToType, bool CStyle, bool IsTopLevel, bool &PreviousToQualsIncludeConst, bool &ObjCLifetimeConversion)
Perform a single iteration of the loop for checking if a qualification conversion is valid.
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 ExprResult CheckConvertedConstantExpression(Sema &S, Expr *From, QualType T, APValue &Value, Sema::CCEKind CCE, bool RequireInt, NamedDecl *Dest)
CheckConvertedConstantExpression - Check that the expression From is a converted constant expression ...
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 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 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 ExprResult BuildConvertedConstantExpression(Sema &S, Expr *From, QualType T, Sema::CCEKind CCE, NamedDecl *Dest, APValue &PreNarrowingValue)
BuildConvertedConstantExpression - Check that the expression From is a converted constant expression ...
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 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 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 bool sameFunctionParameterTypeLists(Sema &S, const OverloadCandidate &Cand1, const OverloadCandidate &Cand2)
We're allowed to use constraints partial ordering only if the candidates have the same parameter type...
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 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 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, PackFold PackFold=PackFold::ParameterToArgument)
Defines the SourceManager interface.
static QualType getPointeeType(const MemRegion *R)
Allows QualTypes to be sorted and hence used in maps and sets.
C Language Family Type Representation.
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.
bool areLaxCompatibleSveTypes(QualType FirstType, QualType SecondType)
Return true if the given vector types are lax-compatible SVE vector types, false otherwise.
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.
bool hasSimilarType(QualType T1, QualType T2)
Determine if two types are similar, according to the C++ rules.
QualType getMemberPointerType(QualType T, const Type *Cls) const
Return the uniqued reference to the type for a member pointer to the specified type in the specified ...
DeclarationNameTable DeclarationNames
QualType getRecordType(const RecordDecl *Decl) const
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.
CallingConv getDefaultCallingConvention(bool IsVariadic, bool IsCXXMethod, bool IsBuiltin=false) const
Retrieves the default calling convention for the current target.
QualType getPointerType(QualType T) const
Return the uniqued reference to the type for a pointer to the specified type.
bool canAssignObjCInterfaces(const ObjCObjectPointerType *LHSOPT, const ObjCObjectPointerType *RHSOPT)
canAssignObjCInterfaces - Return true if the two interface types are compatible for assignment from R...
QualType getLValueReferenceType(QualType T, bool SpelledAsLValue=true) const
Return the uniqued reference to the type for an lvalue reference to the specified type.
QualType getTypeDeclType(const TypeDecl *Decl, const TypeDecl *PrevDecl=nullptr) const
Return the unique reference to the type for the specified type declaration.
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...
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 getSizeType() const
Return the unique type for "size_t" (C99 7.17), defined in <stddef.h>.
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.
bool UnwrapSimilarTypes(QualType &T1, QualType &T2, bool AllowPiMismatch=true)
Attempt to unwrap two types that may be similar (C++ [conv.qual]).
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...
QualType getCVRQualifiedType(QualType T, unsigned CVR) const
Return a type with additional const, volatile, or restrict qualifiers.
bool areCompatibleVectorTypes(QualType FirstVec, QualType SecondVec)
Return true if the given vector types are of the same unqualified type or if they are equivalent to t...
const TargetInfo & getTargetInfo() const
bool typesAreCompatible(QualType T1, QualType T2, bool CompareUnqualified=false)
Compatibility predicates used to check assignment expressions.
QualType getAddrSpaceQualType(QualType T, LangAS AddressSpace) const
Return the uniqued reference to the type for an address space qualified type with the specified type ...
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 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.
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.
RefQualifierKind getRefQualifier() const
Retrieve the ref-qualifier associated with this method.
const CXXRecordDecl * getParent() const
Return the parent of this method declaration, which is the class in which this method is defined.
QualType getThisType() const
Return the type of the this pointer.
bool isMoveAssignmentOperator() const
Determine whether this is a move assignment operator.
Qualifiers getMethodQualifiers() const
QualType getFunctionObjectParameterType() const
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 markDependentForPostponedNameLookup()
Used by Sema to implement MSVC-compatible delayed name lookup.
static CallExpr * CreateTemporary(void *Mem, Expr *Fn, QualType Ty, ExprValueKind VK, SourceLocation RParenLoc, ADLCallKind UsesADL=NotADL)
Create a temporary call expression with no arguments in the memory pointed to by Mem.
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 isAtLeastAsQualifiedAs(CanQual< T > Other) const
Determines whether this canonical type is at least as qualified as the Other canonical type.
bool isVolatileQualified() const
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.
bool Equals(const DeclContext *DC) const
Determine whether this declaration context is equivalent to the declaration context DC.
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.
FriendObjectKind getFriendObjectKind() const
Determines whether this declaration is the object of a friend declaration and, if so,...
ASTContext & getASTContext() const LLVM_READONLY
bool isImplicit() const
isImplicit - Indicates whether the declaration was implicitly generated by the implementation.
void setInvalidDecl(bool Invalid=true)
setInvalidDecl - Indicates the Decl had a semantic error.
const FunctionType * getFunctionType(bool BlocksToo=true) const
Looks through the Decl's underlying type to extract a FunctionType when possible.
unsigned getTemplateDepth() const
Determine the number of levels of template parameter surrounding this declaration.
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
void print(raw_ostream &Out, unsigned Indentation=0, bool PrintInstantiation=false) 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...
NestedNameSpecifier * getQualifier() const
Retrieve the nested-name-specifier that qualifies the name of this declaration, if it was present in ...
SourceLocation getBeginLoc() const LLVM_READONLY
Expr * getTrailingRequiresClause()
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
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 * getDecl() const
Store information needed for an explicit specifier.
bool isExplicit() const
Determine whether this specifier is known to correspond to an explicit declaration.
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.
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.
bool isIntegerConstantExpr(const ASTContext &Ctx, SourceLocation *Loc=nullptr) const
@ 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
unsigned getMinRequiredArguments() const
Returns the minimum number of arguments needed to call this function.
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.
DependentFunctionTemplateSpecializationInfo * getDependentSpecializationInfo() const
bool isDeleted() const
Whether this function has been deleted.
const TemplateArgumentList * getTemplateSpecializationArgs() const
Retrieve the template arguments used to produce this function template specialization from the primar...
bool isMSVCRTEntryPoint() const
Determines whether this function is a MSVCRT user defined entry point.
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.
bool isMain() const
Determines whether this function is "main", which is the entry point into an executable program.
bool isDefaulted() const
Whether this function is defaulted.
SourceRange getSourceRange() const override LLVM_READONLY
Source range that this declaration covers.
OverloadedOperatorKind getOverloadedOperator() const
getOverloadedOperator - Which C++ overloaded operator this function represents, if any.
TemplateSpecializationKind getTemplateSpecializationKind() const
Determine what kind of template instantiation this function represents.
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.
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
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, NonTypeTemplateParmDecl *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'.
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.
NestedNameSpecifier * getQualifier() const
If the member name was qualified, retrieves the nested-name-specifier that precedes the member name.
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.
QualType getPointeeType() const
const Type * getClass() 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.
ArrayRef< ParmVarDecl * > parameters() const
unsigned param_size() const
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.
bool isNewCandidate(Decl *F, OverloadCandidateParamOrder PO=OverloadCandidateParamOrder::Normal)
Determine when this overload candidate will be new to the overload set.
ConversionSequenceList allocateConversionSequences(unsigned NumConversions)
Allocate storage for conversion sequences for NumConversions conversions.
OverloadCandidate & addCandidate(unsigned NumConversions=0, ConversionSequenceList Conversions=std::nullopt)
Add a new candidate with NumConversions conversion sequence slots to the overload set.
OperatorRewriteInfo getRewriteInfo() 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
CandidateSetKind getKind() 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.
NestedNameSpecifier * getQualifier() const
Fetches the nested-name qualifier, if one was given.
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.
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.
PointerType - C99 6.7.5.1 - Pointer Declarators.
QualType getPointeeType() const
static PseudoObjectExpr * Create(const ASTContext &Context, Expr *syntactic, ArrayRef< Expr * > semantic, unsigned resultIndex)
A (possibly-)qualified type.
bool isVolatileQualified() const
Determine whether this type is volatile-qualified.
bool isRestrictQualified() const
Determine whether this type is restrict-qualified.
bool hasQualifiers() const
Determine whether this type has any qualifiers.
QualType getNonLValueExprType(const ASTContext &Context) const
Determine the type of a (typically non-lvalue) expression with the specified result type.
QualType getLocalUnqualifiedType() const
Return this type with all of the instance-specific qualifiers removed, but without removing any quali...
bool isAtLeastAsQualifiedAs(QualType Other) const
Determine whether this type is at least as qualified as the other given type, requiring exact equalit...
bool isNull() const
Return true if this QualType doesn't point to a type yet.
const Type * getTypePtr() const
Retrieves a pointer to the underlying (unqualified) type.
LangAS getAddressSpace() const
Return the address space of this type.
Qualifiers getQualifiers() const
Retrieve the set of qualifiers applied to this type.
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
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)
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()
void removeAddressSpace()
void setAddressSpace(LangAS space)
static bool isAddressSpaceSupersetOf(LangAS A, LangAS B)
Returns true if address space A is equal to or a superset of B.
bool hasObjCGCAttr() const
ObjCLifetime getObjCLifetime() const
std::string getAsString() const
bool compatiblyIncludes(Qualifiers other) const
Determines if these qualifiers compatibly include another set.
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
A helper class that allows the use of isa/cast/dyncast to detect TagType objects of structs/unions/cl...
RecordDecl * getDecl() const
Base for LValueReferenceType and RValueReferenceType.
QualType getPointeeType() const
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
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.
ExprResult PerformImplicitObjectArgumentInitialization(Expr *From, NestedNameSpecifier *Qualifier, NamedDecl *FoundDecl, CXXMethodDecl *Method)
PerformObjectArgumentInitialization - Perform initialization of the implicit object parameter for the...
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 DiagnoseEmptyLookup(Scope *S, CXXScopeSpec &SS, LookupResult &R, CorrectionCandidateCallback &CCC, TemplateArgumentListInfo *ExplicitTemplateArgs=nullptr, ArrayRef< Expr * > Args=std::nullopt, DeclContext *LookupCtx=nullptr, TypoExpr **Out=nullptr)
Diagnose an empty lookup.
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.
void AddConversionCandidate(CXXConversionDecl *Conversion, DeclAccessPair FoundDecl, CXXRecordDecl *ActingContext, Expr *From, QualType ToType, OverloadCandidateSet &CandidateSet, bool AllowObjCConversionOnExplicit, bool AllowExplicit, bool AllowResultConversion=true)
AddConversionCandidate - Add a C++ conversion function as a candidate in the candidate set (C++ [over...
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.
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 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...
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)
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...
FunctionDecl * ResolveSingleFunctionTemplateSpecialization(OverloadExpr *ovl, bool Complain=false, DeclAccessPair *Found=nullptr, TemplateSpecCandidateSet *FailedTSC=nullptr)
Given an expression that refers to an overloaded function, try to resolve that overloaded function ex...
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 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...
bool CheckMemberPointerConversion(Expr *From, QualType ToType, CastKind &Kind, CXXCastPath &BasePath, bool IgnoreBaseAccess)
CheckMemberPointerConversion - Check the member pointer conversion from the expression From to the ty...
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,...
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 (...
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)
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)
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.
bool AreConstraintExpressionsEqual(const NamedDecl *Old, const Expr *OldConstr, const TemplateCompareNewDeclInfo &New, const Expr *NewConstr)
FunctionTemplateDecl * getMoreSpecializedTemplate(FunctionTemplateDecl *FT1, FunctionTemplateDecl *FT2, SourceLocation Loc, TemplatePartialOrderingContext TPOC, unsigned NumCallArguments1, QualType RawObj1Ty={}, QualType RawObj2Ty={}, bool Reversed=false)
Returns the more specialized function template according to the rules of function template partial or...
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.
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...
bool MaybeEmitAmbiguousAtomicConstraintsDiagnostic(NamedDecl *D1, ArrayRef< const Expr * > AC1, NamedDecl *D2, ArrayRef< const Expr * > AC2)
If D1 was not at least as constrained as D2, but would've been if a pair of atomic constraints involv...
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.
MaterializeTemporaryExpr * CreateMaterializeTemporaryExpr(QualType T, Expr *Temporary, bool BoundToLvalueReference)
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.
ObjCMethodDecl * SelectBestMethod(Selector Sel, MultiExprArg Args, bool IsInstance, SmallVectorImpl< ObjCMethodDecl * > &Methods)
AssignConvertType
AssignConvertType - All of the 'assignment' semantic checks return this enum to indicate whether the ...
@ CompatiblePointerDiscardsQualifiers
CompatiblePointerDiscardsQualifiers - The assignment discards c/v/r qualifiers, which we accept as an...
@ IncompatiblePointer
IncompatiblePointer - The assignment is between two pointers types that are not compatible,...
@ Compatible
Compatible - the types are compatible according to the standard.
@ IncompatiblePointerSign
IncompatiblePointerSign - The assignment is between two pointers types which point to integers which ...
void MarkDeclRefReferenced(DeclRefExpr *E, const Expr *Base=nullptr)
Perform reference-marking and odr-use handling for a DeclRefExpr.
ExprResult CheckPlaceholderExpr(Expr *E)
Check for operands with placeholder types and complain if found.
EnableIfAttr * CheckEnableIf(FunctionDecl *Function, SourceLocation CallLoc, ArrayRef< Expr * > Args, bool MissingImplicitThis=false)
Check the enable_if expressions on the given function.
ExprResult CreateUnresolvedLookupExpr(CXXRecordDecl *NamingClass, NestedNameSpecifierLoc NNSLoc, DeclarationNameInfo DNI, const UnresolvedSetImpl &Fns, bool PerformADL=true)
bool inTemplateInstantiation() const
Determine whether we are currently performing template instantiation.
void AddMethodCandidate(DeclAccessPair FoundDecl, QualType ObjectType, Expr::Classification ObjectClassification, ArrayRef< Expr * > Args, OverloadCandidateSet &CandidateSet, bool SuppressUserConversion=false, OverloadCandidateParamOrder PO={})
AddMethodCandidate - Adds a named decl (which is some kind of method) as a method candidate to the gi...
void diagnoseEquivalentInternalLinkageDeclarations(SourceLocation Loc, const NamedDecl *D, ArrayRef< const NamedDecl * > Equiv)
ExprResult FixOverloadedFunctionReference(Expr *E, DeclAccessPair FoundDecl, FunctionDecl *Fn)
FixOverloadedFunctionReference - E is an expression that refers to a C++ overloaded function (possibl...
ExprResult 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.
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=std::nullopt, OverloadCandidateParamOrder PO={}, bool AggregateCandidateDeduction=false)
AddOverloadCandidate - Adds the given function to the set of candidate functions, using the given fun...
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,...
CCEKind
Contexts in which a converted constant expression is required.
@ CCEK_ExplicitBool
Condition in an explicit(bool) specifier.
@ CCEK_Noexcept
Condition in a noexcept(bool) specifier.
@ CCEK_ArrayBound
Array bound in array declarator or new-expression.
@ CCEK_TemplateArg
Value of a non-type template parameter.
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.
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.
void DiagnoseUnsatisfiedConstraint(const ConstraintSatisfaction &Satisfaction, bool First=true)
Emit diagnostics explaining why a constraint expression was deemed unsatisfied.
bool IsDerivedFrom(SourceLocation Loc, QualType Derived, QualType Base)
Determine whether the type Derived is a C++ class that is derived from the type Base.
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...
bool CheckNonDependentConversions(FunctionTemplateDecl *FunctionTemplate, ArrayRef< QualType > ParamTypes, ArrayRef< Expr * > Args, OverloadCandidateSet &CandidateSet, ConversionSequenceList &Conversions, bool SuppressUserConversions, 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...
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.
bool IsFunctionConversion(QualType FromType, QualType ToType, QualType &ResultTy)
Determine whether the conversion from FromType to ToType is a valid conversion that strips "noexcept"...
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)
QualType getToType(unsigned Idx) const
Stmt - This represents one statement.
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...
void Profile(llvm::FoldingSetNodeID &ID, const ASTContext &Context, bool Canonical, bool ProfileLambdaExpr=false) const
Produce a unique representation of the given statement.
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() 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
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.
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.
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.
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...
static UnresolvedLookupExpr * Create(const ASTContext &Context, CXXRecordDecl *NamingClass, NestedNameSpecifierLoc QualifierLoc, const DeclarationNameInfo &NameInfo, bool RequiresADL, UnresolvedSetIterator Begin, UnresolvedSetIterator End, bool KnownDependent)
bool requiresADL() const
True if this declaration should be extended by argument-dependent lookup.
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.
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)
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?
bool AggregateDeductionCandidateHasMismatchedArity
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.
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.
bool Ret(InterpState &S, CodePtr &PC, APValue &Result)
void checkExprLifetime(Sema &SemaRef, const InitializedEntity &Entity, Expr *Init)
Check that the lifetime of the given expr (and its subobjects) is sufficient for initializing the ent...
The JSON file list parser is used to communicate input to InstallAPI.
@ Seq
'seq' clause, allowed on 'loop' and 'routine' directives.
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
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 isUnresolvedExceptionSpec(ExceptionSpecificationType ESpecType)
@ ovl_fail_final_conversion_not_exact
This conversion function template specialization candidate is not viable because the final conversion...
@ ovl_fail_enable_if
This candidate function was not viable because an enable_if attribute disabled it.
@ ovl_fail_illegal_constructor
This conversion candidate was not considered because it is an illegal instantiation of a constructor ...
@ ovl_fail_bad_final_conversion
This conversion candidate is not viable because its result type is not implicitly convertible to the ...
@ ovl_fail_module_mismatched
This candidate was not viable because it has internal linkage and is from a different module unit tha...
@ ovl_fail_too_few_arguments
@ ovl_fail_addr_not_available
This candidate was not viable because its address could not be taken.
@ ovl_fail_too_many_arguments
@ ovl_non_default_multiversion_function
This candidate was not viable because it is a non-default multiversioned function.
@ ovl_fail_constraints_not_satisfied
This candidate was not viable because its associated constraints were not satisfied.
@ ovl_fail_bad_conversion
@ ovl_fail_bad_target
(CUDA) This candidate was not viable because the callee was not accessible from the caller's target (...
@ ovl_fail_inhctor_slice
This inherited constructor is not viable because it would slice the argument.
@ ovl_fail_object_addrspace_mismatch
This constructor/conversion candidate fail due to an address space mismatch between the object being ...
@ ovl_fail_explicit
This candidate constructor or conversion function is explicit but the context doesn't permit explicit...
@ ovl_fail_trivial_conversion
This conversion candidate was not considered because it duplicates the work of a trivial or derived-t...
@ 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.
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])
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...
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.
bool isBetterOverloadCandidate(Sema &S, const OverloadCandidate &Cand1, const OverloadCandidate &Cand2, SourceLocation Loc, OverloadCandidateSet::CandidateSetKind Kind)
isBetterOverloadCandidate - Determines whether the first overload candidate is a better candidate tha...
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....
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.
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 &)
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.
std::optional< unsigned > getCallArgIndex()
Return the index of the call argument that this deduction failure refers to, 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.
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.
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).
CallExpr::ADLCallKind IsADLCandidate
True if the candidate was found using ADL.
bool TryToFixBadConversion(unsigned Idx, Sema &S)
bool NotValidBecauseConstraintExprHasError() const
bool 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.
bool IgnoreObjectArgument
IgnoreObjectArgument - True to indicate that the first argument's conversion, which for this function...
DeclAccessPair FoundDecl
FoundDecl - The original declaration that was looked up / invented / otherwise found,...
FunctionDecl * Function
Function - The actual function that this candidate represents.
bool Viable
Viable - True to indicate that this overload candidate is viable.
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.
StandardConversionSequence FinalConversion
FinalConversion - For a conversion function (where Function is a CXXConversionDecl),...
unsigned getNumParams() const
unsigned ExplicitCallArguments
The number of call arguments that were explicitly provided, to be used while performing partial order...
unsigned char FailureKind
FailureKind - The reason why this candidate is not viable.
ConversionSequenceList Conversions
The conversion sequences used to convert the function arguments to the function parameters.
bool TookAddressOfOverload
DeductionFailureInfo DeductionFailure
bool Best
Whether this candidate is the best viable function, or tied for being the best viable function.
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
A context in which code is being synthesized (where a source location alone is not sufficient to iden...
enum clang::Sema::CodeSynthesisContext::SynthesisKind Kind
@ RewritingOperatorAsSpaceship
We are rewriting a comparison operator in terms of an operator<=>.
Decl * Entity
The entity that is being synthesized.
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.
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.