30 #include "llvm/ADT/DenseSet.h" 31 #include "llvm/ADT/Optional.h" 32 #include "llvm/ADT/STLExtras.h" 33 #include "llvm/ADT/SmallPtrSet.h" 34 #include "llvm/ADT/SmallString.h" 38 using namespace clang;
43 return P->hasAttr<PassObjectSizeAttr>();
50 const Expr *
Base,
bool HadMultipleCandidates,
65 if (HadMultipleCandidates)
76 CK_FunctionToPointerDecay);
80 bool InOverloadResolution,
83 bool AllowObjCWritebackConversion);
87 bool InOverloadResolution,
95 bool AllowObjCConversionOnExplicit);
148 return Rank[(int)Kind];
158 "Function-to-pointer",
159 "Function pointer conversion",
161 "Integral promotion",
162 "Floating point promotion",
164 "Integral conversion",
165 "Floating conversion",
166 "Complex conversion",
167 "Floating-integral conversion",
168 "Pointer conversion",
169 "Pointer-to-member conversion",
170 "Boolean conversion",
171 "Compatible-types conversion",
172 "Derived-to-base conversion",
175 "Complex-real conversion",
176 "Block Pointer conversion",
177 "Transparent Union Conversion",
178 "Writeback conversion",
179 "OpenCL Zero Event Conversion",
180 "C specific type conversion",
181 "Incompatible pointer conversion" 192 DeprecatedStringLiteralToCharPtr =
false;
193 QualificationIncludesObjCLifetime =
false;
194 ReferenceBinding =
false;
195 DirectBinding =
false;
196 IsLvalueReference =
true;
197 BindsToFunctionLvalue =
false;
198 BindsToRvalue =
false;
199 BindsImplicitObjectArgumentWithoutRefQualifier =
false;
200 ObjCLifetimeConversionBinding =
false;
201 CopyConstructor =
nullptr;
228 (getFromType()->isPointerType() ||
229 getFromType()->isMemberPointerType() ||
230 getFromType()->isObjCObjectPointerType() ||
231 getFromType()->isBlockPointerType() ||
232 getFromType()->isNullPtrType() ||
265 const Expr *Converted) {
268 if (
auto *EWC = dyn_cast<ExprWithCleanups>(Converted)) {
275 while (
auto *ICE = dyn_cast<ImplicitCastExpr>(Converted)) {
276 switch (ICE->getCastKind()) {
278 case CK_IntegralCast:
279 case CK_IntegralToBoolean:
280 case CK_IntegralToFloating:
281 case CK_BooleanToSignedIntegral:
282 case CK_FloatingToIntegral:
283 case CK_FloatingToBoolean:
284 case CK_FloatingCast:
285 Converted = ICE->getSubExpr();
309 QualType &ConstantType,
bool IgnoreFloatToIntegralConversion)
const {
310 assert(Ctx.
getLangOpts().CPlusPlus &&
"narrowing check outside C++");
321 ToType = ET->getDecl()->getIntegerType();
326 if (FromType->isRealFloatingType())
327 goto FloatingIntegralConversion;
328 if (FromType->isIntegralOrUnscopedEnumerationType())
329 goto IntegralConversion;
341 FloatingIntegralConversion:
342 if (FromType->isRealFloatingType() && ToType->
isIntegralType(Ctx)) {
344 }
else if (FromType->isIntegralOrUnscopedEnumerationType() &&
346 if (IgnoreFloatToIntegralConversion)
350 assert(Initializer &&
"Unknown conversion expression");
359 Result.convertFromAPInt(IntConstantValue, IntConstantValue.isSigned(),
360 llvm::APFloat::rmNearestTiesToEven);
364 Result.convertToInteger(ConvertedValue,
365 llvm::APFloat::rmTowardZero, &ignored);
367 if (IntConstantValue != ConvertedValue) {
368 ConstantValue =
APValue(IntConstantValue);
369 ConstantType = Initializer->
getType();
395 assert(ConstantValue.
isFloat());
396 llvm::APFloat FloatVal = ConstantValue.
getFloat();
399 llvm::APFloat::opStatus ConvertStatus = FloatVal.convert(
401 llvm::APFloat::rmNearestTiesToEven, &ignored);
404 if (ConvertStatus & llvm::APFloat::opOverflow) {
405 ConstantType = Initializer->
getType();
420 IntegralConversion: {
421 assert(FromType->isIntegralOrUnscopedEnumerationType());
423 const bool FromSigned = FromType->isSignedIntegerOrEnumerationType();
424 const unsigned FromWidth = Ctx.
getIntWidth(FromType);
428 if (FromWidth > ToWidth ||
429 (FromWidth == ToWidth && FromSigned != ToSigned) ||
430 (FromSigned && !ToSigned)) {
443 bool Narrowing =
false;
444 if (FromWidth < ToWidth) {
447 if (InitializerValue.isSigned() && InitializerValue.isNegative())
452 InitializerValue = InitializerValue.extend(
453 InitializerValue.getBitWidth() + 1);
456 ConvertedValue = ConvertedValue.trunc(ToWidth);
457 ConvertedValue.setIsSigned(ToSigned);
458 ConvertedValue = ConvertedValue.extend(InitializerValue.getBitWidth());
459 ConvertedValue.setIsSigned(InitializerValue.isSigned());
461 if (ConvertedValue != InitializerValue)
465 ConstantType = Initializer->
getType();
466 ConstantValue =
APValue(InitializerValue);
482 raw_ostream &OS = llvm::errs();
483 bool PrintedSomething =
false;
486 PrintedSomething =
true;
490 if (PrintedSomething) {
495 if (CopyConstructor) {
496 OS <<
" (by copy constructor)";
497 }
else if (DirectBinding) {
498 OS <<
" (direct reference binding)";
499 }
else if (ReferenceBinding) {
500 OS <<
" (reference binding)";
502 PrintedSomething =
true;
506 if (PrintedSomething) {
510 PrintedSomething =
true;
513 if (!PrintedSomething) {
514 OS <<
"No conversions required";
521 raw_ostream &OS = llvm::errs();
522 if (Before.First || Before.Second || Before.Third) {
526 if (ConversionFunction)
527 OS <<
'\'' << *ConversionFunction <<
'\'';
529 OS <<
"aggregate initialization";
539 raw_ostream &OS = llvm::errs();
540 if (isStdInitializerListElement())
541 OS <<
"Worst std::initializer_list element conversion: ";
542 switch (ConversionKind) {
543 case StandardConversion:
544 OS <<
"Standard conversion: ";
547 case UserDefinedConversion:
548 OS <<
"User-defined conversion: ";
551 case EllipsisConversion:
552 OS <<
"Ellipsis conversion";
554 case AmbiguousConversion:
555 OS <<
"Ambiguous conversion";
558 OS <<
"Bad conversion";
570 conversions().~ConversionSet();
583 struct DFIArguments {
589 struct DFIParamWithArguments : DFIArguments {
594 struct DFIDeducedMismatchArgs : DFIArguments {
596 unsigned CallArgIndex;
613 Result.
Result =
static_cast<unsigned>(TDK);
622 Result.
Data =
nullptr;
627 Result.
Data = Info.
Param.getOpaqueValue();
633 auto *Saved =
new (Context) DFIDeducedMismatchArgs;
636 Saved->TemplateArgs = Info.
take();
644 DFIArguments *Saved =
new (Context) DFIArguments;
656 DFIParamWithArguments *Saved =
new (Context) DFIParamWithArguments;
657 Saved->Param = Info.
Param;
675 CNSInfo *Saved =
new (Context) CNSInfo;
676 Saved->TemplateArgs = Info.
take();
684 llvm_unreachable(
"not a deduction failure");
691 switch (static_cast<Sema::TemplateDeductionResult>(Result)) {
717 Diag->~PartialDiagnosticAt();
718 HasDiagnostic =
false;
726 Diag->~PartialDiagnosticAt();
727 HasDiagnostic =
false;
744 switch (static_cast<Sema::TemplateDeductionResult>(Result)) {
761 return TemplateParameter::getFromOpaqueValue(Data);
766 return static_cast<DFIParamWithArguments*
>(Data)->Param;
777 switch (static_cast<Sema::TemplateDeductionResult>(Result)) {
795 return static_cast<DFIDeducedMismatchArgs*
>(Data)->TemplateArgs;
801 return static_cast<CNSInfo*
>(Data)->TemplateArgs;
812 switch (static_cast<Sema::TemplateDeductionResult>(Result)) {
832 return &
static_cast<DFIArguments*
>(Data)->FirstArg;
843 switch (static_cast<Sema::TemplateDeductionResult>(Result)) {
863 return &
static_cast<DFIArguments*
>(Data)->SecondArg;
874 switch (static_cast<Sema::TemplateDeductionResult>(Result)) {
877 return static_cast<DFIDeducedMismatchArgs*
>(Data)->CallArgIndex;
886 if (!AllowRewrittenCandidates)
888 return Op == OO_EqualEqual || Op == OO_Spaceship;
903 void OverloadCandidateSet::destroyCandidates() {
904 for (
iterator i = begin(), e = end(); i != e; ++i) {
905 for (
auto &C : i->Conversions)
906 C.~ImplicitConversionSequence();
908 i->DeductionFailure.Destroy();
914 SlabAllocator.Reset();
915 NumInlineBytesUsed = 0;
922 class UnbridgedCastsSet {
932 Entry entry = { &E, E };
933 Entries.push_back(entry);
939 i = Entries.begin(), e = Entries.end(); i != e; ++i)
954 UnbridgedCastsSet *unbridgedCasts =
nullptr) {
958 if (placeholder->getKind() == BuiltinType::Overload)
return false;
962 if (placeholder->getKind() == BuiltinType::ARCUnbridgedCast &&
964 unbridgedCasts->save(S, E);
985 UnbridgedCastsSet &unbridged) {
986 for (
unsigned i = 0, e = Args.size(); i != e; ++i)
1028 NamedDecl *&Match,
bool NewIsUsingDecl) {
1033 bool OldIsUsingDecl =
false;
1034 if (isa<UsingShadowDecl>(OldD)) {
1035 OldIsUsingDecl =
true;
1039 if (NewIsUsingDecl)
continue;
1041 OldD = cast<UsingShadowDecl>(OldD)->getTargetDecl();
1046 if ((OldIsUsingDecl || NewIsUsingDecl) && !isVisible(*I))
1054 bool UseMemberUsingDeclRules =
1055 (OldIsUsingDecl || NewIsUsingDecl) && CurContext->isRecord() &&
1059 if (!IsOverload(New, OldF, UseMemberUsingDeclRules)) {
1060 if (UseMemberUsingDeclRules && OldIsUsingDecl) {
1061 HideUsingShadowDecl(S, cast<UsingShadowDecl>(*I));
1065 if (!isa<FunctionTemplateDecl>(OldD) &&
1066 !shouldLinkPossiblyHiddenDecl(*I, New))
1075 if (!getASTContext().canBuiltinBeRedeclared(OldF)) {
1077 return Ovl_NonFunction;
1079 }
else if (isa<UsingDecl>(OldD) || isa<UsingPackDecl>(OldD)) {
1083 }
else if (isa<TagDecl>(OldD)) {
1085 }
else if (
auto *UUD = dyn_cast<UnresolvedUsingValueDecl>(OldD)) {
1092 if (UUD->getQualifier()->isDependent() && !UUD->isCXXClassMember()) {
1094 return Ovl_NonFunction;
1101 return Ovl_NonFunction;
1126 if (CheckFunctionTemplateSpecialization(New,
nullptr, TemplateSpecResult,
1129 return Ovl_Overload;
1136 return Ovl_Overload;
1140 bool UseMemberUsingDeclRules,
bool ConsiderCudaAttrs,
1141 bool ConsiderRequiresClauses) {
1156 if ((OldTemplate ==
nullptr) != (NewTemplate ==
nullptr))
1169 if (isa<FunctionNoProtoType>(OldQType.
getTypePtr()) ||
1170 isa<FunctionNoProtoType>(NewQType.
getTypePtr()))
1179 if (OldQType != NewQType &&
1181 OldType->
isVariadic() != NewType->isVariadic() ||
1182 !FunctionParamTypesAreEqual(OldType, NewType)))
1197 if (!UseMemberUsingDeclRules && NewTemplate &&
1200 false, TPL_TemplateMatch) ||
1215 if (OldMethod && NewMethod &&
1216 !OldMethod->
isStatic() && !NewMethod->isStatic()) {
1218 if (!UseMemberUsingDeclRules &&
1220 NewMethod->getRefQualifier() ==
RQ_None)) {
1227 Diag(NewMethod->getLocation(), diag::err_ref_qualifier_overload)
1239 auto NewQuals = NewMethod->getMethodQualifiers();
1240 if (!getLangOpts().
CPlusPlus14 && NewMethod->isConstexpr() &&
1241 !isa<CXXConstructorDecl>(NewMethod))
1244 OldQuals.removeRestrict();
1245 NewQuals.removeRestrict();
1246 if (OldQuals != NewQuals)
1264 NewI != NewE || OldI != OldE; ++NewI, ++OldI) {
1265 if (NewI == NewE || OldI == OldE)
1267 llvm::FoldingSetNodeID NewID, OldID;
1268 NewI->getCond()->Profile(NewID, Context,
true);
1269 OldI->getCond()->Profile(OldID, Context,
true);
1274 if (getLangOpts().
CUDA && ConsiderCudaAttrs) {
1277 if (!isa<CXXDestructorDecl>(New)) {
1279 OldTarget = IdentifyCUDATarget(Old);
1280 if (NewTarget != CFT_InvalidTarget) {
1281 assert((OldTarget != CFT_InvalidTarget) &&
1282 "Unexpected invalid target.");
1286 if (NewTarget != OldTarget)
1292 if (ConsiderRequiresClauses) {
1295 if ((NewRC !=
nullptr) != (OldRC !=
nullptr))
1300 llvm::FoldingSetNodeID NewID, OldID;
1301 NewRC->
Profile(NewID, Context,
true);
1302 OldRC->Profile(OldID, Context,
true);
1319 bool SuppressUserConversions,
1321 bool InOverloadResolution,
1323 bool AllowObjCWritebackConversion,
1324 bool AllowObjCConversionOnExplicit) {
1327 if (SuppressUserConversions) {
1338 Conversions, AllowExplicit,
1339 AllowObjCConversionOnExplicit)) {
1356 if (Constructor->isCopyConstructor() &&
1357 (FromCanon == ToCanon ||
1368 if (ToCanon != FromCanon)
1379 Cand != Conversions.
end(); ++Cand)
1422 bool SuppressUserConversions,
1424 bool InOverloadResolution,
1426 bool AllowObjCWritebackConversion,
1427 bool AllowObjCConversionOnExplicit) {
1430 ICS.
Standard, CStyle, AllowObjCWritebackConversion)){
1470 AllowExplicit, InOverloadResolution, CStyle,
1471 AllowObjCWritebackConversion,
1472 AllowObjCConversionOnExplicit);
1477 bool SuppressUserConversions,
1479 bool InOverloadResolution,
1481 bool AllowObjCWritebackConversion) {
1483 SuppressUserConversions, AllowExplicit,
1484 InOverloadResolution, CStyle,
1485 AllowObjCWritebackConversion,
1498 return PerformImplicitConversion(From, ToType, Action, AllowExplicit, ICS);
1509 bool AllowObjCWritebackConversion
1510 = getLangOpts().ObjCAutoRefCount &&
1511 (Action == AA_Passing || Action == AA_Sending);
1512 if (getLangOpts().ObjC)
1513 CheckObjCBridgeRelatedConversions(From->
getBeginLoc(), ToType,
1520 AllowObjCWritebackConversion,
1522 return PerformImplicitConversion(From, ToType, ICS, Action);
1543 if (TyClass != CanFrom->getTypeClass())
return false;
1544 if (TyClass != Type::FunctionProto && TyClass != Type::FunctionNoProto) {
1545 if (TyClass == Type::Pointer) {
1548 }
else if (TyClass == Type::BlockPointer) {
1551 }
else if (TyClass == Type::MemberPointer) {
1555 if (ToMPT->getClass() != FromMPT->
getClass())
1557 CanTo = ToMPT->getPointeeType();
1563 TyClass = CanTo->getTypeClass();
1564 if (TyClass != CanFrom->getTypeClass())
return false;
1565 if (TyClass != Type::FunctionProto && TyClass != Type::FunctionNoProto)
1569 const auto *FromFn = cast<FunctionType>(CanFrom);
1572 const auto *ToFn = cast<FunctionType>(CanTo);
1575 bool Changed =
false;
1578 if (FromEInfo.getNoReturn() && !ToEInfo.getNoReturn()) {
1584 if (
const auto *FromFPT = dyn_cast<FunctionProtoType>(FromFn)) {
1585 const auto *ToFPT = cast<FunctionProtoType>(ToFn);
1586 if (FromFPT->isNothrow() && !ToFPT->isNothrow()) {
1587 FromFn = cast<FunctionType>(
1598 bool CanUseToFPT, CanUseFromFPT;
1600 CanUseFromFPT, NewParamInfos) &&
1601 CanUseToFPT && !CanUseFromFPT) {
1604 NewParamInfos.empty() ? nullptr : NewParamInfos.data();
1606 FromFPT->getParamTypes(), ExtInfo);
1615 assert(
QualType(FromFn, 0).isCanonical());
1616 if (
QualType(FromFn, 0) != CanTo)
return false;
1668 bool InOverloadResolution,
1681 bool InOverloadResolution,
1684 bool AllowObjCWritebackConversion) {
1731 if (Method && !Method->
isStatic()) {
1733 "Non-unary operator on non-static member address");
1734 assert(cast<UnaryOperator>(From->
IgnoreParens())->getOpcode()
1736 "Non-address-of operator on non-static member address");
1737 const Type *ClassType
1741 assert(cast<UnaryOperator>(From->
IgnoreParens())->getOpcode() ==
1743 "Non-address-of operator for overloaded function expression");
1770 FromType = Atomic->getValueType();
1805 if (
auto *FD = dyn_cast<FunctionDecl>(DRE->getDecl()))
1825 bool IncompatibleObjC =
false;
1876 if (Float128AndLongDouble &&
1878 &llvm::APFloat::PPCDoubleDouble()))
1893 }
else if (AllowObjCWritebackConversion &&
1897 FromType, IncompatibleObjC)) {
1903 InOverloadResolution, FromType)) {
1915 InOverloadResolution,
1946 bool ObjCLifetimeConversion;
1952 ObjCLifetimeConversion)) {
1971 CanonFrom = CanonTo;
1976 if (CanonFrom == CanonTo)
1981 if (S.
getLangOpts().CPlusPlus || !InOverloadResolution)
2025 bool InOverloadResolution,
2035 for (
const auto *it : UD->
fields()) {
2038 ToType = it->getType();
2068 return To->
getKind() == BuiltinType::Int;
2071 return To->
getKind() == BuiltinType::UInt;
2095 if (FromEnumType->getDecl()->isScoped())
2102 if (FromEnumType->getDecl()->isFixed()) {
2103 QualType Underlying = FromEnumType->getDecl()->getIntegerType();
2105 IsIntegralPromotion(
nullptr, Underlying, ToType);
2112 ToType, FromEnumType->getDecl()->getPromotionType());
2119 if (getLangOpts().CPlusPlus)
2137 uint64_t FromSize = Context.
getTypeSize(FromType);
2146 for (
int Idx = 0; Idx < 6; ++Idx) {
2147 uint64_t ToSize = Context.
getTypeSize(PromoteTypes[Idx]);
2148 if (FromSize < ToSize ||
2149 (FromSize == ToSize &&
2150 FromIsSigned == PromoteTypes[Idx]->isSignedIntegerType())) {
2177 MemberDecl->getBitWidth()->isIntegerConstantExpr(BitWidth, Context)) {
2178 llvm::APSInt ToSize(BitWidth.getBitWidth(), BitWidth.isUnsigned());
2182 if (BitWidth < ToSize ||
2184 return To->
getKind() == BuiltinType::Int;
2190 return To->
getKind() == BuiltinType::UInt;
2215 if (FromBuiltin->getKind() == BuiltinType::Float &&
2216 ToBuiltin->getKind() == BuiltinType::Double)
2222 if (!getLangOpts().CPlusPlus &&
2223 (FromBuiltin->getKind() == BuiltinType::Float ||
2224 FromBuiltin->getKind() == BuiltinType::Double) &&
2225 (ToBuiltin->getKind() == BuiltinType::LongDouble ||
2226 ToBuiltin->getKind() == BuiltinType::Float128))
2230 if (!getLangOpts().NativeHalfType &&
2231 FromBuiltin->getKind() == BuiltinType::Half &&
2232 ToBuiltin->getKind() == BuiltinType::Float)
2269 bool StripObjCLifetime =
false) {
2272 "Invalid similarly-qualified pointer type");
2283 if (StripObjCLifetime)
2294 if (isa<ObjCObjectPointerType>(ToType))
2303 if (isa<ObjCObjectPointerType>(ToType))
2309 bool InOverloadResolution,
2315 return !InOverloadResolution;
2339 bool InOverloadResolution,
2341 bool &IncompatibleObjC) {
2342 IncompatibleObjC =
false;
2343 if (isObjCPointerConversion(FromType, ToType, ConvertedType,
2350 ConvertedType = ToType;
2357 ConvertedType = ToType;
2364 ConvertedType = ToType;
2372 ConvertedType = ToType;
2382 ConvertedType = ToType;
2390 !getLangOpts().ObjCAutoRefCount) {
2421 if (getLangOpts().MSVCCompat && FromPointeeType->
isFunctionType() &&
2455 IsDerivedFrom(From->
getBeginLoc(), FromPointeeType, ToPointeeType)) {
2492 bool &IncompatibleObjC) {
2493 if (!getLangOpts().ObjC)
2505 if (ToObjCPtr && FromObjCPtr) {
2516 if (getLangOpts().
CPlusPlus && LHS && RHS &&
2518 FromObjCPtr->getPointeeType()))
2523 ConvertedType =
AdoptQualifiers(Context, ConvertedType, FromQualifiers);
2531 IncompatibleObjC =
true;
2535 ConvertedType =
AdoptQualifiers(Context, ConvertedType, FromQualifiers);
2547 if (FromObjCPtr && FromObjCPtr->isObjCBuiltinType()) {
2575 isObjCPointerConversion(FromPointeeType, ToPointeeType, ConvertedType,
2576 IncompatibleObjC)) {
2578 IncompatibleObjC =
true;
2580 ConvertedType =
AdoptQualifiers(Context, ConvertedType, FromQualifiers);
2587 isObjCPointerConversion(FromPointeeType, ToPointeeType, ConvertedType,
2588 IncompatibleObjC)) {
2591 ConvertedType =
AdoptQualifiers(Context, ConvertedType, FromQualifiers);
2603 if (FromFunctionType && ToFunctionType) {
2612 if (FromFunctionType->
getNumParams() != ToFunctionType->getNumParams() ||
2613 FromFunctionType->
isVariadic() != ToFunctionType->isVariadic() ||
2614 FromFunctionType->
getMethodQuals() != ToFunctionType->getMethodQuals())
2617 bool HasObjCConversion =
false;
2621 }
else if (isObjCPointerConversion(FromFunctionType->
getReturnType(),
2622 ToFunctionType->getReturnType(),
2623 ConvertedType, IncompatibleObjC)) {
2625 HasObjCConversion =
true;
2632 for (
unsigned ArgIdx = 0, NumArgs = FromFunctionType->
getNumParams();
2633 ArgIdx != NumArgs; ++ArgIdx) {
2635 QualType ToArgType = ToFunctionType->getParamType(ArgIdx);
2639 }
else if (isObjCPointerConversion(FromArgType, ToArgType,
2640 ConvertedType, IncompatibleObjC)) {
2642 HasObjCConversion =
true;
2649 if (HasObjCConversion) {
2653 IncompatibleObjC =
true;
2672 if (!getLangOpts().ObjCAutoRefCount ||
2714 bool IncompatibleObjC;
2716 FromPointee = ToPointee;
2717 else if (!isObjCPointerConversion(FromPointee, ToPointee, FromPointee,
2752 if (!FromFunctionType || !ToFunctionType)
2755 if (Context.
hasSameType(FromPointeeType, ToPointeeType))
2760 if (FromFunctionType->
getNumParams() != ToFunctionType->getNumParams() ||
2761 FromFunctionType->
isVariadic() != ToFunctionType->isVariadic())
2766 if (FromEInfo != ToEInfo)
2769 bool IncompatibleObjC =
false;
2771 ToFunctionType->getReturnType())) {
2775 QualType LHS = ToFunctionType->getReturnType();
2782 }
else if (isObjCPointerConversion(RHS, LHS,
2783 ConvertedType, IncompatibleObjC)) {
2784 if (IncompatibleObjC)
2793 for (
unsigned ArgIdx = 0, NumArgs = FromFunctionType->
getNumParams();
2794 ArgIdx != NumArgs; ++ArgIdx) {
2795 IncompatibleObjC =
false;
2797 QualType ToArgType = ToFunctionType->getParamType(ArgIdx);
2798 if (Context.
hasSameType(FromArgType, ToArgType)) {
2800 }
else if (isObjCPointerConversion(ToArgType, FromArgType,
2801 ConvertedType, IncompatibleObjC)) {
2802 if (IncompatibleObjC)
2811 bool CanUseToFPT, CanUseFromFPT;
2813 CanUseToFPT, CanUseFromFPT,
2817 ConvertedType = ToType;
2858 if (!Context.
hasSameType(FromMember->getClass(), ToMember->getClass())) {
2860 <<
QualType(FromMember->getClass(), 0);
2893 if (!FromFunction || !ToFunction) {
2898 if (FromFunction->
getNumParams() != ToFunction->getNumParams()) {
2906 if (!FunctionParamTypesAreEqual(FromFunction, ToFunction, &ArgPos)) {
2908 << ToFunction->getParamType(ArgPos)
2915 ToFunction->getReturnType())) {
2921 if (FromFunction->
getMethodQuals() != ToFunction->getMethodQuals()) {
2931 cast<FunctionProtoType>(ToFunction->getCanonicalTypeUnqualified())
2951 O && (O != E); ++O, ++N) {
2975 bool IgnoreBaseAccess,
2978 bool IsCStyleOrFunctionalCast = IgnoreBaseAccess;
2982 if (Diagnose && !IsCStyleOrFunctionalCast && !FromType->
isAnyPointerType() &&
2986 DiagRuntimeBehavior(From->
getExprLoc(), From,
2987 PDiag(diag::warn_impcast_bool_to_null_pointer)
2989 else if (!isUnevaluatedContext())
2998 if (FromPointeeType->
isRecordType() && ToPointeeType->isRecordType() &&
3002 unsigned InaccessibleID = 0;
3003 unsigned AmbigiousID = 0;
3005 InaccessibleID = diag::err_upcast_to_inaccessible_base;
3006 AmbigiousID = diag::err_ambiguous_derived_to_base_conv;
3008 if (CheckDerivedToBaseConversion(
3009 FromPointeeType, ToPointeeType, InaccessibleID, AmbigiousID,
3011 &BasePath, IgnoreBaseAccess))
3015 Kind = CK_DerivedToBase;
3018 if (Diagnose && !IsCStyleOrFunctionalCast &&
3019 FromPointeeType->
isFunctionType() && ToPointeeType->isVoidType()) {
3020 assert(getLangOpts().MSVCCompat &&
3021 "this should only be possible with MSVCCompat!");
3033 if (FromPtrType->isObjCBuiltinType() || ToPtrType->isObjCBuiltinType())
3036 Kind = CK_BlockPointerToObjCPointerCast;
3038 Kind = CK_CPointerToObjCPointerCast;
3042 Kind = CK_AnyPointerToBlockPointerCast;
3048 Kind = CK_NullToPointer;
3060 bool InOverloadResolution,
3070 ConvertedType = ToType;
3085 IsDerivedFrom(From->
getBeginLoc(), ToClass, FromClass)) {
3103 bool IgnoreBaseAccess) {
3110 "Expr must be null pointer constant!");
3111 Kind = CK_NullToMemberPointer;
3116 assert(ToPtrType &&
"No member pointer cast has a target type " 3117 "that is not a member pointer.");
3123 assert(FromClass->
isRecordType() &&
"Pointer into non-class.");
3124 assert(ToClass->isRecordType() &&
"Pointer into non-class.");
3128 bool DerivationOkay =
3129 IsDerivedFrom(From->
getBeginLoc(), ToClass, FromClass, Paths);
3130 assert(DerivationOkay &&
3131 "Should not have been called if derivation isn't OK.");
3132 (void)DerivationOkay;
3135 getUnqualifiedType())) {
3136 std::string PathDisplayStr = getAmbiguousPathsDisplayString(Paths);
3138 << 0 << FromClass << ToClass << PathDisplayStr << From->
getSourceRange();
3142 if (
const RecordType *VBase = Paths.getDetectedVirtual()) {
3144 << FromClass << ToClass <<
QualType(VBase, 0)
3149 if (!IgnoreBaseAccess)
3150 CheckBaseClassAccess(From->
getExprLoc(), FromClass, ToClass,
3152 diag::err_downcast_from_inaccessible_base);
3156 Kind = CK_BaseToDerivedMemberPointer;
3179 bool CStyle,
bool IsTopLevel,
3180 bool &PreviousToQualsIncludeConst,
3181 bool &ObjCLifetimeConversion) {
3194 ObjCLifetimeConversion =
true;
3230 !PreviousToQualsIncludeConst)
3235 PreviousToQualsIncludeConst =
3236 PreviousToQualsIncludeConst && ToQuals.
hasConst();
3249 bool CStyle,
bool &ObjCLifetimeConversion) {
3252 ObjCLifetimeConversion =
false;
3262 bool PreviousToQualsIncludeConst =
true;
3263 bool UnwrappedAnyPointer =
false;
3266 FromType, ToType, CStyle, !UnwrappedAnyPointer,
3267 PreviousToQualsIncludeConst, ObjCLifetimeConversion))
3269 UnwrappedAnyPointer =
true;
3286 bool InOverloadResolution,
3295 InOverloadResolution, InnerSCS,
3299 SCS.
Second = InnerSCS.Second;
3300 SCS.
setToType(1, InnerSCS.getToType(1));
3301 SCS.
Third = InnerSCS.Third;
3303 = InnerSCS.QualificationIncludesObjCLifetime;
3304 SCS.
setToType(2, InnerSCS.getToType(2));
3312 if (CtorType->getNumParams() > 0) {
3313 QualType FirstArg = CtorType->getParamType(0);
3325 bool AllowExplicit) {
3332 bool Usable = !Info.Constructor->isInvalidDecl() &&
3338 S.
Context, Info.Constructor, ToType);
3339 if (Info.ConstructorTmpl)
3342 CandidateSet, SuppressUserConversions,
3347 CandidateSet, SuppressUserConversions,
3348 false, AllowExplicit);
3352 bool HadMultipleCandidates = (CandidateSet.
size() > 1);
3355 switch (
auto Result =
3379 llvm_unreachable(
"Invalid OverloadResult!");
3401 bool AllowObjCConversionOnExplicit) {
3402 assert(AllowExplicit || !AllowObjCConversionOnExplicit);
3406 bool ConstructorsOnly =
false;
3422 ConstructorsOnly =
true;
3427 = dyn_cast<CXXRecordDecl>(ToRecordType->getDecl())) {
3429 Expr **Args = &From;
3430 unsigned NumArgs = 1;
3431 bool ListInitializing =
false;
3432 if (
InitListExpr *InitList = dyn_cast<InitListExpr>(From)) {
3435 S, From, ToType, ToRecordDecl, User, CandidateSet, AllowExplicit);
3444 Args = InitList->getInits();
3445 NumArgs = InitList->getNumInits();
3446 ListInitializing =
true;
3454 bool Usable = !Info.Constructor->isInvalidDecl();
3455 if (!ListInitializing)
3456 Usable = Usable && Info.Constructor->isConvertingConstructor(
3459 bool SuppressUserConversions = !ConstructorsOnly;
3460 if (SuppressUserConversions && ListInitializing) {
3461 SuppressUserConversions =
false;
3466 S.
Context, Info.Constructor, ToType);
3469 if (Info.ConstructorTmpl)
3471 Info.ConstructorTmpl, Info.FoundDecl,
3472 nullptr, llvm::makeArrayRef(Args, NumArgs),
3473 CandidateSet, SuppressUserConversions,
3474 false, AllowExplicit);
3479 llvm::makeArrayRef(Args, NumArgs),
3480 CandidateSet, SuppressUserConversions,
3481 false, AllowExplicit);
3488 if (ConstructorsOnly || isa<InitListExpr>(From)) {
3491 }
else if (
const RecordType *FromRecordType =
3494 = dyn_cast<CXXRecordDecl>(FromRecordType->getDecl())) {
3496 const auto &Conversions = FromRecordDecl->getVisibleConversionFunctions();
3497 for (
auto I = Conversions.
begin(), E = Conversions.
end(); I != E; ++I) {
3501 if (isa<UsingShadowDecl>(D))
3502 D = cast<UsingShadowDecl>(D)->getTargetDecl();
3506 if ((ConvTemplate = dyn_cast<FunctionTemplateDecl>(D)))
3509 Conv = cast<CXXConversionDecl>(D);
3513 ConvTemplate, FoundDecl, ActingContext, From, ToType,
3514 CandidateSet, AllowObjCConversionOnExplicit, AllowExplicit);
3517 Conv, FoundDecl, ActingContext, From, ToType, CandidateSet,
3518 AllowObjCConversionOnExplicit, AllowExplicit);
3523 bool HadMultipleCandidates = (CandidateSet.
size() > 1);
3526 switch (
auto Result =
3532 = dyn_cast<CXXConstructorDecl>(Best->Function)) {
3539 QualType ThisType = Constructor->getThisType();
3540 if (isa<InitListExpr>(From)) {
3544 if (Best->Conversions[0].isEllipsis())
3547 User.
Before = Best->Conversions[0].Standard;
3560 = dyn_cast<CXXConversionDecl>(Best->Function)) {
3567 User.
Before = Best->Conversions[0].Standard;
3582 User.
After = Best->FinalConversion;
3585 llvm_unreachable(
"Not a constructor or conversion function?");
3594 llvm_unreachable(
"Invalid OverloadResult!");
3604 CandidateSet,
false,
false);
3610 auto Cands = CandidateSet.CompleteCandidates(
3618 if (!RequireCompleteType(From->
getBeginLoc(), ToType,
3619 diag::err_typecheck_nonviable_condition_incomplete,
3625 CandidateSet.NoteCandidates(
3626 *
this, From, Cands);
3656 if (Block1 != Block2)
3743 if (!ICS1.
isBad()) {
3904 else if (Rank2 < Rank1)
3939 bool SCS1ConvertsToVoid
3941 bool SCS2ConvertsToVoid
3943 if (SCS1ConvertsToVoid != SCS2ConvertsToVoid) {
3948 }
else if (!SCS1ConvertsToVoid && !SCS2ConvertsToVoid) {
3954 }
else if (SCS1ConvertsToVoid && SCS2ConvertsToVoid &&
3983 if (FromObjCPtr1 && FromObjCPtr2) {
3988 if (AssignLeft != AssignRight) {
4023 if (UnqualT1 == UnqualT2) {
4035 if (isa<ArrayType>(T1) && T1Quals)
4037 if (isa<ArrayType>(T2) && T2Quals)
4083 if (SCS1IsCompatibleVectorConversion != SCS2IsCompatibleVectorConversion)
4084 return SCS1IsCompatibleVectorConversion
4122 if (UnqualT1 == UnqualT2)
4248 if (FromPointee1 == FromPointee2 && ToPointee1 != ToPointee2) {
4256 if (FromPointee1 != FromPointee2 && ToPointee1 == ToPointee2) {
4273 if (FromPtr1 && FromPtr2 && ToPtr1 && ToPtr2) {
4280 bool FromAssignRight
4289 if (ToPtr1->isObjCIdType() &&
4290 (ToPtr2->isObjCQualifiedIdType() || ToPtr2->getInterfaceDecl()))
4292 if (ToPtr2->isObjCIdType() &&
4293 (ToPtr1->isObjCQualifiedIdType() || ToPtr1->getInterfaceDecl()))
4298 if (ToPtr1->isObjCQualifiedIdType() && ToPtr2->getInterfaceDecl())
4300 if (ToPtr2->isObjCQualifiedIdType() && ToPtr1->getInterfaceDecl())
4305 if (ToPtr1->isObjCClassType() &&
4306 (ToPtr2->isObjCQualifiedClassType() || ToPtr2->getInterfaceDecl()))
4308 if (ToPtr2->isObjCClassType() &&
4309 (ToPtr1->isObjCQualifiedClassType() || ToPtr1->getInterfaceDecl()))
4314 if (ToPtr1->isObjCQualifiedClassType() && ToPtr2->getInterfaceDecl())
4316 if (ToPtr2->isObjCQualifiedClassType() && ToPtr1->getInterfaceDecl())
4322 (ToAssignLeft != ToAssignRight)) {
4333 }
else if (IsSecondSame)
4342 (FromAssignLeft != FromAssignRight))
4356 const Type *FromPointeeType1 = FromMemPointer1->getClass();
4357 const Type *ToPointeeType1 = ToMemPointer1->
getClass();
4358 const Type *FromPointeeType2 = FromMemPointer2->
getClass();
4359 const Type *ToPointeeType2 = ToMemPointer2->
getClass();
4365 if (FromPointee1 == FromPointee2 && ToPointee1 != ToPointee2) {
4372 if (ToPointee1 == ToPointee2 && FromPointee1 != FromPointee2) {
4413 return !Record->isInvalidDecl();
4439 "T1 must be the pointee type of the reference type");
4440 assert(!OrigT2->
isReferenceType() &&
"T2 cannot be a reference type");
4464 if (UnqualT1 == UnqualT2) {
4466 }
else if (isCompleteType(Loc, OrigT2) &&
4468 IsDerivedFrom(Loc, UnqualT2, UnqualT1))
4469 Conv |= ReferenceConversions::DerivedToBase;
4475 IsFunctionConversion(UnqualT2, UnqualT1, ConvertedT2)) {
4478 return Ref_Compatible;
4480 bool ConvertedReferent = Conv != 0;
4484 bool PreviousToQualsIncludeConst =
true;
4485 bool TopLevel =
true;
4491 Conv |= ReferenceConversions::Qualification;
4497 Conv |= ReferenceConversions::NestedQualification;
4505 bool ObjCLifetimeConversion =
false;
4507 PreviousToQualsIncludeConst,
4508 ObjCLifetimeConversion))
4514 if (ObjCLifetimeConversion)
4515 Conv |= ReferenceConversions::ObjCLifetime;
4534 bool AllowExplicit) {
4535 assert(T2->
isRecordType() &&
"Can only find conversions of record types.");
4536 auto *T2RecordDecl = cast<CXXRecordDecl>(T2->
castAs<
RecordType>()->getDecl());
4540 const auto &Conversions = T2RecordDecl->getVisibleConversionFunctions();
4541 for (
auto I = Conversions.begin(), E = Conversions.end(); I != E; ++I) {
4544 if (isa<UsingShadowDecl>(D))
4545 D = cast<UsingShadowDecl>(D)->getTargetDecl();
4553 Conv = cast<CXXConversionDecl>(D);
4565 if (!ConvTemplate &&
4568 Conv->getConversionType()
4569 .getNonReferenceType()
4570 .getUnqualifiedType(),
4589 ConvTemplate, I.getPair(), ActingDC, Init, DeclType, CandidateSet,
4590 false, AllowExplicit);
4593 Conv, I.getPair(), ActingDC, Init, DeclType, CandidateSet,
4594 false, AllowExplicit);
4597 bool HadMultipleCandidates = (CandidateSet.size() > 1);
4600 switch (CandidateSet.BestViableFunction(S, DeclLoc, Best)) {
4612 if (!Best->FinalConversion.DirectBinding)
4624 "Expected a direct reference binding!");
4630 Cand != CandidateSet.end(); ++Cand)
4642 llvm_unreachable(
"Invalid OverloadResult!");
4650 bool SuppressUserConversions,
4651 bool AllowExplicit) {
4652 assert(DeclType->
isReferenceType() &&
"Reference init needs a reference");
4679 auto SetAsReferenceBinding = [&](
bool BindsDirectly) {
4684 ICS.Standard.Second = (RefConv & Sema::ReferenceConversions::DerivedToBase)
4692 ICS.Standard.Third = (RefConv &
4693 Sema::ReferenceConversions::NestedQualification)
4697 ICS.Standard.setToType(0, T2);
4698 ICS.Standard.setToType(1, T1);
4699 ICS.Standard.setToType(2, T1);
4700 ICS.Standard.ReferenceBinding =
true;
4701 ICS.Standard.DirectBinding = BindsDirectly;
4702 ICS.Standard.IsLvalueReference = !isRValRef;
4704 ICS.Standard.BindsToRvalue = InitCategory.
isRValue();
4705 ICS.Standard.BindsImplicitObjectArgumentWithoutRefQualifier =
false;
4706 ICS.Standard.ObjCLifetimeConversionBinding =
4707 (RefConv & Sema::ReferenceConversions::ObjCLifetime) != 0;
4708 ICS.Standard.CopyConstructor =
nullptr;
4709 ICS.Standard.DeprecatedStringLiteralToCharPtr =
false;
4730 SetAsReferenceBinding(
true);
4776 SetAsReferenceBinding(S.
getLangOpts().CPlusPlus11 ||
4800 if (ICS.isUserDefined() && isRValRef &&
4872 if (ICS.isStandard()) {
4873 ICS.Standard.ReferenceBinding =
true;
4874 ICS.Standard.IsLvalueReference = !isRValRef;
4875 ICS.Standard.BindsToFunctionLvalue =
false;
4876 ICS.Standard.BindsToRvalue =
true;
4877 ICS.Standard.BindsImplicitObjectArgumentWithoutRefQualifier =
false;
4878 ICS.Standard.ObjCLifetimeConversionBinding =
false;
4879 }
else if (ICS.isUserDefined()) {
4881 ICS.UserDefined.ConversionFunction->getReturnType()
4898 ICS.UserDefined.After.ReferenceBinding =
true;
4899 ICS.UserDefined.After.IsLvalueReference = !isRValRef;
4900 ICS.UserDefined.After.BindsToFunctionLvalue =
false;
4901 ICS.UserDefined.After.BindsToRvalue = !LValRefType;
4902 ICS.UserDefined.After.BindsImplicitObjectArgumentWithoutRefQualifier =
false;
4903 ICS.UserDefined.After.ObjCLifetimeConversionBinding =
false;
4911 bool SuppressUserConversions,
4912 bool InOverloadResolution,
4913 bool AllowObjCWritebackConversion,
4914 bool AllowExplicit =
false);
4920 bool SuppressUserConversions,
4921 bool InOverloadResolution,
4922 bool AllowObjCWritebackConversion) {
4951 SuppressUserConversions,
4952 InOverloadResolution,
4953 AllowObjCWritebackConversion);
4986 bool toStdInitializerList =
false;
4993 for (
unsigned i = 0, e = From->
getNumInits(); i < e; ++i) {
4997 InOverloadResolution,
4998 AllowObjCWritebackConversion);
5035 InOverloadResolution,
false,
5036 AllowObjCWritebackConversion,
5091 Init, ToType,
false, Found))
5101 SuppressUserConversions,
5109 InOverloadResolution,
5110 AllowObjCWritebackConversion);
5111 if (Result.isFailure())
5113 assert(!Result.isEllipsis() &&
5114 "Sub-initialization cannot result in ellipsis conversion.");
5120 Result.UserDefined.After;
5141 if (NumInits == 1 && !isa<InitListExpr>(From->
getInit(0)))
5143 SuppressUserConversions,
5144 InOverloadResolution,
5145 AllowObjCWritebackConversion);
5148 else if (NumInits == 0) {
5171 bool SuppressUserConversions,
5172 bool InOverloadResolution,
5173 bool AllowObjCWritebackConversion,
5174 bool AllowExplicit) {
5175 if (
InitListExpr *FromInitList = dyn_cast<InitListExpr>(From))
5177 InOverloadResolution,AllowObjCWritebackConversion);
5182 SuppressUserConversions, AllowExplicit);
5185 SuppressUserConversions,
5187 InOverloadResolution,
5189 AllowObjCWritebackConversion,
5202 return !ICS.
isBad();
5217 if (isa<CXXDestructorDecl>(Method)) {
5234 assert(FromClassification.
isLValue());
5260 != FromTypeCanon.getLocalCVRQualifiers() &&
5263 FromType, ImplicitParamType);
5267 if (FromTypeCanon.hasAddressSpace()) {
5269 Qualifiers QualsFromType = FromTypeCanon.getQualifiers();
5272 FromType, ImplicitParamType);
5287 FromType, ImplicitParamType);
5307 if (!FromClassification.
isRValue()) {
5350 FromRecordType = From->
getType();
5351 DestType = ImplicitParamRecordType;
5352 FromClassification = From->
Classify(Context);
5356 From = CreateMaterializeTemporaryExpr(FromRecordType, From,
5368 switch (ICS.Bad.Kind) {
5375 << Method->getDeclName() << FromRecordType << (CVR - 1)
5377 Diag(Method->getLocation(), diag::note_previous_decl)
5378 << Method->getDeclName();
5386 bool IsRValueQualified =
5389 << Method->getDeclName() << FromClassification.
isRValue()
5390 << IsRValueQualified;
5391 Diag(Method->getLocation(), diag::note_previous_decl)
5392 << Method->getDeclName();
5401 return Diag(From->
getBeginLoc(), diag::err_member_function_call_bad_type)
5402 << ImplicitParamRecordType << FromRecordType
5408 PerformObjectMemberConversion(From, Qualifier, FoundDecl, Method);
5411 From = FromRes.
get();
5420 CK = CK_AddressSpaceConversion;
5423 From = ImpCastExprToType(From, DestType, CK, From->
getValueKind()).
get();
5449 return PerformImplicitConversion(From, Context.
BoolTy, ICS, AA_Converting);
5451 if (!DiagnoseMultipleUserDefinedConversion(From, Context.
BoolTy))
5511 llvm_unreachable(
"found a first conversion kind in Second");
5514 llvm_unreachable(
"found a third conversion kind in Second");
5520 llvm_unreachable(
"unknown conversion kind");
5531 "converted constant expression outside C++11");
5567 diag::err_typecheck_converted_constant_expression)
5572 llvm_unreachable(
"ellipsis conversion in converted constant expression");
5578 diag::err_typecheck_converted_constant_expression_disallowed)
5584 diag::err_typecheck_converted_constant_expression_indirect)
5605 PreNarrowingType)) {
5623 << CCE << 0 << From->
getType() << T;
5627 if (Result.
get()->isValueDependent()) {
5640 if (!Result.
get()->EvaluateAsConstantExpr(Eval, Usage, S.
Context) ||
5641 (RequireInt && !Eval.
Val.
isInt())) {
5648 if (Notes.empty()) {
5655 if (Notes.size() == 1 &&
5656 Notes[0].second.getDiagID() == diag::note_invalid_subexpr_in_const_expr)
5657 S.
Diag(Notes[0].first, diag::err_expr_not_cce) << CCE;
5661 for (
unsigned I = 0; I < Notes.size(); ++I)
5662 S.
Diag(Notes[I].first, Notes[I].second);
5679 if (!R.isInvalid() && !R.get()->isValueDependent())
5742 return PerformImplicitConversion(From, Ty, ICS, AA_Converting);
5762 for (
unsigned I = 0, N = ViableConversions.
size(); I != N; ++I) {
5764 cast<CXXConversionDecl>(ViableConversions[I]->getUnderlyingDecl());
5774 QualType T,
bool HadMultipleCandidates,
5776 if (ExplicitConversions.
size() == 1 && !Converter.
Suppress) {
5784 std::string TypeStr;
5789 "static_cast<" + TypeStr +
">(")
5801 HadMultipleCandidates);
5806 CK_UserDefinedConversion, Result.
get(),
5807 nullptr, Result.
get()->getValueKind());
5814 QualType T,
bool HadMultipleCandidates,
5830 HadMultipleCandidates);
5835 CK_UserDefinedConversion, Result.
get(),
5836 nullptr, Result.
get()->getValueKind());
5854 for (
unsigned I = 0, N = ViableConversions.
size(); I != N; ++I) {
5858 if (isa<UsingShadowDecl>(D))
5859 D = cast<UsingShadowDecl>(D)->getTargetDecl();
5863 if ((ConvTemplate = dyn_cast<FunctionTemplateDecl>(D)))
5866 Conv = cast<CXXConversionDecl>(D);
5870 ConvTemplate, FoundDecl, ActingContext, From, ToType, CandidateSet,
5874 ToType, CandidateSet,
5906 ExprResult result = CheckPlaceholderExpr(From);
5909 From = result.
get();
5914 if (Converter.
match(T))
5915 return DefaultLvalueConversion(From);
5922 if (!RecordTy || !getLangOpts().CPlusPlus) {
5934 : Converter(Converter), From(From) {}
5939 } IncompleteDiagnoser(Converter, From);
5941 if (Converter.
Suppress ? !isCompleteType(Loc, T)
5942 : RequireCompleteType(Loc, T, IncompleteDiagnoser))
5949 const auto &Conversions =
5950 cast<CXXRecordDecl>(RecordTy->
getDecl())->getVisibleConversionFunctions();
5952 bool HadMultipleCandidates =
5953 (
std::distance(Conversions.begin(), Conversions.end()) > 1);
5957 bool HasUniqueTargetType =
true;
5960 for (
auto I = Conversions.begin(), E = Conversions.end(); I != E; ++I) {
5965 if (getLangOpts().CPlusPlus14)
5970 Conversion = cast<CXXConversionDecl>(D);
5972 assert((!ConvTemplate || getLangOpts().
CPlusPlus14) &&
5973 "Conversion operator templates are considered potentially " 5977 if (Converter.
match(CurToType) || ConvTemplate) {
5983 ExplicitConversions.
addDecl(I.getDecl(), I.getAccess());
5985 if (!ConvTemplate && getLangOpts().CPlusPlus14) {
5988 else if (HasUniqueTargetType &&
5990 HasUniqueTargetType =
false;
5992 ViableConversions.
addDecl(I.getDecl(), I.getAccess());
5997 if (getLangOpts().CPlusPlus14) {
6010 HadMultipleCandidates,
6011 ExplicitConversions))
6017 if (!HasUniqueTargetType)
6036 HadMultipleCandidates, Found))
6045 HadMultipleCandidates,
6046 ExplicitConversions))
6054 switch (ViableConversions.
size()) {
6057 HadMultipleCandidates,
6058 ExplicitConversions))
6068 HadMultipleCandidates, Found))
6099 if (Proto->getNumParams() < 1)
6103 QualType ArgType = Proto->getParamType(0).getNonReferenceType();
6108 if (Proto->getNumParams() < 2)
6112 QualType ArgType = Proto->getParamType(1).getNonReferenceType();
6131 bool PartialOverloading,
bool AllowExplicit,
bool AllowExplicitConversions,
6136 assert(Proto &&
"Functions without a prototype cannot be overloaded");
6138 "Use AddTemplateOverloadCandidate for function templates");
6140 if (
CXXMethodDecl *Method = dyn_cast<CXXMethodDecl>(Function)) {
6141 if (!isa<CXXConstructorDecl>(Method)) {
6149 AddMethodCandidate(Method, FoundDecl, Method->getParent(),
QualType(),
6151 CandidateSet, SuppressUserConversions,
6152 PartialOverloading, EarlyConversions, PO);
6187 CandidateSet.
addCandidate(Args.size(), EarlyConversions);
6202 Candidate.
Viable =
false;
6208 !Function->
getAttr<TargetAttr>()->isDefaultVersion()) {
6209 Candidate.
Viable =
false;
6221 IsDerivedFrom(Args[0]->getBeginLoc(), Args[0]->getType(),
6223 Candidate.
Viable =
false;
6236 if (Shadow && Args.size() == 1 && Constructor->
getNumParams() >= 1 &&
6244 Candidate.
Viable =
false;
6255 Candidate.
Viable =
false;
6265 if (TooManyArguments(NumParams, Args.size(), PartialOverloading) &&
6267 Candidate.
Viable =
false;
6278 if (Args.size() < MinRequiredArgs && !PartialOverloading) {
6280 Candidate.
Viable =
false;
6286 if (getLangOpts().CUDA)
6287 if (
const FunctionDecl *Caller = dyn_cast<FunctionDecl>(CurContext))
6292 if (!Caller->isImplicit() && !IsAllowedCUDACall(Caller, Function)) {
6293 Candidate.
Viable =
false;
6300 if (CheckFunctionConstraints(Function, Satisfaction) ||
6302 Candidate.
Viable =
false;
6310 for (
unsigned ArgIdx = 0; ArgIdx < Args.size(); ++ArgIdx) {
6313 if (Candidate.
Conversions[ConvIdx].isInitialized()) {
6316 }
else if (ArgIdx < NumParams) {
6323 *
this, Args[ArgIdx], ParamType, SuppressUserConversions,
6326 getLangOpts().ObjCAutoRefCount, AllowExplicitConversions);
6328 Candidate.
Viable =
false;
6340 if (EnableIfAttr *FailedAttr = CheckEnableIf(Function, Args)) {
6341 Candidate.
Viable =
false;
6347 if (LangOpts.OpenCL && isOpenCLDisabledDecl(Function)) {
6348 Candidate.
Viable =
false;
6357 if (Methods.size() <= 1)
6360 for (
unsigned b = 0, e = Methods.size(); b < e; b++) {
6368 if (Args.size() < NumNamedArgs)
6371 for (
unsigned i = 0; i < NumNamedArgs; i++) {
6373 if (Args[i]->isTypeDependent()) {
6379 Expr *argExpr = Args[i];
6380 assert(argExpr &&
"SelectBestMethod(): missing expression");
6385 !param->
hasAttr<CFConsumedAttr>())
6386 argExpr = stripARCUnbridgedCast(argExpr);
6399 getLangOpts().ObjCAutoRefCount,
6403 if (ConversionState.
isBad() ||
6413 for (
unsigned i = NumNamedArgs, e = Args.size(); i < e; ++i) {
6414 if (Args[i]->isTypeDependent()) {
6418 ExprResult Arg = DefaultVariadicArgumentPromotion(Args[i], VariadicMethod,
6427 if (Args.size() != NumNamedArgs)
6429 else if (Match && NumNamedArgs == 0 && Methods.size() > 1) {
6432 for (
unsigned b = 0, e = Methods.size(); b < e; b++) {
6433 QualType ReturnT = Methods[b]->getReturnType();
6449 bool MissingImplicitThis,
Expr *&ConvertedThis,
6453 assert(!isa<CXXConstructorDecl>(Method) &&
6454 "Shouldn't have `this` for ctors!");
6455 assert(!Method->
isStatic() &&
"Shouldn't have `this` for static methods!");
6457 ThisArg,
nullptr, Method, Method);
6460 ConvertedThis = R.get();
6462 if (
auto *MD = dyn_cast<CXXMethodDecl>(Function)) {
6464 assert((MissingImplicitThis || MD->isStatic() ||
6465 isa<CXXConstructorDecl>(MD)) &&
6466 "Expected `this` for non-ctor instance methods");
6468 ConvertedThis =
nullptr;
6476 for (
unsigned I = 0; I != ArgSizeNoVarargs; ++I) {
6485 ConvertedArgs.push_back(R.
get());
6493 for (
unsigned i = Args.size(), e = Function->
getNumParams(); i != e; ++i) {
6508 ConvertedArgs.push_back(R.
get());
6518 bool MissingImplicitThis) {
6520 if (EnableIfAttrs.begin() == EnableIfAttrs.end())
6526 Expr *DiscardedThis;
6528 *
this, Function,
nullptr, Args, Trap,
6529 true, DiscardedThis, ConvertedArgs))
6530 return *EnableIfAttrs.begin();
6532 for (
auto *EIA : EnableIfAttrs) {
6536 if (EIA->getCond()->isValueDependent() ||
6537 !EIA->getCond()->EvaluateWithSubstitution(
6538 Result, Context, Function, llvm::makeArrayRef(ConvertedArgs)))
6541 if (!Result.
isInt() || !Result.
getInt().getBoolValue())
6547 template <
typename CheckFn>
6550 CheckFn &&IsSuccessful) {
6553 if (ArgDependent == DIA->getArgDependent())
6554 Attrs.push_back(DIA);
6561 auto WarningBegin = std::stable_partition(
6562 Attrs.begin(), Attrs.end(),
6563 [](
const DiagnoseIfAttr *DIA) {
return DIA->isError(); });
6567 auto ErrAttr = llvm::find_if(llvm::make_range(Attrs.begin(), WarningBegin),
6569 if (ErrAttr != WarningBegin) {
6570 const DiagnoseIfAttr *DIA = *ErrAttr;
6571 S.
Diag(Loc, diag::err_diagnose_if_succeeded) << DIA->getMessage();
6572 S.
Diag(DIA->getLocation(), diag::note_from_diagnose_if)
6573 << DIA->getParent() << DIA->getCond()->getSourceRange();
6577 for (
const auto *DIA : llvm::make_range(WarningBegin, Attrs.end()))
6578 if (IsSuccessful(DIA)) {
6579 S.
Diag(Loc, diag::warn_diagnose_if_succeeded) << DIA->getMessage();
6580 S.
Diag(DIA->getLocation(), diag::note_from_diagnose_if)
6581 << DIA->getParent() << DIA->getCond()->getSourceRange();
6588 const Expr *ThisArg,
6592 *
this, Function,
true, Loc,
6593 [&](
const DiagnoseIfAttr *DIA) {
6598 if (!DIA->getCond()->EvaluateWithSubstitution(
6599 Result, Context, cast<FunctionDecl>(DIA->getParent()), Args, ThisArg))
6601 return Result.
isInt() && Result.
getInt().getBoolValue();
6608 *
this, ND,
false, Loc,
6609 [&](
const DiagnoseIfAttr *DIA) {
6611 return DIA->getCond()->EvaluateAsBooleanCondition(Result, Context) &&
6622 bool SuppressUserConversions,
6623 bool PartialOverloading,
6624 bool FirstArgumentIsBase) {
6633 if (isa<CXXMethodDecl>(FD) && !cast<CXXMethodDecl>(FD)->isStatic()) {
6636 if (Args.size() > 0) {
6637 if (
Expr *E = Args[0]) {
6639 ObjectType = E->getType();
6645 ObjectClassification = E->Classify(Context);
6647 FunctionArgs = Args.slice(1);
6650 AddMethodTemplateCandidate(
6651 FunTmpl, F.getPair(),
6653 ExplicitTemplateArgs, ObjectType, ObjectClassification,
6654 FunctionArgs, CandidateSet, SuppressUserConversions,
6655 PartialOverloading);
6657 AddMethodCandidate(cast<CXXMethodDecl>(FD), F.getPair(),
6658 cast<CXXMethodDecl>(FD)->getParent(), ObjectType,
6659 ObjectClassification, FunctionArgs, CandidateSet,
6660 SuppressUserConversions, PartialOverloading);
6667 if (Args.size() > 0 &&
6668 (!Args[0] || (FirstArgumentIsBase && isa<CXXMethodDecl>(FD) &&
6669 !isa<CXXConstructorDecl>(FD)))) {
6670 assert(cast<CXXMethodDecl>(FD)->isStatic());
6671 FunctionArgs = Args.slice(1);
6674 AddTemplateOverloadCandidate(FunTmpl, F.getPair(),
6675 ExplicitTemplateArgs, FunctionArgs,
6676 CandidateSet, SuppressUserConversions,
6677 PartialOverloading);
6679 AddOverloadCandidate(FD, F.getPair(), FunctionArgs, CandidateSet,
6680 SuppressUserConversions, PartialOverloading);
6692 bool SuppressUserConversions,
6697 if (isa<UsingShadowDecl>(Decl))
6698 Decl = cast<UsingShadowDecl>(Decl)->getTargetDecl();
6701 assert(isa<CXXMethodDecl>(TD->getTemplatedDecl()) &&
6702 "Expected a member function template");
6703 AddMethodTemplateCandidate(TD, FoundDecl, ActingContext,
6704 nullptr, ObjectType,
6705 ObjectClassification, Args, CandidateSet,
6706 SuppressUserConversions,
false, PO);
6708 AddMethodCandidate(cast<CXXMethodDecl>(Decl), FoundDecl, ActingContext,
6709 ObjectType, ObjectClassification, Args, CandidateSet,
6710 SuppressUserConversions,
false, None, PO);
6727 bool SuppressUserConversions,
6728 bool PartialOverloading,
6733 assert(Proto &&
"Methods without a prototype cannot be overloaded");
6734 assert(!isa<CXXConstructorDecl>(Method) &&
6735 "Use AddOverloadCandidate for constructors");
6753 CandidateSet.
addCandidate(Args.size() + 1, EarlyConversions);
6767 if (TooManyArguments(NumParams, Args.size(), PartialOverloading) &&
6769 Candidate.
Viable =
false;
6780 if (Args.size() < MinRequiredArgs && !PartialOverloading) {
6782 Candidate.
Viable =
false;
6797 *
this, CandidateSet.
getLocation(), ObjectType, ObjectClassification,
6798 Method, ActingContext);
6800 Candidate.
Viable =
false;
6807 if (getLangOpts().CUDA)
6808 if (
const FunctionDecl *Caller = dyn_cast<FunctionDecl>(CurContext))
6809 if (!IsAllowedCUDACall(Caller, Method)) {
6810 Candidate.Viable =
false;
6815 if (Method->getTrailingRequiresClause()) {
6817 if (CheckFunctionConstraints(Method, Satisfaction) ||
6819 Candidate.Viable =
false;
6827 for (
unsigned ArgIdx = 0; ArgIdx < Args.size(); ++ArgIdx) {
6830 if (Candidate.Conversions[ConvIdx].isInitialized()) {
6833 }
else if (ArgIdx < NumParams) {
6838 QualType ParamType = Proto->getParamType(ArgIdx);
6839 Candidate.Conversions[ConvIdx]
6841 SuppressUserConversions,
6844 getLangOpts().ObjCAutoRefCount);
6845 if (Candidate.Conversions[ConvIdx].isBad()) {
6846 Candidate.Viable =
false;
6854 Candidate.Conversions[ConvIdx].setEllipsis();
6858 if (EnableIfAttr *FailedAttr = CheckEnableIf(Method, Args,
true)) {
6859 Candidate.Viable =
false;
6861 Candidate.DeductionFailure.Data = FailedAttr;
6865 if (Method->isMultiVersion() && Method->hasAttr<TargetAttr>() &&
6866 !Method->getAttr<TargetAttr>()->isDefaultVersion()) {
6867 Candidate.Viable =
false;
6898 MethodTmpl, ExplicitTemplateArgs, Args, Specialization, Info,
6900 return CheckNonDependentConversions(
6901 MethodTmpl, ParamTypes, Args, CandidateSet, Conversions,
6902 SuppressUserConversions, ActingContext, ObjectType,
6903 ObjectClassification, PO);
6906 CandidateSet.
addCandidate(Conversions.size(), Conversions);
6909 Candidate.
Viable =
false;
6914 cast<CXXMethodDecl>(Candidate.
Function)->isStatic() ||
6917 if (Result == TDK_NonDependentConversionFailure)
6929 assert(Specialization &&
"Missing member function template specialization?");
6930 assert(isa<CXXMethodDecl>(Specialization) &&
6931 "Specialization is not a member function?");
6932 AddMethodCandidate(cast<CXXMethodDecl>(Specialization), FoundDecl,
6933 ActingContext, ObjectType, ObjectClassification, Args,
6934 CandidateSet, SuppressUserConversions, PartialOverloading,
6951 bool PartialOverloading,
bool AllowExplicit,
ADLCallKind IsADLCandidate,
6963 Candidate.
Viable =
false;
6981 FunctionTemplate, ExplicitTemplateArgs, Args, Specialization, Info,
6983 return CheckNonDependentConversions(
6984 FunctionTemplate, ParamTypes, Args, CandidateSet, Conversions,
6985 SuppressUserConversions,
nullptr,
QualType(), {}, PO);
6988 CandidateSet.
addCandidate(Conversions.size(), Conversions);
6991 Candidate.
Viable =
false;
6999 isa<CXXMethodDecl>(Candidate.
Function) &&
7000 !isa<CXXConstructorDecl>(Candidate.
Function);
7002 if (Result == TDK_NonDependentConversionFailure)
7014 assert(Specialization &&
"Missing function template specialization?");
7015 AddOverloadCandidate(
7016 Specialization, FoundDecl, Args, CandidateSet, SuppressUserConversions,
7017 PartialOverloading, AllowExplicit,
7018 false, IsADLCandidate, Conversions, PO);
7033 const bool AllowExplicit =
false;
7037 bool HasThisConversion = Method && !isa<CXXConstructorDecl>(Method);
7038 unsigned ThisConversions = HasThisConversion ? 1 : 0;
7050 if (HasThisConversion && !cast<CXXMethodDecl>(FD)->isStatic() &&
7054 *
this, CandidateSet.
getLocation(), ObjectType, ObjectClassification,
7055 Method, ActingContext);
7056 if (Conversions[ConvIdx].isBad())
7060 for (
unsigned I = 0, N =
std::min(ParamTypes.size(), Args.size()); I != N;
7062 QualType ParamType = ParamTypes[I];
7066 : (ThisConversions + I);
7067 Conversions[ConvIdx]
7069 SuppressUserConversions,
7072 getLangOpts().ObjCAutoRefCount,
7074 if (Conversions[ConvIdx].isBad())
7096 bool AllowObjCPointerConversion) {
7104 bool ObjCLifetimeConversion;
7106 ObjCLifetimeConversion))
7111 if (!AllowObjCPointerConversion)
7115 bool IncompatibleObjC =
false;
7131 bool AllowExplicit,
bool AllowResultConversion) {
7133 "Conversion function templates use AddTemplateConversionCandidate");
7140 if (getLangOpts().CPlusPlus14 && ConvType->isUndeducedType()) {
7141 if (DeduceReturnType(Conversion, From->
getExprLoc()))
7148 if (!AllowResultConversion &&
7160 AllowObjCConversionOnExplicit))
7182 if (!AllowExplicit && Conversion->
isExplicit()) {
7183 Candidate.
Viable =
false;
7203 From->
Classify(Context), Conversion, ConversionContext);
7206 Candidate.
Viable =
false;
7213 if (CheckFunctionConstraints(Conversion, Satisfaction) ||
7215 Candidate.
Viable =
false;
7227 if (FromCanon == ToCanon ||
7228 IsDerivedFrom(CandidateSet.
getLocation(), FromCanon, ToCanon)) {
7229 Candidate.
Viable =
false;
7246 CK_FunctionToPointerDecay,
7250 if (!isCompleteType(From->
getBeginLoc(), ConversionType)) {
7251 Candidate.
Viable =
false;
7265 Buffer, &ConversionFn, CallResultType, VK, From->
getBeginLoc());
7273 switch (ICS.getKind()) {
7283 Candidate.
Viable =
false;
7295 Candidate.
Viable =
false;
7302 Candidate.
Viable =
false;
7308 "Can only end up with a standard conversion sequence or failure");
7311 if (EnableIfAttr *FailedAttr = CheckEnableIf(Conversion, None)) {
7312 Candidate.
Viable =
false;
7319 !Conversion->
getAttr<TargetAttr>()->isDefaultVersion()) {
7320 Candidate.
Viable =
false;
7334 bool AllowExplicit,
bool AllowResultConversion) {
7336 "Only conversion function templates permitted here");
7348 Candidate.
Viable =
false;
7357 Specialization, Info)) {
7361 Candidate.
Viable =
false;
7373 assert(Specialization &&
"Missing function template specialization?");
7374 AddConversionCandidate(Specialization, FoundDecl, ActingDC, From, ToType,
7375 CandidateSet, AllowObjCConversionOnExplicit,
7376 AllowExplicit, AllowResultConversion);
7411 Object->
Classify(Context), Conversion, ActingContext);
7412 if (ObjectInit.
isBad()) {
7413 Candidate.
Viable =
false;
7424 Candidate.
Conversions[0].UserDefined.EllipsisConversion =
false;
7425 Candidate.
Conversions[0].UserDefined.HadMultipleCandidates =
false;
7426 Candidate.
Conversions[0].UserDefined.ConversionFunction = Conversion;
7427 Candidate.
Conversions[0].UserDefined.FoundConversionFunction = FoundDecl;
7430 Candidate.
Conversions[0].UserDefined.After.setAsIdentityConversion();
7438 if (Args.size() > NumParams && !Proto->
isVariadic()) {
7439 Candidate.
Viable =
false;
7446 if (Args.size() < NumParams) {
7448 Candidate.
Viable =
false;
7455 for (
unsigned ArgIdx = 0, N = Args.size(); ArgIdx != N; ++ArgIdx) {
7456 if (ArgIdx < NumParams) {
7467 getLangOpts().ObjCAutoRefCount);
7469 Candidate.
Viable =
false;
7481 if (EnableIfAttr *FailedAttr = CheckEnableIf(Conversion, None)) {
7482 Candidate.
Viable =
false;
7507 assert(!isa<CXXMethodDecl>(FD) &&
7508 "unqualified operator lookup found a member function");
7511 AddTemplateOverloadCandidate(FunTmpl, F.getPair(), ExplicitTemplateArgs,
7512 FunctionArgs, CandidateSet);
7514 AddTemplateOverloadCandidate(
7515 FunTmpl, F.getPair(), ExplicitTemplateArgs,
7516 {FunctionArgs[1], FunctionArgs[0]}, CandidateSet,
false,
false,
7519 if (ExplicitTemplateArgs)
7521 AddOverloadCandidate(FD, F.getPair(), FunctionArgs, CandidateSet);
7523 AddOverloadCandidate(FD, F.getPair(),
7524 {FunctionArgs[1], FunctionArgs[0]}, CandidateSet,
7525 false,
false,
true,
false, ADLCallKind::NotADL,
7562 if (!isCompleteType(OpLoc, T1) && !T1Rec->isBeingDefined())
7565 if (!T1Rec->getDecl()->getDefinition())
7568 LookupResult Operators(*
this, OpName, OpLoc, LookupOrdinaryName);
7569 LookupQualifiedName(Operators, T1Rec->getDecl());
7573 OperEnd = Operators.
end();
7576 AddMethodCandidate(Oper.getPair(), Args[0]->getType(),
7577 Args[0]->Classify(Context), Args.slice(1),
7578 CandidateSet,
false, PO);
7592 bool IsAssignmentOperator,
7593 unsigned NumContextualBoolArguments) {
7610 for (
unsigned ArgIdx = 0, N = Args.size(); ArgIdx != N; ++ArgIdx) {
7623 if (ArgIdx < NumContextualBoolArguments) {
7624 assert(ParamTys[ArgIdx] == Context.
BoolTy &&
7625 "Contextual conversion to bool requires bool type");
7631 ArgIdx == 0 && IsAssignmentOperator,
7634 getLangOpts().ObjCAutoRefCount);
7637 Candidate.
Viable =
false;
7650 class BuiltinCandidateTypeSet {
7652 typedef llvm::SetVector<QualType, SmallVector<QualType, 8>,
7653 llvm::SmallPtrSet<QualType, 8>> TypeSet;
7657 TypeSet PointerTypes;
7661 TypeSet MemberPointerTypes;
7665 TypeSet EnumerationTypes;
7669 TypeSet VectorTypes;
7672 bool HasNonRecordTypes;
7676 bool HasArithmeticOrEnumeralTypes;
7680 bool HasNullPtrType;
7689 bool AddPointerWithMoreQualifiedTypeVariants(
QualType Ty,
7691 bool AddMemberPointerWithMoreQualifiedTypeVariants(
QualType Ty);
7695 typedef TypeSet::iterator
iterator;
7697 BuiltinCandidateTypeSet(
Sema &SemaRef)
7698 : HasNonRecordTypes(
false),
7699 HasArithmeticOrEnumeralTypes(
false),
7700 HasNullPtrType(
false),
7704 void AddTypesConvertedFrom(
QualType Ty,
7706 bool AllowUserConversions,
7707 bool AllowExplicitConversions,
7708 const Qualifiers &VisibleTypeConversionsQuals);
7711 iterator pointer_begin() {
return PointerTypes.begin(); }
7714 iterator pointer_end() {
return PointerTypes.end(); }
7717 iterator member_pointer_begin() {
return MemberPointerTypes.begin(); }
7720 iterator member_pointer_end() {
return MemberPointerTypes.end(); }
7723 iterator enumeration_begin() {
return EnumerationTypes.begin(); }
7726 iterator enumeration_end() {
return EnumerationTypes.end(); }
7728 iterator vector_begin() {
return VectorTypes.begin(); }
7729 iterator vector_end() {
return VectorTypes.end(); }
7731 bool hasNonRecordTypes() {
return HasNonRecordTypes; }
7732 bool hasArithmeticOrEnumeralTypes() {
return HasArithmeticOrEnumeralTypes; }
7733 bool hasNullPtrType()
const {
return HasNullPtrType; }
7748 BuiltinCandidateTypeSet::AddPointerWithMoreQualifiedTypeVariants(
QualType Ty,
7752 if (!PointerTypes.insert(Ty))
7757 bool buildObjCPtr =
false;
7761 buildObjCPtr =
true;
7779 if ((CVR | BaseCVR) != CVR)
continue;
7801 PointerTypes.insert(QPointerTy);
7817 BuiltinCandidateTypeSet::AddMemberPointerWithMoreQualifiedTypeVariants(
7820 if (!MemberPointerTypes.insert(Ty))
7824 assert(PointerTy &&
"type was not a member pointer type!");
7839 if ((CVR | BaseCVR) != CVR)
continue;
7842 MemberPointerTypes.insert(
7858 BuiltinCandidateTypeSet::AddTypesConvertedFrom(
QualType Ty,
7860 bool AllowUserConversions,
7861 bool AllowExplicitConversions,
7873 Ty = SemaRef.Context.getArrayDecayedType(Ty);
7880 HasNonRecordTypes = HasNonRecordTypes || !TyRec;
7883 HasArithmeticOrEnumeralTypes =
7887 PointerTypes.insert(Ty);
7891 if (!AddPointerWithMoreQualifiedTypeVariants(Ty, VisibleQuals))
7895 if (!AddMemberPointerWithMoreQualifiedTypeVariants(Ty))
7898 HasArithmeticOrEnumeralTypes =
true;
7899 EnumerationTypes.insert(Ty);
7903 HasArithmeticOrEnumeralTypes =
true;
7904 VectorTypes.insert(Ty);
7906 HasNullPtrType =
true;
7907 }
else if (AllowUserConversions && TyRec) {
7909 if (!SemaRef.isCompleteType(Loc, Ty))
7914 if (isa<UsingShadowDecl>(D))
7915 D = cast<UsingShadowDecl>(D)->getTargetDecl();
7919 if (isa<FunctionTemplateDecl>(D))
7923 if (AllowExplicitConversions || !Conv->
isExplicit()) {
7986 if (isa<UsingShadowDecl>(D))
7987 D = cast<UsingShadowDecl>(D)->getTargetDecl();
8021 class BuiltinOperatorOverloadBuilder {
8026 bool HasArithmeticOrEnumeralCandidateType;
8030 static constexpr
int ArithmeticTypesCap = 24;
8036 unsigned FirstIntegralType,
8038 unsigned FirstPromotedIntegralType,
8039 LastPromotedIntegralType;
8040 unsigned FirstPromotedArithmeticType,
8041 LastPromotedArithmeticType;
8042 unsigned NumArithmeticTypes;
8044 void InitArithmeticTypes() {
8046 FirstPromotedArithmeticType = 0;
8054 FirstIntegralType = ArithmeticTypes.size();
8055 FirstPromotedIntegralType = ArithmeticTypes.size();
8066 LastPromotedIntegralType = ArithmeticTypes.size();
8067 LastPromotedArithmeticType = ArithmeticTypes.size();
8081 LastIntegralType = ArithmeticTypes.size();
8082 NumArithmeticTypes = ArithmeticTypes.size();
8086 assert(ArithmeticTypes.size() <= ArithmeticTypesCap &&
8087 "Enough inline storage for all arithmetic types.");
8092 void addPlusPlusMinusMinusStyleOverloads(
QualType CandidateTy,
8134 BuiltinOperatorOverloadBuilder(
8137 bool HasArithmeticOrEnumeralCandidateType,
8141 VisibleTypeConversionsQuals(VisibleTypeConversionsQuals),
8142 HasArithmeticOrEnumeralCandidateType(
8143 HasArithmeticOrEnumeralCandidateType),
8144 CandidateTypes(CandidateTypes),
8145 CandidateSet(CandidateSet) {
8147 InitArithmeticTypes();
8170 if (!HasArithmeticOrEnumeralCandidateType)
8173 for (
unsigned Arith = 0; Arith < NumArithmeticTypes; ++Arith) {
8174 const auto TypeOfT = ArithmeticTypes[Arith];
8176 if (Op == OO_MinusMinus)
8178 if (Op == OO_PlusPlus && S.
getLangOpts().CPlusPlus17)
8181 addPlusPlusMinusMinusStyleOverloads(
8198 void addPlusPlusMinusMinusPointerOverloads() {
8199 for (BuiltinCandidateTypeSet::iterator
8200 Ptr = CandidateTypes[0].pointer_begin(),
8201 PtrEnd = CandidateTypes[0].pointer_end();
8202 Ptr != PtrEnd; ++Ptr) {
8204 if (!(*Ptr)->getPointeeType()->isObjectType())
8207 addPlusPlusMinusMinusStyleOverloads(*Ptr,
8208 (!(*Ptr).isVolatileQualified() &&
8210 (!(*Ptr).isRestrictQualified() &&
8225 void addUnaryStarPointerOverloads() {
8226 for (BuiltinCandidateTypeSet::iterator
8227 Ptr = CandidateTypes[0].pointer_begin(),
8228 PtrEnd = CandidateTypes[0].pointer_end();
8229 Ptr != PtrEnd; ++Ptr) {
8236 if (Proto->getMethodQuals() || Proto->getRefQualifier())
8249 void addUnaryPlusOrMinusArithmeticOverloads() {
8250 if (!HasArithmeticOrEnumeralCandidateType)
8253 for (
unsigned Arith = FirstPromotedArithmeticType;
8254 Arith < LastPromotedArithmeticType; ++Arith) {
8255 QualType ArithTy = ArithmeticTypes[Arith];
8260 for (BuiltinCandidateTypeSet::iterator
8261 Vec = CandidateTypes[0].vector_begin(),
8262 VecEnd = CandidateTypes[0].vector_end();
8263 Vec != VecEnd; ++Vec) {
8274 void addUnaryPlusPointerOverloads() {
8275 for (BuiltinCandidateTypeSet::iterator
8276 Ptr = CandidateTypes[0].pointer_begin(),
8277 PtrEnd = CandidateTypes[0].pointer_end();
8278 Ptr != PtrEnd; ++Ptr) {
8289 void addUnaryTildePromotedIntegralOverloads() {
8290 if (!HasArithmeticOrEnumeralCandidateType)
8293 for (
unsigned Int = FirstPromotedIntegralType;
8294 Int < LastPromotedIntegralType; ++Int) {
8295 QualType IntTy = ArithmeticTypes[Int];
8300 for (BuiltinCandidateTypeSet::iterator
8301 Vec = CandidateTypes[0].vector_begin(),
8302 VecEnd = CandidateTypes[0].vector_end();
8303 Vec != VecEnd; ++Vec) {
8315 void addEqualEqualOrNotEqualMemberPointerOrNullptrOverloads() {
8317 llvm::SmallPtrSet<QualType, 8> AddedTypes;
8319 for (
unsigned ArgIdx = 0, N = Args.size(); ArgIdx != N; ++ArgIdx) {
8320 for (BuiltinCandidateTypeSet::iterator
8321 MemPtr = CandidateTypes[ArgIdx].member_pointer_begin(),
8322 MemPtrEnd = CandidateTypes[ArgIdx].member_pointer_end();
8323 MemPtr != MemPtrEnd;
8329 QualType ParamTypes[2] = { *MemPtr, *MemPtr };
8333 if (CandidateTypes[ArgIdx].hasNullPtrType()) {
8335 if (AddedTypes.insert(NullPtrTy).second) {
8336 QualType ParamTypes[2] = { NullPtrTy, NullPtrTy };
8355 void addGenericBinaryPointerOrEnumeralOverloads() {
8369 UserDefinedBinaryOperators;
8371 for (
unsigned ArgIdx = 0, N = Args.size(); ArgIdx != N; ++ArgIdx) {
8372 if (CandidateTypes[ArgIdx].enumeration_begin() !=
8373 CandidateTypes[ArgIdx].enumeration_end()) {
8375 CEnd = CandidateSet.
end();
8377 if (!C->Viable || !C->Function || C->Function->getNumParams() != 2)
8380 if (C->Function->isFunctionTemplateSpecialization())
8387 QualType FirstParamType = C->Function->getParamDecl(Reversed ? 1 : 0)
8389 .getUnqualifiedType();
8390 QualType SecondParamType = C->Function->getParamDecl(Reversed ? 0 : 1)
8392 .getUnqualifiedType();
8400 UserDefinedBinaryOperators.insert(
8408 llvm::SmallPtrSet<QualType, 8> AddedTypes;
8410 for (
unsigned ArgIdx = 0, N = Args.size(); ArgIdx != N; ++ArgIdx) {
8411 for (BuiltinCandidateTypeSet::iterator
8412 Ptr = CandidateTypes[ArgIdx].pointer_begin(),
8413 PtrEnd = CandidateTypes[ArgIdx].pointer_end();
8414 Ptr != PtrEnd; ++Ptr) {
8419 QualType ParamTypes[2] = { *Ptr, *Ptr };
8422 for (BuiltinCandidateTypeSet::iterator
8423 Enum = CandidateTypes[ArgIdx].enumeration_begin(),
8424 EnumEnd = CandidateTypes[ArgIdx].enumeration_end();
8425 Enum != EnumEnd; ++Enum) {
8430 if (!AddedTypes.insert(CanonType).second ||
8431 UserDefinedBinaryOperators.count(std::make_pair(CanonType,
8434 QualType ParamTypes[2] = { *Enum, *Enum };
8459 llvm::SmallPtrSet<QualType, 8> AddedTypes;
8461 for (
int Arg = 0; Arg < 2; ++Arg) {
8462 QualType AsymmetricParamTypes[2] = {
8466 for (BuiltinCandidateTypeSet::iterator
8467 Ptr = CandidateTypes[Arg].pointer_begin(),
8468 PtrEnd = CandidateTypes[Arg].pointer_end();
8469 Ptr != PtrEnd; ++Ptr) {
8474 AsymmetricParamTypes[Arg] = *Ptr;
8475 if (Arg == 0 || Op == OO_Plus) {
8480 if (Op == OO_Minus) {
8485 QualType ParamTypes[2] = { *Ptr, *Ptr };
8521 void addGenericBinaryArithmeticOverloads() {
8522 if (!HasArithmeticOrEnumeralCandidateType)
8525 for (
unsigned Left = FirstPromotedArithmeticType;
8526 Left < LastPromotedArithmeticType; ++Left) {
8527 for (
unsigned Right = FirstPromotedArithmeticType;
8528 Right < LastPromotedArithmeticType; ++Right) {
8529 QualType LandR[2] = { ArithmeticTypes[Left],
8530 ArithmeticTypes[Right] };
8537 for (BuiltinCandidateTypeSet::iterator
8538 Vec1 = CandidateTypes[0].vector_begin(),
8539 Vec1End = CandidateTypes[0].vector_end();
8540 Vec1 != Vec1End; ++Vec1) {
8541 for (BuiltinCandidateTypeSet::iterator
8542 Vec2 = CandidateTypes[1].vector_begin(),
8543 Vec2End = CandidateTypes[1].vector_end();
8544 Vec2 != Vec2End; ++Vec2) {
8545 QualType LandR[2] = { *Vec1, *Vec2 };
8582 void addThreeWayArithmeticOverloads() {
8583 addGenericBinaryArithmeticOverloads();
8601 if (!HasArithmeticOrEnumeralCandidateType)
8604 for (
unsigned Left = FirstPromotedIntegralType;
8605 Left < LastPromotedIntegralType; ++Left) {
8606 for (
unsigned Right = FirstPromotedIntegralType;
8607 Right < LastPromotedIntegralType; ++Right) {
8608 QualType LandR[2] = { ArithmeticTypes[Left],
8609 ArithmeticTypes[Right] };
8622 void addAssignmentMemberPointerOrEnumeralOverloads() {
8624 llvm::SmallPtrSet<QualType, 8> AddedTypes;
8626 for (
unsigned ArgIdx = 0; ArgIdx < 2; ++ArgIdx) {
8627 for (BuiltinCandidateTypeSet::iterator
8628 Enum = CandidateTypes[ArgIdx].enumeration_begin(),
8629 EnumEnd = CandidateTypes[ArgIdx].enumeration_end();
8630 Enum != EnumEnd; ++Enum) {
8637 for (BuiltinCandidateTypeSet::iterator
8638 MemPtr = CandidateTypes[ArgIdx].member_pointer_begin(),
8639 MemPtrEnd = CandidateTypes[ArgIdx].member_pointer_end();
8640 MemPtr != MemPtrEnd; ++MemPtr) {
8665 void addAssignmentPointerOverloads(
bool isEqualOp) {
8667 llvm::SmallPtrSet<QualType, 8> AddedTypes;
8669 for (BuiltinCandidateTypeSet::iterator
8670 Ptr = CandidateTypes[0].pointer_begin(),
8671 PtrEnd = CandidateTypes[0].pointer_end();
8672 Ptr != PtrEnd; ++Ptr) {
8676 else if (!(*Ptr)->getPointeeType()->isObjectType())
8687 bool NeedVolatile = !(*Ptr).isVolatileQualified() &&
8697 if (!(*Ptr).isRestrictQualified() &&
8719 for (BuiltinCandidateTypeSet::iterator
8720 Ptr = CandidateTypes[1].pointer_begin(),
8721 PtrEnd = CandidateTypes[1].pointer_end();
8722 Ptr != PtrEnd; ++Ptr) {
8736 bool NeedVolatile = !(*Ptr).isVolatileQualified() &&
8746 if (!(*Ptr).isRestrictQualified() &&
8781 void addAssignmentArithmeticOverloads(
bool isEqualOp) {
8782 if (!HasArithmeticOrEnumeralCandidateType)
8785 for (
unsigned Left = 0; Left < NumArithmeticTypes; ++Left) {
8786 for (
unsigned Right = FirstPromotedArithmeticType;
8787 Right < LastPromotedArithmeticType; ++Right) {
8789 ParamTypes[1] = ArithmeticTypes[Right];
8791 S, ArithmeticTypes[Left], Args[0]);
8808 for (BuiltinCandidateTypeSet::iterator
8809 Vec1 = CandidateTypes[0].vector_begin(),
8810 Vec1End = CandidateTypes[0].vector_end();
8811 Vec1 != Vec1End; ++Vec1) {
8812 for (BuiltinCandidateTypeSet::iterator
8813 Vec2 = CandidateTypes[1].vector_begin(),
8814 Vec2End = CandidateTypes[1].vector_end();
8815 Vec2 != Vec2End; ++Vec2) {
8817 ParamTypes[1] = *Vec2;
8846 void addAssignmentIntegralOverloads() {
8847 if (!HasArithmeticOrEnumeralCandidateType)
8850 for (
unsigned Left = FirstIntegralType; Left < LastIntegralType; ++Left) {
8851 for (
unsigned Right = FirstPromotedIntegralType;
8852 Right < LastPromotedIntegralType; ++Right) {
8854 ParamTypes[1] = ArithmeticTypes[Right];
8856 S, ArithmeticTypes[Left], Args[0]);
8862 ParamTypes[0] = LeftBaseTy;
8878 void addExclaimOverload() {
8884 void addAmpAmpOrPipePipeOverload() {
8901 void addSubscriptOverloads() {
8902 for (BuiltinCandidateTypeSet::iterator
8903 Ptr = CandidateTypes[0].pointer_begin(),
8904 PtrEnd = CandidateTypes[0].pointer_end();
8905 Ptr != PtrEnd; ++Ptr) {
8915 for (BuiltinCandidateTypeSet::iterator
8916 Ptr = CandidateTypes[1].pointer_begin(),
8917 PtrEnd = CandidateTypes[1].pointer_end();
8918 Ptr != PtrEnd; ++Ptr) {
8938 void addArrowStarOverloads() {
8939 for (BuiltinCandidateTypeSet::iterator
8940 Ptr = CandidateTypes[0].pointer_begin(),
8941 PtrEnd = CandidateTypes[0].pointer_end();
8942 Ptr != PtrEnd; ++Ptr) {
8947 if (!isa<RecordType>(C1))
8956 for (BuiltinCandidateTypeSet::iterator
8957 MemPtr = CandidateTypes[1].member_pointer_begin(),
8958 MemPtrEnd = CandidateTypes[1].member_pointer_end();
8959 MemPtr != MemPtrEnd; ++MemPtr) {
8965 QualType ParamTypes[2] = { *Ptr, *MemPtr };
8990 void addConditionalOperatorOverloads() {
8992 llvm::SmallPtrSet<QualType, 8> AddedTypes;
8994 for (
unsigned ArgIdx = 0; ArgIdx < 2; ++ArgIdx) {
8995 for (BuiltinCandidateTypeSet::iterator
8996 Ptr = CandidateTypes[ArgIdx].pointer_begin(),
8997 PtrEnd = CandidateTypes[ArgIdx].pointer_end();
8998 Ptr != PtrEnd; ++Ptr) {
9002 QualType ParamTypes[2] = { *Ptr, *Ptr };
9006 for (BuiltinCandidateTypeSet::iterator
9007 MemPtr = CandidateTypes[ArgIdx].member_pointer_begin(),
9008 MemPtrEnd = CandidateTypes[ArgIdx].member_pointer_end();
9009 MemPtr != MemPtrEnd; ++MemPtr) {
9013 QualType ParamTypes[2] = { *MemPtr, *MemPtr };
9018 for (BuiltinCandidateTypeSet::iterator
9019 Enum = CandidateTypes[ArgIdx].enumeration_begin(),
9020 EnumEnd = CandidateTypes[ArgIdx].enumeration_end();
9021 Enum != EnumEnd; ++Enum) {
9028 QualType ParamTypes[2] = { *Enum, *Enum };
9052 VisibleTypeConversionsQuals.
addConst();
9053 for (
unsigned ArgIdx = 0, N = Args.size(); ArgIdx != N; ++ArgIdx)
9056 bool HasNonRecordCandidateType =
false;
9057 bool HasArithmeticOrEnumeralCandidateType =
false;
9059 for (
unsigned ArgIdx = 0, N = Args.size(); ArgIdx != N; ++ArgIdx) {
9060 CandidateTypes.emplace_back(*
this);
9061 CandidateTypes[ArgIdx].AddTypesConvertedFrom(Args[ArgIdx]->getType(),
9064 (Op == OO_Exclaim ||
9067 VisibleTypeConversionsQuals);
9068 HasNonRecordCandidateType = HasNonRecordCandidateType ||
9069 CandidateTypes[ArgIdx].hasNonRecordTypes();
9070 HasArithmeticOrEnumeralCandidateType =
9071 HasArithmeticOrEnumeralCandidateType ||
9072 CandidateTypes[ArgIdx].hasArithmeticOrEnumeralTypes();
9080 if (!HasNonRecordCandidateType &&
9081 !(Op == OO_Exclaim || Op == OO_AmpAmp || Op == OO_PipePipe))
9085 BuiltinOperatorOverloadBuilder OpBuilder(*
this, Args,
9086 VisibleTypeConversionsQuals,
9087 HasArithmeticOrEnumeralCandidateType,
9088 CandidateTypes, CandidateSet);
9094 llvm_unreachable(
"Expected an overloaded operator");
9099 case OO_Array_Delete:
9102 "Special operators don't use AddBuiltinOperatorCandidates");
9114 if (Args.size() == 1)
9115 OpBuilder.addUnaryPlusPointerOverloads();
9119 if (Args.size() == 1) {
9120 OpBuilder.addUnaryPlusOrMinusArithmeticOverloads();
9122 OpBuilder.addBinaryPlusOrMinusPointerOverloads(Op);
9123 OpBuilder.addGenericBinaryArithmeticOverloads();
9128 if (Args.size() == 1)
9129 OpBuilder.addUnaryStarPointerOverloads();
9131 OpBuilder.addGenericBinaryArithmeticOverloads();
9135 OpBuilder.addGenericBinaryArithmeticOverloads();
9140 OpBuilder.addPlusPlusMinusMinusArithmeticOverloads(Op);
9141 OpBuilder.addPlusPlusMinusMinusPointerOverloads();
9145 case OO_ExclaimEqual:
9146 OpBuilder.addEqualEqualOrNotEqualMemberPointerOrNullptrOverloads();
9152 case OO_GreaterEqual:
9153 OpBuilder.addGenericBinaryPointerOrEnumeralOverloads();
9154 OpBuilder.addGenericBinaryArithmeticOverloads();
9158 OpBuilder.addGenericBinaryPointerOrEnumeralOverloads();
9159 OpBuilder.addThreeWayArithmeticOverloads();
9166 case OO_GreaterGreater:
9167 OpBuilder.addBinaryBitwiseArithmeticOverloads(Op);
9171 if (Args.size() == 1)
9177 OpBuilder.addBinaryBitwiseArithmeticOverloads(Op);
9181 OpBuilder.addUnaryTildePromotedIntegralOverloads();
9185 OpBuilder.addAssignmentMemberPointerOrEnumeralOverloads();
9190 OpBuilder.addAssignmentPointerOverloads(Op == OO_Equal);
9195 OpBuilder.addAssignmentArithmeticOverloads(Op == OO_Equal);
9198 case OO_PercentEqual:
9199 case OO_LessLessEqual:
9200 case OO_GreaterGreaterEqual:
9204 OpBuilder.addAssignmentIntegralOverloads();
9208 OpBuilder.addExclaimOverload();
9213 OpBuilder.addAmpAmpOrPipePipeOverload();
9217 OpBuilder.addSubscriptOverloads();
9221 OpBuilder.addArrowStarOverloads();
9224 case OO_Conditional:
9225 OpBuilder.addConditionalOperatorOverloads();
9226 OpBuilder.addGenericBinaryArithmeticOverloads();
9244 bool PartialOverloading) {
9255 ArgumentDependentLookup(Name, Loc, Args, Fns);
9259 CandEnd = CandidateSet.
end();
9260 Cand != CandEnd; ++Cand)
9261 if (Cand->Function) {
9262 Fns.
erase(Cand->Function);
9273 if (ExplicitTemplateArgs)
9276 AddOverloadCandidate(
9277 FD, FoundDecl, Args, CandidateSet,
false,
9278 PartialOverloading,
true,
9279 false, ADLCallKind::UsesADL);
9281 AddOverloadCandidate(
9282 FD, FoundDecl, {Args[1], Args[0]}, CandidateSet,
9283 false, PartialOverloading,
9288 auto *FTD = cast<FunctionTemplateDecl>(*I);
9289 AddTemplateOverloadCandidate(
9290 FTD, FoundDecl, ExplicitTemplateArgs, Args, CandidateSet,
9291 false, PartialOverloading,
9292 true, ADLCallKind::UsesADL);
9294 Context, FTD->getTemplatedDecl())) {
9295 AddTemplateOverloadCandidate(
9296 FTD, FoundDecl, ExplicitTemplateArgs, {Args[1], Args[0]},
9297 CandidateSet,
false, PartialOverloading,
9298 true, ADLCallKind::UsesADL,
9323 bool Cand1Attr = Cand1->
hasAttr<EnableIfAttr>();
9324 bool Cand2Attr = Cand2->
hasAttr<EnableIfAttr>();
9325 if (!Cand1Attr || !Cand2Attr) {
9326 if (Cand1Attr == Cand2Attr)
9328 return Cand1Attr ? Comparison::Better : Comparison::Worse;
9334 llvm::FoldingSetNodeID Cand1ID, Cand2ID;
9335 for (
auto Pair : zip_longest(Cand1Attrs, Cand2Attrs)) {
9342 return Comparison::Worse;
9344 return Comparison::Better;
9349 (*Cand1A)->getCond()->Profile(Cand1ID, S.
getASTContext(),
true);
9350 (*Cand2A)->getCond()->Profile(Cand2ID, S.
getASTContext(),
true);
9351 if (Cand1ID != Cand2ID)
9352 return Comparison::Worse;
9373 const auto *Cand1CPUSpec = Cand1.
Function->
getAttr<CPUSpecificAttr>();
9374 const auto *Cand2CPUSpec = Cand2.
Function->
getAttr<CPUSpecificAttr>();
9376 if (!Cand1CPUDisp && !Cand2CPUDisp && !Cand1CPUSpec && !Cand2CPUSpec)
9379 if (Cand1CPUDisp && !Cand2CPUDisp)
9381 if (Cand2CPUDisp && !Cand1CPUDisp)
9384 if (Cand1CPUSpec && Cand2CPUSpec) {
9385 if (Cand1CPUSpec->cpus_size() != Cand2CPUSpec->cpus_size())
9386 return Cand1CPUSpec->cpus_size() < Cand2CPUSpec->cpus_size();
9388 std::pair<CPUSpecificAttr::cpus_iterator, CPUSpecificAttr::cpus_iterator>
9389 FirstDiff = std::mismatch(
9390 Cand1CPUSpec->cpus_begin(), Cand1CPUSpec->cpus_end(),
9391 Cand2CPUSpec->cpus_begin(),
9393 return LHS->
getName() == RHS->getName();
9396 assert(FirstDiff.first != Cand1CPUSpec->cpus_end() &&
9397 "Two different cpu-specific versions should not have the same " 9398 "identifier list, otherwise they'd be the same decl!");
9399 return (*FirstDiff.first)->getName() < (*FirstDiff.second)->
getName();
9401 llvm_unreachable(
"No way to get here unless both had cpu_dispatch");
9422 unsigned StartArg = 0;
9429 return ICS.isStandard() &&
9441 assert(Cand2.
Conversions.size() == NumArgs &&
"Overload candidate mismatch");
9442 bool HasBetterConversion =
false;
9443 for (
unsigned ArgIdx = StartArg; ArgIdx < NumArgs; ++ArgIdx) {
9444 bool Cand1Bad = IsIllFormedConversion(Cand1.
Conversions[ArgIdx]);
9445 bool Cand2Bad = IsIllFormedConversion(Cand2.
Conversions[ArgIdx]);
9446 if (Cand1Bad != Cand2Bad) {
9449 HasBetterConversion =
true;
9453 if (HasBetterConversion)
9460 bool HasWorseConversion =
false;
9461 for (
unsigned ArgIdx = StartArg; ArgIdx < NumArgs; ++ArgIdx) {
9467 HasBetterConversion =
true;
9485 HasWorseConversion =
true;
9500 if (HasBetterConversion)
9502 if (HasWorseConversion)
9513 isa<CXXConversionDecl>(Cand1.
Function) &&
9514 isa<CXXConversionDecl>(Cand2.
Function)) {
9542 isa<CXXConstructorDecl>(Cand1.
Function) !=
9543 isa<CXXConstructorDecl>(Cand2.
Function))
9544 return isa<CXXConstructorDecl>(Cand1.
Function);
9548 bool Cand1IsSpecialization = Cand1.
Function &&
9550 bool Cand2IsSpecialization = Cand2.
Function &&
9552 if (Cand1IsSpecialization != Cand2IsSpecialization)
9553 return Cand2IsSpecialization;
9559 if (Cand1IsSpecialization && Cand2IsSpecialization) {
9578 if (PT1->getNumParams() == PT2->getNumParams() &&
9579 PT1->isVariadic() == PT2->isVariadic() &&
9584 bool AtLeastAsConstrained1, AtLeastAsConstrained2;
9586 {RC2}, AtLeastAsConstrained1) ||
9588 {RC1}, AtLeastAsConstrained2))
9590 if (AtLeastAsConstrained1 != AtLeastAsConstrained2)
9591 return AtLeastAsConstrained1;
9592 }
else if (RC1 || RC2) {
9593 return RC1 !=
nullptr;
9602 bool Cand1IsInherited =
9604 bool Cand2IsInherited =
9606 if (Cand1IsInherited != Cand2IsInherited)
9607 return Cand2IsInherited;
9608 else if (Cand1IsInherited) {
9609 assert(Cand2IsInherited);
9612 if (Cand1Class->isDerivedFrom(Cand2Class))
9614 if (Cand2Class->isDerivedFrom(Cand1Class))
9631 auto *Guide1 = dyn_cast_or_null<CXXDeductionGuideDecl>(Cand1.
Function);
9632 auto *Guide2 = dyn_cast_or_null<CXXDeductionGuideDecl>(Cand2.
Function);
9633 if (Guide1 && Guide2) {
9635 if (Guide1->isImplicit() != Guide2->isImplicit())
9636 return Guide2->isImplicit();
9639 if (Guide1->isCopyDeductionCandidate())
9648 return Cmp == Comparison::Better;
9657 bool HasPS1 = Cand1.
Function !=
nullptr &&
9659 bool HasPS2 = Cand2.
Function !=
nullptr &&
9661 if (HasPS1 != HasPS2 && HasPS1)
9676 auto *VA = dyn_cast_or_null<ValueDecl>(A);
9677 auto *VB = dyn_cast_or_null<ValueDecl>(B);
9683 if (!VA->getDeclContext()->getRedeclContext()->Equals(
9684 VB->getDeclContext()->getRedeclContext()) ||
9685 getOwningModule(VA) == getOwningModule(VB) ||
9686 VA->isExternallyVisible() || VB->isExternallyVisible())
9694 if (Context.
hasSameType(VA->getType(), VB->getType()))
9699 if (
auto *EA = dyn_cast<EnumConstantDecl>(VA)) {
9700 if (
auto *EB = dyn_cast<EnumConstantDecl>(VB)) {
9703 auto *EnumA = cast<EnumDecl>(EA->getDeclContext());
9704 auto *EnumB = cast<EnumDecl>(EB->getDeclContext());
9705 if (EnumA->hasNameForLinkage() || EnumB->hasNameForLinkage() ||
9707 EnumB->getIntegerType()))
9710 return llvm::APSInt::isSameValue(EA->getInitVal(), EB->getInitVal());
9720 Diag(Loc, diag::ext_equivalent_internal_linkage_decl_in_modules) << D;
9722 Module *M = getOwningModule(D);
9726 for (
auto *E : Equiv) {
9727 Module *M = getOwningModule(E);
9728 Diag(E->getLocation(), diag::note_equivalent_internal_linkage_decl)
9747 std::transform(begin(), end(), std::back_inserter(Candidates),
9759 bool ContainsSameSideCandidate =
9766 if (ContainsSameSideCandidate) {
9773 llvm::erase_if(Candidates, IsWrongSideCandidate);
9779 for (
auto *Cand : Candidates) {
9782 if (Best == end() ||
9794 PendingBest.push_back(&*Best);
9799 while (!PendingBest.empty()) {
9800 auto *Curr = PendingBest.pop_back_val();
9801 for (
auto *Cand : Candidates) {
9804 PendingBest.push_back(Cand);
9809 EquivalentCands.push_back(Cand->
Function);
9821 if (Best->Function && Best->Function->isDeleted())
9824 if (!EquivalentCands.empty())
9836 oc_reversed_binary_operator,
9838 oc_implicit_default_constructor,
9839 oc_implicit_copy_constructor,
9840 oc_implicit_move_constructor,
9841 oc_implicit_copy_assignment,
9842 oc_implicit_move_assignment,
9843 oc_implicit_equality_comparison,
9844 oc_inherited_constructor
9850 ocs_described_template,
9853 static std::pair<OverloadCandidateKind, OverloadCandidateSelect>
9856 std::string &Description) {
9866 if (!Description.empty())
9867 return ocs_described_template;
9868 return isTemplate ? ocs_template : ocs_non_template;
9873 return oc_implicit_equality_comparison;
9876 return oc_reversed_binary_operator;
9879 if (!Ctor->isImplicit()) {
9880 if (isa<ConstructorUsingShadowDecl>(Found))
9881 return oc_inherited_constructor;
9883 return oc_constructor;
9886 if (Ctor->isDefaultConstructor())
9887 return oc_implicit_default_constructor;
9889 if (Ctor->isMoveConstructor())
9890 return oc_implicit_move_constructor;
9892 assert(Ctor->isCopyConstructor() &&
9893 "unexpected sort of implicit constructor");
9894 return oc_implicit_copy_constructor;
9900 if (!Meth->isImplicit())
9903 if (Meth->isMoveAssignmentOperator())
9904 return oc_implicit_move_assignment;
9906 if (Meth->isCopyAssignmentOperator())
9907 return oc_implicit_copy_assignment;
9909 assert(isa<CXXConversionDecl>(Meth) &&
"expected conversion");
9916 return std::make_pair(Kind, Select);
9919 void MaybeEmitInheritedConstructorNote(
Sema &S,
Decl *FoundDecl) {
9922 if (
auto *Shadow = dyn_cast<ConstructorUsingShadowDecl>(FoundDecl))
9924 diag::note_ovl_candidate_inherited_constructor)
9925 << Shadow->getNominatedBaseClass();
9934 if (EnableIf->getCond()->isValueDependent() ||
9935 !EnableIf->getCond()->EvaluateAsBooleanCondition(AlwaysTrue, Ctx))
9952 bool InOverloadResolution,
9956 if (InOverloadResolution)
9958 diag::note_addrof_ovl_candidate_disabled_by_enable_if_attr);
9960 S.
Diag(Loc, diag::err_addrof_function_disabled_by_enable_if_attr) << FD;
9971 if (InOverloadResolution)
9973 diag::note_ovl_candidate_unsatisfied_constraints);
9975 S.
Diag(Loc, diag::err_addrof_function_constraints_not_satisfied)
9984 return P->hasAttr<PassObjectSizeAttr>();
9992 if (InOverloadResolution)
9994 diag::note_ovl_candidate_has_pass_object_size_params)
9997 S.
Diag(Loc, diag::err_address_of_function_with_pass_object_size_params)
10021 QualType DestType,
bool TakingAddress) {
10025 !Fn->
getAttr<TargetAttr>()->isDefaultVersion())
10028 std::string FnDesc;
10029 std::pair<OverloadCandidateKind, OverloadCandidateSelect> KSPair =
10030 ClassifyOverloadCandidate(*
this, Found, Fn, RewriteKind, FnDesc);
10032 << (unsigned)KSPair.first << (
unsigned)KSPair.second
10035 HandleFunctionTypeMismatch(PD, Fn->
getType(), DestType);
10037 MaybeEmitInheritedConstructorNote(*
this, Found);
10055 FunctionDecl *FirstCand =
nullptr, *SecondCand =
nullptr;
10056 for (
auto I = Cands.begin(), E = Cands.end(); I != E; ++I) {
10060 if (
auto *Template = I->Function->getPrimaryTemplate())
10061 Template->getAssociatedConstraints(AC);
10063 I->Function->getAssociatedConstraints(AC);
10066 if (FirstCand ==
nullptr) {
10067 FirstCand = I->Function;
10069 }
else if (SecondCand ==
nullptr) {
10070 SecondCand = I->Function;
10083 SecondCand, SecondAC))
10092 bool TakingAddress) {
10102 dyn_cast<FunctionTemplateDecl>((*I)->getUnderlyingDecl()) ) {
10103 NoteOverloadCandidate(*I, FunTmpl->getTemplatedDecl(),
CRK_None, DestType,
10106 = dyn_cast<FunctionDecl>((*I)->getUnderlyingDecl()) ) {
10107 NoteOverloadCandidate(*I, Fun,
CRK_None, DestType, TakingAddress);
10119 S.
Diag(CaretLoc, PDiag)
10120 << Ambiguous.getFromType() << Ambiguous.getToType();
10125 unsigned CandsShown = 0;
10127 for (I = Ambiguous.begin(), E = Ambiguous.end(); I != E; ++I) {
10128 if (CandsShown >= 4 && ShowOverloads ==
Ovl_Best)
10138 unsigned I,
bool TakingCandidateAddress) {
10140 assert(Conv.
isBad());
10141 assert(Cand->
Function &&
"for now, candidate must be a function");
10147 bool isObjectArgument =
false;
10148 if (isa<CXXMethodDecl>(Fn) && !isa<CXXConstructorDecl>(Fn)) {
10150 isObjectArgument =
true;
10155 std::string FnDesc;
10156 std::pair<OverloadCandidateKind, OverloadCandidateSelect> FnKindPair =
10165 assert(FromExpr &&
"overload set argument came from implicit argument?");
10167 if (isa<UnaryOperator>(E))
10168 E = cast<UnaryOperator>(E)->getSubExpr()->
IgnoreParens();
10172 << (
unsigned)FnKindPair.first << (unsigned)FnKindPair.second << FnDesc
10173 << (FromExpr ? FromExpr->getSourceRange() :
SourceRange()) << ToTy
10175 MaybeEmitInheritedConstructorNote(S, Cand->
FoundDecl);
10184 CToTy = RT->getPointeeType();
10189 CFromTy = FromPT->getPointeeType();
10190 CToTy = ToPT->getPointeeType();
10200 if (isObjectArgument)
10201 S.
Diag(Fn->
getLocation(), diag::note_ovl_candidate_bad_addrspace_this)
10202 << (
unsigned)FnKindPair.first << (unsigned)FnKindPair.second
10203 << FnDesc << (FromExpr ? FromExpr->getSourceRange() :
SourceRange())
10207 << (
unsigned)FnKindPair.first << (unsigned)FnKindPair.second
10208 << FnDesc << (FromExpr ? FromExpr->getSourceRange() :
SourceRange())
10211 MaybeEmitInheritedConstructorNote(S, Cand->
FoundDecl);
10217 << (
unsigned)FnKindPair.first << (unsigned)FnKindPair.second << FnDesc
10218 << (FromExpr ? FromExpr->getSourceRange() :
SourceRange()) << FromTy
10220 << (unsigned)isObjectArgument << I + 1;
10221 MaybeEmitInheritedConstructorNote(S, Cand->
FoundDecl);
10227 << (
unsigned)FnKindPair.first << (unsigned)FnKindPair.second << FnDesc
10228 << (FromExpr ? FromExpr->getSourceRange() :
SourceRange()) << FromTy
10230 << (unsigned)isObjectArgument << I + 1;
10231 MaybeEmitInheritedConstructorNote(S, Cand->
FoundDecl);
10237 << (
unsigned)FnKindPair.first << (unsigned)FnKindPair.second << FnDesc
10238 << (FromExpr ? FromExpr->getSourceRange() :
SourceRange()) << FromTy
10240 MaybeEmitInheritedConstructorNote(S, Cand->
FoundDecl);
10245 assert(CVR &&
"unexpected qualifiers mismatch");
10247 if (isObjectArgument) {
10249 << (
unsigned)FnKindPair.first << (unsigned)FnKindPair.second << FnDesc
10250 << (FromExpr ? FromExpr->getSourceRange() :
SourceRange()) << FromTy
10254 << (
unsigned)FnKindPair.first << (unsigned)FnKindPair.second << FnDesc
10255 << (FromExpr ? FromExpr->getSourceRange() :
SourceRange()) << FromTy
10256 << (CVR - 1) << I + 1;
10258 MaybeEmitInheritedConstructorNote(S, Cand->
FoundDecl);
10264 if (FromExpr && isa<InitListExpr>(FromExpr)) {
10265 S.
Diag(Fn->
getLocation(), diag::note_ovl_candidate_bad_list_argument)
10266 << (
unsigned)FnKindPair.first << (unsigned)FnKindPair.second << FnDesc
10267 << (FromExpr ? FromExpr->getSourceRange() :
SourceRange()) << FromTy
10268 << ToTy << (
unsigned)isObjectArgument << I + 1;
10269 MaybeEmitInheritedConstructorNote(S, Cand->
FoundDecl);
10281 S.
Diag(Fn->
getLocation(), diag::note_ovl_candidate_bad_conv_incomplete)
10282 << (
unsigned)FnKindPair.first << (unsigned)FnKindPair.second << FnDesc
10283 << (FromExpr ? FromExpr->getSourceRange() :
SourceRange()) << FromTy
10284 << ToTy << (
unsigned)isObjectArgument << I + 1
10285 << (unsigned)(Cand->
Fix.
Kind);
10287 MaybeEmitInheritedConstructorNote(S, Cand->
FoundDecl);
10292 unsigned BaseToDerivedConversion = 0;
10295 if (ToPtrTy->getPointeeType().isAtLeastAsQualifiedAs(
10296 FromPtrTy->getPointeeType()) &&
10297 !FromPtrTy->getPointeeType()->isIncompleteType() &&
10298 !ToPtrTy->getPointeeType()->isIncompleteType() &&
10300 FromPtrTy->getPointeeType()))
10301 BaseToDerivedConversion = 1;
10309 if (ToPtrTy->getPointeeType().isAtLeastAsQualifiedAs(
10310 FromPtrTy->getPointeeType()) &&
10311 FromIface->isSuperClassOf(ToIface))
10312 BaseToDerivedConversion = 2;
10314 if (ToRefTy->getPointeeType().isAtLeastAsQualifiedAs(FromTy) &&
10316 !ToRefTy->getPointeeType()->isIncompleteType() &&
10318 BaseToDerivedConversion = 3;
10323 << (
unsigned)FnKindPair.first << (unsigned)FnKindPair.second << FnDesc
10324 << (
unsigned)isObjectArgument << I + 1
10325 << (FromExpr ? FromExpr->getSourceRange() :
SourceRange());
10326 MaybeEmitInheritedConstructorNote(S, Cand->
FoundDecl);
10331 if (BaseToDerivedConversion) {
10332 S.
Diag(Fn->
getLocation(), diag::note_ovl_candidate_bad_base_to_derived_conv)
10333 << (
unsigned)FnKindPair.first << (unsigned)FnKindPair.second << FnDesc
10334 << (FromExpr ? FromExpr->getSourceRange() :
SourceRange())
10335 << (BaseToDerivedConversion - 1) << FromTy << ToTy << I + 1;
10336 MaybeEmitInheritedConstructorNote(S, Cand->
FoundDecl);
10340 if (isa<ObjCObjectPointerType>(CFromTy) &&
10341 isa<PointerType>(CToTy)) {
10346 << (
unsigned)FnKindPair.first << (unsigned)FnKindPair.second
10347 << FnDesc << (FromExpr ? FromExpr->getSourceRange() :
SourceRange())
10348 << FromTy << ToTy << (
unsigned)isObjectArgument << I + 1;
10349 MaybeEmitInheritedConstructorNote(S, Cand->
FoundDecl);
10354 if (TakingCandidateAddress &&
10360 FDiag << (unsigned)FnKindPair.first << (
unsigned)FnKindPair.second << FnDesc
10361 << (FromExpr ? FromExpr->getSourceRange() :
SourceRange()) << FromTy
10362 << ToTy << (
unsigned)isObjectArgument << I + 1
10363 << (unsigned)(Cand->
Fix.
Kind);
10366 for (std::vector<FixItHint>::iterator HI = Cand->
Fix.
Hints.begin(),
10367 HE = Cand->
Fix.
Hints.end(); HI != HE; ++HI)
10371 MaybeEmitInheritedConstructorNote(S, Cand->
FoundDecl);
10378 unsigned NumArgs) {
10391 if (NumArgs < MinParams) {
10406 unsigned NumFormalArgs) {
10407 assert(isa<FunctionDecl>(D) &&
10408 "The templated declaration should at least be a function" 10409 " when diagnosing bad template argument deduction due to too many" 10410 " or too few arguments");
10419 unsigned mode, modeCount;
10420 if (NumFormalArgs < MinParams) {
10421 if (MinParams != FnTy->getNumParams() || FnTy->isVariadic() ||
10422 FnTy->isTemplateVariadic())
10426 modeCount = MinParams;
10428 if (MinParams != FnTy->getNumParams())
10432 modeCount = FnTy->getNumParams();
10435 std::string Description;
10436 std::pair<OverloadCandidateKind, OverloadCandidateSelect> FnKindPair =
10437 ClassifyOverloadCandidate(S, Found, Fn,
CRK_None, Description);
10441 << (
unsigned)FnKindPair.first << (unsigned)FnKindPair.second
10442 << Description << mode << Fn->
getParamDecl(0) << NumFormalArgs;
10445 << (
unsigned)FnKindPair.first << (unsigned)FnKindPair.second
10446 << Description << mode << modeCount << NumFormalArgs;
10448 MaybeEmitInheritedConstructorNote(S, Found);
10453 unsigned NumFormalArgs) {
10461 llvm_unreachable(
"Unsupported: Getting the described template declaration" 10462 " for bad deduction diagnosis");
10469 bool TakingCandidateAddress) {
10475 switch (DeductionFailure.
Result) {
10477 llvm_unreachable(
"TDK_success while diagnosing bad deduction");
10480 assert(ParamD &&
"no parameter found for incomplete deduction result");
10482 diag::note_ovl_candidate_incomplete_deduction)
10484 MaybeEmitInheritedConstructorNote(S, Found);
10489 assert(ParamD &&
"no parameter found for incomplete deduction result");
10491 diag::note_ovl_candidate_incomplete_deduction_pack)
10495 MaybeEmitInheritedConstructorNote(S, Found);
10500 assert(ParamD &&
"no parameter found for bad qualifiers deduction result");
10518 S.
Diag(Templated->
getLocation(), diag::note_ovl_candidate_underqualified)
10519 << ParamD->
getDeclName() << Arg << NonCanonParam;
10520 MaybeEmitInheritedConstructorNote(S, Found);
10525 assert(ParamD &&
"no parameter found for inconsistent deduction result");
10527 if (isa<TemplateTypeParmDecl>(ParamD))
10529 else if (isa<NonTypeTemplateParmDecl>(ParamD)) {
10539 diag::note_ovl_candidate_inconsistent_deduction_types)
10542 MaybeEmitInheritedConstructorNote(S, Found);
10562 diag::note_ovl_candidate_inconsistent_deduction)
10565 MaybeEmitInheritedConstructorNote(S, Found);
10570 assert(ParamD &&
"no parameter found for invalid explicit arguments");
10573 diag::note_ovl_candidate_explicit_arg_mismatch_named)
10578 index = TTP->getIndex();
10580 = dyn_cast<NonTypeTemplateParmDecl>(ParamD))
10581 index = NTTP->getIndex();
10583 index = cast<TemplateTemplateParmDecl>(ParamD)->getIndex();
10585 diag::note_ovl_candidate_explicit_arg_mismatch_unnamed)
10588 MaybeEmitInheritedConstructorNote(S, Found);
10595 TemplateArgString =
" ";
10598 if (TemplateArgString.size() == 1)
10599 TemplateArgString.clear();
10601 diag::note_ovl_candidate_unsatisfied_constraints)
10602 << TemplateArgString;
10605 static_cast<CNSInfo*>(DeductionFailure.
Data)->Satisfaction);
10615 diag::note_ovl_candidate_instantiation_depth);
10616 MaybeEmitInheritedConstructorNote(S, Found);
10624 TemplateArgString =
" ";
10627 if (TemplateArgString.size() == 1)
10628 TemplateArgString.clear();
10633 if (PDiag && PDiag->second.getDiagID() ==
10634 diag::err_typename_nested_not_found_enable_if) {
10637 S.
Diag(PDiag->first, diag::note_ovl_candidate_disabled_by_enable_if)
10638 <<
"'enable_if'" << TemplateArgString;
10643 if (PDiag && PDiag->second.getDiagID() ==
10644 diag::err_typename_nested_not_found_requirement) {
10646 diag::note_ovl_candidate_disabled_by_requirement)
10647 << PDiag->second.getStringArg(0) << TemplateArgString;
10657 SFINAEArgString =
": ";
10659 PDiag->second.EmitToString(S.
getDiagnostics(), SFINAEArgString);
10663 diag::note_ovl_candidate_substitution_failure)
10664 << TemplateArgString << SFINAEArgString << R;
10665 MaybeEmitInheritedConstructorNote(S, Found);
10675 TemplateArgString =
" ";
10678 if (TemplateArgString.size() == 1)
10679 TemplateArgString.clear();
10682 S.
Diag(Templated->
getLocation(), diag::note_ovl_candidate_deduced_mismatch)
10685 << TemplateArgString
10709 diag::note_ovl_candidate_non_deduced_mismatch_qualified)
10716 if (TakingCandidateAddress && isa<FunctionDecl>(Templated) &&
10725 diag::note_ovl_candidate_non_deduced_mismatch)
10726 << FirstTA << SecondTA;
10732 S.
Diag(Templated->
getLocation(), diag::note_ovl_candidate_bad_deduction);
10733 MaybeEmitInheritedConstructorNote(S, Found);
10737 diag::note_cuda_ovl_candidate_target_mismatch);
10745 bool TakingCandidateAddress) {
10763 std::string FnDesc;
10764 std::pair<OverloadCandidateKind, OverloadCandidateSelect> FnKindPair =
10765 ClassifyOverloadCandidate(S, Cand->
FoundDecl, Callee,
10768 S.
Diag(Callee->getLocation(), diag::note_ovl_candidate_bad_target)
10769 << (
unsigned)FnKindPair.first << (unsigned)ocs_non_template
10771 << CalleeTarget << CallerTarget;
10776 if (Meth !=
nullptr && Meth->
isImplicit()) {
10780 switch (FnKindPair.first) {
10783 case oc_implicit_default_constructor:
10786 case oc_implicit_copy_constructor:
10789 case oc_implicit_move_constructor:
10792 case oc_implicit_copy_assignment:
10795 case oc_implicit_move_assignment:
10800 bool ConstRHS =
false;
10804 ConstRHS = RT->getPointeeType().isConstQualified();
10819 diag::note_ovl_candidate_disabled_by_function_cond_attr)
10820 << Attr->getCond()->getSourceRange() << Attr->getMessage();
10825 assert(ES.
isExplicit() &&
"not an explicit candidate");
10829 case Decl::Kind::CXXConstructor:
10832 case Decl::Kind::CXXConversion:
10835 case Decl::Kind::CXXDeductionGuide:
10839 llvm_unreachable(
"invalid Decl");
10851 diag::note_ovl_candidate_explicit)
10852 << Kind << (ES.
getExpr() ? 1 : 0)
10860 diag::note_ovl_candidate_disabled_by_extension)
10881 bool TakingCandidateAddress,
10888 std::string FnDesc;
10889 std::pair<OverloadCandidateKind, OverloadCandidateSelect> FnKindPair =
10890 ClassifyOverloadCandidate(S, Cand->
FoundDecl, Fn,
10894 << (
unsigned)FnKindPair.first << (unsigned)FnKindPair.second << FnDesc
10896 MaybeEmitInheritedConstructorNote(S, Cand->
FoundDecl);
10912 TakingCandidateAddress);
10915 S.
Diag(Fn->
getLocation(), diag::note_ovl_candidate_illegal_constructor)
10917 MaybeEmitInheritedConstructorNote(S, Cand->
FoundDecl);
10925 diag::note_ovl_candidate_illegal_constructor_adrspace_mismatch)
10926 << QualsForPrinting;
10927 MaybeEmitInheritedConstructorNote(S, Cand->
FoundDecl);
10938 for (
unsigned N = Cand->
Conversions.size(); I != N; ++I)
10962 if (cast<CXXConstructorDecl>(Fn)->isCopyOrMoveConstructor())
10965 diag::note_ovl_candidate_inherited_constructor_slice)
10968 MaybeEmitInheritedConstructorNote(S, Cand->
FoundDecl);
10974 assert(!Available);
10982 std::string FnDesc;
10983 std::pair<OverloadCandidateKind, OverloadCandidateSelect> FnKindPair =
10984 ClassifyOverloadCandidate(S, Cand->
FoundDecl, Fn,
10988 diag::note_ovl_candidate_constraints_not_satisfied)
10989 << (
unsigned)FnKindPair.first << (unsigned)ocs_non_template
11004 bool isLValueReference =
false;
11005 bool isRValueReference =
false;
11006 bool isPointer =
false;
11010 isLValueReference =
true;
11014 isRValueReference =
true;
11034 assert(Cand->
Conversions.size() <= 2 &&
"builtin operator is not binary");
11035 std::string TypeStr(
"operator");
11041 S.
Diag(OpLoc, diag::note_ovl_builtin_candidate) << TypeStr;
11046 S.
Diag(OpLoc, diag::note_ovl_builtin_candidate) << TypeStr;
11053 if (ICS.
isBad())
break;
11057 S, OpLoc, S.
PDiag(diag::note_ambiguous_type_conversion));
11073 llvm_unreachable(
"non-deduction failure while diagnosing bad deduction");
11103 llvm_unreachable(
"Unhandled deduction result");
11107 struct CompareOverloadCandidatesForDisplay {
11113 CompareOverloadCandidatesForDisplay(
11116 : S(S), NumArgs(NArgs), CSK(CSK) {}
11128 if (NumArgs < C->Function->getMinRequiredArguments())
11138 if (L == R)
return false;
11142 if (!R->
Viable)
return true;
11168 if (LDist == RDist) {
11169 if (LFailureKind == RFailureKind)
11177 return LDist < RDist;
11195 numLFixes = (numLFixes == 0) ?
UINT_MAX : numLFixes;
11196 numRFixes = (numRFixes == 0) ?
UINT_MAX : numRFixes;
11197 if (numLFixes != numRFixes) {
11198 return numLFixes < numRFixes;
11205 int leftBetter = 0;
11207 for (
unsigned E = L->
Conversions.size(); I != E; ++I) {
11223 if (leftBetter > 0)
return true;
11224 if (leftBetter < 0)
return false;
11269 bool Unfixable =
false;
11277 assert(ConvIdx != ConvCount &&
"no bad conversion in candidate");
11278 if (Cand->
Conversions[ConvIdx].isInitialized() &&
11287 bool SuppressUserConversions =
false;
11289 unsigned ConvIdx = 0;
11290 unsigned ArgIdx = 0;
11305 if (isa<CXXMethodDecl>(Cand->
Function) &&
11306 !isa<CXXConstructorDecl>(Cand->
Function) && !Reversed) {
11316 assert(ConvCount <= 3);
11321 for (
unsigned ParamIdx = Reversed ? ParamTypes.size() - 1 : 0;
11322 ConvIdx != ConvCount;
11323 ++ConvIdx, ++ArgIdx,
ParamIdx += (Reversed ? -1 : 1)) {
11324 assert(ArgIdx < Args.size() &&
"no argument for this arg conversion");
11325 if (Cand->
Conversions[ConvIdx].isInitialized()) {
11327 }
else if (ParamIdx < ParamTypes.size()) {
11328 if (ParamTypes[ParamIdx]->isDependentType())
11329 Cand->
Conversions[ConvIdx].setAsIdentityConversion(
11330 Args[ArgIdx]->getType());
11334 SuppressUserConversions,
11339 if (!Unfixable && Cand->
Conversions[ConvIdx].isBad())
11355 for (
iterator Cand = begin(), LastCand = end(); Cand != LastCand; ++Cand) {
11360 if (!Cand->Viable) {
11361 if (!Cand->Function && !Cand->IsSurrogate) {
11381 Cands.push_back(Cand);
11385 Cands, CompareOverloadCandidatesForDisplay(S, OpLoc, Args.size(),
Kind));
11397 auto Cands = CompleteCandidates(S, OCD, Args, OpLoc,
Filter);
11399 S.
Diag(PD.first, PD.second);
11401 NoteCandidates(S, Args, Cands, Opc, OpLoc);
11410 bool ReportedAmbiguousConversions =
false;
11413 unsigned CandsShown = 0;
11414 auto I = Cands.begin(), E = Cands.end();
11415 for (; I != E; ++I) {
11421 if (CandsShown >= 4 && ShowOverloads ==
Ovl_Best) {
11433 "Non-viable built-in candidates are not added to Cands.");
11440 if (!ReportedAmbiguousConversions) {
11442 ReportedAmbiguousConversions =
true;
11451 S.
Diag(OpLoc, diag::note_ovl_too_many_candidates) << int(E - I);
11461 struct CompareTemplateSpecCandidatesForDisplay {
11463 CompareTemplateSpecCandidatesForDisplay(
Sema &S) : S(S) {}
11497 bool ForTakingAddress) {
11499 DeductionFailure, 0, ForTakingAddress);
11502 void TemplateSpecCandidateSet::destroyCandidates() {
11503 for (
iterator i = begin(), e = end(); i != e; ++i) {
11504 i->DeductionFailure.Destroy();
11509 destroyCandidates();
11510 Candidates.clear();
11523 Cands.reserve(size());
11524 for (
iterator Cand = begin(), LastCand = end(); Cand != LastCand; ++Cand) {
11525 if (Cand->Specialization)
11526 Cands.push_back(Cand);
11531 llvm::sort(Cands, CompareTemplateSpecCandidatesForDisplay(S));
11538 unsigned CandsShown = 0;
11539 for (I = Cands.begin(), E = Cands.end(); I != E; ++I) {
11545 if (CandsShown >= 4 && ShowOverloads ==
Ovl_Best)
11550 "Non-matching built-in candidates are not added to Cands.");
11555 S.
Diag(Loc, diag::note_ovl_too_many_candidates) << int(E - I);
11581 bool Complain =
true) {
11598 class AddressOfFunctionResolver {
11608 bool TargetTypeIsNonStaticMemberFunction;
11609 bool FoundNonTemplateFunction;
11610 bool StaticMemberFunctionFromBoundPointer;
11611 bool HasComplained;
11620 AddressOfFunctionResolver(
Sema &S,
Expr *SourceExpr,
11621 const QualType &TargetType,
bool Complain)
11622 : S(S), SourceExpr(SourceExpr), TargetType(TargetType),
11624 TargetTypeIsNonStaticMemberFunction(
11626 FoundNonTemplateFunction(
false),
11627 StaticMemberFunctionFromBoundPointer(
false),
11628 HasComplained(
false),
11631 FailedCandidates(OvlExpr->
getNameLoc(),
true) {
11632 ExtractUnqualifiedFunctionTypeFromTargetType();
11636 if (!UME->isImplicitAccess() &&
11638 StaticMemberFunctionFromBoundPointer =
true;
11642 OvlExpr,
false, &dap)) {
11644 if (!Method->isStatic()) {
11648 TargetTypeIsNonStaticMemberFunction =
true;
11656 Matches.push_back(std::make_pair(dap, Fn));
11664 if (FindAllFunctionsThatMatchTargetTypeExactly()) {
11667 if (Matches.size() > 1 && !eliminiateSuboptimalOverloadCandidates()) {
11668 if (FoundNonTemplateFunction)
11669 EliminateAllTemplateMatches();
11671 EliminateAllExceptMostSpecializedTemplate();
11676 EliminateSuboptimalCudaMatches();
11679 bool hasComplained()
const {
return HasComplained; }
11682 bool candidateHasExactlyCorrectType(
const FunctionDecl *FD) {
11694 return candidateHasExactlyCorrectType(A) &&
11695 (!candidateHasExactlyCorrectType(B) ||
11701 bool eliminiateSuboptimalOverloadCandidates() {
11704 auto Best = Matches.begin();
11705 for (
auto I = Matches.begin()+1, E = Matches.end(); I != E; ++I)
11706 if (isBetterCandidate(I->second, Best->second))
11710 auto IsBestOrInferiorToBest = [
this, BestFn](
11711 const std::pair<DeclAccessPair, FunctionDecl *> &Pair) {
11712 return BestFn == Pair.second || isBetterCandidate(BestFn, Pair.second);
11717 if (!llvm::all_of(Matches, IsBestOrInferiorToBest))
11719 Matches[0] = *Best;
11724 bool isTargetTypeAFunction()
const {
11733 void inline ExtractUnqualifiedFunctionTypeFromTargetType() {
11744 if (Method->isStatic() == TargetTypeIsNonStaticMemberFunction)
11747 else if (TargetTypeIsNonStaticMemberFunction)
11760 &OvlExplicitTemplateArgs,
11761 TargetFunctionType, Specialization,
11780 Matches.push_back(std::make_pair(CurAccessFunPair, Specialization));
11784 bool AddMatchingNonTemplateFunction(
NamedDecl* Fn,
11789 if (Method->isStatic() == TargetTypeIsNonStaticMemberFunction)
11792 else if (TargetTypeIsNonStaticMemberFunction)
11795 if (
FunctionDecl *FunDecl = dyn_cast<FunctionDecl>(Fn)) {
11800 if (FunDecl->isMultiVersion()) {
11801 const auto *TA = FunDecl->getAttr<TargetAttr>();
11802 if (TA && !TA->isDefaultVersion())
11810 HasComplained |= Complain;
11819 candidateHasExactlyCorrectType(FunDecl)) {
11820 Matches.push_back(std::make_pair(
11821 CurAccessFunPair, cast<FunctionDecl>(FunDecl->getCanonicalDecl())));
11822 FoundNonTemplateFunction =
true;
11830 bool FindAllFunctionsThatMatchTargetTypeExactly() {
11835 if (IsInvalidFormOfPointerToMemberFunction())
11851 = dyn_cast<FunctionTemplateDecl>(Fn)) {
11852 if (AddMatchingTemplateFunction(FunctionTemplate, I.getPair()))
11857 AddMatchingNonTemplateFunction(Fn, I.getPair()))
11860 assert(Ret || Matches.empty());
11864 void EliminateAllExceptMostSpecializedTemplate() {
11877 for (
unsigned I = 0, E = Matches.size(); I != E; ++I)
11878 MatchesCopy.
addDecl(Matches[I].second, Matches[I].first.getAccess());
11883 MatchesCopy.
begin(), MatchesCopy.
end(), FailedCandidates,
11885 S.
PDiag(diag::err_addr_ovl_ambiguous)
11886 << Matches[0].second->getDeclName(),
11887 S.
PDiag(diag::note_ovl_candidate)
11888 << (unsigned)oc_function << (
unsigned)ocs_described_template,
11889 Complain, TargetFunctionType);
11891 if (Result != MatchesCopy.
end()) {
11893 Matches[0].first = Matches[Result - MatchesCopy.
begin()].first;
11894 Matches[0].second = cast<FunctionDecl>(*Result);
11897 HasComplained |= Complain;
11900 void EliminateAllTemplateMatches() {
11903 for (
unsigned I = 0, N = Matches.size(); I != N; ) {
11904 if (Matches[I].second->getPrimaryTemplate() ==
nullptr)
11907 Matches[I] = Matches[--N];
11913 void EliminateSuboptimalCudaMatches() {
11918 void ComplainNoMatchesFound()
const {
11919 assert(Matches.empty());
11921 << OvlExpr->
getName() << TargetFunctionType
11923 if (FailedCandidates.
empty())
11934 dyn_cast<FunctionDecl>((*I)->getUnderlyingDecl()))
11942 bool IsInvalidFormOfPointerToMemberFunction()
const {
11943 return TargetTypeIsNonStaticMemberFunction &&
11947 void ComplainIsInvalidFormOfPointerToMemberFunction()
const {
11955 bool IsStaticMemberFunctionFromBoundPointer()
const {
11956 return StaticMemberFunctionFromBoundPointer;
11959 void ComplainIsStaticMemberFunctionFromBoundPointer()
const {
11961 diag::err_invalid_form_pointer_member_function)
11965 void ComplainOfInvalidConversion()
const {
11967 << OvlExpr->
getName() << TargetType;
11970 void ComplainMultipleMatchesFound()
const {
11971 assert(Matches.size() > 1);
11978 bool hadMultipleCandidates()
const {
return (OvlExpr->
getNumDecls() > 1); }
11980 int getNumMatches()
const {
return Matches.size(); }
11983 if (Matches.size() != 1)
return nullptr;
11984 return Matches[0].second;
11988 if (Matches.size() != 1)
return nullptr;
11989 return &Matches[0].first;
12014 bool *pHadMultipleCandidates) {
12017 AddressOfFunctionResolver Resolver(*
this, AddressOfExpr, TargetType,
12019 int NumMatches = Resolver.getNumMatches();
12021 bool ShouldComplain = Complain && !Resolver.hasComplained();
12022 if (NumMatches == 0 && ShouldComplain) {
12023 if (Resolver.IsInvalidFormOfPointerToMemberFunction())
12024 Resolver.ComplainIsInvalidFormOfPointerToMemberFunction();
12026 Resolver.ComplainNoMatchesFound();
12028 else if (NumMatches > 1 && ShouldComplain)
12029 Resolver.ComplainMultipleMatchesFound();
12030 else if (NumMatches == 1) {
12031 Fn = Resolver.getMatchingFunctionDecl();
12034 ResolveExceptionSpec(AddressOfExpr->
getExprLoc(), FPT);
12035 FoundResult = *Resolver.getMatchingFunctionAccessPair();
12037 if (Resolver.IsStaticMemberFunctionFromBoundPointer())
12038 Resolver.ComplainIsStaticMemberFunctionFromBoundPointer();
12040 CheckAddressOfMemberAccess(AddressOfExpr, FoundResult);
12044 if (pHadMultipleCandidates)
12045 *pHadMultipleCandidates = Resolver.hadMultipleCandidates();
12060 bool IsResultAmbiguous =
false;
12065 auto CheckMoreConstrained =
12069 FD2->getAssociatedConstraints(AC2);
12070 bool AtLeastAsConstrained1, AtLeastAsConstrained2;
12071 if (IsAtLeastAsConstrained(FD1, AC1, FD2, AC2, AtLeastAsConstrained1))
12073 if (IsAtLeastAsConstrained(FD2, AC2, FD1, AC1, AtLeastAsConstrained2))
12075 if (AtLeastAsConstrained1 == AtLeastAsConstrained2)
12077 return AtLeastAsConstrained1;
12084 auto *FD = dyn_cast<
FunctionDecl>(I->getUnderlyingDecl());
12094 Optional<bool> MoreConstrainedThanPrevious = CheckMoreConstrained(FD,
12096 if (!MoreConstrainedThanPrevious) {
12097 IsResultAmbiguous =
true;
12098 AmbiguousDecls.push_back(FD);
12101 if (!*MoreConstrainedThanPrevious)
12105 IsResultAmbiguous =
false;
12110 if (IsResultAmbiguous)
12118 if (!CheckMoreConstrained(Skipped, Result).hasValue())
12133 ExprResult &SrcExpr,
bool DoFunctionPointerConverion) {
12138 FunctionDecl *Found = resolveAddressOfSingleOverloadCandidate(E, DAP);
12147 CheckAddressOfMemberAccess(E, DAP);
12148 Expr *Fixed = FixOverloadedFunctionReference(E, DAP, Found);
12150 SrcExpr = DefaultFunctionArrayConversion(Fixed,
false);
12197 = cast<FunctionTemplateDecl>((*I)->getUnderlyingDecl());
12209 Specialization, Info,
12213 FailedCandidates.addCandidate()
12219 assert(Specialization &&
"no specialization and no error?");
12226 NoteAllOverloadCandidates(ovl);
12231 Matched = Specialization;
12232 if (FoundResult) *FoundResult = I.getPair();
12251 ExprResult &SrcExpr,
bool doFunctionPointerConverion,
12252 bool complain,
SourceRange OpRangeForComplaining,
12254 unsigned DiagIDForComplaining) {
12261 if (
FunctionDecl *fn = ResolveSingleFunctionTemplateSpecialization(
12262 ovl.Expression,
false, &found)) {
12263 if (DiagnoseUseOfDecl(fn, SrcExpr.
get()->getBeginLoc())) {
12272 if (!ovl.HasFormOfMemberPointer &&
12273 isa<CXXMethodDecl>(fn) &&
12274 cast<CXXMethodDecl>(fn)->isInstance()) {
12275 if (!complain)
return false;
12277 Diag(ovl.Expression->getExprLoc(),
12278 diag::err_bound_member_function)
12279 << 0 << ovl.Expression->getSourceRange();
12291 SingleFunctionExpression =
12292 FixOverloadedFunctionReference(SrcExpr.
get(), found, fn);
12295 if (doFunctionPointerConverion) {
12296 SingleFunctionExpression =
12297 DefaultFunctionArrayLvalueConversion(SingleFunctionExpression.
get());
12298 if (SingleFunctionExpression.
isInvalid()) {
12305 if (!SingleFunctionExpression.
isUsable()) {
12307 Diag(OpRangeForComplaining.
getBegin(), DiagIDForComplaining)
12308 << ovl.Expression->getName()
12309 << DestTypeForComplaining
12310 << OpRangeForComplaining
12311 << ovl.Expression->getQualifierLoc().getSourceRange();
12312 NoteAllOverloadCandidates(SrcExpr.
get());
12321 SrcExpr = SingleFunctionExpression;
12331 bool PartialOverloading,
12334 if (isa<UsingShadowDecl>(Callee))
12335 Callee = cast<UsingShadowDecl>(Callee)->getTargetDecl();
12337 if (
FunctionDecl *Func = dyn_cast<FunctionDecl>(Callee)) {
12338 if (ExplicitTemplateArgs) {
12339 assert(!KnownValid &&
"Explicit template arguments?");
12343 if (!dyn_cast<FunctionProtoType>(Func->getType()->getAs<
FunctionType>()))
12348 PartialOverloading);
12353 = dyn_cast<FunctionTemplateDecl>(Callee)) {
12355 ExplicitTemplateArgs, Args, CandidateSet,
12357 PartialOverloading);
12361 assert(!KnownValid &&
"unhandled case in overloaded call candidate");
12369 bool PartialOverloading) {
12392 assert(!(*I)->getDeclContext()->isRecord());
12393 assert(isa<UsingShadowDecl>(*I) ||
12394 !(*I)->getDeclContext()->isFunctionOrMethod());
12395 assert((*I)->getUnderlyingDecl()->isFunctionOrFunctionTemplate());
12405 ExplicitTemplateArgs = &TABuffer;
12411 CandidateSet, PartialOverloading,
12416 Args, ExplicitTemplateArgs,
12417 CandidateSet, PartialOverloading);
12424 case OO_New:
case OO_Array_New:
12425 case OO_Delete:
case OO_Array_Delete:
12445 bool *DoDiagnoseEmptyLookup =
nullptr) {
12450 if (DC->isTransparentContext())
12458 if (isa<CXXRecordDecl>(DC)) {
12462 if (DoDiagnoseEmptyLookup)
12463 *DoDiagnoseEmptyLookup =
true;
12470 ExplicitTemplateArgs, Args,
12471 Candidates,
false,
false);
12474 if (Candidates.BestViableFunction(SemaRef, FnLoc, Best) !=
OR_Success) {
12486 AssociatedNamespaces,
12487 AssociatedClasses);
12491 for (Sema::AssociatedNamespaceSet::iterator
12492 it = AssociatedNamespaces.begin(),
12493 end = AssociatedNamespaces.end(); it != end; ++it) {
12505 SuggestedNamespaces.insert(*it);
12509 SemaRef.
Diag(R.
getNameLoc(), diag::err_not_found_by_two_phase_lookup)
12511 if (SuggestedNamespaces.empty()) {
12512 SemaRef.
Diag(Best->Function->getLocation(),
12513 diag::note_not_found_by_two_phase_lookup)
12515 }
else if (SuggestedNamespaces.size() == 1) {
12516 SemaRef.
Diag(Best->Function->getLocation(),
12517 diag::note_not_found_by_two_phase_lookup)
12523 SemaRef.
Diag(Best->Function->getLocation(),
12524 diag::note_not_found_by_two_phase_lookup)
12556 class BuildRecoveryCallExprRAII {
12559 BuildRecoveryCallExprRAII(
Sema &S) : SemaRef(S) {
12564 ~BuildRecoveryCallExprRAII() {
12580 bool EmptyLookup,
bool AllowTypoCorrection) {
12589 BuildRecoveryCallExprRAII RCE(SemaRef);
12599 ExplicitTemplateArgs = &TABuffer;
12604 bool DoDiagnoseEmptyLookup = EmptyLookup;
12607 ExplicitTemplateArgs, Args, &DoDiagnoseEmptyLookup)) {
12610 ExplicitTemplateArgs !=
nullptr,
12613 AllowTypoCorrection
12615 : static_cast<CorrectionCandidateCallback &>(NoTypoValidator);
12616 if (!DoDiagnoseEmptyLookup ||
12622 assert(!R.empty() &&
"lookup results empty despite recovery");
12625 if (R.isAmbiguous()) {
12626 R.suppressDiagnostics();
12633 if ((*R.begin())->isCXXClassMember())
12635 ExplicitTemplateArgs, S);
12636 else if (ExplicitTemplateArgs || TemplateKWLoc.
isValid())
12638 ExplicitTemplateArgs);
12665 assert(!ULE->
getQualifier() &&
"qualified name with ADL");
12674 llvm_unreachable(
"performing ADL for builtin");
12677 assert(getLangOpts().
CPlusPlus &&
"ADL enabled in C");
12681 UnbridgedCastsSet UnbridgedCasts;
12689 AddOverloadedCallCandidates(ULE, Args, *CandidateSet);
12691 if (getLangOpts().MSVCCompat &&
12692 CurContext->isDependentContext() && !isSFINAEContext() &&
12693 (isa<FunctionDecl>(CurContext) || isa<CXXRecordDecl>(CurContext))) {
12696 if (CandidateSet->
empty() ||
12713 if (CandidateSet->
empty())
12716 UnbridgedCasts.restore();
12732 bool AllowTypoCorrection) {
12733 if (CandidateSet->
empty())
12736 AllowTypoCorrection);
12738 switch (OverloadResult) {
12747 (*Best)->IsADLCandidate);
12756 AllowTypoCorrection);
12763 for (
const Expr *Arg : Args) {
12764 if (!Arg->getType()->isFunctionType())
12766 if (
auto *DRE = dyn_cast<DeclRefExpr>(Arg->IgnoreParenImpCasts())) {
12770 Arg->getExprLoc()))
12778 SemaRef.
PDiag(diag::err_ovl_no_viable_function_in_call)
12787 SemaRef.
PDiag(diag::err_ovl_ambiguous_call)
12795 SemaRef.
PDiag(diag::err_ovl_deleted_call)
12805 (*Best)->IsADLCandidate);
12815 for (
auto I = CS.
begin(), E = CS.
end(); I != E; ++I) {
12836 bool AllowTypoCorrection,
12837 bool CalleesAddressIsTaken) {
12842 if (buildOverloadedCallSet(S, Fn, ULE, Args, LParenLoc, &CandidateSet,
12848 if (CalleesAddressIsTaken)
12853 CandidateSet.BestViableFunction(*
this, Fn->
getBeginLoc(), Best);
12856 ExecConfig, &CandidateSet, &Best,
12857 OverloadResult, AllowTypoCorrection);
12861 return Functions.
size() > 1 ||
12862 (Functions.
size() == 1 && isa<FunctionTemplateDecl>(*Functions.
begin()));
12883 Expr *Input,
bool PerformADL) {
12885 assert(Op !=
OO_None &&
"Invalid opcode for overloaded unary operator");
12893 Expr *Args[2] = { Input,
nullptr };
12894 unsigned NumArgs = 1;
12899 if (Opc == UO_PostInc || Opc == UO_PostDec) {
12926 AddNonMemberOperatorCandidates(Fns, ArgsArray, CandidateSet);
12929 AddMemberOperatorCandidates(Op, OpLoc, ArgsArray, CandidateSet);
12933 AddArgumentDependentLookupCandidates(OpName, OpLoc, ArgsArray,
12939 AddBuiltinOperatorCandidates(Op, OpLoc, ArgsArray, CandidateSet);
12941 bool HadMultipleCandidates = (CandidateSet.
size() > 1);
12956 if (
CXXMethodDecl *Method = dyn_cast<CXXMethodDecl>(FnDecl)) {
12957 CheckMemberOperatorAccess(OpLoc, Args[0],
nullptr, Best->FoundDecl);
12960 PerformObjectArgumentInitialization(Input,
nullptr,
12961 Best->FoundDecl, Method);
12964 Base = Input = InputRes.
get();
12975 Input = InputInit.
get();
12980 Base, HadMultipleCandidates,
12992 Context, Op, FnExpr.
get(), ArgsArray, ResultTy, VK, OpLoc,
12995 if (CheckCallReturnType(FnDecl->
getReturnType(), OpLoc, TheCall, FnDecl))
12998 if (CheckFunctionCall(FnDecl, TheCall,
13002 return MaybeBindToTemporary(TheCall);
13007 ExprResult InputRes = PerformImplicitConversion(
13008 Input, Best->BuiltinParamTypes[0], Best->Conversions[0], AA_Passing,
13009 CCK_ForBuiltinOverloadedOp);
13012 Input = InputRes.
get();
13032 PDiag(diag::err_ovl_ambiguous_oper_unary)
13052 return CreateBuiltinUnaryOp(OpLoc, Opc, Input);
13069 AddNonMemberOperatorCandidates(Fns, Args, CandidateSet);
13072 AddMemberOperatorCandidates(Op, OpLoc, Args, CandidateSet);
13074 AddMemberOperatorCandidates(Op, OpLoc, {Args[1], Args[0]}, CandidateSet,
13079 AddMemberOperatorCandidates(ExtraOp, OpLoc, Args, CandidateSet);
13080 if (CandidateSet.getRewriteInfo().shouldAddReversed(ExtraOp))
13081 AddMemberOperatorCandidates(ExtraOp, OpLoc, {Args[1], Args[0]},
13089 if (Op != OO_Equal && PerformADL) {
13091 AddArgumentDependentLookupCandidates(OpName, OpLoc, Args,
13097 AddArgumentDependentLookupCandidates(ExtraOpName, OpLoc, Args,
13116 AddBuiltinOperatorCandidates(Op, OpLoc, Args, CandidateSet);
13145 Expr *RHS,
bool PerformADL,
13146 bool AllowRewrittenCandidates,
13148 Expr *Args[2] = { LHS, RHS };
13152 AllowRewrittenCandidates =
false;
13158 if (Args[0]->isTypeDependent() || Args[1]->isTypeDependent()) {
13162 if (Opc <= BO_Assign || Opc > BO_OrAssign)
13165 OpLoc, FPFeatures);
13202 if (Opc == BO_Assign && !Args[0]->getType()->isOverloadableType())
13203 return CreateBuiltinBinOp(OpLoc, Opc, Args[0], Args[1]);
13207 if (Opc == BO_PtrMemD)
13208 return CreateBuiltinBinOp(OpLoc, Opc, Args[0], Args[1]);
13215 CandidateSet.
exclude(DefaultedFn);
13216 LookupOverloadedBinOp(CandidateSet, Op, Fns, Args, PerformADL);
13218 bool HadMultipleCandidates = (CandidateSet.
size() > 1);
13229 std::swap(Args[0], Args[1]);
13242 if (Best->RewriteKind && ChosenOp == OO_EqualEqual &&
13244 Diag(OpLoc, diag::err_ovl_rewrite_equalequal_not_bool)
13251 if (AllowRewrittenCandidates && !IsReversed &&
13258 if (Cand.Viable && Cand.Function == FnDecl &&
13260 for (
unsigned ArgIdx = 0; ArgIdx < 2; ++ArgIdx) {
13262 *
this, OpLoc, Cand.Conversions[ArgIdx],
13263 Best->Conversions[ArgIdx]) ==
13265 Diag(OpLoc, diag::ext_ovl_ambiguous_oper_binary_reversed)
13270 diag::note_ovl_ambiguous_oper_binary_reversed_candidate);
13279 if (
CXXMethodDecl *Method = dyn_cast<CXXMethodDecl>(FnDecl)) {
13281 CheckMemberOperatorAccess(OpLoc, Args[0], Args[1], Best->FoundDecl);
13284 PerformCopyInitialization(
13292 PerformObjectArgumentInitialization(Args[0],
nullptr,
13293 Best->FoundDecl, Method);
13300 ExprResult Arg0 = PerformCopyInitialization(
13308 PerformCopyInitialization(
13320 Best->FoundDecl, Base,
13321 HadMultipleCandidates, OpLoc);
13322 if (FnExpr.isInvalid())
13331 Context, ChosenOp, FnExpr.get(), Args, ResultTy, VK, OpLoc,
13332 FPFeatures, Best->IsADLCandidate);
13334 if (CheckCallReturnType(FnDecl->
getReturnType(), OpLoc, TheCall,
13339 const Expr *ImplicitThis =
nullptr;
13341 if (isa<CXXMethodDecl>(FnDecl)) {
13342 ImplicitThis = ArgsArray[0];
13343 ArgsArray = ArgsArray.slice(1);
13347 if (Op == OO_Equal)
13348 DiagnoseSelfMove(Args[0], Args[1], OpLoc);
13350 checkCall(FnDecl,
nullptr, ImplicitThis, ArgsArray,
13351 isa<CXXMethodDecl>(FnDecl), OpLoc, TheCall->getSourceRange(),
13352 VariadicDoesNotApply);
13354 ExprResult R = MaybeBindToTemporary(TheCall);
13361 (Op == OO_Spaceship && IsReversed)) {
13362 if (Op == OO_ExclaimEqual) {
13363 assert(ChosenOp == OO_EqualEqual &&
"unexpected operator name");
13364 R = CreateBuiltinUnaryOp(OpLoc, UO_LNot, R.get());
13366 assert(ChosenOp == OO_Spaceship &&
"unexpected operator name");
13368 Expr *ZeroLiteral =
13374 pushCodeSynthesisContext(Ctx);
13376 R = CreateOverloadedBinOp(
13377 OpLoc, Opc, Fns, IsReversed ? ZeroLiteral : R.get(),
13378 IsReversed ? R.get() : ZeroLiteral, PerformADL,
13381 popCodeSynthesisContext();
13386 assert(ChosenOp == Op &&
"unexpected operator name");
13390 if (Best->RewriteKind !=
CRK_None)
13398 ExprResult ArgsRes0 = PerformImplicitConversion(
13399 Args[0], Best->BuiltinParamTypes[0], Best->Conversions[0],
13400 AA_Passing, CCK_ForBuiltinOverloadedOp);
13403 Args[0] = ArgsRes0.
get();
13405 ExprResult ArgsRes1 = PerformImplicitConversion(
13406 Args[1], Best->BuiltinParamTypes[1], Best->Conversions[1],
13407 AA_Passing, CCK_ForBuiltinOverloadedOp);
13410 Args[1] = ArgsRes1.
get();
13420 if (Opc == BO_Comma)
13425 if (DefaultedFn && Opc == BO_Cmp) {
13426 ExprResult E = BuildSynthesizedThreeWayComparison(OpLoc, Fns, Args[0],
13427 Args[1], DefaultedFn);
13440 Opc >= BO_Assign && Opc <= BO_OrAssign) {
13441 Diag(OpLoc, diag::err_ovl_no_viable_oper)
13444 if (Args[0]->getType()->isIncompleteType()) {
13445 Diag(OpLoc, diag::note_assign_lhs_incomplete)
13459 Result = CreateBuiltinBinOp(OpLoc, Opc, Args[0], Args[1]);
13462 "C++ binary operator overloading is missing candidates!");
13471 << Args[0]->getType()
13472 << Args[1]->getType()
13480 if (isImplicitlyDeleted(Best->Function)) {
13484 Diag(OpLoc, diag::err_ovl_deleted_special_oper)
13488 Diag(OpLoc, diag::err_ovl_deleted_comparison)
13489 << Args[0]->
getType() << DeletedFD;
13494 NoteDeletedFunction(DeletedFD);
13499 OpLoc, PDiag(diag::err_ovl_deleted_oper)
13501 .getCXXOverloadedOperator())
13510 return CreateBuiltinBinOp(OpLoc, Opc, Args[0], Args[1]);
13526 "cannot use prvalue expressions more than once");
13527 Expr *OrigLHS = LHS;
13528 Expr *OrigRHS = RHS;
13532 LHS =
new (Context)
13535 RHS =
new (Context)
13539 ExprResult Eq = CreateOverloadedBinOp(OpLoc, BO_EQ, Fns, LHS, RHS,
true,
true,
13544 ExprResult Less = CreateOverloadedBinOp(OpLoc, BO_LT, Fns, LHS, RHS,
true,
13545 true, DefaultedFn);
13551 Greater = CreateOverloadedBinOp(OpLoc, BO_LT, Fns, RHS, LHS,
true,
true,
13573 for (; I >= 0; --I) {
13575 auto *VI = Info->lookupValueInfo(Comparisons[I].Result);
13585 if (Result.get()) {
13586 Result = ActOnConditionalOp(OpLoc, OpLoc, Comparisons[I].Cmp.get(),
13587 ThisResult.
get(), Result.get());
13588 if (Result.isInvalid())
13591 Result = ThisResult;
13597 Expr *SyntacticForm =
new (Context)
13599 Result.
get()->getValueKind(),
13600 Result.
get()->getObjectKind(), OpLoc, FPFeatures);
13601 Expr *SemanticForm[] = {LHS, RHS, Result.
get()};
13609 Expr *Args[2] = { Base, Idx };
13615 if (Args[0]->isTypeDependent() || Args[1]->isTypeDependent()) {
13646 AddMemberOperatorCandidates(OO_Subscript, LLoc, Args, CandidateSet);
13649 AddBuiltinOperatorCandidates(OO_Subscript, LLoc, Args, CandidateSet);
13651 bool HadMultipleCandidates = (CandidateSet.
size() > 1);
13664 CheckMemberOperatorAccess(LLoc, Args[0], Args[1], Best->FoundDecl);
13669 PerformObjectArgumentInitialization(Args[0],
nullptr,
13670 Best->FoundDecl, Method);
13671 if (Arg0.isInvalid())
13673 Args[0] = Arg0.get();
13689 OpLocInfo.setCXXOperatorNameRange(
SourceRange(LLoc, RLoc));
13693 HadMultipleCandidates,
13694 OpLocInfo.getLoc(),
13695 OpLocInfo.getInfo());
13706 Args, ResultTy, VK, RLoc,
FPOptions());
13708 if (CheckCallReturnType(FnDecl->
getReturnType(), LLoc, TheCall, FnDecl))
13711 if (CheckFunctionCall(Method, TheCall,
13715 return MaybeBindToTemporary(TheCall);
13720 ExprResult ArgsRes0 = PerformImplicitConversion(
13721 Args[0], Best->BuiltinParamTypes[0], Best->Conversions[0],
13722 AA_Passing, CCK_ForBuiltinOverloadedOp);
13725 Args[0] = ArgsRes0.
get();
13727 ExprResult ArgsRes1 = PerformImplicitConversion(
13728 Args[1], Best->BuiltinParamTypes[1], Best->Conversions[1],
13729 AA_Passing, CCK_ForBuiltinOverloadedOp);
13732 Args[1] = ArgsRes1.
get();
13740 ? (PDiag(diag::err_ovl_no_oper)
13743 : (PDiag(diag::err_ovl_no_viable_subscript)
13754 <<
"[]" << Args[0]->getType()
13755 << Args[1]->getType()
13771 return CreateBuiltinArraySubscriptExpr(Args[0], LLoc, Args[1], RLoc);
13794 if (
BinaryOperator *op = dyn_cast<BinaryOperator>(NakedMemExpr)) {
13796 assert(op->getOpcode() == BO_PtrMemD || op->getOpcode() == BO_PtrMemI);
13809 QualType objectType = op->getLHS()->getType();
13810 if (op->getOpcode() == BO_PtrMemI)
13814 Qualifiers difference = objectQuals - funcQuals;
13818 std::string qualsString = difference.
getAsString();
13819 Diag(LParenLoc, diag::err_pointer_to_member_call_drops_quals)
13820 << fnType.getUnqualifiedType()
13822 << (qualsString.find(
' ') == std::string::npos ? 1 : 2);
13829 if (CheckCallReturnType(proto->
getReturnType(), op->getRHS()->getBeginLoc(),
13833 if (ConvertArgumentsForCall(call, op,
nullptr, proto, Args, RParenLoc))
13836 if (CheckOtherCall(call, proto))
13839 return MaybeBindToTemporary(call);
13842 if (isa<CXXPseudoDestructorExpr>(NakedMemExpr))
13846 UnbridgedCastsSet UnbridgedCasts;
13854 if (isa<MemberExpr>(NakedMemExpr)) {
13855 MemExpr = cast<MemberExpr>(NakedMemExpr);
13859 UnbridgedCasts.restore();
13877 TemplateArgs = &TemplateArgsBuffer;
13881 E = UnresExpr->
decls_end(); I != E; ++I) {
13885 if (isa<UsingShadowDecl>(Func))
13886 Func = cast<UsingShadowDecl>(Func)->getTargetDecl();
13890 if (getLangOpts().MicrosoftExt && isa<CXXConstructorDecl>(Func)) {
13891 AddOverloadCandidate(cast<CXXConstructorDecl>(Func), I.getPair(), Args,
13894 }
else if ((Method = dyn_cast<CXXMethodDecl>(Func))) {
13900 AddMethodCandidate(Method, I.getPair(), ActingDC, ObjectType,
13901 ObjectClassification, Args, CandidateSet,
13904 AddMethodTemplateCandidate(
13905 cast<FunctionTemplateDecl>(Func), I.getPair(), ActingDC,
13906 TemplateArgs, ObjectType, ObjectClassification, Args, CandidateSet,
13913 UnbridgedCasts.restore();
13916 switch (CandidateSet.BestViableFunction(*
this, UnresExpr->
getBeginLoc(),
13919 Method = cast<CXXMethodDecl>(Best->Function);
13920 FoundDecl = Best->FoundDecl;
13921 CheckUnresolvedMemberAccess(UnresExpr, Best->FoundDecl);
13922 if (DiagnoseUseOfDecl(Best->FoundDecl, UnresExpr->
getNameLoc()))
13930 if (Method != FoundDecl.getDecl() &&
13931 DiagnoseUseOfDecl(Method, UnresExpr->
getNameLoc()))
13936 CandidateSet.NoteCandidates(
13939 PDiag(diag::err_ovl_no_viable_member_function_in_call)
13946 CandidateSet.NoteCandidates(
13948 PDiag(diag::err_ovl_ambiguous_member_call)
13955 CandidateSet.NoteCandidates(
13957 PDiag(diag::err_ovl_deleted_member_call)
13964 MemExprE = FixOverloadedFunctionReference(MemExprE, FoundDecl, Method);
13969 return BuildResolvedCallExpr(MemExprE, Method, LParenLoc, Args,
13978 ResultType = ResultType.getNonLValueExprType(Context);
13980 assert(Method &&
"Member call to something that isn't a method?");
13984 RParenLoc, Proto->getNumParams());
13996 PerformObjectArgumentInitialization(MemExpr->
getBase(), Qualifier,
13997 FoundDecl, Method);
14004 if (ConvertArgumentsForCall(TheCall, MemExpr, Method, Proto, Args,
14008 DiagnoseSentinelCalls(Method, LParenLoc, Args);
14010 if (CheckFunctionCall(Method, TheCall, Proto))
14016 if (
auto *MemE = dyn_cast<MemberExpr>(NakedMemExpr)) {
14017 if (
const EnableIfAttr *
Attr = CheckEnableIf(Method, Args,
true)) {
14018 Diag(MemE->getMemberLoc(),
14019 diag::err_ovl_no_viable_member_function_in_call)
14022 diag::note_ovl_candidate_disabled_by_function_cond_attr)
14023 <<
Attr->getCond()->getSourceRange() <<
Attr->getMessage();
14028 if ((isa<CXXConstructorDecl>(CurContext) ||
14029 isa<CXXDestructorDecl>(CurContext)) &&
14030 TheCall->getMethodDecl()->isPure()) {
14036 diag::warn_call_to_pure_virtual_member_function_from_ctor_dtor)
14037 << MD->
getDeclName() << isa<CXXDestructorDecl>(CurContext)
14041 if (getLangOpts().AppleKext)
14048 dyn_cast<CXXDestructorDecl>(TheCall->getMethodDecl())) {
14050 bool CallCanBeVirtual = !MemExpr->
hasQualifier() || getLangOpts().AppleKext;
14051 CheckVirtualDtorCall(DD, MemExpr->
getBeginLoc(),
false,
14052 CallCanBeVirtual,
true,
14056 return MaybeBindToTemporary(TheCall);
14072 UnbridgedCastsSet UnbridgedCasts;
14076 assert(Object.
get()->getType()->isRecordType() &&
14077 "Requires object type argument");
14090 if (RequireCompleteType(LParenLoc, Object.
get()->getType(),
14091 diag::err_incomplete_object_call, Object.
get()))
14094 const auto *Record = Object.
get()->getType()->castAs<
RecordType>();
14095 LookupResult R(*
this, OpName, LParenLoc, LookupOrdinaryName);
14096 LookupQualifiedName(R, Record->getDecl());
14097 R.suppressDiagnostics();
14100 Oper != OperEnd; ++Oper) {
14101 AddMethodCandidate(Oper.getPair(), Object.
get()->getType(),
14102 Object.
get()->Classify(Context), Args, CandidateSet,
14123 const auto &Conversions =
14124 cast<CXXRecordDecl>(Record->getDecl())->getVisibleConversionFunctions();
14125 for (
auto I = Conversions.begin(), E = Conversions.end(); I != E; ++I) {
14128 if (isa<UsingShadowDecl>(D))
14129 D = cast<UsingShadowDecl>(D)->getTargetDecl();
14133 if (isa<FunctionTemplateDecl>(D))
14146 AddSurrogateCandidate(Conv, I.getPair(), ActingContext, Proto,
14147 Object.
get(), Args, CandidateSet);
14152 bool HadMultipleCandidates = (CandidateSet.size() > 1);
14156 switch (CandidateSet.BestViableFunction(*
this, Object.
get()->getBeginLoc(),
14165 CandidateSet.empty()
14166 ? (PDiag(diag::err_ovl_no_oper)
14167 << Object.
get()->getType() << 1
14168 << Object.
get()->getSourceRange())
14169 : (PDiag(diag::err_ovl_no_viable_object_call)
14170 << Object.
get()->getType() << Object.
get()->getSourceRange());
14171 CandidateSet.NoteCandidates(
14177 CandidateSet.NoteCandidates(
14179 PDiag(diag::err_ovl_ambiguous_object_call)
14180 << Object.
get()->getType()
14181 << Object.
get()->getSourceRange()),
14186 CandidateSet.NoteCandidates(
14188 PDiag(diag::err_ovl_deleted_object_call)
14189 << Object.
get()->getType()
14190 << Object.
get()->getSourceRange()),
14195 if (Best == CandidateSet.end())
14198 UnbridgedCasts.restore();
14200 if (Best->Function ==
nullptr) {
14204 = cast<CXXConversionDecl>(
14205 Best->Conversions[0].UserDefined.ConversionFunction);
14207 CheckMemberOperatorAccess(LParenLoc, Object.
get(),
nullptr,
14209 if (DiagnoseUseOfDecl(Best->FoundDecl, LParenLoc))
14211 assert(Conv == Best->FoundDecl.getDecl() &&
14212 "Found Decl & conversion-to-functionptr should be same, right?!");
14219 ExprResult Call = BuildCXXMemberCallExpr(Object.
get(), Best->FoundDecl,
14220 Conv, HadMultipleCandidates);
14221 if (Call.isInvalid())
14225 CK_UserDefinedConversion, Call.get(),
14228 return BuildCallExpr(S, Call.get(), LParenLoc, Args, RParenLoc);
14231 CheckMemberOperatorAccess(LParenLoc, Object.
get(),
nullptr, Best->FoundDecl);
14236 CXXMethodDecl *Method = cast<CXXMethodDecl>(Best->Function);
14239 if (Method->isInvalidDecl())
14249 Obj, HadMultipleCandidates,
14250 OpLocInfo.getLoc(),
14251 OpLocInfo.getInfo());
14258 unsigned NumArgsSlots = 1 + std::max<unsigned>(Args.size(), NumParams);
14264 bool IsError =
false;
14268 PerformObjectArgumentInitialization(Object.
get(),
nullptr,
14269 Best->FoundDecl, Method);
14274 MethodArgs[0] = Object.
get();
14277 for (
unsigned i = 0; i != NumParams; i++) {
14279 if (i < Args.size()) {
14287 Method->getParamDecl(i)),
14294 = BuildCXXDefaultArgExpr(LParenLoc, Method, Method->getParamDecl(i));
14303 MethodArgs[i + 1] = Arg;
14307 if (Proto->isVariadic()) {
14309 for (
unsigned i = NumParams, e = Args.size(); i < e; i++) {
14310 ExprResult Arg = DefaultVariadicArgumentPromotion(Args[i], VariadicMethod,
14313 MethodArgs[i + 1] = Arg.
get();
14320 DiagnoseSentinelCalls(Method, LParenLoc, Args);
14323 QualType ResultTy = Method->getReturnType();
14331 if (CheckCallReturnType(Method->getReturnType(), LParenLoc, TheCall, Method))
14334 if (CheckFunctionCall(Method, TheCall, Proto))
14337 return MaybeBindToTemporary(TheCall);
14345 bool *NoArrowOperatorFound) {
14347 "left-hand side must have class type");
14364 if (RequireCompleteType(Loc, Base->
getType(),
14365 diag::err_typecheck_incomplete_tag, Base))
14368 LookupResult R(*
this, OpName, OpLoc, LookupOrdinaryName);
14373 Oper != OperEnd; ++Oper) {
14374 AddMethodCandidate(Oper.getPair(), Base->
getType(), Base->
Classify(Context),
14375 None, CandidateSet,
false);
14378 bool HadMultipleCandidates = (CandidateSet.
size() > 1);
14389 if (CandidateSet.
empty()) {
14391 if (NoArrowOperatorFound) {
14394 *NoArrowOperatorFound =
true;
14397 Diag(OpLoc, diag::err_typecheck_member_reference_arrow)
14400 Diag(OpLoc, diag::note_typecheck_member_reference_suggestion)
14404 Diag(OpLoc, diag::err_ovl_no_viable_oper)
14425 CheckMemberOperatorAccess(OpLoc, Base,
nullptr, Best->FoundDecl);
14428 CXXMethodDecl *Method = cast<CXXMethodDecl>(Best->Function);
14430 PerformObjectArgumentInitialization(Base,
nullptr,
14431 Best->FoundDecl, Method);
14432 if (BaseResult.isInvalid())
14434 Base = BaseResult.get();
14438 Base, HadMultipleCandidates, OpLoc);
14446 Context, OO_Arrow, FnExpr.
get(), Base, ResultTy, VK, OpLoc,
FPOptions());
14448 if (CheckCallReturnType(Method->
getReturnType(), OpLoc, TheCall, Method))
14451 if (CheckFunctionCall(Method, TheCall,
14455 return MaybeBindToTemporary(TheCall);
14469 AddNonMemberOperatorCandidates(R.
asUnresolvedSet(), Args, CandidateSet,
14472 bool HadMultipleCandidates = (CandidateSet.size() > 1);
14477 switch (CandidateSet.BestViableFunction(*
this, UDSuffixLoc, Best)) {
14483 CandidateSet.NoteCandidates(
14485 PDiag(diag::err_ovl_no_viable_function_in_call)
14491 CandidateSet.NoteCandidates(
14500 nullptr, HadMultipleCandidates,
14509 for (
unsigned ArgIdx = 0, N = Args.size(); ArgIdx != N; ++ArgIdx) {
14510 ExprResult InputInit = PerformCopyInitialization(
14515 ConvArgs[ArgIdx] = InputInit.
get();
14523 Context, Fn.
get(), llvm::makeArrayRef(ConvArgs, Args.size()), ResultTy,
14524 VK, LitEndLoc, UDSuffixLoc);
14526 if (CheckCallReturnType(FD->
getReturnType(), UDSuffixLoc, UDL, FD))
14529 if (CheckFunctionCall(FD, UDL,
nullptr))
14532 return MaybeBindToTemporary(UDL);
14549 Scope *S =
nullptr;
14552 if (!MemberLookup.
empty()) {
14554 BuildMemberReferenceExpr(Range, Range->
getType(), Loc,
14562 return FRS_DiagnosticIssued;
14564 *CallExpr = BuildCallExpr(S, MemberRef.
get(), Loc, None, Loc,
nullptr);
14567 return FRS_DiagnosticIssued;
14575 FoundNames.
begin(), FoundNames.
end());
14577 bool CandidateSetError = buildOverloadedCallSet(S, Fn, Fn, Range, Loc,
14578 CandidateSet, CallExpr);
14579 if (CandidateSet->
empty() || CandidateSetError) {
14581 return FRS_NoViableFunction;
14589 return FRS_NoViableFunction;
14592 Loc,
nullptr, CandidateSet, &Best,
14597 return FRS_DiagnosticIssued;
14600 return FRS_Success;
14611 if (
ParenExpr *PE = dyn_cast<ParenExpr>(E)) {
14612 Expr *SubExpr = FixOverloadedFunctionReference(PE->getSubExpr(),
14614 if (SubExpr == PE->getSubExpr())
14617 return new (Context)
ParenExpr(PE->getLParen(), PE->getRParen(), SubExpr);
14621 Expr *SubExpr = FixOverloadedFunctionReference(ICE->getSubExpr(),
14623 assert(Context.
hasSameType(ICE->getSubExpr()->getType(),
14625 "Implicit cast type cannot be determined from overload");
14626 assert(ICE->path_empty() &&
"fixing up hierarchy conversion?");
14627 if (SubExpr == ICE->getSubExpr())
14631 ICE->getCastKind(),
14636 if (
auto *GSE = dyn_cast<GenericSelectionExpr>(E)) {
14637 if (!GSE->isResultDependent()) {
14639 FixOverloadedFunctionReference(GSE->getResultExpr(), Found, Fn);
14640 if (SubExpr == GSE->getResultExpr())
14647 unsigned ResultIdx = GSE->getResultIndex();
14648 AssocExprs[ResultIdx] = SubExpr;
14651 Context, GSE->getGenericLoc(), GSE->getControllingExpr(),
14652 GSE->getAssocTypeSourceInfos(), AssocExprs, GSE->getDefaultLoc(),
14653 GSE->getRParenLoc(), GSE->containsUnexpandedParameterPack(),
14662 assert(UnOp->getOpcode() == UO_AddrOf &&
14663 "Can only take the address of an overloaded function");
14665 if (Method->isStatic()) {
14672 Expr *SubExpr = FixOverloadedFunctionReference(UnOp->getSubExpr(),
14674 if (SubExpr == UnOp->getSubExpr())
14677 assert(isa<DeclRefExpr>(SubExpr)
14678 &&
"fixed to something other than a decl ref");
14679 assert(cast<DeclRefExpr>(SubExpr)->getQualifier()
14680 &&
"fixed to a member ref with no nested name qualifier");
14686 = Context.
getTypeDeclType(cast<RecordDecl>(Method->getDeclContext()));
14691 (
void)isCompleteType(UnOp->getOperatorLoc(), MemPtrType);
14693 return new (Context)
UnaryOperator(SubExpr, UO_AddrOf, MemPtrType,
14695 UnOp->getOperatorLoc(),
false);
14698 Expr *SubExpr = FixOverloadedFunctionReference(UnOp->getSubExpr(),
14700 if (SubExpr == UnOp->getSubExpr())
14706 UnOp->getOperatorLoc(),
false);
14712 if (ULE->hasExplicitTemplateArgs()) {
14713 ULE->copyTemplateArgumentsInto(TemplateArgsBuffer);
14714 TemplateArgs = &TemplateArgsBuffer;
14719 ULE->getQualifierLoc(), Found.
getDecl(),
14720 ULE->getTemplateKeywordLoc(), TemplateArgs);
14728 if (MemExpr->hasExplicitTemplateArgs()) {
14729 MemExpr->copyTemplateArgumentsInto(TemplateArgsBuffer);
14730 TemplateArgs = &TemplateArgsBuffer;
14737 if (MemExpr->isImplicitAccess()) {
14738 if (cast<CXXMethodDecl>(Fn)->isStatic()) {
14741 MemExpr->getQualifierLoc(), Found.
getDecl(),
14742 MemExpr->getTemplateKeywordLoc(), TemplateArgs);
14747 if (MemExpr->getQualifier())
14748 Loc = MemExpr->getQualifierLoc().getBeginLoc();
14750 BuildCXXThisExpr(Loc, MemExpr->getBaseType(),
true);
14753 Base = MemExpr->getBase();
14757 if (cast<CXXMethodDecl>(Fn)->isStatic()) {
14765 return BuildMemberExpr(
14766 Base, MemExpr->isArrow(), MemExpr->getOperatorLoc(),
14767 MemExpr->getQualifierLoc(), MemExpr->getTemplateKeywordLoc(), Fn, Found,
14768 true, MemExpr->getMemberNameInfo(),
14772 llvm_unreachable(
"Invalid reference to overloaded function");
14778 return FixOverloadedFunctionReference(E.
get(), Found, Fn);
Abstract class used to diagnose incomplete types.
Condition in an explicit(bool) specifier.
unsigned ExplicitCallArguments
The number of call arguments that were explicitly provided, to be used while performing partial order...
A call to an overloaded operator written using operator syntax.
SourceLocation getLoc() const
getLoc - Returns the main location of the declaration name.
const ObjCInterfaceType * getInterfaceType() const
If this pointer points to an Objective C @interface type, gets the type for that interface.
void setValueDependent(bool VD)
Set whether this expression is value-dependent or not.
const internal::VariadicAllOfMatcher< Type > type
Matches Types in the clang AST.
Function pointer conversion (C++17 [conv.fctptr])
DeclAccessPair FoundConversionFunction
The declaration that we found via name lookup, which might be the same as ConversionFunction or it mi...
Defines the clang::ASTContext interface.
QualType getAddrSpaceQualType(QualType T, LangAS AddressSpace) const
Return the uniqued reference to the type for an address space qualified type with the specified type ...
unsigned DeprecatedStringLiteralToCharPtr
Whether this is the deprecated conversion of a string literal to a pointer to non-const character dat...
void clear(CandidateSetKind CSK)
Clear out all of the candidates.
(CUDA) This candidate was not viable because the callee was not accessible from the caller's target (...
unsigned getNumDecls() const
Gets the number of declarations in the unresolved set.
Represents a function declaration or definition.
NamespaceDecl * getStdNamespace() const
void setStdInitializerListElement(bool V=true)
static DiagnosticBuilder Diag(DiagnosticsEngine *Diags, const LangOptions &Features, FullSourceLoc TokLoc, const char *TokBegin, const char *TokRangeBegin, const char *TokRangeEnd, unsigned DiagID)
Produce a diagnostic highlighting some portion of a literal.
bool EllipsisConversion
EllipsisConversion - When this is true, it means user-defined conversion sequence starts with a ...
CUDA Target attributes do not match.
static void markUnaddressableCandidatesUnviable(Sema &S, OverloadCandidateSet &CS)
bool hasExplicitTemplateArgs() const
Determines whether this expression had explicit template arguments.
ExprResult PerformContextuallyConvertToBool(Expr *From)
PerformContextuallyConvertToBool - Perform a contextual conversion of the expression From to bool (C+...
no exception specification
const TemplateArgument * getSecondArg()
Return the second template argument this deduction failure refers to, if any.
Smart pointer class that efficiently represents Objective-C method names.
static bool isTypeValid(QualType T)
Determine whether the given type is valid, e.g., it is not an invalid C++ class.
QualType getObjCIdType() const
Represents the Objective-CC id type.
PointerType - C99 6.7.5.1 - Pointer Declarators.
QualType getPointeeType() const
A (possibly-)qualified type.
bool isBlockPointerType() const
static void DiagnoseArityMismatch(Sema &S, NamedDecl *Found, Decl *D, unsigned NumFormalArgs)
General arity mismatch diagnosis over a candidate in a candidate set.
TemplateDeductionResult
Describes the result of template argument deduction.
void setToType(QualType T)
bool isMemberPointerType() const
ValueDecl * getMemberDecl() const
Retrieve the member declaration to which this expression refers.
ImplicitConversionKind
ImplicitConversionKind - The kind of implicit conversion used to convert an argument to a parameter's...
unsigned param_size() const
bool isEquivalentInternalLinkageDeclaration(const NamedDecl *A, const NamedDecl *B)
Determine if A and B are equivalent internal linkage declarations from different modules, and thus an ambiguity error can be downgraded to an extension warning.
void setFromType(QualType T)
const DeclarationNameLoc & getInfo() const
Candidate is not a rewritten candidate.
void DiagnoseUnsatisfiedConstraint(const ConstraintSatisfaction &Satisfaction, bool First=true)
Emit diagnostics explaining why a constraint expression was deemed unsatisfied.
Conversion not allowed by the C standard, but that we accept as an extension anyway.
static bool IsTransparentUnionStandardConversion(Sema &S, Expr *From, QualType &ToType, bool InOverloadResolution, StandardConversionSequence &SCS, bool CStyle)
Template argument deduction was successful.
const FunctionProtoType * ResolveExceptionSpec(SourceLocation Loc, const FunctionProtoType *FPT)
UnresolvedSetIterator getMostSpecialized(UnresolvedSetIterator SBegin, UnresolvedSetIterator SEnd, TemplateSpecCandidateSet &FailedCandidates, SourceLocation Loc, const PartialDiagnostic &NoneDiag, const PartialDiagnostic &AmbigDiag, const PartialDiagnostic &CandidateDiag, bool Complain=true, QualType TargetType=QualType())
Retrieve the most specialized of the given function template specializations.
Information about operator rewrites to consider when adding operator functions to a candidate set...
OverloadCandidateParamOrder
The parameter ordering that will be used for the candidate.
Ordinary name lookup, which finds ordinary names (functions, variables, typedefs, etc...
const Expr * getInit(unsigned Init) const
bool isObjCPointerConversion(QualType FromType, QualType ToType, QualType &ConvertedType, bool &IncompatibleObjC)
isObjCPointerConversion - Determines whether this is an Objective-C pointer conversion.
QualType getPointerDiffType() const
Return the unique type for "ptrdiff_t" (C99 7.17) defined in <stddef.h>.
A structure used to record information about a failed template argument deduction, for diagnosis.
Checking non-dependent argument conversions failed.
Decl * Entity
The entity that is being synthesized.
Cannot tell whether this is a narrowing conversion because the expression is value-dependent.
bool isArithmeticType() const
specific_attr_iterator< T > specific_attr_begin() const
Stmt - This represents one statement.
FunctionType - C99 6.7.5.3 - Function Declarators.
Provides information about an attempted template argument deduction, whose success or failure was des...
QualType getPointeeType() const
If this is a pointer, ObjC object pointer, or block pointer, this returns the respective pointee...
bool isMain() const
Determines whether this function is "main", which is the entry point into an executable program...
bool diagnoseArgDependentDiagnoseIfAttrs(const FunctionDecl *Function, const Expr *ThisArg, ArrayRef< const Expr *> Args, SourceLocation Loc)
Emit diagnostics for the diagnose_if attributes on Function, ignoring any non-ArgDependent DiagnoseIf...
bool isRealFloatingType() const
Floating point categories.
static CallExpr * CreateTemporary(void *Mem, Expr *Fn, QualType Ty, ExprValueKind VK, SourceLocation RParenLoc, ADLCallKind UsesADL=NotADL)
Create a temporary call expression with no arguments in the memory pointed to by Mem.
bool hasPlaceholderType() const
Returns whether this expression has a placeholder type.
void clear()
Clear out all of the candidates.
ConversionSet::const_iterator const_iterator
QualType getThisType() const
Return the type of the this pointer.
Complex conversions (C99 6.3.1.6)
void setObjCLifetime(ObjCLifetime type)
bool isRecordType() const
static void DiagnoseFailedExplicitSpec(Sema &S, OverloadCandidate *Cand)
bool isEmpty() const
No scope specifier.
std::string getTemplateArgumentBindingsText(const TemplateParameterList *Params, const TemplateArgumentList &Args)
Produces a formatted string that describes the binding of template parameters to template arguments...
static InitializedEntity InitializeParameter(ASTContext &Context, const ParmVarDecl *Parm)
Create the initialization entity for a parameter.
UserDefinedConversionSequence UserDefined
When ConversionKind == UserDefinedConversion, provides the details of the user-defined conversion seq...
QualType getQualifiedType(SplitQualType split) const
Un-split a SplitQualType.
QualType getLValueReferenceType(QualType T, bool SpelledAsLValue=true) const
Return the uniqued reference to the type for an lvalue reference to the specified type...
const Type * getTypeForDecl() const
SemaDiagnosticBuilder Diag(SourceLocation Loc, unsigned DiagID)
Emit a diagnostic.
ConstructorInfo getConstructorInfo(NamedDecl *ND)
bool isBetterOverloadCandidate(Sema &S, const OverloadCandidate &Cand1, const OverloadCandidate &Cand2, SourceLocation Loc, OverloadCandidateSet::CandidateSetKind Kind)
isBetterOverloadCandidate - Determines whether the first overload candidate is a better candidate tha...
Decl - This represents one declaration (or definition), e.g.
static ImplicitConversionSequence TryContextuallyConvertToBool(Sema &S, Expr *From)
TryContextuallyConvertToBool - Attempt to contextually convert the expression From to bool (C++0x [co...
specific_attr_iterator - Iterates over a subrange of an AttrVec, only providing attributes that are o...
bool isVariadic() const
Whether this function prototype is variadic.
__DEVICE__ long long abs(long long __n)
ExprResult BuildCallToMemberFunction(Scope *S, Expr *MemExpr, SourceLocation LParenLoc, MultiExprArg Args, SourceLocation RParenLoc)
BuildCallToMemberFunction - Build a call to a member function.
static ImplicitConversionSequence::CompareKind CompareDerivedToBaseConversions(Sema &S, SourceLocation Loc, const StandardConversionSequence &SCS1, const StandardConversionSequence &SCS2)
CompareDerivedToBaseConversions - Compares two standard conversion sequences to determine whether the...
static TemplateDecl * getDescribedTemplate(Decl *Templated)
bool isExtVectorType() const
AssignConvertType
AssignConvertType - All of the 'assignment' semantic checks return this enum to indicate whether the ...
A reference to a name which we were able to look up during parsing but could not resolve to a specifi...
ExprResult PerformContextualImplicitConversion(SourceLocation Loc, Expr *FromE, ContextualImplicitConverter &Converter)
Perform a contextual implicit conversion.
ConstExprUsage
Indicates how the constant expression will be used.
Classification Classify(ASTContext &Ctx) const
Classify - Classify this expression according to the C++11 expression taxonomy.
OverloadedOperatorKind getCXXOverloadedOperator() const
If this name is the name of an overloadable operator in C++ (e.g., operator+), retrieve the kind of o...
Not a narrowing conversion.
bool isBeforeInTranslationUnit(SourceLocation LHS, SourceLocation RHS) const
Determines the order of 2 source locations in the translation unit.
ParenExpr - This represents a parethesized expression, e.g.
NamedDecl * getDecl() const
QualType getNonReferenceType() const
If Type is a reference type (e.g., const int&), returns the type that the reference refers to ("const...
bool CanPerformCopyInitialization(const InitializedEntity &Entity, ExprResult Init)
ImplicitConversionRank
ImplicitConversionRank - The rank of an implicit conversion kind.
bool hasQualifier() const
Determines whether this member expression actually had a C++ nested-name-specifier prior to the name ...
The base class of the type hierarchy.
CanQual< T > getUnqualifiedType() const
Retrieve the unqualified form of this type.
unsigned IncompatibleObjC
IncompatibleObjC - Whether this is an Objective-C conversion that we should warn about (if we actuall...
static bool convertArgsForAvailabilityChecks(Sema &S, FunctionDecl *Function, Expr *ThisArg, ArrayRef< Expr *> Args, Sema::SFINAETrap &Trap, bool MissingImplicitThis, Expr *&ConvertedThis, SmallVectorImpl< Expr *> &ConvertedArgs)
Represent a C++ namespace.
Template argument deduction produced inconsistent deduced values for the given template parameter...
SourceLocation getLocForEndOfToken(SourceLocation Loc, unsigned Offset=0)
Calls Lexer::getLocForEndOfToken()
static ExprValueKind getValueKindForType(QualType T)
getValueKindForType - Given a formal return or parameter type, give its value kind.
bool isRestrictQualified() const
Determine whether this type is restrict-qualified.
Ambiguous candidates found.
const TargetInfo & getTargetInfo() const
Store information needed for an explicit specifier.
QualType getValueType() const
Gets the type contained by this atomic type, i.e.
Conversions between compatible types in C99.
Floating point control options.
constexpr XRayInstrMask Function
static bool CheckConvertedConstantConversions(Sema &S, StandardConversionSequence &SCS)
Check that the specified conversion is permitted in a converted constant expression, according to C++11 [expr.const]p3.
bool inferCUDATargetForImplicitSpecialMember(CXXRecordDecl *ClassDecl, CXXSpecialMember CSM, CXXMethodDecl *MemberDecl, bool ConstRHS, bool Diagnose)
Given a implicit special member, infer its CUDA target from the calls it needs to make to underlying ...
bool IgnoreObjectArgument
IgnoreObjectArgument - True to indicate that the first argument's conversion, which for this function...
QualType getConversionType() const
Returns the type that this conversion function is converting to.
Partial ordering of function templates for a call to a conversion function.
unsigned DirectBinding
DirectBinding - True when this is a reference binding that is a direct binding (C++ [dcl...
Represents a C++ constructor within a class.
LLVM_ATTRIBUTE_REINITIALIZES void clear()
Clears out any current state.
float __ovld __cnfn distance(float p0, float p1)
Returns the distance between p0 and p1.
size_t param_size() const
static QualType withoutUnaligned(ASTContext &Ctx, QualType T)
QualType getElementType() const
static unsigned RankDeductionFailure(const DeductionFailureInfo &DFI)
const RecordType * getAsUnionType() const
NOTE: getAs*ArrayType are methods on ASTContext.
static CXXOperatorCallExpr * Create(const ASTContext &Ctx, OverloadedOperatorKind OpKind, Expr *Fn, ArrayRef< Expr *> Args, QualType Ty, ExprValueKind VK, SourceLocation OperatorLoc, FPOptions FPFeatures, ADLCallKind UsesADL=NotADL)
static bool isFunctionAlwaysEnabled(const ASTContext &Ctx, const FunctionDecl *FD)
bool isUnsignedIntegerType() const
Return true if this is an integer type that is unsigned, according to C99 6.2.5p6 [which returns true...
void Adopt(NestedNameSpecifierLoc Other)
Adopt an existing nested-name-specifier (with source-range information).
RAII object that enters a new expression evaluation context.
QualType getFromType() const
PartialDiagnostic PDiag(unsigned DiagID=0)
Build a partial diagnostic.
void AddOverloadedCallCandidates(UnresolvedLookupExpr *ULE, ArrayRef< Expr *> Args, OverloadCandidateSet &CandidateSet, bool PartialOverloading=false)
Add the overload candidates named by callee and/or found by argument dependent lookup to the given ov...
ExprResult PerformObjectArgumentInitialization(Expr *From, NestedNameSpecifier *Qualifier, NamedDecl *FoundDecl, CXXMethodDecl *Method)
PerformObjectArgumentInitialization - Perform initialization of the implicit object parameter for the...
static bool isAllowableExplicitConversion(Sema &S, QualType ConvType, QualType ToType, bool AllowObjCPointerConversion)
Determine whether this is an allowable conversion from the result of an explicit conversion operator ...
DeclarationName getLookupName() const
Gets the name to look up.
void removeObjCLifetime()
QualType getReturnType() const
DiagnosticsEngine & Diags
unsigned getNumParams() const
bool isEnumeralType() const
bool isUserDefined() const
bool isFixed() const
Returns true if this is an Objective-C, C++11, or Microsoft-style enumeration with a fixed underlying...
const T * getAs() const
Member-template getAs<specific type>'.
static ExprResult FinishOverloadedCallExpr(Sema &SemaRef, Scope *S, Expr *Fn, UnresolvedLookupExpr *ULE, SourceLocation LParenLoc, MultiExprArg Args, SourceLocation RParenLoc, Expr *ExecConfig, OverloadCandidateSet *CandidateSet, OverloadCandidateSet::iterator *Best, OverloadingResult OverloadResult, bool AllowTypoCorrection)
FinishOverloadedCallExpr - given an OverloadCandidateSet, builds and returns the completed call expre...
PrintingPolicy getPrintingPolicy() const
Retrieve a suitable printing policy for diagnostics.
OverloadKind CheckOverload(Scope *S, FunctionDecl *New, const LookupResult &OldDecls, NamedDecl *&OldDecl, bool IsForUsingDecl)
Determine whether the given New declaration is an overload of the declarations in Old...
static bool functionHasPassObjectSizeParams(const FunctionDecl *FD)
Extra information about a function prototype.
bool IsSurrogate
IsSurrogate - True to indicate that this candidate is a surrogate for a conversion to a function poin...
static ImplicitConversionSequence::CompareKind CompareQualificationConversions(Sema &S, const StandardConversionSequence &SCS1, const StandardConversionSequence &SCS2)
CompareQualificationConversions - Compares two standard conversion sequences to determine whether the...
LangAS
Defines the address space values used by the address space qualifier of QualType. ...
void Profile(llvm::FoldingSetNodeID &ID, const ASTContext &Context, bool Canonical) const
Produce a unique representation of the given statement.
ObjCMethodDecl - Represents an instance or class method declaration.
NamedDecl * getUnderlyingDecl()
Looks through UsingDecls and ObjCCompatibleAliasDecls for the underlying named decl.
ExprResult ActOnFinishFullExpr(Expr *Expr, bool DiscardedValue)
QualType ExtractUnqualifiedFunctionType(QualType PossiblyAFunctionType)
QualType getMemberPointerType(QualType T, const Type *Cls) const
Return the uniqued reference to the type for a member pointer to the specified type in the specified ...
DeclarationName getName() const
Gets the name looked up.
bool HadMultipleCandidates
HadMultipleCandidates - When this is true, it means that the conversion function was resolved from an...
bool isInvalidDecl() const
Like System, but searched after the system directories.
Decl * Specialization
Specialization - The actual specialization that this candidate represents.
bool requiresADL() const
True if this declaration should be extended by argument-dependent lookup.
A context in which code is being synthesized (where a source location alone is not sufficient to iden...
ReferenceCompareResult CompareReferenceRelationship(SourceLocation Loc, QualType T1, QualType T2, ReferenceConversions *Conv=nullptr)
CompareReferenceRelationship - Compare the two types T1 and T2 to determine whether they are referenc...
static bool DiagnoseTwoPhaseOperatorLookup(Sema &SemaRef, OverloadedOperatorKind Op, SourceLocation OpLoc, ArrayRef< Expr *> Args)
Attempt to recover from ill-formed use of a non-dependent operator in a template, where the non-depen...
bool IsIntegralPromotion(Expr *From, QualType FromType, QualType ToType)
IsIntegralPromotion - Determines whether the conversion from the expression From (whose potentially-a...
bool hasDefinition() const
std::vector< FixItHint > Hints
The list of Hints generated so far.
Represents a parameter to a function.
QualType getLocalUnqualifiedType() const
Return this type with all of the instance-specific qualifiers removed, but without removing any quali...
Defines the clang::Expr interface and subclasses for C++ expressions.
TemplateParameter Param
The template parameter to which a template argument deduction failure refers.
static void MaybeDiagnoseAmbiguousConstraints(Sema &S, ArrayRef< OverloadCandidate > Cands)
static const TemplateDecl * isTemplate(const NamedDecl *ND, const TemplateArgumentList *&TemplateArgs)
void * ToTypePtrs[3]
ToType - The types that this conversion is converting to in each step.
The collection of all-type qualifiers we support.
FieldDecl * getSourceBitField()
If this expression refers to a bit-field, retrieve the declaration of that bit-field.
bool isObjCObjectOrInterfaceType() const
bool UnwrapSimilarTypes(QualType &T1, QualType &T2)
Attempt to unwrap two types that may be similar (C++ [conv.qual]).
Qualifiers getQualifiers() const
Retrieve all qualifiers.
OverloadCandidate & addCandidate(unsigned NumConversions=0, ConversionSequenceList Conversions=None)
Add a new candidate with NumConversions conversion sequence slots to the overload set...
ExprResult PerformImplicitConversion(Expr *From, QualType ToType, AssignmentAction Action, bool AllowExplicit=false)
PerformImplicitConversion - Perform an implicit conversion of the expression From to the type ToType...
bool isMoveAssignmentOperator() const
Determine whether this is a move assignment operator.
Expr * FixOverloadedFunctionReference(Expr *E, DeclAccessPair FoundDecl, FunctionDecl *Fn)
FixOverloadedFunctionReference - E is an expression that refers to a C++ overloaded function (possibl...
Represents a struct/union/class.
enum clang::Sema::CodeSynthesisContext::SynthesisKind Kind
DeclarationName getDeclName() const
Get the actual, stored name of the declaration, which may be a special name.
bool Encloses(const DeclContext *DC) const
Determine whether this declaration context encloses the declaration context DC.
Boolean conversions (C++ [conv.bool])
One of these records is kept for each identifier that is lexed.
TargetCXXABI getCXXABI() const
Get the C++ ABI currently in use.
ExprResult CreateOverloadedBinOp(SourceLocation OpLoc, BinaryOperatorKind Opc, const UnresolvedSetImpl &Fns, Expr *LHS, Expr *RHS, bool RequiresADL=true, bool AllowRewrittenCandidates=true, FunctionDecl *DefaultedFn=nullptr)
Create a binary operation that may resolve to an overloaded operator.
Value of a non-type template parameter.
SourceLocation getBeginLoc() const LLVM_READONLY
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
A C++ nested-name-specifier augmented with source location information.
bool inTemplateInstantiation() const
Determine whether we are currently performing template instantiation.
void dump() const
dump - Print this implicit conversion sequence to standard error.
bool isObjCLifetimeType() const
Returns true if objects of this type have lifetime semantics under ARC.
static bool diagnoseNoViableConversion(Sema &SemaRef, SourceLocation Loc, Expr *&From, Sema::ContextualImplicitConverter &Converter, QualType T, bool HadMultipleCandidates, UnresolvedSetImpl &ExplicitConversions)
unsigned BindsToFunctionLvalue
Whether we're binding to a function lvalue.
TemplateDecl * getAsTemplateDecl() const
Retrieve the underlying template declaration that this template name refers to, if known...
C++ [over.match.copy]: Copy-initialization of an object of class type by user-defined conversion...
Base class for callback objects used by Sema::CorrectTypo to check the validity of a potential typo c...
BadConversionSequence Bad
When ConversionKind == BadConversion, provides the details of the bad conversion. ...
bool IsDerivedFrom(SourceLocation Loc, QualType Derived, QualType Base)
Determine whether the type Derived is a C++ class that is derived from the type Base.
field_range fields() const
SourceLocation getBeginLoc() const LLVM_READONLY
NameKind getNameKind() const
Determine what kind of name this is.
bool isObjCIdType() const
Represents a member of a struct/union/class.
void LookupOverloadedBinOp(OverloadCandidateSet &CandidateSet, OverloadedOperatorKind Op, const UnresolvedSetImpl &Fns, ArrayRef< Expr *> Args, bool RequiresADL=true)
Perform lookup for an overloaded binary operator.
Expr * getBase()
Retrieve the base object of this member expressions, e.g., the x in x.m.
Identity conversion (no conversion)
CallExpr::ADLCallKind IsADLCandidate
True if the candidate was found using ADL.
bool isStdInitializerListElement() const
Whether the target is really a std::initializer_list, and the sequence only represents the worst elem...
ConversionSet & conversions()
bool buildOverloadedCallSet(Scope *S, Expr *Fn, UnresolvedLookupExpr *ULE, MultiExprArg Args, SourceLocation RParenLoc, OverloadCandidateSet *CandidateSet, ExprResult *Result)
Constructs and populates an OverloadedCandidateSet from the given function.
bool Zero(InterpState &S, CodePtr OpPC)
static bool isQualificationConversionStep(QualType FromType, QualType ToType, bool CStyle, bool IsTopLevel, bool &PreviousToQualsIncludeConst, bool &ObjCLifetimeConversion)
Perform a single iteration of the loop for checking if a qualification conversion is valid...
bool isNewCandidate(Decl *F, OverloadCandidateParamOrder PO=OverloadCandidateParamOrder::Normal)
Determine when this overload candidate will be new to the overload set.
Floating point conversions (C++ [conv.double].
virtual SemaDiagnosticBuilder diagnoseConversion(Sema &S, SourceLocation Loc, QualType T, QualType ConvTy)=0
Emits a diagnostic when we picked a conversion function (for cases when we are not allowed to pick a ...
bool isReferenceType() const
The iterator over UnresolvedSets.
ExprResult PerformContextuallyConvertToObjCPointer(Expr *From)
PerformContextuallyConvertToObjCPointer - Perform a contextual conversion of the expression From to a...
bool match(QualType T) override
Match an integral or (possibly scoped) enumeration type.
bool isSpecialized() const
Whether this type is specialized, meaning that it has type arguments.
CompatiblePointerDiscardsQualifiers - The assignment discards c/v/r qualifiers, which we accept as an...
void copyTemplateArgumentsInto(TemplateArgumentListInfo &List) const
Copies the template arguments into the given structure.
Represents a C++ member access expression for which lookup produced a set of overloaded functions...
Ref_Incompatible - The two types are incompatible, so direct reference binding is not possible...
CUDAFunctionTarget IdentifyCUDATarget(const FunctionDecl *D, bool IgnoreImplicitHDAttr=false)
Determines whether the given function is a CUDA device/host/kernel/etc.
ConstraintSatisfaction AssociatedConstraintsSatisfaction
The constraint satisfaction details resulting from the associated constraints satisfaction tests...
SourceLocation getBeginLoc() const LLVM_READONLY
ConversionSequenceList allocateConversionSequences(unsigned NumConversions)
Allocate storage for conversion sequences for NumConversions conversions.
specific_attr_iterator< T > specific_attr_end() const
ComparisonCategoryResult
An enumeration representing the possible results of a three-way comparison.
void set(DeclAccessPair Found, Decl *Spec, DeductionFailureInfo Info)
OverloadKind
C++ Overloading.
bool isAtLeastAsQualifiedAs(QualType Other) const
Determine whether this type is at least as qualified as the other given type, requiring exact equalit...
bool isIntegralOrEnumerationType() const
Determine whether this type is an integral or enumeration type.
Describes a module or submodule.
OverloadCandidateDisplayKind
Qualifiers getLocalQualifiers() const
Retrieve the set of qualifiers local to this particular QualType instance, not including any qualifie...
void getAssociatedConstraints(SmallVectorImpl< const Expr *> &AC) const
Get the associated-constraints of this function declaration.
An r-value expression (a pr-value in the C++11 taxonomy) produces a temporary value.
ArrayRef< ParmVarDecl * > parameters() const
DeclClass * getAsSingle() const
StringRef getOpcodeStr() const
Floating point promotions (C++ [conv.fpprom])
Describes an C or C++ initializer list.
An rvalue reference type, per C++11 [dcl.ref].
bool isCompleteType(SourceLocation Loc, QualType T)
static ExprResult CheckConvertedConstantExpression(Sema &S, Expr *From, QualType T, APValue &Value, Sema::CCEKind CCE, bool RequireInt)
CheckConvertedConstantExpression - Check that the expression From is a converted constant expression ...
ReferenceConversions
The conversions that would be performed on an lvalue of type T2 when binding a reference of type T1 t...
SmallVectorImpl< PartialDiagnosticAt > * Diag
Diag - If this is non-null, it will be filled in with a stack of notes indicating why evaluation fail...
Represents the results of name lookup.
RefQualifierKind getRefQualifier() const
Retrieve the ref-qualifier associated with this method.
OverloadCandidateRewriteKind getRewriteKind(const FunctionDecl *FD, OverloadCandidateParamOrder PO)
Determine the kind of rewrite that should be performed for this candidate.
An lvalue ref-qualifier was provided (&).
ExprResult CreateOverloadedUnaryOp(SourceLocation OpLoc, UnaryOperatorKind Opc, const UnresolvedSetImpl &Fns, Expr *input, bool RequiresADL=true)
Create a unary operation that may resolve to an overloaded operator.
unsigned BindsToRvalue
Whether we're binding to an rvalue.
static ImplicitConversionSequence::CompareKind compareStandardConversionSubsets(ASTContext &Context, const StandardConversionSequence &SCS1, const StandardConversionSequence &SCS2)
static DeclAccessPair make(NamedDecl *D, AccessSpecifier AS)
std::string getFullModuleName(bool AllowStringLiterals=false) const
Retrieve the full name of this module, including the path from its top-level module.
bool HasFormOfMemberPointer
void setCXXOperatorNameRange(SourceRange R)
setCXXOperatorNameRange - Sets the range of the operator name (without the operator keyword)...
TemplateSpecCandidateSet - A set of generalized overload candidates, used in template specializations...
bool isPartial() const
True iff the comparison is not totally ordered.
Succeeded, but refers to a deleted function.
APValue Val
Val - This is the value the expression can be folded to.
A convenient class for passing around template argument information.
static const Expr * IgnoreNarrowingConversion(ASTContext &Ctx, const Expr *Converted)
Skip any implicit casts which could be either part of a narrowing conversion or after one in an impli...
QualType getVolatileType(QualType T) const
Return the uniqued reference to the type for a volatile qualified type.
Ref_Compatible - The two types are reference-compatible.
bool hasPrototype() const
Whether this function has a prototype, either because one was explicitly written or because it was "i...
FunctionTemplateDecl * getDescribedFunctionTemplate() const
Retrieves the function template that is described by this function declaration.
unsigned QualificationIncludesObjCLifetime
Whether the qualification conversion involves a change in the Objective-C lifetime (for automatic ref...
ExprValueKind getValueKind() const
getValueKind - The value kind that this expression produces.
SourceLocation getTemplateKeywordLoc() const
Retrieve the location of the template keyword preceding this name, if any.
QualType getToType(unsigned Idx) const
OverloadCandidateRewriteKind getRewriteKind() const
Get RewriteKind value in OverloadCandidateRewriteKind type (This function is to workaround the spurio...
bool IsFunctionConversion(QualType FromType, QualType ToType, QualType &ResultTy)
Determine whether the conversion from FromType to ToType is a valid conversion that strips "noexcept"...
void MarkDeclRefReferenced(DeclRefExpr *E, const Expr *Base=nullptr)
Perform reference-marking and odr-use handling for a DeclRefExpr.
static bool isRecordType(QualType T)
bool diagnoseArgIndependentDiagnoseIfAttrs(const NamedDecl *ND, SourceLocation Loc)
Emit diagnostics for the diagnose_if attributes on Function, ignoring any ArgDependent DiagnoseIfAttr...
A builtin binary operation expression such as "x + y" or "x <= y".
Substitution of the deduced template argument values resulted in an error.
bool isVolatileQualified() const
Determine whether this type is volatile-qualified.
This candidate function was not viable because an enable_if attribute disabled it.
LangAS getAddressSpace() const
A set of unresolved declarations.
ImplicitConversionKind Second
Second - The second conversion can be an integral promotion, floating point promotion, integral conversion, floating point conversion, floating-integral conversion, pointer conversion, pointer-to-member conversion, or boolean conversion.
const Type * getClass() const
bool isRValueReferenceType() const
Template argument deduction exceeded the maximum template instantiation depth (which has already been...
void diagnoseEquivalentInternalLinkageDeclarations(SourceLocation Loc, const NamedDecl *D, ArrayRef< const NamedDecl *> Equiv)
static ImplicitConversionSequence TryListConversion(Sema &S, InitListExpr *From, QualType ToType, bool SuppressUserConversions, bool InOverloadResolution, bool AllowObjCWritebackConversion)
TryListConversion - Try to copy-initialize a value of type ToType from the initializer list From...
static void AddOverloadedCallCandidate(Sema &S, DeclAccessPair FoundDecl, TemplateArgumentListInfo *ExplicitTemplateArgs, ArrayRef< Expr *> Args, OverloadCandidateSet &CandidateSet, bool PartialOverloading, bool KnownValid)
Add a single candidate to the overload set.
Defines the Diagnostic-related interfaces.
A narrowing conversion, because a constant expression got narrowed.
FunctionDecl * ResolveAddressOfOverloadedFunction(Expr *AddressOfExpr, QualType TargetType, bool Complain, DeclAccessPair &Found, bool *pHadMultipleCandidates=nullptr)
ResolveAddressOfOverloadedFunction - Try to resolve the address of an overloaded function (C++ [over...
ExprResult BuildOverloadedCallExpr(Scope *S, Expr *Fn, UnresolvedLookupExpr *ULE, SourceLocation LParenLoc, MultiExprArg Args, SourceLocation RParenLoc, Expr *ExecConfig, bool AllowTypoCorrection=true, bool CalleesAddressIsTaken=false)
BuildOverloadedCallExpr - Given the call expression that calls Fn (which eventually refers to the dec...
unsigned IsLvalueReference
Whether this is an lvalue reference binding (otherwise, it's an rvalue reference binding).
bool isLambda() const
Determine whether this class describes a lambda function object.
Expr * IgnoreParenCasts() LLVM_READONLY
Skip past any parentheses and casts which might surround this expression until reaching a fixed point...
NarrowingKind
NarrowingKind - The kind of narrowing conversion being performed by a standard conversion sequence ac...
Scope - A scope is a transient data structure that is used while parsing the program.
QualType getCVRQualifiedType(QualType T, unsigned CVR) const
Return a type with additional const, volatile, or restrict qualifiers.
bool MaybeEmitAmbiguousAtomicConstraintsDiagnostic(NamedDecl *D1, ArrayRef< const Expr *> AC1, NamedDecl *D2, ArrayRef< const Expr *> AC2)
If D1 was not at least as constrained as D2, but would've been if a pair of atomic constraints involv...
const Type * getTypePtr() const
Retrieves a pointer to the underlying (unqualified) type.
ExprResult BuildResolvedCallExpr(Expr *Fn, NamedDecl *NDecl, SourceLocation LParenLoc, ArrayRef< Expr *> Arg, SourceLocation RParenLoc, Expr *Config=nullptr, bool IsExecConfig=false, ADLCallKind UsesADL=ADLCallKind::NotADL)
BuildResolvedCallExpr - Build a call to a resolved expression, i.e.
param_type_iterator param_type_begin() const
void Destroy()
Free any memory associated with this deduction failure.
Qualification conversions (C++ [conv.qual])
bool isCPUSpecificMultiVersion() const
True if this function is a multiversioned processor specific function as a part of the cpu_specific/c...
llvm::iterator_range< conversion_iterator > getVisibleConversionFunctions() const
Get all conversion functions visible in current class, including conversion function templates...
static bool isBooleanType(QualType Ty)
NestedNameSpecifier * getQualifier() const
Fetches the nested-name qualifier, if one was given.
Represents a C++ nested-name-specifier or a global scope specifier.
void setFromType(QualType T)
static bool checkAddressOfFunctionIsAvailable(Sema &S, const FunctionDecl *FD, bool Complain, bool InOverloadResolution, SourceLocation Loc)
Returns true if we can take the address of the function.
const LangOptions & getLangOpts() const
static IntegerLiteral * Create(const ASTContext &C, const llvm::APInt &V, QualType type, SourceLocation l)
Returns a new integer literal with value 'V' and type 'type'.
bool isTypeDependent() const
isTypeDependent - Determines whether this expression is type-dependent (C++ [temp.dep.expr]), which means that its type could change from one template instantiation to the next.
static ImplicitConversionSequence TryContextuallyConvertToObjCPointer(Sema &S, Expr *From)
TryContextuallyConvertToObjCPointer - Attempt to contextually convert the expression From to an Objec...
void * getAsOpaquePtr() const
bool compatiblyIncludesObjCLifetime(Qualifiers other) const
Determines if these qualifiers compatibly include another set of qualifiers from the narrow perspecti...
AssignConvertType CheckSingleAssignmentConstraints(QualType LHSType, ExprResult &RHS, bool Diagnose=true, bool DiagnoseCFAudited=false, bool ConvertRHS=true)
Check assignment constraints for an assignment of RHS to LHSType.
An ordinary object is located at an address in memory.
virtual SemaDiagnosticBuilder diagnoseIncomplete(Sema &S, SourceLocation Loc, QualType T)=0
Emits a diagnostic when the expression has incomplete class type.
The number of conversion kinds.
ForRangeStatus BuildForRangeBeginEndCall(SourceLocation Loc, SourceLocation RangeLoc, const DeclarationNameInfo &NameInfo, LookupResult &MemberLookup, OverloadCandidateSet *CandidateSet, Expr *Range, ExprResult *CallExpr)
Build a call to 'begin' or 'end' for a C++11 for-range statement.
TemplateParameter getTemplateParameter()
Retrieve the template parameter this deduction failure refers to, if any.
Represents an ObjC class declaration.
static ExprResult finishContextualImplicitConversion(Sema &SemaRef, SourceLocation Loc, Expr *From, Sema::ContextualImplicitConverter &Converter)
ImplicitConversionKind Third
Third - The third conversion can be a qualification conversion or a function conversion.
IncompatiblePointerSign - The assignment is between two pointers types which point to integers which ...
ExprResult BuildDeclarationNameExpr(const CXXScopeSpec &SS, LookupResult &R, bool NeedsADL, bool AcceptInvalidDecl=false)
static UnresolvedLookupExpr * Create(const ASTContext &Context, CXXRecordDecl *NamingClass, NestedNameSpecifierLoc QualifierLoc, const DeclarationNameInfo &NameInfo, bool RequiresADL, bool Overloaded, UnresolvedSetIterator Begin, UnresolvedSetIterator End)
Complex <-> Real conversion.
bool Viable
Viable - True to indicate that this overload candidate is viable.
ConversionSequenceList Conversions
The conversion sequences used to convert the function arguments to the function parameters.
static Classification makeSimpleLValue()
Create a simple, modifiably lvalue.
CanQualType UnsignedCharTy
Integral promotions (C++ [conv.prom])
This conversion function template specialization candidate is not viable because the final conversion...
QualType removePtrSizeAddrSpace(QualType T) const
Remove the existing address space on the type if it is a pointer size address space and return the ty...
bool IsStringLiteralToNonConstPointerConversion(Expr *From, QualType ToType)
Helper function to determine whether this is the (deprecated) C++ conversion from a string literal to...
bool IsAtLeastAsConstrained(NamedDecl *D1, ArrayRef< const Expr *> AC1, NamedDecl *D2, ArrayRef< const Expr *> AC2, bool &Result)
Check whether the given declaration's associated constraints are at least as constrained than another...
SourceLocation getMemberLoc() const
Retrieve the location of the name of the member that this expression refers to.
QualType BuiltinParamTypes[3]
BuiltinParamTypes - Provides the parameter types of a built-in overload candidate.
This object can be modified without requiring retains or releases.
param_iterator param_begin()
C-only conversion between pointers with incompatible types.
DeclarationName getMemberName() const
Retrieve the name of the member that this expression refers to.
bool IsComplexPromotion(QualType FromType, QualType ToType)
Determine if a conversion is a complex promotion.
FunctionTemplateDecl * getPrimaryTemplate() const
Retrieve the primary template that this function template specialization either specializes or was in...
DiagnosticsEngine & getDiagnostics() const
CXXSpecialMember asSpecialMember() const
This candidate was not viable because its associated constraints were not satisfied.
RAII class used to determine whether SFINAE has trapped any errors that occur during template argumen...
bool isIntegralOrUnscopedEnumerationType() const
Determine whether this type is an integral or unscoped enumeration type.
static bool hasDeprecatedStringLiteralToCharPtrConversion(const ImplicitConversionSequence &ICS)
CXXSpecialMember
Kinds of C++ special members.
QualType getDeclaredReturnType() const
Get the declared return type, which may differ from the actual return type if the return type is dedu...
OverloadFixItKind Kind
The type of fix applied.
static Sema::TemplateDeductionResult DeduceTemplateArguments(Sema &S, TemplateParameterList *TemplateParams, const TemplateArgument &Param, TemplateArgument Arg, TemplateDeductionInfo &Info, SmallVectorImpl< DeducedTemplateArgument > &Deduced)
DeductionFailureInfo DeductionFailure
Template argument deduction info.
static void NoteAmbiguousUserConversions(Sema &S, SourceLocation OpLoc, OverloadCandidate *Cand)
Sema - This implements semantic analysis and AST building for C.
bool isPromotableIntegerType() const
More type predicates useful for type checking/promotion.
bool IsOverload(FunctionDecl *New, FunctionDecl *Old, bool IsForUsingDecl, bool ConsiderCudaAttrs=true, bool ConsiderRequiresClauses=true)
bool AllowRewrittenCandidates
Whether we should include rewritten candidates in the overload set.
CXXRecordDecl * getAsCXXRecordDecl() const
Retrieves the CXXRecordDecl that this type refers to, either because the type is a RecordType or beca...
Represents a prototype with parameter type info, e.g.
bool compatiblyIncludes(Qualifiers other) const
Determines if these qualifiers compatibly include another set.
OverloadedOperatorKind getOverloadedOperator() const
getOverloadedOperator - Which C++ overloaded operator this function represents, if any...
void erase(NamedDecl *D)
Removes any data associated with a given decl.
void AddMethodCandidate(DeclAccessPair FoundDecl, QualType ObjectType, Expr::Classification ObjectClassification, ArrayRef< Expr *> Args, OverloadCandidateSet &CandidateSet, bool SuppressUserConversion=false, OverloadCandidateParamOrder PO={})
AddMethodCandidate - Adds a named decl (which is some kind of method) as a method candidate to the gi...
Transparent Union Conversions.
bool isMoreQualifiedThan(QualType Other) const
Determine whether this type is more qualified than the other given type, requiring exact equality for...
bool isStdInitializerList(QualType Ty, QualType *Element)
Tests whether Ty is an instance of std::initializer_list and, if it is and Element is not NULL...
CastKind
CastKind - The kind of operation required for a conversion.
NestedNameSpecifier * getQualifier() const
If the member name was qualified, retrieves the nested-name-specifier that precedes the member name...
The return type of classify().
static ImplicitCastExpr * Create(const ASTContext &Context, QualType T, CastKind Kind, Expr *Operand, const CXXCastPath *BasePath, ExprValueKind Cat)
DeclarationNameTable DeclarationNames
Template argument deduction did not deduce a value for every template parameter.
static ExprResult CreateFunctionRefExpr(Sema &S, FunctionDecl *Fn, NamedDecl *FoundDecl, const Expr *Base, bool HadMultipleCandidates, SourceLocation Loc=SourceLocation(), const DeclarationNameLoc &LocInfo=DeclarationNameLoc())
A convenience routine for creating a decayed reference to a function.
bool CheckPointerConversion(Expr *From, QualType ToType, CastKind &Kind, CXXCastPath &BasePath, bool IgnoreBaseAccess, bool Diagnose=true)
CheckPointerConversion - Check the pointer conversion from the expression From to the type ToType...
virtual SemaDiagnosticBuilder diagnoseExplicitConv(Sema &S, SourceLocation Loc, QualType T, QualType ConvTy)=0
Emits a diagnostic when the only matching conversion function is explicit.
bool hasQualifiers() const
Determine whether this type has any qualifiers.
static const char * GetImplicitConversionName(ImplicitConversionKind Kind)
GetImplicitConversionName - Return the name of this kind of implicit conversion.
const FunctionType * getFunctionType(bool BlocksToo=true) const
Looks through the Decl's underlying type to extract a FunctionType when possible. ...
This conversion candidate was not considered because it duplicates the work of a trivial or derived-t...
CandidateSetKind getKind() const
static void NoteBuiltinOperatorCandidate(Sema &S, StringRef Opc, SourceLocation OpLoc, OverloadCandidate *Cand)
The result of a constraint satisfaction check, containing the necessary information to diagnose an un...
A narrowing conversion by virtue of the source and destination types.
StandardConversionSequence FinalConversion
FinalConversion - For a conversion function (where Function is a CXXConversionDecl), the standard conversion that occurs after the call to the overload candidate to convert the result of calling the conversion function to the required type.
unsigned Result
A Sema::TemplateDeductionResult.
llvm::APSInt EvaluateKnownConstInt(const ASTContext &Ctx, SmallVectorImpl< PartialDiagnosticAt > *Diag=nullptr) const
EvaluateKnownConstInt - Call EvaluateAsRValue and return the folded integer.
ImplicitConversionSequence TryImplicitConversion(Expr *From, QualType ToType, bool SuppressUserConversions, bool AllowExplicit, bool InOverloadResolution, bool CStyle, bool AllowObjCWritebackConversion)
bool isObjCWritebackConversion(QualType FromType, QualType ToType, QualType &ConvertedType)
Determine whether this is an Objective-C writeback conversion, used for parameter passing when perfor...
static SourceLocation GetLocationForCandidate(const OverloadCandidate *Cand)
An Objective-C property is a logical field of an Objective-C object which is read and written via Obj...
bool CanPerformAggregateInitializationForOverloadResolution(const InitializedEntity &Entity, InitListExpr *From)
Determine whether we can perform aggregate initialization for the purposes of overload resolution...
Allows QualTypes to be sorted and hence used in maps and sets.
TemplateParameterList * getTemplateParameters() const
Get the list of template parameters.
ObjC ARC writeback conversion.
A single parameter index whose accessors require each use to make explicit the parameter index encodi...
QualType getElementType() const
static CallExpr * Create(const ASTContext &Ctx, Expr *Fn, ArrayRef< Expr *> Args, QualType Ty, ExprValueKind VK, SourceLocation RParenLoc, unsigned MinNumArgs=0, ADLCallKind UsesADL=NotADL)
Create a call expression.
bool hasOnlyConst() const
static OverloadingResult IsInitializerListConstructorConversion(Sema &S, Expr *From, QualType ToType, CXXRecordDecl *To, UserDefinedConversionSequence &User, OverloadCandidateSet &CandidateSet, bool AllowExplicit)
Represents a shadow constructor declaration introduced into a class by a C++11 using-declaration that...
bool isMultiVersion() const
True if this function is considered a multiversioned function.
DeclAccessPair getFoundDecl() const
Retrieves the declaration found by lookup.
This represents one expression.
static ImplicitConversionSequence TryObjectArgumentInitialization(Sema &S, SourceLocation Loc, QualType FromType, Expr::Classification FromClassification, CXXMethodDecl *Method, CXXRecordDecl *ActingContext)
TryObjectArgumentInitialization - Try to initialize the object parameter of the given member function...
Show just the "best" overload candidates.
QualType getPointeeType() const
std::string getAsString(const ASTContext &Ctx, QualType Ty) const
Represents an ambiguous user-defined conversion sequence.
ExprValueKind
The categorization of expression values, currently following the C++11 scheme.
bool isVariadic() const
Whether this function is variadic.
bool isDefaulted() const
Whether this function is defaulted per C++0x.
Expr * stripARCUnbridgedCast(Expr *e)
stripARCUnbridgedCast - Given an expression of ARCUnbridgedCast type, remove the placeholder cast...
This candidate was not viable because it is a non-default multiversioned function.
bool isArrow() const
Determine whether this member expression used the '->' operator; otherwise, it used the '...
This inherited constructor is not viable because it would slice the argument.
Candidate is a rewritten candidate with a reversed order of parameters.
void takeSFINAEDiagnostic(PartialDiagnosticAt &PD)
Take ownership of the SFINAE diagnostic.
When performing template argument deduction for a function template, there were too many call argumen...
Declaration of a template type parameter.
static FindResult find(Expr *E)
Finds the overloaded expression in the given expression E of OverloadTy.
SourceLocation getLocation() const
StandardConversionSequence After
After - Represents the standard conversion that occurs after the actual user-defined conversion...
ExprResult BuildCallExpr(Scope *S, Expr *Fn, SourceLocation LParenLoc, MultiExprArg ArgExprs, SourceLocation RParenLoc, Expr *ExecConfig=nullptr, bool IsExecConfig=false)
BuildCallExpr - Handle a call to Fn with the specified array of arguments.
bool isObjCBuiltinType() const
const T * castAs() const
Member-template castAs<specific type>.
bool shouldAddReversed(OverloadedOperatorKind Op)
Determine whether we should consider looking for and adding reversed candidates for operator Op...
static bool isFirstArgumentCompatibleWithType(ASTContext &Context, CXXConstructorDecl *Constructor, QualType Type)
void setTypeDependent(bool TD)
Set whether this expression is type-dependent or not.
Represents a C++ destructor within a class.
void setInvalidDecl(bool Invalid=true)
setInvalidDecl - Indicates the Decl had a semantic error.
unsigned getNumInits() const
bool isImplicit() const
isImplicit - Indicates whether the declaration was implicitly generated by the implementation.
const TemplateArgumentList * getTemplateSpecializationArgs() const
Retrieve the template arguments used to produce this function template specialization from the primar...
bool isNullPtrType() const
void copyFrom(const AmbiguousConversionSequence &)
static bool IsStandardConversion(Sema &S, Expr *From, QualType ToType, bool InOverloadResolution, StandardConversionSequence &SCS, bool CStyle, bool AllowObjCWritebackConversion)
IsStandardConversion - Determines whether there is a standard conversion sequence (C++ [conv]...
NestedNameSpecifier * getQualifier() const
Retrieve the nested-name-specifier that qualifies the name of this declaration, if it was present in ...
static Qualifiers CollectVRQualifiers(ASTContext &Context, Expr *ArgExpr)
CollectVRQualifiers - This routine returns Volatile/Restrict qualifiers, if any, found in visible typ...
void AddMemberOperatorCandidates(OverloadedOperatorKind Op, SourceLocation OpLoc, ArrayRef< Expr *> Args, OverloadCandidateSet &CandidateSet, OverloadCandidateParamOrder PO={})
Add overload candidates for overloaded operators that are member functions.
bool performsVirtualDispatch(const LangOptions &LO) const
Returns true if virtual dispatch is performed.
ObjCLifetime getObjCLifetime() const
static ConstantExpr * Create(const ASTContext &Context, Expr *E, const APValue &Result)
CXXConstructorDecl * CopyConstructor
CopyConstructor - The copy constructor that is used to perform this conversion, when the conversion i...
bool isObjCClassType() const
static bool completeFunctionType(Sema &S, FunctionDecl *FD, SourceLocation Loc, bool Complain=true)
DeclContext * getDeclContext()
Overload resolution succeeded.
bool isObjCIdType() const
True if this is equivalent to the 'id' type, i.e.
bool isCPUDispatchMultiVersion() const
True if this function is a multiversioned dispatch function as a part of the cpu_specific/cpu_dispatc...
bool isAnyComplexType() const
static OverloadedOperatorKind getOverloadedOperator(Opcode Opc)
Retrieve the overloaded operator kind that corresponds to the given unary opcode. ...
static bool IsOverloaded(const UnresolvedSetImpl &Functions)
When performing template argument deduction for a function template, there were too few call argument...
static bool IsAcceptableNonMemberOperatorCandidate(ASTContext &Context, FunctionDecl *Fn, ArrayRef< Expr *> Args)
IsAcceptableNonMemberOperatorCandidate - Determine whether Fn is an acceptable non-member overloaded ...
llvm::PointerUnion< TemplateTypeParmDecl *, NonTypeTemplateParmDecl *, TemplateTemplateParmDecl * > TemplateParameter
Stores a template parameter of any kind.
unsigned ReferenceBinding
ReferenceBinding - True when this is a reference binding (C++ [over.ics.ref]).
static bool isNonDependentlyExplicit(FunctionTemplateDecl *FTD)
Determine whether a given function template has a simple explicit specifier or a non-value-dependent ...
ExprResult CheckPlaceholderExpr(Expr *E)
Check for operands with placeholder types and complain if found.
NonTypeTemplateParmDecl - Declares a non-type template parameter, e.g., "Size" in.
Represents a C++ template name within the type system.
Ref_Related - The two types are reference-related, which means that their unqualified forms (T1 and T...
const Expr * getExpr() const
void getAsStringInternal(std::string &Str, const PrintingPolicy &Policy) const
decls_iterator decls_begin() const
ReferenceCompareResult
ReferenceCompareResult - Expresses the result of comparing two types (cv1 T1 and cv2 T2) to determine...
virtual SemaDiagnosticBuilder diagnoseAmbiguous(Sema &S, SourceLocation Loc, QualType T)=0
Emits a diagnostic when there are multiple possible conversion functions.
Floating-integral conversions (C++ [conv.fpint])
The current expression and its subexpressions occur within an unevaluated operand (C++11 [expr]p7)...
DependentFunctionTemplateSpecializationInfo * getDependentSpecializationInfo() const
ExprResult BuildTemplateIdExpr(const CXXScopeSpec &SS, SourceLocation TemplateKWLoc, LookupResult &R, bool RequiresADL, const TemplateArgumentListInfo *TemplateArgs)
FunctionDecl * ResolveSingleFunctionTemplateSpecialization(OverloadExpr *ovl, bool Complain=false, DeclAccessPair *Found=nullptr)
Given an expression that refers to an overloaded function, try to resolve that overloaded function ex...
ExprResult BuildSynthesizedThreeWayComparison(SourceLocation OpLoc, const UnresolvedSetImpl &Fns, Expr *LHS, Expr *RHS, FunctionDecl *DefaultedFn)
bool isSameOrCompatibleFunctionType(CanQualType Param, CanQualType Arg)
Compare types for equality with respect to possibly compatible function types (noreturn adjustment...
CanQualType UnsignedInt128Ty
Specifies that a value-dependent expression of integral or dependent type should be considered a null...
bool isSignedIntegerType() const
Return true if this is an integer type that is signed, according to C99 6.2.5p4 [char, signed char, short, int, long..], or an enum decl which has a signed representation.
This conversion candidate was not considered because it is an illegal instantiation of a constructor ...
bool TryToFixBadConversion(unsigned Idx, Sema &S)
static void collectViableConversionCandidates(Sema &SemaRef, Expr *From, QualType ToType, UnresolvedSetImpl &ViableConversions, OverloadCandidateSet &CandidateSet)
CXXConversionDecl * Surrogate
Surrogate - The conversion function for which this candidate is a surrogate, but only if IsSurrogate ...
UserDefinedConversionSequence - Represents a user-defined conversion sequence (C++ 13...
This candidate was not viable because its address could not be taken.
void NoteDeductionFailure(Sema &S, bool ForTakingAddress)
Diagnose a template argument deduction failure.
static bool isBetterMultiversionCandidate(const OverloadCandidate &Cand1, const OverloadCandidate &Cand2)
StandardConversionSequence Standard
When ConversionKind == StandardConversion, provides the details of the standard conversion sequence...
bool ResolveAndFixSingleFunctionTemplateSpecialization(ExprResult &SrcExpr, bool DoFunctionPointerConverion=false, bool Complain=false, SourceRange OpRangeForComplaining=SourceRange(), QualType DestTypeForComplaining=QualType(), unsigned DiagIDForComplaining=0)
DeclContext * getParent()
getParent - Returns the containing DeclContext.
ExprResult BuildLiteralOperatorCall(LookupResult &R, DeclarationNameInfo &SuffixInfo, ArrayRef< Expr *> Args, SourceLocation LitEndLoc, TemplateArgumentListInfo *ExplicitTemplateArgs=nullptr)
BuildLiteralOperatorCall - Build a UserDefinedLiteral by creating a call to a literal operator descri...
static void DiagnoseOpenCLExtensionDisabled(Sema &S, OverloadCandidate *Cand)
void setAddressSpace(LangAS space)
For a defaulted function, the kind of defaulted function that it is.
void DiagnoseAmbiguousConversion(Sema &S, SourceLocation CaretLoc, const PartialDiagnostic &PDiag) const
Diagnoses an ambiguous conversion.
static const FunctionProtoType * tryGetFunctionProtoType(QualType FromType)
Attempts to get the FunctionProtoType from a Type.
QualType getRecordType(const RecordDecl *Decl) const
static QualType AdjustAddressSpaceForBuiltinOperandType(Sema &S, QualType T, Expr *Arg)
Helper function for adjusting address spaces for the pointer or reference operands of builtin operato...
bool isAtLeastAsQualifiedAs(CanQual< T > Other) const
Determines whether this canonical type is at least as qualified as the Other canonical type...
virtual SemaDiagnosticBuilder noteExplicitConv(Sema &S, CXXConversionDecl *Conv, QualType ConvTy)=0
Emits a note for the explicit conversion function.
QualType getFunctionTypeWithExceptionSpec(QualType Orig, const FunctionProtoType::ExceptionSpecInfo &ESI)
Get a function type and produce the equivalent function type with the specified exception specificati...
UnaryOperator - This represents the unary-expression's (except sizeof and alignof), the postinc/postdec operators from postfix-expression, and various extensions.
QualType getFunctionType(QualType ResultTy, ArrayRef< QualType > Args, const FunctionProtoType::ExtProtoInfo &EPI) const
Return a normal function type with a typed argument list.
bool DeduceReturnType(FunctionDecl *FD, SourceLocation Loc, bool Diagnose=true)
SourceLocation getMemberLoc() const
getMemberLoc - Return the location of the "member", in X->F, it is the location of 'F'...
ExprResult BuildPossibleImplicitMemberExpr(const CXXScopeSpec &SS, SourceLocation TemplateKWLoc, LookupResult &R, const TemplateArgumentListInfo *TemplateArgs, const Scope *S)
Builds an expression which might be an implicit member expression.
An lvalue reference type, per C++11 [dcl.ref].
TemplateTemplateParmDecl - Declares a template template parameter, e.g., "T" in.
unsigned getNumArgs() const
bool isAcceptableCandidate(const FunctionDecl *FD)
static bool CheckArityMismatch(Sema &S, OverloadCandidate *Cand, unsigned NumArgs)
Additional arity mismatch diagnosis specific to a function overload candidates.
const BuiltinType * getAsPlaceholderType() const
After substituting deduced template arguments, a dependent parameter type did not match the correspon...
Represents a C++ conversion function within a class.
QualType getTypeDeclType(const TypeDecl *Decl, const TypeDecl *PrevDecl=nullptr) const
Return the unique reference to the type for the specified type declaration.
bool isExplicit() const
Determine whether this specifier is known to correspond to an explicit declaration.
bool isNull() const
Return true if this QualType doesn't point to a type yet.
bool isVolatileQualified() const
OverloadsShown getShowOverloads() const
void exclude(Decl *F)
Exclude a function from being considered by overload resolution.
OverloadCandidateRewriteKind
The kinds of rewrite we perform on overload candidates.
FriendObjectKind getFriendObjectKind() const
Determines whether this declaration is the object of a friend declaration and, if so...
decl_type * getFirstDecl()
Return the first declaration of this declaration or itself if this is the only declaration.
SourceLocation getEndLoc() const LLVM_READONLY
unsigned getCVRQualifiers() const
Retrieve the set of CVR (const-volatile-restrict) qualifiers applied to this type.
ExprObjectKind getObjectKind() const
getObjectKind - The object kind that this expression produces.
static ImplicitConversionSequence::CompareKind CompareImplicitConversionSequences(Sema &S, SourceLocation Loc, const ImplicitConversionSequence &ICS1, const ImplicitConversionSequence &ICS2)
CompareImplicitConversionSequences - Compare two implicit conversion sequences to determine whether o...
A narrowing conversion, because a non-constant-expression variable might have got narrowed...
QualType getFromType() const
CanQualType getCanonicalTypeUnqualified() const
Lvalue-to-rvalue conversion (C++ [conv.lval])
bool isConstQualified() const
Determine whether this type is const-qualified.
NarrowingKind getNarrowingKind(ASTContext &Context, const Expr *Converted, APValue &ConstantValue, QualType &ConstantType, bool IgnoreFloatToIntegralConversion=false) const
Check if this standard conversion sequence represents a narrowing conversion, according to C++11 [dcl...
RecordDecl * getDecl() const
static bool isBetterReferenceBindingKind(const StandardConversionSequence &SCS1, const StandardConversionSequence &SCS2)
Determine whether one of the given reference bindings is better than the other based on what kind of ...
bool isExplicit() const
Return true if the declartion is already resolved to be explicit.
void EraseUnwantedCUDAMatches(const FunctionDecl *Caller, SmallVectorImpl< std::pair< DeclAccessPair, FunctionDecl *>> &Matches)
Finds a function in Matches with highest calling priority from Caller context and erases all function...
bool isTemplateDecl() const
returns true if this declaration is a template
void AddBuiltinOperatorCandidates(OverloadedOperatorKind Op, SourceLocation OpLoc, ArrayRef< Expr *> Args, OverloadCandidateSet &CandidateSet)
AddBuiltinOperatorCandidates - Add the appropriate built-in operator overloads to the candidate set (...
unsigned ObjCLifetimeConversionBinding
Whether this binds a reference to an object with a different Objective-C lifetime qualifier...
Expr * getTrailingRequiresClause()
Get the constraint-expression introduced by the trailing requires-clause in the function/member decla...
static bool isNullPointerConstantForConversion(Expr *Expr, bool InOverloadResolution, ASTContext &Context)
Decl::Kind getDeclKind() const
bool isComparison() const
OpaqueValueExpr - An expression referring to an opaque object of a fixed type and value class...
Integral conversions (C++ [conv.integral])
void AddBuiltinCandidate(QualType *ParamTys, ArrayRef< Expr *> Args, OverloadCandidateSet &CandidateSet, bool IsAssignmentOperator=false, unsigned NumContextualBoolArguments=0)
AddBuiltinCandidate - Add a candidate for a built-in operator.
SmallVectorImpl< OverloadCandidate >::iterator iterator
Complex promotions (Clang extension)
Assigning into this object requires the old value to be released and the new value to be retained...
A reference to an overloaded function set, either an UnresolvedLookupExpr or an UnresolvedMemberExpr...
CanProxy< U > castAs() const
ImplicitConversionSequence - Represents an implicit conversion sequence, which may be a standard conv...
OverloadedOperatorKind getRewrittenOverloadedOperator(OverloadedOperatorKind Kind)
Get the other overloaded operator that the given operator can be rewritten into, if any such operator...
QualType getCanonicalType() const
bool isPointerConversionToVoidPointer(ASTContext &Context) const
isPointerConversionToVoidPointer - Determines whether this conversion is a conversion of a pointer to...
ActionResult - This structure is used while parsing/acting on expressions, stmts, etc...
static bool checkAddressOfCandidateIsAvailable(Sema &S, const FunctionDecl *FD)
FunctionDecl * resolveAddressOfSingleOverloadCandidate(Expr *E, DeclAccessPair &FoundResult)
Given an expression that refers to an overloaded function, try to resolve that function to a single f...
OverloadCandidate - A single candidate in an overload set (C++ 13.3).
FunctionDecl * getAsFunction() LLVM_READONLY
Returns the function itself, or the templated function if this is a function template.
ASTContext & getASTContext() const
static bool DiagnoseTwoPhaseLookup(Sema &SemaRef, SourceLocation FnLoc, const CXXScopeSpec &SS, LookupResult &R, OverloadCandidateSet::CandidateSetKind CSK, TemplateArgumentListInfo *ExplicitTemplateArgs, ArrayRef< Expr *> Args, bool *DoDiagnoseEmptyLookup=nullptr)
Attempt to recover from an ill-formed use of a non-dependent name in a template, where the non-depend...
SourceLocation getNameLoc() const
Gets the location of the name.
const ExtParameterInfo * ExtParameterInfos
NullPointerConstantKind isNullPointerConstant(ASTContext &Ctx, NullPointerConstantValueDependence NPC) const
isNullPointerConstant - C99 6.3.2.3p3 - Test if this reduces down to a Null pointer constant...
FunctionDecl * getTemplatedDecl() const
Get the underlying function declaration of the template.
Encodes a location in the source.
C++ [over.match.ctor], [over.match.list] Initialization of an object of class type by constructor...
QualType getReturnType() const
A helper class that allows the use of isa/cast/dyncast to detect TagType objects of enums...
bool isIdentityConversion() const
void FindAssociatedClassesAndNamespaces(SourceLocation InstantiationLoc, ArrayRef< Expr *> Args, AssociatedNamespaceSet &AssociatedNamespaces, AssociatedClassSet &AssociatedClasses)
Find the associated classes and namespaces for argument-dependent lookup for a call with the given se...
LangAS getAddressSpace() const
Return the address space of this type.
llvm::mapped_iterator< decltype(Decls)::iterator, select_second > iterator
Interfaces are the core concept in Objective-C for object oriented design.
virtual SemaDiagnosticBuilder noteAmbiguous(Sema &S, CXXConversionDecl *Conv, QualType ConvTy)=0
Emits a note for one of the candidate conversions.
static bool Ret(InterpState &S, CodePtr &PC, APValue &Result)
static ImplicitConversionSequence::CompareKind CompareStandardConversionSequences(Sema &S, SourceLocation Loc, const StandardConversionSequence &SCS1, const StandardConversionSequence &SCS2)
CompareStandardConversionSequences - Compare two standard conversion sequences to determine whether o...
A call to a literal operator (C++11 [over.literal]) written as a user-defined literal (C++11 [lit...
Template argument deduction failed due to inconsistent cv-qualifiers on a template parameter type tha...
MutableArrayRef< Expr * > MultiExprArg
Represents a call to a member function that may be written either with member call syntax (e...
Requests that only tied-for-best candidates be shown.
const ComparisonCategoryInfo * lookupInfoForType(QualType Ty) const
A vector splat from an arithmetic type.
IncompatiblePointer - The assignment is between two pointers types that are not compatible, but we accept them as an extension.
Template argument deduction did not deduce a value for every expansion of an expanded template parame...
static Comparison compareEnableIfAttrs(const Sema &S, const FunctionDecl *Cand1, const FunctionDecl *Cand2)
Compares the enable_if attributes of two FunctionDecls, for the purposes of overload resolution...
OverloadingResult
OverloadingResult - Capture the result of performing overload resolution.
std::string getOpenCLExtensionsFromDeclExtMap(FunctionDecl *FD)
Check if a function declaration FD associates with any extensions present in OpenCLDeclExtMap and if ...
static ImplicitConversionSequence::CompareKind compareConversionFunctions(Sema &S, FunctionDecl *Function1, FunctionDecl *Function2)
Compare the user-defined conversion functions or constructors of two user-defined conversion sequence...
std::pair< SourceLocation, PartialDiagnostic > PartialDiagnosticAt
A partial diagnostic along with the source location where this diagnostic occurs. ...
bool isIntegralType(const ASTContext &Ctx) const
Determine whether this type is an integral type.
Represents a static or instance method of a struct/union/class.
static ExprWithCleanups * Create(const ASTContext &C, EmptyShell empty, unsigned numObjects)
static void DiagnoseBadConversion(Sema &S, OverloadCandidate *Cand, unsigned I, bool TakingCandidateAddress)
void AddConversionCandidate(CXXConversionDecl *Conversion, DeclAccessPair FoundDecl, CXXRecordDecl *ActingContext, Expr *From, QualType ToType, OverloadCandidateSet &CandidateSet, bool AllowObjCConversionOnExplicit, bool AllowExplicit, bool AllowResultConversion=true)
AddConversionCandidate - Add a C++ conversion function as a candidate in the candidate set (C++ [over...
ExprResult DefaultLvalueConversion(Expr *E)
Represents a C++ nested name specifier, such as "\::std::vector<int>::".
No ref-qualifier was provided.
Objective-C ARC writeback conversion.
bool DiagnoseMultipleUserDefinedConversion(Expr *From, QualType ToType)
const ParmVarDecl * getParamDecl(unsigned i) const
The declaration was invalid; do nothing.
bool CheckNonDependentConversions(FunctionTemplateDecl *FunctionTemplate, ArrayRef< QualType > ParamTypes, ArrayRef< Expr *> Args, OverloadCandidateSet &CandidateSet, ConversionSequenceList &Conversions, bool SuppressUserConversions, CXXRecordDecl *ActingContext=nullptr, QualType ObjectType=QualType(), Expr::Classification ObjectClassification={}, OverloadCandidateParamOrder PO={})
Check that implicit conversion sequences can be formed for each argument whose corresponding paramete...
OperatorRewriteInfo getRewriteInfo() const
static bool IsVectorConversion(Sema &S, QualType FromType, QualType ToType, ImplicitConversionKind &ICK)
Determine whether the conversion from FromType to ToType is a valid vector conversion.
const ArrayType * getAsArrayType(QualType T) const
Type Query functions.
unsigned pack_size() const
The number of template arguments in the given template argument pack.
Qualifiers getMethodQuals() const
bool isSignedIntegerOrEnumerationType() const
Determines whether this is an integer type that is signed or an enumeration types whose underlying ty...
static bool checkArgPlaceholdersForOverload(Sema &S, MultiExprArg Args, UnbridgedCastsSet &unbridged)
checkArgPlaceholdersForOverload - Check a set of call operands for placeholders.
Specifies that a value-dependent expression should be considered to never be a null pointer constant...
OverloadingResult BestViableFunction(Sema &S, SourceLocation Loc, OverloadCandidateSet::iterator &Best)
Find the best viable function on this overload set, if it exists.
bool isScoped() const
Returns true if this is a C++11 scoped enumeration.
void addDecl(NamedDecl *D)
TemplateDeductionResult DeduceTemplateArguments(ClassTemplatePartialSpecializationDecl *Partial, const TemplateArgumentList &TemplateArgs, sema::TemplateDeductionInfo &Info)
Perform template argument deduction to determine whether the given template arguments match the given...
llvm::Optional< unsigned > getCallArgIndex()
Return the index of the call argument that this deduction failure refers to, if any.
bool isValueDependent() const
isValueDependent - Determines whether this expression is value-dependent (C++ [temp.dep.constexpr]).
Qualifiers withoutObjCLifetime() const
bool isObjCObjectPointerType() const
bool isAnyPointerType() const
bool resolveAndFixAddressOfSingleOverloadCandidate(ExprResult &SrcExpr, bool DoFunctionPointerConversion=false)
Given an overloaded function, tries to turn it into a non-overloaded function reference using resolve...
bool CheckMemberPointerConversion(Expr *From, QualType ToType, CastKind &Kind, CXXCastPath &BasePath, bool IgnoreBaseAccess)
CheckMemberPointerConversion - Check the member pointer conversion from the expression From to the ty...
void setAsIdentityConversion()
StandardConversionSequence - Set the standard conversion sequence to the identity conversion...
Pointer conversions (C++ [conv.ptr])
C++ [over.match.oper]: Lookup of operator function candidates in a call using operator syntax...
ImplicitCastExpr - Allows us to explicitly represent implicit type conversions, which have no direct ...
bool canBindObjCObjectType(QualType To, QualType From)
void AddNonMemberOperatorCandidates(const UnresolvedSetImpl &Functions, ArrayRef< Expr *> Args, OverloadCandidateSet &CandidateSet, TemplateArgumentListInfo *ExplicitTemplateArgs=nullptr)
Add all of the non-member operator function declarations in the given function set to the overload ca...
bool hasUninstantiatedDefaultArg() const
Requests that all candidates be shown.
bool DiagnoseUseOfDecl(NamedDecl *D, ArrayRef< SourceLocation > Locs, const ObjCInterfaceDecl *UnknownObjCClass=nullptr, bool ObjCPropertyAccess=false, bool AvoidPartialAvailabilityChecks=false, ObjCInterfaceDecl *ClassReciever=nullptr)
Determine whether the use of this declaration is valid, and emit any corresponding diagnostics...
TypeClass getTypeClass() const
unsigned getMinRequiredArguments() const
Returns the minimum number of arguments needed to call this function.
unsigned HasDiagnostic
Indicates whether a diagnostic is stored in Diagnostic.
bool isAnyCharacterType() const
Determine whether this type is any of the built-in character types.
static ExplicitSpecifier getFromDecl(FunctionDecl *Function)
bool IsBuildingRecoveryCallExpr
Flag indicating if Sema is building a recovery call expression.
EnumDecl * getDecl() const
virtual bool match(QualType T)=0
Determine whether the specified type is a valid destination type for this conversion.
Derived-to-base (C++ [over.best.ics])
DeductionFailureInfo MakeDeductionFailureInfo(ASTContext &Context, Sema::TemplateDeductionResult TDK, sema::TemplateDeductionInfo &Info)
Convert from Sema's representation of template deduction information to the form used in overload-can...
bool isVectorType() const
static void DiagnoseBadDeduction(Sema &S, NamedDecl *Found, Decl *Templated, DeductionFailureInfo &DeductionFailure, unsigned NumArgs, bool TakingCandidateAddress)
Diagnose a failed template-argument deduction.
Complex-real conversions (C99 6.3.1.7)
This constructor/conversion candidate fail due to an address space mismatch between the object being ...
An rvalue ref-qualifier was provided (&&).
Assigning into this object requires a lifetime extension.
OverloadCandidateSet - A set of overload candidates, used in C++ overload resolution (C++ 13...
void setBad(BadConversionSequence::FailureKind Failure, Expr *FromExpr, QualType ToType)
Sets this sequence as a bad conversion for an explicit argument.
ExprResult BuildCallToObjectOfClassType(Scope *S, Expr *Object, SourceLocation LParenLoc, MultiExprArg Args, SourceLocation RParenLoc)
BuildCallToObjectOfClassType - Build a call to an object of class type (C++ [over.call.object]), which can end up invoking an overloaded function call operator (operator()) or performing a user-defined conversion on the object argument.
bool hasSameUnqualifiedType(QualType T1, QualType T2) const
Determine whether the given types are equivalent after cvr-qualifiers have been removed.
std::string getAsString() const
bool isInstantiationDependentType() const
Determine whether this type is an instantiation-dependent type, meaning that the type involves a temp...
SourceLocation getExprLoc() const LLVM_READONLY
getExprLoc - Return the preferred location for the arrow when diagnosing a problem with a generic exp...
QualType getArrayDecayedType(QualType T) const
Return the properly qualified result of decaying the specified array type to a pointer.
unsigned getNumParams() const
const llvm::fltSemantics & getFloatTypeSemantics(QualType T) const
Return the APFloat 'semantics' for the specified scalar floating point type.
CanProxy< U > getAs() const
Retrieve a canonical type pointer with a different static type, upcasting or downcasting as needed...
FunctionTemplateDecl * getMoreSpecializedTemplate(FunctionTemplateDecl *FT1, FunctionTemplateDecl *FT2, SourceLocation Loc, TemplatePartialOrderingContext TPOC, unsigned NumCallArguments1, unsigned NumCallArguments2)
Returns the more specialized function template according to the rules of function template partial or...
bool isPointerConversionToBool() const
isPointerConversionToBool - Determines whether this conversion is a conversion of a pointer or pointe...
CompoundAssignOperator - For compound assignments (e.g.
SourceLocation getLocation() const
A POD class for pairing a NamedDecl* with an access specifier.
DeclarationNameLoc - Additional source/type location info for a declaration name. ...
ExprResult BuildOverloadedArrowExpr(Scope *S, Expr *Base, SourceLocation OpLoc, bool *NoArrowOperatorFound=nullptr)
BuildOverloadedArrowExpr - Build a call to an overloaded operator-> (if one exists), where Base is an expression of class type and Member is the name of the member we're trying to find.
ExprResult BuildCXXMemberCallExpr(Expr *Exp, NamedDecl *FoundDecl, CXXConversionDecl *Method, bool HadMultipleCandidates)
StringRef getName() const
Return the actual identifier string.
ImplicitConversionRank GetConversionRank(ImplicitConversionKind Kind)
GetConversionRank - Retrieve the implicit conversion rank corresponding to the given implicit convers...
A class for storing results from argument-dependent lookup.
CanQualType UnsignedShortTy
SourceLocation getBeginLoc() const LLVM_READONLY
const TemplateArgument * getFirstArg()
Return the first template argument this deduction failure refers to, if any.
Represents a template argument.
ExprResult PerformCopyInitialization(const InitializedEntity &Entity, SourceLocation EqualLoc, ExprResult Init, bool TopLevelOfInitList=false, bool AllowExplicit=false)
DeclContextLookupResult LookupConstructors(CXXRecordDecl *Class)
Look up the constructors for the given class.
DeclAccessPair FoundCopyConstructor
static ExprResult diagnoseAmbiguousConversion(Sema &SemaRef, SourceLocation Loc, Expr *From, Sema::ContextualImplicitConverter &Converter, QualType T, UnresolvedSetImpl &ViableConversions)
Abstract base class used to perform a contextual implicit conversion from an expression to any type p...
Dataflow Directional Tag Classes.
int getFloatingTypeOrder(QualType LHS, QualType RHS) const
Compare the rank of the two specified floating point types, ignoring the domain of the type (i...
bool isValid() const
Return true if this is a valid SourceLocation object.
SourceLocation getBeginLoc() const LLVM_READONLY
ExtInfo getExtInfo() const
A qualifier set is used to build a set of qualifiers.
DeclContext - This is used only as base class of specific decl types that can act as declaration cont...
EvalResult is a struct with detailed info about an evaluated expression.
static ImplicitConversionSequence TryImplicitConversion(Sema &S, Expr *From, QualType ToType, bool SuppressUserConversions, bool AllowExplicit, bool InOverloadResolution, bool CStyle, bool AllowObjCWritebackConversion, bool AllowObjCConversionOnExplicit)
TryImplicitConversion - Attempt to perform an implicit conversion from the given expression (Expr) to...
The base class of all kinds of template declarations (e.g., class, function, etc.).
static std::string getName(const CallEvent &Call)
bool IsFloatingPointPromotion(QualType FromType, QualType ToType)
IsFloatingPointPromotion - Determines whether the conversion from FromType to ToType is a floating po...
OverloadedOperatorKind
Enumeration specifying the different kinds of C++ overloaded operators.
ExprResult ImpCastExprToType(Expr *E, QualType Type, CastKind CK, ExprValueKind VK=VK_RValue, const CXXCastPath *BasePath=nullptr, CheckedConversionKind CCK=CCK_ImplicitConversion)
ImpCastExprToType - If Expr is not of type 'Type', insert an implicit cast.
QualType getRestrictType(QualType T) const
Return the uniqued reference to the type for a restrict qualified type.
void AddSurrogateCandidate(CXXConversionDecl *Conversion, DeclAccessPair FoundDecl, CXXRecordDecl *ActingContext, const FunctionProtoType *Proto, Expr *Object, ArrayRef< Expr *> Args, OverloadCandidateSet &CandidateSet)
AddSurrogateCandidate - Adds a "surrogate" candidate function that converts the given Object to a fun...
bool isObjCClassType() const
True if this is equivalent to the 'Class' type, i.e.
virtual SemaDiagnosticBuilder diagnoseNoMatch(Sema &S, SourceLocation Loc, QualType T)=0
Emits a diagnostic complaining that the expression does not have integral or enumeration type...
Qualifiers getMethodQualifiers() const
void HandleFunctionTypeMismatch(PartialDiagnostic &PDiag, QualType FromType, QualType ToType)
HandleFunctionTypeMismatch - Gives diagnostic information for differeing function types...
bool IsAllowedCUDACall(const FunctionDecl *Caller, const FunctionDecl *Callee)
Determines whether Caller may invoke Callee, based on their CUDA host/device attributes.
static void NoteFunctionCandidate(Sema &S, OverloadCandidate *Cand, unsigned NumArgs, bool TakingCandidateAddress, LangAS CtorDestAS=LangAS::Default)
Generates a 'note' diagnostic for an overload candidate.
CanQualType UnsignedLongLongTy
static bool checkPlaceholderForOverload(Sema &S, Expr *&E, UnbridgedCastsSet *unbridgedCasts=nullptr)
checkPlaceholderForOverload - Do any interesting placeholder-like preprocessing on the given expressi...
Conversions allowed in C, but not C++.
static GenericSelectionExpr * Create(const ASTContext &Context, SourceLocation GenericLoc, Expr *ControllingExpr, ArrayRef< TypeSourceInfo *> AssocTypes, ArrayRef< Expr *> AssocExprs, SourceLocation DefaultLoc, SourceLocation RParenLoc, bool ContainsUnexpandedParameterPack, unsigned ResultIndex)
Create a non-result-dependent generic selection expression.
Array-to-pointer conversion (C++ [conv.array])
void setConversionChecker(TypeComparisonFuncTy Foo)
Resets the default conversion checker method.
A non-depnedent component of the parameter did not match the corresponding component of the argument...
PartialDiagnosticAt * getSFINAEDiagnostic()
Retrieve the diagnostic which caused this deduction failure, if any.
FunctionDecl * getTemplateInstantiationPattern() const
Retrieve the function declaration from which this function could be instantiated, if it is an instant...
The name of a declaration.
static std::string getAsString(SplitQualType split, const PrintingPolicy &Policy)
StandardConversionSequence Before
Represents the standard conversion that occurs before the actual user-defined conversion.
bool IsBlockPointerConversion(QualType FromType, QualType ToType, QualType &ConvertedType)
const CXXRecordDecl * getParent() const
Return the parent of this method declaration, which is the class in which this method is defined...
bool isBooleanType() const
const Type * strip(QualType type)
Collect any qualifiers on the given type and return an unqualified type.
bool isSpecializationCopyingObject() const
Determine whether this is a member template specialization that would copy the object to itself...
bool isMoveConstructor(unsigned &TypeQuals) const
Determine whether this constructor is a move constructor (C++11 [class.copy]p3), which can be used to...
OverloadExpr * Expression
void AddArgumentDependentLookupCandidates(DeclarationName Name, SourceLocation Loc, ArrayRef< Expr *> Args, TemplateArgumentListInfo *ExplicitTemplateArgs, OverloadCandidateSet &CandidateSet, bool PartialOverloading=false)
Add function candidates found via argument-dependent lookup to the set of overloading candidates...
static QualType AdoptQualifiers(ASTContext &Context, QualType T, Qualifiers Qs)
Adopt the given qualifiers for the given type.
Expression is a Null pointer constant built from a zero integer expression that is not a simple...
bool isMSVCRTEntryPoint() const
Determines whether this function is a MSVCRT user defined entry point.
A set of unresolved declarations.
static PseudoObjectExpr * Create(const ASTContext &Context, Expr *syntactic, ArrayRef< Expr *> semantic, unsigned resultIndex)
void setInstantiationDependent(bool ID)
Set whether this expression is instantiation-dependent or not.
Requests that only viable candidates be shown.
FunctionDecl * Function
Function - The actual function that this candidate represents.
bool IsMemberPointerConversion(Expr *From, QualType FromType, QualType ToType, bool InOverloadResolution, QualType &ConvertedType)
IsMemberPointerConversion - Determines whether the conversion of the expression From, which has the (possibly adjusted) type FromType, can be converted to the type ToType via a member pointer conversion (C++ 4.11).
A pointer to member type per C++ 8.3.3 - Pointers to members.
static void dropPointerConversion(StandardConversionSequence &SCS)
dropPointerConversions - If the given standard conversion sequence involves any pointer conversions...
QualType getCallResultType(const ASTContext &Context) const
Determine the type of an expression that calls a function of this type.
bool isIntegerConstantExpr(llvm::APSInt &Result, const ASTContext &Ctx, SourceLocation *Loc=nullptr, bool isEvaluated=true) const
isIntegerConstantExpr - Return true if this expression is a valid integer constant expression...
const FunctionType * adjustFunctionType(const FunctionType *Fn, FunctionType::ExtInfo EInfo)
Change the ExtInfo on a function type.
TemplateSpecCandidate & addCandidate()
Add a new candidate with NumConversions conversion sequence slots to the overload set...
Optional< sema::TemplateDeductionInfo * > isSFINAEContext() const
Determines whether we are currently in a context where template argument substitution failures are no...
bool isAggregateType() const
Determines whether the type is a C++ aggregate type or C aggregate or union type. ...
static void CompleteNonViableCandidate(Sema &S, OverloadCandidate *Cand, ArrayRef< Expr *> Args, OverloadCandidateSet::CandidateSetKind CSK)
CompleteNonViableCandidate - Normally, overload resolution only computes up to the first bad conversi...
DeclarationNameInfo - A collector data type for bundling together a DeclarationName and the correspnd...
QualType apply(const ASTContext &Context, QualType QT) const
Apply the collected qualifiers to the given type.
void dump() const
dump - Print this user-defined conversion sequence to standard error.
void * Data
Opaque pointer containing additional data about this deduction failure.
bool isSpecialMember() const
bool isUndeducedType() const
Determine whether this type is an undeduced type, meaning that it somehow involves a C++11 'auto' typ...
void AddFunctionCandidates(const UnresolvedSetImpl &Functions, ArrayRef< Expr *> Args, OverloadCandidateSet &CandidateSet, TemplateArgumentListInfo *ExplicitTemplateArgs=nullptr, bool SuppressUserConversions=false, bool PartialOverloading=false, bool FirstArgumentIsBase=false)
Add all of the function declarations in the given function set to the overload candidate set...
param_iterator param_end()
static void NoteSurrogateCandidate(Sema &S, OverloadCandidate *Cand)
bool hasSFINAEDiagnostic() const
Is a SFINAE diagnostic available?
FunctionDecl * ConversionFunction
ConversionFunction - The function that will perform the user-defined conversion.
Represents a pointer to an Objective C object.
Conversion only allowed in the C standard (e.g. void* to char*).
unsigned getIntWidth(QualType T) const
Not an overloaded operator.
const UnresolvedSetImpl & asUnresolvedSet() const
ExprResult CreateOverloadedArraySubscriptExpr(SourceLocation LLoc, SourceLocation RLoc, Expr *Base, Expr *Idx)
bool IsPointerConversion(Expr *From, QualType FromType, QualType ToType, bool InOverloadResolution, QualType &ConvertedType, bool &IncompatibleObjC)
IsPointerConversion - Determines whether the conversion of the expression From, which has the (possib...
A helper class that allows the use of isa/cast/dyncast to detect TagType objects of structs/unions/cl...
void setAllToTypes(QualType T)
Complex values, per C99 6.2.5p11.
Candidate is a rewritten candidate with a different operator name.
unsigned getKindRank() const
Return a ranking of the implicit conversion sequence kind, where smaller ranks represent better conve...
Expr * getUninstantiatedDefaultArg()
void NoteOverloadCandidate(NamedDecl *Found, FunctionDecl *Fn, OverloadCandidateRewriteKind RewriteKind=OverloadCandidateRewriteKind(), QualType DestType=QualType(), bool TakingAddress=false)
ObjCInterfaceDecl * getInterfaceDecl() const
If this pointer points to an Objective @interface type, gets the declaration for that interface...
CUDAFunctionPreference IdentifyCUDAPreference(const FunctionDecl *Caller, const FunctionDecl *Callee)
Identifies relative preference of a given Caller/Callee combination, based on their host/device attri...
bool isIntegerType() const
isIntegerType() does not include complex integers (a GCC extension).
TemplateArgumentList * take()
Take ownership of the deduced template argument list.
CanQualType UnsignedLongTy
This candidate was not viable because its OpenCL extension is disabled.
bool areCompatibleVectorTypes(QualType FirstVec, QualType SecondVec)
Return true if the given vector types are of the same unqualified type or if they are equivalent to t...
const char * getOperatorSpelling(OverloadedOperatorKind Operator)
Retrieve the spelling of the given overloaded operator, without the preceding "operator" keyword...
unsigned BindsImplicitObjectArgumentWithoutRefQualifier
Whether this binds an implicit object argument to a non-static member function without a ref-qualifie...
unsigned char FailureKind
FailureKind - The reason why this candidate is not viable.
static bool FindConversionForRefInit(Sema &S, ImplicitConversionSequence &ICS, QualType DeclType, SourceLocation DeclLoc, Expr *Init, QualType T2, bool AllowRvalues, bool AllowExplicit)
Look for a user-defined conversion to a value reference-compatible with DeclType. ...
bool isFunctionType() const
bool isObjCQualifiedIdType() const
DeclAccessPair FoundDecl
FoundDecl - The original declaration that was looked up / invented / otherwise found, together with its access.
Base for LValueReferenceType and RValueReferenceType.
CanQualType BoundMemberTy
bool hasSameType(QualType T1, QualType T2) const
Determine whether the given types T1 and T2 are equivalent.
The deduced arguments did not satisfy the constraints associated with the template.
AccessResult CheckMemberOperatorAccess(SourceLocation Loc, Expr *ObjectExpr, Expr *ArgExpr, DeclAccessPair FoundDecl)
Checks access to an overloaded member operator, including conversion operators.
void AddTemplateOverloadCandidate(FunctionTemplateDecl *FunctionTemplate, DeclAccessPair FoundDecl, TemplateArgumentListInfo *ExplicitTemplateArgs, ArrayRef< Expr *> Args, OverloadCandidateSet &CandidateSet, bool SuppressUserConversions=false, bool PartialOverloading=false, bool AllowExplicit=true, ADLCallKind IsADLCandidate=ADLCallKind::NotADL, OverloadCandidateParamOrder PO={})
Add a C++ function template specialization as a candidate in the candidate set, using template argume...
TemplateSpecCandidate - This is a generalization of OverloadCandidate which keeps track of template a...
Block Pointer conversions.
Deduction failed; that's all we know.
virtual bool hasFloat128Type() const
Determine whether the __float128 type is supported on this target.
static FixItHint CreateInsertion(SourceLocation InsertionLoc, StringRef Code, bool BeforePreviousInsertions=false)
Create a code modification hint that inserts the given code string at a specific location.
bool canAssignObjCInterfaces(const ObjCObjectPointerType *LHSOPT, const ObjCObjectPointerType *RHSOPT)
canAssignObjCInterfaces - Return true if the two interface types are compatible for assignment from R...
Implements a partial diagnostic that can be emitted anwyhere in a DiagnosticBuilder stream...
Sema::LookupNameKind getLookupKind() const
Gets the kind of lookup to perform.
The template argument is actually a parameter pack.
QualType getNonLValueExprType(const ASTContext &Context) const
Determine the type of a (typically non-lvalue) expression with the specified result type...
static ExprResult BuildRecoveryCallExpr(Sema &SemaRef, Scope *S, Expr *Fn, UnresolvedLookupExpr *ULE, SourceLocation LParenLoc, MutableArrayRef< Expr *> Args, SourceLocation RParenLoc, bool EmptyLookup, bool AllowTypoCorrection)
Attempts to recover from a call where no functions were found.
APValue - This class implements a discriminated union of [uninitialized] [APSInt] [APFloat]...
virtual bool hasInt128Type() const
Determine whether the __int128 type is supported on this target.
static bool tryAtomicConversion(Sema &S, Expr *From, QualType ToType, bool InOverloadResolution, StandardConversionSequence &SCS, bool CStyle)
bool isInitListConstructor(const FunctionDecl *Ctor)
Determine whether Ctor is an initializer-list constructor, as defined in [dcl.init.list]p2.
static bool isNonTrivialObjCLifetimeConversion(Qualifiers FromQuals, Qualifiers ToQuals)
Determine whether the lifetime conversion between the two given qualifiers sets is nontrivial...
void NoteCandidates(PartialDiagnosticAt PA, Sema &S, OverloadCandidateDisplayKind OCD, ArrayRef< Expr *> Args, StringRef Opc="", SourceLocation Loc=SourceLocation(), llvm::function_ref< bool(OverloadCandidate &)> Filter=[](OverloadCandidate &) { return true;})
When overload resolution fails, prints diagnostic messages containing the candidates in the candidate...
bool isObjectType() const
Determine whether this type is an object type.
uint64_t getTypeSize(QualType T) const
Return the size of the specified (complete) type T, in bits.
Condition in a constexpr if statement.
bool isIncompleteType(NamedDecl **Def=nullptr) const
Types are partitioned into 3 broad categories (C99 6.2.5p1): object types, function types...
bool hasObjCGCAttr() const
bool checkAddressOfFunctionIsAvailable(const FunctionDecl *Function, bool Complain=false, SourceLocation Loc=SourceLocation())
Returns whether the given function's address can be taken or not, optionally emitting a diagnostic if...
bool LookupQualifiedName(LookupResult &R, DeclContext *LookupCtx, bool InUnqualifiedLookup=false)
Perform qualified name lookup into a given context.
TemplateArgumentList * getTemplateArgumentList()
Retrieve the template argument list associated with this deduction failure, if any.
ConversionFixItGenerator Fix
The FixIt hints which can be used to fix the Bad candidate.
llvm::iterator_range< specific_attr_iterator< T > > specific_attrs() const
CanQualType getCanonicalType(QualType T) const
Return the canonical (structural) type corresponding to the specified potentially non-canonical type ...
bool CheckFunctionConstraints(const FunctionDecl *FD, ConstraintSatisfaction &Satisfaction, SourceLocation UsageLoc=SourceLocation())
Check whether the given function decl's trailing requires clause is satisfied, if any...
AmbiguousConversionSequence Ambiguous
When ConversionKind == AmbiguousConversion, provides the details of the ambiguous conversion...
void setHadMultipleCandidates(bool V=true)
Sets the flag telling whether this expression refers to a function that was resolved from an overload...
A template argument list.
bool isLValueReferenceType() const
void addConversion(NamedDecl *Found, FunctionDecl *D)
SourceLocation getCXXLiteralOperatorNameLoc() const
getCXXLiteralOperatorNameLoc - Returns the location of the literal operator name (not the operator ke...
X
Add a minimal nested name specifier fixit hint to allow lookup of a tag name from an outer enclosing ...
Reading or writing from this object requires a barrier call.
bool hasSimilarType(QualType T1, QualType T2)
Determine if two types are similar, according to the C++ rules.
ArgKind getKind() const
Return the kind of stored template argument.
CCEKind
Contexts in which a converted constant expression is required.
static void BuildBasePathArray(const CXXBasePath &Path, CXXCastPath &BasePathArray)
static CXXMemberCallExpr * Create(const ASTContext &Ctx, Expr *Fn, ArrayRef< Expr *> Args, QualType Ty, ExprValueKind VK, SourceLocation RP, unsigned MinNumArgs=0)
QualType getParamType(unsigned i) const
SmallVector< OverloadCandidate *, 32 > CompleteCandidates(Sema &S, OverloadCandidateDisplayKind OCD, ArrayRef< Expr *> Args, SourceLocation OpLoc=SourceLocation(), llvm::function_ref< bool(OverloadCandidate &)> Filter=[](OverloadCandidate &) { return true;})
bool typesAreCompatible(QualType T1, QualType T2, bool CompareUnqualified=false)
Compatibility predicates used to check assignment expressions.
bool FunctionParamTypesAreEqual(const FunctionProtoType *OldType, const FunctionProtoType *NewType, unsigned *ArgPos=nullptr)
FunctionParamTypesAreEqual - This routine checks two function proto types for equality of their argum...
Function-to-pointer (C++ [conv.array])
MemberExpr - [C99 6.5.2.3] Structure and Union Members.
QualType getToType() const
ActionResult< Expr * > ExprResult
QualType getUnqualifiedType() const
Retrieve the unqualified variant of the given type, removing as little sugar as possible.
bool hasUnaligned() const
bool mergeExtParameterInfo(const FunctionProtoType *FirstFnType, const FunctionProtoType *SecondFnType, bool &CanUseFirst, bool &CanUseSecond, SmallVectorImpl< FunctionProtoType::ExtParameterInfo > &NewParamInfos)
This function merges the ExtParameterInfo lists of two functions.
Represents a C++ struct/union/class.
static ImplicitConversionSequence TryReferenceInit(Sema &S, Expr *Init, QualType DeclType, SourceLocation DeclLoc, bool SuppressUserConversions, bool AllowExplicit)
Compute an implicit conversion sequence for reference initialization.
Compatible - the types are compatible according to the standard.
QualType getRValueReferenceType(QualType T) const
Return the uniqued reference to the type for an rvalue reference to the specified type...
The template argument is a template name that was provided for a template template parameter...
void addAllDecls(const LookupResult &Other)
Add all the declarations from another set of lookup results.
OverloadsShown
Specifies which overload candidates to display when overload resolution fails.
bool isStrong() const
True iff the comparison is "strong".
Qualifiers getQualifiers() const
Retrieve the set of qualifiers applied to this type.
This candidate constructor or conversion function is explicit but the context doesn't permit explicit...
bool isLaxVectorConversion(QualType srcType, QualType destType)
Is this a legal conversion between two types, one of which is known to be a vector type...
AccessResult CheckUnresolvedLookupAccess(UnresolvedLookupExpr *E, DeclAccessPair FoundDecl)
void AddOverloadCandidate(FunctionDecl *Function, DeclAccessPair FoundDecl, ArrayRef< Expr *> Args, OverloadCandidateSet &CandidateSet, bool SuppressUserConversions=false, bool PartialOverloading=false, bool AllowExplicit=true, bool AllowExplicitConversion=false, ADLCallKind IsADLCandidate=ADLCallKind::NotADL, ConversionSequenceList EarlyConversions=None, OverloadCandidateParamOrder PO={})
AddOverloadCandidate - Adds the given function to the set of candidate functions, using the given fun...
DeclContext * CurContext
CurContext - This is the current declaration context of parsing.
TemplateArgument SecondArg
The second template argument to which the template argument deduction failure refers.
Partial ordering of function templates for a function call.
static bool isAddressSpaceSupersetOf(LangAS A, LangAS B)
Returns true if address space A is equal to or a superset of B.
QualType getPointerType(QualType T) const
Return the uniqued reference to the type for a pointer to the specified type.
static FixItHint CreateReplacement(CharSourceRange RemoveRange, StringRef Code)
Create a code modification hint that replaces the given source range with the given code string...
This class is used for builtin types like 'int'.
bool DiagnoseEmptyLookup(Scope *S, CXXScopeSpec &SS, LookupResult &R, CorrectionCandidateCallback &CCC, TemplateArgumentListInfo *ExplicitTemplateArgs=nullptr, ArrayRef< Expr *> Args=None, TypoExpr **Out=nullptr)
Diagnose an empty lookup.
static void AddBuiltinAssignmentOperatorCandidates(Sema &S, QualType T, ArrayRef< Expr *> Args, OverloadCandidateSet &CandidateSet)
Helper function for AddBuiltinOperatorCandidates() that adds the volatile- and non-volatile-qualified...
After substituting deduced template arguments, an element of a dependent parameter type did not match...
We are rewriting a comparison operator in terms of an operator<=>.
SourceRange getSourceRange() const LLVM_READONLY
SourceLocation tokens are not useful in isolation - they are low level value objects created/interpre...
static void DiagnoseBadTarget(Sema &S, OverloadCandidate *Cand)
CUDA: diagnose an invalid call across targets.
__DEVICE__ int min(int __a, int __b)
A little helper class (which is basically a smart pointer that forwards info from DiagnosticsEngine) ...
static bool canBeDeclaredInNamespace(const DeclarationName &Name)
Determine whether a declaration with the specified name could be moved into a different namespace...
Defines the clang::TargetInfo interface.
CallExpr - Represents a function call (C99 6.5.2.2, C++ [expr.call]).
bool isMicrosoft() const
Is this ABI an MSVC-compatible ABI?
ImplicitConversionRank getRank() const
getRank - Retrieve the rank of this standard conversion sequence (C++ 13.3.3.1.1p3).
SourceRange getSourceRange() const override LLVM_READONLY
Source range that this declaration covers.
QualType getIntegerType() const
Return the integer type this enum decl corresponds to.
StringRef getName() const
Get the name of identifier for this declaration as a StringRef.
unsigned getCVRQualifiers() const
std::string getQualifiedNameAsString() const
ExprResult CheckConvertedConstantExpression(Expr *From, QualType T, llvm::APSInt &Value, CCEKind CCE)
bool IsQualificationConversion(QualType FromType, QualType ToType, bool CStyle, bool &ObjCLifetimeConversion)
IsQualificationConversion - Determines whether the conversion from an rvalue of type FromType to ToTy...
bool isDependentType() const
Whether this type is a dependent type, meaning that its definition somehow depends on a template para...
QualType getAsType() const
Retrieve the type for a type template argument.
A rewritten comparison expression that was originally written using operator syntax.
SourceLocation getBeginLoc() const LLVM_READONLY
A reference to a declared variable, function, enum, etc.
Represents a type template specialization; the template must be a class template, a type alias templa...
void AddTemplateConversionCandidate(FunctionTemplateDecl *FunctionTemplate, DeclAccessPair FoundDecl, CXXRecordDecl *ActingContext, Expr *From, QualType ToType, OverloadCandidateSet &CandidateSet, bool AllowObjCConversionOnExplicit, bool AllowExplicit, bool AllowResultConversion=true)
Adds a conversion function template specialization candidate to the overload set, using template argu...
bool isDeleted() const
Whether this function has been deleted.
NestedNameSpecifierLoc getQualifierLoc() const
Fetches the nested-name qualifier with source-location information, if one was given.
bool isPointerType() const
static FixedEnumPromotion getFixedEnumPromtion(Sema &S, const StandardConversionSequence &SCS)
Returns kind of fixed enum promotion the SCS uses.
Zero constant to event (OpenCL1.2 6.12.10)
unsigned CallArgIndex
The index of the function argument that caused a deduction failure.
unsigned RewriteKind
Whether this is a rewritten candidate, and if so, of what kind?
SourceManager & SourceMgr
static OverloadedOperatorKind getOverloadedOperator(Opcode Opc)
Retrieve the overloaded operator kind that corresponds to the given binary opcode.
void NoteAllOverloadCandidates(Expr *E, QualType DestType=QualType(), bool TakingAddress=false)
BasePaths - Represents the set of paths from a derived class to one of its (direct or indirect) bases...
ImplicitConversionKind First
First – The first conversion can be an lvalue-to-rvalue conversion, array-to-pointer conversion...
No viable function found.
void NoteCandidates(Sema &S, SourceLocation Loc)
NoteCandidates - When no template specialization match is found, prints diagnostic messages containin...
TemplateArgument FirstArg
The first template argument to which the template argument deduction failure refers.
DeductionFailureInfo DeductionFailure
void suppressDiagnostics()
Suppress the diagnostics that would normally fire because of this lookup.
static bool recordConversion(Sema &SemaRef, SourceLocation Loc, Expr *&From, Sema::ContextualImplicitConverter &Converter, QualType T, bool HadMultipleCandidates, DeclAccessPair &Found)
bool empty() const
Return true if no decls were found.
An l-value expression is a reference to an object with independent storage.
bool isUnresolvedExceptionSpec(ExceptionSpecificationType ESpecType)
A trivial tuple used to represent a source range.
static StringRef getOpcodeStr(Opcode Op)
getOpcodeStr - Turn an Opcode enum value into the punctuation char it corresponds to...
This represents a decl that may have a name.
void dump() const
dump - Print this standard conversion sequence to standard error.
QualType getObjCObjectPointerType(QualType OIT) const
Return a ObjCObjectPointerType type for the given ObjCObjectType.
TemplateDecl * getDescribedTemplate() const
If this is a declaration that describes some template, this method returns that template declaration...
QualType getNonTypeTemplateArgumentType() const
If this is a non-type template argument, get its type.
TemplateName getAsTemplate() const
Retrieve the template name for a template name argument.
Pointer-to-member conversions (C++ [conv.mem])
SourceLocation getNameLoc() const
Gets the location of the identifier.
static OverloadingResult IsUserDefinedConversion(Sema &S, Expr *From, QualType ToType, UserDefinedConversionSequence &User, OverloadCandidateSet &Conversions, bool AllowExplicit, bool AllowObjCConversionOnExplicit)
Determines whether there is a user-defined conversion sequence (C++ [over.ics.user]) that converts ex...
Look up of an operator name (e.g., operator+) for use with operator overloading.
Describes an entity that is being initialized.
static UserDefinedLiteral * Create(const ASTContext &Ctx, Expr *Fn, ArrayRef< Expr *> Args, QualType Ty, ExprValueKind VK, SourceLocation LitEndLoc, SourceLocation SuffixLoc)
void setToType(unsigned Idx, QualType T)
EnableIfAttr * CheckEnableIf(FunctionDecl *Function, ArrayRef< Expr *> Args, bool MissingImplicitThis=false)
Check the enable_if expressions on the given function.
unsigned getNumParams() const
Return the number of parameters this function must have based on its FunctionType.
char Diagnostic[sizeof(PartialDiagnosticAt)]
A diagnostic indicating why deduction failed.
void removeAddressSpace()
SourceLocation getBegin() const
const LangOptions & getLangOpts() const
static ImplicitConversionSequence TryCopyInitialization(Sema &S, Expr *From, QualType ToType, bool SuppressUserConversions, bool InOverloadResolution, bool AllowObjCWritebackConversion, bool AllowExplicit=false)
TryCopyInitialization - Try to copy-initialize a value of type ToType from the expression From...
decls_iterator decls_end() const
The explicitly-specified template arguments were not valid template arguments for the given template...
This conversion candidate is not viable because its result type is not implicitly convertible to the ...
QualType getBaseType() const
Declaration of a template function.
static bool diagnoseDiagnoseIfAttrsWith(Sema &S, const NamedDecl *ND, bool ArgDependent, SourceLocation Loc, CheckFn &&IsSuccessful)
A class which abstracts out some details necessary for making a call.
static QualType BuildSimilarlyQualifiedPointerType(const Type *FromPtr, QualType ToPointee, QualType ToType, ASTContext &Context, bool StripObjCLifetime=false)
BuildSimilarlyQualifiedPointerType - In a pointer conversion from the pointer type FromPtr to a point...
static ImplicitConversionSequence TryUserDefinedConversion(Sema &S, Expr *From, QualType ToType, bool SuppressUserConversions, bool AllowExplicit, bool InOverloadResolution, bool CStyle, bool AllowObjCWritebackConversion, bool AllowObjCConversionOnExplicit)
Tries a user-defined conversion from From to ToType.
QualType getUnqualifiedArrayType(QualType T, Qualifiers &Quals)
Return this type as a completely-unqualified array type, capturing the qualifiers in Quals...
Attr - This represents one attribute.
bool isDeletedAsWritten() const
SourceLocation getLocation() const
bool isIncompleteOrObjectType() const
Return true if this is an incomplete or object type, in other words, not a function type...
bool isCXX11ConstantExpr(const ASTContext &Ctx, APValue *Result=nullptr, SourceLocation *Loc=nullptr) const
isCXX11ConstantExpr - Return true if this expression is a constant expression in C++11.
QualType getPointeeType() const
A single template declaration.
ArrayRef< ParmVarDecl * > parameters() const
Expr * IgnoreParens() LLVM_READONLY
Skip past any parentheses which might surround this expression until reaching a fixed point...
CanQualType UnsignedIntTy
bool hasErrorOccurred() const
Determine whether any SFINAE errors have been trapped.
bool Best
Whether this candidate is the best viable function, or tied for being the best viable function...
unsigned NumConversionsFixed
The number of Conversions fixed.
void AddMethodTemplateCandidate(FunctionTemplateDecl *MethodTmpl, DeclAccessPair FoundDecl, CXXRecordDecl *ActingContext, TemplateArgumentListInfo *ExplicitTemplateArgs, QualType ObjectType, Expr::Classification ObjectClassification, ArrayRef< Expr *> Args, OverloadCandidateSet &CandidateSet, bool SuppressUserConversions=false, bool PartialOverloading=false, OverloadCandidateParamOrder PO={})
Add a C++ member function template as a candidate to the candidate set, using template argument deduc...
param_type_iterator param_type_end() const
QualType getPointeeType() const
Gets the type pointed to by this ObjC pointer.
StandardConversionSequence - represents a standard conversion sequence (C++ 13.3.3.1.1).
static void DiagnoseFailedEnableIfAttr(Sema &S, OverloadCandidate *Cand)
ComparisonCategories CompCategories
Types and expressions required to build C++2a three-way comparisons using operator<=>, including the values return by builtin <=> operators.