41#include "llvm/ADT/DenseSet.h"
42#include "llvm/ADT/STLExtras.h"
43#include "llvm/ADT/STLForwardCompat.h"
44#include "llvm/ADT/ScopeExit.h"
45#include "llvm/ADT/SmallPtrSet.h"
46#include "llvm/ADT/SmallVector.h"
60 return P->hasAttr<PassObjectSizeAttr>();
84 NameInfo, Fn->getType(),
VK_LValue, FoundDecl,
86 if (HadMultipleCandidates)
87 DRE->setHadMultipleCandidates(
true);
93 DRE->setType(Fn->getType());
97 CK_FunctionToPointerDecay);
102 bool HadMultipleCandidates,
105 FoundDecl,
Base, HadMultipleCandidates, NameInfo,
111 bool HadMultipleCandidates,
118 bool InOverloadResolution,
121 bool AllowObjCWritebackConversion);
125 bool InOverloadResolution,
133 bool AllowObjCConversionOnExplicit);
202 return Rank[(int)Kind];
227 static const char *
const Name[] = {
231 "Function-to-pointer",
232 "Function pointer conversion",
234 "Integral promotion",
235 "Floating point promotion",
237 "Integral conversion",
238 "Floating conversion",
239 "Complex conversion",
240 "Floating-integral conversion",
241 "Pointer conversion",
242 "Pointer-to-member conversion",
243 "Boolean conversion",
244 "Compatible-types conversion",
245 "Derived-to-base conversion",
247 "SVE Vector conversion",
248 "RVV Vector conversion",
250 "Complex-real conversion",
251 "Block Pointer conversion",
252 "Transparent Union Conversion",
253 "Writeback conversion",
254 "OpenCL Zero Event Conversion",
255 "OpenCL Zero Queue Conversion",
256 "C specific type conversion",
257 "Incompatible pointer conversion",
258 "Fixed point conversion",
259 "HLSL vector truncation",
260 "HLSL matrix truncation",
261 "Non-decaying array conversion",
264 "HLSL packed type conversion",
340 FromType = Context.getArrayDecayedType(FromType);
352 const Expr *Converted) {
355 if (
auto *EWC = dyn_cast<ExprWithCleanups>(Converted)) {
362 while (
auto *ICE = dyn_cast<ImplicitCastExpr>(Converted)) {
363 switch (ICE->getCastKind()) {
365 case CK_IntegralCast:
366 case CK_IntegralToBoolean:
367 case CK_IntegralToFloating:
368 case CK_BooleanToSignedIntegral:
369 case CK_FloatingToIntegral:
370 case CK_FloatingToBoolean:
371 case CK_FloatingCast:
372 Converted = ICE->getSubExpr();
398 QualType &ConstantType,
bool IgnoreFloatToIntegralConversion,
399 bool AllowRelaxedEval)
const {
401 "narrowing check outside C++");
412 ToType = ED->getIntegerType();
418 goto FloatingIntegralConversion;
420 goto IntegralConversion;
431 FloatingIntegralConversion:
436 if (IgnoreFloatToIntegralConversion)
439 assert(
Initializer &&
"Unknown conversion expression");
445 if (std::optional<llvm::APSInt> IntConstantValue =
449 Result.convertFromAPInt(*IntConstantValue, IntConstantValue->isSigned(),
450 llvm::APFloat::rmNearestTiesToEven);
452 llvm::APSInt ConvertedValue = *IntConstantValue;
454 llvm::APFloat::opStatus Status =
Result.convertToInteger(
455 ConvertedValue, llvm::APFloat::rmTowardZero, &ignored);
458 if (Status == llvm::APFloat::opInvalidOp ||
459 *IntConstantValue != ConvertedValue) {
460 ConstantValue =
APValue(*IntConstantValue);
488 Initializer->isCXX11ConstantExpr(Ctx, ConstantValue,
489 AllowRelaxedEval)))) {
492 ConstantValue = R.Val;
493 assert(ConstantValue.
isFloat());
494 llvm::APFloat FloatVal = ConstantValue.
getFloat();
497 llvm::APFloat Converted = FloatVal;
498 llvm::APFloat::opStatus ConvertStatus =
500 llvm::APFloat::rmNearestTiesToEven, &ignored);
502 llvm::APFloat::rmNearestTiesToEven, &ignored);
504 if (FloatVal.isNaN() && Converted.isNaN() &&
505 !FloatVal.isSignaling() && !Converted.isSignaling()) {
511 if (!Converted.bitwiseIsEqual(FloatVal)) {
518 if (ConvertStatus & llvm::APFloat::opOverflow) {
540 IntegralConversion: {
548 constexpr auto CanRepresentAll = [](
bool FromSigned,
unsigned FromWidth,
549 bool ToSigned,
unsigned ToWidth) {
550 return (FromWidth < ToWidth + (FromSigned == ToSigned)) &&
551 !(FromSigned && !ToSigned);
554 if (CanRepresentAll(FromSigned, FromWidth, ToSigned, ToWidth))
560 bool DependentBitField =
false;
562 if (BitField->getBitWidth()->isValueDependent())
563 DependentBitField =
true;
564 else if (
unsigned BitFieldWidth = BitField->getBitWidthValue();
565 BitFieldWidth < FromWidth) {
566 if (CanRepresentAll(FromSigned, BitFieldWidth, ToSigned, ToWidth))
570 FromWidth = BitFieldWidth;
578 std::optional<llvm::APSInt> OptInitializerValue =
579 Initializer->getIntegerConstantExpr(Ctx, AllowRelaxedEval);
580 if (!OptInitializerValue) {
584 if (DependentBitField && !(FromSigned && !ToSigned))
590 llvm::APSInt &InitializerValue = *OptInitializerValue;
591 bool Narrowing =
false;
592 if (FromWidth < ToWidth) {
595 if (InitializerValue.isSigned() && InitializerValue.isNegative())
601 InitializerValue.extend(InitializerValue.getBitWidth() + 1);
603 llvm::APSInt ConvertedValue = InitializerValue;
604 ConvertedValue = ConvertedValue.trunc(ToWidth);
605 ConvertedValue.setIsSigned(ToSigned);
606 ConvertedValue = ConvertedValue.extend(InitializerValue.getBitWidth());
607 ConvertedValue.setIsSigned(InitializerValue.isSigned());
609 if (ConvertedValue != InitializerValue)
614 ConstantValue =
APValue(InitializerValue);
630 ConstantValue = R.Val;
631 assert(ConstantValue.
isFloat());
632 llvm::APFloat FloatVal = ConstantValue.
getFloat();
637 if (FloatVal.isNaN() && FloatVal.isSignaling()) {
653 raw_ostream &OS = llvm::errs();
654 bool PrintedSomething =
false;
657 PrintedSomething =
true;
661 if (PrintedSomething) {
667 OS <<
" (by copy constructor)";
669 OS <<
" (direct reference binding)";
671 OS <<
" (reference binding)";
673 PrintedSomething =
true;
677 if (PrintedSomething) {
681 PrintedSomething =
true;
684 if (!PrintedSomething) {
685 OS <<
"No conversions required";
692 raw_ostream &OS = llvm::errs();
700 OS <<
"aggregate initialization";
710 raw_ostream &OS = llvm::errs();
712 OS <<
"Worst list element conversion: ";
713 switch (ConversionKind) {
715 OS <<
"Standard conversion: ";
719 OS <<
"User-defined conversion: ";
723 OS <<
"Ellipsis conversion";
726 OS <<
"Ambiguous conversion";
729 OS <<
"Bad conversion";
754 struct DFIArguments {
760 struct DFIParamWithArguments : DFIArguments {
765 struct DFIDeducedMismatchArgs : DFIArguments {
766 TemplateArgumentList *TemplateArgs;
767 unsigned CallArgIndex;
772 TemplateArgumentList *TemplateArgs;
773 ConstraintSatisfaction Satisfaction;
784 Result.Result =
static_cast<unsigned>(TDK);
785 Result.HasDiagnostic =
false;
805 Result.HasDiagnostic =
true;
812 auto *Saved =
new (Context) DFIDeducedMismatchArgs;
823 DFIArguments *Saved =
new (Context) DFIArguments;
835 DFIParamWithArguments *Saved =
new (Context) DFIParamWithArguments;
836 Saved->Param = Info.
Param;
849 Result.HasDiagnostic =
true;
854 CNSInfo *Saved =
new (Context) CNSInfo;
864 llvm_unreachable(
"not a deduction failure");
897 Diag->~PartialDiagnosticAt();
904 static_cast<CNSInfo *
>(
Data)->Satisfaction.~ConstraintSatisfaction();
907 Diag->~PartialDiagnosticAt();
943 return TemplateParameter::getFromOpaqueValue(
Data);
948 return static_cast<DFIParamWithArguments*
>(
Data)->Param;
978 return static_cast<DFIDeducedMismatchArgs*
>(
Data)->TemplateArgs;
984 return static_cast<CNSInfo*
>(
Data)->TemplateArgs;
1016 return &
static_cast<DFIArguments*
>(
Data)->FirstArg;
1048 return &
static_cast<DFIArguments*
>(
Data)->SecondArg;
1063 return static_cast<DFIDeducedMismatchArgs*
>(
Data)->CallArgIndex;
1066 return std::nullopt;
1079 for (
unsigned I = 0; I <
X->getNumParams(); ++I)
1083 if (
auto *FTX =
X->getDescribedFunctionTemplate()) {
1088 FTY->getTemplateParameters()))
1097 OverloadedOperatorKind::OO_EqualEqual);
1109 OverloadedOperatorKind::OO_ExclaimEqual);
1127 auto *NotEqFD = Op->getAsFunction();
1128 if (
auto *UD = dyn_cast<UsingShadowDecl>(Op))
1129 NotEqFD = UD->getUnderlyingDecl()->getAsFunction();
1142 return Op == OO_EqualEqual || Op == OO_Spaceship;
1150 if (Op == OverloadedOperatorKind::OO_EqualEqual) {
1151 assert(OriginalArgs.size() == 2);
1153 S,
OpLoc, OriginalArgs[1], FD))
1164void OverloadCandidateSet::destroyCandidates() {
1165 for (
iterator i = Candidates.begin(), e = Candidates.end(); i != e; ++i) {
1166 for (
auto &
C : i->Conversions)
1167 C.~ImplicitConversionSequence();
1169 i->DeductionFailure.Destroy();
1174 destroyCandidates();
1175 SlabAllocator.Reset();
1176 NumInlineBytesUsed = 0;
1180 FirstDeferredCandidate =
nullptr;
1181 DeferredCandidatesCount = 0;
1182 HasDeferredTemplateConstructors =
false;
1183 ResolutionByPerfectCandidateIsDisabled =
false;
1187 class UnbridgedCastsSet {
1197 Entry entry = { &E, E };
1198 Entries.push_back(entry);
1203 for (SmallVectorImpl<Entry>::iterator
1204 i = Entries.begin(), e = Entries.end(); i != e; ++i)
1205 *i->Addr = i->Saved;
1219 UnbridgedCastsSet *unbridgedCasts =
nullptr) {
1223 if (placeholder->getKind() == BuiltinType::Overload)
return false;
1227 if (placeholder->getKind() == BuiltinType::ARCUnbridgedCast &&
1229 unbridgedCasts->save(S, E);
1249 UnbridgedCastsSet &unbridged) {
1250 for (
unsigned i = 0, e = Args.size(); i != e; ++i)
1259 bool NewIsUsingDecl) {
1264 bool OldIsUsingDecl =
false;
1266 OldIsUsingDecl =
true;
1270 if (NewIsUsingDecl)
continue;
1277 if ((OldIsUsingDecl || NewIsUsingDecl) && !
isVisible(*I))
1285 bool UseMemberUsingDeclRules =
1286 (OldIsUsingDecl || NewIsUsingDecl) &&
CurContext->isRecord() &&
1287 !
New->getFriendObjectKind();
1291 if (UseMemberUsingDeclRules && OldIsUsingDecl) {
1297 !shouldLinkPossiblyHiddenDecl(*I,
New))
1316 }
else if (
auto *UUD = dyn_cast<UnresolvedUsingValueDecl>(OldD)) {
1323 if (UUD->getQualifier().isDependent() && !UUD->isCXXClassMember()) {
1351 if (
New->getFriendObjectKind() &&
New->getQualifier() &&
1352 !
New->getDescribedFunctionTemplate() &&
1353 !
New->getDependentSpecializationInfo() &&
1354 !
New->getType()->isDependentType()) {
1359 New->setInvalidDecl();
1371 assert(D &&
"function decl should not be null");
1372 if (
auto *A = D->
getAttr<AttrT>())
1373 return !A->isImplicit();
1379 bool UseMemberUsingDeclRules,
1380 bool ConsiderCudaAttrs,
1381 bool UseOverrideRules =
false) {
1387 if (
New->isMSVCRTEntryPoint())
1398 if ((OldTemplate ==
nullptr) != (NewTemplate ==
nullptr))
1421 if (OldQType != NewQType && OldType->isVariadic() != NewType->isVariadic())
1425 if ((
New->isMemberLikeConstrainedFriend() ||
1436 OldDecl = OldTemplate;
1437 NewDecl = NewTemplate;
1455 bool ConstraintsInTemplateHead =
1466 if (UseMemberUsingDeclRules && ConstraintsInTemplateHead &&
1467 !SameTemplateParameterList)
1469 if (!UseMemberUsingDeclRules &&
1470 (!SameTemplateParameterList || !SameReturnType))
1474 const auto *OldMethod = dyn_cast<CXXMethodDecl>(Old);
1475 const auto *NewMethod = dyn_cast<CXXMethodDecl>(
New);
1477 int OldParamsOffset = 0;
1478 int NewParamsOffset = 0;
1486 if (ThisType.isConstQualified())
1506 BS.
Quals = NormalizeQualifiers(OldMethod, BS.
Quals);
1507 DS.Quals = NormalizeQualifiers(NewMethod, DS.Quals);
1509 if (OldMethod->isExplicitObjectMemberFunction()) {
1511 DS.Quals.removeVolatile();
1514 return BS.
Quals == DS.Quals;
1518 auto BS =
Base.getNonReferenceType().getCanonicalType().split();
1519 auto DS = D.getNonReferenceType().getCanonicalType().split();
1521 if (!AreQualifiersEqual(BS, DS))
1524 if (OldMethod->isImplicitObjectMemberFunction() &&
1525 OldMethod->getParent() != NewMethod->getParent()) {
1537 if (
Base->isLValueReferenceType())
1538 return D->isLValueReferenceType();
1539 return Base->isRValueReferenceType() == D->isRValueReferenceType();
1544 auto DiagnoseInconsistentRefQualifiers = [&]() {
1545 if (SemaRef.
LangOpts.CPlusPlus23 && !UseOverrideRules)
1547 if (OldMethod->getRefQualifier() == NewMethod->getRefQualifier())
1549 if (OldMethod->isExplicitObjectMemberFunction() ||
1550 NewMethod->isExplicitObjectMemberFunction())
1552 if (!UseMemberUsingDeclRules && (OldMethod->getRefQualifier() ==
RQ_None ||
1553 NewMethod->getRefQualifier() ==
RQ_None)) {
1554 SemaRef.
Diag(NewMethod->getLocation(), diag::err_ref_qualifier_overload)
1555 << OldMethod->getRefQualifier() << NewMethod->getRefQualifier();
1556 SemaRef.
Diag(OldMethod->getLocation(), diag::note_previous_declaration);
1565 bool ShouldDiagnoseInconsistentRefQualifiers =
false;
1566 bool HaveInconsistentQualifiers =
false;
1568 if (OldMethod && OldMethod->isExplicitObjectMemberFunction())
1570 if (NewMethod && NewMethod->isExplicitObjectMemberFunction())
1573 if (OldType->getNumParams() - OldParamsOffset !=
1574 NewType->getNumParams() - NewParamsOffset ||
1576 {OldType->param_type_begin() + OldParamsOffset,
1577 OldType->param_type_end()},
1578 {NewType->param_type_begin() + NewParamsOffset,
1579 NewType->param_type_end()},
1584 if (OldMethod && NewMethod && !OldMethod->isStatic() &&
1585 !NewMethod->isStatic()) {
1586 bool HaveCorrespondingObjectParameters = [&](
const CXXMethodDecl *Old,
1588 auto NewObjectType =
New->getFunctionObjectParameterReferenceType();
1592 return F->getRefQualifier() ==
RQ_None &&
1593 !F->isExplicitObjectMemberFunction();
1596 if (IsImplicitWithNoRefQual(Old) != IsImplicitWithNoRefQual(
New) &&
1597 CompareType(OldObjectType.getNonReferenceType(),
1598 NewObjectType.getNonReferenceType()))
1600 return CompareType(OldObjectType, NewObjectType);
1601 }(OldMethod, NewMethod);
1603 if (!HaveCorrespondingObjectParameters) {
1604 ShouldDiagnoseInconsistentRefQualifiers =
true;
1608 if (!UseOverrideRules || (!NewMethod->isExplicitObjectMemberFunction() &&
1609 !OldMethod->isExplicitObjectMemberFunction()))
1610 HaveInconsistentQualifiers =
true;
1614 if (NewMethod && OldMethod && OldMethod->isImplicitObjectMemberFunction() &&
1615 NewMethod->isImplicitObjectMemberFunction())
1616 ShouldDiagnoseInconsistentRefQualifiers =
true;
1618 if (!UseOverrideRules &&
1622 if (!NewRC != !OldRC)
1642 NewI =
New->specific_attr_begin<EnableIfAttr>(),
1643 NewE =
New->specific_attr_end<EnableIfAttr>(),
1646 NewI != NewE || OldI != OldE; ++NewI, ++OldI) {
1647 if (NewI == NewE || OldI == OldE)
1649 llvm::FoldingSetNodeID NewID, OldID;
1650 NewI->getCond()->Profile(NewID, SemaRef.
Context,
true);
1651 OldI->getCond()->Profile(OldID, SemaRef.
Context,
true);
1656 if ((ShouldDiagnoseInconsistentRefQualifiers &&
1657 DiagnoseInconsistentRefQualifiers()) ||
1658 HaveInconsistentQualifiers)
1662 if (SemaRef.
getLangOpts().CUDA && ConsiderCudaAttrs) {
1670 "Unexpected invalid target.");
1674 if (NewTarget != OldTarget) {
1677 if (OldMethod && NewMethod && OldMethod->isVirtual() &&
1678 OldMethod->isConstexpr() && !NewMethod->isConstexpr() &&
1696 bool UseMemberUsingDeclRules,
bool ConsiderCudaAttrs) {
1702 bool UseMemberUsingDeclRules,
bool ConsiderCudaAttrs) {
1715 bool SuppressUserConversions,
1717 bool InOverloadResolution,
1719 bool AllowObjCWritebackConversion,
1720 bool AllowObjCConversionOnExplicit) {
1723 if (SuppressUserConversions) {
1734 Conversions, AllowExplicit,
1735 AllowObjCConversionOnExplicit)) {
1756 bool FromListInit =
false;
1757 if (
const auto *InitList = dyn_cast<InitListExpr>(From);
1758 InitList && InitList->getNumInits() == 1 &&
1760 const Expr *SingleInit = InitList->getInit(0);
1761 FromType = SingleInit->
getType();
1763 FromListInit =
true;
1772 if ((FromCanon == ToCanon ||
1784 if (ToCanon != FromCanon)
1795 Cand != Conversions.
end(); ++Cand)
1836static ImplicitConversionSequence
1838 bool SuppressUserConversions,
1840 bool InOverloadResolution,
1842 bool AllowObjCWritebackConversion,
1843 bool AllowObjCConversionOnExplicit) {
1846 ICS.
Standard, CStyle, AllowObjCWritebackConversion)){
1897 bool CanConvert =
false;
1903 FromResType->getWrappedType()) &&
1905 FromResType->getContainedType()) &&
1906 ToResType->getAttrs() == FromResType->getAttrs())
1908 }
else if (ToTy->isHLSLResourceType()) {
1922 AllowExplicit, InOverloadResolution, CStyle,
1923 AllowObjCWritebackConversion,
1924 AllowObjCConversionOnExplicit);
1927ImplicitConversionSequence
1929 bool SuppressUserConversions,
1931 bool InOverloadResolution,
1933 bool AllowObjCWritebackConversion) {
1934 return ::TryImplicitConversion(*
this, From, ToType, SuppressUserConversions,
1935 AllowExplicit, InOverloadResolution, CStyle,
1936 AllowObjCWritebackConversion,
1942 bool AllowExplicit) {
1947 bool AllowObjCWritebackConversion =
1954 *
this, From, ToType,
1956 AllowExplicit ? AllowedExplicit::All : AllowedExplicit::None,
1958 false, AllowObjCWritebackConversion,
1972 if (
Context.hasSameUnqualifiedType(FromType, ToType))
1985 if (TyClass != CanFrom->getTypeClass())
return false;
1986 if (TyClass != Type::FunctionProto && TyClass != Type::FunctionNoProto) {
1987 if (TyClass == Type::Pointer) {
1990 }
else if (TyClass == Type::BlockPointer) {
1993 }
else if (TyClass == Type::MemberPointer) {
2000 CanTo = ToMPT->getPointeeType();
2006 TyClass = CanTo->getTypeClass();
2007 if (TyClass != CanFrom->getTypeClass())
return false;
2008 if (TyClass != Type::FunctionProto && TyClass != Type::FunctionNoProto)
2018 bool Changed =
false;
2026 const auto *FromFPT = dyn_cast<FunctionProtoType>(FromFn);
2027 const auto *ToFPT = dyn_cast<FunctionProtoType>(ToFn);
2029 if (FromFPT && ToFPT) {
2030 if (FromFPT->hasCFIUncheckedCallee() != ToFPT->hasCFIUncheckedCallee()) {
2032 FromFPT->getReturnType(), FromFPT->getParamTypes(),
2033 FromFPT->getExtProtoInfo().withCFIUncheckedCallee(
2034 ToFPT->hasCFIUncheckedCallee()));
2042 if (FromFPT && ToFPT) {
2043 if (FromFPT->isNothrow() && !ToFPT->isNothrow()) {
2055 bool CanUseToFPT, CanUseFromFPT;
2056 if (
Context.mergeExtParameterInfo(ToFPT, FromFPT, CanUseToFPT,
2057 CanUseFromFPT, NewParamInfos) &&
2058 CanUseToFPT && !CanUseFromFPT) {
2061 NewParamInfos.empty() ?
nullptr : NewParamInfos.data();
2063 FromFPT->getParamTypes(), ExtInfo);
2068 if (
Context.hasAnyFunctionEffects()) {
2073 const auto FromFX = FromFPT->getFunctionEffects();
2074 const auto ToFX = ToFPT->getFunctionEffects();
2075 if (FromFX != ToFX) {
2079 FromFPT->getReturnType(), FromFPT->getParamTypes(), ExtInfo);
2089 assert(
QualType(FromFn, 0).isCanonical());
2090 if (
QualType(FromFn, 0) != CanTo)
return false;
2117 if ((&FromSem == &llvm::APFloat::PPCDoubleDouble() &&
2118 &ToSem == &llvm::APFloat::IEEEquad()) ||
2119 (&FromSem == &llvm::APFloat::IEEEquad() &&
2120 &ToSem == &llvm::APFloat::PPCDoubleDouble()))
2176 bool InOverloadResolution,
bool CStyle) {
2186 if (ToMatrixType && FromMatrixType) {
2188 unsigned ToCols = ToMatrixType->getNumColumns();
2189 if (FromCols < ToCols)
2192 unsigned FromRows = FromMatrixType->
getNumRows();
2193 unsigned ToRows = ToMatrixType->getNumRows();
2194 if (FromRows < ToRows)
2197 if (FromRows == ToRows && FromCols == ToCols)
2203 QualType ToElTy = ToMatrixType->getElementType();
2212 QualType ToElTy = ToMatrixType->getElementType();
2215 if (FromMatrixType && !ToMatrixType) {
2234 bool InOverloadResolution,
bool CStyle) {
2251 if (ToExtType && FromExtType) {
2253 unsigned ToElts = ToExtType->getNumElements();
2254 if (FromElts < ToElts)
2256 if (FromElts == ToElts)
2262 QualType ToElTy = ToExtType->getElementType();
2267 if (FromExtType && !ToExtType) {
2281 if (ToExtType->getNumElements() != FromExtType->getNumElements())
2286 FromExtType->getElementType()->isIntegerType()) {
2298 QualType ToElTy = ToExtType->getElementType();
2333 !ToType->
hasAttr(attr::ArmMveStrictPolymorphism))) {
2338 !InOverloadResolution && !CStyle) {
2340 << FromType << ToType;
2363 if (FromPacked && ToPacked) {
2372 if (FromPacked && !ToIsUint)
2376 if (ToPacked && !FromIsUint)
2380 if (FromIsUint || ToIsUint) {
2390 bool InOverloadResolution,
2391 StandardConversionSequence &SCS,
2396 bool InOverloadResolution,
2397 StandardConversionSequence &SCS,
2409 bool InOverloadResolution,
2412 bool AllowObjCWritebackConversion) {
2438 FromType = Fn->getType();
2458 if (Method && !Method->isStatic() &&
2459 !Method->isExplicitObjectMemberFunction()) {
2461 "Non-unary operator on non-static member address");
2464 "Non-address-of operator on non-static member address");
2466 FromType, std::nullopt, Method->getParent());
2470 "Non-address-of operator for overloaded function expression");
2516 FromType =
Atomic->getValueType();
2551 if (
auto *FD = dyn_cast<FunctionDecl>(DRE->getDecl()))
2571 bool IncompatibleObjC =
false;
2633 }
else if (AllowObjCWritebackConversion &&
2637 FromType, IncompatibleObjC)) {
2643 InOverloadResolution, FromType)) {
2647 From, InOverloadResolution, CStyle)) {
2652 From, InOverloadResolution, CStyle)) {
2657 DimensionICK, From)) {
2667 S, From, ToType, InOverloadResolution, SCS, CStyle)) {
2676 S, From, ToType, InOverloadResolution, SCS, CStyle)) {
2706 bool ObjCLifetimeConversion;
2712 ObjCLifetimeConversion)) {
2731 CanonFrom = CanonTo;
2736 if (CanonFrom == CanonTo)
2741 if (S.
getLangOpts().CPlusPlus || !InOverloadResolution)
2753 case AssignConvertType::
2754 CompatibleVoidPtrToNonVoidPtr:
2787 bool InOverloadResolution,
2796 if (!UD->
hasAttr<TransparentUnionAttr>())
2799 for (
const auto *it : UD->
fields()) {
2802 ToType = it->getType();
2828 return To->
getKind() == BuiltinType::Int;
2831 return To->
getKind() == BuiltinType::UInt;
2855 if (FromED->isScoped())
2862 if (FromED->isFixed()) {
2863 QualType Underlying = FromED->getIntegerType();
2864 return Context.hasSameUnqualifiedType(Underlying, ToType) ||
2871 return Context.hasSameUnqualifiedType(ToType, FromED->getPromotionType());
2896 uint64_t FromSize =
Context.getTypeSize(FromType);
2905 for (
int Idx = 0; Idx < 6; ++Idx) {
2906 uint64_t ToSize =
Context.getTypeSize(PromoteTypes[Idx]);
2907 if (FromSize < ToSize ||
2908 (FromSize == ToSize &&
2909 FromIsSigned == PromoteTypes[Idx]->isSignedIntegerType())) {
2913 return Context.hasSameUnqualifiedType(ToType, PromoteTypes[Idx]);
2934 std::optional<llvm::APSInt> BitWidth;
2937 MemberDecl->getBitWidth()->getIntegerConstantExpr(
Context))) {
2938 llvm::APSInt ToSize(BitWidth->getBitWidth(), BitWidth->isUnsigned());
2939 ToSize =
Context.getTypeSize(ToType);
2942 if (*BitWidth < ToSize ||
2944 return To->
getKind() == BuiltinType::Int;
2950 return To->
getKind() == BuiltinType::UInt;
2968 return Context.getTypeSize(FromType) <
Context.getTypeSize(ToType);
2978 if (FromBuiltin->getKind() == BuiltinType::Float &&
2979 ToBuiltin->getKind() == BuiltinType::Double)
2986 (FromBuiltin->getKind() == BuiltinType::Float ||
2987 FromBuiltin->getKind() == BuiltinType::Double) &&
2988 (ToBuiltin->getKind() == BuiltinType::LongDouble ||
2989 ToBuiltin->getKind() == BuiltinType::Float128 ||
2990 ToBuiltin->getKind() == BuiltinType::Ibm128))
2995 if (
getLangOpts().
HLSL && FromBuiltin->getKind() == BuiltinType::Half &&
2996 (ToBuiltin->getKind() == BuiltinType::Float ||
2997 ToBuiltin->getKind() == BuiltinType::Double))
3002 FromBuiltin->getKind() == BuiltinType::Half &&
3003 ToBuiltin->getKind() == BuiltinType::Float)
3032 return Context.getTypeSize(FromType) <
Context.getTypeSize(ToType);
3044 if (
const EnumType *ToEnumType = ToType->
getAs<EnumType>()) {
3056 return Context.getTypeSize(FromType) >
Context.getTypeSize(ToType);
3071 bool StripObjCLifetime =
false) {
3074 "Invalid similarly-qualified pointer type");
3085 if (StripObjCLifetime)
3097 return Context.getObjCObjectPointerType(ToPointee);
3098 return Context.getPointerType(ToPointee);
3106 return Context.getObjCObjectPointerType(QualifiedCanonToPointee);
3107 return Context.getPointerType(QualifiedCanonToPointee);
3111 bool InOverloadResolution,
3117 return !InOverloadResolution;
3125 bool InOverloadResolution,
3127 bool &IncompatibleObjC) {
3128 IncompatibleObjC =
false;
3136 ConvertedType = ToType;
3143 ConvertedType = ToType;
3150 ConvertedType = ToType;
3158 ConvertedType = ToType;
3168 ConvertedType = ToType;
3190 if (
Context.hasSameUnqualifiedType(FromPointeeType, ToPointeeType))
3217 Context.typesAreCompatible(FromPointeeType, ToPointeeType)) {
3239 !
Context.hasSameUnqualifiedType(FromPointeeType, ToPointeeType) &&
3248 Context.areCompatibleVectorTypes(FromPointeeType, ToPointeeType)) {
3267 return Context.getQualifiedType(
T, Qs);
3269 return Context.getQualifiedType(
T.getUnqualifiedType(), Qs);
3274 bool &IncompatibleObjC) {
3287 if (ToObjCPtr && FromObjCPtr) {
3295 if (
Context.canAssignObjCInterfaces(ToObjCPtr, FromObjCPtr)) {
3309 if (
Context.canAssignObjCInterfaces(FromObjCPtr, ToObjCPtr)) {
3313 IncompatibleObjC =
true;
3329 if (FromObjCPtr && FromObjCPtr->isObjCBuiltinType()) {
3358 IncompatibleObjC)) {
3360 IncompatibleObjC =
true;
3361 ConvertedType =
Context.getPointerType(ConvertedType);
3370 IncompatibleObjC)) {
3372 ConvertedType =
Context.getPointerType(ConvertedType);
3385 if (FromFunctionType && ToFunctionType) {
3388 if (
Context.getCanonicalType(FromPointeeType)
3389 ==
Context.getCanonicalType(ToPointeeType))
3394 if (FromFunctionType->
getNumParams() != ToFunctionType->getNumParams() ||
3395 FromFunctionType->
isVariadic() != ToFunctionType->isVariadic() ||
3396 FromFunctionType->
getMethodQuals() != ToFunctionType->getMethodQuals())
3399 bool HasObjCConversion =
false;
3401 Context.getCanonicalType(ToFunctionType->getReturnType())) {
3404 ToFunctionType->getReturnType(),
3405 ConvertedType, IncompatibleObjC)) {
3407 HasObjCConversion =
true;
3414 for (
unsigned ArgIdx = 0, NumArgs = FromFunctionType->
getNumParams();
3415 ArgIdx != NumArgs; ++ArgIdx) {
3417 QualType ToArgType = ToFunctionType->getParamType(ArgIdx);
3418 if (
Context.getCanonicalType(FromArgType)
3419 ==
Context.getCanonicalType(ToArgType)) {
3422 ConvertedType, IncompatibleObjC)) {
3424 HasObjCConversion =
true;
3431 if (HasObjCConversion) {
3435 IncompatibleObjC =
true;
3467 if (!FromFunctionType || !ToFunctionType)
3470 if (
Context.hasSameType(FromPointeeType, ToPointeeType))
3475 if (FromFunctionType->
getNumParams() != ToFunctionType->getNumParams() ||
3476 FromFunctionType->
isVariadic() != ToFunctionType->isVariadic())
3481 if (FromEInfo != ToEInfo)
3484 bool IncompatibleObjC =
false;
3486 ToFunctionType->getReturnType())) {
3490 QualType LHS = ToFunctionType->getReturnType();
3495 if (
Context.hasSameType(RHS,LHS)) {
3498 ConvertedType, IncompatibleObjC)) {
3499 if (IncompatibleObjC)
3508 for (
unsigned ArgIdx = 0, NumArgs = FromFunctionType->
getNumParams();
3509 ArgIdx != NumArgs; ++ArgIdx) {
3510 IncompatibleObjC =
false;
3512 QualType ToArgType = ToFunctionType->getParamType(ArgIdx);
3513 if (
Context.hasSameType(FromArgType, ToArgType)) {
3516 ConvertedType, IncompatibleObjC)) {
3517 if (IncompatibleObjC)
3526 bool CanUseToFPT, CanUseFromFPT;
3527 if (!
Context.mergeExtParameterInfo(ToFunctionType, FromFunctionType,
3528 CanUseToFPT, CanUseFromFPT,
3532 ConvertedType = ToType;
3571 ToMember->getMostRecentCXXRecordDecl())) {
3573 if (ToMember->isSugared())
3575 ToMember->getMostRecentCXXRecordDecl());
3577 PDiag << ToMember->getQualifier();
3578 if (FromMember->isSugared())
3580 FromMember->getMostRecentCXXRecordDecl());
3582 PDiag << FromMember->getQualifier();
3600 !FromType->
getAs<TemplateSpecializationType>()) {
3606 if (
Context.hasSameType(FromType, ToType)) {
3615 if (!FromFunction || !ToFunction) {
3620 if (FromFunction->
getNumParams() != ToFunction->getNumParams()) {
3630 << ToFunction->getParamType(ArgPos)
3637 ToFunction->getReturnType())) {
3643 if (FromFunction->
getMethodQuals() != ToFunction->getMethodQuals()) {
3666 assert(llvm::size(Old) == llvm::size(
New) &&
3667 "Can't compare parameters of functions with different number of "
3670 for (
auto &&[Idx,
Type] : llvm::enumerate(Old)) {
3672 size_t J =
Reversed ? (llvm::size(
New) - Idx - 1) : Idx;
3677 Context.removePtrSizeAddrSpace(
Type.getUnqualifiedType());
3679 Context.removePtrSizeAddrSpace((
New.begin() + J)->getUnqualifiedType());
3681 if (!
Context.hasSameType(OldType, NewType)) {
3706 unsigned OldIgnore =
3708 unsigned NewIgnore =
3715 NewPT->param_types().slice(NewIgnore),
3722 bool IgnoreBaseAccess,
3725 bool IsCStyleOrFunctionalCast = IgnoreBaseAccess;
3734 PDiag(diag::warn_impcast_bool_to_null_pointer)
3745 if (FromPointeeType->
isRecordType() && ToPointeeType->isRecordType() &&
3746 !
Context.hasSameUnqualifiedType(FromPointeeType, ToPointeeType)) {
3749 unsigned InaccessibleID = 0;
3750 unsigned AmbiguousID = 0;
3752 InaccessibleID = diag::err_upcast_to_inaccessible_base;
3753 AmbiguousID = diag::err_ambiguous_derived_to_base_conv;
3756 FromPointeeType, ToPointeeType, InaccessibleID, AmbiguousID,
3758 &BasePath, IgnoreBaseAccess))
3762 Kind = CK_DerivedToBase;
3765 if (
Diagnose && !IsCStyleOrFunctionalCast &&
3766 FromPointeeType->
isFunctionType() && ToPointeeType->isVoidType()) {
3768 "this should only be possible with MSVCCompat!");
3780 if (FromPtrType->isObjCBuiltinType() || ToPtrType->isObjCBuiltinType())
3783 Kind = CK_BlockPointerToObjCPointerCast;
3785 Kind = CK_CPointerToObjCPointerCast;
3789 Kind = CK_AnyPointerToBlockPointerCast;
3795 Kind = CK_NullToPointer;
3802 bool InOverloadResolution,
3812 ConvertedType = ToType;
3828 ConvertedType =
Context.getMemberPointerType(
3842 if (
Context.getTargetInfo().getCXXABI().isMicrosoft()) {
3850 Kind = CK_NullToMemberPointer;
3868 PD <<
Context.getCanonicalTagType(Cls);
3878 std::swap(
Base, Derived);
3887 PD <<
int(Direction);
3895 DiagFromTo(PD) <<
QualType(VBase, 0) << OpRange;
3903 ? CK_DerivedToBaseMemberPointer
3904 : CK_BaseToDerivedMemberPointer;
3906 if (!IgnoreBaseAccess)
3910 ? diag::err_upcast_to_inaccessible_base
3911 : diag::err_downcast_from_inaccessible_base,
3913 NestedNameSpecifier BaseQual = FromPtrType->getQualifier(),
3914 DerivedQual = ToPtrType->getQualifier();
3915 if (Direction == MemberPointerConversionDirection::Upcast)
3916 std::swap(BaseQual, DerivedQual);
3917 DiagCls(PD, DerivedQual, Derived);
3918 DiagCls(PD, BaseQual, Base);
3953 bool CStyle,
bool IsTopLevel,
3954 bool &PreviousToQualsIncludeConst,
3955 bool &ObjCLifetimeConversion,
3968 ObjCLifetimeConversion =
true;
4008 !PreviousToQualsIncludeConst)
4026 PreviousToQualsIncludeConst =
4027 PreviousToQualsIncludeConst && ToQuals.
hasConst();
4033 bool CStyle,
bool &ObjCLifetimeConversion) {
4034 FromType =
Context.getCanonicalType(FromType);
4035 ToType =
Context.getCanonicalType(ToType);
4036 ObjCLifetimeConversion =
false;
4046 bool PreviousToQualsIncludeConst =
true;
4047 bool UnwrappedAnyPointer =
false;
4048 while (
Context.UnwrapSimilarTypes(FromType, ToType)) {
4050 !UnwrappedAnyPointer,
4051 PreviousToQualsIncludeConst,
4054 UnwrappedAnyPointer =
true;
4062 return UnwrappedAnyPointer &&
Context.hasSameUnqualifiedType(FromType,ToType);
4071 bool InOverloadResolution,
4080 InOverloadResolution, InnerSCS,
4095 bool InOverloadResolution,
4098 const OverflowBehaviorType *ToOBT = ToType->
getAs<OverflowBehaviorType>();
4109 InOverloadResolution, InnerSCS, CStyle,
4126 if (CtorType->getNumParams() > 0) {
4127 QualType FirstArg = CtorType->getParamType(0);
4139 bool AllowExplicit) {
4146 bool Usable = !Info.Constructor->isInvalidDecl() &&
4149 bool SuppressUserConversions =
false;
4150 if (Info.ConstructorTmpl)
4153 CandidateSet, SuppressUserConversions,
4158 CandidateSet, SuppressUserConversions,
4159 false, AllowExplicit);
4163 bool HadMultipleCandidates = (CandidateSet.
size() > 1);
4190 llvm_unreachable(
"Invalid OverloadResult!");
4212 bool AllowObjCConversionOnExplicit) {
4213 assert(AllowExplicit != AllowedExplicit::None ||
4214 !AllowObjCConversionOnExplicit);
4218 bool ConstructorsOnly =
false;
4222 if (
const RecordType *ToRecordType = ToType->
getAsCanonical<RecordType>()) {
4234 ConstructorsOnly =
true;
4238 }
else if (
auto *ToRecordDecl =
4239 dyn_cast<CXXRecordDecl>(ToRecordType->getDecl())) {
4240 ToRecordDecl = ToRecordDecl->getDefinitionOrSelf();
4242 Expr **Args = &From;
4243 unsigned NumArgs = 1;
4244 bool ListInitializing =
false;
4245 if (
InitListExpr *InitList = dyn_cast<InitListExpr>(From)) {
4248 S, From, ToType, ToRecordDecl, User, CandidateSet,
4249 AllowExplicit == AllowedExplicit::All);
4258 Args = InitList->getInits();
4259 NumArgs = InitList->getNumInits();
4260 ListInitializing =
true;
4268 bool Usable = !Info.Constructor->isInvalidDecl();
4269 if (!ListInitializing)
4270 Usable = Usable && Info.Constructor->isConvertingConstructor(
4273 bool SuppressUserConversions = !ConstructorsOnly;
4281 if (SuppressUserConversions && ListInitializing) {
4282 SuppressUserConversions =
4287 if (Info.ConstructorTmpl)
4289 Info.ConstructorTmpl, Info.FoundDecl,
4291 CandidateSet, SuppressUserConversions,
4293 AllowExplicit == AllowedExplicit::All);
4299 SuppressUserConversions,
4301 AllowExplicit == AllowedExplicit::All);
4311 }
else if (
const RecordType *FromRecordType =
4313 if (
auto *FromRecordDecl =
4314 dyn_cast<CXXRecordDecl>(FromRecordType->getDecl())) {
4315 FromRecordDecl = FromRecordDecl->getDefinitionOrSelf();
4317 const auto &Conversions = FromRecordDecl->getVisibleConversionFunctions();
4318 for (
auto I = Conversions.begin(), E = Conversions.end(); I != E; ++I) {
4327 if ((ConvTemplate = dyn_cast<FunctionTemplateDecl>(D)))
4334 ConvTemplate, FoundDecl, ActingContext, From, ToType,
4335 CandidateSet, AllowObjCConversionOnExplicit,
4336 AllowExplicit != AllowedExplicit::None);
4339 CandidateSet, AllowObjCConversionOnExplicit,
4340 AllowExplicit != AllowedExplicit::None);
4345 bool HadMultipleCandidates = (CandidateSet.
size() > 1);
4354 = dyn_cast<CXXConstructorDecl>(Best->Function)) {
4366 if (Best->Conversions[0].isEllipsis())
4369 User.
Before = Best->Conversions[0].Standard;
4382 = dyn_cast<CXXConversionDecl>(Best->Function)) {
4384 assert(Best->HasFinalConversion);
4392 User.
Before = Best->Conversions[0].Standard;
4407 User.
After = Best->FinalConversion;
4410 llvm_unreachable(
"Not a constructor or conversion function?");
4419 llvm_unreachable(
"Invalid OverloadResult!");
4429 CandidateSet, AllowedExplicit::None,
false);
4444 diag::err_typecheck_nonviable_condition_incomplete,
4451 *
this, From, Cands);
4477 if (!Conv1 || !Conv2)
4492 if (Block1 != Block2)
4505 if (Conv1FuncRet && Conv2FuncRet &&
4516 CallOpProto->isVariadic(),
false);
4518 CallOpProto->isVariadic(),
true);
4520 CallingConv PrefOrder[] = {DefaultFree, DefaultMember, CallOpCC};
4615 if (!ICS1.
isBad()) {
4616 bool StdInit1 =
false, StdInit2 =
false;
4623 if (StdInit1 != StdInit2)
4634 CAT2->getElementType())) {
4636 if (CAT1->getSize() != CAT2->getSize())
4638 return CAT1->getSize().ult(CAT2->getSize())
4673 if (ConvFunc1 == ConvFunc2)
4775 if (!
Enum->isFixed())
4811 else if (Rank2 < Rank1)
4846 bool SCS1ConvertsToVoid
4848 bool SCS2ConvertsToVoid
4850 if (SCS1ConvertsToVoid != SCS2ConvertsToVoid) {
4855 }
else if (!SCS1ConvertsToVoid && !SCS2ConvertsToVoid) {
4861 }
else if (SCS1ConvertsToVoid && SCS2ConvertsToVoid &&
4890 if (FromObjCPtr1 && FromObjCPtr2) {
4895 if (AssignLeft != AssignRight) {
4934 if (UnqualT1 == UnqualT2) {
4996 if (SCS1IsCompatibleVectorConversion != SCS2IsCompatibleVectorConversion)
4997 return SCS1IsCompatibleVectorConversion
5004 bool SCS1IsCompatibleSVEVectorConversion =
5006 bool SCS2IsCompatibleSVEVectorConversion =
5009 if (SCS1IsCompatibleSVEVectorConversion !=
5010 SCS2IsCompatibleSVEVectorConversion)
5011 return SCS1IsCompatibleSVEVectorConversion
5018 bool SCS1IsCompatibleRVVVectorConversion =
5020 bool SCS2IsCompatibleRVVVectorConversion =
5023 if (SCS1IsCompatibleRVVVectorConversion !=
5024 SCS2IsCompatibleRVVVectorConversion)
5025 return SCS1IsCompatibleRVVVectorConversion
5084 if (UnqualT1 == UnqualT2)
5102 bool ObjCLifetimeConversion;
5112 if (CanPick1 != CanPick2)
5166 if (FromPointee1 == FromPointee2 && ToPointee1 != ToPointee2) {
5174 if (FromPointee1 != FromPointee2 && ToPointee1 == ToPointee2) {
5191 if (FromPtr1 && FromPtr2 && ToPtr1 && ToPtr2) {
5198 bool FromAssignRight
5207 if (ToPtr1->isObjCIdType() &&
5208 (ToPtr2->isObjCQualifiedIdType() || ToPtr2->getInterfaceDecl()))
5210 if (ToPtr2->isObjCIdType() &&
5211 (ToPtr1->isObjCQualifiedIdType() || ToPtr1->getInterfaceDecl()))
5216 if (ToPtr1->isObjCQualifiedIdType() && ToPtr2->getInterfaceDecl())
5218 if (ToPtr2->isObjCQualifiedIdType() && ToPtr1->getInterfaceDecl())
5223 if (ToPtr1->isObjCClassType() &&
5224 (ToPtr2->isObjCQualifiedClassType() || ToPtr2->getInterfaceDecl()))
5226 if (ToPtr2->isObjCClassType() &&
5227 (ToPtr1->isObjCQualifiedClassType() || ToPtr1->getInterfaceDecl()))
5232 if (ToPtr1->isObjCQualifiedClassType() && ToPtr2->getInterfaceDecl())
5234 if (ToPtr2->isObjCQualifiedClassType() && ToPtr1->getInterfaceDecl())
5240 (ToAssignLeft != ToAssignRight)) {
5251 }
else if (IsSecondSame)
5260 (FromAssignLeft != FromAssignRight))
5274 CXXRecordDecl *FromPointee1 = FromMemPointer1->getMostRecentCXXRecordDecl();
5279 if (FromPointee1 == FromPointee2 && ToPointee1 != ToPointee2) {
5286 if (ToPointee1 == ToPointee2 && FromPointee1 != FromPointee2) {
5324 if (!
T.getQualifiers().hasUnaligned())
5338 "T1 must be the pointee type of the reference type");
5339 assert(!OrigT2->
isReferenceType() &&
"T2 cannot be a reference type");
5362 if (UnqualT1 == UnqualT2) {
5366 Conv |= ReferenceConversions::DerivedToBase;
5369 Context.canBindObjCObjectType(UnqualT1, UnqualT2))
5370 Conv |= ReferenceConversions::ObjC;
5373 Conv |= ReferenceConversions::Function;
5377 bool ConvertedReferent = Conv != 0;
5381 bool PreviousToQualsIncludeConst =
true;
5382 bool TopLevel =
true;
5388 Conv |= ReferenceConversions::Qualification;
5394 Conv |= ReferenceConversions::NestedQualification;
5402 bool ObjCLifetimeConversion =
false;
5404 PreviousToQualsIncludeConst,
5406 return (ConvertedReferent ||
Context.hasSimilarType(T1, T2))
5411 if (ObjCLifetimeConversion)
5412 Conv |= ReferenceConversions::ObjCLifetime;
5415 }
while (
Context.UnwrapSimilarTypes(T1, T2));
5420 return (ConvertedReferent ||
Context.hasSameUnqualifiedType(T1, T2))
5431 bool AllowExplicit) {
5432 assert(T2->
isRecordType() &&
"Can only find conversions of record types.");
5436 const auto &Conversions = T2RecordDecl->getVisibleConversionFunctions();
5437 for (
auto I = Conversions.begin(), E = Conversions.end(); I != E; ++I) {
5444 = dyn_cast<FunctionTemplateDecl>(D);
5461 if (!ConvTemplate &&
5485 ConvTemplate, I.getPair(), ActingDC,
Init, DeclType, CandidateSet,
5486 false, AllowExplicit);
5489 Conv, I.getPair(), ActingDC,
Init, DeclType, CandidateSet,
5490 false, AllowExplicit);
5493 bool HadMultipleCandidates = (CandidateSet.
size() > 1);
5499 assert(Best->HasFinalConversion);
5511 if (!Best->FinalConversion.DirectBinding)
5523 "Expected a direct reference binding!");
5529 Cand != CandidateSet.
end(); ++Cand)
5541 llvm_unreachable(
"Invalid OverloadResult!");
5546static ImplicitConversionSequence
5549 bool SuppressUserConversions,
5550 bool AllowExplicit) {
5551 assert(DeclType->
isReferenceType() &&
"Reference init needs a reference");
5578 auto SetAsReferenceBinding = [&](
bool BindsDirectly) {
5583 ICS.
Standard.
Second = (RefConv & Sema::ReferenceConversions::DerivedToBase)
5585 : (RefConv & Sema::ReferenceConversions::ObjC)
5593 Sema::ReferenceConversions::NestedQualification)
5607 (RefConv & Sema::ReferenceConversions::ObjCLifetime) != 0;
5631 SetAsReferenceBinding(
true);
5680 SetAsReferenceBinding(S.
getLangOpts().CPlusPlus11 ||
5771 AllowedExplicit::None,
5796 if (isRValRef && LValRefType) {
5813static ImplicitConversionSequence
5815 bool SuppressUserConversions,
5816 bool InOverloadResolution,
5817 bool AllowObjCWritebackConversion,
5818 bool AllowExplicit =
false);
5822static ImplicitConversionSequence
5824 bool SuppressUserConversions,
5825 bool InOverloadResolution,
5826 bool AllowObjCWritebackConversion) {
5839 if (
const auto *IAT = dyn_cast<IncompleteArrayType>(AT))
5841 InitTy = IAT->getElementType();
5867 if (From->
getNumInits() == 1 && !IsDesignatedInit) {
5873 SuppressUserConversions,
5874 InOverloadResolution,
5875 AllowObjCWritebackConversion);
5884 Result.Standard.setAsIdentityConversion();
5885 Result.Standard.setFromType(ToType);
5886 Result.Standard.setAllToTypes(ToType);
5911 bool IsUnbounded =
false;
5915 if (CT->getSize().ult(e)) {
5919 Result.setInitializerListContainerType(ContTy, IsUnbounded);
5922 if (CT->getSize().ugt(e)) {
5928 S, &EmptyList, InitTy, SuppressUserConversions,
5929 InOverloadResolution, AllowObjCWritebackConversion);
5930 if (DfltElt.
isBad()) {
5934 Result.setInitializerListContainerType(ContTy, IsUnbounded);
5945 Result.setInitializerListContainerType(ContTy, IsUnbounded);
5955 Result.Standard.setAsIdentityConversion();
5956 Result.Standard.setFromType(InitTy);
5957 Result.Standard.setAllToTypes(InitTy);
5958 for (
unsigned i = 0; i < e; ++i) {
5961 S,
Init, InitTy, SuppressUserConversions, InOverloadResolution,
5962 AllowObjCWritebackConversion);
5973 Result.setInitializerListContainerType(ContTy, IsUnbounded);
5987 Result.setInitializerListContainerType(ContTy, IsUnbounded);
6001 AllowedExplicit::None,
6002 InOverloadResolution,
false,
6003 AllowObjCWritebackConversion,
6022 Result.UserDefined.Before.setAsIdentityConversion();
6027 Result.UserDefined.After.setAsIdentityConversion();
6028 Result.UserDefined.After.setFromType(ToType);
6029 Result.UserDefined.After.setAllToTypes(ToType);
6030 Result.UserDefined.ConversionFunction =
nullptr;
6047 if (From->
getNumInits() == 1 && !IsDesignatedInit) {
6068 SuppressUserConversions,
6076 InOverloadResolution,
6077 AllowObjCWritebackConversion);
6080 assert(!
Result.isEllipsis() &&
6081 "Sub-initialization cannot result in ellipsis conversion.");
6087 Result.UserDefined.After;
6115 S, From->
getInit(0), ToType, SuppressUserConversions,
6116 InOverloadResolution, AllowObjCWritebackConversion);
6118 Result.Standard.FromBracedInitList =
true;
6122 else if (NumInits == 0) {
6124 Result.Standard.setAsIdentityConversion();
6125 Result.Standard.setFromType(ToType);
6126 Result.Standard.setAllToTypes(ToType);
6143static ImplicitConversionSequence
6145 bool SuppressUserConversions,
6146 bool InOverloadResolution,
6147 bool AllowObjCWritebackConversion,
6148 bool AllowExplicit) {
6149 if (
InitListExpr *FromInitList = dyn_cast<InitListExpr>(From))
6151 InOverloadResolution,AllowObjCWritebackConversion);
6156 SuppressUserConversions, AllowExplicit);
6159 SuppressUserConversions,
6160 AllowedExplicit::None,
6161 InOverloadResolution,
6163 AllowObjCWritebackConversion,
6176 return !ICS.
isBad();
6185 const CXXRecordDecl *ActingContext,
bool InOverloadResolution =
false,
6187 bool SuppressUserConversion =
false) {
6195 assert(FromClassification.
isLValue());
6206 if (Method->isExplicitObjectMemberFunction()) {
6207 if (ExplicitParameterType.isNull())
6208 ExplicitParameterType = Method->getFunctionObjectParameterReferenceType();
6210 ValueKindFromClassification(FromClassification));
6212 S, &TmpExpr, ExplicitParameterType, SuppressUserConversion,
6229 Qualifiers Quals = Method->getMethodQualifiers();
6267 FromType, ImplicitParamType);
6277 FromType, ImplicitParamType);
6290 }
else if (!Method->isExplicitObjectMemberFunction()) {
6292 FromType, ImplicitParamType);
6297 switch (Method->getRefQualifier()) {
6312 if (!FromClassification.
isRValue()) {
6334 = (Method->getRefQualifier() ==
RQ_None);
6345 QualType ImplicitParamRecordType =
Method->getFunctionObjectParameterType();
6358 DestType =
Method->getThisType();
6361 FromRecordType = From->
getType();
6362 DestType = ImplicitParamRecordType;
6370 Method->getRefQualifier() !=
6388 <<
Method->getDeclName() << FromRecordType << (CVR - 1)
6390 Diag(
Method->getLocation(), diag::note_previous_decl)
6391 <<
Method->getDeclName();
6399 bool IsRValueQualified =
6403 << IsRValueQualified;
6404 Diag(
Method->getLocation(), diag::note_previous_decl)
6405 <<
Method->getDeclName();
6415 llvm_unreachable(
"Lists are not objects");
6418 return Diag(From->
getBeginLoc(), diag::err_member_function_call_bad_type)
6419 << ImplicitParamRecordType << FromRecordType
6428 From = FromRes.
get();
6437 CK = CK_AddressSpaceConversion;
6462 AllowedExplicit::Conversions,
6473 return AMDGPU().ExpandAMDGPUPredicateBuiltIn(From);
6547 llvm_unreachable(
"found a first conversion kind in Second");
6551 llvm_unreachable(
"found a third conversion kind in Second");
6557 llvm_unreachable(
"unknown conversion kind");
6567 [[maybe_unused]]
bool isCCEAllowedPreCXX11 =
6570 assert((S.
getLangOpts().CPlusPlus11 || isCCEAllowedPreCXX11) &&
6571 "converted constant expression outside C++11 or TTP matching");
6606 if (
T->isRecordType())
6615 diag::err_typecheck_converted_constant_expression)
6621 llvm_unreachable(
"bad conversion in converted constant expression");
6627 diag::err_typecheck_converted_constant_expression_disallowed)
6633 diag::err_typecheck_converted_constant_expression_indirect)
6643 diag::err_reference_bind_to_bitfield_in_cce)
6651 bool IsTemplateArgument =
6653 if (
T->isRecordType()) {
6654 assert(IsTemplateArgument &&
6655 "unexpected class type converted constant expr");
6671 IsTemplateArgument);
6678 bool ReturnPreNarrowingValue =
false;
6681 S.
Context,
Result.get(), PreNarrowingValue, PreNarrowingType,
6682 false, AllowRelaxedEval)) {
6692 PreNarrowingValue.
isInt()) {
6695 ReturnPreNarrowingValue =
true;
6721 << CCE << 0 << From->
getType() <<
T;
6726 if (!ReturnPreNarrowingValue)
6727 PreNarrowingValue = {};
6743 if (
Result.isInvalid() ||
Result.get()->isValueDependent()) {
6748 RequireInt, PreNarrowingValue);
6755 return ::BuildConvertedConstantExpression(*
this, From,
T, CCE, Dest,
6762 return ::CheckConvertedConstantExpression(*
this, From,
T,
Value, CCE,
false,
6767 llvm::APSInt &
Value,
6769 assert(
T->isIntegralOrEnumerationType() &&
"unexpected converted const type");
6774 if (!R.isInvalid() && !R.get()->isValueDependent())
6782 const APValue &PreNarrowingValue) {
6796 Kind = ConstantExprKind::ClassTemplateArgument;
6798 Kind = ConstantExprKind::NonClassTemplateArgument;
6800 Kind = ConstantExprKind::Normal;
6803 (RequireInt && !Eval.
Val.
isInt())) {
6812 if (Notes.empty() && !CantFold) {
6813 for (
auto &Info : MSWarning)
6814 Diag(Info.first, Info.second);
6817 if (
const auto *CE = dyn_cast<ConstantExpr>(E)) {
6821 "ConstantExpr has no value associated with it");
6827 Value = std::move(PreNarrowingValue);
6833 if (Notes.size() == 1 &&
6834 Notes[0].second.getDiagID() == diag::note_invalid_subexpr_in_const_expr) {
6835 Diag(Notes[0].first, diag::err_expr_not_cce) << CCE;
6836 }
else if (!Notes.empty() && Notes[0].second.getDiagID() ==
6837 diag::note_constexpr_invalid_template_arg) {
6838 Notes[0].second.setDiagID(diag::err_constexpr_invalid_template_arg);
6839 for (
unsigned I = 0; I < Notes.size(); ++I)
6840 Diag(Notes[I].first, Notes[I].second);
6844 for (
unsigned I = 0; I < Notes.size(); ++I)
6845 Diag(Notes[I].first, Notes[I].second);
6864static ImplicitConversionSequence
6872 AllowedExplicit::Conversions,
6914 "expected a member expression");
6916 if (
const auto M = dyn_cast<UnresolvedMemberExpr>(MemExprE);
6917 M && !M->isImplicitAccess())
6918 Base = M->getBase();
6919 else if (
const auto M = dyn_cast<MemberExpr>(MemExprE);
6920 M && !M->isImplicitAccess())
6921 Base = M->getBase();
6925 if (
T->isPointerType())
6926 T =
T->getPointeeType();
6954 assert(Method->isExplicitObjectMemberFunction() &&
6955 "Method is not an explicit member function");
6956 assert(NewArgs.empty() &&
"NewArgs should be empty");
6958 NewArgs.reserve(Args.size() + 1);
6960 NewArgs.push_back(
This);
6961 NewArgs.append(Args.begin(), Args.end());
6964 Method,
Object->getBeginLoc());
6970 return AllowScopedEnumerations ?
T->isIntegralOrEnumerationType()
6971 :
T->isIntegralOrUnscopedEnumerationType();
6983 for (
unsigned I = 0, N = ViableConversions.
size(); I != N; ++I) {
6997 if (ExplicitConversions.
size() == 1 && !Converter.
Suppress) {
7005 std::string TypeStr;
7010 "static_cast<" + TypeStr +
">(")
7022 HadMultipleCandidates);
7029 From,
Result.get()->getType());
7055 HadMultipleCandidates);
7060 CK_UserDefinedConversion,
Result.get(),
7061 nullptr,
Result.get()->getValueKind(),
7086 if (
auto *ConvTemplate = dyn_cast<FunctionTemplateDecl>(D)) {
7088 ConvTemplate, FoundDecl, ActingContext, From, ToType, CandidateSet,
7094 Conv, FoundDecl, ActingContext, From, ToType, CandidateSet,
7128 From = result.
get();
7134 From = Converted.
isUsable() ? Converted.
get() :
nullptr;
7143 const RecordType *RecordTy =
T->getAsCanonical<RecordType>();
7156 : Converter(Converter), From(From) {}
7161 } IncompleteDiagnoser(Converter, From);
7172 ->getDefinitionOrSelf()
7173 ->getVisibleConversionFunctions();
7175 bool HadMultipleCandidates =
7180 bool HasUniqueTargetType =
true;
7196 "Conversion operator templates are considered potentially "
7200 if (Converter.
match(CurToType) || ConvTemplate) {
7206 ExplicitConversions.
addDecl(I.getDecl(), I.getAccess());
7211 else if (HasUniqueTargetType &&
7213 HasUniqueTargetType =
false;
7215 ViableConversions.
addDecl(I.getDecl(), I.getAccess());
7233 HadMultipleCandidates,
7234 ExplicitConversions))
7240 if (!HasUniqueTargetType)
7259 HadMultipleCandidates,
Found))
7268 HadMultipleCandidates,
7269 ExplicitConversions))
7277 switch (ViableConversions.
size()) {
7280 HadMultipleCandidates,
7281 ExplicitConversions))
7291 HadMultipleCandidates,
Found))
7322 if (Proto->getNumParams() < 1)
7326 QualType ArgType = Proto->getParamType(0).getNonReferenceType();
7327 if (Context.hasSameUnqualifiedType(T1, ArgType))
7331 if (Proto->getNumParams() < 2)
7335 QualType ArgType = Proto->getParamType(1).getNonReferenceType();
7336 if (Context.hasSameUnqualifiedType(T2, ArgType))
7355 unsigned SeenAt = 0;
7357 bool HasDefault =
false;
7366 return HasDefault || SeenAt != 0;
7372 bool PartialOverloading,
bool AllowExplicit,
bool AllowExplicitConversions,
7375 bool StrictPackMatch) {
7378 assert(Proto &&
"Functions without a prototype cannot be overloaded");
7379 assert(!
Function->getDescribedFunctionTemplate() &&
7380 "Use AddTemplateOverloadCandidate for function templates");
7393 CandidateSet, SuppressUserConversions,
7394 PartialOverloading, EarlyConversions, PO,
7430 CandidateSet.
addCandidate(Args.size(), EarlyConversions);
7444 Candidate.
Viable =
false;
7457 bool IsImplicitlyInstantiated =
false;
7458 if (
auto *SpecInfo =
Function->getTemplateSpecializationInfo()) {
7459 ND = SpecInfo->getTemplate();
7460 IsImplicitlyInstantiated = SpecInfo->getTemplateSpecializationKind() ==
7471 const bool IsInlineFunctionInGMF =
7473 (IsImplicitlyInstantiated ||
Function->isInlined());
7478 const bool IsCurrentUnitGMFDecl =
7479 Function->isFromGlobalModule() && CurrentModule &&
7480 Function->getOwningModule()->getTopLevelModule() ==
7484 !IsCurrentUnitGMFDecl) {
7485 Candidate.
Viable =
false;
7492 Candidate.
Viable =
false;
7503 if (Args.size() == 1 &&
Constructor->isSpecializationCopyingObject() &&
7504 (
Context.hasSameUnqualifiedType(ClassType, Args[0]->getType()) ||
7507 Candidate.
Viable =
false;
7519 auto *Shadow = dyn_cast<ConstructorUsingShadowDecl>(FoundDecl.
getDecl());
7520 if (Shadow && Args.size() == 1 &&
Constructor->getNumParams() >= 1 &&
7521 Constructor->getParamDecl(0)->getType()->isReferenceType()) {
7528 Candidate.
Viable =
false;
7537 Constructor->getMethodQualifiers().getAddressSpace(),
7539 Candidate.
Viable =
false;
7552 Candidate.
Viable =
false;
7562 unsigned MinRequiredArgs =
Function->getMinRequiredArguments();
7563 if (!AggregateCandidateDeduction && Args.size() < MinRequiredArgs &&
7564 !PartialOverloading) {
7566 Candidate.
Viable =
false;
7580 Candidate.
Viable =
false;
7586 if (
Function->getTrailingRequiresClause()) {
7591 Candidate.
Viable =
false;
7600 for (
unsigned ArgIdx = 0; ArgIdx < Args.size(); ++ArgIdx) {
7603 if (Candidate.
Conversions[ConvIdx].isInitialized()) {
7606 }
else if (ArgIdx < NumParams) {
7617 Args[ArgIdx]->
getType().getAddressSpace() ==
7619 Diag(Args[ArgIdx]->getBeginLoc(), diag::warn_hlsl_groupshared_inout);
7622 *
this, Args[ArgIdx], ParamType, SuppressUserConversions,
7625 getLangOpts().ObjCAutoRefCount, AllowExplicitConversions);
7627 Candidate.
Viable =
false;
7639 if (EnableIfAttr *FailedAttr =
7641 Candidate.
Viable =
false;
7651 if (Methods.size() <= 1)
7654 for (
unsigned b = 0, e = Methods.size(); b < e; b++) {
7660 if (
Method->param_size() > NumNamedArgs)
7661 NumNamedArgs =
Method->param_size();
7662 if (Args.size() < NumNamedArgs)
7665 for (
unsigned i = 0; i < NumNamedArgs; i++) {
7667 if (Args[i]->isTypeDependent()) {
7673 Expr *argExpr = Args[i];
7674 assert(argExpr &&
"SelectBestMethod(): missing expression");
7679 !param->
hasAttr<CFConsumedAttr>())
7680 argExpr =
ObjC().stripARCUnbridgedCast(argExpr);
7697 if (ConversionState.
isBad() ||
7707 for (
unsigned i = NumNamedArgs, e = Args.size(); i < e; ++i) {
7708 if (Args[i]->isTypeDependent()) {
7721 if (Args.size() != NumNamedArgs)
7723 else if (
Match && NumNamedArgs == 0 && Methods.size() > 1) {
7726 for (
unsigned b = 0, e = Methods.size(); b < e; b++) {
7727 QualType ReturnT = Methods[b]->getReturnType();
7747 "Shouldn't have `this` for ctors!");
7748 assert(!Method->isStatic() &&
"Shouldn't have `this` for static methods!");
7750 ThisArg, std::nullopt, Method, Method);
7753 ConvertedThis = R.get();
7755 if (
auto *MD = dyn_cast<CXXMethodDecl>(Function)) {
7757 assert((MissingImplicitThis || MD->isStatic() ||
7759 "Expected `this` for non-ctor instance methods");
7761 ConvertedThis =
nullptr;
7766 unsigned ArgSizeNoVarargs = std::min(Function->param_size(), Args.size());
7769 for (
unsigned I = 0; I != ArgSizeNoVarargs; ++I) {
7772 S.
Context, Function->getParamDecl(I)),
7778 ConvertedArgs.push_back(R.get());
7785 if (!Function->isVariadic() && Args.size() < Function->getNumParams()) {
7786 for (
unsigned i = Args.size(), e = Function->getNumParams(); i != e; ++i) {
7793 ConvertedArgs.push_back(R.get());
7805 bool MissingImplicitThis) {
7806 auto EnableIfAttrs =
Function->specific_attrs<EnableIfAttr>();
7807 if (EnableIfAttrs.begin() == EnableIfAttrs.end())
7813 llvm::scope_exit UndelayDiags(
7815 DelayedDiagnostics.popUndelayed(CurrentState);
7819 Expr *DiscardedThis;
7821 *
this,
Function,
nullptr, CallLoc, Args, Trap,
7822 true, DiscardedThis, ConvertedArgs))
7823 return *EnableIfAttrs.begin();
7825 for (
auto *EIA : EnableIfAttrs) {
7829 if (EIA->getCond()->isValueDependent() ||
7830 !EIA->getCond()->EvaluateWithSubstitution(
7834 if (!
Result.isInt() || !
Result.getInt().getBoolValue())
7840template <
typename CheckFn>
7843 CheckFn &&IsSuccessful) {
7846 if (ArgDependent == DIA->getArgDependent())
7847 Attrs.push_back(DIA);
7854 auto WarningBegin = std::stable_partition(
7855 Attrs.begin(), Attrs.end(), [](
const DiagnoseIfAttr *DIA) {
7856 return DIA->getDefaultSeverity() == DiagnoseIfAttr::DS_error &&
7857 DIA->getWarningGroup().empty();
7862 auto ErrAttr = llvm::find_if(llvm::make_range(Attrs.begin(), WarningBegin),
7864 if (ErrAttr != WarningBegin) {
7865 const DiagnoseIfAttr *DIA = *ErrAttr;
7866 S.
Diag(Loc, diag::err_diagnose_if_succeeded) << DIA->getMessage();
7867 S.
Diag(DIA->getLocation(), diag::note_from_diagnose_if)
7868 << DIA->getParent() << DIA->getCond()->getSourceRange();
7872 auto ToSeverity = [](DiagnoseIfAttr::DefaultSeverity Sev) {
7874 case DiagnoseIfAttr::DS_warning:
7876 case DiagnoseIfAttr::DS_error:
7879 llvm_unreachable(
"Fully covered switch above!");
7882 for (
const auto *DIA : llvm::make_range(WarningBegin, Attrs.end()))
7883 if (IsSuccessful(DIA)) {
7884 if (DIA->getWarningGroup().empty() &&
7885 DIA->getDefaultSeverity() == DiagnoseIfAttr::DS_warning) {
7886 S.
Diag(Loc, diag::warn_diagnose_if_succeeded) << DIA->getMessage();
7887 S.
Diag(DIA->getLocation(), diag::note_from_diagnose_if)
7888 << DIA->getParent() << DIA->getCond()->getSourceRange();
7891 DIA->getWarningGroup());
7894 {ToSeverity(DIA->getDefaultSeverity()),
"%0",
7896 S.
Diag(Loc, DiagID) << DIA->getMessage();
7904 const Expr *ThisArg,
7909 [&](
const DiagnoseIfAttr *DIA) {
7914 if (!DIA->getCond()->EvaluateWithSubstitution(
7917 return Result.isInt() &&
Result.getInt().getBoolValue();
7924 *
this, ND,
false, Loc,
7925 [&](
const DiagnoseIfAttr *DIA) {
7927 return DIA->getCond()->EvaluateAsBooleanCondition(
Result,
Context) &&
7936 bool SuppressUserConversions,
7937 bool PartialOverloading,
7938 bool FirstArgumentIsBase) {
7950 if (Args.size() > 0) {
7951 if (
Expr *E = Args[0]) {
7961 FunctionArgs = Args.slice(1);
7965 FunTmpl, F.getPair(),
7967 ExplicitTemplateArgs, ObjectType, ObjectClassification,
7968 FunctionArgs, CandidateSet, SuppressUserConversions,
7969 PartialOverloading);
7973 ObjectClassification, FunctionArgs, CandidateSet,
7974 SuppressUserConversions, PartialOverloading);
7981 if (Args.size() > 0 &&
7985 FunctionArgs = Args.slice(1);
7989 ExplicitTemplateArgs, FunctionArgs,
7990 CandidateSet, SuppressUserConversions,
7991 PartialOverloading);
7994 SuppressUserConversions, PartialOverloading);
8004 bool SuppressUserConversions,
8014 "Expected a member function template");
8016 nullptr, ObjectType,
8017 ObjectClassification, Args, CandidateSet,
8018 SuppressUserConversions,
false, PO);
8021 ObjectType, ObjectClassification, Args, CandidateSet,
8022 SuppressUserConversions,
false, {}, PO);
8035 assert(Proto &&
"Methods without a prototype cannot be overloaded");
8037 "Use AddOverloadCandidate for constructors");
8046 Method->isMoveAssignmentOperator())
8053 bool IgnoreExplicitObject =
8054 (
Method->isExplicitObjectMemberFunction() &&
8057 bool ImplicitObjectMethodTreatedAsStatic =
8060 Method->isImplicitObjectMemberFunction();
8062 unsigned ExplicitOffset =
8063 !IgnoreExplicitObject &&
Method->isExplicitObjectMemberFunction() ? 1 : 0;
8065 unsigned NumParams =
Method->getNumParams() - ExplicitOffset +
8066 int(ImplicitObjectMethodTreatedAsStatic);
8068 unsigned ExtraArgs =
8075 CandidateSet.
addCandidate(Args.size() + ExtraArgs, EarlyConversions);
8091 Candidate.
Viable =
false;
8101 unsigned MinRequiredArgs =
Method->getMinRequiredArguments() -
8103 int(ImplicitObjectMethodTreatedAsStatic);
8105 if (Args.size() < MinRequiredArgs && !PartialOverloading) {
8107 Candidate.
Viable =
false;
8115 if (!IgnoreExplicitObject) {
8118 else if (
Method->isStatic()) {
8128 Candidate.
Conversions[FirstConvIdx].setStaticObjectArgument();
8133 *
this, CandidateSet.
getLocation(), ObjectType, ObjectClassification,
8134 Method, ActingContext,
true);
8135 if (Candidate.
Conversions[FirstConvIdx].isBad()) {
8136 Candidate.
Viable =
false;
8147 Candidate.
Viable =
false;
8152 if (
Method->getTrailingRequiresClause()) {
8157 Candidate.
Viable =
false;
8165 for (
unsigned ArgIdx = 0; ArgIdx < Args.size(); ++ArgIdx) {
8168 if (Candidate.
Conversions[ConvIdx].isInitialized()) {
8171 }
else if (ArgIdx < NumParams) {
8177 if (ImplicitObjectMethodTreatedAsStatic) {
8178 ParamType = ArgIdx == 0
8179 ?
Method->getFunctionObjectParameterReferenceType()
8182 ParamType = Proto->
getParamType(ArgIdx + ExplicitOffset);
8186 SuppressUserConversions,
8191 Candidate.
Viable =
false;
8203 if (EnableIfAttr *FailedAttr =
8205 Candidate.
Viable =
false;
8212 Candidate.
Viable =
false;
8223 bool SuppressUserConversions,
bool PartialOverloading,
8241 PartialOverloading,
false,
8242 false, ObjectType, ObjectClassification,
8246 bool OnlyInitializeNonUserDefinedConversions) {
8247 return S.CheckNonDependentConversions(
8248 MethodTmpl, ParamTypes, Args, CandidateSet, Conversions,
8249 Sema::CheckNonDependentConversionsFlag(
8250 SuppressUserConversions,
8251 OnlyInitializeNonUserDefinedConversions),
8252 ActingContext, ObjectType, ObjectClassification, PO);
8256 CandidateSet.
addCandidate(Conversions.size(), Conversions);
8259 Candidate.
Viable =
false;
8268 Method->isStatic() ||
8269 (!Method->isExplicitObjectMemberFunction() && ObjectType.
isNull());
8283 assert(
Specialization &&
"Missing member function template specialization?");
8285 "Specialization is not a member function?");
8288 ObjectClassification, Args, CandidateSet, SuppressUserConversions,
8302 if (ExplicitTemplateArgs ||
8305 *
this, CandidateSet, MethodTmpl, FoundDecl, ActingContext,
8306 ExplicitTemplateArgs, ObjectType, ObjectClassification, Args,
8307 SuppressUserConversions, PartialOverloading, PO);
8312 MethodTmpl, FoundDecl, ActingContext, ObjectType, ObjectClassification,
8313 Args, SuppressUserConversions, PartialOverloading, PO);
8331 bool SuppressUserConversions,
bool PartialOverloading,
bool AllowExplicit,
8333 bool AggregateCandidateDeduction) {
8342 Candidate.
Viable =
false;
8362 PartialOverloading, AggregateCandidateDeduction,
8369 bool OnlyInitializeNonUserDefinedConversions) {
8370 return S.CheckNonDependentConversions(
8371 FunctionTemplate, ParamTypes, Args, CandidateSet, Conversions,
8372 Sema::CheckNonDependentConversionsFlag(
8373 SuppressUserConversions,
8374 OnlyInitializeNonUserDefinedConversions),
8375 nullptr, QualType(), {}, PO);
8378 OverloadCandidate &Candidate =
8379 CandidateSet.addCandidate(Conversions.size(), Conversions);
8382 Candidate.
Viable =
false;
8384 CandidateSet.getRewriteInfo().getRewriteKind(Candidate.
Function, PO);
8390 CandidateSet.getKind() ==
8396 ->isExplicitObjectMemberFunction() &&
8412 assert(
Specialization &&
"Missing function template specialization?");
8414 Specialization, FoundDecl, Args, CandidateSet, SuppressUserConversions,
8415 PartialOverloading, AllowExplicit,
8416 false, IsADLCandidate, Conversions, PO,
8417 Info.AggregateDeductionCandidateHasMismatchedArity,
8418 Info.hasStrictPackMatch());
8425 bool PartialOverloading,
bool AllowExplicit,
ADLCallKind IsADLCandidate,
8432 if (ExplicitTemplateArgs ||
8435 DependentExplicitSpecifier)) {
8439 Args, SuppressUserConversions, PartialOverloading, AllowExplicit,
8440 IsADLCandidate, PO, AggregateCandidateDeduction);
8442 if (DependentExplicitSpecifier)
8449 PartialOverloading, AllowExplicit, IsADLCandidate, PO,
8450 AggregateCandidateDeduction);
8463 const bool AllowExplicit =
false;
8465 bool ForOverloadSetAddressResolution =
8468 auto *
Method = dyn_cast<CXXMethodDecl>(FD);
8469 bool HasThisConversion = !ForOverloadSetAddressResolution &&
Method &&
8471 unsigned ThisConversions = HasThisConversion ? 1 : 0;
8487 if (!FD->hasCXXExplicitFunctionObjectParameter() ||
8488 !ParamTypes[0]->isDependentType()) {
8490 *
this, CandidateSet.
getLocation(), ObjectType, ObjectClassification,
8491 Method, ActingContext,
true,
8492 FD->hasCXXExplicitFunctionObjectParameter() ? ParamTypes[0]
8502 auto MaybeInvolveUserDefinedConversion = [&](
QualType ParamType,
8526 if (
auto *RD =
ArgType->getAsCXXRecordDecl();
8527 RD && RD->hasDefinition() &&
8528 !RD->getVisibleConversionFunctions().empty())
8535 HasThisConversion &&
Method->hasCXXExplicitFunctionObjectParameter() ? 1
8538 for (
unsigned I = 0, N = std::min(ParamTypes.size() - Offset, Args.size());
8540 QualType ParamType = ParamTypes[I + Offset];
8544 ConvIdx = Args.size() - 1 - I;
8545 assert(Args.size() + ThisConversions == 2 &&
8546 "number of args (including 'this') must be exactly 2 for "
8550 assert(!HasThisConversion || (ConvIdx == 0 && I == 0));
8553 ConvIdx = ThisConversions + I;
8558 MaybeInvolveUserDefinedConversion(ParamType, Args[I]->
getType()))
8587 bool AllowObjCPointerConversion) {
8595 bool ObjCLifetimeConversion;
8597 ObjCLifetimeConversion))
8602 if (!AllowObjCPointerConversion)
8606 bool IncompatibleObjC =
false;
8616 bool AllowExplicit,
bool AllowResultConversion,
bool StrictPackMatch) {
8618 "Conversion function templates use AddTemplateConversionCandidate");
8633 if (!AllowResultConversion &&
8645 AllowObjCConversionOnExplicit))
8667 if (!AllowExplicit && Conversion->
isExplicit()) {
8668 Candidate.
Viable =
false;
8695 Candidate.
Viable =
false;
8704 Candidate.
Viable =
false;
8715 QualType ToCanon =
Context.getCanonicalType(ToType).getUnqualifiedType();
8716 if (FromCanon == ToCanon ||
8718 Candidate.
Viable =
false;
8735 CK_FunctionToPointerDecay, &ConversionRef,
8740 Candidate.
Viable =
false;
8770 Candidate.
Viable =
false;
8782 Candidate.
Viable =
false;
8789 Candidate.
Viable =
false;
8795 "Can only end up with a standard conversion sequence or failure");
8798 if (EnableIfAttr *FailedAttr =
8800 Candidate.
Viable =
false;
8807 Candidate.
Viable =
false;
8816 bool AllowObjCConversionOnExplicit,
bool AllowExplicit,
8817 bool AllowResultConversion) {
8826 Candidate.
Viable =
false;
8843 Candidate.
Viable =
false;
8853 assert(
Specialization &&
"Missing function template specialization?");
8855 ToType, CandidateSet, AllowObjCConversionOnExplicit,
8856 AllowExplicit, AllowResultConversion,
8864 bool AllowExplicit,
bool AllowResultConversion) {
8866 "Only conversion function templates permitted here");
8877 ToType, AllowObjCConversionOnExplicit, AllowExplicit,
8878 AllowResultConversion);
8886 AllowObjCConversionOnExplicit, AllowExplicit, AllowResultConversion);
8925 if (ObjectInit.
isBad()) {
8926 Candidate.
Viable =
false;
8937 Candidate.
Conversions[0].UserDefined.EllipsisConversion =
false;
8938 Candidate.
Conversions[0].UserDefined.HadMultipleCandidates =
false;
8939 Candidate.
Conversions[0].UserDefined.ConversionFunction = Conversion;
8940 Candidate.
Conversions[0].UserDefined.FoundConversionFunction = FoundDecl;
8943 Candidate.
Conversions[0].UserDefined.After.setAsIdentityConversion();
8951 if (Args.size() > NumParams && !Proto->
isVariadic()) {
8952 Candidate.
Viable =
false;
8959 if (Args.size() < NumParams) {
8961 Candidate.
Viable =
false;
8968 for (
unsigned ArgIdx = 0, N = Args.size(); ArgIdx != N; ++ArgIdx) {
8969 if (ArgIdx < NumParams) {
8982 Candidate.
Viable =
false;
8999 Candidate.
Viable =
false;
9005 if (EnableIfAttr *FailedAttr =
9007 Candidate.
Viable =
false;
9031 "unqualified operator lookup found a member function");
9035 FunctionArgs, CandidateSet);
9041 FunctionArgs[1], FunctionArgs[0]);
9043 Reversed, CandidateSet,
false,
false,
true,
9044 ADLCallKind::NotADL,
9048 if (ExplicitTemplateArgs)
9053 {FunctionArgs[1], FunctionArgs[0]}, CandidateSet,
9054 false,
false,
true,
false, ADLCallKind::NotADL, {},
9086 if (!T1RD || (!IsComplete && !T1RD->isBeingDefined()))
9094 OperEnd = Operators.
end();
9095 Oper != OperEnd; ++Oper) {
9096 if (Oper->getAsFunction() &&
9099 *
this, {Args[1], Args[0]}, Oper->getAsFunction()))
9102 Args[0]->Classify(
Context), Args.slice(1),
9103 CandidateSet,
false, PO);
9110 bool IsAssignmentOperator,
9111 unsigned NumContextualBoolArguments) {
9126 for (
unsigned ArgIdx = 0, N = Args.size(); ArgIdx != N; ++ArgIdx) {
9139 if (ArgIdx < NumContextualBoolArguments) {
9140 assert(ParamTys[ArgIdx] ==
Context.BoolTy &&
9141 "Contextual conversion to bool requires bool type");
9147 ArgIdx == 0 && IsAssignmentOperator,
9153 Candidate.
Viable =
false;
9166class BuiltinCandidateTypeSet {
9172 TypeSet PointerTypes;
9176 TypeSet MemberPointerTypes;
9180 TypeSet EnumerationTypes;
9184 TypeSet VectorTypes;
9188 TypeSet MatrixTypes;
9191 TypeSet BitIntTypes;
9194 bool HasNonRecordTypes;
9198 bool HasArithmeticOrEnumeralTypes;
9204 bool MayConvertToArithmetic;
9208 bool HasNullPtrType;
9212 bool HasReflectionType;
9221 bool AddPointerWithMoreQualifiedTypeVariants(
QualType Ty,
9223 bool AddMemberPointerWithMoreQualifiedTypeVariants(
QualType Ty);
9227 typedef TypeSet::iterator
iterator;
9229 BuiltinCandidateTypeSet(
Sema &SemaRef)
9230 : HasNonRecordTypes(
false), HasArithmeticOrEnumeralTypes(
false),
9231 MayConvertToArithmetic(
false), HasNullPtrType(
false),
9232 HasReflectionType(
false), SemaRef(SemaRef), Context(SemaRef.Context) {}
9234 void AddTypesConvertedFrom(
QualType Ty,
9236 bool AllowUserConversions,
9237 bool AllowExplicitConversions,
9238 const Qualifiers &VisibleTypeConversionsQuals);
9240 llvm::iterator_range<iterator> pointer_types() {
return PointerTypes; }
9241 llvm::iterator_range<iterator> member_pointer_types() {
9242 return MemberPointerTypes;
9244 llvm::iterator_range<iterator> enumeration_types() {
9245 return EnumerationTypes;
9247 llvm::iterator_range<iterator> vector_types() {
return VectorTypes; }
9248 llvm::iterator_range<iterator> matrix_types() {
return MatrixTypes; }
9249 llvm::iterator_range<iterator> bitint_types() {
return BitIntTypes; }
9251 bool containsMatrixType(QualType Ty)
const {
return MatrixTypes.count(Ty); }
9252 bool hasNonRecordTypes() {
return HasNonRecordTypes; }
9253 bool hasArithmeticOrEnumeralTypes() {
return HasArithmeticOrEnumeralTypes; }
9254 bool mayConvertToArithmetic()
const {
return MayConvertToArithmetic; }
9255 bool hasNullPtrType()
const {
return HasNullPtrType; }
9256 bool hasReflectionType()
const {
return HasReflectionType; }
9271BuiltinCandidateTypeSet::AddPointerWithMoreQualifiedTypeVariants(QualType Ty,
9272 const Qualifiers &VisibleQuals) {
9275 if (!PointerTypes.insert(Ty))
9279 const PointerType *PointerTy = Ty->
getAs<PointerType>();
9280 bool buildObjCPtr =
false;
9282 const ObjCObjectPointerType *PTy = Ty->
castAs<ObjCObjectPointerType>();
9284 buildObjCPtr =
true;
9296 unsigned BaseCVR = PointeeTy.getCVRQualifiers();
9302 if ((CVR | BaseCVR) != CVR)
continue;
9317 QualType QPointerTy;
9324 PointerTypes.insert(QPointerTy);
9340BuiltinCandidateTypeSet::AddMemberPointerWithMoreQualifiedTypeVariants(
9343 if (!MemberPointerTypes.insert(Ty))
9346 const MemberPointerType *PointerTy = Ty->
getAs<MemberPointerType>();
9347 assert(PointerTy &&
"type was not a member pointer type!");
9362 if ((CVR | BaseCVR) != CVR)
continue;
9366 QPointeeTy, std::nullopt, Cls));
9381BuiltinCandidateTypeSet::AddTypesConvertedFrom(QualType Ty,
9383 bool AllowUserConversions,
9384 bool AllowExplicitConversions,
9385 const Qualifiers &VisibleQuals) {
9391 if (
const ReferenceType *RefTy = Ty->
getAs<ReferenceType>())
9396 Ty = SemaRef.Context.getArrayDecayedType(Ty);
9403 HasNonRecordTypes = HasNonRecordTypes || !TyIsRec;
9406 HasArithmeticOrEnumeralTypes =
9411 MayConvertToArithmetic =
9412 MayConvertToArithmetic ||
9417 PointerTypes.insert(Ty);
9418 else if (Ty->
getAs<PointerType>() || Ty->
getAs<ObjCObjectPointerType>()) {
9421 if (!AddPointerWithMoreQualifiedTypeVariants(Ty, VisibleQuals))
9425 if (!AddMemberPointerWithMoreQualifiedTypeVariants(Ty))
9428 HasArithmeticOrEnumeralTypes =
true;
9429 EnumerationTypes.insert(Ty);
9431 HasArithmeticOrEnumeralTypes =
true;
9432 BitIntTypes.insert(Ty);
9436 HasArithmeticOrEnumeralTypes =
true;
9437 VectorTypes.insert(Ty);
9441 HasArithmeticOrEnumeralTypes =
true;
9442 MatrixTypes.insert(Ty);
9444 HasNullPtrType =
true;
9446 HasReflectionType =
true;
9447 }
else if (AllowUserConversions && TyIsRec) {
9449 if (!SemaRef.isCompleteType(Loc, Ty))
9453 for (NamedDecl *D : ClassDecl->getVisibleConversionFunctions()) {
9460 MayConvertToArithmetic =
true;
9465 if (AllowExplicitConversions || !Conv->
isExplicit()) {
9513 ClassDecl = RHSMPType->getMostRecentCXXRecordDecl();
9561 if (Available.hasAtomic()) {
9562 Available.removeAtomic();
9569 if (Available.hasVolatile()) {
9570 Available.removeVolatile();
9604class BuiltinOperatorOverloadBuilder {
9607 ArrayRef<Expr *> Args;
9608 QualifiersAndAtomic VisibleTypeConversionsQuals;
9612 bool ArithmeticCandidatesMayBeViable;
9613 SmallVectorImpl<BuiltinCandidateTypeSet> &CandidateTypes;
9614 OverloadCandidateSet &CandidateSet;
9616 static constexpr int ArithmeticTypesCap = 26;
9617 SmallVector<CanQualType, ArithmeticTypesCap> ArithmeticTypes;
9622 unsigned FirstIntegralType,
9624 unsigned FirstPromotedIntegralType,
9625 LastPromotedIntegralType;
9626 unsigned FirstPromotedArithmeticType,
9627 LastPromotedArithmeticType;
9628 unsigned NumArithmeticTypes;
9630 void InitArithmeticTypes() {
9632 FirstPromotedArithmeticType = 0;
9642 FirstIntegralType = ArithmeticTypes.size();
9643 FirstPromotedIntegralType = ArithmeticTypes.size();
9665 llvm::SmallSetVector<CanQualType, 2> BitIntCandidates;
9666 for (BuiltinCandidateTypeSet &Candidate : CandidateTypes) {
9667 for (QualType BitTy : Candidate.bitint_types())
9670 llvm::move(BitIntCandidates, std::back_inserter(ArithmeticTypes));
9671 LastPromotedIntegralType = ArithmeticTypes.size();
9672 LastPromotedArithmeticType = ArithmeticTypes.size();
9686 LastIntegralType = ArithmeticTypes.size();
9687 NumArithmeticTypes = ArithmeticTypes.size();
9694 assert(ArithmeticTypes.size() - BitIntCandidates.size() <=
9695 ArithmeticTypesCap &&
9696 "Enough inline storage for all arithmetic types.");
9701 void addPlusPlusMinusMinusStyleOverloads(QualType CandidateTy,
9704 QualType ParamTypes[2] = {
9744 void AddCandidate(QualType L, QualType R) {
9745 QualType LandR[2] = {L,
R};
9750 BuiltinOperatorOverloadBuilder(
9751 Sema &S, ArrayRef<Expr *> Args,
9752 QualifiersAndAtomic VisibleTypeConversionsQuals,
9753 bool HasArithmeticOrEnumeralCandidateType,
9754 SmallVectorImpl<BuiltinCandidateTypeSet> &CandidateTypes,
9755 OverloadCandidateSet &CandidateSet)
9757 VisibleTypeConversionsQuals(VisibleTypeConversionsQuals),
9758 ArithmeticCandidatesMayBeViable(
9759 HasArithmeticOrEnumeralCandidateType &&
9760 llvm::all_of(CandidateTypes,
9761 [](const BuiltinCandidateTypeSet &Types) {
9762 return Types.mayConvertToArithmetic();
9764 CandidateTypes(CandidateTypes), CandidateSet(CandidateSet) {
9765 InitArithmeticTypes();
9788 if (!ArithmeticCandidatesMayBeViable)
9791 for (
unsigned Arith = 0; Arith < NumArithmeticTypes; ++Arith) {
9792 const auto TypeOfT = ArithmeticTypes[Arith];
9794 if (Op == OO_MinusMinus)
9796 if (Op == OO_PlusPlus && S.
getLangOpts().CPlusPlus17)
9799 addPlusPlusMinusMinusStyleOverloads(
9816 void addPlusPlusMinusMinusPointerOverloads() {
9817 for (QualType PtrTy : CandidateTypes[0].pointer_types()) {
9819 if (!PtrTy->getPointeeType()->isObjectType())
9822 addPlusPlusMinusMinusStyleOverloads(
9824 (!PtrTy.isVolatileQualified() &&
9826 (!PtrTy.isRestrictQualified() &&
9841 void addUnaryStarPointerOverloads() {
9842 for (QualType ParamTy : CandidateTypes[0].pointer_types()) {
9847 if (
const FunctionProtoType *Proto =PointeeTy->
getAs<FunctionProtoType>())
9848 if (Proto->getMethodQuals() || Proto->getRefQualifier())
9861 void addUnaryPlusOrMinusArithmeticOverloads() {
9862 if (!ArithmeticCandidatesMayBeViable)
9865 for (
unsigned Arith = FirstPromotedArithmeticType;
9866 Arith < LastPromotedArithmeticType; ++Arith) {
9867 QualType ArithTy = ArithmeticTypes[Arith];
9872 for (QualType VecTy : CandidateTypes[0].vector_types())
9881 void addUnaryPlusPointerOverloads() {
9882 for (QualType ParamTy : CandidateTypes[0].pointer_types())
9891 void addUnaryTildePromotedIntegralOverloads() {
9892 if (!ArithmeticCandidatesMayBeViable)
9895 for (
unsigned Int = FirstPromotedIntegralType;
9896 Int < LastPromotedIntegralType; ++
Int) {
9897 QualType IntTy = ArithmeticTypes[
Int];
9902 for (QualType VecTy : CandidateTypes[0].vector_types())
9912 void addEqualEqualOrNotEqualMemberPointerOrNullptrOverloads() {
9914 llvm::SmallPtrSet<QualType, 8> AddedTypes;
9916 for (
unsigned ArgIdx = 0, N = Args.size(); ArgIdx != N; ++ArgIdx) {
9917 for (QualType MemPtrTy : CandidateTypes[ArgIdx].member_pointer_types()) {
9922 QualType ParamTypes[2] = {MemPtrTy, MemPtrTy};
9926 if (CandidateTypes[ArgIdx].hasNullPtrType()) {
9928 if (AddedTypes.insert(NullPtrTy).second) {
9929 QualType ParamTypes[2] = { NullPtrTy, NullPtrTy };
9934 if (CandidateTypes[ArgIdx].hasReflectionType()) {
9936 if (AddedTypes.insert(MetaInfoTy).second) {
9937 QualType ParamTypes[2] = {MetaInfoTy, MetaInfoTy};
9956 void addGenericBinaryPointerOrEnumeralOverloads(
bool IsSpaceship) {
9969 llvm::DenseSet<std::pair<CanQualType, CanQualType> >
9970 UserDefinedBinaryOperators;
9972 for (
unsigned ArgIdx = 0, N = Args.size(); ArgIdx != N; ++ArgIdx) {
9973 if (!CandidateTypes[ArgIdx].enumeration_types().empty()) {
9975 CEnd = CandidateSet.
end();
9977 if (!
C->Viable || !
C->Function ||
C->Function->getNumParams() != 2)
9980 if (
C->Function->isFunctionTemplateSpecialization())
9987 QualType FirstParamType =
C->Function->getParamDecl(
Reversed ? 1 : 0)
9989 .getUnqualifiedType();
9990 QualType SecondParamType =
C->Function->getParamDecl(
Reversed ? 0 : 1)
9992 .getUnqualifiedType();
10000 UserDefinedBinaryOperators.insert(
10008 llvm::SmallPtrSet<QualType, 8> AddedTypes;
10010 for (
unsigned ArgIdx = 0, N = Args.size(); ArgIdx != N; ++ArgIdx) {
10011 for (QualType PtrTy : CandidateTypes[ArgIdx].pointer_types()) {
10015 if (IsSpaceship && PtrTy->isFunctionPointerType())
10018 QualType ParamTypes[2] = {PtrTy, PtrTy};
10021 for (QualType EnumTy : CandidateTypes[ArgIdx].enumeration_types()) {
10026 if (!AddedTypes.insert(CanonType).second ||
10027 UserDefinedBinaryOperators.count(std::make_pair(CanonType,
10030 QualType ParamTypes[2] = {EnumTy, EnumTy};
10055 llvm::SmallPtrSet<QualType, 8> AddedTypes;
10057 for (
int Arg = 0; Arg < 2; ++Arg) {
10058 QualType AsymmetricParamTypes[2] = {
10062 for (QualType PtrTy : CandidateTypes[Arg].pointer_types()) {
10067 AsymmetricParamTypes[Arg] = PtrTy;
10068 if (Arg == 0 || Op == OO_Plus) {
10073 if (Op == OO_Minus) {
10078 QualType ParamTypes[2] = {PtrTy, PtrTy};
10114 void addGenericBinaryArithmeticOverloads() {
10115 if (!ArithmeticCandidatesMayBeViable)
10118 for (
unsigned Left = FirstPromotedArithmeticType;
10119 Left < LastPromotedArithmeticType; ++
Left) {
10120 for (
unsigned Right = FirstPromotedArithmeticType;
10121 Right < LastPromotedArithmeticType; ++
Right) {
10122 QualType LandR[2] = { ArithmeticTypes[
Left],
10123 ArithmeticTypes[
Right] };
10130 for (QualType Vec1Ty : CandidateTypes[0].vector_types())
10131 for (QualType Vec2Ty : CandidateTypes[1].vector_types()) {
10132 QualType LandR[2] = {Vec1Ty, Vec2Ty};
10142 void addMatrixBinaryArithmeticOverloads() {
10143 if (!ArithmeticCandidatesMayBeViable)
10146 for (QualType M1 : CandidateTypes[0].matrix_types()) {
10148 AddCandidate(M1, M1);
10151 for (QualType M2 : CandidateTypes[1].matrix_types()) {
10153 if (!CandidateTypes[0].containsMatrixType(M2))
10154 AddCandidate(M2, M2);
10189 void addThreeWayArithmeticOverloads() {
10190 addGenericBinaryArithmeticOverloads();
10207 void addBinaryBitwiseArithmeticOverloads() {
10208 if (!ArithmeticCandidatesMayBeViable)
10211 for (
unsigned Left = FirstPromotedIntegralType;
10212 Left < LastPromotedIntegralType; ++
Left) {
10213 for (
unsigned Right = FirstPromotedIntegralType;
10214 Right < LastPromotedIntegralType; ++
Right) {
10215 QualType LandR[2] = { ArithmeticTypes[
Left],
10216 ArithmeticTypes[
Right] };
10229 void addAssignmentMemberPointerOrEnumeralOverloads() {
10231 llvm::SmallPtrSet<QualType, 8> AddedTypes;
10233 for (
unsigned ArgIdx = 0; ArgIdx < 2; ++ArgIdx) {
10234 for (QualType EnumTy : CandidateTypes[ArgIdx].enumeration_types()) {
10241 for (QualType MemPtrTy : CandidateTypes[ArgIdx].member_pointer_types()) {
10266 void addAssignmentPointerOverloads(
bool isEqualOp) {
10268 llvm::SmallPtrSet<QualType, 8> AddedTypes;
10270 for (QualType PtrTy : CandidateTypes[0].pointer_types()) {
10274 else if (!PtrTy->getPointeeType()->isObjectType())
10278 QualType ParamTypes[2] = {
10285 bool NeedVolatile = !PtrTy.isVolatileQualified() &&
10287 if (NeedVolatile) {
10295 if (!PtrTy.isRestrictQualified() &&
10303 if (NeedVolatile) {
10315 for (QualType PtrTy : CandidateTypes[1].pointer_types()) {
10320 QualType ParamTypes[2] = {
10329 bool NeedVolatile = !PtrTy.isVolatileQualified() &&
10331 if (NeedVolatile) {
10339 if (!PtrTy.isRestrictQualified() &&
10347 if (NeedVolatile) {
10372 void addAssignmentArithmeticOverloads(
bool isEqualOp) {
10373 if (!ArithmeticCandidatesMayBeViable)
10376 for (
unsigned Left = 0;
Left < NumArithmeticTypes; ++
Left) {
10377 for (
unsigned Right = FirstPromotedArithmeticType;
10378 Right < LastPromotedArithmeticType; ++
Right) {
10379 QualType ParamTypes[2];
10380 ParamTypes[1] = ArithmeticTypes[
Right];
10382 S, ArithmeticTypes[Left], Args[0]);
10385 VisibleTypeConversionsQuals, [&](QualifiersAndAtomic Quals) {
10395 for (QualType Vec1Ty : CandidateTypes[0].vector_types())
10396 for (QualType Vec2Ty : CandidateTypes[0].vector_types()) {
10397 QualType ParamTypes[2];
10398 ParamTypes[1] = Vec2Ty;
10426 void addAssignmentIntegralOverloads() {
10427 if (!ArithmeticCandidatesMayBeViable)
10430 for (
unsigned Left = FirstIntegralType;
Left < LastIntegralType; ++
Left) {
10431 for (
unsigned Right = FirstPromotedIntegralType;
10432 Right < LastPromotedIntegralType; ++
Right) {
10433 QualType ParamTypes[2];
10434 ParamTypes[1] = ArithmeticTypes[
Right];
10436 S, ArithmeticTypes[Left], Args[0]);
10439 VisibleTypeConversionsQuals, [&](QualifiersAndAtomic Quals) {
10455 void addExclaimOverload() {
10461 void addAmpAmpOrPipePipeOverload() {
10478 void addSubscriptOverloads() {
10479 for (QualType PtrTy : CandidateTypes[0].pointer_types()) {
10489 for (QualType PtrTy : CandidateTypes[1].pointer_types()) {
10509 void addArrowStarOverloads() {
10510 for (QualType PtrTy : CandidateTypes[0].pointer_types()) {
10511 QualType C1Ty = PtrTy;
10513 QualifierCollector Q1;
10524 for (QualType MemPtrTy : CandidateTypes[1].member_pointer_types()) {
10531 QualType ParamTypes[2] = {PtrTy, MemPtrTy};
10534 if (!VisibleTypeConversionsQuals.
hasVolatile() &&
10535 T.isVolatileQualified())
10537 if (!VisibleTypeConversionsQuals.
hasRestrict() &&
10538 T.isRestrictQualified())
10556 void addConditionalOperatorOverloads() {
10558 llvm::SmallPtrSet<QualType, 8> AddedTypes;
10560 for (
unsigned ArgIdx = 0; ArgIdx < 2; ++ArgIdx) {
10561 for (QualType PtrTy : CandidateTypes[ArgIdx].pointer_types()) {
10565 QualType ParamTypes[2] = {PtrTy, PtrTy};
10569 for (QualType MemPtrTy : CandidateTypes[ArgIdx].member_pointer_types()) {
10573 QualType ParamTypes[2] = {MemPtrTy, MemPtrTy};
10578 for (QualType EnumTy : CandidateTypes[ArgIdx].enumeration_types()) {
10579 if (!EnumTy->castAsCanonical<EnumType>()->getDecl()->isScoped())
10585 QualType ParamTypes[2] = {EnumTy, EnumTy};
10604 VisibleTypeConversionsQuals.
addConst();
10605 for (
unsigned ArgIdx = 0, N = Args.size(); ArgIdx != N; ++ArgIdx) {
10607 if (Args[ArgIdx]->
getType()->isAtomicType())
10608 VisibleTypeConversionsQuals.
addAtomic();
10611 bool HasNonRecordCandidateType =
false;
10612 bool HasArithmeticOrEnumeralCandidateType =
false;
10614 for (
unsigned ArgIdx = 0, N = Args.size(); ArgIdx != N; ++ArgIdx) {
10615 CandidateTypes.emplace_back(*
this);
10616 CandidateTypes[ArgIdx].AddTypesConvertedFrom(Args[ArgIdx]->
getType(),
10619 (Op == OO_Exclaim ||
10621 Op == OO_PipePipe),
10622 VisibleTypeConversionsQuals);
10623 HasNonRecordCandidateType = HasNonRecordCandidateType ||
10624 CandidateTypes[ArgIdx].hasNonRecordTypes();
10625 HasArithmeticOrEnumeralCandidateType =
10626 HasArithmeticOrEnumeralCandidateType ||
10627 CandidateTypes[ArgIdx].hasArithmeticOrEnumeralTypes();
10635 if (!HasNonRecordCandidateType &&
10636 !(Op == OO_Exclaim || Op == OO_AmpAmp || Op == OO_PipePipe))
10640 BuiltinOperatorOverloadBuilder OpBuilder(*
this, Args,
10641 VisibleTypeConversionsQuals,
10642 HasArithmeticOrEnumeralCandidateType,
10643 CandidateTypes, CandidateSet);
10649 llvm_unreachable(
"Expected an overloaded operator");
10654 case OO_Array_Delete:
10657 "Special operators don't use AddBuiltinOperatorCandidates");
10669 if (Args.size() == 1)
10670 OpBuilder.addUnaryPlusPointerOverloads();
10674 if (Args.size() == 1) {
10675 OpBuilder.addUnaryPlusOrMinusArithmeticOverloads();
10677 OpBuilder.addBinaryPlusOrMinusPointerOverloads(Op);
10678 OpBuilder.addGenericBinaryArithmeticOverloads();
10679 OpBuilder.addMatrixBinaryArithmeticOverloads();
10684 if (Args.size() == 1)
10685 OpBuilder.addUnaryStarPointerOverloads();
10687 OpBuilder.addGenericBinaryArithmeticOverloads();
10688 OpBuilder.addMatrixBinaryArithmeticOverloads();
10693 OpBuilder.addGenericBinaryArithmeticOverloads();
10697 case OO_MinusMinus:
10698 OpBuilder.addPlusPlusMinusMinusArithmeticOverloads(Op);
10699 OpBuilder.addPlusPlusMinusMinusPointerOverloads();
10702 case OO_EqualEqual:
10703 case OO_ExclaimEqual:
10704 OpBuilder.addEqualEqualOrNotEqualMemberPointerOrNullptrOverloads();
10705 OpBuilder.addGenericBinaryPointerOrEnumeralOverloads(
false);
10706 OpBuilder.addGenericBinaryArithmeticOverloads();
10712 case OO_GreaterEqual:
10713 OpBuilder.addGenericBinaryPointerOrEnumeralOverloads(
false);
10714 OpBuilder.addGenericBinaryArithmeticOverloads();
10718 OpBuilder.addGenericBinaryPointerOrEnumeralOverloads(
true);
10719 OpBuilder.addThreeWayArithmeticOverloads();
10726 case OO_GreaterGreater:
10727 OpBuilder.addBinaryBitwiseArithmeticOverloads();
10731 if (Args.size() == 1)
10737 OpBuilder.addBinaryBitwiseArithmeticOverloads();
10741 OpBuilder.addUnaryTildePromotedIntegralOverloads();
10745 OpBuilder.addAssignmentMemberPointerOrEnumeralOverloads();
10749 case OO_MinusEqual:
10750 OpBuilder.addAssignmentPointerOverloads(Op == OO_Equal);
10754 case OO_SlashEqual:
10755 OpBuilder.addAssignmentArithmeticOverloads(Op == OO_Equal);
10758 case OO_PercentEqual:
10759 case OO_LessLessEqual:
10760 case OO_GreaterGreaterEqual:
10762 case OO_CaretEqual:
10764 OpBuilder.addAssignmentIntegralOverloads();
10768 OpBuilder.addExclaimOverload();
10773 OpBuilder.addAmpAmpOrPipePipeOverload();
10777 if (Args.size() == 2)
10778 OpBuilder.addSubscriptOverloads();
10782 OpBuilder.addArrowStarOverloads();
10785 case OO_Conditional:
10786 OpBuilder.addConditionalOperatorOverloads();
10787 OpBuilder.addGenericBinaryArithmeticOverloads();
10798 bool PartialOverloading) {
10815 CandEnd = CandidateSet.
end();
10816 Cand != CandEnd; ++Cand)
10817 if (Cand->Function) {
10821 Fns.
erase(FunTmpl);
10830 if (ExplicitTemplateArgs)
10834 FD, FoundDecl, Args, CandidateSet,
false,
10835 PartialOverloading,
true,
10836 false, ADLCallKind::UsesADL);
10839 FD, FoundDecl, {Args[1], Args[0]}, CandidateSet,
10840 false, PartialOverloading,
10847 FTD, FoundDecl, ExplicitTemplateArgs, Args, CandidateSet,
10848 false, PartialOverloading,
10849 true, ADLCallKind::UsesADL);
10851 *
this, Args, FTD->getTemplatedDecl())) {
10855 if (ReversedArgs.empty())
10859 FTD, FoundDecl, ExplicitTemplateArgs, ReversedArgs, CandidateSet,
10860 false, PartialOverloading,
10861 true, ADLCallKind::UsesADL,
10886 bool Cand1Attr = Cand1->
hasAttr<EnableIfAttr>();
10887 bool Cand2Attr = Cand2->
hasAttr<EnableIfAttr>();
10888 if (!Cand1Attr || !Cand2Attr) {
10889 if (Cand1Attr == Cand2Attr)
10890 return Comparison::Equal;
10891 return Cand1Attr ? Comparison::Better : Comparison::Worse;
10897 llvm::FoldingSetNodeID Cand1ID, Cand2ID;
10898 for (
auto Pair : zip_longest(Cand1Attrs, Cand2Attrs)) {
10899 std::optional<EnableIfAttr *> Cand1A = std::get<0>(Pair);
10900 std::optional<EnableIfAttr *> Cand2A = std::get<1>(Pair);
10905 return Comparison::Worse;
10907 return Comparison::Better;
10912 (*Cand1A)->getCond()->Profile(Cand1ID, S.
getASTContext(),
true);
10913 (*Cand2A)->getCond()->Profile(Cand2ID, S.
getASTContext(),
true);
10914 if (Cand1ID != Cand2ID)
10915 return Comparison::Worse;
10918 return Comparison::Equal;
10926 return Comparison::Equal;
10932 return Comparison::Equal;
10933 return Comparison::Worse;
10936 return Comparison::Better;
10942 const auto *Cand1CPUSpec = Cand1.
Function->
getAttr<CPUSpecificAttr>();
10943 const auto *Cand2CPUSpec = Cand2.
Function->
getAttr<CPUSpecificAttr>();
10945 if (!Cand1CPUDisp && !Cand2CPUDisp && !Cand1CPUSpec && !Cand2CPUSpec)
10946 return Comparison::Equal;
10948 if (Cand1CPUDisp && !Cand2CPUDisp)
10949 return Comparison::Better;
10950 if (Cand2CPUDisp && !Cand1CPUDisp)
10951 return Comparison::Worse;
10953 if (Cand1CPUSpec && Cand2CPUSpec) {
10954 if (Cand1CPUSpec->cpus_size() != Cand2CPUSpec->cpus_size())
10955 return Cand1CPUSpec->cpus_size() < Cand2CPUSpec->cpus_size()
10956 ? Comparison::Better
10957 : Comparison::Worse;
10959 std::pair<CPUSpecificAttr::cpus_iterator, CPUSpecificAttr::cpus_iterator>
10960 FirstDiff = std::mismatch(
10961 Cand1CPUSpec->cpus_begin(), Cand1CPUSpec->cpus_end(),
10962 Cand2CPUSpec->cpus_begin(),
10964 return LHS->getName() == RHS->getName();
10967 assert(FirstDiff.first != Cand1CPUSpec->cpus_end() &&
10968 "Two different cpu-specific versions should not have the same "
10969 "identifier list, otherwise they'd be the same decl!");
10970 return (*FirstDiff.first)->getName() < (*FirstDiff.second)->getName()
10971 ? Comparison::Better
10972 : Comparison::Worse;
10974 llvm_unreachable(
"No way to get here unless both had cpu_dispatch");
10980static std::optional<QualType>
10983 return std::nullopt;
10989 return M->getFunctionObjectParameterReferenceType();
11003 PT2->getInstantiatedFromMemberTemplate()))
11014 assert(I < F->getNumParams());
11021 if (F1NumParams != F2NumParams)
11024 unsigned I1 = 0, I2 = 0;
11025 for (
unsigned I = 0; I != F1NumParams; ++I) {
11026 QualType T1 = NextParam(F1, I1, I == 0);
11027 QualType T2 = NextParam(F2, I2, I == 0);
11028 assert(!T1.
isNull() && !T2.
isNull() &&
"Unexpected null param types");
11029 if (!Context.hasSameUnqualifiedType(T1, T2))
11042 bool IsFn1Reversed,
11043 bool IsFn2Reversed) {
11044 assert(Fn1 && Fn2);
11049 IsFn1Reversed ^ IsFn2Reversed))
11052 auto *Mem1 = dyn_cast<CXXMethodDecl>(Fn1);
11053 auto *Mem2 = dyn_cast<CXXMethodDecl>(Fn2);
11054 if (Mem1 && Mem2) {
11057 if (Mem1->getParent() != Mem2->getParent())
11061 if (Mem1->isInstance() && Mem2->isInstance() &&
11063 Mem1->getFunctionObjectParameterReferenceType(),
11064 Mem2->getFunctionObjectParameterReferenceType()))
11070static FunctionDecl *
11072 bool IsFn1Reversed,
bool IsFn2Reversed) {
11082 if (Cand1IsSpecialization || Cand2IsSpecialization)
11099 bool PartialOverloading) {
11145 bool IsCand1ImplicitHD =
11147 bool IsCand2ImplicitHD =
11162 auto EmitThreshold =
11163 (S.
getLangOpts().CUDAIsDevice && IsCallerImplicitHD &&
11164 (IsCand1ImplicitHD || IsCand2ImplicitHD))
11167 auto Cand1Emittable = P1 > EmitThreshold;
11168 auto Cand2Emittable = P2 > EmitThreshold;
11169 if (Cand1Emittable && !Cand2Emittable)
11171 if (!Cand1Emittable && Cand2Emittable)
11182 unsigned StartArg = 0;
11190 return ICS.isStandard() &&
11202 assert(Cand2.
Conversions.size() == NumArgs &&
"Overload candidate mismatch");
11203 bool HasBetterConversion =
false;
11204 for (
unsigned ArgIdx = StartArg; ArgIdx < NumArgs; ++ArgIdx) {
11205 bool Cand1Bad = IsIllFormedConversion(Cand1.
Conversions[ArgIdx]);
11206 bool Cand2Bad = IsIllFormedConversion(Cand2.
Conversions[ArgIdx]);
11207 if (Cand1Bad != Cand2Bad) {
11210 HasBetterConversion =
true;
11214 if (HasBetterConversion)
11221 bool HasWorseConversion =
false;
11222 for (
unsigned ArgIdx = StartArg; ArgIdx < NumArgs; ++ArgIdx) {
11228 HasBetterConversion =
true;
11247 HasWorseConversion =
true;
11262 if (HasBetterConversion && !HasWorseConversion)
11313 bool Cand1IsSpecialization = Cand1.
Function &&
11315 bool Cand2IsSpecialization = Cand2.
Function &&
11317 if (Cand1IsSpecialization != Cand2IsSpecialization)
11318 return Cand2IsSpecialization;
11324 if (Cand1IsSpecialization && Cand2IsSpecialization) {
11325 const auto *Obj1Context =
11327 const auto *Obj2Context =
11356 bool Cand1IsInherited =
11358 bool Cand2IsInherited =
11360 if (Cand1IsInherited != Cand2IsInherited)
11361 return Cand2IsInherited;
11362 else if (Cand1IsInherited) {
11363 assert(Cand2IsInherited);
11366 if (Cand1Class->isDerivedFrom(Cand2Class))
11368 if (Cand2Class->isDerivedFrom(Cand1Class))
11385 auto *Guide1 = dyn_cast_or_null<CXXDeductionGuideDecl>(Cand1.
Function);
11386 auto *Guide2 = dyn_cast_or_null<CXXDeductionGuideDecl>(Cand2.
Function);
11387 if (Guide1 && Guide2) {
11389 if (Guide1->isImplicit() != Guide2->isImplicit())
11390 return Guide2->isImplicit();
11400 const auto *Constructor1 = Guide1->getCorrespondingConstructor();
11401 const auto *Constructor2 = Guide2->getCorrespondingConstructor();
11402 if (Constructor1 && Constructor2) {
11403 bool isC1Templated = Constructor1->getTemplatedKind() !=
11405 bool isC2Templated = Constructor2->getTemplatedKind() !=
11407 if (isC1Templated != isC2Templated)
11408 return isC2Templated;
11416 if (
Cmp != Comparison::Equal)
11417 return Cmp == Comparison::Better;
11420 bool HasPS1 = Cand1.
Function !=
nullptr &&
11422 bool HasPS2 = Cand2.
Function !=
nullptr &&
11424 if (HasPS1 != HasPS2 && HasPS1)
11428 if (MV == Comparison::Better)
11430 if (MV == Comparison::Worse)
11445 const auto *CD1 = dyn_cast_or_null<CXXConstructorDecl>(Cand1.
Function);
11446 const auto *CD2 = dyn_cast_or_null<CXXConstructorDecl>(Cand2.
Function);
11448 LangAS AS1 = CD1->getMethodQualifiers().getAddressSpace();
11449 LangAS AS2 = CD2->getMethodQualifiers().getAddressSpace();
11470 auto *VA = dyn_cast_or_null<ValueDecl>(A);
11471 auto *VB = dyn_cast_or_null<ValueDecl>(B);
11477 if (!VA->getDeclContext()->getRedeclContext()->Equals(
11478 VB->getDeclContext()->getRedeclContext()) ||
11480 VA->isExternallyVisible() || VB->isExternallyVisible())
11488 if (
Context.hasSameType(VA->getType(), VB->getType()))
11493 if (
auto *EA = dyn_cast<EnumConstantDecl>(VA)) {
11494 if (
auto *EB = dyn_cast<EnumConstantDecl>(VB)) {
11499 if (EnumA->hasNameForLinkage() || EnumB->hasNameForLinkage() ||
11500 !
Context.hasSameType(EnumA->getIntegerType(),
11501 EnumB->getIntegerType()))
11504 return llvm::APSInt::isSameValue(EA->getInitVal(), EB->getInitVal());
11514 assert(D &&
"Unknown declaration");
11515 Diag(Loc, diag::ext_equivalent_internal_linkage_decl_in_modules) << D;
11521 for (
auto *E : Equiv) {
11523 Diag(E->getLocation(), diag::note_equivalent_internal_linkage_decl)
11533 ->Satisfaction.ContainsErrors;
11539 bool PartialOverloading,
bool AllowExplicit,
11541 bool AggregateCandidateDeduction) {
11544 allocateDeferredCandidate<DeferredFunctionTemplateOverloadCandidate>();
11549 false, AllowExplicit, SuppressUserConversions,
11550 PartialOverloading, AggregateCandidateDeduction},
11557 HasDeferredTemplateConstructors |=
11565 bool SuppressUserConversions,
bool PartialOverloading,
11571 allocateDeferredCandidate<DeferredMethodTemplateOverloadCandidate>();
11577 false, SuppressUserConversions, PartialOverloading,
11583 ObjectClassification,
11591 bool AllowObjCConversionOnExplicit,
bool AllowExplicit,
11592 bool AllowResultConversion) {
11595 allocateDeferredCandidate<DeferredConversionTemplateOverloadCandidate>();
11599 AllowObjCConversionOnExplicit, AllowResultConversion,
11616 S, CandidateSet,
C.FunctionTemplate,
C.FoundDecl,
C.ActingContext,
11617 nullptr,
C.ObjectType,
C.ObjectClassification,
11618 C.Args,
C.SuppressUserConversions,
C.PartialOverloading,
C.PO);
11625 S, CandidateSet,
C.FunctionTemplate,
C.FoundDecl,
11626 nullptr,
C.Args,
C.SuppressUserConversions,
11627 C.PartialOverloading,
C.AllowExplicit,
C.IsADLCandidate,
C.PO,
11628 C.AggregateCandidateDeduction);
11635 S, CandidateSet,
C.FunctionTemplate,
C.FoundDecl,
C.ActingContext,
C.From,
11636 C.ToType,
C.AllowObjCConversionOnExplicit,
C.AllowExplicit,
11637 C.AllowResultConversion);
11641 Candidates.reserve(Candidates.size() + DeferredCandidatesCount);
11644 switch (Cand->
Kind) {
11663 FirstDeferredCandidate =
nullptr;
11664 DeferredCandidatesCount = 0;
11668OverloadCandidateSet::ResultForBestCandidate(
const iterator &Best) {
11670 if (Best->Function && Best->Function->isDeleted())
11675void OverloadCandidateSet::CudaExcludeWrongSideCandidates(
11692 bool ContainsSameSideCandidate =
11700 if (!ContainsSameSideCandidate)
11703 auto IsWrongSideCandidate = [&](
const OverloadCandidate *Cand) {
11709 llvm::erase_if(Candidates, IsWrongSideCandidate);
11727 DeferredCandidatesCount == 0) &&
11728 "Unexpected deferred template candidates");
11730 bool TwoPhaseResolution =
11731 DeferredCandidatesCount != 0 && !ResolutionByPerfectCandidateIsDisabled;
11733 if (TwoPhaseResolution) {
11735 if (Best !=
end() && Best->isPerfectMatch(S.
Context)) {
11736 if (!(HasDeferredTemplateConstructors &&
11737 isa_and_nonnull<CXXConversionDecl>(Best->Function)))
11743 return BestViableFunctionImpl(S, Loc, Best);
11750 Candidates.reserve(this->Candidates.size());
11751 std::transform(this->Candidates.begin(), this->Candidates.end(),
11752 std::back_inserter(Candidates),
11756 CudaExcludeWrongSideCandidates(S, Candidates);
11759 for (
auto *Cand : Candidates) {
11760 Cand->
Best =
false;
11762 if (Best ==
end() ||
11779 llvm::SmallVector<OverloadCandidate *, 4> PendingBest;
11780 llvm::SmallVector<const NamedDecl *, 4> EquivalentCands;
11781 PendingBest.push_back(&*Best);
11786 while (!PendingBest.empty()) {
11787 auto *Curr = PendingBest.pop_back_val();
11788 for (
auto *Cand : Candidates) {
11791 PendingBest.push_back(Cand);
11796 EquivalentCands.push_back(Cand->
Function);
11808 if (!EquivalentCands.empty())
11816enum OverloadCandidateKind {
11819 oc_reversed_binary_operator,
11821 oc_implicit_default_constructor,
11822 oc_implicit_copy_constructor,
11823 oc_implicit_move_constructor,
11824 oc_implicit_copy_assignment,
11825 oc_implicit_move_assignment,
11826 oc_implicit_equality_comparison,
11827 oc_inherited_constructor
11830enum OverloadCandidateSelect {
11833 ocs_described_template,
11836static std::pair<OverloadCandidateKind, OverloadCandidateSelect>
11837ClassifyOverloadCandidate(Sema &S,
const NamedDecl *
Found,
11838 const FunctionDecl *Fn,
11840 std::string &Description) {
11843 if (FunctionTemplateDecl *FunTmpl =
Fn->getPrimaryTemplate()) {
11846 FunTmpl->getTemplateParameters(), *
Fn->getTemplateSpecializationArgs());
11849 OverloadCandidateSelect Select = [&]() {
11850 if (!Description.empty())
11851 return ocs_described_template;
11852 return isTemplate ? ocs_template : ocs_non_template;
11855 OverloadCandidateKind Kind = [&]() {
11856 if (
Fn->isImplicit() &&
Fn->getOverloadedOperator() == OO_EqualEqual)
11857 return oc_implicit_equality_comparison;
11860 return oc_reversed_binary_operator;
11862 if (
const auto *Ctor = dyn_cast<CXXConstructorDecl>(Fn)) {
11863 if (!Ctor->isImplicit()) {
11865 return oc_inherited_constructor;
11867 return oc_constructor;
11870 if (Ctor->isDefaultConstructor())
11871 return oc_implicit_default_constructor;
11873 if (Ctor->isMoveConstructor())
11874 return oc_implicit_move_constructor;
11876 assert(Ctor->isCopyConstructor() &&
11877 "unexpected sort of implicit constructor");
11878 return oc_implicit_copy_constructor;
11881 if (
const auto *Meth = dyn_cast<CXXMethodDecl>(Fn)) {
11884 if (!Meth->isImplicit())
11887 if (Meth->isMoveAssignmentOperator())
11888 return oc_implicit_move_assignment;
11890 if (Meth->isCopyAssignmentOperator())
11891 return oc_implicit_copy_assignment;
11897 return oc_function;
11900 return std::make_pair(Kind, Select);
11903void MaybeEmitInheritedConstructorNote(Sema &S,
const Decl *FoundDecl) {
11906 if (
const auto *Shadow = dyn_cast<ConstructorUsingShadowDecl>(FoundDecl))
11908 diag::note_ovl_candidate_inherited_constructor)
11909 << Shadow->getNominatedBaseClass();
11918 if (EnableIf->getCond()->isValueDependent() ||
11919 !EnableIf->getCond()->EvaluateAsBooleanCondition(AlwaysTrue, Ctx))
11936 bool InOverloadResolution,
11940 if (InOverloadResolution)
11942 diag::note_addrof_ovl_candidate_disabled_by_enable_if_attr);
11944 S.
Diag(Loc, diag::err_addrof_function_disabled_by_enable_if_attr) << FD;
11955 if (InOverloadResolution) {
11958 TemplateArgString +=
" ";
11960 FunTmpl->getTemplateParameters(),
11965 diag::note_ovl_candidate_unsatisfied_constraints)
11966 << TemplateArgString;
11968 S.
Diag(Loc, diag::err_addrof_function_constraints_not_satisfied)
11977 return P->hasAttr<PassObjectSizeAttr>();
11984 unsigned ParamNo = std::distance(FD->
param_begin(), I) + 1;
11985 if (InOverloadResolution)
11987 diag::note_ovl_candidate_has_pass_object_size_params)
11990 S.
Diag(Loc, diag::err_address_of_function_with_pass_object_size_params)
12006 return ::checkAddressOfFunctionIsAvailable(*
this,
Function, Complain,
12014 const auto *ConvD = dyn_cast<CXXConversionDecl>(Fn);
12019 if (!RD->isLambda())
12029 return ConvToCC != CallOpCC;
12035 QualType DestType,
bool TakingAddress) {
12038 if (Fn->isMultiVersion() && Fn->hasAttr<TargetAttr>() &&
12039 !Fn->getAttr<TargetAttr>()->isDefaultVersion())
12041 if (Fn->isMultiVersion() && Fn->hasAttr<TargetVersionAttr>() &&
12042 !Fn->getAttr<TargetVersionAttr>()->isDefaultVersion())
12047 std::string FnDesc;
12048 std::pair<OverloadCandidateKind, OverloadCandidateSelect> KSPair =
12049 ClassifyOverloadCandidate(*
this,
Found, Fn, RewriteKind, FnDesc);
12051 << (
unsigned)KSPair.first << (
unsigned)KSPair.second
12055 Diag(Fn->getLocation(), PD);
12056 MaybeEmitInheritedConstructorNote(*
this,
Found);
12074 FunctionDecl *FirstCand =
nullptr, *SecondCand =
nullptr;
12075 for (
auto I = Cands.begin(), E = Cands.end(); I != E; ++I) {
12079 if (
auto *
Template = I->Function->getPrimaryTemplate())
12080 Template->getAssociatedConstraints(AC);
12082 I->Function->getAssociatedConstraints(AC);
12085 if (FirstCand ==
nullptr) {
12086 FirstCand = I->Function;
12088 }
else if (SecondCand ==
nullptr) {
12089 SecondCand = I->Function;
12102 SecondCand, SecondAC))
12111 bool TakingAddress) {
12121 dyn_cast<FunctionTemplateDecl>((*I)->getUnderlyingDecl()) ) {
12125 = dyn_cast<FunctionDecl>((*I)->getUnderlyingDecl()) ) {
12138 S.
Diag(CaretLoc, PDiag)
12140 unsigned CandsShown = 0;
12154 unsigned I,
bool TakingCandidateAddress) {
12156 assert(Conv.
isBad());
12157 assert(Cand->
Function &&
"for now, candidate must be a function");
12163 bool isObjectArgument =
false;
12167 isObjectArgument =
true;
12172 std::string FnDesc;
12173 std::pair<OverloadCandidateKind, OverloadCandidateSelect> FnKindPair =
12184 bool HasParamPack =
12185 llvm::any_of(Fn->parameters().take_front(I), [](
const ParmVarDecl *Parm) {
12186 return Parm->isParameterPack();
12188 if (!isObjectArgument && !HasParamPack && I < Fn->getNumParams())
12189 ToParamRange = Fn->getParamDecl(I)->getSourceRange();
12192 assert(FromExpr &&
"overload set argument came from implicit argument?");
12198 S.
Diag(Fn->getLocation(), diag::note_ovl_candidate_bad_overload)
12199 << (
unsigned)FnKindPair.first << (
unsigned)FnKindPair.second << FnDesc
12200 << ToParamRange << ToTy << Name << I + 1;
12201 MaybeEmitInheritedConstructorNote(S, Cand->
FoundDecl);
12210 CToTy = RT->getPointeeType();
12215 CFromTy = FromPT->getPointeeType();
12216 CToTy = ToPT->getPointeeType();
12226 if (isObjectArgument)
12227 S.
Diag(Fn->getLocation(), diag::note_ovl_candidate_bad_addrspace_this)
12228 << (
unsigned)FnKindPair.first << (
unsigned)FnKindPair.second
12231 S.
Diag(Fn->getLocation(), diag::note_ovl_candidate_bad_addrspace)
12232 << (
unsigned)FnKindPair.first << (
unsigned)FnKindPair.second
12235 MaybeEmitInheritedConstructorNote(S, Cand->
FoundDecl);
12240 S.
Diag(Fn->getLocation(), diag::note_ovl_candidate_bad_ownership)
12241 << (
unsigned)FnKindPair.first << (
unsigned)FnKindPair.second << FnDesc
12244 MaybeEmitInheritedConstructorNote(S, Cand->
FoundDecl);
12249 S.
Diag(Fn->getLocation(), diag::note_ovl_candidate_bad_gc)
12250 << (
unsigned)FnKindPair.first << (
unsigned)FnKindPair.second << FnDesc
12253 MaybeEmitInheritedConstructorNote(S, Cand->
FoundDecl);
12258 S.
Diag(Fn->getLocation(), diag::note_ovl_candidate_bad_ptrauth)
12259 << (
unsigned)FnKindPair.first << (
unsigned)FnKindPair.second << FnDesc
12264 MaybeEmitInheritedConstructorNote(S, Cand->
FoundDecl);
12269 assert(CVR &&
"expected qualifiers mismatch");
12271 if (isObjectArgument) {
12272 S.
Diag(Fn->getLocation(), diag::note_ovl_candidate_bad_cvr_this)
12273 << (
unsigned)FnKindPair.first << (
unsigned)FnKindPair.second << FnDesc
12274 << FromTy << (CVR - 1);
12276 S.
Diag(Fn->getLocation(), diag::note_ovl_candidate_bad_cvr)
12277 << (
unsigned)FnKindPair.first << (
unsigned)FnKindPair.second << FnDesc
12278 << ToParamRange << FromTy << (CVR - 1) << I + 1;
12280 MaybeEmitInheritedConstructorNote(S, Cand->
FoundDecl);
12286 S.
Diag(Fn->getLocation(), diag::note_ovl_candidate_bad_value_category)
12287 << (
unsigned)FnKindPair.first << (
unsigned)FnKindPair.second << FnDesc
12288 << (
unsigned)isObjectArgument << I + 1
12291 MaybeEmitInheritedConstructorNote(S, Cand->
FoundDecl);
12298 S.
Diag(Fn->getLocation(), diag::note_ovl_candidate_bad_list_argument)
12299 << (
unsigned)FnKindPair.first << (
unsigned)FnKindPair.second << FnDesc
12300 << ToParamRange << FromTy << ToTy << (
unsigned)isObjectArgument << I + 1
12305 MaybeEmitInheritedConstructorNote(S, Cand->
FoundDecl);
12317 S.
Diag(Fn->getLocation(), diag::note_ovl_candidate_bad_conv_incomplete)
12318 << (
unsigned)FnKindPair.first << (
unsigned)FnKindPair.second << FnDesc
12319 << ToParamRange << FromTy << ToTy << (
unsigned)isObjectArgument << I + 1
12320 << (
unsigned)(Cand->
Fix.
Kind);
12322 MaybeEmitInheritedConstructorNote(S, Cand->
FoundDecl);
12327 unsigned BaseToDerivedConversion = 0;
12330 if (ToPtrTy->getPointeeType().isAtLeastAsQualifiedAs(
12332 !FromPtrTy->getPointeeType()->isIncompleteType() &&
12333 !ToPtrTy->getPointeeType()->isIncompleteType() &&
12335 FromPtrTy->getPointeeType()))
12336 BaseToDerivedConversion = 1;
12344 if (ToPtrTy->getPointeeType().isAtLeastAsQualifiedAs(
12346 FromIface->isSuperClassOf(ToIface))
12347 BaseToDerivedConversion = 2;
12349 if (ToRefTy->getPointeeType().isAtLeastAsQualifiedAs(FromTy,
12352 !ToRefTy->getPointeeType()->isIncompleteType() &&
12354 BaseToDerivedConversion = 3;
12358 if (BaseToDerivedConversion) {
12359 S.
Diag(Fn->getLocation(), diag::note_ovl_candidate_bad_base_to_derived_conv)
12360 << (
unsigned)FnKindPair.first << (
unsigned)FnKindPair.second << FnDesc
12361 << ToParamRange << (BaseToDerivedConversion - 1) << FromTy << ToTy
12363 MaybeEmitInheritedConstructorNote(S, Cand->
FoundDecl);
12372 S.
Diag(Fn->getLocation(), diag::note_ovl_candidate_bad_arc_conv)
12373 << (
unsigned)FnKindPair.first << (
unsigned)FnKindPair.second << FnDesc
12374 << ToParamRange << FromTy << ToTy << (
unsigned)isObjectArgument
12376 MaybeEmitInheritedConstructorNote(S, Cand->
FoundDecl);
12386 if (FromTy == S.
Context.AMDGPUFeaturePredicateTy &&
12389 diag::err_amdgcn_predicate_type_needs_explicit_bool_cast)
12396 FDiag << (
unsigned)FnKindPair.first << (
unsigned)FnKindPair.second << FnDesc
12397 << ToParamRange << FromTy << ToTy << (
unsigned)isObjectArgument << I + 1
12398 << (
unsigned)(Cand->
Fix.
Kind);
12407 S.
Diag(Fn->getLocation(), FDiag);
12409 MaybeEmitInheritedConstructorNote(S, Cand->
FoundDecl);
12416 unsigned NumArgs,
bool IsAddressOf =
false) {
12417 assert(Cand->
Function &&
"Candidate is required to be a function.");
12419 unsigned MinParams = Fn->getMinRequiredExplicitArguments() +
12420 ((IsAddressOf && !Fn->isStatic()) ? 1 : 0);
12427 if (Fn->isInvalidDecl() &&
12431 if (NumArgs < MinParams) {
12448 unsigned NumFormalArgs,
12449 bool IsAddressOf =
false) {
12451 "The templated declaration should at least be a function"
12452 " when diagnosing bad template argument deduction due to too many"
12453 " or too few arguments");
12459 unsigned MinParams = Fn->getMinRequiredExplicitArguments() +
12460 ((IsAddressOf && !Fn->isStatic()) ? 1 : 0);
12463 bool HasExplicitObjectParam =
12464 !IsAddressOf && Fn->hasCXXExplicitFunctionObjectParameter();
12466 unsigned ParamCount =
12467 Fn->getNumNonObjectParams() + ((IsAddressOf && !Fn->isStatic()) ? 1 : 0);
12468 unsigned mode, modeCount;
12470 if (NumFormalArgs < MinParams) {
12471 if (MinParams != ParamCount || FnTy->isVariadic() ||
12472 FnTy->isTemplateVariadic())
12476 modeCount = MinParams;
12478 if (MinParams != ParamCount)
12482 modeCount = ParamCount;
12485 std::string Description;
12486 std::pair<OverloadCandidateKind, OverloadCandidateSelect> FnKindPair =
12487 ClassifyOverloadCandidate(S,
Found, Fn,
CRK_None, Description);
12489 unsigned FirstNonObjectParamIdx = HasExplicitObjectParam ? 1 : 0;
12490 if (modeCount == 1 && !IsAddressOf &&
12491 FirstNonObjectParamIdx < Fn->getNumParams() &&
12492 Fn->getParamDecl(FirstNonObjectParamIdx)->getDeclName())
12493 S.
Diag(Fn->getLocation(), diag::note_ovl_candidate_arity_one)
12494 << (
unsigned)FnKindPair.first << (
unsigned)FnKindPair.second
12495 << Description << mode << Fn->getParamDecl(FirstNonObjectParamIdx)
12496 << NumFormalArgs << HasExplicitObjectParam
12497 << Fn->getParametersSourceRange();
12499 S.
Diag(Fn->getLocation(), diag::note_ovl_candidate_arity)
12500 << (
unsigned)FnKindPair.first << (
unsigned)FnKindPair.second
12501 << Description << mode << modeCount << NumFormalArgs
12502 << HasExplicitObjectParam << Fn->getParametersSourceRange();
12504 MaybeEmitInheritedConstructorNote(S,
Found);
12509 unsigned NumFormalArgs) {
12510 assert(Cand->
Function &&
"Candidate must be a function");
12520 llvm_unreachable(
"Unsupported: Getting the described template declaration"
12521 " for bad deduction diagnosis");
12527 unsigned NumArgs,
bool TakingCandidateAddress,
12531 NamedDecl *ParamD = dyn_cast_if_present<TemplateTypeParmDecl *>(Param);
12533 ParamD = dyn_cast_if_present<NonTypeTemplateParmDecl *>(Param);
12535 ParamD = dyn_cast_if_present<TemplateTemplateParmDecl *>(Param);
12536 switch (DeductionFailure.
getResult()) {
12539 "TemplateDeductionResult::Success while diagnosing bad deduction");
12541 llvm_unreachable(
"TemplateDeductionResult::NonDependentConversionFailure "
12542 "while diagnosing bad deduction");
12548 assert(ParamD &&
"no parameter found for incomplete deduction result");
12550 diag::note_ovl_candidate_incomplete_deduction)
12552 MaybeEmitInheritedConstructorNote(S,
Found);
12557 assert(ParamD &&
"no parameter found for incomplete deduction result");
12559 diag::note_ovl_candidate_incomplete_deduction_pack)
12561 << (DeductionFailure.
getFirstArg()->pack_size() + 1)
12563 MaybeEmitInheritedConstructorNote(S,
Found);
12568 assert(ParamD &&
"no parameter found for bad qualifiers deduction result");
12586 S.
Diag(Templated->
getLocation(), diag::note_ovl_candidate_underqualified)
12587 << ParamD->
getDeclName() << Arg << NonCanonParam;
12588 MaybeEmitInheritedConstructorNote(S,
Found);
12593 assert(ParamD &&
"no parameter found for inconsistent deduction result");
12607 diag::note_ovl_candidate_inconsistent_deduction_types)
12610 MaybeEmitInheritedConstructorNote(S,
Found);
12630 diag::note_ovl_candidate_inconsistent_deduction)
12633 MaybeEmitInheritedConstructorNote(S,
Found);
12638 assert(ParamD &&
"no parameter found for invalid explicit arguments");
12641 diag::note_ovl_candidate_explicit_arg_mismatch);
12643 Diag << diag::ExplicitArgMismatchNameKind::Named << ParamD->
getDeclName();
12645 Diag << diag::ExplicitArgMismatchNameKind::Unnamed
12650 Diag << diag::ExplicitArgMismatchReasonKind::Detailed << DiagContent;
12652 Diag << diag::ExplicitArgMismatchReasonKind::Vague;
12655 MaybeEmitInheritedConstructorNote(S,
Found);
12662 TemplateArgString =
" ";
12665 if (TemplateArgString.size() == 1)
12666 TemplateArgString.clear();
12668 diag::note_ovl_candidate_unsatisfied_constraints)
12669 << TemplateArgString;
12672 static_cast<CNSInfo*
>(DeductionFailure.
Data)->Satisfaction);
12682 diag::note_ovl_candidate_instantiation_depth);
12683 MaybeEmitInheritedConstructorNote(S,
Found);
12691 TemplateArgString =
" ";
12694 if (TemplateArgString.size() == 1)
12695 TemplateArgString.clear();
12700 if (PDiag && PDiag->second.getDiagID() ==
12701 diag::err_typename_nested_not_found_enable_if) {
12704 S.
Diag(PDiag->first, diag::note_ovl_candidate_disabled_by_enable_if)
12705 <<
"'enable_if'" << TemplateArgString;
12710 if (PDiag && PDiag->second.getDiagID() ==
12711 diag::err_typename_nested_not_found_requirement) {
12713 diag::note_ovl_candidate_disabled_by_requirement)
12714 << PDiag->second.getStringArg(0) << TemplateArgString;
12724 SFINAEArgString =
": ";
12726 PDiag->second.EmitToString(S.
getDiagnostics(), SFINAEArgString);
12730 diag::note_ovl_candidate_substitution_failure)
12731 << TemplateArgString << SFINAEArgString << R;
12732 MaybeEmitInheritedConstructorNote(S,
Found);
12742 TemplateArgString =
" ";
12745 if (TemplateArgString.size() == 1)
12746 TemplateArgString.clear();
12749 S.
Diag(Templated->
getLocation(), diag::note_ovl_candidate_deduced_mismatch)
12752 << TemplateArgString
12777 CandidateSetKind ==
12779 ? diag::note_friend_template_non_deduced_mismatch_qualified
12780 : diag::note_ovl_candidate_non_deduced_mismatch_qualified)
12797 ? diag::note_friend_template_non_deduced_mismatch
12798 : diag::note_ovl_candidate_non_deduced_mismatch)
12799 << FirstTA << SecondTA;
12805 S.
Diag(Templated->
getLocation(), diag::note_ovl_candidate_bad_deduction);
12806 MaybeEmitInheritedConstructorNote(S,
Found);
12810 diag::note_cuda_ovl_candidate_target_mismatch);
12818 bool TakingCandidateAddress) {
12819 assert(Cand->
Function &&
"Candidate must be a function");
12834 assert(Cand->
Function &&
"Candidate must be a Function.");
12840 std::string FnDesc;
12841 std::pair<OverloadCandidateKind, OverloadCandidateSelect> FnKindPair =
12842 ClassifyOverloadCandidate(S, Cand->
FoundDecl, Callee,
12845 S.
Diag(Callee->getLocation(), diag::note_ovl_candidate_bad_target)
12846 << (
unsigned)FnKindPair.first << (
unsigned)ocs_non_template
12848 << CalleeTarget << CallerTarget;
12853 if (Meth !=
nullptr && Meth->
isImplicit()) {
12857 switch (FnKindPair.first) {
12860 case oc_implicit_default_constructor:
12863 case oc_implicit_copy_constructor:
12866 case oc_implicit_move_constructor:
12869 case oc_implicit_copy_assignment:
12872 case oc_implicit_move_assignment:
12877 bool ConstRHS =
false;
12881 ConstRHS = RT->getPointeeType().isConstQualified();
12892 assert(Cand->
Function &&
"Candidate must be a function");
12896 S.
Diag(Callee->getLocation(),
12897 diag::note_ovl_candidate_disabled_by_function_cond_attr)
12898 <<
Attr->getCond()->getSourceRange() <<
Attr->getMessage();
12902 assert(Cand->
Function &&
"Candidate must be a function");
12905 assert(ES.
isExplicit() &&
"not an explicit candidate");
12908 switch (Fn->getDeclKind()) {
12909 case Decl::Kind::CXXConstructor:
12912 case Decl::Kind::CXXConversion:
12915 case Decl::Kind::CXXDeductionGuide:
12916 Kind = Fn->isImplicit() ? 0 : 2;
12919 llvm_unreachable(
"invalid Decl");
12928 First = Pattern->getFirstDecl();
12931 diag::note_ovl_candidate_explicit)
12932 << Kind << (ES.
getExpr() ? 1 : 0)
12937 auto *DG = dyn_cast<CXXDeductionGuideDecl>(Fn);
12944 if (!(DG->isImplicit() || (OriginTemplate && OriginTemplate->
isTypeAlias())))
12946 std::string FunctionProto;
12947 llvm::raw_string_ostream OS(FunctionProto);
12960 "Non-template implicit deduction guides are only possible for "
12963 S.
Diag(DG->getLocation(), diag::note_implicit_deduction_guide)
12968 assert(
Template &&
"Cannot find the associated function template of "
12969 "CXXDeductionGuideDecl?");
12972 S.
Diag(DG->getLocation(), diag::note_implicit_deduction_guide)
12993 bool TakingCandidateAddress,
12995 assert(Cand->
Function &&
"Candidate must be a function");
13003 if (S.
getLangOpts().OpenCL && Fn->isImplicit() &&
13010 !Fn->hasCXXExplicitFunctionObjectParameter() && !Fn->isStatic())
13015 if (Fn->isDeleted()) {
13016 std::string FnDesc;
13017 std::pair<OverloadCandidateKind, OverloadCandidateSelect> FnKindPair =
13018 ClassifyOverloadCandidate(S, Cand->
FoundDecl, Fn,
13021 S.
Diag(Fn->getLocation(), diag::note_ovl_candidate_deleted)
13022 << (
unsigned)FnKindPair.first << (
unsigned)FnKindPair.second << FnDesc
13023 << (Fn->isDeleted()
13024 ? (Fn->getCanonicalDecl()->isDeletedAsWritten() ? 1 : 2)
13026 MaybeEmitInheritedConstructorNote(S, Cand->
FoundDecl);
13053 TakingCandidateAddress);
13056 S.
Diag(Fn->getLocation(), diag::note_ovl_candidate_illegal_constructor)
13057 << (Fn->getPrimaryTemplate() ? 1 : 0);
13058 MaybeEmitInheritedConstructorNote(S, Cand->
FoundDecl);
13065 S.
Diag(Fn->getLocation(),
13066 diag::note_ovl_candidate_illegal_constructor_adrspace_mismatch)
13067 << QualsForPrinting;
13068 MaybeEmitInheritedConstructorNote(S, Cand->
FoundDecl);
13079 for (
unsigned N = Cand->
Conversions.size(); I != N; ++I)
13102 S.
Diag(Fn->getLocation(),
13103 diag::note_ovl_candidate_inherited_constructor_slice)
13104 << (Fn->getPrimaryTemplate() ? 1 : 0)
13105 << Fn->getParamDecl(0)->getType()->isRValueReferenceType();
13106 MaybeEmitInheritedConstructorNote(S, Cand->
FoundDecl);
13112 assert(!Available);
13120 std::string FnDesc;
13121 std::pair<OverloadCandidateKind, OverloadCandidateSelect> FnKindPair =
13122 ClassifyOverloadCandidate(S, Cand->
FoundDecl, Fn,
13125 S.
Diag(Fn->getLocation(),
13126 diag::note_ovl_candidate_constraints_not_satisfied)
13127 << (
unsigned)FnKindPair.first << (
unsigned)ocs_non_template
13146 bool isLValueReference =
false;
13147 bool isRValueReference =
false;
13148 bool isPointer =
false;
13152 isLValueReference =
true;
13156 isRValueReference =
true;
13172 diag::note_ovl_surrogate_constraints_not_satisfied)
13186 assert(Cand->
Conversions.size() <= 2 &&
"builtin operator is not binary");
13187 std::string TypeStr(
"operator");
13193 S.
Diag(OpLoc, diag::note_ovl_builtin_candidate) << TypeStr;
13198 S.
Diag(OpLoc, diag::note_ovl_builtin_candidate) << TypeStr;
13205 if (ICS.
isBad())
break;
13209 S, OpLoc, S.
PDiag(diag::note_ambiguous_type_conversion));
13226 llvm_unreachable(
"non-deduction failure while diagnosing bad deduction");
13256 llvm_unreachable(
"Unhandled deduction result");
13261struct CompareOverloadCandidatesForDisplay {
13263 SourceLocation Loc;
13267 CompareOverloadCandidatesForDisplay(
13268 Sema &S, SourceLocation Loc,
size_t NArgs,
13270 : S(S), NumArgs(NArgs), CSK(CSK) {}
13280 if (NumArgs >
C->Function->getNumParams() && !
C->Function->isVariadic())
13282 if (NumArgs < C->
Function->getMinRequiredArguments())
13289 bool operator()(
const OverloadCandidate *L,
13290 const OverloadCandidate *R) {
13292 if (L == R)
return false;
13296 if (!
R->Viable)
return true;
13298 if (
int Ord = CompareConversions(*L, *R))
13301 }
else if (
R->Viable)
13304 assert(L->
Viable ==
R->Viable);
13317 int RDist =
std::abs((
int)
R->getNumParams() - (
int)NumArgs);
13318 if (LDist == RDist) {
13319 if (LFailureKind == RFailureKind)
13327 return LDist < RDist;
13344 unsigned numRFixes =
R->Fix.NumConversionsFixed;
13345 numLFixes = (numLFixes == 0) ?
UINT_MAX : numLFixes;
13346 numRFixes = (numRFixes == 0) ?
UINT_MAX : numRFixes;
13347 if (numLFixes != numRFixes) {
13348 return numLFixes < numRFixes;
13352 if (
int Ord = CompareConversions(*L, *R))
13364 if (LRank != RRank)
13365 return LRank < RRank;
13391 struct ConversionSignals {
13392 unsigned KindRank = 0;
13395 static ConversionSignals ForSequence(ImplicitConversionSequence &
Seq) {
13396 ConversionSignals Sig;
13397 Sig.KindRank =
Seq.getKindRank();
13398 if (
Seq.isStandard())
13399 Sig.Rank =
Seq.Standard.getRank();
13400 else if (
Seq.isUserDefined())
13401 Sig.Rank =
Seq.UserDefined.After.getRank();
13407 static ConversionSignals ForObjectArgument() {
13417 int CompareConversions(
const OverloadCandidate &L,
13418 const OverloadCandidate &R) {
13423 for (
unsigned I = 0, N = L.
Conversions.size(); I != N; ++I) {
13425 ? ConversionSignals::ForObjectArgument()
13426 : ConversionSignals::ForSequence(L.Conversions[I]);
13427 auto RS =
R.IgnoreObjectArgument
13428 ? ConversionSignals::ForObjectArgument()
13429 : ConversionSignals::ForSequence(
R.Conversions[I]);
13430 if (std::tie(LS.KindRank, LS.Rank) != std::tie(RS.KindRank, RS.Rank))
13431 return std::tie(LS.KindRank, LS.Rank) < std::tie(RS.KindRank, RS.Rank)
13456 bool Unfixable =
false;
13462 for (
unsigned ConvIdx =
13466 assert(ConvIdx != ConvCount &&
"no bad conversion in candidate");
13467 if (Cand->
Conversions[ConvIdx].isInitialized() &&
13476 bool SuppressUserConversions =
false;
13478 unsigned ConvIdx = 0;
13479 unsigned ArgIdx = 0;
13508 assert(ConvCount <= 3);
13514 ConvIdx != ConvCount && ArgIdx < Args.size();
13516 if (Cand->
Conversions[ConvIdx].isInitialized()) {
13518 }
else if (
ParamIdx < ParamTypes.size()) {
13519 if (ParamTypes[
ParamIdx]->isDependentType())
13520 Cand->
Conversions[ConvIdx].setAsIdentityConversion(
13525 SuppressUserConversions,
13530 if (!Unfixable && Cand->
Conversions[ConvIdx].isBad())
13549 for (
iterator Cand = Candidates.begin(), LastCand = Candidates.end();
13550 Cand != LastCand; ++Cand) {
13551 if (!Filter(*Cand))
13576 Cands.push_back(Cand);
13580 Cands, CompareOverloadCandidatesForDisplay(S, OpLoc, Args.size(), Kind));
13587 bool DeferHint =
false;
13591 auto WrongSidedCands =
13593 return (Cand.
Viable ==
false &&
13599 DeferHint = !WrongSidedCands.empty();
13615 S.
Diag(PD.first, PD.second);
13620 bool NoteCands =
true;
13621 for (
const Expr *Arg : Args) {
13622 if (Arg->getType()->isWebAssemblyTableType())
13631 {Candidates.begin(), Candidates.end()});
13637 bool ReportedAmbiguousConversions =
false;
13640 unsigned CandsShown = 0;
13641 auto I = Cands.begin(), E = Cands.end();
13642 for (; I != E; ++I) {
13658 "Non-viable built-in candidates are not added to Cands.");
13665 if (!ReportedAmbiguousConversions) {
13667 ReportedAmbiguousConversions =
true;
13681 S.
Diag(OpLoc, diag::note_ovl_too_many_candidates) <<
int(E - I);
13686 const Sema &S)
const {
13692 if (Caller && Caller->
hasAttr<CUDAHostAttr>() &&
13693 Caller->
hasAttr<CUDADeviceAttr>())
13714struct CompareTemplateSpecCandidatesForDisplay {
13716 CompareTemplateSpecCandidatesForDisplay(Sema &S) : S(S) {}
13718 bool operator()(
const TemplateSpecCandidate *L,
13719 const TemplateSpecCandidate *R) {
13750 Sema &S,
bool ForTakingAddress,
13757void TemplateSpecCandidateSet::destroyCandidates() {
13759 i->DeductionFailure.Destroy();
13764 destroyCandidates();
13765 Candidates.clear();
13778 Cands.reserve(
size());
13779 for (
iterator Cand =
begin(), LastCand =
end(); Cand != LastCand; ++Cand) {
13780 if (Cand->Specialization)
13781 Cands.push_back(Cand);
13786 llvm::sort(Cands, CompareTemplateSpecCandidatesForDisplay(S));
13793 unsigned CandsShown = 0;
13794 for (I = Cands.begin(), E = Cands.end(); I != E; ++I) {
13800 if (CandsShown >= 4 && ShowOverloads ==
Ovl_Best)
13805 "Non-matching built-in candidates are not added to Cands.");
13810 S.
Diag(Loc, diag::note_ovl_too_many_candidates) <<
int(E - I);
13820 QualType Ret = PossiblyAFunctionType;
13823 Ret = ToTypePtr->getPointeeType();
13826 Ret = ToTypeRef->getPointeeType();
13829 Ret = MemTypePtr->getPointeeType();
13831 Context.getCanonicalType(Ret).getUnqualifiedType();
13836 bool Complain =
true) {
13853class AddressOfFunctionResolver {
13856 const QualType& TargetType;
13857 QualType TargetFunctionType;
13861 ASTContext& Context;
13863 bool TargetTypeIsNonStaticMemberFunction;
13864 bool FoundNonTemplateFunction;
13865 bool StaticMemberFunctionFromBoundPointer;
13866 bool HasComplained;
13868 OverloadExpr::FindResult OvlExprInfo;
13869 OverloadExpr *OvlExpr;
13870 TemplateArgumentListInfo OvlExplicitTemplateArgs;
13871 SmallVector<std::pair<DeclAccessPair, FunctionDecl*>, 4> Matches;
13872 TemplateSpecCandidateSet FailedCandidates;
13875 AddressOfFunctionResolver(Sema &S, Expr *SourceExpr,
13876 const QualType &TargetType,
bool Complain)
13877 : S(S), SourceExpr(SourceExpr), TargetType(TargetType),
13878 Complain(Complain), Context(S.getASTContext()),
13879 TargetTypeIsNonStaticMemberFunction(
13880 !!TargetType->getAs<MemberPointerType>()),
13881 FoundNonTemplateFunction(
false),
13882 StaticMemberFunctionFromBoundPointer(
false),
13883 HasComplained(
false),
13884 OvlExprInfo(OverloadExpr::find(SourceExpr)),
13886 FailedCandidates(OvlExpr->getNameLoc(),
true) {
13887 ExtractUnqualifiedFunctionTypeFromTargetType();
13890 if (UnresolvedMemberExpr *UME = dyn_cast<UnresolvedMemberExpr>(OvlExpr))
13891 if (!UME->isImplicitAccess() &&
13893 StaticMemberFunctionFromBoundPointer =
true;
13895 DeclAccessPair dap;
13897 OvlExpr,
false, &dap)) {
13898 if (CXXMethodDecl *
Method = dyn_cast<CXXMethodDecl>(Fn))
13899 if (!
Method->isStatic()) {
13903 TargetTypeIsNonStaticMemberFunction =
true;
13911 Matches.push_back(std::make_pair(dap, Fn));
13919 if (FindAllFunctionsThatMatchTargetTypeExactly()) {
13921 EliminateSuboptimalCudaMatches();
13925 if (Matches.size() > 1 && !eliminiateSuboptimalOverloadCandidates()) {
13926 if (FoundNonTemplateFunction) {
13927 EliminateAllTemplateMatches();
13928 EliminateLessPartialOrderingConstrainedMatches();
13930 EliminateAllExceptMostSpecializedTemplate();
13935 bool hasComplained()
const {
return HasComplained; }
13938 bool candidateHasExactlyCorrectType(
const FunctionDecl *FD) {
13945 bool isBetterCandidate(
const FunctionDecl *A,
const FunctionDecl *B) {
13949 return candidateHasExactlyCorrectType(A) &&
13950 (!candidateHasExactlyCorrectType(B) ||
13956 bool eliminiateSuboptimalOverloadCandidates() {
13959 auto Best = Matches.begin();
13960 for (
auto I = Matches.begin()+1, E = Matches.end(); I != E; ++I)
13961 if (isBetterCandidate(I->second, Best->second))
13964 const FunctionDecl *BestFn = Best->second;
13965 auto IsBestOrInferiorToBest = [
this, BestFn](
13966 const std::pair<DeclAccessPair, FunctionDecl *> &Pair) {
13967 return BestFn == Pair.second || isBetterCandidate(BestFn, Pair.second);
13972 if (!llvm::all_of(Matches, IsBestOrInferiorToBest))
13974 Matches[0] = *Best;
13979 bool isTargetTypeAFunction()
const {
13988 void inline ExtractUnqualifiedFunctionTypeFromTargetType() {
13994 const DeclAccessPair& CurAccessFunPair) {
13995 if (CXXMethodDecl *
Method
13999 bool CanConvertToFunctionPointer =
14000 Method->isStatic() ||
Method->isExplicitObjectMemberFunction();
14001 if (CanConvertToFunctionPointer == TargetTypeIsNonStaticMemberFunction)
14004 else if (TargetTypeIsNonStaticMemberFunction)
14014 TemplateDeductionInfo Info(FailedCandidates.
getLocation());
14018 Result != TemplateDeductionResult::Success) {
14036 Matches.push_back(std::make_pair(CurAccessFunPair,
Specialization));
14040 bool AddMatchingNonTemplateFunction(NamedDecl* Fn,
14041 const DeclAccessPair& CurAccessFunPair) {
14042 if (CXXMethodDecl *
Method = dyn_cast<CXXMethodDecl>(Fn)) {
14045 bool CanConvertToFunctionPointer =
14046 Method->isStatic() ||
Method->isExplicitObjectMemberFunction();
14047 if (CanConvertToFunctionPointer == TargetTypeIsNonStaticMemberFunction)
14050 else if (TargetTypeIsNonStaticMemberFunction)
14053 if (FunctionDecl *FunDecl = dyn_cast<FunctionDecl>(Fn)) {
14060 if (FunDecl->isMultiVersion()) {
14061 const auto *TA = FunDecl->getAttr<TargetAttr>();
14062 if (TA && !TA->isDefaultVersion())
14064 const auto *TVA = FunDecl->getAttr<TargetVersionAttr>();
14065 if (TVA && !TVA->isDefaultVersion())
14073 HasComplained |= Complain;
14082 candidateHasExactlyCorrectType(FunDecl)) {
14083 Matches.push_back(std::make_pair(
14085 FoundNonTemplateFunction =
true;
14093 bool FindAllFunctionsThatMatchTargetTypeExactly() {
14098 if (IsInvalidFormOfPointerToMemberFunction())
14101 for (UnresolvedSetIterator I = OvlExpr->
decls_begin(),
14105 NamedDecl *
Fn = (*I)->getUnderlyingDecl();
14114 = dyn_cast<FunctionTemplateDecl>(Fn)) {
14120 AddMatchingNonTemplateFunction(Fn, I.getPair()))
14123 assert(Ret || Matches.empty());
14127 void EliminateAllExceptMostSpecializedTemplate() {
14139 UnresolvedSet<4> MatchesCopy;
14140 for (
unsigned I = 0, E = Matches.size(); I != E; ++I)
14141 MatchesCopy.
addDecl(Matches[I].second, Matches[I].first.getAccess());
14146 MatchesCopy.
begin(), MatchesCopy.
end(), FailedCandidates,
14148 S.
PDiag(diag::err_addr_ovl_ambiguous)
14149 << Matches[0].second->getDeclName(),
14150 S.
PDiag(diag::note_ovl_candidate)
14151 << (
unsigned)oc_function << (
unsigned)ocs_described_template,
14152 Complain, TargetFunctionType);
14156 Matches[0].first = Matches[
Result - MatchesCopy.
begin()].first;
14160 HasComplained |= Complain;
14163 void EliminateAllTemplateMatches() {
14166 for (
unsigned I = 0, N = Matches.size(); I != N; ) {
14167 if (Matches[I].second->getPrimaryTemplate() ==
nullptr)
14170 Matches[I] = Matches[--N];
14176 void EliminateLessPartialOrderingConstrainedMatches() {
14181 assert(Matches[0].second->getPrimaryTemplate() ==
nullptr &&
14182 "Call EliminateAllTemplateMatches() first");
14183 SmallVector<std::pair<DeclAccessPair, FunctionDecl *>, 4> Results;
14184 Results.push_back(Matches[0]);
14185 for (
unsigned I = 1, N = Matches.size(); I < N; ++I) {
14186 assert(Matches[I].second->getPrimaryTemplate() ==
nullptr);
14188 S, Matches[I].second, Results[0].second,
14192 Results.push_back(Matches[I]);
14195 if (F == Matches[I].second) {
14197 Results.push_back(Matches[I]);
14200 std::swap(Matches, Results);
14203 void EliminateSuboptimalCudaMatches() {
14209 void ComplainNoMatchesFound()
const {
14210 assert(Matches.empty());
14212 << OvlExpr->
getName() << TargetFunctionType
14214 if (FailedCandidates.
empty())
14221 for (UnresolvedSetIterator I = OvlExpr->
decls_begin(),
14224 if (FunctionDecl *Fun =
14225 dyn_cast<FunctionDecl>((*I)->getUnderlyingDecl()))
14233 bool IsInvalidFormOfPointerToMemberFunction()
const {
14234 return TargetTypeIsNonStaticMemberFunction &&
14238 void ComplainIsInvalidFormOfPointerToMemberFunction()
const {
14246 bool IsStaticMemberFunctionFromBoundPointer()
const {
14247 return StaticMemberFunctionFromBoundPointer;
14250 void ComplainIsStaticMemberFunctionFromBoundPointer()
const {
14252 diag::err_invalid_form_pointer_member_function)
14256 void ComplainOfInvalidConversion()
const {
14258 << OvlExpr->
getName() << TargetType;
14261 void ComplainMultipleMatchesFound()
const {
14262 assert(Matches.size() > 1);
14269 bool hadMultipleCandidates()
const {
return (OvlExpr->
getNumDecls() > 1); }
14271 int getNumMatches()
const {
return Matches.size(); }
14273 FunctionDecl* getMatchingFunctionDecl()
const {
14274 if (Matches.size() != 1)
return nullptr;
14275 return Matches[0].second;
14278 const DeclAccessPair* getMatchingFunctionAccessPair()
const {
14279 if (Matches.size() != 1)
return nullptr;
14280 return &Matches[0].first;
14290 bool *pHadMultipleCandidates) {
14293 AddressOfFunctionResolver Resolver(*
this, AddressOfExpr, TargetType,
14295 int NumMatches = Resolver.getNumMatches();
14297 bool ShouldComplain = Complain && !Resolver.hasComplained();
14298 if (NumMatches == 0 && ShouldComplain) {
14299 if (Resolver.IsInvalidFormOfPointerToMemberFunction())
14300 Resolver.ComplainIsInvalidFormOfPointerToMemberFunction();
14302 Resolver.ComplainNoMatchesFound();
14304 else if (NumMatches > 1 && ShouldComplain)
14305 Resolver.ComplainMultipleMatchesFound();
14306 else if (NumMatches == 1) {
14307 Fn = Resolver.getMatchingFunctionDecl();
14311 FoundResult = *Resolver.getMatchingFunctionAccessPair();
14313 if (Resolver.IsStaticMemberFunctionFromBoundPointer())
14314 Resolver.ComplainIsStaticMemberFunctionFromBoundPointer();
14320 if (pHadMultipleCandidates)
14321 *pHadMultipleCandidates = Resolver.hadMultipleCandidates();
14329 bool IsResultAmbiguous =
false;
14337 return static_cast<int>(
CUDA().IdentifyPreference(Caller, FD1)) -
14338 static_cast<int>(
CUDA().IdentifyPreference(Caller, FD2));
14345 auto *FD = dyn_cast<FunctionDecl>(I->getUnderlyingDecl());
14353 auto FoundBetter = [&]() {
14354 IsResultAmbiguous =
false;
14366 int PreferenceByCUDA = CheckCUDAPreference(FD,
Result);
14368 if (PreferenceByCUDA != 0) {
14370 if (PreferenceByCUDA > 0)
14383 if (
Result->isFunctionTemplateSpecialization() !=
14398 if (MoreConstrained != FD) {
14399 if (!MoreConstrained) {
14400 IsResultAmbiguous =
true;
14401 AmbiguousDecls.push_back(FD);
14410 if (IsResultAmbiguous)
14431 ExprResult &SrcExpr,
bool DoFunctionPointerConversion) {
14433 assert(E->
getType() ==
Context.OverloadTy &&
"SrcExpr must be an overload");
14437 if (!
Found ||
Found->isCPUDispatchMultiVersion() ||
14438 Found->isCPUSpecificMultiVersion())
14486 dyn_cast<FunctionTemplateDecl>((*I)->getUnderlyingDecl());
14517 if (ForTypeDeduction &&
14531 if (FoundResult) *FoundResult = I.getPair();
14542 ExprResult &SrcExpr,
bool doFunctionPointerConversion,
bool complain,
14544 unsigned DiagIDForComplaining) {
14565 if (!complain)
return false;
14568 diag::err_bound_member_function)
14581 SingleFunctionExpression =
14585 if (doFunctionPointerConversion) {
14586 SingleFunctionExpression =
14588 if (SingleFunctionExpression.
isInvalid()) {
14595 if (!SingleFunctionExpression.
isUsable()) {
14597 Diag(OpRangeForComplaining.
getBegin(), DiagIDForComplaining)
14599 << DestTypeForComplaining
14600 << OpRangeForComplaining
14611 SrcExpr = SingleFunctionExpression;
14621 bool PartialOverloading,
14628 if (ExplicitTemplateArgs) {
14629 assert(!KnownValid &&
"Explicit template arguments?");
14638 PartialOverloading);
14643 = dyn_cast<FunctionTemplateDecl>(Callee)) {
14645 ExplicitTemplateArgs, Args, CandidateSet,
14647 PartialOverloading);
14651 assert(!KnownValid &&
"unhandled case in overloaded call candidate");
14657 bool PartialOverloading) {
14680 assert(!(*I)->getDeclContext()->isRecord());
14682 !(*I)->getDeclContext()->isFunctionOrMethod());
14683 assert((*I)->getUnderlyingDecl()->isFunctionOrFunctionTemplate());
14693 ExplicitTemplateArgs = &TABuffer;
14699 CandidateSet, PartialOverloading,
14704 Args, ExplicitTemplateArgs,
14705 CandidateSet, PartialOverloading);
14713 CandidateSet,
false,
false);
14720 case OO_New:
case OO_Array_New:
14721 case OO_Delete:
case OO_Array_Delete:
14745 if (DC->isTransparentContext())
14751 R.suppressDiagnostics();
14756 for (
auto &Cand : ResolvedCandidates) {
14769 if (
auto *RD = dyn_cast<CXXRecordDecl>(DC)) {
14774 if (FoundInClass) {
14775 *FoundInClass = RD;
14778 R.addDecl(Best->FoundDecl.getDecl(), Best->FoundDecl.getAccess());
14795 AssociatedNamespaces,
14796 AssociatedClasses);
14800 for (Sema::AssociatedNamespaceSet::iterator
14801 it = AssociatedNamespaces.begin(),
14802 end = AssociatedNamespaces.end(); it !=
end; ++it) {
14814 SuggestedNamespaces.insert(*it);
14818 SemaRef.
Diag(R.getNameLoc(), diag::err_not_found_by_two_phase_lookup)
14819 << R.getLookupName();
14820 if (SuggestedNamespaces.empty()) {
14821 SemaRef.
Diag(Best->Function->getLocation(),
14822 diag::note_not_found_by_two_phase_lookup)
14823 << R.getLookupName() << 0;
14824 }
else if (SuggestedNamespaces.size() == 1) {
14825 SemaRef.
Diag(Best->Function->getLocation(),
14826 diag::note_not_found_by_two_phase_lookup)
14827 << R.getLookupName() << 1 << *SuggestedNamespaces.begin();
14832 SemaRef.
Diag(Best->Function->getLocation(),
14833 diag::note_not_found_by_two_phase_lookup)
14834 << R.getLookupName() << 2;
14860 ResolvedCandidateSet,
14861 nullptr, Args,
nullptr);
14865class BuildRecoveryCallExprRAII {
14867 Sema::SatisfactionStackResetRAII SatStack;
14870 BuildRecoveryCallExprRAII(Sema &S) : SemaRef(S), SatStack(S) {
14891 bool AllowTypoCorrection) {
14899 BuildRecoveryCallExprRAII RCE(SemaRef);
14909 ExplicitTemplateArgs = &TABuffer;
14917 ResolvedCandidateSet, ExplicitTemplateArgs, Args, &FoundInClass)) {
14919 }
else if (ResolvedCandidateSet.
empty()) {
14924 ExplicitTemplateArgs !=
nullptr,
14925 dyn_cast<MemberExpr>(Fn));
14927 AllowTypoCorrection
14933 }
else if (FoundInClass && SemaRef.
getLangOpts().MSVCCompat) {
14948 assert(!R.empty() &&
"lookup results empty despite recovery");
14951 if (R.isAmbiguous()) {
14952 R.suppressDiagnostics();
14959 if ((*R.begin())->isCXXClassMember())
14961 ExplicitTemplateArgs, S);
14962 else if (ExplicitTemplateArgs || TemplateKWLoc.
isValid())
14964 ExplicitTemplateArgs);
14988 assert(!ULE->
getQualifier() &&
"qualified name with ADL");
14995 (F = dyn_cast<FunctionDecl>(*ULE->
decls_begin())) &&
14997 llvm_unreachable(
"performing ADL for builtin");
15004 UnbridgedCastsSet UnbridgedCasts;
15019 if (CandidateSet->
empty() ||
15035 if (CandidateSet->
empty())
15038 UnbridgedCasts.restore();
15045 std::optional<QualType>
Result;
15065 if (Best && *Best != CS.
end())
15066 ConsiderCandidate(**Best);
15069 for (
const auto &
C : CS)
15071 ConsiderCandidate(
C);
15074 for (
const auto &
C : CS)
15075 ConsiderCandidate(
C);
15080 if (
Value.isNull() ||
Value->isUndeducedType())
15097 bool AllowTypoCorrection) {
15098 switch (OverloadResult) {
15109 Res.
get(), FDecl, LParenLoc, Args, RParenLoc, ExecConfig,
15115 if (*Best != CandidateSet->
end() &&
15119 dyn_cast_if_present<CXXMethodDecl>((*Best)->Function);
15124 SemaRef.
PDiag(diag::err_member_call_without_object) << 0 << M),
15134 *CandidateSet, AllowTypoCorrection);
15141 for (
const Expr *Arg : Args) {
15142 if (!Arg->getType()->isFunctionType())
15144 if (
auto *DRE = dyn_cast<DeclRefExpr>(Arg->IgnoreParenImpCasts())) {
15145 auto *FD = dyn_cast<FunctionDecl>(DRE->getDecl());
15148 Arg->getExprLoc()))
15156 SemaRef.
PDiag(diag::err_ovl_no_viable_function_in_call)
15157 << ULE->
getName() << Fn->getSourceRange()),
15165 SemaRef.
PDiag(diag::err_ovl_ambiguous_call)
15166 << ULE->
getName() << Fn->getSourceRange()),
15173 Fn->getSourceRange(), ULE->
getName(),
15174 *CandidateSet, FDecl, Args);
15183 Res.
get(), FDecl, LParenLoc, Args, RParenLoc, ExecConfig,
15191 SubExprs.append(Args.begin(), Args.end());
15198 for (
auto I = CS.
begin(), E = CS.
end(); I != E; ++I) {
15213 bool AllowTypoCorrection,
15214 bool CalleesAddressIsTaken) {
15229 if (CalleesAddressIsTaken)
15240 Best != CandidateSet.
end()) {
15241 if (
auto *M = dyn_cast_or_null<CXXMethodDecl>(Best->Function);
15242 M && M->isImplicitObjectMemberFunction()) {
15253 CUDA().recordPotentialODRUsedVariable(Args, CandidateSet);
15271 if (
const auto *TP =
15281 ExecConfig, &CandidateSet, &Best,
15282 OverloadResult, AllowTypoCorrection);
15291 Context, NamingClass, NNSLoc, DNI, PerformADL, Fns.
begin(), Fns.
end(),
15297 bool HadMultipleCandidates) {
15307 if (
Method->isExplicitObjectMemberFunction())
15311 E, std::nullopt, FoundDecl,
Method);
15315 if (
Method->getParent()->isLambda() &&
15316 Method->getConversionType()->isBlockPointerType()) {
15320 auto *CE = dyn_cast<CastExpr>(SubE);
15321 if (CE && CE->getCastKind() == CK_NoOp)
15322 SubE = CE->getSubExpr();
15324 if (
auto *BE = dyn_cast<CXXBindTemporaryExpr>(SubE))
15325 SubE = BE->getSubExpr();
15348 if (
Method->isExplicitObjectMemberFunction()) {
15354 Expr *ObjectParam = Exp.
get();
15368 Exp.
get()->getEndLoc(),
15383 assert(Op !=
OO_None &&
"Invalid opcode for overloaded unary operator");
15400 Expr *Input,
bool PerformADL) {
15402 assert(Op !=
OO_None &&
"Invalid opcode for overloaded unary operator");
15410 Expr *Args[2] = { Input,
nullptr };
15411 unsigned NumArgs = 1;
15416 if (Opc == UO_PostInc || Opc == UO_PostDec) {
15430 if (Opc == UO_PreDec || Opc == UO_PreInc || Opc == UO_Deref)
15441 if (Fn.isInvalid())
15452 bool HadMultipleCandidates = (CandidateSet.
size() > 1);
15471 if (
Method->isExplicitObjectMemberFunction())
15475 Input, std::nullopt, Best->FoundDecl,
Method);
15478 Base = Input = InputInit.
get();
15489 Input = InputInit.
get();
15494 Base, HadMultipleCandidates,
15506 Context, Op, FnExpr.
get(), ArgsArray, ResultTy,
VK, OpLoc,
15522 Input, Best->BuiltinParamTypes[0], Best->Conversions[0],
15527 Input = InputRes.
get();
15548 PDiag(diag::err_ovl_ambiguous_oper_unary)
15565 << (Msg !=
nullptr)
15566 << (Msg ? Msg->
getString() : StringRef())
15619 if (Op != OO_Equal && PerformADL) {
15626 Context.DeclarationNames.getCXXOperatorName(ExtraOp);
15652 Expr *RHS,
bool PerformADL,
15653 bool AllowRewrittenCandidates,
15655 Expr *Args[2] = { LHS, RHS };
15659 AllowRewrittenCandidates =
false;
15665 if (Args[0]->isTypeDependent() || Args[1]->isTypeDependent()) {
15686 if (Fn.isInvalid())
15695 if (Opc == BO_PtrMemD) {
15696 auto CheckPlaceholder = [&](
Expr *&Arg) {
15705 if (CheckPlaceholder(Args[0]) || CheckPlaceholder(Args[1]))
15729 if (Opc == BO_Assign &&
15738 Op, OpLoc, AllowRewrittenCandidates));
15740 CandidateSet.
exclude(DefaultedFn);
15743 bool HadMultipleCandidates = (CandidateSet.
size() > 1);
15752 bool IsReversed = Best->isReversed();
15754 std::swap(Args[0], Args[1]);
15771 if (Best->RewriteKind && ChosenOp == OO_EqualEqual &&
15775 Diag(OpLoc, IsExtension ? diag::ext_ovl_rewrite_equalequal_not_bool
15776 : diag::err_ovl_rewrite_equalequal_not_bool)
15784 if (AllowRewrittenCandidates && !IsReversed &&
15794 for (
unsigned ArgIdx = 0; ArgIdx < 2; ++ArgIdx) {
15797 Best->Conversions[ArgIdx]) ==
15799 AmbiguousWith.push_back(Cand.
Function);
15806 if (!AmbiguousWith.empty()) {
15807 bool AmbiguousWithSelf =
15808 AmbiguousWith.size() == 1 &&
15810 Diag(OpLoc, diag::ext_ovl_ambiguous_oper_binary_reversed)
15812 << Args[0]->
getType() << Args[1]->
getType() << AmbiguousWithSelf
15814 if (AmbiguousWithSelf) {
15816 diag::note_ovl_ambiguous_oper_binary_reversed_self);
15821 if (
auto *MD = dyn_cast<CXXMethodDecl>(FnDecl))
15822 if (Op == OverloadedOperatorKind::OO_EqualEqual &&
15824 !MD->hasCXXExplicitFunctionObjectParameter() &&
15825 Context.hasSameUnqualifiedType(
15826 MD->getFunctionObjectParameterType(),
15827 MD->getParamDecl(0)->getType().getNonReferenceType()) &&
15828 Context.hasSameUnqualifiedType(
15829 MD->getFunctionObjectParameterType(),
15831 Context.hasSameUnqualifiedType(
15832 MD->getFunctionObjectParameterType(),
15835 diag::note_ovl_ambiguous_eqeq_reversed_self_non_const);
15838 diag::note_ovl_ambiguous_oper_binary_selected_candidate);
15839 for (
auto *F : AmbiguousWith)
15841 diag::note_ovl_ambiguous_oper_binary_reversed_candidate);
15849 if (Op == OO_Equal)
15860 if (
Method->isExplicitObjectMemberFunction()) {
15865 Args[0], std::nullopt, Best->FoundDecl,
Method);
15898 Best->FoundDecl,
Base,
15899 HadMultipleCandidates, OpLoc);
15905 Pattern->setIsUsed();
15914 const Expr *ImplicitThis =
nullptr;
15919 Context, ChosenOp, FnExpr.
get(), Args, ResultTy,
VK, OpLoc,
15924 if (
const auto *
Method = dyn_cast<CXXMethodDecl>(FnDecl);
15927 ImplicitThis = ArgsArray[0];
15928 ArgsArray = ArgsArray.slice(1);
15935 if (Op == OO_Equal) {
15940 *
this,
AssignedEntity{Args[0], dyn_cast<CXXMethodDecl>(FnDecl)},
15943 if (ImplicitThis) {
15948 CheckArgAlignment(OpLoc, FnDecl,
"'this'", ThisType,
15952 checkCall(FnDecl,
nullptr, ImplicitThis, ArgsArray,
15967 (Op == OO_Spaceship && IsReversed)) {
15968 if (Op == OO_ExclaimEqual) {
15969 assert(ChosenOp == OO_EqualEqual &&
"unexpected operator name");
15972 assert(ChosenOp == OO_Spaceship &&
"unexpected operator name");
15974 Expr *ZeroLiteral =
15983 OpLoc, Opc, Fns, IsReversed ? ZeroLiteral : R.get(),
15984 IsReversed ? R.get() : ZeroLiteral,
true,
15992 assert(ChosenOp == Op &&
"unexpected operator name");
15996 if (Best->RewriteKind !=
CRK_None)
16005 Args[0], Best->BuiltinParamTypes[0], Best->Conversions[0],
16010 Args[0] = ArgsRes0.
get();
16013 Args[1], Best->BuiltinParamTypes[1], Best->Conversions[1],
16018 Args[1] = ArgsRes1.
get();
16028 if (Opc == BO_Comma)
16033 if (DefaultedFn && Opc == BO_Cmp) {
16035 Args[1], DefaultedFn);
16050 Opc >= BO_Assign && Opc <= BO_OrAssign) {
16051 Diag(OpLoc, diag::err_ovl_no_viable_oper)
16054 if (Args[0]->
getType()->isIncompleteType()) {
16055 Diag(OpLoc, diag::note_assign_lhs_incomplete)
16072 assert(
Result.isInvalid() &&
16073 "C++ binary operator overloading is missing candidates!");
16084 << Args[0]->getSourceRange()
16085 << Args[1]->getSourceRange()),
16096 Diag(OpLoc, diag::err_ovl_deleted_special_oper)
16100 Diag(OpLoc, diag::err_ovl_deleted_comparison)
16101 << Args[0]->
getType() << DeletedFD;
16114 PDiag(diag::err_ovl_deleted_oper)
16116 .getCXXOverloadedOperator())
16117 << (Msg !=
nullptr) << (Msg ? Msg->
getString() : StringRef())
16118 << Args[0]->getSourceRange() << Args[1]->getSourceRange()),
16142 "cannot use prvalue expressions more than once");
16143 Expr *OrigLHS = LHS;
16144 Expr *OrigRHS = RHS;
16161 true, DefaultedFn);
16162 if (
Less.isInvalid())
16189 for (; I >= 0; --I) {
16191 auto *VI = Info->lookupValueInfo(Comparisons[I].
Result);
16214 Context, OrigLHS, OrigRHS, BO_Cmp,
Result.get()->getType(),
16215 Result.get()->getValueKind(),
Result.get()->getObjectKind(), OpLoc,
16217 Expr *SemanticForm[] = {LHS, RHS,
Result.get()};
16227 unsigned NumArgsSlots =
16228 MethodArgs.size() + std::max<unsigned>(Args.size(), NumParams);
16231 MethodArgs.reserve(MethodArgs.size() + NumArgsSlots);
16232 bool IsError =
false;
16235 for (
unsigned i = 0; i != NumParams; i++) {
16237 if (i < Args.size()) {
16241 S.
Context, Method->getParamDecl(i)),
16255 MethodArgs.push_back(Arg);
16265 Args.push_back(
Base);
16266 for (
auto *e : ArgExpr) {
16270 Context.DeclarationNames.getCXXOperatorName(OO_Subscript);
16275 ArgExpr.back()->getEndLoc());
16287 if (Fn.isInvalid())
16297 UnbridgedCastsSet UnbridgedCasts;
16310 if (Args.size() == 2)
16313 bool HadMultipleCandidates = (CandidateSet.
size() > 1);
16333 if (
Method->isExplicitObjectMemberFunction()) {
16338 Args[0] = Res.
get();
16342 Args[0], std::nullopt, Best->FoundDecl,
Method);
16346 MethodArgs.push_back(Arg0.
get());
16350 *
this, MethodArgs,
Method, ArgExpr, LLoc);
16359 HadMultipleCandidates, OpLocInfo);
16369 Context, OO_Subscript, FnExpr.
get(), MethodArgs, ResultTy,
VK, RLoc,
16386 Args[0], Best->BuiltinParamTypes[0], Best->Conversions[0],
16391 Args[0] = ArgsRes0.
get();
16394 Args[1], Best->BuiltinParamTypes[1], Best->Conversions[1],
16399 Args[1] = ArgsRes1.
get();
16407 CandidateSet.
empty()
16408 ? (
PDiag(diag::err_ovl_no_oper)
16409 << Args[0]->getType() << 0
16410 << Args[0]->getSourceRange() << Range)
16411 : (
PDiag(diag::err_ovl_no_viable_subscript)
16412 << Args[0]->getType() << Args[0]->getSourceRange() << Range);
16419 if (Args.size() == 2) {
16422 LLoc,
PDiag(diag::err_ovl_ambiguous_oper_binary)
16424 << Args[0]->getSourceRange() << Range),
16429 PDiag(diag::err_ovl_ambiguous_subscript_call)
16431 << Args[0]->getSourceRange() << Range),
16440 PDiag(diag::err_ovl_deleted_oper)
16441 <<
"[]" << (Msg !=
nullptr)
16442 << (Msg ? Msg->
getString() : StringRef())
16443 << Args[0]->getSourceRange() << Range),
16457 Expr *ExecConfig,
bool IsExecConfig,
16458 bool AllowRecovery) {
16467 if (
BinaryOperator *op = dyn_cast<BinaryOperator>(NakedMemExpr)) {
16468 assert(op->getType() ==
Context.BoundMemberTy);
16469 assert(op->getOpcode() == BO_PtrMemD || op->getOpcode() == BO_PtrMemI);
16482 QualType objectType = op->getLHS()->getType();
16483 if (op->getOpcode() == BO_PtrMemI)
16487 Qualifiers difference = objectQuals - funcQuals;
16491 std::string qualsString = difference.
getAsString();
16492 Diag(LParenLoc, diag::err_pointer_to_member_call_drops_quals)
16495 << (qualsString.find(
' ') == std::string::npos ? 1 : 2);
16499 Context, MemExprE, Args, resultType, valueKind, RParenLoc,
16509 if (CheckOtherCall(call, proto))
16519 if (!AllowRecovery)
16521 std::vector<Expr *> SubExprs = {MemExprE};
16522 llvm::append_range(SubExprs, Args);
16530 UnbridgedCastsSet UnbridgedCasts;
16536 bool HadMultipleCandidates =
false;
16544 UnbridgedCasts.restore();
16562 TemplateArgs = &TemplateArgsBuffer;
16566 E = UnresExpr->
decls_end(); I != E; ++I) {
16568 QualType ExplicitObjectType = ObjectType;
16575 bool HasExplicitParameter =
false;
16576 if (
const auto *M = dyn_cast<FunctionDecl>(
Func);
16577 M && M->hasCXXExplicitFunctionObjectParameter())
16578 HasExplicitParameter =
true;
16579 else if (
const auto *M = dyn_cast<FunctionTemplateDecl>(
Func);
16581 M->getTemplatedDecl()->hasCXXExplicitFunctionObjectParameter())
16582 HasExplicitParameter =
true;
16584 if (HasExplicitParameter)
16592 }
else if ((
Method = dyn_cast<CXXMethodDecl>(
Func))) {
16599 ObjectClassification, Args, CandidateSet,
16603 I.getPair(), ActingDC, TemplateArgs,
16604 ExplicitObjectType, ObjectClassification,
16605 Args, CandidateSet,
16610 HadMultipleCandidates = (CandidateSet.
size() > 1);
16614 UnbridgedCasts.restore();
16617 bool Succeeded =
false;
16622 FoundDecl = Best->FoundDecl;
16642 PDiag(diag::err_ovl_no_viable_member_function_in_call)
16649 PDiag(diag::err_ovl_ambiguous_member_call)
16656 CandidateSet, Best->Function, Args,
true);
16667 MemExprE = Res.
get();
16671 if (
Method->isStatic()) {
16673 ExecConfig, IsExecConfig);
16683 assert(
Method &&
"Member call to something that isn't a method?");
16688 if (
Method->isExplicitObjectMemberFunction()) {
16697 TemplateArgs = &TemplateArgsBuffer;
16703 Method, FoundDecl, MemExpr, HadMultipleCandidates,
16711 TheCall->setUsesMemberSyntax(
true);
16721 Proto->getNumParams());
16727 return BuildRecoveryExpr(ResultType);
16732 return BuildRecoveryExpr(ResultType);
16742 if (
auto *MemE = dyn_cast<MemberExpr>(NakedMemExpr)) {
16743 if (
const EnableIfAttr *
Attr =
16745 Diag(MemE->getMemberLoc(),
16746 diag::err_ovl_no_viable_member_function_in_call)
16749 diag::note_ovl_candidate_disabled_by_function_cond_attr)
16750 <<
Attr->getCond()->getSourceRange() <<
Attr->getMessage();
16756 TheCall->getDirectCallee()->isPureVirtual()) {
16762 diag::warn_call_to_pure_virtual_member_function_from_ctor_dtor)
16773 if (
auto *DD = dyn_cast<CXXDestructorDecl>(TheCall->getDirectCallee())) {
16777 CallCanBeVirtual,
true,
16782 TheCall->getDirectCallee());
16794 UnbridgedCastsSet UnbridgedCasts;
16798 assert(
Object.get()->getType()->isRecordType() &&
16799 "Requires object type argument");
16813 diag::err_incomplete_object_call,
Object.get()))
16816 auto *
Record =
Object.get()->getType()->castAsCXXRecordDecl();
16819 R.suppressAccessDiagnostics();
16822 Oper != OperEnd; ++Oper) {
16836 bool IgnoreSurrogateFunctions =
false;
16839 if (!Candidate.
Viable &&
16841 IgnoreSurrogateFunctions =
true;
16863 !IgnoreSurrogateFunctions && I != E; ++I) {
16885 Object.get(), Args, CandidateSet);
16890 bool HadMultipleCandidates = (CandidateSet.
size() > 1);
16903 CandidateSet.
empty()
16904 ? (
PDiag(diag::err_ovl_no_oper)
16905 <<
Object.get()->getType() << 1
16906 <<
Object.get()->getSourceRange())
16907 : (
PDiag(diag::err_ovl_no_viable_object_call)
16908 <<
Object.get()->getType() <<
Object.get()->getSourceRange());
16915 if (!R.isAmbiguous())
16918 PDiag(diag::err_ovl_ambiguous_object_call)
16919 <<
Object.get()->getType()
16920 <<
Object.get()->getSourceRange()),
16931 PDiag(diag::err_ovl_deleted_object_call)
16932 <<
Object.get()->getType() << (Msg !=
nullptr)
16933 << (Msg ? Msg->
getString() : StringRef())
16934 <<
Object.get()->getSourceRange()),
16940 if (Best == CandidateSet.
end())
16943 UnbridgedCasts.restore();
16945 if (Best->Function ==
nullptr) {
16950 Best->Conversions[0].UserDefined.ConversionFunction);
16954 "Found Decl & conversion-to-functionptr should be same, right?!");
16966 Conv, HadMultipleCandidates);
16967 if (
Call.isInvalid())
16971 Context,
Call.get()->getType(), CK_UserDefinedConversion,
Call.get(),
16985 if (
Method->isInvalidDecl())
16992 Context.DeclarationNames.getCXXOperatorName(OO_Call), LParenLoc);
16995 HadMultipleCandidates, OpLocInfo);
17000 MethodArgs.reserve(NumParams + 1);
17002 bool IsError =
false;
17006 if (
Method->isExplicitObjectMemberFunction()) {
17015 MethodArgs.push_back(
Object.get());
17019 *
this, MethodArgs,
Method, Args, LParenLoc);
17022 if (Proto->isVariadic()) {
17024 for (
unsigned i = NumParams, e = Args.size(); i < e; i++) {
17028 MethodArgs.push_back(Arg.
get());
17043 Context, OO_Call, NewFn.
get(), MethodArgs, ResultTy,
VK, RParenLoc,
17057 bool *NoArrowOperatorFound) {
17058 assert(
Base->getType()->isRecordType() &&
17059 "left-hand side must have class type");
17073 Context.DeclarationNames.getCXXOperatorName(OO_Arrow);
17077 diag::err_typecheck_incomplete_tag,
Base))
17082 R.suppressAccessDiagnostics();
17085 Oper != OperEnd; ++Oper) {
17091 bool HadMultipleCandidates = (CandidateSet.
size() > 1);
17102 if (CandidateSet.
empty()) {
17104 if (NoArrowOperatorFound) {
17107 *NoArrowOperatorFound =
true;
17110 Diag(OpLoc, diag::err_typecheck_member_reference_arrow)
17111 << BaseType <<
Base->getSourceRange();
17112 if (BaseType->isRecordType() && !BaseType->isPointerType()) {
17113 Diag(OpLoc, diag::note_typecheck_member_reference_suggestion)
17117 Diag(OpLoc, diag::err_ovl_no_viable_oper)
17118 <<
"operator->" <<
Base->getSourceRange();
17123 if (!R.isAmbiguous())
17126 <<
"->" <<
Base->getType()
17127 <<
Base->getSourceRange()),
17135 <<
"->" << (Msg !=
nullptr)
17136 << (Msg ? Msg->
getString() : StringRef())
17137 <<
Base->getSourceRange()),
17148 if (
Method->isExplicitObjectMemberFunction()) {
17155 Base, std::nullopt, Best->FoundDecl,
Method);
17163 Base, HadMultipleCandidates, OpLoc);
17197 bool HadMultipleCandidates = (CandidateSet.
size() > 1);
17210 PDiag(diag::err_ovl_no_viable_function_in_call)
17211 << R.getLookupName()),
17218 << R.getLookupName()),
17225 HadMultipleCandidates, SuffixInfo);
17226 if (Fn.isInvalid())
17232 for (
unsigned ArgIdx = 0, N = Args.size(); ArgIdx != N; ++ArgIdx) {
17238 ConvArgs[ArgIdx] = InputInit.
get();
17265 Scope *S =
nullptr;
17268 if (!MemberLookup.
empty()) {
17295 if (CandidateSet->
empty() || CandidateSetError) {
17308 Loc,
nullptr, CandidateSet, &Best,
17321 if (
ParenExpr *PE = dyn_cast<ParenExpr>(E)) {
17326 if (SubExpr.
get() == PE->getSubExpr())
17330 ParenExpr(PE->getLParen(), PE->getRParen(), SubExpr.
get());
17338 assert(
Context.hasSameType(ICE->getSubExpr()->getType(),
17340 "Implicit cast type cannot be determined from overload");
17341 assert(ICE->path_empty() &&
"fixing up hierarchy conversion?");
17342 if (SubExpr.
get() == ICE->getSubExpr())
17350 if (
auto *GSE = dyn_cast<GenericSelectionExpr>(E)) {
17351 if (!GSE->isResultDependent()) {
17356 if (SubExpr.
get() == GSE->getResultExpr())
17363 unsigned ResultIdx = GSE->getResultIndex();
17364 AssocExprs[ResultIdx] = SubExpr.
get();
17366 if (GSE->isExprPredicate())
17368 Context, GSE->getGenericLoc(), GSE->getControllingExpr(),
17369 GSE->getAssocTypeSourceInfos(), AssocExprs, GSE->getDefaultLoc(),
17370 GSE->getRParenLoc(), GSE->containsUnexpandedParameterPack(),
17373 Context, GSE->getGenericLoc(), GSE->getControllingType(),
17374 GSE->getAssocTypeSourceInfos(), AssocExprs, GSE->getDefaultLoc(),
17375 GSE->getRParenLoc(), GSE->containsUnexpandedParameterPack(),
17384 assert(UnOp->getOpcode() == UO_AddrOf &&
17385 "Can only take the address of an overloaded function");
17387 if (!
Method->isImplicitObjectMemberFunction()) {
17398 if (SubExpr.
get() == UnOp->getSubExpr())
17406 "fixed to something other than a decl ref");
17409 assert(Qualifier &&
17410 "fixed to a member ref with no nested name qualifier");
17416 Fn->getType(), Qualifier,
17419 if (
Context.getTargetInfo().getCXXABI().isMicrosoft())
17424 UnOp->getOperatorLoc(),
false,
17432 if (SubExpr.
get() == UnOp->getSubExpr())
17445 if (ULE->hasExplicitTemplateArgs()) {
17446 ULE->copyTemplateArgumentsInto(TemplateArgsBuffer);
17447 TemplateArgs = &TemplateArgsBuffer;
17452 getLangOpts().CPlusPlus && !Fn->hasCXXExplicitFunctionObjectParameter()
17457 if (
unsigned BID = Fn->getBuiltinID()) {
17458 if (!
Context.BuiltinInfo.isDirectlyAddressable(BID)) {
17465 Fn,
Type, ValueKind, ULE->getNameInfo(), ULE->getQualifierLoc(),
17466 Found.getDecl(), ULE->getTemplateKeywordLoc(), TemplateArgs);
17474 if (MemExpr->hasExplicitTemplateArgs()) {
17475 MemExpr->copyTemplateArgumentsInto(TemplateArgsBuffer);
17476 TemplateArgs = &TemplateArgsBuffer;
17483 if (MemExpr->isImplicitAccess()) {
17486 Fn, Fn->getType(),
VK_LValue, MemExpr->getNameInfo(),
17487 MemExpr->getQualifierLoc(),
Found.getDecl(),
17488 MemExpr->getTemplateKeywordLoc(), TemplateArgs);
17493 if (MemExpr->getQualifier())
17494 Loc = MemExpr->getQualifierLoc().getBeginLoc();
17499 Base = MemExpr->getBase();
17505 type = Fn->getType();
17512 Base, MemExpr->isArrow(), MemExpr->getOperatorLoc(),
17513 MemExpr->getQualifierLoc(), MemExpr->getTemplateKeywordLoc(), Fn,
Found,
17514 true, MemExpr->getMemberNameInfo(),
17518 llvm_unreachable(
"Invalid reference to overloaded function");
17529 if (!PartialOverloading || !
Function)
17533 if (
const auto *Proto =
17534 dyn_cast<FunctionProtoType>(
Function->getFunctionType()))
17535 if (Proto->isTemplateVariadic())
17537 if (
auto *Pattern =
Function->getTemplateInstantiationPattern())
17538 if (
const auto *Proto =
17539 dyn_cast<FunctionProtoType>(Pattern->getFunctionType()))
17540 if (Proto->isTemplateVariadic())
17553 << IsMember << Name << (Msg !=
nullptr)
17554 << (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)
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 containsErrors() const
Whether this expression contains subexpressions which had errors.
Expr * IgnoreParens() LLVM_READONLY
Skip past any parentheses which might surround this expression until reaching a fixed point.
static bool hasAnyTypeDependentArguments(ArrayRef< Expr * > Exprs)
hasAnyTypeDependentArguments - Determines if any of the expressions in Exprs is type-dependent.
FieldDecl * getSourceBitField()
If this expression refers to a bit-field, retrieve the declaration of that bit-field.
@ NPC_ValueDependentIsNull
Specifies that a value-dependent expression of integral or dependent type should be considered a null...
@ NPC_ValueDependentIsNotNull
Specifies that a value-dependent expression should be considered to never be a null pointer constant.
ExprObjectKind getObjectKind() const
getObjectKind - The object kind that this expression produces.
bool EvaluateAsConstantExpr(EvalResult &Result, const ASTContext &Ctx, ConstantExprKind Kind=ConstantExprKind::Normal) const
Evaluate an expression that is required to be a constant expression.
@ NPCK_ZeroExpression
Expression is a Null pointer constant built from a zero integer expression that is not a simple,...
NullPointerConstantKind isNullPointerConstant(ASTContext &Ctx, NullPointerConstantValueDependence NPC) const
isNullPointerConstant - C99 6.3.2.3p3 - Test if this reduces down to a Null pointer constant.
SourceLocation getExprLoc() const LLVM_READONLY
getExprLoc - Return the preferred location for the arrow when diagnosing a problem with a generic exp...
bool refersToBitField() const
Returns true if this expression is a gl-value that potentially refers to a bit-field.
Classification Classify(ASTContext &Ctx) const
Classify - Classify this expression according to the C++11 expression taxonomy.
bool hasPlaceholderType() const
Returns whether this expression has a placeholder type.
static ExprValueKind getValueKindForType(QualType T)
getValueKindForType - Given a formal return or parameter type, give its value kind.
ExtVectorType - Extended vector type.
Represents difference between two FPOptions values.
Represents a member of a struct/union/class.
Annotates a diagnostic with some code that should be inserted, removed, or replaced to fix the proble...
static FixItHint CreateReplacement(CharSourceRange RemoveRange, StringRef Code)
Create a code modification hint that replaces the given source range with the given code string.
static FixItHint CreateInsertion(SourceLocation InsertionLoc, StringRef Code, bool BeforePreviousInsertions=false)
Create a code modification hint that inserts the given code string at a specific location.
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.
unsigned getNumInits() const
SourceLocation getBeginLoc() const LLVM_READONLY
const Expr * getInit(unsigned Init) const
SourceLocation getEndLoc() const LLVM_READONLY
Describes an entity that is being initialized.
static InitializedEntity InitializeParameter(ASTContext &Context, ParmVarDecl *Parm)
Create the initialization entity for a parameter.
static InitializedEntity InitializeTemplateParameter(QualType T, NamedDecl *Param)
Create the initialization entity for a template parameter.
static IntegerLiteral * Create(const ASTContext &C, const llvm::APInt &V, QualType type, SourceLocation l)
Returns a new integer literal with value 'V' and type 'type'.
An lvalue reference type, per C++11 [dcl.ref].
bool isCompatibleWithMSVC() const
Represents the results of name lookup.
void addAllDecls(const LookupResult &Other)
Add all the declarations from another set of lookup results.
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.
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.