31 #include "llvm/ADT/DenseSet.h" 32 #include "llvm/ADT/Optional.h" 33 #include "llvm/ADT/STLExtras.h" 34 #include "llvm/ADT/SmallPtrSet.h" 35 #include "llvm/ADT/SmallString.h" 39 using namespace clang;
44 return P->hasAttr<PassObjectSizeAttr>();
51 const Expr *
Base,
bool HadMultipleCandidates,
68 if (HadMultipleCandidates)
73 CK_FunctionToPointerDecay);
77 bool InOverloadResolution,
80 bool AllowObjCWritebackConversion);
84 bool InOverloadResolution,
92 bool AllowObjCConversionOnExplicit);
145 return Rank[(int)Kind];
155 "Function-to-pointer",
156 "Function pointer conversion",
158 "Integral promotion",
159 "Floating point promotion",
161 "Integral conversion",
162 "Floating conversion",
163 "Complex conversion",
164 "Floating-integral conversion",
165 "Pointer conversion",
166 "Pointer-to-member conversion",
167 "Boolean conversion",
168 "Compatible-types conversion",
169 "Derived-to-base conversion",
172 "Complex-real conversion",
173 "Block Pointer conversion",
174 "Transparent Union Conversion",
175 "Writeback conversion",
176 "OpenCL Zero Event Conversion",
177 "C specific type conversion",
178 "Incompatible pointer conversion" 189 DeprecatedStringLiteralToCharPtr =
false;
190 QualificationIncludesObjCLifetime =
false;
191 ReferenceBinding =
false;
192 DirectBinding =
false;
193 IsLvalueReference =
true;
194 BindsToFunctionLvalue =
false;
195 BindsToRvalue =
false;
196 BindsImplicitObjectArgumentWithoutRefQualifier =
false;
197 ObjCLifetimeConversionBinding =
false;
198 CopyConstructor =
nullptr;
225 (getFromType()->isPointerType() ||
226 getFromType()->isMemberPointerType() ||
227 getFromType()->isObjCObjectPointerType() ||
228 getFromType()->isBlockPointerType() ||
229 getFromType()->isNullPtrType() ||
262 while (
const ImplicitCastExpr *ICE = dyn_cast<ImplicitCastExpr>(Converted)) {
263 switch (ICE->getCastKind()) {
265 case CK_IntegralCast:
266 case CK_IntegralToBoolean:
267 case CK_IntegralToFloating:
268 case CK_BooleanToSignedIntegral:
269 case CK_FloatingToIntegral:
270 case CK_FloatingToBoolean:
271 case CK_FloatingCast:
272 Converted = ICE->getSubExpr();
296 QualType &ConstantType,
bool IgnoreFloatToIntegralConversion)
const {
297 assert(Ctx.
getLangOpts().CPlusPlus &&
"narrowing check outside C++");
308 ToType = ET->getDecl()->getIntegerType();
313 if (FromType->isRealFloatingType())
314 goto FloatingIntegralConversion;
315 if (FromType->isIntegralOrUnscopedEnumerationType())
316 goto IntegralConversion;
328 FloatingIntegralConversion:
329 if (FromType->isRealFloatingType() && ToType->
isIntegralType(Ctx)) {
331 }
else if (FromType->isIntegralOrUnscopedEnumerationType() &&
333 if (IgnoreFloatToIntegralConversion)
335 llvm::APSInt IntConstantValue;
337 assert(Initializer &&
"Unknown conversion expression");
346 Result.convertFromAPInt(IntConstantValue, IntConstantValue.isSigned(),
347 llvm::APFloat::rmNearestTiesToEven);
349 llvm::APSInt ConvertedValue = IntConstantValue;
351 Result.convertToInteger(ConvertedValue,
352 llvm::APFloat::rmTowardZero, &ignored);
354 if (IntConstantValue != ConvertedValue) {
355 ConstantValue =
APValue(IntConstantValue);
356 ConstantType = Initializer->
getType();
382 assert(ConstantValue.
isFloat());
383 llvm::APFloat FloatVal = ConstantValue.
getFloat();
386 llvm::APFloat::opStatus ConvertStatus = FloatVal.convert(
388 llvm::APFloat::rmNearestTiesToEven, &ignored);
391 if (ConvertStatus & llvm::APFloat::opOverflow) {
392 ConstantType = Initializer->
getType();
407 IntegralConversion: {
408 assert(FromType->isIntegralOrUnscopedEnumerationType());
410 const bool FromSigned = FromType->isSignedIntegerOrEnumerationType();
411 const unsigned FromWidth = Ctx.
getIntWidth(FromType);
415 if (FromWidth > ToWidth ||
416 (FromWidth == ToWidth && FromSigned != ToSigned) ||
417 (FromSigned && !ToSigned)) {
419 llvm::APSInt InitializerValue;
430 bool Narrowing =
false;
431 if (FromWidth < ToWidth) {
434 if (InitializerValue.isSigned() && InitializerValue.isNegative())
439 InitializerValue = InitializerValue.extend(
440 InitializerValue.getBitWidth() + 1);
442 llvm::APSInt ConvertedValue = InitializerValue;
443 ConvertedValue = ConvertedValue.trunc(ToWidth);
444 ConvertedValue.setIsSigned(ToSigned);
445 ConvertedValue = ConvertedValue.extend(InitializerValue.getBitWidth());
446 ConvertedValue.setIsSigned(InitializerValue.isSigned());
448 if (ConvertedValue != InitializerValue)
452 ConstantType = Initializer->
getType();
453 ConstantValue =
APValue(InitializerValue);
469 raw_ostream &OS = llvm::errs();
470 bool PrintedSomething =
false;
473 PrintedSomething =
true;
477 if (PrintedSomething) {
482 if (CopyConstructor) {
483 OS <<
" (by copy constructor)";
484 }
else if (DirectBinding) {
485 OS <<
" (direct reference binding)";
486 }
else if (ReferenceBinding) {
487 OS <<
" (reference binding)";
489 PrintedSomething =
true;
493 if (PrintedSomething) {
497 PrintedSomething =
true;
500 if (!PrintedSomething) {
501 OS <<
"No conversions required";
508 raw_ostream &OS = llvm::errs();
509 if (Before.First || Before.Second || Before.Third) {
513 if (ConversionFunction)
514 OS <<
'\'' << *ConversionFunction <<
'\'';
516 OS <<
"aggregate initialization";
526 raw_ostream &OS = llvm::errs();
527 if (isStdInitializerListElement())
528 OS <<
"Worst std::initializer_list element conversion: ";
529 switch (ConversionKind) {
530 case StandardConversion:
531 OS <<
"Standard conversion: ";
534 case UserDefinedConversion:
535 OS <<
"User-defined conversion: ";
538 case EllipsisConversion:
539 OS <<
"Ellipsis conversion";
541 case AmbiguousConversion:
542 OS <<
"Ambiguous conversion";
545 OS <<
"Bad conversion";
557 conversions().~ConversionSet();
570 struct DFIArguments {
576 struct DFIParamWithArguments : DFIArguments {
581 struct DFIDeducedMismatchArgs : DFIArguments {
583 unsigned CallArgIndex;
594 Result.
Result =
static_cast<unsigned>(TDK);
603 Result.
Data =
nullptr;
608 Result.
Data = Info.
Param.getOpaqueValue();
614 auto *Saved =
new (Context) DFIDeducedMismatchArgs;
617 Saved->TemplateArgs = Info.
take();
625 DFIArguments *Saved =
new (Context) DFIArguments;
637 DFIParamWithArguments *Saved =
new (Context) DFIParamWithArguments;
638 Saved->Param = Info.
Param;
657 llvm_unreachable(
"not a deduction failure");
664 switch (static_cast<Sema::TemplateDeductionResult>(Result)) {
690 Diag->~PartialDiagnosticAt();
691 HasDiagnostic =
false;
708 switch (static_cast<Sema::TemplateDeductionResult>(Result)) {
724 return TemplateParameter::getFromOpaqueValue(Data);
729 return static_cast<DFIParamWithArguments*
>(Data)->Param;
740 switch (static_cast<Sema::TemplateDeductionResult>(Result)) {
758 return static_cast<DFIDeducedMismatchArgs*
>(Data)->TemplateArgs;
772 switch (static_cast<Sema::TemplateDeductionResult>(Result)) {
791 return &
static_cast<DFIArguments*
>(Data)->FirstArg;
802 switch (static_cast<Sema::TemplateDeductionResult>(Result)) {
821 return &
static_cast<DFIArguments*
>(Data)->SecondArg;
832 switch (static_cast<Sema::TemplateDeductionResult>(Result)) {
835 return static_cast<DFIDeducedMismatchArgs*
>(Data)->CallArgIndex;
842 void OverloadCandidateSet::destroyCandidates() {
843 for (iterator i = begin(), e = end(); i != e; ++i) {
844 for (
auto &C : i->Conversions)
845 C.~ImplicitConversionSequence();
847 i->DeductionFailure.Destroy();
853 SlabAllocator.Reset();
854 NumInlineBytesUsed = 0;
861 class UnbridgedCastsSet {
871 Entry entry = { &E, E };
872 Entries.push_back(entry);
878 i = Entries.begin(), e = Entries.end(); i != e; ++i)
893 UnbridgedCastsSet *unbridgedCasts =
nullptr) {
897 if (placeholder->getKind() == BuiltinType::Overload)
return false;
901 if (placeholder->getKind() == BuiltinType::ARCUnbridgedCast &&
903 unbridgedCasts->save(S, E);
924 UnbridgedCastsSet &unbridged) {
925 for (
unsigned i = 0, e = Args.size(); i != e; ++i)
967 NamedDecl *&Match,
bool NewIsUsingDecl) {
972 bool OldIsUsingDecl =
false;
973 if (isa<UsingShadowDecl>(OldD)) {
974 OldIsUsingDecl =
true;
978 if (NewIsUsingDecl)
continue;
980 OldD = cast<UsingShadowDecl>(OldD)->getTargetDecl();
985 if ((OldIsUsingDecl || NewIsUsingDecl) && !isVisible(*I))
993 bool UseMemberUsingDeclRules =
994 (OldIsUsingDecl || NewIsUsingDecl) && CurContext->isRecord() &&
998 if (!IsOverload(New, OldF, UseMemberUsingDeclRules)) {
999 if (UseMemberUsingDeclRules && OldIsUsingDecl) {
1000 HideUsingShadowDecl(S, cast<UsingShadowDecl>(*I));
1004 if (!isa<FunctionTemplateDecl>(OldD) &&
1005 !shouldLinkPossiblyHiddenDecl(*I, New))
1014 if (!getASTContext().canBuiltinBeRedeclared(OldF)) {
1016 return Ovl_NonFunction;
1018 }
else if (isa<UsingDecl>(OldD) || isa<UsingPackDecl>(OldD)) {
1022 }
else if (isa<TagDecl>(OldD)) {
1024 }
else if (
auto *UUD = dyn_cast<UnresolvedUsingValueDecl>(OldD)) {
1031 if (UUD->getQualifier()->isDependent() && !UUD->isCXXClassMember()) {
1033 return Ovl_NonFunction;
1040 return Ovl_NonFunction;
1064 if (CheckFunctionTemplateSpecialization(New,
nullptr, TemplateSpecResult,
1067 return Ovl_Overload;
1074 return Ovl_Overload;
1078 bool UseMemberUsingDeclRules,
bool ConsiderCudaAttrs) {
1093 if ((OldTemplate ==
nullptr) != (NewTemplate ==
nullptr))
1106 if (isa<FunctionNoProtoType>(OldQType.
getTypePtr()) ||
1107 isa<FunctionNoProtoType>(NewQType.
getTypePtr()))
1116 if (OldQType != NewQType &&
1118 OldType->
isVariadic() != NewType->isVariadic() ||
1119 !FunctionParamTypesAreEqual(OldType, NewType)))
1134 if (!UseMemberUsingDeclRules && NewTemplate &&
1137 false, TPL_TemplateMatch) ||
1152 if (OldMethod && NewMethod &&
1153 !OldMethod->
isStatic() && !NewMethod->isStatic()) {
1155 if (!UseMemberUsingDeclRules &&
1157 NewMethod->getRefQualifier() ==
RQ_None)) {
1164 Diag(NewMethod->getLocation(), diag::err_ref_qualifier_overload)
1177 unsigned NewQuals = NewMethod->getTypeQualifiers().getCVRUQualifiers();
1178 if (!getLangOpts().
CPlusPlus14 && NewMethod->isConstexpr() &&
1179 !isa<CXXConstructorDecl>(NewMethod))
1185 if (OldQuals != NewQuals)
1203 NewI != NewE || OldI != OldE; ++NewI, ++OldI) {
1204 if (NewI == NewE || OldI == OldE)
1206 llvm::FoldingSetNodeID NewID, OldID;
1207 NewI->getCond()->
Profile(NewID, Context,
true);
1208 OldI->getCond()->Profile(OldID, Context,
true);
1213 if (getLangOpts().CUDA && ConsiderCudaAttrs) {
1216 if (isa<CXXDestructorDecl>(New))
1220 OldTarget = IdentifyCUDATarget(Old);
1221 if (NewTarget == CFT_InvalidTarget)
1224 assert((OldTarget != CFT_InvalidTarget) &&
"Unexpected invalid target.");
1228 return NewTarget != OldTarget;
1245 Decl *C = cast<Decl>(CurContext);
1259 bool SuppressUserConversions,
1261 bool InOverloadResolution,
1263 bool AllowObjCWritebackConversion,
1264 bool AllowObjCConversionOnExplicit) {
1267 if (SuppressUserConversions) {
1278 Conversions, AllowExplicit,
1279 AllowObjCConversionOnExplicit)) {
1296 if (Constructor->isCopyConstructor() &&
1297 (FromCanon == ToCanon ||
1308 if (ToCanon != FromCanon)
1319 Cand != Conversions.
end(); ++Cand)
1362 bool SuppressUserConversions,
1364 bool InOverloadResolution,
1366 bool AllowObjCWritebackConversion,
1367 bool AllowObjCConversionOnExplicit) {
1370 ICS.
Standard, CStyle, AllowObjCWritebackConversion)){
1410 AllowExplicit, InOverloadResolution, CStyle,
1411 AllowObjCWritebackConversion,
1412 AllowObjCConversionOnExplicit);
1417 bool SuppressUserConversions,
1419 bool InOverloadResolution,
1421 bool AllowObjCWritebackConversion) {
1423 SuppressUserConversions, AllowExplicit,
1424 InOverloadResolution, CStyle,
1425 AllowObjCWritebackConversion,
1438 return PerformImplicitConversion(From, ToType, Action, AllowExplicit, ICS);
1449 bool AllowObjCWritebackConversion
1450 = getLangOpts().ObjCAutoRefCount &&
1451 (Action == AA_Passing || Action == AA_Sending);
1452 if (getLangOpts().ObjC)
1453 CheckObjCBridgeRelatedConversions(From->
getBeginLoc(), ToType,
1460 AllowObjCWritebackConversion,
1462 return PerformImplicitConversion(From, ToType, ICS, Action);
1483 if (TyClass != CanFrom->getTypeClass())
return false;
1484 if (TyClass != Type::FunctionProto && TyClass != Type::FunctionNoProto) {
1485 if (TyClass == Type::Pointer) {
1488 }
else if (TyClass == Type::BlockPointer) {
1491 }
else if (TyClass == Type::MemberPointer) {
1495 if (ToMPT->getClass() != FromMPT->
getClass())
1497 CanTo = ToMPT->getPointeeType();
1503 TyClass = CanTo->getTypeClass();
1504 if (TyClass != CanFrom->getTypeClass())
return false;
1505 if (TyClass != Type::FunctionProto && TyClass != Type::FunctionNoProto)
1509 const auto *FromFn = cast<FunctionType>(CanFrom);
1512 const auto *ToFn = cast<FunctionType>(CanTo);
1515 bool Changed =
false;
1518 if (FromEInfo.getNoReturn() && !ToEInfo.getNoReturn()) {
1524 if (
const auto *FromFPT = dyn_cast<FunctionProtoType>(FromFn)) {
1525 const auto *ToFPT = cast<FunctionProtoType>(ToFn);
1526 if (FromFPT->isNothrow() && !ToFPT->isNothrow()) {
1527 FromFn = cast<FunctionType>(
1538 bool CanUseToFPT, CanUseFromFPT;
1540 CanUseFromFPT, NewParamInfos) &&
1541 CanUseToFPT && !CanUseFromFPT) {
1544 NewParamInfos.empty() ? nullptr : NewParamInfos.data();
1546 FromFPT->getParamTypes(), ExtInfo);
1555 assert(
QualType(FromFn, 0).isCanonical());
1556 if (
QualType(FromFn, 0) != CanTo)
return false;
1608 bool InOverloadResolution,
1621 bool InOverloadResolution,
1624 bool AllowObjCWritebackConversion) {
1671 if (Method && !Method->
isStatic()) {
1673 "Non-unary operator on non-static member address");
1676 "Non-address-of operator on non-static member address");
1677 const Type *ClassType
1683 "Non-address-of operator for overloaded function expression");
1710 FromType = Atomic->getValueType();
1745 if (
auto *FD = dyn_cast<FunctionDecl>(DRE->getDecl()))
1765 bool IncompatibleObjC =
false;
1816 if (Float128AndLongDouble &&
1818 &llvm::APFloat::PPCDoubleDouble()))
1833 }
else if (AllowObjCWritebackConversion &&
1837 FromType, IncompatibleObjC)) {
1843 InOverloadResolution, FromType)) {
1855 InOverloadResolution,
1882 bool ObjCLifetimeConversion;
1888 ObjCLifetimeConversion)) {
1907 CanonFrom = CanonTo;
1912 if (CanonFrom == CanonTo)
1917 if (S.
getLangOpts().CPlusPlus || !InOverloadResolution)
1961 bool InOverloadResolution,
1971 for (
const auto *it : UD->
fields()) {
1974 ToType = it->getType();
2004 return To->
getKind() == BuiltinType::Int;
2007 return To->
getKind() == BuiltinType::UInt;
2031 if (FromEnumType->getDecl()->isScoped())
2038 if (FromEnumType->getDecl()->isFixed()) {
2039 QualType Underlying = FromEnumType->getDecl()->getIntegerType();
2041 IsIntegralPromotion(
nullptr, Underlying, ToType);
2048 ToType, FromEnumType->getDecl()->getPromotionType());
2055 if (getLangOpts().CPlusPlus)
2073 uint64_t FromSize = Context.
getTypeSize(FromType);
2082 for (
int Idx = 0; Idx < 6; ++Idx) {
2083 uint64_t ToSize = Context.
getTypeSize(PromoteTypes[Idx]);
2084 if (FromSize < ToSize ||
2085 (FromSize == ToSize &&
2086 FromIsSigned == PromoteTypes[Idx]->isSignedIntegerType())) {
2111 llvm::APSInt BitWidth;
2113 MemberDecl->getBitWidth()->isIntegerConstantExpr(BitWidth, Context)) {
2114 llvm::APSInt ToSize(BitWidth.getBitWidth(), BitWidth.isUnsigned());
2118 if (BitWidth < ToSize ||
2120 return To->
getKind() == BuiltinType::Int;
2126 return To->
getKind() == BuiltinType::UInt;
2151 if (FromBuiltin->getKind() == BuiltinType::Float &&
2152 ToBuiltin->getKind() == BuiltinType::Double)
2158 if (!getLangOpts().CPlusPlus &&
2159 (FromBuiltin->getKind() == BuiltinType::Float ||
2160 FromBuiltin->getKind() == BuiltinType::Double) &&
2161 (ToBuiltin->getKind() == BuiltinType::LongDouble ||
2162 ToBuiltin->getKind() == BuiltinType::Float128))
2166 if (!getLangOpts().NativeHalfType &&
2167 FromBuiltin->getKind() == BuiltinType::Half &&
2168 ToBuiltin->getKind() == BuiltinType::Float)
2205 bool StripObjCLifetime =
false) {
2208 "Invalid similarly-qualified pointer type");
2219 if (StripObjCLifetime)
2230 if (isa<ObjCObjectPointerType>(ToType))
2239 if (isa<ObjCObjectPointerType>(ToType))
2245 bool InOverloadResolution,
2251 return !InOverloadResolution;
2275 bool InOverloadResolution,
2277 bool &IncompatibleObjC) {
2278 IncompatibleObjC =
false;
2279 if (isObjCPointerConversion(FromType, ToType, ConvertedType,
2286 ConvertedType = ToType;
2293 ConvertedType = ToType;
2300 ConvertedType = ToType;
2308 ConvertedType = ToType;
2318 ConvertedType = ToType;
2326 !getLangOpts().ObjCAutoRefCount) {
2357 if (getLangOpts().MSVCCompat && FromPointeeType->
isFunctionType() &&
2391 IsDerivedFrom(From->
getBeginLoc(), FromPointeeType, ToPointeeType)) {
2428 bool &IncompatibleObjC) {
2429 if (!getLangOpts().ObjC)
2441 if (ToObjCPtr && FromObjCPtr) {
2452 if (getLangOpts().
CPlusPlus && LHS && RHS &&
2454 FromObjCPtr->getPointeeType()))
2459 ConvertedType =
AdoptQualifiers(Context, ConvertedType, FromQualifiers);
2467 IncompatibleObjC =
true;
2471 ConvertedType =
AdoptQualifiers(Context, ConvertedType, FromQualifiers);
2483 if (FromObjCPtr && FromObjCPtr->isObjCBuiltinType()) {
2511 isObjCPointerConversion(FromPointeeType, ToPointeeType, ConvertedType,
2512 IncompatibleObjC)) {
2514 IncompatibleObjC =
true;
2516 ConvertedType =
AdoptQualifiers(Context, ConvertedType, FromQualifiers);
2523 isObjCPointerConversion(FromPointeeType, ToPointeeType, ConvertedType,
2524 IncompatibleObjC)) {
2527 ConvertedType =
AdoptQualifiers(Context, ConvertedType, FromQualifiers);
2539 if (FromFunctionType && ToFunctionType) {
2548 if (FromFunctionType->
getNumParams() != ToFunctionType->getNumParams() ||
2549 FromFunctionType->
isVariadic() != ToFunctionType->isVariadic() ||
2550 FromFunctionType->
getTypeQuals() != ToFunctionType->getTypeQuals())
2553 bool HasObjCConversion =
false;
2557 }
else if (isObjCPointerConversion(FromFunctionType->
getReturnType(),
2558 ToFunctionType->getReturnType(),
2559 ConvertedType, IncompatibleObjC)) {
2561 HasObjCConversion =
true;
2568 for (
unsigned ArgIdx = 0, NumArgs = FromFunctionType->
getNumParams();
2569 ArgIdx != NumArgs; ++ArgIdx) {
2571 QualType ToArgType = ToFunctionType->getParamType(ArgIdx);
2575 }
else if (isObjCPointerConversion(FromArgType, ToArgType,
2576 ConvertedType, IncompatibleObjC)) {
2578 HasObjCConversion =
true;
2585 if (HasObjCConversion) {
2589 IncompatibleObjC =
true;
2608 if (!getLangOpts().ObjCAutoRefCount ||
2650 bool IncompatibleObjC;
2652 FromPointee = ToPointee;
2653 else if (!isObjCPointerConversion(FromPointee, ToPointee, FromPointee,
2688 if (!FromFunctionType || !ToFunctionType)
2691 if (Context.
hasSameType(FromPointeeType, ToPointeeType))
2696 if (FromFunctionType->
getNumParams() != ToFunctionType->getNumParams() ||
2697 FromFunctionType->
isVariadic() != ToFunctionType->isVariadic())
2702 if (FromEInfo != ToEInfo)
2705 bool IncompatibleObjC =
false;
2707 ToFunctionType->getReturnType())) {
2711 QualType LHS = ToFunctionType->getReturnType();
2718 }
else if (isObjCPointerConversion(RHS, LHS,
2719 ConvertedType, IncompatibleObjC)) {
2720 if (IncompatibleObjC)
2729 for (
unsigned ArgIdx = 0, NumArgs = FromFunctionType->
getNumParams();
2730 ArgIdx != NumArgs; ++ArgIdx) {
2731 IncompatibleObjC =
false;
2733 QualType ToArgType = ToFunctionType->getParamType(ArgIdx);
2734 if (Context.
hasSameType(FromArgType, ToArgType)) {
2736 }
else if (isObjCPointerConversion(ToArgType, FromArgType,
2737 ConvertedType, IncompatibleObjC)) {
2738 if (IncompatibleObjC)
2747 bool CanUseToFPT, CanUseFromFPT;
2749 CanUseToFPT, CanUseFromFPT,
2753 ConvertedType = ToType;
2829 if (!FromFunction || !ToFunction) {
2834 if (FromFunction->
getNumParams() != ToFunction->getNumParams()) {
2842 if (!FunctionParamTypesAreEqual(FromFunction, ToFunction, &ArgPos)) {
2844 << ToFunction->getParamType(ArgPos)
2851 ToFunction->getReturnType())) {
2857 if (FromFunction->
getTypeQuals() != ToFunction->getTypeQuals()) {
2867 cast<FunctionProtoType>(ToFunction->getCanonicalTypeUnqualified())
2887 O && (O != E); ++O, ++N) {
2889 N->getUnqualifiedType())) {
2907 bool IgnoreBaseAccess,
2910 bool IsCStyleOrFunctionalCast = IgnoreBaseAccess;
2914 if (Diagnose && !IsCStyleOrFunctionalCast && !FromType->
isAnyPointerType() &&
2918 DiagRuntimeBehavior(From->
getExprLoc(), From,
2919 PDiag(diag::warn_impcast_bool_to_null_pointer)
2921 else if (!isUnevaluatedContext())
2930 if (FromPointeeType->
isRecordType() && ToPointeeType->isRecordType() &&
2934 unsigned InaccessibleID = 0;
2935 unsigned AmbigiousID = 0;
2937 InaccessibleID = diag::err_upcast_to_inaccessible_base;
2938 AmbigiousID = diag::err_ambiguous_derived_to_base_conv;
2940 if (CheckDerivedToBaseConversion(
2941 FromPointeeType, ToPointeeType, InaccessibleID, AmbigiousID,
2943 &BasePath, IgnoreBaseAccess))
2947 Kind = CK_DerivedToBase;
2950 if (Diagnose && !IsCStyleOrFunctionalCast &&
2951 FromPointeeType->
isFunctionType() && ToPointeeType->isVoidType()) {
2952 assert(getLangOpts().MSVCCompat &&
2953 "this should only be possible with MSVCCompat!");
2965 if (FromPtrType->isObjCBuiltinType() || ToPtrType->isObjCBuiltinType())
2968 Kind = CK_BlockPointerToObjCPointerCast;
2970 Kind = CK_CPointerToObjCPointerCast;
2974 Kind = CK_AnyPointerToBlockPointerCast;
2980 Kind = CK_NullToPointer;
2992 bool InOverloadResolution,
3002 ConvertedType = ToType;
3017 IsDerivedFrom(From->
getBeginLoc(), ToClass, FromClass)) {
3035 bool IgnoreBaseAccess) {
3042 "Expr must be null pointer constant!");
3043 Kind = CK_NullToMemberPointer;
3048 assert(ToPtrType &&
"No member pointer cast has a target type " 3049 "that is not a member pointer.");
3055 assert(FromClass->
isRecordType() &&
"Pointer into non-class.");
3056 assert(ToClass->isRecordType() &&
"Pointer into non-class.");
3060 bool DerivationOkay =
3061 IsDerivedFrom(From->
getBeginLoc(), ToClass, FromClass, Paths);
3062 assert(DerivationOkay &&
3063 "Should not have been called if derivation isn't OK.");
3064 (void)DerivationOkay;
3067 getUnqualifiedType())) {
3068 std::string PathDisplayStr = getAmbiguousPathsDisplayString(Paths);
3070 << 0 << FromClass << ToClass << PathDisplayStr << From->
getSourceRange();
3074 if (
const RecordType *VBase = Paths.getDetectedVirtual()) {
3076 << FromClass << ToClass <<
QualType(VBase, 0)
3081 if (!IgnoreBaseAccess)
3082 CheckBaseClassAccess(From->
getExprLoc(), FromClass, ToClass,
3084 diag::err_downcast_from_inaccessible_base);
3088 Kind = CK_BaseToDerivedMemberPointer;
3113 bool CStyle,
bool &ObjCLifetimeConversion) {
3116 ObjCLifetimeConversion =
false;
3126 bool PreviousToQualsIncludeConst =
true;
3127 bool UnwrappedAnyPointer =
false;
3135 UnwrappedAnyPointer =
true;
3147 UnwrappedAnyPointer) {
3150 ObjCLifetimeConversion =
true;
3175 && !PreviousToQualsIncludeConst)
3180 PreviousToQualsIncludeConst
3181 = PreviousToQualsIncludeConst && ToQuals.
hasConst();
3207 bool InOverloadResolution,
3216 InOverloadResolution, InnerSCS,
3220 SCS.
Second = InnerSCS.Second;
3221 SCS.
setToType(1, InnerSCS.getToType(1));
3222 SCS.
Third = InnerSCS.Third;
3224 = InnerSCS.QualificationIncludesObjCLifetime;
3225 SCS.
setToType(2, InnerSCS.getToType(2));
3247 bool AllowExplicit) {
3254 bool Usable = !Info.Constructor->isInvalidDecl() &&
3256 (AllowExplicit || !Info.Constructor->isExplicit());
3261 S.
Context, Info.Constructor, ToType);
3262 if (Info.ConstructorTmpl)
3265 CandidateSet, SuppressUserConversions);
3268 CandidateSet, SuppressUserConversions);
3272 bool HadMultipleCandidates = (CandidateSet.
size() > 1);
3275 switch (
auto Result =
3299 llvm_unreachable(
"Invalid OverloadResult!");
3321 bool AllowObjCConversionOnExplicit) {
3322 assert(AllowExplicit || !AllowObjCConversionOnExplicit);
3326 bool ConstructorsOnly =
false;
3342 ConstructorsOnly =
true;
3347 = dyn_cast<CXXRecordDecl>(ToRecordType->getDecl())) {
3349 Expr **Args = &From;
3350 unsigned NumArgs = 1;
3351 bool ListInitializing =
false;
3352 if (
InitListExpr *InitList = dyn_cast<InitListExpr>(From)) {
3355 S, From, ToType, ToRecordDecl, User, CandidateSet, AllowExplicit);
3364 Args = InitList->getInits();
3365 NumArgs = InitList->getNumInits();
3366 ListInitializing =
true;
3374 bool Usable = !Info.Constructor->isInvalidDecl();
3375 if (ListInitializing)
3376 Usable = Usable && (AllowExplicit || !Info.Constructor->isExplicit());
3379 Info.Constructor->isConvertingConstructor(AllowExplicit);
3381 bool SuppressUserConversions = !ConstructorsOnly;
3382 if (SuppressUserConversions && ListInitializing) {
3383 SuppressUserConversions =
false;
3388 S.
Context, Info.Constructor, ToType);
3391 if (Info.ConstructorTmpl)
3393 Info.ConstructorTmpl, Info.FoundDecl,
3394 nullptr, llvm::makeArrayRef(Args, NumArgs),
3395 CandidateSet, SuppressUserConversions);
3400 llvm::makeArrayRef(Args, NumArgs),
3401 CandidateSet, SuppressUserConversions);
3408 if (ConstructorsOnly || isa<InitListExpr>(From)) {
3411 }
else if (
const RecordType *FromRecordType =
3414 = dyn_cast<CXXRecordDecl>(FromRecordType->getDecl())) {
3416 const auto &Conversions = FromRecordDecl->getVisibleConversionFunctions();
3417 for (
auto I = Conversions.
begin(), E = Conversions.
end(); I != E; ++I) {
3421 if (isa<UsingShadowDecl>(D))
3422 D = cast<UsingShadowDecl>(D)->getTargetDecl();
3426 if ((ConvTemplate = dyn_cast<FunctionTemplateDecl>(D)))
3429 Conv = cast<CXXConversionDecl>(D);
3431 if (AllowExplicit || !Conv->isExplicit()) {
3434 ActingContext, From, ToType,
3436 AllowObjCConversionOnExplicit);
3439 From, ToType, CandidateSet,
3440 AllowObjCConversionOnExplicit);
3446 bool HadMultipleCandidates = (CandidateSet.
size() > 1);
3449 switch (
auto Result =
3455 = dyn_cast<CXXConstructorDecl>(Best->Function)) {
3462 QualType ThisType = Constructor->getThisType();
3463 if (isa<InitListExpr>(From)) {
3467 if (Best->Conversions[0].isEllipsis())
3470 User.
Before = Best->Conversions[0].Standard;
3483 = dyn_cast<CXXConversionDecl>(Best->Function)) {
3490 User.
Before = Best->Conversions[0].Standard;
3505 User.
After = Best->FinalConversion;
3508 llvm_unreachable(
"Not a constructor or conversion function?");
3517 llvm_unreachable(
"Invalid OverloadResult!");
3527 CandidateSet,
false,
false);
3532 if (!RequireCompleteType(From->
getBeginLoc(), ToType,
3533 diag::err_typecheck_nonviable_condition_incomplete,
3569 if (Block1 != Block2)
3656 if (!ICS1.
isBad()) {
3789 else if (Rank2 < Rank1)
3810 bool SCS1ConvertsToVoid
3812 bool SCS2ConvertsToVoid
3814 if (SCS1ConvertsToVoid != SCS2ConvertsToVoid) {
3819 }
else if (!SCS1ConvertsToVoid && !SCS2ConvertsToVoid) {
3825 }
else if (SCS1ConvertsToVoid && SCS2ConvertsToVoid &&
3854 if (FromObjCPtr1 && FromObjCPtr2) {
3859 if (AssignLeft != AssignRight) {
3892 if (UnqualT1 == UnqualT2) {
3904 if (isa<ArrayType>(T1) && T1Quals)
3906 if (isa<ArrayType>(T2) && T2Quals)
3952 if (SCS1IsCompatibleVectorConversion != SCS2IsCompatibleVectorConversion)
3953 return SCS1IsCompatibleVectorConversion
3990 if (UnqualT1 == UnqualT2)
3995 if (isa<ArrayType>(T1) && T1Quals)
3997 if (isa<ArrayType>(T2) && T2Quals)
4120 if (FromPointee1 == FromPointee2 && ToPointee1 != ToPointee2) {
4128 if (FromPointee1 != FromPointee2 && ToPointee1 == ToPointee2) {
4145 if (FromPtr1 && FromPtr2 && ToPtr1 && ToPtr2) {
4152 bool FromAssignRight
4161 if (ToPtr1->isObjCIdType() &&
4162 (ToPtr2->isObjCQualifiedIdType() || ToPtr2->getInterfaceDecl()))
4164 if (ToPtr2->isObjCIdType() &&
4165 (ToPtr1->isObjCQualifiedIdType() || ToPtr1->getInterfaceDecl()))
4170 if (ToPtr1->isObjCQualifiedIdType() && ToPtr2->getInterfaceDecl())
4172 if (ToPtr2->isObjCQualifiedIdType() && ToPtr1->getInterfaceDecl())
4177 if (ToPtr1->isObjCClassType() &&
4178 (ToPtr2->isObjCQualifiedClassType() || ToPtr2->getInterfaceDecl()))
4180 if (ToPtr2->isObjCClassType() &&
4181 (ToPtr1->isObjCQualifiedClassType() || ToPtr1->getInterfaceDecl()))
4186 if (ToPtr1->isObjCQualifiedClassType() && ToPtr2->getInterfaceDecl())
4188 if (ToPtr2->isObjCQualifiedClassType() && ToPtr1->getInterfaceDecl())
4194 (ToAssignLeft != ToAssignRight)) {
4205 }
else if (IsSecondSame)
4214 (FromAssignLeft != FromAssignRight))
4232 const Type *FromPointeeType1 = FromMemPointer1->
getClass();
4233 const Type *ToPointeeType1 = ToMemPointer1->getClass();
4234 const Type *FromPointeeType2 = FromMemPointer2->getClass();
4235 const Type *ToPointeeType2 = ToMemPointer2->getClass();
4241 if (FromPointee1 == FromPointee2 && ToPointee1 != ToPointee2) {
4248 if (ToPointee1 == ToPointee2 && FromPointee1 != FromPointee2) {
4289 return !Record->isInvalidDecl();
4304 bool &DerivedToBase,
4305 bool &ObjCConversion,
4306 bool &ObjCLifetimeConversion) {
4308 "T1 must be the pointee type of the reference type");
4309 assert(!OrigT2->
isReferenceType() &&
"T2 cannot be a reference type");
4321 DerivedToBase =
false;
4322 ObjCConversion =
false;
4323 ObjCLifetimeConversion =
false;
4325 if (UnqualT1 == UnqualT2) {
4327 }
else if (isCompleteType(Loc, OrigT2) &&
4329 IsDerivedFrom(Loc, UnqualT2, UnqualT1))
4330 DerivedToBase =
true;
4334 ObjCConversion =
true;
4336 IsFunctionConversion(UnqualT2, UnqualT1, ConvertedT2))
4343 return Ref_Compatible;
4345 return Ref_Incompatible;
4352 if (isa<ArrayType>(T1) && T1Quals)
4354 if (isa<ArrayType>(T2) && T2Quals)
4372 ObjCLifetimeConversion =
true;
4383 return Ref_Compatible;
4394 bool AllowExplicit) {
4395 assert(T2->
isRecordType() &&
"Can only find conversions of record types.");
4401 const auto &Conversions = T2RecordDecl->getVisibleConversionFunctions();
4402 for (
auto I = Conversions.begin(), E = Conversions.end(); I != E; ++I) {
4405 if (isa<UsingShadowDecl>(D))
4406 D = cast<UsingShadowDecl>(D)->getTargetDecl();
4414 Conv = cast<CXXConversionDecl>(D);
4418 if (!AllowExplicit && Conv->isExplicit())
4422 bool DerivedToBase =
false;
4423 bool ObjCConversion =
false;
4424 bool ObjCLifetimeConversion =
false;
4435 if (!ConvTemplate &&
4438 Conv->getConversionType().getNonReferenceType()
4439 .getUnqualifiedType(),
4441 DerivedToBase, ObjCConversion, ObjCLifetimeConversion) ==
4459 Init, DeclType, CandidateSet,
4463 DeclType, CandidateSet,
4467 bool HadMultipleCandidates = (CandidateSet.size() > 1);
4470 switch (CandidateSet.BestViableFunction(S, DeclLoc, Best)) {
4482 if (!Best->FinalConversion.DirectBinding)
4494 "Expected a direct reference binding!");
4500 Cand != CandidateSet.end(); ++Cand)
4512 llvm_unreachable(
"Invalid OverloadResult!");
4520 bool SuppressUserConversions,
4521 bool AllowExplicit) {
4522 assert(DeclType->
isReferenceType() &&
"Reference init needs a reference");
4543 bool DerivedToBase =
false;
4544 bool ObjCConversion =
false;
4545 bool ObjCLifetimeConversion =
false;
4549 ObjCConversion, ObjCLifetimeConversion);
4577 ICS.Standard.setToType(0, T2);
4578 ICS.Standard.setToType(1, T1);
4579 ICS.Standard.setToType(2, T1);
4580 ICS.Standard.ReferenceBinding =
true;
4581 ICS.Standard.DirectBinding =
true;
4582 ICS.Standard.IsLvalueReference = !isRValRef;
4584 ICS.Standard.BindsToRvalue =
false;
4585 ICS.Standard.BindsImplicitObjectArgumentWithoutRefQualifier =
false;
4586 ICS.Standard.ObjCLifetimeConversionBinding = ObjCLifetimeConversion;
4587 ICS.Standard.CopyConstructor =
nullptr;
4588 ICS.Standard.DeprecatedStringLiteralToCharPtr =
false;
4635 ICS.Standard.setToType(0, T2);
4636 ICS.Standard.setToType(1, T1);
4637 ICS.Standard.setToType(2, T1);
4638 ICS.Standard.ReferenceBinding =
true;
4644 ICS.Standard.DirectBinding =
4647 ICS.Standard.IsLvalueReference = !isRValRef;
4649 ICS.Standard.BindsToRvalue = InitCategory.
isRValue();
4650 ICS.Standard.BindsImplicitObjectArgumentWithoutRefQualifier =
false;
4651 ICS.Standard.ObjCLifetimeConversionBinding = ObjCLifetimeConversion;
4652 ICS.Standard.CopyConstructor =
nullptr;
4653 ICS.Standard.DeprecatedStringLiteralToCharPtr =
false;
4676 if (ICS.isUserDefined() && isRValRef &&
4748 if (ICS.isStandard()) {
4749 ICS.Standard.ReferenceBinding =
true;
4750 ICS.Standard.IsLvalueReference = !isRValRef;
4751 ICS.Standard.BindsToFunctionLvalue =
false;
4752 ICS.Standard.BindsToRvalue =
true;
4753 ICS.Standard.BindsImplicitObjectArgumentWithoutRefQualifier =
false;
4754 ICS.Standard.ObjCLifetimeConversionBinding =
false;
4755 }
else if (ICS.isUserDefined()) {
4757 ICS.UserDefined.ConversionFunction->getReturnType()
4774 ICS.UserDefined.After.ReferenceBinding =
true;
4775 ICS.UserDefined.After.IsLvalueReference = !isRValRef;
4776 ICS.UserDefined.After.BindsToFunctionLvalue =
false;
4777 ICS.UserDefined.After.BindsToRvalue = !LValRefType;
4778 ICS.UserDefined.After.BindsImplicitObjectArgumentWithoutRefQualifier =
false;
4779 ICS.UserDefined.After.ObjCLifetimeConversionBinding =
false;
4787 bool SuppressUserConversions,
4788 bool InOverloadResolution,
4789 bool AllowObjCWritebackConversion,
4790 bool AllowExplicit =
false);
4796 bool SuppressUserConversions,
4797 bool InOverloadResolution,
4798 bool AllowObjCWritebackConversion) {
4827 SuppressUserConversions,
4828 InOverloadResolution,
4829 AllowObjCWritebackConversion);
4862 bool toStdInitializerList =
false;
4869 for (
unsigned i = 0, e = From->
getNumInits(); i < e; ++i) {
4873 InOverloadResolution,
4874 AllowObjCWritebackConversion);
4911 InOverloadResolution,
false,
4912 AllowObjCWritebackConversion,
4969 Init, ToType,
false, Found))
4974 bool dummy1 =
false;
4975 bool dummy2 =
false;
4976 bool dummy3 =
false;
4983 SuppressUserConversions,
4991 InOverloadResolution,
4992 AllowObjCWritebackConversion);
4993 if (Result.isFailure())
4995 assert(!Result.isEllipsis() &&
4996 "Sub-initialization cannot result in ellipsis conversion.");
5002 Result.UserDefined.After;
5023 if (NumInits == 1 && !isa<InitListExpr>(From->
getInit(0)))
5025 SuppressUserConversions,
5026 InOverloadResolution,
5027 AllowObjCWritebackConversion);
5030 else if (NumInits == 0) {
5053 bool SuppressUserConversions,
5054 bool InOverloadResolution,
5055 bool AllowObjCWritebackConversion,
5056 bool AllowExplicit) {
5057 if (
InitListExpr *FromInitList = dyn_cast<InitListExpr>(From))
5059 InOverloadResolution,AllowObjCWritebackConversion);
5064 SuppressUserConversions, AllowExplicit);
5067 SuppressUserConversions,
5069 InOverloadResolution,
5071 AllowObjCWritebackConversion,
5084 return !ICS.
isBad();
5099 if (isa<CXXDestructorDecl>(Method)) {
5118 assert(FromClassification.
isLValue());
5144 != FromTypeCanon.getLocalCVRQualifiers() &&
5147 FromType, ImplicitParamType);
5161 FromType, ImplicitParamType);
5181 if (!FromClassification.
isRValue()) {
5224 FromRecordType = From->
getType();
5225 DestType = ImplicitParamRecordType;
5226 FromClassification = From->
Classify(Context);
5230 From = CreateMaterializeTemporaryExpr(FromRecordType, From,
5242 switch (ICS.Bad.Kind) {
5249 << Method->getDeclName() << FromRecordType << (CVR - 1)
5251 Diag(Method->getLocation(), diag::note_previous_decl)
5252 << Method->getDeclName();
5260 bool IsRValueQualified =
5263 << Method->getDeclName() << FromClassification.
isRValue()
5264 << IsRValueQualified;
5265 Diag(Method->getLocation(), diag::note_previous_decl)
5266 << Method->getDeclName();
5275 return Diag(From->
getBeginLoc(), diag::err_member_function_call_bad_type)
5276 << ImplicitParamRecordType << FromRecordType
5282 PerformObjectMemberConversion(From, Qualifier, FoundDecl, Method);
5285 From = FromRes.
get();
5290 From = ImpCastExprToType(From, DestType, CK_AddressSpaceConversion,
5293 From = ImpCastExprToType(From, DestType, CK_NoOp,
5320 return PerformImplicitConversion(From, Context.
BoolTy, ICS, AA_Converting);
5322 if (!DiagnoseMultipleUserDefinedConversion(From, Context.
BoolTy))
5382 llvm_unreachable(
"found a first conversion kind in Second");
5385 llvm_unreachable(
"found a third conversion kind in Second");
5391 llvm_unreachable(
"unknown conversion kind");
5402 "converted constant expression outside C++11");
5438 diag::err_typecheck_converted_constant_expression)
5443 llvm_unreachable(
"ellipsis conversion in converted constant expression");
5449 diag::err_typecheck_converted_constant_expression_disallowed)
5455 diag::err_typecheck_converted_constant_expression_indirect)
5468 PreNarrowingType)) {
5486 << CCE << 0 << From->
getType() << T;
5490 if (Result.
get()->isValueDependent()) {
5503 if (!Result.
get()->EvaluateAsConstantExpr(Eval, Usage, S.
Context) ||
5504 (RequireInt && !Eval.
Val.
isInt())) {
5511 if (Notes.empty()) {
5518 if (Notes.size() == 1 &&
5519 Notes[0].second.getDiagID() == diag::note_invalid_subexpr_in_const_expr)
5520 S.
Diag(Notes[0].first, diag::err_expr_not_cce) << CCE;
5524 for (
unsigned I = 0; I < Notes.size(); ++I)
5525 S.
Diag(Notes[I].first, Notes[I].second);
5536 llvm::APSInt &
Value,
5542 if (!R.isInvalid() && !R.get()->isValueDependent())
5605 return PerformImplicitConversion(From, Ty, ICS, AA_Converting);
5625 for (
unsigned I = 0, N = ViableConversions.
size(); I != N; ++I) {
5627 cast<CXXConversionDecl>(ViableConversions[I]->getUnderlyingDecl());
5637 QualType T,
bool HadMultipleCandidates,
5639 if (ExplicitConversions.
size() == 1 && !Converter.
Suppress) {
5647 std::string TypeStr;
5652 "static_cast<" + TypeStr +
">(")
5664 HadMultipleCandidates);
5669 CK_UserDefinedConversion, Result.
get(),
5670 nullptr, Result.
get()->getValueKind());
5677 QualType T,
bool HadMultipleCandidates,
5693 HadMultipleCandidates);
5698 CK_UserDefinedConversion, Result.
get(),
5699 nullptr, Result.
get()->getValueKind());
5717 for (
unsigned I = 0, N = ViableConversions.
size(); I != N; ++I) {
5721 if (isa<UsingShadowDecl>(D))
5722 D = cast<UsingShadowDecl>(D)->getTargetDecl();
5726 if ((ConvTemplate = dyn_cast<FunctionTemplateDecl>(D)))
5729 Conv = cast<CXXConversionDecl>(D);
5733 ConvTemplate, FoundDecl, ActingContext, From, ToType, CandidateSet,
5737 ToType, CandidateSet,
5768 ExprResult result = CheckPlaceholderExpr(From);
5771 From = result.
get();
5776 if (Converter.
match(T))
5777 return DefaultLvalueConversion(From);
5784 if (!RecordTy || !getLangOpts().CPlusPlus) {
5796 : Converter(Converter), From(From) {}
5801 } IncompleteDiagnoser(Converter, From);
5803 if (Converter.
Suppress ? !isCompleteType(Loc, T)
5804 : RequireCompleteType(Loc, T, IncompleteDiagnoser))
5811 const auto &Conversions =
5812 cast<CXXRecordDecl>(RecordTy->
getDecl())->getVisibleConversionFunctions();
5814 bool HadMultipleCandidates =
5815 (
std::distance(Conversions.begin(), Conversions.end()) > 1);
5819 bool HasUniqueTargetType =
true;
5822 for (
auto I = Conversions.begin(), E = Conversions.end(); I != E; ++I) {
5827 if (getLangOpts().CPlusPlus14)
5832 Conversion = cast<CXXConversionDecl>(D);
5834 assert((!ConvTemplate || getLangOpts().
CPlusPlus14) &&
5835 "Conversion operator templates are considered potentially " 5839 if (Converter.
match(CurToType) || ConvTemplate) {
5845 ExplicitConversions.
addDecl(I.getDecl(), I.getAccess());
5847 if (!ConvTemplate && getLangOpts().CPlusPlus14) {
5850 else if (HasUniqueTargetType &&
5852 HasUniqueTargetType =
false;
5854 ViableConversions.
addDecl(I.getDecl(), I.getAccess());
5859 if (getLangOpts().CPlusPlus14) {
5872 HadMultipleCandidates,
5873 ExplicitConversions))
5879 if (!HasUniqueTargetType)
5898 HadMultipleCandidates, Found))
5907 HadMultipleCandidates,
5908 ExplicitConversions))
5916 switch (ViableConversions.
size()) {
5919 HadMultipleCandidates,
5920 ExplicitConversions))
5930 HadMultipleCandidates, Found))
5993 bool SuppressUserConversions,
5994 bool PartialOverloading,
bool AllowExplicit,
5999 assert(Proto &&
"Functions without a prototype cannot be overloaded");
6001 "Use AddTemplateOverloadCandidate for function templates");
6003 if (
CXXMethodDecl *Method = dyn_cast<CXXMethodDecl>(Function)) {
6004 if (!isa<CXXConstructorDecl>(Method)) {
6012 AddMethodCandidate(Method, FoundDecl, Method->getParent(),
QualType(),
6014 CandidateSet, SuppressUserConversions,
6015 PartialOverloading, EarlyConversions);
6050 CandidateSet.
addCandidate(Args.size(), EarlyConversions);
6060 !Function->
getAttr<TargetAttr>()->isDefaultVersion()) {
6061 Candidate.
Viable =
false;
6073 IsDerivedFrom(Args[0]->getBeginLoc(), Args[0]->getType(),
6075 Candidate.
Viable =
false;
6088 if (Shadow && Args.size() == 1 && Constructor->
getNumParams() >= 1 &&
6096 Candidate.
Viable =
false;
6108 if (TooManyArguments(NumParams, Args.size(), PartialOverloading) &&
6110 Candidate.
Viable =
false;
6121 if (Args.size() < MinRequiredArgs && !PartialOverloading) {
6123 Candidate.
Viable =
false;
6129 if (getLangOpts().CUDA)
6130 if (
const FunctionDecl *Caller = dyn_cast<FunctionDecl>(CurContext))
6135 if (!Caller->isImplicit() && !IsAllowedCUDACall(Caller, Function)) {
6136 Candidate.
Viable =
false;
6143 for (
unsigned ArgIdx = 0; ArgIdx < Args.size(); ++ArgIdx) {
6144 if (Candidate.
Conversions[ArgIdx].isInitialized()) {
6147 }
else if (ArgIdx < NumParams) {
6155 SuppressUserConversions,
6158 getLangOpts().ObjCAutoRefCount,
6161 Candidate.
Viable =
false;
6173 if (EnableIfAttr *FailedAttr = CheckEnableIf(Function, Args)) {
6174 Candidate.
Viable =
false;
6180 if (LangOpts.OpenCL && isOpenCLDisabledDecl(Function)) {
6181 Candidate.
Viable =
false;
6190 if (Methods.size() <= 1)
6193 for (
unsigned b = 0, e = Methods.size(); b < e; b++) {
6201 if (Args.size() < NumNamedArgs)
6204 for (
unsigned i = 0; i < NumNamedArgs; i++) {
6206 if (Args[i]->isTypeDependent()) {
6212 Expr *argExpr = Args[i];
6213 assert(argExpr &&
"SelectBestMethod(): missing expression");
6218 !param->
hasAttr<CFConsumedAttr>())
6219 argExpr = stripARCUnbridgedCast(argExpr);
6232 getLangOpts().ObjCAutoRefCount,
6236 if (ConversionState.
isBad() ||
6246 for (
unsigned i = NumNamedArgs, e = Args.size(); i < e; ++i) {
6247 if (Args[i]->isTypeDependent()) {
6251 ExprResult Arg = DefaultVariadicArgumentPromotion(Args[i], VariadicMethod,
6260 if (Args.size() != NumNamedArgs)
6262 else if (Match && NumNamedArgs == 0 && Methods.size() > 1) {
6265 for (
unsigned b = 0, e = Methods.size(); b < e; b++) {
6266 QualType ReturnT = Methods[b]->getReturnType();
6282 bool MissingImplicitThis,
Expr *&ConvertedThis,
6286 assert(!isa<CXXConstructorDecl>(Method) &&
6287 "Shouldn't have `this` for ctors!");
6288 assert(!Method->
isStatic() &&
"Shouldn't have `this` for static methods!");
6290 ThisArg,
nullptr, Method, Method);
6293 ConvertedThis = R.get();
6295 if (
auto *MD = dyn_cast<CXXMethodDecl>(Function)) {
6297 assert((MissingImplicitThis || MD->isStatic() ||
6298 isa<CXXConstructorDecl>(MD)) &&
6299 "Expected `this` for non-ctor instance methods");
6301 ConvertedThis =
nullptr;
6309 for (
unsigned I = 0; I != ArgSizeNoVarargs; ++I) {
6318 ConvertedArgs.push_back(R.
get());
6326 for (
unsigned i = Args.size(), e = Function->
getNumParams(); i != e; ++i) {
6341 ConvertedArgs.push_back(R.
get());
6351 bool MissingImplicitThis) {
6353 if (EnableIfAttrs.begin() == EnableIfAttrs.end())
6359 Expr *DiscardedThis;
6361 *
this, Function,
nullptr, Args, Trap,
6362 true, DiscardedThis, ConvertedArgs))
6363 return *EnableIfAttrs.begin();
6365 for (
auto *EIA : EnableIfAttrs) {
6369 if (!EIA->getCond()->EvaluateWithSubstitution(
6370 Result, Context, Function, llvm::makeArrayRef(ConvertedArgs)))
6373 if (!Result.
isInt() || !Result.
getInt().getBoolValue())
6379 template <
typename CheckFn>
6382 CheckFn &&IsSuccessful) {
6385 if (ArgDependent == DIA->getArgDependent())
6386 Attrs.push_back(DIA);
6393 auto WarningBegin = std::stable_partition(
6394 Attrs.begin(), Attrs.end(),
6395 [](
const DiagnoseIfAttr *DIA) {
return DIA->isError(); });
6399 auto ErrAttr = llvm::find_if(llvm::make_range(Attrs.begin(), WarningBegin),
6401 if (ErrAttr != WarningBegin) {
6402 const DiagnoseIfAttr *DIA = *ErrAttr;
6403 S.
Diag(Loc, diag::err_diagnose_if_succeeded) << DIA->getMessage();
6404 S.
Diag(DIA->getLocation(), diag::note_from_diagnose_if)
6405 << DIA->getParent() << DIA->getCond()->getSourceRange();
6409 for (
const auto *DIA : llvm::make_range(WarningBegin, Attrs.end()))
6410 if (IsSuccessful(DIA)) {
6411 S.
Diag(Loc, diag::warn_diagnose_if_succeeded) << DIA->getMessage();
6412 S.
Diag(DIA->getLocation(), diag::note_from_diagnose_if)
6413 << DIA->getParent() << DIA->getCond()->getSourceRange();
6420 const Expr *ThisArg,
6424 *
this, Function,
true, Loc,
6425 [&](
const DiagnoseIfAttr *DIA) {
6430 if (!DIA->getCond()->EvaluateWithSubstitution(
6431 Result, Context, cast<FunctionDecl>(DIA->getParent()), Args, ThisArg))
6433 return Result.
isInt() && Result.
getInt().getBoolValue();
6440 *
this, ND,
false, Loc,
6441 [&](
const DiagnoseIfAttr *DIA) {
6443 return DIA->getCond()->EvaluateAsBooleanCondition(Result, Context) &&
6454 bool SuppressUserConversions,
6455 bool PartialOverloading,
6456 bool FirstArgumentIsBase) {
6465 if (isa<CXXMethodDecl>(FD) && !cast<CXXMethodDecl>(FD)->isStatic()) {
6468 if (Args.size() > 0) {
6469 if (
Expr *E = Args[0]) {
6471 ObjectType = E->getType();
6477 ObjectClassification = E->Classify(Context);
6479 FunctionArgs = Args.slice(1);
6482 AddMethodTemplateCandidate(
6483 FunTmpl, F.getPair(),
6485 ExplicitTemplateArgs, ObjectType, ObjectClassification,
6486 FunctionArgs, CandidateSet, SuppressUserConversions,
6487 PartialOverloading);
6489 AddMethodCandidate(cast<CXXMethodDecl>(FD), F.getPair(),
6490 cast<CXXMethodDecl>(FD)->getParent(), ObjectType,
6491 ObjectClassification, FunctionArgs, CandidateSet,
6492 SuppressUserConversions, PartialOverloading);
6499 if (Args.size() > 0 &&
6500 (!Args[0] || (FirstArgumentIsBase && isa<CXXMethodDecl>(FD) &&
6501 !isa<CXXConstructorDecl>(FD)))) {
6502 assert(cast<CXXMethodDecl>(FD)->isStatic());
6503 FunctionArgs = Args.slice(1);
6506 AddTemplateOverloadCandidate(
6507 FunTmpl, F.getPair(), ExplicitTemplateArgs, FunctionArgs,
6508 CandidateSet, SuppressUserConversions, PartialOverloading);
6510 AddOverloadCandidate(FD, F.getPair(), FunctionArgs, CandidateSet,
6511 SuppressUserConversions, PartialOverloading);
6524 bool SuppressUserConversions) {
6528 if (isa<UsingShadowDecl>(Decl))
6529 Decl = cast<UsingShadowDecl>(Decl)->getTargetDecl();
6532 assert(isa<CXXMethodDecl>(TD->getTemplatedDecl()) &&
6533 "Expected a member function template");
6534 AddMethodTemplateCandidate(TD, FoundDecl, ActingContext,
6535 nullptr, ObjectType,
6536 ObjectClassification, Args, CandidateSet,
6537 SuppressUserConversions);
6539 AddMethodCandidate(cast<CXXMethodDecl>(Decl), FoundDecl, ActingContext,
6540 ObjectType, ObjectClassification, Args, CandidateSet,
6541 SuppressUserConversions);
6558 bool SuppressUserConversions,
6559 bool PartialOverloading,
6563 assert(Proto &&
"Methods without a prototype cannot be overloaded");
6564 assert(!isa<CXXConstructorDecl>(Method) &&
6565 "Use AddOverloadCandidate for constructors");
6583 CandidateSet.
addCandidate(Args.size() + 1, EarlyConversions);
6595 if (TooManyArguments(NumParams, Args.size(), PartialOverloading) &&
6597 Candidate.
Viable =
false;
6608 if (Args.size() < MinRequiredArgs && !PartialOverloading) {
6610 Candidate.
Viable =
false;
6624 *
this, CandidateSet.
getLocation(), ObjectType, ObjectClassification,
6625 Method, ActingContext);
6627 Candidate.
Viable =
false;
6634 if (getLangOpts().CUDA)
6635 if (
const FunctionDecl *Caller = dyn_cast<FunctionDecl>(CurContext))
6636 if (!IsAllowedCUDACall(Caller, Method)) {
6637 Candidate.Viable =
false;
6644 for (
unsigned ArgIdx = 0; ArgIdx < Args.size(); ++ArgIdx) {
6645 if (Candidate.Conversions[ArgIdx + 1].isInitialized()) {
6648 }
else if (ArgIdx < NumParams) {
6653 QualType ParamType = Proto->getParamType(ArgIdx);
6654 Candidate.Conversions[ArgIdx + 1]
6656 SuppressUserConversions,
6659 getLangOpts().ObjCAutoRefCount);
6660 if (Candidate.Conversions[ArgIdx + 1].isBad()) {
6661 Candidate.Viable =
false;
6669 Candidate.Conversions[ArgIdx + 1].setEllipsis();
6673 if (EnableIfAttr *FailedAttr = CheckEnableIf(Method, Args,
true)) {
6674 Candidate.Viable =
false;
6676 Candidate.DeductionFailure.Data = FailedAttr;
6680 if (Method->isMultiVersion() && Method->hasAttr<TargetAttr>() &&
6681 !Method->getAttr<TargetAttr>()->isDefaultVersion()) {
6682 Candidate.Viable =
false;
6699 bool SuppressUserConversions,
6700 bool PartialOverloading) {
6717 MethodTmpl, ExplicitTemplateArgs, Args, Specialization, Info,
6719 return CheckNonDependentConversions(
6720 MethodTmpl, ParamTypes, Args, CandidateSet, Conversions,
6721 SuppressUserConversions, ActingContext, ObjectType,
6722 ObjectClassification);
6725 CandidateSet.
addCandidate(Conversions.size(), Conversions);
6728 Candidate.
Viable =
false;
6731 cast<CXXMethodDecl>(Candidate.
Function)->isStatic() ||
6734 if (Result == TDK_NonDependentConversionFailure)
6746 assert(Specialization &&
"Missing member function template specialization?");
6747 assert(isa<CXXMethodDecl>(Specialization) &&
6748 "Specialization is not a member function?");
6749 AddMethodCandidate(cast<CXXMethodDecl>(Specialization), FoundDecl,
6750 ActingContext, ObjectType, ObjectClassification, Args,
6751 CandidateSet, SuppressUserConversions, PartialOverloading,
6762 bool PartialOverloading,
ADLCallKind IsADLCandidate) {
6779 FunctionTemplate, ExplicitTemplateArgs, Args, Specialization, Info,
6781 return CheckNonDependentConversions(FunctionTemplate, ParamTypes,
6782 Args, CandidateSet, Conversions,
6783 SuppressUserConversions);
6786 CandidateSet.
addCandidate(Conversions.size(), Conversions);
6789 Candidate.
Viable =
false;
6795 isa<CXXMethodDecl>(Candidate.
Function) &&
6796 !isa<CXXConstructorDecl>(Candidate.
Function);
6798 if (Result == TDK_NonDependentConversionFailure)
6810 assert(Specialization &&
"Missing function template specialization?");
6811 AddOverloadCandidate(Specialization, FoundDecl, Args, CandidateSet,
6812 SuppressUserConversions, PartialOverloading,
6813 false, IsADLCandidate, Conversions);
6828 const bool AllowExplicit =
false;
6832 bool HasThisConversion = Method && !isa<CXXConstructorDecl>(Method);
6833 unsigned ThisConversions = HasThisConversion ? 1 : 0;
6845 if (HasThisConversion && !cast<CXXMethodDecl>(FD)->isStatic() &&
6848 *
this, CandidateSet.
getLocation(), ObjectType, ObjectClassification,
6849 Method, ActingContext);
6850 if (Conversions[0].isBad())
6854 for (
unsigned I = 0, N =
std::min(ParamTypes.size(), Args.size()); I != N;
6856 QualType ParamType = ParamTypes[I];
6858 Conversions[ThisConversions + I]
6860 SuppressUserConversions,
6863 getLangOpts().ObjCAutoRefCount,
6865 if (Conversions[ThisConversions + I].isBad())
6887 bool AllowObjCPointerConversion) {
6895 bool ObjCLifetimeConversion;
6897 ObjCLifetimeConversion))
6902 if (!AllowObjCPointerConversion)
6906 bool IncompatibleObjC =
false;
6924 bool AllowObjCConversionOnExplicit,
6925 bool AllowResultConversion) {
6927 "Conversion function templates use AddTemplateConversionCandidate");
6934 if (getLangOpts().CPlusPlus14 && ConvType->isUndeducedType()) {
6935 if (DeduceReturnType(Conversion, From->
getExprLoc()))
6942 if (!AllowResultConversion &&
6951 AllowObjCConversionOnExplicit))
6981 = cast<CXXRecordDecl>(ImplicitParamType->
getAs<
RecordType>()->getDecl());
6985 From->
Classify(Context), Conversion, ConversionContext);
6988 Candidate.
Viable =
false;
6999 if (FromCanon == ToCanon ||
7000 IsDerivedFrom(CandidateSet.
getLocation(), FromCanon, ToCanon)) {
7001 Candidate.
Viable =
false;
7018 CK_FunctionToPointerDecay,
7022 if (!isCompleteType(From->
getBeginLoc(), ConversionType)) {
7023 Candidate.
Viable =
false;
7035 llvm::AlignedCharArray<alignof(CallExpr), sizeof(CallExpr) + sizeof(Stmt *)>
7038 Buffer.buffer, &ConversionFn, CallResultType, VK, From->
getBeginLoc());
7046 switch (ICS.getKind()) {
7056 Candidate.
Viable =
false;
7068 Candidate.
Viable =
false;
7075 Candidate.
Viable =
false;
7081 "Can only end up with a standard conversion sequence or failure");
7084 if (EnableIfAttr *FailedAttr = CheckEnableIf(Conversion, None)) {
7085 Candidate.
Viable =
false;
7092 !Conversion->
getAttr<TargetAttr>()->isDefaultVersion()) {
7093 Candidate.
Viable =
false;
7109 bool AllowObjCConversionOnExplicit,
7110 bool AllowResultConversion) {
7112 "Only conversion function templates permitted here");
7121 Specialization, Info)) {
7125 Candidate.
Viable =
false;
7137 assert(Specialization &&
"Missing function template specialization?");
7138 AddConversionCandidate(Specialization, FoundDecl, ActingDC, From, ToType,
7139 CandidateSet, AllowObjCConversionOnExplicit,
7140 AllowResultConversion);
7175 Object->
Classify(Context), Conversion, ActingContext);
7176 if (ObjectInit.
isBad()) {
7177 Candidate.
Viable =
false;
7188 Candidate.
Conversions[0].UserDefined.EllipsisConversion =
false;
7189 Candidate.
Conversions[0].UserDefined.HadMultipleCandidates =
false;
7190 Candidate.
Conversions[0].UserDefined.ConversionFunction = Conversion;
7191 Candidate.
Conversions[0].UserDefined.FoundConversionFunction = FoundDecl;
7194 Candidate.
Conversions[0].UserDefined.After.setAsIdentityConversion();
7202 if (Args.size() > NumParams && !Proto->
isVariadic()) {
7203 Candidate.
Viable =
false;
7210 if (Args.size() < NumParams) {
7212 Candidate.
Viable =
false;
7219 for (
unsigned ArgIdx = 0, N = Args.size(); ArgIdx != N; ++ArgIdx) {
7220 if (ArgIdx < NumParams) {
7231 getLangOpts().ObjCAutoRefCount);
7233 Candidate.
Viable =
false;
7245 if (EnableIfAttr *FailedAttr = CheckEnableIf(Conversion, None)) {
7246 Candidate.
Viable =
false;
7284 if (!isCompleteType(OpLoc, T1) && !T1Rec->isBeingDefined())
7287 if (!T1Rec->getDecl()->getDefinition())
7290 LookupResult Operators(*
this, OpName, OpLoc, LookupOrdinaryName);
7291 LookupQualifiedName(Operators, T1Rec->getDecl());
7295 OperEnd = Operators.
end();
7298 AddMethodCandidate(Oper.getPair(), Args[0]->getType(),
7299 Args[0]->Classify(Context), Args.slice(1),
7300 CandidateSet,
false);
7314 bool IsAssignmentOperator,
7315 unsigned NumContextualBoolArguments) {
7332 for (
unsigned ArgIdx = 0, N = Args.size(); ArgIdx != N; ++ArgIdx) {
7345 if (ArgIdx < NumContextualBoolArguments) {
7346 assert(ParamTys[ArgIdx] == Context.
BoolTy &&
7347 "Contextual conversion to bool requires bool type");
7353 ArgIdx == 0 && IsAssignmentOperator,
7356 getLangOpts().ObjCAutoRefCount);
7359 Candidate.
Viable =
false;
7372 class BuiltinCandidateTypeSet {
7374 typedef llvm::SetVector<QualType, SmallVector<QualType, 8>,
7375 llvm::SmallPtrSet<QualType, 8>> TypeSet;
7379 TypeSet PointerTypes;
7383 TypeSet MemberPointerTypes;
7387 TypeSet EnumerationTypes;
7391 TypeSet VectorTypes;
7394 bool HasNonRecordTypes;
7398 bool HasArithmeticOrEnumeralTypes;
7402 bool HasNullPtrType;
7411 bool AddPointerWithMoreQualifiedTypeVariants(
QualType Ty,
7413 bool AddMemberPointerWithMoreQualifiedTypeVariants(
QualType Ty);
7417 typedef TypeSet::iterator iterator;
7419 BuiltinCandidateTypeSet(
Sema &SemaRef)
7420 : HasNonRecordTypes(
false),
7421 HasArithmeticOrEnumeralTypes(
false),
7422 HasNullPtrType(
false),
7426 void AddTypesConvertedFrom(
QualType Ty,
7428 bool AllowUserConversions,
7429 bool AllowExplicitConversions,
7430 const Qualifiers &VisibleTypeConversionsQuals);
7433 iterator pointer_begin() {
return PointerTypes.begin(); }
7436 iterator pointer_end() {
return PointerTypes.end(); }
7439 iterator member_pointer_begin() {
return MemberPointerTypes.begin(); }
7442 iterator member_pointer_end() {
return MemberPointerTypes.end(); }
7445 iterator enumeration_begin() {
return EnumerationTypes.begin(); }
7448 iterator enumeration_end() {
return EnumerationTypes.end(); }
7450 iterator vector_begin() {
return VectorTypes.begin(); }
7451 iterator vector_end() {
return VectorTypes.end(); }
7453 bool hasNonRecordTypes() {
return HasNonRecordTypes; }
7454 bool hasArithmeticOrEnumeralTypes() {
return HasArithmeticOrEnumeralTypes; }
7455 bool hasNullPtrType()
const {
return HasNullPtrType; }
7470 BuiltinCandidateTypeSet::AddPointerWithMoreQualifiedTypeVariants(
QualType Ty,
7474 if (!PointerTypes.insert(Ty))
7479 bool buildObjCPtr =
false;
7483 buildObjCPtr =
true;
7501 if ((CVR | BaseCVR) != CVR)
continue;
7523 PointerTypes.insert(QPointerTy);
7539 BuiltinCandidateTypeSet::AddMemberPointerWithMoreQualifiedTypeVariants(
7542 if (!MemberPointerTypes.insert(Ty))
7546 assert(PointerTy &&
"type was not a member pointer type!");
7561 if ((CVR | BaseCVR) != CVR)
continue;
7564 MemberPointerTypes.insert(
7580 BuiltinCandidateTypeSet::AddTypesConvertedFrom(
QualType Ty,
7582 bool AllowUserConversions,
7583 bool AllowExplicitConversions,
7595 Ty = SemaRef.Context.getArrayDecayedType(Ty);
7602 HasNonRecordTypes = HasNonRecordTypes || !TyRec;
7605 HasArithmeticOrEnumeralTypes =
7609 PointerTypes.insert(Ty);
7613 if (!AddPointerWithMoreQualifiedTypeVariants(Ty, VisibleQuals))
7617 if (!AddMemberPointerWithMoreQualifiedTypeVariants(Ty))
7620 HasArithmeticOrEnumeralTypes =
true;
7621 EnumerationTypes.insert(Ty);
7625 HasArithmeticOrEnumeralTypes =
true;
7626 VectorTypes.insert(Ty);
7628 HasNullPtrType =
true;
7629 }
else if (AllowUserConversions && TyRec) {
7631 if (!SemaRef.isCompleteType(Loc, Ty))
7636 if (isa<UsingShadowDecl>(D))
7637 D = cast<UsingShadowDecl>(D)->getTargetDecl();
7641 if (isa<FunctionTemplateDecl>(D))
7645 if (AllowExplicitConversions || !Conv->
isExplicit()) {
7700 if (isa<UsingShadowDecl>(D))
7701 D = cast<UsingShadowDecl>(D)->getTargetDecl();
7735 class BuiltinOperatorOverloadBuilder {
7740 bool HasArithmeticOrEnumeralCandidateType;
7744 static constexpr
int ArithmeticTypesCap = 24;
7750 unsigned FirstIntegralType,
7752 unsigned FirstPromotedIntegralType,
7753 LastPromotedIntegralType;
7754 unsigned FirstPromotedArithmeticType,
7755 LastPromotedArithmeticType;
7756 unsigned NumArithmeticTypes;
7758 void InitArithmeticTypes() {
7760 FirstPromotedArithmeticType = 0;
7768 FirstIntegralType = ArithmeticTypes.size();
7769 FirstPromotedIntegralType = ArithmeticTypes.size();
7780 LastPromotedIntegralType = ArithmeticTypes.size();
7781 LastPromotedArithmeticType = ArithmeticTypes.size();
7795 LastIntegralType = ArithmeticTypes.size();
7796 NumArithmeticTypes = ArithmeticTypes.size();
7800 assert(ArithmeticTypes.size() <= ArithmeticTypesCap &&
7801 "Enough inline storage for all arithmetic types.");
7806 void addPlusPlusMinusMinusStyleOverloads(
QualType CandidateTy,
7848 BuiltinOperatorOverloadBuilder(
7851 bool HasArithmeticOrEnumeralCandidateType,
7855 VisibleTypeConversionsQuals(VisibleTypeConversionsQuals),
7856 HasArithmeticOrEnumeralCandidateType(
7857 HasArithmeticOrEnumeralCandidateType),
7858 CandidateTypes(CandidateTypes),
7859 CandidateSet(CandidateSet) {
7861 InitArithmeticTypes();
7884 if (!HasArithmeticOrEnumeralCandidateType)
7887 for (
unsigned Arith = 0; Arith < NumArithmeticTypes; ++Arith) {
7888 const auto TypeOfT = ArithmeticTypes[Arith];
7890 if (Op == OO_MinusMinus)
7892 if (Op == OO_PlusPlus && S.
getLangOpts().CPlusPlus17)
7895 addPlusPlusMinusMinusStyleOverloads(
7912 void addPlusPlusMinusMinusPointerOverloads() {
7913 for (BuiltinCandidateTypeSet::iterator
7914 Ptr = CandidateTypes[0].pointer_begin(),
7915 PtrEnd = CandidateTypes[0].pointer_end();
7916 Ptr != PtrEnd; ++Ptr) {
7918 if (!(*Ptr)->getPointeeType()->isObjectType())
7921 addPlusPlusMinusMinusStyleOverloads(*Ptr,
7922 (!(*Ptr).isVolatileQualified() &&
7924 (!(*Ptr).isRestrictQualified() &&
7939 void addUnaryStarPointerOverloads() {
7940 for (BuiltinCandidateTypeSet::iterator
7941 Ptr = CandidateTypes[0].pointer_begin(),
7942 PtrEnd = CandidateTypes[0].pointer_end();
7943 Ptr != PtrEnd; ++Ptr) {
7950 if (Proto->getTypeQuals() || Proto->getRefQualifier())
7963 void addUnaryPlusOrMinusArithmeticOverloads() {
7964 if (!HasArithmeticOrEnumeralCandidateType)
7967 for (
unsigned Arith = FirstPromotedArithmeticType;
7968 Arith < LastPromotedArithmeticType; ++Arith) {
7969 QualType ArithTy = ArithmeticTypes[Arith];
7974 for (BuiltinCandidateTypeSet::iterator
7975 Vec = CandidateTypes[0].vector_begin(),
7976 VecEnd = CandidateTypes[0].vector_end();
7977 Vec != VecEnd; ++Vec) {
7988 void addUnaryPlusPointerOverloads() {
7989 for (BuiltinCandidateTypeSet::iterator
7990 Ptr = CandidateTypes[0].pointer_begin(),
7991 PtrEnd = CandidateTypes[0].pointer_end();
7992 Ptr != PtrEnd; ++Ptr) {
8003 void addUnaryTildePromotedIntegralOverloads() {
8004 if (!HasArithmeticOrEnumeralCandidateType)
8007 for (
unsigned Int = FirstPromotedIntegralType;
8008 Int < LastPromotedIntegralType; ++Int) {
8009 QualType IntTy = ArithmeticTypes[Int];
8014 for (BuiltinCandidateTypeSet::iterator
8015 Vec = CandidateTypes[0].vector_begin(),
8016 VecEnd = CandidateTypes[0].vector_end();
8017 Vec != VecEnd; ++Vec) {
8029 void addEqualEqualOrNotEqualMemberPointerOrNullptrOverloads() {
8031 llvm::SmallPtrSet<QualType, 8> AddedTypes;
8033 for (
unsigned ArgIdx = 0, N = Args.size(); ArgIdx != N; ++ArgIdx) {
8034 for (BuiltinCandidateTypeSet::iterator
8035 MemPtr = CandidateTypes[ArgIdx].member_pointer_begin(),
8036 MemPtrEnd = CandidateTypes[ArgIdx].member_pointer_end();
8037 MemPtr != MemPtrEnd;
8043 QualType ParamTypes[2] = { *MemPtr, *MemPtr };
8047 if (CandidateTypes[ArgIdx].hasNullPtrType()) {
8049 if (AddedTypes.insert(NullPtrTy).second) {
8050 QualType ParamTypes[2] = { NullPtrTy, NullPtrTy };
8069 void addGenericBinaryPointerOrEnumeralOverloads() {
8083 UserDefinedBinaryOperators;
8085 for (
unsigned ArgIdx = 0, N = Args.size(); ArgIdx != N; ++ArgIdx) {
8086 if (CandidateTypes[ArgIdx].enumeration_begin() !=
8087 CandidateTypes[ArgIdx].enumeration_end()) {
8089 CEnd = CandidateSet.
end();
8091 if (!C->Viable || !C->Function || C->Function->getNumParams() != 2)
8094 if (C->Function->isFunctionTemplateSpecialization())
8098 C->Function->getParamDecl(0)->getType().getUnqualifiedType();
8100 C->Function->getParamDecl(1)->getType().getUnqualifiedType();
8108 UserDefinedBinaryOperators.insert(
8116 llvm::SmallPtrSet<QualType, 8> AddedTypes;
8118 for (
unsigned ArgIdx = 0, N = Args.size(); ArgIdx != N; ++ArgIdx) {
8119 for (BuiltinCandidateTypeSet::iterator
8120 Ptr = CandidateTypes[ArgIdx].pointer_begin(),
8121 PtrEnd = CandidateTypes[ArgIdx].pointer_end();
8122 Ptr != PtrEnd; ++Ptr) {
8127 QualType ParamTypes[2] = { *Ptr, *Ptr };
8130 for (BuiltinCandidateTypeSet::iterator
8131 Enum = CandidateTypes[ArgIdx].enumeration_begin(),
8132 EnumEnd = CandidateTypes[ArgIdx].enumeration_end();
8133 Enum != EnumEnd; ++Enum) {
8138 if (!AddedTypes.insert(CanonType).second ||
8139 UserDefinedBinaryOperators.count(std::make_pair(CanonType,
8142 QualType ParamTypes[2] = { *Enum, *Enum };
8167 llvm::SmallPtrSet<QualType, 8> AddedTypes;
8169 for (
int Arg = 0; Arg < 2; ++Arg) {
8170 QualType AsymmetricParamTypes[2] = {
8174 for (BuiltinCandidateTypeSet::iterator
8175 Ptr = CandidateTypes[Arg].pointer_begin(),
8176 PtrEnd = CandidateTypes[Arg].pointer_end();
8177 Ptr != PtrEnd; ++Ptr) {
8182 AsymmetricParamTypes[Arg] = *Ptr;
8183 if (Arg == 0 || Op == OO_Plus) {
8188 if (Op == OO_Minus) {
8193 QualType ParamTypes[2] = { *Ptr, *Ptr };
8229 void addGenericBinaryArithmeticOverloads() {
8230 if (!HasArithmeticOrEnumeralCandidateType)
8233 for (
unsigned Left = FirstPromotedArithmeticType;
8234 Left < LastPromotedArithmeticType; ++Left) {
8235 for (
unsigned Right = FirstPromotedArithmeticType;
8236 Right < LastPromotedArithmeticType; ++Right) {
8237 QualType LandR[2] = { ArithmeticTypes[Left],
8238 ArithmeticTypes[Right] };
8245 for (BuiltinCandidateTypeSet::iterator
8246 Vec1 = CandidateTypes[0].vector_begin(),
8247 Vec1End = CandidateTypes[0].vector_end();
8248 Vec1 != Vec1End; ++Vec1) {
8249 for (BuiltinCandidateTypeSet::iterator
8250 Vec2 = CandidateTypes[1].vector_begin(),
8251 Vec2End = CandidateTypes[1].vector_end();
8252 Vec2 != Vec2End; ++Vec2) {
8253 QualType LandR[2] = { *Vec1, *Vec2 };
8290 void addThreeWayArithmeticOverloads() {
8291 addGenericBinaryArithmeticOverloads();
8309 if (!HasArithmeticOrEnumeralCandidateType)
8312 for (
unsigned Left = FirstPromotedIntegralType;
8313 Left < LastPromotedIntegralType; ++Left) {
8314 for (
unsigned Right = FirstPromotedIntegralType;
8315 Right < LastPromotedIntegralType; ++Right) {
8316 QualType LandR[2] = { ArithmeticTypes[Left],
8317 ArithmeticTypes[Right] };
8330 void addAssignmentMemberPointerOrEnumeralOverloads() {
8332 llvm::SmallPtrSet<QualType, 8> AddedTypes;
8334 for (
unsigned ArgIdx = 0; ArgIdx < 2; ++ArgIdx) {
8335 for (BuiltinCandidateTypeSet::iterator
8336 Enum = CandidateTypes[ArgIdx].enumeration_begin(),
8337 EnumEnd = CandidateTypes[ArgIdx].enumeration_end();
8338 Enum != EnumEnd; ++Enum) {
8345 for (BuiltinCandidateTypeSet::iterator
8346 MemPtr = CandidateTypes[ArgIdx].member_pointer_begin(),
8347 MemPtrEnd = CandidateTypes[ArgIdx].member_pointer_end();
8348 MemPtr != MemPtrEnd; ++MemPtr) {
8373 void addAssignmentPointerOverloads(
bool isEqualOp) {
8375 llvm::SmallPtrSet<QualType, 8> AddedTypes;
8377 for (BuiltinCandidateTypeSet::iterator
8378 Ptr = CandidateTypes[0].pointer_begin(),
8379 PtrEnd = CandidateTypes[0].pointer_end();
8380 Ptr != PtrEnd; ++Ptr) {
8384 else if (!(*Ptr)->getPointeeType()->isObjectType())
8395 bool NeedVolatile = !(*Ptr).isVolatileQualified() &&
8405 if (!(*Ptr).isRestrictQualified() &&
8427 for (BuiltinCandidateTypeSet::iterator
8428 Ptr = CandidateTypes[1].pointer_begin(),
8429 PtrEnd = CandidateTypes[1].pointer_end();
8430 Ptr != PtrEnd; ++Ptr) {
8444 bool NeedVolatile = !(*Ptr).isVolatileQualified() &&
8454 if (!(*Ptr).isRestrictQualified() &&
8489 void addAssignmentArithmeticOverloads(
bool isEqualOp) {
8490 if (!HasArithmeticOrEnumeralCandidateType)
8493 for (
unsigned Left = 0; Left < NumArithmeticTypes; ++Left) {
8494 for (
unsigned Right = FirstPromotedArithmeticType;
8495 Right < LastPromotedArithmeticType; ++Right) {
8497 ParamTypes[1] = ArithmeticTypes[Right];
8517 for (BuiltinCandidateTypeSet::iterator
8518 Vec1 = CandidateTypes[0].vector_begin(),
8519 Vec1End = CandidateTypes[0].vector_end();
8520 Vec1 != Vec1End; ++Vec1) {
8521 for (BuiltinCandidateTypeSet::iterator
8522 Vec2 = CandidateTypes[1].vector_begin(),
8523 Vec2End = CandidateTypes[1].vector_end();
8524 Vec2 != Vec2End; ++Vec2) {
8526 ParamTypes[1] = *Vec2;
8555 void addAssignmentIntegralOverloads() {
8556 if (!HasArithmeticOrEnumeralCandidateType)
8559 for (
unsigned Left = FirstIntegralType; Left < LastIntegralType; ++Left) {
8560 for (
unsigned Right = FirstPromotedIntegralType;
8561 Right < LastPromotedIntegralType; ++Right) {
8563 ParamTypes[1] = ArithmeticTypes[Right];
8571 ParamTypes[0] = ArithmeticTypes[Left];
8587 void addExclaimOverload() {
8593 void addAmpAmpOrPipePipeOverload() {
8610 void addSubscriptOverloads() {
8611 for (BuiltinCandidateTypeSet::iterator
8612 Ptr = CandidateTypes[0].pointer_begin(),
8613 PtrEnd = CandidateTypes[0].pointer_end();
8614 Ptr != PtrEnd; ++Ptr) {
8624 for (BuiltinCandidateTypeSet::iterator
8625 Ptr = CandidateTypes[1].pointer_begin(),
8626 PtrEnd = CandidateTypes[1].pointer_end();
8627 Ptr != PtrEnd; ++Ptr) {
8647 void addArrowStarOverloads() {
8648 for (BuiltinCandidateTypeSet::iterator
8649 Ptr = CandidateTypes[0].pointer_begin(),
8650 PtrEnd = CandidateTypes[0].pointer_end();
8651 Ptr != PtrEnd; ++Ptr) {
8656 if (!isa<RecordType>(C1))
8665 for (BuiltinCandidateTypeSet::iterator
8666 MemPtr = CandidateTypes[1].member_pointer_begin(),
8667 MemPtrEnd = CandidateTypes[1].member_pointer_end();
8668 MemPtr != MemPtrEnd; ++MemPtr) {
8674 QualType ParamTypes[2] = { *Ptr, *MemPtr };
8699 void addConditionalOperatorOverloads() {
8701 llvm::SmallPtrSet<QualType, 8> AddedTypes;
8703 for (
unsigned ArgIdx = 0; ArgIdx < 2; ++ArgIdx) {
8704 for (BuiltinCandidateTypeSet::iterator
8705 Ptr = CandidateTypes[ArgIdx].pointer_begin(),
8706 PtrEnd = CandidateTypes[ArgIdx].pointer_end();
8707 Ptr != PtrEnd; ++Ptr) {
8711 QualType ParamTypes[2] = { *Ptr, *Ptr };
8715 for (BuiltinCandidateTypeSet::iterator
8716 MemPtr = CandidateTypes[ArgIdx].member_pointer_begin(),
8717 MemPtrEnd = CandidateTypes[ArgIdx].member_pointer_end();
8718 MemPtr != MemPtrEnd; ++MemPtr) {
8722 QualType ParamTypes[2] = { *MemPtr, *MemPtr };
8727 for (BuiltinCandidateTypeSet::iterator
8728 Enum = CandidateTypes[ArgIdx].enumeration_begin(),
8729 EnumEnd = CandidateTypes[ArgIdx].enumeration_end();
8730 Enum != EnumEnd; ++Enum) {
8737 QualType ParamTypes[2] = { *Enum, *Enum };
8761 VisibleTypeConversionsQuals.
addConst();
8762 for (
unsigned ArgIdx = 0, N = Args.size(); ArgIdx != N; ++ArgIdx)
8765 bool HasNonRecordCandidateType =
false;
8766 bool HasArithmeticOrEnumeralCandidateType =
false;
8768 for (
unsigned ArgIdx = 0, N = Args.size(); ArgIdx != N; ++ArgIdx) {
8769 CandidateTypes.emplace_back(*
this);
8770 CandidateTypes[ArgIdx].AddTypesConvertedFrom(Args[ArgIdx]->getType(),
8773 (Op == OO_Exclaim ||
8776 VisibleTypeConversionsQuals);
8777 HasNonRecordCandidateType = HasNonRecordCandidateType ||
8778 CandidateTypes[ArgIdx].hasNonRecordTypes();
8779 HasArithmeticOrEnumeralCandidateType =
8780 HasArithmeticOrEnumeralCandidateType ||
8781 CandidateTypes[ArgIdx].hasArithmeticOrEnumeralTypes();
8789 if (!HasNonRecordCandidateType &&
8790 !(Op == OO_Exclaim || Op == OO_AmpAmp || Op == OO_PipePipe))
8794 BuiltinOperatorOverloadBuilder OpBuilder(*
this, Args,
8795 VisibleTypeConversionsQuals,
8796 HasArithmeticOrEnumeralCandidateType,
8797 CandidateTypes, CandidateSet);
8803 llvm_unreachable(
"Expected an overloaded operator");
8808 case OO_Array_Delete:
8811 "Special operators don't use AddBuiltinOperatorCandidates");
8823 if (Args.size() == 1)
8824 OpBuilder.addUnaryPlusPointerOverloads();
8828 if (Args.size() == 1) {
8829 OpBuilder.addUnaryPlusOrMinusArithmeticOverloads();
8831 OpBuilder.addBinaryPlusOrMinusPointerOverloads(Op);
8832 OpBuilder.addGenericBinaryArithmeticOverloads();
8837 if (Args.size() == 1)
8838 OpBuilder.addUnaryStarPointerOverloads();
8840 OpBuilder.addGenericBinaryArithmeticOverloads();
8844 OpBuilder.addGenericBinaryArithmeticOverloads();
8849 OpBuilder.addPlusPlusMinusMinusArithmeticOverloads(Op);
8850 OpBuilder.addPlusPlusMinusMinusPointerOverloads();
8854 case OO_ExclaimEqual:
8855 OpBuilder.addEqualEqualOrNotEqualMemberPointerOrNullptrOverloads();
8861 case OO_GreaterEqual:
8862 OpBuilder.addGenericBinaryPointerOrEnumeralOverloads();
8863 OpBuilder.addGenericBinaryArithmeticOverloads();
8867 OpBuilder.addGenericBinaryPointerOrEnumeralOverloads();
8868 OpBuilder.addThreeWayArithmeticOverloads();
8875 case OO_GreaterGreater:
8876 OpBuilder.addBinaryBitwiseArithmeticOverloads(Op);
8880 if (Args.size() == 1)
8886 OpBuilder.addBinaryBitwiseArithmeticOverloads(Op);
8890 OpBuilder.addUnaryTildePromotedIntegralOverloads();
8894 OpBuilder.addAssignmentMemberPointerOrEnumeralOverloads();
8899 OpBuilder.addAssignmentPointerOverloads(Op == OO_Equal);
8904 OpBuilder.addAssignmentArithmeticOverloads(Op == OO_Equal);
8907 case OO_PercentEqual:
8908 case OO_LessLessEqual:
8909 case OO_GreaterGreaterEqual:
8913 OpBuilder.addAssignmentIntegralOverloads();
8917 OpBuilder.addExclaimOverload();
8922 OpBuilder.addAmpAmpOrPipePipeOverload();
8926 OpBuilder.addSubscriptOverloads();
8930 OpBuilder.addArrowStarOverloads();
8933 case OO_Conditional:
8934 OpBuilder.addConditionalOperatorOverloads();
8935 OpBuilder.addGenericBinaryArithmeticOverloads();
8953 bool PartialOverloading) {
8964 ArgumentDependentLookup(Name, Loc, Args, Fns);
8968 CandEnd = CandidateSet.
end();
8969 Cand != CandEnd; ++Cand)
8970 if (Cand->Function) {
8971 Fns.
erase(Cand->Function);
8982 if (ExplicitTemplateArgs)
8985 AddOverloadCandidate(FD, FoundDecl, Args, CandidateSet,
8986 false, PartialOverloading,
8987 false, ADLCallKind::UsesADL);
8989 AddTemplateOverloadCandidate(cast<FunctionTemplateDecl>(*I), FoundDecl,
8990 ExplicitTemplateArgs, Args, CandidateSet,
8992 PartialOverloading, ADLCallKind::UsesADL);
9015 bool Cand1Attr = Cand1->
hasAttr<EnableIfAttr>();
9016 bool Cand2Attr = Cand2->
hasAttr<EnableIfAttr>();
9017 if (!Cand1Attr || !Cand2Attr) {
9018 if (Cand1Attr == Cand2Attr)
9020 return Cand1Attr ? Comparison::Better : Comparison::Worse;
9026 llvm::FoldingSetNodeID Cand1ID, Cand2ID;
9027 for (
auto Pair : zip_longest(Cand1Attrs, Cand2Attrs)) {
9034 return Comparison::Worse;
9036 return Comparison::Better;
9041 (*Cand1A)->getCond()->Profile(Cand1ID, S.
getASTContext(),
true);
9042 (*Cand2A)->getCond()->Profile(Cand2ID, S.
getASTContext(),
true);
9043 if (Cand1ID != Cand2ID)
9044 return Comparison::Worse;
9065 const auto *Cand1CPUSpec = Cand1.
Function->
getAttr<CPUSpecificAttr>();
9066 const auto *Cand2CPUSpec = Cand2.
Function->
getAttr<CPUSpecificAttr>();
9068 if (!Cand1CPUDisp && !Cand2CPUDisp && !Cand1CPUSpec && !Cand2CPUSpec)
9071 if (Cand1CPUDisp && !Cand2CPUDisp)
9073 if (Cand2CPUDisp && !Cand1CPUDisp)
9076 if (Cand1CPUSpec && Cand2CPUSpec) {
9077 if (Cand1CPUSpec->cpus_size() != Cand2CPUSpec->cpus_size())
9078 return Cand1CPUSpec->cpus_size() < Cand2CPUSpec->cpus_size();
9080 std::pair<CPUSpecificAttr::cpus_iterator, CPUSpecificAttr::cpus_iterator>
9081 FirstDiff = std::mismatch(
9082 Cand1CPUSpec->cpus_begin(), Cand1CPUSpec->cpus_end(),
9083 Cand2CPUSpec->cpus_begin(),
9085 return LHS->
getName() == RHS->getName();
9088 assert(FirstDiff.first != Cand1CPUSpec->cpus_end() &&
9089 "Two different cpu-specific versions should not have the same " 9090 "identifier list, otherwise they'd be the same decl!");
9091 return (*FirstDiff.first)->getName() < (*FirstDiff.second)->
getName();
9093 llvm_unreachable(
"No way to get here unless both had cpu_dispatch");
9114 unsigned StartArg = 0;
9121 return ICS.isStandard() &&
9133 assert(Cand2.
Conversions.size() == NumArgs &&
"Overload candidate mismatch");
9134 bool HasBetterConversion =
false;
9135 for (
unsigned ArgIdx = StartArg; ArgIdx < NumArgs; ++ArgIdx) {
9136 bool Cand1Bad = IsIllFormedConversion(Cand1.
Conversions[ArgIdx]);
9137 bool Cand2Bad = IsIllFormedConversion(Cand2.
Conversions[ArgIdx]);
9138 if (Cand1Bad != Cand2Bad) {
9141 HasBetterConversion =
true;
9145 if (HasBetterConversion)
9152 for (
unsigned ArgIdx = StartArg; ArgIdx < NumArgs; ++ArgIdx) {
9158 HasBetterConversion =
true;
9173 if (HasBetterConversion)
9184 isa<CXXConversionDecl>(Cand1.
Function) &&
9185 isa<CXXConversionDecl>(Cand2.
Function)) {
9213 isa<CXXConstructorDecl>(Cand1.
Function) !=
9214 isa<CXXConstructorDecl>(Cand2.
Function))
9215 return isa<CXXConstructorDecl>(Cand1.
Function);
9219 bool Cand1IsSpecialization = Cand1.
Function &&
9221 bool Cand2IsSpecialization = Cand2.
Function &&
9223 if (Cand1IsSpecialization != Cand2IsSpecialization)
9224 return Cand2IsSpecialization;
9230 if (Cand1IsSpecialization && Cand2IsSpecialization) {
9244 bool Cand1IsInherited =
9246 bool Cand2IsInherited =
9248 if (Cand1IsInherited != Cand2IsInherited)
9249 return Cand2IsInherited;
9250 else if (Cand1IsInherited) {
9251 assert(Cand2IsInherited);
9254 if (Cand1Class->isDerivedFrom(Cand2Class))
9256 if (Cand2Class->isDerivedFrom(Cand1Class))
9263 auto *Guide1 = dyn_cast_or_null<CXXDeductionGuideDecl>(Cand1.
Function);
9264 auto *Guide2 = dyn_cast_or_null<CXXDeductionGuideDecl>(Cand2.
Function);
9265 if (Guide1 && Guide2) {
9267 if (Guide1->isImplicit() != Guide2->isImplicit())
9268 return Guide2->isImplicit();
9271 if (Guide1->isCopyDeductionCandidate())
9280 return Cmp == Comparison::Better;
9289 bool HasPS1 = Cand1.
Function !=
nullptr &&
9291 bool HasPS2 = Cand2.
Function !=
nullptr &&
9293 if (HasPS1 != HasPS2 && HasPS1)
9308 auto *VA = dyn_cast_or_null<ValueDecl>(A);
9309 auto *VB = dyn_cast_or_null<ValueDecl>(B);
9315 if (!VA->getDeclContext()->getRedeclContext()->Equals(
9316 VB->getDeclContext()->getRedeclContext()) ||
9317 getOwningModule(const_cast<ValueDecl *>(VA)) ==
9318 getOwningModule(const_cast<ValueDecl *>(VB)) ||
9319 VA->isExternallyVisible() || VB->isExternallyVisible())
9327 if (Context.
hasSameType(VA->getType(), VB->getType()))
9332 if (
auto *EA = dyn_cast<EnumConstantDecl>(VA)) {
9333 if (
auto *EB = dyn_cast<EnumConstantDecl>(VB)) {
9336 auto *EnumA = cast<EnumDecl>(EA->getDeclContext());
9337 auto *EnumB = cast<EnumDecl>(EB->getDeclContext());
9338 if (EnumA->hasNameForLinkage() || EnumB->hasNameForLinkage() ||
9340 EnumB->getIntegerType()))
9343 return llvm::APSInt::isSameValue(EA->getInitVal(), EB->getInitVal());
9353 Diag(Loc, diag::ext_equivalent_internal_linkage_decl_in_modules) << D;
9355 Module *M = getOwningModule(const_cast<NamedDecl*>(D));
9359 for (
auto *E : Equiv) {
9360 Module *M = getOwningModule(const_cast<NamedDecl*>(E));
9361 Diag(E->getLocation(), diag::note_equivalent_internal_linkage_decl)
9380 std::transform(begin(), end(), std::back_inserter(Candidates),
9392 bool ContainsSameSideCandidate =
9398 if (ContainsSameSideCandidate) {
9404 llvm::erase_if(Candidates, IsWrongSideCandidate);
9410 for (
auto *Cand : Candidates)
9412 if (Best == end() ||
9424 for (
auto *Cand : Candidates) {
9425 if (Cand->
Viable && Cand != Best &&
9429 EquivalentCands.push_back(Cand->
Function);
9439 if (Best->Function &&
9440 (Best->Function->isDeleted() ||
9444 if (!EquivalentCands.empty())
9457 oc_implicit_default_constructor,
9458 oc_implicit_copy_constructor,
9459 oc_implicit_move_constructor,
9460 oc_implicit_copy_assignment,
9461 oc_implicit_move_assignment,
9462 oc_inherited_constructor
9468 ocs_described_template,
9471 static std::pair<OverloadCandidateKind, OverloadCandidateSelect>
9473 std::string &Description) {
9483 if (!Description.empty())
9484 return ocs_described_template;
9485 return isTemplate ? ocs_template : ocs_non_template;
9490 if (!Ctor->isImplicit()) {
9491 if (isa<ConstructorUsingShadowDecl>(Found))
9492 return oc_inherited_constructor;
9494 return oc_constructor;
9497 if (Ctor->isDefaultConstructor())
9498 return oc_implicit_default_constructor;
9500 if (Ctor->isMoveConstructor())
9501 return oc_implicit_move_constructor;
9503 assert(Ctor->isCopyConstructor() &&
9504 "unexpected sort of implicit constructor");
9505 return oc_implicit_copy_constructor;
9511 if (!Meth->isImplicit())
9514 if (Meth->isMoveAssignmentOperator())
9515 return oc_implicit_move_assignment;
9517 if (Meth->isCopyAssignmentOperator())
9518 return oc_implicit_copy_assignment;
9520 assert(isa<CXXConversionDecl>(Meth) &&
"expected conversion");
9527 return std::make_pair(Kind, Select);
9530 void MaybeEmitInheritedConstructorNote(
Sema &S,
Decl *FoundDecl) {
9533 if (
auto *Shadow = dyn_cast<ConstructorUsingShadowDecl>(FoundDecl))
9535 diag::note_ovl_candidate_inherited_constructor)
9536 << Shadow->getNominatedBaseClass();
9545 if (!EnableIf->getCond()->EvaluateAsBooleanCondition(AlwaysTrue, Ctx))
9562 bool InOverloadResolution,
9566 if (InOverloadResolution)
9568 diag::note_addrof_ovl_candidate_disabled_by_enable_if_attr);
9570 S.
Diag(Loc, diag::err_addrof_function_disabled_by_enable_if_attr) << FD;
9576 return P->hasAttr<PassObjectSizeAttr>();
9584 if (InOverloadResolution)
9586 diag::note_ovl_candidate_has_pass_object_size_params)
9589 S.
Diag(Loc, diag::err_address_of_function_with_pass_object_size_params)
9612 QualType DestType,
bool TakingAddress) {
9616 !Fn->
getAttr<TargetAttr>()->isDefaultVersion())
9620 std::pair<OverloadCandidateKind, OverloadCandidateSelect> KSPair =
9621 ClassifyOverloadCandidate(*
this, Found, Fn, FnDesc);
9623 << (unsigned)KSPair.first << (
unsigned)KSPair.second
9626 HandleFunctionTypeMismatch(PD, Fn->
getType(), DestType);
9628 MaybeEmitInheritedConstructorNote(*
this, Found);
9634 bool TakingAddress) {
9644 dyn_cast<FunctionTemplateDecl>((*I)->getUnderlyingDecl()) ) {
9645 NoteOverloadCandidate(*I, FunTmpl->getTemplatedDecl(), DestType,
9648 = dyn_cast<FunctionDecl>((*I)->getUnderlyingDecl()) ) {
9649 NoteOverloadCandidate(*I, Fun, DestType, TakingAddress);
9661 S.
Diag(CaretLoc, PDiag)
9662 << Ambiguous.getFromType() << Ambiguous.getToType();
9667 unsigned CandsShown = 0;
9669 for (I = Ambiguous.begin(), E = Ambiguous.end(); I != E; ++I) {
9670 if (CandsShown >= 4 && ShowOverloads ==
Ovl_Best)
9680 unsigned I,
bool TakingCandidateAddress) {
9682 assert(Conv.
isBad());
9683 assert(Cand->
Function &&
"for now, candidate must be a function");
9689 bool isObjectArgument =
false;
9690 if (isa<CXXMethodDecl>(Fn) && !isa<CXXConstructorDecl>(Fn)) {
9692 isObjectArgument =
true;
9698 std::pair<OverloadCandidateKind, OverloadCandidateSelect> FnKindPair =
9699 ClassifyOverloadCandidate(S, Cand->
FoundDecl, Fn, FnDesc);
9706 assert(FromExpr &&
"overload set argument came from implicit argument?");
9708 if (isa<UnaryOperator>(E))
9709 E = cast<UnaryOperator>(E)->getSubExpr()->
IgnoreParens();
9713 << (
unsigned)FnKindPair.first << (unsigned)FnKindPair.second << FnDesc
9716 MaybeEmitInheritedConstructorNote(S, Cand->
FoundDecl);
9725 CToTy = RT->getPointeeType();
9730 CFromTy = FromPT->getPointeeType();
9731 CToTy = ToPT->getPointeeType();
9742 << (
unsigned)FnKindPair.first << (unsigned)FnKindPair.second << FnDesc
9744 << ToTy << (
unsigned)isObjectArgument << I + 1;
9745 MaybeEmitInheritedConstructorNote(S, Cand->
FoundDecl);
9751 << (
unsigned)FnKindPair.first << (unsigned)FnKindPair.second << FnDesc
9754 << (unsigned)isObjectArgument << I + 1;
9755 MaybeEmitInheritedConstructorNote(S, Cand->
FoundDecl);
9761 << (
unsigned)FnKindPair.first << (unsigned)FnKindPair.second << FnDesc
9764 << (unsigned)isObjectArgument << I + 1;
9765 MaybeEmitInheritedConstructorNote(S, Cand->
FoundDecl);
9771 << (
unsigned)FnKindPair.first << (unsigned)FnKindPair.second << FnDesc
9774 MaybeEmitInheritedConstructorNote(S, Cand->
FoundDecl);
9779 assert(CVR &&
"unexpected qualifiers mismatch");
9781 if (isObjectArgument) {
9783 << (
unsigned)FnKindPair.first << (unsigned)FnKindPair.second << FnDesc
9788 << (
unsigned)FnKindPair.first << (unsigned)FnKindPair.second << FnDesc
9790 << (CVR - 1) << I + 1;
9792 MaybeEmitInheritedConstructorNote(S, Cand->
FoundDecl);
9798 if (FromExpr && isa<InitListExpr>(FromExpr)) {
9800 << (
unsigned)FnKindPair.first << (unsigned)FnKindPair.second << FnDesc
9802 << ToTy << (
unsigned)isObjectArgument << I + 1;
9803 MaybeEmitInheritedConstructorNote(S, Cand->
FoundDecl);
9815 S.
Diag(Fn->
getLocation(), diag::note_ovl_candidate_bad_conv_incomplete)
9816 << (
unsigned)FnKindPair.first << (unsigned)FnKindPair.second << FnDesc
9818 << ToTy << (
unsigned)isObjectArgument << I + 1
9819 << (unsigned)(Cand->
Fix.
Kind);
9821 MaybeEmitInheritedConstructorNote(S, Cand->
FoundDecl);
9826 unsigned BaseToDerivedConversion = 0;
9829 if (ToPtrTy->getPointeeType().isAtLeastAsQualifiedAs(
9830 FromPtrTy->getPointeeType()) &&
9831 !FromPtrTy->getPointeeType()->isIncompleteType() &&
9832 !ToPtrTy->getPointeeType()->isIncompleteType() &&
9834 FromPtrTy->getPointeeType()))
9835 BaseToDerivedConversion = 1;
9843 if (ToPtrTy->getPointeeType().isAtLeastAsQualifiedAs(
9844 FromPtrTy->getPointeeType()) &&
9845 FromIface->isSuperClassOf(ToIface))
9846 BaseToDerivedConversion = 2;
9848 if (ToRefTy->getPointeeType().isAtLeastAsQualifiedAs(FromTy) &&
9850 !ToRefTy->getPointeeType()->isIncompleteType() &&
9852 BaseToDerivedConversion = 3;
9857 << (
unsigned)FnKindPair.first << (unsigned)FnKindPair.second << FnDesc
9858 << (
unsigned)isObjectArgument << I + 1
9860 MaybeEmitInheritedConstructorNote(S, Cand->
FoundDecl);
9865 if (BaseToDerivedConversion) {
9866 S.
Diag(Fn->
getLocation(), diag::note_ovl_candidate_bad_base_to_derived_conv)
9867 << (
unsigned)FnKindPair.first << (unsigned)FnKindPair.second << FnDesc
9869 << (BaseToDerivedConversion - 1) << FromTy << ToTy << I + 1;
9870 MaybeEmitInheritedConstructorNote(S, Cand->
FoundDecl);
9874 if (isa<ObjCObjectPointerType>(CFromTy) &&
9875 isa<PointerType>(CToTy)) {
9880 << (
unsigned)FnKindPair.first << (unsigned)FnKindPair.second
9882 << FromTy << ToTy << (
unsigned)isObjectArgument << I + 1;
9883 MaybeEmitInheritedConstructorNote(S, Cand->
FoundDecl);
9888 if (TakingCandidateAddress &&
9894 FDiag << (unsigned)FnKindPair.first << (
unsigned)FnKindPair.second << FnDesc
9896 << ToTy << (
unsigned)isObjectArgument << I + 1
9897 << (unsigned)(Cand->
Fix.
Kind);
9900 for (std::vector<FixItHint>::iterator HI = Cand->
Fix.
Hints.begin(),
9901 HE = Cand->
Fix.
Hints.end(); HI != HE; ++HI)
9905 MaybeEmitInheritedConstructorNote(S, Cand->
FoundDecl);
9925 if (NumArgs < MinParams) {
9940 unsigned NumFormalArgs) {
9941 assert(isa<FunctionDecl>(D) &&
9942 "The templated declaration should at least be a function" 9943 " when diagnosing bad template argument deduction due to too many" 9944 " or too few arguments");
9953 unsigned mode, modeCount;
9954 if (NumFormalArgs < MinParams) {
9955 if (MinParams != FnTy->getNumParams() || FnTy->isVariadic() ||
9956 FnTy->isTemplateVariadic())
9960 modeCount = MinParams;
9962 if (MinParams != FnTy->getNumParams())
9966 modeCount = FnTy->getNumParams();
9969 std::string Description;
9970 std::pair<OverloadCandidateKind, OverloadCandidateSelect> FnKindPair =
9971 ClassifyOverloadCandidate(S, Found, Fn, Description);
9975 << (
unsigned)FnKindPair.first << (unsigned)FnKindPair.second
9976 << Description << mode << Fn->
getParamDecl(0) << NumFormalArgs;
9979 << (
unsigned)FnKindPair.first << (unsigned)FnKindPair.second
9980 << Description << mode << modeCount << NumFormalArgs;
9982 MaybeEmitInheritedConstructorNote(S, Found);
9987 unsigned NumFormalArgs) {
9995 llvm_unreachable(
"Unsupported: Getting the described template declaration" 9996 " for bad deduction diagnosis");
10003 bool TakingCandidateAddress) {
10009 switch (DeductionFailure.
Result) {
10011 llvm_unreachable(
"TDK_success while diagnosing bad deduction");
10014 assert(ParamD &&
"no parameter found for incomplete deduction result");
10016 diag::note_ovl_candidate_incomplete_deduction)
10018 MaybeEmitInheritedConstructorNote(S, Found);
10023 assert(ParamD &&
"no parameter found for incomplete deduction result");
10025 diag::note_ovl_candidate_incomplete_deduction_pack)
10029 MaybeEmitInheritedConstructorNote(S, Found);
10034 assert(ParamD &&
"no parameter found for bad qualifiers deduction result");
10052 S.
Diag(Templated->
getLocation(), diag::note_ovl_candidate_underqualified)
10053 << ParamD->
getDeclName() << Arg << NonCanonParam;
10054 MaybeEmitInheritedConstructorNote(S, Found);
10059 assert(ParamD &&
"no parameter found for inconsistent deduction result");
10061 if (isa<TemplateTypeParmDecl>(ParamD))
10063 else if (isa<NonTypeTemplateParmDecl>(ParamD)) {
10073 diag::note_ovl_candidate_inconsistent_deduction_types)
10076 MaybeEmitInheritedConstructorNote(S, Found);
10086 diag::note_ovl_candidate_inconsistent_deduction)
10089 MaybeEmitInheritedConstructorNote(S, Found);
10094 assert(ParamD &&
"no parameter found for invalid explicit arguments");
10097 diag::note_ovl_candidate_explicit_arg_mismatch_named)
10102 index = TTP->getIndex();
10104 = dyn_cast<NonTypeTemplateParmDecl>(ParamD))
10105 index = NTTP->getIndex();
10107 index = cast<TemplateTemplateParmDecl>(ParamD)->getIndex();
10109 diag::note_ovl_candidate_explicit_arg_mismatch_unnamed)
10112 MaybeEmitInheritedConstructorNote(S, Found);
10122 diag::note_ovl_candidate_instantiation_depth);
10123 MaybeEmitInheritedConstructorNote(S, Found);
10131 TemplateArgString =
" ";
10138 if (PDiag && PDiag->second.getDiagID() ==
10139 diag::err_typename_nested_not_found_enable_if) {
10142 S.
Diag(PDiag->first, diag::note_ovl_candidate_disabled_by_enable_if)
10143 <<
"'enable_if'" << TemplateArgString;
10148 if (PDiag && PDiag->second.getDiagID() ==
10149 diag::err_typename_nested_not_found_requirement) {
10151 diag::note_ovl_candidate_disabled_by_requirement)
10152 << PDiag->second.getStringArg(0) << TemplateArgString;
10162 SFINAEArgString =
": ";
10164 PDiag->second.EmitToString(S.
getDiagnostics(), SFINAEArgString);
10168 diag::note_ovl_candidate_substitution_failure)
10169 << TemplateArgString << SFINAEArgString << R;
10170 MaybeEmitInheritedConstructorNote(S, Found);
10180 TemplateArgString =
" ";
10185 S.
Diag(Templated->
getLocation(), diag::note_ovl_candidate_deduced_mismatch)
10188 << TemplateArgString
10212 diag::note_ovl_candidate_non_deduced_mismatch_qualified)
10219 if (TakingCandidateAddress && isa<FunctionDecl>(Templated) &&
10228 diag::note_ovl_candidate_non_deduced_mismatch)
10229 << FirstTA << SecondTA;
10235 S.
Diag(Templated->
getLocation(), diag::note_ovl_candidate_bad_deduction);
10236 MaybeEmitInheritedConstructorNote(S, Found);
10240 diag::note_cuda_ovl_candidate_target_mismatch);
10248 bool TakingCandidateAddress) {
10266 std::string FnDesc;
10267 std::pair<OverloadCandidateKind, OverloadCandidateSelect> FnKindPair =
10268 ClassifyOverloadCandidate(S, Cand->
FoundDecl, Callee, FnDesc);
10270 S.
Diag(Callee->getLocation(), diag::note_ovl_candidate_bad_target)
10271 << (
unsigned)FnKindPair.first << (unsigned)ocs_non_template
10273 << CalleeTarget << CallerTarget;
10278 if (Meth !=
nullptr && Meth->
isImplicit()) {
10282 switch (FnKindPair.first) {
10285 case oc_implicit_default_constructor:
10288 case oc_implicit_copy_constructor:
10291 case oc_implicit_move_constructor:
10294 case oc_implicit_copy_assignment:
10297 case oc_implicit_move_assignment:
10302 bool ConstRHS =
false;
10306 ConstRHS = RT->getPointeeType().isConstQualified();
10321 diag::note_ovl_candidate_disabled_by_function_cond_attr)
10322 << Attr->getCond()->getSourceRange() << Attr->getMessage();
10329 diag::note_ovl_candidate_disabled_by_extension)
10348 bool TakingCandidateAddress) {
10354 std::string FnDesc;
10355 std::pair<OverloadCandidateKind, OverloadCandidateSelect> FnKindPair =
10356 ClassifyOverloadCandidate(S, Cand->
FoundDecl, Fn, FnDesc);
10359 << (
unsigned)FnKindPair.first << (unsigned)FnKindPair.second << FnDesc
10361 MaybeEmitInheritedConstructorNote(S, Cand->
FoundDecl);
10377 TakingCandidateAddress);
10380 S.
Diag(Fn->
getLocation(), diag::note_ovl_candidate_illegal_constructor)
10382 MaybeEmitInheritedConstructorNote(S, Cand->
FoundDecl);
10393 for (
unsigned N = Cand->
Conversions.size(); I != N; ++I)
10414 if (cast<CXXConstructorDecl>(Fn)->isCopyOrMoveConstructor())
10417 diag::note_ovl_candidate_inherited_constructor_slice)
10420 MaybeEmitInheritedConstructorNote(S, Cand->
FoundDecl);
10426 assert(!Available);
10440 bool isLValueReference =
false;
10441 bool isRValueReference =
false;
10442 bool isPointer =
false;
10446 isLValueReference =
true;
10450 isRValueReference =
true;
10470 assert(Cand->
Conversions.size() <= 2 &&
"builtin operator is not binary");
10471 std::string TypeStr(
"operator");
10477 S.
Diag(OpLoc, diag::note_ovl_builtin_unary_candidate) << TypeStr;
10482 S.
Diag(OpLoc, diag::note_ovl_builtin_binary_candidate) << TypeStr;
10489 if (ICS.
isBad())
break;
10493 S, OpLoc, S.
PDiag(diag::note_ambiguous_type_conversion));
10509 llvm_unreachable(
"non-deduction failure while diagnosing bad deduction");
10538 llvm_unreachable(
"Unhandled deduction result");
10542 struct CompareOverloadCandidatesForDisplay {
10548 CompareOverloadCandidatesForDisplay(
10551 : S(S), NumArgs(NArgs), CSK(CSK) {}
10556 if (L == R)
return false;
10560 if (!R->
Viable)
return true;
10583 if (LDist == RDist) {
10592 return LDist < RDist;
10610 numLFixes = (numLFixes == 0) ?
UINT_MAX : numLFixes;
10611 numRFixes = (numRFixes == 0) ?
UINT_MAX : numRFixes;
10612 if (numLFixes != numRFixes) {
10613 return numLFixes < numRFixes;
10620 int leftBetter = 0;
10622 for (
unsigned E = L->
Conversions.size(); I != E; ++I) {
10638 if (leftBetter > 0)
return true;
10639 if (leftBetter < 0)
return false;
10681 bool Unfixable =
false;
10689 assert(ConvIdx != ConvCount &&
"no bad conversion in candidate");
10690 if (Cand->
Conversions[ConvIdx].isInitialized() &&
10699 bool SuppressUserConversions =
false;
10701 unsigned ConvIdx = 0;
10715 if (isa<CXXMethodDecl>(Cand->
Function) &&
10716 !isa<CXXConstructorDecl>(Cand->
Function)) {
10722 assert(ConvCount <= 3);
10727 for (
unsigned ArgIdx = 0; ConvIdx != ConvCount; ++ConvIdx, ++ArgIdx) {
10728 if (Cand->
Conversions[ConvIdx].isInitialized()) {
10730 }
else if (ArgIdx < ParamTypes.size()) {
10731 if (ParamTypes[ArgIdx]->isDependentType())
10732 Cand->
Conversions[ConvIdx].setAsIdentityConversion(
10733 Args[ArgIdx]->getType());
10737 SuppressUserConversions,
10742 if (!Unfixable && Cand->
Conversions[ConvIdx].isBad())
10760 for (
iterator Cand = begin(), LastCand = end(); Cand != LastCand; ++Cand) {
10764 Cands.push_back(Cand);
10767 if (Cand->Function || Cand->IsSurrogate)
10768 Cands.push_back(Cand);
10774 std::stable_sort(Cands.begin(), Cands.end(),
10775 CompareOverloadCandidatesForDisplay(S, OpLoc, Args.size(),
Kind));
10777 bool ReportedAmbiguousConversions =
false;
10781 unsigned CandsShown = 0;
10782 for (I = Cands.begin(), E = Cands.end(); I != E; ++I) {
10788 if (CandsShown >= 4 && ShowOverloads ==
Ovl_Best) {
10800 "Non-viable built-in candidates are not added to Cands.");
10807 if (!ReportedAmbiguousConversions) {
10809 ReportedAmbiguousConversions =
true;
10818 S.
Diag(OpLoc, diag::note_ovl_too_many_candidates) << int(E - I);
10828 struct CompareTemplateSpecCandidatesForDisplay {
10830 CompareTemplateSpecCandidatesForDisplay(
Sema &S) : S(S) {}
10864 bool ForTakingAddress) {
10866 DeductionFailure, 0, ForTakingAddress);
10869 void TemplateSpecCandidateSet::destroyCandidates() {
10870 for (iterator i = begin(), e = end(); i != e; ++i) {
10871 i->DeductionFailure.Destroy();
10876 destroyCandidates();
10877 Candidates.clear();
10890 Cands.reserve(size());
10891 for (
iterator Cand = begin(), LastCand = end(); Cand != LastCand; ++Cand) {
10892 if (Cand->Specialization)
10893 Cands.push_back(Cand);
10898 llvm::sort(Cands, CompareTemplateSpecCandidatesForDisplay(S));
10905 unsigned CandsShown = 0;
10906 for (I = Cands.begin(), E = Cands.end(); I != E; ++I) {
10912 if (CandsShown >= 4 && ShowOverloads ==
Ovl_Best)
10917 "Non-matching built-in candidates are not added to Cands.");
10922 S.
Diag(Loc, diag::note_ovl_too_many_candidates) << int(E - I);
10932 QualType Ret = PossiblyAFunctionType;
10948 bool Complain =
true) {
10965 class AddressOfFunctionResolver {
10975 bool TargetTypeIsNonStaticMemberFunction;
10976 bool FoundNonTemplateFunction;
10977 bool StaticMemberFunctionFromBoundPointer;
10978 bool HasComplained;
10987 AddressOfFunctionResolver(
Sema &S,
Expr *SourceExpr,
10988 const QualType &TargetType,
bool Complain)
10989 : S(S), SourceExpr(SourceExpr), TargetType(TargetType),
10991 TargetTypeIsNonStaticMemberFunction(
10993 FoundNonTemplateFunction(
false),
10994 StaticMemberFunctionFromBoundPointer(
false),
10995 HasComplained(
false),
10998 FailedCandidates(OvlExpr->
getNameLoc(),
true) {
10999 ExtractUnqualifiedFunctionTypeFromTargetType();
11003 if (!UME->isImplicitAccess() &&
11005 StaticMemberFunctionFromBoundPointer =
true;
11009 OvlExpr,
false, &dap)) {
11011 if (!Method->isStatic()) {
11015 TargetTypeIsNonStaticMemberFunction =
true;
11023 Matches.push_back(std::make_pair(dap, Fn));
11031 if (FindAllFunctionsThatMatchTargetTypeExactly()) {
11034 if (Matches.size() > 1 && !eliminiateSuboptimalOverloadCandidates()) {
11035 if (FoundNonTemplateFunction)
11036 EliminateAllTemplateMatches();
11038 EliminateAllExceptMostSpecializedTemplate();
11043 EliminateSuboptimalCudaMatches();
11046 bool hasComplained()
const {
return HasComplained; }
11049 bool candidateHasExactlyCorrectType(
const FunctionDecl *FD) {
11061 return candidateHasExactlyCorrectType(A) &&
11062 (!candidateHasExactlyCorrectType(B) ||
11068 bool eliminiateSuboptimalOverloadCandidates() {
11071 auto Best = Matches.begin();
11072 for (
auto I = Matches.begin()+1, E = Matches.end(); I != E; ++I)
11073 if (isBetterCandidate(I->second, Best->second))
11077 auto IsBestOrInferiorToBest = [
this, BestFn](
11078 const std::pair<DeclAccessPair, FunctionDecl *> &Pair) {
11079 return BestFn == Pair.second || isBetterCandidate(BestFn, Pair.second);
11084 if (!llvm::all_of(Matches, IsBestOrInferiorToBest))
11086 Matches[0] = *Best;
11091 bool isTargetTypeAFunction()
const {
11100 void inline ExtractUnqualifiedFunctionTypeFromTargetType() {
11111 if (Method->isStatic() == TargetTypeIsNonStaticMemberFunction)
11114 else if (TargetTypeIsNonStaticMemberFunction)
11127 &OvlExplicitTemplateArgs,
11128 TargetFunctionType, Specialization,
11147 Matches.push_back(std::make_pair(CurAccessFunPair, Specialization));
11151 bool AddMatchingNonTemplateFunction(
NamedDecl* Fn,
11156 if (Method->isStatic() == TargetTypeIsNonStaticMemberFunction)
11159 else if (TargetTypeIsNonStaticMemberFunction)
11162 if (
FunctionDecl *FunDecl = dyn_cast<FunctionDecl>(Fn)) {
11167 if (FunDecl->isMultiVersion()) {
11168 const auto *TA = FunDecl->getAttr<TargetAttr>();
11169 if (TA && !TA->isDefaultVersion())
11177 HasComplained |= Complain;
11186 candidateHasExactlyCorrectType(FunDecl)) {
11187 Matches.push_back(std::make_pair(
11188 CurAccessFunPair, cast<FunctionDecl>(FunDecl->getCanonicalDecl())));
11189 FoundNonTemplateFunction =
true;
11197 bool FindAllFunctionsThatMatchTargetTypeExactly() {
11202 if (IsInvalidFormOfPointerToMemberFunction())
11218 = dyn_cast<FunctionTemplateDecl>(Fn)) {
11219 if (AddMatchingTemplateFunction(FunctionTemplate, I.getPair()))
11224 AddMatchingNonTemplateFunction(Fn, I.getPair()))
11227 assert(Ret || Matches.empty());
11231 void EliminateAllExceptMostSpecializedTemplate() {
11244 for (
unsigned I = 0, E = Matches.size(); I != E; ++I)
11245 MatchesCopy.
addDecl(Matches[I].second, Matches[I].first.getAccess());
11250 MatchesCopy.
begin(), MatchesCopy.
end(), FailedCandidates,
11252 S.
PDiag(diag::err_addr_ovl_ambiguous)
11253 << Matches[0].second->getDeclName(),
11254 S.
PDiag(diag::note_ovl_candidate)
11255 << (unsigned)oc_function << (
unsigned)ocs_described_template,
11256 Complain, TargetFunctionType);
11258 if (Result != MatchesCopy.
end()) {
11260 Matches[0].first = Matches[Result - MatchesCopy.
begin()].first;
11261 Matches[0].second = cast<FunctionDecl>(*Result);
11264 HasComplained |= Complain;
11267 void EliminateAllTemplateMatches() {
11270 for (
unsigned I = 0, N = Matches.size(); I != N; ) {
11271 if (Matches[I].second->getPrimaryTemplate() ==
nullptr)
11274 Matches[I] = Matches[--N];
11280 void EliminateSuboptimalCudaMatches() {
11285 void ComplainNoMatchesFound()
const {
11286 assert(Matches.empty());
11288 << OvlExpr->
getName() << TargetFunctionType
11290 if (FailedCandidates.
empty())
11301 dyn_cast<FunctionDecl>((*I)->getUnderlyingDecl()))
11309 bool IsInvalidFormOfPointerToMemberFunction()
const {
11310 return TargetTypeIsNonStaticMemberFunction &&
11314 void ComplainIsInvalidFormOfPointerToMemberFunction()
const {
11322 bool IsStaticMemberFunctionFromBoundPointer()
const {
11323 return StaticMemberFunctionFromBoundPointer;
11326 void ComplainIsStaticMemberFunctionFromBoundPointer()
const {
11328 diag::err_invalid_form_pointer_member_function)
11332 void ComplainOfInvalidConversion()
const {
11334 << OvlExpr->
getName() << TargetType;
11337 void ComplainMultipleMatchesFound()
const {
11338 assert(Matches.size() > 1);
11345 bool hadMultipleCandidates()
const {
return (OvlExpr->
getNumDecls() > 1); }
11347 int getNumMatches()
const {
return Matches.size(); }
11350 if (Matches.size() != 1)
return nullptr;
11351 return Matches[0].second;
11355 if (Matches.size() != 1)
return nullptr;
11356 return &Matches[0].first;
11381 bool *pHadMultipleCandidates) {
11384 AddressOfFunctionResolver Resolver(*
this, AddressOfExpr, TargetType,
11386 int NumMatches = Resolver.getNumMatches();
11388 bool ShouldComplain = Complain && !Resolver.hasComplained();
11389 if (NumMatches == 0 && ShouldComplain) {
11390 if (Resolver.IsInvalidFormOfPointerToMemberFunction())
11391 Resolver.ComplainIsInvalidFormOfPointerToMemberFunction();
11393 Resolver.ComplainNoMatchesFound();
11395 else if (NumMatches > 1 && ShouldComplain)
11396 Resolver.ComplainMultipleMatchesFound();
11397 else if (NumMatches == 1) {
11398 Fn = Resolver.getMatchingFunctionDecl();
11401 ResolveExceptionSpec(AddressOfExpr->
getExprLoc(), FPT);
11402 FoundResult = *Resolver.getMatchingFunctionAccessPair();
11404 if (Resolver.IsStaticMemberFunctionFromBoundPointer())
11405 Resolver.ComplainIsStaticMemberFunctionFromBoundPointer();
11407 CheckAddressOfMemberAccess(AddressOfExpr, FoundResult);
11411 if (pHadMultipleCandidates)
11412 *pHadMultipleCandidates = Resolver.hadMultipleCandidates();
11433 auto *FD = dyn_cast<
FunctionDecl>(I->getUnderlyingDecl());
11460 ExprResult &SrcExpr,
bool DoFunctionPointerConverion) {
11465 FunctionDecl *Found = resolveAddressOfOnlyViableOverloadCandidate(E, DAP);
11474 CheckAddressOfMemberAccess(E, DAP);
11475 Expr *Fixed = FixOverloadedFunctionReference(E, DAP, Found);
11477 SrcExpr = DefaultFunctionArrayConversion(Fixed,
false);
11524 = cast<FunctionTemplateDecl>((*I)->getUnderlyingDecl());
11536 Specialization, Info,
11540 FailedCandidates.addCandidate()
11546 assert(Specialization &&
"no specialization and no error?");
11553 NoteAllOverloadCandidates(ovl);
11558 Matched = Specialization;
11559 if (FoundResult) *FoundResult = I.getPair();
11578 ExprResult &SrcExpr,
bool doFunctionPointerConverion,
11579 bool complain,
SourceRange OpRangeForComplaining,
11581 unsigned DiagIDForComplaining) {
11588 if (
FunctionDecl *fn = ResolveSingleFunctionTemplateSpecialization(
11589 ovl.Expression,
false, &found)) {
11590 if (DiagnoseUseOfDecl(fn, SrcExpr.
get()->getBeginLoc())) {
11599 if (!ovl.HasFormOfMemberPointer &&
11600 isa<CXXMethodDecl>(fn) &&
11601 cast<CXXMethodDecl>(fn)->isInstance()) {
11602 if (!complain)
return false;
11604 Diag(ovl.Expression->getExprLoc(),
11605 diag::err_bound_member_function)
11606 << 0 << ovl.Expression->getSourceRange();
11618 SingleFunctionExpression =
11619 FixOverloadedFunctionReference(SrcExpr.
get(), found, fn);
11622 if (doFunctionPointerConverion) {
11623 SingleFunctionExpression =
11624 DefaultFunctionArrayLvalueConversion(SingleFunctionExpression.
get());
11625 if (SingleFunctionExpression.
isInvalid()) {
11632 if (!SingleFunctionExpression.
isUsable()) {
11634 Diag(OpRangeForComplaining.
getBegin(), DiagIDForComplaining)
11635 << ovl.Expression->getName()
11636 << DestTypeForComplaining
11637 << OpRangeForComplaining
11638 << ovl.Expression->getQualifierLoc().getSourceRange();
11639 NoteAllOverloadCandidates(SrcExpr.
get());
11648 SrcExpr = SingleFunctionExpression;
11658 bool PartialOverloading,
11661 if (isa<UsingShadowDecl>(Callee))
11662 Callee = cast<UsingShadowDecl>(Callee)->getTargetDecl();
11664 if (
FunctionDecl *Func = dyn_cast<FunctionDecl>(Callee)) {
11665 if (ExplicitTemplateArgs) {
11666 assert(!KnownValid &&
"Explicit template arguments?");
11670 if (!dyn_cast<FunctionProtoType>(Func->getType()->getAs<
FunctionType>()))
11675 PartialOverloading);
11680 = dyn_cast<FunctionTemplateDecl>(Callee)) {
11682 ExplicitTemplateArgs, Args, CandidateSet,
11684 PartialOverloading);
11688 assert(!KnownValid &&
"unhandled case in overloaded call candidate");
11696 bool PartialOverloading) {
11719 assert(!(*I)->getDeclContext()->isRecord());
11720 assert(isa<UsingShadowDecl>(*I) ||
11721 !(*I)->getDeclContext()->isFunctionOrMethod());
11722 assert((*I)->getUnderlyingDecl()->isFunctionOrFunctionTemplate());
11732 ExplicitTemplateArgs = &TABuffer;
11738 CandidateSet, PartialOverloading,
11743 Args, ExplicitTemplateArgs,
11744 CandidateSet, PartialOverloading);
11751 case OO_New:
case OO_Array_New:
11752 case OO_Delete:
case OO_Array_Delete:
11772 bool *DoDiagnoseEmptyLookup =
nullptr) {
11777 if (DC->isTransparentContext())
11785 if (isa<CXXRecordDecl>(DC)) {
11789 if (DoDiagnoseEmptyLookup)
11790 *DoDiagnoseEmptyLookup =
true;
11797 ExplicitTemplateArgs, Args,
11798 Candidates,
false,
false);
11801 if (Candidates.BestViableFunction(SemaRef, FnLoc, Best) !=
OR_Success) {
11813 AssociatedNamespaces,
11814 AssociatedClasses);
11818 for (Sema::AssociatedNamespaceSet::iterator
11819 it = AssociatedNamespaces.begin(),
11820 end = AssociatedNamespaces.end(); it != end; ++it) {
11832 SuggestedNamespaces.insert(*it);
11836 SemaRef.
Diag(R.
getNameLoc(), diag::err_not_found_by_two_phase_lookup)
11838 if (SuggestedNamespaces.empty()) {
11839 SemaRef.
Diag(Best->Function->getLocation(),
11840 diag::note_not_found_by_two_phase_lookup)
11842 }
else if (SuggestedNamespaces.size() == 1) {
11843 SemaRef.
Diag(Best->Function->getLocation(),
11844 diag::note_not_found_by_two_phase_lookup)
11850 SemaRef.
Diag(Best->Function->getLocation(),
11851 diag::note_not_found_by_two_phase_lookup)
11883 class BuildRecoveryCallExprRAII {
11886 BuildRecoveryCallExprRAII(
Sema &S) : SemaRef(S) {
11891 ~BuildRecoveryCallExprRAII() {
11898 static std::unique_ptr<CorrectionCandidateCallback>
11900 bool HasTemplateArgs,
bool AllowTypoCorrection) {
11901 if (!AllowTypoCorrection)
11902 return llvm::make_unique<NoTypoCorrectionCCC>();
11903 return llvm::make_unique<FunctionCallFilterCCC>(SemaRef, NumArgs,
11904 HasTemplateArgs, ME);
11916 bool EmptyLookup,
bool AllowTypoCorrection) {
11925 BuildRecoveryCallExprRAII RCE(SemaRef);
11935 ExplicitTemplateArgs = &TABuffer;
11940 bool DoDiagnoseEmptyLookup = EmptyLookup;
11943 ExplicitTemplateArgs, Args,
11944 &DoDiagnoseEmptyLookup) &&
11947 MakeValidator(SemaRef, dyn_cast<MemberExpr>(Fn), Args.size(),
11948 ExplicitTemplateArgs !=
nullptr, AllowTypoCorrection),
11949 ExplicitTemplateArgs, Args)))
11952 assert(!R.empty() &&
"lookup results empty despite recovery");
11955 if (R.isAmbiguous()) {
11956 R.suppressDiagnostics();
11963 if ((*R.begin())->isCXXClassMember())
11965 ExplicitTemplateArgs, S);
11966 else if (ExplicitTemplateArgs || TemplateKWLoc.
isValid())
11968 ExplicitTemplateArgs);
11995 assert(!ULE->
getQualifier() &&
"qualified name with ADL");
12003 llvm_unreachable(
"performing ADL for builtin");
12006 assert(getLangOpts().
CPlusPlus &&
"ADL enabled in C");
12010 UnbridgedCastsSet UnbridgedCasts;
12018 AddOverloadedCallCandidates(ULE, Args, *CandidateSet);
12020 if (getLangOpts().MSVCCompat &&
12021 CurContext->isDependentContext() && !isSFINAEContext() &&
12022 (isa<FunctionDecl>(CurContext) || isa<CXXRecordDecl>(CurContext))) {
12025 if (CandidateSet->
empty() ||
12042 if (CandidateSet->
empty())
12045 UnbridgedCasts.restore();
12061 bool AllowTypoCorrection) {
12062 if (CandidateSet->
empty())
12065 AllowTypoCorrection);
12067 switch (OverloadResult) {
12076 (*Best)->IsADLCandidate);
12085 AllowTypoCorrection);
12092 for (
const Expr *Arg : Args) {
12093 if (!Arg->getType()->isFunctionType())
12095 if (
auto *DRE = dyn_cast<DeclRefExpr>(Arg->IgnoreParenImpCasts())) {
12099 Arg->getExprLoc()))
12104 SemaRef.
Diag(Fn->
getBeginLoc(), diag::err_ovl_no_viable_function_in_call)
12118 << (*Best)->Function->isDeleted() << ULE->
getName()
12129 (*Best)->IsADLCandidate);
12139 for (
auto I = CS.
begin(), E = CS.
end(); I != E; ++I) {
12160 bool AllowTypoCorrection,
12161 bool CalleesAddressIsTaken) {
12166 if (buildOverloadedCallSet(S, Fn, ULE, Args, LParenLoc, &CandidateSet,
12172 if (CalleesAddressIsTaken)
12177 CandidateSet.BestViableFunction(*
this, Fn->
getBeginLoc(), Best);
12180 RParenLoc, ExecConfig, &CandidateSet,
12181 &Best, OverloadResult,
12182 AllowTypoCorrection);
12186 return Functions.
size() > 1 ||
12187 (Functions.
size() == 1 && isa<FunctionTemplateDecl>(*Functions.
begin()));
12208 Expr *Input,
bool PerformADL) {
12210 assert(Op !=
OO_None &&
"Invalid opcode for overloaded unary operator");
12218 Expr *Args[2] = { Input,
nullptr };
12219 unsigned NumArgs = 1;
12224 if (Opc == UO_PostInc || Opc == UO_PostDec) {
12251 AddFunctionCandidates(Fns, ArgsArray, CandidateSet);
12254 AddMemberOperatorCandidates(Op, OpLoc, ArgsArray, CandidateSet);
12258 AddArgumentDependentLookupCandidates(OpName, OpLoc, ArgsArray,
12264 AddBuiltinOperatorCandidates(Op, OpLoc, ArgsArray, CandidateSet);
12266 bool HadMultipleCandidates = (CandidateSet.
size() > 1);
12281 if (
CXXMethodDecl *Method = dyn_cast<CXXMethodDecl>(FnDecl)) {
12282 CheckMemberOperatorAccess(OpLoc, Args[0],
nullptr, Best->FoundDecl);
12285 PerformObjectArgumentInitialization(Input,
nullptr,
12286 Best->FoundDecl, Method);
12289 Base = Input = InputRes.
get();
12300 Input = InputInit.
get();
12305 Base, HadMultipleCandidates,
12317 Context, Op, FnExpr.
get(), ArgsArray, ResultTy, VK, OpLoc,
12320 if (CheckCallReturnType(FnDecl->
getReturnType(), OpLoc, TheCall, FnDecl))
12323 if (CheckFunctionCall(FnDecl, TheCall,
12327 return MaybeBindToTemporary(TheCall);
12332 ExprResult InputRes = PerformImplicitConversion(
12333 Input, Best->BuiltinParamTypes[0], Best->Conversions[0], AA_Passing,
12334 CCK_ForBuiltinOverloadedOp);
12337 Input = InputRes.
get();
12355 Diag(OpLoc, diag::err_ovl_ambiguous_oper_unary)
12364 Diag(OpLoc, diag::err_ovl_deleted_oper)
12365 << Best->Function->isDeleted()
12367 << getDeletedOrUnavailableSuffix(Best->Function)
12377 return CreateBuiltinUnaryOp(OpLoc, Opc, Input);
12400 Expr *LHS,
Expr *RHS,
bool PerformADL) {
12401 Expr *Args[2] = { LHS, RHS };
12409 if (Args[0]->isTypeDependent() || Args[1]->isTypeDependent()) {
12413 if (Opc <= BO_Assign || Opc > BO_OrAssign)
12416 OpLoc, FPFeatures);
12452 if (Opc == BO_Assign && !Args[0]->getType()->isOverloadableType())
12453 return CreateBuiltinBinOp(OpLoc, Opc, Args[0], Args[1]);
12457 if (Opc == BO_PtrMemD)
12458 return CreateBuiltinBinOp(OpLoc, Opc, Args[0], Args[1]);
12464 AddFunctionCandidates(Fns, Args, CandidateSet);
12467 AddMemberOperatorCandidates(Op, OpLoc, Args, CandidateSet);
12472 if (Opc != BO_Assign && PerformADL)
12473 AddArgumentDependentLookupCandidates(OpName, OpLoc, Args,
12478 AddBuiltinOperatorCandidates(Op, OpLoc, Args, CandidateSet);
12480 bool HadMultipleCandidates = (CandidateSet.
size() > 1);
12495 if (
CXXMethodDecl *Method = dyn_cast<CXXMethodDecl>(FnDecl)) {
12497 CheckMemberOperatorAccess(OpLoc, Args[0], Args[1], Best->FoundDecl);
12500 PerformCopyInitialization(
12508 PerformObjectArgumentInitialization(Args[0],
nullptr,
12509 Best->FoundDecl, Method);
12516 ExprResult Arg0 = PerformCopyInitialization(
12524 PerformCopyInitialization(
12536 Best->FoundDecl, Base,
12537 HadMultipleCandidates, OpLoc);
12538 if (FnExpr.isInvalid())
12547 Context, Op, FnExpr.get(), Args, ResultTy, VK, OpLoc, FPFeatures,
12548 Best->IsADLCandidate);
12550 if (CheckCallReturnType(FnDecl->
getReturnType(), OpLoc, TheCall,
12555 const Expr *ImplicitThis =
nullptr;
12557 if (isa<CXXMethodDecl>(FnDecl)) {
12558 ImplicitThis = ArgsArray[0];
12559 ArgsArray = ArgsArray.slice(1);
12563 if (Op == OO_Equal)
12564 DiagnoseSelfMove(Args[0], Args[1], OpLoc);
12566 checkCall(FnDecl,
nullptr, ImplicitThis, ArgsArray,
12567 isa<CXXMethodDecl>(FnDecl), OpLoc, TheCall->getSourceRange(),
12568 VariadicDoesNotApply);
12570 return MaybeBindToTemporary(TheCall);
12575 ExprResult ArgsRes0 = PerformImplicitConversion(
12576 Args[0], Best->BuiltinParamTypes[0], Best->Conversions[0],
12577 AA_Passing, CCK_ForBuiltinOverloadedOp);
12580 Args[0] = ArgsRes0.
get();
12582 ExprResult ArgsRes1 = PerformImplicitConversion(
12583 Args[1], Best->BuiltinParamTypes[1], Best->Conversions[1],
12584 AA_Passing, CCK_ForBuiltinOverloadedOp);
12587 Args[1] = ArgsRes1.
get();
12597 if (Opc == BO_Comma)
12605 Opc >= BO_Assign && Opc <= BO_OrAssign) {
12606 Diag(OpLoc, diag::err_ovl_no_viable_oper)
12609 if (Args[0]->getType()->isIncompleteType()) {
12610 Diag(OpLoc, diag::note_assign_lhs_incomplete)
12624 Result = CreateBuiltinBinOp(OpLoc, Opc, Args[0], Args[1]);
12627 "C++ binary operator overloading is missing candidates!");
12635 Diag(OpLoc, diag::err_ovl_ambiguous_oper_binary)
12644 if (isImplicitlyDeleted(Best->Function)) {
12645 CXXMethodDecl *Method = cast<CXXMethodDecl>(Best->Function);
12646 Diag(OpLoc, diag::err_ovl_deleted_special_oper)
12648 << getSpecialMember(Method);
12652 NoteDeletedFunction(Method);
12655 Diag(OpLoc, diag::err_ovl_deleted_oper)
12656 << Best->Function->isDeleted()
12658 << getDeletedOrUnavailableSuffix(Best->Function)
12667 return CreateBuiltinBinOp(OpLoc, Opc, Args[0], Args[1]);
12674 Expr *Args[2] = { Base, Idx };
12680 if (Args[0]->isTypeDependent() || Args[1]->isTypeDependent()) {
12711 AddMemberOperatorCandidates(OO_Subscript, LLoc, Args, CandidateSet);
12714 AddBuiltinOperatorCandidates(OO_Subscript, LLoc, Args, CandidateSet);
12716 bool HadMultipleCandidates = (CandidateSet.
size() > 1);
12729 CheckMemberOperatorAccess(LLoc, Args[0], Args[1], Best->FoundDecl);
12734 PerformObjectArgumentInitialization(Args[0],
nullptr,
12735 Best->FoundDecl, Method);
12736 if (Arg0.isInvalid())
12738 Args[0] = Arg0.get();
12754 OpLocInfo.setCXXOperatorNameRange(
SourceRange(LLoc, RLoc));
12758 HadMultipleCandidates,
12759 OpLocInfo.getLoc(),
12760 OpLocInfo.getInfo());
12771 Args, ResultTy, VK, RLoc,
FPOptions());
12773 if (CheckCallReturnType(FnDecl->
getReturnType(), LLoc, TheCall, FnDecl))
12776 if (CheckFunctionCall(Method, TheCall,
12780 return MaybeBindToTemporary(TheCall);
12785 ExprResult ArgsRes0 = PerformImplicitConversion(
12786 Args[0], Best->BuiltinParamTypes[0], Best->Conversions[0],
12787 AA_Passing, CCK_ForBuiltinOverloadedOp);
12790 Args[0] = ArgsRes0.
get();
12792 ExprResult ArgsRes1 = PerformImplicitConversion(
12793 Args[1], Best->BuiltinParamTypes[1], Best->Conversions[1],
12794 AA_Passing, CCK_ForBuiltinOverloadedOp);
12797 Args[1] = ArgsRes1.
get();
12804 if (CandidateSet.
empty())
12805 Diag(LLoc, diag::err_ovl_no_oper)
12809 Diag(LLoc, diag::err_ovl_no_viable_subscript)
12818 Diag(LLoc, diag::err_ovl_ambiguous_oper_binary)
12827 Diag(LLoc, diag::err_ovl_deleted_oper)
12828 << Best->Function->isDeleted() <<
"[]" 12829 << getDeletedOrUnavailableSuffix(Best->Function)
12837 return CreateBuiltinArraySubscriptExpr(Args[0], LLoc, Args[1], RLoc);
12860 if (
BinaryOperator *op = dyn_cast<BinaryOperator>(NakedMemExpr)) {
12862 assert(op->getOpcode() == BO_PtrMemD || op->getOpcode() == BO_PtrMemI);
12875 QualType objectType = op->getLHS()->getType();
12876 if (op->getOpcode() == BO_PtrMemI)
12880 Qualifiers difference = objectQuals - funcQuals;
12884 std::string qualsString = difference.
getAsString();
12885 Diag(LParenLoc, diag::err_pointer_to_member_call_drops_quals)
12886 << fnType.getUnqualifiedType()
12888 << (qualsString.find(
' ') == std::string::npos ? 1 : 2);
12895 if (CheckCallReturnType(proto->
getReturnType(), op->getRHS()->getBeginLoc(),
12899 if (ConvertArgumentsForCall(call, op,
nullptr, proto, Args, RParenLoc))
12902 if (CheckOtherCall(call, proto))
12905 return MaybeBindToTemporary(call);
12908 if (isa<CXXPseudoDestructorExpr>(NakedMemExpr))
12912 UnbridgedCastsSet UnbridgedCasts;
12920 if (isa<MemberExpr>(NakedMemExpr)) {
12921 MemExpr = cast<MemberExpr>(NakedMemExpr);
12925 UnbridgedCasts.restore();
12943 TemplateArgs = &TemplateArgsBuffer;
12947 E = UnresExpr->
decls_end(); I != E; ++I) {
12951 if (isa<UsingShadowDecl>(Func))
12952 Func = cast<UsingShadowDecl>(Func)->getTargetDecl();
12956 if (getLangOpts().MicrosoftExt && isa<CXXConstructorDecl>(Func)) {
12957 AddOverloadCandidate(cast<CXXConstructorDecl>(Func), I.getPair(),
12958 Args, CandidateSet);
12959 }
else if ((Method = dyn_cast<CXXMethodDecl>(Func))) {
12965 AddMethodCandidate(Method, I.getPair(), ActingDC, ObjectType,
12966 ObjectClassification, Args, CandidateSet,
12969 AddMethodTemplateCandidate(
12970 cast<FunctionTemplateDecl>(Func), I.getPair(), ActingDC,
12971 TemplateArgs, ObjectType, ObjectClassification, Args, CandidateSet,
12978 UnbridgedCasts.restore();
12981 switch (CandidateSet.BestViableFunction(*
this, UnresExpr->
getBeginLoc(),
12984 Method = cast<CXXMethodDecl>(Best->Function);
12985 FoundDecl = Best->FoundDecl;
12986 CheckUnresolvedMemberAccess(UnresExpr, Best->FoundDecl);
12987 if (DiagnoseUseOfDecl(Best->FoundDecl, UnresExpr->
getNameLoc()))
12995 if (Method != FoundDecl.getDecl() &&
12996 DiagnoseUseOfDecl(Method, UnresExpr->
getNameLoc()))
13002 diag::err_ovl_no_viable_member_function_in_call)
13017 << Best->Function->isDeleted()
13019 << getDeletedOrUnavailableSuffix(Best->Function)
13026 MemExprE = FixOverloadedFunctionReference(MemExprE, FoundDecl, Method);
13031 return BuildResolvedCallExpr(MemExprE, Method, LParenLoc, Args,
13040 ResultType = ResultType.getNonLValueExprType(Context);
13042 assert(Method &&
"Member call to something that isn't a method?");
13046 RParenLoc, Proto->getNumParams());
13058 PerformObjectArgumentInitialization(MemExpr->
getBase(), Qualifier,
13059 FoundDecl, Method);
13066 if (ConvertArgumentsForCall(TheCall, MemExpr, Method, Proto, Args,
13070 DiagnoseSentinelCalls(Method, LParenLoc, Args);
13072 if (CheckFunctionCall(Method, TheCall, Proto))
13078 if (
auto *MemE = dyn_cast<MemberExpr>(NakedMemExpr)) {
13079 if (
const EnableIfAttr *
Attr = CheckEnableIf(Method, Args,
true)) {
13080 Diag(MemE->getMemberLoc(),
13081 diag::err_ovl_no_viable_member_function_in_call)
13084 diag::note_ovl_candidate_disabled_by_function_cond_attr)
13085 <<
Attr->getCond()->getSourceRange() <<
Attr->getMessage();
13090 if ((isa<CXXConstructorDecl>(CurContext) ||
13091 isa<CXXDestructorDecl>(CurContext)) &&
13092 TheCall->getMethodDecl()->isPure()) {
13098 diag::warn_call_to_pure_virtual_member_function_from_ctor_dtor)
13099 << MD->
getDeclName() << isa<CXXDestructorDecl>(CurContext)
13103 if (getLangOpts().AppleKext)
13110 dyn_cast<CXXDestructorDecl>(TheCall->getMethodDecl())) {
13112 bool CallCanBeVirtual = !MemExpr->
hasQualifier() || getLangOpts().AppleKext;
13113 CheckVirtualDtorCall(DD, MemExpr->
getBeginLoc(),
false,
13114 CallCanBeVirtual,
true,
13118 return MaybeBindToTemporary(TheCall);
13134 UnbridgedCastsSet UnbridgedCasts;
13138 assert(Object.
get()->getType()->isRecordType() &&
13139 "Requires object type argument");
13153 if (RequireCompleteType(LParenLoc, Object.
get()->getType(),
13154 diag::err_incomplete_object_call, Object.
get()))
13157 LookupResult R(*
this, OpName, LParenLoc, LookupOrdinaryName);
13158 LookupQualifiedName(R, Record->getDecl());
13162 Oper != OperEnd; ++Oper) {
13163 AddMethodCandidate(Oper.getPair(), Object.
get()->getType(),
13164 Object.
get()->Classify(Context), Args, CandidateSet,
13185 const auto &Conversions =
13186 cast<CXXRecordDecl>(Record->getDecl())->getVisibleConversionFunctions();
13187 for (
auto I = Conversions.begin(), E = Conversions.end(); I != E; ++I) {
13190 if (isa<UsingShadowDecl>(D))
13191 D = cast<UsingShadowDecl>(D)->getTargetDecl();
13195 if (isa<FunctionTemplateDecl>(D))
13208 AddSurrogateCandidate(Conv, I.getPair(), ActingContext, Proto,
13209 Object.
get(), Args, CandidateSet);
13214 bool HadMultipleCandidates = (CandidateSet.size() > 1);
13218 switch (CandidateSet.BestViableFunction(*
this, Object.
get()->getBeginLoc(),
13226 if (CandidateSet.empty())
13227 Diag(Object.
get()->getBeginLoc(), diag::err_ovl_no_oper)
13228 << Object.
get()->getType() << 1
13229 << Object.
get()->getSourceRange();
13231 Diag(Object.
get()->getBeginLoc(), diag::err_ovl_no_viable_object_call)
13232 << Object.
get()->getType() << Object.
get()->getSourceRange();
13237 Diag(Object.
get()->getBeginLoc(), diag::err_ovl_ambiguous_object_call)
13238 << Object.
get()->getType() << Object.
get()->getSourceRange();
13243 Diag(Object.
get()->getBeginLoc(), diag::err_ovl_deleted_object_call)
13244 << Best->Function->isDeleted() << Object.
get()->getType()
13245 << getDeletedOrUnavailableSuffix(Best->Function)
13246 << Object.
get()->getSourceRange();
13251 if (Best == CandidateSet.end())
13254 UnbridgedCasts.restore();
13256 if (Best->Function ==
nullptr) {
13260 = cast<CXXConversionDecl>(
13261 Best->Conversions[0].UserDefined.ConversionFunction);
13263 CheckMemberOperatorAccess(LParenLoc, Object.
get(),
nullptr,
13265 if (DiagnoseUseOfDecl(Best->FoundDecl, LParenLoc))
13267 assert(Conv == Best->FoundDecl.getDecl() &&
13268 "Found Decl & conversion-to-functionptr should be same, right?!");
13275 ExprResult Call = BuildCXXMemberCallExpr(Object.
get(), Best->FoundDecl,
13276 Conv, HadMultipleCandidates);
13277 if (Call.isInvalid())
13281 CK_UserDefinedConversion, Call.get(),
13284 return ActOnCallExpr(S, Call.get(), LParenLoc, Args, RParenLoc);
13287 CheckMemberOperatorAccess(LParenLoc, Object.
get(),
nullptr, Best->FoundDecl);
13292 CXXMethodDecl *Method = cast<CXXMethodDecl>(Best->Function);
13295 if (Method->isInvalidDecl())
13307 Obj, HadMultipleCandidates,
13308 OpLocInfo.getLoc(),
13309 OpLocInfo.getInfo());
13316 unsigned NumArgsSlots = 1 + std::max<unsigned>(Args.size(), NumParams);
13322 bool IsError =
false;
13326 PerformObjectArgumentInitialization(Object.
get(),
nullptr,
13327 Best->FoundDecl, Method);
13332 MethodArgs[0] = Object.
get();
13335 for (
unsigned i = 0; i != NumParams; i++) {
13337 if (i < Args.size()) {
13345 Method->getParamDecl(i)),
13352 = BuildCXXDefaultArgExpr(LParenLoc, Method, Method->getParamDecl(i));
13361 MethodArgs[i + 1] = Arg;
13367 for (
unsigned i = NumParams, e = Args.size(); i < e; i++) {
13368 ExprResult Arg = DefaultVariadicArgumentPromotion(Args[i], VariadicMethod,
13371 MethodArgs[i + 1] = Arg.
get();
13378 DiagnoseSentinelCalls(Method, LParenLoc, Args);
13381 QualType ResultTy = Method->getReturnType();
13389 if (CheckCallReturnType(Method->getReturnType(), LParenLoc, TheCall, Method))
13392 if (CheckFunctionCall(Method, TheCall, Proto))
13395 return MaybeBindToTemporary(TheCall);
13403 bool *NoArrowOperatorFound) {
13405 "left-hand side must have class type");
13423 if (RequireCompleteType(Loc, Base->
getType(),
13424 diag::err_typecheck_incomplete_tag, Base))
13427 LookupResult R(*
this, OpName, OpLoc, LookupOrdinaryName);
13428 LookupQualifiedName(R, BaseRecord->
getDecl());
13432 Oper != OperEnd; ++Oper) {
13433 AddMethodCandidate(Oper.getPair(), Base->
getType(), Base->
Classify(Context),
13434 None, CandidateSet,
false);
13437 bool HadMultipleCandidates = (CandidateSet.
size() > 1);
13447 if (CandidateSet.
empty()) {
13449 if (NoArrowOperatorFound) {
13452 *NoArrowOperatorFound =
true;
13455 Diag(OpLoc, diag::err_typecheck_member_reference_arrow)
13458 Diag(OpLoc, diag::note_typecheck_member_reference_suggestion)
13462 Diag(OpLoc, diag::err_ovl_no_viable_oper)
13468 Diag(OpLoc, diag::err_ovl_ambiguous_oper_unary)
13474 Diag(OpLoc, diag::err_ovl_deleted_oper)
13475 << Best->Function->isDeleted()
13477 << getDeletedOrUnavailableSuffix(Best->Function)
13483 CheckMemberOperatorAccess(OpLoc, Base,
nullptr, Best->FoundDecl);
13486 CXXMethodDecl *Method = cast<CXXMethodDecl>(Best->Function);
13488 PerformObjectArgumentInitialization(Base,
nullptr,
13489 Best->FoundDecl, Method);
13490 if (BaseResult.isInvalid())
13492 Base = BaseResult.get();
13496 Base, HadMultipleCandidates, OpLoc);
13504 Context, OO_Arrow, FnExpr.
get(), Base, ResultTy, VK, OpLoc,
FPOptions());
13506 if (CheckCallReturnType(Method->
getReturnType(), OpLoc, TheCall, Method))
13509 if (CheckFunctionCall(Method, TheCall,
13513 return MaybeBindToTemporary(TheCall);
13527 AddFunctionCandidates(R.
asUnresolvedSet(), Args, CandidateSet, TemplateArgs,
13530 bool HadMultipleCandidates = (CandidateSet.size() > 1);
13535 switch (CandidateSet.BestViableFunction(*
this, UDSuffixLoc, Best)) {
13541 Diag(UDSuffixLoc, diag::err_ovl_no_viable_function_in_call)
13554 nullptr, HadMultipleCandidates,
13563 for (
unsigned ArgIdx = 0, N = Args.size(); ArgIdx != N; ++ArgIdx) {
13564 ExprResult InputInit = PerformCopyInitialization(
13569 ConvArgs[ArgIdx] = InputInit.
get();
13577 Context, Fn.
get(), llvm::makeArrayRef(ConvArgs, Args.size()), ResultTy,
13578 VK, LitEndLoc, UDSuffixLoc);
13580 if (CheckCallReturnType(FD->
getReturnType(), UDSuffixLoc, UDL, FD))
13583 if (CheckFunctionCall(FD, UDL,
nullptr))
13586 return MaybeBindToTemporary(UDL);
13603 Scope *S =
nullptr;
13606 if (!MemberLookup.
empty()) {
13608 BuildMemberReferenceExpr(Range, Range->
getType(), Loc,
13616 return FRS_DiagnosticIssued;
13618 *CallExpr = ActOnCallExpr(S, MemberRef.
get(), Loc, None, Loc,
nullptr);
13621 return FRS_DiagnosticIssued;
13629 FoundNames.
begin(), FoundNames.
end());
13631 bool CandidateSetError = buildOverloadedCallSet(S, Fn, Fn, Range, Loc,
13632 CandidateSet, CallExpr);
13633 if (CandidateSet->
empty() || CandidateSetError) {
13635 return FRS_NoViableFunction;
13643 return FRS_NoViableFunction;
13646 Loc,
nullptr, CandidateSet, &Best,
13651 return FRS_DiagnosticIssued;
13654 return FRS_Success;
13665 if (
ParenExpr *PE = dyn_cast<ParenExpr>(E)) {
13666 Expr *SubExpr = FixOverloadedFunctionReference(PE->getSubExpr(),
13668 if (SubExpr == PE->getSubExpr())
13671 return new (Context)
ParenExpr(PE->getLParen(), PE->getRParen(), SubExpr);
13675 Expr *SubExpr = FixOverloadedFunctionReference(ICE->getSubExpr(),
13677 assert(Context.
hasSameType(ICE->getSubExpr()->getType(),
13679 "Implicit cast type cannot be determined from overload");
13680 assert(ICE->path_empty() &&
"fixing up hierarchy conversion?");
13681 if (SubExpr == ICE->getSubExpr())
13685 ICE->getCastKind(),
13690 if (
auto *GSE = dyn_cast<GenericSelectionExpr>(E)) {
13691 if (!GSE->isResultDependent()) {
13693 FixOverloadedFunctionReference(GSE->getResultExpr(), Found, Fn);
13694 if (SubExpr == GSE->getResultExpr())
13701 unsigned ResultIdx = GSE->getResultIndex();
13702 AssocExprs[ResultIdx] = SubExpr;
13705 Context, GSE->getGenericLoc(), GSE->getControllingExpr(),
13706 GSE->getAssocTypeSourceInfos(), AssocExprs, GSE->getDefaultLoc(),
13707 GSE->getRParenLoc(), GSE->containsUnexpandedParameterPack(),
13716 assert(UnOp->getOpcode() == UO_AddrOf &&
13717 "Can only take the address of an overloaded function");
13719 if (Method->isStatic()) {
13726 Expr *SubExpr = FixOverloadedFunctionReference(UnOp->getSubExpr(),
13728 if (SubExpr == UnOp->getSubExpr())
13731 assert(isa<DeclRefExpr>(SubExpr)
13732 &&
"fixed to something other than a decl ref");
13733 assert(cast<DeclRefExpr>(SubExpr)->getQualifier()
13734 &&
"fixed to a member ref with no nested name qualifier");
13740 = Context.
getTypeDeclType(cast<RecordDecl>(Method->getDeclContext()));
13745 (
void)isCompleteType(UnOp->getOperatorLoc(), MemPtrType);
13747 return new (Context)
UnaryOperator(SubExpr, UO_AddrOf, MemPtrType,
13749 UnOp->getOperatorLoc(),
false);
13752 Expr *SubExpr = FixOverloadedFunctionReference(UnOp->getSubExpr(),
13754 if (SubExpr == UnOp->getSubExpr())
13760 UnOp->getOperatorLoc(),
false);
13773 if (ULE->hasExplicitTemplateArgs()) {
13774 ULE->copyTemplateArgumentsInto(TemplateArgsBuffer);
13775 TemplateArgs = &TemplateArgsBuffer;
13779 ULE->getQualifierLoc(),
13780 ULE->getTemplateKeywordLoc(),
13788 MarkDeclRefReferenced(DRE);
13796 if (MemExpr->hasExplicitTemplateArgs()) {
13797 MemExpr->copyTemplateArgumentsInto(TemplateArgsBuffer);
13798 TemplateArgs = &TemplateArgsBuffer;
13805 if (MemExpr->isImplicitAccess()) {
13806 if (cast<CXXMethodDecl>(Fn)->isStatic()) {
13808 MemExpr->getQualifierLoc(),
13809 MemExpr->getTemplateKeywordLoc(),
13812 MemExpr->getMemberLoc(),
13817 MarkDeclRefReferenced(DRE);
13822 if (MemExpr->getQualifier())
13823 Loc = MemExpr->getQualifierLoc().getBeginLoc();
13824 CheckCXXThisCapture(Loc);
13826 MemExpr->getBaseType(),
13830 Base = MemExpr->getBase();
13834 if (cast<CXXMethodDecl>(Fn)->isStatic()) {
13843 Context, Base, MemExpr->isArrow(), MemExpr->getOperatorLoc(),
13844 MemExpr->getQualifierLoc(), MemExpr->getTemplateKeywordLoc(), Fn, Found,
13845 MemExpr->getMemberNameInfo(), TemplateArgs,
type, valueKind,
13848 MarkMemberReferenced(ME);
13852 llvm_unreachable(
"Invalid reference to overloaded function");
13858 return FixOverloadedFunctionReference(E.
get(), Found, Fn);
Abstract class used to diagnose incomplete types.
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.
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.
void AddMethodCandidate(DeclAccessPair FoundDecl, QualType ObjectType, Expr::Classification ObjectClassification, ArrayRef< Expr *> Args, OverloadCandidateSet &CandidateSet, bool SuppressUserConversion=false)
AddMethodCandidate - Adds a named decl (which is some kind of method) as a method candidate to the gi...
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
llvm::PointerUnion3< TemplateTypeParmDecl *, NonTypeTemplateParmDecl *, TemplateTemplateParmDecl * > TemplateParameter
Stores a template parameter of any kind.
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.
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.
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
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
Returns the type of the this pointer.
Complex conversions (C99 6.3.1.6)
void setObjCLifetime(ObjCLifetime type)
bool isRecordType() const
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.
bool IsOverload(FunctionDecl *New, FunctionDecl *Old, bool IsForUsingDecl, bool ConsiderCudaAttrs=true)
ConstExprUsage
Indicates how the constant expression will be used.
OverloadedOperatorKind getCXXOverloadedOperator() const
If this name is the name of an overloadable operator in C++ (e.g., operator+), retrieve the kind of o...
Classification Classify(ASTContext &Ctx) const
Classify - Classify this expression according to the C++11 expression taxonomy.
Not a narrowing conversion.
bool isBeforeInTranslationUnit(SourceLocation LHS, SourceLocation RHS) const
Determines the order of 2 source locations in the translation unit.
llvm::iterator_range< conversion_iterator > getVisibleConversionFunctions()
Get all conversion functions visible in current class, including conversion function templates...
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 ...
static void NoteFunctionCandidate(Sema &S, OverloadCandidate *Cand, unsigned NumArgs, bool TakingCandidateAddress)
Generates a 'note' diagnostic for an overload candidate.
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
QualType getValueType() const
Gets the type contained by this atomic type, i.e.
Conversions between compatible types in C99.
Floating point control options.
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
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
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...
std::string getDeletedOrUnavailableSuffix(const FunctionDecl *FD)
Retrieve the message suffix that should be added to a diagnostic complaining about the given function...
ObjCMethodDecl - Represents an instance or class method declaration.
NamedDecl * getUnderlyingDecl()
Looks through UsingDecls and ObjCCompatibleAliasDecls for the underlying named decl.
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.
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.
std::string getName(ArrayRef< StringRef > Parts) const
Get the platform-specific name separator.
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
ExprResult ActOnCallExpr(Scope *S, Expr *Fn, SourceLocation LParenLoc, MultiExprArg ArgExprs, SourceLocation RParenLoc, Expr *ExecConfig=nullptr, bool IsExecConfig=false)
ActOnCallExpr - Handle a call to Fn with the specified array of arguments.
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.
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.
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...
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.
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.
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.
static DeclRefExpr * Create(const ASTContext &Context, NestedNameSpecifierLoc QualifierLoc, SourceLocation TemplateKWLoc, ValueDecl *D, bool RefersToEnclosingVariableOrCapture, SourceLocation NameLoc, QualType T, ExprValueKind VK, NamedDecl *FoundD=nullptr, const TemplateArgumentListInfo *TemplateArgs=nullptr)
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.
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
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...
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.
void AddTemplateOverloadCandidate(FunctionTemplateDecl *FunctionTemplate, DeclAccessPair FoundDecl, TemplateArgumentListInfo *ExplicitTemplateArgs, ArrayRef< Expr *> Args, OverloadCandidateSet &CandidateSet, bool SuppressUserConversions=false, bool PartialOverloading=false, ADLCallKind IsADLCandidate=ADLCallKind::NotADL)
Add a C++ function template specialization as a candidate in the candidate set, using template argume...
bool isFunctionConsideredUnavailable(FunctionDecl *FD)
Checks availability of the function depending on the current function context.Inside an unavailable f...
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 ...
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.
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...
ReferenceCompareResult CompareReferenceRelationship(SourceLocation Loc, QualType T1, QualType T2, bool &DerivedToBase, bool &ObjCConversion, bool &ObjCLifetimeConversion)
CompareReferenceRelationship - Compare the two types T1 and T2 to determine whether they are referenc...
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.
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.
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
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...
std::string getAsString(ASTContext &Ctx, QualType Ty) const
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
IgnoreParenCasts - Ignore parentheses and casts.
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.
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...
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.
Qualifiers getTypeQuals() const
ConversionSequenceList Conversions
The conversion sequences used to convert the function arguments to the function parameters.
FunctionDecl * resolveAddressOfOnlyViableOverloadCandidate(Expr *E, DeclAccessPair &FoundResult)
Given an expression that refers to an overloaded function, try to resolve that function to a single f...
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...
bool IsStringLiteralToNonConstPointerConversion(Expr *From, QualType ToType)
Helper function to determine whether this is the (deprecated) C++ conversion from a string literal to...
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()
Represents the this expression in C++.
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
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.
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.
void erase(NamedDecl *D)
Removes any data associated with a given decl.
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 DiagnoseEmptyLookup(Scope *S, CXXScopeSpec &SS, LookupResult &R, std::unique_ptr< CorrectionCandidateCallback > CCC, TemplateArgumentListInfo *ExplicitTemplateArgs=nullptr, ArrayRef< Expr *> Args=None, TypoExpr **Out=nullptr)
Diagnose an empty lookup.
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.
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)
bool isNewCandidate(Decl *F)
Determine when this overload candidate will be new to the overload set.
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...
void AddTemplateConversionCandidate(FunctionTemplateDecl *FunctionTemplate, DeclAccessPair FoundDecl, CXXRecordDecl *ActingContext, Expr *From, QualType ToType, OverloadCandidateSet &CandidateSet, bool AllowObjCConversionOnExplicit, bool AllowResultConversion=true)
Adds a conversion function template specialization candidate to the overload set, using template argu...
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.
ExprResult CreateOverloadedBinOp(SourceLocation OpLoc, BinaryOperatorKind Opc, const UnresolvedSetImpl &Fns, Expr *LHS, Expr *RHS, bool RequiresADL=true)
Create a binary operation that may resolve to an overloaded operator.
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
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.
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...
bool isObjCBuiltinType() const
const T * castAs() const
Member-template castAs<specific type>.
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
static void CompleteNonViableCandidate(Sema &S, OverloadCandidate *Cand, ArrayRef< Expr *> Args)
CompleteNonViableCandidate - Normally, overload resolution only computes up to the first bad conversi...
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...
bool performsVirtualDispatch(const LangOptions &LO) const
Returns true if virtual dispatch is performed.
ObjCLifetime getObjCLifetime() const
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 ...
unsigned ReferenceBinding
ReferenceBinding - True when this is a reference binding (C++ [over.ics.ref]).
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...
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...
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.
Qualifiers getTypeQualifiers() const
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 DiagnoseAmbiguousConversion(Sema &S, SourceLocation CaretLoc, const PartialDiagnostic &PDiag) const
Diagnoses an ambiguous conversion.
bool resolveAndFixAddressOfOnlyViableOverloadCandidate(ExprResult &SrcExpr, bool DoFunctionPointerConversion=false)
Given an overloaded function, tries to turn it into a non-overloaded function reference using resolve...
static const FunctionProtoType * tryGetFunctionProtoType(QualType FromType)
Attempts to get the FunctionProtoType from a Type.
QualType getRecordType(const RecordDecl *Decl) const
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.
void AddConversionCandidate(CXXConversionDecl *Conversion, DeclAccessPair FoundDecl, CXXRecordDecl *ActingContext, Expr *From, QualType ToType, OverloadCandidateSet &CandidateSet, bool AllowObjCConversionOnExplicit, bool AllowResultConversion=true)
AddConversionCandidate - Add a C++ conversion function as a candidate in the candidate set (C++ [over...
unsigned getNumArgs() const
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)
Add a C++ member function template as a candidate to the candidate set, using template argument deduc...
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 isNull() const
Return true if this QualType doesn't point to a type yet.
bool isVolatileQualified() const
OverloadsShown getShowOverloads() const
FriendObjectKind getFriendObjectKind() const
Determines whether this declaration is the object of a friend declaration and, if so...
SourceLocation getEndLoc() const LLVM_READONLY
unsigned getCVRQualifiers() const
Retrieve the set of CVR (const-volatile-restrict) qualifiers applied to this type.
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
Whether this function is 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...
static bool isNullPointerConstantForConversion(Expr *Expr, bool InOverloadResolution, ASTContext &Context)
OpaqueValueExpr - An expression referring to an opaque object of a fixed type and value class...
static std::unique_ptr< CorrectionCandidateCallback > MakeValidator(Sema &SemaRef, MemberExpr *ME, size_t NumArgs, bool HasTemplateArgs, bool AllowTypoCorrection)
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...
ImplicitConversionSequence - Represents an implicit conversion sequence, which may be a standard conv...
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)
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 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...
static ConstantExpr * Create(const ASTContext &Context, Expr *E)
MutableArrayRef< Expr * > MultiExprArg
void AddMemberOperatorCandidates(OverloadedOperatorKind Op, SourceLocation OpLoc, ArrayRef< Expr *> Args, OverloadCandidateSet &CandidateSet, SourceRange OpRange=SourceRange())
Add overload candidates for overloaded operators that are member functions.
Represents a call to a member function that may be written either with member call syntax (e...
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 void DiagnoseBadConversion(Sema &S, OverloadCandidate *Cand, unsigned I, bool TakingCandidateAddress)
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.
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.
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 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)
bool isLValue() const
isLValue - True if this expression is an "l-value" according to the rules of the current language...
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...
void AddOverloadCandidate(FunctionDecl *Function, DeclAccessPair FoundDecl, ArrayRef< Expr *> Args, OverloadCandidateSet &CandidateSet, bool SuppressUserConversions=false, bool PartialOverloading=false, bool AllowExplicit=false, ADLCallKind IsADLCandidate=ADLCallKind::NotADL, ConversionSequenceList EarlyConversions=None)
AddOverloadCandidate - Adds the given function to the set of candidate functions, using the given fun...
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.
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)
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...
static MemberExpr * Create(const ASTContext &C, Expr *base, bool isarrow, SourceLocation OperatorLoc, NestedNameSpecifierLoc QualifierLoc, SourceLocation TemplateKWLoc, ValueDecl *memberdecl, DeclAccessPair founddecl, DeclarationNameInfo MemberNameInfo, const TemplateArgumentListInfo *targs, QualType ty, ExprValueKind VK, ExprObjectKind OK)
void NoteOverloadCandidate(NamedDecl *Found, FunctionDecl *Fn, QualType DestType=QualType(), bool TakingAddress=false)
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)
Represents a C11 generic selection.
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
static const Expr * IgnoreNarrowingConversion(const Expr *Converted)
Skip any implicit casts which could be either part of a narrowing conversion or after one in an impli...
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.).
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...
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.
BinaryOperator::Opcode getOpcode(const SymExpr *SE)
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++.
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.
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
Returns 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.
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. ...
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.
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={})
Check that implicit conversion sequences can be formed for each argument whose corresponding paramete...
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 isUndeducedType() const
Determine whether this type is an undeduced type, meaning that it somehow involves a C++11 'auto' typ...
void Profile(llvm::FoldingSetNodeID &ID) const
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)
void setHadMultipleCandidates(bool V=true)
Sets the flag telling whether this expression refers to a method that was resolved from an overloaded...
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.
unsigned getKindRank() const
Return a ranking of the implicit conversion sequence kind, where smaller ranks represent better conve...
Expr * getUninstantiatedDefaultArg()
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...
unsigned getCVRUQualifiers() const
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...
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 isAddressSpaceSupersetOf(Qualifiers other) const
Returns true if this address space is a superset of the other one.
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.
AccessResult CheckMemberOperatorAccess(SourceLocation Loc, Expr *ObjectExpr, Expr *ArgExpr, DeclAccessPair FoundDecl)
Checks access to an overloaded member operator, including conversion operators.
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.
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...
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 ...
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
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.
Qualifiers getQualifiers() const
Retrieve the set of qualifiers applied to this type.
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)
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.
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'.
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...
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.
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.
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.
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...
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
__DEVICE__ int min(int __a, int __b)
Zero constant to event (OpenCL1.2 6.12.10)
unsigned CallArgIndex
The index of the function argument that caused a deduction failure.
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)
SmallVector< TemplateSpecCandidate, 16 >::iterator iterator
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...
void NoteCandidates(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...
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
IgnoreParens - Ignore parentheses.
bool isUnavailable(std::string *Message=nullptr) const
Determine whether this declaration is marked 'unavailable'.
CanQualType UnsignedIntTy
bool hasErrorOccurred() const
Determine whether any SFINAE errors have been trapped.
unsigned NumConversionsFixed
The number of Conversions fixed.
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)