43#include "llvm/ADT/DenseSet.h"
44#include "llvm/ADT/STLExtras.h"
45#include "llvm/ADT/STLForwardCompat.h"
46#include "llvm/ADT/ScopeExit.h"
47#include "llvm/ADT/SmallPtrSet.h"
48#include "llvm/ADT/SmallVector.h"
62 return P->hasAttr<PassObjectSizeAttr>();
86 NameInfo, Fn->getType(),
VK_LValue, FoundDecl,
88 if (HadMultipleCandidates)
89 DRE->setHadMultipleCandidates(
true);
95 DRE->setType(Fn->getType());
99 CK_FunctionToPointerDecay);
104 bool HadMultipleCandidates,
107 FoundDecl,
Base, HadMultipleCandidates, NameInfo,
113 bool HadMultipleCandidates,
120 bool InOverloadResolution,
123 bool AllowObjCWritebackConversion);
127 bool InOverloadResolution,
135 bool AllowObjCConversionOnExplicit);
204 return Rank[(int)Kind];
229 static const char *
const Name[] = {
233 "Function-to-pointer",
234 "Function pointer conversion",
236 "Integral promotion",
237 "Floating point promotion",
239 "Integral conversion",
240 "Floating conversion",
241 "Complex conversion",
242 "Floating-integral conversion",
243 "Pointer conversion",
244 "Pointer-to-member conversion",
245 "Boolean conversion",
246 "Compatible-types conversion",
247 "Derived-to-base conversion",
249 "SVE Vector conversion",
250 "RVV Vector conversion",
252 "Complex-real conversion",
253 "Block Pointer conversion",
254 "Transparent Union Conversion",
255 "Writeback conversion",
256 "OpenCL Zero Event Conversion",
257 "OpenCL Zero Queue Conversion",
258 "C specific type conversion",
259 "Incompatible pointer conversion",
260 "Fixed point conversion",
261 "HLSL vector truncation",
262 "HLSL matrix truncation",
263 "Non-decaying array conversion",
266 "HLSL packed type conversion",
342 FromType = Context.getArrayDecayedType(FromType);
354 const Expr *Converted) {
357 if (
auto *EWC = dyn_cast<ExprWithCleanups>(Converted)) {
364 while (
auto *ICE = dyn_cast<ImplicitCastExpr>(Converted)) {
365 switch (ICE->getCastKind()) {
367 case CK_IntegralCast:
368 case CK_IntegralToBoolean:
369 case CK_IntegralToFloating:
370 case CK_BooleanToSignedIntegral:
371 case CK_FloatingToIntegral:
372 case CK_FloatingToBoolean:
373 case CK_FloatingCast:
374 Converted = ICE->getSubExpr();
400 QualType &ConstantType,
bool IgnoreFloatToIntegralConversion,
401 bool AllowRelaxedEval)
const {
403 "narrowing check outside C++");
414 ToType = ED->getIntegerType();
420 goto FloatingIntegralConversion;
422 goto IntegralConversion;
433 FloatingIntegralConversion:
438 if (IgnoreFloatToIntegralConversion)
441 assert(
Initializer &&
"Unknown conversion expression");
447 if (std::optional<llvm::APSInt> IntConstantValue =
451 Result.convertFromAPInt(*IntConstantValue, IntConstantValue->isSigned(),
452 llvm::APFloat::rmNearestTiesToEven);
454 llvm::APSInt ConvertedValue = *IntConstantValue;
456 llvm::APFloat::opStatus Status =
Result.convertToInteger(
457 ConvertedValue, llvm::APFloat::rmTowardZero, &ignored);
460 if (Status == llvm::APFloat::opInvalidOp ||
461 *IntConstantValue != ConvertedValue) {
462 ConstantValue =
APValue(*IntConstantValue);
490 Initializer->isCXX11ConstantExpr(Ctx, ConstantValue,
491 AllowRelaxedEval)))) {
494 ConstantValue = R.Val;
495 assert(ConstantValue.
isFloat());
496 llvm::APFloat FloatVal = ConstantValue.
getFloat();
499 llvm::APFloat Converted = FloatVal;
500 llvm::APFloat::opStatus ConvertStatus =
502 llvm::APFloat::rmNearestTiesToEven, &ignored);
504 llvm::APFloat::rmNearestTiesToEven, &ignored);
506 if (FloatVal.isNaN() && Converted.isNaN() &&
507 !FloatVal.isSignaling() && !Converted.isSignaling()) {
513 if (!Converted.bitwiseIsEqual(FloatVal)) {
520 if (ConvertStatus & llvm::APFloat::opOverflow) {
542 IntegralConversion: {
550 constexpr auto CanRepresentAll = [](
bool FromSigned,
unsigned FromWidth,
551 bool ToSigned,
unsigned ToWidth) {
552 return (FromWidth < ToWidth + (FromSigned == ToSigned)) &&
553 !(FromSigned && !ToSigned);
556 if (CanRepresentAll(FromSigned, FromWidth, ToSigned, ToWidth))
562 bool DependentBitField =
false;
564 if (BitField->getBitWidth()->isValueDependent())
565 DependentBitField =
true;
566 else if (
unsigned BitFieldWidth = BitField->getBitWidthValue();
567 BitFieldWidth < FromWidth) {
568 if (CanRepresentAll(FromSigned, BitFieldWidth, ToSigned, ToWidth))
572 FromWidth = BitFieldWidth;
580 std::optional<llvm::APSInt> OptInitializerValue =
581 Initializer->getIntegerConstantExpr(Ctx, AllowRelaxedEval);
582 if (!OptInitializerValue) {
586 if (DependentBitField && !(FromSigned && !ToSigned))
592 llvm::APSInt &InitializerValue = *OptInitializerValue;
593 bool Narrowing =
false;
594 if (FromWidth < ToWidth) {
597 if (InitializerValue.isSigned() && InitializerValue.isNegative())
603 InitializerValue.extend(InitializerValue.getBitWidth() + 1);
605 llvm::APSInt ConvertedValue = InitializerValue;
606 ConvertedValue = ConvertedValue.trunc(ToWidth);
607 ConvertedValue.setIsSigned(ToSigned);
608 ConvertedValue = ConvertedValue.extend(InitializerValue.getBitWidth());
609 ConvertedValue.setIsSigned(InitializerValue.isSigned());
611 if (ConvertedValue != InitializerValue)
616 ConstantValue =
APValue(InitializerValue);
632 ConstantValue = R.Val;
633 assert(ConstantValue.
isFloat());
634 llvm::APFloat FloatVal = ConstantValue.
getFloat();
639 if (FloatVal.isNaN() && FloatVal.isSignaling()) {
655 raw_ostream &OS = llvm::errs();
656 bool PrintedSomething =
false;
659 PrintedSomething =
true;
663 if (PrintedSomething) {
669 OS <<
" (by copy constructor)";
671 OS <<
" (direct reference binding)";
673 OS <<
" (reference binding)";
675 PrintedSomething =
true;
679 if (PrintedSomething) {
683 PrintedSomething =
true;
686 if (!PrintedSomething) {
687 OS <<
"No conversions required";
694 raw_ostream &OS = llvm::errs();
702 OS <<
"aggregate initialization";
712 raw_ostream &OS = llvm::errs();
714 OS <<
"Worst list element conversion: ";
715 switch (ConversionKind) {
717 OS <<
"Standard conversion: ";
721 OS <<
"User-defined conversion: ";
725 OS <<
"Ellipsis conversion";
728 OS <<
"Ambiguous conversion";
731 OS <<
"Bad conversion";
756 struct DFIArguments {
762 struct DFIParamWithArguments : DFIArguments {
767 struct DFIDeducedMismatchArgs : DFIArguments {
768 TemplateArgumentList *TemplateArgs;
769 unsigned CallArgIndex;
774 TemplateArgumentList *TemplateArgs;
775 ConstraintSatisfaction Satisfaction;
786 Result.Result =
static_cast<unsigned>(TDK);
787 Result.HasDiagnostic =
false;
807 Result.HasDiagnostic =
true;
814 auto *Saved =
new (Context) DFIDeducedMismatchArgs;
825 DFIArguments *Saved =
new (Context) DFIArguments;
837 DFIParamWithArguments *Saved =
new (Context) DFIParamWithArguments;
838 Saved->Param = Info.
Param;
851 Result.HasDiagnostic =
true;
856 CNSInfo *Saved =
new (Context) CNSInfo;
866 llvm_unreachable(
"not a deduction failure");
899 Diag->~PartialDiagnosticAt();
906 static_cast<CNSInfo *
>(
Data)->Satisfaction.~ConstraintSatisfaction();
909 Diag->~PartialDiagnosticAt();
945 return TemplateParameter::getFromOpaqueValue(
Data);
950 return static_cast<DFIParamWithArguments*
>(
Data)->Param;
980 return static_cast<DFIDeducedMismatchArgs*
>(
Data)->TemplateArgs;
986 return static_cast<CNSInfo*
>(
Data)->TemplateArgs;
1018 return &
static_cast<DFIArguments*
>(
Data)->FirstArg;
1050 return &
static_cast<DFIArguments*
>(
Data)->SecondArg;
1065 return static_cast<DFIDeducedMismatchArgs*
>(
Data)->CallArgIndex;
1068 return std::nullopt;
1081 for (
unsigned I = 0; I <
X->getNumParams(); ++I)
1085 if (
auto *FTX =
X->getDescribedFunctionTemplate()) {
1090 FTY->getTemplateParameters()))
1099 OverloadedOperatorKind::OO_EqualEqual);
1111 OverloadedOperatorKind::OO_ExclaimEqual);
1129 auto *NotEqFD = Op->getAsFunction();
1130 if (
auto *UD = dyn_cast<UsingShadowDecl>(Op))
1131 NotEqFD = UD->getUnderlyingDecl()->getAsFunction();
1144 return Op == OO_EqualEqual || Op == OO_Spaceship;
1152 if (Op == OverloadedOperatorKind::OO_EqualEqual) {
1153 assert(OriginalArgs.size() == 2);
1155 S,
OpLoc, OriginalArgs[1], FD))
1166void OverloadCandidateSet::destroyCandidates() {
1167 for (
iterator i = Candidates.begin(), e = Candidates.end(); i != e; ++i) {
1168 for (
auto &
C : i->Conversions)
1169 C.~ImplicitConversionSequence();
1171 i->DeductionFailure.Destroy();
1176 destroyCandidates();
1177 SlabAllocator.Reset();
1178 NumInlineBytesUsed = 0;
1182 FirstDeferredCandidate =
nullptr;
1183 DeferredCandidatesCount = 0;
1184 HasDeferredTemplateConstructors =
false;
1185 ResolutionByPerfectCandidateIsDisabled =
false;
1189 class UnbridgedCastsSet {
1199 Entry entry = { &E, E };
1200 Entries.push_back(entry);
1205 for (SmallVectorImpl<Entry>::iterator
1206 i = Entries.begin(), e = Entries.end(); i != e; ++i)
1207 *i->Addr = i->Saved;
1221 UnbridgedCastsSet *unbridgedCasts =
nullptr) {
1225 if (placeholder->getKind() == BuiltinType::Overload)
return false;
1229 if (placeholder->getKind() == BuiltinType::ARCUnbridgedCast &&
1231 unbridgedCasts->save(S, E);
1251 UnbridgedCastsSet &unbridged) {
1252 for (
unsigned i = 0, e = Args.size(); i != e; ++i)
1261 bool NewIsUsingDecl) {
1266 bool OldIsUsingDecl =
false;
1268 OldIsUsingDecl =
true;
1272 if (NewIsUsingDecl)
continue;
1279 if ((OldIsUsingDecl || NewIsUsingDecl) && !
isVisible(*I))
1287 bool UseMemberUsingDeclRules =
1288 (OldIsUsingDecl || NewIsUsingDecl) &&
CurContext->isRecord() &&
1289 !
New->getFriendObjectKind();
1293 if (UseMemberUsingDeclRules && OldIsUsingDecl) {
1299 !shouldLinkPossiblyHiddenDecl(*I,
New))
1318 }
else if (
auto *UUD = dyn_cast<UnresolvedUsingValueDecl>(OldD)) {
1325 if (UUD->getQualifier().isDependent() && !UUD->isCXXClassMember()) {
1353 if (
New->getFriendObjectKind() &&
New->getQualifier() &&
1354 !
New->getDescribedFunctionTemplate() &&
1355 !
New->getDependentSpecializationInfo() &&
1356 !
New->getType()->isDependentType()) {
1361 New->setInvalidDecl();
1373 assert(D &&
"function decl should not be null");
1374 if (
auto *A = D->
getAttr<AttrT>())
1375 return !A->isImplicit();
1381 bool UseMemberUsingDeclRules,
1382 bool ConsiderCudaAttrs,
1383 bool UseOverrideRules =
false) {
1389 if (
New->isMSVCRTEntryPoint())
1400 if ((OldTemplate ==
nullptr) != (NewTemplate ==
nullptr))
1423 if (OldQType != NewQType && OldType->isVariadic() != NewType->isVariadic())
1427 if ((
New->isMemberLikeConstrainedFriend() ||
1438 OldDecl = OldTemplate;
1439 NewDecl = NewTemplate;
1457 bool ConstraintsInTemplateHead =
1468 if (UseMemberUsingDeclRules && ConstraintsInTemplateHead &&
1469 !SameTemplateParameterList)
1471 if (!UseMemberUsingDeclRules &&
1472 (!SameTemplateParameterList || !SameReturnType))
1476 const auto *OldMethod = dyn_cast<CXXMethodDecl>(Old);
1477 const auto *NewMethod = dyn_cast<CXXMethodDecl>(
New);
1479 int OldParamsOffset = 0;
1480 int NewParamsOffset = 0;
1488 if (ThisType.isConstQualified())
1508 BS.
Quals = NormalizeQualifiers(OldMethod, BS.
Quals);
1509 DS.Quals = NormalizeQualifiers(NewMethod, DS.Quals);
1511 if (OldMethod->isExplicitObjectMemberFunction()) {
1513 DS.Quals.removeVolatile();
1516 return BS.
Quals == DS.Quals;
1520 auto BS =
Base.getNonReferenceType().getCanonicalType().split();
1521 auto DS = D.getNonReferenceType().getCanonicalType().split();
1523 if (!AreQualifiersEqual(BS, DS))
1526 if (OldMethod->isImplicitObjectMemberFunction() &&
1527 OldMethod->getParent() != NewMethod->getParent()) {
1539 if (
Base->isLValueReferenceType())
1540 return D->isLValueReferenceType();
1541 return Base->isRValueReferenceType() == D->isRValueReferenceType();
1546 auto DiagnoseInconsistentRefQualifiers = [&]() {
1547 if (SemaRef.
LangOpts.CPlusPlus23 && !UseOverrideRules)
1549 if (OldMethod->getRefQualifier() == NewMethod->getRefQualifier())
1551 if (OldMethod->isExplicitObjectMemberFunction() ||
1552 NewMethod->isExplicitObjectMemberFunction())
1554 if (!UseMemberUsingDeclRules && (OldMethod->getRefQualifier() ==
RQ_None ||
1555 NewMethod->getRefQualifier() ==
RQ_None)) {
1556 SemaRef.
Diag(NewMethod->getLocation(), diag::err_ref_qualifier_overload)
1557 << OldMethod->getRefQualifier() << NewMethod->getRefQualifier();
1558 SemaRef.
Diag(OldMethod->getLocation(), diag::note_previous_declaration);
1567 bool ShouldDiagnoseInconsistentRefQualifiers =
false;
1568 bool HaveInconsistentQualifiers =
false;
1570 if (OldMethod && OldMethod->isExplicitObjectMemberFunction())
1572 if (NewMethod && NewMethod->isExplicitObjectMemberFunction())
1575 if (OldType->getNumParams() - OldParamsOffset !=
1576 NewType->getNumParams() - NewParamsOffset ||
1578 {OldType->param_type_begin() + OldParamsOffset,
1579 OldType->param_type_end()},
1580 {NewType->param_type_begin() + NewParamsOffset,
1581 NewType->param_type_end()},
1586 if (OldMethod && NewMethod && !OldMethod->isStatic() &&
1587 !NewMethod->isStatic()) {
1588 bool HaveCorrespondingObjectParameters = [&](
const CXXMethodDecl *Old,
1590 auto NewObjectType =
New->getFunctionObjectParameterReferenceType();
1594 return F->getRefQualifier() ==
RQ_None &&
1595 !F->isExplicitObjectMemberFunction();
1598 if (IsImplicitWithNoRefQual(Old) != IsImplicitWithNoRefQual(
New) &&
1599 CompareType(OldObjectType.getNonReferenceType(),
1600 NewObjectType.getNonReferenceType()))
1602 return CompareType(OldObjectType, NewObjectType);
1603 }(OldMethod, NewMethod);
1605 if (!HaveCorrespondingObjectParameters) {
1606 ShouldDiagnoseInconsistentRefQualifiers =
true;
1610 if (!UseOverrideRules || (!NewMethod->isExplicitObjectMemberFunction() &&
1611 !OldMethod->isExplicitObjectMemberFunction()))
1612 HaveInconsistentQualifiers =
true;
1616 if (NewMethod && OldMethod && OldMethod->isImplicitObjectMemberFunction() &&
1617 NewMethod->isImplicitObjectMemberFunction())
1618 ShouldDiagnoseInconsistentRefQualifiers =
true;
1620 if (!UseOverrideRules &&
1624 if (!NewRC != !OldRC)
1644 NewI =
New->specific_attr_begin<EnableIfAttr>(),
1645 NewE =
New->specific_attr_end<EnableIfAttr>(),
1648 NewI != NewE || OldI != OldE; ++NewI, ++OldI) {
1649 if (NewI == NewE || OldI == OldE)
1651 llvm::FoldingSetNodeID NewID, OldID;
1652 NewI->getCond()->Profile(NewID, SemaRef.
Context,
true);
1653 OldI->getCond()->Profile(OldID, SemaRef.
Context,
true);
1658 if ((ShouldDiagnoseInconsistentRefQualifiers &&
1659 DiagnoseInconsistentRefQualifiers()) ||
1660 HaveInconsistentQualifiers)
1664 if (SemaRef.
getLangOpts().CUDA && ConsiderCudaAttrs) {
1672 "Unexpected invalid target.");
1676 if (NewTarget != OldTarget) {
1679 if (OldMethod && NewMethod && OldMethod->isVirtual() &&
1680 OldMethod->isConstexpr() && !NewMethod->isConstexpr() &&
1698 bool UseMemberUsingDeclRules,
bool ConsiderCudaAttrs) {
1704 bool UseMemberUsingDeclRules,
bool ConsiderCudaAttrs) {
1717 bool SuppressUserConversions,
1719 bool InOverloadResolution,
1721 bool AllowObjCWritebackConversion,
1722 bool AllowObjCConversionOnExplicit) {
1725 if (SuppressUserConversions) {
1736 Conversions, AllowExplicit,
1737 AllowObjCConversionOnExplicit)) {
1758 bool FromListInit =
false;
1759 if (
const auto *InitList = dyn_cast<InitListExpr>(From);
1760 InitList && InitList->getNumInits() == 1 &&
1762 const Expr *SingleInit = InitList->getInit(0);
1763 FromType = SingleInit->
getType();
1765 FromListInit =
true;
1774 if ((FromCanon == ToCanon ||
1786 if (ToCanon != FromCanon)
1797 Cand != Conversions.
end(); ++Cand)
1838static ImplicitConversionSequence
1840 bool SuppressUserConversions,
1842 bool InOverloadResolution,
1844 bool AllowObjCWritebackConversion,
1845 bool AllowObjCConversionOnExplicit) {
1848 ICS.
Standard, CStyle, AllowObjCWritebackConversion)){
1899 bool CanConvert =
false;
1905 FromResType->getWrappedType()) &&
1907 FromResType->getContainedType()) &&
1908 ToResType->getAttrs() == FromResType->getAttrs())
1910 }
else if (ToTy->isHLSLResourceType()) {
1924 AllowExplicit, InOverloadResolution, CStyle,
1925 AllowObjCWritebackConversion,
1926 AllowObjCConversionOnExplicit);
1929ImplicitConversionSequence
1931 bool SuppressUserConversions,
1933 bool InOverloadResolution,
1935 bool AllowObjCWritebackConversion) {
1936 return ::TryImplicitConversion(*
this, From, ToType, SuppressUserConversions,
1937 AllowExplicit, InOverloadResolution, CStyle,
1938 AllowObjCWritebackConversion,
1944 bool AllowExplicit) {
1949 bool AllowObjCWritebackConversion =
1956 *
this, From, ToType,
1958 AllowExplicit ? AllowedExplicit::All : AllowedExplicit::None,
1960 false, AllowObjCWritebackConversion,
1974 if (
Context.hasSameUnqualifiedType(FromType, ToType))
1987 if (TyClass != CanFrom->getTypeClass())
return false;
1988 if (TyClass != Type::FunctionProto && TyClass != Type::FunctionNoProto) {
1989 if (TyClass == Type::Pointer) {
1992 }
else if (TyClass == Type::BlockPointer) {
1995 }
else if (TyClass == Type::MemberPointer) {
2002 CanTo = ToMPT->getPointeeType();
2008 TyClass = CanTo->getTypeClass();
2009 if (TyClass != CanFrom->getTypeClass())
return false;
2010 if (TyClass != Type::FunctionProto && TyClass != Type::FunctionNoProto)
2020 bool Changed =
false;
2028 const auto *FromFPT = dyn_cast<FunctionProtoType>(FromFn);
2029 const auto *ToFPT = dyn_cast<FunctionProtoType>(ToFn);
2031 if (FromFPT && ToFPT) {
2032 if (FromFPT->hasCFIUncheckedCallee() != ToFPT->hasCFIUncheckedCallee()) {
2034 FromFPT->getReturnType(), FromFPT->getParamTypes(),
2035 FromFPT->getExtProtoInfo().withCFIUncheckedCallee(
2036 ToFPT->hasCFIUncheckedCallee()));
2044 if (FromFPT && ToFPT) {
2045 if (FromFPT->isNothrow() && !ToFPT->isNothrow()) {
2057 bool CanUseToFPT, CanUseFromFPT;
2058 if (
Context.mergeExtParameterInfo(ToFPT, FromFPT, CanUseToFPT,
2059 CanUseFromFPT, NewParamInfos) &&
2060 CanUseToFPT && !CanUseFromFPT) {
2063 NewParamInfos.empty() ?
nullptr : NewParamInfos.data();
2065 FromFPT->getParamTypes(), ExtInfo);
2070 if (
Context.hasAnyFunctionEffects()) {
2075 const auto FromFX = FromFPT->getFunctionEffects();
2076 const auto ToFX = ToFPT->getFunctionEffects();
2077 if (FromFX != ToFX) {
2081 FromFPT->getReturnType(), FromFPT->getParamTypes(), ExtInfo);
2091 assert(
QualType(FromFn, 0).isCanonical());
2092 if (
QualType(FromFn, 0) != CanTo)
return false;
2119 if ((&FromSem == &llvm::APFloat::PPCDoubleDouble() &&
2120 &ToSem == &llvm::APFloat::IEEEquad()) ||
2121 (&FromSem == &llvm::APFloat::IEEEquad() &&
2122 &ToSem == &llvm::APFloat::PPCDoubleDouble()))
2178 bool InOverloadResolution,
bool CStyle) {
2188 if (ToMatrixType && FromMatrixType) {
2190 unsigned ToCols = ToMatrixType->getNumColumns();
2191 if (FromCols < ToCols)
2194 unsigned FromRows = FromMatrixType->
getNumRows();
2195 unsigned ToRows = ToMatrixType->getNumRows();
2196 if (FromRows < ToRows)
2199 if (FromRows == ToRows && FromCols == ToCols)
2205 QualType ToElTy = ToMatrixType->getElementType();
2214 QualType ToElTy = ToMatrixType->getElementType();
2217 if (FromMatrixType && !ToMatrixType) {
2236 bool InOverloadResolution,
bool CStyle) {
2253 if (ToExtType && FromExtType) {
2255 unsigned ToElts = ToExtType->getNumElements();
2256 if (FromElts < ToElts)
2258 if (FromElts == ToElts)
2264 QualType ToElTy = ToExtType->getElementType();
2269 if (FromExtType && !ToExtType) {
2283 if (ToExtType->getNumElements() != FromExtType->getNumElements())
2288 FromExtType->getElementType()->isIntegerType()) {
2300 QualType ToElTy = ToExtType->getElementType();
2335 !ToType->
hasAttr(attr::ArmMveStrictPolymorphism))) {
2340 !InOverloadResolution && !CStyle) {
2342 << FromType << ToType;
2365 if (FromPacked && ToPacked) {
2374 if (FromPacked && !ToIsUint)
2378 if (ToPacked && !FromIsUint)
2382 if (FromIsUint || ToIsUint) {
2392 bool InOverloadResolution,
2393 StandardConversionSequence &SCS,
2398 bool InOverloadResolution,
2399 StandardConversionSequence &SCS,
2411 bool InOverloadResolution,
2414 bool AllowObjCWritebackConversion) {
2440 FromType = Fn->getType();
2460 if (Method && !Method->isStatic() &&
2461 !Method->isExplicitObjectMemberFunction()) {
2463 "Non-unary operator on non-static member address");
2466 "Non-address-of operator on non-static member address");
2468 FromType, std::nullopt, Method->getParent());
2472 "Non-address-of operator for overloaded function expression");
2518 FromType =
Atomic->getValueType();
2553 if (
auto *FD = dyn_cast<FunctionDecl>(DRE->getDecl()))
2573 bool IncompatibleObjC =
false;
2635 }
else if (AllowObjCWritebackConversion &&
2639 FromType, IncompatibleObjC)) {
2645 InOverloadResolution, FromType)) {
2649 From, InOverloadResolution, CStyle)) {
2654 From, InOverloadResolution, CStyle)) {
2659 DimensionICK, From)) {
2669 S, From, ToType, InOverloadResolution, SCS, CStyle)) {
2678 S, From, ToType, InOverloadResolution, SCS, CStyle)) {
2708 bool ObjCLifetimeConversion;
2714 ObjCLifetimeConversion)) {
2733 CanonFrom = CanonTo;
2738 if (CanonFrom == CanonTo)
2743 if (S.
getLangOpts().CPlusPlus || !InOverloadResolution)
2755 case AssignConvertType::
2756 CompatibleVoidPtrToNonVoidPtr:
2789 bool InOverloadResolution,
2798 if (!UD->
hasAttr<TransparentUnionAttr>())
2801 for (
const auto *it : UD->
fields()) {
2804 ToType = it->getType();
2830 return To->
getKind() == BuiltinType::Int;
2833 return To->
getKind() == BuiltinType::UInt;
2857 if (FromED->isScoped())
2864 if (FromED->isFixed()) {
2865 QualType Underlying = FromED->getIntegerType();
2866 return Context.hasSameUnqualifiedType(Underlying, ToType) ||
2873 return Context.hasSameUnqualifiedType(ToType, FromED->getPromotionType());
2898 uint64_t FromSize =
Context.getTypeSize(FromType);
2907 for (
int Idx = 0; Idx < 6; ++Idx) {
2908 uint64_t ToSize =
Context.getTypeSize(PromoteTypes[Idx]);
2909 if (FromSize < ToSize ||
2910 (FromSize == ToSize &&
2911 FromIsSigned == PromoteTypes[Idx]->isSignedIntegerType())) {
2915 return Context.hasSameUnqualifiedType(ToType, PromoteTypes[Idx]);
2936 std::optional<llvm::APSInt> BitWidth;
2939 MemberDecl->getBitWidth()->getIntegerConstantExpr(
Context))) {
2940 llvm::APSInt ToSize(BitWidth->getBitWidth(), BitWidth->isUnsigned());
2941 ToSize =
Context.getTypeSize(ToType);
2944 if (*BitWidth < ToSize ||
2946 return To->
getKind() == BuiltinType::Int;
2952 return To->
getKind() == BuiltinType::UInt;
2970 return Context.getTypeSize(FromType) <
Context.getTypeSize(ToType);
2980 if (FromBuiltin->getKind() == BuiltinType::Float &&
2981 ToBuiltin->getKind() == BuiltinType::Double)
2988 (FromBuiltin->getKind() == BuiltinType::Float ||
2989 FromBuiltin->getKind() == BuiltinType::Double) &&
2990 (ToBuiltin->getKind() == BuiltinType::LongDouble ||
2991 ToBuiltin->getKind() == BuiltinType::Float128 ||
2992 ToBuiltin->getKind() == BuiltinType::Ibm128))
2997 if (
getLangOpts().
HLSL && FromBuiltin->getKind() == BuiltinType::Half &&
2998 (ToBuiltin->getKind() == BuiltinType::Float ||
2999 ToBuiltin->getKind() == BuiltinType::Double))
3004 FromBuiltin->getKind() == BuiltinType::Half &&
3005 ToBuiltin->getKind() == BuiltinType::Float)
3034 return Context.getTypeSize(FromType) <
Context.getTypeSize(ToType);
3046 if (
const EnumType *ToEnumType = ToType->
getAs<EnumType>()) {
3058 return Context.getTypeSize(FromType) >
Context.getTypeSize(ToType);
3073 bool StripObjCLifetime =
false) {
3076 "Invalid similarly-qualified pointer type");
3087 if (StripObjCLifetime)
3099 return Context.getObjCObjectPointerType(ToPointee);
3100 return Context.getPointerType(ToPointee);
3108 return Context.getObjCObjectPointerType(QualifiedCanonToPointee);
3109 return Context.getPointerType(QualifiedCanonToPointee);
3113 bool InOverloadResolution,
3119 return !InOverloadResolution;
3127 bool InOverloadResolution,
3129 bool &IncompatibleObjC) {
3130 IncompatibleObjC =
false;
3138 ConvertedType = ToType;
3145 ConvertedType = ToType;
3152 ConvertedType = ToType;
3160 ConvertedType = ToType;
3170 ConvertedType = ToType;
3192 if (
Context.hasSameUnqualifiedType(FromPointeeType, ToPointeeType))
3219 Context.typesAreCompatible(FromPointeeType, ToPointeeType)) {
3241 !
Context.hasSameUnqualifiedType(FromPointeeType, ToPointeeType) &&
3250 Context.areCompatibleVectorTypes(FromPointeeType, ToPointeeType)) {
3269 return Context.getQualifiedType(
T, Qs);
3271 return Context.getQualifiedType(
T.getUnqualifiedType(), Qs);
3276 bool &IncompatibleObjC) {
3289 if (ToObjCPtr && FromObjCPtr) {
3297 if (
Context.canAssignObjCInterfaces(ToObjCPtr, FromObjCPtr)) {
3311 if (
Context.canAssignObjCInterfaces(FromObjCPtr, ToObjCPtr)) {
3315 IncompatibleObjC =
true;
3331 if (FromObjCPtr && FromObjCPtr->isObjCBuiltinType()) {
3360 IncompatibleObjC)) {
3362 IncompatibleObjC =
true;
3363 ConvertedType =
Context.getPointerType(ConvertedType);
3372 IncompatibleObjC)) {
3374 ConvertedType =
Context.getPointerType(ConvertedType);
3387 if (FromFunctionType && ToFunctionType) {
3390 if (
Context.getCanonicalType(FromPointeeType)
3391 ==
Context.getCanonicalType(ToPointeeType))
3396 if (FromFunctionType->
getNumParams() != ToFunctionType->getNumParams() ||
3397 FromFunctionType->
isVariadic() != ToFunctionType->isVariadic() ||
3398 FromFunctionType->
getMethodQuals() != ToFunctionType->getMethodQuals())
3401 bool HasObjCConversion =
false;
3403 Context.getCanonicalType(ToFunctionType->getReturnType())) {
3406 ToFunctionType->getReturnType(),
3407 ConvertedType, IncompatibleObjC)) {
3409 HasObjCConversion =
true;
3416 for (
unsigned ArgIdx = 0, NumArgs = FromFunctionType->
getNumParams();
3417 ArgIdx != NumArgs; ++ArgIdx) {
3419 QualType ToArgType = ToFunctionType->getParamType(ArgIdx);
3420 if (
Context.getCanonicalType(FromArgType)
3421 ==
Context.getCanonicalType(ToArgType)) {
3424 ConvertedType, IncompatibleObjC)) {
3426 HasObjCConversion =
true;
3433 if (HasObjCConversion) {
3437 IncompatibleObjC =
true;
3469 if (!FromFunctionType || !ToFunctionType)
3472 if (
Context.hasSameType(FromPointeeType, ToPointeeType))
3477 if (FromFunctionType->
getNumParams() != ToFunctionType->getNumParams() ||
3478 FromFunctionType->
isVariadic() != ToFunctionType->isVariadic())
3483 if (FromEInfo != ToEInfo)
3486 bool IncompatibleObjC =
false;
3488 ToFunctionType->getReturnType())) {
3492 QualType LHS = ToFunctionType->getReturnType();
3497 if (
Context.hasSameType(RHS,LHS)) {
3500 ConvertedType, IncompatibleObjC)) {
3501 if (IncompatibleObjC)
3510 for (
unsigned ArgIdx = 0, NumArgs = FromFunctionType->
getNumParams();
3511 ArgIdx != NumArgs; ++ArgIdx) {
3512 IncompatibleObjC =
false;
3514 QualType ToArgType = ToFunctionType->getParamType(ArgIdx);
3515 if (
Context.hasSameType(FromArgType, ToArgType)) {
3518 ConvertedType, IncompatibleObjC)) {
3519 if (IncompatibleObjC)
3528 bool CanUseToFPT, CanUseFromFPT;
3529 if (!
Context.mergeExtParameterInfo(ToFunctionType, FromFunctionType,
3530 CanUseToFPT, CanUseFromFPT,
3534 ConvertedType = ToType;
3573 ToMember->getMostRecentCXXRecordDecl())) {
3575 if (ToMember->isSugared())
3577 ToMember->getMostRecentCXXRecordDecl());
3579 PDiag << ToMember->getQualifier();
3580 if (FromMember->isSugared())
3582 FromMember->getMostRecentCXXRecordDecl());
3584 PDiag << FromMember->getQualifier();
3602 !FromType->
getAs<TemplateSpecializationType>()) {
3608 if (
Context.hasSameType(FromType, ToType)) {
3617 if (!FromFunction || !ToFunction) {
3622 if (FromFunction->
getNumParams() != ToFunction->getNumParams()) {
3632 << ToFunction->getParamType(ArgPos)
3639 ToFunction->getReturnType())) {
3645 if (FromFunction->
getMethodQuals() != ToFunction->getMethodQuals()) {
3668 assert(llvm::size(Old) == llvm::size(
New) &&
3669 "Can't compare parameters of functions with different number of "
3672 for (
auto &&[Idx,
Type] : llvm::enumerate(Old)) {
3674 size_t J =
Reversed ? (llvm::size(
New) - Idx - 1) : Idx;
3679 Context.removePtrSizeAddrSpace(
Type.getUnqualifiedType());
3681 Context.removePtrSizeAddrSpace((
New.begin() + J)->getUnqualifiedType());
3683 if (!
Context.hasSameType(OldType, NewType)) {
3708 unsigned OldIgnore =
3710 unsigned NewIgnore =
3717 NewPT->param_types().slice(NewIgnore),
3724 bool IgnoreBaseAccess,
3727 bool IsCStyleOrFunctionalCast = IgnoreBaseAccess;
3736 PDiag(diag::warn_impcast_bool_to_null_pointer)
3747 if (FromPointeeType->
isRecordType() && ToPointeeType->isRecordType() &&
3748 !
Context.hasSameUnqualifiedType(FromPointeeType, ToPointeeType)) {
3751 unsigned InaccessibleID = 0;
3752 unsigned AmbiguousID = 0;
3754 InaccessibleID = diag::err_upcast_to_inaccessible_base;
3755 AmbiguousID = diag::err_ambiguous_derived_to_base_conv;
3758 FromPointeeType, ToPointeeType, InaccessibleID, AmbiguousID,
3760 &BasePath, IgnoreBaseAccess))
3764 Kind = CK_DerivedToBase;
3767 if (
Diagnose && !IsCStyleOrFunctionalCast &&
3768 FromPointeeType->
isFunctionType() && ToPointeeType->isVoidType()) {
3770 "this should only be possible with MSVCCompat!");
3782 if (FromPtrType->isObjCBuiltinType() || ToPtrType->isObjCBuiltinType())
3785 Kind = CK_BlockPointerToObjCPointerCast;
3787 Kind = CK_CPointerToObjCPointerCast;
3791 Kind = CK_AnyPointerToBlockPointerCast;
3797 Kind = CK_NullToPointer;
3804 bool InOverloadResolution,
3814 ConvertedType = ToType;
3830 ConvertedType =
Context.getMemberPointerType(
3844 if (
Context.getTargetInfo().getCXXABI().isMicrosoft()) {
3852 Kind = CK_NullToMemberPointer;
3870 PD <<
Context.getCanonicalTagType(Cls);
3880 std::swap(
Base, Derived);
3889 PD <<
int(Direction);
3897 DiagFromTo(PD) <<
QualType(VBase, 0) << OpRange;
3905 ? CK_DerivedToBaseMemberPointer
3906 : CK_BaseToDerivedMemberPointer;
3908 if (!IgnoreBaseAccess)
3912 ? diag::err_upcast_to_inaccessible_base
3913 : diag::err_downcast_from_inaccessible_base,
3915 NestedNameSpecifier BaseQual = FromPtrType->getQualifier(),
3916 DerivedQual = ToPtrType->getQualifier();
3917 if (Direction == MemberPointerConversionDirection::Upcast)
3918 std::swap(BaseQual, DerivedQual);
3919 DiagCls(PD, DerivedQual, Derived);
3920 DiagCls(PD, BaseQual, Base);
3955 bool CStyle,
bool IsTopLevel,
3956 bool &PreviousToQualsIncludeConst,
3957 bool &ObjCLifetimeConversion,
3970 ObjCLifetimeConversion =
true;
4010 !PreviousToQualsIncludeConst)
4028 PreviousToQualsIncludeConst =
4029 PreviousToQualsIncludeConst && ToQuals.
hasConst();
4035 bool CStyle,
bool &ObjCLifetimeConversion) {
4036 FromType =
Context.getCanonicalType(FromType);
4037 ToType =
Context.getCanonicalType(ToType);
4038 ObjCLifetimeConversion =
false;
4048 bool PreviousToQualsIncludeConst =
true;
4049 bool UnwrappedAnyPointer =
false;
4050 while (
Context.UnwrapSimilarTypes(FromType, ToType)) {
4052 !UnwrappedAnyPointer,
4053 PreviousToQualsIncludeConst,
4056 UnwrappedAnyPointer =
true;
4064 return UnwrappedAnyPointer &&
Context.hasSameUnqualifiedType(FromType,ToType);
4073 bool InOverloadResolution,
4082 InOverloadResolution, InnerSCS,
4097 bool InOverloadResolution,
4100 const OverflowBehaviorType *ToOBT = ToType->
getAs<OverflowBehaviorType>();
4111 InOverloadResolution, InnerSCS, CStyle,
4128 if (CtorType->getNumParams() > 0) {
4129 QualType FirstArg = CtorType->getParamType(0);
4141 bool AllowExplicit) {
4148 bool Usable = !Info.Constructor->isInvalidDecl() &&
4151 bool SuppressUserConversions =
false;
4152 if (Info.ConstructorTmpl)
4155 CandidateSet, SuppressUserConversions,
4160 CandidateSet, SuppressUserConversions,
4161 false, AllowExplicit);
4165 bool HadMultipleCandidates = (CandidateSet.
size() > 1);
4192 llvm_unreachable(
"Invalid OverloadResult!");
4214 bool AllowObjCConversionOnExplicit) {
4215 assert(AllowExplicit != AllowedExplicit::None ||
4216 !AllowObjCConversionOnExplicit);
4220 bool ConstructorsOnly =
false;
4224 if (
const RecordType *ToRecordType = ToType->
getAsCanonical<RecordType>()) {
4236 ConstructorsOnly =
true;
4240 }
else if (
auto *ToRecordDecl =
4241 dyn_cast<CXXRecordDecl>(ToRecordType->getDecl())) {
4242 ToRecordDecl = ToRecordDecl->getDefinitionOrSelf();
4244 Expr **Args = &From;
4245 unsigned NumArgs = 1;
4246 bool ListInitializing =
false;
4248 if (
InitListExpr *InitList = dyn_cast<InitListExpr>(From)) {
4251 S, From, ToType, ToRecordDecl, User, CandidateSet,
4252 AllowExplicit == AllowedExplicit::All);
4263 Args =
Inits.data();
4264 NumArgs =
Inits.size();
4265 ListInitializing =
true;
4273 bool Usable = !Info.Constructor->isInvalidDecl();
4274 if (!ListInitializing)
4275 Usable = Usable && Info.Constructor->isConvertingConstructor(
4278 bool SuppressUserConversions = !ConstructorsOnly;
4286 if (SuppressUserConversions && ListInitializing) {
4287 SuppressUserConversions =
4292 if (Info.ConstructorTmpl)
4294 Info.ConstructorTmpl, Info.FoundDecl,
4296 CandidateSet, SuppressUserConversions,
4298 AllowExplicit == AllowedExplicit::All);
4304 SuppressUserConversions,
4306 AllowExplicit == AllowedExplicit::All);
4316 }
else if (
const RecordType *FromRecordType =
4318 if (
auto *FromRecordDecl =
4319 dyn_cast<CXXRecordDecl>(FromRecordType->getDecl())) {
4320 FromRecordDecl = FromRecordDecl->getDefinitionOrSelf();
4322 const auto &Conversions = FromRecordDecl->getVisibleConversionFunctions();
4323 for (
auto I = Conversions.begin(), E = Conversions.end(); I != E; ++I) {
4332 if ((ConvTemplate = dyn_cast<FunctionTemplateDecl>(D)))
4339 ConvTemplate, FoundDecl, ActingContext, From, ToType,
4340 CandidateSet, AllowObjCConversionOnExplicit,
4341 AllowExplicit != AllowedExplicit::None);
4344 CandidateSet, AllowObjCConversionOnExplicit,
4345 AllowExplicit != AllowedExplicit::None);
4350 bool HadMultipleCandidates = (CandidateSet.
size() > 1);
4359 = dyn_cast<CXXConstructorDecl>(Best->Function)) {
4371 if (Best->Conversions[0].isEllipsis())
4374 User.
Before = Best->Conversions[0].Standard;
4387 = dyn_cast<CXXConversionDecl>(Best->Function)) {
4389 assert(Best->HasFinalConversion);
4397 User.
Before = Best->Conversions[0].Standard;
4412 User.
After = Best->FinalConversion;
4415 llvm_unreachable(
"Not a constructor or conversion function?");
4424 llvm_unreachable(
"Invalid OverloadResult!");
4434 CandidateSet, AllowedExplicit::None,
false);
4449 diag::err_typecheck_nonviable_condition_incomplete,
4456 *
this, From, Cands);
4482 if (!Conv1 || !Conv2)
4497 if (Block1 != Block2)
4510 if (Conv1FuncRet && Conv2FuncRet &&
4521 CallOpProto->isVariadic(),
false);
4523 CallOpProto->isVariadic(),
true);
4525 CallingConv PrefOrder[] = {DefaultFree, DefaultMember, CallOpCC};
4620 if (!ICS1.
isBad()) {
4621 bool StdInit1 =
false, StdInit2 =
false;
4628 if (StdInit1 != StdInit2)
4639 CAT2->getElementType())) {
4641 if (CAT1->getSize() != CAT2->getSize())
4643 return CAT1->getSize().ult(CAT2->getSize())
4678 if (ConvFunc1 == ConvFunc2)
4780 if (!
Enum->isFixed())
4816 else if (Rank2 < Rank1)
4851 bool SCS1ConvertsToVoid
4853 bool SCS2ConvertsToVoid
4855 if (SCS1ConvertsToVoid != SCS2ConvertsToVoid) {
4860 }
else if (!SCS1ConvertsToVoid && !SCS2ConvertsToVoid) {
4866 }
else if (SCS1ConvertsToVoid && SCS2ConvertsToVoid &&
4895 if (FromObjCPtr1 && FromObjCPtr2) {
4900 if (AssignLeft != AssignRight) {
4939 if (UnqualT1 == UnqualT2) {
5001 if (SCS1IsCompatibleVectorConversion != SCS2IsCompatibleVectorConversion)
5002 return SCS1IsCompatibleVectorConversion
5009 bool SCS1IsCompatibleSVEVectorConversion =
5011 bool SCS2IsCompatibleSVEVectorConversion =
5014 if (SCS1IsCompatibleSVEVectorConversion !=
5015 SCS2IsCompatibleSVEVectorConversion)
5016 return SCS1IsCompatibleSVEVectorConversion
5023 bool SCS1IsCompatibleRVVVectorConversion =
5025 bool SCS2IsCompatibleRVVVectorConversion =
5028 if (SCS1IsCompatibleRVVVectorConversion !=
5029 SCS2IsCompatibleRVVVectorConversion)
5030 return SCS1IsCompatibleRVVVectorConversion
5089 if (UnqualT1 == UnqualT2)
5107 bool ObjCLifetimeConversion;
5117 if (CanPick1 != CanPick2)
5171 if (FromPointee1 == FromPointee2 && ToPointee1 != ToPointee2) {
5179 if (FromPointee1 != FromPointee2 && ToPointee1 == ToPointee2) {
5196 if (FromPtr1 && FromPtr2 && ToPtr1 && ToPtr2) {
5203 bool FromAssignRight
5212 if (ToPtr1->isObjCIdType() &&
5213 (ToPtr2->isObjCQualifiedIdType() || ToPtr2->getInterfaceDecl()))
5215 if (ToPtr2->isObjCIdType() &&
5216 (ToPtr1->isObjCQualifiedIdType() || ToPtr1->getInterfaceDecl()))
5221 if (ToPtr1->isObjCQualifiedIdType() && ToPtr2->getInterfaceDecl())
5223 if (ToPtr2->isObjCQualifiedIdType() && ToPtr1->getInterfaceDecl())
5228 if (ToPtr1->isObjCClassType() &&
5229 (ToPtr2->isObjCQualifiedClassType() || ToPtr2->getInterfaceDecl()))
5231 if (ToPtr2->isObjCClassType() &&
5232 (ToPtr1->isObjCQualifiedClassType() || ToPtr1->getInterfaceDecl()))
5237 if (ToPtr1->isObjCQualifiedClassType() && ToPtr2->getInterfaceDecl())
5239 if (ToPtr2->isObjCQualifiedClassType() && ToPtr1->getInterfaceDecl())
5245 (ToAssignLeft != ToAssignRight)) {
5256 }
else if (IsSecondSame)
5265 (FromAssignLeft != FromAssignRight))
5279 CXXRecordDecl *FromPointee1 = FromMemPointer1->getMostRecentCXXRecordDecl();
5284 if (FromPointee1 == FromPointee2 && ToPointee1 != ToPointee2) {
5291 if (ToPointee1 == ToPointee2 && FromPointee1 != FromPointee2) {
5329 if (!
T.getQualifiers().hasUnaligned())
5343 "T1 must be the pointee type of the reference type");
5344 assert(!OrigT2->
isReferenceType() &&
"T2 cannot be a reference type");
5367 if (UnqualT1 == UnqualT2) {
5371 Conv |= ReferenceConversions::DerivedToBase;
5374 Context.canBindObjCObjectType(UnqualT1, UnqualT2))
5375 Conv |= ReferenceConversions::ObjC;
5378 Conv |= ReferenceConversions::Function;
5382 bool ConvertedReferent = Conv != 0;
5386 bool PreviousToQualsIncludeConst =
true;
5387 bool TopLevel =
true;
5393 Conv |= ReferenceConversions::Qualification;
5399 Conv |= ReferenceConversions::NestedQualification;
5407 bool ObjCLifetimeConversion =
false;
5409 PreviousToQualsIncludeConst,
5411 return (ConvertedReferent ||
Context.hasSimilarType(T1, T2))
5416 if (ObjCLifetimeConversion)
5417 Conv |= ReferenceConversions::ObjCLifetime;
5420 }
while (
Context.UnwrapSimilarTypes(T1, T2));
5425 return (ConvertedReferent ||
Context.hasSameUnqualifiedType(T1, T2))
5436 bool AllowExplicit) {
5437 assert(T2->
isRecordType() &&
"Can only find conversions of record types.");
5441 const auto &Conversions = T2RecordDecl->getVisibleConversionFunctions();
5442 for (
auto I = Conversions.begin(), E = Conversions.end(); I != E; ++I) {
5449 = dyn_cast<FunctionTemplateDecl>(D);
5466 if (!ConvTemplate &&
5490 ConvTemplate, I.getPair(), ActingDC,
Init, DeclType, CandidateSet,
5491 false, AllowExplicit);
5494 Conv, I.getPair(), ActingDC,
Init, DeclType, CandidateSet,
5495 false, AllowExplicit);
5498 bool HadMultipleCandidates = (CandidateSet.
size() > 1);
5504 assert(Best->HasFinalConversion);
5516 if (!Best->FinalConversion.DirectBinding)
5528 "Expected a direct reference binding!");
5534 Cand != CandidateSet.
end(); ++Cand)
5546 llvm_unreachable(
"Invalid OverloadResult!");
5551static ImplicitConversionSequence
5554 bool SuppressUserConversions,
5555 bool AllowExplicit) {
5556 assert(DeclType->
isReferenceType() &&
"Reference init needs a reference");
5583 auto SetAsReferenceBinding = [&](
bool BindsDirectly) {
5588 ICS.
Standard.
Second = (RefConv & Sema::ReferenceConversions::DerivedToBase)
5590 : (RefConv & Sema::ReferenceConversions::ObjC)
5598 Sema::ReferenceConversions::NestedQualification)
5612 (RefConv & Sema::ReferenceConversions::ObjCLifetime) != 0;
5636 SetAsReferenceBinding(
true);
5685 SetAsReferenceBinding(S.
getLangOpts().CPlusPlus11 ||
5776 AllowedExplicit::None,
5801 if (isRValRef && LValRefType) {
5818static ImplicitConversionSequence
5820 bool SuppressUserConversions,
5821 bool InOverloadResolution,
5822 bool AllowObjCWritebackConversion,
5823 bool AllowExplicit =
false);
5827static ImplicitConversionSequence
5829 bool SuppressUserConversions,
5830 bool InOverloadResolution,
5831 bool AllowObjCWritebackConversion) {
5844 if (
const auto *IAT = dyn_cast<IncompleteArrayType>(AT))
5846 InitTy = IAT->getElementType();
5872 if (From->
hasOneInit() && !IsDesignatedInit) {
5878 SuppressUserConversions,
5879 InOverloadResolution,
5880 AllowObjCWritebackConversion);
5889 Result.Standard.setAsIdentityConversion();
5890 Result.Standard.setFromType(ToType);
5891 Result.Standard.setAllToTypes(ToType);
5916 bool IsUnbounded =
false;
5920 if (CT->getSize().ult(e)) {
5924 Result.setInitializerListContainerType(ContTy, IsUnbounded);
5927 if (CT->getSize().ugt(e)) {
5933 S, &EmptyList, InitTy, SuppressUserConversions,
5934 InOverloadResolution, AllowObjCWritebackConversion);
5935 if (DfltElt.
isBad()) {
5939 Result.setInitializerListContainerType(ContTy, IsUnbounded);
5950 Result.setInitializerListContainerType(ContTy, IsUnbounded);
5960 Result.Standard.setAsIdentityConversion();
5961 Result.Standard.setFromType(InitTy);
5962 Result.Standard.setAllToTypes(InitTy);
5967 S,
Init, InitTy, SuppressUserConversions, InOverloadResolution,
5968 AllowObjCWritebackConversion);
5979 Result.setInitializerListContainerType(ContTy, IsUnbounded);
5993 Result.setInitializerListContainerType(ContTy, IsUnbounded);
6007 AllowedExplicit::None,
6008 InOverloadResolution,
false,
6009 AllowObjCWritebackConversion,
6028 Result.UserDefined.Before.setAsIdentityConversion();
6033 Result.UserDefined.After.setAsIdentityConversion();
6034 Result.UserDefined.After.setFromType(ToType);
6035 Result.UserDefined.After.setAllToTypes(ToType);
6036 Result.UserDefined.ConversionFunction =
nullptr;
6053 if (From->
hasOneInit() && !IsDesignatedInit) {
6074 SuppressUserConversions,
6082 InOverloadResolution,
6083 AllowObjCWritebackConversion);
6086 assert(!
Result.isEllipsis() &&
6087 "Sub-initialization cannot result in ellipsis conversion.");
6093 Result.UserDefined.After;
6117 S, From->
getInit(0), ToType, SuppressUserConversions,
6118 InOverloadResolution, AllowObjCWritebackConversion);
6120 Result.Standard.FromBracedInitList =
true;
6126 Result.Standard.setAsIdentityConversion();
6127 Result.Standard.setFromType(ToType);
6128 Result.Standard.setAllToTypes(ToType);
6145static ImplicitConversionSequence
6147 bool SuppressUserConversions,
6148 bool InOverloadResolution,
6149 bool AllowObjCWritebackConversion,
6150 bool AllowExplicit) {
6151 if (
InitListExpr *FromInitList = dyn_cast<InitListExpr>(From))
6153 InOverloadResolution,AllowObjCWritebackConversion);
6158 SuppressUserConversions, AllowExplicit);
6161 SuppressUserConversions,
6162 AllowedExplicit::None,
6163 InOverloadResolution,
6165 AllowObjCWritebackConversion,
6178 return !ICS.
isBad();
6187 const CXXRecordDecl *ActingContext,
bool InOverloadResolution =
false,
6189 bool SuppressUserConversion =
false) {
6197 assert(FromClassification.
isLValue());
6208 if (Method->isExplicitObjectMemberFunction()) {
6209 if (ExplicitParameterType.isNull())
6210 ExplicitParameterType = Method->getFunctionObjectParameterReferenceType();
6212 ValueKindFromClassification(FromClassification));
6214 S, &TmpExpr, ExplicitParameterType, SuppressUserConversion,
6231 Qualifiers Quals = Method->getMethodQualifiers();
6269 FromType, ImplicitParamType);
6279 FromType, ImplicitParamType);
6292 }
else if (!Method->isExplicitObjectMemberFunction()) {
6294 FromType, ImplicitParamType);
6299 switch (Method->getRefQualifier()) {
6314 if (!FromClassification.
isRValue()) {
6336 = (Method->getRefQualifier() ==
RQ_None);
6347 QualType ImplicitParamRecordType =
Method->getFunctionObjectParameterType();
6363 From, Ty, Ty, TempEntity, From->
getBeginLoc(),
true);
6372 DestType =
Method->getThisType();
6375 FromRecordType = From->
getType();
6376 DestType = ImplicitParamRecordType;
6384 Method->getRefQualifier() !=
6402 <<
Method->getDeclName() << FromRecordType << (CVR - 1)
6404 Diag(
Method->getLocation(), diag::note_previous_decl)
6405 <<
Method->getDeclName();
6413 bool IsRValueQualified =
6417 << IsRValueQualified;
6418 Diag(
Method->getLocation(), diag::note_previous_decl)
6419 <<
Method->getDeclName();
6429 llvm_unreachable(
"Lists are not objects");
6432 return Diag(From->
getBeginLoc(), diag::err_member_function_call_bad_type)
6433 << ImplicitParamRecordType << FromRecordType
6442 From = FromRes.
get();
6451 CK = CK_AddressSpaceConversion;
6476 AllowedExplicit::Conversions,
6487 return AMDGPU().ExpandAMDGPUPredicateBuiltIn(From);
6561 llvm_unreachable(
"found a first conversion kind in Second");
6565 llvm_unreachable(
"found a third conversion kind in Second");
6571 llvm_unreachable(
"unknown conversion kind");
6581 [[maybe_unused]]
bool isCCEAllowedPreCXX11 =
6584 assert((S.
getLangOpts().CPlusPlus11 || isCCEAllowedPreCXX11) &&
6585 "converted constant expression outside C++11 or TTP matching");
6609 if (
T->isRecordType())
6618 diag::err_typecheck_converted_constant_expression)
6624 llvm_unreachable(
"bad conversion in converted constant expression");
6630 diag::err_typecheck_converted_constant_expression_disallowed)
6636 diag::err_typecheck_converted_constant_expression_indirect)
6646 diag::err_reference_bind_to_bitfield_in_cce)
6654 bool IsTemplateArgument =
6656 if (
T->isRecordType()) {
6657 assert(IsTemplateArgument &&
6658 "unexpected class type converted constant expr");
6674 IsTemplateArgument);
6681 bool ReturnPreNarrowingValue =
false;
6684 S.
Context,
Result.get(), PreNarrowingValue, PreNarrowingType,
6685 false, AllowRelaxedEval)) {
6695 PreNarrowingValue.
isInt()) {
6698 ReturnPreNarrowingValue =
true;
6724 << CCE << 0 << From->
getType() <<
T;
6729 if (!ReturnPreNarrowingValue)
6730 PreNarrowingValue = {};
6746 if (
Result.isInvalid() ||
Result.get()->isValueDependent()) {
6751 RequireInt, PreNarrowingValue);
6758 return ::BuildConvertedConstantExpression(*
this, From,
T, CCE, Dest,
6765 return ::CheckConvertedConstantExpression(*
this, From,
T,
Value, CCE,
false,
6770 llvm::APSInt &
Value,
6772 assert(
T->isIntegralOrEnumerationType() &&
"unexpected converted const type");
6777 if (!R.isInvalid() && !R.get()->isValueDependent())
6785 const APValue &PreNarrowingValue) {
6799 Kind = ConstantExprKind::ClassTemplateArgument;
6801 Kind = ConstantExprKind::NonClassTemplateArgument;
6803 Kind = ConstantExprKind::Normal;
6807 (RequireInt && !Eval.
Val.
isInt())) {
6816 if (Notes.empty() && !CantFold) {
6817 for (
auto &Info : MSWarning)
6818 Diag(Info.first, Info.second);
6821 if (
const auto *CE = dyn_cast<ConstantExpr>(E)) {
6825 "ConstantExpr has no value associated with it");
6831 Value = std::move(PreNarrowingValue);
6837 if (Notes.size() == 1 &&
6838 Notes[0].second.getDiagID() == diag::note_invalid_subexpr_in_const_expr) {
6839 Diag(Notes[0].first, diag::err_expr_not_cce) << CCE;
6840 }
else if (!Notes.empty() && Notes[0].second.getDiagID() ==
6841 diag::note_constexpr_invalid_template_arg) {
6842 Notes[0].second.setDiagID(diag::err_constexpr_invalid_template_arg);
6843 for (
unsigned I = 0; I < Notes.size(); ++I)
6844 Diag(Notes[I].first, Notes[I].second);
6848 for (
unsigned I = 0; I < Notes.size(); ++I)
6849 Diag(Notes[I].first, Notes[I].second);
6868static ImplicitConversionSequence
6876 AllowedExplicit::Conversions,
6918 "expected a member expression");
6920 if (
const auto M = dyn_cast<UnresolvedMemberExpr>(MemExprE);
6921 M && !M->isImplicitAccess())
6922 Base = M->getBase();
6923 else if (
const auto M = dyn_cast<MemberExpr>(MemExprE);
6924 M && !M->isImplicitAccess())
6925 Base = M->getBase();
6929 if (
T->isPointerType())
6930 T =
T->getPointeeType();
6958 assert(Method->isExplicitObjectMemberFunction() &&
6959 "Method is not an explicit member function");
6960 assert(NewArgs.empty() &&
"NewArgs should be empty");
6962 NewArgs.reserve(Args.size() + 1);
6964 NewArgs.push_back(
This);
6965 NewArgs.append(Args.begin(), Args.end());
6968 Method,
Object->getBeginLoc());
6974 return AllowScopedEnumerations ?
T->isIntegralOrEnumerationType()
6975 :
T->isIntegralOrUnscopedEnumerationType();
6987 for (
unsigned I = 0, N = ViableConversions.
size(); I != N; ++I) {
7001 if (ExplicitConversions.
size() == 1 && !Converter.
Suppress) {
7009 std::string TypeStr;
7014 "static_cast<" + TypeStr +
">(")
7026 HadMultipleCandidates);
7033 From,
Result.get()->getType());
7059 HadMultipleCandidates);
7064 CK_UserDefinedConversion,
Result.get(),
7065 nullptr,
Result.get()->getValueKind(),
7090 if (
auto *ConvTemplate = dyn_cast<FunctionTemplateDecl>(D)) {
7092 ConvTemplate, FoundDecl, ActingContext, From, ToType, CandidateSet,
7098 Conv, FoundDecl, ActingContext, From, ToType, CandidateSet,
7132 From = result.
get();
7138 From = Converted.
isUsable() ? Converted.
get() :
nullptr;
7147 const RecordType *RecordTy =
T->getAsCanonical<RecordType>();
7160 : Converter(Converter), From(From) {}
7165 } IncompleteDiagnoser(Converter, From);
7176 ->getDefinitionOrSelf()
7177 ->getVisibleConversionFunctions();
7179 bool HadMultipleCandidates =
7184 bool HasUniqueTargetType =
true;
7200 "Conversion operator templates are considered potentially "
7204 if (Converter.
match(CurToType) || ConvTemplate) {
7210 ExplicitConversions.
addDecl(I.getDecl(), I.getAccess());
7215 else if (HasUniqueTargetType &&
7217 HasUniqueTargetType =
false;
7219 ViableConversions.
addDecl(I.getDecl(), I.getAccess());
7237 HadMultipleCandidates,
7238 ExplicitConversions))
7244 if (!HasUniqueTargetType)
7263 HadMultipleCandidates,
Found))
7272 HadMultipleCandidates,
7273 ExplicitConversions))
7281 switch (ViableConversions.
size()) {
7284 HadMultipleCandidates,
7285 ExplicitConversions))
7295 HadMultipleCandidates,
Found))
7326 if (Proto->getNumParams() < 1)
7330 QualType ArgType = Proto->getParamType(0).getNonReferenceType();
7331 if (Context.hasSameUnqualifiedType(T1, ArgType))
7335 if (Proto->getNumParams() < 2)
7339 QualType ArgType = Proto->getParamType(1).getNonReferenceType();
7340 if (Context.hasSameUnqualifiedType(T2, ArgType))
7359 unsigned SeenAt = 0;
7361 bool HasDefault =
false;
7370 return HasDefault || SeenAt != 0;
7376 bool PartialOverloading,
bool AllowExplicit,
bool AllowExplicitConversions,
7379 bool StrictPackMatch) {
7382 assert(Proto &&
"Functions without a prototype cannot be overloaded");
7383 assert(!
Function->getDescribedFunctionTemplate() &&
7384 "Use AddTemplateOverloadCandidate for function templates");
7397 CandidateSet, SuppressUserConversions,
7398 PartialOverloading, EarlyConversions, PO,
7434 CandidateSet.
addCandidate(Args.size(), EarlyConversions);
7448 Candidate.
Viable =
false;
7461 bool IsImplicitlyInstantiated =
false;
7462 if (
auto *SpecInfo =
Function->getTemplateSpecializationInfo()) {
7463 ND = SpecInfo->getTemplate();
7464 IsImplicitlyInstantiated = SpecInfo->getTemplateSpecializationKind() ==
7475 const bool IsInlineFunctionInGMF =
7477 (IsImplicitlyInstantiated ||
Function->isInlined());
7482 const bool IsCurrentUnitGMFDecl =
7483 Function->isFromGlobalModule() && CurrentModule &&
7484 Function->getOwningModule()->getTopLevelModule() ==
7488 !IsCurrentUnitGMFDecl) {
7489 Candidate.
Viable =
false;
7496 Candidate.
Viable =
false;
7507 if (Args.size() == 1 &&
Constructor->isSpecializationCopyingObject() &&
7508 (
Context.hasSameUnqualifiedType(ClassType, Args[0]->getType()) ||
7511 Candidate.
Viable =
false;
7523 auto *Shadow = dyn_cast<ConstructorUsingShadowDecl>(FoundDecl.
getDecl());
7524 if (Shadow && Args.size() == 1 &&
Constructor->getNumParams() >= 1 &&
7525 Constructor->getParamDecl(0)->getType()->isReferenceType()) {
7532 Candidate.
Viable =
false;
7541 Constructor->getMethodQualifiers().getAddressSpace(),
7543 Candidate.
Viable =
false;
7556 Candidate.
Viable =
false;
7566 unsigned MinRequiredArgs =
Function->getMinRequiredArguments();
7567 if (!AggregateCandidateDeduction && Args.size() < MinRequiredArgs &&
7568 !PartialOverloading) {
7570 Candidate.
Viable =
false;
7584 Candidate.
Viable =
false;
7590 if (
Function->getTrailingRequiresClause()) {
7595 Candidate.
Viable =
false;
7604 for (
unsigned ArgIdx = 0; ArgIdx < Args.size(); ++ArgIdx) {
7607 if (Candidate.
Conversions[ConvIdx].isInitialized()) {
7610 }
else if (ArgIdx < NumParams) {
7621 Args[ArgIdx]->
getType().getAddressSpace() ==
7623 Diag(Args[ArgIdx]->getBeginLoc(), diag::warn_hlsl_groupshared_inout);
7626 *
this, Args[ArgIdx], ParamType, SuppressUserConversions,
7629 getLangOpts().ObjCAutoRefCount, AllowExplicitConversions);
7631 Candidate.
Viable =
false;
7643 if (EnableIfAttr *FailedAttr =
7645 Candidate.
Viable =
false;
7655 if (Methods.size() <= 1)
7658 for (
unsigned b = 0, e = Methods.size(); b < e; b++) {
7664 if (
Method->param_size() > NumNamedArgs)
7665 NumNamedArgs =
Method->param_size();
7666 if (Args.size() < NumNamedArgs)
7669 for (
unsigned i = 0; i < NumNamedArgs; i++) {
7671 if (Args[i]->isTypeDependent()) {
7677 Expr *argExpr = Args[i];
7678 assert(argExpr &&
"SelectBestMethod(): missing expression");
7683 !param->
hasAttr<CFConsumedAttr>())
7684 argExpr =
ObjC().stripARCUnbridgedCast(argExpr);
7701 if (ConversionState.
isBad() ||
7711 for (
unsigned i = NumNamedArgs, e = Args.size(); i < e; ++i) {
7712 if (Args[i]->isTypeDependent()) {
7725 if (Args.size() != NumNamedArgs)
7727 else if (
Match && NumNamedArgs == 0 && Methods.size() > 1) {
7730 for (
unsigned b = 0, e = Methods.size(); b < e; b++) {
7731 QualType ReturnT = Methods[b]->getReturnType();
7751 "Shouldn't have `this` for ctors!");
7752 assert(!Method->isStatic() &&
"Shouldn't have `this` for static methods!");
7754 ThisArg, std::nullopt, Method, Method);
7757 ConvertedThis = R.get();
7759 if (
auto *MD = dyn_cast<CXXMethodDecl>(Function)) {
7761 assert((MissingImplicitThis || MD->isStatic() ||
7763 "Expected `this` for non-ctor instance methods");
7765 ConvertedThis =
nullptr;
7770 unsigned ArgSizeNoVarargs = std::min(Function->param_size(), Args.size());
7773 for (
unsigned I = 0; I != ArgSizeNoVarargs; ++I) {
7776 S.
Context, Function->getParamDecl(I)),
7782 ConvertedArgs.push_back(R.get());
7789 if (!Function->isVariadic() && Args.size() < Function->getNumParams()) {
7790 for (
unsigned i = Args.size(), e = Function->getNumParams(); i != e; ++i) {
7797 ConvertedArgs.push_back(R.get());
7809 bool MissingImplicitThis) {
7810 auto EnableIfAttrs =
Function->specific_attrs<EnableIfAttr>();
7811 if (EnableIfAttrs.begin() == EnableIfAttrs.end())
7817 llvm::scope_exit UndelayDiags(
7819 DelayedDiagnostics.popUndelayed(CurrentState);
7823 Expr *DiscardedThis;
7825 *
this,
Function,
nullptr, CallLoc, Args, Trap,
7826 true, DiscardedThis, ConvertedArgs))
7827 return *EnableIfAttrs.begin();
7829 for (
auto *EIA : EnableIfAttrs) {
7833 if (EIA->getCond()->isValueDependent() ||
7834 !EIA->getCond()->EvaluateWithSubstitution(
7838 if (!
Result.isInt() || !
Result.getInt().getBoolValue())
7844template <
typename CheckFn>
7847 CheckFn &&IsSuccessful) {
7850 if (ArgDependent == DIA->getArgDependent())
7851 Attrs.push_back(DIA);
7858 auto WarningBegin = std::stable_partition(
7859 Attrs.begin(), Attrs.end(), [](
const DiagnoseIfAttr *DIA) {
7860 return DIA->getDefaultSeverity() == DiagnoseIfAttr::DS_error &&
7861 DIA->getWarningGroup().empty();
7866 auto ErrAttr = llvm::find_if(llvm::make_range(Attrs.begin(), WarningBegin),
7868 if (ErrAttr != WarningBegin) {
7869 const DiagnoseIfAttr *DIA = *ErrAttr;
7870 S.
Diag(Loc, diag::err_diagnose_if_succeeded) << DIA->getMessage();
7871 S.
Diag(DIA->getLocation(), diag::note_from_diagnose_if)
7872 << DIA->getParent() << DIA->getCond()->getSourceRange();
7876 auto ToSeverity = [](DiagnoseIfAttr::DefaultSeverity Sev) {
7878 case DiagnoseIfAttr::DS_warning:
7880 case DiagnoseIfAttr::DS_error:
7883 llvm_unreachable(
"Fully covered switch above!");
7886 for (
const auto *DIA : llvm::make_range(WarningBegin, Attrs.end()))
7887 if (IsSuccessful(DIA)) {
7888 if (DIA->getWarningGroup().empty() &&
7889 DIA->getDefaultSeverity() == DiagnoseIfAttr::DS_warning) {
7890 S.
Diag(Loc, diag::warn_diagnose_if_succeeded) << DIA->getMessage();
7891 S.
Diag(DIA->getLocation(), diag::note_from_diagnose_if)
7892 << DIA->getParent() << DIA->getCond()->getSourceRange();
7895 DIA->getWarningGroup());
7898 {ToSeverity(DIA->getDefaultSeverity()),
"%0",
7900 S.
Diag(Loc, DiagID) << DIA->getMessage();
7908 const Expr *ThisArg,
7913 [&](
const DiagnoseIfAttr *DIA) {
7918 if (!DIA->getCond()->EvaluateWithSubstitution(
7921 return Result.isInt() &&
Result.getInt().getBoolValue();
7928 *
this, ND,
false, Loc,
7929 [&](
const DiagnoseIfAttr *DIA) {
7931 return DIA->getCond()->EvaluateAsBooleanCondition(
Result,
Context) &&
7940 bool SuppressUserConversions,
7941 bool PartialOverloading,
7942 bool FirstArgumentIsBase) {
7954 if (Args.size() > 0) {
7955 if (
Expr *E = Args[0]) {
7965 FunctionArgs = Args.slice(1);
7969 FunTmpl, F.getPair(),
7971 ExplicitTemplateArgs, ObjectType, ObjectClassification,
7972 FunctionArgs, CandidateSet, SuppressUserConversions,
7973 PartialOverloading);
7977 ObjectClassification, FunctionArgs, CandidateSet,
7978 SuppressUserConversions, PartialOverloading);
7985 if (Args.size() > 0 &&
7989 FunctionArgs = Args.slice(1);
7993 ExplicitTemplateArgs, FunctionArgs,
7994 CandidateSet, SuppressUserConversions,
7995 PartialOverloading);
7998 SuppressUserConversions, PartialOverloading);
8008 bool SuppressUserConversions,
8018 "Expected a member function template");
8020 nullptr, ObjectType,
8021 ObjectClassification, Args, CandidateSet,
8022 SuppressUserConversions,
false, PO);
8025 ObjectType, ObjectClassification, Args, CandidateSet,
8026 SuppressUserConversions,
false, {}, PO);
8039 assert(Proto &&
"Methods without a prototype cannot be overloaded");
8041 "Use AddOverloadCandidate for constructors");
8050 Method->isMoveAssignmentOperator())
8057 bool IgnoreExplicitObject =
8058 (
Method->isExplicitObjectMemberFunction() &&
8061 bool ImplicitObjectMethodTreatedAsStatic =
8064 Method->isImplicitObjectMemberFunction();
8066 unsigned ExplicitOffset =
8067 !IgnoreExplicitObject &&
Method->isExplicitObjectMemberFunction() ? 1 : 0;
8069 unsigned NumParams =
Method->getNumParams() - ExplicitOffset +
8070 int(ImplicitObjectMethodTreatedAsStatic);
8072 unsigned ExtraArgs =
8079 CandidateSet.
addCandidate(Args.size() + ExtraArgs, EarlyConversions);
8095 Candidate.
Viable =
false;
8105 unsigned MinRequiredArgs =
Method->getMinRequiredArguments() -
8107 int(ImplicitObjectMethodTreatedAsStatic);
8109 if (Args.size() < MinRequiredArgs && !PartialOverloading) {
8111 Candidate.
Viable =
false;
8119 if (!IgnoreExplicitObject) {
8122 else if (
Method->isStatic()) {
8132 Candidate.
Conversions[FirstConvIdx].setStaticObjectArgument();
8137 *
this, CandidateSet.
getLocation(), ObjectType, ObjectClassification,
8138 Method, ActingContext,
true);
8139 if (Candidate.
Conversions[FirstConvIdx].isBad()) {
8140 Candidate.
Viable =
false;
8151 Candidate.
Viable =
false;
8156 if (
Method->getTrailingRequiresClause()) {
8161 Candidate.
Viable =
false;
8169 for (
unsigned ArgIdx = 0; ArgIdx < Args.size(); ++ArgIdx) {
8172 if (Candidate.
Conversions[ConvIdx].isInitialized()) {
8175 }
else if (ArgIdx < NumParams) {
8181 if (ImplicitObjectMethodTreatedAsStatic) {
8182 ParamType = ArgIdx == 0
8183 ?
Method->getFunctionObjectParameterReferenceType()
8186 ParamType = Proto->
getParamType(ArgIdx + ExplicitOffset);
8190 SuppressUserConversions,
8195 Candidate.
Viable =
false;
8207 if (EnableIfAttr *FailedAttr =
8209 Candidate.
Viable =
false;
8216 Candidate.
Viable =
false;
8227 bool SuppressUserConversions,
bool PartialOverloading,
8245 PartialOverloading,
false,
8246 false, ObjectType, ObjectClassification,
8250 bool OnlyInitializeNonUserDefinedConversions) {
8251 return S.CheckNonDependentConversions(
8252 MethodTmpl, ParamTypes, Args, CandidateSet, Conversions,
8253 Sema::CheckNonDependentConversionsFlag(
8254 SuppressUserConversions,
8255 OnlyInitializeNonUserDefinedConversions),
8256 ActingContext, ObjectType, ObjectClassification, PO);
8260 CandidateSet.
addCandidate(Conversions.size(), Conversions);
8263 Candidate.
Viable =
false;
8272 Method->isStatic() ||
8273 (!Method->isExplicitObjectMemberFunction() && ObjectType.
isNull());
8287 assert(
Specialization &&
"Missing member function template specialization?");
8289 "Specialization is not a member function?");
8292 ObjectClassification, Args, CandidateSet, SuppressUserConversions,
8306 if (ExplicitTemplateArgs ||
8309 *
this, CandidateSet, MethodTmpl, FoundDecl, ActingContext,
8310 ExplicitTemplateArgs, ObjectType, ObjectClassification, Args,
8311 SuppressUserConversions, PartialOverloading, PO);
8316 MethodTmpl, FoundDecl, ActingContext, ObjectType, ObjectClassification,
8317 Args, SuppressUserConversions, PartialOverloading, PO);
8335 bool SuppressUserConversions,
bool PartialOverloading,
bool AllowExplicit,
8337 bool AggregateCandidateDeduction) {
8346 Candidate.
Viable =
false;
8366 PartialOverloading, AggregateCandidateDeduction,
8373 bool OnlyInitializeNonUserDefinedConversions) {
8374 return S.CheckNonDependentConversions(
8375 FunctionTemplate, ParamTypes, Args, CandidateSet, Conversions,
8376 Sema::CheckNonDependentConversionsFlag(
8377 SuppressUserConversions,
8378 OnlyInitializeNonUserDefinedConversions),
8379 nullptr, QualType(), {}, PO);
8382 OverloadCandidate &Candidate =
8383 CandidateSet.addCandidate(Conversions.size(), Conversions);
8386 Candidate.
Viable =
false;
8388 CandidateSet.getRewriteInfo().getRewriteKind(Candidate.
Function, PO);
8394 CandidateSet.getKind() ==
8400 ->isExplicitObjectMemberFunction() &&
8416 assert(
Specialization &&
"Missing function template specialization?");
8418 Specialization, FoundDecl, Args, CandidateSet, SuppressUserConversions,
8419 PartialOverloading, AllowExplicit,
8420 false, IsADLCandidate, Conversions, PO,
8421 Info.AggregateDeductionCandidateHasMismatchedArity,
8422 Info.hasStrictPackMatch());
8429 bool PartialOverloading,
bool AllowExplicit,
ADLCallKind IsADLCandidate,
8436 if (ExplicitTemplateArgs ||
8439 DependentExplicitSpecifier)) {
8443 Args, SuppressUserConversions, PartialOverloading, AllowExplicit,
8444 IsADLCandidate, PO, AggregateCandidateDeduction);
8446 if (DependentExplicitSpecifier)
8453 PartialOverloading, AllowExplicit, IsADLCandidate, PO,
8454 AggregateCandidateDeduction);
8467 const bool AllowExplicit =
false;
8469 bool ForOverloadSetAddressResolution =
8472 auto *
Method = dyn_cast<CXXMethodDecl>(FD);
8473 bool HasThisConversion = !ForOverloadSetAddressResolution &&
Method &&
8475 unsigned ThisConversions = HasThisConversion ? 1 : 0;
8491 if (!FD->hasCXXExplicitFunctionObjectParameter() ||
8492 !ParamTypes[0]->isDependentType()) {
8494 *
this, CandidateSet.
getLocation(), ObjectType, ObjectClassification,
8495 Method, ActingContext,
true,
8496 FD->hasCXXExplicitFunctionObjectParameter() ? ParamTypes[0]
8506 auto MaybeInvolveUserDefinedConversion = [&](
QualType ParamType,
8530 if (
auto *RD =
ArgType->getAsCXXRecordDecl();
8531 RD && RD->hasDefinition() &&
8532 !RD->getVisibleConversionFunctions().empty())
8539 HasThisConversion &&
Method->hasCXXExplicitFunctionObjectParameter() ? 1
8542 for (
unsigned I = 0, N = std::min(ParamTypes.size() - Offset, Args.size());
8544 QualType ParamType = ParamTypes[I + Offset];
8548 ConvIdx = Args.size() - 1 - I;
8549 assert(Args.size() + ThisConversions == 2 &&
8550 "number of args (including 'this') must be exactly 2 for "
8554 assert(!HasThisConversion || (ConvIdx == 0 && I == 0));
8557 ConvIdx = ThisConversions + I;
8562 MaybeInvolveUserDefinedConversion(ParamType, Args[I]->
getType()))
8591 bool AllowObjCPointerConversion) {
8599 bool ObjCLifetimeConversion;
8601 ObjCLifetimeConversion))
8606 if (!AllowObjCPointerConversion)
8610 bool IncompatibleObjC =
false;
8620 bool AllowExplicit,
bool AllowResultConversion,
bool StrictPackMatch) {
8622 "Conversion function templates use AddTemplateConversionCandidate");
8637 if (!AllowResultConversion &&
8649 AllowObjCConversionOnExplicit))
8671 if (!AllowExplicit && Conversion->
isExplicit()) {
8672 Candidate.
Viable =
false;
8699 Candidate.
Viable =
false;
8708 Candidate.
Viable =
false;
8719 QualType ToCanon =
Context.getCanonicalType(ToType).getUnqualifiedType();
8720 if (FromCanon == ToCanon ||
8722 Candidate.
Viable =
false;
8739 CK_FunctionToPointerDecay, &ConversionRef,
8744 Candidate.
Viable =
false;
8774 Candidate.
Viable =
false;
8786 Candidate.
Viable =
false;
8793 Candidate.
Viable =
false;
8799 "Can only end up with a standard conversion sequence or failure");
8802 if (EnableIfAttr *FailedAttr =
8804 Candidate.
Viable =
false;
8811 Candidate.
Viable =
false;
8820 bool AllowObjCConversionOnExplicit,
bool AllowExplicit,
8821 bool AllowResultConversion) {
8830 Candidate.
Viable =
false;
8847 Candidate.
Viable =
false;
8857 assert(
Specialization &&
"Missing function template specialization?");
8859 ToType, CandidateSet, AllowObjCConversionOnExplicit,
8860 AllowExplicit, AllowResultConversion,
8868 bool AllowExplicit,
bool AllowResultConversion) {
8870 "Only conversion function templates permitted here");
8881 ToType, AllowObjCConversionOnExplicit, AllowExplicit,
8882 AllowResultConversion);
8890 AllowObjCConversionOnExplicit, AllowExplicit, AllowResultConversion);
8929 if (ObjectInit.
isBad()) {
8930 Candidate.
Viable =
false;
8941 Candidate.
Conversions[0].UserDefined.EllipsisConversion =
false;
8942 Candidate.
Conversions[0].UserDefined.HadMultipleCandidates =
false;
8943 Candidate.
Conversions[0].UserDefined.ConversionFunction = Conversion;
8944 Candidate.
Conversions[0].UserDefined.FoundConversionFunction = FoundDecl;
8947 Candidate.
Conversions[0].UserDefined.After.setAsIdentityConversion();
8955 if (Args.size() > NumParams && !Proto->
isVariadic()) {
8956 Candidate.
Viable =
false;
8963 if (Args.size() < NumParams) {
8965 Candidate.
Viable =
false;
8972 for (
unsigned ArgIdx = 0, N = Args.size(); ArgIdx != N; ++ArgIdx) {
8973 if (ArgIdx < NumParams) {
8986 Candidate.
Viable =
false;
9003 Candidate.
Viable =
false;
9009 if (EnableIfAttr *FailedAttr =
9011 Candidate.
Viable =
false;
9035 "unqualified operator lookup found a member function");
9039 FunctionArgs, CandidateSet);
9045 FunctionArgs[1], FunctionArgs[0]);
9047 Reversed, CandidateSet,
false,
false,
true,
9048 ADLCallKind::NotADL,
9052 if (ExplicitTemplateArgs)
9057 {FunctionArgs[1], FunctionArgs[0]}, CandidateSet,
9058 false,
false,
true,
false, ADLCallKind::NotADL, {},
9090 if (!T1RD || (!IsComplete && !T1RD->isBeingDefined()))
9098 OperEnd = Operators.
end();
9099 Oper != OperEnd; ++Oper) {
9100 if (Oper->getAsFunction() &&
9103 *
this, {Args[1], Args[0]}, Oper->getAsFunction()))
9106 Args[0]->Classify(
Context), Args.slice(1),
9107 CandidateSet,
false, PO);
9114 bool IsAssignmentOperator,
9115 unsigned NumContextualBoolArguments) {
9130 for (
unsigned ArgIdx = 0, N = Args.size(); ArgIdx != N; ++ArgIdx) {
9143 if (ArgIdx < NumContextualBoolArguments) {
9144 assert(ParamTys[ArgIdx] ==
Context.BoolTy &&
9145 "Contextual conversion to bool requires bool type");
9151 ArgIdx == 0 && IsAssignmentOperator,
9157 Candidate.
Viable =
false;
9170class BuiltinCandidateTypeSet {
9176 TypeSet PointerTypes;
9180 TypeSet MemberPointerTypes;
9184 TypeSet EnumerationTypes;
9188 TypeSet VectorTypes;
9192 TypeSet MatrixTypes;
9195 TypeSet BitIntTypes;
9198 bool HasNonRecordTypes;
9202 bool HasArithmeticOrEnumeralTypes;
9208 bool MayConvertToArithmetic;
9212 bool HasNullPtrType;
9216 bool HasReflectionType;
9225 bool AddPointerWithMoreQualifiedTypeVariants(
QualType Ty,
9227 bool AddMemberPointerWithMoreQualifiedTypeVariants(
QualType Ty);
9231 typedef TypeSet::iterator
iterator;
9233 BuiltinCandidateTypeSet(
Sema &SemaRef)
9234 : HasNonRecordTypes(
false), HasArithmeticOrEnumeralTypes(
false),
9235 MayConvertToArithmetic(
false), HasNullPtrType(
false),
9236 HasReflectionType(
false), SemaRef(SemaRef), Context(SemaRef.Context) {}
9238 void AddTypesConvertedFrom(
QualType Ty,
9240 bool AllowUserConversions,
9241 bool AllowExplicitConversions,
9242 const Qualifiers &VisibleTypeConversionsQuals);
9244 llvm::iterator_range<iterator> pointer_types() {
return PointerTypes; }
9245 llvm::iterator_range<iterator> member_pointer_types() {
9246 return MemberPointerTypes;
9248 llvm::iterator_range<iterator> enumeration_types() {
9249 return EnumerationTypes;
9251 llvm::iterator_range<iterator> vector_types() {
return VectorTypes; }
9252 llvm::iterator_range<iterator> matrix_types() {
return MatrixTypes; }
9253 llvm::iterator_range<iterator> bitint_types() {
return BitIntTypes; }
9255 bool containsMatrixType(QualType Ty)
const {
return MatrixTypes.count(Ty); }
9256 bool hasNonRecordTypes() {
return HasNonRecordTypes; }
9257 bool hasArithmeticOrEnumeralTypes() {
return HasArithmeticOrEnumeralTypes; }
9258 bool mayConvertToArithmetic()
const {
return MayConvertToArithmetic; }
9259 bool hasNullPtrType()
const {
return HasNullPtrType; }
9260 bool hasReflectionType()
const {
return HasReflectionType; }
9275BuiltinCandidateTypeSet::AddPointerWithMoreQualifiedTypeVariants(QualType Ty,
9276 const Qualifiers &VisibleQuals) {
9279 if (!PointerTypes.insert(Ty))
9283 const PointerType *PointerTy = Ty->
getAs<PointerType>();
9284 bool buildObjCPtr =
false;
9286 const ObjCObjectPointerType *PTy = Ty->
castAs<ObjCObjectPointerType>();
9288 buildObjCPtr =
true;
9300 unsigned BaseCVR = PointeeTy.getCVRQualifiers();
9306 if ((CVR | BaseCVR) != CVR)
continue;
9321 QualType QPointerTy;
9328 PointerTypes.insert(QPointerTy);
9344BuiltinCandidateTypeSet::AddMemberPointerWithMoreQualifiedTypeVariants(
9347 if (!MemberPointerTypes.insert(Ty))
9350 const MemberPointerType *PointerTy = Ty->
getAs<MemberPointerType>();
9351 assert(PointerTy &&
"type was not a member pointer type!");
9366 if ((CVR | BaseCVR) != CVR)
continue;
9370 QPointeeTy, std::nullopt, Cls));
9385BuiltinCandidateTypeSet::AddTypesConvertedFrom(QualType Ty,
9387 bool AllowUserConversions,
9388 bool AllowExplicitConversions,
9389 const Qualifiers &VisibleQuals) {
9395 if (
const ReferenceType *RefTy = Ty->
getAs<ReferenceType>())
9400 Ty = SemaRef.Context.getArrayDecayedType(Ty);
9407 HasNonRecordTypes = HasNonRecordTypes || !TyIsRec;
9410 HasArithmeticOrEnumeralTypes =
9415 MayConvertToArithmetic =
9416 MayConvertToArithmetic ||
9421 PointerTypes.insert(Ty);
9422 else if (Ty->
getAs<PointerType>() || Ty->
getAs<ObjCObjectPointerType>()) {
9425 if (!AddPointerWithMoreQualifiedTypeVariants(Ty, VisibleQuals))
9429 if (!AddMemberPointerWithMoreQualifiedTypeVariants(Ty))
9432 HasArithmeticOrEnumeralTypes =
true;
9433 EnumerationTypes.insert(Ty);
9435 HasArithmeticOrEnumeralTypes =
true;
9436 BitIntTypes.insert(Ty);
9440 HasArithmeticOrEnumeralTypes =
true;
9441 VectorTypes.insert(Ty);
9445 HasArithmeticOrEnumeralTypes =
true;
9446 MatrixTypes.insert(Ty);
9448 HasNullPtrType =
true;
9450 HasReflectionType =
true;
9451 }
else if (AllowUserConversions && TyIsRec) {
9453 if (!SemaRef.isCompleteType(Loc, Ty))
9457 for (NamedDecl *D : ClassDecl->getVisibleConversionFunctions()) {
9464 MayConvertToArithmetic =
true;
9469 if (AllowExplicitConversions || !Conv->
isExplicit()) {
9517 ClassDecl = RHSMPType->getMostRecentCXXRecordDecl();
9565 if (Available.hasAtomic()) {
9566 Available.removeAtomic();
9573 if (Available.hasVolatile()) {
9574 Available.removeVolatile();
9608class BuiltinOperatorOverloadBuilder {
9611 ArrayRef<Expr *> Args;
9612 QualifiersAndAtomic VisibleTypeConversionsQuals;
9616 bool ArithmeticCandidatesMayBeViable;
9617 SmallVectorImpl<BuiltinCandidateTypeSet> &CandidateTypes;
9618 OverloadCandidateSet &CandidateSet;
9620 static constexpr int ArithmeticTypesCap = 26;
9621 SmallVector<CanQualType, ArithmeticTypesCap> ArithmeticTypes;
9626 unsigned FirstIntegralType,
9628 unsigned FirstPromotedIntegralType,
9629 LastPromotedIntegralType;
9630 unsigned FirstPromotedArithmeticType,
9631 LastPromotedArithmeticType;
9632 unsigned NumArithmeticTypes;
9634 void InitArithmeticTypes() {
9636 FirstPromotedArithmeticType = 0;
9646 FirstIntegralType = ArithmeticTypes.size();
9647 FirstPromotedIntegralType = ArithmeticTypes.size();
9669 llvm::SmallSetVector<CanQualType, 2> BitIntCandidates;
9670 for (BuiltinCandidateTypeSet &Candidate : CandidateTypes) {
9671 for (QualType BitTy : Candidate.bitint_types())
9674 llvm::move(BitIntCandidates, std::back_inserter(ArithmeticTypes));
9675 LastPromotedIntegralType = ArithmeticTypes.size();
9676 LastPromotedArithmeticType = ArithmeticTypes.size();
9690 LastIntegralType = ArithmeticTypes.size();
9691 NumArithmeticTypes = ArithmeticTypes.size();
9698 assert(ArithmeticTypes.size() - BitIntCandidates.size() <=
9699 ArithmeticTypesCap &&
9700 "Enough inline storage for all arithmetic types.");
9705 void addPlusPlusMinusMinusStyleOverloads(QualType CandidateTy,
9708 QualType ParamTypes[2] = {
9748 void AddCandidate(QualType L, QualType R) {
9749 QualType LandR[2] = {L,
R};
9754 BuiltinOperatorOverloadBuilder(
9755 Sema &S, ArrayRef<Expr *> Args,
9756 QualifiersAndAtomic VisibleTypeConversionsQuals,
9757 bool HasArithmeticOrEnumeralCandidateType,
9758 SmallVectorImpl<BuiltinCandidateTypeSet> &CandidateTypes,
9759 OverloadCandidateSet &CandidateSet)
9761 VisibleTypeConversionsQuals(VisibleTypeConversionsQuals),
9762 ArithmeticCandidatesMayBeViable(
9763 HasArithmeticOrEnumeralCandidateType &&
9764 llvm::all_of(CandidateTypes,
9765 [](const BuiltinCandidateTypeSet &Types) {
9766 return Types.mayConvertToArithmetic();
9768 CandidateTypes(CandidateTypes), CandidateSet(CandidateSet) {
9769 InitArithmeticTypes();
9792 if (!ArithmeticCandidatesMayBeViable)
9795 for (
unsigned Arith = 0; Arith < NumArithmeticTypes; ++Arith) {
9796 const auto TypeOfT = ArithmeticTypes[Arith];
9798 if (Op == OO_MinusMinus)
9800 if (Op == OO_PlusPlus && S.
getLangOpts().CPlusPlus17)
9803 addPlusPlusMinusMinusStyleOverloads(
9820 void addPlusPlusMinusMinusPointerOverloads() {
9821 for (QualType PtrTy : CandidateTypes[0].pointer_types()) {
9823 if (!PtrTy->getPointeeType()->isObjectType())
9826 addPlusPlusMinusMinusStyleOverloads(
9828 (!PtrTy.isVolatileQualified() &&
9830 (!PtrTy.isRestrictQualified() &&
9845 void addUnaryStarPointerOverloads() {
9846 for (QualType ParamTy : CandidateTypes[0].pointer_types()) {
9851 if (
const FunctionProtoType *Proto =PointeeTy->
getAs<FunctionProtoType>())
9852 if (Proto->getMethodQuals() || Proto->getRefQualifier())
9865 void addUnaryPlusOrMinusArithmeticOverloads() {
9866 if (!ArithmeticCandidatesMayBeViable)
9869 for (
unsigned Arith = FirstPromotedArithmeticType;
9870 Arith < LastPromotedArithmeticType; ++Arith) {
9871 QualType ArithTy = ArithmeticTypes[Arith];
9876 for (QualType VecTy : CandidateTypes[0].vector_types())
9885 void addUnaryPlusPointerOverloads() {
9886 for (QualType ParamTy : CandidateTypes[0].pointer_types())
9895 void addUnaryTildePromotedIntegralOverloads() {
9896 if (!ArithmeticCandidatesMayBeViable)
9899 for (
unsigned Int = FirstPromotedIntegralType;
9900 Int < LastPromotedIntegralType; ++
Int) {
9901 QualType IntTy = ArithmeticTypes[
Int];
9906 for (QualType VecTy : CandidateTypes[0].vector_types())
9916 void addEqualEqualOrNotEqualMemberPointerOrNullptrOverloads() {
9918 llvm::SmallPtrSet<QualType, 8> AddedTypes;
9920 for (
unsigned ArgIdx = 0, N = Args.size(); ArgIdx != N; ++ArgIdx) {
9921 for (QualType MemPtrTy : CandidateTypes[ArgIdx].member_pointer_types()) {
9926 QualType ParamTypes[2] = {MemPtrTy, MemPtrTy};
9930 if (CandidateTypes[ArgIdx].hasNullPtrType()) {
9932 if (AddedTypes.insert(NullPtrTy).second) {
9933 QualType ParamTypes[2] = { NullPtrTy, NullPtrTy };
9938 if (CandidateTypes[ArgIdx].hasReflectionType()) {
9940 if (AddedTypes.insert(MetaInfoTy).second) {
9941 QualType ParamTypes[2] = {MetaInfoTy, MetaInfoTy};
9960 void addGenericBinaryPointerOrEnumeralOverloads(
bool IsSpaceship) {
9973 llvm::DenseSet<std::pair<CanQualType, CanQualType> >
9974 UserDefinedBinaryOperators;
9976 for (
unsigned ArgIdx = 0, N = Args.size(); ArgIdx != N; ++ArgIdx) {
9977 if (!CandidateTypes[ArgIdx].enumeration_types().empty()) {
9979 CEnd = CandidateSet.
end();
9981 if (!
C->Viable || !
C->Function ||
C->Function->getNumParams() != 2)
9984 if (
C->Function->isFunctionTemplateSpecialization())
9991 QualType FirstParamType =
C->Function->getParamDecl(
Reversed ? 1 : 0)
9993 .getUnqualifiedType();
9994 QualType SecondParamType =
C->Function->getParamDecl(
Reversed ? 0 : 1)
9996 .getUnqualifiedType();
10004 UserDefinedBinaryOperators.insert(
10012 llvm::SmallPtrSet<QualType, 8> AddedTypes;
10014 for (
unsigned ArgIdx = 0, N = Args.size(); ArgIdx != N; ++ArgIdx) {
10015 for (QualType PtrTy : CandidateTypes[ArgIdx].pointer_types()) {
10019 if (IsSpaceship && PtrTy->isFunctionPointerType())
10022 QualType ParamTypes[2] = {PtrTy, PtrTy};
10025 for (QualType EnumTy : CandidateTypes[ArgIdx].enumeration_types()) {
10030 if (!AddedTypes.insert(CanonType).second ||
10031 UserDefinedBinaryOperators.count(std::make_pair(CanonType,
10034 QualType ParamTypes[2] = {EnumTy, EnumTy};
10059 llvm::SmallPtrSet<QualType, 8> AddedTypes;
10061 for (
int Arg = 0; Arg < 2; ++Arg) {
10062 QualType AsymmetricParamTypes[2] = {
10066 for (QualType PtrTy : CandidateTypes[Arg].pointer_types()) {
10071 AsymmetricParamTypes[Arg] = PtrTy;
10072 if (Arg == 0 || Op == OO_Plus) {
10077 if (Op == OO_Minus) {
10082 QualType ParamTypes[2] = {PtrTy, PtrTy};
10118 void addGenericBinaryArithmeticOverloads() {
10119 if (!ArithmeticCandidatesMayBeViable)
10122 for (
unsigned Left = FirstPromotedArithmeticType;
10123 Left < LastPromotedArithmeticType; ++
Left) {
10124 for (
unsigned Right = FirstPromotedArithmeticType;
10125 Right < LastPromotedArithmeticType; ++
Right) {
10126 QualType LandR[2] = { ArithmeticTypes[
Left],
10127 ArithmeticTypes[
Right] };
10134 for (QualType Vec1Ty : CandidateTypes[0].vector_types())
10135 for (QualType Vec2Ty : CandidateTypes[1].vector_types()) {
10136 QualType LandR[2] = {Vec1Ty, Vec2Ty};
10146 void addMatrixBinaryArithmeticOverloads() {
10147 if (!ArithmeticCandidatesMayBeViable)
10150 for (QualType M1 : CandidateTypes[0].matrix_types()) {
10152 AddCandidate(M1, M1);
10155 for (QualType M2 : CandidateTypes[1].matrix_types()) {
10157 if (!CandidateTypes[0].containsMatrixType(M2))
10158 AddCandidate(M2, M2);
10193 void addThreeWayArithmeticOverloads() {
10194 addGenericBinaryArithmeticOverloads();
10211 void addBinaryBitwiseArithmeticOverloads() {
10212 if (!ArithmeticCandidatesMayBeViable)
10215 for (
unsigned Left = FirstPromotedIntegralType;
10216 Left < LastPromotedIntegralType; ++
Left) {
10217 for (
unsigned Right = FirstPromotedIntegralType;
10218 Right < LastPromotedIntegralType; ++
Right) {
10219 QualType LandR[2] = { ArithmeticTypes[
Left],
10220 ArithmeticTypes[
Right] };
10233 void addAssignmentMemberPointerOrEnumeralOverloads() {
10235 llvm::SmallPtrSet<QualType, 8> AddedTypes;
10237 for (
unsigned ArgIdx = 0; ArgIdx < 2; ++ArgIdx) {
10238 for (QualType EnumTy : CandidateTypes[ArgIdx].enumeration_types()) {
10245 for (QualType MemPtrTy : CandidateTypes[ArgIdx].member_pointer_types()) {
10270 void addAssignmentPointerOverloads(
bool isEqualOp) {
10272 llvm::SmallPtrSet<QualType, 8> AddedTypes;
10274 for (QualType PtrTy : CandidateTypes[0].pointer_types()) {
10278 else if (!PtrTy->getPointeeType()->isObjectType())
10282 QualType ParamTypes[2] = {
10289 bool NeedVolatile = !PtrTy.isVolatileQualified() &&
10291 if (NeedVolatile) {
10299 if (!PtrTy.isRestrictQualified() &&
10307 if (NeedVolatile) {
10319 for (QualType PtrTy : CandidateTypes[1].pointer_types()) {
10324 QualType ParamTypes[2] = {
10333 bool NeedVolatile = !PtrTy.isVolatileQualified() &&
10335 if (NeedVolatile) {
10343 if (!PtrTy.isRestrictQualified() &&
10351 if (NeedVolatile) {
10376 void addAssignmentArithmeticOverloads(
bool isEqualOp) {
10377 if (!ArithmeticCandidatesMayBeViable)
10380 for (
unsigned Left = 0;
Left < NumArithmeticTypes; ++
Left) {
10381 for (
unsigned Right = FirstPromotedArithmeticType;
10382 Right < LastPromotedArithmeticType; ++
Right) {
10383 QualType ParamTypes[2];
10384 ParamTypes[1] = ArithmeticTypes[
Right];
10386 S, ArithmeticTypes[Left], Args[0]);
10389 VisibleTypeConversionsQuals, [&](QualifiersAndAtomic Quals) {
10399 for (QualType Vec1Ty : CandidateTypes[0].vector_types())
10400 for (QualType Vec2Ty : CandidateTypes[0].vector_types()) {
10401 QualType ParamTypes[2];
10402 ParamTypes[1] = Vec2Ty;
10430 void addAssignmentIntegralOverloads() {
10431 if (!ArithmeticCandidatesMayBeViable)
10434 for (
unsigned Left = FirstIntegralType;
Left < LastIntegralType; ++
Left) {
10435 for (
unsigned Right = FirstPromotedIntegralType;
10436 Right < LastPromotedIntegralType; ++
Right) {
10437 QualType ParamTypes[2];
10438 ParamTypes[1] = ArithmeticTypes[
Right];
10440 S, ArithmeticTypes[Left], Args[0]);
10443 VisibleTypeConversionsQuals, [&](QualifiersAndAtomic Quals) {
10459 void addExclaimOverload() {
10465 void addAmpAmpOrPipePipeOverload() {
10482 void addSubscriptOverloads() {
10483 for (QualType PtrTy : CandidateTypes[0].pointer_types()) {
10493 for (QualType PtrTy : CandidateTypes[1].pointer_types()) {
10513 void addArrowStarOverloads() {
10514 for (QualType PtrTy : CandidateTypes[0].pointer_types()) {
10515 QualType C1Ty = PtrTy;
10517 QualifierCollector Q1;
10528 for (QualType MemPtrTy : CandidateTypes[1].member_pointer_types()) {
10535 QualType ParamTypes[2] = {PtrTy, MemPtrTy};
10538 if (!VisibleTypeConversionsQuals.
hasVolatile() &&
10539 T.isVolatileQualified())
10541 if (!VisibleTypeConversionsQuals.
hasRestrict() &&
10542 T.isRestrictQualified())
10560 void addConditionalOperatorOverloads() {
10562 llvm::SmallPtrSet<QualType, 8> AddedTypes;
10564 for (
unsigned ArgIdx = 0; ArgIdx < 2; ++ArgIdx) {
10565 for (QualType PtrTy : CandidateTypes[ArgIdx].pointer_types()) {
10569 QualType ParamTypes[2] = {PtrTy, PtrTy};
10573 for (QualType MemPtrTy : CandidateTypes[ArgIdx].member_pointer_types()) {
10577 QualType ParamTypes[2] = {MemPtrTy, MemPtrTy};
10582 for (QualType EnumTy : CandidateTypes[ArgIdx].enumeration_types()) {
10583 if (!EnumTy->castAsCanonical<EnumType>()->getDecl()->isScoped())
10589 QualType ParamTypes[2] = {EnumTy, EnumTy};
10608 VisibleTypeConversionsQuals.
addConst();
10609 for (
unsigned ArgIdx = 0, N = Args.size(); ArgIdx != N; ++ArgIdx) {
10611 if (Args[ArgIdx]->
getType()->isAtomicType())
10612 VisibleTypeConversionsQuals.
addAtomic();
10615 bool HasNonRecordCandidateType =
false;
10616 bool HasArithmeticOrEnumeralCandidateType =
false;
10618 for (
unsigned ArgIdx = 0, N = Args.size(); ArgIdx != N; ++ArgIdx) {
10619 CandidateTypes.emplace_back(*
this);
10620 CandidateTypes[ArgIdx].AddTypesConvertedFrom(Args[ArgIdx]->
getType(),
10623 (Op == OO_Exclaim ||
10625 Op == OO_PipePipe),
10626 VisibleTypeConversionsQuals);
10627 HasNonRecordCandidateType = HasNonRecordCandidateType ||
10628 CandidateTypes[ArgIdx].hasNonRecordTypes();
10629 HasArithmeticOrEnumeralCandidateType =
10630 HasArithmeticOrEnumeralCandidateType ||
10631 CandidateTypes[ArgIdx].hasArithmeticOrEnumeralTypes();
10639 if (!HasNonRecordCandidateType &&
10640 !(Op == OO_Exclaim || Op == OO_AmpAmp || Op == OO_PipePipe))
10644 BuiltinOperatorOverloadBuilder OpBuilder(*
this, Args,
10645 VisibleTypeConversionsQuals,
10646 HasArithmeticOrEnumeralCandidateType,
10647 CandidateTypes, CandidateSet);
10653 llvm_unreachable(
"Expected an overloaded operator");
10658 case OO_Array_Delete:
10661 "Special operators don't use AddBuiltinOperatorCandidates");
10673 if (Args.size() == 1)
10674 OpBuilder.addUnaryPlusPointerOverloads();
10678 if (Args.size() == 1) {
10679 OpBuilder.addUnaryPlusOrMinusArithmeticOverloads();
10681 OpBuilder.addBinaryPlusOrMinusPointerOverloads(Op);
10682 OpBuilder.addGenericBinaryArithmeticOverloads();
10683 OpBuilder.addMatrixBinaryArithmeticOverloads();
10688 if (Args.size() == 1)
10689 OpBuilder.addUnaryStarPointerOverloads();
10691 OpBuilder.addGenericBinaryArithmeticOverloads();
10692 OpBuilder.addMatrixBinaryArithmeticOverloads();
10697 OpBuilder.addGenericBinaryArithmeticOverloads();
10701 case OO_MinusMinus:
10702 OpBuilder.addPlusPlusMinusMinusArithmeticOverloads(Op);
10703 OpBuilder.addPlusPlusMinusMinusPointerOverloads();
10706 case OO_EqualEqual:
10707 case OO_ExclaimEqual:
10708 OpBuilder.addEqualEqualOrNotEqualMemberPointerOrNullptrOverloads();
10709 OpBuilder.addGenericBinaryPointerOrEnumeralOverloads(
false);
10710 OpBuilder.addGenericBinaryArithmeticOverloads();
10716 case OO_GreaterEqual:
10717 OpBuilder.addGenericBinaryPointerOrEnumeralOverloads(
false);
10718 OpBuilder.addGenericBinaryArithmeticOverloads();
10722 OpBuilder.addGenericBinaryPointerOrEnumeralOverloads(
true);
10723 OpBuilder.addThreeWayArithmeticOverloads();
10730 case OO_GreaterGreater:
10731 OpBuilder.addBinaryBitwiseArithmeticOverloads();
10735 if (Args.size() == 1)
10741 OpBuilder.addBinaryBitwiseArithmeticOverloads();
10745 OpBuilder.addUnaryTildePromotedIntegralOverloads();
10749 OpBuilder.addAssignmentMemberPointerOrEnumeralOverloads();
10753 case OO_MinusEqual:
10754 OpBuilder.addAssignmentPointerOverloads(Op == OO_Equal);
10758 case OO_SlashEqual:
10759 OpBuilder.addAssignmentArithmeticOverloads(Op == OO_Equal);
10762 case OO_PercentEqual:
10763 case OO_LessLessEqual:
10764 case OO_GreaterGreaterEqual:
10766 case OO_CaretEqual:
10768 OpBuilder.addAssignmentIntegralOverloads();
10772 OpBuilder.addExclaimOverload();
10777 OpBuilder.addAmpAmpOrPipePipeOverload();
10781 if (Args.size() == 2)
10782 OpBuilder.addSubscriptOverloads();
10786 OpBuilder.addArrowStarOverloads();
10789 case OO_Conditional:
10790 OpBuilder.addConditionalOperatorOverloads();
10791 OpBuilder.addGenericBinaryArithmeticOverloads();
10802 bool PartialOverloading) {
10819 CandEnd = CandidateSet.
end();
10820 Cand != CandEnd; ++Cand)
10821 if (Cand->Function) {
10825 Fns.
erase(FunTmpl);
10834 if (ExplicitTemplateArgs)
10838 FD, FoundDecl, Args, CandidateSet,
false,
10839 PartialOverloading,
true,
10840 false, ADLCallKind::UsesADL);
10843 FD, FoundDecl, {Args[1], Args[0]}, CandidateSet,
10844 false, PartialOverloading,
10851 FTD, FoundDecl, ExplicitTemplateArgs, Args, CandidateSet,
10852 false, PartialOverloading,
10853 true, ADLCallKind::UsesADL);
10855 *
this, Args, FTD->getTemplatedDecl())) {
10859 if (ReversedArgs.empty())
10863 FTD, FoundDecl, ExplicitTemplateArgs, ReversedArgs, CandidateSet,
10864 false, PartialOverloading,
10865 true, ADLCallKind::UsesADL,
10890 bool Cand1Attr = Cand1->
hasAttr<EnableIfAttr>();
10891 bool Cand2Attr = Cand2->
hasAttr<EnableIfAttr>();
10892 if (!Cand1Attr || !Cand2Attr) {
10893 if (Cand1Attr == Cand2Attr)
10894 return Comparison::Equal;
10895 return Cand1Attr ? Comparison::Better : Comparison::Worse;
10901 llvm::FoldingSetNodeID Cand1ID, Cand2ID;
10902 for (
auto Pair : zip_longest(Cand1Attrs, Cand2Attrs)) {
10903 std::optional<EnableIfAttr *> Cand1A = std::get<0>(Pair);
10904 std::optional<EnableIfAttr *> Cand2A = std::get<1>(Pair);
10909 return Comparison::Worse;
10911 return Comparison::Better;
10916 (*Cand1A)->getCond()->Profile(Cand1ID, S.
getASTContext(),
true);
10917 (*Cand2A)->getCond()->Profile(Cand2ID, S.
getASTContext(),
true);
10918 if (Cand1ID != Cand2ID)
10919 return Comparison::Worse;
10922 return Comparison::Equal;
10930 return Comparison::Equal;
10936 return Comparison::Equal;
10937 return Comparison::Worse;
10940 return Comparison::Better;
10946 const auto *Cand1CPUSpec = Cand1.
Function->
getAttr<CPUSpecificAttr>();
10947 const auto *Cand2CPUSpec = Cand2.
Function->
getAttr<CPUSpecificAttr>();
10949 if (!Cand1CPUDisp && !Cand2CPUDisp && !Cand1CPUSpec && !Cand2CPUSpec)
10950 return Comparison::Equal;
10952 if (Cand1CPUDisp && !Cand2CPUDisp)
10953 return Comparison::Better;
10954 if (Cand2CPUDisp && !Cand1CPUDisp)
10955 return Comparison::Worse;
10957 if (Cand1CPUSpec && Cand2CPUSpec) {
10958 if (Cand1CPUSpec->cpus_size() != Cand2CPUSpec->cpus_size())
10959 return Cand1CPUSpec->cpus_size() < Cand2CPUSpec->cpus_size()
10960 ? Comparison::Better
10961 : Comparison::Worse;
10963 std::pair<CPUSpecificAttr::cpus_iterator, CPUSpecificAttr::cpus_iterator>
10964 FirstDiff = std::mismatch(
10965 Cand1CPUSpec->cpus_begin(), Cand1CPUSpec->cpus_end(),
10966 Cand2CPUSpec->cpus_begin(),
10968 return LHS->getName() == RHS->getName();
10971 assert(FirstDiff.first != Cand1CPUSpec->cpus_end() &&
10972 "Two different cpu-specific versions should not have the same "
10973 "identifier list, otherwise they'd be the same decl!");
10974 return (*FirstDiff.first)->getName() < (*FirstDiff.second)->getName()
10975 ? Comparison::Better
10976 : Comparison::Worse;
10978 llvm_unreachable(
"No way to get here unless both had cpu_dispatch");
10984static std::optional<QualType>
10987 return std::nullopt;
10993 return M->getFunctionObjectParameterReferenceType();
11007 PT2->getInstantiatedFromMemberTemplate()))
11018 assert(I < F->getNumParams());
11025 if (F1NumParams != F2NumParams)
11028 unsigned I1 = 0, I2 = 0;
11029 for (
unsigned I = 0; I != F1NumParams; ++I) {
11030 QualType T1 = NextParam(F1, I1, I == 0);
11031 QualType T2 = NextParam(F2, I2, I == 0);
11032 assert(!T1.
isNull() && !T2.
isNull() &&
"Unexpected null param types");
11033 if (!Context.hasSameUnqualifiedType(T1, T2))
11046 bool IsFn1Reversed,
11047 bool IsFn2Reversed) {
11048 assert(Fn1 && Fn2);
11053 IsFn1Reversed ^ IsFn2Reversed))
11056 auto *Mem1 = dyn_cast<CXXMethodDecl>(Fn1);
11057 auto *Mem2 = dyn_cast<CXXMethodDecl>(Fn2);
11058 if (Mem1 && Mem2) {
11061 if (Mem1->getParent() != Mem2->getParent())
11065 if (Mem1->isInstance() && Mem2->isInstance() &&
11067 Mem1->getFunctionObjectParameterReferenceType(),
11068 Mem2->getFunctionObjectParameterReferenceType()))
11074static FunctionDecl *
11076 bool IsFn1Reversed,
bool IsFn2Reversed) {
11086 if (Cand1IsSpecialization || Cand2IsSpecialization)
11103 bool PartialOverloading) {
11149 bool IsCand1ImplicitHD =
11151 bool IsCand2ImplicitHD =
11166 auto EmitThreshold =
11167 (S.
getLangOpts().CUDAIsDevice && IsCallerImplicitHD &&
11168 (IsCand1ImplicitHD || IsCand2ImplicitHD))
11171 auto Cand1Emittable = P1 > EmitThreshold;
11172 auto Cand2Emittable = P2 > EmitThreshold;
11173 if (Cand1Emittable && !Cand2Emittable)
11175 if (!Cand1Emittable && Cand2Emittable)
11186 unsigned StartArg = 0;
11194 return ICS.isStandard() &&
11206 assert(Cand2.
Conversions.size() == NumArgs &&
"Overload candidate mismatch");
11207 bool HasBetterConversion =
false;
11208 for (
unsigned ArgIdx = StartArg; ArgIdx < NumArgs; ++ArgIdx) {
11209 bool Cand1Bad = IsIllFormedConversion(Cand1.
Conversions[ArgIdx]);
11210 bool Cand2Bad = IsIllFormedConversion(Cand2.
Conversions[ArgIdx]);
11211 if (Cand1Bad != Cand2Bad) {
11214 HasBetterConversion =
true;
11218 if (HasBetterConversion)
11225 bool HasWorseConversion =
false;
11226 for (
unsigned ArgIdx = StartArg; ArgIdx < NumArgs; ++ArgIdx) {
11232 HasBetterConversion =
true;
11251 HasWorseConversion =
true;
11266 if (HasBetterConversion && !HasWorseConversion)
11317 bool Cand1IsSpecialization = Cand1.
Function &&
11319 bool Cand2IsSpecialization = Cand2.
Function &&
11321 if (Cand1IsSpecialization != Cand2IsSpecialization)
11322 return Cand2IsSpecialization;
11328 if (Cand1IsSpecialization && Cand2IsSpecialization) {
11329 const auto *Obj1Context =
11331 const auto *Obj2Context =
11360 bool Cand1IsInherited =
11362 bool Cand2IsInherited =
11364 if (Cand1IsInherited != Cand2IsInherited)
11365 return Cand2IsInherited;
11366 else if (Cand1IsInherited) {
11367 assert(Cand2IsInherited);
11370 if (Cand1Class->isDerivedFrom(Cand2Class))
11372 if (Cand2Class->isDerivedFrom(Cand1Class))
11389 auto *Guide1 = dyn_cast_or_null<CXXDeductionGuideDecl>(Cand1.
Function);
11390 auto *Guide2 = dyn_cast_or_null<CXXDeductionGuideDecl>(Cand2.
Function);
11391 if (Guide1 && Guide2) {
11393 if (Guide1->isImplicit() != Guide2->isImplicit())
11394 return Guide2->isImplicit();
11404 const auto *Constructor1 = Guide1->getCorrespondingConstructor();
11405 const auto *Constructor2 = Guide2->getCorrespondingConstructor();
11406 if (Constructor1 && Constructor2) {
11407 bool isC1Templated = Constructor1->getTemplatedKind() !=
11409 bool isC2Templated = Constructor2->getTemplatedKind() !=
11411 if (isC1Templated != isC2Templated)
11412 return isC2Templated;
11420 if (
Cmp != Comparison::Equal)
11421 return Cmp == Comparison::Better;
11424 bool HasPS1 = Cand1.
Function !=
nullptr &&
11426 bool HasPS2 = Cand2.
Function !=
nullptr &&
11428 if (HasPS1 != HasPS2 && HasPS1)
11432 if (MV == Comparison::Better)
11434 if (MV == Comparison::Worse)
11449 const auto *CD1 = dyn_cast_or_null<CXXConstructorDecl>(Cand1.
Function);
11450 const auto *CD2 = dyn_cast_or_null<CXXConstructorDecl>(Cand2.
Function);
11452 LangAS AS1 = CD1->getMethodQualifiers().getAddressSpace();
11453 LangAS AS2 = CD2->getMethodQualifiers().getAddressSpace();
11474 auto *VA = dyn_cast_or_null<ValueDecl>(A);
11475 auto *VB = dyn_cast_or_null<ValueDecl>(B);
11481 if (!VA->getDeclContext()->getRedeclContext()->Equals(
11482 VB->getDeclContext()->getRedeclContext()) ||
11484 VA->isExternallyVisible() || VB->isExternallyVisible())
11492 if (
Context.hasSameType(VA->getType(), VB->getType()))
11497 if (
auto *EA = dyn_cast<EnumConstantDecl>(VA)) {
11498 if (
auto *EB = dyn_cast<EnumConstantDecl>(VB)) {
11503 if (EnumA->hasNameForLinkage() || EnumB->hasNameForLinkage() ||
11504 !
Context.hasSameType(EnumA->getIntegerType(),
11505 EnumB->getIntegerType()))
11508 return llvm::APSInt::isSameValue(EA->getInitVal(), EB->getInitVal());
11518 assert(D &&
"Unknown declaration");
11519 Diag(Loc, diag::ext_equivalent_internal_linkage_decl_in_modules) << D;
11525 for (
auto *E : Equiv) {
11527 Diag(E->getLocation(), diag::note_equivalent_internal_linkage_decl)
11537 ->Satisfaction.ContainsErrors;
11543 bool PartialOverloading,
bool AllowExplicit,
11545 bool AggregateCandidateDeduction) {
11548 allocateDeferredCandidate<DeferredFunctionTemplateOverloadCandidate>();
11553 false, AllowExplicit, SuppressUserConversions,
11554 PartialOverloading, AggregateCandidateDeduction},
11561 HasDeferredTemplateConstructors |=
11569 bool SuppressUserConversions,
bool PartialOverloading,
11575 allocateDeferredCandidate<DeferredMethodTemplateOverloadCandidate>();
11581 false, SuppressUserConversions, PartialOverloading,
11587 ObjectClassification,
11595 bool AllowObjCConversionOnExplicit,
bool AllowExplicit,
11596 bool AllowResultConversion) {
11599 allocateDeferredCandidate<DeferredConversionTemplateOverloadCandidate>();
11603 AllowObjCConversionOnExplicit, AllowResultConversion,
11620 S, CandidateSet,
C.FunctionTemplate,
C.FoundDecl,
C.ActingContext,
11621 nullptr,
C.ObjectType,
C.ObjectClassification,
11622 C.Args,
C.SuppressUserConversions,
C.PartialOverloading,
C.PO);
11629 S, CandidateSet,
C.FunctionTemplate,
C.FoundDecl,
11630 nullptr,
C.Args,
C.SuppressUserConversions,
11631 C.PartialOverloading,
C.AllowExplicit,
C.IsADLCandidate,
C.PO,
11632 C.AggregateCandidateDeduction);
11639 S, CandidateSet,
C.FunctionTemplate,
C.FoundDecl,
C.ActingContext,
C.From,
11640 C.ToType,
C.AllowObjCConversionOnExplicit,
C.AllowExplicit,
11641 C.AllowResultConversion);
11645 Candidates.reserve(Candidates.size() + DeferredCandidatesCount);
11648 switch (Cand->
Kind) {
11667 FirstDeferredCandidate =
nullptr;
11668 DeferredCandidatesCount = 0;
11672OverloadCandidateSet::ResultForBestCandidate(
const iterator &Best) {
11674 if (Best->Function && Best->Function->isDeleted())
11679void OverloadCandidateSet::CudaExcludeWrongSideCandidates(
11696 bool ContainsSameSideCandidate =
11704 if (!ContainsSameSideCandidate)
11707 auto IsWrongSideCandidate = [&](
const OverloadCandidate *Cand) {
11713 llvm::erase_if(Candidates, IsWrongSideCandidate);
11731 DeferredCandidatesCount == 0) &&
11732 "Unexpected deferred template candidates");
11734 bool TwoPhaseResolution =
11735 DeferredCandidatesCount != 0 && !ResolutionByPerfectCandidateIsDisabled;
11737 if (TwoPhaseResolution) {
11739 if (Best !=
end() && Best->isPerfectMatch(S.
Context)) {
11740 if (!(HasDeferredTemplateConstructors &&
11741 isa_and_nonnull<CXXConversionDecl>(Best->Function)))
11747 return BestViableFunctionImpl(S, Loc, Best);
11754 Candidates.reserve(this->Candidates.size());
11755 std::transform(this->Candidates.begin(), this->Candidates.end(),
11756 std::back_inserter(Candidates),
11760 CudaExcludeWrongSideCandidates(S, Candidates);
11763 for (
auto *Cand : Candidates) {
11764 Cand->
Best =
false;
11766 if (Best ==
end() ||
11783 llvm::SmallVector<OverloadCandidate *, 4> PendingBest;
11784 llvm::SmallVector<const NamedDecl *, 4> EquivalentCands;
11785 PendingBest.push_back(&*Best);
11790 while (!PendingBest.empty()) {
11791 auto *Curr = PendingBest.pop_back_val();
11792 for (
auto *Cand : Candidates) {
11795 PendingBest.push_back(Cand);
11800 EquivalentCands.push_back(Cand->
Function);
11812 if (!EquivalentCands.empty())
11820enum OverloadCandidateKind {
11823 oc_reversed_binary_operator,
11825 oc_implicit_default_constructor,
11826 oc_implicit_copy_constructor,
11827 oc_implicit_move_constructor,
11828 oc_implicit_copy_assignment,
11829 oc_implicit_move_assignment,
11830 oc_implicit_equality_comparison,
11831 oc_inherited_constructor
11834enum OverloadCandidateSelect {
11837 ocs_described_template,
11840static std::pair<OverloadCandidateKind, OverloadCandidateSelect>
11841ClassifyOverloadCandidate(Sema &S,
const NamedDecl *
Found,
11842 const FunctionDecl *Fn,
11844 std::string &Description) {
11847 if (FunctionTemplateDecl *FunTmpl =
Fn->getPrimaryTemplate()) {
11850 FunTmpl->getTemplateParameters(), *
Fn->getTemplateSpecializationArgs());
11853 OverloadCandidateSelect Select = [&]() {
11854 if (!Description.empty())
11855 return ocs_described_template;
11856 return isTemplate ? ocs_template : ocs_non_template;
11859 OverloadCandidateKind Kind = [&]() {
11860 if (
Fn->isImplicit() &&
Fn->getOverloadedOperator() == OO_EqualEqual)
11861 return oc_implicit_equality_comparison;
11864 return oc_reversed_binary_operator;
11866 if (
const auto *Ctor = dyn_cast<CXXConstructorDecl>(Fn)) {
11867 if (!Ctor->isImplicit()) {
11869 return oc_inherited_constructor;
11871 return oc_constructor;
11874 if (Ctor->isDefaultConstructor())
11875 return oc_implicit_default_constructor;
11877 if (Ctor->isMoveConstructor())
11878 return oc_implicit_move_constructor;
11880 assert(Ctor->isCopyConstructor() &&
11881 "unexpected sort of implicit constructor");
11882 return oc_implicit_copy_constructor;
11885 if (
const auto *Meth = dyn_cast<CXXMethodDecl>(Fn)) {
11888 if (!Meth->isImplicit())
11891 if (Meth->isMoveAssignmentOperator())
11892 return oc_implicit_move_assignment;
11894 if (Meth->isCopyAssignmentOperator())
11895 return oc_implicit_copy_assignment;
11901 return oc_function;
11904 return std::make_pair(Kind, Select);
11907void MaybeEmitInheritedConstructorNote(Sema &S,
const Decl *FoundDecl) {
11910 if (
const auto *Shadow = dyn_cast<ConstructorUsingShadowDecl>(FoundDecl))
11912 diag::note_ovl_candidate_inherited_constructor)
11913 << Shadow->getNominatedBaseClass();
11922 if (EnableIf->getCond()->isValueDependent() ||
11923 !EnableIf->getCond()->EvaluateAsBooleanCondition(AlwaysTrue, Ctx))
11940 bool InOverloadResolution,
11944 if (InOverloadResolution)
11946 diag::note_addrof_ovl_candidate_disabled_by_enable_if_attr);
11948 S.
Diag(Loc, diag::err_addrof_function_disabled_by_enable_if_attr) << FD;
11959 if (InOverloadResolution) {
11962 TemplateArgString +=
" ";
11964 FunTmpl->getTemplateParameters(),
11969 diag::note_ovl_candidate_unsatisfied_constraints)
11970 << TemplateArgString;
11972 S.
Diag(Loc, diag::err_addrof_function_constraints_not_satisfied)
11981 return P->hasAttr<PassObjectSizeAttr>();
11988 unsigned ParamNo = std::distance(FD->
param_begin(), I) + 1;
11989 if (InOverloadResolution)
11991 diag::note_ovl_candidate_has_pass_object_size_params)
11994 S.
Diag(Loc, diag::err_address_of_function_with_pass_object_size_params)
12010 return ::checkAddressOfFunctionIsAvailable(*
this,
Function, Complain,
12018 const auto *ConvD = dyn_cast<CXXConversionDecl>(Fn);
12023 if (!RD->isLambda())
12033 return ConvToCC != CallOpCC;
12039 QualType DestType,
bool TakingAddress) {
12042 if (Fn->isMultiVersion() && Fn->hasAttr<TargetAttr>() &&
12043 !Fn->getAttr<TargetAttr>()->isDefaultVersion())
12045 if (Fn->isMultiVersion() && Fn->hasAttr<TargetVersionAttr>() &&
12046 !Fn->getAttr<TargetVersionAttr>()->isDefaultVersion())
12051 std::string FnDesc;
12052 std::pair<OverloadCandidateKind, OverloadCandidateSelect> KSPair =
12053 ClassifyOverloadCandidate(*
this,
Found, Fn, RewriteKind, FnDesc);
12055 << (
unsigned)KSPair.first << (
unsigned)KSPair.second
12059 Diag(Fn->getLocation(), PD);
12060 MaybeEmitInheritedConstructorNote(*
this,
Found);
12078 FunctionDecl *FirstCand =
nullptr, *SecondCand =
nullptr;
12079 for (
auto I = Cands.begin(), E = Cands.end(); I != E; ++I) {
12083 if (
auto *
Template = I->Function->getPrimaryTemplate())
12084 Template->getAssociatedConstraints(AC);
12086 I->Function->getAssociatedConstraints(AC);
12089 if (FirstCand ==
nullptr) {
12090 FirstCand = I->Function;
12092 }
else if (SecondCand ==
nullptr) {
12093 SecondCand = I->Function;
12106 SecondCand, SecondAC))
12115 bool TakingAddress) {
12125 dyn_cast<FunctionTemplateDecl>((*I)->getUnderlyingDecl()) ) {
12129 = dyn_cast<FunctionDecl>((*I)->getUnderlyingDecl()) ) {
12142 S.
Diag(CaretLoc, PDiag)
12144 unsigned CandsShown = 0;
12158 unsigned I,
bool TakingCandidateAddress) {
12160 assert(Conv.
isBad());
12161 assert(Cand->
Function &&
"for now, candidate must be a function");
12167 bool isObjectArgument =
false;
12171 isObjectArgument =
true;
12176 std::string FnDesc;
12177 std::pair<OverloadCandidateKind, OverloadCandidateSelect> FnKindPair =
12188 bool HasParamPack =
12189 llvm::any_of(Fn->parameters().take_front(I), [](
const ParmVarDecl *Parm) {
12190 return Parm->isParameterPack();
12192 if (!isObjectArgument && !HasParamPack && I < Fn->getNumParams())
12193 ToParamRange = Fn->getParamDecl(I)->getSourceRange();
12196 assert(FromExpr &&
"overload set argument came from implicit argument?");
12202 S.
Diag(Fn->getLocation(), diag::note_ovl_candidate_bad_overload)
12203 << (
unsigned)FnKindPair.first << (
unsigned)FnKindPair.second << FnDesc
12204 << ToParamRange << ToTy << Name << I + 1;
12205 MaybeEmitInheritedConstructorNote(S, Cand->
FoundDecl);
12214 CToTy = RT->getPointeeType();
12219 CFromTy = FromPT->getPointeeType();
12220 CToTy = ToPT->getPointeeType();
12230 if (isObjectArgument)
12231 S.
Diag(Fn->getLocation(), diag::note_ovl_candidate_bad_addrspace_this)
12232 << (
unsigned)FnKindPair.first << (
unsigned)FnKindPair.second
12235 S.
Diag(Fn->getLocation(), diag::note_ovl_candidate_bad_addrspace)
12236 << (
unsigned)FnKindPair.first << (
unsigned)FnKindPair.second
12239 MaybeEmitInheritedConstructorNote(S, Cand->
FoundDecl);
12244 S.
Diag(Fn->getLocation(), diag::note_ovl_candidate_bad_ownership)
12245 << (
unsigned)FnKindPair.first << (
unsigned)FnKindPair.second << FnDesc
12248 MaybeEmitInheritedConstructorNote(S, Cand->
FoundDecl);
12253 S.
Diag(Fn->getLocation(), diag::note_ovl_candidate_bad_gc)
12254 << (
unsigned)FnKindPair.first << (
unsigned)FnKindPair.second << FnDesc
12257 MaybeEmitInheritedConstructorNote(S, Cand->
FoundDecl);
12262 S.
Diag(Fn->getLocation(), diag::note_ovl_candidate_bad_ptrauth)
12263 << (
unsigned)FnKindPair.first << (
unsigned)FnKindPair.second << FnDesc
12268 MaybeEmitInheritedConstructorNote(S, Cand->
FoundDecl);
12273 assert(CVR &&
"expected qualifiers mismatch");
12275 if (isObjectArgument) {
12276 S.
Diag(Fn->getLocation(), diag::note_ovl_candidate_bad_cvr_this)
12277 << (
unsigned)FnKindPair.first << (
unsigned)FnKindPair.second << FnDesc
12278 << FromTy << (CVR - 1);
12280 S.
Diag(Fn->getLocation(), diag::note_ovl_candidate_bad_cvr)
12281 << (
unsigned)FnKindPair.first << (
unsigned)FnKindPair.second << FnDesc
12282 << ToParamRange << FromTy << (CVR - 1) << I + 1;
12284 MaybeEmitInheritedConstructorNote(S, Cand->
FoundDecl);
12290 S.
Diag(Fn->getLocation(), diag::note_ovl_candidate_bad_value_category)
12291 << (
unsigned)FnKindPair.first << (
unsigned)FnKindPair.second << FnDesc
12292 << (
unsigned)isObjectArgument << I + 1
12295 MaybeEmitInheritedConstructorNote(S, Cand->
FoundDecl);
12302 S.
Diag(Fn->getLocation(), diag::note_ovl_candidate_bad_list_argument)
12303 << (
unsigned)FnKindPair.first << (
unsigned)FnKindPair.second << FnDesc
12304 << ToParamRange << FromTy << ToTy << (
unsigned)isObjectArgument << I + 1
12309 MaybeEmitInheritedConstructorNote(S, Cand->
FoundDecl);
12321 S.
Diag(Fn->getLocation(), diag::note_ovl_candidate_bad_conv_incomplete)
12322 << (
unsigned)FnKindPair.first << (
unsigned)FnKindPair.second << FnDesc
12323 << ToParamRange << FromTy << ToTy << (
unsigned)isObjectArgument << I + 1
12324 << (
unsigned)(Cand->
Fix.
Kind);
12326 MaybeEmitInheritedConstructorNote(S, Cand->
FoundDecl);
12331 unsigned BaseToDerivedConversion = 0;
12334 if (ToPtrTy->getPointeeType().isAtLeastAsQualifiedAs(
12336 !FromPtrTy->getPointeeType()->isIncompleteType() &&
12337 !ToPtrTy->getPointeeType()->isIncompleteType() &&
12339 FromPtrTy->getPointeeType()))
12340 BaseToDerivedConversion = 1;
12348 if (ToPtrTy->getPointeeType().isAtLeastAsQualifiedAs(
12350 FromIface->isSuperClassOf(ToIface))
12351 BaseToDerivedConversion = 2;
12353 if (ToRefTy->getPointeeType().isAtLeastAsQualifiedAs(FromTy,
12356 !ToRefTy->getPointeeType()->isIncompleteType() &&
12358 BaseToDerivedConversion = 3;
12362 if (BaseToDerivedConversion) {
12363 S.
Diag(Fn->getLocation(), diag::note_ovl_candidate_bad_base_to_derived_conv)
12364 << (
unsigned)FnKindPair.first << (
unsigned)FnKindPair.second << FnDesc
12365 << ToParamRange << (BaseToDerivedConversion - 1) << FromTy << ToTy
12367 MaybeEmitInheritedConstructorNote(S, Cand->
FoundDecl);
12376 S.
Diag(Fn->getLocation(), diag::note_ovl_candidate_bad_arc_conv)
12377 << (
unsigned)FnKindPair.first << (
unsigned)FnKindPair.second << FnDesc
12378 << ToParamRange << FromTy << ToTy << (
unsigned)isObjectArgument
12380 MaybeEmitInheritedConstructorNote(S, Cand->
FoundDecl);
12390 if (FromTy == S.
Context.AMDGPUFeaturePredicateTy &&
12393 diag::err_amdgcn_predicate_type_needs_explicit_bool_cast)
12400 FDiag << (
unsigned)FnKindPair.first << (
unsigned)FnKindPair.second << FnDesc
12401 << ToParamRange << FromTy << ToTy << (
unsigned)isObjectArgument << I + 1
12402 << (
unsigned)(Cand->
Fix.
Kind);
12411 S.
Diag(Fn->getLocation(), FDiag);
12413 MaybeEmitInheritedConstructorNote(S, Cand->
FoundDecl);
12420 unsigned NumArgs,
bool IsAddressOf =
false) {
12421 assert(Cand->
Function &&
"Candidate is required to be a function.");
12423 unsigned MinParams = Fn->getMinRequiredExplicitArguments() +
12424 ((IsAddressOf && !Fn->isStatic()) ? 1 : 0);
12431 if (Fn->isInvalidDecl() &&
12435 if (NumArgs < MinParams) {
12452 unsigned NumFormalArgs,
12453 bool IsAddressOf =
false) {
12455 "The templated declaration should at least be a function"
12456 " when diagnosing bad template argument deduction due to too many"
12457 " or too few arguments");
12463 unsigned MinParams = Fn->getMinRequiredExplicitArguments() +
12464 ((IsAddressOf && !Fn->isStatic()) ? 1 : 0);
12467 bool HasExplicitObjectParam =
12468 !IsAddressOf && Fn->hasCXXExplicitFunctionObjectParameter();
12470 unsigned ParamCount =
12471 Fn->getNumNonObjectParams() + ((IsAddressOf && !Fn->isStatic()) ? 1 : 0);
12472 unsigned mode, modeCount;
12474 if (NumFormalArgs < MinParams) {
12475 if (MinParams != ParamCount || FnTy->isVariadic() ||
12476 FnTy->isTemplateVariadic())
12480 modeCount = MinParams;
12482 if (MinParams != ParamCount)
12486 modeCount = ParamCount;
12489 std::string Description;
12490 std::pair<OverloadCandidateKind, OverloadCandidateSelect> FnKindPair =
12491 ClassifyOverloadCandidate(S,
Found, Fn,
CRK_None, Description);
12493 unsigned FirstNonObjectParamIdx = HasExplicitObjectParam ? 1 : 0;
12494 if (modeCount == 1 && !IsAddressOf &&
12495 FirstNonObjectParamIdx < Fn->getNumParams() &&
12496 Fn->getParamDecl(FirstNonObjectParamIdx)->getDeclName())
12497 S.
Diag(Fn->getLocation(), diag::note_ovl_candidate_arity_one)
12498 << (
unsigned)FnKindPair.first << (
unsigned)FnKindPair.second
12499 << Description << mode << Fn->getParamDecl(FirstNonObjectParamIdx)
12500 << NumFormalArgs << HasExplicitObjectParam
12501 << Fn->getParametersSourceRange();
12503 S.
Diag(Fn->getLocation(), diag::note_ovl_candidate_arity)
12504 << (
unsigned)FnKindPair.first << (
unsigned)FnKindPair.second
12505 << Description << mode << modeCount << NumFormalArgs
12506 << HasExplicitObjectParam << Fn->getParametersSourceRange();
12508 MaybeEmitInheritedConstructorNote(S,
Found);
12513 unsigned NumFormalArgs) {
12514 assert(Cand->
Function &&
"Candidate must be a function");
12524 llvm_unreachable(
"Unsupported: Getting the described template declaration"
12525 " for bad deduction diagnosis");
12531 unsigned NumArgs,
bool TakingCandidateAddress,
12535 NamedDecl *ParamD = dyn_cast_if_present<TemplateTypeParmDecl *>(Param);
12537 ParamD = dyn_cast_if_present<NonTypeTemplateParmDecl *>(Param);
12539 ParamD = dyn_cast_if_present<TemplateTemplateParmDecl *>(Param);
12540 switch (DeductionFailure.
getResult()) {
12543 "TemplateDeductionResult::Success while diagnosing bad deduction");
12545 llvm_unreachable(
"TemplateDeductionResult::NonDependentConversionFailure "
12546 "while diagnosing bad deduction");
12552 assert(ParamD &&
"no parameter found for incomplete deduction result");
12554 diag::note_ovl_candidate_incomplete_deduction)
12556 MaybeEmitInheritedConstructorNote(S,
Found);
12561 assert(ParamD &&
"no parameter found for incomplete deduction result");
12563 diag::note_ovl_candidate_incomplete_deduction_pack)
12565 << (DeductionFailure.
getFirstArg()->pack_size() + 1)
12567 MaybeEmitInheritedConstructorNote(S,
Found);
12572 assert(ParamD &&
"no parameter found for bad qualifiers deduction result");
12590 S.
Diag(Templated->
getLocation(), diag::note_ovl_candidate_underqualified)
12591 << ParamD->
getDeclName() << Arg << NonCanonParam;
12592 MaybeEmitInheritedConstructorNote(S,
Found);
12597 assert(ParamD &&
"no parameter found for inconsistent deduction result");
12611 diag::note_ovl_candidate_inconsistent_deduction_types)
12614 MaybeEmitInheritedConstructorNote(S,
Found);
12634 diag::note_ovl_candidate_inconsistent_deduction)
12637 MaybeEmitInheritedConstructorNote(S,
Found);
12642 assert(ParamD &&
"no parameter found for invalid explicit arguments");
12645 diag::note_ovl_candidate_explicit_arg_mismatch);
12647 Diag << diag::ExplicitArgMismatchNameKind::Named << ParamD->
getDeclName();
12649 Diag << diag::ExplicitArgMismatchNameKind::Unnamed
12654 Diag << diag::ExplicitArgMismatchReasonKind::Detailed << DiagContent;
12656 Diag << diag::ExplicitArgMismatchReasonKind::Vague;
12659 MaybeEmitInheritedConstructorNote(S,
Found);
12666 TemplateArgString =
" ";
12669 if (TemplateArgString.size() == 1)
12670 TemplateArgString.clear();
12672 diag::note_ovl_candidate_unsatisfied_constraints)
12673 << TemplateArgString;
12676 static_cast<CNSInfo*
>(DeductionFailure.
Data)->Satisfaction);
12686 diag::note_ovl_candidate_instantiation_depth);
12687 MaybeEmitInheritedConstructorNote(S,
Found);
12695 TemplateArgString =
" ";
12698 if (TemplateArgString.size() == 1)
12699 TemplateArgString.clear();
12704 if (PDiag && PDiag->second.getDiagID() ==
12705 diag::err_typename_nested_not_found_enable_if) {
12708 S.
Diag(PDiag->first, diag::note_ovl_candidate_disabled_by_enable_if)
12709 <<
"'enable_if'" << TemplateArgString;
12714 if (PDiag && PDiag->second.getDiagID() ==
12715 diag::err_typename_nested_not_found_requirement) {
12717 diag::note_ovl_candidate_disabled_by_requirement)
12718 << PDiag->second.getStringArg(0) << TemplateArgString;
12728 SFINAEArgString =
": ";
12730 PDiag->second.EmitToString(S.
getDiagnostics(), SFINAEArgString);
12734 diag::note_ovl_candidate_substitution_failure)
12735 << TemplateArgString << SFINAEArgString << R;
12736 MaybeEmitInheritedConstructorNote(S,
Found);
12746 TemplateArgString =
" ";
12749 if (TemplateArgString.size() == 1)
12750 TemplateArgString.clear();
12753 S.
Diag(Templated->
getLocation(), diag::note_ovl_candidate_deduced_mismatch)
12756 << TemplateArgString
12781 CandidateSetKind ==
12783 ? diag::note_friend_template_non_deduced_mismatch_qualified
12784 : diag::note_ovl_candidate_non_deduced_mismatch_qualified)
12801 ? diag::note_friend_template_non_deduced_mismatch
12802 : diag::note_ovl_candidate_non_deduced_mismatch)
12803 << FirstTA << SecondTA;
12809 S.
Diag(Templated->
getLocation(), diag::note_ovl_candidate_bad_deduction);
12810 MaybeEmitInheritedConstructorNote(S,
Found);
12814 diag::note_cuda_ovl_candidate_target_mismatch);
12822 bool TakingCandidateAddress) {
12823 assert(Cand->
Function &&
"Candidate must be a function");
12838 assert(Cand->
Function &&
"Candidate must be a Function.");
12844 std::string FnDesc;
12845 std::pair<OverloadCandidateKind, OverloadCandidateSelect> FnKindPair =
12846 ClassifyOverloadCandidate(S, Cand->
FoundDecl, Callee,
12849 S.
Diag(Callee->getLocation(), diag::note_ovl_candidate_bad_target)
12850 << (
unsigned)FnKindPair.first << (
unsigned)ocs_non_template
12852 << CalleeTarget << CallerTarget;
12857 if (Meth !=
nullptr && Meth->
isImplicit()) {
12861 switch (FnKindPair.first) {
12864 case oc_implicit_default_constructor:
12867 case oc_implicit_copy_constructor:
12870 case oc_implicit_move_constructor:
12873 case oc_implicit_copy_assignment:
12876 case oc_implicit_move_assignment:
12881 bool ConstRHS =
false;
12885 ConstRHS = RT->getPointeeType().isConstQualified();
12896 assert(Cand->
Function &&
"Candidate must be a function");
12900 S.
Diag(Callee->getLocation(),
12901 diag::note_ovl_candidate_disabled_by_function_cond_attr)
12902 <<
Attr->getCond()->getSourceRange() <<
Attr->getMessage();
12906 assert(Cand->
Function &&
"Candidate must be a function");
12909 assert(ES.
isExplicit() &&
"not an explicit candidate");
12912 switch (Fn->getDeclKind()) {
12913 case Decl::Kind::CXXConstructor:
12916 case Decl::Kind::CXXConversion:
12919 case Decl::Kind::CXXDeductionGuide:
12920 Kind = Fn->isImplicit() ? 0 : 2;
12923 llvm_unreachable(
"invalid Decl");
12932 First = Pattern->getFirstDecl();
12935 diag::note_ovl_candidate_explicit)
12936 << Kind << (ES.
getExpr() ? 1 : 0)
12941 auto *DG = dyn_cast<CXXDeductionGuideDecl>(Fn);
12948 if (!(DG->isImplicit() || (OriginTemplate && OriginTemplate->
isTypeAlias())))
12950 std::string FunctionProto;
12951 llvm::raw_string_ostream OS(FunctionProto);
12964 "Non-template implicit deduction guides are only possible for "
12967 S.
Diag(DG->getLocation(), diag::note_implicit_deduction_guide)
12972 assert(
Template &&
"Cannot find the associated function template of "
12973 "CXXDeductionGuideDecl?");
12976 S.
Diag(DG->getLocation(), diag::note_implicit_deduction_guide)
12997 bool TakingCandidateAddress,
12999 assert(Cand->
Function &&
"Candidate must be a function");
13007 if (S.
getLangOpts().OpenCL && Fn->isImplicit() &&
13014 !Fn->hasCXXExplicitFunctionObjectParameter() && !Fn->isStatic())
13019 if (Fn->isDeleted()) {
13020 std::string FnDesc;
13021 std::pair<OverloadCandidateKind, OverloadCandidateSelect> FnKindPair =
13022 ClassifyOverloadCandidate(S, Cand->
FoundDecl, Fn,
13025 S.
Diag(Fn->getLocation(), diag::note_ovl_candidate_deleted)
13026 << (
unsigned)FnKindPair.first << (
unsigned)FnKindPair.second << FnDesc
13027 << (Fn->isDeleted()
13028 ? (Fn->getCanonicalDecl()->isDeletedAsWritten() ? 1 : 2)
13030 MaybeEmitInheritedConstructorNote(S, Cand->
FoundDecl);
13057 TakingCandidateAddress);
13060 S.
Diag(Fn->getLocation(), diag::note_ovl_candidate_illegal_constructor)
13061 << (Fn->getPrimaryTemplate() ? 1 : 0);
13062 MaybeEmitInheritedConstructorNote(S, Cand->
FoundDecl);
13069 S.
Diag(Fn->getLocation(),
13070 diag::note_ovl_candidate_illegal_constructor_adrspace_mismatch)
13071 << QualsForPrinting;
13072 MaybeEmitInheritedConstructorNote(S, Cand->
FoundDecl);
13083 for (
unsigned N = Cand->
Conversions.size(); I != N; ++I)
13106 S.
Diag(Fn->getLocation(),
13107 diag::note_ovl_candidate_inherited_constructor_slice)
13108 << (Fn->getPrimaryTemplate() ? 1 : 0)
13109 << Fn->getParamDecl(0)->getType()->isRValueReferenceType();
13110 MaybeEmitInheritedConstructorNote(S, Cand->
FoundDecl);
13116 assert(!Available);
13124 std::string FnDesc;
13125 std::pair<OverloadCandidateKind, OverloadCandidateSelect> FnKindPair =
13126 ClassifyOverloadCandidate(S, Cand->
FoundDecl, Fn,
13129 S.
Diag(Fn->getLocation(),
13130 diag::note_ovl_candidate_constraints_not_satisfied)
13131 << (
unsigned)FnKindPair.first << (
unsigned)ocs_non_template
13150 bool isLValueReference =
false;
13151 bool isRValueReference =
false;
13152 bool isPointer =
false;
13156 isLValueReference =
true;
13160 isRValueReference =
true;
13176 diag::note_ovl_surrogate_constraints_not_satisfied)
13190 assert(Cand->
Conversions.size() <= 2 &&
"builtin operator is not binary");
13191 std::string TypeStr(
"operator");
13197 S.
Diag(OpLoc, diag::note_ovl_builtin_candidate) << TypeStr;
13202 S.
Diag(OpLoc, diag::note_ovl_builtin_candidate) << TypeStr;
13209 if (ICS.
isBad())
break;
13213 S, OpLoc, S.
PDiag(diag::note_ambiguous_type_conversion));
13230 llvm_unreachable(
"non-deduction failure while diagnosing bad deduction");
13260 llvm_unreachable(
"Unhandled deduction result");
13265struct CompareOverloadCandidatesForDisplay {
13267 SourceLocation Loc;
13271 CompareOverloadCandidatesForDisplay(
13272 Sema &S, SourceLocation Loc,
size_t NArgs,
13274 : S(S), NumArgs(NArgs), CSK(CSK) {}
13284 if (NumArgs >
C->Function->getNumParams() && !
C->Function->isVariadic())
13286 if (NumArgs < C->
Function->getMinRequiredArguments())
13293 bool operator()(
const OverloadCandidate *L,
13294 const OverloadCandidate *R) {
13296 if (L == R)
return false;
13300 if (!
R->Viable)
return true;
13302 if (
int Ord = CompareConversions(*L, *R))
13305 }
else if (
R->Viable)
13308 assert(L->
Viable ==
R->Viable);
13321 int RDist =
std::abs((
int)
R->getNumParams() - (
int)NumArgs);
13322 if (LDist == RDist) {
13323 if (LFailureKind == RFailureKind)
13331 return LDist < RDist;
13348 unsigned numRFixes =
R->Fix.NumConversionsFixed;
13349 numLFixes = (numLFixes == 0) ?
UINT_MAX : numLFixes;
13350 numRFixes = (numRFixes == 0) ?
UINT_MAX : numRFixes;
13351 if (numLFixes != numRFixes) {
13352 return numLFixes < numRFixes;
13356 if (
int Ord = CompareConversions(*L, *R))
13368 if (LRank != RRank)
13369 return LRank < RRank;
13395 struct ConversionSignals {
13396 unsigned KindRank = 0;
13399 static ConversionSignals ForSequence(ImplicitConversionSequence &
Seq) {
13400 ConversionSignals Sig;
13401 Sig.KindRank =
Seq.getKindRank();
13402 if (
Seq.isStandard())
13403 Sig.Rank =
Seq.Standard.getRank();
13404 else if (
Seq.isUserDefined())
13405 Sig.Rank =
Seq.UserDefined.After.getRank();
13411 static ConversionSignals ForObjectArgument() {
13421 int CompareConversions(
const OverloadCandidate &L,
13422 const OverloadCandidate &R) {
13427 for (
unsigned I = 0, N = L.
Conversions.size(); I != N; ++I) {
13429 ? ConversionSignals::ForObjectArgument()
13430 : ConversionSignals::ForSequence(L.Conversions[I]);
13431 auto RS =
R.IgnoreObjectArgument
13432 ? ConversionSignals::ForObjectArgument()
13433 : ConversionSignals::ForSequence(
R.Conversions[I]);
13434 if (std::tie(LS.KindRank, LS.Rank) != std::tie(RS.KindRank, RS.Rank))
13435 return std::tie(LS.KindRank, LS.Rank) < std::tie(RS.KindRank, RS.Rank)
13460 bool Unfixable =
false;
13466 for (
unsigned ConvIdx =
13470 assert(ConvIdx != ConvCount &&
"no bad conversion in candidate");
13471 if (Cand->
Conversions[ConvIdx].isInitialized() &&
13480 bool SuppressUserConversions =
false;
13482 unsigned ConvIdx = 0;
13483 unsigned ArgIdx = 0;
13512 assert(ConvCount <= 3);
13518 ConvIdx != ConvCount && ArgIdx < Args.size();
13520 if (Cand->
Conversions[ConvIdx].isInitialized()) {
13522 }
else if (
ParamIdx < ParamTypes.size()) {
13523 if (ParamTypes[
ParamIdx]->isDependentType())
13524 Cand->
Conversions[ConvIdx].setAsIdentityConversion(
13529 SuppressUserConversions,
13534 if (!Unfixable && Cand->
Conversions[ConvIdx].isBad())
13553 for (
iterator Cand = Candidates.begin(), LastCand = Candidates.end();
13554 Cand != LastCand; ++Cand) {
13555 if (!Filter(*Cand))
13580 Cands.push_back(Cand);
13584 Cands, CompareOverloadCandidatesForDisplay(S, OpLoc, Args.size(), Kind));
13591 bool DeferHint =
false;
13595 auto WrongSidedCands =
13597 return (Cand.
Viable ==
false &&
13603 DeferHint = !WrongSidedCands.empty();
13619 S.
Diag(PD.first, PD.second);
13624 bool NoteCands =
true;
13625 for (
const Expr *Arg : Args) {
13626 if (Arg->getType()->isWebAssemblyTableType())
13635 {Candidates.begin(), Candidates.end()});
13641 bool ReportedAmbiguousConversions =
false;
13644 unsigned CandsShown = 0;
13645 auto I = Cands.begin(), E = Cands.end();
13646 for (; I != E; ++I) {
13662 "Non-viable built-in candidates are not added to Cands.");
13669 if (!ReportedAmbiguousConversions) {
13671 ReportedAmbiguousConversions =
true;
13685 S.
Diag(OpLoc, diag::note_ovl_too_many_candidates) <<
int(E - I);
13690 const Sema &S)
const {
13696 if (Caller && Caller->
hasAttr<CUDAHostAttr>() &&
13697 Caller->
hasAttr<CUDADeviceAttr>())
13718struct CompareTemplateSpecCandidatesForDisplay {
13720 CompareTemplateSpecCandidatesForDisplay(Sema &S) : S(S) {}
13722 bool operator()(
const TemplateSpecCandidate *L,
13723 const TemplateSpecCandidate *R) {
13754 Sema &S,
bool ForTakingAddress,
13761void TemplateSpecCandidateSet::destroyCandidates() {
13763 i->DeductionFailure.Destroy();
13768 destroyCandidates();
13769 Candidates.clear();
13782 Cands.reserve(
size());
13783 for (
iterator Cand =
begin(), LastCand =
end(); Cand != LastCand; ++Cand) {
13784 if (Cand->Specialization)
13785 Cands.push_back(Cand);
13790 llvm::sort(Cands, CompareTemplateSpecCandidatesForDisplay(S));
13797 unsigned CandsShown = 0;
13798 for (I = Cands.begin(), E = Cands.end(); I != E; ++I) {
13804 if (CandsShown >= 4 && ShowOverloads ==
Ovl_Best)
13809 "Non-matching built-in candidates are not added to Cands.");
13814 S.
Diag(Loc, diag::note_ovl_too_many_candidates) <<
int(E - I);
13824 QualType Ret = PossiblyAFunctionType;
13827 Ret = ToTypePtr->getPointeeType();
13830 Ret = ToTypeRef->getPointeeType();
13833 Ret = MemTypePtr->getPointeeType();
13835 Context.getCanonicalType(Ret).getUnqualifiedType();
13840 bool Complain =
true) {
13857class AddressOfFunctionResolver {
13860 const QualType& TargetType;
13861 QualType TargetFunctionType;
13865 ASTContext& Context;
13867 bool TargetTypeIsNonStaticMemberFunction;
13868 bool FoundNonTemplateFunction;
13869 bool StaticMemberFunctionFromBoundPointer;
13870 bool HasComplained;
13872 OverloadExpr::FindResult OvlExprInfo;
13873 OverloadExpr *OvlExpr;
13874 TemplateArgumentListInfo OvlExplicitTemplateArgs;
13875 SmallVector<std::pair<DeclAccessPair, FunctionDecl*>, 4> Matches;
13876 TemplateSpecCandidateSet FailedCandidates;
13879 AddressOfFunctionResolver(Sema &S, Expr *SourceExpr,
13880 const QualType &TargetType,
bool Complain)
13881 : S(S), SourceExpr(SourceExpr), TargetType(TargetType),
13882 Complain(Complain), Context(S.getASTContext()),
13883 TargetTypeIsNonStaticMemberFunction(
13884 !!TargetType->getAs<MemberPointerType>()),
13885 FoundNonTemplateFunction(
false),
13886 StaticMemberFunctionFromBoundPointer(
false),
13887 HasComplained(
false),
13888 OvlExprInfo(OverloadExpr::find(SourceExpr)),
13890 FailedCandidates(OvlExpr->getNameLoc(),
true) {
13891 ExtractUnqualifiedFunctionTypeFromTargetType();
13894 if (UnresolvedMemberExpr *UME = dyn_cast<UnresolvedMemberExpr>(OvlExpr))
13895 if (!UME->isImplicitAccess() &&
13897 StaticMemberFunctionFromBoundPointer =
true;
13899 DeclAccessPair dap;
13901 OvlExpr,
false, &dap)) {
13902 if (CXXMethodDecl *
Method = dyn_cast<CXXMethodDecl>(Fn))
13903 if (!
Method->isStatic()) {
13907 TargetTypeIsNonStaticMemberFunction =
true;
13915 Matches.push_back(std::make_pair(dap, Fn));
13923 if (FindAllFunctionsThatMatchTargetTypeExactly()) {
13925 EliminateSuboptimalCudaMatches();
13929 if (Matches.size() > 1 && !eliminiateSuboptimalOverloadCandidates()) {
13930 if (FoundNonTemplateFunction) {
13931 EliminateAllTemplateMatches();
13932 EliminateLessPartialOrderingConstrainedMatches();
13934 EliminateAllExceptMostSpecializedTemplate();
13939 bool hasComplained()
const {
return HasComplained; }
13942 bool candidateHasExactlyCorrectType(
const FunctionDecl *FD) {
13949 bool isBetterCandidate(
const FunctionDecl *A,
const FunctionDecl *B) {
13953 return candidateHasExactlyCorrectType(A) &&
13954 (!candidateHasExactlyCorrectType(B) ||
13960 bool eliminiateSuboptimalOverloadCandidates() {
13963 auto Best = Matches.begin();
13964 for (
auto I = Matches.begin()+1, E = Matches.end(); I != E; ++I)
13965 if (isBetterCandidate(I->second, Best->second))
13968 const FunctionDecl *BestFn = Best->second;
13969 auto IsBestOrInferiorToBest = [
this, BestFn](
13970 const std::pair<DeclAccessPair, FunctionDecl *> &Pair) {
13971 return BestFn == Pair.second || isBetterCandidate(BestFn, Pair.second);
13976 if (!llvm::all_of(Matches, IsBestOrInferiorToBest))
13978 Matches[0] = *Best;
13983 bool isTargetTypeAFunction()
const {
13992 void inline ExtractUnqualifiedFunctionTypeFromTargetType() {
13998 const DeclAccessPair& CurAccessFunPair) {
13999 if (CXXMethodDecl *
Method
14003 bool CanConvertToFunctionPointer =
14004 Method->isStatic() ||
Method->isExplicitObjectMemberFunction();
14005 if (CanConvertToFunctionPointer == TargetTypeIsNonStaticMemberFunction)
14008 else if (TargetTypeIsNonStaticMemberFunction)
14018 TemplateDeductionInfo Info(FailedCandidates.
getLocation());
14022 Result != TemplateDeductionResult::Success) {
14040 Matches.push_back(std::make_pair(CurAccessFunPair,
Specialization));
14044 bool AddMatchingNonTemplateFunction(NamedDecl* Fn,
14045 const DeclAccessPair& CurAccessFunPair) {
14046 if (CXXMethodDecl *
Method = dyn_cast<CXXMethodDecl>(Fn)) {
14049 bool CanConvertToFunctionPointer =
14050 Method->isStatic() ||
Method->isExplicitObjectMemberFunction();
14051 if (CanConvertToFunctionPointer == TargetTypeIsNonStaticMemberFunction)
14054 else if (TargetTypeIsNonStaticMemberFunction)
14057 if (FunctionDecl *FunDecl = dyn_cast<FunctionDecl>(Fn)) {
14064 if (FunDecl->isMultiVersion()) {
14065 const auto *TA = FunDecl->getAttr<TargetAttr>();
14066 if (TA && !TA->isDefaultVersion())
14068 const auto *TVA = FunDecl->getAttr<TargetVersionAttr>();
14069 if (TVA && !TVA->isDefaultVersion())
14077 HasComplained |= Complain;
14086 candidateHasExactlyCorrectType(FunDecl)) {
14087 Matches.push_back(std::make_pair(
14089 FoundNonTemplateFunction =
true;
14097 bool FindAllFunctionsThatMatchTargetTypeExactly() {
14102 if (IsInvalidFormOfPointerToMemberFunction())
14105 for (UnresolvedSetIterator I = OvlExpr->
decls_begin(),
14109 NamedDecl *
Fn = (*I)->getUnderlyingDecl();
14118 = dyn_cast<FunctionTemplateDecl>(Fn)) {
14124 AddMatchingNonTemplateFunction(Fn, I.getPair()))
14127 assert(Ret || Matches.empty());
14131 void EliminateAllExceptMostSpecializedTemplate() {
14143 UnresolvedSet<4> MatchesCopy;
14144 for (
unsigned I = 0, E = Matches.size(); I != E; ++I)
14145 MatchesCopy.
addDecl(Matches[I].second, Matches[I].first.getAccess());
14150 MatchesCopy.
begin(), MatchesCopy.
end(), FailedCandidates,
14152 S.
PDiag(diag::err_addr_ovl_ambiguous)
14153 << Matches[0].second->getDeclName(),
14154 S.
PDiag(diag::note_ovl_candidate)
14155 << (
unsigned)oc_function << (
unsigned)ocs_described_template,
14156 Complain, TargetFunctionType);
14160 Matches[0].first = Matches[
Result - MatchesCopy.
begin()].first;
14164 HasComplained |= Complain;
14167 void EliminateAllTemplateMatches() {
14170 for (
unsigned I = 0, N = Matches.size(); I != N; ) {
14171 if (Matches[I].second->getPrimaryTemplate() ==
nullptr)
14174 Matches[I] = Matches[--N];
14180 void EliminateLessPartialOrderingConstrainedMatches() {
14185 assert(Matches[0].second->getPrimaryTemplate() ==
nullptr &&
14186 "Call EliminateAllTemplateMatches() first");
14187 SmallVector<std::pair<DeclAccessPair, FunctionDecl *>, 4> Results;
14188 Results.push_back(Matches[0]);
14189 for (
unsigned I = 1, N = Matches.size(); I < N; ++I) {
14190 assert(Matches[I].second->getPrimaryTemplate() ==
nullptr);
14192 S, Matches[I].second, Results[0].second,
14196 Results.push_back(Matches[I]);
14199 if (F == Matches[I].second) {
14201 Results.push_back(Matches[I]);
14204 std::swap(Matches, Results);
14207 void EliminateSuboptimalCudaMatches() {
14213 void ComplainNoMatchesFound()
const {
14214 assert(Matches.empty());
14216 << OvlExpr->
getName() << TargetFunctionType
14218 if (FailedCandidates.
empty())
14225 for (UnresolvedSetIterator I = OvlExpr->
decls_begin(),
14228 if (FunctionDecl *Fun =
14229 dyn_cast<FunctionDecl>((*I)->getUnderlyingDecl()))
14237 bool IsInvalidFormOfPointerToMemberFunction()
const {
14238 return TargetTypeIsNonStaticMemberFunction &&
14242 void ComplainIsInvalidFormOfPointerToMemberFunction()
const {
14250 bool IsStaticMemberFunctionFromBoundPointer()
const {
14251 return StaticMemberFunctionFromBoundPointer;
14254 void ComplainIsStaticMemberFunctionFromBoundPointer()
const {
14256 diag::err_invalid_form_pointer_member_function)
14260 void ComplainOfInvalidConversion()
const {
14262 << OvlExpr->
getName() << TargetType;
14265 void ComplainMultipleMatchesFound()
const {
14266 assert(Matches.size() > 1);
14273 bool hadMultipleCandidates()
const {
return (OvlExpr->
getNumDecls() > 1); }
14275 int getNumMatches()
const {
return Matches.size(); }
14277 FunctionDecl* getMatchingFunctionDecl()
const {
14278 if (Matches.size() != 1)
return nullptr;
14279 return Matches[0].second;
14282 const DeclAccessPair* getMatchingFunctionAccessPair()
const {
14283 if (Matches.size() != 1)
return nullptr;
14284 return &Matches[0].first;
14294 bool *pHadMultipleCandidates) {
14297 AddressOfFunctionResolver Resolver(*
this, AddressOfExpr, TargetType,
14299 int NumMatches = Resolver.getNumMatches();
14301 bool ShouldComplain = Complain && !Resolver.hasComplained();
14302 if (NumMatches == 0 && ShouldComplain) {
14303 if (Resolver.IsInvalidFormOfPointerToMemberFunction())
14304 Resolver.ComplainIsInvalidFormOfPointerToMemberFunction();
14306 Resolver.ComplainNoMatchesFound();
14308 else if (NumMatches > 1 && ShouldComplain)
14309 Resolver.ComplainMultipleMatchesFound();
14310 else if (NumMatches == 1) {
14311 Fn = Resolver.getMatchingFunctionDecl();
14315 FoundResult = *Resolver.getMatchingFunctionAccessPair();
14317 if (Resolver.IsStaticMemberFunctionFromBoundPointer())
14318 Resolver.ComplainIsStaticMemberFunctionFromBoundPointer();
14324 if (pHadMultipleCandidates)
14325 *pHadMultipleCandidates = Resolver.hadMultipleCandidates();
14333 bool IsResultAmbiguous =
false;
14341 return static_cast<int>(
CUDA().IdentifyPreference(Caller, FD1)) -
14342 static_cast<int>(
CUDA().IdentifyPreference(Caller, FD2));
14349 auto *FD = dyn_cast<FunctionDecl>(I->getUnderlyingDecl());
14357 auto FoundBetter = [&]() {
14358 IsResultAmbiguous =
false;
14370 int PreferenceByCUDA = CheckCUDAPreference(FD,
Result);
14372 if (PreferenceByCUDA != 0) {
14374 if (PreferenceByCUDA > 0)
14387 if (
Result->isFunctionTemplateSpecialization() !=
14402 if (MoreConstrained != FD) {
14403 if (!MoreConstrained) {
14404 IsResultAmbiguous =
true;
14405 AmbiguousDecls.push_back(FD);
14414 if (IsResultAmbiguous)
14435 ExprResult &SrcExpr,
bool DoFunctionPointerConversion) {
14437 assert(E->
getType() ==
Context.OverloadTy &&
"SrcExpr must be an overload");
14441 if (!
Found ||
Found->isCPUDispatchMultiVersion() ||
14442 Found->isCPUSpecificMultiVersion())
14490 dyn_cast<FunctionTemplateDecl>((*I)->getUnderlyingDecl());
14521 if (ForTypeDeduction &&
14535 if (FoundResult) *FoundResult = I.getPair();
14546 ExprResult &SrcExpr,
bool doFunctionPointerConversion,
bool complain,
14548 unsigned DiagIDForComplaining) {
14569 if (!complain)
return false;
14572 diag::err_bound_member_function)
14585 SingleFunctionExpression =
14589 if (doFunctionPointerConversion) {
14590 SingleFunctionExpression =
14592 if (SingleFunctionExpression.
isInvalid()) {
14599 if (!SingleFunctionExpression.
isUsable()) {
14601 Diag(OpRangeForComplaining.
getBegin(), DiagIDForComplaining)
14603 << DestTypeForComplaining
14604 << OpRangeForComplaining
14615 SrcExpr = SingleFunctionExpression;
14625 bool PartialOverloading,
14632 if (ExplicitTemplateArgs) {
14633 assert(!KnownValid &&
"Explicit template arguments?");
14642 PartialOverloading);
14647 = dyn_cast<FunctionTemplateDecl>(Callee)) {
14649 ExplicitTemplateArgs, Args, CandidateSet,
14651 PartialOverloading);
14655 assert(!KnownValid &&
"unhandled case in overloaded call candidate");
14661 bool PartialOverloading) {
14684 assert(!(*I)->getDeclContext()->isRecord());
14686 !(*I)->getDeclContext()->isFunctionOrMethod());
14687 assert((*I)->getUnderlyingDecl()->isFunctionOrFunctionTemplate());
14697 ExplicitTemplateArgs = &TABuffer;
14703 CandidateSet, PartialOverloading,
14708 Args, ExplicitTemplateArgs,
14709 CandidateSet, PartialOverloading);
14717 CandidateSet,
false,
false);
14724 case OO_New:
case OO_Array_New:
14725 case OO_Delete:
case OO_Array_Delete:
14749 if (DC->isTransparentContext())
14755 R.suppressDiagnostics();
14760 for (
auto &Cand : ResolvedCandidates) {
14773 if (
auto *RD = dyn_cast<CXXRecordDecl>(DC)) {
14778 if (FoundInClass) {
14779 *FoundInClass = RD;
14782 R.addDecl(Best->FoundDecl.getDecl(), Best->FoundDecl.getAccess());
14799 AssociatedNamespaces,
14800 AssociatedClasses);
14804 for (Sema::AssociatedNamespaceSet::iterator
14805 it = AssociatedNamespaces.begin(),
14806 end = AssociatedNamespaces.end(); it !=
end; ++it) {
14818 SuggestedNamespaces.insert(*it);
14822 SemaRef.
Diag(R.getNameLoc(), diag::err_not_found_by_two_phase_lookup)
14823 << R.getLookupName();
14824 if (SuggestedNamespaces.empty()) {
14825 SemaRef.
Diag(Best->Function->getLocation(),
14826 diag::note_not_found_by_two_phase_lookup)
14827 << R.getLookupName() << 0;
14828 }
else if (SuggestedNamespaces.size() == 1) {
14829 SemaRef.
Diag(Best->Function->getLocation(),
14830 diag::note_not_found_by_two_phase_lookup)
14831 << R.getLookupName() << 1 << *SuggestedNamespaces.begin();
14836 SemaRef.
Diag(Best->Function->getLocation(),
14837 diag::note_not_found_by_two_phase_lookup)
14838 << R.getLookupName() << 2;
14864 ResolvedCandidateSet,
14865 nullptr, Args,
nullptr);
14869class BuildRecoveryCallExprRAII {
14871 Sema::SatisfactionStackResetRAII SatStack;
14874 BuildRecoveryCallExprRAII(Sema &S) : SemaRef(S), SatStack(S) {
14895 bool AllowTypoCorrection) {
14903 BuildRecoveryCallExprRAII RCE(SemaRef);
14913 ExplicitTemplateArgs = &TABuffer;
14921 ResolvedCandidateSet, ExplicitTemplateArgs, Args, &FoundInClass)) {
14923 }
else if (ResolvedCandidateSet.
empty()) {
14928 ExplicitTemplateArgs !=
nullptr,
14929 dyn_cast<MemberExpr>(Fn));
14931 AllowTypoCorrection
14937 }
else if (FoundInClass && SemaRef.
getLangOpts().MSVCCompat) {
14952 assert(!R.empty() &&
"lookup results empty despite recovery");
14955 if (R.isAmbiguous()) {
14956 R.suppressDiagnostics();
14963 if ((*R.begin())->isCXXClassMember())
14965 ExplicitTemplateArgs, S);
14966 else if (ExplicitTemplateArgs || TemplateKWLoc.
isValid())
14968 ExplicitTemplateArgs);
14992 assert(!ULE->
getQualifier() &&
"qualified name with ADL");
14999 (F = dyn_cast<FunctionDecl>(*ULE->
decls_begin())) &&
15001 llvm_unreachable(
"performing ADL for builtin");
15008 UnbridgedCastsSet UnbridgedCasts;
15023 if (CandidateSet->
empty() ||
15039 if (CandidateSet->
empty())
15042 UnbridgedCasts.restore();
15049 std::optional<QualType>
Result;
15069 if (Best && *Best != CS.
end())
15070 ConsiderCandidate(**Best);
15073 for (
const auto &
C : CS)
15075 ConsiderCandidate(
C);
15078 for (
const auto &
C : CS)
15079 ConsiderCandidate(
C);
15084 if (
Value.isNull() ||
Value->isUndeducedType())
15101 bool AllowTypoCorrection) {
15102 switch (OverloadResult) {
15113 Res.
get(), FDecl, LParenLoc, Args, RParenLoc, ExecConfig,
15119 if (*Best != CandidateSet->
end() &&
15123 dyn_cast_if_present<CXXMethodDecl>((*Best)->Function);
15128 SemaRef.
PDiag(diag::err_member_call_without_object) << 0 << M),
15138 *CandidateSet, AllowTypoCorrection);
15145 for (
const Expr *Arg : Args) {
15146 if (!Arg->getType()->isFunctionType())
15148 if (
auto *DRE = dyn_cast<DeclRefExpr>(Arg->IgnoreParenImpCasts())) {
15149 auto *FD = dyn_cast<FunctionDecl>(DRE->getDecl());
15152 Arg->getExprLoc()))
15160 SemaRef.
PDiag(diag::err_ovl_no_viable_function_in_call)
15161 << ULE->
getName() << Fn->getSourceRange()),
15169 SemaRef.
PDiag(diag::err_ovl_ambiguous_call)
15170 << ULE->
getName() << Fn->getSourceRange()),
15177 Fn->getSourceRange(), ULE->
getName(),
15178 *CandidateSet, FDecl, Args);
15187 Res.
get(), FDecl, LParenLoc, Args, RParenLoc, ExecConfig,
15195 SubExprs.append(Args.begin(), Args.end());
15202 for (
auto I = CS.
begin(), E = CS.
end(); I != E; ++I) {
15217 bool AllowTypoCorrection,
15218 bool CalleesAddressIsTaken) {
15233 if (CalleesAddressIsTaken)
15244 Best != CandidateSet.
end()) {
15245 if (
auto *M = dyn_cast_or_null<CXXMethodDecl>(Best->Function);
15246 M && M->isImplicitObjectMemberFunction()) {
15257 CUDA().recordPotentialODRUsedVariable(Args, CandidateSet);
15275 if (
const auto *TP =
15285 ExecConfig, &CandidateSet, &Best,
15286 OverloadResult, AllowTypoCorrection);
15295 Context, NamingClass, NNSLoc, DNI, PerformADL, Fns.
begin(), Fns.
end(),
15301 bool HadMultipleCandidates) {
15311 if (
Method->isExplicitObjectMemberFunction())
15315 E, std::nullopt, FoundDecl,
Method);
15319 if (
Method->getParent()->isLambda() &&
15320 Method->getConversionType()->isBlockPointerType()) {
15324 auto *CE = dyn_cast<CastExpr>(SubE);
15325 if (CE && CE->getCastKind() == CK_NoOp)
15326 SubE = CE->getSubExpr();
15328 if (
auto *BE = dyn_cast<CXXBindTemporaryExpr>(SubE))
15329 SubE = BE->getSubExpr();
15352 if (
Method->isExplicitObjectMemberFunction()) {
15358 Expr *ObjectParam = Exp.
get();
15372 Exp.
get()->getEndLoc(),
15387 assert(Op !=
OO_None &&
"Invalid opcode for overloaded unary operator");
15404 Expr *Input,
bool PerformADL) {
15406 assert(Op !=
OO_None &&
"Invalid opcode for overloaded unary operator");
15414 Expr *Args[2] = { Input,
nullptr };
15415 unsigned NumArgs = 1;
15420 if (Opc == UO_PostInc || Opc == UO_PostDec) {
15434 if (Opc == UO_PreDec || Opc == UO_PreInc || Opc == UO_Deref)
15445 if (Fn.isInvalid())
15456 bool HadMultipleCandidates = (CandidateSet.
size() > 1);
15475 if (
Method->isExplicitObjectMemberFunction())
15479 Input, std::nullopt, Best->FoundDecl,
Method);
15482 Base = Input = InputInit.
get();
15493 Input = InputInit.
get();
15498 Base, HadMultipleCandidates,
15510 Context, Op, FnExpr.
get(), ArgsArray, ResultTy,
VK, OpLoc,
15526 Input, Best->BuiltinParamTypes[0], Best->Conversions[0],
15531 Input = InputRes.
get();
15552 PDiag(diag::err_ovl_ambiguous_oper_unary)
15569 << (Msg !=
nullptr)
15570 << (Msg ? Msg->
getString() : StringRef())
15623 if (Op != OO_Equal && PerformADL) {
15630 Context.DeclarationNames.getCXXOperatorName(ExtraOp);
15656 Expr *RHS,
bool PerformADL,
15657 bool AllowRewrittenCandidates,
15659 Expr *Args[2] = { LHS, RHS };
15663 AllowRewrittenCandidates =
false;
15669 if (Args[0]->isTypeDependent() || Args[1]->isTypeDependent()) {
15690 if (Fn.isInvalid())
15699 if (Opc == BO_PtrMemD) {
15700 auto CheckPlaceholder = [&](
Expr *&Arg) {
15709 if (CheckPlaceholder(Args[0]) || CheckPlaceholder(Args[1]))
15733 if (Opc == BO_Assign &&
15742 Op, OpLoc, AllowRewrittenCandidates));
15744 CandidateSet.
exclude(DefaultedFn);
15747 bool HadMultipleCandidates = (CandidateSet.
size() > 1);
15756 bool IsReversed = Best->isReversed();
15758 std::swap(Args[0], Args[1]);
15775 if (Best->RewriteKind && ChosenOp == OO_EqualEqual &&
15779 Diag(OpLoc, IsExtension ? diag::ext_ovl_rewrite_equalequal_not_bool
15780 : diag::err_ovl_rewrite_equalequal_not_bool)
15788 if (AllowRewrittenCandidates && !IsReversed &&
15798 for (
unsigned ArgIdx = 0; ArgIdx < 2; ++ArgIdx) {
15801 Best->Conversions[ArgIdx]) ==
15803 AmbiguousWith.push_back(Cand.
Function);
15810 if (!AmbiguousWith.empty()) {
15811 bool AmbiguousWithSelf =
15812 AmbiguousWith.size() == 1 &&
15814 Diag(OpLoc, diag::ext_ovl_ambiguous_oper_binary_reversed)
15816 << Args[0]->
getType() << Args[1]->
getType() << AmbiguousWithSelf
15818 if (AmbiguousWithSelf) {
15820 diag::note_ovl_ambiguous_oper_binary_reversed_self);
15825 if (
auto *MD = dyn_cast<CXXMethodDecl>(FnDecl))
15826 if (Op == OverloadedOperatorKind::OO_EqualEqual &&
15828 !MD->hasCXXExplicitFunctionObjectParameter() &&
15829 Context.hasSameUnqualifiedType(
15830 MD->getFunctionObjectParameterType(),
15831 MD->getParamDecl(0)->getType().getNonReferenceType()) &&
15832 Context.hasSameUnqualifiedType(
15833 MD->getFunctionObjectParameterType(),
15835 Context.hasSameUnqualifiedType(
15836 MD->getFunctionObjectParameterType(),
15839 diag::note_ovl_ambiguous_eqeq_reversed_self_non_const);
15842 diag::note_ovl_ambiguous_oper_binary_selected_candidate);
15843 for (
auto *F : AmbiguousWith)
15845 diag::note_ovl_ambiguous_oper_binary_reversed_candidate);
15853 if (Op == OO_Equal)
15864 if (
Method->isExplicitObjectMemberFunction()) {
15869 Args[0], std::nullopt, Best->FoundDecl,
Method);
15902 Best->FoundDecl,
Base,
15903 HadMultipleCandidates, OpLoc);
15909 Pattern->setIsUsed();
15918 const Expr *ImplicitThis =
nullptr;
15923 Context, ChosenOp, FnExpr.
get(), Args, ResultTy,
VK, OpLoc,
15928 if (
const auto *
Method = dyn_cast<CXXMethodDecl>(FnDecl);
15931 ImplicitThis = ArgsArray[0];
15932 ArgsArray = ArgsArray.slice(1);
15939 if (Op == OO_Equal) {
15944 *
this,
AssignedEntity{Args[0], dyn_cast<CXXMethodDecl>(FnDecl)},
15947 if (ImplicitThis) {
15952 CheckArgAlignment(OpLoc, FnDecl,
"'this'", ThisType,
15956 checkCall(FnDecl,
nullptr, ImplicitThis, ArgsArray,
15971 (Op == OO_Spaceship && IsReversed)) {
15972 if (Op == OO_ExclaimEqual) {
15973 assert(ChosenOp == OO_EqualEqual &&
"unexpected operator name");
15976 assert(ChosenOp == OO_Spaceship &&
"unexpected operator name");
15978 Expr *ZeroLiteral =
15987 OpLoc, Opc, Fns, IsReversed ? ZeroLiteral : R.get(),
15988 IsReversed ? R.get() : ZeroLiteral,
true,
15996 assert(ChosenOp == Op &&
"unexpected operator name");
16000 if (Best->RewriteKind !=
CRK_None)
16009 Args[0], Best->BuiltinParamTypes[0], Best->Conversions[0],
16014 Args[0] = ArgsRes0.
get();
16017 Args[1], Best->BuiltinParamTypes[1], Best->Conversions[1],
16022 Args[1] = ArgsRes1.
get();
16032 if (Opc == BO_Comma)
16037 if (DefaultedFn && Opc == BO_Cmp) {
16039 Args[1], DefaultedFn);
16054 Opc >= BO_Assign && Opc <= BO_OrAssign) {
16055 Diag(OpLoc, diag::err_ovl_no_viable_oper)
16058 if (Args[0]->
getType()->isIncompleteType()) {
16059 Diag(OpLoc, diag::note_assign_lhs_incomplete)
16076 assert(
Result.isInvalid() &&
16077 "C++ binary operator overloading is missing candidates!");
16088 << Args[0]->getSourceRange()
16089 << Args[1]->getSourceRange()),
16100 Diag(OpLoc, diag::err_ovl_deleted_special_oper)
16104 Diag(OpLoc, diag::err_ovl_deleted_comparison)
16105 << Args[0]->
getType() << DeletedFD;
16118 PDiag(diag::err_ovl_deleted_oper)
16120 .getCXXOverloadedOperator())
16121 << (Msg !=
nullptr) << (Msg ? Msg->
getString() : StringRef())
16122 << Args[0]->getSourceRange() << Args[1]->getSourceRange()),
16146 "cannot use prvalue expressions more than once");
16147 Expr *OrigLHS = LHS;
16148 Expr *OrigRHS = RHS;
16165 true, DefaultedFn);
16166 if (
Less.isInvalid())
16193 for (; I >= 0; --I) {
16195 auto *VI = Info->lookupValueInfo(Comparisons[I].
Result);
16218 Context, OrigLHS, OrigRHS, BO_Cmp,
Result.get()->getType(),
16219 Result.get()->getValueKind(),
Result.get()->getObjectKind(), OpLoc,
16221 Expr *SemanticForm[] = {LHS, RHS,
Result.get()};
16231 unsigned NumArgsSlots =
16232 MethodArgs.size() + std::max<unsigned>(Args.size(), NumParams);
16235 MethodArgs.reserve(MethodArgs.size() + NumArgsSlots);
16236 bool IsError =
false;
16239 for (
unsigned i = 0; i != NumParams; i++) {
16241 if (i < Args.size()) {
16245 S.
Context, Method->getParamDecl(i)),
16259 MethodArgs.push_back(Arg);
16269 Args.push_back(
Base);
16270 for (
auto *e : ArgExpr) {
16274 Context.DeclarationNames.getCXXOperatorName(OO_Subscript);
16279 ArgExpr.back()->getEndLoc());
16291 if (Fn.isInvalid())
16301 UnbridgedCastsSet UnbridgedCasts;
16314 if (Args.size() == 2)
16317 bool HadMultipleCandidates = (CandidateSet.
size() > 1);
16337 if (
Method->isExplicitObjectMemberFunction()) {
16342 Args[0] = Res.
get();
16346 Args[0], std::nullopt, Best->FoundDecl,
Method);
16350 MethodArgs.push_back(Arg0.
get());
16354 *
this, MethodArgs,
Method, ArgExpr, LLoc);
16363 HadMultipleCandidates, OpLocInfo);
16373 Context, OO_Subscript, FnExpr.
get(), MethodArgs, ResultTy,
VK, RLoc,
16390 Args[0], Best->BuiltinParamTypes[0], Best->Conversions[0],
16395 Args[0] = ArgsRes0.
get();
16398 Args[1], Best->BuiltinParamTypes[1], Best->Conversions[1],
16403 Args[1] = ArgsRes1.
get();
16411 CandidateSet.
empty()
16412 ? (
PDiag(diag::err_ovl_no_oper)
16413 << Args[0]->getType() << 0
16414 << Args[0]->getSourceRange() << Range)
16415 : (
PDiag(diag::err_ovl_no_viable_subscript)
16416 << Args[0]->getType() << Args[0]->getSourceRange() << Range);
16423 if (Args.size() == 2) {
16426 LLoc,
PDiag(diag::err_ovl_ambiguous_oper_binary)
16428 << Args[0]->getSourceRange() << Range),
16433 PDiag(diag::err_ovl_ambiguous_subscript_call)
16435 << Args[0]->getSourceRange() << Range),
16444 PDiag(diag::err_ovl_deleted_oper)
16445 <<
"[]" << (Msg !=
nullptr)
16446 << (Msg ? Msg->
getString() : StringRef())
16447 << Args[0]->getSourceRange() << Range),
16461 Expr *ExecConfig,
bool IsExecConfig,
16462 bool AllowRecovery) {
16471 if (
BinaryOperator *op = dyn_cast<BinaryOperator>(NakedMemExpr)) {
16472 assert(op->getType() ==
Context.BoundMemberTy);
16473 assert(op->getOpcode() == BO_PtrMemD || op->getOpcode() == BO_PtrMemI);
16486 QualType objectType = op->getLHS()->getType();
16487 if (op->getOpcode() == BO_PtrMemI)
16491 Qualifiers difference = objectQuals - funcQuals;
16495 std::string qualsString = difference.
getAsString();
16496 Diag(LParenLoc, diag::err_pointer_to_member_call_drops_quals)
16499 << (qualsString.find(
' ') == std::string::npos ? 1 : 2);
16503 Context, MemExprE, Args, resultType, valueKind, RParenLoc,
16513 if (CheckOtherCall(call, proto))
16523 if (!AllowRecovery)
16525 std::vector<Expr *> SubExprs = {MemExprE};
16526 llvm::append_range(SubExprs, Args);
16534 UnbridgedCastsSet UnbridgedCasts;
16540 bool HadMultipleCandidates =
false;
16548 UnbridgedCasts.restore();
16566 TemplateArgs = &TemplateArgsBuffer;
16570 E = UnresExpr->
decls_end(); I != E; ++I) {
16572 QualType ExplicitObjectType = ObjectType;
16579 bool HasExplicitParameter =
false;
16580 if (
const auto *M = dyn_cast<FunctionDecl>(
Func);
16581 M && M->hasCXXExplicitFunctionObjectParameter())
16582 HasExplicitParameter =
true;
16583 else if (
const auto *M = dyn_cast<FunctionTemplateDecl>(
Func);
16585 M->getTemplatedDecl()->hasCXXExplicitFunctionObjectParameter())
16586 HasExplicitParameter =
true;
16588 if (HasExplicitParameter)
16596 }
else if ((
Method = dyn_cast<CXXMethodDecl>(
Func))) {
16603 ObjectClassification, Args, CandidateSet,
16607 I.getPair(), ActingDC, TemplateArgs,
16608 ExplicitObjectType, ObjectClassification,
16609 Args, CandidateSet,
16614 HadMultipleCandidates = (CandidateSet.
size() > 1);
16618 UnbridgedCasts.restore();
16621 bool Succeeded =
false;
16626 FoundDecl = Best->FoundDecl;
16646 PDiag(diag::err_ovl_no_viable_member_function_in_call)
16653 PDiag(diag::err_ovl_ambiguous_member_call)
16660 CandidateSet, Best->Function, Args,
true);
16671 MemExprE = Res.
get();
16675 if (
Method->isStatic()) {
16677 ExecConfig, IsExecConfig);
16687 assert(
Method &&
"Member call to something that isn't a method?");
16692 if (
Method->isExplicitObjectMemberFunction()) {
16701 TemplateArgs = &TemplateArgsBuffer;
16707 Method, FoundDecl, MemExpr, HadMultipleCandidates,
16715 TheCall->setUsesMemberSyntax(
true);
16725 Proto->getNumParams());
16731 return BuildRecoveryExpr(ResultType);
16736 return BuildRecoveryExpr(ResultType);
16746 if (
auto *MemE = dyn_cast<MemberExpr>(NakedMemExpr)) {
16747 if (
const EnableIfAttr *
Attr =
16749 Diag(MemE->getMemberLoc(),
16750 diag::err_ovl_no_viable_member_function_in_call)
16753 diag::note_ovl_candidate_disabled_by_function_cond_attr)
16754 <<
Attr->getCond()->getSourceRange() <<
Attr->getMessage();
16760 TheCall->getDirectCallee()->isPureVirtual()) {
16766 diag::warn_call_to_pure_virtual_member_function_from_ctor_dtor)
16777 if (
auto *DD = dyn_cast<CXXDestructorDecl>(TheCall->getDirectCallee())) {
16781 CallCanBeVirtual,
true,
16786 TheCall->getDirectCallee());
16798 UnbridgedCastsSet UnbridgedCasts;
16802 assert(
Object.get()->getType()->isRecordType() &&
16803 "Requires object type argument");
16817 diag::err_incomplete_object_call,
Object.get()))
16820 auto *
Record =
Object.get()->getType()->castAsCXXRecordDecl();
16823 R.suppressAccessDiagnostics();
16826 Oper != OperEnd; ++Oper) {
16840 bool IgnoreSurrogateFunctions =
false;
16843 if (!Candidate.
Viable &&
16845 IgnoreSurrogateFunctions =
true;
16867 !IgnoreSurrogateFunctions && I != E; ++I) {
16889 Object.get(), Args, CandidateSet);
16894 bool HadMultipleCandidates = (CandidateSet.
size() > 1);
16907 CandidateSet.
empty()
16908 ? (
PDiag(diag::err_ovl_no_oper)
16909 <<
Object.get()->getType() << 1
16910 <<
Object.get()->getSourceRange())
16911 : (
PDiag(diag::err_ovl_no_viable_object_call)
16912 <<
Object.get()->getType() <<
Object.get()->getSourceRange());
16919 if (!R.isAmbiguous())
16922 PDiag(diag::err_ovl_ambiguous_object_call)
16923 <<
Object.get()->getType()
16924 <<
Object.get()->getSourceRange()),
16935 PDiag(diag::err_ovl_deleted_object_call)
16936 <<
Object.get()->getType() << (Msg !=
nullptr)
16937 << (Msg ? Msg->
getString() : StringRef())
16938 <<
Object.get()->getSourceRange()),
16944 if (Best == CandidateSet.
end())
16947 UnbridgedCasts.restore();
16949 if (Best->Function ==
nullptr) {
16954 Best->Conversions[0].UserDefined.ConversionFunction);
16958 "Found Decl & conversion-to-functionptr should be same, right?!");
16970 Conv, HadMultipleCandidates);
16971 if (
Call.isInvalid())
16975 Context,
Call.get()->getType(), CK_UserDefinedConversion,
Call.get(),
16989 if (
Method->isInvalidDecl())
16996 Context.DeclarationNames.getCXXOperatorName(OO_Call), LParenLoc);
16999 HadMultipleCandidates, OpLocInfo);
17004 MethodArgs.reserve(NumParams + 1);
17006 bool IsError =
false;
17010 if (
Method->isExplicitObjectMemberFunction()) {
17019 MethodArgs.push_back(
Object.get());
17023 *
this, MethodArgs,
Method, Args, LParenLoc);
17026 if (Proto->isVariadic()) {
17028 for (
unsigned i = NumParams, e = Args.size(); i < e; i++) {
17032 MethodArgs.push_back(Arg.
get());
17047 Context, OO_Call, NewFn.
get(), MethodArgs, ResultTy,
VK, RParenLoc,
17061 bool *NoArrowOperatorFound) {
17062 assert(
Base->getType()->isRecordType() &&
17063 "left-hand side must have class type");
17077 Context.DeclarationNames.getCXXOperatorName(OO_Arrow);
17081 diag::err_typecheck_incomplete_tag,
Base))
17086 R.suppressAccessDiagnostics();
17089 Oper != OperEnd; ++Oper) {
17095 bool HadMultipleCandidates = (CandidateSet.
size() > 1);
17106 if (CandidateSet.
empty()) {
17108 if (NoArrowOperatorFound) {
17111 *NoArrowOperatorFound =
true;
17114 Diag(OpLoc, diag::err_typecheck_member_reference_arrow)
17115 << BaseType <<
Base->getSourceRange();
17116 if (BaseType->isRecordType() && !BaseType->isPointerType()) {
17117 Diag(OpLoc, diag::note_typecheck_member_reference_suggestion)
17121 Diag(OpLoc, diag::err_ovl_no_viable_oper)
17122 <<
"operator->" <<
Base->getSourceRange();
17127 if (!R.isAmbiguous())
17130 <<
"->" <<
Base->getType()
17131 <<
Base->getSourceRange()),
17139 <<
"->" << (Msg !=
nullptr)
17140 << (Msg ? Msg->
getString() : StringRef())
17141 <<
Base->getSourceRange()),
17152 if (
Method->isExplicitObjectMemberFunction()) {
17159 Base, std::nullopt, Best->FoundDecl,
Method);
17167 Base, HadMultipleCandidates, OpLoc);
17201 bool HadMultipleCandidates = (CandidateSet.
size() > 1);
17214 PDiag(diag::err_ovl_no_viable_function_in_call)
17215 << R.getLookupName()),
17222 << R.getLookupName()),
17229 HadMultipleCandidates, SuffixInfo);
17230 if (Fn.isInvalid())
17236 for (
unsigned ArgIdx = 0, N = Args.size(); ArgIdx != N; ++ArgIdx) {
17242 ConvArgs[ArgIdx] = InputInit.
get();
17269 Scope *S =
nullptr;
17272 if (!MemberLookup.
empty()) {
17299 if (CandidateSet->
empty() || CandidateSetError) {
17312 Loc,
nullptr, CandidateSet, &Best,
17325 if (
ParenExpr *PE = dyn_cast<ParenExpr>(E)) {
17330 if (SubExpr.
get() == PE->getSubExpr())
17334 ParenExpr(PE->getLParen(), PE->getRParen(), SubExpr.
get());
17342 assert(
Context.hasSameType(ICE->getSubExpr()->getType(),
17344 "Implicit cast type cannot be determined from overload");
17345 assert(ICE->path_empty() &&
"fixing up hierarchy conversion?");
17346 if (SubExpr.
get() == ICE->getSubExpr())
17354 if (
auto *GSE = dyn_cast<GenericSelectionExpr>(E)) {
17355 if (!GSE->isResultDependent()) {
17360 if (SubExpr.
get() == GSE->getResultExpr())
17367 unsigned ResultIdx = GSE->getResultIndex();
17368 AssocExprs[ResultIdx] = SubExpr.
get();
17370 if (GSE->isExprPredicate())
17372 Context, GSE->getGenericLoc(), GSE->getControllingExpr(),
17373 GSE->getAssocTypeSourceInfos(), AssocExprs, GSE->getDefaultLoc(),
17374 GSE->getRParenLoc(), GSE->containsUnexpandedParameterPack(),
17377 Context, GSE->getGenericLoc(), GSE->getControllingType(),
17378 GSE->getAssocTypeSourceInfos(), AssocExprs, GSE->getDefaultLoc(),
17379 GSE->getRParenLoc(), GSE->containsUnexpandedParameterPack(),
17388 assert(UnOp->getOpcode() == UO_AddrOf &&
17389 "Can only take the address of an overloaded function");
17391 if (!
Method->isImplicitObjectMemberFunction()) {
17402 if (SubExpr.
get() == UnOp->getSubExpr())
17410 "fixed to something other than a decl ref");
17413 assert(Qualifier &&
17414 "fixed to a member ref with no nested name qualifier");
17420 Fn->getType(), Qualifier,
17423 if (
Context.getTargetInfo().getCXXABI().isMicrosoft())
17428 UnOp->getOperatorLoc(),
false,
17436 if (SubExpr.
get() == UnOp->getSubExpr())
17449 if (ULE->hasExplicitTemplateArgs()) {
17450 ULE->copyTemplateArgumentsInto(TemplateArgsBuffer);
17451 TemplateArgs = &TemplateArgsBuffer;
17456 getLangOpts().CPlusPlus && !Fn->hasCXXExplicitFunctionObjectParameter()
17461 if (
unsigned BID = Fn->getBuiltinID()) {
17462 if (!
Context.BuiltinInfo.isDirectlyAddressable(BID)) {
17469 Fn,
Type, ValueKind, ULE->getNameInfo(), ULE->getQualifierLoc(),
17470 Found.getDecl(), ULE->getTemplateKeywordLoc(), TemplateArgs);
17478 if (MemExpr->hasExplicitTemplateArgs()) {
17479 MemExpr->copyTemplateArgumentsInto(TemplateArgsBuffer);
17480 TemplateArgs = &TemplateArgsBuffer;
17487 if (MemExpr->isImplicitAccess()) {
17490 Fn, Fn->getType(),
VK_LValue, MemExpr->getNameInfo(),
17491 MemExpr->getQualifierLoc(),
Found.getDecl(),
17492 MemExpr->getTemplateKeywordLoc(), TemplateArgs);
17497 if (MemExpr->getQualifier())
17498 Loc = MemExpr->getQualifierLoc().getBeginLoc();
17503 Base = MemExpr->getBase();
17509 type = Fn->getType();
17516 Base, MemExpr->isArrow(), MemExpr->getOperatorLoc(),
17517 MemExpr->getQualifierLoc(), MemExpr->getTemplateKeywordLoc(), Fn,
Found,
17518 true, MemExpr->getMemberNameInfo(),
17522 llvm_unreachable(
"Invalid reference to overloaded function");
17533 if (!PartialOverloading || !
Function)
17537 if (
const auto *Proto =
17538 dyn_cast<FunctionProtoType>(
Function->getFunctionType()))
17539 if (Proto->isTemplateVariadic())
17541 if (
auto *Pattern =
Function->getTemplateInstantiationPattern())
17542 if (
const auto *Proto =
17543 dyn_cast<FunctionProtoType>(Pattern->getFunctionType()))
17544 if (Proto->isTemplateVariadic())
17557 << IsMember << Name << (Msg !=
nullptr)
17558 << (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.
Result
Implement __builtin_bit_cast and related operations.
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 AMDGPU.
This file declares semantic analysis functions specific to ARM.
static AccessResult DeduceTemplateArguments(Sema &S, FriendTemplateDecl *FTD, DeclContext *DC, const TemplateSpecializationType *TST, ArrayRef< TemplateParameterList * > TPLs, TemplateSpecCandidateSet *FailedTSC, MultiLevelTemplateArgumentList &DeducedArgs)
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)
This file declares semantic analysis for HLSL constructs.
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 void DiagnoseBadDeduction(Sema &S, NamedDecl *Found, Decl *Templated, DeductionFailureInfo &DeductionFailure, unsigned NumArgs, bool TakingCandidateAddress, TemplateSpecCandidateSetKind CandidateSetKind=TemplateSpecCandidateSetKind::Normal)
Diagnose a failed template-argument deduction.
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 IsHLSLPackedTypeConversion(Sema &S, QualType FromType, QualType ToType, ImplicitConversionKind &ICK, ImplicitConversionKind &DimensionICK, Expr *From)
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 bool tryOverflowBehaviorTypeConversion(Sema &S, Expr *From, QualType ToType, bool InOverloadResolution, StandardConversionSequence &SCS, bool CStyle)
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 bool DiagnoseTwoPhaseOperatorLookup(Sema &SemaRef, OverloadedOperatorKind Op, SourceLocation OpLoc, ArrayRef< Expr * > Args, const OverloadCandidateSet &ResolvedCandidateSet)
Attempt to recover from ill-formed use of a non-dependent operator in a template, where the non-depen...
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 ImplicitConversionSequence::CompareKind CompareOverflowBehaviorConversions(Sema &S, const StandardConversionSequence &SCS1, const StandardConversionSequence &SCS2)
CompareOverflowBehaviorConversions - Compares two standard conversion sequences to determine whether ...
static ExprResult BuildRecoveryCallExpr(Sema &SemaRef, Scope *S, Expr *Fn, UnresolvedLookupExpr *ULE, SourceLocation LParenLoc, MutableArrayRef< Expr * > Args, SourceLocation RParenLoc, const OverloadCandidateSet &ResolvedCandidateSet, bool AllowTypoCorrection)
Attempts to recover from a call where no functions were found.
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 bool DiagnoseTwoPhaseLookup(Sema &SemaRef, SourceLocation FnLoc, const CXXScopeSpec &SS, LookupResult &R, OverloadCandidateSet::CandidateSetKind CSK, const OverloadCandidateSet &ResolvedCandidates, 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 void DiagnoseFailedExplicitSpec(Sema &S, OverloadCandidate *Cand)
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 ExprResult CreateFunctionRefExpr(Sema &S, NestedNameSpecifierLoc QualifierLoc, SourceLocation TemplateKWLoc, FunctionDecl *Fn, NamedDecl *FoundDecl, const Expr *Base, bool HadMultipleCandidates, const DeclarationNameInfo &NameInfo, const TemplateArgumentListInfo *TemplateArgs)
A convenience routine for creating a decayed reference to a function.
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 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 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 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)
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
CanQualType getLogicalOperationType() const
The result type of logical operations, '<', '>', '!=', etc.
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.
bool areCompatibleOverflowBehaviorTypes(QualType LHS, QualType RHS)
Return true if two OverflowBehaviorTypes are compatible for assignment.
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, bool IsReversed=false)
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 isHLSLBuiltinRecord() const
Returns true if the class is a built-in HLSL record.
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...
static DeclRefExpr * Create(const ASTContext &Context, NestedNameSpecifierLoc QualifierLoc, SourceLocation TemplateKWLoc, ValueDecl *D, bool RefersToEnclosingVariableOrCapture, SourceLocation NameLoc, QualType T, ExprValueKind VK, NamedDecl *FoundD=nullptr, const TemplateArgumentListInfo *TemplateArgs=nullptr, NonOdrUseReason NOUR=NOUR_None)
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).
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.
bool isScoped() const
Returns true if this is a C++11 scoped enumeration.
EnumDecl * getDefinitionOrSelf() const
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(const 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.
bool EvaluateAsMandatedConstantExpr(EvalResult &Result, const ASTContext &Ctx, SemaProxy &SProxy, ConstantExprKind Kind=ConstantExprKind::Normal) const
Evaluate an expression that is required by the language to be a constant expression.
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.
@ 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.
For a defaulted function, the kind of defaulted function that it is.
CXXSpecialMemberKind asSpecialMember() const
bool isComparison() const
bool isSpecialMember() const
Represents a function declaration or definition.
bool isMultiVersion() const
True if this function is considered a multiversioned function.
const ParmVarDecl * getParamDecl(unsigned i) const
bool isFunctionTemplateSpecialization() const
Determine whether this function is a function template specialization.
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.
DefaultedFunctionKind getDefaultedFunctionKind() const
Determine the kind of defaulting that would be done for a given function.
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...
FunctionDecl * getInstantiatedFromMemberFunction() const
If this function is an instantiation of a member function of a class template specialization,...
unsigned getNumParams() const
Return the number of parameters this function must have based on its FunctionType.
bool willHaveBody() const
True if this function will eventually have a body, once it's fully parsed.
Represents a prototype with parameter type info, e.g.
ExtParameterInfo getExtParameterInfo(unsigned I) const
unsigned getNumParams() const
Qualifiers getMethodQuals() const
QualType getParamType(unsigned i) const
bool isVariadic() const
Whether this function prototype is variadic.
ArrayRef< QualType > param_types() const
Declaration of a template function.
FunctionDecl * getTemplatedDecl() const
Get the underlying function declaration of the template.
A class which abstracts out some details necessary for making a call.
ExtInfo withNoReturn(bool noReturn) const
ParameterABI getABI() const
Return the ABI treatment of this parameter.
FunctionType - C99 6.7.5.3 - Function Declarators.
ExtInfo getExtInfo() const
CallingConv getCallConv() const
QualType getReturnType() const
QualType getCallResultType(const ASTContext &Context) const
Determine the type of an expression that calls a function of this type.
static GenericSelectionExpr * Create(const ASTContext &Context, SourceLocation GenericLoc, Expr *ControllingExpr, ArrayRef< TypeSourceInfo * > AssocTypes, ArrayRef< Expr * > AssocExprs, SourceLocation DefaultLoc, SourceLocation RParenLoc, bool ContainsUnexpandedParameterPack, unsigned ResultIndex)
Create a non-result-dependent generic selection expression accepting an expression predicate.
One of these records is kept for each identifier that is lexed.
ImplicitCastExpr - Allows us to explicitly represent implicit type conversions, which have no direct ...
static ImplicitCastExpr * Create(const ASTContext &Context, QualType T, CastKind Kind, Expr *Operand, const CXXCastPath *BasePath, ExprValueKind Cat, FPOptionsOverride FPO)
ImplicitConversionSequence - Represents an implicit conversion sequence, which may be a standard conv...
void dump() const
dump - Print this implicit conversion sequence to standard error.
bool isUserDefined() const
@ StaticObjectArgumentConversion
StandardConversionSequence Standard
When ConversionKind == StandardConversion, provides the details of the standard conversion sequence.
void setBad(BadConversionSequence::FailureKind Failure, Expr *FromExpr, QualType ToType)
Sets this sequence as a bad conversion for an explicit argument.
UserDefinedConversionSequence UserDefined
When ConversionKind == UserDefinedConversion, provides the details of the user-defined conversion seq...
static ImplicitConversionSequence getNullptrToBool(QualType SourceType, QualType DestType, bool NeedLValToRVal)
Form an "implicit" conversion sequence from nullptr_t to bool, for a direct-initialization of a bool ...
AmbiguousConversionSequence Ambiguous
When ConversionKind == AmbiguousConversion, provides the details of the ambiguous conversion.
bool hasInitializerListContainerType() const
unsigned getKindRank() const
Return a ranking of the implicit conversion sequence kind, where smaller ranks represent better conve...
bool isInitializerListOfIncompleteArray() const
BadConversionSequence Bad
When ConversionKind == BadConversion, provides the details of the bad conversion.
QualType getInitializerListContainerType() const
void DiagnoseAmbiguousConversion(Sema &S, SourceLocation CaretLoc, const PartialDiagnostic &PDiag) const
Diagnoses an ambiguous conversion.
Describes an C or C++ initializer list.
bool hasDesignatedInit() const
Determine whether this initializer list contains a designated initializer.
bool hasOneInit() const
Whether getNumInitsWithEmbedExpanded() is 1, without walking the list.
SourceLocation getBeginLoc() const LLVM_READONLY
bool hasZeroInits() const
unsigned getNumInitsWithEmbedExpanded() const
getNumInits but if the list has an EmbedExpr inside includes full length of embedded data.
const Expr * getInit(unsigned Init) const
SourceLocation getEndLoc() const LLVM_READONLY
ArrayRef< Expr * > inits() const
Describes an entity that is being initialized.
static InitializedEntity InitializeTemporary(QualType Type)
Create the initialization entity for a temporary.
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.
DeclClass * getAsSingle() const
bool empty() const
Return true if no decls were found.
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...
UnresolvedSetImpl::iterator iterator
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.
SourceLocation getTemplateKeywordLoc() const
Retrieve the location of the template keyword preceding the member name, if any.
NestedNameSpecifierLoc getQualifierLoc() 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 hasExplicitTemplateArgs() const
Determines whether the member name was followed by an explicit template argument list.
bool hasQualifier() const
Determines whether this member expression actually had a C++ nested-name-specifier prior to the name ...
void copyTemplateArgumentsInto(TemplateArgumentListInfo &List) const
Copies the template arguments (if present) into the given structure.
bool performsVirtualDispatch(const LangOptions &LO) const
Returns true if virtual dispatch is performed.
SourceLocation getBeginLoc() const LLVM_READONLY
DeclarationNameInfo getMemberNameInfo() const
Retrieve the member declaration name info.
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.
Module * getTopLevelModule()
Retrieve the top-level module for this (sub)module, which may be this 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>::".
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.
bool shouldDeferTemplateArgumentDeduction(const Sema &S) const
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
@ 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.
@ CSK_CodeCompletion
When doing overload resolution during code completion, we want to show all viable candidates,...
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 withConst() const
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
RecordDecl * getDefinitionOrSelf() 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.
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.
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....
void LookupOverloadedUnaryOp(OverloadCandidateSet &CandidateSet, OverloadedOperatorKind Op, const UnresolvedSetImpl &Fns, ArrayRef< Expr * > Args, bool RequiresADL=true)
Perform lookup for an overloaded unary operator.
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.
bool IsOverflowBehaviorTypeConversion(QualType FromType, QualType ToType)
IsOverflowBehaviorTypeConversion - Determines whether the conversion from FromType to ToType necessar...
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)
Module * getCurrentModule() const
Get the module unit whose scope we are currently within.
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)
bool IsOverflowBehaviorTypePromotion(QualType FromType, QualType ToType)
IsOverflowBehaviorTypePromotion - Determines whether the conversion from FromType to ToType involves ...
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.
MultiExprArg getInitsWithEmbedExpanded(InitListExpr *ILE, SmallVectorImpl< Expr * > &Storage)
The initializers of ILE with each multi-element EmbedExpr split into one EmbedExpr per embedded eleme...
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.
NarrowingKind getNarrowingKind(ASTContext &Context, const Expr *Converted, APValue &ConstantValue, QualType &ConstantType, bool IgnoreFloatToIntegralConversion=false, bool AllowRelaxedEval=false) const
Check if this standard conversion sequence represents a narrowing conversion, according to C++11 [dcl...
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.
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.
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 isOverloadableType() const
Determines whether this is a type for which one can define an overloaded operator.
bool isObjCIdType() const
bool isMatrixType() const
bool isOverflowBehaviorType() const
bool isHLSLBuiltinPackedType() 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 isMetaInfoType() const
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
bool isScopedEnumeralType() const
Determine whether this type is a scoped enumeration type.
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.
PRESERVE_NONE bool Ret(InterpState &S)
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...
Top level wrappers for InstallAPI frontend operations.
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.
std::pair< unsigned, unsigned > getDepthAndIndex(const NamedDecl *ND)
Retrieve the depth and index of a template parameter.
OptionalUnsigned< unsigned > UnsignedOrNone
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_Packed_Type_Conversion
HLSL packed type conversion to and from uint.
@ 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.
TemplateSpecCandidateSetKind
ActionResult< CXXBaseSpecifier * > BaseResult
AssignConvertType
AssignConvertType - All of the 'assignment' semantic checks return this enum to indicate whether the ...
@ IncompatiblePointer
IncompatiblePointer - The assignment is between two pointers types that are not compatible,...
@ CompatiblePointerDiscardsQualifiers
CompatiblePointerDiscardsQualifiers - The assignment discards c/v/r qualifiers, which we accept as an...
@ Compatible
Compatible - the types are compatible according to the standard.
@ IncompatiblePointerSign
IncompatiblePointerSign - The assignment is between two pointers types which point to integers which ...
DeductionFailureInfo MakeDeductionFailureInfo(ASTContext &Context, TemplateDeductionResult TDK, sema::TemplateDeductionInfo &Info)
Convert from Sema's representation of template deduction information to the form used in overload-can...
@ FunctionTemplate
The name was classified as a function template name.
LangAS
Defines the address space values used by the address space qualifier of QualType.
CastKind
CastKind - The kind of operation required for a conversion.
CXXSpecialMemberKind
Kinds of C++ special members.
OverloadedOperatorKind getRewrittenOverloadedOperator(OverloadedOperatorKind Kind)
Get the other overloaded operator that the given operator can be rewritten into, if any such operator...
std::pair< SourceLocation, PartialDiagnostic > PartialDiagnosticAt
A partial diagnostic along with the source location where this diagnostic occurs.
ExprValueKind
The categorization of expression values, currently following the C++11 scheme.
@ VK_PRValue
A pr-value expression (in the C++11 taxonomy) produces a temporary value.
@ VK_XValue
An x-value expression is a reference to an object with independent storage but which can be "moved",...
@ VK_LValue
An l-value expression is a reference to an object with independent storage.
bool shouldEnforceArgLimit(bool PartialOverloading, FunctionDecl *Function)
SmallVector< CXXBaseSpecifier *, 4 > CXXCastPath
A simple array of base specifiers.
llvm::PointerUnion< TemplateTypeParmDecl *, NonTypeTemplateParmDecl *, TemplateTemplateParmDecl * > TemplateParameter
Stores a template parameter of any kind.
NarrowingKind
NarrowingKind - The kind of narrowing conversion being performed by a standard conversion sequence ac...
@ NK_Not_Narrowing
Not a narrowing conversion.
@ NK_Constant_Narrowing
A narrowing conversion, because a constant expression got narrowed.
@ NK_Dependent_Narrowing
Cannot tell whether this is a narrowing conversion because the expression is value-dependent.
@ NK_Type_Narrowing
A narrowing conversion by virtue of the source and destination types.
@ NK_Variable_Narrowing
A narrowing conversion, because a non-constant-expression variable might have got narrowed.
@ TPOC_Conversion
Partial ordering of function templates for a call to a conversion function.
@ TPOC_Call
Partial ordering of function templates for a function call.
bool declaresSameEntity(const Decl *D1, const Decl *D2)
Determine whether two declarations declare the same entity.
TemplateDeductionResult
Describes the result of template argument deduction.
@ MiscellaneousDeductionFailure
Deduction failed; that's all we know.
@ NonDependentConversionFailure
Checking non-dependent argument conversions failed.
@ ConstraintsNotSatisfied
The deduced arguments did not satisfy the constraints associated with the template.
@ Underqualified
Template argument deduction failed due to inconsistent cv-qualifiers on a template parameter type tha...
@ InstantiationDepth
Template argument deduction exceeded the maximum template instantiation depth (which has already been...
@ InvalidExplicitArguments
The explicitly-specified template arguments were not valid template arguments for the given template.
@ CUDATargetMismatch
CUDA Target attributes do not match.
@ TooFewArguments
When performing template argument deduction for a function template, there were too few call argument...
@ Incomplete
Template argument deduction did not deduce a value for every template parameter.
@ Invalid
The declaration was invalid; do nothing.
@ Success
Template argument deduction was successful.
@ SubstitutionFailure
Substitution of the deduced template argument values resulted in an error.
@ IncompletePack
Template argument deduction did not deduce a value for every expansion of an expanded template parame...
@ DeducedMismatch
After substituting deduced template arguments, a dependent parameter type did not match the correspon...
@ Inconsistent
Template argument deduction produced inconsistent deduced values for the given template parameter.
@ TooManyArguments
When performing template argument deduction for a function template, there were too many call argumen...
@ AlreadyDiagnosed
Some error which was already diagnosed.
@ DeducedMismatchNested
After substituting deduced template arguments, an element of a dependent parameter type did not match...
@ NonDeducedMismatch
A non-depnedent component of the parameter did not match the corresponding component of the argument.
@ TSK_ExplicitSpecialization
This template specialization was declared or defined by an explicit specialization (C++ [temp....
@ TSK_ImplicitInstantiation
This template specialization was implicitly instantiated from a template.
CallingConv
CallingConv - Specifies the calling convention that a function uses.
const char * getOperatorSpelling(OverloadedOperatorKind Operator)
Retrieve the spelling of the given overloaded operator, without the preceding "operator" keyword.
U cast(CodeGen::Address addr)
ConstructorInfo getConstructorInfo(NamedDecl *ND)
CCEKind
Contexts in which a converted constant expression is required.
@ TemplateArg
Value of a non-type template parameter.
@ Noexcept
Condition in a noexcept(bool) specifier.
@ ArrayBound
Array bound in array declarator or new-expression.
@ TempArgStrict
As above, but applies strict template checking rules.
@ PackIndex
Index of a pack indexing expression or specifier.
@ 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).
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...
SmallVectorImpl< PartialDiagnosticAt > * ExtendedDiag
Location where we spot ptr to int cast or null subobject while evaluating constant expression in MS c...
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...
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)
void NoteDeductionFailure(Sema &S, bool ForTakingAddress, TemplateSpecCandidateSetKind CandidateSetKind)
Diagnose a template argument deduction failure.
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.