37#include "llvm/ADT/DenseSet.h"
38#include "llvm/ADT/STLExtras.h"
39#include "llvm/ADT/SmallPtrSet.h"
40#include "llvm/ADT/SmallString.h"
41#include "llvm/ADT/SmallVector.h"
42#include "llvm/Support/Casting.h"
55 return P->hasAttr<PassObjectSizeAttr>();
76 if (HadMultipleCandidates)
87 CK_FunctionToPointerDecay);
91 bool InOverloadResolution,
94 bool AllowObjCWritebackConversion);
98 bool InOverloadResolution,
106 bool AllowObjCConversionOnExplicit);
165 return Rank[(
int)Kind];
171 static const char *
const Name[] = {
175 "Function-to-pointer",
176 "Function pointer conversion",
178 "Integral promotion",
179 "Floating point promotion",
181 "Integral conversion",
182 "Floating conversion",
183 "Complex conversion",
184 "Floating-integral conversion",
185 "Pointer conversion",
186 "Pointer-to-member conversion",
187 "Boolean conversion",
188 "Compatible-types conversion",
189 "Derived-to-base conversion",
191 "SVE Vector conversion",
192 "RVV Vector conversion",
194 "Complex-real conversion",
195 "Block Pointer conversion",
196 "Transparent Union Conversion",
197 "Writeback conversion",
198 "OpenCL Zero Event Conversion",
199 "OpenCL Zero Queue Conversion",
200 "C specific type conversion",
201 "Incompatible pointer conversion",
202 "Fixed point conversion",
203 "HLSL vector truncation",
290 const Expr *Converted) {
293 if (
auto *EWC = dyn_cast<ExprWithCleanups>(Converted)) {
300 while (
auto *ICE = dyn_cast<ImplicitCastExpr>(Converted)) {
301 switch (ICE->getCastKind()) {
303 case CK_IntegralCast:
304 case CK_IntegralToBoolean:
305 case CK_IntegralToFloating:
306 case CK_BooleanToSignedIntegral:
307 case CK_FloatingToIntegral:
308 case CK_FloatingToBoolean:
309 case CK_FloatingCast:
310 Converted = ICE->getSubExpr();
334 QualType &ConstantType,
bool IgnoreFloatToIntegralConversion)
const {
336 "narrowing check outside C++");
347 ToType = ET->getDecl()->getIntegerType();
353 goto FloatingIntegralConversion;
355 goto IntegralConversion;
366 FloatingIntegralConversion:
371 if (IgnoreFloatToIntegralConversion)
374 assert(
Initializer &&
"Unknown conversion expression");
380 if (std::optional<llvm::APSInt> IntConstantValue =
384 Result.convertFromAPInt(*IntConstantValue, IntConstantValue->isSigned(),
385 llvm::APFloat::rmNearestTiesToEven);
387 llvm::APSInt ConvertedValue = *IntConstantValue;
389 Result.convertToInteger(ConvertedValue,
390 llvm::APFloat::rmTowardZero, &ignored);
392 if (*IntConstantValue != ConvertedValue) {
393 ConstantValue =
APValue(*IntConstantValue);
420 Initializer->isCXX11ConstantExpr(Ctx, &ConstantValue)) {
423 ConstantValue = R.
Val;
424 assert(ConstantValue.
isFloat());
425 llvm::APFloat FloatVal = ConstantValue.
getFloat();
428 llvm::APFloat Converted = FloatVal;
429 llvm::APFloat::opStatus ConvertStatus =
431 llvm::APFloat::rmNearestTiesToEven, &ignored);
433 llvm::APFloat::rmNearestTiesToEven, &ignored);
435 if (FloatVal.isNaN() && Converted.isNaN() &&
436 !FloatVal.isSignaling() && !Converted.isSignaling()) {
442 if (!Converted.bitwiseIsEqual(FloatVal)) {
449 if (ConvertStatus & llvm::APFloat::opOverflow) {
466 IntegralConversion: {
470 const unsigned FromWidth = Ctx.
getIntWidth(FromType);
474 if (FromWidth > ToWidth ||
475 (FromWidth == ToWidth && FromSigned != ToSigned) ||
476 (FromSigned && !ToSigned)) {
484 std::optional<llvm::APSInt> OptInitializerValue;
485 if (!(OptInitializerValue =
Initializer->getIntegerConstantExpr(Ctx))) {
489 llvm::APSInt &InitializerValue = *OptInitializerValue;
490 bool Narrowing =
false;
491 if (FromWidth < ToWidth) {
494 if (InitializerValue.isSigned() && InitializerValue.isNegative())
499 InitializerValue = InitializerValue.extend(
500 InitializerValue.getBitWidth() + 1);
502 llvm::APSInt ConvertedValue = InitializerValue;
503 ConvertedValue = ConvertedValue.trunc(ToWidth);
504 ConvertedValue.setIsSigned(ToSigned);
505 ConvertedValue = ConvertedValue.extend(InitializerValue.getBitWidth());
506 ConvertedValue.setIsSigned(InitializerValue.isSigned());
508 if (ConvertedValue != InitializerValue)
513 ConstantValue =
APValue(InitializerValue);
529 ConstantValue = R.
Val;
530 assert(ConstantValue.
isFloat());
531 llvm::APFloat FloatVal = ConstantValue.
getFloat();
536 if (FloatVal.isNaN() && FloatVal.isSignaling()) {
552 raw_ostream &OS = llvm::errs();
553 bool PrintedSomething =
false;
556 PrintedSomething =
true;
560 if (PrintedSomething) {
566 OS <<
" (by copy constructor)";
568 OS <<
" (direct reference binding)";
570 OS <<
" (reference binding)";
572 PrintedSomething =
true;
576 if (PrintedSomething) {
580 PrintedSomething =
true;
583 if (!PrintedSomething) {
584 OS <<
"No conversions required";
591 raw_ostream &OS = llvm::errs();
599 OS <<
"aggregate initialization";
609 raw_ostream &OS = llvm::errs();
611 OS <<
"Worst list element conversion: ";
612 switch (ConversionKind) {
614 OS <<
"Standard conversion: ";
618 OS <<
"User-defined conversion: ";
622 OS <<
"Ellipsis conversion";
625 OS <<
"Ambiguous conversion";
628 OS <<
"Bad conversion";
653 struct DFIArguments {
659 struct DFIParamWithArguments : DFIArguments {
664 struct DFIDeducedMismatchArgs : DFIArguments {
666 unsigned CallArgIndex;
683 Result.Result =
static_cast<unsigned>(TDK);
684 Result.HasDiagnostic =
false;
703 auto *Saved =
new (Context) DFIDeducedMismatchArgs;
714 DFIArguments *Saved =
new (Context) DFIArguments;
726 DFIParamWithArguments *Saved =
new (Context) DFIParamWithArguments;
727 Saved->Param = Info.
Param;
740 Result.HasDiagnostic =
true;
745 CNSInfo *Saved =
new (Context) CNSInfo;
755 llvm_unreachable(
"not a deduction failure");
788 Diag->~PartialDiagnosticAt();
797 Diag->~PartialDiagnosticAt();
833 return TemplateParameter::getFromOpaqueValue(
Data);
838 return static_cast<DFIParamWithArguments*
>(
Data)->Param;
868 return static_cast<DFIDeducedMismatchArgs*
>(
Data)->TemplateArgs;
874 return static_cast<CNSInfo*
>(
Data)->TemplateArgs;
906 return &
static_cast<DFIArguments*
>(
Data)->FirstArg;
938 return &
static_cast<DFIArguments*
>(
Data)->SecondArg;
953 return static_cast<DFIDeducedMismatchArgs*
>(
Data)->CallArgIndex;
969 for (
unsigned I = 0; I <
X->getNumParams(); ++I)
973 if (
auto *FTX =
X->getDescribedFunctionTemplate()) {
978 FTY->getTemplateParameters()))
987 OverloadedOperatorKind::OO_EqualEqual);
999 OverloadedOperatorKind::OO_ExclaimEqual);
1000 if (isa<CXXMethodDecl>(EqFD)) {
1017 auto *NotEqFD = Op->getAsFunction();
1018 if (
auto *UD = dyn_cast<UsingShadowDecl>(Op))
1019 NotEqFD = UD->getUnderlyingDecl()->getAsFunction();
1022 cast<Decl>(Op->getLexicalDeclContext())))
1032 return Op == OO_EqualEqual || Op == OO_Spaceship;
1038 if (!allowsReversed(Op))
1040 if (Op == OverloadedOperatorKind::OO_EqualEqual) {
1041 assert(OriginalArgs.size() == 2);
1043 S, OpLoc, OriginalArgs[1], FD))
1054void OverloadCandidateSet::destroyCandidates() {
1056 for (
auto &
C : i->Conversions)
1057 C.~ImplicitConversionSequence();
1059 i->DeductionFailure.Destroy();
1064 destroyCandidates();
1065 SlabAllocator.Reset();
1066 NumInlineBytesUsed = 0;
1073 class UnbridgedCastsSet {
1083 Entry entry = { &E, E };
1084 Entries.push_back(entry);
1090 i = Entries.begin(), e = Entries.end(); i != e; ++i)
1091 *i->Addr = i->Saved;
1105 UnbridgedCastsSet *unbridgedCasts =
nullptr) {
1109 if (placeholder->getKind() == BuiltinType::Overload)
return false;
1113 if (placeholder->getKind() == BuiltinType::ARCUnbridgedCast &&
1115 unbridgedCasts->save(S, E);
1135 UnbridgedCastsSet &unbridged) {
1136 for (
unsigned i = 0, e = Args.size(); i != e; ++i)
1178 NamedDecl *&Match,
bool NewIsUsingDecl) {
1183 bool OldIsUsingDecl =
false;
1184 if (isa<UsingShadowDecl>(OldD)) {
1185 OldIsUsingDecl =
true;
1189 if (NewIsUsingDecl)
continue;
1191 OldD = cast<UsingShadowDecl>(OldD)->getTargetDecl();
1196 if ((OldIsUsingDecl || NewIsUsingDecl) && !isVisible(*I))
1204 bool UseMemberUsingDeclRules =
1205 (OldIsUsingDecl || NewIsUsingDecl) && CurContext->isRecord() &&
1209 if (!IsOverload(New, OldF, UseMemberUsingDeclRules)) {
1210 if (UseMemberUsingDeclRules && OldIsUsingDecl) {
1211 HideUsingShadowDecl(S, cast<UsingShadowDecl>(*I));
1215 if (!isa<FunctionTemplateDecl>(OldD) &&
1216 !shouldLinkPossiblyHiddenDecl(*I, New))
1225 if (!getASTContext().canBuiltinBeRedeclared(OldF)) {
1227 return Ovl_NonFunction;
1229 }
else if (isa<UsingDecl>(OldD) || isa<UsingPackDecl>(OldD)) {
1233 }
else if (isa<TagDecl>(OldD)) {
1235 }
else if (
auto *UUD = dyn_cast<UnresolvedUsingValueDecl>(OldD)) {
1242 if (UUD->getQualifier()->isDependent() && !UUD->isCXXClassMember()) {
1244 return Ovl_NonFunction;
1251 return Ovl_NonFunction;
1276 if (CheckFunctionTemplateSpecialization(New,
nullptr, TemplateSpecResult,
1279 return Ovl_Overload;
1286 return Ovl_Overload;
1291 bool UseMemberUsingDeclRules,
1292 bool ConsiderCudaAttrs,
1293 bool UseOverrideRules =
false) {
1308 if ((OldTemplate ==
nullptr) != (NewTemplate ==
nullptr))
1321 if (isa<FunctionNoProtoType>(OldQType.
getTypePtr()) ||
1322 isa<FunctionNoProtoType>(NewQType.
getTypePtr()))
1325 const auto *OldType = cast<FunctionProtoType>(OldQType);
1326 const auto *NewType = cast<FunctionProtoType>(NewQType);
1331 if (OldQType != NewQType && OldType->isVariadic() != NewType->isVariadic())
1363 bool ConstraintsInTemplateHead =
1374 if (UseMemberUsingDeclRules && ConstraintsInTemplateHead &&
1375 !SameTemplateParameterList)
1377 if (!UseMemberUsingDeclRules &&
1378 (!SameTemplateParameterList || !SameReturnType))
1382 const auto *OldMethod = dyn_cast<CXXMethodDecl>(Old);
1383 const auto *NewMethod = dyn_cast<CXXMethodDecl>(New);
1385 int OldParamsOffset = 0;
1386 int NewParamsOffset = 0;
1404 !isa<CXXConstructorDecl>(NewMethod))
1410 auto BS =
Base.getNonReferenceType().getCanonicalType().split();
1411 BS.Quals = NormalizeQualifiers(OldMethod, BS.Quals);
1413 auto DS = D.getNonReferenceType().getCanonicalType().split();
1414 DS.Quals = NormalizeQualifiers(NewMethod, DS.Quals);
1416 if (BS.Quals != DS.Quals)
1419 if (OldMethod->isImplicitObjectMemberFunction() &&
1420 OldMethod->getParent() != NewMethod->getParent()) {
1433 if (
Base->isLValueReferenceType())
1435 return Base->isRValueReferenceType() == D->isRValueReferenceType();
1440 auto DiagnoseInconsistentRefQualifiers = [&]() {
1443 if (OldMethod->getRefQualifier() == NewMethod->getRefQualifier())
1445 if (OldMethod->isExplicitObjectMemberFunction() ||
1446 NewMethod->isExplicitObjectMemberFunction())
1448 if (!UseMemberUsingDeclRules && (OldMethod->getRefQualifier() ==
RQ_None ||
1449 NewMethod->getRefQualifier() ==
RQ_None)) {
1450 SemaRef.
Diag(NewMethod->getLocation(), diag::err_ref_qualifier_overload)
1451 << NewMethod->getRefQualifier() << OldMethod->getRefQualifier();
1452 SemaRef.
Diag(OldMethod->getLocation(), diag::note_previous_declaration);
1458 if (OldMethod && OldMethod->isExplicitObjectMemberFunction())
1460 if (NewMethod && NewMethod->isExplicitObjectMemberFunction())
1463 if (OldType->getNumParams() - OldParamsOffset !=
1464 NewType->getNumParams() - NewParamsOffset ||
1466 {OldType->param_type_begin() + OldParamsOffset,
1467 OldType->param_type_end()},
1468 {NewType->param_type_begin() + NewParamsOffset,
1469 NewType->param_type_end()},
1474 if (OldMethod && NewMethod && !OldMethod->isStatic() &&
1475 !OldMethod->isStatic()) {
1476 bool HaveCorrespondingObjectParameters = [&](
const CXXMethodDecl *Old,
1478 auto NewObjectType = New->getFunctionObjectParameterReferenceType();
1482 return F->getRefQualifier() ==
RQ_None &&
1483 !F->isExplicitObjectMemberFunction();
1486 if (IsImplicitWithNoRefQual(Old) != IsImplicitWithNoRefQual(New) &&
1487 CompareType(OldObjectType.getNonReferenceType(),
1488 NewObjectType.getNonReferenceType()))
1490 return CompareType(OldObjectType, NewObjectType);
1491 }(OldMethod, NewMethod);
1493 if (!HaveCorrespondingObjectParameters) {
1494 if (DiagnoseInconsistentRefQualifiers())
1499 if (!UseOverrideRules || (!NewMethod->isExplicitObjectMemberFunction() &&
1500 !OldMethod->isExplicitObjectMemberFunction()))
1505 if (!UseOverrideRules) {
1508 if ((NewRC !=
nullptr) != (OldRC !=
nullptr))
1515 if (NewMethod && OldMethod && OldMethod->isImplicitObjectMemberFunction() &&
1516 NewMethod->isImplicitObjectMemberFunction()) {
1517 if (DiagnoseInconsistentRefQualifiers())
1535 NewI != NewE || OldI != OldE; ++NewI, ++OldI) {
1536 if (NewI == NewE || OldI == OldE)
1538 llvm::FoldingSetNodeID NewID, OldID;
1540 OldI->getCond()->Profile(OldID, SemaRef.
Context,
true);
1545 if (SemaRef.
getLangOpts().CUDA && ConsiderCudaAttrs) {
1548 if (!isa<CXXDestructorDecl>(New)) {
1553 "Unexpected invalid target.");
1557 if (NewTarget != OldTarget)
1568 bool UseMemberUsingDeclRules,
bool ConsiderCudaAttrs) {
1574 bool UseMemberUsingDeclRules,
bool ConsiderCudaAttrs) {
1587 bool SuppressUserConversions,
1589 bool InOverloadResolution,
1591 bool AllowObjCWritebackConversion,
1592 bool AllowObjCConversionOnExplicit) {
1595 if (SuppressUserConversions) {
1606 Conversions, AllowExplicit,
1607 AllowObjCConversionOnExplicit)) {
1624 if (Constructor->isCopyConstructor() &&
1625 (FromCanon == ToCanon ||
1636 if (ToCanon != FromCanon)
1647 Cand != Conversions.
end(); ++Cand)
1690 bool SuppressUserConversions,
1692 bool InOverloadResolution,
1694 bool AllowObjCWritebackConversion,
1695 bool AllowObjCConversionOnExplicit) {
1698 ICS.
Standard, CStyle, AllowObjCWritebackConversion)){
1738 AllowExplicit, InOverloadResolution, CStyle,
1739 AllowObjCWritebackConversion,
1740 AllowObjCConversionOnExplicit);
1745 bool SuppressUserConversions,
1747 bool InOverloadResolution,
1749 bool AllowObjCWritebackConversion) {
1750 return ::TryImplicitConversion(*
this, From, ToType, SuppressUserConversions,
1751 AllowExplicit, InOverloadResolution, CStyle,
1752 AllowObjCWritebackConversion,
1763 bool AllowExplicit) {
1768 bool AllowObjCWritebackConversion
1769 = getLangOpts().ObjCAutoRefCount &&
1770 (Action == AA_Passing || Action == AA_Sending);
1771 if (getLangOpts().ObjC)
1772 CheckObjCBridgeRelatedConversions(From->
getBeginLoc(), ToType,
1775 *
this, From, ToType,
1777 AllowExplicit ? AllowedExplicit::All : AllowedExplicit::None,
1779 false, AllowObjCWritebackConversion,
1781 return PerformImplicitConversion(From, ToType, ICS, Action);
1802 if (TyClass != CanFrom->getTypeClass())
return false;
1803 if (TyClass != Type::FunctionProto && TyClass != Type::FunctionNoProto) {
1804 if (TyClass == Type::Pointer) {
1807 }
else if (TyClass == Type::BlockPointer) {
1810 }
else if (TyClass == Type::MemberPointer) {
1814 if (ToMPT->getClass() != FromMPT->
getClass())
1816 CanTo = ToMPT->getPointeeType();
1822 TyClass = CanTo->getTypeClass();
1823 if (TyClass != CanFrom->getTypeClass())
return false;
1824 if (TyClass != Type::FunctionProto && TyClass != Type::FunctionNoProto)
1828 const auto *FromFn = cast<FunctionType>(CanFrom);
1831 const auto *ToFn = cast<FunctionType>(CanTo);
1834 bool Changed =
false;
1843 if (
const auto *FromFPT = dyn_cast<FunctionProtoType>(FromFn)) {
1844 const auto *ToFPT = cast<FunctionProtoType>(ToFn);
1845 if (FromFPT->isNothrow() && !ToFPT->isNothrow()) {
1846 FromFn = cast<FunctionType>(
1857 bool CanUseToFPT, CanUseFromFPT;
1859 CanUseFromFPT, NewParamInfos) &&
1860 CanUseToFPT && !CanUseFromFPT) {
1863 NewParamInfos.empty() ? nullptr : NewParamInfos.data();
1865 FromFPT->getParamTypes(), ExtInfo);
1874 assert(
QualType(FromFn, 0).isCanonical());
1875 if (
QualType(FromFn, 0) != CanTo)
return false;
1903 if ((&FromSem == &llvm::APFloat::PPCDoubleDouble() &&
1904 &ToSem == &llvm::APFloat::IEEEquad()) ||
1905 (&FromSem == &llvm::APFloat::IEEEquad() &&
1906 &ToSem == &llvm::APFloat::PPCDoubleDouble()))
1961 bool InOverloadResolution,
bool CStyle) {
1978 if (FromElts < ToElts)
1980 if (FromElts == ToElts)
2029 !ToType->
hasAttr(attr::ArmMveStrictPolymorphism))) {
2034 !InOverloadResolution && !CStyle) {
2036 << FromType << ToType;
2047 bool InOverloadResolution,
2060 bool InOverloadResolution,
2063 bool AllowObjCWritebackConversion) {
2110 if (Method && !Method->
isStatic() &&
2113 "Non-unary operator on non-static member address");
2114 assert(cast<UnaryOperator>(From->
IgnoreParens())->getOpcode()
2116 "Non-address-of operator on non-static member address");
2117 const Type *ClassType
2121 assert(cast<UnaryOperator>(From->
IgnoreParens())->getOpcode() ==
2123 "Non-address-of operator for overloaded function expression");
2143 FromType =
Atomic->getValueType();
2178 if (
auto *FD = dyn_cast<FunctionDecl>(DRE->getDecl()))
2198 bool IncompatibleObjC =
false;
2253 }
else if (AllowObjCWritebackConversion &&
2257 FromType, IncompatibleObjC)) {
2263 InOverloadResolution, FromType)) {
2267 From, InOverloadResolution, CStyle)) {
2277 S, From, ToType, InOverloadResolution, SCS, CStyle)) {
2313 bool ObjCLifetimeConversion;
2319 ObjCLifetimeConversion)) {
2338 CanonFrom = CanonTo;
2343 if (CanonFrom == CanonTo)
2348 if (S.
getLangOpts().CPlusPlus || !InOverloadResolution)
2392 bool InOverloadResolution,
2402 for (
const auto *it : UD->
fields()) {
2405 ToType = it->getType();
2435 return To->
getKind() == BuiltinType::Int;
2438 return To->
getKind() == BuiltinType::UInt;
2462 if (FromEnumType->getDecl()->isScoped())
2469 if (FromEnumType->getDecl()->isFixed()) {
2470 QualType Underlying = FromEnumType->getDecl()->getIntegerType();
2472 IsIntegralPromotion(
nullptr, Underlying, ToType);
2479 ToType, FromEnumType->getDecl()->getPromotionType());
2504 uint64_t FromSize = Context.
getTypeSize(FromType);
2513 for (
int Idx = 0; Idx < 6; ++Idx) {
2514 uint64_t ToSize = Context.
getTypeSize(PromoteTypes[Idx]);
2515 if (FromSize < ToSize ||
2516 (FromSize == ToSize &&
2517 FromIsSigned == PromoteTypes[Idx]->isSignedIntegerType())) {
2542 std::optional<llvm::APSInt> BitWidth;
2545 MemberDecl->getBitWidth()->getIntegerConstantExpr(Context))) {
2546 llvm::APSInt ToSize(BitWidth->getBitWidth(), BitWidth->isUnsigned());
2550 if (*BitWidth < ToSize ||
2552 return To->
getKind() == BuiltinType::Int;
2558 return To->
getKind() == BuiltinType::UInt;
2588 if (FromBuiltin->getKind() == BuiltinType::Float &&
2589 ToBuiltin->getKind() == BuiltinType::Double)
2596 (FromBuiltin->getKind() == BuiltinType::Float ||
2597 FromBuiltin->getKind() == BuiltinType::Double) &&
2598 (ToBuiltin->getKind() == BuiltinType::LongDouble ||
2599 ToBuiltin->getKind() == BuiltinType::Float128 ||
2600 ToBuiltin->getKind() == BuiltinType::Ibm128))
2604 if (!getLangOpts().NativeHalfType &&
2605 FromBuiltin->getKind() == BuiltinType::Half &&
2606 ToBuiltin->getKind() == BuiltinType::Float)
2643 bool StripObjCLifetime =
false) {
2646 "Invalid similarly-qualified pointer type");
2657 if (StripObjCLifetime)
2668 if (isa<ObjCObjectPointerType>(ToType))
2677 if (isa<ObjCObjectPointerType>(ToType))
2683 bool InOverloadResolution,
2689 return !InOverloadResolution;
2713 bool InOverloadResolution,
2715 bool &IncompatibleObjC) {
2716 IncompatibleObjC =
false;
2717 if (isObjCPointerConversion(FromType, ToType, ConvertedType,
2724 ConvertedType = ToType;
2731 ConvertedType = ToType;
2738 ConvertedType = ToType;
2746 ConvertedType = ToType;
2756 ConvertedType = ToType;
2764 !getLangOpts().ObjCAutoRefCount) {
2794 if (getLangOpts().MSVCCompat && FromPointeeType->
isFunctionType() &&
2828 IsDerivedFrom(From->
getBeginLoc(), FromPointeeType, ToPointeeType)) {
2865 bool &IncompatibleObjC) {
2866 if (!getLangOpts().
ObjC)
2878 if (ToObjCPtr && FromObjCPtr) {
2889 if (getLangOpts().CPlusPlus && LHS && RHS &&
2891 FromObjCPtr->getPointeeType()))
2896 ConvertedType =
AdoptQualifiers(Context, ConvertedType, FromQualifiers);
2904 IncompatibleObjC =
true;
2908 ConvertedType =
AdoptQualifiers(Context, ConvertedType, FromQualifiers);
2920 if (FromObjCPtr && FromObjCPtr->isObjCBuiltinType()) {
2948 isObjCPointerConversion(FromPointeeType, ToPointeeType, ConvertedType,
2949 IncompatibleObjC)) {
2951 IncompatibleObjC =
true;
2953 ConvertedType =
AdoptQualifiers(Context, ConvertedType, FromQualifiers);
2960 isObjCPointerConversion(FromPointeeType, ToPointeeType, ConvertedType,
2961 IncompatibleObjC)) {
2964 ConvertedType =
AdoptQualifiers(Context, ConvertedType, FromQualifiers);
2976 if (FromFunctionType && ToFunctionType) {
2985 if (FromFunctionType->
getNumParams() != ToFunctionType->getNumParams() ||
2986 FromFunctionType->
isVariadic() != ToFunctionType->isVariadic() ||
2987 FromFunctionType->
getMethodQuals() != ToFunctionType->getMethodQuals())
2990 bool HasObjCConversion =
false;
2994 }
else if (isObjCPointerConversion(FromFunctionType->
getReturnType(),
2995 ToFunctionType->getReturnType(),
2996 ConvertedType, IncompatibleObjC)) {
2998 HasObjCConversion =
true;
3005 for (
unsigned ArgIdx = 0, NumArgs = FromFunctionType->
getNumParams();
3006 ArgIdx != NumArgs; ++ArgIdx) {
3008 QualType ToArgType = ToFunctionType->getParamType(ArgIdx);
3012 }
else if (isObjCPointerConversion(FromArgType, ToArgType,
3013 ConvertedType, IncompatibleObjC)) {
3015 HasObjCConversion =
true;
3022 if (HasObjCConversion) {
3026 IncompatibleObjC =
true;
3045 if (!getLangOpts().ObjCAutoRefCount ||
3087 bool IncompatibleObjC;
3089 FromPointee = ToPointee;
3090 else if (!isObjCPointerConversion(FromPointee, ToPointee, FromPointee,
3125 if (!FromFunctionType || !ToFunctionType)
3128 if (Context.
hasSameType(FromPointeeType, ToPointeeType))
3133 if (FromFunctionType->
getNumParams() != ToFunctionType->getNumParams() ||
3134 FromFunctionType->
isVariadic() != ToFunctionType->isVariadic())
3139 if (FromEInfo != ToEInfo)
3142 bool IncompatibleObjC =
false;
3144 ToFunctionType->getReturnType())) {
3148 QualType LHS = ToFunctionType->getReturnType();
3149 if ((!getLangOpts().CPlusPlus || !RHS->
isRecordType()) &&
3155 }
else if (isObjCPointerConversion(RHS, LHS,
3156 ConvertedType, IncompatibleObjC)) {
3157 if (IncompatibleObjC)
3166 for (
unsigned ArgIdx = 0, NumArgs = FromFunctionType->
getNumParams();
3167 ArgIdx != NumArgs; ++ArgIdx) {
3168 IncompatibleObjC =
false;
3170 QualType ToArgType = ToFunctionType->getParamType(ArgIdx);
3171 if (Context.
hasSameType(FromArgType, ToArgType)) {
3173 }
else if (isObjCPointerConversion(ToArgType, FromArgType,
3174 ConvertedType, IncompatibleObjC)) {
3175 if (IncompatibleObjC)
3184 bool CanUseToFPT, CanUseFromFPT;
3186 CanUseToFPT, CanUseFromFPT,
3190 ConvertedType = ToType;
3231 if (!Context.
hasSameType(FromMember->getClass(), ToMember->getClass())) {
3233 <<
QualType(FromMember->getClass(), 0);
3266 if (!FromFunction || !ToFunction) {
3271 if (FromFunction->
getNumParams() != ToFunction->getNumParams()) {
3279 if (!FunctionParamTypesAreEqual(FromFunction, ToFunction, &ArgPos)) {
3281 << ToFunction->getParamType(ArgPos)
3288 ToFunction->getReturnType())) {
3294 if (FromFunction->
getMethodQuals() != ToFunction->getMethodQuals()) {
3304 cast<FunctionProtoType>(ToFunction->getCanonicalTypeUnqualified())
3324 assert(llvm::size(Old) == llvm::size(New) &&
3325 "Can't compare parameters of functions with different number of "
3328 for (
auto &&[Idx,
Type] : llvm::enumerate(Old)) {
3330 size_t J =
Reversed ? (llvm::size(New) - Idx - 1) : Idx;
3351 return FunctionParamTypesAreEqual(OldType->
param_types(),
3364 unsigned OldIgnore =
3366 unsigned NewIgnore =
3369 auto *OldPT = cast<FunctionProtoType>(OldFunction->
getFunctionType());
3370 auto *NewPT = cast<FunctionProtoType>(NewFunction->
getFunctionType());
3372 return FunctionParamTypesAreEqual(OldPT->param_types().slice(OldIgnore),
3373 NewPT->param_types().slice(NewIgnore),
3386 bool IgnoreBaseAccess,
3389 bool IsCStyleOrFunctionalCast = IgnoreBaseAccess;
3393 if (Diagnose && !IsCStyleOrFunctionalCast && !FromType->
isAnyPointerType() &&
3397 DiagRuntimeBehavior(From->
getExprLoc(), From,
3398 PDiag(diag::warn_impcast_bool_to_null_pointer)
3400 else if (!isUnevaluatedContext())
3409 if (FromPointeeType->
isRecordType() && ToPointeeType->isRecordType() &&
3413 unsigned InaccessibleID = 0;
3414 unsigned AmbiguousID = 0;
3416 InaccessibleID = diag::err_upcast_to_inaccessible_base;
3417 AmbiguousID = diag::err_ambiguous_derived_to_base_conv;
3419 if (CheckDerivedToBaseConversion(
3420 FromPointeeType, ToPointeeType, InaccessibleID, AmbiguousID,
3422 &BasePath, IgnoreBaseAccess))
3426 Kind = CK_DerivedToBase;
3429 if (Diagnose && !IsCStyleOrFunctionalCast &&
3430 FromPointeeType->
isFunctionType() && ToPointeeType->isVoidType()) {
3431 assert(getLangOpts().MSVCCompat &&
3432 "this should only be possible with MSVCCompat!");
3444 if (FromPtrType->isObjCBuiltinType() || ToPtrType->isObjCBuiltinType())
3447 Kind = CK_BlockPointerToObjCPointerCast;
3449 Kind = CK_CPointerToObjCPointerCast;
3453 Kind = CK_AnyPointerToBlockPointerCast;
3459 Kind = CK_NullToPointer;
3471 bool InOverloadResolution,
3481 ConvertedType = ToType;
3496 IsDerivedFrom(From->
getBeginLoc(), ToClass, FromClass)) {
3514 bool IgnoreBaseAccess) {
3521 "Expr must be null pointer constant!");
3522 Kind = CK_NullToMemberPointer;
3527 assert(ToPtrType &&
"No member pointer cast has a target type "
3528 "that is not a member pointer.");
3534 assert(FromClass->
isRecordType() &&
"Pointer into non-class.");
3535 assert(ToClass->
isRecordType() &&
"Pointer into non-class.");
3539 bool DerivationOkay =
3540 IsDerivedFrom(From->
getBeginLoc(), ToClass, FromClass, Paths);
3541 assert(DerivationOkay &&
3542 "Should not have been called if derivation isn't OK.");
3543 (void)DerivationOkay;
3546 getUnqualifiedType())) {
3547 std::string PathDisplayStr = getAmbiguousPathsDisplayString(Paths);
3549 << 0 << FromClass << ToClass << PathDisplayStr << From->
getSourceRange();
3553 if (
const RecordType *VBase = Paths.getDetectedVirtual()) {
3555 << FromClass << ToClass <<
QualType(VBase, 0)
3560 if (!IgnoreBaseAccess)
3561 CheckBaseClassAccess(From->
getExprLoc(), FromClass, ToClass,
3563 diag::err_downcast_from_inaccessible_base);
3567 Kind = CK_BaseToDerivedMemberPointer;
3590 bool CStyle,
bool IsTopLevel,
3591 bool &PreviousToQualsIncludeConst,
3592 bool &ObjCLifetimeConversion) {
3604 ObjCLifetimeConversion =
true;
3640 !PreviousToQualsIncludeConst)
3658 PreviousToQualsIncludeConst =
3659 PreviousToQualsIncludeConst && ToQuals.
hasConst();
3672 bool CStyle,
bool &ObjCLifetimeConversion) {
3675 ObjCLifetimeConversion =
false;
3685 bool PreviousToQualsIncludeConst =
true;
3686 bool UnwrappedAnyPointer =
false;
3689 FromType, ToType, CStyle, !UnwrappedAnyPointer,
3690 PreviousToQualsIncludeConst, ObjCLifetimeConversion))
3692 UnwrappedAnyPointer =
true;
3709 bool InOverloadResolution,
3718 InOverloadResolution, InnerSCS,
3735 if (CtorType->getNumParams() > 0) {
3736 QualType FirstArg = CtorType->getParamType(0);
3748 bool AllowExplicit) {
3755 bool Usable = !Info.Constructor->isInvalidDecl() &&
3758 bool SuppressUserConversions =
false;
3759 if (Info.ConstructorTmpl)
3762 CandidateSet, SuppressUserConversions,
3767 CandidateSet, SuppressUserConversions,
3768 false, AllowExplicit);
3772 bool HadMultipleCandidates = (CandidateSet.
size() > 1);
3781 QualType ThisType = Constructor->getFunctionObjectParameterType();
3799 llvm_unreachable(
"Invalid OverloadResult!");
3821 bool AllowObjCConversionOnExplicit) {
3822 assert(AllowExplicit != AllowedExplicit::None ||
3823 !AllowObjCConversionOnExplicit);
3827 bool ConstructorsOnly =
false;
3843 ConstructorsOnly =
true;
3848 = dyn_cast<CXXRecordDecl>(ToRecordType->getDecl())) {
3850 Expr **Args = &From;
3851 unsigned NumArgs = 1;
3852 bool ListInitializing =
false;
3853 if (
InitListExpr *InitList = dyn_cast<InitListExpr>(From)) {
3856 S, From, ToType, ToRecordDecl, User, CandidateSet,
3857 AllowExplicit == AllowedExplicit::All);
3866 Args = InitList->getInits();
3867 NumArgs = InitList->getNumInits();
3868 ListInitializing =
true;
3876 bool Usable = !Info.Constructor->isInvalidDecl();
3877 if (!ListInitializing)
3878 Usable = Usable && Info.Constructor->isConvertingConstructor(
3881 bool SuppressUserConversions = !ConstructorsOnly;
3889 if (SuppressUserConversions && ListInitializing) {
3890 SuppressUserConversions =
3891 NumArgs == 1 && isa<InitListExpr>(Args[0]) &&
3895 if (Info.ConstructorTmpl)
3897 Info.ConstructorTmpl, Info.FoundDecl,
3899 CandidateSet, SuppressUserConversions,
3901 AllowExplicit == AllowedExplicit::All);
3907 SuppressUserConversions,
3909 AllowExplicit == AllowedExplicit::All);
3916 if (ConstructorsOnly || isa<InitListExpr>(From)) {
3919 }
else if (
const RecordType *FromRecordType =
3922 = dyn_cast<CXXRecordDecl>(FromRecordType->getDecl())) {
3924 const auto &Conversions = FromRecordDecl->getVisibleConversionFunctions();
3925 for (
auto I = Conversions.begin(), E = Conversions.end(); I != E; ++I) {
3929 if (isa<UsingShadowDecl>(D))
3930 D = cast<UsingShadowDecl>(D)->getTargetDecl();
3934 if ((ConvTemplate = dyn_cast<FunctionTemplateDecl>(D)))
3937 Conv = cast<CXXConversionDecl>(D);
3941 ConvTemplate, FoundDecl, ActingContext, From, ToType,
3942 CandidateSet, AllowObjCConversionOnExplicit,
3943 AllowExplicit != AllowedExplicit::None);
3946 CandidateSet, AllowObjCConversionOnExplicit,
3947 AllowExplicit != AllowedExplicit::None);
3952 bool HadMultipleCandidates = (CandidateSet.
size() > 1);
3961 = dyn_cast<CXXConstructorDecl>(Best->Function)) {
3968 if (isa<InitListExpr>(From)) {
3972 if (Best->Conversions[0].isEllipsis())
3975 User.
Before = Best->Conversions[0].Standard;
3988 = dyn_cast<CXXConversionDecl>(Best->Function)) {
3995 User.
Before = Best->Conversions[0].Standard;
4010 User.
After = Best->FinalConversion;
4013 llvm_unreachable(
"Not a constructor or conversion function?");
4022 llvm_unreachable(
"Invalid OverloadResult!");
4032 CandidateSet, AllowedExplicit::None,
false);
4046 if (!RequireCompleteType(From->
getBeginLoc(), ToType,
4047 diag::err_typecheck_nonviable_condition_incomplete,
4054 *
this, From, Cands);
4080 if (!Conv1 || !Conv2)
4095 if (Block1 != Block2)
4108 if (Conv1FuncRet && Conv2FuncRet &&
4119 CallOpProto->isVariadic(),
false);
4121 CallOpProto->isVariadic(),
true);
4123 CallingConv PrefOrder[] = {DefaultFree, DefaultMember, CallOpCC};
4218 if (!ICS1.
isBad()) {
4219 bool StdInit1 =
false, StdInit2 =
false;
4226 if (StdInit1 != StdInit2)
4237 CAT2->getElementType())) {
4239 if (CAT1->getSize() != CAT2->getSize())
4241 return CAT1->getSize().ult(CAT2->getSize())
4363 return FixedEnumPromotion::None;
4367 return FixedEnumPromotion::None;
4370 if (!
Enum->isFixed())
4371 return FixedEnumPromotion::None;
4375 return FixedEnumPromotion::ToUnderlyingType;
4377 return FixedEnumPromotion::ToPromotedUnderlyingType;
4406 else if (Rank2 < Rank1)
4429 if (FEP1 != FixedEnumPromotion::None && FEP2 != FixedEnumPromotion::None &&
4431 return FEP1 == FixedEnumPromotion::ToUnderlyingType
4441 bool SCS1ConvertsToVoid
4443 bool SCS2ConvertsToVoid
4445 if (SCS1ConvertsToVoid != SCS2ConvertsToVoid) {
4450 }
else if (!SCS1ConvertsToVoid && !SCS2ConvertsToVoid) {
4456 }
else if (SCS1ConvertsToVoid && SCS2ConvertsToVoid &&
4485 if (FromObjCPtr1 && FromObjCPtr2) {
4490 if (AssignLeft != AssignRight) {
4525 if (UnqualT1 == UnqualT2) {
4537 if (isa<ArrayType>(T1) && T1Quals)
4539 if (isa<ArrayType>(T2) && T2Quals)
4587 if (SCS1IsCompatibleVectorConversion != SCS2IsCompatibleVectorConversion)
4588 return SCS1IsCompatibleVectorConversion
4595 bool SCS1IsCompatibleSVEVectorConversion =
4597 bool SCS2IsCompatibleSVEVectorConversion =
4600 if (SCS1IsCompatibleSVEVectorConversion !=
4601 SCS2IsCompatibleSVEVectorConversion)
4602 return SCS1IsCompatibleSVEVectorConversion
4609 bool SCS1IsCompatibleRVVVectorConversion =
4611 bool SCS2IsCompatibleRVVVectorConversion =
4614 if (SCS1IsCompatibleRVVVectorConversion !=
4615 SCS2IsCompatibleRVVVectorConversion)
4616 return SCS1IsCompatibleRVVVectorConversion
4657 if (UnqualT1 == UnqualT2)
4675 bool ObjCLifetimeConversion;
4685 if (CanPick1 != CanPick2)
4739 if (FromPointee1 == FromPointee2 && ToPointee1 != ToPointee2) {
4747 if (FromPointee1 != FromPointee2 && ToPointee1 == ToPointee2) {
4764 if (FromPtr1 && FromPtr2 && ToPtr1 && ToPtr2) {
4771 bool FromAssignRight
4780 if (ToPtr1->isObjCIdType() &&
4781 (ToPtr2->isObjCQualifiedIdType() || ToPtr2->getInterfaceDecl()))
4783 if (ToPtr2->isObjCIdType() &&
4784 (ToPtr1->isObjCQualifiedIdType() || ToPtr1->getInterfaceDecl()))
4789 if (ToPtr1->isObjCQualifiedIdType() && ToPtr2->getInterfaceDecl())
4791 if (ToPtr2->isObjCQualifiedIdType() && ToPtr1->getInterfaceDecl())
4796 if (ToPtr1->isObjCClassType() &&
4797 (ToPtr2->isObjCQualifiedClassType() || ToPtr2->getInterfaceDecl()))
4799 if (ToPtr2->isObjCClassType() &&
4800 (ToPtr1->isObjCQualifiedClassType() || ToPtr1->getInterfaceDecl()))
4805 if (ToPtr1->isObjCQualifiedClassType() && ToPtr2->getInterfaceDecl())
4807 if (ToPtr2->isObjCQualifiedClassType() && ToPtr1->getInterfaceDecl())
4813 (ToAssignLeft != ToAssignRight)) {
4824 }
else if (IsSecondSame)
4833 (FromAssignLeft != FromAssignRight))
4847 const Type *FromPointeeType1 = FromMemPointer1->getClass();
4848 const Type *ToPointeeType1 = ToMemPointer1->
getClass();
4849 const Type *FromPointeeType2 = FromMemPointer2->
getClass();
4850 const Type *ToPointeeType2 = ToMemPointer2->
getClass();
4856 if (FromPointee1 == FromPointee2 && ToPointee1 != ToPointee2) {
4863 if (ToPointee1 == ToPointee2 && FromPointee1 != FromPointee2) {
4921 "T1 must be the pointee type of the reference type");
4922 assert(!OrigT2->
isReferenceType() &&
"T2 cannot be a reference type");
4946 if (UnqualT1 == UnqualT2) {
4948 }
else if (isCompleteType(Loc, OrigT2) &&
4949 IsDerivedFrom(Loc, UnqualT2, UnqualT1))
4950 Conv |= ReferenceConversions::DerivedToBase;
4954 Conv |= ReferenceConversions::ObjC;
4956 IsFunctionConversion(UnqualT2, UnqualT1, ConvertedT2)) {
4957 Conv |= ReferenceConversions::Function;
4959 return Ref_Compatible;
4961 bool ConvertedReferent = Conv != 0;
4965 bool PreviousToQualsIncludeConst =
true;
4966 bool TopLevel =
true;
4972 Conv |= ReferenceConversions::Qualification;
4978 Conv |= ReferenceConversions::NestedQualification;
4986 bool ObjCLifetimeConversion =
false;
4988 PreviousToQualsIncludeConst,
4989 ObjCLifetimeConversion))
4995 if (ObjCLifetimeConversion)
4996 Conv |= ReferenceConversions::ObjCLifetime;
5015 bool AllowExplicit) {
5016 assert(T2->
isRecordType() &&
"Can only find conversions of record types.");
5021 const auto &Conversions = T2RecordDecl->getVisibleConversionFunctions();
5022 for (
auto I = Conversions.begin(), E = Conversions.end(); I != E; ++I) {
5025 if (isa<UsingShadowDecl>(D))
5026 D = cast<UsingShadowDecl>(D)->getTargetDecl();
5029 = dyn_cast<FunctionTemplateDecl>(D);
5034 Conv = cast<CXXConversionDecl>(D);
5046 if (!ConvTemplate &&
5070 ConvTemplate, I.getPair(), ActingDC,
Init, DeclType, CandidateSet,
5071 false, AllowExplicit);
5074 Conv, I.getPair(), ActingDC,
Init, DeclType, CandidateSet,
5075 false, AllowExplicit);
5078 bool HadMultipleCandidates = (CandidateSet.
size() > 1);
5093 if (!Best->FinalConversion.DirectBinding)
5105 "Expected a direct reference binding!");
5111 Cand != CandidateSet.
end(); ++Cand)
5123 llvm_unreachable(
"Invalid OverloadResult!");
5131 bool SuppressUserConversions,
5132 bool AllowExplicit) {
5133 assert(DeclType->
isReferenceType() &&
"Reference init needs a reference");
5160 auto SetAsReferenceBinding = [&](
bool BindsDirectly) {
5165 ICS.
Standard.
Second = (RefConv & Sema::ReferenceConversions::DerivedToBase)
5167 : (RefConv & Sema::ReferenceConversions::ObjC)
5175 Sema::ReferenceConversions::NestedQualification)
5189 (RefConv & Sema::ReferenceConversions::ObjCLifetime) != 0;
5212 SetAsReferenceBinding(
true);
5261 SetAsReferenceBinding(S.
getLangOpts().CPlusPlus11 ||
5352 AllowedExplicit::None,
5377 if (isRValRef && LValRefType) {
5395 bool SuppressUserConversions,
5396 bool InOverloadResolution,
5397 bool AllowObjCWritebackConversion,
5398 bool AllowExplicit =
false);
5404 bool SuppressUserConversions,
5405 bool InOverloadResolution,
5406 bool AllowObjCWritebackConversion) {
5419 if (
const auto *IAT = dyn_cast<IncompleteArrayType>(AT))
5421 InitTy = IAT->getElementType();
5447 if (From->
getNumInits() == 1 && !IsDesignatedInit) {
5453 SuppressUserConversions,
5454 InOverloadResolution,
5455 AllowObjCWritebackConversion);
5464 Result.Standard.setAsIdentityConversion();
5465 Result.Standard.setFromType(ToType);
5466 Result.Standard.setAllToTypes(ToType);
5491 bool IsUnbounded =
false;
5495 if (CT->getSize().ult(e)) {
5499 Result.setInitializerListContainerType(ContTy, IsUnbounded);
5502 if (CT->getSize().ugt(e)) {
5508 S, &EmptyList, InitTy, SuppressUserConversions,
5509 InOverloadResolution, AllowObjCWritebackConversion);
5510 if (DfltElt.
isBad()) {
5514 Result.setInitializerListContainerType(ContTy, IsUnbounded);
5519 assert(isa<IncompleteArrayType>(AT) &&
"Expected incomplete array");
5525 Result.setInitializerListContainerType(ContTy, IsUnbounded);
5535 Result.Standard.setAsIdentityConversion();
5536 Result.Standard.setFromType(InitTy);
5537 Result.Standard.setAllToTypes(InitTy);
5538 for (
unsigned i = 0; i < e; ++i) {
5541 S,
Init, InitTy, SuppressUserConversions, InOverloadResolution,
5542 AllowObjCWritebackConversion);
5553 Result.setInitializerListContainerType(ContTy, IsUnbounded);
5567 Result.setInitializerListContainerType(ContTy, IsUnbounded);
5581 AllowedExplicit::None,
5582 InOverloadResolution,
false,
5583 AllowObjCWritebackConversion,
5602 Result.UserDefined.Before.setAsIdentityConversion();
5607 Result.UserDefined.After.setAsIdentityConversion();
5608 Result.UserDefined.After.setFromType(ToType);
5609 Result.UserDefined.After.setAllToTypes(ToType);
5610 Result.UserDefined.ConversionFunction =
nullptr;
5627 if (From->
getNumInits() == 1 && !IsDesignatedInit) {
5638 Init, ToType,
false, Found))
5648 SuppressUserConversions,
5656 InOverloadResolution,
5657 AllowObjCWritebackConversion);
5660 assert(!
Result.isEllipsis() &&
5661 "Sub-initialization cannot result in ellipsis conversion.");
5667 Result.UserDefined.After;
5688 if (NumInits == 1 && !isa<InitListExpr>(From->
getInit(0)))
5690 SuppressUserConversions,
5691 InOverloadResolution,
5692 AllowObjCWritebackConversion);
5695 else if (NumInits == 0) {
5697 Result.Standard.setAsIdentityConversion();
5698 Result.Standard.setFromType(ToType);
5699 Result.Standard.setAllToTypes(ToType);
5718 bool SuppressUserConversions,
5719 bool InOverloadResolution,
5720 bool AllowObjCWritebackConversion,
5721 bool AllowExplicit) {
5722 if (
InitListExpr *FromInitList = dyn_cast<InitListExpr>(From))
5724 InOverloadResolution,AllowObjCWritebackConversion);
5729 SuppressUserConversions, AllowExplicit);
5732 SuppressUserConversions,
5733 AllowedExplicit::None,
5734 InOverloadResolution,
5736 AllowObjCWritebackConversion,
5749 return !ICS.
isBad();
5758 const CXXRecordDecl *ActingContext,
bool InOverloadResolution =
false,
5760 bool SuppressUserConversion =
false) {
5768 assert(FromClassification.
isLValue());
5780 if (ExplicitParameterType.isNull())
5783 ValueKindFromClassification(FromClassification));
5785 S, &TmpExpr, ExplicitParameterType, SuppressUserConversion,
5803 if (isa<CXXDestructorDecl>(Method) || Method->
isStatic()) {
5840 FromType, ImplicitParamType);
5849 FromType, ImplicitParamType);
5864 FromType, ImplicitParamType);
5884 if (!FromClassification.
isRValue()) {
5924 FromRecordType = From->
getType();
5925 DestType = ImplicitParamRecordType;
5926 FromClassification = From->
Classify(Context);
5930 From = CreateMaterializeTemporaryExpr(FromRecordType, From,
5949 << Method->
getDeclName() << FromRecordType << (CVR - 1)
5960 bool IsRValueQualified =
5964 << IsRValueQualified;
5976 llvm_unreachable(
"Lists are not objects");
5979 return Diag(From->
getBeginLoc(), diag::err_member_function_call_bad_type)
5980 << ImplicitParamRecordType << FromRecordType
5986 PerformObjectMemberConversion(From, Qualifier, FoundDecl, Method);
5989 From = FromRes.
get();
5998 CK = CK_AddressSpaceConversion;
6001 From = ImpCastExprToType(From, DestType, CK, From->
getValueKind()).get();
6023 AllowedExplicit::Conversions,
6038 return PerformImplicitConversion(From, Context.
BoolTy, ICS, AA_Converting);
6040 if (!DiagnoseMultipleUserDefinedConversion(From, Context.
BoolTy))
6103 llvm_unreachable(
"found a first conversion kind in Second");
6107 llvm_unreachable(
"found a third conversion kind in Second");
6113 llvm_unreachable(
"unknown conversion kind");
6125 "converted constant expression outside C++11");
6158 diag::err_typecheck_converted_constant_expression)
6164 llvm_unreachable(
"bad conversion in converted constant expression");
6170 diag::err_typecheck_converted_constant_expression_disallowed)
6176 diag::err_typecheck_converted_constant_expression_indirect)
6186 diag::err_reference_bind_to_bitfield_in_cce)
6196 "unexpected class type converted constant expr");
6199 T, cast<NonTypeTemplateParmDecl>(Dest)),
6216 bool ReturnPreNarrowingValue =
false;
6219 PreNarrowingType)) {
6232 PreNarrowingValue.
isInt()) {
6235 ReturnPreNarrowingValue =
true;
6247 << CCE << 0 << From->
getType() << T;
6250 if (!ReturnPreNarrowingValue)
6251 PreNarrowingValue = {};
6268 if (
Result.isInvalid() ||
Result.get()->isValueDependent()) {
6273 RequireInt, PreNarrowingValue);
6280 return ::BuildConvertedConstantExpression(*
this, From, T, CCE, Dest,
6287 return ::CheckConvertedConstantExpression(*
this, From, T,
Value, CCE,
false,
6292 llvm::APSInt &
Value,
6299 if (!R.isInvalid() && !R.get()->isValueDependent())
6310 const APValue &PreNarrowingValue) {
6320 Kind = ConstantExprKind::ClassTemplateArgument;
6322 Kind = ConstantExprKind::NonClassTemplateArgument;
6324 Kind = ConstantExprKind::Normal;
6327 (RequireInt && !Eval.
Val.
isInt())) {
6334 if (Notes.empty()) {
6337 if (
const auto *CE = dyn_cast<ConstantExpr>(E)) {
6341 "ConstantExpr has no value associated with it");
6346 Value = std::move(PreNarrowingValue);
6352 if (Notes.size() == 1 &&
6353 Notes[0].second.getDiagID() == diag::note_invalid_subexpr_in_const_expr) {
6354 Diag(Notes[0].first, diag::err_expr_not_cce) << CCE;
6355 }
else if (!Notes.empty() && Notes[0].second.getDiagID() ==
6356 diag::note_constexpr_invalid_template_arg) {
6357 Notes[0].second.setDiagID(diag::err_constexpr_invalid_template_arg);
6358 for (
unsigned I = 0; I < Notes.size(); ++I)
6359 Diag(Notes[I].first, Notes[I].second);
6363 for (
unsigned I = 0; I < Notes.size(); ++I)
6364 Diag(Notes[I].first, Notes[I].second);
6391 AllowedExplicit::Conversions,
6428 return PerformImplicitConversion(From, Ty, ICS, AA_Converting);
6434 assert((isa<UnresolvedMemberExpr, MemberExpr>(MemExprE)) &&
6435 "expected a member expression");
6437 if (
const auto M = dyn_cast<UnresolvedMemberExpr>(MemExprE);
6438 M && !M->isImplicitAccess())
6439 Base = M->getBase();
6440 else if (
const auto M = dyn_cast<MemberExpr>(MemExprE);
6441 M && !M->isImplicitAccess())
6442 Base = M->getBase();
6481 "Method is not an explicit member function");
6482 assert(NewArgs.empty() &&
"NewArgs should be empty");
6483 NewArgs.reserve(Args.size() + 1);
6485 NewArgs.push_back(This);
6486 NewArgs.append(Args.begin(), Args.end());
6506 for (
unsigned I = 0, N = ViableConversions.
size(); I != N; ++I) {
6508 cast<CXXConversionDecl>(ViableConversions[I]->getUnderlyingDecl());
6518 QualType T,
bool HadMultipleCandidates,
6520 if (ExplicitConversions.
size() == 1 && !Converter.
Suppress) {
6528 std::string TypeStr;
6533 "static_cast<" + TypeStr +
">(")
6545 HadMultipleCandidates);
6550 CK_UserDefinedConversion,
Result.get(),
6551 nullptr,
Result.get()->getValueKind(),
6559 QualType T,
bool HadMultipleCandidates,
6575 HadMultipleCandidates);
6580 CK_UserDefinedConversion,
Result.get(),
6581 nullptr,
Result.get()->getValueKind(),
6600 for (
unsigned I = 0, N = ViableConversions.
size(); I != N; ++I) {
6604 if (isa<UsingShadowDecl>(D))
6605 D = cast<UsingShadowDecl>(D)->getTargetDecl();
6609 if ((ConvTemplate = dyn_cast<FunctionTemplateDecl>(D)))
6612 Conv = cast<CXXConversionDecl>(D);
6616 ConvTemplate, FoundDecl, ActingContext, From, ToType, CandidateSet,
6620 ToType, CandidateSet,
6652 ExprResult result = CheckPlaceholderExpr(From);
6655 From = result.
get();
6659 ExprResult Converted = DefaultLvalueConversion(From);
6662 if (Converter.
match(T))
6670 if (!RecordTy || !getLangOpts().CPlusPlus) {
6682 : Converter(Converter), From(From) {}
6687 } IncompleteDiagnoser(Converter, From);
6689 if (Converter.
Suppress ? !isCompleteType(Loc, T)
6690 : RequireCompleteType(Loc, T, IncompleteDiagnoser))
6697 const auto &Conversions =
6698 cast<CXXRecordDecl>(RecordTy->
getDecl())->getVisibleConversionFunctions();
6700 bool HadMultipleCandidates =
6701 (std::distance(Conversions.begin(), Conversions.end()) > 1);
6705 bool HasUniqueTargetType =
true;
6708 for (
auto I = Conversions.begin(), E = Conversions.end(); I != E; ++I) {
6718 Conversion = cast<CXXConversionDecl>(D);
6720 assert((!ConvTemplate || getLangOpts().
CPlusPlus14) &&
6721 "Conversion operator templates are considered potentially "
6725 if (Converter.
match(CurToType) || ConvTemplate) {
6731 ExplicitConversions.
addDecl(I.getDecl(), I.getAccess());
6736 else if (HasUniqueTargetType &&
6738 HasUniqueTargetType =
false;
6740 ViableConversions.
addDecl(I.getDecl(), I.getAccess());
6758 HadMultipleCandidates,
6759 ExplicitConversions))
6765 if (!HasUniqueTargetType)
6784 HadMultipleCandidates, Found))
6793 HadMultipleCandidates,
6794 ExplicitConversions))
6802 switch (ViableConversions.
size()) {
6805 HadMultipleCandidates,
6806 ExplicitConversions))
6816 HadMultipleCandidates, Found))
6847 if (Proto->getNumParams() < 1)
6851 QualType ArgType = Proto->getParamType(0).getNonReferenceType();
6856 if (Proto->getNumParams() < 2)
6860 QualType ArgType = Proto->getParamType(1).getNonReferenceType();
6879 bool PartialOverloading,
bool AllowExplicit,
bool AllowExplicitConversions,
6884 assert(Proto &&
"Functions without a prototype cannot be overloaded");
6885 assert(!
Function->getDescribedFunctionTemplate() &&
6886 "Use AddTemplateOverloadCandidate for function templates");
6889 if (!isa<CXXConstructorDecl>(Method)) {
6899 CandidateSet, SuppressUserConversions,
6900 PartialOverloading, EarlyConversions, PO);
6914 if (Constructor && Constructor->isDefaulted() && Constructor->isDeleted() &&
6915 Constructor->isMoveConstructor())
6935 CandidateSet.
addCandidate(Args.size(), EarlyConversions);
6950 Candidate.
Viable =
false;
6956 if (getLangOpts().CPlusPlusModules &&
Function->isInAnotherModuleUnit()) {
6963 if (
auto *SpecInfo =
Function->getTemplateSpecializationInfo())
6964 ND = SpecInfo->getTemplate();
6967 Candidate.
Viable =
false;
6974 ((
Function->hasAttr<TargetAttr>() &&
6975 !
Function->getAttr<TargetAttr>()->isDefaultVersion()) ||
6976 (
Function->hasAttr<TargetVersionAttr>() &&
6977 !
Function->getAttr<TargetVersionAttr>()->isDefaultVersion()))) {
6978 Candidate.
Viable =
false;
6988 if (Args.size() == 1 && Constructor->isSpecializationCopyingObject() &&
6990 IsDerivedFrom(Args[0]->getBeginLoc(), Args[0]->getType(),
6992 Candidate.
Viable =
false;
7004 auto *Shadow = dyn_cast<ConstructorUsingShadowDecl>(FoundDecl.getDecl());
7005 if (Shadow && Args.size() == 1 && Constructor->getNumParams() >= 1 &&
7006 Constructor->getParamDecl(0)->getType()->isReferenceType()) {
7007 QualType P = Constructor->getParamDecl(0)->getType()->getPointeeType();
7013 Candidate.
Viable =
false;
7022 Constructor->getMethodQualifiers().getAddressSpace(),
7024 Candidate.
Viable =
false;
7037 Candidate.
Viable =
false;
7047 unsigned MinRequiredArgs =
Function->getMinRequiredArguments();
7048 if (!AggregateCandidateDeduction && Args.size() < MinRequiredArgs &&
7049 !PartialOverloading) {
7051 Candidate.
Viable =
false;
7057 if (getLangOpts().
CUDA) {
7064 !IsAllowedCUDACall(Caller,
Function)) {
7065 Candidate.
Viable =
false;
7071 if (
Function->getTrailingRequiresClause()) {
7073 if (CheckFunctionConstraints(
Function, Satisfaction, {},
7076 Candidate.
Viable =
false;
7084 for (
unsigned ArgIdx = 0; ArgIdx < Args.size(); ++ArgIdx) {
7087 if (Candidate.
Conversions[ConvIdx].isInitialized()) {
7090 }
else if (ArgIdx < NumParams) {
7097 *
this, Args[ArgIdx], ParamType, SuppressUserConversions,
7100 getLangOpts().ObjCAutoRefCount, AllowExplicitConversions);
7102 Candidate.
Viable =
false;
7114 if (EnableIfAttr *FailedAttr =
7116 Candidate.
Viable =
false;
7126 if (Methods.size() <= 1)
7129 for (
unsigned b = 0, e = Methods.size();
b < e;
b++) {
7137 if (Args.size() < NumNamedArgs)
7140 for (
unsigned i = 0; i < NumNamedArgs; i++) {
7142 if (Args[i]->isTypeDependent()) {
7148 Expr *argExpr = Args[i];
7149 assert(argExpr &&
"SelectBestMethod(): missing expression");
7154 !param->
hasAttr<CFConsumedAttr>())
7155 argExpr = stripARCUnbridgedCast(argExpr);
7168 getLangOpts().ObjCAutoRefCount,
7172 if (ConversionState.
isBad() ||
7182 for (
unsigned i = NumNamedArgs, e = Args.size(); i < e; ++i) {
7183 if (Args[i]->isTypeDependent()) {
7187 ExprResult Arg = DefaultVariadicArgumentPromotion(Args[i], VariadicMethod,
7196 if (Args.size() != NumNamedArgs)
7198 else if (Match && NumNamedArgs == 0 && Methods.size() > 1) {
7201 for (
unsigned b = 0, e = Methods.size();
b < e;
b++) {
7202 QualType ReturnT = Methods[
b]->getReturnType();
7221 assert(!isa<CXXConstructorDecl>(Method) &&
7222 "Shouldn't have `this` for ctors!");
7223 assert(!Method->
isStatic() &&
"Shouldn't have `this` for static methods!");
7225 ThisArg,
nullptr, Method, Method);
7228 ConvertedThis = R.
get();
7230 if (
auto *MD = dyn_cast<CXXMethodDecl>(
Function)) {
7232 assert((MissingImplicitThis || MD->isStatic() ||
7233 isa<CXXConstructorDecl>(MD)) &&
7234 "Expected `this` for non-ctor instance methods");
7236 ConvertedThis =
nullptr;
7241 unsigned ArgSizeNoVarargs = std::min(
Function->param_size(), Args.size());
7244 for (
unsigned I = 0; I != ArgSizeNoVarargs; ++I) {
7253 ConvertedArgs.push_back(R.
get());
7261 for (
unsigned i = Args.size(), e =
Function->getNumParams(); i != e; ++i) {
7263 if (!
P->hasDefaultArg())
7268 ConvertedArgs.push_back(R.
get());
7280 bool MissingImplicitThis) {
7281 auto EnableIfAttrs =
Function->specific_attrs<EnableIfAttr>();
7282 if (EnableIfAttrs.begin() == EnableIfAttrs.end())
7288 Expr *DiscardedThis;
7290 *
this,
Function,
nullptr, CallLoc, Args, Trap,
7291 true, DiscardedThis, ConvertedArgs))
7292 return *EnableIfAttrs.begin();
7294 for (
auto *EIA : EnableIfAttrs) {
7298 if (EIA->getCond()->isValueDependent() ||
7299 !EIA->getCond()->EvaluateWithSubstitution(
7303 if (!
Result.isInt() || !
Result.getInt().getBoolValue())
7309template <
typename CheckFn>
7312 CheckFn &&IsSuccessful) {
7315 if (ArgDependent == DIA->getArgDependent())
7316 Attrs.push_back(DIA);
7323 auto WarningBegin = std::stable_partition(
7324 Attrs.begin(), Attrs.end(),
7325 [](
const DiagnoseIfAttr *DIA) { return DIA->isError(); });
7329 auto ErrAttr = llvm::find_if(llvm::make_range(Attrs.begin(), WarningBegin),
7331 if (ErrAttr != WarningBegin) {
7332 const DiagnoseIfAttr *DIA = *ErrAttr;
7333 S.
Diag(Loc, diag::err_diagnose_if_succeeded) << DIA->getMessage();
7334 S.
Diag(DIA->getLocation(), diag::note_from_diagnose_if)
7335 << DIA->getParent() << DIA->getCond()->getSourceRange();
7339 for (
const auto *DIA : llvm::make_range(WarningBegin, Attrs.end()))
7340 if (IsSuccessful(DIA)) {
7341 S.
Diag(Loc, diag::warn_diagnose_if_succeeded) << DIA->getMessage();
7342 S.
Diag(DIA->getLocation(), diag::note_from_diagnose_if)
7343 << DIA->getParent() << DIA->getCond()->getSourceRange();
7350 const Expr *ThisArg,
7355 [&](
const DiagnoseIfAttr *DIA) {
7360 if (!DIA->getCond()->EvaluateWithSubstitution(
7361 Result, Context, cast<FunctionDecl>(DIA->getParent()), Args, ThisArg))
7363 return Result.isInt() &&
Result.getInt().getBoolValue();
7370 *
this, ND,
false, Loc,
7371 [&](
const DiagnoseIfAttr *DIA) {
7384 bool SuppressUserConversions,
7385 bool PartialOverloading,
7386 bool FirstArgumentIsBase) {
7395 if (isa<CXXMethodDecl>(FD) && !cast<CXXMethodDecl>(FD)->isStatic()) {
7398 if (Args.size() > 0) {
7399 if (
Expr *E = Args[0]) {
7401 ObjectType = E->getType();
7407 ObjectClassification = E->Classify(Context);
7409 FunctionArgs = Args.slice(1);
7412 AddMethodTemplateCandidate(
7413 FunTmpl, F.getPair(),
7415 ExplicitTemplateArgs, ObjectType, ObjectClassification,
7416 FunctionArgs, CandidateSet, SuppressUserConversions,
7417 PartialOverloading);
7419 AddMethodCandidate(cast<CXXMethodDecl>(FD), F.getPair(),
7420 cast<CXXMethodDecl>(FD)->getParent(), ObjectType,
7421 ObjectClassification, FunctionArgs, CandidateSet,
7422 SuppressUserConversions, PartialOverloading);
7429 if (Args.size() > 0 &&
7430 (!Args[0] || (FirstArgumentIsBase && isa<CXXMethodDecl>(FD) &&
7431 !isa<CXXConstructorDecl>(FD)))) {
7432 assert(cast<CXXMethodDecl>(FD)->isStatic());
7433 FunctionArgs = Args.slice(1);
7436 AddTemplateOverloadCandidate(FunTmpl, F.getPair(),
7437 ExplicitTemplateArgs, FunctionArgs,
7438 CandidateSet, SuppressUserConversions,
7439 PartialOverloading);
7441 AddOverloadCandidate(FD, F.getPair(), FunctionArgs, CandidateSet,
7442 SuppressUserConversions, PartialOverloading);
7454 bool SuppressUserConversions,
7459 if (isa<UsingShadowDecl>(
Decl))
7460 Decl = cast<UsingShadowDecl>(
Decl)->getTargetDecl();
7463 assert(isa<CXXMethodDecl>(TD->getTemplatedDecl()) &&
7464 "Expected a member function template");
7465 AddMethodTemplateCandidate(TD, FoundDecl, ActingContext,
7466 nullptr, ObjectType,
7467 ObjectClassification, Args, CandidateSet,
7468 SuppressUserConversions,
false, PO);
7470 AddMethodCandidate(cast<CXXMethodDecl>(
Decl), FoundDecl, ActingContext,
7471 ObjectType, ObjectClassification, Args, CandidateSet,
7472 SuppressUserConversions,
false, std::nullopt, PO);
7489 bool SuppressUserConversions,
7490 bool PartialOverloading,
7495 assert(Proto &&
"Methods without a prototype cannot be overloaded");
7496 assert(!isa<CXXConstructorDecl>(Method) &&
7497 "Use AddOverloadCandidate for constructors");
7515 CandidateSet.
addCandidate(Args.size() + 1, EarlyConversions);
7533 Candidate.
Viable =
false;
7544 if (Args.size() < MinRequiredArgs && !PartialOverloading) {
7546 Candidate.
Viable =
false;
7566 Candidate.
Conversions[FirstConvIdx].setStaticObjectArgument();
7571 *
this, CandidateSet.
getLocation(), ObjectType, ObjectClassification,
7572 Method, ActingContext,
true);
7573 if (Candidate.
Conversions[FirstConvIdx].isBad()) {
7574 Candidate.
Viable =
false;
7581 if (getLangOpts().
CUDA)
7582 if (!IsAllowedCUDACall(getCurFunctionDecl(
true), Method)) {
7583 Candidate.
Viable =
false;
7590 if (CheckFunctionConstraints(Method, Satisfaction, {},
7593 Candidate.
Viable =
false;
7601 for (
unsigned ArgIdx = 0; ArgIdx < Args.size(); ++ArgIdx) {
7604 if (Candidate.
Conversions[ConvIdx].isInitialized()) {
7607 }
else if (ArgIdx < NumParams) {
7615 SuppressUserConversions,
7618 getLangOpts().ObjCAutoRefCount);
7620 Candidate.
Viable =
false;
7632 if (EnableIfAttr *FailedAttr =
7633 CheckEnableIf(Method, CandidateSet.
getLocation(), Args,
true)) {
7634 Candidate.
Viable =
false;
7641 ((Method->
hasAttr<TargetAttr>() &&
7642 !Method->
getAttr<TargetAttr>()->isDefaultVersion()) ||
7643 (Method->
hasAttr<TargetVersionAttr>() &&
7644 !Method->
getAttr<TargetVersionAttr>()->isDefaultVersion()))) {
7645 Candidate.
Viable =
false;
7677 PartialOverloading,
false, ObjectType,
7678 ObjectClassification,
7680 return CheckNonDependentConversions(
7681 MethodTmpl, ParamTypes, Args, CandidateSet, Conversions,
7682 SuppressUserConversions, ActingContext, ObjectType,
7683 ObjectClassification, PO);
7687 CandidateSet.
addCandidate(Conversions.size(), Conversions);
7690 Candidate.
Viable =
false;
7695 cast<CXXMethodDecl>(Candidate.
Function)->isStatic() ||
7710 assert(
Specialization &&
"Missing member function template specialization?");
7712 "Specialization is not a member function?");
7713 AddMethodCandidate(cast<CXXMethodDecl>(
Specialization), FoundDecl,
7714 ActingContext, ObjectType, ObjectClassification, Args,
7715 CandidateSet, SuppressUserConversions, PartialOverloading,
7732 bool PartialOverloading,
bool AllowExplicit,
ADLCallKind IsADLCandidate,
7744 Candidate.
Viable =
false;
7763 FunctionTemplate, ExplicitTemplateArgs, Args,
Specialization, Info,
7764 PartialOverloading, AggregateCandidateDeduction,
7768 return CheckNonDependentConversions(
7769 FunctionTemplate, ParamTypes, Args, CandidateSet, Conversions,
7770 SuppressUserConversions,
nullptr,
QualType(), {}, PO);
7774 CandidateSet.
addCandidate(Conversions.size(), Conversions);
7777 Candidate.
Viable =
false;
7785 isa<CXXMethodDecl>(Candidate.
Function) &&
7786 !isa<CXXConstructorDecl>(Candidate.
Function);
7800 assert(
Specialization &&
"Missing function template specialization?");
7801 AddOverloadCandidate(
7802 Specialization, FoundDecl, Args, CandidateSet, SuppressUserConversions,
7803 PartialOverloading, AllowExplicit,
7804 false, IsADLCandidate, Conversions, PO,
7820 const bool AllowExplicit =
false;
7823 auto *Method = dyn_cast<CXXMethodDecl>(FD);
7824 bool HasThisConversion = Method && !isa<CXXConstructorDecl>(Method);
7825 unsigned ThisConversions = HasThisConversion ? 1 : 0;
7837 if (HasThisConversion && !cast<CXXMethodDecl>(FD)->isStatic() &&
7840 if (!FD->hasCXXExplicitFunctionObjectParameter() ||
7841 !ParamTypes[0]->isDependentType()) {
7843 *
this, CandidateSet.
getLocation(), ObjectType, ObjectClassification,
7844 Method, ActingContext,
true,
7845 FD->hasCXXExplicitFunctionObjectParameter() ? ParamTypes[0]
7847 if (Conversions[ConvIdx].isBad())
7853 Method && Method->hasCXXExplicitFunctionObjectParameter() ? 1 : 0;
7855 for (
unsigned I = 0, N = std::min(ParamTypes.size() - Offset, Args.size());
7857 QualType ParamType = ParamTypes[I + Offset];
7861 ConvIdx = Args.size() - 1 - I;
7862 assert(Args.size() + ThisConversions == 2 &&
7863 "number of args (including 'this') must be exactly 2 for "
7867 assert(!HasThisConversion || (ConvIdx == 0 && I == 0));
7870 ConvIdx = ThisConversions + I;
7872 Conversions[ConvIdx]
7874 SuppressUserConversions,
7877 getLangOpts().ObjCAutoRefCount,
7879 if (Conversions[ConvIdx].isBad())
7901 bool AllowObjCPointerConversion) {
7909 bool ObjCLifetimeConversion;
7911 ObjCLifetimeConversion))
7916 if (!AllowObjCPointerConversion)
7920 bool IncompatibleObjC =
false;
7936 bool AllowExplicit,
bool AllowResultConversion) {
7938 "Conversion function templates use AddTemplateConversionCandidate");
7946 if (DeduceReturnType(Conversion, From->
getExprLoc()))
7953 if (!AllowResultConversion &&
7965 AllowObjCConversionOnExplicit))
7987 if (!AllowExplicit && Conversion->
isExplicit()) {
7988 Candidate.
Viable =
false;
8003 const auto *ConversionContext =
8012 From->
Classify(Context), Conversion, ConversionContext,
8017 Candidate.
Viable =
false;
8024 if (CheckFunctionConstraints(Conversion, Satisfaction) ||
8026 Candidate.
Viable =
false;
8038 if (FromCanon == ToCanon ||
8039 IsDerivedFrom(CandidateSet.
getLocation(), FromCanon, ToCanon)) {
8040 Candidate.
Viable =
false;
8057 CK_FunctionToPointerDecay, &ConversionRef,
8061 if (!isCompleteType(From->
getBeginLoc(), ConversionType)) {
8062 Candidate.
Viable =
false;
8076 Buffer, &ConversionFn, CallResultType, VK, From->
getBeginLoc());
8094 Candidate.
Viable =
false;
8106 Candidate.
Viable =
false;
8113 Candidate.
Viable =
false;
8119 "Can only end up with a standard conversion sequence or failure");
8122 if (EnableIfAttr *FailedAttr =
8123 CheckEnableIf(Conversion, CandidateSet.
getLocation(), std::nullopt)) {
8124 Candidate.
Viable =
false;
8131 ((Conversion->
hasAttr<TargetAttr>() &&
8132 !Conversion->
getAttr<TargetAttr>()->isDefaultVersion()) ||
8133 (Conversion->
hasAttr<TargetVersionAttr>() &&
8134 !Conversion->
getAttr<TargetVersionAttr>()->isDefaultVersion()))) {
8135 Candidate.
Viable =
false;
8149 bool AllowExplicit,
bool AllowResultConversion) {
8151 "Only conversion function templates permitted here");
8163 Candidate.
Viable =
false;
8174 FunctionTemplate, ObjectType, ObjectClassification, ToType,
8180 Candidate.
Viable =
false;
8192 assert(
Specialization &&
"Missing function template specialization?");
8193 AddConversionCandidate(
Specialization, FoundDecl, ActingDC, From, ToType,
8194 CandidateSet, AllowObjCConversionOnExplicit,
8195 AllowExplicit, AllowResultConversion);
8236 *
this, CandidateSet.
getLocation(), Object->getType(),
8237 Object->Classify(Context), Conversion, ActingContext);
8240 if (ObjectInit.
isBad()) {
8241 Candidate.
Viable =
false;
8252 Candidate.
Conversions[0].UserDefined.EllipsisConversion =
false;
8253 Candidate.
Conversions[0].UserDefined.HadMultipleCandidates =
false;
8254 Candidate.
Conversions[0].UserDefined.ConversionFunction = Conversion;
8255 Candidate.
Conversions[0].UserDefined.FoundConversionFunction = FoundDecl;
8258 Candidate.
Conversions[0].UserDefined.After.setAsIdentityConversion();
8266 if (Args.size() > NumParams && !Proto->
isVariadic()) {
8267 Candidate.
Viable =
false;
8274 if (Args.size() < NumParams) {
8276 Candidate.
Viable =
false;
8283 for (
unsigned ArgIdx = 0, N = Args.size(); ArgIdx != N; ++ArgIdx) {
8284 if (ArgIdx < NumParams) {
8295 getLangOpts().ObjCAutoRefCount);
8297 Candidate.
Viable =
false;
8311 if (CheckFunctionConstraints(Conversion, Satisfaction, {},
8314 Candidate.
Viable =
false;
8320 if (EnableIfAttr *FailedAttr =
8321 CheckEnableIf(Conversion, CandidateSet.
getLocation(), std::nullopt)) {
8322 Candidate.
Viable =
false;
8347 assert(!isa<CXXMethodDecl>(FD) &&
8348 "unqualified operator lookup found a member function");
8351 AddTemplateOverloadCandidate(FunTmpl, F.getPair(), ExplicitTemplateArgs,
8352 FunctionArgs, CandidateSet);
8354 AddTemplateOverloadCandidate(
8355 FunTmpl, F.getPair(), ExplicitTemplateArgs,
8356 {FunctionArgs[1], FunctionArgs[0]}, CandidateSet,
false,
false,
8359 if (ExplicitTemplateArgs)
8361 AddOverloadCandidate(FD, F.getPair(), FunctionArgs, CandidateSet);
8363 AddOverloadCandidate(
8364 FD, F.getPair(), {FunctionArgs[1], FunctionArgs[0]}, CandidateSet,
8365 false,
false,
true,
false, ADLCallKind::NotADL, std::nullopt,
8402 if (!isCompleteType(OpLoc, T1) && !T1Rec->isBeingDefined())
8405 if (!T1Rec->getDecl()->getDefinition())
8408 LookupResult Operators(*
this, OpName, OpLoc, LookupOrdinaryName);
8409 LookupQualifiedName(Operators, T1Rec->getDecl());
8413 OperEnd = Operators.
end();
8414 Oper != OperEnd; ++Oper) {
8415 if (Oper->getAsFunction() &&
8418 *
this, {Args[1], Args[0]}, Oper->getAsFunction()))
8420 AddMethodCandidate(Oper.getPair(), Args[0]->getType(),
8421 Args[0]->Classify(Context), Args.slice(1),
8422 CandidateSet,
false, PO);
8437 bool IsAssignmentOperator,
8438 unsigned NumContextualBoolArguments) {
8455 for (
unsigned ArgIdx = 0, N = Args.size(); ArgIdx != N; ++ArgIdx) {
8468 if (ArgIdx < NumContextualBoolArguments) {
8469 assert(ParamTys[ArgIdx] == Context.
BoolTy &&
8470 "Contextual conversion to bool requires bool type");
8476 ArgIdx == 0 && IsAssignmentOperator,
8479 getLangOpts().ObjCAutoRefCount);
8482 Candidate.
Viable =
false;
8495class BuiltinCandidateTypeSet {
8501 TypeSet PointerTypes;
8505 TypeSet MemberPointerTypes;
8509 TypeSet EnumerationTypes;
8513 TypeSet VectorTypes;
8517 TypeSet MatrixTypes;
8520 TypeSet BitIntTypes;
8523 bool HasNonRecordTypes;
8527 bool HasArithmeticOrEnumeralTypes;
8531 bool HasNullPtrType;
8540 bool AddPointerWithMoreQualifiedTypeVariants(
QualType Ty,
8542 bool AddMemberPointerWithMoreQualifiedTypeVariants(
QualType Ty);
8546 typedef TypeSet::iterator iterator;
8548 BuiltinCandidateTypeSet(
Sema &SemaRef)
8549 : HasNonRecordTypes(
false),
8550 HasArithmeticOrEnumeralTypes(
false),
8551 HasNullPtrType(
false),
8553 Context(SemaRef.Context) { }
8555 void AddTypesConvertedFrom(
QualType Ty,
8557 bool AllowUserConversions,
8558 bool AllowExplicitConversions,
8559 const Qualifiers &VisibleTypeConversionsQuals);
8561 llvm::iterator_range<iterator> pointer_types() {
return PointerTypes; }
8562 llvm::iterator_range<iterator> member_pointer_types() {
8563 return MemberPointerTypes;
8565 llvm::iterator_range<iterator> enumeration_types() {
8566 return EnumerationTypes;
8568 llvm::iterator_range<iterator> vector_types() {
return VectorTypes; }
8569 llvm::iterator_range<iterator> matrix_types() {
return MatrixTypes; }
8570 llvm::iterator_range<iterator> bitint_types() {
return BitIntTypes; }
8572 bool containsMatrixType(
QualType Ty)
const {
return MatrixTypes.count(Ty); }
8573 bool hasNonRecordTypes() {
return HasNonRecordTypes; }
8574 bool hasArithmeticOrEnumeralTypes() {
return HasArithmeticOrEnumeralTypes; }
8575 bool hasNullPtrType()
const {
return HasNullPtrType; }
8590BuiltinCandidateTypeSet::AddPointerWithMoreQualifiedTypeVariants(
QualType Ty,
8594 if (!PointerTypes.insert(Ty))
8599 bool buildObjCPtr =
false;
8603 buildObjCPtr =
true;
8615 unsigned BaseCVR = PointeeTy.getCVRQualifiers();
8621 if ((CVR | BaseCVR) != CVR)
continue;
8643 PointerTypes.insert(QPointerTy);
8659BuiltinCandidateTypeSet::AddMemberPointerWithMoreQualifiedTypeVariants(
8662 if (!MemberPointerTypes.insert(Ty))
8666 assert(PointerTy &&
"type was not a member pointer type!");
8681 if ((CVR | BaseCVR) != CVR)
continue;
8684 MemberPointerTypes.insert(
8700BuiltinCandidateTypeSet::AddTypesConvertedFrom(
QualType Ty,
8702 bool AllowUserConversions,
8703 bool AllowExplicitConversions,
8715 Ty = SemaRef.Context.getArrayDecayedType(Ty);
8722 HasNonRecordTypes = HasNonRecordTypes || !TyRec;
8725 HasArithmeticOrEnumeralTypes =
8729 PointerTypes.insert(Ty);
8733 if (!AddPointerWithMoreQualifiedTypeVariants(Ty, VisibleQuals))
8737 if (!AddMemberPointerWithMoreQualifiedTypeVariants(Ty))
8740 HasArithmeticOrEnumeralTypes =
true;
8741 EnumerationTypes.insert(Ty);
8743 HasArithmeticOrEnumeralTypes =
true;
8744 BitIntTypes.insert(Ty);
8748 HasArithmeticOrEnumeralTypes =
true;
8749 VectorTypes.insert(Ty);
8753 HasArithmeticOrEnumeralTypes =
true;
8754 MatrixTypes.insert(Ty);
8756 HasNullPtrType =
true;
8757 }
else if (AllowUserConversions && TyRec) {
8759 if (!SemaRef.isCompleteType(Loc, Ty))
8764 if (isa<UsingShadowDecl>(D))
8765 D = cast<UsingShadowDecl>(D)->getTargetDecl();
8769 if (isa<FunctionTemplateDecl>(D))
8773 if (AllowExplicitConversions || !Conv->
isExplicit()) {
8836 if (isa<UsingShadowDecl>(D))
8837 D = cast<UsingShadowDecl>(D)->getTargetDecl();
8871 if (Available.hasAtomic()) {
8872 Available.removeAtomic();
8879 if (Available.hasVolatile()) {
8880 Available.removeVolatile();
8914class BuiltinOperatorOverloadBuilder {
8919 bool HasArithmeticOrEnumeralCandidateType;
8923 static constexpr int ArithmeticTypesCap = 26;
8929 unsigned FirstIntegralType,
8931 unsigned FirstPromotedIntegralType,
8932 LastPromotedIntegralType;
8933 unsigned FirstPromotedArithmeticType,
8934 LastPromotedArithmeticType;
8935 unsigned NumArithmeticTypes;
8937 void InitArithmeticTypes() {
8939 FirstPromotedArithmeticType = 0;
8949 FirstIntegralType = ArithmeticTypes.size();
8950 FirstPromotedIntegralType = ArithmeticTypes.size();
8973 llvm::for_each(CandidateTypes, [&BitIntCandidates](
8974 BuiltinCandidateTypeSet &Candidate) {
8975 for (
QualType BitTy : Candidate.bitint_types())
8978 llvm::move(BitIntCandidates, std::back_inserter(ArithmeticTypes));
8979 LastPromotedIntegralType = ArithmeticTypes.size();
8980 LastPromotedArithmeticType = ArithmeticTypes.size();
8994 LastIntegralType = ArithmeticTypes.size();
8995 NumArithmeticTypes = ArithmeticTypes.size();
9002 assert(ArithmeticTypes.size() - BitIntCandidates.size() <=
9003 ArithmeticTypesCap &&
9004 "Enough inline storage for all arithmetic types.");
9009 void addPlusPlusMinusMinusStyleOverloads(
QualType CandidateTy,
9058 BuiltinOperatorOverloadBuilder(
9061 bool HasArithmeticOrEnumeralCandidateType,
9065 VisibleTypeConversionsQuals(VisibleTypeConversionsQuals),
9066 HasArithmeticOrEnumeralCandidateType(
9067 HasArithmeticOrEnumeralCandidateType),
9068 CandidateTypes(CandidateTypes),
9069 CandidateSet(CandidateSet) {
9071 InitArithmeticTypes();
9094 if (!HasArithmeticOrEnumeralCandidateType)
9097 for (
unsigned Arith = 0; Arith < NumArithmeticTypes; ++Arith) {
9098 const auto TypeOfT = ArithmeticTypes[Arith];
9100 if (Op == OO_MinusMinus)
9102 if (Op == OO_PlusPlus && S.
getLangOpts().CPlusPlus17)
9105 addPlusPlusMinusMinusStyleOverloads(
9122 void addPlusPlusMinusMinusPointerOverloads() {
9123 for (
QualType PtrTy : CandidateTypes[0].pointer_types()) {
9125 if (!PtrTy->getPointeeType()->isObjectType())
9128 addPlusPlusMinusMinusStyleOverloads(
9130 (!PtrTy.isVolatileQualified() &&
9132 (!PtrTy.isRestrictQualified() &&
9147 void addUnaryStarPointerOverloads() {
9148 for (
QualType ParamTy : CandidateTypes[0].pointer_types()) {
9154 if (Proto->getMethodQuals() || Proto->getRefQualifier())
9167 void addUnaryPlusOrMinusArithmeticOverloads() {
9168 if (!HasArithmeticOrEnumeralCandidateType)
9171 for (
unsigned Arith = FirstPromotedArithmeticType;
9172 Arith < LastPromotedArithmeticType; ++Arith) {
9173 QualType ArithTy = ArithmeticTypes[Arith];
9178 for (
QualType VecTy : CandidateTypes[0].vector_types())
9187 void addUnaryPlusPointerOverloads() {
9188 for (
QualType ParamTy : CandidateTypes[0].pointer_types())
9197 void addUnaryTildePromotedIntegralOverloads() {
9198 if (!HasArithmeticOrEnumeralCandidateType)
9201 for (
unsigned Int = FirstPromotedIntegralType;
9202 Int < LastPromotedIntegralType; ++Int) {
9203 QualType IntTy = ArithmeticTypes[Int];
9208 for (
QualType VecTy : CandidateTypes[0].vector_types())
9218 void addEqualEqualOrNotEqualMemberPointerOrNullptrOverloads() {
9222 for (
unsigned ArgIdx = 0, N = Args.size(); ArgIdx != N; ++ArgIdx) {
9223 for (
QualType MemPtrTy : CandidateTypes[ArgIdx].member_pointer_types()) {
9228 QualType ParamTypes[2] = {MemPtrTy, MemPtrTy};
9232 if (CandidateTypes[ArgIdx].hasNullPtrType()) {
9234 if (AddedTypes.insert(NullPtrTy).second) {
9235 QualType ParamTypes[2] = { NullPtrTy, NullPtrTy };
9254 void addGenericBinaryPointerOrEnumeralOverloads(
bool IsSpaceship) {
9268 UserDefinedBinaryOperators;
9270 for (
unsigned ArgIdx = 0, N = Args.size(); ArgIdx != N; ++ArgIdx) {
9271 if (!CandidateTypes[ArgIdx].enumeration_types().empty()) {
9273 CEnd = CandidateSet.
end();
9275 if (!
C->Viable || !
C->Function ||
C->Function->getNumParams() != 2)
9278 if (
C->Function->isFunctionTemplateSpecialization())
9287 .getUnqualifiedType();
9290 .getUnqualifiedType();
9298 UserDefinedBinaryOperators.insert(
9308 for (
unsigned ArgIdx = 0, N = Args.size(); ArgIdx != N; ++ArgIdx) {
9309 for (
QualType PtrTy : CandidateTypes[ArgIdx].pointer_types()) {
9313 if (IsSpaceship && PtrTy->isFunctionPointerType())
9316 QualType ParamTypes[2] = {PtrTy, PtrTy};
9319 for (
QualType EnumTy : CandidateTypes[ArgIdx].enumeration_types()) {
9324 if (!AddedTypes.insert(CanonType).second ||
9325 UserDefinedBinaryOperators.count(std::make_pair(CanonType,
9328 QualType ParamTypes[2] = {EnumTy, EnumTy};
9355 for (
int Arg = 0; Arg < 2; ++Arg) {
9356 QualType AsymmetricParamTypes[2] = {
9360 for (
QualType PtrTy : CandidateTypes[Arg].pointer_types()) {
9365 AsymmetricParamTypes[Arg] = PtrTy;
9366 if (Arg == 0 || Op == OO_Plus) {
9371 if (Op == OO_Minus) {
9376 QualType ParamTypes[2] = {PtrTy, PtrTy};
9412 void addGenericBinaryArithmeticOverloads() {
9413 if (!HasArithmeticOrEnumeralCandidateType)
9416 for (
unsigned Left = FirstPromotedArithmeticType;
9417 Left < LastPromotedArithmeticType; ++Left) {
9418 for (
unsigned Right = FirstPromotedArithmeticType;
9419 Right < LastPromotedArithmeticType; ++Right) {
9420 QualType LandR[2] = { ArithmeticTypes[Left],
9421 ArithmeticTypes[Right] };
9428 for (
QualType Vec1Ty : CandidateTypes[0].vector_types())
9429 for (
QualType Vec2Ty : CandidateTypes[1].vector_types()) {
9430 QualType LandR[2] = {Vec1Ty, Vec2Ty};
9440 void addMatrixBinaryArithmeticOverloads() {
9441 if (!HasArithmeticOrEnumeralCandidateType)
9444 for (
QualType M1 : CandidateTypes[0].matrix_types()) {
9445 AddCandidate(M1, cast<MatrixType>(M1)->getElementType());
9446 AddCandidate(M1, M1);
9449 for (
QualType M2 : CandidateTypes[1].matrix_types()) {
9450 AddCandidate(cast<MatrixType>(M2)->getElementType(), M2);
9451 if (!CandidateTypes[0].containsMatrixType(M2))
9452 AddCandidate(M2, M2);
9487 void addThreeWayArithmeticOverloads() {
9488 addGenericBinaryArithmeticOverloads();
9505 void addBinaryBitwiseArithmeticOverloads() {
9506 if (!HasArithmeticOrEnumeralCandidateType)
9509 for (
unsigned Left = FirstPromotedIntegralType;
9510 Left < LastPromotedIntegralType; ++Left) {
9511 for (
unsigned Right = FirstPromotedIntegralType;
9512 Right < LastPromotedIntegralType; ++Right) {
9513 QualType LandR[2] = { ArithmeticTypes[Left],
9514 ArithmeticTypes[Right] };
9527 void addAssignmentMemberPointerOrEnumeralOverloads() {
9531 for (
unsigned ArgIdx = 0; ArgIdx < 2; ++ArgIdx) {
9532 for (
QualType EnumTy : CandidateTypes[ArgIdx].enumeration_types()) {
9539 for (
QualType MemPtrTy : CandidateTypes[ArgIdx].member_pointer_types()) {
9564 void addAssignmentPointerOverloads(
bool isEqualOp) {
9568 for (
QualType PtrTy : CandidateTypes[0].pointer_types()) {
9572 else if (!PtrTy->getPointeeType()->isObjectType())
9583 bool NeedVolatile = !PtrTy.isVolatileQualified() &&
9593 if (!PtrTy.isRestrictQualified() &&
9613 for (
QualType PtrTy : CandidateTypes[1].pointer_types()) {
9627 bool NeedVolatile = !PtrTy.isVolatileQualified() &&
9637 if (!PtrTy.isRestrictQualified() &&
9670 void addAssignmentArithmeticOverloads(
bool isEqualOp) {
9671 if (!HasArithmeticOrEnumeralCandidateType)
9674 for (
unsigned Left = 0; Left < NumArithmeticTypes; ++Left) {
9675 for (
unsigned Right = FirstPromotedArithmeticType;
9676 Right < LastPromotedArithmeticType; ++Right) {
9678 ParamTypes[1] = ArithmeticTypes[Right];
9680 S, ArithmeticTypes[Left], Args[0]);
9693 for (
QualType Vec1Ty : CandidateTypes[0].vector_types())
9694 for (
QualType Vec2Ty : CandidateTypes[0].vector_types()) {
9696 ParamTypes[1] = Vec2Ty;
9724 void addAssignmentIntegralOverloads() {
9725 if (!HasArithmeticOrEnumeralCandidateType)
9728 for (
unsigned Left = FirstIntegralType; Left < LastIntegralType; ++Left) {
9729 for (
unsigned Right = FirstPromotedIntegralType;
9730 Right < LastPromotedIntegralType; ++Right) {
9732 ParamTypes[1] = ArithmeticTypes[Right];
9734 S, ArithmeticTypes[Left], Args[0]);
9753 void addExclaimOverload() {
9759 void addAmpAmpOrPipePipeOverload() {
9776 void addSubscriptOverloads() {
9777 for (
QualType PtrTy : CandidateTypes[0].pointer_types()) {
9787 for (
QualType PtrTy : CandidateTypes[1].pointer_types()) {
9807 void addArrowStarOverloads() {
9808 for (
QualType PtrTy : CandidateTypes[0].pointer_types()) {
9813 if (!isa<RecordType>(C1))
9822 for (
QualType MemPtrTy : CandidateTypes[1].member_pointer_types()) {
9828 QualType ParamTypes[2] = {PtrTy, MemPtrTy};
9853 void addConditionalOperatorOverloads() {
9857 for (
unsigned ArgIdx = 0; ArgIdx < 2; ++ArgIdx) {
9858 for (
QualType PtrTy : CandidateTypes[ArgIdx].pointer_types()) {
9862 QualType ParamTypes[2] = {PtrTy, PtrTy};
9866 for (
QualType MemPtrTy : CandidateTypes[ArgIdx].member_pointer_types()) {
9870 QualType ParamTypes[2] = {MemPtrTy, MemPtrTy};
9875 for (
QualType EnumTy : CandidateTypes[ArgIdx].enumeration_types()) {
9882 QualType ParamTypes[2] = {EnumTy, EnumTy};
9906 VisibleTypeConversionsQuals.
addConst();
9907 for (
unsigned ArgIdx = 0, N = Args.size(); ArgIdx != N; ++ArgIdx) {
9909 if (Args[ArgIdx]->getType()->isAtomicType())
9910 VisibleTypeConversionsQuals.
addAtomic();
9913 bool HasNonRecordCandidateType =
false;
9914 bool HasArithmeticOrEnumeralCandidateType =
false;
9916 for (
unsigned ArgIdx = 0, N = Args.size(); ArgIdx != N; ++ArgIdx) {
9917 CandidateTypes.emplace_back(*
this);
9918 CandidateTypes[ArgIdx].AddTypesConvertedFrom(Args[ArgIdx]->getType(),
9921 (Op == OO_Exclaim ||
9924 VisibleTypeConversionsQuals);
9925 HasNonRecordCandidateType = HasNonRecordCandidateType ||
9926 CandidateTypes[ArgIdx].hasNonRecordTypes();
9927 HasArithmeticOrEnumeralCandidateType =
9928 HasArithmeticOrEnumeralCandidateType ||
9929 CandidateTypes[ArgIdx].hasArithmeticOrEnumeralTypes();
9937 if (!HasNonRecordCandidateType &&
9938 !(Op == OO_Exclaim || Op == OO_AmpAmp || Op == OO_PipePipe))
9942 BuiltinOperatorOverloadBuilder OpBuilder(*
this, Args,
9943 VisibleTypeConversionsQuals,
9944 HasArithmeticOrEnumeralCandidateType,
9945 CandidateTypes, CandidateSet);
9951 llvm_unreachable(
"Expected an overloaded operator");
9956 case OO_Array_Delete:
9959 "Special operators don't use AddBuiltinOperatorCandidates");
9971 if (Args.size() == 1)
9972 OpBuilder.addUnaryPlusPointerOverloads();
9976 if (Args.size() == 1) {
9977 OpBuilder.addUnaryPlusOrMinusArithmeticOverloads();
9979 OpBuilder.addBinaryPlusOrMinusPointerOverloads(Op);
9980 OpBuilder.addGenericBinaryArithmeticOverloads();
9981 OpBuilder.addMatrixBinaryArithmeticOverloads();
9986 if (Args.size() == 1)
9987 OpBuilder.addUnaryStarPointerOverloads();
9989 OpBuilder.addGenericBinaryArithmeticOverloads();
9990 OpBuilder.addMatrixBinaryArithmeticOverloads();
9995 OpBuilder.addGenericBinaryArithmeticOverloads();
10000 OpBuilder.addPlusPlusMinusMinusArithmeticOverloads(Op);
10001 OpBuilder.addPlusPlusMinusMinusPointerOverloads();
10004 case OO_EqualEqual:
10005 case OO_ExclaimEqual:
10006 OpBuilder.addEqualEqualOrNotEqualMemberPointerOrNullptrOverloads();
10007 OpBuilder.addGenericBinaryPointerOrEnumeralOverloads(
false);
10008 OpBuilder.addGenericBinaryArithmeticOverloads();
10014 case OO_GreaterEqual:
10015 OpBuilder.addGenericBinaryPointerOrEnumeralOverloads(
false);
10016 OpBuilder.addGenericBinaryArithmeticOverloads();
10020 OpBuilder.addGenericBinaryPointerOrEnumeralOverloads(
true);
10021 OpBuilder.addThreeWayArithmeticOverloads();
10028 case OO_GreaterGreater:
10029 OpBuilder.addBinaryBitwiseArithmeticOverloads();
10033 if (Args.size() == 1)
10039 OpBuilder.addBinaryBitwiseArithmeticOverloads();
10043 OpBuilder.addUnaryTildePromotedIntegralOverloads();
10047 OpBuilder.addAssignmentMemberPointerOrEnumeralOverloads();
10051 case OO_MinusEqual:
10052 OpBuilder.addAssignmentPointerOverloads(Op == OO_Equal);
10056 case OO_SlashEqual:
10057 OpBuilder.addAssignmentArithmeticOverloads(Op == OO_Equal);
10060 case OO_PercentEqual:
10061 case OO_LessLessEqual:
10062 case OO_GreaterGreaterEqual:
10064 case OO_CaretEqual:
10066 OpBuilder.addAssignmentIntegralOverloads();
10070 OpBuilder.addExclaimOverload();
10075 OpBuilder.addAmpAmpOrPipePipeOverload();
10079 if (Args.size() == 2)
10080 OpBuilder.addSubscriptOverloads();
10084 OpBuilder.addArrowStarOverloads();
10087 case OO_Conditional:
10088 OpBuilder.addConditionalOperatorOverloads();
10089 OpBuilder.addGenericBinaryArithmeticOverloads();
10107 bool PartialOverloading) {
10118 ArgumentDependentLookup(Name, Loc, Args, Fns);
10122 CandEnd = CandidateSet.
end();
10123 Cand != CandEnd; ++Cand)
10124 if (Cand->Function) {
10125 Fns.
erase(Cand->Function);
10127 Fns.
erase(FunTmpl);
10136 if (ExplicitTemplateArgs)
10139 AddOverloadCandidate(
10140 FD, FoundDecl, Args, CandidateSet,
false,
10141 PartialOverloading,
true,
10142 false, ADLCallKind::UsesADL);
10144 AddOverloadCandidate(
10145 FD, FoundDecl, {Args[1], Args[0]}, CandidateSet,
10146 false, PartialOverloading,
10148 ADLCallKind::UsesADL, std::nullopt,
10152 auto *FTD = cast<FunctionTemplateDecl>(*I);
10153 AddTemplateOverloadCandidate(
10154 FTD, FoundDecl, ExplicitTemplateArgs, Args, CandidateSet,
10155 false, PartialOverloading,
10156 true, ADLCallKind::UsesADL);
10158 *
this, Args, FTD->getTemplatedDecl())) {
10159 AddTemplateOverloadCandidate(
10160 FTD, FoundDecl, ExplicitTemplateArgs, {Args[1], Args[0]},
10161 CandidateSet,
false, PartialOverloading,
10162 true, ADLCallKind::UsesADL,
10170enum class Comparison {
Equal, Better, Worse };
10187 bool Cand1Attr = Cand1->
hasAttr<EnableIfAttr>();
10188 bool Cand2Attr = Cand2->
hasAttr<EnableIfAttr>();
10189 if (!Cand1Attr || !Cand2Attr) {
10190 if (Cand1Attr == Cand2Attr)
10191 return Comparison::Equal;
10192 return Cand1Attr ? Comparison::Better : Comparison::Worse;
10198 llvm::FoldingSetNodeID Cand1ID, Cand2ID;
10199 for (
auto Pair : zip_longest(Cand1Attrs, Cand2Attrs)) {
10200 std::optional<EnableIfAttr *> Cand1A = std::get<0>(Pair);
10201 std::optional<EnableIfAttr *> Cand2A = std::get<1>(Pair);
10206 return Comparison::Worse;
10208 return Comparison::Better;
10213 (*Cand1A)->getCond()->Profile(Cand1ID, S.
getASTContext(),
true);
10214 (*Cand2A)->getCond()->Profile(Cand2ID, S.
getASTContext(),
true);
10215 if (Cand1ID != Cand2ID)
10216 return Comparison::Worse;
10219 return Comparison::Equal;
10227 return Comparison::Equal;
10233 return Comparison::Equal;
10234 return Comparison::Worse;
10237 return Comparison::Better;
10243 const auto *Cand1CPUSpec = Cand1.
Function->
getAttr<CPUSpecificAttr>();
10244 const auto *Cand2CPUSpec = Cand2.
Function->
getAttr<CPUSpecificAttr>();
10246 if (!Cand1CPUDisp && !Cand2CPUDisp && !Cand1CPUSpec && !Cand2CPUSpec)
10247 return Comparison::Equal;
10249 if (Cand1CPUDisp && !Cand2CPUDisp)
10250 return Comparison::Better;
10251 if (Cand2CPUDisp && !Cand1CPUDisp)
10252 return Comparison::Worse;
10254 if (Cand1CPUSpec && Cand2CPUSpec) {
10255 if (Cand1CPUSpec->cpus_size() != Cand2CPUSpec->cpus_size())
10256 return Cand1CPUSpec->cpus_size() < Cand2CPUSpec->cpus_size()
10257 ? Comparison::Better
10258 : Comparison::Worse;
10260 std::pair<CPUSpecificAttr::cpus_iterator, CPUSpecificAttr::cpus_iterator>
10261 FirstDiff = std::mismatch(
10262 Cand1CPUSpec->cpus_begin(), Cand1CPUSpec->cpus_end(),
10263 Cand2CPUSpec->cpus_begin(),
10265 return LHS->getName() == RHS->getName();
10268 assert(FirstDiff.first != Cand1CPUSpec->cpus_end() &&
10269 "Two different cpu-specific versions should not have the same "
10270 "identifier list, otherwise they'd be the same decl!");
10271 return (*FirstDiff.first)->getName() < (*FirstDiff.second)->
getName()
10272 ? Comparison::Better
10273 : Comparison::Worse;
10275 llvm_unreachable(
"No way to get here unless both had cpu_dispatch");
10281static std::optional<QualType>
10283 if (!isa<CXXMethodDecl>(F) || isa<CXXConstructorDecl>(F))
10284 return std::nullopt;
10286 auto *M = cast<CXXMethodDecl>(F);
10290 return M->getFunctionObjectParameterReferenceType();
10304 PT2->getInstantiatedFromMemberTemplate()))
10315 assert(I < F->getNumParams());
10319 unsigned F1NumParams = F1->
getNumParams() + isa<CXXMethodDecl>(F1);
10320 unsigned F2NumParams = F2->
getNumParams() + isa<CXXMethodDecl>(F2);
10322 if (F1NumParams != F2NumParams)
10325 unsigned I1 = 0, I2 = 0;
10326 for (
unsigned I = 0; I != F1NumParams; ++I) {
10327 QualType T1 = NextParam(F1, I1, I == 0);
10328 QualType T2 = NextParam(F2, I2, I == 0);
10329 assert(!T1.
isNull() && !T2.
isNull() &&
"Unexpected null param types");
10357 auto *Mem1 = dyn_cast<CXXMethodDecl>(Fn1);
10358 auto *Mem2 = dyn_cast<CXXMethodDecl>(Fn2);
10359 if (Mem1 && Mem2) {
10362 if (Mem1->getParent() != Mem2->getParent())
10366 if (Mem1->isInstance() && Mem2->isInstance() &&
10368 Mem1->getFunctionObjectParameterReferenceType(),
10369 Mem1->getFunctionObjectParameterReferenceType()))
10425 bool IsCand1ImplicitHD =
10427 bool IsCand2ImplicitHD =
10442 auto EmitThreshold =
10443 (S.
getLangOpts().CUDAIsDevice && IsCallerImplicitHD &&
10444 (IsCand1ImplicitHD || IsCand2ImplicitHD))
10447 auto Cand1Emittable = P1 > EmitThreshold;
10448 auto Cand2Emittable = P2 > EmitThreshold;
10449 if (Cand1Emittable && !Cand2Emittable)
10451 if (!Cand1Emittable && Cand2Emittable)
10462 unsigned StartArg = 0;
10469 return ICS.isStandard() &&
10481 assert(Cand2.
Conversions.size() == NumArgs &&
"Overload candidate mismatch");
10482 bool HasBetterConversion =
false;
10483 for (
unsigned ArgIdx = StartArg; ArgIdx < NumArgs; ++ArgIdx) {
10484 bool Cand1Bad = IsIllFormedConversion(Cand1.
Conversions[ArgIdx]);
10485 bool Cand2Bad = IsIllFormedConversion(Cand2.
Conversions[ArgIdx]);
10486 if (Cand1Bad != Cand2Bad) {
10489 HasBetterConversion =
true;
10493 if (HasBetterConversion)
10500 bool HasWorseConversion =
false;
10501 for (
unsigned ArgIdx = StartArg; ArgIdx < NumArgs; ++ArgIdx) {
10507 HasBetterConversion =
true;
10526 HasWorseConversion =
true;
10541 if (HasBetterConversion && !HasWorseConversion)
10552 isa<CXXConversionDecl>(Cand1.
Function) &&
10553 isa<CXXConversionDecl>(Cand2.
Function)) {
10581 isa<CXXConstructorDecl>(Cand1.
Function) !=
10582 isa<CXXConstructorDecl>(Cand2.
Function))
10583 return isa<CXXConstructorDecl>(Cand1.
Function);
10587 bool Cand1IsSpecialization = Cand1.
Function &&
10589 bool Cand2IsSpecialization = Cand2.
Function &&
10591 if (Cand1IsSpecialization != Cand2IsSpecialization)
10592 return Cand2IsSpecialization;
10598 if (Cand1IsSpecialization && Cand2IsSpecialization) {
10599 const auto *Obj1Context =
10601 const auto *Obj2Context =
10609 Obj1Context ?
QualType(Obj1Context->getTypeForDecl(), 0)
10611 Obj2Context ?
QualType(Obj2Context->getTypeForDecl(), 0)
10620 if (!Cand1IsSpecialization && !Cand2IsSpecialization &&
10632 bool AtLeastAsConstrained1, AtLeastAsConstrained2;
10634 AtLeastAsConstrained1) ||
10636 AtLeastAsConstrained2))
10638 if (AtLeastAsConstrained1 != AtLeastAsConstrained2)
10639 return AtLeastAsConstrained1;
10640 }
else if (RC1 || RC2) {
10641 return RC1 !=
nullptr;
10649 bool Cand1IsInherited =
10651 bool Cand2IsInherited =
10653 if (Cand1IsInherited != Cand2IsInherited)
10654 return Cand2IsInherited;
10655 else if (Cand1IsInherited) {
10656 assert(Cand2IsInherited);
10659 if (Cand1Class->isDerivedFrom(Cand2Class))
10661 if (Cand2Class->isDerivedFrom(Cand1Class))
10678 auto *Guide1 = dyn_cast_or_null<CXXDeductionGuideDecl>(Cand1.
Function);
10679 auto *Guide2 = dyn_cast_or_null<CXXDeductionGuideDecl>(Cand2.
Function);
10680 if (Guide1 && Guide2) {
10682 if (Guide1->isImplicit() != Guide2->isImplicit())
10683 return Guide2->isImplicit();
10693 const auto *Constructor1 = Guide1->getCorrespondingConstructor();
10694 const auto *Constructor2 = Guide2->getCorrespondingConstructor();
10695 if (Constructor1 && Constructor2) {
10696 bool isC1Templated = Constructor1->getTemplatedKind() !=
10698 bool isC2Templated = Constructor2->getTemplatedKind() !=
10700 if (isC1Templated != isC2Templated)
10701 return isC2Templated;
10709 if (Cmp != Comparison::Equal)
10710 return Cmp == Comparison::Better;
10713 bool HasPS1 = Cand1.
Function !=
nullptr &&
10715 bool HasPS2 = Cand2.
Function !=
nullptr &&
10717 if (HasPS1 != HasPS2 && HasPS1)
10721 if (MV == Comparison::Better)
10723 if (MV == Comparison::Worse)
10738 const auto *CD1 = dyn_cast_or_null<CXXConstructorDecl>(Cand1.
Function);
10739 const auto *CD2 = dyn_cast_or_null<CXXConstructorDecl>(Cand2.
Function);
10741 LangAS AS1 = CD1->getMethodQualifiers().getAddressSpace();
10742 LangAS AS2 = CD2->getMethodQualifiers().getAddressSpace();
10763 auto *VA = dyn_cast_or_null<ValueDecl>(A);
10764 auto *VB = dyn_cast_or_null<ValueDecl>(B);
10770 if (!VA->getDeclContext()->getRedeclContext()->Equals(
10771 VB->getDeclContext()->getRedeclContext()) ||
10772 getOwningModule(VA) == getOwningModule(VB) ||
10773 VA->isExternallyVisible() || VB->isExternallyVisible())
10781 if (Context.
hasSameType(VA->getType(), VB->getType()))
10786 if (
auto *EA = dyn_cast<EnumConstantDecl>(VA)) {
10787 if (
auto *EB = dyn_cast<EnumConstantDecl>(VB)) {
10790 auto *EnumA = cast<EnumDecl>(EA->getDeclContext());
10791 auto *EnumB = cast<EnumDecl>(EB->getDeclContext());
10792 if (EnumA->hasNameForLinkage() || EnumB->hasNameForLinkage() ||
10794 EnumB->getIntegerType()))
10797 return llvm::APSInt::isSameValue(EA->getInitVal(), EB->getInitVal());
10807 assert(D &&
"Unknown declaration");
10808 Diag(Loc, diag::ext_equivalent_internal_linkage_decl_in_modules) << D;
10810 Module *M = getOwningModule(D);
10814 for (
auto *E : Equiv) {
10815 Module *M = getOwningModule(E);
10816 Diag(E->getLocation(), diag::note_equivalent_internal_linkage_decl)
10825 static_cast<CNSInfo *
>(DeductionFailure.Data)
10826 ->Satisfaction.ContainsErrors;
10843 std::transform(
begin(),
end(), std::back_inserter(Candidates),
10859 bool ContainsSameSideCandidate =
10866 if (ContainsSameSideCandidate) {
10873 llvm::erase_if(Candidates, IsWrongSideCandidate);
10879 for (
auto *Cand : Candidates) {
10880 Cand->
Best =
false;
10882 if (Best ==
end() ||
10902 PendingBest.push_back(&*Best);
10907 while (!PendingBest.empty()) {
10908 auto *Curr = PendingBest.pop_back_val();
10909 for (
auto *Cand : Candidates) {
10912 PendingBest.push_back(Cand);
10917 EquivalentCands.push_back(Cand->
Function);
10929 if (Best->Function && Best->Function->isDeleted())
10932 if (!EquivalentCands.empty())
10941enum OverloadCandidateKind {
10944 oc_reversed_binary_operator,
10946 oc_implicit_default_constructor,
10947 oc_implicit_copy_constructor,
10948 oc_implicit_move_constructor,
10949 oc_implicit_copy_assignment,
10950 oc_implicit_move_assignment,
10951 oc_implicit_equality_comparison,
10952 oc_inherited_constructor
10955enum OverloadCandidateSelect {
10958 ocs_described_template,
10961static std::pair<OverloadCandidateKind, OverloadCandidateSelect>
10965 std::string &Description) {
10974 OverloadCandidateSelect Select = [&]() {
10975 if (!Description.empty())
10976 return ocs_described_template;
10977 return isTemplate ? ocs_template : ocs_non_template;
10980 OverloadCandidateKind Kind = [&]() {
10982 return oc_implicit_equality_comparison;
10985 return oc_reversed_binary_operator;
10987 if (
const auto *Ctor = dyn_cast<CXXConstructorDecl>(Fn)) {
10988 if (!Ctor->isImplicit()) {
10989 if (isa<ConstructorUsingShadowDecl>(Found))
10990 return oc_inherited_constructor;
10992 return oc_constructor;
10995 if (Ctor->isDefaultConstructor())
10996 return oc_implicit_default_constructor;
10998 if (Ctor->isMoveConstructor())
10999 return oc_implicit_move_constructor;
11001 assert(Ctor->isCopyConstructor() &&
11002 "unexpected sort of implicit constructor");
11003 return oc_implicit_copy_constructor;
11006 if (
const auto *Meth = dyn_cast<CXXMethodDecl>(Fn)) {
11009 if (!Meth->isImplicit())
11012 if (Meth->isMoveAssignmentOperator())
11013 return oc_implicit_move_assignment;
11015 if (Meth->isCopyAssignmentOperator())
11016 return oc_implicit_copy_assignment;
11018 assert(isa<CXXConversionDecl>(Meth) &&
"expected conversion");
11022 return oc_function;
11025 return std::make_pair(Kind, Select);
11028void MaybeEmitInheritedConstructorNote(
Sema &S,
const Decl *FoundDecl) {
11031 if (
const auto *Shadow = dyn_cast<ConstructorUsingShadowDecl>(FoundDecl))
11033 diag::note_ovl_candidate_inherited_constructor)
11034 << Shadow->getNominatedBaseClass();
11043 if (EnableIf->getCond()->isValueDependent() ||
11044 !EnableIf->getCond()->EvaluateAsBooleanCondition(AlwaysTrue, Ctx))
11061 bool InOverloadResolution,
11065 if (InOverloadResolution)
11067 diag::note_addrof_ovl_candidate_disabled_by_enable_if_attr);
11069 S.
Diag(Loc, diag::err_addrof_function_disabled_by_enable_if_attr) << FD;
11080 if (InOverloadResolution) {
11083 TemplateArgString +=
" ";
11085 FunTmpl->getTemplateParameters(),
11090 diag::note_ovl_candidate_unsatisfied_constraints)
11091 << TemplateArgString;
11093 S.
Diag(Loc, diag::err_addrof_function_constraints_not_satisfied)
11102 return P->hasAttr<PassObjectSizeAttr>();
11109 unsigned ParamNo = std::distance(FD->
param_begin(), I) + 1;
11110 if (InOverloadResolution)
11112 diag::note_ovl_candidate_has_pass_object_size_params)
11115 S.
Diag(Loc, diag::err_address_of_function_with_pass_object_size_params)
11131 return ::checkAddressOfFunctionIsAvailable(*
this,
Function, Complain,
11139 const auto *ConvD = dyn_cast<CXXConversionDecl>(Fn);
11143 const auto *RD = cast<CXXRecordDecl>(Fn->
getParent());
11144 if (!RD->isLambda())
11154 return ConvToCC != CallOpCC;
11160 QualType DestType,
bool TakingAddress) {
11164 !Fn->
getAttr<TargetAttr>()->isDefaultVersion())
11167 !Fn->
getAttr<TargetVersionAttr>()->isDefaultVersion())
11172 std::string FnDesc;
11173 std::pair<OverloadCandidateKind, OverloadCandidateSelect> KSPair =
11174 ClassifyOverloadCandidate(*
this, Found, Fn, RewriteKind, FnDesc);
11176 << (
unsigned)KSPair.first << (
unsigned)KSPair.second
11179 HandleFunctionTypeMismatch(PD, Fn->
getType(), DestType);
11181 MaybeEmitInheritedConstructorNote(*
this, Found);
11199 FunctionDecl *FirstCand =
nullptr, *SecondCand =
nullptr;
11200 for (
auto I = Cands.begin(), E = Cands.end(); I != E; ++I) {
11204 if (
auto *Template = I->Function->getPrimaryTemplate())
11205 Template->getAssociatedConstraints(AC);
11207 I->Function->getAssociatedConstraints(AC);
11210 if (FirstCand ==
nullptr) {
11211 FirstCand = I->Function;
11213 }
else if (SecondCand ==
nullptr) {
11214 SecondCand = I->Function;
11227 SecondCand, SecondAC))
11236 bool TakingAddress) {
11246 dyn_cast<FunctionTemplateDecl>((*I)->getUnderlyingDecl()) ) {
11247 NoteOverloadCandidate(*I, FunTmpl->getTemplatedDecl(),
CRK_None, DestType,
11250 = dyn_cast<FunctionDecl>((*I)->getUnderlyingDecl()) ) {
11251 NoteOverloadCandidate(*I, Fun,
CRK_None, DestType, TakingAddress);
11263 S.
Diag(CaretLoc, PDiag)
11264 << Ambiguous.getFromType() << Ambiguous.getToType();
11265 unsigned CandsShown = 0;
11267 for (I = Ambiguous.begin(), E = Ambiguous.end(); I != E; ++I) {
11279 unsigned I,
bool TakingCandidateAddress) {
11281 assert(Conv.
isBad());
11282 assert(Cand->
Function &&
"for now, candidate must be a function");
11288 bool isObjectArgument =
false;
11289 if (isa<CXXMethodDecl>(Fn) && !isa<CXXConstructorDecl>(Fn)) {
11291 isObjectArgument =
true;
11296 std::string FnDesc;
11297 std::pair<OverloadCandidateKind, OverloadCandidateSelect> FnKindPair =
11308 assert(FromExpr &&
"overload set argument came from implicit argument?");
11310 if (isa<UnaryOperator>(E))
11311 E = cast<UnaryOperator>(E)->getSubExpr()->
IgnoreParens();
11315 << (
unsigned)FnKindPair.first << (
unsigned)FnKindPair.second << FnDesc
11316 << ToParamRange << ToTy << Name << I + 1;
11317 MaybeEmitInheritedConstructorNote(S, Cand->
FoundDecl);
11326 CToTy = RT->getPointeeType();
11331 CFromTy = FromPT->getPointeeType();
11332 CToTy = ToPT->getPointeeType();
11342 if (isObjectArgument)
11343 S.
Diag(Fn->
getLocation(), diag::note_ovl_candidate_bad_addrspace_this)
11344 << (
unsigned)FnKindPair.first << (
unsigned)FnKindPair.second
11348 << (
unsigned)FnKindPair.first << (
unsigned)FnKindPair.second
11351 MaybeEmitInheritedConstructorNote(S, Cand->
FoundDecl);
11357 << (
unsigned)FnKindPair.first << (
unsigned)FnKindPair.second << FnDesc
11360 MaybeEmitInheritedConstructorNote(S, Cand->
FoundDecl);
11366 << (
unsigned)FnKindPair.first << (
unsigned)FnKindPair.second << FnDesc
11369 MaybeEmitInheritedConstructorNote(S, Cand->
FoundDecl);
11374 assert(CVR &&
"expected qualifiers mismatch");
11376 if (isObjectArgument) {
11378 << (
unsigned)FnKindPair.first << (
unsigned)FnKindPair.second << FnDesc
11379 << FromTy << (CVR - 1);
11382 << (
unsigned)FnKindPair.first << (
unsigned)FnKindPair.second << FnDesc
11383 << ToParamRange << FromTy << (CVR - 1) << I + 1;
11385 MaybeEmitInheritedConstructorNote(S, Cand->
FoundDecl);
11391 S.
Diag(Fn->
getLocation(), diag::note_ovl_candidate_bad_value_category)
11392 << (
unsigned)FnKindPair.first << (
unsigned)FnKindPair.second << FnDesc
11393 << (
unsigned)isObjectArgument << I + 1
11396 MaybeEmitInheritedConstructorNote(S, Cand->
FoundDecl);
11402 if (FromExpr && isa<InitListExpr>(FromExpr)) {
11403 S.
Diag(Fn->
getLocation(), diag::note_ovl_candidate_bad_list_argument)
11404 << (
unsigned)FnKindPair.first << (
unsigned)FnKindPair.second << FnDesc
11405 << ToParamRange << FromTy << ToTy << (
unsigned)isObjectArgument << I + 1
11410 MaybeEmitInheritedConstructorNote(S, Cand->
FoundDecl);
11422 S.
Diag(Fn->
getLocation(), diag::note_ovl_candidate_bad_conv_incomplete)
11423 << (
unsigned)FnKindPair.first << (
unsigned)FnKindPair.second << FnDesc
11424 << ToParamRange << FromTy << ToTy << (
unsigned)isObjectArgument << I + 1
11425 << (
unsigned)(Cand->
Fix.
Kind);
11427 MaybeEmitInheritedConstructorNote(S, Cand->
FoundDecl);
11432 unsigned BaseToDerivedConversion = 0;
11435 if (ToPtrTy->getPointeeType().isAtLeastAsQualifiedAs(
11436 FromPtrTy->getPointeeType()) &&
11437 !FromPtrTy->getPointeeType()->isIncompleteType() &&
11438 !ToPtrTy->getPointeeType()->isIncompleteType() &&
11440 FromPtrTy->getPointeeType()))
11441 BaseToDerivedConversion = 1;
11449 if (ToPtrTy->getPointeeType().isAtLeastAsQualifiedAs(
11450 FromPtrTy->getPointeeType()) &&
11451 FromIface->isSuperClassOf(ToIface))
11452 BaseToDerivedConversion = 2;
11454 if (ToRefTy->getPointeeType().isAtLeastAsQualifiedAs(FromTy) &&
11456 !ToRefTy->getPointeeType()->isIncompleteType() &&
11458 BaseToDerivedConversion = 3;
11462 if (BaseToDerivedConversion) {
11463 S.
Diag(Fn->
getLocation(), diag::note_ovl_candidate_bad_base_to_derived_conv)
11464 << (
unsigned)FnKindPair.first << (
unsigned)FnKindPair.second << FnDesc
11465 << ToParamRange << (BaseToDerivedConversion - 1) << FromTy << ToTy
11467 MaybeEmitInheritedConstructorNote(S, Cand->
FoundDecl);
11471 if (isa<ObjCObjectPointerType>(CFromTy) &&
11472 isa<PointerType>(CToTy)) {
11477 << (
unsigned)FnKindPair.first << (
unsigned)FnKindPair.second << FnDesc
11478 << ToParamRange << FromTy << ToTy << (
unsigned)isObjectArgument
11480 MaybeEmitInheritedConstructorNote(S, Cand->
FoundDecl);
11485 if (TakingCandidateAddress &&
11491 FDiag << (
unsigned)FnKindPair.first << (
unsigned)FnKindPair.second << FnDesc
11492 << ToParamRange << FromTy << ToTy << (
unsigned)isObjectArgument << I + 1
11493 << (
unsigned)(Cand->
Fix.
Kind);
11504 MaybeEmitInheritedConstructorNote(S, Cand->
FoundDecl);
11511 unsigned NumArgs) {
11524 if (NumArgs < MinParams) {
11541 unsigned NumFormalArgs) {
11542 assert(isa<FunctionDecl>(D) &&
11543 "The templated declaration should at least be a function"
11544 " when diagnosing bad template argument deduction due to too many"
11545 " or too few arguments");
11555 unsigned ParamCount = FnTy->getNumParams() - (HasExplicitObjectParam ? 1 : 0);
11556 unsigned mode, modeCount;
11557 if (NumFormalArgs < MinParams) {
11558 if (MinParams != ParamCount || FnTy->isVariadic() ||
11559 FnTy->isTemplateVariadic())
11563 modeCount = MinParams;
11565 if (MinParams != ParamCount)
11569 modeCount = ParamCount;
11572 std::string Description;
11573 std::pair<OverloadCandidateKind, OverloadCandidateSelect> FnKindPair =
11574 ClassifyOverloadCandidate(S, Found, Fn,
CRK_None, Description);
11576 if (modeCount == 1 &&
11579 << (
unsigned)FnKindPair.first << (
unsigned)FnKindPair.second
11580 << Description << mode
11581 << Fn->
getParamDecl(HasExplicitObjectParam ? 1 : 0) << NumFormalArgs
11585 << (
unsigned)FnKindPair.first << (
unsigned)FnKindPair.second
11586 << Description << mode << modeCount << NumFormalArgs
11589 MaybeEmitInheritedConstructorNote(S, Found);
11594 unsigned NumFormalArgs) {
11602 llvm_unreachable(
"Unsupported: Getting the described template declaration"
11603 " for bad deduction diagnosis");
11610 bool TakingCandidateAddress) {
11616 switch (DeductionFailure.
getResult()) {
11619 "TemplateDeductionResult::Success while diagnosing bad deduction");
11621 llvm_unreachable(
"TemplateDeductionResult::NonDependentConversionFailure "
11622 "while diagnosing bad deduction");
11628 assert(ParamD &&
"no parameter found for incomplete deduction result");
11630 diag::note_ovl_candidate_incomplete_deduction)
11632 MaybeEmitInheritedConstructorNote(S, Found);
11637 assert(ParamD &&
"no parameter found for incomplete deduction result");
11639 diag::note_ovl_candidate_incomplete_deduction_pack)
11643 MaybeEmitInheritedConstructorNote(S, Found);
11648 assert(ParamD &&
"no parameter found for bad qualifiers deduction result");
11666 S.
Diag(Templated->
getLocation(), diag::note_ovl_candidate_underqualified)
11667 << ParamD->
getDeclName() << Arg << NonCanonParam;
11668 MaybeEmitInheritedConstructorNote(S, Found);
11673 assert(ParamD &&
"no parameter found for inconsistent deduction result");
11675 if (isa<TemplateTypeParmDecl>(ParamD))
11677 else if (isa<NonTypeTemplateParmDecl>(ParamD)) {
11687 diag::note_ovl_candidate_inconsistent_deduction_types)
11690 MaybeEmitInheritedConstructorNote(S, Found);
11710 diag::note_ovl_candidate_inconsistent_deduction)
11713 MaybeEmitInheritedConstructorNote(S, Found);
11718 assert(ParamD &&
"no parameter found for invalid explicit arguments");
11721 diag::note_ovl_candidate_explicit_arg_mismatch_named)
11726 index = TTP->getIndex();
11728 = dyn_cast<NonTypeTemplateParmDecl>(ParamD))
11729 index = NTTP->getIndex();
11731 index = cast<TemplateTemplateParmDecl>(ParamD)->getIndex();
11733 diag::note_ovl_candidate_explicit_arg_mismatch_unnamed)
11736 MaybeEmitInheritedConstructorNote(S, Found);
11743 TemplateArgString =
" ";
11746 if (TemplateArgString.size() == 1)
11747 TemplateArgString.clear();
11749 diag::note_ovl_candidate_unsatisfied_constraints)
11750 << TemplateArgString;
11753 static_cast<CNSInfo*
>(DeductionFailure.
Data)->Satisfaction);
11763 diag::note_ovl_candidate_instantiation_depth);
11764 MaybeEmitInheritedConstructorNote(S, Found);
11772 TemplateArgString =
" ";
11775 if (TemplateArgString.size() == 1)
11776 TemplateArgString.clear();
11781 if (PDiag && PDiag->second.getDiagID() ==
11782 diag::err_typename_nested_not_found_enable_if) {
11785 S.
Diag(PDiag->first, diag::note_ovl_candidate_disabled_by_enable_if)
11786 <<
"'enable_if'" << TemplateArgString;
11791 if (PDiag && PDiag->second.getDiagID() ==
11792 diag::err_typename_nested_not_found_requirement) {
11794 diag::note_ovl_candidate_disabled_by_requirement)
11795 << PDiag->second.getStringArg(0) << TemplateArgString;
11805 SFINAEArgString =
": ";
11807 PDiag->second.EmitToString(S.
getDiagnostics(), SFINAEArgString);
11811 diag::note_ovl_candidate_substitution_failure)
11812 << TemplateArgString << SFINAEArgString << R;
11813 MaybeEmitInheritedConstructorNote(S, Found);
11823 TemplateArgString =
" ";
11826 if (TemplateArgString.size() == 1)
11827 TemplateArgString.clear();
11830 S.
Diag(Templated->
getLocation(), diag::note_ovl_candidate_deduced_mismatch)
11833 << TemplateArgString
11858 diag::note_ovl_candidate_non_deduced_mismatch_qualified)
11865 if (TakingCandidateAddress && isa<FunctionDecl>(Templated) &&
11874 diag::note_ovl_candidate_non_deduced_mismatch)
11875 << FirstTA << SecondTA;
11881 S.
Diag(Templated->
getLocation(), diag::note_ovl_candidate_bad_deduction);
11882 MaybeEmitInheritedConstructorNote(S, Found);
11886 diag::note_cuda_ovl_candidate_target_mismatch);
11894 bool TakingCandidateAddress) {
11913 std::string FnDesc;
11914 std::pair<OverloadCandidateKind, OverloadCandidateSelect> FnKindPair =
11915 ClassifyOverloadCandidate(S, Cand->
FoundDecl, Callee,
11918 S.
Diag(Callee->getLocation(), diag::note_ovl_candidate_bad_target)
11919 << (
unsigned)FnKindPair.first << (
unsigned)ocs_non_template
11921 << CalleeTarget << CallerTarget;
11926 if (Meth !=
nullptr && Meth->
isImplicit()) {
11930 switch (FnKindPair.first) {
11933 case oc_implicit_default_constructor:
11936 case oc_implicit_copy_constructor:
11939 case oc_implicit_move_constructor:
11942 case oc_implicit_copy_assignment:
11945 case oc_implicit_move_assignment:
11950 bool ConstRHS =
false;
11954 ConstRHS = RT->getPointeeType().isConstQualified();
11968 S.
Diag(Callee->getLocation(),
11969 diag::note_ovl_candidate_disabled_by_function_cond_attr)
11970 <<
Attr->getCond()->getSourceRange() <<
Attr->getMessage();
11975 assert(ES.
isExplicit() &&
"not an explicit candidate");
11979 case Decl::Kind::CXXConstructor:
11982 case Decl::Kind::CXXConversion:
11985 case Decl::Kind::CXXDeductionGuide:
11989 llvm_unreachable(
"invalid Decl");
11998 First = Pattern->getFirstDecl();
12001 diag::note_ovl_candidate_explicit)
12002 << Kind << (ES.
getExpr() ? 1 : 0)
12023 bool TakingCandidateAddress,
12039 std::string FnDesc;
12040 std::pair<OverloadCandidateKind, OverloadCandidateSelect> FnKindPair =
12041 ClassifyOverloadCandidate(S, Cand->
FoundDecl, Fn,
12045 << (
unsigned)FnKindPair.first << (
unsigned)FnKindPair.second << FnDesc
12047 MaybeEmitInheritedConstructorNote(S, Cand->
FoundDecl);
12063 TakingCandidateAddress);
12066 S.
Diag(Fn->
getLocation(), diag::note_ovl_candidate_illegal_constructor)
12068 MaybeEmitInheritedConstructorNote(S, Cand->
FoundDecl);
12076 diag::note_ovl_candidate_illegal_constructor_adrspace_mismatch)
12077 << QualsForPrinting;
12078 MaybeEmitInheritedConstructorNote(S, Cand->
FoundDecl);
12089 for (
unsigned N = Cand->
Conversions.size(); I != N; ++I)
12110 if (cast<CXXConstructorDecl>(Fn)->isCopyOrMoveConstructor())
12113 diag::note_ovl_candidate_inherited_constructor_slice)
12116 MaybeEmitInheritedConstructorNote(S, Cand->
FoundDecl);
12122 assert(!Available);
12130 std::string FnDesc;
12131 std::pair<OverloadCandidateKind, OverloadCandidateSelect> FnKindPair =
12132 ClassifyOverloadCandidate(S, Cand->
FoundDecl, Fn,
12136 diag::note_ovl_candidate_constraints_not_satisfied)
12137 << (
unsigned)FnKindPair.first << (
unsigned)ocs_non_template
12155 bool isLValueReference =
false;
12156 bool isRValueReference =
false;
12157 bool isPointer =
false;
12161 isLValueReference =
true;
12165 isRValueReference =
true;
12181 diag::note_ovl_surrogate_constraints_not_satisfied)
12195 assert(Cand->
Conversions.size() <= 2 &&
"builtin operator is not binary");
12196 std::string TypeStr(
"operator");
12202 S.
Diag(OpLoc, diag::note_ovl_builtin_candidate) << TypeStr;
12207 S.
Diag(OpLoc, diag::note_ovl_builtin_candidate) << TypeStr;
12214 if (ICS.
isBad())
break;
12218 S, OpLoc, S.
PDiag(diag::note_ambiguous_type_conversion));
12235 llvm_unreachable(
"non-deduction failure while diagnosing bad deduction");
12265 llvm_unreachable(
"Unhandled deduction result");
12270struct CompareOverloadCandidatesForDisplay {
12276 CompareOverloadCandidatesForDisplay(
12279 : S(S), NumArgs(NArgs), CSK(CSK) {}
12289 if (NumArgs >
C->Function->getNumParams() && !
C->Function->isVariadic())
12291 if (NumArgs < C->
Function->getMinRequiredArguments())
12301 if (L == R)
return false;
12305 if (!R->
Viable)
return true;
12307 if (
int Ord = CompareConversions(*L, *R))
12327 if (LDist == RDist) {
12328 if (LFailureKind == RFailureKind)
12336 return LDist < RDist;
12354 numLFixes = (numLFixes == 0) ?
UINT_MAX : numLFixes;
12355 numRFixes = (numRFixes == 0) ?
UINT_MAX : numRFixes;
12356 if (numLFixes != numRFixes) {
12357 return numLFixes < numRFixes;
12361 if (
int Ord = CompareConversions(*L, *R))
12373 if (LRank != RRank)
12374 return LRank < RRank;
12400 struct ConversionSignals {
12401 unsigned KindRank = 0;
12405 ConversionSignals Sig;
12406 Sig.KindRank =
Seq.getKindRank();
12407 if (
Seq.isStandard())
12408 Sig.Rank =
Seq.Standard.getRank();
12409 else if (
Seq.isUserDefined())
12410 Sig.Rank =
Seq.UserDefined.After.getRank();
12416 static ConversionSignals ForObjectArgument() {
12432 for (
unsigned I = 0, N = L.
Conversions.size(); I != N; ++I) {
12434 ? ConversionSignals::ForObjectArgument()
12435 : ConversionSignals::ForSequence(L.Conversions[I]);
12437 ? ConversionSignals::ForObjectArgument()
12438 : ConversionSignals::ForSequence(R.Conversions[I]);
12439 if (std::tie(LS.KindRank, LS.Rank) != std::tie(RS.KindRank, RS.Rank))
12440 return std::tie(LS.KindRank, LS.Rank) < std::tie(RS.KindRank, RS.Rank)
12465 bool Unfixable =
false;
12473 assert(ConvIdx != ConvCount &&
"no bad conversion in candidate");
12474 if (Cand->
Conversions[ConvIdx].isInitialized() &&
12483 bool SuppressUserConversions =
false;
12485 unsigned ConvIdx = 0;
12486 unsigned ArgIdx = 0;
12501 if (isa<CXXMethodDecl>(Cand->
Function) &&
12514 assert(ConvCount <= 3);
12520 ConvIdx != ConvCount;
12522 assert(ArgIdx < Args.size() &&
"no argument for this arg conversion");
12523 if (Cand->
Conversions[ConvIdx].isInitialized()) {
12525 }
else if (
ParamIdx < ParamTypes.size()) {
12526 if (ParamTypes[
ParamIdx]->isDependentType())
12527 Cand->
Conversions[ConvIdx].setAsIdentityConversion(
12528 Args[ArgIdx]->getType());
12532 SuppressUserConversions,
12537 if (!Unfixable && Cand->
Conversions[ConvIdx].isBad())
12553 for (
iterator Cand =
begin(), LastCand =
end(); Cand != LastCand; ++Cand) {
12554 if (!Filter(*Cand))
12558 if (!Cand->Viable) {
12559 if (!Cand->Function && !Cand->IsSurrogate) {
12579 Cands.push_back(Cand);
12583 Cands, CompareOverloadCandidatesForDisplay(S, OpLoc, Args.size(), Kind));
12590 bool DeferHint =
false;
12594 auto WrongSidedCands =
12596 return (Cand.Viable ==
false &&
12599 Cand.Function->template hasAttr<CUDAHostAttr>() &&
12600 Cand.Function->template hasAttr<CUDADeviceAttr>());
12602 DeferHint = !WrongSidedCands.empty();
12620 bool NoteCands =
true;
12621 for (
const Expr *Arg : Args) {
12622 if (Arg->getType()->isWebAssemblyTableType())
12636 bool ReportedAmbiguousConversions =
false;
12639 unsigned CandsShown = 0;
12640 auto I = Cands.begin(), E = Cands.end();
12641 for (; I != E; ++I) {
12657 "Non-viable built-in candidates are not added to Cands.");
12664 if (!ReportedAmbiguousConversions) {
12666 ReportedAmbiguousConversions =
true;
12679 S.
Diag(OpLoc, diag::note_ovl_too_many_candidates,
12691struct CompareTemplateSpecCandidatesForDisplay {
12693 CompareTemplateSpecCandidatesForDisplay(
Sema &S) : S(S) {}
12727 bool ForTakingAddress) {
12729 DeductionFailure, 0, ForTakingAddress);
12732void TemplateSpecCandidateSet::destroyCandidates() {
12734 i->DeductionFailure.Destroy();
12739 destroyCandidates();
12740 Candidates.clear();
12753 Cands.reserve(
size());
12754 for (
iterator Cand =
begin(), LastCand =
end(); Cand != LastCand; ++Cand) {
12755 if (Cand->Specialization)
12756 Cands.push_back(Cand);
12761 llvm::sort(Cands, CompareTemplateSpecCandidatesForDisplay(S));
12768 unsigned CandsShown = 0;
12769 for (I = Cands.begin(), E = Cands.end(); I != E; ++I) {
12775 if (CandsShown >= 4 && ShowOverloads ==
Ovl_Best)
12780 "Non-matching built-in candidates are not added to Cands.");
12785 S.
Diag(Loc, diag::note_ovl_too_many_candidates) <<
int(E - I);
12795 QualType Ret = PossiblyAFunctionType;
12798 Ret = ToTypePtr->getPointeeType();
12801 Ret = ToTypeRef->getPointeeType();
12804 Ret = MemTypePtr->getPointeeType();
12811 bool Complain =
true) {
12828class AddressOfFunctionResolver {
12838 bool TargetTypeIsNonStaticMemberFunction;
12839 bool FoundNonTemplateFunction;
12840 bool StaticMemberFunctionFromBoundPointer;
12841 bool HasComplained;
12850 AddressOfFunctionResolver(
Sema &S,
Expr *SourceExpr,
12851 const QualType &TargetType,
bool Complain)
12852 : S(S), SourceExpr(SourceExpr), TargetType(TargetType),
12853 Complain(Complain), Context(S.getASTContext()),
12854 TargetTypeIsNonStaticMemberFunction(
12856 FoundNonTemplateFunction(
false),
12857 StaticMemberFunctionFromBoundPointer(
false),
12858 HasComplained(
false),
12861 FailedCandidates(OvlExpr->getNameLoc(),
true) {
12862 ExtractUnqualifiedFunctionTypeFromTargetType();
12866 if (!UME->isImplicitAccess() &&
12868 StaticMemberFunctionFromBoundPointer =
true;
12872 OvlExpr,
false, &dap)) {
12874 if (!Method->isStatic()) {
12878 TargetTypeIsNonStaticMemberFunction =
true;
12886 Matches.push_back(std::make_pair(dap, Fn));
12894 if (FindAllFunctionsThatMatchTargetTypeExactly()) {
12897 if (Matches.size() > 1 && !eliminiateSuboptimalOverloadCandidates()) {
12898 if (FoundNonTemplateFunction)
12899 EliminateAllTemplateMatches();
12901 EliminateAllExceptMostSpecializedTemplate();
12906 EliminateSuboptimalCudaMatches();
12909 bool hasComplained()
const {
return HasComplained; }
12912 bool candidateHasExactlyCorrectType(
const FunctionDecl *FD) {
12924 return candidateHasExactlyCorrectType(A) &&
12925 (!candidateHasExactlyCorrectType(B) ||
12931 bool eliminiateSuboptimalOverloadCandidates() {
12934 auto Best = Matches.begin();
12935 for (
auto I = Matches.begin()+1, E = Matches.end(); I != E; ++I)
12936 if (isBetterCandidate(I->second, Best->second))
12940 auto IsBestOrInferiorToBest = [
this, BestFn](
12941 const std::pair<DeclAccessPair, FunctionDecl *> &Pair) {
12942 return BestFn == Pair.second || isBetterCandidate(BestFn, Pair.second);
12947 if (!llvm::all_of(Matches, IsBestOrInferiorToBest))
12949 Matches[0] = *Best;
12954 bool isTargetTypeAFunction()
const {
12963 void inline ExtractUnqualifiedFunctionTypeFromTargetType() {
12974 bool CanConvertToFunctionPointer =
12975 Method->isStatic() || Method->isExplicitObjectMemberFunction();
12976 if (CanConvertToFunctionPointer == TargetTypeIsNonStaticMemberFunction)
12979 else if (TargetTypeIsNonStaticMemberFunction)
12991 FunctionTemplate, &OvlExplicitTemplateArgs, TargetFunctionType,
12993 Result != TemplateDeductionResult::Success) {
13011 Matches.push_back(std::make_pair(CurAccessFunPair,
Specialization));
13015 bool AddMatchingNonTemplateFunction(
NamedDecl* Fn,
13020 bool CanConvertToFunctionPointer =
13021 Method->isStatic() || Method->isExplicitObjectMemberFunction();
13022 if (CanConvertToFunctionPointer == TargetTypeIsNonStaticMemberFunction)
13025 else if (TargetTypeIsNonStaticMemberFunction)
13028 if (
FunctionDecl *FunDecl = dyn_cast<FunctionDecl>(Fn)) {
13035 if (FunDecl->isMultiVersion()) {
13036 const auto *TA = FunDecl->
getAttr<TargetAttr>();
13037 if (TA && !TA->isDefaultVersion())
13039 const auto *TVA = FunDecl->getAttr<TargetVersionAttr>();
13040 if (TVA && !TVA->isDefaultVersion())
13048 HasComplained |= Complain;
13057 candidateHasExactlyCorrectType(FunDecl)) {
13058 Matches.push_back(std::make_pair(
13059 CurAccessFunPair, cast<FunctionDecl>(FunDecl->getCanonicalDecl())));
13060 FoundNonTemplateFunction =
true;
13068 bool FindAllFunctionsThatMatchTargetTypeExactly() {
13073 if (IsInvalidFormOfPointerToMemberFunction())
13089 = dyn_cast<FunctionTemplateDecl>(Fn)) {
13090 if (AddMatchingTemplateFunction(FunctionTemplate, I.getPair()))
13095 AddMatchingNonTemplateFunction(Fn, I.getPair()))
13098 assert(Ret || Matches.empty());
13102 void EliminateAllExceptMostSpecializedTemplate() {
13115 for (
unsigned I = 0, E = Matches.size(); I != E; ++I)
13116 MatchesCopy.
addDecl(Matches[I].second, Matches[I].first.getAccess());
13121 MatchesCopy.
begin(), MatchesCopy.
end(), FailedCandidates,
13123 S.
PDiag(diag::err_addr_ovl_ambiguous)
13124 << Matches[0].second->getDeclName(),
13125 S.
PDiag(diag::note_ovl_candidate)
13126 << (
unsigned)oc_function << (
unsigned)ocs_described_template,
13127 Complain, TargetFunctionType);
13129 if (Result != MatchesCopy.
end()) {
13131 Matches[0].first = Matches[Result - MatchesCopy.
begin()].first;
13132 Matches[0].second = cast<FunctionDecl>(*Result);
13135 HasComplained |= Complain;
13138 void EliminateAllTemplateMatches() {
13141 for (
unsigned I = 0, N = Matches.size(); I != N; ) {
13142 if (Matches[I].second->getPrimaryTemplate() ==
nullptr)
13145 Matches[I] = Matches[--N];
13151 void EliminateSuboptimalCudaMatches() {
13157 void ComplainNoMatchesFound()
const {
13158 assert(Matches.empty());
13160 << OvlExpr->
getName() << TargetFunctionType
13162 if (FailedCandidates.
empty())
13173 dyn_cast<FunctionDecl>((*I)->getUnderlyingDecl()))
13181 bool IsInvalidFormOfPointerToMemberFunction()
const {
13182 return TargetTypeIsNonStaticMemberFunction &&
13186 void ComplainIsInvalidFormOfPointerToMemberFunction()
const {
13194 bool IsStaticMemberFunctionFromBoundPointer()
const {
13195 return StaticMemberFunctionFromBoundPointer;
13198 void ComplainIsStaticMemberFunctionFromBoundPointer()
const {
13200 diag::err_invalid_form_pointer_member_function)
13204 void ComplainOfInvalidConversion()
const {
13206 << OvlExpr->
getName() << TargetType;
13209 void ComplainMultipleMatchesFound()
const {
13210 assert(Matches.size() > 1);
13217 bool hadMultipleCandidates()
const {
return (OvlExpr->
getNumDecls() > 1); }
13219 int getNumMatches()
const {
return Matches.size(); }
13222 if (Matches.size() != 1)
return nullptr;
13223 return Matches[0].second;
13227 if (Matches.size() != 1)
return nullptr;
13228 return &Matches[0].first;
13253 bool *pHadMultipleCandidates) {
13256 AddressOfFunctionResolver Resolver(*
this, AddressOfExpr, TargetType,
13258 int NumMatches = Resolver.getNumMatches();
13260 bool ShouldComplain = Complain && !Resolver.hasComplained();
13261 if (NumMatches == 0 && ShouldComplain) {
13262 if (Resolver.IsInvalidFormOfPointerToMemberFunction())
13263 Resolver.ComplainIsInvalidFormOfPointerToMemberFunction();
13265 Resolver.ComplainNoMatchesFound();
13267 else if (NumMatches > 1 && ShouldComplain)
13268 Resolver.ComplainMultipleMatchesFound();
13269 else if (NumMatches == 1) {
13270 Fn = Resolver.getMatchingFunctionDecl();
13273 ResolveExceptionSpec(AddressOfExpr->
getExprLoc(), FPT);
13274 FoundResult = *Resolver.getMatchingFunctionAccessPair();
13276 if (Resolver.IsStaticMemberFunctionFromBoundPointer())
13277 Resolver.ComplainIsStaticMemberFunctionFromBoundPointer();
13279 CheckAddressOfMemberAccess(AddressOfExpr, FoundResult);
13283 if (pHadMultipleCandidates)
13284 *pHadMultipleCandidates = Resolver.hadMultipleCandidates();
13299 bool IsResultAmbiguous =
false;
13307 return static_cast<int>(IdentifyCUDAPreference(Caller, FD1)) -
13308 static_cast<int>(IdentifyCUDAPreference(Caller, FD2));
13319 FD2->getAssociatedConstraints(AC2);
13320 bool AtLeastAsConstrained1, AtLeastAsConstrained2;
13321 if (IsAtLeastAsConstrained(FD1, AC1, FD2, AC2, AtLeastAsConstrained1))
13322 return std::nullopt;
13323 if (IsAtLeastAsConstrained(FD2, AC2, FD1, AC1, AtLeastAsConstrained2))
13324 return std::nullopt;
13325 if (AtLeastAsConstrained1 == AtLeastAsConstrained2)
13326 return std::nullopt;
13327 return AtLeastAsConstrained1;
13334 auto *FD = dyn_cast<FunctionDecl>(I->getUnderlyingDecl());
13342 auto FoundBetter = [&]() {
13343 IsResultAmbiguous =
false;
13354 if (getLangOpts().CUDA) {
13355 int PreferenceByCUDA = CheckCUDAPreference(FD,
Result);
13357 if (PreferenceByCUDA != 0) {
13359 if (PreferenceByCUDA > 0)
13366 std::optional<bool> MoreConstrainedThanPrevious =
13367 CheckMoreConstrained(FD,
Result);
13368 if (!MoreConstrainedThanPrevious) {
13369 IsResultAmbiguous =
true;
13370 AmbiguousDecls.push_back(FD);
13373 if (!*MoreConstrainedThanPrevious)
13380 if (IsResultAmbiguous)
13391 if (getLangOpts().
CUDA && CheckCUDAPreference(Skipped,
Result) != 0)
13393 if (!CheckMoreConstrained(Skipped,
Result))
13409 ExprResult &SrcExpr,
bool DoFunctionPointerConversion) {
13414 FunctionDecl *Found = resolveAddressOfSingleOverloadCandidate(E, DAP);
13423 CheckAddressOfMemberAccess(E, DAP);
13424 ExprResult Res = FixOverloadedFunctionReference(E, DAP, Found);
13429 SrcExpr = DefaultFunctionArrayConversion(Fixed,
false);
13474 = cast<FunctionTemplateDecl>((*I)->getUnderlyingDecl());
13503 NoteAllOverloadCandidates(ovl);
13509 if (FoundResult) *FoundResult = I.getPair();
13528 ExprResult &SrcExpr,
bool doFunctionPointerConversion,
bool complain,
13530 unsigned DiagIDForComplaining) {
13537 if (
FunctionDecl *fn = ResolveSingleFunctionTemplateSpecialization(
13549 isa<CXXMethodDecl>(fn) &&
13550 cast<CXXMethodDecl>(fn)->isInstance()) {
13551 if (!complain)
return false;
13554 diag::err_bound_member_function)
13567 SingleFunctionExpression =
13568 FixOverloadedFunctionReference(SrcExpr.
get(), found, fn);
13571 if (doFunctionPointerConversion) {
13572 SingleFunctionExpression =
13573 DefaultFunctionArrayLvalueConversion(SingleFunctionExpression.
get());
13574 if (SingleFunctionExpression.
isInvalid()) {
13581 if (!SingleFunctionExpression.
isUsable()) {
13583 Diag(OpRangeForComplaining.
getBegin(), DiagIDForComplaining)
13585 << DestTypeForComplaining
13586 << OpRangeForComplaining
13588 NoteAllOverloadCandidates(SrcExpr.
get());
13597 SrcExpr = SingleFunctionExpression;
13607 bool PartialOverloading,
13609 NamedDecl *Callee = FoundDecl.getDecl();
13610 if (isa<UsingShadowDecl>(Callee))
13611 Callee = cast<UsingShadowDecl>(Callee)->getTargetDecl();
13614 if (ExplicitTemplateArgs) {
13615 assert(!KnownValid &&
"Explicit template arguments?");
13624 PartialOverloading);
13629 = dyn_cast<FunctionTemplateDecl>(Callee)) {
13631 ExplicitTemplateArgs, Args, CandidateSet,
13633 PartialOverloading);
13637 assert(!KnownValid &&
"unhandled case in overloaded call candidate");
13645 bool PartialOverloading) {
13668 assert(!(*I)->getDeclContext()->isRecord());
13669 assert(isa<UsingShadowDecl>(*I) ||
13670 !(*I)->getDeclContext()->isFunctionOrMethod());
13671 assert((*I)->getUnderlyingDecl()->isFunctionOrFunctionTemplate());
13681 ExplicitTemplateArgs = &TABuffer;
13687 CandidateSet, PartialOverloading,
13692 Args, ExplicitTemplateArgs,
13693 CandidateSet, PartialOverloading);
13703 CandidateSet,
false,
false);
13709 switch (Name.getCXXOverloadedOperator()) {
13710 case OO_New:
case OO_Array_New:
13711 case OO_Delete:
case OO_Array_Delete:
13734 if (DC->isTransparentContext())
13750 if (
auto *RD = dyn_cast<CXXRecordDecl>(DC)) {
13755 if (FoundInClass) {
13756 *FoundInClass = RD;
13759 R.
addDecl(Best->FoundDecl.getDecl(), Best->FoundDecl.getAccess());
13776 AssociatedNamespaces,
13777 AssociatedClasses);
13781 for (Sema::AssociatedNamespaceSet::iterator
13782 it = AssociatedNamespaces.begin(),
13783 end = AssociatedNamespaces.end(); it !=
end; ++it) {
13785 if (
Std &&
Std->Encloses(*it))
13795 SuggestedNamespaces.insert(*it);
13799 SemaRef.
Diag(R.
getNameLoc(), diag::err_not_found_by_two_phase_lookup)
13801 if (SuggestedNamespaces.empty()) {
13802 SemaRef.
Diag(Best->Function->getLocation(),
13803 diag::note_not_found_by_two_phase_lookup)
13805 }
else if (SuggestedNamespaces.size() == 1) {
13806 SemaRef.
Diag(Best->Function->getLocation(),
13807 diag::note_not_found_by_two_phase_lookup)
13813 SemaRef.
Diag(Best->Function->getLocation(),
13814 diag::note_not_found_by_two_phase_lookup)
13846class BuildRecoveryCallExprRAII {
13851 BuildRecoveryCallExprRAII(
Sema &S) : SemaRef(S), SatStack(S) {
13873 bool EmptyLookup,
bool AllowTypoCorrection) {
13881 BuildRecoveryCallExprRAII RCE(SemaRef);
13891 ExplicitTemplateArgs = &TABuffer;
13899 ExplicitTemplateArgs, Args, &FoundInClass)) {
13901 }
else if (EmptyLookup) {
13906 ExplicitTemplateArgs !=
nullptr,
13907 dyn_cast<MemberExpr>(Fn));
13909 AllowTypoCorrection
13915 }
else if (FoundInClass && SemaRef.
getLangOpts().MSVCCompat) {
13930 assert(!R.
empty() &&
"lookup results empty despite recovery");
13941 if ((*R.
begin())->isCXXClassMember())
13943 ExplicitTemplateArgs, S);
13944 else if (ExplicitTemplateArgs || TemplateKWLoc.
isValid())
13946 ExplicitTemplateArgs);
13973 assert(!ULE->
getQualifier() &&
"qualified name with ADL");
13980 (F = dyn_cast<FunctionDecl>(*ULE->
decls_begin())) &&
13982 llvm_unreachable(
"performing ADL for builtin");
13985 assert(getLangOpts().
CPlusPlus &&
"ADL enabled in C");
13989 UnbridgedCastsSet UnbridgedCasts;
13997 AddOverloadedCallCandidates(ULE, Args, *CandidateSet);
13999 if (getLangOpts().MSVCCompat &&
14000 CurContext->isDependentContext() && !isSFINAEContext() &&
14001 (isa<FunctionDecl>(CurContext) || isa<CXXRecordDecl>(CurContext))) {
14004 if (CandidateSet->
empty() ||
14013 RParenLoc, CurFPFeatureOverrides());
14020 if (CandidateSet->
empty())
14023 UnbridgedCasts.restore();
14030 std::optional<QualType>
Result;
14033 if (!Candidate.Function)
14035 if (Candidate.Function->isInvalidDecl())
14037 QualType T = Candidate.Function->getReturnType();
14050 if (Best && *Best != CS.
end())
14051 ConsiderCandidate(**Best);
14054 for (
const auto &
C : CS)
14056 ConsiderCandidate(
C);
14059 for (
const auto &
C : CS)
14060 ConsiderCandidate(
C);
14065 if (
Value.isNull() ||
Value->isUndeducedType())
14082 bool AllowTypoCorrection) {
14083 switch (OverloadResult) {
14094 Res.
get(), FDecl, LParenLoc, Args, RParenLoc, ExecConfig,
14095 false, (*Best)->IsADLCandidate);
14103 CandidateSet->
empty(),
14104 AllowTypoCorrection);
14111 for (
const Expr *Arg : Args) {
14112 if (!Arg->getType()->isFunctionType())
14114 if (
auto *DRE = dyn_cast<DeclRefExpr>(Arg->IgnoreParenImpCasts())) {
14115 auto *FD = dyn_cast<FunctionDecl>(DRE->getDecl());
14118 Arg->getExprLoc()))
14126 SemaRef.
PDiag(diag::err_ovl_no_viable_function_in_call)
14135 SemaRef.
PDiag(diag::err_ovl_ambiguous_call)
14143 SemaRef.
PDiag(diag::err_ovl_deleted_call)
14155 Res.
get(), FDecl, LParenLoc, Args, RParenLoc, ExecConfig,
14156 false, (*Best)->IsADLCandidate);
14162 SubExprs.append(Args.begin(), Args.end());
14169 for (
auto I = CS.
begin(), E = CS.
end(); I != E; ++I) {
14190 bool AllowTypoCorrection,
14191 bool CalleesAddressIsTaken) {
14196 if (buildOverloadedCallSet(S, Fn, ULE, Args, LParenLoc, &CandidateSet,
14202 if (CalleesAddressIsTaken)
14216 if (
const auto *TP =
14220 VK_PRValue, RParenLoc, CurFPFeatureOverrides());
14226 ExecConfig, &CandidateSet, &Best,
14227 OverloadResult, AllowTypoCorrection);
14231 return Functions.
size() > 1 ||
14232 (Functions.
size() == 1 &&
14233 isa<FunctionTemplateDecl>((*Functions.
begin())->getUnderlyingDecl()));
14248 bool HadMultipleCandidates) {
14253 Exp = InitializeExplicitObjectArgument(*
this, E, Method);
14255 Exp = PerformImplicitObjectArgumentInitialization(E,
nullptr,
14256 FoundDecl, Method);
14265 auto *CE = dyn_cast<CastExpr>(SubE);
14266 if (CE && CE->getCastKind() == CK_NoOp)
14267 SubE = CE->getSubExpr();
14269 if (
auto *BE = dyn_cast<CXXBindTemporaryExpr>(SubE))
14270 SubE = BE->getSubExpr();
14271 if (isa<LambdaExpr>(SubE)) {
14277 PushExpressionEvaluationContext(
14278 ExpressionEvaluationContext::PotentiallyEvaluated);
14279 ExprResult BlockExp = BuildBlockForLambdaConversion(
14281 PopExpressionEvaluationContext();
14299 Expr *ObjectParam = Exp.
get();
14302 CurFPFeatureOverrides());
14312 Exp.
get()->getEndLoc(),
14313 CurFPFeatureOverrides());
14316 if (CheckFunctionCall(Method, CE,
14341 Expr *Input,
bool PerformADL) {
14343 assert(Op !=
OO_None &&
"Invalid opcode for overloaded unary operator");
14351 Expr *Args[2] = { Input,
nullptr };
14352 unsigned NumArgs = 1;
14357 if (Opc == UO_PostInc || Opc == UO_PostDec) {
14370 CurFPFeatureOverrides());
14379 CurFPFeatureOverrides());
14386 AddNonMemberOperatorCandidates(Fns, ArgsArray, CandidateSet);
14389 AddMemberOperatorCandidates(Op, OpLoc, ArgsArray, CandidateSet);
14393 AddArgumentDependentLookupCandidates(OpName, OpLoc, ArgsArray,
14399 AddBuiltinOperatorCandidates(Op, OpLoc, ArgsArray, CandidateSet);
14401 bool HadMultipleCandidates = (CandidateSet.
size() > 1);
14416 if (
CXXMethodDecl *Method = dyn_cast<CXXMethodDecl>(FnDecl)) {
14417 CheckMemberOperatorAccess(OpLoc, Input,
nullptr, Best->FoundDecl);
14420 if (Method->isExplicitObjectMemberFunction())
14421 InputInit = InitializeExplicitObjectArgument(*
this, Input, Method);
14423 InputInit = PerformImplicitObjectArgumentInitialization(
14424 Input,
nullptr, Best->FoundDecl, Method);
14427 Base = Input = InputInit.
get();
14438 Input = InputInit.
get();
14443 Base, HadMultipleCandidates,
14455 Context, Op, FnExpr.
get(), ArgsArray, ResultTy, VK, OpLoc,
14456 CurFPFeatureOverrides(), Best->IsADLCandidate);
14458 if (CheckCallReturnType(FnDecl->
getReturnType(), OpLoc, TheCall, FnDecl))
14461 if (CheckFunctionCall(FnDecl, TheCall,
14464 return CheckForImmediateInvocation(MaybeBindToTemporary(TheCall), FnDecl);
14469 ExprResult InputRes = PerformImplicitConversion(
14470 Input, Best->BuiltinParamTypes[0], Best->Conversions[0], AA_Passing,
14471 CCK_ForBuiltinOverloadedOp);
14474 Input = InputRes.
get();
14494 PDiag(diag::err_ovl_ambiguous_oper_unary)
14519 return CreateBuiltinUnaryOp(OpLoc, Opc, Input);
14536 AddNonMemberOperatorCandidates(Fns, Args, CandidateSet);
14539 AddMemberOperatorCandidates(Op, OpLoc, Args, CandidateSet);
14541 AddMemberOperatorCandidates(Op, OpLoc, {Args[1], Args[0]}, CandidateSet,
14546 AddMemberOperatorCandidates(ExtraOp, OpLoc, Args, CandidateSet);
14548 AddMemberOperatorCandidates(ExtraOp, OpLoc, {Args[1], Args[0]},
14556 if (Op != OO_Equal && PerformADL) {
14558 AddArgumentDependentLookupCandidates(OpName, OpLoc, Args,
14564 AddArgumentDependentLookupCandidates(ExtraOpName, OpLoc, Args,
14583 AddBuiltinOperatorCandidates(Op, OpLoc, Args, CandidateSet);
14612 Expr *RHS,
bool PerformADL,
14613 bool AllowRewrittenCandidates,
14615 Expr *Args[2] = { LHS, RHS };
14619 AllowRewrittenCandidates =
false;
14625 if (Args[0]->isTypeDependent() || Args[1]->isTypeDependent()) {
14650 CurFPFeatureOverrides());
14655 if (Opc == BO_PtrMemD) {
14656 auto CheckPlaceholder = [&](
Expr *&Arg) {
14665 if (CheckPlaceholder(Args[0]) || CheckPlaceholder(Args[1]))
14667 return CreateBuiltinBinOp(OpLoc, Opc, Args[0], Args[1]);
14686 if (Opc == BO_Assign && !Args[0]->getType()->isOverloadableType())
14687 return CreateBuiltinBinOp(OpLoc, Opc, Args[0], Args[1]);
14692 Op, OpLoc, AllowRewrittenCandidates));
14694 CandidateSet.
exclude(DefaultedFn);
14695 LookupOverloadedBinOp(CandidateSet, Op, Fns, Args, PerformADL);
14697 bool HadMultipleCandidates = (CandidateSet.
size() > 1);
14706 bool IsReversed = Best->isReversed();
14708 std::swap(Args[0], Args[1]);
14725 if (Best->RewriteKind && ChosenOp == OO_EqualEqual &&
14729 Diag(OpLoc, IsExtension ? diag::ext_ovl_rewrite_equalequal_not_bool
14730 : diag::err_ovl_rewrite_equalequal_not_bool)
14738 if (AllowRewrittenCandidates && !IsReversed &&
14746 if (Cand.Viable && Cand.Function && Cand.isReversed() &&
14748 for (
unsigned ArgIdx = 0; ArgIdx < 2; ++ArgIdx) {
14750 *
this, OpLoc, Cand.Conversions[ArgIdx],
14751 Best->Conversions[ArgIdx]) ==
14753 AmbiguousWith.push_back(Cand.Function);
14760 if (!AmbiguousWith.empty()) {
14761 bool AmbiguousWithSelf =
14762 AmbiguousWith.size() == 1 &&
14764 Diag(OpLoc, diag::ext_ovl_ambiguous_oper_binary_reversed)
14766 << Args[0]->
getType() << Args[1]->
getType() << AmbiguousWithSelf
14768 if (AmbiguousWithSelf) {
14770 diag::note_ovl_ambiguous_oper_binary_reversed_self);
14775 if (
auto *MD = dyn_cast<CXXMethodDecl>(FnDecl))
14776 if (Op == OverloadedOperatorKind::OO_EqualEqual &&
14778 !MD->hasCXXExplicitFunctionObjectParameter() &&
14780 MD->getFunctionObjectParameterType(),
14781 MD->getParamDecl(0)->getType().getNonReferenceType()) &&
14783 MD->getFunctionObjectParameterType(),
14786 MD->getFunctionObjectParameterType(),
14789 diag::note_ovl_ambiguous_eqeq_reversed_self_non_const);
14792 diag::note_ovl_ambiguous_oper_binary_selected_candidate);
14793 for (
auto *F : AmbiguousWith)
14794 Diag(F->getLocation(),
14795 diag::note_ovl_ambiguous_oper_binary_reversed_candidate);
14801 if (
CXXMethodDecl *Method = dyn_cast<CXXMethodDecl>(FnDecl)) {
14803 CheckMemberOperatorAccess(OpLoc, Args[0], Args[1], Best->FoundDecl);
14807 if (Method->isExplicitObjectMemberFunction()) {
14808 Arg0 = InitializeExplicitObjectArgument(*
this, Args[0], FnDecl);
14811 Arg0 = PerformImplicitObjectArgumentInitialization(
14812 Args[0],
nullptr, Best->FoundDecl, Method);
14814 Arg1 = PerformCopyInitialization(
14825 ExprResult Arg0 = PerformCopyInitialization(
14833 PerformCopyInitialization(
14845 Best->FoundDecl,
Base,
14846 HadMultipleCandidates, OpLoc);
14857 const Expr *ImplicitThis =
nullptr;
14862 Context, ChosenOp, FnExpr.
get(), Args, ResultTy, VK, OpLoc,
14863 CurFPFeatureOverrides(), Best->IsADLCandidate);
14865 if (
const auto *Method = dyn_cast<CXXMethodDecl>(FnDecl);
14866 Method && Method->isImplicitObjectMemberFunction()) {
14868 ImplicitThis = ArgsArray[0];
14869 ArgsArray = ArgsArray.slice(1);
14872 if (CheckCallReturnType(FnDecl->
getReturnType(), OpLoc, TheCall,
14877 if (Op == OO_Equal)
14878 DiagnoseSelfMove(Args[0], Args[1], OpLoc);
14880 if (ImplicitThis) {
14883 cast<CXXMethodDecl>(FnDecl)->getFunctionObjectParameterType());
14885 CheckArgAlignment(OpLoc, FnDecl,
"'this'", ThisType,
14889 checkCall(FnDecl,
nullptr, ImplicitThis, ArgsArray,
14891 VariadicDoesNotApply);
14893 ExprResult R = MaybeBindToTemporary(TheCall);
14897 R = CheckForImmediateInvocation(R, FnDecl);
14904 (Op == OO_Spaceship && IsReversed)) {
14905 if (Op == OO_ExclaimEqual) {
14906 assert(ChosenOp == OO_EqualEqual &&
"unexpected operator name");
14907 R = CreateBuiltinUnaryOp(OpLoc, UO_LNot, R.
get());
14909 assert(ChosenOp == OO_Spaceship &&
"unexpected operator name");
14911 Expr *ZeroLiteral =
14917 pushCodeSynthesisContext(Ctx);
14919 R = CreateOverloadedBinOp(
14920 OpLoc, Opc, Fns, IsReversed ? ZeroLiteral : R.
get(),
14921 IsReversed ? R.
get() : ZeroLiteral,
true,
14924 popCodeSynthesisContext();
14929 assert(ChosenOp == Op &&
"unexpected operator name");
14933 if (Best->RewriteKind !=
CRK_None)
14941 ExprResult ArgsRes0 = PerformImplicitConversion(
14942 Args[0], Best->BuiltinParamTypes[0], Best->Conversions[0],
14943 AA_Passing, CCK_ForBuiltinOverloadedOp);
14946 Args[0] = ArgsRes0.
get();
14948 ExprResult ArgsRes1 = PerformImplicitConversion(
14949 Args[1], Best->BuiltinParamTypes[1], Best->Conversions[1],
14950 AA_Passing, CCK_ForBuiltinOverloadedOp);
14953 Args[1] = ArgsRes1.
get();
14963 if (Opc == BO_Comma)
14968 if (DefaultedFn && Opc == BO_Cmp) {
14969 ExprResult E = BuildSynthesizedThreeWayComparison(OpLoc, Fns, Args[0],
14970 Args[1], DefaultedFn);
14985 Opc >= BO_Assign && Opc <= BO_OrAssign) {
14986 Diag(OpLoc, diag::err_ovl_no_viable_oper)
14989 if (Args[0]->getType()->isIncompleteType()) {
14990 Diag(OpLoc, diag::note_assign_lhs_incomplete)
15004 Result = CreateBuiltinBinOp(OpLoc, Opc, Args[0], Args[1]);
15006 assert(
Result.isInvalid() &&
15007 "C++ binary operator overloading is missing candidates!");
15016 << Args[0]->getType()
15017 << Args[1]->getType()
15018 << Args[0]->getSourceRange()
15019 << Args[1]->getSourceRange()),
15025 if (isImplicitlyDeleted(Best->Function)) {
15029 Diag(OpLoc, diag::err_ovl_deleted_special_oper)
15033 Diag(OpLoc, diag::err_ovl_deleted_comparison)
15034 << Args[0]->
getType() << DeletedFD;
15039 NoteDeletedFunction(DeletedFD);
15044 OpLoc, PDiag(diag::err_ovl_deleted_oper)
15046 .getCXXOverloadedOperator())
15055 return CreateBuiltinBinOp(OpLoc, Opc, Args[0], Args[1]);
15071 "cannot use prvalue expressions more than once");
15072 Expr *OrigLHS = LHS;
15073 Expr *OrigRHS = RHS;
15077 LHS =
new (Context)
15080 RHS =
new (Context)
15084 ExprResult Eq = CreateOverloadedBinOp(OpLoc, BO_EQ, Fns, LHS, RHS,
true,
true,
15086 if (
Eq.isInvalid())
15089 ExprResult Less = CreateOverloadedBinOp(OpLoc, BO_LT, Fns, LHS, RHS,
true,
15090 true, DefaultedFn);
15091 if (
Less.isInvalid())
15096 Greater = CreateOverloadedBinOp(OpLoc, BO_LT, Fns, RHS, LHS,
true,
true,
15103 struct Comparison {
15118 for (; I >= 0; --I) {
15120 auto *VI = Info->lookupValueInfo(Comparisons[I].
Result);
15131 Result = ActOnConditionalOp(OpLoc, OpLoc, Comparisons[I].Cmp.get(),
15143 Context, OrigLHS, OrigRHS, BO_Cmp,
Result.get()->getType(),
15144 Result.get()->getValueKind(),
Result.get()->getObjectKind(), OpLoc,
15145 CurFPFeatureOverrides());
15146 Expr *SemanticForm[] = {LHS, RHS,
Result.get()};
15156 unsigned NumArgsSlots =
15157 MethodArgs.size() + std::max<unsigned>(Args.size(), NumParams);
15160 MethodArgs.reserve(MethodArgs.size() + NumArgsSlots);
15161 bool IsError =
false;
15164 for (
unsigned i = 0; i != NumParams; i++) {
15166 if (i < Args.size()) {
15184 MethodArgs.push_back(Arg);
15194 Args.push_back(
Base);
15195 for (
auto *e : ArgExpr) {
15204 ArgExpr.back()->getEndLoc());
15222 CurFPFeatureOverrides());
15226 UnbridgedCastsSet UnbridgedCasts;
15236 AddMemberOperatorCandidates(OO_Subscript, LLoc, Args, CandidateSet);
15239 if (Args.size() == 2)
15240 AddBuiltinOperatorCandidates(OO_Subscript, LLoc, Args, CandidateSet);
15242 bool HadMultipleCandidates = (CandidateSet.
size() > 1);
15255 CheckMemberOperatorAccess(LLoc, Args[0], ArgExpr, Best->FoundDecl);
15264 InitializeExplicitObjectArgument(*
this, Args[0], Method);
15267 Args[0] = Res.
get();
15270 ExprResult Arg0 = PerformImplicitObjectArgumentInitialization(
15271 Args[0],
nullptr, Best->FoundDecl, Method);
15275 MethodArgs.push_back(Arg0.
get());
15279 *
this, MethodArgs, Method, ArgExpr, LLoc);
15287 *
this, FnDecl, Best->FoundDecl,
Base, HadMultipleCandidates,
15298 Context, OO_Subscript, FnExpr.
get(), MethodArgs, ResultTy, VK, RLoc,
15299 CurFPFeatureOverrides());
15301 if (CheckCallReturnType(FnDecl->
getReturnType(), LLoc, TheCall, FnDecl))
15304 if (CheckFunctionCall(Method, TheCall,
15308 return CheckForImmediateInvocation(MaybeBindToTemporary(TheCall),
15314 ExprResult ArgsRes0 = PerformImplicitConversion(
15315 Args[0], Best->BuiltinParamTypes[0], Best->Conversions[0],
15316 AA_Passing, CCK_ForBuiltinOverloadedOp);
15319 Args[0] = ArgsRes0.
get();
15321 ExprResult ArgsRes1 = PerformImplicitConversion(
15322 Args[1], Best->BuiltinParamTypes[1], Best->Conversions[1],
15323 AA_Passing, CCK_ForBuiltinOverloadedOp);
15326 Args[1] = ArgsRes1.
get();
15334 CandidateSet.
empty()
15335 ? (PDiag(diag::err_ovl_no_oper)
15336 << Args[0]->getType() << 0
15337 << Args[0]->getSourceRange() << Range)
15338 : (PDiag(diag::err_ovl_no_viable_subscript)
15339 << Args[0]->getType() << Args[0]->getSourceRange() << Range);
15346 if (Args.size() == 2) {
15349 LLoc, PDiag(diag::err_ovl_ambiguous_oper_binary)
15350 <<
"[]" << Args[0]->getType() << Args[1]->getType()
15351 << Args[0]->getSourceRange() << Range),
15356 PDiag(diag::err_ovl_ambiguous_subscript_call)
15357 << Args[0]->getType()
15358 << Args[0]->getSourceRange() << Range),
15366 <<
"[]" << Args[0]->getSourceRange()
15373 return CreateBuiltinArraySubscriptExpr(Args[0], LLoc, Args[1], RLoc);
15387 Expr *ExecConfig,
bool IsExecConfig,
15388 bool AllowRecovery) {
15397 if (
BinaryOperator *op = dyn_cast<BinaryOperator>(NakedMemExpr)) {
15399 assert(op->getOpcode() == BO_PtrMemD || op->getOpcode() == BO_PtrMemI);
15412 QualType objectType = op->getLHS()->getType();
15413 if (op->getOpcode() == BO_PtrMemI)
15417 Qualifiers difference = objectQuals - funcQuals;
15421 std::string qualsString = difference.
getAsString();
15422 Diag(LParenLoc, diag::err_pointer_to_member_call_drops_quals)
15425 << (qualsString.find(
' ') == std::string::npos ? 1 : 2);
15429 Context, MemExprE, Args, resultType, valueKind, RParenLoc,
15432 if (CheckCallReturnType(proto->
getReturnType(), op->getRHS()->getBeginLoc(),
15436 if (ConvertArgumentsForCall(call, op,
nullptr, proto, Args, RParenLoc))
15439 if (CheckOtherCall(call, proto))
15442 return MaybeBindToTemporary(call);
15449 if (!AllowRecovery)
15451 std::vector<Expr *> SubExprs = {MemExprE};
15452 llvm::append_range(SubExprs, Args);
15453 return CreateRecoveryExpr(MemExprE->
getBeginLoc(), RParenLoc, SubExprs,
15456 if (isa<CXXPseudoDestructorExpr>(NakedMemExpr))
15458 RParenLoc, CurFPFeatureOverrides());
15460 UnbridgedCastsSet UnbridgedCasts;
15466 bool HadMultipleCandidates =
false;
15469 if (isa<MemberExpr>(NakedMemExpr)) {
15470 MemExpr = cast<MemberExpr>(NakedMemExpr);
15474 UnbridgedCasts.restore();
15492 TemplateArgs = &TemplateArgsBuffer;
15496 E = UnresExpr->
decls_end(); I != E; ++I) {
15498 QualType ExplicitObjectType = ObjectType;
15502 if (isa<UsingShadowDecl>(
Func))
15503 Func = cast<UsingShadowDecl>(
Func)->getTargetDecl();
15505 bool HasExplicitParameter =
false;
15506 if (
const auto *M = dyn_cast<FunctionDecl>(
Func);
15507 M && M->hasCXXExplicitFunctionObjectParameter())
15508 HasExplicitParameter =
true;
15509 else if (
const auto *M = dyn_cast<FunctionTemplateDecl>(
Func);
15511 M->getTemplatedDecl()->hasCXXExplicitFunctionObjectParameter())
15512 HasExplicitParameter =
true;
15514 if (HasExplicitParameter)
15518 if (getLangOpts().MicrosoftExt && isa<CXXConstructorDecl>(
Func)) {
15519 AddOverloadCandidate(cast<CXXConstructorDecl>(
Func), I.getPair(), Args,
15522 }
else if ((Method = dyn_cast<CXXMethodDecl>(
Func))) {
15528 AddMethodCandidate(Method, I.getPair(), ActingDC, ExplicitObjectType,
15529 ObjectClassification, Args, CandidateSet,
15532 AddMethodTemplateCandidate(cast<FunctionTemplateDecl>(
Func),
15533 I.getPair(), ActingDC, TemplateArgs,
15534 ExplicitObjectType, ObjectClassification,
15535 Args, CandidateSet,
15540 HadMultipleCandidates = (CandidateSet.
size() > 1);
15544 UnbridgedCasts.restore();
15547 bool Succeeded =
false;
15551 Method = cast<CXXMethodDecl>(Best->Function);
15552 FoundDecl = Best->FoundDecl;
15553 CheckUnresolvedMemberAccess(UnresExpr, Best->FoundDecl);
15554 if (DiagnoseUseOfOverloadedDecl(Best->FoundDecl, UnresExpr->
getNameLoc()))
15562 if (Method != FoundDecl.getDecl() &&
15563 DiagnoseUseOfOverloadedDecl(Method, UnresExpr->
getNameLoc()))
15572 PDiag(diag::err_ovl_no_viable_member_function_in_call)
15579 PDiag(diag::err_ovl_ambiguous_member_call)
15586 PDiag(diag::err_ovl_deleted_member_call)
15596 FixOverloadedFunctionReference(MemExprE, FoundDecl, Method);
15599 MemExprE = Res.
get();
15604 return BuildResolvedCallExpr(MemExprE, Method, LParenLoc, Args, RParenLoc,
15605 ExecConfig, IsExecConfig);
15615 assert(Method &&
"Member call to something that isn't a method?");
15626 HadMultipleCandidates, MemExpr->
getExprLoc());
15632 CurFPFeatureOverrides(), Proto->getNumParams());
15637 ExprResult ObjectArg = PerformImplicitObjectArgumentInitialization(
15638 MemExpr->
getBase(), Qualifier, FoundDecl, Method);
15643 RParenLoc, CurFPFeatureOverrides(),
15644 Proto->getNumParams());
15650 return BuildRecoveryExpr(ResultType);
15653 if (ConvertArgumentsForCall(TheCall, MemExpr, Method, Proto, Args,
15655 return BuildRecoveryExpr(ResultType);
15657 DiagnoseSentinelCalls(Method, LParenLoc, Args);
15659 if (CheckFunctionCall(Method, TheCall, Proto))
15665 if (
auto *MemE = dyn_cast<MemberExpr>(NakedMemExpr)) {
15666 if (
const EnableIfAttr *
Attr =
15667 CheckEnableIf(Method, LParenLoc, Args,
true)) {
15668 Diag(MemE->getMemberLoc(),
15669 diag::err_ovl_no_viable_member_function_in_call)
15672 diag::note_ovl_candidate_disabled_by_function_cond_attr)
15673 <<
Attr->getCond()->getSourceRange() <<
Attr->getMessage();
15678 if (isa<CXXConstructorDecl, CXXDestructorDecl>(CurContext) &&
15679 TheCall->getDirectCallee()->isPureVirtual()) {
15685 diag::warn_call_to_pure_virtual_member_function_from_ctor_dtor)
15686 << MD->
getDeclName() << isa<CXXDestructorDecl>(CurContext)
15690 if (getLangOpts().AppleKext)
15696 if (
auto *DD = dyn_cast<CXXDestructorDecl>(TheCall->getDirectCallee())) {
15698 bool CallCanBeVirtual = !MemExpr->
hasQualifier() || getLangOpts().AppleKext;
15699 CheckVirtualDtorCall(DD, MemExpr->
getBeginLoc(),
false,
15700 CallCanBeVirtual,
true,
15704 return CheckForImmediateInvocation(MaybeBindToTemporary(TheCall),
15705 TheCall->getDirectCallee());
15721 UnbridgedCastsSet UnbridgedCasts;
15725 assert(Object.get()->getType()->isRecordType() &&
15726 "Requires object type argument");
15739 if (RequireCompleteType(LParenLoc, Object.get()->getType(),
15740 diag::err_incomplete_object_call, Object.get()))
15744 LookupResult R(*
this, OpName, LParenLoc, LookupOrdinaryName);
15745 LookupQualifiedName(R,
Record->getDecl());
15746 R.suppressAccessDiagnostics();
15749 Oper != OperEnd; ++Oper) {
15750 AddMethodCandidate(Oper.getPair(), Object.get()->getType(),
15751 Object.get()->Classify(Context), Args, CandidateSet,
15763 bool IgnoreSurrogateFunctions =
false;
15764 if (CandidateSet.
size() == 1 &&
Record->getAsCXXRecordDecl()->isLambda()) {
15766 if (!Candidate.
Viable &&
15768 IgnoreSurrogateFunctions =
true;
15788 const auto &Conversions =
15789 cast<CXXRecordDecl>(
Record->getDecl())->getVisibleConversionFunctions();
15790 for (
auto I = Conversions.begin(), E = Conversions.end();
15791 !IgnoreSurrogateFunctions && I != E; ++I) {
15794 if (isa<UsingShadowDecl>(D))
15795 D = cast<UsingShadowDecl>(D)->getTargetDecl();
15799 if (isa<FunctionTemplateDecl>(D))
15812 AddSurrogateCandidate(Conv, I.getPair(), ActingContext, Proto,
15813 Object.get(), Args, CandidateSet);
15818 bool HadMultipleCandidates = (CandidateSet.
size() > 1);
15831 CandidateSet.
empty()
15832 ? (PDiag(diag::err_ovl_no_oper)
15833 << Object.get()->getType() << 1
15834 << Object.get()->getSourceRange())
15835 : (PDiag(diag::err_ovl_no_viable_object_call)
15836 << Object.get()->getType() << Object.get()->getSourceRange());
15843 if (!R.isAmbiguous())
15846 PDiag(diag::err_ovl_ambiguous_object_call)
15847 << Object.get()->getType()
15848 << Object.get()->getSourceRange()),
15855 PDiag(diag::err_ovl_deleted_object_call)
15856 << Object.get()->getType()
15857 << Object.get()->getSourceRange()),
15862 if (Best == CandidateSet.
end())
15865 UnbridgedCasts.restore();
15867 if (Best->Function ==
nullptr) {
15871 = cast<CXXConversionDecl>(
15872 Best->Conversions[0].UserDefined.ConversionFunction);
15874 CheckMemberOperatorAccess(LParenLoc, Object.get(),
nullptr,
15876 if (DiagnoseUseOfDecl(Best->FoundDecl, LParenLoc))
15878 assert(Conv == Best->FoundDecl.getDecl() &&
15879 "Found Decl & conversion-to-functionptr should be same, right?!");
15886 ExprResult Call = BuildCXXMemberCallExpr(Object.get(), Best->FoundDecl,
15887 Conv, HadMultipleCandidates);
15888 if (
Call.isInvalid())
15892 Context,
Call.get()->getType(), CK_UserDefinedConversion,
Call.get(),
15893 nullptr,
VK_PRValue, CurFPFeatureOverrides());
15895 return BuildCallExpr(S,
Call.get(), LParenLoc, Args, RParenLoc);
15898 CheckMemberOperatorAccess(LParenLoc, Object.get(),
nullptr, Best->FoundDecl);
15903 CXXMethodDecl *Method = cast<CXXMethodDecl>(Best->Function);
15916 Obj, HadMultipleCandidates,
15923 MethodArgs.reserve(NumParams + 1);
15925 bool IsError =
false;
15931 DiagnoseInvalidExplicitObjectParameterInLambda(Method);
15934 ExprResult ObjRes = PerformImplicitObjectArgumentInitialization(
15935 Object.get(),
nullptr, Best->FoundDecl, Method);
15940 MethodArgs.push_back(Object.get());
15944 *
this, MethodArgs, Method, Args, LParenLoc);
15947 if (Proto->isVariadic()) {
15949 for (
unsigned i = NumParams, e = Args.size(); i < e; i++) {
15950 ExprResult Arg = DefaultVariadicArgumentPromotion(Args[i], VariadicMethod,
15953 MethodArgs.push_back(Arg.
get());
15960 DiagnoseSentinelCalls(Method, LParenLoc, Args);
15968 Context, OO_Call, NewFn.
get(), MethodArgs, ResultTy, VK, RParenLoc,
15969 CurFPFeatureOverrides());
15971 if (CheckCallReturnType(Method->
getReturnType(), LParenLoc, TheCall, Method))
15974 if (CheckFunctionCall(Method, TheCall, Proto))
15977 return CheckForImmediateInvocation(MaybeBindToTemporary(TheCall), Method);
15985 bool *NoArrowOperatorFound) {
15986 assert(
Base->getType()->isRecordType() &&
15987 "left-hand side must have class type");
16004 if (RequireCompleteType(Loc,
Base->getType(),
16005 diag::err_typecheck_incomplete_tag,
Base))
16008 LookupResult R(*
this, OpName, OpLoc, LookupOrdinaryName);
16013 Oper != OperEnd; ++Oper) {
16014 AddMethodCandidate(Oper.getPair(),
Base->getType(),
Base->Classify(Context),
16015 std::nullopt, CandidateSet,
16019 bool HadMultipleCandidates = (CandidateSet.
size() > 1);
16030 if (CandidateSet.
empty()) {
16032 if (NoArrowOperatorFound) {
16035 *NoArrowOperatorFound =
true;
16038 Diag(OpLoc, diag::err_typecheck_member_reference_arrow)
16039 << BaseType <<
Base->getSourceRange();
16041 Diag(OpLoc, diag::note_typecheck_member_reference_suggestion)
16045 Diag(OpLoc, diag::err_ovl_no_viable_oper)
16046 <<
"operator->" <<
Base->getSourceRange();
16054 <<
"->" <<
Base->getType()
16055 <<
Base->getSourceRange()),
16062 <<
"->" <<
Base->getSourceRange()),
16067 CheckMemberOperatorAccess(OpLoc,
Base,
nullptr, Best->FoundDecl);
16070 CXXMethodDecl *Method = cast<CXXMethodDecl>(Best->Function);
16073 ExprResult R = InitializeExplicitObjectArgument(*
this,
Base, Method);
16079 Base,
nullptr, Best->FoundDecl, Method);
16087 Base, HadMultipleCandidates, OpLoc);
16097 ResultTy, VK, OpLoc, CurFPFeatureOverrides());
16099 if (CheckCallReturnType(Method->
getReturnType(), OpLoc, TheCall, Method))
16102 if (CheckFunctionCall(Method, TheCall,
16106 return CheckForImmediateInvocation(MaybeBindToTemporary(TheCall), Method);
16120 AddNonMemberOperatorCandidates(R.
asUnresolvedSet(), Args, CandidateSet,
16123 bool HadMultipleCandidates = (CandidateSet.
size() > 1);
16136 PDiag(diag::err_ovl_no_viable_function_in_call)
16151 nullptr, HadMultipleCandidates,
16160 for (
unsigned ArgIdx = 0, N = Args.size(); ArgIdx != N; ++ArgIdx) {
16161 ExprResult InputInit = PerformCopyInitialization(
16166 ConvArgs[ArgIdx] = InputInit.
get();
16175 LitEndLoc, UDSuffixLoc, CurFPFeatureOverrides());
16177 if (CheckCallReturnType(FD->
getReturnType(), UDSuffixLoc, UDL, FD))
16180 if (CheckFunctionCall(FD, UDL,
nullptr))
16183 return CheckForImmediateInvocation(MaybeBindToTemporary(UDL), FD);
16200 Scope *S =
nullptr;
16203 if (!MemberLookup.
empty()) {
16205 BuildMemberReferenceExpr(Range, Range->getType(), Loc,
16213 return FRS_DiagnosticIssued;
16216 BuildCallExpr(S, MemberRef.
get(), Loc, std::nullopt, Loc,
nullptr);
16219 return FRS_DiagnosticIssued;
16222 ExprResult FnR = CreateUnresolvedLookupExpr(
nullptr,
16226 return FRS_DiagnosticIssued;
16229 bool CandidateSetError = buildOverloadedCallSet(S, Fn, Fn, Range, Loc,
16231 if (CandidateSet->
empty() || CandidateSetError) {
16233 return FRS_NoViableFunction;
16241 return FRS_NoViableFunction;
16244 Loc,
nullptr, CandidateSet, &Best,
16249 return FRS_DiagnosticIssued;
16252 return FRS_Success;
16263 if (
ParenExpr *PE = dyn_cast<ParenExpr>(E)) {
16265 FixOverloadedFunctionReference(PE->getSubExpr(), Found, Fn);
16268 if (SubExpr.
get() == PE->getSubExpr())
16271 return new (Context)
16272 ParenExpr(PE->getLParen(), PE->getRParen(), SubExpr.
get());
16277 FixOverloadedFunctionReference(ICE->getSubExpr(), Found, Fn);
16280 assert(Context.
hasSameType(ICE->getSubExpr()->getType(),
16282 "Implicit cast type cannot be determined from overload");
16283 assert(ICE->path_empty() &&
"fixing up hierarchy conversion?");
16284 if (SubExpr.
get() == ICE->getSubExpr())
16289 CurFPFeatureOverrides());
16292 if (
auto *GSE = dyn_cast<GenericSelectionExpr>(E)) {
16293 if (!GSE->isResultDependent()) {
16295 FixOverloadedFunctionReference(GSE->getResultExpr(), Found, Fn);
16298 if (SubExpr.
get() == GSE->getResultExpr())
16305 unsigned ResultIdx = GSE->getResultIndex();
16306 AssocExprs[ResultIdx] = SubExpr.
get();
16308 if (GSE->isExprPredicate())
16310 Context, GSE->getGenericLoc(), GSE->getControllingExpr(),
16311 GSE->getAssocTypeSourceInfos(), AssocExprs, GSE->getDefaultLoc(),
16312 GSE->getRParenLoc(), GSE->containsUnexpandedParameterPack(),
16315 Context, GSE->getGenericLoc(), GSE->getControllingType(),
16316 GSE->getAssocTypeSourceInfos(), AssocExprs, GSE->getDefaultLoc(),
16317 GSE->getRParenLoc(), GSE->containsUnexpandedParameterPack(),
16326 assert(UnOp->getOpcode() == UO_AddrOf &&
16327 "Can only take the address of an overloaded function");
16329 if (Method->isStatic()) {
16337 FixOverloadedFunctionReference(UnOp->getSubExpr(), Found, Fn);
16340 if (SubExpr.
get() == UnOp->getSubExpr())
16343 if (CheckUseOfCXXMethodAsAddressOfOperand(UnOp->getBeginLoc(),
16344 SubExpr.
get(), Method))
16347 assert(isa<DeclRefExpr>(SubExpr.
get()) &&
16348 "fixed to something other than a decl ref");
16349 assert(cast<DeclRefExpr>(SubExpr.
get())->getQualifier() &&
16350 "fixed to a member ref with no nested name qualifier");
16361 (void)isCompleteType(UnOp->getOperatorLoc(), MemPtrType);
16365 UnOp->getOperatorLoc(),
false,
16366 CurFPFeatureOverrides());
16370 FixOverloadedFunctionReference(UnOp->getSubExpr(), Found, Fn);
16373 if (SubExpr.
get() == UnOp->getSubExpr())
16376 return CreateBuiltinUnaryOp(UnOp->getOperatorLoc(), UO_AddrOf,
16383 if (ULE->hasExplicitTemplateArgs()) {
16384 ULE->copyTemplateArgumentsInto(TemplateArgsBuffer);
16385 TemplateArgs = &TemplateArgsBuffer;
16400 Fn,
Type, ValueKind, ULE->getNameInfo(), ULE->getQualifierLoc(),
16401 Found.
getDecl(), ULE->getTemplateKeywordLoc(), TemplateArgs);
16409 if (MemExpr->hasExplicitTemplateArgs()) {
16410 MemExpr->copyTemplateArgumentsInto(TemplateArgsBuffer);
16411 TemplateArgs = &TemplateArgsBuffer;
16418 if (MemExpr->isImplicitAccess()) {
16419 if (cast<CXXMethodDecl>(Fn)->isStatic()) {
16422 MemExpr->getQualifierLoc(), Found.
getDecl(),
16423 MemExpr->getTemplateKeywordLoc(), TemplateArgs);
16428 if (MemExpr->getQualifier())
16429 Loc = MemExpr->getQualifierLoc().getBeginLoc();
16431 BuildCXXThisExpr(Loc, MemExpr->getBaseType(),
true);
16434 Base = MemExpr->getBase();
16438 if (cast<CXXMethodDecl>(Fn)->isStatic()) {
16446 return BuildMemberExpr(
16447 Base, MemExpr->isArrow(), MemExpr->getOperatorLoc(),
16448 MemExpr->getQualifierLoc(), MemExpr->getTemplateKeywordLoc(), Fn, Found,
16449 true, MemExpr->getMemberNameInfo(),
16453 llvm_unreachable(
"Invalid reference to overloaded function");
16459 return FixOverloadedFunctionReference(E.
get(), Found, Fn);
16464 if (!PartialOverloading || !
Function)
16468 if (
const auto *Proto =
16469 dyn_cast<FunctionProtoType>(
Function->getFunctionType()))
16470 if (Proto->isTemplateVariadic())
16472 if (
auto *Pattern =
Function->getTemplateInstantiationPattern())
16473 if (
const auto *Proto =
16474 dyn_cast<FunctionProtoType>(Pattern->getFunctionType()))
16475 if (Proto->isTemplateVariadic())
Defines the clang::ASTContext interface.
This file provides some common utility functions for processing Lambda related AST Constructs.
Defines the Diagnostic-related interfaces.
static bool isBooleanType(QualType Ty)
Defines the C++ Decl subclasses, other than those for templates (found in DeclTemplate....
Defines the clang::Expr interface and subclasses for C++ expressions.
static bool EvaluateAsBooleanCondition(const Expr *E, bool &Result, EvalInfo &Info)
static const GlobalDecl isTemplate(GlobalDecl GD, const TemplateArgumentList *&TemplateArgs)
static DiagnosticBuilder Diag(DiagnosticsEngine *Diags, const LangOptions &Features, FullSourceLoc TokLoc, const char *TokBegin, const char *TokRangeBegin, const char *TokRangeEnd, unsigned DiagID)
Produce a diagnostic highlighting some portion of a literal.
llvm::MachO::Record Record
Defines an enumeration for C++ overloaded operators.
Implements a partial diagnostic that can be emitted anwyhere in a DiagnosticBuilder stream.
static std::string getName(const CallEvent &Call)
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...
static ImplicitConversionSequence::CompareKind CompareStandardConversionSequences(Sema &S, SourceLocation Loc, const StandardConversionSequence &SCS1, const StandardConversionSequence &SCS2)
CompareStandardConversionSequences - Compare two standard conversion sequences to determine whether o...
static bool isNullPointerConstantForConversion(Expr *Expr, bool InOverloadResolution, ASTContext &Context)
static bool shouldSkipNotingLambdaConversionDecl(const FunctionDecl *Fn)
static const FunctionType * getConversionOpReturnTyAsFunction(CXXConversionDecl *Conv)
static bool functionHasPassObjectSizeParams(const FunctionDecl *FD)
static Comparison compareEnableIfAttrs(const Sema &S, const FunctionDecl *Cand1, const FunctionDecl *Cand2)
Compares the enable_if attributes of two FunctionDecls, for the purposes of overload resolution.
static Qualifiers CollectVRQualifiers(ASTContext &Context, Expr *ArgExpr)
CollectVRQualifiers - This routine returns Volatile/Restrict qualifiers, if any, found in visible typ...
@ ToPromotedUnderlyingType
static void AddOverloadedCallCandidate(Sema &S, DeclAccessPair FoundDecl, TemplateArgumentListInfo *ExplicitTemplateArgs, ArrayRef< Expr * > Args, OverloadCandidateSet &CandidateSet, bool PartialOverloading, bool KnownValid)
Add a single candidate to the overload set.
static ExprResult FinishOverloadedCallExpr(Sema &SemaRef, Scope *S, Expr *Fn, UnresolvedLookupExpr *ULE, SourceLocation LParenLoc, MultiExprArg Args, SourceLocation RParenLoc, Expr *ExecConfig, OverloadCandidateSet *CandidateSet, OverloadCandidateSet::iterator *Best, OverloadingResult OverloadResult, bool AllowTypoCorrection)
FinishOverloadedCallExpr - given an OverloadCandidateSet, builds and returns the completed call expre...
static ImplicitConversionSequence::CompareKind CompareQualificationConversions(Sema &S, const StandardConversionSequence &SCS1, const StandardConversionSequence &SCS2)
CompareQualificationConversions - Compares two standard conversion sequences to determine whether the...
static void dropPointerConversion(StandardConversionSequence &SCS)
dropPointerConversions - If the given standard conversion sequence involves any pointer conversions,...
static SourceLocation GetLocationForCandidate(const OverloadCandidate *Cand)
static const Expr * IgnoreNarrowingConversion(ASTContext &Ctx, const Expr *Converted)
Skip any implicit casts which could be either part of a narrowing conversion or after one in an impli...
static bool isQualificationConversionStep(QualType FromType, QualType ToType, bool CStyle, bool IsTopLevel, bool &PreviousToQualsIncludeConst, bool &ObjCLifetimeConversion)
Perform a single iteration of the loop for checking if a qualification conversion is valid.
static bool allowAmbiguity(ASTContext &Context, const FunctionDecl *F1, const FunctionDecl *F2)
static unsigned RankDeductionFailure(const DeductionFailureInfo &DFI)
static QualType BuildSimilarlyQualifiedPointerType(const Type *FromPtr, QualType ToPointee, QualType ToType, ASTContext &Context, bool StripObjCLifetime=false)
BuildSimilarlyQualifiedPointerType - In a pointer conversion from the pointer type FromPtr to a point...
static void forAllQualifierCombinations(QualifiersAndAtomic Quals, llvm::function_ref< void(QualifiersAndAtomic)> Callback)
static bool FindConversionForRefInit(Sema &S, ImplicitConversionSequence &ICS, QualType DeclType, SourceLocation DeclLoc, Expr *Init, QualType T2, bool AllowRvalues, bool AllowExplicit)
Look for a user-defined conversion to a value reference-compatible with DeclType.
static bool tryAtomicConversion(Sema &S, Expr *From, QualType ToType, bool InOverloadResolution, StandardConversionSequence &SCS, bool CStyle)
static Expr * GetExplicitObjectExpr(Sema &S, Expr *Obj, const FunctionDecl *Fun)
static bool hasDeprecatedStringLiteralToCharPtrConversion(const ImplicitConversionSequence &ICS)
static ExprResult CheckConvertedConstantExpression(Sema &S, Expr *From, QualType T, APValue &Value, Sema::CCEKind CCE, bool RequireInt, NamedDecl *Dest)
CheckConvertedConstantExpression - Check that the expression From is a converted constant expression ...
static void AddBuiltinAssignmentOperatorCandidates(Sema &S, QualType T, ArrayRef< Expr * > Args, OverloadCandidateSet &CandidateSet)
Helper function for AddBuiltinOperatorCandidates() that adds the volatile- and non-volatile-qualified...
static bool CheckConvertedConstantConversions(Sema &S, StandardConversionSequence &SCS)
Check that the specified conversion is permitted in a converted constant expression,...
static void NoteBuiltinOperatorCandidate(Sema &S, StringRef Opc, SourceLocation OpLoc, OverloadCandidate *Cand)
static ImplicitConversionSequence::CompareKind compareConversionFunctions(Sema &S, FunctionDecl *Function1, FunctionDecl *Function2)
Compare the user-defined conversion functions or constructors of two user-defined conversion sequence...
static void forAllQualifierCombinationsImpl(QualifiersAndAtomic Available, QualifiersAndAtomic Applied, llvm::function_ref< void(QualifiersAndAtomic)> Callback)
static const char * GetImplicitConversionName(ImplicitConversionKind Kind)
GetImplicitConversionName - Return the name of this kind of implicit conversion.
static bool checkAddressOfFunctionIsAvailable(Sema &S, const FunctionDecl *FD, bool Complain, bool InOverloadResolution, SourceLocation Loc)
Returns true if we can take the address of the function.
static ImplicitConversionSequence::CompareKind CompareDerivedToBaseConversions(Sema &S, SourceLocation Loc, const StandardConversionSequence &SCS1, const StandardConversionSequence &SCS2)
CompareDerivedToBaseConversions - Compares two standard conversion sequences to determine whether the...
static bool convertArgsForAvailabilityChecks(Sema &S, FunctionDecl *Function, Expr *ThisArg, SourceLocation CallLoc, ArrayRef< Expr * > Args, Sema::SFINAETrap &Trap, bool MissingImplicitThis, Expr *&ConvertedThis, SmallVectorImpl< Expr * > &ConvertedArgs)
static TemplateDecl * getDescribedTemplate(Decl *Templated)
static void CompleteNonViableCandidate(Sema &S, OverloadCandidate *Cand, ArrayRef< Expr * > Args, OverloadCandidateSet::CandidateSetKind CSK)
CompleteNonViableCandidate - Normally, overload resolution only computes up to the first bad conversi...
static QualType AdoptQualifiers(ASTContext &Context, QualType T, Qualifiers Qs)
Adopt the given qualifiers for the given type.
static void NoteAmbiguousUserConversions(Sema &S, SourceLocation OpLoc, OverloadCandidate *Cand)
static 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 void DiagnoseArityMismatch(Sema &S, NamedDecl *Found, Decl *D, unsigned NumFormalArgs)
General arity mismatch diagnosis over a candidate in a candidate set.
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 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 bool IsOverloaded(const UnresolvedSetImpl &Functions)
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 void PrepareExplicitObjectArgument(Sema &S, CXXMethodDecl *Method, Expr *Object, MultiExprArg &Args, SmallVectorImpl< Expr * > &NewArgs)
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 CheckArityMismatch(Sema &S, OverloadCandidate *Cand, unsigned NumArgs)
Additional arity mismatch diagnosis specific to a function overload candidates.
static bool shouldAddReversedEqEq(Sema &S, SourceLocation OpLoc, Expr *FirstOperand, FunctionDecl *EqFD)
static bool isFunctionAlwaysEnabled(const ASTContext &Ctx, const FunctionDecl *FD)
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 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)
Defines the SourceManager interface.
Allows QualTypes to be sorted and hence used in maps and sets.
C Language Family Type Representation.
A class for storing results from argument-dependent lookup.
void erase(NamedDecl *D)
Removes any data associated with a given decl.
llvm::mapped_iterator< decltype(Decls)::iterator, select_second > iterator
APValue - This class implements a discriminated union of [uninitialized] [APSInt] [APFloat],...
std::string getAsString(const ASTContext &Ctx, QualType Ty) const
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
const ConstantArrayType * getAsConstantArrayType(QualType T) const
QualType getAtomicType(QualType T) const
Return the uniqued reference to the atomic type for the specified type.
bool areLaxCompatibleSveTypes(QualType FirstType, QualType SecondType)
Return true if the given vector types are lax-compatible SVE vector types, false otherwise.
QualType getRValueReferenceType(QualType T) const
Return the uniqued reference to the type for an rvalue reference to the specified type.
unsigned getIntWidth(QualType T) const
const FunctionType * adjustFunctionType(const FunctionType *Fn, FunctionType::ExtInfo EInfo)
Change the ExtInfo on a function type.
bool areCompatibleRVVTypes(QualType FirstType, QualType SecondType)
Return true if the given types are an RISC-V vector builtin type and a VectorType that is a fixed-len...
const llvm::fltSemantics & getFloatTypeSemantics(QualType T) const
Return the APFloat 'semantics' for the specified scalar floating point type.
bool hasSimilarType(QualType T1, QualType T2)
Determine if two types are similar, according to the C++ rules.
QualType getMemberPointerType(QualType T, const Type *Cls) const
Return the uniqued reference to the type for a member pointer to the specified type in the specified ...
DeclarationNameTable DeclarationNames
QualType getRecordType(const RecordDecl *Decl) const
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...
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
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 getUnqualifiedArrayType(QualType T, Qualifiers &Quals)
Return this type as a completely-unqualified array type, capturing the qualifiers in Quals.
QualType getObjCObjectPointerType(QualType OIT) const
Return a ObjCObjectPointerType type for the given ObjCObjectType.
QualType getObjCIdType() const
Represents the Objective-CC id type.
bool hasSameUnqualifiedType(QualType T1, QualType T2) const
Determine whether the given types are equivalent after cvr-qualifiers have been removed.
const ArrayType * getAsArrayType(QualType T) const
Type Query functions.
bool isSameTemplateParameterList(const TemplateParameterList *X, const TemplateParameterList *Y) const
Determine whether two template parameter lists are similar enough that they may be used in declaratio...
uint64_t getTypeSize(QualType T) const
Return the size of the specified (complete) type T, in bits.
CanQualType UnsignedInt128Ty
CanQualType UnsignedCharTy
CanQualType UnsignedIntTy
QualType getVolatileType(QualType T) const
Return the uniqued reference to the type for a volatile qualified type.
CanQualType UnsignedLongLongTy
QualType getArrayDecayedType(QualType T) const
Return the properly qualified result of decaying the specified array type to a pointer.
CanQualType UnsignedShortTy
QualType getFunctionType(QualType ResultTy, ArrayRef< QualType > Args, const FunctionProtoType::ExtProtoInfo &EPI) const
Return a normal function type with a typed argument list.
bool UnwrapSimilarTypes(QualType &T1, QualType &T2, bool AllowPiMismatch=true)
Attempt to unwrap two types that may be similar (C++ [conv.qual]).
bool areCompatibleSveTypes(QualType FirstType, QualType SecondType)
Return true if the given types are an SVE builtin and a VectorType that is a fixed-length representat...
QualType getCVRQualifiedType(QualType T, unsigned CVR) const
Return a type with additional const, volatile, or restrict qualifiers.
bool areCompatibleVectorTypes(QualType FirstVec, QualType SecondVec)
Return true if the given vector types are of the same unqualified type or if they are equivalent to t...
const TargetInfo & getTargetInfo() const
bool typesAreCompatible(QualType T1, QualType T2, bool CompareUnqualified=false)
Compatibility predicates used to check assignment expressions.
QualType getAddrSpaceQualType(QualType T, LangAS AddressSpace) const
Return the uniqued reference to the type for an address space qualified type with the specified type ...
bool isPromotableIntegerType(QualType T) const
More type predicates useful for type checking/promotion.
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...
unsigned getNumExplicitParams() const
QualType getFunctionObjectParameterReferenceType() const
Return the type of the object pointed by this.
RefQualifierKind getRefQualifier() const
Retrieve the ref-qualifier associated with this method.
const CXXRecordDecl * getParent() const
Return the parent of this method declaration, which is the class in which this method is defined.
QualType getThisType() const
Return the type of the this pointer.
bool isMoveAssignmentOperator() const
Determine whether this is a move assignment operator.
Qualifiers getMethodQualifiers() const
QualType getFunctionObjectParameterType() const
static CXXOperatorCallExpr * Create(const ASTContext &Ctx, OverloadedOperatorKind OpKind, Expr *Fn, ArrayRef< Expr * > Args, QualType Ty, ExprValueKind VK, SourceLocation OperatorLoc, FPOptionsOverride FPFeatures, ADLCallKind UsesADL=NotADL)
Represents a C++ struct/union/class.
bool isLambda() const
Determine whether this class describes a lambda function object.
llvm::iterator_range< conversion_iterator > getVisibleConversionFunctions() const
Get all conversion functions visible in current class, including conversion function templates.
bool hasDefinition() const
CXXMethodDecl * getLambdaCallOperator() const
Retrieve the lambda call operator of the closure type if this is a closure type.
A rewritten comparison expression that was originally written using operator syntax.
Represents a C++ nested-name-specifier or a global scope specifier.
bool isEmpty() const
No scope specifier.
void Adopt(NestedNameSpecifierLoc Other)
Adopt an existing nested-name-specifier (with source-range information).
CallExpr - Represents a function call (C99 6.5.2.2, C++ [expr.call]).
static CallExpr * Create(const ASTContext &Ctx, Expr *Fn, ArrayRef< Expr * > Args, QualType Ty, ExprValueKind VK, SourceLocation RParenLoc, FPOptionsOverride FPFeatures, unsigned MinNumArgs=0, ADLCallKind UsesADL=NotADL)
Create a call expression.
FunctionDecl * getDirectCallee()
If the callee is a FunctionDecl, return it. Otherwise return null.
void markDependentForPostponedNameLookup()
Used by Sema to implement MSVC-compatible delayed name lookup.
static CallExpr * CreateTemporary(void *Mem, Expr *Fn, QualType Ty, ExprValueKind VK, SourceLocation RParenLoc, ADLCallKind UsesADL=NotADL)
Create a temporary call expression with no arguments in the memory pointed to by Mem.
static CanQual< Type > CreateUnsafe(QualType Other)
Builds a canonical type from a QualType.
CanProxy< U > castAs() const
CanQual< T > getUnqualifiedType() const
Retrieve the unqualified form of this type.
Qualifiers getQualifiers() const
Retrieve all qualifiers.
CanProxy< U > getAs() const
Retrieve a canonical type pointer with a different static type, upcasting or downcasting as needed.
bool isAtLeastAsQualifiedAs(CanQual< T > Other) const
Determines whether this canonical type is at least as qualified as the Other canonical type.
bool isVolatileQualified() const
const ComparisonCategoryInfo * lookupInfoForType(QualType Ty) const
bool isPartial() const
True iff the comparison is not totally ordered.
bool isStrong() const
True iff the comparison is "strong".
Complex values, per C99 6.2.5p11.
QualType getElementType() const
static CompoundAssignOperator * Create(const ASTContext &C, Expr *lhs, Expr *rhs, Opcode opc, QualType ResTy, ExprValueKind VK, ExprObjectKind OK, SourceLocation opLoc, FPOptionsOverride FPFeatures, QualType CompLHSType=QualType(), QualType CompResultType=QualType())
Represents the canonical version of C arrays with a specified constant size.
static ConstantExpr * Create(const ASTContext &Context, Expr *E, const APValue &Result)
The result of a constraint satisfaction check, containing the necessary information to diagnose an un...
Base class for callback objects used by Sema::CorrectTypo to check the validity of a potential typo c...
A POD class for pairing a NamedDecl* with an access specifier.
static DeclAccessPair make(NamedDecl *D, AccessSpecifier AS)
NamedDecl * getDecl() const
DeclContext - This is used only as base class of specific decl types that can act as declaration cont...
DeclContext * getParent()
getParent - Returns the containing DeclContext.
bool Equals(const DeclContext *DC) const
Determine whether this declaration context is equivalent to the declaration context DC.
lookup_result lookup(DeclarationName Name) const
lookup - Find the declarations (if any) with the given Name in this context.
DeclContext * getEnclosingNamespaceContext()
Retrieve the nearest enclosing namespace context.
Decl::Kind getDeclKind() const
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.
bool isTemplateDecl() const
returns true if this declaration is a template
FriendObjectKind getFriendObjectKind() const
Determines whether this declaration is the object of a friend declaration and, if so,...
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
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.
OverloadedOperatorKind getCXXOverloadedOperator() const
If this name is the name of an overloadable operator in C++ (e.g., operator+), retrieve the kind of o...
NameKind getNameKind() const
Determine what kind of name this is.
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, modifiably 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.
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
bool isCPUSpecificMultiVersion() const
True if this function is a multiversioned processor specific function as a part of the cpu_specific/c...
FunctionDecl * getTemplateInstantiationPattern(bool ForDefinition=true) const
Retrieve the function declaration from which this function could be instantiated, if it is an instant...
unsigned getMinRequiredExplicitArguments() const
Returns the minimum number of non-object arguments needed to call this function.
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 isDeletedAsWritten() const
bool isMain() const
Determines whether this function is "main", which is the entry point into an executable program.
bool isCPUDispatchMultiVersion() const
True if this function is a multiversioned dispatch function as a part of the cpu_specific/cpu_dispatc...
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.
QualType getDeclaredReturnType() const
Get the declared return type, which may differ from the actual return type if the return type is dedu...
void getAssociatedConstraints(SmallVectorImpl< const Expr * > &AC) const
Get the associated-constraints of this function declaration.
FunctionDecl * getInstantiatedFromMemberFunction() const
If this function is an instantiation of a member function of a class template specialization,...
unsigned getNumParams() const
Return the number of parameters this function must have based on its FunctionType.
SourceRange getParametersSourceRange() const
Attempt to compute an informative source range covering the function parameters, including the ellips...
bool willHaveBody() const
True if this function will eventually have a body, once it's fully parsed.
Represents a prototype with parameter type info, e.g.
unsigned getNumParams() const
Qualifiers getMethodQuals() const
QualType getParamType(unsigned i) const
bool isVariadic() const
Whether this function prototype is variadic.
ArrayRef< QualType > param_types() const
Declaration of a template function.
FunctionDecl * getTemplatedDecl() const
Get the underlying function declaration of the template.
A class which abstracts out some details necessary for making a call.
ExtInfo withNoReturn(bool noReturn) const
FunctionType - C99 6.7.5.3 - Function Declarators.
ExtInfo getExtInfo() const
CallingConv getCallConv() const
QualType getReturnType() const
QualType getCallResultType(const ASTContext &Context) const
Determine the type of an expression that calls a function of this type.
static GenericSelectionExpr * Create(const ASTContext &Context, SourceLocation GenericLoc, Expr *ControllingExpr, ArrayRef< TypeSourceInfo * > AssocTypes, ArrayRef< Expr * > AssocExprs, SourceLocation DefaultLoc, SourceLocation RParenLoc, bool ContainsUnexpandedParameterPack, unsigned ResultIndex)
Create a non-result-dependent generic selection expression accepting an expression predicate.
One of these records is kept for each identifier that is lexed.
ImplicitCastExpr - Allows us to explicitly represent implicit type conversions, which have no direct ...
static ImplicitCastExpr * Create(const ASTContext &Context, QualType T, CastKind Kind, Expr *Operand, const CXXCastPath *BasePath, ExprValueKind Cat, FPOptionsOverride FPO)
ImplicitConversionSequence - Represents an implicit conversion sequence, which may be a standard conv...
void dump() const
dump - Print this implicit conversion sequence to standard error.
bool isUserDefined() const
@ StaticObjectArgumentConversion
StandardConversionSequence Standard
When ConversionKind == StandardConversion, provides the details of the standard conversion sequence.
void setBad(BadConversionSequence::FailureKind Failure, Expr *FromExpr, QualType ToType)
Sets this sequence as a bad conversion for an explicit argument.
UserDefinedConversionSequence UserDefined
When ConversionKind == UserDefinedConversion, provides the details of the user-defined conversion seq...
static ImplicitConversionSequence getNullptrToBool(QualType SourceType, QualType DestType, bool NeedLValToRVal)
Form an "implicit" conversion sequence from nullptr_t to bool, for a direct-initialization of a bool ...
AmbiguousConversionSequence Ambiguous
When ConversionKind == AmbiguousConversion, provides the details of the ambiguous conversion.
bool hasInitializerListContainerType() const
unsigned getKindRank() const
Return a ranking of the implicit conversion sequence kind, where smaller ranks represent better conve...
bool isInitializerListOfIncompleteArray() const
BadConversionSequence Bad
When ConversionKind == BadConversion, provides the details of the bad conversion.
QualType getInitializerListContainerType() const
void DiagnoseAmbiguousConversion(Sema &S, SourceLocation CaretLoc, const PartialDiagnostic &PDiag) const
Diagnoses an ambiguous conversion.
Describes an C or C++ initializer list.
bool hasDesignatedInit() const
Determine whether this initializer list contains a designated initializer.
unsigned getNumInits() const
SourceLocation getBeginLoc() const LLVM_READONLY
const Expr * getInit(unsigned Init) const
SourceLocation getEndLoc() const LLVM_READONLY
Describes an entity that is being initialized.
static InitializedEntity InitializeParameter(ASTContext &Context, ParmVarDecl *Parm)
Create the initialization entity for a parameter.
static InitializedEntity InitializeTemplateParameter(QualType T, NonTypeTemplateParmDecl *Param)
Create the initialization entity for a template parameter.
static IntegerLiteral * Create(const ASTContext &C, const llvm::APInt &V, QualType type, SourceLocation l)
Returns a new integer literal with value 'V' and type 'type'.
An lvalue reference type, per C++11 [dcl.ref].
bool isCompatibleWithMSVC(MSVCMajorVersion MajorVersion) const
Represents the results of name lookup.
void addAllDecls(const LookupResult &Other)
Add all the declarations from another set of lookup results.
LLVM_ATTRIBUTE_REINITIALIZES void clear()
Clears out any current state.
DeclClass * getAsSingle() const
void addDecl(NamedDecl *D)
Add a declaration to these results with its natural access.
bool empty() const
Return true if no decls were found.
void resolveKind()
Resolves the result kind of the lookup, possibly hiding decls.
SourceLocation getNameLoc() const
Gets the location of the identifier.
Sema::LookupNameKind getLookupKind() const
Gets the kind of lookup to perform.
void suppressAccessDiagnostics()
Suppress the diagnostics that would normally fire because of this lookup due to access control violat...
const UnresolvedSetImpl & asUnresolvedSet() const
void suppressDiagnostics()
Suppress the diagnostics that would normally fire because of this lookup.
DeclarationName getLookupName() const
Gets the name to look up.
MemberExpr - [C99 6.5.2.3] Structure and Union Members.
SourceLocation getMemberLoc() const
getMemberLoc - Return the location of the "member", in X->F, it is the location of 'F'.
ValueDecl * getMemberDecl() const
Retrieve the member declaration to which this expression refers.
bool hasQualifier() const
Determines whether this member expression actually had a C++ nested-name-specifier prior to the name ...
bool performsVirtualDispatch(const LangOptions &LO) const
Returns true if virtual dispatch is performed.
NestedNameSpecifier * getQualifier() const
If the member name was qualified, retrieves the nested-name-specifier that precedes the member name.
SourceLocation getBeginLoc() const LLVM_READONLY
SourceLocation getExprLoc() const LLVM_READONLY
DeclAccessPair getFoundDecl() const
Retrieves the declaration found by lookup.
A pointer to member type per C++ 8.3.3 - Pointers to members.
QualType getPointeeType() const
const Type * getClass() const
Describes a module or submodule.
std::string getFullModuleName(bool AllowStringLiterals=false) const
Retrieve the full name of this module, including the path from its top-level module.
This represents a decl that may have a name.
NamedDecl * getUnderlyingDecl()
Looks through UsingDecls and ObjCCompatibleAliasDecls for the underlying named decl.
StringRef getName() const
Get the name of identifier for this declaration as a StringRef.
DeclarationName getDeclName() const
Get the actual, stored name of the declaration, which may be a special name.
std::string getQualifiedNameAsString() const
Linkage getFormalLinkage() const
Get the linkage from a semantic point of view.
Represent a C++ namespace.
A C++ nested-name-specifier augmented with source location information.
SourceRange getSourceRange() const LLVM_READONLY
Retrieve the source range covering the entirety of this nested-name-specifier.
Represents a C++ nested name specifier, such as "\::std::vector<int>::".
NonTypeTemplateParmDecl - Declares a non-type template parameter, e.g., "Size" in.
Represents an ObjC class declaration.
Interfaces are the core concept in Objective-C for object oriented design.
ObjCMethodDecl - Represents an instance or class method declaration.
ArrayRef< ParmVarDecl * > parameters() const
unsigned param_size() const
Represents a pointer to an Objective C object.
bool isSpecialized() const
Whether this type is specialized, meaning that it has type arguments.
bool isObjCIdType() const
True if this is equivalent to the 'id' type, i.e.
QualType getPointeeType() const
Gets the type pointed to by this ObjC pointer.
ObjCInterfaceDecl * getInterfaceDecl() const
If this pointer points to an Objective @interface type, gets the declaration for that interface.
const ObjCInterfaceType * getInterfaceType() const
If this pointer points to an Objective C @interface type, gets the type for that interface.
bool isObjCClassType() const
True if this is equivalent to the 'Class' type, i.e.
OpaqueValueExpr - An expression referring to an opaque object of a fixed type and value class.
OverloadCandidateSet - A set of overload candidates, used in C++ overload resolution (C++ 13....
void clear(CandidateSetKind CSK)
Clear out all of the candidates.
bool isNewCandidate(Decl *F, OverloadCandidateParamOrder PO=OverloadCandidateParamOrder::Normal)
Determine when this overload candidate will be new to the overload set.
ConversionSequenceList allocateConversionSequences(unsigned NumConversions)
Allocate storage for conversion sequences for NumConversions conversions.
OverloadCandidate & addCandidate(unsigned NumConversions=0, ConversionSequenceList Conversions=std::nullopt)
Add a new candidate with NumConversions conversion sequence slots to the overload set.
OperatorRewriteInfo getRewriteInfo() const
@ CSK_InitByConstructor
C++ [over.match.ctor], [over.match.list] Initialization of an object of class type by constructor,...
@ CSK_InitByUserDefinedConversion
C++ [over.match.copy]: Copy-initialization of an object of class type by user-defined conversion.
@ CSK_Normal
Normal lookup.
@ CSK_Operator
C++ [over.match.oper]: Lookup of operator function candidates in a call using operator syntax.
SmallVectorImpl< OverloadCandidate >::iterator iterator
void NoteCandidates(PartialDiagnosticAt PA, Sema &S, OverloadCandidateDisplayKind OCD, ArrayRef< Expr * > Args, StringRef Opc="", SourceLocation Loc=SourceLocation(), llvm::function_ref< bool(OverloadCandidate &)> Filter=[](OverloadCandidate &) { return true;})
When overload resolution fails, prints diagnostic messages containing the candidates in the candidate...
bool shouldDeferDiags(Sema &S, ArrayRef< Expr * > Args, SourceLocation OpLoc)
Whether diagnostics should be deferred.
OverloadingResult BestViableFunction(Sema &S, SourceLocation Loc, OverloadCandidateSet::iterator &Best)
Find the best viable function on this overload set, if it exists.
void exclude(Decl *F)
Exclude a function from being considered by overload resolution.
SourceLocation getLocation() const
CandidateSetKind getKind() const
SmallVector< OverloadCandidate *, 32 > CompleteCandidates(Sema &S, OverloadCandidateDisplayKind OCD, ArrayRef< Expr * > Args, SourceLocation OpLoc=SourceLocation(), llvm::function_ref< bool(OverloadCandidate &)> Filter=[](OverloadCandidate &) { return true;})
A reference to an overloaded function set, either an UnresolvedLookupExpr or an UnresolvedMemberExpr.
NestedNameSpecifier * getQualifier() const
Fetches the nested-name qualifier, if one was given.
bool hasExplicitTemplateArgs() const
Determines whether this expression had explicit template arguments.
static FindResult find(Expr *E)
Finds the overloaded expression in the given expression E of OverloadTy.
SourceLocation getNameLoc() const
Gets the location of the name.
decls_iterator decls_begin() const
unsigned getNumDecls() const
Gets the number of declarations in the unresolved set.
SourceLocation getTemplateKeywordLoc() const
Retrieve the location of the template keyword preceding this name, if any.
NestedNameSpecifierLoc getQualifierLoc() const
Fetches the nested-name qualifier with source-location information, if one was given.
void copyTemplateArgumentsInto(TemplateArgumentListInfo &List) const
Copies the template arguments into the given structure.
decls_iterator decls_end() const
DeclarationName getName() const
Gets the name looked up.
A single parameter index whose accessors require each use to make explicit the parameter index encodi...
ParenExpr - This represents a parethesized expression, e.g.
Represents a parameter to a function.
SourceRange getSourceRange() const override LLVM_READONLY
Source range that this declaration covers.
PointerType - C99 6.7.5.1 - Pointer Declarators.
QualType getPointeeType() const
static PseudoObjectExpr * Create(const ASTContext &Context, Expr *syntactic, ArrayRef< Expr * > semantic, unsigned resultIndex)
A (possibly-)qualified type.
bool isVolatileQualified() const
Determine whether this type is volatile-qualified.
bool isRestrictQualified() const
Determine whether this type is restrict-qualified.
bool hasQualifiers() const
Determine whether this type has any qualifiers.
QualType getNonLValueExprType(const ASTContext &Context) const
Determine the type of a (typically non-lvalue) expression with the specified result type.
QualType getLocalUnqualifiedType() const
Return this type with all of the instance-specific qualifiers removed, but without removing any quali...
bool isAtLeastAsQualifiedAs(QualType Other) const
Determine whether this type is at least as qualified as the other given type, requiring exact equalit...
bool isNull() const
Return true if this QualType doesn't point to a type yet.
const Type * getTypePtr() const
Retrieves a pointer to the underlying (unqualified) type.
LangAS getAddressSpace() const
Return the address space of this type.
Qualifiers getQualifiers() const
Retrieve the set of qualifiers applied to this type.
void getAsStringInternal(std::string &Str, const PrintingPolicy &Policy) const
QualType getNonReferenceType() const
If Type is a reference type (e.g., const int&), returns the type that the reference refers to ("const...
QualType getCanonicalType() const
QualType getUnqualifiedType() const
Retrieve the unqualified variant of the given type, removing as little sugar as possible.
unsigned getLocalCVRQualifiers() const
Retrieve the set of CVR (const-volatile-restrict) qualifiers local to this particular QualType instan...
bool isMoreQualifiedThan(QualType Other) const
Determine whether this type is more qualified than the other given type, requiring exact equality for...
bool isConstQualified() const
Determine whether this type is const-qualified.
bool hasAddressSpace() const
Check if this type has any address space qualifier.
unsigned getCVRQualifiers() const
Retrieve the set of CVR (const-volatile-restrict) qualifiers applied to this type.
static std::string getAsString(SplitQualType split, const PrintingPolicy &Policy)
Qualifiers getLocalQualifiers() const
Retrieve the set of qualifiers local to this particular QualType instance, not including any qualifie...
A qualifier set is used to build a set of qualifiers.
const Type * strip(QualType type)
Collect any qualifiers on the given type and return an unqualified type.
QualType apply(const ASTContext &Context, QualType QT) const
Apply the collected qualifiers to the given type.
QualifiersAndAtomic withVolatile()
QualifiersAndAtomic withAtomic()
The collection of all-type qualifiers we support.
unsigned getCVRQualifiers() const
bool hasOnlyConst() const
@ OCL_Strong
Assigning into this object requires the old value to be released and the new value to be retained.
@ OCL_ExplicitNone
This object can be modified without requiring retains or releases.
@ OCL_Weak
Reading or writing from this object requires a barrier call.
@ OCL_Autoreleasing
Assigning into this object requires a lifetime extension.
void removeObjCLifetime()
bool hasUnaligned() const
void removeAddressSpace()
void setAddressSpace(LangAS space)
static bool isAddressSpaceSupersetOf(LangAS A, LangAS B)
Returns true if address space A is equal to or a superset of B.
bool hasObjCGCAttr() const
ObjCLifetime getObjCLifetime() const
Qualifiers withoutObjCLifetime() const
std::string getAsString() const
bool compatiblyIncludes(Qualifiers other) const
Determines if these qualifiers compatibly include another set.
LangAS getAddressSpace() const
bool compatiblyIncludesObjCLifetime(Qualifiers other) const
Determines if these qualifiers compatibly include another set of qualifiers from the narrow perspecti...
void setObjCLifetime(ObjCLifetime type)
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
decl_type * getFirstDecl()
Return the first declaration of this declaration or itself if this is the only declaration.
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
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
CXXSpecialMember asSpecialMember() const
bool isComparison() 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.
CUDAFunctionTarget IdentifyCUDATarget(const FunctionDecl *D, bool IgnoreImplicitHDAttr=false)
Determines whether the given function is a CUDA device/host/kernel/etc.
bool DiagnoseEmptyLookup(Scope *S, CXXScopeSpec &SS, LookupResult &R, CorrectionCandidateCallback &CCC, TemplateArgumentListInfo *ExplicitTemplateArgs=nullptr, ArrayRef< Expr * > Args=std::nullopt, DeclContext *LookupCtx=nullptr, TypoExpr **Out=nullptr)
Diagnose an empty lookup.
bool IsBuildingRecoveryCallExpr
Flag indicating if Sema is building a recovery call expression.
bool IsOverload(FunctionDecl *New, FunctionDecl *Old, bool UseMemberUsingDeclRules, bool ConsiderCudaAttrs=true)
@ LookupOrdinaryName
Ordinary name lookup, which finds ordinary names (functions, variables, typedefs, etc....
@ LookupOperatorName
Look up of an operator name (e.g., operator+) for use with operator overloading.
@ LookupMemberName
Member name lookup, which finds the names of class/struct/union members.
ImplicitConversionSequence TryImplicitConversion(Expr *From, QualType ToType, bool SuppressUserConversions, AllowedExplicit AllowExplicit, bool InOverloadResolution, bool CStyle, bool AllowObjCWritebackConversion)
ExprResult BuildLiteralOperatorCall(LookupResult &R, DeclarationNameInfo &SuffixInfo, ArrayRef< Expr * > Args, SourceLocation LitEndLoc, TemplateArgumentListInfo *ExplicitTemplateArgs=nullptr)
BuildLiteralOperatorCall - Build a UserDefinedLiteral by creating a call to a literal operator descri...
SemaDiagnosticBuilder Diag(SourceLocation Loc, unsigned DiagID, bool DeferHint=false)
Emit a diagnostic.
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...
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 EraseUnwantedCUDAMatches(const FunctionDecl *Caller, SmallVectorImpl< std::pair< DeclAccessPair, FunctionDecl * > > &Matches)
Finds a function in Matches with highest calling priority from Caller context and erases all function...
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.
ExprResult PerformImplicitConversion(Expr *From, QualType ToType, const ImplicitConversionSequence &ICS, AssignmentAction Action, CheckedConversionKind CCK=CCK_ImplicitConversion)
PerformImplicitConversion - Perform an implicit conversion of the expression From to the type ToType ...
bool DeduceReturnType(FunctionDecl *FD, SourceLocation Loc, bool Diagnose=true)
bool IsAllowedCUDACall(const FunctionDecl *Caller, const FunctionDecl *Callee)
Determines whether Caller may invoke Callee, based on their CUDA host/device attributes.
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.
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...
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 (...
ExprResult ImpCastExprToType(Expr *E, QualType Type, CastKind CK, ExprValueKind VK=VK_PRValue, const CXXCastPath *BasePath=nullptr, CheckedConversionKind CCK=CCK_ImplicitConversion)
ImpCastExprToType - If Expr is not of type 'Type', insert an implicit cast.
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)
Expr * stripARCUnbridgedCast(Expr *e)
stripARCUnbridgedCast - Given an expression of ARCUnbridgedCast type, remove the placeholder cast.
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...
CUDAFunctionPreference IdentifyCUDAPreference(const FunctionDecl *Caller, const FunctionDecl *Callee)
Identifies relative preference of a given Caller/Callee combination, based on their host/device attri...
AssignConvertType CheckSingleAssignmentConstraints(QualType LHSType, ExprResult &RHS, bool Diagnose=true, bool DiagnoseCFAudited=false, bool ConvertRHS=true)
Check assignment constraints for an assignment of RHS to LHSType.
ExprResult CreateOverloadedUnaryOp(SourceLocation OpLoc, UnaryOperatorKind Opc, const UnresolvedSetImpl &Fns, Expr *input, bool RequiresADL=true)
Create a unary operation that may resolve to an overloaded operator.
std::optional< sema::TemplateDeductionInfo * > isSFINAEContext() const
Determines whether we are currently in a context where template argument substitution failures are no...
void AddOverloadedCallCandidates(UnresolvedLookupExpr *ULE, ArrayRef< Expr * > Args, OverloadCandidateSet &CandidateSet, bool PartialOverloading=false)
Add the overload candidates named by callee and/or found by argument dependent lookup to the given ov...
bool MaybeEmitAmbiguousAtomicConstraintsDiagnostic(NamedDecl *D1, ArrayRef< const Expr * > AC1, NamedDecl *D2, ArrayRef< const Expr * > AC2)
If D1 was not at least as constrained as D2, but would've been if a pair of atomic constraints involv...
ExprResult DefaultLvalueConversion(Expr *E)
ExprResult BuildDeclarationNameExpr(const CXXScopeSpec &SS, LookupResult &R, bool NeedsADL, bool AcceptInvalidDecl=false)
bool isVisible(const NamedDecl *D)
Determine whether a declaration is visible to name lookup.
void NoteOverloadCandidate(const NamedDecl *Found, const FunctionDecl *Fn, OverloadCandidateRewriteKind RewriteKind=OverloadCandidateRewriteKind(), QualType DestType=QualType(), bool TakingAddress=false)
bool DiagnoseMultipleUserDefinedConversion(Expr *From, QualType ToType)
FunctionDecl * resolveAddressOfSingleOverloadCandidate(Expr *E, DeclAccessPair &FoundResult)
Given an expression that refers to an overloaded function, try to resolve that function to a single f...
DeclContext * CurContext
CurContext - This is the current declaration context of parsing.
MaterializeTemporaryExpr * CreateMaterializeTemporaryExpr(QualType T, Expr *Temporary, bool BoundToLvalueReference)
ExprResult PerformContextuallyConvertToBool(Expr *From)
PerformContextuallyConvertToBool - Perform a contextual conversion of the expression From to bool (C+...
bool CheckFunctionConstraints(const FunctionDecl *FD, ConstraintSatisfaction &Satisfaction, SourceLocation UsageLoc=SourceLocation(), bool ForOverloadResolution=false)
Check whether the given function decl's trailing requires clause is satisfied, if any.
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...
bool resolveAndFixAddressOfSingleOverloadCandidate(ExprResult &SrcExpr, bool DoFunctionPointerConversion=false)
Given an overloaded function, tries to turn it into a non-overloaded function reference using resolve...
ExprResult BuildCXXDefaultArgExpr(SourceLocation CallLoc, FunctionDecl *FD, ParmVarDecl *Param, Expr *Init=nullptr)
BuildCXXDefaultArgExpr - Creates a CXXDefaultArgExpr, instantiating the default expr if needed.
void AddOverloadCandidate(FunctionDecl *Function, DeclAccessPair FoundDecl, ArrayRef< Expr * > Args, OverloadCandidateSet &CandidateSet, bool SuppressUserConversions=false, bool PartialOverloading=false, bool AllowExplicit=true, bool AllowExplicitConversion=false, ADLCallKind IsADLCandidate=ADLCallKind::NotADL, ConversionSequenceList EarlyConversions=std::nullopt, OverloadCandidateParamOrder PO={}, bool AggregateCandidateDeduction=false)
AddOverloadCandidate - Adds the given function to the set of candidate functions, using the given fun...
bool anyAltivecTypes(QualType srcType, QualType destType)
bool isLaxVectorConversion(QualType srcType, QualType destType)
Is this a legal conversion between two types, one of which is known to be a vector type?
bool IsAtLeastAsConstrained(NamedDecl *D1, MutableArrayRef< const Expr * > AC1, NamedDecl *D2, MutableArrayRef< const Expr * > AC2, bool &Result)
Check whether the given declaration's associated constraints are at least as constrained than another...
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...
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 inferCUDATargetForImplicitSpecialMember(CXXRecordDecl *ClassDecl, CXXSpecialMember 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 ...
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...
PartialDiagnostic PDiag(unsigned DiagID=0)
Build a partial diagnostic.
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 isObjCWritebackConversion(QualType FromType, QualType ToType, QualType &ConvertedType)
Determine whether this is an Objective-C writeback conversion, used for parameter passing when perfor...
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)
Perform template argument deduction to determine whether the given template arguments match the given...
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...
static bool isCUDAImplicitHostDeviceFunction(const FunctionDecl *D)
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)
CXXSpecialMember
Kinds of C++ special members.
bool CanPerformCopyInitialization(const InitializedEntity &Entity, ExprResult Init)
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.
ExprResult BuildPossibleImplicitMemberExpr(const CXXScopeSpec &SS, SourceLocation TemplateKWLoc, LookupResult &R, const TemplateArgumentListInfo *TemplateArgs, const Scope *S, UnresolvedLookupExpr *AsULE=nullptr)
Builds an expression which might be an implicit member expression.
DeclContextLookupResult LookupConstructors(CXXRecordDecl *Class)
Look up the constructors for the given class.
bool IsFunctionConversion(QualType FromType, QualType ToType, QualType &ResultTy)
Determine whether the conversion from FromType to ToType is a valid conversion that strips "noexcept"...
void AddMemberOperatorCandidates(OverloadedOperatorKind Op, SourceLocation OpLoc, ArrayRef< Expr * > Args, OverloadCandidateSet &CandidateSet, OverloadCandidateParamOrder PO={})
Add overload candidates for overloaded operators that are member functions.
ExprResult ActOnFinishFullExpr(Expr *Expr, bool DiscardedValue)
Encodes a location in the source.
bool isValid() const
Return true if this is a valid SourceLocation object.
bool isInSystemHeader(SourceLocation Loc) const
Returns if a SourceLocation is in a system header.
bool isBeforeInTranslationUnit(SourceLocation LHS, SourceLocation RHS) const
Determines the order of 2 source locations in the translation unit.
A trivial tuple used to represent a source range.
SourceLocation getBegin() const
StandardConversionSequence - represents a standard conversion sequence (C++ 13.3.3....
void dump() const
dump - Print this standard conversion sequence to standard error.
void setFromType(QualType T)
DeclAccessPair FoundCopyConstructor
bool isIdentityConversion() const
unsigned BindsToRvalue
Whether we're binding to an rvalue.
ImplicitConversionKind Second
Second - The second conversion can be an integral promotion, floating point promotion,...
QualType getFromType() const
ImplicitConversionKind First
First – The first conversion can be an lvalue-to-rvalue conversion, array-to-pointer conversion,...
unsigned BindsImplicitObjectArgumentWithoutRefQualifier
Whether this binds an implicit object argument to a non-static member function without a ref-qualifie...
unsigned ReferenceBinding
ReferenceBinding - True when this is a reference binding (C++ [over.ics.ref]).
void setAsIdentityConversion()
StandardConversionSequence - Set the standard conversion sequence to the identity conversion.
unsigned DeprecatedStringLiteralToCharPtr
Whether this is the deprecated conversion of a string literal to a pointer to non-const character dat...
CXXConstructorDecl * CopyConstructor
CopyConstructor - The copy constructor that is used to perform this conversion, when the conversion i...
unsigned IncompatibleObjC
IncompatibleObjC - Whether this is an Objective-C conversion that we should warn about (if we actuall...
unsigned ObjCLifetimeConversionBinding
Whether this binds a reference to an object with a different Objective-C lifetime qualifier.
ImplicitConversionKind Third
Third - The third conversion can be a qualification conversion or a function conversion.
unsigned QualificationIncludesObjCLifetime
Whether the qualification conversion involves a change in the Objective-C lifetime (for automatic ref...
ImplicitConversionKind Element
Element - Between the second and third conversion a vector or matrix element conversion may occur.
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).
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
bool isMicrosoft() const
Is this ABI an MSVC-compatible ABI?
const llvm::Triple & getTriple() const
Returns the target triple of the primary target.
virtual bool hasInt128Type() const
Determine whether the __int128 type is supported on this target.
virtual bool hasIbm128Type() const
Determine whether the __ibm128 type is supported on this target.
virtual bool hasFloat128Type() const
Determine whether the __float128 type is supported on this target.
TargetCXXABI getCXXABI() const
Get the C++ ABI currently in use.
A convenient class for passing around template argument information.
A template argument list.
Represents a template argument.
QualType getNonTypeTemplateArgumentType() const
If this is a non-type template argument, get its type.
QualType getAsType() const
Retrieve the type for a type template argument.
TemplateName getAsTemplate() const
Retrieve the template name for a template name argument.
unsigned pack_size() const
The number of template arguments in the given template argument pack.
@ Template
The template argument is a template name that was provided for a template template parameter.
@ Pack
The template argument is actually a parameter pack.
ArgKind getKind() const
Return the kind of stored template argument.
The base class of all kinds of template declarations (e.g., class, function, etc.).
TemplateParameterList * getTemplateParameters() const
Get the list of template parameters.
Represents a C++ template name within the type system.
TemplateDecl * getAsTemplateDecl() const
Retrieve the underlying template declaration that this template name refers to, if known.
@ Template
A single template declaration.
bool hasAssociatedConstraints() const
TemplateSpecCandidateSet - A set of generalized overload candidates, used in template specializations...
SmallVector< TemplateSpecCandidate, 16 >::iterator iterator
void NoteCandidates(Sema &S, SourceLocation Loc)
NoteCandidates - When no template specialization match is found, prints diagnostic messages containin...
void clear()
Clear out all of the candidates.
SourceLocation getLocation() const
TemplateSpecCandidate & addCandidate()
Add a new candidate with NumConversions conversion sequence slots to the overload set.
Represents a type template specialization; the template must be a class template, a type alias templa...
TemplateTemplateParmDecl - Declares a template template parameter, e.g., "T" in.
Declaration of a template type parameter.
const Type * getTypeForDecl() const
The base class of the type hierarchy.
bool isIncompleteOrObjectType() const
Return true if this is an incomplete or object type, in other words, not a function type.
bool isBlockPointerType() const
bool isBooleanType() const
bool isObjCBuiltinType() const
bool isSignedIntegerOrEnumerationType() const
Determines whether this is an integer type that is signed or an enumeration types whose underlying ty...
bool hasAttr(attr::Kind AK) const
Determine whether this type had the specified attribute applied to it (looking through top-level type...
const RecordType * getAsUnionType() const
NOTE: getAs*ArrayType are methods on ASTContext.
bool isIncompleteArrayType() const
bool isSignedIntegerType() const
Return true if this is an integer type that is signed, according to C99 6.2.5p4 [char,...
bool isFloat16Type() const
bool isComplexType() const
isComplexType() does not include complex integers (a GCC extension).
bool isIntegralOrUnscopedEnumerationType() const
Determine whether this type is an integral or unscoped enumeration type.
bool isRValueReferenceType() const
bool isConstantArrayType() const
bool isConvertibleToFixedPointType() const
Return true if this can be converted to (or from) a fixed point type.
bool isArithmeticType() const
bool isPointerType() 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 isExtVectorType() const
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 isObjCLifetimeType() const
Returns true if objects of this type have lifetime semantics under ARC.
bool isUndeducedType() const
Determine whether this type is an undeduced type, meaning that it somehow involves a C++11 'auto' typ...
bool isObjectType() const
Determine whether this type is an object type.
bool isBFloat16Type() const
bool isIncompleteType(NamedDecl **Def=nullptr) const
Types are partitioned into 3 broad categories (C99 6.2.5p1): object types, function types,...
bool isFunctionType() const
bool isObjCObjectPointerType() const
bool isVectorType() const
bool isObjCClassType() const
bool isRealFloatingType() const
Floating point categories.
bool isRVVSizelessBuiltinType() const
Returns true for RVV scalable vector types.
bool isUnsignedIntegerType() const
Return true if this is an integer type that is unsigned, according to C99 6.2.5p6 [which returns true...
bool isAnyPointerType() const
TypeClass getTypeClass() const
const T * getAs() const
Member-template getAs<specific type>'.
bool isNullPtrType() const
bool isRecordType() const
UnaryOperator - This represents the unary-expression's (except sizeof and alignof),...
static OverloadedOperatorKind getOverloadedOperator(Opcode Opc)
Retrieve the overloaded operator kind that corresponds to the given unary opcode.
static UnaryOperator * Create(const ASTContext &C, Expr *input, Opcode opc, QualType type, ExprValueKind VK, ExprObjectKind OK, SourceLocation l, bool CanOverflow, FPOptionsOverride FPFeatures)
static StringRef getOpcodeStr(Opcode Op)
getOpcodeStr - Turn an Opcode enum value into the punctuation char it corresponds to,...
A reference to a name which we were able to look up during parsing but could not resolve to a specifi...
SourceLocation getBeginLoc() const LLVM_READONLY
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, bool Overloaded, UnresolvedSetIterator Begin, UnresolvedSetIterator End)
Represents a C++ member access expression for which lookup produced a set of overloaded functions.
DeclarationName getMemberName() const
Retrieve the name of the member that this expression refers to.
QualType getBaseType() const
bool isArrow() const
Determine whether this member expression used the '->' operator; otherwise, it used the '.
Expr * getBase()
Retrieve the base object of this member expressions, e.g., the x in x.m.
SourceLocation getBeginLoc() const LLVM_READONLY
SourceLocation getMemberLoc() const
Retrieve the location of the name of the member that this expression refers to.
A set of unresolved declarations.
void addDecl(NamedDecl *D)
The iterator over UnresolvedSets.
A set of unresolved declarations.
A call to a literal operator (C++11 [over.literal]) written as a user-defined literal (C++11 [lit....
static UserDefinedLiteral * Create(const ASTContext &Ctx, Expr *Fn, ArrayRef< Expr * > Args, QualType Ty, ExprValueKind VK, SourceLocation LitEndLoc, SourceLocation SuffixLoc, FPOptionsOverride FPFeatures)
Represents a GCC generic vector type.
Provides information about an attempted template argument deduction, whose success or failure was des...
TemplateArgumentList * takeSugared()
Take ownership of the deduced template argument lists.
TemplateArgument SecondArg
The second template argument to which the template argument deduction failure refers.
TemplateParameter Param
The template parameter to which a template argument deduction failure refers.
bool hasSFINAEDiagnostic() const
Is a SFINAE diagnostic available?
bool AggregateDeductionCandidateHasMismatchedArity
TemplateArgument FirstArg
The first template argument to which the template argument deduction failure refers.
ConstraintSatisfaction AssociatedConstraintsSatisfaction
The constraint satisfaction details resulting from the associated constraints satisfaction tests.
void takeSFINAEDiagnostic(PartialDiagnosticAt &PD)
Take ownership of the SFINAE diagnostic.
unsigned CallArgIndex
The index of the function argument that caused a deduction failure.
specific_attr_iterator - Iterates over a subrange of an AttrVec, only providing attributes that are o...
Defines the clang::TargetInfo interface.
const internal::VariadicAllOfMatcher< Type > type
Matches Types in the clang AST.
bool Ret(InterpState &S, CodePtr &PC, APValue &Result)
The JSON file list parser is used to communicate input to InstallAPI.
@ Seq
'seq' clause, allowed on 'loop' and 'routine' directives.
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_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_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.
OverloadCandidateDisplayKind
@ OCD_AmbiguousCandidates
Requests that only tied-for-best candidates be shown.
@ OCD_ViableCandidates
Requests that only viable candidates be shown.
@ OCD_AllCandidates
Requests that all candidates be shown.
@ OK_ObjCProperty
An Objective-C property is a logical field of an Objective-C object which is read and written via Obj...
@ OK_Ordinary
An ordinary object is located at an address in memory.
OverloadCandidateParamOrder
The parameter ordering that will be used for the candidate.
OverloadsShown
Specifies which overload candidates to display when overload resolution fails.
@ Ovl_Best
Show just the "best" overload candidates.
ComparisonCategoryResult
An enumeration representing the possible results of a three-way comparison.
OverloadCandidateRewriteKind
The kinds of rewrite we perform on overload candidates.
@ CRK_Reversed
Candidate is a rewritten candidate with a reversed order of parameters.
@ CRK_None
Candidate is not a rewritten candidate.
@ CRK_DifferentOperator
Candidate is a rewritten candidate with a different operator name.
@ Internal
Internal linkage, which indicates that the entity can be referred to from within the translation unit...
@ Result
The result type of a method or function.
ImplicitConversionKind
ImplicitConversionKind - The kind of implicit conversion used to convert an argument to a parameter's...
@ ICK_Complex_Conversion
Complex conversions (C99 6.3.1.6)
@ ICK_Floating_Promotion
Floating point promotions (C++ [conv.fpprom])
@ ICK_Boolean_Conversion
Boolean conversions (C++ [conv.bool])
@ ICK_Integral_Conversion
Integral conversions (C++ [conv.integral])
@ ICK_Fixed_Point_Conversion
Fixed point type conversions according to N1169.
@ ICK_Vector_Conversion
Vector conversions.
@ ICK_Block_Pointer_Conversion
Block Pointer conversions.
@ ICK_Pointer_Member
Pointer-to-member conversions (C++ [conv.mem])
@ ICK_Floating_Integral
Floating-integral conversions (C++ [conv.fpint])
@ ICK_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.
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...
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.
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
__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.
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.
DeductionFailureInfo DeductionFailure
bool Best
Whether this candidate is the best viable function, or tied for being the best viable function.
CXXConversionDecl * Surrogate
Surrogate - The conversion function for which this candidate is a surrogate, but only if IsSurrogate ...
OverloadCandidateRewriteKind getRewriteKind() const
Get RewriteKind value in OverloadCandidateRewriteKind type (This function is to workaround the spurio...
bool HasFormOfMemberPointer
OverloadExpr * Expression
A context in which code is being synthesized (where a source location alone is not sufficient to iden...
enum clang::Sema::CodeSynthesisContext::SynthesisKind Kind
@ RewritingOperatorAsSpaceship
We are rewriting a comparison operator in terms of an operator<=>.
Decl * Entity
The entity that is being synthesized.
ReferenceConversions
The conversions that would be performed on an lvalue of type T2 when binding a reference of type T1 t...
Abstract class used to diagnose incomplete types.
TemplateSpecCandidate - This is a generalization of OverloadCandidate which keeps track of template a...
void NoteDeductionFailure(Sema &S, bool ForTakingAddress)
Diagnose a template argument deduction failure.
DeductionFailureInfo DeductionFailure
Template argument deduction info.
Decl * Specialization
Specialization - The actual specialization that this candidate represents.
void set(DeclAccessPair Found, Decl *Spec, DeductionFailureInfo Info)
UserDefinedConversionSequence - Represents a user-defined conversion sequence (C++ 13....
StandardConversionSequence Before
Represents the standard conversion that occurs before the actual user-defined conversion.
FunctionDecl * ConversionFunction
ConversionFunction - The function that will perform the user-defined conversion.
bool HadMultipleCandidates
HadMultipleCandidates - When this is true, it means that the conversion function was resolved from an...
StandardConversionSequence After
After - Represents the standard conversion that occurs after the actual user-defined conversion.
bool EllipsisConversion
EllipsisConversion - When this is true, it means user-defined conversion sequence starts with a ....
DeclAccessPair FoundConversionFunction
The declaration that we found via name lookup, which might be the same as ConversionFunction or it mi...
void dump() const
dump - Print this user-defined conversion sequence to standard error.