38#include "llvm/ADT/DenseSet.h"
39#include "llvm/ADT/STLExtras.h"
40#include "llvm/ADT/STLForwardCompat.h"
41#include "llvm/ADT/ScopeExit.h"
42#include "llvm/ADT/SmallPtrSet.h"
43#include "llvm/ADT/SmallVector.h"
57 return P->hasAttr<PassObjectSizeAttr>();
78 if (HadMultipleCandidates)
89 CK_FunctionToPointerDecay);
93 bool InOverloadResolution,
96 bool AllowObjCWritebackConversion);
100 bool InOverloadResolution,
108 bool AllowObjCConversionOnExplicit);
169 return Rank[(int)Kind];
194 static const char *
const Name[] = {
198 "Function-to-pointer",
199 "Function pointer conversion",
201 "Integral promotion",
202 "Floating point promotion",
204 "Integral conversion",
205 "Floating conversion",
206 "Complex conversion",
207 "Floating-integral conversion",
208 "Pointer conversion",
209 "Pointer-to-member conversion",
210 "Boolean conversion",
211 "Compatible-types conversion",
212 "Derived-to-base conversion",
214 "SVE Vector conversion",
215 "RVV Vector conversion",
217 "Complex-real conversion",
218 "Block Pointer conversion",
219 "Transparent Union Conversion",
220 "Writeback conversion",
221 "OpenCL Zero Event Conversion",
222 "OpenCL Zero Queue Conversion",
223 "C specific type conversion",
224 "Incompatible pointer conversion",
225 "Fixed point conversion",
226 "HLSL vector truncation",
227 "Non-decaying array conversion",
304 FromType = Context.getArrayDecayedType(FromType);
316 const Expr *Converted) {
319 if (
auto *EWC = dyn_cast<ExprWithCleanups>(Converted)) {
326 while (
auto *ICE = dyn_cast<ImplicitCastExpr>(Converted)) {
327 switch (ICE->getCastKind()) {
329 case CK_IntegralCast:
330 case CK_IntegralToBoolean:
331 case CK_IntegralToFloating:
332 case CK_BooleanToSignedIntegral:
333 case CK_FloatingToIntegral:
334 case CK_FloatingToBoolean:
335 case CK_FloatingCast:
336 Converted = ICE->getSubExpr();
360 QualType &ConstantType,
bool IgnoreFloatToIntegralConversion)
const {
362 "narrowing check outside C++");
373 ToType = ED->getIntegerType();
379 goto FloatingIntegralConversion;
381 goto IntegralConversion;
392 FloatingIntegralConversion:
397 if (IgnoreFloatToIntegralConversion)
400 assert(
Initializer &&
"Unknown conversion expression");
406 if (std::optional<llvm::APSInt> IntConstantValue =
410 Result.convertFromAPInt(*IntConstantValue, IntConstantValue->isSigned(),
411 llvm::APFloat::rmNearestTiesToEven);
413 llvm::APSInt ConvertedValue = *IntConstantValue;
415 llvm::APFloat::opStatus Status =
Result.convertToInteger(
416 ConvertedValue, llvm::APFloat::rmTowardZero, &ignored);
419 if (Status == llvm::APFloat::opInvalidOp ||
420 *IntConstantValue != ConvertedValue) {
421 ConstantValue =
APValue(*IntConstantValue);
448 Initializer->isCXX11ConstantExpr(Ctx, &ConstantValue)) {
451 ConstantValue = R.
Val;
452 assert(ConstantValue.
isFloat());
453 llvm::APFloat FloatVal = ConstantValue.
getFloat();
456 llvm::APFloat Converted = FloatVal;
457 llvm::APFloat::opStatus ConvertStatus =
459 llvm::APFloat::rmNearestTiesToEven, &ignored);
461 llvm::APFloat::rmNearestTiesToEven, &ignored);
463 if (FloatVal.isNaN() && Converted.isNaN() &&
464 !FloatVal.isSignaling() && !Converted.isSignaling()) {
470 if (!Converted.bitwiseIsEqual(FloatVal)) {
477 if (ConvertStatus & llvm::APFloat::opOverflow) {
499 IntegralConversion: {
507 constexpr auto CanRepresentAll = [](
bool FromSigned,
unsigned FromWidth,
508 bool ToSigned,
unsigned ToWidth) {
509 return (FromWidth < ToWidth + (FromSigned == ToSigned)) &&
510 !(FromSigned && !ToSigned);
513 if (CanRepresentAll(FromSigned, FromWidth, ToSigned, ToWidth))
519 bool DependentBitField =
false;
521 if (BitField->getBitWidth()->isValueDependent())
522 DependentBitField =
true;
523 else if (
unsigned BitFieldWidth = BitField->getBitWidthValue();
524 BitFieldWidth < FromWidth) {
525 if (CanRepresentAll(FromSigned, BitFieldWidth, ToSigned, ToWidth))
529 FromWidth = BitFieldWidth;
537 std::optional<llvm::APSInt> OptInitializerValue =
539 if (!OptInitializerValue) {
543 if (DependentBitField && !(FromSigned && !ToSigned))
549 llvm::APSInt &InitializerValue = *OptInitializerValue;
550 bool Narrowing =
false;
551 if (FromWidth < ToWidth) {
554 if (InitializerValue.isSigned() && InitializerValue.isNegative())
560 InitializerValue.extend(InitializerValue.getBitWidth() + 1);
562 llvm::APSInt ConvertedValue = InitializerValue;
563 ConvertedValue = ConvertedValue.trunc(ToWidth);
564 ConvertedValue.setIsSigned(ToSigned);
565 ConvertedValue = ConvertedValue.extend(InitializerValue.getBitWidth());
566 ConvertedValue.setIsSigned(InitializerValue.isSigned());
568 if (ConvertedValue != InitializerValue)
573 ConstantValue =
APValue(InitializerValue);
589 ConstantValue = R.
Val;
590 assert(ConstantValue.
isFloat());
591 llvm::APFloat FloatVal = ConstantValue.
getFloat();
596 if (FloatVal.isNaN() && FloatVal.isSignaling()) {
612 raw_ostream &OS = llvm::errs();
613 bool PrintedSomething =
false;
616 PrintedSomething =
true;
620 if (PrintedSomething) {
626 OS <<
" (by copy constructor)";
628 OS <<
" (direct reference binding)";
630 OS <<
" (reference binding)";
632 PrintedSomething =
true;
636 if (PrintedSomething) {
640 PrintedSomething =
true;
643 if (!PrintedSomething) {
644 OS <<
"No conversions required";
651 raw_ostream &OS = llvm::errs();
659 OS <<
"aggregate initialization";
669 raw_ostream &OS = llvm::errs();
671 OS <<
"Worst list element conversion: ";
672 switch (ConversionKind) {
674 OS <<
"Standard conversion: ";
678 OS <<
"User-defined conversion: ";
682 OS <<
"Ellipsis conversion";
685 OS <<
"Ambiguous conversion";
688 OS <<
"Bad conversion";
713 struct DFIArguments {
719 struct DFIParamWithArguments : DFIArguments {
724 struct DFIDeducedMismatchArgs : DFIArguments {
725 TemplateArgumentList *TemplateArgs;
726 unsigned CallArgIndex;
731 TemplateArgumentList *TemplateArgs;
732 ConstraintSatisfaction Satisfaction;
743 Result.Result =
static_cast<unsigned>(TDK);
744 Result.HasDiagnostic =
false;
763 auto *Saved =
new (Context) DFIDeducedMismatchArgs;
774 DFIArguments *Saved =
new (Context) DFIArguments;
786 DFIParamWithArguments *Saved =
new (Context) DFIParamWithArguments;
787 Saved->Param = Info.
Param;
800 Result.HasDiagnostic =
true;
805 CNSInfo *Saved =
new (Context) CNSInfo;
815 llvm_unreachable(
"not a deduction failure");
848 Diag->~PartialDiagnosticAt();
857 Diag->~PartialDiagnosticAt();
893 return TemplateParameter::getFromOpaqueValue(
Data);
898 return static_cast<DFIParamWithArguments*
>(
Data)->Param;
928 return static_cast<DFIDeducedMismatchArgs*
>(
Data)->TemplateArgs;
934 return static_cast<CNSInfo*
>(
Data)->TemplateArgs;
966 return &
static_cast<DFIArguments*
>(
Data)->FirstArg;
998 return &
static_cast<DFIArguments*
>(
Data)->SecondArg;
1013 return static_cast<DFIDeducedMismatchArgs*
>(
Data)->CallArgIndex;
1016 return std::nullopt;
1029 for (
unsigned I = 0; I <
X->getNumParams(); ++I)
1033 if (
auto *FTX =
X->getDescribedFunctionTemplate()) {
1038 FTY->getTemplateParameters()))
1047 OverloadedOperatorKind::OO_EqualEqual);
1059 OverloadedOperatorKind::OO_ExclaimEqual);
1077 auto *NotEqFD = Op->getAsFunction();
1078 if (
auto *UD = dyn_cast<UsingShadowDecl>(Op))
1079 NotEqFD = UD->getUnderlyingDecl()->getAsFunction();
1092 return Op == OO_EqualEqual || Op == OO_Spaceship;
1100 if (Op == OverloadedOperatorKind::OO_EqualEqual) {
1101 assert(OriginalArgs.size() == 2);
1103 S,
OpLoc, OriginalArgs[1], FD))
1114void OverloadCandidateSet::destroyCandidates() {
1115 for (
iterator i = Candidates.begin(), e = Candidates.end(); i != e; ++i) {
1116 for (
auto &
C : i->Conversions)
1117 C.~ImplicitConversionSequence();
1119 i->DeductionFailure.Destroy();
1124 destroyCandidates();
1125 SlabAllocator.Reset();
1126 NumInlineBytesUsed = 0;
1130 FirstDeferredCandidate =
nullptr;
1131 DeferredCandidatesCount = 0;
1132 HasDeferredTemplateConstructors =
false;
1133 ResolutionByPerfectCandidateIsDisabled =
false;
1137 class UnbridgedCastsSet {
1147 Entry entry = { &E, E };
1148 Entries.push_back(entry);
1153 for (SmallVectorImpl<Entry>::iterator
1154 i = Entries.begin(), e = Entries.end(); i != e; ++i)
1155 *i->Addr = i->Saved;
1169 UnbridgedCastsSet *unbridgedCasts =
nullptr) {
1173 if (placeholder->getKind() == BuiltinType::Overload)
return false;
1177 if (placeholder->getKind() == BuiltinType::ARCUnbridgedCast &&
1179 unbridgedCasts->save(S, E);
1199 UnbridgedCastsSet &unbridged) {
1200 for (
unsigned i = 0, e = Args.size(); i != e; ++i)
1209 bool NewIsUsingDecl) {
1214 bool OldIsUsingDecl =
false;
1216 OldIsUsingDecl =
true;
1220 if (NewIsUsingDecl)
continue;
1227 if ((OldIsUsingDecl || NewIsUsingDecl) && !
isVisible(*I))
1235 bool UseMemberUsingDeclRules =
1236 (OldIsUsingDecl || NewIsUsingDecl) &&
CurContext->isRecord() &&
1237 !
New->getFriendObjectKind();
1241 if (UseMemberUsingDeclRules && OldIsUsingDecl) {
1247 !shouldLinkPossiblyHiddenDecl(*I,
New))
1266 }
else if (
auto *UUD = dyn_cast<UnresolvedUsingValueDecl>(OldD)) {
1273 if (UUD->getQualifier().isDependent() && !UUD->isCXXClassMember()) {
1301 if (
New->getFriendObjectKind() &&
New->getQualifier() &&
1302 !
New->getDescribedFunctionTemplate() &&
1303 !
New->getDependentSpecializationInfo() &&
1304 !
New->getType()->isDependentType()) {
1309 New->setInvalidDecl();
1321 assert(D &&
"function decl should not be null");
1322 if (
auto *A = D->
getAttr<AttrT>())
1323 return !A->isImplicit();
1329 bool UseMemberUsingDeclRules,
1330 bool ConsiderCudaAttrs,
1331 bool UseOverrideRules =
false) {
1337 if (
New->isMSVCRTEntryPoint())
1348 if ((OldTemplate ==
nullptr) != (NewTemplate ==
nullptr))
1371 if (OldQType != NewQType && OldType->isVariadic() != NewType->isVariadic())
1375 if ((
New->isMemberLikeConstrainedFriend() ||
1386 OldDecl = OldTemplate;
1387 NewDecl = NewTemplate;
1405 bool ConstraintsInTemplateHead =
1416 if (UseMemberUsingDeclRules && ConstraintsInTemplateHead &&
1417 !SameTemplateParameterList)
1419 if (!UseMemberUsingDeclRules &&
1420 (!SameTemplateParameterList || !SameReturnType))
1424 const auto *OldMethod = dyn_cast<CXXMethodDecl>(Old);
1425 const auto *NewMethod = dyn_cast<CXXMethodDecl>(
New);
1427 int OldParamsOffset = 0;
1428 int NewParamsOffset = 0;
1436 if (ThisType.isConstQualified())
1456 BS.
Quals = NormalizeQualifiers(OldMethod, BS.
Quals);
1457 DS.Quals = NormalizeQualifiers(NewMethod, DS.Quals);
1459 if (OldMethod->isExplicitObjectMemberFunction()) {
1461 DS.Quals.removeVolatile();
1464 return BS.
Quals == DS.Quals;
1468 auto BS =
Base.getNonReferenceType().getCanonicalType().split();
1469 auto DS = D.getNonReferenceType().getCanonicalType().split();
1471 if (!AreQualifiersEqual(BS, DS))
1474 if (OldMethod->isImplicitObjectMemberFunction() &&
1475 OldMethod->getParent() != NewMethod->getParent()) {
1487 if (
Base->isLValueReferenceType())
1488 return D->isLValueReferenceType();
1489 return Base->isRValueReferenceType() == D->isRValueReferenceType();
1494 auto DiagnoseInconsistentRefQualifiers = [&]() {
1495 if (SemaRef.
LangOpts.CPlusPlus23 && !UseOverrideRules)
1497 if (OldMethod->getRefQualifier() == NewMethod->getRefQualifier())
1499 if (OldMethod->isExplicitObjectMemberFunction() ||
1500 NewMethod->isExplicitObjectMemberFunction())
1502 if (!UseMemberUsingDeclRules && (OldMethod->getRefQualifier() ==
RQ_None ||
1503 NewMethod->getRefQualifier() ==
RQ_None)) {
1504 SemaRef.
Diag(NewMethod->getLocation(), diag::err_ref_qualifier_overload)
1505 << NewMethod->getRefQualifier() << OldMethod->getRefQualifier();
1506 SemaRef.
Diag(OldMethod->getLocation(), diag::note_previous_declaration);
1512 if (OldMethod && OldMethod->isExplicitObjectMemberFunction())
1514 if (NewMethod && NewMethod->isExplicitObjectMemberFunction())
1517 if (OldType->getNumParams() - OldParamsOffset !=
1518 NewType->getNumParams() - NewParamsOffset ||
1520 {OldType->param_type_begin() + OldParamsOffset,
1521 OldType->param_type_end()},
1522 {NewType->param_type_begin() + NewParamsOffset,
1523 NewType->param_type_end()},
1528 if (OldMethod && NewMethod && !OldMethod->isStatic() &&
1529 !NewMethod->isStatic()) {
1530 bool HaveCorrespondingObjectParameters = [&](
const CXXMethodDecl *Old,
1532 auto NewObjectType =
New->getFunctionObjectParameterReferenceType();
1536 return F->getRefQualifier() ==
RQ_None &&
1537 !F->isExplicitObjectMemberFunction();
1540 if (IsImplicitWithNoRefQual(Old) != IsImplicitWithNoRefQual(
New) &&
1541 CompareType(OldObjectType.getNonReferenceType(),
1542 NewObjectType.getNonReferenceType()))
1544 return CompareType(OldObjectType, NewObjectType);
1545 }(OldMethod, NewMethod);
1547 if (!HaveCorrespondingObjectParameters) {
1548 if (DiagnoseInconsistentRefQualifiers())
1553 if (!UseOverrideRules || (!NewMethod->isExplicitObjectMemberFunction() &&
1554 !OldMethod->isExplicitObjectMemberFunction()))
1559 if (!UseOverrideRules &&
1563 if (!NewRC != !OldRC)
1573 if (NewMethod && OldMethod && OldMethod->isImplicitObjectMemberFunction() &&
1574 NewMethod->isImplicitObjectMemberFunction()) {
1575 if (DiagnoseInconsistentRefQualifiers())
1589 NewI =
New->specific_attr_begin<EnableIfAttr>(),
1590 NewE =
New->specific_attr_end<EnableIfAttr>(),
1593 NewI != NewE || OldI != OldE; ++NewI, ++OldI) {
1594 if (NewI == NewE || OldI == OldE)
1596 llvm::FoldingSetNodeID NewID, OldID;
1597 NewI->getCond()->Profile(NewID, SemaRef.
Context,
true);
1598 OldI->getCond()->Profile(OldID, SemaRef.
Context,
true);
1604 if (SemaRef.
getLangOpts().CUDA && ConsiderCudaAttrs) {
1612 "Unexpected invalid target.");
1616 if (NewTarget != OldTarget) {
1619 if (OldMethod && NewMethod && OldMethod->isVirtual() &&
1620 OldMethod->isConstexpr() && !NewMethod->isConstexpr() &&
1638 bool UseMemberUsingDeclRules,
bool ConsiderCudaAttrs) {
1644 bool UseMemberUsingDeclRules,
bool ConsiderCudaAttrs) {
1657 bool SuppressUserConversions,
1659 bool InOverloadResolution,
1661 bool AllowObjCWritebackConversion,
1662 bool AllowObjCConversionOnExplicit) {
1665 if (SuppressUserConversions) {
1676 Conversions, AllowExplicit,
1677 AllowObjCConversionOnExplicit)) {
1698 bool FromListInit =
false;
1699 if (
const auto *InitList = dyn_cast<InitListExpr>(From);
1700 InitList && InitList->getNumInits() == 1 &&
1702 const Expr *SingleInit = InitList->getInit(0);
1703 FromType = SingleInit->
getType();
1705 FromListInit =
true;
1714 if ((FromCanon == ToCanon ||
1726 if (ToCanon != FromCanon)
1737 Cand != Conversions.
end(); ++Cand)
1778static ImplicitConversionSequence
1780 bool SuppressUserConversions,
1782 bool InOverloadResolution,
1784 bool AllowObjCWritebackConversion,
1785 bool AllowObjCConversionOnExplicit) {
1788 ICS.
Standard, CStyle, AllowObjCWritebackConversion)){
1832 FromResType->getWrappedType()) &&
1834 FromResType->getContainedType()) &&
1835 ToResType->getAttrs() == FromResType->getAttrs()) {
1845 AllowExplicit, InOverloadResolution, CStyle,
1846 AllowObjCWritebackConversion,
1847 AllowObjCConversionOnExplicit);
1850ImplicitConversionSequence
1852 bool SuppressUserConversions,
1854 bool InOverloadResolution,
1856 bool AllowObjCWritebackConversion) {
1857 return ::TryImplicitConversion(*
this, From, ToType, SuppressUserConversions,
1858 AllowExplicit, InOverloadResolution, CStyle,
1859 AllowObjCWritebackConversion,
1865 bool AllowExplicit) {
1870 bool AllowObjCWritebackConversion =
1877 *
this, From, ToType,
1879 AllowExplicit ? AllowedExplicit::All : AllowedExplicit::None,
1881 false, AllowObjCWritebackConversion,
1902 if (
Context.hasSameUnqualifiedType(FromType, ToType))
1915 if (TyClass != CanFrom->getTypeClass())
return false;
1916 if (TyClass != Type::FunctionProto && TyClass != Type::FunctionNoProto) {
1917 if (TyClass == Type::Pointer) {
1920 }
else if (TyClass == Type::BlockPointer) {
1923 }
else if (TyClass == Type::MemberPointer) {
1930 CanTo = ToMPT->getPointeeType();
1936 TyClass = CanTo->getTypeClass();
1937 if (TyClass != CanFrom->getTypeClass())
return false;
1938 if (TyClass != Type::FunctionProto && TyClass != Type::FunctionNoProto)
1948 bool Changed =
false;
1956 const auto *FromFPT = dyn_cast<FunctionProtoType>(FromFn);
1957 const auto *ToFPT = dyn_cast<FunctionProtoType>(ToFn);
1959 if (FromFPT && ToFPT) {
1960 if (FromFPT->hasCFIUncheckedCallee() && !ToFPT->hasCFIUncheckedCallee()) {
1962 FromFPT->getReturnType(), FromFPT->getParamTypes(),
1963 FromFPT->getExtProtoInfo().withCFIUncheckedCallee(
false));
1969 }
else if (!FromFPT->hasCFIUncheckedCallee() &&
1970 ToFPT->hasCFIUncheckedCallee()) {
1972 FromFPT->getReturnType(), FromFPT->getParamTypes(),
1973 FromFPT->getExtProtoInfo().withCFIUncheckedCallee(
true));
1983 if (FromFPT && ToFPT) {
1984 if (FromFPT->isNothrow() && !ToFPT->isNothrow()) {
1996 bool CanUseToFPT, CanUseFromFPT;
1997 if (
Context.mergeExtParameterInfo(ToFPT, FromFPT, CanUseToFPT,
1998 CanUseFromFPT, NewParamInfos) &&
1999 CanUseToFPT && !CanUseFromFPT) {
2002 NewParamInfos.empty() ?
nullptr : NewParamInfos.data();
2004 FromFPT->getParamTypes(), ExtInfo);
2018 const auto FromFX = FromFPT->getFunctionEffects();
2019 const auto ToFX = ToFPT->getFunctionEffects();
2020 if (FromFX != ToFX) {
2024 FromFPT->getReturnType(), FromFPT->getParamTypes(), ExtInfo);
2034 assert(
QualType(FromFn, 0).isCanonical());
2035 if (
QualType(FromFn, 0) != CanTo)
return false;
2062 if ((&FromSem == &llvm::APFloat::PPCDoubleDouble() &&
2063 &ToSem == &llvm::APFloat::IEEEquad()) ||
2064 (&FromSem == &llvm::APFloat::IEEEquad() &&
2065 &ToSem == &llvm::APFloat::PPCDoubleDouble()))
2120 bool InOverloadResolution,
bool CStyle) {
2137 if (ToExtType && FromExtType) {
2139 unsigned ToElts = ToExtType->getNumElements();
2140 if (FromElts < ToElts)
2142 if (FromElts == ToElts)
2148 QualType ToElTy = ToExtType->getElementType();
2153 if (FromExtType && !ToExtType) {
2167 if (ToExtType->getNumElements() != FromExtType->getNumElements())
2172 FromExtType->getElementType()->isIntegerType()) {
2184 QualType ToElTy = ToExtType->getElementType();
2218 !ToType->
hasAttr(attr::ArmMveStrictPolymorphism))) {
2223 !InOverloadResolution && !CStyle) {
2225 << FromType << ToType;
2236 bool InOverloadResolution,
2237 StandardConversionSequence &SCS,
2249 bool InOverloadResolution,
2252 bool AllowObjCWritebackConversion) {
2278 FromType = Fn->getType();
2298 if (Method && !Method->isStatic() &&
2299 !Method->isExplicitObjectMemberFunction()) {
2301 "Non-unary operator on non-static member address");
2304 "Non-address-of operator on non-static member address");
2306 FromType, std::nullopt, Method->getParent());
2310 "Non-address-of operator for overloaded function expression");
2356 FromType =
Atomic->getValueType();
2391 if (
auto *FD = dyn_cast<FunctionDecl>(DRE->getDecl()))
2411 bool IncompatibleObjC =
false;
2466 }
else if (AllowObjCWritebackConversion &&
2470 FromType, IncompatibleObjC)) {
2476 InOverloadResolution, FromType)) {
2480 From, InOverloadResolution, CStyle)) {
2490 S, From, ToType, InOverloadResolution, SCS, CStyle)) {
2526 bool ObjCLifetimeConversion;
2532 ObjCLifetimeConversion)) {
2551 CanonFrom = CanonTo;
2564 if ((S.
getLangOpts().CPlusPlus || !InOverloadResolution))
2576 case AssignConvertType::
2577 CompatibleVoidPtrToNonVoidPtr:
2610 bool InOverloadResolution,
2618 const RecordDecl *UD = UT->getOriginalDecl()->getDefinitionOrSelf();
2619 if (!UD->
hasAttr<TransparentUnionAttr>())
2622 for (
const auto *it : UD->
fields()) {
2625 ToType = it->getType();
2651 return To->
getKind() == BuiltinType::Int;
2654 return To->
getKind() == BuiltinType::UInt;
2678 if (FromED->isScoped())
2685 if (FromED->isFixed()) {
2686 QualType Underlying = FromED->getIntegerType();
2687 return Context.hasSameUnqualifiedType(Underlying, ToType) ||
2694 return Context.hasSameUnqualifiedType(ToType, FromED->getPromotionType());
2719 uint64_t FromSize =
Context.getTypeSize(FromType);
2728 for (
int Idx = 0; Idx < 6; ++Idx) {
2729 uint64_t ToSize =
Context.getTypeSize(PromoteTypes[Idx]);
2730 if (FromSize < ToSize ||
2731 (FromSize == ToSize &&
2732 FromIsSigned == PromoteTypes[Idx]->isSignedIntegerType())) {
2736 return Context.hasSameUnqualifiedType(ToType, PromoteTypes[Idx]);
2757 std::optional<llvm::APSInt> BitWidth;
2760 MemberDecl->getBitWidth()->getIntegerConstantExpr(
Context))) {
2761 llvm::APSInt ToSize(BitWidth->getBitWidth(), BitWidth->isUnsigned());
2762 ToSize =
Context.getTypeSize(ToType);
2765 if (*BitWidth < ToSize ||
2767 return To->
getKind() == BuiltinType::Int;
2773 return To->
getKind() == BuiltinType::UInt;
2791 return Context.getTypeSize(FromType) <
Context.getTypeSize(ToType);
2801 if (FromBuiltin->getKind() == BuiltinType::Float &&
2802 ToBuiltin->getKind() == BuiltinType::Double)
2809 (FromBuiltin->getKind() == BuiltinType::Float ||
2810 FromBuiltin->getKind() == BuiltinType::Double) &&
2811 (ToBuiltin->getKind() == BuiltinType::LongDouble ||
2812 ToBuiltin->getKind() == BuiltinType::Float128 ||
2813 ToBuiltin->getKind() == BuiltinType::Ibm128))
2818 if (
getLangOpts().
HLSL && FromBuiltin->getKind() == BuiltinType::Half &&
2819 (ToBuiltin->getKind() == BuiltinType::Float ||
2820 ToBuiltin->getKind() == BuiltinType::Double))
2825 FromBuiltin->getKind() == BuiltinType::Half &&
2826 ToBuiltin->getKind() == BuiltinType::Float)
2858 bool StripObjCLifetime =
false) {
2861 "Invalid similarly-qualified pointer type");
2872 if (StripObjCLifetime)
2884 return Context.getObjCObjectPointerType(ToPointee);
2885 return Context.getPointerType(ToPointee);
2893 return Context.getObjCObjectPointerType(QualifiedCanonToPointee);
2894 return Context.getPointerType(QualifiedCanonToPointee);
2898 bool InOverloadResolution,
2904 return !InOverloadResolution;
2912 bool InOverloadResolution,
2914 bool &IncompatibleObjC) {
2915 IncompatibleObjC =
false;
2923 ConvertedType = ToType;
2930 ConvertedType = ToType;
2937 ConvertedType = ToType;
2945 ConvertedType = ToType;
2955 ConvertedType = ToType;
2977 if (
Context.hasSameUnqualifiedType(FromPointeeType, ToPointeeType))
3004 Context.typesAreCompatible(FromPointeeType, ToPointeeType)) {
3026 !
Context.hasSameUnqualifiedType(FromPointeeType, ToPointeeType) &&
3035 Context.areCompatibleVectorTypes(FromPointeeType, ToPointeeType)) {
3054 return Context.getQualifiedType(
T, Qs);
3056 return Context.getQualifiedType(
T.getUnqualifiedType(), Qs);
3061 bool &IncompatibleObjC) {
3074 if (ToObjCPtr && FromObjCPtr) {
3082 if (
Context.canAssignObjCInterfaces(ToObjCPtr, FromObjCPtr)) {
3096 if (
Context.canAssignObjCInterfaces(FromObjCPtr, ToObjCPtr)) {
3100 IncompatibleObjC =
true;
3116 if (FromObjCPtr && FromObjCPtr->isObjCBuiltinType()) {
3145 IncompatibleObjC)) {
3147 IncompatibleObjC =
true;
3148 ConvertedType =
Context.getPointerType(ConvertedType);
3157 IncompatibleObjC)) {
3159 ConvertedType =
Context.getPointerType(ConvertedType);
3172 if (FromFunctionType && ToFunctionType) {
3175 if (
Context.getCanonicalType(FromPointeeType)
3176 ==
Context.getCanonicalType(ToPointeeType))
3181 if (FromFunctionType->
getNumParams() != ToFunctionType->getNumParams() ||
3182 FromFunctionType->
isVariadic() != ToFunctionType->isVariadic() ||
3183 FromFunctionType->
getMethodQuals() != ToFunctionType->getMethodQuals())
3186 bool HasObjCConversion =
false;
3188 Context.getCanonicalType(ToFunctionType->getReturnType())) {
3191 ToFunctionType->getReturnType(),
3192 ConvertedType, IncompatibleObjC)) {
3194 HasObjCConversion =
true;
3201 for (
unsigned ArgIdx = 0, NumArgs = FromFunctionType->
getNumParams();
3202 ArgIdx != NumArgs; ++ArgIdx) {
3204 QualType ToArgType = ToFunctionType->getParamType(ArgIdx);
3205 if (
Context.getCanonicalType(FromArgType)
3206 ==
Context.getCanonicalType(ToArgType)) {
3209 ConvertedType, IncompatibleObjC)) {
3211 HasObjCConversion =
true;
3218 if (HasObjCConversion) {
3222 IncompatibleObjC =
true;
3254 if (!FromFunctionType || !ToFunctionType)
3257 if (
Context.hasSameType(FromPointeeType, ToPointeeType))
3262 if (FromFunctionType->
getNumParams() != ToFunctionType->getNumParams() ||
3263 FromFunctionType->
isVariadic() != ToFunctionType->isVariadic())
3268 if (FromEInfo != ToEInfo)
3271 bool IncompatibleObjC =
false;
3273 ToFunctionType->getReturnType())) {
3277 QualType LHS = ToFunctionType->getReturnType();
3282 if (
Context.hasSameType(RHS,LHS)) {
3285 ConvertedType, IncompatibleObjC)) {
3286 if (IncompatibleObjC)
3295 for (
unsigned ArgIdx = 0, NumArgs = FromFunctionType->
getNumParams();
3296 ArgIdx != NumArgs; ++ArgIdx) {
3297 IncompatibleObjC =
false;
3299 QualType ToArgType = ToFunctionType->getParamType(ArgIdx);
3300 if (
Context.hasSameType(FromArgType, ToArgType)) {
3303 ConvertedType, IncompatibleObjC)) {
3304 if (IncompatibleObjC)
3313 bool CanUseToFPT, CanUseFromFPT;
3314 if (!
Context.mergeExtParameterInfo(ToFunctionType, FromFunctionType,
3315 CanUseToFPT, CanUseFromFPT,
3319 ConvertedType = ToType;
3358 ToMember->getMostRecentCXXRecordDecl())) {
3360 if (ToMember->isSugared())
3362 ToMember->getMostRecentCXXRecordDecl());
3364 PDiag << ToMember->getQualifier();
3365 if (FromMember->isSugared())
3367 FromMember->getMostRecentCXXRecordDecl());
3369 PDiag << FromMember->getQualifier();
3387 !FromType->
getAs<TemplateSpecializationType>()) {
3393 if (
Context.hasSameType(FromType, ToType)) {
3402 if (!FromFunction || !ToFunction) {
3407 if (FromFunction->
getNumParams() != ToFunction->getNumParams()) {
3417 << ToFunction->getParamType(ArgPos)
3424 ToFunction->getReturnType())) {
3430 if (FromFunction->
getMethodQuals() != ToFunction->getMethodQuals()) {
3453 assert(llvm::size(Old) == llvm::size(
New) &&
3454 "Can't compare parameters of functions with different number of "
3457 for (
auto &&[Idx,
Type] : llvm::enumerate(Old)) {
3459 size_t J =
Reversed ? (llvm::size(
New) - Idx - 1) : Idx;
3464 Context.removePtrSizeAddrSpace(
Type.getUnqualifiedType());
3466 Context.removePtrSizeAddrSpace((
New.begin() + J)->getUnqualifiedType());
3468 if (!
Context.hasSameType(OldType, NewType)) {
3493 unsigned OldIgnore =
3495 unsigned NewIgnore =
3502 NewPT->param_types().slice(NewIgnore),
3509 bool IgnoreBaseAccess,
3512 bool IsCStyleOrFunctionalCast = IgnoreBaseAccess;
3521 PDiag(diag::warn_impcast_bool_to_null_pointer)
3532 if (FromPointeeType->
isRecordType() && ToPointeeType->isRecordType() &&
3533 !
Context.hasSameUnqualifiedType(FromPointeeType, ToPointeeType)) {
3536 unsigned InaccessibleID = 0;
3537 unsigned AmbiguousID = 0;
3539 InaccessibleID = diag::err_upcast_to_inaccessible_base;
3540 AmbiguousID = diag::err_ambiguous_derived_to_base_conv;
3543 FromPointeeType, ToPointeeType, InaccessibleID, AmbiguousID,
3545 &BasePath, IgnoreBaseAccess))
3549 Kind = CK_DerivedToBase;
3552 if (
Diagnose && !IsCStyleOrFunctionalCast &&
3553 FromPointeeType->
isFunctionType() && ToPointeeType->isVoidType()) {
3555 "this should only be possible with MSVCCompat!");
3567 if (FromPtrType->isObjCBuiltinType() || ToPtrType->isObjCBuiltinType())
3570 Kind = CK_BlockPointerToObjCPointerCast;
3572 Kind = CK_CPointerToObjCPointerCast;
3576 Kind = CK_AnyPointerToBlockPointerCast;
3582 Kind = CK_NullToPointer;
3589 bool InOverloadResolution,
3599 ConvertedType = ToType;
3615 ConvertedType =
Context.getMemberPointerType(
3629 if (
Context.getTargetInfo().getCXXABI().isMicrosoft()) {
3637 Kind = CK_NullToMemberPointer;
3655 PD <<
Context.getCanonicalTagType(Cls);
3665 std::swap(
Base, Derived);
3674 PD <<
int(Direction);
3682 DiagFromTo(PD) <<
QualType(VBase, 0) << OpRange;
3690 ? CK_DerivedToBaseMemberPointer
3691 : CK_BaseToDerivedMemberPointer;
3693 if (!IgnoreBaseAccess)
3697 ? diag::err_upcast_to_inaccessible_base
3698 : diag::err_downcast_from_inaccessible_base,
3700 NestedNameSpecifier BaseQual = FromPtrType->getQualifier(),
3701 DerivedQual = ToPtrType->getQualifier();
3702 if (Direction == MemberPointerConversionDirection::Upcast)
3703 std::swap(BaseQual, DerivedQual);
3704 DiagCls(PD, DerivedQual, Derived);
3705 DiagCls(PD, BaseQual, Base);
3740 bool CStyle,
bool IsTopLevel,
3741 bool &PreviousToQualsIncludeConst,
3742 bool &ObjCLifetimeConversion,
3755 ObjCLifetimeConversion =
true;
3795 !PreviousToQualsIncludeConst)
3813 PreviousToQualsIncludeConst =
3814 PreviousToQualsIncludeConst && ToQuals.
hasConst();
3820 bool CStyle,
bool &ObjCLifetimeConversion) {
3821 FromType =
Context.getCanonicalType(FromType);
3822 ToType =
Context.getCanonicalType(ToType);
3823 ObjCLifetimeConversion =
false;
3833 bool PreviousToQualsIncludeConst =
true;
3834 bool UnwrappedAnyPointer =
false;
3835 while (
Context.UnwrapSimilarTypes(FromType, ToType)) {
3837 !UnwrappedAnyPointer,
3838 PreviousToQualsIncludeConst,
3841 UnwrappedAnyPointer =
true;
3849 return UnwrappedAnyPointer &&
Context.hasSameUnqualifiedType(FromType,ToType);
3858 bool InOverloadResolution,
3867 InOverloadResolution, InnerSCS,
3884 if (CtorType->getNumParams() > 0) {
3885 QualType FirstArg = CtorType->getParamType(0);
3897 bool AllowExplicit) {
3904 bool Usable = !Info.Constructor->isInvalidDecl() &&
3907 bool SuppressUserConversions =
false;
3908 if (Info.ConstructorTmpl)
3911 CandidateSet, SuppressUserConversions,
3916 CandidateSet, SuppressUserConversions,
3917 false, AllowExplicit);
3921 bool HadMultipleCandidates = (CandidateSet.
size() > 1);
3924 switch (
auto Result =
3948 llvm_unreachable(
"Invalid OverloadResult!");
3970 bool AllowObjCConversionOnExplicit) {
3971 assert(AllowExplicit != AllowedExplicit::None ||
3972 !AllowObjCConversionOnExplicit);
3976 bool ConstructorsOnly =
false;
3980 if (
const RecordType *ToRecordType = ToType->
getAsCanonical<RecordType>()) {
3992 ConstructorsOnly =
true;
3996 }
else if (
auto *ToRecordDecl =
3997 dyn_cast<CXXRecordDecl>(ToRecordType->getOriginalDecl())) {
3998 ToRecordDecl = ToRecordDecl->getDefinitionOrSelf();
4000 Expr **Args = &From;
4001 unsigned NumArgs = 1;
4002 bool ListInitializing =
false;
4003 if (
InitListExpr *InitList = dyn_cast<InitListExpr>(From)) {
4006 S, From, ToType, ToRecordDecl, User, CandidateSet,
4007 AllowExplicit == AllowedExplicit::All);
4016 Args = InitList->getInits();
4017 NumArgs = InitList->getNumInits();
4018 ListInitializing =
true;
4026 bool Usable = !Info.Constructor->isInvalidDecl();
4027 if (!ListInitializing)
4028 Usable = Usable && Info.Constructor->isConvertingConstructor(
4031 bool SuppressUserConversions = !ConstructorsOnly;
4039 if (SuppressUserConversions && ListInitializing) {
4040 SuppressUserConversions =
4045 if (Info.ConstructorTmpl)
4047 Info.ConstructorTmpl, Info.FoundDecl,
4049 CandidateSet, SuppressUserConversions,
4051 AllowExplicit == AllowedExplicit::All);
4057 SuppressUserConversions,
4059 AllowExplicit == AllowedExplicit::All);
4069 }
else if (
const RecordType *FromRecordType =
4071 if (
auto *FromRecordDecl =
4072 dyn_cast<CXXRecordDecl>(FromRecordType->getOriginalDecl())) {
4073 FromRecordDecl = FromRecordDecl->getDefinitionOrSelf();
4075 const auto &Conversions = FromRecordDecl->getVisibleConversionFunctions();
4076 for (
auto I = Conversions.begin(), E = Conversions.end(); I != E; ++I) {
4085 if ((ConvTemplate = dyn_cast<FunctionTemplateDecl>(D)))
4092 ConvTemplate, FoundDecl, ActingContext, From, ToType,
4093 CandidateSet, AllowObjCConversionOnExplicit,
4094 AllowExplicit != AllowedExplicit::None);
4097 CandidateSet, AllowObjCConversionOnExplicit,
4098 AllowExplicit != AllowedExplicit::None);
4103 bool HadMultipleCandidates = (CandidateSet.
size() > 1);
4106 switch (
auto Result =
4112 = dyn_cast<CXXConstructorDecl>(Best->Function)) {
4124 if (Best->Conversions[0].isEllipsis())
4127 User.
Before = Best->Conversions[0].Standard;
4140 = dyn_cast<CXXConversionDecl>(Best->Function)) {
4142 assert(Best->HasFinalConversion);
4150 User.
Before = Best->Conversions[0].Standard;
4165 User.
After = Best->FinalConversion;
4168 llvm_unreachable(
"Not a constructor or conversion function?");
4177 llvm_unreachable(
"Invalid OverloadResult!");
4187 CandidateSet, AllowedExplicit::None,
false);
4202 diag::err_typecheck_nonviable_condition_incomplete,
4209 *
this, From, Cands);
4235 if (!Conv1 || !Conv2)
4250 if (Block1 != Block2)
4263 if (Conv1FuncRet && Conv2FuncRet &&
4274 CallOpProto->isVariadic(),
false);
4276 CallOpProto->isVariadic(),
true);
4278 CallingConv PrefOrder[] = {DefaultFree, DefaultMember, CallOpCC};
4373 if (!ICS1.
isBad()) {
4374 bool StdInit1 =
false, StdInit2 =
false;
4381 if (StdInit1 != StdInit2)
4392 CAT2->getElementType())) {
4394 if (CAT1->getSize() != CAT2->getSize())
4396 return CAT1->getSize().ult(CAT2->getSize())
4524 if (!
Enum->isFixed())
4560 else if (Rank2 < Rank1)
4595 bool SCS1ConvertsToVoid
4597 bool SCS2ConvertsToVoid
4599 if (SCS1ConvertsToVoid != SCS2ConvertsToVoid) {
4604 }
else if (!SCS1ConvertsToVoid && !SCS2ConvertsToVoid) {
4610 }
else if (SCS1ConvertsToVoid && SCS2ConvertsToVoid &&
4639 if (FromObjCPtr1 && FromObjCPtr2) {
4644 if (AssignLeft != AssignRight) {
4679 if (UnqualT1 == UnqualT2) {
4741 if (SCS1IsCompatibleVectorConversion != SCS2IsCompatibleVectorConversion)
4742 return SCS1IsCompatibleVectorConversion
4749 bool SCS1IsCompatibleSVEVectorConversion =
4751 bool SCS2IsCompatibleSVEVectorConversion =
4754 if (SCS1IsCompatibleSVEVectorConversion !=
4755 SCS2IsCompatibleSVEVectorConversion)
4756 return SCS1IsCompatibleSVEVectorConversion
4763 bool SCS1IsCompatibleRVVVectorConversion =
4765 bool SCS2IsCompatibleRVVVectorConversion =
4768 if (SCS1IsCompatibleRVVVectorConversion !=
4769 SCS2IsCompatibleRVVVectorConversion)
4770 return SCS1IsCompatibleRVVVectorConversion
4810 if (UnqualT1 == UnqualT2)
4828 bool ObjCLifetimeConversion;
4838 if (CanPick1 != CanPick2)
4892 if (FromPointee1 == FromPointee2 && ToPointee1 != ToPointee2) {
4900 if (FromPointee1 != FromPointee2 && ToPointee1 == ToPointee2) {
4917 if (FromPtr1 && FromPtr2 && ToPtr1 && ToPtr2) {
4924 bool FromAssignRight
4933 if (ToPtr1->isObjCIdType() &&
4934 (ToPtr2->isObjCQualifiedIdType() || ToPtr2->getInterfaceDecl()))
4936 if (ToPtr2->isObjCIdType() &&
4937 (ToPtr1->isObjCQualifiedIdType() || ToPtr1->getInterfaceDecl()))
4942 if (ToPtr1->isObjCQualifiedIdType() && ToPtr2->getInterfaceDecl())
4944 if (ToPtr2->isObjCQualifiedIdType() && ToPtr1->getInterfaceDecl())
4949 if (ToPtr1->isObjCClassType() &&
4950 (ToPtr2->isObjCQualifiedClassType() || ToPtr2->getInterfaceDecl()))
4952 if (ToPtr2->isObjCClassType() &&
4953 (ToPtr1->isObjCQualifiedClassType() || ToPtr1->getInterfaceDecl()))
4958 if (ToPtr1->isObjCQualifiedClassType() && ToPtr2->getInterfaceDecl())
4960 if (ToPtr2->isObjCQualifiedClassType() && ToPtr1->getInterfaceDecl())
4966 (ToAssignLeft != ToAssignRight)) {
4977 }
else if (IsSecondSame)
4986 (FromAssignLeft != FromAssignRight))
5000 CXXRecordDecl *FromPointee1 = FromMemPointer1->getMostRecentCXXRecordDecl();
5005 if (FromPointee1 == FromPointee2 && ToPointee1 != ToPointee2) {
5012 if (ToPointee1 == ToPointee2 && FromPointee1 != FromPointee2) {
5050 if (!
T.getQualifiers().hasUnaligned())
5064 "T1 must be the pointee type of the reference type");
5065 assert(!OrigT2->
isReferenceType() &&
"T2 cannot be a reference type");
5088 if (UnqualT1 == UnqualT2) {
5092 Conv |= ReferenceConversions::DerivedToBase;
5095 Context.canBindObjCObjectType(UnqualT1, UnqualT2))
5096 Conv |= ReferenceConversions::ObjC;
5099 Conv |= ReferenceConversions::Function;
5103 bool ConvertedReferent = Conv != 0;
5107 bool PreviousToQualsIncludeConst =
true;
5108 bool TopLevel =
true;
5114 Conv |= ReferenceConversions::Qualification;
5120 Conv |= ReferenceConversions::NestedQualification;
5128 bool ObjCLifetimeConversion =
false;
5130 PreviousToQualsIncludeConst,
5132 return (ConvertedReferent ||
Context.hasSimilarType(T1, T2))
5137 if (ObjCLifetimeConversion)
5138 Conv |= ReferenceConversions::ObjCLifetime;
5141 }
while (
Context.UnwrapSimilarTypes(T1, T2));
5146 return (ConvertedReferent ||
Context.hasSameUnqualifiedType(T1, T2))
5157 bool AllowExplicit) {
5158 assert(T2->
isRecordType() &&
"Can only find conversions of record types.");
5162 const auto &Conversions = T2RecordDecl->getVisibleConversionFunctions();
5163 for (
auto I = Conversions.begin(), E = Conversions.end(); I != E; ++I) {
5170 = dyn_cast<FunctionTemplateDecl>(D);
5187 if (!ConvTemplate &&
5211 ConvTemplate, I.getPair(), ActingDC,
Init, DeclType, CandidateSet,
5212 false, AllowExplicit);
5215 Conv, I.getPair(), ActingDC,
Init, DeclType, CandidateSet,
5216 false, AllowExplicit);
5219 bool HadMultipleCandidates = (CandidateSet.
size() > 1);
5225 assert(Best->HasFinalConversion);
5237 if (!Best->FinalConversion.DirectBinding)
5249 "Expected a direct reference binding!");
5255 Cand != CandidateSet.
end(); ++Cand)
5267 llvm_unreachable(
"Invalid OverloadResult!");
5272static ImplicitConversionSequence
5275 bool SuppressUserConversions,
5276 bool AllowExplicit) {
5277 assert(DeclType->
isReferenceType() &&
"Reference init needs a reference");
5304 auto SetAsReferenceBinding = [&](
bool BindsDirectly) {
5309 ICS.
Standard.
Second = (RefConv & Sema::ReferenceConversions::DerivedToBase)
5311 : (RefConv & Sema::ReferenceConversions::ObjC)
5319 Sema::ReferenceConversions::NestedQualification)
5333 (RefConv & Sema::ReferenceConversions::ObjCLifetime) != 0;
5357 SetAsReferenceBinding(
true);
5406 SetAsReferenceBinding(S.
getLangOpts().CPlusPlus11 ||
5497 AllowedExplicit::None,
5522 if (isRValRef && LValRefType) {
5539static ImplicitConversionSequence
5541 bool SuppressUserConversions,
5542 bool InOverloadResolution,
5543 bool AllowObjCWritebackConversion,
5544 bool AllowExplicit =
false);
5548static ImplicitConversionSequence
5550 bool SuppressUserConversions,
5551 bool InOverloadResolution,
5552 bool AllowObjCWritebackConversion) {
5565 if (
const auto *IAT = dyn_cast<IncompleteArrayType>(AT))
5567 InitTy = IAT->getElementType();
5593 if (From->
getNumInits() == 1 && !IsDesignatedInit) {
5599 SuppressUserConversions,
5600 InOverloadResolution,
5601 AllowObjCWritebackConversion);
5609 Result.setStandard();
5610 Result.Standard.setAsIdentityConversion();
5611 Result.Standard.setFromType(ToType);
5612 Result.Standard.setAllToTypes(ToType);
5637 bool IsUnbounded =
false;
5641 if (CT->getSize().ult(e)) {
5645 Result.setInitializerListContainerType(ContTy, IsUnbounded);
5648 if (CT->getSize().ugt(e)) {
5654 S, &EmptyList, InitTy, SuppressUserConversions,
5655 InOverloadResolution, AllowObjCWritebackConversion);
5656 if (DfltElt.
isBad()) {
5660 Result.setInitializerListContainerType(ContTy, IsUnbounded);
5671 Result.setInitializerListContainerType(ContTy, IsUnbounded);
5680 Result.setStandard();
5681 Result.Standard.setAsIdentityConversion();
5682 Result.Standard.setFromType(InitTy);
5683 Result.Standard.setAllToTypes(InitTy);
5684 for (
unsigned i = 0; i < e; ++i) {
5687 S,
Init, InitTy, SuppressUserConversions, InOverloadResolution,
5688 AllowObjCWritebackConversion);
5698 if (Result.isBad()) {
5699 Result.setInitializerListContainerType(ContTy, IsUnbounded);
5709 S, From->
getEndLoc(), DfltElt, Result) ==
5727 AllowedExplicit::None,
5728 InOverloadResolution,
false,
5729 AllowObjCWritebackConversion,
5747 Result.setUserDefined();
5748 Result.UserDefined.Before.setAsIdentityConversion();
5750 Result.UserDefined.Before.setFromType(
QualType());
5751 Result.UserDefined.Before.setAllToTypes(
QualType());
5753 Result.UserDefined.After.setAsIdentityConversion();
5754 Result.UserDefined.After.setFromType(ToType);
5755 Result.UserDefined.After.setAllToTypes(ToType);
5756 Result.UserDefined.ConversionFunction =
nullptr;
5773 if (From->
getNumInits() == 1 && !IsDesignatedInit) {
5794 SuppressUserConversions,
5802 InOverloadResolution,
5803 AllowObjCWritebackConversion);
5804 if (Result.isFailure())
5806 assert(!Result.isEllipsis() &&
5807 "Sub-initialization cannot result in ellipsis conversion.");
5813 Result.UserDefined.After;
5841 S, From->
getInit(0), ToType, SuppressUserConversions,
5842 InOverloadResolution, AllowObjCWritebackConversion);
5843 if (Result.isStandard())
5844 Result.Standard.FromBracedInitList =
true;
5848 else if (NumInits == 0) {
5849 Result.setStandard();
5850 Result.Standard.setAsIdentityConversion();
5851 Result.Standard.setFromType(ToType);
5852 Result.Standard.setAllToTypes(ToType);
5869static ImplicitConversionSequence
5871 bool SuppressUserConversions,
5872 bool InOverloadResolution,
5873 bool AllowObjCWritebackConversion,
5874 bool AllowExplicit) {
5875 if (
InitListExpr *FromInitList = dyn_cast<InitListExpr>(From))
5877 InOverloadResolution,AllowObjCWritebackConversion);
5882 SuppressUserConversions, AllowExplicit);
5885 SuppressUserConversions,
5886 AllowedExplicit::None,
5887 InOverloadResolution,
5889 AllowObjCWritebackConversion,
5902 return !ICS.
isBad();
5911 const CXXRecordDecl *ActingContext,
bool InOverloadResolution =
false,
5913 bool SuppressUserConversion =
false) {
5921 assert(FromClassification.
isLValue());
5932 if (Method->isExplicitObjectMemberFunction()) {
5933 if (ExplicitParameterType.isNull())
5934 ExplicitParameterType = Method->getFunctionObjectParameterReferenceType();
5936 ValueKindFromClassification(FromClassification));
5938 S, &TmpExpr, ExplicitParameterType, SuppressUserConversion,
5955 Qualifiers Quals = Method->getMethodQualifiers();
5993 FromType, ImplicitParamType);
6003 FromType, ImplicitParamType);
6016 }
else if (!Method->isExplicitObjectMemberFunction()) {
6018 FromType, ImplicitParamType);
6023 switch (Method->getRefQualifier()) {
6038 if (!FromClassification.
isRValue()) {
6060 = (Method->getRefQualifier() ==
RQ_None);
6071 QualType ImplicitParamRecordType =
Method->getFunctionObjectParameterType();
6076 DestType =
Method->getThisType();
6079 FromRecordType = From->
getType();
6080 DestType = ImplicitParamRecordType;
6088 Method->getRefQualifier() !=
6106 <<
Method->getDeclName() << FromRecordType << (CVR - 1)
6108 Diag(
Method->getLocation(), diag::note_previous_decl)
6109 <<
Method->getDeclName();
6117 bool IsRValueQualified =
6121 << IsRValueQualified;
6122 Diag(
Method->getLocation(), diag::note_previous_decl)
6123 <<
Method->getDeclName();
6133 llvm_unreachable(
"Lists are not objects");
6136 return Diag(From->
getBeginLoc(), diag::err_member_function_call_bad_type)
6137 << ImplicitParamRecordType << FromRecordType
6146 From = FromRes.
get();
6155 CK = CK_AddressSpaceConversion;
6180 AllowedExplicit::Conversions,
6261 llvm_unreachable(
"found a first conversion kind in Second");
6265 llvm_unreachable(
"found a third conversion kind in Second");
6271 llvm_unreachable(
"unknown conversion kind");
6281 [[maybe_unused]]
bool isCCEAllowedPreCXX11 =
6283 assert((S.
getLangOpts().CPlusPlus11 || isCCEAllowedPreCXX11) &&
6284 "converted constant expression outside C++11 or TTP matching");
6308 if (
T->isRecordType())
6317 diag::err_typecheck_converted_constant_expression)
6323 llvm_unreachable(
"bad conversion in converted constant expression");
6329 diag::err_typecheck_converted_constant_expression_disallowed)
6335 diag::err_typecheck_converted_constant_expression_indirect)
6345 diag::err_reference_bind_to_bitfield_in_cce)
6353 bool IsTemplateArgument =
6355 if (
T->isRecordType()) {
6356 assert(IsTemplateArgument &&
6357 "unexpected class type converted constant expr");
6366 if (Result.isInvalid())
6373 IsTemplateArgument);
6374 if (Result.isInvalid())
6378 bool ReturnPreNarrowingValue =
false;
6381 PreNarrowingType)) {
6391 PreNarrowingValue.
isInt()) {
6394 ReturnPreNarrowingValue =
true;
6414 << CCE << 0 << From->
getType() <<
T;
6417 if (!ReturnPreNarrowingValue)
6418 PreNarrowingValue = {};
6434 if (Result.isInvalid() || Result.get()->isValueDependent()) {
6439 RequireInt, PreNarrowingValue);
6446 return ::BuildConvertedConstantExpression(*
this, From,
T, CCE, Dest,
6453 return ::CheckConvertedConstantExpression(*
this, From,
T,
Value, CCE,
false,
6458 llvm::APSInt &
Value,
6460 assert(
T->isIntegralOrEnumerationType() &&
"unexpected converted const type");
6465 if (!R.isInvalid() && !R.get()->isValueDependent())
6473 const APValue &PreNarrowingValue) {
6485 Kind = ConstantExprKind::ClassTemplateArgument;
6487 Kind = ConstantExprKind::NonClassTemplateArgument;
6489 Kind = ConstantExprKind::Normal;
6492 (RequireInt && !Eval.
Val.
isInt())) {
6499 if (Notes.empty()) {
6502 if (
const auto *CE = dyn_cast<ConstantExpr>(E)) {
6506 "ConstantExpr has no value associated with it");
6512 Value = std::move(PreNarrowingValue);
6518 if (Notes.size() == 1 &&
6519 Notes[0].second.getDiagID() == diag::note_invalid_subexpr_in_const_expr) {
6520 Diag(Notes[0].first, diag::err_expr_not_cce) << CCE;
6521 }
else if (!Notes.empty() && Notes[0].second.getDiagID() ==
6522 diag::note_constexpr_invalid_template_arg) {
6523 Notes[0].second.setDiagID(diag::err_constexpr_invalid_template_arg);
6524 for (
unsigned I = 0; I < Notes.size(); ++I)
6525 Diag(Notes[I].first, Notes[I].second);
6529 for (
unsigned I = 0; I < Notes.size(); ++I)
6530 Diag(Notes[I].first, Notes[I].second);
6549static ImplicitConversionSequence
6557 AllowedExplicit::Conversions,
6599 "expected a member expression");
6601 if (
const auto M = dyn_cast<UnresolvedMemberExpr>(MemExprE);
6602 M && !M->isImplicitAccess())
6603 Base = M->getBase();
6604 else if (
const auto M = dyn_cast<MemberExpr>(MemExprE);
6605 M && !M->isImplicitAccess())
6606 Base = M->getBase();
6610 if (
T->isPointerType())
6611 T =
T->getPointeeType();
6639 assert(Method->isExplicitObjectMemberFunction() &&
6640 "Method is not an explicit member function");
6641 assert(NewArgs.empty() &&
"NewArgs should be empty");
6643 NewArgs.reserve(Args.size() + 1);
6645 NewArgs.push_back(
This);
6646 NewArgs.append(Args.begin(), Args.end());
6649 Method, Object->getBeginLoc());
6655 return AllowScopedEnumerations ?
T->isIntegralOrEnumerationType()
6656 :
T->isIntegralOrUnscopedEnumerationType();
6668 for (
unsigned I = 0, N = ViableConversions.
size(); I != N; ++I) {
6682 if (ExplicitConversions.
size() == 1 && !Converter.
Suppress) {
6690 std::string TypeStr;
6695 "static_cast<" + TypeStr +
">(")
6707 HadMultipleCandidates);
6708 if (Result.isInvalid())
6714 From, Result.get()->
getType());
6715 if (Result.isInvalid())
6717 From = Result.get();
6740 HadMultipleCandidates);
6741 if (Result.isInvalid())
6745 CK_UserDefinedConversion, Result.get(),
6746 nullptr, Result.get()->getValueKind(),
6771 if (
auto *ConvTemplate = dyn_cast<FunctionTemplateDecl>(D)) {
6773 ConvTemplate, FoundDecl, ActingContext, From, ToType, CandidateSet,
6779 Conv, FoundDecl, ActingContext, From, ToType, CandidateSet,
6813 From = result.
get();
6827 const RecordType *RecordTy =
T->getAsCanonical<RecordType>();
6840 : Converter(Converter), From(From) {}
6845 } IncompleteDiagnoser(Converter, From);
6856 ->getDefinitionOrSelf()
6857 ->getVisibleConversionFunctions();
6859 bool HadMultipleCandidates =
6864 bool HasUniqueTargetType =
true;
6880 "Conversion operator templates are considered potentially "
6884 if (Converter.
match(CurToType) || ConvTemplate) {
6890 ExplicitConversions.
addDecl(I.getDecl(), I.getAccess());
6895 else if (HasUniqueTargetType &&
6897 HasUniqueTargetType =
false;
6899 ViableConversions.
addDecl(I.getDecl(), I.getAccess());
6917 HadMultipleCandidates,
6918 ExplicitConversions))
6924 if (!HasUniqueTargetType)
6943 HadMultipleCandidates,
Found))
6952 HadMultipleCandidates,
6953 ExplicitConversions))
6961 switch (ViableConversions.
size()) {
6964 HadMultipleCandidates,
6965 ExplicitConversions))
6975 HadMultipleCandidates,
Found))
7006 if (Proto->getNumParams() < 1)
7010 QualType ArgType = Proto->getParamType(0).getNonReferenceType();
7011 if (Context.hasSameUnqualifiedType(T1, ArgType))
7015 if (Proto->getNumParams() < 2)
7019 QualType ArgType = Proto->getParamType(1).getNonReferenceType();
7020 if (Context.hasSameUnqualifiedType(T2, ArgType))
7039 unsigned SeenAt = 0;
7041 bool HasDefault =
false;
7050 return HasDefault || SeenAt != 0;
7056 bool PartialOverloading,
bool AllowExplicit,
bool AllowExplicitConversions,
7059 bool StrictPackMatch) {
7062 assert(Proto &&
"Functions without a prototype cannot be overloaded");
7063 assert(!
Function->getDescribedFunctionTemplate() &&
7064 "Use AddTemplateOverloadCandidate for function templates");
7077 CandidateSet, SuppressUserConversions,
7078 PartialOverloading, EarlyConversions, PO,
7114 CandidateSet.
addCandidate(Args.size(), EarlyConversions);
7128 Candidate.
Viable =
false;
7141 bool IsImplicitlyInstantiated =
false;
7142 if (
auto *SpecInfo =
Function->getTemplateSpecializationInfo()) {
7143 ND = SpecInfo->getTemplate();
7144 IsImplicitlyInstantiated = SpecInfo->getTemplateSpecializationKind() ==
7155 const bool IsInlineFunctionInGMF =
7157 (IsImplicitlyInstantiated ||
Function->isInlined());
7160 Candidate.
Viable =
false;
7167 Candidate.
Viable =
false;
7178 if (Args.size() == 1 &&
Constructor->isSpecializationCopyingObject() &&
7179 (
Context.hasSameUnqualifiedType(ClassType, Args[0]->getType()) ||
7182 Candidate.
Viable =
false;
7194 auto *Shadow = dyn_cast<ConstructorUsingShadowDecl>(FoundDecl.
getDecl());
7195 if (Shadow && Args.size() == 1 &&
Constructor->getNumParams() >= 1 &&
7196 Constructor->getParamDecl(0)->getType()->isReferenceType()) {
7203 Candidate.
Viable =
false;
7212 Constructor->getMethodQualifiers().getAddressSpace(),
7214 Candidate.
Viable =
false;
7227 Candidate.
Viable =
false;
7237 unsigned MinRequiredArgs =
Function->getMinRequiredArguments();
7238 if (!AggregateCandidateDeduction && Args.size() < MinRequiredArgs &&
7239 !PartialOverloading) {
7241 Candidate.
Viable =
false;
7255 Candidate.
Viable =
false;
7261 if (
Function->getTrailingRequiresClause()) {
7266 Candidate.
Viable =
false;
7275 for (
unsigned ArgIdx = 0; ArgIdx < Args.size(); ++ArgIdx) {
7278 if (Candidate.
Conversions[ConvIdx].isInitialized()) {
7281 }
else if (ArgIdx < NumParams) {
7292 *
this, Args[ArgIdx], ParamType, SuppressUserConversions,
7295 getLangOpts().ObjCAutoRefCount, AllowExplicitConversions);
7297 Candidate.
Viable =
false;
7309 if (EnableIfAttr *FailedAttr =
7311 Candidate.
Viable =
false;
7321 if (Methods.size() <= 1)
7324 for (
unsigned b = 0, e = Methods.size();
b < e;
b++) {
7330 if (
Method->param_size() > NumNamedArgs)
7331 NumNamedArgs =
Method->param_size();
7332 if (Args.size() < NumNamedArgs)
7335 for (
unsigned i = 0; i < NumNamedArgs; i++) {
7337 if (Args[i]->isTypeDependent()) {
7343 Expr *argExpr = Args[i];
7344 assert(argExpr &&
"SelectBestMethod(): missing expression");
7349 !param->
hasAttr<CFConsumedAttr>())
7350 argExpr =
ObjC().stripARCUnbridgedCast(argExpr);
7367 if (ConversionState.
isBad() ||
7377 for (
unsigned i = NumNamedArgs, e = Args.size(); i < e; ++i) {
7378 if (Args[i]->isTypeDependent()) {
7391 if (Args.size() != NumNamedArgs)
7393 else if (
Match && NumNamedArgs == 0 && Methods.size() > 1) {
7396 for (
unsigned b = 0, e = Methods.size();
b < e;
b++) {
7397 QualType ReturnT = Methods[
b]->getReturnType();
7417 "Shouldn't have `this` for ctors!");
7418 assert(!Method->isStatic() &&
"Shouldn't have `this` for static methods!");
7420 ThisArg, std::nullopt, Method, Method);
7423 ConvertedThis = R.
get();
7425 if (
auto *MD = dyn_cast<CXXMethodDecl>(Function)) {
7427 assert((MissingImplicitThis || MD->isStatic() ||
7429 "Expected `this` for non-ctor instance methods");
7431 ConvertedThis =
nullptr;
7436 unsigned ArgSizeNoVarargs = std::min(Function->param_size(), Args.size());
7439 for (
unsigned I = 0; I != ArgSizeNoVarargs; ++I) {
7442 S.
Context, Function->getParamDecl(I)),
7448 ConvertedArgs.push_back(R.
get());
7455 if (!Function->isVariadic() && Args.size() < Function->getNumParams()) {
7456 for (
unsigned i = Args.size(), e = Function->getNumParams(); i != e; ++i) {
7463 ConvertedArgs.push_back(R.
get());
7475 bool MissingImplicitThis) {
7476 auto EnableIfAttrs =
Function->specific_attrs<EnableIfAttr>();
7477 if (EnableIfAttrs.begin() == EnableIfAttrs.end())
7483 Expr *DiscardedThis;
7485 *
this,
Function,
nullptr, CallLoc, Args, Trap,
7486 true, DiscardedThis, ConvertedArgs))
7487 return *EnableIfAttrs.begin();
7489 for (
auto *EIA : EnableIfAttrs) {
7493 if (EIA->getCond()->isValueDependent() ||
7494 !EIA->getCond()->EvaluateWithSubstitution(
7498 if (!
Result.isInt() || !
Result.getInt().getBoolValue())
7504template <
typename CheckFn>
7507 CheckFn &&IsSuccessful) {
7510 if (ArgDependent == DIA->getArgDependent())
7511 Attrs.push_back(DIA);
7518 auto WarningBegin = std::stable_partition(
7519 Attrs.begin(), Attrs.end(), [](
const DiagnoseIfAttr *DIA) {
7520 return DIA->getDefaultSeverity() == DiagnoseIfAttr::DS_error &&
7521 DIA->getWarningGroup().empty();
7526 auto ErrAttr = llvm::find_if(llvm::make_range(Attrs.begin(), WarningBegin),
7528 if (ErrAttr != WarningBegin) {
7529 const DiagnoseIfAttr *DIA = *ErrAttr;
7530 S.
Diag(Loc, diag::err_diagnose_if_succeeded) << DIA->getMessage();
7531 S.
Diag(DIA->getLocation(), diag::note_from_diagnose_if)
7532 << DIA->getParent() << DIA->getCond()->getSourceRange();
7536 auto ToSeverity = [](DiagnoseIfAttr::DefaultSeverity Sev) {
7538 case DiagnoseIfAttr::DS_warning:
7540 case DiagnoseIfAttr::DS_error:
7543 llvm_unreachable(
"Fully covered switch above!");
7546 for (
const auto *DIA : llvm::make_range(WarningBegin, Attrs.end()))
7547 if (IsSuccessful(DIA)) {
7548 if (DIA->getWarningGroup().empty() &&
7549 DIA->getDefaultSeverity() == DiagnoseIfAttr::DS_warning) {
7550 S.
Diag(Loc, diag::warn_diagnose_if_succeeded) << DIA->getMessage();
7551 S.
Diag(DIA->getLocation(), diag::note_from_diagnose_if)
7552 << DIA->getParent() << DIA->getCond()->getSourceRange();
7555 DIA->getWarningGroup());
7558 {ToSeverity(DIA->getDefaultSeverity()),
"%0",
7560 S.
Diag(Loc, DiagID) << DIA->getMessage();
7568 const Expr *ThisArg,
7573 [&](
const DiagnoseIfAttr *DIA) {
7578 if (!DIA->getCond()->EvaluateWithSubstitution(
7581 return Result.isInt() &&
Result.getInt().getBoolValue();
7588 *
this, ND,
false, Loc,
7589 [&](
const DiagnoseIfAttr *DIA) {
7591 return DIA->getCond()->EvaluateAsBooleanCondition(
Result,
Context) &&
7600 bool SuppressUserConversions,
7601 bool PartialOverloading,
7602 bool FirstArgumentIsBase) {
7614 if (Args.size() > 0) {
7615 if (
Expr *E = Args[0]) {
7625 FunctionArgs = Args.slice(1);
7629 FunTmpl, F.getPair(),
7631 ExplicitTemplateArgs, ObjectType, ObjectClassification,
7632 FunctionArgs, CandidateSet, SuppressUserConversions,
7633 PartialOverloading);
7637 ObjectClassification, FunctionArgs, CandidateSet,
7638 SuppressUserConversions, PartialOverloading);
7645 if (Args.size() > 0 &&
7649 FunctionArgs = Args.slice(1);
7653 ExplicitTemplateArgs, FunctionArgs,
7654 CandidateSet, SuppressUserConversions,
7655 PartialOverloading);
7658 SuppressUserConversions, PartialOverloading);
7668 bool SuppressUserConversions,
7678 "Expected a member function template");
7680 nullptr, ObjectType,
7681 ObjectClassification, Args, CandidateSet,
7682 SuppressUserConversions,
false, PO);
7685 ObjectType, ObjectClassification, Args, CandidateSet,
7686 SuppressUserConversions,
false, {}, PO);
7699 assert(Proto &&
"Methods without a prototype cannot be overloaded");
7701 "Use AddOverloadCandidate for constructors");
7710 Method->isMoveAssignmentOperator())
7717 bool IgnoreExplicitObject =
7718 (
Method->isExplicitObjectMemberFunction() &&
7721 bool ImplicitObjectMethodTreatedAsStatic =
7724 Method->isImplicitObjectMemberFunction();
7726 unsigned ExplicitOffset =
7727 !IgnoreExplicitObject &&
Method->isExplicitObjectMemberFunction() ? 1 : 0;
7729 unsigned NumParams =
Method->getNumParams() - ExplicitOffset +
7730 int(ImplicitObjectMethodTreatedAsStatic);
7732 unsigned ExtraArgs =
7739 CandidateSet.
addCandidate(Args.size() + ExtraArgs, EarlyConversions);
7755 Candidate.
Viable =
false;
7765 unsigned MinRequiredArgs =
Method->getMinRequiredArguments() -
7767 int(ImplicitObjectMethodTreatedAsStatic);
7769 if (Args.size() < MinRequiredArgs && !PartialOverloading) {
7771 Candidate.
Viable =
false;
7779 if (!IgnoreExplicitObject) {
7782 else if (
Method->isStatic()) {
7792 Candidate.
Conversions[FirstConvIdx].setStaticObjectArgument();
7797 *
this, CandidateSet.
getLocation(), ObjectType, ObjectClassification,
7798 Method, ActingContext,
true);
7799 if (Candidate.
Conversions[FirstConvIdx].isBad()) {
7800 Candidate.
Viable =
false;
7811 Candidate.
Viable =
false;
7816 if (
Method->getTrailingRequiresClause()) {
7821 Candidate.
Viable =
false;
7829 for (
unsigned ArgIdx = 0; ArgIdx < Args.size(); ++ArgIdx) {
7832 if (Candidate.
Conversions[ConvIdx].isInitialized()) {
7835 }
else if (ArgIdx < NumParams) {
7841 if (ImplicitObjectMethodTreatedAsStatic) {
7842 ParamType = ArgIdx == 0
7843 ?
Method->getFunctionObjectParameterReferenceType()
7846 ParamType = Proto->
getParamType(ArgIdx + ExplicitOffset);
7850 SuppressUserConversions,
7855 Candidate.
Viable =
false;
7867 if (EnableIfAttr *FailedAttr =
7869 Candidate.
Viable =
false;
7876 Candidate.
Viable =
false;
7887 bool SuppressUserConversions,
bool PartialOverloading,
7905 PartialOverloading,
false,
7906 false, ObjectType, ObjectClassification,
7910 bool OnlyInitializeNonUserDefinedConversions) {
7911 return S.CheckNonDependentConversions(
7912 MethodTmpl, ParamTypes, Args, CandidateSet, Conversions,
7913 Sema::CheckNonDependentConversionsFlag(
7914 SuppressUserConversions,
7915 OnlyInitializeNonUserDefinedConversions),
7916 ActingContext, ObjectType, ObjectClassification, PO);
7920 CandidateSet.
addCandidate(Conversions.size(), Conversions);
7923 Candidate.
Viable =
false;
7932 Method->isStatic() ||
7933 (!Method->isExplicitObjectMemberFunction() && ObjectType.
isNull());
7947 assert(
Specialization &&
"Missing member function template specialization?");
7949 "Specialization is not a member function?");
7952 ObjectClassification, Args, CandidateSet, SuppressUserConversions,
7966 if (ExplicitTemplateArgs ||
7969 *
this, CandidateSet, MethodTmpl, FoundDecl, ActingContext,
7970 ExplicitTemplateArgs, ObjectType, ObjectClassification, Args,
7971 SuppressUserConversions, PartialOverloading, PO);
7976 MethodTmpl, FoundDecl, ActingContext, ObjectType, ObjectClassification,
7977 Args, SuppressUserConversions, PartialOverloading, PO);
7995 bool SuppressUserConversions,
bool PartialOverloading,
bool AllowExplicit,
7997 bool AggregateCandidateDeduction) {
8006 Candidate.
Viable =
false;
8026 PartialOverloading, AggregateCandidateDeduction,
8033 bool OnlyInitializeNonUserDefinedConversions) {
8034 return S.CheckNonDependentConversions(
8035 FunctionTemplate, ParamTypes, Args, CandidateSet, Conversions,
8036 Sema::CheckNonDependentConversionsFlag(
8037 SuppressUserConversions,
8038 OnlyInitializeNonUserDefinedConversions),
8039 nullptr, QualType(), {}, PO);
8042 OverloadCandidate &Candidate =
8043 CandidateSet.addCandidate(Conversions.size(), Conversions);
8046 Candidate.
Viable =
false;
8048 CandidateSet.getRewriteInfo().getRewriteKind(Candidate.
Function, PO);
8054 CandidateSet.getKind() ==
8060 ->isExplicitObjectMemberFunction() &&
8076 assert(
Specialization &&
"Missing function template specialization?");
8078 Specialization, FoundDecl, Args, CandidateSet, SuppressUserConversions,
8079 PartialOverloading, AllowExplicit,
8080 false, IsADLCandidate, Conversions, PO,
8081 Info.AggregateDeductionCandidateHasMismatchedArity,
8082 Info.hasStrictPackMatch());
8089 bool PartialOverloading,
bool AllowExplicit,
ADLCallKind IsADLCandidate,
8096 if (ExplicitTemplateArgs ||
8099 DependentExplicitSpecifier)) {
8103 Args, SuppressUserConversions, PartialOverloading, AllowExplicit,
8104 IsADLCandidate, PO, AggregateCandidateDeduction);
8106 if (DependentExplicitSpecifier)
8113 PartialOverloading, AllowExplicit, IsADLCandidate, PO,
8114 AggregateCandidateDeduction);
8127 const bool AllowExplicit =
false;
8129 bool ForOverloadSetAddressResolution =
8132 auto *
Method = dyn_cast<CXXMethodDecl>(FD);
8133 bool HasThisConversion = !ForOverloadSetAddressResolution &&
Method &&
8135 unsigned ThisConversions = HasThisConversion ? 1 : 0;
8151 if (!FD->hasCXXExplicitFunctionObjectParameter() ||
8152 !ParamTypes[0]->isDependentType()) {
8154 *
this, CandidateSet.
getLocation(), ObjectType, ObjectClassification,
8155 Method, ActingContext,
true,
8156 FD->hasCXXExplicitFunctionObjectParameter() ? ParamTypes[0]
8166 auto MaybeInvolveUserDefinedConversion = [&](
QualType ParamType,
8190 if (
auto *RD =
ArgType->getAsCXXRecordDecl();
8191 RD && RD->hasDefinition() &&
8192 !RD->getVisibleConversionFunctions().empty())
8199 HasThisConversion &&
Method->hasCXXExplicitFunctionObjectParameter() ? 1
8202 for (
unsigned I = 0, N = std::min(ParamTypes.size() - Offset, Args.size());
8204 QualType ParamType = ParamTypes[I + Offset];
8208 ConvIdx = Args.size() - 1 - I;
8209 assert(Args.size() + ThisConversions == 2 &&
8210 "number of args (including 'this') must be exactly 2 for "
8214 assert(!HasThisConversion || (ConvIdx == 0 && I == 0));
8217 ConvIdx = ThisConversions + I;
8222 MaybeInvolveUserDefinedConversion(ParamType, Args[I]->
getType()))
8251 bool AllowObjCPointerConversion) {
8259 bool ObjCLifetimeConversion;
8261 ObjCLifetimeConversion))
8266 if (!AllowObjCPointerConversion)
8270 bool IncompatibleObjC =
false;
8280 bool AllowExplicit,
bool AllowResultConversion,
bool StrictPackMatch) {
8282 "Conversion function templates use AddTemplateConversionCandidate");
8297 if (!AllowResultConversion &&
8309 AllowObjCConversionOnExplicit))
8331 if (!AllowExplicit && Conversion->
isExplicit()) {
8332 Candidate.
Viable =
false;
8359 Candidate.
Viable =
false;
8368 Candidate.
Viable =
false;
8379 QualType ToCanon =
Context.getCanonicalType(ToType).getUnqualifiedType();
8380 if (FromCanon == ToCanon ||
8382 Candidate.
Viable =
false;
8399 CK_FunctionToPointerDecay, &ConversionRef,
8404 Candidate.
Viable =
false;
8434 Candidate.
Viable =
false;
8446 Candidate.
Viable =
false;
8453 Candidate.
Viable =
false;
8459 "Can only end up with a standard conversion sequence or failure");
8462 if (EnableIfAttr *FailedAttr =
8464 Candidate.
Viable =
false;
8471 Candidate.
Viable =
false;
8480 bool AllowObjCConversionOnExplicit,
bool AllowExplicit,
8481 bool AllowResultConversion) {
8490 Candidate.
Viable =
false;
8507 Candidate.
Viable =
false;
8517 assert(
Specialization &&
"Missing function template specialization?");
8519 ToType, CandidateSet, AllowObjCConversionOnExplicit,
8520 AllowExplicit, AllowResultConversion,
8528 bool AllowExplicit,
bool AllowResultConversion) {
8530 "Only conversion function templates permitted here");
8541 ToType, AllowObjCConversionOnExplicit, AllowExplicit,
8542 AllowResultConversion);
8550 AllowObjCConversionOnExplicit, AllowExplicit, AllowResultConversion);
8585 *
this, CandidateSet.
getLocation(), Object->getType(),
8586 Object->Classify(
Context), Conversion, ActingContext);
8589 if (ObjectInit.
isBad()) {
8590 Candidate.
Viable =
false;
8601 Candidate.
Conversions[0].UserDefined.EllipsisConversion =
false;
8602 Candidate.
Conversions[0].UserDefined.HadMultipleCandidates =
false;
8603 Candidate.
Conversions[0].UserDefined.ConversionFunction = Conversion;
8604 Candidate.
Conversions[0].UserDefined.FoundConversionFunction = FoundDecl;
8607 Candidate.
Conversions[0].UserDefined.After.setAsIdentityConversion();
8615 if (Args.size() > NumParams && !Proto->
isVariadic()) {
8616 Candidate.
Viable =
false;
8623 if (Args.size() < NumParams) {
8625 Candidate.
Viable =
false;
8632 for (
unsigned ArgIdx = 0, N = Args.size(); ArgIdx != N; ++ArgIdx) {
8633 if (ArgIdx < NumParams) {
8646 Candidate.
Viable =
false;
8663 Candidate.
Viable =
false;
8669 if (EnableIfAttr *FailedAttr =
8671 Candidate.
Viable =
false;
8695 "unqualified operator lookup found a member function");
8699 FunctionArgs, CandidateSet);
8705 FunctionArgs[1], FunctionArgs[0]);
8707 Reversed, CandidateSet,
false,
false,
true,
8708 ADLCallKind::NotADL,
8712 if (ExplicitTemplateArgs)
8717 {FunctionArgs[1], FunctionArgs[0]}, CandidateSet,
8718 false,
false,
true,
false, ADLCallKind::NotADL, {},
8750 if (!T1RD || (!IsComplete && !T1RD->isBeingDefined()))
8758 OperEnd = Operators.
end();
8759 Oper != OperEnd; ++Oper) {
8760 if (Oper->getAsFunction() &&
8763 *
this, {Args[1], Args[0]}, Oper->getAsFunction()))
8766 Args[0]->Classify(
Context), Args.slice(1),
8767 CandidateSet,
false, PO);
8774 bool IsAssignmentOperator,
8775 unsigned NumContextualBoolArguments) {
8790 for (
unsigned ArgIdx = 0, N = Args.size(); ArgIdx != N; ++ArgIdx) {
8803 if (ArgIdx < NumContextualBoolArguments) {
8804 assert(ParamTys[ArgIdx] ==
Context.BoolTy &&
8805 "Contextual conversion to bool requires bool type");
8811 ArgIdx == 0 && IsAssignmentOperator,
8817 Candidate.
Viable =
false;
8830class BuiltinCandidateTypeSet {
8836 TypeSet PointerTypes;
8840 TypeSet MemberPointerTypes;
8844 TypeSet EnumerationTypes;
8848 TypeSet VectorTypes;
8852 TypeSet MatrixTypes;
8855 TypeSet BitIntTypes;
8858 bool HasNonRecordTypes;
8862 bool HasArithmeticOrEnumeralTypes;
8866 bool HasNullPtrType;
8875 bool AddPointerWithMoreQualifiedTypeVariants(
QualType Ty,
8877 bool AddMemberPointerWithMoreQualifiedTypeVariants(
QualType Ty);
8881 typedef TypeSet::iterator
iterator;
8883 BuiltinCandidateTypeSet(
Sema &SemaRef)
8884 : HasNonRecordTypes(
false),
8885 HasArithmeticOrEnumeralTypes(
false),
8886 HasNullPtrType(
false),
8888 Context(SemaRef.Context) { }
8890 void AddTypesConvertedFrom(
QualType Ty,
8892 bool AllowUserConversions,
8893 bool AllowExplicitConversions,
8894 const Qualifiers &VisibleTypeConversionsQuals);
8896 llvm::iterator_range<iterator> pointer_types() {
return PointerTypes; }
8897 llvm::iterator_range<iterator> member_pointer_types() {
8898 return MemberPointerTypes;
8900 llvm::iterator_range<iterator> enumeration_types() {
8901 return EnumerationTypes;
8903 llvm::iterator_range<iterator> vector_types() {
return VectorTypes; }
8904 llvm::iterator_range<iterator> matrix_types() {
return MatrixTypes; }
8905 llvm::iterator_range<iterator> bitint_types() {
return BitIntTypes; }
8907 bool containsMatrixType(QualType Ty)
const {
return MatrixTypes.count(Ty); }
8908 bool hasNonRecordTypes() {
return HasNonRecordTypes; }
8909 bool hasArithmeticOrEnumeralTypes() {
return HasArithmeticOrEnumeralTypes; }
8910 bool hasNullPtrType()
const {
return HasNullPtrType; }
8925BuiltinCandidateTypeSet::AddPointerWithMoreQualifiedTypeVariants(QualType Ty,
8926 const Qualifiers &VisibleQuals) {
8929 if (!PointerTypes.insert(Ty))
8933 const PointerType *PointerTy = Ty->
getAs<PointerType>();
8934 bool buildObjCPtr =
false;
8936 const ObjCObjectPointerType *PTy = Ty->
castAs<ObjCObjectPointerType>();
8938 buildObjCPtr =
true;
8950 unsigned BaseCVR = PointeeTy.getCVRQualifiers();
8956 if ((CVR | BaseCVR) != CVR)
continue;
8971 QualType QPointerTy;
8978 PointerTypes.insert(QPointerTy);
8994BuiltinCandidateTypeSet::AddMemberPointerWithMoreQualifiedTypeVariants(
8997 if (!MemberPointerTypes.insert(Ty))
9000 const MemberPointerType *PointerTy = Ty->
getAs<MemberPointerType>();
9001 assert(PointerTy &&
"type was not a member pointer type!");
9016 if ((CVR | BaseCVR) != CVR)
continue;
9020 QPointeeTy, std::nullopt, Cls));
9035BuiltinCandidateTypeSet::AddTypesConvertedFrom(QualType Ty,
9037 bool AllowUserConversions,
9038 bool AllowExplicitConversions,
9039 const Qualifiers &VisibleQuals) {
9045 if (
const ReferenceType *RefTy = Ty->
getAs<ReferenceType>())
9050 Ty = SemaRef.Context.getArrayDecayedType(Ty);
9057 HasNonRecordTypes = HasNonRecordTypes || !TyIsRec;
9060 HasArithmeticOrEnumeralTypes =
9064 PointerTypes.insert(Ty);
9065 else if (Ty->
getAs<PointerType>() || Ty->
getAs<ObjCObjectPointerType>()) {
9068 if (!AddPointerWithMoreQualifiedTypeVariants(Ty, VisibleQuals))
9072 if (!AddMemberPointerWithMoreQualifiedTypeVariants(Ty))
9075 HasArithmeticOrEnumeralTypes =
true;
9076 EnumerationTypes.insert(Ty);
9078 HasArithmeticOrEnumeralTypes =
true;
9079 BitIntTypes.insert(Ty);
9083 HasArithmeticOrEnumeralTypes =
true;
9084 VectorTypes.insert(Ty);
9088 HasArithmeticOrEnumeralTypes =
true;
9089 MatrixTypes.insert(Ty);
9091 HasNullPtrType =
true;
9092 }
else if (AllowUserConversions && TyIsRec) {
9094 if (!SemaRef.isCompleteType(Loc, Ty))
9098 for (NamedDecl *D : ClassDecl->getVisibleConversionFunctions()) {
9108 if (AllowExplicitConversions || !Conv->
isExplicit()) {
9156 ClassDecl = RHSMPType->getMostRecentCXXRecordDecl();
9204 if (Available.hasAtomic()) {
9205 Available.removeAtomic();
9212 if (Available.hasVolatile()) {
9213 Available.removeVolatile();
9247class BuiltinOperatorOverloadBuilder {
9250 ArrayRef<Expr *> Args;
9251 QualifiersAndAtomic VisibleTypeConversionsQuals;
9252 bool HasArithmeticOrEnumeralCandidateType;
9253 SmallVectorImpl<BuiltinCandidateTypeSet> &CandidateTypes;
9254 OverloadCandidateSet &CandidateSet;
9256 static constexpr int ArithmeticTypesCap = 26;
9257 SmallVector<CanQualType, ArithmeticTypesCap> ArithmeticTypes;
9262 unsigned FirstIntegralType,
9264 unsigned FirstPromotedIntegralType,
9265 LastPromotedIntegralType;
9266 unsigned FirstPromotedArithmeticType,
9267 LastPromotedArithmeticType;
9268 unsigned NumArithmeticTypes;
9270 void InitArithmeticTypes() {
9272 FirstPromotedArithmeticType = 0;
9282 FirstIntegralType = ArithmeticTypes.size();
9283 FirstPromotedIntegralType = ArithmeticTypes.size();
9305 llvm::SmallSetVector<CanQualType, 2> BitIntCandidates;
9306 for (BuiltinCandidateTypeSet &Candidate : CandidateTypes) {
9307 for (QualType BitTy : Candidate.bitint_types())
9310 llvm::move(BitIntCandidates, std::back_inserter(ArithmeticTypes));
9311 LastPromotedIntegralType = ArithmeticTypes.size();
9312 LastPromotedArithmeticType = ArithmeticTypes.size();
9326 LastIntegralType = ArithmeticTypes.size();
9327 NumArithmeticTypes = ArithmeticTypes.size();
9334 assert(ArithmeticTypes.size() - BitIntCandidates.size() <=
9335 ArithmeticTypesCap &&
9336 "Enough inline storage for all arithmetic types.");
9341 void addPlusPlusMinusMinusStyleOverloads(QualType CandidateTy,
9344 QualType ParamTypes[2] = {
9384 void AddCandidate(QualType L, QualType R) {
9385 QualType LandR[2] = {L, R};
9390 BuiltinOperatorOverloadBuilder(
9391 Sema &S, ArrayRef<Expr *> Args,
9392 QualifiersAndAtomic VisibleTypeConversionsQuals,
9393 bool HasArithmeticOrEnumeralCandidateType,
9394 SmallVectorImpl<BuiltinCandidateTypeSet> &CandidateTypes,
9395 OverloadCandidateSet &CandidateSet)
9397 VisibleTypeConversionsQuals(VisibleTypeConversionsQuals),
9398 HasArithmeticOrEnumeralCandidateType(
9399 HasArithmeticOrEnumeralCandidateType),
9400 CandidateTypes(CandidateTypes),
9401 CandidateSet(CandidateSet) {
9403 InitArithmeticTypes();
9426 if (!HasArithmeticOrEnumeralCandidateType)
9429 for (
unsigned Arith = 0; Arith < NumArithmeticTypes; ++Arith) {
9430 const auto TypeOfT = ArithmeticTypes[Arith];
9432 if (Op == OO_MinusMinus)
9434 if (Op == OO_PlusPlus && S.
getLangOpts().CPlusPlus17)
9437 addPlusPlusMinusMinusStyleOverloads(
9454 void addPlusPlusMinusMinusPointerOverloads() {
9455 for (QualType PtrTy : CandidateTypes[0].pointer_types()) {
9457 if (!PtrTy->getPointeeType()->isObjectType())
9460 addPlusPlusMinusMinusStyleOverloads(
9462 (!PtrTy.isVolatileQualified() &&
9464 (!PtrTy.isRestrictQualified() &&
9479 void addUnaryStarPointerOverloads() {
9480 for (QualType ParamTy : CandidateTypes[0].pointer_types()) {
9485 if (
const FunctionProtoType *Proto =PointeeTy->
getAs<FunctionProtoType>())
9486 if (Proto->getMethodQuals() || Proto->getRefQualifier())
9499 void addUnaryPlusOrMinusArithmeticOverloads() {
9500 if (!HasArithmeticOrEnumeralCandidateType)
9503 for (
unsigned Arith = FirstPromotedArithmeticType;
9504 Arith < LastPromotedArithmeticType; ++Arith) {
9505 QualType ArithTy = ArithmeticTypes[Arith];
9510 for (QualType VecTy : CandidateTypes[0].vector_types())
9519 void addUnaryPlusPointerOverloads() {
9520 for (QualType ParamTy : CandidateTypes[0].pointer_types())
9529 void addUnaryTildePromotedIntegralOverloads() {
9530 if (!HasArithmeticOrEnumeralCandidateType)
9533 for (
unsigned Int = FirstPromotedIntegralType;
9534 Int < LastPromotedIntegralType; ++
Int) {
9535 QualType IntTy = ArithmeticTypes[
Int];
9540 for (QualType VecTy : CandidateTypes[0].vector_types())
9550 void addEqualEqualOrNotEqualMemberPointerOrNullptrOverloads() {
9552 llvm::SmallPtrSet<QualType, 8> AddedTypes;
9554 for (
unsigned ArgIdx = 0, N = Args.size(); ArgIdx != N; ++ArgIdx) {
9555 for (QualType MemPtrTy : CandidateTypes[ArgIdx].member_pointer_types()) {
9560 QualType ParamTypes[2] = {MemPtrTy, MemPtrTy};
9564 if (CandidateTypes[ArgIdx].hasNullPtrType()) {
9566 if (AddedTypes.insert(NullPtrTy).second) {
9567 QualType ParamTypes[2] = { NullPtrTy, NullPtrTy };
9586 void addGenericBinaryPointerOrEnumeralOverloads(
bool IsSpaceship) {
9599 llvm::DenseSet<std::pair<CanQualType, CanQualType> >
9600 UserDefinedBinaryOperators;
9602 for (
unsigned ArgIdx = 0, N = Args.size(); ArgIdx != N; ++ArgIdx) {
9603 if (!CandidateTypes[ArgIdx].enumeration_types().empty()) {
9605 CEnd = CandidateSet.
end();
9607 if (!
C->Viable || !
C->Function ||
C->Function->getNumParams() != 2)
9610 if (
C->Function->isFunctionTemplateSpecialization())
9617 QualType FirstParamType =
C->Function->getParamDecl(
Reversed ? 1 : 0)
9619 .getUnqualifiedType();
9620 QualType SecondParamType =
C->Function->getParamDecl(
Reversed ? 0 : 1)
9622 .getUnqualifiedType();
9630 UserDefinedBinaryOperators.insert(
9638 llvm::SmallPtrSet<QualType, 8> AddedTypes;
9640 for (
unsigned ArgIdx = 0, N = Args.size(); ArgIdx != N; ++ArgIdx) {
9641 for (QualType PtrTy : CandidateTypes[ArgIdx].pointer_types()) {
9645 if (IsSpaceship && PtrTy->isFunctionPointerType())
9648 QualType ParamTypes[2] = {PtrTy, PtrTy};
9651 for (QualType EnumTy : CandidateTypes[ArgIdx].enumeration_types()) {
9656 if (!AddedTypes.insert(CanonType).second ||
9657 UserDefinedBinaryOperators.count(std::make_pair(CanonType,
9660 QualType ParamTypes[2] = {EnumTy, EnumTy};
9685 llvm::SmallPtrSet<QualType, 8> AddedTypes;
9687 for (
int Arg = 0; Arg < 2; ++Arg) {
9688 QualType AsymmetricParamTypes[2] = {
9692 for (QualType PtrTy : CandidateTypes[Arg].pointer_types()) {
9697 AsymmetricParamTypes[Arg] = PtrTy;
9698 if (Arg == 0 || Op == OO_Plus) {
9703 if (Op == OO_Minus) {
9708 QualType ParamTypes[2] = {PtrTy, PtrTy};
9744 void addGenericBinaryArithmeticOverloads() {
9745 if (!HasArithmeticOrEnumeralCandidateType)
9748 for (
unsigned Left = FirstPromotedArithmeticType;
9749 Left < LastPromotedArithmeticType; ++
Left) {
9750 for (
unsigned Right = FirstPromotedArithmeticType;
9751 Right < LastPromotedArithmeticType; ++
Right) {
9752 QualType LandR[2] = { ArithmeticTypes[
Left],
9753 ArithmeticTypes[
Right] };
9760 for (QualType Vec1Ty : CandidateTypes[0].vector_types())
9761 for (QualType Vec2Ty : CandidateTypes[1].vector_types()) {
9762 QualType LandR[2] = {Vec1Ty, Vec2Ty};
9772 void addMatrixBinaryArithmeticOverloads() {
9773 if (!HasArithmeticOrEnumeralCandidateType)
9776 for (QualType M1 : CandidateTypes[0].matrix_types()) {
9778 AddCandidate(M1, M1);
9781 for (QualType M2 : CandidateTypes[1].matrix_types()) {
9783 if (!CandidateTypes[0].containsMatrixType(M2))
9784 AddCandidate(M2, M2);
9819 void addThreeWayArithmeticOverloads() {
9820 addGenericBinaryArithmeticOverloads();
9837 void addBinaryBitwiseArithmeticOverloads() {
9838 if (!HasArithmeticOrEnumeralCandidateType)
9841 for (
unsigned Left = FirstPromotedIntegralType;
9842 Left < LastPromotedIntegralType; ++
Left) {
9843 for (
unsigned Right = FirstPromotedIntegralType;
9845 QualType LandR[2] = { ArithmeticTypes[
Left],
9846 ArithmeticTypes[
Right] };
9859 void addAssignmentMemberPointerOrEnumeralOverloads() {
9861 llvm::SmallPtrSet<QualType, 8> AddedTypes;
9863 for (
unsigned ArgIdx = 0; ArgIdx < 2; ++ArgIdx) {
9864 for (QualType EnumTy : CandidateTypes[ArgIdx].enumeration_types()) {
9871 for (QualType MemPtrTy : CandidateTypes[ArgIdx].member_pointer_types()) {
9896 void addAssignmentPointerOverloads(
bool isEqualOp) {
9898 llvm::SmallPtrSet<QualType, 8> AddedTypes;
9900 for (QualType PtrTy : CandidateTypes[0].pointer_types()) {
9904 else if (!PtrTy->getPointeeType()->isObjectType())
9908 QualType ParamTypes[2] = {
9915 bool NeedVolatile = !PtrTy.isVolatileQualified() &&
9925 if (!PtrTy.isRestrictQualified() &&
9945 for (QualType PtrTy : CandidateTypes[1].pointer_types()) {
9950 QualType ParamTypes[2] = {
9959 bool NeedVolatile = !PtrTy.isVolatileQualified() &&
9969 if (!PtrTy.isRestrictQualified() &&
10002 void addAssignmentArithmeticOverloads(
bool isEqualOp) {
10003 if (!HasArithmeticOrEnumeralCandidateType)
10006 for (
unsigned Left = 0;
Left < NumArithmeticTypes; ++
Left) {
10007 for (
unsigned Right = FirstPromotedArithmeticType;
10008 Right < LastPromotedArithmeticType; ++
Right) {
10009 QualType ParamTypes[2];
10010 ParamTypes[1] = ArithmeticTypes[
Right];
10012 S, ArithmeticTypes[Left], Args[0]);
10015 VisibleTypeConversionsQuals, [&](QualifiersAndAtomic Quals) {
10025 for (QualType Vec1Ty : CandidateTypes[0].vector_types())
10026 for (QualType Vec2Ty : CandidateTypes[0].vector_types()) {
10027 QualType ParamTypes[2];
10028 ParamTypes[1] = Vec2Ty;
10056 void addAssignmentIntegralOverloads() {
10057 if (!HasArithmeticOrEnumeralCandidateType)
10060 for (
unsigned Left = FirstIntegralType;
Left < LastIntegralType; ++
Left) {
10061 for (
unsigned Right = FirstPromotedIntegralType;
10062 Right < LastPromotedIntegralType; ++
Right) {
10063 QualType ParamTypes[2];
10064 ParamTypes[1] = ArithmeticTypes[
Right];
10066 S, ArithmeticTypes[Left], Args[0]);
10069 VisibleTypeConversionsQuals, [&](QualifiersAndAtomic Quals) {
10085 void addExclaimOverload() {
10091 void addAmpAmpOrPipePipeOverload() {
10108 void addSubscriptOverloads() {
10109 for (QualType PtrTy : CandidateTypes[0].pointer_types()) {
10119 for (QualType PtrTy : CandidateTypes[1].pointer_types()) {
10139 void addArrowStarOverloads() {
10140 for (QualType PtrTy : CandidateTypes[0].pointer_types()) {
10141 QualType C1Ty = PtrTy;
10143 QualifierCollector Q1;
10154 for (QualType MemPtrTy : CandidateTypes[1].member_pointer_types()) {
10161 QualType ParamTypes[2] = {PtrTy, MemPtrTy};
10164 if (!VisibleTypeConversionsQuals.
hasVolatile() &&
10165 T.isVolatileQualified())
10167 if (!VisibleTypeConversionsQuals.
hasRestrict() &&
10168 T.isRestrictQualified())
10186 void addConditionalOperatorOverloads() {
10188 llvm::SmallPtrSet<QualType, 8> AddedTypes;
10190 for (
unsigned ArgIdx = 0; ArgIdx < 2; ++ArgIdx) {
10191 for (QualType PtrTy : CandidateTypes[ArgIdx].pointer_types()) {
10195 QualType ParamTypes[2] = {PtrTy, PtrTy};
10199 for (QualType MemPtrTy : CandidateTypes[ArgIdx].member_pointer_types()) {
10203 QualType ParamTypes[2] = {MemPtrTy, MemPtrTy};
10208 for (QualType EnumTy : CandidateTypes[ArgIdx].enumeration_types()) {
10209 if (!EnumTy->castAsCanonical<EnumType>()
10210 ->getOriginalDecl()
10217 QualType ParamTypes[2] = {EnumTy, EnumTy};
10236 VisibleTypeConversionsQuals.
addConst();
10237 for (
unsigned ArgIdx = 0, N = Args.size(); ArgIdx != N; ++ArgIdx) {
10239 if (Args[ArgIdx]->
getType()->isAtomicType())
10240 VisibleTypeConversionsQuals.
addAtomic();
10243 bool HasNonRecordCandidateType =
false;
10244 bool HasArithmeticOrEnumeralCandidateType =
false;
10246 for (
unsigned ArgIdx = 0, N = Args.size(); ArgIdx != N; ++ArgIdx) {
10247 CandidateTypes.emplace_back(*
this);
10248 CandidateTypes[ArgIdx].AddTypesConvertedFrom(Args[ArgIdx]->
getType(),
10251 (Op == OO_Exclaim ||
10253 Op == OO_PipePipe),
10254 VisibleTypeConversionsQuals);
10255 HasNonRecordCandidateType = HasNonRecordCandidateType ||
10256 CandidateTypes[ArgIdx].hasNonRecordTypes();
10257 HasArithmeticOrEnumeralCandidateType =
10258 HasArithmeticOrEnumeralCandidateType ||
10259 CandidateTypes[ArgIdx].hasArithmeticOrEnumeralTypes();
10267 if (!HasNonRecordCandidateType &&
10268 !(Op == OO_Exclaim || Op == OO_AmpAmp || Op == OO_PipePipe))
10272 BuiltinOperatorOverloadBuilder OpBuilder(*
this, Args,
10273 VisibleTypeConversionsQuals,
10274 HasArithmeticOrEnumeralCandidateType,
10275 CandidateTypes, CandidateSet);
10281 llvm_unreachable(
"Expected an overloaded operator");
10286 case OO_Array_Delete:
10289 "Special operators don't use AddBuiltinOperatorCandidates");
10301 if (Args.size() == 1)
10302 OpBuilder.addUnaryPlusPointerOverloads();
10306 if (Args.size() == 1) {
10307 OpBuilder.addUnaryPlusOrMinusArithmeticOverloads();
10309 OpBuilder.addBinaryPlusOrMinusPointerOverloads(Op);
10310 OpBuilder.addGenericBinaryArithmeticOverloads();
10311 OpBuilder.addMatrixBinaryArithmeticOverloads();
10316 if (Args.size() == 1)
10317 OpBuilder.addUnaryStarPointerOverloads();
10319 OpBuilder.addGenericBinaryArithmeticOverloads();
10320 OpBuilder.addMatrixBinaryArithmeticOverloads();
10325 OpBuilder.addGenericBinaryArithmeticOverloads();
10329 case OO_MinusMinus:
10330 OpBuilder.addPlusPlusMinusMinusArithmeticOverloads(Op);
10331 OpBuilder.addPlusPlusMinusMinusPointerOverloads();
10334 case OO_EqualEqual:
10335 case OO_ExclaimEqual:
10336 OpBuilder.addEqualEqualOrNotEqualMemberPointerOrNullptrOverloads();
10337 OpBuilder.addGenericBinaryPointerOrEnumeralOverloads(
false);
10338 OpBuilder.addGenericBinaryArithmeticOverloads();
10344 case OO_GreaterEqual:
10345 OpBuilder.addGenericBinaryPointerOrEnumeralOverloads(
false);
10346 OpBuilder.addGenericBinaryArithmeticOverloads();
10350 OpBuilder.addGenericBinaryPointerOrEnumeralOverloads(
true);
10351 OpBuilder.addThreeWayArithmeticOverloads();
10358 case OO_GreaterGreater:
10359 OpBuilder.addBinaryBitwiseArithmeticOverloads();
10363 if (Args.size() == 1)
10369 OpBuilder.addBinaryBitwiseArithmeticOverloads();
10373 OpBuilder.addUnaryTildePromotedIntegralOverloads();
10377 OpBuilder.addAssignmentMemberPointerOrEnumeralOverloads();
10381 case OO_MinusEqual:
10382 OpBuilder.addAssignmentPointerOverloads(Op == OO_Equal);
10386 case OO_SlashEqual:
10387 OpBuilder.addAssignmentArithmeticOverloads(Op == OO_Equal);
10390 case OO_PercentEqual:
10391 case OO_LessLessEqual:
10392 case OO_GreaterGreaterEqual:
10394 case OO_CaretEqual:
10396 OpBuilder.addAssignmentIntegralOverloads();
10400 OpBuilder.addExclaimOverload();
10405 OpBuilder.addAmpAmpOrPipePipeOverload();
10409 if (Args.size() == 2)
10410 OpBuilder.addSubscriptOverloads();
10414 OpBuilder.addArrowStarOverloads();
10417 case OO_Conditional:
10418 OpBuilder.addConditionalOperatorOverloads();
10419 OpBuilder.addGenericBinaryArithmeticOverloads();
10430 bool PartialOverloading) {
10447 CandEnd = CandidateSet.
end();
10448 Cand != CandEnd; ++Cand)
10449 if (Cand->Function) {
10453 Fns.
erase(FunTmpl);
10462 if (ExplicitTemplateArgs)
10466 FD, FoundDecl, Args, CandidateSet,
false,
10467 PartialOverloading,
true,
10468 false, ADLCallKind::UsesADL);
10471 FD, FoundDecl, {Args[1], Args[0]}, CandidateSet,
10472 false, PartialOverloading,
10479 FTD, FoundDecl, ExplicitTemplateArgs, Args, CandidateSet,
10480 false, PartialOverloading,
10481 true, ADLCallKind::UsesADL);
10483 *
this, Args, FTD->getTemplatedDecl())) {
10487 if (ReversedArgs.empty())
10491 FTD, FoundDecl, ExplicitTemplateArgs, ReversedArgs, CandidateSet,
10492 false, PartialOverloading,
10493 true, ADLCallKind::UsesADL,
10518 bool Cand1Attr = Cand1->
hasAttr<EnableIfAttr>();
10519 bool Cand2Attr = Cand2->
hasAttr<EnableIfAttr>();
10520 if (!Cand1Attr || !Cand2Attr) {
10521 if (Cand1Attr == Cand2Attr)
10522 return Comparison::Equal;
10523 return Cand1Attr ? Comparison::Better : Comparison::Worse;
10529 llvm::FoldingSetNodeID Cand1ID, Cand2ID;
10530 for (
auto Pair : zip_longest(Cand1Attrs, Cand2Attrs)) {
10531 std::optional<EnableIfAttr *> Cand1A = std::get<0>(Pair);
10532 std::optional<EnableIfAttr *> Cand2A = std::get<1>(Pair);
10537 return Comparison::Worse;
10539 return Comparison::Better;
10544 (*Cand1A)->getCond()->Profile(Cand1ID, S.
getASTContext(),
true);
10545 (*Cand2A)->getCond()->Profile(Cand2ID, S.
getASTContext(),
true);
10546 if (Cand1ID != Cand2ID)
10547 return Comparison::Worse;
10550 return Comparison::Equal;
10558 return Comparison::Equal;
10564 return Comparison::Equal;
10565 return Comparison::Worse;
10568 return Comparison::Better;
10574 const auto *Cand1CPUSpec = Cand1.
Function->
getAttr<CPUSpecificAttr>();
10575 const auto *Cand2CPUSpec = Cand2.
Function->
getAttr<CPUSpecificAttr>();
10577 if (!Cand1CPUDisp && !Cand2CPUDisp && !Cand1CPUSpec && !Cand2CPUSpec)
10578 return Comparison::Equal;
10580 if (Cand1CPUDisp && !Cand2CPUDisp)
10581 return Comparison::Better;
10582 if (Cand2CPUDisp && !Cand1CPUDisp)
10583 return Comparison::Worse;
10585 if (Cand1CPUSpec && Cand2CPUSpec) {
10586 if (Cand1CPUSpec->cpus_size() != Cand2CPUSpec->cpus_size())
10587 return Cand1CPUSpec->cpus_size() < Cand2CPUSpec->cpus_size()
10588 ? Comparison::Better
10589 : Comparison::Worse;
10591 std::pair<CPUSpecificAttr::cpus_iterator, CPUSpecificAttr::cpus_iterator>
10592 FirstDiff = std::mismatch(
10593 Cand1CPUSpec->cpus_begin(), Cand1CPUSpec->cpus_end(),
10594 Cand2CPUSpec->cpus_begin(),
10596 return LHS->getName() == RHS->getName();
10599 assert(FirstDiff.first != Cand1CPUSpec->cpus_end() &&
10600 "Two different cpu-specific versions should not have the same "
10601 "identifier list, otherwise they'd be the same decl!");
10602 return (*FirstDiff.first)->getName() < (*FirstDiff.second)->getName()
10603 ? Comparison::Better
10604 : Comparison::Worse;
10606 llvm_unreachable(
"No way to get here unless both had cpu_dispatch");
10612static std::optional<QualType>
10615 return std::nullopt;
10621 return M->getFunctionObjectParameterReferenceType();
10635 PT2->getInstantiatedFromMemberTemplate()))
10646 assert(I < F->getNumParams());
10653 if (F1NumParams != F2NumParams)
10656 unsigned I1 = 0, I2 = 0;
10657 for (
unsigned I = 0; I != F1NumParams; ++I) {
10658 QualType T1 = NextParam(F1, I1, I == 0);
10659 QualType T2 = NextParam(F2, I2, I == 0);
10660 assert(!T1.
isNull() && !T2.
isNull() &&
"Unexpected null param types");
10661 if (!Context.hasSameUnqualifiedType(T1, T2))
10674 bool IsFn1Reversed,
10675 bool IsFn2Reversed) {
10676 assert(Fn1 && Fn2);
10681 IsFn1Reversed ^ IsFn2Reversed))
10684 auto *Mem1 = dyn_cast<CXXMethodDecl>(Fn1);
10685 auto *Mem2 = dyn_cast<CXXMethodDecl>(Fn2);
10686 if (Mem1 && Mem2) {
10689 if (Mem1->getParent() != Mem2->getParent())
10693 if (Mem1->isInstance() && Mem2->isInstance() &&
10695 Mem1->getFunctionObjectParameterReferenceType(),
10696 Mem1->getFunctionObjectParameterReferenceType()))
10702static FunctionDecl *
10704 bool IsFn1Reversed,
bool IsFn2Reversed) {
10714 if (Cand1IsSpecialization || Cand2IsSpecialization)
10731 bool PartialOverloading) {
10777 bool IsCand1ImplicitHD =
10779 bool IsCand2ImplicitHD =
10794 auto EmitThreshold =
10795 (S.
getLangOpts().CUDAIsDevice && IsCallerImplicitHD &&
10796 (IsCand1ImplicitHD || IsCand2ImplicitHD))
10799 auto Cand1Emittable = P1 > EmitThreshold;
10800 auto Cand2Emittable = P2 > EmitThreshold;
10801 if (Cand1Emittable && !Cand2Emittable)
10803 if (!Cand1Emittable && Cand2Emittable)
10814 unsigned StartArg = 0;
10822 return ICS.isStandard() &&
10834 assert(Cand2.
Conversions.size() == NumArgs &&
"Overload candidate mismatch");
10835 bool HasBetterConversion =
false;
10836 for (
unsigned ArgIdx = StartArg; ArgIdx < NumArgs; ++ArgIdx) {
10837 bool Cand1Bad = IsIllFormedConversion(Cand1.
Conversions[ArgIdx]);
10838 bool Cand2Bad = IsIllFormedConversion(Cand2.
Conversions[ArgIdx]);
10839 if (Cand1Bad != Cand2Bad) {
10842 HasBetterConversion =
true;
10846 if (HasBetterConversion)
10853 bool HasWorseConversion =
false;
10854 for (
unsigned ArgIdx = StartArg; ArgIdx < NumArgs; ++ArgIdx) {
10860 HasBetterConversion =
true;
10879 HasWorseConversion =
true;
10894 if (HasBetterConversion && !HasWorseConversion)
10945 bool Cand1IsSpecialization = Cand1.
Function &&
10947 bool Cand2IsSpecialization = Cand2.
Function &&
10949 if (Cand1IsSpecialization != Cand2IsSpecialization)
10950 return Cand2IsSpecialization;
10956 if (Cand1IsSpecialization && Cand2IsSpecialization) {
10957 const auto *Obj1Context =
10959 const auto *Obj2Context =
10988 bool Cand1IsInherited =
10990 bool Cand2IsInherited =
10992 if (Cand1IsInherited != Cand2IsInherited)
10993 return Cand2IsInherited;
10994 else if (Cand1IsInherited) {
10995 assert(Cand2IsInherited);
10998 if (Cand1Class->isDerivedFrom(Cand2Class))
11000 if (Cand2Class->isDerivedFrom(Cand1Class))
11017 auto *Guide1 = dyn_cast_or_null<CXXDeductionGuideDecl>(Cand1.
Function);
11018 auto *Guide2 = dyn_cast_or_null<CXXDeductionGuideDecl>(Cand2.
Function);
11019 if (Guide1 && Guide2) {
11021 if (Guide1->isImplicit() != Guide2->isImplicit())
11022 return Guide2->isImplicit();
11032 const auto *Constructor1 = Guide1->getCorrespondingConstructor();
11033 const auto *Constructor2 = Guide2->getCorrespondingConstructor();
11034 if (Constructor1 && Constructor2) {
11035 bool isC1Templated = Constructor1->getTemplatedKind() !=
11037 bool isC2Templated = Constructor2->getTemplatedKind() !=
11039 if (isC1Templated != isC2Templated)
11040 return isC2Templated;
11048 if (Cmp != Comparison::Equal)
11049 return Cmp == Comparison::Better;
11052 bool HasPS1 = Cand1.
Function !=
nullptr &&
11054 bool HasPS2 = Cand2.
Function !=
nullptr &&
11056 if (HasPS1 != HasPS2 && HasPS1)
11060 if (MV == Comparison::Better)
11062 if (MV == Comparison::Worse)
11077 const auto *CD1 = dyn_cast_or_null<CXXConstructorDecl>(Cand1.
Function);
11078 const auto *CD2 = dyn_cast_or_null<CXXConstructorDecl>(Cand2.
Function);
11080 LangAS AS1 = CD1->getMethodQualifiers().getAddressSpace();
11081 LangAS AS2 = CD2->getMethodQualifiers().getAddressSpace();
11102 auto *VA = dyn_cast_or_null<ValueDecl>(A);
11103 auto *VB = dyn_cast_or_null<ValueDecl>(B);
11109 if (!VA->getDeclContext()->getRedeclContext()->Equals(
11110 VB->getDeclContext()->getRedeclContext()) ||
11112 VA->isExternallyVisible() || VB->isExternallyVisible())
11120 if (
Context.hasSameType(VA->getType(), VB->getType()))
11125 if (
auto *EA = dyn_cast<EnumConstantDecl>(VA)) {
11126 if (
auto *EB = dyn_cast<EnumConstantDecl>(VB)) {
11131 if (EnumA->hasNameForLinkage() || EnumB->hasNameForLinkage() ||
11132 !
Context.hasSameType(EnumA->getIntegerType(),
11133 EnumB->getIntegerType()))
11136 return llvm::APSInt::isSameValue(EA->getInitVal(), EB->getInitVal());
11146 assert(D &&
"Unknown declaration");
11147 Diag(Loc, diag::ext_equivalent_internal_linkage_decl_in_modules) << D;
11153 for (
auto *E : Equiv) {
11155 Diag(E->getLocation(), diag::note_equivalent_internal_linkage_decl)
11165 ->Satisfaction.ContainsErrors;
11171 bool PartialOverloading,
bool AllowExplicit,
11173 bool AggregateCandidateDeduction) {
11176 allocateDeferredCandidate<DeferredFunctionTemplateOverloadCandidate>();
11181 false, AllowExplicit, SuppressUserConversions,
11182 PartialOverloading, AggregateCandidateDeduction},
11189 HasDeferredTemplateConstructors |=
11197 bool SuppressUserConversions,
bool PartialOverloading,
11203 allocateDeferredCandidate<DeferredMethodTemplateOverloadCandidate>();
11209 false, SuppressUserConversions, PartialOverloading,
11215 ObjectClassification,
11223 bool AllowObjCConversionOnExplicit,
bool AllowExplicit,
11224 bool AllowResultConversion) {
11227 allocateDeferredCandidate<DeferredConversionTemplateOverloadCandidate>();
11231 AllowObjCConversionOnExplicit, AllowResultConversion,
11248 S, CandidateSet,
C.FunctionTemplate,
C.FoundDecl,
C.ActingContext,
11249 nullptr,
C.ObjectType,
C.ObjectClassification,
11250 C.Args,
C.SuppressUserConversions,
C.PartialOverloading,
C.PO);
11257 S, CandidateSet,
C.FunctionTemplate,
C.FoundDecl,
11258 nullptr,
C.Args,
C.SuppressUserConversions,
11259 C.PartialOverloading,
C.AllowExplicit,
C.IsADLCandidate,
C.PO,
11260 C.AggregateCandidateDeduction);
11267 S, CandidateSet,
C.FunctionTemplate,
C.FoundDecl,
C.ActingContext,
C.From,
11268 C.ToType,
C.AllowObjCConversionOnExplicit,
C.AllowExplicit,
11269 C.AllowResultConversion);
11273 Candidates.reserve(Candidates.size() + DeferredCandidatesCount);
11276 switch (Cand->
Kind) {
11295 FirstDeferredCandidate =
nullptr;
11296 DeferredCandidatesCount = 0;
11300OverloadCandidateSet::ResultForBestCandidate(
const iterator &Best) {
11302 if (Best->Function && Best->Function->isDeleted())
11307void OverloadCandidateSet::CudaExcludeWrongSideCandidates(
11324 bool ContainsSameSideCandidate =
11332 if (!ContainsSameSideCandidate)
11335 auto IsWrongSideCandidate = [&](
const OverloadCandidate *Cand) {
11341 llvm::erase_if(Candidates, IsWrongSideCandidate);
11359 DeferredCandidatesCount == 0) &&
11360 "Unexpected deferred template candidates");
11362 bool TwoPhaseResolution =
11363 DeferredCandidatesCount != 0 && !ResolutionByPerfectCandidateIsDisabled;
11365 if (TwoPhaseResolution) {
11367 if (Best !=
end() && Best->isPerfectMatch(S.
Context)) {
11368 if (!(HasDeferredTemplateConstructors &&
11369 isa_and_nonnull<CXXConversionDecl>(Best->Function)))
11375 return BestViableFunctionImpl(S, Loc, Best);
11382 Candidates.reserve(this->Candidates.size());
11383 std::transform(this->Candidates.begin(), this->Candidates.end(),
11384 std::back_inserter(Candidates),
11388 CudaExcludeWrongSideCandidates(S, Candidates);
11391 for (
auto *Cand : Candidates) {
11392 Cand->
Best =
false;
11394 if (Best ==
end() ||
11411 llvm::SmallVector<OverloadCandidate *, 4> PendingBest;
11412 llvm::SmallVector<const NamedDecl *, 4> EquivalentCands;
11413 PendingBest.push_back(&*Best);
11418 while (!PendingBest.empty()) {
11419 auto *Curr = PendingBest.pop_back_val();
11420 for (
auto *Cand : Candidates) {
11423 PendingBest.push_back(Cand);
11428 EquivalentCands.push_back(Cand->
Function);
11440 if (!EquivalentCands.empty())
11448enum OverloadCandidateKind {
11451 oc_reversed_binary_operator,
11453 oc_implicit_default_constructor,
11454 oc_implicit_copy_constructor,
11455 oc_implicit_move_constructor,
11456 oc_implicit_copy_assignment,
11457 oc_implicit_move_assignment,
11458 oc_implicit_equality_comparison,
11459 oc_inherited_constructor
11462enum OverloadCandidateSelect {
11465 ocs_described_template,
11468static std::pair<OverloadCandidateKind, OverloadCandidateSelect>
11469ClassifyOverloadCandidate(Sema &S,
const NamedDecl *
Found,
11470 const FunctionDecl *Fn,
11472 std::string &Description) {
11475 if (FunctionTemplateDecl *FunTmpl =
Fn->getPrimaryTemplate()) {
11478 FunTmpl->getTemplateParameters(), *
Fn->getTemplateSpecializationArgs());
11481 OverloadCandidateSelect Select = [&]() {
11482 if (!Description.empty())
11483 return ocs_described_template;
11484 return isTemplate ? ocs_template : ocs_non_template;
11487 OverloadCandidateKind Kind = [&]() {
11488 if (
Fn->isImplicit() &&
Fn->getOverloadedOperator() == OO_EqualEqual)
11489 return oc_implicit_equality_comparison;
11492 return oc_reversed_binary_operator;
11494 if (
const auto *Ctor = dyn_cast<CXXConstructorDecl>(Fn)) {
11495 if (!Ctor->isImplicit()) {
11497 return oc_inherited_constructor;
11499 return oc_constructor;
11502 if (Ctor->isDefaultConstructor())
11503 return oc_implicit_default_constructor;
11505 if (Ctor->isMoveConstructor())
11506 return oc_implicit_move_constructor;
11508 assert(Ctor->isCopyConstructor() &&
11509 "unexpected sort of implicit constructor");
11510 return oc_implicit_copy_constructor;
11513 if (
const auto *Meth = dyn_cast<CXXMethodDecl>(Fn)) {
11516 if (!Meth->isImplicit())
11519 if (Meth->isMoveAssignmentOperator())
11520 return oc_implicit_move_assignment;
11522 if (Meth->isCopyAssignmentOperator())
11523 return oc_implicit_copy_assignment;
11529 return oc_function;
11532 return std::make_pair(Kind, Select);
11535void MaybeEmitInheritedConstructorNote(Sema &S,
const Decl *FoundDecl) {
11538 if (
const auto *Shadow = dyn_cast<ConstructorUsingShadowDecl>(FoundDecl))
11540 diag::note_ovl_candidate_inherited_constructor)
11541 << Shadow->getNominatedBaseClass();
11550 if (EnableIf->getCond()->isValueDependent() ||
11551 !EnableIf->getCond()->EvaluateAsBooleanCondition(AlwaysTrue, Ctx))
11568 bool InOverloadResolution,
11572 if (InOverloadResolution)
11574 diag::note_addrof_ovl_candidate_disabled_by_enable_if_attr);
11576 S.
Diag(Loc, diag::err_addrof_function_disabled_by_enable_if_attr) << FD;
11587 if (InOverloadResolution) {
11590 TemplateArgString +=
" ";
11592 FunTmpl->getTemplateParameters(),
11597 diag::note_ovl_candidate_unsatisfied_constraints)
11598 << TemplateArgString;
11600 S.
Diag(Loc, diag::err_addrof_function_constraints_not_satisfied)
11609 return P->hasAttr<PassObjectSizeAttr>();
11616 unsigned ParamNo = std::distance(FD->
param_begin(), I) + 1;
11617 if (InOverloadResolution)
11619 diag::note_ovl_candidate_has_pass_object_size_params)
11622 S.
Diag(Loc, diag::err_address_of_function_with_pass_object_size_params)
11638 return ::checkAddressOfFunctionIsAvailable(*
this,
Function, Complain,
11646 const auto *ConvD = dyn_cast<CXXConversionDecl>(Fn);
11651 if (!RD->isLambda())
11661 return ConvToCC != CallOpCC;
11667 QualType DestType,
bool TakingAddress) {
11670 if (Fn->isMultiVersion() && Fn->hasAttr<TargetAttr>() &&
11671 !Fn->getAttr<TargetAttr>()->isDefaultVersion())
11673 if (Fn->isMultiVersion() && Fn->hasAttr<TargetVersionAttr>() &&
11674 !Fn->getAttr<TargetVersionAttr>()->isDefaultVersion())
11679 std::string FnDesc;
11680 std::pair<OverloadCandidateKind, OverloadCandidateSelect> KSPair =
11681 ClassifyOverloadCandidate(*
this,
Found, Fn, RewriteKind, FnDesc);
11683 << (
unsigned)KSPair.first << (
unsigned)KSPair.second
11687 Diag(Fn->getLocation(), PD);
11688 MaybeEmitInheritedConstructorNote(*
this,
Found);
11706 FunctionDecl *FirstCand =
nullptr, *SecondCand =
nullptr;
11707 for (
auto I = Cands.begin(), E = Cands.end(); I != E; ++I) {
11711 if (
auto *
Template = I->Function->getPrimaryTemplate())
11712 Template->getAssociatedConstraints(AC);
11714 I->Function->getAssociatedConstraints(AC);
11717 if (FirstCand ==
nullptr) {
11718 FirstCand = I->Function;
11720 }
else if (SecondCand ==
nullptr) {
11721 SecondCand = I->Function;
11734 SecondCand, SecondAC))
11743 bool TakingAddress) {
11753 dyn_cast<FunctionTemplateDecl>((*I)->getUnderlyingDecl()) ) {
11757 = dyn_cast<FunctionDecl>((*I)->getUnderlyingDecl()) ) {
11770 S.
Diag(CaretLoc, PDiag)
11772 unsigned CandsShown = 0;
11786 unsigned I,
bool TakingCandidateAddress) {
11788 assert(Conv.
isBad());
11789 assert(Cand->
Function &&
"for now, candidate must be a function");
11795 bool isObjectArgument =
false;
11799 isObjectArgument =
true;
11800 else if (!Fn->hasCXXExplicitFunctionObjectParameter())
11804 std::string FnDesc;
11805 std::pair<OverloadCandidateKind, OverloadCandidateSelect> FnKindPair =
11816 bool HasParamPack =
11817 llvm::any_of(Fn->parameters().take_front(I), [](
const ParmVarDecl *Parm) {
11818 return Parm->isParameterPack();
11820 if (!isObjectArgument && !HasParamPack)
11821 ToParamRange = Fn->getParamDecl(I)->getSourceRange();
11824 assert(FromExpr &&
"overload set argument came from implicit argument?");
11830 S.
Diag(Fn->getLocation(), diag::note_ovl_candidate_bad_overload)
11831 << (
unsigned)FnKindPair.first << (
unsigned)FnKindPair.second << FnDesc
11832 << ToParamRange << ToTy << Name << I + 1;
11833 MaybeEmitInheritedConstructorNote(S, Cand->
FoundDecl);
11842 CToTy = RT->getPointeeType();
11847 CFromTy = FromPT->getPointeeType();
11848 CToTy = ToPT->getPointeeType();
11858 if (isObjectArgument)
11859 S.
Diag(Fn->getLocation(), diag::note_ovl_candidate_bad_addrspace_this)
11860 << (
unsigned)FnKindPair.first << (
unsigned)FnKindPair.second
11863 S.
Diag(Fn->getLocation(), diag::note_ovl_candidate_bad_addrspace)
11864 << (
unsigned)FnKindPair.first << (
unsigned)FnKindPair.second
11867 MaybeEmitInheritedConstructorNote(S, Cand->
FoundDecl);
11872 S.
Diag(Fn->getLocation(), diag::note_ovl_candidate_bad_ownership)
11873 << (
unsigned)FnKindPair.first << (
unsigned)FnKindPair.second << FnDesc
11876 MaybeEmitInheritedConstructorNote(S, Cand->
FoundDecl);
11881 S.
Diag(Fn->getLocation(), diag::note_ovl_candidate_bad_gc)
11882 << (
unsigned)FnKindPair.first << (
unsigned)FnKindPair.second << FnDesc
11885 MaybeEmitInheritedConstructorNote(S, Cand->
FoundDecl);
11890 S.
Diag(Fn->getLocation(), diag::note_ovl_candidate_bad_ptrauth)
11891 << (
unsigned)FnKindPair.first << (
unsigned)FnKindPair.second << FnDesc
11896 MaybeEmitInheritedConstructorNote(S, Cand->
FoundDecl);
11901 assert(CVR &&
"expected qualifiers mismatch");
11903 if (isObjectArgument) {
11904 S.
Diag(Fn->getLocation(), diag::note_ovl_candidate_bad_cvr_this)
11905 << (
unsigned)FnKindPair.first << (
unsigned)FnKindPair.second << FnDesc
11906 << FromTy << (CVR - 1);
11908 S.
Diag(Fn->getLocation(), diag::note_ovl_candidate_bad_cvr)
11909 << (
unsigned)FnKindPair.first << (
unsigned)FnKindPair.second << FnDesc
11910 << ToParamRange << FromTy << (CVR - 1) << I + 1;
11912 MaybeEmitInheritedConstructorNote(S, Cand->
FoundDecl);
11918 S.
Diag(Fn->getLocation(), diag::note_ovl_candidate_bad_value_category)
11919 << (
unsigned)FnKindPair.first << (
unsigned)FnKindPair.second << FnDesc
11920 << (
unsigned)isObjectArgument << I + 1
11923 MaybeEmitInheritedConstructorNote(S, Cand->
FoundDecl);
11930 S.
Diag(Fn->getLocation(), diag::note_ovl_candidate_bad_list_argument)
11931 << (
unsigned)FnKindPair.first << (
unsigned)FnKindPair.second << FnDesc
11932 << ToParamRange << FromTy << ToTy << (
unsigned)isObjectArgument << I + 1
11937 MaybeEmitInheritedConstructorNote(S, Cand->
FoundDecl);
11949 S.
Diag(Fn->getLocation(), diag::note_ovl_candidate_bad_conv_incomplete)
11950 << (
unsigned)FnKindPair.first << (
unsigned)FnKindPair.second << FnDesc
11951 << ToParamRange << FromTy << ToTy << (
unsigned)isObjectArgument << I + 1
11952 << (
unsigned)(Cand->
Fix.
Kind);
11954 MaybeEmitInheritedConstructorNote(S, Cand->
FoundDecl);
11959 unsigned BaseToDerivedConversion = 0;
11962 if (ToPtrTy->getPointeeType().isAtLeastAsQualifiedAs(
11964 !FromPtrTy->getPointeeType()->isIncompleteType() &&
11965 !ToPtrTy->getPointeeType()->isIncompleteType() &&
11967 FromPtrTy->getPointeeType()))
11968 BaseToDerivedConversion = 1;
11976 if (ToPtrTy->getPointeeType().isAtLeastAsQualifiedAs(
11978 FromIface->isSuperClassOf(ToIface))
11979 BaseToDerivedConversion = 2;
11981 if (ToRefTy->getPointeeType().isAtLeastAsQualifiedAs(FromTy,
11984 !ToRefTy->getPointeeType()->isIncompleteType() &&
11986 BaseToDerivedConversion = 3;
11990 if (BaseToDerivedConversion) {
11991 S.
Diag(Fn->getLocation(), diag::note_ovl_candidate_bad_base_to_derived_conv)
11992 << (
unsigned)FnKindPair.first << (
unsigned)FnKindPair.second << FnDesc
11993 << ToParamRange << (BaseToDerivedConversion - 1) << FromTy << ToTy
11995 MaybeEmitInheritedConstructorNote(S, Cand->
FoundDecl);
12004 S.
Diag(Fn->getLocation(), diag::note_ovl_candidate_bad_arc_conv)
12005 << (
unsigned)FnKindPair.first << (
unsigned)FnKindPair.second << FnDesc
12006 << ToParamRange << FromTy << ToTy << (
unsigned)isObjectArgument
12008 MaybeEmitInheritedConstructorNote(S, Cand->
FoundDecl);
12018 FDiag << (
unsigned)FnKindPair.first << (
unsigned)FnKindPair.second << FnDesc
12019 << ToParamRange << FromTy << ToTy << (
unsigned)isObjectArgument << I + 1
12020 << (
unsigned)(Cand->
Fix.
Kind);
12029 S.
Diag(Fn->getLocation(), FDiag);
12031 MaybeEmitInheritedConstructorNote(S, Cand->
FoundDecl);
12038 unsigned NumArgs,
bool IsAddressOf =
false) {
12039 assert(Cand->
Function &&
"Candidate is required to be a function.");
12041 unsigned MinParams = Fn->getMinRequiredExplicitArguments() +
12042 ((IsAddressOf && !Fn->isStatic()) ? 1 : 0);
12049 if (Fn->isInvalidDecl() &&
12053 if (NumArgs < MinParams) {
12070 unsigned NumFormalArgs,
12071 bool IsAddressOf =
false) {
12073 "The templated declaration should at least be a function"
12074 " when diagnosing bad template argument deduction due to too many"
12075 " or too few arguments");
12081 unsigned MinParams = Fn->getMinRequiredExplicitArguments() +
12082 ((IsAddressOf && !Fn->isStatic()) ? 1 : 0);
12085 bool HasExplicitObjectParam =
12086 !IsAddressOf && Fn->hasCXXExplicitFunctionObjectParameter();
12088 unsigned ParamCount =
12089 Fn->getNumNonObjectParams() + ((IsAddressOf && !Fn->isStatic()) ? 1 : 0);
12090 unsigned mode, modeCount;
12092 if (NumFormalArgs < MinParams) {
12093 if (MinParams != ParamCount || FnTy->isVariadic() ||
12094 FnTy->isTemplateVariadic())
12098 modeCount = MinParams;
12100 if (MinParams != ParamCount)
12104 modeCount = ParamCount;
12107 std::string Description;
12108 std::pair<OverloadCandidateKind, OverloadCandidateSelect> FnKindPair =
12109 ClassifyOverloadCandidate(S,
Found, Fn,
CRK_None, Description);
12111 if (modeCount == 1 && !IsAddressOf &&
12112 Fn->getParamDecl(HasExplicitObjectParam ? 1 : 0)->getDeclName())
12113 S.
Diag(Fn->getLocation(), diag::note_ovl_candidate_arity_one)
12114 << (
unsigned)FnKindPair.first << (
unsigned)FnKindPair.second
12115 << Description << mode
12116 << Fn->getParamDecl(HasExplicitObjectParam ? 1 : 0) << NumFormalArgs
12117 << HasExplicitObjectParam << Fn->getParametersSourceRange();
12119 S.
Diag(Fn->getLocation(), diag::note_ovl_candidate_arity)
12120 << (
unsigned)FnKindPair.first << (
unsigned)FnKindPair.second
12121 << Description << mode << modeCount << NumFormalArgs
12122 << HasExplicitObjectParam << Fn->getParametersSourceRange();
12124 MaybeEmitInheritedConstructorNote(S,
Found);
12129 unsigned NumFormalArgs) {
12130 assert(Cand->
Function &&
"Candidate must be a function");
12140 llvm_unreachable(
"Unsupported: Getting the described template declaration"
12141 " for bad deduction diagnosis");
12148 bool TakingCandidateAddress) {
12154 switch (DeductionFailure.
getResult()) {
12157 "TemplateDeductionResult::Success while diagnosing bad deduction");
12159 llvm_unreachable(
"TemplateDeductionResult::NonDependentConversionFailure "
12160 "while diagnosing bad deduction");
12166 assert(ParamD &&
"no parameter found for incomplete deduction result");
12168 diag::note_ovl_candidate_incomplete_deduction)
12170 MaybeEmitInheritedConstructorNote(S,
Found);
12175 assert(ParamD &&
"no parameter found for incomplete deduction result");
12177 diag::note_ovl_candidate_incomplete_deduction_pack)
12179 << (DeductionFailure.
getFirstArg()->pack_size() + 1)
12181 MaybeEmitInheritedConstructorNote(S,
Found);
12186 assert(ParamD &&
"no parameter found for bad qualifiers deduction result");
12204 S.
Diag(Templated->
getLocation(), diag::note_ovl_candidate_underqualified)
12205 << ParamD->
getDeclName() << Arg << NonCanonParam;
12206 MaybeEmitInheritedConstructorNote(S,
Found);
12211 assert(ParamD &&
"no parameter found for inconsistent deduction result");
12225 diag::note_ovl_candidate_inconsistent_deduction_types)
12228 MaybeEmitInheritedConstructorNote(S,
Found);
12248 diag::note_ovl_candidate_inconsistent_deduction)
12251 MaybeEmitInheritedConstructorNote(S,
Found);
12256 assert(ParamD &&
"no parameter found for invalid explicit arguments");
12259 diag::note_ovl_candidate_explicit_arg_mismatch_named)
12264 index = TTP->getIndex();
12266 = dyn_cast<NonTypeTemplateParmDecl>(ParamD))
12267 index = NTTP->getIndex();
12271 diag::note_ovl_candidate_explicit_arg_mismatch_unnamed)
12274 MaybeEmitInheritedConstructorNote(S,
Found);
12281 TemplateArgString =
" ";
12284 if (TemplateArgString.size() == 1)
12285 TemplateArgString.clear();
12287 diag::note_ovl_candidate_unsatisfied_constraints)
12288 << TemplateArgString;
12291 static_cast<CNSInfo*
>(DeductionFailure.
Data)->Satisfaction);
12301 diag::note_ovl_candidate_instantiation_depth);
12302 MaybeEmitInheritedConstructorNote(S,
Found);
12310 TemplateArgString =
" ";
12313 if (TemplateArgString.size() == 1)
12314 TemplateArgString.clear();
12319 if (PDiag && PDiag->second.getDiagID() ==
12320 diag::err_typename_nested_not_found_enable_if) {
12323 S.
Diag(PDiag->first, diag::note_ovl_candidate_disabled_by_enable_if)
12324 <<
"'enable_if'" << TemplateArgString;
12329 if (PDiag && PDiag->second.getDiagID() ==
12330 diag::err_typename_nested_not_found_requirement) {
12332 diag::note_ovl_candidate_disabled_by_requirement)
12333 << PDiag->second.getStringArg(0) << TemplateArgString;
12343 SFINAEArgString =
": ";
12345 PDiag->second.EmitToString(S.
getDiagnostics(), SFINAEArgString);
12349 diag::note_ovl_candidate_substitution_failure)
12350 << TemplateArgString << SFINAEArgString << R;
12351 MaybeEmitInheritedConstructorNote(S,
Found);
12361 TemplateArgString =
" ";
12364 if (TemplateArgString.size() == 1)
12365 TemplateArgString.clear();
12368 S.
Diag(Templated->
getLocation(), diag::note_ovl_candidate_deduced_mismatch)
12371 << TemplateArgString
12396 diag::note_ovl_candidate_non_deduced_mismatch_qualified)
12412 diag::note_ovl_candidate_non_deduced_mismatch)
12413 << FirstTA << SecondTA;
12419 S.
Diag(Templated->
getLocation(), diag::note_ovl_candidate_bad_deduction);
12420 MaybeEmitInheritedConstructorNote(S,
Found);
12424 diag::note_cuda_ovl_candidate_target_mismatch);
12432 bool TakingCandidateAddress) {
12433 assert(Cand->
Function &&
"Candidate must be a function");
12448 assert(Cand->
Function &&
"Candidate must be a Function.");
12454 std::string FnDesc;
12455 std::pair<OverloadCandidateKind, OverloadCandidateSelect> FnKindPair =
12456 ClassifyOverloadCandidate(S, Cand->
FoundDecl, Callee,
12459 S.
Diag(Callee->getLocation(), diag::note_ovl_candidate_bad_target)
12460 << (
unsigned)FnKindPair.first << (
unsigned)ocs_non_template
12462 << CalleeTarget << CallerTarget;
12467 if (Meth !=
nullptr && Meth->
isImplicit()) {
12471 switch (FnKindPair.first) {
12474 case oc_implicit_default_constructor:
12477 case oc_implicit_copy_constructor:
12480 case oc_implicit_move_constructor:
12483 case oc_implicit_copy_assignment:
12486 case oc_implicit_move_assignment:
12491 bool ConstRHS =
false;
12495 ConstRHS = RT->getPointeeType().isConstQualified();
12506 assert(Cand->
Function &&
"Candidate must be a function");
12510 S.
Diag(Callee->getLocation(),
12511 diag::note_ovl_candidate_disabled_by_function_cond_attr)
12512 <<
Attr->getCond()->getSourceRange() <<
Attr->getMessage();
12516 assert(Cand->
Function &&
"Candidate must be a function");
12519 assert(ES.
isExplicit() &&
"not an explicit candidate");
12522 switch (Fn->getDeclKind()) {
12523 case Decl::Kind::CXXConstructor:
12526 case Decl::Kind::CXXConversion:
12529 case Decl::Kind::CXXDeductionGuide:
12530 Kind = Fn->isImplicit() ? 0 : 2;
12533 llvm_unreachable(
"invalid Decl");
12542 First = Pattern->getFirstDecl();
12545 diag::note_ovl_candidate_explicit)
12546 << Kind << (ES.
getExpr() ? 1 : 0)
12551 auto *DG = dyn_cast<CXXDeductionGuideDecl>(Fn);
12558 if (!(DG->isImplicit() || (OriginTemplate && OriginTemplate->
isTypeAlias())))
12560 std::string FunctionProto;
12561 llvm::raw_string_ostream OS(FunctionProto);
12574 "Non-template implicit deduction guides are only possible for "
12577 S.
Diag(DG->getLocation(), diag::note_implicit_deduction_guide)
12582 assert(
Template &&
"Cannot find the associated function template of "
12583 "CXXDeductionGuideDecl?");
12586 S.
Diag(DG->getLocation(), diag::note_implicit_deduction_guide)
12607 bool TakingCandidateAddress,
12609 assert(Cand->
Function &&
"Candidate must be a function");
12617 if (S.
getLangOpts().OpenCL && Fn->isImplicit() &&
12624 !Fn->hasCXXExplicitFunctionObjectParameter() && !Fn->isStatic())
12629 if (Fn->isDeleted()) {
12630 std::string FnDesc;
12631 std::pair<OverloadCandidateKind, OverloadCandidateSelect> FnKindPair =
12632 ClassifyOverloadCandidate(S, Cand->
FoundDecl, Fn,
12635 S.
Diag(Fn->getLocation(), diag::note_ovl_candidate_deleted)
12636 << (
unsigned)FnKindPair.first << (
unsigned)FnKindPair.second << FnDesc
12637 << (Fn->isDeleted() ? (Fn->isDeletedAsWritten() ? 1 : 2) : 0);
12638 MaybeEmitInheritedConstructorNote(S, Cand->
FoundDecl);
12665 TakingCandidateAddress);
12668 S.
Diag(Fn->getLocation(), diag::note_ovl_candidate_illegal_constructor)
12669 << (Fn->getPrimaryTemplate() ? 1 : 0);
12670 MaybeEmitInheritedConstructorNote(S, Cand->
FoundDecl);
12677 S.
Diag(Fn->getLocation(),
12678 diag::note_ovl_candidate_illegal_constructor_adrspace_mismatch)
12679 << QualsForPrinting;
12680 MaybeEmitInheritedConstructorNote(S, Cand->
FoundDecl);
12691 for (
unsigned N = Cand->
Conversions.size(); I != N; ++I)
12714 S.
Diag(Fn->getLocation(),
12715 diag::note_ovl_candidate_inherited_constructor_slice)
12716 << (Fn->getPrimaryTemplate() ? 1 : 0)
12717 << Fn->getParamDecl(0)->getType()->isRValueReferenceType();
12718 MaybeEmitInheritedConstructorNote(S, Cand->
FoundDecl);
12724 assert(!Available);
12732 std::string FnDesc;
12733 std::pair<OverloadCandidateKind, OverloadCandidateSelect> FnKindPair =
12734 ClassifyOverloadCandidate(S, Cand->
FoundDecl, Fn,
12737 S.
Diag(Fn->getLocation(),
12738 diag::note_ovl_candidate_constraints_not_satisfied)
12739 << (
unsigned)FnKindPair.first << (
unsigned)ocs_non_template
12757 bool isLValueReference =
false;
12758 bool isRValueReference =
false;
12759 bool isPointer =
false;
12763 isLValueReference =
true;
12767 isRValueReference =
true;
12783 diag::note_ovl_surrogate_constraints_not_satisfied)
12797 assert(Cand->
Conversions.size() <= 2 &&
"builtin operator is not binary");
12798 std::string TypeStr(
"operator");
12804 S.
Diag(OpLoc, diag::note_ovl_builtin_candidate) << TypeStr;
12809 S.
Diag(OpLoc, diag::note_ovl_builtin_candidate) << TypeStr;
12816 if (ICS.
isBad())
break;
12820 S, OpLoc, S.
PDiag(diag::note_ambiguous_type_conversion));
12837 llvm_unreachable(
"non-deduction failure while diagnosing bad deduction");
12867 llvm_unreachable(
"Unhandled deduction result");
12872struct CompareOverloadCandidatesForDisplay {
12874 SourceLocation Loc;
12878 CompareOverloadCandidatesForDisplay(
12879 Sema &S, SourceLocation Loc,
size_t NArgs,
12881 : S(S), NumArgs(NArgs), CSK(CSK) {}
12891 if (NumArgs >
C->Function->getNumParams() && !
C->Function->isVariadic())
12893 if (NumArgs < C->
Function->getMinRequiredArguments())
12900 bool operator()(
const OverloadCandidate *L,
12901 const OverloadCandidate *R) {
12903 if (L == R)
return false;
12907 if (!R->
Viable)
return true;
12909 if (
int Ord = CompareConversions(*L, *R))
12929 if (LDist == RDist) {
12930 if (LFailureKind == RFailureKind)
12938 return LDist < RDist;
12956 numLFixes = (numLFixes == 0) ?
UINT_MAX : numLFixes;
12957 numRFixes = (numRFixes == 0) ?
UINT_MAX : numRFixes;
12958 if (numLFixes != numRFixes) {
12959 return numLFixes < numRFixes;
12963 if (
int Ord = CompareConversions(*L, *R))
12975 if (LRank != RRank)
12976 return LRank < RRank;
13002 struct ConversionSignals {
13003 unsigned KindRank = 0;
13006 static ConversionSignals ForSequence(ImplicitConversionSequence &
Seq) {
13007 ConversionSignals Sig;
13008 Sig.KindRank =
Seq.getKindRank();
13009 if (
Seq.isStandard())
13010 Sig.Rank =
Seq.Standard.getRank();
13011 else if (
Seq.isUserDefined())
13012 Sig.Rank =
Seq.UserDefined.After.getRank();
13018 static ConversionSignals ForObjectArgument() {
13028 int CompareConversions(
const OverloadCandidate &L,
13029 const OverloadCandidate &R) {
13034 for (
unsigned I = 0, N = L.
Conversions.size(); I != N; ++I) {
13036 ? ConversionSignals::ForObjectArgument()
13037 : ConversionSignals::ForSequence(L.Conversions[I]);
13039 ? ConversionSignals::ForObjectArgument()
13040 : ConversionSignals::ForSequence(R.Conversions[I]);
13041 if (std::tie(LS.KindRank, LS.Rank) != std::tie(RS.KindRank, RS.Rank))
13042 return std::tie(LS.KindRank, LS.Rank) < std::tie(RS.KindRank, RS.Rank)
13067 bool Unfixable =
false;
13073 for (
unsigned ConvIdx =
13077 assert(ConvIdx != ConvCount &&
"no bad conversion in candidate");
13078 if (Cand->
Conversions[ConvIdx].isInitialized() &&
13087 bool SuppressUserConversions =
false;
13089 unsigned ConvIdx = 0;
13090 unsigned ArgIdx = 0;
13119 assert(ConvCount <= 3);
13125 ConvIdx != ConvCount && ArgIdx < Args.size();
13127 if (Cand->
Conversions[ConvIdx].isInitialized()) {
13129 }
else if (
ParamIdx < ParamTypes.size()) {
13130 if (ParamTypes[
ParamIdx]->isDependentType())
13131 Cand->
Conversions[ConvIdx].setAsIdentityConversion(
13136 SuppressUserConversions,
13141 if (!Unfixable && Cand->
Conversions[ConvIdx].isBad())
13160 for (
iterator Cand = Candidates.begin(), LastCand = Candidates.end();
13161 Cand != LastCand; ++Cand) {
13162 if (!Filter(*Cand))
13187 Cands.push_back(Cand);
13191 Cands, CompareOverloadCandidatesForDisplay(S, OpLoc, Args.size(), Kind));
13198 bool DeferHint =
false;
13202 auto WrongSidedCands =
13204 return (Cand.
Viable ==
false &&
13210 DeferHint = !WrongSidedCands.empty();
13228 bool NoteCands =
true;
13229 for (
const Expr *Arg : Args) {
13230 if (Arg->getType()->isWebAssemblyTableType())
13239 {Candidates.begin(), Candidates.end()});
13245 bool ReportedAmbiguousConversions =
false;
13248 unsigned CandsShown = 0;
13249 auto I = Cands.begin(), E = Cands.end();
13250 for (; I != E; ++I) {
13266 "Non-viable built-in candidates are not added to Cands.");
13273 if (!ReportedAmbiguousConversions) {
13275 ReportedAmbiguousConversions =
true;
13288 S.
Diag(OpLoc, diag::note_ovl_too_many_candidates,
13300struct CompareTemplateSpecCandidatesForDisplay {
13302 CompareTemplateSpecCandidatesForDisplay(Sema &S) : S(S) {}
13304 bool operator()(
const TemplateSpecCandidate *L,
13305 const TemplateSpecCandidate *R) {
13336 bool ForTakingAddress) {
13341void TemplateSpecCandidateSet::destroyCandidates() {
13343 i->DeductionFailure.Destroy();
13348 destroyCandidates();
13349 Candidates.clear();
13362 Cands.reserve(
size());
13363 for (
iterator Cand =
begin(), LastCand =
end(); Cand != LastCand; ++Cand) {
13364 if (Cand->Specialization)
13365 Cands.push_back(Cand);
13370 llvm::sort(Cands, CompareTemplateSpecCandidatesForDisplay(S));
13377 unsigned CandsShown = 0;
13378 for (I = Cands.begin(), E = Cands.end(); I != E; ++I) {
13384 if (CandsShown >= 4 && ShowOverloads ==
Ovl_Best)
13389 "Non-matching built-in candidates are not added to Cands.");
13394 S.
Diag(Loc, diag::note_ovl_too_many_candidates) <<
int(E - I);
13404 QualType Ret = PossiblyAFunctionType;
13407 Ret = ToTypePtr->getPointeeType();
13410 Ret = ToTypeRef->getPointeeType();
13413 Ret = MemTypePtr->getPointeeType();
13415 Context.getCanonicalType(Ret).getUnqualifiedType();
13420 bool Complain =
true) {
13437class AddressOfFunctionResolver {
13440 const QualType& TargetType;
13441 QualType TargetFunctionType;
13445 ASTContext& Context;
13447 bool TargetTypeIsNonStaticMemberFunction;
13448 bool FoundNonTemplateFunction;
13449 bool StaticMemberFunctionFromBoundPointer;
13450 bool HasComplained;
13452 OverloadExpr::FindResult OvlExprInfo;
13453 OverloadExpr *OvlExpr;
13454 TemplateArgumentListInfo OvlExplicitTemplateArgs;
13455 SmallVector<std::pair<DeclAccessPair, FunctionDecl*>, 4> Matches;
13456 TemplateSpecCandidateSet FailedCandidates;
13459 AddressOfFunctionResolver(Sema &S, Expr *SourceExpr,
13460 const QualType &TargetType,
bool Complain)
13461 : S(S), SourceExpr(SourceExpr), TargetType(TargetType),
13462 Complain(Complain), Context(S.getASTContext()),
13463 TargetTypeIsNonStaticMemberFunction(
13464 !!TargetType->getAs<MemberPointerType>()),
13465 FoundNonTemplateFunction(
false),
13466 StaticMemberFunctionFromBoundPointer(
false),
13467 HasComplained(
false),
13468 OvlExprInfo(OverloadExpr::find(SourceExpr)),
13470 FailedCandidates(OvlExpr->getNameLoc(),
true) {
13471 ExtractUnqualifiedFunctionTypeFromTargetType();
13474 if (UnresolvedMemberExpr *UME = dyn_cast<UnresolvedMemberExpr>(OvlExpr))
13475 if (!UME->isImplicitAccess() &&
13477 StaticMemberFunctionFromBoundPointer =
true;
13479 DeclAccessPair dap;
13481 OvlExpr,
false, &dap)) {
13482 if (CXXMethodDecl *
Method = dyn_cast<CXXMethodDecl>(Fn))
13483 if (!
Method->isStatic()) {
13487 TargetTypeIsNonStaticMemberFunction =
true;
13495 Matches.push_back(std::make_pair(dap, Fn));
13503 if (FindAllFunctionsThatMatchTargetTypeExactly()) {
13506 if (Matches.size() > 1 && !eliminiateSuboptimalOverloadCandidates()) {
13507 if (FoundNonTemplateFunction) {
13508 EliminateAllTemplateMatches();
13509 EliminateLessPartialOrderingConstrainedMatches();
13511 EliminateAllExceptMostSpecializedTemplate();
13516 EliminateSuboptimalCudaMatches();
13519 bool hasComplained()
const {
return HasComplained; }
13522 bool candidateHasExactlyCorrectType(
const FunctionDecl *FD) {
13529 bool isBetterCandidate(
const FunctionDecl *A,
const FunctionDecl *B) {
13533 return candidateHasExactlyCorrectType(A) &&
13534 (!candidateHasExactlyCorrectType(B) ||
13540 bool eliminiateSuboptimalOverloadCandidates() {
13543 auto Best = Matches.begin();
13544 for (
auto I = Matches.begin()+1, E = Matches.end(); I != E; ++I)
13545 if (isBetterCandidate(I->second, Best->second))
13548 const FunctionDecl *BestFn = Best->second;
13549 auto IsBestOrInferiorToBest = [
this, BestFn](
13550 const std::pair<DeclAccessPair, FunctionDecl *> &Pair) {
13551 return BestFn == Pair.second || isBetterCandidate(BestFn, Pair.second);
13556 if (!llvm::all_of(Matches, IsBestOrInferiorToBest))
13558 Matches[0] = *Best;
13563 bool isTargetTypeAFunction()
const {
13572 void inline ExtractUnqualifiedFunctionTypeFromTargetType() {
13578 const DeclAccessPair& CurAccessFunPair) {
13579 if (CXXMethodDecl *
Method
13583 bool CanConvertToFunctionPointer =
13584 Method->isStatic() ||
Method->isExplicitObjectMemberFunction();
13585 if (CanConvertToFunctionPointer == TargetTypeIsNonStaticMemberFunction)
13588 else if (TargetTypeIsNonStaticMemberFunction)
13598 TemplateDeductionInfo Info(FailedCandidates.
getLocation());
13602 Result != TemplateDeductionResult::Success) {
13620 Matches.push_back(std::make_pair(CurAccessFunPair,
Specialization));
13624 bool AddMatchingNonTemplateFunction(NamedDecl* Fn,
13625 const DeclAccessPair& CurAccessFunPair) {
13626 if (CXXMethodDecl *
Method = dyn_cast<CXXMethodDecl>(Fn)) {
13629 bool CanConvertToFunctionPointer =
13630 Method->isStatic() ||
Method->isExplicitObjectMemberFunction();
13631 if (CanConvertToFunctionPointer == TargetTypeIsNonStaticMemberFunction)
13634 else if (TargetTypeIsNonStaticMemberFunction)
13637 if (FunctionDecl *FunDecl = dyn_cast<FunctionDecl>(Fn)) {
13644 if (FunDecl->isMultiVersion()) {
13645 const auto *TA = FunDecl->getAttr<TargetAttr>();
13646 if (TA && !TA->isDefaultVersion())
13648 const auto *TVA = FunDecl->getAttr<TargetVersionAttr>();
13649 if (TVA && !TVA->isDefaultVersion())
13657 HasComplained |= Complain;
13666 candidateHasExactlyCorrectType(FunDecl)) {
13667 Matches.push_back(std::make_pair(
13669 FoundNonTemplateFunction =
true;
13677 bool FindAllFunctionsThatMatchTargetTypeExactly() {
13682 if (IsInvalidFormOfPointerToMemberFunction())
13685 for (UnresolvedSetIterator I = OvlExpr->
decls_begin(),
13689 NamedDecl *
Fn = (*I)->getUnderlyingDecl();
13698 = dyn_cast<FunctionTemplateDecl>(Fn)) {
13704 AddMatchingNonTemplateFunction(Fn, I.getPair()))
13707 assert(Ret || Matches.empty());
13711 void EliminateAllExceptMostSpecializedTemplate() {
13723 UnresolvedSet<4> MatchesCopy;
13724 for (
unsigned I = 0, E = Matches.size(); I != E; ++I)
13725 MatchesCopy.
addDecl(Matches[I].second, Matches[I].first.getAccess());
13730 MatchesCopy.
begin(), MatchesCopy.
end(), FailedCandidates,
13732 S.
PDiag(diag::err_addr_ovl_ambiguous)
13733 << Matches[0].second->getDeclName(),
13734 S.
PDiag(diag::note_ovl_candidate)
13735 << (
unsigned)oc_function << (
unsigned)ocs_described_template,
13736 Complain, TargetFunctionType);
13740 Matches[0].first = Matches[
Result - MatchesCopy.
begin()].first;
13744 HasComplained |= Complain;
13747 void EliminateAllTemplateMatches() {
13750 for (
unsigned I = 0, N = Matches.size(); I != N; ) {
13751 if (Matches[I].second->getPrimaryTemplate() ==
nullptr)
13754 Matches[I] = Matches[--N];
13760 void EliminateLessPartialOrderingConstrainedMatches() {
13765 assert(Matches[0].second->getPrimaryTemplate() ==
nullptr &&
13766 "Call EliminateAllTemplateMatches() first");
13767 SmallVector<std::pair<DeclAccessPair, FunctionDecl *>, 4> Results;
13768 Results.push_back(Matches[0]);
13769 for (
unsigned I = 1, N = Matches.size(); I < N; ++I) {
13770 assert(Matches[I].second->getPrimaryTemplate() ==
nullptr);
13772 S, Matches[I].second, Results[0].second,
13776 Results.push_back(Matches[I]);
13779 if (F == Matches[I].second) {
13781 Results.push_back(Matches[I]);
13784 std::swap(Matches, Results);
13787 void EliminateSuboptimalCudaMatches() {
13793 void ComplainNoMatchesFound()
const {
13794 assert(Matches.empty());
13796 << OvlExpr->
getName() << TargetFunctionType
13798 if (FailedCandidates.
empty())
13805 for (UnresolvedSetIterator I = OvlExpr->
decls_begin(),
13808 if (FunctionDecl *Fun =
13809 dyn_cast<FunctionDecl>((*I)->getUnderlyingDecl()))
13817 bool IsInvalidFormOfPointerToMemberFunction()
const {
13818 return TargetTypeIsNonStaticMemberFunction &&
13822 void ComplainIsInvalidFormOfPointerToMemberFunction()
const {
13830 bool IsStaticMemberFunctionFromBoundPointer()
const {
13831 return StaticMemberFunctionFromBoundPointer;
13834 void ComplainIsStaticMemberFunctionFromBoundPointer()
const {
13836 diag::err_invalid_form_pointer_member_function)
13840 void ComplainOfInvalidConversion()
const {
13842 << OvlExpr->
getName() << TargetType;
13845 void ComplainMultipleMatchesFound()
const {
13846 assert(Matches.size() > 1);
13853 bool hadMultipleCandidates()
const {
return (OvlExpr->
getNumDecls() > 1); }
13855 int getNumMatches()
const {
return Matches.size(); }
13857 FunctionDecl* getMatchingFunctionDecl()
const {
13858 if (Matches.size() != 1)
return nullptr;
13859 return Matches[0].second;
13862 const DeclAccessPair* getMatchingFunctionAccessPair()
const {
13863 if (Matches.size() != 1)
return nullptr;
13864 return &Matches[0].first;
13874 bool *pHadMultipleCandidates) {
13877 AddressOfFunctionResolver Resolver(*
this, AddressOfExpr, TargetType,
13879 int NumMatches = Resolver.getNumMatches();
13881 bool ShouldComplain = Complain && !Resolver.hasComplained();
13882 if (NumMatches == 0 && ShouldComplain) {
13883 if (Resolver.IsInvalidFormOfPointerToMemberFunction())
13884 Resolver.ComplainIsInvalidFormOfPointerToMemberFunction();
13886 Resolver.ComplainNoMatchesFound();
13888 else if (NumMatches > 1 && ShouldComplain)
13889 Resolver.ComplainMultipleMatchesFound();
13890 else if (NumMatches == 1) {
13891 Fn = Resolver.getMatchingFunctionDecl();
13895 FoundResult = *Resolver.getMatchingFunctionAccessPair();
13897 if (Resolver.IsStaticMemberFunctionFromBoundPointer())
13898 Resolver.ComplainIsStaticMemberFunctionFromBoundPointer();
13904 if (pHadMultipleCandidates)
13905 *pHadMultipleCandidates = Resolver.hadMultipleCandidates();
13913 bool IsResultAmbiguous =
false;
13921 return static_cast<int>(
CUDA().IdentifyPreference(Caller, FD1)) -
13922 static_cast<int>(
CUDA().IdentifyPreference(Caller, FD2));
13929 auto *FD = dyn_cast<FunctionDecl>(I->getUnderlyingDecl());
13937 auto FoundBetter = [&]() {
13938 IsResultAmbiguous =
false;
13950 int PreferenceByCUDA = CheckCUDAPreference(FD,
Result);
13952 if (PreferenceByCUDA != 0) {
13954 if (PreferenceByCUDA > 0)
13970 if (MoreConstrained != FD) {
13971 if (!MoreConstrained) {
13972 IsResultAmbiguous =
true;
13973 AmbiguousDecls.push_back(FD);
13982 if (IsResultAmbiguous)
14003 ExprResult &SrcExpr,
bool DoFunctionPointerConversion) {
14005 assert(E->
getType() ==
Context.OverloadTy &&
"SrcExpr must be an overload");
14009 if (!
Found ||
Found->isCPUDispatchMultiVersion() ||
14010 Found->isCPUSpecificMultiVersion())
14058 dyn_cast<FunctionTemplateDecl>((*I)->getUnderlyingDecl());
14089 if (ForTypeDeduction &&
14103 if (FoundResult) *FoundResult = I.getPair();
14114 ExprResult &SrcExpr,
bool doFunctionPointerConversion,
bool complain,
14116 unsigned DiagIDForComplaining) {
14137 if (!complain)
return false;
14140 diag::err_bound_member_function)
14153 SingleFunctionExpression =
14157 if (doFunctionPointerConversion) {
14158 SingleFunctionExpression =
14160 if (SingleFunctionExpression.
isInvalid()) {
14167 if (!SingleFunctionExpression.
isUsable()) {
14169 Diag(OpRangeForComplaining.
getBegin(), DiagIDForComplaining)
14171 << DestTypeForComplaining
14172 << OpRangeForComplaining
14183 SrcExpr = SingleFunctionExpression;
14193 bool PartialOverloading,
14200 if (ExplicitTemplateArgs) {
14201 assert(!KnownValid &&
"Explicit template arguments?");
14210 PartialOverloading);
14215 = dyn_cast<FunctionTemplateDecl>(Callee)) {
14217 ExplicitTemplateArgs, Args, CandidateSet,
14219 PartialOverloading);
14223 assert(!KnownValid &&
"unhandled case in overloaded call candidate");
14229 bool PartialOverloading) {
14252 assert(!(*I)->getDeclContext()->isRecord());
14254 !(*I)->getDeclContext()->isFunctionOrMethod());
14255 assert((*I)->getUnderlyingDecl()->isFunctionOrFunctionTemplate());
14265 ExplicitTemplateArgs = &TABuffer;
14271 CandidateSet, PartialOverloading,
14276 Args, ExplicitTemplateArgs,
14277 CandidateSet, PartialOverloading);
14285 CandidateSet,
false,
false);
14292 case OO_New:
case OO_Array_New:
14293 case OO_Delete:
case OO_Array_Delete:
14316 if (DC->isTransparentContext())
14332 if (
auto *RD = dyn_cast<CXXRecordDecl>(DC)) {
14337 if (FoundInClass) {
14338 *FoundInClass = RD;
14341 R.
addDecl(Best->FoundDecl.getDecl(), Best->FoundDecl.getAccess());
14358 AssociatedNamespaces,
14359 AssociatedClasses);
14363 for (Sema::AssociatedNamespaceSet::iterator
14364 it = AssociatedNamespaces.begin(),
14365 end = AssociatedNamespaces.end(); it !=
end; ++it) {
14377 SuggestedNamespaces.insert(*it);
14381 SemaRef.
Diag(R.
getNameLoc(), diag::err_not_found_by_two_phase_lookup)
14383 if (SuggestedNamespaces.empty()) {
14384 SemaRef.
Diag(Best->Function->getLocation(),
14385 diag::note_not_found_by_two_phase_lookup)
14387 }
else if (SuggestedNamespaces.size() == 1) {
14388 SemaRef.
Diag(Best->Function->getLocation(),
14389 diag::note_not_found_by_two_phase_lookup)
14395 SemaRef.
Diag(Best->Function->getLocation(),
14396 diag::note_not_found_by_two_phase_lookup)
14428class BuildRecoveryCallExprRAII {
14430 Sema::SatisfactionStackResetRAII SatStack;
14433 BuildRecoveryCallExprRAII(Sema &S) : SemaRef(S), SatStack(S) {
14455 bool EmptyLookup,
bool AllowTypoCorrection) {
14463 BuildRecoveryCallExprRAII RCE(SemaRef);
14473 ExplicitTemplateArgs = &TABuffer;
14481 ExplicitTemplateArgs, Args, &FoundInClass)) {
14483 }
else if (EmptyLookup) {
14488 ExplicitTemplateArgs !=
nullptr,
14489 dyn_cast<MemberExpr>(Fn));
14491 AllowTypoCorrection
14497 }
else if (FoundInClass && SemaRef.
getLangOpts().MSVCCompat) {
14512 assert(!R.
empty() &&
"lookup results empty despite recovery");
14523 if ((*R.
begin())->isCXXClassMember())
14525 ExplicitTemplateArgs, S);
14526 else if (ExplicitTemplateArgs || TemplateKWLoc.
isValid())
14528 ExplicitTemplateArgs);
14552 assert(!ULE->
getQualifier() &&
"qualified name with ADL");
14559 (F = dyn_cast<FunctionDecl>(*ULE->
decls_begin())) &&
14561 llvm_unreachable(
"performing ADL for builtin");
14568 UnbridgedCastsSet UnbridgedCasts;
14583 if (CandidateSet->
empty() ||
14599 if (CandidateSet->
empty())
14602 UnbridgedCasts.restore();
14609 std::optional<QualType> Result;
14621 else if (Result !=
T)
14629 if (Best && *Best != CS.
end())
14630 ConsiderCandidate(**Best);
14633 for (
const auto &
C : CS)
14635 ConsiderCandidate(
C);
14638 for (
const auto &
C : CS)
14639 ConsiderCandidate(
C);
14643 auto Value = *Result;
14644 if (
Value.isNull() ||
Value->isUndeducedType())
14661 bool AllowTypoCorrection) {
14662 switch (OverloadResult) {
14673 Res.
get(), FDecl, LParenLoc, Args, RParenLoc, ExecConfig,
14679 if (*Best != CandidateSet->
end() &&
14683 dyn_cast_if_present<CXXMethodDecl>((*Best)->Function);
14688 SemaRef.
PDiag(diag::err_member_call_without_object) << 0 << M),
14698 CandidateSet->
empty(),
14699 AllowTypoCorrection);
14706 for (
const Expr *Arg : Args) {
14707 if (!Arg->getType()->isFunctionType())
14709 if (
auto *DRE = dyn_cast<DeclRefExpr>(Arg->IgnoreParenImpCasts())) {
14710 auto *FD = dyn_cast<FunctionDecl>(DRE->getDecl());
14713 Arg->getExprLoc()))
14721 SemaRef.
PDiag(diag::err_ovl_no_viable_function_in_call)
14722 << ULE->
getName() << Fn->getSourceRange()),
14730 SemaRef.
PDiag(diag::err_ovl_ambiguous_call)
14731 << ULE->
getName() << Fn->getSourceRange()),
14738 Fn->getSourceRange(), ULE->
getName(),
14739 *CandidateSet, FDecl, Args);
14748 Res.
get(), FDecl, LParenLoc, Args, RParenLoc, ExecConfig,
14756 SubExprs.append(Args.begin(), Args.end());
14763 for (
auto I = CS.
begin(), E = CS.
end(); I != E; ++I) {
14778 bool AllowTypoCorrection,
14779 bool CalleesAddressIsTaken) {
14794 if (CalleesAddressIsTaken)
14805 Best != CandidateSet.
end()) {
14806 if (
auto *M = dyn_cast_or_null<CXXMethodDecl>(Best->Function);
14807 M && M->isImplicitObjectMemberFunction()) {
14818 CUDA().recordPotentialODRUsedVariable(Args, CandidateSet);
14836 if (
const auto *TP =
14846 ExecConfig, &CandidateSet, &Best,
14847 OverloadResult, AllowTypoCorrection);
14856 Context, NamingClass, NNSLoc, DNI, PerformADL, Fns.
begin(), Fns.
end(),
14862 bool HadMultipleCandidates) {
14872 if (
Method->isExplicitObjectMemberFunction())
14876 E, std::nullopt, FoundDecl,
Method);
14880 if (
Method->getParent()->isLambda() &&
14881 Method->getConversionType()->isBlockPointerType()) {
14885 auto *CE = dyn_cast<CastExpr>(SubE);
14886 if (CE && CE->getCastKind() == CK_NoOp)
14887 SubE = CE->getSubExpr();
14889 if (
auto *BE = dyn_cast<CXXBindTemporaryExpr>(SubE))
14890 SubE = BE->getSubExpr();
14913 if (
Method->isExplicitObjectMemberFunction()) {
14919 Expr *ObjectParam = Exp.
get();
14933 Exp.
get()->getEndLoc(),
14947 Expr *Input,
bool PerformADL) {
14949 assert(Op !=
OO_None &&
"Invalid opcode for overloaded unary operator");
14957 Expr *Args[2] = { Input,
nullptr };
14958 unsigned NumArgs = 1;
14963 if (Opc == UO_PostInc || Opc == UO_PostDec) {
14977 if (Opc == UO_PreDec || Opc == UO_PreInc || Opc == UO_Deref)
14988 if (Fn.isInvalid())
15014 bool HadMultipleCandidates = (CandidateSet.
size() > 1);
15033 if (
Method->isExplicitObjectMemberFunction())
15037 Input, std::nullopt, Best->FoundDecl,
Method);
15040 Base = Input = InputInit.
get();
15051 Input = InputInit.
get();
15056 Base, HadMultipleCandidates,
15068 Context, Op, FnExpr.
get(), ArgsArray, ResultTy,
VK, OpLoc,
15084 Input, Best->BuiltinParamTypes[0], Best->Conversions[0],
15089 Input = InputRes.
get();
15109 PDiag(diag::err_ovl_ambiguous_oper_unary)
15126 << (Msg !=
nullptr)
15127 << (Msg ? Msg->
getString() : StringRef())
15180 if (Op != OO_Equal && PerformADL) {
15187 Context.DeclarationNames.getCXXOperatorName(ExtraOp);
15213 Expr *RHS,
bool PerformADL,
15214 bool AllowRewrittenCandidates,
15216 Expr *Args[2] = { LHS, RHS };
15220 AllowRewrittenCandidates =
false;
15226 if (Args[0]->isTypeDependent() || Args[1]->isTypeDependent()) {
15247 if (Fn.isInvalid())
15256 if (Opc == BO_PtrMemD) {
15257 auto CheckPlaceholder = [&](
Expr *&Arg) {
15266 if (CheckPlaceholder(Args[0]) || CheckPlaceholder(Args[1]))
15287 if (Opc == BO_Assign && !Args[0]->
getType()->isOverloadableType())
15293 Op, OpLoc, AllowRewrittenCandidates));
15295 CandidateSet.
exclude(DefaultedFn);
15298 bool HadMultipleCandidates = (CandidateSet.
size() > 1);
15307 bool IsReversed = Best->isReversed();
15309 std::swap(Args[0], Args[1]);
15326 if (Best->RewriteKind && ChosenOp == OO_EqualEqual &&
15330 Diag(OpLoc, IsExtension ? diag::ext_ovl_rewrite_equalequal_not_bool
15331 : diag::err_ovl_rewrite_equalequal_not_bool)
15339 if (AllowRewrittenCandidates && !IsReversed &&
15349 for (
unsigned ArgIdx = 0; ArgIdx < 2; ++ArgIdx) {
15352 Best->Conversions[ArgIdx]) ==
15354 AmbiguousWith.push_back(Cand.
Function);
15361 if (!AmbiguousWith.empty()) {
15362 bool AmbiguousWithSelf =
15363 AmbiguousWith.size() == 1 &&
15365 Diag(OpLoc, diag::ext_ovl_ambiguous_oper_binary_reversed)
15367 << Args[0]->
getType() << Args[1]->
getType() << AmbiguousWithSelf
15369 if (AmbiguousWithSelf) {
15371 diag::note_ovl_ambiguous_oper_binary_reversed_self);
15376 if (
auto *MD = dyn_cast<CXXMethodDecl>(FnDecl))
15377 if (Op == OverloadedOperatorKind::OO_EqualEqual &&
15379 !MD->hasCXXExplicitFunctionObjectParameter() &&
15380 Context.hasSameUnqualifiedType(
15381 MD->getFunctionObjectParameterType(),
15382 MD->getParamDecl(0)->getType().getNonReferenceType()) &&
15383 Context.hasSameUnqualifiedType(
15384 MD->getFunctionObjectParameterType(),
15386 Context.hasSameUnqualifiedType(
15387 MD->getFunctionObjectParameterType(),
15390 diag::note_ovl_ambiguous_eqeq_reversed_self_non_const);
15393 diag::note_ovl_ambiguous_oper_binary_selected_candidate);
15394 for (
auto *F : AmbiguousWith)
15396 diag::note_ovl_ambiguous_oper_binary_reversed_candidate);
15404 if (Op == OO_Equal)
15415 if (
Method->isExplicitObjectMemberFunction()) {
15420 Args[0], std::nullopt, Best->FoundDecl,
Method);
15453 Best->FoundDecl,
Base,
15454 HadMultipleCandidates, OpLoc);
15465 const Expr *ImplicitThis =
nullptr;
15470 Context, ChosenOp, FnExpr.
get(), Args, ResultTy,
VK, OpLoc,
15474 if (
const auto *
Method = dyn_cast<CXXMethodDecl>(FnDecl);
15477 ImplicitThis = ArgsArray[0];
15478 ArgsArray = ArgsArray.slice(1);
15485 if (Op == OO_Equal) {
15490 *
this,
AssignedEntity{Args[0], dyn_cast<CXXMethodDecl>(FnDecl)},
15493 if (ImplicitThis) {
15498 CheckArgAlignment(OpLoc, FnDecl,
"'this'", ThisType,
15502 checkCall(FnDecl,
nullptr, ImplicitThis, ArgsArray,
15517 (Op == OO_Spaceship && IsReversed)) {
15518 if (Op == OO_ExclaimEqual) {
15519 assert(ChosenOp == OO_EqualEqual &&
"unexpected operator name");
15522 assert(ChosenOp == OO_Spaceship &&
"unexpected operator name");
15524 Expr *ZeroLiteral =
15533 OpLoc, Opc, Fns, IsReversed ? ZeroLiteral : R.
get(),
15534 IsReversed ? R.
get() : ZeroLiteral,
true,
15542 assert(ChosenOp == Op &&
"unexpected operator name");
15546 if (Best->RewriteKind !=
CRK_None)
15555 Args[0], Best->BuiltinParamTypes[0], Best->Conversions[0],
15560 Args[0] = ArgsRes0.
get();
15563 Args[1], Best->BuiltinParamTypes[1], Best->Conversions[1],
15568 Args[1] = ArgsRes1.
get();
15578 if (Opc == BO_Comma)
15583 if (DefaultedFn && Opc == BO_Cmp) {
15585 Args[1], DefaultedFn);
15600 Opc >= BO_Assign && Opc <= BO_OrAssign) {
15601 Diag(OpLoc, diag::err_ovl_no_viable_oper)
15604 if (Args[0]->
getType()->isIncompleteType()) {
15605 Diag(OpLoc, diag::note_assign_lhs_incomplete)
15621 assert(
Result.isInvalid() &&
15622 "C++ binary operator overloading is missing candidates!");
15633 << Args[0]->getSourceRange()
15634 << Args[1]->getSourceRange()),
15644 Diag(OpLoc, diag::err_ovl_deleted_special_oper)
15648 Diag(OpLoc, diag::err_ovl_deleted_comparison)
15649 << Args[0]->
getType() << DeletedFD;
15662 PDiag(diag::err_ovl_deleted_oper)
15664 .getCXXOverloadedOperator())
15665 << (Msg !=
nullptr) << (Msg ? Msg->
getString() : StringRef())
15666 << Args[0]->getSourceRange() << Args[1]->getSourceRange()),
15690 "cannot use prvalue expressions more than once");
15691 Expr *OrigLHS = LHS;
15692 Expr *OrigRHS = RHS;
15705 if (
Eq.isInvalid())
15709 true, DefaultedFn);
15710 if (
Less.isInvalid())
15737 for (; I >= 0; --I) {
15739 auto *VI = Info->lookupValueInfo(Comparisons[I].
Result);
15762 Context, OrigLHS, OrigRHS, BO_Cmp,
Result.get()->getType(),
15763 Result.get()->getValueKind(),
Result.get()->getObjectKind(), OpLoc,
15765 Expr *SemanticForm[] = {LHS, RHS,
Result.get()};
15775 unsigned NumArgsSlots =
15776 MethodArgs.size() + std::max<unsigned>(Args.size(), NumParams);
15779 MethodArgs.reserve(MethodArgs.size() + NumArgsSlots);
15780 bool IsError =
false;
15783 for (
unsigned i = 0; i != NumParams; i++) {
15785 if (i < Args.size()) {
15789 S.
Context, Method->getParamDecl(i)),
15803 MethodArgs.push_back(Arg);
15813 Args.push_back(
Base);
15814 for (
auto *e : ArgExpr) {
15818 Context.DeclarationNames.getCXXOperatorName(OO_Subscript);
15823 ArgExpr.back()->getEndLoc());
15835 if (Fn.isInvalid())
15845 UnbridgedCastsSet UnbridgedCasts;
15858 if (Args.size() == 2)
15861 bool HadMultipleCandidates = (CandidateSet.
size() > 1);
15881 if (
Method->isExplicitObjectMemberFunction()) {
15886 Args[0] = Res.
get();
15890 Args[0], std::nullopt, Best->FoundDecl,
Method);
15894 MethodArgs.push_back(Arg0.
get());
15898 *
this, MethodArgs,
Method, ArgExpr, LLoc);
15906 *
this, FnDecl, Best->FoundDecl,
Base, HadMultipleCandidates,
15917 Context, OO_Subscript, FnExpr.
get(), MethodArgs, ResultTy,
VK, RLoc,
15934 Args[0], Best->BuiltinParamTypes[0], Best->Conversions[0],
15939 Args[0] = ArgsRes0.
get();
15942 Args[1], Best->BuiltinParamTypes[1], Best->Conversions[1],
15947 Args[1] = ArgsRes1.
get();
15955 CandidateSet.
empty()
15956 ? (
PDiag(diag::err_ovl_no_oper)
15957 << Args[0]->getType() << 0
15958 << Args[0]->getSourceRange() << Range)
15959 : (
PDiag(diag::err_ovl_no_viable_subscript)
15960 << Args[0]->getType() << Args[0]->getSourceRange() << Range);
15967 if (Args.size() == 2) {
15970 LLoc,
PDiag(diag::err_ovl_ambiguous_oper_binary)
15972 << Args[0]->getSourceRange() << Range),
15977 PDiag(diag::err_ovl_ambiguous_subscript_call)
15979 << Args[0]->getSourceRange() << Range),
15988 PDiag(diag::err_ovl_deleted_oper)
15989 <<
"[]" << (Msg !=
nullptr)
15990 << (Msg ? Msg->
getString() : StringRef())
15991 << Args[0]->getSourceRange() << Range),
16005 Expr *ExecConfig,
bool IsExecConfig,
16006 bool AllowRecovery) {
16015 if (
BinaryOperator *op = dyn_cast<BinaryOperator>(NakedMemExpr)) {
16016 assert(op->getType() ==
Context.BoundMemberTy);
16017 assert(op->getOpcode() == BO_PtrMemD || op->getOpcode() == BO_PtrMemI);
16030 QualType objectType = op->getLHS()->getType();
16031 if (op->getOpcode() == BO_PtrMemI)
16035 Qualifiers difference = objectQuals - funcQuals;
16039 std::string qualsString = difference.
getAsString();
16040 Diag(LParenLoc, diag::err_pointer_to_member_call_drops_quals)
16043 << (qualsString.find(
' ') == std::string::npos ? 1 : 2);
16047 Context, MemExprE, Args, resultType, valueKind, RParenLoc,
16057 if (CheckOtherCall(call, proto))
16067 if (!AllowRecovery)
16069 std::vector<Expr *> SubExprs = {MemExprE};
16070 llvm::append_range(SubExprs, Args);
16078 UnbridgedCastsSet UnbridgedCasts;
16084 bool HadMultipleCandidates =
false;
16092 UnbridgedCasts.restore();
16110 TemplateArgs = &TemplateArgsBuffer;
16114 E = UnresExpr->
decls_end(); I != E; ++I) {
16116 QualType ExplicitObjectType = ObjectType;
16123 bool HasExplicitParameter =
false;
16124 if (
const auto *M = dyn_cast<FunctionDecl>(
Func);
16125 M && M->hasCXXExplicitFunctionObjectParameter())
16126 HasExplicitParameter =
true;
16127 else if (
const auto *M = dyn_cast<FunctionTemplateDecl>(
Func);
16129 M->getTemplatedDecl()->hasCXXExplicitFunctionObjectParameter())
16130 HasExplicitParameter =
true;
16132 if (HasExplicitParameter)
16140 }
else if ((
Method = dyn_cast<CXXMethodDecl>(
Func))) {
16147 ObjectClassification, Args, CandidateSet,
16151 I.getPair(), ActingDC, TemplateArgs,
16152 ExplicitObjectType, ObjectClassification,
16153 Args, CandidateSet,
16158 HadMultipleCandidates = (CandidateSet.
size() > 1);
16162 UnbridgedCasts.restore();
16165 bool Succeeded =
false;
16170 FoundDecl = Best->FoundDecl;
16190 PDiag(diag::err_ovl_no_viable_member_function_in_call)
16197 PDiag(diag::err_ovl_ambiguous_member_call)
16204 CandidateSet, Best->Function, Args,
true);
16215 MemExprE = Res.
get();
16219 if (
Method->isStatic()) {
16221 ExecConfig, IsExecConfig);
16231 assert(
Method &&
"Member call to something that isn't a method?");
16236 if (
Method->isExplicitObjectMemberFunction()) {
16244 HadMultipleCandidates, MemExpr->
getExprLoc());
16251 TheCall->setUsesMemberSyntax(
true);
16261 Proto->getNumParams());
16267 return BuildRecoveryExpr(ResultType);
16272 return BuildRecoveryExpr(ResultType);
16282 if (
auto *MemE = dyn_cast<MemberExpr>(NakedMemExpr)) {
16283 if (
const EnableIfAttr *
Attr =
16285 Diag(MemE->getMemberLoc(),
16286 diag::err_ovl_no_viable_member_function_in_call)
16289 diag::note_ovl_candidate_disabled_by_function_cond_attr)
16290 <<
Attr->getCond()->getSourceRange() <<
Attr->getMessage();
16296 TheCall->getDirectCallee()->isPureVirtual()) {
16302 diag::warn_call_to_pure_virtual_member_function_from_ctor_dtor)
16313 if (
auto *DD = dyn_cast<CXXDestructorDecl>(TheCall->getDirectCallee())) {
16317 CallCanBeVirtual,
true,
16322 TheCall->getDirectCallee());
16334 UnbridgedCastsSet UnbridgedCasts;
16338 assert(Object.get()->getType()->isRecordType() &&
16339 "Requires object type argument");
16353 diag::err_incomplete_object_call, Object.get()))
16356 auto *
Record = Object.get()->getType()->castAsCXXRecordDecl();
16362 Oper != OperEnd; ++Oper) {
16364 Object.get()->Classify(
Context), Args, CandidateSet,
16376 bool IgnoreSurrogateFunctions =
false;
16379 if (!Candidate.
Viable &&
16381 IgnoreSurrogateFunctions =
true;
16403 !IgnoreSurrogateFunctions && I != E; ++I) {
16425 Object.get(), Args, CandidateSet);
16430 bool HadMultipleCandidates = (CandidateSet.
size() > 1);
16443 CandidateSet.
empty()
16444 ? (
PDiag(diag::err_ovl_no_oper)
16445 << Object.get()->getType() << 1
16446 << Object.get()->getSourceRange())
16447 : (
PDiag(diag::err_ovl_no_viable_object_call)
16448 << Object.get()->getType() << Object.get()->getSourceRange());
16458 PDiag(diag::err_ovl_ambiguous_object_call)
16459 << Object.get()->getType()
16460 << Object.get()->getSourceRange()),
16471 PDiag(diag::err_ovl_deleted_object_call)
16472 << Object.get()->getType() << (Msg !=
nullptr)
16473 << (Msg ? Msg->
getString() : StringRef())
16474 << Object.get()->getSourceRange()),
16480 if (Best == CandidateSet.
end())
16483 UnbridgedCasts.restore();
16485 if (Best->Function ==
nullptr) {
16490 Best->Conversions[0].UserDefined.ConversionFunction);
16496 assert(Conv == Best->FoundDecl.getDecl() &&
16497 "Found Decl & conversion-to-functionptr should be same, right?!");
16505 Conv, HadMultipleCandidates);
16506 if (
Call.isInvalid())
16510 Context,
Call.get()->getType(), CK_UserDefinedConversion,
Call.get(),
16524 if (
Method->isInvalidDecl())
16531 Context.DeclarationNames.getCXXOperatorName(OO_Call), LParenLoc);
16534 Obj, HadMultipleCandidates,
16541 MethodArgs.reserve(NumParams + 1);
16543 bool IsError =
false;
16547 if (
Method->isExplicitObjectMemberFunction()) {
16551 Object.get(), std::nullopt, Best->FoundDecl,
Method);
16556 MethodArgs.push_back(Object.get());
16560 *
this, MethodArgs,
Method, Args, LParenLoc);
16563 if (Proto->isVariadic()) {
16565 for (
unsigned i = NumParams, e = Args.size(); i < e; i++) {
16569 MethodArgs.push_back(Arg.
get());
16584 Context, OO_Call, NewFn.
get(), MethodArgs, ResultTy,
VK, RParenLoc,
16598 bool *NoArrowOperatorFound) {
16599 assert(
Base->getType()->isRecordType() &&
16600 "left-hand side must have class type");
16614 Context.DeclarationNames.getCXXOperatorName(OO_Arrow);
16618 diag::err_typecheck_incomplete_tag,
Base))
16626 Oper != OperEnd; ++Oper) {
16632 bool HadMultipleCandidates = (CandidateSet.
size() > 1);
16643 if (CandidateSet.
empty()) {
16645 if (NoArrowOperatorFound) {
16648 *NoArrowOperatorFound =
true;
16651 Diag(OpLoc, diag::err_typecheck_member_reference_arrow)
16652 << BaseType <<
Base->getSourceRange();
16653 if (BaseType->isRecordType() && !BaseType->isPointerType()) {
16654 Diag(OpLoc, diag::note_typecheck_member_reference_suggestion)
16658 Diag(OpLoc, diag::err_ovl_no_viable_oper)
16659 <<
"operator->" <<
Base->getSourceRange();
16667 <<
"->" <<
Base->getType()
16668 <<
Base->getSourceRange()),
16676 <<
"->" << (Msg !=
nullptr)
16677 << (Msg ? Msg->
getString() : StringRef())
16678 <<
Base->getSourceRange()),
16689 if (
Method->isExplicitObjectMemberFunction()) {
16696 Base, std::nullopt, Best->FoundDecl,
Method);
16704 Base, HadMultipleCandidates, OpLoc);
16738 bool HadMultipleCandidates = (CandidateSet.
size() > 1);
16751 PDiag(diag::err_ovl_no_viable_function_in_call)
16766 nullptr, HadMultipleCandidates,
16769 if (Fn.isInvalid())
16775 for (
unsigned ArgIdx = 0, N = Args.size(); ArgIdx != N; ++ArgIdx) {
16781 ConvArgs[ArgIdx] = InputInit.
get();
16808 Scope *S =
nullptr;
16811 if (!MemberLookup.
empty()) {
16838 if (CandidateSet->
empty() || CandidateSetError) {
16851 Loc,
nullptr, CandidateSet, &Best,
16864 if (
ParenExpr *PE = dyn_cast<ParenExpr>(E)) {
16869 if (SubExpr.
get() == PE->getSubExpr())
16873 ParenExpr(PE->getLParen(), PE->getRParen(), SubExpr.
get());
16881 assert(
Context.hasSameType(ICE->getSubExpr()->getType(),
16883 "Implicit cast type cannot be determined from overload");
16884 assert(ICE->path_empty() &&
"fixing up hierarchy conversion?");
16885 if (SubExpr.
get() == ICE->getSubExpr())
16893 if (
auto *GSE = dyn_cast<GenericSelectionExpr>(E)) {
16894 if (!GSE->isResultDependent()) {
16899 if (SubExpr.
get() == GSE->getResultExpr())
16906 unsigned ResultIdx = GSE->getResultIndex();
16907 AssocExprs[ResultIdx] = SubExpr.
get();
16909 if (GSE->isExprPredicate())
16911 Context, GSE->getGenericLoc(), GSE->getControllingExpr(),
16912 GSE->getAssocTypeSourceInfos(), AssocExprs, GSE->getDefaultLoc(),
16913 GSE->getRParenLoc(), GSE->containsUnexpandedParameterPack(),
16916 Context, GSE->getGenericLoc(), GSE->getControllingType(),
16917 GSE->getAssocTypeSourceInfos(), AssocExprs, GSE->getDefaultLoc(),
16918 GSE->getRParenLoc(), GSE->containsUnexpandedParameterPack(),
16927 assert(UnOp->getOpcode() == UO_AddrOf &&
16928 "Can only take the address of an overloaded function");
16930 if (!
Method->isImplicitObjectMemberFunction()) {
16941 if (SubExpr.
get() == UnOp->getSubExpr())
16949 "fixed to something other than a decl ref");
16952 assert(Qualifier &&
16953 "fixed to a member ref with no nested name qualifier");
16959 Fn->getType(), Qualifier,
16962 if (
Context.getTargetInfo().getCXXABI().isMicrosoft())
16967 UnOp->getOperatorLoc(),
false,
16975 if (SubExpr.
get() == UnOp->getSubExpr())
16988 if (ULE->hasExplicitTemplateArgs()) {
16989 ULE->copyTemplateArgumentsInto(TemplateArgsBuffer);
16990 TemplateArgs = &TemplateArgsBuffer;
16995 getLangOpts().CPlusPlus && !Fn->hasCXXExplicitFunctionObjectParameter()
17000 if (
unsigned BID = Fn->getBuiltinID()) {
17001 if (!
Context.BuiltinInfo.isDirectlyAddressable(BID)) {
17008 Fn,
Type, ValueKind, ULE->getNameInfo(), ULE->getQualifierLoc(),
17009 Found.getDecl(), ULE->getTemplateKeywordLoc(), TemplateArgs);
17017 if (MemExpr->hasExplicitTemplateArgs()) {
17018 MemExpr->copyTemplateArgumentsInto(TemplateArgsBuffer);
17019 TemplateArgs = &TemplateArgsBuffer;
17026 if (MemExpr->isImplicitAccess()) {
17029 Fn, Fn->getType(),
VK_LValue, MemExpr->getNameInfo(),
17030 MemExpr->getQualifierLoc(),
Found.getDecl(),
17031 MemExpr->getTemplateKeywordLoc(), TemplateArgs);
17036 if (MemExpr->getQualifier())
17037 Loc = MemExpr->getQualifierLoc().getBeginLoc();
17042 Base = MemExpr->getBase();
17048 type = Fn->getType();
17055 Base, MemExpr->isArrow(), MemExpr->getOperatorLoc(),
17056 MemExpr->getQualifierLoc(), MemExpr->getTemplateKeywordLoc(), Fn,
Found,
17057 true, MemExpr->getMemberNameInfo(),
17061 llvm_unreachable(
"Invalid reference to overloaded function");
17072 if (!PartialOverloading || !
Function)
17076 if (
const auto *Proto =
17077 dyn_cast<FunctionProtoType>(
Function->getFunctionType()))
17078 if (Proto->isTemplateVariadic())
17080 if (
auto *Pattern =
Function->getTemplateInstantiationPattern())
17081 if (
const auto *Proto =
17082 dyn_cast<FunctionProtoType>(Pattern->getFunctionType()))
17083 if (Proto->isTemplateVariadic())
17096 << IsMember << Name << (Msg !=
nullptr)
17097 << (Msg ? Msg->
getString() : StringRef())
Defines the clang::ASTContext interface.
Defines the Diagnostic-related interfaces.
static bool isBooleanType(QualType Ty)
Defines the C++ Decl subclasses, other than those for templates (found in DeclTemplate....
Defines the clang::Expr interface and subclasses for C++ expressions.
static const GlobalDecl isTemplate(GlobalDecl GD, const TemplateArgumentList *&TemplateArgs)
static DiagnosticBuilder Diag(DiagnosticsEngine *Diags, const LangOptions &Features, FullSourceLoc TokLoc, const char *TokBegin, const char *TokRangeBegin, const char *TokRangeEnd, unsigned DiagID)
Produce a diagnostic highlighting some portion of a literal.
llvm::MachO::Record Record
Defines an enumeration for C++ overloaded operators.
Implements a partial diagnostic that can be emitted anwyhere in a DiagnosticBuilder stream.
This file declares semantic analysis functions specific to ARM.
static bool hasAttr(const Decl *D, bool IgnoreImplicitAttr)
static bool hasExplicitAttr(const VarDecl *D)
This file declares semantic analysis for CUDA constructs.
static void BuildBasePathArray(const CXXBasePath &Path, CXXCastPath &BasePathArray)
static bool isRecordType(QualType T)
static void TryUserDefinedConversion(Sema &S, QualType DestType, const InitializationKind &Kind, Expr *Initializer, InitializationSequence &Sequence, bool TopLevelOfInitList)
Attempt a user-defined conversion between two types (C++ [dcl.init]), which enumerates all conversion...
This file declares semantic analysis for Objective-C.
static ImplicitConversionSequence::CompareKind CompareStandardConversionSequences(Sema &S, SourceLocation Loc, const StandardConversionSequence &SCS1, const StandardConversionSequence &SCS2)
CompareStandardConversionSequences - Compare two standard conversion sequences to determine whether o...
static bool sameFunctionParameterTypeLists(Sema &S, FunctionDecl *Fn1, FunctionDecl *Fn2, bool IsFn1Reversed, bool IsFn2Reversed)
We're allowed to use constraints partial ordering only if the candidates have the same parameter type...
static bool isNullPointerConstantForConversion(Expr *Expr, bool InOverloadResolution, ASTContext &Context)
static bool shouldSkipNotingLambdaConversionDecl(const FunctionDecl *Fn)
static const FunctionType * getConversionOpReturnTyAsFunction(CXXConversionDecl *Conv)
static bool functionHasPassObjectSizeParams(const FunctionDecl *FD)
static Comparison compareEnableIfAttrs(const Sema &S, const FunctionDecl *Cand1, const FunctionDecl *Cand2)
Compares the enable_if attributes of two FunctionDecls, for the purposes of overload resolution.
static Qualifiers CollectVRQualifiers(ASTContext &Context, Expr *ArgExpr)
CollectVRQualifiers - This routine returns Volatile/Restrict qualifiers, if any, found in visible typ...
@ ToPromotedUnderlyingType
static void AddOverloadedCallCandidate(Sema &S, DeclAccessPair FoundDecl, TemplateArgumentListInfo *ExplicitTemplateArgs, ArrayRef< Expr * > Args, OverloadCandidateSet &CandidateSet, bool PartialOverloading, bool KnownValid)
Add a single candidate to the overload set.
static void AddTemplateOverloadCandidateImmediately(Sema &S, OverloadCandidateSet &CandidateSet, FunctionTemplateDecl *FunctionTemplate, DeclAccessPair FoundDecl, TemplateArgumentListInfo *ExplicitTemplateArgs, ArrayRef< Expr * > Args, bool SuppressUserConversions, bool PartialOverloading, bool AllowExplicit, Sema::ADLCallKind IsADLCandidate, OverloadCandidateParamOrder PO, bool AggregateCandidateDeduction)
static ExprResult FinishOverloadedCallExpr(Sema &SemaRef, Scope *S, Expr *Fn, UnresolvedLookupExpr *ULE, SourceLocation LParenLoc, MultiExprArg Args, SourceLocation RParenLoc, Expr *ExecConfig, OverloadCandidateSet *CandidateSet, OverloadCandidateSet::iterator *Best, OverloadingResult OverloadResult, bool AllowTypoCorrection)
FinishOverloadedCallExpr - given an OverloadCandidateSet, builds and returns the completed call expre...
static bool isQualificationConversionStep(QualType FromType, QualType ToType, bool CStyle, bool IsTopLevel, bool &PreviousToQualsIncludeConst, bool &ObjCLifetimeConversion, const ASTContext &Ctx)
Perform a single iteration of the loop for checking if a qualification conversion is valid.
static ImplicitConversionSequence::CompareKind CompareQualificationConversions(Sema &S, const StandardConversionSequence &SCS1, const StandardConversionSequence &SCS2)
CompareQualificationConversions - Compares two standard conversion sequences to determine whether the...
static void dropPointerConversion(StandardConversionSequence &SCS)
dropPointerConversions - If the given standard conversion sequence involves any pointer conversions,...
static SourceLocation GetLocationForCandidate(const OverloadCandidate *Cand)
static void DiagnoseArityMismatch(Sema &S, NamedDecl *Found, Decl *D, unsigned NumFormalArgs, bool IsAddressOf=false)
General arity mismatch diagnosis over a candidate in a candidate set.
static const Expr * IgnoreNarrowingConversion(ASTContext &Ctx, const Expr *Converted)
Skip any implicit casts which could be either part of a narrowing conversion or after one in an impli...
static bool allowAmbiguity(ASTContext &Context, const FunctionDecl *F1, const FunctionDecl *F2)
static unsigned RankDeductionFailure(const DeductionFailureInfo &DFI)
static QualType BuildSimilarlyQualifiedPointerType(const Type *FromPtr, QualType ToPointee, QualType ToType, ASTContext &Context, bool StripObjCLifetime=false)
BuildSimilarlyQualifiedPointerType - In a pointer conversion from the pointer type FromPtr to a point...
static void forAllQualifierCombinations(QualifiersAndAtomic Quals, llvm::function_ref< void(QualifiersAndAtomic)> Callback)
static bool FindConversionForRefInit(Sema &S, ImplicitConversionSequence &ICS, QualType DeclType, SourceLocation DeclLoc, Expr *Init, QualType T2, bool AllowRvalues, bool AllowExplicit)
Look for a user-defined conversion to a value reference-compatible with DeclType.
static bool tryAtomicConversion(Sema &S, Expr *From, QualType ToType, bool InOverloadResolution, StandardConversionSequence &SCS, bool CStyle)
static Expr * GetExplicitObjectExpr(Sema &S, Expr *Obj, const FunctionDecl *Fun)
static bool hasDeprecatedStringLiteralToCharPtrConversion(const ImplicitConversionSequence &ICS)
static void AddBuiltinAssignmentOperatorCandidates(Sema &S, QualType T, ArrayRef< Expr * > Args, OverloadCandidateSet &CandidateSet)
Helper function for AddBuiltinOperatorCandidates() that adds the volatile- and non-volatile-qualified...
static bool CheckConvertedConstantConversions(Sema &S, StandardConversionSequence &SCS)
Check that the specified conversion is permitted in a converted constant expression,...
static void NoteBuiltinOperatorCandidate(Sema &S, StringRef Opc, SourceLocation OpLoc, OverloadCandidate *Cand)
static ImplicitConversionSequence::CompareKind compareConversionFunctions(Sema &S, FunctionDecl *Function1, FunctionDecl *Function2)
Compare the user-defined conversion functions or constructors of two user-defined conversion sequence...
static void forAllQualifierCombinationsImpl(QualifiersAndAtomic Available, QualifiersAndAtomic Applied, llvm::function_ref< void(QualifiersAndAtomic)> Callback)
static const char * GetImplicitConversionName(ImplicitConversionKind Kind)
GetImplicitConversionName - Return the name of this kind of implicit conversion.
static bool checkAddressOfFunctionIsAvailable(Sema &S, const FunctionDecl *FD, bool Complain, bool InOverloadResolution, SourceLocation Loc)
Returns true if we can take the address of the function.
static ImplicitConversionSequence::CompareKind CompareDerivedToBaseConversions(Sema &S, SourceLocation Loc, const StandardConversionSequence &SCS1, const StandardConversionSequence &SCS2)
CompareDerivedToBaseConversions - Compares two standard conversion sequences to determine whether the...
static bool convertArgsForAvailabilityChecks(Sema &S, FunctionDecl *Function, Expr *ThisArg, SourceLocation CallLoc, ArrayRef< Expr * > Args, Sema::SFINAETrap &Trap, bool MissingImplicitThis, Expr *&ConvertedThis, SmallVectorImpl< Expr * > &ConvertedArgs)
static TemplateDecl * getDescribedTemplate(Decl *Templated)
static void CompleteNonViableCandidate(Sema &S, OverloadCandidate *Cand, ArrayRef< Expr * > Args, OverloadCandidateSet::CandidateSetKind CSK)
CompleteNonViableCandidate - Normally, overload resolution only computes up to the first bad conversi...
static QualType AdoptQualifiers(ASTContext &Context, QualType T, Qualifiers Qs)
Adopt the given qualifiers for the given type.
static void NoteAmbiguousUserConversions(Sema &S, SourceLocation OpLoc, OverloadCandidate *Cand)
static bool CheckArityMismatch(Sema &S, OverloadCandidate *Cand, unsigned NumArgs, bool IsAddressOf=false)
Additional arity mismatch diagnosis specific to a function overload candidates.
static ImplicitConversionSequence::CompareKind compareStandardConversionSubsets(ASTContext &Context, const StandardConversionSequence &SCS1, const StandardConversionSequence &SCS2)
static bool hasDependentExplicit(FunctionTemplateDecl *FTD)
static bool IsVectorConversion(Sema &S, QualType FromType, QualType ToType, ImplicitConversionKind &ICK, ImplicitConversionKind &ElConv, Expr *From, bool InOverloadResolution, bool CStyle)
Determine whether the conversion from FromType to ToType is a valid vector conversion.
static ImplicitConversionSequence TryContextuallyConvertToObjCPointer(Sema &S, Expr *From)
TryContextuallyConvertToObjCPointer - Attempt to contextually convert the expression From to an Objec...
static ExprResult CheckConvertedConstantExpression(Sema &S, Expr *From, QualType T, APValue &Value, CCEKind CCE, bool RequireInt, NamedDecl *Dest)
CheckConvertedConstantExpression - Check that the expression From is a converted constant expression ...
static ExprResult CreateFunctionRefExpr(Sema &S, FunctionDecl *Fn, NamedDecl *FoundDecl, const Expr *Base, bool HadMultipleCandidates, SourceLocation Loc=SourceLocation(), const DeclarationNameLoc &LocInfo=DeclarationNameLoc())
A convenience routine for creating a decayed reference to a function.
static std::optional< QualType > getImplicitObjectParamType(ASTContext &Context, const FunctionDecl *F)
Compute the type of the implicit object parameter for the given function, if any.
static bool checkPlaceholderForOverload(Sema &S, Expr *&E, UnbridgedCastsSet *unbridgedCasts=nullptr)
checkPlaceholderForOverload - Do any interesting placeholder-like preprocessing on the given expressi...
static FixedEnumPromotion getFixedEnumPromtion(Sema &S, const StandardConversionSequence &SCS)
Returns kind of fixed enum promotion the SCS uses.
static bool isAllowableExplicitConversion(Sema &S, QualType ConvType, QualType ToType, bool AllowObjCPointerConversion)
Determine whether this is an allowable conversion from the result of an explicit conversion operator ...
static bool isNonViableMultiVersionOverload(FunctionDecl *FD)
static bool FunctionsCorrespond(ASTContext &Ctx, const FunctionDecl *X, const FunctionDecl *Y)
static ImplicitConversionSequence TryImplicitConversion(Sema &S, Expr *From, QualType ToType, bool SuppressUserConversions, AllowedExplicit AllowExplicit, bool InOverloadResolution, bool CStyle, bool AllowObjCWritebackConversion, bool AllowObjCConversionOnExplicit)
TryImplicitConversion - Attempt to perform an implicit conversion from the given expression (Expr) to...
static ExprResult BuildConvertedConstantExpression(Sema &S, Expr *From, QualType T, CCEKind CCE, NamedDecl *Dest, APValue &PreNarrowingValue)
BuildConvertedConstantExpression - Check that the expression From is a converted constant expression ...
static bool IsVectorElementConversion(Sema &S, QualType FromType, QualType ToType, ImplicitConversionKind &ICK, Expr *From)
static ImplicitConversionSequence TryListConversion(Sema &S, InitListExpr *From, QualType ToType, bool SuppressUserConversions, bool InOverloadResolution, bool AllowObjCWritebackConversion)
TryListConversion - Try to copy-initialize a value of type ToType from the initializer list From.
static bool IsOverloadOrOverrideImpl(Sema &SemaRef, FunctionDecl *New, FunctionDecl *Old, bool UseMemberUsingDeclRules, bool ConsiderCudaAttrs, bool UseOverrideRules=false)
static QualType withoutUnaligned(ASTContext &Ctx, QualType T)
static void DiagnoseBadTarget(Sema &S, OverloadCandidate *Cand)
CUDA: diagnose an invalid call across targets.
static void MaybeDiagnoseAmbiguousConstraints(Sema &S, ArrayRef< OverloadCandidate > Cands)
static bool diagnoseNoViableConversion(Sema &SemaRef, SourceLocation Loc, Expr *&From, Sema::ContextualImplicitConverter &Converter, QualType T, bool HadMultipleCandidates, UnresolvedSetImpl &ExplicitConversions)
static void AddMethodTemplateCandidateImmediately(Sema &S, OverloadCandidateSet &CandidateSet, FunctionTemplateDecl *MethodTmpl, DeclAccessPair FoundDecl, CXXRecordDecl *ActingContext, TemplateArgumentListInfo *ExplicitTemplateArgs, QualType ObjectType, Expr::Classification ObjectClassification, ArrayRef< Expr * > Args, bool SuppressUserConversions, bool PartialOverloading, OverloadCandidateParamOrder PO)
static void AddTemplateConversionCandidateImmediately(Sema &S, OverloadCandidateSet &CandidateSet, FunctionTemplateDecl *FunctionTemplate, DeclAccessPair FoundDecl, CXXRecordDecl *ActingContext, Expr *From, QualType ToType, bool AllowObjCConversionOnExplicit, bool AllowExplicit, bool AllowResultConversion)
static ImplicitConversionSequence TryContextuallyConvertToBool(Sema &S, Expr *From)
TryContextuallyConvertToBool - Attempt to contextually convert the expression From to bool (C++0x [co...
static ImplicitConversionSequence TryObjectArgumentInitialization(Sema &S, SourceLocation Loc, QualType FromType, Expr::Classification FromClassification, CXXMethodDecl *Method, const CXXRecordDecl *ActingContext, bool InOverloadResolution=false, QualType ExplicitParameterType=QualType(), bool SuppressUserConversion=false)
TryObjectArgumentInitialization - Try to initialize the object parameter of the given member function...
static bool recordConversion(Sema &SemaRef, SourceLocation Loc, Expr *&From, Sema::ContextualImplicitConverter &Converter, QualType T, bool HadMultipleCandidates, DeclAccessPair &Found)
static ImplicitConversionSequence::CompareKind CompareImplicitConversionSequences(Sema &S, SourceLocation Loc, const ImplicitConversionSequence &ICS1, const ImplicitConversionSequence &ICS2)
CompareImplicitConversionSequences - Compare two implicit conversion sequences to determine whether o...
static void NoteFunctionCandidate(Sema &S, OverloadCandidate *Cand, unsigned NumArgs, bool TakingCandidateAddress, LangAS CtorDestAS=LangAS::Default)
Generates a 'note' diagnostic for an overload candidate.
static ImplicitConversionSequence TryCopyInitialization(Sema &S, Expr *From, QualType ToType, bool SuppressUserConversions, bool InOverloadResolution, bool AllowObjCWritebackConversion, bool AllowExplicit=false)
TryCopyInitialization - Try to copy-initialize a value of type ToType from the expression From.
static ExprResult diagnoseAmbiguousConversion(Sema &SemaRef, SourceLocation Loc, Expr *From, Sema::ContextualImplicitConverter &Converter, QualType T, UnresolvedSetImpl &ViableConversions)
static void markUnaddressableCandidatesUnviable(Sema &S, OverloadCandidateSet &CS)
static QualType GetExplicitObjectType(Sema &S, const Expr *MemExprE)
Sema::AllowedExplicit AllowedExplicit
static QualType AdjustAddressSpaceForBuiltinOperandType(Sema &S, QualType T, Expr *Arg)
Helper function for adjusting address spaces for the pointer or reference operands of builtin operato...
static void DiagnoseFailedExplicitSpec(Sema &S, OverloadCandidate *Cand)
static bool DiagnoseTwoPhaseLookup(Sema &SemaRef, SourceLocation FnLoc, const CXXScopeSpec &SS, LookupResult &R, OverloadCandidateSet::CandidateSetKind CSK, TemplateArgumentListInfo *ExplicitTemplateArgs, ArrayRef< Expr * > Args, CXXRecordDecl **FoundInClass=nullptr)
Attempt to recover from an ill-formed use of a non-dependent name in a template, where the non-depend...
static bool isBetterReferenceBindingKind(const StandardConversionSequence &SCS1, const StandardConversionSequence &SCS2)
Determine whether one of the given reference bindings is better than the other based on what kind of ...
static bool canBeDeclaredInNamespace(const DeclarationName &Name)
Determine whether a declaration with the specified name could be moved into a different namespace.
static ExprResult finishContextualImplicitConversion(Sema &SemaRef, SourceLocation Loc, Expr *From, Sema::ContextualImplicitConverter &Converter)
static bool IsStandardConversion(Sema &S, Expr *From, QualType ToType, bool InOverloadResolution, StandardConversionSequence &SCS, bool CStyle, bool AllowObjCWritebackConversion)
IsStandardConversion - Determines whether there is a standard conversion sequence (C++ [conv],...
static bool DiagnoseTwoPhaseOperatorLookup(Sema &SemaRef, OverloadedOperatorKind Op, SourceLocation OpLoc, ArrayRef< Expr * > Args)
Attempt to recover from ill-formed use of a non-dependent operator in a template, where the non-depen...
static bool isNonTrivialObjCLifetimeConversion(Qualifiers FromQuals, Qualifiers ToQuals)
Determine whether the lifetime conversion between the two given qualifiers sets is nontrivial.
static void DiagnoseBadConversion(Sema &S, OverloadCandidate *Cand, unsigned I, bool TakingCandidateAddress)
static bool completeFunctionType(Sema &S, FunctionDecl *FD, SourceLocation Loc, bool Complain=true)
static bool shouldAddReversedEqEq(Sema &S, SourceLocation OpLoc, Expr *FirstOperand, FunctionDecl *EqFD)
static bool isFunctionAlwaysEnabled(const ASTContext &Ctx, const FunctionDecl *FD)
static bool PrepareExplicitObjectArgument(Sema &S, CXXMethodDecl *Method, Expr *Object, MultiExprArg &Args, SmallVectorImpl< Expr * > &NewArgs)
static OverloadingResult IsInitializerListConstructorConversion(Sema &S, Expr *From, QualType ToType, CXXRecordDecl *To, UserDefinedConversionSequence &User, OverloadCandidateSet &CandidateSet, bool AllowExplicit)
static bool checkAddressOfCandidateIsAvailable(Sema &S, const FunctionDecl *FD)
static bool IsFloatingPointConversion(Sema &S, QualType FromType, QualType ToType)
Determine whether the conversion from FromType to ToType is a valid floating point conversion.
static bool isFirstArgumentCompatibleWithType(ASTContext &Context, CXXConstructorDecl *Constructor, QualType Type)
static Comparison isBetterMultiversionCandidate(const OverloadCandidate &Cand1, const OverloadCandidate &Cand2)
static void NoteImplicitDeductionGuide(Sema &S, FunctionDecl *Fn)
static void collectViableConversionCandidates(Sema &SemaRef, Expr *From, QualType ToType, UnresolvedSetImpl &ViableConversions, OverloadCandidateSet &CandidateSet)
static ImplicitConversionSequence TryReferenceInit(Sema &S, Expr *Init, QualType DeclType, SourceLocation DeclLoc, bool SuppressUserConversions, bool AllowExplicit)
Compute an implicit conversion sequence for reference initialization.
static bool isNonDependentlyExplicit(FunctionTemplateDecl *FTD)
Determine whether a given function template has a simple explicit specifier or a non-value-dependent ...
static bool checkArgPlaceholdersForOverload(Sema &S, MultiExprArg Args, UnbridgedCastsSet &unbridged)
checkArgPlaceholdersForOverload - Check a set of call operands for placeholders.
static QualType makeQualifiedLValueReferenceType(QualType Base, QualifiersAndAtomic Quals, Sema &S)
static QualType chooseRecoveryType(OverloadCandidateSet &CS, OverloadCandidateSet::iterator *Best)
static void AddTemplateOverloadCandidate(Sema &S, OverloadCandidateSet &CandidateSet, DeferredMethodTemplateOverloadCandidate &C)
static void NoteSurrogateCandidate(Sema &S, OverloadCandidate *Cand)
static ExprResult BuildRecoveryCallExpr(Sema &SemaRef, Scope *S, Expr *Fn, UnresolvedLookupExpr *ULE, SourceLocation LParenLoc, MutableArrayRef< Expr * > Args, SourceLocation RParenLoc, bool EmptyLookup, bool AllowTypoCorrection)
Attempts to recover from a call where no functions were found.
static void DiagnoseFailedEnableIfAttr(Sema &S, OverloadCandidate *Cand)
static bool diagnoseDiagnoseIfAttrsWith(Sema &S, const NamedDecl *ND, bool ArgDependent, SourceLocation Loc, CheckFn &&IsSuccessful)
static OverloadingResult IsUserDefinedConversion(Sema &S, Expr *From, QualType ToType, UserDefinedConversionSequence &User, OverloadCandidateSet &Conversions, AllowedExplicit AllowExplicit, bool AllowObjCConversionOnExplicit)
Determines whether there is a user-defined conversion sequence (C++ [over.ics.user]) that converts ex...
static bool IsAcceptableNonMemberOperatorCandidate(ASTContext &Context, FunctionDecl *Fn, ArrayRef< Expr * > Args)
IsAcceptableNonMemberOperatorCandidate - Determine whether Fn is an acceptable non-member overloaded ...
static FunctionDecl * getMorePartialOrderingConstrained(Sema &S, FunctionDecl *Fn1, FunctionDecl *Fn2, bool IsFn1Reversed, bool IsFn2Reversed)
static void DiagnoseBadDeduction(Sema &S, NamedDecl *Found, Decl *Templated, DeductionFailureInfo &DeductionFailure, unsigned NumArgs, bool TakingCandidateAddress)
Diagnose a failed template-argument deduction.
static bool IsTransparentUnionStandardConversion(Sema &S, Expr *From, QualType &ToType, bool InOverloadResolution, StandardConversionSequence &SCS, bool CStyle)
static const FunctionProtoType * tryGetFunctionProtoType(QualType FromType)
Attempts to get the FunctionProtoType from a Type.
static bool PrepareArgumentsForCallToObjectOfClassType(Sema &S, SmallVectorImpl< Expr * > &MethodArgs, CXXMethodDecl *Method, MultiExprArg Args, SourceLocation LParenLoc)
static TemplateDeductionResult DeduceTemplateArguments(Sema &S, TemplateParameterList *TemplateParams, ArrayRef< TemplateArgument > Ps, ArrayRef< TemplateArgument > As, TemplateDeductionInfo &Info, SmallVectorImpl< DeducedTemplateArgument > &Deduced, bool NumberOfArgumentsMustMatch, bool PartialOrdering, PackFold PackFold, bool *HasDeducedAnyParam)
Defines the SourceManager interface.
static QualType getPointeeType(const MemRegion *R)
C Language Family Type Representation.
a trap message and trap category.
A class for storing results from argument-dependent lookup.
void erase(NamedDecl *D)
Removes any data associated with a given decl.
llvm::mapped_iterator< decltype(Decls)::iterator, select_second > iterator
APValue - This class implements a discriminated union of [uninitialized] [APSInt] [APFloat],...
std::string getAsString(const ASTContext &Ctx, QualType Ty) const
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
const ConstantArrayType * getAsConstantArrayType(QualType T) const
QualType getAtomicType(QualType T) const
Return the uniqued reference to the atomic type for the specified type.
QualType getRValueReferenceType(QualType T) const
Return the uniqued reference to the type for an rvalue reference to the specified type.
unsigned getIntWidth(QualType T) const
bool areCompatibleRVVTypes(QualType FirstType, QualType SecondType)
Return true if the given types are an RISC-V vector builtin type and a VectorType that is a fixed-len...
const llvm::fltSemantics & getFloatTypeSemantics(QualType T) const
Return the APFloat 'semantics' for the specified scalar floating point type.
DeclarationNameTable DeclarationNames
QualType getArrayParameterType(QualType Ty) const
Return the uniqued reference to a specified array parameter type from the original array type.
CanQualType getCanonicalType(QualType T) const
Return the canonical (structural) type corresponding to the specified potentially non-canonical type ...
bool hasSameType(QualType T1, QualType T2) const
Determine whether the given types T1 and T2 are equivalent.
QualType getPointerType(QualType T) const
Return the uniqued reference to the type for a pointer to the specified type.
bool canAssignObjCInterfaces(const ObjCObjectPointerType *LHSOPT, const ObjCObjectPointerType *RHSOPT)
canAssignObjCInterfaces - Return true if the two interface types are compatible for assignment from R...
QualType getLValueReferenceType(QualType T, bool SpelledAsLValue=true) const
Return the uniqued reference to the type for an lvalue reference to the specified type.
QualType getConstantArrayType(QualType EltTy, const llvm::APInt &ArySize, const Expr *SizeExpr, ArraySizeModifier ASM, unsigned IndexTypeQuals) const
Return the unique reference to the type for a constant array of the specified element type.
const LangOptions & getLangOpts() const
bool areLaxCompatibleRVVTypes(QualType FirstType, QualType SecondType)
Return true if the given vector types are lax-compatible RISC-V vector types as defined by -flax-vect...
CallingConv getDefaultCallingConvention(bool IsVariadic, bool IsCXXMethod) const
Retrieves the default calling convention for the current context.
void forEachMultiversionedFunctionVersion(const FunctionDecl *FD, llvm::function_ref< void(FunctionDecl *)> Pred) const
Visits all versions of a multiversioned function with the passed predicate.
QualType getPointerDiffType() const
Return the unique type for "ptrdiff_t" (C99 7.17) defined in <stddef.h>.
int getFloatingTypeOrder(QualType LHS, QualType RHS) const
Compare the rank of the two specified floating point types, ignoring the domain of the type (i....
const TargetInfo * getAuxTargetInfo() const
CanQualType UnsignedLongTy
QualType getRestrictType(QualType T) const
Return the uniqued reference to the type for a restrict qualified type.
QualType getQualifiedType(SplitQualType split) const
Un-split a SplitQualType.
QualType getObjCObjectPointerType(QualType OIT) const
Return a ObjCObjectPointerType type for the given ObjCObjectType.
QualType getObjCIdType() const
Represents the Objective-CC id type.
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 getMemberPointerType(QualType T, NestedNameSpecifier Qualifier, const CXXRecordDecl *Cls) const
Return the uniqued reference to the type for a member pointer to the specified type in the specified ...
QualType getSizeType() const
Return the unique type for "size_t" (C99 7.17), defined in <stddef.h>.
QualType getCVRQualifiedType(QualType T, unsigned CVR) const
Return a type with additional const, volatile, or restrict qualifiers.
bool areCompatibleVectorTypes(QualType FirstVec, QualType SecondVec)
Return true if the given vector types are of the same unqualified type or if they are equivalent to t...
const TargetInfo & getTargetInfo() const
bool typesAreCompatible(QualType T1, QualType T2, bool CompareUnqualified=false)
Compatibility predicates used to check assignment expressions.
QualType getAddrSpaceQualType(QualType T, LangAS AddressSpace) const
Return the uniqued reference to the type for an address space qualified type with the specified type ...
CanQualType getCanonicalTagType(const TagDecl *TD) const
QualType getUnqualifiedArrayType(QualType T, Qualifiers &Quals) const
Return this type as a completely-unqualified array type, capturing the qualifiers in Quals.
Represents a constant array type that does not decay to a pointer when used as a function parameter.
QualType getConstantArrayType(const ASTContext &Ctx) const
Represents an array type, per C99 6.7.5.2 - Array Declarators.
QualType getElementType() const
QualType getValueType() const
Gets the type contained by this atomic type, i.e.
Attr - This represents one attribute.
A builtin binary operation expression such as "x + y" or "x <= y".
static OverloadedOperatorKind getOverloadedOperator(Opcode Opc)
Retrieve the overloaded operator kind that corresponds to the given binary opcode.
StringRef getOpcodeStr() const
static StringRef getOpcodeStr(Opcode Op)
getOpcodeStr - Turn an Opcode enum value into the punctuation char it corresponds to,...
static BinaryOperator * Create(const ASTContext &C, Expr *lhs, Expr *rhs, Opcode opc, QualType ResTy, ExprValueKind VK, ExprObjectKind OK, SourceLocation opLoc, FPOptionsOverride FPFeatures)
static bool isCompoundAssignmentOp(Opcode Opc)
This class is used for builtin types like 'int'.
BasePaths - Represents the set of paths from a derived class to one of its (direct or indirect) bases...
const RecordType * getDetectedVirtual() const
The virtual base discovered on the path (if we are merely detecting virtuals).
bool isAmbiguous(CanQualType BaseType)
Determine whether the path from the most-derived type to the given base type is ambiguous (i....
Represents a C++ constructor within a class.
bool isCopyOrMoveConstructor(unsigned &TypeQuals) const
Determine whether this is a copy or move constructor.
bool isConvertingConstructor(bool AllowExplicit) const
Whether this constructor is a converting constructor (C++ [class.conv.ctor]), which can be used for u...
Represents a C++ conversion function within a class.
bool isExplicit() const
Return true if the declaration is already resolved to be explicit.
QualType getConversionType() const
Returns the type that this conversion function is converting to.
Represents a call to a member function that may be written either with member call syntax (e....
static CXXMemberCallExpr * Create(const ASTContext &Ctx, Expr *Fn, ArrayRef< Expr * > Args, QualType Ty, ExprValueKind VK, SourceLocation RP, FPOptionsOverride FPFeatures, unsigned MinNumArgs=0)
Represents a static or instance method of a struct/union/class.
bool isExplicitObjectMemberFunction() const
[C++2b][dcl.fct]/p7 An explicit object member function is a non-static member function with an explic...
bool isImplicitObjectMemberFunction() const
[C++2b][dcl.fct]/p7 An implicit object member function is a non-static member function without an exp...
QualType getFunctionObjectParameterReferenceType() const
Return the type of the object pointed by this.
const CXXRecordDecl * getParent() const
Return the parent of this method declaration, which is the class in which this method is defined.
static CXXOperatorCallExpr * Create(const ASTContext &Ctx, OverloadedOperatorKind OpKind, Expr *Fn, ArrayRef< Expr * > Args, QualType Ty, ExprValueKind VK, SourceLocation OperatorLoc, FPOptionsOverride FPFeatures, ADLCallKind UsesADL=NotADL)
Represents a C++ struct/union/class.
bool isLambda() const
Determine whether this class describes a lambda function object.
llvm::iterator_range< conversion_iterator > getVisibleConversionFunctions() const
Get all conversion functions visible in current class, including conversion function templates.
bool hasDefinition() const
CXXMethodDecl * getLambdaCallOperator() const
Retrieve the lambda call operator of the closure type if this is a closure type.
A rewritten comparison expression that was originally written using operator syntax.
Represents a C++ nested-name-specifier or a global scope specifier.
bool isEmpty() const
No scope specifier.
void Adopt(NestedNameSpecifierLoc Other)
Adopt an existing nested-name-specifier (with source-range information).
CallExpr - Represents a function call (C99 6.5.2.2, C++ [expr.call]).
static CallExpr * Create(const ASTContext &Ctx, Expr *Fn, ArrayRef< Expr * > Args, QualType Ty, ExprValueKind VK, SourceLocation RParenLoc, FPOptionsOverride FPFeatures, unsigned MinNumArgs=0, ADLCallKind UsesADL=NotADL)
Create a call expression.
FunctionDecl * getDirectCallee()
If the callee is a FunctionDecl, return it. Otherwise return null.
void setUsesMemberSyntax(bool V=true)
void markDependentForPostponedNameLookup()
Used by Sema to implement MSVC-compatible delayed name lookup.
Represents a canonical, potentially-qualified type.
bool isAtLeastAsQualifiedAs(CanQual< T > Other, const ASTContext &Ctx) const
Determines whether this canonical type is at least as qualified as the Other canonical type.
static CanQual< Type > CreateUnsafe(QualType Other)
CanProxy< U > castAs() const
CanQual< T > getUnqualifiedType() const
Retrieve the unqualified form of this type.
Qualifiers getQualifiers() const
Retrieve all qualifiers.
CanProxy< U > getAs() const
Retrieve a canonical type pointer with a different static type, upcasting or downcasting as needed.
bool isVolatileQualified() const
const T * getTypePtr() const
Retrieve the underlying type pointer, which refers to a canonical type.
bool isPartial() const
True iff the comparison is not totally ordered.
bool isStrong() const
True iff the comparison is "strong".
Complex values, per C99 6.2.5p11.
QualType getElementType() const
static CompoundAssignOperator * Create(const ASTContext &C, Expr *lhs, Expr *rhs, Opcode opc, QualType ResTy, ExprValueKind VK, ExprObjectKind OK, SourceLocation opLoc, FPOptionsOverride FPFeatures, QualType CompLHSType=QualType(), QualType CompResultType=QualType())
Represents the canonical version of C arrays with a specified constant size.
static ConstantExpr * Create(const ASTContext &Context, Expr *E, const APValue &Result)
The result of a constraint satisfaction check, containing the necessary information to diagnose an un...
Base class for callback objects used by Sema::CorrectTypo to check the validity of a potential typo c...
A POD class for pairing a NamedDecl* with an access specifier.
static DeclAccessPair make(NamedDecl *D, AccessSpecifier AS)
NamedDecl * getDecl() const
DeclContext - This is used only as base class of specific decl types that can act as declaration cont...
DeclContext * getParent()
getParent - Returns the containing DeclContext.
lookup_result lookup(DeclarationName Name) const
lookup - Find the declarations (if any) with the given Name in this context.
DeclContext * getEnclosingNamespaceContext()
Retrieve the nearest enclosing namespace context.
bool Encloses(const DeclContext *DC) const
Determine whether this declaration context semantically encloses the declaration context DC.
A reference to a declared variable, function, enum, etc.
void setHadMultipleCandidates(bool V=true)
Sets the flag telling whether this expression refers to a function that was resolved from an overload...
Decl - This represents one declaration (or definition), e.g.
TemplateDecl * getDescribedTemplate() const
If this is a declaration that describes some template, this method returns that template declaration.
ASTContext & getASTContext() const LLVM_READONLY
bool isImplicit() const
isImplicit - Indicates whether the declaration was implicitly generated by the implementation.
const FunctionType * getFunctionType(bool BlocksToo=true) const
Looks through the Decl's underlying type to extract a FunctionType when possible.
FunctionDecl * getAsFunction() LLVM_READONLY
Returns the function itself, or the templated function if this is a function template.
bool isInvalidDecl() const
llvm::iterator_range< specific_attr_iterator< T > > specific_attrs() const
SourceLocation getLocation() const
DeclContext * getDeclContext()
AccessSpecifier getAccess() const
specific_attr_iterator< T > specific_attr_end() const
specific_attr_iterator< T > specific_attr_begin() const
DeclContext * getLexicalDeclContext()
getLexicalDeclContext - The declaration context where this Decl was lexically declared (LexicalDC).
DeclarationNameLoc - Additional source/type location info for a declaration name.
The name of a declaration.
TemplateDecl * getCXXDeductionGuideTemplate() const
If this name is the name of a C++ deduction guide, return the template associated with that name.
OverloadedOperatorKind getCXXOverloadedOperator() const
If this name is the name of an overloadable operator in C++ (e.g., operator+), retrieve the kind of o...
SourceLocation getBeginLoc() const LLVM_READONLY
const AssociatedConstraint & getTrailingRequiresClause() const
Get the constraint-expression introduced by the trailing requires-clause in the function/member decla...
void overloadCandidatesShown(unsigned N)
Call this after showing N overload candidates.
unsigned getNumOverloadCandidatesToShow() const
When a call or operator fails, print out up to this many candidate overloads as suggestions.
OverloadsShown getShowOverloads() const
const IntrusiveRefCntPtr< DiagnosticIDs > & getDiagnosticIDs() const
RAII object that enters a new expression evaluation context.
Store information needed for an explicit specifier.
bool isExplicit() const
Determine whether this specifier is known to correspond to an explicit declaration.
ExplicitSpecKind getKind() const
const Expr * getExpr() const
static ExplicitSpecifier getFromDecl(FunctionDecl *Function)
static ExprWithCleanups * Create(const ASTContext &C, EmptyShell empty, unsigned numObjects)
The return type of classify().
static Classification makeSimpleLValue()
Create a simple, modifiable lvalue.
This represents one expression.
bool isIntegerConstantExpr(const ASTContext &Ctx) const
Expr * IgnoreParenCasts() LLVM_READONLY
Skip past any parentheses and casts which might surround this expression until reaching a fixed point...
bool isValueDependent() const
Determines whether the value of this expression depends on.
ExprValueKind getValueKind() const
getValueKind - The value kind that this expression produces.
bool isTypeDependent() const
Determines whether the type of this expression depends on.
llvm::APSInt EvaluateKnownConstInt(const ASTContext &Ctx) const
EvaluateKnownConstInt - Call EvaluateAsRValue and return the folded integer.
Expr * IgnoreParens() LLVM_READONLY
Skip past any parentheses which might surround this expression until reaching a fixed point.
static bool hasAnyTypeDependentArguments(ArrayRef< Expr * > Exprs)
hasAnyTypeDependentArguments - Determines if any of the expressions in Exprs is type-dependent.
FieldDecl * getSourceBitField()
If this expression refers to a bit-field, retrieve the declaration of that bit-field.
@ NPC_ValueDependentIsNull
Specifies that a value-dependent expression of integral or dependent type should be considered a null...
@ NPC_ValueDependentIsNotNull
Specifies that a value-dependent expression should be considered to never be a null pointer constant.
ExprObjectKind getObjectKind() const
getObjectKind - The object kind that this expression produces.
bool EvaluateAsConstantExpr(EvalResult &Result, const ASTContext &Ctx, ConstantExprKind Kind=ConstantExprKind::Normal) const
Evaluate an expression that is required to be a constant expression.
@ NPCK_ZeroExpression
Expression is a Null pointer constant built from a zero integer expression that is not a simple,...
NullPointerConstantKind isNullPointerConstant(ASTContext &Ctx, NullPointerConstantValueDependence NPC) const
isNullPointerConstant - C99 6.3.2.3p3 - Test if this reduces down to a Null pointer constant.
SourceLocation getExprLoc() const LLVM_READONLY
getExprLoc - Return the preferred location for the arrow when diagnosing a problem with a generic exp...
bool refersToBitField() const
Returns true if this expression is a gl-value that potentially refers to a bit-field.
Classification Classify(ASTContext &Ctx) const
Classify - Classify this expression according to the C++11 expression taxonomy.
bool hasPlaceholderType() const
Returns whether this expression has a placeholder type.
static ExprValueKind getValueKindForType(QualType T)
getValueKindForType - Given a formal return or parameter type, give its value kind.
ExtVectorType - Extended vector type.
Represents difference between two FPOptions values.
Represents a member of a struct/union/class.
Annotates a diagnostic with some code that should be inserted, removed, or replaced to fix the proble...
static FixItHint CreateReplacement(CharSourceRange RemoveRange, StringRef Code)
Create a code modification hint that replaces the given source range with the given code string.
static FixItHint CreateInsertion(SourceLocation InsertionLoc, StringRef Code, bool BeforePreviousInsertions=false)
Create a code modification hint that inserts the given code string at a specific location.
Represents a function declaration or definition.
bool isMultiVersion() const
True if this function is considered a multiversioned function.
const ParmVarDecl * getParamDecl(unsigned i) const
FunctionTemplateDecl * getDescribedFunctionTemplate() const
Retrieves the function template that is described by this function declaration.
unsigned getBuiltinID(bool ConsiderWrapperFunctions=false) const
Returns a value indicating whether this function corresponds to a builtin function.
param_iterator param_end()
bool isMemberLikeConstrainedFriend() const
Determine whether a function is a friend function that cannot be redeclared outside of its class,...
bool hasCXXExplicitFunctionObjectParameter() const
QualType getReturnType() const
ArrayRef< ParmVarDecl * > parameters() const
FunctionDecl * getTemplateInstantiationPattern(bool ForDefinition=true) const
Retrieve the function declaration from which this function could be instantiated, if it is an instant...
FunctionTemplateDecl * getPrimaryTemplate() const
Retrieve the primary template that this function template specialization either specializes or was in...
param_iterator param_begin()
bool isVariadic() const
Whether this function is variadic.
const TemplateArgumentList * getTemplateSpecializationArgs() const
Retrieve the template arguments used to produce this function template specialization from the primar...
bool isTemplateInstantiation() const
Determines if the given function was instantiated from a function template.
unsigned getNumNonObjectParams() const
bool isConstexpr() const
Whether this is a (C++11) constexpr function or constexpr constructor.
OverloadedOperatorKind getOverloadedOperator() const
getOverloadedOperator - Which C++ overloaded operator this function represents, if any.
bool isTargetMultiVersion() const
True if this function is a multiversioned dispatch function as a part of the target functionality.
QualType getDeclaredReturnType() const
Get the declared return type, which may differ from the actual return type if the return type is dedu...
bool isTargetMultiVersionDefault() const
True if this function is the default version of a multiversioned dispatch function as a part of the t...
unsigned getNumParams() const
Return the number of parameters this function must have based on its FunctionType.
bool willHaveBody() const
True if this function will eventually have a body, once it's fully parsed.
Represents a prototype with parameter type info, e.g.
ExtParameterInfo getExtParameterInfo(unsigned I) const
unsigned getNumParams() const
Qualifiers getMethodQuals() const
QualType getParamType(unsigned i) const
bool isVariadic() const
Whether this function prototype is variadic.
ArrayRef< QualType > param_types() const
Declaration of a template function.
FunctionDecl * getTemplatedDecl() const
Get the underlying function declaration of the template.
A class which abstracts out some details necessary for making a call.
ExtInfo withNoReturn(bool noReturn) const
ParameterABI getABI() const
Return the ABI treatment of this parameter.
FunctionType - C99 6.7.5.3 - Function Declarators.
ExtInfo getExtInfo() const
CallingConv getCallConv() const
QualType getReturnType() const
QualType getCallResultType(const ASTContext &Context) const
Determine the type of an expression that calls a function of this type.
static GenericSelectionExpr * Create(const ASTContext &Context, SourceLocation GenericLoc, Expr *ControllingExpr, ArrayRef< TypeSourceInfo * > AssocTypes, ArrayRef< Expr * > AssocExprs, SourceLocation DefaultLoc, SourceLocation RParenLoc, bool ContainsUnexpandedParameterPack, unsigned ResultIndex)
Create a non-result-dependent generic selection expression accepting an expression predicate.
One of these records is kept for each identifier that is lexed.
ImplicitCastExpr - Allows us to explicitly represent implicit type conversions, which have no direct ...
static ImplicitCastExpr * Create(const ASTContext &Context, QualType T, CastKind Kind, Expr *Operand, const CXXCastPath *BasePath, ExprValueKind Cat, FPOptionsOverride FPO)
ImplicitConversionSequence - Represents an implicit conversion sequence, which may be a standard conv...
void dump() const
dump - Print this implicit conversion sequence to standard error.
bool isUserDefined() const
@ StaticObjectArgumentConversion
StandardConversionSequence Standard
When ConversionKind == StandardConversion, provides the details of the standard conversion sequence.
void setBad(BadConversionSequence::FailureKind Failure, Expr *FromExpr, QualType ToType)
Sets this sequence as a bad conversion for an explicit argument.
UserDefinedConversionSequence UserDefined
When ConversionKind == UserDefinedConversion, provides the details of the user-defined conversion seq...
static ImplicitConversionSequence getNullptrToBool(QualType SourceType, QualType DestType, bool NeedLValToRVal)
Form an "implicit" conversion sequence from nullptr_t to bool, for a direct-initialization of a bool ...
AmbiguousConversionSequence Ambiguous
When ConversionKind == AmbiguousConversion, provides the details of the ambiguous conversion.
void setInitializerListContainerType(QualType T, bool IA)
bool hasInitializerListContainerType() const
unsigned getKindRank() const
Return a ranking of the implicit conversion sequence kind, where smaller ranks represent better conve...
bool isInitializerListOfIncompleteArray() const
BadConversionSequence Bad
When ConversionKind == BadConversion, provides the details of the bad conversion.
QualType getInitializerListContainerType() const
void DiagnoseAmbiguousConversion(Sema &S, SourceLocation CaretLoc, const PartialDiagnostic &PDiag) const
Diagnoses an ambiguous conversion.
Describes an C or C++ initializer list.
bool hasDesignatedInit() const
Determine whether this initializer list contains a designated initializer.
unsigned getNumInits() const
SourceLocation getBeginLoc() const LLVM_READONLY
const Expr * getInit(unsigned Init) const
SourceLocation getEndLoc() const LLVM_READONLY
Describes an entity that is being initialized.
static InitializedEntity InitializeParameter(ASTContext &Context, ParmVarDecl *Parm)
Create the initialization entity for a parameter.
static InitializedEntity InitializeTemplateParameter(QualType T, NamedDecl *Param)
Create the initialization entity for a template parameter.
static IntegerLiteral * Create(const ASTContext &C, const llvm::APInt &V, QualType type, SourceLocation l)
Returns a new integer literal with value 'V' and type 'type'.
An lvalue reference type, per C++11 [dcl.ref].
bool isCompatibleWithMSVC(MSVCMajorVersion MajorVersion) const
Represents the results of name lookup.
void addAllDecls(const LookupResult &Other)
Add all the declarations from another set of lookup results.
LLVM_ATTRIBUTE_REINITIALIZES void clear()
Clears out any current state.
DeclClass * getAsSingle() const
void addDecl(NamedDecl *D)
Add a declaration to these results with its natural access.
bool empty() const
Return true if no decls were found.
void resolveKind()
Resolves the result kind of the lookup, possibly hiding decls.
SourceLocation getNameLoc() const
Gets the location of the identifier.
Sema::LookupNameKind getLookupKind() const
Gets the kind of lookup to perform.
void suppressAccessDiagnostics()
Suppress the diagnostics that would normally fire because of this lookup due to access control violat...
const UnresolvedSetImpl & asUnresolvedSet() const
UnresolvedSetImpl::iterator iterator
void suppressDiagnostics()
Suppress the diagnostics that would normally fire because of this lookup.
DeclarationName getLookupName() const
Gets the name to look up.
MemberExpr - [C99 6.5.2.3] Structure and Union Members.
SourceLocation getMemberLoc() const
getMemberLoc - Return the location of the "member", in X->F, it is the location of 'F'.
NestedNameSpecifier getQualifier() const
If the member name was qualified, retrieves the nested-name-specifier that precedes the member name.
ValueDecl * getMemberDecl() const
Retrieve the member declaration to which this expression refers.
bool hasQualifier() const
Determines whether this member expression actually had a C++ nested-name-specifier prior to the name ...
bool performsVirtualDispatch(const LangOptions &LO) const
Returns true if virtual dispatch is performed.
SourceLocation getBeginLoc() const LLVM_READONLY
SourceLocation getExprLoc() const LLVM_READONLY
DeclAccessPair getFoundDecl() const
Retrieves the declaration found by lookup.
A pointer to member type per C++ 8.3.3 - Pointers to members.
NestedNameSpecifier getQualifier() const
CXXRecordDecl * getMostRecentCXXRecordDecl() const
Note: this can trigger extra deserialization when external AST sources are used.
QualType getPointeeType() const
Describes a module or submodule.
std::string getFullModuleName(bool AllowStringLiterals=false) const
Retrieve the full name of this module, including the path from its top-level module.
This represents a decl that may have a name.
NamedDecl * getUnderlyingDecl()
Looks through UsingDecls and ObjCCompatibleAliasDecls for the underlying named decl.
StringRef getName() const
Get the name of identifier for this declaration as a StringRef.
DeclarationName getDeclName() const
Get the actual, stored name of the declaration, which may be a special name.
std::string getQualifiedNameAsString() const
Linkage getFormalLinkage() const
Get the linkage from a semantic point of view.
Represent a C++ namespace.
A C++ nested-name-specifier augmented with source location information.
SourceRange getSourceRange() const LLVM_READONLY
Retrieve the source range covering the entirety of this nested-name-specifier.
Represents a C++ nested name specifier, such as "\::std::vector<int>::".
NonTypeTemplateParmDecl - Declares a non-type template parameter, e.g., "Size" in.
Represents an ObjC class declaration.
Represents typeof(type), a C23 feature and GCC extension, or `typeof_unqual(type),...
ObjCMethodDecl - Represents an instance or class method declaration.
Represents a pointer to an Objective C object.
bool isSpecialized() const
Whether this type is specialized, meaning that it has type arguments.
bool isObjCIdType() const
True if this is equivalent to the 'id' type, i.e.
QualType getPointeeType() const
Gets the type pointed to by this ObjC pointer.
ObjCInterfaceDecl * getInterfaceDecl() const
If this pointer points to an Objective @interface type, gets the declaration for that interface.
const ObjCInterfaceType * getInterfaceType() const
If this pointer points to an Objective C @interface type, gets the type for that interface.
bool isObjCClassType() const
True if this is equivalent to the 'Class' type, i.e.
OpaqueValueExpr - An expression referring to an opaque object of a fixed type and value class.
OverloadCandidateSet - A set of overload candidates, used in C++ overload resolution (C++ 13....
void clear(CandidateSetKind CSK)
Clear out all of the candidates.
void AddDeferredTemplateCandidate(FunctionTemplateDecl *FunctionTemplate, DeclAccessPair FoundDecl, ArrayRef< Expr * > Args, bool SuppressUserConversions, bool PartialOverloading, bool AllowExplicit, CallExpr::ADLCallKind IsADLCandidate, OverloadCandidateParamOrder PO, bool AggregateCandidateDeduction)
bool isNewCandidate(Decl *F, OverloadCandidateParamOrder PO=OverloadCandidateParamOrder::Normal)
Determine when this overload candidate will be new to the overload set.
void AddDeferredConversionTemplateCandidate(FunctionTemplateDecl *FunctionTemplate, DeclAccessPair FoundDecl, CXXRecordDecl *ActingContext, Expr *From, QualType ToType, bool AllowObjCConversionOnExplicit, bool AllowExplicit, bool AllowResultConversion)
void AddDeferredMethodTemplateCandidate(FunctionTemplateDecl *MethodTmpl, DeclAccessPair FoundDecl, CXXRecordDecl *ActingContext, QualType ObjectType, Expr::Classification ObjectClassification, ArrayRef< Expr * > Args, bool SuppressUserConversions, bool PartialOverloading, OverloadCandidateParamOrder PO)
void DisableResolutionByPerfectCandidate()
ConversionSequenceList allocateConversionSequences(unsigned NumConversions)
Allocate storage for conversion sequences for NumConversions conversions.
llvm::MutableArrayRef< Expr * > getPersistentArgsArray(unsigned N)
Provide storage for any Expr* arg that must be preserved until deferred template candidates are deduc...
OperatorRewriteInfo getRewriteInfo() const
bool shouldDeferTemplateArgumentDeduction(const LangOptions &Opts) const
@ CSK_AddressOfOverloadSet
C++ [over.match.call.general] Resolve a call through the address of an overload set.
@ CSK_InitByConstructor
C++ [over.match.ctor], [over.match.list] Initialization of an object of class type by constructor,...
@ CSK_InitByUserDefinedConversion
C++ [over.match.copy]: Copy-initialization of an object of class type by user-defined conversion.
@ CSK_Normal
Normal lookup.
@ CSK_Operator
C++ [over.match.oper]: Lookup of operator function candidates in a call using operator syntax.
SmallVectorImpl< OverloadCandidate >::iterator iterator
void NoteCandidates(PartialDiagnosticAt PA, Sema &S, OverloadCandidateDisplayKind OCD, ArrayRef< Expr * > Args, StringRef Opc="", SourceLocation Loc=SourceLocation(), llvm::function_ref< bool(OverloadCandidate &)> Filter=[](OverloadCandidate &) { return true;})
When overload resolution fails, prints diagnostic messages containing the candidates in the candidate...
bool shouldDeferDiags(Sema &S, ArrayRef< Expr * > Args, SourceLocation OpLoc)
Whether diagnostics should be deferred.
OverloadingResult BestViableFunction(Sema &S, SourceLocation Loc, OverloadCandidateSet::iterator &Best)
Find the best viable function on this overload set, if it exists.
void exclude(Decl *F)
Exclude a function from being considered by overload resolution.
SourceLocation getLocation() const
OverloadCandidate & addCandidate(unsigned NumConversions=0, ConversionSequenceList Conversions={})
Add a new candidate with NumConversions conversion sequence slots to the overload set.
void InjectNonDeducedTemplateCandidates(Sema &S)
CandidateSetKind getKind() const
size_t nonDeferredCandidatesCount() const
SmallVector< OverloadCandidate *, 32 > CompleteCandidates(Sema &S, OverloadCandidateDisplayKind OCD, ArrayRef< Expr * > Args, SourceLocation OpLoc=SourceLocation(), llvm::function_ref< bool(OverloadCandidate &)> Filter=[](OverloadCandidate &) { return true;})
A reference to an overloaded function set, either an UnresolvedLookupExpr or an UnresolvedMemberExpr.
bool hasExplicitTemplateArgs() const
Determines whether this expression had explicit template arguments.
static FindResult find(Expr *E)
Finds the overloaded expression in the given expression E of OverloadTy.
NestedNameSpecifier getQualifier() const
Fetches the nested-name qualifier, if one was given.
SourceLocation getNameLoc() const
Gets the location of the name.
UnresolvedSetImpl::iterator decls_iterator
decls_iterator decls_begin() const
unsigned getNumDecls() const
Gets the number of declarations in the unresolved set.
SourceLocation getTemplateKeywordLoc() const
Retrieve the location of the template keyword preceding this name, if any.
NestedNameSpecifierLoc getQualifierLoc() const
Fetches the nested-name qualifier with source-location information, if one was given.
void copyTemplateArgumentsInto(TemplateArgumentListInfo &List) const
Copies the template arguments into the given structure.
decls_iterator decls_end() const
DeclarationName getName() const
Gets the name looked up.
A single parameter index whose accessors require each use to make explicit the parameter index encodi...
ParenExpr - This represents a parenthesized expression, e.g.
Represents a parameter to a function.
bool hasDefaultArg() const
Determines whether this parameter has a default argument, either parsed or not.
bool isEquivalent(PointerAuthQualifier Other) const
std::string getAsString() const
PointerType - C99 6.7.5.1 - Pointer Declarators.
QualType getPointeeType() const
static PseudoObjectExpr * Create(const ASTContext &Context, Expr *syntactic, ArrayRef< Expr * > semantic, unsigned resultIndex)
A (possibly-)qualified type.
bool isVolatileQualified() const
Determine whether this type is volatile-qualified.
bool isRestrictQualified() const
Determine whether this type is restrict-qualified.
bool hasQualifiers() const
Determine whether this type has any qualifiers.
QualType getNonLValueExprType(const ASTContext &Context) const
Determine the type of a (typically non-lvalue) expression with the specified result type.
QualType getLocalUnqualifiedType() const
Return this type with all of the instance-specific qualifiers removed, but without removing any quali...
bool isNull() const
Return true if this QualType doesn't point to a type yet.
const Type * getTypePtr() const
Retrieves a pointer to the underlying (unqualified) type.
LangAS getAddressSpace() const
Return the address space of this type.
Qualifiers getQualifiers() const
Retrieve the set of qualifiers applied to this type.
void getAsStringInternal(std::string &Str, const PrintingPolicy &Policy) const
QualType getNonReferenceType() const
If Type is a reference type (e.g., const int&), returns the type that the reference refers to ("const...
QualType getCanonicalType() const
QualType getUnqualifiedType() const
Retrieve the unqualified variant of the given type, removing as little sugar as possible.
unsigned getLocalCVRQualifiers() const
Retrieve the set of CVR (const-volatile-restrict) qualifiers local to this particular QualType instan...
bool isMoreQualifiedThan(QualType Other, const ASTContext &Ctx) const
Determine whether this type is more qualified than the other given type, requiring exact equality for...
bool isConstQualified() const
Determine whether this type is const-qualified.
bool hasAddressSpace() const
Check if this type has any address space qualifier.
unsigned getCVRQualifiers() const
Retrieve the set of CVR (const-volatile-restrict) qualifiers applied to this type.
static std::string getAsString(SplitQualType split, const PrintingPolicy &Policy)
bool isAtLeastAsQualifiedAs(QualType Other, const ASTContext &Ctx) const
Determine whether this type is at least as qualified as the other given type, requiring exact equalit...
Qualifiers getLocalQualifiers() const
Retrieve the set of qualifiers local to this particular QualType instance, not including any qualifie...
A qualifier set is used to build a set of qualifiers.
const Type * strip(QualType type)
Collect any qualifiers on the given type and return an unqualified type.
QualType apply(const ASTContext &Context, QualType QT) const
Apply the collected qualifiers to the given type.
QualifiersAndAtomic withVolatile()
QualifiersAndAtomic withAtomic()
The collection of all-type qualifiers we support.
unsigned getCVRQualifiers() const
bool hasOnlyConst() const
@ OCL_ExplicitNone
This object can be modified without requiring retains or releases.
void removeObjCLifetime()
bool compatiblyIncludes(Qualifiers other, const ASTContext &Ctx) const
Determines if these qualifiers compatibly include another set.
static bool isAddressSpaceSupersetOf(LangAS A, LangAS B, const ASTContext &Ctx)
Returns true if address space A is equal to or a superset of B.
void removeAddressSpace()
void setAddressSpace(LangAS space)
PointerAuthQualifier getPointerAuth() const
bool hasObjCGCAttr() const
ObjCLifetime getObjCLifetime() const
std::string getAsString() const
LangAS getAddressSpace() const
bool compatiblyIncludesObjCLifetime(Qualifiers other) const
Determines if these qualifiers compatibly include another set of qualifiers from the narrow perspecti...
An rvalue reference type, per C++11 [dcl.ref].
Represents a struct/union/class.
field_range fields() const
Base for LValueReferenceType and RValueReferenceType.
QualType getPointeeType() const
Scope - A scope is a transient data structure that is used while parsing the program.
Smart pointer class that efficiently represents Objective-C method names.
unsigned getNumArgs() const
bool areCompatibleSveTypes(QualType FirstType, QualType SecondType)
Return true if the given types are an SVE builtin and a VectorType that is a fixed-length representat...
bool areLaxCompatibleSveTypes(QualType FirstType, QualType SecondType)
Return true if the given vector types are lax-compatible SVE vector types, false otherwise.
SemaDiagnosticBuilder Diag(SourceLocation Loc, unsigned DiagID, bool DeferHint=false)
Emit a diagnostic.
PartialDiagnostic PDiag(unsigned DiagID=0)
Build a partial diagnostic.
bool IsAllowedCall(const FunctionDecl *Caller, const FunctionDecl *Callee)
Determines whether Caller may invoke Callee, based on their CUDA host/device attributes.
CUDAFunctionTarget IdentifyTarget(const FunctionDecl *D, bool IgnoreImplicitHDAttr=false)
Determines whether the given function is a CUDA device/host/kernel/etc.
bool inferTargetForImplicitSpecialMember(CXXRecordDecl *ClassDecl, CXXSpecialMemberKind CSM, CXXMethodDecl *MemberDecl, bool ConstRHS, bool Diagnose)
Given a implicit special member, infer its CUDA target from the calls it needs to make to underlying ...
static bool isImplicitHostDeviceFunction(const FunctionDecl *D)
void EraseUnwantedMatches(const FunctionDecl *Caller, llvm::SmallVectorImpl< std::pair< DeclAccessPair, FunctionDecl * > > &Matches)
Finds a function in Matches with highest calling priority from Caller context and erases all function...
CUDAFunctionPreference IdentifyPreference(const FunctionDecl *Caller, const FunctionDecl *Callee)
Identifies relative preference of a given Caller/Callee combination, based on their host/device attri...
bool isObjCWritebackConversion(QualType FromType, QualType ToType, QualType &ConvertedType)
Determine whether this is an Objective-C writeback conversion, used for parameter passing when perfor...
Expr * stripARCUnbridgedCast(Expr *e)
stripARCUnbridgedCast - Given an expression of ARCUnbridgedCast type, remove the placeholder cast.
Abstract base class used to perform a contextual implicit conversion from an expression to any type p...
virtual SemaDiagnosticBuilder noteAmbiguous(Sema &S, CXXConversionDecl *Conv, QualType ConvTy)=0
Emits a note for one of the candidate conversions.
virtual SemaDiagnosticBuilder diagnoseNoMatch(Sema &S, SourceLocation Loc, QualType T)=0
Emits a diagnostic complaining that the expression does not have integral or enumeration type.
virtual SemaDiagnosticBuilder noteExplicitConv(Sema &S, CXXConversionDecl *Conv, QualType ConvTy)=0
Emits a note for the explicit conversion function.
virtual SemaDiagnosticBuilder diagnoseExplicitConv(Sema &S, SourceLocation Loc, QualType T, QualType ConvTy)=0
Emits a diagnostic when the only matching conversion function is explicit.
virtual SemaDiagnosticBuilder diagnoseConversion(Sema &S, SourceLocation Loc, QualType T, QualType ConvTy)=0
Emits a diagnostic when we picked a conversion function (for cases when we are not allowed to pick a ...
virtual SemaDiagnosticBuilder diagnoseAmbiguous(Sema &S, SourceLocation Loc, QualType T)=0
Emits a diagnostic when there are multiple possible conversion functions.
virtual bool match(QualType T)=0
Determine whether the specified type is a valid destination type for this conversion.
virtual SemaDiagnosticBuilder diagnoseIncomplete(Sema &S, SourceLocation Loc, QualType T)=0
Emits a diagnostic when the expression has incomplete class type.
For a defaulted function, the kind of defaulted function that it is.
bool isSpecialMember() const
bool isComparison() const
CXXSpecialMemberKind asSpecialMember() const
RAII class to control scope of DeferDiags.
bool match(QualType T) override
Match an integral or (possibly scoped) enumeration type.
RAII class used to determine whether SFINAE has trapped any errors that occur during template argumen...
bool hasErrorOccurred() const
Determine whether any SFINAE errors have been trapped.
Sema - This implements semantic analysis and AST building for C.
bool TryFunctionConversion(QualType FromType, QualType ToType, QualType &ResultTy) const
Same as IsFunctionConversion, but if this would return true, it sets ResultTy to ToType.
bool DiscardingCFIUncheckedCallee(QualType From, QualType To) const
Returns true if From is a function or pointer to a function with the cfi_unchecked_callee attribute b...
QualType getCurrentThisType()
Try to retrieve the type of the 'this' pointer.
ExprResult BuildBlockForLambdaConversion(SourceLocation CurrentLocation, SourceLocation ConvLocation, CXXConversionDecl *Conv, Expr *Src)
bool diagnoseArgDependentDiagnoseIfAttrs(const FunctionDecl *Function, const Expr *ThisArg, ArrayRef< const Expr * > Args, SourceLocation Loc)
Emit diagnostics for the diagnose_if attributes on Function, ignoring any non-ArgDependent DiagnoseIf...
ExprResult PerformContextuallyConvertToObjCPointer(Expr *From)
PerformContextuallyConvertToObjCPointer - Perform a contextual conversion of the expression From to a...
bool buildOverloadedCallSet(Scope *S, Expr *Fn, UnresolvedLookupExpr *ULE, MultiExprArg Args, SourceLocation RParenLoc, OverloadCandidateSet *CandidateSet, ExprResult *Result)
Constructs and populates an OverloadedCandidateSet from the given function.
void HideUsingShadowDecl(Scope *S, UsingShadowDecl *Shadow)
Hides a using shadow declaration.
bool IsBuildingRecoveryCallExpr
Flag indicating if Sema is building a recovery call expression.
DefaultedFunctionKind getDefaultedFunctionKind(const FunctionDecl *FD)
Determine the kind of defaulting that would be done for a given function.
ExprResult BuildMemberReferenceExpr(Expr *Base, QualType BaseType, SourceLocation OpLoc, bool IsArrow, CXXScopeSpec &SS, SourceLocation TemplateKWLoc, NamedDecl *FirstQualifierInScope, const DeclarationNameInfo &NameInfo, const TemplateArgumentListInfo *TemplateArgs, const Scope *S, ActOnMemberAccessExtraArgs *ExtraArgs=nullptr)
bool IsOverload(FunctionDecl *New, FunctionDecl *Old, bool UseMemberUsingDeclRules, bool ConsiderCudaAttrs=true)
ExprResult CreateBuiltinUnaryOp(SourceLocation OpLoc, UnaryOperatorKind Opc, Expr *InputExpr, bool IsAfterAmp=false)
@ LookupOrdinaryName
Ordinary name lookup, which finds ordinary names (functions, variables, typedefs, etc....
@ LookupUsingDeclName
Look up all declarations in a scope with the given name, including resolved using declarations.
@ LookupOperatorName
Look up of an operator name (e.g., operator+) for use with operator overloading.
@ LookupMemberName
Member name lookup, which finds the names of class/struct/union members.
void DiagnoseSentinelCalls(const NamedDecl *D, SourceLocation Loc, ArrayRef< Expr * > Args)
DiagnoseSentinelCalls - This routine checks whether a call or message-send is to a declaration with t...
ImplicitConversionSequence TryImplicitConversion(Expr *From, QualType ToType, bool SuppressUserConversions, AllowedExplicit AllowExplicit, bool InOverloadResolution, bool CStyle, bool AllowObjCWritebackConversion)
ExprResult BuildLiteralOperatorCall(LookupResult &R, DeclarationNameInfo &SuffixInfo, ArrayRef< Expr * > Args, SourceLocation LitEndLoc, TemplateArgumentListInfo *ExplicitTemplateArgs=nullptr)
BuildLiteralOperatorCall - Build a UserDefinedLiteral by creating a call to a literal operator descri...
bool IsStringInit(Expr *Init, const ArrayType *AT)
ExprResult CreateBuiltinBinOp(SourceLocation OpLoc, BinaryOperatorKind Opc, Expr *LHSExpr, Expr *RHSExpr, bool ForFoldExpression=false)
CreateBuiltinBinOp - Creates a new built-in binary operation with operator Opc at location TokLoc.
ExprResult CreateOverloadedArraySubscriptExpr(SourceLocation LLoc, SourceLocation RLoc, Expr *Base, MultiExprArg Args)
void LookupOverloadedBinOp(OverloadCandidateSet &CandidateSet, OverloadedOperatorKind Op, const UnresolvedSetImpl &Fns, ArrayRef< Expr * > Args, bool RequiresADL=true)
Perform lookup for an overloaded binary operator.
bool isImplicitlyDeleted(FunctionDecl *FD)
Determine whether the given function is an implicitly-deleted special member function.
void PushExpressionEvaluationContext(ExpressionEvaluationContext NewContext, Decl *LambdaContextDecl=nullptr, ExpressionEvaluationContextRecord::ExpressionKind Type=ExpressionEvaluationContextRecord::EK_Other)
bool TemplateParameterListsAreEqual(const TemplateCompareNewDeclInfo &NewInstFrom, TemplateParameterList *New, const NamedDecl *OldInstFrom, TemplateParameterList *Old, bool Complain, TemplateParameterListEqualKind Kind, SourceLocation TemplateArgLoc=SourceLocation())
Determine whether the given template parameter lists are equivalent.
ReferenceCompareResult
ReferenceCompareResult - Expresses the result of comparing two types (cv1 T1 and cv2 T2) to determine...
@ Ref_Incompatible
Ref_Incompatible - The two types are incompatible, so direct reference binding is not possible.
@ Ref_Compatible
Ref_Compatible - The two types are reference-compatible.
@ Ref_Related
Ref_Related - The two types are reference-related, which means that their unqualified forms (T1 and T...
void AddTemplateConversionCandidate(FunctionTemplateDecl *FunctionTemplate, DeclAccessPair FoundDecl, CXXRecordDecl *ActingContext, Expr *From, QualType ToType, OverloadCandidateSet &CandidateSet, bool AllowObjCConversionOnExplicit, bool AllowExplicit, bool AllowResultConversion=true)
Adds a conversion function template specialization candidate to the overload set, using template argu...
FunctionDecl * getMoreConstrainedFunction(FunctionDecl *FD1, FunctionDecl *FD2)
Returns the more constrained function according to the rules of partial ordering by constraints (C++ ...
void AddBuiltinCandidate(QualType *ParamTys, ArrayRef< Expr * > Args, OverloadCandidateSet &CandidateSet, bool IsAssignmentOperator=false, unsigned NumContextualBoolArguments=0)
AddBuiltinCandidate - Add a candidate for a built-in operator.
ExprResult MaybeBindToTemporary(Expr *E)
MaybeBindToTemporary - If the passed in expression has a record type with a non-trivial destructor,...
void AddArgumentDependentLookupCandidates(DeclarationName Name, SourceLocation Loc, ArrayRef< Expr * > Args, TemplateArgumentListInfo *ExplicitTemplateArgs, OverloadCandidateSet &CandidateSet, bool PartialOverloading=false)
Add function candidates found via argument-dependent lookup to the set of overloading candidates.
ExprResult EvaluateConvertedConstantExpression(Expr *E, QualType T, APValue &Value, CCEKind CCE, bool RequireInt, const APValue &PreNarrowingValue)
EvaluateConvertedConstantExpression - Evaluate an Expression That is a converted constant expression ...
FPOptionsOverride CurFPFeatureOverrides()
ExprResult BuildOverloadedArrowExpr(Scope *S, Expr *Base, SourceLocation OpLoc, bool *NoArrowOperatorFound=nullptr)
BuildOverloadedArrowExpr - Build a call to an overloaded operator-> (if one exists),...
ExprResult BuildCallToMemberFunction(Scope *S, Expr *MemExpr, SourceLocation LParenLoc, MultiExprArg Args, SourceLocation RParenLoc, Expr *ExecConfig=nullptr, bool IsExecConfig=false, bool AllowRecovery=false)
BuildCallToMemberFunction - Build a call to a member function.
AssignConvertType CheckSingleAssignmentConstraints(QualType LHSType, ExprResult &RHS, bool Diagnose=true, bool DiagnoseCFAudited=false, bool ConvertRHS=true)
Check assignment constraints for an assignment of RHS to LHSType.
FunctionDecl * getCurFunctionDecl(bool AllowLambda=false) const
Returns a pointer to the innermost enclosing function, or nullptr if the current context is not insid...
ExprResult PerformContextualImplicitConversion(SourceLocation Loc, Expr *FromE, ContextualImplicitConverter &Converter)
Perform a contextual implicit conversion.
ExprResult DefaultVariadicArgumentPromotion(Expr *E, VariadicCallType CT, FunctionDecl *FDecl)
bool DeduceReturnType(FunctionDecl *FD, SourceLocation Loc, bool Diagnose=true)
bool IsQualificationConversion(QualType FromType, QualType ToType, bool CStyle, bool &ObjCLifetimeConversion)
IsQualificationConversion - Determines whether the conversion from an rvalue of type FromType to ToTy...
void diagnoseNullableToNonnullConversion(QualType DstType, QualType SrcType, SourceLocation Loc)
Warn if we're implicitly casting from a _Nullable pointer type to a _Nonnull one.
DiagnosticsEngine & getDiagnostics() const
bool checkAddressOfFunctionIsAvailable(const FunctionDecl *Function, bool Complain=false, SourceLocation Loc=SourceLocation())
Returns whether the given function's address can be taken or not, optionally emitting a diagnostic if...
bool CheckNonDependentConversions(FunctionTemplateDecl *FunctionTemplate, ArrayRef< QualType > ParamTypes, ArrayRef< Expr * > Args, OverloadCandidateSet &CandidateSet, ConversionSequenceList &Conversions, CheckNonDependentConversionsFlag UserConversionFlag, CXXRecordDecl *ActingContext=nullptr, QualType ObjectType=QualType(), Expr::Classification ObjectClassification={}, OverloadCandidateParamOrder PO={})
Check that implicit conversion sequences can be formed for each argument whose corresponding paramete...
bool isObjCPointerConversion(QualType FromType, QualType ToType, QualType &ConvertedType, bool &IncompatibleObjC)
isObjCPointerConversion - Determines whether this is an Objective-C pointer conversion.
FunctionDecl * ResolveAddressOfOverloadedFunction(Expr *AddressOfExpr, QualType TargetType, bool Complain, DeclAccessPair &Found, bool *pHadMultipleCandidates=nullptr)
ResolveAddressOfOverloadedFunction - Try to resolve the address of an overloaded function (C++ [over....
bool FunctionParamTypesAreEqual(ArrayRef< QualType > Old, ArrayRef< QualType > New, unsigned *ArgPos=nullptr, bool Reversed=false)
FunctionParamTypesAreEqual - This routine checks two function proto types for equality of their param...
ExprResult PerformImplicitObjectArgumentInitialization(Expr *From, NestedNameSpecifier Qualifier, NamedDecl *FoundDecl, CXXMethodDecl *Method)
PerformObjectArgumentInitialization - Perform initialization of the implicit object parameter for the...
ExprResult DefaultFunctionArrayLvalueConversion(Expr *E, bool Diagnose=true)
ASTContext & getASTContext() const
UnresolvedSetIterator getMostSpecialized(UnresolvedSetIterator SBegin, UnresolvedSetIterator SEnd, TemplateSpecCandidateSet &FailedCandidates, SourceLocation Loc, const PartialDiagnostic &NoneDiag, const PartialDiagnostic &AmbigDiag, const PartialDiagnostic &CandidateDiag, bool Complain=true, QualType TargetType=QualType())
Retrieve the most specialized of the given function template specializations.
bool IsIntegralPromotion(Expr *From, QualType FromType, QualType ToType)
IsIntegralPromotion - Determines whether the conversion from the expression From (whose potentially-a...
bool IsFloatingPointPromotion(QualType FromType, QualType ToType)
IsFloatingPointPromotion - Determines whether the conversion from FromType to ToType is a floating po...
ExprResult BuildTemplateIdExpr(const CXXScopeSpec &SS, SourceLocation TemplateKWLoc, LookupResult &R, bool RequiresADL, const TemplateArgumentListInfo *TemplateArgs)
void PopExpressionEvaluationContext()
ExprResult CreateOverloadedBinOp(SourceLocation OpLoc, BinaryOperatorKind Opc, const UnresolvedSetImpl &Fns, Expr *LHS, Expr *RHS, bool RequiresADL=true, bool AllowRewrittenCandidates=true, FunctionDecl *DefaultedFn=nullptr)
Create a binary operation that may resolve to an overloaded operator.
ExprResult ImpCastExprToType(Expr *E, QualType Type, CastKind CK, ExprValueKind VK=VK_PRValue, const CXXCastPath *BasePath=nullptr, CheckedConversionKind CCK=CheckedConversionKind::Implicit)
ImpCastExprToType - If Expr is not of type 'Type', insert an implicit cast.
bool FunctionNonObjectParamTypesAreEqual(const FunctionDecl *OldFunction, const FunctionDecl *NewFunction, unsigned *ArgPos=nullptr, bool Reversed=false)
bool isInitListConstructor(const FunctionDecl *Ctor)
Determine whether Ctor is an initializer-list constructor, as defined in [dcl.init....
llvm::SmallSetVector< CXXRecordDecl *, 16 > AssociatedClassSet
std::string getAmbiguousPathsDisplayString(CXXBasePaths &Paths)
Builds a string representing ambiguous paths from a specific derived class to different subobjects of...
AccessResult CheckMemberOperatorAccess(SourceLocation Loc, Expr *ObjectExpr, const SourceRange &, DeclAccessPair FoundDecl)
OverloadKind CheckOverload(Scope *S, FunctionDecl *New, const LookupResult &OldDecls, NamedDecl *&OldDecl, bool UseMemberUsingDeclRules)
Determine whether the given New declaration is an overload of the declarations in Old.
QualType ExtractUnqualifiedFunctionType(QualType PossiblyAFunctionType)
bool IsPointerConversion(Expr *From, QualType FromType, QualType ToType, bool InOverloadResolution, QualType &ConvertedType, bool &IncompatibleObjC)
IsPointerConversion - Determines whether the conversion of the expression From, which has the (possib...
@ Conversions
Allow explicit conversion functions but not explicit constructors.
void DiagnoseUseOfDeletedFunction(SourceLocation Loc, SourceRange Range, DeclarationName Name, OverloadCandidateSet &CandidateSet, FunctionDecl *Fn, MultiExprArg Args, bool IsMember=false)
PrintingPolicy getPrintingPolicy() const
Retrieve a suitable printing policy for diagnostics.
bool IsComplexPromotion(QualType FromType, QualType ToType)
Determine if a conversion is a complex promotion.
Module * getOwningModule(const Decl *Entity)
Get the module owning an entity.
DeclRefExpr * BuildDeclRefExpr(ValueDecl *D, QualType Ty, ExprValueKind VK, SourceLocation Loc, const CXXScopeSpec *SS=nullptr)
ExprResult CheckConvertedConstantExpression(Expr *From, QualType T, llvm::APSInt &Value, CCEKind CCE)
@ TPL_TemplateMatch
We are matching the template parameter lists of two templates that might be redeclarations.
bool AddingCFIUncheckedCallee(QualType From, QualType To) const
Returns true if From is a function or pointer to a function without the cfi_unchecked_callee attribut...
void AddConversionCandidate(CXXConversionDecl *Conversion, DeclAccessPair FoundDecl, CXXRecordDecl *ActingContext, Expr *From, QualType ToType, OverloadCandidateSet &CandidateSet, bool AllowObjCConversionOnExplicit, bool AllowExplicit, bool AllowResultConversion=true, bool StrictPackMatch=false)
AddConversionCandidate - Add a C++ conversion function as a candidate in the candidate set (C++ [over...
bool IsBlockPointerConversion(QualType FromType, QualType ToType, QualType &ConvertedType)
bool CheckFunctionTemplateSpecialization(FunctionDecl *FD, TemplateArgumentListInfo *ExplicitTemplateArgs, LookupResult &Previous, bool QualifiedFriend=false)
Perform semantic analysis for the given function template specialization.
void FindAssociatedClassesAndNamespaces(SourceLocation InstantiationLoc, ArrayRef< Expr * > Args, AssociatedNamespaceSet &AssociatedNamespaces, AssociatedClassSet &AssociatedClasses)
Find the associated classes and namespaces for argument-dependent lookup for a call with the given se...
void AddMethodTemplateCandidate(FunctionTemplateDecl *MethodTmpl, DeclAccessPair FoundDecl, CXXRecordDecl *ActingContext, TemplateArgumentListInfo *ExplicitTemplateArgs, QualType ObjectType, Expr::Classification ObjectClassification, ArrayRef< Expr * > Args, OverloadCandidateSet &CandidateSet, bool SuppressUserConversions=false, bool PartialOverloading=false, OverloadCandidateParamOrder PO={})
Add a C++ member function template as a candidate to the candidate set, using template argument deduc...
void DiagnoseSelfMove(const Expr *LHSExpr, const Expr *RHSExpr, SourceLocation OpLoc)
DiagnoseSelfMove - Emits a warning if a value is moved to itself.
bool isSameOrCompatibleFunctionType(QualType Param, QualType Arg)
Compare types for equality with respect to possibly compatible function types (noreturn adjustment,...
void AddTemplateOverloadCandidate(FunctionTemplateDecl *FunctionTemplate, DeclAccessPair FoundDecl, TemplateArgumentListInfo *ExplicitTemplateArgs, ArrayRef< Expr * > Args, OverloadCandidateSet &CandidateSet, bool SuppressUserConversions=false, bool PartialOverloading=false, bool AllowExplicit=true, ADLCallKind IsADLCandidate=ADLCallKind::NotADL, OverloadCandidateParamOrder PO={}, bool AggregateCandidateDeduction=false)
Add a C++ function template specialization as a candidate in the candidate set, using template argume...
Sema(Preprocessor &pp, ASTContext &ctxt, ASTConsumer &consumer, TranslationUnitKind TUKind=TU_Complete, CodeCompleteConsumer *CompletionConsumer=nullptr)
SourceLocation getLocForEndOfToken(SourceLocation Loc, unsigned Offset=0)
Calls Lexer::getLocForEndOfToken()
const LangOptions & getLangOpts() const
const FunctionProtoType * ResolveExceptionSpec(SourceLocation Loc, const FunctionProtoType *FPT)
bool isEquivalentInternalLinkageDeclaration(const NamedDecl *A, const NamedDecl *B)
Determine if A and B are equivalent internal linkage declarations from different modules,...
bool DiagnoseEmptyLookup(Scope *S, CXXScopeSpec &SS, LookupResult &R, CorrectionCandidateCallback &CCC, TemplateArgumentListInfo *ExplicitTemplateArgs=nullptr, ArrayRef< Expr * > Args={}, DeclContext *LookupCtx=nullptr)
Diagnose an empty lookup.
ExprResult BuildCallExpr(Scope *S, Expr *Fn, SourceLocation LParenLoc, MultiExprArg ArgExprs, SourceLocation RParenLoc, Expr *ExecConfig=nullptr, bool IsExecConfig=false, bool AllowRecovery=false)
BuildCallExpr - Handle a call to Fn with the specified array of arguments.
ExprResult BuildSynthesizedThreeWayComparison(SourceLocation OpLoc, const UnresolvedSetImpl &Fns, Expr *LHS, Expr *RHS, FunctionDecl *DefaultedFn)
AccessResult CheckBaseClassAccess(SourceLocation AccessLoc, QualType Base, QualType Derived, const CXXBasePath &Path, unsigned DiagID, bool ForceCheck=false, bool ForceUnprivileged=false)
Checks access for a hierarchy conversion.
bool CheckUseOfCXXMethodAsAddressOfOperand(SourceLocation OpLoc, const Expr *Op, const CXXMethodDecl *MD)
AccessResult CheckUnresolvedMemberAccess(UnresolvedMemberExpr *E, DeclAccessPair FoundDecl)
Perform access-control checking on a previously-unresolved member access which has now been resolved ...
void AddBuiltinOperatorCandidates(OverloadedOperatorKind Op, SourceLocation OpLoc, ArrayRef< Expr * > Args, OverloadCandidateSet &CandidateSet)
AddBuiltinOperatorCandidates - Add the appropriate built-in operator overloads to the candidate set (...
void AddOverloadCandidate(FunctionDecl *Function, DeclAccessPair FoundDecl, ArrayRef< Expr * > Args, OverloadCandidateSet &CandidateSet, bool SuppressUserConversions=false, bool PartialOverloading=false, bool AllowExplicit=true, bool AllowExplicitConversion=false, ADLCallKind IsADLCandidate=ADLCallKind::NotADL, ConversionSequenceList EarlyConversions={}, OverloadCandidateParamOrder PO={}, bool AggregateCandidateDeduction=false, bool StrictPackMatch=false)
AddOverloadCandidate - Adds the given function to the set of candidate functions, using the given fun...
const LangOptions & LangOpts
bool IsMemberPointerConversion(Expr *From, QualType FromType, QualType ToType, bool InOverloadResolution, QualType &ConvertedType)
IsMemberPointerConversion - Determines whether the conversion of the expression From,...
ExprResult BuildResolvedCallExpr(Expr *Fn, NamedDecl *NDecl, SourceLocation LParenLoc, ArrayRef< Expr * > Arg, SourceLocation RParenLoc, Expr *Config=nullptr, bool IsExecConfig=false, ADLCallKind UsesADL=ADLCallKind::NotADL)
BuildResolvedCallExpr - Build a call to a resolved expression, i.e.
ExprResult BuildCXXMemberCallExpr(Expr *Exp, NamedDecl *FoundDecl, CXXConversionDecl *Method, bool HadMultipleCandidates)
ExprResult CheckForImmediateInvocation(ExprResult E, FunctionDecl *Decl)
Wrap the expression in a ConstantExpr if it is a potential immediate invocation.
llvm::SmallSetVector< DeclContext *, 16 > AssociatedNamespaceSet
MemberPointerConversionDirection
bool diagnoseArgIndependentDiagnoseIfAttrs(const NamedDecl *ND, SourceLocation Loc)
Emit diagnostics for the diagnose_if attributes on Function, ignoring any ArgDependent DiagnoseIfAttr...
ExprResult BuildConvertedConstantExpression(Expr *From, QualType T, CCEKind CCE, NamedDecl *Dest=nullptr)
void popCodeSynthesisContext()
bool AreConstraintExpressionsEqual(const NamedDecl *Old, const Expr *OldConstr, const TemplateCompareNewDeclInfo &New, const Expr *NewConstr)
ReferenceConversionsScope::ReferenceConversions ReferenceConversions
MemberPointerConversionResult CheckMemberPointerConversion(QualType FromType, const MemberPointerType *ToPtrType, CastKind &Kind, CXXCastPath &BasePath, SourceLocation CheckLoc, SourceRange OpRange, bool IgnoreBaseAccess, MemberPointerConversionDirection Direction)
CheckMemberPointerConversion - Check the member pointer conversion from the expression From to the ty...
Expr * BuildCXXThisExpr(SourceLocation Loc, QualType Type, bool IsImplicit)
Build a CXXThisExpr and mark it referenced in the current context.
void pushCodeSynthesisContext(CodeSynthesisContext Ctx)
ExprResult CreateOverloadedUnaryOp(SourceLocation OpLoc, UnaryOperatorKind Opc, const UnresolvedSetImpl &Fns, Expr *input, bool RequiresADL=true)
Create a unary operation that may resolve to an overloaded operator.
std::optional< sema::TemplateDeductionInfo * > isSFINAEContext() const
Determines whether we are currently in a context where template argument substitution failures are no...
void AddOverloadedCallCandidates(UnresolvedLookupExpr *ULE, ArrayRef< Expr * > Args, OverloadCandidateSet &CandidateSet, bool PartialOverloading=false)
Add the overload candidates named by callee and/or found by argument dependent lookup to the given ov...
ExprResult DefaultLvalueConversion(Expr *E)
ExprResult BuildDeclarationNameExpr(const CXXScopeSpec &SS, LookupResult &R, bool NeedsADL, bool AcceptInvalidDecl=false)
bool isVisible(const NamedDecl *D)
Determine whether a declaration is visible to name lookup.
bool CheckDerivedToBaseConversion(QualType Derived, QualType Base, SourceLocation Loc, SourceRange Range, CXXCastPath *BasePath=nullptr, bool IgnoreAccess=false)
void NoteOverloadCandidate(const NamedDecl *Found, const FunctionDecl *Fn, OverloadCandidateRewriteKind RewriteKind=OverloadCandidateRewriteKind(), QualType DestType=QualType(), bool TakingAddress=false)
bool DiagnoseMultipleUserDefinedConversion(Expr *From, QualType ToType)
bool DiagnoseUseOfOverloadedDecl(NamedDecl *D, SourceLocation Loc)
void ArgumentDependentLookup(DeclarationName Name, SourceLocation Loc, ArrayRef< Expr * > Args, ADLResult &Functions)
FunctionDecl * resolveAddressOfSingleOverloadCandidate(Expr *E, DeclAccessPair &FoundResult)
Given an expression that refers to an overloaded function, try to resolve that function to a single f...
DeclContext * CurContext
CurContext - This is the current declaration context of parsing.
MaterializeTemporaryExpr * CreateMaterializeTemporaryExpr(QualType T, Expr *Temporary, bool BoundToLvalueReference)
ExprResult PerformContextuallyConvertToBool(Expr *From)
PerformContextuallyConvertToBool - Perform a contextual conversion of the expression From to bool (C+...
bool CheckFunctionConstraints(const FunctionDecl *FD, ConstraintSatisfaction &Satisfaction, SourceLocation UsageLoc=SourceLocation(), bool ForOverloadResolution=false)
Check whether the given function decl's trailing requires clause is satisfied, if any.
bool IsDerivedFrom(SourceLocation Loc, CXXRecordDecl *Derived, CXXRecordDecl *Base, CXXBasePaths &Paths)
Determine whether the type Derived is a C++ class that is derived from the type Base.
bool isUnevaluatedContext() const
Determines whether we are currently in a context that is not evaluated as per C++ [expr] p5.
ObjCMethodDecl * SelectBestMethod(Selector Sel, MultiExprArg Args, bool IsInstance, SmallVectorImpl< ObjCMethodDecl * > &Methods)
FunctionDecl * ResolveSingleFunctionTemplateSpecialization(OverloadExpr *ovl, bool Complain=false, DeclAccessPair *Found=nullptr, TemplateSpecCandidateSet *FailedTSC=nullptr, bool ForTypeDeduction=false)
Given an expression that refers to an overloaded function, try to resolve that overloaded function ex...
AccessResult CheckAddressOfMemberAccess(Expr *OvlExpr, DeclAccessPair FoundDecl)
void MarkDeclRefReferenced(DeclRefExpr *E, const Expr *Base=nullptr)
Perform reference-marking and odr-use handling for a DeclRefExpr.
ExprResult CheckPlaceholderExpr(Expr *E)
Check for operands with placeholder types and complain if found.
EnableIfAttr * CheckEnableIf(FunctionDecl *Function, SourceLocation CallLoc, ArrayRef< Expr * > Args, bool MissingImplicitThis=false)
Check the enable_if expressions on the given function.
ExprResult CreateUnresolvedLookupExpr(CXXRecordDecl *NamingClass, NestedNameSpecifierLoc NNSLoc, DeclarationNameInfo DNI, const UnresolvedSetImpl &Fns, bool PerformADL=true)
bool inTemplateInstantiation() const
Determine whether we are currently performing template instantiation.
void AddMethodCandidate(DeclAccessPair FoundDecl, QualType ObjectType, Expr::Classification ObjectClassification, ArrayRef< Expr * > Args, OverloadCandidateSet &CandidateSet, bool SuppressUserConversion=false, OverloadCandidateParamOrder PO={})
AddMethodCandidate - Adds a named decl (which is some kind of method) as a method candidate to the gi...
void diagnoseEquivalentInternalLinkageDeclarations(SourceLocation Loc, const NamedDecl *D, ArrayRef< const NamedDecl * > Equiv)
ExprResult FixOverloadedFunctionReference(Expr *E, DeclAccessPair FoundDecl, FunctionDecl *Fn)
FixOverloadedFunctionReference - E is an expression that refers to a C++ overloaded function (possibl...
ExprResult ActOnConditionalOp(SourceLocation QuestionLoc, SourceLocation ColonLoc, Expr *CondExpr, Expr *LHSExpr, Expr *RHSExpr)
ActOnConditionalOp - Parse a ?
bool IsFunctionConversion(QualType FromType, QualType ToType, bool *DiscardingCFIUncheckedCallee=nullptr, bool *AddingCFIUncheckedCallee=nullptr) const
Determine whether the conversion from FromType to ToType is a valid conversion that strips "noexcept"...
ExprResult BuildPossibleImplicitMemberExpr(const CXXScopeSpec &SS, SourceLocation TemplateKWLoc, LookupResult &R, const TemplateArgumentListInfo *TemplateArgs, const Scope *S)
Builds an expression which might be an implicit member expression.
bool resolveAndFixAddressOfSingleOverloadCandidate(ExprResult &SrcExpr, bool DoFunctionPointerConversion=false)
Given an overloaded function, tries to turn it into a non-overloaded function reference using resolve...
CallExpr::ADLCallKind ADLCallKind
bool DiagRuntimeBehavior(SourceLocation Loc, const Stmt *Statement, const PartialDiagnostic &PD)
Conditionally issue a diagnostic based on the current evaluation context.
ExprResult BuildCXXDefaultArgExpr(SourceLocation CallLoc, FunctionDecl *FD, ParmVarDecl *Param, Expr *Init=nullptr)
BuildCXXDefaultArgExpr - Creates a CXXDefaultArgExpr, instantiating the default expr if needed.
bool anyAltivecTypes(QualType srcType, QualType destType)
bool isLaxVectorConversion(QualType srcType, QualType destType)
Is this a legal conversion between two types, one of which is known to be a vector type?
ExprResult BuildOverloadedCallExpr(Scope *S, Expr *Fn, UnresolvedLookupExpr *ULE, SourceLocation LParenLoc, MultiExprArg Args, SourceLocation RParenLoc, Expr *ExecConfig, bool AllowTypoCorrection=true, bool CalleesAddressIsTaken=false)
BuildOverloadedCallExpr - Given the call expression that calls Fn (which eventually refers to the dec...
ExprResult PerformImplicitConversion(Expr *From, QualType ToType, const ImplicitConversionSequence &ICS, AssignmentAction Action, CheckedConversionKind CCK=CheckedConversionKind::Implicit)
PerformImplicitConversion - Perform an implicit conversion of the expression From to the type ToType ...
bool DiagnoseUseOfDecl(NamedDecl *D, ArrayRef< SourceLocation > Locs, const ObjCInterfaceDecl *UnknownObjCClass=nullptr, bool ObjCPropertyAccess=false, bool AvoidPartialAvailabilityChecks=false, ObjCInterfaceDecl *ClassReciever=nullptr, bool SkipTrailingRequiresClause=false)
Determine whether the use of this declaration is valid, and emit any corresponding diagnostics.
ExprResult BuildCallToObjectOfClassType(Scope *S, Expr *Object, SourceLocation LParenLoc, MultiExprArg Args, SourceLocation RParenLoc)
BuildCallToObjectOfClassType - Build a call to an object of class type (C++ [over....
bool isCompleteType(SourceLocation Loc, QualType T, CompleteTypeKind Kind=CompleteTypeKind::Default)
bool CanPerformAggregateInitializationForOverloadResolution(const InitializedEntity &Entity, InitListExpr *From)
Determine whether we can perform aggregate initialization for the purposes of overload resolution.
bool IsOverride(FunctionDecl *MD, FunctionDecl *BaseMD, bool UseMemberUsingDeclRules, bool ConsiderCudaAttrs=true)
bool isStdInitializerList(QualType Ty, QualType *Element)
Tests whether Ty is an instance of std::initializer_list and, if it is and Element is not NULL,...
void AddFunctionCandidates(const UnresolvedSetImpl &Functions, ArrayRef< Expr * > Args, OverloadCandidateSet &CandidateSet, TemplateArgumentListInfo *ExplicitTemplateArgs=nullptr, bool SuppressUserConversions=false, bool PartialOverloading=false, bool FirstArgumentIsBase=false)
Add all of the function declarations in the given function set to the overload candidate set.
bool CheckPointerConversion(Expr *From, QualType ToType, CastKind &Kind, CXXCastPath &BasePath, bool IgnoreBaseAccess, bool Diagnose=true)
CheckPointerConversion - Check the pointer conversion from the expression From to the type ToType.
void NoteDeletedFunction(FunctionDecl *FD)
Emit a note explaining that this function is deleted.
ExprResult CreateBuiltinArraySubscriptExpr(Expr *Base, SourceLocation LLoc, Expr *Idx, SourceLocation RLoc)
void NoteAllOverloadCandidates(Expr *E, QualType DestType=QualType(), bool TakingAddress=false)
AccessResult CheckUnresolvedLookupAccess(UnresolvedLookupExpr *E, DeclAccessPair FoundDecl)
void AddNonMemberOperatorCandidates(const UnresolvedSetImpl &Functions, ArrayRef< Expr * > Args, OverloadCandidateSet &CandidateSet, TemplateArgumentListInfo *ExplicitTemplateArgs=nullptr)
Add all of the non-member operator function declarations in the given function set to the overload ca...
@ PotentiallyEvaluated
The current expression is potentially evaluated at run time, which means that code may be generated t...
@ Unevaluated
The current expression and its subexpressions occur within an unevaluated operand (C++11 [expr]p7),...
bool CheckCallReturnType(QualType ReturnType, SourceLocation Loc, CallExpr *CE, FunctionDecl *FD)
CheckCallReturnType - Checks that a call expression's return type is complete.
bool RequireCompleteType(SourceLocation Loc, QualType T, CompleteTypeKind Kind, TypeDiagnoser &Diagnoser)
Ensure that the type T is a complete type.
ReferenceCompareResult CompareReferenceRelationship(SourceLocation Loc, QualType T1, QualType T2, ReferenceConversions *Conv=nullptr)
CompareReferenceRelationship - Compare the two types T1 and T2 to determine whether they are referenc...
bool LookupQualifiedName(LookupResult &R, DeclContext *LookupCtx, bool InUnqualifiedLookup=false)
Perform qualified name lookup into a given context.
ExprResult PerformObjectMemberConversion(Expr *From, NestedNameSpecifier Qualifier, NamedDecl *FoundDecl, NamedDecl *Member)
Cast a base object to a member's actual type.
MemberPointerConversionResult
SourceManager & SourceMgr
bool DiagnoseDependentMemberLookup(const LookupResult &R)
Diagnose a lookup that found results in an enclosing class during error recovery.
DiagnosticsEngine & Diags
NamespaceDecl * getStdNamespace() const
ExprResult DefaultFunctionArrayConversion(Expr *E, bool Diagnose=true)
DefaultFunctionArrayConversion (C99 6.3.2.1p3, C99 6.3.2.1p4).
ExprResult PerformCopyInitialization(const InitializedEntity &Entity, SourceLocation EqualLoc, ExprResult Init, bool TopLevelOfInitList=false, bool AllowExplicit=false)
bool ResolveAndFixSingleFunctionTemplateSpecialization(ExprResult &SrcExpr, bool DoFunctionPointerConversion=false, bool Complain=false, SourceRange OpRangeForComplaining=SourceRange(), QualType DestTypeForComplaining=QualType(), unsigned DiagIDForComplaining=0)
TemplateDeductionResult DeduceTemplateArguments(ClassTemplatePartialSpecializationDecl *Partial, ArrayRef< TemplateArgument > TemplateArgs, sema::TemplateDeductionInfo &Info)
void AddSurrogateCandidate(CXXConversionDecl *Conversion, DeclAccessPair FoundDecl, CXXRecordDecl *ActingContext, const FunctionProtoType *Proto, Expr *Object, ArrayRef< Expr * > Args, OverloadCandidateSet &CandidateSet)
AddSurrogateCandidate - Adds a "surrogate" candidate function that converts the given Object to a fun...
MemberExpr * BuildMemberExpr(Expr *Base, bool IsArrow, SourceLocation OpLoc, NestedNameSpecifierLoc NNS, SourceLocation TemplateKWLoc, ValueDecl *Member, DeclAccessPair FoundDecl, bool HadMultipleCandidates, const DeclarationNameInfo &MemberNameInfo, QualType Ty, ExprValueKind VK, ExprObjectKind OK, const TemplateArgumentListInfo *TemplateArgs=nullptr)
ExprResult CreateRecoveryExpr(SourceLocation Begin, SourceLocation End, ArrayRef< Expr * > SubExprs, QualType T=QualType())
Attempts to produce a RecoveryExpr after some AST node cannot be created.
std::string getTemplateArgumentBindingsText(const TemplateParameterList *Params, const TemplateArgumentList &Args)
Produces a formatted string that describes the binding of template parameters to template arguments.
bool MaybeEmitAmbiguousAtomicConstraintsDiagnostic(const NamedDecl *D1, ArrayRef< AssociatedConstraint > AC1, const NamedDecl *D2, ArrayRef< AssociatedConstraint > AC2)
If D1 was not at least as constrained as D2, but would've been if a pair of atomic constraints involv...
void DiagnoseUnsatisfiedConstraint(const ConstraintSatisfaction &Satisfaction, bool First=true)
Emit diagnostics explaining why a constraint expression was deemed unsatisfied.
ForRangeStatus BuildForRangeBeginEndCall(SourceLocation Loc, SourceLocation RangeLoc, const DeclarationNameInfo &NameInfo, LookupResult &MemberLookup, OverloadCandidateSet *CandidateSet, Expr *Range, ExprResult *CallExpr)
Build a call to 'begin' or 'end' for a C++11 for-range statement.
@ Diagnose
Diagnose issues that are non-constant or that are extensions.
ExprResult InitializeExplicitObjectArgument(Sema &S, Expr *Obj, FunctionDecl *Fun)
bool CanPerformCopyInitialization(const InitializedEntity &Entity, ExprResult Init)
bool DiagnoseInvalidExplicitObjectParameterInLambda(CXXMethodDecl *Method, SourceLocation CallLoc)
Returns true if the explicit object parameter was invalid.
bool IsStringLiteralToNonConstPointerConversion(Expr *From, QualType ToType)
Helper function to determine whether this is the (deprecated) C++ conversion from a string literal to...
void HandleFunctionTypeMismatch(PartialDiagnostic &PDiag, QualType FromType, QualType ToType)
HandleFunctionTypeMismatch - Gives diagnostic information for differeing function types.
bool ConvertArgumentsForCall(CallExpr *Call, Expr *Fn, FunctionDecl *FDecl, const FunctionProtoType *Proto, ArrayRef< Expr * > Args, SourceLocation RParenLoc, bool ExecConfig=false)
ConvertArgumentsForCall - Converts the arguments specified in Args/NumArgs to the parameter types of ...
DeclContextLookupResult LookupConstructors(CXXRecordDecl *Class)
Look up the constructors for the given class.
FunctionTemplateDecl * getMoreSpecializedTemplate(FunctionTemplateDecl *FT1, FunctionTemplateDecl *FT2, SourceLocation Loc, TemplatePartialOrderingContext TPOC, unsigned NumCallArguments1, QualType RawObj1Ty={}, QualType RawObj2Ty={}, bool Reversed=false, bool PartialOverloading=false)
Returns the more specialized function template according to the rules of function template partial or...
bool CheckFunctionCall(FunctionDecl *FDecl, CallExpr *TheCall, const FunctionProtoType *Proto)
CheckFunctionCall - Check a direct function call for various correctness and safety properties not st...
void AddMemberOperatorCandidates(OverloadedOperatorKind Op, SourceLocation OpLoc, ArrayRef< Expr * > Args, OverloadCandidateSet &CandidateSet, OverloadCandidateParamOrder PO={})
Add overload candidates for overloaded operators that are member functions.
void CheckVirtualDtorCall(CXXDestructorDecl *dtor, SourceLocation Loc, bool IsDelete, bool CallCanBeVirtual, bool WarnOnNonAbstractTypes, SourceLocation DtorLoc)
ExprResult ActOnFinishFullExpr(Expr *Expr, bool DiscardedValue)
void checkCall(NamedDecl *FDecl, const FunctionProtoType *Proto, const Expr *ThisArg, ArrayRef< const Expr * > Args, bool IsMemberFunction, SourceLocation Loc, SourceRange Range, VariadicCallType CallType)
Handles the checks for format strings, non-POD arguments to vararg functions, NULL arguments passed t...
Encodes a location in the source.
bool isValid() const
Return true if this is a valid SourceLocation object.
bool isInSystemHeader(SourceLocation Loc) const
Returns if a SourceLocation is in a system header.
bool isBeforeInTranslationUnit(SourceLocation LHS, SourceLocation RHS) const
Determines the order of 2 source locations in the translation unit.
A trivial tuple used to represent a source range.
SourceLocation getBegin() const
StandardConversionSequence - represents a standard conversion sequence (C++ 13.3.3....
void dump() const
dump - Print this standard conversion sequence to standard error.
void setFromType(QualType T)
DeclAccessPair FoundCopyConstructor
bool isIdentityConversion() const
unsigned BindsToRvalue
Whether we're binding to an rvalue.
ImplicitConversionKind Second
Second - The second conversion can be an integral promotion, floating point promotion,...
QualType getFromType() const
ImplicitConversionKind First
First – The first conversion can be an lvalue-to-rvalue conversion, array-to-pointer conversion,...
unsigned BindsImplicitObjectArgumentWithoutRefQualifier
Whether this binds an implicit object argument to a non-static member function without a ref-qualifie...
unsigned ReferenceBinding
ReferenceBinding - True when this is a reference binding (C++ [over.ics.ref]).
void setAsIdentityConversion()
StandardConversionSequence - Set the standard conversion sequence to the identity conversion.
unsigned DeprecatedStringLiteralToCharPtr
Whether this is the deprecated conversion of a string literal to a pointer to non-const character dat...
CXXConstructorDecl * CopyConstructor
CopyConstructor - The copy constructor that is used to perform this conversion, when the conversion i...
unsigned IncompatibleObjC
IncompatibleObjC - Whether this is an Objective-C conversion that we should warn about (if we actuall...
unsigned ObjCLifetimeConversionBinding
Whether this binds a reference to an object with a different Objective-C lifetime qualifier.
ImplicitConversionKind Third
Third - The third conversion can be a qualification conversion or a function conversion.
unsigned QualificationIncludesObjCLifetime
Whether the qualification conversion involves a change in the Objective-C lifetime (for automatic ref...
void setToType(unsigned Idx, QualType T)
bool isPointerConversionToBool() const
isPointerConversionToBool - Determines whether this conversion is a conversion of a pointer or pointe...
void * ToTypePtrs[3]
ToType - The types that this conversion is converting to in each step.
NarrowingKind getNarrowingKind(ASTContext &Context, const Expr *Converted, APValue &ConstantValue, QualType &ConstantType, bool IgnoreFloatToIntegralConversion=false) const
Check if this standard conversion sequence represents a narrowing conversion, according to C++11 [dcl...
unsigned IsLvalueReference
Whether this is an lvalue reference binding (otherwise, it's an rvalue reference binding).
ImplicitConversionKind Dimension
Dimension - Between the second and third conversion a vector or matrix dimension conversion may occur...
unsigned BindsToFunctionLvalue
Whether we're binding to a function lvalue.
unsigned DirectBinding
DirectBinding - True when this is a reference binding that is a direct binding (C++ [dcl....
ImplicitConversionRank getRank() const
getRank - Retrieve the rank of this standard conversion sequence (C++ 13.3.3.1.1p3).
bool isPointerConversionToVoidPointer(ASTContext &Context) const
isPointerConversionToVoidPointer - Determines whether this conversion is a conversion of a pointer to...
void setAllToTypes(QualType T)
unsigned FromBracedInitList
Whether the source expression was originally a single element braced-init-list.
QualType getToType(unsigned Idx) const
SourceLocation getEndLoc() const LLVM_READONLY
SourceRange getSourceRange() const LLVM_READONLY
SourceLocation tokens are not useful in isolation - they are low level value objects created/interpre...
SourceLocation getBeginLoc() const LLVM_READONLY
StringLiteral - This represents a string literal expression, e.g.
StringRef getString() const
const llvm::Triple & getTriple() const
Returns the target triple of the primary target.
virtual bool hasInt128Type() const
Determine whether the __int128 type is supported on this target.
virtual bool hasIbm128Type() const
Determine whether the __ibm128 type is supported on this target.
virtual bool hasFloat128Type() const
Determine whether the __float128 type is supported on this target.
A convenient class for passing around template argument information.
A template argument list.
Represents a template argument.
QualType getNonTypeTemplateArgumentType() const
If this is a non-type template argument, get its type.
QualType getAsType() const
Retrieve the type for a type template argument.
TemplateName getAsTemplate() const
Retrieve the template name for a template name argument.
unsigned pack_size() const
The number of template arguments in the given template argument pack.
@ Template
The template argument is a template name that was provided for a template template parameter.
@ Pack
The template argument is actually a parameter pack.
ArgKind getKind() const
Return the kind of stored template argument.
The base class of all kinds of template declarations (e.g., class, function, etc.).
TemplateParameterList * getTemplateParameters() const
Get the list of template parameters.
Represents a C++ template name within the type system.
TemplateDecl * getAsTemplateDecl(bool IgnoreDeduced=false) const
Retrieve the underlying template declaration that this template name refers to, if known.
@ Template
A single template declaration.
bool hasAssociatedConstraints() const
TemplateSpecCandidateSet - A set of generalized overload candidates, used in template specializations...
SmallVector< TemplateSpecCandidate, 16 >::iterator iterator
void NoteCandidates(Sema &S, SourceLocation Loc)
NoteCandidates - When no template specialization match is found, prints diagnostic messages containin...
void clear()
Clear out all of the candidates.
SourceLocation getLocation() const
TemplateSpecCandidate & addCandidate()
Add a new candidate with NumConversions conversion sequence slots to the overload set.
TemplateTemplateParmDecl - Declares a template template parameter, e.g., "T" in.
Declaration of a template type parameter.
const Type * getTypeForDecl() const
The base class of the type hierarchy.
bool isIncompleteOrObjectType() const
Return true if this is an incomplete or object type, in other words, not a function type.
bool isBlockPointerType() const
bool isBooleanType() const
bool isObjCBuiltinType() const
bool isSignedIntegerOrEnumerationType() const
Determines whether this is an integer type that is signed or an enumeration types whose underlying ty...
bool hasAttr(attr::Kind AK) const
Determine whether this type had the specified attribute applied to it (looking through top-level type...
const RecordType * getAsUnionType() const
NOTE: getAs*ArrayType are methods on ASTContext.
bool isIncompleteArrayType() const
bool isSignedIntegerType() const
Return true if this is an integer type that is signed, according to C99 6.2.5p4 [char,...
bool isFloat16Type() const
bool isComplexType() const
isComplexType() does not include complex integers (a GCC extension).
bool isIntegralOrUnscopedEnumerationType() const
Determine whether this type is an integral or unscoped enumeration type.
bool isRValueReferenceType() const
CXXRecordDecl * getAsCXXRecordDecl() const
Retrieves the CXXRecordDecl that this type refers to, either because the type is a RecordType or beca...
bool isConstantArrayType() const
bool canDecayToPointerType() const
Determines whether this type can decay to a pointer type.
bool isConvertibleToFixedPointType() const
Return true if this can be converted to (or from) a fixed point type.
CXXRecordDecl * castAsCXXRecordDecl() const
bool isArithmeticType() const
bool isPointerType() const
bool isArrayParameterType() const
CanQualType getCanonicalTypeUnqualified() const
bool isIntegerType() const
isIntegerType() does not include complex integers (a GCC extension).
bool isSVESizelessBuiltinType() const
Returns true for SVE scalable vector types.
const T * castAs() const
Member-template castAs<specific type>.
bool isReferenceType() const
bool isEnumeralType() const
bool isIntegralType(const ASTContext &Ctx) const
Determine whether this type is an integral type.
bool isObjCQualifiedIdType() const
QualType getPointeeType() const
If this is a pointer, ObjC object pointer, or block pointer, this returns the respective pointee.
bool isIntegralOrEnumerationType() const
Determine whether this type is an integral or enumeration type.
bool isAnyCharacterType() const
Determine whether this type is any of the built-in character types.
bool isExtVectorBoolType() const
bool isObjCObjectOrInterfaceType() const
bool isInstantiationDependentType() const
Determine whether this type is an instantiation-dependent type, meaning that the type involves a temp...
bool isLValueReferenceType() const
bool isBitIntType() const
bool isDependentType() const
Whether this type is a dependent type, meaning that its definition somehow depends on a template para...
bool isAggregateType() const
Determines whether the type is a C++ aggregate type or C aggregate or union type.
bool isAnyComplexType() const
bool isFixedPointType() const
Return true if this is a fixed point type according to ISO/IEC JTC1 SC22 WG14 N1169.
const BuiltinType * getAsPlaceholderType() const
bool isMemberPointerType() const
bool isObjCIdType() const
bool isMatrixType() const
bool isUndeducedType() const
Determine whether this type is an undeduced type, meaning that it somehow involves a C++11 'auto' typ...
bool isObjectType() const
Determine whether this type is an object type.
EnumDecl * getAsEnumDecl() const
Retrieves the EnumDecl this type refers to.
bool isBFloat16Type() const
bool isIncompleteType(NamedDecl **Def=nullptr) const
Types are partitioned into 3 broad categories (C99 6.2.5p1): object types, function types,...
bool isFunctionType() const
bool isObjCObjectPointerType() const
bool isVectorType() const
bool isObjCClassType() const
bool isRealFloatingType() const
Floating point categories.
bool isRVVSizelessBuiltinType() const
Returns true for RVV scalable vector types.
const T * getAsCanonical() const
If this type is canonically the specified type, return its canonical type cast to that specified type...
bool isHLSLAttributedResourceType() const
bool isUnsignedIntegerType() const
Return true if this is an integer type that is unsigned, according to C99 6.2.5p6 [which returns true...
bool isAnyPointerType() const
TypeClass getTypeClass() const
const T * getAs() const
Member-template getAs<specific type>'.
bool isNullPtrType() const
bool isRecordType() const
UnaryOperator - This represents the unary-expression's (except sizeof and alignof),...
static OverloadedOperatorKind getOverloadedOperator(Opcode Opc)
Retrieve the overloaded operator kind that corresponds to the given unary opcode.
static UnaryOperator * Create(const ASTContext &C, Expr *input, Opcode opc, QualType type, ExprValueKind VK, ExprObjectKind OK, SourceLocation l, bool CanOverflow, FPOptionsOverride FPFeatures)
static StringRef getOpcodeStr(Opcode Op)
getOpcodeStr - Turn an Opcode enum value into the punctuation char it corresponds to,...
A reference to a name which we were able to look up during parsing but could not resolve to a specifi...
bool requiresADL() const
True if this declaration should be extended by argument-dependent lookup.
static UnresolvedLookupExpr * Create(const ASTContext &Context, CXXRecordDecl *NamingClass, NestedNameSpecifierLoc QualifierLoc, const DeclarationNameInfo &NameInfo, bool RequiresADL, UnresolvedSetIterator Begin, UnresolvedSetIterator End, bool KnownDependent, bool KnownInstantiationDependent)
Represents a C++ member access expression for which lookup produced a set of overloaded functions.
DeclarationName getMemberName() const
Retrieve the name of the member that this expression refers to.
QualType getBaseType() const
bool isArrow() const
Determine whether this member expression used the '->' operator; otherwise, it used the '.
Expr * getBase()
Retrieve the base object of this member expressions, e.g., the x in x.m.
SourceLocation getBeginLoc() const LLVM_READONLY
SourceLocation getMemberLoc() const
Retrieve the location of the name of the member that this expression refers to.
A set of unresolved declarations.
ArrayRef< DeclAccessPair > pairs() const
void addDecl(NamedDecl *D)
The iterator over UnresolvedSets.
A set of unresolved declarations.
A call to a literal operator (C++11 [over.literal]) written as a user-defined literal (C++11 [lit....
static UserDefinedLiteral * Create(const ASTContext &Ctx, Expr *Fn, ArrayRef< Expr * > Args, QualType Ty, ExprValueKind VK, SourceLocation LitEndLoc, SourceLocation SuffixLoc, FPOptionsOverride FPFeatures)
unsigned getNumElements() const
QualType getElementType() const
Provides information about an attempted template argument deduction, whose success or failure was des...
TemplateArgumentList * takeSugared()
Take ownership of the deduced template argument lists.
TemplateArgument SecondArg
The second template argument to which the template argument deduction failure refers.
TemplateParameter Param
The template parameter to which a template argument deduction failure refers.
bool hasSFINAEDiagnostic() const
Is a SFINAE diagnostic available?
TemplateArgument FirstArg
The first template argument to which the template argument deduction failure refers.
ConstraintSatisfaction AssociatedConstraintsSatisfaction
The constraint satisfaction details resulting from the associated constraints satisfaction tests.
void takeSFINAEDiagnostic(PartialDiagnosticAt &PD)
Take ownership of the SFINAE diagnostic.
unsigned CallArgIndex
The index of the function argument that caused a deduction failure.
bool hasStrictPackMatch() const
specific_attr_iterator - Iterates over a subrange of an AttrVec, only providing attributes that are o...
Defines the clang::TargetInfo interface.
const internal::VariadicAllOfMatcher< Type > type
Matches Types in the clang AST.
@ Warning
Present this diagnostic as a warning.
@ Error
Present this diagnostic as an error.
bool Ret(InterpState &S, CodePtr &PC)
void checkAssignmentLifetime(Sema &SemaRef, const AssignedEntity &Entity, Expr *Init)
Check that the lifetime of the given expr (and its subobjects) is sufficient for assigning to the ent...
The JSON file list parser is used to communicate input to InstallAPI.
ImplicitConversionRank GetDimensionConversionRank(ImplicitConversionRank Base, ImplicitConversionKind Dimension)
CanQual< Type > CanQualType
Represents a canonical, potentially-qualified type.
OverloadedOperatorKind
Enumeration specifying the different kinds of C++ overloaded operators.
@ OO_None
Not an overloaded operator.
@ NUM_OVERLOADED_OPERATORS
@ NonFunction
This is not an overload because the lookup results contain a non-function.
@ Match
This is not an overload because the signature exactly matches an existing declaration.
@ Overload
This is a legitimate overload: the existing declarations are functions or function templates with dif...
bool isa(CodeGen::Address addr)
OverloadingResult
OverloadingResult - Capture the result of performing overload resolution.
@ OR_Deleted
Succeeded, but refers to a deleted function.
@ OR_Success
Overload resolution succeeded.
@ OR_Ambiguous
Ambiguous candidates found.
@ OR_No_Viable_Function
No viable function found.
@ Specialization
We are substituting template parameters for template arguments in order to form a template specializa...
bool isBetterOverloadCandidate(Sema &S, const OverloadCandidate &Cand1, const OverloadCandidate &Cand2, SourceLocation Loc, OverloadCandidateSet::CandidateSetKind Kind, bool PartialOverloading=false)
isBetterOverloadCandidate - Determines whether the first overload candidate is a better candidate tha...
bool isUnresolvedExceptionSpec(ExceptionSpecificationType ESpecType)
@ ovl_fail_final_conversion_not_exact
This conversion function template specialization candidate is not viable because the final conversion...
@ ovl_fail_enable_if
This candidate function was not viable because an enable_if attribute disabled it.
@ ovl_fail_illegal_constructor
This conversion candidate was not considered because it is an illegal instantiation of a constructor ...
@ ovl_fail_bad_final_conversion
This conversion candidate is not viable because its result type is not implicitly convertible to the ...
@ ovl_fail_module_mismatched
This candidate was not viable because it has internal linkage and is from a different module unit tha...
@ ovl_fail_too_few_arguments
@ ovl_fail_addr_not_available
This candidate was not viable because its address could not be taken.
@ ovl_fail_too_many_arguments
@ ovl_non_default_multiversion_function
This candidate was not viable because it is a non-default multiversioned function.
@ ovl_fail_constraints_not_satisfied
This candidate was not viable because its associated constraints were not satisfied.
@ ovl_fail_bad_conversion
@ ovl_fail_bad_target
(CUDA) This candidate was not viable because the callee was not accessible from the caller's target (...
@ ovl_fail_inhctor_slice
This inherited constructor is not viable because it would slice the argument.
@ ovl_fail_object_addrspace_mismatch
This constructor/conversion candidate fail due to an address space mismatch between the object being ...
@ ovl_fail_explicit
This candidate constructor or conversion function is explicit but the context doesn't permit explicit...
@ ovl_fail_trivial_conversion
This conversion candidate was not considered because it duplicates the work of a trivial or derived-t...
@ Comparison
A comparison.
@ RQ_None
No ref-qualifier was provided.
@ RQ_LValue
An lvalue ref-qualifier was provided (&).
@ RQ_RValue
An rvalue ref-qualifier was provided (&&).
ImplicitConversionRank
ImplicitConversionRank - The rank of an implicit conversion kind.
@ ICR_Conversion
Conversion.
@ ICR_Writeback_Conversion
ObjC ARC writeback conversion.
@ ICR_HLSL_Dimension_Reduction
HLSL Matching Dimension Reduction.
@ ICR_HLSL_Dimension_Reduction_Conversion
HLSL Dimension reduction with conversion.
@ ICR_HLSL_Scalar_Widening
HLSL Scalar Widening.
@ ICR_C_Conversion
Conversion only allowed in the C standard (e.g. void* to char*).
@ ICR_OCL_Scalar_Widening
OpenCL Scalar Widening.
@ ICR_Complex_Real_Conversion
Complex <-> Real conversion.
@ ICR_HLSL_Scalar_Widening_Conversion
HLSL Scalar Widening with conversion.
@ ICR_HLSL_Dimension_Reduction_Promotion
HLSL Dimension reduction with promotion.
@ ICR_Promotion
Promotion.
@ ICR_Exact_Match
Exact Match.
@ ICR_C_Conversion_Extension
Conversion not allowed by the C standard, but that we accept as an extension anyway.
@ ICR_HLSL_Scalar_Widening_Promotion
HLSL Scalar Widening with promotion.
OverloadCandidateDisplayKind
@ OCD_AmbiguousCandidates
Requests that only tied-for-best candidates be shown.
@ OCD_ViableCandidates
Requests that only viable candidates be shown.
@ OCD_AllCandidates
Requests that all candidates be shown.
@ OK_ObjCProperty
An Objective-C property is a logical field of an Objective-C object which is read and written via Obj...
@ OK_Ordinary
An ordinary object is located at an address in memory.
Expr::ConstantExprKind ConstantExprKind
OverloadCandidateParamOrder
The parameter ordering that will be used for the candidate.
@ Seq
'seq' clause, allowed on 'loop' and 'routine' directives.
nullptr
This class represents a compute construct, representing a 'Kind' of ‘parallel’, 'serial',...
OverloadsShown
Specifies which overload candidates to display when overload resolution fails.
@ Ovl_Best
Show just the "best" overload candidates.
llvm::MutableArrayRef< ImplicitConversionSequence > ConversionSequenceList
A list of implicit conversion sequences for the arguments of an OverloadCandidate.
ComparisonCategoryResult
An enumeration representing the possible results of a three-way comparison.
OverloadCandidateRewriteKind
The kinds of rewrite we perform on overload candidates.
@ CRK_Reversed
Candidate is a rewritten candidate with a reversed order of parameters.
@ CRK_None
Candidate is not a rewritten candidate.
@ CRK_DifferentOperator
Candidate is a rewritten candidate with a different operator name.
MutableArrayRef< Expr * > MultiExprArg
@ Internal
Internal linkage, which indicates that the entity can be referred to from within the translation unit...
@ Result
The result type of a method or function.
const FunctionProtoType * T
ImplicitConversionKind
ImplicitConversionKind - The kind of implicit conversion used to convert an argument to a parameter's...
@ ICK_Complex_Conversion
Complex conversions (C99 6.3.1.6)
@ ICK_Floating_Promotion
Floating point promotions (C++ [conv.fpprom])
@ ICK_Boolean_Conversion
Boolean conversions (C++ [conv.bool])
@ ICK_Integral_Conversion
Integral conversions (C++ [conv.integral])
@ ICK_Fixed_Point_Conversion
Fixed point type conversions according to N1169.
@ ICK_Vector_Conversion
Vector conversions.
@ ICK_Block_Pointer_Conversion
Block Pointer conversions.
@ ICK_Pointer_Member
Pointer-to-member conversions (C++ [conv.mem])
@ ICK_Floating_Integral
Floating-integral conversions (C++ [conv.fpint])
@ ICK_HLSL_Array_RValue
HLSL non-decaying array rvalue cast.
@ ICK_SVE_Vector_Conversion
Arm SVE Vector conversions.
@ ICK_HLSL_Vector_Truncation
HLSL vector truncation.
@ ICK_Incompatible_Pointer_Conversion
C-only conversion between pointers with incompatible types.
@ ICK_Array_To_Pointer
Array-to-pointer conversion (C++ [conv.array])
@ ICK_RVV_Vector_Conversion
RISC-V RVV Vector conversions.
@ ICK_Complex_Promotion
Complex promotions (Clang extension)
@ ICK_Num_Conversion_Kinds
The number of conversion kinds.
@ ICK_Function_Conversion
Function pointer conversion (C++17 [conv.fctptr])
@ ICK_Vector_Splat
A vector splat from an arithmetic type.
@ ICK_Zero_Queue_Conversion
Zero constant to queue.
@ ICK_Identity
Identity conversion (no conversion)
@ ICK_Derived_To_Base
Derived-to-base (C++ [over.best.ics])
@ ICK_Lvalue_To_Rvalue
Lvalue-to-rvalue conversion (C++ [conv.lval])
@ ICK_Qualification
Qualification conversions (C++ [conv.qual])
@ ICK_Pointer_Conversion
Pointer conversions (C++ [conv.ptr])
@ ICK_TransparentUnionConversion
Transparent Union Conversions.
@ ICK_Integral_Promotion
Integral promotions (C++ [conv.prom])
@ ICK_Floating_Conversion
Floating point conversions (C++ [conv.double].
@ ICK_Compatible_Conversion
Conversions between compatible types in C99.
@ ICK_C_Only_Conversion
Conversions allowed in C, but not C++.
@ ICK_Writeback_Conversion
Objective-C ARC writeback conversion.
@ ICK_Zero_Event_Conversion
Zero constant to event (OpenCL1.2 6.12.10)
@ ICK_Complex_Real
Complex-real conversions (C99 6.3.1.7)
@ ICK_Function_To_Pointer
Function-to-pointer (C++ [conv.array])
@ Template
We are parsing a template declaration.
ActionResult< CXXBaseSpecifier * > BaseResult
AssignConvertType
AssignConvertType - All of the 'assignment' semantic checks return this enum to indicate whether the ...
@ IncompatiblePointer
IncompatiblePointer - The assignment is between two pointers types that are not compatible,...
@ CompatiblePointerDiscardsQualifiers
CompatiblePointerDiscardsQualifiers - The assignment discards c/v/r qualifiers, which we accept as an...
@ Compatible
Compatible - the types are compatible according to the standard.
@ IncompatiblePointerSign
IncompatiblePointerSign - The assignment is between two pointers types which point to integers which ...
DeductionFailureInfo MakeDeductionFailureInfo(ASTContext &Context, TemplateDeductionResult TDK, sema::TemplateDeductionInfo &Info)
Convert from Sema's representation of template deduction information to the form used in overload-can...
@ FunctionTemplate
The name was classified as a function template name.
LangAS
Defines the address space values used by the address space qualifier of QualType.
CastKind
CastKind - The kind of operation required for a conversion.
CXXSpecialMemberKind
Kinds of C++ special members.
OverloadedOperatorKind getRewrittenOverloadedOperator(OverloadedOperatorKind Kind)
Get the other overloaded operator that the given operator can be rewritten into, if any such operator...
std::pair< SourceLocation, PartialDiagnostic > PartialDiagnosticAt
A partial diagnostic along with the source location where this diagnostic occurs.
ExprValueKind
The categorization of expression values, currently following the C++11 scheme.
@ VK_PRValue
A pr-value expression (in the C++11 taxonomy) produces a temporary value.
@ VK_XValue
An x-value expression is a reference to an object with independent storage but which can be "moved",...
@ VK_LValue
An l-value expression is a reference to an object with independent storage.
bool shouldEnforceArgLimit(bool PartialOverloading, FunctionDecl *Function)
SmallVector< CXXBaseSpecifier *, 4 > CXXCastPath
A simple array of base specifiers.
llvm::PointerUnion< TemplateTypeParmDecl *, NonTypeTemplateParmDecl *, TemplateTemplateParmDecl * > TemplateParameter
Stores a template parameter of any kind.
NarrowingKind
NarrowingKind - The kind of narrowing conversion being performed by a standard conversion sequence ac...
@ NK_Not_Narrowing
Not a narrowing conversion.
@ NK_Constant_Narrowing
A narrowing conversion, because a constant expression got narrowed.
@ NK_Dependent_Narrowing
Cannot tell whether this is a narrowing conversion because the expression is value-dependent.
@ NK_Type_Narrowing
A narrowing conversion by virtue of the source and destination types.
@ NK_Variable_Narrowing
A narrowing conversion, because a non-constant-expression variable might have got narrowed.
@ TPOC_Conversion
Partial ordering of function templates for a call to a conversion function.
@ TPOC_Call
Partial ordering of function templates for a function call.
bool declaresSameEntity(const Decl *D1, const Decl *D2)
Determine whether two declarations declare the same entity.
TemplateDeductionResult
Describes the result of template argument deduction.
@ MiscellaneousDeductionFailure
Deduction failed; that's all we know.
@ NonDependentConversionFailure
Checking non-dependent argument conversions failed.
@ ConstraintsNotSatisfied
The deduced arguments did not satisfy the constraints associated with the template.
@ Underqualified
Template argument deduction failed due to inconsistent cv-qualifiers on a template parameter type tha...
@ InstantiationDepth
Template argument deduction exceeded the maximum template instantiation depth (which has already been...
@ InvalidExplicitArguments
The explicitly-specified template arguments were not valid template arguments for the given template.
@ CUDATargetMismatch
CUDA Target attributes do not match.
@ TooFewArguments
When performing template argument deduction for a function template, there were too few call argument...
@ Incomplete
Template argument deduction did not deduce a value for every template parameter.
@ Invalid
The declaration was invalid; do nothing.
@ Success
Template argument deduction was successful.
@ SubstitutionFailure
Substitution of the deduced template argument values resulted in an error.
@ IncompletePack
Template argument deduction did not deduce a value for every expansion of an expanded template parame...
@ DeducedMismatch
After substituting deduced template arguments, a dependent parameter type did not match the correspon...
@ Inconsistent
Template argument deduction produced inconsistent deduced values for the given template parameter.
@ TooManyArguments
When performing template argument deduction for a function template, there were too many call argumen...
@ AlreadyDiagnosed
Some error which was already diagnosed.
@ DeducedMismatchNested
After substituting deduced template arguments, an element of a dependent parameter type did not match...
@ NonDeducedMismatch
A non-depnedent component of the parameter did not match the corresponding component of the argument.
@ TSK_ExplicitSpecialization
This template specialization was declared or defined by an explicit specialization (C++ [temp....
@ TSK_ImplicitInstantiation
This template specialization was implicitly instantiated from a template.
CallingConv
CallingConv - Specifies the calling convention that a function uses.
const char * getOperatorSpelling(OverloadedOperatorKind Operator)
Retrieve the spelling of the given overloaded operator, without the preceding "operator" keyword.
U cast(CodeGen::Address addr)
ConstructorInfo getConstructorInfo(NamedDecl *ND)
CCEKind
Contexts in which a converted constant expression is required.
@ TemplateArg
Value of a non-type template parameter.
@ Noexcept
Condition in a noexcept(bool) specifier.
@ ArrayBound
Array bound in array declarator or new-expression.
@ TempArgStrict
As above, but applies strict template checking rules.
@ ExplicitBool
Condition in an explicit(bool) specifier.
ImplicitConversionRank GetConversionRank(ImplicitConversionKind Kind)
GetConversionRank - Retrieve the implicit conversion rank corresponding to the given implicit convers...
@ Enum
The "enum" keyword introduces the elaborated-type-specifier.
ActionResult< Expr * > ExprResult
@ EST_None
no exception specification
@ ForBuiltinOverloadedOp
A conversion for an operand of a builtin overloaded operator.
__DEVICE__ _Tp abs(const std::complex< _Tp > &__c)
Represents an ambiguous user-defined conversion sequence.
ConversionSet::const_iterator const_iterator
ConversionSet & conversions()
SmallVector< std::pair< NamedDecl *, FunctionDecl * >, 4 > ConversionSet
void setFromType(QualType T)
void setToType(QualType T)
void addConversion(NamedDecl *Found, FunctionDecl *D)
void copyFrom(const AmbiguousConversionSequence &)
const Expr * ConstraintExpr
UnsignedOrNone ArgPackSubstIndex
QualType getToType() const
QualType getFromType() const
OverloadFixItKind Kind
The type of fix applied.
unsigned NumConversionsFixed
The number of Conversions fixed.
void setConversionChecker(TypeComparisonFuncTy Foo)
Resets the default conversion checker method.
std::vector< FixItHint > Hints
The list of Hints generated so far.
DeclarationNameInfo - A collector data type for bundling together a DeclarationName and the correspon...
SourceLocation getLoc() const
getLoc - Returns the main location of the declaration name.
void setCXXOperatorNameRange(SourceRange R)
setCXXOperatorNameRange - Sets the range of the operator name (without the operator keyword).
const DeclarationNameLoc & getInfo() const
SourceLocation getCXXLiteralOperatorNameLoc() const
getCXXLiteralOperatorNameLoc - Returns the location of the literal operator name (not the operator ke...
A structure used to record information about a failed template argument deduction,...
void * Data
Opaque pointer containing additional data about this deduction failure.
const TemplateArgument * getSecondArg()
Return the second template argument this deduction failure refers to, if any.
unsigned Result
A Sema::TemplateDeductionResult.
PartialDiagnosticAt * getSFINAEDiagnostic()
Retrieve the diagnostic which caused this deduction failure, if any.
unsigned HasDiagnostic
Indicates whether a diagnostic is stored in Diagnostic.
TemplateDeductionResult getResult() const
void Destroy()
Free any memory associated with this deduction failure.
char Diagnostic[sizeof(PartialDiagnosticAt)]
A diagnostic indicating why deduction failed.
UnsignedOrNone getCallArgIndex()
Return the index of the call argument that this deduction failure refers to, if any.
TemplateParameter getTemplateParameter()
Retrieve the template parameter this deduction failure refers to, if any.
TemplateArgumentList * getTemplateArgumentList()
Retrieve the template argument list associated with this deduction failure, if any.
const TemplateArgument * getFirstArg()
Return the first template argument this deduction failure refers to, if any.
DeferredTemplateOverloadCandidate * Next
EvalResult is a struct with detailed info about an evaluated expression.
APValue Val
Val - This is the value the expression can be folded to.
SmallVectorImpl< PartialDiagnosticAt > * Diag
Diag - If this is non-null, it will be filled in with a stack of notes indicating why evaluation fail...
Extra information about a function prototype.
FunctionEffectsRef FunctionEffects
const ExtParameterInfo * ExtParameterInfos
Information about operator rewrites to consider when adding operator functions to a candidate set.
bool 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.
SourceLocation OpLoc
The source location of the operator.
bool AllowRewrittenCandidates
Whether we should include rewritten candidates in the overload set.
bool isReversible()
Determines whether this operator could be implemented by a function with reversed parameter order.
bool isAcceptableCandidate(const FunctionDecl *FD)
OverloadCandidateRewriteKind getRewriteKind(const FunctionDecl *FD, OverloadCandidateParamOrder PO)
Determine the kind of rewrite that should be performed for this candidate.
OverloadCandidate - A single candidate in an overload set (C++ 13.3).
unsigned StrictPackMatch
Have we matched any packs on the parameter side, versus any non-packs on the argument side,...
unsigned IgnoreObjectArgument
IgnoreObjectArgument - True to indicate that the first argument's conversion, which for this function...
bool TryToFixBadConversion(unsigned Idx, Sema &S)
bool NotValidBecauseConstraintExprHasError() const
unsigned IsADLCandidate
True if the candidate was found using ADL.
unsigned IsSurrogate
IsSurrogate - True to indicate that this candidate is a surrogate for a conversion to a function poin...
QualType BuiltinParamTypes[3]
BuiltinParamTypes - Provides the parameter types of a built-in overload candidate.
DeclAccessPair FoundDecl
FoundDecl - The original declaration that was looked up / invented / otherwise found,...
FunctionDecl * Function
Function - The actual function that this candidate represents.
unsigned RewriteKind
Whether this is a rewritten candidate, and if so, of what kind?
ConversionFixItGenerator Fix
The FixIt hints which can be used to fix the Bad candidate.
unsigned Best
Whether this candidate is the best viable function, or tied for being the best viable function.
StandardConversionSequence FinalConversion
FinalConversion - For a conversion function (where Function is a CXXConversionDecl),...
unsigned getNumParams() const
unsigned HasFinalConversion
Whether FinalConversion has been set.
unsigned TookAddressOfOverload
unsigned FailureKind
FailureKind - The reason why this candidate is not viable.
unsigned ExplicitCallArguments
The number of call arguments that were explicitly provided, to be used while performing partial order...
ConversionSequenceList Conversions
The conversion sequences used to convert the function arguments to the function parameters.
DeductionFailureInfo DeductionFailure
unsigned Viable
Viable - True to indicate that this overload candidate is viable.
CXXConversionDecl * Surrogate
Surrogate - The conversion function for which this candidate is a surrogate, but only if IsSurrogate ...
OverloadCandidateRewriteKind getRewriteKind() const
Get RewriteKind value in OverloadCandidateRewriteKind type (This function is to workaround the spurio...
bool HasFormOfMemberPointer
OverloadExpr * Expression
bool SuppressUserConversions
Do not consider any user-defined conversions when constructing the initializing sequence.
bool OnlyInitializeNonUserDefinedConversions
Before constructing the initializing sequence, we check whether the parameter type and argument type ...
A context in which code is being synthesized (where a source location alone is not sufficient to iden...
enum clang::Sema::CodeSynthesisContext::SynthesisKind Kind
@ RewritingOperatorAsSpaceship
We are rewriting a comparison operator in terms of an operator<=>.
Decl * Entity
The entity that is being synthesized.
Abstract class used to diagnose incomplete types.
A std::pair-like structure for storing a qualified type split into its local qualifiers and its local...
const Type * Ty
The locally-unqualified type.
Qualifiers Quals
The local qualifiers.
TemplateSpecCandidate - This is a generalization of OverloadCandidate which keeps track of template a...
void NoteDeductionFailure(Sema &S, bool ForTakingAddress)
Diagnose a template argument deduction failure.
DeductionFailureInfo DeductionFailure
Template argument deduction info.
Decl * Specialization
Specialization - The actual specialization that this candidate represents.
DeclAccessPair FoundDecl
The declaration that was looked up, together with its access.
void set(DeclAccessPair Found, Decl *Spec, DeductionFailureInfo Info)
UserDefinedConversionSequence - Represents a user-defined conversion sequence (C++ 13....
StandardConversionSequence Before
Represents the standard conversion that occurs before the actual user-defined conversion.
FunctionDecl * ConversionFunction
ConversionFunction - The function that will perform the user-defined conversion.
bool HadMultipleCandidates
HadMultipleCandidates - When this is true, it means that the conversion function was resolved from an...
StandardConversionSequence After
After - Represents the standard conversion that occurs after the actual user-defined conversion.
bool EllipsisConversion
EllipsisConversion - When this is true, it means user-defined conversion sequence starts with a ....
DeclAccessPair FoundConversionFunction
The declaration that we found via name lookup, which might be the same as ConversionFunction or it mi...
void dump() const
dump - Print this user-defined conversion sequence to standard error.
Describes an entity that is being assigned.