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()->isObjCObjectPointerType() ||
227 getFromType()->isBlockPointerType() ||
228 getFromType()->isNullPtrType() ||
261 while (
const ImplicitCastExpr *ICE = dyn_cast<ImplicitCastExpr>(Converted)) {
262 switch (ICE->getCastKind()) {
264 case CK_IntegralCast:
265 case CK_IntegralToBoolean:
266 case CK_IntegralToFloating:
267 case CK_BooleanToSignedIntegral:
268 case CK_FloatingToIntegral:
269 case CK_FloatingToBoolean:
270 case CK_FloatingCast:
271 Converted = ICE->getSubExpr();
293 const Expr *Converted,
296 assert(Ctx.
getLangOpts().CPlusPlus &&
"narrowing check outside C++");
307 ToType = ET->getDecl()->getIntegerType();
312 if (FromType->isRealFloatingType())
313 goto FloatingIntegralConversion;
314 if (FromType->isIntegralOrUnscopedEnumerationType())
315 goto IntegralConversion;
327 FloatingIntegralConversion:
328 if (FromType->isRealFloatingType() && ToType->
isIntegralType(Ctx)) {
331 llvm::APSInt IntConstantValue;
333 assert(Initializer &&
"Unknown conversion expression");
342 Result.convertFromAPInt(IntConstantValue, IntConstantValue.isSigned(),
343 llvm::APFloat::rmNearestTiesToEven);
345 llvm::APSInt ConvertedValue = IntConstantValue;
347 Result.convertToInteger(ConvertedValue,
348 llvm::APFloat::rmTowardZero, &ignored);
350 if (IntConstantValue != ConvertedValue) {
351 ConstantValue =
APValue(IntConstantValue);
352 ConstantType = Initializer->
getType();
378 assert(ConstantValue.
isFloat());
379 llvm::APFloat FloatVal = ConstantValue.
getFloat();
382 llvm::APFloat::opStatus ConvertStatus = FloatVal.convert(
384 llvm::APFloat::rmNearestTiesToEven, &ignored);
387 if (ConvertStatus & llvm::APFloat::opOverflow) {
388 ConstantType = Initializer->
getType();
403 IntegralConversion: {
404 assert(FromType->isIntegralOrUnscopedEnumerationType());
406 const bool FromSigned = FromType->isSignedIntegerOrEnumerationType();
407 const unsigned FromWidth = Ctx.
getIntWidth(FromType);
411 if (FromWidth > ToWidth ||
412 (FromWidth == ToWidth && FromSigned != ToSigned) ||
413 (FromSigned && !ToSigned)) {
415 llvm::APSInt InitializerValue;
426 bool Narrowing =
false;
427 if (FromWidth < ToWidth) {
430 if (InitializerValue.isSigned() && InitializerValue.isNegative())
435 InitializerValue = InitializerValue.extend(
436 InitializerValue.getBitWidth() + 1);
438 llvm::APSInt ConvertedValue = InitializerValue;
439 ConvertedValue = ConvertedValue.trunc(ToWidth);
440 ConvertedValue.setIsSigned(ToSigned);
441 ConvertedValue = ConvertedValue.extend(InitializerValue.getBitWidth());
442 ConvertedValue.setIsSigned(InitializerValue.isSigned());
444 if (ConvertedValue != InitializerValue)
448 ConstantType = Initializer->
getType();
449 ConstantValue =
APValue(InitializerValue);
465 raw_ostream &OS = llvm::errs();
466 bool PrintedSomething =
false;
469 PrintedSomething =
true;
473 if (PrintedSomething) {
478 if (CopyConstructor) {
479 OS <<
" (by copy constructor)";
480 }
else if (DirectBinding) {
481 OS <<
" (direct reference binding)";
482 }
else if (ReferenceBinding) {
483 OS <<
" (reference binding)";
485 PrintedSomething =
true;
489 if (PrintedSomething) {
493 PrintedSomething =
true;
496 if (!PrintedSomething) {
497 OS <<
"No conversions required";
504 raw_ostream &OS = llvm::errs();
505 if (Before.First || Before.Second || Before.Third) {
509 if (ConversionFunction)
510 OS <<
'\'' << *ConversionFunction <<
'\'';
512 OS <<
"aggregate initialization";
522 raw_ostream &OS = llvm::errs();
523 if (isStdInitializerListElement())
524 OS <<
"Worst std::initializer_list element conversion: ";
525 switch (ConversionKind) {
526 case StandardConversion:
527 OS <<
"Standard conversion: ";
530 case UserDefinedConversion:
531 OS <<
"User-defined conversion: ";
534 case EllipsisConversion:
535 OS <<
"Ellipsis conversion";
537 case AmbiguousConversion:
538 OS <<
"Ambiguous conversion";
541 OS <<
"Bad conversion";
553 conversions().~ConversionSet();
566 struct DFIArguments {
572 struct DFIParamWithArguments : DFIArguments {
577 struct DFIDeducedMismatchArgs : DFIArguments {
579 unsigned CallArgIndex;
590 Result.
Result =
static_cast<unsigned>(TDK);
599 Result.
Data =
nullptr;
604 Result.
Data = Info.
Param.getOpaqueValue();
610 auto *Saved =
new (Context) DFIDeducedMismatchArgs;
613 Saved->TemplateArgs = Info.
take();
621 DFIArguments *Saved =
new (Context) DFIArguments;
631 DFIParamWithArguments *Saved =
new (Context) DFIParamWithArguments;
632 Saved->Param = Info.
Param;
651 llvm_unreachable(
"not a deduction failure");
658 switch (static_cast<Sema::TemplateDeductionResult>(Result)) {
683 Diag->~PartialDiagnosticAt();
684 HasDiagnostic =
false;
701 switch (static_cast<Sema::TemplateDeductionResult>(Result)) {
717 return TemplateParameter::getFromOpaqueValue(Data);
721 return static_cast<DFIParamWithArguments*
>(Data)->Param;
732 switch (static_cast<Sema::TemplateDeductionResult>(Result)) {
749 return static_cast<DFIDeducedMismatchArgs*
>(Data)->TemplateArgs;
763 switch (static_cast<Sema::TemplateDeductionResult>(Result)) {
781 return &
static_cast<DFIArguments*
>(Data)->FirstArg;
792 switch (static_cast<Sema::TemplateDeductionResult>(Result)) {
810 return &
static_cast<DFIArguments*
>(Data)->SecondArg;
821 switch (static_cast<Sema::TemplateDeductionResult>(Result)) {
824 return static_cast<DFIDeducedMismatchArgs*
>(Data)->CallArgIndex;
831 void OverloadCandidateSet::destroyCandidates() {
832 for (iterator i = begin(), e = end(); i != e; ++i) {
833 for (
auto &C : i->Conversions)
834 C.~ImplicitConversionSequence();
836 i->DeductionFailure.Destroy();
842 SlabAllocator.Reset();
843 NumInlineBytesUsed = 0;
850 class UnbridgedCastsSet {
860 Entry entry = { &E, E };
861 Entries.push_back(entry);
867 i = Entries.begin(), e = Entries.end(); i != e; ++i)
882 UnbridgedCastsSet *unbridgedCasts =
nullptr) {
886 if (placeholder->getKind() == BuiltinType::Overload)
return false;
890 if (placeholder->getKind() == BuiltinType::ARCUnbridgedCast &&
892 unbridgedCasts->save(S, E);
913 UnbridgedCastsSet &unbridged) {
914 for (
unsigned i = 0, e = Args.size(); i != e; ++i)
956 NamedDecl *&Match,
bool NewIsUsingDecl) {
961 bool OldIsUsingDecl =
false;
962 if (isa<UsingShadowDecl>(OldD)) {
963 OldIsUsingDecl =
true;
967 if (NewIsUsingDecl)
continue;
969 OldD = cast<UsingShadowDecl>(OldD)->getTargetDecl();
974 if ((OldIsUsingDecl || NewIsUsingDecl) && !isVisible(*I))
982 bool UseMemberUsingDeclRules =
983 (OldIsUsingDecl || NewIsUsingDecl) && CurContext->isRecord() &&
987 if (!IsOverload(New, OldF, UseMemberUsingDeclRules)) {
988 if (UseMemberUsingDeclRules && OldIsUsingDecl) {
989 HideUsingShadowDecl(S, cast<UsingShadowDecl>(*I));
993 if (!isa<FunctionTemplateDecl>(OldD) &&
994 !shouldLinkPossiblyHiddenDecl(*I, New))
1000 }
else if (isa<UsingDecl>(OldD) || isa<UsingPackDecl>(OldD)) {
1004 }
else if (isa<TagDecl>(OldD)) {
1006 }
else if (
auto *UUD = dyn_cast<UnresolvedUsingValueDecl>(OldD)) {
1013 if (UUD->getQualifier()->isDependent() && !UUD->isCXXClassMember()) {
1015 return Ovl_NonFunction;
1022 return Ovl_NonFunction;
1026 return Ovl_Overload;
1030 bool UseMemberUsingDeclRules,
bool ConsiderCudaAttrs) {
1045 if ((OldTemplate ==
nullptr) != (NewTemplate ==
nullptr))
1058 if (isa<FunctionNoProtoType>(OldQType.
getTypePtr()) ||
1059 isa<FunctionNoProtoType>(NewQType.
getTypePtr()))
1068 if (OldQType != NewQType &&
1070 OldType->
isVariadic() != NewType->isVariadic() ||
1071 !FunctionParamTypesAreEqual(OldType, NewType)))
1086 if (!UseMemberUsingDeclRules && NewTemplate &&
1089 false, TPL_TemplateMatch) ||
1103 if (OldMethod && NewMethod &&
1104 !OldMethod->
isStatic() && !NewMethod->isStatic()) {
1106 if (!UseMemberUsingDeclRules &&
1108 NewMethod->getRefQualifier() ==
RQ_None)) {
1115 Diag(NewMethod->getLocation(), diag::err_ref_qualifier_overload)
1127 unsigned NewQuals = NewMethod->getTypeQualifiers();
1128 if (!getLangOpts().
CPlusPlus14 && NewMethod->isConstexpr() &&
1129 !isa<CXXConstructorDecl>(NewMethod))
1135 if (OldQuals != NewQuals)
1153 NewI != NewE || OldI != OldE; ++NewI, ++OldI) {
1154 if (NewI == NewE || OldI == OldE)
1156 llvm::FoldingSetNodeID NewID, OldID;
1157 NewI->getCond()->
Profile(NewID, Context,
true);
1158 OldI->getCond()->Profile(OldID, Context,
true);
1163 if (getLangOpts().CUDA && ConsiderCudaAttrs) {
1166 if (isa<CXXDestructorDecl>(New))
1170 OldTarget = IdentifyCUDATarget(Old);
1171 if (NewTarget == CFT_InvalidTarget)
1174 assert((OldTarget != CFT_InvalidTarget) &&
"Unexpected invalid target.");
1178 return NewTarget != OldTarget;
1195 Decl *C = cast<Decl>(CurContext);
1209 bool SuppressUserConversions,
1211 bool InOverloadResolution,
1213 bool AllowObjCWritebackConversion,
1214 bool AllowObjCConversionOnExplicit) {
1217 if (SuppressUserConversions) {
1228 Conversions, AllowExplicit,
1229 AllowObjCConversionOnExplicit)) {
1246 if (Constructor->isCopyConstructor() &&
1247 (FromCanon == ToCanon ||
1258 if (ToCanon != FromCanon)
1269 Cand != Conversions.
end(); ++Cand)
1312 bool SuppressUserConversions,
1314 bool InOverloadResolution,
1316 bool AllowObjCWritebackConversion,
1317 bool AllowObjCConversionOnExplicit) {
1320 ICS.
Standard, CStyle, AllowObjCWritebackConversion)){
1360 AllowExplicit, InOverloadResolution, CStyle,
1361 AllowObjCWritebackConversion,
1362 AllowObjCConversionOnExplicit);
1367 bool SuppressUserConversions,
1369 bool InOverloadResolution,
1371 bool AllowObjCWritebackConversion) {
1373 SuppressUserConversions, AllowExplicit,
1374 InOverloadResolution, CStyle,
1375 AllowObjCWritebackConversion,
1388 return PerformImplicitConversion(From, ToType, Action, AllowExplicit, ICS);
1399 bool AllowObjCWritebackConversion
1400 = getLangOpts().ObjCAutoRefCount &&
1401 (Action == AA_Passing || Action == AA_Sending);
1402 if (getLangOpts().ObjC1)
1403 CheckObjCBridgeRelatedConversions(From->
getLocStart(),
1404 ToType, From->
getType(), From);
1410 AllowObjCWritebackConversion,
1412 return PerformImplicitConversion(From, ToType, ICS, Action);
1433 if (TyClass != CanFrom->getTypeClass())
return false;
1434 if (TyClass != Type::FunctionProto && TyClass != Type::FunctionNoProto) {
1435 if (TyClass == Type::Pointer) {
1438 }
else if (TyClass == Type::BlockPointer) {
1441 }
else if (TyClass == Type::MemberPointer) {
1445 if (ToMPT->getClass() != FromMPT->
getClass())
1447 CanTo = ToMPT->getPointeeType();
1453 TyClass = CanTo->getTypeClass();
1454 if (TyClass != CanFrom->getTypeClass())
return false;
1455 if (TyClass != Type::FunctionProto && TyClass != Type::FunctionNoProto)
1459 const auto *FromFn = cast<FunctionType>(CanFrom);
1462 const auto *ToFn = cast<FunctionType>(CanTo);
1465 bool Changed =
false;
1468 if (FromEInfo.getNoReturn() && !ToEInfo.getNoReturn()) {
1474 if (
const auto *FromFPT = dyn_cast<FunctionProtoType>(FromFn)) {
1475 const auto *ToFPT = cast<FunctionProtoType>(ToFn);
1476 if (FromFPT->isNothrow(Context) && !ToFPT->isNothrow(Context)) {
1477 FromFn = cast<FunctionType>(
1479 FromFPT->getParamTypes(),
1480 FromFPT->getExtProtoInfo().withExceptionSpec(
1490 bool CanUseToFPT, CanUseFromFPT;
1492 CanUseFromFPT, NewParamInfos) &&
1493 CanUseToFPT && !CanUseFromFPT) {
1496 NewParamInfos.empty() ? nullptr : NewParamInfos.data();
1498 FromFPT->getParamTypes(), ExtInfo);
1507 assert(
QualType(FromFn, 0).isCanonical());
1508 if (
QualType(FromFn, 0) != CanTo)
return false;
1560 bool InOverloadResolution,
1573 bool InOverloadResolution,
1576 bool AllowObjCWritebackConversion) {
1623 if (Method && !Method->
isStatic()) {
1625 "Non-unary operator on non-static member address");
1628 "Non-address-of operator on non-static member address");
1629 const Type *ClassType
1635 "Non-address-of operator for overloaded function expression");
1662 FromType = Atomic->getValueType();
1697 if (
auto *FD = dyn_cast<FunctionDecl>(DRE->getDecl()))
1717 bool IncompatibleObjC =
false;
1768 if (Float128AndLongDouble &&
1770 &llvm::APFloat::IEEEdouble()))
1785 }
else if (AllowObjCWritebackConversion &&
1789 FromType, IncompatibleObjC)) {
1795 InOverloadResolution, FromType)) {
1807 InOverloadResolution,
1834 bool ObjCLifetimeConversion;
1840 ObjCLifetimeConversion)) {
1859 CanonFrom = CanonTo;
1864 if (CanonFrom == CanonTo)
1869 if (S.
getLangOpts().CPlusPlus || !InOverloadResolution)
1913 bool InOverloadResolution,
1923 for (
const auto *it : UD->
fields()) {
1926 ToType = it->getType();
1956 return To->
getKind() == BuiltinType::Int;
1959 return To->
getKind() == BuiltinType::UInt;
1983 if (FromEnumType->getDecl()->isScoped())
1990 if (FromEnumType->getDecl()->isFixed()) {
1991 QualType Underlying = FromEnumType->getDecl()->getIntegerType();
1993 IsIntegralPromotion(
nullptr, Underlying, ToType);
2000 ToType, FromEnumType->getDecl()->getPromotionType());
2017 uint64_t FromSize = Context.
getTypeSize(FromType);
2026 for (
int Idx = 0; Idx < 6; ++Idx) {
2027 uint64_t ToSize = Context.
getTypeSize(PromoteTypes[Idx]);
2028 if (FromSize < ToSize ||
2029 (FromSize == ToSize &&
2030 FromIsSigned == PromoteTypes[Idx]->isSignedIntegerType())) {
2050 llvm::APSInt BitWidth;
2052 MemberDecl->getBitWidth()->isIntegerConstantExpr(BitWidth, Context)) {
2053 llvm::APSInt ToSize(BitWidth.getBitWidth(), BitWidth.isUnsigned());
2057 if (BitWidth < ToSize ||
2059 return To->
getKind() == BuiltinType::Int;
2065 return To->
getKind() == BuiltinType::UInt;
2090 if (FromBuiltin->getKind() == BuiltinType::Float &&
2091 ToBuiltin->getKind() == BuiltinType::Double)
2097 if (!getLangOpts().CPlusPlus &&
2098 (FromBuiltin->getKind() == BuiltinType::Float ||
2099 FromBuiltin->getKind() == BuiltinType::Double) &&
2100 (ToBuiltin->getKind() == BuiltinType::LongDouble ||
2101 ToBuiltin->getKind() == BuiltinType::Float128))
2105 if (!getLangOpts().NativeHalfType &&
2106 FromBuiltin->getKind() == BuiltinType::Half &&
2107 ToBuiltin->getKind() == BuiltinType::Float)
2144 bool StripObjCLifetime =
false) {
2147 "Invalid similarly-qualified pointer type");
2158 if (StripObjCLifetime)
2169 if (isa<ObjCObjectPointerType>(ToType))
2178 if (isa<ObjCObjectPointerType>(ToType))
2184 bool InOverloadResolution,
2190 return !InOverloadResolution;
2214 bool InOverloadResolution,
2216 bool &IncompatibleObjC) {
2217 IncompatibleObjC =
false;
2218 if (isObjCPointerConversion(FromType, ToType, ConvertedType,
2225 ConvertedType = ToType;
2232 ConvertedType = ToType;
2239 ConvertedType = ToType;
2247 ConvertedType = ToType;
2257 ConvertedType = ToType;
2265 !getLangOpts().ObjCAutoRefCount) {
2296 if (getLangOpts().MSVCCompat && FromPointeeType->
isFunctionType() &&
2330 IsDerivedFrom(From->
getLocStart(), FromPointeeType, ToPointeeType)) {
2367 bool &IncompatibleObjC) {
2368 if (!getLangOpts().ObjC1)
2380 if (ToObjCPtr && FromObjCPtr) {
2391 if (getLangOpts().
CPlusPlus && LHS && RHS &&
2393 FromObjCPtr->getPointeeType()))
2398 ConvertedType =
AdoptQualifiers(Context, ConvertedType, FromQualifiers);
2406 IncompatibleObjC =
true;
2410 ConvertedType =
AdoptQualifiers(Context, ConvertedType, FromQualifiers);
2422 if (FromObjCPtr && FromObjCPtr->isObjCBuiltinType()) {
2450 isObjCPointerConversion(FromPointeeType, ToPointeeType, ConvertedType,
2451 IncompatibleObjC)) {
2453 IncompatibleObjC =
true;
2455 ConvertedType =
AdoptQualifiers(Context, ConvertedType, FromQualifiers);
2462 isObjCPointerConversion(FromPointeeType, ToPointeeType, ConvertedType,
2463 IncompatibleObjC)) {
2466 ConvertedType =
AdoptQualifiers(Context, ConvertedType, FromQualifiers);
2478 if (FromFunctionType && ToFunctionType) {
2487 if (FromFunctionType->
getNumParams() != ToFunctionType->getNumParams() ||
2488 FromFunctionType->
isVariadic() != ToFunctionType->isVariadic() ||
2489 FromFunctionType->
getTypeQuals() != ToFunctionType->getTypeQuals())
2492 bool HasObjCConversion =
false;
2496 }
else if (isObjCPointerConversion(FromFunctionType->
getReturnType(),
2497 ToFunctionType->getReturnType(),
2498 ConvertedType, IncompatibleObjC)) {
2500 HasObjCConversion =
true;
2507 for (
unsigned ArgIdx = 0, NumArgs = FromFunctionType->
getNumParams();
2508 ArgIdx != NumArgs; ++ArgIdx) {
2510 QualType ToArgType = ToFunctionType->getParamType(ArgIdx);
2514 }
else if (isObjCPointerConversion(FromArgType, ToArgType,
2515 ConvertedType, IncompatibleObjC)) {
2517 HasObjCConversion =
true;
2524 if (HasObjCConversion) {
2528 IncompatibleObjC =
true;
2547 if (!getLangOpts().ObjCAutoRefCount ||
2589 bool IncompatibleObjC;
2591 FromPointee = ToPointee;
2592 else if (!isObjCPointerConversion(FromPointee, ToPointee, FromPointee,
2627 if (!FromFunctionType || !ToFunctionType)
2630 if (Context.
hasSameType(FromPointeeType, ToPointeeType))
2635 if (FromFunctionType->
getNumParams() != ToFunctionType->getNumParams() ||
2636 FromFunctionType->
isVariadic() != ToFunctionType->isVariadic())
2641 if (FromEInfo != ToEInfo)
2644 bool IncompatibleObjC =
false;
2646 ToFunctionType->getReturnType())) {
2650 QualType LHS = ToFunctionType->getReturnType();
2657 }
else if (isObjCPointerConversion(RHS, LHS,
2658 ConvertedType, IncompatibleObjC)) {
2659 if (IncompatibleObjC)
2668 for (
unsigned ArgIdx = 0, NumArgs = FromFunctionType->
getNumParams();
2669 ArgIdx != NumArgs; ++ArgIdx) {
2670 IncompatibleObjC =
false;
2672 QualType ToArgType = ToFunctionType->getParamType(ArgIdx);
2673 if (Context.
hasSameType(FromArgType, ToArgType)) {
2675 }
else if (isObjCPointerConversion(ToArgType, FromArgType,
2676 ConvertedType, IncompatibleObjC)) {
2677 if (IncompatibleObjC)
2686 bool CanUseToFPT, CanUseFromFPT;
2688 CanUseToFPT, CanUseFromFPT,
2692 ConvertedType = ToType;
2768 if (!FromFunction || !ToFunction) {
2773 if (FromFunction->
getNumParams() != ToFunction->getNumParams()) {
2781 if (!FunctionParamTypesAreEqual(FromFunction, ToFunction, &ArgPos)) {
2783 << ToFunction->getParamType(ArgPos)
2790 ToFunction->getReturnType())) {
2797 ToQuals = ToFunction->getTypeQuals();
2798 if (FromQuals != ToQuals) {
2806 ->isNothrow(Context) !=
2807 cast<FunctionProtoType>(ToFunction->getCanonicalTypeUnqualified())
2808 ->isNothrow(Context)) {
2827 O && (O != E); ++O, ++N) {
2829 N->getUnqualifiedType())) {
2847 bool IgnoreBaseAccess,
2850 bool IsCStyleOrFunctionalCast = IgnoreBaseAccess;
2854 if (Diagnose && !IsCStyleOrFunctionalCast && !FromType->
isAnyPointerType() &&
2858 DiagRuntimeBehavior(From->
getExprLoc(), From,
2859 PDiag(diag::warn_impcast_bool_to_null_pointer)
2861 else if (!isUnevaluatedContext())
2870 if (FromPointeeType->
isRecordType() && ToPointeeType->isRecordType() &&
2874 unsigned InaccessibleID = 0;
2875 unsigned AmbigiousID = 0;
2877 InaccessibleID = diag::err_upcast_to_inaccessible_base;
2878 AmbigiousID = diag::err_ambiguous_derived_to_base_conv;
2880 if (CheckDerivedToBaseConversion(
2881 FromPointeeType, ToPointeeType, InaccessibleID, AmbigiousID,
2883 &BasePath, IgnoreBaseAccess))
2887 Kind = CK_DerivedToBase;
2890 if (Diagnose && !IsCStyleOrFunctionalCast &&
2891 FromPointeeType->
isFunctionType() && ToPointeeType->isVoidType()) {
2892 assert(getLangOpts().MSVCCompat &&
2893 "this should only be possible with MSVCCompat!");
2905 if (FromPtrType->isObjCBuiltinType() || ToPtrType->isObjCBuiltinType())
2908 Kind = CK_BlockPointerToObjCPointerCast;
2910 Kind = CK_CPointerToObjCPointerCast;
2914 Kind = CK_AnyPointerToBlockPointerCast;
2920 Kind = CK_NullToPointer;
2932 bool InOverloadResolution,
2942 ConvertedType = ToType;
2957 IsDerivedFrom(From->
getLocStart(), ToClass, FromClass)) {
2975 bool IgnoreBaseAccess) {
2982 "Expr must be null pointer constant!");
2983 Kind = CK_NullToMemberPointer;
2988 assert(ToPtrType &&
"No member pointer cast has a target type " 2989 "that is not a member pointer.");
2995 assert(FromClass->
isRecordType() &&
"Pointer into non-class.");
2996 assert(ToClass->isRecordType() &&
"Pointer into non-class.");
3000 bool DerivationOkay =
3001 IsDerivedFrom(From->
getLocStart(), ToClass, FromClass, Paths);
3002 assert(DerivationOkay &&
3003 "Should not have been called if derivation isn't OK.");
3004 (void)DerivationOkay;
3007 getUnqualifiedType())) {
3008 std::string PathDisplayStr = getAmbiguousPathsDisplayString(Paths);
3010 << 0 << FromClass << ToClass << PathDisplayStr << From->
getSourceRange();
3014 if (
const RecordType *VBase = Paths.getDetectedVirtual()) {
3016 << FromClass << ToClass <<
QualType(VBase, 0)
3021 if (!IgnoreBaseAccess)
3022 CheckBaseClassAccess(From->
getExprLoc(), FromClass, ToClass,
3024 diag::err_downcast_from_inaccessible_base);
3028 Kind = CK_BaseToDerivedMemberPointer;
3053 bool CStyle,
bool &ObjCLifetimeConversion) {
3056 ObjCLifetimeConversion =
false;
3066 bool PreviousToQualsIncludeConst =
true;
3067 bool UnwrappedAnyPointer =
false;
3075 UnwrappedAnyPointer =
true;
3087 UnwrappedAnyPointer) {
3090 ObjCLifetimeConversion =
true;
3115 && !PreviousToQualsIncludeConst)
3120 PreviousToQualsIncludeConst
3121 = PreviousToQualsIncludeConst && ToQuals.
hasConst();
3138 bool InOverloadResolution,
3147 InOverloadResolution, InnerSCS,
3151 SCS.
Second = InnerSCS.Second;
3152 SCS.
setToType(1, InnerSCS.getToType(1));
3153 SCS.
Third = InnerSCS.Third;
3155 = InnerSCS.QualificationIncludesObjCLifetime;
3156 SCS.
setToType(2, InnerSCS.getToType(2));
3178 bool AllowExplicit) {
3185 bool Usable = !Info.Constructor->isInvalidDecl() &&
3187 (AllowExplicit || !Info.Constructor->isExplicit());
3192 S.
Context, Info.Constructor, ToType);
3193 if (Info.ConstructorTmpl)
3196 CandidateSet, SuppressUserConversions);
3199 CandidateSet, SuppressUserConversions);
3203 bool HadMultipleCandidates = (CandidateSet.
size() > 1);
3206 switch (
auto Result =
3231 llvm_unreachable(
"Invalid OverloadResult!");
3253 bool AllowObjCConversionOnExplicit) {
3254 assert(AllowExplicit || !AllowObjCConversionOnExplicit);
3258 bool ConstructorsOnly =
false;
3274 ConstructorsOnly =
true;
3279 = dyn_cast<CXXRecordDecl>(ToRecordType->getDecl())) {
3281 Expr **Args = &From;
3282 unsigned NumArgs = 1;
3283 bool ListInitializing =
false;
3284 if (
InitListExpr *InitList = dyn_cast<InitListExpr>(From)) {
3287 S, From, ToType, ToRecordDecl, User, CandidateSet, AllowExplicit);
3296 Args = InitList->getInits();
3297 NumArgs = InitList->getNumInits();
3298 ListInitializing =
true;
3306 bool Usable = !Info.Constructor->isInvalidDecl();
3307 if (ListInitializing)
3308 Usable = Usable && (AllowExplicit || !Info.Constructor->isExplicit());
3311 Info.Constructor->isConvertingConstructor(AllowExplicit);
3313 bool SuppressUserConversions = !ConstructorsOnly;
3314 if (SuppressUserConversions && ListInitializing) {
3315 SuppressUserConversions =
false;
3320 S.
Context, Info.Constructor, ToType);
3323 if (Info.ConstructorTmpl)
3325 Info.ConstructorTmpl, Info.FoundDecl,
3326 nullptr, llvm::makeArrayRef(Args, NumArgs),
3327 CandidateSet, SuppressUserConversions);
3332 llvm::makeArrayRef(Args, NumArgs),
3333 CandidateSet, SuppressUserConversions);
3340 if (ConstructorsOnly || isa<InitListExpr>(From)) {
3346 = dyn_cast<CXXRecordDecl>(FromRecordType->getDecl())) {
3348 const auto &Conversions = FromRecordDecl->getVisibleConversionFunctions();
3349 for (
auto I = Conversions.
begin(), E = Conversions.
end(); I != E; ++I) {
3353 if (isa<UsingShadowDecl>(D))
3354 D = cast<UsingShadowDecl>(D)->getTargetDecl();
3358 if ((ConvTemplate = dyn_cast<FunctionTemplateDecl>(D)))
3361 Conv = cast<CXXConversionDecl>(D);
3363 if (AllowExplicit || !Conv->isExplicit()) {
3366 ActingContext, From, ToType,
3368 AllowObjCConversionOnExplicit);
3371 From, ToType, CandidateSet,
3372 AllowObjCConversionOnExplicit);
3378 bool HadMultipleCandidates = (CandidateSet.
size() > 1);
3387 = dyn_cast<CXXConstructorDecl>(Best->Function)) {
3395 if (isa<InitListExpr>(From)) {
3399 if (Best->Conversions[0].isEllipsis())
3402 User.
Before = Best->Conversions[0].Standard;
3415 = dyn_cast<CXXConversionDecl>(Best->Function)) {
3422 User.
Before = Best->Conversions[0].Standard;
3437 User.
After = Best->FinalConversion;
3440 llvm_unreachable(
"Not a constructor or conversion function?");
3449 llvm_unreachable(
"Invalid OverloadResult!");
3459 CandidateSet,
false,
false);
3464 if (!RequireCompleteType(From->
getLocStart(), ToType,
3465 diag::err_typecheck_nonviable_condition_incomplete,
3501 if (Block1 != Block2)
3588 if (!ICS1.
isBad()) {
3731 else if (Rank2 < Rank1)
3752 bool SCS1ConvertsToVoid
3754 bool SCS2ConvertsToVoid
3756 if (SCS1ConvertsToVoid != SCS2ConvertsToVoid) {
3761 }
else if (!SCS1ConvertsToVoid && !SCS2ConvertsToVoid) {
3767 }
else if (SCS1ConvertsToVoid && SCS2ConvertsToVoid &&
3796 if (FromObjCPtr1 && FromObjCPtr2) {
3801 if (AssignLeft != AssignRight) {
3834 if (UnqualT1 == UnqualT2) {
3846 if (isa<ArrayType>(T1) && T1Quals)
3848 if (isa<ArrayType>(T2) && T2Quals)
3907 if (UnqualT1 == UnqualT2)
3912 if (isa<ArrayType>(T1) && T1Quals)
3914 if (isa<ArrayType>(T2) && T2Quals)
4037 if (FromPointee1 == FromPointee2 && ToPointee1 != ToPointee2) {
4045 if (FromPointee1 != FromPointee2 && ToPointee1 == ToPointee2) {
4062 if (FromPtr1 && FromPtr2 && ToPtr1 && ToPtr2) {
4069 bool FromAssignRight
4078 if (ToPtr1->isObjCIdType() &&
4079 (ToPtr2->isObjCQualifiedIdType() || ToPtr2->getInterfaceDecl()))
4081 if (ToPtr2->isObjCIdType() &&
4082 (ToPtr1->isObjCQualifiedIdType() || ToPtr1->getInterfaceDecl()))
4087 if (ToPtr1->isObjCQualifiedIdType() && ToPtr2->getInterfaceDecl())
4089 if (ToPtr2->isObjCQualifiedIdType() && ToPtr1->getInterfaceDecl())
4094 if (ToPtr1->isObjCClassType() &&
4095 (ToPtr2->isObjCQualifiedClassType() || ToPtr2->getInterfaceDecl()))
4097 if (ToPtr2->isObjCClassType() &&
4098 (ToPtr1->isObjCQualifiedClassType() || ToPtr1->getInterfaceDecl()))
4103 if (ToPtr1->isObjCQualifiedClassType() && ToPtr2->getInterfaceDecl())
4105 if (ToPtr2->isObjCQualifiedClassType() && ToPtr1->getInterfaceDecl())
4111 (ToAssignLeft != ToAssignRight)) {
4122 }
else if (IsSecondSame)
4131 (FromAssignLeft != FromAssignRight))
4149 const Type *FromPointeeType1 = FromMemPointer1->
getClass();
4150 const Type *ToPointeeType1 = ToMemPointer1->getClass();
4151 const Type *FromPointeeType2 = FromMemPointer2->getClass();
4152 const Type *ToPointeeType2 = ToMemPointer2->getClass();
4158 if (FromPointee1 == FromPointee2 && ToPointee1 != ToPointee2) {
4165 if (ToPointee1 == ToPointee2 && FromPointee1 != FromPointee2) {
4206 return !Record->isInvalidDecl();
4221 bool &DerivedToBase,
4222 bool &ObjCConversion,
4223 bool &ObjCLifetimeConversion) {
4225 "T1 must be the pointee type of the reference type");
4226 assert(!OrigT2->
isReferenceType() &&
"T2 cannot be a reference type");
4238 DerivedToBase =
false;
4239 ObjCConversion =
false;
4240 ObjCLifetimeConversion =
false;
4242 if (UnqualT1 == UnqualT2) {
4244 }
else if (isCompleteType(Loc, OrigT2) &&
4246 IsDerivedFrom(Loc, UnqualT2, UnqualT1))
4247 DerivedToBase =
true;
4251 ObjCConversion =
true;
4253 IsFunctionConversion(UnqualT2, UnqualT1, ConvertedT2))
4260 return Ref_Compatible;
4262 return Ref_Incompatible;
4269 if (isa<ArrayType>(T1) && T1Quals)
4271 if (isa<ArrayType>(T2) && T2Quals)
4289 ObjCLifetimeConversion =
true;
4300 return Ref_Compatible;
4311 bool AllowExplicit) {
4312 assert(T2->
isRecordType() &&
"Can only find conversions of record types.");
4318 const auto &Conversions = T2RecordDecl->getVisibleConversionFunctions();
4319 for (
auto I = Conversions.begin(), E = Conversions.end(); I != E; ++I) {
4322 if (isa<UsingShadowDecl>(D))
4323 D = cast<UsingShadowDecl>(D)->getTargetDecl();
4331 Conv = cast<CXXConversionDecl>(D);
4335 if (!AllowExplicit && Conv->isExplicit())
4339 bool DerivedToBase =
false;
4340 bool ObjCConversion =
false;
4341 bool ObjCLifetimeConversion =
false;
4352 if (!ConvTemplate &&
4355 Conv->getConversionType().getNonReferenceType()
4356 .getUnqualifiedType(),
4358 DerivedToBase, ObjCConversion, ObjCLifetimeConversion) ==
4376 Init, DeclType, CandidateSet,
4380 DeclType, CandidateSet,
4384 bool HadMultipleCandidates = (CandidateSet.size() > 1);
4387 switch (CandidateSet.BestViableFunction(S, DeclLoc, Best)) {
4399 if (!Best->FinalConversion.DirectBinding)
4411 "Expected a direct reference binding!");
4417 Cand != CandidateSet.end(); ++Cand)
4429 llvm_unreachable(
"Invalid OverloadResult!");
4437 bool SuppressUserConversions,
4438 bool AllowExplicit) {
4439 assert(DeclType->
isReferenceType() &&
"Reference init needs a reference");
4460 bool DerivedToBase =
false;
4461 bool ObjCConversion =
false;
4462 bool ObjCLifetimeConversion =
false;
4466 ObjCConversion, ObjCLifetimeConversion);
4494 ICS.Standard.setToType(0, T2);
4495 ICS.Standard.setToType(1, T1);
4496 ICS.Standard.setToType(2, T1);
4497 ICS.Standard.ReferenceBinding =
true;
4498 ICS.Standard.DirectBinding =
true;
4499 ICS.Standard.IsLvalueReference = !isRValRef;
4501 ICS.Standard.BindsToRvalue =
false;
4502 ICS.Standard.BindsImplicitObjectArgumentWithoutRefQualifier =
false;
4503 ICS.Standard.ObjCLifetimeConversionBinding = ObjCLifetimeConversion;
4504 ICS.Standard.CopyConstructor =
nullptr;
4505 ICS.Standard.DeprecatedStringLiteralToCharPtr =
false;
4552 ICS.Standard.setToType(0, T2);
4553 ICS.Standard.setToType(1, T1);
4554 ICS.Standard.setToType(2, T1);
4555 ICS.Standard.ReferenceBinding =
true;
4561 ICS.Standard.DirectBinding =
4564 ICS.Standard.IsLvalueReference = !isRValRef;
4566 ICS.Standard.BindsToRvalue = InitCategory.
isRValue();
4567 ICS.Standard.BindsImplicitObjectArgumentWithoutRefQualifier =
false;
4568 ICS.Standard.ObjCLifetimeConversionBinding = ObjCLifetimeConversion;
4569 ICS.Standard.CopyConstructor =
nullptr;
4570 ICS.Standard.DeprecatedStringLiteralToCharPtr =
false;
4593 if (ICS.isUserDefined() && isRValRef &&
4665 if (ICS.isStandard()) {
4666 ICS.Standard.ReferenceBinding =
true;
4667 ICS.Standard.IsLvalueReference = !isRValRef;
4668 ICS.Standard.BindsToFunctionLvalue =
false;
4669 ICS.Standard.BindsToRvalue =
true;
4670 ICS.Standard.BindsImplicitObjectArgumentWithoutRefQualifier =
false;
4671 ICS.Standard.ObjCLifetimeConversionBinding =
false;
4672 }
else if (ICS.isUserDefined()) {
4674 ICS.UserDefined.ConversionFunction->getReturnType()
4691 ICS.UserDefined.After.ReferenceBinding =
true;
4692 ICS.UserDefined.After.IsLvalueReference = !isRValRef;
4693 ICS.UserDefined.After.BindsToFunctionLvalue =
false;
4694 ICS.UserDefined.After.BindsToRvalue = !LValRefType;
4695 ICS.UserDefined.After.BindsImplicitObjectArgumentWithoutRefQualifier =
false;
4696 ICS.UserDefined.After.ObjCLifetimeConversionBinding =
false;
4704 bool SuppressUserConversions,
4705 bool InOverloadResolution,
4706 bool AllowObjCWritebackConversion,
4707 bool AllowExplicit =
false);
4713 bool SuppressUserConversions,
4714 bool InOverloadResolution,
4715 bool AllowObjCWritebackConversion) {
4744 SuppressUserConversions,
4745 InOverloadResolution,
4746 AllowObjCWritebackConversion);
4779 bool toStdInitializerList =
false;
4786 for (
unsigned i = 0, e = From->
getNumInits(); i < e; ++i) {
4790 InOverloadResolution,
4791 AllowObjCWritebackConversion);
4798 if (Result.
isBad() ||
4829 InOverloadResolution,
false,
4830 AllowObjCWritebackConversion,
4887 Init, ToType,
false, Found))
4892 bool dummy1 =
false;
4893 bool dummy2 =
false;
4894 bool dummy3 =
false;
4901 SuppressUserConversions,
4909 InOverloadResolution,
4910 AllowObjCWritebackConversion);
4911 if (Result.isFailure())
4913 assert(!Result.isEllipsis() &&
4914 "Sub-initialization cannot result in ellipsis conversion.");
4920 Result.UserDefined.After;
4941 if (NumInits == 1 && !isa<InitListExpr>(From->
getInit(0)))
4943 SuppressUserConversions,
4944 InOverloadResolution,
4945 AllowObjCWritebackConversion);
4948 else if (NumInits == 0) {
4971 bool SuppressUserConversions,
4972 bool InOverloadResolution,
4973 bool AllowObjCWritebackConversion,
4974 bool AllowExplicit) {
4975 if (
InitListExpr *FromInitList = dyn_cast<InitListExpr>(From))
4977 InOverloadResolution,AllowObjCWritebackConversion);
4982 SuppressUserConversions,
4986 SuppressUserConversions,
4988 InOverloadResolution,
4990 AllowObjCWritebackConversion,
5003 return !ICS.
isBad();
5017 unsigned Quals = isa<CXXDestructorDecl>(Method) ?
5031 assert(FromClassification.
isLValue());
5057 != FromTypeCanon.getLocalCVRQualifiers() &&
5060 FromType, ImplicitParamType);
5074 FromType, ImplicitParamType);
5094 if (!FromClassification.
isRValue()) {
5137 FromRecordType = From->
getType();
5138 DestType = ImplicitParamRecordType;
5139 FromClassification = From->
Classify(Context);
5155 diag::err_member_function_call_bad_cvr)
5156 << Method->getDeclName() << FromRecordType << (CVR - 1)
5158 Diag(Method->getLocation(), diag::note_previous_decl)
5159 << Method->getDeclName();
5167 bool IsRValueQualified =
5170 << Method->getDeclName() << FromClassification.
isRValue()
5171 << IsRValueQualified;
5172 Diag(Method->getLocation(), diag::note_previous_decl)
5173 << Method->getDeclName();
5183 diag::err_member_function_call_bad_type)
5184 << ImplicitParamRecordType << FromRecordType << From->
getSourceRange();
5189 PerformObjectMemberConversion(From, Qualifier, FoundDecl, Method);
5192 From = FromRes.
get();
5196 From = ImpCastExprToType(From, DestType, CK_NoOp,
5222 return PerformImplicitConversion(From, Context.
BoolTy, ICS, AA_Converting);
5224 if (!DiagnoseMultipleUserDefinedConversion(From, Context.
BoolTy))
5226 diag::err_typecheck_bool_condition)
5285 llvm_unreachable(
"found a first conversion kind in Second");
5288 llvm_unreachable(
"found a third conversion kind in Second");
5294 llvm_unreachable(
"unknown conversion kind");
5305 "converted constant expression outside C++11");
5341 diag::err_typecheck_converted_constant_expression)
5346 llvm_unreachable(
"ellipsis conversion in converted constant expression");
5352 diag::err_typecheck_converted_constant_expression_disallowed)
5358 diag::err_typecheck_converted_constant_expression_indirect)
5371 PreNarrowingType)) {
5389 << CCE << 0 << From->
getType() <<
T;
5393 if (Result.
get()->isValueDependent()) {
5404 ? !Result.
get()->EvaluateAsLValue(Eval, S.
Context)
5405 : !Result.
get()->EvaluateAsRValue(Eval, S.
Context)) ||
5406 (RequireInt && !Eval.
Val.
isInt())) {
5413 if (Notes.empty()) {
5420 if (Notes.size() == 1 &&
5421 Notes[0].second.getDiagID() == diag::note_invalid_subexpr_in_const_expr)
5422 S.
Diag(Notes[0].first, diag::err_expr_not_cce) << CCE;
5426 for (
unsigned I = 0; I < Notes.size(); ++I)
5427 S.
Diag(Notes[I].first, Notes[I].second);
5438 llvm::APSInt &
Value,
5444 if (!R.isInvalid() && !R.get()->isValueDependent())
5507 return PerformImplicitConversion(From, Ty, ICS, AA_Converting);
5527 for (
unsigned I = 0, N = ViableConversions.
size(); I != N; ++I) {
5529 cast<CXXConversionDecl>(ViableConversions[I]->getUnderlyingDecl());
5541 if (ExplicitConversions.
size() == 1 && !Converter.
Suppress) {
5549 std::string TypeStr;
5554 "static_cast<" + TypeStr +
">(")
5566 HadMultipleCandidates);
5571 CK_UserDefinedConversion, Result.
get(),
5572 nullptr, Result.
get()->getValueKind());
5595 HadMultipleCandidates);
5600 CK_UserDefinedConversion, Result.
get(),
5601 nullptr, Result.
get()->getValueKind());
5619 for (
unsigned I = 0, N = ViableConversions.
size(); I != N; ++I) {
5623 if (isa<UsingShadowDecl>(D))
5624 D = cast<UsingShadowDecl>(D)->getTargetDecl();
5628 if ((ConvTemplate = dyn_cast<FunctionTemplateDecl>(D)))
5631 Conv = cast<CXXConversionDecl>(D);
5635 ConvTemplate, FoundDecl, ActingContext, From, ToType, CandidateSet,
5639 ToType, CandidateSet,
5670 ExprResult result = CheckPlaceholderExpr(From);
5673 From = result.
get();
5678 if (Converter.
match(T))
5679 return DefaultLvalueConversion(From);
5686 if (!RecordTy || !getLangOpts().CPlusPlus) {
5698 : Converter(Converter), From(From) {}
5703 } IncompleteDiagnoser(Converter, From);
5705 if (Converter.
Suppress ? !isCompleteType(Loc, T)
5706 : RequireCompleteType(Loc, T, IncompleteDiagnoser))
5713 const auto &Conversions =
5714 cast<CXXRecordDecl>(RecordTy->
getDecl())->getVisibleConversionFunctions();
5716 bool HadMultipleCandidates =
5717 (
std::distance(Conversions.begin(), Conversions.end()) > 1);
5721 bool HasUniqueTargetType =
true;
5724 for (
auto I = Conversions.begin(), E = Conversions.end(); I != E; ++I) {
5729 if (getLangOpts().CPlusPlus14)
5734 Conversion = cast<CXXConversionDecl>(D);
5736 assert((!ConvTemplate || getLangOpts().
CPlusPlus14) &&
5737 "Conversion operator templates are considered potentially " 5741 if (Converter.
match(CurToType) || ConvTemplate) {
5747 ExplicitConversions.
addDecl(I.getDecl(), I.getAccess());
5749 if (!ConvTemplate && getLangOpts().CPlusPlus14) {
5752 else if (HasUniqueTargetType &&
5754 HasUniqueTargetType =
false;
5756 ViableConversions.
addDecl(I.getDecl(), I.getAccess());
5761 if (getLangOpts().CPlusPlus14) {
5774 HadMultipleCandidates,
5775 ExplicitConversions))
5781 if (!HasUniqueTargetType)
5800 HadMultipleCandidates, Found))
5809 HadMultipleCandidates,
5810 ExplicitConversions))
5818 switch (ViableConversions.
size()) {
5821 HadMultipleCandidates,
5822 ExplicitConversions))
5832 HadMultipleCandidates, Found))
5897 bool SuppressUserConversions,
5898 bool PartialOverloading,
5903 assert(Proto &&
"Functions without a prototype cannot be overloaded");
5905 "Use AddTemplateOverloadCandidate for function templates");
5907 if (
CXXMethodDecl *Method = dyn_cast<CXXMethodDecl>(Function)) {
5908 if (!isa<CXXConstructorDecl>(Method)) {
5916 AddMethodCandidate(Method, FoundDecl, Method->getParent(),
QualType(),
5918 CandidateSet, SuppressUserConversions,
5919 PartialOverloading, EarlyConversions);
5954 CandidateSet.
addCandidate(Args.size(), EarlyConversions);
5969 IsDerivedFrom(Args[0]->getLocStart(), Args[0]->getType(),
5971 Candidate.
Viable =
false;
5984 if (Shadow && Args.size() == 1 && Constructor->
getNumParams() >= 1 &&
5992 Candidate.
Viable =
false;
6004 if (TooManyArguments(NumParams, Args.size(), PartialOverloading) &&
6006 Candidate.
Viable =
false;
6017 if (Args.size() < MinRequiredArgs && !PartialOverloading) {
6019 Candidate.
Viable =
false;
6025 if (getLangOpts().CUDA)
6026 if (
const FunctionDecl *Caller = dyn_cast<FunctionDecl>(CurContext))
6031 if (!Caller->isImplicit() && !IsAllowedCUDACall(Caller, Function)) {
6032 Candidate.
Viable =
false;
6039 for (
unsigned ArgIdx = 0; ArgIdx < Args.size(); ++ArgIdx) {
6040 if (Candidate.
Conversions[ArgIdx].isInitialized()) {
6043 }
else if (ArgIdx < NumParams) {
6051 SuppressUserConversions,
6054 getLangOpts().ObjCAutoRefCount,
6057 Candidate.
Viable =
false;
6069 if (EnableIfAttr *FailedAttr = CheckEnableIf(Function, Args)) {
6070 Candidate.
Viable =
false;
6076 if (LangOpts.OpenCL && isOpenCLDisabledDecl(Function)) {
6077 Candidate.
Viable =
false;
6086 if (Methods.size() <= 1)
6089 for (
unsigned b = 0, e = Methods.size(); b < e; b++) {
6097 if (Args.size() < NumNamedArgs)
6100 for (
unsigned i = 0; i < NumNamedArgs; i++) {
6102 if (Args[i]->isTypeDependent()) {
6108 Expr *argExpr = Args[i];
6109 assert(argExpr &&
"SelectBestMethod(): missing expression");
6114 !param->
hasAttr<CFConsumedAttr>())
6115 argExpr = stripARCUnbridgedCast(argExpr);
6128 getLangOpts().ObjCAutoRefCount,
6132 if (ConversionState.
isBad() ||
6142 for (
unsigned i = NumNamedArgs, e = Args.size(); i < e; ++i) {
6143 if (Args[i]->isTypeDependent()) {
6147 ExprResult Arg = DefaultVariadicArgumentPromotion(Args[i], VariadicMethod,
6156 if (Args.size() != NumNamedArgs)
6158 else if (Match && NumNamedArgs == 0 && Methods.size() > 1) {
6161 for (
unsigned b = 0, e = Methods.size(); b < e; b++) {
6162 QualType ReturnT = Methods[b]->getReturnType();
6184 const auto &FuncAttrs = Function->
getAttrs();
6186 if (
auto *EnableIf = dyn_cast<EnableIfAttr>(
Attr))
6187 Result.push_back(EnableIf);
6189 std::reverse(Result.begin(), Result.end());
6196 bool MissingImplicitThis,
Expr *&ConvertedThis,
6200 assert(!isa<CXXConstructorDecl>(Method) &&
6201 "Shouldn't have `this` for ctors!");
6202 assert(!Method->
isStatic() &&
"Shouldn't have `this` for static methods!");
6204 ThisArg,
nullptr, Method, Method);
6207 ConvertedThis = R.get();
6209 if (
auto *MD = dyn_cast<CXXMethodDecl>(Function)) {
6211 assert((MissingImplicitThis || MD->isStatic() ||
6212 isa<CXXConstructorDecl>(MD)) &&
6213 "Expected `this` for non-ctor instance methods");
6215 ConvertedThis =
nullptr;
6223 for (
unsigned I = 0; I != ArgSizeNoVarargs; ++I) {
6232 ConvertedArgs.push_back(R.
get());
6240 for (
unsigned i = Args.size(), e = Function->
getNumParams(); i != e; ++i) {
6250 ConvertedArgs.push_back(R.
get());
6260 bool MissingImplicitThis) {
6263 if (EnableIfAttrs.empty())
6269 Expr *DiscardedThis;
6271 *
this, Function,
nullptr, Args, Trap,
6272 true, DiscardedThis, ConvertedArgs))
6273 return EnableIfAttrs[0];
6275 for (
auto *EIA : EnableIfAttrs) {
6279 if (!EIA->getCond()->EvaluateWithSubstitution(
6280 Result, Context, Function, llvm::makeArrayRef(ConvertedArgs)))
6283 if (!Result.
isInt() || !Result.
getInt().getBoolValue())
6289 template <
typename CheckFn>
6292 CheckFn &&IsSuccessful) {
6295 if (ArgDependent == DIA->getArgDependent())
6296 Attrs.push_back(DIA);
6303 auto WarningBegin = std::stable_partition(
6304 Attrs.begin(), Attrs.end(),
6305 [](
const DiagnoseIfAttr *DIA) {
return DIA->isError(); });
6309 auto ErrAttr = llvm::find_if(llvm::make_range(Attrs.begin(), WarningBegin),
6311 if (ErrAttr != WarningBegin) {
6312 const DiagnoseIfAttr *DIA = *ErrAttr;
6313 S.
Diag(Loc, diag::err_diagnose_if_succeeded) << DIA->getMessage();
6314 S.
Diag(DIA->getLocation(), diag::note_from_diagnose_if)
6315 << DIA->getParent() << DIA->getCond()->getSourceRange();
6319 for (
const auto *DIA : llvm::make_range(WarningBegin, Attrs.end()))
6320 if (IsSuccessful(DIA)) {
6321 S.
Diag(Loc, diag::warn_diagnose_if_succeeded) << DIA->getMessage();
6322 S.
Diag(DIA->getLocation(), diag::note_from_diagnose_if)
6323 << DIA->getParent() << DIA->getCond()->getSourceRange();
6330 const Expr *ThisArg,
6334 *
this, Function,
true, Loc,
6335 [&](
const DiagnoseIfAttr *DIA) {
6340 if (!DIA->getCond()->EvaluateWithSubstitution(
6341 Result, Context, cast<FunctionDecl>(DIA->getParent()), Args, ThisArg))
6343 return Result.
isInt() && Result.
getInt().getBoolValue();
6350 *
this, ND,
false, Loc,
6351 [&](
const DiagnoseIfAttr *DIA) {
6353 return DIA->getCond()->EvaluateAsBooleanCondition(Result, Context) &&
6364 bool SuppressUserConversions,
6365 bool PartialOverloading,
6366 bool FirstArgumentIsBase) {
6371 if (isa<CXXMethodDecl>(FD) && !cast<CXXMethodDecl>(FD)->isStatic()) {
6374 if (Args.size() > 0) {
6375 if (
Expr *E = Args[0]) {
6377 ObjectType = E->getType();
6378 ObjectClassification = E->Classify(Context);
6380 FunctionArgs = Args.slice(1);
6382 AddMethodCandidate(cast<CXXMethodDecl>(FD), F.getPair(),
6383 cast<CXXMethodDecl>(FD)->getParent(), ObjectType,
6384 ObjectClassification, FunctionArgs, CandidateSet,
6385 SuppressUserConversions, PartialOverloading);
6389 if (Args.size() > 0 && (!Args[0] || (FirstArgumentIsBase && isa<CXXMethodDecl>(FD) &&
6390 !isa<CXXConstructorDecl>(FD)))) {
6391 assert(cast<CXXMethodDecl>(FD)->isStatic());
6392 FunctionArgs = Args.slice(1);
6394 AddOverloadCandidate(FD, F.getPair(), FunctionArgs, CandidateSet,
6395 SuppressUserConversions, PartialOverloading);
6403 if (
Expr *E = Args[0]) {
6405 ObjectType = E->getType();
6406 ObjectClassification = E->Classify(Context);
6408 AddMethodTemplateCandidate(
6409 FunTmpl, F.getPair(),
6411 ExplicitTemplateArgs, ObjectType, ObjectClassification,
6412 Args.slice(1), CandidateSet, SuppressUserConversions,
6413 PartialOverloading);
6415 AddTemplateOverloadCandidate(FunTmpl, F.getPair(),
6416 ExplicitTemplateArgs, Args,
6417 CandidateSet, SuppressUserConversions,
6418 PartialOverloading);
6431 bool SuppressUserConversions) {
6435 if (isa<UsingShadowDecl>(Decl))
6436 Decl = cast<UsingShadowDecl>(Decl)->getTargetDecl();
6439 assert(isa<CXXMethodDecl>(TD->getTemplatedDecl()) &&
6440 "Expected a member function template");
6441 AddMethodTemplateCandidate(TD, FoundDecl, ActingContext,
6442 nullptr, ObjectType,
6443 ObjectClassification, Args, CandidateSet,
6444 SuppressUserConversions);
6446 AddMethodCandidate(cast<CXXMethodDecl>(Decl), FoundDecl, ActingContext,
6447 ObjectType, ObjectClassification, Args, CandidateSet,
6448 SuppressUserConversions);
6465 bool SuppressUserConversions,
6466 bool PartialOverloading,
6470 assert(Proto &&
"Methods without a prototype cannot be overloaded");
6471 assert(!isa<CXXConstructorDecl>(Method) &&
6472 "Use AddOverloadCandidate for constructors");
6490 CandidateSet.
addCandidate(Args.size() + 1, EarlyConversions);
6502 if (TooManyArguments(NumParams, Args.size(), PartialOverloading) &&
6504 Candidate.
Viable =
false;
6515 if (Args.size() < MinRequiredArgs && !PartialOverloading) {
6517 Candidate.
Viable =
false;
6531 *
this, CandidateSet.
getLocation(), ObjectType, ObjectClassification,
6532 Method, ActingContext);
6534 Candidate.
Viable =
false;
6541 if (getLangOpts().CUDA)
6542 if (
const FunctionDecl *Caller = dyn_cast<FunctionDecl>(CurContext))
6543 if (!IsAllowedCUDACall(Caller, Method)) {
6544 Candidate.Viable =
false;
6551 for (
unsigned ArgIdx = 0; ArgIdx < Args.size(); ++ArgIdx) {
6552 if (Candidate.Conversions[ArgIdx + 1].isInitialized()) {
6555 }
else if (ArgIdx < NumParams) {
6560 QualType ParamType = Proto->getParamType(ArgIdx);
6561 Candidate.Conversions[ArgIdx + 1]
6563 SuppressUserConversions,
6566 getLangOpts().ObjCAutoRefCount);
6567 if (Candidate.Conversions[ArgIdx + 1].isBad()) {
6568 Candidate.Viable =
false;
6576 Candidate.Conversions[ArgIdx + 1].setEllipsis();
6580 if (EnableIfAttr *FailedAttr = CheckEnableIf(Method, Args,
true)) {
6581 Candidate.Viable =
false;
6583 Candidate.DeductionFailure.Data = FailedAttr;
6600 bool SuppressUserConversions,
6601 bool PartialOverloading) {
6618 MethodTmpl, ExplicitTemplateArgs, Args, Specialization, Info,
6620 return CheckNonDependentConversions(
6621 MethodTmpl, ParamTypes, Args, CandidateSet, Conversions,
6622 SuppressUserConversions, ActingContext, ObjectType,
6623 ObjectClassification);
6626 CandidateSet.
addCandidate(Conversions.size(), Conversions);
6629 Candidate.
Viable =
false;
6632 cast<CXXMethodDecl>(Candidate.
Function)->isStatic() ||
6635 if (Result == TDK_NonDependentConversionFailure)
6647 assert(Specialization &&
"Missing member function template specialization?");
6648 assert(isa<CXXMethodDecl>(Specialization) &&
6649 "Specialization is not a member function?");
6650 AddMethodCandidate(cast<CXXMethodDecl>(Specialization), FoundDecl,
6651 ActingContext, ObjectType, ObjectClassification, Args,
6652 CandidateSet, SuppressUserConversions, PartialOverloading,
6665 bool SuppressUserConversions,
6666 bool PartialOverloading) {
6683 FunctionTemplate, ExplicitTemplateArgs, Args, Specialization, Info,
6685 return CheckNonDependentConversions(FunctionTemplate, ParamTypes,
6686 Args, CandidateSet, Conversions,
6687 SuppressUserConversions);
6690 CandidateSet.
addCandidate(Conversions.size(), Conversions);
6693 Candidate.
Viable =
false;
6698 isa<CXXMethodDecl>(Candidate.
Function) &&
6699 !isa<CXXConstructorDecl>(Candidate.
Function);
6701 if (Result == TDK_NonDependentConversionFailure)
6713 assert(Specialization &&
"Missing function template specialization?");
6714 AddOverloadCandidate(Specialization, FoundDecl, Args, CandidateSet,
6715 SuppressUserConversions, PartialOverloading,
6716 false, Conversions);
6731 const bool AllowExplicit =
false;
6735 bool HasThisConversion = Method && !isa<CXXConstructorDecl>(Method);
6736 unsigned ThisConversions = HasThisConversion ? 1 : 0;
6748 if (HasThisConversion && !cast<CXXMethodDecl>(FD)->isStatic() &&
6751 *
this, CandidateSet.
getLocation(), ObjectType, ObjectClassification,
6752 Method, ActingContext);
6753 if (Conversions[0].isBad())
6757 for (
unsigned I = 0, N =
std::min(ParamTypes.size(), Args.size()); I != N;
6759 QualType ParamType = ParamTypes[I];
6761 Conversions[ThisConversions + I]
6763 SuppressUserConversions,
6766 getLangOpts().ObjCAutoRefCount,
6768 if (Conversions[ThisConversions + I].isBad())
6790 bool AllowObjCPointerConversion) {
6798 bool ObjCLifetimeConversion;
6800 ObjCLifetimeConversion))
6805 if (!AllowObjCPointerConversion)
6809 bool IncompatibleObjC =
false;
6827 bool AllowObjCConversionOnExplicit,
6828 bool AllowResultConversion) {
6830 "Conversion function templates use AddTemplateConversionCandidate");
6837 if (getLangOpts().CPlusPlus14 && ConvType->isUndeducedType()) {
6838 if (DeduceReturnType(Conversion, From->
getExprLoc()))
6845 if (!AllowResultConversion &&
6854 AllowObjCConversionOnExplicit))
6884 = cast<CXXRecordDecl>(ImplicitParamType->
getAs<
RecordType>()->getDecl());
6888 From->
Classify(Context), Conversion, ConversionContext);
6891 Candidate.
Viable =
false;
6902 if (FromCanon == ToCanon ||
6903 IsDerivedFrom(CandidateSet.
getLocation(), FromCanon, ToCanon)) {
6904 Candidate.
Viable =
false;
6921 CK_FunctionToPointerDecay,
6925 if (!isCompleteType(From->
getLocStart(), ConversionType)) {
6926 Candidate.
Viable =
false;
6937 CallExpr Call(Context, &ConversionFn, None, CallResultType, VK,
6945 switch (ICS.getKind()) {
6955 Candidate.
Viable =
false;
6967 Candidate.
Viable =
false;
6974 Candidate.
Viable =
false;
6980 "Can only end up with a standard conversion sequence or failure");
6983 if (EnableIfAttr *FailedAttr = CheckEnableIf(Conversion, None)) {
6984 Candidate.
Viable =
false;
7002 bool AllowObjCConversionOnExplicit,
7003 bool AllowResultConversion) {
7005 "Only conversion function templates permitted here");
7014 Specialization, Info)) {
7018 Candidate.
Viable =
false;
7030 assert(Specialization &&
"Missing function template specialization?");
7031 AddConversionCandidate(Specialization, FoundDecl, ActingDC, From, ToType,
7032 CandidateSet, AllowObjCConversionOnExplicit,
7033 AllowResultConversion);
7068 Object->
Classify(Context), Conversion, ActingContext);
7069 if (ObjectInit.
isBad()) {
7070 Candidate.
Viable =
false;
7081 Candidate.
Conversions[0].UserDefined.EllipsisConversion =
false;
7082 Candidate.
Conversions[0].UserDefined.HadMultipleCandidates =
false;
7083 Candidate.
Conversions[0].UserDefined.ConversionFunction = Conversion;
7084 Candidate.
Conversions[0].UserDefined.FoundConversionFunction = FoundDecl;
7087 Candidate.
Conversions[0].UserDefined.After.setAsIdentityConversion();
7095 if (Args.size() > NumParams && !Proto->
isVariadic()) {
7096 Candidate.
Viable =
false;
7103 if (Args.size() < NumParams) {
7105 Candidate.
Viable =
false;
7112 for (
unsigned ArgIdx = 0, N = Args.size(); ArgIdx != N; ++ArgIdx) {
7113 if (ArgIdx < NumParams) {
7124 getLangOpts().ObjCAutoRefCount);
7126 Candidate.
Viable =
false;
7138 if (EnableIfAttr *FailedAttr = CheckEnableIf(Conversion, None)) {
7139 Candidate.
Viable =
false;
7177 if (!isCompleteType(OpLoc, T1) && !T1Rec->isBeingDefined())
7180 if (!T1Rec->getDecl()->getDefinition())
7183 LookupResult Operators(*
this, OpName, OpLoc, LookupOrdinaryName);
7184 LookupQualifiedName(Operators, T1Rec->getDecl());
7188 OperEnd = Operators.
end();
7191 AddMethodCandidate(Oper.getPair(), Args[0]->getType(),
7192 Args[0]->Classify(Context), Args.slice(1),
7193 CandidateSet,
false);
7207 bool IsAssignmentOperator,
7208 unsigned NumContextualBoolArguments) {
7225 for (
unsigned ArgIdx = 0, N = Args.size(); ArgIdx != N; ++ArgIdx) {
7238 if (ArgIdx < NumContextualBoolArguments) {
7239 assert(ParamTys[ArgIdx] == Context.
BoolTy &&
7240 "Contextual conversion to bool requires bool type");
7246 ArgIdx == 0 && IsAssignmentOperator,
7249 getLangOpts().ObjCAutoRefCount);
7252 Candidate.
Viable =
false;
7265 class BuiltinCandidateTypeSet {
7267 typedef llvm::SetVector<QualType, SmallVector<QualType, 8>,
7268 llvm::SmallPtrSet<QualType, 8>> TypeSet;
7272 TypeSet PointerTypes;
7276 TypeSet MemberPointerTypes;
7280 TypeSet EnumerationTypes;
7284 TypeSet VectorTypes;
7287 bool HasNonRecordTypes;
7291 bool HasArithmeticOrEnumeralTypes;
7295 bool HasNullPtrType;
7304 bool AddPointerWithMoreQualifiedTypeVariants(
QualType Ty,
7306 bool AddMemberPointerWithMoreQualifiedTypeVariants(
QualType Ty);
7310 typedef TypeSet::iterator iterator;
7312 BuiltinCandidateTypeSet(
Sema &SemaRef)
7313 : HasNonRecordTypes(
false),
7314 HasArithmeticOrEnumeralTypes(
false),
7315 HasNullPtrType(
false),
7319 void AddTypesConvertedFrom(
QualType Ty,
7321 bool AllowUserConversions,
7322 bool AllowExplicitConversions,
7323 const Qualifiers &VisibleTypeConversionsQuals);
7326 iterator pointer_begin() {
return PointerTypes.begin(); }
7329 iterator pointer_end() {
return PointerTypes.end(); }
7332 iterator member_pointer_begin() {
return MemberPointerTypes.begin(); }
7335 iterator member_pointer_end() {
return MemberPointerTypes.end(); }
7338 iterator enumeration_begin() {
return EnumerationTypes.begin(); }
7341 iterator enumeration_end() {
return EnumerationTypes.end(); }
7343 iterator vector_begin() {
return VectorTypes.begin(); }
7344 iterator vector_end() {
return VectorTypes.end(); }
7346 bool hasNonRecordTypes() {
return HasNonRecordTypes; }
7347 bool hasArithmeticOrEnumeralTypes() {
return HasArithmeticOrEnumeralTypes; }
7348 bool hasNullPtrType()
const {
return HasNullPtrType; }
7363 BuiltinCandidateTypeSet::AddPointerWithMoreQualifiedTypeVariants(
QualType Ty,
7367 if (!PointerTypes.insert(Ty))
7372 bool buildObjCPtr =
false;
7376 buildObjCPtr =
true;
7394 if ((CVR | BaseCVR) != CVR)
continue;
7416 PointerTypes.insert(QPointerTy);
7432 BuiltinCandidateTypeSet::AddMemberPointerWithMoreQualifiedTypeVariants(
7435 if (!MemberPointerTypes.insert(Ty))
7439 assert(PointerTy &&
"type was not a member pointer type!");
7454 if ((CVR | BaseCVR) != CVR)
continue;
7457 MemberPointerTypes.insert(
7473 BuiltinCandidateTypeSet::AddTypesConvertedFrom(
QualType Ty,
7475 bool AllowUserConversions,
7476 bool AllowExplicitConversions,
7488 Ty = SemaRef.Context.getArrayDecayedType(Ty);
7495 HasNonRecordTypes = HasNonRecordTypes || !TyRec;
7498 HasArithmeticOrEnumeralTypes =
7502 PointerTypes.insert(Ty);
7506 if (!AddPointerWithMoreQualifiedTypeVariants(Ty, VisibleQuals))
7510 if (!AddMemberPointerWithMoreQualifiedTypeVariants(Ty))
7513 HasArithmeticOrEnumeralTypes =
true;
7514 EnumerationTypes.insert(Ty);
7518 HasArithmeticOrEnumeralTypes =
true;
7519 VectorTypes.insert(Ty);
7521 HasNullPtrType =
true;
7522 }
else if (AllowUserConversions && TyRec) {
7524 if (!SemaRef.isCompleteType(Loc, Ty))
7529 if (isa<UsingShadowDecl>(D))
7530 D = cast<UsingShadowDecl>(D)->getTargetDecl();
7534 if (isa<FunctionTemplateDecl>(D))
7538 if (AllowExplicitConversions || !Conv->
isExplicit()) {
7593 if (isa<UsingShadowDecl>(D))
7594 D = cast<UsingShadowDecl>(D)->getTargetDecl();
7628 class BuiltinOperatorOverloadBuilder {
7633 bool HasArithmeticOrEnumeralCandidateType;
7637 static constexpr
int ArithmeticTypesCap = 24;
7643 unsigned FirstIntegralType,
7645 unsigned FirstPromotedIntegralType,
7646 LastPromotedIntegralType;
7647 unsigned FirstPromotedArithmeticType,
7648 LastPromotedArithmeticType;
7649 unsigned NumArithmeticTypes;
7651 void InitArithmeticTypes() {
7653 FirstPromotedArithmeticType = 0;
7661 FirstIntegralType = ArithmeticTypes.size();
7662 FirstPromotedIntegralType = ArithmeticTypes.size();
7673 LastPromotedIntegralType = ArithmeticTypes.size();
7674 LastPromotedArithmeticType = ArithmeticTypes.size();
7686 LastIntegralType = ArithmeticTypes.size();
7687 NumArithmeticTypes = ArithmeticTypes.size();
7691 assert(ArithmeticTypes.size() <= ArithmeticTypesCap &&
7692 "Enough inline storage for all arithmetic types.");
7697 void addPlusPlusMinusMinusStyleOverloads(
QualType CandidateTy,
7739 BuiltinOperatorOverloadBuilder(
7742 bool HasArithmeticOrEnumeralCandidateType,
7746 VisibleTypeConversionsQuals(VisibleTypeConversionsQuals),
7747 HasArithmeticOrEnumeralCandidateType(
7748 HasArithmeticOrEnumeralCandidateType),
7749 CandidateTypes(CandidateTypes),
7750 CandidateSet(CandidateSet) {
7752 InitArithmeticTypes();
7773 if (!HasArithmeticOrEnumeralCandidateType)
7776 for (
unsigned Arith = (Op == OO_PlusPlus? 0 : 1);
7777 Arith < NumArithmeticTypes; ++Arith) {
7778 addPlusPlusMinusMinusStyleOverloads(
7779 ArithmeticTypes[Arith],
7795 void addPlusPlusMinusMinusPointerOverloads() {
7796 for (BuiltinCandidateTypeSet::iterator
7797 Ptr = CandidateTypes[0].pointer_begin(),
7798 PtrEnd = CandidateTypes[0].pointer_end();
7799 Ptr != PtrEnd; ++Ptr) {
7801 if (!(*Ptr)->getPointeeType()->isObjectType())
7804 addPlusPlusMinusMinusStyleOverloads(*Ptr,
7805 (!(*Ptr).isVolatileQualified() &&
7807 (!(*Ptr).isRestrictQualified() &&
7822 void addUnaryStarPointerOverloads() {
7823 for (BuiltinCandidateTypeSet::iterator
7824 Ptr = CandidateTypes[0].pointer_begin(),
7825 PtrEnd = CandidateTypes[0].pointer_end();
7826 Ptr != PtrEnd; ++Ptr) {
7833 if (Proto->getTypeQuals() || Proto->getRefQualifier())
7846 void addUnaryPlusOrMinusArithmeticOverloads() {
7847 if (!HasArithmeticOrEnumeralCandidateType)
7850 for (
unsigned Arith = FirstPromotedArithmeticType;
7851 Arith < LastPromotedArithmeticType; ++Arith) {
7852 QualType ArithTy = ArithmeticTypes[Arith];
7857 for (BuiltinCandidateTypeSet::iterator
7858 Vec = CandidateTypes[0].vector_begin(),
7859 VecEnd = CandidateTypes[0].vector_end();
7860 Vec != VecEnd; ++Vec) {
7871 void addUnaryPlusPointerOverloads() {
7872 for (BuiltinCandidateTypeSet::iterator
7873 Ptr = CandidateTypes[0].pointer_begin(),
7874 PtrEnd = CandidateTypes[0].pointer_end();
7875 Ptr != PtrEnd; ++Ptr) {
7886 void addUnaryTildePromotedIntegralOverloads() {
7887 if (!HasArithmeticOrEnumeralCandidateType)
7890 for (
unsigned Int = FirstPromotedIntegralType;
7891 Int < LastPromotedIntegralType; ++Int) {
7892 QualType IntTy = ArithmeticTypes[Int];
7897 for (BuiltinCandidateTypeSet::iterator
7898 Vec = CandidateTypes[0].vector_begin(),
7899 VecEnd = CandidateTypes[0].vector_end();
7900 Vec != VecEnd; ++Vec) {
7912 void addEqualEqualOrNotEqualMemberPointerOrNullptrOverloads() {
7914 llvm::SmallPtrSet<QualType, 8> AddedTypes;
7916 for (
unsigned ArgIdx = 0, N = Args.size(); ArgIdx != N; ++ArgIdx) {
7917 for (BuiltinCandidateTypeSet::iterator
7918 MemPtr = CandidateTypes[ArgIdx].member_pointer_begin(),
7919 MemPtrEnd = CandidateTypes[ArgIdx].member_pointer_end();
7920 MemPtr != MemPtrEnd;
7926 QualType ParamTypes[2] = { *MemPtr, *MemPtr };
7930 if (CandidateTypes[ArgIdx].hasNullPtrType()) {
7932 if (AddedTypes.insert(NullPtrTy).second) {
7933 QualType ParamTypes[2] = { NullPtrTy, NullPtrTy };
7951 void addRelationalPointerOrEnumeralOverloads() {
7965 UserDefinedBinaryOperators;
7967 for (
unsigned ArgIdx = 0, N = Args.size(); ArgIdx != N; ++ArgIdx) {
7968 if (CandidateTypes[ArgIdx].enumeration_begin() !=
7969 CandidateTypes[ArgIdx].enumeration_end()) {
7971 CEnd = CandidateSet.
end();
7973 if (!C->Viable || !C->Function || C->Function->getNumParams() != 2)
7976 if (C->Function->isFunctionTemplateSpecialization())
7980 C->Function->getParamDecl(0)->getType().getUnqualifiedType();
7982 C->Function->getParamDecl(1)->getType().getUnqualifiedType();
7990 UserDefinedBinaryOperators.insert(
7998 llvm::SmallPtrSet<QualType, 8> AddedTypes;
8000 for (
unsigned ArgIdx = 0, N = Args.size(); ArgIdx != N; ++ArgIdx) {
8001 for (BuiltinCandidateTypeSet::iterator
8002 Ptr = CandidateTypes[ArgIdx].pointer_begin(),
8003 PtrEnd = CandidateTypes[ArgIdx].pointer_end();
8004 Ptr != PtrEnd; ++Ptr) {
8009 QualType ParamTypes[2] = { *Ptr, *Ptr };
8012 for (BuiltinCandidateTypeSet::iterator
8013 Enum = CandidateTypes[ArgIdx].enumeration_begin(),
8014 EnumEnd = CandidateTypes[ArgIdx].enumeration_end();
8015 Enum != EnumEnd; ++Enum) {
8020 if (!AddedTypes.insert(CanonType).second ||
8021 UserDefinedBinaryOperators.count(std::make_pair(CanonType,
8025 QualType ParamTypes[2] = { *Enum, *Enum };
8050 llvm::SmallPtrSet<QualType, 8> AddedTypes;
8052 for (
int Arg = 0; Arg < 2; ++Arg) {
8053 QualType AsymmetricParamTypes[2] = {
8057 for (BuiltinCandidateTypeSet::iterator
8058 Ptr = CandidateTypes[Arg].pointer_begin(),
8059 PtrEnd = CandidateTypes[Arg].pointer_end();
8060 Ptr != PtrEnd; ++Ptr) {
8065 AsymmetricParamTypes[Arg] = *Ptr;
8066 if (Arg == 0 || Op == OO_Plus) {
8071 if (Op == OO_Minus) {
8076 QualType ParamTypes[2] = { *Ptr, *Ptr };
8112 void addGenericBinaryArithmeticOverloads() {
8113 if (!HasArithmeticOrEnumeralCandidateType)
8116 for (
unsigned Left = FirstPromotedArithmeticType;
8117 Left < LastPromotedArithmeticType; ++Left) {
8118 for (
unsigned Right = FirstPromotedArithmeticType;
8119 Right < LastPromotedArithmeticType; ++Right) {
8120 QualType LandR[2] = { ArithmeticTypes[Left],
8121 ArithmeticTypes[Right] };
8128 for (BuiltinCandidateTypeSet::iterator
8129 Vec1 = CandidateTypes[0].vector_begin(),
8130 Vec1End = CandidateTypes[0].vector_end();
8131 Vec1 != Vec1End; ++Vec1) {
8132 for (BuiltinCandidateTypeSet::iterator
8133 Vec2 = CandidateTypes[1].vector_begin(),
8134 Vec2End = CandidateTypes[1].vector_end();
8135 Vec2 != Vec2End; ++Vec2) {
8136 QualType LandR[2] = { *Vec1, *Vec2 };
8157 if (!HasArithmeticOrEnumeralCandidateType)
8160 for (
unsigned Left = FirstPromotedIntegralType;
8161 Left < LastPromotedIntegralType; ++Left) {
8162 for (
unsigned Right = FirstPromotedIntegralType;
8163 Right < LastPromotedIntegralType; ++Right) {
8164 QualType LandR[2] = { ArithmeticTypes[Left],
8165 ArithmeticTypes[Right] };
8178 void addAssignmentMemberPointerOrEnumeralOverloads() {
8180 llvm::SmallPtrSet<QualType, 8> AddedTypes;
8182 for (
unsigned ArgIdx = 0; ArgIdx < 2; ++ArgIdx) {
8183 for (BuiltinCandidateTypeSet::iterator
8184 Enum = CandidateTypes[ArgIdx].enumeration_begin(),
8185 EnumEnd = CandidateTypes[ArgIdx].enumeration_end();
8186 Enum != EnumEnd; ++Enum) {
8193 for (BuiltinCandidateTypeSet::iterator
8194 MemPtr = CandidateTypes[ArgIdx].member_pointer_begin(),
8195 MemPtrEnd = CandidateTypes[ArgIdx].member_pointer_end();
8196 MemPtr != MemPtrEnd; ++MemPtr) {
8221 void addAssignmentPointerOverloads(
bool isEqualOp) {
8223 llvm::SmallPtrSet<QualType, 8> AddedTypes;
8225 for (BuiltinCandidateTypeSet::iterator
8226 Ptr = CandidateTypes[0].pointer_begin(),
8227 PtrEnd = CandidateTypes[0].pointer_end();
8228 Ptr != PtrEnd; ++Ptr) {
8232 else if (!(*Ptr)->getPointeeType()->isObjectType())
8243 bool NeedVolatile = !(*Ptr).isVolatileQualified() &&
8253 if (!(*Ptr).isRestrictQualified() &&
8275 for (BuiltinCandidateTypeSet::iterator
8276 Ptr = CandidateTypes[1].pointer_begin(),
8277 PtrEnd = CandidateTypes[1].pointer_end();
8278 Ptr != PtrEnd; ++Ptr) {
8292 bool NeedVolatile = !(*Ptr).isVolatileQualified() &&
8302 if (!(*Ptr).isRestrictQualified() &&
8337 void addAssignmentArithmeticOverloads(
bool isEqualOp) {
8338 if (!HasArithmeticOrEnumeralCandidateType)
8341 for (
unsigned Left = 0; Left < NumArithmeticTypes; ++Left) {
8342 for (
unsigned Right = FirstPromotedArithmeticType;
8343 Right < LastPromotedArithmeticType; ++Right) {
8345 ParamTypes[1] = ArithmeticTypes[Right];
8365 for (BuiltinCandidateTypeSet::iterator
8366 Vec1 = CandidateTypes[0].vector_begin(),
8367 Vec1End = CandidateTypes[0].vector_end();
8368 Vec1 != Vec1End; ++Vec1) {
8369 for (BuiltinCandidateTypeSet::iterator
8370 Vec2 = CandidateTypes[1].vector_begin(),
8371 Vec2End = CandidateTypes[1].vector_end();
8372 Vec2 != Vec2End; ++Vec2) {
8374 ParamTypes[1] = *Vec2;
8403 void addAssignmentIntegralOverloads() {
8404 if (!HasArithmeticOrEnumeralCandidateType)
8407 for (
unsigned Left = FirstIntegralType; Left < LastIntegralType; ++Left) {
8408 for (
unsigned Right = FirstPromotedIntegralType;
8409 Right < LastPromotedIntegralType; ++Right) {
8411 ParamTypes[1] = ArithmeticTypes[Right];
8419 ParamTypes[0] = ArithmeticTypes[Left];
8435 void addExclaimOverload() {
8441 void addAmpAmpOrPipePipeOverload() {
8458 void addSubscriptOverloads() {
8459 for (BuiltinCandidateTypeSet::iterator
8460 Ptr = CandidateTypes[0].pointer_begin(),
8461 PtrEnd = CandidateTypes[0].pointer_end();
8462 Ptr != PtrEnd; ++Ptr) {
8472 for (BuiltinCandidateTypeSet::iterator
8473 Ptr = CandidateTypes[1].pointer_begin(),
8474 PtrEnd = CandidateTypes[1].pointer_end();
8475 Ptr != PtrEnd; ++Ptr) {
8495 void addArrowStarOverloads() {
8496 for (BuiltinCandidateTypeSet::iterator
8497 Ptr = CandidateTypes[0].pointer_begin(),
8498 PtrEnd = CandidateTypes[0].pointer_end();
8499 Ptr != PtrEnd; ++Ptr) {
8504 if (!isa<RecordType>(C1))
8513 for (BuiltinCandidateTypeSet::iterator
8514 MemPtr = CandidateTypes[1].member_pointer_begin(),
8515 MemPtrEnd = CandidateTypes[1].member_pointer_end();
8516 MemPtr != MemPtrEnd; ++MemPtr) {
8522 QualType ParamTypes[2] = { *Ptr, *MemPtr };
8547 void addConditionalOperatorOverloads() {
8549 llvm::SmallPtrSet<QualType, 8> AddedTypes;
8551 for (
unsigned ArgIdx = 0; ArgIdx < 2; ++ArgIdx) {
8552 for (BuiltinCandidateTypeSet::iterator
8553 Ptr = CandidateTypes[ArgIdx].pointer_begin(),
8554 PtrEnd = CandidateTypes[ArgIdx].pointer_end();
8555 Ptr != PtrEnd; ++Ptr) {
8559 QualType ParamTypes[2] = { *Ptr, *Ptr };
8563 for (BuiltinCandidateTypeSet::iterator
8564 MemPtr = CandidateTypes[ArgIdx].member_pointer_begin(),
8565 MemPtrEnd = CandidateTypes[ArgIdx].member_pointer_end();
8566 MemPtr != MemPtrEnd; ++MemPtr) {
8570 QualType ParamTypes[2] = { *MemPtr, *MemPtr };
8575 for (BuiltinCandidateTypeSet::iterator
8576 Enum = CandidateTypes[ArgIdx].enumeration_begin(),
8577 EnumEnd = CandidateTypes[ArgIdx].enumeration_end();
8578 Enum != EnumEnd; ++Enum) {
8585 QualType ParamTypes[2] = { *Enum, *Enum };
8609 VisibleTypeConversionsQuals.
addConst();
8610 for (
unsigned ArgIdx = 0, N = Args.size(); ArgIdx != N; ++ArgIdx)
8613 bool HasNonRecordCandidateType =
false;
8614 bool HasArithmeticOrEnumeralCandidateType =
false;
8616 for (
unsigned ArgIdx = 0, N = Args.size(); ArgIdx != N; ++ArgIdx) {
8617 CandidateTypes.emplace_back(*
this);
8618 CandidateTypes[ArgIdx].AddTypesConvertedFrom(Args[ArgIdx]->getType(),
8621 (Op == OO_Exclaim ||
8624 VisibleTypeConversionsQuals);
8625 HasNonRecordCandidateType = HasNonRecordCandidateType ||
8626 CandidateTypes[ArgIdx].hasNonRecordTypes();
8627 HasArithmeticOrEnumeralCandidateType =
8628 HasArithmeticOrEnumeralCandidateType ||
8629 CandidateTypes[ArgIdx].hasArithmeticOrEnumeralTypes();
8637 if (!HasNonRecordCandidateType &&
8638 !(Op == OO_Exclaim || Op == OO_AmpAmp || Op == OO_PipePipe))
8642 BuiltinOperatorOverloadBuilder OpBuilder(*
this, Args,
8643 VisibleTypeConversionsQuals,
8644 HasArithmeticOrEnumeralCandidateType,
8645 CandidateTypes, CandidateSet);
8651 llvm_unreachable(
"Expected an overloaded operator");
8656 case OO_Array_Delete:
8659 "Special operators don't use AddBuiltinOperatorCandidates");
8671 if (Args.size() == 1)
8672 OpBuilder.addUnaryPlusPointerOverloads();
8676 if (Args.size() == 1) {
8677 OpBuilder.addUnaryPlusOrMinusArithmeticOverloads();
8679 OpBuilder.addBinaryPlusOrMinusPointerOverloads(Op);
8680 OpBuilder.addGenericBinaryArithmeticOverloads();
8685 if (Args.size() == 1)
8686 OpBuilder.addUnaryStarPointerOverloads();
8688 OpBuilder.addGenericBinaryArithmeticOverloads();
8692 OpBuilder.addGenericBinaryArithmeticOverloads();
8697 OpBuilder.addPlusPlusMinusMinusArithmeticOverloads(Op);
8698 OpBuilder.addPlusPlusMinusMinusPointerOverloads();
8702 case OO_ExclaimEqual:
8703 OpBuilder.addEqualEqualOrNotEqualMemberPointerOrNullptrOverloads();
8709 case OO_GreaterEqual:
8710 OpBuilder.addRelationalPointerOrEnumeralOverloads();
8711 OpBuilder.addGenericBinaryArithmeticOverloads();
8715 llvm_unreachable(
"<=> expressions not supported yet");
8721 case OO_GreaterGreater:
8722 OpBuilder.addBinaryBitwiseArithmeticOverloads(Op);
8726 if (Args.size() == 1)
8732 OpBuilder.addBinaryBitwiseArithmeticOverloads(Op);
8736 OpBuilder.addUnaryTildePromotedIntegralOverloads();
8740 OpBuilder.addAssignmentMemberPointerOrEnumeralOverloads();
8745 OpBuilder.addAssignmentPointerOverloads(Op == OO_Equal);
8750 OpBuilder.addAssignmentArithmeticOverloads(Op == OO_Equal);
8753 case OO_PercentEqual:
8754 case OO_LessLessEqual:
8755 case OO_GreaterGreaterEqual:
8759 OpBuilder.addAssignmentIntegralOverloads();
8763 OpBuilder.addExclaimOverload();
8768 OpBuilder.addAmpAmpOrPipePipeOverload();
8772 OpBuilder.addSubscriptOverloads();
8776 OpBuilder.addArrowStarOverloads();
8779 case OO_Conditional:
8780 OpBuilder.addConditionalOperatorOverloads();
8781 OpBuilder.addGenericBinaryArithmeticOverloads();
8799 bool PartialOverloading) {
8810 ArgumentDependentLookup(Name, Loc, Args, Fns);
8814 CandEnd = CandidateSet.
end();
8815 Cand != CandEnd; ++Cand)
8816 if (Cand->Function) {
8817 Fns.
erase(Cand->Function);
8827 if (ExplicitTemplateArgs)
8830 AddOverloadCandidate(FD, FoundDecl, Args, CandidateSet,
false,
8831 PartialOverloading);
8833 AddTemplateOverloadCandidate(cast<FunctionTemplateDecl>(*I),
8834 FoundDecl, ExplicitTemplateArgs,
8835 Args, CandidateSet, PartialOverloading);
8857 bool Cand1Attr = Cand1->
hasAttr<EnableIfAttr>();
8858 bool Cand2Attr = Cand2->
hasAttr<EnableIfAttr>();
8859 if (!Cand1Attr || !Cand2Attr) {
8860 if (Cand1Attr == Cand2Attr)
8861 return Comparison::Equal;
8862 return Cand1Attr ? Comparison::Better : Comparison::Worse;
8873 if (Cand1Attrs.size() < Cand2Attrs.size())
8874 return Comparison::Worse;
8876 auto Cand1I = Cand1Attrs.begin();
8877 llvm::FoldingSetNodeID Cand1ID, Cand2ID;
8878 for (
auto &Cand2A : Cand2Attrs) {
8882 auto &Cand1A = *Cand1I++;
8883 Cand1A->getCond()->Profile(Cand1ID, S.
getASTContext(),
true);
8884 Cand2A->getCond()->Profile(Cand2ID, S.
getASTContext(),
true);
8885 if (Cand1ID != Cand2ID)
8886 return Comparison::Worse;
8889 return Cand1I == Cand1Attrs.end() ? Comparison::Equal : Comparison::Better;
8910 unsigned StartArg = 0;
8917 return ICS.isStandard() &&
8929 assert(Cand2.
Conversions.size() == NumArgs &&
"Overload candidate mismatch");
8930 bool HasBetterConversion =
false;
8931 for (
unsigned ArgIdx = StartArg; ArgIdx < NumArgs; ++ArgIdx) {
8932 bool Cand1Bad = IsIllFormedConversion(Cand1.
Conversions[ArgIdx]);
8933 bool Cand2Bad = IsIllFormedConversion(Cand2.
Conversions[ArgIdx]);
8934 if (Cand1Bad != Cand2Bad) {
8937 HasBetterConversion =
true;
8941 if (HasBetterConversion)
8948 for (
unsigned ArgIdx = StartArg; ArgIdx < NumArgs; ++ArgIdx) {
8954 HasBetterConversion =
true;
8969 if (HasBetterConversion)
8980 isa<CXXConversionDecl>(Cand1.
Function) &&
8981 isa<CXXConversionDecl>(Cand2.
Function)) {
9009 isa<CXXConstructorDecl>(Cand1.
Function) !=
9010 isa<CXXConstructorDecl>(Cand2.
Function))
9011 return isa<CXXConstructorDecl>(Cand1.
Function);
9015 bool Cand1IsSpecialization = Cand1.
Function &&
9017 bool Cand2IsSpecialization = Cand2.
Function &&
9019 if (Cand1IsSpecialization != Cand2IsSpecialization)
9020 return Cand2IsSpecialization;
9026 if (Cand1IsSpecialization && Cand2IsSpecialization) {
9040 bool Cand1IsInherited =
9042 bool Cand2IsInherited =
9044 if (Cand1IsInherited != Cand2IsInherited)
9045 return Cand2IsInherited;
9046 else if (Cand1IsInherited) {
9047 assert(Cand2IsInherited);
9050 if (Cand1Class->isDerivedFrom(Cand2Class))
9052 if (Cand2Class->isDerivedFrom(Cand1Class))
9059 auto *Guide1 = dyn_cast_or_null<CXXDeductionGuideDecl>(Cand1.
Function);
9060 auto *Guide2 = dyn_cast_or_null<CXXDeductionGuideDecl>(Cand2.
Function);
9061 if (Guide1 && Guide2) {
9063 if (Guide1->isImplicit() != Guide2->isImplicit())
9064 return Guide2->isImplicit();
9067 if (Guide1->isCopyDeductionCandidate())
9075 if (Cmp != Comparison::Equal)
9076 return Cmp == Comparison::Better;
9085 bool HasPS1 = Cand1.
Function !=
nullptr &&
9087 bool HasPS2 = Cand2.
Function !=
nullptr &&
9089 return HasPS1 != HasPS2 && HasPS1;
9101 auto *VA = dyn_cast_or_null<ValueDecl>(A);
9102 auto *VB = dyn_cast_or_null<ValueDecl>(B);
9108 if (!VA->getDeclContext()->getRedeclContext()->Equals(
9109 VB->getDeclContext()->getRedeclContext()) ||
9110 getOwningModule(const_cast<ValueDecl *>(VA)) ==
9111 getOwningModule(const_cast<ValueDecl *>(VB)) ||
9112 VA->isExternallyVisible() || VB->isExternallyVisible())
9120 if (Context.
hasSameType(VA->getType(), VB->getType()))
9125 if (
auto *EA = dyn_cast<EnumConstantDecl>(VA)) {
9126 if (
auto *EB = dyn_cast<EnumConstantDecl>(VB)) {
9129 auto *EnumA = cast<EnumDecl>(EA->getDeclContext());
9130 auto *EnumB = cast<EnumDecl>(EB->getDeclContext());
9131 if (EnumA->hasNameForLinkage() || EnumB->hasNameForLinkage() ||
9133 EnumB->getIntegerType()))
9136 return llvm::APSInt::isSameValue(EA->getInitVal(), EB->getInitVal());
9146 Diag(Loc, diag::ext_equivalent_internal_linkage_decl_in_modules) << D;
9148 Module *M = getOwningModule(const_cast<NamedDecl*>(D));
9152 for (
auto *E : Equiv) {
9153 Module *M = getOwningModule(const_cast<NamedDecl*>(E));
9154 Diag(E->getLocation(), diag::note_equivalent_internal_linkage_decl)
9173 std::transform(begin(), end(), std::back_inserter(Candidates),
9185 bool ContainsSameSideCandidate =
9191 if (ContainsSameSideCandidate) {
9197 llvm::erase_if(Candidates, IsWrongSideCandidate);
9203 for (
auto *Cand : Candidates)
9205 if (Best == end() ||
9217 for (
auto *Cand : Candidates) {
9218 if (Cand->
Viable && Cand != Best &&
9222 EquivalentCands.push_back(Cand->
Function);
9232 if (Best->Function &&
9233 (Best->Function->isDeleted() ||
9237 if (!EquivalentCands.empty())
9250 oc_function_template,
9252 oc_constructor_template,
9253 oc_implicit_default_constructor,
9254 oc_implicit_copy_constructor,
9255 oc_implicit_move_constructor,
9256 oc_implicit_copy_assignment,
9257 oc_implicit_move_assignment,
9258 oc_inherited_constructor,
9259 oc_inherited_constructor_template
9264 std::string &Description) {
9274 if (!Ctor->isImplicit()) {
9275 if (isa<ConstructorUsingShadowDecl>(Found))
9276 return isTemplate ? oc_inherited_constructor_template
9277 : oc_inherited_constructor;
9279 return isTemplate ? oc_constructor_template : oc_constructor;
9282 if (Ctor->isDefaultConstructor())
9283 return oc_implicit_default_constructor;
9285 if (Ctor->isMoveConstructor())
9286 return oc_implicit_move_constructor;
9288 assert(Ctor->isCopyConstructor() &&
9289 "unexpected sort of implicit constructor");
9290 return oc_implicit_copy_constructor;
9296 if (!Meth->isImplicit())
9297 return isTemplate ? oc_method_template : oc_method;
9299 if (Meth->isMoveAssignmentOperator())
9300 return oc_implicit_move_assignment;
9302 if (Meth->isCopyAssignmentOperator())
9303 return oc_implicit_copy_assignment;
9305 assert(isa<CXXConversionDecl>(Meth) &&
"expected conversion");
9309 return isTemplate ? oc_function_template : oc_function;
9312 void MaybeEmitInheritedConstructorNote(
Sema &S,
Decl *FoundDecl) {
9315 if (
auto *Shadow = dyn_cast<ConstructorUsingShadowDecl>(FoundDecl))
9317 diag::note_ovl_candidate_inherited_constructor)
9318 << Shadow->getNominatedBaseClass();
9327 if (!EnableIf->getCond()->EvaluateAsBooleanCondition(AlwaysTrue, Ctx))
9344 bool InOverloadResolution,
9348 if (InOverloadResolution)
9350 diag::note_addrof_ovl_candidate_disabled_by_enable_if_attr);
9352 S.
Diag(Loc, diag::err_addrof_function_disabled_by_enable_if_attr) << FD;
9358 return P->hasAttr<PassObjectSizeAttr>();
9366 if (InOverloadResolution)
9368 diag::note_ovl_candidate_has_pass_object_size_params)
9371 S.
Diag(Loc, diag::err_address_of_function_with_pass_object_size_params)
9394 QualType DestType,
bool TakingAddress) {
9401 << (unsigned) K << Fn << FnDesc;
9403 HandleFunctionTypeMismatch(PD, Fn->
getType(), DestType);
9405 MaybeEmitInheritedConstructorNote(*
this, Found);
9411 bool TakingAddress) {
9421 dyn_cast<FunctionTemplateDecl>((*I)->getUnderlyingDecl()) ) {
9422 NoteOverloadCandidate(*I, FunTmpl->getTemplatedDecl(), DestType,
9425 = dyn_cast<FunctionDecl>((*I)->getUnderlyingDecl()) ) {
9426 NoteOverloadCandidate(*I, Fun, DestType, TakingAddress);
9438 S.
Diag(CaretLoc, PDiag)
9439 << Ambiguous.getFromType() << Ambiguous.getToType();
9444 unsigned CandsShown = 0;
9446 for (I = Ambiguous.begin(), E = Ambiguous.end(); I != E; ++I) {
9447 if (CandsShown >= 4 && ShowOverloads ==
Ovl_Best)
9457 unsigned I,
bool TakingCandidateAddress) {
9459 assert(Conv.
isBad());
9460 assert(Cand->
Function &&
"for now, candidate must be a function");
9466 bool isObjectArgument =
false;
9467 if (isa<CXXMethodDecl>(Fn) && !isa<CXXConstructorDecl>(Fn)) {
9469 isObjectArgument =
true;
9476 ClassifyOverloadCandidate(S, Cand->
FoundDecl, Fn, FnDesc);
9483 assert(FromExpr &&
"overload set argument came from implicit argument?");
9485 if (isa<UnaryOperator>(E))
9486 E = cast<UnaryOperator>(E)->getSubExpr()->
IgnoreParens();
9490 << (
unsigned) FnKind << FnDesc
9492 << ToTy << Name << I+1;
9493 MaybeEmitInheritedConstructorNote(S, Cand->
FoundDecl);
9502 CToTy = RT->getPointeeType();
9507 CFromTy = FromPT->getPointeeType();
9508 CToTy = ToPT->getPointeeType();
9519 << (
unsigned) FnKind << FnDesc
9524 << (unsigned) isObjectArgument << I+1;
9525 MaybeEmitInheritedConstructorNote(S, Cand->
FoundDecl);
9531 << (
unsigned) FnKind << FnDesc
9535 << (unsigned) isObjectArgument << I+1;
9536 MaybeEmitInheritedConstructorNote(S, Cand->
FoundDecl);
9542 << (
unsigned) FnKind << FnDesc
9546 << (unsigned) isObjectArgument << I+1;
9547 MaybeEmitInheritedConstructorNote(S, Cand->
FoundDecl);
9553 << (
unsigned) FnKind << FnDesc
9556 MaybeEmitInheritedConstructorNote(S, Cand->
FoundDecl);
9561 assert(CVR &&
"unexpected qualifiers mismatch");
9563 if (isObjectArgument) {
9565 << (
unsigned) FnKind << FnDesc
9567 << FromTy << (CVR - 1);
9570 << (
unsigned) FnKind << FnDesc
9572 << FromTy << (CVR - 1) << I+1;
9574 MaybeEmitInheritedConstructorNote(S, Cand->
FoundDecl);
9580 if (FromExpr && isa<InitListExpr>(FromExpr)) {
9582 << (
unsigned) FnKind << FnDesc
9584 << FromTy << ToTy << (
unsigned) isObjectArgument << I+1;
9585 MaybeEmitInheritedConstructorNote(S, Cand->
FoundDecl);
9597 S.
Diag(Fn->
getLocation(), diag::note_ovl_candidate_bad_conv_incomplete)
9598 << (
unsigned) FnKind << FnDesc
9600 << FromTy << ToTy << (
unsigned) isObjectArgument << I+1
9601 << (unsigned) (Cand->
Fix.
Kind);
9603 MaybeEmitInheritedConstructorNote(S, Cand->
FoundDecl);
9608 unsigned BaseToDerivedConversion = 0;
9611 if (ToPtrTy->getPointeeType().isAtLeastAsQualifiedAs(
9612 FromPtrTy->getPointeeType()) &&
9613 !FromPtrTy->getPointeeType()->isIncompleteType() &&
9614 !ToPtrTy->getPointeeType()->isIncompleteType() &&
9616 FromPtrTy->getPointeeType()))
9617 BaseToDerivedConversion = 1;
9625 if (ToPtrTy->getPointeeType().isAtLeastAsQualifiedAs(
9626 FromPtrTy->getPointeeType()) &&
9627 FromIface->isSuperClassOf(ToIface))
9628 BaseToDerivedConversion = 2;
9630 if (ToRefTy->getPointeeType().isAtLeastAsQualifiedAs(FromTy) &&
9632 !ToRefTy->getPointeeType()->isIncompleteType() &&
9634 BaseToDerivedConversion = 3;
9639 << (
unsigned) FnKind << FnDesc
9641 << (
unsigned) isObjectArgument << I + 1;
9642 MaybeEmitInheritedConstructorNote(S, Cand->
FoundDecl);
9647 if (BaseToDerivedConversion) {
9649 diag::note_ovl_candidate_bad_base_to_derived_conv)
9650 << (
unsigned) FnKind << FnDesc
9652 << (BaseToDerivedConversion - 1)
9653 << FromTy << ToTy << I+1;
9654 MaybeEmitInheritedConstructorNote(S, Cand->
FoundDecl);
9658 if (isa<ObjCObjectPointerType>(CFromTy) &&
9659 isa<PointerType>(CToTy)) {
9664 << (
unsigned) FnKind << FnDesc
9666 << FromTy << ToTy << (
unsigned) isObjectArgument << I+1;
9667 MaybeEmitInheritedConstructorNote(S, Cand->
FoundDecl);
9672 if (TakingCandidateAddress &&
9678 FDiag << (unsigned) FnKind << FnDesc
9680 << FromTy << ToTy << (
unsigned) isObjectArgument << I + 1
9681 << (unsigned) (Cand->
Fix.
Kind);
9684 for (std::vector<FixItHint>::iterator HI = Cand->
Fix.
Hints.begin(),
9685 HE = Cand->
Fix.
Hints.end(); HI != HE; ++HI)
9689 MaybeEmitInheritedConstructorNote(S, Cand->
FoundDecl);
9709 if (NumArgs < MinParams) {
9724 unsigned NumFormalArgs) {
9725 assert(isa<FunctionDecl>(D) &&
9726 "The templated declaration should at least be a function" 9727 " when diagnosing bad template argument deduction due to too many" 9728 " or too few arguments");
9737 unsigned mode, modeCount;
9738 if (NumFormalArgs < MinParams) {
9739 if (MinParams != FnTy->getNumParams() || FnTy->isVariadic() ||
9740 FnTy->isTemplateVariadic())
9744 modeCount = MinParams;
9746 if (MinParams != FnTy->getNumParams())
9750 modeCount = FnTy->getNumParams();
9753 std::string Description;
9755 ClassifyOverloadCandidate(S, Found, Fn, Description);
9764 << mode << modeCount << NumFormalArgs;
9765 MaybeEmitInheritedConstructorNote(S, Found);
9770 unsigned NumFormalArgs) {
9778 llvm_unreachable(
"Unsupported: Getting the described template declaration" 9779 " for bad deduction diagnosis");
9786 bool TakingCandidateAddress) {
9792 switch (DeductionFailure.
Result) {
9794 llvm_unreachable(
"TDK_success while diagnosing bad deduction");
9797 assert(ParamD &&
"no parameter found for incomplete deduction result");
9799 diag::note_ovl_candidate_incomplete_deduction)
9801 MaybeEmitInheritedConstructorNote(S, Found);
9806 assert(ParamD &&
"no parameter found for bad qualifiers deduction result");
9824 S.
Diag(Templated->
getLocation(), diag::note_ovl_candidate_underqualified)
9826 MaybeEmitInheritedConstructorNote(S, Found);
9831 assert(ParamD &&
"no parameter found for inconsistent deduction result");
9833 if (isa<TemplateTypeParmDecl>(ParamD))
9835 else if (isa<NonTypeTemplateParmDecl>(ParamD)) {
9845 diag::note_ovl_candidate_inconsistent_deduction_types)
9848 MaybeEmitInheritedConstructorNote(S, Found);
9858 diag::note_ovl_candidate_inconsistent_deduction)
9861 MaybeEmitInheritedConstructorNote(S, Found);
9866 assert(ParamD &&
"no parameter found for invalid explicit arguments");
9869 diag::note_ovl_candidate_explicit_arg_mismatch_named)
9874 index = TTP->getIndex();
9876 = dyn_cast<NonTypeTemplateParmDecl>(ParamD))
9877 index = NTTP->getIndex();
9879 index = cast<TemplateTemplateParmDecl>(ParamD)->getIndex();
9881 diag::note_ovl_candidate_explicit_arg_mismatch_unnamed)
9884 MaybeEmitInheritedConstructorNote(S, Found);
9894 diag::note_ovl_candidate_instantiation_depth);
9895 MaybeEmitInheritedConstructorNote(S, Found);
9903 TemplateArgString =
" ";
9910 if (PDiag && PDiag->second.getDiagID() ==
9911 diag::err_typename_nested_not_found_enable_if) {
9914 S.
Diag(PDiag->first, diag::note_ovl_candidate_disabled_by_enable_if)
9915 <<
"'enable_if'" << TemplateArgString;
9920 if (PDiag && PDiag->second.getDiagID() ==
9921 diag::err_typename_nested_not_found_requirement) {
9923 diag::note_ovl_candidate_disabled_by_requirement)
9924 << PDiag->second.getStringArg(0) << TemplateArgString;
9934 SFINAEArgString =
": ";
9940 diag::note_ovl_candidate_substitution_failure)
9941 << TemplateArgString << SFINAEArgString << R;
9942 MaybeEmitInheritedConstructorNote(S, Found);
9952 TemplateArgString =
" ";
9957 S.
Diag(Templated->
getLocation(), diag::note_ovl_candidate_deduced_mismatch)
9960 << TemplateArgString
9984 diag::note_ovl_candidate_non_deduced_mismatch_qualified)
9991 if (TakingCandidateAddress && isa<FunctionDecl>(Templated) &&
10000 diag::note_ovl_candidate_non_deduced_mismatch)
10001 << FirstTA << SecondTA;
10007 S.
Diag(Templated->
getLocation(), diag::note_ovl_candidate_bad_deduction);
10008 MaybeEmitInheritedConstructorNote(S, Found);
10012 diag::note_cuda_ovl_candidate_target_mismatch);
10020 bool TakingCandidateAddress) {
10038 std::string FnDesc;
10040 ClassifyOverloadCandidate(S, Cand->
FoundDecl, Callee, FnDesc);
10042 S.
Diag(Callee->getLocation(), diag::note_ovl_candidate_bad_target)
10043 << (
unsigned)FnKind << CalleeTarget << CallerTarget;
10048 if (Meth !=
nullptr && Meth->
isImplicit()) {
10055 case oc_implicit_default_constructor:
10058 case oc_implicit_copy_constructor:
10061 case oc_implicit_move_constructor:
10064 case oc_implicit_copy_assignment:
10067 case oc_implicit_move_assignment:
10072 bool ConstRHS =
false;
10076 ConstRHS = RT->getPointeeType().isConstQualified();
10091 diag::note_ovl_candidate_disabled_by_function_cond_attr)
10092 << Attr->getCond()->getSourceRange() << Attr->getMessage();
10099 diag::note_ovl_candidate_disabled_by_extension);
10117 bool TakingCandidateAddress) {
10123 std::string FnDesc;
10125 ClassifyOverloadCandidate(S, Cand->
FoundDecl, Fn, FnDesc);
10128 << FnKind << FnDesc
10130 MaybeEmitInheritedConstructorNote(S, Cand->
FoundDecl);
10146 TakingCandidateAddress);
10149 S.
Diag(Fn->
getLocation(), diag::note_ovl_candidate_illegal_constructor)
10151 MaybeEmitInheritedConstructorNote(S, Cand->
FoundDecl);
10162 for (
unsigned N = Cand->
Conversions.size(); I != N; ++I)
10183 if (cast<CXXConstructorDecl>(Fn)->isCopyOrMoveConstructor())
10186 diag::note_ovl_candidate_inherited_constructor_slice)
10189 MaybeEmitInheritedConstructorNote(S, Cand->
FoundDecl);
10195 assert(!Available);
10206 bool isLValueReference =
false;
10207 bool isRValueReference =
false;
10208 bool isPointer =
false;
10212 isLValueReference =
true;
10216 isRValueReference =
true;
10236 assert(Cand->
Conversions.size() <= 2 &&
"builtin operator is not binary");
10237 std::string TypeStr(
"operator");
10243 S.
Diag(OpLoc, diag::note_ovl_builtin_unary_candidate) << TypeStr;
10248 S.
Diag(OpLoc, diag::note_ovl_builtin_binary_candidate) << TypeStr;
10255 if (ICS.
isBad())
break;
10259 S, OpLoc, S.
PDiag(diag::note_ambiguous_type_conversion));
10275 llvm_unreachable(
"non-deduction failure while diagnosing bad deduction");
10303 llvm_unreachable(
"Unhandled deduction result");
10307 struct CompareOverloadCandidatesForDisplay {
10313 CompareOverloadCandidatesForDisplay(
10316 : S(S), NumArgs(NArgs), CSK(CSK) {}
10321 if (L == R)
return false;
10325 if (!R->
Viable)
return true;
10348 if (LDist == RDist) {
10357 return LDist < RDist;
10375 numLFixes = (numLFixes == 0) ?
UINT_MAX : numLFixes;
10376 numRFixes = (numRFixes == 0) ?
UINT_MAX : numRFixes;
10377 if (numLFixes != numRFixes) {
10378 return numLFixes < numRFixes;
10385 int leftBetter = 0;
10387 for (
unsigned E = L->
Conversions.size(); I != E; ++I) {
10403 if (leftBetter > 0)
return true;
10404 if (leftBetter < 0)
return false;
10446 bool Unfixable =
false;
10454 assert(ConvIdx != ConvCount &&
"no bad conversion in candidate");
10455 if (Cand->
Conversions[ConvIdx].isInitialized() &&
10464 bool SuppressUserConversions =
false;
10466 unsigned ConvIdx = 0;
10480 if (isa<CXXMethodDecl>(Cand->
Function) &&
10481 !isa<CXXConstructorDecl>(Cand->
Function)) {
10487 assert(ConvCount <= 3);
10492 for (
unsigned ArgIdx = 0; ConvIdx != ConvCount; ++ConvIdx, ++ArgIdx) {
10493 if (Cand->
Conversions[ConvIdx].isInitialized()) {
10495 }
else if (ArgIdx < ParamTypes.size()) {
10496 if (ParamTypes[ArgIdx]->isDependentType())
10497 Cand->
Conversions[ConvIdx].setAsIdentityConversion(
10498 Args[ArgIdx]->getType());
10502 SuppressUserConversions,
10507 if (!Unfixable && Cand->
Conversions[ConvIdx].isBad())
10526 for (
iterator Cand = begin(), LastCand = end(); Cand != LastCand; ++Cand) {
10527 if (!Filter(*Cand))
10530 Cands.push_back(Cand);
10533 if (Cand->Function || Cand->IsSurrogate)
10534 Cands.push_back(Cand);
10540 std::stable_sort(Cands.begin(), Cands.end(),
10541 CompareOverloadCandidatesForDisplay(S, OpLoc, Args.size(),
Kind));
10543 bool ReportedAmbiguousConversions =
false;
10547 unsigned CandsShown = 0;
10548 for (I = Cands.begin(), E = Cands.end(); I != E; ++I) {
10554 if (CandsShown >= 4 && ShowOverloads ==
Ovl_Best) {
10566 "Non-viable built-in candidates are not added to Cands.");
10573 if (!ReportedAmbiguousConversions) {
10575 ReportedAmbiguousConversions =
true;
10584 S.
Diag(OpLoc, diag::note_ovl_too_many_candidates) << int(E - I);
10594 struct CompareTemplateSpecCandidatesForDisplay {
10596 CompareTemplateSpecCandidatesForDisplay(
Sema &S) : S(S) {}
10630 bool ForTakingAddress) {
10632 DeductionFailure, 0, ForTakingAddress);
10635 void TemplateSpecCandidateSet::destroyCandidates() {
10636 for (iterator i = begin(), e = end(); i != e; ++i) {
10637 i->DeductionFailure.Destroy();
10642 destroyCandidates();
10643 Candidates.clear();
10656 Cands.reserve(size());
10657 for (
iterator Cand = begin(), LastCand = end(); Cand != LastCand; ++Cand) {
10658 if (Cand->Specialization)
10659 Cands.push_back(Cand);
10664 std::sort(Cands.begin(), Cands.end(),
10665 CompareTemplateSpecCandidatesForDisplay(S));
10672 unsigned CandsShown = 0;
10673 for (I = Cands.begin(), E = Cands.end(); I != E; ++I) {
10679 if (CandsShown >= 4 && ShowOverloads ==
Ovl_Best)
10684 "Non-matching built-in candidates are not added to Cands.");
10689 S.
Diag(Loc, diag::note_ovl_too_many_candidates) << int(E - I);
10699 QualType Ret = PossiblyAFunctionType;
10715 bool Complain =
true) {
10732 class AddressOfFunctionResolver {
10742 bool TargetTypeIsNonStaticMemberFunction;
10743 bool FoundNonTemplateFunction;
10744 bool StaticMemberFunctionFromBoundPointer;
10745 bool HasComplained;
10754 AddressOfFunctionResolver(
Sema &S,
Expr *SourceExpr,
10755 const QualType &TargetType,
bool Complain)
10756 : S(S), SourceExpr(SourceExpr), TargetType(TargetType),
10758 TargetTypeIsNonStaticMemberFunction(
10760 FoundNonTemplateFunction(
false),
10761 StaticMemberFunctionFromBoundPointer(
false),
10762 HasComplained(
false),
10765 FailedCandidates(OvlExpr->
getNameLoc(),
true) {
10766 ExtractUnqualifiedFunctionTypeFromTargetType();
10770 if (!UME->isImplicitAccess() &&
10772 StaticMemberFunctionFromBoundPointer =
true;
10776 OvlExpr,
false, &dap)) {
10778 if (!Method->isStatic()) {
10782 TargetTypeIsNonStaticMemberFunction =
true;
10790 Matches.push_back(std::make_pair(dap, Fn));
10798 if (FindAllFunctionsThatMatchTargetTypeExactly()) {
10801 if (Matches.size() > 1 && !eliminiateSuboptimalOverloadCandidates()) {
10802 if (FoundNonTemplateFunction)
10803 EliminateAllTemplateMatches();
10805 EliminateAllExceptMostSpecializedTemplate();
10810 EliminateSuboptimalCudaMatches();
10813 bool hasComplained()
const {
return HasComplained; }
10816 bool candidateHasExactlyCorrectType(
const FunctionDecl *FD) {
10828 return candidateHasExactlyCorrectType(A) &&
10829 (!candidateHasExactlyCorrectType(B) ||
10835 bool eliminiateSuboptimalOverloadCandidates() {
10838 auto Best = Matches.begin();
10839 for (
auto I = Matches.begin()+1, E = Matches.end(); I != E; ++I)
10840 if (isBetterCandidate(I->second, Best->second))
10844 auto IsBestOrInferiorToBest = [
this, BestFn](
10845 const std::pair<DeclAccessPair, FunctionDecl *> &Pair) {
10846 return BestFn == Pair.second || isBetterCandidate(BestFn, Pair.second);
10851 if (!std::all_of(Matches.begin(), Matches.end(), IsBestOrInferiorToBest))
10853 Matches[0] = *Best;
10858 bool isTargetTypeAFunction()
const {
10867 void inline ExtractUnqualifiedFunctionTypeFromTargetType() {
10878 if (Method->isStatic() == TargetTypeIsNonStaticMemberFunction)
10881 else if (TargetTypeIsNonStaticMemberFunction)
10894 &OvlExplicitTemplateArgs,
10895 TargetFunctionType, Specialization,
10914 Matches.push_back(std::make_pair(CurAccessFunPair, Specialization));
10918 bool AddMatchingNonTemplateFunction(
NamedDecl* Fn,
10923 if (Method->isStatic() == TargetTypeIsNonStaticMemberFunction)
10926 else if (TargetTypeIsNonStaticMemberFunction)
10929 if (
FunctionDecl *FunDecl = dyn_cast<FunctionDecl>(Fn)) {
10939 HasComplained |= Complain;
10948 candidateHasExactlyCorrectType(FunDecl)) {
10949 Matches.push_back(std::make_pair(
10950 CurAccessFunPair, cast<FunctionDecl>(FunDecl->getCanonicalDecl())));
10951 FoundNonTemplateFunction =
true;
10959 bool FindAllFunctionsThatMatchTargetTypeExactly() {
10964 if (IsInvalidFormOfPointerToMemberFunction())
10980 = dyn_cast<FunctionTemplateDecl>(Fn)) {
10981 if (AddMatchingTemplateFunction(FunctionTemplate, I.getPair()))
10986 AddMatchingNonTemplateFunction(Fn, I.getPair()))
10989 assert(Ret || Matches.empty());
10993 void EliminateAllExceptMostSpecializedTemplate() {
11006 for (
unsigned I = 0, E = Matches.size(); I != E; ++I)
11007 MatchesCopy.
addDecl(Matches[I].second, Matches[I].first.getAccess());
11012 MatchesCopy.
begin(), MatchesCopy.
end(), FailedCandidates,
11014 S.
PDiag(diag::err_addr_ovl_ambiguous)
11015 << Matches[0].second->getDeclName(),
11016 S.
PDiag(diag::note_ovl_candidate)
11017 << (unsigned)oc_function_template,
11018 Complain, TargetFunctionType);
11020 if (Result != MatchesCopy.
end()) {
11022 Matches[0].first = Matches[Result - MatchesCopy.
begin()].first;
11023 Matches[0].second = cast<FunctionDecl>(*Result);
11026 HasComplained |= Complain;
11029 void EliminateAllTemplateMatches() {
11032 for (
unsigned I = 0, N = Matches.size(); I != N; ) {
11033 if (Matches[I].second->getPrimaryTemplate() ==
nullptr)
11036 Matches[I] = Matches[--N];
11042 void EliminateSuboptimalCudaMatches() {
11047 void ComplainNoMatchesFound()
const {
11048 assert(Matches.empty());
11050 << OvlExpr->
getName() << TargetFunctionType
11052 if (FailedCandidates.
empty())
11063 dyn_cast<FunctionDecl>((*I)->getUnderlyingDecl()))
11071 bool IsInvalidFormOfPointerToMemberFunction()
const {
11072 return TargetTypeIsNonStaticMemberFunction &&
11076 void ComplainIsInvalidFormOfPointerToMemberFunction()
const {
11084 bool IsStaticMemberFunctionFromBoundPointer()
const {
11085 return StaticMemberFunctionFromBoundPointer;
11088 void ComplainIsStaticMemberFunctionFromBoundPointer()
const {
11090 diag::err_invalid_form_pointer_member_function)
11094 void ComplainOfInvalidConversion()
const {
11096 << OvlExpr->
getName() << TargetType;
11099 void ComplainMultipleMatchesFound()
const {
11100 assert(Matches.size() > 1);
11108 bool hadMultipleCandidates()
const {
return (OvlExpr->
getNumDecls() > 1); }
11110 int getNumMatches()
const {
return Matches.size(); }
11113 if (Matches.size() != 1)
return nullptr;
11114 return Matches[0].second;
11118 if (Matches.size() != 1)
return nullptr;
11119 return &Matches[0].first;
11144 bool *pHadMultipleCandidates) {
11147 AddressOfFunctionResolver Resolver(*
this, AddressOfExpr, TargetType,
11149 int NumMatches = Resolver.getNumMatches();
11151 bool ShouldComplain = Complain && !Resolver.hasComplained();
11152 if (NumMatches == 0 && ShouldComplain) {
11153 if (Resolver.IsInvalidFormOfPointerToMemberFunction())
11154 Resolver.ComplainIsInvalidFormOfPointerToMemberFunction();
11156 Resolver.ComplainNoMatchesFound();
11158 else if (NumMatches > 1 && ShouldComplain)
11159 Resolver.ComplainMultipleMatchesFound();
11160 else if (NumMatches == 1) {
11161 Fn = Resolver.getMatchingFunctionDecl();
11164 ResolveExceptionSpec(AddressOfExpr->
getExprLoc(), FPT);
11165 FoundResult = *Resolver.getMatchingFunctionAccessPair();
11167 if (Resolver.IsStaticMemberFunctionFromBoundPointer())
11168 Resolver.ComplainIsStaticMemberFunctionFromBoundPointer();
11170 CheckAddressOfMemberAccess(AddressOfExpr, FoundResult);
11174 if (pHadMultipleCandidates)
11175 *pHadMultipleCandidates = Resolver.hadMultipleCandidates();
11196 auto *FD = dyn_cast<
FunctionDecl>(I->getUnderlyingDecl());
11223 ExprResult &SrcExpr,
bool DoFunctionPointerConverion) {
11228 FunctionDecl *Found = resolveAddressOfOnlyViableOverloadCandidate(E, DAP);
11236 CheckAddressOfMemberAccess(E, DAP);
11237 Expr *Fixed = FixOverloadedFunctionReference(E, DAP, Found);
11239 SrcExpr = DefaultFunctionArrayConversion(Fixed,
false);
11286 = cast<FunctionTemplateDecl>((*I)->getUnderlyingDecl());
11298 Specialization, Info,
11302 FailedCandidates.addCandidate()
11308 assert(Specialization &&
"no specialization and no error?");
11315 NoteAllOverloadCandidates(ovl);
11320 Matched = Specialization;
11321 if (FoundResult) *FoundResult = I.getPair();
11340 ExprResult &SrcExpr,
bool doFunctionPointerConverion,
11341 bool complain,
SourceRange OpRangeForComplaining,
11343 unsigned DiagIDForComplaining) {
11350 if (
FunctionDecl *fn = ResolveSingleFunctionTemplateSpecialization(
11351 ovl.Expression,
false, &found)) {
11352 if (DiagnoseUseOfDecl(fn, SrcExpr.
get()->getLocStart())) {
11361 if (!ovl.HasFormOfMemberPointer &&
11362 isa<CXXMethodDecl>(fn) &&
11363 cast<CXXMethodDecl>(fn)->isInstance()) {
11364 if (!complain)
return false;
11366 Diag(ovl.Expression->getExprLoc(),
11367 diag::err_bound_member_function)
11368 << 0 << ovl.Expression->getSourceRange();
11380 SingleFunctionExpression =
11381 FixOverloadedFunctionReference(SrcExpr.
get(), found, fn);
11384 if (doFunctionPointerConverion) {
11385 SingleFunctionExpression =
11386 DefaultFunctionArrayLvalueConversion(SingleFunctionExpression.
get());
11387 if (SingleFunctionExpression.
isInvalid()) {
11394 if (!SingleFunctionExpression.
isUsable()) {
11396 Diag(OpRangeForComplaining.
getBegin(), DiagIDForComplaining)
11397 << ovl.Expression->getName()
11398 << DestTypeForComplaining
11399 << OpRangeForComplaining
11400 << ovl.Expression->getQualifierLoc().getSourceRange();
11401 NoteAllOverloadCandidates(SrcExpr.
get());
11410 SrcExpr = SingleFunctionExpression;
11420 bool PartialOverloading,
11423 if (isa<UsingShadowDecl>(Callee))
11424 Callee = cast<UsingShadowDecl>(Callee)->getTargetDecl();
11426 if (
FunctionDecl *Func = dyn_cast<FunctionDecl>(Callee)) {
11427 if (ExplicitTemplateArgs) {
11428 assert(!KnownValid &&
"Explicit template arguments?");
11432 if (!dyn_cast<FunctionProtoType>(Func->getType()->getAs<
FunctionType>()))
11437 PartialOverloading);
11442 = dyn_cast<FunctionTemplateDecl>(Callee)) {
11444 ExplicitTemplateArgs, Args, CandidateSet,
11446 PartialOverloading);
11450 assert(!KnownValid &&
"unhandled case in overloaded call candidate");
11458 bool PartialOverloading) {
11481 assert(!(*I)->getDeclContext()->isRecord());
11482 assert(isa<UsingShadowDecl>(*I) ||
11483 !(*I)->getDeclContext()->isFunctionOrMethod());
11484 assert((*I)->getUnderlyingDecl()->isFunctionOrFunctionTemplate());
11494 ExplicitTemplateArgs = &TABuffer;
11500 CandidateSet, PartialOverloading,
11505 Args, ExplicitTemplateArgs,
11506 CandidateSet, PartialOverloading);
11513 case OO_New:
case OO_Array_New:
11514 case OO_Delete:
case OO_Array_Delete:
11534 bool *DoDiagnoseEmptyLookup =
nullptr) {
11539 if (DC->isTransparentContext())
11547 if (isa<CXXRecordDecl>(DC)) {
11551 if (DoDiagnoseEmptyLookup)
11552 *DoDiagnoseEmptyLookup =
true;
11559 ExplicitTemplateArgs, Args,
11560 Candidates,
false,
false);
11563 if (Candidates.BestViableFunction(SemaRef, FnLoc, Best) !=
OR_Success) {
11575 AssociatedNamespaces,
11576 AssociatedClasses);
11580 for (Sema::AssociatedNamespaceSet::iterator
11581 it = AssociatedNamespaces.begin(),
11582 end = AssociatedNamespaces.end(); it != end; ++it) {
11594 SuggestedNamespaces.insert(*it);
11598 SemaRef.
Diag(R.
getNameLoc(), diag::err_not_found_by_two_phase_lookup)
11600 if (SuggestedNamespaces.empty()) {
11601 SemaRef.
Diag(Best->Function->getLocation(),
11602 diag::note_not_found_by_two_phase_lookup)
11604 }
else if (SuggestedNamespaces.size() == 1) {
11605 SemaRef.
Diag(Best->Function->getLocation(),
11606 diag::note_not_found_by_two_phase_lookup)
11612 SemaRef.
Diag(Best->Function->getLocation(),
11613 diag::note_not_found_by_two_phase_lookup)
11645 class BuildRecoveryCallExprRAII {
11648 BuildRecoveryCallExprRAII(
Sema &S) : SemaRef(S) {
11653 ~BuildRecoveryCallExprRAII() {
11660 static std::unique_ptr<CorrectionCandidateCallback>
11662 bool HasTemplateArgs,
bool AllowTypoCorrection) {
11663 if (!AllowTypoCorrection)
11664 return llvm::make_unique<NoTypoCorrectionCCC>();
11665 return llvm::make_unique<FunctionCallFilterCCC>(SemaRef, NumArgs,
11666 HasTemplateArgs, ME);
11678 bool EmptyLookup,
bool AllowTypoCorrection) {
11687 BuildRecoveryCallExprRAII RCE(SemaRef);
11697 ExplicitTemplateArgs = &TABuffer;
11702 bool DoDiagnoseEmptyLookup = EmptyLookup;
11705 ExplicitTemplateArgs, Args,
11706 &DoDiagnoseEmptyLookup) &&
11709 MakeValidator(SemaRef, dyn_cast<MemberExpr>(Fn), Args.size(),
11710 ExplicitTemplateArgs !=
nullptr, AllowTypoCorrection),
11711 ExplicitTemplateArgs, Args)))
11714 assert(!R.empty() &&
"lookup results empty despite recovery");
11717 if (R.isAmbiguous()) {
11718 R.suppressDiagnostics();
11725 if ((*R.begin())->isCXXClassMember())
11727 ExplicitTemplateArgs, S);
11728 else if (ExplicitTemplateArgs || TemplateKWLoc.
isValid())
11730 ExplicitTemplateArgs);
11757 assert(!ULE->
getQualifier() &&
"qualified name with ADL");
11765 llvm_unreachable(
"performing ADL for builtin");
11768 assert(getLangOpts().
CPlusPlus &&
"ADL enabled in C");
11772 UnbridgedCastsSet UnbridgedCasts;
11780 AddOverloadedCallCandidates(ULE, Args, *CandidateSet);
11782 if (getLangOpts().MSVCCompat &&
11783 CurContext->isDependentContext() && !isSFINAEContext() &&
11784 (isa<FunctionDecl>(CurContext) || isa<CXXRecordDecl>(CurContext))) {
11787 if (CandidateSet->
empty() ||
11804 if (CandidateSet->
empty())
11807 UnbridgedCasts.restore();
11823 bool AllowTypoCorrection) {
11824 if (CandidateSet->
empty())
11827 AllowTypoCorrection);
11829 switch (OverloadResult) {
11846 AllowTypoCorrection);
11853 for (
const Expr *Arg : Args) {
11854 if (!Arg->getType()->isFunctionType())
11856 if (
auto *DRE = dyn_cast<DeclRefExpr>(Arg->IgnoreParenImpCasts())) {
11860 Arg->getExprLoc()))
11865 SemaRef.
Diag(Fn->
getLocStart(), diag::err_ovl_no_viable_function_in_call)
11879 << (*Best)->Function->isDeleted()
11900 for (
auto I = CS.
begin(), E = CS.
end(); I != E; ++I) {
11921 bool AllowTypoCorrection,
11922 bool CalleesAddressIsTaken) {
11927 if (buildOverloadedCallSet(S, Fn, ULE, Args, LParenLoc, &CandidateSet,
11933 if (CalleesAddressIsTaken)
11938 CandidateSet.BestViableFunction(*
this, Fn->
getLocStart(), Best);
11941 RParenLoc, ExecConfig, &CandidateSet,
11942 &Best, OverloadResult,
11943 AllowTypoCorrection);
11947 return Functions.
size() > 1 ||
11948 (Functions.
size() == 1 && isa<FunctionTemplateDecl>(*Functions.
begin()));
11969 Expr *Input,
bool PerformADL) {
11971 assert(Op !=
OO_None &&
"Invalid opcode for overloaded unary operator");
11979 Expr *Args[2] = { Input,
nullptr };
11980 unsigned NumArgs = 1;
11985 if (Opc == UO_PostInc || Opc == UO_PostDec) {
12005 return new (Context)
12014 AddFunctionCandidates(Fns, ArgsArray, CandidateSet);
12017 AddMemberOperatorCandidates(Op, OpLoc, ArgsArray, CandidateSet);
12021 AddArgumentDependentLookupCandidates(OpName, OpLoc, ArgsArray,
12027 AddBuiltinOperatorCandidates(Op, OpLoc, ArgsArray, CandidateSet);
12029 bool HadMultipleCandidates = (CandidateSet.
size() > 1);
12044 if (
CXXMethodDecl *Method = dyn_cast<CXXMethodDecl>(FnDecl)) {
12045 CheckMemberOperatorAccess(OpLoc, Args[0],
nullptr, Best->FoundDecl);
12048 PerformObjectArgumentInitialization(Input,
nullptr,
12049 Best->FoundDecl, Method);
12052 Base = Input = InputRes.
get();
12063 Input = InputInit.
get();
12068 Base, HadMultipleCandidates,
12083 if (CheckCallReturnType(FnDecl->
getReturnType(), OpLoc, TheCall, FnDecl))
12086 if (CheckFunctionCall(FnDecl, TheCall,
12090 return MaybeBindToTemporary(TheCall);
12095 ExprResult InputRes = PerformImplicitConversion(
12096 Input, Best->BuiltinParamTypes[0], Best->Conversions[0], AA_Passing);
12099 Input = InputRes.
get();
12117 Diag(OpLoc, diag::err_ovl_ambiguous_oper_unary)
12126 Diag(OpLoc, diag::err_ovl_deleted_oper)
12127 << Best->Function->isDeleted()
12129 << getDeletedOrUnavailableSuffix(Best->Function)
12139 return CreateBuiltinUnaryOp(OpLoc, Opc, Input);
12162 Expr *LHS,
Expr *RHS,
bool PerformADL) {
12163 Expr *Args[2] = { LHS, RHS };
12171 if (Args[0]->isTypeDependent() || Args[1]->isTypeDependent()) {
12175 if (Opc <= BO_Assign || Opc > BO_OrAssign)
12178 OpLoc, FPFeatures);
12195 return new (Context)
12216 if (Opc == BO_Assign && !Args[0]->getType()->isOverloadableType())
12217 return CreateBuiltinBinOp(OpLoc, Opc, Args[0], Args[1]);
12221 if (Opc == BO_PtrMemD)
12222 return CreateBuiltinBinOp(OpLoc, Opc, Args[0], Args[1]);
12228 AddFunctionCandidates(Fns, Args, CandidateSet);
12231 AddMemberOperatorCandidates(Op, OpLoc, Args, CandidateSet);
12236 if (Opc != BO_Assign && PerformADL)
12237 AddArgumentDependentLookupCandidates(OpName, OpLoc, Args,
12242 AddBuiltinOperatorCandidates(Op, OpLoc, Args, CandidateSet);
12244 bool HadMultipleCandidates = (CandidateSet.
size() > 1);
12259 if (
CXXMethodDecl *Method = dyn_cast<CXXMethodDecl>(FnDecl)) {
12261 CheckMemberOperatorAccess(OpLoc, Args[0], Args[1], Best->FoundDecl);
12264 PerformCopyInitialization(
12272 PerformObjectArgumentInitialization(Args[0],
nullptr,
12273 Best->FoundDecl, Method);
12280 ExprResult Arg0 = PerformCopyInitialization(
12288 PerformCopyInitialization(
12300 Best->FoundDecl, Base,
12301 HadMultipleCandidates, OpLoc);
12302 if (FnExpr.isInvalid())
12312 Args, ResultTy, VK, OpLoc,
12315 if (CheckCallReturnType(FnDecl->
getReturnType(), OpLoc, TheCall,
12320 const Expr *ImplicitThis =
nullptr;
12322 if (isa<CXXMethodDecl>(FnDecl)) {
12323 ImplicitThis = ArgsArray[0];
12324 ArgsArray = ArgsArray.slice(1);
12328 if (Op == OO_Equal)
12329 DiagnoseSelfMove(Args[0], Args[1], OpLoc);
12331 checkCall(FnDecl,
nullptr, ImplicitThis, ArgsArray,
12332 isa<CXXMethodDecl>(FnDecl), OpLoc, TheCall->getSourceRange(),
12333 VariadicDoesNotApply);
12335 return MaybeBindToTemporary(TheCall);
12341 PerformImplicitConversion(Args[0], Best->BuiltinParamTypes[0],
12342 Best->Conversions[0], AA_Passing);
12345 Args[0] = ArgsRes0.
get();
12348 PerformImplicitConversion(Args[1], Best->BuiltinParamTypes[1],
12349 Best->Conversions[1], AA_Passing);
12352 Args[1] = ArgsRes1.
get();
12362 if (Opc == BO_Comma)
12370 Opc >= BO_Assign && Opc <= BO_OrAssign) {
12371 Diag(OpLoc, diag::err_ovl_no_viable_oper)
12374 if (Args[0]->getType()->isIncompleteType()) {
12375 Diag(OpLoc, diag::note_assign_lhs_incomplete)
12389 Result = CreateBuiltinBinOp(OpLoc, Opc, Args[0], Args[1]);
12392 "C++ binary operator overloading is missing candidates!");
12400 Diag(OpLoc, diag::err_ovl_ambiguous_oper_binary)
12409 if (isImplicitlyDeleted(Best->Function)) {
12410 CXXMethodDecl *Method = cast<CXXMethodDecl>(Best->Function);
12411 Diag(OpLoc, diag::err_ovl_deleted_special_oper)
12413 << getSpecialMember(Method);
12417 NoteDeletedFunction(Method);
12420 Diag(OpLoc, diag::err_ovl_deleted_oper)
12421 << Best->Function->isDeleted()
12423 << getDeletedOrUnavailableSuffix(Best->Function)
12432 return CreateBuiltinBinOp(OpLoc, Opc, Args[0], Args[1]);
12439 Expr *Args[2] = { Base, Idx };
12445 if (Args[0]->isTypeDependent() || Args[1]->isTypeDependent()) {
12459 return new (Context)
12476 AddMemberOperatorCandidates(OO_Subscript, LLoc, Args, CandidateSet);
12479 AddBuiltinOperatorCandidates(OO_Subscript, LLoc, Args, CandidateSet);
12481 bool HadMultipleCandidates = (CandidateSet.
size() > 1);
12494 CheckMemberOperatorAccess(LLoc, Args[0], Args[1], Best->FoundDecl);
12499 PerformObjectArgumentInitialization(Args[0],
nullptr,
12500 Best->FoundDecl, Method);
12501 if (Arg0.isInvalid())
12503 Args[0] = Arg0.get();
12519 OpLocInfo.setCXXOperatorNameRange(
SourceRange(LLoc, RLoc));
12523 HadMultipleCandidates,
12524 OpLocInfo.getLoc(),
12525 OpLocInfo.getInfo());
12536 FnExpr.
get(), Args,
12537 ResultTy, VK, RLoc,
12540 if (CheckCallReturnType(FnDecl->
getReturnType(), LLoc, TheCall, FnDecl))
12543 if (CheckFunctionCall(Method, TheCall,
12547 return MaybeBindToTemporary(TheCall);
12553 PerformImplicitConversion(Args[0], Best->BuiltinParamTypes[0],
12554 Best->Conversions[0], AA_Passing);
12557 Args[0] = ArgsRes0.
get();
12560 PerformImplicitConversion(Args[1], Best->BuiltinParamTypes[1],
12561 Best->Conversions[1], AA_Passing);
12564 Args[1] = ArgsRes1.
get();
12571 if (CandidateSet.
empty())
12572 Diag(LLoc, diag::err_ovl_no_oper)
12576 Diag(LLoc, diag::err_ovl_no_viable_subscript)
12585 Diag(LLoc, diag::err_ovl_ambiguous_oper_binary)
12594 Diag(LLoc, diag::err_ovl_deleted_oper)
12595 << Best->Function->isDeleted() <<
"[]" 12596 << getDeletedOrUnavailableSuffix(Best->Function)
12604 return CreateBuiltinArraySubscriptExpr(Args[0], LLoc, Args[1], RLoc);
12627 if (
BinaryOperator *op = dyn_cast<BinaryOperator>(NakedMemExpr)) {
12629 assert(op->getOpcode() == BO_PtrMemD || op->getOpcode() == BO_PtrMemI);
12642 QualType objectType = op->getLHS()->getType();
12643 if (op->getOpcode() == BO_PtrMemI)
12645 Qualifiers objectQuals = objectType.getQualifiers();
12647 Qualifiers difference = objectQuals - funcQuals;
12651 std::string qualsString = difference.
getAsString();
12652 Diag(LParenLoc, diag::err_pointer_to_member_call_drops_quals)
12653 << fnType.getUnqualifiedType()
12655 << (qualsString.find(
' ') == std::string::npos ? 1 : 2);
12660 resultType, valueKind, RParenLoc);
12662 if (CheckCallReturnType(proto->
getReturnType(), op->getRHS()->getLocStart(),
12666 if (ConvertArgumentsForCall(call, op,
nullptr, proto, Args, RParenLoc))
12669 if (CheckOtherCall(call, proto))
12672 return MaybeBindToTemporary(call);
12675 if (isa<CXXPseudoDestructorExpr>(NakedMemExpr))
12676 return new (Context)
12679 UnbridgedCastsSet UnbridgedCasts;
12687 if (isa<MemberExpr>(NakedMemExpr)) {
12688 MemExpr = cast<MemberExpr>(NakedMemExpr);
12692 UnbridgedCasts.restore();
12710 TemplateArgs = &TemplateArgsBuffer;
12714 E = UnresExpr->
decls_end(); I != E; ++I) {
12718 if (isa<UsingShadowDecl>(Func))
12719 Func = cast<UsingShadowDecl>(Func)->getTargetDecl();
12723 if (getLangOpts().MicrosoftExt && isa<CXXConstructorDecl>(Func)) {
12724 AddOverloadCandidate(cast<CXXConstructorDecl>(Func), I.getPair(),
12725 Args, CandidateSet);
12726 }
else if ((Method = dyn_cast<CXXMethodDecl>(Func))) {
12732 AddMethodCandidate(Method, I.getPair(), ActingDC, ObjectType,
12733 ObjectClassification, Args, CandidateSet,
12736 AddMethodTemplateCandidate(
12737 cast<FunctionTemplateDecl>(Func), I.getPair(), ActingDC,
12738 TemplateArgs, ObjectType, ObjectClassification, Args, CandidateSet,
12745 UnbridgedCasts.restore();
12748 switch (CandidateSet.BestViableFunction(*
this, UnresExpr->
getLocStart(),
12751 Method = cast<CXXMethodDecl>(Best->Function);
12752 FoundDecl = Best->FoundDecl;
12753 CheckUnresolvedMemberAccess(UnresExpr, Best->FoundDecl);
12754 if (DiagnoseUseOfDecl(Best->FoundDecl, UnresExpr->
getNameLoc()))
12762 if (Method != FoundDecl.getDecl() &&
12763 DiagnoseUseOfDecl(Method, UnresExpr->
getNameLoc()))
12769 diag::err_ovl_no_viable_member_function_in_call)
12784 << Best->Function->isDeleted()
12786 << getDeletedOrUnavailableSuffix(Best->Function)
12793 MemExprE = FixOverloadedFunctionReference(MemExprE, FoundDecl, Method);
12798 return BuildResolvedCallExpr(MemExprE, Method, LParenLoc, Args,
12807 ResultType = ResultType.getNonLValueExprType(Context);
12809 assert(Method &&
"Member call to something that isn't a method?");
12812 ResultType, VK, RParenLoc);
12824 PerformObjectArgumentInitialization(MemExpr->
getBase(), Qualifier,
12825 FoundDecl, Method);
12834 if (ConvertArgumentsForCall(TheCall, MemExpr, Method, Proto, Args,
12838 DiagnoseSentinelCalls(Method, LParenLoc, Args);
12840 if (CheckFunctionCall(Method, TheCall, Proto))
12846 if (
auto *MemE = dyn_cast<MemberExpr>(NakedMemExpr)) {
12847 if (
const EnableIfAttr *
Attr = CheckEnableIf(Method, Args,
true)) {
12848 Diag(MemE->getMemberLoc(),
12849 diag::err_ovl_no_viable_member_function_in_call)
12852 diag::note_ovl_candidate_disabled_by_function_cond_attr)
12853 <<
Attr->getCond()->getSourceRange() <<
Attr->getMessage();
12858 if ((isa<CXXConstructorDecl>(CurContext) ||
12859 isa<CXXDestructorDecl>(CurContext)) &&
12866 diag::warn_call_to_pure_virtual_member_function_from_ctor_dtor)
12867 << MD->
getDeclName() << isa<CXXDestructorDecl>(CurContext)
12871 if (getLangOpts().AppleKext)
12873 diag::note_pure_qualified_call_kext)
12882 bool CallCanBeVirtual = !MemExpr->
hasQualifier() || getLangOpts().AppleKext;
12883 CheckVirtualDtorCall(DD, MemExpr->
getLocStart(),
false,
12884 CallCanBeVirtual,
true,
12888 return MaybeBindToTemporary(TheCall);
12904 UnbridgedCastsSet UnbridgedCasts;
12908 assert(Object.
get()->getType()->isRecordType() &&
12909 "Requires object type argument");
12923 if (RequireCompleteType(LParenLoc, Object.
get()->getType(),
12924 diag::err_incomplete_object_call, Object.
get()))
12927 LookupResult R(*
this, OpName, LParenLoc, LookupOrdinaryName);
12928 LookupQualifiedName(R, Record->getDecl());
12932 Oper != OperEnd; ++Oper) {
12933 AddMethodCandidate(Oper.getPair(), Object.
get()->getType(),
12934 Object.
get()->Classify(Context), Args, CandidateSet,
12955 const auto &Conversions =
12956 cast<CXXRecordDecl>(Record->getDecl())->getVisibleConversionFunctions();
12957 for (
auto I = Conversions.begin(), E = Conversions.end(); I != E; ++I) {
12960 if (isa<UsingShadowDecl>(D))
12961 D = cast<UsingShadowDecl>(D)->getTargetDecl();
12965 if (isa<FunctionTemplateDecl>(D))
12978 AddSurrogateCandidate(Conv, I.getPair(), ActingContext, Proto,
12979 Object.
get(), Args, CandidateSet);
12984 bool HadMultipleCandidates = (CandidateSet.size() > 1);
12988 switch (CandidateSet.BestViableFunction(*
this, Object.
get()->getLocStart(),
12996 if (CandidateSet.empty())
12997 Diag(Object.
get()->getLocStart(), diag::err_ovl_no_oper)
12998 << Object.
get()->getType() << 1
12999 << Object.
get()->getSourceRange();
13001 Diag(Object.
get()->getLocStart(),
13002 diag::err_ovl_no_viable_object_call)
13003 << Object.
get()->getType() << Object.
get()->getSourceRange();
13008 Diag(Object.
get()->getLocStart(),
13009 diag::err_ovl_ambiguous_object_call)
13010 << Object.
get()->getType() << Object.
get()->getSourceRange();
13015 Diag(Object.
get()->getLocStart(),
13016 diag::err_ovl_deleted_object_call)
13017 << Best->Function->isDeleted()
13018 << Object.
get()->getType()
13019 << getDeletedOrUnavailableSuffix(Best->Function)
13020 << Object.
get()->getSourceRange();
13025 if (Best == CandidateSet.end())
13028 UnbridgedCasts.restore();
13030 if (Best->Function ==
nullptr) {
13034 = cast<CXXConversionDecl>(
13035 Best->Conversions[0].UserDefined.ConversionFunction);
13037 CheckMemberOperatorAccess(LParenLoc, Object.
get(),
nullptr,
13039 if (DiagnoseUseOfDecl(Best->FoundDecl, LParenLoc))
13041 assert(Conv == Best->FoundDecl.getDecl() &&
13042 "Found Decl & conversion-to-functionptr should be same, right?!");
13049 ExprResult Call = BuildCXXMemberCallExpr(Object.
get(), Best->FoundDecl,
13050 Conv, HadMultipleCandidates);
13051 if (Call.isInvalid())
13055 CK_UserDefinedConversion, Call.get(),
13058 return ActOnCallExpr(S, Call.get(), LParenLoc, Args, RParenLoc);
13061 CheckMemberOperatorAccess(LParenLoc, Object.
get(),
nullptr, Best->FoundDecl);
13066 CXXMethodDecl *Method = cast<CXXMethodDecl>(Best->Function);
13069 if (Method->isInvalidDecl())
13081 Obj, HadMultipleCandidates,
13082 OpLocInfo.getLoc(),
13083 OpLocInfo.getInfo());
13090 MethodArgs[0] = Object.
get();
13091 std::copy(Args.begin(), Args.end(), MethodArgs.begin() + 1);
13095 QualType ResultTy = Method->getReturnType();
13097 ResultTy = ResultTy.getNonLValueExprType(Context);
13103 if (CheckCallReturnType(Method->getReturnType(), LParenLoc, TheCall, Method))
13108 if (Args.size() < NumParams)
13109 TheCall->
setNumArgs(Context, NumParams + 1);
13111 bool IsError =
false;
13115 PerformObjectArgumentInitialization(Object.
get(),
nullptr,
13116 Best->FoundDecl, Method);
13121 TheCall->setArg(0, Object.
get());
13124 for (
unsigned i = 0; i != NumParams; i++) {
13126 if (i < Args.size()) {
13134 Method->getParamDecl(i)),
13141 = BuildCXXDefaultArgExpr(LParenLoc, Method, Method->getParamDecl(i));
13150 TheCall->setArg(i + 1, Arg);
13156 for (
unsigned i = NumParams, e = Args.size(); i < e; i++) {
13157 ExprResult Arg = DefaultVariadicArgumentPromotion(Args[i], VariadicMethod,
13160 TheCall->setArg(i + 1, Arg.
get());
13164 if (IsError)
return true;
13166 DiagnoseSentinelCalls(Method, LParenLoc, Args);
13168 if (CheckFunctionCall(Method, TheCall, Proto))
13171 return MaybeBindToTemporary(TheCall);
13179 bool *NoArrowOperatorFound) {
13181 "left-hand side must have class type");
13199 if (RequireCompleteType(Loc, Base->
getType(),
13200 diag::err_typecheck_incomplete_tag, Base))
13203 LookupResult R(*
this, OpName, OpLoc, LookupOrdinaryName);
13204 LookupQualifiedName(R, BaseRecord->
getDecl());
13208 Oper != OperEnd; ++Oper) {
13209 AddMethodCandidate(Oper.getPair(), Base->
getType(), Base->
Classify(Context),
13210 None, CandidateSet,
false);
13213 bool HadMultipleCandidates = (CandidateSet.
size() > 1);
13223 if (CandidateSet.
empty()) {
13225 if (NoArrowOperatorFound) {
13228 *NoArrowOperatorFound =
true;
13231 Diag(OpLoc, diag::err_typecheck_member_reference_arrow)
13234 Diag(OpLoc, diag::note_typecheck_member_reference_suggestion)
13238 Diag(OpLoc, diag::err_ovl_no_viable_oper)
13244 Diag(OpLoc, diag::err_ovl_ambiguous_oper_unary)
13250 Diag(OpLoc, diag::err_ovl_deleted_oper)
13251 << Best->Function->isDeleted()
13253 << getDeletedOrUnavailableSuffix(Best->Function)
13259 CheckMemberOperatorAccess(OpLoc, Base,
nullptr, Best->FoundDecl);
13262 CXXMethodDecl *Method = cast<CXXMethodDecl>(Best->Function);
13264 PerformObjectArgumentInitialization(Base,
nullptr,
13265 Best->FoundDecl, Method);
13266 if (BaseResult.isInvalid())
13268 Base = BaseResult.get();
13272 Base, HadMultipleCandidates, OpLoc);
13281 Base, ResultTy, VK, OpLoc,
FPOptions());
13283 if (CheckCallReturnType(Method->
getReturnType(), OpLoc, TheCall, Method))
13286 if (CheckFunctionCall(Method, TheCall,
13290 return MaybeBindToTemporary(TheCall);
13304 AddFunctionCandidates(R.
asUnresolvedSet(), Args, CandidateSet, TemplateArgs,
13307 bool HadMultipleCandidates = (CandidateSet.size() > 1);
13312 switch (CandidateSet.BestViableFunction(*
this, UDSuffixLoc, Best)) {
13318 Diag(UDSuffixLoc, diag::err_ovl_no_viable_function_in_call)
13331 nullptr, HadMultipleCandidates,
13340 for (
unsigned ArgIdx = 0, N = Args.size(); ArgIdx != N; ++ArgIdx) {
13341 ExprResult InputInit = PerformCopyInitialization(
13346 ConvArgs[ArgIdx] = InputInit.
get();
13355 llvm::makeArrayRef(ConvArgs, Args.size()),
13356 ResultTy, VK, LitEndLoc, UDSuffixLoc);
13358 if (CheckCallReturnType(FD->
getReturnType(), UDSuffixLoc, UDL, FD))
13361 if (CheckFunctionCall(FD, UDL,
nullptr))
13364 return MaybeBindToTemporary(UDL);
13381 Scope *S =
nullptr;
13384 if (!MemberLookup.
empty()) {
13386 BuildMemberReferenceExpr(Range, Range->
getType(), Loc,
13394 return FRS_DiagnosticIssued;
13396 *CallExpr = ActOnCallExpr(S, MemberRef.
get(), Loc, None, Loc,
nullptr);
13399 return FRS_DiagnosticIssued;
13407 FoundNames.
begin(), FoundNames.
end());
13409 bool CandidateSetError = buildOverloadedCallSet(S, Fn, Fn, Range, Loc,
13410 CandidateSet, CallExpr);
13411 if (CandidateSet->
empty() || CandidateSetError) {
13413 return FRS_NoViableFunction;
13421 return FRS_NoViableFunction;
13424 Loc,
nullptr, CandidateSet, &Best,
13429 return FRS_DiagnosticIssued;
13432 return FRS_Success;
13443 if (
ParenExpr *PE = dyn_cast<ParenExpr>(E)) {
13444 Expr *SubExpr = FixOverloadedFunctionReference(PE->getSubExpr(),
13446 if (SubExpr == PE->getSubExpr())
13449 return new (Context)
ParenExpr(PE->getLParen(), PE->getRParen(), SubExpr);
13453 Expr *SubExpr = FixOverloadedFunctionReference(ICE->getSubExpr(),
13455 assert(Context.
hasSameType(ICE->getSubExpr()->getType(),
13457 "Implicit cast type cannot be determined from overload");
13458 assert(ICE->path_empty() &&
"fixing up hierarchy conversion?");
13459 if (SubExpr == ICE->getSubExpr())
13463 ICE->getCastKind(),
13468 if (
auto *GSE = dyn_cast<GenericSelectionExpr>(E)) {
13469 if (!GSE->isResultDependent()) {
13471 FixOverloadedFunctionReference(GSE->getResultExpr(), Found, Fn);
13472 if (SubExpr == GSE->getResultExpr())
13479 unsigned ResultIdx = GSE->getResultIndex();
13480 AssocExprs[ResultIdx] = SubExpr;
13483 Context, GSE->getGenericLoc(), GSE->getControllingExpr(),
13484 GSE->getAssocTypeSourceInfos(), AssocExprs, GSE->getDefaultLoc(),
13485 GSE->getRParenLoc(), GSE->containsUnexpandedParameterPack(),
13494 assert(UnOp->getOpcode() == UO_AddrOf &&
13495 "Can only take the address of an overloaded function");
13497 if (Method->isStatic()) {
13504 Expr *SubExpr = FixOverloadedFunctionReference(UnOp->getSubExpr(),
13506 if (SubExpr == UnOp->getSubExpr())
13509 assert(isa<DeclRefExpr>(SubExpr)
13510 &&
"fixed to something other than a decl ref");
13511 assert(cast<DeclRefExpr>(SubExpr)->getQualifier()
13512 &&
"fixed to a member ref with no nested name qualifier");
13518 = Context.
getTypeDeclType(cast<RecordDecl>(Method->getDeclContext()));
13523 (
void)isCompleteType(UnOp->getOperatorLoc(), MemPtrType);
13525 return new (Context)
UnaryOperator(SubExpr, UO_AddrOf, MemPtrType,
13527 UnOp->getOperatorLoc());
13530 Expr *SubExpr = FixOverloadedFunctionReference(UnOp->getSubExpr(),
13532 if (SubExpr == UnOp->getSubExpr())
13538 UnOp->getOperatorLoc());
13551 if (ULE->hasExplicitTemplateArgs()) {
13552 ULE->copyTemplateArgumentsInto(TemplateArgsBuffer);
13553 TemplateArgs = &TemplateArgsBuffer;
13557 ULE->getQualifierLoc(),
13558 ULE->getTemplateKeywordLoc(),
13566 MarkDeclRefReferenced(DRE);
13574 if (MemExpr->hasExplicitTemplateArgs()) {
13575 MemExpr->copyTemplateArgumentsInto(TemplateArgsBuffer);
13576 TemplateArgs = &TemplateArgsBuffer;
13583 if (MemExpr->isImplicitAccess()) {
13584 if (cast<CXXMethodDecl>(Fn)->isStatic()) {
13586 MemExpr->getQualifierLoc(),
13587 MemExpr->getTemplateKeywordLoc(),
13590 MemExpr->getMemberLoc(),
13595 MarkDeclRefReferenced(DRE);
13600 if (MemExpr->getQualifier())
13601 Loc = MemExpr->getQualifierLoc().getBeginLoc();
13602 CheckCXXThisCapture(Loc);
13604 MemExpr->getBaseType(),
13608 Base = MemExpr->getBase();
13612 if (cast<CXXMethodDecl>(Fn)->isStatic()) {
13621 Context, Base, MemExpr->isArrow(), MemExpr->getOperatorLoc(),
13622 MemExpr->getQualifierLoc(), MemExpr->getTemplateKeywordLoc(), Fn, Found,
13623 MemExpr->getMemberNameInfo(), TemplateArgs,
type, valueKind,
13626 MarkMemberReferenced(ME);
13630 llvm_unreachable(
"Invalid reference to overloaded function");
13636 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 4.13)
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.
SmallVector< TemplateSpecCandidate, 16 >::iterator iterator
(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.
An instance of this class is created to represent 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+...
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.
ActionResult< Expr * > ExprResult
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)
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)
NamespaceDecl - 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.
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.
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.
ParmVarDecl - Represents a parameter to a function.
QualType getLocalUnqualifiedType() const
Return this type with all of the instance-specific qualifiers removed, but without removing any quali...
Defines the clang::Expr interface and subclasses for C++ expressions.
TemplateParameter Param
The template parameter to which a template argument deduction failure refers.
static 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.
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...
RecordDecl - Represents a struct/union/class.
DeclarationName getDeclName() const
getDeclName - 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++ 4.12)
TargetCXXABI getCXXABI() const
Get the C++ ABI currently in use.
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.
llvm::mapped_iterator< decltype(Decls)::iterator, select_second > iterator
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
FieldDecl - An instance of this class is created by Sema::ActOnField to represent a member of a struc...
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++ 4.8)
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++ 4.6)
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)
bool UnwrapSimilarPointerTypes(QualType &T1, QualType &T2)
UnwrapSimilarPointerTypes - If T1 and T2 are pointer types that may be similar (C++ 4...
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++ 4.4)
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++ 4.5)
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 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)
SourceLocation getLocEnd() const LLVM_READONLY
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...
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...
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...
const FunctionProtoType * T
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...
SmallVectorImpl< OverloadCandidate >::iterator iterator
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 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
char __ovld __cnfn min(char x, char y)
Returns y if y < x, otherwise it returns x.
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++ 4.9)
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.
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.
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++ 4.1)
bool isConstQualified() const
Determine whether this type is const-qualified.
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...
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++ 4.7)
void AddBuiltinCandidate(QualType *ParamTys, ArrayRef< Expr *> Args, OverloadCandidateSet &CandidateSet, bool IsAssignmentOperator=false, unsigned NumContextualBoolArguments=0)
AddBuiltinCandidate - Add a candidate for a built-in operator.
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.
NarrowingKind getNarrowingKind(ASTContext &Context, const Expr *Converted, APValue &ConstantValue, QualType &ConstantType) const
Check if this standard conversion sequence represents a narrowing conversion, according to C++11 [dcl...
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...
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...
void AddMemberOperatorCandidates(OverloadedOperatorKind Op, SourceLocation OpLoc, ArrayRef< Expr *> Args, OverloadCandidateSet &CandidateSet, SourceRange OpRange=SourceRange())
Add overload candidates for overloaded operators that are member functions.
Represents a call to a member function that may be written either with member call syntax (e...
A vector splat from an arithmetic type.
IncompatiblePointer - The assignment is between two pointers types that are not compatible, but we accept them as an extension.
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...
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.
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++ 4.10)
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 ...
std::pair< SourceLocation, PartialDiagnostic > PartialDiagnosticAt
A partial diagnostic along with the source location where this diagnostic occurs. ...
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.
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.
SourceLocation getLocStart() const LLVM_READONLY
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.
MutableArrayRef< Expr * > MultiExprArg
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.
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.
ConversionSet::const_iterator const_iterator
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.
static bool hasSimilarType(ASTContext &Context, QualType T1, QualType T2)
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)
bool DiagnoseUseOfDecl(NamedDecl *D, SourceLocation Loc, const ObjCInterfaceDecl *UnknownObjCClass=nullptr, bool ObjCPropertyAccess=false, bool AvoidPartialAvailabilityChecks=false)
Determine whether the use of this declaration is valid, and emit any corresponding diagnostics...
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++ 4.2)
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.
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 isObjCQualifiedIdType() const
DeclAccessPair FoundDecl
FoundDecl - The original declaration that was looked up / invented / otherwise found, together with its access.
Base for LValueReferenceType and RValueReferenceType.
CanQualType BoundMemberTy
bool hasSameType(QualType T1, QualType T2) const
Determine whether the given types T1 and T2 are equivalent.
AccessResult CheckMemberOperatorAccess(SourceLocation Loc, Expr *ObjectExpr, Expr *ArgExpr, DeclAccessPair FoundDecl)
Checks access to an overloaded member operator, including conversion operators.
TemplateSpecCandidate - This is a generalization of OverloadCandidate which keeps track of template a...
Block Pointer conversions.
Deduction failed; that's all we know.
virtual bool hasFloat128Type() const
Determine whether the __float128 type is supported on this target.
static FixItHint CreateInsertion(SourceLocation InsertionLoc, StringRef Code, bool BeforePreviousInsertions=false)
Create a code modification hint that inserts the given code string at a specific location.
bool canAssignObjCInterfaces(const ObjCObjectPointerType *LHSOPT, const ObjCObjectPointerType *RHSOPT)
canAssignObjCInterfaces - Return true if the two interface types are compatible for assignment from R...
Implements a partial diagnostic that can be emitted anwyhere in a DiagnosticBuilder stream...
Sema::LookupNameKind getLookupKind() const
Gets the kind of lookup to perform.
QualType getNonLValueExprType(const ASTContext &Context) const
Determine the type of a (typically non-lvalue) expression with the specified result type...
static ExprResult BuildRecoveryCallExpr(Sema &SemaRef, Scope *S, Expr *Fn, UnresolvedLookupExpr *ULE, SourceLocation LParenLoc, MutableArrayRef< Expr *> Args, SourceLocation RParenLoc, bool EmptyLookup, bool AllowTypoCorrection)
Attempts to recover from a call where no functions were found.
APValue - This class implements a discriminated union of [uninitialized] [APSInt] [APFloat]...
virtual bool hasInt128Type() const
Determine whether the __int128 type is supported on this target.
static bool tryAtomicConversion(Sema &S, Expr *From, QualType ToType, bool InOverloadResolution, StandardConversionSequence &SCS, bool CStyle)
Determine whether this is a conversion from a scalar type to an atomic type.
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.
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++ 4.3)
MemberExpr - [C99 6.5.2.3] Structure and Union Members.
QualType getToType() const
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
getName - 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
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.
unsigned getAddressSpaceAttributePrintValue() const
Get the address space attribute value to be printed by diagnostics.
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...
NamedDecl - This represents a decl with 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++ 4.11)
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.
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.
SourceLocation getLocStart() const LLVM_READONLY
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;})
PrintOverloadCandidates - When overload resolution fails, prints diagnostic messages containing the c...
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).
SourceLocation getLocStart() const LLVM_READONLY
static void DiagnoseFailedEnableIfAttr(Sema &S, OverloadCandidate *Cand)