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;
1044 return Ovl_Overload;
1048 bool UseMemberUsingDeclRules,
bool ConsiderCudaAttrs) {
1063 if ((OldTemplate ==
nullptr) != (NewTemplate ==
nullptr))
1076 if (isa<FunctionNoProtoType>(OldQType.
getTypePtr()) ||
1077 isa<FunctionNoProtoType>(NewQType.
getTypePtr()))
1086 if (OldQType != NewQType &&
1088 OldType->
isVariadic() != NewType->isVariadic() ||
1089 !FunctionParamTypesAreEqual(OldType, NewType)))
1104 if (!UseMemberUsingDeclRules && NewTemplate &&
1107 false, TPL_TemplateMatch) ||
1121 if (OldMethod && NewMethod &&
1122 !OldMethod->
isStatic() && !NewMethod->isStatic()) {
1124 if (!UseMemberUsingDeclRules &&
1126 NewMethod->getRefQualifier() ==
RQ_None)) {
1133 Diag(NewMethod->getLocation(), diag::err_ref_qualifier_overload)
1145 unsigned NewQuals = NewMethod->getTypeQualifiers();
1146 if (!getLangOpts().
CPlusPlus14 && NewMethod->isConstexpr() &&
1147 !isa<CXXConstructorDecl>(NewMethod))
1153 if (OldQuals != NewQuals)
1171 NewI != NewE || OldI != OldE; ++NewI, ++OldI) {
1172 if (NewI == NewE || OldI == OldE)
1174 llvm::FoldingSetNodeID NewID, OldID;
1175 NewI->getCond()->
Profile(NewID, Context,
true);
1176 OldI->getCond()->Profile(OldID, Context,
true);
1181 if (getLangOpts().CUDA && ConsiderCudaAttrs) {
1184 if (isa<CXXDestructorDecl>(New))
1188 OldTarget = IdentifyCUDATarget(Old);
1189 if (NewTarget == CFT_InvalidTarget)
1192 assert((OldTarget != CFT_InvalidTarget) &&
"Unexpected invalid target.");
1196 return NewTarget != OldTarget;
1213 Decl *C = cast<Decl>(CurContext);
1227 bool SuppressUserConversions,
1229 bool InOverloadResolution,
1231 bool AllowObjCWritebackConversion,
1232 bool AllowObjCConversionOnExplicit) {
1235 if (SuppressUserConversions) {
1246 Conversions, AllowExplicit,
1247 AllowObjCConversionOnExplicit)) {
1264 if (Constructor->isCopyConstructor() &&
1265 (FromCanon == ToCanon ||
1276 if (ToCanon != FromCanon)
1287 Cand != Conversions.
end(); ++Cand)
1330 bool SuppressUserConversions,
1332 bool InOverloadResolution,
1334 bool AllowObjCWritebackConversion,
1335 bool AllowObjCConversionOnExplicit) {
1338 ICS.
Standard, CStyle, AllowObjCWritebackConversion)){
1378 AllowExplicit, InOverloadResolution, CStyle,
1379 AllowObjCWritebackConversion,
1380 AllowObjCConversionOnExplicit);
1385 bool SuppressUserConversions,
1387 bool InOverloadResolution,
1389 bool AllowObjCWritebackConversion) {
1391 SuppressUserConversions, AllowExplicit,
1392 InOverloadResolution, CStyle,
1393 AllowObjCWritebackConversion,
1406 return PerformImplicitConversion(From, ToType, Action, AllowExplicit, ICS);
1417 bool AllowObjCWritebackConversion
1418 = getLangOpts().ObjCAutoRefCount &&
1419 (Action == AA_Passing || Action == AA_Sending);
1420 if (getLangOpts().ObjC1)
1421 CheckObjCBridgeRelatedConversions(From->
getLocStart(),
1422 ToType, From->
getType(), From);
1428 AllowObjCWritebackConversion,
1430 return PerformImplicitConversion(From, ToType, ICS, Action);
1451 if (TyClass != CanFrom->getTypeClass())
return false;
1452 if (TyClass != Type::FunctionProto && TyClass != Type::FunctionNoProto) {
1453 if (TyClass == Type::Pointer) {
1456 }
else if (TyClass == Type::BlockPointer) {
1459 }
else if (TyClass == Type::MemberPointer) {
1463 if (ToMPT->getClass() != FromMPT->
getClass())
1465 CanTo = ToMPT->getPointeeType();
1471 TyClass = CanTo->getTypeClass();
1472 if (TyClass != CanFrom->getTypeClass())
return false;
1473 if (TyClass != Type::FunctionProto && TyClass != Type::FunctionNoProto)
1477 const auto *FromFn = cast<FunctionType>(CanFrom);
1480 const auto *ToFn = cast<FunctionType>(CanTo);
1483 bool Changed =
false;
1486 if (FromEInfo.getNoReturn() && !ToEInfo.getNoReturn()) {
1492 if (
const auto *FromFPT = dyn_cast<FunctionProtoType>(FromFn)) {
1493 const auto *ToFPT = cast<FunctionProtoType>(ToFn);
1494 if (FromFPT->isNothrow() && !ToFPT->isNothrow()) {
1495 FromFn = cast<FunctionType>(
1506 bool CanUseToFPT, CanUseFromFPT;
1508 CanUseFromFPT, NewParamInfos) &&
1509 CanUseToFPT && !CanUseFromFPT) {
1512 NewParamInfos.empty() ? nullptr : NewParamInfos.data();
1514 FromFPT->getParamTypes(), ExtInfo);
1523 assert(
QualType(FromFn, 0).isCanonical());
1524 if (
QualType(FromFn, 0) != CanTo)
return false;
1576 bool InOverloadResolution,
1589 bool InOverloadResolution,
1592 bool AllowObjCWritebackConversion) {
1639 if (Method && !Method->
isStatic()) {
1641 "Non-unary operator on non-static member address");
1644 "Non-address-of operator on non-static member address");
1645 const Type *ClassType
1651 "Non-address-of operator for overloaded function expression");
1678 FromType = Atomic->getValueType();
1713 if (
auto *FD = dyn_cast<FunctionDecl>(DRE->getDecl()))
1733 bool IncompatibleObjC =
false;
1784 if (Float128AndLongDouble &&
1786 &llvm::APFloat::PPCDoubleDouble()))
1801 }
else if (AllowObjCWritebackConversion &&
1805 FromType, IncompatibleObjC)) {
1811 InOverloadResolution, FromType)) {
1823 InOverloadResolution,
1850 bool ObjCLifetimeConversion;
1856 ObjCLifetimeConversion)) {
1875 CanonFrom = CanonTo;
1880 if (CanonFrom == CanonTo)
1885 if (S.
getLangOpts().CPlusPlus || !InOverloadResolution)
1929 bool InOverloadResolution,
1939 for (
const auto *it : UD->
fields()) {
1942 ToType = it->getType();
1972 return To->
getKind() == BuiltinType::Int;
1975 return To->
getKind() == BuiltinType::UInt;
1999 if (FromEnumType->getDecl()->isScoped())
2006 if (FromEnumType->getDecl()->isFixed()) {
2007 QualType Underlying = FromEnumType->getDecl()->getIntegerType();
2009 IsIntegralPromotion(
nullptr, Underlying, ToType);
2016 ToType, FromEnumType->getDecl()->getPromotionType());
2023 if (getLangOpts().CPlusPlus)
2041 uint64_t FromSize = Context.
getTypeSize(FromType);
2050 for (
int Idx = 0; Idx < 6; ++Idx) {
2051 uint64_t ToSize = Context.
getTypeSize(PromoteTypes[Idx]);
2052 if (FromSize < ToSize ||
2053 (FromSize == ToSize &&
2054 FromIsSigned == PromoteTypes[Idx]->isSignedIntegerType())) {
2079 llvm::APSInt BitWidth;
2081 MemberDecl->getBitWidth()->isIntegerConstantExpr(BitWidth, Context)) {
2082 llvm::APSInt ToSize(BitWidth.getBitWidth(), BitWidth.isUnsigned());
2086 if (BitWidth < ToSize ||
2088 return To->
getKind() == BuiltinType::Int;
2094 return To->
getKind() == BuiltinType::UInt;
2119 if (FromBuiltin->getKind() == BuiltinType::Float &&
2120 ToBuiltin->getKind() == BuiltinType::Double)
2126 if (!getLangOpts().CPlusPlus &&
2127 (FromBuiltin->getKind() == BuiltinType::Float ||
2128 FromBuiltin->getKind() == BuiltinType::Double) &&
2129 (ToBuiltin->getKind() == BuiltinType::LongDouble ||
2130 ToBuiltin->getKind() == BuiltinType::Float128))
2134 if (!getLangOpts().NativeHalfType &&
2135 FromBuiltin->getKind() == BuiltinType::Half &&
2136 ToBuiltin->getKind() == BuiltinType::Float)
2173 bool StripObjCLifetime =
false) {
2176 "Invalid similarly-qualified pointer type");
2187 if (StripObjCLifetime)
2198 if (isa<ObjCObjectPointerType>(ToType))
2207 if (isa<ObjCObjectPointerType>(ToType))
2213 bool InOverloadResolution,
2219 return !InOverloadResolution;
2243 bool InOverloadResolution,
2245 bool &IncompatibleObjC) {
2246 IncompatibleObjC =
false;
2247 if (isObjCPointerConversion(FromType, ToType, ConvertedType,
2254 ConvertedType = ToType;
2261 ConvertedType = ToType;
2268 ConvertedType = ToType;
2276 ConvertedType = ToType;
2286 ConvertedType = ToType;
2294 !getLangOpts().ObjCAutoRefCount) {
2325 if (getLangOpts().MSVCCompat && FromPointeeType->
isFunctionType() &&
2359 IsDerivedFrom(From->
getLocStart(), FromPointeeType, ToPointeeType)) {
2396 bool &IncompatibleObjC) {
2397 if (!getLangOpts().ObjC1)
2409 if (ToObjCPtr && FromObjCPtr) {
2420 if (getLangOpts().
CPlusPlus && LHS && RHS &&
2422 FromObjCPtr->getPointeeType()))
2427 ConvertedType =
AdoptQualifiers(Context, ConvertedType, FromQualifiers);
2435 IncompatibleObjC =
true;
2439 ConvertedType =
AdoptQualifiers(Context, ConvertedType, FromQualifiers);
2451 if (FromObjCPtr && FromObjCPtr->isObjCBuiltinType()) {
2479 isObjCPointerConversion(FromPointeeType, ToPointeeType, ConvertedType,
2480 IncompatibleObjC)) {
2482 IncompatibleObjC =
true;
2484 ConvertedType =
AdoptQualifiers(Context, ConvertedType, FromQualifiers);
2491 isObjCPointerConversion(FromPointeeType, ToPointeeType, ConvertedType,
2492 IncompatibleObjC)) {
2495 ConvertedType =
AdoptQualifiers(Context, ConvertedType, FromQualifiers);
2507 if (FromFunctionType && ToFunctionType) {
2516 if (FromFunctionType->
getNumParams() != ToFunctionType->getNumParams() ||
2517 FromFunctionType->
isVariadic() != ToFunctionType->isVariadic() ||
2518 FromFunctionType->
getTypeQuals() != ToFunctionType->getTypeQuals())
2521 bool HasObjCConversion =
false;
2525 }
else if (isObjCPointerConversion(FromFunctionType->
getReturnType(),
2526 ToFunctionType->getReturnType(),
2527 ConvertedType, IncompatibleObjC)) {
2529 HasObjCConversion =
true;
2536 for (
unsigned ArgIdx = 0, NumArgs = FromFunctionType->
getNumParams();
2537 ArgIdx != NumArgs; ++ArgIdx) {
2539 QualType ToArgType = ToFunctionType->getParamType(ArgIdx);
2543 }
else if (isObjCPointerConversion(FromArgType, ToArgType,
2544 ConvertedType, IncompatibleObjC)) {
2546 HasObjCConversion =
true;
2553 if (HasObjCConversion) {
2557 IncompatibleObjC =
true;
2576 if (!getLangOpts().ObjCAutoRefCount ||
2618 bool IncompatibleObjC;
2620 FromPointee = ToPointee;
2621 else if (!isObjCPointerConversion(FromPointee, ToPointee, FromPointee,
2656 if (!FromFunctionType || !ToFunctionType)
2659 if (Context.
hasSameType(FromPointeeType, ToPointeeType))
2664 if (FromFunctionType->
getNumParams() != ToFunctionType->getNumParams() ||
2665 FromFunctionType->
isVariadic() != ToFunctionType->isVariadic())
2670 if (FromEInfo != ToEInfo)
2673 bool IncompatibleObjC =
false;
2675 ToFunctionType->getReturnType())) {
2679 QualType LHS = ToFunctionType->getReturnType();
2686 }
else if (isObjCPointerConversion(RHS, LHS,
2687 ConvertedType, IncompatibleObjC)) {
2688 if (IncompatibleObjC)
2697 for (
unsigned ArgIdx = 0, NumArgs = FromFunctionType->
getNumParams();
2698 ArgIdx != NumArgs; ++ArgIdx) {
2699 IncompatibleObjC =
false;
2701 QualType ToArgType = ToFunctionType->getParamType(ArgIdx);
2702 if (Context.
hasSameType(FromArgType, ToArgType)) {
2704 }
else if (isObjCPointerConversion(ToArgType, FromArgType,
2705 ConvertedType, IncompatibleObjC)) {
2706 if (IncompatibleObjC)
2715 bool CanUseToFPT, CanUseFromFPT;
2717 CanUseToFPT, CanUseFromFPT,
2721 ConvertedType = ToType;
2797 if (!FromFunction || !ToFunction) {
2802 if (FromFunction->
getNumParams() != ToFunction->getNumParams()) {
2810 if (!FunctionParamTypesAreEqual(FromFunction, ToFunction, &ArgPos)) {
2812 << ToFunction->getParamType(ArgPos)
2819 ToFunction->getReturnType())) {
2826 ToQuals = ToFunction->getTypeQuals();
2827 if (FromQuals != ToQuals) {
2836 cast<FunctionProtoType>(ToFunction->getCanonicalTypeUnqualified())
2856 O && (O != E); ++O, ++N) {
2858 N->getUnqualifiedType())) {
2876 bool IgnoreBaseAccess,
2879 bool IsCStyleOrFunctionalCast = IgnoreBaseAccess;
2883 if (Diagnose && !IsCStyleOrFunctionalCast && !FromType->
isAnyPointerType() &&
2887 DiagRuntimeBehavior(From->
getExprLoc(), From,
2888 PDiag(diag::warn_impcast_bool_to_null_pointer)
2890 else if (!isUnevaluatedContext())
2899 if (FromPointeeType->
isRecordType() && ToPointeeType->isRecordType() &&
2903 unsigned InaccessibleID = 0;
2904 unsigned AmbigiousID = 0;
2906 InaccessibleID = diag::err_upcast_to_inaccessible_base;
2907 AmbigiousID = diag::err_ambiguous_derived_to_base_conv;
2909 if (CheckDerivedToBaseConversion(
2910 FromPointeeType, ToPointeeType, InaccessibleID, AmbigiousID,
2912 &BasePath, IgnoreBaseAccess))
2916 Kind = CK_DerivedToBase;
2919 if (Diagnose && !IsCStyleOrFunctionalCast &&
2920 FromPointeeType->
isFunctionType() && ToPointeeType->isVoidType()) {
2921 assert(getLangOpts().MSVCCompat &&
2922 "this should only be possible with MSVCCompat!");
2934 if (FromPtrType->isObjCBuiltinType() || ToPtrType->isObjCBuiltinType())
2937 Kind = CK_BlockPointerToObjCPointerCast;
2939 Kind = CK_CPointerToObjCPointerCast;
2943 Kind = CK_AnyPointerToBlockPointerCast;
2949 Kind = CK_NullToPointer;
2961 bool InOverloadResolution,
2971 ConvertedType = ToType;
2986 IsDerivedFrom(From->
getLocStart(), ToClass, FromClass)) {
3004 bool IgnoreBaseAccess) {
3011 "Expr must be null pointer constant!");
3012 Kind = CK_NullToMemberPointer;
3017 assert(ToPtrType &&
"No member pointer cast has a target type " 3018 "that is not a member pointer.");
3024 assert(FromClass->
isRecordType() &&
"Pointer into non-class.");
3025 assert(ToClass->isRecordType() &&
"Pointer into non-class.");
3029 bool DerivationOkay =
3030 IsDerivedFrom(From->
getLocStart(), ToClass, FromClass, Paths);
3031 assert(DerivationOkay &&
3032 "Should not have been called if derivation isn't OK.");
3033 (void)DerivationOkay;
3036 getUnqualifiedType())) {
3037 std::string PathDisplayStr = getAmbiguousPathsDisplayString(Paths);
3039 << 0 << FromClass << ToClass << PathDisplayStr << From->
getSourceRange();
3043 if (
const RecordType *VBase = Paths.getDetectedVirtual()) {
3045 << FromClass << ToClass <<
QualType(VBase, 0)
3050 if (!IgnoreBaseAccess)
3051 CheckBaseClassAccess(From->
getExprLoc(), FromClass, ToClass,
3053 diag::err_downcast_from_inaccessible_base);
3057 Kind = CK_BaseToDerivedMemberPointer;
3082 bool CStyle,
bool &ObjCLifetimeConversion) {
3085 ObjCLifetimeConversion =
false;
3095 bool PreviousToQualsIncludeConst =
true;
3096 bool UnwrappedAnyPointer =
false;
3104 UnwrappedAnyPointer =
true;
3116 UnwrappedAnyPointer) {
3119 ObjCLifetimeConversion =
true;
3144 && !PreviousToQualsIncludeConst)
3149 PreviousToQualsIncludeConst
3150 = PreviousToQualsIncludeConst && ToQuals.
hasConst();
3176 bool InOverloadResolution,
3185 InOverloadResolution, InnerSCS,
3189 SCS.
Second = InnerSCS.Second;
3190 SCS.
setToType(1, InnerSCS.getToType(1));
3191 SCS.
Third = InnerSCS.Third;
3193 = InnerSCS.QualificationIncludesObjCLifetime;
3194 SCS.
setToType(2, InnerSCS.getToType(2));
3216 bool AllowExplicit) {
3223 bool Usable = !Info.Constructor->isInvalidDecl() &&
3225 (AllowExplicit || !Info.Constructor->isExplicit());
3230 S.
Context, Info.Constructor, ToType);
3231 if (Info.ConstructorTmpl)
3234 CandidateSet, SuppressUserConversions);
3237 CandidateSet, SuppressUserConversions);
3241 bool HadMultipleCandidates = (CandidateSet.
size() > 1);
3244 switch (
auto Result =
3269 llvm_unreachable(
"Invalid OverloadResult!");
3291 bool AllowObjCConversionOnExplicit) {
3292 assert(AllowExplicit || !AllowObjCConversionOnExplicit);
3296 bool ConstructorsOnly =
false;
3312 ConstructorsOnly =
true;
3317 = dyn_cast<CXXRecordDecl>(ToRecordType->getDecl())) {
3319 Expr **Args = &From;
3320 unsigned NumArgs = 1;
3321 bool ListInitializing =
false;
3322 if (
InitListExpr *InitList = dyn_cast<InitListExpr>(From)) {
3325 S, From, ToType, ToRecordDecl, User, CandidateSet, AllowExplicit);
3334 Args = InitList->getInits();
3335 NumArgs = InitList->getNumInits();
3336 ListInitializing =
true;
3344 bool Usable = !Info.Constructor->isInvalidDecl();
3345 if (ListInitializing)
3346 Usable = Usable && (AllowExplicit || !Info.Constructor->isExplicit());
3349 Info.Constructor->isConvertingConstructor(AllowExplicit);
3351 bool SuppressUserConversions = !ConstructorsOnly;
3352 if (SuppressUserConversions && ListInitializing) {
3353 SuppressUserConversions =
false;
3358 S.
Context, Info.Constructor, ToType);
3361 if (Info.ConstructorTmpl)
3363 Info.ConstructorTmpl, Info.FoundDecl,
3364 nullptr, llvm::makeArrayRef(Args, NumArgs),
3365 CandidateSet, SuppressUserConversions);
3370 llvm::makeArrayRef(Args, NumArgs),
3371 CandidateSet, SuppressUserConversions);
3378 if (ConstructorsOnly || isa<InitListExpr>(From)) {
3384 = dyn_cast<CXXRecordDecl>(FromRecordType->getDecl())) {
3386 const auto &Conversions = FromRecordDecl->getVisibleConversionFunctions();
3387 for (
auto I = Conversions.
begin(), E = Conversions.
end(); I != E; ++I) {
3391 if (isa<UsingShadowDecl>(D))
3392 D = cast<UsingShadowDecl>(D)->getTargetDecl();
3396 if ((ConvTemplate = dyn_cast<FunctionTemplateDecl>(D)))
3399 Conv = cast<CXXConversionDecl>(D);
3401 if (AllowExplicit || !Conv->isExplicit()) {
3404 ActingContext, From, ToType,
3406 AllowObjCConversionOnExplicit);
3409 From, ToType, CandidateSet,
3410 AllowObjCConversionOnExplicit);
3416 bool HadMultipleCandidates = (CandidateSet.
size() > 1);
3425 = dyn_cast<CXXConstructorDecl>(Best->Function)) {
3433 if (isa<InitListExpr>(From)) {
3437 if (Best->Conversions[0].isEllipsis())
3440 User.
Before = Best->Conversions[0].Standard;
3453 = dyn_cast<CXXConversionDecl>(Best->Function)) {
3460 User.
Before = Best->Conversions[0].Standard;
3475 User.
After = Best->FinalConversion;
3478 llvm_unreachable(
"Not a constructor or conversion function?");
3487 llvm_unreachable(
"Invalid OverloadResult!");
3497 CandidateSet,
false,
false);
3502 if (!RequireCompleteType(From->
getLocStart(), ToType,
3503 diag::err_typecheck_nonviable_condition_incomplete,
3539 if (Block1 != Block2)
3626 if (!ICS1.
isBad()) {
3759 else if (Rank2 < Rank1)
3780 bool SCS1ConvertsToVoid
3782 bool SCS2ConvertsToVoid
3784 if (SCS1ConvertsToVoid != SCS2ConvertsToVoid) {
3789 }
else if (!SCS1ConvertsToVoid && !SCS2ConvertsToVoid) {
3795 }
else if (SCS1ConvertsToVoid && SCS2ConvertsToVoid &&
3824 if (FromObjCPtr1 && FromObjCPtr2) {
3829 if (AssignLeft != AssignRight) {
3862 if (UnqualT1 == UnqualT2) {
3874 if (isa<ArrayType>(T1) && T1Quals)
3876 if (isa<ArrayType>(T2) && T2Quals)
3935 if (UnqualT1 == UnqualT2)
3940 if (isa<ArrayType>(T1) && T1Quals)
3942 if (isa<ArrayType>(T2) && T2Quals)
4065 if (FromPointee1 == FromPointee2 && ToPointee1 != ToPointee2) {
4073 if (FromPointee1 != FromPointee2 && ToPointee1 == ToPointee2) {
4090 if (FromPtr1 && FromPtr2 && ToPtr1 && ToPtr2) {
4097 bool FromAssignRight
4106 if (ToPtr1->isObjCIdType() &&
4107 (ToPtr2->isObjCQualifiedIdType() || ToPtr2->getInterfaceDecl()))
4109 if (ToPtr2->isObjCIdType() &&
4110 (ToPtr1->isObjCQualifiedIdType() || ToPtr1->getInterfaceDecl()))
4115 if (ToPtr1->isObjCQualifiedIdType() && ToPtr2->getInterfaceDecl())
4117 if (ToPtr2->isObjCQualifiedIdType() && ToPtr1->getInterfaceDecl())
4122 if (ToPtr1->isObjCClassType() &&
4123 (ToPtr2->isObjCQualifiedClassType() || ToPtr2->getInterfaceDecl()))
4125 if (ToPtr2->isObjCClassType() &&
4126 (ToPtr1->isObjCQualifiedClassType() || ToPtr1->getInterfaceDecl()))
4131 if (ToPtr1->isObjCQualifiedClassType() && ToPtr2->getInterfaceDecl())
4133 if (ToPtr2->isObjCQualifiedClassType() && ToPtr1->getInterfaceDecl())
4139 (ToAssignLeft != ToAssignRight)) {
4150 }
else if (IsSecondSame)
4159 (FromAssignLeft != FromAssignRight))
4177 const Type *FromPointeeType1 = FromMemPointer1->
getClass();
4178 const Type *ToPointeeType1 = ToMemPointer1->getClass();
4179 const Type *FromPointeeType2 = FromMemPointer2->getClass();
4180 const Type *ToPointeeType2 = ToMemPointer2->getClass();
4186 if (FromPointee1 == FromPointee2 && ToPointee1 != ToPointee2) {
4193 if (ToPointee1 == ToPointee2 && FromPointee1 != FromPointee2) {
4234 return !Record->isInvalidDecl();
4249 bool &DerivedToBase,
4250 bool &ObjCConversion,
4251 bool &ObjCLifetimeConversion) {
4253 "T1 must be the pointee type of the reference type");
4254 assert(!OrigT2->
isReferenceType() &&
"T2 cannot be a reference type");
4266 DerivedToBase =
false;
4267 ObjCConversion =
false;
4268 ObjCLifetimeConversion =
false;
4270 if (UnqualT1 == UnqualT2) {
4272 }
else if (isCompleteType(Loc, OrigT2) &&
4274 IsDerivedFrom(Loc, UnqualT2, UnqualT1))
4275 DerivedToBase =
true;
4279 ObjCConversion =
true;
4281 IsFunctionConversion(UnqualT2, UnqualT1, ConvertedT2))
4288 return Ref_Compatible;
4290 return Ref_Incompatible;
4297 if (isa<ArrayType>(T1) && T1Quals)
4299 if (isa<ArrayType>(T2) && T2Quals)
4317 ObjCLifetimeConversion =
true;
4328 return Ref_Compatible;
4339 bool AllowExplicit) {
4340 assert(T2->
isRecordType() &&
"Can only find conversions of record types.");
4346 const auto &Conversions = T2RecordDecl->getVisibleConversionFunctions();
4347 for (
auto I = Conversions.begin(), E = Conversions.end(); I != E; ++I) {
4350 if (isa<UsingShadowDecl>(D))
4351 D = cast<UsingShadowDecl>(D)->getTargetDecl();
4359 Conv = cast<CXXConversionDecl>(D);
4363 if (!AllowExplicit && Conv->isExplicit())
4367 bool DerivedToBase =
false;
4368 bool ObjCConversion =
false;
4369 bool ObjCLifetimeConversion =
false;
4380 if (!ConvTemplate &&
4383 Conv->getConversionType().getNonReferenceType()
4384 .getUnqualifiedType(),
4386 DerivedToBase, ObjCConversion, ObjCLifetimeConversion) ==
4404 Init, DeclType, CandidateSet,
4408 DeclType, CandidateSet,
4412 bool HadMultipleCandidates = (CandidateSet.size() > 1);
4415 switch (CandidateSet.BestViableFunction(S, DeclLoc, Best)) {
4427 if (!Best->FinalConversion.DirectBinding)
4439 "Expected a direct reference binding!");
4445 Cand != CandidateSet.end(); ++Cand)
4457 llvm_unreachable(
"Invalid OverloadResult!");
4465 bool SuppressUserConversions,
4466 bool AllowExplicit) {
4467 assert(DeclType->
isReferenceType() &&
"Reference init needs a reference");
4488 bool DerivedToBase =
false;
4489 bool ObjCConversion =
false;
4490 bool ObjCLifetimeConversion =
false;
4494 ObjCConversion, ObjCLifetimeConversion);
4522 ICS.Standard.setToType(0, T2);
4523 ICS.Standard.setToType(1, T1);
4524 ICS.Standard.setToType(2, T1);
4525 ICS.Standard.ReferenceBinding =
true;
4526 ICS.Standard.DirectBinding =
true;
4527 ICS.Standard.IsLvalueReference = !isRValRef;
4529 ICS.Standard.BindsToRvalue =
false;
4530 ICS.Standard.BindsImplicitObjectArgumentWithoutRefQualifier =
false;
4531 ICS.Standard.ObjCLifetimeConversionBinding = ObjCLifetimeConversion;
4532 ICS.Standard.CopyConstructor =
nullptr;
4533 ICS.Standard.DeprecatedStringLiteralToCharPtr =
false;
4580 ICS.Standard.setToType(0, T2);
4581 ICS.Standard.setToType(1, T1);
4582 ICS.Standard.setToType(2, T1);
4583 ICS.Standard.ReferenceBinding =
true;
4589 ICS.Standard.DirectBinding =
4592 ICS.Standard.IsLvalueReference = !isRValRef;
4594 ICS.Standard.BindsToRvalue = InitCategory.
isRValue();
4595 ICS.Standard.BindsImplicitObjectArgumentWithoutRefQualifier =
false;
4596 ICS.Standard.ObjCLifetimeConversionBinding = ObjCLifetimeConversion;
4597 ICS.Standard.CopyConstructor =
nullptr;
4598 ICS.Standard.DeprecatedStringLiteralToCharPtr =
false;
4621 if (ICS.isUserDefined() && isRValRef &&
4693 if (ICS.isStandard()) {
4694 ICS.Standard.ReferenceBinding =
true;
4695 ICS.Standard.IsLvalueReference = !isRValRef;
4696 ICS.Standard.BindsToFunctionLvalue =
false;
4697 ICS.Standard.BindsToRvalue =
true;
4698 ICS.Standard.BindsImplicitObjectArgumentWithoutRefQualifier =
false;
4699 ICS.Standard.ObjCLifetimeConversionBinding =
false;
4700 }
else if (ICS.isUserDefined()) {
4702 ICS.UserDefined.ConversionFunction->getReturnType()
4719 ICS.UserDefined.After.ReferenceBinding =
true;
4720 ICS.UserDefined.After.IsLvalueReference = !isRValRef;
4721 ICS.UserDefined.After.BindsToFunctionLvalue =
false;
4722 ICS.UserDefined.After.BindsToRvalue = !LValRefType;
4723 ICS.UserDefined.After.BindsImplicitObjectArgumentWithoutRefQualifier =
false;
4724 ICS.UserDefined.After.ObjCLifetimeConversionBinding =
false;
4732 bool SuppressUserConversions,
4733 bool InOverloadResolution,
4734 bool AllowObjCWritebackConversion,
4735 bool AllowExplicit =
false);
4741 bool SuppressUserConversions,
4742 bool InOverloadResolution,
4743 bool AllowObjCWritebackConversion) {
4772 SuppressUserConversions,
4773 InOverloadResolution,
4774 AllowObjCWritebackConversion);
4807 bool toStdInitializerList =
false;
4814 for (
unsigned i = 0, e = From->
getNumInits(); i < e; ++i) {
4818 InOverloadResolution,
4819 AllowObjCWritebackConversion);
4826 if (Result.
isBad() ||
4857 InOverloadResolution,
false,
4858 AllowObjCWritebackConversion,
4915 Init, ToType,
false, Found))
4920 bool dummy1 =
false;
4921 bool dummy2 =
false;
4922 bool dummy3 =
false;
4929 SuppressUserConversions,
4937 InOverloadResolution,
4938 AllowObjCWritebackConversion);
4939 if (Result.isFailure())
4941 assert(!Result.isEllipsis() &&
4942 "Sub-initialization cannot result in ellipsis conversion.");
4948 Result.UserDefined.After;
4969 if (NumInits == 1 && !isa<InitListExpr>(From->
getInit(0)))
4971 SuppressUserConversions,
4972 InOverloadResolution,
4973 AllowObjCWritebackConversion);
4976 else if (NumInits == 0) {
4999 bool SuppressUserConversions,
5000 bool InOverloadResolution,
5001 bool AllowObjCWritebackConversion,
5002 bool AllowExplicit) {
5003 if (
InitListExpr *FromInitList = dyn_cast<InitListExpr>(From))
5005 InOverloadResolution,AllowObjCWritebackConversion);
5010 SuppressUserConversions,
5014 SuppressUserConversions,
5016 InOverloadResolution,
5018 AllowObjCWritebackConversion,
5031 return !ICS.
isBad();
5045 unsigned Quals = isa<CXXDestructorDecl>(Method) ?
5059 assert(FromClassification.
isLValue());
5085 != FromTypeCanon.getLocalCVRQualifiers() &&
5088 FromType, ImplicitParamType);
5102 FromType, ImplicitParamType);
5122 if (!FromClassification.
isRValue()) {
5165 FromRecordType = From->
getType();
5166 DestType = ImplicitParamRecordType;
5167 FromClassification = From->
Classify(Context);
5171 From = CreateMaterializeTemporaryExpr(FromRecordType, From,
5183 switch (ICS.Bad.Kind) {
5190 diag::err_member_function_call_bad_cvr)
5191 << Method->getDeclName() << FromRecordType << (CVR - 1)
5193 Diag(Method->getLocation(), diag::note_previous_decl)
5194 << Method->getDeclName();
5202 bool IsRValueQualified =
5205 << Method->getDeclName() << FromClassification.
isRValue()
5206 << IsRValueQualified;
5207 Diag(Method->getLocation(), diag::note_previous_decl)
5208 << Method->getDeclName();
5218 diag::err_member_function_call_bad_type)
5219 << ImplicitParamRecordType << FromRecordType << From->
getSourceRange();
5224 PerformObjectMemberConversion(From, Qualifier, FoundDecl, Method);
5227 From = FromRes.
get();
5231 From = ImpCastExprToType(From, DestType, CK_NoOp,
5257 return PerformImplicitConversion(From, Context.
BoolTy, ICS, AA_Converting);
5259 if (!DiagnoseMultipleUserDefinedConversion(From, Context.
BoolTy))
5261 diag::err_typecheck_bool_condition)
5320 llvm_unreachable(
"found a first conversion kind in Second");
5323 llvm_unreachable(
"found a third conversion kind in Second");
5329 llvm_unreachable(
"unknown conversion kind");
5340 "converted constant expression outside C++11");
5376 diag::err_typecheck_converted_constant_expression)
5381 llvm_unreachable(
"ellipsis conversion in converted constant expression");
5387 diag::err_typecheck_converted_constant_expression_disallowed)
5393 diag::err_typecheck_converted_constant_expression_indirect)
5406 PreNarrowingType)) {
5424 << CCE << 0 << From->
getType() << T;
5428 if (Result.
get()->isValueDependent()) {
5441 if (!Result.
get()->EvaluateAsConstantExpr(Eval, Usage, S.
Context) ||
5442 (RequireInt && !Eval.
Val.
isInt())) {
5449 if (Notes.empty()) {
5456 if (Notes.size() == 1 &&
5457 Notes[0].second.getDiagID() == diag::note_invalid_subexpr_in_const_expr)
5458 S.
Diag(Notes[0].first, diag::err_expr_not_cce) << CCE;
5462 for (
unsigned I = 0; I < Notes.size(); ++I)
5463 S.
Diag(Notes[I].first, Notes[I].second);
5474 llvm::APSInt &
Value,
5480 if (!R.isInvalid() && !R.get()->isValueDependent())
5543 return PerformImplicitConversion(From, Ty, ICS, AA_Converting);
5563 for (
unsigned I = 0, N = ViableConversions.
size(); I != N; ++I) {
5565 cast<CXXConversionDecl>(ViableConversions[I]->getUnderlyingDecl());
5575 QualType T,
bool HadMultipleCandidates,
5577 if (ExplicitConversions.
size() == 1 && !Converter.
Suppress) {
5585 std::string TypeStr;
5590 "static_cast<" + TypeStr +
">(")
5602 HadMultipleCandidates);
5607 CK_UserDefinedConversion, Result.
get(),
5608 nullptr, Result.
get()->getValueKind());
5615 QualType T,
bool HadMultipleCandidates,
5631 HadMultipleCandidates);
5636 CK_UserDefinedConversion, Result.
get(),
5637 nullptr, Result.
get()->getValueKind());
5655 for (
unsigned I = 0, N = ViableConversions.
size(); I != N; ++I) {
5659 if (isa<UsingShadowDecl>(D))
5660 D = cast<UsingShadowDecl>(D)->getTargetDecl();
5664 if ((ConvTemplate = dyn_cast<FunctionTemplateDecl>(D)))
5667 Conv = cast<CXXConversionDecl>(D);
5671 ConvTemplate, FoundDecl, ActingContext, From, ToType, CandidateSet,
5675 ToType, CandidateSet,
5706 ExprResult result = CheckPlaceholderExpr(From);
5709 From = result.
get();
5714 if (Converter.
match(T))
5715 return DefaultLvalueConversion(From);
5722 if (!RecordTy || !getLangOpts().CPlusPlus) {
5734 : Converter(Converter), From(From) {}
5739 } IncompleteDiagnoser(Converter, From);
5741 if (Converter.
Suppress ? !isCompleteType(Loc, T)
5742 : RequireCompleteType(Loc, T, IncompleteDiagnoser))
5749 const auto &Conversions =
5750 cast<CXXRecordDecl>(RecordTy->
getDecl())->getVisibleConversionFunctions();
5752 bool HadMultipleCandidates =
5753 (
std::distance(Conversions.begin(), Conversions.end()) > 1);
5757 bool HasUniqueTargetType =
true;
5760 for (
auto I = Conversions.begin(), E = Conversions.end(); I != E; ++I) {
5765 if (getLangOpts().CPlusPlus14)
5770 Conversion = cast<CXXConversionDecl>(D);
5772 assert((!ConvTemplate || getLangOpts().
CPlusPlus14) &&
5773 "Conversion operator templates are considered potentially " 5777 if (Converter.
match(CurToType) || ConvTemplate) {
5783 ExplicitConversions.
addDecl(I.getDecl(), I.getAccess());
5785 if (!ConvTemplate && getLangOpts().CPlusPlus14) {
5788 else if (HasUniqueTargetType &&
5790 HasUniqueTargetType =
false;
5792 ViableConversions.
addDecl(I.getDecl(), I.getAccess());
5797 if (getLangOpts().CPlusPlus14) {
5810 HadMultipleCandidates,
5811 ExplicitConversions))
5817 if (!HasUniqueTargetType)
5836 HadMultipleCandidates, Found))
5845 HadMultipleCandidates,
5846 ExplicitConversions))
5854 switch (ViableConversions.
size()) {
5857 HadMultipleCandidates,
5858 ExplicitConversions))
5868 HadMultipleCandidates, Found))
5933 bool SuppressUserConversions,
5934 bool PartialOverloading,
5939 assert(Proto &&
"Functions without a prototype cannot be overloaded");
5941 "Use AddTemplateOverloadCandidate for function templates");
5943 if (
CXXMethodDecl *Method = dyn_cast<CXXMethodDecl>(Function)) {
5944 if (!isa<CXXConstructorDecl>(Method)) {
5952 AddMethodCandidate(Method, FoundDecl, Method->getParent(),
QualType(),
5954 CandidateSet, SuppressUserConversions,
5955 PartialOverloading, EarlyConversions);
5990 CandidateSet.
addCandidate(Args.size(), EarlyConversions);
5999 !Function->
getAttr<TargetAttr>()->isDefaultVersion()) {
6000 Candidate.
Viable =
false;
6012 IsDerivedFrom(Args[0]->getLocStart(), Args[0]->getType(),
6014 Candidate.
Viable =
false;
6027 if (Shadow && Args.size() == 1 && Constructor->
getNumParams() >= 1 &&
6035 Candidate.
Viable =
false;
6047 if (TooManyArguments(NumParams, Args.size(), PartialOverloading) &&
6049 Candidate.
Viable =
false;
6060 if (Args.size() < MinRequiredArgs && !PartialOverloading) {
6062 Candidate.
Viable =
false;
6068 if (getLangOpts().CUDA)
6069 if (
const FunctionDecl *Caller = dyn_cast<FunctionDecl>(CurContext))
6074 if (!Caller->isImplicit() && !IsAllowedCUDACall(Caller, Function)) {
6075 Candidate.
Viable =
false;
6082 for (
unsigned ArgIdx = 0; ArgIdx < Args.size(); ++ArgIdx) {
6083 if (Candidate.
Conversions[ArgIdx].isInitialized()) {
6086 }
else if (ArgIdx < NumParams) {
6094 SuppressUserConversions,
6097 getLangOpts().ObjCAutoRefCount,
6100 Candidate.
Viable =
false;
6112 if (EnableIfAttr *FailedAttr = CheckEnableIf(Function, Args)) {
6113 Candidate.
Viable =
false;
6119 if (LangOpts.OpenCL && isOpenCLDisabledDecl(Function)) {
6120 Candidate.
Viable =
false;
6129 if (Methods.size() <= 1)
6132 for (
unsigned b = 0, e = Methods.size(); b < e; b++) {
6140 if (Args.size() < NumNamedArgs)
6143 for (
unsigned i = 0; i < NumNamedArgs; i++) {
6145 if (Args[i]->isTypeDependent()) {
6151 Expr *argExpr = Args[i];
6152 assert(argExpr &&
"SelectBestMethod(): missing expression");
6157 !param->
hasAttr<CFConsumedAttr>())
6158 argExpr = stripARCUnbridgedCast(argExpr);
6171 getLangOpts().ObjCAutoRefCount,
6175 if (ConversionState.
isBad() ||
6185 for (
unsigned i = NumNamedArgs, e = Args.size(); i < e; ++i) {
6186 if (Args[i]->isTypeDependent()) {
6190 ExprResult Arg = DefaultVariadicArgumentPromotion(Args[i], VariadicMethod,
6199 if (Args.size() != NumNamedArgs)
6201 else if (Match && NumNamedArgs == 0 && Methods.size() > 1) {
6204 for (
unsigned b = 0, e = Methods.size(); b < e; b++) {
6205 QualType ReturnT = Methods[b]->getReturnType();
6227 const auto &FuncAttrs = Function->
getAttrs();
6229 if (
auto *EnableIf = dyn_cast<EnableIfAttr>(
Attr))
6230 Result.push_back(EnableIf);
6232 std::reverse(Result.begin(), Result.end());
6239 bool MissingImplicitThis,
Expr *&ConvertedThis,
6243 assert(!isa<CXXConstructorDecl>(Method) &&
6244 "Shouldn't have `this` for ctors!");
6245 assert(!Method->
isStatic() &&
"Shouldn't have `this` for static methods!");
6247 ThisArg,
nullptr, Method, Method);
6250 ConvertedThis = R.get();
6252 if (
auto *MD = dyn_cast<CXXMethodDecl>(Function)) {
6254 assert((MissingImplicitThis || MD->isStatic() ||
6255 isa<CXXConstructorDecl>(MD)) &&
6256 "Expected `this` for non-ctor instance methods");
6258 ConvertedThis =
nullptr;
6266 for (
unsigned I = 0; I != ArgSizeNoVarargs; ++I) {
6275 ConvertedArgs.push_back(R.
get());
6283 for (
unsigned i = Args.size(), e = Function->
getNumParams(); i != e; ++i) {
6298 ConvertedArgs.push_back(R.
get());
6308 bool MissingImplicitThis) {
6311 if (EnableIfAttrs.empty())
6317 Expr *DiscardedThis;
6319 *
this, Function,
nullptr, Args, Trap,
6320 true, DiscardedThis, ConvertedArgs))
6321 return EnableIfAttrs[0];
6323 for (
auto *EIA : EnableIfAttrs) {
6327 if (!EIA->getCond()->EvaluateWithSubstitution(
6328 Result, Context, Function, llvm::makeArrayRef(ConvertedArgs)))
6331 if (!Result.
isInt() || !Result.
getInt().getBoolValue())
6337 template <
typename CheckFn>
6340 CheckFn &&IsSuccessful) {
6343 if (ArgDependent == DIA->getArgDependent())
6344 Attrs.push_back(DIA);
6351 auto WarningBegin = std::stable_partition(
6352 Attrs.begin(), Attrs.end(),
6353 [](
const DiagnoseIfAttr *DIA) {
return DIA->isError(); });
6357 auto ErrAttr = llvm::find_if(llvm::make_range(Attrs.begin(), WarningBegin),
6359 if (ErrAttr != WarningBegin) {
6360 const DiagnoseIfAttr *DIA = *ErrAttr;
6361 S.
Diag(Loc, diag::err_diagnose_if_succeeded) << DIA->getMessage();
6362 S.
Diag(DIA->getLocation(), diag::note_from_diagnose_if)
6363 << DIA->getParent() << DIA->getCond()->getSourceRange();
6367 for (
const auto *DIA : llvm::make_range(WarningBegin, Attrs.end()))
6368 if (IsSuccessful(DIA)) {
6369 S.
Diag(Loc, diag::warn_diagnose_if_succeeded) << DIA->getMessage();
6370 S.
Diag(DIA->getLocation(), diag::note_from_diagnose_if)
6371 << DIA->getParent() << DIA->getCond()->getSourceRange();
6378 const Expr *ThisArg,
6382 *
this, Function,
true, Loc,
6383 [&](
const DiagnoseIfAttr *DIA) {
6388 if (!DIA->getCond()->EvaluateWithSubstitution(
6389 Result, Context, cast<FunctionDecl>(DIA->getParent()), Args, ThisArg))
6391 return Result.
isInt() && Result.
getInt().getBoolValue();
6398 *
this, ND,
false, Loc,
6399 [&](
const DiagnoseIfAttr *DIA) {
6401 return DIA->getCond()->EvaluateAsBooleanCondition(Result, Context) &&
6412 bool SuppressUserConversions,
6413 bool PartialOverloading,
6414 bool FirstArgumentIsBase) {
6423 if (isa<CXXMethodDecl>(FD) && !cast<CXXMethodDecl>(FD)->isStatic()) {
6426 if (Args.size() > 0) {
6427 if (
Expr *E = Args[0]) {
6429 ObjectType = E->getType();
6430 ObjectClassification = E->Classify(Context);
6432 FunctionArgs = Args.slice(1);
6435 AddMethodTemplateCandidate(
6436 FunTmpl, F.getPair(),
6438 ExplicitTemplateArgs, ObjectType, ObjectClassification,
6439 FunctionArgs, CandidateSet, SuppressUserConversions,
6440 PartialOverloading);
6442 AddMethodCandidate(cast<CXXMethodDecl>(FD), F.getPair(),
6443 cast<CXXMethodDecl>(FD)->getParent(), ObjectType,
6444 ObjectClassification, FunctionArgs, CandidateSet,
6445 SuppressUserConversions, PartialOverloading);
6452 if (Args.size() > 0 &&
6453 (!Args[0] || (FirstArgumentIsBase && isa<CXXMethodDecl>(FD) &&
6454 !isa<CXXConstructorDecl>(FD)))) {
6455 assert(cast<CXXMethodDecl>(FD)->isStatic());
6456 FunctionArgs = Args.slice(1);
6459 AddTemplateOverloadCandidate(
6460 FunTmpl, F.getPair(), ExplicitTemplateArgs, FunctionArgs,
6461 CandidateSet, SuppressUserConversions, PartialOverloading);
6463 AddOverloadCandidate(FD, F.getPair(), FunctionArgs, CandidateSet,
6464 SuppressUserConversions, PartialOverloading);
6477 bool SuppressUserConversions) {
6481 if (isa<UsingShadowDecl>(Decl))
6482 Decl = cast<UsingShadowDecl>(Decl)->getTargetDecl();
6485 assert(isa<CXXMethodDecl>(TD->getTemplatedDecl()) &&
6486 "Expected a member function template");
6487 AddMethodTemplateCandidate(TD, FoundDecl, ActingContext,
6488 nullptr, ObjectType,
6489 ObjectClassification, Args, CandidateSet,
6490 SuppressUserConversions);
6492 AddMethodCandidate(cast<CXXMethodDecl>(Decl), FoundDecl, ActingContext,
6493 ObjectType, ObjectClassification, Args, CandidateSet,
6494 SuppressUserConversions);
6511 bool SuppressUserConversions,
6512 bool PartialOverloading,
6516 assert(Proto &&
"Methods without a prototype cannot be overloaded");
6517 assert(!isa<CXXConstructorDecl>(Method) &&
6518 "Use AddOverloadCandidate for constructors");
6536 CandidateSet.
addCandidate(Args.size() + 1, EarlyConversions);
6548 if (TooManyArguments(NumParams, Args.size(), PartialOverloading) &&
6550 Candidate.
Viable =
false;
6561 if (Args.size() < MinRequiredArgs && !PartialOverloading) {
6563 Candidate.
Viable =
false;
6577 *
this, CandidateSet.
getLocation(), ObjectType, ObjectClassification,
6578 Method, ActingContext);
6580 Candidate.
Viable =
false;
6587 if (getLangOpts().CUDA)
6588 if (
const FunctionDecl *Caller = dyn_cast<FunctionDecl>(CurContext))
6589 if (!IsAllowedCUDACall(Caller, Method)) {
6590 Candidate.Viable =
false;
6597 for (
unsigned ArgIdx = 0; ArgIdx < Args.size(); ++ArgIdx) {
6598 if (Candidate.Conversions[ArgIdx + 1].isInitialized()) {
6601 }
else if (ArgIdx < NumParams) {
6606 QualType ParamType = Proto->getParamType(ArgIdx);
6607 Candidate.Conversions[ArgIdx + 1]
6609 SuppressUserConversions,
6612 getLangOpts().ObjCAutoRefCount);
6613 if (Candidate.Conversions[ArgIdx + 1].isBad()) {
6614 Candidate.Viable =
false;
6622 Candidate.Conversions[ArgIdx + 1].setEllipsis();
6626 if (EnableIfAttr *FailedAttr = CheckEnableIf(Method, Args,
true)) {
6627 Candidate.Viable =
false;
6629 Candidate.DeductionFailure.Data = FailedAttr;
6633 if (Method->isMultiVersion() && Method->hasAttr<TargetAttr>() &&
6634 !Method->getAttr<TargetAttr>()->isDefaultVersion()) {
6635 Candidate.Viable =
false;
6652 bool SuppressUserConversions,
6653 bool PartialOverloading) {
6670 MethodTmpl, ExplicitTemplateArgs, Args, Specialization, Info,
6672 return CheckNonDependentConversions(
6673 MethodTmpl, ParamTypes, Args, CandidateSet, Conversions,
6674 SuppressUserConversions, ActingContext, ObjectType,
6675 ObjectClassification);
6678 CandidateSet.
addCandidate(Conversions.size(), Conversions);
6681 Candidate.
Viable =
false;
6684 cast<CXXMethodDecl>(Candidate.
Function)->isStatic() ||
6687 if (Result == TDK_NonDependentConversionFailure)
6699 assert(Specialization &&
"Missing member function template specialization?");
6700 assert(isa<CXXMethodDecl>(Specialization) &&
6701 "Specialization is not a member function?");
6702 AddMethodCandidate(cast<CXXMethodDecl>(Specialization), FoundDecl,
6703 ActingContext, ObjectType, ObjectClassification, Args,
6704 CandidateSet, SuppressUserConversions, PartialOverloading,
6717 bool SuppressUserConversions,
6718 bool PartialOverloading) {
6735 FunctionTemplate, ExplicitTemplateArgs, Args, Specialization, Info,
6737 return CheckNonDependentConversions(FunctionTemplate, ParamTypes,
6738 Args, CandidateSet, Conversions,
6739 SuppressUserConversions);
6742 CandidateSet.
addCandidate(Conversions.size(), Conversions);
6745 Candidate.
Viable =
false;
6750 isa<CXXMethodDecl>(Candidate.
Function) &&
6751 !isa<CXXConstructorDecl>(Candidate.
Function);
6753 if (Result == TDK_NonDependentConversionFailure)
6765 assert(Specialization &&
"Missing function template specialization?");
6766 AddOverloadCandidate(Specialization, FoundDecl, Args, CandidateSet,
6767 SuppressUserConversions, PartialOverloading,
6768 false, Conversions);
6783 const bool AllowExplicit =
false;
6787 bool HasThisConversion = Method && !isa<CXXConstructorDecl>(Method);
6788 unsigned ThisConversions = HasThisConversion ? 1 : 0;
6800 if (HasThisConversion && !cast<CXXMethodDecl>(FD)->isStatic() &&
6803 *
this, CandidateSet.
getLocation(), ObjectType, ObjectClassification,
6804 Method, ActingContext);
6805 if (Conversions[0].isBad())
6809 for (
unsigned I = 0, N =
std::min(ParamTypes.size(), Args.size()); I != N;
6811 QualType ParamType = ParamTypes[I];
6813 Conversions[ThisConversions + I]
6815 SuppressUserConversions,
6818 getLangOpts().ObjCAutoRefCount,
6820 if (Conversions[ThisConversions + I].isBad())
6842 bool AllowObjCPointerConversion) {
6850 bool ObjCLifetimeConversion;
6852 ObjCLifetimeConversion))
6857 if (!AllowObjCPointerConversion)
6861 bool IncompatibleObjC =
false;
6879 bool AllowObjCConversionOnExplicit,
6880 bool AllowResultConversion) {
6882 "Conversion function templates use AddTemplateConversionCandidate");
6889 if (getLangOpts().CPlusPlus14 && ConvType->isUndeducedType()) {
6890 if (DeduceReturnType(Conversion, From->
getExprLoc()))
6897 if (!AllowResultConversion &&
6906 AllowObjCConversionOnExplicit))
6936 = cast<CXXRecordDecl>(ImplicitParamType->
getAs<
RecordType>()->getDecl());
6940 From->
Classify(Context), Conversion, ConversionContext);
6943 Candidate.
Viable =
false;
6954 if (FromCanon == ToCanon ||
6955 IsDerivedFrom(CandidateSet.
getLocation(), FromCanon, ToCanon)) {
6956 Candidate.
Viable =
false;
6973 CK_FunctionToPointerDecay,
6977 if (!isCompleteType(From->
getLocStart(), ConversionType)) {
6978 Candidate.
Viable =
false;
6989 CallExpr Call(Context, &ConversionFn, None, CallResultType, VK,
6997 switch (ICS.getKind()) {
7007 Candidate.
Viable =
false;
7019 Candidate.
Viable =
false;
7026 Candidate.
Viable =
false;
7032 "Can only end up with a standard conversion sequence or failure");
7035 if (EnableIfAttr *FailedAttr = CheckEnableIf(Conversion, None)) {
7036 Candidate.
Viable =
false;
7043 !Conversion->
getAttr<TargetAttr>()->isDefaultVersion()) {
7044 Candidate.
Viable =
false;
7060 bool AllowObjCConversionOnExplicit,
7061 bool AllowResultConversion) {
7063 "Only conversion function templates permitted here");
7072 Specialization, Info)) {
7076 Candidate.
Viable =
false;
7088 assert(Specialization &&
"Missing function template specialization?");
7089 AddConversionCandidate(Specialization, FoundDecl, ActingDC, From, ToType,
7090 CandidateSet, AllowObjCConversionOnExplicit,
7091 AllowResultConversion);
7126 Object->
Classify(Context), Conversion, ActingContext);
7127 if (ObjectInit.
isBad()) {
7128 Candidate.
Viable =
false;
7139 Candidate.
Conversions[0].UserDefined.EllipsisConversion =
false;
7140 Candidate.
Conversions[0].UserDefined.HadMultipleCandidates =
false;
7141 Candidate.
Conversions[0].UserDefined.ConversionFunction = Conversion;
7142 Candidate.
Conversions[0].UserDefined.FoundConversionFunction = FoundDecl;
7145 Candidate.
Conversions[0].UserDefined.After.setAsIdentityConversion();
7153 if (Args.size() > NumParams && !Proto->
isVariadic()) {
7154 Candidate.
Viable =
false;
7161 if (Args.size() < NumParams) {
7163 Candidate.
Viable =
false;
7170 for (
unsigned ArgIdx = 0, N = Args.size(); ArgIdx != N; ++ArgIdx) {
7171 if (ArgIdx < NumParams) {
7182 getLangOpts().ObjCAutoRefCount);
7184 Candidate.
Viable =
false;
7196 if (EnableIfAttr *FailedAttr = CheckEnableIf(Conversion, None)) {
7197 Candidate.
Viable =
false;
7235 if (!isCompleteType(OpLoc, T1) && !T1Rec->isBeingDefined())
7238 if (!T1Rec->getDecl()->getDefinition())
7241 LookupResult Operators(*
this, OpName, OpLoc, LookupOrdinaryName);
7242 LookupQualifiedName(Operators, T1Rec->getDecl());
7246 OperEnd = Operators.
end();
7249 AddMethodCandidate(Oper.getPair(), Args[0]->getType(),
7250 Args[0]->Classify(Context), Args.slice(1),
7251 CandidateSet,
false);
7265 bool IsAssignmentOperator,
7266 unsigned NumContextualBoolArguments) {
7283 for (
unsigned ArgIdx = 0, N = Args.size(); ArgIdx != N; ++ArgIdx) {
7296 if (ArgIdx < NumContextualBoolArguments) {
7297 assert(ParamTys[ArgIdx] == Context.
BoolTy &&
7298 "Contextual conversion to bool requires bool type");
7304 ArgIdx == 0 && IsAssignmentOperator,
7307 getLangOpts().ObjCAutoRefCount);
7310 Candidate.
Viable =
false;
7323 class BuiltinCandidateTypeSet {
7325 typedef llvm::SetVector<QualType, SmallVector<QualType, 8>,
7326 llvm::SmallPtrSet<QualType, 8>> TypeSet;
7330 TypeSet PointerTypes;
7334 TypeSet MemberPointerTypes;
7338 TypeSet EnumerationTypes;
7342 TypeSet VectorTypes;
7345 bool HasNonRecordTypes;
7349 bool HasArithmeticOrEnumeralTypes;
7353 bool HasNullPtrType;
7362 bool AddPointerWithMoreQualifiedTypeVariants(
QualType Ty,
7364 bool AddMemberPointerWithMoreQualifiedTypeVariants(
QualType Ty);
7368 typedef TypeSet::iterator iterator;
7370 BuiltinCandidateTypeSet(
Sema &SemaRef)
7371 : HasNonRecordTypes(
false),
7372 HasArithmeticOrEnumeralTypes(
false),
7373 HasNullPtrType(
false),
7377 void AddTypesConvertedFrom(
QualType Ty,
7379 bool AllowUserConversions,
7380 bool AllowExplicitConversions,
7381 const Qualifiers &VisibleTypeConversionsQuals);
7384 iterator pointer_begin() {
return PointerTypes.begin(); }
7387 iterator pointer_end() {
return PointerTypes.end(); }
7390 iterator member_pointer_begin() {
return MemberPointerTypes.begin(); }
7393 iterator member_pointer_end() {
return MemberPointerTypes.end(); }
7396 iterator enumeration_begin() {
return EnumerationTypes.begin(); }
7399 iterator enumeration_end() {
return EnumerationTypes.end(); }
7401 iterator vector_begin() {
return VectorTypes.begin(); }
7402 iterator vector_end() {
return VectorTypes.end(); }
7404 bool hasNonRecordTypes() {
return HasNonRecordTypes; }
7405 bool hasArithmeticOrEnumeralTypes() {
return HasArithmeticOrEnumeralTypes; }
7406 bool hasNullPtrType()
const {
return HasNullPtrType; }
7421 BuiltinCandidateTypeSet::AddPointerWithMoreQualifiedTypeVariants(
QualType Ty,
7425 if (!PointerTypes.insert(Ty))
7430 bool buildObjCPtr =
false;
7434 buildObjCPtr =
true;
7452 if ((CVR | BaseCVR) != CVR)
continue;
7474 PointerTypes.insert(QPointerTy);
7490 BuiltinCandidateTypeSet::AddMemberPointerWithMoreQualifiedTypeVariants(
7493 if (!MemberPointerTypes.insert(Ty))
7497 assert(PointerTy &&
"type was not a member pointer type!");
7512 if ((CVR | BaseCVR) != CVR)
continue;
7515 MemberPointerTypes.insert(
7531 BuiltinCandidateTypeSet::AddTypesConvertedFrom(
QualType Ty,
7533 bool AllowUserConversions,
7534 bool AllowExplicitConversions,
7546 Ty = SemaRef.Context.getArrayDecayedType(Ty);
7553 HasNonRecordTypes = HasNonRecordTypes || !TyRec;
7556 HasArithmeticOrEnumeralTypes =
7560 PointerTypes.insert(Ty);
7564 if (!AddPointerWithMoreQualifiedTypeVariants(Ty, VisibleQuals))
7568 if (!AddMemberPointerWithMoreQualifiedTypeVariants(Ty))
7571 HasArithmeticOrEnumeralTypes =
true;
7572 EnumerationTypes.insert(Ty);
7576 HasArithmeticOrEnumeralTypes =
true;
7577 VectorTypes.insert(Ty);
7579 HasNullPtrType =
true;
7580 }
else if (AllowUserConversions && TyRec) {
7582 if (!SemaRef.isCompleteType(Loc, Ty))
7587 if (isa<UsingShadowDecl>(D))
7588 D = cast<UsingShadowDecl>(D)->getTargetDecl();
7592 if (isa<FunctionTemplateDecl>(D))
7596 if (AllowExplicitConversions || !Conv->
isExplicit()) {
7651 if (isa<UsingShadowDecl>(D))
7652 D = cast<UsingShadowDecl>(D)->getTargetDecl();
7686 class BuiltinOperatorOverloadBuilder {
7691 bool HasArithmeticOrEnumeralCandidateType;
7695 static constexpr
int ArithmeticTypesCap = 24;
7701 unsigned FirstIntegralType,
7703 unsigned FirstPromotedIntegralType,
7704 LastPromotedIntegralType;
7705 unsigned FirstPromotedArithmeticType,
7706 LastPromotedArithmeticType;
7707 unsigned NumArithmeticTypes;
7709 void InitArithmeticTypes() {
7711 FirstPromotedArithmeticType = 0;
7719 FirstIntegralType = ArithmeticTypes.size();
7720 FirstPromotedIntegralType = ArithmeticTypes.size();
7731 LastPromotedIntegralType = ArithmeticTypes.size();
7732 LastPromotedArithmeticType = ArithmeticTypes.size();
7746 LastIntegralType = ArithmeticTypes.size();
7747 NumArithmeticTypes = ArithmeticTypes.size();
7751 assert(ArithmeticTypes.size() <= ArithmeticTypesCap &&
7752 "Enough inline storage for all arithmetic types.");
7757 void addPlusPlusMinusMinusStyleOverloads(
QualType CandidateTy,
7799 BuiltinOperatorOverloadBuilder(
7802 bool HasArithmeticOrEnumeralCandidateType,
7806 VisibleTypeConversionsQuals(VisibleTypeConversionsQuals),
7807 HasArithmeticOrEnumeralCandidateType(
7808 HasArithmeticOrEnumeralCandidateType),
7809 CandidateTypes(CandidateTypes),
7810 CandidateSet(CandidateSet) {
7812 InitArithmeticTypes();
7835 if (!HasArithmeticOrEnumeralCandidateType)
7838 for (
unsigned Arith = 0; Arith < NumArithmeticTypes; ++Arith) {
7839 const auto TypeOfT = ArithmeticTypes[Arith];
7841 if (Op == OO_MinusMinus)
7843 if (Op == OO_PlusPlus && S.
getLangOpts().CPlusPlus17)
7846 addPlusPlusMinusMinusStyleOverloads(
7863 void addPlusPlusMinusMinusPointerOverloads() {
7864 for (BuiltinCandidateTypeSet::iterator
7865 Ptr = CandidateTypes[0].pointer_begin(),
7866 PtrEnd = CandidateTypes[0].pointer_end();
7867 Ptr != PtrEnd; ++Ptr) {
7869 if (!(*Ptr)->getPointeeType()->isObjectType())
7872 addPlusPlusMinusMinusStyleOverloads(*Ptr,
7873 (!(*Ptr).isVolatileQualified() &&
7875 (!(*Ptr).isRestrictQualified() &&
7890 void addUnaryStarPointerOverloads() {
7891 for (BuiltinCandidateTypeSet::iterator
7892 Ptr = CandidateTypes[0].pointer_begin(),
7893 PtrEnd = CandidateTypes[0].pointer_end();
7894 Ptr != PtrEnd; ++Ptr) {
7901 if (Proto->getTypeQuals() || Proto->getRefQualifier())
7914 void addUnaryPlusOrMinusArithmeticOverloads() {
7915 if (!HasArithmeticOrEnumeralCandidateType)
7918 for (
unsigned Arith = FirstPromotedArithmeticType;
7919 Arith < LastPromotedArithmeticType; ++Arith) {
7920 QualType ArithTy = ArithmeticTypes[Arith];
7925 for (BuiltinCandidateTypeSet::iterator
7926 Vec = CandidateTypes[0].vector_begin(),
7927 VecEnd = CandidateTypes[0].vector_end();
7928 Vec != VecEnd; ++Vec) {
7939 void addUnaryPlusPointerOverloads() {
7940 for (BuiltinCandidateTypeSet::iterator
7941 Ptr = CandidateTypes[0].pointer_begin(),
7942 PtrEnd = CandidateTypes[0].pointer_end();
7943 Ptr != PtrEnd; ++Ptr) {
7954 void addUnaryTildePromotedIntegralOverloads() {
7955 if (!HasArithmeticOrEnumeralCandidateType)
7958 for (
unsigned Int = FirstPromotedIntegralType;
7959 Int < LastPromotedIntegralType; ++Int) {
7960 QualType IntTy = ArithmeticTypes[Int];
7965 for (BuiltinCandidateTypeSet::iterator
7966 Vec = CandidateTypes[0].vector_begin(),
7967 VecEnd = CandidateTypes[0].vector_end();
7968 Vec != VecEnd; ++Vec) {
7980 void addEqualEqualOrNotEqualMemberPointerOrNullptrOverloads() {
7982 llvm::SmallPtrSet<QualType, 8> AddedTypes;
7984 for (
unsigned ArgIdx = 0, N = Args.size(); ArgIdx != N; ++ArgIdx) {
7985 for (BuiltinCandidateTypeSet::iterator
7986 MemPtr = CandidateTypes[ArgIdx].member_pointer_begin(),
7987 MemPtrEnd = CandidateTypes[ArgIdx].member_pointer_end();
7988 MemPtr != MemPtrEnd;
7994 QualType ParamTypes[2] = { *MemPtr, *MemPtr };
7998 if (CandidateTypes[ArgIdx].hasNullPtrType()) {
8000 if (AddedTypes.insert(NullPtrTy).second) {
8001 QualType ParamTypes[2] = { NullPtrTy, NullPtrTy };
8020 void addGenericBinaryPointerOrEnumeralOverloads() {
8034 UserDefinedBinaryOperators;
8036 for (
unsigned ArgIdx = 0, N = Args.size(); ArgIdx != N; ++ArgIdx) {
8037 if (CandidateTypes[ArgIdx].enumeration_begin() !=
8038 CandidateTypes[ArgIdx].enumeration_end()) {
8040 CEnd = CandidateSet.
end();
8042 if (!C->Viable || !C->Function || C->Function->getNumParams() != 2)
8045 if (C->Function->isFunctionTemplateSpecialization())
8049 C->Function->getParamDecl(0)->getType().getUnqualifiedType();
8051 C->Function->getParamDecl(1)->getType().getUnqualifiedType();
8059 UserDefinedBinaryOperators.insert(
8067 llvm::SmallPtrSet<QualType, 8> AddedTypes;
8069 for (
unsigned ArgIdx = 0, N = Args.size(); ArgIdx != N; ++ArgIdx) {
8070 for (BuiltinCandidateTypeSet::iterator
8071 Ptr = CandidateTypes[ArgIdx].pointer_begin(),
8072 PtrEnd = CandidateTypes[ArgIdx].pointer_end();
8073 Ptr != PtrEnd; ++Ptr) {
8078 QualType ParamTypes[2] = { *Ptr, *Ptr };
8081 for (BuiltinCandidateTypeSet::iterator
8082 Enum = CandidateTypes[ArgIdx].enumeration_begin(),
8083 EnumEnd = CandidateTypes[ArgIdx].enumeration_end();
8084 Enum != EnumEnd; ++Enum) {
8089 if (!AddedTypes.insert(CanonType).second ||
8090 UserDefinedBinaryOperators.count(std::make_pair(CanonType,
8093 QualType ParamTypes[2] = { *Enum, *Enum };
8118 llvm::SmallPtrSet<QualType, 8> AddedTypes;
8120 for (
int Arg = 0; Arg < 2; ++Arg) {
8121 QualType AsymmetricParamTypes[2] = {
8125 for (BuiltinCandidateTypeSet::iterator
8126 Ptr = CandidateTypes[Arg].pointer_begin(),
8127 PtrEnd = CandidateTypes[Arg].pointer_end();
8128 Ptr != PtrEnd; ++Ptr) {
8133 AsymmetricParamTypes[Arg] = *Ptr;
8134 if (Arg == 0 || Op == OO_Plus) {
8139 if (Op == OO_Minus) {
8144 QualType ParamTypes[2] = { *Ptr, *Ptr };
8180 void addGenericBinaryArithmeticOverloads() {
8181 if (!HasArithmeticOrEnumeralCandidateType)
8184 for (
unsigned Left = FirstPromotedArithmeticType;
8185 Left < LastPromotedArithmeticType; ++Left) {
8186 for (
unsigned Right = FirstPromotedArithmeticType;
8187 Right < LastPromotedArithmeticType; ++Right) {
8188 QualType LandR[2] = { ArithmeticTypes[Left],
8189 ArithmeticTypes[Right] };
8196 for (BuiltinCandidateTypeSet::iterator
8197 Vec1 = CandidateTypes[0].vector_begin(),
8198 Vec1End = CandidateTypes[0].vector_end();
8199 Vec1 != Vec1End; ++Vec1) {
8200 for (BuiltinCandidateTypeSet::iterator
8201 Vec2 = CandidateTypes[1].vector_begin(),
8202 Vec2End = CandidateTypes[1].vector_end();
8203 Vec2 != Vec2End; ++Vec2) {
8204 QualType LandR[2] = { *Vec1, *Vec2 };
8241 void addThreeWayArithmeticOverloads() {
8242 addGenericBinaryArithmeticOverloads();
8260 if (!HasArithmeticOrEnumeralCandidateType)
8263 for (
unsigned Left = FirstPromotedIntegralType;
8264 Left < LastPromotedIntegralType; ++Left) {
8265 for (
unsigned Right = FirstPromotedIntegralType;
8266 Right < LastPromotedIntegralType; ++Right) {
8267 QualType LandR[2] = { ArithmeticTypes[Left],
8268 ArithmeticTypes[Right] };
8281 void addAssignmentMemberPointerOrEnumeralOverloads() {
8283 llvm::SmallPtrSet<QualType, 8> AddedTypes;
8285 for (
unsigned ArgIdx = 0; ArgIdx < 2; ++ArgIdx) {
8286 for (BuiltinCandidateTypeSet::iterator
8287 Enum = CandidateTypes[ArgIdx].enumeration_begin(),
8288 EnumEnd = CandidateTypes[ArgIdx].enumeration_end();
8289 Enum != EnumEnd; ++Enum) {
8296 for (BuiltinCandidateTypeSet::iterator
8297 MemPtr = CandidateTypes[ArgIdx].member_pointer_begin(),
8298 MemPtrEnd = CandidateTypes[ArgIdx].member_pointer_end();
8299 MemPtr != MemPtrEnd; ++MemPtr) {
8324 void addAssignmentPointerOverloads(
bool isEqualOp) {
8326 llvm::SmallPtrSet<QualType, 8> AddedTypes;
8328 for (BuiltinCandidateTypeSet::iterator
8329 Ptr = CandidateTypes[0].pointer_begin(),
8330 PtrEnd = CandidateTypes[0].pointer_end();
8331 Ptr != PtrEnd; ++Ptr) {
8335 else if (!(*Ptr)->getPointeeType()->isObjectType())
8346 bool NeedVolatile = !(*Ptr).isVolatileQualified() &&
8356 if (!(*Ptr).isRestrictQualified() &&
8378 for (BuiltinCandidateTypeSet::iterator
8379 Ptr = CandidateTypes[1].pointer_begin(),
8380 PtrEnd = CandidateTypes[1].pointer_end();
8381 Ptr != PtrEnd; ++Ptr) {
8395 bool NeedVolatile = !(*Ptr).isVolatileQualified() &&
8405 if (!(*Ptr).isRestrictQualified() &&
8440 void addAssignmentArithmeticOverloads(
bool isEqualOp) {
8441 if (!HasArithmeticOrEnumeralCandidateType)
8444 for (
unsigned Left = 0; Left < NumArithmeticTypes; ++Left) {
8445 for (
unsigned Right = FirstPromotedArithmeticType;
8446 Right < LastPromotedArithmeticType; ++Right) {
8448 ParamTypes[1] = ArithmeticTypes[Right];
8468 for (BuiltinCandidateTypeSet::iterator
8469 Vec1 = CandidateTypes[0].vector_begin(),
8470 Vec1End = CandidateTypes[0].vector_end();
8471 Vec1 != Vec1End; ++Vec1) {
8472 for (BuiltinCandidateTypeSet::iterator
8473 Vec2 = CandidateTypes[1].vector_begin(),
8474 Vec2End = CandidateTypes[1].vector_end();
8475 Vec2 != Vec2End; ++Vec2) {
8477 ParamTypes[1] = *Vec2;
8506 void addAssignmentIntegralOverloads() {
8507 if (!HasArithmeticOrEnumeralCandidateType)
8510 for (
unsigned Left = FirstIntegralType; Left < LastIntegralType; ++Left) {
8511 for (
unsigned Right = FirstPromotedIntegralType;
8512 Right < LastPromotedIntegralType; ++Right) {
8514 ParamTypes[1] = ArithmeticTypes[Right];
8522 ParamTypes[0] = ArithmeticTypes[Left];
8538 void addExclaimOverload() {
8544 void addAmpAmpOrPipePipeOverload() {
8561 void addSubscriptOverloads() {
8562 for (BuiltinCandidateTypeSet::iterator
8563 Ptr = CandidateTypes[0].pointer_begin(),
8564 PtrEnd = CandidateTypes[0].pointer_end();
8565 Ptr != PtrEnd; ++Ptr) {
8575 for (BuiltinCandidateTypeSet::iterator
8576 Ptr = CandidateTypes[1].pointer_begin(),
8577 PtrEnd = CandidateTypes[1].pointer_end();
8578 Ptr != PtrEnd; ++Ptr) {
8598 void addArrowStarOverloads() {
8599 for (BuiltinCandidateTypeSet::iterator
8600 Ptr = CandidateTypes[0].pointer_begin(),
8601 PtrEnd = CandidateTypes[0].pointer_end();
8602 Ptr != PtrEnd; ++Ptr) {
8607 if (!isa<RecordType>(C1))
8616 for (BuiltinCandidateTypeSet::iterator
8617 MemPtr = CandidateTypes[1].member_pointer_begin(),
8618 MemPtrEnd = CandidateTypes[1].member_pointer_end();
8619 MemPtr != MemPtrEnd; ++MemPtr) {
8625 QualType ParamTypes[2] = { *Ptr, *MemPtr };
8650 void addConditionalOperatorOverloads() {
8652 llvm::SmallPtrSet<QualType, 8> AddedTypes;
8654 for (
unsigned ArgIdx = 0; ArgIdx < 2; ++ArgIdx) {
8655 for (BuiltinCandidateTypeSet::iterator
8656 Ptr = CandidateTypes[ArgIdx].pointer_begin(),
8657 PtrEnd = CandidateTypes[ArgIdx].pointer_end();
8658 Ptr != PtrEnd; ++Ptr) {
8662 QualType ParamTypes[2] = { *Ptr, *Ptr };
8666 for (BuiltinCandidateTypeSet::iterator
8667 MemPtr = CandidateTypes[ArgIdx].member_pointer_begin(),
8668 MemPtrEnd = CandidateTypes[ArgIdx].member_pointer_end();
8669 MemPtr != MemPtrEnd; ++MemPtr) {
8673 QualType ParamTypes[2] = { *MemPtr, *MemPtr };
8678 for (BuiltinCandidateTypeSet::iterator
8679 Enum = CandidateTypes[ArgIdx].enumeration_begin(),
8680 EnumEnd = CandidateTypes[ArgIdx].enumeration_end();
8681 Enum != EnumEnd; ++Enum) {
8688 QualType ParamTypes[2] = { *Enum, *Enum };
8712 VisibleTypeConversionsQuals.
addConst();
8713 for (
unsigned ArgIdx = 0, N = Args.size(); ArgIdx != N; ++ArgIdx)
8716 bool HasNonRecordCandidateType =
false;
8717 bool HasArithmeticOrEnumeralCandidateType =
false;
8719 for (
unsigned ArgIdx = 0, N = Args.size(); ArgIdx != N; ++ArgIdx) {
8720 CandidateTypes.emplace_back(*
this);
8721 CandidateTypes[ArgIdx].AddTypesConvertedFrom(Args[ArgIdx]->getType(),
8724 (Op == OO_Exclaim ||
8727 VisibleTypeConversionsQuals);
8728 HasNonRecordCandidateType = HasNonRecordCandidateType ||
8729 CandidateTypes[ArgIdx].hasNonRecordTypes();
8730 HasArithmeticOrEnumeralCandidateType =
8731 HasArithmeticOrEnumeralCandidateType ||
8732 CandidateTypes[ArgIdx].hasArithmeticOrEnumeralTypes();
8740 if (!HasNonRecordCandidateType &&
8741 !(Op == OO_Exclaim || Op == OO_AmpAmp || Op == OO_PipePipe))
8745 BuiltinOperatorOverloadBuilder OpBuilder(*
this, Args,
8746 VisibleTypeConversionsQuals,
8747 HasArithmeticOrEnumeralCandidateType,
8748 CandidateTypes, CandidateSet);
8754 llvm_unreachable(
"Expected an overloaded operator");
8759 case OO_Array_Delete:
8762 "Special operators don't use AddBuiltinOperatorCandidates");
8774 if (Args.size() == 1)
8775 OpBuilder.addUnaryPlusPointerOverloads();
8779 if (Args.size() == 1) {
8780 OpBuilder.addUnaryPlusOrMinusArithmeticOverloads();
8782 OpBuilder.addBinaryPlusOrMinusPointerOverloads(Op);
8783 OpBuilder.addGenericBinaryArithmeticOverloads();
8788 if (Args.size() == 1)
8789 OpBuilder.addUnaryStarPointerOverloads();
8791 OpBuilder.addGenericBinaryArithmeticOverloads();
8795 OpBuilder.addGenericBinaryArithmeticOverloads();
8800 OpBuilder.addPlusPlusMinusMinusArithmeticOverloads(Op);
8801 OpBuilder.addPlusPlusMinusMinusPointerOverloads();
8805 case OO_ExclaimEqual:
8806 OpBuilder.addEqualEqualOrNotEqualMemberPointerOrNullptrOverloads();
8812 case OO_GreaterEqual:
8813 OpBuilder.addGenericBinaryPointerOrEnumeralOverloads();
8814 OpBuilder.addGenericBinaryArithmeticOverloads();
8818 OpBuilder.addGenericBinaryPointerOrEnumeralOverloads();
8819 OpBuilder.addThreeWayArithmeticOverloads();
8826 case OO_GreaterGreater:
8827 OpBuilder.addBinaryBitwiseArithmeticOverloads(Op);
8831 if (Args.size() == 1)
8837 OpBuilder.addBinaryBitwiseArithmeticOverloads(Op);
8841 OpBuilder.addUnaryTildePromotedIntegralOverloads();
8845 OpBuilder.addAssignmentMemberPointerOrEnumeralOverloads();
8850 OpBuilder.addAssignmentPointerOverloads(Op == OO_Equal);
8855 OpBuilder.addAssignmentArithmeticOverloads(Op == OO_Equal);
8858 case OO_PercentEqual:
8859 case OO_LessLessEqual:
8860 case OO_GreaterGreaterEqual:
8864 OpBuilder.addAssignmentIntegralOverloads();
8868 OpBuilder.addExclaimOverload();
8873 OpBuilder.addAmpAmpOrPipePipeOverload();
8877 OpBuilder.addSubscriptOverloads();
8881 OpBuilder.addArrowStarOverloads();
8884 case OO_Conditional:
8885 OpBuilder.addConditionalOperatorOverloads();
8886 OpBuilder.addGenericBinaryArithmeticOverloads();
8904 bool PartialOverloading) {
8915 ArgumentDependentLookup(Name, Loc, Args, Fns);
8919 CandEnd = CandidateSet.
end();
8920 Cand != CandEnd; ++Cand)
8921 if (Cand->Function) {
8922 Fns.
erase(Cand->Function);
8932 if (ExplicitTemplateArgs)
8935 AddOverloadCandidate(FD, FoundDecl, Args, CandidateSet,
false,
8936 PartialOverloading);
8938 AddTemplateOverloadCandidate(cast<FunctionTemplateDecl>(*I),
8939 FoundDecl, ExplicitTemplateArgs,
8940 Args, CandidateSet, PartialOverloading);
8962 bool Cand1Attr = Cand1->
hasAttr<EnableIfAttr>();
8963 bool Cand2Attr = Cand2->
hasAttr<EnableIfAttr>();
8964 if (!Cand1Attr || !Cand2Attr) {
8965 if (Cand1Attr == Cand2Attr)
8967 return Cand1Attr ? Comparison::Better : Comparison::Worse;
8978 if (Cand1Attrs.size() < Cand2Attrs.size())
8979 return Comparison::Worse;
8981 auto Cand1I = Cand1Attrs.begin();
8982 llvm::FoldingSetNodeID Cand1ID, Cand2ID;
8983 for (
auto &Cand2A : Cand2Attrs) {
8987 auto &Cand1A = *Cand1I++;
8988 Cand1A->getCond()->Profile(Cand1ID, S.
getASTContext(),
true);
8989 Cand2A->getCond()->Profile(Cand2ID, S.
getASTContext(),
true);
8990 if (Cand1ID != Cand2ID)
8991 return Comparison::Worse;
9007 const auto *Cand1CPUSpec = Cand1.
Function->
getAttr<CPUSpecificAttr>();
9008 const auto *Cand2CPUSpec = Cand2.
Function->
getAttr<CPUSpecificAttr>();
9010 if (!Cand1CPUDisp && !Cand2CPUDisp && !Cand1CPUSpec && !Cand2CPUSpec)
9013 if (Cand1CPUDisp && !Cand2CPUDisp)
9015 if (Cand2CPUDisp && !Cand1CPUDisp)
9018 if (Cand1CPUSpec && Cand2CPUSpec) {
9019 if (Cand1CPUSpec->cpus_size() != Cand2CPUSpec->cpus_size())
9020 return Cand1CPUSpec->cpus_size() < Cand2CPUSpec->cpus_size();
9022 std::pair<CPUSpecificAttr::cpus_iterator, CPUSpecificAttr::cpus_iterator>
9023 FirstDiff = std::mismatch(
9024 Cand1CPUSpec->cpus_begin(), Cand1CPUSpec->cpus_end(),
9025 Cand2CPUSpec->cpus_begin(),
9027 return LHS->
getName() == RHS->getName();
9030 assert(FirstDiff.first != Cand1CPUSpec->cpus_end() &&
9031 "Two different cpu-specific versions should not have the same " 9032 "identifier list, otherwise they'd be the same decl!");
9033 return (*FirstDiff.first)->getName() < (*FirstDiff.second)->
getName();
9035 llvm_unreachable(
"No way to get here unless both had cpu_dispatch");
9056 unsigned StartArg = 0;
9063 return ICS.isStandard() &&
9075 assert(Cand2.
Conversions.size() == NumArgs &&
"Overload candidate mismatch");
9076 bool HasBetterConversion =
false;
9077 for (
unsigned ArgIdx = StartArg; ArgIdx < NumArgs; ++ArgIdx) {
9078 bool Cand1Bad = IsIllFormedConversion(Cand1.
Conversions[ArgIdx]);
9079 bool Cand2Bad = IsIllFormedConversion(Cand2.
Conversions[ArgIdx]);
9080 if (Cand1Bad != Cand2Bad) {
9083 HasBetterConversion =
true;
9087 if (HasBetterConversion)
9094 for (
unsigned ArgIdx = StartArg; ArgIdx < NumArgs; ++ArgIdx) {
9100 HasBetterConversion =
true;
9115 if (HasBetterConversion)
9126 isa<CXXConversionDecl>(Cand1.
Function) &&
9127 isa<CXXConversionDecl>(Cand2.
Function)) {
9155 isa<CXXConstructorDecl>(Cand1.
Function) !=
9156 isa<CXXConstructorDecl>(Cand2.
Function))
9157 return isa<CXXConstructorDecl>(Cand1.
Function);
9161 bool Cand1IsSpecialization = Cand1.
Function &&
9163 bool Cand2IsSpecialization = Cand2.
Function &&
9165 if (Cand1IsSpecialization != Cand2IsSpecialization)
9166 return Cand2IsSpecialization;
9172 if (Cand1IsSpecialization && Cand2IsSpecialization) {
9186 bool Cand1IsInherited =
9188 bool Cand2IsInherited =
9190 if (Cand1IsInherited != Cand2IsInherited)
9191 return Cand2IsInherited;
9192 else if (Cand1IsInherited) {
9193 assert(Cand2IsInherited);
9196 if (Cand1Class->isDerivedFrom(Cand2Class))
9198 if (Cand2Class->isDerivedFrom(Cand1Class))
9205 auto *Guide1 = dyn_cast_or_null<CXXDeductionGuideDecl>(Cand1.
Function);
9206 auto *Guide2 = dyn_cast_or_null<CXXDeductionGuideDecl>(Cand2.
Function);
9207 if (Guide1 && Guide2) {
9209 if (Guide1->isImplicit() != Guide2->isImplicit())
9210 return Guide2->isImplicit();
9213 if (Guide1->isCopyDeductionCandidate())
9222 return Cmp == Comparison::Better;
9231 bool HasPS1 = Cand1.
Function !=
nullptr &&
9233 bool HasPS2 = Cand2.
Function !=
nullptr &&
9235 if (HasPS1 != HasPS2 && HasPS1)
9250 auto *VA = dyn_cast_or_null<ValueDecl>(A);
9251 auto *VB = dyn_cast_or_null<ValueDecl>(B);
9257 if (!VA->getDeclContext()->getRedeclContext()->Equals(
9258 VB->getDeclContext()->getRedeclContext()) ||
9259 getOwningModule(const_cast<ValueDecl *>(VA)) ==
9260 getOwningModule(const_cast<ValueDecl *>(VB)) ||
9261 VA->isExternallyVisible() || VB->isExternallyVisible())
9269 if (Context.
hasSameType(VA->getType(), VB->getType()))
9274 if (
auto *EA = dyn_cast<EnumConstantDecl>(VA)) {
9275 if (
auto *EB = dyn_cast<EnumConstantDecl>(VB)) {
9278 auto *EnumA = cast<EnumDecl>(EA->getDeclContext());
9279 auto *EnumB = cast<EnumDecl>(EB->getDeclContext());
9280 if (EnumA->hasNameForLinkage() || EnumB->hasNameForLinkage() ||
9282 EnumB->getIntegerType()))
9285 return llvm::APSInt::isSameValue(EA->getInitVal(), EB->getInitVal());
9295 Diag(Loc, diag::ext_equivalent_internal_linkage_decl_in_modules) << D;
9297 Module *M = getOwningModule(const_cast<NamedDecl*>(D));
9301 for (
auto *E : Equiv) {
9302 Module *M = getOwningModule(const_cast<NamedDecl*>(E));
9303 Diag(E->getLocation(), diag::note_equivalent_internal_linkage_decl)
9322 std::transform(begin(), end(), std::back_inserter(Candidates),
9334 bool ContainsSameSideCandidate =
9340 if (ContainsSameSideCandidate) {
9346 llvm::erase_if(Candidates, IsWrongSideCandidate);
9352 for (
auto *Cand : Candidates)
9354 if (Best == end() ||
9366 for (
auto *Cand : Candidates) {
9367 if (Cand->
Viable && Cand != Best &&
9371 EquivalentCands.push_back(Cand->
Function);
9381 if (Best->Function &&
9382 (Best->Function->isDeleted() ||
9386 if (!EquivalentCands.empty())
9399 oc_implicit_default_constructor,
9400 oc_implicit_copy_constructor,
9401 oc_implicit_move_constructor,
9402 oc_implicit_copy_assignment,
9403 oc_implicit_move_assignment,
9404 oc_inherited_constructor
9410 ocs_described_template,
9413 static std::pair<OverloadCandidateKind, OverloadCandidateSelect>
9415 std::string &Description) {
9425 if (!Description.empty())
9426 return ocs_described_template;
9427 return isTemplate ? ocs_template : ocs_non_template;
9432 if (!Ctor->isImplicit()) {
9433 if (isa<ConstructorUsingShadowDecl>(Found))
9434 return oc_inherited_constructor;
9436 return oc_constructor;
9439 if (Ctor->isDefaultConstructor())
9440 return oc_implicit_default_constructor;
9442 if (Ctor->isMoveConstructor())
9443 return oc_implicit_move_constructor;
9445 assert(Ctor->isCopyConstructor() &&
9446 "unexpected sort of implicit constructor");
9447 return oc_implicit_copy_constructor;
9453 if (!Meth->isImplicit())
9456 if (Meth->isMoveAssignmentOperator())
9457 return oc_implicit_move_assignment;
9459 if (Meth->isCopyAssignmentOperator())
9460 return oc_implicit_copy_assignment;
9462 assert(isa<CXXConversionDecl>(Meth) &&
"expected conversion");
9469 return std::make_pair(Kind, Select);
9472 void MaybeEmitInheritedConstructorNote(
Sema &S,
Decl *FoundDecl) {
9475 if (
auto *Shadow = dyn_cast<ConstructorUsingShadowDecl>(FoundDecl))
9477 diag::note_ovl_candidate_inherited_constructor)
9478 << Shadow->getNominatedBaseClass();
9487 if (!EnableIf->getCond()->EvaluateAsBooleanCondition(AlwaysTrue, Ctx))
9504 bool InOverloadResolution,
9508 if (InOverloadResolution)
9510 diag::note_addrof_ovl_candidate_disabled_by_enable_if_attr);
9512 S.
Diag(Loc, diag::err_addrof_function_disabled_by_enable_if_attr) << FD;
9518 return P->hasAttr<PassObjectSizeAttr>();
9526 if (InOverloadResolution)
9528 diag::note_ovl_candidate_has_pass_object_size_params)
9531 S.
Diag(Loc, diag::err_address_of_function_with_pass_object_size_params)
9554 QualType DestType,
bool TakingAddress) {
9558 !Fn->
getAttr<TargetAttr>()->isDefaultVersion())
9562 std::pair<OverloadCandidateKind, OverloadCandidateSelect> KSPair =
9563 ClassifyOverloadCandidate(*
this, Found, Fn, FnDesc);
9565 << (unsigned)KSPair.first << (
unsigned)KSPair.second
9568 HandleFunctionTypeMismatch(PD, Fn->
getType(), DestType);
9570 MaybeEmitInheritedConstructorNote(*
this, Found);
9576 bool TakingAddress) {
9586 dyn_cast<FunctionTemplateDecl>((*I)->getUnderlyingDecl()) ) {
9587 NoteOverloadCandidate(*I, FunTmpl->getTemplatedDecl(), DestType,
9590 = dyn_cast<FunctionDecl>((*I)->getUnderlyingDecl()) ) {
9591 NoteOverloadCandidate(*I, Fun, DestType, TakingAddress);
9603 S.
Diag(CaretLoc, PDiag)
9604 << Ambiguous.getFromType() << Ambiguous.getToType();
9609 unsigned CandsShown = 0;
9611 for (I = Ambiguous.begin(), E = Ambiguous.end(); I != E; ++I) {
9612 if (CandsShown >= 4 && ShowOverloads ==
Ovl_Best)
9622 unsigned I,
bool TakingCandidateAddress) {
9624 assert(Conv.
isBad());
9625 assert(Cand->
Function &&
"for now, candidate must be a function");
9631 bool isObjectArgument =
false;
9632 if (isa<CXXMethodDecl>(Fn) && !isa<CXXConstructorDecl>(Fn)) {
9634 isObjectArgument =
true;
9640 std::pair<OverloadCandidateKind, OverloadCandidateSelect> FnKindPair =
9641 ClassifyOverloadCandidate(S, Cand->
FoundDecl, Fn, FnDesc);
9648 assert(FromExpr &&
"overload set argument came from implicit argument?");
9650 if (isa<UnaryOperator>(E))
9651 E = cast<UnaryOperator>(E)->getSubExpr()->
IgnoreParens();
9655 << (
unsigned)FnKindPair.first << (unsigned)FnKindPair.second << FnDesc
9658 MaybeEmitInheritedConstructorNote(S, Cand->
FoundDecl);
9667 CToTy = RT->getPointeeType();
9672 CFromTy = FromPT->getPointeeType();
9673 CToTy = ToPT->getPointeeType();
9684 << (
unsigned)FnKindPair.first << (unsigned)FnKindPair.second << FnDesc
9686 << ToTy << (
unsigned)isObjectArgument << I + 1;
9687 MaybeEmitInheritedConstructorNote(S, Cand->
FoundDecl);
9693 << (
unsigned)FnKindPair.first << (unsigned)FnKindPair.second << FnDesc
9696 << (unsigned)isObjectArgument << I + 1;
9697 MaybeEmitInheritedConstructorNote(S, Cand->
FoundDecl);
9703 << (
unsigned)FnKindPair.first << (unsigned)FnKindPair.second << FnDesc
9706 << (unsigned)isObjectArgument << I + 1;
9707 MaybeEmitInheritedConstructorNote(S, Cand->
FoundDecl);
9713 << (
unsigned)FnKindPair.first << (unsigned)FnKindPair.second << FnDesc
9716 MaybeEmitInheritedConstructorNote(S, Cand->
FoundDecl);
9721 assert(CVR &&
"unexpected qualifiers mismatch");
9723 if (isObjectArgument) {
9725 << (
unsigned)FnKindPair.first << (unsigned)FnKindPair.second << FnDesc
9730 << (
unsigned)FnKindPair.first << (unsigned)FnKindPair.second << FnDesc
9732 << (CVR - 1) << I + 1;
9734 MaybeEmitInheritedConstructorNote(S, Cand->
FoundDecl);
9740 if (FromExpr && isa<InitListExpr>(FromExpr)) {
9742 << (
unsigned)FnKindPair.first << (unsigned)FnKindPair.second << FnDesc
9744 << ToTy << (
unsigned)isObjectArgument << I + 1;
9745 MaybeEmitInheritedConstructorNote(S, Cand->
FoundDecl);
9757 S.
Diag(Fn->
getLocation(), diag::note_ovl_candidate_bad_conv_incomplete)
9758 << (
unsigned)FnKindPair.first << (unsigned)FnKindPair.second << FnDesc
9760 << ToTy << (
unsigned)isObjectArgument << I + 1
9761 << (unsigned)(Cand->
Fix.
Kind);
9763 MaybeEmitInheritedConstructorNote(S, Cand->
FoundDecl);
9768 unsigned BaseToDerivedConversion = 0;
9771 if (ToPtrTy->getPointeeType().isAtLeastAsQualifiedAs(
9772 FromPtrTy->getPointeeType()) &&
9773 !FromPtrTy->getPointeeType()->isIncompleteType() &&
9774 !ToPtrTy->getPointeeType()->isIncompleteType() &&
9776 FromPtrTy->getPointeeType()))
9777 BaseToDerivedConversion = 1;
9785 if (ToPtrTy->getPointeeType().isAtLeastAsQualifiedAs(
9786 FromPtrTy->getPointeeType()) &&
9787 FromIface->isSuperClassOf(ToIface))
9788 BaseToDerivedConversion = 2;
9790 if (ToRefTy->getPointeeType().isAtLeastAsQualifiedAs(FromTy) &&
9792 !ToRefTy->getPointeeType()->isIncompleteType() &&
9794 BaseToDerivedConversion = 3;
9799 << (
unsigned)FnKindPair.first << (unsigned)FnKindPair.second << FnDesc
9800 << (
unsigned)isObjectArgument << I + 1
9802 MaybeEmitInheritedConstructorNote(S, Cand->
FoundDecl);
9807 if (BaseToDerivedConversion) {
9808 S.
Diag(Fn->
getLocation(), diag::note_ovl_candidate_bad_base_to_derived_conv)
9809 << (
unsigned)FnKindPair.first << (unsigned)FnKindPair.second << FnDesc
9811 << (BaseToDerivedConversion - 1) << FromTy << ToTy << I + 1;
9812 MaybeEmitInheritedConstructorNote(S, Cand->
FoundDecl);
9816 if (isa<ObjCObjectPointerType>(CFromTy) &&
9817 isa<PointerType>(CToTy)) {
9822 << (
unsigned)FnKindPair.first << (unsigned)FnKindPair.second
9824 << FromTy << ToTy << (
unsigned)isObjectArgument << I + 1;
9825 MaybeEmitInheritedConstructorNote(S, Cand->
FoundDecl);
9830 if (TakingCandidateAddress &&
9836 FDiag << (unsigned)FnKindPair.first << (
unsigned)FnKindPair.second << FnDesc
9838 << ToTy << (
unsigned)isObjectArgument << I + 1
9839 << (unsigned)(Cand->
Fix.
Kind);
9842 for (std::vector<FixItHint>::iterator HI = Cand->
Fix.
Hints.begin(),
9843 HE = Cand->
Fix.
Hints.end(); HI != HE; ++HI)
9847 MaybeEmitInheritedConstructorNote(S, Cand->
FoundDecl);
9867 if (NumArgs < MinParams) {
9882 unsigned NumFormalArgs) {
9883 assert(isa<FunctionDecl>(D) &&
9884 "The templated declaration should at least be a function" 9885 " when diagnosing bad template argument deduction due to too many" 9886 " or too few arguments");
9895 unsigned mode, modeCount;
9896 if (NumFormalArgs < MinParams) {
9897 if (MinParams != FnTy->getNumParams() || FnTy->isVariadic() ||
9898 FnTy->isTemplateVariadic())
9902 modeCount = MinParams;
9904 if (MinParams != FnTy->getNumParams())
9908 modeCount = FnTy->getNumParams();
9911 std::string Description;
9912 std::pair<OverloadCandidateKind, OverloadCandidateSelect> FnKindPair =
9913 ClassifyOverloadCandidate(S, Found, Fn, Description);
9917 << (
unsigned)FnKindPair.first << (unsigned)FnKindPair.second
9918 << Description << mode << Fn->
getParamDecl(0) << NumFormalArgs;
9921 << (
unsigned)FnKindPair.first << (unsigned)FnKindPair.second
9922 << Description << mode << modeCount << NumFormalArgs;
9924 MaybeEmitInheritedConstructorNote(S, Found);
9929 unsigned NumFormalArgs) {
9937 llvm_unreachable(
"Unsupported: Getting the described template declaration" 9938 " for bad deduction diagnosis");
9945 bool TakingCandidateAddress) {
9951 switch (DeductionFailure.
Result) {
9953 llvm_unreachable(
"TDK_success while diagnosing bad deduction");
9956 assert(ParamD &&
"no parameter found for incomplete deduction result");
9958 diag::note_ovl_candidate_incomplete_deduction)
9960 MaybeEmitInheritedConstructorNote(S, Found);
9965 assert(ParamD &&
"no parameter found for incomplete deduction result");
9967 diag::note_ovl_candidate_incomplete_deduction_pack)
9971 MaybeEmitInheritedConstructorNote(S, Found);
9976 assert(ParamD &&
"no parameter found for bad qualifiers deduction result");
9994 S.
Diag(Templated->
getLocation(), diag::note_ovl_candidate_underqualified)
9996 MaybeEmitInheritedConstructorNote(S, Found);
10001 assert(ParamD &&
"no parameter found for inconsistent deduction result");
10003 if (isa<TemplateTypeParmDecl>(ParamD))
10005 else if (isa<NonTypeTemplateParmDecl>(ParamD)) {
10015 diag::note_ovl_candidate_inconsistent_deduction_types)
10018 MaybeEmitInheritedConstructorNote(S, Found);
10028 diag::note_ovl_candidate_inconsistent_deduction)
10031 MaybeEmitInheritedConstructorNote(S, Found);
10036 assert(ParamD &&
"no parameter found for invalid explicit arguments");
10039 diag::note_ovl_candidate_explicit_arg_mismatch_named)
10044 index = TTP->getIndex();
10046 = dyn_cast<NonTypeTemplateParmDecl>(ParamD))
10047 index = NTTP->getIndex();
10049 index = cast<TemplateTemplateParmDecl>(ParamD)->getIndex();
10051 diag::note_ovl_candidate_explicit_arg_mismatch_unnamed)
10054 MaybeEmitInheritedConstructorNote(S, Found);
10064 diag::note_ovl_candidate_instantiation_depth);
10065 MaybeEmitInheritedConstructorNote(S, Found);
10073 TemplateArgString =
" ";
10080 if (PDiag && PDiag->second.getDiagID() ==
10081 diag::err_typename_nested_not_found_enable_if) {
10084 S.
Diag(PDiag->first, diag::note_ovl_candidate_disabled_by_enable_if)
10085 <<
"'enable_if'" << TemplateArgString;
10090 if (PDiag && PDiag->second.getDiagID() ==
10091 diag::err_typename_nested_not_found_requirement) {
10093 diag::note_ovl_candidate_disabled_by_requirement)
10094 << PDiag->second.getStringArg(0) << TemplateArgString;
10104 SFINAEArgString =
": ";
10106 PDiag->second.EmitToString(S.
getDiagnostics(), SFINAEArgString);
10110 diag::note_ovl_candidate_substitution_failure)
10111 << TemplateArgString << SFINAEArgString << R;
10112 MaybeEmitInheritedConstructorNote(S, Found);
10122 TemplateArgString =
" ";
10127 S.
Diag(Templated->
getLocation(), diag::note_ovl_candidate_deduced_mismatch)
10130 << TemplateArgString
10154 diag::note_ovl_candidate_non_deduced_mismatch_qualified)
10161 if (TakingCandidateAddress && isa<FunctionDecl>(Templated) &&
10170 diag::note_ovl_candidate_non_deduced_mismatch)
10171 << FirstTA << SecondTA;
10177 S.
Diag(Templated->
getLocation(), diag::note_ovl_candidate_bad_deduction);
10178 MaybeEmitInheritedConstructorNote(S, Found);
10182 diag::note_cuda_ovl_candidate_target_mismatch);
10190 bool TakingCandidateAddress) {
10208 std::string FnDesc;
10209 std::pair<OverloadCandidateKind, OverloadCandidateSelect> FnKindPair =
10210 ClassifyOverloadCandidate(S, Cand->
FoundDecl, Callee, FnDesc);
10212 S.
Diag(Callee->getLocation(), diag::note_ovl_candidate_bad_target)
10213 << (
unsigned)FnKindPair.first << (unsigned)ocs_non_template
10215 << CalleeTarget << CallerTarget;
10220 if (Meth !=
nullptr && Meth->
isImplicit()) {
10224 switch (FnKindPair.first) {
10227 case oc_implicit_default_constructor:
10230 case oc_implicit_copy_constructor:
10233 case oc_implicit_move_constructor:
10236 case oc_implicit_copy_assignment:
10239 case oc_implicit_move_assignment:
10244 bool ConstRHS =
false;
10248 ConstRHS = RT->getPointeeType().isConstQualified();
10263 diag::note_ovl_candidate_disabled_by_function_cond_attr)
10264 << Attr->getCond()->getSourceRange() << Attr->getMessage();
10271 diag::note_ovl_candidate_disabled_by_extension);
10289 bool TakingCandidateAddress) {
10295 std::string FnDesc;
10296 std::pair<OverloadCandidateKind, OverloadCandidateSelect> FnKindPair =
10297 ClassifyOverloadCandidate(S, Cand->
FoundDecl, Fn, FnDesc);
10300 << (
unsigned)FnKindPair.first << (unsigned)FnKindPair.second << FnDesc
10302 MaybeEmitInheritedConstructorNote(S, Cand->
FoundDecl);
10318 TakingCandidateAddress);
10321 S.
Diag(Fn->
getLocation(), diag::note_ovl_candidate_illegal_constructor)
10323 MaybeEmitInheritedConstructorNote(S, Cand->
FoundDecl);
10334 for (
unsigned N = Cand->
Conversions.size(); I != N; ++I)
10355 if (cast<CXXConstructorDecl>(Fn)->isCopyOrMoveConstructor())
10358 diag::note_ovl_candidate_inherited_constructor_slice)
10361 MaybeEmitInheritedConstructorNote(S, Cand->
FoundDecl);
10367 assert(!Available);
10381 bool isLValueReference =
false;
10382 bool isRValueReference =
false;
10383 bool isPointer =
false;
10387 isLValueReference =
true;
10391 isRValueReference =
true;
10411 assert(Cand->
Conversions.size() <= 2 &&
"builtin operator is not binary");
10412 std::string TypeStr(
"operator");
10418 S.
Diag(OpLoc, diag::note_ovl_builtin_unary_candidate) << TypeStr;
10423 S.
Diag(OpLoc, diag::note_ovl_builtin_binary_candidate) << TypeStr;
10430 if (ICS.
isBad())
break;
10434 S, OpLoc, S.
PDiag(diag::note_ambiguous_type_conversion));
10450 llvm_unreachable(
"non-deduction failure while diagnosing bad deduction");
10479 llvm_unreachable(
"Unhandled deduction result");
10483 struct CompareOverloadCandidatesForDisplay {
10489 CompareOverloadCandidatesForDisplay(
10492 : S(S), NumArgs(NArgs), CSK(CSK) {}
10497 if (L == R)
return false;
10501 if (!R->
Viable)
return true;
10524 if (LDist == RDist) {
10533 return LDist < RDist;
10551 numLFixes = (numLFixes == 0) ?
UINT_MAX : numLFixes;
10552 numRFixes = (numRFixes == 0) ?
UINT_MAX : numRFixes;
10553 if (numLFixes != numRFixes) {
10554 return numLFixes < numRFixes;
10561 int leftBetter = 0;
10563 for (
unsigned E = L->
Conversions.size(); I != E; ++I) {
10579 if (leftBetter > 0)
return true;
10580 if (leftBetter < 0)
return false;
10622 bool Unfixable =
false;
10630 assert(ConvIdx != ConvCount &&
"no bad conversion in candidate");
10631 if (Cand->
Conversions[ConvIdx].isInitialized() &&
10640 bool SuppressUserConversions =
false;
10642 unsigned ConvIdx = 0;
10656 if (isa<CXXMethodDecl>(Cand->
Function) &&
10657 !isa<CXXConstructorDecl>(Cand->
Function)) {
10663 assert(ConvCount <= 3);
10668 for (
unsigned ArgIdx = 0; ConvIdx != ConvCount; ++ConvIdx, ++ArgIdx) {
10669 if (Cand->
Conversions[ConvIdx].isInitialized()) {
10671 }
else if (ArgIdx < ParamTypes.size()) {
10672 if (ParamTypes[ArgIdx]->isDependentType())
10673 Cand->
Conversions[ConvIdx].setAsIdentityConversion(
10674 Args[ArgIdx]->getType());
10678 SuppressUserConversions,
10683 if (!Unfixable && Cand->
Conversions[ConvIdx].isBad())
10701 for (
iterator Cand = begin(), LastCand = end(); Cand != LastCand; ++Cand) {
10702 if (!Filter(*Cand))
10705 Cands.push_back(Cand);
10708 if (Cand->Function || Cand->IsSurrogate)
10709 Cands.push_back(Cand);
10715 std::stable_sort(Cands.begin(), Cands.end(),
10716 CompareOverloadCandidatesForDisplay(S, OpLoc, Args.size(),
Kind));
10718 bool ReportedAmbiguousConversions =
false;
10722 unsigned CandsShown = 0;
10723 for (I = Cands.begin(), E = Cands.end(); I != E; ++I) {
10729 if (CandsShown >= 4 && ShowOverloads ==
Ovl_Best) {
10741 "Non-viable built-in candidates are not added to Cands.");
10748 if (!ReportedAmbiguousConversions) {
10750 ReportedAmbiguousConversions =
true;
10759 S.
Diag(OpLoc, diag::note_ovl_too_many_candidates) << int(E - I);
10769 struct CompareTemplateSpecCandidatesForDisplay {
10771 CompareTemplateSpecCandidatesForDisplay(
Sema &S) : S(S) {}
10805 bool ForTakingAddress) {
10807 DeductionFailure, 0, ForTakingAddress);
10810 void TemplateSpecCandidateSet::destroyCandidates() {
10811 for (iterator i = begin(), e = end(); i != e; ++i) {
10812 i->DeductionFailure.Destroy();
10817 destroyCandidates();
10818 Candidates.clear();
10831 Cands.reserve(size());
10832 for (
iterator Cand = begin(), LastCand = end(); Cand != LastCand; ++Cand) {
10833 if (Cand->Specialization)
10834 Cands.push_back(Cand);
10839 llvm::sort(Cands.begin(), Cands.end(),
10840 CompareTemplateSpecCandidatesForDisplay(S));
10847 unsigned CandsShown = 0;
10848 for (I = Cands.begin(), E = Cands.end(); I != E; ++I) {
10854 if (CandsShown >= 4 && ShowOverloads ==
Ovl_Best)
10859 "Non-matching built-in candidates are not added to Cands.");
10864 S.
Diag(Loc, diag::note_ovl_too_many_candidates) << int(E - I);
10874 QualType Ret = PossiblyAFunctionType;
10890 bool Complain =
true) {
10907 class AddressOfFunctionResolver {
10917 bool TargetTypeIsNonStaticMemberFunction;
10918 bool FoundNonTemplateFunction;
10919 bool StaticMemberFunctionFromBoundPointer;
10920 bool HasComplained;
10929 AddressOfFunctionResolver(
Sema &S,
Expr *SourceExpr,
10930 const QualType &TargetType,
bool Complain)
10931 : S(S), SourceExpr(SourceExpr), TargetType(TargetType),
10933 TargetTypeIsNonStaticMemberFunction(
10935 FoundNonTemplateFunction(
false),
10936 StaticMemberFunctionFromBoundPointer(
false),
10937 HasComplained(
false),
10940 FailedCandidates(OvlExpr->
getNameLoc(),
true) {
10941 ExtractUnqualifiedFunctionTypeFromTargetType();
10945 if (!UME->isImplicitAccess() &&
10947 StaticMemberFunctionFromBoundPointer =
true;
10951 OvlExpr,
false, &dap)) {
10953 if (!Method->isStatic()) {
10957 TargetTypeIsNonStaticMemberFunction =
true;
10965 Matches.push_back(std::make_pair(dap, Fn));
10973 if (FindAllFunctionsThatMatchTargetTypeExactly()) {
10976 if (Matches.size() > 1 && !eliminiateSuboptimalOverloadCandidates()) {
10977 if (FoundNonTemplateFunction)
10978 EliminateAllTemplateMatches();
10980 EliminateAllExceptMostSpecializedTemplate();
10985 EliminateSuboptimalCudaMatches();
10988 bool hasComplained()
const {
return HasComplained; }
10991 bool candidateHasExactlyCorrectType(
const FunctionDecl *FD) {
11003 return candidateHasExactlyCorrectType(A) &&
11004 (!candidateHasExactlyCorrectType(B) ||
11010 bool eliminiateSuboptimalOverloadCandidates() {
11013 auto Best = Matches.begin();
11014 for (
auto I = Matches.begin()+1, E = Matches.end(); I != E; ++I)
11015 if (isBetterCandidate(I->second, Best->second))
11019 auto IsBestOrInferiorToBest = [
this, BestFn](
11020 const std::pair<DeclAccessPair, FunctionDecl *> &Pair) {
11021 return BestFn == Pair.second || isBetterCandidate(BestFn, Pair.second);
11026 if (!std::all_of(Matches.begin(), Matches.end(), IsBestOrInferiorToBest))
11028 Matches[0] = *Best;
11033 bool isTargetTypeAFunction()
const {
11042 void inline ExtractUnqualifiedFunctionTypeFromTargetType() {
11053 if (Method->isStatic() == TargetTypeIsNonStaticMemberFunction)
11056 else if (TargetTypeIsNonStaticMemberFunction)
11069 &OvlExplicitTemplateArgs,
11070 TargetFunctionType, Specialization,
11089 Matches.push_back(std::make_pair(CurAccessFunPair, Specialization));
11093 bool AddMatchingNonTemplateFunction(
NamedDecl* Fn,
11098 if (Method->isStatic() == TargetTypeIsNonStaticMemberFunction)
11101 else if (TargetTypeIsNonStaticMemberFunction)
11104 if (
FunctionDecl *FunDecl = dyn_cast<FunctionDecl>(Fn)) {
11109 if (FunDecl->isMultiVersion()) {
11110 const auto *TA = FunDecl->getAttr<TargetAttr>();
11111 if (TA && !TA->isDefaultVersion())
11119 HasComplained |= Complain;
11128 candidateHasExactlyCorrectType(FunDecl)) {
11129 Matches.push_back(std::make_pair(
11130 CurAccessFunPair, cast<FunctionDecl>(FunDecl->getCanonicalDecl())));
11131 FoundNonTemplateFunction =
true;
11139 bool FindAllFunctionsThatMatchTargetTypeExactly() {
11144 if (IsInvalidFormOfPointerToMemberFunction())
11160 = dyn_cast<FunctionTemplateDecl>(Fn)) {
11161 if (AddMatchingTemplateFunction(FunctionTemplate, I.getPair()))
11166 AddMatchingNonTemplateFunction(Fn, I.getPair()))
11169 assert(Ret || Matches.empty());
11173 void EliminateAllExceptMostSpecializedTemplate() {
11186 for (
unsigned I = 0, E = Matches.size(); I != E; ++I)
11187 MatchesCopy.
addDecl(Matches[I].second, Matches[I].first.getAccess());
11192 MatchesCopy.
begin(), MatchesCopy.
end(), FailedCandidates,
11194 S.
PDiag(diag::err_addr_ovl_ambiguous)
11195 << Matches[0].second->getDeclName(),
11196 S.
PDiag(diag::note_ovl_candidate)
11197 << (unsigned)oc_function << (
unsigned)ocs_described_template,
11198 Complain, TargetFunctionType);
11200 if (Result != MatchesCopy.
end()) {
11202 Matches[0].first = Matches[Result - MatchesCopy.
begin()].first;
11203 Matches[0].second = cast<FunctionDecl>(*Result);
11206 HasComplained |= Complain;
11209 void EliminateAllTemplateMatches() {
11212 for (
unsigned I = 0, N = Matches.size(); I != N; ) {
11213 if (Matches[I].second->getPrimaryTemplate() ==
nullptr)
11216 Matches[I] = Matches[--N];
11222 void EliminateSuboptimalCudaMatches() {
11227 void ComplainNoMatchesFound()
const {
11228 assert(Matches.empty());
11230 << OvlExpr->
getName() << TargetFunctionType
11232 if (FailedCandidates.
empty())
11243 dyn_cast<FunctionDecl>((*I)->getUnderlyingDecl()))
11251 bool IsInvalidFormOfPointerToMemberFunction()
const {
11252 return TargetTypeIsNonStaticMemberFunction &&
11256 void ComplainIsInvalidFormOfPointerToMemberFunction()
const {
11264 bool IsStaticMemberFunctionFromBoundPointer()
const {
11265 return StaticMemberFunctionFromBoundPointer;
11268 void ComplainIsStaticMemberFunctionFromBoundPointer()
const {
11270 diag::err_invalid_form_pointer_member_function)
11274 void ComplainOfInvalidConversion()
const {
11276 << OvlExpr->
getName() << TargetType;
11279 void ComplainMultipleMatchesFound()
const {
11280 assert(Matches.size() > 1);
11288 bool hadMultipleCandidates()
const {
return (OvlExpr->
getNumDecls() > 1); }
11290 int getNumMatches()
const {
return Matches.size(); }
11293 if (Matches.size() != 1)
return nullptr;
11294 return Matches[0].second;
11298 if (Matches.size() != 1)
return nullptr;
11299 return &Matches[0].first;
11324 bool *pHadMultipleCandidates) {
11327 AddressOfFunctionResolver Resolver(*
this, AddressOfExpr, TargetType,
11329 int NumMatches = Resolver.getNumMatches();
11331 bool ShouldComplain = Complain && !Resolver.hasComplained();
11332 if (NumMatches == 0 && ShouldComplain) {
11333 if (Resolver.IsInvalidFormOfPointerToMemberFunction())
11334 Resolver.ComplainIsInvalidFormOfPointerToMemberFunction();
11336 Resolver.ComplainNoMatchesFound();
11338 else if (NumMatches > 1 && ShouldComplain)
11339 Resolver.ComplainMultipleMatchesFound();
11340 else if (NumMatches == 1) {
11341 Fn = Resolver.getMatchingFunctionDecl();
11344 ResolveExceptionSpec(AddressOfExpr->
getExprLoc(), FPT);
11345 FoundResult = *Resolver.getMatchingFunctionAccessPair();
11347 if (Resolver.IsStaticMemberFunctionFromBoundPointer())
11348 Resolver.ComplainIsStaticMemberFunctionFromBoundPointer();
11350 CheckAddressOfMemberAccess(AddressOfExpr, FoundResult);
11354 if (pHadMultipleCandidates)
11355 *pHadMultipleCandidates = Resolver.hadMultipleCandidates();
11376 auto *FD = dyn_cast<
FunctionDecl>(I->getUnderlyingDecl());
11403 ExprResult &SrcExpr,
bool DoFunctionPointerConverion) {
11408 FunctionDecl *Found = resolveAddressOfOnlyViableOverloadCandidate(E, DAP);
11417 CheckAddressOfMemberAccess(E, DAP);
11418 Expr *Fixed = FixOverloadedFunctionReference(E, DAP, Found);
11420 SrcExpr = DefaultFunctionArrayConversion(Fixed,
false);
11467 = cast<FunctionTemplateDecl>((*I)->getUnderlyingDecl());
11479 Specialization, Info,
11483 FailedCandidates.addCandidate()
11489 assert(Specialization &&
"no specialization and no error?");
11496 NoteAllOverloadCandidates(ovl);
11501 Matched = Specialization;
11502 if (FoundResult) *FoundResult = I.getPair();
11521 ExprResult &SrcExpr,
bool doFunctionPointerConverion,
11522 bool complain,
SourceRange OpRangeForComplaining,
11524 unsigned DiagIDForComplaining) {
11531 if (
FunctionDecl *fn = ResolveSingleFunctionTemplateSpecialization(
11532 ovl.Expression,
false, &found)) {
11533 if (DiagnoseUseOfDecl(fn, SrcExpr.
get()->getLocStart())) {
11542 if (!ovl.HasFormOfMemberPointer &&
11543 isa<CXXMethodDecl>(fn) &&
11544 cast<CXXMethodDecl>(fn)->isInstance()) {
11545 if (!complain)
return false;
11547 Diag(ovl.Expression->getExprLoc(),
11548 diag::err_bound_member_function)
11549 << 0 << ovl.Expression->getSourceRange();
11561 SingleFunctionExpression =
11562 FixOverloadedFunctionReference(SrcExpr.
get(), found, fn);
11565 if (doFunctionPointerConverion) {
11566 SingleFunctionExpression =
11567 DefaultFunctionArrayLvalueConversion(SingleFunctionExpression.
get());
11568 if (SingleFunctionExpression.
isInvalid()) {
11575 if (!SingleFunctionExpression.
isUsable()) {
11577 Diag(OpRangeForComplaining.
getBegin(), DiagIDForComplaining)
11578 << ovl.Expression->getName()
11579 << DestTypeForComplaining
11580 << OpRangeForComplaining
11581 << ovl.Expression->getQualifierLoc().getSourceRange();
11582 NoteAllOverloadCandidates(SrcExpr.
get());
11591 SrcExpr = SingleFunctionExpression;
11601 bool PartialOverloading,
11604 if (isa<UsingShadowDecl>(Callee))
11605 Callee = cast<UsingShadowDecl>(Callee)->getTargetDecl();
11607 if (
FunctionDecl *Func = dyn_cast<FunctionDecl>(Callee)) {
11608 if (ExplicitTemplateArgs) {
11609 assert(!KnownValid &&
"Explicit template arguments?");
11613 if (!dyn_cast<FunctionProtoType>(Func->getType()->getAs<
FunctionType>()))
11618 PartialOverloading);
11623 = dyn_cast<FunctionTemplateDecl>(Callee)) {
11625 ExplicitTemplateArgs, Args, CandidateSet,
11627 PartialOverloading);
11631 assert(!KnownValid &&
"unhandled case in overloaded call candidate");
11639 bool PartialOverloading) {
11662 assert(!(*I)->getDeclContext()->isRecord());
11663 assert(isa<UsingShadowDecl>(*I) ||
11664 !(*I)->getDeclContext()->isFunctionOrMethod());
11665 assert((*I)->getUnderlyingDecl()->isFunctionOrFunctionTemplate());
11675 ExplicitTemplateArgs = &TABuffer;
11681 CandidateSet, PartialOverloading,
11686 Args, ExplicitTemplateArgs,
11687 CandidateSet, PartialOverloading);
11694 case OO_New:
case OO_Array_New:
11695 case OO_Delete:
case OO_Array_Delete:
11715 bool *DoDiagnoseEmptyLookup =
nullptr) {
11720 if (DC->isTransparentContext())
11728 if (isa<CXXRecordDecl>(DC)) {
11732 if (DoDiagnoseEmptyLookup)
11733 *DoDiagnoseEmptyLookup =
true;
11740 ExplicitTemplateArgs, Args,
11741 Candidates,
false,
false);
11744 if (Candidates.BestViableFunction(SemaRef, FnLoc, Best) !=
OR_Success) {
11756 AssociatedNamespaces,
11757 AssociatedClasses);
11761 for (Sema::AssociatedNamespaceSet::iterator
11762 it = AssociatedNamespaces.begin(),
11763 end = AssociatedNamespaces.end(); it != end; ++it) {
11775 SuggestedNamespaces.insert(*it);
11779 SemaRef.
Diag(R.
getNameLoc(), diag::err_not_found_by_two_phase_lookup)
11781 if (SuggestedNamespaces.empty()) {
11782 SemaRef.
Diag(Best->Function->getLocation(),
11783 diag::note_not_found_by_two_phase_lookup)
11785 }
else if (SuggestedNamespaces.size() == 1) {
11786 SemaRef.
Diag(Best->Function->getLocation(),
11787 diag::note_not_found_by_two_phase_lookup)
11793 SemaRef.
Diag(Best->Function->getLocation(),
11794 diag::note_not_found_by_two_phase_lookup)
11826 class BuildRecoveryCallExprRAII {
11829 BuildRecoveryCallExprRAII(
Sema &S) : SemaRef(S) {
11834 ~BuildRecoveryCallExprRAII() {
11841 static std::unique_ptr<CorrectionCandidateCallback>
11843 bool HasTemplateArgs,
bool AllowTypoCorrection) {
11844 if (!AllowTypoCorrection)
11845 return llvm::make_unique<NoTypoCorrectionCCC>();
11846 return llvm::make_unique<FunctionCallFilterCCC>(SemaRef, NumArgs,
11847 HasTemplateArgs, ME);
11859 bool EmptyLookup,
bool AllowTypoCorrection) {
11868 BuildRecoveryCallExprRAII RCE(SemaRef);
11878 ExplicitTemplateArgs = &TABuffer;
11883 bool DoDiagnoseEmptyLookup = EmptyLookup;
11886 ExplicitTemplateArgs, Args,
11887 &DoDiagnoseEmptyLookup) &&
11890 MakeValidator(SemaRef, dyn_cast<MemberExpr>(Fn), Args.size(),
11891 ExplicitTemplateArgs !=
nullptr, AllowTypoCorrection),
11892 ExplicitTemplateArgs, Args)))
11895 assert(!R.empty() &&
"lookup results empty despite recovery");
11898 if (R.isAmbiguous()) {
11899 R.suppressDiagnostics();
11906 if ((*R.begin())->isCXXClassMember())
11908 ExplicitTemplateArgs, S);
11909 else if (ExplicitTemplateArgs || TemplateKWLoc.
isValid())
11911 ExplicitTemplateArgs);
11938 assert(!ULE->
getQualifier() &&
"qualified name with ADL");
11946 llvm_unreachable(
"performing ADL for builtin");
11949 assert(getLangOpts().
CPlusPlus &&
"ADL enabled in C");
11953 UnbridgedCastsSet UnbridgedCasts;
11961 AddOverloadedCallCandidates(ULE, Args, *CandidateSet);
11963 if (getLangOpts().MSVCCompat &&
11964 CurContext->isDependentContext() && !isSFINAEContext() &&
11965 (isa<FunctionDecl>(CurContext) || isa<CXXRecordDecl>(CurContext))) {
11968 if (CandidateSet->
empty() ||
11985 if (CandidateSet->
empty())
11988 UnbridgedCasts.restore();
12004 bool AllowTypoCorrection) {
12005 if (CandidateSet->
empty())
12008 AllowTypoCorrection);
12010 switch (OverloadResult) {
12027 AllowTypoCorrection);
12034 for (
const Expr *Arg : Args) {
12035 if (!Arg->getType()->isFunctionType())
12037 if (
auto *DRE = dyn_cast<DeclRefExpr>(Arg->IgnoreParenImpCasts())) {
12041 Arg->getExprLoc()))
12046 SemaRef.
Diag(Fn->
getLocStart(), diag::err_ovl_no_viable_function_in_call)
12060 << (*Best)->Function->isDeleted()
12081 for (
auto I = CS.
begin(), E = CS.
end(); I != E; ++I) {
12102 bool AllowTypoCorrection,
12103 bool CalleesAddressIsTaken) {
12108 if (buildOverloadedCallSet(S, Fn, ULE, Args, LParenLoc, &CandidateSet,
12114 if (CalleesAddressIsTaken)
12119 CandidateSet.BestViableFunction(*
this, Fn->
getLocStart(), Best);
12122 RParenLoc, ExecConfig, &CandidateSet,
12123 &Best, OverloadResult,
12124 AllowTypoCorrection);
12128 return Functions.
size() > 1 ||
12129 (Functions.
size() == 1 && isa<FunctionTemplateDecl>(*Functions.
begin()));
12150 Expr *Input,
bool PerformADL) {
12152 assert(Op !=
OO_None &&
"Invalid opcode for overloaded unary operator");
12160 Expr *Args[2] = { Input,
nullptr };
12161 unsigned NumArgs = 1;
12166 if (Opc == UO_PostInc || Opc == UO_PostDec) {
12186 return new (Context)
12195 AddFunctionCandidates(Fns, ArgsArray, CandidateSet);
12198 AddMemberOperatorCandidates(Op, OpLoc, ArgsArray, CandidateSet);
12202 AddArgumentDependentLookupCandidates(OpName, OpLoc, ArgsArray,
12208 AddBuiltinOperatorCandidates(Op, OpLoc, ArgsArray, CandidateSet);
12210 bool HadMultipleCandidates = (CandidateSet.
size() > 1);
12225 if (
CXXMethodDecl *Method = dyn_cast<CXXMethodDecl>(FnDecl)) {
12226 CheckMemberOperatorAccess(OpLoc, Args[0],
nullptr, Best->FoundDecl);
12229 PerformObjectArgumentInitialization(Input,
nullptr,
12230 Best->FoundDecl, Method);
12233 Base = Input = InputRes.
get();
12244 Input = InputInit.
get();
12249 Base, HadMultipleCandidates,
12264 if (CheckCallReturnType(FnDecl->
getReturnType(), OpLoc, TheCall, FnDecl))
12267 if (CheckFunctionCall(FnDecl, TheCall,
12271 return MaybeBindToTemporary(TheCall);
12276 ExprResult InputRes = PerformImplicitConversion(
12277 Input, Best->BuiltinParamTypes[0], Best->Conversions[0], AA_Passing,
12278 CCK_ForBuiltinOverloadedOp);
12281 Input = InputRes.
get();
12299 Diag(OpLoc, diag::err_ovl_ambiguous_oper_unary)
12308 Diag(OpLoc, diag::err_ovl_deleted_oper)
12309 << Best->Function->isDeleted()
12311 << getDeletedOrUnavailableSuffix(Best->Function)
12321 return CreateBuiltinUnaryOp(OpLoc, Opc, Input);
12344 Expr *LHS,
Expr *RHS,
bool PerformADL) {
12345 Expr *Args[2] = { LHS, RHS };
12353 if (Args[0]->isTypeDependent() || Args[1]->isTypeDependent()) {
12357 if (Opc <= BO_Assign || Opc > BO_OrAssign)
12360 OpLoc, FPFeatures);
12377 return new (Context)
12398 if (Opc == BO_Assign && !Args[0]->getType()->isOverloadableType())
12399 return CreateBuiltinBinOp(OpLoc, Opc, Args[0], Args[1]);
12403 if (Opc == BO_PtrMemD)
12404 return CreateBuiltinBinOp(OpLoc, Opc, Args[0], Args[1]);
12410 AddFunctionCandidates(Fns, Args, CandidateSet);
12413 AddMemberOperatorCandidates(Op, OpLoc, Args, CandidateSet);
12418 if (Opc != BO_Assign && PerformADL)
12419 AddArgumentDependentLookupCandidates(OpName, OpLoc, Args,
12424 AddBuiltinOperatorCandidates(Op, OpLoc, Args, CandidateSet);
12426 bool HadMultipleCandidates = (CandidateSet.
size() > 1);
12441 if (
CXXMethodDecl *Method = dyn_cast<CXXMethodDecl>(FnDecl)) {
12443 CheckMemberOperatorAccess(OpLoc, Args[0], Args[1], Best->FoundDecl);
12446 PerformCopyInitialization(
12454 PerformObjectArgumentInitialization(Args[0],
nullptr,
12455 Best->FoundDecl, Method);
12462 ExprResult Arg0 = PerformCopyInitialization(
12470 PerformCopyInitialization(
12482 Best->FoundDecl, Base,
12483 HadMultipleCandidates, OpLoc);
12484 if (FnExpr.isInvalid())
12494 Args, ResultTy, VK, OpLoc,
12497 if (CheckCallReturnType(FnDecl->
getReturnType(), OpLoc, TheCall,
12502 const Expr *ImplicitThis =
nullptr;
12504 if (isa<CXXMethodDecl>(FnDecl)) {
12505 ImplicitThis = ArgsArray[0];
12506 ArgsArray = ArgsArray.slice(1);
12510 if (Op == OO_Equal)
12511 DiagnoseSelfMove(Args[0], Args[1], OpLoc);
12513 checkCall(FnDecl,
nullptr, ImplicitThis, ArgsArray,
12514 isa<CXXMethodDecl>(FnDecl), OpLoc, TheCall->getSourceRange(),
12515 VariadicDoesNotApply);
12517 return MaybeBindToTemporary(TheCall);
12522 ExprResult ArgsRes0 = PerformImplicitConversion(
12523 Args[0], Best->BuiltinParamTypes[0], Best->Conversions[0],
12524 AA_Passing, CCK_ForBuiltinOverloadedOp);
12527 Args[0] = ArgsRes0.
get();
12529 ExprResult ArgsRes1 = PerformImplicitConversion(
12530 Args[1], Best->BuiltinParamTypes[1], Best->Conversions[1],
12531 AA_Passing, CCK_ForBuiltinOverloadedOp);
12534 Args[1] = ArgsRes1.
get();
12544 if (Opc == BO_Comma)
12552 Opc >= BO_Assign && Opc <= BO_OrAssign) {
12553 Diag(OpLoc, diag::err_ovl_no_viable_oper)
12556 if (Args[0]->getType()->isIncompleteType()) {
12557 Diag(OpLoc, diag::note_assign_lhs_incomplete)
12571 Result = CreateBuiltinBinOp(OpLoc, Opc, Args[0], Args[1]);
12574 "C++ binary operator overloading is missing candidates!");
12582 Diag(OpLoc, diag::err_ovl_ambiguous_oper_binary)
12591 if (isImplicitlyDeleted(Best->Function)) {
12592 CXXMethodDecl *Method = cast<CXXMethodDecl>(Best->Function);
12593 Diag(OpLoc, diag::err_ovl_deleted_special_oper)
12595 << getSpecialMember(Method);
12599 NoteDeletedFunction(Method);
12602 Diag(OpLoc, diag::err_ovl_deleted_oper)
12603 << Best->Function->isDeleted()
12605 << getDeletedOrUnavailableSuffix(Best->Function)
12614 return CreateBuiltinBinOp(OpLoc, Opc, Args[0], Args[1]);
12621 Expr *Args[2] = { Base, Idx };
12627 if (Args[0]->isTypeDependent() || Args[1]->isTypeDependent()) {
12641 return new (Context)
12658 AddMemberOperatorCandidates(OO_Subscript, LLoc, Args, CandidateSet);
12661 AddBuiltinOperatorCandidates(OO_Subscript, LLoc, Args, CandidateSet);
12663 bool HadMultipleCandidates = (CandidateSet.
size() > 1);
12676 CheckMemberOperatorAccess(LLoc, Args[0], Args[1], Best->FoundDecl);
12681 PerformObjectArgumentInitialization(Args[0],
nullptr,
12682 Best->FoundDecl, Method);
12683 if (Arg0.isInvalid())
12685 Args[0] = Arg0.get();
12701 OpLocInfo.setCXXOperatorNameRange(
SourceRange(LLoc, RLoc));
12705 HadMultipleCandidates,
12706 OpLocInfo.getLoc(),
12707 OpLocInfo.getInfo());
12718 FnExpr.
get(), Args,
12719 ResultTy, VK, RLoc,
12722 if (CheckCallReturnType(FnDecl->
getReturnType(), LLoc, TheCall, FnDecl))
12725 if (CheckFunctionCall(Method, TheCall,
12729 return MaybeBindToTemporary(TheCall);
12734 ExprResult ArgsRes0 = PerformImplicitConversion(
12735 Args[0], Best->BuiltinParamTypes[0], Best->Conversions[0],
12736 AA_Passing, CCK_ForBuiltinOverloadedOp);
12739 Args[0] = ArgsRes0.
get();
12741 ExprResult ArgsRes1 = PerformImplicitConversion(
12742 Args[1], Best->BuiltinParamTypes[1], Best->Conversions[1],
12743 AA_Passing, CCK_ForBuiltinOverloadedOp);
12746 Args[1] = ArgsRes1.
get();
12753 if (CandidateSet.
empty())
12754 Diag(LLoc, diag::err_ovl_no_oper)
12758 Diag(LLoc, diag::err_ovl_no_viable_subscript)
12767 Diag(LLoc, diag::err_ovl_ambiguous_oper_binary)
12776 Diag(LLoc, diag::err_ovl_deleted_oper)
12777 << Best->Function->isDeleted() <<
"[]" 12778 << getDeletedOrUnavailableSuffix(Best->Function)
12786 return CreateBuiltinArraySubscriptExpr(Args[0], LLoc, Args[1], RLoc);
12809 if (
BinaryOperator *op = dyn_cast<BinaryOperator>(NakedMemExpr)) {
12811 assert(op->getOpcode() == BO_PtrMemD || op->getOpcode() == BO_PtrMemI);
12824 QualType objectType = op->getLHS()->getType();
12825 if (op->getOpcode() == BO_PtrMemI)
12827 Qualifiers objectQuals = objectType.getQualifiers();
12829 Qualifiers difference = objectQuals - funcQuals;
12833 std::string qualsString = difference.
getAsString();
12834 Diag(LParenLoc, diag::err_pointer_to_member_call_drops_quals)
12835 << fnType.getUnqualifiedType()
12837 << (qualsString.find(
' ') == std::string::npos ? 1 : 2);
12842 resultType, valueKind, RParenLoc);
12844 if (CheckCallReturnType(proto->
getReturnType(), op->getRHS()->getLocStart(),
12848 if (ConvertArgumentsForCall(call, op,
nullptr, proto, Args, RParenLoc))
12851 if (CheckOtherCall(call, proto))
12854 return MaybeBindToTemporary(call);
12857 if (isa<CXXPseudoDestructorExpr>(NakedMemExpr))
12858 return new (Context)
12861 UnbridgedCastsSet UnbridgedCasts;
12869 if (isa<MemberExpr>(NakedMemExpr)) {
12870 MemExpr = cast<MemberExpr>(NakedMemExpr);
12874 UnbridgedCasts.restore();
12892 TemplateArgs = &TemplateArgsBuffer;
12896 E = UnresExpr->
decls_end(); I != E; ++I) {
12900 if (isa<UsingShadowDecl>(Func))
12901 Func = cast<UsingShadowDecl>(Func)->getTargetDecl();
12905 if (getLangOpts().MicrosoftExt && isa<CXXConstructorDecl>(Func)) {
12906 AddOverloadCandidate(cast<CXXConstructorDecl>(Func), I.getPair(),
12907 Args, CandidateSet);
12908 }
else if ((Method = dyn_cast<CXXMethodDecl>(Func))) {
12914 AddMethodCandidate(Method, I.getPair(), ActingDC, ObjectType,
12915 ObjectClassification, Args, CandidateSet,
12918 AddMethodTemplateCandidate(
12919 cast<FunctionTemplateDecl>(Func), I.getPair(), ActingDC,
12920 TemplateArgs, ObjectType, ObjectClassification, Args, CandidateSet,
12927 UnbridgedCasts.restore();
12930 switch (CandidateSet.BestViableFunction(*
this, UnresExpr->
getLocStart(),
12933 Method = cast<CXXMethodDecl>(Best->Function);
12934 FoundDecl = Best->FoundDecl;
12935 CheckUnresolvedMemberAccess(UnresExpr, Best->FoundDecl);
12936 if (DiagnoseUseOfDecl(Best->FoundDecl, UnresExpr->
getNameLoc()))
12944 if (Method != FoundDecl.getDecl() &&
12945 DiagnoseUseOfDecl(Method, UnresExpr->
getNameLoc()))
12951 diag::err_ovl_no_viable_member_function_in_call)
12966 << Best->Function->isDeleted()
12968 << getDeletedOrUnavailableSuffix(Best->Function)
12975 MemExprE = FixOverloadedFunctionReference(MemExprE, FoundDecl, Method);
12980 return BuildResolvedCallExpr(MemExprE, Method, LParenLoc, Args,
12989 ResultType = ResultType.getNonLValueExprType(Context);
12991 assert(Method &&
"Member call to something that isn't a method?");
12994 ResultType, VK, RParenLoc);
13006 PerformObjectArgumentInitialization(MemExpr->
getBase(), Qualifier,
13007 FoundDecl, Method);
13016 if (ConvertArgumentsForCall(TheCall, MemExpr, Method, Proto, Args,
13020 DiagnoseSentinelCalls(Method, LParenLoc, Args);
13022 if (CheckFunctionCall(Method, TheCall, Proto))
13028 if (
auto *MemE = dyn_cast<MemberExpr>(NakedMemExpr)) {
13029 if (
const EnableIfAttr *
Attr = CheckEnableIf(Method, Args,
true)) {
13030 Diag(MemE->getMemberLoc(),
13031 diag::err_ovl_no_viable_member_function_in_call)
13034 diag::note_ovl_candidate_disabled_by_function_cond_attr)
13035 <<
Attr->getCond()->getSourceRange() <<
Attr->getMessage();
13040 if ((isa<CXXConstructorDecl>(CurContext) ||
13041 isa<CXXDestructorDecl>(CurContext)) &&
13048 diag::warn_call_to_pure_virtual_member_function_from_ctor_dtor)
13049 << MD->
getDeclName() << isa<CXXDestructorDecl>(CurContext)
13053 if (getLangOpts().AppleKext)
13055 diag::note_pure_qualified_call_kext)
13064 bool CallCanBeVirtual = !MemExpr->
hasQualifier() || getLangOpts().AppleKext;
13065 CheckVirtualDtorCall(DD, MemExpr->
getLocStart(),
false,
13066 CallCanBeVirtual,
true,
13070 return MaybeBindToTemporary(TheCall);
13086 UnbridgedCastsSet UnbridgedCasts;
13090 assert(Object.
get()->getType()->isRecordType() &&
13091 "Requires object type argument");
13105 if (RequireCompleteType(LParenLoc, Object.
get()->getType(),
13106 diag::err_incomplete_object_call, Object.
get()))
13109 LookupResult R(*
this, OpName, LParenLoc, LookupOrdinaryName);
13110 LookupQualifiedName(R, Record->getDecl());
13114 Oper != OperEnd; ++Oper) {
13115 AddMethodCandidate(Oper.getPair(), Object.
get()->getType(),
13116 Object.
get()->Classify(Context), Args, CandidateSet,
13137 const auto &Conversions =
13138 cast<CXXRecordDecl>(Record->getDecl())->getVisibleConversionFunctions();
13139 for (
auto I = Conversions.begin(), E = Conversions.end(); I != E; ++I) {
13142 if (isa<UsingShadowDecl>(D))
13143 D = cast<UsingShadowDecl>(D)->getTargetDecl();
13147 if (isa<FunctionTemplateDecl>(D))
13160 AddSurrogateCandidate(Conv, I.getPair(), ActingContext, Proto,
13161 Object.
get(), Args, CandidateSet);
13166 bool HadMultipleCandidates = (CandidateSet.size() > 1);
13170 switch (CandidateSet.BestViableFunction(*
this, Object.
get()->getLocStart(),
13178 if (CandidateSet.empty())
13179 Diag(Object.
get()->getLocStart(), diag::err_ovl_no_oper)
13180 << Object.
get()->getType() << 1
13181 << Object.
get()->getSourceRange();
13183 Diag(Object.
get()->getLocStart(),
13184 diag::err_ovl_no_viable_object_call)
13185 << Object.
get()->getType() << Object.
get()->getSourceRange();
13190 Diag(Object.
get()->getLocStart(),
13191 diag::err_ovl_ambiguous_object_call)
13192 << Object.
get()->getType() << Object.
get()->getSourceRange();
13197 Diag(Object.
get()->getLocStart(),
13198 diag::err_ovl_deleted_object_call)
13199 << Best->Function->isDeleted()
13200 << Object.
get()->getType()
13201 << getDeletedOrUnavailableSuffix(Best->Function)
13202 << Object.
get()->getSourceRange();
13207 if (Best == CandidateSet.end())
13210 UnbridgedCasts.restore();
13212 if (Best->Function ==
nullptr) {
13216 = cast<CXXConversionDecl>(
13217 Best->Conversions[0].UserDefined.ConversionFunction);
13219 CheckMemberOperatorAccess(LParenLoc, Object.
get(),
nullptr,
13221 if (DiagnoseUseOfDecl(Best->FoundDecl, LParenLoc))
13223 assert(Conv == Best->FoundDecl.getDecl() &&
13224 "Found Decl & conversion-to-functionptr should be same, right?!");
13231 ExprResult Call = BuildCXXMemberCallExpr(Object.
get(), Best->FoundDecl,
13232 Conv, HadMultipleCandidates);
13233 if (Call.isInvalid())
13237 CK_UserDefinedConversion, Call.get(),
13240 return ActOnCallExpr(S, Call.get(), LParenLoc, Args, RParenLoc);
13243 CheckMemberOperatorAccess(LParenLoc, Object.
get(),
nullptr, Best->FoundDecl);
13248 CXXMethodDecl *Method = cast<CXXMethodDecl>(Best->Function);
13251 if (Method->isInvalidDecl())
13263 Obj, HadMultipleCandidates,
13264 OpLocInfo.getLoc(),
13265 OpLocInfo.getInfo());
13272 MethodArgs[0] = Object.
get();
13273 std::copy(Args.begin(), Args.end(), MethodArgs.begin() + 1);
13277 QualType ResultTy = Method->getReturnType();
13279 ResultTy = ResultTy.getNonLValueExprType(Context);
13285 if (CheckCallReturnType(Method->getReturnType(), LParenLoc, TheCall, Method))
13290 if (Args.size() < NumParams)
13291 TheCall->
setNumArgs(Context, NumParams + 1);
13293 bool IsError =
false;
13297 PerformObjectArgumentInitialization(Object.
get(),
nullptr,
13298 Best->FoundDecl, Method);
13303 TheCall->setArg(0, Object.
get());
13306 for (
unsigned i = 0; i != NumParams; i++) {
13308 if (i < Args.size()) {
13316 Method->getParamDecl(i)),
13323 = BuildCXXDefaultArgExpr(LParenLoc, Method, Method->getParamDecl(i));
13332 TheCall->setArg(i + 1, Arg);
13338 for (
unsigned i = NumParams, e = Args.size(); i < e; i++) {
13339 ExprResult Arg = DefaultVariadicArgumentPromotion(Args[i], VariadicMethod,
13342 TheCall->setArg(i + 1, Arg.
get());
13346 if (IsError)
return true;
13348 DiagnoseSentinelCalls(Method, LParenLoc, Args);
13350 if (CheckFunctionCall(Method, TheCall, Proto))
13353 return MaybeBindToTemporary(TheCall);
13361 bool *NoArrowOperatorFound) {
13363 "left-hand side must have class type");
13381 if (RequireCompleteType(Loc, Base->
getType(),
13382 diag::err_typecheck_incomplete_tag, Base))
13385 LookupResult R(*
this, OpName, OpLoc, LookupOrdinaryName);
13386 LookupQualifiedName(R, BaseRecord->
getDecl());
13390 Oper != OperEnd; ++Oper) {
13391 AddMethodCandidate(Oper.getPair(), Base->
getType(), Base->
Classify(Context),
13392 None, CandidateSet,
false);
13395 bool HadMultipleCandidates = (CandidateSet.
size() > 1);
13405 if (CandidateSet.
empty()) {
13407 if (NoArrowOperatorFound) {
13410 *NoArrowOperatorFound =
true;
13413 Diag(OpLoc, diag::err_typecheck_member_reference_arrow)
13416 Diag(OpLoc, diag::note_typecheck_member_reference_suggestion)
13420 Diag(OpLoc, diag::err_ovl_no_viable_oper)
13426 Diag(OpLoc, diag::err_ovl_ambiguous_oper_unary)
13432 Diag(OpLoc, diag::err_ovl_deleted_oper)
13433 << Best->Function->isDeleted()
13435 << getDeletedOrUnavailableSuffix(Best->Function)
13441 CheckMemberOperatorAccess(OpLoc, Base,
nullptr, Best->FoundDecl);
13444 CXXMethodDecl *Method = cast<CXXMethodDecl>(Best->Function);
13446 PerformObjectArgumentInitialization(Base,
nullptr,
13447 Best->FoundDecl, Method);
13448 if (BaseResult.isInvalid())
13450 Base = BaseResult.get();
13454 Base, HadMultipleCandidates, OpLoc);
13463 Base, ResultTy, VK, OpLoc,
FPOptions());
13465 if (CheckCallReturnType(Method->
getReturnType(), OpLoc, TheCall, Method))
13468 if (CheckFunctionCall(Method, TheCall,
13472 return MaybeBindToTemporary(TheCall);
13486 AddFunctionCandidates(R.
asUnresolvedSet(), Args, CandidateSet, TemplateArgs,
13489 bool HadMultipleCandidates = (CandidateSet.size() > 1);
13494 switch (CandidateSet.BestViableFunction(*
this, UDSuffixLoc, Best)) {
13500 Diag(UDSuffixLoc, diag::err_ovl_no_viable_function_in_call)
13513 nullptr, HadMultipleCandidates,
13522 for (
unsigned ArgIdx = 0, N = Args.size(); ArgIdx != N; ++ArgIdx) {
13523 ExprResult InputInit = PerformCopyInitialization(
13528 ConvArgs[ArgIdx] = InputInit.
get();
13537 llvm::makeArrayRef(ConvArgs, Args.size()),
13538 ResultTy, VK, LitEndLoc, UDSuffixLoc);
13540 if (CheckCallReturnType(FD->
getReturnType(), UDSuffixLoc, UDL, FD))
13543 if (CheckFunctionCall(FD, UDL,
nullptr))
13546 return MaybeBindToTemporary(UDL);
13563 Scope *S =
nullptr;
13566 if (!MemberLookup.
empty()) {
13568 BuildMemberReferenceExpr(Range, Range->
getType(), Loc,
13576 return FRS_DiagnosticIssued;
13578 *CallExpr = ActOnCallExpr(S, MemberRef.
get(), Loc, None, Loc,
nullptr);
13581 return FRS_DiagnosticIssued;
13589 FoundNames.
begin(), FoundNames.
end());
13591 bool CandidateSetError = buildOverloadedCallSet(S, Fn, Fn, Range, Loc,
13592 CandidateSet, CallExpr);
13593 if (CandidateSet->
empty() || CandidateSetError) {
13595 return FRS_NoViableFunction;
13603 return FRS_NoViableFunction;
13606 Loc,
nullptr, CandidateSet, &Best,
13611 return FRS_DiagnosticIssued;
13614 return FRS_Success;
13625 if (
ParenExpr *PE = dyn_cast<ParenExpr>(E)) {
13626 Expr *SubExpr = FixOverloadedFunctionReference(PE->getSubExpr(),
13628 if (SubExpr == PE->getSubExpr())
13631 return new (Context)
ParenExpr(PE->getLParen(), PE->getRParen(), SubExpr);
13635 Expr *SubExpr = FixOverloadedFunctionReference(ICE->getSubExpr(),
13637 assert(Context.
hasSameType(ICE->getSubExpr()->getType(),
13639 "Implicit cast type cannot be determined from overload");
13640 assert(ICE->path_empty() &&
"fixing up hierarchy conversion?");
13641 if (SubExpr == ICE->getSubExpr())
13645 ICE->getCastKind(),
13650 if (
auto *GSE = dyn_cast<GenericSelectionExpr>(E)) {
13651 if (!GSE->isResultDependent()) {
13653 FixOverloadedFunctionReference(GSE->getResultExpr(), Found, Fn);
13654 if (SubExpr == GSE->getResultExpr())
13661 unsigned ResultIdx = GSE->getResultIndex();
13662 AssocExprs[ResultIdx] = SubExpr;
13665 Context, GSE->getGenericLoc(), GSE->getControllingExpr(),
13666 GSE->getAssocTypeSourceInfos(), AssocExprs, GSE->getDefaultLoc(),
13667 GSE->getRParenLoc(), GSE->containsUnexpandedParameterPack(),
13676 assert(UnOp->getOpcode() == UO_AddrOf &&
13677 "Can only take the address of an overloaded function");
13679 if (Method->isStatic()) {
13686 Expr *SubExpr = FixOverloadedFunctionReference(UnOp->getSubExpr(),
13688 if (SubExpr == UnOp->getSubExpr())
13691 assert(isa<DeclRefExpr>(SubExpr)
13692 &&
"fixed to something other than a decl ref");
13693 assert(cast<DeclRefExpr>(SubExpr)->getQualifier()
13694 &&
"fixed to a member ref with no nested name qualifier");
13700 = Context.
getTypeDeclType(cast<RecordDecl>(Method->getDeclContext()));
13705 (
void)isCompleteType(UnOp->getOperatorLoc(), MemPtrType);
13707 return new (Context)
UnaryOperator(SubExpr, UO_AddrOf, MemPtrType,
13709 UnOp->getOperatorLoc(),
false);
13712 Expr *SubExpr = FixOverloadedFunctionReference(UnOp->getSubExpr(),
13714 if (SubExpr == UnOp->getSubExpr())
13720 UnOp->getOperatorLoc(),
false);
13733 if (ULE->hasExplicitTemplateArgs()) {
13734 ULE->copyTemplateArgumentsInto(TemplateArgsBuffer);
13735 TemplateArgs = &TemplateArgsBuffer;
13739 ULE->getQualifierLoc(),
13740 ULE->getTemplateKeywordLoc(),
13748 MarkDeclRefReferenced(DRE);
13756 if (MemExpr->hasExplicitTemplateArgs()) {
13757 MemExpr->copyTemplateArgumentsInto(TemplateArgsBuffer);
13758 TemplateArgs = &TemplateArgsBuffer;
13765 if (MemExpr->isImplicitAccess()) {
13766 if (cast<CXXMethodDecl>(Fn)->isStatic()) {
13768 MemExpr->getQualifierLoc(),
13769 MemExpr->getTemplateKeywordLoc(),
13772 MemExpr->getMemberLoc(),
13777 MarkDeclRefReferenced(DRE);
13782 if (MemExpr->getQualifier())
13783 Loc = MemExpr->getQualifierLoc().getBeginLoc();
13784 CheckCXXThisCapture(Loc);
13786 MemExpr->getBaseType(),
13790 Base = MemExpr->getBase();
13794 if (cast<CXXMethodDecl>(Fn)->isStatic()) {
13803 Context, Base, MemExpr->isArrow(), MemExpr->getOperatorLoc(),
13804 MemExpr->getQualifierLoc(), MemExpr->getTemplateKeywordLoc(), Fn, Found,
13805 MemExpr->getMemberNameInfo(), TemplateArgs,
type, valueKind,
13808 MarkMemberReferenced(ME);
13812 llvm_unreachable(
"Invalid reference to overloaded function");
13818 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.
static UnresolvedLookupExpr * Create(const ASTContext &C, CXXRecordDecl *NamingClass, NestedNameSpecifierLoc QualifierLoc, const DeclarationNameInfo &NameInfo, bool ADL, bool Overloaded, UnresolvedSetIterator Begin, UnresolvedSetIterator End)
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.
bool hasPlaceholderType() const
Returns whether this expression has a placeholder type.
void clear()
Clear out all of the candidates.
ConversionSet::const_iterator const_iterator
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...
__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.
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.
ExprResult BuildResolvedCallExpr(Expr *Fn, NamedDecl *NDecl, SourceLocation LParenLoc, ArrayRef< Expr *> Arg, SourceLocation RParenLoc, Expr *Config=nullptr, bool IsExecConfig=false)
BuildResolvedCallExpr - Build a call to a resolved expression, i.e.
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.
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.
SourceLocation getLocStart() const LLVM_READONLY
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...
void AddOverloadCandidate(FunctionDecl *Function, DeclAccessPair FoundDecl, ArrayRef< Expr *> Args, OverloadCandidateSet &CandidateSet, bool SuppressUserConversions=false, bool PartialOverloading=false, bool AllowExplicit=false, ConversionSequenceList EarlyConversions=None)
AddOverloadCandidate - Adds the given function to the set of candidate functions, using the given fun...
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.
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
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)
void setNumArgs(const ASTContext &C, unsigned NumArgs)
setNumArgs - This changes the number of arguments present in this call.
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.
unsigned getTypeQualifiers() const
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.
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)
SourceLocation getLocStart() const LLVM_READONLY
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.
unsigned getTypeQuals() const
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
StringRef getOpcodeStr() const
Floating point promotions (C++ [conv.fpprom])
Describes an C or C++ initializer list.
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)
QualType getThisType(ASTContext &C) const
Returns the type of the this pointer.
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.
void getAsStringInternal(std::string &Str, const PrintingPolicy &Policy) const
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)
Complex <-> Real conversion.
NameKind getNameKind() const
getNameKind - Determine what kind of name this is.
bool Viable
Viable - True to indicate that this overload candidate is viable.
ConversionSequenceList Conversions
The conversion sequences used to convert the function arguments to the function parameters.
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
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.
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 DiagnoseUseOfDecl(NamedDecl *D, ArrayRef< SourceLocation > Locs, const ObjCInterfaceDecl *UnknownObjCClass=nullptr, bool ObjCPropertyAccess=false, bool AvoidPartialAvailabilityChecks=false)
Determine whether the use of this declaration is valid, and emit any corresponding diagnostics...
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
OverloadedOperatorKind getCXXOverloadedOperator() const
getCXXOverloadedOperator - If this name is the name of an overloadable operator in C++ (e...
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 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.
Expr - 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.
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]...
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...
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])
static SmallVector< EnableIfAttr *, 4 > getOrderedEnableIfAttrs(const FunctionDecl *Function)
The current expression and its subexpressions occur within an unevaluated operand (C++11 [expr]p7)...
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.
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.
CXXMethodDecl * getMethodDecl() const
Retrieves the declaration of the called method.
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...
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
bool isPure() const
Whether this virtual function is pure, i.e.
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...
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...
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...
SourceLocation getLocStart() const LLVM_READONLY
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.
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.
SourceLocation getLocEnd() const LLVM_READONLY
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
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.
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.
SourceLocation getLocStart() const LLVM_READONLY
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.
DeclarationName - 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.
SourceLocation getLocStart() const LLVM_READONLY
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...
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.
void AddTemplateOverloadCandidate(FunctionTemplateDecl *FunctionTemplate, DeclAccessPair FoundDecl, TemplateArgumentListInfo *ExplicitTemplateArgs, ArrayRef< Expr *> Args, OverloadCandidateSet &CandidateSet, bool SuppressUserConversions=false, bool PartialOverloading=false)
Add a C++ function template specialization as a candidate in the candidate set, using template argume...
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.
SourceLocation getLocStart() const LLVM_READONLY
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)
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...
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
static Qualifiers fromCVRMask(unsigned CVR)
std::string getQualifiedNameAsString() const
ExprResult CheckConvertedConstantExpression(Expr *From, QualType T, llvm::APSInt &Value, CCEKind CCE)
bool IsQualificationConversion(QualType FromType, QualType ToType, bool CStyle, bool &ObjCLifetimeConversion)
IsQualificationConversion - Determines whether the conversion from an rvalue of type FromType to ToTy...
bool isDependentType() const
Whether this type is a dependent type, meaning that its definition somehow depends on a template para...
QualType getAsType() const
Retrieve the type for a type template argument.
A 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.
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.
void clear()
Clears out any current state.
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)