37#include "llvm/ADT/DenseSet.h"
38#include "llvm/ADT/STLExtras.h"
39#include "llvm/ADT/STLForwardCompat.h"
40#include "llvm/ADT/ScopeExit.h"
41#include "llvm/ADT/SmallPtrSet.h"
42#include "llvm/ADT/SmallVector.h"
56 return P->hasAttr<PassObjectSizeAttr>();
77 if (HadMultipleCandidates)
88 CK_FunctionToPointerDecay);
92 bool InOverloadResolution,
95 bool AllowObjCWritebackConversion);
99 bool InOverloadResolution,
107 bool AllowObjCConversionOnExplicit);
168 return Rank[(
int)Kind];
193 static const char *
const Name[] = {
197 "Function-to-pointer",
198 "Function pointer conversion",
200 "Integral promotion",
201 "Floating point promotion",
203 "Integral conversion",
204 "Floating conversion",
205 "Complex conversion",
206 "Floating-integral conversion",
207 "Pointer conversion",
208 "Pointer-to-member conversion",
209 "Boolean conversion",
210 "Compatible-types conversion",
211 "Derived-to-base conversion",
213 "SVE Vector conversion",
214 "RVV Vector conversion",
216 "Complex-real conversion",
217 "Block Pointer conversion",
218 "Transparent Union Conversion",
219 "Writeback conversion",
220 "OpenCL Zero Event Conversion",
221 "OpenCL Zero Queue Conversion",
222 "C specific type conversion",
223 "Incompatible pointer conversion",
224 "Fixed point conversion",
225 "HLSL vector truncation",
226 "Non-decaying array conversion",
314 const Expr *Converted) {
317 if (
auto *EWC = dyn_cast<ExprWithCleanups>(Converted)) {
324 while (
auto *ICE = dyn_cast<ImplicitCastExpr>(Converted)) {
325 switch (ICE->getCastKind()) {
327 case CK_IntegralCast:
328 case CK_IntegralToBoolean:
329 case CK_IntegralToFloating:
330 case CK_BooleanToSignedIntegral:
331 case CK_FloatingToIntegral:
332 case CK_FloatingToBoolean:
333 case CK_FloatingCast:
334 Converted = ICE->getSubExpr();
358 QualType &ConstantType,
bool IgnoreFloatToIntegralConversion)
const {
360 "narrowing check outside C++");
371 ToType = ET->getDecl()->getIntegerType();
377 goto FloatingIntegralConversion;
379 goto IntegralConversion;
390 FloatingIntegralConversion:
395 if (IgnoreFloatToIntegralConversion)
398 assert(
Initializer &&
"Unknown conversion expression");
404 if (std::optional<llvm::APSInt> IntConstantValue =
408 Result.convertFromAPInt(*IntConstantValue, IntConstantValue->isSigned(),
409 llvm::APFloat::rmNearestTiesToEven);
411 llvm::APSInt ConvertedValue = *IntConstantValue;
413 Result.convertToInteger(ConvertedValue,
414 llvm::APFloat::rmTowardZero, &ignored);
416 if (*IntConstantValue != ConvertedValue) {
417 ConstantValue =
APValue(*IntConstantValue);
444 Initializer->isCXX11ConstantExpr(Ctx, &ConstantValue)) {
447 ConstantValue = R.
Val;
448 assert(ConstantValue.
isFloat());
449 llvm::APFloat FloatVal = ConstantValue.
getFloat();
452 llvm::APFloat Converted = FloatVal;
453 llvm::APFloat::opStatus ConvertStatus =
455 llvm::APFloat::rmNearestTiesToEven, &ignored);
457 llvm::APFloat::rmNearestTiesToEven, &ignored);
459 if (FloatVal.isNaN() && Converted.isNaN() &&
460 !FloatVal.isSignaling() && !Converted.isSignaling()) {
466 if (!Converted.bitwiseIsEqual(FloatVal)) {
473 if (ConvertStatus & llvm::APFloat::opOverflow) {
495 IntegralConversion: {
503 constexpr auto CanRepresentAll = [](
bool FromSigned,
unsigned FromWidth,
504 bool ToSigned,
unsigned ToWidth) {
505 return (FromWidth < ToWidth + (FromSigned == ToSigned)) &&
506 !(FromSigned && !ToSigned);
509 if (CanRepresentAll(FromSigned, FromWidth, ToSigned, ToWidth))
515 bool DependentBitField =
false;
517 if (BitField->getBitWidth()->isValueDependent())
518 DependentBitField =
true;
519 else if (
unsigned BitFieldWidth = BitField->getBitWidthValue(Ctx);
520 BitFieldWidth < FromWidth) {
521 if (CanRepresentAll(FromSigned, BitFieldWidth, ToSigned, ToWidth))
525 FromWidth = BitFieldWidth;
533 std::optional<llvm::APSInt> OptInitializerValue =
535 if (!OptInitializerValue) {
539 if (DependentBitField && !(FromSigned && !ToSigned))
545 llvm::APSInt &InitializerValue = *OptInitializerValue;
546 bool Narrowing =
false;
547 if (FromWidth < ToWidth) {
550 if (InitializerValue.isSigned() && InitializerValue.isNegative())
556 InitializerValue.extend(InitializerValue.getBitWidth() + 1);
558 llvm::APSInt ConvertedValue = InitializerValue;
559 ConvertedValue = ConvertedValue.trunc(ToWidth);
560 ConvertedValue.setIsSigned(ToSigned);
561 ConvertedValue = ConvertedValue.extend(InitializerValue.getBitWidth());
562 ConvertedValue.setIsSigned(InitializerValue.isSigned());
564 if (ConvertedValue != InitializerValue)
569 ConstantValue =
APValue(InitializerValue);
585 ConstantValue = R.
Val;
586 assert(ConstantValue.
isFloat());
587 llvm::APFloat FloatVal = ConstantValue.
getFloat();
592 if (FloatVal.isNaN() && FloatVal.isSignaling()) {
608 raw_ostream &OS = llvm::errs();
609 bool PrintedSomething =
false;
612 PrintedSomething =
true;
616 if (PrintedSomething) {
622 OS <<
" (by copy constructor)";
624 OS <<
" (direct reference binding)";
626 OS <<
" (reference binding)";
628 PrintedSomething =
true;
632 if (PrintedSomething) {
636 PrintedSomething =
true;
639 if (!PrintedSomething) {
640 OS <<
"No conversions required";
647 raw_ostream &OS = llvm::errs();
655 OS <<
"aggregate initialization";
665 raw_ostream &OS = llvm::errs();
667 OS <<
"Worst list element conversion: ";
668 switch (ConversionKind) {
670 OS <<
"Standard conversion: ";
674 OS <<
"User-defined conversion: ";
678 OS <<
"Ellipsis conversion";
681 OS <<
"Ambiguous conversion";
684 OS <<
"Bad conversion";
709 struct DFIArguments {
715 struct DFIParamWithArguments : DFIArguments {
720 struct DFIDeducedMismatchArgs : DFIArguments {
722 unsigned CallArgIndex;
739 Result.Result =
static_cast<unsigned>(TDK);
740 Result.HasDiagnostic =
false;
759 auto *Saved =
new (Context) DFIDeducedMismatchArgs;
770 DFIArguments *Saved =
new (Context) DFIArguments;
782 DFIParamWithArguments *Saved =
new (Context) DFIParamWithArguments;
783 Saved->Param = Info.
Param;
796 Result.HasDiagnostic =
true;
801 CNSInfo *Saved =
new (Context) CNSInfo;
811 llvm_unreachable(
"not a deduction failure");
844 Diag->~PartialDiagnosticAt();
853 Diag->~PartialDiagnosticAt();
889 return TemplateParameter::getFromOpaqueValue(
Data);
894 return static_cast<DFIParamWithArguments*
>(
Data)->Param;
924 return static_cast<DFIDeducedMismatchArgs*
>(
Data)->TemplateArgs;
930 return static_cast<CNSInfo*
>(
Data)->TemplateArgs;
962 return &
static_cast<DFIArguments*
>(
Data)->FirstArg;
994 return &
static_cast<DFIArguments*
>(
Data)->SecondArg;
1009 return static_cast<DFIDeducedMismatchArgs*
>(
Data)->CallArgIndex;
1012 return std::nullopt;
1025 for (
unsigned I = 0; I <
X->getNumParams(); ++I)
1029 if (
auto *FTX =
X->getDescribedFunctionTemplate()) {
1034 FTY->getTemplateParameters()))
1043 OverloadedOperatorKind::OO_EqualEqual);
1055 OverloadedOperatorKind::OO_ExclaimEqual);
1056 if (isa<CXXMethodDecl>(EqFD)) {
1073 auto *NotEqFD = Op->getAsFunction();
1074 if (
auto *UD = dyn_cast<UsingShadowDecl>(Op))
1075 NotEqFD = UD->getUnderlyingDecl()->getAsFunction();
1078 cast<Decl>(Op->getLexicalDeclContext())))
1088 return Op == OO_EqualEqual || Op == OO_Spaceship;
1094 if (!allowsReversed(Op))
1096 if (Op == OverloadedOperatorKind::OO_EqualEqual) {
1097 assert(OriginalArgs.size() == 2);
1099 S, OpLoc, OriginalArgs[1], FD))
1110void OverloadCandidateSet::destroyCandidates() {
1112 for (
auto &
C : i->Conversions)
1113 C.~ImplicitConversionSequence();
1115 i->DeductionFailure.Destroy();
1120 destroyCandidates();
1121 SlabAllocator.Reset();
1122 NumInlineBytesUsed = 0;
1129 class UnbridgedCastsSet {
1139 Entry entry = { &
E,
E };
1140 Entries.push_back(entry);
1146 i = Entries.begin(), e = Entries.end(); i != e; ++i)
1147 *i->Addr = i->Saved;
1161 UnbridgedCastsSet *unbridgedCasts =
nullptr) {
1165 if (placeholder->getKind() == BuiltinType::Overload)
return false;
1169 if (placeholder->getKind() == BuiltinType::ARCUnbridgedCast &&
1171 unbridgedCasts->save(S,
E);
1191 UnbridgedCastsSet &unbridged) {
1192 for (
unsigned i = 0, e = Args.size(); i != e; ++i)
1201 NamedDecl *&Match,
bool NewIsUsingDecl) {
1206 bool OldIsUsingDecl =
false;
1207 if (isa<UsingShadowDecl>(OldD)) {
1208 OldIsUsingDecl =
true;
1212 if (NewIsUsingDecl)
continue;
1214 OldD = cast<UsingShadowDecl>(OldD)->getTargetDecl();
1219 if ((OldIsUsingDecl || NewIsUsingDecl) && !isVisible(*I))
1227 bool UseMemberUsingDeclRules =
1228 (OldIsUsingDecl || NewIsUsingDecl) && CurContext->isRecord() &&
1232 if (!IsOverload(New, OldF, UseMemberUsingDeclRules)) {
1233 if (UseMemberUsingDeclRules && OldIsUsingDecl) {
1234 HideUsingShadowDecl(S, cast<UsingShadowDecl>(*I));
1238 if (!isa<FunctionTemplateDecl>(OldD) &&
1239 !shouldLinkPossiblyHiddenDecl(*I, New))
1248 if (!getASTContext().canBuiltinBeRedeclared(OldF)) {
1250 return Ovl_NonFunction;
1252 }
else if (isa<UsingDecl>(OldD) || isa<UsingPackDecl>(OldD)) {
1256 }
else if (isa<TagDecl>(OldD)) {
1258 }
else if (
auto *UUD = dyn_cast<UnresolvedUsingValueDecl>(OldD)) {
1265 if (UUD->getQualifier()->isDependent() && !UUD->isCXXClassMember()) {
1267 return Ovl_NonFunction;
1274 return Ovl_NonFunction;
1299 if (CheckFunctionTemplateSpecialization(New,
nullptr, TemplateSpecResult,
1302 return Ovl_Overload;
1309 return Ovl_Overload;
1314 bool UseMemberUsingDeclRules,
1315 bool ConsiderCudaAttrs,
1316 bool UseOverrideRules =
false) {
1333 if ((OldTemplate ==
nullptr) != (NewTemplate ==
nullptr))
1346 if (isa<FunctionNoProtoType>(OldQType.
getTypePtr()) ||
1347 isa<FunctionNoProtoType>(NewQType.
getTypePtr()))
1350 const auto *OldType = cast<FunctionProtoType>(OldQType);
1351 const auto *NewType = cast<FunctionProtoType>(NewQType);
1356 if (OldQType != NewQType && OldType->isVariadic() != NewType->isVariadic())
1371 OldDecl = OldTemplate;
1372 NewDecl = NewTemplate;
1390 bool ConstraintsInTemplateHead =
1401 if (UseMemberUsingDeclRules && ConstraintsInTemplateHead &&
1402 !SameTemplateParameterList)
1404 if (!UseMemberUsingDeclRules &&
1405 (!SameTemplateParameterList || !SameReturnType))
1409 const auto *OldMethod = dyn_cast<CXXMethodDecl>(Old);
1410 const auto *NewMethod = dyn_cast<CXXMethodDecl>(New);
1412 int OldParamsOffset = 0;
1413 int NewParamsOffset = 0;
1421 if (ThisType.isConstQualified())
1435 !isa<CXXConstructorDecl>(NewMethod))
1441 BS.
Quals = NormalizeQualifiers(OldMethod, BS.
Quals);
1442 DS.Quals = NormalizeQualifiers(NewMethod, DS.Quals);
1444 if (OldMethod->isExplicitObjectMemberFunction()) {
1446 DS.Quals.removeVolatile();
1449 return BS.
Quals == DS.Quals;
1453 auto BS =
Base.getNonReferenceType().getCanonicalType().split();
1454 auto DS =
D.getNonReferenceType().getCanonicalType().split();
1456 if (!AreQualifiersEqual(BS, DS))
1459 if (OldMethod->isImplicitObjectMemberFunction() &&
1460 OldMethod->getParent() != NewMethod->getParent()) {
1463 .getCanonicalType();
1473 if (
Base->isLValueReferenceType())
1474 return D->isLValueReferenceType();
1475 return Base->isRValueReferenceType() ==
D->isRValueReferenceType();
1480 auto DiagnoseInconsistentRefQualifiers = [&]() {
1483 if (OldMethod->getRefQualifier() == NewMethod->getRefQualifier())
1485 if (OldMethod->isExplicitObjectMemberFunction() ||
1486 NewMethod->isExplicitObjectMemberFunction())
1488 if (!UseMemberUsingDeclRules && (OldMethod->getRefQualifier() ==
RQ_None ||
1489 NewMethod->getRefQualifier() ==
RQ_None)) {
1490 SemaRef.
Diag(NewMethod->getLocation(), diag::err_ref_qualifier_overload)
1491 << NewMethod->getRefQualifier() << OldMethod->getRefQualifier();
1492 SemaRef.
Diag(OldMethod->getLocation(), diag::note_previous_declaration);
1498 if (OldMethod && OldMethod->isExplicitObjectMemberFunction())
1500 if (NewMethod && NewMethod->isExplicitObjectMemberFunction())
1503 if (OldType->getNumParams() - OldParamsOffset !=
1504 NewType->getNumParams() - NewParamsOffset ||
1506 {OldType->param_type_begin() + OldParamsOffset,
1507 OldType->param_type_end()},
1508 {NewType->param_type_begin() + NewParamsOffset,
1509 NewType->param_type_end()},
1514 if (OldMethod && NewMethod && !OldMethod->isStatic() &&
1515 !NewMethod->isStatic()) {
1516 bool HaveCorrespondingObjectParameters = [&](
const CXXMethodDecl *Old,
1518 auto NewObjectType = New->getFunctionObjectParameterReferenceType();
1522 return F->getRefQualifier() ==
RQ_None &&
1523 !F->isExplicitObjectMemberFunction();
1526 if (IsImplicitWithNoRefQual(Old) != IsImplicitWithNoRefQual(New) &&
1527 CompareType(OldObjectType.getNonReferenceType(),
1528 NewObjectType.getNonReferenceType()))
1530 return CompareType(OldObjectType, NewObjectType);
1531 }(OldMethod, NewMethod);
1533 if (!HaveCorrespondingObjectParameters) {
1534 if (DiagnoseInconsistentRefQualifiers())
1539 if (!UseOverrideRules || (!NewMethod->isExplicitObjectMemberFunction() &&
1540 !OldMethod->isExplicitObjectMemberFunction()))
1545 if (!UseOverrideRules &&
1549 if ((NewRC !=
nullptr) != (OldRC !=
nullptr))
1556 if (NewMethod && OldMethod && OldMethod->isImplicitObjectMemberFunction() &&
1557 NewMethod->isImplicitObjectMemberFunction()) {
1558 if (DiagnoseInconsistentRefQualifiers())
1576 NewI != NewE || OldI != OldE; ++NewI, ++OldI) {
1577 if (NewI == NewE || OldI == OldE)
1579 llvm::FoldingSetNodeID NewID, OldID;
1581 OldI->getCond()->Profile(OldID, SemaRef.
Context,
true);
1586 if (SemaRef.
getLangOpts().CUDA && ConsiderCudaAttrs) {
1589 if (!isa<CXXDestructorDecl>(New)) {
1594 "Unexpected invalid target.");
1598 if (NewTarget != OldTarget)
1609 bool UseMemberUsingDeclRules,
bool ConsiderCudaAttrs) {
1615 bool UseMemberUsingDeclRules,
bool ConsiderCudaAttrs) {
1628 bool SuppressUserConversions,
1630 bool InOverloadResolution,
1632 bool AllowObjCWritebackConversion,
1633 bool AllowObjCConversionOnExplicit) {
1636 if (SuppressUserConversions) {
1647 Conversions, AllowExplicit,
1648 AllowObjCConversionOnExplicit)) {
1669 if (
const auto *InitList = dyn_cast<InitListExpr>(From);
1670 InitList && InitList->getNumInits() == 1 &&
1672 const Expr *SingleInit = InitList->getInit(0);
1673 FromType = SingleInit->
getType();
1683 if ((FromCanon == ToCanon ||
1694 if (ToCanon != FromCanon)
1705 Cand != Conversions.
end(); ++Cand)
1748 bool SuppressUserConversions,
1750 bool InOverloadResolution,
1752 bool AllowObjCWritebackConversion,
1753 bool AllowObjCConversionOnExplicit) {
1756 ICS.
Standard, CStyle, AllowObjCWritebackConversion)){
1797 auto *ToResType = cast<HLSLAttributedResourceType>(ToType);
1798 auto *FromResType = cast<HLSLAttributedResourceType>(FromType);
1800 FromResType->getWrappedType()) &&
1802 FromResType->getContainedType()) &&
1803 ToResType->getAttrs() == FromResType->getAttrs()) {
1813 AllowExplicit, InOverloadResolution, CStyle,
1814 AllowObjCWritebackConversion,
1815 AllowObjCConversionOnExplicit);
1820 bool SuppressUserConversions,
1822 bool InOverloadResolution,
1824 bool AllowObjCWritebackConversion) {
1825 return ::TryImplicitConversion(*
this, From, ToType, SuppressUserConversions,
1826 AllowExplicit, InOverloadResolution, CStyle,
1827 AllowObjCWritebackConversion,
1833 bool AllowExplicit) {
1838 bool AllowObjCWritebackConversion =
1841 if (getLangOpts().ObjC)
1845 *
this, From, ToType,
1847 AllowExplicit ? AllowedExplicit::All : AllowedExplicit::None,
1849 false, AllowObjCWritebackConversion,
1851 return PerformImplicitConversion(From, ToType, ICS, Action);
1869 if (TyClass != CanFrom->getTypeClass())
return false;
1870 if (TyClass != Type::FunctionProto && TyClass != Type::FunctionNoProto) {
1871 if (TyClass == Type::Pointer) {
1874 }
else if (TyClass == Type::BlockPointer) {
1877 }
else if (TyClass == Type::MemberPointer) {
1881 if (ToMPT->getClass() != FromMPT->
getClass())
1883 CanTo = ToMPT->getPointeeType();
1889 TyClass = CanTo->getTypeClass();
1890 if (TyClass != CanFrom->getTypeClass())
return false;
1891 if (TyClass != Type::FunctionProto && TyClass != Type::FunctionNoProto)
1895 const auto *FromFn = cast<FunctionType>(CanFrom);
1898 const auto *ToFn = cast<FunctionType>(CanTo);
1901 bool Changed =
false;
1910 if (
const auto *FromFPT = dyn_cast<FunctionProtoType>(FromFn)) {
1911 const auto *ToFPT = cast<FunctionProtoType>(ToFn);
1912 if (FromFPT->isNothrow() && !ToFPT->isNothrow()) {
1913 FromFn = cast<FunctionType>(
1924 bool CanUseToFPT, CanUseFromFPT;
1926 CanUseFromFPT, NewParamInfos) &&
1927 CanUseToFPT && !CanUseFromFPT) {
1930 NewParamInfos.empty() ? nullptr : NewParamInfos.data();
1932 FromFPT->getParamTypes(), ExtInfo);
1942 FromFPT = cast<FunctionProtoType>(FromFn);
1946 const auto FromFX = FromFPT->getFunctionEffects();
1947 const auto ToFX = ToFPT->getFunctionEffects();
1948 if (FromFX != ToFX) {
1952 FromFPT->getReturnType(), FromFPT->getParamTypes(), ExtInfo);
1962 assert(
QualType(FromFn, 0).isCanonical());
1963 if (
QualType(FromFn, 0) != CanTo)
return false;
1991 if ((&FromSem == &llvm::APFloat::PPCDoubleDouble() &&
1992 &ToSem == &llvm::APFloat::IEEEquad()) ||
1993 (&FromSem == &llvm::APFloat::IEEEquad() &&
1994 &ToSem == &llvm::APFloat::PPCDoubleDouble()))
2049 bool InOverloadResolution,
bool CStyle) {
2066 if (ToExtType && FromExtType) {
2068 unsigned ToElts = ToExtType->getNumElements();
2069 if (FromElts < ToElts)
2071 if (FromElts == ToElts)
2077 QualType ToElTy = ToExtType->getElementType();
2082 if (FromExtType && !ToExtType) {
2104 QualType ToElTy = ToExtType->getElementType();
2138 !ToType->
hasAttr(attr::ArmMveStrictPolymorphism))) {
2143 !InOverloadResolution && !CStyle) {
2145 << FromType << ToType;
2156 bool InOverloadResolution,
2169 bool InOverloadResolution,
2172 bool AllowObjCWritebackConversion) {
2198 FromType = Fn->getType();
2219 if (Method && !Method->
isStatic() &&
2222 "Non-unary operator on non-static member address");
2223 assert(cast<UnaryOperator>(From->
IgnoreParens())->getOpcode()
2225 "Non-address-of operator on non-static member address");
2226 const Type *ClassType
2230 assert(cast<UnaryOperator>(From->
IgnoreParens())->getOpcode() ==
2232 "Non-address-of operator for overloaded function expression");
2279 FromType =
Atomic->getValueType();
2314 if (
auto *FD = dyn_cast<FunctionDecl>(DRE->getDecl()))
2334 bool IncompatibleObjC =
false;
2389 }
else if (AllowObjCWritebackConversion &&
2393 FromType, IncompatibleObjC)) {
2399 InOverloadResolution, FromType)) {
2403 From, InOverloadResolution, CStyle)) {
2413 S, From, ToType, InOverloadResolution, SCS, CStyle)) {
2449 bool ObjCLifetimeConversion;
2455 ObjCLifetimeConversion)) {
2474 CanonFrom = CanonTo;
2479 if (CanonFrom == CanonTo)
2484 if (S.
getLangOpts().CPlusPlus || !InOverloadResolution)
2528 bool InOverloadResolution,
2538 for (
const auto *it : UD->
fields()) {
2541 ToType = it->getType();
2567 return To->
getKind() == BuiltinType::Int;
2570 return To->
getKind() == BuiltinType::UInt;
2594 if (FromEnumType->getDecl()->isScoped())
2601 if (FromEnumType->getDecl()->isFixed()) {
2602 QualType Underlying = FromEnumType->getDecl()->getIntegerType();
2604 IsIntegralPromotion(
nullptr, Underlying, ToType);
2611 ToType, FromEnumType->getDecl()->getPromotionType());
2636 uint64_t FromSize = Context.
getTypeSize(FromType);
2645 for (
int Idx = 0; Idx < 6; ++Idx) {
2646 uint64_t ToSize = Context.
getTypeSize(PromoteTypes[Idx]);
2647 if (FromSize < ToSize ||
2648 (FromSize == ToSize &&
2649 FromIsSigned == PromoteTypes[Idx]->isSignedIntegerType())) {
2674 std::optional<llvm::APSInt> BitWidth;
2677 MemberDecl->getBitWidth()->getIntegerConstantExpr(Context))) {
2678 llvm::APSInt ToSize(BitWidth->getBitWidth(), BitWidth->isUnsigned());
2682 if (*BitWidth < ToSize ||
2684 return To->
getKind() == BuiltinType::Int;
2690 return To->
getKind() == BuiltinType::UInt;
2718 if (FromBuiltin->getKind() == BuiltinType::Float &&
2719 ToBuiltin->getKind() == BuiltinType::Double)
2726 (FromBuiltin->getKind() == BuiltinType::Float ||
2727 FromBuiltin->getKind() == BuiltinType::Double) &&
2728 (ToBuiltin->getKind() == BuiltinType::LongDouble ||
2729 ToBuiltin->getKind() == BuiltinType::Float128 ||
2730 ToBuiltin->getKind() == BuiltinType::Ibm128))
2735 if (getLangOpts().
HLSL && FromBuiltin->getKind() == BuiltinType::Half &&
2736 (ToBuiltin->getKind() == BuiltinType::Float ||
2737 ToBuiltin->getKind() == BuiltinType::Double))
2741 if (!getLangOpts().NativeHalfType &&
2742 FromBuiltin->getKind() == BuiltinType::Half &&
2743 ToBuiltin->getKind() == BuiltinType::Float)
2775 bool StripObjCLifetime =
false) {
2778 "Invalid similarly-qualified pointer type");
2789 if (StripObjCLifetime)
2800 if (isa<ObjCObjectPointerType>(ToType))
2809 if (isa<ObjCObjectPointerType>(ToType))
2815 bool InOverloadResolution,
2821 return !InOverloadResolution;
2829 bool InOverloadResolution,
2831 bool &IncompatibleObjC) {
2832 IncompatibleObjC =
false;
2833 if (isObjCPointerConversion(FromType, ToType, ConvertedType,
2840 ConvertedType = ToType;
2847 ConvertedType = ToType;
2854 ConvertedType = ToType;
2862 ConvertedType = ToType;
2872 ConvertedType = ToType;
2880 !getLangOpts().ObjCAutoRefCount) {
2910 if (getLangOpts().MSVCCompat && FromPointeeType->
isFunctionType() &&
2944 IsDerivedFrom(From->
getBeginLoc(), FromPointeeType, ToPointeeType)) {
2978 bool &IncompatibleObjC) {
2979 if (!getLangOpts().
ObjC)
2991 if (ToObjCPtr && FromObjCPtr) {
3002 if (getLangOpts().CPlusPlus && LHS && RHS &&
3004 FromObjCPtr->getPointeeType(), getASTContext()))
3009 ConvertedType =
AdoptQualifiers(Context, ConvertedType, FromQualifiers);
3017 IncompatibleObjC =
true;
3021 ConvertedType =
AdoptQualifiers(Context, ConvertedType, FromQualifiers);
3033 if (FromObjCPtr && FromObjCPtr->isObjCBuiltinType()) {
3061 isObjCPointerConversion(FromPointeeType, ToPointeeType, ConvertedType,
3062 IncompatibleObjC)) {
3064 IncompatibleObjC =
true;
3066 ConvertedType =
AdoptQualifiers(Context, ConvertedType, FromQualifiers);
3073 isObjCPointerConversion(FromPointeeType, ToPointeeType, ConvertedType,
3074 IncompatibleObjC)) {
3077 ConvertedType =
AdoptQualifiers(Context, ConvertedType, FromQualifiers);
3089 if (FromFunctionType && ToFunctionType) {
3098 if (FromFunctionType->
getNumParams() != ToFunctionType->getNumParams() ||
3099 FromFunctionType->
isVariadic() != ToFunctionType->isVariadic() ||
3100 FromFunctionType->
getMethodQuals() != ToFunctionType->getMethodQuals())
3103 bool HasObjCConversion =
false;
3107 }
else if (isObjCPointerConversion(FromFunctionType->
getReturnType(),
3108 ToFunctionType->getReturnType(),
3109 ConvertedType, IncompatibleObjC)) {
3111 HasObjCConversion =
true;
3118 for (
unsigned ArgIdx = 0, NumArgs = FromFunctionType->
getNumParams();
3119 ArgIdx != NumArgs; ++ArgIdx) {
3121 QualType ToArgType = ToFunctionType->getParamType(ArgIdx);
3125 }
else if (isObjCPointerConversion(FromArgType, ToArgType,
3126 ConvertedType, IncompatibleObjC)) {
3128 HasObjCConversion =
true;
3135 if (HasObjCConversion) {
3139 IncompatibleObjC =
true;
3171 if (!FromFunctionType || !ToFunctionType)
3174 if (Context.
hasSameType(FromPointeeType, ToPointeeType))
3179 if (FromFunctionType->
getNumParams() != ToFunctionType->getNumParams() ||
3180 FromFunctionType->
isVariadic() != ToFunctionType->isVariadic())
3185 if (FromEInfo != ToEInfo)
3188 bool IncompatibleObjC =
false;
3190 ToFunctionType->getReturnType())) {
3194 QualType LHS = ToFunctionType->getReturnType();
3195 if ((!getLangOpts().CPlusPlus || !RHS->
isRecordType()) &&
3201 }
else if (isObjCPointerConversion(RHS, LHS,
3202 ConvertedType, IncompatibleObjC)) {
3203 if (IncompatibleObjC)
3212 for (
unsigned ArgIdx = 0, NumArgs = FromFunctionType->
getNumParams();
3213 ArgIdx != NumArgs; ++ArgIdx) {
3214 IncompatibleObjC =
false;
3216 QualType ToArgType = ToFunctionType->getParamType(ArgIdx);
3217 if (Context.
hasSameType(FromArgType, ToArgType)) {
3219 }
else if (isObjCPointerConversion(ToArgType, FromArgType,
3220 ConvertedType, IncompatibleObjC)) {
3221 if (IncompatibleObjC)
3230 bool CanUseToFPT, CanUseFromFPT;
3232 CanUseToFPT, CanUseFromFPT,
3236 ConvertedType = ToType;
3274 if (!Context.
hasSameType(FromMember->getClass(), ToMember->getClass())) {
3276 <<
QualType(FromMember->getClass(), 0);
3309 if (!FromFunction || !ToFunction) {
3314 if (FromFunction->
getNumParams() != ToFunction->getNumParams()) {
3322 if (!FunctionParamTypesAreEqual(FromFunction, ToFunction, &ArgPos)) {
3324 << ToFunction->getParamType(ArgPos)
3331 ToFunction->getReturnType())) {
3337 if (FromFunction->
getMethodQuals() != ToFunction->getMethodQuals()) {
3347 cast<FunctionProtoType>(ToFunction->getCanonicalTypeUnqualified())
3360 assert(llvm::size(Old) == llvm::size(New) &&
3361 "Can't compare parameters of functions with different number of "
3364 for (
auto &&[Idx,
Type] : llvm::enumerate(Old)) {
3366 size_t J =
Reversed ? (llvm::size(New) - Idx - 1) : Idx;
3387 return FunctionParamTypesAreEqual(OldType->
param_types(),
3400 unsigned OldIgnore =
3402 unsigned NewIgnore =
3405 auto *OldPT = cast<FunctionProtoType>(OldFunction->
getFunctionType());
3406 auto *NewPT = cast<FunctionProtoType>(NewFunction->
getFunctionType());
3408 return FunctionParamTypesAreEqual(OldPT->param_types().slice(OldIgnore),
3409 NewPT->param_types().slice(NewIgnore),
3416 bool IgnoreBaseAccess,
3419 bool IsCStyleOrFunctionalCast = IgnoreBaseAccess;
3423 if (Diagnose && !IsCStyleOrFunctionalCast && !FromType->
isAnyPointerType() &&
3427 DiagRuntimeBehavior(From->
getExprLoc(), From,
3428 PDiag(diag::warn_impcast_bool_to_null_pointer)
3430 else if (!isUnevaluatedContext())
3439 if (FromPointeeType->
isRecordType() && ToPointeeType->isRecordType() &&
3443 unsigned InaccessibleID = 0;
3444 unsigned AmbiguousID = 0;
3446 InaccessibleID = diag::err_upcast_to_inaccessible_base;
3447 AmbiguousID = diag::err_ambiguous_derived_to_base_conv;
3449 if (CheckDerivedToBaseConversion(
3450 FromPointeeType, ToPointeeType, InaccessibleID, AmbiguousID,
3452 &BasePath, IgnoreBaseAccess))
3456 Kind = CK_DerivedToBase;
3459 if (Diagnose && !IsCStyleOrFunctionalCast &&
3460 FromPointeeType->
isFunctionType() && ToPointeeType->isVoidType()) {
3461 assert(getLangOpts().MSVCCompat &&
3462 "this should only be possible with MSVCCompat!");
3474 if (FromPtrType->isObjCBuiltinType() || ToPtrType->isObjCBuiltinType())
3477 Kind = CK_BlockPointerToObjCPointerCast;
3479 Kind = CK_CPointerToObjCPointerCast;
3483 Kind = CK_AnyPointerToBlockPointerCast;
3489 Kind = CK_NullToPointer;
3496 bool InOverloadResolution,
3506 ConvertedType = ToType;
3521 IsDerivedFrom(From->
getBeginLoc(), ToClass, FromClass)) {
3533 bool IgnoreBaseAccess) {
3540 "Expr must be null pointer constant!");
3541 Kind = CK_NullToMemberPointer;
3546 assert(ToPtrType &&
"No member pointer cast has a target type "
3547 "that is not a member pointer.");
3553 assert(FromClass->
isRecordType() &&
"Pointer into non-class.");
3554 assert(ToClass->
isRecordType() &&
"Pointer into non-class.");
3558 bool DerivationOkay =
3559 IsDerivedFrom(From->
getBeginLoc(), ToClass, FromClass, Paths);
3560 assert(DerivationOkay &&
3561 "Should not have been called if derivation isn't OK.");
3562 (void)DerivationOkay;
3565 getUnqualifiedType())) {
3566 std::string PathDisplayStr = getAmbiguousPathsDisplayString(Paths);
3568 << 0 << FromClass << ToClass << PathDisplayStr << From->
getSourceRange();
3572 if (
const RecordType *VBase = Paths.getDetectedVirtual()) {
3574 << FromClass << ToClass <<
QualType(VBase, 0)
3579 if (!IgnoreBaseAccess)
3580 CheckBaseClassAccess(From->
getExprLoc(), FromClass, ToClass,
3582 diag::err_downcast_from_inaccessible_base);
3586 Kind = CK_BaseToDerivedMemberPointer;
3609 bool CStyle,
bool IsTopLevel,
3610 bool &PreviousToQualsIncludeConst,
3611 bool &ObjCLifetimeConversion,
3624 ObjCLifetimeConversion =
true;
3660 !PreviousToQualsIncludeConst)
3678 PreviousToQualsIncludeConst =
3679 PreviousToQualsIncludeConst && ToQuals.
hasConst();
3685 bool CStyle,
bool &ObjCLifetimeConversion) {
3688 ObjCLifetimeConversion =
false;
3698 bool PreviousToQualsIncludeConst =
true;
3699 bool UnwrappedAnyPointer =
false;
3702 !UnwrappedAnyPointer,
3703 PreviousToQualsIncludeConst,
3704 ObjCLifetimeConversion, getASTContext()))
3706 UnwrappedAnyPointer =
true;
3723 bool InOverloadResolution,
3732 InOverloadResolution, InnerSCS,
3749 if (CtorType->getNumParams() > 0) {
3750 QualType FirstArg = CtorType->getParamType(0);
3762 bool AllowExplicit) {
3769 bool Usable = !Info.Constructor->isInvalidDecl() &&
3772 bool SuppressUserConversions =
false;
3773 if (Info.ConstructorTmpl)
3776 CandidateSet, SuppressUserConversions,
3781 CandidateSet, SuppressUserConversions,
3782 false, AllowExplicit);
3786 bool HadMultipleCandidates = (CandidateSet.
size() > 1);
3795 QualType ThisType = Constructor->getFunctionObjectParameterType();
3813 llvm_unreachable(
"Invalid OverloadResult!");
3835 bool AllowObjCConversionOnExplicit) {
3836 assert(AllowExplicit != AllowedExplicit::None ||
3837 !AllowObjCConversionOnExplicit);
3841 bool ConstructorsOnly =
false;
3857 ConstructorsOnly =
true;
3862 = dyn_cast<CXXRecordDecl>(ToRecordType->getDecl())) {
3864 Expr **Args = &From;
3865 unsigned NumArgs = 1;
3866 bool ListInitializing =
false;
3867 if (
InitListExpr *InitList = dyn_cast<InitListExpr>(From)) {
3870 S, From, ToType, ToRecordDecl, User, CandidateSet,
3871 AllowExplicit == AllowedExplicit::All);
3880 Args = InitList->getInits();
3881 NumArgs = InitList->getNumInits();
3882 ListInitializing =
true;
3890 bool Usable = !Info.Constructor->isInvalidDecl();
3891 if (!ListInitializing)
3892 Usable = Usable && Info.Constructor->isConvertingConstructor(
3895 bool SuppressUserConversions = !ConstructorsOnly;
3903 if (SuppressUserConversions && ListInitializing) {
3904 SuppressUserConversions =
3905 NumArgs == 1 && isa<InitListExpr>(Args[0]) &&
3909 if (Info.ConstructorTmpl)
3911 Info.ConstructorTmpl, Info.FoundDecl,
3913 CandidateSet, SuppressUserConversions,
3915 AllowExplicit == AllowedExplicit::All);
3921 SuppressUserConversions,
3923 AllowExplicit == AllowedExplicit::All);
3930 if (ConstructorsOnly || isa<InitListExpr>(From)) {
3933 }
else if (
const RecordType *FromRecordType =
3936 = dyn_cast<CXXRecordDecl>(FromRecordType->getDecl())) {
3938 const auto &Conversions = FromRecordDecl->getVisibleConversionFunctions();
3939 for (
auto I = Conversions.begin(),
E = Conversions.end(); I !=
E; ++I) {
3943 if (isa<UsingShadowDecl>(
D))
3944 D = cast<UsingShadowDecl>(
D)->getTargetDecl();
3948 if ((ConvTemplate = dyn_cast<FunctionTemplateDecl>(
D)))
3951 Conv = cast<CXXConversionDecl>(
D);
3955 ConvTemplate, FoundDecl, ActingContext, From, ToType,
3956 CandidateSet, AllowObjCConversionOnExplicit,
3957 AllowExplicit != AllowedExplicit::None);
3960 CandidateSet, AllowObjCConversionOnExplicit,
3961 AllowExplicit != AllowedExplicit::None);
3966 bool HadMultipleCandidates = (CandidateSet.
size() > 1);
3975 = dyn_cast<CXXConstructorDecl>(Best->Function)) {
3982 if (isa<InitListExpr>(From)) {
3986 if (Best->Conversions[0].isEllipsis())
3989 User.
Before = Best->Conversions[0].Standard;
4002 = dyn_cast<CXXConversionDecl>(Best->Function)) {
4009 User.
Before = Best->Conversions[0].Standard;
4024 User.
After = Best->FinalConversion;
4027 llvm_unreachable(
"Not a constructor or conversion function?");
4036 llvm_unreachable(
"Invalid OverloadResult!");
4046 CandidateSet, AllowedExplicit::None,
false);
4060 if (!RequireCompleteType(From->
getBeginLoc(), ToType,
4061 diag::err_typecheck_nonviable_condition_incomplete,
4068 *
this, From, Cands);
4094 if (!Conv1 || !Conv2)
4109 if (Block1 != Block2)
4122 if (Conv1FuncRet && Conv2FuncRet &&
4133 CallOpProto->isVariadic(),
false);
4135 CallOpProto->isVariadic(),
true);
4137 CallingConv PrefOrder[] = {DefaultFree, DefaultMember, CallOpCC};
4232 if (!ICS1.
isBad()) {
4233 bool StdInit1 =
false, StdInit2 =
false;
4240 if (StdInit1 != StdInit2)
4251 CAT2->getElementType())) {
4253 if (CAT1->getSize() != CAT2->getSize())
4255 return CAT1->getSize().ult(CAT2->getSize())
4377 return FixedEnumPromotion::None;
4381 return FixedEnumPromotion::None;
4384 if (!
Enum->isFixed())
4385 return FixedEnumPromotion::None;
4389 return FixedEnumPromotion::ToUnderlyingType;
4391 return FixedEnumPromotion::ToPromotedUnderlyingType;
4420 else if (Rank2 < Rank1)
4443 if (FEP1 != FixedEnumPromotion::None && FEP2 != FixedEnumPromotion::None &&
4445 return FEP1 == FixedEnumPromotion::ToUnderlyingType
4455 bool SCS1ConvertsToVoid
4457 bool SCS2ConvertsToVoid
4459 if (SCS1ConvertsToVoid != SCS2ConvertsToVoid) {
4464 }
else if (!SCS1ConvertsToVoid && !SCS2ConvertsToVoid) {
4470 }
else if (SCS1ConvertsToVoid && SCS2ConvertsToVoid &&
4499 if (FromObjCPtr1 && FromObjCPtr2) {
4504 if (AssignLeft != AssignRight) {
4539 if (UnqualT1 == UnqualT2) {
4551 if (isa<ArrayType>(T1) && T1Quals)
4553 if (isa<ArrayType>(T2) && T2Quals)
4601 if (SCS1IsCompatibleVectorConversion != SCS2IsCompatibleVectorConversion)
4602 return SCS1IsCompatibleVectorConversion
4609 bool SCS1IsCompatibleSVEVectorConversion =
4611 bool SCS2IsCompatibleSVEVectorConversion =
4614 if (SCS1IsCompatibleSVEVectorConversion !=
4615 SCS2IsCompatibleSVEVectorConversion)
4616 return SCS1IsCompatibleSVEVectorConversion
4623 bool SCS1IsCompatibleRVVVectorConversion =
4625 bool SCS2IsCompatibleRVVVectorConversion =
4628 if (SCS1IsCompatibleRVVVectorConversion !=
4629 SCS2IsCompatibleRVVVectorConversion)
4630 return SCS1IsCompatibleRVVVectorConversion
4670 if (UnqualT1 == UnqualT2)
4688 bool ObjCLifetimeConversion;
4698 if (CanPick1 != CanPick2)
4752 if (FromPointee1 == FromPointee2 && ToPointee1 != ToPointee2) {
4760 if (FromPointee1 != FromPointee2 && ToPointee1 == ToPointee2) {
4777 if (FromPtr1 && FromPtr2 && ToPtr1 && ToPtr2) {
4784 bool FromAssignRight
4793 if (ToPtr1->isObjCIdType() &&
4794 (ToPtr2->isObjCQualifiedIdType() || ToPtr2->getInterfaceDecl()))
4796 if (ToPtr2->isObjCIdType() &&
4797 (ToPtr1->isObjCQualifiedIdType() || ToPtr1->getInterfaceDecl()))
4802 if (ToPtr1->isObjCQualifiedIdType() && ToPtr2->getInterfaceDecl())
4804 if (ToPtr2->isObjCQualifiedIdType() && ToPtr1->getInterfaceDecl())
4809 if (ToPtr1->isObjCClassType() &&
4810 (ToPtr2->isObjCQualifiedClassType() || ToPtr2->getInterfaceDecl()))
4812 if (ToPtr2->isObjCClassType() &&
4813 (ToPtr1->isObjCQualifiedClassType() || ToPtr1->getInterfaceDecl()))
4818 if (ToPtr1->isObjCQualifiedClassType() && ToPtr2->getInterfaceDecl())
4820 if (ToPtr2->isObjCQualifiedClassType() && ToPtr1->getInterfaceDecl())
4826 (ToAssignLeft != ToAssignRight)) {
4837 }
else if (IsSecondSame)
4846 (FromAssignLeft != FromAssignRight))
4860 const Type *FromPointeeType1 = FromMemPointer1->getClass();
4861 const Type *ToPointeeType1 = ToMemPointer1->
getClass();
4862 const Type *FromPointeeType2 = FromMemPointer2->
getClass();
4863 const Type *ToPointeeType2 = ToMemPointer2->
getClass();
4869 if (FromPointee1 == FromPointee2 && ToPointee1 != ToPointee2) {
4876 if (ToPointee1 == ToPointee2 && FromPointee1 != FromPointee2) {
4914 if (!
T.getQualifiers().hasUnaligned())
4928 "T1 must be the pointee type of the reference type");
4929 assert(!OrigT2->
isReferenceType() &&
"T2 cannot be a reference type");
4953 if (UnqualT1 == UnqualT2) {
4955 }
else if (isCompleteType(
Loc, OrigT2) &&
4956 IsDerivedFrom(
Loc, UnqualT2, UnqualT1))
4957 Conv |= ReferenceConversions::DerivedToBase;
4961 Conv |= ReferenceConversions::ObjC;
4963 IsFunctionConversion(UnqualT2, UnqualT1, ConvertedT2)) {
4964 Conv |= ReferenceConversions::Function;
4966 return Ref_Compatible;
4968 bool ConvertedReferent = Conv != 0;
4972 bool PreviousToQualsIncludeConst =
true;
4973 bool TopLevel =
true;
4979 Conv |= ReferenceConversions::Qualification;
4985 Conv |= ReferenceConversions::NestedQualification;
4993 bool ObjCLifetimeConversion =
false;
4995 PreviousToQualsIncludeConst,
4996 ObjCLifetimeConversion, getASTContext()))
5002 if (ObjCLifetimeConversion)
5003 Conv |= ReferenceConversions::ObjCLifetime;
5022 bool AllowExplicit) {
5023 assert(T2->
isRecordType() &&
"Can only find conversions of record types.");
5028 const auto &Conversions = T2RecordDecl->getVisibleConversionFunctions();
5029 for (
auto I = Conversions.begin(),
E = Conversions.end(); I !=
E; ++I) {
5032 if (isa<UsingShadowDecl>(
D))
5033 D = cast<UsingShadowDecl>(
D)->getTargetDecl();
5036 = dyn_cast<FunctionTemplateDecl>(
D);
5041 Conv = cast<CXXConversionDecl>(
D);
5053 if (!ConvTemplate &&
5077 ConvTemplate, I.getPair(), ActingDC,
Init, DeclType, CandidateSet,
5078 false, AllowExplicit);
5081 Conv, I.getPair(), ActingDC,
Init, DeclType, CandidateSet,
5082 false, AllowExplicit);
5085 bool HadMultipleCandidates = (CandidateSet.
size() > 1);
5100 if (!Best->FinalConversion.DirectBinding)
5112 "Expected a direct reference binding!");
5118 Cand != CandidateSet.
end(); ++Cand)
5130 llvm_unreachable(
"Invalid OverloadResult!");
5138 bool SuppressUserConversions,
5139 bool AllowExplicit) {
5140 assert(DeclType->
isReferenceType() &&
"Reference init needs a reference");
5167 auto SetAsReferenceBinding = [&](
bool BindsDirectly) {
5172 ICS.
Standard.
Second = (RefConv & Sema::ReferenceConversions::DerivedToBase)
5174 : (RefConv & Sema::ReferenceConversions::ObjC)
5182 Sema::ReferenceConversions::NestedQualification)
5196 (RefConv & Sema::ReferenceConversions::ObjCLifetime) != 0;
5219 SetAsReferenceBinding(
true);
5268 SetAsReferenceBinding(S.
getLangOpts().CPlusPlus11 ||
5359 AllowedExplicit::None,
5384 if (isRValRef && LValRefType) {
5402 bool SuppressUserConversions,
5403 bool InOverloadResolution,
5404 bool AllowObjCWritebackConversion,
5405 bool AllowExplicit =
false);
5411 bool SuppressUserConversions,
5412 bool InOverloadResolution,
5413 bool AllowObjCWritebackConversion) {
5426 if (
const auto *IAT = dyn_cast<IncompleteArrayType>(AT))
5428 InitTy = IAT->getElementType();
5454 if (From->
getNumInits() == 1 && !IsDesignatedInit) {
5460 SuppressUserConversions,
5461 InOverloadResolution,
5462 AllowObjCWritebackConversion);
5471 Result.Standard.setAsIdentityConversion();
5472 Result.Standard.setFromType(ToType);
5473 Result.Standard.setAllToTypes(ToType);
5498 bool IsUnbounded =
false;
5502 if (CT->getSize().ult(e)) {
5506 Result.setInitializerListContainerType(ContTy, IsUnbounded);
5509 if (CT->getSize().ugt(e)) {
5515 S, &EmptyList, InitTy, SuppressUserConversions,
5516 InOverloadResolution, AllowObjCWritebackConversion);
5517 if (DfltElt.
isBad()) {
5521 Result.setInitializerListContainerType(ContTy, IsUnbounded);
5526 assert(isa<IncompleteArrayType>(AT) &&
"Expected incomplete array");
5532 Result.setInitializerListContainerType(ContTy, IsUnbounded);
5542 Result.Standard.setAsIdentityConversion();
5543 Result.Standard.setFromType(InitTy);
5544 Result.Standard.setAllToTypes(InitTy);
5545 for (
unsigned i = 0; i < e; ++i) {
5548 S,
Init, InitTy, SuppressUserConversions, InOverloadResolution,
5549 AllowObjCWritebackConversion);
5560 Result.setInitializerListContainerType(ContTy, IsUnbounded);
5574 Result.setInitializerListContainerType(ContTy, IsUnbounded);
5588 AllowedExplicit::None,
5589 InOverloadResolution,
false,
5590 AllowObjCWritebackConversion,
5609 Result.UserDefined.Before.setAsIdentityConversion();
5614 Result.UserDefined.After.setAsIdentityConversion();
5615 Result.UserDefined.After.setFromType(ToType);
5616 Result.UserDefined.After.setAllToTypes(ToType);
5617 Result.UserDefined.ConversionFunction =
nullptr;
5634 if (From->
getNumInits() == 1 && !IsDesignatedInit) {
5655 SuppressUserConversions,
5663 InOverloadResolution,
5664 AllowObjCWritebackConversion);
5667 assert(!
Result.isEllipsis() &&
5668 "Sub-initialization cannot result in ellipsis conversion.");
5674 Result.UserDefined.After;
5695 if (NumInits == 1 && !isa<InitListExpr>(From->
getInit(0)))
5697 SuppressUserConversions,
5698 InOverloadResolution,
5699 AllowObjCWritebackConversion);
5702 else if (NumInits == 0) {
5704 Result.Standard.setAsIdentityConversion();
5705 Result.Standard.setFromType(ToType);
5706 Result.Standard.setAllToTypes(ToType);
5725 bool SuppressUserConversions,
5726 bool InOverloadResolution,
5727 bool AllowObjCWritebackConversion,
5728 bool AllowExplicit) {
5729 if (
InitListExpr *FromInitList = dyn_cast<InitListExpr>(From))
5731 InOverloadResolution,AllowObjCWritebackConversion);
5736 SuppressUserConversions, AllowExplicit);
5739 SuppressUserConversions,
5740 AllowedExplicit::None,
5741 InOverloadResolution,
5743 AllowObjCWritebackConversion,
5756 return !ICS.
isBad();
5765 const CXXRecordDecl *ActingContext,
bool InOverloadResolution =
false,
5767 bool SuppressUserConversion =
false) {
5775 assert(FromClassification.
isLValue());
5787 if (ExplicitParameterType.isNull())
5790 ValueKindFromClassification(FromClassification));
5792 S, &TmpExpr, ExplicitParameterType, SuppressUserConversion,
5810 if (isa<CXXDestructorDecl>(Method) || Method->
isStatic()) {
5847 FromType, ImplicitParamType);
5857 FromType, ImplicitParamType);
5872 FromType, ImplicitParamType);
5892 if (!FromClassification.
isRValue()) {
5932 FromRecordType = From->
getType();
5933 DestType = ImplicitParamRecordType;
5934 FromClassification = From->
Classify(Context);
5940 From = CreateMaterializeTemporaryExpr(FromRecordType, From,
5959 << Method->
getDeclName() << FromRecordType << (CVR - 1)
5970 bool IsRValueQualified =
5974 << IsRValueQualified;
5986 llvm_unreachable(
"Lists are not objects");
5989 return Diag(From->
getBeginLoc(), diag::err_member_function_call_bad_type)
5990 << ImplicitParamRecordType << FromRecordType
5996 PerformObjectMemberConversion(From, Qualifier, FoundDecl, Method);
5999 From = FromRes.
get();
6008 CK = CK_AddressSpaceConversion;
6011 From = ImpCastExprToType(From, DestType, CK, From->
getValueKind()).get();
6033 AllowedExplicit::Conversions,
6046 return PerformImplicitConversion(From, Context.
BoolTy, ICS,
6049 if (!DiagnoseMultipleUserDefinedConversion(From, Context.
BoolTy))
6114 llvm_unreachable(
"found a first conversion kind in Second");
6118 llvm_unreachable(
"found a third conversion kind in Second");
6124 llvm_unreachable(
"unknown conversion kind");
6136 "converted constant expression outside C++11");
6169 diag::err_typecheck_converted_constant_expression)
6175 llvm_unreachable(
"bad conversion in converted constant expression");
6181 diag::err_typecheck_converted_constant_expression_disallowed)
6187 diag::err_typecheck_converted_constant_expression_indirect)
6197 diag::err_reference_bind_to_bitfield_in_cce)
6207 "unexpected class type converted constant expr");
6210 T, cast<NonTypeTemplateParmDecl>(Dest)),
6228 bool ReturnPreNarrowingValue =
false;
6231 PreNarrowingType)) {
6244 PreNarrowingValue.
isInt()) {
6247 ReturnPreNarrowingValue =
true;
6259 << CCE << 0 << From->
getType() <<
T;
6262 if (!ReturnPreNarrowingValue)
6263 PreNarrowingValue = {};
6280 if (
Result.isInvalid() ||
Result.get()->isValueDependent()) {
6285 RequireInt, PreNarrowingValue);
6292 return ::BuildConvertedConstantExpression(*
this, From,
T, CCE, Dest,
6299 return ::CheckConvertedConstantExpression(*
this, From,
T,
Value, CCE,
false,
6304 llvm::APSInt &
Value,
6311 if (!R.isInvalid() && !R.get()->isValueDependent())
6319 const APValue &PreNarrowingValue) {
6329 Kind = ConstantExprKind::ClassTemplateArgument;
6331 Kind = ConstantExprKind::NonClassTemplateArgument;
6333 Kind = ConstantExprKind::Normal;
6336 (RequireInt && !Eval.
Val.
isInt())) {
6343 if (Notes.empty()) {
6346 if (
const auto *CE = dyn_cast<ConstantExpr>(
E)) {
6350 "ConstantExpr has no value associated with it");
6356 Value = std::move(PreNarrowingValue);
6362 if (Notes.size() == 1 &&
6363 Notes[0].second.getDiagID() == diag::note_invalid_subexpr_in_const_expr) {
6364 Diag(Notes[0].first, diag::err_expr_not_cce) << CCE;
6365 }
else if (!Notes.empty() && Notes[0].second.getDiagID() ==
6366 diag::note_constexpr_invalid_template_arg) {
6367 Notes[0].second.setDiagID(diag::err_constexpr_invalid_template_arg);
6368 for (
unsigned I = 0; I < Notes.size(); ++I)
6369 Diag(Notes[I].first, Notes[I].second);
6373 for (
unsigned I = 0; I < Notes.size(); ++I)
6374 Diag(Notes[I].first, Notes[I].second);
6401 AllowedExplicit::Conversions,
6435 return PerformImplicitConversion(From, Ty, ICS,
6442 assert((isa<UnresolvedMemberExpr, MemberExpr>(MemExprE)) &&
6443 "expected a member expression");
6445 if (
const auto M = dyn_cast<UnresolvedMemberExpr>(MemExprE);
6446 M && !M->isImplicitAccess())
6447 Base = M->getBase();
6448 else if (
const auto M = dyn_cast<MemberExpr>(MemExprE);
6449 M && !M->isImplicitAccess())
6450 Base = M->getBase();
6484 "Method is not an explicit member function");
6485 assert(NewArgs.empty() &&
"NewArgs should be empty");
6487 NewArgs.reserve(Args.size() + 1);
6489 NewArgs.push_back(This);
6490 NewArgs.append(Args.begin(), Args.end());
6493 Method, Object->getBeginLoc());
6512 for (
unsigned I = 0, N = ViableConversions.
size(); I != N; ++I) {
6514 cast<CXXConversionDecl>(ViableConversions[I]->getUnderlyingDecl());
6526 if (ExplicitConversions.
size() == 1 && !Converter.
Suppress) {
6529 cast<CXXConversionDecl>(
Found->getUnderlyingDecl());
6534 std::string TypeStr;
6539 "static_cast<" + TypeStr +
">(")
6551 HadMultipleCandidates);
6558 From,
Result.get()->getType());
6571 cast<CXXConversionDecl>(
Found->getUnderlyingDecl());
6584 HadMultipleCandidates);
6589 CK_UserDefinedConversion,
Result.get(),
6590 nullptr,
Result.get()->getValueKind(),
6612 if (isa<UsingShadowDecl>(
D))
6613 D = cast<UsingShadowDecl>(
D)->getTargetDecl();
6615 if (
auto *ConvTemplate = dyn_cast<FunctionTemplateDecl>(
D)) {
6617 ConvTemplate, FoundDecl, ActingContext, From, ToType, CandidateSet,
6623 Conv, FoundDecl, ActingContext, From, ToType, CandidateSet,
6654 ExprResult result = CheckPlaceholderExpr(From);
6657 From = result.
get();
6661 ExprResult Converted = DefaultLvalueConversion(From);
6672 if (!RecordTy || !getLangOpts().CPlusPlus) {
6684 : Converter(Converter), From(From) {}
6689 } IncompleteDiagnoser(Converter, From);
6692 : RequireCompleteType(
Loc,
T, IncompleteDiagnoser))
6699 const auto &Conversions =
6700 cast<CXXRecordDecl>(RecordTy->
getDecl())->getVisibleConversionFunctions();
6702 bool HadMultipleCandidates =
6703 (std::distance(Conversions.begin(), Conversions.end()) > 1);
6707 bool HasUniqueTargetType =
true;
6710 for (
auto I = Conversions.begin(),
E = Conversions.end(); I !=
E; ++I) {
6720 Conversion = cast<CXXConversionDecl>(
D);
6722 assert((!ConvTemplate || getLangOpts().
CPlusPlus14) &&
6723 "Conversion operator templates are considered potentially "
6727 if (Converter.
match(CurToType) || ConvTemplate) {
6733 ExplicitConversions.
addDecl(I.getDecl(), I.getAccess());
6738 else if (HasUniqueTargetType &&
6740 HasUniqueTargetType =
false;
6742 ViableConversions.
addDecl(I.getDecl(), I.getAccess());
6760 HadMultipleCandidates,
6761 ExplicitConversions))
6767 if (!HasUniqueTargetType)
6786 HadMultipleCandidates,
Found))
6795 HadMultipleCandidates,
6796 ExplicitConversions))
6804 switch (ViableConversions.
size()) {
6807 HadMultipleCandidates,
6808 ExplicitConversions))
6818 HadMultipleCandidates,
Found))
6849 if (Proto->getNumParams() < 1)
6853 QualType ArgType = Proto->getParamType(0).getNonReferenceType();
6858 if (Proto->getNumParams() < 2)
6862 QualType ArgType = Proto->getParamType(1).getNonReferenceType();
6882 unsigned SeenAt = 0;
6884 bool HasDefault =
false;
6893 return HasDefault || SeenAt != 0;
6899 bool PartialOverloading,
bool AllowExplicit,
bool AllowExplicitConversions,
6904 assert(Proto &&
"Functions without a prototype cannot be overloaded");
6905 assert(!
Function->getDescribedFunctionTemplate() &&
6906 "Use AddTemplateOverloadCandidate for function templates");
6909 if (!isa<CXXConstructorDecl>(Method)) {
6919 CandidateSet, SuppressUserConversions,
6920 PartialOverloading, EarlyConversions, PO);
6934 if (Constructor && Constructor->isDefaulted() && Constructor->isDeleted() &&
6935 Constructor->isMoveConstructor())
6955 CandidateSet.
addCandidate(Args.size(), EarlyConversions);
6968 Candidate.
Viable =
false;
6974 if (getLangOpts().CPlusPlusModules &&
Function->isInAnotherModuleUnit()) {
6981 bool IsImplicitlyInstantiated =
false;
6982 if (
auto *SpecInfo =
Function->getTemplateSpecializationInfo()) {
6983 ND = SpecInfo->getTemplate();
6984 IsImplicitlyInstantiated = SpecInfo->getTemplateSpecializationKind() ==
6995 const bool IsInlineFunctionInGMF =
6997 (IsImplicitlyInstantiated ||
Function->isInlined());
7000 Candidate.
Viable =
false;
7007 Candidate.
Viable =
false;
7017 if (Args.size() == 1 && Constructor->isSpecializationCopyingObject() &&
7019 IsDerivedFrom(Args[0]->getBeginLoc(), Args[0]->getType(),
7021 Candidate.
Viable =
false;
7033 auto *Shadow = dyn_cast<ConstructorUsingShadowDecl>(FoundDecl.getDecl());
7034 if (Shadow && Args.size() == 1 && Constructor->getNumParams() >= 1 &&
7035 Constructor->getParamDecl(0)->getType()->isReferenceType()) {
7036 QualType P = Constructor->getParamDecl(0)->getType()->getPointeeType();
7042 Candidate.
Viable =
false;
7051 Constructor->getMethodQualifiers().getAddressSpace(),
7052 CandidateSet.
getDestAS(), getASTContext())) {
7053 Candidate.
Viable =
false;
7066 Candidate.
Viable =
false;
7076 unsigned MinRequiredArgs =
Function->getMinRequiredArguments();
7077 if (!AggregateCandidateDeduction && Args.size() < MinRequiredArgs &&
7078 !PartialOverloading) {
7080 Candidate.
Viable =
false;
7086 if (getLangOpts().
CUDA) {
7094 Candidate.
Viable =
false;
7100 if (
Function->getTrailingRequiresClause()) {
7102 if (CheckFunctionConstraints(
Function, Satisfaction, {},
7105 Candidate.
Viable =
false;
7113 for (
unsigned ArgIdx = 0; ArgIdx < Args.size(); ++ArgIdx) {
7116 if (Candidate.
Conversions[ConvIdx].isInitialized()) {
7119 }
else if (ArgIdx < NumParams) {
7130 *
this, Args[ArgIdx], ParamType, SuppressUserConversions,
7133 getLangOpts().ObjCAutoRefCount, AllowExplicitConversions);
7135 Candidate.
Viable =
false;
7147 if (EnableIfAttr *FailedAttr =
7149 Candidate.
Viable =
false;
7159 if (Methods.size() <= 1)
7162 for (
unsigned b = 0, e = Methods.size();
b < e;
b++) {
7170 if (Args.size() < NumNamedArgs)
7173 for (
unsigned i = 0; i < NumNamedArgs; i++) {
7175 if (Args[i]->isTypeDependent()) {
7181 Expr *argExpr = Args[i];
7182 assert(argExpr &&
"SelectBestMethod(): missing expression");
7187 !param->
hasAttr<CFConsumedAttr>())
7188 argExpr =
ObjC().stripARCUnbridgedCast(argExpr);
7201 getLangOpts().ObjCAutoRefCount,
7205 if (ConversionState.
isBad() ||
7215 for (
unsigned i = NumNamedArgs, e = Args.size(); i < e; ++i) {
7216 if (Args[i]->isTypeDependent()) {
7220 ExprResult Arg = DefaultVariadicArgumentPromotion(Args[i], VariadicMethod,
7229 if (Args.size() != NumNamedArgs)
7231 else if (Match && NumNamedArgs == 0 && Methods.size() > 1) {
7234 for (
unsigned b = 0, e = Methods.size();
b < e;
b++) {
7235 QualType ReturnT = Methods[
b]->getReturnType();
7254 assert(!isa<CXXConstructorDecl>(Method) &&
7255 "Shouldn't have `this` for ctors!");
7256 assert(!Method->
isStatic() &&
"Shouldn't have `this` for static methods!");
7258 ThisArg,
nullptr, Method, Method);
7261 ConvertedThis = R.
get();
7263 if (
auto *MD = dyn_cast<CXXMethodDecl>(
Function)) {
7265 assert((MissingImplicitThis || MD->isStatic() ||
7266 isa<CXXConstructorDecl>(MD)) &&
7267 "Expected `this` for non-ctor instance methods");
7269 ConvertedThis =
nullptr;
7274 unsigned ArgSizeNoVarargs = std::min(
Function->param_size(), Args.size());
7277 for (
unsigned I = 0; I != ArgSizeNoVarargs; ++I) {
7286 ConvertedArgs.push_back(R.
get());
7294 for (
unsigned i = Args.size(), e =
Function->getNumParams(); i != e; ++i) {
7296 if (!
P->hasDefaultArg())
7301 ConvertedArgs.push_back(R.
get());
7313 bool MissingImplicitThis) {
7314 auto EnableIfAttrs =
Function->specific_attrs<EnableIfAttr>();
7315 if (EnableIfAttrs.begin() == EnableIfAttrs.end())
7321 Expr *DiscardedThis;
7323 *
this,
Function,
nullptr, CallLoc, Args, Trap,
7324 true, DiscardedThis, ConvertedArgs))
7325 return *EnableIfAttrs.begin();
7327 for (
auto *EIA : EnableIfAttrs) {
7331 if (EIA->getCond()->isValueDependent() ||
7332 !EIA->getCond()->EvaluateWithSubstitution(
7336 if (!
Result.isInt() || !
Result.getInt().getBoolValue())
7342template <
typename CheckFn>
7345 CheckFn &&IsSuccessful) {
7348 if (ArgDependent == DIA->getArgDependent())
7349 Attrs.push_back(DIA);
7356 auto WarningBegin = std::stable_partition(
7357 Attrs.begin(), Attrs.end(),
7358 [](
const DiagnoseIfAttr *DIA) { return DIA->isError(); });
7362 auto ErrAttr = llvm::find_if(llvm::make_range(Attrs.begin(), WarningBegin),
7364 if (ErrAttr != WarningBegin) {
7365 const DiagnoseIfAttr *DIA = *ErrAttr;
7366 S.
Diag(
Loc, diag::err_diagnose_if_succeeded) << DIA->getMessage();
7367 S.
Diag(DIA->getLocation(), diag::note_from_diagnose_if)
7368 << DIA->getParent() << DIA->getCond()->getSourceRange();
7372 for (
const auto *DIA : llvm::make_range(WarningBegin, Attrs.end()))
7373 if (IsSuccessful(DIA)) {
7374 S.
Diag(
Loc, diag::warn_diagnose_if_succeeded) << DIA->getMessage();
7375 S.
Diag(DIA->getLocation(), diag::note_from_diagnose_if)
7376 << DIA->getParent() << DIA->getCond()->getSourceRange();
7383 const Expr *ThisArg,
7388 [&](
const DiagnoseIfAttr *DIA) {
7393 if (!DIA->getCond()->EvaluateWithSubstitution(
7394 Result, Context, cast<FunctionDecl>(DIA->getParent()), Args, ThisArg))
7396 return Result.isInt() &&
Result.getInt().getBoolValue();
7403 *
this, ND,
false,
Loc,
7404 [&](
const DiagnoseIfAttr *DIA) {
7415 bool SuppressUserConversions,
7416 bool PartialOverloading,
7417 bool FirstArgumentIsBase) {
7419 NamedDecl *
D = F.getDecl()->getUnderlyingDecl();
7426 if (isa<CXXMethodDecl>(FD) && !cast<CXXMethodDecl>(FD)->isStatic()) {
7429 if (Args.size() > 0) {
7430 if (
Expr *
E = Args[0]) {
7438 ObjectClassification =
E->
Classify(Context);
7440 FunctionArgs = Args.slice(1);
7443 AddMethodTemplateCandidate(
7444 FunTmpl, F.getPair(),
7446 ExplicitTemplateArgs, ObjectType, ObjectClassification,
7447 FunctionArgs, CandidateSet, SuppressUserConversions,
7448 PartialOverloading);
7450 AddMethodCandidate(cast<CXXMethodDecl>(FD), F.getPair(),
7451 cast<CXXMethodDecl>(FD)->getParent(), ObjectType,
7452 ObjectClassification, FunctionArgs, CandidateSet,
7453 SuppressUserConversions, PartialOverloading);
7460 if (Args.size() > 0 &&
7461 (!Args[0] || (FirstArgumentIsBase && isa<CXXMethodDecl>(FD) &&
7462 !isa<CXXConstructorDecl>(FD)))) {
7463 assert(cast<CXXMethodDecl>(FD)->isStatic());
7464 FunctionArgs = Args.slice(1);
7467 AddTemplateOverloadCandidate(FunTmpl, F.getPair(),
7468 ExplicitTemplateArgs, FunctionArgs,
7469 CandidateSet, SuppressUserConversions,
7470 PartialOverloading);
7472 AddOverloadCandidate(FD, F.getPair(), FunctionArgs, CandidateSet,
7473 SuppressUserConversions, PartialOverloading);
7483 bool SuppressUserConversions,
7488 if (isa<UsingShadowDecl>(
Decl))
7489 Decl = cast<UsingShadowDecl>(
Decl)->getTargetDecl();
7492 assert(isa<CXXMethodDecl>(TD->getTemplatedDecl()) &&
7493 "Expected a member function template");
7494 AddMethodTemplateCandidate(TD, FoundDecl, ActingContext,
7495 nullptr, ObjectType,
7496 ObjectClassification, Args, CandidateSet,
7497 SuppressUserConversions,
false, PO);
7499 AddMethodCandidate(cast<CXXMethodDecl>(
Decl), FoundDecl, ActingContext,
7500 ObjectType, ObjectClassification, Args, CandidateSet,
7501 SuppressUserConversions,
false, {}, PO);
7511 bool SuppressUserConversions,
7512 bool PartialOverloading,
7517 assert(Proto &&
"Methods without a prototype cannot be overloaded");
7518 assert(!isa<CXXConstructorDecl>(Method) &&
7519 "Use AddOverloadCandidate for constructors");
7537 CandidateSet.
addCandidate(Args.size() + 1, EarlyConversions);
7546 bool IgnoreExplicitObject =
7550 bool ImplicitObjectMethodTreatedAsStatic =
7555 unsigned ExplicitOffset =
7558 unsigned NumParams = Method->
getNumParams() - ExplicitOffset +
7559 int(ImplicitObjectMethodTreatedAsStatic);
7567 Candidate.
Viable =
false;
7579 int(ImplicitObjectMethodTreatedAsStatic);
7581 if (Args.size() < MinRequiredArgs && !PartialOverloading) {
7583 Candidate.
Viable =
false;
7603 Candidate.
Conversions[FirstConvIdx].setStaticObjectArgument();
7608 *
this, CandidateSet.
getLocation(), ObjectType, ObjectClassification,
7609 Method, ActingContext,
true);
7610 if (Candidate.
Conversions[FirstConvIdx].isBad()) {
7611 Candidate.
Viable =
false;
7618 if (getLangOpts().
CUDA)
7619 if (!
CUDA().IsAllowedCall(getCurFunctionDecl(
true),
7621 Candidate.
Viable =
false;
7628 if (CheckFunctionConstraints(Method, Satisfaction, {},
7631 Candidate.
Viable =
false;
7639 for (
unsigned ArgIdx = 0; ArgIdx < Args.size(); ++ArgIdx) {
7642 if (Candidate.
Conversions[ConvIdx].isInitialized()) {
7645 }
else if (ArgIdx < NumParams) {
7651 if (ImplicitObjectMethodTreatedAsStatic) {
7652 ParamType = ArgIdx == 0
7656 ParamType = Proto->
getParamType(ArgIdx + ExplicitOffset);
7660 SuppressUserConversions,
7663 getLangOpts().ObjCAutoRefCount);
7665 Candidate.
Viable =
false;
7677 if (EnableIfAttr *FailedAttr =
7678 CheckEnableIf(Method, CandidateSet.
getLocation(), Args,
true)) {
7679 Candidate.
Viable =
false;
7686 Candidate.
Viable =
false;
7715 PartialOverloading,
false, ObjectType,
7716 ObjectClassification,
7718 return CheckNonDependentConversions(
7719 MethodTmpl, ParamTypes, Args, CandidateSet, Conversions,
7720 SuppressUserConversions, ActingContext, ObjectType,
7721 ObjectClassification, PO);
7725 CandidateSet.
addCandidate(Conversions.size(), Conversions);
7728 Candidate.
Viable =
false;
7733 cast<CXXMethodDecl>(Candidate.
Function)->isStatic() ||
7748 assert(
Specialization &&
"Missing member function template specialization?");
7750 "Specialization is not a member function?");
7751 AddMethodCandidate(cast<CXXMethodDecl>(
Specialization), FoundDecl,
7752 ActingContext, ObjectType, ObjectClassification, Args,
7753 CandidateSet, SuppressUserConversions, PartialOverloading,
7767 bool PartialOverloading,
bool AllowExplicit,
ADLCallKind IsADLCandidate,
7779 Candidate.
Viable =
false;
7798 FunctionTemplate, ExplicitTemplateArgs, Args,
Specialization, Info,
7799 PartialOverloading, AggregateCandidateDeduction,
7803 return CheckNonDependentConversions(
7804 FunctionTemplate, ParamTypes, Args, CandidateSet, Conversions,
7805 SuppressUserConversions,
nullptr,
QualType(), {}, PO);
7809 CandidateSet.
addCandidate(Conversions.size(), Conversions);
7812 Candidate.
Viable =
false;
7820 isa<CXXMethodDecl>(Candidate.
Function) &&
7821 !isa<CXXConstructorDecl>(Candidate.
Function);
7835 assert(
Specialization &&
"Missing function template specialization?");
7836 AddOverloadCandidate(
7837 Specialization, FoundDecl, Args, CandidateSet, SuppressUserConversions,
7838 PartialOverloading, AllowExplicit,
7839 false, IsADLCandidate, Conversions, PO,
7852 const bool AllowExplicit =
false;
7855 auto *Method = dyn_cast<CXXMethodDecl>(FD);
7856 bool HasThisConversion = Method && !isa<CXXConstructorDecl>(Method);
7857 unsigned ThisConversions = HasThisConversion ? 1 : 0;
7869 if (HasThisConversion && !cast<CXXMethodDecl>(FD)->isStatic() &&
7872 if (!FD->hasCXXExplicitFunctionObjectParameter() ||
7873 !ParamTypes[0]->isDependentType()) {
7875 *
this, CandidateSet.
getLocation(), ObjectType, ObjectClassification,
7876 Method, ActingContext,
true,
7877 FD->hasCXXExplicitFunctionObjectParameter() ? ParamTypes[0]
7879 if (Conversions[ConvIdx].isBad())
7887 for (
unsigned I = 0, N = std::min(ParamTypes.size() - Offset, Args.size());
7889 QualType ParamType = ParamTypes[I + Offset];
7893 ConvIdx = Args.size() - 1 - I;
7894 assert(Args.size() + ThisConversions == 2 &&
7895 "number of args (including 'this') must be exactly 2 for "
7899 assert(!HasThisConversion || (ConvIdx == 0 && I == 0));
7902 ConvIdx = ThisConversions + I;
7904 Conversions[ConvIdx]
7906 SuppressUserConversions,
7909 getLangOpts().ObjCAutoRefCount,
7911 if (Conversions[ConvIdx].isBad())
7933 bool AllowObjCPointerConversion) {
7941 bool ObjCLifetimeConversion;
7943 ObjCLifetimeConversion))
7948 if (!AllowObjCPointerConversion)
7952 bool IncompatibleObjC =
false;
7962 bool AllowExplicit,
bool AllowResultConversion) {
7964 "Conversion function templates use AddTemplateConversionCandidate");
7972 if (DeduceReturnType(Conversion, From->
getExprLoc()))
7979 if (!AllowResultConversion &&
7991 AllowObjCConversionOnExplicit))
8011 if (!AllowExplicit && Conversion->
isExplicit()) {
8012 Candidate.
Viable =
false;
8027 const auto *ConversionContext =
8036 From->
Classify(Context), Conversion, ConversionContext,
8041 Candidate.
Viable =
false;
8048 if (CheckFunctionConstraints(Conversion, Satisfaction) ||
8050 Candidate.
Viable =
false;
8062 if (FromCanon == ToCanon ||
8063 IsDerivedFrom(CandidateSet.
getLocation(), FromCanon, ToCanon)) {
8064 Candidate.
Viable =
false;
8081 CK_FunctionToPointerDecay, &ConversionRef,
8085 if (!isCompleteType(From->
getBeginLoc(), ConversionType)) {
8086 Candidate.
Viable =
false;
8100 Buffer, &ConversionFn, CallResultType, VK, From->
getBeginLoc());
8118 Candidate.
Viable =
false;
8130 Candidate.
Viable =
false;
8137 Candidate.
Viable =
false;
8143 "Can only end up with a standard conversion sequence or failure");
8146 if (EnableIfAttr *FailedAttr =
8147 CheckEnableIf(Conversion, CandidateSet.
getLocation(), {})) {
8148 Candidate.
Viable =
false;
8155 Candidate.
Viable =
false;
8164 bool AllowExplicit,
bool AllowResultConversion) {
8166 "Only conversion function templates permitted here");
8178 Candidate.
Viable =
false;
8189 FunctionTemplate, ObjectType, ObjectClassification, ToType,
8195 Candidate.
Viable =
false;
8205 assert(
Specialization &&
"Missing function template specialization?");
8206 AddConversionCandidate(
Specialization, FoundDecl, ActingDC, From, ToType,
8207 CandidateSet, AllowObjCConversionOnExplicit,
8208 AllowExplicit, AllowResultConversion);
8243 *
this, CandidateSet.
getLocation(), Object->getType(),
8244 Object->Classify(Context), Conversion, ActingContext);
8247 if (ObjectInit.
isBad()) {
8248 Candidate.
Viable =
false;
8259 Candidate.
Conversions[0].UserDefined.EllipsisConversion =
false;
8260 Candidate.
Conversions[0].UserDefined.HadMultipleCandidates =
false;
8261 Candidate.
Conversions[0].UserDefined.ConversionFunction = Conversion;
8262 Candidate.
Conversions[0].UserDefined.FoundConversionFunction = FoundDecl;
8265 Candidate.
Conversions[0].UserDefined.After.setAsIdentityConversion();
8273 if (Args.size() > NumParams && !Proto->
isVariadic()) {
8274 Candidate.
Viable =
false;
8281 if (Args.size() < NumParams) {
8283 Candidate.
Viable =
false;
8290 for (
unsigned ArgIdx = 0, N = Args.size(); ArgIdx != N; ++ArgIdx) {
8291 if (ArgIdx < NumParams) {
8302 getLangOpts().ObjCAutoRefCount);
8304 Candidate.
Viable =
false;
8318 if (CheckFunctionConstraints(Conversion, Satisfaction, {},
8321 Candidate.
Viable =
false;
8327 if (EnableIfAttr *FailedAttr =
8328 CheckEnableIf(Conversion, CandidateSet.
getLocation(), {})) {
8329 Candidate.
Viable =
false;
8341 NamedDecl *
D = F.getDecl()->getUnderlyingDecl();
8352 assert(!isa<CXXMethodDecl>(FD) &&
8353 "unqualified operator lookup found a member function");
8356 AddTemplateOverloadCandidate(FunTmpl, F.getPair(), ExplicitTemplateArgs,
8357 FunctionArgs, CandidateSet);
8359 AddTemplateOverloadCandidate(
8360 FunTmpl, F.getPair(), ExplicitTemplateArgs,
8361 {FunctionArgs[1], FunctionArgs[0]}, CandidateSet,
false,
false,
8364 if (ExplicitTemplateArgs)
8366 AddOverloadCandidate(FD, F.getPair(), FunctionArgs, CandidateSet);
8368 AddOverloadCandidate(FD, F.getPair(),
8369 {FunctionArgs[1], FunctionArgs[0]}, CandidateSet,
8370 false,
false,
true,
false, ADLCallKind::NotADL, {},
8399 if (!isCompleteType(OpLoc, T1) && !T1Rec->isBeingDefined())
8402 if (!T1Rec->getDecl()->getDefinition())
8405 LookupResult Operators(*
this, OpName, OpLoc, LookupOrdinaryName);
8406 LookupQualifiedName(Operators, T1Rec->getDecl());
8410 OperEnd = Operators.
end();
8411 Oper != OperEnd; ++Oper) {
8412 if (Oper->getAsFunction() &&
8415 *
this, {Args[1], Args[0]}, Oper->getAsFunction()))
8417 AddMethodCandidate(Oper.getPair(), Args[0]->getType(),
8418 Args[0]->Classify(Context), Args.slice(1),
8419 CandidateSet,
false, PO);
8426 bool IsAssignmentOperator,
8427 unsigned NumContextualBoolArguments) {
8442 for (
unsigned ArgIdx = 0, N = Args.size(); ArgIdx != N; ++ArgIdx) {
8455 if (ArgIdx < NumContextualBoolArguments) {
8456 assert(ParamTys[ArgIdx] == Context.
BoolTy &&
8457 "Contextual conversion to bool requires bool type");
8463 ArgIdx == 0 && IsAssignmentOperator,
8466 getLangOpts().ObjCAutoRefCount);
8469 Candidate.
Viable =
false;
8482class BuiltinCandidateTypeSet {
8488 TypeSet PointerTypes;
8492 TypeSet MemberPointerTypes;
8496 TypeSet EnumerationTypes;
8500 TypeSet VectorTypes;
8504 TypeSet MatrixTypes;
8507 TypeSet BitIntTypes;
8510 bool HasNonRecordTypes;
8514 bool HasArithmeticOrEnumeralTypes;
8518 bool HasNullPtrType;
8527 bool AddPointerWithMoreQualifiedTypeVariants(
QualType Ty,
8529 bool AddMemberPointerWithMoreQualifiedTypeVariants(
QualType Ty);
8533 typedef TypeSet::iterator iterator;
8535 BuiltinCandidateTypeSet(
Sema &SemaRef)
8536 : HasNonRecordTypes(
false),
8537 HasArithmeticOrEnumeralTypes(
false),
8538 HasNullPtrType(
false),
8540 Context(SemaRef.Context) { }
8542 void AddTypesConvertedFrom(
QualType Ty,
8544 bool AllowUserConversions,
8545 bool AllowExplicitConversions,
8546 const Qualifiers &VisibleTypeConversionsQuals);
8548 llvm::iterator_range<iterator> pointer_types() {
return PointerTypes; }
8549 llvm::iterator_range<iterator> member_pointer_types() {
8550 return MemberPointerTypes;
8552 llvm::iterator_range<iterator> enumeration_types() {
8553 return EnumerationTypes;
8555 llvm::iterator_range<iterator> vector_types() {
return VectorTypes; }
8556 llvm::iterator_range<iterator> matrix_types() {
return MatrixTypes; }
8557 llvm::iterator_range<iterator> bitint_types() {
return BitIntTypes; }
8559 bool containsMatrixType(
QualType Ty)
const {
return MatrixTypes.count(Ty); }
8560 bool hasNonRecordTypes() {
return HasNonRecordTypes; }
8561 bool hasArithmeticOrEnumeralTypes() {
return HasArithmeticOrEnumeralTypes; }
8562 bool hasNullPtrType()
const {
return HasNullPtrType; }
8577BuiltinCandidateTypeSet::AddPointerWithMoreQualifiedTypeVariants(
QualType Ty,
8581 if (!PointerTypes.insert(Ty))
8586 bool buildObjCPtr =
false;
8590 buildObjCPtr =
true;
8602 unsigned BaseCVR = PointeeTy.getCVRQualifiers();
8608 if ((CVR | BaseCVR) != CVR)
continue;
8630 PointerTypes.insert(QPointerTy);
8646BuiltinCandidateTypeSet::AddMemberPointerWithMoreQualifiedTypeVariants(
8649 if (!MemberPointerTypes.insert(Ty))
8653 assert(PointerTy &&
"type was not a member pointer type!");
8668 if ((CVR | BaseCVR) != CVR)
continue;
8671 MemberPointerTypes.insert(
8687BuiltinCandidateTypeSet::AddTypesConvertedFrom(
QualType Ty,
8689 bool AllowUserConversions,
8690 bool AllowExplicitConversions,
8702 Ty = SemaRef.Context.getArrayDecayedType(Ty);
8709 HasNonRecordTypes = HasNonRecordTypes || !TyRec;
8712 HasArithmeticOrEnumeralTypes =
8716 PointerTypes.insert(Ty);
8720 if (!AddPointerWithMoreQualifiedTypeVariants(Ty, VisibleQuals))
8724 if (!AddMemberPointerWithMoreQualifiedTypeVariants(Ty))
8727 HasArithmeticOrEnumeralTypes =
true;
8728 EnumerationTypes.insert(Ty);
8730 HasArithmeticOrEnumeralTypes =
true;
8731 BitIntTypes.insert(Ty);
8735 HasArithmeticOrEnumeralTypes =
true;
8736 VectorTypes.insert(Ty);
8740 HasArithmeticOrEnumeralTypes =
true;
8741 MatrixTypes.insert(Ty);
8743 HasNullPtrType =
true;
8744 }
else if (AllowUserConversions && TyRec) {
8746 if (!SemaRef.isCompleteType(Loc, Ty))
8751 if (isa<UsingShadowDecl>(
D))
8752 D = cast<UsingShadowDecl>(
D)->getTargetDecl();
8756 if (isa<FunctionTemplateDecl>(
D))
8760 if (AllowExplicitConversions || !Conv->
isExplicit()) {
8823 if (isa<UsingShadowDecl>(
D))
8824 D = cast<UsingShadowDecl>(
D)->getTargetDecl();
8858 if (Available.hasAtomic()) {
8859 Available.removeAtomic();
8866 if (Available.hasVolatile()) {
8867 Available.removeVolatile();
8901class BuiltinOperatorOverloadBuilder {
8906 bool HasArithmeticOrEnumeralCandidateType;
8910 static constexpr int ArithmeticTypesCap = 26;
8916 unsigned FirstIntegralType,
8918 unsigned FirstPromotedIntegralType,
8919 LastPromotedIntegralType;
8920 unsigned FirstPromotedArithmeticType,
8921 LastPromotedArithmeticType;
8922 unsigned NumArithmeticTypes;
8924 void InitArithmeticTypes() {
8926 FirstPromotedArithmeticType = 0;
8936 FirstIntegralType = ArithmeticTypes.size();
8937 FirstPromotedIntegralType = ArithmeticTypes.size();
8960 llvm::for_each(CandidateTypes, [&BitIntCandidates](
8961 BuiltinCandidateTypeSet &Candidate) {
8962 for (
QualType BitTy : Candidate.bitint_types())
8965 llvm::move(BitIntCandidates, std::back_inserter(ArithmeticTypes));
8966 LastPromotedIntegralType = ArithmeticTypes.size();
8967 LastPromotedArithmeticType = ArithmeticTypes.size();
8981 LastIntegralType = ArithmeticTypes.size();
8982 NumArithmeticTypes = ArithmeticTypes.size();
8989 assert(ArithmeticTypes.size() - BitIntCandidates.size() <=
8990 ArithmeticTypesCap &&
8991 "Enough inline storage for all arithmetic types.");
8996 void addPlusPlusMinusMinusStyleOverloads(
QualType CandidateTy,
9045 BuiltinOperatorOverloadBuilder(
9048 bool HasArithmeticOrEnumeralCandidateType,
9052 VisibleTypeConversionsQuals(VisibleTypeConversionsQuals),
9053 HasArithmeticOrEnumeralCandidateType(
9054 HasArithmeticOrEnumeralCandidateType),
9055 CandidateTypes(CandidateTypes),
9056 CandidateSet(CandidateSet) {
9058 InitArithmeticTypes();
9081 if (!HasArithmeticOrEnumeralCandidateType)
9084 for (
unsigned Arith = 0; Arith < NumArithmeticTypes; ++Arith) {
9085 const auto TypeOfT = ArithmeticTypes[Arith];
9087 if (Op == OO_MinusMinus)
9089 if (Op == OO_PlusPlus && S.
getLangOpts().CPlusPlus17)
9092 addPlusPlusMinusMinusStyleOverloads(
9109 void addPlusPlusMinusMinusPointerOverloads() {
9110 for (
QualType PtrTy : CandidateTypes[0].pointer_types()) {
9112 if (!PtrTy->getPointeeType()->isObjectType())
9115 addPlusPlusMinusMinusStyleOverloads(
9117 (!PtrTy.isVolatileQualified() &&
9119 (!PtrTy.isRestrictQualified() &&
9134 void addUnaryStarPointerOverloads() {
9135 for (
QualType ParamTy : CandidateTypes[0].pointer_types()) {
9141 if (Proto->getMethodQuals() || Proto->getRefQualifier())
9154 void addUnaryPlusOrMinusArithmeticOverloads() {
9155 if (!HasArithmeticOrEnumeralCandidateType)
9158 for (
unsigned Arith = FirstPromotedArithmeticType;
9159 Arith < LastPromotedArithmeticType; ++Arith) {
9160 QualType ArithTy = ArithmeticTypes[Arith];
9165 for (
QualType VecTy : CandidateTypes[0].vector_types())
9174 void addUnaryPlusPointerOverloads() {
9175 for (
QualType ParamTy : CandidateTypes[0].pointer_types())
9184 void addUnaryTildePromotedIntegralOverloads() {
9185 if (!HasArithmeticOrEnumeralCandidateType)
9188 for (
unsigned Int = FirstPromotedIntegralType;
9189 Int < LastPromotedIntegralType; ++
Int) {
9195 for (
QualType VecTy : CandidateTypes[0].vector_types())
9205 void addEqualEqualOrNotEqualMemberPointerOrNullptrOverloads() {
9209 for (
unsigned ArgIdx = 0, N = Args.size(); ArgIdx != N; ++ArgIdx) {
9210 for (
QualType MemPtrTy : CandidateTypes[ArgIdx].member_pointer_types()) {
9215 QualType ParamTypes[2] = {MemPtrTy, MemPtrTy};
9219 if (CandidateTypes[ArgIdx].hasNullPtrType()) {
9221 if (AddedTypes.insert(NullPtrTy).second) {
9222 QualType ParamTypes[2] = { NullPtrTy, NullPtrTy };
9241 void addGenericBinaryPointerOrEnumeralOverloads(
bool IsSpaceship) {
9254 llvm::DenseSet<std::pair<CanQualType, CanQualType> >
9255 UserDefinedBinaryOperators;
9257 for (
unsigned ArgIdx = 0, N = Args.size(); ArgIdx != N; ++ArgIdx) {
9258 if (!CandidateTypes[ArgIdx].enumeration_types().empty()) {
9260 CEnd = CandidateSet.
end();
9262 if (!
C->Viable || !
C->Function ||
C->Function->getNumParams() != 2)
9265 if (
C->Function->isFunctionTemplateSpecialization())
9274 .getUnqualifiedType();
9277 .getUnqualifiedType();
9285 UserDefinedBinaryOperators.insert(
9295 for (
unsigned ArgIdx = 0, N = Args.size(); ArgIdx != N; ++ArgIdx) {
9296 for (
QualType PtrTy : CandidateTypes[ArgIdx].pointer_types()) {
9300 if (IsSpaceship && PtrTy->isFunctionPointerType())
9303 QualType ParamTypes[2] = {PtrTy, PtrTy};
9306 for (
QualType EnumTy : CandidateTypes[ArgIdx].enumeration_types()) {
9311 if (!AddedTypes.insert(CanonType).second ||
9312 UserDefinedBinaryOperators.count(std::make_pair(CanonType,
9315 QualType ParamTypes[2] = {EnumTy, EnumTy};
9342 for (
int Arg = 0; Arg < 2; ++Arg) {
9343 QualType AsymmetricParamTypes[2] = {
9347 for (
QualType PtrTy : CandidateTypes[Arg].pointer_types()) {
9352 AsymmetricParamTypes[Arg] = PtrTy;
9353 if (Arg == 0 || Op == OO_Plus) {
9358 if (Op == OO_Minus) {
9363 QualType ParamTypes[2] = {PtrTy, PtrTy};
9399 void addGenericBinaryArithmeticOverloads() {
9400 if (!HasArithmeticOrEnumeralCandidateType)
9403 for (
unsigned Left = FirstPromotedArithmeticType;
9404 Left < LastPromotedArithmeticType; ++
Left) {
9405 for (
unsigned Right = FirstPromotedArithmeticType;
9406 Right < LastPromotedArithmeticType; ++
Right) {
9408 ArithmeticTypes[
Right] };
9415 for (
QualType Vec1Ty : CandidateTypes[0].vector_types())
9416 for (
QualType Vec2Ty : CandidateTypes[1].vector_types()) {
9417 QualType LandR[2] = {Vec1Ty, Vec2Ty};
9427 void addMatrixBinaryArithmeticOverloads() {
9428 if (!HasArithmeticOrEnumeralCandidateType)
9431 for (
QualType M1 : CandidateTypes[0].matrix_types()) {
9432 AddCandidate(M1, cast<MatrixType>(M1)->getElementType());
9433 AddCandidate(M1, M1);
9436 for (
QualType M2 : CandidateTypes[1].matrix_types()) {
9437 AddCandidate(cast<MatrixType>(M2)->getElementType(), M2);
9438 if (!CandidateTypes[0].containsMatrixType(M2))
9439 AddCandidate(M2, M2);
9474 void addThreeWayArithmeticOverloads() {
9475 addGenericBinaryArithmeticOverloads();
9492 void addBinaryBitwiseArithmeticOverloads() {
9493 if (!HasArithmeticOrEnumeralCandidateType)
9496 for (
unsigned Left = FirstPromotedIntegralType;
9497 Left < LastPromotedIntegralType; ++
Left) {
9498 for (
unsigned Right = FirstPromotedIntegralType;
9501 ArithmeticTypes[
Right] };
9514 void addAssignmentMemberPointerOrEnumeralOverloads() {
9518 for (
unsigned ArgIdx = 0; ArgIdx < 2; ++ArgIdx) {
9519 for (
QualType EnumTy : CandidateTypes[ArgIdx].enumeration_types()) {
9526 for (
QualType MemPtrTy : CandidateTypes[ArgIdx].member_pointer_types()) {
9551 void addAssignmentPointerOverloads(
bool isEqualOp) {
9555 for (
QualType PtrTy : CandidateTypes[0].pointer_types()) {
9559 else if (!PtrTy->getPointeeType()->isObjectType())
9570 bool NeedVolatile = !PtrTy.isVolatileQualified() &&
9580 if (!PtrTy.isRestrictQualified() &&
9600 for (
QualType PtrTy : CandidateTypes[1].pointer_types()) {
9614 bool NeedVolatile = !PtrTy.isVolatileQualified() &&
9624 if (!PtrTy.isRestrictQualified() &&
9657 void addAssignmentArithmeticOverloads(
bool isEqualOp) {
9658 if (!HasArithmeticOrEnumeralCandidateType)
9661 for (
unsigned Left = 0;
Left < NumArithmeticTypes; ++
Left) {
9662 for (
unsigned Right = FirstPromotedArithmeticType;
9663 Right < LastPromotedArithmeticType; ++
Right) {
9665 ParamTypes[1] = ArithmeticTypes[
Right];
9667 S, ArithmeticTypes[Left], Args[0]);
9680 for (
QualType Vec1Ty : CandidateTypes[0].vector_types())
9681 for (
QualType Vec2Ty : CandidateTypes[0].vector_types()) {
9683 ParamTypes[1] = Vec2Ty;
9711 void addAssignmentIntegralOverloads() {
9712 if (!HasArithmeticOrEnumeralCandidateType)
9715 for (
unsigned Left = FirstIntegralType;
Left < LastIntegralType; ++
Left) {
9716 for (
unsigned Right = FirstPromotedIntegralType;
9719 ParamTypes[1] = ArithmeticTypes[
Right];
9721 S, ArithmeticTypes[Left], Args[0]);
9740 void addExclaimOverload() {
9746 void addAmpAmpOrPipePipeOverload() {
9763 void addSubscriptOverloads() {
9764 for (
QualType PtrTy : CandidateTypes[0].pointer_types()) {
9774 for (
QualType PtrTy : CandidateTypes[1].pointer_types()) {
9794 void addArrowStarOverloads() {
9795 for (
QualType PtrTy : CandidateTypes[0].pointer_types()) {
9800 if (!isa<RecordType>(C1))
9809 for (
QualType MemPtrTy : CandidateTypes[1].member_pointer_types()) {
9815 QualType ParamTypes[2] = {PtrTy, MemPtrTy};
9819 T.isVolatileQualified())
9822 T.isRestrictQualified())
9840 void addConditionalOperatorOverloads() {
9844 for (
unsigned ArgIdx = 0; ArgIdx < 2; ++ArgIdx) {
9845 for (
QualType PtrTy : CandidateTypes[ArgIdx].pointer_types()) {
9849 QualType ParamTypes[2] = {PtrTy, PtrTy};
9853 for (
QualType MemPtrTy : CandidateTypes[ArgIdx].member_pointer_types()) {
9857 QualType ParamTypes[2] = {MemPtrTy, MemPtrTy};
9862 for (
QualType EnumTy : CandidateTypes[ArgIdx].enumeration_types()) {
9869 QualType ParamTypes[2] = {EnumTy, EnumTy};
9888 VisibleTypeConversionsQuals.
addConst();
9889 for (
unsigned ArgIdx = 0, N = Args.size(); ArgIdx != N; ++ArgIdx) {
9891 if (Args[ArgIdx]->getType()->isAtomicType())
9892 VisibleTypeConversionsQuals.
addAtomic();
9895 bool HasNonRecordCandidateType =
false;
9896 bool HasArithmeticOrEnumeralCandidateType =
false;
9898 for (
unsigned ArgIdx = 0, N = Args.size(); ArgIdx != N; ++ArgIdx) {
9899 CandidateTypes.emplace_back(*
this);
9900 CandidateTypes[ArgIdx].AddTypesConvertedFrom(Args[ArgIdx]->getType(),
9903 (Op == OO_Exclaim ||
9906 VisibleTypeConversionsQuals);
9907 HasNonRecordCandidateType = HasNonRecordCandidateType ||
9908 CandidateTypes[ArgIdx].hasNonRecordTypes();
9909 HasArithmeticOrEnumeralCandidateType =
9910 HasArithmeticOrEnumeralCandidateType ||
9911 CandidateTypes[ArgIdx].hasArithmeticOrEnumeralTypes();
9919 if (!HasNonRecordCandidateType &&
9920 !(Op == OO_Exclaim || Op == OO_AmpAmp || Op == OO_PipePipe))
9924 BuiltinOperatorOverloadBuilder OpBuilder(*
this, Args,
9925 VisibleTypeConversionsQuals,
9926 HasArithmeticOrEnumeralCandidateType,
9927 CandidateTypes, CandidateSet);
9933 llvm_unreachable(
"Expected an overloaded operator");
9938 case OO_Array_Delete:
9941 "Special operators don't use AddBuiltinOperatorCandidates");
9953 if (Args.size() == 1)
9954 OpBuilder.addUnaryPlusPointerOverloads();
9958 if (Args.size() == 1) {
9959 OpBuilder.addUnaryPlusOrMinusArithmeticOverloads();
9961 OpBuilder.addBinaryPlusOrMinusPointerOverloads(Op);
9962 OpBuilder.addGenericBinaryArithmeticOverloads();
9963 OpBuilder.addMatrixBinaryArithmeticOverloads();
9968 if (Args.size() == 1)
9969 OpBuilder.addUnaryStarPointerOverloads();
9971 OpBuilder.addGenericBinaryArithmeticOverloads();
9972 OpBuilder.addMatrixBinaryArithmeticOverloads();
9977 OpBuilder.addGenericBinaryArithmeticOverloads();
9982 OpBuilder.addPlusPlusMinusMinusArithmeticOverloads(Op);
9983 OpBuilder.addPlusPlusMinusMinusPointerOverloads();
9987 case OO_ExclaimEqual:
9988 OpBuilder.addEqualEqualOrNotEqualMemberPointerOrNullptrOverloads();
9989 OpBuilder.addGenericBinaryPointerOrEnumeralOverloads(
false);
9990 OpBuilder.addGenericBinaryArithmeticOverloads();
9996 case OO_GreaterEqual:
9997 OpBuilder.addGenericBinaryPointerOrEnumeralOverloads(
false);
9998 OpBuilder.addGenericBinaryArithmeticOverloads();
10002 OpBuilder.addGenericBinaryPointerOrEnumeralOverloads(
true);
10003 OpBuilder.addThreeWayArithmeticOverloads();
10010 case OO_GreaterGreater:
10011 OpBuilder.addBinaryBitwiseArithmeticOverloads();
10015 if (Args.size() == 1)
10021 OpBuilder.addBinaryBitwiseArithmeticOverloads();
10025 OpBuilder.addUnaryTildePromotedIntegralOverloads();
10029 OpBuilder.addAssignmentMemberPointerOrEnumeralOverloads();
10033 case OO_MinusEqual:
10034 OpBuilder.addAssignmentPointerOverloads(Op == OO_Equal);
10038 case OO_SlashEqual:
10039 OpBuilder.addAssignmentArithmeticOverloads(Op == OO_Equal);
10042 case OO_PercentEqual:
10043 case OO_LessLessEqual:
10044 case OO_GreaterGreaterEqual:
10046 case OO_CaretEqual:
10048 OpBuilder.addAssignmentIntegralOverloads();
10052 OpBuilder.addExclaimOverload();
10057 OpBuilder.addAmpAmpOrPipePipeOverload();
10061 if (Args.size() == 2)
10062 OpBuilder.addSubscriptOverloads();
10066 OpBuilder.addArrowStarOverloads();
10069 case OO_Conditional:
10070 OpBuilder.addConditionalOperatorOverloads();
10071 OpBuilder.addGenericBinaryArithmeticOverloads();
10082 bool PartialOverloading) {
10093 ArgumentDependentLookup(Name,
Loc, Args, Fns);
10097 CandEnd = CandidateSet.
end();
10098 Cand != CandEnd; ++Cand)
10099 if (Cand->Function) {
10103 Fns.
erase(FunTmpl);
10112 if (ExplicitTemplateArgs)
10115 AddOverloadCandidate(
10116 FD, FoundDecl, Args, CandidateSet,
false,
10117 PartialOverloading,
true,
10118 false, ADLCallKind::UsesADL);
10120 AddOverloadCandidate(
10121 FD, FoundDecl, {Args[1], Args[0]}, CandidateSet,
10122 false, PartialOverloading,
10127 auto *FTD = cast<FunctionTemplateDecl>(*I);
10128 AddTemplateOverloadCandidate(
10129 FTD, FoundDecl, ExplicitTemplateArgs, Args, CandidateSet,
10130 false, PartialOverloading,
10131 true, ADLCallKind::UsesADL);
10133 *
this, Args, FTD->getTemplatedDecl())) {
10134 AddTemplateOverloadCandidate(
10135 FTD, FoundDecl, ExplicitTemplateArgs, {Args[1], Args[0]},
10136 CandidateSet,
false, PartialOverloading,
10137 true, ADLCallKind::UsesADL,
10145enum class Comparison {
Equal, Better, Worse };
10162 bool Cand1Attr = Cand1->
hasAttr<EnableIfAttr>();
10163 bool Cand2Attr = Cand2->
hasAttr<EnableIfAttr>();
10164 if (!Cand1Attr || !Cand2Attr) {
10165 if (Cand1Attr == Cand2Attr)
10166 return Comparison::Equal;
10167 return Cand1Attr ? Comparison::Better : Comparison::Worse;
10173 llvm::FoldingSetNodeID Cand1ID, Cand2ID;
10174 for (
auto Pair : zip_longest(Cand1Attrs, Cand2Attrs)) {
10175 std::optional<EnableIfAttr *> Cand1A = std::get<0>(Pair);
10176 std::optional<EnableIfAttr *> Cand2A = std::get<1>(Pair);
10181 return Comparison::Worse;
10183 return Comparison::Better;
10188 (*Cand1A)->getCond()->Profile(Cand1ID, S.
getASTContext(),
true);
10189 (*Cand2A)->getCond()->Profile(Cand2ID, S.
getASTContext(),
true);
10190 if (Cand1ID != Cand2ID)
10191 return Comparison::Worse;
10194 return Comparison::Equal;
10202 return Comparison::Equal;
10208 return Comparison::Equal;
10209 return Comparison::Worse;
10212 return Comparison::Better;
10218 const auto *Cand1CPUSpec = Cand1.
Function->
getAttr<CPUSpecificAttr>();
10219 const auto *Cand2CPUSpec = Cand2.
Function->
getAttr<CPUSpecificAttr>();
10221 if (!Cand1CPUDisp && !Cand2CPUDisp && !Cand1CPUSpec && !Cand2CPUSpec)
10222 return Comparison::Equal;
10224 if (Cand1CPUDisp && !Cand2CPUDisp)
10225 return Comparison::Better;
10226 if (Cand2CPUDisp && !Cand1CPUDisp)
10227 return Comparison::Worse;
10229 if (Cand1CPUSpec && Cand2CPUSpec) {
10230 if (Cand1CPUSpec->cpus_size() != Cand2CPUSpec->cpus_size())
10231 return Cand1CPUSpec->cpus_size() < Cand2CPUSpec->cpus_size()
10232 ? Comparison::Better
10233 : Comparison::Worse;
10235 std::pair<CPUSpecificAttr::cpus_iterator, CPUSpecificAttr::cpus_iterator>
10236 FirstDiff = std::mismatch(
10237 Cand1CPUSpec->cpus_begin(), Cand1CPUSpec->cpus_end(),
10238 Cand2CPUSpec->cpus_begin(),
10240 return LHS->getName() == RHS->getName();
10243 assert(FirstDiff.first != Cand1CPUSpec->cpus_end() &&
10244 "Two different cpu-specific versions should not have the same "
10245 "identifier list, otherwise they'd be the same decl!");
10246 return (*FirstDiff.first)->getName() < (*FirstDiff.second)->
getName()
10247 ? Comparison::Better
10248 : Comparison::Worse;
10250 llvm_unreachable(
"No way to get here unless both had cpu_dispatch");
10256static std::optional<QualType>
10258 if (!isa<CXXMethodDecl>(F) || isa<CXXConstructorDecl>(F))
10259 return std::nullopt;
10261 auto *M = cast<CXXMethodDecl>(F);
10265 return M->getFunctionObjectParameterReferenceType();
10279 PT2->getInstantiatedFromMemberTemplate()))
10290 assert(I < F->getNumParams());
10294 unsigned F1NumParams = F1->
getNumParams() + isa<CXXMethodDecl>(F1);
10295 unsigned F2NumParams = F2->
getNumParams() + isa<CXXMethodDecl>(F2);
10297 if (F1NumParams != F2NumParams)
10300 unsigned I1 = 0, I2 = 0;
10301 for (
unsigned I = 0; I != F1NumParams; ++I) {
10302 QualType T1 = NextParam(F1, I1, I == 0);
10303 QualType T2 = NextParam(F2, I2, I == 0);
10304 assert(!T1.
isNull() && !T2.
isNull() &&
"Unexpected null param types");
10332 auto *Mem1 = dyn_cast<CXXMethodDecl>(Fn1);
10333 auto *Mem2 = dyn_cast<CXXMethodDecl>(Fn2);
10334 if (Mem1 && Mem2) {
10337 if (Mem1->getParent() != Mem2->getParent())
10341 if (Mem1->isInstance() && Mem2->isInstance() &&
10343 Mem1->getFunctionObjectParameterReferenceType(),
10344 Mem1->getFunctionObjectParameterReferenceType()))
10400 bool IsCand1ImplicitHD =
10402 bool IsCand2ImplicitHD =
10417 auto EmitThreshold =
10418 (S.
getLangOpts().CUDAIsDevice && IsCallerImplicitHD &&
10419 (IsCand1ImplicitHD || IsCand2ImplicitHD))
10422 auto Cand1Emittable = P1 > EmitThreshold;
10423 auto Cand2Emittable = P2 > EmitThreshold;
10424 if (Cand1Emittable && !Cand2Emittable)
10426 if (!Cand1Emittable && Cand2Emittable)
10437 unsigned StartArg = 0;
10444 return ICS.isStandard() &&
10456 assert(Cand2.
Conversions.size() == NumArgs &&
"Overload candidate mismatch");
10457 bool HasBetterConversion =
false;
10458 for (
unsigned ArgIdx = StartArg; ArgIdx < NumArgs; ++ArgIdx) {
10459 bool Cand1Bad = IsIllFormedConversion(Cand1.
Conversions[ArgIdx]);
10460 bool Cand2Bad = IsIllFormedConversion(Cand2.
Conversions[ArgIdx]);
10461 if (Cand1Bad != Cand2Bad) {
10464 HasBetterConversion =
true;
10468 if (HasBetterConversion)
10475 bool HasWorseConversion =
false;
10476 for (
unsigned ArgIdx = StartArg; ArgIdx < NumArgs; ++ArgIdx) {
10482 HasBetterConversion =
true;
10501 HasWorseConversion =
true;
10516 if (HasBetterConversion && !HasWorseConversion)
10527 isa<CXXConversionDecl>(Cand1.
Function) &&
10528 isa<CXXConversionDecl>(Cand2.
Function)) {
10556 isa<CXXConstructorDecl>(Cand1.
Function) !=
10557 isa<CXXConstructorDecl>(Cand2.
Function))
10558 return isa<CXXConstructorDecl>(Cand1.
Function);
10562 bool Cand1IsSpecialization = Cand1.
Function &&
10564 bool Cand2IsSpecialization = Cand2.
Function &&
10566 if (Cand1IsSpecialization != Cand2IsSpecialization)
10567 return Cand2IsSpecialization;
10573 if (Cand1IsSpecialization && Cand2IsSpecialization) {
10574 const auto *Obj1Context =
10576 const auto *Obj2Context =
10584 Obj1Context ?
QualType(Obj1Context->getTypeForDecl(), 0)
10586 Obj2Context ?
QualType(Obj2Context->getTypeForDecl(), 0)
10595 if (!Cand1IsSpecialization && !Cand2IsSpecialization &&
10605 bool Cand1IsInherited =
10607 bool Cand2IsInherited =
10609 if (Cand1IsInherited != Cand2IsInherited)
10610 return Cand2IsInherited;
10611 else if (Cand1IsInherited) {
10612 assert(Cand2IsInherited);
10615 if (Cand1Class->isDerivedFrom(Cand2Class))
10617 if (Cand2Class->isDerivedFrom(Cand1Class))
10634 auto *Guide1 = dyn_cast_or_null<CXXDeductionGuideDecl>(Cand1.
Function);
10635 auto *Guide2 = dyn_cast_or_null<CXXDeductionGuideDecl>(Cand2.
Function);
10636 if (Guide1 && Guide2) {
10638 if (Guide1->isImplicit() != Guide2->isImplicit())
10639 return Guide2->isImplicit();
10649 const auto *Constructor1 = Guide1->getCorrespondingConstructor();
10650 const auto *Constructor2 = Guide2->getCorrespondingConstructor();
10651 if (Constructor1 && Constructor2) {
10652 bool isC1Templated = Constructor1->getTemplatedKind() !=
10654 bool isC2Templated = Constructor2->getTemplatedKind() !=
10656 if (isC1Templated != isC2Templated)
10657 return isC2Templated;
10665 if (Cmp != Comparison::Equal)
10666 return Cmp == Comparison::Better;
10669 bool HasPS1 = Cand1.
Function !=
nullptr &&
10671 bool HasPS2 = Cand2.
Function !=
nullptr &&
10673 if (HasPS1 != HasPS2 && HasPS1)
10677 if (MV == Comparison::Better)
10679 if (MV == Comparison::Worse)
10694 const auto *CD1 = dyn_cast_or_null<CXXConstructorDecl>(Cand1.
Function);
10695 const auto *CD2 = dyn_cast_or_null<CXXConstructorDecl>(Cand2.
Function);
10697 LangAS AS1 = CD1->getMethodQualifiers().getAddressSpace();
10698 LangAS AS2 = CD2->getMethodQualifiers().getAddressSpace();
10719 auto *VA = dyn_cast_or_null<ValueDecl>(A);
10720 auto *VB = dyn_cast_or_null<ValueDecl>(B);
10726 if (!VA->getDeclContext()->getRedeclContext()->Equals(
10727 VB->getDeclContext()->getRedeclContext()) ||
10728 getOwningModule(VA) == getOwningModule(VB) ||
10729 VA->isExternallyVisible() || VB->isExternallyVisible())
10737 if (Context.
hasSameType(VA->getType(), VB->getType()))
10742 if (
auto *EA = dyn_cast<EnumConstantDecl>(VA)) {
10743 if (
auto *EB = dyn_cast<EnumConstantDecl>(VB)) {
10746 auto *EnumA = cast<EnumDecl>(EA->getDeclContext());
10747 auto *EnumB = cast<EnumDecl>(EB->getDeclContext());
10748 if (EnumA->hasNameForLinkage() || EnumB->hasNameForLinkage() ||
10750 EnumB->getIntegerType()))
10753 return llvm::APSInt::isSameValue(EA->getInitVal(), EB->getInitVal());
10763 assert(
D &&
"Unknown declaration");
10764 Diag(
Loc, diag::ext_equivalent_internal_linkage_decl_in_modules) <<
D;
10766 Module *M = getOwningModule(
D);
10770 for (
auto *
E : Equiv) {
10771 Module *M = getOwningModule(
E);
10772 Diag(
E->getLocation(), diag::note_equivalent_internal_linkage_decl)
10781 static_cast<CNSInfo *
>(DeductionFailure.Data)
10782 ->Satisfaction.ContainsErrors;
10799 std::transform(
begin(),
end(), std::back_inserter(Candidates),
10815 bool ContainsSameSideCandidate =
10819 S.
CUDA().IdentifyPreference(Caller, Cand->
Function) ==
10822 if (ContainsSameSideCandidate) {
10829 llvm::erase_if(Candidates, IsWrongSideCandidate);
10835 for (
auto *Cand : Candidates) {
10836 Cand->
Best =
false;
10838 if (Best ==
end() ||
10858 PendingBest.push_back(&*Best);
10863 while (!PendingBest.empty()) {
10864 auto *Curr = PendingBest.pop_back_val();
10865 for (
auto *Cand : Candidates) {
10868 PendingBest.push_back(Cand);
10873 EquivalentCands.push_back(Cand->
Function);
10885 if (Best->Function && Best->Function->isDeleted())
10888 if (
auto *M = dyn_cast_or_null<CXXMethodDecl>(Best->Function);
10890 M->isImplicitObjectMemberFunction()) {
10894 if (!EquivalentCands.empty())
10903enum OverloadCandidateKind {
10906 oc_reversed_binary_operator,
10908 oc_implicit_default_constructor,
10909 oc_implicit_copy_constructor,
10910 oc_implicit_move_constructor,
10911 oc_implicit_copy_assignment,
10912 oc_implicit_move_assignment,
10913 oc_implicit_equality_comparison,
10914 oc_inherited_constructor
10917enum OverloadCandidateSelect {
10920 ocs_described_template,
10923static std::pair<OverloadCandidateKind, OverloadCandidateSelect>
10927 std::string &Description) {
10933 FunTmpl->getTemplateParameters(), *
Fn->getTemplateSpecializationArgs());
10936 OverloadCandidateSelect Select = [&]() {
10937 if (!Description.empty())
10938 return ocs_described_template;
10939 return isTemplate ? ocs_template : ocs_non_template;
10942 OverloadCandidateKind Kind = [&]() {
10943 if (
Fn->isImplicit() &&
Fn->getOverloadedOperator() == OO_EqualEqual)
10944 return oc_implicit_equality_comparison;
10947 return oc_reversed_binary_operator;
10949 if (
const auto *Ctor = dyn_cast<CXXConstructorDecl>(Fn)) {
10950 if (!Ctor->isImplicit()) {
10951 if (isa<ConstructorUsingShadowDecl>(
Found))
10952 return oc_inherited_constructor;
10954 return oc_constructor;
10957 if (Ctor->isDefaultConstructor())
10958 return oc_implicit_default_constructor;
10960 if (Ctor->isMoveConstructor())
10961 return oc_implicit_move_constructor;
10963 assert(Ctor->isCopyConstructor() &&
10964 "unexpected sort of implicit constructor");
10965 return oc_implicit_copy_constructor;
10968 if (
const auto *Meth = dyn_cast<CXXMethodDecl>(Fn)) {
10971 if (!Meth->isImplicit())
10974 if (Meth->isMoveAssignmentOperator())
10975 return oc_implicit_move_assignment;
10977 if (Meth->isCopyAssignmentOperator())
10978 return oc_implicit_copy_assignment;
10980 assert(isa<CXXConversionDecl>(Meth) &&
"expected conversion");
10984 return oc_function;
10987 return std::make_pair(Kind, Select);
10990void MaybeEmitInheritedConstructorNote(
Sema &S,
const Decl *FoundDecl) {
10993 if (
const auto *Shadow = dyn_cast<ConstructorUsingShadowDecl>(FoundDecl))
10995 diag::note_ovl_candidate_inherited_constructor)
10996 << Shadow->getNominatedBaseClass();
11005 if (EnableIf->getCond()->isValueDependent() ||
11006 !EnableIf->getCond()->EvaluateAsBooleanCondition(AlwaysTrue, Ctx))
11023 bool InOverloadResolution,
11027 if (InOverloadResolution)
11029 diag::note_addrof_ovl_candidate_disabled_by_enable_if_attr);
11031 S.
Diag(
Loc, diag::err_addrof_function_disabled_by_enable_if_attr) << FD;
11042 if (InOverloadResolution) {
11045 TemplateArgString +=
" ";
11047 FunTmpl->getTemplateParameters(),
11052 diag::note_ovl_candidate_unsatisfied_constraints)
11053 << TemplateArgString;
11055 S.
Diag(
Loc, diag::err_addrof_function_constraints_not_satisfied)
11064 return P->hasAttr<PassObjectSizeAttr>();
11071 unsigned ParamNo = std::distance(FD->
param_begin(), I) + 1;
11072 if (InOverloadResolution)
11074 diag::note_ovl_candidate_has_pass_object_size_params)
11077 S.
Diag(
Loc, diag::err_address_of_function_with_pass_object_size_params)
11093 return ::checkAddressOfFunctionIsAvailable(*
this,
Function, Complain,
11101 const auto *ConvD = dyn_cast<CXXConversionDecl>(Fn);
11105 const auto *RD = cast<CXXRecordDecl>(Fn->getParent());
11106 if (!RD->isLambda())
11116 return ConvToCC != CallOpCC;
11122 QualType DestType,
bool TakingAddress) {
11125 if (Fn->isMultiVersion() && Fn->hasAttr<TargetAttr>() &&
11126 !Fn->getAttr<TargetAttr>()->isDefaultVersion())
11128 if (Fn->isMultiVersion() && Fn->hasAttr<TargetVersionAttr>() &&
11129 !Fn->getAttr<TargetVersionAttr>()->isDefaultVersion())
11134 std::string FnDesc;
11135 std::pair<OverloadCandidateKind, OverloadCandidateSelect> KSPair =
11136 ClassifyOverloadCandidate(*
this,
Found, Fn, RewriteKind, FnDesc);
11138 << (
unsigned)KSPair.first << (
unsigned)KSPair.second
11141 HandleFunctionTypeMismatch(PD, Fn->getType(), DestType);
11142 Diag(Fn->getLocation(), PD);
11143 MaybeEmitInheritedConstructorNote(*
this,
Found);
11161 FunctionDecl *FirstCand =
nullptr, *SecondCand =
nullptr;
11162 for (
auto I = Cands.begin(),
E = Cands.end(); I !=
E; ++I) {
11166 if (
auto *Template = I->Function->getPrimaryTemplate())
11167 Template->getAssociatedConstraints(AC);
11169 I->Function->getAssociatedConstraints(AC);
11172 if (FirstCand ==
nullptr) {
11173 FirstCand = I->Function;
11175 }
else if (SecondCand ==
nullptr) {
11176 SecondCand = I->Function;
11189 SecondCand, SecondAC))
11198 bool TakingAddress) {
11208 dyn_cast<FunctionTemplateDecl>((*I)->getUnderlyingDecl()) ) {
11209 NoteOverloadCandidate(*I, FunTmpl->getTemplatedDecl(),
CRK_None, DestType,
11212 = dyn_cast<FunctionDecl>((*I)->getUnderlyingDecl()) ) {
11213 NoteOverloadCandidate(*I, Fun,
CRK_None, DestType, TakingAddress);
11225 S.
Diag(CaretLoc, PDiag)
11226 << Ambiguous.getFromType() << Ambiguous.getToType();
11227 unsigned CandsShown = 0;
11229 for (I = Ambiguous.begin(),
E = Ambiguous.end(); I !=
E; ++I) {
11241 unsigned I,
bool TakingCandidateAddress) {
11243 assert(Conv.
isBad());
11244 assert(Cand->
Function &&
"for now, candidate must be a function");
11250 bool isObjectArgument =
false;
11251 if (isa<CXXMethodDecl>(Fn) && !isa<CXXConstructorDecl>(Fn)) {
11253 isObjectArgument =
true;
11254 else if (!Fn->hasCXXExplicitFunctionObjectParameter())
11258 std::string FnDesc;
11259 std::pair<OverloadCandidateKind, OverloadCandidateSelect> FnKindPair =
11270 bool HasParamPack =
11271 llvm::any_of(Fn->parameters().take_front(I), [](
const ParmVarDecl *Parm) {
11272 return Parm->isParameterPack();
11274 if (!isObjectArgument && !HasParamPack)
11275 ToParamRange = Fn->getParamDecl(I)->getSourceRange();
11278 assert(FromExpr &&
"overload set argument came from implicit argument?");
11280 if (isa<UnaryOperator>(
E))
11284 S.
Diag(Fn->getLocation(), diag::note_ovl_candidate_bad_overload)
11285 << (
unsigned)FnKindPair.first << (
unsigned)FnKindPair.second << FnDesc
11286 << ToParamRange << ToTy << Name << I + 1;
11287 MaybeEmitInheritedConstructorNote(S, Cand->
FoundDecl);
11296 CToTy = RT->getPointeeType();
11301 CFromTy = FromPT->getPointeeType();
11302 CToTy = ToPT->getPointeeType();
11312 if (isObjectArgument)
11313 S.
Diag(Fn->getLocation(), diag::note_ovl_candidate_bad_addrspace_this)
11314 << (
unsigned)FnKindPair.first << (
unsigned)FnKindPair.second
11317 S.
Diag(Fn->getLocation(), diag::note_ovl_candidate_bad_addrspace)
11318 << (
unsigned)FnKindPair.first << (
unsigned)FnKindPair.second
11321 MaybeEmitInheritedConstructorNote(S, Cand->
FoundDecl);
11326 S.
Diag(Fn->getLocation(), diag::note_ovl_candidate_bad_ownership)
11327 << (
unsigned)FnKindPair.first << (
unsigned)FnKindPair.second << FnDesc
11330 MaybeEmitInheritedConstructorNote(S, Cand->
FoundDecl);
11335 S.
Diag(Fn->getLocation(), diag::note_ovl_candidate_bad_gc)
11336 << (
unsigned)FnKindPair.first << (
unsigned)FnKindPair.second << FnDesc
11339 MaybeEmitInheritedConstructorNote(S, Cand->
FoundDecl);
11344 assert(CVR &&
"expected qualifiers mismatch");
11346 if (isObjectArgument) {
11347 S.
Diag(Fn->getLocation(), diag::note_ovl_candidate_bad_cvr_this)
11348 << (
unsigned)FnKindPair.first << (
unsigned)FnKindPair.second << FnDesc
11349 << FromTy << (CVR - 1);
11351 S.
Diag(Fn->getLocation(), diag::note_ovl_candidate_bad_cvr)
11352 << (
unsigned)FnKindPair.first << (
unsigned)FnKindPair.second << FnDesc
11353 << ToParamRange << FromTy << (CVR - 1) << I + 1;
11355 MaybeEmitInheritedConstructorNote(S, Cand->
FoundDecl);
11361 S.
Diag(Fn->getLocation(), diag::note_ovl_candidate_bad_value_category)
11362 << (
unsigned)FnKindPair.first << (
unsigned)FnKindPair.second << FnDesc
11363 << (
unsigned)isObjectArgument << I + 1
11366 MaybeEmitInheritedConstructorNote(S, Cand->
FoundDecl);
11372 if (FromExpr && isa<InitListExpr>(FromExpr)) {
11373 S.
Diag(Fn->getLocation(), diag::note_ovl_candidate_bad_list_argument)
11374 << (
unsigned)FnKindPair.first << (
unsigned)FnKindPair.second << FnDesc
11375 << ToParamRange << FromTy << ToTy << (
unsigned)isObjectArgument << I + 1
11380 MaybeEmitInheritedConstructorNote(S, Cand->
FoundDecl);
11392 S.
Diag(Fn->getLocation(), diag::note_ovl_candidate_bad_conv_incomplete)
11393 << (
unsigned)FnKindPair.first << (
unsigned)FnKindPair.second << FnDesc
11394 << ToParamRange << FromTy << ToTy << (
unsigned)isObjectArgument << I + 1
11395 << (
unsigned)(Cand->
Fix.
Kind);
11397 MaybeEmitInheritedConstructorNote(S, Cand->
FoundDecl);
11402 unsigned BaseToDerivedConversion = 0;
11405 if (ToPtrTy->getPointeeType().isAtLeastAsQualifiedAs(
11407 !FromPtrTy->getPointeeType()->isIncompleteType() &&
11408 !ToPtrTy->getPointeeType()->isIncompleteType() &&
11410 FromPtrTy->getPointeeType()))
11411 BaseToDerivedConversion = 1;
11419 if (ToPtrTy->getPointeeType().isAtLeastAsQualifiedAs(
11421 FromIface->isSuperClassOf(ToIface))
11422 BaseToDerivedConversion = 2;
11424 if (ToRefTy->getPointeeType().isAtLeastAsQualifiedAs(FromTy,
11427 !ToRefTy->getPointeeType()->isIncompleteType() &&
11429 BaseToDerivedConversion = 3;
11433 if (BaseToDerivedConversion) {
11434 S.
Diag(Fn->getLocation(), diag::note_ovl_candidate_bad_base_to_derived_conv)
11435 << (
unsigned)FnKindPair.first << (
unsigned)FnKindPair.second << FnDesc
11436 << ToParamRange << (BaseToDerivedConversion - 1) << FromTy << ToTy
11438 MaybeEmitInheritedConstructorNote(S, Cand->
FoundDecl);
11442 if (isa<ObjCObjectPointerType>(CFromTy) &&
11443 isa<PointerType>(CToTy)) {
11447 S.
Diag(Fn->getLocation(), diag::note_ovl_candidate_bad_arc_conv)
11448 << (
unsigned)FnKindPair.first << (
unsigned)FnKindPair.second << FnDesc
11449 << ToParamRange << FromTy << ToTy << (
unsigned)isObjectArgument
11451 MaybeEmitInheritedConstructorNote(S, Cand->
FoundDecl);
11461 FDiag << (
unsigned)FnKindPair.first << (
unsigned)FnKindPair.second << FnDesc
11462 << ToParamRange << FromTy << ToTy << (
unsigned)isObjectArgument << I + 1
11463 << (
unsigned)(Cand->
Fix.
Kind);
11472 S.
Diag(Fn->getLocation(), FDiag);
11474 MaybeEmitInheritedConstructorNote(S, Cand->
FoundDecl);
11481 unsigned NumArgs,
bool IsAddressOf =
false) {
11482 assert(Cand->
Function &&
"Candidate is required to be a function.");
11484 unsigned MinParams = Fn->getMinRequiredExplicitArguments() +
11485 ((IsAddressOf && !Fn->isStatic()) ? 1 : 0);
11492 if (Fn->isInvalidDecl() &&
11496 if (NumArgs < MinParams) {
11513 unsigned NumFormalArgs,
11514 bool IsAddressOf =
false) {
11515 assert(isa<FunctionDecl>(
D) &&
11516 "The templated declaration should at least be a function"
11517 " when diagnosing bad template argument deduction due to too many"
11518 " or too few arguments");
11524 unsigned MinParams = Fn->getMinRequiredExplicitArguments() +
11525 ((IsAddressOf && !Fn->isStatic()) ? 1 : 0);
11528 bool HasExplicitObjectParam =
11529 !IsAddressOf && Fn->hasCXXExplicitFunctionObjectParameter();
11531 unsigned ParamCount =
11532 Fn->getNumNonObjectParams() + ((IsAddressOf && !Fn->isStatic()) ? 1 : 0);
11533 unsigned mode, modeCount;
11535 if (NumFormalArgs < MinParams) {
11536 if (MinParams != ParamCount || FnTy->isVariadic() ||
11537 FnTy->isTemplateVariadic())
11541 modeCount = MinParams;
11543 if (MinParams != ParamCount)
11547 modeCount = ParamCount;
11550 std::string Description;
11551 std::pair<OverloadCandidateKind, OverloadCandidateSelect> FnKindPair =
11552 ClassifyOverloadCandidate(S,
Found, Fn,
CRK_None, Description);
11554 if (modeCount == 1 && !IsAddressOf &&
11555 Fn->getParamDecl(HasExplicitObjectParam ? 1 : 0)->getDeclName())
11556 S.
Diag(Fn->getLocation(), diag::note_ovl_candidate_arity_one)
11557 << (
unsigned)FnKindPair.first << (
unsigned)FnKindPair.second
11558 << Description << mode
11559 << Fn->getParamDecl(HasExplicitObjectParam ? 1 : 0) << NumFormalArgs
11560 << HasExplicitObjectParam << Fn->getParametersSourceRange();
11562 S.
Diag(Fn->getLocation(), diag::note_ovl_candidate_arity)
11563 << (
unsigned)FnKindPair.first << (
unsigned)FnKindPair.second
11564 << Description << mode << modeCount << NumFormalArgs
11565 << HasExplicitObjectParam << Fn->getParametersSourceRange();
11567 MaybeEmitInheritedConstructorNote(S,
Found);
11572 unsigned NumFormalArgs) {
11573 assert(Cand->
Function &&
"Candidate must be a function");
11583 llvm_unreachable(
"Unsupported: Getting the described template declaration"
11584 " for bad deduction diagnosis");
11591 bool TakingCandidateAddress) {
11597 switch (DeductionFailure.
getResult()) {
11600 "TemplateDeductionResult::Success while diagnosing bad deduction");
11602 llvm_unreachable(
"TemplateDeductionResult::NonDependentConversionFailure "
11603 "while diagnosing bad deduction");
11609 assert(ParamD &&
"no parameter found for incomplete deduction result");
11611 diag::note_ovl_candidate_incomplete_deduction)
11613 MaybeEmitInheritedConstructorNote(S,
Found);
11618 assert(ParamD &&
"no parameter found for incomplete deduction result");
11620 diag::note_ovl_candidate_incomplete_deduction_pack)
11624 MaybeEmitInheritedConstructorNote(S,
Found);
11629 assert(ParamD &&
"no parameter found for bad qualifiers deduction result");
11647 S.
Diag(Templated->
getLocation(), diag::note_ovl_candidate_underqualified)
11648 << ParamD->
getDeclName() << Arg << NonCanonParam;
11649 MaybeEmitInheritedConstructorNote(S,
Found);
11654 assert(ParamD &&
"no parameter found for inconsistent deduction result");
11656 if (isa<TemplateTypeParmDecl>(ParamD))
11658 else if (isa<NonTypeTemplateParmDecl>(ParamD)) {
11668 diag::note_ovl_candidate_inconsistent_deduction_types)
11671 MaybeEmitInheritedConstructorNote(S,
Found);
11691 diag::note_ovl_candidate_inconsistent_deduction)
11694 MaybeEmitInheritedConstructorNote(S,
Found);
11699 assert(ParamD &&
"no parameter found for invalid explicit arguments");
11702 diag::note_ovl_candidate_explicit_arg_mismatch_named)
11707 index = TTP->getIndex();
11709 = dyn_cast<NonTypeTemplateParmDecl>(ParamD))
11710 index = NTTP->getIndex();
11712 index = cast<TemplateTemplateParmDecl>(ParamD)->getIndex();
11714 diag::note_ovl_candidate_explicit_arg_mismatch_unnamed)
11717 MaybeEmitInheritedConstructorNote(S,
Found);
11724 TemplateArgString =
" ";
11727 if (TemplateArgString.size() == 1)
11728 TemplateArgString.clear();
11730 diag::note_ovl_candidate_unsatisfied_constraints)
11731 << TemplateArgString;
11734 static_cast<CNSInfo*
>(DeductionFailure.
Data)->Satisfaction);
11744 diag::note_ovl_candidate_instantiation_depth);
11745 MaybeEmitInheritedConstructorNote(S,
Found);
11753 TemplateArgString =
" ";
11756 if (TemplateArgString.size() == 1)
11757 TemplateArgString.clear();
11762 if (PDiag && PDiag->second.getDiagID() ==
11763 diag::err_typename_nested_not_found_enable_if) {
11766 S.
Diag(PDiag->first, diag::note_ovl_candidate_disabled_by_enable_if)
11767 <<
"'enable_if'" << TemplateArgString;
11772 if (PDiag && PDiag->second.getDiagID() ==
11773 diag::err_typename_nested_not_found_requirement) {
11775 diag::note_ovl_candidate_disabled_by_requirement)
11776 << PDiag->second.getStringArg(0) << TemplateArgString;
11786 SFINAEArgString =
": ";
11788 PDiag->second.EmitToString(S.
getDiagnostics(), SFINAEArgString);
11792 diag::note_ovl_candidate_substitution_failure)
11793 << TemplateArgString << SFINAEArgString << R;
11794 MaybeEmitInheritedConstructorNote(S,
Found);
11804 TemplateArgString =
" ";
11807 if (TemplateArgString.size() == 1)
11808 TemplateArgString.clear();
11811 S.
Diag(Templated->
getLocation(), diag::note_ovl_candidate_deduced_mismatch)
11814 << TemplateArgString
11839 diag::note_ovl_candidate_non_deduced_mismatch_qualified)
11846 if (TakingCandidateAddress && isa<FunctionDecl>(Templated) &&
11855 diag::note_ovl_candidate_non_deduced_mismatch)
11856 << FirstTA << SecondTA;
11862 S.
Diag(Templated->
getLocation(), diag::note_ovl_candidate_bad_deduction);
11863 MaybeEmitInheritedConstructorNote(S,
Found);
11867 diag::note_cuda_ovl_candidate_target_mismatch);
11875 bool TakingCandidateAddress) {
11876 assert(Cand->
Function &&
"Candidate must be a function");
11891 assert(Cand->
Function &&
"Candidate must be a Function.");
11897 std::string FnDesc;
11898 std::pair<OverloadCandidateKind, OverloadCandidateSelect> FnKindPair =
11899 ClassifyOverloadCandidate(S, Cand->
FoundDecl, Callee,
11902 S.
Diag(Callee->getLocation(), diag::note_ovl_candidate_bad_target)
11903 << (
unsigned)FnKindPair.first << (
unsigned)ocs_non_template
11905 << llvm::to_underlying(CalleeTarget) << llvm::to_underlying(CallerTarget);
11910 if (Meth !=
nullptr && Meth->
isImplicit()) {
11914 switch (FnKindPair.first) {
11917 case oc_implicit_default_constructor:
11920 case oc_implicit_copy_constructor:
11923 case oc_implicit_move_constructor:
11926 case oc_implicit_copy_assignment:
11929 case oc_implicit_move_assignment:
11934 bool ConstRHS =
false;
11938 ConstRHS = RT->getPointeeType().isConstQualified();
11949 assert(Cand->
Function &&
"Candidate must be a function");
11953 S.
Diag(Callee->getLocation(),
11954 diag::note_ovl_candidate_disabled_by_function_cond_attr)
11955 <<
Attr->getCond()->getSourceRange() <<
Attr->getMessage();
11959 assert(Cand->
Function &&
"Candidate must be a function");
11962 assert(ES.
isExplicit() &&
"not an explicit candidate");
11965 switch (Fn->getDeclKind()) {
11966 case Decl::Kind::CXXConstructor:
11969 case Decl::Kind::CXXConversion:
11972 case Decl::Kind::CXXDeductionGuide:
11973 Kind = Fn->isImplicit() ? 0 : 2;
11976 llvm_unreachable(
"invalid Decl");
11985 First = Pattern->getFirstDecl();
11988 diag::note_ovl_candidate_explicit)
11989 << Kind << (ES.
getExpr() ? 1 : 0)
11994 auto *DG = dyn_cast<CXXDeductionGuideDecl>(Fn);
12001 if (!(DG->isImplicit() || (OriginTemplate && OriginTemplate->
isTypeAlias())))
12003 std::string FunctionProto;
12004 llvm::raw_string_ostream OS(FunctionProto);
12017 "Non-template implicit deduction guides are only possible for "
12020 S.
Diag(DG->getLocation(), diag::note_implicit_deduction_guide)
12025 assert(Template &&
"Cannot find the associated function template of "
12026 "CXXDeductionGuideDecl?");
12028 Template->
print(OS);
12029 S.
Diag(DG->getLocation(), diag::note_implicit_deduction_guide)
12050 bool TakingCandidateAddress,
12052 assert(Cand->
Function &&
"Candidate must be a function");
12060 if (S.
getLangOpts().OpenCL && Fn->isImplicit() &&
12067 !Fn->hasCXXExplicitFunctionObjectParameter() && !Fn->isStatic())
12072 if (Fn->isDeleted()) {
12073 std::string FnDesc;
12074 std::pair<OverloadCandidateKind, OverloadCandidateSelect> FnKindPair =
12075 ClassifyOverloadCandidate(S, Cand->
FoundDecl, Fn,
12078 S.
Diag(Fn->getLocation(), diag::note_ovl_candidate_deleted)
12079 << (
unsigned)FnKindPair.first << (
unsigned)FnKindPair.second << FnDesc
12080 << (Fn->isDeleted() ? (Fn->isDeletedAsWritten() ? 1 : 2) : 0);
12081 MaybeEmitInheritedConstructorNote(S, Cand->
FoundDecl);
12108 TakingCandidateAddress);
12111 S.
Diag(Fn->getLocation(), diag::note_ovl_candidate_illegal_constructor)
12112 << (Fn->getPrimaryTemplate() ? 1 : 0);
12113 MaybeEmitInheritedConstructorNote(S, Cand->
FoundDecl);
12120 S.
Diag(Fn->getLocation(),
12121 diag::note_ovl_candidate_illegal_constructor_adrspace_mismatch)
12122 << QualsForPrinting;
12123 MaybeEmitInheritedConstructorNote(S, Cand->
FoundDecl);
12134 for (
unsigned N = Cand->
Conversions.size(); I != N; ++I)
12155 if (cast<CXXConstructorDecl>(Fn)->isCopyOrMoveConstructor())
12157 S.
Diag(Fn->getLocation(),
12158 diag::note_ovl_candidate_inherited_constructor_slice)
12159 << (Fn->getPrimaryTemplate() ? 1 : 0)
12160 << Fn->getParamDecl(0)->getType()->isRValueReferenceType();
12161 MaybeEmitInheritedConstructorNote(S, Cand->
FoundDecl);
12167 assert(!Available);
12175 std::string FnDesc;
12176 std::pair<OverloadCandidateKind, OverloadCandidateSelect> FnKindPair =
12177 ClassifyOverloadCandidate(S, Cand->
FoundDecl, Fn,
12180 S.
Diag(Fn->getLocation(),
12181 diag::note_ovl_candidate_constraints_not_satisfied)
12182 << (
unsigned)FnKindPair.first << (
unsigned)ocs_non_template
12200 bool isLValueReference =
false;
12201 bool isRValueReference =
false;
12202 bool isPointer =
false;
12206 isLValueReference =
true;
12210 isRValueReference =
true;
12226 diag::note_ovl_surrogate_constraints_not_satisfied)
12240 assert(Cand->
Conversions.size() <= 2 &&
"builtin operator is not binary");
12241 std::string TypeStr(
"operator");
12247 S.
Diag(OpLoc, diag::note_ovl_builtin_candidate) << TypeStr;
12252 S.
Diag(OpLoc, diag::note_ovl_builtin_candidate) << TypeStr;
12259 if (ICS.
isBad())
break;
12263 S, OpLoc, S.
PDiag(diag::note_ambiguous_type_conversion));
12280 llvm_unreachable(
"non-deduction failure while diagnosing bad deduction");
12310 llvm_unreachable(
"Unhandled deduction result");
12315struct CompareOverloadCandidatesForDisplay {
12321 CompareOverloadCandidatesForDisplay(
12324 : S(S), NumArgs(NArgs), CSK(CSK) {}
12334 if (NumArgs >
C->Function->getNumParams() && !
C->Function->isVariadic())
12336 if (NumArgs < C->
Function->getMinRequiredArguments())
12346 if (L == R)
return false;
12350 if (!R->
Viable)
return true;
12352 if (
int Ord = CompareConversions(*L, *R))
12372 if (LDist == RDist) {
12373 if (LFailureKind == RFailureKind)
12381 return LDist < RDist;
12399 numLFixes = (numLFixes == 0) ?
UINT_MAX : numLFixes;
12400 numRFixes = (numRFixes == 0) ?
UINT_MAX : numRFixes;
12401 if (numLFixes != numRFixes) {
12402 return numLFixes < numRFixes;
12406 if (
int Ord = CompareConversions(*L, *R))
12418 if (LRank != RRank)
12419 return LRank < RRank;
12445 struct ConversionSignals {
12446 unsigned KindRank = 0;
12450 ConversionSignals Sig;
12451 Sig.KindRank =
Seq.getKindRank();
12452 if (
Seq.isStandard())
12453 Sig.Rank =
Seq.Standard.getRank();
12454 else if (
Seq.isUserDefined())
12455 Sig.Rank =
Seq.UserDefined.After.getRank();
12461 static ConversionSignals ForObjectArgument() {
12477 for (
unsigned I = 0, N = L.
Conversions.size(); I != N; ++I) {
12479 ? ConversionSignals::ForObjectArgument()
12480 : ConversionSignals::ForSequence(L.Conversions[I]);
12482 ? ConversionSignals::ForObjectArgument()
12483 : ConversionSignals::ForSequence(R.Conversions[I]);
12484 if (std::tie(LS.KindRank, LS.Rank) != std::tie(RS.KindRank, RS.Rank))
12485 return std::tie(LS.KindRank, LS.Rank) < std::tie(RS.KindRank, RS.Rank)
12510 bool Unfixable =
false;
12518 assert(ConvIdx != ConvCount &&
"no bad conversion in candidate");
12519 if (Cand->
Conversions[ConvIdx].isInitialized() &&
12528 bool SuppressUserConversions =
false;
12530 unsigned ConvIdx = 0;
12531 unsigned ArgIdx = 0;
12546 if (isa<CXXMethodDecl>(Cand->
Function) &&
12559 assert(ConvCount <= 3);
12565 ConvIdx != ConvCount;
12567 assert(ArgIdx < Args.size() &&
"no argument for this arg conversion");
12568 if (Cand->
Conversions[ConvIdx].isInitialized()) {
12570 }
else if (
ParamIdx < ParamTypes.size()) {
12571 if (ParamTypes[
ParamIdx]->isDependentType())
12572 Cand->
Conversions[ConvIdx].setAsIdentityConversion(
12573 Args[ArgIdx]->getType());
12577 SuppressUserConversions,
12582 if (!Unfixable && Cand->
Conversions[ConvIdx].isBad())
12598 for (
iterator Cand =
begin(), LastCand =
end(); Cand != LastCand; ++Cand) {
12599 if (!Filter(*Cand))
12603 if (!Cand->Viable) {
12604 if (!Cand->Function && !Cand->IsSurrogate) {
12624 Cands.push_back(Cand);
12628 Cands, CompareOverloadCandidatesForDisplay(S, OpLoc, Args.size(), Kind));
12635 bool DeferHint =
false;
12639 auto WrongSidedCands =
12641 return (Cand.Viable ==
false &&
12644 Cand.Function->template hasAttr<CUDAHostAttr>() &&
12645 Cand.Function->template hasAttr<CUDADeviceAttr>());
12647 DeferHint = !WrongSidedCands.empty();
12665 bool NoteCands =
true;
12666 for (
const Expr *Arg : Args) {
12667 if (Arg->getType()->isWebAssemblyTableType())
12681 bool ReportedAmbiguousConversions =
false;
12684 unsigned CandsShown = 0;
12685 auto I = Cands.begin(),
E = Cands.end();
12686 for (; I !=
E; ++I) {
12702 "Non-viable built-in candidates are not added to Cands.");
12709 if (!ReportedAmbiguousConversions) {
12711 ReportedAmbiguousConversions =
true;
12724 S.
Diag(OpLoc, diag::note_ovl_too_many_candidates,
12736struct CompareTemplateSpecCandidatesForDisplay {
12738 CompareTemplateSpecCandidatesForDisplay(
Sema &S) : S(S) {}
12772 bool ForTakingAddress) {
12774 DeductionFailure, 0, ForTakingAddress);
12777void TemplateSpecCandidateSet::destroyCandidates() {
12779 i->DeductionFailure.Destroy();
12784 destroyCandidates();
12785 Candidates.clear();
12798 Cands.reserve(
size());
12799 for (
iterator Cand =
begin(), LastCand =
end(); Cand != LastCand; ++Cand) {
12800 if (Cand->Specialization)
12801 Cands.push_back(Cand);
12806 llvm::sort(Cands, CompareTemplateSpecCandidatesForDisplay(S));
12813 unsigned CandsShown = 0;
12814 for (I = Cands.begin(),
E = Cands.end(); I !=
E; ++I) {
12820 if (CandsShown >= 4 && ShowOverloads ==
Ovl_Best)
12825 "Non-matching built-in candidates are not added to Cands.");
12830 S.
Diag(
Loc, diag::note_ovl_too_many_candidates) <<
int(
E - I);
12840 QualType Ret = PossiblyAFunctionType;
12843 Ret = ToTypePtr->getPointeeType();
12846 Ret = ToTypeRef->getPointeeType();
12849 Ret = MemTypePtr->getPointeeType();
12856 bool Complain =
true) {
12873class AddressOfFunctionResolver {
12883 bool TargetTypeIsNonStaticMemberFunction;
12884 bool FoundNonTemplateFunction;
12885 bool StaticMemberFunctionFromBoundPointer;
12886 bool HasComplained;
12895 AddressOfFunctionResolver(
Sema &S,
Expr *SourceExpr,
12896 const QualType &TargetType,
bool Complain)
12897 : S(S), SourceExpr(SourceExpr), TargetType(TargetType),
12898 Complain(Complain), Context(S.getASTContext()),
12899 TargetTypeIsNonStaticMemberFunction(
12901 FoundNonTemplateFunction(
false),
12902 StaticMemberFunctionFromBoundPointer(
false),
12903 HasComplained(
false),
12906 FailedCandidates(OvlExpr->getNameLoc(),
true) {
12907 ExtractUnqualifiedFunctionTypeFromTargetType();
12911 if (!UME->isImplicitAccess() &&
12913 StaticMemberFunctionFromBoundPointer =
true;
12917 OvlExpr,
false, &dap)) {
12923 TargetTypeIsNonStaticMemberFunction =
true;
12931 Matches.push_back(std::make_pair(dap, Fn));
12939 if (FindAllFunctionsThatMatchTargetTypeExactly()) {
12942 if (Matches.size() > 1 && !eliminiateSuboptimalOverloadCandidates()) {
12943 if (FoundNonTemplateFunction)
12944 EliminateAllTemplateMatches();
12946 EliminateAllExceptMostSpecializedTemplate();
12951 EliminateSuboptimalCudaMatches();
12954 bool hasComplained()
const {
return HasComplained; }
12957 bool candidateHasExactlyCorrectType(
const FunctionDecl *FD) {
12969 return candidateHasExactlyCorrectType(A) &&
12970 (!candidateHasExactlyCorrectType(B) ||
12976 bool eliminiateSuboptimalOverloadCandidates() {
12979 auto Best = Matches.begin();
12980 for (
auto I = Matches.begin()+1,
E = Matches.end(); I !=
E; ++I)
12981 if (isBetterCandidate(I->second, Best->second))
12985 auto IsBestOrInferiorToBest = [
this, BestFn](
12986 const std::pair<DeclAccessPair, FunctionDecl *> &Pair) {
12987 return BestFn == Pair.second || isBetterCandidate(BestFn, Pair.second);
12992 if (!llvm::all_of(Matches, IsBestOrInferiorToBest))
12994 Matches[0] = *Best;
12999 bool isTargetTypeAFunction()
const {
13008 void inline ExtractUnqualifiedFunctionTypeFromTargetType() {
13019 bool CanConvertToFunctionPointer =
13021 if (CanConvertToFunctionPointer == TargetTypeIsNonStaticMemberFunction)
13024 else if (TargetTypeIsNonStaticMemberFunction)
13036 FunctionTemplate, &OvlExplicitTemplateArgs, TargetFunctionType,
13038 Result != TemplateDeductionResult::Success) {
13056 Matches.push_back(std::make_pair(CurAccessFunPair,
Specialization));
13060 bool AddMatchingNonTemplateFunction(
NamedDecl* Fn,
13065 bool CanConvertToFunctionPointer =
13067 if (CanConvertToFunctionPointer == TargetTypeIsNonStaticMemberFunction)
13070 else if (TargetTypeIsNonStaticMemberFunction)
13073 if (
FunctionDecl *FunDecl = dyn_cast<FunctionDecl>(Fn)) {
13080 if (FunDecl->isMultiVersion()) {
13081 const auto *TA = FunDecl->
getAttr<TargetAttr>();
13082 if (TA && !TA->isDefaultVersion())
13084 const auto *TVA = FunDecl->getAttr<TargetVersionAttr>();
13085 if (TVA && !TVA->isDefaultVersion())
13093 HasComplained |= Complain;
13102 candidateHasExactlyCorrectType(FunDecl)) {
13103 Matches.push_back(std::make_pair(
13104 CurAccessFunPair, cast<FunctionDecl>(FunDecl->getCanonicalDecl())));
13105 FoundNonTemplateFunction =
true;
13113 bool FindAllFunctionsThatMatchTargetTypeExactly() {
13118 if (IsInvalidFormOfPointerToMemberFunction())
13134 = dyn_cast<FunctionTemplateDecl>(Fn)) {
13135 if (AddMatchingTemplateFunction(FunctionTemplate, I.getPair()))
13140 AddMatchingNonTemplateFunction(Fn, I.getPair()))
13143 assert(Ret || Matches.empty());
13147 void EliminateAllExceptMostSpecializedTemplate() {
13160 for (
unsigned I = 0,
E = Matches.size(); I !=
E; ++I)
13161 MatchesCopy.
addDecl(Matches[I].second, Matches[I].first.getAccess());
13166 MatchesCopy.
begin(), MatchesCopy.
end(), FailedCandidates,
13168 S.
PDiag(diag::err_addr_ovl_ambiguous)
13169 << Matches[0].second->getDeclName(),
13170 S.
PDiag(diag::note_ovl_candidate)
13171 << (
unsigned)oc_function << (
unsigned)ocs_described_template,
13172 Complain, TargetFunctionType);
13174 if (Result != MatchesCopy.
end()) {
13176 Matches[0].first = Matches[Result - MatchesCopy.
begin()].first;
13177 Matches[0].second = cast<FunctionDecl>(*Result);
13180 HasComplained |= Complain;
13183 void EliminateAllTemplateMatches() {
13186 for (
unsigned I = 0, N = Matches.size(); I != N; ) {
13187 if (Matches[I].second->getPrimaryTemplate() ==
nullptr)
13190 Matches[I] = Matches[--N];
13196 void EliminateSuboptimalCudaMatches() {
13202 void ComplainNoMatchesFound()
const {
13203 assert(Matches.empty());
13205 << OvlExpr->
getName() << TargetFunctionType
13207 if (FailedCandidates.
empty())
13218 dyn_cast<FunctionDecl>((*I)->getUnderlyingDecl()))
13226 bool IsInvalidFormOfPointerToMemberFunction()
const {
13227 return TargetTypeIsNonStaticMemberFunction &&
13231 void ComplainIsInvalidFormOfPointerToMemberFunction()
const {
13239 bool IsStaticMemberFunctionFromBoundPointer()
const {
13240 return StaticMemberFunctionFromBoundPointer;
13243 void ComplainIsStaticMemberFunctionFromBoundPointer()
const {
13245 diag::err_invalid_form_pointer_member_function)
13249 void ComplainOfInvalidConversion()
const {
13251 << OvlExpr->
getName() << TargetType;
13254 void ComplainMultipleMatchesFound()
const {
13255 assert(Matches.size() > 1);
13262 bool hadMultipleCandidates()
const {
return (OvlExpr->
getNumDecls() > 1); }
13264 int getNumMatches()
const {
return Matches.size(); }
13267 if (Matches.size() != 1)
return nullptr;
13268 return Matches[0].second;
13272 if (Matches.size() != 1)
return nullptr;
13273 return &Matches[0].first;
13283 bool *pHadMultipleCandidates) {
13286 AddressOfFunctionResolver Resolver(*
this, AddressOfExpr, TargetType,
13288 int NumMatches = Resolver.getNumMatches();
13290 bool ShouldComplain = Complain && !Resolver.hasComplained();
13291 if (NumMatches == 0 && ShouldComplain) {
13292 if (Resolver.IsInvalidFormOfPointerToMemberFunction())
13293 Resolver.ComplainIsInvalidFormOfPointerToMemberFunction();
13295 Resolver.ComplainNoMatchesFound();
13297 else if (NumMatches > 1 && ShouldComplain)
13298 Resolver.ComplainMultipleMatchesFound();
13299 else if (NumMatches == 1) {
13300 Fn = Resolver.getMatchingFunctionDecl();
13303 ResolveExceptionSpec(AddressOfExpr->
getExprLoc(), FPT);
13304 FoundResult = *Resolver.getMatchingFunctionAccessPair();
13306 if (Resolver.IsStaticMemberFunctionFromBoundPointer())
13307 Resolver.ComplainIsStaticMemberFunctionFromBoundPointer();
13309 CheckAddressOfMemberAccess(AddressOfExpr, FoundResult);
13313 if (pHadMultipleCandidates)
13314 *pHadMultipleCandidates = Resolver.hadMultipleCandidates();
13322 bool IsResultAmbiguous =
false;
13330 return static_cast<int>(
CUDA().IdentifyPreference(Caller, FD1)) -
13331 static_cast<int>(
CUDA().IdentifyPreference(Caller, FD2));
13338 auto *FD = dyn_cast<FunctionDecl>(I->getUnderlyingDecl());
13346 auto FoundBetter = [&]() {
13347 IsResultAmbiguous =
false;
13358 if (getLangOpts().CUDA) {
13359 int PreferenceByCUDA = CheckCUDAPreference(FD,
Result);
13361 if (PreferenceByCUDA != 0) {
13363 if (PreferenceByCUDA > 0)
13371 if (MoreConstrained != FD) {
13372 if (!MoreConstrained) {
13373 IsResultAmbiguous =
true;
13374 AmbiguousDecls.push_back(FD);
13383 if (IsResultAmbiguous)
13394 if (getLangOpts().
CUDA && CheckCUDAPreference(Skipped,
Result) != 0)
13396 if (!getMoreConstrainedFunction(Skipped,
Result))
13405 ExprResult &SrcExpr,
bool DoFunctionPointerConversion) {
13411 if (!
Found ||
Found->isCPUDispatchMultiVersion() ||
13412 Found->isCPUSpecificMultiVersion())
13419 CheckAddressOfMemberAccess(
E, DAP);
13425 SrcExpr = DefaultFunctionArrayConversion(Fixed,
false);
13460 = cast<FunctionTemplateDecl>((*I)->getUnderlyingDecl());
13489 NoteAllOverloadCandidates(ovl);
13495 if (FoundResult) *FoundResult = I.getPair();
13506 ExprResult &SrcExpr,
bool doFunctionPointerConversion,
bool complain,
13508 unsigned DiagIDForComplaining) {
13515 if (
FunctionDecl *fn = ResolveSingleFunctionTemplateSpecialization(
13527 isa<CXXMethodDecl>(fn) &&
13528 cast<CXXMethodDecl>(fn)->isInstance()) {
13529 if (!complain)
return false;
13532 diag::err_bound_member_function)
13545 SingleFunctionExpression =
13546 FixOverloadedFunctionReference(SrcExpr.
get(), found, fn);
13549 if (doFunctionPointerConversion) {
13550 SingleFunctionExpression =
13551 DefaultFunctionArrayLvalueConversion(SingleFunctionExpression.
get());
13552 if (SingleFunctionExpression.
isInvalid()) {
13559 if (!SingleFunctionExpression.
isUsable()) {
13561 Diag(OpRangeForComplaining.
getBegin(), DiagIDForComplaining)
13563 << DestTypeForComplaining
13564 << OpRangeForComplaining
13566 NoteAllOverloadCandidates(SrcExpr.
get());
13575 SrcExpr = SingleFunctionExpression;
13585 bool PartialOverloading,
13587 NamedDecl *Callee = FoundDecl.getDecl();
13588 if (isa<UsingShadowDecl>(Callee))
13589 Callee = cast<UsingShadowDecl>(Callee)->getTargetDecl();
13592 if (ExplicitTemplateArgs) {
13593 assert(!KnownValid &&
"Explicit template arguments?");
13602 PartialOverloading);
13607 = dyn_cast<FunctionTemplateDecl>(Callee)) {
13609 ExplicitTemplateArgs, Args, CandidateSet,
13611 PartialOverloading);
13615 assert(!KnownValid &&
"unhandled case in overloaded call candidate");
13621 bool PartialOverloading) {
13644 assert(!(*I)->getDeclContext()->isRecord());
13645 assert(isa<UsingShadowDecl>(*I) ||
13646 !(*I)->getDeclContext()->isFunctionOrMethod());
13647 assert((*I)->getUnderlyingDecl()->isFunctionOrFunctionTemplate());
13657 ExplicitTemplateArgs = &TABuffer;
13663 CandidateSet, PartialOverloading,
13668 Args, ExplicitTemplateArgs,
13669 CandidateSet, PartialOverloading);
13677 CandidateSet,
false,
false);
13683 switch (Name.getCXXOverloadedOperator()) {
13684 case OO_New:
case OO_Array_New:
13685 case OO_Delete:
case OO_Array_Delete:
13708 if (DC->isTransparentContext())
13724 if (
auto *RD = dyn_cast<CXXRecordDecl>(DC)) {
13729 if (FoundInClass) {
13730 *FoundInClass = RD;
13733 R.
addDecl(Best->FoundDecl.getDecl(), Best->FoundDecl.getAccess());
13750 AssociatedNamespaces,
13751 AssociatedClasses);
13755 for (Sema::AssociatedNamespaceSet::iterator
13756 it = AssociatedNamespaces.begin(),
13757 end = AssociatedNamespaces.end(); it !=
end; ++it) {
13759 if (
Std &&
Std->Encloses(*it))
13769 SuggestedNamespaces.insert(*it);
13773 SemaRef.
Diag(R.
getNameLoc(), diag::err_not_found_by_two_phase_lookup)
13775 if (SuggestedNamespaces.empty()) {
13776 SemaRef.
Diag(Best->Function->getLocation(),
13777 diag::note_not_found_by_two_phase_lookup)
13779 }
else if (SuggestedNamespaces.size() == 1) {
13780 SemaRef.
Diag(Best->Function->getLocation(),
13781 diag::note_not_found_by_two_phase_lookup)
13787 SemaRef.
Diag(Best->Function->getLocation(),
13788 diag::note_not_found_by_two_phase_lookup)
13820class BuildRecoveryCallExprRAII {
13825 BuildRecoveryCallExprRAII(
Sema &S) : SemaRef(S), SatStack(S) {
13847 bool EmptyLookup,
bool AllowTypoCorrection) {
13855 BuildRecoveryCallExprRAII RCE(SemaRef);
13865 ExplicitTemplateArgs = &TABuffer;
13873 ExplicitTemplateArgs, Args, &FoundInClass)) {
13875 }
else if (EmptyLookup) {
13880 ExplicitTemplateArgs !=
nullptr,
13881 dyn_cast<MemberExpr>(Fn));
13883 AllowTypoCorrection
13889 }
else if (FoundInClass && SemaRef.
getLangOpts().MSVCCompat) {
13904 assert(!R.
empty() &&
"lookup results empty despite recovery");
13915 if ((*R.
begin())->isCXXClassMember())
13917 ExplicitTemplateArgs, S);
13918 else if (ExplicitTemplateArgs || TemplateKWLoc.
isValid())
13920 ExplicitTemplateArgs);
13944 assert(!ULE->
getQualifier() &&
"qualified name with ADL");
13951 (F = dyn_cast<FunctionDecl>(*ULE->
decls_begin())) &&
13953 llvm_unreachable(
"performing ADL for builtin");
13956 assert(getLangOpts().
CPlusPlus &&
"ADL enabled in C");
13960 UnbridgedCastsSet UnbridgedCasts;
13968 AddOverloadedCallCandidates(ULE, Args, *CandidateSet);
13970 if (getLangOpts().MSVCCompat &&
13971 CurContext->isDependentContext() && !isSFINAEContext() &&
13972 (isa<FunctionDecl>(CurContext) || isa<CXXRecordDecl>(CurContext))) {
13975 if (CandidateSet->
empty() ||
13984 RParenLoc, CurFPFeatureOverrides());
13991 if (CandidateSet->
empty())
13994 UnbridgedCasts.restore();
14001 std::optional<QualType>
Result;
14004 if (!Candidate.Function)
14006 if (Candidate.Function->isInvalidDecl())
14008 QualType T = Candidate.Function->getReturnType();
14021 if (Best && *Best != CS.
end())
14022 ConsiderCandidate(**Best);
14025 for (
const auto &
C : CS)
14027 ConsiderCandidate(
C);
14030 for (
const auto &
C : CS)
14031 ConsiderCandidate(
C);
14036 if (
Value.isNull() ||
Value->isUndeducedType())
14053 bool AllowTypoCorrection) {
14054 switch (OverloadResult) {
14065 Res.
get(), FDecl, LParenLoc, Args, RParenLoc, ExecConfig,
14066 false, (*Best)->IsADLCandidate);
14070 if (*Best != CandidateSet->
end() &&
14074 dyn_cast_if_present<CXXMethodDecl>((*Best)->Function);
14079 SemaRef.
PDiag(diag::err_member_call_without_object) << 0 << M),
14089 CandidateSet->
empty(),
14090 AllowTypoCorrection);
14097 for (
const Expr *Arg : Args) {
14098 if (!Arg->getType()->isFunctionType())
14100 if (
auto *DRE = dyn_cast<DeclRefExpr>(Arg->IgnoreParenImpCasts())) {
14101 auto *FD = dyn_cast<FunctionDecl>(DRE->getDecl());
14104 Arg->getExprLoc()))
14112 SemaRef.
PDiag(diag::err_ovl_no_viable_function_in_call)
14113 << ULE->
getName() << Fn->getSourceRange()),
14121 SemaRef.
PDiag(diag::err_ovl_ambiguous_call)
14122 << ULE->
getName() << Fn->getSourceRange()),
14129 Fn->getSourceRange(), ULE->
getName(),
14130 *CandidateSet, FDecl, Args);
14139 Res.
get(), FDecl, LParenLoc, Args, RParenLoc, ExecConfig,
14140 false, (*Best)->IsADLCandidate);
14146 SubExprs.append(Args.begin(), Args.end());
14153 for (
auto I = CS.
begin(),
E = CS.
end(); I !=
E; ++I) {
14168 bool AllowTypoCorrection,
14169 bool CalleesAddressIsTaken) {
14171 Fn->getExprLoc(), CalleesAddressIsTaken
14176 if (buildOverloadedCallSet(S, Fn, ULE, Args, LParenLoc, &CandidateSet,
14182 if (CalleesAddressIsTaken)
14196 if (
const auto *TP =
14200 VK_PRValue, RParenLoc, CurFPFeatureOverrides());
14206 ExecConfig, &CandidateSet, &Best,
14207 OverloadResult, AllowTypoCorrection);
14216 Context, NamingClass, NNSLoc, DNI, PerformADL, Fns.
begin(), Fns.
end(),
14222 bool HadMultipleCandidates) {
14227 Exp = InitializeExplicitObjectArgument(*
this,
E, Method);
14229 Exp = PerformImplicitObjectArgumentInitialization(
E,
nullptr,
14230 FoundDecl, Method);
14239 auto *CE = dyn_cast<CastExpr>(SubE);
14240 if (CE && CE->getCastKind() == CK_NoOp)
14241 SubE = CE->getSubExpr();
14243 if (
auto *BE = dyn_cast<CXXBindTemporaryExpr>(SubE))
14244 SubE = BE->getSubExpr();
14245 if (isa<LambdaExpr>(SubE)) {
14251 PushExpressionEvaluationContext(
14252 ExpressionEvaluationContext::PotentiallyEvaluated);
14253 ExprResult BlockExp = BuildBlockForLambdaConversion(
14255 PopExpressionEvaluationContext();
14273 Expr *ObjectParam = Exp.
get();
14276 CurFPFeatureOverrides());
14286 Exp.
get()->getEndLoc(),
14287 CurFPFeatureOverrides());
14290 if (CheckFunctionCall(Method, CE,
14300 Expr *Input,
bool PerformADL) {
14302 assert(Op !=
OO_None &&
"Invalid opcode for overloaded unary operator");
14310 Expr *Args[2] = { Input,
nullptr };
14311 unsigned NumArgs = 1;
14316 if (Opc == UO_PostInc || Opc == UO_PostDec) {
14330 if (Opc == UO_PreDec || Opc == UO_PreInc || Opc == UO_Deref)
14336 CurFPFeatureOverrides());
14341 if (Fn.isInvalid())
14345 CurFPFeatureOverrides());
14352 AddNonMemberOperatorCandidates(Fns, ArgsArray, CandidateSet);
14355 AddMemberOperatorCandidates(Op, OpLoc, ArgsArray, CandidateSet);
14359 AddArgumentDependentLookupCandidates(OpName, OpLoc, ArgsArray,
14365 AddBuiltinOperatorCandidates(Op, OpLoc, ArgsArray, CandidateSet);
14367 bool HadMultipleCandidates = (CandidateSet.
size() > 1);
14382 if (
CXXMethodDecl *Method = dyn_cast<CXXMethodDecl>(FnDecl)) {
14383 CheckMemberOperatorAccess(OpLoc, Input,
nullptr, Best->FoundDecl);
14387 InputInit = InitializeExplicitObjectArgument(*
this, Input, Method);
14389 InputInit = PerformImplicitObjectArgumentInitialization(
14390 Input,
nullptr, Best->FoundDecl, Method);
14393 Base = Input = InputInit.
get();
14404 Input = InputInit.
get();
14409 Base, HadMultipleCandidates,
14421 Context, Op, FnExpr.
get(), ArgsArray, ResultTy, VK, OpLoc,
14422 CurFPFeatureOverrides(), Best->IsADLCandidate);
14424 if (CheckCallReturnType(FnDecl->
getReturnType(), OpLoc, TheCall, FnDecl))
14427 if (CheckFunctionCall(FnDecl, TheCall,
14430 return CheckForImmediateInvocation(MaybeBindToTemporary(TheCall), FnDecl);
14435 ExprResult InputRes = PerformImplicitConversion(
14436 Input, Best->BuiltinParamTypes[0], Best->Conversions[0],
14441 Input = InputRes.
get();
14461 PDiag(diag::err_ovl_ambiguous_oper_unary)
14478 << (Msg !=
nullptr)
14479 << (Msg ? Msg->
getString() : StringRef())
14490 return CreateBuiltinUnaryOp(OpLoc, Opc, Input);
14506 AddNonMemberOperatorCandidates(Fns, Args, CandidateSet);
14509 AddMemberOperatorCandidates(Op, OpLoc, Args, CandidateSet);
14511 AddMemberOperatorCandidates(Op, OpLoc, {Args[1], Args[0]}, CandidateSet,
14516 AddMemberOperatorCandidates(ExtraOp, OpLoc, Args, CandidateSet);
14518 AddMemberOperatorCandidates(ExtraOp, OpLoc, {Args[1], Args[0]},
14526 if (Op != OO_Equal && PerformADL) {
14528 AddArgumentDependentLookupCandidates(OpName, OpLoc, Args,
14534 AddArgumentDependentLookupCandidates(ExtraOpName, OpLoc, Args,
14553 AddBuiltinOperatorCandidates(Op, OpLoc, Args, CandidateSet);
14559 Expr *RHS,
bool PerformADL,
14560 bool AllowRewrittenCandidates,
14562 Expr *Args[2] = { LHS, RHS };
14566 AllowRewrittenCandidates =
false;
14572 if (Args[0]->isTypeDependent() || Args[1]->isTypeDependent()) {
14593 if (Fn.isInvalid())
14597 CurFPFeatureOverrides());
14602 if (Opc == BO_PtrMemD) {
14603 auto CheckPlaceholder = [&](
Expr *&Arg) {
14612 if (CheckPlaceholder(Args[0]) || CheckPlaceholder(Args[1]))
14614 return CreateBuiltinBinOp(OpLoc, Opc, Args[0], Args[1]);
14633 if (Opc == BO_Assign && !Args[0]->getType()->isOverloadableType())
14634 return CreateBuiltinBinOp(OpLoc, Opc, Args[0], Args[1]);
14639 Op, OpLoc, AllowRewrittenCandidates));
14641 CandidateSet.
exclude(DefaultedFn);
14642 LookupOverloadedBinOp(CandidateSet, Op, Fns, Args, PerformADL);
14644 bool HadMultipleCandidates = (CandidateSet.
size() > 1);
14653 bool IsReversed = Best->isReversed();
14655 std::swap(Args[0], Args[1]);
14672 if (Best->RewriteKind && ChosenOp == OO_EqualEqual &&
14676 Diag(OpLoc, IsExtension ? diag::ext_ovl_rewrite_equalequal_not_bool
14677 : diag::err_ovl_rewrite_equalequal_not_bool)
14685 if (AllowRewrittenCandidates && !IsReversed &&
14693 if (Cand.Viable && Cand.Function && Cand.isReversed() &&
14695 for (
unsigned ArgIdx = 0; ArgIdx < 2; ++ArgIdx) {
14697 *
this, OpLoc, Cand.Conversions[ArgIdx],
14698 Best->Conversions[ArgIdx]) ==
14700 AmbiguousWith.push_back(Cand.Function);
14707 if (!AmbiguousWith.empty()) {
14708 bool AmbiguousWithSelf =
14709 AmbiguousWith.size() == 1 &&
14711 Diag(OpLoc, diag::ext_ovl_ambiguous_oper_binary_reversed)
14713 << Args[0]->
getType() << Args[1]->
getType() << AmbiguousWithSelf
14715 if (AmbiguousWithSelf) {
14717 diag::note_ovl_ambiguous_oper_binary_reversed_self);
14722 if (
auto *MD = dyn_cast<CXXMethodDecl>(FnDecl))
14723 if (Op == OverloadedOperatorKind::OO_EqualEqual &&
14725 !MD->hasCXXExplicitFunctionObjectParameter() &&
14727 MD->getFunctionObjectParameterType(),
14728 MD->getParamDecl(0)->getType().getNonReferenceType()) &&
14730 MD->getFunctionObjectParameterType(),
14733 MD->getFunctionObjectParameterType(),
14736 diag::note_ovl_ambiguous_eqeq_reversed_self_non_const);
14739 diag::note_ovl_ambiguous_oper_binary_selected_candidate);
14740 for (
auto *F : AmbiguousWith)
14741 Diag(F->getLocation(),
14742 diag::note_ovl_ambiguous_oper_binary_reversed_candidate);
14750 if (Op == OO_Equal)
14751 diagnoseNullableToNonnullConversion(Args[0]->getType(),
14752 Args[1]->getType(), OpLoc);
14755 if (
CXXMethodDecl *Method = dyn_cast<CXXMethodDecl>(FnDecl)) {
14757 CheckMemberOperatorAccess(OpLoc, Args[0], Args[1], Best->FoundDecl);
14762 Arg0 = InitializeExplicitObjectArgument(*
this, Args[0], FnDecl);
14765 Arg0 = PerformImplicitObjectArgumentInitialization(
14766 Args[0],
nullptr, Best->FoundDecl, Method);
14768 Arg1 = PerformCopyInitialization(
14779 ExprResult Arg0 = PerformCopyInitialization(
14787 PerformCopyInitialization(
14799 Best->FoundDecl,
Base,
14800 HadMultipleCandidates, OpLoc);
14811 const Expr *ImplicitThis =
nullptr;
14816 Context, ChosenOp, FnExpr.
get(), Args, ResultTy, VK, OpLoc,
14817 CurFPFeatureOverrides(), Best->IsADLCandidate);
14819 if (
const auto *Method = dyn_cast<CXXMethodDecl>(FnDecl);
14822 ImplicitThis = ArgsArray[0];
14823 ArgsArray = ArgsArray.slice(1);
14826 if (CheckCallReturnType(FnDecl->
getReturnType(), OpLoc, TheCall,
14830 if (Op == OO_Equal) {
14832 DiagnoseSelfMove(Args[0], Args[1], OpLoc);
14835 *
this,
AssignedEntity{Args[0], dyn_cast<CXXMethodDecl>(FnDecl)},
14838 if (ImplicitThis) {
14841 cast<CXXMethodDecl>(FnDecl)->getFunctionObjectParameterType());
14843 CheckArgAlignment(OpLoc, FnDecl,
"'this'", ThisType,
14847 checkCall(FnDecl,
nullptr, ImplicitThis, ArgsArray,
14849 VariadicDoesNotApply);
14851 ExprResult R = MaybeBindToTemporary(TheCall);
14855 R = CheckForImmediateInvocation(R, FnDecl);
14862 (Op == OO_Spaceship && IsReversed)) {
14863 if (Op == OO_ExclaimEqual) {
14864 assert(ChosenOp == OO_EqualEqual &&
"unexpected operator name");
14865 R = CreateBuiltinUnaryOp(OpLoc, UO_LNot, R.
get());
14867 assert(ChosenOp == OO_Spaceship &&
"unexpected operator name");
14869 Expr *ZeroLiteral =
14875 pushCodeSynthesisContext(Ctx);
14877 R = CreateOverloadedBinOp(
14878 OpLoc, Opc, Fns, IsReversed ? ZeroLiteral : R.
get(),
14879 IsReversed ? R.
get() : ZeroLiteral,
true,
14882 popCodeSynthesisContext();
14887 assert(ChosenOp == Op &&
"unexpected operator name");
14891 if (Best->RewriteKind !=
CRK_None)
14899 ExprResult ArgsRes0 = PerformImplicitConversion(
14900 Args[0], Best->BuiltinParamTypes[0], Best->Conversions[0],
14905 Args[0] = ArgsRes0.
get();
14907 ExprResult ArgsRes1 = PerformImplicitConversion(
14908 Args[1], Best->BuiltinParamTypes[1], Best->Conversions[1],
14913 Args[1] = ArgsRes1.
get();
14923 if (Opc == BO_Comma)
14928 if (DefaultedFn && Opc == BO_Cmp) {
14929 ExprResult E = BuildSynthesizedThreeWayComparison(OpLoc, Fns, Args[0],
14930 Args[1], DefaultedFn);
14931 if (
E.isInvalid() ||
E.isUsable())
14945 Opc >= BO_Assign && Opc <= BO_OrAssign) {
14946 Diag(OpLoc, diag::err_ovl_no_viable_oper)
14949 if (Args[0]->getType()->isIncompleteType()) {
14950 Diag(OpLoc, diag::note_assign_lhs_incomplete)
14964 Result = CreateBuiltinBinOp(OpLoc, Opc, Args[0], Args[1]);
14966 assert(
Result.isInvalid() &&
14967 "C++ binary operator overloading is missing candidates!");
14976 << Args[0]->getType()
14977 << Args[1]->getType()
14978 << Args[0]->getSourceRange()
14979 << Args[1]->getSourceRange()),
14985 if (isImplicitlyDeleted(Best->Function)) {
14989 Diag(OpLoc, diag::err_ovl_deleted_special_oper)
14994 Diag(OpLoc, diag::err_ovl_deleted_comparison)
14995 << Args[0]->
getType() << DeletedFD;
15000 NoteDeletedFunction(DeletedFD);
15008 PDiag(diag::err_ovl_deleted_oper)
15010 .getCXXOverloadedOperator())
15011 << (Msg !=
nullptr) << (Msg ? Msg->
getString() : StringRef())
15012 << Args[0]->getSourceRange() << Args[1]->getSourceRange()),
15020 return CreateBuiltinBinOp(OpLoc, Opc, Args[0], Args[1]);
15036 "cannot use prvalue expressions more than once");
15037 Expr *OrigLHS = LHS;
15038 Expr *OrigRHS = RHS;
15042 LHS =
new (Context)
15045 RHS =
new (Context)
15049 ExprResult Eq = CreateOverloadedBinOp(OpLoc, BO_EQ, Fns, LHS, RHS,
true,
true,
15051 if (
Eq.isInvalid())
15054 ExprResult Less = CreateOverloadedBinOp(OpLoc, BO_LT, Fns, LHS, RHS,
true,
15055 true, DefaultedFn);
15056 if (
Less.isInvalid())
15061 Greater = CreateOverloadedBinOp(OpLoc, BO_LT, Fns, RHS, LHS,
true,
true,
15068 struct Comparison {
15083 for (; I >= 0; --I) {
15085 auto *VI = Info->lookupValueInfo(Comparisons[I].
Result);
15096 Result = ActOnConditionalOp(OpLoc, OpLoc, Comparisons[I].Cmp.get(),
15108 Context, OrigLHS, OrigRHS, BO_Cmp,
Result.get()->getType(),
15109 Result.get()->getValueKind(),
Result.get()->getObjectKind(), OpLoc,
15110 CurFPFeatureOverrides());
15111 Expr *SemanticForm[] = {LHS, RHS,
Result.get()};
15121 unsigned NumArgsSlots =
15122 MethodArgs.size() + std::max<unsigned>(Args.size(), NumParams);
15125 MethodArgs.reserve(MethodArgs.size() + NumArgsSlots);
15126 bool IsError =
false;
15129 for (
unsigned i = 0; i != NumParams; i++) {
15131 if (i < Args.size()) {
15149 MethodArgs.push_back(Arg);
15159 Args.push_back(
Base);
15160 for (
auto *e : ArgExpr) {
15169 ArgExpr.back()->getEndLoc());
15181 if (Fn.isInvalid())
15187 CurFPFeatureOverrides());
15191 UnbridgedCastsSet UnbridgedCasts;
15201 AddMemberOperatorCandidates(OO_Subscript, LLoc, Args, CandidateSet);
15204 if (Args.size() == 2)
15205 AddBuiltinOperatorCandidates(OO_Subscript, LLoc, Args, CandidateSet);
15207 bool HadMultipleCandidates = (CandidateSet.
size() > 1);
15220 CheckMemberOperatorAccess(LLoc, Args[0], ArgExpr, Best->FoundDecl);
15229 InitializeExplicitObjectArgument(*
this, Args[0], Method);
15232 Args[0] = Res.
get();
15235 ExprResult Arg0 = PerformImplicitObjectArgumentInitialization(
15236 Args[0],
nullptr, Best->FoundDecl, Method);
15240 MethodArgs.push_back(Arg0.
get());
15244 *
this, MethodArgs, Method, ArgExpr, LLoc);
15252 *
this, FnDecl, Best->FoundDecl,
Base, HadMultipleCandidates,
15263 Context, OO_Subscript, FnExpr.
get(), MethodArgs, ResultTy, VK, RLoc,
15264 CurFPFeatureOverrides());
15266 if (CheckCallReturnType(FnDecl->
getReturnType(), LLoc, TheCall, FnDecl))
15269 if (CheckFunctionCall(Method, TheCall,
15273 return CheckForImmediateInvocation(MaybeBindToTemporary(TheCall),
15279 ExprResult ArgsRes0 = PerformImplicitConversion(
15280 Args[0], Best->BuiltinParamTypes[0], Best->Conversions[0],
15285 Args[0] = ArgsRes0.
get();
15287 ExprResult ArgsRes1 = PerformImplicitConversion(
15288 Args[1], Best->BuiltinParamTypes[1], Best->Conversions[1],
15293 Args[1] = ArgsRes1.
get();
15301 CandidateSet.
empty()
15302 ? (PDiag(diag::err_ovl_no_oper)
15303 << Args[0]->getType() << 0
15304 << Args[0]->getSourceRange() <<
Range)
15305 : (PDiag(diag::err_ovl_no_viable_subscript)
15306 << Args[0]->getType() << Args[0]->getSourceRange() <<
Range);
15313 if (Args.size() == 2) {
15316 LLoc, PDiag(diag::err_ovl_ambiguous_oper_binary)
15317 <<
"[]" << Args[0]->getType() << Args[1]->getType()
15318 << Args[0]->getSourceRange() <<
Range),
15323 PDiag(diag::err_ovl_ambiguous_subscript_call)
15324 << Args[0]->getType()
15325 << Args[0]->getSourceRange() <<
Range),
15334 PDiag(diag::err_ovl_deleted_oper)
15335 <<
"[]" << (Msg !=
nullptr)
15336 << (Msg ? Msg->
getString() : StringRef())
15337 << Args[0]->getSourceRange() <<
Range),
15344 return CreateBuiltinArraySubscriptExpr(Args[0], LLoc, Args[1], RLoc);
15351 Expr *ExecConfig,
bool IsExecConfig,
15352 bool AllowRecovery) {
15361 if (
BinaryOperator *op = dyn_cast<BinaryOperator>(NakedMemExpr)) {
15363 assert(op->getOpcode() == BO_PtrMemD || op->getOpcode() == BO_PtrMemI);
15376 QualType objectType = op->getLHS()->getType();
15377 if (op->getOpcode() == BO_PtrMemI)
15381 Qualifiers difference = objectQuals - funcQuals;
15385 std::string qualsString = difference.
getAsString();
15386 Diag(LParenLoc, diag::err_pointer_to_member_call_drops_quals)
15389 << (qualsString.find(
' ') == std::string::npos ? 1 : 2);
15393 Context, MemExprE, Args, resultType, valueKind, RParenLoc,
15396 if (CheckCallReturnType(proto->
getReturnType(), op->getRHS()->getBeginLoc(),
15400 if (ConvertArgumentsForCall(call, op,
nullptr, proto, Args, RParenLoc))
15403 if (CheckOtherCall(call, proto))
15406 return MaybeBindToTemporary(call);
15413 if (!AllowRecovery)
15415 std::vector<Expr *> SubExprs = {MemExprE};
15416 llvm::append_range(SubExprs, Args);
15417 return CreateRecoveryExpr(MemExprE->
getBeginLoc(), RParenLoc, SubExprs,
15420 if (isa<CXXPseudoDestructorExpr>(NakedMemExpr))
15422 RParenLoc, CurFPFeatureOverrides());
15424 UnbridgedCastsSet UnbridgedCasts;
15430 bool HadMultipleCandidates =
false;
15433 if (isa<MemberExpr>(NakedMemExpr)) {
15434 MemExpr = cast<MemberExpr>(NakedMemExpr);
15438 UnbridgedCasts.restore();
15456 TemplateArgs = &TemplateArgsBuffer;
15462 QualType ExplicitObjectType = ObjectType;
15466 if (isa<UsingShadowDecl>(
Func))
15467 Func = cast<UsingShadowDecl>(
Func)->getTargetDecl();
15469 bool HasExplicitParameter =
false;
15470 if (
const auto *M = dyn_cast<FunctionDecl>(
Func);
15471 M && M->hasCXXExplicitFunctionObjectParameter())
15472 HasExplicitParameter =
true;
15473 else if (
const auto *M = dyn_cast<FunctionTemplateDecl>(
Func);
15475 M->getTemplatedDecl()->hasCXXExplicitFunctionObjectParameter())
15476 HasExplicitParameter =
true;
15478 if (HasExplicitParameter)
15482 if (getLangOpts().MicrosoftExt && isa<CXXConstructorDecl>(
Func)) {
15483 AddOverloadCandidate(cast<CXXConstructorDecl>(
Func), I.getPair(), Args,
15486 }
else if ((Method = dyn_cast<CXXMethodDecl>(
Func))) {
15492 AddMethodCandidate(Method, I.getPair(), ActingDC, ExplicitObjectType,
15493 ObjectClassification, Args, CandidateSet,
15496 AddMethodTemplateCandidate(cast<FunctionTemplateDecl>(
Func),
15497 I.getPair(), ActingDC, TemplateArgs,
15498 ExplicitObjectType, ObjectClassification,
15499 Args, CandidateSet,
15504 HadMultipleCandidates = (CandidateSet.
size() > 1);
15508 UnbridgedCasts.restore();
15511 bool Succeeded =
false;
15515 Method = cast<CXXMethodDecl>(Best->Function);
15516 FoundDecl = Best->FoundDecl;
15517 CheckUnresolvedMemberAccess(UnresExpr, Best->FoundDecl);
15518 if (DiagnoseUseOfOverloadedDecl(Best->FoundDecl, UnresExpr->
getNameLoc()))
15526 if (Method != FoundDecl.getDecl() &&
15527 DiagnoseUseOfOverloadedDecl(Method, UnresExpr->
getNameLoc()))
15536 PDiag(diag::err_ovl_no_viable_member_function_in_call)
15543 PDiag(diag::err_ovl_ambiguous_member_call)
15548 DiagnoseUseOfDeletedFunction(
15550 CandidateSet, Best->Function, Args,
true);
15558 FixOverloadedFunctionReference(MemExprE, FoundDecl, Method);
15561 MemExprE = Res.
get();
15566 return BuildResolvedCallExpr(MemExprE, Method, LParenLoc, Args, RParenLoc,
15567 ExecConfig, IsExecConfig);
15577 assert(Method &&
"Member call to something that isn't a method?");
15590 HadMultipleCandidates, MemExpr->
getExprLoc());
15596 CurFPFeatureOverrides(), Proto->getNumParams());
15599 ExprResult ObjectArg = PerformImplicitObjectArgumentInitialization(
15600 MemExpr->
getBase(), Qualifier, FoundDecl, Method);
15605 RParenLoc, CurFPFeatureOverrides(),
15606 Proto->getNumParams());
15612 return BuildRecoveryExpr(ResultType);
15615 if (ConvertArgumentsForCall(TheCall, MemExpr, Method, Proto, Args,
15617 return BuildRecoveryExpr(ResultType);
15619 DiagnoseSentinelCalls(Method, LParenLoc, Args);
15621 if (CheckFunctionCall(Method, TheCall, Proto))
15627 if (
auto *MemE = dyn_cast<MemberExpr>(NakedMemExpr)) {
15628 if (
const EnableIfAttr *
Attr =
15629 CheckEnableIf(Method, LParenLoc, Args,
true)) {
15630 Diag(MemE->getMemberLoc(),
15631 diag::err_ovl_no_viable_member_function_in_call)
15634 diag::note_ovl_candidate_disabled_by_function_cond_attr)
15635 <<
Attr->getCond()->getSourceRange() <<
Attr->getMessage();
15640 if (isa<CXXConstructorDecl, CXXDestructorDecl>(CurContext) &&
15641 TheCall->getDirectCallee()->isPureVirtual()) {
15647 diag::warn_call_to_pure_virtual_member_function_from_ctor_dtor)
15648 << MD->
getDeclName() << isa<CXXDestructorDecl>(CurContext)
15652 if (getLangOpts().AppleKext)
15658 if (
auto *DD = dyn_cast<CXXDestructorDecl>(TheCall->getDirectCallee())) {
15660 bool CallCanBeVirtual = !MemExpr->
hasQualifier() || getLangOpts().AppleKext;
15661 CheckVirtualDtorCall(DD, MemExpr->
getBeginLoc(),
false,
15662 CallCanBeVirtual,
true,
15666 return CheckForImmediateInvocation(MaybeBindToTemporary(TheCall),
15667 TheCall->getDirectCallee());
15679 UnbridgedCastsSet UnbridgedCasts;
15683 assert(Object.get()->getType()->isRecordType() &&
15684 "Requires object type argument");
15697 if (RequireCompleteType(LParenLoc, Object.get()->getType(),
15698 diag::err_incomplete_object_call, Object.get()))
15702 LookupResult R(*
this, OpName, LParenLoc, LookupOrdinaryName);
15703 LookupQualifiedName(R,
Record->getDecl());
15704 R.suppressAccessDiagnostics();
15707 Oper != OperEnd; ++Oper) {
15708 AddMethodCandidate(Oper.getPair(), Object.get()->getType(),
15709 Object.get()->Classify(Context), Args, CandidateSet,
15721 bool IgnoreSurrogateFunctions =
false;
15722 if (CandidateSet.
size() == 1 &&
Record->getAsCXXRecordDecl()->isLambda()) {
15724 if (!Candidate.
Viable &&
15726 IgnoreSurrogateFunctions =
true;
15746 const auto &Conversions =
15747 cast<CXXRecordDecl>(
Record->getDecl())->getVisibleConversionFunctions();
15748 for (
auto I = Conversions.begin(),
E = Conversions.end();
15749 !IgnoreSurrogateFunctions && I !=
E; ++I) {
15752 if (isa<UsingShadowDecl>(
D))
15753 D = cast<UsingShadowDecl>(
D)->getTargetDecl();
15757 if (isa<FunctionTemplateDecl>(
D))
15770 AddSurrogateCandidate(Conv, I.getPair(), ActingContext, Proto,
15771 Object.get(), Args, CandidateSet);
15776 bool HadMultipleCandidates = (CandidateSet.
size() > 1);
15789 CandidateSet.
empty()
15790 ? (PDiag(diag::err_ovl_no_oper)
15791 << Object.get()->getType() << 1
15792 << Object.get()->getSourceRange())
15793 : (PDiag(diag::err_ovl_no_viable_object_call)
15794 << Object.get()->getType() << Object.get()->getSourceRange());
15801 if (!R.isAmbiguous())
15804 PDiag(diag::err_ovl_ambiguous_object_call)
15805 << Object.get()->getType()
15806 << Object.get()->getSourceRange()),
15817 PDiag(diag::err_ovl_deleted_object_call)
15818 << Object.get()->getType() << (Msg !=
nullptr)
15819 << (Msg ? Msg->
getString() : StringRef())
15820 << Object.get()->getSourceRange()),
15826 if (Best == CandidateSet.
end())
15829 UnbridgedCasts.restore();
15831 if (Best->Function ==
nullptr) {
15835 = cast<CXXConversionDecl>(
15836 Best->Conversions[0].UserDefined.ConversionFunction);
15838 CheckMemberOperatorAccess(LParenLoc, Object.get(),
nullptr,
15840 if (DiagnoseUseOfDecl(Best->FoundDecl, LParenLoc))
15842 assert(Conv == Best->FoundDecl.getDecl() &&
15843 "Found Decl & conversion-to-functionptr should be same, right?!");
15850 ExprResult Call = BuildCXXMemberCallExpr(Object.get(), Best->FoundDecl,
15851 Conv, HadMultipleCandidates);
15852 if (
Call.isInvalid())
15856 Context,
Call.get()->getType(), CK_UserDefinedConversion,
Call.get(),
15857 nullptr,
VK_PRValue, CurFPFeatureOverrides());
15859 return BuildCallExpr(S,
Call.get(), LParenLoc, Args, RParenLoc);
15862 CheckMemberOperatorAccess(LParenLoc, Object.get(),
nullptr, Best->FoundDecl);
15867 CXXMethodDecl *Method = cast<CXXMethodDecl>(Best->Function);
15880 Obj, HadMultipleCandidates,
15887 MethodArgs.reserve(NumParams + 1);
15889 bool IsError =
false;
15896 ExprResult ObjRes = PerformImplicitObjectArgumentInitialization(
15897 Object.get(),
nullptr, Best->FoundDecl, Method);
15902 MethodArgs.push_back(Object.get());
15906 *
this, MethodArgs, Method, Args, LParenLoc);
15909 if (Proto->isVariadic()) {
15911 for (
unsigned i = NumParams, e = Args.size(); i < e; i++) {
15912 ExprResult Arg = DefaultVariadicArgumentPromotion(Args[i], VariadicMethod,
15915 MethodArgs.push_back(Arg.
get());
15922 DiagnoseSentinelCalls(Method, LParenLoc, Args);
15930 Context, OO_Call, NewFn.
get(), MethodArgs, ResultTy, VK, RParenLoc,
15931 CurFPFeatureOverrides());
15933 if (CheckCallReturnType(Method->
getReturnType(), LParenLoc, TheCall, Method))
15936 if (CheckFunctionCall(Method, TheCall, Proto))
15939 return CheckForImmediateInvocation(MaybeBindToTemporary(TheCall), Method);
15944 bool *NoArrowOperatorFound) {
15945 assert(
Base->getType()->isRecordType() &&
15946 "left-hand side must have class type");
15963 if (RequireCompleteType(
Loc,
Base->getType(),
15964 diag::err_typecheck_incomplete_tag,
Base))
15967 LookupResult R(*
this, OpName, OpLoc, LookupOrdinaryName);
15972 Oper != OperEnd; ++Oper) {
15973 AddMethodCandidate(Oper.getPair(),
Base->getType(),
Base->Classify(Context),
15978 bool HadMultipleCandidates = (CandidateSet.
size() > 1);
15989 if (CandidateSet.
empty()) {
15991 if (NoArrowOperatorFound) {
15994 *NoArrowOperatorFound =
true;
15997 Diag(OpLoc, diag::err_typecheck_member_reference_arrow)
15998 << BaseType <<
Base->getSourceRange();
16000 Diag(OpLoc, diag::note_typecheck_member_reference_suggestion)
16004 Diag(OpLoc, diag::err_ovl_no_viable_oper)
16005 <<
"operator->" <<
Base->getSourceRange();
16013 <<
"->" <<
Base->getType()
16014 <<
Base->getSourceRange()),
16022 <<
"->" << (Msg !=
nullptr)
16023 << (Msg ? Msg->
getString() : StringRef())
16024 <<
Base->getSourceRange()),
16030 CheckMemberOperatorAccess(OpLoc,
Base,
nullptr, Best->FoundDecl);
16033 CXXMethodDecl *Method = cast<CXXMethodDecl>(Best->Function);
16036 ExprResult R = InitializeExplicitObjectArgument(*
this,
Base, Method);
16042 Base,
nullptr, Best->FoundDecl, Method);
16050 Base, HadMultipleCandidates, OpLoc);
16060 ResultTy, VK, OpLoc, CurFPFeatureOverrides());
16062 if (CheckCallReturnType(Method->
getReturnType(), OpLoc, TheCall, Method))
16065 if (CheckFunctionCall(Method, TheCall,
16069 return CheckForImmediateInvocation(MaybeBindToTemporary(TheCall), Method);
16081 AddNonMemberOperatorCandidates(R.
asUnresolvedSet(), Args, CandidateSet,
16084 bool HadMultipleCandidates = (CandidateSet.
size() > 1);
16097 PDiag(diag::err_ovl_no_viable_function_in_call)
16112 nullptr, HadMultipleCandidates,
16115 if (Fn.isInvalid())
16121 for (
unsigned ArgIdx = 0, N = Args.size(); ArgIdx != N; ++ArgIdx) {
16122 ExprResult InputInit = PerformCopyInitialization(
16127 ConvArgs[ArgIdx] = InputInit.
get();
16135 Context, Fn.get(),
llvm::ArrayRef(ConvArgs, Args.size()), ResultTy, VK,
16136 LitEndLoc, UDSuffixLoc, CurFPFeatureOverrides());
16138 if (CheckCallReturnType(FD->
getReturnType(), UDSuffixLoc, UDL, FD))
16141 if (CheckFunctionCall(FD, UDL,
nullptr))
16144 return CheckForImmediateInvocation(MaybeBindToTemporary(UDL), FD);
16154 Scope *S =
nullptr;
16157 if (!MemberLookup.
empty()) {
16167 return FRS_DiagnosticIssued;
16172 return FRS_DiagnosticIssued;
16175 ExprResult FnR = CreateUnresolvedLookupExpr(
nullptr,
16179 return FRS_DiagnosticIssued;
16182 bool CandidateSetError = buildOverloadedCallSet(S, Fn, Fn,
Range,
Loc,
16184 if (CandidateSet->
empty() || CandidateSetError) {
16186 return FRS_NoViableFunction;
16194 return FRS_NoViableFunction;
16197 Loc,
nullptr, CandidateSet, &Best,
16202 return FRS_DiagnosticIssued;
16205 return FRS_Success;
16210 if (
ParenExpr *PE = dyn_cast<ParenExpr>(
E)) {
16212 FixOverloadedFunctionReference(PE->getSubExpr(),
Found, Fn);
16215 if (SubExpr.
get() == PE->getSubExpr())
16218 return new (Context)
16219 ParenExpr(PE->getLParen(), PE->getRParen(), SubExpr.
get());
16224 FixOverloadedFunctionReference(ICE->getSubExpr(),
Found, Fn);
16227 assert(Context.
hasSameType(ICE->getSubExpr()->getType(),
16229 "Implicit cast type cannot be determined from overload");
16230 assert(ICE->path_empty() &&
"fixing up hierarchy conversion?");
16231 if (SubExpr.
get() == ICE->getSubExpr())
16236 CurFPFeatureOverrides());
16239 if (
auto *GSE = dyn_cast<GenericSelectionExpr>(
E)) {
16240 if (!GSE->isResultDependent()) {
16242 FixOverloadedFunctionReference(GSE->getResultExpr(),
Found, Fn);
16245 if (SubExpr.
get() == GSE->getResultExpr())
16252 unsigned ResultIdx = GSE->getResultIndex();
16253 AssocExprs[ResultIdx] = SubExpr.
get();
16255 if (GSE->isExprPredicate())
16257 Context, GSE->getGenericLoc(), GSE->getControllingExpr(),
16258 GSE->getAssocTypeSourceInfos(), AssocExprs, GSE->getDefaultLoc(),
16259 GSE->getRParenLoc(), GSE->containsUnexpandedParameterPack(),
16262 Context, GSE->getGenericLoc(), GSE->getControllingType(),
16263 GSE->getAssocTypeSourceInfos(), AssocExprs, GSE->getDefaultLoc(),
16264 GSE->getRParenLoc(), GSE->containsUnexpandedParameterPack(),
16273 assert(UnOp->getOpcode() == UO_AddrOf &&
16274 "Can only take the address of an overloaded function");
16284 FixOverloadedFunctionReference(UnOp->getSubExpr(),
Found, Fn);
16287 if (SubExpr.
get() == UnOp->getSubExpr())
16290 if (CheckUseOfCXXMethodAsAddressOfOperand(UnOp->getBeginLoc(),
16291 SubExpr.
get(), Method))
16294 assert(isa<DeclRefExpr>(SubExpr.
get()) &&
16295 "fixed to something other than a decl ref");
16296 assert(cast<DeclRefExpr>(SubExpr.
get())->getQualifier() &&
16297 "fixed to a member ref with no nested name qualifier");
16308 (void)isCompleteType(UnOp->getOperatorLoc(), MemPtrType);
16312 UnOp->getOperatorLoc(),
false,
16313 CurFPFeatureOverrides());
16317 FixOverloadedFunctionReference(UnOp->getSubExpr(),
Found, Fn);
16320 if (SubExpr.
get() == UnOp->getSubExpr())
16323 return CreateBuiltinUnaryOp(UnOp->getOperatorLoc(), UO_AddrOf,
16330 if (ULE->hasExplicitTemplateArgs()) {
16331 ULE->copyTemplateArgumentsInto(TemplateArgsBuffer);
16332 TemplateArgs = &TemplateArgsBuffer;
16337 getLangOpts().CPlusPlus && !Fn->hasCXXExplicitFunctionObjectParameter()
16342 if (
unsigned BID = Fn->getBuiltinID()) {
16350 Fn,
Type, ValueKind, ULE->getNameInfo(), ULE->getQualifierLoc(),
16351 Found.getDecl(), ULE->getTemplateKeywordLoc(), TemplateArgs);
16359 if (MemExpr->hasExplicitTemplateArgs()) {
16360 MemExpr->copyTemplateArgumentsInto(TemplateArgsBuffer);
16361 TemplateArgs = &TemplateArgsBuffer;
16368 if (MemExpr->isImplicitAccess()) {
16369 if (cast<CXXMethodDecl>(Fn)->isStatic()) {
16371 Fn, Fn->getType(),
VK_LValue, MemExpr->getNameInfo(),
16372 MemExpr->getQualifierLoc(),
Found.getDecl(),
16373 MemExpr->getTemplateKeywordLoc(), TemplateArgs);
16378 if (MemExpr->getQualifier())
16379 Loc = MemExpr->getQualifierLoc().getBeginLoc();
16381 BuildCXXThisExpr(
Loc, MemExpr->getBaseType(),
true);
16384 Base = MemExpr->getBase();
16388 if (cast<CXXMethodDecl>(Fn)->isStatic()) {
16390 type = Fn->getType();
16396 return BuildMemberExpr(
16397 Base, MemExpr->isArrow(), MemExpr->getOperatorLoc(),
16398 MemExpr->getQualifierLoc(), MemExpr->getTemplateKeywordLoc(), Fn,
Found,
16399 true, MemExpr->getMemberNameInfo(),
16403 llvm_unreachable(
"Invalid reference to overloaded function");
16409 return FixOverloadedFunctionReference(
E.get(),
Found, Fn);
16414 if (!PartialOverloading || !
Function)
16418 if (
const auto *Proto =
16419 dyn_cast<FunctionProtoType>(
Function->getFunctionType()))
16420 if (Proto->isTemplateVariadic())
16422 if (
auto *Pattern =
Function->getTemplateInstantiationPattern())
16423 if (
const auto *Proto =
16424 dyn_cast<FunctionProtoType>(Pattern->getFunctionType()))
16425 if (Proto->isTemplateVariadic())
16438 << IsMember << Name << (Msg !=
nullptr)
16439 << (Msg ? Msg->
getString() : StringRef())
Defines the clang::ASTContext interface.
Defines the Diagnostic-related interfaces.
static bool isBooleanType(QualType Ty)
Defines the C++ Decl subclasses, other than those for templates (found in DeclTemplate....
Defines the clang::Expr interface and subclasses for C++ expressions.
static bool EvaluateAsBooleanCondition(const Expr *E, bool &Result, EvalInfo &Info)
static const GlobalDecl isTemplate(GlobalDecl GD, const TemplateArgumentList *&TemplateArgs)
static DiagnosticBuilder Diag(DiagnosticsEngine *Diags, const LangOptions &Features, FullSourceLoc TokLoc, const char *TokBegin, const char *TokRangeBegin, const char *TokRangeEnd, unsigned DiagID)
Produce a diagnostic highlighting some portion of a literal.
llvm::MachO::Record Record
Defines an enumeration for C++ overloaded operators.
Implements a partial diagnostic that can be emitted anwyhere in a DiagnosticBuilder stream.
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 bool isQualificationConversionStep(QualType FromType, QualType ToType, bool CStyle, bool IsTopLevel, bool &PreviousToQualsIncludeConst, bool &ObjCLifetimeConversion, const ASTContext &Ctx)
Perform a single iteration of the loop for checking if a qualification conversion is valid.
static ImplicitConversionSequence::CompareKind CompareQualificationConversions(Sema &S, const StandardConversionSequence &SCS1, const StandardConversionSequence &SCS2)
CompareQualificationConversions - Compares two standard conversion sequences to determine whether the...
static void dropPointerConversion(StandardConversionSequence &SCS)
dropPointerConversions - If the given standard conversion sequence involves any pointer conversions,...
static SourceLocation GetLocationForCandidate(const OverloadCandidate *Cand)
static void DiagnoseArityMismatch(Sema &S, NamedDecl *Found, Decl *D, unsigned NumFormalArgs, bool IsAddressOf=false)
General arity mismatch diagnosis over a candidate in a candidate set.
static const Expr * IgnoreNarrowingConversion(ASTContext &Ctx, const Expr *Converted)
Skip any implicit casts which could be either part of a narrowing conversion or after one in an impli...
static bool allowAmbiguity(ASTContext &Context, const FunctionDecl *F1, const FunctionDecl *F2)
static unsigned RankDeductionFailure(const DeductionFailureInfo &DFI)
static QualType BuildSimilarlyQualifiedPointerType(const Type *FromPtr, QualType ToPointee, QualType ToType, ASTContext &Context, bool StripObjCLifetime=false)
BuildSimilarlyQualifiedPointerType - In a pointer conversion from the pointer type FromPtr to a point...
static void forAllQualifierCombinations(QualifiersAndAtomic Quals, llvm::function_ref< void(QualifiersAndAtomic)> Callback)
static bool FindConversionForRefInit(Sema &S, ImplicitConversionSequence &ICS, QualType DeclType, SourceLocation DeclLoc, Expr *Init, QualType T2, bool AllowRvalues, bool AllowExplicit)
Look for a user-defined conversion to a value reference-compatible with DeclType.
static bool tryAtomicConversion(Sema &S, Expr *From, QualType ToType, bool InOverloadResolution, StandardConversionSequence &SCS, bool CStyle)
static Expr * GetExplicitObjectExpr(Sema &S, Expr *Obj, const FunctionDecl *Fun)
static bool hasDeprecatedStringLiteralToCharPtrConversion(const ImplicitConversionSequence &ICS)
static 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, bool PartialOrdering, PackFold PackFold, bool *HasDeducedAnyParam)
Defines the SourceManager interface.
static QualType getPointeeType(const MemRegion *R)
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.
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 hasSimilarType(QualType T1, QualType T2) const
Determine if two types are similar, according to the C++ rules.
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.
bool UnwrapSimilarTypes(QualType &T1, QualType &T2, bool AllowPiMismatch=true) const
Attempt to unwrap two types that may be similar (C++ [conv.qual]).
QualType getAddrSpaceQualType(QualType T, LangAS AddressSpace) const
Return the uniqued reference to the type for an address space qualified type with the specified type ...
bool isPromotableIntegerType(QualType T) const
More type predicates useful for type checking/promotion.
QualType getUnqualifiedArrayType(QualType T, Qualifiers &Quals) const
Return this type as a completely-unqualified array type, capturing the qualifiers in Quals.
Represents a constant array type that does not decay to a pointer when used as a function parameter.
QualType getConstantArrayType(const ASTContext &Ctx) const
Represents an array type, per C99 6.7.5.2 - Array Declarators.
QualType getElementType() const
QualType getValueType() const
Gets the type contained by this atomic type, i.e.
Attr - This represents one attribute.
A builtin binary operation expression such as "x + y" or "x <= y".
static OverloadedOperatorKind getOverloadedOperator(Opcode Opc)
Retrieve the overloaded operator kind that corresponds to the given binary opcode.
StringRef getOpcodeStr() const
bool isCompoundAssignmentOp() const
static BinaryOperator * Create(const ASTContext &C, Expr *lhs, Expr *rhs, Opcode opc, QualType ResTy, ExprValueKind VK, ExprObjectKind OK, SourceLocation opLoc, FPOptionsOverride FPFeatures)
This class is used for builtin types like 'int'.
bool isDirectlyAddressable(unsigned ID) const
Determines whether this builtin can have its address taken with no special action required.
BasePaths - Represents the set of paths from a derived class to one of its (direct or indirect) bases...
Represents a C++ constructor within a class.
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.
bool isAtLeastAsQualifiedAs(CanQual< T > Other, const ASTContext &Ctx) const
Determines whether this canonical type is at least as qualified as the Other canonical type.
static CanQual< Type > CreateUnsafe(QualType Other)
Builds a canonical type from a QualType.
CanProxy< U > castAs() const
CanQual< T > getUnqualifiedType() const
Retrieve the unqualified form of this type.
Qualifiers getQualifiers() const
Retrieve all qualifiers.
CanProxy< U > getAs() const
Retrieve a canonical type pointer with a different static type, upcasting or downcasting as needed.
bool isVolatileQualified() const
const 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.
ExtParameterInfo getExtParameterInfo(unsigned I) const
unsigned getNumParams() const
Qualifiers getMethodQuals() const
QualType getParamType(unsigned i) const
bool isVariadic() const
Whether this function prototype is variadic.
ArrayRef< QualType > param_types() const
Declaration of a template function.
FunctionDecl * getTemplatedDecl() const
Get the underlying function declaration of the template.
A class which abstracts out some details necessary for making a call.
ExtInfo withNoReturn(bool noReturn) const
ParameterABI getABI() const
Return the ABI treatment of this parameter.
FunctionType - C99 6.7.5.3 - Function Declarators.
ExtInfo getExtInfo() const
CallingConv getCallConv() const
QualType getReturnType() const
QualType getCallResultType(const ASTContext &Context) const
Determine the type of an expression that calls a function of this type.
static GenericSelectionExpr * Create(const ASTContext &Context, SourceLocation GenericLoc, Expr *ControllingExpr, ArrayRef< TypeSourceInfo * > AssocTypes, ArrayRef< Expr * > AssocExprs, SourceLocation DefaultLoc, SourceLocation RParenLoc, bool ContainsUnexpandedParameterPack, unsigned ResultIndex)
Create a non-result-dependent generic selection expression accepting an expression predicate.
One of these records is kept for each identifier that is lexed.
ImplicitCastExpr - Allows us to explicitly represent implicit type conversions, which have no direct ...
static ImplicitCastExpr * Create(const ASTContext &Context, QualType T, CastKind Kind, Expr *Operand, const CXXCastPath *BasePath, ExprValueKind Cat, FPOptionsOverride FPO)
ImplicitConversionSequence - Represents an implicit conversion sequence, which may be a standard conv...
void dump() const
dump - Print this implicit conversion sequence to standard error.
bool isUserDefined() const
@ StaticObjectArgumentConversion
StandardConversionSequence Standard
When ConversionKind == StandardConversion, provides the details of the standard conversion sequence.
void setBad(BadConversionSequence::FailureKind Failure, Expr *FromExpr, QualType ToType)
Sets this sequence as a bad conversion for an explicit argument.
UserDefinedConversionSequence UserDefined
When ConversionKind == UserDefinedConversion, provides the details of the user-defined conversion seq...
static ImplicitConversionSequence getNullptrToBool(QualType SourceType, QualType DestType, bool NeedLValToRVal)
Form an "implicit" conversion sequence from nullptr_t to bool, for a direct-initialization of a bool ...
AmbiguousConversionSequence Ambiguous
When ConversionKind == AmbiguousConversion, provides the details of the ambiguous conversion.
bool hasInitializerListContainerType() const
unsigned getKindRank() const
Return a ranking of the implicit conversion sequence kind, where smaller ranks represent better conve...
bool isInitializerListOfIncompleteArray() const
BadConversionSequence Bad
When ConversionKind == BadConversion, provides the details of the bad conversion.
QualType getInitializerListContainerType() const
void DiagnoseAmbiguousConversion(Sema &S, SourceLocation CaretLoc, const PartialDiagnostic &PDiag) const
Diagnoses an ambiguous conversion.
Describes an C or C++ initializer list.
bool hasDesignatedInit() const
Determine whether this initializer list contains a designated initializer.
unsigned getNumInits() const
SourceLocation getBeginLoc() const LLVM_READONLY
const Expr * getInit(unsigned Init) const
SourceLocation getEndLoc() const LLVM_READONLY
Describes an entity that is being initialized.
static InitializedEntity InitializeParameter(ASTContext &Context, ParmVarDecl *Parm)
Create the initialization entity for a parameter.
static InitializedEntity InitializeTemplateParameter(QualType T, 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.
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
OverloadCandidate & addCandidate(unsigned NumConversions=0, ConversionSequenceList Conversions={})
Add a new candidate with NumConversions conversion sequence slots to the overload set.
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...
void addConst()
Add the const type qualifier to this QualType.
bool isNull() const
Return true if this QualType doesn't point to a type yet.
const Type * getTypePtr() const
Retrieves a pointer to the underlying (unqualified) type.
LangAS getAddressSpace() const
Return the address space of this type.
Qualifiers getQualifiers() const
Retrieve the set of qualifiers applied to this type.
void getAsStringInternal(std::string &Str, const PrintingPolicy &Policy) const
QualType getNonReferenceType() const
If Type is a reference type (e.g., const int&), returns the type that the reference refers to ("const...
QualType getUnqualifiedType() const
Retrieve the unqualified variant of the given type, removing as little sugar as possible.
unsigned getLocalCVRQualifiers() const
Retrieve the set of CVR (const-volatile-restrict) qualifiers local to this particular QualType instan...
bool isMoreQualifiedThan(QualType Other, const ASTContext &Ctx) const
Determine whether this type is more qualified than the other given type, requiring exact equality for...
bool isConstQualified() const
Determine whether this type is const-qualified.
bool hasAddressSpace() const
Check if this type has any address space qualifier.
unsigned getCVRQualifiers() const
Retrieve the set of CVR (const-volatile-restrict) qualifiers applied to this type.
static std::string getAsString(SplitQualType split, const PrintingPolicy &Policy)
bool isAtLeastAsQualifiedAs(QualType Other, const ASTContext &Ctx) const
Determine whether this type is at least as qualified as the other given type, requiring exact equalit...
Qualifiers getLocalQualifiers() const
Retrieve the set of qualifiers local to this particular QualType instance, not including any qualifie...
A qualifier set is used to build a set of qualifiers.
const Type * strip(QualType type)
Collect any qualifiers on the given type and return an unqualified type.
QualType apply(const ASTContext &Context, QualType QT) const
Apply the collected qualifiers to the given type.
QualifiersAndAtomic withVolatile()
QualifiersAndAtomic withAtomic()
The collection of all-type qualifiers we support.
unsigned getCVRQualifiers() const
bool hasOnlyConst() const
@ OCL_ExplicitNone
This object can be modified without requiring retains or releases.
void removeObjCLifetime()
bool compatiblyIncludes(Qualifiers other, const ASTContext &Ctx) const
Determines if these qualifiers compatibly include another set.
static bool isAddressSpaceSupersetOf(LangAS A, LangAS B, const ASTContext &Ctx)
Returns true if address space A is equal to or a superset of B.
void removeAddressSpace()
void setAddressSpace(LangAS space)
bool hasObjCGCAttr() const
ObjCLifetime getObjCLifetime() const
std::string getAsString() const
LangAS getAddressSpace() const
bool compatiblyIncludesObjCLifetime(Qualifiers other) const
Determines if these qualifiers compatibly include another set of qualifiers from the narrow perspecti...
An rvalue reference type, per C++11 [dcl.ref].
Represents a struct/union/class.
field_range fields() const
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 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.
bool DiagnoseEmptyLookup(Scope *S, CXXScopeSpec &SS, LookupResult &R, CorrectionCandidateCallback &CCC, TemplateArgumentListInfo *ExplicitTemplateArgs=nullptr, ArrayRef< Expr * > Args={}, DeclContext *LookupCtx=nullptr, TypoExpr **Out=nullptr)
Diagnose an empty lookup.
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.
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.
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)
void AddOverloadCandidate(FunctionDecl *Function, DeclAccessPair FoundDecl, ArrayRef< Expr * > Args, OverloadCandidateSet &CandidateSet, bool SuppressUserConversions=false, bool PartialOverloading=false, bool AllowExplicit=true, bool AllowExplicitConversion=false, ADLCallKind IsADLCandidate=ADLCallKind::NotADL, ConversionSequenceList EarlyConversions={}, OverloadCandidateParamOrder PO={}, bool AggregateCandidateDeduction=false)
AddOverloadCandidate - Adds the given function to the set of candidate functions, using the given fun...
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(bool IgnoreDeduced=false) const
Retrieve the underlying template declaration that this template name refers to, if known.
@ Template
A single template declaration.
bool hasAssociatedConstraints() const
TemplateSpecCandidateSet - A set of generalized overload candidates, used in template specializations...
SmallVector< TemplateSpecCandidate, 16 >::iterator iterator
void NoteCandidates(Sema &S, SourceLocation Loc)
NoteCandidates - When no template specialization match is found, prints diagnostic messages containin...
void clear()
Clear out all of the candidates.
SourceLocation getLocation() const
TemplateSpecCandidate & addCandidate()
Add a new candidate with NumConversions conversion sequence slots to the overload set.
Represents a type template specialization; the template must be a class template, a type alias templa...
TemplateTemplateParmDecl - Declares a template template parameter, e.g., "T" in.
Declaration of a template type parameter.
const Type * getTypeForDecl() const
The base class of the type hierarchy.
bool isIncompleteOrObjectType() const
Return true if this is an incomplete or object type, in other words, not a function type.
bool isBlockPointerType() const
bool isBooleanType() const
bool isObjCBuiltinType() const
bool isSignedIntegerOrEnumerationType() const
Determines whether this is an integer type that is signed or an enumeration types whose underlying ty...
bool hasAttr(attr::Kind AK) const
Determine whether this type had the specified attribute applied to it (looking through top-level type...
const RecordType * getAsUnionType() const
NOTE: getAs*ArrayType are methods on ASTContext.
bool isIncompleteArrayType() const
bool isSignedIntegerType() const
Return true if this is an integer type that is signed, according to C99 6.2.5p4 [char,...
bool isFloat16Type() const
bool isComplexType() const
isComplexType() does not include complex integers (a GCC extension).
bool isIntegralOrUnscopedEnumerationType() const
Determine whether this type is an integral or unscoped enumeration type.
bool isRValueReferenceType() const
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 isHLSLAttributedResourceType() const
bool isUnsignedIntegerType() const
Return true if this is an integer type that is unsigned, according to C99 6.2.5p6 [which returns true...
bool isAnyPointerType() const
TypeClass getTypeClass() const
const T * getAs() const
Member-template getAs<specific type>'.
bool isNullPtrType() const
bool isRecordType() const
UnaryOperator - This represents the unary-expression's (except sizeof and alignof),...
static OverloadedOperatorKind getOverloadedOperator(Opcode Opc)
Retrieve the overloaded operator kind that corresponds to the given unary opcode.
static UnaryOperator * Create(const ASTContext &C, Expr *input, Opcode opc, QualType type, ExprValueKind VK, ExprObjectKind OK, SourceLocation l, bool CanOverflow, FPOptionsOverride FPFeatures)
static StringRef getOpcodeStr(Opcode Op)
getOpcodeStr - Turn an Opcode enum value into the punctuation char it corresponds to,...
A reference to a name which we were able to look up during parsing but could not resolve to a specifi...
bool requiresADL() const
True if this declaration should be extended by argument-dependent lookup.
static UnresolvedLookupExpr * Create(const ASTContext &Context, CXXRecordDecl *NamingClass, NestedNameSpecifierLoc QualifierLoc, const DeclarationNameInfo &NameInfo, bool RequiresADL, UnresolvedSetIterator Begin, UnresolvedSetIterator End, bool KnownDependent, bool KnownInstantiationDependent)
Represents a C++ member access expression for which lookup produced a set of overloaded functions.
DeclarationName getMemberName() const
Retrieve the name of the member that this expression refers to.
QualType getBaseType() const
bool isArrow() const
Determine whether this member expression used the '->' operator; otherwise, it used the '.
Expr * getBase()
Retrieve the base object of this member expressions, e.g., the x in x.m.
SourceLocation getBeginLoc() const LLVM_READONLY
SourceLocation getMemberLoc() const
Retrieve the location of the name of the member that this expression refers to.
A set of unresolved declarations.
ArrayRef< DeclAccessPair > pairs() const
void addDecl(NamedDecl *D)
The iterator over UnresolvedSets.
A set of unresolved declarations.
A call to a literal operator (C++11 [over.literal]) written as a user-defined literal (C++11 [lit....
static UserDefinedLiteral * Create(const ASTContext &Ctx, Expr *Fn, ArrayRef< Expr * > Args, QualType Ty, ExprValueKind VK, SourceLocation LitEndLoc, SourceLocation SuffixLoc, FPOptionsOverride FPFeatures)
unsigned getNumElements() const
QualType getElementType() const
Provides information about an attempted template argument deduction, whose success or failure was des...
TemplateArgumentList * takeSugared()
Take ownership of the deduced template argument lists.
TemplateArgument SecondArg
The second template argument to which the template argument deduction failure refers.
TemplateParameter Param
The template parameter to which a template argument deduction failure refers.
bool hasSFINAEDiagnostic() const
Is a SFINAE diagnostic available?
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)
void checkAssignmentLifetime(Sema &SemaRef, const AssignedEntity &Entity, Expr *Init)
Check that the lifetime of the given expr (and its subobjects) is sufficient for assigning to the ent...
The JSON file list parser is used to communicate input to InstallAPI.
ImplicitConversionRank GetDimensionConversionRank(ImplicitConversionRank Base, ImplicitConversionKind Dimension)
OverloadedOperatorKind
Enumeration specifying the different kinds of C++ overloaded operators.
@ OO_None
Not an overloaded operator.
@ NUM_OVERLOADED_OPERATORS
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.
@ Seq
'seq' clause, allowed on 'loop' and 'routine' directives.
OverloadsShown
Specifies which overload candidates to display when overload resolution fails.
@ Ovl_Best
Show just the "best" overload candidates.
ComparisonCategoryResult
An enumeration representing the possible results of a three-way comparison.
OverloadCandidateRewriteKind
The kinds of rewrite we perform on overload candidates.
@ CRK_Reversed
Candidate is a rewritten candidate with a reversed order of parameters.
@ CRK_None
Candidate is not a rewritten candidate.
@ CRK_DifferentOperator
Candidate is a rewritten candidate with a different operator name.
@ Internal
Internal linkage, which indicates that the entity can be referred to from within the translation unit...
@ Result
The result type of a method or function.
ImplicitConversionKind
ImplicitConversionKind - The kind of implicit conversion used to convert an argument to a parameter's...
@ ICK_Complex_Conversion
Complex conversions (C99 6.3.1.6)
@ ICK_Floating_Promotion
Floating point promotions (C++ [conv.fpprom])
@ ICK_Boolean_Conversion
Boolean conversions (C++ [conv.bool])
@ ICK_Integral_Conversion
Integral conversions (C++ [conv.integral])
@ ICK_Fixed_Point_Conversion
Fixed point type conversions according to N1169.
@ ICK_Vector_Conversion
Vector conversions.
@ ICK_Block_Pointer_Conversion
Block Pointer conversions.
@ ICK_Pointer_Member
Pointer-to-member conversions (C++ [conv.mem])
@ ICK_Floating_Integral
Floating-integral conversions (C++ [conv.fpint])
@ ICK_HLSL_Array_RValue
HLSL non-decaying array rvalue cast.
@ ICK_SVE_Vector_Conversion
Arm SVE Vector conversions.
@ ICK_HLSL_Vector_Truncation
HLSL vector truncation.
@ ICK_Incompatible_Pointer_Conversion
C-only conversion between pointers with incompatible types.
@ ICK_Array_To_Pointer
Array-to-pointer conversion (C++ [conv.array])
@ ICK_RVV_Vector_Conversion
RISC-V RVV Vector conversions.
@ ICK_Complex_Promotion
Complex promotions (Clang extension)
@ ICK_Num_Conversion_Kinds
The number of conversion kinds.
@ ICK_Function_Conversion
Function pointer conversion (C++17 [conv.fctptr])
@ ICK_Vector_Splat
A vector splat from an arithmetic type.
@ ICK_Zero_Queue_Conversion
Zero constant to queue.
@ ICK_Identity
Identity conversion (no conversion)
@ ICK_Derived_To_Base
Derived-to-base (C++ [over.best.ics])
@ ICK_Lvalue_To_Rvalue
Lvalue-to-rvalue conversion (C++ [conv.lval])
@ ICK_Qualification
Qualification conversions (C++ [conv.qual])
@ ICK_Pointer_Conversion
Pointer conversions (C++ [conv.ptr])
@ ICK_TransparentUnionConversion
Transparent Union Conversions.
@ ICK_Integral_Promotion
Integral promotions (C++ [conv.prom])
@ ICK_Floating_Conversion
Floating point conversions (C++ [conv.double].
@ ICK_Compatible_Conversion
Conversions between compatible types in C99.
@ ICK_C_Only_Conversion
Conversions allowed in C, but not C++.
@ ICK_Writeback_Conversion
Objective-C ARC writeback conversion.
@ ICK_Zero_Event_Conversion
Zero constant to event (OpenCL1.2 6.12.10)
@ ICK_Complex_Real
Complex-real conversions (C99 6.3.1.7)
@ ICK_Function_To_Pointer
Function-to-pointer (C++ [conv.array])
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....
@ TSK_ImplicitInstantiation
This template specialization was implicitly instantiated from a template.
CallingConv
CallingConv - Specifies the calling convention that a function uses.
const char * getOperatorSpelling(OverloadedOperatorKind Operator)
Retrieve the spelling of the given overloaded operator, without the preceding "operator" keyword.
ConstructorInfo getConstructorInfo(NamedDecl *ND)
@ None
The alignment was not explicit in code.
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.
A std::pair-like structure for storing a qualified type split into its local qualifiers and its local...
const Type * Ty
The locally-unqualified type.
Qualifiers Quals
The local qualifiers.
TemplateSpecCandidate - This is a generalization of OverloadCandidate which keeps track of template a...
void NoteDeductionFailure(Sema &S, bool ForTakingAddress)
Diagnose a template argument deduction failure.
DeductionFailureInfo DeductionFailure
Template argument deduction info.
Decl * Specialization
Specialization - The actual specialization that this candidate represents.
void set(DeclAccessPair Found, Decl *Spec, DeductionFailureInfo Info)
UserDefinedConversionSequence - Represents a user-defined conversion sequence (C++ 13....
StandardConversionSequence Before
Represents the standard conversion that occurs before the actual user-defined conversion.
FunctionDecl * ConversionFunction
ConversionFunction - The function that will perform the user-defined conversion.
bool HadMultipleCandidates
HadMultipleCandidates - When this is true, it means that the conversion function was resolved from an...
StandardConversionSequence After
After - Represents the standard conversion that occurs after the actual user-defined conversion.
bool EllipsisConversion
EllipsisConversion - When this is true, it means user-defined conversion sequence starts with a ....
DeclAccessPair FoundConversionFunction
The declaration that we found via name lookup, which might be the same as ConversionFunction or it mi...
void dump() const
dump - Print this user-defined conversion sequence to standard error.
Describes an entity that is being assigned.