38#include "llvm/ADT/DenseSet.h"
39#include "llvm/ADT/STLExtras.h"
40#include "llvm/ADT/STLForwardCompat.h"
41#include "llvm/ADT/ScopeExit.h"
42#include "llvm/ADT/SmallPtrSet.h"
43#include "llvm/ADT/SmallVector.h"
57 return P->hasAttr<PassObjectSizeAttr>();
78 if (HadMultipleCandidates)
89 CK_FunctionToPointerDecay);
93 bool InOverloadResolution,
96 bool AllowObjCWritebackConversion);
100 bool InOverloadResolution,
108 bool AllowObjCConversionOnExplicit);
176 return Rank[(int)Kind];
201 static const char *
const Name[] = {
205 "Function-to-pointer",
206 "Function pointer conversion",
208 "Integral promotion",
209 "Floating point promotion",
211 "Integral conversion",
212 "Floating conversion",
213 "Complex conversion",
214 "Floating-integral conversion",
215 "Pointer conversion",
216 "Pointer-to-member conversion",
217 "Boolean conversion",
218 "Compatible-types conversion",
219 "Derived-to-base conversion",
221 "SVE Vector conversion",
222 "RVV Vector conversion",
224 "Complex-real conversion",
225 "Block Pointer conversion",
226 "Transparent Union Conversion",
227 "Writeback conversion",
228 "OpenCL Zero Event Conversion",
229 "OpenCL Zero Queue Conversion",
230 "C specific type conversion",
231 "Incompatible pointer conversion",
232 "Fixed point conversion",
233 "HLSL vector truncation",
234 "HLSL matrix truncation",
235 "Non-decaying array conversion",
313 FromType = Context.getArrayDecayedType(FromType);
325 const Expr *Converted) {
328 if (
auto *EWC = dyn_cast<ExprWithCleanups>(Converted)) {
335 while (
auto *ICE = dyn_cast<ImplicitCastExpr>(Converted)) {
336 switch (ICE->getCastKind()) {
338 case CK_IntegralCast:
339 case CK_IntegralToBoolean:
340 case CK_IntegralToFloating:
341 case CK_BooleanToSignedIntegral:
342 case CK_FloatingToIntegral:
343 case CK_FloatingToBoolean:
344 case CK_FloatingCast:
345 Converted = ICE->getSubExpr();
369 QualType &ConstantType,
bool IgnoreFloatToIntegralConversion)
const {
371 "narrowing check outside C++");
382 ToType = ED->getIntegerType();
388 goto FloatingIntegralConversion;
390 goto IntegralConversion;
401 FloatingIntegralConversion:
406 if (IgnoreFloatToIntegralConversion)
409 assert(
Initializer &&
"Unknown conversion expression");
415 if (std::optional<llvm::APSInt> IntConstantValue =
419 Result.convertFromAPInt(*IntConstantValue, IntConstantValue->isSigned(),
420 llvm::APFloat::rmNearestTiesToEven);
422 llvm::APSInt ConvertedValue = *IntConstantValue;
424 llvm::APFloat::opStatus Status =
Result.convertToInteger(
425 ConvertedValue, llvm::APFloat::rmTowardZero, &ignored);
428 if (Status == llvm::APFloat::opInvalidOp ||
429 *IntConstantValue != ConvertedValue) {
430 ConstantValue =
APValue(*IntConstantValue);
458 Initializer->isCXX11ConstantExpr(Ctx, &ConstantValue)))) {
461 ConstantValue = R.Val;
462 assert(ConstantValue.
isFloat());
463 llvm::APFloat FloatVal = ConstantValue.
getFloat();
466 llvm::APFloat Converted = FloatVal;
467 llvm::APFloat::opStatus ConvertStatus =
469 llvm::APFloat::rmNearestTiesToEven, &ignored);
471 llvm::APFloat::rmNearestTiesToEven, &ignored);
473 if (FloatVal.isNaN() && Converted.isNaN() &&
474 !FloatVal.isSignaling() && !Converted.isSignaling()) {
480 if (!Converted.bitwiseIsEqual(FloatVal)) {
487 if (ConvertStatus & llvm::APFloat::opOverflow) {
509 IntegralConversion: {
517 constexpr auto CanRepresentAll = [](
bool FromSigned,
unsigned FromWidth,
518 bool ToSigned,
unsigned ToWidth) {
519 return (FromWidth < ToWidth + (FromSigned == ToSigned)) &&
520 !(FromSigned && !ToSigned);
523 if (CanRepresentAll(FromSigned, FromWidth, ToSigned, ToWidth))
529 bool DependentBitField =
false;
531 if (BitField->getBitWidth()->isValueDependent())
532 DependentBitField =
true;
533 else if (
unsigned BitFieldWidth = BitField->getBitWidthValue();
534 BitFieldWidth < FromWidth) {
535 if (CanRepresentAll(FromSigned, BitFieldWidth, ToSigned, ToWidth))
539 FromWidth = BitFieldWidth;
547 std::optional<llvm::APSInt> OptInitializerValue =
549 if (!OptInitializerValue) {
553 if (DependentBitField && !(FromSigned && !ToSigned))
559 llvm::APSInt &InitializerValue = *OptInitializerValue;
560 bool Narrowing =
false;
561 if (FromWidth < ToWidth) {
564 if (InitializerValue.isSigned() && InitializerValue.isNegative())
570 InitializerValue.extend(InitializerValue.getBitWidth() + 1);
572 llvm::APSInt ConvertedValue = InitializerValue;
573 ConvertedValue = ConvertedValue.trunc(ToWidth);
574 ConvertedValue.setIsSigned(ToSigned);
575 ConvertedValue = ConvertedValue.extend(InitializerValue.getBitWidth());
576 ConvertedValue.setIsSigned(InitializerValue.isSigned());
578 if (ConvertedValue != InitializerValue)
583 ConstantValue =
APValue(InitializerValue);
599 ConstantValue = R.Val;
600 assert(ConstantValue.
isFloat());
601 llvm::APFloat FloatVal = ConstantValue.
getFloat();
606 if (FloatVal.isNaN() && FloatVal.isSignaling()) {
622 raw_ostream &OS = llvm::errs();
623 bool PrintedSomething =
false;
626 PrintedSomething =
true;
630 if (PrintedSomething) {
636 OS <<
" (by copy constructor)";
638 OS <<
" (direct reference binding)";
640 OS <<
" (reference binding)";
642 PrintedSomething =
true;
646 if (PrintedSomething) {
650 PrintedSomething =
true;
653 if (!PrintedSomething) {
654 OS <<
"No conversions required";
661 raw_ostream &OS = llvm::errs();
669 OS <<
"aggregate initialization";
679 raw_ostream &OS = llvm::errs();
681 OS <<
"Worst list element conversion: ";
682 switch (ConversionKind) {
684 OS <<
"Standard conversion: ";
688 OS <<
"User-defined conversion: ";
692 OS <<
"Ellipsis conversion";
695 OS <<
"Ambiguous conversion";
698 OS <<
"Bad conversion";
723 struct DFIArguments {
729 struct DFIParamWithArguments : DFIArguments {
734 struct DFIDeducedMismatchArgs : DFIArguments {
735 TemplateArgumentList *TemplateArgs;
736 unsigned CallArgIndex;
741 TemplateArgumentList *TemplateArgs;
742 ConstraintSatisfaction Satisfaction;
753 Result.Result =
static_cast<unsigned>(TDK);
754 Result.HasDiagnostic =
false;
773 auto *Saved =
new (Context) DFIDeducedMismatchArgs;
784 DFIArguments *Saved =
new (Context) DFIArguments;
796 DFIParamWithArguments *Saved =
new (Context) DFIParamWithArguments;
797 Saved->Param = Info.
Param;
810 Result.HasDiagnostic =
true;
815 CNSInfo *Saved =
new (Context) CNSInfo;
825 llvm_unreachable(
"not a deduction failure");
858 Diag->~PartialDiagnosticAt();
865 static_cast<CNSInfo *
>(
Data)->Satisfaction.~ConstraintSatisfaction();
868 Diag->~PartialDiagnosticAt();
904 return TemplateParameter::getFromOpaqueValue(
Data);
909 return static_cast<DFIParamWithArguments*
>(
Data)->Param;
939 return static_cast<DFIDeducedMismatchArgs*
>(
Data)->TemplateArgs;
945 return static_cast<CNSInfo*
>(
Data)->TemplateArgs;
977 return &
static_cast<DFIArguments*
>(
Data)->FirstArg;
1009 return &
static_cast<DFIArguments*
>(
Data)->SecondArg;
1024 return static_cast<DFIDeducedMismatchArgs*
>(
Data)->CallArgIndex;
1027 return std::nullopt;
1040 for (
unsigned I = 0; I <
X->getNumParams(); ++I)
1044 if (
auto *FTX =
X->getDescribedFunctionTemplate()) {
1049 FTY->getTemplateParameters()))
1058 OverloadedOperatorKind::OO_EqualEqual);
1070 OverloadedOperatorKind::OO_ExclaimEqual);
1088 auto *NotEqFD = Op->getAsFunction();
1089 if (
auto *UD = dyn_cast<UsingShadowDecl>(Op))
1090 NotEqFD = UD->getUnderlyingDecl()->getAsFunction();
1103 return Op == OO_EqualEqual || Op == OO_Spaceship;
1111 if (Op == OverloadedOperatorKind::OO_EqualEqual) {
1112 assert(OriginalArgs.size() == 2);
1114 S,
OpLoc, OriginalArgs[1], FD))
1125void OverloadCandidateSet::destroyCandidates() {
1126 for (
iterator i = Candidates.begin(), e = Candidates.end(); i != e; ++i) {
1127 for (
auto &
C : i->Conversions)
1128 C.~ImplicitConversionSequence();
1130 i->DeductionFailure.Destroy();
1135 destroyCandidates();
1136 SlabAllocator.Reset();
1137 NumInlineBytesUsed = 0;
1141 FirstDeferredCandidate =
nullptr;
1142 DeferredCandidatesCount = 0;
1143 HasDeferredTemplateConstructors =
false;
1144 ResolutionByPerfectCandidateIsDisabled =
false;
1148 class UnbridgedCastsSet {
1158 Entry entry = { &E, E };
1159 Entries.push_back(entry);
1164 for (SmallVectorImpl<Entry>::iterator
1165 i = Entries.begin(), e = Entries.end(); i != e; ++i)
1166 *i->Addr = i->Saved;
1180 UnbridgedCastsSet *unbridgedCasts =
nullptr) {
1184 if (placeholder->getKind() == BuiltinType::Overload)
return false;
1188 if (placeholder->getKind() == BuiltinType::ARCUnbridgedCast &&
1190 unbridgedCasts->save(S, E);
1210 UnbridgedCastsSet &unbridged) {
1211 for (
unsigned i = 0, e = Args.size(); i != e; ++i)
1220 bool NewIsUsingDecl) {
1225 bool OldIsUsingDecl =
false;
1227 OldIsUsingDecl =
true;
1231 if (NewIsUsingDecl)
continue;
1238 if ((OldIsUsingDecl || NewIsUsingDecl) && !
isVisible(*I))
1246 bool UseMemberUsingDeclRules =
1247 (OldIsUsingDecl || NewIsUsingDecl) &&
CurContext->isRecord() &&
1248 !
New->getFriendObjectKind();
1252 if (UseMemberUsingDeclRules && OldIsUsingDecl) {
1258 !shouldLinkPossiblyHiddenDecl(*I,
New))
1277 }
else if (
auto *UUD = dyn_cast<UnresolvedUsingValueDecl>(OldD)) {
1284 if (UUD->getQualifier().isDependent() && !UUD->isCXXClassMember()) {
1312 if (
New->getFriendObjectKind() &&
New->getQualifier() &&
1313 !
New->getDescribedFunctionTemplate() &&
1314 !
New->getDependentSpecializationInfo() &&
1315 !
New->getType()->isDependentType()) {
1320 New->setInvalidDecl();
1332 assert(D &&
"function decl should not be null");
1333 if (
auto *A = D->
getAttr<AttrT>())
1334 return !A->isImplicit();
1340 bool UseMemberUsingDeclRules,
1341 bool ConsiderCudaAttrs,
1342 bool UseOverrideRules =
false) {
1348 if (
New->isMSVCRTEntryPoint())
1359 if ((OldTemplate ==
nullptr) != (NewTemplate ==
nullptr))
1382 if (OldQType != NewQType && OldType->isVariadic() != NewType->isVariadic())
1386 if ((
New->isMemberLikeConstrainedFriend() ||
1397 OldDecl = OldTemplate;
1398 NewDecl = NewTemplate;
1416 bool ConstraintsInTemplateHead =
1427 if (UseMemberUsingDeclRules && ConstraintsInTemplateHead &&
1428 !SameTemplateParameterList)
1430 if (!UseMemberUsingDeclRules &&
1431 (!SameTemplateParameterList || !SameReturnType))
1435 const auto *OldMethod = dyn_cast<CXXMethodDecl>(Old);
1436 const auto *NewMethod = dyn_cast<CXXMethodDecl>(
New);
1438 int OldParamsOffset = 0;
1439 int NewParamsOffset = 0;
1447 if (ThisType.isConstQualified())
1467 BS.
Quals = NormalizeQualifiers(OldMethod, BS.
Quals);
1468 DS.Quals = NormalizeQualifiers(NewMethod, DS.Quals);
1470 if (OldMethod->isExplicitObjectMemberFunction()) {
1472 DS.Quals.removeVolatile();
1475 return BS.
Quals == DS.Quals;
1479 auto BS =
Base.getNonReferenceType().getCanonicalType().split();
1480 auto DS = D.getNonReferenceType().getCanonicalType().split();
1482 if (!AreQualifiersEqual(BS, DS))
1485 if (OldMethod->isImplicitObjectMemberFunction() &&
1486 OldMethod->getParent() != NewMethod->getParent()) {
1498 if (
Base->isLValueReferenceType())
1499 return D->isLValueReferenceType();
1500 return Base->isRValueReferenceType() == D->isRValueReferenceType();
1505 auto DiagnoseInconsistentRefQualifiers = [&]() {
1506 if (SemaRef.
LangOpts.CPlusPlus23 && !UseOverrideRules)
1508 if (OldMethod->getRefQualifier() == NewMethod->getRefQualifier())
1510 if (OldMethod->isExplicitObjectMemberFunction() ||
1511 NewMethod->isExplicitObjectMemberFunction())
1513 if (!UseMemberUsingDeclRules && (OldMethod->getRefQualifier() ==
RQ_None ||
1514 NewMethod->getRefQualifier() ==
RQ_None)) {
1515 SemaRef.
Diag(NewMethod->getLocation(), diag::err_ref_qualifier_overload)
1516 << NewMethod->getRefQualifier() << OldMethod->getRefQualifier();
1517 SemaRef.
Diag(OldMethod->getLocation(), diag::note_previous_declaration);
1523 if (OldMethod && OldMethod->isExplicitObjectMemberFunction())
1525 if (NewMethod && NewMethod->isExplicitObjectMemberFunction())
1528 if (OldType->getNumParams() - OldParamsOffset !=
1529 NewType->getNumParams() - NewParamsOffset ||
1531 {OldType->param_type_begin() + OldParamsOffset,
1532 OldType->param_type_end()},
1533 {NewType->param_type_begin() + NewParamsOffset,
1534 NewType->param_type_end()},
1539 if (OldMethod && NewMethod && !OldMethod->isStatic() &&
1540 !NewMethod->isStatic()) {
1541 bool HaveCorrespondingObjectParameters = [&](
const CXXMethodDecl *Old,
1543 auto NewObjectType =
New->getFunctionObjectParameterReferenceType();
1547 return F->getRefQualifier() ==
RQ_None &&
1548 !F->isExplicitObjectMemberFunction();
1551 if (IsImplicitWithNoRefQual(Old) != IsImplicitWithNoRefQual(
New) &&
1552 CompareType(OldObjectType.getNonReferenceType(),
1553 NewObjectType.getNonReferenceType()))
1555 return CompareType(OldObjectType, NewObjectType);
1556 }(OldMethod, NewMethod);
1558 if (!HaveCorrespondingObjectParameters) {
1559 if (DiagnoseInconsistentRefQualifiers())
1564 if (!UseOverrideRules || (!NewMethod->isExplicitObjectMemberFunction() &&
1565 !OldMethod->isExplicitObjectMemberFunction()))
1570 if (!UseOverrideRules &&
1574 if (!NewRC != !OldRC)
1584 if (NewMethod && OldMethod && OldMethod->isImplicitObjectMemberFunction() &&
1585 NewMethod->isImplicitObjectMemberFunction()) {
1586 if (DiagnoseInconsistentRefQualifiers())
1600 NewI =
New->specific_attr_begin<EnableIfAttr>(),
1601 NewE =
New->specific_attr_end<EnableIfAttr>(),
1604 NewI != NewE || OldI != OldE; ++NewI, ++OldI) {
1605 if (NewI == NewE || OldI == OldE)
1607 llvm::FoldingSetNodeID NewID, OldID;
1608 NewI->getCond()->Profile(NewID, SemaRef.
Context,
true);
1609 OldI->getCond()->Profile(OldID, SemaRef.
Context,
true);
1615 if (SemaRef.
getLangOpts().CUDA && ConsiderCudaAttrs) {
1623 "Unexpected invalid target.");
1627 if (NewTarget != OldTarget) {
1630 if (OldMethod && NewMethod && OldMethod->isVirtual() &&
1631 OldMethod->isConstexpr() && !NewMethod->isConstexpr() &&
1649 bool UseMemberUsingDeclRules,
bool ConsiderCudaAttrs) {
1655 bool UseMemberUsingDeclRules,
bool ConsiderCudaAttrs) {
1668 bool SuppressUserConversions,
1670 bool InOverloadResolution,
1672 bool AllowObjCWritebackConversion,
1673 bool AllowObjCConversionOnExplicit) {
1676 if (SuppressUserConversions) {
1687 Conversions, AllowExplicit,
1688 AllowObjCConversionOnExplicit)) {
1709 bool FromListInit =
false;
1710 if (
const auto *InitList = dyn_cast<InitListExpr>(From);
1711 InitList && InitList->getNumInits() == 1 &&
1713 const Expr *SingleInit = InitList->getInit(0);
1714 FromType = SingleInit->
getType();
1716 FromListInit =
true;
1725 if ((FromCanon == ToCanon ||
1737 if (ToCanon != FromCanon)
1748 Cand != Conversions.
end(); ++Cand)
1789static ImplicitConversionSequence
1791 bool SuppressUserConversions,
1793 bool InOverloadResolution,
1795 bool AllowObjCWritebackConversion,
1796 bool AllowObjCConversionOnExplicit) {
1799 ICS.
Standard, CStyle, AllowObjCWritebackConversion)){
1845 bool CanConvert =
false;
1851 FromResType->getWrappedType()) &&
1853 FromResType->getContainedType()) &&
1854 ToResType->getAttrs() == FromResType->getAttrs())
1856 }
else if (ToTy->isHLSLResourceType()) {
1870 AllowExplicit, InOverloadResolution, CStyle,
1871 AllowObjCWritebackConversion,
1872 AllowObjCConversionOnExplicit);
1875ImplicitConversionSequence
1877 bool SuppressUserConversions,
1879 bool InOverloadResolution,
1881 bool AllowObjCWritebackConversion) {
1882 return ::TryImplicitConversion(*
this, From, ToType, SuppressUserConversions,
1883 AllowExplicit, InOverloadResolution, CStyle,
1884 AllowObjCWritebackConversion,
1890 bool AllowExplicit) {
1895 bool AllowObjCWritebackConversion =
1902 *
this, From, ToType,
1904 AllowExplicit ? AllowedExplicit::All : AllowedExplicit::None,
1906 false, AllowObjCWritebackConversion,
1920 if (
Context.hasSameUnqualifiedType(FromType, ToType))
1933 if (TyClass != CanFrom->getTypeClass())
return false;
1934 if (TyClass != Type::FunctionProto && TyClass != Type::FunctionNoProto) {
1935 if (TyClass == Type::Pointer) {
1938 }
else if (TyClass == Type::BlockPointer) {
1941 }
else if (TyClass == Type::MemberPointer) {
1948 CanTo = ToMPT->getPointeeType();
1954 TyClass = CanTo->getTypeClass();
1955 if (TyClass != CanFrom->getTypeClass())
return false;
1956 if (TyClass != Type::FunctionProto && TyClass != Type::FunctionNoProto)
1966 bool Changed =
false;
1974 const auto *FromFPT = dyn_cast<FunctionProtoType>(FromFn);
1975 const auto *ToFPT = dyn_cast<FunctionProtoType>(ToFn);
1977 if (FromFPT && ToFPT) {
1978 if (FromFPT->hasCFIUncheckedCallee() != ToFPT->hasCFIUncheckedCallee()) {
1980 FromFPT->getReturnType(), FromFPT->getParamTypes(),
1981 FromFPT->getExtProtoInfo().withCFIUncheckedCallee(
1982 ToFPT->hasCFIUncheckedCallee()));
1990 if (FromFPT && ToFPT) {
1991 if (FromFPT->isNothrow() && !ToFPT->isNothrow()) {
2003 bool CanUseToFPT, CanUseFromFPT;
2004 if (
Context.mergeExtParameterInfo(ToFPT, FromFPT, CanUseToFPT,
2005 CanUseFromFPT, NewParamInfos) &&
2006 CanUseToFPT && !CanUseFromFPT) {
2009 NewParamInfos.empty() ?
nullptr : NewParamInfos.data();
2011 FromFPT->getParamTypes(), ExtInfo);
2016 if (
Context.hasAnyFunctionEffects()) {
2021 const auto FromFX = FromFPT->getFunctionEffects();
2022 const auto ToFX = ToFPT->getFunctionEffects();
2023 if (FromFX != ToFX) {
2027 FromFPT->getReturnType(), FromFPT->getParamTypes(), ExtInfo);
2037 assert(
QualType(FromFn, 0).isCanonical());
2038 if (
QualType(FromFn, 0) != CanTo)
return false;
2065 if ((&FromSem == &llvm::APFloat::PPCDoubleDouble() &&
2066 &ToSem == &llvm::APFloat::IEEEquad()) ||
2067 (&FromSem == &llvm::APFloat::IEEEquad() &&
2068 &ToSem == &llvm::APFloat::PPCDoubleDouble()))
2124 bool InOverloadResolution,
bool CStyle) {
2134 if (ToMatrixType && FromMatrixType) {
2136 unsigned ToCols = ToMatrixType->getNumColumns();
2137 if (FromCols < ToCols)
2140 unsigned FromRows = FromMatrixType->
getNumRows();
2141 unsigned ToRows = ToMatrixType->getNumRows();
2142 if (FromRows < ToRows)
2145 if (FromRows == ToRows && FromCols == ToCols)
2151 QualType ToElTy = ToMatrixType->getElementType();
2160 QualType ToElTy = ToMatrixType->getElementType();
2163 if (FromMatrixType && !ToMatrixType) {
2182 bool InOverloadResolution,
bool CStyle) {
2199 if (ToExtType && FromExtType) {
2201 unsigned ToElts = ToExtType->getNumElements();
2202 if (FromElts < ToElts)
2204 if (FromElts == ToElts)
2210 QualType ToElTy = ToExtType->getElementType();
2215 if (FromExtType && !ToExtType) {
2229 if (ToExtType->getNumElements() != FromExtType->getNumElements())
2234 FromExtType->getElementType()->isIntegerType()) {
2246 QualType ToElTy = ToExtType->getElementType();
2281 !ToType->
hasAttr(attr::ArmMveStrictPolymorphism))) {
2286 !InOverloadResolution && !CStyle) {
2288 << FromType << ToType;
2299 bool InOverloadResolution,
2300 StandardConversionSequence &SCS,
2305 bool InOverloadResolution,
2306 StandardConversionSequence &SCS,
2318 bool InOverloadResolution,
2321 bool AllowObjCWritebackConversion) {
2347 FromType = Fn->getType();
2367 if (Method && !Method->isStatic() &&
2368 !Method->isExplicitObjectMemberFunction()) {
2370 "Non-unary operator on non-static member address");
2373 "Non-address-of operator on non-static member address");
2375 FromType, std::nullopt, Method->getParent());
2379 "Non-address-of operator for overloaded function expression");
2425 FromType =
Atomic->getValueType();
2460 if (
auto *FD = dyn_cast<FunctionDecl>(DRE->getDecl()))
2480 bool IncompatibleObjC =
false;
2542 }
else if (AllowObjCWritebackConversion &&
2546 FromType, IncompatibleObjC)) {
2552 InOverloadResolution, FromType)) {
2556 From, InOverloadResolution, CStyle)) {
2561 From, InOverloadResolution, CStyle)) {
2571 S, From, ToType, InOverloadResolution, SCS, CStyle)) {
2580 S, From, ToType, InOverloadResolution, SCS, CStyle)) {
2610 bool ObjCLifetimeConversion;
2616 ObjCLifetimeConversion)) {
2635 CanonFrom = CanonTo;
2640 if (CanonFrom == CanonTo)
2645 if (S.
getLangOpts().CPlusPlus || !InOverloadResolution)
2657 case AssignConvertType::
2658 CompatibleVoidPtrToNonVoidPtr:
2691 bool InOverloadResolution,
2699 const RecordDecl *UD = UT->getDecl()->getDefinitionOrSelf();
2700 if (!UD->
hasAttr<TransparentUnionAttr>())
2703 for (
const auto *it : UD->
fields()) {
2706 ToType = it->getType();
2732 return To->
getKind() == BuiltinType::Int;
2735 return To->
getKind() == BuiltinType::UInt;
2759 if (FromED->isScoped())
2766 if (FromED->isFixed()) {
2767 QualType Underlying = FromED->getIntegerType();
2768 return Context.hasSameUnqualifiedType(Underlying, ToType) ||
2775 return Context.hasSameUnqualifiedType(ToType, FromED->getPromotionType());
2800 uint64_t FromSize =
Context.getTypeSize(FromType);
2809 for (
int Idx = 0; Idx < 6; ++Idx) {
2810 uint64_t ToSize =
Context.getTypeSize(PromoteTypes[Idx]);
2811 if (FromSize < ToSize ||
2812 (FromSize == ToSize &&
2813 FromIsSigned == PromoteTypes[Idx]->isSignedIntegerType())) {
2817 return Context.hasSameUnqualifiedType(ToType, PromoteTypes[Idx]);
2838 std::optional<llvm::APSInt> BitWidth;
2841 MemberDecl->getBitWidth()->getIntegerConstantExpr(
Context))) {
2842 llvm::APSInt ToSize(BitWidth->getBitWidth(), BitWidth->isUnsigned());
2843 ToSize =
Context.getTypeSize(ToType);
2846 if (*BitWidth < ToSize ||
2848 return To->
getKind() == BuiltinType::Int;
2854 return To->
getKind() == BuiltinType::UInt;
2872 return Context.getTypeSize(FromType) <
Context.getTypeSize(ToType);
2882 if (FromBuiltin->getKind() == BuiltinType::Float &&
2883 ToBuiltin->getKind() == BuiltinType::Double)
2890 (FromBuiltin->getKind() == BuiltinType::Float ||
2891 FromBuiltin->getKind() == BuiltinType::Double) &&
2892 (ToBuiltin->getKind() == BuiltinType::LongDouble ||
2893 ToBuiltin->getKind() == BuiltinType::Float128 ||
2894 ToBuiltin->getKind() == BuiltinType::Ibm128))
2899 if (
getLangOpts().
HLSL && FromBuiltin->getKind() == BuiltinType::Half &&
2900 (ToBuiltin->getKind() == BuiltinType::Float ||
2901 ToBuiltin->getKind() == BuiltinType::Double))
2906 FromBuiltin->getKind() == BuiltinType::Half &&
2907 ToBuiltin->getKind() == BuiltinType::Float)
2936 return Context.getTypeSize(FromType) <
Context.getTypeSize(ToType);
2948 if (
const EnumType *ToEnumType = ToType->
getAs<EnumType>()) {
2960 return Context.getTypeSize(FromType) >
Context.getTypeSize(ToType);
2975 bool StripObjCLifetime =
false) {
2978 "Invalid similarly-qualified pointer type");
2989 if (StripObjCLifetime)
3001 return Context.getObjCObjectPointerType(ToPointee);
3002 return Context.getPointerType(ToPointee);
3010 return Context.getObjCObjectPointerType(QualifiedCanonToPointee);
3011 return Context.getPointerType(QualifiedCanonToPointee);
3015 bool InOverloadResolution,
3021 return !InOverloadResolution;
3029 bool InOverloadResolution,
3031 bool &IncompatibleObjC) {
3032 IncompatibleObjC =
false;
3040 ConvertedType = ToType;
3047 ConvertedType = ToType;
3054 ConvertedType = ToType;
3062 ConvertedType = ToType;
3072 ConvertedType = ToType;
3094 if (
Context.hasSameUnqualifiedType(FromPointeeType, ToPointeeType))
3121 Context.typesAreCompatible(FromPointeeType, ToPointeeType)) {
3143 !
Context.hasSameUnqualifiedType(FromPointeeType, ToPointeeType) &&
3152 Context.areCompatibleVectorTypes(FromPointeeType, ToPointeeType)) {
3171 return Context.getQualifiedType(T, Qs);
3173 return Context.getQualifiedType(T.getUnqualifiedType(), Qs);
3178 bool &IncompatibleObjC) {
3191 if (ToObjCPtr && FromObjCPtr) {
3199 if (
Context.canAssignObjCInterfaces(ToObjCPtr, FromObjCPtr)) {
3213 if (
Context.canAssignObjCInterfaces(FromObjCPtr, ToObjCPtr)) {
3217 IncompatibleObjC =
true;
3233 if (FromObjCPtr && FromObjCPtr->isObjCBuiltinType()) {
3262 IncompatibleObjC)) {
3264 IncompatibleObjC =
true;
3265 ConvertedType =
Context.getPointerType(ConvertedType);
3274 IncompatibleObjC)) {
3276 ConvertedType =
Context.getPointerType(ConvertedType);
3289 if (FromFunctionType && ToFunctionType) {
3292 if (
Context.getCanonicalType(FromPointeeType)
3293 ==
Context.getCanonicalType(ToPointeeType))
3298 if (FromFunctionType->
getNumParams() != ToFunctionType->getNumParams() ||
3299 FromFunctionType->
isVariadic() != ToFunctionType->isVariadic() ||
3300 FromFunctionType->
getMethodQuals() != ToFunctionType->getMethodQuals())
3303 bool HasObjCConversion =
false;
3305 Context.getCanonicalType(ToFunctionType->getReturnType())) {
3308 ToFunctionType->getReturnType(),
3309 ConvertedType, IncompatibleObjC)) {
3311 HasObjCConversion =
true;
3318 for (
unsigned ArgIdx = 0, NumArgs = FromFunctionType->
getNumParams();
3319 ArgIdx != NumArgs; ++ArgIdx) {
3321 QualType ToArgType = ToFunctionType->getParamType(ArgIdx);
3322 if (
Context.getCanonicalType(FromArgType)
3323 ==
Context.getCanonicalType(ToArgType)) {
3326 ConvertedType, IncompatibleObjC)) {
3328 HasObjCConversion =
true;
3335 if (HasObjCConversion) {
3339 IncompatibleObjC =
true;
3371 if (!FromFunctionType || !ToFunctionType)
3374 if (
Context.hasSameType(FromPointeeType, ToPointeeType))
3379 if (FromFunctionType->
getNumParams() != ToFunctionType->getNumParams() ||
3380 FromFunctionType->
isVariadic() != ToFunctionType->isVariadic())
3385 if (FromEInfo != ToEInfo)
3388 bool IncompatibleObjC =
false;
3390 ToFunctionType->getReturnType())) {
3394 QualType LHS = ToFunctionType->getReturnType();
3399 if (
Context.hasSameType(RHS,LHS)) {
3402 ConvertedType, IncompatibleObjC)) {
3403 if (IncompatibleObjC)
3412 for (
unsigned ArgIdx = 0, NumArgs = FromFunctionType->
getNumParams();
3413 ArgIdx != NumArgs; ++ArgIdx) {
3414 IncompatibleObjC =
false;
3416 QualType ToArgType = ToFunctionType->getParamType(ArgIdx);
3417 if (
Context.hasSameType(FromArgType, ToArgType)) {
3420 ConvertedType, IncompatibleObjC)) {
3421 if (IncompatibleObjC)
3430 bool CanUseToFPT, CanUseFromFPT;
3431 if (!
Context.mergeExtParameterInfo(ToFunctionType, FromFunctionType,
3432 CanUseToFPT, CanUseFromFPT,
3436 ConvertedType = ToType;
3475 ToMember->getMostRecentCXXRecordDecl())) {
3477 if (ToMember->isSugared())
3479 ToMember->getMostRecentCXXRecordDecl());
3481 PDiag << ToMember->getQualifier();
3482 if (FromMember->isSugared())
3484 FromMember->getMostRecentCXXRecordDecl());
3486 PDiag << FromMember->getQualifier();
3504 !FromType->
getAs<TemplateSpecializationType>()) {
3510 if (
Context.hasSameType(FromType, ToType)) {
3519 if (!FromFunction || !ToFunction) {
3524 if (FromFunction->
getNumParams() != ToFunction->getNumParams()) {
3534 << ToFunction->getParamType(ArgPos)
3541 ToFunction->getReturnType())) {
3547 if (FromFunction->
getMethodQuals() != ToFunction->getMethodQuals()) {
3570 assert(llvm::size(Old) == llvm::size(
New) &&
3571 "Can't compare parameters of functions with different number of "
3574 for (
auto &&[Idx,
Type] : llvm::enumerate(Old)) {
3576 size_t J =
Reversed ? (llvm::size(
New) - Idx - 1) : Idx;
3581 Context.removePtrSizeAddrSpace(
Type.getUnqualifiedType());
3583 Context.removePtrSizeAddrSpace((
New.begin() + J)->getUnqualifiedType());
3585 if (!
Context.hasSameType(OldType, NewType)) {
3610 unsigned OldIgnore =
3612 unsigned NewIgnore =
3619 NewPT->param_types().slice(NewIgnore),
3626 bool IgnoreBaseAccess,
3629 bool IsCStyleOrFunctionalCast = IgnoreBaseAccess;
3638 PDiag(diag::warn_impcast_bool_to_null_pointer)
3649 if (FromPointeeType->
isRecordType() && ToPointeeType->isRecordType() &&
3650 !
Context.hasSameUnqualifiedType(FromPointeeType, ToPointeeType)) {
3653 unsigned InaccessibleID = 0;
3654 unsigned AmbiguousID = 0;
3656 InaccessibleID = diag::err_upcast_to_inaccessible_base;
3657 AmbiguousID = diag::err_ambiguous_derived_to_base_conv;
3660 FromPointeeType, ToPointeeType, InaccessibleID, AmbiguousID,
3662 &BasePath, IgnoreBaseAccess))
3666 Kind = CK_DerivedToBase;
3669 if (
Diagnose && !IsCStyleOrFunctionalCast &&
3670 FromPointeeType->
isFunctionType() && ToPointeeType->isVoidType()) {
3672 "this should only be possible with MSVCCompat!");
3684 if (FromPtrType->isObjCBuiltinType() || ToPtrType->isObjCBuiltinType())
3687 Kind = CK_BlockPointerToObjCPointerCast;
3689 Kind = CK_CPointerToObjCPointerCast;
3693 Kind = CK_AnyPointerToBlockPointerCast;
3699 Kind = CK_NullToPointer;
3706 bool InOverloadResolution,
3716 ConvertedType = ToType;
3732 ConvertedType =
Context.getMemberPointerType(
3746 if (
Context.getTargetInfo().getCXXABI().isMicrosoft()) {
3754 Kind = CK_NullToMemberPointer;
3772 PD <<
Context.getCanonicalTagType(Cls);
3782 std::swap(
Base, Derived);
3791 PD <<
int(Direction);
3799 DiagFromTo(PD) <<
QualType(VBase, 0) << OpRange;
3807 ? CK_DerivedToBaseMemberPointer
3808 : CK_BaseToDerivedMemberPointer;
3810 if (!IgnoreBaseAccess)
3814 ? diag::err_upcast_to_inaccessible_base
3815 : diag::err_downcast_from_inaccessible_base,
3817 NestedNameSpecifier BaseQual = FromPtrType->getQualifier(),
3818 DerivedQual = ToPtrType->getQualifier();
3819 if (Direction == MemberPointerConversionDirection::Upcast)
3820 std::swap(BaseQual, DerivedQual);
3821 DiagCls(PD, DerivedQual, Derived);
3822 DiagCls(PD, BaseQual, Base);
3857 bool CStyle,
bool IsTopLevel,
3858 bool &PreviousToQualsIncludeConst,
3859 bool &ObjCLifetimeConversion,
3872 ObjCLifetimeConversion =
true;
3912 !PreviousToQualsIncludeConst)
3930 PreviousToQualsIncludeConst =
3931 PreviousToQualsIncludeConst && ToQuals.
hasConst();
3937 bool CStyle,
bool &ObjCLifetimeConversion) {
3938 FromType =
Context.getCanonicalType(FromType);
3939 ToType =
Context.getCanonicalType(ToType);
3940 ObjCLifetimeConversion =
false;
3950 bool PreviousToQualsIncludeConst =
true;
3951 bool UnwrappedAnyPointer =
false;
3952 while (
Context.UnwrapSimilarTypes(FromType, ToType)) {
3954 !UnwrappedAnyPointer,
3955 PreviousToQualsIncludeConst,
3958 UnwrappedAnyPointer =
true;
3966 return UnwrappedAnyPointer &&
Context.hasSameUnqualifiedType(FromType,ToType);
3975 bool InOverloadResolution,
3984 InOverloadResolution, InnerSCS,
3999 bool InOverloadResolution,
4002 const OverflowBehaviorType *ToOBT = ToType->
getAs<OverflowBehaviorType>();
4013 InOverloadResolution, InnerSCS, CStyle,
4030 if (CtorType->getNumParams() > 0) {
4031 QualType FirstArg = CtorType->getParamType(0);
4043 bool AllowExplicit) {
4050 bool Usable = !Info.Constructor->isInvalidDecl() &&
4053 bool SuppressUserConversions =
false;
4054 if (Info.ConstructorTmpl)
4057 CandidateSet, SuppressUserConversions,
4062 CandidateSet, SuppressUserConversions,
4063 false, AllowExplicit);
4067 bool HadMultipleCandidates = (CandidateSet.
size() > 1);
4070 switch (
auto Result =
4094 llvm_unreachable(
"Invalid OverloadResult!");
4116 bool AllowObjCConversionOnExplicit) {
4117 assert(AllowExplicit != AllowedExplicit::None ||
4118 !AllowObjCConversionOnExplicit);
4122 bool ConstructorsOnly =
false;
4126 if (
const RecordType *ToRecordType = ToType->
getAsCanonical<RecordType>()) {
4138 ConstructorsOnly =
true;
4142 }
else if (
auto *ToRecordDecl =
4143 dyn_cast<CXXRecordDecl>(ToRecordType->getDecl())) {
4144 ToRecordDecl = ToRecordDecl->getDefinitionOrSelf();
4146 Expr **Args = &From;
4147 unsigned NumArgs = 1;
4148 bool ListInitializing =
false;
4149 if (
InitListExpr *InitList = dyn_cast<InitListExpr>(From)) {
4152 S, From, ToType, ToRecordDecl, User, CandidateSet,
4153 AllowExplicit == AllowedExplicit::All);
4162 Args = InitList->getInits();
4163 NumArgs = InitList->getNumInits();
4164 ListInitializing =
true;
4172 bool Usable = !Info.Constructor->isInvalidDecl();
4173 if (!ListInitializing)
4174 Usable = Usable && Info.Constructor->isConvertingConstructor(
4177 bool SuppressUserConversions = !ConstructorsOnly;
4185 if (SuppressUserConversions && ListInitializing) {
4186 SuppressUserConversions =
4191 if (Info.ConstructorTmpl)
4193 Info.ConstructorTmpl, Info.FoundDecl,
4195 CandidateSet, SuppressUserConversions,
4197 AllowExplicit == AllowedExplicit::All);
4203 SuppressUserConversions,
4205 AllowExplicit == AllowedExplicit::All);
4215 }
else if (
const RecordType *FromRecordType =
4217 if (
auto *FromRecordDecl =
4218 dyn_cast<CXXRecordDecl>(FromRecordType->getDecl())) {
4219 FromRecordDecl = FromRecordDecl->getDefinitionOrSelf();
4221 const auto &Conversions = FromRecordDecl->getVisibleConversionFunctions();
4222 for (
auto I = Conversions.begin(), E = Conversions.end(); I != E; ++I) {
4231 if ((ConvTemplate = dyn_cast<FunctionTemplateDecl>(D)))
4238 ConvTemplate, FoundDecl, ActingContext, From, ToType,
4239 CandidateSet, AllowObjCConversionOnExplicit,
4240 AllowExplicit != AllowedExplicit::None);
4243 CandidateSet, AllowObjCConversionOnExplicit,
4244 AllowExplicit != AllowedExplicit::None);
4249 bool HadMultipleCandidates = (CandidateSet.
size() > 1);
4252 switch (
auto Result =
4258 = dyn_cast<CXXConstructorDecl>(Best->Function)) {
4270 if (Best->Conversions[0].isEllipsis())
4273 User.
Before = Best->Conversions[0].Standard;
4286 = dyn_cast<CXXConversionDecl>(Best->Function)) {
4288 assert(Best->HasFinalConversion);
4296 User.
Before = Best->Conversions[0].Standard;
4311 User.
After = Best->FinalConversion;
4314 llvm_unreachable(
"Not a constructor or conversion function?");
4323 llvm_unreachable(
"Invalid OverloadResult!");
4333 CandidateSet, AllowedExplicit::None,
false);
4348 diag::err_typecheck_nonviable_condition_incomplete,
4355 *
this, From, Cands);
4381 if (!Conv1 || !Conv2)
4396 if (Block1 != Block2)
4409 if (Conv1FuncRet && Conv2FuncRet &&
4418 CallOp->getType()->castAs<
FunctionType>()->getCallConv();
4420 CallOpProto->isVariadic(),
false);
4422 CallOpProto->isVariadic(),
true);
4424 CallingConv PrefOrder[] = {DefaultFree, DefaultMember, CallOpCC};
4519 if (!ICS1.
isBad()) {
4520 bool StdInit1 =
false, StdInit2 =
false;
4527 if (StdInit1 != StdInit2)
4538 CAT2->getElementType())) {
4540 if (CAT1->getSize() != CAT2->getSize())
4542 return CAT1->getSize().ult(CAT2->getSize())
4577 if (ConvFunc1 == ConvFunc2)
4679 if (!
Enum->isFixed())
4715 else if (Rank2 < Rank1)
4750 bool SCS1ConvertsToVoid
4752 bool SCS2ConvertsToVoid
4754 if (SCS1ConvertsToVoid != SCS2ConvertsToVoid) {
4759 }
else if (!SCS1ConvertsToVoid && !SCS2ConvertsToVoid) {
4765 }
else if (SCS1ConvertsToVoid && SCS2ConvertsToVoid &&
4794 if (FromObjCPtr1 && FromObjCPtr2) {
4799 if (AssignLeft != AssignRight) {
4838 if (UnqualT1 == UnqualT2) {
4900 if (SCS1IsCompatibleVectorConversion != SCS2IsCompatibleVectorConversion)
4901 return SCS1IsCompatibleVectorConversion
4908 bool SCS1IsCompatibleSVEVectorConversion =
4910 bool SCS2IsCompatibleSVEVectorConversion =
4913 if (SCS1IsCompatibleSVEVectorConversion !=
4914 SCS2IsCompatibleSVEVectorConversion)
4915 return SCS1IsCompatibleSVEVectorConversion
4922 bool SCS1IsCompatibleRVVVectorConversion =
4924 bool SCS2IsCompatibleRVVVectorConversion =
4927 if (SCS1IsCompatibleRVVVectorConversion !=
4928 SCS2IsCompatibleRVVVectorConversion)
4929 return SCS1IsCompatibleRVVVectorConversion
4988 if (UnqualT1 == UnqualT2)
5006 bool ObjCLifetimeConversion;
5016 if (CanPick1 != CanPick2)
5070 if (FromPointee1 == FromPointee2 && ToPointee1 != ToPointee2) {
5078 if (FromPointee1 != FromPointee2 && ToPointee1 == ToPointee2) {
5095 if (FromPtr1 && FromPtr2 && ToPtr1 && ToPtr2) {
5102 bool FromAssignRight
5111 if (ToPtr1->isObjCIdType() &&
5112 (ToPtr2->isObjCQualifiedIdType() || ToPtr2->getInterfaceDecl()))
5114 if (ToPtr2->isObjCIdType() &&
5115 (ToPtr1->isObjCQualifiedIdType() || ToPtr1->getInterfaceDecl()))
5120 if (ToPtr1->isObjCQualifiedIdType() && ToPtr2->getInterfaceDecl())
5122 if (ToPtr2->isObjCQualifiedIdType() && ToPtr1->getInterfaceDecl())
5127 if (ToPtr1->isObjCClassType() &&
5128 (ToPtr2->isObjCQualifiedClassType() || ToPtr2->getInterfaceDecl()))
5130 if (ToPtr2->isObjCClassType() &&
5131 (ToPtr1->isObjCQualifiedClassType() || ToPtr1->getInterfaceDecl()))
5136 if (ToPtr1->isObjCQualifiedClassType() && ToPtr2->getInterfaceDecl())
5138 if (ToPtr2->isObjCQualifiedClassType() && ToPtr1->getInterfaceDecl())
5144 (ToAssignLeft != ToAssignRight)) {
5155 }
else if (IsSecondSame)
5164 (FromAssignLeft != FromAssignRight))
5178 CXXRecordDecl *FromPointee1 = FromMemPointer1->getMostRecentCXXRecordDecl();
5183 if (FromPointee1 == FromPointee2 && ToPointee1 != ToPointee2) {
5190 if (ToPointee1 == ToPointee2 && FromPointee1 != FromPointee2) {
5228 if (!T.getQualifiers().hasUnaligned())
5242 "T1 must be the pointee type of the reference type");
5243 assert(!OrigT2->
isReferenceType() &&
"T2 cannot be a reference type");
5266 if (UnqualT1 == UnqualT2) {
5270 Conv |= ReferenceConversions::DerivedToBase;
5273 Context.canBindObjCObjectType(UnqualT1, UnqualT2))
5274 Conv |= ReferenceConversions::ObjC;
5277 Conv |= ReferenceConversions::Function;
5281 bool ConvertedReferent = Conv != 0;
5285 bool PreviousToQualsIncludeConst =
true;
5286 bool TopLevel =
true;
5292 Conv |= ReferenceConversions::Qualification;
5298 Conv |= ReferenceConversions::NestedQualification;
5306 bool ObjCLifetimeConversion =
false;
5308 PreviousToQualsIncludeConst,
5310 return (ConvertedReferent ||
Context.hasSimilarType(T1, T2))
5315 if (ObjCLifetimeConversion)
5316 Conv |= ReferenceConversions::ObjCLifetime;
5319 }
while (
Context.UnwrapSimilarTypes(T1, T2));
5324 return (ConvertedReferent ||
Context.hasSameUnqualifiedType(T1, T2))
5335 bool AllowExplicit) {
5336 assert(T2->
isRecordType() &&
"Can only find conversions of record types.");
5340 const auto &Conversions = T2RecordDecl->getVisibleConversionFunctions();
5341 for (
auto I = Conversions.begin(), E = Conversions.end(); I != E; ++I) {
5348 = dyn_cast<FunctionTemplateDecl>(D);
5365 if (!ConvTemplate &&
5389 ConvTemplate, I.getPair(), ActingDC,
Init, DeclType, CandidateSet,
5390 false, AllowExplicit);
5393 Conv, I.getPair(), ActingDC,
Init, DeclType, CandidateSet,
5394 false, AllowExplicit);
5397 bool HadMultipleCandidates = (CandidateSet.
size() > 1);
5403 assert(Best->HasFinalConversion);
5415 if (!Best->FinalConversion.DirectBinding)
5427 "Expected a direct reference binding!");
5433 Cand != CandidateSet.
end(); ++Cand)
5445 llvm_unreachable(
"Invalid OverloadResult!");
5450static ImplicitConversionSequence
5453 bool SuppressUserConversions,
5454 bool AllowExplicit) {
5455 assert(DeclType->
isReferenceType() &&
"Reference init needs a reference");
5482 auto SetAsReferenceBinding = [&](
bool BindsDirectly) {
5487 ICS.
Standard.
Second = (RefConv & Sema::ReferenceConversions::DerivedToBase)
5489 : (RefConv & Sema::ReferenceConversions::ObjC)
5497 Sema::ReferenceConversions::NestedQualification)
5511 (RefConv & Sema::ReferenceConversions::ObjCLifetime) != 0;
5535 SetAsReferenceBinding(
true);
5584 SetAsReferenceBinding(S.
getLangOpts().CPlusPlus11 ||
5675 AllowedExplicit::None,
5700 if (isRValRef && LValRefType) {
5717static ImplicitConversionSequence
5719 bool SuppressUserConversions,
5720 bool InOverloadResolution,
5721 bool AllowObjCWritebackConversion,
5722 bool AllowExplicit =
false);
5726static ImplicitConversionSequence
5728 bool SuppressUserConversions,
5729 bool InOverloadResolution,
5730 bool AllowObjCWritebackConversion) {
5743 if (
const auto *IAT = dyn_cast<IncompleteArrayType>(AT))
5745 InitTy = IAT->getElementType();
5771 if (From->
getNumInits() == 1 && !IsDesignatedInit) {
5777 SuppressUserConversions,
5778 InOverloadResolution,
5779 AllowObjCWritebackConversion);
5787 Result.setStandard();
5788 Result.Standard.setAsIdentityConversion();
5789 Result.Standard.setFromType(ToType);
5790 Result.Standard.setAllToTypes(ToType);
5815 bool IsUnbounded =
false;
5819 if (CT->getSize().ult(e)) {
5823 Result.setInitializerListContainerType(ContTy, IsUnbounded);
5826 if (CT->getSize().ugt(e)) {
5832 S, &EmptyList, InitTy, SuppressUserConversions,
5833 InOverloadResolution, AllowObjCWritebackConversion);
5834 if (DfltElt.
isBad()) {
5838 Result.setInitializerListContainerType(ContTy, IsUnbounded);
5849 Result.setInitializerListContainerType(ContTy, IsUnbounded);
5858 Result.setStandard();
5859 Result.Standard.setAsIdentityConversion();
5860 Result.Standard.setFromType(InitTy);
5861 Result.Standard.setAllToTypes(InitTy);
5862 for (
unsigned i = 0; i < e; ++i) {
5865 S,
Init, InitTy, SuppressUserConversions, InOverloadResolution,
5866 AllowObjCWritebackConversion);
5876 if (Result.isBad()) {
5877 Result.setInitializerListContainerType(ContTy, IsUnbounded);
5887 S, From->
getEndLoc(), DfltElt, Result) ==
5905 AllowedExplicit::None,
5906 InOverloadResolution,
false,
5907 AllowObjCWritebackConversion,
5925 Result.setUserDefined();
5926 Result.UserDefined.Before.setAsIdentityConversion();
5928 Result.UserDefined.Before.setFromType(
QualType());
5929 Result.UserDefined.Before.setAllToTypes(
QualType());
5931 Result.UserDefined.After.setAsIdentityConversion();
5932 Result.UserDefined.After.setFromType(ToType);
5933 Result.UserDefined.After.setAllToTypes(ToType);
5934 Result.UserDefined.ConversionFunction =
nullptr;
5951 if (From->
getNumInits() == 1 && !IsDesignatedInit) {
5972 SuppressUserConversions,
5980 InOverloadResolution,
5981 AllowObjCWritebackConversion);
5982 if (Result.isFailure())
5984 assert(!Result.isEllipsis() &&
5985 "Sub-initialization cannot result in ellipsis conversion.");
5991 Result.UserDefined.After;
6019 S, From->
getInit(0), ToType, SuppressUserConversions,
6020 InOverloadResolution, AllowObjCWritebackConversion);
6021 if (Result.isStandard())
6022 Result.Standard.FromBracedInitList =
true;
6026 else if (NumInits == 0) {
6027 Result.setStandard();
6028 Result.Standard.setAsIdentityConversion();
6029 Result.Standard.setFromType(ToType);
6030 Result.Standard.setAllToTypes(ToType);
6047static ImplicitConversionSequence
6049 bool SuppressUserConversions,
6050 bool InOverloadResolution,
6051 bool AllowObjCWritebackConversion,
6052 bool AllowExplicit) {
6053 if (
InitListExpr *FromInitList = dyn_cast<InitListExpr>(From))
6055 InOverloadResolution,AllowObjCWritebackConversion);
6060 SuppressUserConversions, AllowExplicit);
6063 SuppressUserConversions,
6064 AllowedExplicit::None,
6065 InOverloadResolution,
6067 AllowObjCWritebackConversion,
6080 return !ICS.
isBad();
6089 const CXXRecordDecl *ActingContext,
bool InOverloadResolution =
false,
6091 bool SuppressUserConversion =
false) {
6099 assert(FromClassification.
isLValue());
6110 if (Method->isExplicitObjectMemberFunction()) {
6111 if (ExplicitParameterType.isNull())
6112 ExplicitParameterType = Method->getFunctionObjectParameterReferenceType();
6114 ValueKindFromClassification(FromClassification));
6116 S, &TmpExpr, ExplicitParameterType, SuppressUserConversion,
6133 Qualifiers Quals = Method->getMethodQualifiers();
6171 FromType, ImplicitParamType);
6181 FromType, ImplicitParamType);
6194 }
else if (!Method->isExplicitObjectMemberFunction()) {
6196 FromType, ImplicitParamType);
6201 switch (Method->getRefQualifier()) {
6216 if (!FromClassification.
isRValue()) {
6238 = (Method->getRefQualifier() ==
RQ_None);
6249 QualType ImplicitParamRecordType =
Method->getFunctionObjectParameterType();
6254 DestType =
Method->getThisType();
6257 FromRecordType = From->
getType();
6258 DestType = ImplicitParamRecordType;
6266 Method->getRefQualifier() !=
6284 <<
Method->getDeclName() << FromRecordType << (CVR - 1)
6286 Diag(
Method->getLocation(), diag::note_previous_decl)
6287 <<
Method->getDeclName();
6295 bool IsRValueQualified =
6299 << IsRValueQualified;
6300 Diag(
Method->getLocation(), diag::note_previous_decl)
6301 <<
Method->getDeclName();
6311 llvm_unreachable(
"Lists are not objects");
6314 return Diag(From->
getBeginLoc(), diag::err_member_function_call_bad_type)
6315 << ImplicitParamRecordType << FromRecordType
6324 From = FromRes.
get();
6333 CK = CK_AddressSpaceConversion;
6358 AllowedExplicit::Conversions,
6441 llvm_unreachable(
"found a first conversion kind in Second");
6445 llvm_unreachable(
"found a third conversion kind in Second");
6451 llvm_unreachable(
"unknown conversion kind");
6461 [[maybe_unused]]
bool isCCEAllowedPreCXX11 =
6463 assert((S.
getLangOpts().CPlusPlus11 || isCCEAllowedPreCXX11) &&
6464 "converted constant expression outside C++11 or TTP matching");
6496 if (T->isRecordType())
6505 diag::err_typecheck_converted_constant_expression)
6511 llvm_unreachable(
"bad conversion in converted constant expression");
6517 diag::err_typecheck_converted_constant_expression_disallowed)
6523 diag::err_typecheck_converted_constant_expression_indirect)
6533 diag::err_reference_bind_to_bitfield_in_cce)
6541 bool IsTemplateArgument =
6543 if (T->isRecordType()) {
6544 assert(IsTemplateArgument &&
6545 "unexpected class type converted constant expr");
6554 if (Result.isInvalid())
6561 IsTemplateArgument);
6562 if (Result.isInvalid())
6566 bool ReturnPreNarrowingValue =
false;
6569 PreNarrowingType)) {
6579 PreNarrowingValue.
isInt()) {
6582 ReturnPreNarrowingValue =
true;
6608 << CCE << 0 << From->
getType() << T;
6613 if (!ReturnPreNarrowingValue)
6614 PreNarrowingValue = {};
6630 if (Result.isInvalid() || Result.get()->isValueDependent()) {
6635 RequireInt, PreNarrowingValue);
6642 return ::BuildConvertedConstantExpression(*
this, From, T, CCE, Dest,
6649 return ::CheckConvertedConstantExpression(*
this, From, T,
Value, CCE,
false,
6654 llvm::APSInt &
Value,
6656 assert(T->isIntegralOrEnumerationType() &&
"unexpected converted const type");
6661 if (!R.isInvalid() && !R.get()->isValueDependent())
6669 const APValue &PreNarrowingValue) {
6681 Kind = ConstantExprKind::ClassTemplateArgument;
6683 Kind = ConstantExprKind::NonClassTemplateArgument;
6685 Kind = ConstantExprKind::Normal;
6688 (RequireInt && !Eval.
Val.
isInt())) {
6695 if (Notes.empty()) {
6698 if (
const auto *CE = dyn_cast<ConstantExpr>(E)) {
6702 "ConstantExpr has no value associated with it");
6708 Value = std::move(PreNarrowingValue);
6714 if (Notes.size() == 1 &&
6715 Notes[0].second.getDiagID() == diag::note_invalid_subexpr_in_const_expr) {
6716 Diag(Notes[0].first, diag::err_expr_not_cce) << CCE;
6717 }
else if (!Notes.empty() && Notes[0].second.getDiagID() ==
6718 diag::note_constexpr_invalid_template_arg) {
6719 Notes[0].second.setDiagID(diag::err_constexpr_invalid_template_arg);
6720 for (
unsigned I = 0; I < Notes.size(); ++I)
6721 Diag(Notes[I].first, Notes[I].second);
6725 for (
unsigned I = 0; I < Notes.size(); ++I)
6726 Diag(Notes[I].first, Notes[I].second);
6745static ImplicitConversionSequence
6753 AllowedExplicit::Conversions,
6795 "expected a member expression");
6797 if (
const auto M = dyn_cast<UnresolvedMemberExpr>(MemExprE);
6798 M && !M->isImplicitAccess())
6799 Base = M->getBase();
6800 else if (
const auto M = dyn_cast<MemberExpr>(MemExprE);
6801 M && !M->isImplicitAccess())
6802 Base = M->getBase();
6806 if (T->isPointerType())
6835 assert(Method->isExplicitObjectMemberFunction() &&
6836 "Method is not an explicit member function");
6837 assert(NewArgs.empty() &&
"NewArgs should be empty");
6839 NewArgs.reserve(Args.size() + 1);
6841 NewArgs.push_back(
This);
6842 NewArgs.append(Args.begin(), Args.end());
6845 Method, Object->getBeginLoc());
6851 return AllowScopedEnumerations ? T->isIntegralOrEnumerationType()
6852 : T->isIntegralOrUnscopedEnumerationType();
6864 for (
unsigned I = 0, N = ViableConversions.
size(); I != N; ++I) {
6876 QualType T,
bool HadMultipleCandidates,
6878 if (ExplicitConversions.
size() == 1 && !Converter.
Suppress) {
6886 std::string TypeStr;
6891 "static_cast<" + TypeStr +
">(")
6903 HadMultipleCandidates);
6904 if (Result.isInvalid())
6910 From, Result.get()->
getType());
6911 if (Result.isInvalid())
6913 From = Result.get();
6920 QualType T,
bool HadMultipleCandidates,
6936 HadMultipleCandidates);
6937 if (Result.isInvalid())
6941 CK_UserDefinedConversion, Result.get(),
6942 nullptr, Result.get()->getValueKind(),
6967 if (
auto *ConvTemplate = dyn_cast<FunctionTemplateDecl>(D)) {
6969 ConvTemplate, FoundDecl, ActingContext, From, ToType, CandidateSet,
6975 Conv, FoundDecl, ActingContext, From, ToType, CandidateSet,
7009 From = result.
get();
7016 if (Converter.
match(T))
7023 const RecordType *RecordTy = T->getAsCanonical<RecordType>();
7036 : Converter(Converter), From(From) {}
7041 } IncompleteDiagnoser(Converter, From);
7052 ->getDefinitionOrSelf()
7053 ->getVisibleConversionFunctions();
7055 bool HadMultipleCandidates =
7060 bool HasUniqueTargetType =
true;
7076 "Conversion operator templates are considered potentially "
7080 if (Converter.
match(CurToType) || ConvTemplate) {
7086 ExplicitConversions.
addDecl(I.getDecl(), I.getAccess());
7091 else if (HasUniqueTargetType &&
7093 HasUniqueTargetType =
false;
7095 ViableConversions.
addDecl(I.getDecl(), I.getAccess());
7113 HadMultipleCandidates,
7114 ExplicitConversions))
7120 if (!HasUniqueTargetType)
7139 HadMultipleCandidates,
Found))
7148 HadMultipleCandidates,
7149 ExplicitConversions))
7157 switch (ViableConversions.
size()) {
7160 HadMultipleCandidates,
7161 ExplicitConversions))
7171 HadMultipleCandidates,
Found))
7202 if (Proto->getNumParams() < 1)
7206 QualType ArgType = Proto->getParamType(0).getNonReferenceType();
7207 if (Context.hasSameUnqualifiedType(T1, ArgType))
7211 if (Proto->getNumParams() < 2)
7215 QualType ArgType = Proto->getParamType(1).getNonReferenceType();
7216 if (Context.hasSameUnqualifiedType(T2, ArgType))
7235 unsigned SeenAt = 0;
7237 bool HasDefault =
false;
7246 return HasDefault || SeenAt != 0;
7252 bool PartialOverloading,
bool AllowExplicit,
bool AllowExplicitConversions,
7255 bool StrictPackMatch) {
7258 assert(Proto &&
"Functions without a prototype cannot be overloaded");
7259 assert(!
Function->getDescribedFunctionTemplate() &&
7260 "Use AddTemplateOverloadCandidate for function templates");
7273 CandidateSet, SuppressUserConversions,
7274 PartialOverloading, EarlyConversions, PO,
7310 CandidateSet.
addCandidate(Args.size(), EarlyConversions);
7324 Candidate.
Viable =
false;
7337 bool IsImplicitlyInstantiated =
false;
7338 if (
auto *SpecInfo =
Function->getTemplateSpecializationInfo()) {
7339 ND = SpecInfo->getTemplate();
7340 IsImplicitlyInstantiated = SpecInfo->getTemplateSpecializationKind() ==
7351 const bool IsInlineFunctionInGMF =
7353 (IsImplicitlyInstantiated ||
Function->isInlined());
7356 Candidate.
Viable =
false;
7363 Candidate.
Viable =
false;
7374 if (Args.size() == 1 &&
Constructor->isSpecializationCopyingObject() &&
7375 (
Context.hasSameUnqualifiedType(ClassType, Args[0]->getType()) ||
7378 Candidate.
Viable =
false;
7390 auto *Shadow = dyn_cast<ConstructorUsingShadowDecl>(FoundDecl.
getDecl());
7391 if (Shadow && Args.size() == 1 &&
Constructor->getNumParams() >= 1 &&
7392 Constructor->getParamDecl(0)->getType()->isReferenceType()) {
7399 Candidate.
Viable =
false;
7408 Constructor->getMethodQualifiers().getAddressSpace(),
7410 Candidate.
Viable =
false;
7423 Candidate.
Viable =
false;
7433 unsigned MinRequiredArgs =
Function->getMinRequiredArguments();
7434 if (!AggregateCandidateDeduction && Args.size() < MinRequiredArgs &&
7435 !PartialOverloading) {
7437 Candidate.
Viable =
false;
7451 Candidate.
Viable =
false;
7457 if (
Function->getTrailingRequiresClause()) {
7462 Candidate.
Viable =
false;
7471 for (
unsigned ArgIdx = 0; ArgIdx < Args.size(); ++ArgIdx) {
7474 if (Candidate.
Conversions[ConvIdx].isInitialized()) {
7477 }
else if (ArgIdx < NumParams) {
7488 Args[ArgIdx]->
getType().getAddressSpace() ==
7490 Diag(Args[ArgIdx]->getBeginLoc(), diag::warn_hlsl_groupshared_inout);
7493 *
this, Args[ArgIdx], ParamType, SuppressUserConversions,
7496 getLangOpts().ObjCAutoRefCount, AllowExplicitConversions);
7498 Candidate.
Viable =
false;
7510 if (EnableIfAttr *FailedAttr =
7512 Candidate.
Viable =
false;
7522 if (Methods.size() <= 1)
7525 for (
unsigned b = 0, e = Methods.size();
b < e;
b++) {
7531 if (
Method->param_size() > NumNamedArgs)
7532 NumNamedArgs =
Method->param_size();
7533 if (Args.size() < NumNamedArgs)
7536 for (
unsigned i = 0; i < NumNamedArgs; i++) {
7538 if (Args[i]->isTypeDependent()) {
7544 Expr *argExpr = Args[i];
7545 assert(argExpr &&
"SelectBestMethod(): missing expression");
7550 !param->
hasAttr<CFConsumedAttr>())
7551 argExpr =
ObjC().stripARCUnbridgedCast(argExpr);
7568 if (ConversionState.
isBad() ||
7578 for (
unsigned i = NumNamedArgs, e = Args.size(); i < e; ++i) {
7579 if (Args[i]->isTypeDependent()) {
7592 if (Args.size() != NumNamedArgs)
7594 else if (
Match && NumNamedArgs == 0 && Methods.size() > 1) {
7597 for (
unsigned b = 0, e = Methods.size();
b < e;
b++) {
7598 QualType ReturnT = Methods[
b]->getReturnType();
7618 "Shouldn't have `this` for ctors!");
7619 assert(!Method->isStatic() &&
"Shouldn't have `this` for static methods!");
7621 ThisArg, std::nullopt, Method, Method);
7624 ConvertedThis = R.get();
7626 if (
auto *MD = dyn_cast<CXXMethodDecl>(Function)) {
7628 assert((MissingImplicitThis || MD->isStatic() ||
7630 "Expected `this` for non-ctor instance methods");
7632 ConvertedThis =
nullptr;
7637 unsigned ArgSizeNoVarargs = std::min(Function->param_size(), Args.size());
7640 for (
unsigned I = 0; I != ArgSizeNoVarargs; ++I) {
7643 S.
Context, Function->getParamDecl(I)),
7649 ConvertedArgs.push_back(R.get());
7656 if (!Function->isVariadic() && Args.size() < Function->getNumParams()) {
7657 for (
unsigned i = Args.size(), e = Function->getNumParams(); i != e; ++i) {
7664 ConvertedArgs.push_back(R.get());
7676 bool MissingImplicitThis) {
7677 auto EnableIfAttrs =
Function->specific_attrs<EnableIfAttr>();
7678 if (EnableIfAttrs.begin() == EnableIfAttrs.end())
7684 llvm::scope_exit UndelayDiags(
7686 DelayedDiagnostics.popUndelayed(CurrentState);
7690 Expr *DiscardedThis;
7692 *
this,
Function,
nullptr, CallLoc, Args, Trap,
7693 true, DiscardedThis, ConvertedArgs))
7694 return *EnableIfAttrs.begin();
7696 for (
auto *EIA : EnableIfAttrs) {
7700 if (EIA->getCond()->isValueDependent() ||
7701 !EIA->getCond()->EvaluateWithSubstitution(
7705 if (!
Result.isInt() || !
Result.getInt().getBoolValue())
7711template <
typename CheckFn>
7714 CheckFn &&IsSuccessful) {
7717 if (ArgDependent == DIA->getArgDependent())
7718 Attrs.push_back(DIA);
7725 auto WarningBegin = std::stable_partition(
7726 Attrs.begin(), Attrs.end(), [](
const DiagnoseIfAttr *DIA) {
7727 return DIA->getDefaultSeverity() == DiagnoseIfAttr::DS_error &&
7728 DIA->getWarningGroup().empty();
7733 auto ErrAttr = llvm::find_if(llvm::make_range(Attrs.begin(), WarningBegin),
7735 if (ErrAttr != WarningBegin) {
7736 const DiagnoseIfAttr *DIA = *ErrAttr;
7737 S.
Diag(Loc, diag::err_diagnose_if_succeeded) << DIA->getMessage();
7738 S.
Diag(DIA->getLocation(), diag::note_from_diagnose_if)
7739 << DIA->getParent() << DIA->getCond()->getSourceRange();
7743 auto ToSeverity = [](DiagnoseIfAttr::DefaultSeverity Sev) {
7745 case DiagnoseIfAttr::DS_warning:
7747 case DiagnoseIfAttr::DS_error:
7750 llvm_unreachable(
"Fully covered switch above!");
7753 for (
const auto *DIA : llvm::make_range(WarningBegin, Attrs.end()))
7754 if (IsSuccessful(DIA)) {
7755 if (DIA->getWarningGroup().empty() &&
7756 DIA->getDefaultSeverity() == DiagnoseIfAttr::DS_warning) {
7757 S.
Diag(Loc, diag::warn_diagnose_if_succeeded) << DIA->getMessage();
7758 S.
Diag(DIA->getLocation(), diag::note_from_diagnose_if)
7759 << DIA->getParent() << DIA->getCond()->getSourceRange();
7762 DIA->getWarningGroup());
7765 {ToSeverity(DIA->getDefaultSeverity()),
"%0",
7767 S.
Diag(Loc, DiagID) << DIA->getMessage();
7775 const Expr *ThisArg,
7780 [&](
const DiagnoseIfAttr *DIA) {
7785 if (!DIA->getCond()->EvaluateWithSubstitution(
7788 return Result.isInt() &&
Result.getInt().getBoolValue();
7795 *
this, ND,
false, Loc,
7796 [&](
const DiagnoseIfAttr *DIA) {
7798 return DIA->getCond()->EvaluateAsBooleanCondition(
Result,
Context) &&
7807 bool SuppressUserConversions,
7808 bool PartialOverloading,
7809 bool FirstArgumentIsBase) {
7821 if (Args.size() > 0) {
7822 if (
Expr *E = Args[0]) {
7832 FunctionArgs = Args.slice(1);
7836 FunTmpl, F.getPair(),
7838 ExplicitTemplateArgs, ObjectType, ObjectClassification,
7839 FunctionArgs, CandidateSet, SuppressUserConversions,
7840 PartialOverloading);
7844 ObjectClassification, FunctionArgs, CandidateSet,
7845 SuppressUserConversions, PartialOverloading);
7852 if (Args.size() > 0 &&
7856 FunctionArgs = Args.slice(1);
7860 ExplicitTemplateArgs, FunctionArgs,
7861 CandidateSet, SuppressUserConversions,
7862 PartialOverloading);
7865 SuppressUserConversions, PartialOverloading);
7875 bool SuppressUserConversions,
7885 "Expected a member function template");
7887 nullptr, ObjectType,
7888 ObjectClassification, Args, CandidateSet,
7889 SuppressUserConversions,
false, PO);
7892 ObjectType, ObjectClassification, Args, CandidateSet,
7893 SuppressUserConversions,
false, {}, PO);
7906 assert(Proto &&
"Methods without a prototype cannot be overloaded");
7908 "Use AddOverloadCandidate for constructors");
7917 Method->isMoveAssignmentOperator())
7924 bool IgnoreExplicitObject =
7925 (
Method->isExplicitObjectMemberFunction() &&
7928 bool ImplicitObjectMethodTreatedAsStatic =
7931 Method->isImplicitObjectMemberFunction();
7933 unsigned ExplicitOffset =
7934 !IgnoreExplicitObject &&
Method->isExplicitObjectMemberFunction() ? 1 : 0;
7936 unsigned NumParams =
Method->getNumParams() - ExplicitOffset +
7937 int(ImplicitObjectMethodTreatedAsStatic);
7939 unsigned ExtraArgs =
7946 CandidateSet.
addCandidate(Args.size() + ExtraArgs, EarlyConversions);
7962 Candidate.
Viable =
false;
7972 unsigned MinRequiredArgs =
Method->getMinRequiredArguments() -
7974 int(ImplicitObjectMethodTreatedAsStatic);
7976 if (Args.size() < MinRequiredArgs && !PartialOverloading) {
7978 Candidate.
Viable =
false;
7986 if (!IgnoreExplicitObject) {
7989 else if (
Method->isStatic()) {
7999 Candidate.
Conversions[FirstConvIdx].setStaticObjectArgument();
8004 *
this, CandidateSet.
getLocation(), ObjectType, ObjectClassification,
8005 Method, ActingContext,
true);
8006 if (Candidate.
Conversions[FirstConvIdx].isBad()) {
8007 Candidate.
Viable =
false;
8018 Candidate.
Viable =
false;
8023 if (
Method->getTrailingRequiresClause()) {
8028 Candidate.
Viable =
false;
8036 for (
unsigned ArgIdx = 0; ArgIdx < Args.size(); ++ArgIdx) {
8039 if (Candidate.
Conversions[ConvIdx].isInitialized()) {
8042 }
else if (ArgIdx < NumParams) {
8048 if (ImplicitObjectMethodTreatedAsStatic) {
8049 ParamType = ArgIdx == 0
8050 ?
Method->getFunctionObjectParameterReferenceType()
8053 ParamType = Proto->
getParamType(ArgIdx + ExplicitOffset);
8057 SuppressUserConversions,
8062 Candidate.
Viable =
false;
8074 if (EnableIfAttr *FailedAttr =
8076 Candidate.
Viable =
false;
8083 Candidate.
Viable =
false;
8094 bool SuppressUserConversions,
bool PartialOverloading,
8112 PartialOverloading,
false,
8113 false, ObjectType, ObjectClassification,
8117 bool OnlyInitializeNonUserDefinedConversions) {
8118 return S.CheckNonDependentConversions(
8119 MethodTmpl, ParamTypes, Args, CandidateSet, Conversions,
8120 Sema::CheckNonDependentConversionsFlag(
8121 SuppressUserConversions,
8122 OnlyInitializeNonUserDefinedConversions),
8123 ActingContext, ObjectType, ObjectClassification, PO);
8127 CandidateSet.
addCandidate(Conversions.size(), Conversions);
8130 Candidate.
Viable =
false;
8139 Method->isStatic() ||
8140 (!Method->isExplicitObjectMemberFunction() && ObjectType.
isNull());
8154 assert(
Specialization &&
"Missing member function template specialization?");
8156 "Specialization is not a member function?");
8159 ObjectClassification, Args, CandidateSet, SuppressUserConversions,
8173 if (ExplicitTemplateArgs ||
8176 *
this, CandidateSet, MethodTmpl, FoundDecl, ActingContext,
8177 ExplicitTemplateArgs, ObjectType, ObjectClassification, Args,
8178 SuppressUserConversions, PartialOverloading, PO);
8183 MethodTmpl, FoundDecl, ActingContext, ObjectType, ObjectClassification,
8184 Args, SuppressUserConversions, PartialOverloading, PO);
8202 bool SuppressUserConversions,
bool PartialOverloading,
bool AllowExplicit,
8204 bool AggregateCandidateDeduction) {
8213 Candidate.
Viable =
false;
8233 PartialOverloading, AggregateCandidateDeduction,
8240 bool OnlyInitializeNonUserDefinedConversions) {
8241 return S.CheckNonDependentConversions(
8242 FunctionTemplate, ParamTypes, Args, CandidateSet, Conversions,
8243 Sema::CheckNonDependentConversionsFlag(
8244 SuppressUserConversions,
8245 OnlyInitializeNonUserDefinedConversions),
8246 nullptr, QualType(), {}, PO);
8249 OverloadCandidate &Candidate =
8250 CandidateSet.addCandidate(Conversions.size(), Conversions);
8253 Candidate.
Viable =
false;
8255 CandidateSet.getRewriteInfo().getRewriteKind(Candidate.
Function, PO);
8261 CandidateSet.getKind() ==
8267 ->isExplicitObjectMemberFunction() &&
8283 assert(
Specialization &&
"Missing function template specialization?");
8285 Specialization, FoundDecl, Args, CandidateSet, SuppressUserConversions,
8286 PartialOverloading, AllowExplicit,
8287 false, IsADLCandidate, Conversions, PO,
8288 Info.AggregateDeductionCandidateHasMismatchedArity,
8289 Info.hasStrictPackMatch());
8296 bool PartialOverloading,
bool AllowExplicit,
ADLCallKind IsADLCandidate,
8303 if (ExplicitTemplateArgs ||
8306 DependentExplicitSpecifier)) {
8310 Args, SuppressUserConversions, PartialOverloading, AllowExplicit,
8311 IsADLCandidate, PO, AggregateCandidateDeduction);
8313 if (DependentExplicitSpecifier)
8320 PartialOverloading, AllowExplicit, IsADLCandidate, PO,
8321 AggregateCandidateDeduction);
8334 const bool AllowExplicit =
false;
8336 bool ForOverloadSetAddressResolution =
8339 auto *
Method = dyn_cast<CXXMethodDecl>(FD);
8340 bool HasThisConversion = !ForOverloadSetAddressResolution &&
Method &&
8342 unsigned ThisConversions = HasThisConversion ? 1 : 0;
8358 if (!FD->hasCXXExplicitFunctionObjectParameter() ||
8359 !ParamTypes[0]->isDependentType()) {
8361 *
this, CandidateSet.
getLocation(), ObjectType, ObjectClassification,
8362 Method, ActingContext,
true,
8363 FD->hasCXXExplicitFunctionObjectParameter() ? ParamTypes[0]
8373 auto MaybeInvolveUserDefinedConversion = [&](
QualType ParamType,
8397 if (
auto *RD =
ArgType->getAsCXXRecordDecl();
8398 RD && RD->hasDefinition() &&
8399 !RD->getVisibleConversionFunctions().empty())
8406 HasThisConversion &&
Method->hasCXXExplicitFunctionObjectParameter() ? 1
8409 for (
unsigned I = 0, N = std::min(ParamTypes.size() - Offset, Args.size());
8411 QualType ParamType = ParamTypes[I + Offset];
8415 ConvIdx = Args.size() - 1 - I;
8416 assert(Args.size() + ThisConversions == 2 &&
8417 "number of args (including 'this') must be exactly 2 for "
8421 assert(!HasThisConversion || (ConvIdx == 0 && I == 0));
8424 ConvIdx = ThisConversions + I;
8429 MaybeInvolveUserDefinedConversion(ParamType, Args[I]->
getType()))
8458 bool AllowObjCPointerConversion) {
8466 bool ObjCLifetimeConversion;
8468 ObjCLifetimeConversion))
8473 if (!AllowObjCPointerConversion)
8477 bool IncompatibleObjC =
false;
8487 bool AllowExplicit,
bool AllowResultConversion,
bool StrictPackMatch) {
8489 "Conversion function templates use AddTemplateConversionCandidate");
8504 if (!AllowResultConversion &&
8516 AllowObjCConversionOnExplicit))
8538 if (!AllowExplicit && Conversion->
isExplicit()) {
8539 Candidate.
Viable =
false;
8566 Candidate.
Viable =
false;
8575 Candidate.
Viable =
false;
8586 QualType ToCanon =
Context.getCanonicalType(ToType).getUnqualifiedType();
8587 if (FromCanon == ToCanon ||
8589 Candidate.
Viable =
false;
8606 CK_FunctionToPointerDecay, &ConversionRef,
8611 Candidate.
Viable =
false;
8641 Candidate.
Viable =
false;
8653 Candidate.
Viable =
false;
8660 Candidate.
Viable =
false;
8666 "Can only end up with a standard conversion sequence or failure");
8669 if (EnableIfAttr *FailedAttr =
8671 Candidate.
Viable =
false;
8678 Candidate.
Viable =
false;
8687 bool AllowObjCConversionOnExplicit,
bool AllowExplicit,
8688 bool AllowResultConversion) {
8697 Candidate.
Viable =
false;
8714 Candidate.
Viable =
false;
8724 assert(
Specialization &&
"Missing function template specialization?");
8726 ToType, CandidateSet, AllowObjCConversionOnExplicit,
8727 AllowExplicit, AllowResultConversion,
8735 bool AllowExplicit,
bool AllowResultConversion) {
8737 "Only conversion function templates permitted here");
8748 ToType, AllowObjCConversionOnExplicit, AllowExplicit,
8749 AllowResultConversion);
8757 AllowObjCConversionOnExplicit, AllowExplicit, AllowResultConversion);
8792 *
this, CandidateSet.
getLocation(), Object->getType(),
8793 Object->Classify(
Context), Conversion, ActingContext);
8796 if (ObjectInit.
isBad()) {
8797 Candidate.
Viable =
false;
8808 Candidate.
Conversions[0].UserDefined.EllipsisConversion =
false;
8809 Candidate.
Conversions[0].UserDefined.HadMultipleCandidates =
false;
8810 Candidate.
Conversions[0].UserDefined.ConversionFunction = Conversion;
8811 Candidate.
Conversions[0].UserDefined.FoundConversionFunction = FoundDecl;
8814 Candidate.
Conversions[0].UserDefined.After.setAsIdentityConversion();
8822 if (Args.size() > NumParams && !Proto->
isVariadic()) {
8823 Candidate.
Viable =
false;
8830 if (Args.size() < NumParams) {
8832 Candidate.
Viable =
false;
8839 for (
unsigned ArgIdx = 0, N = Args.size(); ArgIdx != N; ++ArgIdx) {
8840 if (ArgIdx < NumParams) {
8853 Candidate.
Viable =
false;
8870 Candidate.
Viable =
false;
8876 if (EnableIfAttr *FailedAttr =
8878 Candidate.
Viable =
false;
8902 "unqualified operator lookup found a member function");
8906 FunctionArgs, CandidateSet);
8912 FunctionArgs[1], FunctionArgs[0]);
8914 Reversed, CandidateSet,
false,
false,
true,
8915 ADLCallKind::NotADL,
8919 if (ExplicitTemplateArgs)
8924 {FunctionArgs[1], FunctionArgs[0]}, CandidateSet,
8925 false,
false,
true,
false, ADLCallKind::NotADL, {},
8957 if (!T1RD || (!IsComplete && !T1RD->isBeingDefined()))
8965 OperEnd = Operators.
end();
8966 Oper != OperEnd; ++Oper) {
8967 if (Oper->getAsFunction() &&
8970 *
this, {Args[1], Args[0]}, Oper->getAsFunction()))
8973 Args[0]->Classify(
Context), Args.slice(1),
8974 CandidateSet,
false, PO);
8981 bool IsAssignmentOperator,
8982 unsigned NumContextualBoolArguments) {
8997 for (
unsigned ArgIdx = 0, N = Args.size(); ArgIdx != N; ++ArgIdx) {
9010 if (ArgIdx < NumContextualBoolArguments) {
9011 assert(ParamTys[ArgIdx] ==
Context.BoolTy &&
9012 "Contextual conversion to bool requires bool type");
9018 ArgIdx == 0 && IsAssignmentOperator,
9024 Candidate.
Viable =
false;
9037class BuiltinCandidateTypeSet {
9043 TypeSet PointerTypes;
9047 TypeSet MemberPointerTypes;
9051 TypeSet EnumerationTypes;
9055 TypeSet VectorTypes;
9059 TypeSet MatrixTypes;
9062 TypeSet BitIntTypes;
9065 bool HasNonRecordTypes;
9069 bool HasArithmeticOrEnumeralTypes;
9073 bool HasNullPtrType;
9082 bool AddPointerWithMoreQualifiedTypeVariants(
QualType Ty,
9084 bool AddMemberPointerWithMoreQualifiedTypeVariants(
QualType Ty);
9088 typedef TypeSet::iterator
iterator;
9090 BuiltinCandidateTypeSet(
Sema &SemaRef)
9091 : HasNonRecordTypes(
false),
9092 HasArithmeticOrEnumeralTypes(
false),
9093 HasNullPtrType(
false),
9095 Context(SemaRef.Context) { }
9097 void AddTypesConvertedFrom(
QualType Ty,
9099 bool AllowUserConversions,
9100 bool AllowExplicitConversions,
9101 const Qualifiers &VisibleTypeConversionsQuals);
9103 llvm::iterator_range<iterator> pointer_types() {
return PointerTypes; }
9104 llvm::iterator_range<iterator> member_pointer_types() {
9105 return MemberPointerTypes;
9107 llvm::iterator_range<iterator> enumeration_types() {
9108 return EnumerationTypes;
9110 llvm::iterator_range<iterator> vector_types() {
return VectorTypes; }
9111 llvm::iterator_range<iterator> matrix_types() {
return MatrixTypes; }
9112 llvm::iterator_range<iterator> bitint_types() {
return BitIntTypes; }
9114 bool containsMatrixType(QualType Ty)
const {
return MatrixTypes.count(Ty); }
9115 bool hasNonRecordTypes() {
return HasNonRecordTypes; }
9116 bool hasArithmeticOrEnumeralTypes() {
return HasArithmeticOrEnumeralTypes; }
9117 bool hasNullPtrType()
const {
return HasNullPtrType; }
9132BuiltinCandidateTypeSet::AddPointerWithMoreQualifiedTypeVariants(QualType Ty,
9133 const Qualifiers &VisibleQuals) {
9136 if (!PointerTypes.insert(Ty))
9140 const PointerType *PointerTy = Ty->
getAs<PointerType>();
9141 bool buildObjCPtr =
false;
9143 const ObjCObjectPointerType *PTy = Ty->
castAs<ObjCObjectPointerType>();
9145 buildObjCPtr =
true;
9157 unsigned BaseCVR = PointeeTy.getCVRQualifiers();
9163 if ((CVR | BaseCVR) != CVR)
continue;
9178 QualType QPointerTy;
9185 PointerTypes.insert(QPointerTy);
9201BuiltinCandidateTypeSet::AddMemberPointerWithMoreQualifiedTypeVariants(
9204 if (!MemberPointerTypes.insert(Ty))
9207 const MemberPointerType *PointerTy = Ty->
getAs<MemberPointerType>();
9208 assert(PointerTy &&
"type was not a member pointer type!");
9223 if ((CVR | BaseCVR) != CVR)
continue;
9227 QPointeeTy, std::nullopt, Cls));
9242BuiltinCandidateTypeSet::AddTypesConvertedFrom(QualType Ty,
9244 bool AllowUserConversions,
9245 bool AllowExplicitConversions,
9246 const Qualifiers &VisibleQuals) {
9252 if (
const ReferenceType *RefTy = Ty->
getAs<ReferenceType>())
9257 Ty = SemaRef.Context.getArrayDecayedType(Ty);
9264 HasNonRecordTypes = HasNonRecordTypes || !TyIsRec;
9267 HasArithmeticOrEnumeralTypes =
9271 PointerTypes.insert(Ty);
9272 else if (Ty->
getAs<PointerType>() || Ty->
getAs<ObjCObjectPointerType>()) {
9275 if (!AddPointerWithMoreQualifiedTypeVariants(Ty, VisibleQuals))
9279 if (!AddMemberPointerWithMoreQualifiedTypeVariants(Ty))
9282 HasArithmeticOrEnumeralTypes =
true;
9283 EnumerationTypes.insert(Ty);
9285 HasArithmeticOrEnumeralTypes =
true;
9286 BitIntTypes.insert(Ty);
9290 HasArithmeticOrEnumeralTypes =
true;
9291 VectorTypes.insert(Ty);
9295 HasArithmeticOrEnumeralTypes =
true;
9296 MatrixTypes.insert(Ty);
9298 HasNullPtrType =
true;
9299 }
else if (AllowUserConversions && TyIsRec) {
9301 if (!SemaRef.isCompleteType(Loc, Ty))
9305 for (NamedDecl *D : ClassDecl->getVisibleConversionFunctions()) {
9315 if (AllowExplicitConversions || !Conv->
isExplicit()) {
9363 ClassDecl = RHSMPType->getMostRecentCXXRecordDecl();
9411 if (Available.hasAtomic()) {
9412 Available.removeAtomic();
9419 if (Available.hasVolatile()) {
9420 Available.removeVolatile();
9454class BuiltinOperatorOverloadBuilder {
9457 ArrayRef<Expr *> Args;
9458 QualifiersAndAtomic VisibleTypeConversionsQuals;
9459 bool HasArithmeticOrEnumeralCandidateType;
9460 SmallVectorImpl<BuiltinCandidateTypeSet> &CandidateTypes;
9461 OverloadCandidateSet &CandidateSet;
9463 static constexpr int ArithmeticTypesCap = 26;
9464 SmallVector<CanQualType, ArithmeticTypesCap> ArithmeticTypes;
9469 unsigned FirstIntegralType,
9471 unsigned FirstPromotedIntegralType,
9472 LastPromotedIntegralType;
9473 unsigned FirstPromotedArithmeticType,
9474 LastPromotedArithmeticType;
9475 unsigned NumArithmeticTypes;
9477 void InitArithmeticTypes() {
9479 FirstPromotedArithmeticType = 0;
9489 FirstIntegralType = ArithmeticTypes.size();
9490 FirstPromotedIntegralType = ArithmeticTypes.size();
9512 llvm::SmallSetVector<CanQualType, 2> BitIntCandidates;
9513 for (BuiltinCandidateTypeSet &Candidate : CandidateTypes) {
9514 for (QualType BitTy : Candidate.bitint_types())
9517 llvm::move(BitIntCandidates, std::back_inserter(ArithmeticTypes));
9518 LastPromotedIntegralType = ArithmeticTypes.size();
9519 LastPromotedArithmeticType = ArithmeticTypes.size();
9533 LastIntegralType = ArithmeticTypes.size();
9534 NumArithmeticTypes = ArithmeticTypes.size();
9541 assert(ArithmeticTypes.size() - BitIntCandidates.size() <=
9542 ArithmeticTypesCap &&
9543 "Enough inline storage for all arithmetic types.");
9548 void addPlusPlusMinusMinusStyleOverloads(QualType CandidateTy,
9551 QualType ParamTypes[2] = {
9591 void AddCandidate(QualType L, QualType R) {
9592 QualType LandR[2] = {L,
R};
9597 BuiltinOperatorOverloadBuilder(
9598 Sema &S, ArrayRef<Expr *> Args,
9599 QualifiersAndAtomic VisibleTypeConversionsQuals,
9600 bool HasArithmeticOrEnumeralCandidateType,
9601 SmallVectorImpl<BuiltinCandidateTypeSet> &CandidateTypes,
9602 OverloadCandidateSet &CandidateSet)
9604 VisibleTypeConversionsQuals(VisibleTypeConversionsQuals),
9605 HasArithmeticOrEnumeralCandidateType(
9606 HasArithmeticOrEnumeralCandidateType),
9607 CandidateTypes(CandidateTypes),
9608 CandidateSet(CandidateSet) {
9610 InitArithmeticTypes();
9633 if (!HasArithmeticOrEnumeralCandidateType)
9636 for (
unsigned Arith = 0; Arith < NumArithmeticTypes; ++Arith) {
9637 const auto TypeOfT = ArithmeticTypes[Arith];
9639 if (Op == OO_MinusMinus)
9641 if (Op == OO_PlusPlus && S.
getLangOpts().CPlusPlus17)
9644 addPlusPlusMinusMinusStyleOverloads(
9661 void addPlusPlusMinusMinusPointerOverloads() {
9662 for (QualType PtrTy : CandidateTypes[0].pointer_types()) {
9664 if (!PtrTy->getPointeeType()->isObjectType())
9667 addPlusPlusMinusMinusStyleOverloads(
9669 (!PtrTy.isVolatileQualified() &&
9671 (!PtrTy.isRestrictQualified() &&
9686 void addUnaryStarPointerOverloads() {
9687 for (QualType ParamTy : CandidateTypes[0].pointer_types()) {
9692 if (
const FunctionProtoType *Proto =PointeeTy->
getAs<FunctionProtoType>())
9693 if (Proto->getMethodQuals() || Proto->getRefQualifier())
9706 void addUnaryPlusOrMinusArithmeticOverloads() {
9707 if (!HasArithmeticOrEnumeralCandidateType)
9710 for (
unsigned Arith = FirstPromotedArithmeticType;
9711 Arith < LastPromotedArithmeticType; ++Arith) {
9712 QualType ArithTy = ArithmeticTypes[Arith];
9717 for (QualType VecTy : CandidateTypes[0].vector_types())
9726 void addUnaryPlusPointerOverloads() {
9727 for (QualType ParamTy : CandidateTypes[0].pointer_types())
9736 void addUnaryTildePromotedIntegralOverloads() {
9737 if (!HasArithmeticOrEnumeralCandidateType)
9740 for (
unsigned Int = FirstPromotedIntegralType;
9741 Int < LastPromotedIntegralType; ++
Int) {
9742 QualType IntTy = ArithmeticTypes[
Int];
9747 for (QualType VecTy : CandidateTypes[0].vector_types())
9757 void addEqualEqualOrNotEqualMemberPointerOrNullptrOverloads() {
9759 llvm::SmallPtrSet<QualType, 8> AddedTypes;
9761 for (
unsigned ArgIdx = 0, N = Args.size(); ArgIdx != N; ++ArgIdx) {
9762 for (QualType MemPtrTy : CandidateTypes[ArgIdx].member_pointer_types()) {
9767 QualType ParamTypes[2] = {MemPtrTy, MemPtrTy};
9771 if (CandidateTypes[ArgIdx].hasNullPtrType()) {
9773 if (AddedTypes.insert(NullPtrTy).second) {
9774 QualType ParamTypes[2] = { NullPtrTy, NullPtrTy };
9793 void addGenericBinaryPointerOrEnumeralOverloads(
bool IsSpaceship) {
9806 llvm::DenseSet<std::pair<CanQualType, CanQualType> >
9807 UserDefinedBinaryOperators;
9809 for (
unsigned ArgIdx = 0, N = Args.size(); ArgIdx != N; ++ArgIdx) {
9810 if (!CandidateTypes[ArgIdx].enumeration_types().empty()) {
9812 CEnd = CandidateSet.
end();
9814 if (!
C->Viable || !
C->Function ||
C->Function->getNumParams() != 2)
9817 if (
C->Function->isFunctionTemplateSpecialization())
9824 QualType FirstParamType =
C->Function->getParamDecl(
Reversed ? 1 : 0)
9826 .getUnqualifiedType();
9827 QualType SecondParamType =
C->Function->getParamDecl(
Reversed ? 0 : 1)
9829 .getUnqualifiedType();
9837 UserDefinedBinaryOperators.insert(
9845 llvm::SmallPtrSet<QualType, 8> AddedTypes;
9847 for (
unsigned ArgIdx = 0, N = Args.size(); ArgIdx != N; ++ArgIdx) {
9848 for (QualType PtrTy : CandidateTypes[ArgIdx].pointer_types()) {
9852 if (IsSpaceship && PtrTy->isFunctionPointerType())
9855 QualType ParamTypes[2] = {PtrTy, PtrTy};
9858 for (QualType EnumTy : CandidateTypes[ArgIdx].enumeration_types()) {
9863 if (!AddedTypes.insert(CanonType).second ||
9864 UserDefinedBinaryOperators.count(std::make_pair(CanonType,
9867 QualType ParamTypes[2] = {EnumTy, EnumTy};
9892 llvm::SmallPtrSet<QualType, 8> AddedTypes;
9894 for (
int Arg = 0; Arg < 2; ++Arg) {
9895 QualType AsymmetricParamTypes[2] = {
9899 for (QualType PtrTy : CandidateTypes[Arg].pointer_types()) {
9904 AsymmetricParamTypes[Arg] = PtrTy;
9905 if (Arg == 0 || Op == OO_Plus) {
9910 if (Op == OO_Minus) {
9915 QualType ParamTypes[2] = {PtrTy, PtrTy};
9951 void addGenericBinaryArithmeticOverloads() {
9952 if (!HasArithmeticOrEnumeralCandidateType)
9955 for (
unsigned Left = FirstPromotedArithmeticType;
9956 Left < LastPromotedArithmeticType; ++
Left) {
9957 for (
unsigned Right = FirstPromotedArithmeticType;
9958 Right < LastPromotedArithmeticType; ++
Right) {
9959 QualType LandR[2] = { ArithmeticTypes[
Left],
9960 ArithmeticTypes[
Right] };
9967 for (QualType Vec1Ty : CandidateTypes[0].vector_types())
9968 for (QualType Vec2Ty : CandidateTypes[1].vector_types()) {
9969 QualType LandR[2] = {Vec1Ty, Vec2Ty};
9979 void addMatrixBinaryArithmeticOverloads() {
9980 if (!HasArithmeticOrEnumeralCandidateType)
9983 for (QualType M1 : CandidateTypes[0].matrix_types()) {
9985 AddCandidate(M1, M1);
9988 for (QualType M2 : CandidateTypes[1].matrix_types()) {
9990 if (!CandidateTypes[0].containsMatrixType(M2))
9991 AddCandidate(M2, M2);
10026 void addThreeWayArithmeticOverloads() {
10027 addGenericBinaryArithmeticOverloads();
10044 void addBinaryBitwiseArithmeticOverloads() {
10045 if (!HasArithmeticOrEnumeralCandidateType)
10048 for (
unsigned Left = FirstPromotedIntegralType;
10049 Left < LastPromotedIntegralType; ++
Left) {
10050 for (
unsigned Right = FirstPromotedIntegralType;
10051 Right < LastPromotedIntegralType; ++
Right) {
10052 QualType LandR[2] = { ArithmeticTypes[
Left],
10053 ArithmeticTypes[
Right] };
10066 void addAssignmentMemberPointerOrEnumeralOverloads() {
10068 llvm::SmallPtrSet<QualType, 8> AddedTypes;
10070 for (
unsigned ArgIdx = 0; ArgIdx < 2; ++ArgIdx) {
10071 for (QualType EnumTy : CandidateTypes[ArgIdx].enumeration_types()) {
10078 for (QualType MemPtrTy : CandidateTypes[ArgIdx].member_pointer_types()) {
10103 void addAssignmentPointerOverloads(
bool isEqualOp) {
10105 llvm::SmallPtrSet<QualType, 8> AddedTypes;
10107 for (QualType PtrTy : CandidateTypes[0].pointer_types()) {
10111 else if (!PtrTy->getPointeeType()->isObjectType())
10115 QualType ParamTypes[2] = {
10122 bool NeedVolatile = !PtrTy.isVolatileQualified() &&
10124 if (NeedVolatile) {
10132 if (!PtrTy.isRestrictQualified() &&
10140 if (NeedVolatile) {
10152 for (QualType PtrTy : CandidateTypes[1].pointer_types()) {
10157 QualType ParamTypes[2] = {
10166 bool NeedVolatile = !PtrTy.isVolatileQualified() &&
10168 if (NeedVolatile) {
10176 if (!PtrTy.isRestrictQualified() &&
10184 if (NeedVolatile) {
10209 void addAssignmentArithmeticOverloads(
bool isEqualOp) {
10210 if (!HasArithmeticOrEnumeralCandidateType)
10213 for (
unsigned Left = 0;
Left < NumArithmeticTypes; ++
Left) {
10214 for (
unsigned Right = FirstPromotedArithmeticType;
10215 Right < LastPromotedArithmeticType; ++
Right) {
10216 QualType ParamTypes[2];
10217 ParamTypes[1] = ArithmeticTypes[
Right];
10219 S, ArithmeticTypes[Left], Args[0]);
10222 VisibleTypeConversionsQuals, [&](QualifiersAndAtomic Quals) {
10232 for (QualType Vec1Ty : CandidateTypes[0].vector_types())
10233 for (QualType Vec2Ty : CandidateTypes[0].vector_types()) {
10234 QualType ParamTypes[2];
10235 ParamTypes[1] = Vec2Ty;
10263 void addAssignmentIntegralOverloads() {
10264 if (!HasArithmeticOrEnumeralCandidateType)
10267 for (
unsigned Left = FirstIntegralType;
Left < LastIntegralType; ++
Left) {
10268 for (
unsigned Right = FirstPromotedIntegralType;
10269 Right < LastPromotedIntegralType; ++
Right) {
10270 QualType ParamTypes[2];
10271 ParamTypes[1] = ArithmeticTypes[
Right];
10273 S, ArithmeticTypes[Left], Args[0]);
10276 VisibleTypeConversionsQuals, [&](QualifiersAndAtomic Quals) {
10292 void addExclaimOverload() {
10298 void addAmpAmpOrPipePipeOverload() {
10315 void addSubscriptOverloads() {
10316 for (QualType PtrTy : CandidateTypes[0].pointer_types()) {
10326 for (QualType PtrTy : CandidateTypes[1].pointer_types()) {
10346 void addArrowStarOverloads() {
10347 for (QualType PtrTy : CandidateTypes[0].pointer_types()) {
10348 QualType C1Ty = PtrTy;
10350 QualifierCollector Q1;
10361 for (QualType MemPtrTy : CandidateTypes[1].member_pointer_types()) {
10368 QualType ParamTypes[2] = {PtrTy, MemPtrTy};
10371 if (!VisibleTypeConversionsQuals.
hasVolatile() &&
10374 if (!VisibleTypeConversionsQuals.
hasRestrict() &&
10393 void addConditionalOperatorOverloads() {
10395 llvm::SmallPtrSet<QualType, 8> AddedTypes;
10397 for (
unsigned ArgIdx = 0; ArgIdx < 2; ++ArgIdx) {
10398 for (QualType PtrTy : CandidateTypes[ArgIdx].pointer_types()) {
10402 QualType ParamTypes[2] = {PtrTy, PtrTy};
10406 for (QualType MemPtrTy : CandidateTypes[ArgIdx].member_pointer_types()) {
10410 QualType ParamTypes[2] = {MemPtrTy, MemPtrTy};
10415 for (QualType EnumTy : CandidateTypes[ArgIdx].enumeration_types()) {
10416 if (!EnumTy->castAsCanonical<EnumType>()->getDecl()->isScoped())
10422 QualType ParamTypes[2] = {EnumTy, EnumTy};
10441 VisibleTypeConversionsQuals.
addConst();
10442 for (
unsigned ArgIdx = 0, N = Args.size(); ArgIdx != N; ++ArgIdx) {
10444 if (Args[ArgIdx]->
getType()->isAtomicType())
10445 VisibleTypeConversionsQuals.
addAtomic();
10448 bool HasNonRecordCandidateType =
false;
10449 bool HasArithmeticOrEnumeralCandidateType =
false;
10451 for (
unsigned ArgIdx = 0, N = Args.size(); ArgIdx != N; ++ArgIdx) {
10452 CandidateTypes.emplace_back(*
this);
10453 CandidateTypes[ArgIdx].AddTypesConvertedFrom(Args[ArgIdx]->
getType(),
10456 (Op == OO_Exclaim ||
10458 Op == OO_PipePipe),
10459 VisibleTypeConversionsQuals);
10460 HasNonRecordCandidateType = HasNonRecordCandidateType ||
10461 CandidateTypes[ArgIdx].hasNonRecordTypes();
10462 HasArithmeticOrEnumeralCandidateType =
10463 HasArithmeticOrEnumeralCandidateType ||
10464 CandidateTypes[ArgIdx].hasArithmeticOrEnumeralTypes();
10472 if (!HasNonRecordCandidateType &&
10473 !(Op == OO_Exclaim || Op == OO_AmpAmp || Op == OO_PipePipe))
10477 BuiltinOperatorOverloadBuilder OpBuilder(*
this, Args,
10478 VisibleTypeConversionsQuals,
10479 HasArithmeticOrEnumeralCandidateType,
10480 CandidateTypes, CandidateSet);
10486 llvm_unreachable(
"Expected an overloaded operator");
10491 case OO_Array_Delete:
10494 "Special operators don't use AddBuiltinOperatorCandidates");
10506 if (Args.size() == 1)
10507 OpBuilder.addUnaryPlusPointerOverloads();
10511 if (Args.size() == 1) {
10512 OpBuilder.addUnaryPlusOrMinusArithmeticOverloads();
10514 OpBuilder.addBinaryPlusOrMinusPointerOverloads(Op);
10515 OpBuilder.addGenericBinaryArithmeticOverloads();
10516 OpBuilder.addMatrixBinaryArithmeticOverloads();
10521 if (Args.size() == 1)
10522 OpBuilder.addUnaryStarPointerOverloads();
10524 OpBuilder.addGenericBinaryArithmeticOverloads();
10525 OpBuilder.addMatrixBinaryArithmeticOverloads();
10530 OpBuilder.addGenericBinaryArithmeticOverloads();
10534 case OO_MinusMinus:
10535 OpBuilder.addPlusPlusMinusMinusArithmeticOverloads(Op);
10536 OpBuilder.addPlusPlusMinusMinusPointerOverloads();
10539 case OO_EqualEqual:
10540 case OO_ExclaimEqual:
10541 OpBuilder.addEqualEqualOrNotEqualMemberPointerOrNullptrOverloads();
10542 OpBuilder.addGenericBinaryPointerOrEnumeralOverloads(
false);
10543 OpBuilder.addGenericBinaryArithmeticOverloads();
10549 case OO_GreaterEqual:
10550 OpBuilder.addGenericBinaryPointerOrEnumeralOverloads(
false);
10551 OpBuilder.addGenericBinaryArithmeticOverloads();
10555 OpBuilder.addGenericBinaryPointerOrEnumeralOverloads(
true);
10556 OpBuilder.addThreeWayArithmeticOverloads();
10563 case OO_GreaterGreater:
10564 OpBuilder.addBinaryBitwiseArithmeticOverloads();
10568 if (Args.size() == 1)
10574 OpBuilder.addBinaryBitwiseArithmeticOverloads();
10578 OpBuilder.addUnaryTildePromotedIntegralOverloads();
10582 OpBuilder.addAssignmentMemberPointerOrEnumeralOverloads();
10586 case OO_MinusEqual:
10587 OpBuilder.addAssignmentPointerOverloads(Op == OO_Equal);
10591 case OO_SlashEqual:
10592 OpBuilder.addAssignmentArithmeticOverloads(Op == OO_Equal);
10595 case OO_PercentEqual:
10596 case OO_LessLessEqual:
10597 case OO_GreaterGreaterEqual:
10599 case OO_CaretEqual:
10601 OpBuilder.addAssignmentIntegralOverloads();
10605 OpBuilder.addExclaimOverload();
10610 OpBuilder.addAmpAmpOrPipePipeOverload();
10614 if (Args.size() == 2)
10615 OpBuilder.addSubscriptOverloads();
10619 OpBuilder.addArrowStarOverloads();
10622 case OO_Conditional:
10623 OpBuilder.addConditionalOperatorOverloads();
10624 OpBuilder.addGenericBinaryArithmeticOverloads();
10635 bool PartialOverloading) {
10652 CandEnd = CandidateSet.
end();
10653 Cand != CandEnd; ++Cand)
10654 if (Cand->Function) {
10658 Fns.
erase(FunTmpl);
10667 if (ExplicitTemplateArgs)
10671 FD, FoundDecl, Args, CandidateSet,
false,
10672 PartialOverloading,
true,
10673 false, ADLCallKind::UsesADL);
10676 FD, FoundDecl, {Args[1], Args[0]}, CandidateSet,
10677 false, PartialOverloading,
10684 FTD, FoundDecl, ExplicitTemplateArgs, Args, CandidateSet,
10685 false, PartialOverloading,
10686 true, ADLCallKind::UsesADL);
10688 *
this, Args, FTD->getTemplatedDecl())) {
10692 if (ReversedArgs.empty())
10696 FTD, FoundDecl, ExplicitTemplateArgs, ReversedArgs, CandidateSet,
10697 false, PartialOverloading,
10698 true, ADLCallKind::UsesADL,
10723 bool Cand1Attr = Cand1->
hasAttr<EnableIfAttr>();
10724 bool Cand2Attr = Cand2->
hasAttr<EnableIfAttr>();
10725 if (!Cand1Attr || !Cand2Attr) {
10726 if (Cand1Attr == Cand2Attr)
10727 return Comparison::Equal;
10728 return Cand1Attr ? Comparison::Better : Comparison::Worse;
10734 llvm::FoldingSetNodeID Cand1ID, Cand2ID;
10735 for (
auto Pair : zip_longest(Cand1Attrs, Cand2Attrs)) {
10736 std::optional<EnableIfAttr *> Cand1A = std::get<0>(Pair);
10737 std::optional<EnableIfAttr *> Cand2A = std::get<1>(Pair);
10742 return Comparison::Worse;
10744 return Comparison::Better;
10749 (*Cand1A)->getCond()->Profile(Cand1ID, S.
getASTContext(),
true);
10750 (*Cand2A)->getCond()->Profile(Cand2ID, S.
getASTContext(),
true);
10751 if (Cand1ID != Cand2ID)
10752 return Comparison::Worse;
10755 return Comparison::Equal;
10763 return Comparison::Equal;
10769 return Comparison::Equal;
10770 return Comparison::Worse;
10773 return Comparison::Better;
10779 const auto *Cand1CPUSpec = Cand1.
Function->
getAttr<CPUSpecificAttr>();
10780 const auto *Cand2CPUSpec = Cand2.
Function->
getAttr<CPUSpecificAttr>();
10782 if (!Cand1CPUDisp && !Cand2CPUDisp && !Cand1CPUSpec && !Cand2CPUSpec)
10783 return Comparison::Equal;
10785 if (Cand1CPUDisp && !Cand2CPUDisp)
10786 return Comparison::Better;
10787 if (Cand2CPUDisp && !Cand1CPUDisp)
10788 return Comparison::Worse;
10790 if (Cand1CPUSpec && Cand2CPUSpec) {
10791 if (Cand1CPUSpec->cpus_size() != Cand2CPUSpec->cpus_size())
10792 return Cand1CPUSpec->cpus_size() < Cand2CPUSpec->cpus_size()
10793 ? Comparison::Better
10794 : Comparison::Worse;
10796 std::pair<CPUSpecificAttr::cpus_iterator, CPUSpecificAttr::cpus_iterator>
10797 FirstDiff = std::mismatch(
10798 Cand1CPUSpec->cpus_begin(), Cand1CPUSpec->cpus_end(),
10799 Cand2CPUSpec->cpus_begin(),
10801 return LHS->getName() == RHS->getName();
10804 assert(FirstDiff.first != Cand1CPUSpec->cpus_end() &&
10805 "Two different cpu-specific versions should not have the same "
10806 "identifier list, otherwise they'd be the same decl!");
10807 return (*FirstDiff.first)->getName() < (*FirstDiff.second)->getName()
10808 ? Comparison::Better
10809 : Comparison::Worse;
10811 llvm_unreachable(
"No way to get here unless both had cpu_dispatch");
10817static std::optional<QualType>
10820 return std::nullopt;
10826 return M->getFunctionObjectParameterReferenceType();
10840 PT2->getInstantiatedFromMemberTemplate()))
10851 assert(I < F->getNumParams());
10858 if (F1NumParams != F2NumParams)
10861 unsigned I1 = 0, I2 = 0;
10862 for (
unsigned I = 0; I != F1NumParams; ++I) {
10863 QualType T1 = NextParam(F1, I1, I == 0);
10864 QualType T2 = NextParam(F2, I2, I == 0);
10865 assert(!T1.
isNull() && !T2.
isNull() &&
"Unexpected null param types");
10866 if (!Context.hasSameUnqualifiedType(T1, T2))
10879 bool IsFn1Reversed,
10880 bool IsFn2Reversed) {
10881 assert(Fn1 && Fn2);
10886 IsFn1Reversed ^ IsFn2Reversed))
10889 auto *Mem1 = dyn_cast<CXXMethodDecl>(Fn1);
10890 auto *Mem2 = dyn_cast<CXXMethodDecl>(Fn2);
10891 if (Mem1 && Mem2) {
10894 if (Mem1->getParent() != Mem2->getParent())
10898 if (Mem1->isInstance() && Mem2->isInstance() &&
10900 Mem1->getFunctionObjectParameterReferenceType(),
10901 Mem1->getFunctionObjectParameterReferenceType()))
10907static FunctionDecl *
10909 bool IsFn1Reversed,
bool IsFn2Reversed) {
10919 if (Cand1IsSpecialization || Cand2IsSpecialization)
10936 bool PartialOverloading) {
10982 bool IsCand1ImplicitHD =
10984 bool IsCand2ImplicitHD =
10999 auto EmitThreshold =
11000 (S.
getLangOpts().CUDAIsDevice && IsCallerImplicitHD &&
11001 (IsCand1ImplicitHD || IsCand2ImplicitHD))
11004 auto Cand1Emittable = P1 > EmitThreshold;
11005 auto Cand2Emittable = P2 > EmitThreshold;
11006 if (Cand1Emittable && !Cand2Emittable)
11008 if (!Cand1Emittable && Cand2Emittable)
11019 unsigned StartArg = 0;
11027 return ICS.isStandard() &&
11039 assert(Cand2.
Conversions.size() == NumArgs &&
"Overload candidate mismatch");
11040 bool HasBetterConversion =
false;
11041 for (
unsigned ArgIdx = StartArg; ArgIdx < NumArgs; ++ArgIdx) {
11042 bool Cand1Bad = IsIllFormedConversion(Cand1.
Conversions[ArgIdx]);
11043 bool Cand2Bad = IsIllFormedConversion(Cand2.
Conversions[ArgIdx]);
11044 if (Cand1Bad != Cand2Bad) {
11047 HasBetterConversion =
true;
11051 if (HasBetterConversion)
11058 bool HasWorseConversion =
false;
11059 for (
unsigned ArgIdx = StartArg; ArgIdx < NumArgs; ++ArgIdx) {
11065 HasBetterConversion =
true;
11084 HasWorseConversion =
true;
11099 if (HasBetterConversion && !HasWorseConversion)
11150 bool Cand1IsSpecialization = Cand1.
Function &&
11152 bool Cand2IsSpecialization = Cand2.
Function &&
11154 if (Cand1IsSpecialization != Cand2IsSpecialization)
11155 return Cand2IsSpecialization;
11161 if (Cand1IsSpecialization && Cand2IsSpecialization) {
11162 const auto *Obj1Context =
11164 const auto *Obj2Context =
11193 bool Cand1IsInherited =
11195 bool Cand2IsInherited =
11197 if (Cand1IsInherited != Cand2IsInherited)
11198 return Cand2IsInherited;
11199 else if (Cand1IsInherited) {
11200 assert(Cand2IsInherited);
11203 if (Cand1Class->isDerivedFrom(Cand2Class))
11205 if (Cand2Class->isDerivedFrom(Cand1Class))
11222 auto *Guide1 = dyn_cast_or_null<CXXDeductionGuideDecl>(Cand1.
Function);
11223 auto *Guide2 = dyn_cast_or_null<CXXDeductionGuideDecl>(Cand2.
Function);
11224 if (Guide1 && Guide2) {
11226 if (Guide1->isImplicit() != Guide2->isImplicit())
11227 return Guide2->isImplicit();
11237 const auto *Constructor1 = Guide1->getCorrespondingConstructor();
11238 const auto *Constructor2 = Guide2->getCorrespondingConstructor();
11239 if (Constructor1 && Constructor2) {
11240 bool isC1Templated = Constructor1->getTemplatedKind() !=
11242 bool isC2Templated = Constructor2->getTemplatedKind() !=
11244 if (isC1Templated != isC2Templated)
11245 return isC2Templated;
11253 if (
Cmp != Comparison::Equal)
11254 return Cmp == Comparison::Better;
11257 bool HasPS1 = Cand1.
Function !=
nullptr &&
11259 bool HasPS2 = Cand2.
Function !=
nullptr &&
11261 if (HasPS1 != HasPS2 && HasPS1)
11265 if (MV == Comparison::Better)
11267 if (MV == Comparison::Worse)
11282 const auto *CD1 = dyn_cast_or_null<CXXConstructorDecl>(Cand1.
Function);
11283 const auto *CD2 = dyn_cast_or_null<CXXConstructorDecl>(Cand2.
Function);
11285 LangAS AS1 = CD1->getMethodQualifiers().getAddressSpace();
11286 LangAS AS2 = CD2->getMethodQualifiers().getAddressSpace();
11307 auto *VA = dyn_cast_or_null<ValueDecl>(A);
11308 auto *VB = dyn_cast_or_null<ValueDecl>(B);
11314 if (!VA->getDeclContext()->getRedeclContext()->Equals(
11315 VB->getDeclContext()->getRedeclContext()) ||
11317 VA->isExternallyVisible() || VB->isExternallyVisible())
11325 if (
Context.hasSameType(VA->getType(), VB->getType()))
11330 if (
auto *EA = dyn_cast<EnumConstantDecl>(VA)) {
11331 if (
auto *EB = dyn_cast<EnumConstantDecl>(VB)) {
11336 if (EnumA->hasNameForLinkage() || EnumB->hasNameForLinkage() ||
11337 !
Context.hasSameType(EnumA->getIntegerType(),
11338 EnumB->getIntegerType()))
11341 return llvm::APSInt::isSameValue(EA->getInitVal(), EB->getInitVal());
11351 assert(D &&
"Unknown declaration");
11352 Diag(Loc, diag::ext_equivalent_internal_linkage_decl_in_modules) << D;
11358 for (
auto *E : Equiv) {
11360 Diag(E->getLocation(), diag::note_equivalent_internal_linkage_decl)
11370 ->Satisfaction.ContainsErrors;
11376 bool PartialOverloading,
bool AllowExplicit,
11378 bool AggregateCandidateDeduction) {
11381 allocateDeferredCandidate<DeferredFunctionTemplateOverloadCandidate>();
11386 false, AllowExplicit, SuppressUserConversions,
11387 PartialOverloading, AggregateCandidateDeduction},
11394 HasDeferredTemplateConstructors |=
11402 bool SuppressUserConversions,
bool PartialOverloading,
11408 allocateDeferredCandidate<DeferredMethodTemplateOverloadCandidate>();
11414 false, SuppressUserConversions, PartialOverloading,
11420 ObjectClassification,
11428 bool AllowObjCConversionOnExplicit,
bool AllowExplicit,
11429 bool AllowResultConversion) {
11432 allocateDeferredCandidate<DeferredConversionTemplateOverloadCandidate>();
11436 AllowObjCConversionOnExplicit, AllowResultConversion,
11453 S, CandidateSet,
C.FunctionTemplate,
C.FoundDecl,
C.ActingContext,
11454 nullptr,
C.ObjectType,
C.ObjectClassification,
11455 C.Args,
C.SuppressUserConversions,
C.PartialOverloading,
C.PO);
11462 S, CandidateSet,
C.FunctionTemplate,
C.FoundDecl,
11463 nullptr,
C.Args,
C.SuppressUserConversions,
11464 C.PartialOverloading,
C.AllowExplicit,
C.IsADLCandidate,
C.PO,
11465 C.AggregateCandidateDeduction);
11472 S, CandidateSet,
C.FunctionTemplate,
C.FoundDecl,
C.ActingContext,
C.From,
11473 C.ToType,
C.AllowObjCConversionOnExplicit,
C.AllowExplicit,
11474 C.AllowResultConversion);
11478 Candidates.reserve(Candidates.size() + DeferredCandidatesCount);
11481 switch (Cand->
Kind) {
11500 FirstDeferredCandidate =
nullptr;
11501 DeferredCandidatesCount = 0;
11505OverloadCandidateSet::ResultForBestCandidate(
const iterator &Best) {
11507 if (Best->Function && Best->Function->isDeleted())
11512void OverloadCandidateSet::CudaExcludeWrongSideCandidates(
11529 bool ContainsSameSideCandidate =
11537 if (!ContainsSameSideCandidate)
11540 auto IsWrongSideCandidate = [&](
const OverloadCandidate *Cand) {
11546 llvm::erase_if(Candidates, IsWrongSideCandidate);
11564 DeferredCandidatesCount == 0) &&
11565 "Unexpected deferred template candidates");
11567 bool TwoPhaseResolution =
11568 DeferredCandidatesCount != 0 && !ResolutionByPerfectCandidateIsDisabled;
11570 if (TwoPhaseResolution) {
11572 if (Best !=
end() && Best->isPerfectMatch(S.
Context)) {
11573 if (!(HasDeferredTemplateConstructors &&
11574 isa_and_nonnull<CXXConversionDecl>(Best->Function)))
11580 return BestViableFunctionImpl(S, Loc, Best);
11587 Candidates.reserve(this->Candidates.size());
11588 std::transform(this->Candidates.begin(), this->Candidates.end(),
11589 std::back_inserter(Candidates),
11593 CudaExcludeWrongSideCandidates(S, Candidates);
11596 for (
auto *Cand : Candidates) {
11597 Cand->
Best =
false;
11599 if (Best ==
end() ||
11616 llvm::SmallVector<OverloadCandidate *, 4> PendingBest;
11617 llvm::SmallVector<const NamedDecl *, 4> EquivalentCands;
11618 PendingBest.push_back(&*Best);
11623 while (!PendingBest.empty()) {
11624 auto *Curr = PendingBest.pop_back_val();
11625 for (
auto *Cand : Candidates) {
11628 PendingBest.push_back(Cand);
11633 EquivalentCands.push_back(Cand->
Function);
11645 if (!EquivalentCands.empty())
11653enum OverloadCandidateKind {
11656 oc_reversed_binary_operator,
11658 oc_implicit_default_constructor,
11659 oc_implicit_copy_constructor,
11660 oc_implicit_move_constructor,
11661 oc_implicit_copy_assignment,
11662 oc_implicit_move_assignment,
11663 oc_implicit_equality_comparison,
11664 oc_inherited_constructor
11667enum OverloadCandidateSelect {
11670 ocs_described_template,
11673static std::pair<OverloadCandidateKind, OverloadCandidateSelect>
11674ClassifyOverloadCandidate(Sema &S,
const NamedDecl *
Found,
11675 const FunctionDecl *Fn,
11677 std::string &Description) {
11680 if (FunctionTemplateDecl *FunTmpl =
Fn->getPrimaryTemplate()) {
11683 FunTmpl->getTemplateParameters(), *
Fn->getTemplateSpecializationArgs());
11686 OverloadCandidateSelect Select = [&]() {
11687 if (!Description.empty())
11688 return ocs_described_template;
11689 return isTemplate ? ocs_template : ocs_non_template;
11692 OverloadCandidateKind Kind = [&]() {
11693 if (
Fn->isImplicit() &&
Fn->getOverloadedOperator() == OO_EqualEqual)
11694 return oc_implicit_equality_comparison;
11697 return oc_reversed_binary_operator;
11699 if (
const auto *Ctor = dyn_cast<CXXConstructorDecl>(Fn)) {
11700 if (!Ctor->isImplicit()) {
11702 return oc_inherited_constructor;
11704 return oc_constructor;
11707 if (Ctor->isDefaultConstructor())
11708 return oc_implicit_default_constructor;
11710 if (Ctor->isMoveConstructor())
11711 return oc_implicit_move_constructor;
11713 assert(Ctor->isCopyConstructor() &&
11714 "unexpected sort of implicit constructor");
11715 return oc_implicit_copy_constructor;
11718 if (
const auto *Meth = dyn_cast<CXXMethodDecl>(Fn)) {
11721 if (!Meth->isImplicit())
11724 if (Meth->isMoveAssignmentOperator())
11725 return oc_implicit_move_assignment;
11727 if (Meth->isCopyAssignmentOperator())
11728 return oc_implicit_copy_assignment;
11734 return oc_function;
11737 return std::make_pair(Kind, Select);
11740void MaybeEmitInheritedConstructorNote(Sema &S,
const Decl *FoundDecl) {
11743 if (
const auto *Shadow = dyn_cast<ConstructorUsingShadowDecl>(FoundDecl))
11745 diag::note_ovl_candidate_inherited_constructor)
11746 << Shadow->getNominatedBaseClass();
11755 if (EnableIf->getCond()->isValueDependent() ||
11756 !EnableIf->getCond()->EvaluateAsBooleanCondition(AlwaysTrue, Ctx))
11773 bool InOverloadResolution,
11777 if (InOverloadResolution)
11779 diag::note_addrof_ovl_candidate_disabled_by_enable_if_attr);
11781 S.
Diag(Loc, diag::err_addrof_function_disabled_by_enable_if_attr) << FD;
11792 if (InOverloadResolution) {
11795 TemplateArgString +=
" ";
11797 FunTmpl->getTemplateParameters(),
11802 diag::note_ovl_candidate_unsatisfied_constraints)
11803 << TemplateArgString;
11805 S.
Diag(Loc, diag::err_addrof_function_constraints_not_satisfied)
11814 return P->hasAttr<PassObjectSizeAttr>();
11821 unsigned ParamNo = std::distance(FD->
param_begin(), I) + 1;
11822 if (InOverloadResolution)
11824 diag::note_ovl_candidate_has_pass_object_size_params)
11827 S.
Diag(Loc, diag::err_address_of_function_with_pass_object_size_params)
11843 return ::checkAddressOfFunctionIsAvailable(*
this,
Function, Complain,
11851 const auto *ConvD = dyn_cast<CXXConversionDecl>(Fn);
11856 if (!RD->isLambda())
11861 CallOp->getType()->castAs<
FunctionType>()->getCallConv();
11866 return ConvToCC != CallOpCC;
11872 QualType DestType,
bool TakingAddress) {
11875 if (Fn->isMultiVersion() && Fn->hasAttr<TargetAttr>() &&
11876 !Fn->getAttr<TargetAttr>()->isDefaultVersion())
11878 if (Fn->isMultiVersion() && Fn->hasAttr<TargetVersionAttr>() &&
11879 !Fn->getAttr<TargetVersionAttr>()->isDefaultVersion())
11884 std::string FnDesc;
11885 std::pair<OverloadCandidateKind, OverloadCandidateSelect> KSPair =
11886 ClassifyOverloadCandidate(*
this,
Found, Fn, RewriteKind, FnDesc);
11888 << (
unsigned)KSPair.first << (
unsigned)KSPair.second
11892 Diag(Fn->getLocation(), PD);
11893 MaybeEmitInheritedConstructorNote(*
this,
Found);
11911 FunctionDecl *FirstCand =
nullptr, *SecondCand =
nullptr;
11912 for (
auto I = Cands.begin(), E = Cands.end(); I != E; ++I) {
11916 if (
auto *
Template = I->Function->getPrimaryTemplate())
11917 Template->getAssociatedConstraints(AC);
11919 I->Function->getAssociatedConstraints(AC);
11922 if (FirstCand ==
nullptr) {
11923 FirstCand = I->Function;
11925 }
else if (SecondCand ==
nullptr) {
11926 SecondCand = I->Function;
11939 SecondCand, SecondAC))
11948 bool TakingAddress) {
11958 dyn_cast<FunctionTemplateDecl>((*I)->getUnderlyingDecl()) ) {
11962 = dyn_cast<FunctionDecl>((*I)->getUnderlyingDecl()) ) {
11975 S.
Diag(CaretLoc, PDiag)
11977 unsigned CandsShown = 0;
11991 unsigned I,
bool TakingCandidateAddress) {
11993 assert(Conv.
isBad());
11994 assert(Cand->
Function &&
"for now, candidate must be a function");
12000 bool isObjectArgument =
false;
12004 isObjectArgument =
true;
12009 std::string FnDesc;
12010 std::pair<OverloadCandidateKind, OverloadCandidateSelect> FnKindPair =
12021 bool HasParamPack =
12022 llvm::any_of(Fn->parameters().take_front(I), [](
const ParmVarDecl *Parm) {
12023 return Parm->isParameterPack();
12025 if (!isObjectArgument && !HasParamPack && I < Fn->getNumParams())
12026 ToParamRange = Fn->getParamDecl(I)->getSourceRange();
12029 assert(FromExpr &&
"overload set argument came from implicit argument?");
12035 S.
Diag(Fn->getLocation(), diag::note_ovl_candidate_bad_overload)
12036 << (
unsigned)FnKindPair.first << (
unsigned)FnKindPair.second << FnDesc
12037 << ToParamRange << ToTy << Name << I + 1;
12038 MaybeEmitInheritedConstructorNote(S, Cand->
FoundDecl);
12047 CToTy = RT->getPointeeType();
12052 CFromTy = FromPT->getPointeeType();
12053 CToTy = ToPT->getPointeeType();
12063 if (isObjectArgument)
12064 S.
Diag(Fn->getLocation(), diag::note_ovl_candidate_bad_addrspace_this)
12065 << (
unsigned)FnKindPair.first << (
unsigned)FnKindPair.second
12068 S.
Diag(Fn->getLocation(), diag::note_ovl_candidate_bad_addrspace)
12069 << (
unsigned)FnKindPair.first << (
unsigned)FnKindPair.second
12072 MaybeEmitInheritedConstructorNote(S, Cand->
FoundDecl);
12077 S.
Diag(Fn->getLocation(), diag::note_ovl_candidate_bad_ownership)
12078 << (
unsigned)FnKindPair.first << (
unsigned)FnKindPair.second << FnDesc
12081 MaybeEmitInheritedConstructorNote(S, Cand->
FoundDecl);
12086 S.
Diag(Fn->getLocation(), diag::note_ovl_candidate_bad_gc)
12087 << (
unsigned)FnKindPair.first << (
unsigned)FnKindPair.second << FnDesc
12090 MaybeEmitInheritedConstructorNote(S, Cand->
FoundDecl);
12095 S.
Diag(Fn->getLocation(), diag::note_ovl_candidate_bad_ptrauth)
12096 << (
unsigned)FnKindPair.first << (
unsigned)FnKindPair.second << FnDesc
12101 MaybeEmitInheritedConstructorNote(S, Cand->
FoundDecl);
12106 assert(CVR &&
"expected qualifiers mismatch");
12108 if (isObjectArgument) {
12109 S.
Diag(Fn->getLocation(), diag::note_ovl_candidate_bad_cvr_this)
12110 << (
unsigned)FnKindPair.first << (
unsigned)FnKindPair.second << FnDesc
12111 << FromTy << (CVR - 1);
12113 S.
Diag(Fn->getLocation(), diag::note_ovl_candidate_bad_cvr)
12114 << (
unsigned)FnKindPair.first << (
unsigned)FnKindPair.second << FnDesc
12115 << ToParamRange << FromTy << (CVR - 1) << I + 1;
12117 MaybeEmitInheritedConstructorNote(S, Cand->
FoundDecl);
12123 S.
Diag(Fn->getLocation(), diag::note_ovl_candidate_bad_value_category)
12124 << (
unsigned)FnKindPair.first << (
unsigned)FnKindPair.second << FnDesc
12125 << (
unsigned)isObjectArgument << I + 1
12128 MaybeEmitInheritedConstructorNote(S, Cand->
FoundDecl);
12135 S.
Diag(Fn->getLocation(), diag::note_ovl_candidate_bad_list_argument)
12136 << (
unsigned)FnKindPair.first << (
unsigned)FnKindPair.second << FnDesc
12137 << ToParamRange << FromTy << ToTy << (
unsigned)isObjectArgument << I + 1
12142 MaybeEmitInheritedConstructorNote(S, Cand->
FoundDecl);
12154 S.
Diag(Fn->getLocation(), diag::note_ovl_candidate_bad_conv_incomplete)
12155 << (
unsigned)FnKindPair.first << (
unsigned)FnKindPair.second << FnDesc
12156 << ToParamRange << FromTy << ToTy << (
unsigned)isObjectArgument << I + 1
12157 << (
unsigned)(Cand->
Fix.
Kind);
12159 MaybeEmitInheritedConstructorNote(S, Cand->
FoundDecl);
12164 unsigned BaseToDerivedConversion = 0;
12167 if (ToPtrTy->getPointeeType().isAtLeastAsQualifiedAs(
12169 !FromPtrTy->getPointeeType()->isIncompleteType() &&
12170 !ToPtrTy->getPointeeType()->isIncompleteType() &&
12172 FromPtrTy->getPointeeType()))
12173 BaseToDerivedConversion = 1;
12181 if (ToPtrTy->getPointeeType().isAtLeastAsQualifiedAs(
12183 FromIface->isSuperClassOf(ToIface))
12184 BaseToDerivedConversion = 2;
12186 if (ToRefTy->getPointeeType().isAtLeastAsQualifiedAs(FromTy,
12189 !ToRefTy->getPointeeType()->isIncompleteType() &&
12191 BaseToDerivedConversion = 3;
12195 if (BaseToDerivedConversion) {
12196 S.
Diag(Fn->getLocation(), diag::note_ovl_candidate_bad_base_to_derived_conv)
12197 << (
unsigned)FnKindPair.first << (
unsigned)FnKindPair.second << FnDesc
12198 << ToParamRange << (BaseToDerivedConversion - 1) << FromTy << ToTy
12200 MaybeEmitInheritedConstructorNote(S, Cand->
FoundDecl);
12209 S.
Diag(Fn->getLocation(), diag::note_ovl_candidate_bad_arc_conv)
12210 << (
unsigned)FnKindPair.first << (
unsigned)FnKindPair.second << FnDesc
12211 << ToParamRange << FromTy << ToTy << (
unsigned)isObjectArgument
12213 MaybeEmitInheritedConstructorNote(S, Cand->
FoundDecl);
12223 FDiag << (
unsigned)FnKindPair.first << (
unsigned)FnKindPair.second << FnDesc
12224 << ToParamRange << FromTy << ToTy << (
unsigned)isObjectArgument << I + 1
12225 << (
unsigned)(Cand->
Fix.
Kind);
12234 S.
Diag(Fn->getLocation(), FDiag);
12236 MaybeEmitInheritedConstructorNote(S, Cand->
FoundDecl);
12243 unsigned NumArgs,
bool IsAddressOf =
false) {
12244 assert(Cand->
Function &&
"Candidate is required to be a function.");
12246 unsigned MinParams = Fn->getMinRequiredExplicitArguments() +
12247 ((IsAddressOf && !Fn->isStatic()) ? 1 : 0);
12254 if (Fn->isInvalidDecl() &&
12258 if (NumArgs < MinParams) {
12275 unsigned NumFormalArgs,
12276 bool IsAddressOf =
false) {
12278 "The templated declaration should at least be a function"
12279 " when diagnosing bad template argument deduction due to too many"
12280 " or too few arguments");
12286 unsigned MinParams = Fn->getMinRequiredExplicitArguments() +
12287 ((IsAddressOf && !Fn->isStatic()) ? 1 : 0);
12290 bool HasExplicitObjectParam =
12291 !IsAddressOf && Fn->hasCXXExplicitFunctionObjectParameter();
12293 unsigned ParamCount =
12294 Fn->getNumNonObjectParams() + ((IsAddressOf && !Fn->isStatic()) ? 1 : 0);
12295 unsigned mode, modeCount;
12297 if (NumFormalArgs < MinParams) {
12298 if (MinParams != ParamCount || FnTy->isVariadic() ||
12299 FnTy->isTemplateVariadic())
12303 modeCount = MinParams;
12305 if (MinParams != ParamCount)
12309 modeCount = ParamCount;
12312 std::string Description;
12313 std::pair<OverloadCandidateKind, OverloadCandidateSelect> FnKindPair =
12314 ClassifyOverloadCandidate(S,
Found, Fn,
CRK_None, Description);
12316 unsigned FirstNonObjectParamIdx = HasExplicitObjectParam ? 1 : 0;
12317 if (modeCount == 1 && !IsAddressOf &&
12318 FirstNonObjectParamIdx < Fn->getNumParams() &&
12319 Fn->getParamDecl(FirstNonObjectParamIdx)->getDeclName())
12320 S.
Diag(Fn->getLocation(), diag::note_ovl_candidate_arity_one)
12321 << (
unsigned)FnKindPair.first << (
unsigned)FnKindPair.second
12322 << Description << mode << Fn->getParamDecl(FirstNonObjectParamIdx)
12323 << NumFormalArgs << HasExplicitObjectParam
12324 << Fn->getParametersSourceRange();
12326 S.
Diag(Fn->getLocation(), diag::note_ovl_candidate_arity)
12327 << (
unsigned)FnKindPair.first << (
unsigned)FnKindPair.second
12328 << Description << mode << modeCount << NumFormalArgs
12329 << HasExplicitObjectParam << Fn->getParametersSourceRange();
12331 MaybeEmitInheritedConstructorNote(S,
Found);
12336 unsigned NumFormalArgs) {
12337 assert(Cand->
Function &&
"Candidate must be a function");
12347 llvm_unreachable(
"Unsupported: Getting the described template declaration"
12348 " for bad deduction diagnosis");
12355 bool TakingCandidateAddress) {
12361 switch (DeductionFailure.
getResult()) {
12364 "TemplateDeductionResult::Success while diagnosing bad deduction");
12366 llvm_unreachable(
"TemplateDeductionResult::NonDependentConversionFailure "
12367 "while diagnosing bad deduction");
12373 assert(ParamD &&
"no parameter found for incomplete deduction result");
12375 diag::note_ovl_candidate_incomplete_deduction)
12377 MaybeEmitInheritedConstructorNote(S,
Found);
12382 assert(ParamD &&
"no parameter found for incomplete deduction result");
12384 diag::note_ovl_candidate_incomplete_deduction_pack)
12386 << (DeductionFailure.
getFirstArg()->pack_size() + 1)
12388 MaybeEmitInheritedConstructorNote(S,
Found);
12393 assert(ParamD &&
"no parameter found for bad qualifiers deduction result");
12411 S.
Diag(Templated->
getLocation(), diag::note_ovl_candidate_underqualified)
12412 << ParamD->
getDeclName() << Arg << NonCanonParam;
12413 MaybeEmitInheritedConstructorNote(S,
Found);
12418 assert(ParamD &&
"no parameter found for inconsistent deduction result");
12432 diag::note_ovl_candidate_inconsistent_deduction_types)
12435 MaybeEmitInheritedConstructorNote(S,
Found);
12455 diag::note_ovl_candidate_inconsistent_deduction)
12458 MaybeEmitInheritedConstructorNote(S,
Found);
12463 assert(ParamD &&
"no parameter found for invalid explicit arguments");
12466 diag::note_ovl_candidate_explicit_arg_mismatch_named)
12471 index = TTP->getIndex();
12473 = dyn_cast<NonTypeTemplateParmDecl>(ParamD))
12474 index = NTTP->getIndex();
12478 diag::note_ovl_candidate_explicit_arg_mismatch_unnamed)
12481 MaybeEmitInheritedConstructorNote(S,
Found);
12488 TemplateArgString =
" ";
12491 if (TemplateArgString.size() == 1)
12492 TemplateArgString.clear();
12494 diag::note_ovl_candidate_unsatisfied_constraints)
12495 << TemplateArgString;
12498 static_cast<CNSInfo*
>(DeductionFailure.
Data)->Satisfaction);
12508 diag::note_ovl_candidate_instantiation_depth);
12509 MaybeEmitInheritedConstructorNote(S,
Found);
12517 TemplateArgString =
" ";
12520 if (TemplateArgString.size() == 1)
12521 TemplateArgString.clear();
12526 if (PDiag && PDiag->second.getDiagID() ==
12527 diag::err_typename_nested_not_found_enable_if) {
12530 S.
Diag(PDiag->first, diag::note_ovl_candidate_disabled_by_enable_if)
12531 <<
"'enable_if'" << TemplateArgString;
12536 if (PDiag && PDiag->second.getDiagID() ==
12537 diag::err_typename_nested_not_found_requirement) {
12539 diag::note_ovl_candidate_disabled_by_requirement)
12540 << PDiag->second.getStringArg(0) << TemplateArgString;
12550 SFINAEArgString =
": ";
12552 PDiag->second.EmitToString(S.
getDiagnostics(), SFINAEArgString);
12556 diag::note_ovl_candidate_substitution_failure)
12557 << TemplateArgString << SFINAEArgString << R;
12558 MaybeEmitInheritedConstructorNote(S,
Found);
12568 TemplateArgString =
" ";
12571 if (TemplateArgString.size() == 1)
12572 TemplateArgString.clear();
12575 S.
Diag(Templated->
getLocation(), diag::note_ovl_candidate_deduced_mismatch)
12578 << TemplateArgString
12603 diag::note_ovl_candidate_non_deduced_mismatch_qualified)
12619 diag::note_ovl_candidate_non_deduced_mismatch)
12620 << FirstTA << SecondTA;
12626 S.
Diag(Templated->
getLocation(), diag::note_ovl_candidate_bad_deduction);
12627 MaybeEmitInheritedConstructorNote(S,
Found);
12631 diag::note_cuda_ovl_candidate_target_mismatch);
12639 bool TakingCandidateAddress) {
12640 assert(Cand->
Function &&
"Candidate must be a function");
12655 assert(Cand->
Function &&
"Candidate must be a Function.");
12661 std::string FnDesc;
12662 std::pair<OverloadCandidateKind, OverloadCandidateSelect> FnKindPair =
12663 ClassifyOverloadCandidate(S, Cand->
FoundDecl, Callee,
12666 S.
Diag(Callee->getLocation(), diag::note_ovl_candidate_bad_target)
12667 << (
unsigned)FnKindPair.first << (
unsigned)ocs_non_template
12669 << CalleeTarget << CallerTarget;
12674 if (Meth !=
nullptr && Meth->
isImplicit()) {
12678 switch (FnKindPair.first) {
12681 case oc_implicit_default_constructor:
12684 case oc_implicit_copy_constructor:
12687 case oc_implicit_move_constructor:
12690 case oc_implicit_copy_assignment:
12693 case oc_implicit_move_assignment:
12698 bool ConstRHS =
false;
12702 ConstRHS = RT->getPointeeType().isConstQualified();
12713 assert(Cand->
Function &&
"Candidate must be a function");
12717 S.
Diag(Callee->getLocation(),
12718 diag::note_ovl_candidate_disabled_by_function_cond_attr)
12719 <<
Attr->getCond()->getSourceRange() <<
Attr->getMessage();
12723 assert(Cand->
Function &&
"Candidate must be a function");
12726 assert(ES.
isExplicit() &&
"not an explicit candidate");
12729 switch (Fn->getDeclKind()) {
12730 case Decl::Kind::CXXConstructor:
12733 case Decl::Kind::CXXConversion:
12736 case Decl::Kind::CXXDeductionGuide:
12737 Kind = Fn->isImplicit() ? 0 : 2;
12740 llvm_unreachable(
"invalid Decl");
12749 First = Pattern->getFirstDecl();
12752 diag::note_ovl_candidate_explicit)
12753 << Kind << (ES.
getExpr() ? 1 : 0)
12758 auto *DG = dyn_cast<CXXDeductionGuideDecl>(Fn);
12765 if (!(DG->isImplicit() || (OriginTemplate && OriginTemplate->
isTypeAlias())))
12767 std::string FunctionProto;
12768 llvm::raw_string_ostream OS(FunctionProto);
12781 "Non-template implicit deduction guides are only possible for "
12784 S.
Diag(DG->getLocation(), diag::note_implicit_deduction_guide)
12789 assert(
Template &&
"Cannot find the associated function template of "
12790 "CXXDeductionGuideDecl?");
12793 S.
Diag(DG->getLocation(), diag::note_implicit_deduction_guide)
12814 bool TakingCandidateAddress,
12816 assert(Cand->
Function &&
"Candidate must be a function");
12824 if (S.
getLangOpts().OpenCL && Fn->isImplicit() &&
12831 !Fn->hasCXXExplicitFunctionObjectParameter() && !Fn->isStatic())
12836 if (Fn->isDeleted()) {
12837 std::string FnDesc;
12838 std::pair<OverloadCandidateKind, OverloadCandidateSelect> FnKindPair =
12839 ClassifyOverloadCandidate(S, Cand->
FoundDecl, Fn,
12842 S.
Diag(Fn->getLocation(), diag::note_ovl_candidate_deleted)
12843 << (
unsigned)FnKindPair.first << (
unsigned)FnKindPair.second << FnDesc
12844 << (Fn->isDeleted()
12845 ? (Fn->getCanonicalDecl()->isDeletedAsWritten() ? 1 : 2)
12847 MaybeEmitInheritedConstructorNote(S, Cand->
FoundDecl);
12874 TakingCandidateAddress);
12877 S.
Diag(Fn->getLocation(), diag::note_ovl_candidate_illegal_constructor)
12878 << (Fn->getPrimaryTemplate() ? 1 : 0);
12879 MaybeEmitInheritedConstructorNote(S, Cand->
FoundDecl);
12886 S.
Diag(Fn->getLocation(),
12887 diag::note_ovl_candidate_illegal_constructor_adrspace_mismatch)
12888 << QualsForPrinting;
12889 MaybeEmitInheritedConstructorNote(S, Cand->
FoundDecl);
12900 for (
unsigned N = Cand->
Conversions.size(); I != N; ++I)
12923 S.
Diag(Fn->getLocation(),
12924 diag::note_ovl_candidate_inherited_constructor_slice)
12925 << (Fn->getPrimaryTemplate() ? 1 : 0)
12926 << Fn->getParamDecl(0)->getType()->isRValueReferenceType();
12927 MaybeEmitInheritedConstructorNote(S, Cand->
FoundDecl);
12933 assert(!Available);
12941 std::string FnDesc;
12942 std::pair<OverloadCandidateKind, OverloadCandidateSelect> FnKindPair =
12943 ClassifyOverloadCandidate(S, Cand->
FoundDecl, Fn,
12946 S.
Diag(Fn->getLocation(),
12947 diag::note_ovl_candidate_constraints_not_satisfied)
12948 << (
unsigned)FnKindPair.first << (
unsigned)ocs_non_template
12967 bool isLValueReference =
false;
12968 bool isRValueReference =
false;
12969 bool isPointer =
false;
12973 isLValueReference =
true;
12977 isRValueReference =
true;
12993 diag::note_ovl_surrogate_constraints_not_satisfied)
13007 assert(Cand->
Conversions.size() <= 2 &&
"builtin operator is not binary");
13008 std::string TypeStr(
"operator");
13014 S.
Diag(OpLoc, diag::note_ovl_builtin_candidate) << TypeStr;
13019 S.
Diag(OpLoc, diag::note_ovl_builtin_candidate) << TypeStr;
13026 if (ICS.
isBad())
break;
13030 S, OpLoc, S.
PDiag(diag::note_ambiguous_type_conversion));
13047 llvm_unreachable(
"non-deduction failure while diagnosing bad deduction");
13077 llvm_unreachable(
"Unhandled deduction result");
13082struct CompareOverloadCandidatesForDisplay {
13084 SourceLocation Loc;
13088 CompareOverloadCandidatesForDisplay(
13089 Sema &S, SourceLocation Loc,
size_t NArgs,
13091 : S(S), NumArgs(NArgs), CSK(CSK) {}
13101 if (NumArgs >
C->Function->getNumParams() && !
C->Function->isVariadic())
13103 if (NumArgs < C->
Function->getMinRequiredArguments())
13110 bool operator()(
const OverloadCandidate *L,
13111 const OverloadCandidate *R) {
13113 if (L == R)
return false;
13117 if (!
R->Viable)
return true;
13119 if (
int Ord = CompareConversions(*L, *R))
13122 }
else if (
R->Viable)
13125 assert(L->
Viable ==
R->Viable);
13138 int RDist =
std::abs((
int)
R->getNumParams() - (
int)NumArgs);
13139 if (LDist == RDist) {
13140 if (LFailureKind == RFailureKind)
13148 return LDist < RDist;
13165 unsigned numRFixes =
R->Fix.NumConversionsFixed;
13166 numLFixes = (numLFixes == 0) ?
UINT_MAX : numLFixes;
13167 numRFixes = (numRFixes == 0) ?
UINT_MAX : numRFixes;
13168 if (numLFixes != numRFixes) {
13169 return numLFixes < numRFixes;
13173 if (
int Ord = CompareConversions(*L, *R))
13185 if (LRank != RRank)
13186 return LRank < RRank;
13212 struct ConversionSignals {
13213 unsigned KindRank = 0;
13216 static ConversionSignals ForSequence(ImplicitConversionSequence &
Seq) {
13217 ConversionSignals Sig;
13218 Sig.KindRank =
Seq.getKindRank();
13219 if (
Seq.isStandard())
13220 Sig.Rank =
Seq.Standard.getRank();
13221 else if (
Seq.isUserDefined())
13222 Sig.Rank =
Seq.UserDefined.After.getRank();
13228 static ConversionSignals ForObjectArgument() {
13238 int CompareConversions(
const OverloadCandidate &L,
13239 const OverloadCandidate &R) {
13244 for (
unsigned I = 0, N = L.
Conversions.size(); I != N; ++I) {
13246 ? ConversionSignals::ForObjectArgument()
13247 : ConversionSignals::ForSequence(L.Conversions[I]);
13248 auto RS =
R.IgnoreObjectArgument
13249 ? ConversionSignals::ForObjectArgument()
13250 : ConversionSignals::ForSequence(
R.Conversions[I]);
13251 if (std::tie(LS.KindRank, LS.Rank) != std::tie(RS.KindRank, RS.Rank))
13252 return std::tie(LS.KindRank, LS.Rank) < std::tie(RS.KindRank, RS.Rank)
13277 bool Unfixable =
false;
13283 for (
unsigned ConvIdx =
13287 assert(ConvIdx != ConvCount &&
"no bad conversion in candidate");
13288 if (Cand->
Conversions[ConvIdx].isInitialized() &&
13297 bool SuppressUserConversions =
false;
13299 unsigned ConvIdx = 0;
13300 unsigned ArgIdx = 0;
13329 assert(ConvCount <= 3);
13335 ConvIdx != ConvCount && ArgIdx < Args.size();
13337 if (Cand->
Conversions[ConvIdx].isInitialized()) {
13339 }
else if (
ParamIdx < ParamTypes.size()) {
13340 if (ParamTypes[
ParamIdx]->isDependentType())
13341 Cand->
Conversions[ConvIdx].setAsIdentityConversion(
13346 SuppressUserConversions,
13351 if (!Unfixable && Cand->
Conversions[ConvIdx].isBad())
13370 for (
iterator Cand = Candidates.begin(), LastCand = Candidates.end();
13371 Cand != LastCand; ++Cand) {
13372 if (!Filter(*Cand))
13397 Cands.push_back(Cand);
13401 Cands, CompareOverloadCandidatesForDisplay(S, OpLoc, Args.size(), Kind));
13408 bool DeferHint =
false;
13412 auto WrongSidedCands =
13414 return (Cand.
Viable ==
false &&
13420 DeferHint = !WrongSidedCands.empty();
13436 S.
Diag(PD.first, PD.second);
13441 bool NoteCands =
true;
13442 for (
const Expr *Arg : Args) {
13443 if (Arg->getType()->isWebAssemblyTableType())
13452 {Candidates.begin(), Candidates.end()});
13458 bool ReportedAmbiguousConversions =
false;
13461 unsigned CandsShown = 0;
13462 auto I = Cands.begin(), E = Cands.end();
13463 for (; I != E; ++I) {
13479 "Non-viable built-in candidates are not added to Cands.");
13486 if (!ReportedAmbiguousConversions) {
13488 ReportedAmbiguousConversions =
true;
13502 S.
Diag(OpLoc, diag::note_ovl_too_many_candidates) <<
int(E - I);
13513struct CompareTemplateSpecCandidatesForDisplay {
13515 CompareTemplateSpecCandidatesForDisplay(Sema &S) : S(S) {}
13517 bool operator()(
const TemplateSpecCandidate *L,
13518 const TemplateSpecCandidate *R) {
13549 bool ForTakingAddress) {
13554void TemplateSpecCandidateSet::destroyCandidates() {
13556 i->DeductionFailure.Destroy();
13561 destroyCandidates();
13562 Candidates.clear();
13575 Cands.reserve(
size());
13576 for (
iterator Cand =
begin(), LastCand =
end(); Cand != LastCand; ++Cand) {
13577 if (Cand->Specialization)
13578 Cands.push_back(Cand);
13583 llvm::sort(Cands, CompareTemplateSpecCandidatesForDisplay(S));
13590 unsigned CandsShown = 0;
13591 for (I = Cands.begin(), E = Cands.end(); I != E; ++I) {
13597 if (CandsShown >= 4 && ShowOverloads ==
Ovl_Best)
13602 "Non-matching built-in candidates are not added to Cands.");
13607 S.
Diag(Loc, diag::note_ovl_too_many_candidates) <<
int(E - I);
13617 QualType Ret = PossiblyAFunctionType;
13620 Ret = ToTypePtr->getPointeeType();
13623 Ret = ToTypeRef->getPointeeType();
13626 Ret = MemTypePtr->getPointeeType();
13628 Context.getCanonicalType(Ret).getUnqualifiedType();
13633 bool Complain =
true) {
13650class AddressOfFunctionResolver {
13653 const QualType& TargetType;
13654 QualType TargetFunctionType;
13658 ASTContext& Context;
13660 bool TargetTypeIsNonStaticMemberFunction;
13661 bool FoundNonTemplateFunction;
13662 bool StaticMemberFunctionFromBoundPointer;
13663 bool HasComplained;
13665 OverloadExpr::FindResult OvlExprInfo;
13666 OverloadExpr *OvlExpr;
13667 TemplateArgumentListInfo OvlExplicitTemplateArgs;
13668 SmallVector<std::pair<DeclAccessPair, FunctionDecl*>, 4> Matches;
13669 TemplateSpecCandidateSet FailedCandidates;
13672 AddressOfFunctionResolver(Sema &S, Expr *SourceExpr,
13673 const QualType &TargetType,
bool Complain)
13674 : S(S), SourceExpr(SourceExpr), TargetType(TargetType),
13675 Complain(Complain), Context(S.getASTContext()),
13676 TargetTypeIsNonStaticMemberFunction(
13677 !!TargetType->getAs<MemberPointerType>()),
13678 FoundNonTemplateFunction(
false),
13679 StaticMemberFunctionFromBoundPointer(
false),
13680 HasComplained(
false),
13681 OvlExprInfo(OverloadExpr::find(SourceExpr)),
13683 FailedCandidates(OvlExpr->getNameLoc(),
true) {
13684 ExtractUnqualifiedFunctionTypeFromTargetType();
13687 if (UnresolvedMemberExpr *UME = dyn_cast<UnresolvedMemberExpr>(OvlExpr))
13688 if (!UME->isImplicitAccess() &&
13690 StaticMemberFunctionFromBoundPointer =
true;
13692 DeclAccessPair dap;
13694 OvlExpr,
false, &dap)) {
13695 if (CXXMethodDecl *
Method = dyn_cast<CXXMethodDecl>(Fn))
13696 if (!
Method->isStatic()) {
13700 TargetTypeIsNonStaticMemberFunction =
true;
13708 Matches.push_back(std::make_pair(dap, Fn));
13716 if (FindAllFunctionsThatMatchTargetTypeExactly()) {
13719 if (Matches.size() > 1 && !eliminiateSuboptimalOverloadCandidates()) {
13720 if (FoundNonTemplateFunction) {
13721 EliminateAllTemplateMatches();
13722 EliminateLessPartialOrderingConstrainedMatches();
13724 EliminateAllExceptMostSpecializedTemplate();
13729 EliminateSuboptimalCudaMatches();
13732 bool hasComplained()
const {
return HasComplained; }
13735 bool candidateHasExactlyCorrectType(
const FunctionDecl *FD) {
13742 bool isBetterCandidate(
const FunctionDecl *A,
const FunctionDecl *B) {
13746 return candidateHasExactlyCorrectType(A) &&
13747 (!candidateHasExactlyCorrectType(B) ||
13753 bool eliminiateSuboptimalOverloadCandidates() {
13756 auto Best = Matches.begin();
13757 for (
auto I = Matches.begin()+1, E = Matches.end(); I != E; ++I)
13758 if (isBetterCandidate(I->second, Best->second))
13761 const FunctionDecl *BestFn = Best->second;
13762 auto IsBestOrInferiorToBest = [
this, BestFn](
13763 const std::pair<DeclAccessPair, FunctionDecl *> &Pair) {
13764 return BestFn == Pair.second || isBetterCandidate(BestFn, Pair.second);
13769 if (!llvm::all_of(Matches, IsBestOrInferiorToBest))
13771 Matches[0] = *Best;
13776 bool isTargetTypeAFunction()
const {
13785 void inline ExtractUnqualifiedFunctionTypeFromTargetType() {
13791 const DeclAccessPair& CurAccessFunPair) {
13792 if (CXXMethodDecl *
Method
13796 bool CanConvertToFunctionPointer =
13797 Method->isStatic() ||
Method->isExplicitObjectMemberFunction();
13798 if (CanConvertToFunctionPointer == TargetTypeIsNonStaticMemberFunction)
13801 else if (TargetTypeIsNonStaticMemberFunction)
13811 TemplateDeductionInfo Info(FailedCandidates.
getLocation());
13815 Result != TemplateDeductionResult::Success) {
13833 Matches.push_back(std::make_pair(CurAccessFunPair,
Specialization));
13837 bool AddMatchingNonTemplateFunction(NamedDecl* Fn,
13838 const DeclAccessPair& CurAccessFunPair) {
13839 if (CXXMethodDecl *
Method = dyn_cast<CXXMethodDecl>(Fn)) {
13842 bool CanConvertToFunctionPointer =
13843 Method->isStatic() ||
Method->isExplicitObjectMemberFunction();
13844 if (CanConvertToFunctionPointer == TargetTypeIsNonStaticMemberFunction)
13847 else if (TargetTypeIsNonStaticMemberFunction)
13850 if (FunctionDecl *FunDecl = dyn_cast<FunctionDecl>(Fn)) {
13857 if (FunDecl->isMultiVersion()) {
13858 const auto *TA = FunDecl->getAttr<TargetAttr>();
13859 if (TA && !TA->isDefaultVersion())
13861 const auto *TVA = FunDecl->getAttr<TargetVersionAttr>();
13862 if (TVA && !TVA->isDefaultVersion())
13870 HasComplained |= Complain;
13879 candidateHasExactlyCorrectType(FunDecl)) {
13880 Matches.push_back(std::make_pair(
13882 FoundNonTemplateFunction =
true;
13890 bool FindAllFunctionsThatMatchTargetTypeExactly() {
13895 if (IsInvalidFormOfPointerToMemberFunction())
13898 for (UnresolvedSetIterator I = OvlExpr->
decls_begin(),
13902 NamedDecl *
Fn = (*I)->getUnderlyingDecl();
13911 = dyn_cast<FunctionTemplateDecl>(Fn)) {
13917 AddMatchingNonTemplateFunction(Fn, I.getPair()))
13920 assert(Ret || Matches.empty());
13924 void EliminateAllExceptMostSpecializedTemplate() {
13936 UnresolvedSet<4> MatchesCopy;
13937 for (
unsigned I = 0, E = Matches.size(); I != E; ++I)
13938 MatchesCopy.
addDecl(Matches[I].second, Matches[I].first.getAccess());
13943 MatchesCopy.
begin(), MatchesCopy.
end(), FailedCandidates,
13945 S.
PDiag(diag::err_addr_ovl_ambiguous)
13946 << Matches[0].second->getDeclName(),
13947 S.
PDiag(diag::note_ovl_candidate)
13948 << (
unsigned)oc_function << (
unsigned)ocs_described_template,
13949 Complain, TargetFunctionType);
13953 Matches[0].first = Matches[
Result - MatchesCopy.
begin()].first;
13957 HasComplained |= Complain;
13960 void EliminateAllTemplateMatches() {
13963 for (
unsigned I = 0, N = Matches.size(); I != N; ) {
13964 if (Matches[I].second->getPrimaryTemplate() ==
nullptr)
13967 Matches[I] = Matches[--N];
13973 void EliminateLessPartialOrderingConstrainedMatches() {
13978 assert(Matches[0].second->getPrimaryTemplate() ==
nullptr &&
13979 "Call EliminateAllTemplateMatches() first");
13980 SmallVector<std::pair<DeclAccessPair, FunctionDecl *>, 4> Results;
13981 Results.push_back(Matches[0]);
13982 for (
unsigned I = 1, N = Matches.size(); I < N; ++I) {
13983 assert(Matches[I].second->getPrimaryTemplate() ==
nullptr);
13985 S, Matches[I].second, Results[0].second,
13989 Results.push_back(Matches[I]);
13992 if (F == Matches[I].second) {
13994 Results.push_back(Matches[I]);
13997 std::swap(Matches, Results);
14000 void EliminateSuboptimalCudaMatches() {
14006 void ComplainNoMatchesFound()
const {
14007 assert(Matches.empty());
14009 << OvlExpr->
getName() << TargetFunctionType
14011 if (FailedCandidates.
empty())
14018 for (UnresolvedSetIterator I = OvlExpr->
decls_begin(),
14021 if (FunctionDecl *Fun =
14022 dyn_cast<FunctionDecl>((*I)->getUnderlyingDecl()))
14030 bool IsInvalidFormOfPointerToMemberFunction()
const {
14031 return TargetTypeIsNonStaticMemberFunction &&
14035 void ComplainIsInvalidFormOfPointerToMemberFunction()
const {
14043 bool IsStaticMemberFunctionFromBoundPointer()
const {
14044 return StaticMemberFunctionFromBoundPointer;
14047 void ComplainIsStaticMemberFunctionFromBoundPointer()
const {
14049 diag::err_invalid_form_pointer_member_function)
14053 void ComplainOfInvalidConversion()
const {
14055 << OvlExpr->
getName() << TargetType;
14058 void ComplainMultipleMatchesFound()
const {
14059 assert(Matches.size() > 1);
14066 bool hadMultipleCandidates()
const {
return (OvlExpr->
getNumDecls() > 1); }
14068 int getNumMatches()
const {
return Matches.size(); }
14070 FunctionDecl* getMatchingFunctionDecl()
const {
14071 if (Matches.size() != 1)
return nullptr;
14072 return Matches[0].second;
14075 const DeclAccessPair* getMatchingFunctionAccessPair()
const {
14076 if (Matches.size() != 1)
return nullptr;
14077 return &Matches[0].first;
14087 bool *pHadMultipleCandidates) {
14090 AddressOfFunctionResolver Resolver(*
this, AddressOfExpr, TargetType,
14092 int NumMatches = Resolver.getNumMatches();
14094 bool ShouldComplain = Complain && !Resolver.hasComplained();
14095 if (NumMatches == 0 && ShouldComplain) {
14096 if (Resolver.IsInvalidFormOfPointerToMemberFunction())
14097 Resolver.ComplainIsInvalidFormOfPointerToMemberFunction();
14099 Resolver.ComplainNoMatchesFound();
14101 else if (NumMatches > 1 && ShouldComplain)
14102 Resolver.ComplainMultipleMatchesFound();
14103 else if (NumMatches == 1) {
14104 Fn = Resolver.getMatchingFunctionDecl();
14108 FoundResult = *Resolver.getMatchingFunctionAccessPair();
14110 if (Resolver.IsStaticMemberFunctionFromBoundPointer())
14111 Resolver.ComplainIsStaticMemberFunctionFromBoundPointer();
14117 if (pHadMultipleCandidates)
14118 *pHadMultipleCandidates = Resolver.hadMultipleCandidates();
14126 bool IsResultAmbiguous =
false;
14134 return static_cast<int>(
CUDA().IdentifyPreference(Caller, FD1)) -
14135 static_cast<int>(
CUDA().IdentifyPreference(Caller, FD2));
14142 auto *FD = dyn_cast<FunctionDecl>(I->getUnderlyingDecl());
14150 auto FoundBetter = [&]() {
14151 IsResultAmbiguous =
false;
14163 int PreferenceByCUDA = CheckCUDAPreference(FD,
Result);
14165 if (PreferenceByCUDA != 0) {
14167 if (PreferenceByCUDA > 0)
14183 if (MoreConstrained != FD) {
14184 if (!MoreConstrained) {
14185 IsResultAmbiguous =
true;
14186 AmbiguousDecls.push_back(FD);
14195 if (IsResultAmbiguous)
14216 ExprResult &SrcExpr,
bool DoFunctionPointerConversion) {
14218 assert(E->
getType() ==
Context.OverloadTy &&
"SrcExpr must be an overload");
14222 if (!
Found ||
Found->isCPUDispatchMultiVersion() ||
14223 Found->isCPUSpecificMultiVersion())
14271 dyn_cast<FunctionTemplateDecl>((*I)->getUnderlyingDecl());
14302 if (ForTypeDeduction &&
14316 if (FoundResult) *FoundResult = I.getPair();
14327 ExprResult &SrcExpr,
bool doFunctionPointerConversion,
bool complain,
14329 unsigned DiagIDForComplaining) {
14350 if (!complain)
return false;
14353 diag::err_bound_member_function)
14366 SingleFunctionExpression =
14370 if (doFunctionPointerConversion) {
14371 SingleFunctionExpression =
14373 if (SingleFunctionExpression.
isInvalid()) {
14380 if (!SingleFunctionExpression.
isUsable()) {
14382 Diag(OpRangeForComplaining.
getBegin(), DiagIDForComplaining)
14384 << DestTypeForComplaining
14385 << OpRangeForComplaining
14396 SrcExpr = SingleFunctionExpression;
14406 bool PartialOverloading,
14413 if (ExplicitTemplateArgs) {
14414 assert(!KnownValid &&
"Explicit template arguments?");
14423 PartialOverloading);
14428 = dyn_cast<FunctionTemplateDecl>(Callee)) {
14430 ExplicitTemplateArgs, Args, CandidateSet,
14432 PartialOverloading);
14436 assert(!KnownValid &&
"unhandled case in overloaded call candidate");
14442 bool PartialOverloading) {
14465 assert(!(*I)->getDeclContext()->isRecord());
14467 !(*I)->getDeclContext()->isFunctionOrMethod());
14468 assert((*I)->getUnderlyingDecl()->isFunctionOrFunctionTemplate());
14478 ExplicitTemplateArgs = &TABuffer;
14484 CandidateSet, PartialOverloading,
14489 Args, ExplicitTemplateArgs,
14490 CandidateSet, PartialOverloading);
14498 CandidateSet,
false,
false);
14505 case OO_New:
case OO_Array_New:
14506 case OO_Delete:
case OO_Array_Delete:
14529 if (DC->isTransparentContext())
14535 R.suppressDiagnostics();
14545 if (
auto *RD = dyn_cast<CXXRecordDecl>(DC)) {
14550 if (FoundInClass) {
14551 *FoundInClass = RD;
14554 R.addDecl(Best->FoundDecl.getDecl(), Best->FoundDecl.getAccess());
14571 AssociatedNamespaces,
14572 AssociatedClasses);
14576 for (Sema::AssociatedNamespaceSet::iterator
14577 it = AssociatedNamespaces.begin(),
14578 end = AssociatedNamespaces.end(); it !=
end; ++it) {
14590 SuggestedNamespaces.insert(*it);
14594 SemaRef.
Diag(R.getNameLoc(), diag::err_not_found_by_two_phase_lookup)
14595 << R.getLookupName();
14596 if (SuggestedNamespaces.empty()) {
14597 SemaRef.
Diag(Best->Function->getLocation(),
14598 diag::note_not_found_by_two_phase_lookup)
14599 << R.getLookupName() << 0;
14600 }
else if (SuggestedNamespaces.size() == 1) {
14601 SemaRef.
Diag(Best->Function->getLocation(),
14602 diag::note_not_found_by_two_phase_lookup)
14603 << R.getLookupName() << 1 << *SuggestedNamespaces.begin();
14608 SemaRef.
Diag(Best->Function->getLocation(),
14609 diag::note_not_found_by_two_phase_lookup)
14610 << R.getLookupName() << 2;
14641class BuildRecoveryCallExprRAII {
14643 Sema::SatisfactionStackResetRAII SatStack;
14646 BuildRecoveryCallExprRAII(Sema &S) : SemaRef(S), SatStack(S) {
14668 bool EmptyLookup,
bool AllowTypoCorrection) {
14676 BuildRecoveryCallExprRAII RCE(SemaRef);
14686 ExplicitTemplateArgs = &TABuffer;
14694 ExplicitTemplateArgs, Args, &FoundInClass)) {
14696 }
else if (EmptyLookup) {
14701 ExplicitTemplateArgs !=
nullptr,
14702 dyn_cast<MemberExpr>(Fn));
14704 AllowTypoCorrection
14710 }
else if (FoundInClass && SemaRef.
getLangOpts().MSVCCompat) {
14725 assert(!R.empty() &&
"lookup results empty despite recovery");
14728 if (R.isAmbiguous()) {
14729 R.suppressDiagnostics();
14736 if ((*R.begin())->isCXXClassMember())
14738 ExplicitTemplateArgs, S);
14739 else if (ExplicitTemplateArgs || TemplateKWLoc.
isValid())
14741 ExplicitTemplateArgs);
14765 assert(!ULE->
getQualifier() &&
"qualified name with ADL");
14772 (F = dyn_cast<FunctionDecl>(*ULE->
decls_begin())) &&
14774 llvm_unreachable(
"performing ADL for builtin");
14781 UnbridgedCastsSet UnbridgedCasts;
14796 if (CandidateSet->
empty() ||
14812 if (CandidateSet->
empty())
14815 UnbridgedCasts.restore();
14822 std::optional<QualType> Result;
14834 else if (Result != T)
14842 if (Best && *Best != CS.
end())
14843 ConsiderCandidate(**Best);
14846 for (
const auto &
C : CS)
14848 ConsiderCandidate(
C);
14851 for (
const auto &
C : CS)
14852 ConsiderCandidate(
C);
14856 auto Value = *Result;
14857 if (
Value.isNull() ||
Value->isUndeducedType())
14874 bool AllowTypoCorrection) {
14875 switch (OverloadResult) {
14886 Res.
get(), FDecl, LParenLoc, Args, RParenLoc, ExecConfig,
14892 if (*Best != CandidateSet->
end() &&
14896 dyn_cast_if_present<CXXMethodDecl>((*Best)->Function);
14901 SemaRef.
PDiag(diag::err_member_call_without_object) << 0 << M),
14911 CandidateSet->
empty(),
14912 AllowTypoCorrection);
14919 for (
const Expr *Arg : Args) {
14920 if (!Arg->getType()->isFunctionType())
14922 if (
auto *DRE = dyn_cast<DeclRefExpr>(Arg->IgnoreParenImpCasts())) {
14923 auto *FD = dyn_cast<FunctionDecl>(DRE->getDecl());
14926 Arg->getExprLoc()))
14934 SemaRef.
PDiag(diag::err_ovl_no_viable_function_in_call)
14935 << ULE->
getName() << Fn->getSourceRange()),
14943 SemaRef.
PDiag(diag::err_ovl_ambiguous_call)
14944 << ULE->
getName() << Fn->getSourceRange()),
14951 Fn->getSourceRange(), ULE->
getName(),
14952 *CandidateSet, FDecl, Args);
14961 Res.
get(), FDecl, LParenLoc, Args, RParenLoc, ExecConfig,
14969 SubExprs.append(Args.begin(), Args.end());
14976 for (
auto I = CS.
begin(), E = CS.
end(); I != E; ++I) {
14991 bool AllowTypoCorrection,
14992 bool CalleesAddressIsTaken) {
15007 if (CalleesAddressIsTaken)
15018 Best != CandidateSet.
end()) {
15019 if (
auto *M = dyn_cast_or_null<CXXMethodDecl>(Best->Function);
15020 M && M->isImplicitObjectMemberFunction()) {
15031 CUDA().recordPotentialODRUsedVariable(Args, CandidateSet);
15049 if (
const auto *TP =
15059 ExecConfig, &CandidateSet, &Best,
15060 OverloadResult, AllowTypoCorrection);
15069 Context, NamingClass, NNSLoc, DNI, PerformADL, Fns.
begin(), Fns.
end(),
15075 bool HadMultipleCandidates) {
15085 if (
Method->isExplicitObjectMemberFunction())
15089 E, std::nullopt, FoundDecl,
Method);
15093 if (
Method->getParent()->isLambda() &&
15094 Method->getConversionType()->isBlockPointerType()) {
15098 auto *CE = dyn_cast<CastExpr>(SubE);
15099 if (CE && CE->getCastKind() == CK_NoOp)
15100 SubE = CE->getSubExpr();
15102 if (
auto *BE = dyn_cast<CXXBindTemporaryExpr>(SubE))
15103 SubE = BE->getSubExpr();
15126 if (
Method->isExplicitObjectMemberFunction()) {
15132 Expr *ObjectParam = Exp.
get();
15146 Exp.
get()->getEndLoc(),
15160 Expr *Input,
bool PerformADL) {
15162 assert(Op !=
OO_None &&
"Invalid opcode for overloaded unary operator");
15170 Expr *Args[2] = { Input,
nullptr };
15171 unsigned NumArgs = 1;
15176 if (Opc == UO_PostInc || Opc == UO_PostDec) {
15190 if (Opc == UO_PreDec || Opc == UO_PreInc || Opc == UO_Deref)
15201 if (Fn.isInvalid())
15227 bool HadMultipleCandidates = (CandidateSet.
size() > 1);
15246 if (
Method->isExplicitObjectMemberFunction())
15250 Input, std::nullopt, Best->FoundDecl,
Method);
15253 Base = Input = InputInit.
get();
15264 Input = InputInit.
get();
15269 Base, HadMultipleCandidates,
15281 Context, Op, FnExpr.
get(), ArgsArray, ResultTy,
VK, OpLoc,
15297 Input, Best->BuiltinParamTypes[0], Best->Conversions[0],
15302 Input = InputRes.
get();
15322 PDiag(diag::err_ovl_ambiguous_oper_unary)
15339 << (Msg !=
nullptr)
15340 << (Msg ? Msg->
getString() : StringRef())
15393 if (Op != OO_Equal && PerformADL) {
15400 Context.DeclarationNames.getCXXOperatorName(ExtraOp);
15426 Expr *RHS,
bool PerformADL,
15427 bool AllowRewrittenCandidates,
15429 Expr *Args[2] = { LHS, RHS };
15433 AllowRewrittenCandidates =
false;
15439 if (Args[0]->isTypeDependent() || Args[1]->isTypeDependent()) {
15460 if (Fn.isInvalid())
15469 if (Opc == BO_PtrMemD) {
15470 auto CheckPlaceholder = [&](
Expr *&Arg) {
15479 if (CheckPlaceholder(Args[0]) || CheckPlaceholder(Args[1]))
15500 if (Opc == BO_Assign && !Args[0]->
getType()->isOverloadableType())
15506 Op, OpLoc, AllowRewrittenCandidates));
15508 CandidateSet.
exclude(DefaultedFn);
15511 bool HadMultipleCandidates = (CandidateSet.
size() > 1);
15520 bool IsReversed = Best->isReversed();
15522 std::swap(Args[0], Args[1]);
15539 if (Best->RewriteKind && ChosenOp == OO_EqualEqual &&
15543 Diag(OpLoc, IsExtension ? diag::ext_ovl_rewrite_equalequal_not_bool
15544 : diag::err_ovl_rewrite_equalequal_not_bool)
15552 if (AllowRewrittenCandidates && !IsReversed &&
15562 for (
unsigned ArgIdx = 0; ArgIdx < 2; ++ArgIdx) {
15565 Best->Conversions[ArgIdx]) ==
15567 AmbiguousWith.push_back(Cand.
Function);
15574 if (!AmbiguousWith.empty()) {
15575 bool AmbiguousWithSelf =
15576 AmbiguousWith.size() == 1 &&
15578 Diag(OpLoc, diag::ext_ovl_ambiguous_oper_binary_reversed)
15580 << Args[0]->
getType() << Args[1]->
getType() << AmbiguousWithSelf
15582 if (AmbiguousWithSelf) {
15584 diag::note_ovl_ambiguous_oper_binary_reversed_self);
15589 if (
auto *MD = dyn_cast<CXXMethodDecl>(FnDecl))
15590 if (Op == OverloadedOperatorKind::OO_EqualEqual &&
15592 !MD->hasCXXExplicitFunctionObjectParameter() &&
15593 Context.hasSameUnqualifiedType(
15594 MD->getFunctionObjectParameterType(),
15595 MD->getParamDecl(0)->getType().getNonReferenceType()) &&
15596 Context.hasSameUnqualifiedType(
15597 MD->getFunctionObjectParameterType(),
15599 Context.hasSameUnqualifiedType(
15600 MD->getFunctionObjectParameterType(),
15603 diag::note_ovl_ambiguous_eqeq_reversed_self_non_const);
15606 diag::note_ovl_ambiguous_oper_binary_selected_candidate);
15607 for (
auto *F : AmbiguousWith)
15609 diag::note_ovl_ambiguous_oper_binary_reversed_candidate);
15617 if (Op == OO_Equal)
15628 if (
Method->isExplicitObjectMemberFunction()) {
15633 Args[0], std::nullopt, Best->FoundDecl,
Method);
15666 Best->FoundDecl,
Base,
15667 HadMultipleCandidates, OpLoc);
15678 const Expr *ImplicitThis =
nullptr;
15683 Context, ChosenOp, FnExpr.
get(), Args, ResultTy,
VK, OpLoc,
15687 if (
const auto *
Method = dyn_cast<CXXMethodDecl>(FnDecl);
15690 ImplicitThis = ArgsArray[0];
15691 ArgsArray = ArgsArray.slice(1);
15698 if (Op == OO_Equal) {
15703 *
this,
AssignedEntity{Args[0], dyn_cast<CXXMethodDecl>(FnDecl)},
15706 if (ImplicitThis) {
15711 CheckArgAlignment(OpLoc, FnDecl,
"'this'", ThisType,
15715 checkCall(FnDecl,
nullptr, ImplicitThis, ArgsArray,
15730 (Op == OO_Spaceship && IsReversed)) {
15731 if (Op == OO_ExclaimEqual) {
15732 assert(ChosenOp == OO_EqualEqual &&
"unexpected operator name");
15735 assert(ChosenOp == OO_Spaceship &&
"unexpected operator name");
15737 Expr *ZeroLiteral =
15746 OpLoc, Opc, Fns, IsReversed ? ZeroLiteral : R.get(),
15747 IsReversed ? R.get() : ZeroLiteral,
true,
15755 assert(ChosenOp == Op &&
"unexpected operator name");
15759 if (Best->RewriteKind !=
CRK_None)
15768 Args[0], Best->BuiltinParamTypes[0], Best->Conversions[0],
15773 Args[0] = ArgsRes0.
get();
15776 Args[1], Best->BuiltinParamTypes[1], Best->Conversions[1],
15781 Args[1] = ArgsRes1.
get();
15791 if (Opc == BO_Comma)
15796 if (DefaultedFn && Opc == BO_Cmp) {
15798 Args[1], DefaultedFn);
15813 Opc >= BO_Assign && Opc <= BO_OrAssign) {
15814 Diag(OpLoc, diag::err_ovl_no_viable_oper)
15817 if (Args[0]->
getType()->isIncompleteType()) {
15818 Diag(OpLoc, diag::note_assign_lhs_incomplete)
15834 assert(
Result.isInvalid() &&
15835 "C++ binary operator overloading is missing candidates!");
15846 << Args[0]->getSourceRange()
15847 << Args[1]->getSourceRange()),
15857 Diag(OpLoc, diag::err_ovl_deleted_special_oper)
15861 Diag(OpLoc, diag::err_ovl_deleted_comparison)
15862 << Args[0]->
getType() << DeletedFD;
15875 PDiag(diag::err_ovl_deleted_oper)
15877 .getCXXOverloadedOperator())
15878 << (Msg !=
nullptr) << (Msg ? Msg->
getString() : StringRef())
15879 << Args[0]->getSourceRange() << Args[1]->getSourceRange()),
15903 "cannot use prvalue expressions more than once");
15904 Expr *OrigLHS = LHS;
15905 Expr *OrigRHS = RHS;
15922 true, DefaultedFn);
15923 if (
Less.isInvalid())
15950 for (; I >= 0; --I) {
15952 auto *VI = Info->lookupValueInfo(Comparisons[I].
Result);
15975 Context, OrigLHS, OrigRHS, BO_Cmp,
Result.get()->getType(),
15976 Result.get()->getValueKind(),
Result.get()->getObjectKind(), OpLoc,
15978 Expr *SemanticForm[] = {LHS, RHS,
Result.get()};
15988 unsigned NumArgsSlots =
15989 MethodArgs.size() + std::max<unsigned>(Args.size(), NumParams);
15992 MethodArgs.reserve(MethodArgs.size() + NumArgsSlots);
15993 bool IsError =
false;
15996 for (
unsigned i = 0; i != NumParams; i++) {
15998 if (i < Args.size()) {
16002 S.
Context, Method->getParamDecl(i)),
16016 MethodArgs.push_back(Arg);
16026 Args.push_back(
Base);
16027 for (
auto *e : ArgExpr) {
16031 Context.DeclarationNames.getCXXOperatorName(OO_Subscript);
16036 ArgExpr.back()->getEndLoc());
16048 if (Fn.isInvalid())
16058 UnbridgedCastsSet UnbridgedCasts;
16071 if (Args.size() == 2)
16074 bool HadMultipleCandidates = (CandidateSet.
size() > 1);
16094 if (
Method->isExplicitObjectMemberFunction()) {
16099 Args[0] = Res.
get();
16103 Args[0], std::nullopt, Best->FoundDecl,
Method);
16107 MethodArgs.push_back(Arg0.
get());
16111 *
this, MethodArgs,
Method, ArgExpr, LLoc);
16119 *
this, FnDecl, Best->FoundDecl,
Base, HadMultipleCandidates,
16130 Context, OO_Subscript, FnExpr.
get(), MethodArgs, ResultTy,
VK, RLoc,
16147 Args[0], Best->BuiltinParamTypes[0], Best->Conversions[0],
16152 Args[0] = ArgsRes0.
get();
16155 Args[1], Best->BuiltinParamTypes[1], Best->Conversions[1],
16160 Args[1] = ArgsRes1.
get();
16168 CandidateSet.
empty()
16169 ? (
PDiag(diag::err_ovl_no_oper)
16170 << Args[0]->getType() << 0
16171 << Args[0]->getSourceRange() << Range)
16172 : (
PDiag(diag::err_ovl_no_viable_subscript)
16173 << Args[0]->getType() << Args[0]->getSourceRange() << Range);
16180 if (Args.size() == 2) {
16183 LLoc,
PDiag(diag::err_ovl_ambiguous_oper_binary)
16185 << Args[0]->getSourceRange() << Range),
16190 PDiag(diag::err_ovl_ambiguous_subscript_call)
16192 << Args[0]->getSourceRange() << Range),
16201 PDiag(diag::err_ovl_deleted_oper)
16202 <<
"[]" << (Msg !=
nullptr)
16203 << (Msg ? Msg->
getString() : StringRef())
16204 << Args[0]->getSourceRange() << Range),
16218 Expr *ExecConfig,
bool IsExecConfig,
16219 bool AllowRecovery) {
16228 if (
BinaryOperator *op = dyn_cast<BinaryOperator>(NakedMemExpr)) {
16229 assert(op->getType() ==
Context.BoundMemberTy);
16230 assert(op->getOpcode() == BO_PtrMemD || op->getOpcode() == BO_PtrMemI);
16243 QualType objectType = op->getLHS()->getType();
16244 if (op->getOpcode() == BO_PtrMemI)
16248 Qualifiers difference = objectQuals - funcQuals;
16252 std::string qualsString = difference.
getAsString();
16253 Diag(LParenLoc, diag::err_pointer_to_member_call_drops_quals)
16256 << (qualsString.find(
' ') == std::string::npos ? 1 : 2);
16260 Context, MemExprE, Args, resultType, valueKind, RParenLoc,
16270 if (CheckOtherCall(call, proto))
16280 if (!AllowRecovery)
16282 std::vector<Expr *> SubExprs = {MemExprE};
16283 llvm::append_range(SubExprs, Args);
16291 UnbridgedCastsSet UnbridgedCasts;
16297 bool HadMultipleCandidates =
false;
16305 UnbridgedCasts.restore();
16323 TemplateArgs = &TemplateArgsBuffer;
16327 E = UnresExpr->
decls_end(); I != E; ++I) {
16329 QualType ExplicitObjectType = ObjectType;
16336 bool HasExplicitParameter =
false;
16337 if (
const auto *M = dyn_cast<FunctionDecl>(
Func);
16338 M && M->hasCXXExplicitFunctionObjectParameter())
16339 HasExplicitParameter =
true;
16340 else if (
const auto *M = dyn_cast<FunctionTemplateDecl>(
Func);
16342 M->getTemplatedDecl()->hasCXXExplicitFunctionObjectParameter())
16343 HasExplicitParameter =
true;
16345 if (HasExplicitParameter)
16353 }
else if ((
Method = dyn_cast<CXXMethodDecl>(
Func))) {
16360 ObjectClassification, Args, CandidateSet,
16364 I.getPair(), ActingDC, TemplateArgs,
16365 ExplicitObjectType, ObjectClassification,
16366 Args, CandidateSet,
16371 HadMultipleCandidates = (CandidateSet.
size() > 1);
16375 UnbridgedCasts.restore();
16378 bool Succeeded =
false;
16383 FoundDecl = Best->FoundDecl;
16403 PDiag(diag::err_ovl_no_viable_member_function_in_call)
16410 PDiag(diag::err_ovl_ambiguous_member_call)
16417 CandidateSet, Best->Function, Args,
true);
16428 MemExprE = Res.
get();
16432 if (
Method->isStatic()) {
16434 ExecConfig, IsExecConfig);
16444 assert(
Method &&
"Member call to something that isn't a method?");
16449 if (
Method->isExplicitObjectMemberFunction()) {
16457 HadMultipleCandidates, MemExpr->
getExprLoc());
16464 TheCall->setUsesMemberSyntax(
true);
16474 Proto->getNumParams());
16480 return BuildRecoveryExpr(ResultType);
16485 return BuildRecoveryExpr(ResultType);
16495 if (
auto *MemE = dyn_cast<MemberExpr>(NakedMemExpr)) {
16496 if (
const EnableIfAttr *
Attr =
16498 Diag(MemE->getMemberLoc(),
16499 diag::err_ovl_no_viable_member_function_in_call)
16502 diag::note_ovl_candidate_disabled_by_function_cond_attr)
16503 <<
Attr->getCond()->getSourceRange() <<
Attr->getMessage();
16509 TheCall->getDirectCallee()->isPureVirtual()) {
16515 diag::warn_call_to_pure_virtual_member_function_from_ctor_dtor)
16526 if (
auto *DD = dyn_cast<CXXDestructorDecl>(TheCall->getDirectCallee())) {
16530 CallCanBeVirtual,
true,
16535 TheCall->getDirectCallee());
16547 UnbridgedCastsSet UnbridgedCasts;
16551 assert(Object.get()->getType()->isRecordType() &&
16552 "Requires object type argument");
16566 diag::err_incomplete_object_call, Object.get()))
16569 auto *
Record = Object.get()->getType()->castAsCXXRecordDecl();
16572 R.suppressAccessDiagnostics();
16575 Oper != OperEnd; ++Oper) {
16577 Object.get()->Classify(
Context), Args, CandidateSet,
16589 bool IgnoreSurrogateFunctions =
false;
16592 if (!Candidate.
Viable &&
16594 IgnoreSurrogateFunctions =
true;
16616 !IgnoreSurrogateFunctions && I != E; ++I) {
16638 Object.get(), Args, CandidateSet);
16643 bool HadMultipleCandidates = (CandidateSet.
size() > 1);
16656 CandidateSet.
empty()
16657 ? (
PDiag(diag::err_ovl_no_oper)
16658 << Object.get()->getType() << 1
16659 << Object.get()->getSourceRange())
16660 : (
PDiag(diag::err_ovl_no_viable_object_call)
16661 << Object.get()->getType() << Object.get()->getSourceRange());
16668 if (!R.isAmbiguous())
16671 PDiag(diag::err_ovl_ambiguous_object_call)
16672 << Object.get()->getType()
16673 << Object.get()->getSourceRange()),
16684 PDiag(diag::err_ovl_deleted_object_call)
16685 << Object.get()->getType() << (Msg !=
nullptr)
16686 << (Msg ? Msg->
getString() : StringRef())
16687 << Object.get()->getSourceRange()),
16693 if (Best == CandidateSet.
end())
16696 UnbridgedCasts.restore();
16698 if (Best->Function ==
nullptr) {
16703 Best->Conversions[0].UserDefined.ConversionFunction);
16709 assert(Conv == Best->FoundDecl.getDecl() &&
16710 "Found Decl & conversion-to-functionptr should be same, right?!");
16718 Conv, HadMultipleCandidates);
16719 if (
Call.isInvalid())
16723 Context,
Call.get()->getType(), CK_UserDefinedConversion,
Call.get(),
16737 if (
Method->isInvalidDecl())
16744 Context.DeclarationNames.getCXXOperatorName(OO_Call), LParenLoc);
16747 Obj, HadMultipleCandidates,
16754 MethodArgs.reserve(NumParams + 1);
16756 bool IsError =
false;
16760 if (
Method->isExplicitObjectMemberFunction()) {
16764 Object.get(), std::nullopt, Best->FoundDecl,
Method);
16769 MethodArgs.push_back(Object.get());
16773 *
this, MethodArgs,
Method, Args, LParenLoc);
16776 if (Proto->isVariadic()) {
16778 for (
unsigned i = NumParams, e = Args.size(); i < e; i++) {
16782 MethodArgs.push_back(Arg.
get());
16797 Context, OO_Call, NewFn.
get(), MethodArgs, ResultTy,
VK, RParenLoc,
16811 bool *NoArrowOperatorFound) {
16812 assert(
Base->getType()->isRecordType() &&
16813 "left-hand side must have class type");
16827 Context.DeclarationNames.getCXXOperatorName(OO_Arrow);
16831 diag::err_typecheck_incomplete_tag,
Base))
16836 R.suppressAccessDiagnostics();
16839 Oper != OperEnd; ++Oper) {
16845 bool HadMultipleCandidates = (CandidateSet.
size() > 1);
16856 if (CandidateSet.
empty()) {
16858 if (NoArrowOperatorFound) {
16861 *NoArrowOperatorFound =
true;
16864 Diag(OpLoc, diag::err_typecheck_member_reference_arrow)
16865 << BaseType <<
Base->getSourceRange();
16866 if (BaseType->isRecordType() && !BaseType->isPointerType()) {
16867 Diag(OpLoc, diag::note_typecheck_member_reference_suggestion)
16871 Diag(OpLoc, diag::err_ovl_no_viable_oper)
16872 <<
"operator->" <<
Base->getSourceRange();
16877 if (!R.isAmbiguous())
16880 <<
"->" <<
Base->getType()
16881 <<
Base->getSourceRange()),
16889 <<
"->" << (Msg !=
nullptr)
16890 << (Msg ? Msg->
getString() : StringRef())
16891 <<
Base->getSourceRange()),
16902 if (
Method->isExplicitObjectMemberFunction()) {
16909 Base, std::nullopt, Best->FoundDecl,
Method);
16917 Base, HadMultipleCandidates, OpLoc);
16951 bool HadMultipleCandidates = (CandidateSet.
size() > 1);
16964 PDiag(diag::err_ovl_no_viable_function_in_call)
16965 << R.getLookupName()),
16972 << R.getLookupName()),
16979 nullptr, HadMultipleCandidates,
16982 if (Fn.isInvalid())
16988 for (
unsigned ArgIdx = 0, N = Args.size(); ArgIdx != N; ++ArgIdx) {
16994 ConvArgs[ArgIdx] = InputInit.
get();
17021 Scope *S =
nullptr;
17024 if (!MemberLookup.
empty()) {
17051 if (CandidateSet->
empty() || CandidateSetError) {
17064 Loc,
nullptr, CandidateSet, &Best,
17077 if (
ParenExpr *PE = dyn_cast<ParenExpr>(E)) {
17082 if (SubExpr.
get() == PE->getSubExpr())
17086 ParenExpr(PE->getLParen(), PE->getRParen(), SubExpr.
get());
17094 assert(
Context.hasSameType(ICE->getSubExpr()->getType(),
17096 "Implicit cast type cannot be determined from overload");
17097 assert(ICE->path_empty() &&
"fixing up hierarchy conversion?");
17098 if (SubExpr.
get() == ICE->getSubExpr())
17106 if (
auto *GSE = dyn_cast<GenericSelectionExpr>(E)) {
17107 if (!GSE->isResultDependent()) {
17112 if (SubExpr.
get() == GSE->getResultExpr())
17119 unsigned ResultIdx = GSE->getResultIndex();
17120 AssocExprs[ResultIdx] = SubExpr.
get();
17122 if (GSE->isExprPredicate())
17124 Context, GSE->getGenericLoc(), GSE->getControllingExpr(),
17125 GSE->getAssocTypeSourceInfos(), AssocExprs, GSE->getDefaultLoc(),
17126 GSE->getRParenLoc(), GSE->containsUnexpandedParameterPack(),
17129 Context, GSE->getGenericLoc(), GSE->getControllingType(),
17130 GSE->getAssocTypeSourceInfos(), AssocExprs, GSE->getDefaultLoc(),
17131 GSE->getRParenLoc(), GSE->containsUnexpandedParameterPack(),
17140 assert(UnOp->getOpcode() == UO_AddrOf &&
17141 "Can only take the address of an overloaded function");
17143 if (!
Method->isImplicitObjectMemberFunction()) {
17154 if (SubExpr.
get() == UnOp->getSubExpr())
17162 "fixed to something other than a decl ref");
17165 assert(Qualifier &&
17166 "fixed to a member ref with no nested name qualifier");
17172 Fn->getType(), Qualifier,
17175 if (
Context.getTargetInfo().getCXXABI().isMicrosoft())
17180 UnOp->getOperatorLoc(),
false,
17188 if (SubExpr.
get() == UnOp->getSubExpr())
17201 if (ULE->hasExplicitTemplateArgs()) {
17202 ULE->copyTemplateArgumentsInto(TemplateArgsBuffer);
17203 TemplateArgs = &TemplateArgsBuffer;
17208 getLangOpts().CPlusPlus && !Fn->hasCXXExplicitFunctionObjectParameter()
17213 if (
unsigned BID = Fn->getBuiltinID()) {
17214 if (!
Context.BuiltinInfo.isDirectlyAddressable(BID)) {
17221 Fn,
Type, ValueKind, ULE->getNameInfo(), ULE->getQualifierLoc(),
17222 Found.getDecl(), ULE->getTemplateKeywordLoc(), TemplateArgs);
17230 if (MemExpr->hasExplicitTemplateArgs()) {
17231 MemExpr->copyTemplateArgumentsInto(TemplateArgsBuffer);
17232 TemplateArgs = &TemplateArgsBuffer;
17239 if (MemExpr->isImplicitAccess()) {
17242 Fn, Fn->getType(),
VK_LValue, MemExpr->getNameInfo(),
17243 MemExpr->getQualifierLoc(),
Found.getDecl(),
17244 MemExpr->getTemplateKeywordLoc(), TemplateArgs);
17249 if (MemExpr->getQualifier())
17250 Loc = MemExpr->getQualifierLoc().getBeginLoc();
17255 Base = MemExpr->getBase();
17261 type = Fn->getType();
17268 Base, MemExpr->isArrow(), MemExpr->getOperatorLoc(),
17269 MemExpr->getQualifierLoc(), MemExpr->getTemplateKeywordLoc(), Fn,
Found,
17270 true, MemExpr->getMemberNameInfo(),
17274 llvm_unreachable(
"Invalid reference to overloaded function");
17285 if (!PartialOverloading || !
Function)
17289 if (
const auto *Proto =
17290 dyn_cast<FunctionProtoType>(
Function->getFunctionType()))
17291 if (Proto->isTemplateVariadic())
17293 if (
auto *Pattern =
Function->getTemplateInstantiationPattern())
17294 if (
const auto *Proto =
17295 dyn_cast<FunctionProtoType>(Pattern->getFunctionType()))
17296 if (Proto->isTemplateVariadic())
17309 << IsMember << Name << (Msg !=
nullptr)
17310 << (Msg ? Msg->
getString() : StringRef())
Defines the clang::ASTContext interface.
Defines the Diagnostic-related interfaces.
static bool isBooleanType(QualType Ty)
Defines the C++ Decl subclasses, other than those for templates (found in DeclTemplate....
Defines the clang::Expr interface and subclasses for C++ expressions.
static const GlobalDecl isTemplate(GlobalDecl GD, const TemplateArgumentList *&TemplateArgs)
static DiagnosticBuilder Diag(DiagnosticsEngine *Diags, const LangOptions &Features, FullSourceLoc TokLoc, const char *TokBegin, const char *TokRangeBegin, const char *TokRangeEnd, unsigned DiagID)
Produce a diagnostic highlighting some portion of a literal.
llvm::MachO::Record Record
Defines an enumeration for C++ overloaded operators.
Implements a partial diagnostic that can be emitted anwyhere in a DiagnosticBuilder stream.
This file declares semantic analysis functions specific to ARM.
static bool hasAttr(const Decl *D, bool IgnoreImplicitAttr)
static bool hasExplicitAttr(const VarDecl *D)
This file declares semantic analysis for CUDA constructs.
static void BuildBasePathArray(const CXXBasePath &Path, CXXCastPath &BasePathArray)
static bool isRecordType(QualType T)
static void TryUserDefinedConversion(Sema &S, QualType DestType, const InitializationKind &Kind, Expr *Initializer, InitializationSequence &Sequence, bool TopLevelOfInitList)
Attempt a user-defined conversion between two types (C++ [dcl.init]), which enumerates all conversion...
This file declares semantic analysis for Objective-C.
static ImplicitConversionSequence::CompareKind CompareStandardConversionSequences(Sema &S, SourceLocation Loc, const StandardConversionSequence &SCS1, const StandardConversionSequence &SCS2)
CompareStandardConversionSequences - Compare two standard conversion sequences to determine whether o...
static bool sameFunctionParameterTypeLists(Sema &S, FunctionDecl *Fn1, FunctionDecl *Fn2, bool IsFn1Reversed, bool IsFn2Reversed)
We're allowed to use constraints partial ordering only if the candidates have the same parameter type...
static bool isNullPointerConstantForConversion(Expr *Expr, bool InOverloadResolution, ASTContext &Context)
static bool shouldSkipNotingLambdaConversionDecl(const FunctionDecl *Fn)
static const FunctionType * getConversionOpReturnTyAsFunction(CXXConversionDecl *Conv)
static bool functionHasPassObjectSizeParams(const FunctionDecl *FD)
static Comparison compareEnableIfAttrs(const Sema &S, const FunctionDecl *Cand1, const FunctionDecl *Cand2)
Compares the enable_if attributes of two FunctionDecls, for the purposes of overload resolution.
static Qualifiers CollectVRQualifiers(ASTContext &Context, Expr *ArgExpr)
CollectVRQualifiers - This routine returns Volatile/Restrict qualifiers, if any, found in visible typ...
@ ToPromotedUnderlyingType
static void AddOverloadedCallCandidate(Sema &S, DeclAccessPair FoundDecl, TemplateArgumentListInfo *ExplicitTemplateArgs, ArrayRef< Expr * > Args, OverloadCandidateSet &CandidateSet, bool PartialOverloading, bool KnownValid)
Add a single candidate to the overload set.
static void AddTemplateOverloadCandidateImmediately(Sema &S, OverloadCandidateSet &CandidateSet, FunctionTemplateDecl *FunctionTemplate, DeclAccessPair FoundDecl, TemplateArgumentListInfo *ExplicitTemplateArgs, ArrayRef< Expr * > Args, bool SuppressUserConversions, bool PartialOverloading, bool AllowExplicit, Sema::ADLCallKind IsADLCandidate, OverloadCandidateParamOrder PO, bool AggregateCandidateDeduction)
static bool IsVectorOrMatrixElementConversion(Sema &S, QualType FromType, QualType ToType, ImplicitConversionKind &ICK, Expr *From)
static ExprResult FinishOverloadedCallExpr(Sema &SemaRef, Scope *S, Expr *Fn, UnresolvedLookupExpr *ULE, SourceLocation LParenLoc, MultiExprArg Args, SourceLocation RParenLoc, Expr *ExecConfig, OverloadCandidateSet *CandidateSet, OverloadCandidateSet::iterator *Best, OverloadingResult OverloadResult, bool AllowTypoCorrection)
FinishOverloadedCallExpr - given an OverloadCandidateSet, builds and returns the completed call expre...
static bool isQualificationConversionStep(QualType FromType, QualType ToType, bool CStyle, bool IsTopLevel, bool &PreviousToQualsIncludeConst, bool &ObjCLifetimeConversion, const ASTContext &Ctx)
Perform a single iteration of the loop for checking if a qualification conversion is valid.
static ImplicitConversionSequence::CompareKind CompareQualificationConversions(Sema &S, const StandardConversionSequence &SCS1, const StandardConversionSequence &SCS2)
CompareQualificationConversions - Compares two standard conversion sequences to determine whether the...
static void dropPointerConversion(StandardConversionSequence &SCS)
dropPointerConversions - If the given standard conversion sequence involves any pointer conversions,...
static SourceLocation GetLocationForCandidate(const OverloadCandidate *Cand)
static void DiagnoseArityMismatch(Sema &S, NamedDecl *Found, Decl *D, unsigned NumFormalArgs, bool IsAddressOf=false)
General arity mismatch diagnosis over a candidate in a candidate set.
static const Expr * IgnoreNarrowingConversion(ASTContext &Ctx, const Expr *Converted)
Skip any implicit casts which could be either part of a narrowing conversion or after one in an impli...
static bool allowAmbiguity(ASTContext &Context, const FunctionDecl *F1, const FunctionDecl *F2)
static unsigned RankDeductionFailure(const DeductionFailureInfo &DFI)
static QualType BuildSimilarlyQualifiedPointerType(const Type *FromPtr, QualType ToPointee, QualType ToType, ASTContext &Context, bool StripObjCLifetime=false)
BuildSimilarlyQualifiedPointerType - In a pointer conversion from the pointer type FromPtr to a point...
static void forAllQualifierCombinations(QualifiersAndAtomic Quals, llvm::function_ref< void(QualifiersAndAtomic)> Callback)
static bool FindConversionForRefInit(Sema &S, ImplicitConversionSequence &ICS, QualType DeclType, SourceLocation DeclLoc, Expr *Init, QualType T2, bool AllowRvalues, bool AllowExplicit)
Look for a user-defined conversion to a value reference-compatible with DeclType.
static bool tryAtomicConversion(Sema &S, Expr *From, QualType ToType, bool InOverloadResolution, StandardConversionSequence &SCS, bool CStyle)
static Expr * GetExplicitObjectExpr(Sema &S, Expr *Obj, const FunctionDecl *Fun)
static bool hasDeprecatedStringLiteralToCharPtrConversion(const ImplicitConversionSequence &ICS)
static void AddBuiltinAssignmentOperatorCandidates(Sema &S, QualType T, ArrayRef< Expr * > Args, OverloadCandidateSet &CandidateSet)
Helper function for AddBuiltinOperatorCandidates() that adds the volatile- and non-volatile-qualified...
static bool CheckConvertedConstantConversions(Sema &S, StandardConversionSequence &SCS)
Check that the specified conversion is permitted in a converted constant expression,...
static 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 ExprResult CreateFunctionRefExpr(Sema &S, FunctionDecl *Fn, NamedDecl *FoundDecl, const Expr *Base, bool HadMultipleCandidates, SourceLocation Loc=SourceLocation(), const DeclarationNameLoc &LocInfo=DeclarationNameLoc())
A convenience routine for creating a decayed reference to a function.
static std::optional< QualType > getImplicitObjectParamType(ASTContext &Context, const FunctionDecl *F)
Compute the type of the implicit object parameter for the given function, if any.
static bool checkPlaceholderForOverload(Sema &S, Expr *&E, UnbridgedCastsSet *unbridgedCasts=nullptr)
checkPlaceholderForOverload - Do any interesting placeholder-like preprocessing on the given expressi...
static FixedEnumPromotion getFixedEnumPromtion(Sema &S, const StandardConversionSequence &SCS)
Returns kind of fixed enum promotion the SCS uses.
static bool isAllowableExplicitConversion(Sema &S, QualType ConvType, QualType ToType, bool AllowObjCPointerConversion)
Determine whether this is an allowable conversion from the result of an explicit conversion operator ...
static bool isNonViableMultiVersionOverload(FunctionDecl *FD)
static bool FunctionsCorrespond(ASTContext &Ctx, const FunctionDecl *X, const FunctionDecl *Y)
static ImplicitConversionSequence TryImplicitConversion(Sema &S, Expr *From, QualType ToType, bool SuppressUserConversions, AllowedExplicit AllowExplicit, bool InOverloadResolution, bool CStyle, bool AllowObjCWritebackConversion, bool AllowObjCConversionOnExplicit)
TryImplicitConversion - Attempt to perform an implicit conversion from the given expression (Expr) to...
static ExprResult BuildConvertedConstantExpression(Sema &S, Expr *From, QualType T, CCEKind CCE, NamedDecl *Dest, APValue &PreNarrowingValue)
BuildConvertedConstantExpression - Check that the expression From is a converted constant expression ...
static ImplicitConversionSequence TryListConversion(Sema &S, InitListExpr *From, QualType ToType, bool SuppressUserConversions, bool InOverloadResolution, bool AllowObjCWritebackConversion)
TryListConversion - Try to copy-initialize a value of type ToType from the initializer list From.
static bool IsOverloadOrOverrideImpl(Sema &SemaRef, FunctionDecl *New, FunctionDecl *Old, bool UseMemberUsingDeclRules, bool ConsiderCudaAttrs, bool UseOverrideRules=false)
static QualType withoutUnaligned(ASTContext &Ctx, QualType T)
static void DiagnoseBadTarget(Sema &S, OverloadCandidate *Cand)
CUDA: diagnose an invalid call across targets.
static void MaybeDiagnoseAmbiguousConstraints(Sema &S, ArrayRef< OverloadCandidate > Cands)
static bool diagnoseNoViableConversion(Sema &SemaRef, SourceLocation Loc, Expr *&From, Sema::ContextualImplicitConverter &Converter, QualType T, bool HadMultipleCandidates, UnresolvedSetImpl &ExplicitConversions)
static void AddMethodTemplateCandidateImmediately(Sema &S, OverloadCandidateSet &CandidateSet, FunctionTemplateDecl *MethodTmpl, DeclAccessPair FoundDecl, CXXRecordDecl *ActingContext, TemplateArgumentListInfo *ExplicitTemplateArgs, QualType ObjectType, Expr::Classification ObjectClassification, ArrayRef< Expr * > Args, bool SuppressUserConversions, bool PartialOverloading, OverloadCandidateParamOrder PO)
static void AddTemplateConversionCandidateImmediately(Sema &S, OverloadCandidateSet &CandidateSet, FunctionTemplateDecl *FunctionTemplate, DeclAccessPair FoundDecl, CXXRecordDecl *ActingContext, Expr *From, QualType ToType, bool AllowObjCConversionOnExplicit, bool AllowExplicit, bool AllowResultConversion)
static ImplicitConversionSequence TryContextuallyConvertToBool(Sema &S, Expr *From)
TryContextuallyConvertToBool - Attempt to contextually convert the expression From to bool (C++0x [co...
static ImplicitConversionSequence TryObjectArgumentInitialization(Sema &S, SourceLocation Loc, QualType FromType, Expr::Classification FromClassification, CXXMethodDecl *Method, const CXXRecordDecl *ActingContext, bool InOverloadResolution=false, QualType ExplicitParameterType=QualType(), bool SuppressUserConversion=false)
TryObjectArgumentInitialization - Try to initialize the object parameter of the given member function...
static bool recordConversion(Sema &SemaRef, SourceLocation Loc, Expr *&From, Sema::ContextualImplicitConverter &Converter, QualType T, bool HadMultipleCandidates, DeclAccessPair &Found)
static ImplicitConversionSequence::CompareKind CompareImplicitConversionSequences(Sema &S, SourceLocation Loc, const ImplicitConversionSequence &ICS1, const ImplicitConversionSequence &ICS2)
CompareImplicitConversionSequences - Compare two implicit conversion sequences to determine whether o...
static ImplicitConversionSequence::CompareKind CompareOverflowBehaviorConversions(Sema &S, const StandardConversionSequence &SCS1, const StandardConversionSequence &SCS2)
CompareOverflowBehaviorConversions - Compares two standard conversion sequences to determine whether ...
static void NoteFunctionCandidate(Sema &S, OverloadCandidate *Cand, unsigned NumArgs, bool TakingCandidateAddress, LangAS CtorDestAS=LangAS::Default)
Generates a 'note' diagnostic for an overload candidate.
static ImplicitConversionSequence TryCopyInitialization(Sema &S, Expr *From, QualType ToType, bool SuppressUserConversions, bool InOverloadResolution, bool AllowObjCWritebackConversion, bool AllowExplicit=false)
TryCopyInitialization - Try to copy-initialize a value of type ToType from the expression From.
static ExprResult diagnoseAmbiguousConversion(Sema &SemaRef, SourceLocation Loc, Expr *From, Sema::ContextualImplicitConverter &Converter, QualType T, UnresolvedSetImpl &ViableConversions)
static void markUnaddressableCandidatesUnviable(Sema &S, OverloadCandidateSet &CS)
static QualType GetExplicitObjectType(Sema &S, const Expr *MemExprE)
Sema::AllowedExplicit AllowedExplicit
static QualType AdjustAddressSpaceForBuiltinOperandType(Sema &S, QualType T, Expr *Arg)
Helper function for adjusting address spaces for the pointer or reference operands of builtin operato...
static void DiagnoseFailedExplicitSpec(Sema &S, OverloadCandidate *Cand)
static bool DiagnoseTwoPhaseLookup(Sema &SemaRef, SourceLocation FnLoc, const CXXScopeSpec &SS, LookupResult &R, OverloadCandidateSet::CandidateSetKind CSK, TemplateArgumentListInfo *ExplicitTemplateArgs, ArrayRef< Expr * > Args, CXXRecordDecl **FoundInClass=nullptr)
Attempt to recover from an ill-formed use of a non-dependent name in a template, where the non-depend...
static bool isBetterReferenceBindingKind(const StandardConversionSequence &SCS1, const StandardConversionSequence &SCS2)
Determine whether one of the given reference bindings is better than the other based on what kind of ...
static bool canBeDeclaredInNamespace(const DeclarationName &Name)
Determine whether a declaration with the specified name could be moved into a different namespace.
static ExprResult finishContextualImplicitConversion(Sema &SemaRef, SourceLocation Loc, Expr *From, Sema::ContextualImplicitConverter &Converter)
static bool IsStandardConversion(Sema &S, Expr *From, QualType ToType, bool InOverloadResolution, StandardConversionSequence &SCS, bool CStyle, bool AllowObjCWritebackConversion)
IsStandardConversion - Determines whether there is a standard conversion sequence (C++ [conv],...
static bool DiagnoseTwoPhaseOperatorLookup(Sema &SemaRef, OverloadedOperatorKind Op, SourceLocation OpLoc, ArrayRef< Expr * > Args)
Attempt to recover from ill-formed use of a non-dependent operator in a template, where the non-depen...
static bool isNonTrivialObjCLifetimeConversion(Qualifiers FromQuals, Qualifiers ToQuals)
Determine whether the lifetime conversion between the two given qualifiers sets is nontrivial.
static void DiagnoseBadConversion(Sema &S, OverloadCandidate *Cand, unsigned I, bool TakingCandidateAddress)
static bool completeFunctionType(Sema &S, FunctionDecl *FD, SourceLocation Loc, bool Complain=true)
static bool shouldAddReversedEqEq(Sema &S, SourceLocation OpLoc, Expr *FirstOperand, FunctionDecl *EqFD)
static bool isFunctionAlwaysEnabled(const ASTContext &Ctx, const FunctionDecl *FD)
static bool PrepareExplicitObjectArgument(Sema &S, CXXMethodDecl *Method, Expr *Object, MultiExprArg &Args, SmallVectorImpl< Expr * > &NewArgs)
static OverloadingResult IsInitializerListConstructorConversion(Sema &S, Expr *From, QualType ToType, CXXRecordDecl *To, UserDefinedConversionSequence &User, OverloadCandidateSet &CandidateSet, bool AllowExplicit)
static bool IsMatrixConversion(Sema &S, QualType FromType, QualType ToType, ImplicitConversionKind &ICK, ImplicitConversionKind &ElConv, Expr *From, bool InOverloadResolution, bool CStyle)
Determine whether the conversion from FromType to ToType is a valid matrix conversion.
static bool checkAddressOfCandidateIsAvailable(Sema &S, const FunctionDecl *FD)
static bool IsFloatingPointConversion(Sema &S, QualType FromType, QualType ToType)
Determine whether the conversion from FromType to ToType is a valid floating point conversion.
static bool isFirstArgumentCompatibleWithType(ASTContext &Context, CXXConstructorDecl *Constructor, QualType Type)
static Comparison isBetterMultiversionCandidate(const OverloadCandidate &Cand1, const OverloadCandidate &Cand2)
static void NoteImplicitDeductionGuide(Sema &S, FunctionDecl *Fn)
static void collectViableConversionCandidates(Sema &SemaRef, Expr *From, QualType ToType, UnresolvedSetImpl &ViableConversions, OverloadCandidateSet &CandidateSet)
static ImplicitConversionSequence TryReferenceInit(Sema &S, Expr *Init, QualType DeclType, SourceLocation DeclLoc, bool SuppressUserConversions, bool AllowExplicit)
Compute an implicit conversion sequence for reference initialization.
static bool isNonDependentlyExplicit(FunctionTemplateDecl *FTD)
Determine whether a given function template has a simple explicit specifier or a non-value-dependent ...
static bool checkArgPlaceholdersForOverload(Sema &S, MultiExprArg Args, UnbridgedCastsSet &unbridged)
checkArgPlaceholdersForOverload - Check a set of call operands for placeholders.
static QualType makeQualifiedLValueReferenceType(QualType Base, QualifiersAndAtomic Quals, Sema &S)
static QualType chooseRecoveryType(OverloadCandidateSet &CS, OverloadCandidateSet::iterator *Best)
static void AddTemplateOverloadCandidate(Sema &S, OverloadCandidateSet &CandidateSet, DeferredMethodTemplateOverloadCandidate &C)
static void NoteSurrogateCandidate(Sema &S, OverloadCandidate *Cand)
static ExprResult BuildRecoveryCallExpr(Sema &SemaRef, Scope *S, Expr *Fn, UnresolvedLookupExpr *ULE, SourceLocation LParenLoc, MutableArrayRef< Expr * > Args, SourceLocation RParenLoc, bool EmptyLookup, bool AllowTypoCorrection)
Attempts to recover from a call where no functions were found.
static void DiagnoseFailedEnableIfAttr(Sema &S, OverloadCandidate *Cand)
static bool diagnoseDiagnoseIfAttrsWith(Sema &S, const NamedDecl *ND, bool ArgDependent, SourceLocation Loc, CheckFn &&IsSuccessful)
static OverloadingResult IsUserDefinedConversion(Sema &S, Expr *From, QualType ToType, UserDefinedConversionSequence &User, OverloadCandidateSet &Conversions, AllowedExplicit AllowExplicit, bool AllowObjCConversionOnExplicit)
Determines whether there is a user-defined conversion sequence (C++ [over.ics.user]) that converts ex...
static bool IsAcceptableNonMemberOperatorCandidate(ASTContext &Context, FunctionDecl *Fn, ArrayRef< Expr * > Args)
IsAcceptableNonMemberOperatorCandidate - Determine whether Fn is an acceptable non-member overloaded ...
static FunctionDecl * getMorePartialOrderingConstrained(Sema &S, FunctionDecl *Fn1, FunctionDecl *Fn2, bool IsFn1Reversed, bool IsFn2Reversed)
static void DiagnoseBadDeduction(Sema &S, NamedDecl *Found, Decl *Templated, DeductionFailureInfo &DeductionFailure, unsigned NumArgs, bool TakingCandidateAddress)
Diagnose a failed template-argument deduction.
static bool IsTransparentUnionStandardConversion(Sema &S, Expr *From, QualType &ToType, bool InOverloadResolution, StandardConversionSequence &SCS, bool CStyle)
static const FunctionProtoType * tryGetFunctionProtoType(QualType FromType)
Attempts to get the FunctionProtoType from a Type.
static bool PrepareArgumentsForCallToObjectOfClassType(Sema &S, SmallVectorImpl< Expr * > &MethodArgs, CXXMethodDecl *Method, MultiExprArg Args, SourceLocation LParenLoc)
static TemplateDeductionResult DeduceTemplateArguments(Sema &S, TemplateParameterList *TemplateParams, ArrayRef< TemplateArgument > Ps, ArrayRef< TemplateArgument > As, TemplateDeductionInfo &Info, SmallVectorImpl< DeducedTemplateArgument > &Deduced, bool NumberOfArgumentsMustMatch, bool PartialOrdering, PackFold PackFold, bool *HasDeducedAnyParam)
Defines the SourceManager interface.
static QualType getPointeeType(const MemRegion *R)
C Language Family Type Representation.
a trap message and trap category.
A class for storing results from argument-dependent lookup.
void erase(NamedDecl *D)
Removes any data associated with a given decl.
llvm::mapped_iterator< decltype(Decls)::iterator, select_second > iterator
APValue - This class implements a discriminated union of [uninitialized] [APSInt] [APFloat],...
std::string getAsString(const ASTContext &Ctx, QualType Ty) const
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
const ConstantArrayType * getAsConstantArrayType(QualType T) const
QualType getAtomicType(QualType T) const
Return the uniqued reference to the atomic type for the specified type.
QualType getRValueReferenceType(QualType T) const
Return the uniqued reference to the type for an rvalue reference to the specified type.
unsigned getIntWidth(QualType T) const
bool areCompatibleRVVTypes(QualType FirstType, QualType SecondType)
Return true if the given types are an RISC-V vector builtin type and a VectorType that is a fixed-len...
const llvm::fltSemantics & getFloatTypeSemantics(QualType T) const
Return the APFloat 'semantics' for the specified scalar floating point type.
static CanQualType getCanonicalType(QualType T)
Return the canonical (structural) type corresponding to the specified potentially non-canonical type ...
DeclarationNameTable DeclarationNames
QualType getArrayParameterType(QualType Ty) const
Return the uniqued reference to a specified array parameter type from the original array type.
QualType getPointerType(QualType T) const
Return the uniqued reference to the type for a pointer to the specified type.
bool canAssignObjCInterfaces(const ObjCObjectPointerType *LHSOPT, const ObjCObjectPointerType *RHSOPT)
canAssignObjCInterfaces - Return true if the two interface types are compatible for assignment from R...
QualType getLValueReferenceType(QualType T, bool SpelledAsLValue=true) const
Return the uniqued reference to the type for an lvalue reference to the specified type.
QualType getConstantArrayType(QualType EltTy, const llvm::APInt &ArySize, const Expr *SizeExpr, ArraySizeModifier ASM, unsigned IndexTypeQuals) const
Return the unique reference to the type for a constant array of the specified element type.
const LangOptions & getLangOpts() const
bool areLaxCompatibleRVVTypes(QualType FirstType, QualType SecondType)
Return true if the given vector types are lax-compatible RISC-V vector types as defined by -flax-vect...
CallingConv getDefaultCallingConvention(bool IsVariadic, bool IsCXXMethod) const
Retrieves the default calling convention for the current context.
void forEachMultiversionedFunctionVersion(const FunctionDecl *FD, llvm::function_ref< void(FunctionDecl *)> Pred) const
Visits all versions of a multiversioned function with the passed predicate.
QualType getPointerDiffType() const
Return the unique type for "ptrdiff_t" (C99 7.17) defined in <stddef.h>.
int getFloatingTypeOrder(QualType LHS, QualType RHS) const
Compare the rank of the two specified floating point types, ignoring the domain of the type (i....
const TargetInfo * getAuxTargetInfo() const
CanQualType UnsignedLongTy
QualType getRestrictType(QualType T) const
Return the uniqued reference to the type for a restrict qualified type.
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)
Represents a C++ struct/union/class.
bool isLambda() const
Determine whether this class describes a lambda function object.
llvm::iterator_range< conversion_iterator > getVisibleConversionFunctions() const
Get all conversion functions visible in current class, including conversion function templates.
bool hasDefinition() const
CXXMethodDecl * getLambdaCallOperator() const
Retrieve the lambda call operator of the closure type if this is a closure type.
A rewritten comparison expression that was originally written using operator syntax.
Represents a C++ nested-name-specifier or a global scope specifier.
bool isEmpty() const
No scope specifier.
void Adopt(NestedNameSpecifierLoc Other)
Adopt an existing nested-name-specifier (with source-range information).
CallExpr - Represents a function call (C99 6.5.2.2, C++ [expr.call]).
static CallExpr * Create(const ASTContext &Ctx, Expr *Fn, ArrayRef< Expr * > Args, QualType Ty, ExprValueKind VK, SourceLocation RParenLoc, FPOptionsOverride FPFeatures, unsigned MinNumArgs=0, ADLCallKind UsesADL=NotADL)
Create a call expression.
FunctionDecl * getDirectCallee()
If the callee is a FunctionDecl, return it. Otherwise return null.
void setUsesMemberSyntax(bool V=true)
void markDependentForPostponedNameLookup()
Used by Sema to implement MSVC-compatible delayed name lookup.
Represents a canonical, potentially-qualified type.
bool isAtLeastAsQualifiedAs(CanQual< T > Other, const ASTContext &Ctx) const
Determines whether this canonical type is at least as qualified as the Other canonical type.
static CanQual< Type > CreateUnsafe(QualType Other)
CanProxy< U > castAs() const
CanQual< T > getUnqualifiedType() const
Retrieve the unqualified form of this type.
Qualifiers getQualifiers() const
Retrieve all qualifiers.
CanProxy< U > getAs() const
Retrieve a canonical type pointer with a different static type, upcasting or downcasting as needed.
bool isVolatileQualified() const
const T * getTypePtr() const
Retrieve the underlying type pointer, which refers to a canonical type.
bool isPartial() const
True iff the comparison is not totally ordered.
bool isStrong() const
True iff the comparison is "strong".
Complex values, per C99 6.2.5p11.
QualType getElementType() const
static CompoundAssignOperator * Create(const ASTContext &C, Expr *lhs, Expr *rhs, Opcode opc, QualType ResTy, ExprValueKind VK, ExprObjectKind OK, SourceLocation opLoc, FPOptionsOverride FPFeatures, QualType CompLHSType=QualType(), QualType CompResultType=QualType())
Represents the canonical version of C arrays with a specified constant size.
static ConstantExpr * Create(const ASTContext &Context, Expr *E, const APValue &Result)
Represents a concrete matrix type with constant number of rows and columns.
unsigned getNumColumns() const
Returns the number of columns in the matrix.
unsigned getNumRows() const
Returns the number of rows in the matrix.
The result of a constraint satisfaction check, containing the necessary information to diagnose an un...
Base class for callback objects used by Sema::CorrectTypo to check the validity of a potential typo c...
A POD class for pairing a NamedDecl* with an access specifier.
static DeclAccessPair make(NamedDecl *D, AccessSpecifier AS)
NamedDecl * getDecl() const
DeclContext - This is used only as base class of specific decl types that can act as declaration cont...
DeclContext * getParent()
getParent - Returns the containing DeclContext.
lookup_result lookup(DeclarationName Name) const
lookup - Find the declarations (if any) with the given Name in this context.
DeclContext * getEnclosingNamespaceContext()
Retrieve the nearest enclosing namespace context.
bool Encloses(const DeclContext *DC) const
Determine whether this declaration context semantically encloses the declaration context DC.
A reference to a declared variable, function, enum, etc.
void setHadMultipleCandidates(bool V=true)
Sets the flag telling whether this expression refers to a function that was resolved from an overload...
Decl - This represents one declaration (or definition), e.g.
TemplateDecl * getDescribedTemplate() const
If this is a declaration that describes some template, this method returns that template declaration.
ASTContext & getASTContext() const LLVM_READONLY
bool isImplicit() const
isImplicit - Indicates whether the declaration was implicitly generated by the implementation.
const FunctionType * getFunctionType(bool BlocksToo=true) const
Looks through the Decl's underlying type to extract a FunctionType when possible.
FunctionDecl * getAsFunction() LLVM_READONLY
Returns the function itself, or the templated function if this is a function template.
bool isInvalidDecl() const
llvm::iterator_range< specific_attr_iterator< T > > specific_attrs() const
SourceLocation getLocation() const
DeclContext * getDeclContext()
AccessSpecifier getAccess() const
specific_attr_iterator< T > specific_attr_end() const
specific_attr_iterator< T > specific_attr_begin() const
DeclContext * getLexicalDeclContext()
getLexicalDeclContext - The declaration context where this Decl was lexically declared (LexicalDC).
DeclarationNameLoc - Additional source/type location info for a declaration name.
The name of a declaration.
TemplateDecl * getCXXDeductionGuideTemplate() const
If this name is the name of a C++ deduction guide, return the template associated with that name.
OverloadedOperatorKind getCXXOverloadedOperator() const
If this name is the name of an overloadable operator in C++ (e.g., operator+), retrieve the kind of o...
SourceLocation getBeginLoc() const LLVM_READONLY
const AssociatedConstraint & getTrailingRequiresClause() const
Get the constraint-expression introduced by the trailing requires-clause in the function/member decla...
void overloadCandidatesShown(unsigned N)
Call this after showing N overload candidates.
unsigned getNumOverloadCandidatesToShow() const
When a call or operator fails, print out up to this many candidate overloads as suggestions.
OverloadsShown getShowOverloads() const
const IntrusiveRefCntPtr< DiagnosticIDs > & getDiagnosticIDs() const
RAII object that enters a new expression evaluation context.
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(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.
Represents a function declaration or definition.
bool isMultiVersion() const
True if this function is considered a multiversioned function.
const ParmVarDecl * getParamDecl(unsigned i) const
FunctionTemplateDecl * getDescribedFunctionTemplate() const
Retrieves the function template that is described by this function declaration.
unsigned getBuiltinID(bool ConsiderWrapperFunctions=false) const
Returns a value indicating whether this function corresponds to a builtin function.
param_iterator param_end()
bool isMemberLikeConstrainedFriend() const
Determine whether a function is a friend function that cannot be redeclared outside of its class,...
bool hasCXXExplicitFunctionObjectParameter() const
QualType getReturnType() const
ArrayRef< ParmVarDecl * > parameters() const
FunctionDecl * getTemplateInstantiationPattern(bool ForDefinition=true) const
Retrieve the function declaration from which this function could be instantiated, if it is an instant...
FunctionTemplateDecl * getPrimaryTemplate() const
Retrieve the primary template that this function template specialization either specializes or was in...
FunctionDecl * getCanonicalDecl() override
Retrieves the "canonical" declaration of the given declaration.
param_iterator param_begin()
bool isVariadic() const
Whether this function is variadic.
const TemplateArgumentList * getTemplateSpecializationArgs() const
Retrieve the template arguments used to produce this function template specialization from the primar...
bool isTemplateInstantiation() const
Determines if the given function was instantiated from a function template.
unsigned getNumNonObjectParams() const
bool isConstexpr() const
Whether this is a (C++11) constexpr function or constexpr constructor.
OverloadedOperatorKind getOverloadedOperator() const
getOverloadedOperator - Which C++ overloaded operator this function represents, if any.
bool isTargetMultiVersion() const
True if this function is a multiversioned dispatch function as a part of the target functionality.
QualType getDeclaredReturnType() const
Get the declared return type, which may differ from the actual return type if the return type is dedu...
bool isTargetMultiVersionDefault() const
True if this function is the default version of a multiversioned dispatch function as a part of the t...
unsigned getNumParams() const
Return the number of parameters this function must have based on its FunctionType.
bool willHaveBody() const
True if this function will eventually have a body, once it's fully parsed.
Represents a prototype with parameter type info, e.g.
ExtParameterInfo getExtParameterInfo(unsigned I) const
unsigned getNumParams() const
Qualifiers getMethodQuals() const
QualType getParamType(unsigned i) const
bool isVariadic() const
Whether this function prototype is variadic.
ArrayRef< QualType > param_types() const
Declaration of a template function.
FunctionDecl * getTemplatedDecl() const
Get the underlying function declaration of the template.
A class which abstracts out some details necessary for making a call.
ExtInfo withNoReturn(bool noReturn) const
ParameterABI getABI() const
Return the ABI treatment of this parameter.
FunctionType - C99 6.7.5.3 - Function Declarators.
ExtInfo getExtInfo() const
CallingConv getCallConv() const
QualType getReturnType() const
QualType getCallResultType(const ASTContext &Context) const
Determine the type of an expression that calls a function of this type.
static GenericSelectionExpr * Create(const ASTContext &Context, SourceLocation GenericLoc, Expr *ControllingExpr, ArrayRef< TypeSourceInfo * > AssocTypes, ArrayRef< Expr * > AssocExprs, SourceLocation DefaultLoc, SourceLocation RParenLoc, bool ContainsUnexpandedParameterPack, unsigned ResultIndex)
Create a non-result-dependent generic selection expression accepting an expression predicate.
One of these records is kept for each identifier that is lexed.
ImplicitCastExpr - Allows us to explicitly represent implicit type conversions, which have no direct ...
static ImplicitCastExpr * Create(const ASTContext &Context, QualType T, CastKind Kind, Expr *Operand, const CXXCastPath *BasePath, ExprValueKind Cat, FPOptionsOverride FPO)
ImplicitConversionSequence - Represents an implicit conversion sequence, which may be a standard conv...
void dump() const
dump - Print this implicit conversion sequence to standard error.
bool isUserDefined() const
@ StaticObjectArgumentConversion
StandardConversionSequence Standard
When ConversionKind == StandardConversion, provides the details of the standard conversion sequence.
void setBad(BadConversionSequence::FailureKind Failure, Expr *FromExpr, QualType ToType)
Sets this sequence as a bad conversion for an explicit argument.
UserDefinedConversionSequence UserDefined
When ConversionKind == UserDefinedConversion, provides the details of the user-defined conversion seq...
static ImplicitConversionSequence getNullptrToBool(QualType SourceType, QualType DestType, bool NeedLValToRVal)
Form an "implicit" conversion sequence from nullptr_t to bool, for a direct-initialization of a bool ...
AmbiguousConversionSequence Ambiguous
When ConversionKind == AmbiguousConversion, provides the details of the ambiguous conversion.
void setInitializerListContainerType(QualType T, bool IA)
bool hasInitializerListContainerType() const
unsigned getKindRank() const
Return a ranking of the implicit conversion sequence kind, where smaller ranks represent better conve...
bool isInitializerListOfIncompleteArray() const
BadConversionSequence Bad
When ConversionKind == BadConversion, provides the details of the bad conversion.
QualType getInitializerListContainerType() const
void DiagnoseAmbiguousConversion(Sema &S, SourceLocation CaretLoc, const PartialDiagnostic &PDiag) const
Diagnoses an ambiguous conversion.
Describes an C or C++ initializer list.
bool hasDesignatedInit() const
Determine whether this initializer list contains a designated initializer.
unsigned getNumInits() const
SourceLocation getBeginLoc() const LLVM_READONLY
const Expr * getInit(unsigned Init) const
SourceLocation getEndLoc() const LLVM_READONLY
Describes an entity that is being initialized.
static InitializedEntity InitializeParameter(ASTContext &Context, ParmVarDecl *Parm)
Create the initialization entity for a parameter.
static InitializedEntity InitializeTemplateParameter(QualType T, NamedDecl *Param)
Create the initialization entity for a template parameter.
static IntegerLiteral * Create(const ASTContext &C, const llvm::APInt &V, QualType type, SourceLocation l)
Returns a new integer literal with value 'V' and type 'type'.
An lvalue reference type, per C++11 [dcl.ref].
bool isCompatibleWithMSVC() const
Represents the results of name lookup.
void addAllDecls(const LookupResult &Other)
Add all the declarations from another set of lookup results.
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.
ValueDecl * getMemberDecl() const
Retrieve the member declaration to which this expression refers.
bool hasQualifier() const
Determines whether this member expression actually had a C++ nested-name-specifier prior to the name ...
bool performsVirtualDispatch(const LangOptions &LO) const
Returns true if virtual dispatch is performed.
SourceLocation getBeginLoc() const LLVM_READONLY
SourceLocation getExprLoc() const LLVM_READONLY
DeclAccessPair getFoundDecl() const
Retrieves the declaration found by lookup.
A pointer to member type per C++ 8.3.3 - Pointers to members.
NestedNameSpecifier getQualifier() const
CXXRecordDecl * getMostRecentCXXRecordDecl() const
Note: this can trigger extra deserialization when external AST sources are used.
QualType getPointeeType() const
Describes a module or submodule.
std::string getFullModuleName(bool AllowStringLiterals=false) const
Retrieve the full name of this module, including the path from its top-level module.
This represents a decl that may have a name.
NamedDecl * getUnderlyingDecl()
Looks through UsingDecls and ObjCCompatibleAliasDecls for the underlying named decl.
StringRef getName() const
Get the name of identifier for this declaration as a StringRef.
DeclarationName getDeclName() const
Get the actual, stored name of the declaration, which may be a special name.
std::string getQualifiedNameAsString() const
Linkage getFormalLinkage() const
Get the linkage from a semantic point of view.
Represent a C++ namespace.
A C++ nested-name-specifier augmented with source location information.
SourceRange getSourceRange() const LLVM_READONLY
Retrieve the source range covering the entirety of this nested-name-specifier.
Represents a C++ nested name specifier, such as "\::std::vector<int>::".
NonTypeTemplateParmDecl - Declares a non-type template parameter, e.g., "Size" in.
Represents an ObjC class declaration.
Represents typeof(type), a C23 feature and GCC extension, or `typeof_unqual(type),...
ObjCMethodDecl - Represents an instance or class method declaration.
Represents a pointer to an Objective C object.
bool isSpecialized() const
Whether this type is specialized, meaning that it has type arguments.
bool isObjCIdType() const
True if this is equivalent to the 'id' type, i.e.
QualType getPointeeType() const
Gets the type pointed to by this ObjC pointer.
ObjCInterfaceDecl * getInterfaceDecl() const
If this pointer points to an Objective @interface type, gets the declaration for that interface.
const ObjCInterfaceType * getInterfaceType() const
If this pointer points to an Objective C @interface type, gets the type for that interface.
bool isObjCClassType() const
True if this is equivalent to the 'Class' type, i.e.
OpaqueValueExpr - An expression referring to an opaque object of a fixed type and value class.
OverloadCandidateSet - A set of overload candidates, used in C++ overload resolution (C++ 13....
void clear(CandidateSetKind CSK)
Clear out all of the candidates.
void AddDeferredTemplateCandidate(FunctionTemplateDecl *FunctionTemplate, DeclAccessPair FoundDecl, ArrayRef< Expr * > Args, bool SuppressUserConversions, bool PartialOverloading, bool AllowExplicit, CallExpr::ADLCallKind IsADLCandidate, OverloadCandidateParamOrder PO, bool AggregateCandidateDeduction)
bool isNewCandidate(Decl *F, OverloadCandidateParamOrder PO=OverloadCandidateParamOrder::Normal)
Determine when this overload candidate will be new to the overload set.
void AddDeferredConversionTemplateCandidate(FunctionTemplateDecl *FunctionTemplate, DeclAccessPair FoundDecl, CXXRecordDecl *ActingContext, Expr *From, QualType ToType, bool AllowObjCConversionOnExplicit, bool AllowExplicit, bool AllowResultConversion)
void AddDeferredMethodTemplateCandidate(FunctionTemplateDecl *MethodTmpl, DeclAccessPair FoundDecl, CXXRecordDecl *ActingContext, QualType ObjectType, Expr::Classification ObjectClassification, ArrayRef< Expr * > Args, bool SuppressUserConversions, bool PartialOverloading, OverloadCandidateParamOrder PO)
void DisableResolutionByPerfectCandidate()
ConversionSequenceList allocateConversionSequences(unsigned NumConversions)
Allocate storage for conversion sequences for NumConversions conversions.
llvm::MutableArrayRef< Expr * > getPersistentArgsArray(unsigned N)
Provide storage for any Expr* arg that must be preserved until deferred template candidates are deduc...
OperatorRewriteInfo getRewriteInfo() const
bool shouldDeferTemplateArgumentDeduction(const LangOptions &Opts) const
@ CSK_AddressOfOverloadSet
C++ [over.match.call.general] Resolve a call through the address of an overload set.
@ CSK_InitByConstructor
C++ [over.match.ctor], [over.match.list] Initialization of an object of class type by constructor,...
@ CSK_InitByUserDefinedConversion
C++ [over.match.copy]: Copy-initialization of an object of class type by user-defined conversion.
@ CSK_Normal
Normal lookup.
@ CSK_Operator
C++ [over.match.oper]: Lookup of operator function candidates in a call using operator syntax.
SmallVectorImpl< OverloadCandidate >::iterator iterator
void NoteCandidates(PartialDiagnosticAt PA, Sema &S, OverloadCandidateDisplayKind OCD, ArrayRef< Expr * > Args, StringRef Opc="", SourceLocation Loc=SourceLocation(), llvm::function_ref< bool(OverloadCandidate &)> Filter=[](OverloadCandidate &) { return true;})
When overload resolution fails, prints diagnostic messages containing the candidates in the candidate...
bool shouldDeferDiags(Sema &S, ArrayRef< Expr * > Args, SourceLocation OpLoc)
Whether diagnostics should be deferred.
OverloadingResult BestViableFunction(Sema &S, SourceLocation Loc, OverloadCandidateSet::iterator &Best)
Find the best viable function on this overload set, if it exists.
void exclude(Decl *F)
Exclude a function from being considered by overload resolution.
SourceLocation getLocation() const
OverloadCandidate & addCandidate(unsigned NumConversions=0, ConversionSequenceList Conversions={})
Add a new candidate with NumConversions conversion sequence slots to the overload set.
void InjectNonDeducedTemplateCandidates(Sema &S)
CandidateSetKind getKind() const
size_t nonDeferredCandidatesCount() const
SmallVector< OverloadCandidate *, 32 > CompleteCandidates(Sema &S, OverloadCandidateDisplayKind OCD, ArrayRef< Expr * > Args, SourceLocation OpLoc=SourceLocation(), llvm::function_ref< bool(OverloadCandidate &)> Filter=[](OverloadCandidate &) { return true;})
A reference to an overloaded function set, either an UnresolvedLookupExpr or an UnresolvedMemberExpr.
bool hasExplicitTemplateArgs() const
Determines whether this expression had explicit template arguments.
static FindResult find(Expr *E)
Finds the overloaded expression in the given expression E of OverloadTy.
NestedNameSpecifier getQualifier() const
Fetches the nested-name qualifier, if one was given.
SourceLocation getNameLoc() const
Gets the location of the name.
UnresolvedSetImpl::iterator decls_iterator
decls_iterator decls_begin() const
unsigned getNumDecls() const
Gets the number of declarations in the unresolved set.
SourceLocation getTemplateKeywordLoc() const
Retrieve the location of the template keyword preceding this name, if any.
NestedNameSpecifierLoc getQualifierLoc() const
Fetches the nested-name qualifier with source-location information, if one was given.
void copyTemplateArgumentsInto(TemplateArgumentListInfo &List) const
Copies the template arguments into the given structure.
decls_iterator decls_end() const
DeclarationName getName() const
Gets the name looked up.
A single parameter index whose accessors require each use to make explicit the parameter index encodi...
ParenExpr - This represents a parenthesized expression, e.g.
Represents a parameter to a function.
bool hasDefaultArg() const
Determines whether this parameter has a default argument, either parsed or not.
bool isEquivalent(PointerAuthQualifier Other) const
std::string getAsString() const
PointerType - C99 6.7.5.1 - Pointer Declarators.
QualType getPointeeType() const
static PseudoObjectExpr * Create(const ASTContext &Context, Expr *syntactic, ArrayRef< Expr * > semantic, unsigned resultIndex)
A (possibly-)qualified type.
bool isVolatileQualified() const
Determine whether this type is volatile-qualified.
bool isRestrictQualified() const
Determine whether this type is restrict-qualified.
bool hasQualifiers() const
Determine whether this type has any qualifiers.
QualType getNonLValueExprType(const ASTContext &Context) const
Determine the type of a (typically non-lvalue) expression with the specified result type.
QualType getLocalUnqualifiedType() const
Return this type with all of the instance-specific qualifiers removed, but without removing any quali...
bool isNull() const
Return true if this QualType doesn't point to a type yet.
const Type * getTypePtr() const
Retrieves a pointer to the underlying (unqualified) type.
LangAS getAddressSpace() const
Return the address space of this type.
Qualifiers getQualifiers() const
Retrieve the set of qualifiers applied to this type.
void getAsStringInternal(std::string &Str, const PrintingPolicy &Policy) const
QualType getNonReferenceType() const
If Type is a reference type (e.g., const int&), returns the type that the reference refers to ("const...
QualType getCanonicalType() const
QualType getUnqualifiedType() const
Retrieve the unqualified variant of the given type, removing as little sugar as possible.
unsigned getLocalCVRQualifiers() const
Retrieve the set of CVR (const-volatile-restrict) qualifiers local to this particular QualType instan...
bool isMoreQualifiedThan(QualType Other, const ASTContext &Ctx) const
Determine whether this type is more qualified than the other given type, requiring exact equality for...
bool isConstQualified() const
Determine whether this type is const-qualified.
bool hasAddressSpace() const
Check if this type has any address space qualifier.
unsigned getCVRQualifiers() const
Retrieve the set of CVR (const-volatile-restrict) qualifiers applied to this type.
static std::string getAsString(SplitQualType split, const PrintingPolicy &Policy)
bool isAtLeastAsQualifiedAs(QualType Other, const ASTContext &Ctx) const
Determine whether this type is at least as qualified as the other given type, requiring exact equalit...
Qualifiers getLocalQualifiers() const
Retrieve the set of qualifiers local to this particular QualType instance, not including any qualifie...
A qualifier set is used to build a set of qualifiers.
const Type * strip(QualType type)
Collect any qualifiers on the given type and return an unqualified type.
QualType apply(const ASTContext &Context, QualType QT) const
Apply the collected qualifiers to the given type.
QualifiersAndAtomic withVolatile()
QualifiersAndAtomic withAtomic()
The collection of all-type qualifiers we support.
unsigned getCVRQualifiers() const
bool hasOnlyConst() const
@ OCL_ExplicitNone
This object can be modified without requiring retains or releases.
void removeObjCLifetime()
bool compatiblyIncludes(Qualifiers other, const ASTContext &Ctx) const
Determines if these qualifiers compatibly include another set.
static bool isAddressSpaceSupersetOf(LangAS A, LangAS B, const ASTContext &Ctx)
Returns true if address space A is equal to or a superset of B.
void removeAddressSpace()
void setAddressSpace(LangAS space)
PointerAuthQualifier getPointerAuth() const
bool hasObjCGCAttr() const
ObjCLifetime getObjCLifetime() const
std::string getAsString() const
LangAS getAddressSpace() const
bool compatiblyIncludesObjCLifetime(Qualifiers other) const
Determines if these qualifiers compatibly include another set of qualifiers from the narrow perspecti...
An rvalue reference type, per C++11 [dcl.ref].
Represents a struct/union/class.
field_range fields() const
Base for LValueReferenceType and RValueReferenceType.
QualType getPointeeType() const
Scope - A scope is a transient data structure that is used while parsing the program.
Smart pointer class that efficiently represents Objective-C method names.
unsigned getNumArgs() const
bool areCompatibleSveTypes(QualType FirstType, QualType SecondType)
Return true if the given types are an SVE builtin and a VectorType that is a fixed-length representat...
bool areLaxCompatibleSveTypes(QualType FirstType, QualType SecondType)
Return true if the given vector types are lax-compatible SVE vector types, false otherwise.
PartialDiagnostic PDiag(unsigned DiagID=0)
Build a partial diagnostic.
SemaDiagnosticBuilder Diag(SourceLocation Loc, unsigned DiagID)
Emit a diagnostic.
bool IsAllowedCall(const FunctionDecl *Caller, const FunctionDecl *Callee)
Determines whether Caller may invoke Callee, based on their CUDA host/device attributes.
CUDAFunctionTarget IdentifyTarget(const FunctionDecl *D, bool IgnoreImplicitHDAttr=false)
Determines whether the given function is a CUDA device/host/kernel/etc.
bool inferTargetForImplicitSpecialMember(CXXRecordDecl *ClassDecl, CXXSpecialMemberKind CSM, CXXMethodDecl *MemberDecl, bool ConstRHS, bool Diagnose)
Given a implicit special member, infer its CUDA target from the calls it needs to make to underlying ...
static bool isImplicitHostDeviceFunction(const FunctionDecl *D)
void EraseUnwantedMatches(const FunctionDecl *Caller, llvm::SmallVectorImpl< std::pair< DeclAccessPair, FunctionDecl * > > &Matches)
Finds a function in Matches with highest calling priority from Caller context and erases all function...
CUDAFunctionPreference IdentifyPreference(const FunctionDecl *Caller, const FunctionDecl *Callee)
Identifies relative preference of a given Caller/Callee combination, based on their host/device attri...
bool isObjCWritebackConversion(QualType FromType, QualType ToType, QualType &ConvertedType)
Determine whether this is an Objective-C writeback conversion, used for parameter passing when perfor...
Expr * stripARCUnbridgedCast(Expr *e)
stripARCUnbridgedCast - Given an expression of ARCUnbridgedCast type, remove the placeholder cast.
Abstract base class used to perform a contextual implicit conversion from an expression to any type p...
virtual SemaDiagnosticBuilder noteAmbiguous(Sema &S, CXXConversionDecl *Conv, QualType ConvTy)=0
Emits a note for one of the candidate conversions.
virtual SemaDiagnosticBuilder diagnoseNoMatch(Sema &S, SourceLocation Loc, QualType T)=0
Emits a diagnostic complaining that the expression does not have integral or enumeration type.
virtual SemaDiagnosticBuilder noteExplicitConv(Sema &S, CXXConversionDecl *Conv, QualType ConvTy)=0
Emits a note for the explicit conversion function.
virtual SemaDiagnosticBuilder diagnoseExplicitConv(Sema &S, SourceLocation Loc, QualType T, QualType ConvTy)=0
Emits a diagnostic when the only matching conversion function is explicit.
virtual SemaDiagnosticBuilder diagnoseConversion(Sema &S, SourceLocation Loc, QualType T, QualType ConvTy)=0
Emits a diagnostic when we picked a conversion function (for cases when we are not allowed to pick a ...
virtual SemaDiagnosticBuilder diagnoseAmbiguous(Sema &S, SourceLocation Loc, QualType T)=0
Emits a diagnostic when there are multiple possible conversion functions.
virtual bool match(QualType T)=0
Determine whether the specified type is a valid destination type for this conversion.
virtual SemaDiagnosticBuilder diagnoseIncomplete(Sema &S, SourceLocation Loc, QualType T)=0
Emits a diagnostic when the expression has incomplete class type.
For a defaulted function, the kind of defaulted function that it is.
bool isSpecialMember() const
bool isComparison() const
CXXSpecialMemberKind asSpecialMember() const
RAII class to control scope of DeferDiags.
A class which encapsulates the logic for delaying diagnostics during parsing and other processing.
DelayedDiagnosticsState pushUndelayed()
Enter a new scope where access and deprecation diagnostics are not delayed.
bool match(QualType T) override
Match an integral or (possibly scoped) enumeration type.
RAII class used to determine whether SFINAE has trapped any errors that occur during template argumen...
bool hasErrorOccurred() const
Determine whether any SFINAE errors have been trapped.
Sema - This implements semantic analysis and AST building for C.
bool TryFunctionConversion(QualType FromType, QualType ToType, QualType &ResultTy) const
Same as IsFunctionConversion, but if this would return true, it sets ResultTy to ToType.
QualType getCurrentThisType()
Try to retrieve the type of the 'this' pointer.
ExprResult BuildBlockForLambdaConversion(SourceLocation CurrentLocation, SourceLocation ConvLocation, CXXConversionDecl *Conv, Expr *Src)
bool diagnoseArgDependentDiagnoseIfAttrs(const FunctionDecl *Function, const Expr *ThisArg, ArrayRef< const Expr * > Args, SourceLocation Loc)
Emit diagnostics for the diagnose_if attributes on Function, ignoring any non-ArgDependent DiagnoseIf...
ExprResult PerformContextuallyConvertToObjCPointer(Expr *From)
PerformContextuallyConvertToObjCPointer - Perform a contextual conversion of the expression From to a...
bool buildOverloadedCallSet(Scope *S, Expr *Fn, UnresolvedLookupExpr *ULE, MultiExprArg Args, SourceLocation RParenLoc, OverloadCandidateSet *CandidateSet, ExprResult *Result)
Constructs and populates an OverloadedCandidateSet from the given function.
void HideUsingShadowDecl(Scope *S, UsingShadowDecl *Shadow)
Hides a using shadow declaration.
bool IsBuildingRecoveryCallExpr
Flag indicating if Sema is building a recovery call expression.
DefaultedFunctionKind getDefaultedFunctionKind(const FunctionDecl *FD)
Determine the kind of defaulting that would be done for a given function.
ExprResult BuildMemberReferenceExpr(Expr *Base, QualType BaseType, SourceLocation OpLoc, bool IsArrow, CXXScopeSpec &SS, SourceLocation TemplateKWLoc, NamedDecl *FirstQualifierInScope, const DeclarationNameInfo &NameInfo, const TemplateArgumentListInfo *TemplateArgs, const Scope *S, ActOnMemberAccessExtraArgs *ExtraArgs=nullptr)
bool IsOverload(FunctionDecl *New, FunctionDecl *Old, bool UseMemberUsingDeclRules, bool ConsiderCudaAttrs=true)
ExprResult CreateBuiltinUnaryOp(SourceLocation OpLoc, UnaryOperatorKind Opc, Expr *InputExpr, bool IsAfterAmp=false)
@ LookupOrdinaryName
Ordinary name lookup, which finds ordinary names (functions, variables, typedefs, etc....
@ LookupUsingDeclName
Look up all declarations in a scope with the given name, including resolved using declarations.
@ LookupOperatorName
Look up of an operator name (e.g., operator+) for use with operator overloading.
@ LookupMemberName
Member name lookup, which finds the names of class/struct/union members.
void DiagnoseSentinelCalls(const NamedDecl *D, SourceLocation Loc, ArrayRef< Expr * > Args)
DiagnoseSentinelCalls - This routine checks whether a call or message-send is to a declaration with t...
ImplicitConversionSequence TryImplicitConversion(Expr *From, QualType ToType, bool SuppressUserConversions, AllowedExplicit AllowExplicit, bool InOverloadResolution, bool CStyle, bool AllowObjCWritebackConversion)
ExprResult BuildLiteralOperatorCall(LookupResult &R, DeclarationNameInfo &SuffixInfo, ArrayRef< Expr * > Args, SourceLocation LitEndLoc, TemplateArgumentListInfo *ExplicitTemplateArgs=nullptr)
BuildLiteralOperatorCall - Build a UserDefinedLiteral by creating a call to a literal operator descri...
bool IsStringInit(Expr *Init, const ArrayType *AT)
ExprResult CreateBuiltinBinOp(SourceLocation OpLoc, BinaryOperatorKind Opc, Expr *LHSExpr, Expr *RHSExpr, bool ForFoldExpression=false)
CreateBuiltinBinOp - Creates a new built-in binary operation with operator Opc at location TokLoc.
ExprResult CreateOverloadedArraySubscriptExpr(SourceLocation LLoc, SourceLocation RLoc, Expr *Base, MultiExprArg Args)
void LookupOverloadedBinOp(OverloadCandidateSet &CandidateSet, OverloadedOperatorKind Op, const UnresolvedSetImpl &Fns, ArrayRef< Expr * > Args, bool RequiresADL=true)
Perform lookup for an overloaded binary operator.
bool isImplicitlyDeleted(FunctionDecl *FD)
Determine whether the given function is an implicitly-deleted special member function.
void PushExpressionEvaluationContext(ExpressionEvaluationContext NewContext, Decl *LambdaContextDecl=nullptr, ExpressionEvaluationContextRecord::ExpressionKind Type=ExpressionEvaluationContextRecord::EK_Other)
bool TemplateParameterListsAreEqual(const TemplateCompareNewDeclInfo &NewInstFrom, TemplateParameterList *New, const NamedDecl *OldInstFrom, TemplateParameterList *Old, bool Complain, TemplateParameterListEqualKind Kind, SourceLocation TemplateArgLoc=SourceLocation())
Determine whether the given template parameter lists are equivalent.
ReferenceCompareResult
ReferenceCompareResult - Expresses the result of comparing two types (cv1 T1 and cv2 T2) to determine...
@ Ref_Incompatible
Ref_Incompatible - The two types are incompatible, so direct reference binding is not possible.
@ Ref_Compatible
Ref_Compatible - The two types are reference-compatible.
@ Ref_Related
Ref_Related - The two types are reference-related, which means that their unqualified forms (T1 and T...
void AddTemplateConversionCandidate(FunctionTemplateDecl *FunctionTemplate, DeclAccessPair FoundDecl, CXXRecordDecl *ActingContext, Expr *From, QualType ToType, OverloadCandidateSet &CandidateSet, bool AllowObjCConversionOnExplicit, bool AllowExplicit, bool AllowResultConversion=true)
Adds a conversion function template specialization candidate to the overload set, using template argu...
FunctionDecl * getMoreConstrainedFunction(FunctionDecl *FD1, FunctionDecl *FD2)
Returns the more constrained function according to the rules of partial ordering by constraints (C++ ...
void AddBuiltinCandidate(QualType *ParamTys, ArrayRef< Expr * > Args, OverloadCandidateSet &CandidateSet, bool IsAssignmentOperator=false, unsigned NumContextualBoolArguments=0)
AddBuiltinCandidate - Add a candidate for a built-in operator.
ExprResult MaybeBindToTemporary(Expr *E)
MaybeBindToTemporary - If the passed in expression has a record type with a non-trivial destructor,...
void AddArgumentDependentLookupCandidates(DeclarationName Name, SourceLocation Loc, ArrayRef< Expr * > Args, TemplateArgumentListInfo *ExplicitTemplateArgs, OverloadCandidateSet &CandidateSet, bool PartialOverloading=false)
Add function candidates found via argument-dependent lookup to the set of overloading candidates.
ExprResult EvaluateConvertedConstantExpression(Expr *E, QualType T, APValue &Value, CCEKind CCE, bool RequireInt, const APValue &PreNarrowingValue)
EvaluateConvertedConstantExpression - Evaluate an Expression That is a converted constant expression ...
FPOptionsOverride CurFPFeatureOverrides()
ExprResult BuildOverloadedArrowExpr(Scope *S, Expr *Base, SourceLocation OpLoc, bool *NoArrowOperatorFound=nullptr)
BuildOverloadedArrowExpr - Build a call to an overloaded operator-> (if one exists),...
ExprResult BuildCallToMemberFunction(Scope *S, Expr *MemExpr, SourceLocation LParenLoc, MultiExprArg Args, SourceLocation RParenLoc, Expr *ExecConfig=nullptr, bool IsExecConfig=false, bool AllowRecovery=false)
BuildCallToMemberFunction - Build a call to a member function.
AssignConvertType CheckSingleAssignmentConstraints(QualType LHSType, ExprResult &RHS, bool Diagnose=true, bool DiagnoseCFAudited=false, bool ConvertRHS=true)
Check assignment constraints for an assignment of RHS to LHSType.
FunctionDecl * getCurFunctionDecl(bool AllowLambda=false) const
Returns a pointer to the innermost enclosing function, or nullptr if the current context is not insid...
ExprResult PerformContextualImplicitConversion(SourceLocation Loc, Expr *FromE, ContextualImplicitConverter &Converter)
Perform a contextual implicit conversion.
ExprResult DefaultVariadicArgumentPromotion(Expr *E, VariadicCallType CT, FunctionDecl *FDecl)
bool DeduceReturnType(FunctionDecl *FD, SourceLocation Loc, bool Diagnose=true)
bool IsQualificationConversion(QualType FromType, QualType ToType, bool CStyle, bool &ObjCLifetimeConversion)
IsQualificationConversion - Determines whether the conversion from an rvalue of type FromType to ToTy...
void diagnoseNullableToNonnullConversion(QualType DstType, QualType SrcType, SourceLocation Loc)
Warn if we're implicitly casting from a _Nullable pointer type to a _Nonnull one.
bool DiagnoseUseOfDecl(NamedDecl *D, ArrayRef< SourceLocation > Locs, const ObjCInterfaceDecl *UnknownObjCClass=nullptr, bool ObjCPropertyAccess=false, bool AvoidPartialAvailabilityChecks=false, ObjCInterfaceDecl *ClassReceiver=nullptr, bool SkipTrailingRequiresClause=false)
Determine whether the use of this declaration is valid, and emit any corresponding diagnostics.
DiagnosticsEngine & getDiagnostics() const
bool checkAddressOfFunctionIsAvailable(const FunctionDecl *Function, bool Complain=false, SourceLocation Loc=SourceLocation())
Returns whether the given function's address can be taken or not, optionally emitting a diagnostic if...
bool CheckNonDependentConversions(FunctionTemplateDecl *FunctionTemplate, ArrayRef< QualType > ParamTypes, ArrayRef< Expr * > Args, OverloadCandidateSet &CandidateSet, ConversionSequenceList &Conversions, CheckNonDependentConversionsFlag UserConversionFlag, CXXRecordDecl *ActingContext=nullptr, QualType ObjectType=QualType(), Expr::Classification ObjectClassification={}, OverloadCandidateParamOrder PO={})
Check that implicit conversion sequences can be formed for each argument whose corresponding paramete...
bool isObjCPointerConversion(QualType FromType, QualType ToType, QualType &ConvertedType, bool &IncompatibleObjC)
isObjCPointerConversion - Determines whether this is an Objective-C pointer conversion.
FunctionDecl * ResolveAddressOfOverloadedFunction(Expr *AddressOfExpr, QualType TargetType, bool Complain, DeclAccessPair &Found, bool *pHadMultipleCandidates=nullptr)
ResolveAddressOfOverloadedFunction - Try to resolve the address of an overloaded function (C++ [over....
bool FunctionParamTypesAreEqual(ArrayRef< QualType > Old, ArrayRef< QualType > New, unsigned *ArgPos=nullptr, bool Reversed=false)
FunctionParamTypesAreEqual - This routine checks two function proto types for equality of their param...
ExprResult PerformImplicitObjectArgumentInitialization(Expr *From, NestedNameSpecifier Qualifier, NamedDecl *FoundDecl, CXXMethodDecl *Method)
PerformObjectArgumentInitialization - Perform initialization of the implicit object parameter for the...
ExprResult DefaultFunctionArrayLvalueConversion(Expr *E, bool Diagnose=true)
ASTContext & getASTContext() const
UnresolvedSetIterator getMostSpecialized(UnresolvedSetIterator SBegin, UnresolvedSetIterator SEnd, TemplateSpecCandidateSet &FailedCandidates, SourceLocation Loc, const PartialDiagnostic &NoneDiag, const PartialDiagnostic &AmbigDiag, const PartialDiagnostic &CandidateDiag, bool Complain=true, QualType TargetType=QualType())
Retrieve the most specialized of the given function template specializations.
bool IsIntegralPromotion(Expr *From, QualType FromType, QualType ToType)
IsIntegralPromotion - Determines whether the conversion from the expression From (whose potentially-a...
bool IsFloatingPointPromotion(QualType FromType, QualType ToType)
IsFloatingPointPromotion - Determines whether the conversion from FromType to ToType is a floating po...
ExprResult BuildTemplateIdExpr(const CXXScopeSpec &SS, SourceLocation TemplateKWLoc, LookupResult &R, bool RequiresADL, const TemplateArgumentListInfo *TemplateArgs)
void PopExpressionEvaluationContext()
ExprResult CreateOverloadedBinOp(SourceLocation OpLoc, BinaryOperatorKind Opc, const UnresolvedSetImpl &Fns, Expr *LHS, Expr *RHS, bool RequiresADL=true, bool AllowRewrittenCandidates=true, FunctionDecl *DefaultedFn=nullptr)
Create a binary operation that may resolve to an overloaded operator.
ExprResult ImpCastExprToType(Expr *E, QualType Type, CastKind CK, ExprValueKind VK=VK_PRValue, const CXXCastPath *BasePath=nullptr, CheckedConversionKind CCK=CheckedConversionKind::Implicit)
ImpCastExprToType - If Expr is not of type 'Type', insert an implicit cast.
bool FunctionNonObjectParamTypesAreEqual(const FunctionDecl *OldFunction, const FunctionDecl *NewFunction, unsigned *ArgPos=nullptr, bool Reversed=false)
bool isInitListConstructor(const FunctionDecl *Ctor)
Determine whether Ctor is an initializer-list constructor, as defined in [dcl.init....
llvm::SmallSetVector< CXXRecordDecl *, 16 > AssociatedClassSet
std::string getAmbiguousPathsDisplayString(CXXBasePaths &Paths)
Builds a string representing ambiguous paths from a specific derived class to different subobjects of...
AccessResult CheckMemberOperatorAccess(SourceLocation Loc, Expr *ObjectExpr, const SourceRange &, DeclAccessPair FoundDecl)
OverloadKind CheckOverload(Scope *S, FunctionDecl *New, const LookupResult &OldDecls, NamedDecl *&OldDecl, bool UseMemberUsingDeclRules)
Determine whether the given New declaration is an overload of the declarations in Old.
QualType ExtractUnqualifiedFunctionType(QualType PossiblyAFunctionType)
bool IsPointerConversion(Expr *From, QualType FromType, QualType ToType, bool InOverloadResolution, QualType &ConvertedType, bool &IncompatibleObjC)
IsPointerConversion - Determines whether the conversion of the expression From, which has the (possib...
@ Conversions
Allow explicit conversion functions but not explicit constructors.
void DiagnoseUseOfDeletedFunction(SourceLocation Loc, SourceRange Range, DeclarationName Name, OverloadCandidateSet &CandidateSet, FunctionDecl *Fn, MultiExprArg Args, bool IsMember=false)
PrintingPolicy getPrintingPolicy() const
Retrieve a suitable printing policy for diagnostics.
bool IsComplexPromotion(QualType FromType, QualType ToType)
Determine if a conversion is a complex promotion.
bool pushCodeSynthesisContext(CodeSynthesisContext Ctx)
Module * getOwningModule(const Decl *Entity)
Get the module owning an entity.
DeclRefExpr * BuildDeclRefExpr(ValueDecl *D, QualType Ty, ExprValueKind VK, SourceLocation Loc, const CXXScopeSpec *SS=nullptr)
ExprResult CheckConvertedConstantExpression(Expr *From, QualType T, llvm::APSInt &Value, CCEKind CCE)
@ TPL_TemplateMatch
We are matching the template parameter lists of two templates that might be redeclarations.
void AddConversionCandidate(CXXConversionDecl *Conversion, DeclAccessPair FoundDecl, CXXRecordDecl *ActingContext, Expr *From, QualType ToType, OverloadCandidateSet &CandidateSet, bool AllowObjCConversionOnExplicit, bool AllowExplicit, bool AllowResultConversion=true, bool StrictPackMatch=false)
AddConversionCandidate - Add a C++ conversion function as a candidate in the candidate set (C++ [over...
bool IsBlockPointerConversion(QualType FromType, QualType ToType, QualType &ConvertedType)
bool CheckFunctionTemplateSpecialization(FunctionDecl *FD, TemplateArgumentListInfo *ExplicitTemplateArgs, LookupResult &Previous, bool QualifiedFriend=false)
Perform semantic analysis for the given function template specialization.
void FindAssociatedClassesAndNamespaces(SourceLocation InstantiationLoc, ArrayRef< Expr * > Args, AssociatedNamespaceSet &AssociatedNamespaces, AssociatedClassSet &AssociatedClasses)
Find the associated classes and namespaces for argument-dependent lookup for a call with the given se...
void AddMethodTemplateCandidate(FunctionTemplateDecl *MethodTmpl, DeclAccessPair FoundDecl, CXXRecordDecl *ActingContext, TemplateArgumentListInfo *ExplicitTemplateArgs, QualType ObjectType, Expr::Classification ObjectClassification, ArrayRef< Expr * > Args, OverloadCandidateSet &CandidateSet, bool SuppressUserConversions=false, bool PartialOverloading=false, OverloadCandidateParamOrder PO={})
Add a C++ member function template as a candidate to the candidate set, using template argument deduc...
void DiagnoseSelfMove(const Expr *LHSExpr, const Expr *RHSExpr, SourceLocation OpLoc)
DiagnoseSelfMove - Emits a warning if a value is moved to itself.
bool isSameOrCompatibleFunctionType(QualType Param, QualType Arg)
Compare types for equality with respect to possibly compatible function types (noreturn adjustment,...
void AddTemplateOverloadCandidate(FunctionTemplateDecl *FunctionTemplate, DeclAccessPair FoundDecl, TemplateArgumentListInfo *ExplicitTemplateArgs, ArrayRef< Expr * > Args, OverloadCandidateSet &CandidateSet, bool SuppressUserConversions=false, bool PartialOverloading=false, bool AllowExplicit=true, ADLCallKind IsADLCandidate=ADLCallKind::NotADL, OverloadCandidateParamOrder PO={}, bool AggregateCandidateDeduction=false)
Add a C++ function template specialization as a candidate in the candidate set, using template argume...
Sema(Preprocessor &pp, ASTContext &ctxt, ASTConsumer &consumer, TranslationUnitKind TUKind=TU_Complete, CodeCompleteConsumer *CompletionConsumer=nullptr)
SourceLocation getLocForEndOfToken(SourceLocation Loc, unsigned Offset=0)
Calls Lexer::getLocForEndOfToken()
const LangOptions & getLangOpts() const
const FunctionProtoType * ResolveExceptionSpec(SourceLocation Loc, const FunctionProtoType *FPT)
bool isEquivalentInternalLinkageDeclaration(const NamedDecl *A, const NamedDecl *B)
Determine if A and B are equivalent internal linkage declarations from different modules,...
bool DiagnoseEmptyLookup(Scope *S, CXXScopeSpec &SS, LookupResult &R, CorrectionCandidateCallback &CCC, TemplateArgumentListInfo *ExplicitTemplateArgs=nullptr, ArrayRef< Expr * > Args={}, DeclContext *LookupCtx=nullptr)
Diagnose an empty lookup.
ExprResult BuildCallExpr(Scope *S, Expr *Fn, SourceLocation LParenLoc, MultiExprArg ArgExprs, SourceLocation RParenLoc, Expr *ExecConfig=nullptr, bool IsExecConfig=false, bool AllowRecovery=false)
BuildCallExpr - Handle a call to Fn with the specified array of arguments.
ExprResult BuildSynthesizedThreeWayComparison(SourceLocation OpLoc, const UnresolvedSetImpl &Fns, Expr *LHS, Expr *RHS, FunctionDecl *DefaultedFn)
AccessResult CheckBaseClassAccess(SourceLocation AccessLoc, QualType Base, QualType Derived, const CXXBasePath &Path, unsigned DiagID, bool ForceCheck=false, bool ForceUnprivileged=false)
Checks access for a hierarchy conversion.
bool CheckUseOfCXXMethodAsAddressOfOperand(SourceLocation OpLoc, const Expr *Op, const CXXMethodDecl *MD)
AccessResult CheckUnresolvedMemberAccess(UnresolvedMemberExpr *E, DeclAccessPair FoundDecl)
Perform access-control checking on a previously-unresolved member access which has now been resolved ...
void AddBuiltinOperatorCandidates(OverloadedOperatorKind Op, SourceLocation OpLoc, ArrayRef< Expr * > Args, OverloadCandidateSet &CandidateSet)
AddBuiltinOperatorCandidates - Add the appropriate built-in operator overloads to the candidate set (...
void AddOverloadCandidate(FunctionDecl *Function, DeclAccessPair FoundDecl, ArrayRef< Expr * > Args, OverloadCandidateSet &CandidateSet, bool SuppressUserConversions=false, bool PartialOverloading=false, bool AllowExplicit=true, bool AllowExplicitConversion=false, ADLCallKind IsADLCandidate=ADLCallKind::NotADL, ConversionSequenceList EarlyConversions={}, OverloadCandidateParamOrder PO={}, bool AggregateCandidateDeduction=false, bool StrictPackMatch=false)
AddOverloadCandidate - Adds the given function to the set of candidate functions, using the given fun...
const LangOptions & LangOpts
bool IsMemberPointerConversion(Expr *From, QualType FromType, QualType ToType, bool InOverloadResolution, QualType &ConvertedType)
IsMemberPointerConversion - Determines whether the conversion of the expression From,...
ExprResult BuildResolvedCallExpr(Expr *Fn, NamedDecl *NDecl, SourceLocation LParenLoc, ArrayRef< Expr * > Arg, SourceLocation RParenLoc, Expr *Config=nullptr, bool IsExecConfig=false, ADLCallKind UsesADL=ADLCallKind::NotADL)
BuildResolvedCallExpr - Build a call to a resolved expression, i.e.
ExprResult BuildCXXMemberCallExpr(Expr *Exp, NamedDecl *FoundDecl, CXXConversionDecl *Method, bool HadMultipleCandidates)
ExprResult CheckForImmediateInvocation(ExprResult E, FunctionDecl *Decl)
Wrap the expression in a ConstantExpr if it is a potential immediate invocation.
llvm::SmallSetVector< DeclContext *, 16 > AssociatedNamespaceSet
MemberPointerConversionDirection
bool diagnoseArgIndependentDiagnoseIfAttrs(const NamedDecl *ND, SourceLocation Loc)
Emit diagnostics for the diagnose_if attributes on Function, ignoring any ArgDependent DiagnoseIfAttr...
ExprResult BuildConvertedConstantExpression(Expr *From, QualType T, CCEKind CCE, NamedDecl *Dest=nullptr)
void popCodeSynthesisContext()
bool AreConstraintExpressionsEqual(const NamedDecl *Old, const Expr *OldConstr, const TemplateCompareNewDeclInfo &New, const Expr *NewConstr)
ReferenceConversionsScope::ReferenceConversions ReferenceConversions
MemberPointerConversionResult CheckMemberPointerConversion(QualType FromType, const MemberPointerType *ToPtrType, CastKind &Kind, CXXCastPath &BasePath, SourceLocation CheckLoc, SourceRange OpRange, bool IgnoreBaseAccess, MemberPointerConversionDirection Direction)
CheckMemberPointerConversion - Check the member pointer conversion from the expression From to the ty...
Expr * BuildCXXThisExpr(SourceLocation Loc, QualType Type, bool IsImplicit)
Build a CXXThisExpr and mark it referenced in the current context.
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)
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.
unsigned QualificationIncludesObjCLifetime
Whether the qualification conversion involves a change in the Objective-C lifetime (for automatic ref...
void setToType(unsigned Idx, QualType T)
bool isPointerConversionToBool() const
isPointerConversionToBool - Determines whether this conversion is a conversion of a pointer or pointe...
void * ToTypePtrs[3]
ToType - The types that this conversion is converting to in each step.
NarrowingKind getNarrowingKind(ASTContext &Context, const Expr *Converted, APValue &ConstantValue, QualType &ConstantType, bool IgnoreFloatToIntegralConversion=false) const
Check if this standard conversion sequence represents a narrowing conversion, according to C++11 [dcl...
unsigned IsLvalueReference
Whether this is an lvalue reference binding (otherwise, it's an rvalue reference binding).
ImplicitConversionKind Dimension
Dimension - Between the second and third conversion a vector or matrix dimension conversion may occur...
unsigned BindsToFunctionLvalue
Whether we're binding to a function lvalue.
unsigned DirectBinding
DirectBinding - True when this is a reference binding that is a direct binding (C++ [dcl....
ImplicitConversionRank getRank() const
getRank - Retrieve the rank of this standard conversion sequence (C++ 13.3.3.1.1p3).
bool isPointerConversionToVoidPointer(ASTContext &Context) const
isPointerConversionToVoidPointer - Determines whether this conversion is a conversion of a pointer to...
void setAllToTypes(QualType T)
unsigned FromBracedInitList
Whether the source expression was originally a single element braced-init-list.
QualType getToType(unsigned Idx) const
SourceLocation getEndLoc() const LLVM_READONLY
SourceRange getSourceRange() const LLVM_READONLY
SourceLocation tokens are not useful in isolation - they are low level value objects created/interpre...
SourceLocation getBeginLoc() const LLVM_READONLY
StringLiteral - This represents a string literal expression, e.g.
StringRef getString() const
const llvm::Triple & getTriple() const
Returns the target triple of the primary target.
virtual bool hasInt128Type() const
Determine whether the __int128 type is supported on this target.
virtual bool hasIbm128Type() const
Determine whether the __ibm128 type is supported on this target.
virtual bool hasFloat128Type() const
Determine whether the __float128 type is supported on this target.
A convenient class for passing around template argument information.
A template argument list.
Represents a template argument.
QualType getNonTypeTemplateArgumentType() const
If this is a non-type template argument, get its type.
QualType getAsType() const
Retrieve the type for a type template argument.
TemplateName getAsTemplate() const
Retrieve the template name for a template name argument.
unsigned pack_size() const
The number of template arguments in the given template argument pack.
@ Template
The template argument is a template name that was provided for a template template parameter.
@ Pack
The template argument is actually a parameter pack.
ArgKind getKind() const
Return the kind of stored template argument.
The base class of all kinds of template declarations (e.g., class, function, etc.).
TemplateParameterList * getTemplateParameters() const
Get the list of template parameters.
Represents a C++ template name within the type system.
TemplateDecl * getAsTemplateDecl(bool IgnoreDeduced=false) const
Retrieve the underlying template declaration that this template name refers to, if known.
@ Template
A single template declaration.
bool hasAssociatedConstraints() const
TemplateSpecCandidateSet - A set of generalized overload candidates, used in template specializations...
SmallVector< TemplateSpecCandidate, 16 >::iterator iterator
void NoteCandidates(Sema &S, SourceLocation Loc)
NoteCandidates - When no template specialization match is found, prints diagnostic messages containin...
void clear()
Clear out all of the candidates.
SourceLocation getLocation() const
TemplateSpecCandidate & addCandidate()
Add a new candidate with NumConversions conversion sequence slots to the overload set.
TemplateTemplateParmDecl - Declares a template template parameter, e.g., "T" in.
Declaration of a template type parameter.
const Type * getTypeForDecl() const
The base class of the type hierarchy.
bool isIncompleteOrObjectType() const
Return true if this is an incomplete or object type, in other words, not a function type.
bool isBlockPointerType() const
bool isBooleanType() const
bool isObjCBuiltinType() const
bool isSignedIntegerOrEnumerationType() const
Determines whether this is an integer type that is signed or an enumeration types whose underlying ty...
bool hasAttr(attr::Kind AK) const
Determine whether this type had the specified attribute applied to it (looking through top-level type...
const RecordType * getAsUnionType() const
NOTE: getAs*ArrayType are methods on ASTContext.
bool isIncompleteArrayType() const
bool isSignedIntegerType() const
Return true if this is an integer type that is signed, according to C99 6.2.5p4 [char,...
bool isFloat16Type() const
bool isComplexType() const
isComplexType() does not include complex integers (a GCC extension).
bool isIntegralOrUnscopedEnumerationType() const
Determine whether this type is an integral or unscoped enumeration type.
bool isRValueReferenceType() const
CXXRecordDecl * getAsCXXRecordDecl() const
Retrieves the CXXRecordDecl that this type refers to, either because the type is a RecordType or beca...
bool isConstantArrayType() const
bool canDecayToPointerType() const
Determines whether this type can decay to a pointer type.
bool isConvertibleToFixedPointType() const
Return true if this can be converted to (or from) a fixed point type.
CXXRecordDecl * castAsCXXRecordDecl() const
bool isArithmeticType() const
bool isPointerType() const
bool isArrayParameterType() const
CanQualType getCanonicalTypeUnqualified() const
bool isIntegerType() const
isIntegerType() does not include complex integers (a GCC extension).
bool isSVESizelessBuiltinType() const
Returns true for SVE scalable vector types.
const T * castAs() const
Member-template castAs<specific type>.
bool isReferenceType() const
bool isEnumeralType() const
bool isIntegralType(const ASTContext &Ctx) const
Determine whether this type is an integral type.
bool isObjCQualifiedIdType() const
QualType getPointeeType() const
If this is a pointer, ObjC object pointer, or block pointer, this returns the respective pointee.
bool isIntegralOrEnumerationType() const
Determine whether this type is an integral or enumeration type.
bool isAnyCharacterType() const
Determine whether this type is any of the built-in character types.
bool isExtVectorBoolType() const
bool isObjCObjectOrInterfaceType() const
bool isInstantiationDependentType() const
Determine whether this type is an instantiation-dependent type, meaning that the type involves a temp...
bool isLValueReferenceType() const
bool isBitIntType() const
bool isDependentType() const
Whether this type is a dependent type, meaning that its definition somehow depends on a template para...
bool isAggregateType() const
Determines whether the type is a C++ aggregate type or C aggregate or union type.
bool isAnyComplexType() const
bool isFixedPointType() const
Return true if this is a fixed point type according to ISO/IEC JTC1 SC22 WG14 N1169.
const BuiltinType * getAsPlaceholderType() const
bool isMemberPointerType() const
bool isObjCIdType() const
bool isMatrixType() const
bool isOverflowBehaviorType() const
bool isUndeducedType() const
Determine whether this type is an undeduced type, meaning that it somehow involves a C++11 'auto' typ...
bool isObjectType() const
Determine whether this type is an object type.
EnumDecl * getAsEnumDecl() const
Retrieves the EnumDecl this type refers to.
bool isBFloat16Type() const
bool isIncompleteType(NamedDecl **Def=nullptr) const
Types are partitioned into 3 broad categories (C99 6.2.5p1): object types, function types,...
bool isFunctionType() const
bool isObjCObjectPointerType() const
bool isVectorType() const
bool isObjCClassType() const
bool isRealFloatingType() const
Floating point categories.
bool isRVVSizelessBuiltinType() const
Returns true for RVV scalable vector types.
const T * getAsCanonical() const
If this type is canonically the specified type, return its canonical type cast to that specified type...
bool isHLSLAttributedResourceType() const
bool isUnsignedIntegerType() const
Return true if this is an integer type that is unsigned, according to C99 6.2.5p6 [which returns true...
bool isAnyPointerType() const
TypeClass getTypeClass() const
const T * getAs() const
Member-template getAs<specific type>'.
const Type * getUnqualifiedDesugaredType() const
Return the specified type with any "sugar" removed from the type, removing any typedefs,...
bool isNullPtrType() const
bool isRecordType() const
UnaryOperator - This represents the unary-expression's (except sizeof and alignof),...
static OverloadedOperatorKind getOverloadedOperator(Opcode Opc)
Retrieve the overloaded operator kind that corresponds to the given unary opcode.
static UnaryOperator * Create(const ASTContext &C, Expr *input, Opcode opc, QualType type, ExprValueKind VK, ExprObjectKind OK, SourceLocation l, bool CanOverflow, FPOptionsOverride FPFeatures)
static StringRef getOpcodeStr(Opcode Op)
getOpcodeStr - Turn an Opcode enum value into the punctuation char it corresponds to,...
A reference to a name which we were able to look up during parsing but could not resolve to a specifi...
bool requiresADL() const
True if this declaration should be extended by argument-dependent lookup.
static UnresolvedLookupExpr * Create(const ASTContext &Context, CXXRecordDecl *NamingClass, NestedNameSpecifierLoc QualifierLoc, const DeclarationNameInfo &NameInfo, bool RequiresADL, UnresolvedSetIterator Begin, UnresolvedSetIterator End, bool KnownDependent, bool KnownInstantiationDependent)
Represents a C++ member access expression for which lookup produced a set of overloaded functions.
DeclarationName getMemberName() const
Retrieve the name of the member that this expression refers to.
QualType getBaseType() const
bool isArrow() const
Determine whether this member expression used the '->' operator; otherwise, it used the '.
Expr * getBase()
Retrieve the base object of this member expressions, e.g., the x in x.m.
SourceLocation getBeginLoc() const LLVM_READONLY
SourceLocation getMemberLoc() const
Retrieve the location of the name of the member that this expression refers to.
A set of unresolved declarations.
ArrayRef< DeclAccessPair > pairs() const
void addDecl(NamedDecl *D)
The iterator over UnresolvedSets.
A set of unresolved declarations.
A call to a literal operator (C++11 [over.literal]) written as a user-defined literal (C++11 [lit....
static UserDefinedLiteral * Create(const ASTContext &Ctx, Expr *Fn, ArrayRef< Expr * > Args, QualType Ty, ExprValueKind VK, SourceLocation LitEndLoc, SourceLocation SuffixLoc, FPOptionsOverride FPFeatures)
unsigned getNumElements() const
QualType getElementType() const
Provides information about an attempted template argument deduction, whose success or failure was des...
TemplateArgumentList * takeSugared()
Take ownership of the deduced template argument lists.
TemplateArgument SecondArg
The second template argument to which the template argument deduction failure refers.
TemplateParameter Param
The template parameter to which a template argument deduction failure refers.
bool hasSFINAEDiagnostic() const
Is a SFINAE diagnostic available?
TemplateArgument FirstArg
The first template argument to which the template argument deduction failure refers.
ConstraintSatisfaction AssociatedConstraintsSatisfaction
The constraint satisfaction details resulting from the associated constraints satisfaction tests.
void takeSFINAEDiagnostic(PartialDiagnosticAt &PD)
Take ownership of the SFINAE diagnostic.
unsigned CallArgIndex
The index of the function argument that caused a deduction failure.
bool hasStrictPackMatch() const
specific_attr_iterator - Iterates over a subrange of an AttrVec, only providing attributes that are o...
Defines the clang::TargetInfo interface.
const internal::VariadicAllOfMatcher< Type > type
Matches Types in the clang AST.
@ Warning
Present this diagnostic as a warning.
@ Error
Present this diagnostic as an error.
PRESERVE_NONE bool Ret(InterpState &S, CodePtr &PC)
void checkAssignmentLifetime(Sema &SemaRef, const AssignedEntity &Entity, Expr *Init)
Check that the lifetime of the given expr (and its subobjects) is sufficient for assigning to the ent...
The JSON file list parser is used to communicate input to InstallAPI.
ImplicitConversionRank GetDimensionConversionRank(ImplicitConversionRank Base, ImplicitConversionKind Dimension)
CanQual< Type > CanQualType
Represents a canonical, potentially-qualified type.
OverloadedOperatorKind
Enumeration specifying the different kinds of C++ overloaded operators.
@ OO_None
Not an overloaded operator.
@ NUM_OVERLOADED_OPERATORS
@ NonFunction
This is not an overload because the lookup results contain a non-function.
@ Match
This is not an overload because the signature exactly matches an existing declaration.
@ Overload
This is a legitimate overload: the existing declarations are functions or function templates with dif...
bool isa(CodeGen::Address addr)
OverloadingResult
OverloadingResult - Capture the result of performing overload resolution.
@ OR_Deleted
Succeeded, but refers to a deleted function.
@ OR_Success
Overload resolution succeeded.
@ OR_Ambiguous
Ambiguous candidates found.
@ OR_No_Viable_Function
No viable function found.
@ Specialization
We are substituting template parameters for template arguments in order to form a template specializa...
bool isBetterOverloadCandidate(Sema &S, const OverloadCandidate &Cand1, const OverloadCandidate &Cand2, SourceLocation Loc, OverloadCandidateSet::CandidateSetKind Kind, bool PartialOverloading=false)
isBetterOverloadCandidate - Determines whether the first overload candidate is a better candidate tha...
bool isUnresolvedExceptionSpec(ExceptionSpecificationType ESpecType)
@ ovl_fail_final_conversion_not_exact
This conversion function template specialization candidate is not viable because the final conversion...
@ ovl_fail_enable_if
This candidate function was not viable because an enable_if attribute disabled it.
@ ovl_fail_illegal_constructor
This conversion candidate was not considered because it is an illegal instantiation of a constructor ...
@ ovl_fail_bad_final_conversion
This conversion candidate is not viable because its result type is not implicitly convertible to the ...
@ ovl_fail_module_mismatched
This candidate was not viable because it has internal linkage and is from a different module unit tha...
@ ovl_fail_too_few_arguments
@ ovl_fail_addr_not_available
This candidate was not viable because its address could not be taken.
@ ovl_fail_too_many_arguments
@ ovl_non_default_multiversion_function
This candidate was not viable because it is a non-default multiversioned function.
@ ovl_fail_constraints_not_satisfied
This candidate was not viable because its associated constraints were not satisfied.
@ ovl_fail_bad_conversion
@ ovl_fail_bad_target
(CUDA) This candidate was not viable because the callee was not accessible from the caller's target (...
@ ovl_fail_inhctor_slice
This inherited constructor is not viable because it would slice the argument.
@ ovl_fail_object_addrspace_mismatch
This constructor/conversion candidate fail due to an address space mismatch between the object being ...
@ ovl_fail_explicit
This candidate constructor or conversion function is explicit but the context doesn't permit explicit...
@ ovl_fail_trivial_conversion
This conversion candidate was not considered because it duplicates the work of a trivial or derived-t...
@ Comparison
A comparison.
@ RQ_None
No ref-qualifier was provided.
@ RQ_LValue
An lvalue ref-qualifier was provided (&).
@ RQ_RValue
An rvalue ref-qualifier was provided (&&).
ImplicitConversionRank
ImplicitConversionRank - The rank of an implicit conversion kind.
@ ICR_Conversion
Conversion.
@ ICR_Writeback_Conversion
ObjC ARC writeback conversion.
@ ICR_HLSL_Dimension_Reduction
HLSL Matching Dimension Reduction.
@ ICR_HLSL_Dimension_Reduction_Conversion
HLSL Dimension reduction with conversion.
@ ICR_HLSL_Scalar_Widening
HLSL Scalar Widening.
@ ICR_C_Conversion
Conversion only allowed in the C standard (e.g. void* to char*).
@ ICR_OCL_Scalar_Widening
OpenCL Scalar Widening.
@ ICR_Complex_Real_Conversion
Complex <-> Real conversion.
@ ICR_HLSL_Scalar_Widening_Conversion
HLSL Scalar Widening with conversion.
@ ICR_HLSL_Dimension_Reduction_Promotion
HLSL Dimension reduction with promotion.
@ ICR_Promotion
Promotion.
@ ICR_Exact_Match
Exact Match.
@ ICR_C_Conversion_Extension
Conversion not allowed by the C standard, but that we accept as an extension anyway.
@ ICR_HLSL_Scalar_Widening_Promotion
HLSL Scalar Widening with promotion.
OverloadCandidateDisplayKind
@ OCD_AmbiguousCandidates
Requests that only tied-for-best candidates be shown.
@ OCD_ViableCandidates
Requests that only viable candidates be shown.
@ OCD_AllCandidates
Requests that all candidates be shown.
@ OK_ObjCProperty
An Objective-C property is a logical field of an Objective-C object which is read and written via Obj...
@ OK_Ordinary
An ordinary object is located at an address in memory.
Expr::ConstantExprKind ConstantExprKind
OverloadCandidateParamOrder
The parameter ordering that will be used for the candidate.
@ Seq
'seq' clause, allowed on 'loop' and 'routine' directives.
nullptr
This class represents a compute construct, representing a 'Kind' of ‘parallel’, 'serial',...
OverloadsShown
Specifies which overload candidates to display when overload resolution fails.
@ Ovl_Best
Show just the "best" overload candidates.
llvm::MutableArrayRef< ImplicitConversionSequence > ConversionSequenceList
A list of implicit conversion sequences for the arguments of an OverloadCandidate.
ComparisonCategoryResult
An enumeration representing the possible results of a three-way comparison.
OverloadCandidateRewriteKind
The kinds of rewrite we perform on overload candidates.
@ CRK_Reversed
Candidate is a rewritten candidate with a reversed order of parameters.
@ CRK_None
Candidate is not a rewritten candidate.
@ CRK_DifferentOperator
Candidate is a rewritten candidate with a different operator name.
MutableArrayRef< Expr * > MultiExprArg
@ Internal
Internal linkage, which indicates that the entity can be referred to from within the translation unit...
@ Result
The result type of a method or function.
ImplicitConversionKind
ImplicitConversionKind - The kind of implicit conversion used to convert an argument to a parameter's...
@ ICK_Complex_Conversion
Complex conversions (C99 6.3.1.6)
@ ICK_Floating_Promotion
Floating point promotions (C++ [conv.fpprom])
@ ICK_Boolean_Conversion
Boolean conversions (C++ [conv.bool])
@ ICK_Integral_Conversion
Integral conversions (C++ [conv.integral])
@ ICK_Fixed_Point_Conversion
Fixed point type conversions according to N1169.
@ ICK_Vector_Conversion
Vector conversions.
@ ICK_Block_Pointer_Conversion
Block Pointer conversions.
@ ICK_Pointer_Member
Pointer-to-member conversions (C++ [conv.mem])
@ ICK_Floating_Integral
Floating-integral conversions (C++ [conv.fpint])
@ ICK_HLSL_Array_RValue
HLSL non-decaying array rvalue cast.
@ ICK_SVE_Vector_Conversion
Arm SVE Vector conversions.
@ ICK_HLSL_Vector_Truncation
HLSL vector truncation.
@ ICK_Incompatible_Pointer_Conversion
C-only conversion between pointers with incompatible types.
@ ICK_Array_To_Pointer
Array-to-pointer conversion (C++ [conv.array])
@ ICK_RVV_Vector_Conversion
RISC-V RVV Vector conversions.
@ ICK_Complex_Promotion
Complex promotions (Clang extension)
@ ICK_Num_Conversion_Kinds
The number of conversion kinds.
@ ICK_HLSL_Matrix_Splat
HLSL matrix splat from scalar or boolean type.
@ ICK_Function_Conversion
Function pointer conversion (C++17 [conv.fctptr])
@ ICK_Vector_Splat
A vector splat from an arithmetic type.
@ ICK_Zero_Queue_Conversion
Zero constant to queue.
@ ICK_Identity
Identity conversion (no conversion)
@ ICK_Derived_To_Base
Derived-to-base (C++ [over.best.ics])
@ ICK_Lvalue_To_Rvalue
Lvalue-to-rvalue conversion (C++ [conv.lval])
@ ICK_Qualification
Qualification conversions (C++ [conv.qual])
@ ICK_Pointer_Conversion
Pointer conversions (C++ [conv.ptr])
@ ICK_TransparentUnionConversion
Transparent Union Conversions.
@ ICK_Integral_Promotion
Integral promotions (C++ [conv.prom])
@ ICK_HLSL_Matrix_Truncation
HLSL Matrix truncation.
@ ICK_Floating_Conversion
Floating point conversions (C++ [conv.double].
@ ICK_Compatible_Conversion
Conversions between compatible types in C99.
@ ICK_C_Only_Conversion
Conversions allowed in C, but not C++.
@ ICK_Writeback_Conversion
Objective-C ARC writeback conversion.
@ ICK_Zero_Event_Conversion
Zero constant to event (OpenCL1.2 6.12.10)
@ ICK_Complex_Real
Complex-real conversions (C99 6.3.1.7)
@ ICK_Function_To_Pointer
Function-to-pointer (C++ [conv.array])
@ Template
We are parsing a template declaration.
ActionResult< CXXBaseSpecifier * > BaseResult
AssignConvertType
AssignConvertType - All of the 'assignment' semantic checks return this enum to indicate whether the ...
@ IncompatiblePointer
IncompatiblePointer - The assignment is between two pointers types that are not compatible,...
@ CompatiblePointerDiscardsQualifiers
CompatiblePointerDiscardsQualifiers - The assignment discards c/v/r qualifiers, which we accept as an...
@ Compatible
Compatible - the types are compatible according to the standard.
@ IncompatiblePointerSign
IncompatiblePointerSign - The assignment is between two pointers types which point to integers which ...
DeductionFailureInfo MakeDeductionFailureInfo(ASTContext &Context, TemplateDeductionResult TDK, sema::TemplateDeductionInfo &Info)
Convert from Sema's representation of template deduction information to the form used in overload-can...
@ FunctionTemplate
The name was classified as a function template name.
LangAS
Defines the address space values used by the address space qualifier of QualType.
CastKind
CastKind - The kind of operation required for a conversion.
CXXSpecialMemberKind
Kinds of C++ special members.
OverloadedOperatorKind getRewrittenOverloadedOperator(OverloadedOperatorKind Kind)
Get the other overloaded operator that the given operator can be rewritten into, if any such operator...
std::pair< SourceLocation, PartialDiagnostic > PartialDiagnosticAt
A partial diagnostic along with the source location where this diagnostic occurs.
ExprValueKind
The categorization of expression values, currently following the C++11 scheme.
@ VK_PRValue
A pr-value expression (in the C++11 taxonomy) produces a temporary value.
@ VK_XValue
An x-value expression is a reference to an object with independent storage but which can be "moved",...
@ VK_LValue
An l-value expression is a reference to an object with independent storage.
bool shouldEnforceArgLimit(bool PartialOverloading, FunctionDecl *Function)
SmallVector< CXXBaseSpecifier *, 4 > CXXCastPath
A simple array of base specifiers.
llvm::PointerUnion< TemplateTypeParmDecl *, NonTypeTemplateParmDecl *, TemplateTemplateParmDecl * > TemplateParameter
Stores a template parameter of any kind.
NarrowingKind
NarrowingKind - The kind of narrowing conversion being performed by a standard conversion sequence ac...
@ NK_Not_Narrowing
Not a narrowing conversion.
@ NK_Constant_Narrowing
A narrowing conversion, because a constant expression got narrowed.
@ NK_Dependent_Narrowing
Cannot tell whether this is a narrowing conversion because the expression is value-dependent.
@ NK_Type_Narrowing
A narrowing conversion by virtue of the source and destination types.
@ NK_Variable_Narrowing
A narrowing conversion, because a non-constant-expression variable might have got narrowed.
@ TPOC_Conversion
Partial ordering of function templates for a call to a conversion function.
@ TPOC_Call
Partial ordering of function templates for a function call.
bool declaresSameEntity(const Decl *D1, const Decl *D2)
Determine whether two declarations declare the same entity.
TemplateDeductionResult
Describes the result of template argument deduction.
@ MiscellaneousDeductionFailure
Deduction failed; that's all we know.
@ NonDependentConversionFailure
Checking non-dependent argument conversions failed.
@ ConstraintsNotSatisfied
The deduced arguments did not satisfy the constraints associated with the template.
@ Underqualified
Template argument deduction failed due to inconsistent cv-qualifiers on a template parameter type tha...
@ InstantiationDepth
Template argument deduction exceeded the maximum template instantiation depth (which has already been...
@ InvalidExplicitArguments
The explicitly-specified template arguments were not valid template arguments for the given template.
@ CUDATargetMismatch
CUDA Target attributes do not match.
@ TooFewArguments
When performing template argument deduction for a function template, there were too few call argument...
@ Incomplete
Template argument deduction did not deduce a value for every template parameter.
@ Invalid
The declaration was invalid; do nothing.
@ Success
Template argument deduction was successful.
@ SubstitutionFailure
Substitution of the deduced template argument values resulted in an error.
@ IncompletePack
Template argument deduction did not deduce a value for every expansion of an expanded template parame...
@ DeducedMismatch
After substituting deduced template arguments, a dependent parameter type did not match the correspon...
@ Inconsistent
Template argument deduction produced inconsistent deduced values for the given template parameter.
@ TooManyArguments
When performing template argument deduction for a function template, there were too many call argumen...
@ AlreadyDiagnosed
Some error which was already diagnosed.
@ DeducedMismatchNested
After substituting deduced template arguments, an element of a dependent parameter type did not match...
@ NonDeducedMismatch
A non-depnedent component of the parameter did not match the corresponding component of the argument.
@ TSK_ExplicitSpecialization
This template specialization was declared or defined by an explicit specialization (C++ [temp....
@ TSK_ImplicitInstantiation
This template specialization was implicitly instantiated from a template.
CallingConv
CallingConv - Specifies the calling convention that a function uses.
const char * getOperatorSpelling(OverloadedOperatorKind Operator)
Retrieve the spelling of the given overloaded operator, without the preceding "operator" keyword.
U cast(CodeGen::Address addr)
ConstructorInfo getConstructorInfo(NamedDecl *ND)
@ None
The alignment was not explicit in code.
CCEKind
Contexts in which a converted constant expression is required.
@ TemplateArg
Value of a non-type template parameter.
@ Noexcept
Condition in a noexcept(bool) specifier.
@ ArrayBound
Array bound in array declarator or new-expression.
@ TempArgStrict
As above, but applies strict template checking rules.
@ ExplicitBool
Condition in an explicit(bool) specifier.
ImplicitConversionRank GetConversionRank(ImplicitConversionKind Kind)
GetConversionRank - Retrieve the implicit conversion rank corresponding to the given implicit convers...
@ Enum
The "enum" keyword introduces the elaborated-type-specifier.
ActionResult< Expr * > ExprResult
@ EST_None
no exception specification
@ ForBuiltinOverloadedOp
A conversion for an operand of a builtin overloaded operator.
__DEVICE__ _Tp abs(const std::complex< _Tp > &__c)
Represents an ambiguous user-defined conversion sequence.
ConversionSet::const_iterator const_iterator
ConversionSet & conversions()
SmallVector< std::pair< NamedDecl *, FunctionDecl * >, 4 > ConversionSet
void setFromType(QualType T)
void setToType(QualType T)
void addConversion(NamedDecl *Found, FunctionDecl *D)
void copyFrom(const AmbiguousConversionSequence &)
const Expr * ConstraintExpr
UnsignedOrNone ArgPackSubstIndex
QualType getToType() const
QualType getFromType() const
OverloadFixItKind Kind
The type of fix applied.
unsigned NumConversionsFixed
The number of Conversions fixed.
void setConversionChecker(TypeComparisonFuncTy Foo)
Resets the default conversion checker method.
std::vector< FixItHint > Hints
The list of Hints generated so far.
DeclarationNameInfo - A collector data type for bundling together a DeclarationName and the correspon...
SourceLocation getLoc() const
getLoc - Returns the main location of the declaration name.
void setCXXOperatorNameRange(SourceRange R)
setCXXOperatorNameRange - Sets the range of the operator name (without the operator keyword).
const DeclarationNameLoc & getInfo() const
SourceLocation getCXXLiteralOperatorNameLoc() const
getCXXLiteralOperatorNameLoc - Returns the location of the literal operator name (not the operator ke...
A structure used to record information about a failed template argument deduction,...
void * Data
Opaque pointer containing additional data about this deduction failure.
const TemplateArgument * getSecondArg()
Return the second template argument this deduction failure refers to, if any.
unsigned Result
A Sema::TemplateDeductionResult.
PartialDiagnosticAt * getSFINAEDiagnostic()
Retrieve the diagnostic which caused this deduction failure, if any.
unsigned HasDiagnostic
Indicates whether a diagnostic is stored in Diagnostic.
TemplateDeductionResult getResult() const
void Destroy()
Free any memory associated with this deduction failure.
char Diagnostic[sizeof(PartialDiagnosticAt)]
A diagnostic indicating why deduction failed.
UnsignedOrNone getCallArgIndex()
Return the index of the call argument that this deduction failure refers to, if any.
TemplateParameter getTemplateParameter()
Retrieve the template parameter this deduction failure refers to, if any.
TemplateArgumentList * getTemplateArgumentList()
Retrieve the template argument list associated with this deduction failure, if any.
const TemplateArgument * getFirstArg()
Return the first template argument this deduction failure refers to, if any.
DeferredTemplateOverloadCandidate * Next
EvalResult is a struct with detailed info about an evaluated expression.
APValue Val
Val - This is the value the expression can be folded to.
SmallVectorImpl< PartialDiagnosticAt > * Diag
Diag - If this is non-null, it will be filled in with a stack of notes indicating why evaluation fail...
Extra information about a function prototype.
FunctionEffectsRef FunctionEffects
const ExtParameterInfo * ExtParameterInfos
Information about operator rewrites to consider when adding operator functions to a candidate set.
bool allowsReversed(OverloadedOperatorKind Op) const
Determine whether reversing parameter order is allowed for operator Op.
bool shouldAddReversed(Sema &S, ArrayRef< Expr * > OriginalArgs, FunctionDecl *FD) const
Determine whether we should add a rewritten candidate for FD with reversed parameter order.
bool isAcceptableCandidate(const FunctionDecl *FD) const
bool isReversible() const
Determines whether this operator could be implemented by a function with reversed parameter order.
SourceLocation OpLoc
The source location of the operator.
bool AllowRewrittenCandidates
Whether we should include rewritten candidates in the overload set.
OverloadCandidateRewriteKind getRewriteKind(const FunctionDecl *FD, OverloadCandidateParamOrder PO)
Determine the kind of rewrite that should be performed for this candidate.
OverloadCandidate - A single candidate in an overload set (C++ 13.3).
unsigned StrictPackMatch
Have we matched any packs on the parameter side, versus any non-packs on the argument side,...
unsigned IgnoreObjectArgument
IgnoreObjectArgument - True to indicate that the first argument's conversion, which for this function...
bool TryToFixBadConversion(unsigned Idx, Sema &S)
bool NotValidBecauseConstraintExprHasError() const
unsigned IsADLCandidate
True if the candidate was found using ADL.
unsigned IsSurrogate
IsSurrogate - True to indicate that this candidate is a surrogate for a conversion to a function poin...
QualType BuiltinParamTypes[3]
BuiltinParamTypes - Provides the parameter types of a built-in overload candidate.
DeclAccessPair FoundDecl
FoundDecl - The original declaration that was looked up / invented / otherwise found,...
FunctionDecl * Function
Function - The actual function that this candidate represents.
unsigned RewriteKind
Whether this is a rewritten candidate, and if so, of what kind?
ConversionFixItGenerator Fix
The FixIt hints which can be used to fix the Bad candidate.
unsigned Best
Whether this candidate is the best viable function, or tied for being the best viable function.
StandardConversionSequence FinalConversion
FinalConversion - For a conversion function (where Function is a CXXConversionDecl),...
unsigned getNumParams() const
unsigned HasFinalConversion
Whether FinalConversion has been set.
unsigned TookAddressOfOverload
unsigned FailureKind
FailureKind - The reason why this candidate is not viable.
unsigned ExplicitCallArguments
The number of call arguments that were explicitly provided, to be used while performing partial order...
ConversionSequenceList Conversions
The conversion sequences used to convert the function arguments to the function parameters.
DeductionFailureInfo DeductionFailure
unsigned Viable
Viable - True to indicate that this overload candidate is viable.
CXXConversionDecl * Surrogate
Surrogate - The conversion function for which this candidate is a surrogate, but only if IsSurrogate ...
OverloadCandidateRewriteKind getRewriteKind() const
Get RewriteKind value in OverloadCandidateRewriteKind type (This function is to workaround the spurio...
bool HasFormOfMemberPointer
OverloadExpr * Expression
bool SuppressUserConversions
Do not consider any user-defined conversions when constructing the initializing sequence.
bool OnlyInitializeNonUserDefinedConversions
Before constructing the initializing sequence, we check whether the parameter type and argument type ...
A context in which code is being synthesized (where a source location alone is not sufficient to iden...
enum clang::Sema::CodeSynthesisContext::SynthesisKind Kind
@ RewritingOperatorAsSpaceship
We are rewriting a comparison operator in terms of an operator<=>.
Decl * Entity
The entity that is being synthesized.
Abstract class used to diagnose incomplete types.
A std::pair-like structure for storing a qualified type split into its local qualifiers and its local...
const Type * Ty
The locally-unqualified type.
Qualifiers Quals
The local qualifiers.
TemplateSpecCandidate - This is a generalization of OverloadCandidate which keeps track of template a...
void NoteDeductionFailure(Sema &S, bool ForTakingAddress)
Diagnose a template argument deduction failure.
DeductionFailureInfo DeductionFailure
Template argument deduction info.
Decl * Specialization
Specialization - The actual specialization that this candidate represents.
DeclAccessPair FoundDecl
The declaration that was looked up, together with its access.
void set(DeclAccessPair Found, Decl *Spec, DeductionFailureInfo Info)
UserDefinedConversionSequence - Represents a user-defined conversion sequence (C++ 13....
StandardConversionSequence Before
Represents the standard conversion that occurs before the actual user-defined conversion.
FunctionDecl * ConversionFunction
ConversionFunction - The function that will perform the user-defined conversion.
bool HadMultipleCandidates
HadMultipleCandidates - When this is true, it means that the conversion function was resolved from an...
StandardConversionSequence After
After - Represents the standard conversion that occurs after the actual user-defined conversion.
bool EllipsisConversion
EllipsisConversion - When this is true, it means user-defined conversion sequence starts with a ....
DeclAccessPair FoundConversionFunction
The declaration that we found via name lookup, which might be the same as ConversionFunction or it mi...
void dump() const
dump - Print this user-defined conversion sequence to standard error.
Describes an entity that is being assigned.