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);
171 return Rank[(int)Kind];
196 static const char *
const Name[] = {
200 "Function-to-pointer",
201 "Function pointer conversion",
203 "Integral promotion",
204 "Floating point promotion",
206 "Integral conversion",
207 "Floating conversion",
208 "Complex conversion",
209 "Floating-integral conversion",
210 "Pointer conversion",
211 "Pointer-to-member conversion",
212 "Boolean conversion",
213 "Compatible-types conversion",
214 "Derived-to-base conversion",
216 "SVE Vector conversion",
217 "RVV Vector conversion",
219 "Complex-real conversion",
220 "Block Pointer conversion",
221 "Transparent Union Conversion",
222 "Writeback conversion",
223 "OpenCL Zero Event Conversion",
224 "OpenCL Zero Queue Conversion",
225 "C specific type conversion",
226 "Incompatible pointer conversion",
227 "Fixed point conversion",
228 "HLSL vector truncation",
229 "HLSL matrix truncation",
230 "Non-decaying array conversion",
308 FromType = Context.getArrayDecayedType(FromType);
320 const Expr *Converted) {
323 if (
auto *EWC = dyn_cast<ExprWithCleanups>(Converted)) {
330 while (
auto *ICE = dyn_cast<ImplicitCastExpr>(Converted)) {
331 switch (ICE->getCastKind()) {
333 case CK_IntegralCast:
334 case CK_IntegralToBoolean:
335 case CK_IntegralToFloating:
336 case CK_BooleanToSignedIntegral:
337 case CK_FloatingToIntegral:
338 case CK_FloatingToBoolean:
339 case CK_FloatingCast:
340 Converted = ICE->getSubExpr();
364 QualType &ConstantType,
bool IgnoreFloatToIntegralConversion)
const {
366 "narrowing check outside C++");
377 ToType = ED->getIntegerType();
383 goto FloatingIntegralConversion;
385 goto IntegralConversion;
396 FloatingIntegralConversion:
401 if (IgnoreFloatToIntegralConversion)
404 assert(
Initializer &&
"Unknown conversion expression");
410 if (std::optional<llvm::APSInt> IntConstantValue =
414 Result.convertFromAPInt(*IntConstantValue, IntConstantValue->isSigned(),
415 llvm::APFloat::rmNearestTiesToEven);
417 llvm::APSInt ConvertedValue = *IntConstantValue;
419 llvm::APFloat::opStatus Status =
Result.convertToInteger(
420 ConvertedValue, llvm::APFloat::rmTowardZero, &ignored);
423 if (Status == llvm::APFloat::opInvalidOp ||
424 *IntConstantValue != ConvertedValue) {
425 ConstantValue =
APValue(*IntConstantValue);
453 Initializer->isCXX11ConstantExpr(Ctx, &ConstantValue)))) {
456 ConstantValue = R.
Val;
457 assert(ConstantValue.
isFloat());
458 llvm::APFloat FloatVal = ConstantValue.
getFloat();
461 llvm::APFloat Converted = FloatVal;
462 llvm::APFloat::opStatus ConvertStatus =
464 llvm::APFloat::rmNearestTiesToEven, &ignored);
466 llvm::APFloat::rmNearestTiesToEven, &ignored);
468 if (FloatVal.isNaN() && Converted.isNaN() &&
469 !FloatVal.isSignaling() && !Converted.isSignaling()) {
475 if (!Converted.bitwiseIsEqual(FloatVal)) {
482 if (ConvertStatus & llvm::APFloat::opOverflow) {
504 IntegralConversion: {
512 constexpr auto CanRepresentAll = [](
bool FromSigned,
unsigned FromWidth,
513 bool ToSigned,
unsigned ToWidth) {
514 return (FromWidth < ToWidth + (FromSigned == ToSigned)) &&
515 !(FromSigned && !ToSigned);
518 if (CanRepresentAll(FromSigned, FromWidth, ToSigned, ToWidth))
524 bool DependentBitField =
false;
526 if (BitField->getBitWidth()->isValueDependent())
527 DependentBitField =
true;
528 else if (
unsigned BitFieldWidth = BitField->getBitWidthValue();
529 BitFieldWidth < FromWidth) {
530 if (CanRepresentAll(FromSigned, BitFieldWidth, ToSigned, ToWidth))
534 FromWidth = BitFieldWidth;
542 std::optional<llvm::APSInt> OptInitializerValue =
544 if (!OptInitializerValue) {
548 if (DependentBitField && !(FromSigned && !ToSigned))
554 llvm::APSInt &InitializerValue = *OptInitializerValue;
555 bool Narrowing =
false;
556 if (FromWidth < ToWidth) {
559 if (InitializerValue.isSigned() && InitializerValue.isNegative())
565 InitializerValue.extend(InitializerValue.getBitWidth() + 1);
567 llvm::APSInt ConvertedValue = InitializerValue;
568 ConvertedValue = ConvertedValue.trunc(ToWidth);
569 ConvertedValue.setIsSigned(ToSigned);
570 ConvertedValue = ConvertedValue.extend(InitializerValue.getBitWidth());
571 ConvertedValue.setIsSigned(InitializerValue.isSigned());
573 if (ConvertedValue != InitializerValue)
578 ConstantValue =
APValue(InitializerValue);
594 ConstantValue = R.
Val;
595 assert(ConstantValue.
isFloat());
596 llvm::APFloat FloatVal = ConstantValue.
getFloat();
601 if (FloatVal.isNaN() && FloatVal.isSignaling()) {
617 raw_ostream &OS = llvm::errs();
618 bool PrintedSomething =
false;
621 PrintedSomething =
true;
625 if (PrintedSomething) {
631 OS <<
" (by copy constructor)";
633 OS <<
" (direct reference binding)";
635 OS <<
" (reference binding)";
637 PrintedSomething =
true;
641 if (PrintedSomething) {
645 PrintedSomething =
true;
648 if (!PrintedSomething) {
649 OS <<
"No conversions required";
656 raw_ostream &OS = llvm::errs();
664 OS <<
"aggregate initialization";
674 raw_ostream &OS = llvm::errs();
676 OS <<
"Worst list element conversion: ";
677 switch (ConversionKind) {
679 OS <<
"Standard conversion: ";
683 OS <<
"User-defined conversion: ";
687 OS <<
"Ellipsis conversion";
690 OS <<
"Ambiguous conversion";
693 OS <<
"Bad conversion";
718 struct DFIArguments {
724 struct DFIParamWithArguments : DFIArguments {
729 struct DFIDeducedMismatchArgs : DFIArguments {
730 TemplateArgumentList *TemplateArgs;
731 unsigned CallArgIndex;
736 TemplateArgumentList *TemplateArgs;
737 ConstraintSatisfaction Satisfaction;
748 Result.Result =
static_cast<unsigned>(TDK);
749 Result.HasDiagnostic =
false;
768 auto *Saved =
new (Context) DFIDeducedMismatchArgs;
779 DFIArguments *Saved =
new (Context) DFIArguments;
791 DFIParamWithArguments *Saved =
new (Context) DFIParamWithArguments;
792 Saved->Param = Info.
Param;
805 Result.HasDiagnostic =
true;
810 CNSInfo *Saved =
new (Context) CNSInfo;
820 llvm_unreachable(
"not a deduction failure");
853 Diag->~PartialDiagnosticAt();
860 static_cast<CNSInfo *
>(
Data)->Satisfaction.~ConstraintSatisfaction();
863 Diag->~PartialDiagnosticAt();
899 return TemplateParameter::getFromOpaqueValue(
Data);
904 return static_cast<DFIParamWithArguments*
>(
Data)->Param;
934 return static_cast<DFIDeducedMismatchArgs*
>(
Data)->TemplateArgs;
940 return static_cast<CNSInfo*
>(
Data)->TemplateArgs;
972 return &
static_cast<DFIArguments*
>(
Data)->FirstArg;
1004 return &
static_cast<DFIArguments*
>(
Data)->SecondArg;
1019 return static_cast<DFIDeducedMismatchArgs*
>(
Data)->CallArgIndex;
1022 return std::nullopt;
1035 for (
unsigned I = 0; I <
X->getNumParams(); ++I)
1039 if (
auto *FTX =
X->getDescribedFunctionTemplate()) {
1044 FTY->getTemplateParameters()))
1053 OverloadedOperatorKind::OO_EqualEqual);
1065 OverloadedOperatorKind::OO_ExclaimEqual);
1083 auto *NotEqFD = Op->getAsFunction();
1084 if (
auto *UD = dyn_cast<UsingShadowDecl>(Op))
1085 NotEqFD = UD->getUnderlyingDecl()->getAsFunction();
1098 return Op == OO_EqualEqual || Op == OO_Spaceship;
1106 if (Op == OverloadedOperatorKind::OO_EqualEqual) {
1107 assert(OriginalArgs.size() == 2);
1109 S,
OpLoc, OriginalArgs[1], FD))
1120void OverloadCandidateSet::destroyCandidates() {
1121 for (
iterator i = Candidates.begin(), e = Candidates.end(); i != e; ++i) {
1122 for (
auto &
C : i->Conversions)
1123 C.~ImplicitConversionSequence();
1125 i->DeductionFailure.Destroy();
1130 destroyCandidates();
1131 SlabAllocator.Reset();
1132 NumInlineBytesUsed = 0;
1136 FirstDeferredCandidate =
nullptr;
1137 DeferredCandidatesCount = 0;
1138 HasDeferredTemplateConstructors =
false;
1139 ResolutionByPerfectCandidateIsDisabled =
false;
1143 class UnbridgedCastsSet {
1153 Entry entry = { &E, E };
1154 Entries.push_back(entry);
1159 for (SmallVectorImpl<Entry>::iterator
1160 i = Entries.begin(), e = Entries.end(); i != e; ++i)
1161 *i->Addr = i->Saved;
1175 UnbridgedCastsSet *unbridgedCasts =
nullptr) {
1179 if (placeholder->getKind() == BuiltinType::Overload)
return false;
1183 if (placeholder->getKind() == BuiltinType::ARCUnbridgedCast &&
1185 unbridgedCasts->save(S, E);
1205 UnbridgedCastsSet &unbridged) {
1206 for (
unsigned i = 0, e = Args.size(); i != e; ++i)
1215 bool NewIsUsingDecl) {
1220 bool OldIsUsingDecl =
false;
1222 OldIsUsingDecl =
true;
1226 if (NewIsUsingDecl)
continue;
1233 if ((OldIsUsingDecl || NewIsUsingDecl) && !
isVisible(*I))
1241 bool UseMemberUsingDeclRules =
1242 (OldIsUsingDecl || NewIsUsingDecl) &&
CurContext->isRecord() &&
1243 !
New->getFriendObjectKind();
1247 if (UseMemberUsingDeclRules && OldIsUsingDecl) {
1253 !shouldLinkPossiblyHiddenDecl(*I,
New))
1272 }
else if (
auto *UUD = dyn_cast<UnresolvedUsingValueDecl>(OldD)) {
1279 if (UUD->getQualifier().isDependent() && !UUD->isCXXClassMember()) {
1307 if (
New->getFriendObjectKind() &&
New->getQualifier() &&
1308 !
New->getDescribedFunctionTemplate() &&
1309 !
New->getDependentSpecializationInfo() &&
1310 !
New->getType()->isDependentType()) {
1315 New->setInvalidDecl();
1327 assert(D &&
"function decl should not be null");
1328 if (
auto *A = D->
getAttr<AttrT>())
1329 return !A->isImplicit();
1335 bool UseMemberUsingDeclRules,
1336 bool ConsiderCudaAttrs,
1337 bool UseOverrideRules =
false) {
1343 if (
New->isMSVCRTEntryPoint())
1354 if ((OldTemplate ==
nullptr) != (NewTemplate ==
nullptr))
1377 if (OldQType != NewQType && OldType->isVariadic() != NewType->isVariadic())
1381 if ((
New->isMemberLikeConstrainedFriend() ||
1392 OldDecl = OldTemplate;
1393 NewDecl = NewTemplate;
1411 bool ConstraintsInTemplateHead =
1422 if (UseMemberUsingDeclRules && ConstraintsInTemplateHead &&
1423 !SameTemplateParameterList)
1425 if (!UseMemberUsingDeclRules &&
1426 (!SameTemplateParameterList || !SameReturnType))
1430 const auto *OldMethod = dyn_cast<CXXMethodDecl>(Old);
1431 const auto *NewMethod = dyn_cast<CXXMethodDecl>(
New);
1433 int OldParamsOffset = 0;
1434 int NewParamsOffset = 0;
1442 if (ThisType.isConstQualified())
1462 BS.
Quals = NormalizeQualifiers(OldMethod, BS.
Quals);
1463 DS.Quals = NormalizeQualifiers(NewMethod, DS.Quals);
1465 if (OldMethod->isExplicitObjectMemberFunction()) {
1467 DS.Quals.removeVolatile();
1470 return BS.
Quals == DS.Quals;
1474 auto BS =
Base.getNonReferenceType().getCanonicalType().split();
1475 auto DS = D.getNonReferenceType().getCanonicalType().split();
1477 if (!AreQualifiersEqual(BS, DS))
1480 if (OldMethod->isImplicitObjectMemberFunction() &&
1481 OldMethod->getParent() != NewMethod->getParent()) {
1493 if (
Base->isLValueReferenceType())
1494 return D->isLValueReferenceType();
1495 return Base->isRValueReferenceType() == D->isRValueReferenceType();
1500 auto DiagnoseInconsistentRefQualifiers = [&]() {
1501 if (SemaRef.
LangOpts.CPlusPlus23 && !UseOverrideRules)
1503 if (OldMethod->getRefQualifier() == NewMethod->getRefQualifier())
1505 if (OldMethod->isExplicitObjectMemberFunction() ||
1506 NewMethod->isExplicitObjectMemberFunction())
1508 if (!UseMemberUsingDeclRules && (OldMethod->getRefQualifier() ==
RQ_None ||
1509 NewMethod->getRefQualifier() ==
RQ_None)) {
1510 SemaRef.
Diag(NewMethod->getLocation(), diag::err_ref_qualifier_overload)
1511 << NewMethod->getRefQualifier() << OldMethod->getRefQualifier();
1512 SemaRef.
Diag(OldMethod->getLocation(), diag::note_previous_declaration);
1518 if (OldMethod && OldMethod->isExplicitObjectMemberFunction())
1520 if (NewMethod && NewMethod->isExplicitObjectMemberFunction())
1523 if (OldType->getNumParams() - OldParamsOffset !=
1524 NewType->getNumParams() - NewParamsOffset ||
1526 {OldType->param_type_begin() + OldParamsOffset,
1527 OldType->param_type_end()},
1528 {NewType->param_type_begin() + NewParamsOffset,
1529 NewType->param_type_end()},
1534 if (OldMethod && NewMethod && !OldMethod->isStatic() &&
1535 !NewMethod->isStatic()) {
1536 bool HaveCorrespondingObjectParameters = [&](
const CXXMethodDecl *Old,
1538 auto NewObjectType =
New->getFunctionObjectParameterReferenceType();
1542 return F->getRefQualifier() ==
RQ_None &&
1543 !F->isExplicitObjectMemberFunction();
1546 if (IsImplicitWithNoRefQual(Old) != IsImplicitWithNoRefQual(
New) &&
1547 CompareType(OldObjectType.getNonReferenceType(),
1548 NewObjectType.getNonReferenceType()))
1550 return CompareType(OldObjectType, NewObjectType);
1551 }(OldMethod, NewMethod);
1553 if (!HaveCorrespondingObjectParameters) {
1554 if (DiagnoseInconsistentRefQualifiers())
1559 if (!UseOverrideRules || (!NewMethod->isExplicitObjectMemberFunction() &&
1560 !OldMethod->isExplicitObjectMemberFunction()))
1565 if (!UseOverrideRules &&
1569 if (!NewRC != !OldRC)
1579 if (NewMethod && OldMethod && OldMethod->isImplicitObjectMemberFunction() &&
1580 NewMethod->isImplicitObjectMemberFunction()) {
1581 if (DiagnoseInconsistentRefQualifiers())
1595 NewI =
New->specific_attr_begin<EnableIfAttr>(),
1596 NewE =
New->specific_attr_end<EnableIfAttr>(),
1599 NewI != NewE || OldI != OldE; ++NewI, ++OldI) {
1600 if (NewI == NewE || OldI == OldE)
1602 llvm::FoldingSetNodeID NewID, OldID;
1603 NewI->getCond()->Profile(NewID, SemaRef.
Context,
true);
1604 OldI->getCond()->Profile(OldID, SemaRef.
Context,
true);
1610 if (SemaRef.
getLangOpts().CUDA && ConsiderCudaAttrs) {
1618 "Unexpected invalid target.");
1622 if (NewTarget != OldTarget) {
1625 if (OldMethod && NewMethod && OldMethod->isVirtual() &&
1626 OldMethod->isConstexpr() && !NewMethod->isConstexpr() &&
1644 bool UseMemberUsingDeclRules,
bool ConsiderCudaAttrs) {
1650 bool UseMemberUsingDeclRules,
bool ConsiderCudaAttrs) {
1663 bool SuppressUserConversions,
1665 bool InOverloadResolution,
1667 bool AllowObjCWritebackConversion,
1668 bool AllowObjCConversionOnExplicit) {
1671 if (SuppressUserConversions) {
1682 Conversions, AllowExplicit,
1683 AllowObjCConversionOnExplicit)) {
1704 bool FromListInit =
false;
1705 if (
const auto *InitList = dyn_cast<InitListExpr>(From);
1706 InitList && InitList->getNumInits() == 1 &&
1708 const Expr *SingleInit = InitList->getInit(0);
1709 FromType = SingleInit->
getType();
1711 FromListInit =
true;
1720 if ((FromCanon == ToCanon ||
1732 if (ToCanon != FromCanon)
1743 Cand != Conversions.
end(); ++Cand)
1784static ImplicitConversionSequence
1786 bool SuppressUserConversions,
1788 bool InOverloadResolution,
1790 bool AllowObjCWritebackConversion,
1791 bool AllowObjCConversionOnExplicit) {
1794 ICS.
Standard, CStyle, AllowObjCWritebackConversion)){
1840 bool CanConvert =
false;
1846 FromResType->getWrappedType()) &&
1848 FromResType->getContainedType()) &&
1849 ToResType->getAttrs() == FromResType->getAttrs())
1851 }
else if (ToTy->isHLSLResourceType()) {
1865 AllowExplicit, InOverloadResolution, CStyle,
1866 AllowObjCWritebackConversion,
1867 AllowObjCConversionOnExplicit);
1870ImplicitConversionSequence
1872 bool SuppressUserConversions,
1874 bool InOverloadResolution,
1876 bool AllowObjCWritebackConversion) {
1877 return ::TryImplicitConversion(*
this, From, ToType, SuppressUserConversions,
1878 AllowExplicit, InOverloadResolution, CStyle,
1879 AllowObjCWritebackConversion,
1885 bool AllowExplicit) {
1890 bool AllowObjCWritebackConversion =
1897 *
this, From, ToType,
1899 AllowExplicit ? AllowedExplicit::All : AllowedExplicit::None,
1901 false, AllowObjCWritebackConversion,
1915 if (
Context.hasSameUnqualifiedType(FromType, ToType))
1928 if (TyClass != CanFrom->getTypeClass())
return false;
1929 if (TyClass != Type::FunctionProto && TyClass != Type::FunctionNoProto) {
1930 if (TyClass == Type::Pointer) {
1933 }
else if (TyClass == Type::BlockPointer) {
1936 }
else if (TyClass == Type::MemberPointer) {
1943 CanTo = ToMPT->getPointeeType();
1949 TyClass = CanTo->getTypeClass();
1950 if (TyClass != CanFrom->getTypeClass())
return false;
1951 if (TyClass != Type::FunctionProto && TyClass != Type::FunctionNoProto)
1961 bool Changed =
false;
1969 const auto *FromFPT = dyn_cast<FunctionProtoType>(FromFn);
1970 const auto *ToFPT = dyn_cast<FunctionProtoType>(ToFn);
1972 if (FromFPT && ToFPT) {
1973 if (FromFPT->hasCFIUncheckedCallee() != ToFPT->hasCFIUncheckedCallee()) {
1975 FromFPT->getReturnType(), FromFPT->getParamTypes(),
1976 FromFPT->getExtProtoInfo().withCFIUncheckedCallee(
1977 ToFPT->hasCFIUncheckedCallee()));
1985 if (FromFPT && ToFPT) {
1986 if (FromFPT->isNothrow() && !ToFPT->isNothrow()) {
1998 bool CanUseToFPT, CanUseFromFPT;
1999 if (
Context.mergeExtParameterInfo(ToFPT, FromFPT, CanUseToFPT,
2000 CanUseFromFPT, NewParamInfos) &&
2001 CanUseToFPT && !CanUseFromFPT) {
2004 NewParamInfos.empty() ?
nullptr : NewParamInfos.data();
2006 FromFPT->getParamTypes(), ExtInfo);
2011 if (
Context.hasAnyFunctionEffects()) {
2016 const auto FromFX = FromFPT->getFunctionEffects();
2017 const auto ToFX = ToFPT->getFunctionEffects();
2018 if (FromFX != ToFX) {
2022 FromFPT->getReturnType(), FromFPT->getParamTypes(), ExtInfo);
2032 assert(
QualType(FromFn, 0).isCanonical());
2033 if (
QualType(FromFn, 0) != CanTo)
return false;
2060 if ((&FromSem == &llvm::APFloat::PPCDoubleDouble() &&
2061 &ToSem == &llvm::APFloat::IEEEquad()) ||
2062 (&FromSem == &llvm::APFloat::IEEEquad() &&
2063 &ToSem == &llvm::APFloat::PPCDoubleDouble()))
2119 bool InOverloadResolution,
bool CStyle) {
2129 if (ToMatrixType && FromMatrixType) {
2131 unsigned ToCols = ToMatrixType->getNumColumns();
2132 if (FromCols < ToCols)
2135 unsigned FromRows = FromMatrixType->
getNumRows();
2136 unsigned ToRows = ToMatrixType->getNumRows();
2137 if (FromRows < ToRows)
2140 if (FromRows == ToRows && FromCols == ToCols)
2146 QualType ToElTy = ToMatrixType->getElementType();
2155 QualType ToElTy = ToMatrixType->getElementType();
2160 if (FromMatrixType && !ToMatrixType) {
2179 bool InOverloadResolution,
bool CStyle) {
2196 if (ToExtType && FromExtType) {
2198 unsigned ToElts = ToExtType->getNumElements();
2199 if (FromElts < ToElts)
2201 if (FromElts == ToElts)
2207 QualType ToElTy = ToExtType->getElementType();
2212 if (FromExtType && !ToExtType) {
2226 if (ToExtType->getNumElements() != FromExtType->getNumElements())
2231 FromExtType->getElementType()->isIntegerType()) {
2243 QualType ToElTy = ToExtType->getElementType();
2278 !ToType->
hasAttr(attr::ArmMveStrictPolymorphism))) {
2283 !InOverloadResolution && !CStyle) {
2285 << FromType << ToType;
2296 bool InOverloadResolution,
2297 StandardConversionSequence &SCS,
2309 bool InOverloadResolution,
2312 bool AllowObjCWritebackConversion) {
2338 FromType = Fn->getType();
2358 if (Method && !Method->isStatic() &&
2359 !Method->isExplicitObjectMemberFunction()) {
2361 "Non-unary operator on non-static member address");
2364 "Non-address-of operator on non-static member address");
2366 FromType, std::nullopt, Method->getParent());
2370 "Non-address-of operator for overloaded function expression");
2416 FromType =
Atomic->getValueType();
2451 if (
auto *FD = dyn_cast<FunctionDecl>(DRE->getDecl()))
2471 bool IncompatibleObjC =
false;
2526 }
else if (AllowObjCWritebackConversion &&
2530 FromType, IncompatibleObjC)) {
2536 InOverloadResolution, FromType)) {
2540 From, InOverloadResolution, CStyle)) {
2545 From, InOverloadResolution, CStyle)) {
2555 S, From, ToType, InOverloadResolution, SCS, CStyle)) {
2591 bool ObjCLifetimeConversion;
2597 ObjCLifetimeConversion)) {
2616 CanonFrom = CanonTo;
2621 if (CanonFrom == CanonTo)
2626 if (S.
getLangOpts().CPlusPlus || !InOverloadResolution)
2638 case AssignConvertType::
2639 CompatibleVoidPtrToNonVoidPtr:
2672 bool InOverloadResolution,
2680 const RecordDecl *UD = UT->getDecl()->getDefinitionOrSelf();
2681 if (!UD->
hasAttr<TransparentUnionAttr>())
2684 for (
const auto *it : UD->
fields()) {
2687 ToType = it->getType();
2713 return To->
getKind() == BuiltinType::Int;
2716 return To->
getKind() == BuiltinType::UInt;
2740 if (FromED->isScoped())
2747 if (FromED->isFixed()) {
2748 QualType Underlying = FromED->getIntegerType();
2749 return Context.hasSameUnqualifiedType(Underlying, ToType) ||
2756 return Context.hasSameUnqualifiedType(ToType, FromED->getPromotionType());
2781 uint64_t FromSize =
Context.getTypeSize(FromType);
2790 for (
int Idx = 0; Idx < 6; ++Idx) {
2791 uint64_t ToSize =
Context.getTypeSize(PromoteTypes[Idx]);
2792 if (FromSize < ToSize ||
2793 (FromSize == ToSize &&
2794 FromIsSigned == PromoteTypes[Idx]->isSignedIntegerType())) {
2798 return Context.hasSameUnqualifiedType(ToType, PromoteTypes[Idx]);
2819 std::optional<llvm::APSInt> BitWidth;
2822 MemberDecl->getBitWidth()->getIntegerConstantExpr(
Context))) {
2823 llvm::APSInt ToSize(BitWidth->getBitWidth(), BitWidth->isUnsigned());
2824 ToSize =
Context.getTypeSize(ToType);
2827 if (*BitWidth < ToSize ||
2829 return To->
getKind() == BuiltinType::Int;
2835 return To->
getKind() == BuiltinType::UInt;
2853 return Context.getTypeSize(FromType) <
Context.getTypeSize(ToType);
2863 if (FromBuiltin->getKind() == BuiltinType::Float &&
2864 ToBuiltin->getKind() == BuiltinType::Double)
2871 (FromBuiltin->getKind() == BuiltinType::Float ||
2872 FromBuiltin->getKind() == BuiltinType::Double) &&
2873 (ToBuiltin->getKind() == BuiltinType::LongDouble ||
2874 ToBuiltin->getKind() == BuiltinType::Float128 ||
2875 ToBuiltin->getKind() == BuiltinType::Ibm128))
2880 if (
getLangOpts().
HLSL && FromBuiltin->getKind() == BuiltinType::Half &&
2881 (ToBuiltin->getKind() == BuiltinType::Float ||
2882 ToBuiltin->getKind() == BuiltinType::Double))
2887 FromBuiltin->getKind() == BuiltinType::Half &&
2888 ToBuiltin->getKind() == BuiltinType::Float)
2920 bool StripObjCLifetime =
false) {
2923 "Invalid similarly-qualified pointer type");
2934 if (StripObjCLifetime)
2946 return Context.getObjCObjectPointerType(ToPointee);
2947 return Context.getPointerType(ToPointee);
2955 return Context.getObjCObjectPointerType(QualifiedCanonToPointee);
2956 return Context.getPointerType(QualifiedCanonToPointee);
2960 bool InOverloadResolution,
2966 return !InOverloadResolution;
2974 bool InOverloadResolution,
2976 bool &IncompatibleObjC) {
2977 IncompatibleObjC =
false;
2985 ConvertedType = ToType;
2992 ConvertedType = ToType;
2999 ConvertedType = ToType;
3007 ConvertedType = ToType;
3017 ConvertedType = ToType;
3039 if (
Context.hasSameUnqualifiedType(FromPointeeType, ToPointeeType))
3066 Context.typesAreCompatible(FromPointeeType, ToPointeeType)) {
3088 !
Context.hasSameUnqualifiedType(FromPointeeType, ToPointeeType) &&
3097 Context.areCompatibleVectorTypes(FromPointeeType, ToPointeeType)) {
3116 return Context.getQualifiedType(
T, Qs);
3118 return Context.getQualifiedType(
T.getUnqualifiedType(), Qs);
3123 bool &IncompatibleObjC) {
3136 if (ToObjCPtr && FromObjCPtr) {
3144 if (
Context.canAssignObjCInterfaces(ToObjCPtr, FromObjCPtr)) {
3158 if (
Context.canAssignObjCInterfaces(FromObjCPtr, ToObjCPtr)) {
3162 IncompatibleObjC =
true;
3178 if (FromObjCPtr && FromObjCPtr->isObjCBuiltinType()) {
3207 IncompatibleObjC)) {
3209 IncompatibleObjC =
true;
3210 ConvertedType =
Context.getPointerType(ConvertedType);
3219 IncompatibleObjC)) {
3221 ConvertedType =
Context.getPointerType(ConvertedType);
3234 if (FromFunctionType && ToFunctionType) {
3237 if (
Context.getCanonicalType(FromPointeeType)
3238 ==
Context.getCanonicalType(ToPointeeType))
3243 if (FromFunctionType->
getNumParams() != ToFunctionType->getNumParams() ||
3244 FromFunctionType->
isVariadic() != ToFunctionType->isVariadic() ||
3245 FromFunctionType->
getMethodQuals() != ToFunctionType->getMethodQuals())
3248 bool HasObjCConversion =
false;
3250 Context.getCanonicalType(ToFunctionType->getReturnType())) {
3253 ToFunctionType->getReturnType(),
3254 ConvertedType, IncompatibleObjC)) {
3256 HasObjCConversion =
true;
3263 for (
unsigned ArgIdx = 0, NumArgs = FromFunctionType->
getNumParams();
3264 ArgIdx != NumArgs; ++ArgIdx) {
3266 QualType ToArgType = ToFunctionType->getParamType(ArgIdx);
3267 if (
Context.getCanonicalType(FromArgType)
3268 ==
Context.getCanonicalType(ToArgType)) {
3271 ConvertedType, IncompatibleObjC)) {
3273 HasObjCConversion =
true;
3280 if (HasObjCConversion) {
3284 IncompatibleObjC =
true;
3316 if (!FromFunctionType || !ToFunctionType)
3319 if (
Context.hasSameType(FromPointeeType, ToPointeeType))
3324 if (FromFunctionType->
getNumParams() != ToFunctionType->getNumParams() ||
3325 FromFunctionType->
isVariadic() != ToFunctionType->isVariadic())
3330 if (FromEInfo != ToEInfo)
3333 bool IncompatibleObjC =
false;
3335 ToFunctionType->getReturnType())) {
3339 QualType LHS = ToFunctionType->getReturnType();
3344 if (
Context.hasSameType(RHS,LHS)) {
3347 ConvertedType, IncompatibleObjC)) {
3348 if (IncompatibleObjC)
3357 for (
unsigned ArgIdx = 0, NumArgs = FromFunctionType->
getNumParams();
3358 ArgIdx != NumArgs; ++ArgIdx) {
3359 IncompatibleObjC =
false;
3361 QualType ToArgType = ToFunctionType->getParamType(ArgIdx);
3362 if (
Context.hasSameType(FromArgType, ToArgType)) {
3365 ConvertedType, IncompatibleObjC)) {
3366 if (IncompatibleObjC)
3375 bool CanUseToFPT, CanUseFromFPT;
3376 if (!
Context.mergeExtParameterInfo(ToFunctionType, FromFunctionType,
3377 CanUseToFPT, CanUseFromFPT,
3381 ConvertedType = ToType;
3420 ToMember->getMostRecentCXXRecordDecl())) {
3422 if (ToMember->isSugared())
3424 ToMember->getMostRecentCXXRecordDecl());
3426 PDiag << ToMember->getQualifier();
3427 if (FromMember->isSugared())
3429 FromMember->getMostRecentCXXRecordDecl());
3431 PDiag << FromMember->getQualifier();
3449 !FromType->
getAs<TemplateSpecializationType>()) {
3455 if (
Context.hasSameType(FromType, ToType)) {
3464 if (!FromFunction || !ToFunction) {
3469 if (FromFunction->
getNumParams() != ToFunction->getNumParams()) {
3479 << ToFunction->getParamType(ArgPos)
3486 ToFunction->getReturnType())) {
3492 if (FromFunction->
getMethodQuals() != ToFunction->getMethodQuals()) {
3515 assert(llvm::size(Old) == llvm::size(
New) &&
3516 "Can't compare parameters of functions with different number of "
3519 for (
auto &&[Idx,
Type] : llvm::enumerate(Old)) {
3521 size_t J =
Reversed ? (llvm::size(
New) - Idx - 1) : Idx;
3526 Context.removePtrSizeAddrSpace(
Type.getUnqualifiedType());
3528 Context.removePtrSizeAddrSpace((
New.begin() + J)->getUnqualifiedType());
3530 if (!
Context.hasSameType(OldType, NewType)) {
3555 unsigned OldIgnore =
3557 unsigned NewIgnore =
3564 NewPT->param_types().slice(NewIgnore),
3571 bool IgnoreBaseAccess,
3574 bool IsCStyleOrFunctionalCast = IgnoreBaseAccess;
3583 PDiag(diag::warn_impcast_bool_to_null_pointer)
3594 if (FromPointeeType->
isRecordType() && ToPointeeType->isRecordType() &&
3595 !
Context.hasSameUnqualifiedType(FromPointeeType, ToPointeeType)) {
3598 unsigned InaccessibleID = 0;
3599 unsigned AmbiguousID = 0;
3601 InaccessibleID = diag::err_upcast_to_inaccessible_base;
3602 AmbiguousID = diag::err_ambiguous_derived_to_base_conv;
3605 FromPointeeType, ToPointeeType, InaccessibleID, AmbiguousID,
3607 &BasePath, IgnoreBaseAccess))
3611 Kind = CK_DerivedToBase;
3614 if (
Diagnose && !IsCStyleOrFunctionalCast &&
3615 FromPointeeType->
isFunctionType() && ToPointeeType->isVoidType()) {
3617 "this should only be possible with MSVCCompat!");
3629 if (FromPtrType->isObjCBuiltinType() || ToPtrType->isObjCBuiltinType())
3632 Kind = CK_BlockPointerToObjCPointerCast;
3634 Kind = CK_CPointerToObjCPointerCast;
3638 Kind = CK_AnyPointerToBlockPointerCast;
3644 Kind = CK_NullToPointer;
3651 bool InOverloadResolution,
3661 ConvertedType = ToType;
3677 ConvertedType =
Context.getMemberPointerType(
3691 if (
Context.getTargetInfo().getCXXABI().isMicrosoft()) {
3699 Kind = CK_NullToMemberPointer;
3717 PD <<
Context.getCanonicalTagType(Cls);
3727 std::swap(
Base, Derived);
3736 PD <<
int(Direction);
3744 DiagFromTo(PD) <<
QualType(VBase, 0) << OpRange;
3752 ? CK_DerivedToBaseMemberPointer
3753 : CK_BaseToDerivedMemberPointer;
3755 if (!IgnoreBaseAccess)
3759 ? diag::err_upcast_to_inaccessible_base
3760 : diag::err_downcast_from_inaccessible_base,
3762 NestedNameSpecifier BaseQual = FromPtrType->getQualifier(),
3763 DerivedQual = ToPtrType->getQualifier();
3764 if (Direction == MemberPointerConversionDirection::Upcast)
3765 std::swap(BaseQual, DerivedQual);
3766 DiagCls(PD, DerivedQual, Derived);
3767 DiagCls(PD, BaseQual, Base);
3802 bool CStyle,
bool IsTopLevel,
3803 bool &PreviousToQualsIncludeConst,
3804 bool &ObjCLifetimeConversion,
3817 ObjCLifetimeConversion =
true;
3857 !PreviousToQualsIncludeConst)
3875 PreviousToQualsIncludeConst =
3876 PreviousToQualsIncludeConst && ToQuals.
hasConst();
3882 bool CStyle,
bool &ObjCLifetimeConversion) {
3883 FromType =
Context.getCanonicalType(FromType);
3884 ToType =
Context.getCanonicalType(ToType);
3885 ObjCLifetimeConversion =
false;
3895 bool PreviousToQualsIncludeConst =
true;
3896 bool UnwrappedAnyPointer =
false;
3897 while (
Context.UnwrapSimilarTypes(FromType, ToType)) {
3899 !UnwrappedAnyPointer,
3900 PreviousToQualsIncludeConst,
3903 UnwrappedAnyPointer =
true;
3911 return UnwrappedAnyPointer &&
Context.hasSameUnqualifiedType(FromType,ToType);
3920 bool InOverloadResolution,
3929 InOverloadResolution, InnerSCS,
3946 if (CtorType->getNumParams() > 0) {
3947 QualType FirstArg = CtorType->getParamType(0);
3959 bool AllowExplicit) {
3966 bool Usable = !Info.Constructor->isInvalidDecl() &&
3969 bool SuppressUserConversions =
false;
3970 if (Info.ConstructorTmpl)
3973 CandidateSet, SuppressUserConversions,
3978 CandidateSet, SuppressUserConversions,
3979 false, AllowExplicit);
3983 bool HadMultipleCandidates = (CandidateSet.
size() > 1);
3986 switch (
auto Result =
4010 llvm_unreachable(
"Invalid OverloadResult!");
4032 bool AllowObjCConversionOnExplicit) {
4033 assert(AllowExplicit != AllowedExplicit::None ||
4034 !AllowObjCConversionOnExplicit);
4038 bool ConstructorsOnly =
false;
4042 if (
const RecordType *ToRecordType = ToType->
getAsCanonical<RecordType>()) {
4054 ConstructorsOnly =
true;
4058 }
else if (
auto *ToRecordDecl =
4059 dyn_cast<CXXRecordDecl>(ToRecordType->getDecl())) {
4060 ToRecordDecl = ToRecordDecl->getDefinitionOrSelf();
4062 Expr **Args = &From;
4063 unsigned NumArgs = 1;
4064 bool ListInitializing =
false;
4065 if (
InitListExpr *InitList = dyn_cast<InitListExpr>(From)) {
4068 S, From, ToType, ToRecordDecl, User, CandidateSet,
4069 AllowExplicit == AllowedExplicit::All);
4078 Args = InitList->getInits();
4079 NumArgs = InitList->getNumInits();
4080 ListInitializing =
true;
4088 bool Usable = !Info.Constructor->isInvalidDecl();
4089 if (!ListInitializing)
4090 Usable = Usable && Info.Constructor->isConvertingConstructor(
4093 bool SuppressUserConversions = !ConstructorsOnly;
4101 if (SuppressUserConversions && ListInitializing) {
4102 SuppressUserConversions =
4107 if (Info.ConstructorTmpl)
4109 Info.ConstructorTmpl, Info.FoundDecl,
4111 CandidateSet, SuppressUserConversions,
4113 AllowExplicit == AllowedExplicit::All);
4119 SuppressUserConversions,
4121 AllowExplicit == AllowedExplicit::All);
4131 }
else if (
const RecordType *FromRecordType =
4133 if (
auto *FromRecordDecl =
4134 dyn_cast<CXXRecordDecl>(FromRecordType->getDecl())) {
4135 FromRecordDecl = FromRecordDecl->getDefinitionOrSelf();
4137 const auto &Conversions = FromRecordDecl->getVisibleConversionFunctions();
4138 for (
auto I = Conversions.begin(), E = Conversions.end(); I != E; ++I) {
4147 if ((ConvTemplate = dyn_cast<FunctionTemplateDecl>(D)))
4154 ConvTemplate, FoundDecl, ActingContext, From, ToType,
4155 CandidateSet, AllowObjCConversionOnExplicit,
4156 AllowExplicit != AllowedExplicit::None);
4159 CandidateSet, AllowObjCConversionOnExplicit,
4160 AllowExplicit != AllowedExplicit::None);
4165 bool HadMultipleCandidates = (CandidateSet.
size() > 1);
4168 switch (
auto Result =
4174 = dyn_cast<CXXConstructorDecl>(Best->Function)) {
4186 if (Best->Conversions[0].isEllipsis())
4189 User.
Before = Best->Conversions[0].Standard;
4202 = dyn_cast<CXXConversionDecl>(Best->Function)) {
4204 assert(Best->HasFinalConversion);
4212 User.
Before = Best->Conversions[0].Standard;
4227 User.
After = Best->FinalConversion;
4230 llvm_unreachable(
"Not a constructor or conversion function?");
4239 llvm_unreachable(
"Invalid OverloadResult!");
4249 CandidateSet, AllowedExplicit::None,
false);
4264 diag::err_typecheck_nonviable_condition_incomplete,
4271 *
this, From, Cands);
4297 if (!Conv1 || !Conv2)
4312 if (Block1 != Block2)
4325 if (Conv1FuncRet && Conv2FuncRet &&
4334 CallOp->getType()->castAs<
FunctionType>()->getCallConv();
4336 CallOpProto->isVariadic(),
false);
4338 CallOpProto->isVariadic(),
true);
4340 CallingConv PrefOrder[] = {DefaultFree, DefaultMember, CallOpCC};
4435 if (!ICS1.
isBad()) {
4436 bool StdInit1 =
false, StdInit2 =
false;
4443 if (StdInit1 != StdInit2)
4454 CAT2->getElementType())) {
4456 if (CAT1->getSize() != CAT2->getSize())
4458 return CAT1->getSize().ult(CAT2->getSize())
4493 if (ConvFunc1 == ConvFunc2)
4595 if (!
Enum->isFixed())
4631 else if (Rank2 < Rank1)
4666 bool SCS1ConvertsToVoid
4668 bool SCS2ConvertsToVoid
4670 if (SCS1ConvertsToVoid != SCS2ConvertsToVoid) {
4675 }
else if (!SCS1ConvertsToVoid && !SCS2ConvertsToVoid) {
4681 }
else if (SCS1ConvertsToVoid && SCS2ConvertsToVoid &&
4710 if (FromObjCPtr1 && FromObjCPtr2) {
4715 if (AssignLeft != AssignRight) {
4750 if (UnqualT1 == UnqualT2) {
4812 if (SCS1IsCompatibleVectorConversion != SCS2IsCompatibleVectorConversion)
4813 return SCS1IsCompatibleVectorConversion
4820 bool SCS1IsCompatibleSVEVectorConversion =
4822 bool SCS2IsCompatibleSVEVectorConversion =
4825 if (SCS1IsCompatibleSVEVectorConversion !=
4826 SCS2IsCompatibleSVEVectorConversion)
4827 return SCS1IsCompatibleSVEVectorConversion
4834 bool SCS1IsCompatibleRVVVectorConversion =
4836 bool SCS2IsCompatibleRVVVectorConversion =
4839 if (SCS1IsCompatibleRVVVectorConversion !=
4840 SCS2IsCompatibleRVVVectorConversion)
4841 return SCS1IsCompatibleRVVVectorConversion
4881 if (UnqualT1 == UnqualT2)
4899 bool ObjCLifetimeConversion;
4909 if (CanPick1 != CanPick2)
4963 if (FromPointee1 == FromPointee2 && ToPointee1 != ToPointee2) {
4971 if (FromPointee1 != FromPointee2 && ToPointee1 == ToPointee2) {
4988 if (FromPtr1 && FromPtr2 && ToPtr1 && ToPtr2) {
4995 bool FromAssignRight
5004 if (ToPtr1->isObjCIdType() &&
5005 (ToPtr2->isObjCQualifiedIdType() || ToPtr2->getInterfaceDecl()))
5007 if (ToPtr2->isObjCIdType() &&
5008 (ToPtr1->isObjCQualifiedIdType() || ToPtr1->getInterfaceDecl()))
5013 if (ToPtr1->isObjCQualifiedIdType() && ToPtr2->getInterfaceDecl())
5015 if (ToPtr2->isObjCQualifiedIdType() && ToPtr1->getInterfaceDecl())
5020 if (ToPtr1->isObjCClassType() &&
5021 (ToPtr2->isObjCQualifiedClassType() || ToPtr2->getInterfaceDecl()))
5023 if (ToPtr2->isObjCClassType() &&
5024 (ToPtr1->isObjCQualifiedClassType() || ToPtr1->getInterfaceDecl()))
5029 if (ToPtr1->isObjCQualifiedClassType() && ToPtr2->getInterfaceDecl())
5031 if (ToPtr2->isObjCQualifiedClassType() && ToPtr1->getInterfaceDecl())
5037 (ToAssignLeft != ToAssignRight)) {
5048 }
else if (IsSecondSame)
5057 (FromAssignLeft != FromAssignRight))
5071 CXXRecordDecl *FromPointee1 = FromMemPointer1->getMostRecentCXXRecordDecl();
5076 if (FromPointee1 == FromPointee2 && ToPointee1 != ToPointee2) {
5083 if (ToPointee1 == ToPointee2 && FromPointee1 != FromPointee2) {
5121 if (!
T.getQualifiers().hasUnaligned())
5135 "T1 must be the pointee type of the reference type");
5136 assert(!OrigT2->
isReferenceType() &&
"T2 cannot be a reference type");
5159 if (UnqualT1 == UnqualT2) {
5163 Conv |= ReferenceConversions::DerivedToBase;
5166 Context.canBindObjCObjectType(UnqualT1, UnqualT2))
5167 Conv |= ReferenceConversions::ObjC;
5170 Conv |= ReferenceConversions::Function;
5174 bool ConvertedReferent = Conv != 0;
5178 bool PreviousToQualsIncludeConst =
true;
5179 bool TopLevel =
true;
5185 Conv |= ReferenceConversions::Qualification;
5191 Conv |= ReferenceConversions::NestedQualification;
5199 bool ObjCLifetimeConversion =
false;
5201 PreviousToQualsIncludeConst,
5203 return (ConvertedReferent ||
Context.hasSimilarType(T1, T2))
5208 if (ObjCLifetimeConversion)
5209 Conv |= ReferenceConversions::ObjCLifetime;
5212 }
while (
Context.UnwrapSimilarTypes(T1, T2));
5217 return (ConvertedReferent ||
Context.hasSameUnqualifiedType(T1, T2))
5228 bool AllowExplicit) {
5229 assert(T2->
isRecordType() &&
"Can only find conversions of record types.");
5233 const auto &Conversions = T2RecordDecl->getVisibleConversionFunctions();
5234 for (
auto I = Conversions.begin(), E = Conversions.end(); I != E; ++I) {
5241 = dyn_cast<FunctionTemplateDecl>(D);
5258 if (!ConvTemplate &&
5282 ConvTemplate, I.getPair(), ActingDC,
Init, DeclType, CandidateSet,
5283 false, AllowExplicit);
5286 Conv, I.getPair(), ActingDC,
Init, DeclType, CandidateSet,
5287 false, AllowExplicit);
5290 bool HadMultipleCandidates = (CandidateSet.
size() > 1);
5296 assert(Best->HasFinalConversion);
5308 if (!Best->FinalConversion.DirectBinding)
5320 "Expected a direct reference binding!");
5326 Cand != CandidateSet.
end(); ++Cand)
5338 llvm_unreachable(
"Invalid OverloadResult!");
5343static ImplicitConversionSequence
5346 bool SuppressUserConversions,
5347 bool AllowExplicit) {
5348 assert(DeclType->
isReferenceType() &&
"Reference init needs a reference");
5375 auto SetAsReferenceBinding = [&](
bool BindsDirectly) {
5380 ICS.
Standard.
Second = (RefConv & Sema::ReferenceConversions::DerivedToBase)
5382 : (RefConv & Sema::ReferenceConversions::ObjC)
5390 Sema::ReferenceConversions::NestedQualification)
5404 (RefConv & Sema::ReferenceConversions::ObjCLifetime) != 0;
5428 SetAsReferenceBinding(
true);
5477 SetAsReferenceBinding(S.
getLangOpts().CPlusPlus11 ||
5568 AllowedExplicit::None,
5593 if (isRValRef && LValRefType) {
5610static ImplicitConversionSequence
5612 bool SuppressUserConversions,
5613 bool InOverloadResolution,
5614 bool AllowObjCWritebackConversion,
5615 bool AllowExplicit =
false);
5619static ImplicitConversionSequence
5621 bool SuppressUserConversions,
5622 bool InOverloadResolution,
5623 bool AllowObjCWritebackConversion) {
5636 if (
const auto *IAT = dyn_cast<IncompleteArrayType>(AT))
5638 InitTy = IAT->getElementType();
5664 if (From->
getNumInits() == 1 && !IsDesignatedInit) {
5670 SuppressUserConversions,
5671 InOverloadResolution,
5672 AllowObjCWritebackConversion);
5680 Result.setStandard();
5681 Result.Standard.setAsIdentityConversion();
5682 Result.Standard.setFromType(ToType);
5683 Result.Standard.setAllToTypes(ToType);
5708 bool IsUnbounded =
false;
5712 if (CT->getSize().ult(e)) {
5716 Result.setInitializerListContainerType(ContTy, IsUnbounded);
5719 if (CT->getSize().ugt(e)) {
5725 S, &EmptyList, InitTy, SuppressUserConversions,
5726 InOverloadResolution, AllowObjCWritebackConversion);
5727 if (DfltElt.
isBad()) {
5731 Result.setInitializerListContainerType(ContTy, IsUnbounded);
5742 Result.setInitializerListContainerType(ContTy, IsUnbounded);
5751 Result.setStandard();
5752 Result.Standard.setAsIdentityConversion();
5753 Result.Standard.setFromType(InitTy);
5754 Result.Standard.setAllToTypes(InitTy);
5755 for (
unsigned i = 0; i < e; ++i) {
5758 S,
Init, InitTy, SuppressUserConversions, InOverloadResolution,
5759 AllowObjCWritebackConversion);
5769 if (Result.isBad()) {
5770 Result.setInitializerListContainerType(ContTy, IsUnbounded);
5780 S, From->
getEndLoc(), DfltElt, Result) ==
5798 AllowedExplicit::None,
5799 InOverloadResolution,
false,
5800 AllowObjCWritebackConversion,
5818 Result.setUserDefined();
5819 Result.UserDefined.Before.setAsIdentityConversion();
5821 Result.UserDefined.Before.setFromType(
QualType());
5822 Result.UserDefined.Before.setAllToTypes(
QualType());
5824 Result.UserDefined.After.setAsIdentityConversion();
5825 Result.UserDefined.After.setFromType(ToType);
5826 Result.UserDefined.After.setAllToTypes(ToType);
5827 Result.UserDefined.ConversionFunction =
nullptr;
5844 if (From->
getNumInits() == 1 && !IsDesignatedInit) {
5865 SuppressUserConversions,
5873 InOverloadResolution,
5874 AllowObjCWritebackConversion);
5875 if (Result.isFailure())
5877 assert(!Result.isEllipsis() &&
5878 "Sub-initialization cannot result in ellipsis conversion.");
5884 Result.UserDefined.After;
5912 S, From->
getInit(0), ToType, SuppressUserConversions,
5913 InOverloadResolution, AllowObjCWritebackConversion);
5914 if (Result.isStandard())
5915 Result.Standard.FromBracedInitList =
true;
5919 else if (NumInits == 0) {
5920 Result.setStandard();
5921 Result.Standard.setAsIdentityConversion();
5922 Result.Standard.setFromType(ToType);
5923 Result.Standard.setAllToTypes(ToType);
5940static ImplicitConversionSequence
5942 bool SuppressUserConversions,
5943 bool InOverloadResolution,
5944 bool AllowObjCWritebackConversion,
5945 bool AllowExplicit) {
5946 if (
InitListExpr *FromInitList = dyn_cast<InitListExpr>(From))
5948 InOverloadResolution,AllowObjCWritebackConversion);
5953 SuppressUserConversions, AllowExplicit);
5956 SuppressUserConversions,
5957 AllowedExplicit::None,
5958 InOverloadResolution,
5960 AllowObjCWritebackConversion,
5973 return !ICS.
isBad();
5982 const CXXRecordDecl *ActingContext,
bool InOverloadResolution =
false,
5984 bool SuppressUserConversion =
false) {
5992 assert(FromClassification.
isLValue());
6003 if (Method->isExplicitObjectMemberFunction()) {
6004 if (ExplicitParameterType.isNull())
6005 ExplicitParameterType = Method->getFunctionObjectParameterReferenceType();
6007 ValueKindFromClassification(FromClassification));
6009 S, &TmpExpr, ExplicitParameterType, SuppressUserConversion,
6026 Qualifiers Quals = Method->getMethodQualifiers();
6064 FromType, ImplicitParamType);
6074 FromType, ImplicitParamType);
6087 }
else if (!Method->isExplicitObjectMemberFunction()) {
6089 FromType, ImplicitParamType);
6094 switch (Method->getRefQualifier()) {
6109 if (!FromClassification.
isRValue()) {
6131 = (Method->getRefQualifier() ==
RQ_None);
6142 QualType ImplicitParamRecordType =
Method->getFunctionObjectParameterType();
6147 DestType =
Method->getThisType();
6150 FromRecordType = From->
getType();
6151 DestType = ImplicitParamRecordType;
6159 Method->getRefQualifier() !=
6177 <<
Method->getDeclName() << FromRecordType << (CVR - 1)
6179 Diag(
Method->getLocation(), diag::note_previous_decl)
6180 <<
Method->getDeclName();
6188 bool IsRValueQualified =
6192 << IsRValueQualified;
6193 Diag(
Method->getLocation(), diag::note_previous_decl)
6194 <<
Method->getDeclName();
6204 llvm_unreachable(
"Lists are not objects");
6207 return Diag(From->
getBeginLoc(), diag::err_member_function_call_bad_type)
6208 << ImplicitParamRecordType << FromRecordType
6217 From = FromRes.
get();
6226 CK = CK_AddressSpaceConversion;
6251 AllowedExplicit::Conversions,
6334 llvm_unreachable(
"found a first conversion kind in Second");
6338 llvm_unreachable(
"found a third conversion kind in Second");
6344 llvm_unreachable(
"unknown conversion kind");
6354 [[maybe_unused]]
bool isCCEAllowedPreCXX11 =
6356 assert((S.
getLangOpts().CPlusPlus11 || isCCEAllowedPreCXX11) &&
6357 "converted constant expression outside C++11 or TTP matching");
6381 if (
T->isRecordType())
6390 diag::err_typecheck_converted_constant_expression)
6396 llvm_unreachable(
"bad conversion in converted constant expression");
6402 diag::err_typecheck_converted_constant_expression_disallowed)
6408 diag::err_typecheck_converted_constant_expression_indirect)
6418 diag::err_reference_bind_to_bitfield_in_cce)
6426 bool IsTemplateArgument =
6428 if (
T->isRecordType()) {
6429 assert(IsTemplateArgument &&
6430 "unexpected class type converted constant expr");
6439 if (Result.isInvalid())
6446 IsTemplateArgument);
6447 if (Result.isInvalid())
6451 bool ReturnPreNarrowingValue =
false;
6454 PreNarrowingType)) {
6464 PreNarrowingValue.
isInt()) {
6467 ReturnPreNarrowingValue =
true;
6487 << CCE << 0 << From->
getType() <<
T;
6490 if (!ReturnPreNarrowingValue)
6491 PreNarrowingValue = {};
6507 if (Result.isInvalid() || Result.get()->isValueDependent()) {
6512 RequireInt, PreNarrowingValue);
6519 return ::BuildConvertedConstantExpression(*
this, From,
T, CCE, Dest,
6526 return ::CheckConvertedConstantExpression(*
this, From,
T,
Value, CCE,
false,
6531 llvm::APSInt &
Value,
6533 assert(
T->isIntegralOrEnumerationType() &&
"unexpected converted const type");
6538 if (!R.isInvalid() && !R.get()->isValueDependent())
6546 const APValue &PreNarrowingValue) {
6558 Kind = ConstantExprKind::ClassTemplateArgument;
6560 Kind = ConstantExprKind::NonClassTemplateArgument;
6562 Kind = ConstantExprKind::Normal;
6565 (RequireInt && !Eval.
Val.
isInt())) {
6572 if (Notes.empty()) {
6575 if (
const auto *CE = dyn_cast<ConstantExpr>(E)) {
6579 "ConstantExpr has no value associated with it");
6585 Value = std::move(PreNarrowingValue);
6591 if (Notes.size() == 1 &&
6592 Notes[0].second.getDiagID() == diag::note_invalid_subexpr_in_const_expr) {
6593 Diag(Notes[0].first, diag::err_expr_not_cce) << CCE;
6594 }
else if (!Notes.empty() && Notes[0].second.getDiagID() ==
6595 diag::note_constexpr_invalid_template_arg) {
6596 Notes[0].second.setDiagID(diag::err_constexpr_invalid_template_arg);
6597 for (
unsigned I = 0; I < Notes.size(); ++I)
6598 Diag(Notes[I].first, Notes[I].second);
6602 for (
unsigned I = 0; I < Notes.size(); ++I)
6603 Diag(Notes[I].first, Notes[I].second);
6622static ImplicitConversionSequence
6630 AllowedExplicit::Conversions,
6672 "expected a member expression");
6674 if (
const auto M = dyn_cast<UnresolvedMemberExpr>(MemExprE);
6675 M && !M->isImplicitAccess())
6676 Base = M->getBase();
6677 else if (
const auto M = dyn_cast<MemberExpr>(MemExprE);
6678 M && !M->isImplicitAccess())
6679 Base = M->getBase();
6683 if (
T->isPointerType())
6684 T =
T->getPointeeType();
6712 assert(Method->isExplicitObjectMemberFunction() &&
6713 "Method is not an explicit member function");
6714 assert(NewArgs.empty() &&
"NewArgs should be empty");
6716 NewArgs.reserve(Args.size() + 1);
6718 NewArgs.push_back(
This);
6719 NewArgs.append(Args.begin(), Args.end());
6722 Method, Object->getBeginLoc());
6728 return AllowScopedEnumerations ?
T->isIntegralOrEnumerationType()
6729 :
T->isIntegralOrUnscopedEnumerationType();
6741 for (
unsigned I = 0, N = ViableConversions.
size(); I != N; ++I) {
6755 if (ExplicitConversions.
size() == 1 && !Converter.
Suppress) {
6763 std::string TypeStr;
6768 "static_cast<" + TypeStr +
">(")
6780 HadMultipleCandidates);
6781 if (Result.isInvalid())
6787 From, Result.get()->
getType());
6788 if (Result.isInvalid())
6790 From = Result.get();
6813 HadMultipleCandidates);
6814 if (Result.isInvalid())
6818 CK_UserDefinedConversion, Result.get(),
6819 nullptr, Result.get()->getValueKind(),
6844 if (
auto *ConvTemplate = dyn_cast<FunctionTemplateDecl>(D)) {
6846 ConvTemplate, FoundDecl, ActingContext, From, ToType, CandidateSet,
6852 Conv, FoundDecl, ActingContext, From, ToType, CandidateSet,
6886 From = result.
get();
6900 const RecordType *RecordTy =
T->getAsCanonical<RecordType>();
6913 : Converter(Converter), From(From) {}
6918 } IncompleteDiagnoser(Converter, From);
6929 ->getDefinitionOrSelf()
6930 ->getVisibleConversionFunctions();
6932 bool HadMultipleCandidates =
6937 bool HasUniqueTargetType =
true;
6953 "Conversion operator templates are considered potentially "
6957 if (Converter.
match(CurToType) || ConvTemplate) {
6963 ExplicitConversions.
addDecl(I.getDecl(), I.getAccess());
6968 else if (HasUniqueTargetType &&
6970 HasUniqueTargetType =
false;
6972 ViableConversions.
addDecl(I.getDecl(), I.getAccess());
6990 HadMultipleCandidates,
6991 ExplicitConversions))
6997 if (!HasUniqueTargetType)
7016 HadMultipleCandidates,
Found))
7025 HadMultipleCandidates,
7026 ExplicitConversions))
7034 switch (ViableConversions.
size()) {
7037 HadMultipleCandidates,
7038 ExplicitConversions))
7048 HadMultipleCandidates,
Found))
7079 if (Proto->getNumParams() < 1)
7083 QualType ArgType = Proto->getParamType(0).getNonReferenceType();
7084 if (Context.hasSameUnqualifiedType(T1, ArgType))
7088 if (Proto->getNumParams() < 2)
7092 QualType ArgType = Proto->getParamType(1).getNonReferenceType();
7093 if (Context.hasSameUnqualifiedType(T2, ArgType))
7112 unsigned SeenAt = 0;
7114 bool HasDefault =
false;
7123 return HasDefault || SeenAt != 0;
7129 bool PartialOverloading,
bool AllowExplicit,
bool AllowExplicitConversions,
7132 bool StrictPackMatch) {
7135 assert(Proto &&
"Functions without a prototype cannot be overloaded");
7136 assert(!
Function->getDescribedFunctionTemplate() &&
7137 "Use AddTemplateOverloadCandidate for function templates");
7150 CandidateSet, SuppressUserConversions,
7151 PartialOverloading, EarlyConversions, PO,
7187 CandidateSet.
addCandidate(Args.size(), EarlyConversions);
7201 Candidate.
Viable =
false;
7214 bool IsImplicitlyInstantiated =
false;
7215 if (
auto *SpecInfo =
Function->getTemplateSpecializationInfo()) {
7216 ND = SpecInfo->getTemplate();
7217 IsImplicitlyInstantiated = SpecInfo->getTemplateSpecializationKind() ==
7228 const bool IsInlineFunctionInGMF =
7230 (IsImplicitlyInstantiated ||
Function->isInlined());
7233 Candidate.
Viable =
false;
7240 Candidate.
Viable =
false;
7251 if (Args.size() == 1 &&
Constructor->isSpecializationCopyingObject() &&
7252 (
Context.hasSameUnqualifiedType(ClassType, Args[0]->getType()) ||
7255 Candidate.
Viable =
false;
7267 auto *Shadow = dyn_cast<ConstructorUsingShadowDecl>(FoundDecl.
getDecl());
7268 if (Shadow && Args.size() == 1 &&
Constructor->getNumParams() >= 1 &&
7269 Constructor->getParamDecl(0)->getType()->isReferenceType()) {
7276 Candidate.
Viable =
false;
7285 Constructor->getMethodQualifiers().getAddressSpace(),
7287 Candidate.
Viable =
false;
7300 Candidate.
Viable =
false;
7310 unsigned MinRequiredArgs =
Function->getMinRequiredArguments();
7311 if (!AggregateCandidateDeduction && Args.size() < MinRequiredArgs &&
7312 !PartialOverloading) {
7314 Candidate.
Viable =
false;
7328 Candidate.
Viable =
false;
7334 if (
Function->getTrailingRequiresClause()) {
7339 Candidate.
Viable =
false;
7348 for (
unsigned ArgIdx = 0; ArgIdx < Args.size(); ++ArgIdx) {
7351 if (Candidate.
Conversions[ConvIdx].isInitialized()) {
7354 }
else if (ArgIdx < NumParams) {
7365 *
this, Args[ArgIdx], ParamType, SuppressUserConversions,
7368 getLangOpts().ObjCAutoRefCount, AllowExplicitConversions);
7370 Candidate.
Viable =
false;
7382 if (EnableIfAttr *FailedAttr =
7384 Candidate.
Viable =
false;
7394 if (Methods.size() <= 1)
7397 for (
unsigned b = 0, e = Methods.size();
b < e;
b++) {
7403 if (
Method->param_size() > NumNamedArgs)
7404 NumNamedArgs =
Method->param_size();
7405 if (Args.size() < NumNamedArgs)
7408 for (
unsigned i = 0; i < NumNamedArgs; i++) {
7410 if (Args[i]->isTypeDependent()) {
7416 Expr *argExpr = Args[i];
7417 assert(argExpr &&
"SelectBestMethod(): missing expression");
7422 !param->
hasAttr<CFConsumedAttr>())
7423 argExpr =
ObjC().stripARCUnbridgedCast(argExpr);
7440 if (ConversionState.
isBad() ||
7450 for (
unsigned i = NumNamedArgs, e = Args.size(); i < e; ++i) {
7451 if (Args[i]->isTypeDependent()) {
7464 if (Args.size() != NumNamedArgs)
7466 else if (
Match && NumNamedArgs == 0 && Methods.size() > 1) {
7469 for (
unsigned b = 0, e = Methods.size();
b < e;
b++) {
7470 QualType ReturnT = Methods[
b]->getReturnType();
7490 "Shouldn't have `this` for ctors!");
7491 assert(!Method->isStatic() &&
"Shouldn't have `this` for static methods!");
7493 ThisArg, std::nullopt, Method, Method);
7496 ConvertedThis = R.
get();
7498 if (
auto *MD = dyn_cast<CXXMethodDecl>(Function)) {
7500 assert((MissingImplicitThis || MD->isStatic() ||
7502 "Expected `this` for non-ctor instance methods");
7504 ConvertedThis =
nullptr;
7509 unsigned ArgSizeNoVarargs = std::min(Function->param_size(), Args.size());
7512 for (
unsigned I = 0; I != ArgSizeNoVarargs; ++I) {
7515 S.
Context, Function->getParamDecl(I)),
7521 ConvertedArgs.push_back(R.
get());
7528 if (!Function->isVariadic() && Args.size() < Function->getNumParams()) {
7529 for (
unsigned i = Args.size(), e = Function->getNumParams(); i != e; ++i) {
7536 ConvertedArgs.push_back(R.
get());
7548 bool MissingImplicitThis) {
7549 auto EnableIfAttrs =
Function->specific_attrs<EnableIfAttr>();
7550 if (EnableIfAttrs.begin() == EnableIfAttrs.end())
7556 llvm::scope_exit UndelayDiags(
7558 DelayedDiagnostics.popUndelayed(CurrentState);
7562 Expr *DiscardedThis;
7564 *
this,
Function,
nullptr, CallLoc, Args, Trap,
7565 true, DiscardedThis, ConvertedArgs))
7566 return *EnableIfAttrs.begin();
7568 for (
auto *EIA : EnableIfAttrs) {
7572 if (EIA->getCond()->isValueDependent() ||
7573 !EIA->getCond()->EvaluateWithSubstitution(
7577 if (!
Result.isInt() || !
Result.getInt().getBoolValue())
7583template <
typename CheckFn>
7586 CheckFn &&IsSuccessful) {
7589 if (ArgDependent == DIA->getArgDependent())
7590 Attrs.push_back(DIA);
7597 auto WarningBegin = std::stable_partition(
7598 Attrs.begin(), Attrs.end(), [](
const DiagnoseIfAttr *DIA) {
7599 return DIA->getDefaultSeverity() == DiagnoseIfAttr::DS_error &&
7600 DIA->getWarningGroup().empty();
7605 auto ErrAttr = llvm::find_if(llvm::make_range(Attrs.begin(), WarningBegin),
7607 if (ErrAttr != WarningBegin) {
7608 const DiagnoseIfAttr *DIA = *ErrAttr;
7609 S.
Diag(Loc, diag::err_diagnose_if_succeeded) << DIA->getMessage();
7610 S.
Diag(DIA->getLocation(), diag::note_from_diagnose_if)
7611 << DIA->getParent() << DIA->getCond()->getSourceRange();
7615 auto ToSeverity = [](DiagnoseIfAttr::DefaultSeverity Sev) {
7617 case DiagnoseIfAttr::DS_warning:
7619 case DiagnoseIfAttr::DS_error:
7622 llvm_unreachable(
"Fully covered switch above!");
7625 for (
const auto *DIA : llvm::make_range(WarningBegin, Attrs.end()))
7626 if (IsSuccessful(DIA)) {
7627 if (DIA->getWarningGroup().empty() &&
7628 DIA->getDefaultSeverity() == DiagnoseIfAttr::DS_warning) {
7629 S.
Diag(Loc, diag::warn_diagnose_if_succeeded) << DIA->getMessage();
7630 S.
Diag(DIA->getLocation(), diag::note_from_diagnose_if)
7631 << DIA->getParent() << DIA->getCond()->getSourceRange();
7634 DIA->getWarningGroup());
7637 {ToSeverity(DIA->getDefaultSeverity()),
"%0",
7639 S.
Diag(Loc, DiagID) << DIA->getMessage();
7647 const Expr *ThisArg,
7652 [&](
const DiagnoseIfAttr *DIA) {
7657 if (!DIA->getCond()->EvaluateWithSubstitution(
7660 return Result.isInt() &&
Result.getInt().getBoolValue();
7667 *
this, ND,
false, Loc,
7668 [&](
const DiagnoseIfAttr *DIA) {
7670 return DIA->getCond()->EvaluateAsBooleanCondition(
Result,
Context) &&
7679 bool SuppressUserConversions,
7680 bool PartialOverloading,
7681 bool FirstArgumentIsBase) {
7693 if (Args.size() > 0) {
7694 if (
Expr *E = Args[0]) {
7704 FunctionArgs = Args.slice(1);
7708 FunTmpl, F.getPair(),
7710 ExplicitTemplateArgs, ObjectType, ObjectClassification,
7711 FunctionArgs, CandidateSet, SuppressUserConversions,
7712 PartialOverloading);
7716 ObjectClassification, FunctionArgs, CandidateSet,
7717 SuppressUserConversions, PartialOverloading);
7724 if (Args.size() > 0 &&
7728 FunctionArgs = Args.slice(1);
7732 ExplicitTemplateArgs, FunctionArgs,
7733 CandidateSet, SuppressUserConversions,
7734 PartialOverloading);
7737 SuppressUserConversions, PartialOverloading);
7747 bool SuppressUserConversions,
7757 "Expected a member function template");
7759 nullptr, ObjectType,
7760 ObjectClassification, Args, CandidateSet,
7761 SuppressUserConversions,
false, PO);
7764 ObjectType, ObjectClassification, Args, CandidateSet,
7765 SuppressUserConversions,
false, {}, PO);
7778 assert(Proto &&
"Methods without a prototype cannot be overloaded");
7780 "Use AddOverloadCandidate for constructors");
7789 Method->isMoveAssignmentOperator())
7796 bool IgnoreExplicitObject =
7797 (
Method->isExplicitObjectMemberFunction() &&
7800 bool ImplicitObjectMethodTreatedAsStatic =
7803 Method->isImplicitObjectMemberFunction();
7805 unsigned ExplicitOffset =
7806 !IgnoreExplicitObject &&
Method->isExplicitObjectMemberFunction() ? 1 : 0;
7808 unsigned NumParams =
Method->getNumParams() - ExplicitOffset +
7809 int(ImplicitObjectMethodTreatedAsStatic);
7811 unsigned ExtraArgs =
7818 CandidateSet.
addCandidate(Args.size() + ExtraArgs, EarlyConversions);
7834 Candidate.
Viable =
false;
7844 unsigned MinRequiredArgs =
Method->getMinRequiredArguments() -
7846 int(ImplicitObjectMethodTreatedAsStatic);
7848 if (Args.size() < MinRequiredArgs && !PartialOverloading) {
7850 Candidate.
Viable =
false;
7858 if (!IgnoreExplicitObject) {
7861 else if (
Method->isStatic()) {
7871 Candidate.
Conversions[FirstConvIdx].setStaticObjectArgument();
7876 *
this, CandidateSet.
getLocation(), ObjectType, ObjectClassification,
7877 Method, ActingContext,
true);
7878 if (Candidate.
Conversions[FirstConvIdx].isBad()) {
7879 Candidate.
Viable =
false;
7890 Candidate.
Viable =
false;
7895 if (
Method->getTrailingRequiresClause()) {
7900 Candidate.
Viable =
false;
7908 for (
unsigned ArgIdx = 0; ArgIdx < Args.size(); ++ArgIdx) {
7911 if (Candidate.
Conversions[ConvIdx].isInitialized()) {
7914 }
else if (ArgIdx < NumParams) {
7920 if (ImplicitObjectMethodTreatedAsStatic) {
7921 ParamType = ArgIdx == 0
7922 ?
Method->getFunctionObjectParameterReferenceType()
7925 ParamType = Proto->
getParamType(ArgIdx + ExplicitOffset);
7929 SuppressUserConversions,
7934 Candidate.
Viable =
false;
7946 if (EnableIfAttr *FailedAttr =
7948 Candidate.
Viable =
false;
7955 Candidate.
Viable =
false;
7966 bool SuppressUserConversions,
bool PartialOverloading,
7984 PartialOverloading,
false,
7985 false, ObjectType, ObjectClassification,
7989 bool OnlyInitializeNonUserDefinedConversions) {
7990 return S.CheckNonDependentConversions(
7991 MethodTmpl, ParamTypes, Args, CandidateSet, Conversions,
7992 Sema::CheckNonDependentConversionsFlag(
7993 SuppressUserConversions,
7994 OnlyInitializeNonUserDefinedConversions),
7995 ActingContext, ObjectType, ObjectClassification, PO);
7999 CandidateSet.
addCandidate(Conversions.size(), Conversions);
8002 Candidate.
Viable =
false;
8011 Method->isStatic() ||
8012 (!Method->isExplicitObjectMemberFunction() && ObjectType.
isNull());
8026 assert(
Specialization &&
"Missing member function template specialization?");
8028 "Specialization is not a member function?");
8031 ObjectClassification, Args, CandidateSet, SuppressUserConversions,
8045 if (ExplicitTemplateArgs ||
8048 *
this, CandidateSet, MethodTmpl, FoundDecl, ActingContext,
8049 ExplicitTemplateArgs, ObjectType, ObjectClassification, Args,
8050 SuppressUserConversions, PartialOverloading, PO);
8055 MethodTmpl, FoundDecl, ActingContext, ObjectType, ObjectClassification,
8056 Args, SuppressUserConversions, PartialOverloading, PO);
8074 bool SuppressUserConversions,
bool PartialOverloading,
bool AllowExplicit,
8076 bool AggregateCandidateDeduction) {
8085 Candidate.
Viable =
false;
8105 PartialOverloading, AggregateCandidateDeduction,
8112 bool OnlyInitializeNonUserDefinedConversions) {
8113 return S.CheckNonDependentConversions(
8114 FunctionTemplate, ParamTypes, Args, CandidateSet, Conversions,
8115 Sema::CheckNonDependentConversionsFlag(
8116 SuppressUserConversions,
8117 OnlyInitializeNonUserDefinedConversions),
8118 nullptr, QualType(), {}, PO);
8121 OverloadCandidate &Candidate =
8122 CandidateSet.addCandidate(Conversions.size(), Conversions);
8125 Candidate.
Viable =
false;
8127 CandidateSet.getRewriteInfo().getRewriteKind(Candidate.
Function, PO);
8133 CandidateSet.getKind() ==
8139 ->isExplicitObjectMemberFunction() &&
8155 assert(
Specialization &&
"Missing function template specialization?");
8157 Specialization, FoundDecl, Args, CandidateSet, SuppressUserConversions,
8158 PartialOverloading, AllowExplicit,
8159 false, IsADLCandidate, Conversions, PO,
8160 Info.AggregateDeductionCandidateHasMismatchedArity,
8161 Info.hasStrictPackMatch());
8168 bool PartialOverloading,
bool AllowExplicit,
ADLCallKind IsADLCandidate,
8175 if (ExplicitTemplateArgs ||
8178 DependentExplicitSpecifier)) {
8182 Args, SuppressUserConversions, PartialOverloading, AllowExplicit,
8183 IsADLCandidate, PO, AggregateCandidateDeduction);
8185 if (DependentExplicitSpecifier)
8192 PartialOverloading, AllowExplicit, IsADLCandidate, PO,
8193 AggregateCandidateDeduction);
8206 const bool AllowExplicit =
false;
8208 bool ForOverloadSetAddressResolution =
8211 auto *
Method = dyn_cast<CXXMethodDecl>(FD);
8212 bool HasThisConversion = !ForOverloadSetAddressResolution &&
Method &&
8214 unsigned ThisConversions = HasThisConversion ? 1 : 0;
8230 if (!FD->hasCXXExplicitFunctionObjectParameter() ||
8231 !ParamTypes[0]->isDependentType()) {
8233 *
this, CandidateSet.
getLocation(), ObjectType, ObjectClassification,
8234 Method, ActingContext,
true,
8235 FD->hasCXXExplicitFunctionObjectParameter() ? ParamTypes[0]
8245 auto MaybeInvolveUserDefinedConversion = [&](
QualType ParamType,
8269 if (
auto *RD =
ArgType->getAsCXXRecordDecl();
8270 RD && RD->hasDefinition() &&
8271 !RD->getVisibleConversionFunctions().empty())
8278 HasThisConversion &&
Method->hasCXXExplicitFunctionObjectParameter() ? 1
8281 for (
unsigned I = 0, N = std::min(ParamTypes.size() - Offset, Args.size());
8283 QualType ParamType = ParamTypes[I + Offset];
8287 ConvIdx = Args.size() - 1 - I;
8288 assert(Args.size() + ThisConversions == 2 &&
8289 "number of args (including 'this') must be exactly 2 for "
8293 assert(!HasThisConversion || (ConvIdx == 0 && I == 0));
8296 ConvIdx = ThisConversions + I;
8301 MaybeInvolveUserDefinedConversion(ParamType, Args[I]->
getType()))
8330 bool AllowObjCPointerConversion) {
8338 bool ObjCLifetimeConversion;
8340 ObjCLifetimeConversion))
8345 if (!AllowObjCPointerConversion)
8349 bool IncompatibleObjC =
false;
8359 bool AllowExplicit,
bool AllowResultConversion,
bool StrictPackMatch) {
8361 "Conversion function templates use AddTemplateConversionCandidate");
8376 if (!AllowResultConversion &&
8388 AllowObjCConversionOnExplicit))
8410 if (!AllowExplicit && Conversion->
isExplicit()) {
8411 Candidate.
Viable =
false;
8438 Candidate.
Viable =
false;
8447 Candidate.
Viable =
false;
8458 QualType ToCanon =
Context.getCanonicalType(ToType).getUnqualifiedType();
8459 if (FromCanon == ToCanon ||
8461 Candidate.
Viable =
false;
8478 CK_FunctionToPointerDecay, &ConversionRef,
8483 Candidate.
Viable =
false;
8513 Candidate.
Viable =
false;
8525 Candidate.
Viable =
false;
8532 Candidate.
Viable =
false;
8538 "Can only end up with a standard conversion sequence or failure");
8541 if (EnableIfAttr *FailedAttr =
8543 Candidate.
Viable =
false;
8550 Candidate.
Viable =
false;
8559 bool AllowObjCConversionOnExplicit,
bool AllowExplicit,
8560 bool AllowResultConversion) {
8569 Candidate.
Viable =
false;
8586 Candidate.
Viable =
false;
8596 assert(
Specialization &&
"Missing function template specialization?");
8598 ToType, CandidateSet, AllowObjCConversionOnExplicit,
8599 AllowExplicit, AllowResultConversion,
8607 bool AllowExplicit,
bool AllowResultConversion) {
8609 "Only conversion function templates permitted here");
8620 ToType, AllowObjCConversionOnExplicit, AllowExplicit,
8621 AllowResultConversion);
8629 AllowObjCConversionOnExplicit, AllowExplicit, AllowResultConversion);
8664 *
this, CandidateSet.
getLocation(), Object->getType(),
8665 Object->Classify(
Context), Conversion, ActingContext);
8668 if (ObjectInit.
isBad()) {
8669 Candidate.
Viable =
false;
8680 Candidate.
Conversions[0].UserDefined.EllipsisConversion =
false;
8681 Candidate.
Conversions[0].UserDefined.HadMultipleCandidates =
false;
8682 Candidate.
Conversions[0].UserDefined.ConversionFunction = Conversion;
8683 Candidate.
Conversions[0].UserDefined.FoundConversionFunction = FoundDecl;
8686 Candidate.
Conversions[0].UserDefined.After.setAsIdentityConversion();
8694 if (Args.size() > NumParams && !Proto->
isVariadic()) {
8695 Candidate.
Viable =
false;
8702 if (Args.size() < NumParams) {
8704 Candidate.
Viable =
false;
8711 for (
unsigned ArgIdx = 0, N = Args.size(); ArgIdx != N; ++ArgIdx) {
8712 if (ArgIdx < NumParams) {
8725 Candidate.
Viable =
false;
8742 Candidate.
Viable =
false;
8748 if (EnableIfAttr *FailedAttr =
8750 Candidate.
Viable =
false;
8774 "unqualified operator lookup found a member function");
8778 FunctionArgs, CandidateSet);
8784 FunctionArgs[1], FunctionArgs[0]);
8786 Reversed, CandidateSet,
false,
false,
true,
8787 ADLCallKind::NotADL,
8791 if (ExplicitTemplateArgs)
8796 {FunctionArgs[1], FunctionArgs[0]}, CandidateSet,
8797 false,
false,
true,
false, ADLCallKind::NotADL, {},
8829 if (!T1RD || (!IsComplete && !T1RD->isBeingDefined()))
8837 OperEnd = Operators.
end();
8838 Oper != OperEnd; ++Oper) {
8839 if (Oper->getAsFunction() &&
8842 *
this, {Args[1], Args[0]}, Oper->getAsFunction()))
8845 Args[0]->Classify(
Context), Args.slice(1),
8846 CandidateSet,
false, PO);
8853 bool IsAssignmentOperator,
8854 unsigned NumContextualBoolArguments) {
8869 for (
unsigned ArgIdx = 0, N = Args.size(); ArgIdx != N; ++ArgIdx) {
8882 if (ArgIdx < NumContextualBoolArguments) {
8883 assert(ParamTys[ArgIdx] ==
Context.BoolTy &&
8884 "Contextual conversion to bool requires bool type");
8890 ArgIdx == 0 && IsAssignmentOperator,
8896 Candidate.
Viable =
false;
8909class BuiltinCandidateTypeSet {
8915 TypeSet PointerTypes;
8919 TypeSet MemberPointerTypes;
8923 TypeSet EnumerationTypes;
8927 TypeSet VectorTypes;
8931 TypeSet MatrixTypes;
8934 TypeSet BitIntTypes;
8937 bool HasNonRecordTypes;
8941 bool HasArithmeticOrEnumeralTypes;
8945 bool HasNullPtrType;
8954 bool AddPointerWithMoreQualifiedTypeVariants(
QualType Ty,
8956 bool AddMemberPointerWithMoreQualifiedTypeVariants(
QualType Ty);
8960 typedef TypeSet::iterator
iterator;
8962 BuiltinCandidateTypeSet(
Sema &SemaRef)
8963 : HasNonRecordTypes(
false),
8964 HasArithmeticOrEnumeralTypes(
false),
8965 HasNullPtrType(
false),
8967 Context(SemaRef.Context) { }
8969 void AddTypesConvertedFrom(
QualType Ty,
8971 bool AllowUserConversions,
8972 bool AllowExplicitConversions,
8973 const Qualifiers &VisibleTypeConversionsQuals);
8975 llvm::iterator_range<iterator> pointer_types() {
return PointerTypes; }
8976 llvm::iterator_range<iterator> member_pointer_types() {
8977 return MemberPointerTypes;
8979 llvm::iterator_range<iterator> enumeration_types() {
8980 return EnumerationTypes;
8982 llvm::iterator_range<iterator> vector_types() {
return VectorTypes; }
8983 llvm::iterator_range<iterator> matrix_types() {
return MatrixTypes; }
8984 llvm::iterator_range<iterator> bitint_types() {
return BitIntTypes; }
8986 bool containsMatrixType(QualType Ty)
const {
return MatrixTypes.count(Ty); }
8987 bool hasNonRecordTypes() {
return HasNonRecordTypes; }
8988 bool hasArithmeticOrEnumeralTypes() {
return HasArithmeticOrEnumeralTypes; }
8989 bool hasNullPtrType()
const {
return HasNullPtrType; }
9004BuiltinCandidateTypeSet::AddPointerWithMoreQualifiedTypeVariants(QualType Ty,
9005 const Qualifiers &VisibleQuals) {
9008 if (!PointerTypes.insert(Ty))
9012 const PointerType *PointerTy = Ty->
getAs<PointerType>();
9013 bool buildObjCPtr =
false;
9015 const ObjCObjectPointerType *PTy = Ty->
castAs<ObjCObjectPointerType>();
9017 buildObjCPtr =
true;
9029 unsigned BaseCVR = PointeeTy.getCVRQualifiers();
9035 if ((CVR | BaseCVR) != CVR)
continue;
9050 QualType QPointerTy;
9057 PointerTypes.insert(QPointerTy);
9073BuiltinCandidateTypeSet::AddMemberPointerWithMoreQualifiedTypeVariants(
9076 if (!MemberPointerTypes.insert(Ty))
9079 const MemberPointerType *PointerTy = Ty->
getAs<MemberPointerType>();
9080 assert(PointerTy &&
"type was not a member pointer type!");
9095 if ((CVR | BaseCVR) != CVR)
continue;
9099 QPointeeTy, std::nullopt, Cls));
9114BuiltinCandidateTypeSet::AddTypesConvertedFrom(QualType Ty,
9116 bool AllowUserConversions,
9117 bool AllowExplicitConversions,
9118 const Qualifiers &VisibleQuals) {
9124 if (
const ReferenceType *RefTy = Ty->
getAs<ReferenceType>())
9129 Ty = SemaRef.Context.getArrayDecayedType(Ty);
9136 HasNonRecordTypes = HasNonRecordTypes || !TyIsRec;
9139 HasArithmeticOrEnumeralTypes =
9143 PointerTypes.insert(Ty);
9144 else if (Ty->
getAs<PointerType>() || Ty->
getAs<ObjCObjectPointerType>()) {
9147 if (!AddPointerWithMoreQualifiedTypeVariants(Ty, VisibleQuals))
9151 if (!AddMemberPointerWithMoreQualifiedTypeVariants(Ty))
9154 HasArithmeticOrEnumeralTypes =
true;
9155 EnumerationTypes.insert(Ty);
9157 HasArithmeticOrEnumeralTypes =
true;
9158 BitIntTypes.insert(Ty);
9162 HasArithmeticOrEnumeralTypes =
true;
9163 VectorTypes.insert(Ty);
9167 HasArithmeticOrEnumeralTypes =
true;
9168 MatrixTypes.insert(Ty);
9170 HasNullPtrType =
true;
9171 }
else if (AllowUserConversions && TyIsRec) {
9173 if (!SemaRef.isCompleteType(Loc, Ty))
9177 for (NamedDecl *D : ClassDecl->getVisibleConversionFunctions()) {
9187 if (AllowExplicitConversions || !Conv->
isExplicit()) {
9235 ClassDecl = RHSMPType->getMostRecentCXXRecordDecl();
9283 if (Available.hasAtomic()) {
9284 Available.removeAtomic();
9291 if (Available.hasVolatile()) {
9292 Available.removeVolatile();
9326class BuiltinOperatorOverloadBuilder {
9329 ArrayRef<Expr *> Args;
9330 QualifiersAndAtomic VisibleTypeConversionsQuals;
9331 bool HasArithmeticOrEnumeralCandidateType;
9332 SmallVectorImpl<BuiltinCandidateTypeSet> &CandidateTypes;
9333 OverloadCandidateSet &CandidateSet;
9335 static constexpr int ArithmeticTypesCap = 26;
9336 SmallVector<CanQualType, ArithmeticTypesCap> ArithmeticTypes;
9341 unsigned FirstIntegralType,
9343 unsigned FirstPromotedIntegralType,
9344 LastPromotedIntegralType;
9345 unsigned FirstPromotedArithmeticType,
9346 LastPromotedArithmeticType;
9347 unsigned NumArithmeticTypes;
9349 void InitArithmeticTypes() {
9351 FirstPromotedArithmeticType = 0;
9361 FirstIntegralType = ArithmeticTypes.size();
9362 FirstPromotedIntegralType = ArithmeticTypes.size();
9384 llvm::SmallSetVector<CanQualType, 2> BitIntCandidates;
9385 for (BuiltinCandidateTypeSet &Candidate : CandidateTypes) {
9386 for (QualType BitTy : Candidate.bitint_types())
9389 llvm::move(BitIntCandidates, std::back_inserter(ArithmeticTypes));
9390 LastPromotedIntegralType = ArithmeticTypes.size();
9391 LastPromotedArithmeticType = ArithmeticTypes.size();
9405 LastIntegralType = ArithmeticTypes.size();
9406 NumArithmeticTypes = ArithmeticTypes.size();
9413 assert(ArithmeticTypes.size() - BitIntCandidates.size() <=
9414 ArithmeticTypesCap &&
9415 "Enough inline storage for all arithmetic types.");
9420 void addPlusPlusMinusMinusStyleOverloads(QualType CandidateTy,
9423 QualType ParamTypes[2] = {
9463 void AddCandidate(QualType L, QualType R) {
9464 QualType LandR[2] = {L, R};
9469 BuiltinOperatorOverloadBuilder(
9470 Sema &S, ArrayRef<Expr *> Args,
9471 QualifiersAndAtomic VisibleTypeConversionsQuals,
9472 bool HasArithmeticOrEnumeralCandidateType,
9473 SmallVectorImpl<BuiltinCandidateTypeSet> &CandidateTypes,
9474 OverloadCandidateSet &CandidateSet)
9476 VisibleTypeConversionsQuals(VisibleTypeConversionsQuals),
9477 HasArithmeticOrEnumeralCandidateType(
9478 HasArithmeticOrEnumeralCandidateType),
9479 CandidateTypes(CandidateTypes),
9480 CandidateSet(CandidateSet) {
9482 InitArithmeticTypes();
9505 if (!HasArithmeticOrEnumeralCandidateType)
9508 for (
unsigned Arith = 0; Arith < NumArithmeticTypes; ++Arith) {
9509 const auto TypeOfT = ArithmeticTypes[Arith];
9511 if (Op == OO_MinusMinus)
9513 if (Op == OO_PlusPlus && S.
getLangOpts().CPlusPlus17)
9516 addPlusPlusMinusMinusStyleOverloads(
9533 void addPlusPlusMinusMinusPointerOverloads() {
9534 for (QualType PtrTy : CandidateTypes[0].pointer_types()) {
9536 if (!PtrTy->getPointeeType()->isObjectType())
9539 addPlusPlusMinusMinusStyleOverloads(
9541 (!PtrTy.isVolatileQualified() &&
9543 (!PtrTy.isRestrictQualified() &&
9558 void addUnaryStarPointerOverloads() {
9559 for (QualType ParamTy : CandidateTypes[0].pointer_types()) {
9564 if (
const FunctionProtoType *Proto =PointeeTy->
getAs<FunctionProtoType>())
9565 if (Proto->getMethodQuals() || Proto->getRefQualifier())
9578 void addUnaryPlusOrMinusArithmeticOverloads() {
9579 if (!HasArithmeticOrEnumeralCandidateType)
9582 for (
unsigned Arith = FirstPromotedArithmeticType;
9583 Arith < LastPromotedArithmeticType; ++Arith) {
9584 QualType ArithTy = ArithmeticTypes[Arith];
9589 for (QualType VecTy : CandidateTypes[0].vector_types())
9598 void addUnaryPlusPointerOverloads() {
9599 for (QualType ParamTy : CandidateTypes[0].pointer_types())
9608 void addUnaryTildePromotedIntegralOverloads() {
9609 if (!HasArithmeticOrEnumeralCandidateType)
9612 for (
unsigned Int = FirstPromotedIntegralType;
9613 Int < LastPromotedIntegralType; ++
Int) {
9614 QualType IntTy = ArithmeticTypes[
Int];
9619 for (QualType VecTy : CandidateTypes[0].vector_types())
9629 void addEqualEqualOrNotEqualMemberPointerOrNullptrOverloads() {
9631 llvm::SmallPtrSet<QualType, 8> AddedTypes;
9633 for (
unsigned ArgIdx = 0, N = Args.size(); ArgIdx != N; ++ArgIdx) {
9634 for (QualType MemPtrTy : CandidateTypes[ArgIdx].member_pointer_types()) {
9639 QualType ParamTypes[2] = {MemPtrTy, MemPtrTy};
9643 if (CandidateTypes[ArgIdx].hasNullPtrType()) {
9645 if (AddedTypes.insert(NullPtrTy).second) {
9646 QualType ParamTypes[2] = { NullPtrTy, NullPtrTy };
9665 void addGenericBinaryPointerOrEnumeralOverloads(
bool IsSpaceship) {
9678 llvm::DenseSet<std::pair<CanQualType, CanQualType> >
9679 UserDefinedBinaryOperators;
9681 for (
unsigned ArgIdx = 0, N = Args.size(); ArgIdx != N; ++ArgIdx) {
9682 if (!CandidateTypes[ArgIdx].enumeration_types().empty()) {
9684 CEnd = CandidateSet.
end();
9686 if (!
C->Viable || !
C->Function ||
C->Function->getNumParams() != 2)
9689 if (
C->Function->isFunctionTemplateSpecialization())
9696 QualType FirstParamType =
C->Function->getParamDecl(
Reversed ? 1 : 0)
9698 .getUnqualifiedType();
9699 QualType SecondParamType =
C->Function->getParamDecl(
Reversed ? 0 : 1)
9701 .getUnqualifiedType();
9709 UserDefinedBinaryOperators.insert(
9717 llvm::SmallPtrSet<QualType, 8> AddedTypes;
9719 for (
unsigned ArgIdx = 0, N = Args.size(); ArgIdx != N; ++ArgIdx) {
9720 for (QualType PtrTy : CandidateTypes[ArgIdx].pointer_types()) {
9724 if (IsSpaceship && PtrTy->isFunctionPointerType())
9727 QualType ParamTypes[2] = {PtrTy, PtrTy};
9730 for (QualType EnumTy : CandidateTypes[ArgIdx].enumeration_types()) {
9735 if (!AddedTypes.insert(CanonType).second ||
9736 UserDefinedBinaryOperators.count(std::make_pair(CanonType,
9739 QualType ParamTypes[2] = {EnumTy, EnumTy};
9764 llvm::SmallPtrSet<QualType, 8> AddedTypes;
9766 for (
int Arg = 0; Arg < 2; ++Arg) {
9767 QualType AsymmetricParamTypes[2] = {
9771 for (QualType PtrTy : CandidateTypes[Arg].pointer_types()) {
9776 AsymmetricParamTypes[Arg] = PtrTy;
9777 if (Arg == 0 || Op == OO_Plus) {
9782 if (Op == OO_Minus) {
9787 QualType ParamTypes[2] = {PtrTy, PtrTy};
9823 void addGenericBinaryArithmeticOverloads() {
9824 if (!HasArithmeticOrEnumeralCandidateType)
9827 for (
unsigned Left = FirstPromotedArithmeticType;
9828 Left < LastPromotedArithmeticType; ++
Left) {
9829 for (
unsigned Right = FirstPromotedArithmeticType;
9830 Right < LastPromotedArithmeticType; ++
Right) {
9831 QualType LandR[2] = { ArithmeticTypes[
Left],
9832 ArithmeticTypes[
Right] };
9839 for (QualType Vec1Ty : CandidateTypes[0].vector_types())
9840 for (QualType Vec2Ty : CandidateTypes[1].vector_types()) {
9841 QualType LandR[2] = {Vec1Ty, Vec2Ty};
9851 void addMatrixBinaryArithmeticOverloads() {
9852 if (!HasArithmeticOrEnumeralCandidateType)
9855 for (QualType M1 : CandidateTypes[0].matrix_types()) {
9857 AddCandidate(M1, M1);
9860 for (QualType M2 : CandidateTypes[1].matrix_types()) {
9862 if (!CandidateTypes[0].containsMatrixType(M2))
9863 AddCandidate(M2, M2);
9898 void addThreeWayArithmeticOverloads() {
9899 addGenericBinaryArithmeticOverloads();
9916 void addBinaryBitwiseArithmeticOverloads() {
9917 if (!HasArithmeticOrEnumeralCandidateType)
9920 for (
unsigned Left = FirstPromotedIntegralType;
9921 Left < LastPromotedIntegralType; ++
Left) {
9922 for (
unsigned Right = FirstPromotedIntegralType;
9924 QualType LandR[2] = { ArithmeticTypes[
Left],
9925 ArithmeticTypes[
Right] };
9938 void addAssignmentMemberPointerOrEnumeralOverloads() {
9940 llvm::SmallPtrSet<QualType, 8> AddedTypes;
9942 for (
unsigned ArgIdx = 0; ArgIdx < 2; ++ArgIdx) {
9943 for (QualType EnumTy : CandidateTypes[ArgIdx].enumeration_types()) {
9950 for (QualType MemPtrTy : CandidateTypes[ArgIdx].member_pointer_types()) {
9975 void addAssignmentPointerOverloads(
bool isEqualOp) {
9977 llvm::SmallPtrSet<QualType, 8> AddedTypes;
9979 for (QualType PtrTy : CandidateTypes[0].pointer_types()) {
9983 else if (!PtrTy->getPointeeType()->isObjectType())
9987 QualType ParamTypes[2] = {
9994 bool NeedVolatile = !PtrTy.isVolatileQualified() &&
10004 if (!PtrTy.isRestrictQualified() &&
10012 if (NeedVolatile) {
10024 for (QualType PtrTy : CandidateTypes[1].pointer_types()) {
10029 QualType ParamTypes[2] = {
10038 bool NeedVolatile = !PtrTy.isVolatileQualified() &&
10040 if (NeedVolatile) {
10048 if (!PtrTy.isRestrictQualified() &&
10056 if (NeedVolatile) {
10081 void addAssignmentArithmeticOverloads(
bool isEqualOp) {
10082 if (!HasArithmeticOrEnumeralCandidateType)
10085 for (
unsigned Left = 0;
Left < NumArithmeticTypes; ++
Left) {
10086 for (
unsigned Right = FirstPromotedArithmeticType;
10087 Right < LastPromotedArithmeticType; ++
Right) {
10088 QualType ParamTypes[2];
10089 ParamTypes[1] = ArithmeticTypes[
Right];
10091 S, ArithmeticTypes[Left], Args[0]);
10094 VisibleTypeConversionsQuals, [&](QualifiersAndAtomic Quals) {
10104 for (QualType Vec1Ty : CandidateTypes[0].vector_types())
10105 for (QualType Vec2Ty : CandidateTypes[0].vector_types()) {
10106 QualType ParamTypes[2];
10107 ParamTypes[1] = Vec2Ty;
10135 void addAssignmentIntegralOverloads() {
10136 if (!HasArithmeticOrEnumeralCandidateType)
10139 for (
unsigned Left = FirstIntegralType;
Left < LastIntegralType; ++
Left) {
10140 for (
unsigned Right = FirstPromotedIntegralType;
10141 Right < LastPromotedIntegralType; ++
Right) {
10142 QualType ParamTypes[2];
10143 ParamTypes[1] = ArithmeticTypes[
Right];
10145 S, ArithmeticTypes[Left], Args[0]);
10148 VisibleTypeConversionsQuals, [&](QualifiersAndAtomic Quals) {
10164 void addExclaimOverload() {
10170 void addAmpAmpOrPipePipeOverload() {
10187 void addSubscriptOverloads() {
10188 for (QualType PtrTy : CandidateTypes[0].pointer_types()) {
10198 for (QualType PtrTy : CandidateTypes[1].pointer_types()) {
10218 void addArrowStarOverloads() {
10219 for (QualType PtrTy : CandidateTypes[0].pointer_types()) {
10220 QualType C1Ty = PtrTy;
10222 QualifierCollector Q1;
10233 for (QualType MemPtrTy : CandidateTypes[1].member_pointer_types()) {
10240 QualType ParamTypes[2] = {PtrTy, MemPtrTy};
10243 if (!VisibleTypeConversionsQuals.
hasVolatile() &&
10244 T.isVolatileQualified())
10246 if (!VisibleTypeConversionsQuals.
hasRestrict() &&
10247 T.isRestrictQualified())
10265 void addConditionalOperatorOverloads() {
10267 llvm::SmallPtrSet<QualType, 8> AddedTypes;
10269 for (
unsigned ArgIdx = 0; ArgIdx < 2; ++ArgIdx) {
10270 for (QualType PtrTy : CandidateTypes[ArgIdx].pointer_types()) {
10274 QualType ParamTypes[2] = {PtrTy, PtrTy};
10278 for (QualType MemPtrTy : CandidateTypes[ArgIdx].member_pointer_types()) {
10282 QualType ParamTypes[2] = {MemPtrTy, MemPtrTy};
10287 for (QualType EnumTy : CandidateTypes[ArgIdx].enumeration_types()) {
10288 if (!EnumTy->castAsCanonical<EnumType>()->getDecl()->isScoped())
10294 QualType ParamTypes[2] = {EnumTy, EnumTy};
10313 VisibleTypeConversionsQuals.
addConst();
10314 for (
unsigned ArgIdx = 0, N = Args.size(); ArgIdx != N; ++ArgIdx) {
10316 if (Args[ArgIdx]->
getType()->isAtomicType())
10317 VisibleTypeConversionsQuals.
addAtomic();
10320 bool HasNonRecordCandidateType =
false;
10321 bool HasArithmeticOrEnumeralCandidateType =
false;
10323 for (
unsigned ArgIdx = 0, N = Args.size(); ArgIdx != N; ++ArgIdx) {
10324 CandidateTypes.emplace_back(*
this);
10325 CandidateTypes[ArgIdx].AddTypesConvertedFrom(Args[ArgIdx]->
getType(),
10328 (Op == OO_Exclaim ||
10330 Op == OO_PipePipe),
10331 VisibleTypeConversionsQuals);
10332 HasNonRecordCandidateType = HasNonRecordCandidateType ||
10333 CandidateTypes[ArgIdx].hasNonRecordTypes();
10334 HasArithmeticOrEnumeralCandidateType =
10335 HasArithmeticOrEnumeralCandidateType ||
10336 CandidateTypes[ArgIdx].hasArithmeticOrEnumeralTypes();
10344 if (!HasNonRecordCandidateType &&
10345 !(Op == OO_Exclaim || Op == OO_AmpAmp || Op == OO_PipePipe))
10349 BuiltinOperatorOverloadBuilder OpBuilder(*
this, Args,
10350 VisibleTypeConversionsQuals,
10351 HasArithmeticOrEnumeralCandidateType,
10352 CandidateTypes, CandidateSet);
10358 llvm_unreachable(
"Expected an overloaded operator");
10363 case OO_Array_Delete:
10366 "Special operators don't use AddBuiltinOperatorCandidates");
10378 if (Args.size() == 1)
10379 OpBuilder.addUnaryPlusPointerOverloads();
10383 if (Args.size() == 1) {
10384 OpBuilder.addUnaryPlusOrMinusArithmeticOverloads();
10386 OpBuilder.addBinaryPlusOrMinusPointerOverloads(Op);
10387 OpBuilder.addGenericBinaryArithmeticOverloads();
10388 OpBuilder.addMatrixBinaryArithmeticOverloads();
10393 if (Args.size() == 1)
10394 OpBuilder.addUnaryStarPointerOverloads();
10396 OpBuilder.addGenericBinaryArithmeticOverloads();
10397 OpBuilder.addMatrixBinaryArithmeticOverloads();
10402 OpBuilder.addGenericBinaryArithmeticOverloads();
10406 case OO_MinusMinus:
10407 OpBuilder.addPlusPlusMinusMinusArithmeticOverloads(Op);
10408 OpBuilder.addPlusPlusMinusMinusPointerOverloads();
10411 case OO_EqualEqual:
10412 case OO_ExclaimEqual:
10413 OpBuilder.addEqualEqualOrNotEqualMemberPointerOrNullptrOverloads();
10414 OpBuilder.addGenericBinaryPointerOrEnumeralOverloads(
false);
10415 OpBuilder.addGenericBinaryArithmeticOverloads();
10421 case OO_GreaterEqual:
10422 OpBuilder.addGenericBinaryPointerOrEnumeralOverloads(
false);
10423 OpBuilder.addGenericBinaryArithmeticOverloads();
10427 OpBuilder.addGenericBinaryPointerOrEnumeralOverloads(
true);
10428 OpBuilder.addThreeWayArithmeticOverloads();
10435 case OO_GreaterGreater:
10436 OpBuilder.addBinaryBitwiseArithmeticOverloads();
10440 if (Args.size() == 1)
10446 OpBuilder.addBinaryBitwiseArithmeticOverloads();
10450 OpBuilder.addUnaryTildePromotedIntegralOverloads();
10454 OpBuilder.addAssignmentMemberPointerOrEnumeralOverloads();
10458 case OO_MinusEqual:
10459 OpBuilder.addAssignmentPointerOverloads(Op == OO_Equal);
10463 case OO_SlashEqual:
10464 OpBuilder.addAssignmentArithmeticOverloads(Op == OO_Equal);
10467 case OO_PercentEqual:
10468 case OO_LessLessEqual:
10469 case OO_GreaterGreaterEqual:
10471 case OO_CaretEqual:
10473 OpBuilder.addAssignmentIntegralOverloads();
10477 OpBuilder.addExclaimOverload();
10482 OpBuilder.addAmpAmpOrPipePipeOverload();
10486 if (Args.size() == 2)
10487 OpBuilder.addSubscriptOverloads();
10491 OpBuilder.addArrowStarOverloads();
10494 case OO_Conditional:
10495 OpBuilder.addConditionalOperatorOverloads();
10496 OpBuilder.addGenericBinaryArithmeticOverloads();
10507 bool PartialOverloading) {
10524 CandEnd = CandidateSet.
end();
10525 Cand != CandEnd; ++Cand)
10526 if (Cand->Function) {
10530 Fns.
erase(FunTmpl);
10539 if (ExplicitTemplateArgs)
10543 FD, FoundDecl, Args, CandidateSet,
false,
10544 PartialOverloading,
true,
10545 false, ADLCallKind::UsesADL);
10548 FD, FoundDecl, {Args[1], Args[0]}, CandidateSet,
10549 false, PartialOverloading,
10556 FTD, FoundDecl, ExplicitTemplateArgs, Args, CandidateSet,
10557 false, PartialOverloading,
10558 true, ADLCallKind::UsesADL);
10560 *
this, Args, FTD->getTemplatedDecl())) {
10564 if (ReversedArgs.empty())
10568 FTD, FoundDecl, ExplicitTemplateArgs, ReversedArgs, CandidateSet,
10569 false, PartialOverloading,
10570 true, ADLCallKind::UsesADL,
10595 bool Cand1Attr = Cand1->
hasAttr<EnableIfAttr>();
10596 bool Cand2Attr = Cand2->
hasAttr<EnableIfAttr>();
10597 if (!Cand1Attr || !Cand2Attr) {
10598 if (Cand1Attr == Cand2Attr)
10599 return Comparison::Equal;
10600 return Cand1Attr ? Comparison::Better : Comparison::Worse;
10606 llvm::FoldingSetNodeID Cand1ID, Cand2ID;
10607 for (
auto Pair : zip_longest(Cand1Attrs, Cand2Attrs)) {
10608 std::optional<EnableIfAttr *> Cand1A = std::get<0>(Pair);
10609 std::optional<EnableIfAttr *> Cand2A = std::get<1>(Pair);
10614 return Comparison::Worse;
10616 return Comparison::Better;
10621 (*Cand1A)->getCond()->Profile(Cand1ID, S.
getASTContext(),
true);
10622 (*Cand2A)->getCond()->Profile(Cand2ID, S.
getASTContext(),
true);
10623 if (Cand1ID != Cand2ID)
10624 return Comparison::Worse;
10627 return Comparison::Equal;
10635 return Comparison::Equal;
10641 return Comparison::Equal;
10642 return Comparison::Worse;
10645 return Comparison::Better;
10651 const auto *Cand1CPUSpec = Cand1.
Function->
getAttr<CPUSpecificAttr>();
10652 const auto *Cand2CPUSpec = Cand2.
Function->
getAttr<CPUSpecificAttr>();
10654 if (!Cand1CPUDisp && !Cand2CPUDisp && !Cand1CPUSpec && !Cand2CPUSpec)
10655 return Comparison::Equal;
10657 if (Cand1CPUDisp && !Cand2CPUDisp)
10658 return Comparison::Better;
10659 if (Cand2CPUDisp && !Cand1CPUDisp)
10660 return Comparison::Worse;
10662 if (Cand1CPUSpec && Cand2CPUSpec) {
10663 if (Cand1CPUSpec->cpus_size() != Cand2CPUSpec->cpus_size())
10664 return Cand1CPUSpec->cpus_size() < Cand2CPUSpec->cpus_size()
10665 ? Comparison::Better
10666 : Comparison::Worse;
10668 std::pair<CPUSpecificAttr::cpus_iterator, CPUSpecificAttr::cpus_iterator>
10669 FirstDiff = std::mismatch(
10670 Cand1CPUSpec->cpus_begin(), Cand1CPUSpec->cpus_end(),
10671 Cand2CPUSpec->cpus_begin(),
10673 return LHS->getName() == RHS->getName();
10676 assert(FirstDiff.first != Cand1CPUSpec->cpus_end() &&
10677 "Two different cpu-specific versions should not have the same "
10678 "identifier list, otherwise they'd be the same decl!");
10679 return (*FirstDiff.first)->getName() < (*FirstDiff.second)->getName()
10680 ? Comparison::Better
10681 : Comparison::Worse;
10683 llvm_unreachable(
"No way to get here unless both had cpu_dispatch");
10689static std::optional<QualType>
10692 return std::nullopt;
10698 return M->getFunctionObjectParameterReferenceType();
10712 PT2->getInstantiatedFromMemberTemplate()))
10723 assert(I < F->getNumParams());
10730 if (F1NumParams != F2NumParams)
10733 unsigned I1 = 0, I2 = 0;
10734 for (
unsigned I = 0; I != F1NumParams; ++I) {
10735 QualType T1 = NextParam(F1, I1, I == 0);
10736 QualType T2 = NextParam(F2, I2, I == 0);
10737 assert(!T1.
isNull() && !T2.
isNull() &&
"Unexpected null param types");
10738 if (!Context.hasSameUnqualifiedType(T1, T2))
10751 bool IsFn1Reversed,
10752 bool IsFn2Reversed) {
10753 assert(Fn1 && Fn2);
10758 IsFn1Reversed ^ IsFn2Reversed))
10761 auto *Mem1 = dyn_cast<CXXMethodDecl>(Fn1);
10762 auto *Mem2 = dyn_cast<CXXMethodDecl>(Fn2);
10763 if (Mem1 && Mem2) {
10766 if (Mem1->getParent() != Mem2->getParent())
10770 if (Mem1->isInstance() && Mem2->isInstance() &&
10772 Mem1->getFunctionObjectParameterReferenceType(),
10773 Mem1->getFunctionObjectParameterReferenceType()))
10779static FunctionDecl *
10781 bool IsFn1Reversed,
bool IsFn2Reversed) {
10791 if (Cand1IsSpecialization || Cand2IsSpecialization)
10808 bool PartialOverloading) {
10854 bool IsCand1ImplicitHD =
10856 bool IsCand2ImplicitHD =
10871 auto EmitThreshold =
10872 (S.
getLangOpts().CUDAIsDevice && IsCallerImplicitHD &&
10873 (IsCand1ImplicitHD || IsCand2ImplicitHD))
10876 auto Cand1Emittable = P1 > EmitThreshold;
10877 auto Cand2Emittable = P2 > EmitThreshold;
10878 if (Cand1Emittable && !Cand2Emittable)
10880 if (!Cand1Emittable && Cand2Emittable)
10891 unsigned StartArg = 0;
10899 return ICS.isStandard() &&
10911 assert(Cand2.
Conversions.size() == NumArgs &&
"Overload candidate mismatch");
10912 bool HasBetterConversion =
false;
10913 for (
unsigned ArgIdx = StartArg; ArgIdx < NumArgs; ++ArgIdx) {
10914 bool Cand1Bad = IsIllFormedConversion(Cand1.
Conversions[ArgIdx]);
10915 bool Cand2Bad = IsIllFormedConversion(Cand2.
Conversions[ArgIdx]);
10916 if (Cand1Bad != Cand2Bad) {
10919 HasBetterConversion =
true;
10923 if (HasBetterConversion)
10930 bool HasWorseConversion =
false;
10931 for (
unsigned ArgIdx = StartArg; ArgIdx < NumArgs; ++ArgIdx) {
10937 HasBetterConversion =
true;
10956 HasWorseConversion =
true;
10971 if (HasBetterConversion && !HasWorseConversion)
11022 bool Cand1IsSpecialization = Cand1.
Function &&
11024 bool Cand2IsSpecialization = Cand2.
Function &&
11026 if (Cand1IsSpecialization != Cand2IsSpecialization)
11027 return Cand2IsSpecialization;
11033 if (Cand1IsSpecialization && Cand2IsSpecialization) {
11034 const auto *Obj1Context =
11036 const auto *Obj2Context =
11065 bool Cand1IsInherited =
11067 bool Cand2IsInherited =
11069 if (Cand1IsInherited != Cand2IsInherited)
11070 return Cand2IsInherited;
11071 else if (Cand1IsInherited) {
11072 assert(Cand2IsInherited);
11075 if (Cand1Class->isDerivedFrom(Cand2Class))
11077 if (Cand2Class->isDerivedFrom(Cand1Class))
11094 auto *Guide1 = dyn_cast_or_null<CXXDeductionGuideDecl>(Cand1.
Function);
11095 auto *Guide2 = dyn_cast_or_null<CXXDeductionGuideDecl>(Cand2.
Function);
11096 if (Guide1 && Guide2) {
11098 if (Guide1->isImplicit() != Guide2->isImplicit())
11099 return Guide2->isImplicit();
11109 const auto *Constructor1 = Guide1->getCorrespondingConstructor();
11110 const auto *Constructor2 = Guide2->getCorrespondingConstructor();
11111 if (Constructor1 && Constructor2) {
11112 bool isC1Templated = Constructor1->getTemplatedKind() !=
11114 bool isC2Templated = Constructor2->getTemplatedKind() !=
11116 if (isC1Templated != isC2Templated)
11117 return isC2Templated;
11125 if (Cmp != Comparison::Equal)
11126 return Cmp == Comparison::Better;
11129 bool HasPS1 = Cand1.
Function !=
nullptr &&
11131 bool HasPS2 = Cand2.
Function !=
nullptr &&
11133 if (HasPS1 != HasPS2 && HasPS1)
11137 if (MV == Comparison::Better)
11139 if (MV == Comparison::Worse)
11154 const auto *CD1 = dyn_cast_or_null<CXXConstructorDecl>(Cand1.
Function);
11155 const auto *CD2 = dyn_cast_or_null<CXXConstructorDecl>(Cand2.
Function);
11157 LangAS AS1 = CD1->getMethodQualifiers().getAddressSpace();
11158 LangAS AS2 = CD2->getMethodQualifiers().getAddressSpace();
11179 auto *VA = dyn_cast_or_null<ValueDecl>(A);
11180 auto *VB = dyn_cast_or_null<ValueDecl>(B);
11186 if (!VA->getDeclContext()->getRedeclContext()->Equals(
11187 VB->getDeclContext()->getRedeclContext()) ||
11189 VA->isExternallyVisible() || VB->isExternallyVisible())
11197 if (
Context.hasSameType(VA->getType(), VB->getType()))
11202 if (
auto *EA = dyn_cast<EnumConstantDecl>(VA)) {
11203 if (
auto *EB = dyn_cast<EnumConstantDecl>(VB)) {
11208 if (EnumA->hasNameForLinkage() || EnumB->hasNameForLinkage() ||
11209 !
Context.hasSameType(EnumA->getIntegerType(),
11210 EnumB->getIntegerType()))
11213 return llvm::APSInt::isSameValue(EA->getInitVal(), EB->getInitVal());
11223 assert(D &&
"Unknown declaration");
11224 Diag(Loc, diag::ext_equivalent_internal_linkage_decl_in_modules) << D;
11230 for (
auto *E : Equiv) {
11232 Diag(E->getLocation(), diag::note_equivalent_internal_linkage_decl)
11242 ->Satisfaction.ContainsErrors;
11248 bool PartialOverloading,
bool AllowExplicit,
11250 bool AggregateCandidateDeduction) {
11253 allocateDeferredCandidate<DeferredFunctionTemplateOverloadCandidate>();
11258 false, AllowExplicit, SuppressUserConversions,
11259 PartialOverloading, AggregateCandidateDeduction},
11266 HasDeferredTemplateConstructors |=
11274 bool SuppressUserConversions,
bool PartialOverloading,
11280 allocateDeferredCandidate<DeferredMethodTemplateOverloadCandidate>();
11286 false, SuppressUserConversions, PartialOverloading,
11292 ObjectClassification,
11300 bool AllowObjCConversionOnExplicit,
bool AllowExplicit,
11301 bool AllowResultConversion) {
11304 allocateDeferredCandidate<DeferredConversionTemplateOverloadCandidate>();
11308 AllowObjCConversionOnExplicit, AllowResultConversion,
11325 S, CandidateSet,
C.FunctionTemplate,
C.FoundDecl,
C.ActingContext,
11326 nullptr,
C.ObjectType,
C.ObjectClassification,
11327 C.Args,
C.SuppressUserConversions,
C.PartialOverloading,
C.PO);
11334 S, CandidateSet,
C.FunctionTemplate,
C.FoundDecl,
11335 nullptr,
C.Args,
C.SuppressUserConversions,
11336 C.PartialOverloading,
C.AllowExplicit,
C.IsADLCandidate,
C.PO,
11337 C.AggregateCandidateDeduction);
11344 S, CandidateSet,
C.FunctionTemplate,
C.FoundDecl,
C.ActingContext,
C.From,
11345 C.ToType,
C.AllowObjCConversionOnExplicit,
C.AllowExplicit,
11346 C.AllowResultConversion);
11350 Candidates.reserve(Candidates.size() + DeferredCandidatesCount);
11353 switch (Cand->
Kind) {
11372 FirstDeferredCandidate =
nullptr;
11373 DeferredCandidatesCount = 0;
11377OverloadCandidateSet::ResultForBestCandidate(
const iterator &Best) {
11379 if (Best->Function && Best->Function->isDeleted())
11384void OverloadCandidateSet::CudaExcludeWrongSideCandidates(
11401 bool ContainsSameSideCandidate =
11409 if (!ContainsSameSideCandidate)
11412 auto IsWrongSideCandidate = [&](
const OverloadCandidate *Cand) {
11418 llvm::erase_if(Candidates, IsWrongSideCandidate);
11436 DeferredCandidatesCount == 0) &&
11437 "Unexpected deferred template candidates");
11439 bool TwoPhaseResolution =
11440 DeferredCandidatesCount != 0 && !ResolutionByPerfectCandidateIsDisabled;
11442 if (TwoPhaseResolution) {
11444 if (Best !=
end() && Best->isPerfectMatch(S.
Context)) {
11445 if (!(HasDeferredTemplateConstructors &&
11446 isa_and_nonnull<CXXConversionDecl>(Best->Function)))
11452 return BestViableFunctionImpl(S, Loc, Best);
11459 Candidates.reserve(this->Candidates.size());
11460 std::transform(this->Candidates.begin(), this->Candidates.end(),
11461 std::back_inserter(Candidates),
11465 CudaExcludeWrongSideCandidates(S, Candidates);
11468 for (
auto *Cand : Candidates) {
11469 Cand->
Best =
false;
11471 if (Best ==
end() ||
11488 llvm::SmallVector<OverloadCandidate *, 4> PendingBest;
11489 llvm::SmallVector<const NamedDecl *, 4> EquivalentCands;
11490 PendingBest.push_back(&*Best);
11495 while (!PendingBest.empty()) {
11496 auto *Curr = PendingBest.pop_back_val();
11497 for (
auto *Cand : Candidates) {
11500 PendingBest.push_back(Cand);
11505 EquivalentCands.push_back(Cand->
Function);
11517 if (!EquivalentCands.empty())
11525enum OverloadCandidateKind {
11528 oc_reversed_binary_operator,
11530 oc_implicit_default_constructor,
11531 oc_implicit_copy_constructor,
11532 oc_implicit_move_constructor,
11533 oc_implicit_copy_assignment,
11534 oc_implicit_move_assignment,
11535 oc_implicit_equality_comparison,
11536 oc_inherited_constructor
11539enum OverloadCandidateSelect {
11542 ocs_described_template,
11545static std::pair<OverloadCandidateKind, OverloadCandidateSelect>
11546ClassifyOverloadCandidate(Sema &S,
const NamedDecl *
Found,
11547 const FunctionDecl *Fn,
11549 std::string &Description) {
11552 if (FunctionTemplateDecl *FunTmpl =
Fn->getPrimaryTemplate()) {
11555 FunTmpl->getTemplateParameters(), *
Fn->getTemplateSpecializationArgs());
11558 OverloadCandidateSelect Select = [&]() {
11559 if (!Description.empty())
11560 return ocs_described_template;
11561 return isTemplate ? ocs_template : ocs_non_template;
11564 OverloadCandidateKind Kind = [&]() {
11565 if (
Fn->isImplicit() &&
Fn->getOverloadedOperator() == OO_EqualEqual)
11566 return oc_implicit_equality_comparison;
11569 return oc_reversed_binary_operator;
11571 if (
const auto *Ctor = dyn_cast<CXXConstructorDecl>(Fn)) {
11572 if (!Ctor->isImplicit()) {
11574 return oc_inherited_constructor;
11576 return oc_constructor;
11579 if (Ctor->isDefaultConstructor())
11580 return oc_implicit_default_constructor;
11582 if (Ctor->isMoveConstructor())
11583 return oc_implicit_move_constructor;
11585 assert(Ctor->isCopyConstructor() &&
11586 "unexpected sort of implicit constructor");
11587 return oc_implicit_copy_constructor;
11590 if (
const auto *Meth = dyn_cast<CXXMethodDecl>(Fn)) {
11593 if (!Meth->isImplicit())
11596 if (Meth->isMoveAssignmentOperator())
11597 return oc_implicit_move_assignment;
11599 if (Meth->isCopyAssignmentOperator())
11600 return oc_implicit_copy_assignment;
11606 return oc_function;
11609 return std::make_pair(Kind, Select);
11612void MaybeEmitInheritedConstructorNote(Sema &S,
const Decl *FoundDecl) {
11615 if (
const auto *Shadow = dyn_cast<ConstructorUsingShadowDecl>(FoundDecl))
11617 diag::note_ovl_candidate_inherited_constructor)
11618 << Shadow->getNominatedBaseClass();
11627 if (EnableIf->getCond()->isValueDependent() ||
11628 !EnableIf->getCond()->EvaluateAsBooleanCondition(AlwaysTrue, Ctx))
11645 bool InOverloadResolution,
11649 if (InOverloadResolution)
11651 diag::note_addrof_ovl_candidate_disabled_by_enable_if_attr);
11653 S.
Diag(Loc, diag::err_addrof_function_disabled_by_enable_if_attr) << FD;
11664 if (InOverloadResolution) {
11667 TemplateArgString +=
" ";
11669 FunTmpl->getTemplateParameters(),
11674 diag::note_ovl_candidate_unsatisfied_constraints)
11675 << TemplateArgString;
11677 S.
Diag(Loc, diag::err_addrof_function_constraints_not_satisfied)
11686 return P->hasAttr<PassObjectSizeAttr>();
11693 unsigned ParamNo = std::distance(FD->
param_begin(), I) + 1;
11694 if (InOverloadResolution)
11696 diag::note_ovl_candidate_has_pass_object_size_params)
11699 S.
Diag(Loc, diag::err_address_of_function_with_pass_object_size_params)
11715 return ::checkAddressOfFunctionIsAvailable(*
this,
Function, Complain,
11723 const auto *ConvD = dyn_cast<CXXConversionDecl>(Fn);
11728 if (!RD->isLambda())
11733 CallOp->getType()->castAs<
FunctionType>()->getCallConv();
11738 return ConvToCC != CallOpCC;
11744 QualType DestType,
bool TakingAddress) {
11747 if (Fn->isMultiVersion() && Fn->hasAttr<TargetAttr>() &&
11748 !Fn->getAttr<TargetAttr>()->isDefaultVersion())
11750 if (Fn->isMultiVersion() && Fn->hasAttr<TargetVersionAttr>() &&
11751 !Fn->getAttr<TargetVersionAttr>()->isDefaultVersion())
11756 std::string FnDesc;
11757 std::pair<OverloadCandidateKind, OverloadCandidateSelect> KSPair =
11758 ClassifyOverloadCandidate(*
this,
Found, Fn, RewriteKind, FnDesc);
11760 << (
unsigned)KSPair.first << (
unsigned)KSPair.second
11764 Diag(Fn->getLocation(), PD);
11765 MaybeEmitInheritedConstructorNote(*
this,
Found);
11783 FunctionDecl *FirstCand =
nullptr, *SecondCand =
nullptr;
11784 for (
auto I = Cands.begin(), E = Cands.end(); I != E; ++I) {
11788 if (
auto *
Template = I->Function->getPrimaryTemplate())
11789 Template->getAssociatedConstraints(AC);
11791 I->Function->getAssociatedConstraints(AC);
11794 if (FirstCand ==
nullptr) {
11795 FirstCand = I->Function;
11797 }
else if (SecondCand ==
nullptr) {
11798 SecondCand = I->Function;
11811 SecondCand, SecondAC))
11820 bool TakingAddress) {
11830 dyn_cast<FunctionTemplateDecl>((*I)->getUnderlyingDecl()) ) {
11834 = dyn_cast<FunctionDecl>((*I)->getUnderlyingDecl()) ) {
11847 S.
Diag(CaretLoc, PDiag)
11849 unsigned CandsShown = 0;
11863 unsigned I,
bool TakingCandidateAddress) {
11865 assert(Conv.
isBad());
11866 assert(Cand->
Function &&
"for now, candidate must be a function");
11872 bool isObjectArgument =
false;
11876 isObjectArgument =
true;
11877 else if (!Fn->hasCXXExplicitFunctionObjectParameter())
11881 std::string FnDesc;
11882 std::pair<OverloadCandidateKind, OverloadCandidateSelect> FnKindPair =
11893 bool HasParamPack =
11894 llvm::any_of(Fn->parameters().take_front(I), [](
const ParmVarDecl *Parm) {
11895 return Parm->isParameterPack();
11897 if (!isObjectArgument && !HasParamPack)
11898 ToParamRange = Fn->getParamDecl(I)->getSourceRange();
11901 assert(FromExpr &&
"overload set argument came from implicit argument?");
11907 S.
Diag(Fn->getLocation(), diag::note_ovl_candidate_bad_overload)
11908 << (
unsigned)FnKindPair.first << (
unsigned)FnKindPair.second << FnDesc
11909 << ToParamRange << ToTy << Name << I + 1;
11910 MaybeEmitInheritedConstructorNote(S, Cand->
FoundDecl);
11919 CToTy = RT->getPointeeType();
11924 CFromTy = FromPT->getPointeeType();
11925 CToTy = ToPT->getPointeeType();
11935 if (isObjectArgument)
11936 S.
Diag(Fn->getLocation(), diag::note_ovl_candidate_bad_addrspace_this)
11937 << (
unsigned)FnKindPair.first << (
unsigned)FnKindPair.second
11940 S.
Diag(Fn->getLocation(), diag::note_ovl_candidate_bad_addrspace)
11941 << (
unsigned)FnKindPair.first << (
unsigned)FnKindPair.second
11944 MaybeEmitInheritedConstructorNote(S, Cand->
FoundDecl);
11949 S.
Diag(Fn->getLocation(), diag::note_ovl_candidate_bad_ownership)
11950 << (
unsigned)FnKindPair.first << (
unsigned)FnKindPair.second << FnDesc
11953 MaybeEmitInheritedConstructorNote(S, Cand->
FoundDecl);
11958 S.
Diag(Fn->getLocation(), diag::note_ovl_candidate_bad_gc)
11959 << (
unsigned)FnKindPair.first << (
unsigned)FnKindPair.second << FnDesc
11962 MaybeEmitInheritedConstructorNote(S, Cand->
FoundDecl);
11967 S.
Diag(Fn->getLocation(), diag::note_ovl_candidate_bad_ptrauth)
11968 << (
unsigned)FnKindPair.first << (
unsigned)FnKindPair.second << FnDesc
11973 MaybeEmitInheritedConstructorNote(S, Cand->
FoundDecl);
11978 assert(CVR &&
"expected qualifiers mismatch");
11980 if (isObjectArgument) {
11981 S.
Diag(Fn->getLocation(), diag::note_ovl_candidate_bad_cvr_this)
11982 << (
unsigned)FnKindPair.first << (
unsigned)FnKindPair.second << FnDesc
11983 << FromTy << (CVR - 1);
11985 S.
Diag(Fn->getLocation(), diag::note_ovl_candidate_bad_cvr)
11986 << (
unsigned)FnKindPair.first << (
unsigned)FnKindPair.second << FnDesc
11987 << ToParamRange << FromTy << (CVR - 1) << I + 1;
11989 MaybeEmitInheritedConstructorNote(S, Cand->
FoundDecl);
11995 S.
Diag(Fn->getLocation(), diag::note_ovl_candidate_bad_value_category)
11996 << (
unsigned)FnKindPair.first << (
unsigned)FnKindPair.second << FnDesc
11997 << (
unsigned)isObjectArgument << I + 1
12000 MaybeEmitInheritedConstructorNote(S, Cand->
FoundDecl);
12007 S.
Diag(Fn->getLocation(), diag::note_ovl_candidate_bad_list_argument)
12008 << (
unsigned)FnKindPair.first << (
unsigned)FnKindPair.second << FnDesc
12009 << ToParamRange << FromTy << ToTy << (
unsigned)isObjectArgument << I + 1
12014 MaybeEmitInheritedConstructorNote(S, Cand->
FoundDecl);
12026 S.
Diag(Fn->getLocation(), diag::note_ovl_candidate_bad_conv_incomplete)
12027 << (
unsigned)FnKindPair.first << (
unsigned)FnKindPair.second << FnDesc
12028 << ToParamRange << FromTy << ToTy << (
unsigned)isObjectArgument << I + 1
12029 << (
unsigned)(Cand->
Fix.
Kind);
12031 MaybeEmitInheritedConstructorNote(S, Cand->
FoundDecl);
12036 unsigned BaseToDerivedConversion = 0;
12039 if (ToPtrTy->getPointeeType().isAtLeastAsQualifiedAs(
12041 !FromPtrTy->getPointeeType()->isIncompleteType() &&
12042 !ToPtrTy->getPointeeType()->isIncompleteType() &&
12044 FromPtrTy->getPointeeType()))
12045 BaseToDerivedConversion = 1;
12053 if (ToPtrTy->getPointeeType().isAtLeastAsQualifiedAs(
12055 FromIface->isSuperClassOf(ToIface))
12056 BaseToDerivedConversion = 2;
12058 if (ToRefTy->getPointeeType().isAtLeastAsQualifiedAs(FromTy,
12061 !ToRefTy->getPointeeType()->isIncompleteType() &&
12063 BaseToDerivedConversion = 3;
12067 if (BaseToDerivedConversion) {
12068 S.
Diag(Fn->getLocation(), diag::note_ovl_candidate_bad_base_to_derived_conv)
12069 << (
unsigned)FnKindPair.first << (
unsigned)FnKindPair.second << FnDesc
12070 << ToParamRange << (BaseToDerivedConversion - 1) << FromTy << ToTy
12072 MaybeEmitInheritedConstructorNote(S, Cand->
FoundDecl);
12081 S.
Diag(Fn->getLocation(), diag::note_ovl_candidate_bad_arc_conv)
12082 << (
unsigned)FnKindPair.first << (
unsigned)FnKindPair.second << FnDesc
12083 << ToParamRange << FromTy << ToTy << (
unsigned)isObjectArgument
12085 MaybeEmitInheritedConstructorNote(S, Cand->
FoundDecl);
12095 FDiag << (
unsigned)FnKindPair.first << (
unsigned)FnKindPair.second << FnDesc
12096 << ToParamRange << FromTy << ToTy << (
unsigned)isObjectArgument << I + 1
12097 << (
unsigned)(Cand->
Fix.
Kind);
12106 S.
Diag(Fn->getLocation(), FDiag);
12108 MaybeEmitInheritedConstructorNote(S, Cand->
FoundDecl);
12115 unsigned NumArgs,
bool IsAddressOf =
false) {
12116 assert(Cand->
Function &&
"Candidate is required to be a function.");
12118 unsigned MinParams = Fn->getMinRequiredExplicitArguments() +
12119 ((IsAddressOf && !Fn->isStatic()) ? 1 : 0);
12126 if (Fn->isInvalidDecl() &&
12130 if (NumArgs < MinParams) {
12147 unsigned NumFormalArgs,
12148 bool IsAddressOf =
false) {
12150 "The templated declaration should at least be a function"
12151 " when diagnosing bad template argument deduction due to too many"
12152 " or too few arguments");
12158 unsigned MinParams = Fn->getMinRequiredExplicitArguments() +
12159 ((IsAddressOf && !Fn->isStatic()) ? 1 : 0);
12162 bool HasExplicitObjectParam =
12163 !IsAddressOf && Fn->hasCXXExplicitFunctionObjectParameter();
12165 unsigned ParamCount =
12166 Fn->getNumNonObjectParams() + ((IsAddressOf && !Fn->isStatic()) ? 1 : 0);
12167 unsigned mode, modeCount;
12169 if (NumFormalArgs < MinParams) {
12170 if (MinParams != ParamCount || FnTy->isVariadic() ||
12171 FnTy->isTemplateVariadic())
12175 modeCount = MinParams;
12177 if (MinParams != ParamCount)
12181 modeCount = ParamCount;
12184 std::string Description;
12185 std::pair<OverloadCandidateKind, OverloadCandidateSelect> FnKindPair =
12186 ClassifyOverloadCandidate(S,
Found, Fn,
CRK_None, Description);
12188 if (modeCount == 1 && !IsAddressOf &&
12189 Fn->getParamDecl(HasExplicitObjectParam ? 1 : 0)->getDeclName())
12190 S.
Diag(Fn->getLocation(), diag::note_ovl_candidate_arity_one)
12191 << (
unsigned)FnKindPair.first << (
unsigned)FnKindPair.second
12192 << Description << mode
12193 << Fn->getParamDecl(HasExplicitObjectParam ? 1 : 0) << NumFormalArgs
12194 << HasExplicitObjectParam << Fn->getParametersSourceRange();
12196 S.
Diag(Fn->getLocation(), diag::note_ovl_candidate_arity)
12197 << (
unsigned)FnKindPair.first << (
unsigned)FnKindPair.second
12198 << Description << mode << modeCount << NumFormalArgs
12199 << HasExplicitObjectParam << Fn->getParametersSourceRange();
12201 MaybeEmitInheritedConstructorNote(S,
Found);
12206 unsigned NumFormalArgs) {
12207 assert(Cand->
Function &&
"Candidate must be a function");
12217 llvm_unreachable(
"Unsupported: Getting the described template declaration"
12218 " for bad deduction diagnosis");
12225 bool TakingCandidateAddress) {
12231 switch (DeductionFailure.
getResult()) {
12234 "TemplateDeductionResult::Success while diagnosing bad deduction");
12236 llvm_unreachable(
"TemplateDeductionResult::NonDependentConversionFailure "
12237 "while diagnosing bad deduction");
12243 assert(ParamD &&
"no parameter found for incomplete deduction result");
12245 diag::note_ovl_candidate_incomplete_deduction)
12247 MaybeEmitInheritedConstructorNote(S,
Found);
12252 assert(ParamD &&
"no parameter found for incomplete deduction result");
12254 diag::note_ovl_candidate_incomplete_deduction_pack)
12256 << (DeductionFailure.
getFirstArg()->pack_size() + 1)
12258 MaybeEmitInheritedConstructorNote(S,
Found);
12263 assert(ParamD &&
"no parameter found for bad qualifiers deduction result");
12281 S.
Diag(Templated->
getLocation(), diag::note_ovl_candidate_underqualified)
12282 << ParamD->
getDeclName() << Arg << NonCanonParam;
12283 MaybeEmitInheritedConstructorNote(S,
Found);
12288 assert(ParamD &&
"no parameter found for inconsistent deduction result");
12302 diag::note_ovl_candidate_inconsistent_deduction_types)
12305 MaybeEmitInheritedConstructorNote(S,
Found);
12325 diag::note_ovl_candidate_inconsistent_deduction)
12328 MaybeEmitInheritedConstructorNote(S,
Found);
12333 assert(ParamD &&
"no parameter found for invalid explicit arguments");
12336 diag::note_ovl_candidate_explicit_arg_mismatch_named)
12341 index = TTP->getIndex();
12343 = dyn_cast<NonTypeTemplateParmDecl>(ParamD))
12344 index = NTTP->getIndex();
12348 diag::note_ovl_candidate_explicit_arg_mismatch_unnamed)
12351 MaybeEmitInheritedConstructorNote(S,
Found);
12358 TemplateArgString =
" ";
12361 if (TemplateArgString.size() == 1)
12362 TemplateArgString.clear();
12364 diag::note_ovl_candidate_unsatisfied_constraints)
12365 << TemplateArgString;
12368 static_cast<CNSInfo*
>(DeductionFailure.
Data)->Satisfaction);
12378 diag::note_ovl_candidate_instantiation_depth);
12379 MaybeEmitInheritedConstructorNote(S,
Found);
12387 TemplateArgString =
" ";
12390 if (TemplateArgString.size() == 1)
12391 TemplateArgString.clear();
12396 if (PDiag && PDiag->second.getDiagID() ==
12397 diag::err_typename_nested_not_found_enable_if) {
12400 S.
Diag(PDiag->first, diag::note_ovl_candidate_disabled_by_enable_if)
12401 <<
"'enable_if'" << TemplateArgString;
12406 if (PDiag && PDiag->second.getDiagID() ==
12407 diag::err_typename_nested_not_found_requirement) {
12409 diag::note_ovl_candidate_disabled_by_requirement)
12410 << PDiag->second.getStringArg(0) << TemplateArgString;
12420 SFINAEArgString =
": ";
12422 PDiag->second.EmitToString(S.
getDiagnostics(), SFINAEArgString);
12426 diag::note_ovl_candidate_substitution_failure)
12427 << TemplateArgString << SFINAEArgString << R;
12428 MaybeEmitInheritedConstructorNote(S,
Found);
12438 TemplateArgString =
" ";
12441 if (TemplateArgString.size() == 1)
12442 TemplateArgString.clear();
12445 S.
Diag(Templated->
getLocation(), diag::note_ovl_candidate_deduced_mismatch)
12448 << TemplateArgString
12473 diag::note_ovl_candidate_non_deduced_mismatch_qualified)
12489 diag::note_ovl_candidate_non_deduced_mismatch)
12490 << FirstTA << SecondTA;
12496 S.
Diag(Templated->
getLocation(), diag::note_ovl_candidate_bad_deduction);
12497 MaybeEmitInheritedConstructorNote(S,
Found);
12501 diag::note_cuda_ovl_candidate_target_mismatch);
12509 bool TakingCandidateAddress) {
12510 assert(Cand->
Function &&
"Candidate must be a function");
12525 assert(Cand->
Function &&
"Candidate must be a Function.");
12531 std::string FnDesc;
12532 std::pair<OverloadCandidateKind, OverloadCandidateSelect> FnKindPair =
12533 ClassifyOverloadCandidate(S, Cand->
FoundDecl, Callee,
12536 S.
Diag(Callee->getLocation(), diag::note_ovl_candidate_bad_target)
12537 << (
unsigned)FnKindPair.first << (
unsigned)ocs_non_template
12539 << CalleeTarget << CallerTarget;
12544 if (Meth !=
nullptr && Meth->
isImplicit()) {
12548 switch (FnKindPair.first) {
12551 case oc_implicit_default_constructor:
12554 case oc_implicit_copy_constructor:
12557 case oc_implicit_move_constructor:
12560 case oc_implicit_copy_assignment:
12563 case oc_implicit_move_assignment:
12568 bool ConstRHS =
false;
12572 ConstRHS = RT->getPointeeType().isConstQualified();
12583 assert(Cand->
Function &&
"Candidate must be a function");
12587 S.
Diag(Callee->getLocation(),
12588 diag::note_ovl_candidate_disabled_by_function_cond_attr)
12589 <<
Attr->getCond()->getSourceRange() <<
Attr->getMessage();
12593 assert(Cand->
Function &&
"Candidate must be a function");
12596 assert(ES.
isExplicit() &&
"not an explicit candidate");
12599 switch (Fn->getDeclKind()) {
12600 case Decl::Kind::CXXConstructor:
12603 case Decl::Kind::CXXConversion:
12606 case Decl::Kind::CXXDeductionGuide:
12607 Kind = Fn->isImplicit() ? 0 : 2;
12610 llvm_unreachable(
"invalid Decl");
12619 First = Pattern->getFirstDecl();
12622 diag::note_ovl_candidate_explicit)
12623 << Kind << (ES.
getExpr() ? 1 : 0)
12628 auto *DG = dyn_cast<CXXDeductionGuideDecl>(Fn);
12635 if (!(DG->isImplicit() || (OriginTemplate && OriginTemplate->
isTypeAlias())))
12637 std::string FunctionProto;
12638 llvm::raw_string_ostream OS(FunctionProto);
12651 "Non-template implicit deduction guides are only possible for "
12654 S.
Diag(DG->getLocation(), diag::note_implicit_deduction_guide)
12659 assert(
Template &&
"Cannot find the associated function template of "
12660 "CXXDeductionGuideDecl?");
12663 S.
Diag(DG->getLocation(), diag::note_implicit_deduction_guide)
12684 bool TakingCandidateAddress,
12686 assert(Cand->
Function &&
"Candidate must be a function");
12694 if (S.
getLangOpts().OpenCL && Fn->isImplicit() &&
12701 !Fn->hasCXXExplicitFunctionObjectParameter() && !Fn->isStatic())
12706 if (Fn->isDeleted()) {
12707 std::string FnDesc;
12708 std::pair<OverloadCandidateKind, OverloadCandidateSelect> FnKindPair =
12709 ClassifyOverloadCandidate(S, Cand->
FoundDecl, Fn,
12712 S.
Diag(Fn->getLocation(), diag::note_ovl_candidate_deleted)
12713 << (
unsigned)FnKindPair.first << (
unsigned)FnKindPair.second << FnDesc
12714 << (Fn->isDeleted() ? (Fn->isDeletedAsWritten() ? 1 : 2) : 0);
12715 MaybeEmitInheritedConstructorNote(S, Cand->
FoundDecl);
12742 TakingCandidateAddress);
12745 S.
Diag(Fn->getLocation(), diag::note_ovl_candidate_illegal_constructor)
12746 << (Fn->getPrimaryTemplate() ? 1 : 0);
12747 MaybeEmitInheritedConstructorNote(S, Cand->
FoundDecl);
12754 S.
Diag(Fn->getLocation(),
12755 diag::note_ovl_candidate_illegal_constructor_adrspace_mismatch)
12756 << QualsForPrinting;
12757 MaybeEmitInheritedConstructorNote(S, Cand->
FoundDecl);
12768 for (
unsigned N = Cand->
Conversions.size(); I != N; ++I)
12791 S.
Diag(Fn->getLocation(),
12792 diag::note_ovl_candidate_inherited_constructor_slice)
12793 << (Fn->getPrimaryTemplate() ? 1 : 0)
12794 << Fn->getParamDecl(0)->getType()->isRValueReferenceType();
12795 MaybeEmitInheritedConstructorNote(S, Cand->
FoundDecl);
12801 assert(!Available);
12809 std::string FnDesc;
12810 std::pair<OverloadCandidateKind, OverloadCandidateSelect> FnKindPair =
12811 ClassifyOverloadCandidate(S, Cand->
FoundDecl, Fn,
12814 S.
Diag(Fn->getLocation(),
12815 diag::note_ovl_candidate_constraints_not_satisfied)
12816 << (
unsigned)FnKindPair.first << (
unsigned)ocs_non_template
12835 bool isLValueReference =
false;
12836 bool isRValueReference =
false;
12837 bool isPointer =
false;
12841 isLValueReference =
true;
12845 isRValueReference =
true;
12861 diag::note_ovl_surrogate_constraints_not_satisfied)
12875 assert(Cand->
Conversions.size() <= 2 &&
"builtin operator is not binary");
12876 std::string TypeStr(
"operator");
12882 S.
Diag(OpLoc, diag::note_ovl_builtin_candidate) << TypeStr;
12887 S.
Diag(OpLoc, diag::note_ovl_builtin_candidate) << TypeStr;
12894 if (ICS.
isBad())
break;
12898 S, OpLoc, S.
PDiag(diag::note_ambiguous_type_conversion));
12915 llvm_unreachable(
"non-deduction failure while diagnosing bad deduction");
12945 llvm_unreachable(
"Unhandled deduction result");
12950struct CompareOverloadCandidatesForDisplay {
12952 SourceLocation Loc;
12956 CompareOverloadCandidatesForDisplay(
12957 Sema &S, SourceLocation Loc,
size_t NArgs,
12959 : S(S), NumArgs(NArgs), CSK(CSK) {}
12969 if (NumArgs >
C->Function->getNumParams() && !
C->Function->isVariadic())
12971 if (NumArgs < C->
Function->getMinRequiredArguments())
12978 bool operator()(
const OverloadCandidate *L,
12979 const OverloadCandidate *R) {
12981 if (L == R)
return false;
12985 if (!R->
Viable)
return true;
12987 if (
int Ord = CompareConversions(*L, *R))
13007 if (LDist == RDist) {
13008 if (LFailureKind == RFailureKind)
13016 return LDist < RDist;
13034 numLFixes = (numLFixes == 0) ?
UINT_MAX : numLFixes;
13035 numRFixes = (numRFixes == 0) ?
UINT_MAX : numRFixes;
13036 if (numLFixes != numRFixes) {
13037 return numLFixes < numRFixes;
13041 if (
int Ord = CompareConversions(*L, *R))
13053 if (LRank != RRank)
13054 return LRank < RRank;
13080 struct ConversionSignals {
13081 unsigned KindRank = 0;
13084 static ConversionSignals ForSequence(ImplicitConversionSequence &
Seq) {
13085 ConversionSignals Sig;
13086 Sig.KindRank =
Seq.getKindRank();
13087 if (
Seq.isStandard())
13088 Sig.Rank =
Seq.Standard.getRank();
13089 else if (
Seq.isUserDefined())
13090 Sig.Rank =
Seq.UserDefined.After.getRank();
13096 static ConversionSignals ForObjectArgument() {
13106 int CompareConversions(
const OverloadCandidate &L,
13107 const OverloadCandidate &R) {
13112 for (
unsigned I = 0, N = L.
Conversions.size(); I != N; ++I) {
13114 ? ConversionSignals::ForObjectArgument()
13115 : ConversionSignals::ForSequence(L.Conversions[I]);
13117 ? ConversionSignals::ForObjectArgument()
13118 : ConversionSignals::ForSequence(R.Conversions[I]);
13119 if (std::tie(LS.KindRank, LS.Rank) != std::tie(RS.KindRank, RS.Rank))
13120 return std::tie(LS.KindRank, LS.Rank) < std::tie(RS.KindRank, RS.Rank)
13145 bool Unfixable =
false;
13151 for (
unsigned ConvIdx =
13155 assert(ConvIdx != ConvCount &&
"no bad conversion in candidate");
13156 if (Cand->
Conversions[ConvIdx].isInitialized() &&
13165 bool SuppressUserConversions =
false;
13167 unsigned ConvIdx = 0;
13168 unsigned ArgIdx = 0;
13197 assert(ConvCount <= 3);
13203 ConvIdx != ConvCount && ArgIdx < Args.size();
13205 if (Cand->
Conversions[ConvIdx].isInitialized()) {
13207 }
else if (
ParamIdx < ParamTypes.size()) {
13208 if (ParamTypes[
ParamIdx]->isDependentType())
13209 Cand->
Conversions[ConvIdx].setAsIdentityConversion(
13214 SuppressUserConversions,
13219 if (!Unfixable && Cand->
Conversions[ConvIdx].isBad())
13238 for (
iterator Cand = Candidates.begin(), LastCand = Candidates.end();
13239 Cand != LastCand; ++Cand) {
13240 if (!Filter(*Cand))
13265 Cands.push_back(Cand);
13269 Cands, CompareOverloadCandidatesForDisplay(S, OpLoc, Args.size(), Kind));
13276 bool DeferHint =
false;
13280 auto WrongSidedCands =
13282 return (Cand.
Viable ==
false &&
13288 DeferHint = !WrongSidedCands.empty();
13304 S.
Diag(PD.first, PD.second);
13309 bool NoteCands =
true;
13310 for (
const Expr *Arg : Args) {
13311 if (Arg->getType()->isWebAssemblyTableType())
13320 {Candidates.begin(), Candidates.end()});
13326 bool ReportedAmbiguousConversions =
false;
13329 unsigned CandsShown = 0;
13330 auto I = Cands.begin(), E = Cands.end();
13331 for (; I != E; ++I) {
13347 "Non-viable built-in candidates are not added to Cands.");
13354 if (!ReportedAmbiguousConversions) {
13356 ReportedAmbiguousConversions =
true;
13370 S.
Diag(OpLoc, diag::note_ovl_too_many_candidates) <<
int(E - I);
13381struct CompareTemplateSpecCandidatesForDisplay {
13383 CompareTemplateSpecCandidatesForDisplay(Sema &S) : S(S) {}
13385 bool operator()(
const TemplateSpecCandidate *L,
13386 const TemplateSpecCandidate *R) {
13417 bool ForTakingAddress) {
13422void TemplateSpecCandidateSet::destroyCandidates() {
13424 i->DeductionFailure.Destroy();
13429 destroyCandidates();
13430 Candidates.clear();
13443 Cands.reserve(
size());
13444 for (
iterator Cand =
begin(), LastCand =
end(); Cand != LastCand; ++Cand) {
13445 if (Cand->Specialization)
13446 Cands.push_back(Cand);
13451 llvm::sort(Cands, CompareTemplateSpecCandidatesForDisplay(S));
13458 unsigned CandsShown = 0;
13459 for (I = Cands.begin(), E = Cands.end(); I != E; ++I) {
13465 if (CandsShown >= 4 && ShowOverloads ==
Ovl_Best)
13470 "Non-matching built-in candidates are not added to Cands.");
13475 S.
Diag(Loc, diag::note_ovl_too_many_candidates) <<
int(E - I);
13485 QualType Ret = PossiblyAFunctionType;
13488 Ret = ToTypePtr->getPointeeType();
13491 Ret = ToTypeRef->getPointeeType();
13494 Ret = MemTypePtr->getPointeeType();
13496 Context.getCanonicalType(Ret).getUnqualifiedType();
13501 bool Complain =
true) {
13518class AddressOfFunctionResolver {
13521 const QualType& TargetType;
13522 QualType TargetFunctionType;
13526 ASTContext& Context;
13528 bool TargetTypeIsNonStaticMemberFunction;
13529 bool FoundNonTemplateFunction;
13530 bool StaticMemberFunctionFromBoundPointer;
13531 bool HasComplained;
13533 OverloadExpr::FindResult OvlExprInfo;
13534 OverloadExpr *OvlExpr;
13535 TemplateArgumentListInfo OvlExplicitTemplateArgs;
13536 SmallVector<std::pair<DeclAccessPair, FunctionDecl*>, 4> Matches;
13537 TemplateSpecCandidateSet FailedCandidates;
13540 AddressOfFunctionResolver(Sema &S, Expr *SourceExpr,
13541 const QualType &TargetType,
bool Complain)
13542 : S(S), SourceExpr(SourceExpr), TargetType(TargetType),
13543 Complain(Complain), Context(S.getASTContext()),
13544 TargetTypeIsNonStaticMemberFunction(
13545 !!TargetType->getAs<MemberPointerType>()),
13546 FoundNonTemplateFunction(
false),
13547 StaticMemberFunctionFromBoundPointer(
false),
13548 HasComplained(
false),
13549 OvlExprInfo(OverloadExpr::find(SourceExpr)),
13551 FailedCandidates(OvlExpr->getNameLoc(),
true) {
13552 ExtractUnqualifiedFunctionTypeFromTargetType();
13555 if (UnresolvedMemberExpr *UME = dyn_cast<UnresolvedMemberExpr>(OvlExpr))
13556 if (!UME->isImplicitAccess() &&
13558 StaticMemberFunctionFromBoundPointer =
true;
13560 DeclAccessPair dap;
13562 OvlExpr,
false, &dap)) {
13563 if (CXXMethodDecl *
Method = dyn_cast<CXXMethodDecl>(Fn))
13564 if (!
Method->isStatic()) {
13568 TargetTypeIsNonStaticMemberFunction =
true;
13576 Matches.push_back(std::make_pair(dap, Fn));
13584 if (FindAllFunctionsThatMatchTargetTypeExactly()) {
13587 if (Matches.size() > 1 && !eliminiateSuboptimalOverloadCandidates()) {
13588 if (FoundNonTemplateFunction) {
13589 EliminateAllTemplateMatches();
13590 EliminateLessPartialOrderingConstrainedMatches();
13592 EliminateAllExceptMostSpecializedTemplate();
13597 EliminateSuboptimalCudaMatches();
13600 bool hasComplained()
const {
return HasComplained; }
13603 bool candidateHasExactlyCorrectType(
const FunctionDecl *FD) {
13610 bool isBetterCandidate(
const FunctionDecl *A,
const FunctionDecl *B) {
13614 return candidateHasExactlyCorrectType(A) &&
13615 (!candidateHasExactlyCorrectType(B) ||
13621 bool eliminiateSuboptimalOverloadCandidates() {
13624 auto Best = Matches.begin();
13625 for (
auto I = Matches.begin()+1, E = Matches.end(); I != E; ++I)
13626 if (isBetterCandidate(I->second, Best->second))
13629 const FunctionDecl *BestFn = Best->second;
13630 auto IsBestOrInferiorToBest = [
this, BestFn](
13631 const std::pair<DeclAccessPair, FunctionDecl *> &Pair) {
13632 return BestFn == Pair.second || isBetterCandidate(BestFn, Pair.second);
13637 if (!llvm::all_of(Matches, IsBestOrInferiorToBest))
13639 Matches[0] = *Best;
13644 bool isTargetTypeAFunction()
const {
13653 void inline ExtractUnqualifiedFunctionTypeFromTargetType() {
13659 const DeclAccessPair& CurAccessFunPair) {
13660 if (CXXMethodDecl *
Method
13664 bool CanConvertToFunctionPointer =
13665 Method->isStatic() ||
Method->isExplicitObjectMemberFunction();
13666 if (CanConvertToFunctionPointer == TargetTypeIsNonStaticMemberFunction)
13669 else if (TargetTypeIsNonStaticMemberFunction)
13679 TemplateDeductionInfo Info(FailedCandidates.
getLocation());
13683 Result != TemplateDeductionResult::Success) {
13701 Matches.push_back(std::make_pair(CurAccessFunPair,
Specialization));
13705 bool AddMatchingNonTemplateFunction(NamedDecl* Fn,
13706 const DeclAccessPair& CurAccessFunPair) {
13707 if (CXXMethodDecl *
Method = dyn_cast<CXXMethodDecl>(Fn)) {
13710 bool CanConvertToFunctionPointer =
13711 Method->isStatic() ||
Method->isExplicitObjectMemberFunction();
13712 if (CanConvertToFunctionPointer == TargetTypeIsNonStaticMemberFunction)
13715 else if (TargetTypeIsNonStaticMemberFunction)
13718 if (FunctionDecl *FunDecl = dyn_cast<FunctionDecl>(Fn)) {
13725 if (FunDecl->isMultiVersion()) {
13726 const auto *TA = FunDecl->getAttr<TargetAttr>();
13727 if (TA && !TA->isDefaultVersion())
13729 const auto *TVA = FunDecl->getAttr<TargetVersionAttr>();
13730 if (TVA && !TVA->isDefaultVersion())
13738 HasComplained |= Complain;
13747 candidateHasExactlyCorrectType(FunDecl)) {
13748 Matches.push_back(std::make_pair(
13750 FoundNonTemplateFunction =
true;
13758 bool FindAllFunctionsThatMatchTargetTypeExactly() {
13763 if (IsInvalidFormOfPointerToMemberFunction())
13766 for (UnresolvedSetIterator I = OvlExpr->
decls_begin(),
13770 NamedDecl *
Fn = (*I)->getUnderlyingDecl();
13779 = dyn_cast<FunctionTemplateDecl>(Fn)) {
13785 AddMatchingNonTemplateFunction(Fn, I.getPair()))
13788 assert(Ret || Matches.empty());
13792 void EliminateAllExceptMostSpecializedTemplate() {
13804 UnresolvedSet<4> MatchesCopy;
13805 for (
unsigned I = 0, E = Matches.size(); I != E; ++I)
13806 MatchesCopy.
addDecl(Matches[I].second, Matches[I].first.getAccess());
13811 MatchesCopy.
begin(), MatchesCopy.
end(), FailedCandidates,
13813 S.
PDiag(diag::err_addr_ovl_ambiguous)
13814 << Matches[0].second->getDeclName(),
13815 S.
PDiag(diag::note_ovl_candidate)
13816 << (
unsigned)oc_function << (
unsigned)ocs_described_template,
13817 Complain, TargetFunctionType);
13821 Matches[0].first = Matches[
Result - MatchesCopy.
begin()].first;
13825 HasComplained |= Complain;
13828 void EliminateAllTemplateMatches() {
13831 for (
unsigned I = 0, N = Matches.size(); I != N; ) {
13832 if (Matches[I].second->getPrimaryTemplate() ==
nullptr)
13835 Matches[I] = Matches[--N];
13841 void EliminateLessPartialOrderingConstrainedMatches() {
13846 assert(Matches[0].second->getPrimaryTemplate() ==
nullptr &&
13847 "Call EliminateAllTemplateMatches() first");
13848 SmallVector<std::pair<DeclAccessPair, FunctionDecl *>, 4> Results;
13849 Results.push_back(Matches[0]);
13850 for (
unsigned I = 1, N = Matches.size(); I < N; ++I) {
13851 assert(Matches[I].second->getPrimaryTemplate() ==
nullptr);
13853 S, Matches[I].second, Results[0].second,
13857 Results.push_back(Matches[I]);
13860 if (F == Matches[I].second) {
13862 Results.push_back(Matches[I]);
13865 std::swap(Matches, Results);
13868 void EliminateSuboptimalCudaMatches() {
13874 void ComplainNoMatchesFound()
const {
13875 assert(Matches.empty());
13877 << OvlExpr->
getName() << TargetFunctionType
13879 if (FailedCandidates.
empty())
13886 for (UnresolvedSetIterator I = OvlExpr->
decls_begin(),
13889 if (FunctionDecl *Fun =
13890 dyn_cast<FunctionDecl>((*I)->getUnderlyingDecl()))
13898 bool IsInvalidFormOfPointerToMemberFunction()
const {
13899 return TargetTypeIsNonStaticMemberFunction &&
13903 void ComplainIsInvalidFormOfPointerToMemberFunction()
const {
13911 bool IsStaticMemberFunctionFromBoundPointer()
const {
13912 return StaticMemberFunctionFromBoundPointer;
13915 void ComplainIsStaticMemberFunctionFromBoundPointer()
const {
13917 diag::err_invalid_form_pointer_member_function)
13921 void ComplainOfInvalidConversion()
const {
13923 << OvlExpr->
getName() << TargetType;
13926 void ComplainMultipleMatchesFound()
const {
13927 assert(Matches.size() > 1);
13934 bool hadMultipleCandidates()
const {
return (OvlExpr->
getNumDecls() > 1); }
13936 int getNumMatches()
const {
return Matches.size(); }
13938 FunctionDecl* getMatchingFunctionDecl()
const {
13939 if (Matches.size() != 1)
return nullptr;
13940 return Matches[0].second;
13943 const DeclAccessPair* getMatchingFunctionAccessPair()
const {
13944 if (Matches.size() != 1)
return nullptr;
13945 return &Matches[0].first;
13955 bool *pHadMultipleCandidates) {
13958 AddressOfFunctionResolver Resolver(*
this, AddressOfExpr, TargetType,
13960 int NumMatches = Resolver.getNumMatches();
13962 bool ShouldComplain = Complain && !Resolver.hasComplained();
13963 if (NumMatches == 0 && ShouldComplain) {
13964 if (Resolver.IsInvalidFormOfPointerToMemberFunction())
13965 Resolver.ComplainIsInvalidFormOfPointerToMemberFunction();
13967 Resolver.ComplainNoMatchesFound();
13969 else if (NumMatches > 1 && ShouldComplain)
13970 Resolver.ComplainMultipleMatchesFound();
13971 else if (NumMatches == 1) {
13972 Fn = Resolver.getMatchingFunctionDecl();
13976 FoundResult = *Resolver.getMatchingFunctionAccessPair();
13978 if (Resolver.IsStaticMemberFunctionFromBoundPointer())
13979 Resolver.ComplainIsStaticMemberFunctionFromBoundPointer();
13985 if (pHadMultipleCandidates)
13986 *pHadMultipleCandidates = Resolver.hadMultipleCandidates();
13994 bool IsResultAmbiguous =
false;
14002 return static_cast<int>(
CUDA().IdentifyPreference(Caller, FD1)) -
14003 static_cast<int>(
CUDA().IdentifyPreference(Caller, FD2));
14010 auto *FD = dyn_cast<FunctionDecl>(I->getUnderlyingDecl());
14018 auto FoundBetter = [&]() {
14019 IsResultAmbiguous =
false;
14031 int PreferenceByCUDA = CheckCUDAPreference(FD,
Result);
14033 if (PreferenceByCUDA != 0) {
14035 if (PreferenceByCUDA > 0)
14051 if (MoreConstrained != FD) {
14052 if (!MoreConstrained) {
14053 IsResultAmbiguous =
true;
14054 AmbiguousDecls.push_back(FD);
14063 if (IsResultAmbiguous)
14084 ExprResult &SrcExpr,
bool DoFunctionPointerConversion) {
14086 assert(E->
getType() ==
Context.OverloadTy &&
"SrcExpr must be an overload");
14090 if (!
Found ||
Found->isCPUDispatchMultiVersion() ||
14091 Found->isCPUSpecificMultiVersion())
14139 dyn_cast<FunctionTemplateDecl>((*I)->getUnderlyingDecl());
14170 if (ForTypeDeduction &&
14184 if (FoundResult) *FoundResult = I.getPair();
14195 ExprResult &SrcExpr,
bool doFunctionPointerConversion,
bool complain,
14197 unsigned DiagIDForComplaining) {
14218 if (!complain)
return false;
14221 diag::err_bound_member_function)
14234 SingleFunctionExpression =
14238 if (doFunctionPointerConversion) {
14239 SingleFunctionExpression =
14241 if (SingleFunctionExpression.
isInvalid()) {
14248 if (!SingleFunctionExpression.
isUsable()) {
14250 Diag(OpRangeForComplaining.
getBegin(), DiagIDForComplaining)
14252 << DestTypeForComplaining
14253 << OpRangeForComplaining
14264 SrcExpr = SingleFunctionExpression;
14274 bool PartialOverloading,
14281 if (ExplicitTemplateArgs) {
14282 assert(!KnownValid &&
"Explicit template arguments?");
14291 PartialOverloading);
14296 = dyn_cast<FunctionTemplateDecl>(Callee)) {
14298 ExplicitTemplateArgs, Args, CandidateSet,
14300 PartialOverloading);
14304 assert(!KnownValid &&
"unhandled case in overloaded call candidate");
14310 bool PartialOverloading) {
14333 assert(!(*I)->getDeclContext()->isRecord());
14335 !(*I)->getDeclContext()->isFunctionOrMethod());
14336 assert((*I)->getUnderlyingDecl()->isFunctionOrFunctionTemplate());
14346 ExplicitTemplateArgs = &TABuffer;
14352 CandidateSet, PartialOverloading,
14357 Args, ExplicitTemplateArgs,
14358 CandidateSet, PartialOverloading);
14366 CandidateSet,
false,
false);
14373 case OO_New:
case OO_Array_New:
14374 case OO_Delete:
case OO_Array_Delete:
14397 if (DC->isTransparentContext())
14413 if (
auto *RD = dyn_cast<CXXRecordDecl>(DC)) {
14418 if (FoundInClass) {
14419 *FoundInClass = RD;
14422 R.
addDecl(Best->FoundDecl.getDecl(), Best->FoundDecl.getAccess());
14439 AssociatedNamespaces,
14440 AssociatedClasses);
14444 for (Sema::AssociatedNamespaceSet::iterator
14445 it = AssociatedNamespaces.begin(),
14446 end = AssociatedNamespaces.end(); it !=
end; ++it) {
14458 SuggestedNamespaces.insert(*it);
14462 SemaRef.
Diag(R.
getNameLoc(), diag::err_not_found_by_two_phase_lookup)
14464 if (SuggestedNamespaces.empty()) {
14465 SemaRef.
Diag(Best->Function->getLocation(),
14466 diag::note_not_found_by_two_phase_lookup)
14468 }
else if (SuggestedNamespaces.size() == 1) {
14469 SemaRef.
Diag(Best->Function->getLocation(),
14470 diag::note_not_found_by_two_phase_lookup)
14476 SemaRef.
Diag(Best->Function->getLocation(),
14477 diag::note_not_found_by_two_phase_lookup)
14509class BuildRecoveryCallExprRAII {
14511 Sema::SatisfactionStackResetRAII SatStack;
14514 BuildRecoveryCallExprRAII(Sema &S) : SemaRef(S), SatStack(S) {
14536 bool EmptyLookup,
bool AllowTypoCorrection) {
14544 BuildRecoveryCallExprRAII RCE(SemaRef);
14554 ExplicitTemplateArgs = &TABuffer;
14562 ExplicitTemplateArgs, Args, &FoundInClass)) {
14564 }
else if (EmptyLookup) {
14569 ExplicitTemplateArgs !=
nullptr,
14570 dyn_cast<MemberExpr>(Fn));
14572 AllowTypoCorrection
14578 }
else if (FoundInClass && SemaRef.
getLangOpts().MSVCCompat) {
14593 assert(!R.
empty() &&
"lookup results empty despite recovery");
14604 if ((*R.
begin())->isCXXClassMember())
14606 ExplicitTemplateArgs, S);
14607 else if (ExplicitTemplateArgs || TemplateKWLoc.
isValid())
14609 ExplicitTemplateArgs);
14633 assert(!ULE->
getQualifier() &&
"qualified name with ADL");
14640 (F = dyn_cast<FunctionDecl>(*ULE->
decls_begin())) &&
14642 llvm_unreachable(
"performing ADL for builtin");
14649 UnbridgedCastsSet UnbridgedCasts;
14664 if (CandidateSet->
empty() ||
14680 if (CandidateSet->
empty())
14683 UnbridgedCasts.restore();
14690 std::optional<QualType> Result;
14702 else if (Result !=
T)
14710 if (Best && *Best != CS.
end())
14711 ConsiderCandidate(**Best);
14714 for (
const auto &
C : CS)
14716 ConsiderCandidate(
C);
14719 for (
const auto &
C : CS)
14720 ConsiderCandidate(
C);
14724 auto Value = *Result;
14725 if (
Value.isNull() ||
Value->isUndeducedType())
14742 bool AllowTypoCorrection) {
14743 switch (OverloadResult) {
14754 Res.
get(), FDecl, LParenLoc, Args, RParenLoc, ExecConfig,
14760 if (*Best != CandidateSet->
end() &&
14764 dyn_cast_if_present<CXXMethodDecl>((*Best)->Function);
14769 SemaRef.
PDiag(diag::err_member_call_without_object) << 0 << M),
14779 CandidateSet->
empty(),
14780 AllowTypoCorrection);
14787 for (
const Expr *Arg : Args) {
14788 if (!Arg->getType()->isFunctionType())
14790 if (
auto *DRE = dyn_cast<DeclRefExpr>(Arg->IgnoreParenImpCasts())) {
14791 auto *FD = dyn_cast<FunctionDecl>(DRE->getDecl());
14794 Arg->getExprLoc()))
14802 SemaRef.
PDiag(diag::err_ovl_no_viable_function_in_call)
14803 << ULE->
getName() << Fn->getSourceRange()),
14811 SemaRef.
PDiag(diag::err_ovl_ambiguous_call)
14812 << ULE->
getName() << Fn->getSourceRange()),
14819 Fn->getSourceRange(), ULE->
getName(),
14820 *CandidateSet, FDecl, Args);
14829 Res.
get(), FDecl, LParenLoc, Args, RParenLoc, ExecConfig,
14837 SubExprs.append(Args.begin(), Args.end());
14844 for (
auto I = CS.
begin(), E = CS.
end(); I != E; ++I) {
14859 bool AllowTypoCorrection,
14860 bool CalleesAddressIsTaken) {
14875 if (CalleesAddressIsTaken)
14886 Best != CandidateSet.
end()) {
14887 if (
auto *M = dyn_cast_or_null<CXXMethodDecl>(Best->Function);
14888 M && M->isImplicitObjectMemberFunction()) {
14899 CUDA().recordPotentialODRUsedVariable(Args, CandidateSet);
14917 if (
const auto *TP =
14927 ExecConfig, &CandidateSet, &Best,
14928 OverloadResult, AllowTypoCorrection);
14937 Context, NamingClass, NNSLoc, DNI, PerformADL, Fns.
begin(), Fns.
end(),
14943 bool HadMultipleCandidates) {
14953 if (
Method->isExplicitObjectMemberFunction())
14957 E, std::nullopt, FoundDecl,
Method);
14961 if (
Method->getParent()->isLambda() &&
14962 Method->getConversionType()->isBlockPointerType()) {
14966 auto *CE = dyn_cast<CastExpr>(SubE);
14967 if (CE && CE->getCastKind() == CK_NoOp)
14968 SubE = CE->getSubExpr();
14970 if (
auto *BE = dyn_cast<CXXBindTemporaryExpr>(SubE))
14971 SubE = BE->getSubExpr();
14994 if (
Method->isExplicitObjectMemberFunction()) {
15000 Expr *ObjectParam = Exp.
get();
15014 Exp.
get()->getEndLoc(),
15028 Expr *Input,
bool PerformADL) {
15030 assert(Op !=
OO_None &&
"Invalid opcode for overloaded unary operator");
15038 Expr *Args[2] = { Input,
nullptr };
15039 unsigned NumArgs = 1;
15044 if (Opc == UO_PostInc || Opc == UO_PostDec) {
15058 if (Opc == UO_PreDec || Opc == UO_PreInc || Opc == UO_Deref)
15069 if (Fn.isInvalid())
15095 bool HadMultipleCandidates = (CandidateSet.
size() > 1);
15114 if (
Method->isExplicitObjectMemberFunction())
15118 Input, std::nullopt, Best->FoundDecl,
Method);
15121 Base = Input = InputInit.
get();
15132 Input = InputInit.
get();
15137 Base, HadMultipleCandidates,
15149 Context, Op, FnExpr.
get(), ArgsArray, ResultTy,
VK, OpLoc,
15165 Input, Best->BuiltinParamTypes[0], Best->Conversions[0],
15170 Input = InputRes.
get();
15190 PDiag(diag::err_ovl_ambiguous_oper_unary)
15207 << (Msg !=
nullptr)
15208 << (Msg ? Msg->
getString() : StringRef())
15261 if (Op != OO_Equal && PerformADL) {
15268 Context.DeclarationNames.getCXXOperatorName(ExtraOp);
15294 Expr *RHS,
bool PerformADL,
15295 bool AllowRewrittenCandidates,
15297 Expr *Args[2] = { LHS, RHS };
15301 AllowRewrittenCandidates =
false;
15307 if (Args[0]->isTypeDependent() || Args[1]->isTypeDependent()) {
15328 if (Fn.isInvalid())
15337 if (Opc == BO_PtrMemD) {
15338 auto CheckPlaceholder = [&](
Expr *&Arg) {
15347 if (CheckPlaceholder(Args[0]) || CheckPlaceholder(Args[1]))
15368 if (Opc == BO_Assign && !Args[0]->
getType()->isOverloadableType())
15374 Op, OpLoc, AllowRewrittenCandidates));
15376 CandidateSet.
exclude(DefaultedFn);
15379 bool HadMultipleCandidates = (CandidateSet.
size() > 1);
15388 bool IsReversed = Best->isReversed();
15390 std::swap(Args[0], Args[1]);
15407 if (Best->RewriteKind && ChosenOp == OO_EqualEqual &&
15411 Diag(OpLoc, IsExtension ? diag::ext_ovl_rewrite_equalequal_not_bool
15412 : diag::err_ovl_rewrite_equalequal_not_bool)
15420 if (AllowRewrittenCandidates && !IsReversed &&
15430 for (
unsigned ArgIdx = 0; ArgIdx < 2; ++ArgIdx) {
15433 Best->Conversions[ArgIdx]) ==
15435 AmbiguousWith.push_back(Cand.
Function);
15442 if (!AmbiguousWith.empty()) {
15443 bool AmbiguousWithSelf =
15444 AmbiguousWith.size() == 1 &&
15446 Diag(OpLoc, diag::ext_ovl_ambiguous_oper_binary_reversed)
15448 << Args[0]->
getType() << Args[1]->
getType() << AmbiguousWithSelf
15450 if (AmbiguousWithSelf) {
15452 diag::note_ovl_ambiguous_oper_binary_reversed_self);
15457 if (
auto *MD = dyn_cast<CXXMethodDecl>(FnDecl))
15458 if (Op == OverloadedOperatorKind::OO_EqualEqual &&
15460 !MD->hasCXXExplicitFunctionObjectParameter() &&
15461 Context.hasSameUnqualifiedType(
15462 MD->getFunctionObjectParameterType(),
15463 MD->getParamDecl(0)->getType().getNonReferenceType()) &&
15464 Context.hasSameUnqualifiedType(
15465 MD->getFunctionObjectParameterType(),
15467 Context.hasSameUnqualifiedType(
15468 MD->getFunctionObjectParameterType(),
15471 diag::note_ovl_ambiguous_eqeq_reversed_self_non_const);
15474 diag::note_ovl_ambiguous_oper_binary_selected_candidate);
15475 for (
auto *F : AmbiguousWith)
15477 diag::note_ovl_ambiguous_oper_binary_reversed_candidate);
15485 if (Op == OO_Equal)
15496 if (
Method->isExplicitObjectMemberFunction()) {
15501 Args[0], std::nullopt, Best->FoundDecl,
Method);
15534 Best->FoundDecl,
Base,
15535 HadMultipleCandidates, OpLoc);
15546 const Expr *ImplicitThis =
nullptr;
15551 Context, ChosenOp, FnExpr.
get(), Args, ResultTy,
VK, OpLoc,
15555 if (
const auto *
Method = dyn_cast<CXXMethodDecl>(FnDecl);
15558 ImplicitThis = ArgsArray[0];
15559 ArgsArray = ArgsArray.slice(1);
15566 if (Op == OO_Equal) {
15571 *
this,
AssignedEntity{Args[0], dyn_cast<CXXMethodDecl>(FnDecl)},
15574 if (ImplicitThis) {
15579 CheckArgAlignment(OpLoc, FnDecl,
"'this'", ThisType,
15583 checkCall(FnDecl,
nullptr, ImplicitThis, ArgsArray,
15598 (Op == OO_Spaceship && IsReversed)) {
15599 if (Op == OO_ExclaimEqual) {
15600 assert(ChosenOp == OO_EqualEqual &&
"unexpected operator name");
15603 assert(ChosenOp == OO_Spaceship &&
"unexpected operator name");
15605 Expr *ZeroLiteral =
15614 OpLoc, Opc, Fns, IsReversed ? ZeroLiteral : R.
get(),
15615 IsReversed ? R.
get() : ZeroLiteral,
true,
15623 assert(ChosenOp == Op &&
"unexpected operator name");
15627 if (Best->RewriteKind !=
CRK_None)
15636 Args[0], Best->BuiltinParamTypes[0], Best->Conversions[0],
15641 Args[0] = ArgsRes0.
get();
15644 Args[1], Best->BuiltinParamTypes[1], Best->Conversions[1],
15649 Args[1] = ArgsRes1.
get();
15659 if (Opc == BO_Comma)
15664 if (DefaultedFn && Opc == BO_Cmp) {
15666 Args[1], DefaultedFn);
15681 Opc >= BO_Assign && Opc <= BO_OrAssign) {
15682 Diag(OpLoc, diag::err_ovl_no_viable_oper)
15685 if (Args[0]->
getType()->isIncompleteType()) {
15686 Diag(OpLoc, diag::note_assign_lhs_incomplete)
15702 assert(
Result.isInvalid() &&
15703 "C++ binary operator overloading is missing candidates!");
15714 << Args[0]->getSourceRange()
15715 << Args[1]->getSourceRange()),
15725 Diag(OpLoc, diag::err_ovl_deleted_special_oper)
15729 Diag(OpLoc, diag::err_ovl_deleted_comparison)
15730 << Args[0]->
getType() << DeletedFD;
15743 PDiag(diag::err_ovl_deleted_oper)
15745 .getCXXOverloadedOperator())
15746 << (Msg !=
nullptr) << (Msg ? Msg->
getString() : StringRef())
15747 << Args[0]->getSourceRange() << Args[1]->getSourceRange()),
15771 "cannot use prvalue expressions more than once");
15772 Expr *OrigLHS = LHS;
15773 Expr *OrigRHS = RHS;
15790 true, DefaultedFn);
15791 if (
Less.isInvalid())
15818 for (; I >= 0; --I) {
15820 auto *VI = Info->lookupValueInfo(Comparisons[I].
Result);
15843 Context, OrigLHS, OrigRHS, BO_Cmp,
Result.get()->getType(),
15844 Result.get()->getValueKind(),
Result.get()->getObjectKind(), OpLoc,
15846 Expr *SemanticForm[] = {LHS, RHS,
Result.get()};
15856 unsigned NumArgsSlots =
15857 MethodArgs.size() + std::max<unsigned>(Args.size(), NumParams);
15860 MethodArgs.reserve(MethodArgs.size() + NumArgsSlots);
15861 bool IsError =
false;
15864 for (
unsigned i = 0; i != NumParams; i++) {
15866 if (i < Args.size()) {
15870 S.
Context, Method->getParamDecl(i)),
15884 MethodArgs.push_back(Arg);
15894 Args.push_back(
Base);
15895 for (
auto *e : ArgExpr) {
15899 Context.DeclarationNames.getCXXOperatorName(OO_Subscript);
15904 ArgExpr.back()->getEndLoc());
15916 if (Fn.isInvalid())
15926 UnbridgedCastsSet UnbridgedCasts;
15939 if (Args.size() == 2)
15942 bool HadMultipleCandidates = (CandidateSet.
size() > 1);
15962 if (
Method->isExplicitObjectMemberFunction()) {
15967 Args[0] = Res.
get();
15971 Args[0], std::nullopt, Best->FoundDecl,
Method);
15975 MethodArgs.push_back(Arg0.
get());
15979 *
this, MethodArgs,
Method, ArgExpr, LLoc);
15987 *
this, FnDecl, Best->FoundDecl,
Base, HadMultipleCandidates,
15998 Context, OO_Subscript, FnExpr.
get(), MethodArgs, ResultTy,
VK, RLoc,
16015 Args[0], Best->BuiltinParamTypes[0], Best->Conversions[0],
16020 Args[0] = ArgsRes0.
get();
16023 Args[1], Best->BuiltinParamTypes[1], Best->Conversions[1],
16028 Args[1] = ArgsRes1.
get();
16036 CandidateSet.
empty()
16037 ? (
PDiag(diag::err_ovl_no_oper)
16038 << Args[0]->getType() << 0
16039 << Args[0]->getSourceRange() << Range)
16040 : (
PDiag(diag::err_ovl_no_viable_subscript)
16041 << Args[0]->getType() << Args[0]->getSourceRange() << Range);
16048 if (Args.size() == 2) {
16051 LLoc,
PDiag(diag::err_ovl_ambiguous_oper_binary)
16053 << Args[0]->getSourceRange() << Range),
16058 PDiag(diag::err_ovl_ambiguous_subscript_call)
16060 << Args[0]->getSourceRange() << Range),
16069 PDiag(diag::err_ovl_deleted_oper)
16070 <<
"[]" << (Msg !=
nullptr)
16071 << (Msg ? Msg->
getString() : StringRef())
16072 << Args[0]->getSourceRange() << Range),
16086 Expr *ExecConfig,
bool IsExecConfig,
16087 bool AllowRecovery) {
16096 if (
BinaryOperator *op = dyn_cast<BinaryOperator>(NakedMemExpr)) {
16097 assert(op->getType() ==
Context.BoundMemberTy);
16098 assert(op->getOpcode() == BO_PtrMemD || op->getOpcode() == BO_PtrMemI);
16111 QualType objectType = op->getLHS()->getType();
16112 if (op->getOpcode() == BO_PtrMemI)
16116 Qualifiers difference = objectQuals - funcQuals;
16120 std::string qualsString = difference.
getAsString();
16121 Diag(LParenLoc, diag::err_pointer_to_member_call_drops_quals)
16124 << (qualsString.find(
' ') == std::string::npos ? 1 : 2);
16128 Context, MemExprE, Args, resultType, valueKind, RParenLoc,
16138 if (CheckOtherCall(call, proto))
16148 if (!AllowRecovery)
16150 std::vector<Expr *> SubExprs = {MemExprE};
16151 llvm::append_range(SubExprs, Args);
16159 UnbridgedCastsSet UnbridgedCasts;
16165 bool HadMultipleCandidates =
false;
16173 UnbridgedCasts.restore();
16191 TemplateArgs = &TemplateArgsBuffer;
16195 E = UnresExpr->
decls_end(); I != E; ++I) {
16197 QualType ExplicitObjectType = ObjectType;
16204 bool HasExplicitParameter =
false;
16205 if (
const auto *M = dyn_cast<FunctionDecl>(
Func);
16206 M && M->hasCXXExplicitFunctionObjectParameter())
16207 HasExplicitParameter =
true;
16208 else if (
const auto *M = dyn_cast<FunctionTemplateDecl>(
Func);
16210 M->getTemplatedDecl()->hasCXXExplicitFunctionObjectParameter())
16211 HasExplicitParameter =
true;
16213 if (HasExplicitParameter)
16221 }
else if ((
Method = dyn_cast<CXXMethodDecl>(
Func))) {
16228 ObjectClassification, Args, CandidateSet,
16232 I.getPair(), ActingDC, TemplateArgs,
16233 ExplicitObjectType, ObjectClassification,
16234 Args, CandidateSet,
16239 HadMultipleCandidates = (CandidateSet.
size() > 1);
16243 UnbridgedCasts.restore();
16246 bool Succeeded =
false;
16251 FoundDecl = Best->FoundDecl;
16271 PDiag(diag::err_ovl_no_viable_member_function_in_call)
16278 PDiag(diag::err_ovl_ambiguous_member_call)
16285 CandidateSet, Best->Function, Args,
true);
16296 MemExprE = Res.
get();
16300 if (
Method->isStatic()) {
16302 ExecConfig, IsExecConfig);
16312 assert(
Method &&
"Member call to something that isn't a method?");
16317 if (
Method->isExplicitObjectMemberFunction()) {
16325 HadMultipleCandidates, MemExpr->
getExprLoc());
16332 TheCall->setUsesMemberSyntax(
true);
16342 Proto->getNumParams());
16348 return BuildRecoveryExpr(ResultType);
16353 return BuildRecoveryExpr(ResultType);
16363 if (
auto *MemE = dyn_cast<MemberExpr>(NakedMemExpr)) {
16364 if (
const EnableIfAttr *
Attr =
16366 Diag(MemE->getMemberLoc(),
16367 diag::err_ovl_no_viable_member_function_in_call)
16370 diag::note_ovl_candidate_disabled_by_function_cond_attr)
16371 <<
Attr->getCond()->getSourceRange() <<
Attr->getMessage();
16377 TheCall->getDirectCallee()->isPureVirtual()) {
16383 diag::warn_call_to_pure_virtual_member_function_from_ctor_dtor)
16394 if (
auto *DD = dyn_cast<CXXDestructorDecl>(TheCall->getDirectCallee())) {
16398 CallCanBeVirtual,
true,
16403 TheCall->getDirectCallee());
16415 UnbridgedCastsSet UnbridgedCasts;
16419 assert(Object.get()->getType()->isRecordType() &&
16420 "Requires object type argument");
16434 diag::err_incomplete_object_call, Object.get()))
16437 auto *
Record = Object.get()->getType()->castAsCXXRecordDecl();
16443 Oper != OperEnd; ++Oper) {
16445 Object.get()->Classify(
Context), Args, CandidateSet,
16457 bool IgnoreSurrogateFunctions =
false;
16460 if (!Candidate.
Viable &&
16462 IgnoreSurrogateFunctions =
true;
16484 !IgnoreSurrogateFunctions && I != E; ++I) {
16506 Object.get(), Args, CandidateSet);
16511 bool HadMultipleCandidates = (CandidateSet.
size() > 1);
16524 CandidateSet.
empty()
16525 ? (
PDiag(diag::err_ovl_no_oper)
16526 << Object.get()->getType() << 1
16527 << Object.get()->getSourceRange())
16528 : (
PDiag(diag::err_ovl_no_viable_object_call)
16529 << Object.get()->getType() << Object.get()->getSourceRange());
16539 PDiag(diag::err_ovl_ambiguous_object_call)
16540 << Object.get()->getType()
16541 << Object.get()->getSourceRange()),
16552 PDiag(diag::err_ovl_deleted_object_call)
16553 << Object.get()->getType() << (Msg !=
nullptr)
16554 << (Msg ? Msg->
getString() : StringRef())
16555 << Object.get()->getSourceRange()),
16561 if (Best == CandidateSet.
end())
16564 UnbridgedCasts.restore();
16566 if (Best->Function ==
nullptr) {
16571 Best->Conversions[0].UserDefined.ConversionFunction);
16577 assert(Conv == Best->FoundDecl.getDecl() &&
16578 "Found Decl & conversion-to-functionptr should be same, right?!");
16586 Conv, HadMultipleCandidates);
16587 if (
Call.isInvalid())
16591 Context,
Call.get()->getType(), CK_UserDefinedConversion,
Call.get(),
16605 if (
Method->isInvalidDecl())
16612 Context.DeclarationNames.getCXXOperatorName(OO_Call), LParenLoc);
16615 Obj, HadMultipleCandidates,
16622 MethodArgs.reserve(NumParams + 1);
16624 bool IsError =
false;
16628 if (
Method->isExplicitObjectMemberFunction()) {
16632 Object.get(), std::nullopt, Best->FoundDecl,
Method);
16637 MethodArgs.push_back(Object.get());
16641 *
this, MethodArgs,
Method, Args, LParenLoc);
16644 if (Proto->isVariadic()) {
16646 for (
unsigned i = NumParams, e = Args.size(); i < e; i++) {
16650 MethodArgs.push_back(Arg.
get());
16665 Context, OO_Call, NewFn.
get(), MethodArgs, ResultTy,
VK, RParenLoc,
16679 bool *NoArrowOperatorFound) {
16680 assert(
Base->getType()->isRecordType() &&
16681 "left-hand side must have class type");
16695 Context.DeclarationNames.getCXXOperatorName(OO_Arrow);
16699 diag::err_typecheck_incomplete_tag,
Base))
16707 Oper != OperEnd; ++Oper) {
16713 bool HadMultipleCandidates = (CandidateSet.
size() > 1);
16724 if (CandidateSet.
empty()) {
16726 if (NoArrowOperatorFound) {
16729 *NoArrowOperatorFound =
true;
16732 Diag(OpLoc, diag::err_typecheck_member_reference_arrow)
16733 << BaseType <<
Base->getSourceRange();
16734 if (BaseType->isRecordType() && !BaseType->isPointerType()) {
16735 Diag(OpLoc, diag::note_typecheck_member_reference_suggestion)
16739 Diag(OpLoc, diag::err_ovl_no_viable_oper)
16740 <<
"operator->" <<
Base->getSourceRange();
16748 <<
"->" <<
Base->getType()
16749 <<
Base->getSourceRange()),
16757 <<
"->" << (Msg !=
nullptr)
16758 << (Msg ? Msg->
getString() : StringRef())
16759 <<
Base->getSourceRange()),
16770 if (
Method->isExplicitObjectMemberFunction()) {
16777 Base, std::nullopt, Best->FoundDecl,
Method);
16785 Base, HadMultipleCandidates, OpLoc);
16819 bool HadMultipleCandidates = (CandidateSet.
size() > 1);
16832 PDiag(diag::err_ovl_no_viable_function_in_call)
16847 nullptr, HadMultipleCandidates,
16850 if (Fn.isInvalid())
16856 for (
unsigned ArgIdx = 0, N = Args.size(); ArgIdx != N; ++ArgIdx) {
16862 ConvArgs[ArgIdx] = InputInit.
get();
16889 Scope *S =
nullptr;
16892 if (!MemberLookup.
empty()) {
16919 if (CandidateSet->
empty() || CandidateSetError) {
16932 Loc,
nullptr, CandidateSet, &Best,
16945 if (
ParenExpr *PE = dyn_cast<ParenExpr>(E)) {
16950 if (SubExpr.
get() == PE->getSubExpr())
16954 ParenExpr(PE->getLParen(), PE->getRParen(), SubExpr.
get());
16962 assert(
Context.hasSameType(ICE->getSubExpr()->getType(),
16964 "Implicit cast type cannot be determined from overload");
16965 assert(ICE->path_empty() &&
"fixing up hierarchy conversion?");
16966 if (SubExpr.
get() == ICE->getSubExpr())
16974 if (
auto *GSE = dyn_cast<GenericSelectionExpr>(E)) {
16975 if (!GSE->isResultDependent()) {
16980 if (SubExpr.
get() == GSE->getResultExpr())
16987 unsigned ResultIdx = GSE->getResultIndex();
16988 AssocExprs[ResultIdx] = SubExpr.
get();
16990 if (GSE->isExprPredicate())
16992 Context, GSE->getGenericLoc(), GSE->getControllingExpr(),
16993 GSE->getAssocTypeSourceInfos(), AssocExprs, GSE->getDefaultLoc(),
16994 GSE->getRParenLoc(), GSE->containsUnexpandedParameterPack(),
16997 Context, GSE->getGenericLoc(), GSE->getControllingType(),
16998 GSE->getAssocTypeSourceInfos(), AssocExprs, GSE->getDefaultLoc(),
16999 GSE->getRParenLoc(), GSE->containsUnexpandedParameterPack(),
17008 assert(UnOp->getOpcode() == UO_AddrOf &&
17009 "Can only take the address of an overloaded function");
17011 if (!
Method->isImplicitObjectMemberFunction()) {
17022 if (SubExpr.
get() == UnOp->getSubExpr())
17030 "fixed to something other than a decl ref");
17033 assert(Qualifier &&
17034 "fixed to a member ref with no nested name qualifier");
17040 Fn->getType(), Qualifier,
17043 if (
Context.getTargetInfo().getCXXABI().isMicrosoft())
17048 UnOp->getOperatorLoc(),
false,
17056 if (SubExpr.
get() == UnOp->getSubExpr())
17069 if (ULE->hasExplicitTemplateArgs()) {
17070 ULE->copyTemplateArgumentsInto(TemplateArgsBuffer);
17071 TemplateArgs = &TemplateArgsBuffer;
17076 getLangOpts().CPlusPlus && !Fn->hasCXXExplicitFunctionObjectParameter()
17081 if (
unsigned BID = Fn->getBuiltinID()) {
17082 if (!
Context.BuiltinInfo.isDirectlyAddressable(BID)) {
17089 Fn,
Type, ValueKind, ULE->getNameInfo(), ULE->getQualifierLoc(),
17090 Found.getDecl(), ULE->getTemplateKeywordLoc(), TemplateArgs);
17098 if (MemExpr->hasExplicitTemplateArgs()) {
17099 MemExpr->copyTemplateArgumentsInto(TemplateArgsBuffer);
17100 TemplateArgs = &TemplateArgsBuffer;
17107 if (MemExpr->isImplicitAccess()) {
17110 Fn, Fn->getType(),
VK_LValue, MemExpr->getNameInfo(),
17111 MemExpr->getQualifierLoc(),
Found.getDecl(),
17112 MemExpr->getTemplateKeywordLoc(), TemplateArgs);
17117 if (MemExpr->getQualifier())
17118 Loc = MemExpr->getQualifierLoc().getBeginLoc();
17123 Base = MemExpr->getBase();
17129 type = Fn->getType();
17136 Base, MemExpr->isArrow(), MemExpr->getOperatorLoc(),
17137 MemExpr->getQualifierLoc(), MemExpr->getTemplateKeywordLoc(), Fn,
Found,
17138 true, MemExpr->getMemberNameInfo(),
17142 llvm_unreachable(
"Invalid reference to overloaded function");
17153 if (!PartialOverloading || !
Function)
17157 if (
const auto *Proto =
17158 dyn_cast<FunctionProtoType>(
Function->getFunctionType()))
17159 if (Proto->isTemplateVariadic())
17161 if (
auto *Pattern =
Function->getTemplateInstantiationPattern())
17162 if (
const auto *Proto =
17163 dyn_cast<FunctionProtoType>(Pattern->getFunctionType()))
17164 if (Proto->isTemplateVariadic())
17177 << IsMember << Name << (Msg !=
nullptr)
17178 << (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 bool IsVectorOrMatrixElementConversion(Sema &S, QualType FromType, QualType ToType, ImplicitConversionKind &ICK, Expr *From)
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 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 IsMatrixConversion(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 matrix conversion.
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.
static CanQualType getCanonicalType(QualType T)
Return the canonical (structural) type corresponding to the specified potentially non-canonical type ...
DeclarationNameTable DeclarationNames
QualType getArrayParameterType(QualType Ty) const
Return the uniqued reference to a specified array parameter type from the original array type.
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.
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 ...
static bool hasSameType(QualType T1, QualType T2)
Determine whether the given types T1 and T2 are equivalent.
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
static bool hasSameUnqualifiedType(QualType T1, QualType T2)
Determine whether the given types are equivalent after cvr-qualifiers have been removed.
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) const
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)
Represents a concrete matrix type with constant number of rows and columns.
unsigned getNumColumns() const
Returns the number of columns in the matrix.
unsigned getNumRows() const
Returns the number of rows in the matrix.
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...
FunctionDecl * getCanonicalDecl() override
Retrieves the "canonical" declaration of the given declaration.
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() 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.
QualType getElementType() const
Returns type of the elements being stored in the matrix.
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.
PartialDiagnostic PDiag(unsigned DiagID=0)
Build a partial diagnostic.
SemaDiagnosticBuilder Diag(SourceLocation Loc, unsigned DiagID)
Emit a 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.
A class which encapsulates the logic for delaying diagnostics during parsing and other processing.
DelayedDiagnosticsState pushUndelayed()
Enter a new scope where access and deprecation diagnostics are not delayed.
bool match(QualType T) override
Match an integral or (possibly scoped) enumeration type.
RAII class used to determine whether SFINAE has trapped any errors that occur during template argumen...
bool hasErrorOccurred() const
Determine whether any SFINAE errors have been trapped.
Sema - This implements semantic analysis and AST building for C.
bool TryFunctionConversion(QualType FromType, QualType ToType, QualType &ResultTy) const
Same as IsFunctionConversion, but if this would return true, it sets ResultTy to ToType.
QualType getCurrentThisType()
Try to retrieve the type of the 'this' pointer.
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.
bool DiagnoseUseOfDecl(NamedDecl *D, ArrayRef< SourceLocation > Locs, const ObjCInterfaceDecl *UnknownObjCClass=nullptr, bool ObjCPropertyAccess=false, bool AvoidPartialAvailabilityChecks=false, ObjCInterfaceDecl *ClassReceiver=nullptr, bool SkipTrailingRequiresClause=false)
Determine whether the use of this declaration is valid, and emit any corresponding diagnostics.
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.
bool pushCodeSynthesisContext(CodeSynthesisContext Ctx)
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.
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.
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.
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)
void DiagnoseUnsatisfiedConstraint(const ConstraintSatisfaction &Satisfaction, SourceLocation Loc={}, bool First=true)
Emit diagnostics explaining why a constraint expression was deemed unsatisfied.
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 ?
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 isSFINAEContext() const
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.
bool IsFunctionConversion(QualType FromType, QualType ToType) const
Determine whether the conversion from FromType to ToType is a valid conversion of ExtInfo/ExtProtoInf...
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...
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>'.
const Type * getUnqualifiedDesugaredType() const
Return the specified type with any "sugar" removed from the type, removing any typedefs,...
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_HLSL_Matrix_Splat
HLSL matrix splat from scalar or boolean type.
@ 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_HLSL_Matrix_Truncation
HLSL Matrix truncation.
@ 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)
@ None
The alignment was not explicit in code.
CCEKind
Contexts in which a converted constant expression is required.
@ TemplateArg
Value of a non-type template parameter.
@ Noexcept
Condition in a noexcept(bool) specifier.
@ ArrayBound
Array bound in array declarator or new-expression.
@ TempArgStrict
As above, but applies strict template checking rules.
@ ExplicitBool
Condition in an explicit(bool) specifier.
ImplicitConversionRank GetConversionRank(ImplicitConversionKind Kind)
GetConversionRank - Retrieve the implicit conversion rank corresponding to the given implicit convers...
@ Enum
The "enum" keyword introduces the elaborated-type-specifier.
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 allowsReversed(OverloadedOperatorKind Op) const
Determine whether reversing parameter order is allowed for operator Op.
bool shouldAddReversed(Sema &S, ArrayRef< Expr * > OriginalArgs, FunctionDecl *FD) const
Determine whether we should add a rewritten candidate for FD with reversed parameter order.
bool isAcceptableCandidate(const FunctionDecl *FD) const
bool isReversible() const
Determines whether this operator could be implemented by a function with reversed parameter order.
SourceLocation OpLoc
The source location of the operator.
bool AllowRewrittenCandidates
Whether we should include rewritten candidates in the overload set.
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.