40#include "llvm/ADT/DenseSet.h"
41#include "llvm/ADT/STLExtras.h"
42#include "llvm/ADT/STLForwardCompat.h"
43#include "llvm/ADT/ScopeExit.h"
44#include "llvm/ADT/SmallPtrSet.h"
45#include "llvm/ADT/SmallVector.h"
59 return P->hasAttr<PassObjectSizeAttr>();
80 if (HadMultipleCandidates)
91 CK_FunctionToPointerDecay);
95 bool InOverloadResolution,
98 bool AllowObjCWritebackConversion);
102 bool InOverloadResolution,
110 bool AllowObjCConversionOnExplicit);
178 return Rank[(int)Kind];
203 static const char *
const Name[] = {
207 "Function-to-pointer",
208 "Function pointer conversion",
210 "Integral promotion",
211 "Floating point promotion",
213 "Integral conversion",
214 "Floating conversion",
215 "Complex conversion",
216 "Floating-integral conversion",
217 "Pointer conversion",
218 "Pointer-to-member conversion",
219 "Boolean conversion",
220 "Compatible-types conversion",
221 "Derived-to-base conversion",
223 "SVE Vector conversion",
224 "RVV Vector conversion",
226 "Complex-real conversion",
227 "Block Pointer conversion",
228 "Transparent Union Conversion",
229 "Writeback conversion",
230 "OpenCL Zero Event Conversion",
231 "OpenCL Zero Queue Conversion",
232 "C specific type conversion",
233 "Incompatible pointer conversion",
234 "Fixed point conversion",
235 "HLSL vector truncation",
236 "HLSL matrix truncation",
237 "Non-decaying array conversion",
315 FromType = Context.getArrayDecayedType(FromType);
327 const Expr *Converted) {
330 if (
auto *EWC = dyn_cast<ExprWithCleanups>(Converted)) {
337 while (
auto *ICE = dyn_cast<ImplicitCastExpr>(Converted)) {
338 switch (ICE->getCastKind()) {
340 case CK_IntegralCast:
341 case CK_IntegralToBoolean:
342 case CK_IntegralToFloating:
343 case CK_BooleanToSignedIntegral:
344 case CK_FloatingToIntegral:
345 case CK_FloatingToBoolean:
346 case CK_FloatingCast:
347 Converted = ICE->getSubExpr();
371 QualType &ConstantType,
bool IgnoreFloatToIntegralConversion)
const {
373 "narrowing check outside C++");
384 ToType = ED->getIntegerType();
390 goto FloatingIntegralConversion;
392 goto IntegralConversion;
403 FloatingIntegralConversion:
408 if (IgnoreFloatToIntegralConversion)
411 assert(
Initializer &&
"Unknown conversion expression");
417 if (std::optional<llvm::APSInt> IntConstantValue =
421 Result.convertFromAPInt(*IntConstantValue, IntConstantValue->isSigned(),
422 llvm::APFloat::rmNearestTiesToEven);
424 llvm::APSInt ConvertedValue = *IntConstantValue;
426 llvm::APFloat::opStatus Status =
Result.convertToInteger(
427 ConvertedValue, llvm::APFloat::rmTowardZero, &ignored);
430 if (Status == llvm::APFloat::opInvalidOp ||
431 *IntConstantValue != ConvertedValue) {
432 ConstantValue =
APValue(*IntConstantValue);
460 Initializer->isCXX11ConstantExpr(Ctx, &ConstantValue)))) {
463 ConstantValue = R.Val;
464 assert(ConstantValue.
isFloat());
465 llvm::APFloat FloatVal = ConstantValue.
getFloat();
468 llvm::APFloat Converted = FloatVal;
469 llvm::APFloat::opStatus ConvertStatus =
471 llvm::APFloat::rmNearestTiesToEven, &ignored);
473 llvm::APFloat::rmNearestTiesToEven, &ignored);
475 if (FloatVal.isNaN() && Converted.isNaN() &&
476 !FloatVal.isSignaling() && !Converted.isSignaling()) {
482 if (!Converted.bitwiseIsEqual(FloatVal)) {
489 if (ConvertStatus & llvm::APFloat::opOverflow) {
511 IntegralConversion: {
519 constexpr auto CanRepresentAll = [](
bool FromSigned,
unsigned FromWidth,
520 bool ToSigned,
unsigned ToWidth) {
521 return (FromWidth < ToWidth + (FromSigned == ToSigned)) &&
522 !(FromSigned && !ToSigned);
525 if (CanRepresentAll(FromSigned, FromWidth, ToSigned, ToWidth))
531 bool DependentBitField =
false;
533 if (BitField->getBitWidth()->isValueDependent())
534 DependentBitField =
true;
535 else if (
unsigned BitFieldWidth = BitField->getBitWidthValue();
536 BitFieldWidth < FromWidth) {
537 if (CanRepresentAll(FromSigned, BitFieldWidth, ToSigned, ToWidth))
541 FromWidth = BitFieldWidth;
549 std::optional<llvm::APSInt> OptInitializerValue =
551 if (!OptInitializerValue) {
555 if (DependentBitField && !(FromSigned && !ToSigned))
561 llvm::APSInt &InitializerValue = *OptInitializerValue;
562 bool Narrowing =
false;
563 if (FromWidth < ToWidth) {
566 if (InitializerValue.isSigned() && InitializerValue.isNegative())
572 InitializerValue.extend(InitializerValue.getBitWidth() + 1);
574 llvm::APSInt ConvertedValue = InitializerValue;
575 ConvertedValue = ConvertedValue.trunc(ToWidth);
576 ConvertedValue.setIsSigned(ToSigned);
577 ConvertedValue = ConvertedValue.extend(InitializerValue.getBitWidth());
578 ConvertedValue.setIsSigned(InitializerValue.isSigned());
580 if (ConvertedValue != InitializerValue)
585 ConstantValue =
APValue(InitializerValue);
601 ConstantValue = R.Val;
602 assert(ConstantValue.
isFloat());
603 llvm::APFloat FloatVal = ConstantValue.
getFloat();
608 if (FloatVal.isNaN() && FloatVal.isSignaling()) {
624 raw_ostream &OS = llvm::errs();
625 bool PrintedSomething =
false;
628 PrintedSomething =
true;
632 if (PrintedSomething) {
638 OS <<
" (by copy constructor)";
640 OS <<
" (direct reference binding)";
642 OS <<
" (reference binding)";
644 PrintedSomething =
true;
648 if (PrintedSomething) {
652 PrintedSomething =
true;
655 if (!PrintedSomething) {
656 OS <<
"No conversions required";
663 raw_ostream &OS = llvm::errs();
671 OS <<
"aggregate initialization";
681 raw_ostream &OS = llvm::errs();
683 OS <<
"Worst list element conversion: ";
684 switch (ConversionKind) {
686 OS <<
"Standard conversion: ";
690 OS <<
"User-defined conversion: ";
694 OS <<
"Ellipsis conversion";
697 OS <<
"Ambiguous conversion";
700 OS <<
"Bad conversion";
725 struct DFIArguments {
731 struct DFIParamWithArguments : DFIArguments {
736 struct DFIDeducedMismatchArgs : DFIArguments {
737 TemplateArgumentList *TemplateArgs;
738 unsigned CallArgIndex;
743 TemplateArgumentList *TemplateArgs;
744 ConstraintSatisfaction Satisfaction;
755 Result.Result =
static_cast<unsigned>(TDK);
756 Result.HasDiagnostic =
false;
776 Result.HasDiagnostic =
true;
783 auto *Saved =
new (Context) DFIDeducedMismatchArgs;
794 DFIArguments *Saved =
new (Context) DFIArguments;
806 DFIParamWithArguments *Saved =
new (Context) DFIParamWithArguments;
807 Saved->Param = Info.
Param;
820 Result.HasDiagnostic =
true;
825 CNSInfo *Saved =
new (Context) CNSInfo;
835 llvm_unreachable(
"not a deduction failure");
868 Diag->~PartialDiagnosticAt();
875 static_cast<CNSInfo *
>(
Data)->Satisfaction.~ConstraintSatisfaction();
878 Diag->~PartialDiagnosticAt();
914 return TemplateParameter::getFromOpaqueValue(
Data);
919 return static_cast<DFIParamWithArguments*
>(
Data)->Param;
949 return static_cast<DFIDeducedMismatchArgs*
>(
Data)->TemplateArgs;
955 return static_cast<CNSInfo*
>(
Data)->TemplateArgs;
987 return &
static_cast<DFIArguments*
>(
Data)->FirstArg;
1019 return &
static_cast<DFIArguments*
>(
Data)->SecondArg;
1034 return static_cast<DFIDeducedMismatchArgs*
>(
Data)->CallArgIndex;
1037 return std::nullopt;
1050 for (
unsigned I = 0; I <
X->getNumParams(); ++I)
1054 if (
auto *FTX =
X->getDescribedFunctionTemplate()) {
1059 FTY->getTemplateParameters()))
1068 OverloadedOperatorKind::OO_EqualEqual);
1080 OverloadedOperatorKind::OO_ExclaimEqual);
1098 auto *NotEqFD = Op->getAsFunction();
1099 if (
auto *UD = dyn_cast<UsingShadowDecl>(Op))
1100 NotEqFD = UD->getUnderlyingDecl()->getAsFunction();
1113 return Op == OO_EqualEqual || Op == OO_Spaceship;
1121 if (Op == OverloadedOperatorKind::OO_EqualEqual) {
1122 assert(OriginalArgs.size() == 2);
1124 S,
OpLoc, OriginalArgs[1], FD))
1135void OverloadCandidateSet::destroyCandidates() {
1136 for (
iterator i = Candidates.begin(), e = Candidates.end(); i != e; ++i) {
1137 for (
auto &
C : i->Conversions)
1138 C.~ImplicitConversionSequence();
1140 i->DeductionFailure.Destroy();
1145 destroyCandidates();
1146 SlabAllocator.Reset();
1147 NumInlineBytesUsed = 0;
1151 FirstDeferredCandidate =
nullptr;
1152 DeferredCandidatesCount = 0;
1153 HasDeferredTemplateConstructors =
false;
1154 ResolutionByPerfectCandidateIsDisabled =
false;
1158 class UnbridgedCastsSet {
1168 Entry entry = { &E, E };
1169 Entries.push_back(entry);
1174 for (SmallVectorImpl<Entry>::iterator
1175 i = Entries.begin(), e = Entries.end(); i != e; ++i)
1176 *i->Addr = i->Saved;
1190 UnbridgedCastsSet *unbridgedCasts =
nullptr) {
1194 if (placeholder->getKind() == BuiltinType::Overload)
return false;
1198 if (placeholder->getKind() == BuiltinType::ARCUnbridgedCast &&
1200 unbridgedCasts->save(S, E);
1220 UnbridgedCastsSet &unbridged) {
1221 for (
unsigned i = 0, e = Args.size(); i != e; ++i)
1230 bool NewIsUsingDecl) {
1235 bool OldIsUsingDecl =
false;
1237 OldIsUsingDecl =
true;
1241 if (NewIsUsingDecl)
continue;
1248 if ((OldIsUsingDecl || NewIsUsingDecl) && !
isVisible(*I))
1256 bool UseMemberUsingDeclRules =
1257 (OldIsUsingDecl || NewIsUsingDecl) &&
CurContext->isRecord() &&
1258 !
New->getFriendObjectKind();
1262 if (UseMemberUsingDeclRules && OldIsUsingDecl) {
1268 !shouldLinkPossiblyHiddenDecl(*I,
New))
1287 }
else if (
auto *UUD = dyn_cast<UnresolvedUsingValueDecl>(OldD)) {
1294 if (UUD->getQualifier().isDependent() && !UUD->isCXXClassMember()) {
1322 if (
New->getFriendObjectKind() &&
New->getQualifier() &&
1323 !
New->getDescribedFunctionTemplate() &&
1324 !
New->getDependentSpecializationInfo() &&
1325 !
New->getType()->isDependentType()) {
1332 New->setInvalidDecl();
1344 assert(D &&
"function decl should not be null");
1345 if (
auto *A = D->
getAttr<AttrT>())
1346 return !A->isImplicit();
1352 bool UseMemberUsingDeclRules,
1353 bool ConsiderCudaAttrs,
1354 bool UseOverrideRules =
false) {
1360 if (
New->isMSVCRTEntryPoint())
1371 if ((OldTemplate ==
nullptr) != (NewTemplate ==
nullptr))
1394 if (OldQType != NewQType && OldType->isVariadic() != NewType->isVariadic())
1398 if ((
New->isMemberLikeConstrainedFriend() ||
1409 OldDecl = OldTemplate;
1410 NewDecl = NewTemplate;
1428 bool ConstraintsInTemplateHead =
1439 if (UseMemberUsingDeclRules && ConstraintsInTemplateHead &&
1440 !SameTemplateParameterList)
1442 if (!UseMemberUsingDeclRules &&
1443 (!SameTemplateParameterList || !SameReturnType))
1447 const auto *OldMethod = dyn_cast<CXXMethodDecl>(Old);
1448 const auto *NewMethod = dyn_cast<CXXMethodDecl>(
New);
1450 int OldParamsOffset = 0;
1451 int NewParamsOffset = 0;
1459 if (ThisType.isConstQualified())
1479 BS.
Quals = NormalizeQualifiers(OldMethod, BS.
Quals);
1480 DS.Quals = NormalizeQualifiers(NewMethod, DS.Quals);
1482 if (OldMethod->isExplicitObjectMemberFunction()) {
1484 DS.Quals.removeVolatile();
1487 return BS.
Quals == DS.Quals;
1491 auto BS =
Base.getNonReferenceType().getCanonicalType().split();
1492 auto DS = D.getNonReferenceType().getCanonicalType().split();
1494 if (!AreQualifiersEqual(BS, DS))
1497 if (OldMethod->isImplicitObjectMemberFunction() &&
1498 OldMethod->getParent() != NewMethod->getParent()) {
1510 if (
Base->isLValueReferenceType())
1511 return D->isLValueReferenceType();
1512 return Base->isRValueReferenceType() == D->isRValueReferenceType();
1517 auto DiagnoseInconsistentRefQualifiers = [&]() {
1518 if (SemaRef.
LangOpts.CPlusPlus23 && !UseOverrideRules)
1520 if (OldMethod->getRefQualifier() == NewMethod->getRefQualifier())
1522 if (OldMethod->isExplicitObjectMemberFunction() ||
1523 NewMethod->isExplicitObjectMemberFunction())
1525 if (!UseMemberUsingDeclRules && (OldMethod->getRefQualifier() ==
RQ_None ||
1526 NewMethod->getRefQualifier() ==
RQ_None)) {
1527 SemaRef.
Diag(NewMethod->getLocation(), diag::err_ref_qualifier_overload)
1528 << NewMethod->getRefQualifier() << OldMethod->getRefQualifier();
1529 SemaRef.
Diag(OldMethod->getLocation(), diag::note_previous_declaration);
1538 bool ShouldDiagnoseInconsistentRefQualifiers =
false;
1539 bool HaveInconsistentQualifiers =
false;
1541 if (OldMethod && OldMethod->isExplicitObjectMemberFunction())
1543 if (NewMethod && NewMethod->isExplicitObjectMemberFunction())
1546 if (OldType->getNumParams() - OldParamsOffset !=
1547 NewType->getNumParams() - NewParamsOffset ||
1549 {OldType->param_type_begin() + OldParamsOffset,
1550 OldType->param_type_end()},
1551 {NewType->param_type_begin() + NewParamsOffset,
1552 NewType->param_type_end()},
1557 if (OldMethod && NewMethod && !OldMethod->isStatic() &&
1558 !NewMethod->isStatic()) {
1559 bool HaveCorrespondingObjectParameters = [&](
const CXXMethodDecl *Old,
1561 auto NewObjectType =
New->getFunctionObjectParameterReferenceType();
1565 return F->getRefQualifier() ==
RQ_None &&
1566 !F->isExplicitObjectMemberFunction();
1569 if (IsImplicitWithNoRefQual(Old) != IsImplicitWithNoRefQual(
New) &&
1570 CompareType(OldObjectType.getNonReferenceType(),
1571 NewObjectType.getNonReferenceType()))
1573 return CompareType(OldObjectType, NewObjectType);
1574 }(OldMethod, NewMethod);
1576 if (!HaveCorrespondingObjectParameters) {
1577 ShouldDiagnoseInconsistentRefQualifiers =
true;
1581 if (!UseOverrideRules || (!NewMethod->isExplicitObjectMemberFunction() &&
1582 !OldMethod->isExplicitObjectMemberFunction()))
1583 HaveInconsistentQualifiers =
true;
1587 if (NewMethod && OldMethod && OldMethod->isImplicitObjectMemberFunction() &&
1588 NewMethod->isImplicitObjectMemberFunction())
1589 ShouldDiagnoseInconsistentRefQualifiers =
true;
1591 if (!UseOverrideRules &&
1595 if (!NewRC != !OldRC)
1615 NewI =
New->specific_attr_begin<EnableIfAttr>(),
1616 NewE =
New->specific_attr_end<EnableIfAttr>(),
1619 NewI != NewE || OldI != OldE; ++NewI, ++OldI) {
1620 if (NewI == NewE || OldI == OldE)
1622 llvm::FoldingSetNodeID NewID, OldID;
1623 NewI->getCond()->Profile(NewID, SemaRef.
Context,
true);
1624 OldI->getCond()->Profile(OldID, SemaRef.
Context,
true);
1629 if ((ShouldDiagnoseInconsistentRefQualifiers &&
1630 DiagnoseInconsistentRefQualifiers()) ||
1631 HaveInconsistentQualifiers)
1635 if (SemaRef.
getLangOpts().CUDA && ConsiderCudaAttrs) {
1643 "Unexpected invalid target.");
1647 if (NewTarget != OldTarget) {
1650 if (OldMethod && NewMethod && OldMethod->isVirtual() &&
1651 OldMethod->isConstexpr() && !NewMethod->isConstexpr() &&
1669 bool UseMemberUsingDeclRules,
bool ConsiderCudaAttrs) {
1675 bool UseMemberUsingDeclRules,
bool ConsiderCudaAttrs) {
1688 bool SuppressUserConversions,
1690 bool InOverloadResolution,
1692 bool AllowObjCWritebackConversion,
1693 bool AllowObjCConversionOnExplicit) {
1696 if (SuppressUserConversions) {
1707 Conversions, AllowExplicit,
1708 AllowObjCConversionOnExplicit)) {
1729 bool FromListInit =
false;
1730 if (
const auto *InitList = dyn_cast<InitListExpr>(From);
1731 InitList && InitList->getNumInits() == 1 &&
1733 const Expr *SingleInit = InitList->getInit(0);
1734 FromType = SingleInit->
getType();
1736 FromListInit =
true;
1745 if ((FromCanon == ToCanon ||
1757 if (ToCanon != FromCanon)
1768 Cand != Conversions.
end(); ++Cand)
1809static ImplicitConversionSequence
1811 bool SuppressUserConversions,
1813 bool InOverloadResolution,
1815 bool AllowObjCWritebackConversion,
1816 bool AllowObjCConversionOnExplicit) {
1819 ICS.
Standard, CStyle, AllowObjCWritebackConversion)){
1870 bool CanConvert =
false;
1876 FromResType->getWrappedType()) &&
1878 FromResType->getContainedType()) &&
1879 ToResType->getAttrs() == FromResType->getAttrs())
1881 }
else if (ToTy->isHLSLResourceType()) {
1895 AllowExplicit, InOverloadResolution, CStyle,
1896 AllowObjCWritebackConversion,
1897 AllowObjCConversionOnExplicit);
1900ImplicitConversionSequence
1902 bool SuppressUserConversions,
1904 bool InOverloadResolution,
1906 bool AllowObjCWritebackConversion) {
1907 return ::TryImplicitConversion(*
this, From, ToType, SuppressUserConversions,
1908 AllowExplicit, InOverloadResolution, CStyle,
1909 AllowObjCWritebackConversion,
1915 bool AllowExplicit) {
1920 bool AllowObjCWritebackConversion =
1927 *
this, From, ToType,
1929 AllowExplicit ? AllowedExplicit::All : AllowedExplicit::None,
1931 false, AllowObjCWritebackConversion,
1945 if (
Context.hasSameUnqualifiedType(FromType, ToType))
1958 if (TyClass != CanFrom->getTypeClass())
return false;
1959 if (TyClass != Type::FunctionProto && TyClass != Type::FunctionNoProto) {
1960 if (TyClass == Type::Pointer) {
1963 }
else if (TyClass == Type::BlockPointer) {
1966 }
else if (TyClass == Type::MemberPointer) {
1973 CanTo = ToMPT->getPointeeType();
1979 TyClass = CanTo->getTypeClass();
1980 if (TyClass != CanFrom->getTypeClass())
return false;
1981 if (TyClass != Type::FunctionProto && TyClass != Type::FunctionNoProto)
1991 bool Changed =
false;
1999 const auto *FromFPT = dyn_cast<FunctionProtoType>(FromFn);
2000 const auto *ToFPT = dyn_cast<FunctionProtoType>(ToFn);
2002 if (FromFPT && ToFPT) {
2003 if (FromFPT->hasCFIUncheckedCallee() != ToFPT->hasCFIUncheckedCallee()) {
2005 FromFPT->getReturnType(), FromFPT->getParamTypes(),
2006 FromFPT->getExtProtoInfo().withCFIUncheckedCallee(
2007 ToFPT->hasCFIUncheckedCallee()));
2015 if (FromFPT && ToFPT) {
2016 if (FromFPT->isNothrow() && !ToFPT->isNothrow()) {
2028 bool CanUseToFPT, CanUseFromFPT;
2029 if (
Context.mergeExtParameterInfo(ToFPT, FromFPT, CanUseToFPT,
2030 CanUseFromFPT, NewParamInfos) &&
2031 CanUseToFPT && !CanUseFromFPT) {
2034 NewParamInfos.empty() ?
nullptr : NewParamInfos.data();
2036 FromFPT->getParamTypes(), ExtInfo);
2041 if (
Context.hasAnyFunctionEffects()) {
2046 const auto FromFX = FromFPT->getFunctionEffects();
2047 const auto ToFX = ToFPT->getFunctionEffects();
2048 if (FromFX != ToFX) {
2052 FromFPT->getReturnType(), FromFPT->getParamTypes(), ExtInfo);
2062 assert(
QualType(FromFn, 0).isCanonical());
2063 if (
QualType(FromFn, 0) != CanTo)
return false;
2090 if ((&FromSem == &llvm::APFloat::PPCDoubleDouble() &&
2091 &ToSem == &llvm::APFloat::IEEEquad()) ||
2092 (&FromSem == &llvm::APFloat::IEEEquad() &&
2093 &ToSem == &llvm::APFloat::PPCDoubleDouble()))
2149 bool InOverloadResolution,
bool CStyle) {
2159 if (ToMatrixType && FromMatrixType) {
2161 unsigned ToCols = ToMatrixType->getNumColumns();
2162 if (FromCols < ToCols)
2165 unsigned FromRows = FromMatrixType->
getNumRows();
2166 unsigned ToRows = ToMatrixType->getNumRows();
2167 if (FromRows < ToRows)
2170 if (FromRows == ToRows && FromCols == ToCols)
2176 QualType ToElTy = ToMatrixType->getElementType();
2185 QualType ToElTy = ToMatrixType->getElementType();
2188 if (FromMatrixType && !ToMatrixType) {
2207 bool InOverloadResolution,
bool CStyle) {
2224 if (ToExtType && FromExtType) {
2226 unsigned ToElts = ToExtType->getNumElements();
2227 if (FromElts < ToElts)
2229 if (FromElts == ToElts)
2235 QualType ToElTy = ToExtType->getElementType();
2240 if (FromExtType && !ToExtType) {
2254 if (ToExtType->getNumElements() != FromExtType->getNumElements())
2259 FromExtType->getElementType()->isIntegerType()) {
2271 QualType ToElTy = ToExtType->getElementType();
2306 !ToType->
hasAttr(attr::ArmMveStrictPolymorphism))) {
2311 !InOverloadResolution && !CStyle) {
2313 << FromType << ToType;
2324 bool InOverloadResolution,
2325 StandardConversionSequence &SCS,
2330 bool InOverloadResolution,
2331 StandardConversionSequence &SCS,
2343 bool InOverloadResolution,
2346 bool AllowObjCWritebackConversion) {
2372 FromType = Fn->getType();
2392 if (Method && !Method->isStatic() &&
2393 !Method->isExplicitObjectMemberFunction()) {
2395 "Non-unary operator on non-static member address");
2398 "Non-address-of operator on non-static member address");
2400 FromType, std::nullopt, Method->getParent());
2404 "Non-address-of operator for overloaded function expression");
2450 FromType =
Atomic->getValueType();
2485 if (
auto *FD = dyn_cast<FunctionDecl>(DRE->getDecl()))
2505 bool IncompatibleObjC =
false;
2567 }
else if (AllowObjCWritebackConversion &&
2571 FromType, IncompatibleObjC)) {
2577 InOverloadResolution, FromType)) {
2581 From, InOverloadResolution, CStyle)) {
2586 From, InOverloadResolution, CStyle)) {
2596 S, From, ToType, InOverloadResolution, SCS, CStyle)) {
2605 S, From, ToType, InOverloadResolution, SCS, CStyle)) {
2635 bool ObjCLifetimeConversion;
2641 ObjCLifetimeConversion)) {
2660 CanonFrom = CanonTo;
2665 if (CanonFrom == CanonTo)
2670 if (S.
getLangOpts().CPlusPlus || !InOverloadResolution)
2682 case AssignConvertType::
2683 CompatibleVoidPtrToNonVoidPtr:
2716 bool InOverloadResolution,
2725 if (!UD->
hasAttr<TransparentUnionAttr>())
2728 for (
const auto *it : UD->
fields()) {
2731 ToType = it->getType();
2757 return To->
getKind() == BuiltinType::Int;
2760 return To->
getKind() == BuiltinType::UInt;
2784 if (FromED->isScoped())
2791 if (FromED->isFixed()) {
2792 QualType Underlying = FromED->getIntegerType();
2793 return Context.hasSameUnqualifiedType(Underlying, ToType) ||
2800 return Context.hasSameUnqualifiedType(ToType, FromED->getPromotionType());
2825 uint64_t FromSize =
Context.getTypeSize(FromType);
2834 for (
int Idx = 0; Idx < 6; ++Idx) {
2835 uint64_t ToSize =
Context.getTypeSize(PromoteTypes[Idx]);
2836 if (FromSize < ToSize ||
2837 (FromSize == ToSize &&
2838 FromIsSigned == PromoteTypes[Idx]->isSignedIntegerType())) {
2842 return Context.hasSameUnqualifiedType(ToType, PromoteTypes[Idx]);
2863 std::optional<llvm::APSInt> BitWidth;
2866 MemberDecl->getBitWidth()->getIntegerConstantExpr(
Context))) {
2867 llvm::APSInt ToSize(BitWidth->getBitWidth(), BitWidth->isUnsigned());
2868 ToSize =
Context.getTypeSize(ToType);
2871 if (*BitWidth < ToSize ||
2873 return To->
getKind() == BuiltinType::Int;
2879 return To->
getKind() == BuiltinType::UInt;
2897 return Context.getTypeSize(FromType) <
Context.getTypeSize(ToType);
2907 if (FromBuiltin->getKind() == BuiltinType::Float &&
2908 ToBuiltin->getKind() == BuiltinType::Double)
2915 (FromBuiltin->getKind() == BuiltinType::Float ||
2916 FromBuiltin->getKind() == BuiltinType::Double) &&
2917 (ToBuiltin->getKind() == BuiltinType::LongDouble ||
2918 ToBuiltin->getKind() == BuiltinType::Float128 ||
2919 ToBuiltin->getKind() == BuiltinType::Ibm128))
2924 if (
getLangOpts().
HLSL && FromBuiltin->getKind() == BuiltinType::Half &&
2925 (ToBuiltin->getKind() == BuiltinType::Float ||
2926 ToBuiltin->getKind() == BuiltinType::Double))
2931 FromBuiltin->getKind() == BuiltinType::Half &&
2932 ToBuiltin->getKind() == BuiltinType::Float)
2961 return Context.getTypeSize(FromType) <
Context.getTypeSize(ToType);
2973 if (
const EnumType *ToEnumType = ToType->
getAs<EnumType>()) {
2985 return Context.getTypeSize(FromType) >
Context.getTypeSize(ToType);
3000 bool StripObjCLifetime =
false) {
3003 "Invalid similarly-qualified pointer type");
3014 if (StripObjCLifetime)
3026 return Context.getObjCObjectPointerType(ToPointee);
3027 return Context.getPointerType(ToPointee);
3035 return Context.getObjCObjectPointerType(QualifiedCanonToPointee);
3036 return Context.getPointerType(QualifiedCanonToPointee);
3040 bool InOverloadResolution,
3046 return !InOverloadResolution;
3054 bool InOverloadResolution,
3056 bool &IncompatibleObjC) {
3057 IncompatibleObjC =
false;
3065 ConvertedType = ToType;
3072 ConvertedType = ToType;
3079 ConvertedType = ToType;
3087 ConvertedType = ToType;
3097 ConvertedType = ToType;
3119 if (
Context.hasSameUnqualifiedType(FromPointeeType, ToPointeeType))
3146 Context.typesAreCompatible(FromPointeeType, ToPointeeType)) {
3168 !
Context.hasSameUnqualifiedType(FromPointeeType, ToPointeeType) &&
3177 Context.areCompatibleVectorTypes(FromPointeeType, ToPointeeType)) {
3196 return Context.getQualifiedType(T, Qs);
3198 return Context.getQualifiedType(T.getUnqualifiedType(), Qs);
3203 bool &IncompatibleObjC) {
3216 if (ToObjCPtr && FromObjCPtr) {
3224 if (
Context.canAssignObjCInterfaces(ToObjCPtr, FromObjCPtr)) {
3238 if (
Context.canAssignObjCInterfaces(FromObjCPtr, ToObjCPtr)) {
3242 IncompatibleObjC =
true;
3258 if (FromObjCPtr && FromObjCPtr->isObjCBuiltinType()) {
3287 IncompatibleObjC)) {
3289 IncompatibleObjC =
true;
3290 ConvertedType =
Context.getPointerType(ConvertedType);
3299 IncompatibleObjC)) {
3301 ConvertedType =
Context.getPointerType(ConvertedType);
3314 if (FromFunctionType && ToFunctionType) {
3317 if (
Context.getCanonicalType(FromPointeeType)
3318 ==
Context.getCanonicalType(ToPointeeType))
3323 if (FromFunctionType->
getNumParams() != ToFunctionType->getNumParams() ||
3324 FromFunctionType->
isVariadic() != ToFunctionType->isVariadic() ||
3325 FromFunctionType->
getMethodQuals() != ToFunctionType->getMethodQuals())
3328 bool HasObjCConversion =
false;
3330 Context.getCanonicalType(ToFunctionType->getReturnType())) {
3333 ToFunctionType->getReturnType(),
3334 ConvertedType, IncompatibleObjC)) {
3336 HasObjCConversion =
true;
3343 for (
unsigned ArgIdx = 0, NumArgs = FromFunctionType->
getNumParams();
3344 ArgIdx != NumArgs; ++ArgIdx) {
3346 QualType ToArgType = ToFunctionType->getParamType(ArgIdx);
3347 if (
Context.getCanonicalType(FromArgType)
3348 ==
Context.getCanonicalType(ToArgType)) {
3351 ConvertedType, IncompatibleObjC)) {
3353 HasObjCConversion =
true;
3360 if (HasObjCConversion) {
3364 IncompatibleObjC =
true;
3396 if (!FromFunctionType || !ToFunctionType)
3399 if (
Context.hasSameType(FromPointeeType, ToPointeeType))
3404 if (FromFunctionType->
getNumParams() != ToFunctionType->getNumParams() ||
3405 FromFunctionType->
isVariadic() != ToFunctionType->isVariadic())
3410 if (FromEInfo != ToEInfo)
3413 bool IncompatibleObjC =
false;
3415 ToFunctionType->getReturnType())) {
3419 QualType LHS = ToFunctionType->getReturnType();
3424 if (
Context.hasSameType(RHS,LHS)) {
3427 ConvertedType, IncompatibleObjC)) {
3428 if (IncompatibleObjC)
3437 for (
unsigned ArgIdx = 0, NumArgs = FromFunctionType->
getNumParams();
3438 ArgIdx != NumArgs; ++ArgIdx) {
3439 IncompatibleObjC =
false;
3441 QualType ToArgType = ToFunctionType->getParamType(ArgIdx);
3442 if (
Context.hasSameType(FromArgType, ToArgType)) {
3445 ConvertedType, IncompatibleObjC)) {
3446 if (IncompatibleObjC)
3455 bool CanUseToFPT, CanUseFromFPT;
3456 if (!
Context.mergeExtParameterInfo(ToFunctionType, FromFunctionType,
3457 CanUseToFPT, CanUseFromFPT,
3461 ConvertedType = ToType;
3500 ToMember->getMostRecentCXXRecordDecl())) {
3502 if (ToMember->isSugared())
3504 ToMember->getMostRecentCXXRecordDecl());
3506 PDiag << ToMember->getQualifier();
3507 if (FromMember->isSugared())
3509 FromMember->getMostRecentCXXRecordDecl());
3511 PDiag << FromMember->getQualifier();
3529 !FromType->
getAs<TemplateSpecializationType>()) {
3535 if (
Context.hasSameType(FromType, ToType)) {
3544 if (!FromFunction || !ToFunction) {
3549 if (FromFunction->
getNumParams() != ToFunction->getNumParams()) {
3559 << ToFunction->getParamType(ArgPos)
3566 ToFunction->getReturnType())) {
3572 if (FromFunction->
getMethodQuals() != ToFunction->getMethodQuals()) {
3595 assert(llvm::size(Old) == llvm::size(
New) &&
3596 "Can't compare parameters of functions with different number of "
3599 for (
auto &&[Idx,
Type] : llvm::enumerate(Old)) {
3601 size_t J =
Reversed ? (llvm::size(
New) - Idx - 1) : Idx;
3606 Context.removePtrSizeAddrSpace(
Type.getUnqualifiedType());
3608 Context.removePtrSizeAddrSpace((
New.begin() + J)->getUnqualifiedType());
3610 if (!
Context.hasSameType(OldType, NewType)) {
3635 unsigned OldIgnore =
3637 unsigned NewIgnore =
3644 NewPT->param_types().slice(NewIgnore),
3651 bool IgnoreBaseAccess,
3654 bool IsCStyleOrFunctionalCast = IgnoreBaseAccess;
3663 PDiag(diag::warn_impcast_bool_to_null_pointer)
3674 if (FromPointeeType->
isRecordType() && ToPointeeType->isRecordType() &&
3675 !
Context.hasSameUnqualifiedType(FromPointeeType, ToPointeeType)) {
3678 unsigned InaccessibleID = 0;
3679 unsigned AmbiguousID = 0;
3681 InaccessibleID = diag::err_upcast_to_inaccessible_base;
3682 AmbiguousID = diag::err_ambiguous_derived_to_base_conv;
3685 FromPointeeType, ToPointeeType, InaccessibleID, AmbiguousID,
3687 &BasePath, IgnoreBaseAccess))
3691 Kind = CK_DerivedToBase;
3694 if (
Diagnose && !IsCStyleOrFunctionalCast &&
3695 FromPointeeType->
isFunctionType() && ToPointeeType->isVoidType()) {
3697 "this should only be possible with MSVCCompat!");
3709 if (FromPtrType->isObjCBuiltinType() || ToPtrType->isObjCBuiltinType())
3712 Kind = CK_BlockPointerToObjCPointerCast;
3714 Kind = CK_CPointerToObjCPointerCast;
3718 Kind = CK_AnyPointerToBlockPointerCast;
3724 Kind = CK_NullToPointer;
3731 bool InOverloadResolution,
3741 ConvertedType = ToType;
3757 ConvertedType =
Context.getMemberPointerType(
3771 if (
Context.getTargetInfo().getCXXABI().isMicrosoft()) {
3779 Kind = CK_NullToMemberPointer;
3797 PD <<
Context.getCanonicalTagType(Cls);
3807 std::swap(
Base, Derived);
3816 PD <<
int(Direction);
3824 DiagFromTo(PD) <<
QualType(VBase, 0) << OpRange;
3832 ? CK_DerivedToBaseMemberPointer
3833 : CK_BaseToDerivedMemberPointer;
3835 if (!IgnoreBaseAccess)
3839 ? diag::err_upcast_to_inaccessible_base
3840 : diag::err_downcast_from_inaccessible_base,
3842 NestedNameSpecifier BaseQual = FromPtrType->getQualifier(),
3843 DerivedQual = ToPtrType->getQualifier();
3844 if (Direction == MemberPointerConversionDirection::Upcast)
3845 std::swap(BaseQual, DerivedQual);
3846 DiagCls(PD, DerivedQual, Derived);
3847 DiagCls(PD, BaseQual, Base);
3882 bool CStyle,
bool IsTopLevel,
3883 bool &PreviousToQualsIncludeConst,
3884 bool &ObjCLifetimeConversion,
3897 ObjCLifetimeConversion =
true;
3937 !PreviousToQualsIncludeConst)
3955 PreviousToQualsIncludeConst =
3956 PreviousToQualsIncludeConst && ToQuals.
hasConst();
3962 bool CStyle,
bool &ObjCLifetimeConversion) {
3963 FromType =
Context.getCanonicalType(FromType);
3964 ToType =
Context.getCanonicalType(ToType);
3965 ObjCLifetimeConversion =
false;
3975 bool PreviousToQualsIncludeConst =
true;
3976 bool UnwrappedAnyPointer =
false;
3977 while (
Context.UnwrapSimilarTypes(FromType, ToType)) {
3979 !UnwrappedAnyPointer,
3980 PreviousToQualsIncludeConst,
3983 UnwrappedAnyPointer =
true;
3991 return UnwrappedAnyPointer &&
Context.hasSameUnqualifiedType(FromType,ToType);
4000 bool InOverloadResolution,
4009 InOverloadResolution, InnerSCS,
4024 bool InOverloadResolution,
4027 const OverflowBehaviorType *ToOBT = ToType->
getAs<OverflowBehaviorType>();
4038 InOverloadResolution, InnerSCS, CStyle,
4055 if (CtorType->getNumParams() > 0) {
4056 QualType FirstArg = CtorType->getParamType(0);
4068 bool AllowExplicit) {
4075 bool Usable = !Info.Constructor->isInvalidDecl() &&
4078 bool SuppressUserConversions =
false;
4079 if (Info.ConstructorTmpl)
4082 CandidateSet, SuppressUserConversions,
4087 CandidateSet, SuppressUserConversions,
4088 false, AllowExplicit);
4092 bool HadMultipleCandidates = (CandidateSet.
size() > 1);
4119 llvm_unreachable(
"Invalid OverloadResult!");
4141 bool AllowObjCConversionOnExplicit) {
4142 assert(AllowExplicit != AllowedExplicit::None ||
4143 !AllowObjCConversionOnExplicit);
4147 bool ConstructorsOnly =
false;
4151 if (
const RecordType *ToRecordType = ToType->
getAsCanonical<RecordType>()) {
4163 ConstructorsOnly =
true;
4167 }
else if (
auto *ToRecordDecl =
4168 dyn_cast<CXXRecordDecl>(ToRecordType->getDecl())) {
4169 ToRecordDecl = ToRecordDecl->getDefinitionOrSelf();
4171 Expr **Args = &From;
4172 unsigned NumArgs = 1;
4173 bool ListInitializing =
false;
4174 if (
InitListExpr *InitList = dyn_cast<InitListExpr>(From)) {
4177 S, From, ToType, ToRecordDecl, User, CandidateSet,
4178 AllowExplicit == AllowedExplicit::All);
4187 Args = InitList->getInits();
4188 NumArgs = InitList->getNumInits();
4189 ListInitializing =
true;
4197 bool Usable = !Info.Constructor->isInvalidDecl();
4198 if (!ListInitializing)
4199 Usable = Usable && Info.Constructor->isConvertingConstructor(
4202 bool SuppressUserConversions = !ConstructorsOnly;
4210 if (SuppressUserConversions && ListInitializing) {
4211 SuppressUserConversions =
4216 if (Info.ConstructorTmpl)
4218 Info.ConstructorTmpl, Info.FoundDecl,
4220 CandidateSet, SuppressUserConversions,
4222 AllowExplicit == AllowedExplicit::All);
4228 SuppressUserConversions,
4230 AllowExplicit == AllowedExplicit::All);
4240 }
else if (
const RecordType *FromRecordType =
4242 if (
auto *FromRecordDecl =
4243 dyn_cast<CXXRecordDecl>(FromRecordType->getDecl())) {
4244 FromRecordDecl = FromRecordDecl->getDefinitionOrSelf();
4246 const auto &Conversions = FromRecordDecl->getVisibleConversionFunctions();
4247 for (
auto I = Conversions.begin(), E = Conversions.end(); I != E; ++I) {
4256 if ((ConvTemplate = dyn_cast<FunctionTemplateDecl>(D)))
4263 ConvTemplate, FoundDecl, ActingContext, From, ToType,
4264 CandidateSet, AllowObjCConversionOnExplicit,
4265 AllowExplicit != AllowedExplicit::None);
4268 CandidateSet, AllowObjCConversionOnExplicit,
4269 AllowExplicit != AllowedExplicit::None);
4274 bool HadMultipleCandidates = (CandidateSet.
size() > 1);
4283 = dyn_cast<CXXConstructorDecl>(Best->Function)) {
4295 if (Best->Conversions[0].isEllipsis())
4298 User.
Before = Best->Conversions[0].Standard;
4311 = dyn_cast<CXXConversionDecl>(Best->Function)) {
4313 assert(Best->HasFinalConversion);
4321 User.
Before = Best->Conversions[0].Standard;
4336 User.
After = Best->FinalConversion;
4339 llvm_unreachable(
"Not a constructor or conversion function?");
4348 llvm_unreachable(
"Invalid OverloadResult!");
4358 CandidateSet, AllowedExplicit::None,
false);
4373 diag::err_typecheck_nonviable_condition_incomplete,
4380 *
this, From, Cands);
4406 if (!Conv1 || !Conv2)
4421 if (Block1 != Block2)
4434 if (Conv1FuncRet && Conv2FuncRet &&
4443 CallOp->getType()->castAs<
FunctionType>()->getCallConv();
4445 CallOpProto->isVariadic(),
false);
4447 CallOpProto->isVariadic(),
true);
4449 CallingConv PrefOrder[] = {DefaultFree, DefaultMember, CallOpCC};
4544 if (!ICS1.
isBad()) {
4545 bool StdInit1 =
false, StdInit2 =
false;
4552 if (StdInit1 != StdInit2)
4563 CAT2->getElementType())) {
4565 if (CAT1->getSize() != CAT2->getSize())
4567 return CAT1->getSize().ult(CAT2->getSize())
4602 if (ConvFunc1 == ConvFunc2)
4704 if (!
Enum->isFixed())
4740 else if (Rank2 < Rank1)
4775 bool SCS1ConvertsToVoid
4777 bool SCS2ConvertsToVoid
4779 if (SCS1ConvertsToVoid != SCS2ConvertsToVoid) {
4784 }
else if (!SCS1ConvertsToVoid && !SCS2ConvertsToVoid) {
4790 }
else if (SCS1ConvertsToVoid && SCS2ConvertsToVoid &&
4819 if (FromObjCPtr1 && FromObjCPtr2) {
4824 if (AssignLeft != AssignRight) {
4863 if (UnqualT1 == UnqualT2) {
4925 if (SCS1IsCompatibleVectorConversion != SCS2IsCompatibleVectorConversion)
4926 return SCS1IsCompatibleVectorConversion
4933 bool SCS1IsCompatibleSVEVectorConversion =
4935 bool SCS2IsCompatibleSVEVectorConversion =
4938 if (SCS1IsCompatibleSVEVectorConversion !=
4939 SCS2IsCompatibleSVEVectorConversion)
4940 return SCS1IsCompatibleSVEVectorConversion
4947 bool SCS1IsCompatibleRVVVectorConversion =
4949 bool SCS2IsCompatibleRVVVectorConversion =
4952 if (SCS1IsCompatibleRVVVectorConversion !=
4953 SCS2IsCompatibleRVVVectorConversion)
4954 return SCS1IsCompatibleRVVVectorConversion
5013 if (UnqualT1 == UnqualT2)
5031 bool ObjCLifetimeConversion;
5041 if (CanPick1 != CanPick2)
5095 if (FromPointee1 == FromPointee2 && ToPointee1 != ToPointee2) {
5103 if (FromPointee1 != FromPointee2 && ToPointee1 == ToPointee2) {
5120 if (FromPtr1 && FromPtr2 && ToPtr1 && ToPtr2) {
5127 bool FromAssignRight
5136 if (ToPtr1->isObjCIdType() &&
5137 (ToPtr2->isObjCQualifiedIdType() || ToPtr2->getInterfaceDecl()))
5139 if (ToPtr2->isObjCIdType() &&
5140 (ToPtr1->isObjCQualifiedIdType() || ToPtr1->getInterfaceDecl()))
5145 if (ToPtr1->isObjCQualifiedIdType() && ToPtr2->getInterfaceDecl())
5147 if (ToPtr2->isObjCQualifiedIdType() && ToPtr1->getInterfaceDecl())
5152 if (ToPtr1->isObjCClassType() &&
5153 (ToPtr2->isObjCQualifiedClassType() || ToPtr2->getInterfaceDecl()))
5155 if (ToPtr2->isObjCClassType() &&
5156 (ToPtr1->isObjCQualifiedClassType() || ToPtr1->getInterfaceDecl()))
5161 if (ToPtr1->isObjCQualifiedClassType() && ToPtr2->getInterfaceDecl())
5163 if (ToPtr2->isObjCQualifiedClassType() && ToPtr1->getInterfaceDecl())
5169 (ToAssignLeft != ToAssignRight)) {
5180 }
else if (IsSecondSame)
5189 (FromAssignLeft != FromAssignRight))
5203 CXXRecordDecl *FromPointee1 = FromMemPointer1->getMostRecentCXXRecordDecl();
5208 if (FromPointee1 == FromPointee2 && ToPointee1 != ToPointee2) {
5215 if (ToPointee1 == ToPointee2 && FromPointee1 != FromPointee2) {
5253 if (!T.getQualifiers().hasUnaligned())
5267 "T1 must be the pointee type of the reference type");
5268 assert(!OrigT2->
isReferenceType() &&
"T2 cannot be a reference type");
5291 if (UnqualT1 == UnqualT2) {
5295 Conv |= ReferenceConversions::DerivedToBase;
5298 Context.canBindObjCObjectType(UnqualT1, UnqualT2))
5299 Conv |= ReferenceConversions::ObjC;
5302 Conv |= ReferenceConversions::Function;
5306 bool ConvertedReferent = Conv != 0;
5310 bool PreviousToQualsIncludeConst =
true;
5311 bool TopLevel =
true;
5317 Conv |= ReferenceConversions::Qualification;
5323 Conv |= ReferenceConversions::NestedQualification;
5331 bool ObjCLifetimeConversion =
false;
5333 PreviousToQualsIncludeConst,
5335 return (ConvertedReferent ||
Context.hasSimilarType(T1, T2))
5340 if (ObjCLifetimeConversion)
5341 Conv |= ReferenceConversions::ObjCLifetime;
5344 }
while (
Context.UnwrapSimilarTypes(T1, T2));
5349 return (ConvertedReferent ||
Context.hasSameUnqualifiedType(T1, T2))
5360 bool AllowExplicit) {
5361 assert(T2->
isRecordType() &&
"Can only find conversions of record types.");
5365 const auto &Conversions = T2RecordDecl->getVisibleConversionFunctions();
5366 for (
auto I = Conversions.begin(), E = Conversions.end(); I != E; ++I) {
5373 = dyn_cast<FunctionTemplateDecl>(D);
5390 if (!ConvTemplate &&
5414 ConvTemplate, I.getPair(), ActingDC,
Init, DeclType, CandidateSet,
5415 false, AllowExplicit);
5418 Conv, I.getPair(), ActingDC,
Init, DeclType, CandidateSet,
5419 false, AllowExplicit);
5422 bool HadMultipleCandidates = (CandidateSet.
size() > 1);
5428 assert(Best->HasFinalConversion);
5440 if (!Best->FinalConversion.DirectBinding)
5452 "Expected a direct reference binding!");
5458 Cand != CandidateSet.
end(); ++Cand)
5470 llvm_unreachable(
"Invalid OverloadResult!");
5475static ImplicitConversionSequence
5478 bool SuppressUserConversions,
5479 bool AllowExplicit) {
5480 assert(DeclType->
isReferenceType() &&
"Reference init needs a reference");
5507 auto SetAsReferenceBinding = [&](
bool BindsDirectly) {
5512 ICS.
Standard.
Second = (RefConv & Sema::ReferenceConversions::DerivedToBase)
5514 : (RefConv & Sema::ReferenceConversions::ObjC)
5522 Sema::ReferenceConversions::NestedQualification)
5536 (RefConv & Sema::ReferenceConversions::ObjCLifetime) != 0;
5560 SetAsReferenceBinding(
true);
5609 SetAsReferenceBinding(S.
getLangOpts().CPlusPlus11 ||
5700 AllowedExplicit::None,
5725 if (isRValRef && LValRefType) {
5742static ImplicitConversionSequence
5744 bool SuppressUserConversions,
5745 bool InOverloadResolution,
5746 bool AllowObjCWritebackConversion,
5747 bool AllowExplicit =
false);
5751static ImplicitConversionSequence
5753 bool SuppressUserConversions,
5754 bool InOverloadResolution,
5755 bool AllowObjCWritebackConversion) {
5768 if (
const auto *IAT = dyn_cast<IncompleteArrayType>(AT))
5770 InitTy = IAT->getElementType();
5796 if (From->
getNumInits() == 1 && !IsDesignatedInit) {
5802 SuppressUserConversions,
5803 InOverloadResolution,
5804 AllowObjCWritebackConversion);
5813 Result.Standard.setAsIdentityConversion();
5814 Result.Standard.setFromType(ToType);
5815 Result.Standard.setAllToTypes(ToType);
5840 bool IsUnbounded =
false;
5844 if (CT->getSize().ult(e)) {
5848 Result.setInitializerListContainerType(ContTy, IsUnbounded);
5851 if (CT->getSize().ugt(e)) {
5857 S, &EmptyList, InitTy, SuppressUserConversions,
5858 InOverloadResolution, AllowObjCWritebackConversion);
5859 if (DfltElt.
isBad()) {
5863 Result.setInitializerListContainerType(ContTy, IsUnbounded);
5874 Result.setInitializerListContainerType(ContTy, IsUnbounded);
5884 Result.Standard.setAsIdentityConversion();
5885 Result.Standard.setFromType(InitTy);
5886 Result.Standard.setAllToTypes(InitTy);
5887 for (
unsigned i = 0; i < e; ++i) {
5890 S,
Init, InitTy, SuppressUserConversions, InOverloadResolution,
5891 AllowObjCWritebackConversion);
5902 Result.setInitializerListContainerType(ContTy, IsUnbounded);
5916 Result.setInitializerListContainerType(ContTy, IsUnbounded);
5930 AllowedExplicit::None,
5931 InOverloadResolution,
false,
5932 AllowObjCWritebackConversion,
5951 Result.UserDefined.Before.setAsIdentityConversion();
5956 Result.UserDefined.After.setAsIdentityConversion();
5957 Result.UserDefined.After.setFromType(ToType);
5958 Result.UserDefined.After.setAllToTypes(ToType);
5959 Result.UserDefined.ConversionFunction =
nullptr;
5976 if (From->
getNumInits() == 1 && !IsDesignatedInit) {
5997 SuppressUserConversions,
6005 InOverloadResolution,
6006 AllowObjCWritebackConversion);
6009 assert(!
Result.isEllipsis() &&
6010 "Sub-initialization cannot result in ellipsis conversion.");
6016 Result.UserDefined.After;
6044 S, From->
getInit(0), ToType, SuppressUserConversions,
6045 InOverloadResolution, AllowObjCWritebackConversion);
6047 Result.Standard.FromBracedInitList =
true;
6051 else if (NumInits == 0) {
6053 Result.Standard.setAsIdentityConversion();
6054 Result.Standard.setFromType(ToType);
6055 Result.Standard.setAllToTypes(ToType);
6072static ImplicitConversionSequence
6074 bool SuppressUserConversions,
6075 bool InOverloadResolution,
6076 bool AllowObjCWritebackConversion,
6077 bool AllowExplicit) {
6078 if (
InitListExpr *FromInitList = dyn_cast<InitListExpr>(From))
6080 InOverloadResolution,AllowObjCWritebackConversion);
6085 SuppressUserConversions, AllowExplicit);
6088 SuppressUserConversions,
6089 AllowedExplicit::None,
6090 InOverloadResolution,
6092 AllowObjCWritebackConversion,
6105 return !ICS.
isBad();
6114 const CXXRecordDecl *ActingContext,
bool InOverloadResolution =
false,
6116 bool SuppressUserConversion =
false) {
6124 assert(FromClassification.
isLValue());
6135 if (Method->isExplicitObjectMemberFunction()) {
6136 if (ExplicitParameterType.isNull())
6137 ExplicitParameterType = Method->getFunctionObjectParameterReferenceType();
6139 ValueKindFromClassification(FromClassification));
6141 S, &TmpExpr, ExplicitParameterType, SuppressUserConversion,
6158 Qualifiers Quals = Method->getMethodQualifiers();
6196 FromType, ImplicitParamType);
6206 FromType, ImplicitParamType);
6219 }
else if (!Method->isExplicitObjectMemberFunction()) {
6221 FromType, ImplicitParamType);
6226 switch (Method->getRefQualifier()) {
6241 if (!FromClassification.
isRValue()) {
6263 = (Method->getRefQualifier() ==
RQ_None);
6274 QualType ImplicitParamRecordType =
Method->getFunctionObjectParameterType();
6287 DestType =
Method->getThisType();
6290 FromRecordType = From->
getType();
6291 DestType = ImplicitParamRecordType;
6299 Method->getRefQualifier() !=
6317 <<
Method->getDeclName() << FromRecordType << (CVR - 1)
6319 Diag(
Method->getLocation(), diag::note_previous_decl)
6320 <<
Method->getDeclName();
6328 bool IsRValueQualified =
6332 << IsRValueQualified;
6333 Diag(
Method->getLocation(), diag::note_previous_decl)
6334 <<
Method->getDeclName();
6344 llvm_unreachable(
"Lists are not objects");
6347 return Diag(From->
getBeginLoc(), diag::err_member_function_call_bad_type)
6348 << ImplicitParamRecordType << FromRecordType
6357 From = FromRes.
get();
6366 CK = CK_AddressSpaceConversion;
6391 AllowedExplicit::Conversions,
6402 return AMDGPU().ExpandAMDGPUPredicateBuiltIn(From);
6475 llvm_unreachable(
"found a first conversion kind in Second");
6479 llvm_unreachable(
"found a third conversion kind in Second");
6485 llvm_unreachable(
"unknown conversion kind");
6495 [[maybe_unused]]
bool isCCEAllowedPreCXX11 =
6497 assert((S.
getLangOpts().CPlusPlus11 || isCCEAllowedPreCXX11) &&
6498 "converted constant expression outside C++11 or TTP matching");
6530 if (T->isRecordType())
6539 diag::err_typecheck_converted_constant_expression)
6545 llvm_unreachable(
"bad conversion in converted constant expression");
6551 diag::err_typecheck_converted_constant_expression_disallowed)
6557 diag::err_typecheck_converted_constant_expression_indirect)
6567 diag::err_reference_bind_to_bitfield_in_cce)
6575 bool IsTemplateArgument =
6577 if (T->isRecordType()) {
6578 assert(IsTemplateArgument &&
6579 "unexpected class type converted constant expr");
6595 IsTemplateArgument);
6600 bool ReturnPreNarrowingValue =
false;
6603 PreNarrowingType)) {
6613 PreNarrowingValue.
isInt()) {
6616 ReturnPreNarrowingValue =
true;
6642 << CCE << 0 << From->
getType() << T;
6647 if (!ReturnPreNarrowingValue)
6648 PreNarrowingValue = {};
6664 if (
Result.isInvalid() ||
Result.get()->isValueDependent()) {
6669 RequireInt, PreNarrowingValue);
6676 return ::BuildConvertedConstantExpression(*
this, From, T, CCE, Dest,
6683 return ::CheckConvertedConstantExpression(*
this, From, T,
Value, CCE,
false,
6688 llvm::APSInt &
Value,
6690 assert(T->isIntegralOrEnumerationType() &&
"unexpected converted const type");
6695 if (!R.isInvalid() && !R.get()->isValueDependent())
6703 const APValue &PreNarrowingValue) {
6715 Kind = ConstantExprKind::ClassTemplateArgument;
6717 Kind = ConstantExprKind::NonClassTemplateArgument;
6719 Kind = ConstantExprKind::Normal;
6722 (RequireInt && !Eval.
Val.
isInt())) {
6729 if (Notes.empty()) {
6732 if (
const auto *CE = dyn_cast<ConstantExpr>(E)) {
6736 "ConstantExpr has no value associated with it");
6742 Value = std::move(PreNarrowingValue);
6748 if (Notes.size() == 1 &&
6749 Notes[0].second.getDiagID() == diag::note_invalid_subexpr_in_const_expr) {
6750 Diag(Notes[0].first, diag::err_expr_not_cce) << CCE;
6751 }
else if (!Notes.empty() && Notes[0].second.getDiagID() ==
6752 diag::note_constexpr_invalid_template_arg) {
6753 Notes[0].second.setDiagID(diag::err_constexpr_invalid_template_arg);
6754 for (
unsigned I = 0; I < Notes.size(); ++I)
6755 Diag(Notes[I].first, Notes[I].second);
6759 for (
unsigned I = 0; I < Notes.size(); ++I)
6760 Diag(Notes[I].first, Notes[I].second);
6779static ImplicitConversionSequence
6787 AllowedExplicit::Conversions,
6829 "expected a member expression");
6831 if (
const auto M = dyn_cast<UnresolvedMemberExpr>(MemExprE);
6832 M && !M->isImplicitAccess())
6833 Base = M->getBase();
6834 else if (
const auto M = dyn_cast<MemberExpr>(MemExprE);
6835 M && !M->isImplicitAccess())
6836 Base = M->getBase();
6840 if (T->isPointerType())
6869 assert(Method->isExplicitObjectMemberFunction() &&
6870 "Method is not an explicit member function");
6871 assert(NewArgs.empty() &&
"NewArgs should be empty");
6873 NewArgs.reserve(Args.size() + 1);
6875 NewArgs.push_back(
This);
6876 NewArgs.append(Args.begin(), Args.end());
6879 Method,
Object->getBeginLoc());
6885 return AllowScopedEnumerations ? T->isIntegralOrEnumerationType()
6886 : T->isIntegralOrUnscopedEnumerationType();
6898 for (
unsigned I = 0, N = ViableConversions.
size(); I != N; ++I) {
6910 QualType T,
bool HadMultipleCandidates,
6912 if (ExplicitConversions.
size() == 1 && !Converter.
Suppress) {
6920 std::string TypeStr;
6925 "static_cast<" + TypeStr +
">(")
6937 HadMultipleCandidates);
6944 From,
Result.get()->getType());
6954 QualType T,
bool HadMultipleCandidates,
6970 HadMultipleCandidates);
6975 CK_UserDefinedConversion,
Result.get(),
6976 nullptr,
Result.get()->getValueKind(),
7001 if (
auto *ConvTemplate = dyn_cast<FunctionTemplateDecl>(D)) {
7003 ConvTemplate, FoundDecl, ActingContext, From, ToType, CandidateSet,
7009 Conv, FoundDecl, ActingContext, From, ToType, CandidateSet,
7043 From = result.
get();
7049 From = Converted.
isUsable() ? Converted.
get() :
nullptr;
7051 if (Converter.
match(T))
7058 const RecordType *RecordTy = T->getAsCanonical<RecordType>();
7071 : Converter(Converter), From(From) {}
7076 } IncompleteDiagnoser(Converter, From);
7087 ->getDefinitionOrSelf()
7088 ->getVisibleConversionFunctions();
7090 bool HadMultipleCandidates =
7095 bool HasUniqueTargetType =
true;
7111 "Conversion operator templates are considered potentially "
7115 if (Converter.
match(CurToType) || ConvTemplate) {
7121 ExplicitConversions.
addDecl(I.getDecl(), I.getAccess());
7126 else if (HasUniqueTargetType &&
7128 HasUniqueTargetType =
false;
7130 ViableConversions.
addDecl(I.getDecl(), I.getAccess());
7148 HadMultipleCandidates,
7149 ExplicitConversions))
7155 if (!HasUniqueTargetType)
7174 HadMultipleCandidates,
Found))
7183 HadMultipleCandidates,
7184 ExplicitConversions))
7192 switch (ViableConversions.
size()) {
7195 HadMultipleCandidates,
7196 ExplicitConversions))
7206 HadMultipleCandidates,
Found))
7237 if (Proto->getNumParams() < 1)
7241 QualType ArgType = Proto->getParamType(0).getNonReferenceType();
7242 if (Context.hasSameUnqualifiedType(T1, ArgType))
7246 if (Proto->getNumParams() < 2)
7250 QualType ArgType = Proto->getParamType(1).getNonReferenceType();
7251 if (Context.hasSameUnqualifiedType(T2, ArgType))
7270 unsigned SeenAt = 0;
7272 bool HasDefault =
false;
7281 return HasDefault || SeenAt != 0;
7287 bool PartialOverloading,
bool AllowExplicit,
bool AllowExplicitConversions,
7290 bool StrictPackMatch) {
7293 assert(Proto &&
"Functions without a prototype cannot be overloaded");
7294 assert(!
Function->getDescribedFunctionTemplate() &&
7295 "Use AddTemplateOverloadCandidate for function templates");
7308 CandidateSet, SuppressUserConversions,
7309 PartialOverloading, EarlyConversions, PO,
7345 CandidateSet.
addCandidate(Args.size(), EarlyConversions);
7359 Candidate.
Viable =
false;
7372 bool IsImplicitlyInstantiated =
false;
7373 if (
auto *SpecInfo =
Function->getTemplateSpecializationInfo()) {
7374 ND = SpecInfo->getTemplate();
7375 IsImplicitlyInstantiated = SpecInfo->getTemplateSpecializationKind() ==
7386 const bool IsInlineFunctionInGMF =
7388 (IsImplicitlyInstantiated ||
Function->isInlined());
7391 Candidate.
Viable =
false;
7398 Candidate.
Viable =
false;
7409 if (Args.size() == 1 &&
Constructor->isSpecializationCopyingObject() &&
7410 (
Context.hasSameUnqualifiedType(ClassType, Args[0]->getType()) ||
7413 Candidate.
Viable =
false;
7425 auto *Shadow = dyn_cast<ConstructorUsingShadowDecl>(FoundDecl.
getDecl());
7426 if (Shadow && Args.size() == 1 &&
Constructor->getNumParams() >= 1 &&
7427 Constructor->getParamDecl(0)->getType()->isReferenceType()) {
7434 Candidate.
Viable =
false;
7443 Constructor->getMethodQualifiers().getAddressSpace(),
7445 Candidate.
Viable =
false;
7458 Candidate.
Viable =
false;
7468 unsigned MinRequiredArgs =
Function->getMinRequiredArguments();
7469 if (!AggregateCandidateDeduction && Args.size() < MinRequiredArgs &&
7470 !PartialOverloading) {
7472 Candidate.
Viable =
false;
7486 Candidate.
Viable =
false;
7492 if (
Function->getTrailingRequiresClause()) {
7497 Candidate.
Viable =
false;
7506 for (
unsigned ArgIdx = 0; ArgIdx < Args.size(); ++ArgIdx) {
7509 if (Candidate.
Conversions[ConvIdx].isInitialized()) {
7512 }
else if (ArgIdx < NumParams) {
7523 Args[ArgIdx]->
getType().getAddressSpace() ==
7525 Diag(Args[ArgIdx]->getBeginLoc(), diag::warn_hlsl_groupshared_inout);
7528 *
this, Args[ArgIdx], ParamType, SuppressUserConversions,
7531 getLangOpts().ObjCAutoRefCount, AllowExplicitConversions);
7533 Candidate.
Viable =
false;
7545 if (EnableIfAttr *FailedAttr =
7547 Candidate.
Viable =
false;
7557 if (Methods.size() <= 1)
7560 for (
unsigned b = 0, e = Methods.size(); b < e; b++) {
7566 if (
Method->param_size() > NumNamedArgs)
7567 NumNamedArgs =
Method->param_size();
7568 if (Args.size() < NumNamedArgs)
7571 for (
unsigned i = 0; i < NumNamedArgs; i++) {
7573 if (Args[i]->isTypeDependent()) {
7579 Expr *argExpr = Args[i];
7580 assert(argExpr &&
"SelectBestMethod(): missing expression");
7585 !param->
hasAttr<CFConsumedAttr>())
7586 argExpr =
ObjC().stripARCUnbridgedCast(argExpr);
7603 if (ConversionState.
isBad() ||
7613 for (
unsigned i = NumNamedArgs, e = Args.size(); i < e; ++i) {
7614 if (Args[i]->isTypeDependent()) {
7627 if (Args.size() != NumNamedArgs)
7629 else if (
Match && NumNamedArgs == 0 && Methods.size() > 1) {
7632 for (
unsigned b = 0, e = Methods.size(); b < e; b++) {
7633 QualType ReturnT = Methods[b]->getReturnType();
7653 "Shouldn't have `this` for ctors!");
7654 assert(!Method->isStatic() &&
"Shouldn't have `this` for static methods!");
7656 ThisArg, std::nullopt, Method, Method);
7659 ConvertedThis = R.get();
7661 if (
auto *MD = dyn_cast<CXXMethodDecl>(Function)) {
7663 assert((MissingImplicitThis || MD->isStatic() ||
7665 "Expected `this` for non-ctor instance methods");
7667 ConvertedThis =
nullptr;
7672 unsigned ArgSizeNoVarargs = std::min(Function->param_size(), Args.size());
7675 for (
unsigned I = 0; I != ArgSizeNoVarargs; ++I) {
7678 S.
Context, Function->getParamDecl(I)),
7684 ConvertedArgs.push_back(R.get());
7691 if (!Function->isVariadic() && Args.size() < Function->getNumParams()) {
7692 for (
unsigned i = Args.size(), e = Function->getNumParams(); i != e; ++i) {
7699 ConvertedArgs.push_back(R.get());
7711 bool MissingImplicitThis) {
7712 auto EnableIfAttrs =
Function->specific_attrs<EnableIfAttr>();
7713 if (EnableIfAttrs.begin() == EnableIfAttrs.end())
7719 llvm::scope_exit UndelayDiags(
7721 DelayedDiagnostics.popUndelayed(CurrentState);
7725 Expr *DiscardedThis;
7727 *
this,
Function,
nullptr, CallLoc, Args, Trap,
7728 true, DiscardedThis, ConvertedArgs))
7729 return *EnableIfAttrs.begin();
7731 for (
auto *EIA : EnableIfAttrs) {
7735 if (EIA->getCond()->isValueDependent() ||
7736 !EIA->getCond()->EvaluateWithSubstitution(
7740 if (!
Result.isInt() || !
Result.getInt().getBoolValue())
7746template <
typename CheckFn>
7749 CheckFn &&IsSuccessful) {
7752 if (ArgDependent == DIA->getArgDependent())
7753 Attrs.push_back(DIA);
7760 auto WarningBegin = std::stable_partition(
7761 Attrs.begin(), Attrs.end(), [](
const DiagnoseIfAttr *DIA) {
7762 return DIA->getDefaultSeverity() == DiagnoseIfAttr::DS_error &&
7763 DIA->getWarningGroup().empty();
7768 auto ErrAttr = llvm::find_if(llvm::make_range(Attrs.begin(), WarningBegin),
7770 if (ErrAttr != WarningBegin) {
7771 const DiagnoseIfAttr *DIA = *ErrAttr;
7772 S.
Diag(Loc, diag::err_diagnose_if_succeeded) << DIA->getMessage();
7773 S.
Diag(DIA->getLocation(), diag::note_from_diagnose_if)
7774 << DIA->getParent() << DIA->getCond()->getSourceRange();
7778 auto ToSeverity = [](DiagnoseIfAttr::DefaultSeverity Sev) {
7780 case DiagnoseIfAttr::DS_warning:
7782 case DiagnoseIfAttr::DS_error:
7785 llvm_unreachable(
"Fully covered switch above!");
7788 for (
const auto *DIA : llvm::make_range(WarningBegin, Attrs.end()))
7789 if (IsSuccessful(DIA)) {
7790 if (DIA->getWarningGroup().empty() &&
7791 DIA->getDefaultSeverity() == DiagnoseIfAttr::DS_warning) {
7792 S.
Diag(Loc, diag::warn_diagnose_if_succeeded) << DIA->getMessage();
7793 S.
Diag(DIA->getLocation(), diag::note_from_diagnose_if)
7794 << DIA->getParent() << DIA->getCond()->getSourceRange();
7797 DIA->getWarningGroup());
7800 {ToSeverity(DIA->getDefaultSeverity()),
"%0",
7802 S.
Diag(Loc, DiagID) << DIA->getMessage();
7810 const Expr *ThisArg,
7815 [&](
const DiagnoseIfAttr *DIA) {
7820 if (!DIA->getCond()->EvaluateWithSubstitution(
7823 return Result.isInt() &&
Result.getInt().getBoolValue();
7830 *
this, ND,
false, Loc,
7831 [&](
const DiagnoseIfAttr *DIA) {
7833 return DIA->getCond()->EvaluateAsBooleanCondition(
Result,
Context) &&
7842 bool SuppressUserConversions,
7843 bool PartialOverloading,
7844 bool FirstArgumentIsBase) {
7856 if (Args.size() > 0) {
7857 if (
Expr *E = Args[0]) {
7867 FunctionArgs = Args.slice(1);
7871 FunTmpl, F.getPair(),
7873 ExplicitTemplateArgs, ObjectType, ObjectClassification,
7874 FunctionArgs, CandidateSet, SuppressUserConversions,
7875 PartialOverloading);
7879 ObjectClassification, FunctionArgs, CandidateSet,
7880 SuppressUserConversions, PartialOverloading);
7887 if (Args.size() > 0 &&
7891 FunctionArgs = Args.slice(1);
7895 ExplicitTemplateArgs, FunctionArgs,
7896 CandidateSet, SuppressUserConversions,
7897 PartialOverloading);
7900 SuppressUserConversions, PartialOverloading);
7910 bool SuppressUserConversions,
7920 "Expected a member function template");
7922 nullptr, ObjectType,
7923 ObjectClassification, Args, CandidateSet,
7924 SuppressUserConversions,
false, PO);
7927 ObjectType, ObjectClassification, Args, CandidateSet,
7928 SuppressUserConversions,
false, {}, PO);
7941 assert(Proto &&
"Methods without a prototype cannot be overloaded");
7943 "Use AddOverloadCandidate for constructors");
7952 Method->isMoveAssignmentOperator())
7959 bool IgnoreExplicitObject =
7960 (
Method->isExplicitObjectMemberFunction() &&
7963 bool ImplicitObjectMethodTreatedAsStatic =
7966 Method->isImplicitObjectMemberFunction();
7968 unsigned ExplicitOffset =
7969 !IgnoreExplicitObject &&
Method->isExplicitObjectMemberFunction() ? 1 : 0;
7971 unsigned NumParams =
Method->getNumParams() - ExplicitOffset +
7972 int(ImplicitObjectMethodTreatedAsStatic);
7974 unsigned ExtraArgs =
7981 CandidateSet.
addCandidate(Args.size() + ExtraArgs, EarlyConversions);
7997 Candidate.
Viable =
false;
8007 unsigned MinRequiredArgs =
Method->getMinRequiredArguments() -
8009 int(ImplicitObjectMethodTreatedAsStatic);
8011 if (Args.size() < MinRequiredArgs && !PartialOverloading) {
8013 Candidate.
Viable =
false;
8021 if (!IgnoreExplicitObject) {
8024 else if (
Method->isStatic()) {
8034 Candidate.
Conversions[FirstConvIdx].setStaticObjectArgument();
8039 *
this, CandidateSet.
getLocation(), ObjectType, ObjectClassification,
8040 Method, ActingContext,
true);
8041 if (Candidate.
Conversions[FirstConvIdx].isBad()) {
8042 Candidate.
Viable =
false;
8053 Candidate.
Viable =
false;
8058 if (
Method->getTrailingRequiresClause()) {
8063 Candidate.
Viable =
false;
8071 for (
unsigned ArgIdx = 0; ArgIdx < Args.size(); ++ArgIdx) {
8074 if (Candidate.
Conversions[ConvIdx].isInitialized()) {
8077 }
else if (ArgIdx < NumParams) {
8083 if (ImplicitObjectMethodTreatedAsStatic) {
8084 ParamType = ArgIdx == 0
8085 ?
Method->getFunctionObjectParameterReferenceType()
8088 ParamType = Proto->
getParamType(ArgIdx + ExplicitOffset);
8092 SuppressUserConversions,
8097 Candidate.
Viable =
false;
8109 if (EnableIfAttr *FailedAttr =
8111 Candidate.
Viable =
false;
8118 Candidate.
Viable =
false;
8129 bool SuppressUserConversions,
bool PartialOverloading,
8147 PartialOverloading,
false,
8148 false, ObjectType, ObjectClassification,
8152 bool OnlyInitializeNonUserDefinedConversions) {
8153 return S.CheckNonDependentConversions(
8154 MethodTmpl, ParamTypes, Args, CandidateSet, Conversions,
8155 Sema::CheckNonDependentConversionsFlag(
8156 SuppressUserConversions,
8157 OnlyInitializeNonUserDefinedConversions),
8158 ActingContext, ObjectType, ObjectClassification, PO);
8162 CandidateSet.
addCandidate(Conversions.size(), Conversions);
8165 Candidate.
Viable =
false;
8174 Method->isStatic() ||
8175 (!Method->isExplicitObjectMemberFunction() && ObjectType.
isNull());
8189 assert(
Specialization &&
"Missing member function template specialization?");
8191 "Specialization is not a member function?");
8194 ObjectClassification, Args, CandidateSet, SuppressUserConversions,
8208 if (ExplicitTemplateArgs ||
8211 *
this, CandidateSet, MethodTmpl, FoundDecl, ActingContext,
8212 ExplicitTemplateArgs, ObjectType, ObjectClassification, Args,
8213 SuppressUserConversions, PartialOverloading, PO);
8218 MethodTmpl, FoundDecl, ActingContext, ObjectType, ObjectClassification,
8219 Args, SuppressUserConversions, PartialOverloading, PO);
8237 bool SuppressUserConversions,
bool PartialOverloading,
bool AllowExplicit,
8239 bool AggregateCandidateDeduction) {
8248 Candidate.
Viable =
false;
8268 PartialOverloading, AggregateCandidateDeduction,
8275 bool OnlyInitializeNonUserDefinedConversions) {
8276 return S.CheckNonDependentConversions(
8277 FunctionTemplate, ParamTypes, Args, CandidateSet, Conversions,
8278 Sema::CheckNonDependentConversionsFlag(
8279 SuppressUserConversions,
8280 OnlyInitializeNonUserDefinedConversions),
8281 nullptr, QualType(), {}, PO);
8284 OverloadCandidate &Candidate =
8285 CandidateSet.addCandidate(Conversions.size(), Conversions);
8288 Candidate.
Viable =
false;
8290 CandidateSet.getRewriteInfo().getRewriteKind(Candidate.
Function, PO);
8296 CandidateSet.getKind() ==
8302 ->isExplicitObjectMemberFunction() &&
8318 assert(
Specialization &&
"Missing function template specialization?");
8320 Specialization, FoundDecl, Args, CandidateSet, SuppressUserConversions,
8321 PartialOverloading, AllowExplicit,
8322 false, IsADLCandidate, Conversions, PO,
8323 Info.AggregateDeductionCandidateHasMismatchedArity,
8324 Info.hasStrictPackMatch());
8331 bool PartialOverloading,
bool AllowExplicit,
ADLCallKind IsADLCandidate,
8338 if (ExplicitTemplateArgs ||
8341 DependentExplicitSpecifier)) {
8345 Args, SuppressUserConversions, PartialOverloading, AllowExplicit,
8346 IsADLCandidate, PO, AggregateCandidateDeduction);
8348 if (DependentExplicitSpecifier)
8355 PartialOverloading, AllowExplicit, IsADLCandidate, PO,
8356 AggregateCandidateDeduction);
8369 const bool AllowExplicit =
false;
8371 bool ForOverloadSetAddressResolution =
8374 auto *
Method = dyn_cast<CXXMethodDecl>(FD);
8375 bool HasThisConversion = !ForOverloadSetAddressResolution &&
Method &&
8377 unsigned ThisConversions = HasThisConversion ? 1 : 0;
8393 if (!FD->hasCXXExplicitFunctionObjectParameter() ||
8394 !ParamTypes[0]->isDependentType()) {
8396 *
this, CandidateSet.
getLocation(), ObjectType, ObjectClassification,
8397 Method, ActingContext,
true,
8398 FD->hasCXXExplicitFunctionObjectParameter() ? ParamTypes[0]
8408 auto MaybeInvolveUserDefinedConversion = [&](
QualType ParamType,
8432 if (
auto *RD =
ArgType->getAsCXXRecordDecl();
8433 RD && RD->hasDefinition() &&
8434 !RD->getVisibleConversionFunctions().empty())
8441 HasThisConversion &&
Method->hasCXXExplicitFunctionObjectParameter() ? 1
8444 for (
unsigned I = 0, N = std::min(ParamTypes.size() - Offset, Args.size());
8446 QualType ParamType = ParamTypes[I + Offset];
8450 ConvIdx = Args.size() - 1 - I;
8451 assert(Args.size() + ThisConversions == 2 &&
8452 "number of args (including 'this') must be exactly 2 for "
8456 assert(!HasThisConversion || (ConvIdx == 0 && I == 0));
8459 ConvIdx = ThisConversions + I;
8464 MaybeInvolveUserDefinedConversion(ParamType, Args[I]->
getType()))
8493 bool AllowObjCPointerConversion) {
8501 bool ObjCLifetimeConversion;
8503 ObjCLifetimeConversion))
8508 if (!AllowObjCPointerConversion)
8512 bool IncompatibleObjC =
false;
8522 bool AllowExplicit,
bool AllowResultConversion,
bool StrictPackMatch) {
8524 "Conversion function templates use AddTemplateConversionCandidate");
8539 if (!AllowResultConversion &&
8551 AllowObjCConversionOnExplicit))
8573 if (!AllowExplicit && Conversion->
isExplicit()) {
8574 Candidate.
Viable =
false;
8601 Candidate.
Viable =
false;
8610 Candidate.
Viable =
false;
8621 QualType ToCanon =
Context.getCanonicalType(ToType).getUnqualifiedType();
8622 if (FromCanon == ToCanon ||
8624 Candidate.
Viable =
false;
8641 CK_FunctionToPointerDecay, &ConversionRef,
8646 Candidate.
Viable =
false;
8676 Candidate.
Viable =
false;
8688 Candidate.
Viable =
false;
8695 Candidate.
Viable =
false;
8701 "Can only end up with a standard conversion sequence or failure");
8704 if (EnableIfAttr *FailedAttr =
8706 Candidate.
Viable =
false;
8713 Candidate.
Viable =
false;
8722 bool AllowObjCConversionOnExplicit,
bool AllowExplicit,
8723 bool AllowResultConversion) {
8732 Candidate.
Viable =
false;
8749 Candidate.
Viable =
false;
8759 assert(
Specialization &&
"Missing function template specialization?");
8761 ToType, CandidateSet, AllowObjCConversionOnExplicit,
8762 AllowExplicit, AllowResultConversion,
8770 bool AllowExplicit,
bool AllowResultConversion) {
8772 "Only conversion function templates permitted here");
8783 ToType, AllowObjCConversionOnExplicit, AllowExplicit,
8784 AllowResultConversion);
8792 AllowObjCConversionOnExplicit, AllowExplicit, AllowResultConversion);
8831 if (ObjectInit.
isBad()) {
8832 Candidate.
Viable =
false;
8843 Candidate.
Conversions[0].UserDefined.EllipsisConversion =
false;
8844 Candidate.
Conversions[0].UserDefined.HadMultipleCandidates =
false;
8845 Candidate.
Conversions[0].UserDefined.ConversionFunction = Conversion;
8846 Candidate.
Conversions[0].UserDefined.FoundConversionFunction = FoundDecl;
8849 Candidate.
Conversions[0].UserDefined.After.setAsIdentityConversion();
8857 if (Args.size() > NumParams && !Proto->
isVariadic()) {
8858 Candidate.
Viable =
false;
8865 if (Args.size() < NumParams) {
8867 Candidate.
Viable =
false;
8874 for (
unsigned ArgIdx = 0, N = Args.size(); ArgIdx != N; ++ArgIdx) {
8875 if (ArgIdx < NumParams) {
8888 Candidate.
Viable =
false;
8905 Candidate.
Viable =
false;
8911 if (EnableIfAttr *FailedAttr =
8913 Candidate.
Viable =
false;
8937 "unqualified operator lookup found a member function");
8941 FunctionArgs, CandidateSet);
8947 FunctionArgs[1], FunctionArgs[0]);
8949 Reversed, CandidateSet,
false,
false,
true,
8950 ADLCallKind::NotADL,
8954 if (ExplicitTemplateArgs)
8959 {FunctionArgs[1], FunctionArgs[0]}, CandidateSet,
8960 false,
false,
true,
false, ADLCallKind::NotADL, {},
8992 if (!T1RD || (!IsComplete && !T1RD->isBeingDefined()))
9000 OperEnd = Operators.
end();
9001 Oper != OperEnd; ++Oper) {
9002 if (Oper->getAsFunction() &&
9005 *
this, {Args[1], Args[0]}, Oper->getAsFunction()))
9008 Args[0]->Classify(
Context), Args.slice(1),
9009 CandidateSet,
false, PO);
9016 bool IsAssignmentOperator,
9017 unsigned NumContextualBoolArguments) {
9032 for (
unsigned ArgIdx = 0, N = Args.size(); ArgIdx != N; ++ArgIdx) {
9045 if (ArgIdx < NumContextualBoolArguments) {
9046 assert(ParamTys[ArgIdx] ==
Context.BoolTy &&
9047 "Contextual conversion to bool requires bool type");
9053 ArgIdx == 0 && IsAssignmentOperator,
9059 Candidate.
Viable =
false;
9072class BuiltinCandidateTypeSet {
9078 TypeSet PointerTypes;
9082 TypeSet MemberPointerTypes;
9086 TypeSet EnumerationTypes;
9090 TypeSet VectorTypes;
9094 TypeSet MatrixTypes;
9097 TypeSet BitIntTypes;
9100 bool HasNonRecordTypes;
9104 bool HasArithmeticOrEnumeralTypes;
9108 bool HasNullPtrType;
9117 bool AddPointerWithMoreQualifiedTypeVariants(
QualType Ty,
9119 bool AddMemberPointerWithMoreQualifiedTypeVariants(
QualType Ty);
9123 typedef TypeSet::iterator
iterator;
9125 BuiltinCandidateTypeSet(
Sema &SemaRef)
9126 : HasNonRecordTypes(
false),
9127 HasArithmeticOrEnumeralTypes(
false),
9128 HasNullPtrType(
false),
9130 Context(SemaRef.Context) { }
9132 void AddTypesConvertedFrom(
QualType Ty,
9134 bool AllowUserConversions,
9135 bool AllowExplicitConversions,
9136 const Qualifiers &VisibleTypeConversionsQuals);
9138 llvm::iterator_range<iterator> pointer_types() {
return PointerTypes; }
9139 llvm::iterator_range<iterator> member_pointer_types() {
9140 return MemberPointerTypes;
9142 llvm::iterator_range<iterator> enumeration_types() {
9143 return EnumerationTypes;
9145 llvm::iterator_range<iterator> vector_types() {
return VectorTypes; }
9146 llvm::iterator_range<iterator> matrix_types() {
return MatrixTypes; }
9147 llvm::iterator_range<iterator> bitint_types() {
return BitIntTypes; }
9149 bool containsMatrixType(QualType Ty)
const {
return MatrixTypes.count(Ty); }
9150 bool hasNonRecordTypes() {
return HasNonRecordTypes; }
9151 bool hasArithmeticOrEnumeralTypes() {
return HasArithmeticOrEnumeralTypes; }
9152 bool hasNullPtrType()
const {
return HasNullPtrType; }
9167BuiltinCandidateTypeSet::AddPointerWithMoreQualifiedTypeVariants(QualType Ty,
9168 const Qualifiers &VisibleQuals) {
9171 if (!PointerTypes.insert(Ty))
9175 const PointerType *PointerTy = Ty->
getAs<PointerType>();
9176 bool buildObjCPtr =
false;
9178 const ObjCObjectPointerType *PTy = Ty->
castAs<ObjCObjectPointerType>();
9180 buildObjCPtr =
true;
9192 unsigned BaseCVR = PointeeTy.getCVRQualifiers();
9198 if ((CVR | BaseCVR) != CVR)
continue;
9213 QualType QPointerTy;
9220 PointerTypes.insert(QPointerTy);
9236BuiltinCandidateTypeSet::AddMemberPointerWithMoreQualifiedTypeVariants(
9239 if (!MemberPointerTypes.insert(Ty))
9242 const MemberPointerType *PointerTy = Ty->
getAs<MemberPointerType>();
9243 assert(PointerTy &&
"type was not a member pointer type!");
9258 if ((CVR | BaseCVR) != CVR)
continue;
9262 QPointeeTy, std::nullopt, Cls));
9277BuiltinCandidateTypeSet::AddTypesConvertedFrom(QualType Ty,
9279 bool AllowUserConversions,
9280 bool AllowExplicitConversions,
9281 const Qualifiers &VisibleQuals) {
9287 if (
const ReferenceType *RefTy = Ty->
getAs<ReferenceType>())
9292 Ty = SemaRef.Context.getArrayDecayedType(Ty);
9299 HasNonRecordTypes = HasNonRecordTypes || !TyIsRec;
9302 HasArithmeticOrEnumeralTypes =
9306 PointerTypes.insert(Ty);
9307 else if (Ty->
getAs<PointerType>() || Ty->
getAs<ObjCObjectPointerType>()) {
9310 if (!AddPointerWithMoreQualifiedTypeVariants(Ty, VisibleQuals))
9314 if (!AddMemberPointerWithMoreQualifiedTypeVariants(Ty))
9317 HasArithmeticOrEnumeralTypes =
true;
9318 EnumerationTypes.insert(Ty);
9320 HasArithmeticOrEnumeralTypes =
true;
9321 BitIntTypes.insert(Ty);
9325 HasArithmeticOrEnumeralTypes =
true;
9326 VectorTypes.insert(Ty);
9330 HasArithmeticOrEnumeralTypes =
true;
9331 MatrixTypes.insert(Ty);
9333 HasNullPtrType =
true;
9334 }
else if (AllowUserConversions && TyIsRec) {
9336 if (!SemaRef.isCompleteType(Loc, Ty))
9340 for (NamedDecl *D : ClassDecl->getVisibleConversionFunctions()) {
9350 if (AllowExplicitConversions || !Conv->
isExplicit()) {
9398 ClassDecl = RHSMPType->getMostRecentCXXRecordDecl();
9446 if (Available.hasAtomic()) {
9447 Available.removeAtomic();
9454 if (Available.hasVolatile()) {
9455 Available.removeVolatile();
9489class BuiltinOperatorOverloadBuilder {
9492 ArrayRef<Expr *> Args;
9493 QualifiersAndAtomic VisibleTypeConversionsQuals;
9494 bool HasArithmeticOrEnumeralCandidateType;
9495 SmallVectorImpl<BuiltinCandidateTypeSet> &CandidateTypes;
9496 OverloadCandidateSet &CandidateSet;
9498 static constexpr int ArithmeticTypesCap = 26;
9499 SmallVector<CanQualType, ArithmeticTypesCap> ArithmeticTypes;
9504 unsigned FirstIntegralType,
9506 unsigned FirstPromotedIntegralType,
9507 LastPromotedIntegralType;
9508 unsigned FirstPromotedArithmeticType,
9509 LastPromotedArithmeticType;
9510 unsigned NumArithmeticTypes;
9512 void InitArithmeticTypes() {
9514 FirstPromotedArithmeticType = 0;
9524 FirstIntegralType = ArithmeticTypes.size();
9525 FirstPromotedIntegralType = ArithmeticTypes.size();
9547 llvm::SmallSetVector<CanQualType, 2> BitIntCandidates;
9548 for (BuiltinCandidateTypeSet &Candidate : CandidateTypes) {
9549 for (QualType BitTy : Candidate.bitint_types())
9552 llvm::move(BitIntCandidates, std::back_inserter(ArithmeticTypes));
9553 LastPromotedIntegralType = ArithmeticTypes.size();
9554 LastPromotedArithmeticType = ArithmeticTypes.size();
9568 LastIntegralType = ArithmeticTypes.size();
9569 NumArithmeticTypes = ArithmeticTypes.size();
9576 assert(ArithmeticTypes.size() - BitIntCandidates.size() <=
9577 ArithmeticTypesCap &&
9578 "Enough inline storage for all arithmetic types.");
9583 void addPlusPlusMinusMinusStyleOverloads(QualType CandidateTy,
9586 QualType ParamTypes[2] = {
9626 void AddCandidate(QualType L, QualType R) {
9627 QualType LandR[2] = {L,
R};
9632 BuiltinOperatorOverloadBuilder(
9633 Sema &S, ArrayRef<Expr *> Args,
9634 QualifiersAndAtomic VisibleTypeConversionsQuals,
9635 bool HasArithmeticOrEnumeralCandidateType,
9636 SmallVectorImpl<BuiltinCandidateTypeSet> &CandidateTypes,
9637 OverloadCandidateSet &CandidateSet)
9639 VisibleTypeConversionsQuals(VisibleTypeConversionsQuals),
9640 HasArithmeticOrEnumeralCandidateType(
9641 HasArithmeticOrEnumeralCandidateType),
9642 CandidateTypes(CandidateTypes),
9643 CandidateSet(CandidateSet) {
9645 InitArithmeticTypes();
9668 if (!HasArithmeticOrEnumeralCandidateType)
9671 for (
unsigned Arith = 0; Arith < NumArithmeticTypes; ++Arith) {
9672 const auto TypeOfT = ArithmeticTypes[Arith];
9674 if (Op == OO_MinusMinus)
9676 if (Op == OO_PlusPlus && S.
getLangOpts().CPlusPlus17)
9679 addPlusPlusMinusMinusStyleOverloads(
9696 void addPlusPlusMinusMinusPointerOverloads() {
9697 for (QualType PtrTy : CandidateTypes[0].pointer_types()) {
9699 if (!PtrTy->getPointeeType()->isObjectType())
9702 addPlusPlusMinusMinusStyleOverloads(
9704 (!PtrTy.isVolatileQualified() &&
9706 (!PtrTy.isRestrictQualified() &&
9721 void addUnaryStarPointerOverloads() {
9722 for (QualType ParamTy : CandidateTypes[0].pointer_types()) {
9727 if (
const FunctionProtoType *Proto =PointeeTy->
getAs<FunctionProtoType>())
9728 if (Proto->getMethodQuals() || Proto->getRefQualifier())
9741 void addUnaryPlusOrMinusArithmeticOverloads() {
9742 if (!HasArithmeticOrEnumeralCandidateType)
9745 for (
unsigned Arith = FirstPromotedArithmeticType;
9746 Arith < LastPromotedArithmeticType; ++Arith) {
9747 QualType ArithTy = ArithmeticTypes[Arith];
9752 for (QualType VecTy : CandidateTypes[0].vector_types())
9761 void addUnaryPlusPointerOverloads() {
9762 for (QualType ParamTy : CandidateTypes[0].pointer_types())
9771 void addUnaryTildePromotedIntegralOverloads() {
9772 if (!HasArithmeticOrEnumeralCandidateType)
9775 for (
unsigned Int = FirstPromotedIntegralType;
9776 Int < LastPromotedIntegralType; ++
Int) {
9777 QualType IntTy = ArithmeticTypes[
Int];
9782 for (QualType VecTy : CandidateTypes[0].vector_types())
9792 void addEqualEqualOrNotEqualMemberPointerOrNullptrOverloads() {
9794 llvm::SmallPtrSet<QualType, 8> AddedTypes;
9796 for (
unsigned ArgIdx = 0, N = Args.size(); ArgIdx != N; ++ArgIdx) {
9797 for (QualType MemPtrTy : CandidateTypes[ArgIdx].member_pointer_types()) {
9802 QualType ParamTypes[2] = {MemPtrTy, MemPtrTy};
9806 if (CandidateTypes[ArgIdx].hasNullPtrType()) {
9808 if (AddedTypes.insert(NullPtrTy).second) {
9809 QualType ParamTypes[2] = { NullPtrTy, NullPtrTy };
9828 void addGenericBinaryPointerOrEnumeralOverloads(
bool IsSpaceship) {
9841 llvm::DenseSet<std::pair<CanQualType, CanQualType> >
9842 UserDefinedBinaryOperators;
9844 for (
unsigned ArgIdx = 0, N = Args.size(); ArgIdx != N; ++ArgIdx) {
9845 if (!CandidateTypes[ArgIdx].enumeration_types().empty()) {
9847 CEnd = CandidateSet.
end();
9849 if (!
C->Viable || !
C->Function ||
C->Function->getNumParams() != 2)
9852 if (
C->Function->isFunctionTemplateSpecialization())
9859 QualType FirstParamType =
C->Function->getParamDecl(
Reversed ? 1 : 0)
9861 .getUnqualifiedType();
9862 QualType SecondParamType =
C->Function->getParamDecl(
Reversed ? 0 : 1)
9864 .getUnqualifiedType();
9872 UserDefinedBinaryOperators.insert(
9880 llvm::SmallPtrSet<QualType, 8> AddedTypes;
9882 for (
unsigned ArgIdx = 0, N = Args.size(); ArgIdx != N; ++ArgIdx) {
9883 for (QualType PtrTy : CandidateTypes[ArgIdx].pointer_types()) {
9887 if (IsSpaceship && PtrTy->isFunctionPointerType())
9890 QualType ParamTypes[2] = {PtrTy, PtrTy};
9893 for (QualType EnumTy : CandidateTypes[ArgIdx].enumeration_types()) {
9898 if (!AddedTypes.insert(CanonType).second ||
9899 UserDefinedBinaryOperators.count(std::make_pair(CanonType,
9902 QualType ParamTypes[2] = {EnumTy, EnumTy};
9927 llvm::SmallPtrSet<QualType, 8> AddedTypes;
9929 for (
int Arg = 0; Arg < 2; ++Arg) {
9930 QualType AsymmetricParamTypes[2] = {
9934 for (QualType PtrTy : CandidateTypes[Arg].pointer_types()) {
9939 AsymmetricParamTypes[Arg] = PtrTy;
9940 if (Arg == 0 || Op == OO_Plus) {
9945 if (Op == OO_Minus) {
9950 QualType ParamTypes[2] = {PtrTy, PtrTy};
9986 void addGenericBinaryArithmeticOverloads() {
9987 if (!HasArithmeticOrEnumeralCandidateType)
9990 for (
unsigned Left = FirstPromotedArithmeticType;
9991 Left < LastPromotedArithmeticType; ++
Left) {
9992 for (
unsigned Right = FirstPromotedArithmeticType;
9993 Right < LastPromotedArithmeticType; ++
Right) {
9994 QualType LandR[2] = { ArithmeticTypes[
Left],
9995 ArithmeticTypes[
Right] };
10002 for (QualType Vec1Ty : CandidateTypes[0].vector_types())
10003 for (QualType Vec2Ty : CandidateTypes[1].vector_types()) {
10004 QualType LandR[2] = {Vec1Ty, Vec2Ty};
10014 void addMatrixBinaryArithmeticOverloads() {
10015 if (!HasArithmeticOrEnumeralCandidateType)
10018 for (QualType M1 : CandidateTypes[0].matrix_types()) {
10020 AddCandidate(M1, M1);
10023 for (QualType M2 : CandidateTypes[1].matrix_types()) {
10025 if (!CandidateTypes[0].containsMatrixType(M2))
10026 AddCandidate(M2, M2);
10061 void addThreeWayArithmeticOverloads() {
10062 addGenericBinaryArithmeticOverloads();
10079 void addBinaryBitwiseArithmeticOverloads() {
10080 if (!HasArithmeticOrEnumeralCandidateType)
10083 for (
unsigned Left = FirstPromotedIntegralType;
10084 Left < LastPromotedIntegralType; ++
Left) {
10085 for (
unsigned Right = FirstPromotedIntegralType;
10086 Right < LastPromotedIntegralType; ++
Right) {
10087 QualType LandR[2] = { ArithmeticTypes[
Left],
10088 ArithmeticTypes[
Right] };
10101 void addAssignmentMemberPointerOrEnumeralOverloads() {
10103 llvm::SmallPtrSet<QualType, 8> AddedTypes;
10105 for (
unsigned ArgIdx = 0; ArgIdx < 2; ++ArgIdx) {
10106 for (QualType EnumTy : CandidateTypes[ArgIdx].enumeration_types()) {
10113 for (QualType MemPtrTy : CandidateTypes[ArgIdx].member_pointer_types()) {
10138 void addAssignmentPointerOverloads(
bool isEqualOp) {
10140 llvm::SmallPtrSet<QualType, 8> AddedTypes;
10142 for (QualType PtrTy : CandidateTypes[0].pointer_types()) {
10146 else if (!PtrTy->getPointeeType()->isObjectType())
10150 QualType ParamTypes[2] = {
10157 bool NeedVolatile = !PtrTy.isVolatileQualified() &&
10159 if (NeedVolatile) {
10167 if (!PtrTy.isRestrictQualified() &&
10175 if (NeedVolatile) {
10187 for (QualType PtrTy : CandidateTypes[1].pointer_types()) {
10192 QualType ParamTypes[2] = {
10201 bool NeedVolatile = !PtrTy.isVolatileQualified() &&
10203 if (NeedVolatile) {
10211 if (!PtrTy.isRestrictQualified() &&
10219 if (NeedVolatile) {
10244 void addAssignmentArithmeticOverloads(
bool isEqualOp) {
10245 if (!HasArithmeticOrEnumeralCandidateType)
10248 for (
unsigned Left = 0;
Left < NumArithmeticTypes; ++
Left) {
10249 for (
unsigned Right = FirstPromotedArithmeticType;
10250 Right < LastPromotedArithmeticType; ++
Right) {
10251 QualType ParamTypes[2];
10252 ParamTypes[1] = ArithmeticTypes[
Right];
10254 S, ArithmeticTypes[Left], Args[0]);
10257 VisibleTypeConversionsQuals, [&](QualifiersAndAtomic Quals) {
10267 for (QualType Vec1Ty : CandidateTypes[0].vector_types())
10268 for (QualType Vec2Ty : CandidateTypes[0].vector_types()) {
10269 QualType ParamTypes[2];
10270 ParamTypes[1] = Vec2Ty;
10298 void addAssignmentIntegralOverloads() {
10299 if (!HasArithmeticOrEnumeralCandidateType)
10302 for (
unsigned Left = FirstIntegralType;
Left < LastIntegralType; ++
Left) {
10303 for (
unsigned Right = FirstPromotedIntegralType;
10304 Right < LastPromotedIntegralType; ++
Right) {
10305 QualType ParamTypes[2];
10306 ParamTypes[1] = ArithmeticTypes[
Right];
10308 S, ArithmeticTypes[Left], Args[0]);
10311 VisibleTypeConversionsQuals, [&](QualifiersAndAtomic Quals) {
10327 void addExclaimOverload() {
10333 void addAmpAmpOrPipePipeOverload() {
10350 void addSubscriptOverloads() {
10351 for (QualType PtrTy : CandidateTypes[0].pointer_types()) {
10361 for (QualType PtrTy : CandidateTypes[1].pointer_types()) {
10381 void addArrowStarOverloads() {
10382 for (QualType PtrTy : CandidateTypes[0].pointer_types()) {
10383 QualType C1Ty = PtrTy;
10385 QualifierCollector Q1;
10396 for (QualType MemPtrTy : CandidateTypes[1].member_pointer_types()) {
10403 QualType ParamTypes[2] = {PtrTy, MemPtrTy};
10406 if (!VisibleTypeConversionsQuals.
hasVolatile() &&
10409 if (!VisibleTypeConversionsQuals.
hasRestrict() &&
10428 void addConditionalOperatorOverloads() {
10430 llvm::SmallPtrSet<QualType, 8> AddedTypes;
10432 for (
unsigned ArgIdx = 0; ArgIdx < 2; ++ArgIdx) {
10433 for (QualType PtrTy : CandidateTypes[ArgIdx].pointer_types()) {
10437 QualType ParamTypes[2] = {PtrTy, PtrTy};
10441 for (QualType MemPtrTy : CandidateTypes[ArgIdx].member_pointer_types()) {
10445 QualType ParamTypes[2] = {MemPtrTy, MemPtrTy};
10450 for (QualType EnumTy : CandidateTypes[ArgIdx].enumeration_types()) {
10451 if (!EnumTy->castAsCanonical<EnumType>()->getDecl()->isScoped())
10457 QualType ParamTypes[2] = {EnumTy, EnumTy};
10476 VisibleTypeConversionsQuals.
addConst();
10477 for (
unsigned ArgIdx = 0, N = Args.size(); ArgIdx != N; ++ArgIdx) {
10479 if (Args[ArgIdx]->
getType()->isAtomicType())
10480 VisibleTypeConversionsQuals.
addAtomic();
10483 bool HasNonRecordCandidateType =
false;
10484 bool HasArithmeticOrEnumeralCandidateType =
false;
10486 for (
unsigned ArgIdx = 0, N = Args.size(); ArgIdx != N; ++ArgIdx) {
10487 CandidateTypes.emplace_back(*
this);
10488 CandidateTypes[ArgIdx].AddTypesConvertedFrom(Args[ArgIdx]->
getType(),
10491 (Op == OO_Exclaim ||
10493 Op == OO_PipePipe),
10494 VisibleTypeConversionsQuals);
10495 HasNonRecordCandidateType = HasNonRecordCandidateType ||
10496 CandidateTypes[ArgIdx].hasNonRecordTypes();
10497 HasArithmeticOrEnumeralCandidateType =
10498 HasArithmeticOrEnumeralCandidateType ||
10499 CandidateTypes[ArgIdx].hasArithmeticOrEnumeralTypes();
10507 if (!HasNonRecordCandidateType &&
10508 !(Op == OO_Exclaim || Op == OO_AmpAmp || Op == OO_PipePipe))
10512 BuiltinOperatorOverloadBuilder OpBuilder(*
this, Args,
10513 VisibleTypeConversionsQuals,
10514 HasArithmeticOrEnumeralCandidateType,
10515 CandidateTypes, CandidateSet);
10521 llvm_unreachable(
"Expected an overloaded operator");
10526 case OO_Array_Delete:
10529 "Special operators don't use AddBuiltinOperatorCandidates");
10541 if (Args.size() == 1)
10542 OpBuilder.addUnaryPlusPointerOverloads();
10546 if (Args.size() == 1) {
10547 OpBuilder.addUnaryPlusOrMinusArithmeticOverloads();
10549 OpBuilder.addBinaryPlusOrMinusPointerOverloads(Op);
10550 OpBuilder.addGenericBinaryArithmeticOverloads();
10551 OpBuilder.addMatrixBinaryArithmeticOverloads();
10556 if (Args.size() == 1)
10557 OpBuilder.addUnaryStarPointerOverloads();
10559 OpBuilder.addGenericBinaryArithmeticOverloads();
10560 OpBuilder.addMatrixBinaryArithmeticOverloads();
10565 OpBuilder.addGenericBinaryArithmeticOverloads();
10569 case OO_MinusMinus:
10570 OpBuilder.addPlusPlusMinusMinusArithmeticOverloads(Op);
10571 OpBuilder.addPlusPlusMinusMinusPointerOverloads();
10574 case OO_EqualEqual:
10575 case OO_ExclaimEqual:
10576 OpBuilder.addEqualEqualOrNotEqualMemberPointerOrNullptrOverloads();
10577 OpBuilder.addGenericBinaryPointerOrEnumeralOverloads(
false);
10578 OpBuilder.addGenericBinaryArithmeticOverloads();
10584 case OO_GreaterEqual:
10585 OpBuilder.addGenericBinaryPointerOrEnumeralOverloads(
false);
10586 OpBuilder.addGenericBinaryArithmeticOverloads();
10590 OpBuilder.addGenericBinaryPointerOrEnumeralOverloads(
true);
10591 OpBuilder.addThreeWayArithmeticOverloads();
10598 case OO_GreaterGreater:
10599 OpBuilder.addBinaryBitwiseArithmeticOverloads();
10603 if (Args.size() == 1)
10609 OpBuilder.addBinaryBitwiseArithmeticOverloads();
10613 OpBuilder.addUnaryTildePromotedIntegralOverloads();
10617 OpBuilder.addAssignmentMemberPointerOrEnumeralOverloads();
10621 case OO_MinusEqual:
10622 OpBuilder.addAssignmentPointerOverloads(Op == OO_Equal);
10626 case OO_SlashEqual:
10627 OpBuilder.addAssignmentArithmeticOverloads(Op == OO_Equal);
10630 case OO_PercentEqual:
10631 case OO_LessLessEqual:
10632 case OO_GreaterGreaterEqual:
10634 case OO_CaretEqual:
10636 OpBuilder.addAssignmentIntegralOverloads();
10640 OpBuilder.addExclaimOverload();
10645 OpBuilder.addAmpAmpOrPipePipeOverload();
10649 if (Args.size() == 2)
10650 OpBuilder.addSubscriptOverloads();
10654 OpBuilder.addArrowStarOverloads();
10657 case OO_Conditional:
10658 OpBuilder.addConditionalOperatorOverloads();
10659 OpBuilder.addGenericBinaryArithmeticOverloads();
10670 bool PartialOverloading) {
10687 CandEnd = CandidateSet.
end();
10688 Cand != CandEnd; ++Cand)
10689 if (Cand->Function) {
10693 Fns.
erase(FunTmpl);
10702 if (ExplicitTemplateArgs)
10706 FD, FoundDecl, Args, CandidateSet,
false,
10707 PartialOverloading,
true,
10708 false, ADLCallKind::UsesADL);
10711 FD, FoundDecl, {Args[1], Args[0]}, CandidateSet,
10712 false, PartialOverloading,
10719 FTD, FoundDecl, ExplicitTemplateArgs, Args, CandidateSet,
10720 false, PartialOverloading,
10721 true, ADLCallKind::UsesADL);
10723 *
this, Args, FTD->getTemplatedDecl())) {
10727 if (ReversedArgs.empty())
10731 FTD, FoundDecl, ExplicitTemplateArgs, ReversedArgs, CandidateSet,
10732 false, PartialOverloading,
10733 true, ADLCallKind::UsesADL,
10758 bool Cand1Attr = Cand1->
hasAttr<EnableIfAttr>();
10759 bool Cand2Attr = Cand2->
hasAttr<EnableIfAttr>();
10760 if (!Cand1Attr || !Cand2Attr) {
10761 if (Cand1Attr == Cand2Attr)
10762 return Comparison::Equal;
10763 return Cand1Attr ? Comparison::Better : Comparison::Worse;
10769 llvm::FoldingSetNodeID Cand1ID, Cand2ID;
10770 for (
auto Pair : zip_longest(Cand1Attrs, Cand2Attrs)) {
10771 std::optional<EnableIfAttr *> Cand1A = std::get<0>(Pair);
10772 std::optional<EnableIfAttr *> Cand2A = std::get<1>(Pair);
10777 return Comparison::Worse;
10779 return Comparison::Better;
10784 (*Cand1A)->getCond()->Profile(Cand1ID, S.
getASTContext(),
true);
10785 (*Cand2A)->getCond()->Profile(Cand2ID, S.
getASTContext(),
true);
10786 if (Cand1ID != Cand2ID)
10787 return Comparison::Worse;
10790 return Comparison::Equal;
10798 return Comparison::Equal;
10804 return Comparison::Equal;
10805 return Comparison::Worse;
10808 return Comparison::Better;
10814 const auto *Cand1CPUSpec = Cand1.
Function->
getAttr<CPUSpecificAttr>();
10815 const auto *Cand2CPUSpec = Cand2.
Function->
getAttr<CPUSpecificAttr>();
10817 if (!Cand1CPUDisp && !Cand2CPUDisp && !Cand1CPUSpec && !Cand2CPUSpec)
10818 return Comparison::Equal;
10820 if (Cand1CPUDisp && !Cand2CPUDisp)
10821 return Comparison::Better;
10822 if (Cand2CPUDisp && !Cand1CPUDisp)
10823 return Comparison::Worse;
10825 if (Cand1CPUSpec && Cand2CPUSpec) {
10826 if (Cand1CPUSpec->cpus_size() != Cand2CPUSpec->cpus_size())
10827 return Cand1CPUSpec->cpus_size() < Cand2CPUSpec->cpus_size()
10828 ? Comparison::Better
10829 : Comparison::Worse;
10831 std::pair<CPUSpecificAttr::cpus_iterator, CPUSpecificAttr::cpus_iterator>
10832 FirstDiff = std::mismatch(
10833 Cand1CPUSpec->cpus_begin(), Cand1CPUSpec->cpus_end(),
10834 Cand2CPUSpec->cpus_begin(),
10836 return LHS->getName() == RHS->getName();
10839 assert(FirstDiff.first != Cand1CPUSpec->cpus_end() &&
10840 "Two different cpu-specific versions should not have the same "
10841 "identifier list, otherwise they'd be the same decl!");
10842 return (*FirstDiff.first)->getName() < (*FirstDiff.second)->getName()
10843 ? Comparison::Better
10844 : Comparison::Worse;
10846 llvm_unreachable(
"No way to get here unless both had cpu_dispatch");
10852static std::optional<QualType>
10855 return std::nullopt;
10861 return M->getFunctionObjectParameterReferenceType();
10875 PT2->getInstantiatedFromMemberTemplate()))
10886 assert(I < F->getNumParams());
10893 if (F1NumParams != F2NumParams)
10896 unsigned I1 = 0, I2 = 0;
10897 for (
unsigned I = 0; I != F1NumParams; ++I) {
10898 QualType T1 = NextParam(F1, I1, I == 0);
10899 QualType T2 = NextParam(F2, I2, I == 0);
10900 assert(!T1.
isNull() && !T2.
isNull() &&
"Unexpected null param types");
10901 if (!Context.hasSameUnqualifiedType(T1, T2))
10914 bool IsFn1Reversed,
10915 bool IsFn2Reversed) {
10916 assert(Fn1 && Fn2);
10921 IsFn1Reversed ^ IsFn2Reversed))
10924 auto *Mem1 = dyn_cast<CXXMethodDecl>(Fn1);
10925 auto *Mem2 = dyn_cast<CXXMethodDecl>(Fn2);
10926 if (Mem1 && Mem2) {
10929 if (Mem1->getParent() != Mem2->getParent())
10933 if (Mem1->isInstance() && Mem2->isInstance() &&
10935 Mem1->getFunctionObjectParameterReferenceType(),
10936 Mem1->getFunctionObjectParameterReferenceType()))
10942static FunctionDecl *
10944 bool IsFn1Reversed,
bool IsFn2Reversed) {
10954 if (Cand1IsSpecialization || Cand2IsSpecialization)
10971 bool PartialOverloading) {
11017 bool IsCand1ImplicitHD =
11019 bool IsCand2ImplicitHD =
11034 auto EmitThreshold =
11035 (S.
getLangOpts().CUDAIsDevice && IsCallerImplicitHD &&
11036 (IsCand1ImplicitHD || IsCand2ImplicitHD))
11039 auto Cand1Emittable = P1 > EmitThreshold;
11040 auto Cand2Emittable = P2 > EmitThreshold;
11041 if (Cand1Emittable && !Cand2Emittable)
11043 if (!Cand1Emittable && Cand2Emittable)
11054 unsigned StartArg = 0;
11062 return ICS.isStandard() &&
11074 assert(Cand2.
Conversions.size() == NumArgs &&
"Overload candidate mismatch");
11075 bool HasBetterConversion =
false;
11076 for (
unsigned ArgIdx = StartArg; ArgIdx < NumArgs; ++ArgIdx) {
11077 bool Cand1Bad = IsIllFormedConversion(Cand1.
Conversions[ArgIdx]);
11078 bool Cand2Bad = IsIllFormedConversion(Cand2.
Conversions[ArgIdx]);
11079 if (Cand1Bad != Cand2Bad) {
11082 HasBetterConversion =
true;
11086 if (HasBetterConversion)
11093 bool HasWorseConversion =
false;
11094 for (
unsigned ArgIdx = StartArg; ArgIdx < NumArgs; ++ArgIdx) {
11100 HasBetterConversion =
true;
11119 HasWorseConversion =
true;
11134 if (HasBetterConversion && !HasWorseConversion)
11185 bool Cand1IsSpecialization = Cand1.
Function &&
11187 bool Cand2IsSpecialization = Cand2.
Function &&
11189 if (Cand1IsSpecialization != Cand2IsSpecialization)
11190 return Cand2IsSpecialization;
11196 if (Cand1IsSpecialization && Cand2IsSpecialization) {
11197 const auto *Obj1Context =
11199 const auto *Obj2Context =
11228 bool Cand1IsInherited =
11230 bool Cand2IsInherited =
11232 if (Cand1IsInherited != Cand2IsInherited)
11233 return Cand2IsInherited;
11234 else if (Cand1IsInherited) {
11235 assert(Cand2IsInherited);
11238 if (Cand1Class->isDerivedFrom(Cand2Class))
11240 if (Cand2Class->isDerivedFrom(Cand1Class))
11257 auto *Guide1 = dyn_cast_or_null<CXXDeductionGuideDecl>(Cand1.
Function);
11258 auto *Guide2 = dyn_cast_or_null<CXXDeductionGuideDecl>(Cand2.
Function);
11259 if (Guide1 && Guide2) {
11261 if (Guide1->isImplicit() != Guide2->isImplicit())
11262 return Guide2->isImplicit();
11272 const auto *Constructor1 = Guide1->getCorrespondingConstructor();
11273 const auto *Constructor2 = Guide2->getCorrespondingConstructor();
11274 if (Constructor1 && Constructor2) {
11275 bool isC1Templated = Constructor1->getTemplatedKind() !=
11277 bool isC2Templated = Constructor2->getTemplatedKind() !=
11279 if (isC1Templated != isC2Templated)
11280 return isC2Templated;
11288 if (
Cmp != Comparison::Equal)
11289 return Cmp == Comparison::Better;
11292 bool HasPS1 = Cand1.
Function !=
nullptr &&
11294 bool HasPS2 = Cand2.
Function !=
nullptr &&
11296 if (HasPS1 != HasPS2 && HasPS1)
11300 if (MV == Comparison::Better)
11302 if (MV == Comparison::Worse)
11317 const auto *CD1 = dyn_cast_or_null<CXXConstructorDecl>(Cand1.
Function);
11318 const auto *CD2 = dyn_cast_or_null<CXXConstructorDecl>(Cand2.
Function);
11320 LangAS AS1 = CD1->getMethodQualifiers().getAddressSpace();
11321 LangAS AS2 = CD2->getMethodQualifiers().getAddressSpace();
11342 auto *VA = dyn_cast_or_null<ValueDecl>(A);
11343 auto *VB = dyn_cast_or_null<ValueDecl>(B);
11349 if (!VA->getDeclContext()->getRedeclContext()->Equals(
11350 VB->getDeclContext()->getRedeclContext()) ||
11352 VA->isExternallyVisible() || VB->isExternallyVisible())
11360 if (
Context.hasSameType(VA->getType(), VB->getType()))
11365 if (
auto *EA = dyn_cast<EnumConstantDecl>(VA)) {
11366 if (
auto *EB = dyn_cast<EnumConstantDecl>(VB)) {
11371 if (EnumA->hasNameForLinkage() || EnumB->hasNameForLinkage() ||
11372 !
Context.hasSameType(EnumA->getIntegerType(),
11373 EnumB->getIntegerType()))
11376 return llvm::APSInt::isSameValue(EA->getInitVal(), EB->getInitVal());
11386 assert(D &&
"Unknown declaration");
11387 Diag(Loc, diag::ext_equivalent_internal_linkage_decl_in_modules) << D;
11393 for (
auto *E : Equiv) {
11395 Diag(E->getLocation(), diag::note_equivalent_internal_linkage_decl)
11405 ->Satisfaction.ContainsErrors;
11411 bool PartialOverloading,
bool AllowExplicit,
11413 bool AggregateCandidateDeduction) {
11416 allocateDeferredCandidate<DeferredFunctionTemplateOverloadCandidate>();
11421 false, AllowExplicit, SuppressUserConversions,
11422 PartialOverloading, AggregateCandidateDeduction},
11429 HasDeferredTemplateConstructors |=
11437 bool SuppressUserConversions,
bool PartialOverloading,
11443 allocateDeferredCandidate<DeferredMethodTemplateOverloadCandidate>();
11449 false, SuppressUserConversions, PartialOverloading,
11455 ObjectClassification,
11463 bool AllowObjCConversionOnExplicit,
bool AllowExplicit,
11464 bool AllowResultConversion) {
11467 allocateDeferredCandidate<DeferredConversionTemplateOverloadCandidate>();
11471 AllowObjCConversionOnExplicit, AllowResultConversion,
11488 S, CandidateSet,
C.FunctionTemplate,
C.FoundDecl,
C.ActingContext,
11489 nullptr,
C.ObjectType,
C.ObjectClassification,
11490 C.Args,
C.SuppressUserConversions,
C.PartialOverloading,
C.PO);
11497 S, CandidateSet,
C.FunctionTemplate,
C.FoundDecl,
11498 nullptr,
C.Args,
C.SuppressUserConversions,
11499 C.PartialOverloading,
C.AllowExplicit,
C.IsADLCandidate,
C.PO,
11500 C.AggregateCandidateDeduction);
11507 S, CandidateSet,
C.FunctionTemplate,
C.FoundDecl,
C.ActingContext,
C.From,
11508 C.ToType,
C.AllowObjCConversionOnExplicit,
C.AllowExplicit,
11509 C.AllowResultConversion);
11513 Candidates.reserve(Candidates.size() + DeferredCandidatesCount);
11516 switch (Cand->
Kind) {
11535 FirstDeferredCandidate =
nullptr;
11536 DeferredCandidatesCount = 0;
11540OverloadCandidateSet::ResultForBestCandidate(
const iterator &Best) {
11542 if (Best->Function && Best->Function->isDeleted())
11547void OverloadCandidateSet::CudaExcludeWrongSideCandidates(
11564 bool ContainsSameSideCandidate =
11572 if (!ContainsSameSideCandidate)
11575 auto IsWrongSideCandidate = [&](
const OverloadCandidate *Cand) {
11581 llvm::erase_if(Candidates, IsWrongSideCandidate);
11599 DeferredCandidatesCount == 0) &&
11600 "Unexpected deferred template candidates");
11602 bool TwoPhaseResolution =
11603 DeferredCandidatesCount != 0 && !ResolutionByPerfectCandidateIsDisabled;
11605 if (TwoPhaseResolution) {
11607 if (Best !=
end() && Best->isPerfectMatch(S.
Context)) {
11608 if (!(HasDeferredTemplateConstructors &&
11609 isa_and_nonnull<CXXConversionDecl>(Best->Function)))
11615 return BestViableFunctionImpl(S, Loc, Best);
11622 Candidates.reserve(this->Candidates.size());
11623 std::transform(this->Candidates.begin(), this->Candidates.end(),
11624 std::back_inserter(Candidates),
11628 CudaExcludeWrongSideCandidates(S, Candidates);
11631 for (
auto *Cand : Candidates) {
11632 Cand->
Best =
false;
11634 if (Best ==
end() ||
11651 llvm::SmallVector<OverloadCandidate *, 4> PendingBest;
11652 llvm::SmallVector<const NamedDecl *, 4> EquivalentCands;
11653 PendingBest.push_back(&*Best);
11658 while (!PendingBest.empty()) {
11659 auto *Curr = PendingBest.pop_back_val();
11660 for (
auto *Cand : Candidates) {
11663 PendingBest.push_back(Cand);
11668 EquivalentCands.push_back(Cand->
Function);
11680 if (!EquivalentCands.empty())
11688enum OverloadCandidateKind {
11691 oc_reversed_binary_operator,
11693 oc_implicit_default_constructor,
11694 oc_implicit_copy_constructor,
11695 oc_implicit_move_constructor,
11696 oc_implicit_copy_assignment,
11697 oc_implicit_move_assignment,
11698 oc_implicit_equality_comparison,
11699 oc_inherited_constructor
11702enum OverloadCandidateSelect {
11705 ocs_described_template,
11708static std::pair<OverloadCandidateKind, OverloadCandidateSelect>
11709ClassifyOverloadCandidate(Sema &S,
const NamedDecl *
Found,
11710 const FunctionDecl *Fn,
11712 std::string &Description) {
11715 if (FunctionTemplateDecl *FunTmpl =
Fn->getPrimaryTemplate()) {
11718 FunTmpl->getTemplateParameters(), *
Fn->getTemplateSpecializationArgs());
11721 OverloadCandidateSelect Select = [&]() {
11722 if (!Description.empty())
11723 return ocs_described_template;
11724 return isTemplate ? ocs_template : ocs_non_template;
11727 OverloadCandidateKind Kind = [&]() {
11728 if (
Fn->isImplicit() &&
Fn->getOverloadedOperator() == OO_EqualEqual)
11729 return oc_implicit_equality_comparison;
11732 return oc_reversed_binary_operator;
11734 if (
const auto *Ctor = dyn_cast<CXXConstructorDecl>(Fn)) {
11735 if (!Ctor->isImplicit()) {
11737 return oc_inherited_constructor;
11739 return oc_constructor;
11742 if (Ctor->isDefaultConstructor())
11743 return oc_implicit_default_constructor;
11745 if (Ctor->isMoveConstructor())
11746 return oc_implicit_move_constructor;
11748 assert(Ctor->isCopyConstructor() &&
11749 "unexpected sort of implicit constructor");
11750 return oc_implicit_copy_constructor;
11753 if (
const auto *Meth = dyn_cast<CXXMethodDecl>(Fn)) {
11756 if (!Meth->isImplicit())
11759 if (Meth->isMoveAssignmentOperator())
11760 return oc_implicit_move_assignment;
11762 if (Meth->isCopyAssignmentOperator())
11763 return oc_implicit_copy_assignment;
11769 return oc_function;
11772 return std::make_pair(Kind, Select);
11775void MaybeEmitInheritedConstructorNote(Sema &S,
const Decl *FoundDecl) {
11778 if (
const auto *Shadow = dyn_cast<ConstructorUsingShadowDecl>(FoundDecl))
11780 diag::note_ovl_candidate_inherited_constructor)
11781 << Shadow->getNominatedBaseClass();
11790 if (EnableIf->getCond()->isValueDependent() ||
11791 !EnableIf->getCond()->EvaluateAsBooleanCondition(AlwaysTrue, Ctx))
11808 bool InOverloadResolution,
11812 if (InOverloadResolution)
11814 diag::note_addrof_ovl_candidate_disabled_by_enable_if_attr);
11816 S.
Diag(Loc, diag::err_addrof_function_disabled_by_enable_if_attr) << FD;
11827 if (InOverloadResolution) {
11830 TemplateArgString +=
" ";
11832 FunTmpl->getTemplateParameters(),
11837 diag::note_ovl_candidate_unsatisfied_constraints)
11838 << TemplateArgString;
11840 S.
Diag(Loc, diag::err_addrof_function_constraints_not_satisfied)
11849 return P->hasAttr<PassObjectSizeAttr>();
11856 unsigned ParamNo = std::distance(FD->
param_begin(), I) + 1;
11857 if (InOverloadResolution)
11859 diag::note_ovl_candidate_has_pass_object_size_params)
11862 S.
Diag(Loc, diag::err_address_of_function_with_pass_object_size_params)
11878 return ::checkAddressOfFunctionIsAvailable(*
this,
Function, Complain,
11886 const auto *ConvD = dyn_cast<CXXConversionDecl>(Fn);
11891 if (!RD->isLambda())
11896 CallOp->getType()->castAs<
FunctionType>()->getCallConv();
11901 return ConvToCC != CallOpCC;
11907 QualType DestType,
bool TakingAddress) {
11910 if (Fn->isMultiVersion() && Fn->hasAttr<TargetAttr>() &&
11911 !Fn->getAttr<TargetAttr>()->isDefaultVersion())
11913 if (Fn->isMultiVersion() && Fn->hasAttr<TargetVersionAttr>() &&
11914 !Fn->getAttr<TargetVersionAttr>()->isDefaultVersion())
11919 std::string FnDesc;
11920 std::pair<OverloadCandidateKind, OverloadCandidateSelect> KSPair =
11921 ClassifyOverloadCandidate(*
this,
Found, Fn, RewriteKind, FnDesc);
11923 << (
unsigned)KSPair.first << (
unsigned)KSPair.second
11927 Diag(Fn->getLocation(), PD);
11928 MaybeEmitInheritedConstructorNote(*
this,
Found);
11946 FunctionDecl *FirstCand =
nullptr, *SecondCand =
nullptr;
11947 for (
auto I = Cands.begin(), E = Cands.end(); I != E; ++I) {
11951 if (
auto *
Template = I->Function->getPrimaryTemplate())
11952 Template->getAssociatedConstraints(AC);
11954 I->Function->getAssociatedConstraints(AC);
11957 if (FirstCand ==
nullptr) {
11958 FirstCand = I->Function;
11960 }
else if (SecondCand ==
nullptr) {
11961 SecondCand = I->Function;
11974 SecondCand, SecondAC))
11983 bool TakingAddress) {
11993 dyn_cast<FunctionTemplateDecl>((*I)->getUnderlyingDecl()) ) {
11997 = dyn_cast<FunctionDecl>((*I)->getUnderlyingDecl()) ) {
12010 S.
Diag(CaretLoc, PDiag)
12012 unsigned CandsShown = 0;
12026 unsigned I,
bool TakingCandidateAddress) {
12028 assert(Conv.
isBad());
12029 assert(Cand->
Function &&
"for now, candidate must be a function");
12035 bool isObjectArgument =
false;
12039 isObjectArgument =
true;
12044 std::string FnDesc;
12045 std::pair<OverloadCandidateKind, OverloadCandidateSelect> FnKindPair =
12056 bool HasParamPack =
12057 llvm::any_of(Fn->parameters().take_front(I), [](
const ParmVarDecl *Parm) {
12058 return Parm->isParameterPack();
12060 if (!isObjectArgument && !HasParamPack && I < Fn->getNumParams())
12061 ToParamRange = Fn->getParamDecl(I)->getSourceRange();
12064 assert(FromExpr &&
"overload set argument came from implicit argument?");
12070 S.
Diag(Fn->getLocation(), diag::note_ovl_candidate_bad_overload)
12071 << (
unsigned)FnKindPair.first << (
unsigned)FnKindPair.second << FnDesc
12072 << ToParamRange << ToTy << Name << I + 1;
12073 MaybeEmitInheritedConstructorNote(S, Cand->
FoundDecl);
12082 CToTy = RT->getPointeeType();
12087 CFromTy = FromPT->getPointeeType();
12088 CToTy = ToPT->getPointeeType();
12098 if (isObjectArgument)
12099 S.
Diag(Fn->getLocation(), diag::note_ovl_candidate_bad_addrspace_this)
12100 << (
unsigned)FnKindPair.first << (
unsigned)FnKindPair.second
12103 S.
Diag(Fn->getLocation(), diag::note_ovl_candidate_bad_addrspace)
12104 << (
unsigned)FnKindPair.first << (
unsigned)FnKindPair.second
12107 MaybeEmitInheritedConstructorNote(S, Cand->
FoundDecl);
12112 S.
Diag(Fn->getLocation(), diag::note_ovl_candidate_bad_ownership)
12113 << (
unsigned)FnKindPair.first << (
unsigned)FnKindPair.second << FnDesc
12116 MaybeEmitInheritedConstructorNote(S, Cand->
FoundDecl);
12121 S.
Diag(Fn->getLocation(), diag::note_ovl_candidate_bad_gc)
12122 << (
unsigned)FnKindPair.first << (
unsigned)FnKindPair.second << FnDesc
12125 MaybeEmitInheritedConstructorNote(S, Cand->
FoundDecl);
12130 S.
Diag(Fn->getLocation(), diag::note_ovl_candidate_bad_ptrauth)
12131 << (
unsigned)FnKindPair.first << (
unsigned)FnKindPair.second << FnDesc
12136 MaybeEmitInheritedConstructorNote(S, Cand->
FoundDecl);
12141 assert(CVR &&
"expected qualifiers mismatch");
12143 if (isObjectArgument) {
12144 S.
Diag(Fn->getLocation(), diag::note_ovl_candidate_bad_cvr_this)
12145 << (
unsigned)FnKindPair.first << (
unsigned)FnKindPair.second << FnDesc
12146 << FromTy << (CVR - 1);
12148 S.
Diag(Fn->getLocation(), diag::note_ovl_candidate_bad_cvr)
12149 << (
unsigned)FnKindPair.first << (
unsigned)FnKindPair.second << FnDesc
12150 << ToParamRange << FromTy << (CVR - 1) << I + 1;
12152 MaybeEmitInheritedConstructorNote(S, Cand->
FoundDecl);
12158 S.
Diag(Fn->getLocation(), diag::note_ovl_candidate_bad_value_category)
12159 << (
unsigned)FnKindPair.first << (
unsigned)FnKindPair.second << FnDesc
12160 << (
unsigned)isObjectArgument << I + 1
12163 MaybeEmitInheritedConstructorNote(S, Cand->
FoundDecl);
12170 S.
Diag(Fn->getLocation(), diag::note_ovl_candidate_bad_list_argument)
12171 << (
unsigned)FnKindPair.first << (
unsigned)FnKindPair.second << FnDesc
12172 << ToParamRange << FromTy << ToTy << (
unsigned)isObjectArgument << I + 1
12177 MaybeEmitInheritedConstructorNote(S, Cand->
FoundDecl);
12189 S.
Diag(Fn->getLocation(), diag::note_ovl_candidate_bad_conv_incomplete)
12190 << (
unsigned)FnKindPair.first << (
unsigned)FnKindPair.second << FnDesc
12191 << ToParamRange << FromTy << ToTy << (
unsigned)isObjectArgument << I + 1
12192 << (
unsigned)(Cand->
Fix.
Kind);
12194 MaybeEmitInheritedConstructorNote(S, Cand->
FoundDecl);
12199 unsigned BaseToDerivedConversion = 0;
12202 if (ToPtrTy->getPointeeType().isAtLeastAsQualifiedAs(
12204 !FromPtrTy->getPointeeType()->isIncompleteType() &&
12205 !ToPtrTy->getPointeeType()->isIncompleteType() &&
12207 FromPtrTy->getPointeeType()))
12208 BaseToDerivedConversion = 1;
12216 if (ToPtrTy->getPointeeType().isAtLeastAsQualifiedAs(
12218 FromIface->isSuperClassOf(ToIface))
12219 BaseToDerivedConversion = 2;
12221 if (ToRefTy->getPointeeType().isAtLeastAsQualifiedAs(FromTy,
12224 !ToRefTy->getPointeeType()->isIncompleteType() &&
12226 BaseToDerivedConversion = 3;
12230 if (BaseToDerivedConversion) {
12231 S.
Diag(Fn->getLocation(), diag::note_ovl_candidate_bad_base_to_derived_conv)
12232 << (
unsigned)FnKindPair.first << (
unsigned)FnKindPair.second << FnDesc
12233 << ToParamRange << (BaseToDerivedConversion - 1) << FromTy << ToTy
12235 MaybeEmitInheritedConstructorNote(S, Cand->
FoundDecl);
12244 S.
Diag(Fn->getLocation(), diag::note_ovl_candidate_bad_arc_conv)
12245 << (
unsigned)FnKindPair.first << (
unsigned)FnKindPair.second << FnDesc
12246 << ToParamRange << FromTy << ToTy << (
unsigned)isObjectArgument
12248 MaybeEmitInheritedConstructorNote(S, Cand->
FoundDecl);
12258 if (FromTy == S.
Context.AMDGPUFeaturePredicateTy &&
12261 diag::err_amdgcn_predicate_type_needs_explicit_bool_cast)
12268 FDiag << (
unsigned)FnKindPair.first << (
unsigned)FnKindPair.second << FnDesc
12269 << ToParamRange << FromTy << ToTy << (
unsigned)isObjectArgument << I + 1
12270 << (
unsigned)(Cand->
Fix.
Kind);
12279 S.
Diag(Fn->getLocation(), FDiag);
12281 MaybeEmitInheritedConstructorNote(S, Cand->
FoundDecl);
12288 unsigned NumArgs,
bool IsAddressOf =
false) {
12289 assert(Cand->
Function &&
"Candidate is required to be a function.");
12291 unsigned MinParams = Fn->getMinRequiredExplicitArguments() +
12292 ((IsAddressOf && !Fn->isStatic()) ? 1 : 0);
12299 if (Fn->isInvalidDecl() &&
12303 if (NumArgs < MinParams) {
12320 unsigned NumFormalArgs,
12321 bool IsAddressOf =
false) {
12323 "The templated declaration should at least be a function"
12324 " when diagnosing bad template argument deduction due to too many"
12325 " or too few arguments");
12331 unsigned MinParams = Fn->getMinRequiredExplicitArguments() +
12332 ((IsAddressOf && !Fn->isStatic()) ? 1 : 0);
12335 bool HasExplicitObjectParam =
12336 !IsAddressOf && Fn->hasCXXExplicitFunctionObjectParameter();
12338 unsigned ParamCount =
12339 Fn->getNumNonObjectParams() + ((IsAddressOf && !Fn->isStatic()) ? 1 : 0);
12340 unsigned mode, modeCount;
12342 if (NumFormalArgs < MinParams) {
12343 if (MinParams != ParamCount || FnTy->isVariadic() ||
12344 FnTy->isTemplateVariadic())
12348 modeCount = MinParams;
12350 if (MinParams != ParamCount)
12354 modeCount = ParamCount;
12357 std::string Description;
12358 std::pair<OverloadCandidateKind, OverloadCandidateSelect> FnKindPair =
12359 ClassifyOverloadCandidate(S,
Found, Fn,
CRK_None, Description);
12361 unsigned FirstNonObjectParamIdx = HasExplicitObjectParam ? 1 : 0;
12362 if (modeCount == 1 && !IsAddressOf &&
12363 FirstNonObjectParamIdx < Fn->getNumParams() &&
12364 Fn->getParamDecl(FirstNonObjectParamIdx)->getDeclName())
12365 S.
Diag(Fn->getLocation(), diag::note_ovl_candidate_arity_one)
12366 << (
unsigned)FnKindPair.first << (
unsigned)FnKindPair.second
12367 << Description << mode << Fn->getParamDecl(FirstNonObjectParamIdx)
12368 << NumFormalArgs << HasExplicitObjectParam
12369 << Fn->getParametersSourceRange();
12371 S.
Diag(Fn->getLocation(), diag::note_ovl_candidate_arity)
12372 << (
unsigned)FnKindPair.first << (
unsigned)FnKindPair.second
12373 << Description << mode << modeCount << NumFormalArgs
12374 << HasExplicitObjectParam << Fn->getParametersSourceRange();
12376 MaybeEmitInheritedConstructorNote(S,
Found);
12381 unsigned NumFormalArgs) {
12382 assert(Cand->
Function &&
"Candidate must be a function");
12392 llvm_unreachable(
"Unsupported: Getting the described template declaration"
12393 " for bad deduction diagnosis");
12400 bool TakingCandidateAddress) {
12406 switch (DeductionFailure.
getResult()) {
12409 "TemplateDeductionResult::Success while diagnosing bad deduction");
12411 llvm_unreachable(
"TemplateDeductionResult::NonDependentConversionFailure "
12412 "while diagnosing bad deduction");
12418 assert(ParamD &&
"no parameter found for incomplete deduction result");
12420 diag::note_ovl_candidate_incomplete_deduction)
12422 MaybeEmitInheritedConstructorNote(S,
Found);
12427 assert(ParamD &&
"no parameter found for incomplete deduction result");
12429 diag::note_ovl_candidate_incomplete_deduction_pack)
12431 << (DeductionFailure.
getFirstArg()->pack_size() + 1)
12433 MaybeEmitInheritedConstructorNote(S,
Found);
12438 assert(ParamD &&
"no parameter found for bad qualifiers deduction result");
12456 S.
Diag(Templated->
getLocation(), diag::note_ovl_candidate_underqualified)
12457 << ParamD->
getDeclName() << Arg << NonCanonParam;
12458 MaybeEmitInheritedConstructorNote(S,
Found);
12463 assert(ParamD &&
"no parameter found for inconsistent deduction result");
12477 diag::note_ovl_candidate_inconsistent_deduction_types)
12480 MaybeEmitInheritedConstructorNote(S,
Found);
12500 diag::note_ovl_candidate_inconsistent_deduction)
12503 MaybeEmitInheritedConstructorNote(S,
Found);
12508 assert(ParamD &&
"no parameter found for invalid explicit arguments");
12511 diag::note_ovl_candidate_explicit_arg_mismatch);
12513 Diag << diag::ExplicitArgMismatchNameKind::Named << ParamD->
getDeclName();
12515 Diag << diag::ExplicitArgMismatchNameKind::Unnamed
12520 Diag << diag::ExplicitArgMismatchReasonKind::Detailed << DiagContent;
12522 Diag << diag::ExplicitArgMismatchReasonKind::Vague;
12525 MaybeEmitInheritedConstructorNote(S,
Found);
12532 TemplateArgString =
" ";
12535 if (TemplateArgString.size() == 1)
12536 TemplateArgString.clear();
12538 diag::note_ovl_candidate_unsatisfied_constraints)
12539 << TemplateArgString;
12542 static_cast<CNSInfo*
>(DeductionFailure.
Data)->Satisfaction);
12552 diag::note_ovl_candidate_instantiation_depth);
12553 MaybeEmitInheritedConstructorNote(S,
Found);
12561 TemplateArgString =
" ";
12564 if (TemplateArgString.size() == 1)
12565 TemplateArgString.clear();
12570 if (PDiag && PDiag->second.getDiagID() ==
12571 diag::err_typename_nested_not_found_enable_if) {
12574 S.
Diag(PDiag->first, diag::note_ovl_candidate_disabled_by_enable_if)
12575 <<
"'enable_if'" << TemplateArgString;
12580 if (PDiag && PDiag->second.getDiagID() ==
12581 diag::err_typename_nested_not_found_requirement) {
12583 diag::note_ovl_candidate_disabled_by_requirement)
12584 << PDiag->second.getStringArg(0) << TemplateArgString;
12594 SFINAEArgString =
": ";
12596 PDiag->second.EmitToString(S.
getDiagnostics(), SFINAEArgString);
12600 diag::note_ovl_candidate_substitution_failure)
12601 << TemplateArgString << SFINAEArgString << R;
12602 MaybeEmitInheritedConstructorNote(S,
Found);
12612 TemplateArgString =
" ";
12615 if (TemplateArgString.size() == 1)
12616 TemplateArgString.clear();
12619 S.
Diag(Templated->
getLocation(), diag::note_ovl_candidate_deduced_mismatch)
12622 << TemplateArgString
12647 diag::note_ovl_candidate_non_deduced_mismatch_qualified)
12663 diag::note_ovl_candidate_non_deduced_mismatch)
12664 << FirstTA << SecondTA;
12670 S.
Diag(Templated->
getLocation(), diag::note_ovl_candidate_bad_deduction);
12671 MaybeEmitInheritedConstructorNote(S,
Found);
12675 diag::note_cuda_ovl_candidate_target_mismatch);
12683 bool TakingCandidateAddress) {
12684 assert(Cand->
Function &&
"Candidate must be a function");
12699 assert(Cand->
Function &&
"Candidate must be a Function.");
12705 std::string FnDesc;
12706 std::pair<OverloadCandidateKind, OverloadCandidateSelect> FnKindPair =
12707 ClassifyOverloadCandidate(S, Cand->
FoundDecl, Callee,
12710 S.
Diag(Callee->getLocation(), diag::note_ovl_candidate_bad_target)
12711 << (
unsigned)FnKindPair.first << (
unsigned)ocs_non_template
12713 << CalleeTarget << CallerTarget;
12718 if (Meth !=
nullptr && Meth->
isImplicit()) {
12722 switch (FnKindPair.first) {
12725 case oc_implicit_default_constructor:
12728 case oc_implicit_copy_constructor:
12731 case oc_implicit_move_constructor:
12734 case oc_implicit_copy_assignment:
12737 case oc_implicit_move_assignment:
12742 bool ConstRHS =
false;
12746 ConstRHS = RT->getPointeeType().isConstQualified();
12757 assert(Cand->
Function &&
"Candidate must be a function");
12761 S.
Diag(Callee->getLocation(),
12762 diag::note_ovl_candidate_disabled_by_function_cond_attr)
12763 <<
Attr->getCond()->getSourceRange() <<
Attr->getMessage();
12767 assert(Cand->
Function &&
"Candidate must be a function");
12770 assert(ES.
isExplicit() &&
"not an explicit candidate");
12773 switch (Fn->getDeclKind()) {
12774 case Decl::Kind::CXXConstructor:
12777 case Decl::Kind::CXXConversion:
12780 case Decl::Kind::CXXDeductionGuide:
12781 Kind = Fn->isImplicit() ? 0 : 2;
12784 llvm_unreachable(
"invalid Decl");
12793 First = Pattern->getFirstDecl();
12796 diag::note_ovl_candidate_explicit)
12797 << Kind << (ES.
getExpr() ? 1 : 0)
12802 auto *DG = dyn_cast<CXXDeductionGuideDecl>(Fn);
12809 if (!(DG->isImplicit() || (OriginTemplate && OriginTemplate->
isTypeAlias())))
12811 std::string FunctionProto;
12812 llvm::raw_string_ostream OS(FunctionProto);
12825 "Non-template implicit deduction guides are only possible for "
12828 S.
Diag(DG->getLocation(), diag::note_implicit_deduction_guide)
12833 assert(
Template &&
"Cannot find the associated function template of "
12834 "CXXDeductionGuideDecl?");
12837 S.
Diag(DG->getLocation(), diag::note_implicit_deduction_guide)
12858 bool TakingCandidateAddress,
12860 assert(Cand->
Function &&
"Candidate must be a function");
12868 if (S.
getLangOpts().OpenCL && Fn->isImplicit() &&
12875 !Fn->hasCXXExplicitFunctionObjectParameter() && !Fn->isStatic())
12880 if (Fn->isDeleted()) {
12881 std::string FnDesc;
12882 std::pair<OverloadCandidateKind, OverloadCandidateSelect> FnKindPair =
12883 ClassifyOverloadCandidate(S, Cand->
FoundDecl, Fn,
12886 S.
Diag(Fn->getLocation(), diag::note_ovl_candidate_deleted)
12887 << (
unsigned)FnKindPair.first << (
unsigned)FnKindPair.second << FnDesc
12888 << (Fn->isDeleted()
12889 ? (Fn->getCanonicalDecl()->isDeletedAsWritten() ? 1 : 2)
12891 MaybeEmitInheritedConstructorNote(S, Cand->
FoundDecl);
12918 TakingCandidateAddress);
12921 S.
Diag(Fn->getLocation(), diag::note_ovl_candidate_illegal_constructor)
12922 << (Fn->getPrimaryTemplate() ? 1 : 0);
12923 MaybeEmitInheritedConstructorNote(S, Cand->
FoundDecl);
12930 S.
Diag(Fn->getLocation(),
12931 diag::note_ovl_candidate_illegal_constructor_adrspace_mismatch)
12932 << QualsForPrinting;
12933 MaybeEmitInheritedConstructorNote(S, Cand->
FoundDecl);
12944 for (
unsigned N = Cand->
Conversions.size(); I != N; ++I)
12967 S.
Diag(Fn->getLocation(),
12968 diag::note_ovl_candidate_inherited_constructor_slice)
12969 << (Fn->getPrimaryTemplate() ? 1 : 0)
12970 << Fn->getParamDecl(0)->getType()->isRValueReferenceType();
12971 MaybeEmitInheritedConstructorNote(S, Cand->
FoundDecl);
12977 assert(!Available);
12985 std::string FnDesc;
12986 std::pair<OverloadCandidateKind, OverloadCandidateSelect> FnKindPair =
12987 ClassifyOverloadCandidate(S, Cand->
FoundDecl, Fn,
12990 S.
Diag(Fn->getLocation(),
12991 diag::note_ovl_candidate_constraints_not_satisfied)
12992 << (
unsigned)FnKindPair.first << (
unsigned)ocs_non_template
13011 bool isLValueReference =
false;
13012 bool isRValueReference =
false;
13013 bool isPointer =
false;
13017 isLValueReference =
true;
13021 isRValueReference =
true;
13037 diag::note_ovl_surrogate_constraints_not_satisfied)
13051 assert(Cand->
Conversions.size() <= 2 &&
"builtin operator is not binary");
13052 std::string TypeStr(
"operator");
13058 S.
Diag(OpLoc, diag::note_ovl_builtin_candidate) << TypeStr;
13063 S.
Diag(OpLoc, diag::note_ovl_builtin_candidate) << TypeStr;
13070 if (ICS.
isBad())
break;
13074 S, OpLoc, S.
PDiag(diag::note_ambiguous_type_conversion));
13091 llvm_unreachable(
"non-deduction failure while diagnosing bad deduction");
13121 llvm_unreachable(
"Unhandled deduction result");
13126struct CompareOverloadCandidatesForDisplay {
13128 SourceLocation Loc;
13132 CompareOverloadCandidatesForDisplay(
13133 Sema &S, SourceLocation Loc,
size_t NArgs,
13135 : S(S), NumArgs(NArgs), CSK(CSK) {}
13145 if (NumArgs >
C->Function->getNumParams() && !
C->Function->isVariadic())
13147 if (NumArgs < C->
Function->getMinRequiredArguments())
13154 bool operator()(
const OverloadCandidate *L,
13155 const OverloadCandidate *R) {
13157 if (L == R)
return false;
13161 if (!
R->Viable)
return true;
13163 if (
int Ord = CompareConversions(*L, *R))
13166 }
else if (
R->Viable)
13169 assert(L->
Viable ==
R->Viable);
13182 int RDist =
std::abs((
int)
R->getNumParams() - (
int)NumArgs);
13183 if (LDist == RDist) {
13184 if (LFailureKind == RFailureKind)
13192 return LDist < RDist;
13209 unsigned numRFixes =
R->Fix.NumConversionsFixed;
13210 numLFixes = (numLFixes == 0) ?
UINT_MAX : numLFixes;
13211 numRFixes = (numRFixes == 0) ?
UINT_MAX : numRFixes;
13212 if (numLFixes != numRFixes) {
13213 return numLFixes < numRFixes;
13217 if (
int Ord = CompareConversions(*L, *R))
13229 if (LRank != RRank)
13230 return LRank < RRank;
13256 struct ConversionSignals {
13257 unsigned KindRank = 0;
13260 static ConversionSignals ForSequence(ImplicitConversionSequence &
Seq) {
13261 ConversionSignals Sig;
13262 Sig.KindRank =
Seq.getKindRank();
13263 if (
Seq.isStandard())
13264 Sig.Rank =
Seq.Standard.getRank();
13265 else if (
Seq.isUserDefined())
13266 Sig.Rank =
Seq.UserDefined.After.getRank();
13272 static ConversionSignals ForObjectArgument() {
13282 int CompareConversions(
const OverloadCandidate &L,
13283 const OverloadCandidate &R) {
13288 for (
unsigned I = 0, N = L.
Conversions.size(); I != N; ++I) {
13290 ? ConversionSignals::ForObjectArgument()
13291 : ConversionSignals::ForSequence(L.Conversions[I]);
13292 auto RS =
R.IgnoreObjectArgument
13293 ? ConversionSignals::ForObjectArgument()
13294 : ConversionSignals::ForSequence(
R.Conversions[I]);
13295 if (std::tie(LS.KindRank, LS.Rank) != std::tie(RS.KindRank, RS.Rank))
13296 return std::tie(LS.KindRank, LS.Rank) < std::tie(RS.KindRank, RS.Rank)
13321 bool Unfixable =
false;
13327 for (
unsigned ConvIdx =
13331 assert(ConvIdx != ConvCount &&
"no bad conversion in candidate");
13332 if (Cand->
Conversions[ConvIdx].isInitialized() &&
13341 bool SuppressUserConversions =
false;
13343 unsigned ConvIdx = 0;
13344 unsigned ArgIdx = 0;
13373 assert(ConvCount <= 3);
13379 ConvIdx != ConvCount && ArgIdx < Args.size();
13381 if (Cand->
Conversions[ConvIdx].isInitialized()) {
13383 }
else if (
ParamIdx < ParamTypes.size()) {
13384 if (ParamTypes[
ParamIdx]->isDependentType())
13385 Cand->
Conversions[ConvIdx].setAsIdentityConversion(
13390 SuppressUserConversions,
13395 if (!Unfixable && Cand->
Conversions[ConvIdx].isBad())
13414 for (
iterator Cand = Candidates.begin(), LastCand = Candidates.end();
13415 Cand != LastCand; ++Cand) {
13416 if (!Filter(*Cand))
13441 Cands.push_back(Cand);
13445 Cands, CompareOverloadCandidatesForDisplay(S, OpLoc, Args.size(), Kind));
13452 bool DeferHint =
false;
13456 auto WrongSidedCands =
13458 return (Cand.
Viable ==
false &&
13464 DeferHint = !WrongSidedCands.empty();
13480 S.
Diag(PD.first, PD.second);
13485 bool NoteCands =
true;
13486 for (
const Expr *Arg : Args) {
13487 if (Arg->getType()->isWebAssemblyTableType())
13496 {Candidates.begin(), Candidates.end()});
13502 bool ReportedAmbiguousConversions =
false;
13505 unsigned CandsShown = 0;
13506 auto I = Cands.begin(), E = Cands.end();
13507 for (; I != E; ++I) {
13523 "Non-viable built-in candidates are not added to Cands.");
13530 if (!ReportedAmbiguousConversions) {
13532 ReportedAmbiguousConversions =
true;
13546 S.
Diag(OpLoc, diag::note_ovl_too_many_candidates) <<
int(E - I);
13551 const Sema &S)
const {
13557 if (Caller && Caller->
hasAttr<CUDAHostAttr>() &&
13558 Caller->
hasAttr<CUDADeviceAttr>())
13579struct CompareTemplateSpecCandidatesForDisplay {
13581 CompareTemplateSpecCandidatesForDisplay(Sema &S) : S(S) {}
13583 bool operator()(
const TemplateSpecCandidate *L,
13584 const TemplateSpecCandidate *R) {
13615 bool ForTakingAddress) {
13620void TemplateSpecCandidateSet::destroyCandidates() {
13622 i->DeductionFailure.Destroy();
13627 destroyCandidates();
13628 Candidates.clear();
13641 Cands.reserve(
size());
13642 for (
iterator Cand =
begin(), LastCand =
end(); Cand != LastCand; ++Cand) {
13643 if (Cand->Specialization)
13644 Cands.push_back(Cand);
13649 llvm::sort(Cands, CompareTemplateSpecCandidatesForDisplay(S));
13656 unsigned CandsShown = 0;
13657 for (I = Cands.begin(), E = Cands.end(); I != E; ++I) {
13663 if (CandsShown >= 4 && ShowOverloads ==
Ovl_Best)
13668 "Non-matching built-in candidates are not added to Cands.");
13673 S.
Diag(Loc, diag::note_ovl_too_many_candidates) <<
int(E - I);
13683 QualType Ret = PossiblyAFunctionType;
13686 Ret = ToTypePtr->getPointeeType();
13689 Ret = ToTypeRef->getPointeeType();
13692 Ret = MemTypePtr->getPointeeType();
13694 Context.getCanonicalType(Ret).getUnqualifiedType();
13699 bool Complain =
true) {
13716class AddressOfFunctionResolver {
13719 const QualType& TargetType;
13720 QualType TargetFunctionType;
13724 ASTContext& Context;
13726 bool TargetTypeIsNonStaticMemberFunction;
13727 bool FoundNonTemplateFunction;
13728 bool StaticMemberFunctionFromBoundPointer;
13729 bool HasComplained;
13731 OverloadExpr::FindResult OvlExprInfo;
13732 OverloadExpr *OvlExpr;
13733 TemplateArgumentListInfo OvlExplicitTemplateArgs;
13734 SmallVector<std::pair<DeclAccessPair, FunctionDecl*>, 4> Matches;
13735 TemplateSpecCandidateSet FailedCandidates;
13738 AddressOfFunctionResolver(Sema &S, Expr *SourceExpr,
13739 const QualType &TargetType,
bool Complain)
13740 : S(S), SourceExpr(SourceExpr), TargetType(TargetType),
13741 Complain(Complain), Context(S.getASTContext()),
13742 TargetTypeIsNonStaticMemberFunction(
13743 !!TargetType->getAs<MemberPointerType>()),
13744 FoundNonTemplateFunction(
false),
13745 StaticMemberFunctionFromBoundPointer(
false),
13746 HasComplained(
false),
13747 OvlExprInfo(OverloadExpr::find(SourceExpr)),
13749 FailedCandidates(OvlExpr->getNameLoc(),
true) {
13750 ExtractUnqualifiedFunctionTypeFromTargetType();
13753 if (UnresolvedMemberExpr *UME = dyn_cast<UnresolvedMemberExpr>(OvlExpr))
13754 if (!UME->isImplicitAccess() &&
13756 StaticMemberFunctionFromBoundPointer =
true;
13758 DeclAccessPair dap;
13760 OvlExpr,
false, &dap)) {
13761 if (CXXMethodDecl *
Method = dyn_cast<CXXMethodDecl>(Fn))
13762 if (!
Method->isStatic()) {
13766 TargetTypeIsNonStaticMemberFunction =
true;
13774 Matches.push_back(std::make_pair(dap, Fn));
13782 if (FindAllFunctionsThatMatchTargetTypeExactly()) {
13784 EliminateSuboptimalCudaMatches();
13788 if (Matches.size() > 1 && !eliminiateSuboptimalOverloadCandidates()) {
13789 if (FoundNonTemplateFunction) {
13790 EliminateAllTemplateMatches();
13791 EliminateLessPartialOrderingConstrainedMatches();
13793 EliminateAllExceptMostSpecializedTemplate();
13798 bool hasComplained()
const {
return HasComplained; }
13801 bool candidateHasExactlyCorrectType(
const FunctionDecl *FD) {
13808 bool isBetterCandidate(
const FunctionDecl *A,
const FunctionDecl *B) {
13812 return candidateHasExactlyCorrectType(A) &&
13813 (!candidateHasExactlyCorrectType(B) ||
13819 bool eliminiateSuboptimalOverloadCandidates() {
13822 auto Best = Matches.begin();
13823 for (
auto I = Matches.begin()+1, E = Matches.end(); I != E; ++I)
13824 if (isBetterCandidate(I->second, Best->second))
13827 const FunctionDecl *BestFn = Best->second;
13828 auto IsBestOrInferiorToBest = [
this, BestFn](
13829 const std::pair<DeclAccessPair, FunctionDecl *> &Pair) {
13830 return BestFn == Pair.second || isBetterCandidate(BestFn, Pair.second);
13835 if (!llvm::all_of(Matches, IsBestOrInferiorToBest))
13837 Matches[0] = *Best;
13842 bool isTargetTypeAFunction()
const {
13851 void inline ExtractUnqualifiedFunctionTypeFromTargetType() {
13857 const DeclAccessPair& CurAccessFunPair) {
13858 if (CXXMethodDecl *
Method
13862 bool CanConvertToFunctionPointer =
13863 Method->isStatic() ||
Method->isExplicitObjectMemberFunction();
13864 if (CanConvertToFunctionPointer == TargetTypeIsNonStaticMemberFunction)
13867 else if (TargetTypeIsNonStaticMemberFunction)
13877 TemplateDeductionInfo Info(FailedCandidates.
getLocation());
13881 Result != TemplateDeductionResult::Success) {
13899 Matches.push_back(std::make_pair(CurAccessFunPair,
Specialization));
13903 bool AddMatchingNonTemplateFunction(NamedDecl* Fn,
13904 const DeclAccessPair& CurAccessFunPair) {
13905 if (CXXMethodDecl *
Method = dyn_cast<CXXMethodDecl>(Fn)) {
13908 bool CanConvertToFunctionPointer =
13909 Method->isStatic() ||
Method->isExplicitObjectMemberFunction();
13910 if (CanConvertToFunctionPointer == TargetTypeIsNonStaticMemberFunction)
13913 else if (TargetTypeIsNonStaticMemberFunction)
13916 if (FunctionDecl *FunDecl = dyn_cast<FunctionDecl>(Fn)) {
13923 if (FunDecl->isMultiVersion()) {
13924 const auto *TA = FunDecl->getAttr<TargetAttr>();
13925 if (TA && !TA->isDefaultVersion())
13927 const auto *TVA = FunDecl->getAttr<TargetVersionAttr>();
13928 if (TVA && !TVA->isDefaultVersion())
13936 HasComplained |= Complain;
13945 candidateHasExactlyCorrectType(FunDecl)) {
13946 Matches.push_back(std::make_pair(
13948 FoundNonTemplateFunction =
true;
13956 bool FindAllFunctionsThatMatchTargetTypeExactly() {
13961 if (IsInvalidFormOfPointerToMemberFunction())
13964 for (UnresolvedSetIterator I = OvlExpr->
decls_begin(),
13968 NamedDecl *
Fn = (*I)->getUnderlyingDecl();
13977 = dyn_cast<FunctionTemplateDecl>(Fn)) {
13983 AddMatchingNonTemplateFunction(Fn, I.getPair()))
13986 assert(Ret || Matches.empty());
13990 void EliminateAllExceptMostSpecializedTemplate() {
14002 UnresolvedSet<4> MatchesCopy;
14003 for (
unsigned I = 0, E = Matches.size(); I != E; ++I)
14004 MatchesCopy.
addDecl(Matches[I].second, Matches[I].first.getAccess());
14009 MatchesCopy.
begin(), MatchesCopy.
end(), FailedCandidates,
14011 S.
PDiag(diag::err_addr_ovl_ambiguous)
14012 << Matches[0].second->getDeclName(),
14013 S.
PDiag(diag::note_ovl_candidate)
14014 << (
unsigned)oc_function << (
unsigned)ocs_described_template,
14015 Complain, TargetFunctionType);
14019 Matches[0].first = Matches[
Result - MatchesCopy.
begin()].first;
14023 HasComplained |= Complain;
14026 void EliminateAllTemplateMatches() {
14029 for (
unsigned I = 0, N = Matches.size(); I != N; ) {
14030 if (Matches[I].second->getPrimaryTemplate() ==
nullptr)
14033 Matches[I] = Matches[--N];
14039 void EliminateLessPartialOrderingConstrainedMatches() {
14044 assert(Matches[0].second->getPrimaryTemplate() ==
nullptr &&
14045 "Call EliminateAllTemplateMatches() first");
14046 SmallVector<std::pair<DeclAccessPair, FunctionDecl *>, 4> Results;
14047 Results.push_back(Matches[0]);
14048 for (
unsigned I = 1, N = Matches.size(); I < N; ++I) {
14049 assert(Matches[I].second->getPrimaryTemplate() ==
nullptr);
14051 S, Matches[I].second, Results[0].second,
14055 Results.push_back(Matches[I]);
14058 if (F == Matches[I].second) {
14060 Results.push_back(Matches[I]);
14063 std::swap(Matches, Results);
14066 void EliminateSuboptimalCudaMatches() {
14072 void ComplainNoMatchesFound()
const {
14073 assert(Matches.empty());
14075 << OvlExpr->
getName() << TargetFunctionType
14077 if (FailedCandidates.
empty())
14084 for (UnresolvedSetIterator I = OvlExpr->
decls_begin(),
14087 if (FunctionDecl *Fun =
14088 dyn_cast<FunctionDecl>((*I)->getUnderlyingDecl()))
14096 bool IsInvalidFormOfPointerToMemberFunction()
const {
14097 return TargetTypeIsNonStaticMemberFunction &&
14101 void ComplainIsInvalidFormOfPointerToMemberFunction()
const {
14109 bool IsStaticMemberFunctionFromBoundPointer()
const {
14110 return StaticMemberFunctionFromBoundPointer;
14113 void ComplainIsStaticMemberFunctionFromBoundPointer()
const {
14115 diag::err_invalid_form_pointer_member_function)
14119 void ComplainOfInvalidConversion()
const {
14121 << OvlExpr->
getName() << TargetType;
14124 void ComplainMultipleMatchesFound()
const {
14125 assert(Matches.size() > 1);
14132 bool hadMultipleCandidates()
const {
return (OvlExpr->
getNumDecls() > 1); }
14134 int getNumMatches()
const {
return Matches.size(); }
14136 FunctionDecl* getMatchingFunctionDecl()
const {
14137 if (Matches.size() != 1)
return nullptr;
14138 return Matches[0].second;
14141 const DeclAccessPair* getMatchingFunctionAccessPair()
const {
14142 if (Matches.size() != 1)
return nullptr;
14143 return &Matches[0].first;
14153 bool *pHadMultipleCandidates) {
14156 AddressOfFunctionResolver Resolver(*
this, AddressOfExpr, TargetType,
14158 int NumMatches = Resolver.getNumMatches();
14160 bool ShouldComplain = Complain && !Resolver.hasComplained();
14161 if (NumMatches == 0 && ShouldComplain) {
14162 if (Resolver.IsInvalidFormOfPointerToMemberFunction())
14163 Resolver.ComplainIsInvalidFormOfPointerToMemberFunction();
14165 Resolver.ComplainNoMatchesFound();
14167 else if (NumMatches > 1 && ShouldComplain)
14168 Resolver.ComplainMultipleMatchesFound();
14169 else if (NumMatches == 1) {
14170 Fn = Resolver.getMatchingFunctionDecl();
14174 FoundResult = *Resolver.getMatchingFunctionAccessPair();
14176 if (Resolver.IsStaticMemberFunctionFromBoundPointer())
14177 Resolver.ComplainIsStaticMemberFunctionFromBoundPointer();
14183 if (pHadMultipleCandidates)
14184 *pHadMultipleCandidates = Resolver.hadMultipleCandidates();
14192 bool IsResultAmbiguous =
false;
14200 return static_cast<int>(
CUDA().IdentifyPreference(Caller, FD1)) -
14201 static_cast<int>(
CUDA().IdentifyPreference(Caller, FD2));
14208 auto *FD = dyn_cast<FunctionDecl>(I->getUnderlyingDecl());
14216 auto FoundBetter = [&]() {
14217 IsResultAmbiguous =
false;
14229 int PreferenceByCUDA = CheckCUDAPreference(FD,
Result);
14231 if (PreferenceByCUDA != 0) {
14233 if (PreferenceByCUDA > 0)
14249 if (MoreConstrained != FD) {
14250 if (!MoreConstrained) {
14251 IsResultAmbiguous =
true;
14252 AmbiguousDecls.push_back(FD);
14261 if (IsResultAmbiguous)
14282 ExprResult &SrcExpr,
bool DoFunctionPointerConversion) {
14284 assert(E->
getType() ==
Context.OverloadTy &&
"SrcExpr must be an overload");
14288 if (!
Found ||
Found->isCPUDispatchMultiVersion() ||
14289 Found->isCPUSpecificMultiVersion())
14337 dyn_cast<FunctionTemplateDecl>((*I)->getUnderlyingDecl());
14368 if (ForTypeDeduction &&
14382 if (FoundResult) *FoundResult = I.getPair();
14393 ExprResult &SrcExpr,
bool doFunctionPointerConversion,
bool complain,
14395 unsigned DiagIDForComplaining) {
14416 if (!complain)
return false;
14419 diag::err_bound_member_function)
14432 SingleFunctionExpression =
14436 if (doFunctionPointerConversion) {
14437 SingleFunctionExpression =
14439 if (SingleFunctionExpression.
isInvalid()) {
14446 if (!SingleFunctionExpression.
isUsable()) {
14448 Diag(OpRangeForComplaining.
getBegin(), DiagIDForComplaining)
14450 << DestTypeForComplaining
14451 << OpRangeForComplaining
14462 SrcExpr = SingleFunctionExpression;
14472 bool PartialOverloading,
14479 if (ExplicitTemplateArgs) {
14480 assert(!KnownValid &&
"Explicit template arguments?");
14489 PartialOverloading);
14494 = dyn_cast<FunctionTemplateDecl>(Callee)) {
14496 ExplicitTemplateArgs, Args, CandidateSet,
14498 PartialOverloading);
14502 assert(!KnownValid &&
"unhandled case in overloaded call candidate");
14508 bool PartialOverloading) {
14531 assert(!(*I)->getDeclContext()->isRecord());
14533 !(*I)->getDeclContext()->isFunctionOrMethod());
14534 assert((*I)->getUnderlyingDecl()->isFunctionOrFunctionTemplate());
14544 ExplicitTemplateArgs = &TABuffer;
14550 CandidateSet, PartialOverloading,
14555 Args, ExplicitTemplateArgs,
14556 CandidateSet, PartialOverloading);
14564 CandidateSet,
false,
false);
14571 case OO_New:
case OO_Array_New:
14572 case OO_Delete:
case OO_Array_Delete:
14595 if (DC->isTransparentContext())
14601 R.suppressDiagnostics();
14611 if (
auto *RD = dyn_cast<CXXRecordDecl>(DC)) {
14616 if (FoundInClass) {
14617 *FoundInClass = RD;
14620 R.addDecl(Best->FoundDecl.getDecl(), Best->FoundDecl.getAccess());
14637 AssociatedNamespaces,
14638 AssociatedClasses);
14642 for (Sema::AssociatedNamespaceSet::iterator
14643 it = AssociatedNamespaces.begin(),
14644 end = AssociatedNamespaces.end(); it !=
end; ++it) {
14656 SuggestedNamespaces.insert(*it);
14660 SemaRef.
Diag(R.getNameLoc(), diag::err_not_found_by_two_phase_lookup)
14661 << R.getLookupName();
14662 if (SuggestedNamespaces.empty()) {
14663 SemaRef.
Diag(Best->Function->getLocation(),
14664 diag::note_not_found_by_two_phase_lookup)
14665 << R.getLookupName() << 0;
14666 }
else if (SuggestedNamespaces.size() == 1) {
14667 SemaRef.
Diag(Best->Function->getLocation(),
14668 diag::note_not_found_by_two_phase_lookup)
14669 << R.getLookupName() << 1 << *SuggestedNamespaces.begin();
14674 SemaRef.
Diag(Best->Function->getLocation(),
14675 diag::note_not_found_by_two_phase_lookup)
14676 << R.getLookupName() << 2;
14707class BuildRecoveryCallExprRAII {
14709 Sema::SatisfactionStackResetRAII SatStack;
14712 BuildRecoveryCallExprRAII(Sema &S) : SemaRef(S), SatStack(S) {
14734 bool EmptyLookup,
bool AllowTypoCorrection) {
14742 BuildRecoveryCallExprRAII RCE(SemaRef);
14752 ExplicitTemplateArgs = &TABuffer;
14760 ExplicitTemplateArgs, Args, &FoundInClass)) {
14762 }
else if (EmptyLookup) {
14767 ExplicitTemplateArgs !=
nullptr,
14768 dyn_cast<MemberExpr>(Fn));
14770 AllowTypoCorrection
14776 }
else if (FoundInClass && SemaRef.
getLangOpts().MSVCCompat) {
14791 assert(!R.empty() &&
"lookup results empty despite recovery");
14794 if (R.isAmbiguous()) {
14795 R.suppressDiagnostics();
14802 if ((*R.begin())->isCXXClassMember())
14804 ExplicitTemplateArgs, S);
14805 else if (ExplicitTemplateArgs || TemplateKWLoc.
isValid())
14807 ExplicitTemplateArgs);
14831 assert(!ULE->
getQualifier() &&
"qualified name with ADL");
14838 (F = dyn_cast<FunctionDecl>(*ULE->
decls_begin())) &&
14840 llvm_unreachable(
"performing ADL for builtin");
14847 UnbridgedCastsSet UnbridgedCasts;
14862 if (CandidateSet->
empty() ||
14878 if (CandidateSet->
empty())
14881 UnbridgedCasts.restore();
14888 std::optional<QualType>
Result;
14908 if (Best && *Best != CS.
end())
14909 ConsiderCandidate(**Best);
14912 for (
const auto &
C : CS)
14914 ConsiderCandidate(
C);
14917 for (
const auto &
C : CS)
14918 ConsiderCandidate(
C);
14923 if (
Value.isNull() ||
Value->isUndeducedType())
14940 bool AllowTypoCorrection) {
14941 switch (OverloadResult) {
14952 Res.
get(), FDecl, LParenLoc, Args, RParenLoc, ExecConfig,
14958 if (*Best != CandidateSet->
end() &&
14962 dyn_cast_if_present<CXXMethodDecl>((*Best)->Function);
14967 SemaRef.
PDiag(diag::err_member_call_without_object) << 0 << M),
14977 CandidateSet->
empty(),
14978 AllowTypoCorrection);
14985 for (
const Expr *Arg : Args) {
14986 if (!Arg->getType()->isFunctionType())
14988 if (
auto *DRE = dyn_cast<DeclRefExpr>(Arg->IgnoreParenImpCasts())) {
14989 auto *FD = dyn_cast<FunctionDecl>(DRE->getDecl());
14992 Arg->getExprLoc()))
15000 SemaRef.
PDiag(diag::err_ovl_no_viable_function_in_call)
15001 << ULE->
getName() << Fn->getSourceRange()),
15009 SemaRef.
PDiag(diag::err_ovl_ambiguous_call)
15010 << ULE->
getName() << Fn->getSourceRange()),
15017 Fn->getSourceRange(), ULE->
getName(),
15018 *CandidateSet, FDecl, Args);
15027 Res.
get(), FDecl, LParenLoc, Args, RParenLoc, ExecConfig,
15035 SubExprs.append(Args.begin(), Args.end());
15042 for (
auto I = CS.
begin(), E = CS.
end(); I != E; ++I) {
15057 bool AllowTypoCorrection,
15058 bool CalleesAddressIsTaken) {
15073 if (CalleesAddressIsTaken)
15084 Best != CandidateSet.
end()) {
15085 if (
auto *M = dyn_cast_or_null<CXXMethodDecl>(Best->Function);
15086 M && M->isImplicitObjectMemberFunction()) {
15097 CUDA().recordPotentialODRUsedVariable(Args, CandidateSet);
15115 if (
const auto *TP =
15125 ExecConfig, &CandidateSet, &Best,
15126 OverloadResult, AllowTypoCorrection);
15135 Context, NamingClass, NNSLoc, DNI, PerformADL, Fns.
begin(), Fns.
end(),
15141 bool HadMultipleCandidates) {
15151 if (
Method->isExplicitObjectMemberFunction())
15155 E, std::nullopt, FoundDecl,
Method);
15159 if (
Method->getParent()->isLambda() &&
15160 Method->getConversionType()->isBlockPointerType()) {
15164 auto *CE = dyn_cast<CastExpr>(SubE);
15165 if (CE && CE->getCastKind() == CK_NoOp)
15166 SubE = CE->getSubExpr();
15168 if (
auto *BE = dyn_cast<CXXBindTemporaryExpr>(SubE))
15169 SubE = BE->getSubExpr();
15192 if (
Method->isExplicitObjectMemberFunction()) {
15198 Expr *ObjectParam = Exp.
get();
15212 Exp.
get()->getEndLoc(),
15226 Expr *Input,
bool PerformADL) {
15228 assert(Op !=
OO_None &&
"Invalid opcode for overloaded unary operator");
15236 Expr *Args[2] = { Input,
nullptr };
15237 unsigned NumArgs = 1;
15242 if (Opc == UO_PostInc || Opc == UO_PostDec) {
15256 if (Opc == UO_PreDec || Opc == UO_PreInc || Opc == UO_Deref)
15267 if (Fn.isInvalid())
15293 bool HadMultipleCandidates = (CandidateSet.
size() > 1);
15312 if (
Method->isExplicitObjectMemberFunction())
15316 Input, std::nullopt, Best->FoundDecl,
Method);
15319 Base = Input = InputInit.
get();
15330 Input = InputInit.
get();
15335 Base, HadMultipleCandidates,
15347 Context, Op, FnExpr.
get(), ArgsArray, ResultTy,
VK, OpLoc,
15363 Input, Best->BuiltinParamTypes[0], Best->Conversions[0],
15368 Input = InputRes.
get();
15388 PDiag(diag::err_ovl_ambiguous_oper_unary)
15405 << (Msg !=
nullptr)
15406 << (Msg ? Msg->
getString() : StringRef())
15459 if (Op != OO_Equal && PerformADL) {
15466 Context.DeclarationNames.getCXXOperatorName(ExtraOp);
15492 Expr *RHS,
bool PerformADL,
15493 bool AllowRewrittenCandidates,
15495 Expr *Args[2] = { LHS, RHS };
15499 AllowRewrittenCandidates =
false;
15505 if (Args[0]->isTypeDependent() || Args[1]->isTypeDependent()) {
15526 if (Fn.isInvalid())
15535 if (Opc == BO_PtrMemD) {
15536 auto CheckPlaceholder = [&](
Expr *&Arg) {
15545 if (CheckPlaceholder(Args[0]) || CheckPlaceholder(Args[1]))
15569 if (Opc == BO_Assign &&
15578 Op, OpLoc, AllowRewrittenCandidates));
15580 CandidateSet.
exclude(DefaultedFn);
15583 bool HadMultipleCandidates = (CandidateSet.
size() > 1);
15592 bool IsReversed = Best->isReversed();
15594 std::swap(Args[0], Args[1]);
15611 if (Best->RewriteKind && ChosenOp == OO_EqualEqual &&
15615 Diag(OpLoc, IsExtension ? diag::ext_ovl_rewrite_equalequal_not_bool
15616 : diag::err_ovl_rewrite_equalequal_not_bool)
15624 if (AllowRewrittenCandidates && !IsReversed &&
15634 for (
unsigned ArgIdx = 0; ArgIdx < 2; ++ArgIdx) {
15637 Best->Conversions[ArgIdx]) ==
15639 AmbiguousWith.push_back(Cand.
Function);
15646 if (!AmbiguousWith.empty()) {
15647 bool AmbiguousWithSelf =
15648 AmbiguousWith.size() == 1 &&
15650 Diag(OpLoc, diag::ext_ovl_ambiguous_oper_binary_reversed)
15652 << Args[0]->
getType() << Args[1]->
getType() << AmbiguousWithSelf
15654 if (AmbiguousWithSelf) {
15656 diag::note_ovl_ambiguous_oper_binary_reversed_self);
15661 if (
auto *MD = dyn_cast<CXXMethodDecl>(FnDecl))
15662 if (Op == OverloadedOperatorKind::OO_EqualEqual &&
15664 !MD->hasCXXExplicitFunctionObjectParameter() &&
15665 Context.hasSameUnqualifiedType(
15666 MD->getFunctionObjectParameterType(),
15667 MD->getParamDecl(0)->getType().getNonReferenceType()) &&
15668 Context.hasSameUnqualifiedType(
15669 MD->getFunctionObjectParameterType(),
15671 Context.hasSameUnqualifiedType(
15672 MD->getFunctionObjectParameterType(),
15675 diag::note_ovl_ambiguous_eqeq_reversed_self_non_const);
15678 diag::note_ovl_ambiguous_oper_binary_selected_candidate);
15679 for (
auto *F : AmbiguousWith)
15681 diag::note_ovl_ambiguous_oper_binary_reversed_candidate);
15689 if (Op == OO_Equal)
15700 if (
Method->isExplicitObjectMemberFunction()) {
15705 Args[0], std::nullopt, Best->FoundDecl,
Method);
15738 Best->FoundDecl,
Base,
15739 HadMultipleCandidates, OpLoc);
15750 const Expr *ImplicitThis =
nullptr;
15755 Context, ChosenOp, FnExpr.
get(), Args, ResultTy,
VK, OpLoc,
15760 if (
const auto *
Method = dyn_cast<CXXMethodDecl>(FnDecl);
15763 ImplicitThis = ArgsArray[0];
15764 ArgsArray = ArgsArray.slice(1);
15771 if (Op == OO_Equal) {
15776 *
this,
AssignedEntity{Args[0], dyn_cast<CXXMethodDecl>(FnDecl)},
15779 if (ImplicitThis) {
15784 CheckArgAlignment(OpLoc, FnDecl,
"'this'", ThisType,
15788 checkCall(FnDecl,
nullptr, ImplicitThis, ArgsArray,
15803 (Op == OO_Spaceship && IsReversed)) {
15804 if (Op == OO_ExclaimEqual) {
15805 assert(ChosenOp == OO_EqualEqual &&
"unexpected operator name");
15808 assert(ChosenOp == OO_Spaceship &&
"unexpected operator name");
15810 Expr *ZeroLiteral =
15819 OpLoc, Opc, Fns, IsReversed ? ZeroLiteral : R.get(),
15820 IsReversed ? R.get() : ZeroLiteral,
true,
15828 assert(ChosenOp == Op &&
"unexpected operator name");
15832 if (Best->RewriteKind !=
CRK_None)
15841 Args[0], Best->BuiltinParamTypes[0], Best->Conversions[0],
15846 Args[0] = ArgsRes0.
get();
15849 Args[1], Best->BuiltinParamTypes[1], Best->Conversions[1],
15854 Args[1] = ArgsRes1.
get();
15864 if (Opc == BO_Comma)
15869 if (DefaultedFn && Opc == BO_Cmp) {
15871 Args[1], DefaultedFn);
15886 Opc >= BO_Assign && Opc <= BO_OrAssign) {
15887 Diag(OpLoc, diag::err_ovl_no_viable_oper)
15890 if (Args[0]->
getType()->isIncompleteType()) {
15891 Diag(OpLoc, diag::note_assign_lhs_incomplete)
15907 assert(
Result.isInvalid() &&
15908 "C++ binary operator overloading is missing candidates!");
15919 << Args[0]->getSourceRange()
15920 << Args[1]->getSourceRange()),
15930 Diag(OpLoc, diag::err_ovl_deleted_special_oper)
15934 Diag(OpLoc, diag::err_ovl_deleted_comparison)
15935 << Args[0]->
getType() << DeletedFD;
15948 PDiag(diag::err_ovl_deleted_oper)
15950 .getCXXOverloadedOperator())
15951 << (Msg !=
nullptr) << (Msg ? Msg->
getString() : StringRef())
15952 << Args[0]->getSourceRange() << Args[1]->getSourceRange()),
15976 "cannot use prvalue expressions more than once");
15977 Expr *OrigLHS = LHS;
15978 Expr *OrigRHS = RHS;
15995 true, DefaultedFn);
15996 if (
Less.isInvalid())
16023 for (; I >= 0; --I) {
16025 auto *VI = Info->lookupValueInfo(Comparisons[I].
Result);
16048 Context, OrigLHS, OrigRHS, BO_Cmp,
Result.get()->getType(),
16049 Result.get()->getValueKind(),
Result.get()->getObjectKind(), OpLoc,
16051 Expr *SemanticForm[] = {LHS, RHS,
Result.get()};
16061 unsigned NumArgsSlots =
16062 MethodArgs.size() + std::max<unsigned>(Args.size(), NumParams);
16065 MethodArgs.reserve(MethodArgs.size() + NumArgsSlots);
16066 bool IsError =
false;
16069 for (
unsigned i = 0; i != NumParams; i++) {
16071 if (i < Args.size()) {
16075 S.
Context, Method->getParamDecl(i)),
16089 MethodArgs.push_back(Arg);
16099 Args.push_back(
Base);
16100 for (
auto *e : ArgExpr) {
16104 Context.DeclarationNames.getCXXOperatorName(OO_Subscript);
16109 ArgExpr.back()->getEndLoc());
16121 if (Fn.isInvalid())
16131 UnbridgedCastsSet UnbridgedCasts;
16144 if (Args.size() == 2)
16147 bool HadMultipleCandidates = (CandidateSet.
size() > 1);
16167 if (
Method->isExplicitObjectMemberFunction()) {
16172 Args[0] = Res.
get();
16176 Args[0], std::nullopt, Best->FoundDecl,
Method);
16180 MethodArgs.push_back(Arg0.
get());
16184 *
this, MethodArgs,
Method, ArgExpr, LLoc);
16192 *
this, FnDecl, Best->FoundDecl,
Base, HadMultipleCandidates,
16203 Context, OO_Subscript, FnExpr.
get(), MethodArgs, ResultTy,
VK, RLoc,
16220 Args[0], Best->BuiltinParamTypes[0], Best->Conversions[0],
16225 Args[0] = ArgsRes0.
get();
16228 Args[1], Best->BuiltinParamTypes[1], Best->Conversions[1],
16233 Args[1] = ArgsRes1.
get();
16241 CandidateSet.
empty()
16242 ? (
PDiag(diag::err_ovl_no_oper)
16243 << Args[0]->getType() << 0
16244 << Args[0]->getSourceRange() << Range)
16245 : (
PDiag(diag::err_ovl_no_viable_subscript)
16246 << Args[0]->getType() << Args[0]->getSourceRange() << Range);
16253 if (Args.size() == 2) {
16256 LLoc,
PDiag(diag::err_ovl_ambiguous_oper_binary)
16258 << Args[0]->getSourceRange() << Range),
16263 PDiag(diag::err_ovl_ambiguous_subscript_call)
16265 << Args[0]->getSourceRange() << Range),
16274 PDiag(diag::err_ovl_deleted_oper)
16275 <<
"[]" << (Msg !=
nullptr)
16276 << (Msg ? Msg->
getString() : StringRef())
16277 << Args[0]->getSourceRange() << Range),
16291 Expr *ExecConfig,
bool IsExecConfig,
16292 bool AllowRecovery) {
16301 if (
BinaryOperator *op = dyn_cast<BinaryOperator>(NakedMemExpr)) {
16302 assert(op->getType() ==
Context.BoundMemberTy);
16303 assert(op->getOpcode() == BO_PtrMemD || op->getOpcode() == BO_PtrMemI);
16316 QualType objectType = op->getLHS()->getType();
16317 if (op->getOpcode() == BO_PtrMemI)
16321 Qualifiers difference = objectQuals - funcQuals;
16325 std::string qualsString = difference.
getAsString();
16326 Diag(LParenLoc, diag::err_pointer_to_member_call_drops_quals)
16329 << (qualsString.find(
' ') == std::string::npos ? 1 : 2);
16333 Context, MemExprE, Args, resultType, valueKind, RParenLoc,
16343 if (CheckOtherCall(call, proto))
16353 if (!AllowRecovery)
16355 std::vector<Expr *> SubExprs = {MemExprE};
16356 llvm::append_range(SubExprs, Args);
16364 UnbridgedCastsSet UnbridgedCasts;
16370 bool HadMultipleCandidates =
false;
16378 UnbridgedCasts.restore();
16396 TemplateArgs = &TemplateArgsBuffer;
16400 E = UnresExpr->
decls_end(); I != E; ++I) {
16402 QualType ExplicitObjectType = ObjectType;
16409 bool HasExplicitParameter =
false;
16410 if (
const auto *M = dyn_cast<FunctionDecl>(
Func);
16411 M && M->hasCXXExplicitFunctionObjectParameter())
16412 HasExplicitParameter =
true;
16413 else if (
const auto *M = dyn_cast<FunctionTemplateDecl>(
Func);
16415 M->getTemplatedDecl()->hasCXXExplicitFunctionObjectParameter())
16416 HasExplicitParameter =
true;
16418 if (HasExplicitParameter)
16426 }
else if ((
Method = dyn_cast<CXXMethodDecl>(
Func))) {
16433 ObjectClassification, Args, CandidateSet,
16437 I.getPair(), ActingDC, TemplateArgs,
16438 ExplicitObjectType, ObjectClassification,
16439 Args, CandidateSet,
16444 HadMultipleCandidates = (CandidateSet.
size() > 1);
16448 UnbridgedCasts.restore();
16451 bool Succeeded =
false;
16456 FoundDecl = Best->FoundDecl;
16476 PDiag(diag::err_ovl_no_viable_member_function_in_call)
16483 PDiag(diag::err_ovl_ambiguous_member_call)
16490 CandidateSet, Best->Function, Args,
true);
16501 MemExprE = Res.
get();
16505 if (
Method->isStatic()) {
16507 ExecConfig, IsExecConfig);
16517 assert(
Method &&
"Member call to something that isn't a method?");
16522 if (
Method->isExplicitObjectMemberFunction()) {
16530 HadMultipleCandidates, MemExpr->
getExprLoc());
16537 TheCall->setUsesMemberSyntax(
true);
16547 Proto->getNumParams());
16553 return BuildRecoveryExpr(ResultType);
16558 return BuildRecoveryExpr(ResultType);
16568 if (
auto *MemE = dyn_cast<MemberExpr>(NakedMemExpr)) {
16569 if (
const EnableIfAttr *
Attr =
16571 Diag(MemE->getMemberLoc(),
16572 diag::err_ovl_no_viable_member_function_in_call)
16575 diag::note_ovl_candidate_disabled_by_function_cond_attr)
16576 <<
Attr->getCond()->getSourceRange() <<
Attr->getMessage();
16582 TheCall->getDirectCallee()->isPureVirtual()) {
16588 diag::warn_call_to_pure_virtual_member_function_from_ctor_dtor)
16599 if (
auto *DD = dyn_cast<CXXDestructorDecl>(TheCall->getDirectCallee())) {
16603 CallCanBeVirtual,
true,
16608 TheCall->getDirectCallee());
16620 UnbridgedCastsSet UnbridgedCasts;
16624 assert(
Object.get()->getType()->isRecordType() &&
16625 "Requires object type argument");
16639 diag::err_incomplete_object_call,
Object.get()))
16642 auto *
Record =
Object.get()->getType()->castAsCXXRecordDecl();
16645 R.suppressAccessDiagnostics();
16648 Oper != OperEnd; ++Oper) {
16662 bool IgnoreSurrogateFunctions =
false;
16665 if (!Candidate.
Viable &&
16667 IgnoreSurrogateFunctions =
true;
16689 !IgnoreSurrogateFunctions && I != E; ++I) {
16711 Object.get(), Args, CandidateSet);
16716 bool HadMultipleCandidates = (CandidateSet.
size() > 1);
16729 CandidateSet.
empty()
16730 ? (
PDiag(diag::err_ovl_no_oper)
16731 <<
Object.get()->getType() << 1
16732 <<
Object.get()->getSourceRange())
16733 : (
PDiag(diag::err_ovl_no_viable_object_call)
16734 <<
Object.get()->getType() <<
Object.get()->getSourceRange());
16741 if (!R.isAmbiguous())
16744 PDiag(diag::err_ovl_ambiguous_object_call)
16745 <<
Object.get()->getType()
16746 <<
Object.get()->getSourceRange()),
16757 PDiag(diag::err_ovl_deleted_object_call)
16758 <<
Object.get()->getType() << (Msg !=
nullptr)
16759 << (Msg ? Msg->
getString() : StringRef())
16760 <<
Object.get()->getSourceRange()),
16766 if (Best == CandidateSet.
end())
16769 UnbridgedCasts.restore();
16771 if (Best->Function ==
nullptr) {
16776 Best->Conversions[0].UserDefined.ConversionFunction);
16782 assert(Conv == Best->FoundDecl.getDecl() &&
16783 "Found Decl & conversion-to-functionptr should be same, right?!");
16791 Conv, HadMultipleCandidates);
16792 if (
Call.isInvalid())
16796 Context,
Call.get()->getType(), CK_UserDefinedConversion,
Call.get(),
16810 if (
Method->isInvalidDecl())
16817 Context.DeclarationNames.getCXXOperatorName(OO_Call), LParenLoc);
16820 Obj, HadMultipleCandidates,
16827 MethodArgs.reserve(NumParams + 1);
16829 bool IsError =
false;
16833 if (
Method->isExplicitObjectMemberFunction()) {
16842 MethodArgs.push_back(
Object.get());
16846 *
this, MethodArgs,
Method, Args, LParenLoc);
16849 if (Proto->isVariadic()) {
16851 for (
unsigned i = NumParams, e = Args.size(); i < e; i++) {
16855 MethodArgs.push_back(Arg.
get());
16870 Context, OO_Call, NewFn.
get(), MethodArgs, ResultTy,
VK, RParenLoc,
16884 bool *NoArrowOperatorFound) {
16885 assert(
Base->getType()->isRecordType() &&
16886 "left-hand side must have class type");
16900 Context.DeclarationNames.getCXXOperatorName(OO_Arrow);
16904 diag::err_typecheck_incomplete_tag,
Base))
16909 R.suppressAccessDiagnostics();
16912 Oper != OperEnd; ++Oper) {
16918 bool HadMultipleCandidates = (CandidateSet.
size() > 1);
16929 if (CandidateSet.
empty()) {
16931 if (NoArrowOperatorFound) {
16934 *NoArrowOperatorFound =
true;
16937 Diag(OpLoc, diag::err_typecheck_member_reference_arrow)
16938 << BaseType <<
Base->getSourceRange();
16939 if (BaseType->isRecordType() && !BaseType->isPointerType()) {
16940 Diag(OpLoc, diag::note_typecheck_member_reference_suggestion)
16944 Diag(OpLoc, diag::err_ovl_no_viable_oper)
16945 <<
"operator->" <<
Base->getSourceRange();
16950 if (!R.isAmbiguous())
16953 <<
"->" <<
Base->getType()
16954 <<
Base->getSourceRange()),
16962 <<
"->" << (Msg !=
nullptr)
16963 << (Msg ? Msg->
getString() : StringRef())
16964 <<
Base->getSourceRange()),
16975 if (
Method->isExplicitObjectMemberFunction()) {
16982 Base, std::nullopt, Best->FoundDecl,
Method);
16990 Base, HadMultipleCandidates, OpLoc);
17024 bool HadMultipleCandidates = (CandidateSet.
size() > 1);
17037 PDiag(diag::err_ovl_no_viable_function_in_call)
17038 << R.getLookupName()),
17045 << R.getLookupName()),
17052 nullptr, HadMultipleCandidates,
17055 if (Fn.isInvalid())
17061 for (
unsigned ArgIdx = 0, N = Args.size(); ArgIdx != N; ++ArgIdx) {
17067 ConvArgs[ArgIdx] = InputInit.
get();
17094 Scope *S =
nullptr;
17097 if (!MemberLookup.
empty()) {
17124 if (CandidateSet->
empty() || CandidateSetError) {
17137 Loc,
nullptr, CandidateSet, &Best,
17150 if (
ParenExpr *PE = dyn_cast<ParenExpr>(E)) {
17155 if (SubExpr.
get() == PE->getSubExpr())
17159 ParenExpr(PE->getLParen(), PE->getRParen(), SubExpr.
get());
17167 assert(
Context.hasSameType(ICE->getSubExpr()->getType(),
17169 "Implicit cast type cannot be determined from overload");
17170 assert(ICE->path_empty() &&
"fixing up hierarchy conversion?");
17171 if (SubExpr.
get() == ICE->getSubExpr())
17179 if (
auto *GSE = dyn_cast<GenericSelectionExpr>(E)) {
17180 if (!GSE->isResultDependent()) {
17185 if (SubExpr.
get() == GSE->getResultExpr())
17192 unsigned ResultIdx = GSE->getResultIndex();
17193 AssocExprs[ResultIdx] = SubExpr.
get();
17195 if (GSE->isExprPredicate())
17197 Context, GSE->getGenericLoc(), GSE->getControllingExpr(),
17198 GSE->getAssocTypeSourceInfos(), AssocExprs, GSE->getDefaultLoc(),
17199 GSE->getRParenLoc(), GSE->containsUnexpandedParameterPack(),
17202 Context, GSE->getGenericLoc(), GSE->getControllingType(),
17203 GSE->getAssocTypeSourceInfos(), AssocExprs, GSE->getDefaultLoc(),
17204 GSE->getRParenLoc(), GSE->containsUnexpandedParameterPack(),
17213 assert(UnOp->getOpcode() == UO_AddrOf &&
17214 "Can only take the address of an overloaded function");
17216 if (!
Method->isImplicitObjectMemberFunction()) {
17227 if (SubExpr.
get() == UnOp->getSubExpr())
17235 "fixed to something other than a decl ref");
17238 assert(Qualifier &&
17239 "fixed to a member ref with no nested name qualifier");
17245 Fn->getType(), Qualifier,
17248 if (
Context.getTargetInfo().getCXXABI().isMicrosoft())
17253 UnOp->getOperatorLoc(),
false,
17261 if (SubExpr.
get() == UnOp->getSubExpr())
17274 if (ULE->hasExplicitTemplateArgs()) {
17275 ULE->copyTemplateArgumentsInto(TemplateArgsBuffer);
17276 TemplateArgs = &TemplateArgsBuffer;
17281 getLangOpts().CPlusPlus && !Fn->hasCXXExplicitFunctionObjectParameter()
17286 if (
unsigned BID = Fn->getBuiltinID()) {
17287 if (!
Context.BuiltinInfo.isDirectlyAddressable(BID)) {
17294 Fn,
Type, ValueKind, ULE->getNameInfo(), ULE->getQualifierLoc(),
17295 Found.getDecl(), ULE->getTemplateKeywordLoc(), TemplateArgs);
17303 if (MemExpr->hasExplicitTemplateArgs()) {
17304 MemExpr->copyTemplateArgumentsInto(TemplateArgsBuffer);
17305 TemplateArgs = &TemplateArgsBuffer;
17312 if (MemExpr->isImplicitAccess()) {
17315 Fn, Fn->getType(),
VK_LValue, MemExpr->getNameInfo(),
17316 MemExpr->getQualifierLoc(),
Found.getDecl(),
17317 MemExpr->getTemplateKeywordLoc(), TemplateArgs);
17322 if (MemExpr->getQualifier())
17323 Loc = MemExpr->getQualifierLoc().getBeginLoc();
17328 Base = MemExpr->getBase();
17334 type = Fn->getType();
17341 Base, MemExpr->isArrow(), MemExpr->getOperatorLoc(),
17342 MemExpr->getQualifierLoc(), MemExpr->getTemplateKeywordLoc(), Fn,
Found,
17343 true, MemExpr->getMemberNameInfo(),
17347 llvm_unreachable(
"Invalid reference to overloaded function");
17358 if (!PartialOverloading || !
Function)
17362 if (
const auto *Proto =
17363 dyn_cast<FunctionProtoType>(
Function->getFunctionType()))
17364 if (Proto->isTemplateVariadic())
17366 if (
auto *Pattern =
Function->getTemplateInstantiationPattern())
17367 if (
const auto *Proto =
17368 dyn_cast<FunctionProtoType>(Pattern->getFunctionType()))
17369 if (Proto->isTemplateVariadic())
17382 << IsMember << Name << (Msg !=
nullptr)
17383 << (Msg ? Msg->
getString() : StringRef())
Defines the clang::ASTContext interface.
Defines the Diagnostic-related interfaces.
static bool isBooleanType(QualType Ty)
Defines the C++ Decl subclasses, other than those for templates (found in DeclTemplate....
Defines the clang::Expr interface and subclasses for C++ expressions.
Result
Implement __builtin_bit_cast and related operations.
static const GlobalDecl isTemplate(GlobalDecl GD, const TemplateArgumentList *&TemplateArgs)
static DiagnosticBuilder Diag(DiagnosticsEngine *Diags, const LangOptions &Features, FullSourceLoc TokLoc, const char *TokBegin, const char *TokRangeBegin, const char *TokRangeEnd, unsigned DiagID)
Produce a diagnostic highlighting some portion of a literal.
llvm::MachO::Record Record
Defines an enumeration for C++ overloaded operators.
Implements a partial diagnostic that can be emitted anwyhere in a DiagnosticBuilder stream.
This file declares semantic analysis functions specific to AMDGPU.
This file declares semantic analysis functions specific to ARM.
static 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
CanQualType getLogicalOperationType() const
The result type of logical operations, '<', '>', '!=', etc.
bool areLaxCompatibleRVVTypes(QualType FirstType, QualType SecondType)
Return true if the given vector types are lax-compatible RISC-V vector types as defined by -flax-vect...
CallingConv getDefaultCallingConvention(bool IsVariadic, bool IsCXXMethod) const
Retrieves the default calling convention for the current context.
void forEachMultiversionedFunctionVersion(const FunctionDecl *FD, llvm::function_ref< void(FunctionDecl *)> Pred) const
Visits all versions of a multiversioned function with the passed predicate.
QualType getPointerDiffType() const
Return the unique type for "ptrdiff_t" (C99 7.17) defined in <stddef.h>.
int getFloatingTypeOrder(QualType LHS, QualType RHS) const
Compare the rank of the two specified floating point types, ignoring the domain of the type (i....
const TargetInfo * getAuxTargetInfo() const
CanQualType UnsignedLongTy
QualType getRestrictType(QualType T) const
Return the uniqued reference to the type for a restrict qualified type.
bool areCompatibleOverflowBehaviorTypes(QualType LHS, QualType RHS)
Return true if two OverflowBehaviorTypes are compatible for assignment.
QualType getQualifiedType(SplitQualType split) const
Un-split a SplitQualType.
QualType getObjCObjectPointerType(QualType OIT) const
Return a ObjCObjectPointerType type for the given ObjCObjectType.
QualType getObjCIdType() const
Represents the Objective-CC id type.
const ArrayType * getAsArrayType(QualType T) const
Type Query functions.
bool isSameTemplateParameterList(const TemplateParameterList *X, const TemplateParameterList *Y) const
Determine whether two template parameter lists are similar enough that they may be used in declaratio...
uint64_t getTypeSize(QualType T) const
Return the size of the specified (complete) type T, in bits.
CanQualType UnsignedInt128Ty
CanQualType UnsignedCharTy
CanQualType UnsignedIntTy
QualType getVolatileType(QualType T) const
Return the uniqued reference to the type for a volatile qualified type.
CanQualType UnsignedLongLongTy
QualType getArrayDecayedType(QualType T) const
Return the properly qualified result of decaying the specified array type to a pointer.
CanQualType UnsignedShortTy
QualType getMemberPointerType(QualType T, NestedNameSpecifier Qualifier, const CXXRecordDecl *Cls) const
Return the uniqued reference to the type for a member pointer to the specified type in the specified ...
static bool hasSameType(QualType T1, QualType T2)
Determine whether the given types T1 and T2 are equivalent.
QualType getSizeType() const
Return the unique type for "size_t" (C99 7.17), defined in <stddef.h>.
QualType getCVRQualifiedType(QualType T, unsigned CVR) const
Return a type with additional const, volatile, or restrict qualifiers.
bool areCompatibleVectorTypes(QualType FirstVec, QualType SecondVec)
Return true if the given vector types are of the same unqualified type or if they are equivalent to t...
const TargetInfo & getTargetInfo() const
bool typesAreCompatible(QualType T1, QualType T2, bool CompareUnqualified=false)
Compatibility predicates used to check assignment expressions.
QualType getAddrSpaceQualType(QualType T, LangAS AddressSpace) const
Return the uniqued reference to the type for an address space qualified type with the specified type ...
CanQualType getCanonicalTagType(const TagDecl *TD) const
static bool hasSameUnqualifiedType(QualType T1, QualType T2)
Determine whether the given types are equivalent after cvr-qualifiers have been removed.
QualType getUnqualifiedArrayType(QualType T, Qualifiers &Quals) const
Return this type as a completely-unqualified array type, capturing the qualifiers in Quals.
Represents a constant array type that does not decay to a pointer when used as a function parameter.
QualType getConstantArrayType(const ASTContext &Ctx) const
Represents an array type, per C99 6.7.5.2 - Array Declarators.
QualType getElementType() const
QualType getValueType() const
Gets the type contained by this atomic type, i.e.
Attr - This represents one attribute.
A builtin binary operation expression such as "x + y" or "x <= y".
static OverloadedOperatorKind getOverloadedOperator(Opcode Opc)
Retrieve the overloaded operator kind that corresponds to the given binary opcode.
StringRef getOpcodeStr() const
static StringRef getOpcodeStr(Opcode Op)
getOpcodeStr - Turn an Opcode enum value into the punctuation char it corresponds to,...
static BinaryOperator * Create(const ASTContext &C, Expr *lhs, Expr *rhs, Opcode opc, QualType ResTy, ExprValueKind VK, ExprObjectKind OK, SourceLocation opLoc, FPOptionsOverride FPFeatures)
static bool isCompoundAssignmentOp(Opcode Opc)
This class is used for builtin types like 'int'.
BasePaths - Represents the set of paths from a derived class to one of its (direct or indirect) bases...
const RecordType * getDetectedVirtual() const
The virtual base discovered on the path (if we are merely detecting virtuals).
bool isAmbiguous(CanQualType BaseType) const
Determine whether the path from the most-derived type to the given base type is ambiguous (i....
Represents a C++ constructor within a class.
bool isCopyOrMoveConstructor(unsigned &TypeQuals) const
Determine whether this is a copy or move constructor.
bool isConvertingConstructor(bool AllowExplicit) const
Whether this constructor is a converting constructor (C++ [class.conv.ctor]), which can be used for u...
Represents a C++ conversion function within a class.
bool isExplicit() const
Return true if the declaration is already resolved to be explicit.
QualType getConversionType() const
Returns the type that this conversion function is converting to.
Represents a call to a member function that may be written either with member call syntax (e....
static CXXMemberCallExpr * Create(const ASTContext &Ctx, Expr *Fn, ArrayRef< Expr * > Args, QualType Ty, ExprValueKind VK, SourceLocation RP, FPOptionsOverride FPFeatures, unsigned MinNumArgs=0)
Represents a static or instance method of a struct/union/class.
bool isExplicitObjectMemberFunction() const
[C++2b][dcl.fct]/p7 An explicit object member function is a non-static member function with an explic...
bool isImplicitObjectMemberFunction() const
[C++2b][dcl.fct]/p7 An implicit object member function is a non-static member function without an exp...
QualType getFunctionObjectParameterReferenceType() const
Return the type of the object pointed by this.
const CXXRecordDecl * getParent() const
Return the parent of this method declaration, which is the class in which this method is defined.
static CXXOperatorCallExpr * Create(const ASTContext &Ctx, OverloadedOperatorKind OpKind, Expr *Fn, ArrayRef< Expr * > Args, QualType Ty, ExprValueKind VK, SourceLocation OperatorLoc, FPOptionsOverride FPFeatures, ADLCallKind UsesADL=NotADL, bool IsReversed=false)
Represents a C++ struct/union/class.
bool isLambda() const
Determine whether this class describes a lambda function object.
llvm::iterator_range< conversion_iterator > getVisibleConversionFunctions() const
Get all conversion functions visible in current class, including conversion function templates.
bool isHLSLBuiltinRecord() const
Returns true if the class is a built-in HLSL record.
bool hasDefinition() const
CXXMethodDecl * getLambdaCallOperator() const
Retrieve the lambda call operator of the closure type if this is a closure type.
A rewritten comparison expression that was originally written using operator syntax.
Represents a C++ nested-name-specifier or a global scope specifier.
bool isEmpty() const
No scope specifier.
void Adopt(NestedNameSpecifierLoc Other)
Adopt an existing nested-name-specifier (with source-range information).
CallExpr - Represents a function call (C99 6.5.2.2, C++ [expr.call]).
static CallExpr * Create(const ASTContext &Ctx, Expr *Fn, ArrayRef< Expr * > Args, QualType Ty, ExprValueKind VK, SourceLocation RParenLoc, FPOptionsOverride FPFeatures, unsigned MinNumArgs=0, ADLCallKind UsesADL=NotADL)
Create a call expression.
FunctionDecl * getDirectCallee()
If the callee is a FunctionDecl, return it. Otherwise return null.
void setUsesMemberSyntax(bool V=true)
void markDependentForPostponedNameLookup()
Used by Sema to implement MSVC-compatible delayed name lookup.
Represents a canonical, potentially-qualified type.
bool isAtLeastAsQualifiedAs(CanQual< T > Other, const ASTContext &Ctx) const
Determines whether this canonical type is at least as qualified as the Other canonical type.
static CanQual< Type > CreateUnsafe(QualType Other)
CanProxy< U > castAs() const
CanQual< T > getUnqualifiedType() const
Retrieve the unqualified form of this type.
Qualifiers getQualifiers() const
Retrieve all qualifiers.
CanProxy< U > getAs() const
Retrieve a canonical type pointer with a different static type, upcasting or downcasting as needed.
bool isVolatileQualified() const
const T * getTypePtr() const
Retrieve the underlying type pointer, which refers to a canonical type.
bool isPartial() const
True iff the comparison is not totally ordered.
bool isStrong() const
True iff the comparison is "strong".
Complex values, per C99 6.2.5p11.
QualType getElementType() const
static CompoundAssignOperator * Create(const ASTContext &C, Expr *lhs, Expr *rhs, Opcode opc, QualType ResTy, ExprValueKind VK, ExprObjectKind OK, SourceLocation opLoc, FPOptionsOverride FPFeatures, QualType CompLHSType=QualType(), QualType CompResultType=QualType())
Represents the canonical version of C arrays with a specified constant size.
static ConstantExpr * Create(const ASTContext &Context, Expr *E, const APValue &Result)
Represents a concrete matrix type with constant number of rows and columns.
unsigned getNumColumns() const
Returns the number of columns in the matrix.
unsigned getNumRows() const
Returns the number of rows in the matrix.
The result of a constraint satisfaction check, containing the necessary information to diagnose an un...
Base class for callback objects used by Sema::CorrectTypo to check the validity of a potential typo c...
A POD class for pairing a NamedDecl* with an access specifier.
static DeclAccessPair make(NamedDecl *D, AccessSpecifier AS)
NamedDecl * getDecl() const
DeclContext - This is used only as base class of specific decl types that can act as declaration cont...
DeclContext * getParent()
getParent - Returns the containing DeclContext.
lookup_result lookup(DeclarationName Name) const
lookup - Find the declarations (if any) with the given Name in this context.
DeclContext * getEnclosingNamespaceContext()
Retrieve the nearest enclosing namespace context.
bool Encloses(const DeclContext *DC) const
Determine whether this declaration context semantically encloses the declaration context DC.
A reference to a declared variable, function, enum, etc.
void setHadMultipleCandidates(bool V=true)
Sets the flag telling whether this expression refers to a function that was resolved from an overload...
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(const FunctionDecl *Function)
static ExprWithCleanups * Create(const ASTContext &C, EmptyShell empty, unsigned numObjects)
The return type of classify().
static Classification makeSimpleLValue()
Create a simple, modifiable lvalue.
This represents one expression.
bool isIntegerConstantExpr(const ASTContext &Ctx) const
Expr * IgnoreParenCasts() LLVM_READONLY
Skip past any parentheses and casts which might surround this expression until reaching a fixed point...
bool isValueDependent() const
Determines whether the value of this expression depends on.
ExprValueKind getValueKind() const
getValueKind - The value kind that this expression produces.
bool isTypeDependent() const
Determines whether the type of this expression depends on.
llvm::APSInt EvaluateKnownConstInt(const ASTContext &Ctx) const
EvaluateKnownConstInt - Call EvaluateAsRValue and return the folded integer.
bool containsErrors() const
Whether this expression contains subexpressions which had errors.
Expr * IgnoreParens() LLVM_READONLY
Skip past any parentheses which might surround this expression until reaching a fixed point.
static bool hasAnyTypeDependentArguments(ArrayRef< Expr * > Exprs)
hasAnyTypeDependentArguments - Determines if any of the expressions in Exprs is type-dependent.
FieldDecl * getSourceBitField()
If this expression refers to a bit-field, retrieve the declaration of that bit-field.
@ NPC_ValueDependentIsNull
Specifies that a value-dependent expression of integral or dependent type should be considered a null...
@ NPC_ValueDependentIsNotNull
Specifies that a value-dependent expression should be considered to never be a null pointer constant.
ExprObjectKind getObjectKind() const
getObjectKind - The object kind that this expression produces.
bool EvaluateAsConstantExpr(EvalResult &Result, const ASTContext &Ctx, ConstantExprKind Kind=ConstantExprKind::Normal) const
Evaluate an expression that is required to be a constant expression.
@ NPCK_ZeroExpression
Expression is a Null pointer constant built from a zero integer expression that is not a simple,...
NullPointerConstantKind isNullPointerConstant(ASTContext &Ctx, NullPointerConstantValueDependence NPC) const
isNullPointerConstant - C99 6.3.2.3p3 - Test if this reduces down to a Null pointer constant.
SourceLocation getExprLoc() const LLVM_READONLY
getExprLoc - Return the preferred location for the arrow when diagnosing a problem with a generic exp...
bool refersToBitField() const
Returns true if this expression is a gl-value that potentially refers to a bit-field.
Classification Classify(ASTContext &Ctx) const
Classify - Classify this expression according to the C++11 expression taxonomy.
bool hasPlaceholderType() const
Returns whether this expression has a placeholder type.
static ExprValueKind getValueKindForType(QualType T)
getValueKindForType - Given a formal return or parameter type, give its value kind.
ExtVectorType - Extended vector type.
Represents difference between two FPOptions values.
Represents a member of a struct/union/class.
Annotates a diagnostic with some code that should be inserted, removed, or replaced to fix the proble...
static FixItHint CreateReplacement(CharSourceRange RemoveRange, StringRef Code)
Create a code modification hint that replaces the given source range with the given code string.
static FixItHint CreateInsertion(SourceLocation InsertionLoc, StringRef Code, bool BeforePreviousInsertions=false)
Create a code modification hint that inserts the given code string at a specific location.
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.
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.
bool shouldDeferTemplateArgumentDeduction(const Sema &S) const
void AddDeferredConversionTemplateCandidate(FunctionTemplateDecl *FunctionTemplate, DeclAccessPair FoundDecl, CXXRecordDecl *ActingContext, Expr *From, QualType ToType, bool AllowObjCConversionOnExplicit, bool AllowExplicit, bool AllowResultConversion)
void AddDeferredMethodTemplateCandidate(FunctionTemplateDecl *MethodTmpl, DeclAccessPair FoundDecl, CXXRecordDecl *ActingContext, QualType ObjectType, Expr::Classification ObjectClassification, ArrayRef< Expr * > Args, bool SuppressUserConversions, bool PartialOverloading, OverloadCandidateParamOrder PO)
void DisableResolutionByPerfectCandidate()
ConversionSequenceList allocateConversionSequences(unsigned NumConversions)
Allocate storage for conversion sequences for NumConversions conversions.
llvm::MutableArrayRef< Expr * > getPersistentArgsArray(unsigned N)
Provide storage for any Expr* arg that must be preserved until deferred template candidates are deduc...
OperatorRewriteInfo getRewriteInfo() const
@ CSK_AddressOfOverloadSet
C++ [over.match.call.general] Resolve a call through the address of an overload set.
@ CSK_InitByConstructor
C++ [over.match.ctor], [over.match.list] Initialization of an object of class type by constructor,...
@ CSK_InitByUserDefinedConversion
C++ [over.match.copy]: Copy-initialization of an object of class type by user-defined conversion.
@ CSK_Normal
Normal lookup.
@ CSK_Operator
C++ [over.match.oper]: Lookup of operator function candidates in a call using operator syntax.
@ CSK_CodeCompletion
When doing overload resolution during code completion, we want to show all viable candidates,...
SmallVectorImpl< OverloadCandidate >::iterator iterator
void NoteCandidates(PartialDiagnosticAt PA, Sema &S, OverloadCandidateDisplayKind OCD, ArrayRef< Expr * > Args, StringRef Opc="", SourceLocation Loc=SourceLocation(), llvm::function_ref< bool(OverloadCandidate &)> Filter=[](OverloadCandidate &) { return true;})
When overload resolution fails, prints diagnostic messages containing the candidates in the candidate...
bool shouldDeferDiags(Sema &S, ArrayRef< Expr * > Args, SourceLocation OpLoc)
Whether diagnostics should be deferred.
OverloadingResult BestViableFunction(Sema &S, SourceLocation Loc, OverloadCandidateSet::iterator &Best)
Find the best viable function on this overload set, if it exists.
void exclude(Decl *F)
Exclude a function from being considered by overload resolution.
SourceLocation getLocation() const
OverloadCandidate & addCandidate(unsigned NumConversions=0, ConversionSequenceList Conversions={})
Add a new candidate with NumConversions conversion sequence slots to the overload set.
void InjectNonDeducedTemplateCandidates(Sema &S)
CandidateSetKind getKind() const
size_t nonDeferredCandidatesCount() const
SmallVector< OverloadCandidate *, 32 > CompleteCandidates(Sema &S, OverloadCandidateDisplayKind OCD, ArrayRef< Expr * > Args, SourceLocation OpLoc=SourceLocation(), llvm::function_ref< bool(OverloadCandidate &)> Filter=[](OverloadCandidate &) { return true;})
A reference to an overloaded function set, either an UnresolvedLookupExpr or an UnresolvedMemberExpr.
bool hasExplicitTemplateArgs() const
Determines whether this expression had explicit template arguments.
static FindResult find(Expr *E)
Finds the overloaded expression in the given expression E of OverloadTy.
NestedNameSpecifier getQualifier() const
Fetches the nested-name qualifier, if one was given.
SourceLocation getNameLoc() const
Gets the location of the name.
UnresolvedSetImpl::iterator decls_iterator
decls_iterator decls_begin() const
unsigned getNumDecls() const
Gets the number of declarations in the unresolved set.
SourceLocation getTemplateKeywordLoc() const
Retrieve the location of the template keyword preceding this name, if any.
NestedNameSpecifierLoc getQualifierLoc() const
Fetches the nested-name qualifier with source-location information, if one was given.
void copyTemplateArgumentsInto(TemplateArgumentListInfo &List) const
Copies the template arguments into the given structure.
decls_iterator decls_end() const
DeclarationName getName() const
Gets the name looked up.
A single parameter index whose accessors require each use to make explicit the parameter index encodi...
ParenExpr - This represents a parenthesized expression, e.g.
Represents a parameter to a function.
bool hasDefaultArg() const
Determines whether this parameter has a default argument, either parsed or not.
bool isEquivalent(PointerAuthQualifier Other) const
std::string getAsString() const
PointerType - C99 6.7.5.1 - Pointer Declarators.
QualType getPointeeType() const
static PseudoObjectExpr * Create(const ASTContext &Context, Expr *syntactic, ArrayRef< Expr * > semantic, unsigned resultIndex)
A (possibly-)qualified type.
bool isVolatileQualified() const
Determine whether this type is volatile-qualified.
bool isRestrictQualified() const
Determine whether this type is restrict-qualified.
bool hasQualifiers() const
Determine whether this type has any qualifiers.
QualType getNonLValueExprType(const ASTContext &Context) const
Determine the type of a (typically non-lvalue) expression with the specified result type.
QualType withConst() const
QualType getLocalUnqualifiedType() const
Return this type with all of the instance-specific qualifiers removed, but without removing any quali...
bool isNull() const
Return true if this QualType doesn't point to a type yet.
const Type * getTypePtr() const
Retrieves a pointer to the underlying (unqualified) type.
LangAS getAddressSpace() const
Return the address space of this type.
Qualifiers getQualifiers() const
Retrieve the set of qualifiers applied to this type.
void getAsStringInternal(std::string &Str, const PrintingPolicy &Policy) const
QualType getNonReferenceType() const
If Type is a reference type (e.g., const int&), returns the type that the reference refers to ("const...
QualType getCanonicalType() const
QualType getUnqualifiedType() const
Retrieve the unqualified variant of the given type, removing as little sugar as possible.
unsigned getLocalCVRQualifiers() const
Retrieve the set of CVR (const-volatile-restrict) qualifiers local to this particular QualType instan...
bool isMoreQualifiedThan(QualType Other, const ASTContext &Ctx) const
Determine whether this type is more qualified than the other given type, requiring exact equality for...
bool isConstQualified() const
Determine whether this type is const-qualified.
bool hasAddressSpace() const
Check if this type has any address space qualifier.
unsigned getCVRQualifiers() const
Retrieve the set of CVR (const-volatile-restrict) qualifiers applied to this type.
static std::string getAsString(SplitQualType split, const PrintingPolicy &Policy)
bool isAtLeastAsQualifiedAs(QualType Other, const ASTContext &Ctx) const
Determine whether this type is at least as qualified as the other given type, requiring exact equalit...
Qualifiers getLocalQualifiers() const
Retrieve the set of qualifiers local to this particular QualType instance, not including any qualifie...
A qualifier set is used to build a set of qualifiers.
const Type * strip(QualType type)
Collect any qualifiers on the given type and return an unqualified type.
QualType apply(const ASTContext &Context, QualType QT) const
Apply the collected qualifiers to the given type.
QualifiersAndAtomic withVolatile()
QualifiersAndAtomic withAtomic()
The collection of all-type qualifiers we support.
unsigned getCVRQualifiers() const
bool hasOnlyConst() const
@ OCL_ExplicitNone
This object can be modified without requiring retains or releases.
void removeObjCLifetime()
bool compatiblyIncludes(Qualifiers other, const ASTContext &Ctx) const
Determines if these qualifiers compatibly include another set.
static bool isAddressSpaceSupersetOf(LangAS A, LangAS B, const ASTContext &Ctx)
Returns true if address space A is equal to or a superset of B.
void removeAddressSpace()
void setAddressSpace(LangAS space)
PointerAuthQualifier getPointerAuth() const
bool hasObjCGCAttr() const
ObjCLifetime getObjCLifetime() const
std::string getAsString() const
LangAS getAddressSpace() const
bool compatiblyIncludesObjCLifetime(Qualifiers other) const
Determines if these qualifiers compatibly include another set of qualifiers from the narrow perspecti...
An rvalue reference type, per C++11 [dcl.ref].
Represents a struct/union/class.
field_range fields() const
RecordDecl * getDefinitionOrSelf() const
Base for LValueReferenceType and RValueReferenceType.
QualType getPointeeType() const
Scope - A scope is a transient data structure that is used while parsing the program.
Smart pointer class that efficiently represents Objective-C method names.
unsigned getNumArgs() const
bool areCompatibleSveTypes(QualType FirstType, QualType SecondType)
Return true if the given types are an SVE builtin and a VectorType that is a fixed-length representat...
bool areLaxCompatibleSveTypes(QualType FirstType, QualType SecondType)
Return true if the given vector types are lax-compatible SVE vector types, false otherwise.
PartialDiagnostic PDiag(unsigned DiagID=0)
Build a partial diagnostic.
SemaDiagnosticBuilder Diag(SourceLocation Loc, unsigned DiagID)
Emit a diagnostic.
bool IsAllowedCall(const FunctionDecl *Caller, const FunctionDecl *Callee)
Determines whether Caller may invoke Callee, based on their CUDA host/device attributes.
CUDAFunctionTarget IdentifyTarget(const FunctionDecl *D, bool IgnoreImplicitHDAttr=false)
Determines whether the given function is a CUDA device/host/kernel/etc.
bool inferTargetForImplicitSpecialMember(CXXRecordDecl *ClassDecl, CXXSpecialMemberKind CSM, CXXMethodDecl *MemberDecl, bool ConstRHS, bool Diagnose)
Given a implicit special member, infer its CUDA target from the calls it needs to make to underlying ...
static bool isImplicitHostDeviceFunction(const FunctionDecl *D)
void EraseUnwantedMatches(const FunctionDecl *Caller, llvm::SmallVectorImpl< std::pair< DeclAccessPair, FunctionDecl * > > &Matches)
Finds a function in Matches with highest calling priority from Caller context and erases all function...
CUDAFunctionPreference IdentifyPreference(const FunctionDecl *Caller, const FunctionDecl *Callee)
Identifies relative preference of a given Caller/Callee combination, based on their host/device attri...
bool isObjCWritebackConversion(QualType FromType, QualType ToType, QualType &ConvertedType)
Determine whether this is an Objective-C writeback conversion, used for parameter passing when perfor...
Expr * stripARCUnbridgedCast(Expr *e)
stripARCUnbridgedCast - Given an expression of ARCUnbridgedCast type, remove the placeholder cast.
Abstract base class used to perform a contextual implicit conversion from an expression to any type p...
virtual SemaDiagnosticBuilder noteAmbiguous(Sema &S, CXXConversionDecl *Conv, QualType ConvTy)=0
Emits a note for one of the candidate conversions.
virtual SemaDiagnosticBuilder diagnoseNoMatch(Sema &S, SourceLocation Loc, QualType T)=0
Emits a diagnostic complaining that the expression does not have integral or enumeration type.
virtual SemaDiagnosticBuilder noteExplicitConv(Sema &S, CXXConversionDecl *Conv, QualType ConvTy)=0
Emits a note for the explicit conversion function.
virtual SemaDiagnosticBuilder diagnoseExplicitConv(Sema &S, SourceLocation Loc, QualType T, QualType ConvTy)=0
Emits a diagnostic when the only matching conversion function is explicit.
virtual SemaDiagnosticBuilder diagnoseConversion(Sema &S, SourceLocation Loc, QualType T, QualType ConvTy)=0
Emits a diagnostic when we picked a conversion function (for cases when we are not allowed to pick a ...
virtual SemaDiagnosticBuilder diagnoseAmbiguous(Sema &S, SourceLocation Loc, QualType T)=0
Emits a diagnostic when there are multiple possible conversion functions.
virtual bool match(QualType T)=0
Determine whether the specified type is a valid destination type for this conversion.
virtual SemaDiagnosticBuilder diagnoseIncomplete(Sema &S, SourceLocation Loc, QualType T)=0
Emits a diagnostic when the expression has incomplete class type.
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)
bool CheckFunctionTemplateSpecialization(FunctionDecl *FD, const TemplateParameterList *TemplateParams, TemplateArgumentListInfo *ExplicitTemplateArgs, LookupResult &Previous, bool QualifiedFriend=false)
Perform semantic analysis for the given function template specialization.
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)
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)
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()
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)
bool TemplateParameterListsAreEqual(const Decl *NewInstFrom, TemplateParameterList *New, const Decl *OldInstFrom, TemplateParameterList *Old, bool Complain, TemplateParameterListEqualKind Kind, SourceLocation TemplateArgLoc=SourceLocation())
Determine whether the given template parameter lists are equivalent.
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.
bool AreConstraintExpressionsEqual(const Decl *Old, const Expr *OldConstr, const Decl *New, const Expr *NewConstr)
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 isOverloadableType() const
Determines whether this is a type for which one can define an overloaded operator.
bool isObjCIdType() const
bool isMatrixType() const
bool isOverflowBehaviorType() const
bool 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)
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.
std::pair< unsigned, unsigned > getDepthAndIndex(const NamedDecl *ND)
Retrieve the depth and index of a template parameter.
OptionalUnsigned< unsigned > UnsignedOrNone
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.