Lines Matching +full:ovl +full:- +full:2 +full:l

1 //===--- SemaOverload.cpp - C++ Overloading -------------------------------===//
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //===----------------------------------------------------------------------===//
11 //===----------------------------------------------------------------------===//
60 return llvm::any_of(FD->parameters(), [](const ParmVarDecl *P) { in functionHasPassObjectSizeParams()
61 return P->hasAttr<PassObjectSizeAttr>(); in functionHasPassObjectSizeParams()
81 DeclRefExpr(S.Context, Fn, false, Fn->getType(), VK_LValue, Loc, LocInfo); in CreateFunctionRefExpr()
83 DRE->setHadMultipleCandidates(true); in CreateFunctionRefExpr()
86 if (auto *FPT = DRE->getType()->getAs<FunctionProtoType>()) { in CreateFunctionRefExpr()
87 if (isUnresolvedExceptionSpec(FPT->getExceptionSpecType())) { in CreateFunctionRefExpr()
89 DRE->setType(Fn->getType()); in CreateFunctionRefExpr()
92 return S.ImpCastExprToType(DRE, S.Context.getPointerType(DRE->getType()), in CreateFunctionRefExpr()
129 /// GetConversionRank - Retrieve the implicit conversion rank
159 ICR_Exact_Match, // NOTE(gbiv): This may not be completely right -- in GetConversionRank()
162 ICR_Exact_Match, // NOTE(ctopper): This may not be completely right -- in GetConversionRank()
195 /// GetImplicitConversionName - Return the name of this kind of
200 "Lvalue-to-rvalue", in GetImplicitConversionName()
201 "Array-to-pointer", in GetImplicitConversionName()
202 "Function-to-pointer", in GetImplicitConversionName()
211 "Floating-integral conversion", in GetImplicitConversionName()
213 "Pointer-to-member conversion", in GetImplicitConversionName()
215 "Compatible-types conversion", in GetImplicitConversionName()
216 "Derived-to-base conversion", in GetImplicitConversionName()
221 "Complex-real conversion", in GetImplicitConversionName()
231 "Non-decaying array conversion", in GetImplicitConversionName()
238 /// StandardConversionSequence - Set the standard conversion
257 /// getRank - Retrieve the rank of this standard conversion sequence
273 /// isPointerConversionToBool - Determines whether this conversion is
274 /// a conversion of a pointer or pointer-to-member to bool. This is
279 // array-to-pointer or function-to-pointer implicit conversions, so in isPointerConversionToBool()
282 if (getToType(1)->isBooleanType() && in isPointerConversionToBool()
283 (getFromType()->isPointerType() || in isPointerConversionToBool()
284 getFromType()->isMemberPointerType() || in isPointerConversionToBool()
285 getFromType()->isObjCObjectPointerType() || in isPointerConversionToBool()
286 getFromType()->isBlockPointerType() || in isPointerConversionToBool()
293 /// isPointerConversionToVoidPointer - Determines whether this
304 // array-to-pointer implicit conversion, so check for its presence in isPointerConversionToVoidPointer()
309 if (Second == ICK_Pointer_Conversion && FromType->isAnyPointerType()) in isPointerConversionToVoidPointer()
310 if (const PointerType* ToPtrType = ToType->getAs<PointerType>()) in isPointerConversionToVoidPointer()
311 return ToPtrType->getPointeeType()->isVoidType(); in isPointerConversionToVoidPointer()
324 const_cast<Expr *>(IgnoreNarrowingConversion(Ctx, EWC->getSubExpr())); in IgnoreNarrowingConversion()
325 return ExprWithCleanups::Create(Ctx, Inner, EWC->cleanupsHaveSideEffects(), in IgnoreNarrowingConversion()
326 EWC->getObjects()); in IgnoreNarrowingConversion()
330 switch (ICE->getCastKind()) { in IgnoreNarrowingConversion()
339 Converted = ICE->getSubExpr(); in IgnoreNarrowingConversion()
359 /// \param IgnoreFloatToIntegralConversion If true type-narrowing conversions
375 if (auto *ET = ToType->getAs<EnumType>()) in getNarrowingKind()
376 ToType = ET->getDecl()->getIntegerType(); in getNarrowingKind()
381 if (FromType->isRealFloatingType()) in getNarrowingKind()
383 if (FromType->isIntegralOrUnscopedEnumerationType()) in getNarrowingKind()
385 // -- from a pointer type or pointer-to-member type to bool, or in getNarrowingKind()
388 // -- from a floating-point type to an integer type, or in getNarrowingKind()
390 // -- from an integer type or unscoped enumeration type to a floating-point in getNarrowingKind()
396 if (FromType->isRealFloatingType() && ToType->isIntegralType(Ctx)) { in getNarrowingKind()
398 } else if (FromType->isIntegralOrUnscopedEnumerationType() && in getNarrowingKind()
399 ToType->isRealFloatingType()) { in getNarrowingKind()
405 // If it's value-dependent, we can't tell whether it's narrowing. in getNarrowingKind()
406 if (Initializer->isValueDependent()) in getNarrowingKind()
410 Initializer->getIntegerConstantExpr(Ctx)) { in getNarrowingKind()
413 Result.convertFromAPInt(*IntConstantValue, IntConstantValue->isSigned(), in getNarrowingKind()
423 ConstantType = Initializer->getType(); in getNarrowingKind()
433 // -- from long double to double or float, or from double to float, except in getNarrowingKind()
438 if (FromType->isRealFloatingType() && ToType->isRealFloatingType() && in getNarrowingKind()
443 // If it's value-dependent, we can't tell whether it's narrowing. in getNarrowingKind()
444 if (Initializer->isValueDependent()) in getNarrowingKind()
448 if ((Ctx.getLangOpts().C23 && Initializer->EvaluateAsRValue(R, Ctx)) || in getNarrowingKind()
449 Initializer->isCXX11ConstantExpr(Ctx, &ConstantValue)) { in getNarrowingKind()
472 ConstantType = Initializer->getType(); in getNarrowingKind()
479 ConstantType = Initializer->getType(); in getNarrowingKind()
489 // -- from an integer type or unscoped enumeration type to an integer type in getNarrowingKind()
496 assert(FromType->isIntegralOrUnscopedEnumerationType()); in getNarrowingKind()
497 assert(ToType->isIntegralOrUnscopedEnumerationType()); in getNarrowingKind()
498 const bool FromSigned = FromType->isSignedIntegerOrEnumerationType(); in getNarrowingKind()
500 const bool ToSigned = ToType->isSignedIntegerOrEnumerationType(); in getNarrowingKind()
509 // If it's value-dependent, we can't tell whether it's narrowing. in getNarrowingKind()
510 if (Initializer->isValueDependent()) in getNarrowingKind()
514 if (!(OptInitializerValue = Initializer->getIntegerConstantExpr(Ctx))) { in getNarrowingKind()
521 // Negative -> unsigned is narrowing. Otherwise, more bits is never in getNarrowingKind()
530 // Convert the initializer to and from the target width and signed-ness. in getNarrowingKind()
541 ConstantType = Initializer->getType(); in getNarrowingKind()
549 if (FromType->isComplexType() && !ToType->isComplexType()) in getNarrowingKind()
557 if (Initializer->EvaluateAsRValue(R, Ctx)) { in getNarrowingKind()
566 ConstantType = Initializer->getType(); in getNarrowingKind()
578 /// dump - Print this standard conversion sequence to standard
590 OS << " -> "; in dump()
606 OS << " -> "; in dump()
617 /// dump - Print this user-defined conversion sequence to standard
623 OS << " -> "; in dump()
630 OS << " -> "; in dump()
635 /// dump - Print this implicit conversion sequence to standard
647 OS << "User-defined conversion: "; in dump()
706 /// to the form used in overload-candidate information.
733 Saved->FirstArg = Info.FirstArg; in MakeDeductionFailureInfo()
734 Saved->SecondArg = Info.SecondArg; in MakeDeductionFailureInfo()
735 Saved->TemplateArgs = Info.takeSugared(); in MakeDeductionFailureInfo()
736 Saved->CallArgIndex = Info.CallArgIndex; in MakeDeductionFailureInfo()
744 Saved->FirstArg = Info.FirstArg; in MakeDeductionFailureInfo()
745 Saved->SecondArg = Info.SecondArg; in MakeDeductionFailureInfo()
756 Saved->Param = Info.Param; in MakeDeductionFailureInfo()
757 Saved->FirstArg = Info.FirstArg; in MakeDeductionFailureInfo()
758 Saved->SecondArg = Info.SecondArg; in MakeDeductionFailureInfo()
775 Saved->TemplateArgs = Info.takeSugared(); in MakeDeductionFailureInfo()
776 Saved->Satisfaction = Info.AssociatedConstraintsSatisfaction; in MakeDeductionFailureInfo()
817 Diag->~PartialDiagnosticAt(); in Destroy()
826 Diag->~PartialDiagnosticAt(); in Destroy()
867 return static_cast<DFIParamWithArguments*>(Data)->Param; in getTemplateParameter()
897 return static_cast<DFIDeducedMismatchArgs*>(Data)->TemplateArgs; in getTemplateArgumentList()
903 return static_cast<CNSInfo*>(Data)->TemplateArgs; in getTemplateArgumentList()
935 return &static_cast<DFIArguments*>(Data)->FirstArg; in getFirstArg()
967 return &static_cast<DFIArguments*>(Data)->SecondArg; in getSecondArg()
982 return static_cast<DFIDeducedMismatchArgs*>(Data)->CallArgIndex; in getCallArgIndex()
993 if (X->getNumParams() != Y->getNumParams()) in FunctionsCorrespond()
998 for (unsigned I = 0; I < X->getNumParams(); ++I) in FunctionsCorrespond()
999 if (!Ctx.hasSameUnqualifiedType(X->getParamDecl(I)->getType(), in FunctionsCorrespond()
1000 Y->getParamDecl(I)->getType())) in FunctionsCorrespond()
1002 if (auto *FTX = X->getDescribedFunctionTemplate()) { in FunctionsCorrespond()
1003 auto *FTY = Y->getDescribedFunctionTemplate(); in FunctionsCorrespond()
1006 if (!Ctx.isSameTemplateParameterList(FTX->getTemplateParameters(), in FunctionsCorrespond()
1007 FTY->getTemplateParameters())) in FunctionsCorrespond()
1015 assert(EqFD->getOverloadedOperator() == in shouldAddReversedEqEq()
1017 // C++2a [over.match.oper]p4: in shouldAddReversedEqEq()
1018 // A non-template function or function template F named operator== is a in shouldAddReversedEqEq()
1031 QualType RHS = FirstOperand->getType(); in shouldAddReversedEqEq()
1032 auto *RHSRec = RHS->getAs<RecordType>(); in shouldAddReversedEqEq()
1037 S.LookupQualifiedName(Members, RHSRec->getDecl()); in shouldAddReversedEqEq()
1040 if (FunctionsCorrespond(S.Context, EqFD, Op->getAsFunction())) in shouldAddReversedEqEq()
1045 for (NamedDecl *Op : EqFD->getEnclosingNamespaceContext()->lookup(NotEqOp)) { in shouldAddReversedEqEq()
1046 auto *NotEqFD = Op->getAsFunction(); in shouldAddReversedEqEq()
1048 NotEqFD = UD->getUnderlyingDecl()->getAsFunction(); in shouldAddReversedEqEq()
1050 declaresSameEntity(cast<Decl>(EqFD->getEnclosingNamespaceContext()), in shouldAddReversedEqEq()
1051 cast<Decl>(Op->getLexicalDeclContext()))) in shouldAddReversedEqEq()
1066 auto Op = FD->getOverloadedOperator(); in shouldAddReversed()
1070 assert(OriginalArgs.size() == 2); in shouldAddReversed()
1076 // match than the non-reversed version. in shouldAddReversed()
1077 return FD->getNumNonObjectParams() != 2 || in shouldAddReversed()
1078 !S.Context.hasSameUnqualifiedType(FD->getParamDecl(0)->getType(), in shouldAddReversed()
1079 FD->getParamDecl(1)->getType()) || in shouldAddReversed()
1080 FD->hasAttr<EnableIfAttr>(); in shouldAddReversed()
1085 for (auto &C : i->Conversions) in destroyCandidates()
1087 if (!i->Viable && i->FailureKind == ovl_fail_bad_deduction) in destroyCandidates()
1088 i->DeductionFailure.Destroy(); in destroyCandidates()
1107 SmallVector<Entry, 2> Entries;
1111 assert(E->hasPlaceholderType(BuiltinType::ARCUnbridgedCast)); in save()
1120 *i->Addr = i->Saved; in restore()
1125 /// checkPlaceholderForOverload - Do any interesting placeholder-like
1135 if (const BuiltinType *placeholder = E->getType()->getAsPlaceholderType()) { in checkPlaceholderForOverload()
1138 if (placeholder->getKind() == BuiltinType::Overload) return false; in checkPlaceholderForOverload()
1142 if (placeholder->getKind() == BuiltinType::ARCUnbridgedCast && in checkPlaceholderForOverload()
1144 unbridgedCasts->save(S, E); in checkPlaceholderForOverload()
1161 /// checkArgPlaceholdersForOverload - Check a set of call operands for
1187 OldD = cast<UsingShadowDecl>(OldD)->getTargetDecl(); in CheckOverload()
1190 // A using-declaration does not conflict with another declaration in CheckOverload()
1201 (OldIsUsingDecl || NewIsUsingDecl) && CurContext->isRecord() && in CheckOverload()
1202 !New->getFriendObjectKind(); in CheckOverload()
1204 if (FunctionDecl *OldF = OldD->getAsFunction()) { in CheckOverload()
1238 if (UUD->getQualifier()->isDependent() && !UUD->isCXXClassMember()) { in CheckOverload()
1253 // -- if the name of the friend is a qualified or unqualified template-id, in CheckOverload()
1255 // -- if the name of the friend is a qualified-id and a matching in CheckOverload()
1256 // non-template function is found in the specified class or namespace, in CheckOverload()
1258 // -- if the name of the friend is a qualified-id and a matching function in CheckOverload()
1262 // -- the name shall be an unqualified-id [...] in CheckOverload()
1266 if (New->getFriendObjectKind() && New->getQualifier() && in CheckOverload()
1267 !New->getDescribedFunctionTemplate() && in CheckOverload()
1268 !New->getDependentSpecializationInfo() && in CheckOverload()
1269 !New->getType()->isDependentType()) { in CheckOverload()
1274 New->setInvalidDecl(); in CheckOverload()
1291 if (New->isMain()) in IsOverloadOrOverrideImpl()
1295 if (New->isMSVCRTEntryPoint()) in IsOverloadOrOverrideImpl()
1300 FunctionTemplateDecl *OldTemplate = Old->getDescribedFunctionTemplate(); in IsOverloadOrOverrideImpl()
1301 FunctionTemplateDecl *NewTemplate = New->getDescribedFunctionTemplate(); in IsOverloadOrOverrideImpl()
1305 // and with normal (non-template) functions. in IsOverloadOrOverrideImpl()
1310 QualType OldQType = SemaRef.Context.getCanonicalType(Old->getType()); in IsOverloadOrOverrideImpl()
1311 QualType NewQType = SemaRef.Context.getCanonicalType(New->getType()); in IsOverloadOrOverrideImpl()
1317 // If either of these functions is a K&R-style function (no in IsOverloadOrOverrideImpl()
1329 if (OldQType != NewQType && OldType->isVariadic() != NewType->isVariadic()) in IsOverloadOrOverrideImpl()
1332 // For member-like friends, the enclosing class is part of the signature. in IsOverloadOrOverrideImpl()
1333 if ((New->isMemberLikeConstrainedFriend() || in IsOverloadOrOverrideImpl()
1334 Old->isMemberLikeConstrainedFriend()) && in IsOverloadOrOverrideImpl()
1335 !New->getLexicalDeclContext()->Equals(Old->getLexicalDeclContext())) in IsOverloadOrOverrideImpl()
1341 // references to non-instantiated entities during constraint substitution. in IsOverloadOrOverrideImpl()
1356 NewTemplate, NewTemplate->getTemplateParameters(), OldTemplate, in IsOverloadOrOverrideImpl()
1357 OldTemplate->getTemplateParameters(), false, Sema::TPL_TemplateMatch); in IsOverloadOrOverrideImpl()
1359 Old->getDeclaredReturnType(), New->getDeclaredReturnType()); in IsOverloadOrOverrideImpl()
1360 // FIXME(GH58571): Match template parameter list even for non-constrained in IsOverloadOrOverrideImpl()
1364 NewTemplate->getTemplateParameters()->hasAssociatedConstraints() || in IsOverloadOrOverrideImpl()
1365 OldTemplate->getTemplateParameters()->hasAssociatedConstraints(); in IsOverloadOrOverrideImpl()
1367 // The set of declarations named by a using-declarator that inhabits a in IsOverloadOrOverrideImpl()
1392 if (M->isExplicitObjectMemberFunction()) in IsOverloadOrOverrideImpl()
1400 // or non-static member function). Add it now, on the assumption that this in IsOverloadOrOverrideImpl()
1403 (M->isConstexpr() || M->isConsteval()) && in IsOverloadOrOverrideImpl()
1419 if (OldMethod->isImplicitObjectMemberFunction() && in IsOverloadOrOverrideImpl()
1420 OldMethod->getParent() != NewMethod->getParent()) { in IsOverloadOrOverrideImpl()
1422 SemaRef.Context.getTypeDeclType(OldMethod->getParent()) in IsOverloadOrOverrideImpl()
1433 if (Base->isLValueReferenceType()) in IsOverloadOrOverrideImpl()
1434 return D->isLValueReferenceType(); in IsOverloadOrOverrideImpl()
1435 return Base->isRValueReferenceType() == D->isRValueReferenceType(); in IsOverloadOrOverrideImpl()
1439 // cv-qualifiers (if any) and ref-qualifier (if any) on the function itself. in IsOverloadOrOverrideImpl()
1443 if (OldMethod->getRefQualifier() == NewMethod->getRefQualifier()) in IsOverloadOrOverrideImpl()
1445 if (OldMethod->isExplicitObjectMemberFunction() || in IsOverloadOrOverrideImpl()
1446 NewMethod->isExplicitObjectMemberFunction()) in IsOverloadOrOverrideImpl()
1448 if (!UseMemberUsingDeclRules && (OldMethod->getRefQualifier() == RQ_None || in IsOverloadOrOverrideImpl()
1449 NewMethod->getRefQualifier() == RQ_None)) { in IsOverloadOrOverrideImpl()
1450 SemaRef.Diag(NewMethod->getLocation(), diag::err_ref_qualifier_overload) in IsOverloadOrOverrideImpl()
1451 << NewMethod->getRefQualifier() << OldMethod->getRefQualifier(); in IsOverloadOrOverrideImpl()
1452 SemaRef.Diag(OldMethod->getLocation(), diag::note_previous_declaration); in IsOverloadOrOverrideImpl()
1458 if (OldMethod && OldMethod->isExplicitObjectMemberFunction()) in IsOverloadOrOverrideImpl()
1460 if (NewMethod && NewMethod->isExplicitObjectMemberFunction()) in IsOverloadOrOverrideImpl()
1463 if (OldType->getNumParams() - OldParamsOffset != in IsOverloadOrOverrideImpl()
1464 NewType->getNumParams() - NewParamsOffset || in IsOverloadOrOverrideImpl()
1466 {OldType->param_type_begin() + OldParamsOffset, in IsOverloadOrOverrideImpl()
1467 OldType->param_type_end()}, in IsOverloadOrOverrideImpl()
1468 {NewType->param_type_begin() + NewParamsOffset, in IsOverloadOrOverrideImpl()
1469 NewType->param_type_end()}, in IsOverloadOrOverrideImpl()
1474 if (OldMethod && NewMethod && !OldMethod->isStatic() && in IsOverloadOrOverrideImpl()
1475 !NewMethod->isStatic()) { in IsOverloadOrOverrideImpl()
1478 auto NewObjectType = New->getFunctionObjectParameterReferenceType(); in IsOverloadOrOverrideImpl()
1479 auto OldObjectType = Old->getFunctionObjectParameterReferenceType(); in IsOverloadOrOverrideImpl()
1482 return F->getRefQualifier() == RQ_None && in IsOverloadOrOverrideImpl()
1483 !F->isExplicitObjectMemberFunction(); in IsOverloadOrOverrideImpl()
1499 if (!UseOverrideRules || (!NewMethod->isExplicitObjectMemberFunction() && in IsOverloadOrOverrideImpl()
1500 !OldMethod->isExplicitObjectMemberFunction())) in IsOverloadOrOverrideImpl()
1506 New->getTemplateSpecializationKind() != TSK_ExplicitSpecialization) { in IsOverloadOrOverrideImpl()
1507 Expr *NewRC = New->getTrailingRequiresClause(), in IsOverloadOrOverrideImpl()
1508 *OldRC = Old->getTrailingRequiresClause(); in IsOverloadOrOverrideImpl()
1516 if (NewMethod && OldMethod && OldMethod->isImplicitObjectMemberFunction() && in IsOverloadOrOverrideImpl()
1517 NewMethod->isImplicitObjectMemberFunction()) { in IsOverloadOrOverrideImpl()
1523 // consider it to be a function-level modifier for the sake of function in IsOverloadOrOverrideImpl()
1530 // enable_if attributes are an order-sensitive part of the signature. in IsOverloadOrOverrideImpl()
1532 NewI = New->specific_attr_begin<EnableIfAttr>(), in IsOverloadOrOverrideImpl()
1533 NewE = New->specific_attr_end<EnableIfAttr>(), in IsOverloadOrOverrideImpl()
1534 OldI = Old->specific_attr_begin<EnableIfAttr>(), in IsOverloadOrOverrideImpl()
1535 OldE = Old->specific_attr_end<EnableIfAttr>(); in IsOverloadOrOverrideImpl()
1540 NewI->getCond()->Profile(NewID, SemaRef.Context, true); in IsOverloadOrOverrideImpl()
1541 OldI->getCond()->Profile(OldID, SemaRef.Context, true); in IsOverloadOrOverrideImpl()
1582 /// Tries a user-defined conversion from From to ToType.
1603 // Attempt user-defined conversion. in TryUserDefinedConversion()
1604 OverloadCandidateSet Conversions(From->getExprLoc(), in TryUserDefinedConversion()
1617 // constructor (i.e., a user-defined conversion function) is in TryUserDefinedConversion()
1622 = S.Context.getCanonicalType(From->getType().getUnqualifiedType()); in TryUserDefinedConversion()
1625 if (Constructor->isCopyConstructor() && in TryUserDefinedConversion()
1627 S.IsDerivedFrom(From->getBeginLoc(), FromCanon, ToCanon))) { in TryUserDefinedConversion()
1633 ICS.Standard.setFromType(From->getType()); in TryUserDefinedConversion()
1645 ICS.Ambiguous.setFromType(From->getType()); in TryUserDefinedConversion()
1649 if (Cand->Best) in TryUserDefinedConversion()
1650 ICS.Ambiguous.addConversion(Cand->FoundDecl, Cand->Function); in TryUserDefinedConversion()
1662 /// TryImplicitConversion - Attempt to perform an implicit conversion
1672 /// conversion sequence containing an lvalue-to-rvalue conversion (C++
1673 /// 4.1) followed by a floating-integral conversion (C++ 4.9).
1681 /// If @p SuppressUserConversions, then user-defined conversions are
1683 /// If @p AllowExplicit, then explicit user-defined conversions are
1686 /// \param AllowObjCWritebackConversion Whether we allow the Objective-C
1714 // constructor (i.e., a user-defined conversion function) is in TryImplicitConversion()
1716 QualType FromType = From->getType(); in TryImplicitConversion()
1717 if (ToType->getAs<RecordType>() && FromType->getAs<RecordType>() && in TryImplicitConversion()
1719 S.IsDerivedFrom(From->getBeginLoc(), FromType, ToType))) { in TryImplicitConversion()
1731 // Determine whether this is considered a derived-to-base conversion. in TryImplicitConversion()
1763 // Objective-C ARC: Determine whether we will allow the writeback conversion. in PerformImplicitConversion()
1768 ObjC().CheckObjCBridgeRelatedConversions(From->getBeginLoc(), ToType, in PerformImplicitConversion()
1769 From->getType(), From); in PerformImplicitConversion()
1785 // Permit the conversion F(t __attribute__((noreturn))) -> F(t) in IsFunctionConversion()
1786 // or F(t noexcept) -> F(t) in IsFunctionConversion()
1788 // - a pointer in IsFunctionConversion()
1789 // - a member pointer in IsFunctionConversion()
1790 // - a block pointer in IsFunctionConversion()
1794 Type::TypeClass TyClass = CanTo->getTypeClass(); in IsFunctionConversion()
1795 if (TyClass != CanFrom->getTypeClass()) return false; in IsFunctionConversion()
1798 CanTo = CanTo.castAs<PointerType>()->getPointeeType(); in IsFunctionConversion()
1799 CanFrom = CanFrom.castAs<PointerType>()->getPointeeType(); in IsFunctionConversion()
1801 CanTo = CanTo.castAs<BlockPointerType>()->getPointeeType(); in IsFunctionConversion()
1802 CanFrom = CanFrom.castAs<BlockPointerType>()->getPointeeType(); in IsFunctionConversion()
1807 if (ToMPT->getClass() != FromMPT->getClass()) in IsFunctionConversion()
1809 CanTo = ToMPT->getPointeeType(); in IsFunctionConversion()
1810 CanFrom = FromMPT->getPointeeType(); in IsFunctionConversion()
1815 TyClass = CanTo->getTypeClass(); in IsFunctionConversion()
1816 if (TyClass != CanFrom->getTypeClass()) return false; in IsFunctionConversion()
1822 FunctionType::ExtInfo FromEInfo = FromFn->getExtInfo(); in IsFunctionConversion()
1825 FunctionType::ExtInfo ToEInfo = ToFn->getExtInfo(); in IsFunctionConversion()
1838 if (FromFPT->isNothrow() && !ToFPT->isNothrow()) { in IsFunctionConversion()
1854 FunctionProtoType::ExtProtoInfo ExtInfo = FromFPT->getExtProtoInfo(); in IsFunctionConversion()
1857 QualType QT = Context.getFunctionType(FromFPT->getReturnType(), in IsFunctionConversion()
1858 FromFPT->getParamTypes(), ExtInfo); in IsFunctionConversion()
1859 FromFn = QT->getAs<FunctionType>(); in IsFunctionConversion()
1872 const auto FromFX = FromFPT->getFunctionEffects(); in IsFunctionConversion()
1873 const auto ToFX = ToFPT->getFunctionEffects(); in IsFunctionConversion()
1875 FunctionProtoType::ExtProtoInfo ExtInfo = FromFPT->getExtProtoInfo(); in IsFunctionConversion()
1878 FromFPT->getReturnType(), FromFPT->getParamTypes(), ExtInfo); in IsFunctionConversion()
1879 FromFn = QT->getAs<FunctionType>(); in IsFunctionConversion()
1900 if (!FromType->isRealFloatingType() || !ToType->isRealFloatingType()) in IsFloatingPointConversion()
1907 if ((FromType->isBFloat16Type() && in IsFloatingPointConversion()
1908 (ToType->isFloat16Type() || ToType->isHalfType())) || in IsFloatingPointConversion()
1909 (ToType->isBFloat16Type() && in IsFloatingPointConversion()
1910 (FromType->isFloat16Type() || FromType->isHalfType()))) in IsFloatingPointConversion()
1913 // Conversions between IEEE-quad and IBM-extended semantics are not in IsFloatingPointConversion()
1941 if (ToType->isBooleanType() && FromType->isArithmeticType()) { in IsVectorElementConversion()
1946 if ((FromType->isRealFloatingType() && ToType->isIntegralType(S.Context)) || in IsVectorElementConversion()
1947 (FromType->isIntegralOrUnscopedEnumerationType() && in IsVectorElementConversion()
1948 ToType->isRealFloatingType())) { in IsVectorElementConversion()
1958 if (FromType->isIntegralOrUnscopedEnumerationType() && in IsVectorElementConversion()
1959 ToType->isIntegralType(S.Context)) { in IsVectorElementConversion()
1978 if (!ToType->isVectorType() && !FromType->isVectorType()) in IsVectorConversion()
1986 if (auto *ToExtType = ToType->getAs<ExtVectorType>()) { in IsVectorConversion()
1987 if (auto *FromExtType = FromType->getAs<ExtVectorType>()) { in IsVectorConversion()
1990 unsigned FromElts = FromExtType->getNumElements(); in IsVectorConversion()
1991 unsigned ToElts = ToExtType->getNumElements(); in IsVectorConversion()
1999 QualType FromElTy = FromExtType->getElementType(); in IsVectorConversion()
2000 QualType ToElTy = ToExtType->getElementType(); in IsVectorConversion()
2011 if (FromType->isArithmeticType()) { in IsVectorConversion()
2014 QualType ToElTy = ToExtType->getElementType(); in IsVectorConversion()
2022 if (ToType->isSVESizelessBuiltinType() || in IsVectorConversion()
2023 FromType->isSVESizelessBuiltinType()) in IsVectorConversion()
2030 if (ToType->isRVVSizelessBuiltinType() || in IsVectorConversion()
2031 FromType->isRVVSizelessBuiltinType()) in IsVectorConversion()
2040 // 2)lax vector conversions are permitted and the vector types are of the in IsVectorConversion()
2042 // 3)the destination type does not have the ARM MVE strict-polymorphism in IsVectorConversion()
2045 if (ToType->isVectorType() && FromType->isVectorType()) { in IsVectorConversion()
2048 !ToType->hasAttr(attr::ArmMveStrictPolymorphism))) { in IsVectorConversion()
2054 S.Diag(From->getBeginLoc(), diag::warn_deprecated_lax_vec_conv_all) in IsVectorConversion()
2070 /// IsStandardConversion - Determines whether there is a standard
2073 /// only consider non-class types; for conversions that involve class
2083 QualType FromType = From->getType(); in IsStandardConversion()
2094 (FromType->isRecordType() || ToType->isRecordType())) in IsStandardConversion()
2097 // The first conversion can be an lvalue-to-rvalue conversion, in IsStandardConversion()
2098 // array-to-pointer conversion, or function-to-pointer conversion in IsStandardConversion()
2108 FromType = Fn->getType(); in IsStandardConversion()
2120 if (!ToType->isBooleanType()) in IsStandardConversion()
2126 // fact that non-static member functions *must* have such an address-of in IsStandardConversion()
2129 if (Method && !Method->isStatic() && in IsStandardConversion()
2130 !Method->isExplicitObjectMemberFunction()) { in IsStandardConversion()
2131 assert(isa<UnaryOperator>(From->IgnoreParens()) && in IsStandardConversion()
2132 "Non-unary operator on non-static member address"); in IsStandardConversion()
2133 assert(cast<UnaryOperator>(From->IgnoreParens())->getOpcode() in IsStandardConversion()
2135 "Non-address-of operator on non-static member address"); in IsStandardConversion()
2137 = S.Context.getTypeDeclType(Method->getParent()).getTypePtr(); in IsStandardConversion()
2139 } else if (isa<UnaryOperator>(From->IgnoreParens())) { in IsStandardConversion()
2140 assert(cast<UnaryOperator>(From->IgnoreParens())->getOpcode() == in IsStandardConversion()
2142 "Non-address-of operator for overloaded function expression"); in IsStandardConversion()
2149 // Lvalue-to-rvalue conversion (C++11 4.1): in IsStandardConversion()
2150 // A glvalue (3.10) of a non-function, non-array type T can in IsStandardConversion()
2152 bool argIsLValue = From->isGLValue(); in IsStandardConversion()
2153 if (argIsLValue && !FromType->canDecayToPointerType() && in IsStandardConversion()
2158 // ... if the lvalue has atomic type, the value has the non-atomic version in IsStandardConversion()
2160 if (const AtomicType *Atomic = FromType->getAs<AtomicType>()) in IsStandardConversion()
2161 FromType = Atomic->getValueType(); in IsStandardConversion()
2163 // If T is a non-class type, the type of the rvalue is the in IsStandardConversion()
2164 // cv-unqualified version of T. Otherwise, the type of the rvalue in IsStandardConversion()
2168 } else if (S.getLangOpts().HLSL && FromType->isConstantArrayType() && in IsStandardConversion()
2169 ToType->isArrayParameterType()) { in IsStandardConversion()
2181 } else if (FromType->isArrayType()) { in IsStandardConversion()
2182 // Array-to-pointer conversion (C++ 4.2) in IsStandardConversion()
2196 // array-to-pointer conversion followed by a qualification in IsStandardConversion()
2204 } else if (FromType->isFunctionType() && argIsLValue) { in IsStandardConversion()
2205 // Function-to-pointer conversion (C++ 4.3). in IsStandardConversion()
2208 if (auto *DRE = dyn_cast<DeclRefExpr>(From->IgnoreParenCasts())) in IsStandardConversion()
2209 if (auto *FD = dyn_cast<FunctionDecl>(DRE->getDecl())) in IsStandardConversion()
2225 // floating-integral conversion, pointer conversion, in IsStandardConversion()
2226 // pointer-to-member conversion, or boolean conversion (C++ 4p1). in IsStandardConversion()
2227 // For overloading in C, this can also be a "compatible-type" in IsStandardConversion()
2248 } else if (ToType->isBooleanType() && in IsStandardConversion()
2249 (FromType->isArithmeticType() || in IsStandardConversion()
2250 FromType->isAnyPointerType() || in IsStandardConversion()
2251 FromType->isBlockPointerType() || in IsStandardConversion()
2252 FromType->isMemberPointerType())) { in IsStandardConversion()
2256 } else if (FromType->isIntegralOrUnscopedEnumerationType() && in IsStandardConversion()
2257 ToType->isIntegralType(S.Context)) { in IsStandardConversion()
2261 } else if (FromType->isAnyComplexType() && ToType->isAnyComplexType()) { in IsStandardConversion()
2265 } else if ((FromType->isAnyComplexType() && ToType->isArithmeticType()) || in IsStandardConversion()
2266 (ToType->isAnyComplexType() && FromType->isArithmeticType())) { in IsStandardConversion()
2267 // Complex-real conversions (C99 6.3.1.7) in IsStandardConversion()
2274 } else if ((FromType->isRealFloatingType() && in IsStandardConversion()
2275 ToType->isIntegralType(S.Context)) || in IsStandardConversion()
2276 (FromType->isIntegralOrUnscopedEnumerationType() && in IsStandardConversion()
2277 ToType->isRealFloatingType())) { in IsStandardConversion()
2279 // Floating-integral conversions (C++ 4.9). in IsStandardConversion()
2316 } else if (ToType->isEventT() && in IsStandardConversion()
2317 From->isIntegerConstantExpr(S.getASTContext()) && in IsStandardConversion()
2318 From->EvaluateKnownConstInt(S.getASTContext()) == 0) { in IsStandardConversion()
2321 } else if (ToType->isQueueT() && in IsStandardConversion()
2322 From->isIntegerConstantExpr(S.getASTContext()) && in IsStandardConversion()
2323 (From->EvaluateKnownConstInt(S.getASTContext()) == 0)) { in IsStandardConversion()
2326 } else if (ToType->isSamplerT() && in IsStandardConversion()
2327 From->isIntegerConstantExpr(S.getASTContext())) { in IsStandardConversion()
2330 } else if ((ToType->isFixedPointType() && in IsStandardConversion()
2331 FromType->isConvertibleToFixedPointType()) || in IsStandardConversion()
2332 (FromType->isFixedPointType() && in IsStandardConversion()
2333 ToType->isConvertibleToFixedPointType())) { in IsStandardConversion()
2360 // [...] Any difference in top-level cv-qualification is in IsStandardConversion()
2372 SCS.setToType(2, FromType); in IsStandardConversion()
2416 SCS.setToType(2, ToType); in IsStandardConversion()
2427 const RecordType *UT = ToType->getAsUnionType(); in IsTransparentUnionStandardConversion()
2428 if (!UT || !UT->getDecl()->hasAttr<TransparentUnionAttr>()) in IsTransparentUnionStandardConversion()
2431 RecordDecl *UD = UT->getDecl(); in IsTransparentUnionStandardConversion()
2433 for (const auto *it : UD->fields()) { in IsTransparentUnionStandardConversion()
2434 if (IsStandardConversion(S, From, it->getType(), InOverloadResolution, SCS, in IsTransparentUnionStandardConversion()
2436 ToType = it->getType(); in IsTransparentUnionStandardConversion()
2444 const BuiltinType *To = ToType->getAs<BuiltinType>(); in IsIntegralPromotion()
2445 // All integers are built-in. in IsIntegralPromotion()
2455 if (Context.isPromotableIntegerType(FromType) && !FromType->isBooleanType() && in IsIntegralPromotion()
2456 !FromType->isEnumeralType()) { in IsIntegralPromotion()
2458 (FromType->isSignedIntegerType() || in IsIntegralPromotion()
2462 return To->getKind() == BuiltinType::Int; in IsIntegralPromotion()
2465 return To->getKind() == BuiltinType::UInt; in IsIntegralPromotion()
2486 if (const EnumType *FromEnumType = FromType->getAs<EnumType>()) { in IsIntegralPromotion()
2489 if (FromEnumType->getDecl()->isScoped()) in IsIntegralPromotion()
2495 // the bitfield-ness of the actual source expression. in IsIntegralPromotion()
2496 if (FromEnumType->getDecl()->isFixed()) { in IsIntegralPromotion()
2497 QualType Underlying = FromEnumType->getDecl()->getIntegerType(); in IsIntegralPromotion()
2502 // We have already pre-calculated the promotion type, so this is trivial. in IsIntegralPromotion()
2503 if (ToType->isIntegerType() && in IsIntegralPromotion()
2504 isCompleteType(From->getBeginLoc(), FromType)) in IsIntegralPromotion()
2506 ToType, FromEnumType->getDecl()->getPromotionType()); in IsIntegralPromotion()
2509 // If the bit-field has an enumerated type, it is treated as any other in IsIntegralPromotion()
2512 // ... so do not fall through into the bit-field checks below in C++. in IsIntegralPromotion()
2526 if (FromType->isAnyCharacterType() && !FromType->isCharType() && in IsIntegralPromotion()
2527 ToType->isIntegerType()) { in IsIntegralPromotion()
2530 bool FromIsSigned = FromType->isSignedIntegerType(); in IsIntegralPromotion()
2544 FromIsSigned == PromoteTypes[Idx]->isSignedIntegerType())) { in IsIntegralPromotion()
2553 // An rvalue for an integral bit-field (9.6) can be converted to an in IsIntegralPromotion()
2555 // bit-field; otherwise, it can be converted to unsigned int if in IsIntegralPromotion()
2556 // unsigned int can represent all the values of the bit-field. If in IsIntegralPromotion()
2557 // the bit-field is larger yet, no integral promotion applies to in IsIntegralPromotion()
2558 // it. If the bit-field has an enumerated type, it is treated as any in IsIntegralPromotion()
2560 // FIXME: We should delay checking of bit-fields until we actually perform the in IsIntegralPromotion()
2563 // FIXME: In C, only bit-fields of types _Bool, int, or unsigned int may be in IsIntegralPromotion()
2564 // promoted, per C11 6.3.1.1/2. We promote all bit-fields (including enum in IsIntegralPromotion()
2565 // bit-fields and those whose underlying type is larger than int) for GCC in IsIntegralPromotion()
2568 if (FieldDecl *MemberDecl = From->getSourceBitField()) { in IsIntegralPromotion()
2570 if (FromType->isIntegralType(Context) && in IsIntegralPromotion()
2572 MemberDecl->getBitWidth()->getIntegerConstantExpr(Context))) { in IsIntegralPromotion()
2573 llvm::APSInt ToSize(BitWidth->getBitWidth(), BitWidth->isUnsigned()); in IsIntegralPromotion()
2578 (FromType->isSignedIntegerType() && *BitWidth <= ToSize)) { in IsIntegralPromotion()
2579 return To->getKind() == BuiltinType::Int; in IsIntegralPromotion()
2584 if (FromType->isUnsignedIntegerType() && *BitWidth <= ToSize) { in IsIntegralPromotion()
2585 return To->getKind() == BuiltinType::UInt; in IsIntegralPromotion()
2595 if (FromType->isBooleanType() && To->getKind() == BuiltinType::Int) { in IsIntegralPromotion()
2601 if (Context.getLangOpts().HLSL && FromType->isIntegerType() && in IsIntegralPromotion()
2602 ToType->isIntegerType()) in IsIntegralPromotion()
2609 if (const BuiltinType *FromBuiltin = FromType->getAs<BuiltinType>()) in IsFloatingPointPromotion()
2610 if (const BuiltinType *ToBuiltin = ToType->getAs<BuiltinType>()) { in IsFloatingPointPromotion()
2613 if (FromBuiltin->getKind() == BuiltinType::Float && in IsFloatingPointPromotion()
2614 ToBuiltin->getKind() == BuiltinType::Double) in IsFloatingPointPromotion()
2621 (FromBuiltin->getKind() == BuiltinType::Float || in IsFloatingPointPromotion()
2622 FromBuiltin->getKind() == BuiltinType::Double) && in IsFloatingPointPromotion()
2623 (ToBuiltin->getKind() == BuiltinType::LongDouble || in IsFloatingPointPromotion()
2624 ToBuiltin->getKind() == BuiltinType::Float128 || in IsFloatingPointPromotion()
2625 ToBuiltin->getKind() == BuiltinType::Ibm128)) in IsFloatingPointPromotion()
2630 if (getLangOpts().HLSL && FromBuiltin->getKind() == BuiltinType::Half && in IsFloatingPointPromotion()
2631 (ToBuiltin->getKind() == BuiltinType::Float || in IsFloatingPointPromotion()
2632 ToBuiltin->getKind() == BuiltinType::Double)) in IsFloatingPointPromotion()
2637 FromBuiltin->getKind() == BuiltinType::Half && in IsFloatingPointPromotion()
2638 ToBuiltin->getKind() == BuiltinType::Float) in IsFloatingPointPromotion()
2646 const ComplexType *FromComplex = FromType->getAs<ComplexType>(); in IsComplexPromotion()
2650 const ComplexType *ToComplex = ToType->getAs<ComplexType>(); in IsComplexPromotion()
2654 return IsFloatingPointPromotion(FromComplex->getElementType(), in IsComplexPromotion()
2655 ToComplex->getElementType()) || in IsComplexPromotion()
2656 IsIntegralPromotion(nullptr, FromComplex->getElementType(), in IsComplexPromotion()
2657 ToComplex->getElementType()); in IsComplexPromotion()
2660 /// BuildSimilarlyQualifiedPointerType - In a pointer conversion from
2663 /// if non-empty, will be a pointer to ToType that may or may not have
2671 assert((FromPtr->getTypeClass() == Type::Pointer || in BuildSimilarlyQualifiedPointerType()
2672 FromPtr->getTypeClass() == Type::ObjCObjectPointer) && in BuildSimilarlyQualifiedPointerType()
2673 "Invalid similarly-qualified pointer type"); in BuildSimilarlyQualifiedPointerType()
2675 /// Conversions to 'id' subsume cv-qualifier conversions. in BuildSimilarlyQualifiedPointerType()
2676 if (ToType->isObjCIdType() || ToType->isObjCQualifiedIdType()) in BuildSimilarlyQualifiedPointerType()
2680 = Context.getCanonicalType(FromPtr->getPointeeType()); in BuildSimilarlyQualifiedPointerType()
2687 // Exact qualifier match -> return the pointer type we're converting to. in BuildSimilarlyQualifiedPointerType()
2712 // Handle value-dependent integral null pointer constants correctly. in isNullPointerConstantForConversion()
2713 // http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_active.html#903 in isNullPointerConstantForConversion()
2714 if (Expr->isValueDependent() && !Expr->isTypeDependent() && in isNullPointerConstantForConversion()
2715 Expr->getType()->isIntegerType() && !Expr->getType()->isEnumeralType()) in isNullPointerConstantForConversion()
2718 return Expr->isNullPointerConstant(Context, in isNullPointerConstantForConversion()
2732 // Conversion from a null pointer constant to any Objective-C pointer type. in IsPointerConversion()
2733 if (ToType->isObjCObjectPointerType() && in IsPointerConversion()
2740 if (FromType->isBlockPointerType() && ToType->isPointerType() && in IsPointerConversion()
2741 ToType->castAs<PointerType>()->getPointeeType()->isVoidType()) { in IsPointerConversion()
2747 if (ToType->isBlockPointerType() && in IsPointerConversion()
2753 // If the left-hand-side is nullptr_t, the right side can be a null in IsPointerConversion()
2755 if (ToType->isNullPtrType() && in IsPointerConversion()
2761 const PointerType* ToTypePtr = ToType->getAs<PointerType>(); in IsPointerConversion()
2772 // , including objective-c pointers. in IsPointerConversion()
2773 QualType ToPointeeType = ToTypePtr->getPointeeType(); in IsPointerConversion()
2774 if (FromType->isObjCObjectPointerType() && ToPointeeType->isVoidType() && in IsPointerConversion()
2777 FromType->castAs<ObjCObjectPointerType>(), ToPointeeType, ToType, in IsPointerConversion()
2781 const PointerType *FromTypePtr = FromType->getAs<PointerType>(); in IsPointerConversion()
2785 QualType FromPointeeType = FromTypePtr->getPointeeType(); in IsPointerConversion()
2795 if (FromPointeeType->isIncompleteOrObjectType() && in IsPointerConversion()
2796 ToPointeeType->isVoidType()) { in IsPointerConversion()
2805 if (getLangOpts().MSVCCompat && FromPointeeType->isFunctionType() && in IsPointerConversion()
2806 ToPointeeType->isVoidType()) { in IsPointerConversion()
2814 // conversion for compatible-but-not-identical pointee types. in IsPointerConversion()
2829 // necessitates this conversion is ill-formed. The result of the in IsPointerConversion()
2830 // conversion is a pointer to the base class sub-object of the in IsPointerConversion()
2836 if (getLangOpts().CPlusPlus && FromPointeeType->isRecordType() && in IsPointerConversion()
2837 ToPointeeType->isRecordType() && in IsPointerConversion()
2839 IsDerivedFrom(From->getBeginLoc(), FromPointeeType, ToPointeeType)) { in IsPointerConversion()
2846 if (FromPointeeType->isVectorType() && ToPointeeType->isVectorType() && in IsPointerConversion()
2882 ToType->getAs<ObjCObjectPointerType>(); in isObjCPointerConversion()
2884 FromType->getAs<ObjCObjectPointerType>(); in isObjCPointerConversion()
2889 if (Context.hasSameUnqualifiedType(ToObjCPtr->getPointeeType(), in isObjCPointerConversion()
2890 FromObjCPtr->getPointeeType())) in isObjCPointerConversion()
2893 // Conversion between Objective-C pointers. in isObjCPointerConversion()
2895 const ObjCInterfaceType* LHS = ToObjCPtr->getInterfaceType(); in isObjCPointerConversion()
2896 const ObjCInterfaceType* RHS = FromObjCPtr->getInterfaceType(); in isObjCPointerConversion()
2898 !ToObjCPtr->getPointeeType().isAtLeastAsQualifiedAs( in isObjCPointerConversion()
2899 FromObjCPtr->getPointeeType())) in isObjCPointerConversion()
2902 ToObjCPtr->getPointeeType(), in isObjCPointerConversion()
2909 // Okay: this is some kind of implicit downcast of Objective-C in isObjCPointerConversion()
2914 ToObjCPtr->getPointeeType(), in isObjCPointerConversion()
2922 if (const PointerType *ToCPtr = ToType->getAs<PointerType>()) in isObjCPointerConversion()
2923 ToPointeeType = ToCPtr->getPointeeType(); in isObjCPointerConversion()
2925 ToType->getAs<BlockPointerType>()) { in isObjCPointerConversion()
2928 if (FromObjCPtr && FromObjCPtr->isObjCBuiltinType()) { in isObjCPointerConversion()
2932 ToPointeeType = ToBlockPtr->getPointeeType(); in isObjCPointerConversion()
2934 else if (FromType->getAs<BlockPointerType>() && in isObjCPointerConversion()
2935 ToObjCPtr && ToObjCPtr->isObjCBuiltinType()) { in isObjCPointerConversion()
2945 if (const PointerType *FromCPtr = FromType->getAs<PointerType>()) in isObjCPointerConversion()
2946 FromPointeeType = FromCPtr->getPointeeType(); in isObjCPointerConversion()
2948 FromType->getAs<BlockPointerType>()) in isObjCPointerConversion()
2949 FromPointeeType = FromBlockPtr->getPointeeType(); in isObjCPointerConversion()
2954 // is an Objective-C conversion. in isObjCPointerConversion()
2955 if (FromPointeeType->isPointerType() && ToPointeeType->isPointerType() && in isObjCPointerConversion()
2964 // Allow conversion of pointee being objective-c pointer to another one; in isObjCPointerConversion()
2966 if (FromPointeeType->getAs<ObjCObjectPointerType>() && in isObjCPointerConversion()
2967 ToPointeeType->getAs<ObjCObjectPointerType>() && in isObjCPointerConversion()
2977 // differences in the argument and result types are in Objective-C in isObjCPointerConversion()
2981 = FromPointeeType->getAs<FunctionProtoType>(); in isObjCPointerConversion()
2983 = ToPointeeType->getAs<FunctionProtoType>(); in isObjCPointerConversion()
2986 // Objective-C pointer conversion. in isObjCPointerConversion()
2993 if (FromFunctionType->getNumParams() != ToFunctionType->getNumParams() || in isObjCPointerConversion()
2994 FromFunctionType->isVariadic() != ToFunctionType->isVariadic() || in isObjCPointerConversion()
2995 FromFunctionType->getMethodQuals() != ToFunctionType->getMethodQuals()) in isObjCPointerConversion()
2999 if (Context.getCanonicalType(FromFunctionType->getReturnType()) == in isObjCPointerConversion()
3000 Context.getCanonicalType(ToFunctionType->getReturnType())) { in isObjCPointerConversion()
3002 } else if (isObjCPointerConversion(FromFunctionType->getReturnType(), in isObjCPointerConversion()
3003 ToFunctionType->getReturnType(), in isObjCPointerConversion()
3005 // Okay, we have an Objective-C pointer conversion. in isObjCPointerConversion()
3013 for (unsigned ArgIdx = 0, NumArgs = FromFunctionType->getNumParams(); in isObjCPointerConversion()
3015 QualType FromArgType = FromFunctionType->getParamType(ArgIdx); in isObjCPointerConversion()
3016 QualType ToArgType = ToFunctionType->getParamType(ArgIdx); in isObjCPointerConversion()
3022 // Okay, we have an Objective-C pointer conversion. in isObjCPointerConversion()
3031 // We had an Objective-C conversion. Allow this pointer in isObjCPointerConversion()
3046 ToType->getAs<BlockPointerType>()) in IsBlockPointerConversion()
3047 ToPointeeType = ToBlockPtr->getPointeeType(); in IsBlockPointerConversion()
3053 FromType->getAs<BlockPointerType>()) in IsBlockPointerConversion()
3054 FromPointeeType = FromBlockPtr->getPointeeType(); in IsBlockPointerConversion()
3058 // differences in the argument and result types are in Objective-C in IsBlockPointerConversion()
3062 = FromPointeeType->getAs<FunctionProtoType>(); in IsBlockPointerConversion()
3064 = ToPointeeType->getAs<FunctionProtoType>(); in IsBlockPointerConversion()
3074 if (FromFunctionType->getNumParams() != ToFunctionType->getNumParams() || in IsBlockPointerConversion()
3075 FromFunctionType->isVariadic() != ToFunctionType->isVariadic()) in IsBlockPointerConversion()
3078 FunctionType::ExtInfo FromEInfo = FromFunctionType->getExtInfo(); in IsBlockPointerConversion()
3079 FunctionType::ExtInfo ToEInfo = ToFunctionType->getExtInfo(); in IsBlockPointerConversion()
3084 if (Context.hasSameType(FromFunctionType->getReturnType(), in IsBlockPointerConversion()
3085 ToFunctionType->getReturnType())) { in IsBlockPointerConversion()
3088 QualType RHS = FromFunctionType->getReturnType(); in IsBlockPointerConversion()
3089 QualType LHS = ToFunctionType->getReturnType(); in IsBlockPointerConversion()
3090 if ((!getLangOpts().CPlusPlus || !RHS->isRecordType()) && in IsBlockPointerConversion()
3100 // Okay, we have an Objective-C pointer conversion. in IsBlockPointerConversion()
3107 for (unsigned ArgIdx = 0, NumArgs = FromFunctionType->getNumParams(); in IsBlockPointerConversion()
3110 QualType FromArgType = FromFunctionType->getParamType(ArgIdx); in IsBlockPointerConversion()
3111 QualType ToArgType = ToFunctionType->getParamType(ArgIdx); in IsBlockPointerConversion()
3118 // Okay, we have an Objective-C pointer conversion. in IsBlockPointerConversion()
3148 if (auto *FPT = FromType->getAs<FunctionProtoType>()) in tryGetFunctionProtoType()
3151 if (auto *MPT = FromType->getAs<MemberPointerType>()) in tryGetFunctionProtoType()
3152 return MPT->getPointeeType()->getAs<FunctionProtoType>(); in tryGetFunctionProtoType()
3166 if (FromType->isMemberPointerType() && ToType->isMemberPointerType()) { in HandleFunctionTypeMismatch()
3167 const auto *FromMember = FromType->castAs<MemberPointerType>(), in HandleFunctionTypeMismatch()
3168 *ToMember = ToType->castAs<MemberPointerType>(); in HandleFunctionTypeMismatch()
3169 if (!Context.hasSameType(FromMember->getClass(), ToMember->getClass())) { in HandleFunctionTypeMismatch()
3170 PDiag << ft_different_class << QualType(ToMember->getClass(), 0) in HandleFunctionTypeMismatch()
3171 << QualType(FromMember->getClass(), 0); in HandleFunctionTypeMismatch()
3174 FromType = FromMember->getPointeeType(); in HandleFunctionTypeMismatch()
3175 ToType = ToMember->getPointeeType(); in HandleFunctionTypeMismatch()
3178 if (FromType->isPointerType()) in HandleFunctionTypeMismatch()
3179 FromType = FromType->getPointeeType(); in HandleFunctionTypeMismatch()
3180 if (ToType->isPointerType()) in HandleFunctionTypeMismatch()
3181 ToType = ToType->getPointeeType(); in HandleFunctionTypeMismatch()
3187 // Don't print extra info for non-specialized template functions. in HandleFunctionTypeMismatch()
3188 if (FromType->isInstantiationDependentType() && in HandleFunctionTypeMismatch()
3189 !FromType->getAs<TemplateSpecializationType>()) { in HandleFunctionTypeMismatch()
3209 if (FromFunction->getNumParams() != ToFunction->getNumParams()) { in HandleFunctionTypeMismatch()
3210 PDiag << ft_parameter_arity << ToFunction->getNumParams() in HandleFunctionTypeMismatch()
3211 << FromFunction->getNumParams(); in HandleFunctionTypeMismatch()
3219 << ToFunction->getParamType(ArgPos) in HandleFunctionTypeMismatch()
3220 << FromFunction->getParamType(ArgPos); in HandleFunctionTypeMismatch()
3225 if (!Context.hasSameType(FromFunction->getReturnType(), in HandleFunctionTypeMismatch()
3226 ToFunction->getReturnType())) { in HandleFunctionTypeMismatch()
3227 PDiag << ft_return_type << ToFunction->getReturnType() in HandleFunctionTypeMismatch()
3228 << FromFunction->getReturnType(); in HandleFunctionTypeMismatch()
3232 if (FromFunction->getMethodQuals() != ToFunction->getMethodQuals()) { in HandleFunctionTypeMismatch()
3233 PDiag << ft_qualifer_mismatch << ToFunction->getMethodQuals() in HandleFunctionTypeMismatch()
3234 << FromFunction->getMethodQuals(); in HandleFunctionTypeMismatch()
3240 if (cast<FunctionProtoType>(FromFunction->getCanonicalTypeUnqualified()) in HandleFunctionTypeMismatch()
3241 ->isNothrow() != in HandleFunctionTypeMismatch()
3242 cast<FunctionProtoType>(ToFunction->getCanonicalTypeUnqualified()) in HandleFunctionTypeMismatch()
3243 ->isNothrow()) { in HandleFunctionTypeMismatch()
3261 size_t J = Reversed ? (llvm::size(New) - Idx - 1) : Idx; in FunctionParamTypesAreEqual()
3268 Context.removePtrSizeAddrSpace((New.begin() + J)->getUnqualifiedType()); in FunctionParamTypesAreEqual()
3282 return FunctionParamTypesAreEqual(OldType->param_types(), in FunctionParamTypesAreEqual()
3283 NewType->param_types(), ArgPos, Reversed); in FunctionParamTypesAreEqual()
3291 if (OldFunction->getNumNonObjectParams() != in FunctionNonObjectParamTypesAreEqual()
3292 NewFunction->getNumNonObjectParams()) in FunctionNonObjectParamTypesAreEqual()
3296 unsigned(OldFunction->hasCXXExplicitFunctionObjectParameter()); in FunctionNonObjectParamTypesAreEqual()
3298 unsigned(NewFunction->hasCXXExplicitFunctionObjectParameter()); in FunctionNonObjectParamTypesAreEqual()
3300 auto *OldPT = cast<FunctionProtoType>(OldFunction->getFunctionType()); in FunctionNonObjectParamTypesAreEqual()
3301 auto *NewPT = cast<FunctionProtoType>(NewFunction->getFunctionType()); in FunctionNonObjectParamTypesAreEqual()
3303 return FunctionParamTypesAreEqual(OldPT->param_types().slice(OldIgnore), in FunctionNonObjectParamTypesAreEqual()
3304 NewPT->param_types().slice(NewIgnore), in FunctionNonObjectParamTypesAreEqual()
3313 QualType FromType = From->getType(); in CheckPointerConversion()
3318 if (Diagnose && !IsCStyleOrFunctionalCast && !FromType->isAnyPointerType() && in CheckPointerConversion()
3319 From->isNullPointerConstant(Context, Expr::NPC_ValueDependentIsNotNull) == in CheckPointerConversion()
3321 if (Context.hasSameUnqualifiedType(From->getType(), Context.BoolTy)) in CheckPointerConversion()
3322 DiagRuntimeBehavior(From->getExprLoc(), From, in CheckPointerConversion()
3324 << ToType << From->getSourceRange()); in CheckPointerConversion()
3326 Diag(From->getExprLoc(), diag::warn_non_literal_null_pointer) in CheckPointerConversion()
3327 << ToType << From->getSourceRange(); in CheckPointerConversion()
3329 if (const PointerType *ToPtrType = ToType->getAs<PointerType>()) { in CheckPointerConversion()
3330 if (const PointerType *FromPtrType = FromType->getAs<PointerType>()) { in CheckPointerConversion()
3331 QualType FromPointeeType = FromPtrType->getPointeeType(), in CheckPointerConversion()
3332 ToPointeeType = ToPtrType->getPointeeType(); in CheckPointerConversion()
3334 if (FromPointeeType->isRecordType() && ToPointeeType->isRecordType() && in CheckPointerConversion()
3336 // We must have a derived-to-base conversion. Check an in CheckPointerConversion()
3346 From->getExprLoc(), From->getSourceRange(), DeclarationName(), in CheckPointerConversion()
3355 FromPointeeType->isFunctionType() && ToPointeeType->isVoidType()) { in CheckPointerConversion()
3358 Diag(From->getExprLoc(), diag::ext_ms_impcast_fn_obj) in CheckPointerConversion()
3359 << From->getSourceRange(); in CheckPointerConversion()
3363 ToType->getAs<ObjCObjectPointerType>()) { in CheckPointerConversion()
3365 FromType->getAs<ObjCObjectPointerType>()) { in CheckPointerConversion()
3366 // Objective-C++ conversions are always okay. in CheckPointerConversion()
3368 // Objective-C++ implicit conversions. in CheckPointerConversion()
3369 if (FromPtrType->isObjCBuiltinType() || ToPtrType->isObjCBuiltinType()) in CheckPointerConversion()
3371 } else if (FromType->isBlockPointerType()) { in CheckPointerConversion()
3376 } else if (ToType->isBlockPointerType()) { in CheckPointerConversion()
3377 if (!FromType->isBlockPointerType()) in CheckPointerConversion()
3383 if (From->isNullPointerConstant(Context, Expr::NPC_ValueDependentIsNull)) in CheckPointerConversion()
3393 const MemberPointerType *ToTypePtr = ToType->getAs<MemberPointerType>(); in IsMemberPointerConversion()
3398 if (From->isNullPointerConstant(Context, in IsMemberPointerConversion()
3406 const MemberPointerType *FromTypePtr = FromType->getAs<MemberPointerType>(); in IsMemberPointerConversion()
3412 QualType FromClass(FromTypePtr->getClass(), 0); in IsMemberPointerConversion()
3413 QualType ToClass(ToTypePtr->getClass(), 0); in IsMemberPointerConversion()
3416 IsDerivedFrom(From->getBeginLoc(), ToClass, FromClass)) { in IsMemberPointerConversion()
3417 ConvertedType = Context.getMemberPointerType(FromTypePtr->getPointeeType(), in IsMemberPointerConversion()
3429 QualType FromType = From->getType(); in CheckMemberPointerConversion()
3430 const MemberPointerType *FromPtrType = FromType->getAs<MemberPointerType>(); in CheckMemberPointerConversion()
3433 assert(From->isNullPointerConstant(Context, in CheckMemberPointerConversion()
3440 const MemberPointerType *ToPtrType = ToType->getAs<MemberPointerType>(); in CheckMemberPointerConversion()
3444 QualType FromClass = QualType(FromPtrType->getClass(), 0); in CheckMemberPointerConversion()
3445 QualType ToClass = QualType(ToPtrType->getClass(), 0); in CheckMemberPointerConversion()
3448 assert(FromClass->isRecordType() && "Pointer into non-class."); in CheckMemberPointerConversion()
3449 assert(ToClass->isRecordType() && "Pointer into non-class."); in CheckMemberPointerConversion()
3454 IsDerivedFrom(From->getBeginLoc(), ToClass, FromClass, Paths); in CheckMemberPointerConversion()
3462 Diag(From->getExprLoc(), diag::err_ambiguous_memptr_conv) in CheckMemberPointerConversion()
3463 << 0 << FromClass << ToClass << PathDisplayStr << From->getSourceRange(); in CheckMemberPointerConversion()
3468 Diag(From->getExprLoc(), diag::err_memptr_conv_via_virtual) in CheckMemberPointerConversion()
3470 << From->getSourceRange(); in CheckMemberPointerConversion()
3475 CheckBaseClassAccess(From->getExprLoc(), FromClass, ToClass, in CheckMemberPointerConversion()
3502 /// outer layer is const-qualified.
3513 // Objective-C ARC: in isQualificationConversionStep()
3514 // Check Objective-C lifetime conversions. in isQualificationConversionStep()
3523 // Objective-C lifetime qualifiers. in isQualificationConversionStep()
3535 // -- for every j > 0, if const is in cv 1,j then const is in cv in isQualificationConversionStep()
3536 // 2,j, and similarly for volatile. in isQualificationConversionStep()
3541 // - in top level it is only valid to convert to addr space that is a in isQualificationConversionStep()
3542 // superset in all cases apart from C-style casts where we allow in isQualificationConversionStep()
3544 // - in non-top levels it is not a valid conversion. in isQualificationConversionStep()
3551 // -- if the cv 1,j and cv 2,j are different, then const is in in isQualificationConversionStep()
3559 // -- if [...] P1,i [...] is "array of unknown bound of", P3,i is in isQualificationConversionStep()
3561 if (FromType->isIncompleteArrayType() && !ToType->isIncompleteArrayType()) in isQualificationConversionStep()
3564 // -- if the resulting P3,i is different from P1,i [...], then const is in isQualificationConversionStep()
3566 if (!CStyle && FromType->isConstantArrayType() && in isQualificationConversionStep()
3567 ToType->isIncompleteArrayType() && !PreviousToQualsIncludeConst) in isQualificationConversionStep()
3570 // Keep track of whether all prior cv-qualifiers in the "to" type in isQualificationConversionStep()
3590 // A conversion can add cv-qualifiers at levels other than the first in IsQualificationConversion()
3591 // in multi-level pointers, subject to the following rules: [...] in IsQualificationConversion()
3610 /// - Determine whether this is a conversion from a scalar type to an
3619 const AtomicType *ToAtomic = ToType->getAs<AtomicType>(); in tryAtomicConversion()
3624 if (!IsStandardConversion(S, From, ToAtomic->getValueType(), in tryAtomicConversion()
3634 SCS.setToType(2, InnerSCS.getToType(2)); in tryAtomicConversion()
3641 const auto *CtorType = Constructor->getType()->castAs<FunctionProtoType>(); in isFirstArgumentCompatibleWithType()
3642 if (CtorType->getNumParams() > 0) { in isFirstArgumentCompatibleWithType()
3643 QualType FirstArg = CtorType->getParamType(0); in isFirstArgumentCompatibleWithType()
3662 bool Usable = !Info.Constructor->isInvalidDecl() && in IsInitializerListConstructorConversion()
3683 CandidateSet.BestViableFunction(S, From->getBeginLoc(), Best)) { in IsInitializerListConstructorConversion()
3687 CXXConstructorDecl *Constructor = cast<CXXConstructorDecl>(Best->Function); in IsInitializerListConstructorConversion()
3688 QualType ThisType = Constructor->getFunctionObjectParameterType(); in IsInitializerListConstructorConversion()
3693 User.FoundConversionFunction = Best->FoundDecl; in IsInitializerListConstructorConversion()
3709 /// Determines whether there is a user-defined conversion sequence
3712 /// user-defined conversion sequence that performs such a conversion
3717 /// "explicit" conversion functions as well as non-explicit conversion
3721 /// allow an extra Objective-C pointer conversion on uses of explicit
3738 if (const RecordType *ToRecordType = ToType->getAs<RecordType>()) { in IsUserDefinedConversion()
3740 // When objects of class type are direct-initialized (8.5), or in IsUserDefinedConversion()
3741 // copy-initialized from an expression of the same or a in IsUserDefinedConversion()
3743 // constructor. [...] For copy-initialization, the candidate in IsUserDefinedConversion()
3745 // that class. The argument list is the expression-list within in IsUserDefinedConversion()
3747 if (S.Context.hasSameUnqualifiedType(ToType, From->getType()) || in IsUserDefinedConversion()
3748 (From->getType()->getAs<RecordType>() && in IsUserDefinedConversion()
3749 S.IsDerivedFrom(From->getBeginLoc(), From->getType(), ToType))) in IsUserDefinedConversion()
3752 if (!S.isCompleteType(From->getExprLoc(), ToType)) { in IsUserDefinedConversion()
3755 = dyn_cast<CXXRecordDecl>(ToRecordType->getDecl())) { in IsUserDefinedConversion()
3761 // But first, see if there is an init-list-constructor that will work. in IsUserDefinedConversion()
3771 // If we're list-initializing, we pass the individual elements as in IsUserDefinedConversion()
3773 Args = InitList->getInits(); in IsUserDefinedConversion()
3774 NumArgs = InitList->getNumInits(); in IsUserDefinedConversion()
3783 bool Usable = !Info.Constructor->isInvalidDecl(); in IsUserDefinedConversion()
3785 Usable = Usable && Info.Constructor->isConvertingConstructor( in IsUserDefinedConversion()
3794 // conversion is to X or reference to cv X, user-defined conversion in IsUserDefinedConversion()
3810 // Allow one user-defined conversion when user specifies a in IsUserDefinedConversion()
3811 // From->ToType conversion via an static cast (c-style, etc). in IsUserDefinedConversion()
3824 } else if (!S.isCompleteType(From->getBeginLoc(), From->getType())) { in IsUserDefinedConversion()
3827 From->getType()->getAs<RecordType>()) { in IsUserDefinedConversion()
3829 = dyn_cast<CXXRecordDecl>(FromRecordType->getDecl())) { in IsUserDefinedConversion()
3831 const auto &Conversions = FromRecordDecl->getVisibleConversionFunctions(); in IsUserDefinedConversion()
3835 CXXRecordDecl *ActingContext = cast<CXXRecordDecl>(D->getDeclContext()); in IsUserDefinedConversion()
3837 D = cast<UsingShadowDecl>(D)->getTargetDecl(); in IsUserDefinedConversion()
3842 Conv = cast<CXXConversionDecl>(ConvTemplate->getTemplatedDecl()); in IsUserDefinedConversion()
3863 CandidateSet.BestViableFunction(S, From->getBeginLoc(), Best)) { in IsUserDefinedConversion()
3868 = dyn_cast<CXXConstructorDecl>(Best->Function)) { in IsUserDefinedConversion()
3870 // If the user-defined conversion is specified by a in IsUserDefinedConversion()
3879 if (Best->Conversions[0].isEllipsis()) in IsUserDefinedConversion()
3882 User.Before = Best->Conversions[0].Standard; in IsUserDefinedConversion()
3888 User.FoundConversionFunction = Best->FoundDecl; in IsUserDefinedConversion()
3890 User.After.setFromType(Constructor->getFunctionObjectParameterType()); in IsUserDefinedConversion()
3895 = dyn_cast<CXXConversionDecl>(Best->Function)) { in IsUserDefinedConversion()
3898 // [...] If the user-defined conversion is specified by a in IsUserDefinedConversion()
3899 // conversion function (12.3.2), the initial standard in IsUserDefinedConversion()
3902 User.Before = Best->Conversions[0].Standard; in IsUserDefinedConversion()
3905 User.FoundConversionFunction = Best->FoundDecl; in IsUserDefinedConversion()
3910 // result of the user-defined conversion to the target type in IsUserDefinedConversion()
3913 // initialization by user-defined conversion apply when in IsUserDefinedConversion()
3914 // selecting the best user-defined conversion for a in IsUserDefinedConversion()
3915 // user-defined conversion sequence (see 13.3.3 and in IsUserDefinedConversion()
3917 User.After = Best->FinalConversion; in IsUserDefinedConversion()
3935 OverloadCandidateSet CandidateSet(From->getExprLoc(), in DiagnoseMultipleUserDefinedConversion()
3950 Diag(From->getBeginLoc(), diag::err_typecheck_ambiguous_condition) in DiagnoseMultipleUserDefinedConversion()
3951 << From->getType() << ToType << From->getSourceRange(); in DiagnoseMultipleUserDefinedConversion()
3953 if (!RequireCompleteType(From->getBeginLoc(), ToType, in DiagnoseMultipleUserDefinedConversion()
3955 From->getType(), From->getSourceRange())) in DiagnoseMultipleUserDefinedConversion()
3956 Diag(From->getBeginLoc(), diag::err_typecheck_nonviable_condition) in DiagnoseMultipleUserDefinedConversion()
3957 << false << From->getType() << From->getSourceRange() << ToType; in DiagnoseMultipleUserDefinedConversion()
3966 // conversion-operator return value 'points' to, or nullptr.
3969 const FunctionType *ConvFuncTy = Conv->getType()->castAs<FunctionType>(); in getConversionOpReturnTyAsFunction()
3971 ConvFuncTy->getReturnType()->getAs<PointerType>(); in getConversionOpReturnTyAsFunction()
3976 return RetPtrTy->getPointeeType()->getAs<FunctionType>(); in getConversionOpReturnTyAsFunction()
3979 /// Compare the user-defined conversion functions or constructors
3980 /// of two user-defined conversion sequences to determine whether any ordering
3990 if (!Conv1->getParent()->isLambda() || !Conv2->getParent()->isLambda()) in compareConversionFunctions()
3993 // Objective-C++: in compareConversionFunctions()
3994 // If both conversion functions are implicitly-declared conversions from in compareConversionFunctions()
4000 bool Block1 = Conv1->getConversionType()->isBlockPointerType(); in compareConversionFunctions()
4001 bool Block2 = Conv2->getConversionType()->isBlockPointerType(); in compareConversionFunctions()
4009 // different), prefer the 'free' mechanism, followed by the calling-convention in compareConversionFunctions()
4010 // of operator(). The latter is in place to support the MSVC-like solution of in compareConversionFunctions()
4011 // defining ALL of the possible conversions in regards to calling-convention. in compareConversionFunctions()
4016 Conv1FuncRet->getCallConv() != Conv2FuncRet->getCallConv()) { in compareConversionFunctions()
4017 CallingConv Conv1CC = Conv1FuncRet->getCallConv(); in compareConversionFunctions()
4018 CallingConv Conv2CC = Conv2FuncRet->getCallConv(); in compareConversionFunctions()
4020 CXXMethodDecl *CallOp = Conv2->getParent()->getLambdaCallOperator(); in compareConversionFunctions()
4021 const auto *CallOpProto = CallOp->getType()->castAs<FunctionProtoType>(); in compareConversionFunctions()
4024 CallOp->getType()->castAs<FunctionType>()->getCallConv(); in compareConversionFunctions()
4026 CallOpProto->isVariadic(), /*IsCXXMethod=*/false); in compareConversionFunctions()
4028 CallOpProto->isVariadic(), /*IsCXXMethod=*/true); in compareConversionFunctions()
4049 /// CompareImplicitConversionSequences - Compare two implicit
4059 // -- a standard conversion sequence (13.3.3.1.1) is a better in CompareImplicitConversionSequences()
4060 // conversion sequence than a user-defined conversion sequence or in CompareImplicitConversionSequences()
4062 // -- a user-defined conversion sequence (13.3.3.1.2) is a better in CompareImplicitConversionSequences()
4069 // treated as a user-defined sequence that is indistinguishable in CompareImplicitConversionSequences()
4070 // from any other user-defined conversion sequence. in CompareImplicitConversionSequences()
4079 // void f(char*); // #2 in CompareImplicitConversionSequences()
4082 // In C++03, we pick #2 as the best viable function. in CompareImplicitConversionSequences()
4084 // conversion is better than string-literal to char* conversion (since there in CompareImplicitConversionSequences()
4086 // convert arguments, #2 would be the best viable function in C++11. in CompareImplicitConversionSequences()
4093 // Ill-formedness must not differ in CompareImplicitConversionSequences()
4116 // List-initialization sequence L1 is a better conversion sequence than in CompareImplicitConversionSequences()
4117 // list-initialization sequence L2 if: in CompareImplicitConversionSequences()
4118 // - L1 converts to std::initializer_list<X> for some X and L2 does not, or, in CompareImplicitConversionSequences()
4143 if (S.Context.hasSameUnqualifiedType(CAT1->getElementType(), in CompareImplicitConversionSequences()
4144 CAT2->getElementType())) { in CompareImplicitConversionSequences()
4146 if (CAT1->getSize() != CAT2->getSize()) in CompareImplicitConversionSequences()
4148 return CAT1->getSize().ult(CAT2->getSize()) in CompareImplicitConversionSequences()
4167 // User-defined conversion sequence U1 is a better conversion in CompareImplicitConversionSequences()
4168 // sequence than another user-defined conversion sequence U2 if in CompareImplicitConversionSequences()
4169 // they contain the same user-defined conversion function or in CompareImplicitConversionSequences()
4197 // any non-identity conversion sequence in compareStandardConversionSubsets()
4214 return Context.hasSameType(SCS1.getToType(2), SCS2.getToType(2))? Result in compareStandardConversionSubsets()
4237 // -- S1 and S2 are reference bindings (8.5.3) and neither refers to an in isBetterReferenceBindingKind()
4238 // implicit object parameter of a non-static member function declared in isBetterReferenceBindingKind()
4239 // without a ref-qualifier, and *either* S1 binds an rvalue reference in isBetterReferenceBindingKind()
4273 if (!FromType->isEnumeralType()) in getFixedEnumPromtion()
4276 EnumDecl *Enum = FromType->castAs<EnumType>()->getDecl(); in getFixedEnumPromtion()
4277 if (!Enum->isFixed()) in getFixedEnumPromtion()
4280 QualType UnderlyingType = Enum->getIntegerType(); in getFixedEnumPromtion()
4287 /// CompareStandardConversionSequences - Compare two standard
4298 // -- S1 is a proper subsequence of S2 (comparing the conversion in CompareStandardConversionSequences()
4302 // non-identity conversion sequence) or, if not that, in CompareStandardConversionSequences()
4307 // -- the rank of S1 is better than the rank of S2 (by the rules in CompareStandardConversionSequences()
4359 // their derived-to-base conversions. in CompareStandardConversionSequences()
4371 // Adjust the types we're converting from via the array-to-pointer in CompareStandardConversionSequences()
4378 QualType FromPointee1 = FromType1->getPointeeType().getUnqualifiedType(); in CompareStandardConversionSequences()
4379 QualType FromPointee2 = FromType2->getPointeeType().getUnqualifiedType(); in CompareStandardConversionSequences()
4386 // Objective-C++: If one interface is more specific than the in CompareStandardConversionSequences()
4389 = FromType1->getAs<ObjCObjectPointerType>(); in CompareStandardConversionSequences()
4391 = FromType2->getAs<ObjCObjectPointerType>(); in CompareStandardConversionSequences()
4420 // -- S1 and S2 are reference bindings (8.5.3), and the types to in CompareStandardConversionSequences()
4422 // top-level cv-qualifiers, and the type to which the reference in CompareStandardConversionSequences()
4423 // initialized by S2 refers is more cv-qualified than the type in CompareStandardConversionSequences()
4425 QualType T1 = SCS1.getToType(2); in CompareStandardConversionSequences()
4426 QualType T2 = SCS2.getToType(2); in CompareStandardConversionSequences()
4433 // Objective-C++ ARC: If the references refer to objects with different in CompareStandardConversionSequences()
4456 // floating-to-integral conversion if the integral conversion in CompareStandardConversionSequences()
4472 S.Context.getTypeSize(SCS1.getToType(2))) in CompareStandardConversionSequences()
4490 SCS1.getFromType(), SCS1.getToType(2)); in CompareStandardConversionSequences()
4492 SCS2.getFromType(), SCS2.getToType(2)); in CompareStandardConversionSequences()
4503 S.Context.areCompatibleSveTypes(SCS1.getFromType(), SCS1.getToType(2)); in CompareStandardConversionSequences()
4505 S.Context.areCompatibleSveTypes(SCS2.getFromType(), SCS2.getToType(2)); in CompareStandardConversionSequences()
4517 S.Context.areCompatibleRVVTypes(SCS1.getFromType(), SCS1.getToType(2)); in CompareStandardConversionSequences()
4519 S.Context.areCompatibleRVVTypes(SCS2.getFromType(), SCS2.getToType(2)); in CompareStandardConversionSequences()
4530 /// CompareQualificationConversions - Compares two standard conversion
4538 // -- S1 and S2 differ only in their qualification conversion and in CompareQualificationConversions()
4541 // [...] and the cv-qualification signature of type T1 is a proper subset in CompareQualificationConversions()
4542 // of the cv-qualification signature of type T2, and S1 is not the in CompareQualificationConversions()
4543 // deprecated string literal array-to-pointer conversion (4.2). in CompareQualificationConversions()
4544 // [C++2a] in CompareQualificationConversions()
4552 QualType T1 = SCS1.getToType(2); in CompareQualificationConversions()
4553 QualType T2 = SCS2.getToType(2); in CompareQualificationConversions()
4556 assert(!T1->isReferenceType() && !T2->isReferenceType()); in CompareQualificationConversions()
4571 // Objective-C++ ARC: in CompareQualificationConversions()
4585 // FIXME: In Objective-C ARC, we can have qualification conversions in both in CompareQualificationConversions()
4586 // directions, so we can't short-cut this second check in general. in CompareQualificationConversions()
4597 /// CompareDerivedToBaseConversions - Compares two standard conversion
4599 /// various kinds of derived-to-base conversions (C++
4601 /// conversions between Objective-C interface types.
4611 // Adjust the types we're converting from via the array-to-pointer in CompareDerivedToBaseConversions()
4632 /*FIXME: Remove if Objective-C id conversions get their own rank*/ in CompareDerivedToBaseConversions()
4633 FromType1->isPointerType() && FromType2->isPointerType() && in CompareDerivedToBaseConversions()
4634 ToType1->isPointerType() && ToType2->isPointerType()) { in CompareDerivedToBaseConversions()
4636 FromType1->castAs<PointerType>()->getPointeeType().getUnqualifiedType(); in CompareDerivedToBaseConversions()
4638 ToType1->castAs<PointerType>()->getPointeeType().getUnqualifiedType(); in CompareDerivedToBaseConversions()
4640 FromType2->castAs<PointerType>()->getPointeeType().getUnqualifiedType(); in CompareDerivedToBaseConversions()
4642 ToType2->castAs<PointerType>()->getPointeeType().getUnqualifiedType(); in CompareDerivedToBaseConversions()
4644 // -- conversion of C* to B* is better than conversion of C* to A*, in CompareDerivedToBaseConversions()
4652 // -- conversion of B* to A* is better than conversion of C* to A*, in CompareDerivedToBaseConversions()
4662 = FromType1->getAs<ObjCObjectPointerType>(); in CompareDerivedToBaseConversions()
4664 = FromType2->getAs<ObjCObjectPointerType>(); in CompareDerivedToBaseConversions()
4666 = ToType1->getAs<ObjCObjectPointerType>(); in CompareDerivedToBaseConversions()
4668 = ToType2->getAs<ObjCObjectPointerType>(); in CompareDerivedToBaseConversions()
4671 // Apply the same conversion ranking rules for Objective-C pointer types in CompareDerivedToBaseConversions()
4673 // Objective-C pseudo-subtyping relationship used for assignment of in CompareDerivedToBaseConversions()
4674 // Objective-C pointer types. in CompareDerivedToBaseConversions()
4684 // A conversion to an a non-id object pointer type or qualified 'id' in CompareDerivedToBaseConversions()
4686 if (ToPtr1->isObjCIdType() && in CompareDerivedToBaseConversions()
4687 (ToPtr2->isObjCQualifiedIdType() || ToPtr2->getInterfaceDecl())) in CompareDerivedToBaseConversions()
4689 if (ToPtr2->isObjCIdType() && in CompareDerivedToBaseConversions()
4690 (ToPtr1->isObjCQualifiedIdType() || ToPtr1->getInterfaceDecl())) in CompareDerivedToBaseConversions()
4693 // A conversion to a non-id object pointer type is better than a in CompareDerivedToBaseConversions()
4695 if (ToPtr1->isObjCQualifiedIdType() && ToPtr2->getInterfaceDecl()) in CompareDerivedToBaseConversions()
4697 if (ToPtr2->isObjCQualifiedIdType() && ToPtr1->getInterfaceDecl()) in CompareDerivedToBaseConversions()
4700 // A conversion to an a non-Class object pointer type or qualified 'Class' in CompareDerivedToBaseConversions()
4702 if (ToPtr1->isObjCClassType() && in CompareDerivedToBaseConversions()
4703 (ToPtr2->isObjCQualifiedClassType() || ToPtr2->getInterfaceDecl())) in CompareDerivedToBaseConversions()
4705 if (ToPtr2->isObjCClassType() && in CompareDerivedToBaseConversions()
4706 (ToPtr1->isObjCQualifiedClassType() || ToPtr1->getInterfaceDecl())) in CompareDerivedToBaseConversions()
4709 // A conversion to a non-Class object pointer type is better than a in CompareDerivedToBaseConversions()
4711 if (ToPtr1->isObjCQualifiedClassType() && ToPtr2->getInterfaceDecl()) in CompareDerivedToBaseConversions()
4713 if (ToPtr2->isObjCQualifiedClassType() && ToPtr1->getInterfaceDecl()) in CompareDerivedToBaseConversions()
4716 // -- "conversion of C* to B* is better than conversion of C* to A*," in CompareDerivedToBaseConversions()
4718 !FromPtr1->isObjCIdType() && !FromPtr1->isObjCClassType() && in CompareDerivedToBaseConversions()
4720 if (FromPtr1->isSpecialized()) { in CompareDerivedToBaseConversions()
4724 FromPtr1->getInterfaceDecl() == ToPtr1->getInterfaceDecl(); in CompareDerivedToBaseConversions()
4726 FromPtr1->getInterfaceDecl() == ToPtr2->getInterfaceDecl(); in CompareDerivedToBaseConversions()
4737 // -- "conversion of B* to A* is better than conversion of C* to A*," in CompareDerivedToBaseConversions()
4745 // Ranking of member-pointer types. in CompareDerivedToBaseConversions()
4747 FromType1->isMemberPointerType() && FromType2->isMemberPointerType() && in CompareDerivedToBaseConversions()
4748 ToType1->isMemberPointerType() && ToType2->isMemberPointerType()) { in CompareDerivedToBaseConversions()
4749 const auto *FromMemPointer1 = FromType1->castAs<MemberPointerType>(); in CompareDerivedToBaseConversions()
4750 const auto *ToMemPointer1 = ToType1->castAs<MemberPointerType>(); in CompareDerivedToBaseConversions()
4751 const auto *FromMemPointer2 = FromType2->castAs<MemberPointerType>(); in CompareDerivedToBaseConversions()
4752 const auto *ToMemPointer2 = ToType2->castAs<MemberPointerType>(); in CompareDerivedToBaseConversions()
4753 const Type *FromPointeeType1 = FromMemPointer1->getClass(); in CompareDerivedToBaseConversions()
4754 const Type *ToPointeeType1 = ToMemPointer1->getClass(); in CompareDerivedToBaseConversions()
4755 const Type *FromPointeeType2 = FromMemPointer2->getClass(); in CompareDerivedToBaseConversions()
4756 const Type *ToPointeeType2 = ToMemPointer2->getClass(); in CompareDerivedToBaseConversions()
4778 // -- conversion of C to B is better than conversion of C to A, in CompareDerivedToBaseConversions()
4779 // -- binding of an expression of type C to a reference of type in CompareDerivedToBaseConversions()
4790 // -- conversion of B to A is better than conversion of C to A. in CompareDerivedToBaseConversions()
4791 // -- binding of an expression of type B to a reference of type in CompareDerivedToBaseConversions()
4820 assert(!OrigT1->isReferenceType() && in CompareReferenceRelationship()
4822 assert(!OrigT2->isReferenceType() && "T2 cannot be a reference type"); in CompareReferenceRelationship()
4834 // C++2a [dcl.init.ref]p4: in CompareReferenceRelationship()
4836 // reference-related to "cv2 T2" if T1 is similar to T2, or in CompareReferenceRelationship()
4838 // "cv1 T1" is reference-compatible with "cv2 T2" if in CompareReferenceRelationship()
4842 // Check for standard conversions we can apply to pointers: derived-to-base in CompareReferenceRelationship()
4851 else if (UnqualT1->isObjCObjectOrInterfaceType() && in CompareReferenceRelationship()
4852 UnqualT2->isObjCObjectOrInterfaceType() && in CompareReferenceRelationship()
4855 else if (UnqualT2->isFunctionType() && in CompareReferenceRelationship()
4884 // If we find a qualifier mismatch, the types are not reference-compatible, in CompareReferenceRelationship()
4885 // but are still be reference-related if they're similar. in CompareReferenceRelationship()
4901 // At this point, if the types are reference-related, we must either have the in CompareReferenceRelationship()
4909 /// Look for a user-defined conversion to a value reference-compatible
4916 assert(T2->isRecordType() && "Can only find conversions of record types."); in FindConversionForRefInit()
4917 auto *T2RecordDecl = cast<CXXRecordDecl>(T2->castAs<RecordType>()->getDecl()); in FindConversionForRefInit()
4921 const auto &Conversions = T2RecordDecl->getVisibleConversionFunctions(); in FindConversionForRefInit()
4924 CXXRecordDecl *ActingDC = cast<CXXRecordDecl>(D->getDeclContext()); in FindConversionForRefInit()
4926 D = cast<UsingShadowDecl>(D)->getTargetDecl(); in FindConversionForRefInit()
4932 Conv = cast<CXXConversionDecl>(ConvTemplate->getTemplatedDecl()); in FindConversionForRefInit()
4939 if (!ConvTemplate && DeclType->isRValueReferenceType()) { in FindConversionForRefInit()
4941 = Conv->getConversionType()->getAs<LValueReferenceType>(); in FindConversionForRefInit()
4942 if (RefType && !RefType->getPointeeType()->isFunctionType()) in FindConversionForRefInit()
4949 Conv->getConversionType() in FindConversionForRefInit()
4961 Conv->getConversionType()->getAs<ReferenceType>(); in FindConversionForRefInit()
4963 (!RefType->isLValueReferenceType() && in FindConversionForRefInit()
4964 !RefType->getPointeeType()->isFunctionType())) in FindConversionForRefInit()
4988 // user-defined conversion sequence (13.3.3.1.2), with the in FindConversionForRefInit()
4992 // type, a derived-to-base Conversion. in FindConversionForRefInit()
4993 if (!Best->FinalConversion.DirectBinding) in FindConversionForRefInit()
4997 ICS.UserDefined.Before = Best->Conversions[0].Standard; in FindConversionForRefInit()
4998 ICS.UserDefined.After = Best->FinalConversion; in FindConversionForRefInit()
5000 ICS.UserDefined.ConversionFunction = Best->Function; in FindConversionForRefInit()
5001 ICS.UserDefined.FoundConversionFunction = Best->FoundDecl; in FindConversionForRefInit()
5012 if (Cand->Best) in FindConversionForRefInit()
5013 ICS.Ambiguous.addConversion(Cand->FoundDecl, Cand->Function); in FindConversionForRefInit()
5033 assert(DeclType->isReferenceType() && "Reference init needs a reference"); in TryReferenceInit()
5039 QualType T1 = DeclType->castAs<ReferenceType>()->getPointeeType(); in TryReferenceInit()
5040 QualType T2 = Init->getType(); in TryReferenceInit()
5049 T2 = Fn->getType(); in TryReferenceInit()
5053 bool isRValRef = DeclType->isRValueReferenceType(); in TryReferenceInit()
5054 Expr::Classification InitCategory = Init->Classify(S.Context); in TryReferenceInit()
5064 // consider that when ordering reference-to-function bindings. in TryReferenceInit()
5072 // a reference binding that performs a non-top-level qualification in TryReferenceInit()
5081 ICS.Standard.setToType(2, T1); in TryReferenceInit()
5085 ICS.Standard.BindsToFunctionLvalue = T2->isFunctionType(); in TryReferenceInit()
5098 // -- If reference is an lvalue reference and the initializer expression in TryReferenceInit()
5100 // -- is an lvalue (but is not a bit-field), and "cv1 T1" is in TryReferenceInit()
5101 // reference-compatible with "cv2 T2," or in TryReferenceInit()
5103 // Per C++ [over.ics.ref]p4, we don't check the bit-field property here. in TryReferenceInit()
5111 // derived-to-base Conversion (13.3.3.1). in TryReferenceInit()
5115 // derived-to-base conversions is suppressed when we're in TryReferenceInit()
5121 // -- has a class type (i.e., T2 is a class type), where T1 is in TryReferenceInit()
5122 // not reference-related to T2, and can be implicitly in TryReferenceInit()
5124 // is reference-compatible with "cv3 T3" 92) (this in TryReferenceInit()
5128 if (!SuppressUserConversions && T2->isRecordType() && in TryReferenceInit()
5138 // -- Otherwise, the reference shall be an lvalue reference to a in TryReferenceInit()
5139 // non-volatile const type (i.e., cv1 shall be const), or the reference in TryReferenceInit()
5147 // -- If the initializer expression in TryReferenceInit()
5149 // -- is an xvalue, class prvalue, array prvalue or function in TryReferenceInit()
5150 // lvalue and "cv1 T1" is reference-compatible with "cv2 T2", or in TryReferenceInit()
5154 (T2->isRecordType() || T2->isArrayType())) || in TryReferenceInit()
5155 (InitCategory.isLValue() && T2->isFunctionType()))) { in TryReferenceInit()
5162 !(InitCategory.isPRValue() || T2->isRecordType())); in TryReferenceInit()
5166 // -- has a class type (i.e., T2 is a class type), where T1 is not in TryReferenceInit()
5167 // reference-related to T2, and can be implicitly converted to in TryReferenceInit()
5169 // "cv3 T3", where "cv1 T1" is reference-compatible with in TryReferenceInit()
5177 T2->isRecordType() && S.isCompleteType(DeclLoc, T2) && in TryReferenceInit()
5183 // user-defined conversion sequence includes an lvalue-to-rvalue in TryReferenceInit()
5184 // conversion, the program is ill-formed. in TryReferenceInit()
5193 if (T1->isFunctionType()) in TryReferenceInit()
5196 // -- Otherwise, a temporary of type "cv1 T1" is created and in TryReferenceInit()
5198 // rules for a non-reference copy initialization (8.5). The in TryReferenceInit()
5200 // reference-related to T2, cv1 must be the same in TryReferenceInit()
5201 // cv-qualification as, or greater cv-qualification than, in TryReferenceInit()
5202 // cv2; otherwise, the program is ill-formed. in TryReferenceInit()
5204 // If cv1 == cv2 or cv1 is a greater cv-qualified than cv2, then in TryReferenceInit()
5205 // we would be reference-compatible or reference-compatible with in TryReferenceInit()
5209 // Note that we only want to check address spaces and cvr-qualifiers here. in TryReferenceInit()
5230 (T1->isRecordType() || T2->isRecordType())) in TryReferenceInit()
5233 // If T1 is reference-related to T2 and the reference is an rvalue in TryReferenceInit()
5236 Init->Classify(S.Context).isLValue()) { in TryReferenceInit()
5247 // to copy-initializing a temporary of the underlying type with in TryReferenceInit()
5248 // the argument expression. Any difference in top-level in TryReferenceInit()
5249 // cv-qualification is subsumed by the initialization itself in TryReferenceInit()
5268 ICS.UserDefined.ConversionFunction->getReturnType() in TryReferenceInit()
5269 ->getAs<LValueReferenceType>(); in TryReferenceInit()
5300 /// TryListConversion - Try to copy-initialize a value of type ToType from the
5321 InitTy = IAT->getElementType(); in TryListConversion()
5322 if (!S.isCompleteType(From->getBeginLoc(), InitTy)) in TryListConversion()
5325 // C++20 [over.ics.list]/2: in TryListConversion()
5326 // If the initializer list is a designated-initializer-list, a conversion in TryListConversion()
5332 bool IsDesignatedInit = From->hasDesignatedInit(); in TryListConversion()
5333 if (!ToType->isAggregateType() && !ToType->isReferenceType() && in TryListConversion()
5345 // appropriately-typed string literal (8.5.2 [dcl.init.string]), the in TryListConversion()
5347 if (From->getNumInits() == 1 && !IsDesignatedInit) { in TryListConversion()
5348 if (ToType->isRecordType()) { in TryListConversion()
5349 QualType InitType = From->getInit(0)->getType(); in TryListConversion()
5351 S.IsDerivedFrom(From->getBeginLoc(), InitType, ToType)) in TryListConversion()
5352 return TryCopyInitialization(S, From->getInit(0), ToType, in TryListConversion()
5358 if (AT && S.IsStringInit(From->getInit(0), AT)) { in TryListConversion()
5382 // default-constructible, and if all the elements of the initializer list in TryListConversion()
5386 unsigned e = From->getNumInits(); in TryListConversion()
5393 InitTy = AT->getElementType(); in TryListConversion()
5395 if (CT->getSize().ult(e)) { in TryListConversion()
5402 if (CT->getSize().ugt(e)) { in TryListConversion()
5404 InitListExpr EmptyList(S.Context, From->getEndLoc(), std::nullopt, in TryListConversion()
5405 From->getEndLoc()); in TryListConversion()
5422 // Cannot convert to zero-sized. in TryListConversion()
5439 Expr *Init = From->getInit(i); in TryListConversion()
5447 if (CompareImplicitConversionSequences(S, From->getBeginLoc(), ICS, in TryListConversion()
5463 S, From->getEndLoc(), DfltElt, Result) == in TryListConversion()
5473 // Otherwise, if the parameter is a non-aggregate class X and overload in TryListConversion()
5475 // conversion sequence is a user-defined conversion sequence. If multiple in TryListConversion()
5477 // implicit conversion sequence is a user-defined conversion sequence. in TryListConversion()
5478 if (ToType->isRecordType() && !ToType->isAggregateType()) { in TryListConversion()
5491 // sequence is a user-defined conversion sequence. in TryListConversion()
5492 if (ToType->isAggregateType()) { in TryListConversion()
5518 if (ToType->isReferenceType()) { in TryListConversion()
5520 // mention initializer lists in any way. So we go by what list- in TryListConversion()
5523 QualType T1 = ToType->castAs<ReferenceType>()->getPointeeType(); in TryListConversion()
5525 // If the initializer list has a single element that is reference-related in TryListConversion()
5527 if (From->getNumInits() == 1 && !IsDesignatedInit) { in TryListConversion()
5528 Expr *Init = From->getInit(0); in TryListConversion()
5530 QualType T2 = Init->getType(); in TryListConversion()
5539 T2 = Fn->getType(); in TryListConversion()
5544 S.CompareReferenceRelationship(From->getBeginLoc(), T1, T2); in TryListConversion()
5547 return TryReferenceInit(S, Init, ToType, /*FIXME*/ From->getBeginLoc(), in TryListConversion()
5561 "Sub-initialization cannot result in ellipsis conversion."); in TryListConversion()
5564 if (ToType->isRValueReferenceType() || in TryListConversion()
5569 SCS.IsLvalueReference = ToType->isLValueReferenceType(); in TryListConversion()
5583 if (!ToType->isRecordType()) { in TryListConversion()
5584 // - if the initializer list has one element that is not itself an in TryListConversion()
5587 unsigned NumInits = From->getNumInits(); in TryListConversion()
5588 if (NumInits == 1 && !isa<InitListExpr>(From->getInit(0))) in TryListConversion()
5589 Result = TryCopyInitialization(S, From->getInit(0), ToType, in TryListConversion()
5593 // - if the initializer list has no elements, the implicit conversion in TryListConversion()
5610 /// TryCopyInitialization - Try to copy-initialize a value of type
5615 /// do not permit any user-defined conversion sequences.
5626 if (ToType->isReferenceType()) in TryCopyInitialization()
5628 /*FIXME:*/ From->getBeginLoc(), in TryCopyInitialization()
5652 /// TryObjectArgumentInitialization - Try to initialize the object
5663 if (const auto *PT = FromType->getAs<PointerType>()) { in TryObjectArgumentInitialization()
5664 FromType = PT->getPointeeType(); in TryObjectArgumentInitialization()
5679 if (Method->isExplicitObjectMemberFunction()) { in TryObjectArgumentInitialization()
5681 ExplicitParameterType = Method->getFunctionObjectParameterReferenceType(); in TryObjectArgumentInitialization()
5692 assert(FromType->isRecordType()); in TryObjectArgumentInitialization()
5702 Qualifiers Quals = Method->getMethodQualifiers(); in TryObjectArgumentInitialization()
5703 if (isa<CXXDestructorDecl>(Method) || Method->isStatic()) { in TryObjectArgumentInitialization()
5715 // For non-static member functions, the type of the implicit object in TryObjectArgumentInitialization()
5718 // - "lvalue reference to cv X" for functions declared without a in TryObjectArgumentInitialization()
5719 // ref-qualifier or with the & ref-qualifier in TryObjectArgumentInitialization()
5720 // - "rvalue reference to cv X" for functions declared with the && in TryObjectArgumentInitialization()
5721 // ref-qualifier in TryObjectArgumentInitialization()
5724 // cv-qualification on the member function declaration. in TryObjectArgumentInitialization()
5727 // are not allowed to perform user-defined conversions in TryObjectArgumentInitialization()
5730 // non-constant references. in TryObjectArgumentInitialization()
5762 } else if (!Method->isExplicitObjectMemberFunction()) { in TryObjectArgumentInitialization()
5768 // Check the ref-qualifier. in TryObjectArgumentInitialization()
5769 switch (Method->getRefQualifier()) { in TryObjectArgumentInitialization()
5776 // non-const lvalue reference cannot bind to an rvalue in TryObjectArgumentInitialization()
5801 ICS.Standard.IsLvalueReference = Method->getRefQualifier() != RQ_RValue; in TryObjectArgumentInitialization()
5805 = (Method->getRefQualifier() == RQ_None); in TryObjectArgumentInitialization()
5809 /// PerformObjectArgumentInitialization - Perform initialization of
5816 QualType ImplicitParamRecordType = Method->getFunctionObjectParameterType(); in PerformImplicitObjectArgumentInitialization()
5819 if (const PointerType *PT = From->getType()->getAs<PointerType>()) { in PerformImplicitObjectArgumentInitialization()
5820 FromRecordType = PT->getPointeeType(); in PerformImplicitObjectArgumentInitialization()
5821 DestType = Method->getThisType(); in PerformImplicitObjectArgumentInitialization()
5824 FromRecordType = From->getType(); in PerformImplicitObjectArgumentInitialization()
5826 FromClassification = From->Classify(Context); in PerformImplicitObjectArgumentInitialization()
5829 if (From->isPRValue()) { in PerformImplicitObjectArgumentInitialization()
5831 Method->getRefQualifier() != in PerformImplicitObjectArgumentInitialization()
5839 *this, From->getBeginLoc(), From->getType(), FromClassification, Method, in PerformImplicitObjectArgumentInitialization()
5840 Method->getParent()); in PerformImplicitObjectArgumentInitialization()
5848 Diag(From->getBeginLoc(), diag::err_member_function_call_bad_cvr) in PerformImplicitObjectArgumentInitialization()
5849 << Method->getDeclName() << FromRecordType << (CVR - 1) in PerformImplicitObjectArgumentInitialization()
5850 << From->getSourceRange(); in PerformImplicitObjectArgumentInitialization()
5851 Diag(Method->getLocation(), diag::note_previous_decl) in PerformImplicitObjectArgumentInitialization()
5852 << Method->getDeclName(); in PerformImplicitObjectArgumentInitialization()
5861 Method->getRefQualifier() == RefQualifierKind::RQ_RValue; in PerformImplicitObjectArgumentInitialization()
5862 Diag(From->getBeginLoc(), diag::err_member_function_call_bad_ref) in PerformImplicitObjectArgumentInitialization()
5863 << Method->getDeclName() << FromClassification.isRValue() in PerformImplicitObjectArgumentInitialization()
5865 Diag(Method->getLocation(), diag::note_previous_decl) in PerformImplicitObjectArgumentInitialization()
5866 << Method->getDeclName(); in PerformImplicitObjectArgumentInitialization()
5879 return Diag(From->getBeginLoc(), diag::err_member_function_call_bad_type) in PerformImplicitObjectArgumentInitialization()
5881 << From->getSourceRange(); in PerformImplicitObjectArgumentInitialization()
5892 if (!Context.hasSameType(From->getType(), DestType)) { in PerformImplicitObjectArgumentInitialization()
5894 QualType PteeTy = DestType->getPointeeType(); in PerformImplicitObjectArgumentInitialization()
5901 From = ImpCastExprToType(From, DestType, CK, From->getValueKind()).get(); in PerformImplicitObjectArgumentInitialization()
5906 /// TryContextuallyConvertToBool - Attempt to contextually convert the
5911 // - Otherwise, if the initialization is direct-initialization, the source in TryContextuallyConvertToBool()
5914 if (From->getType()->isNullPtrType()) in TryContextuallyConvertToBool()
5915 return ImplicitConversionSequence::getNullptrToBool(From->getType(), in TryContextuallyConvertToBool()
5917 From->isGLValue()); in TryContextuallyConvertToBool()
5919 // All other direct-initialization of bool is equivalent to an implicit in TryContextuallyConvertToBool()
5939 return Diag(From->getBeginLoc(), diag::err_typecheck_bool_condition) in PerformContextuallyConvertToBool()
5940 << From->getType() << From->getSourceRange(); in PerformContextuallyConvertToBool()
5966 // (non-conforming) extension. in CheckConvertedConstantConversions()
5967 return SCS.getFromType()->isIntegralOrUnscopedEnumerationType() && in CheckConvertedConstantConversions()
5968 SCS.getToType(2)->isBooleanType(); in CheckConvertedConstantConversions()
5974 return SCS.getFromType()->isNullPtrType(); in CheckConvertedConstantConversions()
6016 /// BuildConvertedConstantExpression - Check that the expression From is a
6049 if (T->isRecordType()) in BuildConvertedConstantExpression()
6057 return S.Diag(From->getBeginLoc(), in BuildConvertedConstantExpression()
6059 << From->getType() << From->getSourceRange() << T; in BuildConvertedConstantExpression()
6069 return S.Diag(From->getBeginLoc(), in BuildConvertedConstantExpression()
6071 << From->getType() << From->getSourceRange() << T; in BuildConvertedConstantExpression()
6074 if (SCS->ReferenceBinding && !SCS->DirectBinding) { in BuildConvertedConstantExpression()
6075 return S.Diag(From->getBeginLoc(), in BuildConvertedConstantExpression()
6077 << From->getType() << From->getSourceRange() << T; in BuildConvertedConstantExpression()
6080 // a reference to a bit-field due to C++ [over.ics.ref]p4. Namely, in BuildConvertedConstantExpression()
6081 // 'SCS->DirectBinding' occurs to be set to 'true' despite it is not in BuildConvertedConstantExpression()
6084 if (From->refersToBitField() && T.getTypePtr()->isReferenceType()) { in BuildConvertedConstantExpression()
6085 return S.Diag(From->getBeginLoc(), in BuildConvertedConstantExpression()
6087 << From->getSourceRange(); in BuildConvertedConstantExpression()
6094 if (T->isRecordType()) { in BuildConvertedConstantExpression()
6107 // C++2a [intro.execution]p5: in BuildConvertedConstantExpression()
6108 // A full-expression is [...] a constant-expression [...] in BuildConvertedConstantExpression()
6109 Result = S.ActOnFinishFullExpr(Result.get(), From->getExprLoc(), in BuildConvertedConstantExpression()
6118 switch (SCS->getNarrowingKind(S.Context, Result.get(), PreNarrowingValue, in BuildConvertedConstantExpression()
6122 // value-dependent so we can't tell whether it's actually narrowing. in BuildConvertedConstantExpression()
6131 PreNarrowingType->isIntegralOrEnumerationType() && in BuildConvertedConstantExpression()
6134 // errors by allowing the un-narrowed value through. in BuildConvertedConstantExpression()
6138 S.Diag(From->getBeginLoc(), diag::ext_cce_narrowing) in BuildConvertedConstantExpression()
6146 S.Diag(From->getBeginLoc(), diag::ext_cce_narrowing) in BuildConvertedConstantExpression()
6147 << CCE << /*Constant*/ 0 << From->getType() << T; in BuildConvertedConstantExpression()
6156 /// CheckConvertedConstantExpression - Check that the expression From is a
6168 if (Result.isInvalid() || Result.get()->isValueDependent()) { in CheckConvertedConstantExpression()
6194 assert(T->isIntegralOrEnumerationType() && "unexpected converted const type"); in CheckConvertedConstantExpression()
6199 if (!R.isInvalid() && !R.get()->isValueDependent()) in CheckConvertedConstantExpression()
6216 if (CCE == Sema::CCEK_TemplateArg && T->isRecordType()) in EvaluateConvertedConstantExpression()
6223 if (!E->EvaluateAsConstantExpr(Eval, Context, Kind) || in EvaluateConvertedConstantExpression()
6237 assert(CE->getResultStorageKind() != ConstantResultStorageKind::None && in EvaluateConvertedConstantExpression()
6259 Diag(E->getBeginLoc(), diag::err_expr_not_cce) in EvaluateConvertedConstantExpression()
6260 << CCE << E->getSourceRange(); in EvaluateConvertedConstantExpression()
6267 /// dropPointerConversions - If the given standard conversion sequence
6275 SCS.ToTypePtrs[2] = SCS.ToTypePtrs[1] = SCS.ToTypePtrs[0]; in dropPointerConversion()
6279 /// TryContextuallyConvertToObjCPointer - Attempt to contextually
6280 /// convert the expression From to an Objective-C pointer type.
6333 M && !M->isImplicitAccess()) in GetExplicitObjectType()
6334 Base = M->getBase(); in GetExplicitObjectType()
6336 M && !M->isImplicitAccess()) in GetExplicitObjectType()
6337 Base = M->getBase(); in GetExplicitObjectType()
6339 QualType T = Base ? Base->getType() : S.getCurrentThisType(); in GetExplicitObjectType()
6341 if (T->isPointerType()) in GetExplicitObjectType()
6342 T = T->getPointeeType(); in GetExplicitObjectType()
6349 QualType ObjType = Obj->getType(); in GetExplicitObjectExpr()
6350 if (ObjType->isPointerType()) { in GetExplicitObjectExpr()
6351 ObjType = ObjType->getPointeeType(); in GetExplicitObjectExpr()
6356 if (Obj->Classify(S.getASTContext()).isPRValue()) { in GetExplicitObjectExpr()
6359 !Fun->getParamDecl(0)->getType()->isRValueReferenceType()); in GetExplicitObjectExpr()
6368 InitializedEntity::InitializeParameter(S.Context, Fun->getParamDecl(0)), in InitializeExplicitObjectArgument()
6369 Obj->getExprLoc(), Obj); in InitializeExplicitObjectArgument()
6375 assert(Method->isExplicitObjectMemberFunction() && in PrepareExplicitObjectArgument()
6385 Method, Object->getBeginLoc()); in PrepareExplicitObjectArgument()
6391 return AllowScopedEnumerations ? T->isIntegralOrEnumerationType() in match()
6392 : T->isIntegralOrUnscopedEnumerationType(); in match()
6403 Converter.diagnoseAmbiguous(SemaRef, Loc, T) << From->getSourceRange(); in diagnoseAmbiguousConversion()
6406 cast<CXXConversionDecl>(ViableConversions[I]->getUnderlyingDecl()); in diagnoseAmbiguousConversion()
6407 QualType ConvTy = Conv->getConversionType().getNonReferenceType(); in diagnoseAmbiguousConversion()
6421 cast<CXXConversionDecl>(Found->getUnderlyingDecl()); in diagnoseNoViableConversion()
6425 QualType ConvTy = Conversion->getConversionType().getNonReferenceType(); in diagnoseNoViableConversion()
6430 << FixItHint::CreateInsertion(From->getBeginLoc(), in diagnoseNoViableConversion()
6433 SemaRef.getLocForEndOfToken(From->getEndLoc()), ")"); in diagnoseNoViableConversion()
6441 SemaRef.CheckMemberOperatorAccess(From->getExprLoc(), From, nullptr, Found); in diagnoseNoViableConversion()
6449 Result = SemaRef.CreateRecoveryExpr(From->getBeginLoc(), From->getEndLoc(), in diagnoseNoViableConversion()
6450 From, Result.get()->getType()); in diagnoseNoViableConversion()
6463 cast<CXXConversionDecl>(Found->getUnderlyingDecl()); in recordConversion()
6464 SemaRef.CheckMemberOperatorAccess(From->getExprLoc(), From, nullptr, Found); in recordConversion()
6466 QualType ToType = Conversion->getConversionType().getNonReferenceType(); in recordConversion()
6472 << From->getSourceRange(); in recordConversion()
6480 From = ImplicitCastExpr::Create(SemaRef.Context, Result.get()->getType(), in recordConversion()
6482 nullptr, Result.get()->getValueKind(), in recordConversion()
6490 if (!Converter.match(From->getType()) && !Converter.Suppress) in finishContextualImplicitConversion()
6491 Converter.diagnoseNoMatch(SemaRef, Loc, From->getType()) in finishContextualImplicitConversion()
6492 << From->getSourceRange(); in finishContextualImplicitConversion()
6504 CXXRecordDecl *ActingContext = cast<CXXRecordDecl>(D->getDeclContext()); in collectViableConversionCandidates()
6506 D = cast<UsingShadowDecl>(D)->getTargetDecl(); in collectViableConversionCandidates()
6511 Conv = cast<CXXConversionDecl>(ConvTemplate->getTemplatedDecl()); in collectViableConversionCandidates()
6532 /// must have a single non-explicit conversion function converting to a matching
6547 // We can't perform any more checking for type-dependent expressions. in PerformContextualImplicitConversion()
6548 if (From->isTypeDependent()) in PerformContextualImplicitConversion()
6552 if (From->hasPlaceholderType()) { in PerformContextualImplicitConversion()
6561 QualType T = Converted.isUsable() ? Converted.get()->getType() : QualType(); in PerformContextualImplicitConversion()
6570 const RecordType *RecordTy = T->getAs<RecordType>(); in PerformContextualImplicitConversion()
6573 Converter.diagnoseNoMatch(*this, Loc, T) << From->getSourceRange(); in PerformContextualImplicitConversion()
6586 Converter.diagnoseIncomplete(S, Loc, T) << From->getSourceRange(); in PerformContextualImplicitConversion()
6599 cast<CXXRecordDecl>(RecordTy->getDecl())->getVisibleConversionFunctions(); in PerformContextualImplicitConversion()
6610 NamedDecl *D = (*I)->getUnderlyingDecl(); in PerformContextualImplicitConversion()
6615 Conversion = cast<CXXConversionDecl>(ConvTemplate->getTemplatedDecl()); in PerformContextualImplicitConversion()
6625 QualType CurToType = Conversion->getConversionType().getNonReferenceType(); in PerformContextualImplicitConversion()
6628 if (Conversion->isExplicit()) { in PerformContextualImplicitConversion()
6650 // type T and is well-formed if and only if e can be implicitly in PerformContextualImplicitConversion()
6683 DeclAccessPair::make(Best->Function, Best->FoundDecl.getAccess()); in PerformContextualImplicitConversion()
6699 // We'll complain below about a non-integral condition type. in PerformContextualImplicitConversion()
6710 // We'll complain below about a non-integral condition type. in PerformContextualImplicitConversion()
6730 /// IsAcceptableNonMemberOperatorCandidate - Determine whether Fn is
6731 /// an acceptable non-member overloaded operator for a call whose
6732 /// arguments have types T1 (and, if non-empty, T2). This routine
6738 QualType T1 = Args[0]->getType(); in IsAcceptableNonMemberOperatorCandidate()
6739 QualType T2 = Args.size() > 1 ? Args[1]->getType() : QualType(); in IsAcceptableNonMemberOperatorCandidate()
6741 if (T1->isDependentType() || (!T2.isNull() && T2->isDependentType())) in IsAcceptableNonMemberOperatorCandidate()
6744 if (T1->isRecordType() || (!T2.isNull() && T2->isRecordType())) in IsAcceptableNonMemberOperatorCandidate()
6747 const auto *Proto = Fn->getType()->castAs<FunctionProtoType>(); in IsAcceptableNonMemberOperatorCandidate()
6748 if (Proto->getNumParams() < 1) in IsAcceptableNonMemberOperatorCandidate()
6751 if (T1->isEnumeralType()) { in IsAcceptableNonMemberOperatorCandidate()
6752 QualType ArgType = Proto->getParamType(0).getNonReferenceType(); in IsAcceptableNonMemberOperatorCandidate()
6757 if (Proto->getNumParams() < 2) in IsAcceptableNonMemberOperatorCandidate()
6760 if (!T2.isNull() && T2->isEnumeralType()) { in IsAcceptableNonMemberOperatorCandidate()
6761 QualType ArgType = Proto->getParamType(1).getNonReferenceType(); in IsAcceptableNonMemberOperatorCandidate()
6770 if (FD->isTargetMultiVersionDefault()) in isNonViableMultiVersionOverload()
6773 if (!FD->getASTContext().getTargetInfo().getTriple().isAArch64()) in isNonViableMultiVersionOverload()
6774 return FD->isTargetMultiVersion(); in isNonViableMultiVersionOverload()
6776 if (!FD->isMultiVersion()) in isNonViableMultiVersionOverload()
6780 // or the first non-default in the absence of default version. in isNonViableMultiVersionOverload()
6784 FD->getASTContext().forEachMultiversionedFunctionVersion( in isNonViableMultiVersionOverload()
6788 else if (CurFD->isTargetMultiVersionDefault()) in isNonViableMultiVersionOverload()
6802 = dyn_cast<FunctionProtoType>(Function->getType()->getAs<FunctionType>()); in AddOverloadCandidate()
6804 assert(!Function->getDescribedFunctionTemplate() && in AddOverloadCandidate()
6811 // "this->f") that was either written explicitly or created in AddOverloadCandidate()
6816 AddMethodCandidate(Method, FoundDecl, Method->getParent(), QualType(), in AddOverloadCandidate()
6822 // We treat a constructor like a non-member function, since its object in AddOverloadCandidate()
6833 if (Constructor && Constructor->isDefaulted() && Constructor->isDeleted() && in AddOverloadCandidate()
6834 Constructor->isMoveConstructor()) in AddOverloadCandidate()
6842 // if no operand has a class type, only those non-member functions in the in AddOverloadCandidate()
6844 // (possibly cv-qualified) T1", when T1 is an enumeration type, or (if there in AddOverloadCandidate()
6846 // (possibly cv-qualified) T2", when T2 is an enumeration type, are in AddOverloadCandidate()
6873 if (getLangOpts().CPlusPlusModules && Function->isInAnotherModuleUnit()) { in AddOverloadCandidate()
6880 if (auto *SpecInfo = Function->getTemplateSpecializationInfo()) in AddOverloadCandidate()
6881 ND = SpecInfo->getTemplate(); in AddOverloadCandidate()
6883 if (ND->getFormalLinkage() == Linkage::Internal) { in AddOverloadCandidate()
6900 QualType ClassType = Context.getTypeDeclType(Constructor->getParent()); in AddOverloadCandidate()
6901 if (Args.size() == 1 && Constructor->isSpecializationCopyingObject() && in AddOverloadCandidate()
6902 (Context.hasSameUnqualifiedType(ClassType, Args[0]->getType()) || in AddOverloadCandidate()
6903 IsDerivedFrom(Args[0]->getBeginLoc(), Args[0]->getType(), in AddOverloadCandidate()
6915 // one argument and D is reference-related to P and P is reference-related in AddOverloadCandidate()
6918 if (Shadow && Args.size() == 1 && Constructor->getNumParams() >= 1 && in AddOverloadCandidate()
6919 Constructor->getParamDecl(0)->getType()->isReferenceType()) { in AddOverloadCandidate()
6920 QualType P = Constructor->getParamDecl(0)->getType()->getPointeeType(); in AddOverloadCandidate()
6921 QualType C = Context.getRecordType(Constructor->getParent()); in AddOverloadCandidate()
6922 QualType D = Context.getRecordType(Shadow->getParent()); in AddOverloadCandidate()
6923 SourceLocation Loc = Args.front()->getExprLoc(); in AddOverloadCandidate()
6935 Constructor->getMethodQualifiers().getAddressSpace(), in AddOverloadCandidate()
6942 unsigned NumParams = Proto->getNumParams(); in AddOverloadCandidate()
6944 // (C++ 13.3.2p2): A candidate function having fewer than m in AddOverloadCandidate()
6948 !Proto->isVariadic() && in AddOverloadCandidate()
6955 // (C++ 13.3.2p2): A candidate function having more than m parameters in AddOverloadCandidate()
6960 unsigned MinRequiredArgs = Function->getMinRequiredArguments(); in AddOverloadCandidate()
6976 if (!(Caller && Caller->isImplicit()) && in AddOverloadCandidate()
6984 if (Function->getTrailingRequiresClause()) { in AddOverloadCandidate()
6999 PO == OverloadCandidateParamOrder::Reversed ? 1 - ArgIdx : ArgIdx; in AddOverloadCandidate()
7004 // (C++ 13.3.2p3): for F to be a viable function, there shall in AddOverloadCandidate()
7008 QualType ParamType = Proto->getParamType(ArgIdx); in AddOverloadCandidate()
7020 // (C++ 13.3.2p2): For the purposes of overload resolution, any in AddOverloadCandidate()
7047 // to addition of c-style arguments in method. in SelectBestMethod()
7048 if (Method->param_size() > NumNamedArgs) in SelectBestMethod()
7049 NumNamedArgs = Method->param_size(); in SelectBestMethod()
7054 // We can't do any type-checking on a type-dependent argument. in SelectBestMethod()
7055 if (Args[i]->isTypeDependent()) { in SelectBestMethod()
7060 ParmVarDecl *param = Method->parameters()[i]; in SelectBestMethod()
7064 // Strip the unbridged-cast placeholder expression off unless it's in SelectBestMethod()
7066 if (argExpr->hasPlaceholderType(BuiltinType::ARCUnbridgedCast) && in SelectBestMethod()
7067 !param->hasAttr<CFConsumedAttr>()) in SelectBestMethod()
7071 if (param->getType() == Context.UnknownAnyTy) { in SelectBestMethod()
7077 = TryCopyInitialization(*this, argExpr, param->getType(), in SelectBestMethod()
7083 // This function looks for a reasonably-exact match, so we consider in SelectBestMethod()
7094 if (Match && Method->isVariadic()) { in SelectBestMethod()
7096 if (Args[i]->isTypeDependent()) { in SelectBestMethod()
7108 // Check for extra arguments to non-variadic methods. in SelectBestMethod()
7115 QualType ReturnT = Methods[b]->getReturnType(); in SelectBestMethod()
7116 if (ReturnT->isObjCIdType()) in SelectBestMethod()
7136 assert(!Method->isStatic() && "Shouldn't have `this` for static methods!"); in convertArgsForAvailabilityChecks()
7145 assert((MissingImplicitThis || MD->isStatic() || in convertArgsForAvailabilityChecks()
7147 "Expected `this` for non-ctor instance methods"); in convertArgsForAvailabilityChecks()
7154 unsigned ArgSizeNoVarargs = std::min(Function->param_size(), Args.size()); in convertArgsForAvailabilityChecks()
7160 S.Context, Function->getParamDecl(I)), in convertArgsForAvailabilityChecks()
7173 if (!Function->isVariadic() && Args.size() < Function->getNumParams()) { in convertArgsForAvailabilityChecks()
7174 for (unsigned i = Args.size(), e = Function->getNumParams(); i != e; ++i) { in convertArgsForAvailabilityChecks()
7175 ParmVarDecl *P = Function->getParamDecl(i); in convertArgsForAvailabilityChecks()
7176 if (!P->hasDefaultArg()) in convertArgsForAvailabilityChecks()
7194 auto EnableIfAttrs = Function->specific_attrs<EnableIfAttr>(); in CheckEnableIf()
7200 // FIXME: We should look into making enable_if late-parsed. in CheckEnableIf()
7209 // FIXME: This doesn't consider value-dependent cases, because doing so is in CheckEnableIf()
7211 if (EIA->getCond()->isValueDependent() || in CheckEnableIf()
7212 !EIA->getCond()->EvaluateWithSubstitution( in CheckEnableIf()
7227 for (const auto *DIA : ND->specific_attrs<DiagnoseIfAttr>()) { in diagnoseDiagnoseIfAttrsWith()
7228 if (ArgDependent == DIA->getArgDependent()) in diagnoseDiagnoseIfAttrsWith()
7238 [](const DiagnoseIfAttr *DIA) { return DIA->isError(); }); in diagnoseDiagnoseIfAttrsWith()
7240 // Note that diagnose_if attributes are late-parsed, so they appear in the in diagnoseDiagnoseIfAttrsWith()
7246 S.Diag(Loc, diag::err_diagnose_if_succeeded) << DIA->getMessage(); in diagnoseDiagnoseIfAttrsWith()
7247 S.Diag(DIA->getLocation(), diag::note_from_diagnose_if) in diagnoseDiagnoseIfAttrsWith()
7248 << DIA->getParent() << DIA->getCond()->getSourceRange(); in diagnoseDiagnoseIfAttrsWith()
7254 S.Diag(Loc, diag::warn_diagnose_if_succeeded) << DIA->getMessage(); in diagnoseDiagnoseIfAttrsWith()
7255 S.Diag(DIA->getLocation(), diag::note_from_diagnose_if) in diagnoseDiagnoseIfAttrsWith()
7256 << DIA->getParent() << DIA->getCond()->getSourceRange(); in diagnoseDiagnoseIfAttrsWith()
7273 if (!DIA->getCond()->EvaluateWithSubstitution( in diagnoseArgDependentDiagnoseIfAttrs()
7274 Result, Context, cast<FunctionDecl>(DIA->getParent()), Args, ThisArg)) in diagnoseArgDependentDiagnoseIfAttrs()
7286 return DIA->getCond()->EvaluateAsBooleanCondition(Result, Context) && in diagnoseArgIndependentDiagnoseIfAttrs()
7299 NamedDecl *D = F.getDecl()->getUnderlyingDecl(); in AddFunctionCandidates()
7304 FunTmpl ? FunTmpl->getTemplatedDecl() : cast<FunctionDecl>(D); in AddFunctionCandidates()
7306 if (isa<CXXMethodDecl>(FD) && !cast<CXXMethodDecl>(FD)->isStatic()) { in AddFunctionCandidates()
7312 ObjectType = E->getType(); in AddFunctionCandidates()
7314 // always classify them as l-values. in AddFunctionCandidates()
7315 if (!ObjectType.isNull() && ObjectType->isPointerType()) in AddFunctionCandidates()
7318 ObjectClassification = E->Classify(Context); in AddFunctionCandidates()
7325 cast<CXXRecordDecl>(FunTmpl->getDeclContext()), in AddFunctionCandidates()
7331 cast<CXXMethodDecl>(FD)->getParent(), ObjectType, in AddFunctionCandidates()
7339 // static method as non-static. in AddFunctionCandidates()
7343 assert(cast<CXXMethodDecl>(FD)->isStatic()); in AddFunctionCandidates()
7366 CXXRecordDecl *ActingContext = cast<CXXRecordDecl>(Decl->getDeclContext()); in AddMethodCandidate()
7369 Decl = cast<UsingShadowDecl>(Decl)->getTargetDecl(); in AddMethodCandidate()
7372 assert(isa<CXXMethodDecl>(TD->getTemplatedDecl()) && in AddMethodCandidate()
7396 = dyn_cast<FunctionProtoType>(Method->getType()->getAs<FunctionType>()); in AddMethodCandidate()
7407 if (Method->isDefaulted() && Method->isDeleted() && in AddMethodCandidate()
7408 Method->isMoveAssignmentOperator()) in AddMethodCandidate()
7427 (Method->isExplicitObjectMemberFunction() && in AddMethodCandidate()
7433 Method->isImplicitObjectMemberFunction(); in AddMethodCandidate()
7436 !IgnoreExplicitObject && Method->isExplicitObjectMemberFunction() ? 1 : 0; in AddMethodCandidate()
7438 unsigned NumParams = Method->getNumParams() - ExplicitOffset + in AddMethodCandidate()
7441 // (C++ 13.3.2p2): A candidate function having fewer than m in AddMethodCandidate()
7445 !Proto->isVariadic() && in AddMethodCandidate()
7452 // (C++ 13.3.2p2): A candidate function having more than m parameters in AddMethodCandidate()
7457 unsigned MinRequiredArgs = Method->getMinRequiredArguments() - in AddMethodCandidate()
7473 else if (Method->isStatic()) { in AddMethodCandidate()
7506 if (Method->getTrailingRequiresClause()) { in AddMethodCandidate()
7526 // (C++ 13.3.2p3): for F to be a viable function, there shall in AddMethodCandidate()
7533 ? Method->getFunctionObjectParameterReferenceType() in AddMethodCandidate()
7534 : Proto->getParamType(ArgIdx - 1); in AddMethodCandidate()
7536 ParamType = Proto->getParamType(ArgIdx + ExplicitOffset); in AddMethodCandidate()
7550 // (C++ 13.3.2p2): For the purposes of overload resolution, any in AddMethodCandidate()
7584 // deduction (14.8.3, 14.8.2). Those candidates are then handled as in AddMethodTemplateCandidate()
7586 // or more function templates and also to a set of overloaded non-template in AddMethodTemplateCandidate()
7588 // function template are combined with the set of non-template candidate in AddMethodTemplateCandidate()
7607 Candidate.Function = MethodTmpl->getTemplatedDecl(); in AddMethodTemplateCandidate()
7613 cast<CXXMethodDecl>(Candidate.Function)->isStatic() || in AddMethodTemplateCandidate()
7638 /// or a non-value-dependent explicit-specification that evaluates to true.
7640 return ExplicitSpecifier::getFromDecl(FTD->getTemplatedDecl()).isExplicit(); in isNonDependentlyExplicit()
7652 // If the function template has a non-dependent explicit specification, in AddTemplateOverloadCandidate()
7658 Candidate.Function = FunctionTemplate->getTemplatedDecl(); in AddTemplateOverloadCandidate()
7667 // deduction (14.8.3, 14.8.2). Those candidates are then handled as in AddTemplateOverloadCandidate()
7669 // or more function templates and also to a set of overloaded non-template in AddTemplateOverloadCandidate()
7671 // function template are combined with the set of non-template candidate in AddTemplateOverloadCandidate()
7674 FunctionTemplate->getTemplateDepth()); in AddTemplateOverloadCandidate()
7691 Candidate.Function = FunctionTemplate->getTemplatedDecl(); in AddTemplateOverloadCandidate()
7734 auto *FD = FunctionTemplate->getTemplatedDecl(); in CheckNonDependentConversions()
7749 if (HasThisConversion && !cast<CXXMethodDecl>(FD)->isStatic() && in CheckNonDependentConversions()
7752 if (!FD->hasCXXExplicitFunctionObjectParameter() || in CheckNonDependentConversions()
7753 !ParamTypes[0]->isDependentType()) { in CheckNonDependentConversions()
7757 FD->hasCXXExplicitFunctionObjectParameter() ? ParamTypes[0] in CheckNonDependentConversions()
7765 Method && Method->hasCXXExplicitFunctionObjectParameter() ? 1 : 0; in CheckNonDependentConversions()
7767 for (unsigned I = 0, N = std::min(ParamTypes.size() - Offset, Args.size()); in CheckNonDependentConversions()
7770 if (!ParamType->isDependentType()) { in CheckNonDependentConversions()
7773 ConvIdx = Args.size() - 1 - I; in CheckNonDependentConversions()
7774 assert(Args.size() + ThisConversions == 2 && in CheckNonDependentConversions()
7775 "number of args (including 'this') must be exactly 2 for " in CheckNonDependentConversions()
7808 /// Objective-C pointer to another.
7826 // If we're not allowed to consider Objective-C pointer conversions, in isAllowableExplicitConversion()
7831 // Is this an Objective-C pointer conversion? in isAllowableExplicitConversion()
7843 assert(!Conversion->getDescribedFunctionTemplate() && in AddConversionCandidate()
7845 QualType ConvType = Conversion->getConversionType().getNonReferenceType(); in AddConversionCandidate()
7851 if (getLangOpts().CPlusPlus14 && ConvType->isUndeducedType()) { in AddConversionCandidate()
7852 if (DeduceReturnType(Conversion, From->getExprLoc())) in AddConversionCandidate()
7854 ConvType = Conversion->getConversionType().getNonReferenceType(); in AddConversionCandidate()
7858 // functions that don't convert to exactly (possibly cv-qualified) T. in AddConversionCandidate()
7860 !Context.hasSameUnqualifiedType(Conversion->getConversionType(), ToType)) in AddConversionCandidate()
7869 if (Conversion->isExplicit() && in AddConversionCandidate()
7891 if (!AllowExplicit && Conversion->isExplicit()) { in AddConversionCandidate()
7904 QualType ObjectType = From->getType(); in AddConversionCandidate()
7905 if (const auto *FromPtrType = ObjectType->getAs<PointerType>()) in AddConversionCandidate()
7906 ObjectType = FromPtrType->getPointeeType(); in AddConversionCandidate()
7908 cast<CXXRecordDecl>(ObjectType->castAs<RecordType>()->getDecl()); in AddConversionCandidate()
7912 // - the object parameter of a user-defined conversion function in AddConversionCandidate()
7913 // [...] user-defined conversion sequences are not considered. in AddConversionCandidate()
7915 *this, CandidateSet.getLocation(), From->getType(), in AddConversionCandidate()
7916 From->Classify(Context), Conversion, ConversionContext, in AddConversionCandidate()
7926 if (Conversion->getTrailingRequiresClause()) { in AddConversionCandidate()
7936 // We won't go through a user-defined type conversion function to convert a in AddConversionCandidate()
7938 // go through a copy constructor. 13.3.3.1.2-p4 [over.ics.user] in AddConversionCandidate()
7940 = Context.getCanonicalType(From->getType().getUnqualifiedType()); in AddConversionCandidate()
7956 // well-formed. in AddConversionCandidate()
7957 DeclRefExpr ConversionRef(Context, Conversion, false, Conversion->getType(), in AddConversionCandidate()
7958 VK_LValue, From->getBeginLoc()); in AddConversionCandidate()
7960 Context.getPointerType(Conversion->getType()), in AddConversionCandidate()
7964 QualType ConversionType = Conversion->getConversionType(); in AddConversionCandidate()
7965 if (!isCompleteType(From->getBeginLoc(), ConversionType)) { in AddConversionCandidate()
7980 Buffer, &ConversionFn, CallResultType, VK, From->getBeginLoc()); in AddConversionCandidate()
7993 // If the user-defined conversion is specified by a specialization of a in AddConversionCandidate()
7996 if (Conversion->getPrimaryTemplate() && in AddConversionCandidate()
8005 // the second standard conversion sequence of the user-defined in AddConversionCandidate()
8006 // conversion sequence includes an lvalue-to-rvalue conversion, the in AddConversionCandidate()
8007 // program is ill-formed. in AddConversionCandidate()
8008 if (ToType->isRValueReferenceType() && in AddConversionCandidate()
8045 assert(isa<CXXConversionDecl>(FunctionTemplate->getTemplatedDecl()) && in AddTemplateConversionCandidate()
8051 // If the function template has a non-dependent explicit specification, in AddTemplateConversionCandidate()
8057 Candidate.Function = FunctionTemplate->getTemplatedDecl(); in AddTemplateConversionCandidate()
8063 QualType ObjectType = From->getType(); in AddTemplateConversionCandidate()
8064 Expr::Classification ObjectClassification = From->Classify(getASTContext()); in AddTemplateConversionCandidate()
8074 Candidate.Function = FunctionTemplate->getTemplatedDecl(); in AddTemplateConversionCandidate()
8116 if (Conversion->hasCXXExplicitFunctionObjectParameter()) { in AddSurrogateCandidate()
8118 Conversion->getParamDecl(0)->getType(), in AddSurrogateCandidate()
8123 *this, CandidateSet.getLocation(), Object->getType(), in AddSurrogateCandidate()
8124 Object->Classify(Context), Conversion, ActingContext); in AddSurrogateCandidate()
8134 // The first conversion is actually a user-defined conversion whose in AddSurrogateCandidate()
8148 unsigned NumParams = Proto->getNumParams(); in AddSurrogateCandidate()
8150 // (C++ 13.3.2p2): A candidate function having fewer than m in AddSurrogateCandidate()
8153 if (Args.size() > NumParams && !Proto->isVariadic()) { in AddSurrogateCandidate()
8172 // (C++ 13.3.2p3): for F to be a viable function, there shall in AddSurrogateCandidate()
8176 QualType ParamType = Proto->getParamType(ArgIdx); in AddSurrogateCandidate()
8189 // (C++ 13.3.2p2): For the purposes of overload resolution, any in AddSurrogateCandidate()
8196 if (Conversion->getTrailingRequiresClause()) { in AddSurrogateCandidate()
8221 NamedDecl *D = F.getDecl()->getUnderlyingDecl(); in AddNonMemberOperatorCandidates()
8226 FunTmpl ? FunTmpl->getTemplatedDecl() : cast<FunctionDecl>(D); in AddNonMemberOperatorCandidates()
8265 // cv-unqualified version is T1, and for a binary operator @ with in AddMemberOperatorCandidates()
8266 // a left operand of a type whose cv-unqualified version is T1 and in AddMemberOperatorCandidates()
8267 // a right operand of a type whose cv-unqualified version is T2, in AddMemberOperatorCandidates()
8269 // candidates, non-member candidates and built-in candidates, are in AddMemberOperatorCandidates()
8271 QualType T1 = Args[0]->getType(); in AddMemberOperatorCandidates()
8273 // -- If T1 is a complete class type or a class currently being in AddMemberOperatorCandidates()
8277 if (const RecordType *T1Rec = T1->getAs<RecordType>()) { in AddMemberOperatorCandidates()
8279 if (!isCompleteType(OpLoc, T1) && !T1Rec->isBeingDefined()) in AddMemberOperatorCandidates()
8282 if (!T1Rec->getDecl()->getDefinition()) in AddMemberOperatorCandidates()
8286 LookupQualifiedName(Operators, T1Rec->getDecl()); in AddMemberOperatorCandidates()
8292 if (Oper->getAsFunction() && in AddMemberOperatorCandidates()
8295 *this, {Args[1], Args[0]}, Oper->getAsFunction())) in AddMemberOperatorCandidates()
8297 AddMethodCandidate(Oper.getPair(), Args[0]->getType(), in AddMemberOperatorCandidates()
8298 Args[0]->Classify(Context), Args.slice(1), in AddMemberOperatorCandidates()
8324 // For the built-in assignment operators, conversions of the in AddBuiltinCandidate()
8326 // -- no temporaries are introduced to hold the left operand, and in AddBuiltinCandidate()
8327 // -- no user-defined conversions are applied to the left in AddBuiltinCandidate()
8328 // operand to achieve a type match with the left-most in AddBuiltinCandidate()
8329 // parameter of a built-in candidate. in AddBuiltinCandidate()
8331 // We block these conversions by turning off user-defined in AddBuiltinCandidate()
8333 // a reference to a non-class type can occur from something that in AddBuiltinCandidate()
8358 /// BuiltinCandidateTypeSet - A set of types that will be used for the
8359 /// candidate operator functions for built-in operators (C++
8363 /// TypeSet - A set of types.
8366 /// PointerTypes - The set of pointer types that will be used in the
8367 /// built-in candidates.
8370 /// MemberPointerTypes - The set of member pointer types that will be
8371 /// used in the built-in candidates.
8374 /// EnumerationTypes - The set of enumeration types that will be
8375 /// used in the built-in candidates.
8378 /// The set of vector types that will be used in the built-in
8382 /// The set of matrix types that will be used in the built-in
8386 /// The set of _BitInt types that will be used in the built-in candidates.
8389 /// A flag indicating non-record types are viable candidates
8400 /// Sema - The semantic analysis instance where we are building the
8404 /// Context - The AST context in which we will build the type sets.
8412 /// iterator - Iterates through the types that are part of the set.
8447 /// AddPointerWithMoreQualifiedTypeVariants - Add the pointer type @p Ty to
8448 /// the set of pointer types along with any more-qualified variants of
8465 const PointerType *PointerTy = Ty->getAs<PointerType>(); in AddPointerWithMoreQualifiedTypeVariants()
8468 const ObjCObjectPointerType *PTy = Ty->castAs<ObjCObjectPointerType>(); in AddPointerWithMoreQualifiedTypeVariants()
8469 PointeeTy = PTy->getPointeeType(); in AddPointerWithMoreQualifiedTypeVariants()
8472 PointeeTy = PointerTy->getPointeeType(); in AddPointerWithMoreQualifiedTypeVariants()
8477 // only overload situation where it matters is subscript or pointer +- int, in AddPointerWithMoreQualifiedTypeVariants()
8479 if (PointeeTy->isArrayType()) in AddPointerWithMoreQualifiedTypeVariants()
8493 // the type cannot be restrict-qualified. in AddPointerWithMoreQualifiedTypeVariants()
8496 (!(PointeeTy->isAnyPointerType() || PointeeTy->isReferenceType())))) in AddPointerWithMoreQualifiedTypeVariants()
8516 /// AddMemberPointerWithMoreQualifiedTypeVariants - Add the pointer type @p Ty
8517 /// to the set of pointer types along with any more-qualified variants of
8532 const MemberPointerType *PointerTy = Ty->getAs<MemberPointerType>(); in AddMemberPointerWithMoreQualifiedTypeVariants()
8535 QualType PointeeTy = PointerTy->getPointeeType(); in AddMemberPointerWithMoreQualifiedTypeVariants()
8538 // only overload situation where it matters is subscript or pointer +- int, in AddMemberPointerWithMoreQualifiedTypeVariants()
8540 if (PointeeTy->isArrayType()) in AddMemberPointerWithMoreQualifiedTypeVariants()
8542 const Type *ClassTy = PointerTy->getClass(); in AddMemberPointerWithMoreQualifiedTypeVariants()
8558 /// AddTypesConvertedFrom - Add each of the types to which the type @p
8577 if (const ReferenceType *RefTy = Ty->getAs<ReferenceType>()) in AddTypesConvertedFrom()
8578 Ty = RefTy->getPointeeType(); in AddTypesConvertedFrom()
8581 if (Ty->isArrayType()) in AddTypesConvertedFrom()
8587 // Flag if we ever add a non-record type. in AddTypesConvertedFrom()
8588 const RecordType *TyRec = Ty->getAs<RecordType>(); in AddTypesConvertedFrom()
8593 HasArithmeticOrEnumeralTypes || Ty->isArithmeticType(); in AddTypesConvertedFrom()
8595 if (Ty->isObjCIdType() || Ty->isObjCClassType()) in AddTypesConvertedFrom()
8597 else if (Ty->getAs<PointerType>() || Ty->getAs<ObjCObjectPointerType>()) { in AddTypesConvertedFrom()
8598 // Insert our type, and its more-qualified variants, into the set in AddTypesConvertedFrom()
8602 } else if (Ty->isMemberPointerType()) { in AddTypesConvertedFrom()
8606 } else if (Ty->isEnumeralType()) { in AddTypesConvertedFrom()
8609 } else if (Ty->isBitIntType()) { in AddTypesConvertedFrom()
8612 } else if (Ty->isVectorType()) { in AddTypesConvertedFrom()
8617 } else if (Ty->isMatrixType()) { in AddTypesConvertedFrom()
8622 } else if (Ty->isNullPtrType()) { in AddTypesConvertedFrom()
8629 CXXRecordDecl *ClassDecl = cast<CXXRecordDecl>(TyRec->getDecl()); in AddTypesConvertedFrom()
8630 for (NamedDecl *D : ClassDecl->getVisibleConversionFunctions()) { in AddTypesConvertedFrom()
8632 D = cast<UsingShadowDecl>(D)->getTargetDecl(); in AddTypesConvertedFrom()
8640 if (AllowExplicitConversions || !Conv->isExplicit()) { in AddTypesConvertedFrom()
8641 AddTypesConvertedFrom(Conv->getConversionType(), Loc, false, false, in AddTypesConvertedFrom()
8651 return S.Context.getAddrSpaceQualType(T, Arg->getType().getAddressSpace()); in AdjustAddressSpaceForBuiltinOperandType()
8655 /// the volatile- and non-volatile-qualified assignment operators for the
8661 QualType ParamTypes[2]; in AddBuiltinAssignmentOperatorCandidates()
8681 /// CollectVRQualifiers - This routine returns Volatile/Restrict qualifiers,
8687 ArgExpr->getType()->getAs<MemberPointerType>()) in CollectVRQualifiers()
8688 TyRec = RHSMPType->getClass()->getAs<RecordType>(); in CollectVRQualifiers()
8690 TyRec = ArgExpr->getType()->getAs<RecordType>(); in CollectVRQualifiers()
8698 CXXRecordDecl *ClassDecl = cast<CXXRecordDecl>(TyRec->getDecl()); in CollectVRQualifiers()
8699 if (!ClassDecl->hasDefinition()) in CollectVRQualifiers()
8702 for (NamedDecl *D : ClassDecl->getVisibleConversionFunctions()) { in CollectVRQualifiers()
8704 D = cast<UsingShadowDecl>(D)->getTargetDecl(); in CollectVRQualifiers()
8706 QualType CanTy = Context.getCanonicalType(Conv->getConversionType()); in CollectVRQualifiers()
8707 if (const ReferenceType *ResTypeRef = CanTy->getAs<ReferenceType>()) in CollectVRQualifiers()
8708 CanTy = ResTypeRef->getPointeeType(); in CollectVRQualifiers()
8715 if (const PointerType *ResTypePtr = CanTy->getAs<PointerType>()) in CollectVRQualifiers()
8716 CanTy = ResTypePtr->getPointeeType(); in CollectVRQualifiers()
8718 CanTy->getAs<MemberPointerType>()) in CollectVRQualifiers()
8719 CanTy = ResTypeMPtr->getPointeeType(); in CollectVRQualifiers()
8823 S.Context.getAuxTargetInfo()->hasInt128Type())) in InitArithmeticTypes()
8830 S.Context.getAuxTargetInfo()->hasInt128Type())) in InitArithmeticTypes()
8839 llvm::SmallSetVector<CanQualType, 2> BitIntCandidates; in InitArithmeticTypes()
8866 // We don't know for sure how many bit-precise candidates were involved, so in InitArithmeticTypes()
8869 assert(ArithmeticTypes.size() - BitIntCandidates.size() <= in InitArithmeticTypes()
8875 /// for '++' and '--' builtin operators.
8879 QualType ParamTypes[2] = { in addPlusPlusMinusMinusStyleOverloads()
8884 // Non-volatile version. in addPlusPlusMinusMinusStyleOverloads()
8897 // and our candidate type is a non-restrict-qualified pointer. in addPlusPlusMinusMinusStyleOverloads()
8898 if (HasRestrict && CandidateTy->isAnyPointerType() && in addPlusPlusMinusMinusStyleOverloads()
8917 /// Helper to add an overload candidate for a binary builtin with types \p L
8919 void AddCandidate(QualType L, QualType R) { in AddCandidate() argument
8920 QualType LandR[2] = {L, R}; in AddCandidate()
8958 // VQ T& operator--(VQ T&);
8959 // T operator--(VQ T&, int);
8981 // For every pair (T, VQ), where T is a cv-qualified or
8982 // cv-unqualified object type, and VQ is either volatile or
8986 // T*VQ& operator--(T*VQ&);
8988 // T* operator--(T*VQ&, int);
8992 if (!PtrTy->getPointeeType()->isObjectType()) in addPlusPlusMinusMinusPointerOverloads()
9005 // For every cv-qualified or cv-unqualified object type T, there
9011 // For every function type T that does not have cv-qualifiers or a
9012 // ref-qualifier, there exist candidate operator functions of the form
9016 QualType PointeeTy = ParamTy->getPointeeType(); in addUnaryStarPointerOverloads()
9017 if (!PointeeTy->isObjectType() && !PointeeTy->isFunctionType()) in addUnaryStarPointerOverloads()
9020 if (const FunctionProtoType *Proto =PointeeTy->getAs<FunctionProtoType>()) in addUnaryStarPointerOverloads()
9021 if (Proto->getMethodQuals() || Proto->getRefQualifier()) in addUnaryStarPointerOverloads()
9033 // T operator-(T);
9095 QualType ParamTypes[2] = {MemPtrTy, MemPtrTy}; in addEqualEqualOrNotEqualMemberPointerOrNullptrOverloads()
9102 QualType ParamTypes[2] = { NullPtrTy, NullPtrTy }; in addEqualEqualOrNotEqualMemberPointerOrNullptrOverloads()
9123 // [...]the built-in candidates include all of the candidate operator in addGenericBinaryPointerOrEnumeralOverloads()
9125 // do not have the same parameter-type-list as any non-template non-member in addGenericBinaryPointerOrEnumeralOverloads()
9129 // aren't any built-in candidates of record type, and a user-defined operator in addGenericBinaryPointerOrEnumeralOverloads()
9142 if (!C->Viable || !C->Function || C->Function->getNumParams() != 2) in addGenericBinaryPointerOrEnumeralOverloads()
9145 if (C->Function->isFunctionTemplateSpecialization()) in addGenericBinaryPointerOrEnumeralOverloads()
9148 // We interpret "same parameter-type-list" as applying to the in addGenericBinaryPointerOrEnumeralOverloads()
9151 bool Reversed = C->isReversed(); in addGenericBinaryPointerOrEnumeralOverloads()
9152 QualType FirstParamType = C->Function->getParamDecl(Reversed ? 1 : 0) in addGenericBinaryPointerOrEnumeralOverloads()
9153 ->getType() in addGenericBinaryPointerOrEnumeralOverloads()
9155 QualType SecondParamType = C->Function->getParamDecl(Reversed ? 0 : 1) in addGenericBinaryPointerOrEnumeralOverloads()
9156 ->getType() in addGenericBinaryPointerOrEnumeralOverloads()
9160 if (!FirstParamType->isEnumeralType() || in addGenericBinaryPointerOrEnumeralOverloads()
9161 !SecondParamType->isEnumeralType()) in addGenericBinaryPointerOrEnumeralOverloads()
9164 // Add this operator to the set of known user-defined operators. in addGenericBinaryPointerOrEnumeralOverloads()
9180 if (IsSpaceship && PtrTy->isFunctionPointerType()) in addGenericBinaryPointerOrEnumeralOverloads()
9183 QualType ParamTypes[2] = {PtrTy, PtrTy}; in addGenericBinaryPointerOrEnumeralOverloads()
9195 QualType ParamTypes[2] = {EnumTy, EnumTy}; in addGenericBinaryPointerOrEnumeralOverloads()
9203 // For every cv-qualified or cv-unqualified object type T
9208 // T* operator-(T*, ptrdiff_t);
9217 // ptrdiff_t operator-(T, T);
9222 for (int Arg = 0; Arg < 2; ++Arg) { in addBinaryPlusOrMinusPointerOverloads()
9223 QualType AsymmetricParamTypes[2] = { in addBinaryPlusOrMinusPointerOverloads()
9228 QualType PointeeTy = PtrTy->getPointeeType(); in addBinaryPlusOrMinusPointerOverloads()
9229 if (!PointeeTy->isObjectType()) in addBinaryPlusOrMinusPointerOverloads()
9234 // operator+(T*, ptrdiff_t) or operator-(T*, ptrdiff_t) in addBinaryPlusOrMinusPointerOverloads()
9239 // ptrdiff_t operator-(T, T); in addBinaryPlusOrMinusPointerOverloads()
9243 QualType ParamTypes[2] = {PtrTy, PtrTy}; in addBinaryPlusOrMinusPointerOverloads()
9252 // For every pair of promoted arithmetic types L and R, there
9255 // LR operator*(L, R);
9256 // LR operator/(L, R);
9257 // LR operator+(L, R);
9258 // LR operator-(L, R);
9259 // bool operator<(L, R);
9260 // bool operator>(L, R);
9261 // bool operator<=(L, R);
9262 // bool operator>=(L, R);
9263 // bool operator==(L, R);
9264 // bool operator!=(L, R);
9267 // between types L and R.
9271 // For every pair of promoted arithmetic types L and R, there exist
9274 // LR operator?(bool, L, R);
9277 // between types L and R.
9287 QualType LandR[2] = { ArithmeticTypes[Left], in addGenericBinaryArithmeticOverloads()
9297 QualType LandR[2] = {Vec1Ty, Vec2Ty}; in addGenericBinaryArithmeticOverloads()
9303 /// * (M1, M1) -> M1
9304 /// * (M1, M1.getElementType()) -> M1
9305 /// * (M2.getElementType(), M2) -> M2
9306 /// * (M2, M2) -> M2 // Only if M2 is not part of CandidateTypes[0].
9312 AddCandidate(M1, cast<MatrixType>(M1)->getElementType()); in addMatrixBinaryArithmeticOverloads()
9317 AddCandidate(cast<MatrixType>(M2)->getElementType(), M2); in addMatrixBinaryArithmeticOverloads()
9323 // C++2a [over.built]p14:
9330 // C++2a [over.built]p15:
9332 // For every pair of floating-point types L and R, there exists a candidate
9335 // std::partial_ordering operator<=>(L, R);
9338 // the direction of p0946r0, which allows mixed integral and unscoped-enum
9350 // the mixed overloads `operator<=>(L, R)` where L and R are promoted
9360 // For every pair of promoted integral types L and R, there
9363 // LR operator%(L, R);
9364 // LR operator&(L, R);
9365 // LR operator^(L, R);
9366 // LR operator|(L, R);
9367 // L operator<<(L, R);
9368 // L operator>>(L, R);
9371 // between types L and R.
9380 QualType LandR[2] = { ArithmeticTypes[Left], in addBinaryBitwiseArithmeticOverloads()
9398 for (unsigned ArgIdx = 0; ArgIdx < 2; ++ArgIdx) { in addAssignmentMemberPointerOrEnumeralOverloads()
9425 // For every pair (T, VQ), where T is a cv-qualified or
9426 // cv-unqualified object type and VQ is either volatile or
9430 // T*VQ& operator-=(T*VQ&, ptrdiff_t);
9439 else if (!PtrTy->getPointeeType()->isObjectType()) in addAssignmentPointerOverloads()
9442 // non-volatile version in addAssignmentPointerOverloads()
9443 QualType ParamTypes[2] = { in addAssignmentPointerOverloads()
9485 QualType ParamTypes[2] = { in addAssignmentPointerOverloads()
9490 // non-volatile version in addAssignmentPointerOverloads()
9527 // For every triple (L, VQ, R), where L is an arithmetic type,
9532 // VQ L& operator=(VQ L&, R);
9533 // VQ L& operator*=(VQ L&, R);
9534 // VQ L& operator/=(VQ L&, R);
9535 // VQ L& operator+=(VQ L&, R);
9536 // VQ L& operator-=(VQ L&, R);
9544 QualType ParamTypes[2]; in addAssignmentArithmeticOverloads()
9559 // Extension: Add the binary operators =, +=, -=, *=, /= for vector types. in addAssignmentArithmeticOverloads()
9562 QualType ParamTypes[2]; in addAssignmentArithmeticOverloads()
9564 // Add this built-in operator as a candidate (VQ is empty). in addAssignmentArithmeticOverloads()
9569 // Add this built-in operator as a candidate (VQ is 'volatile'). in addAssignmentArithmeticOverloads()
9581 // For every triple (L, VQ, R), where L is an integral type, VQ
9585 // VQ L& operator%=(VQ L&, R);
9586 // VQ L& operator<<=(VQ L&, R);
9587 // VQ L& operator>>=(VQ L&, R);
9588 // VQ L& operator&=(VQ L&, R);
9589 // VQ L& operator^=(VQ L&, R);
9590 // VQ L& operator|=(VQ L&, R);
9598 QualType ParamTypes[2]; in addAssignmentIntegralOverloads()
9627 QualType ParamTypes[2] = { S.Context.BoolTy, S.Context.BoolTy }; in addAmpAmpOrPipePipeOverload()
9630 /*NumContextualBoolArguments=*/2); in addAmpAmpOrPipePipeOverload()
9635 // For every cv-qualified or cv-unqualified object type T there
9640 // T* operator-(T*, ptrdiff_t); [ABOVE]
9645 QualType ParamTypes[2] = {PtrTy, S.Context.getPointerDiffType()}; in addSubscriptOverloads()
9646 QualType PointeeType = PtrTy->getPointeeType(); in addSubscriptOverloads()
9647 if (!PointeeType->isObjectType()) in addSubscriptOverloads()
9655 QualType ParamTypes[2] = {S.Context.getPointerDiffType(), PtrTy}; in addSubscriptOverloads()
9656 QualType PointeeType = PtrTy->getPointeeType(); in addSubscriptOverloads()
9657 if (!PointeeType->isObjectType()) in addSubscriptOverloads()
9668 // type or a function type, and CV1 and CV2 are cv-qualifier-seqs,
9671 // CV12 T& operator->*(CV1 C1*, CV2 T C2::*);
9679 C1 = QualType(Q1.strip(C1Ty->getPointeeType()), 0); in addArrowStarOverloads()
9691 QualType C2 = QualType(mptr->getClass(), 0); in addArrowStarOverloads()
9695 QualType ParamTypes[2] = {PtrTy, MemPtrTy}; in addArrowStarOverloads()
9697 QualType T = mptr->getPointeeType(); in addArrowStarOverloads()
9715 // For every type T, where T is a pointer, pointer-to-member, or scoped
9724 for (unsigned ArgIdx = 0; ArgIdx < 2; ++ArgIdx) { in addConditionalOperatorOverloads()
9729 QualType ParamTypes[2] = {PtrTy, PtrTy}; in addConditionalOperatorOverloads()
9737 QualType ParamTypes[2] = {MemPtrTy, MemPtrTy}; in addConditionalOperatorOverloads()
9743 if (!EnumTy->castAs<EnumType>()->getDecl()->isScoped()) in addConditionalOperatorOverloads()
9749 QualType ParamTypes[2] = {EnumTy, EnumTy}; in addConditionalOperatorOverloads()
9764 // if the operator we're looking at has built-in operator candidates in AddBuiltinOperatorCandidates()
9765 // that make use of these types. Also record whether we encounter non-record in AddBuiltinOperatorCandidates()
9771 if (Args[ArgIdx]->getType()->isAtomicType()) in AddBuiltinOperatorCandidates()
9777 SmallVector<BuiltinCandidateTypeSet, 2> CandidateTypes; in AddBuiltinOperatorCandidates()
9780 CandidateTypes[ArgIdx].AddTypesConvertedFrom(Args[ArgIdx]->getType(), in AddBuiltinOperatorCandidates()
9794 // Exit early when no non-record types have been added to the candidate set in AddBuiltinOperatorCandidates()
9827 // -- For the operator ',', the unary operator '&', the in AddBuiltinOperatorCandidates()
9828 // operator '->', or the operator 'co_await', the in AddBuiltinOperatorCandidates()
9829 // built-in candidates set is empty. in AddBuiltinOperatorCandidates()
9837 case OO_Minus: // '-' is either unary or binary in AddBuiltinOperatorCandidates()
9897 // -- For the operator ',', the unary operator '&', or the in AddBuiltinOperatorCandidates()
9898 // operator '->', the built-in candidates set is empty. in AddBuiltinOperatorCandidates()
9941 if (Args.size() == 2) in AddBuiltinOperatorCandidates()
9966 // redundant candidates from the set) relies on pointer-equality, in AddArgumentDependentLookupCandidates()
9979 if (Cand->Function) { in AddArgumentDependentLookupCandidates()
9980 Fns.erase(Cand->Function); in AddArgumentDependentLookupCandidates()
9981 if (FunctionTemplateDecl *FunTmpl = Cand->Function->getPrimaryTemplate()) in AddArgumentDependentLookupCandidates()
10013 *this, Args, FTD->getTemplatedDecl())) { in AddArgumentDependentLookupCandidates()
10042 bool Cand1Attr = Cand1->hasAttr<EnableIfAttr>(); in compareEnableIfAttrs()
10043 bool Cand2Attr = Cand2->hasAttr<EnableIfAttr>(); in compareEnableIfAttrs()
10050 auto Cand1Attrs = Cand1->specific_attrs<EnableIfAttr>(); in compareEnableIfAttrs()
10051 auto Cand2Attrs = Cand2->specific_attrs<EnableIfAttr>(); in compareEnableIfAttrs()
10068 (*Cand1A)->getCond()->Profile(Cand1ID, S.getASTContext(), true); in compareEnableIfAttrs()
10069 (*Cand2A)->getCond()->Profile(Cand2ID, S.getASTContext(), true); in compareEnableIfAttrs()
10080 if (!Cand1.Function || !Cand1.Function->isMultiVersion() || !Cand2.Function || in isBetterMultiversionCandidate()
10081 !Cand2.Function->isMultiVersion()) in isBetterMultiversionCandidate()
10086 if (Cand1.Function->isInvalidDecl()) { in isBetterMultiversionCandidate()
10087 if (Cand2.Function->isInvalidDecl()) in isBetterMultiversionCandidate()
10091 if (Cand2.Function->isInvalidDecl()) in isBetterMultiversionCandidate()
10096 bool Cand1CPUDisp = Cand1.Function->hasAttr<CPUDispatchAttr>(); in isBetterMultiversionCandidate()
10097 bool Cand2CPUDisp = Cand2.Function->hasAttr<CPUDispatchAttr>(); in isBetterMultiversionCandidate()
10098 const auto *Cand1CPUSpec = Cand1.Function->getAttr<CPUSpecificAttr>(); in isBetterMultiversionCandidate()
10099 const auto *Cand2CPUSpec = Cand2.Function->getAttr<CPUSpecificAttr>(); in isBetterMultiversionCandidate()
10110 if (Cand1CPUSpec->cpus_size() != Cand2CPUSpec->cpus_size()) in isBetterMultiversionCandidate()
10111 return Cand1CPUSpec->cpus_size() < Cand2CPUSpec->cpus_size() in isBetterMultiversionCandidate()
10117 Cand1CPUSpec->cpus_begin(), Cand1CPUSpec->cpus_end(), in isBetterMultiversionCandidate()
10118 Cand2CPUSpec->cpus_begin(), in isBetterMultiversionCandidate()
10120 return LHS->getName() == RHS->getName(); in isBetterMultiversionCandidate()
10123 assert(FirstDiff.first != Cand1CPUSpec->cpus_end() && in isBetterMultiversionCandidate()
10124 "Two different cpu-specific versions should not have the same " in isBetterMultiversionCandidate()
10126 return (*FirstDiff.first)->getName() < (*FirstDiff.second)->getName() in isBetterMultiversionCandidate()
10143 if (M->isStatic()) in getImplicitObjectParamType()
10145 return M->getFunctionObjectParameterReferenceType(); in getImplicitObjectParamType()
10154 auto PT1 = F1->getPrimaryTemplate(); in allowAmbiguity()
10155 auto PT2 = F2->getPrimaryTemplate(); in allowAmbiguity()
10158 declaresSameEntity(PT1->getInstantiatedFromMemberTemplate(), in allowAmbiguity()
10159 PT2->getInstantiatedFromMemberTemplate())) in allowAmbiguity()
10170 assert(I < F->getNumParams()); in allowAmbiguity()
10171 return F->getParamDecl(I++)->getType(); in allowAmbiguity()
10174 unsigned F1NumParams = F1->getNumParams() + isa<CXXMethodDecl>(F1); in allowAmbiguity()
10175 unsigned F2NumParams = F2->getNumParams() + isa<CXXMethodDecl>(F2); in allowAmbiguity()
10194 /// F1 and F2 are non-template functions with the same
10195 /// non-object-parameter-type-lists, and F1 is more constrained than F2 [...]
10205 if (Fn1->isVariadic() != Fn2->isVariadic()) in sameFunctionParameterTypeLists()
10217 if (Mem1->getParent() != Mem2->getParent()) in sameFunctionParameterTypeLists()
10219 // if both are non-static member functions, they have the same types for in sameFunctionParameterTypeLists()
10221 if (Mem1->isInstance() && Mem2->isInstance() && in sameFunctionParameterTypeLists()
10223 Mem1->getFunctionObjectParameterReferenceType(), in sameFunctionParameterTypeLists()
10224 Mem1->getFunctionObjectParameterReferenceType())) in sameFunctionParameterTypeLists()
10230 /// isBetterOverloadCandidate - Determines whether the first overload
10235 // Define viable functions to be better candidates than non-viable in isBetterOverloadCandidate()
10247 // be triggered if it is emitted. However a wrong-sided function is still in isBetterOverloadCandidate()
10259 // should take precedence in preference, e.g. the standard-defined preferences in isBetterOverloadCandidate()
10260 // like argument conversion ranks or enable_if partial-ordering. The in isBetterOverloadCandidate()
10261 // preference for pass-object-size parameters is probably most similar to a in isBetterOverloadCandidate()
10262 // type-based-overloading decision and so should take priority. in isBetterOverloadCandidate()
10274 // -fgpu-exclude-wrong-side-overloads is on since this requires deferring in isBetterOverloadCandidate()
10289 // over wrong-sided candidates, overloading resolution may change, which in isBetterOverloadCandidate()
10290 // may result in non-deferrable diagnostics. As a workaround, we let in isBetterOverloadCandidate()
10291 // implicit HD candidates take equal preference as wrong-sided candidates. in isBetterOverloadCandidate()
10313 // -- if F is a static member function, ICS1(F) is defined such in isBetterOverloadCandidate()
10327 // The only ill-formed conversion we allow in C++ is the string literal to in isBetterOverloadCandidate()
10328 // char* conversion, which is only considered ill-formed after C++11. in isBetterOverloadCandidate()
10333 // Define functions that don't require ill-formed conversions for a given in isBetterOverloadCandidate()
10369 // Work around large-scale breakage caused by considering reversed in isBetterOverloadCandidate()
10394 // -- for some argument j, ICSj(F1) is a better conversion sequence than in isBetterOverloadCandidate()
10399 // -- the context is an initialization by user-defined conversion in isBetterOverloadCandidate()
10410 // other. This only distinguishes the results in non-standard, extension in isBetterOverloadCandidate()
10425 // C++14 [over.match.best]p1 section 2 bullet 3. in isBetterOverloadCandidate()
10440 // -- F1 is a non-template function and F2 is a function template in isBetterOverloadCandidate()
10443 Cand1.Function->getPrimaryTemplate(); in isBetterOverloadCandidate()
10445 Cand2.Function->getPrimaryTemplate(); in isBetterOverloadCandidate()
10449 // -- F1 and F2 are function template specializations, and the function in isBetterOverloadCandidate()
10455 dyn_cast<CXXRecordDecl>(Cand1.FoundDecl->getDeclContext()); in isBetterOverloadCandidate()
10457 dyn_cast<CXXRecordDecl>(Cand2.FoundDecl->getDeclContext()); in isBetterOverloadCandidate()
10459 Cand1.Function->getPrimaryTemplate(), in isBetterOverloadCandidate()
10460 Cand2.Function->getPrimaryTemplate(), Loc, in isBetterOverloadCandidate()
10464 Obj1Context ? QualType(Obj1Context->getTypeForDecl(), 0) in isBetterOverloadCandidate()
10466 Obj2Context ? QualType(Obj2Context->getTypeForDecl(), 0) in isBetterOverloadCandidate()
10469 return BetterTemplate == Cand1.Function->getPrimaryTemplate(); in isBetterOverloadCandidate()
10473 // -— F1 and F2 are non-template functions with the same in isBetterOverloadCandidate()
10474 // parameter-type-lists, and F1 is more constrained than F2 [...], in isBetterOverloadCandidate()
10481 // -- F1 is a constructor for a class D, F2 is a constructor for a base in isBetterOverloadCandidate()
10493 auto *Cand1Class = cast<CXXRecordDecl>(Cand1.Function->getDeclContext()); in isBetterOverloadCandidate()
10494 auto *Cand2Class = cast<CXXRecordDecl>(Cand2.Function->getDeclContext()); in isBetterOverloadCandidate()
10495 if (Cand1Class->isDerivedFrom(Cand2Class)) in isBetterOverloadCandidate()
10497 if (Cand2Class->isDerivedFrom(Cand1Class)) in isBetterOverloadCandidate()
10502 // -- F2 is a rewritten candidate (12.4.1.2) and F1 is not in isBetterOverloadCandidate()
10503 // -- F1 and F2 are rewritten candidates, and F2 is a synthesized candidate in isBetterOverloadCandidate()
10508 // the maximally-rewritten operator (== or <=>). in isBetterOverloadCandidate()
10512 // Check C++17 tie-breakers for deduction guides. in isBetterOverloadCandidate()
10517 // -- F1 is generated from a deduction-guide and F2 is not in isBetterOverloadCandidate()
10518 if (Guide1->isImplicit() != Guide2->isImplicit()) in isBetterOverloadCandidate()
10519 return Guide2->isImplicit(); in isBetterOverloadCandidate()
10521 // -- F1 is the copy deduction candidate(16.3.1.8) and F2 is not in isBetterOverloadCandidate()
10522 if (Guide1->getDeductionCandidateKind() == DeductionCandidate::Copy) in isBetterOverloadCandidate()
10524 if (Guide2->getDeductionCandidateKind() == DeductionCandidate::Copy) in isBetterOverloadCandidate()
10527 // --F1 is generated from a non-template constructor and F2 is generated in isBetterOverloadCandidate()
10529 const auto *Constructor1 = Guide1->getCorrespondingConstructor(); in isBetterOverloadCandidate()
10530 const auto *Constructor2 = Guide2->getCorrespondingConstructor(); in isBetterOverloadCandidate()
10532 bool isC1Templated = Constructor1->getTemplatedKind() != in isBetterOverloadCandidate()
10534 bool isC2Templated = Constructor2->getTemplatedKind() != in isBetterOverloadCandidate()
10542 // Check for enable_if value-based overload resolution. in isBetterOverloadCandidate()
10577 LangAS AS1 = CD1->getMethodQualifiers().getAddressSpace(); in isBetterOverloadCandidate()
10578 LangAS AS2 = CD2->getMethodQualifiers().getAddressSpace(); in isBetterOverloadCandidate()
10606 if (!VA->getDeclContext()->getRedeclContext()->Equals( in isEquivalentInternalLinkageDeclaration()
10607 VB->getDeclContext()->getRedeclContext()) || in isEquivalentInternalLinkageDeclaration()
10609 VA->isExternallyVisible() || VB->isExternallyVisible()) in isEquivalentInternalLinkageDeclaration()
10616 // the same. For non-constant variables, we shouldn't allow it at all. in isEquivalentInternalLinkageDeclaration()
10617 if (Context.hasSameType(VA->getType(), VB->getType())) in isEquivalentInternalLinkageDeclaration()
10626 auto *EnumA = cast<EnumDecl>(EA->getDeclContext()); in isEquivalentInternalLinkageDeclaration()
10627 auto *EnumB = cast<EnumDecl>(EB->getDeclContext()); in isEquivalentInternalLinkageDeclaration()
10628 if (EnumA->hasNameForLinkage() || EnumB->hasNameForLinkage() || in isEquivalentInternalLinkageDeclaration()
10629 !Context.hasSameType(EnumA->getIntegerType(), in isEquivalentInternalLinkageDeclaration()
10630 EnumB->getIntegerType())) in isEquivalentInternalLinkageDeclaration()
10633 return llvm::APSInt::isSameValue(EA->getInitVal(), EB->getInitVal()); in isEquivalentInternalLinkageDeclaration()
10647 Diag(D->getLocation(), diag::note_equivalent_internal_linkage_decl) in diagnoseEquivalentInternalLinkageDeclarations()
10648 << !M << (M ? M->getFullModuleName() : ""); in diagnoseEquivalentInternalLinkageDeclarations()
10652 Diag(E->getLocation(), diag::note_equivalent_internal_linkage_decl) in diagnoseEquivalentInternalLinkageDeclarations()
10653 << !M << (M ? M->getFullModuleName() : ""); in diagnoseEquivalentInternalLinkageDeclarations()
10662 ->Satisfaction.ContainsErrors; in NotValidBecauseConstraintExprHasError()
10682 // [CUDA] HD->H or HD->D calls are technically not allowed by CUDA but in BestViableFunction()
10685 // exclude non-viable overload candidates from consideration based in BestViableFunction()
10689 // We only need to remove wrong-sided candidates here if in BestViableFunction()
10690 // -fgpu-exclude-wrong-side-overloads is off. When in BestViableFunction()
10691 // -fgpu-exclude-wrong-side-overloads is on, all candidates are compared in BestViableFunction()
10698 return Cand->Viable && Cand->Function && in BestViableFunction()
10699 S.CUDA().IdentifyPreference(Caller, Cand->Function) == in BestViableFunction()
10705 return Cand->Viable && Cand->Function && in BestViableFunction()
10706 S.CUDA().IdentifyPreference(Caller, Cand->Function) == in BestViableFunction()
10716 Cand->Best = false; in BestViableFunction()
10717 if (Cand->Viable) { in BestViableFunction()
10721 } else if (Cand->NotValidBecauseConstraintExprHasError()) { in BestViableFunction()
10739 Best->Best = true; in BestViableFunction()
10746 if (Cand->Viable && !Cand->Best && in BestViableFunction()
10749 Cand->Best = true; in BestViableFunction()
10751 if (S.isEquivalentInternalLinkageDeclaration(Cand->Function, in BestViableFunction()
10752 Curr->Function)) in BestViableFunction()
10753 EquivalentCands.push_back(Cand->Function); in BestViableFunction()
10765 if (Best->Function && Best->Function->isDeleted()) in BestViableFunction()
10768 if (auto *M = dyn_cast_or_null<CXXMethodDecl>(Best->Function); in BestViableFunction()
10770 M->isImplicitObjectMemberFunction()) { in BestViableFunction()
10775 S.diagnoseEquivalentInternalLinkageDeclarations(Loc, Best->Function, in BestViableFunction()
10809 bool isTemplate = Fn->isTemplateDecl() || Found->isTemplateDecl(); in ClassifyOverloadCandidate()
10810 if (FunctionTemplateDecl *FunTmpl = Fn->getPrimaryTemplate()) { in ClassifyOverloadCandidate()
10813 FunTmpl->getTemplateParameters(), *Fn->getTemplateSpecializationArgs()); in ClassifyOverloadCandidate()
10823 if (Fn->isImplicit() && Fn->getOverloadedOperator() == OO_EqualEqual) in ClassifyOverloadCandidate()
10830 if (!Ctor->isImplicit()) { in ClassifyOverloadCandidate()
10837 if (Ctor->isDefaultConstructor()) in ClassifyOverloadCandidate()
10840 if (Ctor->isMoveConstructor()) in ClassifyOverloadCandidate()
10843 assert(Ctor->isCopyConstructor() && in ClassifyOverloadCandidate()
10851 if (!Meth->isImplicit()) in ClassifyOverloadCandidate()
10854 if (Meth->isMoveAssignmentOperator()) in ClassifyOverloadCandidate()
10857 if (Meth->isCopyAssignmentOperator()) in ClassifyOverloadCandidate()
10871 // FIXME: It'd be nice to only emit a note once per using-decl per overload in MaybeEmitInheritedConstructorNote()
10874 S.Diag(FoundDecl->getLocation(), in MaybeEmitInheritedConstructorNote()
10876 << Shadow->getNominatedBaseClass(); in MaybeEmitInheritedConstructorNote()
10883 for (auto *EnableIf : FD->specific_attrs<EnableIfAttr>()) { in isFunctionAlwaysEnabled()
10885 if (EnableIf->getCond()->isValueDependent() || in isFunctionAlwaysEnabled()
10886 !EnableIf->getCond()->EvaluateAsBooleanCondition(AlwaysTrue, Ctx)) in isFunctionAlwaysEnabled()
10896 /// \param Complain - If true, we'll emit a diagnostic
10897 /// \param InOverloadResolution - For the purposes of emitting a diagnostic, are
10899 /// \param Loc - The location of the statement we're complaining about. Ignored
10908 S.Diag(FD->getBeginLoc(), in checkAddressOfFunctionIsAvailable()
10916 if (FD->getTrailingRequiresClause()) { in checkAddressOfFunctionIsAvailable()
10924 if (FunctionTemplateDecl *FunTmpl = FD->getPrimaryTemplate()) { in checkAddressOfFunctionIsAvailable()
10927 FunTmpl->getTemplateParameters(), in checkAddressOfFunctionIsAvailable()
10928 *FD->getTemplateSpecializationArgs()); in checkAddressOfFunctionIsAvailable()
10931 S.Diag(FD->getBeginLoc(), in checkAddressOfFunctionIsAvailable()
10943 auto I = llvm::find_if(FD->parameters(), [](const ParmVarDecl *P) { in checkAddressOfFunctionIsAvailable()
10944 return P->hasAttr<PassObjectSizeAttr>(); in checkAddressOfFunctionIsAvailable()
10946 if (I == FD->param_end()) in checkAddressOfFunctionIsAvailable()
10950 // Add one to ParamNo because it's user-facing in checkAddressOfFunctionIsAvailable()
10951 unsigned ParamNo = std::distance(FD->param_begin(), I) + 1; in checkAddressOfFunctionIsAvailable()
10953 S.Diag(FD->getLocation(), in checkAddressOfFunctionIsAvailable()
10985 const auto *RD = cast<CXXRecordDecl>(Fn->getParent()); in shouldSkipNotingLambdaConversionDecl()
10986 if (!RD->isLambda()) in shouldSkipNotingLambdaConversionDecl()
10989 CXXMethodDecl *CallOp = RD->getLambdaCallOperator(); in shouldSkipNotingLambdaConversionDecl()
10991 CallOp->getType()->castAs<FunctionType>()->getCallConv(); in shouldSkipNotingLambdaConversionDecl()
10992 QualType ConvRTy = ConvD->getType()->castAs<FunctionType>()->getReturnType(); in shouldSkipNotingLambdaConversionDecl()
10994 ConvRTy->getPointeeType()->castAs<FunctionType>()->getCallConv(); in shouldSkipNotingLambdaConversionDecl()
11005 if (Fn->isMultiVersion() && Fn->hasAttr<TargetAttr>() && in NoteOverloadCandidate()
11006 !Fn->getAttr<TargetAttr>()->isDefaultVersion()) in NoteOverloadCandidate()
11008 if (Fn->isMultiVersion() && Fn->hasAttr<TargetVersionAttr>() && in NoteOverloadCandidate()
11009 !Fn->getAttr<TargetVersionAttr>()->isDefaultVersion()) in NoteOverloadCandidate()
11021 HandleFunctionTypeMismatch(PD, Fn->getType(), DestType); in NoteOverloadCandidate()
11022 Diag(Fn->getLocation(), PD); in NoteOverloadCandidate()
11032 // void foo() requires (sizeof(T) > 4) && T::value { } // #2 in MaybeDiagnoseAmbiguousConstraints()
11035 // #2 to subsume #1, but these constraint are not considered equivalent in MaybeDiagnoseAmbiguousConstraints()
11037 // source-level construct. This behavior is quite confusing and we should try in MaybeDiagnoseAmbiguousConstraints()
11043 if (!I->Function) in MaybeDiagnoseAmbiguousConstraints()
11046 if (auto *Template = I->Function->getPrimaryTemplate()) in MaybeDiagnoseAmbiguousConstraints()
11047 Template->getAssociatedConstraints(AC); in MaybeDiagnoseAmbiguousConstraints()
11049 I->Function->getAssociatedConstraints(AC); in MaybeDiagnoseAmbiguousConstraints()
11053 FirstCand = I->Function; in MaybeDiagnoseAmbiguousConstraints()
11056 SecondCand = I->Function; in MaybeDiagnoseAmbiguousConstraints()
11059 // We have more than one pair of constrained functions - this check is in MaybeDiagnoseAmbiguousConstraints()
11079 assert(OverloadedExpr->getType() == Context.OverloadTy); in NoteAllOverloadCandidates()
11081 OverloadExpr::FindResult Ovl = OverloadExpr::find(OverloadedExpr); in NoteAllOverloadCandidates() local
11082 OverloadExpr *OvlExpr = Ovl.Expression; in NoteAllOverloadCandidates()
11084 for (UnresolvedSetIterator I = OvlExpr->decls_begin(), in NoteAllOverloadCandidates()
11085 IEnd = OvlExpr->decls_end(); in NoteAllOverloadCandidates()
11088 dyn_cast<FunctionTemplateDecl>((*I)->getUnderlyingDecl()) ) { in NoteAllOverloadCandidates()
11089 NoteOverloadCandidate(*I, FunTmpl->getTemplatedDecl(), CRK_None, DestType, in NoteAllOverloadCandidates()
11092 = dyn_cast<FunctionDecl>((*I)->getUnderlyingDecl()) ) { in NoteAllOverloadCandidates()
11113 S.NoteOverloadCandidate(I->first, I->second); in DiagnoseAmbiguousConversion()
11117 S.Diag(SourceLocation(), diag::note_ovl_too_many_candidates) << int(E - I); in DiagnoseAmbiguousConversion()
11122 const ImplicitConversionSequence &Conv = Cand->Conversions[I]; in DiagnoseBadConversion()
11124 assert(Cand->Function && "for now, candidate must be a function"); in DiagnoseBadConversion()
11125 FunctionDecl *Fn = Cand->Function; in DiagnoseBadConversion()
11128 // non-constructor method. Note that 'I' corresponds the in DiagnoseBadConversion()
11129 // conversion-slot index. in DiagnoseBadConversion()
11135 I--; in DiagnoseBadConversion()
11140 ClassifyOverloadCandidate(S, Cand->FoundDecl, Fn, Cand->getRewriteKind(), in DiagnoseBadConversion()
11151 llvm::any_of(Fn->parameters().take_front(I), [](const ParmVarDecl *Parm) { in DiagnoseBadConversion()
11152 return Parm->isParameterPack(); in DiagnoseBadConversion()
11155 ToParamRange = Fn->getParamDecl(I)->getSourceRange(); in DiagnoseBadConversion()
11159 Expr *E = FromExpr->IgnoreParens(); in DiagnoseBadConversion()
11161 E = cast<UnaryOperator>(E)->getSubExpr()->IgnoreParens(); in DiagnoseBadConversion()
11162 DeclarationName Name = cast<OverloadExpr>(E)->getName(); in DiagnoseBadConversion()
11164 S.Diag(Fn->getLocation(), diag::note_ovl_candidate_bad_overload) in DiagnoseBadConversion()
11167 MaybeEmitInheritedConstructorNote(S, Cand->FoundDecl); in DiagnoseBadConversion()
11171 // Do some hand-waving analysis to see if the non-viability is due in DiagnoseBadConversion()
11175 if (CanQual<ReferenceType> RT = CToTy->getAs<ReferenceType>()) in DiagnoseBadConversion()
11176 CToTy = RT->getPointeeType(); in DiagnoseBadConversion()
11179 if (CanQual<PointerType> FromPT = CFromTy->getAs<PointerType>()) in DiagnoseBadConversion()
11180 if (CanQual<PointerType> ToPT = CToTy->getAs<PointerType>()) { in DiagnoseBadConversion()
11181 CFromTy = FromPT->getPointeeType(); in DiagnoseBadConversion()
11182 CToTy = ToPT->getPointeeType(); in DiagnoseBadConversion()
11193 S.Diag(Fn->getLocation(), diag::note_ovl_candidate_bad_addrspace_this) in DiagnoseBadConversion()
11197 S.Diag(Fn->getLocation(), diag::note_ovl_candidate_bad_addrspace) in DiagnoseBadConversion()
11200 << ToQs.getAddressSpace() << ToTy->isReferenceType() << I + 1; in DiagnoseBadConversion()
11201 MaybeEmitInheritedConstructorNote(S, Cand->FoundDecl); in DiagnoseBadConversion()
11206 S.Diag(Fn->getLocation(), diag::note_ovl_candidate_bad_ownership) in DiagnoseBadConversion()
11210 MaybeEmitInheritedConstructorNote(S, Cand->FoundDecl); in DiagnoseBadConversion()
11215 S.Diag(Fn->getLocation(), diag::note_ovl_candidate_bad_gc) in DiagnoseBadConversion()
11219 MaybeEmitInheritedConstructorNote(S, Cand->FoundDecl); in DiagnoseBadConversion()
11227 S.Diag(Fn->getLocation(), diag::note_ovl_candidate_bad_cvr_this) in DiagnoseBadConversion()
11229 << FromTy << (CVR - 1); in DiagnoseBadConversion()
11231 S.Diag(Fn->getLocation(), diag::note_ovl_candidate_bad_cvr) in DiagnoseBadConversion()
11233 << ToParamRange << FromTy << (CVR - 1) << I + 1; in DiagnoseBadConversion()
11235 MaybeEmitInheritedConstructorNote(S, Cand->FoundDecl); in DiagnoseBadConversion()
11241 S.Diag(Fn->getLocation(), diag::note_ovl_candidate_bad_value_category) in DiagnoseBadConversion()
11246 MaybeEmitInheritedConstructorNote(S, Cand->FoundDecl); in DiagnoseBadConversion()
11253 S.Diag(Fn->getLocation(), diag::note_ovl_candidate_bad_list_argument) in DiagnoseBadConversion()
11258 ? 2 in DiagnoseBadConversion()
11260 MaybeEmitInheritedConstructorNote(S, Cand->FoundDecl); in DiagnoseBadConversion()
11268 if (const PointerType *PTy = TempFromTy->getAs<PointerType>()) in DiagnoseBadConversion()
11269 TempFromTy = PTy->getPointeeType(); in DiagnoseBadConversion()
11270 if (TempFromTy->isIncompleteType()) { in DiagnoseBadConversion()
11272 S.Diag(Fn->getLocation(), diag::note_ovl_candidate_bad_conv_incomplete) in DiagnoseBadConversion()
11275 << (unsigned)(Cand->Fix.Kind); in DiagnoseBadConversion()
11277 MaybeEmitInheritedConstructorNote(S, Cand->FoundDecl); in DiagnoseBadConversion()
11281 // Diagnose base -> derived pointer conversions. in DiagnoseBadConversion()
11283 if (const PointerType *FromPtrTy = FromTy->getAs<PointerType>()) { in DiagnoseBadConversion()
11284 if (const PointerType *ToPtrTy = ToTy->getAs<PointerType>()) { in DiagnoseBadConversion()
11285 if (ToPtrTy->getPointeeType().isAtLeastAsQualifiedAs( in DiagnoseBadConversion()
11286 FromPtrTy->getPointeeType()) && in DiagnoseBadConversion()
11287 !FromPtrTy->getPointeeType()->isIncompleteType() && in DiagnoseBadConversion()
11288 !ToPtrTy->getPointeeType()->isIncompleteType() && in DiagnoseBadConversion()
11289 S.IsDerivedFrom(SourceLocation(), ToPtrTy->getPointeeType(), in DiagnoseBadConversion()
11290 FromPtrTy->getPointeeType())) in DiagnoseBadConversion()
11294 = FromTy->getAs<ObjCObjectPointerType>()) { in DiagnoseBadConversion()
11296 = ToTy->getAs<ObjCObjectPointerType>()) in DiagnoseBadConversion()
11297 if (const ObjCInterfaceDecl *FromIface = FromPtrTy->getInterfaceDecl()) in DiagnoseBadConversion()
11298 if (const ObjCInterfaceDecl *ToIface = ToPtrTy->getInterfaceDecl()) in DiagnoseBadConversion()
11299 if (ToPtrTy->getPointeeType().isAtLeastAsQualifiedAs( in DiagnoseBadConversion()
11300 FromPtrTy->getPointeeType()) && in DiagnoseBadConversion()
11301 FromIface->isSuperClassOf(ToIface)) in DiagnoseBadConversion()
11302 BaseToDerivedConversion = 2; in DiagnoseBadConversion()
11303 } else if (const ReferenceType *ToRefTy = ToTy->getAs<ReferenceType>()) { in DiagnoseBadConversion()
11304 if (ToRefTy->getPointeeType().isAtLeastAsQualifiedAs(FromTy) && in DiagnoseBadConversion()
11305 !FromTy->isIncompleteType() && in DiagnoseBadConversion()
11306 !ToRefTy->getPointeeType()->isIncompleteType() && in DiagnoseBadConversion()
11307 S.IsDerivedFrom(SourceLocation(), ToRefTy->getPointeeType(), FromTy)) { in DiagnoseBadConversion()
11313 S.Diag(Fn->getLocation(), diag::note_ovl_candidate_bad_base_to_derived_conv) in DiagnoseBadConversion()
11315 << ToParamRange << (BaseToDerivedConversion - 1) << FromTy << ToTy in DiagnoseBadConversion()
11317 MaybeEmitInheritedConstructorNote(S, Cand->FoundDecl); in DiagnoseBadConversion()
11326 S.Diag(Fn->getLocation(), diag::note_ovl_candidate_bad_arc_conv) in DiagnoseBadConversion()
11330 MaybeEmitInheritedConstructorNote(S, Cand->FoundDecl); in DiagnoseBadConversion()
11336 !checkAddressOfCandidateIsAvailable(S, Cand->Function)) in DiagnoseBadConversion()
11343 << (unsigned)(Cand->Fix.Kind); in DiagnoseBadConversion()
11346 if (!S.SourceMgr.isInSystemHeader(Fn->getLocation())) { in DiagnoseBadConversion()
11348 for (const FixItHint &HI : Cand->Fix.Hints) in DiagnoseBadConversion()
11352 S.Diag(Fn->getLocation(), FDiag); in DiagnoseBadConversion()
11354 MaybeEmitInheritedConstructorNote(S, Cand->FoundDecl); in DiagnoseBadConversion()
11362 FunctionDecl *Fn = Cand->Function; in CheckArityMismatch()
11363 unsigned MinParams = Fn->getMinRequiredExplicitArguments() + in CheckArityMismatch()
11364 ((IsAddressOf && !Fn->isStatic()) ? 1 : 0); in CheckArityMismatch()
11369 // the weird behavior of overloading member and non-member functions. in CheckArityMismatch()
11371 if (Fn->isInvalidDecl() && in CheckArityMismatch()
11372 Fn->getDeclName().getNameKind() == DeclarationName::CXXOperatorName) in CheckArityMismatch()
11376 assert((Cand->FailureKind == ovl_fail_too_few_arguments) || in CheckArityMismatch()
11377 (Cand->FailureKind == ovl_fail_bad_deduction && in CheckArityMismatch()
11378 Cand->DeductionFailure.getResult() == in CheckArityMismatch()
11381 assert((Cand->FailureKind == ovl_fail_too_many_arguments) || in CheckArityMismatch()
11382 (Cand->FailureKind == ovl_fail_bad_deduction && in CheckArityMismatch()
11383 Cand->DeductionFailure.getResult() == in CheckArityMismatch()
11402 const auto *FnTy = Fn->getType()->castAs<FunctionProtoType>(); in DiagnoseArityMismatch()
11403 unsigned MinParams = Fn->getMinRequiredExplicitArguments() + in DiagnoseArityMismatch()
11404 ((IsAddressOf && !Fn->isStatic()) ? 1 : 0); in DiagnoseArityMismatch()
11408 !IsAddressOf && Fn->hasCXXExplicitFunctionObjectParameter(); in DiagnoseArityMismatch()
11411 Fn->getNumNonObjectParams() + ((IsAddressOf && !Fn->isStatic()) ? 1 : 0); in DiagnoseArityMismatch()
11415 if (MinParams != ParamCount || FnTy->isVariadic() || in DiagnoseArityMismatch()
11416 FnTy->isTemplateVariadic()) in DiagnoseArityMismatch()
11419 mode = 2; // "exactly" in DiagnoseArityMismatch()
11425 mode = 2; // "exactly" in DiagnoseArityMismatch()
11434 Fn->getParamDecl(HasExplicitObjectParam ? 1 : 0)->getDeclName()) in DiagnoseArityMismatch()
11435 S.Diag(Fn->getLocation(), diag::note_ovl_candidate_arity_one) in DiagnoseArityMismatch()
11438 << Fn->getParamDecl(HasExplicitObjectParam ? 1 : 0) << NumFormalArgs in DiagnoseArityMismatch()
11439 << HasExplicitObjectParam << Fn->getParametersSourceRange(); in DiagnoseArityMismatch()
11441 S.Diag(Fn->getLocation(), diag::note_ovl_candidate_arity) in DiagnoseArityMismatch()
11444 << HasExplicitObjectParam << Fn->getParametersSourceRange(); in DiagnoseArityMismatch()
11452 if (!CheckArityMismatch(S, Cand, NumFormalArgs, Cand->TookAddressOfOverload)) in DiagnoseArityMismatch()
11453 DiagnoseArityMismatch(S, Cand->FoundDecl, Cand->Function, NumFormalArgs, in DiagnoseArityMismatch()
11454 Cand->TookAddressOfOverload); in DiagnoseArityMismatch()
11458 if (TemplateDecl *TD = Templated->getDescribedTemplate()) in getDescribedTemplate()
11464 /// Diagnose a failed template-argument deduction.
11487 S.Diag(Templated->getLocation(), in DiagnoseBadDeduction()
11489 << ParamD->getDeclName(); in DiagnoseBadDeduction()
11496 S.Diag(Templated->getLocation(), in DiagnoseBadDeduction()
11498 << ParamD->getDeclName() in DiagnoseBadDeduction()
11499 << (DeductionFailure.getFirstArg()->pack_size() + 1) in DiagnoseBadDeduction()
11509 QualType Param = DeductionFailure.getFirstArg()->getAsType(); in DiagnoseBadDeduction()
11515 QualType NonCanonParam = Qs.apply(S.Context, TParam->getTypeForDecl()); in DiagnoseBadDeduction()
11522 QualType Arg = DeductionFailure.getSecondArg()->getAsType(); in DiagnoseBadDeduction()
11524 S.Diag(Templated->getLocation(), diag::note_ovl_candidate_underqualified) in DiagnoseBadDeduction()
11525 << ParamD->getDeclName() << Arg << NonCanonParam; in DiagnoseBadDeduction()
11537 // different types for a non-type template parameter. in DiagnoseBadDeduction()
11540 DeductionFailure.getFirstArg()->getNonTypeTemplateArgumentType(); in DiagnoseBadDeduction()
11542 DeductionFailure.getSecondArg()->getNonTypeTemplateArgumentType(); in DiagnoseBadDeduction()
11544 S.Diag(Templated->getLocation(), in DiagnoseBadDeduction()
11546 << ParamD->getDeclName() << *DeductionFailure.getFirstArg() << T1 in DiagnoseBadDeduction()
11554 which = 2; in DiagnoseBadDeduction()
11560 if (DeductionFailure.getFirstArg()->getKind() == TemplateArgument::Pack && in DiagnoseBadDeduction()
11561 DeductionFailure.getSecondArg()->getKind() == TemplateArgument::Pack && in DiagnoseBadDeduction()
11562 DeductionFailure.getFirstArg()->pack_size() != in DiagnoseBadDeduction()
11563 DeductionFailure.getSecondArg()->pack_size()) { in DiagnoseBadDeduction()
11567 S.Diag(Templated->getLocation(), in DiagnoseBadDeduction()
11569 << which << ParamD->getDeclName() << *DeductionFailure.getFirstArg() in DiagnoseBadDeduction()
11577 if (ParamD->getDeclName()) in DiagnoseBadDeduction()
11578 S.Diag(Templated->getLocation(), in DiagnoseBadDeduction()
11580 << ParamD->getDeclName(); in DiagnoseBadDeduction()
11584 index = TTP->getIndex(); in DiagnoseBadDeduction()
11587 index = NTTP->getIndex(); in DiagnoseBadDeduction()
11589 index = cast<TemplateTemplateParmDecl>(ParamD)->getIndex(); in DiagnoseBadDeduction()
11590 S.Diag(Templated->getLocation(), in DiagnoseBadDeduction()
11603 getDescribedTemplate(Templated)->getTemplateParameters(), *Args); in DiagnoseBadDeduction()
11606 S.Diag(Templated->getLocation(), in DiagnoseBadDeduction()
11611 static_cast<CNSInfo*>(DeductionFailure.Data)->Satisfaction); in DiagnoseBadDeduction()
11620 S.Diag(Templated->getLocation(), in DiagnoseBadDeduction()
11632 getDescribedTemplate(Templated)->getTemplateParameters(), *Args); in DiagnoseBadDeduction()
11639 if (PDiag && PDiag->second.getDiagID() == in DiagnoseBadDeduction()
11641 // FIXME: Use the source range of the condition, and the fully-qualified in DiagnoseBadDeduction()
11643 S.Diag(PDiag->first, diag::note_ovl_candidate_disabled_by_enable_if) in DiagnoseBadDeduction()
11649 if (PDiag && PDiag->second.getDiagID() == in DiagnoseBadDeduction()
11651 S.Diag(Templated->getLocation(), in DiagnoseBadDeduction()
11653 << PDiag->second.getStringArg(0) << TemplateArgString; in DiagnoseBadDeduction()
11664 R = SourceRange(PDiag->first, PDiag->first); in DiagnoseBadDeduction()
11665 PDiag->second.EmitToString(S.getDiagnostics(), SFINAEArgString); in DiagnoseBadDeduction()
11668 S.Diag(Templated->getLocation(), in DiagnoseBadDeduction()
11683 getDescribedTemplate(Templated)->getTemplateParameters(), *Args); in DiagnoseBadDeduction()
11688 S.Diag(Templated->getLocation(), diag::note_ovl_candidate_deduced_mismatch) in DiagnoseBadDeduction()
11707 if (FirstTN.getAsTemplateDecl()->getName() == in DiagnoseBadDeduction()
11708 SecondTN.getAsTemplateDecl()->getName()) { in DiagnoseBadDeduction()
11712 // 2) The diagnostic printer only attempts to find a better in DiagnoseBadDeduction()
11715 S.Diag(Templated->getLocation(), in DiagnoseBadDeduction()
11731 S.Diag(Templated->getLocation(), in DiagnoseBadDeduction()
11739 S.Diag(Templated->getLocation(), diag::note_ovl_candidate_bad_deduction); in DiagnoseBadDeduction()
11743 S.Diag(Templated->getLocation(), in DiagnoseBadDeduction()
11749 /// Diagnose a failed template-argument deduction, for function calls.
11753 TemplateDeductionResult TDK = Cand->DeductionFailure.getResult(); in DiagnoseBadDeduction()
11759 DiagnoseBadDeduction(S, Cand->FoundDecl, Cand->Function, // pattern in DiagnoseBadDeduction()
11760 Cand->DeductionFailure, NumArgs, TakingCandidateAddress); in DiagnoseBadDeduction()
11766 FunctionDecl *Callee = Cand->Function; in DiagnoseBadTarget()
11773 ClassifyOverloadCandidate(S, Cand->FoundDecl, Callee, in DiagnoseBadTarget()
11774 Cand->getRewriteKind(), FnDesc); in DiagnoseBadTarget()
11776 S.Diag(Callee->getLocation(), diag::note_ovl_candidate_bad_target) in DiagnoseBadTarget()
11784 if (Meth != nullptr && Meth->isImplicit()) { in DiagnoseBadTarget()
11785 CXXRecordDecl *ParentClass = Meth->getParent(); in DiagnoseBadTarget()
11809 if (Meth->getNumParams()) { in DiagnoseBadTarget()
11811 Meth->getParamDecl(0)->getType()->getAs<ReferenceType>()) { in DiagnoseBadTarget()
11812 ConstRHS = RT->getPointeeType().isConstQualified(); in DiagnoseBadTarget()
11823 FunctionDecl *Callee = Cand->Function; in DiagnoseFailedEnableIfAttr()
11824 EnableIfAttr *Attr = static_cast<EnableIfAttr*>(Cand->DeductionFailure.Data); in DiagnoseFailedEnableIfAttr()
11826 S.Diag(Callee->getLocation(), in DiagnoseFailedEnableIfAttr()
11828 << Attr->getCond()->getSourceRange() << Attr->getMessage(); in DiagnoseFailedEnableIfAttr()
11832 ExplicitSpecifier ES = ExplicitSpecifier::getFromDecl(Cand->Function); in DiagnoseFailedExplicitSpec()
11836 switch (Cand->Function->getDeclKind()) { in DiagnoseFailedExplicitSpec()
11844 Kind = Cand->Function->isImplicit() ? 0 : 2; in DiagnoseFailedExplicitSpec()
11850 // Note the location of the first (in-class) declaration; a redeclaration in DiagnoseFailedExplicitSpec()
11851 // (particularly an out-of-class definition) will typically lack the in DiagnoseFailedExplicitSpec()
11854 FunctionDecl *First = Cand->Function->getFirstDecl(); in DiagnoseFailedExplicitSpec()
11855 if (FunctionDecl *Pattern = First->getTemplateInstantiationPattern()) in DiagnoseFailedExplicitSpec()
11856 First = Pattern->getFirstDecl(); in DiagnoseFailedExplicitSpec()
11858 S.Diag(First->getLocation(), in DiagnoseFailedExplicitSpec()
11861 << (ES.getExpr() ? ES.getExpr()->getSourceRange() : SourceRange()); in DiagnoseFailedExplicitSpec()
11869 DG->getDeclName().getCXXDeductionGuideTemplate(); in NoteImplicitDeductionGuide()
11872 if (!(DG->isImplicit() || (OriginTemplate && OriginTemplate->isTypeAlias()))) in NoteImplicitDeductionGuide()
11876 FunctionTemplateDecl *Template = DG->getDescribedFunctionTemplate(); in NoteImplicitDeductionGuide()
11880 DG->getTemplateInstantiationPattern(/*ForDefinition=*/false); in NoteImplicitDeductionGuide()
11882 // The implicit deduction guide is built on an explicit non-template in NoteImplicitDeductionGuide()
11885 // FIXME: Add a test once https://github.com/llvm/llvm-project/pull/96686 in NoteImplicitDeductionGuide()
11887 assert(OriginTemplate->isTypeAlias() && in NoteImplicitDeductionGuide()
11888 "Non-template implicit deduction guides are only possible for " in NoteImplicitDeductionGuide()
11890 DG->print(OS); in NoteImplicitDeductionGuide()
11891 S.Diag(DG->getLocation(), diag::note_implicit_deduction_guide) in NoteImplicitDeductionGuide()
11895 Template = Pattern->getDescribedFunctionTemplate(); in NoteImplicitDeductionGuide()
11899 Template->print(OS); in NoteImplicitDeductionGuide()
11900 S.Diag(DG->getLocation(), diag::note_implicit_deduction_guide) in NoteImplicitDeductionGuide()
11914 /// It would be great to be able to express per-candidate problems
11923 FunctionDecl *Fn = Cand->Function; in NoteFunctionCandidate()
11930 if (S.getLangOpts().OpenCL && Fn->isImplicit() && in NoteFunctionCandidate()
11931 Cand->FailureKind != ovl_fail_bad_conversion) in NoteFunctionCandidate()
11936 if (Cand->TookAddressOfOverload && in NoteFunctionCandidate()
11937 !Cand->Function->hasCXXExplicitFunctionObjectParameter() && in NoteFunctionCandidate()
11938 !Cand->Function->isStatic()) in NoteFunctionCandidate()
11942 if (Cand->Viable) { in NoteFunctionCandidate()
11943 if (Fn->isDeleted()) { in NoteFunctionCandidate()
11946 ClassifyOverloadCandidate(S, Cand->FoundDecl, Fn, in NoteFunctionCandidate()
11947 Cand->getRewriteKind(), FnDesc); in NoteFunctionCandidate()
11949 S.Diag(Fn->getLocation(), diag::note_ovl_candidate_deleted) in NoteFunctionCandidate()
11951 << (Fn->isDeleted() ? (Fn->isDeletedAsWritten() ? 1 : 2) : 0); in NoteFunctionCandidate()
11952 MaybeEmitInheritedConstructorNote(S, Cand->FoundDecl); in NoteFunctionCandidate()
11957 S.NoteOverloadCandidate(Cand->FoundDecl, Fn, Cand->getRewriteKind()); in NoteFunctionCandidate()
11972 switch (Cand->FailureKind) { in NoteFunctionCandidate()
11982 S.Diag(Fn->getLocation(), diag::note_ovl_candidate_illegal_constructor) in NoteFunctionCandidate()
11983 << (Fn->getPrimaryTemplate() ? 1 : 0); in NoteFunctionCandidate()
11984 MaybeEmitInheritedConstructorNote(S, Cand->FoundDecl); in NoteFunctionCandidate()
11991 S.Diag(Fn->getLocation(), in NoteFunctionCandidate()
11994 MaybeEmitInheritedConstructorNote(S, Cand->FoundDecl); in NoteFunctionCandidate()
12001 return S.NoteOverloadCandidate(Cand->FoundDecl, Fn, Cand->getRewriteKind()); in NoteFunctionCandidate()
12004 unsigned I = (Cand->IgnoreObjectArgument ? 1 : 0); in NoteFunctionCandidate()
12005 for (unsigned N = Cand->Conversions.size(); I != N; ++I) in NoteFunctionCandidate()
12006 if (Cand->Conversions[I].isInitialized() && Cand->Conversions[I].isBad()) in NoteFunctionCandidate()
12010 // when user-conversion overload fails. Figure out how to handle in NoteFunctionCandidate()
12012 return S.NoteOverloadCandidate(Cand->FoundDecl, Fn, Cand->getRewriteKind()); in NoteFunctionCandidate()
12026 if (cast<CXXConstructorDecl>(Fn)->isCopyOrMoveConstructor()) in NoteFunctionCandidate()
12028 S.Diag(Fn->getLocation(), in NoteFunctionCandidate()
12030 << (Fn->getPrimaryTemplate() ? 1 : 0) in NoteFunctionCandidate()
12031 << Fn->getParamDecl(0)->getType()->isRValueReferenceType(); in NoteFunctionCandidate()
12032 MaybeEmitInheritedConstructorNote(S, Cand->FoundDecl); in NoteFunctionCandidate()
12036 bool Available = checkAddressOfCandidateIsAvailable(S, Cand->Function); in NoteFunctionCandidate()
12048 ClassifyOverloadCandidate(S, Cand->FoundDecl, Fn, in NoteFunctionCandidate()
12049 Cand->getRewriteKind(), FnDesc); in NoteFunctionCandidate()
12051 S.Diag(Fn->getLocation(), in NoteFunctionCandidate()
12064 if (shouldSkipNotingLambdaConversionDecl(Cand->Surrogate)) in NoteSurrogateCandidate()
12070 QualType FnType = Cand->Surrogate->getConversionType(); in NoteSurrogateCandidate()
12075 FnType->getAs<LValueReferenceType>()) { in NoteSurrogateCandidate()
12076 FnType = FnTypeRef->getPointeeType(); in NoteSurrogateCandidate()
12079 FnType->getAs<RValueReferenceType>()) { in NoteSurrogateCandidate()
12080 FnType = FnTypeRef->getPointeeType(); in NoteSurrogateCandidate()
12083 if (const PointerType *FnTypePtr = FnType->getAs<PointerType>()) { in NoteSurrogateCandidate()
12084 FnType = FnTypePtr->getPointeeType(); in NoteSurrogateCandidate()
12088 FnType = QualType(FnType->getAs<FunctionType>(), 0); in NoteSurrogateCandidate()
12094 if (!Cand->Viable && in NoteSurrogateCandidate()
12095 Cand->FailureKind == ovl_fail_constraints_not_satisfied) { in NoteSurrogateCandidate()
12096 S.Diag(Cand->Surrogate->getLocation(), in NoteSurrogateCandidate()
12098 << Cand->Surrogate; in NoteSurrogateCandidate()
12100 if (S.CheckFunctionConstraints(Cand->Surrogate, Satisfaction)) in NoteSurrogateCandidate()
12103 S.Diag(Cand->Surrogate->getLocation(), diag::note_ovl_surrogate_cand) in NoteSurrogateCandidate()
12111 assert(Cand->Conversions.size() <= 2 && "builtin operator is not binary"); in NoteBuiltinOperatorCandidate()
12115 TypeStr += Cand->BuiltinParamTypes[0].getAsString(); in NoteBuiltinOperatorCandidate()
12116 if (Cand->Conversions.size() == 1) { in NoteBuiltinOperatorCandidate()
12121 TypeStr += Cand->BuiltinParamTypes[1].getAsString(); in NoteBuiltinOperatorCandidate()
12129 for (const ImplicitConversionSequence &ICS : Cand->Conversions) { in NoteAmbiguousUserConversions()
12139 if (Cand->Function) in GetLocationForCandidate()
12140 return Cand->Function->getLocation(); in GetLocationForCandidate()
12141 if (Cand->IsSurrogate) in GetLocationForCandidate()
12142 return Cand->Surrogate->getLocation(); in GetLocationForCandidate()
12151 llvm_unreachable("non-deduction failure while diagnosing bad deduction"); in RankDeductionFailure()
12160 return 2; in RankDeductionFailure()
12198 // If there are too many or too few arguments, that's the high-order bit we in EffectiveFailureKind()
12200 if (C->FailureKind == ovl_fail_too_many_arguments || in EffectiveFailureKind()
12201 C->FailureKind == ovl_fail_too_few_arguments) in EffectiveFailureKind()
12202 return static_cast<OverloadFailureKind>(C->FailureKind); in EffectiveFailureKind()
12204 if (C->Function) { in EffectiveFailureKind()
12205 if (NumArgs > C->Function->getNumParams() && !C->Function->isVariadic()) in EffectiveFailureKind()
12207 if (NumArgs < C->Function->getMinRequiredArguments()) in EffectiveFailureKind()
12211 return static_cast<OverloadFailureKind>(C->FailureKind); in EffectiveFailureKind()
12214 bool operator()(const OverloadCandidate *L, in operator ()()
12216 // Fast-path this check. in operator ()()
12217 if (L == R) return false; in operator ()()
12220 if (L->Viable) { in operator ()()
12221 if (!R->Viable) return true; in operator ()()
12223 if (int Ord = CompareConversions(*L, *R)) in operator ()()
12226 } else if (R->Viable) in operator ()()
12229 assert(L->Viable == R->Viable); in operator ()()
12231 // Criteria by which we can sort non-viable candidates: in operator ()()
12232 if (!L->Viable) { in operator ()()
12233 OverloadFailureKind LFailureKind = EffectiveFailureKind(L); in operator ()()
12241 int LDist = std::abs((int)L->getNumParams() - (int)NumArgs); in operator ()()
12242 int RDist = std::abs((int)R->getNumParams() - (int)NumArgs); in operator ()()
12245 // Sort non-surrogates before surrogates. in operator ()()
12246 return !L->IsSurrogate && R->IsSurrogate; in operator ()()
12260 // 2. Bad conversions come first and are ordered by the number in operator ()()
12268 unsigned numLFixes = L->Fix.NumConversionsFixed; in operator ()()
12269 unsigned numRFixes = R->Fix.NumConversionsFixed; in operator ()()
12277 if (int Ord = CompareConversions(*L, *R)) in operator ()()
12286 if (L->DeductionFailure.Result != R->DeductionFailure.Result) { in operator ()()
12287 unsigned LRank = RankDeductionFailure(L->DeductionFailure); in operator ()()
12288 unsigned RRank = RankDeductionFailure(R->DeductionFailure); in operator ()()
12299 SourceLocation LLoc = GetLocationForCandidate(L); in operator ()()
12312 return L < R; in operator ()()
12339 // Returns -1 if conversions in L are considered better.
12342 int CompareConversions(const OverloadCandidate &L, in CompareConversions()
12347 assert(L.Conversions.size() == R.Conversions.size()); in CompareConversions()
12348 for (unsigned I = 0, N = L.Conversions.size(); I != N; ++I) { in CompareConversions()
12349 auto LS = L.IgnoreObjectArgument && I == 0 in CompareConversions()
12351 : ConversionSignals::ForSequence(L.Conversions[I]); in CompareConversions()
12357 ? -1 in CompareConversions()
12367 /// CompleteNonViableCandidate - Normally, overload resolution only
12374 assert(!Cand->Viable); in CompleteNonViableCandidate()
12377 if (Cand->FailureKind != ovl_fail_bad_conversion) in CompleteNonViableCandidate()
12383 Cand->Fix.setConversionChecker(TryCopyInitialization); in CompleteNonViableCandidate()
12386 unsigned ConvCount = Cand->Conversions.size(); in CompleteNonViableCandidate()
12387 for (unsigned ConvIdx = (Cand->IgnoreObjectArgument ? 1 : 0); /**/; in CompleteNonViableCandidate()
12390 if (Cand->Conversions[ConvIdx].isInitialized() && in CompleteNonViableCandidate()
12391 Cand->Conversions[ConvIdx].isBad()) { in CompleteNonViableCandidate()
12392 Unfixable = !Cand->TryToFixBadConversion(ConvIdx, S); in CompleteNonViableCandidate()
12404 bool Reversed = Cand->isReversed(); in CompleteNonViableCandidate()
12406 if (Cand->IsSurrogate) { in CompleteNonViableCandidate()
12408 = Cand->Surrogate->getConversionType().getNonReferenceType(); in CompleteNonViableCandidate()
12409 if (const PointerType *ConvPtrType = ConvType->getAs<PointerType>()) in CompleteNonViableCandidate()
12410 ConvType = ConvPtrType->getPointeeType(); in CompleteNonViableCandidate()
12411 ParamTypes = ConvType->castAs<FunctionProtoType>()->getParamTypes(); in CompleteNonViableCandidate()
12414 } else if (Cand->Function) { in CompleteNonViableCandidate()
12416 Cand->Function->getType()->castAs<FunctionProtoType>()->getParamTypes(); in CompleteNonViableCandidate()
12417 if (isa<CXXMethodDecl>(Cand->Function) && in CompleteNonViableCandidate()
12418 !isa<CXXConstructorDecl>(Cand->Function) && !Reversed) { in CompleteNonViableCandidate()
12422 Cand->Function->getDeclName().getCXXOverloadedOperator() != OO_Call && in CompleteNonViableCandidate()
12423 Cand->Function->getDeclName().getCXXOverloadedOperator() != in CompleteNonViableCandidate()
12431 ParamTypes = Cand->BuiltinParamTypes; in CompleteNonViableCandidate()
12435 for (unsigned ParamIdx = Reversed ? ParamTypes.size() - 1 : 0; in CompleteNonViableCandidate()
12437 ++ConvIdx, ++ArgIdx, ParamIdx += (Reversed ? -1 : 1)) { in CompleteNonViableCandidate()
12439 if (Cand->Conversions[ConvIdx].isInitialized()) { in CompleteNonViableCandidate()
12442 if (ParamTypes[ParamIdx]->isDependentType()) in CompleteNonViableCandidate()
12443 Cand->Conversions[ConvIdx].setAsIdentityConversion( in CompleteNonViableCandidate()
12444 Args[ArgIdx]->getType()); in CompleteNonViableCandidate()
12446 Cand->Conversions[ConvIdx] = in CompleteNonViableCandidate()
12453 if (!Unfixable && Cand->Conversions[ConvIdx].isBad()) in CompleteNonViableCandidate()
12454 Unfixable = !Cand->TryToFixBadConversion(ConvIdx, S); in CompleteNonViableCandidate()
12457 Cand->Conversions[ConvIdx].setEllipsis(); in CompleteNonViableCandidate()
12474 if (!Cand->Viable) { in CompleteCandidates()
12475 if (!Cand->Function && !Cand->IsSurrogate) { in CompleteCandidates()
12476 // This a non-viable builtin candidate. We do not, in general, in CompleteCandidates()
12485 if (!Cand->Viable) in CompleteCandidates()
12490 if (!Cand->Best) in CompleteCandidates()
12508 // Defer diagnostic for CUDA/HIP if there are wrong-sided candidates or in shouldDeferDiags()
12515 Cand.Function->template hasAttr<CUDAHostAttr>() && in shouldDeferDiags()
12516 Cand.Function->template hasAttr<CUDADeviceAttr>()); in shouldDeferDiags()
12538 if (Arg->getType()->isWebAssemblyTableType()) in NoteCandidates()
12566 if (Cand->Function) in NoteCandidates()
12569 else if (Cand->IsSurrogate) in NoteCandidates()
12572 assert(Cand->Viable && in NoteCandidates()
12573 "Non-viable built-in candidates are not added to Cands."); in NoteCandidates()
12576 // ambiguous user-defined conversion. in NoteCandidates()
12597 << int(E - I); in NoteCandidates()
12602 return Cand->Specialization ? Cand->Specialization->getLocation() in GetLocationForCandidate()
12611 bool operator()(const TemplateSpecCandidate *L, in operator ()()
12613 // Fast-path this check. in operator ()()
12614 if (L == R) in operator ()()
12620 if (L->DeductionFailure.Result != R->DeductionFailure.Result) in operator ()()
12621 return RankDeductionFailure(L->DeductionFailure) < in operator ()()
12622 RankDeductionFailure(R->DeductionFailure); in operator ()()
12625 SourceLocation LLoc = GetLocationForCandidate(L); in operator ()()
12650 i->DeductionFailure.Destroy(); in destroyCandidates()
12659 /// NoteCandidates - When no template specialization match is found, prints
12660 /// diagnostic messages containing the non-matching specializations that form
12663 /// OCD == OCD_AllCandidates and Cand->Viable == false.
12671 if (Cand->Specialization) in NoteCandidates()
12673 // Otherwise, this is a non-matching builtin candidate. We do not, in NoteCandidates()
12695 assert(Cand->Specialization && in NoteCandidates()
12696 "Non-matching built-in candidates are not added to Cands."); in NoteCandidates()
12697 Cand->NoteDeductionFailure(S, ForTakingAddress); in NoteCandidates()
12701 S.Diag(Loc, diag::note_ovl_too_many_candidates) << int(E - I); in NoteCandidates()
12704 // [PossiblyAFunctionType] --> [Return]
12705 // NonFunctionType --> NonFunctionType
12706 // R (A) --> R(A)
12707 // R (*)(A) --> R (A)
12708 // R (&)(A) --> R (A)
12709 // R (S::*)(A) --> R (A)
12713 PossiblyAFunctionType->getAs<PointerType>()) in ExtractUnqualifiedFunctionType()
12714 Ret = ToTypePtr->getPointeeType(); in ExtractUnqualifiedFunctionType()
12716 PossiblyAFunctionType->getAs<ReferenceType>()) in ExtractUnqualifiedFunctionType()
12717 Ret = ToTypeRef->getPointeeType(); in ExtractUnqualifiedFunctionType()
12719 PossiblyAFunctionType->getAs<MemberPointerType>()) in ExtractUnqualifiedFunctionType()
12720 Ret = MemTypePtr->getPointeeType(); in ExtractUnqualifiedFunctionType()
12728 if (S.getLangOpts().CPlusPlus14 && FD->getReturnType()->isUndeducedType() && in completeFunctionType()
12732 auto *FPT = FD->getType()->castAs<FunctionProtoType>(); in completeFunctionType()
12734 isUnresolvedExceptionSpec(FPT->getExceptionSpecType()) && in completeFunctionType()
12743 // - allows us to avoid passing around all those ugly parameters
12771 !!TargetType->getAs<MemberPointerType>()), in AddressOfFunctionResolver()
12777 FailedCandidates(OvlExpr->getNameLoc(), /*ForTakingAddress=*/true) { in AddressOfFunctionResolver()
12780 if (TargetFunctionType->isFunctionType()) { in AddressOfFunctionResolver()
12782 if (!UME->isImplicitAccess() && in AddressOfFunctionResolver()
12785 } else if (OvlExpr->hasExplicitTemplateArgs()) { in AddressOfFunctionResolver()
12790 if (!Method->isStatic()) { in AddressOfFunctionResolver()
12791 // If the target type is a non-function type and the function found in AddressOfFunctionResolver()
12792 // is a non-static member function, pretend as if that was the in AddressOfFunctionResolver()
12807 if (OvlExpr->hasExplicitTemplateArgs()) in AddressOfFunctionResolver()
12808 OvlExpr->copyTemplateArgumentsInto(OvlExplicitTemplateArgs); in AddressOfFunctionResolver()
12830 return Context.hasSameUnqualifiedType(TargetFunctionType, FD->getType()) || in candidateHasExactlyCorrectType()
12831 S.IsFunctionConversion(FD->getType(), TargetFunctionType, Discard); in candidateHasExactlyCorrectType()
12848 // Same algorithm as overload resolution -- one pass to pick the "best", in eliminiateSuboptimalOverloadCandidates()
12852 if (isBetterCandidate(I->second, Best->second)) in eliminiateSuboptimalOverloadCandidates()
12855 const FunctionDecl *BestFn = Best->second; in eliminiateSuboptimalOverloadCandidates()
12871 return TargetFunctionType->isFunctionType(); in isTargetTypeAFunction()
12876 // R (*)(A) --> R (A), IsNonStaticMemberFunction = false
12877 // R (&)(A) --> R (A), IsNonStaticMemberFunction = false
12878 // R (S::*)(A) --> R (A), IsNonStaticMemberFunction = true
12887 = dyn_cast<CXXMethodDecl>(FunctionTemplate->getTemplatedDecl())) { in AddMatchingTemplateFunction()
12888 // Skip non-static function templates when converting to pointer, and in AddMatchingTemplateFunction()
12891 Method->isStatic() || Method->isExplicitObjectMemberFunction(); in AddMatchingTemplateFunction()
12912 .set(CurAccessFunPair, FunctionTemplate->getTemplatedDecl(), in AddMatchingTemplateFunction()
12918 // compatible pointer-to-function arguments that would be adjusted by ICS. in AddMatchingTemplateFunction()
12921 Context.getCanonicalType(Specialization->getType()), in AddMatchingTemplateFunction()
12934 // Skip non-static functions when converting to pointer, and static in AddMatchingNonTemplateFunction()
12937 Method->isStatic() || Method->isExplicitObjectMemberFunction(); in AddMatchingNonTemplateFunction()
12947 if (!(Caller && Caller->isImplicit()) && in AddMatchingNonTemplateFunction()
12951 if (FunDecl->isMultiVersion()) { in AddMatchingNonTemplateFunction()
12952 const auto *TA = FunDecl->getAttr<TargetAttr>(); in AddMatchingNonTemplateFunction()
12953 if (TA && !TA->isDefaultVersion()) in AddMatchingNonTemplateFunction()
12955 const auto *TVA = FunDecl->getAttr<TargetVersionAttr>(); in AddMatchingNonTemplateFunction()
12956 if (TVA && !TVA->isDefaultVersion()) in AddMatchingNonTemplateFunction()
12962 if (completeFunctionType(S, FunDecl, SourceExpr->getBeginLoc(), in AddMatchingNonTemplateFunction()
12975 CurAccessFunPair, cast<FunctionDecl>(FunDecl->getCanonicalDecl()))); in AddMatchingNonTemplateFunction()
12988 // member, don't try to convert it to a pointer-to-member type. in FindAllFunctionsThatMatchTargetTypeExactly()
12992 for (UnresolvedSetIterator I = OvlExpr->decls_begin(), in FindAllFunctionsThatMatchTargetTypeExactly()
12993 E = OvlExpr->decls_end(); in FindAllFunctionsThatMatchTargetTypeExactly()
12996 NamedDecl *Fn = (*I)->getUnderlyingDecl(); in FindAllFunctionsThatMatchTargetTypeExactly()
12999 // Non-member functions and static member functions match in FindAllFunctionsThatMatchTargetTypeExactly()
13000 // targets of type "pointer-to-function" or "reference-to-function." in FindAllFunctionsThatMatchTargetTypeExactly()
13002 // type "pointer-to-member-function." in FindAllFunctionsThatMatchTargetTypeExactly()
13009 // If we have explicit template arguments supplied, skip non-templates. in FindAllFunctionsThatMatchTargetTypeExactly()
13010 else if (!OvlExpr->hasExplicitTemplateArgs() && in FindAllFunctionsThatMatchTargetTypeExactly()
13026 // two-pass algorithm (similar to the one used to identify the in EliminateAllExceptMostSpecializedTemplate()
13038 SourceExpr->getBeginLoc(), S.PDiag(), in EliminateAllExceptMostSpecializedTemplate()
13040 << Matches[0].second->getDeclName(), in EliminateAllExceptMostSpecializedTemplate()
13047 Matches[0].first = Matches[Result - MatchesCopy.begin()].first; in EliminateAllExceptMostSpecializedTemplate()
13056 // eliminated if the set also contains a non-template function, [...] in EliminateAllTemplateMatches()
13058 if (Matches[I].second->getPrimaryTemplate() == nullptr) in EliminateAllTemplateMatches()
13061 Matches[I] = Matches[--N]; in EliminateAllTemplateMatches()
13075 S.Diag(OvlExpr->getBeginLoc(), diag::err_addr_ovl_no_viable) in ComplainNoMatchesFound()
13076 << OvlExpr->getName() << TargetFunctionType in ComplainNoMatchesFound()
13077 << OvlExpr->getSourceRange(); in ComplainNoMatchesFound()
13083 // the function templates, and diagnose the non-template candidates in ComplainNoMatchesFound()
13085 for (UnresolvedSetIterator I = OvlExpr->decls_begin(), in ComplainNoMatchesFound()
13086 IEnd = OvlExpr->decls_end(); in ComplainNoMatchesFound()
13089 dyn_cast<FunctionDecl>((*I)->getUnderlyingDecl())) in ComplainNoMatchesFound()
13093 FailedCandidates.NoteCandidates(S, OvlExpr->getBeginLoc()); in ComplainNoMatchesFound()
13106 S.Diag(OvlExpr->getNameLoc(), diag::err_addr_ovl_no_qualifier) in ComplainIsInvalidFormOfPointerToMemberFunction()
13107 << TargetType << OvlExpr->getSourceRange(); in ComplainIsInvalidFormOfPointerToMemberFunction()
13115 S.Diag(OvlExpr->getBeginLoc(), in ComplainIsStaticMemberFunctionFromBoundPointer()
13117 << OvlExpr->getSourceRange(); in ComplainIsStaticMemberFunctionFromBoundPointer()
13121 S.Diag(OvlExpr->getBeginLoc(), diag::err_addr_ovl_not_func_ptrref) in ComplainOfInvalidConversion()
13122 << OvlExpr->getName() << TargetType; in ComplainOfInvalidConversion()
13127 S.Diag(OvlExpr->getBeginLoc(), diag::err_addr_ovl_ambiguous) in ComplainMultipleMatchesFound()
13128 << OvlExpr->getName() << OvlExpr->getSourceRange(); in ComplainMultipleMatchesFound()
13133 bool hadMultipleCandidates() const { return (OvlExpr->getNumDecls() > 1); } in hadMultipleCandidates()
13155 assert(AddressOfExpr->getType() == Context.OverloadTy); in ResolveAddressOfOverloadedFunction()
13173 if (auto *FPT = Fn->getType()->getAs<FunctionProtoType>()) in ResolveAddressOfOverloadedFunction()
13174 ResolveExceptionSpec(AddressOfExpr->getExprLoc(), FPT); in ResolveAddressOfOverloadedFunction()
13192 OverloadExpr *Ovl = R.Expression; in resolveAddressOfSingleOverloadCandidate() local
13196 SmallVector<FunctionDecl *, 2> AmbiguousDecls; in resolveAddressOfSingleOverloadCandidate()
13201 return static_cast<int>(CUDA().IdentifyPreference(Caller, FD1)) - in resolveAddressOfSingleOverloadCandidate()
13208 for (auto I = Ovl->decls_begin(), E = Ovl->decls_end(); I != E; ++I) { in resolveAddressOfSingleOverloadCandidate()
13209 auto *FD = dyn_cast<FunctionDecl>(I->getUnderlyingDecl()); in resolveAddressOfSingleOverloadCandidate()
13223 // We have more than one result - see if it is more constrained than the in resolveAddressOfSingleOverloadCandidate()
13249 // FD is more constrained - replace Result with it. in resolveAddressOfSingleOverloadCandidate()
13278 assert(E->getType() == Context.OverloadTy && "SrcExpr must be an overload"); in resolveAndFixAddressOfSingleOverloadCandidate()
13282 if (!Found || Found->isCPUDispatchMultiVersion() || in resolveAndFixAddressOfSingleOverloadCandidate()
13283 Found->isCPUSpecificMultiVersion()) in resolveAndFixAddressOfSingleOverloadCandidate()
13289 DiagnoseUseOfDecl(Found, E->getExprLoc()); in resolveAndFixAddressOfSingleOverloadCandidate()
13295 if (DoFunctionPointerConversion && Fixed->getType()->isFunctionType()) in resolveAndFixAddressOfSingleOverloadCandidate()
13303 OverloadExpr *ovl, bool Complain, DeclAccessPair *FoundResult, in ResolveSingleFunctionTemplateSpecialization() argument
13312 // If we didn't actually find any template-ids, we're done. in ResolveSingleFunctionTemplateSpecialization()
13313 if (!ovl->hasExplicitTemplateArgs()) in ResolveSingleFunctionTemplateSpecialization()
13317 ovl->copyTemplateArgumentsInto(ExplicitTemplateArgs); in ResolveSingleFunctionTemplateSpecialization()
13322 for (UnresolvedSetIterator I = ovl->decls_begin(), in ResolveSingleFunctionTemplateSpecialization()
13323 E = ovl->decls_end(); I != E; ++I) { in ResolveSingleFunctionTemplateSpecialization()
13329 // template-id is an lvalue for the function template specialization. in ResolveSingleFunctionTemplateSpecialization()
13331 = cast<FunctionTemplateDecl>((*I)->getUnderlyingDecl()); in ResolveSingleFunctionTemplateSpecialization()
13340 TemplateDeductionInfo Info(ovl->getNameLoc()); in ResolveSingleFunctionTemplateSpecialization()
13347 FailedTSC->addCandidate().set( in ResolveSingleFunctionTemplateSpecialization()
13348 I.getPair(), FunctionTemplate->getTemplatedDecl(), in ResolveSingleFunctionTemplateSpecialization()
13358 Diag(ovl->getExprLoc(), diag::err_addr_ovl_ambiguous) in ResolveSingleFunctionTemplateSpecialization()
13359 << ovl->getName(); in ResolveSingleFunctionTemplateSpecialization()
13360 NoteAllOverloadCandidates(ovl); in ResolveSingleFunctionTemplateSpecialization()
13370 completeFunctionType(*this, Matched, ovl->getExprLoc(), Complain)) in ResolveSingleFunctionTemplateSpecialization()
13380 assert(SrcExpr.get()->getType() == Context.OverloadTy); in ResolveAndFixSingleFunctionTemplateSpecialization()
13382 OverloadExpr::FindResult ovl = OverloadExpr::find(SrcExpr.get()); in ResolveAndFixSingleFunctionTemplateSpecialization() local
13387 ovl.Expression, /*complain*/ false, &found)) { in ResolveAndFixSingleFunctionTemplateSpecialization()
13388 if (DiagnoseUseOfDecl(fn, SrcExpr.get()->getBeginLoc())) { in ResolveAndFixSingleFunctionTemplateSpecialization()
13397 if (!ovl.HasFormOfMemberPointer && in ResolveAndFixSingleFunctionTemplateSpecialization()
13399 cast<CXXMethodDecl>(fn)->isInstance()) { in ResolveAndFixSingleFunctionTemplateSpecialization()
13402 Diag(ovl.Expression->getExprLoc(), in ResolveAndFixSingleFunctionTemplateSpecialization()
13404 << 0 << ovl.Expression->getSourceRange(); in ResolveAndFixSingleFunctionTemplateSpecialization()
13407 // static and non-static candidates (otherwise the expression in ResolveAndFixSingleFunctionTemplateSpecialization()
13419 // If desired, do function-to-pointer decay. in ResolveAndFixSingleFunctionTemplateSpecialization()
13433 << ovl.Expression->getName() in ResolveAndFixSingleFunctionTemplateSpecialization()
13436 << ovl.Expression->getQualifierLoc().getSourceRange(); in ResolveAndFixSingleFunctionTemplateSpecialization()
13460 Callee = cast<UsingShadowDecl>(Callee)->getTargetDecl(); in AddOverloadedCallCandidate()
13467 // Prevent ill-formed function decls to be added as overload candidates. in AddOverloadedCallCandidate()
13468 if (!isa<FunctionProtoType>(Func->getType()->getAs<FunctionType>())) in AddOverloadedCallCandidate()
13502 // -- a declaration of a class member, or in AddOverloadedCallCandidates()
13504 // -- a block-scope function declaration that is not a in AddOverloadedCallCandidates()
13505 // using-declaration, or in AddOverloadedCallCandidates()
13507 // -- a declaration that is neither a function or a function in AddOverloadedCallCandidates()
13512 if (ULE->requiresADL()) { in AddOverloadedCallCandidates()
13513 for (UnresolvedLookupExpr::decls_iterator I = ULE->decls_begin(), in AddOverloadedCallCandidates()
13514 E = ULE->decls_end(); I != E; ++I) { in AddOverloadedCallCandidates()
13515 assert(!(*I)->getDeclContext()->isRecord()); in AddOverloadedCallCandidates()
13517 !(*I)->getDeclContext()->isFunctionOrMethod()); in AddOverloadedCallCandidates()
13518 assert((*I)->getUnderlyingDecl()->isFunctionOrFunctionTemplate()); in AddOverloadedCallCandidates()
13526 if (ULE->hasExplicitTemplateArgs()) { in AddOverloadedCallCandidates()
13527 ULE->copyTemplateArgumentsInto(TABuffer); in AddOverloadedCallCandidates()
13531 for (UnresolvedLookupExpr::decls_iterator I = ULE->decls_begin(), in AddOverloadedCallCandidates()
13532 E = ULE->decls_end(); I != E; ++I) in AddOverloadedCallCandidates()
13537 if (ULE->requiresADL()) in AddOverloadedCallCandidates()
13538 AddArgumentDependentLookupCandidates(ULE->getName(), ULE->getExprLoc(), in AddOverloadedCallCandidates()
13564 /// Attempt to recover from an ill-formed use of a non-dependent name in a
13565 /// template, where the non-dependent name was declared after the template
13567 /// correctly implement two-stage name lookup.
13578 for (DeclContext *DC = SemaRef.CurContext; DC; DC = DC->getParent()) { in DiagnoseTwoPhaseLookup()
13579 if (DC->isTransparentContext()) in DiagnoseTwoPhaseLookup()
13596 // We either found non-function declarations or a best viable function in DiagnoseTwoPhaseLookup()
13597 // at class scope. A class-scope lookup result disables ADL. Don't in DiagnoseTwoPhaseLookup()
13604 R.addDecl(Best->FoundDecl.getDecl(), Best->FoundDecl.getAccess()); in DiagnoseTwoPhaseLookup()
13630 if (Std && Std->Encloses(*it)) in DiagnoseTwoPhaseLookup()
13637 NS->getQualifiedNameAsString().find("__") != std::string::npos) in DiagnoseTwoPhaseLookup()
13647 SemaRef.Diag(Best->Function->getLocation(), in DiagnoseTwoPhaseLookup()
13651 SemaRef.Diag(Best->Function->getLocation(), in DiagnoseTwoPhaseLookup()
13658 SemaRef.Diag(Best->Function->getLocation(), in DiagnoseTwoPhaseLookup()
13660 << R.getLookupName() << 2; in DiagnoseTwoPhaseLookup()
13673 /// Attempt to recover from ill-formed use of a non-dependent operator in a
13674 /// template, where the non-dependent operator was declared after the template
13722 // template <typename T> auto foo(T t) -> decltype(foo(t)) {} in BuildRecoveryCallExpr()
13723 // template <typename T> auto foo(T t) -> decltype(foo(&t)) {} in BuildRecoveryCallExpr()
13729 SS.Adopt(ULE->getQualifierLoc()); in BuildRecoveryCallExpr()
13730 SourceLocation TemplateKWLoc = ULE->getTemplateKeywordLoc(); in BuildRecoveryCallExpr()
13734 if (ULE->hasExplicitTemplateArgs()) { in BuildRecoveryCallExpr()
13735 ULE->copyTemplateArgumentsInto(TABuffer); in BuildRecoveryCallExpr()
13739 LookupResult R(SemaRef, ULE->getName(), ULE->getNameLoc(), in BuildRecoveryCallExpr()
13742 if (DiagnoseTwoPhaseLookup(SemaRef, Fn->getExprLoc(), SS, R, in BuildRecoveryCallExpr()
13745 // OK, diagnosed a two-phase lookup issue. in BuildRecoveryCallExpr()
13786 if ((*R.begin())->isCXXClassMember()) in BuildRecoveryCallExpr()
13813 if (ULE->requiresADL()) { in buildOverloadedCallSet()
13815 assert(!ULE->getQualifier() && "qualified name with ADL"); in buildOverloadedCallSet()
13820 if (ULE->decls_begin() != ULE->decls_end() && in buildOverloadedCallSet()
13821 ULE->decls_begin() + 1 == ULE->decls_end() && in buildOverloadedCallSet()
13822 (F = dyn_cast<FunctionDecl>(*ULE->decls_begin())) && in buildOverloadedCallSet()
13823 F->getBuiltinID() && F->isImplicit()) in buildOverloadedCallSet()
13838 // functions, including those from argument-dependent lookup. in buildOverloadedCallSet()
13842 CurContext->isDependentContext() && !isSFINAEContext() && in buildOverloadedCallSet()
13846 if (CandidateSet->empty() || in buildOverloadedCallSet()
13847 CandidateSet->BestViableFunction(*this, Fn->getBeginLoc(), Best) == in buildOverloadedCallSet()
13856 CE->markDependentForPostponedNameLookup(); in buildOverloadedCallSet()
13862 if (CandidateSet->empty()) in buildOverloadedCallSet()
13877 if (Candidate.Function->isInvalidDecl()) in chooseRecoveryType()
13879 QualType T = Candidate.Function->getReturnType(); in chooseRecoveryType()
13907 if (Value.isNull() || Value->isUndeducedType()) in chooseRecoveryType()
13912 /// FinishOverloadedCallExpr - given an OverloadCandidateSet, builds and returns
13927 FunctionDecl *FDecl = (*Best)->Function; in FinishOverloadedCallExpr()
13928 SemaRef.CheckUnresolvedLookupAccess(ULE, (*Best)->FoundDecl); in FinishOverloadedCallExpr()
13929 if (SemaRef.DiagnoseUseOfDecl(FDecl, ULE->getNameLoc())) in FinishOverloadedCallExpr()
13932 SemaRef.FixOverloadedFunctionReference(Fn, (*Best)->FoundDecl, FDecl); in FinishOverloadedCallExpr()
13937 /*IsExecConfig=*/false, (*Best)->IsADLCandidate); in FinishOverloadedCallExpr()
13941 if (*Best != CandidateSet->end() && in FinishOverloadedCallExpr()
13942 CandidateSet->getKind() == in FinishOverloadedCallExpr()
13945 dyn_cast_if_present<CXXMethodDecl>((*Best)->Function); in FinishOverloadedCallExpr()
13946 M && M->isImplicitObjectMemberFunction()) { in FinishOverloadedCallExpr()
13947 CandidateSet->NoteCandidates( in FinishOverloadedCallExpr()
13949 Fn->getBeginLoc(), in FinishOverloadedCallExpr()
13960 CandidateSet->empty(), in FinishOverloadedCallExpr()
13969 if (!Arg->getType()->isFunctionType()) in FinishOverloadedCallExpr()
13971 if (auto *DRE = dyn_cast<DeclRefExpr>(Arg->IgnoreParenImpCasts())) { in FinishOverloadedCallExpr()
13972 auto *FD = dyn_cast<FunctionDecl>(DRE->getDecl()); in FinishOverloadedCallExpr()
13975 Arg->getExprLoc())) in FinishOverloadedCallExpr()
13980 CandidateSet->NoteCandidates( in FinishOverloadedCallExpr()
13982 Fn->getBeginLoc(), in FinishOverloadedCallExpr()
13984 << ULE->getName() << Fn->getSourceRange()), in FinishOverloadedCallExpr()
13990 CandidateSet->NoteCandidates( in FinishOverloadedCallExpr()
13991 PartialDiagnosticAt(Fn->getBeginLoc(), in FinishOverloadedCallExpr()
13993 << ULE->getName() << Fn->getSourceRange()), in FinishOverloadedCallExpr()
13998 FunctionDecl *FDecl = (*Best)->Function; in FinishOverloadedCallExpr()
13999 SemaRef.DiagnoseUseOfDeletedFunction(Fn->getBeginLoc(), in FinishOverloadedCallExpr()
14000 Fn->getSourceRange(), ULE->getName(), in FinishOverloadedCallExpr()
14006 SemaRef.FixOverloadedFunctionReference(Fn, (*Best)->FoundDecl, FDecl); in FinishOverloadedCallExpr()
14011 /*IsExecConfig=*/false, (*Best)->IsADLCandidate); in FinishOverloadedCallExpr()
14018 return SemaRef.CreateRecoveryExpr(Fn->getBeginLoc(), RParenLoc, SubExprs, in FinishOverloadedCallExpr()
14025 if (I->Viable && in markUnaddressableCandidatesUnviable()
14026 !S.checkAddressOfFunctionIsAvailable(I->Function, /*Complain=*/false)) { in markUnaddressableCandidatesUnviable()
14027 I->Viable = false; in markUnaddressableCandidatesUnviable()
14028 I->FailureKind = ovl_fail_addr_not_available; in markUnaddressableCandidatesUnviable()
14042 Fn->getExprLoc(), CalleesAddressIsTaken in BuildOverloadedCallExpr()
14058 CandidateSet.BestViableFunction(*this, Fn->getBeginLoc(), Best); in BuildOverloadedCallExpr()
14062 // the UnresolvedLookupExpr was type-dependent. in BuildOverloadedCallExpr()
14064 const FunctionDecl *FDecl = Best->Function; in BuildOverloadedCallExpr()
14065 if (FDecl && FDecl->isTemplateInstantiation() && in BuildOverloadedCallExpr()
14066 FDecl->getReturnType()->isUndeducedType()) { in BuildOverloadedCallExpr()
14068 FDecl->getTemplateInstantiationPattern(/*ForDefinition=*/false); in BuildOverloadedCallExpr()
14069 TP && TP->willHaveBody()) { in BuildOverloadedCallExpr()
14097 if (Method->isExplicitObjectMemberFunction()) in BuildCXXMemberCallExpr()
14105 if (Method->getParent()->isLambda() && in BuildCXXMemberCallExpr()
14106 Method->getConversionType()->isBlockPointerType()) { in BuildCXXMemberCallExpr()
14111 if (CE && CE->getCastKind() == CK_NoOp) in BuildCXXMemberCallExpr()
14112 SubE = CE->getSubExpr(); in BuildCXXMemberCallExpr()
14113 SubE = SubE->IgnoreParens(); in BuildCXXMemberCallExpr()
14115 SubE = BE->getSubExpr(); in BuildCXXMemberCallExpr()
14125 Exp.get()->getExprLoc(), Exp.get()->getExprLoc(), Method, Exp.get()); in BuildCXXMemberCallExpr()
14130 Diag(Exp.get()->getExprLoc(), diag::note_lambda_to_block_conv); in BuildCXXMemberCallExpr()
14135 QualType ResultType = Method->getReturnType(); in BuildCXXMemberCallExpr()
14138 if (Method->isExplicitObjectMemberFunction()) { in BuildCXXMemberCallExpr()
14141 HadMultipleCandidates, E->getBeginLoc()); in BuildCXXMemberCallExpr()
14146 ResultType, VK, Exp.get()->getEndLoc(), in BuildCXXMemberCallExpr()
14152 DeclAccessPair::make(FoundDecl, FoundDecl->getAccess()), in BuildCXXMemberCallExpr()
14157 Exp.get()->getEndLoc(), in BuildCXXMemberCallExpr()
14162 Method->getType()->castAs<FunctionProtoType>())) in BuildCXXMemberCallExpr()
14165 return CheckForImmediateInvocation(CE, CE->getDirectCallee()); in BuildCXXMemberCallExpr()
14181 Expr *Args[2] = { Input, nullptr }; in CreateOverloadedUnaryOp()
14184 // For post-increment and post-decrement, add the implicit '0' as in CreateOverloadedUnaryOp()
14185 // the second argument, so that we know this is a post-increment or in CreateOverloadedUnaryOp()
14186 // post-decrement. in CreateOverloadedUnaryOp()
14191 NumArgs = 2; in CreateOverloadedUnaryOp()
14196 if (Input->isTypeDependent()) { in CreateOverloadedUnaryOp()
14244 // We found a built-in operator or an overloaded operator. in CreateOverloadedUnaryOp()
14245 FunctionDecl *FnDecl = Best->Function; in CreateOverloadedUnaryOp()
14254 CheckMemberOperatorAccess(OpLoc, Input, nullptr, Best->FoundDecl); in CreateOverloadedUnaryOp()
14257 if (Method->isExplicitObjectMemberFunction()) in CreateOverloadedUnaryOp()
14261 Input, /*Qualifier=*/nullptr, Best->FoundDecl, Method); in CreateOverloadedUnaryOp()
14270 FnDecl->getParamDecl(0)), in CreateOverloadedUnaryOp()
14279 ExprResult FnExpr = CreateFunctionRefExpr(*this, FnDecl, Best->FoundDecl, in CreateOverloadedUnaryOp()
14286 QualType ResultTy = FnDecl->getReturnType(); in CreateOverloadedUnaryOp()
14293 CurFPFeatureOverrides(), Best->IsADLCandidate); in CreateOverloadedUnaryOp()
14295 if (CheckCallReturnType(FnDecl->getReturnType(), OpLoc, TheCall, FnDecl)) in CreateOverloadedUnaryOp()
14299 FnDecl->getType()->castAs<FunctionProtoType>())) in CreateOverloadedUnaryOp()
14303 // We matched a built-in operator. Convert the arguments, then in CreateOverloadedUnaryOp()
14304 // break out so that we will build the appropriate built-in in CreateOverloadedUnaryOp()
14307 Input, Best->BuiltinParamTypes[0], Best->Conversions[0], AA_Passing, in CreateOverloadedUnaryOp()
14318 // a non-member function. Check for non-member operators which were in CreateOverloadedUnaryOp()
14325 // built-in operator, which will produce an error message for us. in CreateOverloadedUnaryOp()
14333 << Input->getType() << Input->getSourceRange()), in CreateOverloadedUnaryOp()
14344 StringLiteral *Msg = Best->Function->getDeletedMessage(); in CreateOverloadedUnaryOp()
14349 << (Msg ? Msg->getString() : StringRef()) in CreateOverloadedUnaryOp()
14350 << Input->getSourceRange()), in CreateOverloadedUnaryOp()
14358 // built-in operator. In either case, fall through to trying to in CreateOverloadedUnaryOp()
14359 // build a built-in operation. in CreateOverloadedUnaryOp()
14394 // performed for an assignment operator (nor for operator[] nor operator->, in LookupOverloadedBinOp()
14413 // incorrect; a builtin candidate could be hidden by a non-viable candidate, in LookupOverloadedBinOp()
14432 Expr *Args[2] = { LHS, RHS }; in CreateOverloadedBinOp()
14440 // If either side is type-dependent, create an appropriate dependent in CreateOverloadedBinOp()
14442 if (Args[0]->isTypeDependent() || Args[1]->isTypeDependent()) { in CreateOverloadedBinOp()
14471 // create a built-in binary operator. in CreateOverloadedBinOp()
14487 // Always do placeholder-like conversions on the RHS. in CreateOverloadedBinOp()
14491 // Do placeholder-like conversion on the LHS; note that we should in CreateOverloadedBinOp()
14493 assert(Args[0]->getObjectKind() != OK_ObjCProperty); in CreateOverloadedBinOp()
14498 // if the left-hand side is a class or enumeration type. This is actually in CreateOverloadedBinOp()
14500 // various built-in candidates, but as DR507 points out, this can lead to in CreateOverloadedBinOp()
14503 if (Opc == BO_Assign && !Args[0]->getType()->isOverloadableType()) in CreateOverloadedBinOp()
14520 // We found a built-in operator or an overloaded operator. in CreateOverloadedBinOp()
14521 FunctionDecl *FnDecl = Best->Function; in CreateOverloadedBinOp()
14523 bool IsReversed = Best->isReversed(); in CreateOverloadedBinOp()
14529 if (FnDecl->isInvalidDecl()) in CreateOverloadedBinOp()
14537 FnDecl->getDeclName().getCXXOverloadedOperator(); in CreateOverloadedBinOp()
14539 // C++2a [over.match.oper]p9: in CreateOverloadedBinOp()
14542 if (Best->RewriteKind && ChosenOp == OO_EqualEqual && in CreateOverloadedBinOp()
14543 !FnDecl->getReturnType()->isBooleanType()) { in CreateOverloadedBinOp()
14545 FnDecl->getReturnType()->isIntegralOrUnscopedEnumerationType(); in CreateOverloadedBinOp()
14548 << FnDecl->getReturnType() << BinaryOperator::getOpcodeStr(Opc) in CreateOverloadedBinOp()
14549 << Args[0]->getSourceRange() << Args[1]->getSourceRange(); in CreateOverloadedBinOp()
14550 Diag(FnDecl->getLocation(), diag::note_declared_at); in CreateOverloadedBinOp()
14565 for (unsigned ArgIdx = 0; ArgIdx < 2; ++ArgIdx) { in CreateOverloadedBinOp()
14568 Best->Conversions[ArgIdx]) == in CreateOverloadedBinOp()
14583 << Args[0]->getType() << Args[1]->getType() << AmbiguousWithSelf in CreateOverloadedBinOp()
14584 << Args[0]->getSourceRange() << Args[1]->getSourceRange(); in CreateOverloadedBinOp()
14586 Diag(FnDecl->getLocation(), in CreateOverloadedBinOp()
14594 !MD->isConst() && in CreateOverloadedBinOp()
14595 !MD->hasCXXExplicitFunctionObjectParameter() && in CreateOverloadedBinOp()
14597 MD->getFunctionObjectParameterType(), in CreateOverloadedBinOp()
14598 MD->getParamDecl(0)->getType().getNonReferenceType()) && in CreateOverloadedBinOp()
14600 MD->getFunctionObjectParameterType(), in CreateOverloadedBinOp()
14601 Args[0]->getType()) && in CreateOverloadedBinOp()
14603 MD->getFunctionObjectParameterType(), in CreateOverloadedBinOp()
14604 Args[1]->getType())) in CreateOverloadedBinOp()
14605 Diag(FnDecl->getLocation(), in CreateOverloadedBinOp()
14608 Diag(FnDecl->getLocation(), in CreateOverloadedBinOp()
14611 Diag(F->getLocation(), in CreateOverloadedBinOp()
14621 diagnoseNullableToNonnullConversion(Args[0]->getType(), in CreateOverloadedBinOp()
14622 Args[1]->getType(), OpLoc); in CreateOverloadedBinOp()
14626 // Best->Access is only meaningful for class members. in CreateOverloadedBinOp()
14627 CheckMemberOperatorAccess(OpLoc, Args[0], Args[1], Best->FoundDecl); in CreateOverloadedBinOp()
14631 if (Method->isExplicitObjectMemberFunction()) { in CreateOverloadedBinOp()
14636 Args[0], /*Qualifier=*/nullptr, Best->FoundDecl, Method); in CreateOverloadedBinOp()
14640 Context, FnDecl->getParamDecl(ParamIdx)), in CreateOverloadedBinOp()
14651 FnDecl->getParamDecl(0)), in CreateOverloadedBinOp()
14659 FnDecl->getParamDecl(1)), in CreateOverloadedBinOp()
14669 Best->FoundDecl, Base, in CreateOverloadedBinOp()
14675 QualType ResultTy = FnDecl->getReturnType(); in CreateOverloadedBinOp()
14680 ArrayRef<const Expr *> ArgsArray(Args, 2); in CreateOverloadedBinOp()
14687 CurFPFeatureOverrides(), Best->IsADLCandidate); in CreateOverloadedBinOp()
14690 Method && Method->isImplicitObjectMemberFunction()) { in CreateOverloadedBinOp()
14696 if (CheckCallReturnType(FnDecl->getReturnType(), OpLoc, TheCall, in CreateOverloadedBinOp()
14707 QualType ThisType = Context.getPointerType(ImplicitThis->getType()); in CreateOverloadedBinOp()
14709 cast<CXXMethodDecl>(FnDecl)->getFunctionObjectParameterType()); in CreateOverloadedBinOp()
14716 isa<CXXMethodDecl>(FnDecl), OpLoc, TheCall->getSourceRange(), in CreateOverloadedBinOp()
14729 if ((Best->RewriteKind & CRK_DifferentOperator) || in CreateOverloadedBinOp()
14759 if (Best->RewriteKind != CRK_None) in CreateOverloadedBinOp()
14764 // We matched a built-in operator. Convert the arguments, then in CreateOverloadedBinOp()
14765 // break out so that we will build the appropriate built-in in CreateOverloadedBinOp()
14768 Args[0], Best->BuiltinParamTypes[0], Best->Conversions[0], in CreateOverloadedBinOp()
14775 Args[1], Best->BuiltinParamTypes[1], Best->Conversions[1], in CreateOverloadedBinOp()
14788 // built-in operator and interpreted according to clause 5. in CreateOverloadedBinOp()
14792 // When defaulting an 'operator<=>', we can try to synthesize a three-way in CreateOverloadedBinOp()
14802 // operator do not fall through to handling in built-in, but report that in CreateOverloadedBinOp()
14810 if (Args[0]->getType()->isRecordType() && in CreateOverloadedBinOp()
14814 << Args[0]->getSourceRange() << Args[1]->getSourceRange(); in CreateOverloadedBinOp()
14815 if (Args[0]->getType()->isIncompleteType()) { in CreateOverloadedBinOp()
14817 << Args[0]->getType() in CreateOverloadedBinOp()
14818 << Args[0]->getSourceRange() << Args[1]->getSourceRange(); in CreateOverloadedBinOp()
14822 // a non-member function. Check for non-member operators which were in CreateOverloadedBinOp()
14828 // No viable function; try to create a built-in operation, which will in CreateOverloadedBinOp()
14829 // produce an error. Then, show the non-viable candidates. in CreateOverloadedBinOp()
14842 << Args[0]->getType() in CreateOverloadedBinOp()
14843 << Args[1]->getType() in CreateOverloadedBinOp()
14844 << Args[0]->getSourceRange() in CreateOverloadedBinOp()
14845 << Args[1]->getSourceRange()), in CreateOverloadedBinOp()
14851 if (isImplicitlyDeleted(Best->Function)) { in CreateOverloadedBinOp()
14852 FunctionDecl *DeletedFD = Best->Function; in CreateOverloadedBinOp()
14856 << Args[0]->getType() in CreateOverloadedBinOp()
14861 << Args[0]->getType() << DeletedFD; in CreateOverloadedBinOp()
14870 StringLiteral *Msg = Best->Function->getDeletedMessage(); in CreateOverloadedBinOp()
14875 << getOperatorSpelling(Best->Function->getDeclName() in CreateOverloadedBinOp()
14877 << (Msg != nullptr) << (Msg ? Msg->getString() : StringRef()) in CreateOverloadedBinOp()
14878 << Args[0]->getSourceRange() << Args[1]->getSourceRange()), in CreateOverloadedBinOp()
14885 // We matched a built-in operator; build it. in CreateOverloadedBinOp()
14893 Context.CompCategories.lookupInfoForType(DefaultedFn->getReturnType()); in BuildSynthesizedThreeWayComparison()
14895 // synthesize a three-way comparison. Let the caller diagnose this. in BuildSynthesizedThreeWayComparison()
14901 assert(LHS->isGLValue() && RHS->isGLValue() && in BuildSynthesizedThreeWayComparison()
14909 OpaqueValueExpr(LHS->getExprLoc(), LHS->getType(), LHS->getValueKind(), in BuildSynthesizedThreeWayComparison()
14910 LHS->getObjectKind(), LHS); in BuildSynthesizedThreeWayComparison()
14912 OpaqueValueExpr(RHS->getExprLoc(), RHS->getType(), RHS->getValueKind(), in BuildSynthesizedThreeWayComparison()
14913 RHS->getObjectKind(), RHS); in BuildSynthesizedThreeWayComparison()
14926 if (Info->isPartial()) { in BuildSynthesizedThreeWayComparison()
14938 { {Eq, Info->isStrong() ? ComparisonCategoryResult::Equal in BuildSynthesizedThreeWayComparison()
14945 int I = Info->isPartial() ? 3 : 2; in BuildSynthesizedThreeWayComparison()
14949 for (; I >= 0; --I) { in BuildSynthesizedThreeWayComparison()
14951 auto *VI = Info->lookupValueInfo(Comparisons[I].Result); in BuildSynthesizedThreeWayComparison()
14956 BuildDeclarationNameExpr(CXXScopeSpec(), DeclarationNameInfo(), VI->VD); in BuildSynthesizedThreeWayComparison()
14974 Context, OrigLHS, OrigRHS, BO_Cmp, Result.get()->getType(), in BuildSynthesizedThreeWayComparison()
14975 Result.get()->getValueKind(), Result.get()->getObjectKind(), OpLoc, in BuildSynthesizedThreeWayComparison()
14978 return PseudoObjectExpr::Create(Context, SyntacticForm, SemanticForm, 2); in BuildSynthesizedThreeWayComparison()
14985 const auto *Proto = Method->getType()->castAs<FunctionProtoType>(); in PrepareArgumentsForCallToObjectOfClassType()
14986 unsigned NumParams = Proto->getNumParams(); in PrepareArgumentsForCallToObjectOfClassType()
15001 S.Context, Method->getParamDecl(i)), in PrepareArgumentsForCallToObjectOfClassType()
15007 S.BuildCXXDefaultArgExpr(LParenLoc, Method, Method->getParamDecl(i)); in PrepareArgumentsForCallToObjectOfClassType()
15024 SmallVector<Expr *, 2> Args; in CreateOverloadedArraySubscriptExpr()
15034 : SourceRange(ArgExpr.front()->getBeginLoc(), in CreateOverloadedArraySubscriptExpr()
15035 ArgExpr.back()->getEndLoc()); in CreateOverloadedArraySubscriptExpr()
15037 // If either side is type-dependent, create an appropriate dependent in CreateOverloadedArraySubscriptExpr()
15070 if (Args.size() == 2) in CreateOverloadedArraySubscriptExpr()
15079 // We found a built-in operator or an overloaded operator. in CreateOverloadedArraySubscriptExpr()
15080 FunctionDecl *FnDecl = Best->Function; in CreateOverloadedArraySubscriptExpr()
15086 CheckMemberOperatorAccess(LLoc, Args[0], ArgExpr, Best->FoundDecl); in CreateOverloadedArraySubscriptExpr()
15090 SmallVector<Expr *, 2> MethodArgs; in CreateOverloadedArraySubscriptExpr()
15093 if (Method->isExplicitObjectMemberFunction()) { in CreateOverloadedArraySubscriptExpr()
15102 Args[0], /*Qualifier=*/nullptr, Best->FoundDecl, Method); in CreateOverloadedArraySubscriptExpr()
15118 *this, FnDecl, Best->FoundDecl, Base, HadMultipleCandidates, in CreateOverloadedArraySubscriptExpr()
15124 QualType ResultTy = FnDecl->getReturnType(); in CreateOverloadedArraySubscriptExpr()
15132 if (CheckCallReturnType(FnDecl->getReturnType(), LLoc, TheCall, FnDecl)) in CreateOverloadedArraySubscriptExpr()
15136 Method->getType()->castAs<FunctionProtoType>())) in CreateOverloadedArraySubscriptExpr()
15142 // We matched a built-in operator. Convert the arguments, then in CreateOverloadedArraySubscriptExpr()
15143 // break out so that we will build the appropriate built-in in CreateOverloadedArraySubscriptExpr()
15146 Args[0], Best->BuiltinParamTypes[0], Best->Conversions[0], in CreateOverloadedArraySubscriptExpr()
15153 Args[1], Best->BuiltinParamTypes[1], Best->Conversions[1], in CreateOverloadedArraySubscriptExpr()
15167 << Args[0]->getType() << /*subscript*/ 0 in CreateOverloadedArraySubscriptExpr()
15168 << Args[0]->getSourceRange() << Range) in CreateOverloadedArraySubscriptExpr()
15170 << Args[0]->getType() << Args[0]->getSourceRange() << Range); in CreateOverloadedArraySubscriptExpr()
15177 if (Args.size() == 2) { in CreateOverloadedArraySubscriptExpr()
15181 << "[]" << Args[0]->getType() << Args[1]->getType() in CreateOverloadedArraySubscriptExpr()
15182 << Args[0]->getSourceRange() << Range), in CreateOverloadedArraySubscriptExpr()
15188 << Args[0]->getType() in CreateOverloadedArraySubscriptExpr()
15189 << Args[0]->getSourceRange() << Range), in CreateOverloadedArraySubscriptExpr()
15195 StringLiteral *Msg = Best->Function->getDeletedMessage(); in CreateOverloadedArraySubscriptExpr()
15200 << (Msg ? Msg->getString() : StringRef()) in CreateOverloadedArraySubscriptExpr()
15201 << Args[0]->getSourceRange() << Range), in CreateOverloadedArraySubscriptExpr()
15207 // We matched a built-in operator; build it. in CreateOverloadedArraySubscriptExpr()
15217 assert(MemExprE->getType() == Context.BoundMemberTy || in BuildCallToMemberFunction()
15218 MemExprE->getType() == Context.OverloadTy); in BuildCallToMemberFunction()
15222 Expr *NakedMemExpr = MemExprE->IgnoreParens(); in BuildCallToMemberFunction()
15224 // Determine whether this is a call to a pointer-to-member function. in BuildCallToMemberFunction()
15226 assert(op->getType() == Context.BoundMemberTy); in BuildCallToMemberFunction()
15227 assert(op->getOpcode() == BO_PtrMemD || op->getOpcode() == BO_PtrMemI); in BuildCallToMemberFunction()
15230 op->getRHS()->getType()->castAs<MemberPointerType>()->getPointeeType(); in BuildCallToMemberFunction()
15232 const FunctionProtoType *proto = fnType->castAs<FunctionProtoType>(); in BuildCallToMemberFunction()
15233 QualType resultType = proto->getCallResultType(Context); in BuildCallToMemberFunction()
15234 ExprValueKind valueKind = Expr::getValueKindForType(proto->getReturnType()); in BuildCallToMemberFunction()
15238 Qualifiers funcQuals = proto->getMethodQuals(); in BuildCallToMemberFunction()
15240 QualType objectType = op->getLHS()->getType(); in BuildCallToMemberFunction()
15241 if (op->getOpcode() == BO_PtrMemI) in BuildCallToMemberFunction()
15242 objectType = objectType->castAs<PointerType>()->getPointeeType(); in BuildCallToMemberFunction()
15245 Qualifiers difference = objectQuals - funcQuals; in BuildCallToMemberFunction()
15253 << (qualsString.find(' ') == std::string::npos ? 1 : 2); in BuildCallToMemberFunction()
15258 CurFPFeatureOverrides(), proto->getNumParams()); in BuildCallToMemberFunction()
15260 if (CheckCallReturnType(proto->getReturnType(), op->getRHS()->getBeginLoc(), in BuildCallToMemberFunction()
15281 return CreateRecoveryExpr(MemExprE->getBeginLoc(), RParenLoc, SubExprs, in BuildCallToMemberFunction()
15299 Method = cast<CXXMethodDecl>(MemExpr->getMemberDecl()); in BuildCallToMemberFunction()
15300 FoundDecl = MemExpr->getFoundDecl(); in BuildCallToMemberFunction()
15301 Qualifier = MemExpr->getQualifier(); in BuildCallToMemberFunction()
15305 Qualifier = UnresExpr->getQualifier(); in BuildCallToMemberFunction()
15307 QualType ObjectType = UnresExpr->getBaseType(); in BuildCallToMemberFunction()
15309 = UnresExpr->isArrow()? Expr::Classification::makeSimpleLValue() in BuildCallToMemberFunction()
15310 : UnresExpr->getBase()->Classify(Context); in BuildCallToMemberFunction()
15313 OverloadCandidateSet CandidateSet(UnresExpr->getMemberLoc(), in BuildCallToMemberFunction()
15318 if (UnresExpr->hasExplicitTemplateArgs()) { in BuildCallToMemberFunction()
15319 UnresExpr->copyTemplateArgumentsInto(TemplateArgsBuffer); in BuildCallToMemberFunction()
15323 for (UnresolvedMemberExpr::decls_iterator I = UnresExpr->decls_begin(), in BuildCallToMemberFunction()
15324 E = UnresExpr->decls_end(); I != E; ++I) { in BuildCallToMemberFunction()
15329 CXXRecordDecl *ActingDC = cast<CXXRecordDecl>(Func->getDeclContext()); in BuildCallToMemberFunction()
15331 Func = cast<UsingShadowDecl>(Func)->getTargetDecl(); in BuildCallToMemberFunction()
15335 M && M->hasCXXExplicitFunctionObjectParameter()) in BuildCallToMemberFunction()
15339 M->getTemplatedDecl()->hasCXXExplicitFunctionObjectParameter()) in BuildCallToMemberFunction()
15352 // non-template member function. in BuildCallToMemberFunction()
15370 DeclarationName DeclName = UnresExpr->getMemberName(); in BuildCallToMemberFunction()
15376 switch (CandidateSet.BestViableFunction(*this, UnresExpr->getBeginLoc(), in BuildCallToMemberFunction()
15379 Method = cast<CXXMethodDecl>(Best->Function); in BuildCallToMemberFunction()
15380 FoundDecl = Best->FoundDecl; in BuildCallToMemberFunction()
15381 CheckUnresolvedMemberAccess(UnresExpr, Best->FoundDecl); in BuildCallToMemberFunction()
15382 if (DiagnoseUseOfOverloadedDecl(Best->FoundDecl, UnresExpr->getNameLoc())) in BuildCallToMemberFunction()
15391 DiagnoseUseOfOverloadedDecl(Method, UnresExpr->getNameLoc())) in BuildCallToMemberFunction()
15399 UnresExpr->getMemberLoc(), in BuildCallToMemberFunction()
15401 << DeclName << MemExprE->getSourceRange()), in BuildCallToMemberFunction()
15406 PartialDiagnosticAt(UnresExpr->getMemberLoc(), in BuildCallToMemberFunction()
15408 << DeclName << MemExprE->getSourceRange()), in BuildCallToMemberFunction()
15413 UnresExpr->getMemberLoc(), MemExprE->getSourceRange(), DeclName, in BuildCallToMemberFunction()
15414 CandidateSet, Best->Function, Args, /*IsMember=*/true); in BuildCallToMemberFunction()
15428 // build a non-member call based on that function. in BuildCallToMemberFunction()
15429 if (Method->isStatic()) { in BuildCallToMemberFunction()
15434 MemExpr = cast<MemberExpr>(MemExprE->IgnoreParens()); in BuildCallToMemberFunction()
15437 QualType ResultType = Method->getReturnType(); in BuildCallToMemberFunction()
15442 const auto *Proto = Method->getType()->castAs<FunctionProtoType>(); in BuildCallToMemberFunction()
15446 if (Method->isExplicitObjectMemberFunction()) { in BuildCallToMemberFunction()
15447 if (PrepareExplicitObjectArgument(*this, Method, MemExpr->getBase(), Args, in BuildCallToMemberFunction()
15454 HadMultipleCandidates, MemExpr->getExprLoc()); in BuildCallToMemberFunction()
15460 CurFPFeatureOverrides(), Proto->getNumParams()); in BuildCallToMemberFunction()
15462 // Convert the object argument (for a non-static member function call). in BuildCallToMemberFunction()
15466 MemExpr->getBase(), Qualifier, FoundDecl, Method); in BuildCallToMemberFunction()
15469 MemExpr->setBase(ObjectArg.get()); in BuildCallToMemberFunction()
15472 Proto->getNumParams()); in BuildCallToMemberFunction()
15476 if (CheckCallReturnType(Method->getReturnType(), MemExpr->getMemberLoc(), in BuildCallToMemberFunction()
15492 // that here, so it will not hide previous -- and more relevant -- errors. in BuildCallToMemberFunction()
15496 Diag(MemE->getMemberLoc(), in BuildCallToMemberFunction()
15498 << Method << Method->getSourceRange(); in BuildCallToMemberFunction()
15499 Diag(Method->getLocation(), in BuildCallToMemberFunction()
15501 << Attr->getCond()->getSourceRange() << Attr->getMessage(); in BuildCallToMemberFunction()
15507 TheCall->getDirectCallee()->isPureVirtual()) { in BuildCallToMemberFunction()
15508 const FunctionDecl *MD = TheCall->getDirectCallee(); in BuildCallToMemberFunction()
15510 if (isa<CXXThisExpr>(MemExpr->getBase()->IgnoreParenCasts()) && in BuildCallToMemberFunction()
15511 MemExpr->performsVirtualDispatch(getLangOpts())) { in BuildCallToMemberFunction()
15512 Diag(MemExpr->getBeginLoc(), in BuildCallToMemberFunction()
15514 << MD->getDeclName() << isa<CXXDestructorDecl>(CurContext) in BuildCallToMemberFunction()
15515 << MD->getParent(); in BuildCallToMemberFunction()
15517 Diag(MD->getBeginLoc(), diag::note_previous_decl) << MD->getDeclName(); in BuildCallToMemberFunction()
15519 Diag(MemExpr->getBeginLoc(), diag::note_pure_qualified_call_kext) in BuildCallToMemberFunction()
15520 << MD->getParent() << MD->getDeclName(); in BuildCallToMemberFunction()
15524 if (auto *DD = dyn_cast<CXXDestructorDecl>(TheCall->getDirectCallee())) { in BuildCallToMemberFunction()
15525 // a->A::f() doesn't go through the vtable, except in AppleKext mode. in BuildCallToMemberFunction()
15526 bool CallCanBeVirtual = !MemExpr->hasQualifier() || getLangOpts().AppleKext; in BuildCallToMemberFunction()
15527 CheckVirtualDtorCall(DD, MemExpr->getBeginLoc(), /*IsDelete=*/false, in BuildCallToMemberFunction()
15529 MemExpr->getMemberLoc()); in BuildCallToMemberFunction()
15533 TheCall->getDirectCallee()); in BuildCallToMemberFunction()
15549 assert(Object.get()->getType()->isRecordType() && in BuildCallToObjectOfClassType()
15553 // If the primary-expression E in the function call syntax in BuildCallToObjectOfClassType()
15563 if (RequireCompleteType(LParenLoc, Object.get()->getType(), in BuildCallToObjectOfClassType()
15567 const auto *Record = Object.get()->getType()->castAs<RecordType>(); in BuildCallToObjectOfClassType()
15569 LookupQualifiedName(R, Record->getDecl()); in BuildCallToObjectOfClassType()
15574 AddMethodCandidate(Oper.getPair(), Object.get()->getType(), in BuildCallToObjectOfClassType()
15575 Object.get()->Classify(Context), Args, CandidateSet, in BuildCallToObjectOfClassType()
15586 // showing 2 failed overloads instead of one. in BuildCallToObjectOfClassType()
15588 if (CandidateSet.size() == 1 && Record->getAsCXXRecordDecl()->isLambda()) { in BuildCallToObjectOfClassType()
15596 // In addition, for each (non-explicit in C++0x) conversion function in BuildCallToObjectOfClassType()
15599 // operator conversion-type-id () cv-qualifier; in BuildCallToObjectOfClassType()
15601 // where cv-qualifier is the same cv-qualification as, or a in BuildCallToObjectOfClassType()
15602 // greater cv-qualification than, cv, and where conversion-type-id in BuildCallToObjectOfClassType()
15613 cast<CXXRecordDecl>(Record->getDecl())->getVisibleConversionFunctions(); in BuildCallToObjectOfClassType()
15617 CXXRecordDecl *ActingContext = cast<CXXRecordDecl>(D->getDeclContext()); in BuildCallToObjectOfClassType()
15619 D = cast<UsingShadowDecl>(D)->getTargetDecl(); in BuildCallToObjectOfClassType()
15627 if (!Conv->isExplicit()) { in BuildCallToObjectOfClassType()
15630 QualType ConvType = Conv->getConversionType().getNonReferenceType(); in BuildCallToObjectOfClassType()
15631 if (const PointerType *ConvPtrType = ConvType->getAs<PointerType>()) in BuildCallToObjectOfClassType()
15632 ConvType = ConvPtrType->getPointeeType(); in BuildCallToObjectOfClassType()
15634 if (const FunctionProtoType *Proto = ConvType->getAs<FunctionProtoType>()) in BuildCallToObjectOfClassType()
15646 switch (CandidateSet.BestViableFunction(*this, Object.get()->getBeginLoc(), in BuildCallToObjectOfClassType()
15657 << Object.get()->getType() << /*call*/ 1 in BuildCallToObjectOfClassType()
15658 << Object.get()->getSourceRange()) in BuildCallToObjectOfClassType()
15660 << Object.get()->getType() << Object.get()->getSourceRange()); in BuildCallToObjectOfClassType()
15662 PartialDiagnosticAt(Object.get()->getBeginLoc(), PD), *this, in BuildCallToObjectOfClassType()
15669 PartialDiagnosticAt(Object.get()->getBeginLoc(), in BuildCallToObjectOfClassType()
15671 << Object.get()->getType() in BuildCallToObjectOfClassType()
15672 << Object.get()->getSourceRange()), in BuildCallToObjectOfClassType()
15679 // 2. we already issue err_deleted_function_use for this later on anyway. in BuildCallToObjectOfClassType()
15680 StringLiteral *Msg = Best->Function->getDeletedMessage(); in BuildCallToObjectOfClassType()
15682 PartialDiagnosticAt(Object.get()->getBeginLoc(), in BuildCallToObjectOfClassType()
15684 << Object.get()->getType() << (Msg != nullptr) in BuildCallToObjectOfClassType()
15685 << (Msg ? Msg->getString() : StringRef()) in BuildCallToObjectOfClassType()
15686 << Object.get()->getSourceRange()), in BuildCallToObjectOfClassType()
15697 if (Best->Function == nullptr) { in BuildCallToObjectOfClassType()
15702 Best->Conversions[0].UserDefined.ConversionFunction); in BuildCallToObjectOfClassType()
15705 Best->FoundDecl); in BuildCallToObjectOfClassType()
15706 if (DiagnoseUseOfDecl(Best->FoundDecl, LParenLoc)) in BuildCallToObjectOfClassType()
15708 assert(Conv == Best->FoundDecl.getDecl() && in BuildCallToObjectOfClassType()
15709 "Found Decl & conversion-to-functionptr should be same, right?!"); in BuildCallToObjectOfClassType()
15716 ExprResult Call = BuildCXXMemberCallExpr(Object.get(), Best->FoundDecl, in BuildCallToObjectOfClassType()
15722 Context, Call.get()->getType(), CK_UserDefinedConversion, Call.get(), in BuildCallToObjectOfClassType()
15728 CheckMemberOperatorAccess(LParenLoc, Object.get(), nullptr, Best->FoundDecl); in BuildCallToObjectOfClassType()
15733 CXXMethodDecl *Method = cast<CXXMethodDecl>(Best->Function); in BuildCallToObjectOfClassType()
15736 if (Method->isInvalidDecl()) in BuildCallToObjectOfClassType()
15739 const auto *Proto = Method->getType()->castAs<FunctionProtoType>(); in BuildCallToObjectOfClassType()
15740 unsigned NumParams = Proto->getNumParams(); in BuildCallToObjectOfClassType()
15745 ExprResult NewFn = CreateFunctionRefExpr(*this, Method, Best->FoundDecl, in BuildCallToObjectOfClassType()
15759 if (Method->isExplicitObjectMemberFunction()) { in BuildCallToObjectOfClassType()
15763 Object.get(), /*Qualifier=*/nullptr, Best->FoundDecl, Method); in BuildCallToObjectOfClassType()
15775 if (Proto->isVariadic()) { in BuildCallToObjectOfClassType()
15791 QualType ResultTy = Method->getReturnType(); in BuildCallToObjectOfClassType()
15799 if (CheckCallReturnType(Method->getReturnType(), LParenLoc, TheCall, Method)) in BuildCallToObjectOfClassType()
15811 assert(Base->getType()->isRecordType() && in BuildOverloadedArrowExpr()
15812 "left-hand side must have class type"); in BuildOverloadedArrowExpr()
15817 SourceLocation Loc = Base->getExprLoc(); in BuildOverloadedArrowExpr()
15821 // [...] An expression x->m is interpreted as (x.operator->())->m in BuildOverloadedArrowExpr()
15822 // for a class object x of type T if T::operator->() exists and if in BuildOverloadedArrowExpr()
15829 if (RequireCompleteType(Loc, Base->getType(), in BuildOverloadedArrowExpr()
15834 LookupQualifiedName(R, Base->getType()->castAs<RecordType>()->getDecl()); in BuildOverloadedArrowExpr()
15839 AddMethodCandidate(Oper.getPair(), Base->getType(), Base->Classify(Context), in BuildOverloadedArrowExpr()
15856 QualType BaseType = Base->getType(); in BuildOverloadedArrowExpr()
15864 << BaseType << Base->getSourceRange(); in BuildOverloadedArrowExpr()
15865 if (BaseType->isRecordType() && !BaseType->isPointerType()) { in BuildOverloadedArrowExpr()
15871 << "operator->" << Base->getSourceRange(); in BuildOverloadedArrowExpr()
15879 << "->" << Base->getType() in BuildOverloadedArrowExpr()
15880 << Base->getSourceRange()), in BuildOverloadedArrowExpr()
15885 StringLiteral *Msg = Best->Function->getDeletedMessage(); in BuildOverloadedArrowExpr()
15888 << "->" << (Msg != nullptr) in BuildOverloadedArrowExpr()
15889 << (Msg ? Msg->getString() : StringRef()) in BuildOverloadedArrowExpr()
15890 << Base->getSourceRange()), in BuildOverloadedArrowExpr()
15896 CheckMemberOperatorAccess(OpLoc, Base, nullptr, Best->FoundDecl); in BuildOverloadedArrowExpr()
15899 CXXMethodDecl *Method = cast<CXXMethodDecl>(Best->Function); in BuildOverloadedArrowExpr()
15901 if (Method->isExplicitObjectMemberFunction()) { in BuildOverloadedArrowExpr()
15908 Base, /*Qualifier=*/nullptr, Best->FoundDecl, Method); in BuildOverloadedArrowExpr()
15915 ExprResult FnExpr = CreateFunctionRefExpr(*this, Method, Best->FoundDecl, in BuildOverloadedArrowExpr()
15920 QualType ResultTy = Method->getReturnType(); in BuildOverloadedArrowExpr()
15928 if (CheckCallReturnType(Method->getReturnType(), OpLoc, TheCall, Method)) in BuildOverloadedArrowExpr()
15932 Method->getType()->castAs<FunctionProtoType>())) in BuildOverloadedArrowExpr()
15976 FunctionDecl *FD = Best->Function; in BuildLiteralOperatorCall()
15977 ExprResult Fn = CreateFunctionRefExpr(*this, FD, Best->FoundDecl, in BuildLiteralOperatorCall()
15984 // Check the argument types. This should almost always be a no-op, except in BuildLiteralOperatorCall()
15985 // that array-to-pointer decay is applied to string literals. in BuildLiteralOperatorCall()
15986 Expr *ConvArgs[2]; in BuildLiteralOperatorCall()
15989 InitializedEntity::InitializeParameter(Context, FD->getParamDecl(ArgIdx)), in BuildLiteralOperatorCall()
15996 QualType ResultTy = FD->getReturnType(); in BuildLiteralOperatorCall()
16004 if (CheckCallReturnType(FD->getReturnType(), UDSuffixLoc, UDL, FD)) in BuildLiteralOperatorCall()
16022 CandidateSet->clear(OverloadCandidateSet::CSK_Normal); in BuildForRangeBeginEndCall()
16025 BuildMemberReferenceExpr(Range, Range->getType(), Loc, in BuildForRangeBeginEndCall()
16037 if (CallExpr->isInvalid()) { in BuildForRangeBeginEndCall()
16051 if (CandidateSet->empty() || CandidateSetError) { in BuildForRangeBeginEndCall()
16057 CandidateSet->BestViableFunction(*this, Fn->getBeginLoc(), Best); in BuildForRangeBeginEndCall()
16067 if (CallExpr->isInvalid() || OverloadResult != OR_Success) { in BuildForRangeBeginEndCall()
16079 FixOverloadedFunctionReference(PE->getSubExpr(), Found, Fn); in FixOverloadedFunctionReference()
16082 if (SubExpr.get() == PE->getSubExpr()) in FixOverloadedFunctionReference()
16086 ParenExpr(PE->getLParen(), PE->getRParen(), SubExpr.get()); in FixOverloadedFunctionReference()
16091 FixOverloadedFunctionReference(ICE->getSubExpr(), Found, Fn); in FixOverloadedFunctionReference()
16094 assert(Context.hasSameType(ICE->getSubExpr()->getType(), in FixOverloadedFunctionReference()
16095 SubExpr.get()->getType()) && in FixOverloadedFunctionReference()
16097 assert(ICE->path_empty() && "fixing up hierarchy conversion?"); in FixOverloadedFunctionReference()
16098 if (SubExpr.get() == ICE->getSubExpr()) in FixOverloadedFunctionReference()
16101 return ImplicitCastExpr::Create(Context, ICE->getType(), ICE->getCastKind(), in FixOverloadedFunctionReference()
16102 SubExpr.get(), nullptr, ICE->getValueKind(), in FixOverloadedFunctionReference()
16107 if (!GSE->isResultDependent()) { in FixOverloadedFunctionReference()
16109 FixOverloadedFunctionReference(GSE->getResultExpr(), Found, Fn); in FixOverloadedFunctionReference()
16112 if (SubExpr.get() == GSE->getResultExpr()) in FixOverloadedFunctionReference()
16117 ArrayRef<Expr *> A = GSE->getAssocExprs(); in FixOverloadedFunctionReference()
16119 unsigned ResultIdx = GSE->getResultIndex(); in FixOverloadedFunctionReference()
16122 if (GSE->isExprPredicate()) in FixOverloadedFunctionReference()
16124 Context, GSE->getGenericLoc(), GSE->getControllingExpr(), in FixOverloadedFunctionReference()
16125 GSE->getAssocTypeSourceInfos(), AssocExprs, GSE->getDefaultLoc(), in FixOverloadedFunctionReference()
16126 GSE->getRParenLoc(), GSE->containsUnexpandedParameterPack(), in FixOverloadedFunctionReference()
16129 Context, GSE->getGenericLoc(), GSE->getControllingType(), in FixOverloadedFunctionReference()
16130 GSE->getAssocTypeSourceInfos(), AssocExprs, GSE->getDefaultLoc(), in FixOverloadedFunctionReference()
16131 GSE->getRParenLoc(), GSE->containsUnexpandedParameterPack(), in FixOverloadedFunctionReference()
16140 assert(UnOp->getOpcode() == UO_AddrOf && in FixOverloadedFunctionReference()
16143 if (!Method->isImplicitObjectMemberFunction()) { in FixOverloadedFunctionReference()
16145 // explicit object member functions is a (non-member) function pointer. in FixOverloadedFunctionReference()
16151 FixOverloadedFunctionReference(UnOp->getSubExpr(), Found, Fn); in FixOverloadedFunctionReference()
16154 if (SubExpr.get() == UnOp->getSubExpr()) in FixOverloadedFunctionReference()
16157 if (CheckUseOfCXXMethodAsAddressOfOperand(UnOp->getBeginLoc(), in FixOverloadedFunctionReference()
16163 assert(cast<DeclRefExpr>(SubExpr.get())->getQualifier() && in FixOverloadedFunctionReference()
16170 = Context.getTypeDeclType(cast<RecordDecl>(Method->getDeclContext())); in FixOverloadedFunctionReference()
16172 = Context.getMemberPointerType(Fn->getType(), ClassType.getTypePtr()); in FixOverloadedFunctionReference()
16175 (void)isCompleteType(UnOp->getOperatorLoc(), MemPtrType); in FixOverloadedFunctionReference()
16179 UnOp->getOperatorLoc(), false, in FixOverloadedFunctionReference()
16184 FixOverloadedFunctionReference(UnOp->getSubExpr(), Found, Fn); in FixOverloadedFunctionReference()
16187 if (SubExpr.get() == UnOp->getSubExpr()) in FixOverloadedFunctionReference()
16190 return CreateBuiltinUnaryOp(UnOp->getOperatorLoc(), UO_AddrOf, in FixOverloadedFunctionReference()
16197 if (ULE->hasExplicitTemplateArgs()) { in FixOverloadedFunctionReference()
16198 ULE->copyTemplateArgumentsInto(TemplateArgsBuffer); in FixOverloadedFunctionReference()
16202 QualType Type = Fn->getType(); in FixOverloadedFunctionReference()
16204 getLangOpts().CPlusPlus && !Fn->hasCXXExplicitFunctionObjectParameter() in FixOverloadedFunctionReference()
16209 if (unsigned BID = Fn->getBuiltinID()) { in FixOverloadedFunctionReference()
16217 Fn, Type, ValueKind, ULE->getNameInfo(), ULE->getQualifierLoc(), in FixOverloadedFunctionReference()
16218 Found.getDecl(), ULE->getTemplateKeywordLoc(), TemplateArgs); in FixOverloadedFunctionReference()
16219 DRE->setHadMultipleCandidates(ULE->getNumDecls() > 1); in FixOverloadedFunctionReference()
16226 if (MemExpr->hasExplicitTemplateArgs()) { in FixOverloadedFunctionReference()
16227 MemExpr->copyTemplateArgumentsInto(TemplateArgsBuffer); in FixOverloadedFunctionReference()
16235 if (MemExpr->isImplicitAccess()) { in FixOverloadedFunctionReference()
16236 if (cast<CXXMethodDecl>(Fn)->isStatic()) { in FixOverloadedFunctionReference()
16238 Fn, Fn->getType(), VK_LValue, MemExpr->getNameInfo(), in FixOverloadedFunctionReference()
16239 MemExpr->getQualifierLoc(), Found.getDecl(), in FixOverloadedFunctionReference()
16240 MemExpr->getTemplateKeywordLoc(), TemplateArgs); in FixOverloadedFunctionReference()
16241 DRE->setHadMultipleCandidates(MemExpr->getNumDecls() > 1); in FixOverloadedFunctionReference()
16244 SourceLocation Loc = MemExpr->getMemberLoc(); in FixOverloadedFunctionReference()
16245 if (MemExpr->getQualifier()) in FixOverloadedFunctionReference()
16246 Loc = MemExpr->getQualifierLoc().getBeginLoc(); in FixOverloadedFunctionReference()
16248 BuildCXXThisExpr(Loc, MemExpr->getBaseType(), /*IsImplicit=*/true); in FixOverloadedFunctionReference()
16251 Base = MemExpr->getBase(); in FixOverloadedFunctionReference()
16255 if (cast<CXXMethodDecl>(Fn)->isStatic()) { in FixOverloadedFunctionReference()
16257 type = Fn->getType(); in FixOverloadedFunctionReference()
16264 Base, MemExpr->isArrow(), MemExpr->getOperatorLoc(), in FixOverloadedFunctionReference()
16265 MemExpr->getQualifierLoc(), MemExpr->getTemplateKeywordLoc(), Fn, Found, in FixOverloadedFunctionReference()
16266 /*HadMultipleCandidates=*/true, MemExpr->getMemberNameInfo(), in FixOverloadedFunctionReference()
16283 if (Function->isVariadic()) in shouldEnforceArgLimit()
16286 dyn_cast<FunctionProtoType>(Function->getFunctionType())) in shouldEnforceArgLimit()
16287 if (Proto->isTemplateVariadic()) in shouldEnforceArgLimit()
16289 if (auto *Pattern = Function->getTemplateInstantiationPattern()) in shouldEnforceArgLimit()
16291 dyn_cast<FunctionProtoType>(Pattern->getFunctionType())) in shouldEnforceArgLimit()
16292 if (Proto->isTemplateVariadic()) in shouldEnforceArgLimit()
16302 StringLiteral *Msg = Fn->getDeletedMessage(); in DiagnoseUseOfDeletedFunction()
16306 << (Msg ? Msg->getString() : StringRef()) in DiagnoseUseOfDeletedFunction()