30 #include "llvm/ADT/DenseSet.h" 31 #include "llvm/ADT/Optional.h" 32 #include "llvm/ADT/STLExtras.h" 33 #include "llvm/ADT/SmallPtrSet.h" 34 #include "llvm/ADT/SmallString.h" 38 using namespace clang;
43 return P->hasAttr<PassObjectSizeAttr>();
50 const Expr *
Base,
bool HadMultipleCandidates,
67 if (HadMultipleCandidates)
72 CK_FunctionToPointerDecay);
76 bool InOverloadResolution,
79 bool AllowObjCWritebackConversion);
83 bool InOverloadResolution,
91 bool AllowObjCConversionOnExplicit);
144 return Rank[(int)Kind];
154 "Function-to-pointer",
155 "Function pointer conversion",
157 "Integral promotion",
158 "Floating point promotion",
160 "Integral conversion",
161 "Floating conversion",
162 "Complex conversion",
163 "Floating-integral conversion",
164 "Pointer conversion",
165 "Pointer-to-member conversion",
166 "Boolean conversion",
167 "Compatible-types conversion",
168 "Derived-to-base conversion",
171 "Complex-real conversion",
172 "Block Pointer conversion",
173 "Transparent Union Conversion",
174 "Writeback conversion",
175 "OpenCL Zero Event Conversion",
176 "C specific type conversion",
177 "Incompatible pointer conversion" 188 DeprecatedStringLiteralToCharPtr =
false;
189 QualificationIncludesObjCLifetime =
false;
190 ReferenceBinding =
false;
191 DirectBinding =
false;
192 IsLvalueReference =
true;
193 BindsToFunctionLvalue =
false;
194 BindsToRvalue =
false;
195 BindsImplicitObjectArgumentWithoutRefQualifier =
false;
196 ObjCLifetimeConversionBinding =
false;
197 CopyConstructor =
nullptr;
224 (getFromType()->isPointerType() ||
225 getFromType()->isMemberPointerType() ||
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();
295 QualType &ConstantType,
bool IgnoreFloatToIntegralConversion)
const {
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)) {
330 }
else if (FromType->isIntegralOrUnscopedEnumerationType() &&
332 if (IgnoreFloatToIntegralConversion)
334 llvm::APSInt IntConstantValue;
336 assert(Initializer &&
"Unknown conversion expression");
345 Result.convertFromAPInt(IntConstantValue, IntConstantValue.isSigned(),
346 llvm::APFloat::rmNearestTiesToEven);
348 llvm::APSInt ConvertedValue = IntConstantValue;
350 Result.convertToInteger(ConvertedValue,
351 llvm::APFloat::rmTowardZero, &ignored);
353 if (IntConstantValue != ConvertedValue) {
354 ConstantValue =
APValue(IntConstantValue);
355 ConstantType = Initializer->
getType();
381 assert(ConstantValue.
isFloat());
382 llvm::APFloat FloatVal = ConstantValue.
getFloat();
385 llvm::APFloat::opStatus ConvertStatus = FloatVal.convert(
387 llvm::APFloat::rmNearestTiesToEven, &ignored);
390 if (ConvertStatus & llvm::APFloat::opOverflow) {
391 ConstantType = Initializer->
getType();
406 IntegralConversion: {
407 assert(FromType->isIntegralOrUnscopedEnumerationType());
409 const bool FromSigned = FromType->isSignedIntegerOrEnumerationType();
410 const unsigned FromWidth = Ctx.
getIntWidth(FromType);
414 if (FromWidth > ToWidth ||
415 (FromWidth == ToWidth && FromSigned != ToSigned) ||
416 (FromSigned && !ToSigned)) {
418 llvm::APSInt InitializerValue;
429 bool Narrowing =
false;
430 if (FromWidth < ToWidth) {
433 if (InitializerValue.isSigned() && InitializerValue.isNegative())
438 InitializerValue = InitializerValue.extend(
439 InitializerValue.getBitWidth() + 1);
441 llvm::APSInt ConvertedValue = InitializerValue;
442 ConvertedValue = ConvertedValue.trunc(ToWidth);
443 ConvertedValue.setIsSigned(ToSigned);
444 ConvertedValue = ConvertedValue.extend(InitializerValue.getBitWidth());
445 ConvertedValue.setIsSigned(InitializerValue.isSigned());
447 if (ConvertedValue != InitializerValue)
451 ConstantType = Initializer->
getType();
452 ConstantValue =
APValue(InitializerValue);
468 raw_ostream &OS = llvm::errs();
469 bool PrintedSomething =
false;
472 PrintedSomething =
true;
476 if (PrintedSomething) {
481 if (CopyConstructor) {
482 OS <<
" (by copy constructor)";
483 }
else if (DirectBinding) {
484 OS <<
" (direct reference binding)";
485 }
else if (ReferenceBinding) {
486 OS <<
" (reference binding)";
488 PrintedSomething =
true;
492 if (PrintedSomething) {
496 PrintedSomething =
true;
499 if (!PrintedSomething) {
500 OS <<
"No conversions required";
507 raw_ostream &OS = llvm::errs();
508 if (Before.First || Before.Second || Before.Third) {
512 if (ConversionFunction)
513 OS <<
'\'' << *ConversionFunction <<
'\'';
515 OS <<
"aggregate initialization";
525 raw_ostream &OS = llvm::errs();
526 if (isStdInitializerListElement())
527 OS <<
"Worst std::initializer_list element conversion: ";
528 switch (ConversionKind) {
529 case StandardConversion:
530 OS <<
"Standard conversion: ";
533 case UserDefinedConversion:
534 OS <<
"User-defined conversion: ";
537 case EllipsisConversion:
538 OS <<
"Ellipsis conversion";
540 case AmbiguousConversion:
541 OS <<
"Ambiguous conversion";
544 OS <<
"Bad conversion";
556 conversions().~ConversionSet();
569 struct DFIArguments {
575 struct DFIParamWithArguments : DFIArguments {
580 struct DFIDeducedMismatchArgs : DFIArguments {
582 unsigned CallArgIndex;
593 Result.
Result =
static_cast<unsigned>(TDK);
602 Result.
Data =
nullptr;
607 Result.
Data = Info.
Param.getOpaqueValue();
613 auto *Saved =
new (Context) DFIDeducedMismatchArgs;
616 Saved->TemplateArgs = Info.
take();
624 DFIArguments *Saved =
new (Context) DFIArguments;
636 DFIParamWithArguments *Saved =
new (Context) DFIParamWithArguments;
637 Saved->Param = Info.
Param;
656 llvm_unreachable(
"not a deduction failure");
663 switch (static_cast<Sema::TemplateDeductionResult>(Result)) {
689 Diag->~PartialDiagnosticAt();
690 HasDiagnostic =
false;
707 switch (static_cast<Sema::TemplateDeductionResult>(Result)) {
723 return TemplateParameter::getFromOpaqueValue(Data);
728 return static_cast<DFIParamWithArguments*
>(Data)->Param;
739 switch (static_cast<Sema::TemplateDeductionResult>(Result)) {
757 return static_cast<DFIDeducedMismatchArgs*
>(Data)->TemplateArgs;
771 switch (static_cast<Sema::TemplateDeductionResult>(Result)) {
790 return &
static_cast<DFIArguments*
>(Data)->FirstArg;
801 switch (static_cast<Sema::TemplateDeductionResult>(Result)) {
820 return &
static_cast<DFIArguments*
>(Data)->SecondArg;
831 switch (static_cast<Sema::TemplateDeductionResult>(Result)) {
834 return static_cast<DFIDeducedMismatchArgs*
>(Data)->CallArgIndex;
841 void OverloadCandidateSet::destroyCandidates() {
842 for (iterator
i = begin(), e = end();
i != e; ++
i) {
843 for (
auto &C :
i->Conversions)
844 C.~ImplicitConversionSequence();
846 i->DeductionFailure.Destroy();
852 SlabAllocator.Reset();
853 NumInlineBytesUsed = 0;
860 class UnbridgedCastsSet {
870 Entry entry = { &E, E };
871 Entries.push_back(entry);
877 i = Entries.begin(), e = Entries.end();
i != e; ++
i)
892 UnbridgedCastsSet *unbridgedCasts =
nullptr) {
896 if (placeholder->getKind() == BuiltinType::Overload)
return false;
900 if (placeholder->getKind() == BuiltinType::ARCUnbridgedCast &&
902 unbridgedCasts->save(S, E);
923 UnbridgedCastsSet &unbridged) {
924 for (
unsigned i = 0, e = Args.size();
i != e; ++
i)
966 NamedDecl *&Match,
bool NewIsUsingDecl) {
971 bool OldIsUsingDecl =
false;
972 if (isa<UsingShadowDecl>(OldD)) {
973 OldIsUsingDecl =
true;
977 if (NewIsUsingDecl)
continue;
979 OldD = cast<UsingShadowDecl>(OldD)->getTargetDecl();
984 if ((OldIsUsingDecl || NewIsUsingDecl) && !isVisible(*I))
992 bool UseMemberUsingDeclRules =
993 (OldIsUsingDecl || NewIsUsingDecl) && CurContext->isRecord() &&
997 if (!IsOverload(New, OldF, UseMemberUsingDeclRules)) {
998 if (UseMemberUsingDeclRules && OldIsUsingDecl) {
999 HideUsingShadowDecl(S, cast<UsingShadowDecl>(*I));
1003 if (!isa<FunctionTemplateDecl>(OldD) &&
1004 !shouldLinkPossiblyHiddenDecl(*I, New))
1013 if (!getASTContext().canBuiltinBeRedeclared(OldF)) {
1015 return Ovl_NonFunction;
1017 }
else if (isa<UsingDecl>(OldD) || isa<UsingPackDecl>(OldD)) {
1021 }
else if (isa<TagDecl>(OldD)) {
1023 }
else if (
auto *UUD = dyn_cast<UnresolvedUsingValueDecl>(OldD)) {
1030 if (UUD->getQualifier()->isDependent() && !UUD->isCXXClassMember()) {
1032 return Ovl_NonFunction;
1039 return Ovl_NonFunction;
1064 if (CheckFunctionTemplateSpecialization(New,
nullptr, TemplateSpecResult,
1067 return Ovl_Overload;
1074 return Ovl_Overload;
1078 bool UseMemberUsingDeclRules,
bool ConsiderCudaAttrs) {
1093 if ((OldTemplate ==
nullptr) != (NewTemplate ==
nullptr))
1106 if (isa<FunctionNoProtoType>(OldQType.
getTypePtr()) ||
1107 isa<FunctionNoProtoType>(NewQType.
getTypePtr()))
1116 if (OldQType != NewQType &&
1118 OldType->
isVariadic() != NewType->isVariadic() ||
1119 !FunctionParamTypesAreEqual(OldType, NewType)))
1134 if (!UseMemberUsingDeclRules && NewTemplate &&
1137 false, TPL_TemplateMatch) ||
1152 if (OldMethod && NewMethod &&
1153 !OldMethod->
isStatic() && !NewMethod->isStatic()) {
1155 if (!UseMemberUsingDeclRules &&
1157 NewMethod->getRefQualifier() ==
RQ_None)) {
1164 Diag(NewMethod->getLocation(), diag::err_ref_qualifier_overload)
1176 auto NewQuals = NewMethod->getMethodQualifiers();
1177 if (!getLangOpts().
CPlusPlus14 && NewMethod->isConstexpr() &&
1178 !isa<CXXConstructorDecl>(NewMethod))
1181 OldQuals.removeRestrict();
1182 NewQuals.removeRestrict();
1183 if (OldQuals != NewQuals)
1201 NewI != NewE || OldI != OldE; ++NewI, ++OldI) {
1202 if (NewI == NewE || OldI == OldE)
1204 llvm::FoldingSetNodeID NewID, OldID;
1205 NewI->getCond()->Profile(NewID, Context,
true);
1206 OldI->getCond()->Profile(OldID, Context,
true);
1211 if (getLangOpts().CUDA && ConsiderCudaAttrs) {
1214 if (isa<CXXDestructorDecl>(New))
1218 OldTarget = IdentifyCUDATarget(Old);
1219 if (NewTarget == CFT_InvalidTarget)
1222 assert((OldTarget != CFT_InvalidTarget) &&
"Unexpected invalid target.");
1226 return NewTarget != OldTarget;
1239 bool SuppressUserConversions,
1241 bool InOverloadResolution,
1243 bool AllowObjCWritebackConversion,
1244 bool AllowObjCConversionOnExplicit) {
1247 if (SuppressUserConversions) {
1258 Conversions, AllowExplicit,
1259 AllowObjCConversionOnExplicit)) {
1276 if (Constructor->isCopyConstructor() &&
1277 (FromCanon == ToCanon ||
1288 if (ToCanon != FromCanon)
1299 Cand != Conversions.
end(); ++Cand)
1342 bool SuppressUserConversions,
1344 bool InOverloadResolution,
1346 bool AllowObjCWritebackConversion,
1347 bool AllowObjCConversionOnExplicit) {
1350 ICS.
Standard, CStyle, AllowObjCWritebackConversion)){
1390 AllowExplicit, InOverloadResolution, CStyle,
1391 AllowObjCWritebackConversion,
1392 AllowObjCConversionOnExplicit);
1397 bool SuppressUserConversions,
1399 bool InOverloadResolution,
1401 bool AllowObjCWritebackConversion) {
1403 SuppressUserConversions, AllowExplicit,
1404 InOverloadResolution, CStyle,
1405 AllowObjCWritebackConversion,
1418 return PerformImplicitConversion(From, ToType, Action, AllowExplicit, ICS);
1429 bool AllowObjCWritebackConversion
1430 = getLangOpts().ObjCAutoRefCount &&
1431 (Action == AA_Passing || Action == AA_Sending);
1432 if (getLangOpts().ObjC)
1433 CheckObjCBridgeRelatedConversions(From->
getBeginLoc(), ToType,
1440 AllowObjCWritebackConversion,
1442 return PerformImplicitConversion(From, ToType, ICS, Action);
1463 if (TyClass != CanFrom->getTypeClass())
return false;
1464 if (TyClass != Type::FunctionProto && TyClass != Type::FunctionNoProto) {
1465 if (TyClass == Type::Pointer) {
1468 }
else if (TyClass == Type::BlockPointer) {
1471 }
else if (TyClass == Type::MemberPointer) {
1475 if (ToMPT->getClass() != FromMPT->
getClass())
1477 CanTo = ToMPT->getPointeeType();
1483 TyClass = CanTo->getTypeClass();
1484 if (TyClass != CanFrom->getTypeClass())
return false;
1485 if (TyClass != Type::FunctionProto && TyClass != Type::FunctionNoProto)
1489 const auto *FromFn = cast<FunctionType>(CanFrom);
1492 const auto *ToFn = cast<FunctionType>(CanTo);
1495 bool Changed =
false;
1498 if (FromEInfo.getNoReturn() && !ToEInfo.getNoReturn()) {
1504 if (
const auto *FromFPT = dyn_cast<FunctionProtoType>(FromFn)) {
1505 const auto *ToFPT = cast<FunctionProtoType>(ToFn);
1506 if (FromFPT->isNothrow() && !ToFPT->isNothrow()) {
1507 FromFn = cast<FunctionType>(
1518 bool CanUseToFPT, CanUseFromFPT;
1520 CanUseFromFPT, NewParamInfos) &&
1521 CanUseToFPT && !CanUseFromFPT) {
1524 NewParamInfos.empty() ? nullptr : NewParamInfos.data();
1526 FromFPT->getParamTypes(), ExtInfo);
1535 assert(
QualType(FromFn, 0).isCanonical());
1536 if (
QualType(FromFn, 0) != CanTo)
return false;
1588 bool InOverloadResolution,
1601 bool InOverloadResolution,
1604 bool AllowObjCWritebackConversion) {
1651 if (Method && !Method->
isStatic()) {
1653 "Non-unary operator on non-static member address");
1654 assert(cast<UnaryOperator>(From->
IgnoreParens())->getOpcode()
1656 "Non-address-of operator on non-static member address");
1657 const Type *ClassType
1661 assert(cast<UnaryOperator>(From->
IgnoreParens())->getOpcode() ==
1663 "Non-address-of operator for overloaded function expression");
1690 FromType = Atomic->getValueType();
1725 if (
auto *FD = dyn_cast<FunctionDecl>(DRE->getDecl()))
1745 bool IncompatibleObjC =
false;
1796 if (Float128AndLongDouble &&
1798 &llvm::APFloat::PPCDoubleDouble()))
1813 }
else if (AllowObjCWritebackConversion &&
1817 FromType, IncompatibleObjC)) {
1823 InOverloadResolution, FromType)) {
1835 InOverloadResolution,
1866 bool ObjCLifetimeConversion;
1872 ObjCLifetimeConversion)) {
1891 CanonFrom = CanonTo;
1896 if (CanonFrom == CanonTo)
1901 if (S.
getLangOpts().CPlusPlus || !InOverloadResolution)
1945 bool InOverloadResolution,
1955 for (
const auto *it : UD->
fields()) {
1958 ToType = it->getType();
1988 return To->
getKind() == BuiltinType::Int;
1991 return To->
getKind() == BuiltinType::UInt;
2015 if (FromEnumType->getDecl()->isScoped())
2022 if (FromEnumType->getDecl()->isFixed()) {
2023 QualType Underlying = FromEnumType->getDecl()->getIntegerType();
2025 IsIntegralPromotion(
nullptr, Underlying, ToType);
2032 ToType, FromEnumType->getDecl()->getPromotionType());
2039 if (getLangOpts().CPlusPlus)
2057 uint64_t FromSize = Context.
getTypeSize(FromType);
2066 for (
int Idx = 0; Idx < 6; ++Idx) {
2067 uint64_t ToSize = Context.
getTypeSize(PromoteTypes[Idx]);
2068 if (FromSize < ToSize ||
2069 (FromSize == ToSize &&
2070 FromIsSigned == PromoteTypes[Idx]->isSignedIntegerType())) {
2095 llvm::APSInt BitWidth;
2097 MemberDecl->getBitWidth()->isIntegerConstantExpr(BitWidth, Context)) {
2098 llvm::APSInt ToSize(BitWidth.getBitWidth(), BitWidth.isUnsigned());
2102 if (BitWidth < ToSize ||
2104 return To->
getKind() == BuiltinType::Int;
2110 return To->
getKind() == BuiltinType::UInt;
2135 if (FromBuiltin->getKind() == BuiltinType::Float &&
2136 ToBuiltin->getKind() == BuiltinType::Double)
2142 if (!getLangOpts().CPlusPlus &&
2143 (FromBuiltin->getKind() == BuiltinType::Float ||
2144 FromBuiltin->getKind() == BuiltinType::Double) &&
2145 (ToBuiltin->getKind() == BuiltinType::LongDouble ||
2146 ToBuiltin->getKind() == BuiltinType::Float128))
2150 if (!getLangOpts().NativeHalfType &&
2151 FromBuiltin->getKind() == BuiltinType::Half &&
2152 ToBuiltin->getKind() == BuiltinType::Float)
2189 bool StripObjCLifetime =
false) {
2192 "Invalid similarly-qualified pointer type");
2203 if (StripObjCLifetime)
2214 if (isa<ObjCObjectPointerType>(ToType))
2223 if (isa<ObjCObjectPointerType>(ToType))
2229 bool InOverloadResolution,
2235 return !InOverloadResolution;
2259 bool InOverloadResolution,
2261 bool &IncompatibleObjC) {
2262 IncompatibleObjC =
false;
2263 if (isObjCPointerConversion(FromType, ToType, ConvertedType,
2270 ConvertedType = ToType;
2277 ConvertedType = ToType;
2284 ConvertedType = ToType;
2292 ConvertedType = ToType;
2302 ConvertedType = ToType;
2310 !getLangOpts().ObjCAutoRefCount) {
2341 if (getLangOpts().MSVCCompat && FromPointeeType->
isFunctionType() &&
2375 IsDerivedFrom(From->
getBeginLoc(), FromPointeeType, ToPointeeType)) {
2412 bool &IncompatibleObjC) {
2413 if (!getLangOpts().ObjC)
2425 if (ToObjCPtr && FromObjCPtr) {
2436 if (getLangOpts().
CPlusPlus && LHS && RHS &&
2438 FromObjCPtr->getPointeeType()))
2443 ConvertedType =
AdoptQualifiers(Context, ConvertedType, FromQualifiers);
2451 IncompatibleObjC =
true;
2455 ConvertedType =
AdoptQualifiers(Context, ConvertedType, FromQualifiers);
2467 if (FromObjCPtr && FromObjCPtr->isObjCBuiltinType()) {
2495 isObjCPointerConversion(FromPointeeType, ToPointeeType, ConvertedType,
2496 IncompatibleObjC)) {
2498 IncompatibleObjC =
true;
2500 ConvertedType =
AdoptQualifiers(Context, ConvertedType, FromQualifiers);
2507 isObjCPointerConversion(FromPointeeType, ToPointeeType, ConvertedType,
2508 IncompatibleObjC)) {
2511 ConvertedType =
AdoptQualifiers(Context, ConvertedType, FromQualifiers);
2523 if (FromFunctionType && ToFunctionType) {
2532 if (FromFunctionType->
getNumParams() != ToFunctionType->getNumParams() ||
2533 FromFunctionType->
isVariadic() != ToFunctionType->isVariadic() ||
2534 FromFunctionType->
getMethodQuals() != ToFunctionType->getMethodQuals())
2537 bool HasObjCConversion =
false;
2541 }
else if (isObjCPointerConversion(FromFunctionType->
getReturnType(),
2542 ToFunctionType->getReturnType(),
2543 ConvertedType, IncompatibleObjC)) {
2545 HasObjCConversion =
true;
2552 for (
unsigned ArgIdx = 0, NumArgs = FromFunctionType->
getNumParams();
2553 ArgIdx != NumArgs; ++ArgIdx) {
2555 QualType ToArgType = ToFunctionType->getParamType(ArgIdx);
2559 }
else if (isObjCPointerConversion(FromArgType, ToArgType,
2560 ConvertedType, IncompatibleObjC)) {
2562 HasObjCConversion =
true;
2569 if (HasObjCConversion) {
2573 IncompatibleObjC =
true;
2592 if (!getLangOpts().ObjCAutoRefCount ||
2634 bool IncompatibleObjC;
2636 FromPointee = ToPointee;
2637 else if (!isObjCPointerConversion(FromPointee, ToPointee, FromPointee,
2672 if (!FromFunctionType || !ToFunctionType)
2675 if (Context.
hasSameType(FromPointeeType, ToPointeeType))
2680 if (FromFunctionType->
getNumParams() != ToFunctionType->getNumParams() ||
2681 FromFunctionType->
isVariadic() != ToFunctionType->isVariadic())
2686 if (FromEInfo != ToEInfo)
2689 bool IncompatibleObjC =
false;
2691 ToFunctionType->getReturnType())) {
2695 QualType LHS = ToFunctionType->getReturnType();
2702 }
else if (isObjCPointerConversion(RHS, LHS,
2703 ConvertedType, IncompatibleObjC)) {
2704 if (IncompatibleObjC)
2713 for (
unsigned ArgIdx = 0, NumArgs = FromFunctionType->
getNumParams();
2714 ArgIdx != NumArgs; ++ArgIdx) {
2715 IncompatibleObjC =
false;
2717 QualType ToArgType = ToFunctionType->getParamType(ArgIdx);
2718 if (Context.
hasSameType(FromArgType, ToArgType)) {
2720 }
else if (isObjCPointerConversion(ToArgType, FromArgType,
2721 ConvertedType, IncompatibleObjC)) {
2722 if (IncompatibleObjC)
2731 bool CanUseToFPT, CanUseFromFPT;
2733 CanUseToFPT, CanUseFromFPT,
2737 ConvertedType = ToType;
2813 if (!FromFunction || !ToFunction) {
2818 if (FromFunction->
getNumParams() != ToFunction->getNumParams()) {
2826 if (!FunctionParamTypesAreEqual(FromFunction, ToFunction, &ArgPos)) {
2828 << ToFunction->getParamType(ArgPos)
2835 ToFunction->getReturnType())) {
2841 if (FromFunction->
getMethodQuals() != ToFunction->getMethodQuals()) {
2851 cast<FunctionProtoType>(ToFunction->getCanonicalTypeUnqualified())
2871 O && (O != E); ++O, ++N) {
2873 N->getUnqualifiedType())) {
2891 bool IgnoreBaseAccess,
2894 bool IsCStyleOrFunctionalCast = IgnoreBaseAccess;
2898 if (Diagnose && !IsCStyleOrFunctionalCast && !FromType->
isAnyPointerType() &&
2902 DiagRuntimeBehavior(From->
getExprLoc(), From,
2903 PDiag(diag::warn_impcast_bool_to_null_pointer)
2905 else if (!isUnevaluatedContext())
2914 if (FromPointeeType->
isRecordType() && ToPointeeType->isRecordType() &&
2918 unsigned InaccessibleID = 0;
2919 unsigned AmbigiousID = 0;
2921 InaccessibleID = diag::err_upcast_to_inaccessible_base;
2922 AmbigiousID = diag::err_ambiguous_derived_to_base_conv;
2924 if (CheckDerivedToBaseConversion(
2925 FromPointeeType, ToPointeeType, InaccessibleID, AmbigiousID,
2927 &BasePath, IgnoreBaseAccess))
2931 Kind = CK_DerivedToBase;
2934 if (Diagnose && !IsCStyleOrFunctionalCast &&
2935 FromPointeeType->
isFunctionType() && ToPointeeType->isVoidType()) {
2936 assert(getLangOpts().MSVCCompat &&
2937 "this should only be possible with MSVCCompat!");
2949 if (FromPtrType->isObjCBuiltinType() || ToPtrType->isObjCBuiltinType())
2952 Kind = CK_BlockPointerToObjCPointerCast;
2954 Kind = CK_CPointerToObjCPointerCast;
2958 Kind = CK_AnyPointerToBlockPointerCast;
2964 Kind = CK_NullToPointer;
2976 bool InOverloadResolution,
2986 ConvertedType = ToType;
3001 IsDerivedFrom(From->
getBeginLoc(), ToClass, FromClass)) {
3019 bool IgnoreBaseAccess) {
3026 "Expr must be null pointer constant!");
3027 Kind = CK_NullToMemberPointer;
3032 assert(ToPtrType &&
"No member pointer cast has a target type " 3033 "that is not a member pointer.");
3039 assert(FromClass->
isRecordType() &&
"Pointer into non-class.");
3040 assert(ToClass->isRecordType() &&
"Pointer into non-class.");
3044 bool DerivationOkay =
3045 IsDerivedFrom(From->
getBeginLoc(), ToClass, FromClass, Paths);
3046 assert(DerivationOkay &&
3047 "Should not have been called if derivation isn't OK.");
3048 (void)DerivationOkay;
3051 getUnqualifiedType())) {
3052 std::string PathDisplayStr = getAmbiguousPathsDisplayString(Paths);
3054 << 0 << FromClass << ToClass << PathDisplayStr << From->
getSourceRange();
3058 if (
const RecordType *VBase = Paths.getDetectedVirtual()) {
3060 << FromClass << ToClass <<
QualType(VBase, 0)
3065 if (!IgnoreBaseAccess)
3066 CheckBaseClassAccess(From->
getExprLoc(), FromClass, ToClass,
3068 diag::err_downcast_from_inaccessible_base);
3072 Kind = CK_BaseToDerivedMemberPointer;
3097 bool CStyle,
bool &ObjCLifetimeConversion) {
3100 ObjCLifetimeConversion =
false;
3110 bool PreviousToQualsIncludeConst =
true;
3111 bool UnwrappedAnyPointer =
false;
3119 UnwrappedAnyPointer =
true;
3131 UnwrappedAnyPointer) {
3134 ObjCLifetimeConversion =
true;
3159 && !PreviousToQualsIncludeConst)
3164 PreviousToQualsIncludeConst
3165 = PreviousToQualsIncludeConst && ToQuals.
hasConst();
3191 bool InOverloadResolution,
3200 InOverloadResolution, InnerSCS,
3204 SCS.
Second = InnerSCS.Second;
3205 SCS.
setToType(1, InnerSCS.getToType(1));
3206 SCS.
Third = InnerSCS.Third;
3208 = InnerSCS.QualificationIncludesObjCLifetime;
3209 SCS.
setToType(2, InnerSCS.getToType(2));
3231 bool AllowExplicit) {
3238 bool Usable = !Info.Constructor->isInvalidDecl() &&
3240 (AllowExplicit || !Info.Constructor->isExplicit());
3245 S.
Context, Info.Constructor, ToType);
3246 if (Info.ConstructorTmpl)
3249 CandidateSet, SuppressUserConversions,
3254 CandidateSet, SuppressUserConversions,
3255 false, AllowExplicit);
3259 bool HadMultipleCandidates = (CandidateSet.
size() > 1);
3262 switch (
auto Result =
3286 llvm_unreachable(
"Invalid OverloadResult!");
3308 bool AllowObjCConversionOnExplicit) {
3309 assert(AllowExplicit || !AllowObjCConversionOnExplicit);
3313 bool ConstructorsOnly =
false;
3329 ConstructorsOnly =
true;
3334 = dyn_cast<CXXRecordDecl>(ToRecordType->getDecl())) {
3336 Expr **Args = &From;
3337 unsigned NumArgs = 1;
3338 bool ListInitializing =
false;
3339 if (
InitListExpr *InitList = dyn_cast<InitListExpr>(From)) {
3342 S, From, ToType, ToRecordDecl, User, CandidateSet, AllowExplicit);
3351 Args = InitList->getInits();
3352 NumArgs = InitList->getNumInits();
3353 ListInitializing =
true;
3361 bool Usable = !Info.Constructor->isInvalidDecl();
3362 if (ListInitializing)
3363 Usable = Usable && (AllowExplicit || !Info.Constructor->isExplicit());
3366 Info.Constructor->isConvertingConstructor(AllowExplicit);
3368 bool SuppressUserConversions = !ConstructorsOnly;
3369 if (SuppressUserConversions && ListInitializing) {
3370 SuppressUserConversions =
false;
3375 S.
Context, Info.Constructor, ToType);
3378 if (Info.ConstructorTmpl)
3380 Info.ConstructorTmpl, Info.FoundDecl,
3381 nullptr, llvm::makeArrayRef(Args, NumArgs),
3382 CandidateSet, SuppressUserConversions,
3383 false, AllowExplicit);
3388 llvm::makeArrayRef(Args, NumArgs),
3389 CandidateSet, SuppressUserConversions,
3390 false, AllowExplicit);
3397 if (ConstructorsOnly || isa<InitListExpr>(From)) {
3400 }
else if (
const RecordType *FromRecordType =
3403 = dyn_cast<CXXRecordDecl>(FromRecordType->getDecl())) {
3405 const auto &Conversions = FromRecordDecl->getVisibleConversionFunctions();
3406 for (
auto I = Conversions.
begin(), E = Conversions.
end(); I != E; ++I) {
3410 if (isa<UsingShadowDecl>(D))
3411 D = cast<UsingShadowDecl>(D)->getTargetDecl();
3415 if ((ConvTemplate = dyn_cast<FunctionTemplateDecl>(D)))
3418 Conv = cast<CXXConversionDecl>(D);
3420 if (AllowExplicit || !Conv->isExplicit()) {
3423 ConvTemplate, FoundDecl, ActingContext, From, ToType,
3424 CandidateSet, AllowObjCConversionOnExplicit, AllowExplicit);
3427 Conv, FoundDecl, ActingContext, From, ToType, CandidateSet,
3428 AllowObjCConversionOnExplicit, AllowExplicit);
3434 bool HadMultipleCandidates = (CandidateSet.
size() > 1);
3437 switch (
auto Result =
3443 = dyn_cast<CXXConstructorDecl>(Best->Function)) {
3450 QualType ThisType = Constructor->getThisType();
3451 if (isa<InitListExpr>(From)) {
3455 if (Best->Conversions[0].isEllipsis())
3458 User.
Before = Best->Conversions[0].Standard;
3471 = dyn_cast<CXXConversionDecl>(Best->Function)) {
3478 User.
Before = Best->Conversions[0].Standard;
3493 User.
After = Best->FinalConversion;
3496 llvm_unreachable(
"Not a constructor or conversion function?");
3505 llvm_unreachable(
"Invalid OverloadResult!");
3515 CandidateSet,
false,
false);
3526 if (!RequireCompleteType(From->
getBeginLoc(), ToType,
3527 diag::err_typecheck_nonviable_condition_incomplete,
3533 CandidateSet.NoteCandidates(
3534 *
this, From, Cands);
3564 if (Block1 != Block2)
3651 if (!ICS1.
isBad()) {
3784 else if (Rank2 < Rank1)
3805 bool SCS1ConvertsToVoid
3807 bool SCS2ConvertsToVoid
3809 if (SCS1ConvertsToVoid != SCS2ConvertsToVoid) {
3814 }
else if (!SCS1ConvertsToVoid && !SCS2ConvertsToVoid) {
3820 }
else if (SCS1ConvertsToVoid && SCS2ConvertsToVoid &&
3849 if (FromObjCPtr1 && FromObjCPtr2) {
3854 if (AssignLeft != AssignRight) {
3887 if (UnqualT1 == UnqualT2) {
3899 if (isa<ArrayType>(T1) && T1Quals)
3901 if (isa<ArrayType>(T2) && T2Quals)
3947 if (SCS1IsCompatibleVectorConversion != SCS2IsCompatibleVectorConversion)
3948 return SCS1IsCompatibleVectorConversion
3985 if (UnqualT1 == UnqualT2)
3990 if (isa<ArrayType>(T1) && T1Quals)
3992 if (isa<ArrayType>(T2) && T2Quals)
4118 if (FromPointee1 == FromPointee2 && ToPointee1 != ToPointee2) {
4126 if (FromPointee1 != FromPointee2 && ToPointee1 == ToPointee2) {
4143 if (FromPtr1 && FromPtr2 && ToPtr1 && ToPtr2) {
4150 bool FromAssignRight
4159 if (ToPtr1->isObjCIdType() &&
4160 (ToPtr2->isObjCQualifiedIdType() || ToPtr2->getInterfaceDecl()))
4162 if (ToPtr2->isObjCIdType() &&
4163 (ToPtr1->isObjCQualifiedIdType() || ToPtr1->getInterfaceDecl()))
4168 if (ToPtr1->isObjCQualifiedIdType() && ToPtr2->getInterfaceDecl())
4170 if (ToPtr2->isObjCQualifiedIdType() && ToPtr1->getInterfaceDecl())
4175 if (ToPtr1->isObjCClassType() &&
4176 (ToPtr2->isObjCQualifiedClassType() || ToPtr2->getInterfaceDecl()))
4178 if (ToPtr2->isObjCClassType() &&
4179 (ToPtr1->isObjCQualifiedClassType() || ToPtr1->getInterfaceDecl()))
4184 if (ToPtr1->isObjCQualifiedClassType() && ToPtr2->getInterfaceDecl())
4186 if (ToPtr2->isObjCQualifiedClassType() && ToPtr1->getInterfaceDecl())
4192 (ToAssignLeft != ToAssignRight)) {
4203 }
else if (IsSecondSame)
4212 (FromAssignLeft != FromAssignRight))
4230 const Type *FromPointeeType1 = FromMemPointer1->
getClass();
4231 const Type *ToPointeeType1 = ToMemPointer1->getClass();
4232 const Type *FromPointeeType2 = FromMemPointer2->getClass();
4233 const Type *ToPointeeType2 = ToMemPointer2->getClass();
4239 if (FromPointee1 == FromPointee2 && ToPointee1 != ToPointee2) {
4246 if (ToPointee1 == ToPointee2 && FromPointee1 != FromPointee2) {
4287 return !Record->isInvalidDecl();
4302 bool &DerivedToBase,
4303 bool &ObjCConversion,
4304 bool &ObjCLifetimeConversion) {
4306 "T1 must be the pointee type of the reference type");
4307 assert(!OrigT2->
isReferenceType() &&
"T2 cannot be a reference type");
4319 DerivedToBase =
false;
4320 ObjCConversion =
false;
4321 ObjCLifetimeConversion =
false;
4323 if (UnqualT1 == UnqualT2) {
4325 }
else if (isCompleteType(Loc, OrigT2) &&
4327 IsDerivedFrom(Loc, UnqualT2, UnqualT1))
4328 DerivedToBase =
true;
4332 ObjCConversion =
true;
4334 IsFunctionConversion(UnqualT2, UnqualT1, ConvertedT2))
4341 return Ref_Compatible;
4343 return Ref_Incompatible;
4350 if (isa<ArrayType>(T1) && T1Quals)
4352 if (isa<ArrayType>(T2) && T2Quals)
4370 ObjCLifetimeConversion =
true;
4381 return Ref_Compatible;
4392 bool AllowExplicit) {
4393 assert(T2->
isRecordType() &&
"Can only find conversions of record types.");
4399 const auto &Conversions = T2RecordDecl->getVisibleConversionFunctions();
4400 for (
auto I = Conversions.begin(), E = Conversions.end(); I != E; ++I) {
4403 if (isa<UsingShadowDecl>(D))
4404 D = cast<UsingShadowDecl>(D)->getTargetDecl();
4412 Conv = cast<CXXConversionDecl>(D);
4416 if (!AllowExplicit && Conv->isExplicit())
4420 bool DerivedToBase =
false;
4421 bool ObjCConversion =
false;
4422 bool ObjCLifetimeConversion =
false;
4433 if (!ConvTemplate &&
4436 Conv->getConversionType().getNonReferenceType()
4437 .getUnqualifiedType(),
4439 DerivedToBase, ObjCConversion, ObjCLifetimeConversion) ==
4457 ConvTemplate, I.getPair(), ActingDC, Init, DeclType, CandidateSet,
4458 false, AllowExplicit);
4461 Conv, I.getPair(), ActingDC, Init, DeclType, CandidateSet,
4462 false, AllowExplicit);
4465 bool HadMultipleCandidates = (CandidateSet.size() > 1);
4468 switch (CandidateSet.BestViableFunction(S, DeclLoc, Best)) {
4480 if (!Best->FinalConversion.DirectBinding)
4492 "Expected a direct reference binding!");
4498 Cand != CandidateSet.end(); ++Cand)
4510 llvm_unreachable(
"Invalid OverloadResult!");
4518 bool SuppressUserConversions,
4519 bool AllowExplicit) {
4520 assert(DeclType->
isReferenceType() &&
"Reference init needs a reference");
4541 bool DerivedToBase =
false;
4542 bool ObjCConversion =
false;
4543 bool ObjCLifetimeConversion =
false;
4547 ObjCConversion, ObjCLifetimeConversion);
4575 ICS.Standard.setToType(0, T2);
4576 ICS.Standard.setToType(1, T1);
4577 ICS.Standard.setToType(2, T1);
4578 ICS.Standard.ReferenceBinding =
true;
4579 ICS.Standard.DirectBinding =
true;
4580 ICS.Standard.IsLvalueReference = !isRValRef;
4582 ICS.Standard.BindsToRvalue =
false;
4583 ICS.Standard.BindsImplicitObjectArgumentWithoutRefQualifier =
false;
4584 ICS.Standard.ObjCLifetimeConversionBinding = ObjCLifetimeConversion;
4585 ICS.Standard.CopyConstructor =
nullptr;
4586 ICS.Standard.DeprecatedStringLiteralToCharPtr =
false;
4633 ICS.Standard.setToType(0, T2);
4634 ICS.Standard.setToType(1, T1);
4635 ICS.Standard.setToType(2, T1);
4636 ICS.Standard.ReferenceBinding =
true;
4642 ICS.Standard.DirectBinding =
4645 ICS.Standard.IsLvalueReference = !isRValRef;
4647 ICS.Standard.BindsToRvalue = InitCategory.
isRValue();
4648 ICS.Standard.BindsImplicitObjectArgumentWithoutRefQualifier =
false;
4649 ICS.Standard.ObjCLifetimeConversionBinding = ObjCLifetimeConversion;
4650 ICS.Standard.CopyConstructor =
nullptr;
4651 ICS.Standard.DeprecatedStringLiteralToCharPtr =
false;
4674 if (ICS.isUserDefined() && isRValRef &&
4746 if (ICS.isStandard()) {
4747 ICS.Standard.ReferenceBinding =
true;
4748 ICS.Standard.IsLvalueReference = !isRValRef;
4749 ICS.Standard.BindsToFunctionLvalue =
false;
4750 ICS.Standard.BindsToRvalue =
true;
4751 ICS.Standard.BindsImplicitObjectArgumentWithoutRefQualifier =
false;
4752 ICS.Standard.ObjCLifetimeConversionBinding =
false;
4753 }
else if (ICS.isUserDefined()) {
4755 ICS.UserDefined.ConversionFunction->getReturnType()
4772 ICS.UserDefined.After.ReferenceBinding =
true;
4773 ICS.UserDefined.After.IsLvalueReference = !isRValRef;
4774 ICS.UserDefined.After.BindsToFunctionLvalue =
false;
4775 ICS.UserDefined.After.BindsToRvalue = !LValRefType;
4776 ICS.UserDefined.After.BindsImplicitObjectArgumentWithoutRefQualifier =
false;
4777 ICS.UserDefined.After.ObjCLifetimeConversionBinding =
false;
4785 bool SuppressUserConversions,
4786 bool InOverloadResolution,
4787 bool AllowObjCWritebackConversion,
4788 bool AllowExplicit =
false);
4794 bool SuppressUserConversions,
4795 bool InOverloadResolution,
4796 bool AllowObjCWritebackConversion) {
4825 SuppressUserConversions,
4826 InOverloadResolution,
4827 AllowObjCWritebackConversion);
4860 bool toStdInitializerList =
false;
4871 InOverloadResolution,
4872 AllowObjCWritebackConversion);
4909 InOverloadResolution,
false,
4910 AllowObjCWritebackConversion,
4967 Init, ToType,
false, Found))
4972 bool dummy1 =
false;
4973 bool dummy2 =
false;
4974 bool dummy3 =
false;
4981 SuppressUserConversions,
4989 InOverloadResolution,
4990 AllowObjCWritebackConversion);
4991 if (Result.isFailure())
4993 assert(!Result.isEllipsis() &&
4994 "Sub-initialization cannot result in ellipsis conversion.");
5000 Result.UserDefined.After;
5021 if (NumInits == 1 && !isa<InitListExpr>(From->
getInit(0)))
5023 SuppressUserConversions,
5024 InOverloadResolution,
5025 AllowObjCWritebackConversion);
5028 else if (NumInits == 0) {
5051 bool SuppressUserConversions,
5052 bool InOverloadResolution,
5053 bool AllowObjCWritebackConversion,
5054 bool AllowExplicit) {
5055 if (
InitListExpr *FromInitList = dyn_cast<InitListExpr>(From))
5057 InOverloadResolution,AllowObjCWritebackConversion);
5062 SuppressUserConversions, AllowExplicit);
5065 SuppressUserConversions,
5067 InOverloadResolution,
5069 AllowObjCWritebackConversion,
5082 return !ICS.
isBad();
5097 if (isa<CXXDestructorDecl>(Method)) {
5114 assert(FromClassification.
isLValue());
5140 != FromTypeCanon.getLocalCVRQualifiers() &&
5143 FromType, ImplicitParamType);
5147 if (FromTypeCanon.getQualifiers().hasAddressSpace()) {
5149 Qualifiers QualsFromType = FromTypeCanon.getQualifiers();
5152 FromType, ImplicitParamType);
5167 FromType, ImplicitParamType);
5187 if (!FromClassification.
isRValue()) {
5230 FromRecordType = From->
getType();
5231 DestType = ImplicitParamRecordType;
5232 FromClassification = From->
Classify(Context);
5236 From = CreateMaterializeTemporaryExpr(FromRecordType, From,
5248 switch (ICS.Bad.Kind) {
5255 << Method->getDeclName() << FromRecordType << (CVR - 1)
5257 Diag(Method->getLocation(), diag::note_previous_decl)
5258 << Method->getDeclName();
5266 bool IsRValueQualified =
5269 << Method->getDeclName() << FromClassification.
isRValue()
5270 << IsRValueQualified;
5271 Diag(Method->getLocation(), diag::note_previous_decl)
5272 << Method->getDeclName();
5281 return Diag(From->
getBeginLoc(), diag::err_member_function_call_bad_type)
5282 << ImplicitParamRecordType << FromRecordType
5288 PerformObjectMemberConversion(From, Qualifier, FoundDecl, Method);
5291 From = FromRes.
get();
5297 CK = CK_AddressSpaceConversion;
5300 From = ImpCastExprToType(From, DestType, CK, From->
getValueKind()).
get();
5326 return PerformImplicitConversion(From, Context.
BoolTy, ICS, AA_Converting);
5328 if (!DiagnoseMultipleUserDefinedConversion(From, Context.
BoolTy))
5388 llvm_unreachable(
"found a first conversion kind in Second");
5391 llvm_unreachable(
"found a third conversion kind in Second");
5397 llvm_unreachable(
"unknown conversion kind");
5408 "converted constant expression outside C++11");
5444 diag::err_typecheck_converted_constant_expression)
5449 llvm_unreachable(
"ellipsis conversion in converted constant expression");
5455 diag::err_typecheck_converted_constant_expression_disallowed)
5461 diag::err_typecheck_converted_constant_expression_indirect)
5474 PreNarrowingType)) {
5492 << CCE << 0 << From->
getType() << T;
5496 if (Result.
get()->isValueDependent()) {
5509 if (!Result.
get()->EvaluateAsConstantExpr(Eval, Usage, S.
Context) ||
5510 (RequireInt && !Eval.
Val.
isInt())) {
5517 if (Notes.empty()) {
5524 if (Notes.size() == 1 &&
5525 Notes[0].second.getDiagID() == diag::note_invalid_subexpr_in_const_expr)
5526 S.
Diag(Notes[0].first, diag::err_expr_not_cce) << CCE;
5530 for (
unsigned I = 0; I < Notes.size(); ++I)
5531 S.
Diag(Notes[I].first, Notes[I].second);
5542 llvm::APSInt &
Value,
5548 if (!R.isInvalid() && !R.get()->isValueDependent())
5611 return PerformImplicitConversion(From, Ty, ICS, AA_Converting);
5631 for (
unsigned I = 0, N = ViableConversions.
size(); I != N; ++I) {
5633 cast<CXXConversionDecl>(ViableConversions[I]->getUnderlyingDecl());
5643 QualType T,
bool HadMultipleCandidates,
5645 if (ExplicitConversions.
size() == 1 && !Converter.
Suppress) {
5653 std::string TypeStr;
5658 "static_cast<" + TypeStr +
">(")
5670 HadMultipleCandidates);
5675 CK_UserDefinedConversion, Result.
get(),
5676 nullptr, Result.
get()->getValueKind());
5683 QualType T,
bool HadMultipleCandidates,
5699 HadMultipleCandidates);
5704 CK_UserDefinedConversion, Result.
get(),
5705 nullptr, Result.
get()->getValueKind());
5723 for (
unsigned I = 0, N = ViableConversions.
size(); I != N; ++I) {
5727 if (isa<UsingShadowDecl>(D))
5728 D = cast<UsingShadowDecl>(D)->getTargetDecl();
5732 if ((ConvTemplate = dyn_cast<FunctionTemplateDecl>(D)))
5735 Conv = cast<CXXConversionDecl>(D);
5739 ConvTemplate, FoundDecl, ActingContext, From, ToType, CandidateSet,
5743 ToType, CandidateSet,
5778 From = result.
get();
5783 if (Converter.
match(T))
5784 return DefaultLvalueConversion(From);
5791 if (!RecordTy || !getLangOpts().CPlusPlus) {
5803 : Converter(Converter), From(From) {}
5808 } IncompleteDiagnoser(Converter, From);
5810 if (Converter.
Suppress ? !isCompleteType(Loc, T)
5811 : RequireCompleteType(Loc, T, IncompleteDiagnoser))
5818 const auto &Conversions =
5819 cast<CXXRecordDecl>(RecordTy->
getDecl())->getVisibleConversionFunctions();
5821 bool HadMultipleCandidates =
5822 (
std::distance(Conversions.begin(), Conversions.end()) > 1);
5826 bool HasUniqueTargetType =
true;
5829 for (
auto I = Conversions.begin(), E = Conversions.end(); I != E; ++I) {
5834 if (getLangOpts().CPlusPlus14)
5839 Conversion = cast<CXXConversionDecl>(D);
5841 assert((!ConvTemplate || getLangOpts().
CPlusPlus14) &&
5842 "Conversion operator templates are considered potentially " 5846 if (Converter.
match(CurToType) || ConvTemplate) {
5852 ExplicitConversions.
addDecl(I.getDecl(), I.getAccess());
5854 if (!ConvTemplate && getLangOpts().CPlusPlus14) {
5857 else if (HasUniqueTargetType &&
5859 HasUniqueTargetType =
false;
5861 ViableConversions.
addDecl(I.getDecl(), I.getAccess());
5866 if (getLangOpts().CPlusPlus14) {
5879 HadMultipleCandidates,
5880 ExplicitConversions))
5886 if (!HasUniqueTargetType)
5905 HadMultipleCandidates, Found))
5914 HadMultipleCandidates,
5915 ExplicitConversions))
5923 switch (ViableConversions.
size()) {
5926 HadMultipleCandidates,
5927 ExplicitConversions))
5937 HadMultipleCandidates, Found))
6000 bool PartialOverloading,
bool AllowExplicit,
bool AllowExplicitConversions,
6004 assert(Proto &&
"Functions without a prototype cannot be overloaded");
6006 "Use AddTemplateOverloadCandidate for function templates");
6008 if (
CXXMethodDecl *Method = dyn_cast<CXXMethodDecl>(Function)) {
6009 if (!isa<CXXConstructorDecl>(Method)) {
6017 AddMethodCandidate(Method, FoundDecl, Method->getParent(),
QualType(),
6019 CandidateSet, SuppressUserConversions,
6020 PartialOverloading, EarlyConversions);
6055 CandidateSet.
addCandidate(Args.size(), EarlyConversions);
6065 !Function->
getAttr<TargetAttr>()->isDefaultVersion()) {
6066 Candidate.
Viable =
false;
6078 IsDerivedFrom(Args[0]->getBeginLoc(), Args[0]->getType(),
6080 Candidate.
Viable =
false;
6093 if (Shadow && Args.size() == 1 && Constructor->
getNumParams() >= 1 &&
6101 Candidate.
Viable =
false;
6112 Candidate.
Viable =
false;
6122 if (TooManyArguments(NumParams, Args.size(), PartialOverloading) &&
6124 Candidate.
Viable =
false;
6135 if (Args.size() < MinRequiredArgs && !PartialOverloading) {
6137 Candidate.
Viable =
false;
6143 if (getLangOpts().CUDA)
6144 if (
const FunctionDecl *Caller = dyn_cast<FunctionDecl>(CurContext))
6149 if (!Caller->isImplicit() && !IsAllowedCUDACall(Caller, Function)) {
6150 Candidate.
Viable =
false;
6157 for (
unsigned ArgIdx = 0; ArgIdx < Args.size(); ++ArgIdx) {
6158 if (Candidate.
Conversions[ArgIdx].isInitialized()) {
6161 }
else if (ArgIdx < NumParams) {
6168 *
this, Args[ArgIdx], ParamType, SuppressUserConversions,
6171 getLangOpts().ObjCAutoRefCount, AllowExplicitConversions);
6173 Candidate.
Viable =
false;
6185 if (!AllowExplicit) {
6188 Candidate.
Viable =
false;
6194 if (EnableIfAttr *FailedAttr = CheckEnableIf(Function, Args)) {
6195 Candidate.
Viable =
false;
6201 if (LangOpts.OpenCL && isOpenCLDisabledDecl(Function)) {
6202 Candidate.
Viable =
false;
6211 if (Methods.size() <= 1)
6214 for (
unsigned b = 0, e = Methods.size();
b < e;
b++) {
6222 if (Args.size() < NumNamedArgs)
6225 for (
unsigned i = 0;
i < NumNamedArgs;
i++) {
6227 if (Args[
i]->isTypeDependent()) {
6233 Expr *argExpr = Args[
i];
6234 assert(argExpr &&
"SelectBestMethod(): missing expression");
6239 !param->
hasAttr<CFConsumedAttr>())
6240 argExpr = stripARCUnbridgedCast(argExpr);
6253 getLangOpts().ObjCAutoRefCount,
6257 if (ConversionState.
isBad() ||
6267 for (
unsigned i = NumNamedArgs, e = Args.size();
i < e; ++
i) {
6268 if (Args[
i]->isTypeDependent()) {
6272 ExprResult Arg = DefaultVariadicArgumentPromotion(Args[
i], VariadicMethod,
6281 if (Args.size() != NumNamedArgs)
6283 else if (Match && NumNamedArgs == 0 && Methods.size() > 1) {
6286 for (
unsigned b = 0, e = Methods.size();
b < e;
b++) {
6287 QualType ReturnT = Methods[
b]->getReturnType();
6303 bool MissingImplicitThis,
Expr *&ConvertedThis,
6307 assert(!isa<CXXConstructorDecl>(Method) &&
6308 "Shouldn't have `this` for ctors!");
6309 assert(!Method->
isStatic() &&
"Shouldn't have `this` for static methods!");
6311 ThisArg,
nullptr, Method, Method);
6314 ConvertedThis = R.get();
6316 if (
auto *MD = dyn_cast<CXXMethodDecl>(Function)) {
6318 assert((MissingImplicitThis || MD->isStatic() ||
6319 isa<CXXConstructorDecl>(MD)) &&
6320 "Expected `this` for non-ctor instance methods");
6322 ConvertedThis =
nullptr;
6330 for (
unsigned I = 0; I != ArgSizeNoVarargs; ++I) {
6339 ConvertedArgs.push_back(R.
get());
6347 for (
unsigned i = Args.size(), e = Function->
getNumParams();
i != e; ++
i) {
6362 ConvertedArgs.push_back(R.
get());
6372 bool MissingImplicitThis) {
6374 if (EnableIfAttrs.begin() == EnableIfAttrs.end())
6380 Expr *DiscardedThis;
6382 *
this, Function,
nullptr, Args, Trap,
6383 true, DiscardedThis, ConvertedArgs))
6384 return *EnableIfAttrs.begin();
6386 for (
auto *EIA : EnableIfAttrs) {
6390 if (EIA->getCond()->isValueDependent() ||
6391 !EIA->getCond()->EvaluateWithSubstitution(
6392 Result, Context, Function, llvm::makeArrayRef(ConvertedArgs)))
6395 if (!Result.
isInt() || !Result.
getInt().getBoolValue())
6401 template <
typename CheckFn>
6404 CheckFn &&IsSuccessful) {
6407 if (ArgDependent == DIA->getArgDependent())
6408 Attrs.push_back(DIA);
6415 auto WarningBegin = std::stable_partition(
6416 Attrs.begin(), Attrs.end(),
6417 [](
const DiagnoseIfAttr *DIA) {
return DIA->isError(); });
6421 auto ErrAttr = llvm::find_if(llvm::make_range(Attrs.begin(), WarningBegin),
6423 if (ErrAttr != WarningBegin) {
6424 const DiagnoseIfAttr *DIA = *ErrAttr;
6425 S.
Diag(Loc, diag::err_diagnose_if_succeeded) << DIA->getMessage();
6426 S.
Diag(DIA->getLocation(), diag::note_from_diagnose_if)
6427 << DIA->getParent() << DIA->getCond()->getSourceRange();
6431 for (
const auto *DIA : llvm::make_range(WarningBegin, Attrs.end()))
6432 if (IsSuccessful(DIA)) {
6433 S.
Diag(Loc, diag::warn_diagnose_if_succeeded) << DIA->getMessage();
6434 S.
Diag(DIA->getLocation(), diag::note_from_diagnose_if)
6435 << DIA->getParent() << DIA->getCond()->getSourceRange();
6442 const Expr *ThisArg,
6446 *
this, Function,
true, Loc,
6447 [&](
const DiagnoseIfAttr *DIA) {
6452 if (!DIA->getCond()->EvaluateWithSubstitution(
6453 Result, Context, cast<FunctionDecl>(DIA->getParent()), Args, ThisArg))
6455 return Result.
isInt() && Result.
getInt().getBoolValue();
6462 *
this, ND,
false, Loc,
6463 [&](
const DiagnoseIfAttr *DIA) {
6465 return DIA->getCond()->EvaluateAsBooleanCondition(Result, Context) &&
6476 bool SuppressUserConversions,
6477 bool PartialOverloading,
6478 bool FirstArgumentIsBase) {
6487 if (isa<CXXMethodDecl>(FD) && !cast<CXXMethodDecl>(FD)->isStatic()) {
6490 if (Args.size() > 0) {
6491 if (
Expr *E = Args[0]) {
6493 ObjectType = E->getType();
6499 ObjectClassification = E->Classify(Context);
6501 FunctionArgs = Args.slice(1);
6504 AddMethodTemplateCandidate(
6505 FunTmpl, F.getPair(),
6507 ExplicitTemplateArgs, ObjectType, ObjectClassification,
6508 FunctionArgs, CandidateSet, SuppressUserConversions,
6509 PartialOverloading);
6511 AddMethodCandidate(cast<CXXMethodDecl>(FD), F.getPair(),
6512 cast<CXXMethodDecl>(FD)->getParent(), ObjectType,
6513 ObjectClassification, FunctionArgs, CandidateSet,
6514 SuppressUserConversions, PartialOverloading);
6521 if (Args.size() > 0 &&
6522 (!Args[0] || (FirstArgumentIsBase && isa<CXXMethodDecl>(FD) &&
6523 !isa<CXXConstructorDecl>(FD)))) {
6524 assert(cast<CXXMethodDecl>(FD)->isStatic());
6525 FunctionArgs = Args.slice(1);
6528 AddTemplateOverloadCandidate(
6529 FunTmpl, F.getPair(), ExplicitTemplateArgs, FunctionArgs,
6530 CandidateSet, SuppressUserConversions, PartialOverloading);
6532 AddOverloadCandidate(FD, F.getPair(), FunctionArgs, CandidateSet,
6533 SuppressUserConversions, PartialOverloading);
6546 bool SuppressUserConversions) {
6550 if (isa<UsingShadowDecl>(Decl))
6551 Decl = cast<UsingShadowDecl>(Decl)->getTargetDecl();
6554 assert(isa<CXXMethodDecl>(TD->getTemplatedDecl()) &&
6555 "Expected a member function template");
6556 AddMethodTemplateCandidate(TD, FoundDecl, ActingContext,
6557 nullptr, ObjectType,
6558 ObjectClassification, Args, CandidateSet,
6559 SuppressUserConversions);
6561 AddMethodCandidate(cast<CXXMethodDecl>(Decl), FoundDecl, ActingContext,
6562 ObjectType, ObjectClassification, Args, CandidateSet,
6563 SuppressUserConversions);
6580 bool SuppressUserConversions,
6581 bool PartialOverloading,
6585 assert(Proto &&
"Methods without a prototype cannot be overloaded");
6586 assert(!isa<CXXConstructorDecl>(Method) &&
6587 "Use AddOverloadCandidate for constructors");
6605 CandidateSet.
addCandidate(Args.size() + 1, EarlyConversions);
6617 if (TooManyArguments(NumParams, Args.size(), PartialOverloading) &&
6619 Candidate.
Viable =
false;
6630 if (Args.size() < MinRequiredArgs && !PartialOverloading) {
6632 Candidate.
Viable =
false;
6646 *
this, CandidateSet.
getLocation(), ObjectType, ObjectClassification,
6647 Method, ActingContext);
6649 Candidate.
Viable =
false;
6656 if (getLangOpts().CUDA)
6657 if (
const FunctionDecl *Caller = dyn_cast<FunctionDecl>(CurContext))
6658 if (!IsAllowedCUDACall(Caller, Method)) {
6659 Candidate.Viable =
false;
6666 for (
unsigned ArgIdx = 0; ArgIdx < Args.size(); ++ArgIdx) {
6667 if (Candidate.Conversions[ArgIdx + 1].isInitialized()) {
6670 }
else if (ArgIdx < NumParams) {
6675 QualType ParamType = Proto->getParamType(ArgIdx);
6676 Candidate.Conversions[ArgIdx + 1]
6678 SuppressUserConversions,
6681 getLangOpts().ObjCAutoRefCount);
6682 if (Candidate.Conversions[ArgIdx + 1].isBad()) {
6683 Candidate.Viable =
false;
6691 Candidate.Conversions[ArgIdx + 1].setEllipsis();
6695 if (EnableIfAttr *FailedAttr = CheckEnableIf(Method, Args,
true)) {
6696 Candidate.Viable =
false;
6698 Candidate.DeductionFailure.Data = FailedAttr;
6702 if (Method->isMultiVersion() && Method->hasAttr<TargetAttr>() &&
6703 !Method->getAttr<TargetAttr>()->isDefaultVersion()) {
6704 Candidate.Viable =
false;
6721 bool SuppressUserConversions,
6722 bool PartialOverloading) {
6739 MethodTmpl, ExplicitTemplateArgs, Args, Specialization, Info,
6741 return CheckNonDependentConversions(
6742 MethodTmpl, ParamTypes, Args, CandidateSet, Conversions,
6743 SuppressUserConversions, ActingContext, ObjectType,
6744 ObjectClassification);
6747 CandidateSet.
addCandidate(Conversions.size(), Conversions);
6750 Candidate.
Viable =
false;
6753 cast<CXXMethodDecl>(Candidate.
Function)->isStatic() ||
6756 if (Result == TDK_NonDependentConversionFailure)
6768 assert(Specialization &&
"Missing member function template specialization?");
6769 assert(isa<CXXMethodDecl>(Specialization) &&
6770 "Specialization is not a member function?");
6771 AddMethodCandidate(cast<CXXMethodDecl>(Specialization), FoundDecl,
6772 ActingContext, ObjectType, ObjectClassification, Args,
6773 CandidateSet, SuppressUserConversions, PartialOverloading,
6784 bool PartialOverloading,
bool AllowExplicit,
ADLCallKind IsADLCandidate) {
6801 FunctionTemplate, ExplicitTemplateArgs, Args, Specialization, Info,
6803 return CheckNonDependentConversions(FunctionTemplate, ParamTypes,
6804 Args, CandidateSet, Conversions,
6805 SuppressUserConversions);
6808 CandidateSet.
addCandidate(Conversions.size(), Conversions);
6811 Candidate.
Viable =
false;
6817 isa<CXXMethodDecl>(Candidate.
Function) &&
6818 !isa<CXXConstructorDecl>(Candidate.
Function);
6820 if (Result == TDK_NonDependentConversionFailure)
6832 assert(Specialization &&
"Missing function template specialization?");
6833 AddOverloadCandidate(
6834 Specialization, FoundDecl, Args, CandidateSet, SuppressUserConversions,
6835 PartialOverloading, AllowExplicit,
6836 false, IsADLCandidate, Conversions);
6851 const bool AllowExplicit =
false;
6855 bool HasThisConversion = Method && !isa<CXXConstructorDecl>(Method);
6856 unsigned ThisConversions = HasThisConversion ? 1 : 0;
6868 if (HasThisConversion && !cast<CXXMethodDecl>(FD)->isStatic() &&
6871 *
this, CandidateSet.
getLocation(), ObjectType, ObjectClassification,
6872 Method, ActingContext);
6873 if (Conversions[0].isBad())
6877 for (
unsigned I = 0, N =
std::min(ParamTypes.size(), Args.size()); I != N;
6879 QualType ParamType = ParamTypes[I];
6881 Conversions[ThisConversions + I]
6883 SuppressUserConversions,
6886 getLangOpts().ObjCAutoRefCount,
6888 if (Conversions[ThisConversions + I].isBad())
6910 bool AllowObjCPointerConversion) {
6918 bool ObjCLifetimeConversion;
6920 ObjCLifetimeConversion))
6925 if (!AllowObjCPointerConversion)
6929 bool IncompatibleObjC =
false;
6945 bool AllowExplicit,
bool AllowResultConversion) {
6947 "Conversion function templates use AddTemplateConversionCandidate");
6954 if (getLangOpts().CPlusPlus14 && ConvType->isUndeducedType()) {
6955 if (DeduceReturnType(Conversion, From->
getExprLoc()))
6962 if (!AllowResultConversion &&
6971 AllowObjCConversionOnExplicit))
7001 = cast<CXXRecordDecl>(ImplicitParamType->
getAs<
RecordType>()->getDecl());
7005 From->
Classify(Context), Conversion, ConversionContext);
7008 Candidate.
Viable =
false;
7019 if (FromCanon == ToCanon ||
7020 IsDerivedFrom(CandidateSet.
getLocation(), FromCanon, ToCanon)) {
7021 Candidate.
Viable =
false;
7038 CK_FunctionToPointerDecay,
7042 if (!isCompleteType(From->
getBeginLoc(), ConversionType)) {
7043 Candidate.
Viable =
false;
7055 llvm::AlignedCharArray<alignof(CallExpr), sizeof(CallExpr) + sizeof(Stmt *)>
7058 Buffer.buffer, &ConversionFn, CallResultType, VK, From->
getBeginLoc());
7066 switch (ICS.getKind()) {
7076 Candidate.
Viable =
false;
7088 Candidate.
Viable =
false;
7095 Candidate.
Viable =
false;
7101 "Can only end up with a standard conversion sequence or failure");
7106 Candidate.
Viable =
false;
7111 if (EnableIfAttr *FailedAttr = CheckEnableIf(Conversion, None)) {
7112 Candidate.
Viable =
false;
7119 !Conversion->
getAttr<TargetAttr>()->isDefaultVersion()) {
7120 Candidate.
Viable =
false;
7134 bool AllowExplicit,
bool AllowResultConversion) {
7136 "Only conversion function templates permitted here");
7145 Specialization, Info)) {
7149 Candidate.
Viable =
false;
7161 assert(Specialization &&
"Missing function template specialization?");
7162 AddConversionCandidate(Specialization, FoundDecl, ActingDC, From, ToType,
7163 CandidateSet, AllowObjCConversionOnExplicit,
7164 AllowExplicit, AllowResultConversion);
7199 Object->
Classify(Context), Conversion, ActingContext);
7200 if (ObjectInit.
isBad()) {
7201 Candidate.
Viable =
false;
7212 Candidate.
Conversions[0].UserDefined.EllipsisConversion =
false;
7213 Candidate.
Conversions[0].UserDefined.HadMultipleCandidates =
false;
7214 Candidate.
Conversions[0].UserDefined.ConversionFunction = Conversion;
7215 Candidate.
Conversions[0].UserDefined.FoundConversionFunction = FoundDecl;
7218 Candidate.
Conversions[0].UserDefined.After.setAsIdentityConversion();
7226 if (Args.size() > NumParams && !Proto->
isVariadic()) {
7227 Candidate.
Viable =
false;
7234 if (Args.size() < NumParams) {
7236 Candidate.
Viable =
false;
7243 for (
unsigned ArgIdx = 0, N = Args.size(); ArgIdx != N; ++ArgIdx) {
7244 if (ArgIdx < NumParams) {
7255 getLangOpts().ObjCAutoRefCount);
7257 Candidate.
Viable =
false;
7269 if (EnableIfAttr *FailedAttr = CheckEnableIf(Conversion, None)) {
7270 Candidate.
Viable =
false;
7308 if (!isCompleteType(OpLoc, T1) && !T1Rec->isBeingDefined())
7311 if (!T1Rec->getDecl()->getDefinition())
7314 LookupResult Operators(*
this, OpName, OpLoc, LookupOrdinaryName);
7315 LookupQualifiedName(Operators, T1Rec->getDecl());
7319 OperEnd = Operators.
end();
7322 AddMethodCandidate(Oper.getPair(), Args[0]->getType(),
7323 Args[0]->Classify(Context), Args.slice(1),
7324 CandidateSet,
false);
7338 bool IsAssignmentOperator,
7339 unsigned NumContextualBoolArguments) {
7356 for (
unsigned ArgIdx = 0, N = Args.size(); ArgIdx != N; ++ArgIdx) {
7369 if (ArgIdx < NumContextualBoolArguments) {
7370 assert(ParamTys[ArgIdx] == Context.
BoolTy &&
7371 "Contextual conversion to bool requires bool type");
7377 ArgIdx == 0 && IsAssignmentOperator,
7380 getLangOpts().ObjCAutoRefCount);
7383 Candidate.
Viable =
false;
7396 class BuiltinCandidateTypeSet {
7398 typedef llvm::SetVector<QualType, SmallVector<QualType, 8>,
7399 llvm::SmallPtrSet<QualType, 8>> TypeSet;
7403 TypeSet PointerTypes;
7407 TypeSet MemberPointerTypes;
7411 TypeSet EnumerationTypes;
7415 TypeSet VectorTypes;
7418 bool HasNonRecordTypes;
7422 bool HasArithmeticOrEnumeralTypes;
7426 bool HasNullPtrType;
7435 bool AddPointerWithMoreQualifiedTypeVariants(
QualType Ty,
7437 bool AddMemberPointerWithMoreQualifiedTypeVariants(
QualType Ty);
7441 typedef TypeSet::iterator iterator;
7443 BuiltinCandidateTypeSet(
Sema &SemaRef)
7444 : HasNonRecordTypes(
false),
7445 HasArithmeticOrEnumeralTypes(
false),
7446 HasNullPtrType(
false),
7450 void AddTypesConvertedFrom(
QualType Ty,
7452 bool AllowUserConversions,
7453 bool AllowExplicitConversions,
7454 const Qualifiers &VisibleTypeConversionsQuals);
7457 iterator pointer_begin() {
return PointerTypes.begin(); }
7460 iterator pointer_end() {
return PointerTypes.end(); }
7463 iterator member_pointer_begin() {
return MemberPointerTypes.begin(); }
7466 iterator member_pointer_end() {
return MemberPointerTypes.end(); }
7469 iterator enumeration_begin() {
return EnumerationTypes.begin(); }
7472 iterator enumeration_end() {
return EnumerationTypes.end(); }
7474 iterator vector_begin() {
return VectorTypes.begin(); }
7475 iterator vector_end() {
return VectorTypes.end(); }
7477 bool hasNonRecordTypes() {
return HasNonRecordTypes; }
7478 bool hasArithmeticOrEnumeralTypes() {
return HasArithmeticOrEnumeralTypes; }
7479 bool hasNullPtrType()
const {
return HasNullPtrType; }
7494 BuiltinCandidateTypeSet::AddPointerWithMoreQualifiedTypeVariants(
QualType Ty,
7498 if (!PointerTypes.insert(Ty))
7503 bool buildObjCPtr =
false;
7507 buildObjCPtr =
true;
7525 if ((CVR | BaseCVR) != CVR)
continue;
7547 PointerTypes.insert(QPointerTy);
7563 BuiltinCandidateTypeSet::AddMemberPointerWithMoreQualifiedTypeVariants(
7566 if (!MemberPointerTypes.insert(Ty))
7570 assert(PointerTy &&
"type was not a member pointer type!");
7585 if ((CVR | BaseCVR) != CVR)
continue;
7588 MemberPointerTypes.insert(
7604 BuiltinCandidateTypeSet::AddTypesConvertedFrom(
QualType Ty,
7606 bool AllowUserConversions,
7607 bool AllowExplicitConversions,
7619 Ty = SemaRef.Context.getArrayDecayedType(Ty);
7626 HasNonRecordTypes = HasNonRecordTypes || !TyRec;
7629 HasArithmeticOrEnumeralTypes =
7633 PointerTypes.insert(Ty);
7637 if (!AddPointerWithMoreQualifiedTypeVariants(Ty, VisibleQuals))
7641 if (!AddMemberPointerWithMoreQualifiedTypeVariants(Ty))
7644 HasArithmeticOrEnumeralTypes =
true;
7645 EnumerationTypes.insert(Ty);
7649 HasArithmeticOrEnumeralTypes =
true;
7650 VectorTypes.insert(Ty);
7652 HasNullPtrType =
true;
7653 }
else if (AllowUserConversions && TyRec) {
7655 if (!SemaRef.isCompleteType(Loc, Ty))
7660 if (isa<UsingShadowDecl>(D))
7661 D = cast<UsingShadowDecl>(D)->getTargetDecl();
7665 if (isa<FunctionTemplateDecl>(D))
7669 if (AllowExplicitConversions || !Conv->
isExplicit()) {
7732 if (isa<UsingShadowDecl>(D))
7733 D = cast<UsingShadowDecl>(D)->getTargetDecl();
7767 class BuiltinOperatorOverloadBuilder {
7772 bool HasArithmeticOrEnumeralCandidateType;
7776 static constexpr
int ArithmeticTypesCap = 24;
7782 unsigned FirstIntegralType,
7784 unsigned FirstPromotedIntegralType,
7785 LastPromotedIntegralType;
7786 unsigned FirstPromotedArithmeticType,
7787 LastPromotedArithmeticType;
7788 unsigned NumArithmeticTypes;
7790 void InitArithmeticTypes() {
7792 FirstPromotedArithmeticType = 0;
7800 FirstIntegralType = ArithmeticTypes.size();
7801 FirstPromotedIntegralType = ArithmeticTypes.size();
7812 LastPromotedIntegralType = ArithmeticTypes.size();
7813 LastPromotedArithmeticType = ArithmeticTypes.size();
7827 LastIntegralType = ArithmeticTypes.size();
7828 NumArithmeticTypes = ArithmeticTypes.size();
7832 assert(ArithmeticTypes.size() <= ArithmeticTypesCap &&
7833 "Enough inline storage for all arithmetic types.");
7838 void addPlusPlusMinusMinusStyleOverloads(
QualType CandidateTy,
7880 BuiltinOperatorOverloadBuilder(
7883 bool HasArithmeticOrEnumeralCandidateType,
7887 VisibleTypeConversionsQuals(VisibleTypeConversionsQuals),
7888 HasArithmeticOrEnumeralCandidateType(
7889 HasArithmeticOrEnumeralCandidateType),
7890 CandidateTypes(CandidateTypes),
7891 CandidateSet(CandidateSet) {
7893 InitArithmeticTypes();
7916 if (!HasArithmeticOrEnumeralCandidateType)
7919 for (
unsigned Arith = 0; Arith < NumArithmeticTypes; ++Arith) {
7920 const auto TypeOfT = ArithmeticTypes[Arith];
7922 if (Op == OO_MinusMinus)
7924 if (Op == OO_PlusPlus && S.
getLangOpts().CPlusPlus17)
7927 addPlusPlusMinusMinusStyleOverloads(
7944 void addPlusPlusMinusMinusPointerOverloads() {
7945 for (BuiltinCandidateTypeSet::iterator
7946 Ptr = CandidateTypes[0].pointer_begin(),
7947 PtrEnd = CandidateTypes[0].pointer_end();
7948 Ptr != PtrEnd; ++Ptr) {
7950 if (!(*Ptr)->getPointeeType()->isObjectType())
7953 addPlusPlusMinusMinusStyleOverloads(*Ptr,
7954 (!(*Ptr).isVolatileQualified() &&
7956 (!(*Ptr).isRestrictQualified() &&
7971 void addUnaryStarPointerOverloads() {
7972 for (BuiltinCandidateTypeSet::iterator
7973 Ptr = CandidateTypes[0].pointer_begin(),
7974 PtrEnd = CandidateTypes[0].pointer_end();
7975 Ptr != PtrEnd; ++Ptr) {
7982 if (Proto->getMethodQuals() || Proto->getRefQualifier())
7995 void addUnaryPlusOrMinusArithmeticOverloads() {
7996 if (!HasArithmeticOrEnumeralCandidateType)
7999 for (
unsigned Arith = FirstPromotedArithmeticType;
8000 Arith < LastPromotedArithmeticType; ++Arith) {
8001 QualType ArithTy = ArithmeticTypes[Arith];
8006 for (BuiltinCandidateTypeSet::iterator
8007 Vec = CandidateTypes[0].vector_begin(),
8008 VecEnd = CandidateTypes[0].vector_end();
8009 Vec != VecEnd; ++Vec) {
8020 void addUnaryPlusPointerOverloads() {
8021 for (BuiltinCandidateTypeSet::iterator
8022 Ptr = CandidateTypes[0].pointer_begin(),
8023 PtrEnd = CandidateTypes[0].pointer_end();
8024 Ptr != PtrEnd; ++Ptr) {
8035 void addUnaryTildePromotedIntegralOverloads() {
8036 if (!HasArithmeticOrEnumeralCandidateType)
8039 for (
unsigned Int = FirstPromotedIntegralType;
8040 Int < LastPromotedIntegralType; ++Int) {
8041 QualType IntTy = ArithmeticTypes[Int];
8046 for (BuiltinCandidateTypeSet::iterator
8047 Vec = CandidateTypes[0].vector_begin(),
8048 VecEnd = CandidateTypes[0].vector_end();
8049 Vec != VecEnd; ++Vec) {
8061 void addEqualEqualOrNotEqualMemberPointerOrNullptrOverloads() {
8063 llvm::SmallPtrSet<QualType, 8> AddedTypes;
8065 for (
unsigned ArgIdx = 0, N = Args.size(); ArgIdx != N; ++ArgIdx) {
8066 for (BuiltinCandidateTypeSet::iterator
8067 MemPtr = CandidateTypes[ArgIdx].member_pointer_begin(),
8068 MemPtrEnd = CandidateTypes[ArgIdx].member_pointer_end();
8069 MemPtr != MemPtrEnd;
8075 QualType ParamTypes[2] = { *MemPtr, *MemPtr };
8079 if (CandidateTypes[ArgIdx].hasNullPtrType()) {
8081 if (AddedTypes.insert(NullPtrTy).second) {
8082 QualType ParamTypes[2] = { NullPtrTy, NullPtrTy };
8101 void addGenericBinaryPointerOrEnumeralOverloads() {
8115 UserDefinedBinaryOperators;
8117 for (
unsigned ArgIdx = 0, N = Args.size(); ArgIdx != N; ++ArgIdx) {
8118 if (CandidateTypes[ArgIdx].enumeration_begin() !=
8119 CandidateTypes[ArgIdx].enumeration_end()) {
8121 CEnd = CandidateSet.
end();
8123 if (!C->Viable || !C->Function || C->Function->getNumParams() != 2)
8126 if (C->Function->isFunctionTemplateSpecialization())
8130 C->Function->getParamDecl(0)->getType().getUnqualifiedType();
8132 C->Function->getParamDecl(1)->getType().getUnqualifiedType();
8140 UserDefinedBinaryOperators.insert(
8148 llvm::SmallPtrSet<QualType, 8> AddedTypes;
8150 for (
unsigned ArgIdx = 0, N = Args.size(); ArgIdx != N; ++ArgIdx) {
8151 for (BuiltinCandidateTypeSet::iterator
8152 Ptr = CandidateTypes[ArgIdx].pointer_begin(),
8153 PtrEnd = CandidateTypes[ArgIdx].pointer_end();
8154 Ptr != PtrEnd; ++Ptr) {
8159 QualType ParamTypes[2] = { *Ptr, *Ptr };
8162 for (BuiltinCandidateTypeSet::iterator
8163 Enum = CandidateTypes[ArgIdx].enumeration_begin(),
8164 EnumEnd = CandidateTypes[ArgIdx].enumeration_end();
8165 Enum != EnumEnd; ++Enum) {
8170 if (!AddedTypes.insert(CanonType).second ||
8171 UserDefinedBinaryOperators.count(std::make_pair(CanonType,
8174 QualType ParamTypes[2] = { *Enum, *Enum };
8199 llvm::SmallPtrSet<QualType, 8> AddedTypes;
8201 for (
int Arg = 0; Arg < 2; ++Arg) {
8202 QualType AsymmetricParamTypes[2] = {
8206 for (BuiltinCandidateTypeSet::iterator
8207 Ptr = CandidateTypes[Arg].pointer_begin(),
8208 PtrEnd = CandidateTypes[Arg].pointer_end();
8209 Ptr != PtrEnd; ++Ptr) {
8214 AsymmetricParamTypes[Arg] = *Ptr;
8215 if (Arg == 0 || Op == OO_Plus) {
8220 if (Op == OO_Minus) {
8225 QualType ParamTypes[2] = { *Ptr, *Ptr };
8261 void addGenericBinaryArithmeticOverloads() {
8262 if (!HasArithmeticOrEnumeralCandidateType)
8265 for (
unsigned Left = FirstPromotedArithmeticType;
8266 Left < LastPromotedArithmeticType; ++Left) {
8267 for (
unsigned Right = FirstPromotedArithmeticType;
8268 Right < LastPromotedArithmeticType; ++Right) {
8269 QualType LandR[2] = { ArithmeticTypes[Left],
8270 ArithmeticTypes[Right] };
8277 for (BuiltinCandidateTypeSet::iterator
8278 Vec1 = CandidateTypes[0].vector_begin(),
8279 Vec1End = CandidateTypes[0].vector_end();
8280 Vec1 != Vec1End; ++Vec1) {
8281 for (BuiltinCandidateTypeSet::iterator
8282 Vec2 = CandidateTypes[1].vector_begin(),
8283 Vec2End = CandidateTypes[1].vector_end();
8284 Vec2 != Vec2End; ++Vec2) {
8285 QualType LandR[2] = { *Vec1, *Vec2 };
8322 void addThreeWayArithmeticOverloads() {
8323 addGenericBinaryArithmeticOverloads();
8341 if (!HasArithmeticOrEnumeralCandidateType)
8344 for (
unsigned Left = FirstPromotedIntegralType;
8345 Left < LastPromotedIntegralType; ++Left) {
8346 for (
unsigned Right = FirstPromotedIntegralType;
8347 Right < LastPromotedIntegralType; ++Right) {
8348 QualType LandR[2] = { ArithmeticTypes[Left],
8349 ArithmeticTypes[Right] };
8362 void addAssignmentMemberPointerOrEnumeralOverloads() {
8364 llvm::SmallPtrSet<QualType, 8> AddedTypes;
8366 for (
unsigned ArgIdx = 0; ArgIdx < 2; ++ArgIdx) {
8367 for (BuiltinCandidateTypeSet::iterator
8368 Enum = CandidateTypes[ArgIdx].enumeration_begin(),
8369 EnumEnd = CandidateTypes[ArgIdx].enumeration_end();
8370 Enum != EnumEnd; ++Enum) {
8377 for (BuiltinCandidateTypeSet::iterator
8378 MemPtr = CandidateTypes[ArgIdx].member_pointer_begin(),
8379 MemPtrEnd = CandidateTypes[ArgIdx].member_pointer_end();
8380 MemPtr != MemPtrEnd; ++MemPtr) {
8405 void addAssignmentPointerOverloads(
bool isEqualOp) {
8407 llvm::SmallPtrSet<QualType, 8> AddedTypes;
8409 for (BuiltinCandidateTypeSet::iterator
8410 Ptr = CandidateTypes[0].pointer_begin(),
8411 PtrEnd = CandidateTypes[0].pointer_end();
8412 Ptr != PtrEnd; ++Ptr) {
8416 else if (!(*Ptr)->getPointeeType()->isObjectType())
8427 bool NeedVolatile = !(*Ptr).isVolatileQualified() &&
8437 if (!(*Ptr).isRestrictQualified() &&
8459 for (BuiltinCandidateTypeSet::iterator
8460 Ptr = CandidateTypes[1].pointer_begin(),
8461 PtrEnd = CandidateTypes[1].pointer_end();
8462 Ptr != PtrEnd; ++Ptr) {
8476 bool NeedVolatile = !(*Ptr).isVolatileQualified() &&
8486 if (!(*Ptr).isRestrictQualified() &&
8521 void addAssignmentArithmeticOverloads(
bool isEqualOp) {
8522 if (!HasArithmeticOrEnumeralCandidateType)
8525 for (
unsigned Left = 0; Left < NumArithmeticTypes; ++Left) {
8526 for (
unsigned Right = FirstPromotedArithmeticType;
8527 Right < LastPromotedArithmeticType; ++Right) {
8529 ParamTypes[1] = ArithmeticTypes[Right];
8531 S, ArithmeticTypes[Left], Args[0]);
8548 for (BuiltinCandidateTypeSet::iterator
8549 Vec1 = CandidateTypes[0].vector_begin(),
8550 Vec1End = CandidateTypes[0].vector_end();
8551 Vec1 != Vec1End; ++Vec1) {
8552 for (BuiltinCandidateTypeSet::iterator
8553 Vec2 = CandidateTypes[1].vector_begin(),
8554 Vec2End = CandidateTypes[1].vector_end();
8555 Vec2 != Vec2End; ++Vec2) {
8557 ParamTypes[1] = *Vec2;
8586 void addAssignmentIntegralOverloads() {
8587 if (!HasArithmeticOrEnumeralCandidateType)
8590 for (
unsigned Left = FirstIntegralType; Left < LastIntegralType; ++Left) {
8591 for (
unsigned Right = FirstPromotedIntegralType;
8592 Right < LastPromotedIntegralType; ++Right) {
8594 ParamTypes[1] = ArithmeticTypes[Right];
8596 S, ArithmeticTypes[Left], Args[0]);
8602 ParamTypes[0] = LeftBaseTy;
8618 void addExclaimOverload() {
8624 void addAmpAmpOrPipePipeOverload() {
8641 void addSubscriptOverloads() {
8642 for (BuiltinCandidateTypeSet::iterator
8643 Ptr = CandidateTypes[0].pointer_begin(),
8644 PtrEnd = CandidateTypes[0].pointer_end();
8645 Ptr != PtrEnd; ++Ptr) {
8655 for (BuiltinCandidateTypeSet::iterator
8656 Ptr = CandidateTypes[1].pointer_begin(),
8657 PtrEnd = CandidateTypes[1].pointer_end();
8658 Ptr != PtrEnd; ++Ptr) {
8678 void addArrowStarOverloads() {
8679 for (BuiltinCandidateTypeSet::iterator
8680 Ptr = CandidateTypes[0].pointer_begin(),
8681 PtrEnd = CandidateTypes[0].pointer_end();
8682 Ptr != PtrEnd; ++Ptr) {
8687 if (!isa<RecordType>(C1))
8696 for (BuiltinCandidateTypeSet::iterator
8697 MemPtr = CandidateTypes[1].member_pointer_begin(),
8698 MemPtrEnd = CandidateTypes[1].member_pointer_end();
8699 MemPtr != MemPtrEnd; ++MemPtr) {
8705 QualType ParamTypes[2] = { *Ptr, *MemPtr };
8730 void addConditionalOperatorOverloads() {
8732 llvm::SmallPtrSet<QualType, 8> AddedTypes;
8734 for (
unsigned ArgIdx = 0; ArgIdx < 2; ++ArgIdx) {
8735 for (BuiltinCandidateTypeSet::iterator
8736 Ptr = CandidateTypes[ArgIdx].pointer_begin(),
8737 PtrEnd = CandidateTypes[ArgIdx].pointer_end();
8738 Ptr != PtrEnd; ++Ptr) {
8742 QualType ParamTypes[2] = { *Ptr, *Ptr };
8746 for (BuiltinCandidateTypeSet::iterator
8747 MemPtr = CandidateTypes[ArgIdx].member_pointer_begin(),
8748 MemPtrEnd = CandidateTypes[ArgIdx].member_pointer_end();
8749 MemPtr != MemPtrEnd; ++MemPtr) {
8753 QualType ParamTypes[2] = { *MemPtr, *MemPtr };
8758 for (BuiltinCandidateTypeSet::iterator
8759 Enum = CandidateTypes[ArgIdx].enumeration_begin(),
8760 EnumEnd = CandidateTypes[ArgIdx].enumeration_end();
8761 Enum != EnumEnd; ++Enum) {
8768 QualType ParamTypes[2] = { *Enum, *Enum };
8792 VisibleTypeConversionsQuals.
addConst();
8793 for (
unsigned ArgIdx = 0, N = Args.size(); ArgIdx != N; ++ArgIdx)
8796 bool HasNonRecordCandidateType =
false;
8797 bool HasArithmeticOrEnumeralCandidateType =
false;
8799 for (
unsigned ArgIdx = 0, N = Args.size(); ArgIdx != N; ++ArgIdx) {
8800 CandidateTypes.emplace_back(*
this);
8801 CandidateTypes[ArgIdx].AddTypesConvertedFrom(Args[ArgIdx]->getType(),
8804 (Op == OO_Exclaim ||
8807 VisibleTypeConversionsQuals);
8808 HasNonRecordCandidateType = HasNonRecordCandidateType ||
8809 CandidateTypes[ArgIdx].hasNonRecordTypes();
8810 HasArithmeticOrEnumeralCandidateType =
8811 HasArithmeticOrEnumeralCandidateType ||
8812 CandidateTypes[ArgIdx].hasArithmeticOrEnumeralTypes();
8820 if (!HasNonRecordCandidateType &&
8821 !(Op == OO_Exclaim || Op == OO_AmpAmp || Op == OO_PipePipe))
8825 BuiltinOperatorOverloadBuilder OpBuilder(*
this, Args,
8826 VisibleTypeConversionsQuals,
8827 HasArithmeticOrEnumeralCandidateType,
8828 CandidateTypes, CandidateSet);
8834 llvm_unreachable(
"Expected an overloaded operator");
8839 case OO_Array_Delete:
8842 "Special operators don't use AddBuiltinOperatorCandidates");
8854 if (Args.size() == 1)
8855 OpBuilder.addUnaryPlusPointerOverloads();
8859 if (Args.size() == 1) {
8860 OpBuilder.addUnaryPlusOrMinusArithmeticOverloads();
8862 OpBuilder.addBinaryPlusOrMinusPointerOverloads(Op);
8863 OpBuilder.addGenericBinaryArithmeticOverloads();
8868 if (Args.size() == 1)
8869 OpBuilder.addUnaryStarPointerOverloads();
8871 OpBuilder.addGenericBinaryArithmeticOverloads();
8875 OpBuilder.addGenericBinaryArithmeticOverloads();
8880 OpBuilder.addPlusPlusMinusMinusArithmeticOverloads(Op);
8881 OpBuilder.addPlusPlusMinusMinusPointerOverloads();
8885 case OO_ExclaimEqual:
8886 OpBuilder.addEqualEqualOrNotEqualMemberPointerOrNullptrOverloads();
8892 case OO_GreaterEqual:
8893 OpBuilder.addGenericBinaryPointerOrEnumeralOverloads();
8894 OpBuilder.addGenericBinaryArithmeticOverloads();
8898 OpBuilder.addGenericBinaryPointerOrEnumeralOverloads();
8899 OpBuilder.addThreeWayArithmeticOverloads();
8906 case OO_GreaterGreater:
8907 OpBuilder.addBinaryBitwiseArithmeticOverloads(Op);
8911 if (Args.size() == 1)
8917 OpBuilder.addBinaryBitwiseArithmeticOverloads(Op);
8921 OpBuilder.addUnaryTildePromotedIntegralOverloads();
8925 OpBuilder.addAssignmentMemberPointerOrEnumeralOverloads();
8930 OpBuilder.addAssignmentPointerOverloads(Op == OO_Equal);
8935 OpBuilder.addAssignmentArithmeticOverloads(Op == OO_Equal);
8938 case OO_PercentEqual:
8939 case OO_LessLessEqual:
8940 case OO_GreaterGreaterEqual:
8944 OpBuilder.addAssignmentIntegralOverloads();
8948 OpBuilder.addExclaimOverload();
8953 OpBuilder.addAmpAmpOrPipePipeOverload();
8957 OpBuilder.addSubscriptOverloads();
8961 OpBuilder.addArrowStarOverloads();
8964 case OO_Conditional:
8965 OpBuilder.addConditionalOperatorOverloads();
8966 OpBuilder.addGenericBinaryArithmeticOverloads();
8984 bool PartialOverloading) {
8995 ArgumentDependentLookup(Name, Loc, Args, Fns);
8999 CandEnd = CandidateSet.
end();
9000 Cand != CandEnd; ++Cand)
9001 if (Cand->Function) {
9002 Fns.
erase(Cand->Function);
9013 if (ExplicitTemplateArgs)
9016 AddOverloadCandidate(FD, FoundDecl, Args, CandidateSet,
9017 false, PartialOverloading,
9020 ADLCallKind::UsesADL);
9022 AddTemplateOverloadCandidate(
9023 cast<FunctionTemplateDecl>(*I), FoundDecl, ExplicitTemplateArgs, Args,
9025 false, PartialOverloading,
9026 true, ADLCallKind::UsesADL);
9049 bool Cand1Attr = Cand1->
hasAttr<EnableIfAttr>();
9050 bool Cand2Attr = Cand2->
hasAttr<EnableIfAttr>();
9051 if (!Cand1Attr || !Cand2Attr) {
9052 if (Cand1Attr == Cand2Attr)
9054 return Cand1Attr ? Comparison::Better : Comparison::Worse;
9060 llvm::FoldingSetNodeID Cand1ID, Cand2ID;
9061 for (
auto Pair : zip_longest(Cand1Attrs, Cand2Attrs)) {
9068 return Comparison::Worse;
9070 return Comparison::Better;
9075 (*Cand1A)->getCond()->Profile(Cand1ID, S.
getASTContext(),
true);
9076 (*Cand2A)->getCond()->Profile(Cand2ID, S.
getASTContext(),
true);
9077 if (Cand1ID != Cand2ID)
9078 return Comparison::Worse;
9099 const auto *Cand1CPUSpec = Cand1.
Function->
getAttr<CPUSpecificAttr>();
9100 const auto *Cand2CPUSpec = Cand2.
Function->
getAttr<CPUSpecificAttr>();
9102 if (!Cand1CPUDisp && !Cand2CPUDisp && !Cand1CPUSpec && !Cand2CPUSpec)
9105 if (Cand1CPUDisp && !Cand2CPUDisp)
9107 if (Cand2CPUDisp && !Cand1CPUDisp)
9110 if (Cand1CPUSpec && Cand2CPUSpec) {
9111 if (Cand1CPUSpec->cpus_size() != Cand2CPUSpec->cpus_size())
9112 return Cand1CPUSpec->cpus_size() < Cand2CPUSpec->cpus_size();
9114 std::pair<CPUSpecificAttr::cpus_iterator, CPUSpecificAttr::cpus_iterator>
9115 FirstDiff = std::mismatch(
9116 Cand1CPUSpec->cpus_begin(), Cand1CPUSpec->cpus_end(),
9117 Cand2CPUSpec->cpus_begin(),
9119 return LHS->
getName() == RHS->getName();
9122 assert(FirstDiff.first != Cand1CPUSpec->cpus_end() &&
9123 "Two different cpu-specific versions should not have the same " 9124 "identifier list, otherwise they'd be the same decl!");
9125 return (*FirstDiff.first)->getName() < (*FirstDiff.second)->
getName();
9127 llvm_unreachable(
"No way to get here unless both had cpu_dispatch");
9148 unsigned StartArg = 0;
9155 return ICS.isStandard() &&
9167 assert(Cand2.
Conversions.size() == NumArgs &&
"Overload candidate mismatch");
9168 bool HasBetterConversion =
false;
9169 for (
unsigned ArgIdx = StartArg; ArgIdx < NumArgs; ++ArgIdx) {
9170 bool Cand1Bad = IsIllFormedConversion(Cand1.
Conversions[ArgIdx]);
9171 bool Cand2Bad = IsIllFormedConversion(Cand2.
Conversions[ArgIdx]);
9172 if (Cand1Bad != Cand2Bad) {
9175 HasBetterConversion =
true;
9179 if (HasBetterConversion)
9186 for (
unsigned ArgIdx = StartArg; ArgIdx < NumArgs; ++ArgIdx) {
9192 HasBetterConversion =
true;
9207 if (HasBetterConversion)
9218 isa<CXXConversionDecl>(Cand1.
Function) &&
9219 isa<CXXConversionDecl>(Cand2.
Function)) {
9247 isa<CXXConstructorDecl>(Cand1.
Function) !=
9248 isa<CXXConstructorDecl>(Cand2.
Function))
9249 return isa<CXXConstructorDecl>(Cand1.
Function);
9253 bool Cand1IsSpecialization = Cand1.
Function &&
9255 bool Cand2IsSpecialization = Cand2.
Function &&
9257 if (Cand1IsSpecialization != Cand2IsSpecialization)
9258 return Cand2IsSpecialization;
9264 if (Cand1IsSpecialization && Cand2IsSpecialization) {
9278 bool Cand1IsInherited =
9280 bool Cand2IsInherited =
9282 if (Cand1IsInherited != Cand2IsInherited)
9283 return Cand2IsInherited;
9284 else if (Cand1IsInherited) {
9285 assert(Cand2IsInherited);
9288 if (Cand1Class->isDerivedFrom(Cand2Class))
9290 if (Cand2Class->isDerivedFrom(Cand1Class))
9297 auto *Guide1 = dyn_cast_or_null<CXXDeductionGuideDecl>(Cand1.
Function);
9298 auto *Guide2 = dyn_cast_or_null<CXXDeductionGuideDecl>(Cand2.
Function);
9299 if (Guide1 && Guide2) {
9301 if (Guide1->isImplicit() != Guide2->isImplicit())
9302 return Guide2->isImplicit();
9305 if (Guide1->isCopyDeductionCandidate())
9314 return Cmp == Comparison::Better;
9323 bool HasPS1 = Cand1.
Function !=
nullptr &&
9325 bool HasPS2 = Cand2.
Function !=
nullptr &&
9327 if (HasPS1 != HasPS2 && HasPS1)
9342 auto *VA = dyn_cast_or_null<ValueDecl>(A);
9343 auto *VB = dyn_cast_or_null<ValueDecl>(B);
9349 if (!VA->getDeclContext()->getRedeclContext()->Equals(
9350 VB->getDeclContext()->getRedeclContext()) ||
9351 getOwningModule(const_cast<ValueDecl *>(VA)) ==
9352 getOwningModule(const_cast<ValueDecl *>(VB)) ||
9353 VA->isExternallyVisible() || VB->isExternallyVisible())
9361 if (Context.
hasSameType(VA->getType(), VB->getType()))
9366 if (
auto *EA = dyn_cast<EnumConstantDecl>(VA)) {
9367 if (
auto *EB = dyn_cast<EnumConstantDecl>(VB)) {
9370 auto *EnumA = cast<EnumDecl>(EA->getDeclContext());
9371 auto *EnumB = cast<EnumDecl>(EB->getDeclContext());
9372 if (EnumA->hasNameForLinkage() || EnumB->hasNameForLinkage() ||
9374 EnumB->getIntegerType()))
9377 return llvm::APSInt::isSameValue(EA->getInitVal(), EB->getInitVal());
9387 Diag(Loc, diag::ext_equivalent_internal_linkage_decl_in_modules) << D;
9389 Module *M = getOwningModule(const_cast<NamedDecl*>(D));
9393 for (
auto *E : Equiv) {
9394 Module *M = getOwningModule(const_cast<NamedDecl*>(E));
9395 Diag(E->getLocation(), diag::note_equivalent_internal_linkage_decl)
9414 std::transform(begin(), end(), std::back_inserter(Candidates),
9426 bool ContainsSameSideCandidate =
9432 if (ContainsSameSideCandidate) {
9438 llvm::erase_if(Candidates, IsWrongSideCandidate);
9444 for (
auto *Cand : Candidates)
9446 if (Best == end() ||
9458 for (
auto *Cand : Candidates) {
9459 if (Cand->
Viable && Cand != Best &&
9463 EquivalentCands.push_back(Cand->
Function);
9473 if (Best->Function && Best->Function->isDeleted())
9476 if (!EquivalentCands.empty())
9489 oc_implicit_default_constructor,
9490 oc_implicit_copy_constructor,
9491 oc_implicit_move_constructor,
9492 oc_implicit_copy_assignment,
9493 oc_implicit_move_assignment,
9494 oc_inherited_constructor
9500 ocs_described_template,
9503 static std::pair<OverloadCandidateKind, OverloadCandidateSelect>
9505 std::string &Description) {
9515 if (!Description.empty())
9516 return ocs_described_template;
9517 return isTemplate ? ocs_template : ocs_non_template;
9522 if (!Ctor->isImplicit()) {
9523 if (isa<ConstructorUsingShadowDecl>(Found))
9524 return oc_inherited_constructor;
9526 return oc_constructor;
9529 if (Ctor->isDefaultConstructor())
9530 return oc_implicit_default_constructor;
9532 if (Ctor->isMoveConstructor())
9533 return oc_implicit_move_constructor;
9535 assert(Ctor->isCopyConstructor() &&
9536 "unexpected sort of implicit constructor");
9537 return oc_implicit_copy_constructor;
9543 if (!Meth->isImplicit())
9546 if (Meth->isMoveAssignmentOperator())
9547 return oc_implicit_move_assignment;
9549 if (Meth->isCopyAssignmentOperator())
9550 return oc_implicit_copy_assignment;
9552 assert(isa<CXXConversionDecl>(Meth) &&
"expected conversion");
9559 return std::make_pair(Kind, Select);
9562 void MaybeEmitInheritedConstructorNote(
Sema &S,
Decl *FoundDecl) {
9565 if (
auto *Shadow = dyn_cast<ConstructorUsingShadowDecl>(FoundDecl))
9567 diag::note_ovl_candidate_inherited_constructor)
9568 << Shadow->getNominatedBaseClass();
9577 if (EnableIf->getCond()->isValueDependent() ||
9578 !EnableIf->getCond()->EvaluateAsBooleanCondition(AlwaysTrue, Ctx))
9595 bool InOverloadResolution,
9599 if (InOverloadResolution)
9601 diag::note_addrof_ovl_candidate_disabled_by_enable_if_attr);
9603 S.
Diag(Loc, diag::err_addrof_function_disabled_by_enable_if_attr) << FD;
9609 return P->hasAttr<PassObjectSizeAttr>();
9617 if (InOverloadResolution)
9619 diag::note_ovl_candidate_has_pass_object_size_params)
9622 S.
Diag(Loc, diag::err_address_of_function_with_pass_object_size_params)
9645 QualType DestType,
bool TakingAddress) {
9649 !Fn->
getAttr<TargetAttr>()->isDefaultVersion())
9653 std::pair<OverloadCandidateKind, OverloadCandidateSelect> KSPair =
9654 ClassifyOverloadCandidate(*
this, Found, Fn, FnDesc);
9656 << (unsigned)KSPair.first << (
unsigned)KSPair.second
9659 HandleFunctionTypeMismatch(PD, Fn->
getType(), DestType);
9661 MaybeEmitInheritedConstructorNote(*
this, Found);
9667 bool TakingAddress) {
9677 dyn_cast<FunctionTemplateDecl>((*I)->getUnderlyingDecl()) ) {
9678 NoteOverloadCandidate(*I, FunTmpl->getTemplatedDecl(), DestType,
9681 = dyn_cast<FunctionDecl>((*I)->getUnderlyingDecl()) ) {
9682 NoteOverloadCandidate(*I, Fun, DestType, TakingAddress);
9694 S.
Diag(CaretLoc, PDiag)
9695 << Ambiguous.getFromType() << Ambiguous.getToType();
9700 unsigned CandsShown = 0;
9702 for (I = Ambiguous.begin(), E = Ambiguous.end(); I != E; ++I) {
9703 if (CandsShown >= 4 && ShowOverloads ==
Ovl_Best)
9713 unsigned I,
bool TakingCandidateAddress) {
9715 assert(Conv.
isBad());
9716 assert(Cand->
Function &&
"for now, candidate must be a function");
9722 bool isObjectArgument =
false;
9723 if (isa<CXXMethodDecl>(Fn) && !isa<CXXConstructorDecl>(Fn)) {
9725 isObjectArgument =
true;
9731 std::pair<OverloadCandidateKind, OverloadCandidateSelect> FnKindPair =
9732 ClassifyOverloadCandidate(S, Cand->
FoundDecl, Fn, FnDesc);
9739 assert(FromExpr &&
"overload set argument came from implicit argument?");
9741 if (isa<UnaryOperator>(E))
9742 E = cast<UnaryOperator>(E)->getSubExpr()->
IgnoreParens();
9746 << (
unsigned)FnKindPair.first << (unsigned)FnKindPair.second << FnDesc
9749 MaybeEmitInheritedConstructorNote(S, Cand->
FoundDecl);
9758 CToTy = RT->getPointeeType();
9763 CFromTy = FromPT->getPointeeType();
9764 CToTy = ToPT->getPointeeType();
9775 << (
unsigned)FnKindPair.first << (unsigned)FnKindPair.second << FnDesc
9777 << ToTy << (
unsigned)isObjectArgument << I + 1;
9778 MaybeEmitInheritedConstructorNote(S, Cand->
FoundDecl);
9784 << (
unsigned)FnKindPair.first << (unsigned)FnKindPair.second << FnDesc
9787 << (unsigned)isObjectArgument << I + 1;
9788 MaybeEmitInheritedConstructorNote(S, Cand->
FoundDecl);
9794 << (
unsigned)FnKindPair.first << (unsigned)FnKindPair.second << FnDesc
9797 << (unsigned)isObjectArgument << I + 1;
9798 MaybeEmitInheritedConstructorNote(S, Cand->
FoundDecl);
9804 << (
unsigned)FnKindPair.first << (unsigned)FnKindPair.second << FnDesc
9807 MaybeEmitInheritedConstructorNote(S, Cand->
FoundDecl);
9812 assert(CVR &&
"unexpected qualifiers mismatch");
9814 if (isObjectArgument) {
9816 << (
unsigned)FnKindPair.first << (unsigned)FnKindPair.second << FnDesc
9821 << (
unsigned)FnKindPair.first << (unsigned)FnKindPair.second << FnDesc
9823 << (CVR - 1) << I + 1;
9825 MaybeEmitInheritedConstructorNote(S, Cand->
FoundDecl);
9831 if (FromExpr && isa<InitListExpr>(FromExpr)) {
9833 << (
unsigned)FnKindPair.first << (unsigned)FnKindPair.second << FnDesc
9835 << ToTy << (
unsigned)isObjectArgument << I + 1;
9836 MaybeEmitInheritedConstructorNote(S, Cand->
FoundDecl);
9848 S.
Diag(Fn->
getLocation(), diag::note_ovl_candidate_bad_conv_incomplete)
9849 << (
unsigned)FnKindPair.first << (unsigned)FnKindPair.second << FnDesc
9851 << ToTy << (
unsigned)isObjectArgument << I + 1
9852 << (unsigned)(Cand->
Fix.
Kind);
9854 MaybeEmitInheritedConstructorNote(S, Cand->
FoundDecl);
9859 unsigned BaseToDerivedConversion = 0;
9862 if (ToPtrTy->getPointeeType().isAtLeastAsQualifiedAs(
9863 FromPtrTy->getPointeeType()) &&
9864 !FromPtrTy->getPointeeType()->isIncompleteType() &&
9865 !ToPtrTy->getPointeeType()->isIncompleteType() &&
9867 FromPtrTy->getPointeeType()))
9868 BaseToDerivedConversion = 1;
9876 if (ToPtrTy->getPointeeType().isAtLeastAsQualifiedAs(
9877 FromPtrTy->getPointeeType()) &&
9878 FromIface->isSuperClassOf(ToIface))
9879 BaseToDerivedConversion = 2;
9881 if (ToRefTy->getPointeeType().isAtLeastAsQualifiedAs(FromTy) &&
9883 !ToRefTy->getPointeeType()->isIncompleteType() &&
9885 BaseToDerivedConversion = 3;
9890 << (
unsigned)FnKindPair.first << (unsigned)FnKindPair.second << FnDesc
9891 << (
unsigned)isObjectArgument << I + 1
9893 MaybeEmitInheritedConstructorNote(S, Cand->
FoundDecl);
9898 if (BaseToDerivedConversion) {
9899 S.
Diag(Fn->
getLocation(), diag::note_ovl_candidate_bad_base_to_derived_conv)
9900 << (
unsigned)FnKindPair.first << (unsigned)FnKindPair.second << FnDesc
9902 << (BaseToDerivedConversion - 1) << FromTy << ToTy << I + 1;
9903 MaybeEmitInheritedConstructorNote(S, Cand->
FoundDecl);
9907 if (isa<ObjCObjectPointerType>(CFromTy) &&
9908 isa<PointerType>(CToTy)) {
9913 << (
unsigned)FnKindPair.first << (unsigned)FnKindPair.second
9915 << FromTy << ToTy << (
unsigned)isObjectArgument << I + 1;
9916 MaybeEmitInheritedConstructorNote(S, Cand->
FoundDecl);
9921 if (TakingCandidateAddress &&
9927 FDiag << (unsigned)FnKindPair.first << (
unsigned)FnKindPair.second << FnDesc
9929 << ToTy << (
unsigned)isObjectArgument << I + 1
9930 << (unsigned)(Cand->
Fix.
Kind);
9933 for (std::vector<FixItHint>::iterator HI = Cand->
Fix.
Hints.begin(),
9934 HE = Cand->
Fix.
Hints.end(); HI != HE; ++HI)
9938 MaybeEmitInheritedConstructorNote(S, Cand->
FoundDecl);
9958 if (NumArgs < MinParams) {
9973 unsigned NumFormalArgs) {
9974 assert(isa<FunctionDecl>(D) &&
9975 "The templated declaration should at least be a function" 9976 " when diagnosing bad template argument deduction due to too many" 9977 " or too few arguments");
9986 unsigned mode, modeCount;
9987 if (NumFormalArgs < MinParams) {
9988 if (MinParams != FnTy->getNumParams() || FnTy->isVariadic() ||
9989 FnTy->isTemplateVariadic())
9993 modeCount = MinParams;
9995 if (MinParams != FnTy->getNumParams())
9999 modeCount = FnTy->getNumParams();
10002 std::string Description;
10003 std::pair<OverloadCandidateKind, OverloadCandidateSelect> FnKindPair =
10004 ClassifyOverloadCandidate(S, Found, Fn, Description);
10008 << (
unsigned)FnKindPair.first << (unsigned)FnKindPair.second
10009 << Description << mode << Fn->
getParamDecl(0) << NumFormalArgs;
10012 << (
unsigned)FnKindPair.first << (unsigned)FnKindPair.second
10013 << Description << mode << modeCount << NumFormalArgs;
10015 MaybeEmitInheritedConstructorNote(S, Found);
10020 unsigned NumFormalArgs) {
10028 llvm_unreachable(
"Unsupported: Getting the described template declaration" 10029 " for bad deduction diagnosis");
10036 bool TakingCandidateAddress) {
10042 switch (DeductionFailure.
Result) {
10044 llvm_unreachable(
"TDK_success while diagnosing bad deduction");
10047 assert(ParamD &&
"no parameter found for incomplete deduction result");
10049 diag::note_ovl_candidate_incomplete_deduction)
10051 MaybeEmitInheritedConstructorNote(S, Found);
10056 assert(ParamD &&
"no parameter found for incomplete deduction result");
10058 diag::note_ovl_candidate_incomplete_deduction_pack)
10062 MaybeEmitInheritedConstructorNote(S, Found);
10067 assert(ParamD &&
"no parameter found for bad qualifiers deduction result");
10085 S.
Diag(Templated->
getLocation(), diag::note_ovl_candidate_underqualified)
10086 << ParamD->
getDeclName() << Arg << NonCanonParam;
10087 MaybeEmitInheritedConstructorNote(S, Found);
10092 assert(ParamD &&
"no parameter found for inconsistent deduction result");
10094 if (isa<TemplateTypeParmDecl>(ParamD))
10096 else if (isa<NonTypeTemplateParmDecl>(ParamD)) {
10106 diag::note_ovl_candidate_inconsistent_deduction_types)
10109 MaybeEmitInheritedConstructorNote(S, Found);
10119 diag::note_ovl_candidate_inconsistent_deduction)
10122 MaybeEmitInheritedConstructorNote(S, Found);
10127 assert(ParamD &&
"no parameter found for invalid explicit arguments");
10130 diag::note_ovl_candidate_explicit_arg_mismatch_named)
10135 index = TTP->getIndex();
10137 = dyn_cast<NonTypeTemplateParmDecl>(ParamD))
10138 index = NTTP->getIndex();
10140 index = cast<TemplateTemplateParmDecl>(ParamD)->getIndex();
10142 diag::note_ovl_candidate_explicit_arg_mismatch_unnamed)
10145 MaybeEmitInheritedConstructorNote(S, Found);
10155 diag::note_ovl_candidate_instantiation_depth);
10156 MaybeEmitInheritedConstructorNote(S, Found);
10164 TemplateArgString =
" ";
10171 if (PDiag && PDiag->second.getDiagID() ==
10172 diag::err_typename_nested_not_found_enable_if) {
10175 S.
Diag(PDiag->first, diag::note_ovl_candidate_disabled_by_enable_if)
10176 <<
"'enable_if'" << TemplateArgString;
10181 if (PDiag && PDiag->second.getDiagID() ==
10182 diag::err_typename_nested_not_found_requirement) {
10184 diag::note_ovl_candidate_disabled_by_requirement)
10185 << PDiag->second.getStringArg(0) << TemplateArgString;
10195 SFINAEArgString =
": ";
10197 PDiag->second.EmitToString(S.
getDiagnostics(), SFINAEArgString);
10201 diag::note_ovl_candidate_substitution_failure)
10202 << TemplateArgString << SFINAEArgString << R;
10203 MaybeEmitInheritedConstructorNote(S, Found);
10213 TemplateArgString =
" ";
10218 S.
Diag(Templated->
getLocation(), diag::note_ovl_candidate_deduced_mismatch)
10221 << TemplateArgString
10245 diag::note_ovl_candidate_non_deduced_mismatch_qualified)
10252 if (TakingCandidateAddress && isa<FunctionDecl>(Templated) &&
10261 diag::note_ovl_candidate_non_deduced_mismatch)
10262 << FirstTA << SecondTA;
10268 S.
Diag(Templated->
getLocation(), diag::note_ovl_candidate_bad_deduction);
10269 MaybeEmitInheritedConstructorNote(S, Found);
10273 diag::note_cuda_ovl_candidate_target_mismatch);
10281 bool TakingCandidateAddress) {
10299 std::string FnDesc;
10300 std::pair<OverloadCandidateKind, OverloadCandidateSelect> FnKindPair =
10301 ClassifyOverloadCandidate(S, Cand->
FoundDecl, Callee, FnDesc);
10303 S.
Diag(Callee->getLocation(), diag::note_ovl_candidate_bad_target)
10304 << (
unsigned)FnKindPair.first << (unsigned)ocs_non_template
10306 << CalleeTarget << CallerTarget;
10311 if (Meth !=
nullptr && Meth->
isImplicit()) {
10315 switch (FnKindPair.first) {
10318 case oc_implicit_default_constructor:
10321 case oc_implicit_copy_constructor:
10324 case oc_implicit_move_constructor:
10327 case oc_implicit_copy_assignment:
10330 case oc_implicit_move_assignment:
10335 bool ConstRHS =
false;
10339 ConstRHS = RT->getPointeeType().isConstQualified();
10354 diag::note_ovl_candidate_disabled_by_function_cond_attr)
10355 << Attr->getCond()->getSourceRange() << Attr->getMessage();
10360 const char *DeclName;
10362 case Decl::Kind::CXXConstructor:
10363 ES = cast<CXXConstructorDecl>(Cand->
Function)->getExplicitSpecifier();
10364 DeclName =
"constructor";
10366 case Decl::Kind::CXXConversion:
10367 ES = cast<CXXConversionDecl>(Cand->
Function)->getExplicitSpecifier();
10368 DeclName =
"conversion operator";
10370 case Decl::Kind::CXXDeductionGuide:
10371 ES = cast<CXXDeductionGuideDecl>(Cand->
Function)->getExplicitSpecifier();
10372 DeclName =
"deductiong guide";
10375 llvm_unreachable(
"invalid Decl");
10377 assert(ES.
getExpr() &&
"null expression should be handled before");
10379 diag::note_ovl_candidate_explicit_forbidden)
10382 diag::note_explicit_bool_resolved_to_true);
10389 diag::note_ovl_candidate_disabled_by_extension)
10410 bool TakingCandidateAddress,
10417 std::string FnDesc;
10418 std::pair<OverloadCandidateKind, OverloadCandidateSelect> FnKindPair =
10419 ClassifyOverloadCandidate(S, Cand->
FoundDecl, Fn, FnDesc);
10422 << (
unsigned)FnKindPair.first << (unsigned)FnKindPair.second << FnDesc
10424 MaybeEmitInheritedConstructorNote(S, Cand->
FoundDecl);
10440 TakingCandidateAddress);
10443 S.
Diag(Fn->
getLocation(), diag::note_ovl_candidate_illegal_constructor)
10445 MaybeEmitInheritedConstructorNote(S, Cand->
FoundDecl);
10453 diag::note_ovl_candidate_illegal_constructor_adrspace_mismatch)
10454 << QualsForPrinting;
10455 MaybeEmitInheritedConstructorNote(S, Cand->
FoundDecl);
10466 for (
unsigned N = Cand->
Conversions.size(); I != N; ++I)
10490 if (cast<CXXConstructorDecl>(Fn)->isCopyOrMoveConstructor())
10493 diag::note_ovl_candidate_inherited_constructor_slice)
10496 MaybeEmitInheritedConstructorNote(S, Cand->
FoundDecl);
10502 assert(!Available);
10516 bool isLValueReference =
false;
10517 bool isRValueReference =
false;
10518 bool isPointer =
false;
10522 isLValueReference =
true;
10526 isRValueReference =
true;
10546 assert(Cand->
Conversions.size() <= 2 &&
"builtin operator is not binary");
10547 std::string TypeStr(
"operator");
10553 S.
Diag(OpLoc, diag::note_ovl_builtin_unary_candidate) << TypeStr;
10558 S.
Diag(OpLoc, diag::note_ovl_builtin_binary_candidate) << TypeStr;
10565 if (ICS.
isBad())
break;
10569 S, OpLoc, S.
PDiag(diag::note_ambiguous_type_conversion));
10585 llvm_unreachable(
"non-deduction failure while diagnosing bad deduction");
10614 llvm_unreachable(
"Unhandled deduction result");
10618 struct CompareOverloadCandidatesForDisplay {
10624 CompareOverloadCandidatesForDisplay(
10627 : S(S), NumArgs(NArgs), CSK(CSK) {}
10632 if (L == R)
return false;
10636 if (!R->
Viable)
return true;
10659 if (LDist == RDist) {
10668 return LDist < RDist;
10686 numLFixes = (numLFixes == 0) ?
UINT_MAX : numLFixes;
10687 numRFixes = (numRFixes == 0) ?
UINT_MAX : numRFixes;
10688 if (numLFixes != numRFixes) {
10689 return numLFixes < numRFixes;
10696 int leftBetter = 0;
10698 for (
unsigned E = L->
Conversions.size(); I != E; ++I) {
10714 if (leftBetter > 0)
return true;
10715 if (leftBetter < 0)
return false;
10757 bool Unfixable =
false;
10765 assert(ConvIdx != ConvCount &&
"no bad conversion in candidate");
10766 if (Cand->
Conversions[ConvIdx].isInitialized() &&
10775 bool SuppressUserConversions =
false;
10777 unsigned ConvIdx = 0;
10791 if (isa<CXXMethodDecl>(Cand->
Function) &&
10792 !isa<CXXConstructorDecl>(Cand->
Function)) {
10798 assert(ConvCount <= 3);
10803 for (
unsigned ArgIdx = 0; ConvIdx != ConvCount; ++ConvIdx, ++ArgIdx) {
10804 if (Cand->
Conversions[ConvIdx].isInitialized()) {
10806 }
else if (ArgIdx < ParamTypes.size()) {
10807 if (ParamTypes[ArgIdx]->isDependentType())
10808 Cand->
Conversions[ConvIdx].setAsIdentityConversion(
10809 Args[ArgIdx]->getType());
10813 SuppressUserConversions,
10818 if (!Unfixable && Cand->
Conversions[ConvIdx].isBad())
10834 for (
iterator Cand = begin(), LastCand = end(); Cand != LastCand; ++Cand) {
10838 Cands.push_back(Cand);
10841 if (Cand->Function || Cand->IsSurrogate)
10842 Cands.push_back(Cand);
10849 Cands, CompareOverloadCandidatesForDisplay(S, OpLoc, Args.size(),
Kind));
10861 auto Cands = CompleteCandidates(S, OCD, Args, OpLoc,
Filter);
10863 S.
Diag(PD.first, PD.second);
10865 NoteCandidates(S, Args, Cands, Opc, OpLoc);
10871 bool ReportedAmbiguousConversions =
false;
10874 unsigned CandsShown = 0;
10875 auto I = Cands.begin(), E = Cands.end();
10876 for (; I != E; ++I) {
10882 if (CandsShown >= 4 && ShowOverloads ==
Ovl_Best) {
10894 "Non-viable built-in candidates are not added to Cands.");
10901 if (!ReportedAmbiguousConversions) {
10903 ReportedAmbiguousConversions =
true;
10912 S.
Diag(OpLoc, diag::note_ovl_too_many_candidates) << int(E - I);
10922 struct CompareTemplateSpecCandidatesForDisplay {
10924 CompareTemplateSpecCandidatesForDisplay(
Sema &S) : S(S) {}
10958 bool ForTakingAddress) {
10960 DeductionFailure, 0, ForTakingAddress);
10963 void TemplateSpecCandidateSet::destroyCandidates() {
10964 for (iterator
i = begin(), e = end();
i != e; ++
i) {
10965 i->DeductionFailure.Destroy();
10970 destroyCandidates();
10971 Candidates.clear();
10984 Cands.reserve(size());
10985 for (
iterator Cand = begin(), LastCand = end(); Cand != LastCand; ++Cand) {
10986 if (Cand->Specialization)
10987 Cands.push_back(Cand);
10992 llvm::sort(Cands, CompareTemplateSpecCandidatesForDisplay(S));
10999 unsigned CandsShown = 0;
11000 for (I = Cands.begin(), E = Cands.end(); I != E; ++I) {
11006 if (CandsShown >= 4 && ShowOverloads ==
Ovl_Best)
11011 "Non-matching built-in candidates are not added to Cands.");
11016 S.
Diag(Loc, diag::note_ovl_too_many_candidates) << int(E - I);
11026 QualType Ret = PossiblyAFunctionType;
11042 bool Complain =
true) {
11059 class AddressOfFunctionResolver {
11069 bool TargetTypeIsNonStaticMemberFunction;
11070 bool FoundNonTemplateFunction;
11071 bool StaticMemberFunctionFromBoundPointer;
11072 bool HasComplained;
11081 AddressOfFunctionResolver(
Sema &S,
Expr *SourceExpr,
11082 const QualType &TargetType,
bool Complain)
11083 : S(S), SourceExpr(SourceExpr), TargetType(TargetType),
11085 TargetTypeIsNonStaticMemberFunction(
11087 FoundNonTemplateFunction(
false),
11088 StaticMemberFunctionFromBoundPointer(
false),
11089 HasComplained(
false),
11092 FailedCandidates(OvlExpr->
getNameLoc(),
true) {
11093 ExtractUnqualifiedFunctionTypeFromTargetType();
11097 if (!UME->isImplicitAccess() &&
11099 StaticMemberFunctionFromBoundPointer =
true;
11103 OvlExpr,
false, &dap)) {
11105 if (!Method->isStatic()) {
11109 TargetTypeIsNonStaticMemberFunction =
true;
11117 Matches.push_back(std::make_pair(dap, Fn));
11125 if (FindAllFunctionsThatMatchTargetTypeExactly()) {
11128 if (Matches.size() > 1 && !eliminiateSuboptimalOverloadCandidates()) {
11129 if (FoundNonTemplateFunction)
11130 EliminateAllTemplateMatches();
11132 EliminateAllExceptMostSpecializedTemplate();
11137 EliminateSuboptimalCudaMatches();
11140 bool hasComplained()
const {
return HasComplained; }
11143 bool candidateHasExactlyCorrectType(
const FunctionDecl *FD) {
11155 return candidateHasExactlyCorrectType(A) &&
11156 (!candidateHasExactlyCorrectType(B) ||
11162 bool eliminiateSuboptimalOverloadCandidates() {
11165 auto Best = Matches.begin();
11166 for (
auto I = Matches.begin()+1, E = Matches.end(); I != E; ++I)
11167 if (isBetterCandidate(I->second, Best->second))
11171 auto IsBestOrInferiorToBest = [
this, BestFn](
11172 const std::pair<DeclAccessPair, FunctionDecl *> &Pair) {
11173 return BestFn == Pair.second || isBetterCandidate(BestFn, Pair.second);
11178 if (!llvm::all_of(Matches, IsBestOrInferiorToBest))
11180 Matches[0] = *Best;
11185 bool isTargetTypeAFunction()
const {
11194 void inline ExtractUnqualifiedFunctionTypeFromTargetType() {
11205 if (Method->isStatic() == TargetTypeIsNonStaticMemberFunction)
11208 else if (TargetTypeIsNonStaticMemberFunction)
11221 &OvlExplicitTemplateArgs,
11222 TargetFunctionType, Specialization,
11241 Matches.push_back(std::make_pair(CurAccessFunPair, Specialization));
11245 bool AddMatchingNonTemplateFunction(
NamedDecl* Fn,
11250 if (Method->isStatic() == TargetTypeIsNonStaticMemberFunction)
11253 else if (TargetTypeIsNonStaticMemberFunction)
11256 if (
FunctionDecl *FunDecl = dyn_cast<FunctionDecl>(Fn)) {
11261 if (FunDecl->isMultiVersion()) {
11262 const auto *TA = FunDecl->getAttr<TargetAttr>();
11263 if (TA && !TA->isDefaultVersion())
11271 HasComplained |= Complain;
11280 candidateHasExactlyCorrectType(FunDecl)) {
11281 Matches.push_back(std::make_pair(
11282 CurAccessFunPair, cast<FunctionDecl>(FunDecl->getCanonicalDecl())));
11283 FoundNonTemplateFunction =
true;
11291 bool FindAllFunctionsThatMatchTargetTypeExactly() {
11296 if (IsInvalidFormOfPointerToMemberFunction())
11312 = dyn_cast<FunctionTemplateDecl>(Fn)) {
11313 if (AddMatchingTemplateFunction(FunctionTemplate, I.getPair()))
11318 AddMatchingNonTemplateFunction(Fn, I.getPair()))
11321 assert(Ret || Matches.empty());
11325 void EliminateAllExceptMostSpecializedTemplate() {
11338 for (
unsigned I = 0, E = Matches.size(); I != E; ++I)
11339 MatchesCopy.
addDecl(Matches[I].second, Matches[I].first.getAccess());
11344 MatchesCopy.
begin(), MatchesCopy.
end(), FailedCandidates,
11346 S.
PDiag(diag::err_addr_ovl_ambiguous)
11347 << Matches[0].second->getDeclName(),
11348 S.
PDiag(diag::note_ovl_candidate)
11349 << (unsigned)oc_function << (
unsigned)ocs_described_template,
11350 Complain, TargetFunctionType);
11352 if (Result != MatchesCopy.
end()) {
11354 Matches[0].first = Matches[Result - MatchesCopy.
begin()].first;
11355 Matches[0].second = cast<FunctionDecl>(*Result);
11358 HasComplained |= Complain;
11361 void EliminateAllTemplateMatches() {
11364 for (
unsigned I = 0, N = Matches.size(); I != N; ) {
11365 if (Matches[I].second->getPrimaryTemplate() ==
nullptr)
11368 Matches[I] = Matches[--N];
11374 void EliminateSuboptimalCudaMatches() {
11379 void ComplainNoMatchesFound()
const {
11380 assert(Matches.empty());
11382 << OvlExpr->
getName() << TargetFunctionType
11384 if (FailedCandidates.
empty())
11395 dyn_cast<FunctionDecl>((*I)->getUnderlyingDecl()))
11403 bool IsInvalidFormOfPointerToMemberFunction()
const {
11404 return TargetTypeIsNonStaticMemberFunction &&
11408 void ComplainIsInvalidFormOfPointerToMemberFunction()
const {
11416 bool IsStaticMemberFunctionFromBoundPointer()
const {
11417 return StaticMemberFunctionFromBoundPointer;
11420 void ComplainIsStaticMemberFunctionFromBoundPointer()
const {
11422 diag::err_invalid_form_pointer_member_function)
11426 void ComplainOfInvalidConversion()
const {
11428 << OvlExpr->
getName() << TargetType;
11431 void ComplainMultipleMatchesFound()
const {
11432 assert(Matches.size() > 1);
11439 bool hadMultipleCandidates()
const {
return (OvlExpr->
getNumDecls() > 1); }
11441 int getNumMatches()
const {
return Matches.size(); }
11444 if (Matches.size() != 1)
return nullptr;
11445 return Matches[0].second;
11449 if (Matches.size() != 1)
return nullptr;
11450 return &Matches[0].first;
11475 bool *pHadMultipleCandidates) {
11478 AddressOfFunctionResolver Resolver(*
this, AddressOfExpr, TargetType,
11480 int NumMatches = Resolver.getNumMatches();
11482 bool ShouldComplain = Complain && !Resolver.hasComplained();
11483 if (NumMatches == 0 && ShouldComplain) {
11484 if (Resolver.IsInvalidFormOfPointerToMemberFunction())
11485 Resolver.ComplainIsInvalidFormOfPointerToMemberFunction();
11487 Resolver.ComplainNoMatchesFound();
11489 else if (NumMatches > 1 && ShouldComplain)
11490 Resolver.ComplainMultipleMatchesFound();
11491 else if (NumMatches == 1) {
11492 Fn = Resolver.getMatchingFunctionDecl();
11495 ResolveExceptionSpec(AddressOfExpr->
getExprLoc(), FPT);
11496 FoundResult = *Resolver.getMatchingFunctionAccessPair();
11498 if (Resolver.IsStaticMemberFunctionFromBoundPointer())
11499 Resolver.ComplainIsStaticMemberFunctionFromBoundPointer();
11501 CheckAddressOfMemberAccess(AddressOfExpr, FoundResult);
11505 if (pHadMultipleCandidates)
11506 *pHadMultipleCandidates = Resolver.hadMultipleCandidates();
11527 auto *FD = dyn_cast<
FunctionDecl>(I->getUnderlyingDecl());
11554 ExprResult &SrcExpr,
bool DoFunctionPointerConverion) {
11559 FunctionDecl *Found = resolveAddressOfOnlyViableOverloadCandidate(E, DAP);
11568 CheckAddressOfMemberAccess(E, DAP);
11569 Expr *Fixed = FixOverloadedFunctionReference(E, DAP, Found);
11571 SrcExpr = DefaultFunctionArrayConversion(Fixed,
false);
11618 = cast<FunctionTemplateDecl>((*I)->getUnderlyingDecl());
11630 Specialization, Info,
11634 FailedCandidates.addCandidate()
11640 assert(Specialization &&
"no specialization and no error?");
11647 NoteAllOverloadCandidates(ovl);
11652 Matched = Specialization;
11653 if (FoundResult) *FoundResult = I.getPair();
11672 ExprResult &SrcExpr,
bool doFunctionPointerConverion,
11673 bool complain,
SourceRange OpRangeForComplaining,
11675 unsigned DiagIDForComplaining) {
11682 if (
FunctionDecl *fn = ResolveSingleFunctionTemplateSpecialization(
11683 ovl.Expression,
false, &found)) {
11684 if (DiagnoseUseOfDecl(fn, SrcExpr.
get()->getBeginLoc())) {
11693 if (!ovl.HasFormOfMemberPointer &&
11694 isa<CXXMethodDecl>(fn) &&
11695 cast<CXXMethodDecl>(fn)->isInstance()) {
11696 if (!complain)
return false;
11698 Diag(ovl.Expression->getExprLoc(),
11699 diag::err_bound_member_function)
11700 << 0 << ovl.Expression->getSourceRange();
11712 SingleFunctionExpression =
11713 FixOverloadedFunctionReference(SrcExpr.
get(), found, fn);
11716 if (doFunctionPointerConverion) {
11717 SingleFunctionExpression =
11718 DefaultFunctionArrayLvalueConversion(SingleFunctionExpression.
get());
11719 if (SingleFunctionExpression.
isInvalid()) {
11726 if (!SingleFunctionExpression.
isUsable()) {
11728 Diag(OpRangeForComplaining.
getBegin(), DiagIDForComplaining)
11729 << ovl.Expression->getName()
11730 << DestTypeForComplaining
11731 << OpRangeForComplaining
11732 << ovl.Expression->getQualifierLoc().getSourceRange();
11733 NoteAllOverloadCandidates(SrcExpr.
get());
11742 SrcExpr = SingleFunctionExpression;
11752 bool PartialOverloading,
11755 if (isa<UsingShadowDecl>(Callee))
11756 Callee = cast<UsingShadowDecl>(Callee)->getTargetDecl();
11758 if (
FunctionDecl *Func = dyn_cast<FunctionDecl>(Callee)) {
11759 if (ExplicitTemplateArgs) {
11760 assert(!KnownValid &&
"Explicit template arguments?");
11764 if (!dyn_cast<FunctionProtoType>(Func->getType()->getAs<
FunctionType>()))
11769 PartialOverloading);
11774 = dyn_cast<FunctionTemplateDecl>(Callee)) {
11776 ExplicitTemplateArgs, Args, CandidateSet,
11778 PartialOverloading);
11782 assert(!KnownValid &&
"unhandled case in overloaded call candidate");
11790 bool PartialOverloading) {
11813 assert(!(*I)->getDeclContext()->isRecord());
11814 assert(isa<UsingShadowDecl>(*I) ||
11815 !(*I)->getDeclContext()->isFunctionOrMethod());
11816 assert((*I)->getUnderlyingDecl()->isFunctionOrFunctionTemplate());
11826 ExplicitTemplateArgs = &TABuffer;
11832 CandidateSet, PartialOverloading,
11837 Args, ExplicitTemplateArgs,
11838 CandidateSet, PartialOverloading);
11845 case OO_New:
case OO_Array_New:
11846 case OO_Delete:
case OO_Array_Delete:
11866 bool *DoDiagnoseEmptyLookup =
nullptr) {
11871 if (DC->isTransparentContext())
11879 if (isa<CXXRecordDecl>(DC)) {
11883 if (DoDiagnoseEmptyLookup)
11884 *DoDiagnoseEmptyLookup =
true;
11891 ExplicitTemplateArgs, Args,
11892 Candidates,
false,
false);
11895 if (Candidates.BestViableFunction(SemaRef, FnLoc, Best) !=
OR_Success) {
11907 AssociatedNamespaces,
11908 AssociatedClasses);
11912 for (Sema::AssociatedNamespaceSet::iterator
11913 it = AssociatedNamespaces.begin(),
11914 end = AssociatedNamespaces.end(); it != end; ++it) {
11926 SuggestedNamespaces.insert(*it);
11930 SemaRef.
Diag(R.
getNameLoc(), diag::err_not_found_by_two_phase_lookup)
11932 if (SuggestedNamespaces.empty()) {
11933 SemaRef.
Diag(Best->Function->getLocation(),
11934 diag::note_not_found_by_two_phase_lookup)
11936 }
else if (SuggestedNamespaces.size() == 1) {
11937 SemaRef.
Diag(Best->Function->getLocation(),
11938 diag::note_not_found_by_two_phase_lookup)
11944 SemaRef.
Diag(Best->Function->getLocation(),
11945 diag::note_not_found_by_two_phase_lookup)
11977 class BuildRecoveryCallExprRAII {
11980 BuildRecoveryCallExprRAII(
Sema &S) : SemaRef(S) {
11985 ~BuildRecoveryCallExprRAII() {
12001 bool EmptyLookup,
bool AllowTypoCorrection) {
12010 BuildRecoveryCallExprRAII RCE(SemaRef);
12020 ExplicitTemplateArgs = &TABuffer;
12025 bool DoDiagnoseEmptyLookup = EmptyLookup;
12028 ExplicitTemplateArgs, Args, &DoDiagnoseEmptyLookup)) {
12031 ExplicitTemplateArgs !=
nullptr,
12034 AllowTypoCorrection
12036 : static_cast<CorrectionCandidateCallback &>(NoTypoValidator);
12037 if (!DoDiagnoseEmptyLookup ||
12043 assert(!R.empty() &&
"lookup results empty despite recovery");
12046 if (R.isAmbiguous()) {
12047 R.suppressDiagnostics();
12054 if ((*R.begin())->isCXXClassMember())
12056 ExplicitTemplateArgs, S);
12057 else if (ExplicitTemplateArgs || TemplateKWLoc.
isValid())
12059 ExplicitTemplateArgs);
12086 assert(!ULE->
getQualifier() &&
"qualified name with ADL");
12095 llvm_unreachable(
"performing ADL for builtin");
12098 assert(getLangOpts().
CPlusPlus &&
"ADL enabled in C");
12102 UnbridgedCastsSet UnbridgedCasts;
12110 AddOverloadedCallCandidates(ULE, Args, *CandidateSet);
12112 if (getLangOpts().MSVCCompat &&
12113 CurContext->isDependentContext() && !isSFINAEContext() &&
12114 (isa<FunctionDecl>(CurContext) || isa<CXXRecordDecl>(CurContext))) {
12117 if (CandidateSet->
empty() ||
12134 if (CandidateSet->
empty())
12137 UnbridgedCasts.restore();
12153 bool AllowTypoCorrection) {
12154 if (CandidateSet->
empty())
12157 AllowTypoCorrection);
12159 switch (OverloadResult) {
12168 (*Best)->IsADLCandidate);
12177 AllowTypoCorrection);
12184 for (
const Expr *Arg : Args) {
12185 if (!Arg->getType()->isFunctionType())
12187 if (
auto *DRE = dyn_cast<DeclRefExpr>(Arg->IgnoreParenImpCasts())) {
12191 Arg->getExprLoc()))
12199 SemaRef.
PDiag(diag::err_ovl_no_viable_function_in_call)
12208 SemaRef.
PDiag(diag::err_ovl_ambiguous_call)
12216 SemaRef.
PDiag(diag::err_ovl_deleted_call)
12226 (*Best)->IsADLCandidate);
12236 for (
auto I = CS.
begin(), E = CS.
end(); I != E; ++I) {
12257 bool AllowTypoCorrection,
12258 bool CalleesAddressIsTaken) {
12263 if (buildOverloadedCallSet(S, Fn, ULE, Args, LParenLoc, &CandidateSet,
12269 if (CalleesAddressIsTaken)
12274 CandidateSet.BestViableFunction(*
this, Fn->
getBeginLoc(), Best);
12277 ExecConfig, &CandidateSet, &Best,
12278 OverloadResult, AllowTypoCorrection);
12282 return Functions.
size() > 1 ||
12283 (Functions.
size() == 1 && isa<FunctionTemplateDecl>(*Functions.
begin()));
12304 Expr *Input,
bool PerformADL) {
12306 assert(Op !=
OO_None &&
"Invalid opcode for overloaded unary operator");
12314 Expr *Args[2] = { Input,
nullptr };
12315 unsigned NumArgs = 1;
12320 if (Opc == UO_PostInc || Opc == UO_PostDec) {
12347 AddFunctionCandidates(Fns, ArgsArray, CandidateSet);
12350 AddMemberOperatorCandidates(Op, OpLoc, ArgsArray, CandidateSet);
12354 AddArgumentDependentLookupCandidates(OpName, OpLoc, ArgsArray,
12360 AddBuiltinOperatorCandidates(Op, OpLoc, ArgsArray, CandidateSet);
12362 bool HadMultipleCandidates = (CandidateSet.
size() > 1);
12377 if (
CXXMethodDecl *Method = dyn_cast<CXXMethodDecl>(FnDecl)) {
12378 CheckMemberOperatorAccess(OpLoc, Args[0],
nullptr, Best->FoundDecl);
12381 PerformObjectArgumentInitialization(Input,
nullptr,
12382 Best->FoundDecl, Method);
12385 Base = Input = InputRes.
get();
12396 Input = InputInit.
get();
12401 Base, HadMultipleCandidates,
12413 Context, Op, FnExpr.
get(), ArgsArray, ResultTy, VK, OpLoc,
12416 if (CheckCallReturnType(FnDecl->
getReturnType(), OpLoc, TheCall, FnDecl))
12419 if (CheckFunctionCall(FnDecl, TheCall,
12423 return MaybeBindToTemporary(TheCall);
12428 ExprResult InputRes = PerformImplicitConversion(
12429 Input, Best->BuiltinParamTypes[0], Best->Conversions[0], AA_Passing,
12430 CCK_ForBuiltinOverloadedOp);
12433 Input = InputRes.
get();
12453 PDiag(diag::err_ovl_ambiguous_oper_unary)
12473 return CreateBuiltinUnaryOp(OpLoc, Opc, Input);
12496 Expr *LHS,
Expr *RHS,
bool PerformADL) {
12497 Expr *Args[2] = { LHS, RHS };
12505 if (Args[0]->isTypeDependent() || Args[1]->isTypeDependent()) {
12509 if (Opc <= BO_Assign || Opc > BO_OrAssign)
12512 OpLoc, FPFeatures);
12548 if (Opc == BO_Assign && !Args[0]->getType()->isOverloadableType())
12549 return CreateBuiltinBinOp(OpLoc, Opc, Args[0], Args[1]);
12553 if (Opc == BO_PtrMemD)
12554 return CreateBuiltinBinOp(OpLoc, Opc, Args[0], Args[1]);
12560 AddFunctionCandidates(Fns, Args, CandidateSet);
12563 AddMemberOperatorCandidates(Op, OpLoc, Args, CandidateSet);
12568 if (Opc != BO_Assign && PerformADL)
12569 AddArgumentDependentLookupCandidates(OpName, OpLoc, Args,
12574 AddBuiltinOperatorCandidates(Op, OpLoc, Args, CandidateSet);
12576 bool HadMultipleCandidates = (CandidateSet.
size() > 1);
12591 if (
CXXMethodDecl *Method = dyn_cast<CXXMethodDecl>(FnDecl)) {
12593 CheckMemberOperatorAccess(OpLoc, Args[0], Args[1], Best->FoundDecl);
12596 PerformCopyInitialization(
12604 PerformObjectArgumentInitialization(Args[0],
nullptr,
12605 Best->FoundDecl, Method);
12612 ExprResult Arg0 = PerformCopyInitialization(
12620 PerformCopyInitialization(
12632 Best->FoundDecl, Base,
12633 HadMultipleCandidates, OpLoc);
12634 if (FnExpr.isInvalid())
12643 Context, Op, FnExpr.get(), Args, ResultTy, VK, OpLoc, FPFeatures,
12644 Best->IsADLCandidate);
12646 if (CheckCallReturnType(FnDecl->
getReturnType(), OpLoc, TheCall,
12651 const Expr *ImplicitThis =
nullptr;
12653 if (isa<CXXMethodDecl>(FnDecl)) {
12654 ImplicitThis = ArgsArray[0];
12655 ArgsArray = ArgsArray.slice(1);
12659 if (Op == OO_Equal)
12660 DiagnoseSelfMove(Args[0], Args[1], OpLoc);
12662 checkCall(FnDecl,
nullptr, ImplicitThis, ArgsArray,
12663 isa<CXXMethodDecl>(FnDecl), OpLoc, TheCall->getSourceRange(),
12664 VariadicDoesNotApply);
12666 return MaybeBindToTemporary(TheCall);
12671 ExprResult ArgsRes0 = PerformImplicitConversion(
12672 Args[0], Best->BuiltinParamTypes[0], Best->Conversions[0],
12673 AA_Passing, CCK_ForBuiltinOverloadedOp);
12676 Args[0] = ArgsRes0.
get();
12678 ExprResult ArgsRes1 = PerformImplicitConversion(
12679 Args[1], Best->BuiltinParamTypes[1], Best->Conversions[1],
12680 AA_Passing, CCK_ForBuiltinOverloadedOp);
12683 Args[1] = ArgsRes1.
get();
12693 if (Opc == BO_Comma)
12704 Opc >= BO_Assign && Opc <= BO_OrAssign) {
12705 Diag(OpLoc, diag::err_ovl_no_viable_oper)
12708 if (Args[0]->getType()->isIncompleteType()) {
12709 Diag(OpLoc, diag::note_assign_lhs_incomplete)
12723 Result = CreateBuiltinBinOp(OpLoc, Opc, Args[0], Args[1]);
12726 "C++ binary operator overloading is missing candidates!");
12735 << Args[0]->getType()
12736 << Args[1]->getType()
12744 if (isImplicitlyDeleted(Best->Function)) {
12745 CXXMethodDecl *Method = cast<CXXMethodDecl>(Best->Function);
12746 Diag(OpLoc, diag::err_ovl_deleted_special_oper)
12748 << getSpecialMember(Method);
12752 NoteDeletedFunction(Method);
12766 return CreateBuiltinBinOp(OpLoc, Opc, Args[0], Args[1]);
12773 Expr *Args[2] = { Base, Idx };
12779 if (Args[0]->isTypeDependent() || Args[1]->isTypeDependent()) {
12810 AddMemberOperatorCandidates(OO_Subscript, LLoc, Args, CandidateSet);
12813 AddBuiltinOperatorCandidates(OO_Subscript, LLoc, Args, CandidateSet);
12815 bool HadMultipleCandidates = (CandidateSet.
size() > 1);
12828 CheckMemberOperatorAccess(LLoc, Args[0], Args[1], Best->FoundDecl);
12833 PerformObjectArgumentInitialization(Args[0],
nullptr,
12834 Best->FoundDecl, Method);
12835 if (Arg0.isInvalid())
12837 Args[0] = Arg0.get();
12853 OpLocInfo.setCXXOperatorNameRange(
SourceRange(LLoc, RLoc));
12857 HadMultipleCandidates,
12858 OpLocInfo.getLoc(),
12859 OpLocInfo.getInfo());
12870 Args, ResultTy, VK, RLoc,
FPOptions());
12872 if (CheckCallReturnType(FnDecl->
getReturnType(), LLoc, TheCall, FnDecl))
12875 if (CheckFunctionCall(Method, TheCall,
12879 return MaybeBindToTemporary(TheCall);
12884 ExprResult ArgsRes0 = PerformImplicitConversion(
12885 Args[0], Best->BuiltinParamTypes[0], Best->Conversions[0],
12886 AA_Passing, CCK_ForBuiltinOverloadedOp);
12889 Args[0] = ArgsRes0.
get();
12891 ExprResult ArgsRes1 = PerformImplicitConversion(
12892 Args[1], Best->BuiltinParamTypes[1], Best->Conversions[1],
12893 AA_Passing, CCK_ForBuiltinOverloadedOp);
12896 Args[1] = ArgsRes1.
get();
12904 ? (PDiag(diag::err_ovl_no_oper)
12907 : (PDiag(diag::err_ovl_no_viable_subscript)
12918 <<
"[]" << Args[0]->getType()
12919 << Args[1]->getType()
12935 return CreateBuiltinArraySubscriptExpr(Args[0], LLoc, Args[1], RLoc);
12958 if (
BinaryOperator *op = dyn_cast<BinaryOperator>(NakedMemExpr)) {
12960 assert(op->getOpcode() == BO_PtrMemD || op->getOpcode() == BO_PtrMemI);
12973 QualType objectType = op->getLHS()->getType();
12974 if (op->getOpcode() == BO_PtrMemI)
12978 Qualifiers difference = objectQuals - funcQuals;
12982 std::string qualsString = difference.
getAsString();
12983 Diag(LParenLoc, diag::err_pointer_to_member_call_drops_quals)
12984 << fnType.getUnqualifiedType()
12986 << (qualsString.find(
' ') == std::string::npos ? 1 : 2);
12993 if (CheckCallReturnType(proto->
getReturnType(), op->getRHS()->getBeginLoc(),
12997 if (ConvertArgumentsForCall(call, op,
nullptr, proto, Args, RParenLoc))
13000 if (CheckOtherCall(call, proto))
13003 return MaybeBindToTemporary(call);
13006 if (isa<CXXPseudoDestructorExpr>(NakedMemExpr))
13010 UnbridgedCastsSet UnbridgedCasts;
13018 if (isa<MemberExpr>(NakedMemExpr)) {
13019 MemExpr = cast<MemberExpr>(NakedMemExpr);
13023 UnbridgedCasts.restore();
13041 TemplateArgs = &TemplateArgsBuffer;
13045 E = UnresExpr->
decls_end(); I != E; ++I) {
13049 if (isa<UsingShadowDecl>(Func))
13050 Func = cast<UsingShadowDecl>(Func)->getTargetDecl();
13054 if (getLangOpts().MicrosoftExt && isa<CXXConstructorDecl>(Func)) {
13055 AddOverloadCandidate(cast<CXXConstructorDecl>(Func), I.getPair(), Args,
13058 }
else if ((Method = dyn_cast<CXXMethodDecl>(Func))) {
13064 AddMethodCandidate(Method, I.getPair(), ActingDC, ObjectType,
13065 ObjectClassification, Args, CandidateSet,
13068 AddMethodTemplateCandidate(
13069 cast<FunctionTemplateDecl>(Func), I.getPair(), ActingDC,
13070 TemplateArgs, ObjectType, ObjectClassification, Args, CandidateSet,
13077 UnbridgedCasts.restore();
13080 switch (CandidateSet.BestViableFunction(*
this, UnresExpr->
getBeginLoc(),
13083 Method = cast<CXXMethodDecl>(Best->Function);
13084 FoundDecl = Best->FoundDecl;
13085 CheckUnresolvedMemberAccess(UnresExpr, Best->FoundDecl);
13086 if (DiagnoseUseOfDecl(Best->FoundDecl, UnresExpr->
getNameLoc()))
13094 if (Method != FoundDecl.getDecl() &&
13095 DiagnoseUseOfDecl(Method, UnresExpr->
getNameLoc()))
13100 CandidateSet.NoteCandidates(
13103 PDiag(diag::err_ovl_no_viable_member_function_in_call)
13110 CandidateSet.NoteCandidates(
13112 PDiag(diag::err_ovl_ambiguous_member_call)
13119 CandidateSet.NoteCandidates(
13121 PDiag(diag::err_ovl_deleted_member_call)
13128 MemExprE = FixOverloadedFunctionReference(MemExprE, FoundDecl, Method);
13133 return BuildResolvedCallExpr(MemExprE, Method, LParenLoc, Args,
13142 ResultType = ResultType.getNonLValueExprType(Context);
13144 assert(Method &&
"Member call to something that isn't a method?");
13148 RParenLoc, Proto->getNumParams());
13160 PerformObjectArgumentInitialization(MemExpr->
getBase(), Qualifier,
13161 FoundDecl, Method);
13168 if (ConvertArgumentsForCall(TheCall, MemExpr, Method, Proto, Args,
13172 DiagnoseSentinelCalls(Method, LParenLoc, Args);
13174 if (CheckFunctionCall(Method, TheCall, Proto))
13180 if (
auto *MemE = dyn_cast<MemberExpr>(NakedMemExpr)) {
13181 if (
const EnableIfAttr *
Attr = CheckEnableIf(Method, Args,
true)) {
13182 Diag(MemE->getMemberLoc(),
13183 diag::err_ovl_no_viable_member_function_in_call)
13186 diag::note_ovl_candidate_disabled_by_function_cond_attr)
13187 <<
Attr->getCond()->getSourceRange() <<
Attr->getMessage();
13192 if ((isa<CXXConstructorDecl>(CurContext) ||
13193 isa<CXXDestructorDecl>(CurContext)) &&
13194 TheCall->getMethodDecl()->isPure()) {
13200 diag::warn_call_to_pure_virtual_member_function_from_ctor_dtor)
13201 << MD->
getDeclName() << isa<CXXDestructorDecl>(CurContext)
13205 if (getLangOpts().AppleKext)
13212 dyn_cast<CXXDestructorDecl>(TheCall->getMethodDecl())) {
13214 bool CallCanBeVirtual = !MemExpr->
hasQualifier() || getLangOpts().AppleKext;
13215 CheckVirtualDtorCall(DD, MemExpr->
getBeginLoc(),
false,
13216 CallCanBeVirtual,
true,
13220 return MaybeBindToTemporary(TheCall);
13236 UnbridgedCastsSet UnbridgedCasts;
13240 assert(Object.
get()->getType()->isRecordType() &&
13241 "Requires object type argument");
13255 if (RequireCompleteType(LParenLoc, Object.
get()->getType(),
13256 diag::err_incomplete_object_call, Object.
get()))
13259 LookupResult R(*
this, OpName, LParenLoc, LookupOrdinaryName);
13260 LookupQualifiedName(R, Record->getDecl());
13264 Oper != OperEnd; ++Oper) {
13265 AddMethodCandidate(Oper.getPair(), Object.
get()->getType(),
13266 Object.
get()->Classify(Context), Args, CandidateSet,
13287 const auto &Conversions =
13288 cast<CXXRecordDecl>(Record->getDecl())->getVisibleConversionFunctions();
13289 for (
auto I = Conversions.begin(), E = Conversions.end(); I != E; ++I) {
13292 if (isa<UsingShadowDecl>(D))
13293 D = cast<UsingShadowDecl>(D)->getTargetDecl();
13297 if (isa<FunctionTemplateDecl>(D))
13310 AddSurrogateCandidate(Conv, I.getPair(), ActingContext, Proto,
13311 Object.
get(), Args, CandidateSet);
13316 bool HadMultipleCandidates = (CandidateSet.size() > 1);
13320 switch (CandidateSet.BestViableFunction(*
this, Object.
get()->getBeginLoc(),
13329 CandidateSet.empty()
13330 ? (PDiag(diag::err_ovl_no_oper)
13331 << Object.
get()->getType() << 1
13332 << Object.
get()->getSourceRange())
13333 : (PDiag(diag::err_ovl_no_viable_object_call)
13334 << Object.
get()->getType() << Object.
get()->getSourceRange());
13335 CandidateSet.NoteCandidates(
13341 CandidateSet.NoteCandidates(
13343 PDiag(diag::err_ovl_ambiguous_object_call)
13344 << Object.
get()->getType()
13345 << Object.
get()->getSourceRange()),
13350 CandidateSet.NoteCandidates(
13352 PDiag(diag::err_ovl_deleted_object_call)
13353 << Object.
get()->getType()
13354 << Object.
get()->getSourceRange()),
13359 if (Best == CandidateSet.end())
13362 UnbridgedCasts.restore();
13364 if (Best->Function ==
nullptr) {
13368 = cast<CXXConversionDecl>(
13369 Best->Conversions[0].UserDefined.ConversionFunction);
13371 CheckMemberOperatorAccess(LParenLoc, Object.
get(),
nullptr,
13373 if (DiagnoseUseOfDecl(Best->FoundDecl, LParenLoc))
13375 assert(Conv == Best->FoundDecl.getDecl() &&
13376 "Found Decl & conversion-to-functionptr should be same, right?!");
13383 ExprResult Call = BuildCXXMemberCallExpr(Object.
get(), Best->FoundDecl,
13384 Conv, HadMultipleCandidates);
13385 if (Call.isInvalid())
13389 CK_UserDefinedConversion, Call.get(),
13392 return BuildCallExpr(S, Call.get(), LParenLoc, Args, RParenLoc);
13395 CheckMemberOperatorAccess(LParenLoc, Object.
get(),
nullptr, Best->FoundDecl);
13400 CXXMethodDecl *Method = cast<CXXMethodDecl>(Best->Function);
13403 if (Method->isInvalidDecl())
13415 Obj, HadMultipleCandidates,
13416 OpLocInfo.getLoc(),
13417 OpLocInfo.getInfo());
13424 unsigned NumArgsSlots = 1 + std::max<unsigned>(Args.size(), NumParams);
13430 bool IsError =
false;
13434 PerformObjectArgumentInitialization(Object.
get(),
nullptr,
13435 Best->FoundDecl, Method);
13440 MethodArgs[0] = Object.
get();
13443 for (
unsigned i = 0;
i != NumParams;
i++) {
13445 if (
i < Args.size()) {
13453 Method->getParamDecl(
i)),
13460 = BuildCXXDefaultArgExpr(LParenLoc, Method, Method->getParamDecl(
i));
13469 MethodArgs[
i + 1] = Arg;
13475 for (
unsigned i = NumParams, e = Args.size();
i < e;
i++) {
13476 ExprResult Arg = DefaultVariadicArgumentPromotion(Args[
i], VariadicMethod,
13479 MethodArgs[i + 1] = Arg.
get();
13486 DiagnoseSentinelCalls(Method, LParenLoc, Args);
13489 QualType ResultTy = Method->getReturnType();
13497 if (CheckCallReturnType(Method->getReturnType(), LParenLoc, TheCall, Method))
13500 if (CheckFunctionCall(Method, TheCall, Proto))
13503 return MaybeBindToTemporary(TheCall);
13511 bool *NoArrowOperatorFound) {
13513 "left-hand side must have class type");
13531 if (RequireCompleteType(Loc, Base->
getType(),
13532 diag::err_typecheck_incomplete_tag, Base))
13535 LookupResult R(*
this, OpName, OpLoc, LookupOrdinaryName);
13536 LookupQualifiedName(R, BaseRecord->
getDecl());
13540 Oper != OperEnd; ++Oper) {
13541 AddMethodCandidate(Oper.getPair(), Base->
getType(), Base->
Classify(Context),
13542 None, CandidateSet,
false);
13545 bool HadMultipleCandidates = (CandidateSet.
size() > 1);
13556 if (CandidateSet.
empty()) {
13558 if (NoArrowOperatorFound) {
13561 *NoArrowOperatorFound =
true;
13564 Diag(OpLoc, diag::err_typecheck_member_reference_arrow)
13567 Diag(OpLoc, diag::note_typecheck_member_reference_suggestion)
13571 Diag(OpLoc, diag::err_ovl_no_viable_oper)
13592 CheckMemberOperatorAccess(OpLoc, Base,
nullptr, Best->FoundDecl);
13595 CXXMethodDecl *Method = cast<CXXMethodDecl>(Best->Function);
13597 PerformObjectArgumentInitialization(Base,
nullptr,
13598 Best->FoundDecl, Method);
13599 if (BaseResult.isInvalid())
13601 Base = BaseResult.get();
13605 Base, HadMultipleCandidates, OpLoc);
13613 Context, OO_Arrow, FnExpr.
get(), Base, ResultTy, VK, OpLoc,
FPOptions());
13615 if (CheckCallReturnType(Method->
getReturnType(), OpLoc, TheCall, Method))
13618 if (CheckFunctionCall(Method, TheCall,
13622 return MaybeBindToTemporary(TheCall);
13636 AddFunctionCandidates(R.
asUnresolvedSet(), Args, CandidateSet, TemplateArgs,
13639 bool HadMultipleCandidates = (CandidateSet.size() > 1);
13644 switch (CandidateSet.BestViableFunction(*
this, UDSuffixLoc, Best)) {
13650 CandidateSet.NoteCandidates(
13652 PDiag(diag::err_ovl_no_viable_function_in_call)
13658 CandidateSet.NoteCandidates(
13667 nullptr, HadMultipleCandidates,
13676 for (
unsigned ArgIdx = 0, N = Args.size(); ArgIdx != N; ++ArgIdx) {
13677 ExprResult InputInit = PerformCopyInitialization(
13682 ConvArgs[ArgIdx] = InputInit.
get();
13690 Context, Fn.
get(), llvm::makeArrayRef(ConvArgs, Args.size()), ResultTy,
13691 VK, LitEndLoc, UDSuffixLoc);
13693 if (CheckCallReturnType(FD->
getReturnType(), UDSuffixLoc, UDL, FD))
13696 if (CheckFunctionCall(FD, UDL,
nullptr))
13699 return MaybeBindToTemporary(UDL);
13716 Scope *S =
nullptr;
13719 if (!MemberLookup.
empty()) {
13721 BuildMemberReferenceExpr(Range, Range->
getType(), Loc,
13729 return FRS_DiagnosticIssued;
13731 *CallExpr = BuildCallExpr(S, MemberRef.
get(), Loc, None, Loc,
nullptr);
13734 return FRS_DiagnosticIssued;
13742 FoundNames.
begin(), FoundNames.
end());
13744 bool CandidateSetError = buildOverloadedCallSet(S, Fn, Fn, Range, Loc,
13745 CandidateSet, CallExpr);
13746 if (CandidateSet->
empty() || CandidateSetError) {
13748 return FRS_NoViableFunction;
13756 return FRS_NoViableFunction;
13759 Loc,
nullptr, CandidateSet, &Best,
13764 return FRS_DiagnosticIssued;
13767 return FRS_Success;
13778 if (
ParenExpr *PE = dyn_cast<ParenExpr>(E)) {
13779 Expr *SubExpr = FixOverloadedFunctionReference(PE->getSubExpr(),
13781 if (SubExpr == PE->getSubExpr())
13784 return new (Context)
ParenExpr(PE->getLParen(), PE->getRParen(), SubExpr);
13788 Expr *SubExpr = FixOverloadedFunctionReference(ICE->getSubExpr(),
13790 assert(Context.
hasSameType(ICE->getSubExpr()->getType(),
13792 "Implicit cast type cannot be determined from overload");
13793 assert(ICE->path_empty() &&
"fixing up hierarchy conversion?");
13794 if (SubExpr == ICE->getSubExpr())
13798 ICE->getCastKind(),
13803 if (
auto *GSE = dyn_cast<GenericSelectionExpr>(E)) {
13804 if (!GSE->isResultDependent()) {
13806 FixOverloadedFunctionReference(GSE->getResultExpr(), Found, Fn);
13807 if (SubExpr == GSE->getResultExpr())
13814 unsigned ResultIdx = GSE->getResultIndex();
13815 AssocExprs[ResultIdx] = SubExpr;
13818 Context, GSE->getGenericLoc(), GSE->getControllingExpr(),
13819 GSE->getAssocTypeSourceInfos(), AssocExprs, GSE->getDefaultLoc(),
13820 GSE->getRParenLoc(), GSE->containsUnexpandedParameterPack(),
13829 assert(UnOp->getOpcode() == UO_AddrOf &&
13830 "Can only take the address of an overloaded function");
13832 if (Method->isStatic()) {
13839 Expr *SubExpr = FixOverloadedFunctionReference(UnOp->getSubExpr(),
13841 if (SubExpr == UnOp->getSubExpr())
13844 assert(isa<DeclRefExpr>(SubExpr)
13845 &&
"fixed to something other than a decl ref");
13846 assert(cast<DeclRefExpr>(SubExpr)->getQualifier()
13847 &&
"fixed to a member ref with no nested name qualifier");
13853 = Context.
getTypeDeclType(cast<RecordDecl>(Method->getDeclContext()));
13858 (
void)isCompleteType(UnOp->getOperatorLoc(), MemPtrType);
13860 return new (Context)
UnaryOperator(SubExpr, UO_AddrOf, MemPtrType,
13862 UnOp->getOperatorLoc(),
false);
13865 Expr *SubExpr = FixOverloadedFunctionReference(UnOp->getSubExpr(),
13867 if (SubExpr == UnOp->getSubExpr())
13873 UnOp->getOperatorLoc(),
false);
13886 if (ULE->hasExplicitTemplateArgs()) {
13887 ULE->copyTemplateArgumentsInto(TemplateArgsBuffer);
13888 TemplateArgs = &TemplateArgsBuffer;
13893 ULE->getQualifierLoc(), Found.
getDecl(),
13894 ULE->getTemplateKeywordLoc(), TemplateArgs);
13902 if (MemExpr->hasExplicitTemplateArgs()) {
13903 MemExpr->copyTemplateArgumentsInto(TemplateArgsBuffer);
13904 TemplateArgs = &TemplateArgsBuffer;
13911 if (MemExpr->isImplicitAccess()) {
13912 if (cast<CXXMethodDecl>(Fn)->isStatic()) {
13915 MemExpr->getQualifierLoc(), Found.
getDecl(),
13916 MemExpr->getTemplateKeywordLoc(), TemplateArgs);
13921 if (MemExpr->getQualifier())
13922 Loc = MemExpr->getQualifierLoc().getBeginLoc();
13924 BuildCXXThisExpr(Loc, MemExpr->getBaseType(),
true);
13927 Base = MemExpr->getBase();
13931 if (cast<CXXMethodDecl>(Fn)->isStatic()) {
13939 return BuildMemberExpr(
13940 Base, MemExpr->isArrow(), MemExpr->getOperatorLoc(),
13941 MemExpr->getQualifierLoc(), MemExpr->getTemplateKeywordLoc(), Fn, Found,
13942 true, MemExpr->getMemberNameInfo(),
13946 llvm_unreachable(
"Invalid reference to overloaded function");
13952 return FixOverloadedFunctionReference(E.
get(), Found, Fn);
Abstract class used to diagnose incomplete types.
Condition in an explicit(bool) specifier.
unsigned ExplicitCallArguments
The number of call arguments that were explicitly provided, to be used while performing partial order...
A call to an overloaded operator written using operator syntax.
SourceLocation getLoc() const
getLoc - Returns the main location of the declaration name.
const ObjCInterfaceType * getInterfaceType() const
If this pointer points to an Objective C @interface type, gets the type for that interface.
void setValueDependent(bool VD)
Set whether this expression is value-dependent or not.
const internal::VariadicAllOfMatcher< Type > type
Matches Types in the clang AST.
Function pointer conversion (C++17 [conv.fctptr])
DeclAccessPair FoundConversionFunction
The declaration that we found via name lookup, which might be the same as ConversionFunction or it mi...
Defines the clang::ASTContext interface.
QualType getAddrSpaceQualType(QualType T, LangAS AddressSpace) const
Return the uniqued reference to the type for an address space qualified type with the specified type ...
unsigned DeprecatedStringLiteralToCharPtr
Whether this is the deprecated conversion of a string literal to a pointer to non-const character dat...
void clear(CandidateSetKind CSK)
Clear out all of the candidates.
(CUDA) This candidate was not viable because the callee was not accessible from the caller's target (...
unsigned getNumDecls() const
Gets the number of declarations in the unresolved set.
This candidate constructor or conversion fonction is used implicitly but the explicit(bool) specifier...
Represents a function declaration or definition.
NamespaceDecl * getStdNamespace() const
void setStdInitializerListElement(bool V=true)
static DiagnosticBuilder Diag(DiagnosticsEngine *Diags, const LangOptions &Features, FullSourceLoc TokLoc, const char *TokBegin, const char *TokRangeBegin, const char *TokRangeEnd, unsigned DiagID)
Produce a diagnostic highlighting some portion of a literal.
bool EllipsisConversion
EllipsisConversion - When this is true, it means user-defined conversion sequence starts with a ...
CUDA Target attributes do not match.
static void markUnaddressableCandidatesUnviable(Sema &S, OverloadCandidateSet &CS)
bool hasExplicitTemplateArgs() const
Determines whether this expression had explicit template arguments.
ExprResult PerformContextuallyConvertToBool(Expr *From)
PerformContextuallyConvertToBool - Perform a contextual conversion of the expression From to bool (C+...
no exception specification
const TemplateArgument * getSecondArg()
Return the second template argument this deduction failure refers to, if any.
Smart pointer class that efficiently represents Objective-C method names.
static bool isTypeValid(QualType T)
Determine whether the given type is valid, e.g., it is not an invalid C++ class.
QualType getObjCIdType() const
Represents the Objective-CC id type.
PointerType - C99 6.7.5.1 - Pointer Declarators.
QualType getPointeeType() const
A (possibly-)qualified type.
bool isBlockPointerType() const
static void DiagnoseArityMismatch(Sema &S, NamedDecl *Found, Decl *D, unsigned NumFormalArgs)
General arity mismatch diagnosis over a candidate in a candidate set.
void AddMethodCandidate(DeclAccessPair FoundDecl, QualType ObjectType, Expr::Classification ObjectClassification, ArrayRef< Expr *> Args, OverloadCandidateSet &CandidateSet, bool SuppressUserConversion=false)
AddMethodCandidate - Adds a named decl (which is some kind of method) as a method candidate to the gi...
TemplateDeductionResult
Describes the result of template argument deduction.
void setToType(QualType T)
bool isMemberPointerType() const
ValueDecl * getMemberDecl() const
Retrieve the member declaration to which this expression refers.
ImplicitConversionKind
ImplicitConversionKind - The kind of implicit conversion used to convert an argument to a parameter's...
unsigned param_size() const
bool isEquivalentInternalLinkageDeclaration(const NamedDecl *A, const NamedDecl *B)
Determine if A and B are equivalent internal linkage declarations from different modules, and thus an ambiguity error can be downgraded to an extension warning.
void setFromType(QualType T)
const DeclarationNameLoc & getInfo() const
llvm::PointerUnion3< TemplateTypeParmDecl *, NonTypeTemplateParmDecl *, TemplateTemplateParmDecl * > TemplateParameter
Stores a template parameter of any kind.
Conversion not allowed by the C standard, but that we accept as an extension anyway.
static bool IsTransparentUnionStandardConversion(Sema &S, Expr *From, QualType &ToType, bool InOverloadResolution, StandardConversionSequence &SCS, bool CStyle)
Template argument deduction was successful.
const FunctionProtoType * ResolveExceptionSpec(SourceLocation Loc, const FunctionProtoType *FPT)
UnresolvedSetIterator getMostSpecialized(UnresolvedSetIterator SBegin, UnresolvedSetIterator SEnd, TemplateSpecCandidateSet &FailedCandidates, SourceLocation Loc, const PartialDiagnostic &NoneDiag, const PartialDiagnostic &AmbigDiag, const PartialDiagnostic &CandidateDiag, bool Complain=true, QualType TargetType=QualType())
Retrieve the most specialized of the given function template specializations.
Ordinary name lookup, which finds ordinary names (functions, variables, typedefs, etc...
const Expr * getInit(unsigned Init) const
bool isObjCPointerConversion(QualType FromType, QualType ToType, QualType &ConvertedType, bool &IncompatibleObjC)
isObjCPointerConversion - Determines whether this is an Objective-C pointer conversion.
QualType getPointerDiffType() const
Return the unique type for "ptrdiff_t" (C99 7.17) defined in <stddef.h>.
A structure used to record information about a failed template argument deduction, for diagnosis.
Checking non-dependent argument conversions failed.
Cannot tell whether this is a narrowing conversion because the expression is value-dependent.
bool isArithmeticType() const
specific_attr_iterator< T > specific_attr_begin() const
FunctionType - C99 6.7.5.3 - Function Declarators.
Provides information about an attempted template argument deduction, whose success or failure was des...
QualType getPointeeType() const
If this is a pointer, ObjC object pointer, or block pointer, this returns the respective pointee...
bool isMain() const
Determines whether this function is "main", which is the entry point into an executable program...
bool diagnoseArgDependentDiagnoseIfAttrs(const FunctionDecl *Function, const Expr *ThisArg, ArrayRef< const Expr *> Args, SourceLocation Loc)
Emit diagnostics for the diagnose_if attributes on Function, ignoring any non-ArgDependent DiagnoseIf...
bool isRealFloatingType() const
Floating point categories.
static CallExpr * CreateTemporary(void *Mem, Expr *Fn, QualType Ty, ExprValueKind VK, SourceLocation RParenLoc, ADLCallKind UsesADL=NotADL)
Create a temporary call expression with no arguments in the memory pointed to by Mem.
bool hasPlaceholderType() const
Returns whether this expression has a placeholder type.
void clear()
Clear out all of the candidates.
ConversionSet::const_iterator const_iterator
QualType getThisType() const
Return the type of the this pointer.
Complex conversions (C99 6.3.1.6)
void setObjCLifetime(ObjCLifetime type)
bool isRecordType() const
static void DiagnoseFailedExplicitSpec(Sema &S, OverloadCandidate *Cand)
bool isEmpty() const
No scope specifier.
std::string getTemplateArgumentBindingsText(const TemplateParameterList *Params, const TemplateArgumentList &Args)
Produces a formatted string that describes the binding of template parameters to template arguments...
static InitializedEntity InitializeParameter(ASTContext &Context, const ParmVarDecl *Parm)
Create the initialization entity for a parameter.
UserDefinedConversionSequence UserDefined
When ConversionKind == UserDefinedConversion, provides the details of the user-defined conversion seq...
QualType getQualifiedType(SplitQualType split) const
Un-split a SplitQualType.
QualType getLValueReferenceType(QualType T, bool SpelledAsLValue=true) const
Return the uniqued reference to the type for an lvalue reference to the specified type...
const Type * getTypeForDecl() const
SemaDiagnosticBuilder Diag(SourceLocation Loc, unsigned DiagID)
Emit a diagnostic.
ConstructorInfo getConstructorInfo(NamedDecl *ND)
bool isBetterOverloadCandidate(Sema &S, const OverloadCandidate &Cand1, const OverloadCandidate &Cand2, SourceLocation Loc, OverloadCandidateSet::CandidateSetKind Kind)
isBetterOverloadCandidate - Determines whether the first overload candidate is a better candidate tha...
Decl - This represents one declaration (or definition), e.g.
static ImplicitConversionSequence TryContextuallyConvertToBool(Sema &S, Expr *From)
TryContextuallyConvertToBool - Attempt to contextually convert the expression From to bool (C++0x [co...
specific_attr_iterator - Iterates over a subrange of an AttrVec, only providing attributes that are o...
bool isVariadic() const
Whether this function prototype is variadic.
__DEVICE__ long long abs(long long __n)
ExprResult BuildCallToMemberFunction(Scope *S, Expr *MemExpr, SourceLocation LParenLoc, MultiExprArg Args, SourceLocation RParenLoc)
BuildCallToMemberFunction - Build a call to a member function.
static ImplicitConversionSequence::CompareKind CompareDerivedToBaseConversions(Sema &S, SourceLocation Loc, const StandardConversionSequence &SCS1, const StandardConversionSequence &SCS2)
CompareDerivedToBaseConversions - Compares two standard conversion sequences to determine whether the...
static TemplateDecl * getDescribedTemplate(Decl *Templated)
bool isExtVectorType() const
AssignConvertType
AssignConvertType - All of the 'assignment' semantic checks return this enum to indicate whether the ...
A reference to a name which we were able to look up during parsing but could not resolve to a specifi...
ExprResult PerformContextualImplicitConversion(SourceLocation Loc, Expr *FromE, ContextualImplicitConverter &Converter)
Perform a contextual implicit conversion.
bool IsOverload(FunctionDecl *New, FunctionDecl *Old, bool IsForUsingDecl, bool ConsiderCudaAttrs=true)
ConstExprUsage
Indicates how the constant expression will be used.
OverloadedOperatorKind getCXXOverloadedOperator() const
If this name is the name of an overloadable operator in C++ (e.g., operator+), retrieve the kind of o...
Classification Classify(ASTContext &Ctx) const
Classify - Classify this expression according to the C++11 expression taxonomy.
Not a narrowing conversion.
ExplicitSpecifier getExplicitSpecifier()
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 ...
ExplicitSpecKind getKind() const
The base class of the type hierarchy.
CanQual< T > getUnqualifiedType() const
Retrieve the unqualified form of this type.
unsigned IncompatibleObjC
IncompatibleObjC - Whether this is an Objective-C conversion that we should warn about (if we actuall...
static bool convertArgsForAvailabilityChecks(Sema &S, FunctionDecl *Function, Expr *ThisArg, ArrayRef< Expr *> Args, Sema::SFINAETrap &Trap, bool MissingImplicitThis, Expr *&ConvertedThis, SmallVectorImpl< Expr *> &ConvertedArgs)
Represent a C++ namespace.
Template argument deduction produced inconsistent deduced values for the given template parameter...
SourceLocation getLocForEndOfToken(SourceLocation Loc, unsigned Offset=0)
Calls Lexer::getLocForEndOfToken()
static ExprValueKind getValueKindForType(QualType T)
getValueKindForType - Given a formal return or parameter type, give its value kind.
bool isRestrictQualified() const
Determine whether this type is restrict-qualified.
Ambiguous candidates found.
const TargetInfo & getTargetInfo() const
Store information needed for an explicit specifier.
QualType getValueType() const
Gets the type contained by this atomic type, i.e.
Conversions between compatible types in C99.
Floating point control options.
static bool CheckConvertedConstantConversions(Sema &S, StandardConversionSequence &SCS)
Check that the specified conversion is permitted in a converted constant expression, according to C++11 [expr.const]p3.
bool inferCUDATargetForImplicitSpecialMember(CXXRecordDecl *ClassDecl, CXXSpecialMember CSM, CXXMethodDecl *MemberDecl, bool ConstRHS, bool Diagnose)
Given a implicit special member, infer its CUDA target from the calls it needs to make to underlying ...
bool IgnoreObjectArgument
IgnoreObjectArgument - True to indicate that the first argument's conversion, which for this function...
QualType getConversionType() const
Returns the type that this conversion function is converting to.
Partial ordering of function templates for a call to a conversion function.
unsigned DirectBinding
DirectBinding - True when this is a reference binding that is a direct binding (C++ [dcl...
Represents a C++ constructor within a class.
LLVM_ATTRIBUTE_REINITIALIZES void clear()
Clears out any current state.
float __ovld __cnfn distance(float p0, float p1)
Returns the distance between p0 and p1.
size_t param_size() const
QualType getElementType() const
static unsigned RankDeductionFailure(const DeductionFailureInfo &DFI)
const RecordType * getAsUnionType() const
NOTE: getAs*ArrayType are methods on ASTContext.
static CXXOperatorCallExpr * Create(const ASTContext &Ctx, OverloadedOperatorKind OpKind, Expr *Fn, ArrayRef< Expr *> Args, QualType Ty, ExprValueKind VK, SourceLocation OperatorLoc, FPOptions FPFeatures, ADLCallKind UsesADL=NotADL)
static bool isFunctionAlwaysEnabled(const ASTContext &Ctx, const FunctionDecl *FD)
bool isUnsignedIntegerType() const
Return true if this is an integer type that is unsigned, according to C99 6.2.5p6 [which returns true...
void Adopt(NestedNameSpecifierLoc Other)
Adopt an existing nested-name-specifier (with source-range information).
RAII object that enters a new expression evaluation context.
QualType getFromType() const
PartialDiagnostic PDiag(unsigned DiagID=0)
Build a partial diagnostic.
void AddOverloadedCallCandidates(UnresolvedLookupExpr *ULE, ArrayRef< Expr *> Args, OverloadCandidateSet &CandidateSet, bool PartialOverloading=false)
Add the overload candidates named by callee and/or found by argument dependent lookup to the given ov...
ExprResult PerformObjectArgumentInitialization(Expr *From, NestedNameSpecifier *Qualifier, NamedDecl *FoundDecl, CXXMethodDecl *Method)
PerformObjectArgumentInitialization - Perform initialization of the implicit object parameter for the...
static bool isAllowableExplicitConversion(Sema &S, QualType ConvType, QualType ToType, bool AllowObjCPointerConversion)
Determine whether this is an allowable conversion from the result of an explicit conversion operator ...
DeclarationName getLookupName() const
Gets the name to look up.
void removeObjCLifetime()
QualType getReturnType() const
DiagnosticsEngine & Diags
unsigned getNumParams() const
bool isEnumeralType() const
bool isUserDefined() const
const T * getAs() const
Member-template getAs<specific type>'.
static ExprResult FinishOverloadedCallExpr(Sema &SemaRef, Scope *S, Expr *Fn, UnresolvedLookupExpr *ULE, SourceLocation LParenLoc, MultiExprArg Args, SourceLocation RParenLoc, Expr *ExecConfig, OverloadCandidateSet *CandidateSet, OverloadCandidateSet::iterator *Best, OverloadingResult OverloadResult, bool AllowTypoCorrection)
FinishOverloadedCallExpr - given an OverloadCandidateSet, builds and returns the completed call expre...
PrintingPolicy getPrintingPolicy() const
Retrieve a suitable printing policy for diagnostics.
OverloadKind CheckOverload(Scope *S, FunctionDecl *New, const LookupResult &OldDecls, NamedDecl *&OldDecl, bool IsForUsingDecl)
Determine whether the given New declaration is an overload of the declarations in Old...
static bool functionHasPassObjectSizeParams(const FunctionDecl *FD)
Extra information about a function prototype.
bool IsSurrogate
IsSurrogate - True to indicate that this candidate is a surrogate for a conversion to a function poin...
static ImplicitConversionSequence::CompareKind CompareQualificationConversions(Sema &S, const StandardConversionSequence &SCS1, const StandardConversionSequence &SCS2)
CompareQualificationConversions - Compares two standard conversion sequences to determine whether the...
LangAS
Defines the address space values used by the address space qualifier of QualType. ...
ObjCMethodDecl - Represents an instance or class method declaration.
NamedDecl * getUnderlyingDecl()
Looks through UsingDecls and ObjCCompatibleAliasDecls for the underlying named decl.
QualType ExtractUnqualifiedFunctionType(QualType PossiblyAFunctionType)
QualType getMemberPointerType(QualType T, const Type *Cls) const
Return the uniqued reference to the type for a member pointer to the specified type in the specified ...
DeclarationName getName() const
Gets the name looked up.
bool HadMultipleCandidates
HadMultipleCandidates - When this is true, it means that the conversion function was resolved from an...
bool isInvalidDecl() const
Like System, but searched after the system directories.
Decl * Specialization
Specialization - The actual specialization that this candidate represents.
bool requiresADL() const
True if this declaration should be extended by argument-dependent lookup.
static bool DiagnoseTwoPhaseOperatorLookup(Sema &SemaRef, OverloadedOperatorKind Op, SourceLocation OpLoc, ArrayRef< Expr *> Args)
Attempt to recover from ill-formed use of a non-dependent operator in a template, where the non-depen...
bool IsIntegralPromotion(Expr *From, QualType FromType, QualType ToType)
IsIntegralPromotion - Determines whether the conversion from the expression From (whose potentially-a...
bool hasDefinition() const
std::vector< FixItHint > Hints
The list of Hints generated so far.
Represents a parameter to a function.
QualType getLocalUnqualifiedType() const
Return this type with all of the instance-specific qualifiers removed, but without removing any quali...
Defines the clang::Expr interface and subclasses for C++ expressions.
TemplateParameter Param
The template parameter to which a template argument deduction failure refers.
static const TemplateDecl * isTemplate(const NamedDecl *ND, const TemplateArgumentList *&TemplateArgs)
void * ToTypePtrs[3]
ToType - The types that this conversion is converting to in each step.
The collection of all-type qualifiers we support.
FieldDecl * getSourceBitField()
If this expression refers to a bit-field, retrieve the declaration of that bit-field.
bool isObjCObjectOrInterfaceType() const
bool UnwrapSimilarTypes(QualType &T1, QualType &T2)
Attempt to unwrap two types that may be similar (C++ [conv.qual]).
Qualifiers getQualifiers() const
Retrieve all qualifiers.
OverloadCandidate & addCandidate(unsigned NumConversions=0, ConversionSequenceList Conversions=None)
Add a new candidate with NumConversions conversion sequence slots to the overload set...
ExprResult PerformImplicitConversion(Expr *From, QualType ToType, AssignmentAction Action, bool AllowExplicit=false)
PerformImplicitConversion - Perform an implicit conversion of the expression From to the type ToType...
bool isMoveAssignmentOperator() const
Determine whether this is a move assignment operator.
Expr * FixOverloadedFunctionReference(Expr *E, DeclAccessPair FoundDecl, FunctionDecl *Fn)
FixOverloadedFunctionReference - E is an expression that refers to a C++ overloaded function (possibl...
Represents a struct/union/class.
DeclarationName getDeclName() const
Get the actual, stored name of the declaration, which may be a special name.
bool Encloses(const DeclContext *DC) const
Determine whether this declaration context encloses the declaration context DC.
Boolean conversions (C++ [conv.bool])
One of these records is kept for each identifier that is lexed.
TargetCXXABI getCXXABI() const
Get the C++ ABI currently in use.
Value of a non-type template parameter.
SourceLocation getBeginLoc() const LLVM_READONLY
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
A C++ nested-name-specifier augmented with source location information.
bool inTemplateInstantiation() const
Determine whether we are currently performing template instantiation.
void dump() const
dump - Print this implicit conversion sequence to standard error.
bool isObjCLifetimeType() const
Returns true if objects of this type have lifetime semantics under ARC.
static bool diagnoseNoViableConversion(Sema &SemaRef, SourceLocation Loc, Expr *&From, Sema::ContextualImplicitConverter &Converter, QualType T, bool HadMultipleCandidates, UnresolvedSetImpl &ExplicitConversions)
unsigned BindsToFunctionLvalue
Whether we're binding to a function lvalue.
TemplateDecl * getAsTemplateDecl() const
Retrieve the underlying template declaration that this template name refers to, if known...
C++ [over.match.copy]: Copy-initialization of an object of class type by user-defined conversion...
Base class for callback objects used by Sema::CorrectTypo to check the validity of a potential typo c...
BadConversionSequence Bad
When ConversionKind == BadConversion, provides the details of the bad conversion. ...
bool IsDerivedFrom(SourceLocation Loc, QualType Derived, QualType Base)
Determine whether the type Derived is a C++ class that is derived from the type Base.
field_range fields() const
SourceLocation getBeginLoc() const LLVM_READONLY
NameKind getNameKind() const
Determine what kind of name this is.
bool isObjCIdType() const
Represents a member of a struct/union/class.
Expr * getBase()
Retrieve the base object of this member expressions, e.g., the x in x.m.
Identity conversion (no conversion)
CallExpr::ADLCallKind IsADLCandidate
True if the candidate was found using ADL.
bool isStdInitializerListElement() const
Whether the target is really a std::initializer_list, and the sequence only represents the worst elem...
ConversionSet & conversions()
bool buildOverloadedCallSet(Scope *S, Expr *Fn, UnresolvedLookupExpr *ULE, MultiExprArg Args, SourceLocation RParenLoc, OverloadCandidateSet *CandidateSet, ExprResult *Result)
Constructs and populates an OverloadedCandidateSet from the given function.
Floating point conversions (C++ [conv.double].
virtual SemaDiagnosticBuilder diagnoseConversion(Sema &S, SourceLocation Loc, QualType T, QualType ConvTy)=0
Emits a diagnostic when we picked a conversion function (for cases when we are not allowed to pick a ...
bool isReferenceType() const
The iterator over UnresolvedSets.
ExprResult PerformContextuallyConvertToObjCPointer(Expr *From)
PerformContextuallyConvertToObjCPointer - Perform a contextual conversion of the expression From to a...
bool match(QualType T) override
Match an integral or (possibly scoped) enumeration type.
bool isSpecialized() const
Whether this type is specialized, meaning that it has type arguments.
CompatiblePointerDiscardsQualifiers - The assignment discards c/v/r qualifiers, which we accept as an...
void copyTemplateArgumentsInto(TemplateArgumentListInfo &List) const
Copies the template arguments into the given structure.
Represents a C++ member access expression for which lookup produced a set of overloaded functions...
Ref_Incompatible - The two types are incompatible, so direct reference binding is not possible...
CUDAFunctionTarget IdentifyCUDATarget(const FunctionDecl *D, bool IgnoreImplicitHDAttr=false)
Determines whether the given function is a CUDA device/host/kernel/etc.
SourceLocation getBeginLoc() const LLVM_READONLY
ConversionSequenceList allocateConversionSequences(unsigned NumConversions)
Allocate storage for conversion sequences for NumConversions conversions.
specific_attr_iterator< T > specific_attr_end() const
void set(DeclAccessPair Found, Decl *Spec, DeductionFailureInfo Info)
OverloadKind
C++ Overloading.
bool isAtLeastAsQualifiedAs(QualType Other) const
Determine whether this type is at least as qualified as the other given type, requiring exact equalit...
bool isIntegralOrEnumerationType() const
Determine whether this type is an integral or enumeration type.
Describes a module or submodule.
OverloadCandidateDisplayKind
Qualifiers getLocalQualifiers() const
Retrieve the set of qualifiers local to this particular QualType instance, not including any qualifie...
An r-value expression (a pr-value in the C++11 taxonomy) produces a temporary value.
ArrayRef< ParmVarDecl * > parameters() const
DeclClass * getAsSingle() const
StringRef getOpcodeStr() const
Floating point promotions (C++ [conv.fpprom])
Describes an C or C++ initializer list.
An rvalue reference type, per C++11 [dcl.ref].
bool isCompleteType(SourceLocation Loc, QualType T)
static ExprResult CheckConvertedConstantExpression(Sema &S, Expr *From, QualType T, APValue &Value, Sema::CCEKind CCE, bool RequireInt)
CheckConvertedConstantExpression - Check that the expression From is a converted constant expression ...
SmallVectorImpl< PartialDiagnosticAt > * Diag
Diag - If this is non-null, it will be filled in with a stack of notes indicating why evaluation fail...
Represents the results of name lookup.
RefQualifierKind getRefQualifier() const
Retrieve the ref-qualifier associated with this method.
An lvalue ref-qualifier was provided (&).
ExprResult CreateOverloadedUnaryOp(SourceLocation OpLoc, UnaryOperatorKind Opc, const UnresolvedSetImpl &Fns, Expr *input, bool RequiresADL=true)
Create a unary operation that may resolve to an overloaded operator.
unsigned BindsToRvalue
Whether we're binding to an rvalue.
static ImplicitConversionSequence::CompareKind compareStandardConversionSubsets(ASTContext &Context, const StandardConversionSequence &SCS1, const StandardConversionSequence &SCS2)
static DeclAccessPair make(NamedDecl *D, AccessSpecifier AS)
std::string getFullModuleName(bool AllowStringLiterals=false) const
Retrieve the full name of this module, including the path from its top-level module.
bool HasFormOfMemberPointer
void setCXXOperatorNameRange(SourceRange R)
setCXXOperatorNameRange - Sets the range of the operator name (without the operator keyword)...
TemplateSpecCandidateSet - A set of generalized overload candidates, used in template specializations...
ReferenceCompareResult CompareReferenceRelationship(SourceLocation Loc, QualType T1, QualType T2, bool &DerivedToBase, bool &ObjCConversion, bool &ObjCLifetimeConversion)
CompareReferenceRelationship - Compare the two types T1 and T2 to determine whether they are referenc...
Succeeded, but refers to a deleted function.
APValue Val
Val - This is the value the expression can be folded to.
A convenient class for passing around template argument information.
QualType getVolatileType(QualType T) const
Return the uniqued reference to the type for a volatile qualified type.
Ref_Compatible - The two types are reference-compatible.
FunctionTemplateDecl * getDescribedFunctionTemplate() const
Retrieves the function template that is described by this function declaration.
unsigned QualificationIncludesObjCLifetime
Whether the qualification conversion involves a change in the Objective-C lifetime (for automatic ref...
ExprValueKind getValueKind() const
getValueKind - The value kind that this expression produces.
SourceLocation getTemplateKeywordLoc() const
Retrieve the location of the template keyword preceding this name, if any.
QualType getToType(unsigned Idx) const
bool IsFunctionConversion(QualType FromType, QualType ToType, QualType &ResultTy)
Determine whether the conversion from FromType to ToType is a valid conversion that strips "noexcept"...
void MarkDeclRefReferenced(DeclRefExpr *E, const Expr *Base=nullptr)
Perform reference-marking and odr-use handling for a DeclRefExpr.
static bool isRecordType(QualType T)
bool diagnoseArgIndependentDiagnoseIfAttrs(const NamedDecl *ND, SourceLocation Loc)
Emit diagnostics for the diagnose_if attributes on Function, ignoring any ArgDependent DiagnoseIfAttr...
A builtin binary operation expression such as "x + y" or "x <= y".
Substitution of the deduced template argument values resulted in an error.
bool isVolatileQualified() const
Determine whether this type is volatile-qualified.
This candidate function was not viable because an enable_if attribute disabled it.
LangAS getAddressSpace() const
A set of unresolved declarations.
ImplicitConversionKind Second
Second - The second conversion can be an integral promotion, floating point promotion, integral conversion, floating point conversion, floating-integral conversion, pointer conversion, pointer-to-member conversion, or boolean conversion.
const Type * getClass() const
bool isRValueReferenceType() const
Template argument deduction exceeded the maximum template instantiation depth (which has already been...
void diagnoseEquivalentInternalLinkageDeclarations(SourceLocation Loc, const NamedDecl *D, ArrayRef< const NamedDecl *> Equiv)
static ImplicitConversionSequence TryListConversion(Sema &S, InitListExpr *From, QualType ToType, bool SuppressUserConversions, bool InOverloadResolution, bool AllowObjCWritebackConversion)
TryListConversion - Try to copy-initialize a value of type ToType from the initializer list From...
static void AddOverloadedCallCandidate(Sema &S, DeclAccessPair FoundDecl, TemplateArgumentListInfo *ExplicitTemplateArgs, ArrayRef< Expr *> Args, OverloadCandidateSet &CandidateSet, bool PartialOverloading, bool KnownValid)
Add a single candidate to the overload set.
Defines the Diagnostic-related interfaces.
A narrowing conversion, because a constant expression got narrowed.
FunctionDecl * ResolveAddressOfOverloadedFunction(Expr *AddressOfExpr, QualType TargetType, bool Complain, DeclAccessPair &Found, bool *pHadMultipleCandidates=nullptr)
ResolveAddressOfOverloadedFunction - Try to resolve the address of an overloaded function (C++ [over...
ExprResult BuildOverloadedCallExpr(Scope *S, Expr *Fn, UnresolvedLookupExpr *ULE, SourceLocation LParenLoc, MultiExprArg Args, SourceLocation RParenLoc, Expr *ExecConfig, bool AllowTypoCorrection=true, bool CalleesAddressIsTaken=false)
BuildOverloadedCallExpr - Given the call expression that calls Fn (which eventually refers to the dec...
unsigned IsLvalueReference
Whether this is an lvalue reference binding (otherwise, it's an rvalue reference binding).
bool isLambda() const
Determine whether this class describes a lambda function object.
Expr * IgnoreParenCasts() LLVM_READONLY
Skip past any parentheses and casts which might surround this expression until reaching a fixed point...
NarrowingKind
NarrowingKind - The kind of narrowing conversion being performed by a standard conversion sequence ac...
Scope - A scope is a transient data structure that is used while parsing the program.
QualType getCVRQualifiedType(QualType T, unsigned CVR) const
Return a type with additional const, volatile, or restrict qualifiers.
const Type * getTypePtr() const
Retrieves a pointer to the underlying (unqualified) type.
ExprResult BuildResolvedCallExpr(Expr *Fn, NamedDecl *NDecl, SourceLocation LParenLoc, ArrayRef< Expr *> Arg, SourceLocation RParenLoc, Expr *Config=nullptr, bool IsExecConfig=false, ADLCallKind UsesADL=ADLCallKind::NotADL)
BuildResolvedCallExpr - Build a call to a resolved expression, i.e.
param_type_iterator param_type_begin() const
void Destroy()
Free any memory associated with this deduction failure.
Qualification conversions (C++ [conv.qual])
bool isCPUSpecificMultiVersion() const
True if this function is a multiversioned processor specific function as a part of the cpu_specific/c...
static bool isBooleanType(QualType Ty)
NestedNameSpecifier * getQualifier() const
Fetches the nested-name qualifier, if one was given.
Represents a C++ nested-name-specifier or a global scope specifier.
void setFromType(QualType T)
static bool checkAddressOfFunctionIsAvailable(Sema &S, const FunctionDecl *FD, bool Complain, bool InOverloadResolution, SourceLocation Loc)
Returns true if we can take the address of the function.
const LangOptions & getLangOpts() const
static IntegerLiteral * Create(const ASTContext &C, const llvm::APInt &V, QualType type, SourceLocation l)
Returns a new integer literal with value 'V' and type 'type'.
bool isTypeDependent() const
isTypeDependent - Determines whether this expression is type-dependent (C++ [temp.dep.expr]), which means that its type could change from one template instantiation to the next.
static ImplicitConversionSequence TryContextuallyConvertToObjCPointer(Sema &S, Expr *From)
TryContextuallyConvertToObjCPointer - Attempt to contextually convert the expression From to an Objec...
void * getAsOpaquePtr() const
bool compatiblyIncludesObjCLifetime(Qualifiers other) const
Determines if these qualifiers compatibly include another set of qualifiers from the narrow perspecti...
AssignConvertType CheckSingleAssignmentConstraints(QualType LHSType, ExprResult &RHS, bool Diagnose=true, bool DiagnoseCFAudited=false, bool ConvertRHS=true)
Check assignment constraints for an assignment of RHS to LHSType.
An ordinary object is located at an address in memory.
virtual SemaDiagnosticBuilder diagnoseIncomplete(Sema &S, SourceLocation Loc, QualType T)=0
Emits a diagnostic when the expression has incomplete class type.
The number of conversion kinds.
ForRangeStatus BuildForRangeBeginEndCall(SourceLocation Loc, SourceLocation RangeLoc, const DeclarationNameInfo &NameInfo, LookupResult &MemberLookup, OverloadCandidateSet *CandidateSet, Expr *Range, ExprResult *CallExpr)
Build a call to 'begin' or 'end' for a C++11 for-range statement.
TemplateParameter getTemplateParameter()
Retrieve the template parameter this deduction failure refers to, if any.
Represents an ObjC class declaration.
static ExprResult finishContextualImplicitConversion(Sema &SemaRef, SourceLocation Loc, Expr *From, Sema::ContextualImplicitConverter &Converter)
ImplicitConversionKind Third
Third - The third conversion can be a qualification conversion or a function conversion.
IncompatiblePointerSign - The assignment is between two pointers types which point to integers which ...
ExprResult BuildDeclarationNameExpr(const CXXScopeSpec &SS, LookupResult &R, bool NeedsADL, bool AcceptInvalidDecl=false)
static UnresolvedLookupExpr * Create(const ASTContext &Context, CXXRecordDecl *NamingClass, NestedNameSpecifierLoc QualifierLoc, const DeclarationNameInfo &NameInfo, bool RequiresADL, bool Overloaded, UnresolvedSetIterator Begin, UnresolvedSetIterator End)
Complex <-> Real conversion.
bool Viable
Viable - True to indicate that this overload candidate is viable.
ConversionSequenceList Conversions
The conversion sequences used to convert the function arguments to the function parameters.
FunctionDecl * resolveAddressOfOnlyViableOverloadCandidate(Expr *E, DeclAccessPair &FoundResult)
Given an expression that refers to an overloaded function, try to resolve that function to a single f...
static Classification makeSimpleLValue()
Create a simple, modifiably lvalue.
CanQualType UnsignedCharTy
Integral promotions (C++ [conv.prom])
This conversion function template specialization candidate is not viable because the final conversion...
bool IsStringLiteralToNonConstPointerConversion(Expr *From, QualType ToType)
Helper function to determine whether this is the (deprecated) C++ conversion from a string literal to...
SourceLocation getMemberLoc() const
Retrieve the location of the name of the member that this expression refers to.
QualType BuiltinParamTypes[3]
BuiltinParamTypes - Provides the parameter types of a built-in overload candidate.
This object can be modified without requiring retains or releases.
param_iterator param_begin()
C-only conversion between pointers with incompatible types.
DeclarationName getMemberName() const
Retrieve the name of the member that this expression refers to.
bool IsComplexPromotion(QualType FromType, QualType ToType)
Determine if a conversion is a complex promotion.
FunctionTemplateDecl * getPrimaryTemplate() const
Retrieve the primary template that this function template specialization either specializes or was in...
DiagnosticsEngine & getDiagnostics() const
RAII class used to determine whether SFINAE has trapped any errors that occur during template argumen...
bool isIntegralOrUnscopedEnumerationType() const
Determine whether this type is an integral or unscoped enumeration type.
static bool hasDeprecatedStringLiteralToCharPtrConversion(const ImplicitConversionSequence &ICS)
CXXSpecialMember
Kinds of C++ special members.
QualType getDeclaredReturnType() const
Get the declared return type, which may differ from the actual return type if the return type is dedu...
OverloadFixItKind Kind
The type of fix applied.
static Sema::TemplateDeductionResult DeduceTemplateArguments(Sema &S, TemplateParameterList *TemplateParams, const TemplateArgument &Param, TemplateArgument Arg, TemplateDeductionInfo &Info, SmallVectorImpl< DeducedTemplateArgument > &Deduced)
DeductionFailureInfo DeductionFailure
Template argument deduction info.
static void NoteAmbiguousUserConversions(Sema &S, SourceLocation OpLoc, OverloadCandidate *Cand)
Sema - This implements semantic analysis and AST building for C.
bool isPromotableIntegerType() const
More type predicates useful for type checking/promotion.
CXXRecordDecl * getAsCXXRecordDecl() const
Retrieves the CXXRecordDecl that this type refers to, either because the type is a RecordType or beca...
Represents a prototype with parameter type info, e.g.
bool compatiblyIncludes(Qualifiers other) const
Determines if these qualifiers compatibly include another set.
void erase(NamedDecl *D)
Removes any data associated with a given decl.
Transparent Union Conversions.
bool isMoreQualifiedThan(QualType Other) const
Determine whether this type is more qualified than the other given type, requiring exact equality for...
bool isStdInitializerList(QualType Ty, QualType *Element)
Tests whether Ty is an instance of std::initializer_list and, if it is and Element is not NULL...
CastKind
CastKind - The kind of operation required for a conversion.
NestedNameSpecifier * getQualifier() const
If the member name was qualified, retrieves the nested-name-specifier that precedes the member name...
The return type of classify().
static ImplicitCastExpr * Create(const ASTContext &Context, QualType T, CastKind Kind, Expr *Operand, const CXXCastPath *BasePath, ExprValueKind Cat)
DeclarationNameTable DeclarationNames
Template argument deduction did not deduce a value for every template parameter.
static ExprResult CreateFunctionRefExpr(Sema &S, FunctionDecl *Fn, NamedDecl *FoundDecl, const Expr *Base, bool HadMultipleCandidates, SourceLocation Loc=SourceLocation(), const DeclarationNameLoc &LocInfo=DeclarationNameLoc())
A convenience routine for creating a decayed reference to a function.
bool CheckPointerConversion(Expr *From, QualType ToType, CastKind &Kind, CXXCastPath &BasePath, bool IgnoreBaseAccess, bool Diagnose=true)
CheckPointerConversion - Check the pointer conversion from the expression From to the type ToType...
virtual SemaDiagnosticBuilder diagnoseExplicitConv(Sema &S, SourceLocation Loc, QualType T, QualType ConvTy)=0
Emits a diagnostic when the only matching conversion function is explicit.
bool 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...
Allows QualTypes to be sorted and hence used in maps and sets.
TemplateParameterList * getTemplateParameters() const
Get the list of template parameters.
ObjC ARC writeback conversion.
ExprResult CreateOverloadedBinOp(SourceLocation OpLoc, BinaryOperatorKind Opc, const UnresolvedSetImpl &Fns, Expr *LHS, Expr *RHS, bool RequiresADL=true)
Create a binary operation that may resolve to an overloaded operator.
QualType getElementType() const
static CallExpr * Create(const ASTContext &Ctx, Expr *Fn, ArrayRef< Expr *> Args, QualType Ty, ExprValueKind VK, SourceLocation RParenLoc, unsigned MinNumArgs=0, ADLCallKind UsesADL=NotADL)
Create a call expression.
bool hasOnlyConst() const
static OverloadingResult IsInitializerListConstructorConversion(Sema &S, Expr *From, QualType ToType, CXXRecordDecl *To, UserDefinedConversionSequence &User, OverloadCandidateSet &CandidateSet, bool AllowExplicit)
Represents a shadow constructor declaration introduced into a class by a C++11 using-declaration that...
bool isMultiVersion() const
True if this function is considered a multiversioned function.
DeclAccessPair getFoundDecl() const
Retrieves the declaration found by lookup.
This represents one expression.
static ImplicitConversionSequence TryObjectArgumentInitialization(Sema &S, SourceLocation Loc, QualType FromType, Expr::Classification FromClassification, CXXMethodDecl *Method, CXXRecordDecl *ActingContext)
TryObjectArgumentInitialization - Try to initialize the object parameter of the given member function...
Show just the "best" overload candidates.
QualType getPointeeType() const
std::string getAsString(const ASTContext &Ctx, QualType Ty) const
Represents an ambiguous user-defined conversion sequence.
ExprValueKind
The categorization of expression values, currently following the C++11 scheme.
bool isVariadic() const
Whether this function is variadic.
bool isDefaulted() const
Whether this function is defaulted per C++0x.
Expr * stripARCUnbridgedCast(Expr *e)
stripARCUnbridgedCast - Given an expression of ARCUnbridgedCast type, remove the placeholder cast...
This candidate was not viable because it is a non-default multiversioned function.
bool isArrow() const
Determine whether this member expression used the '->' operator; otherwise, it used the '...
This inherited constructor is not viable because it would slice the argument.
void takeSFINAEDiagnostic(PartialDiagnosticAt &PD)
Take ownership of the SFINAE diagnostic.
When performing template argument deduction for a function template, there were too many call argumen...
Declaration of a template type parameter.
static FindResult find(Expr *E)
Finds the overloaded expression in the given expression E of OverloadTy.
SourceLocation getLocation() const
StandardConversionSequence After
After - Represents the standard conversion that occurs after the actual user-defined conversion...
ExprResult BuildCallExpr(Scope *S, Expr *Fn, SourceLocation LParenLoc, MultiExprArg ArgExprs, SourceLocation RParenLoc, Expr *ExecConfig=nullptr, bool IsExecConfig=false)
BuildCallExpr - Handle a call to Fn with the specified array of arguments.
bool isObjCBuiltinType() const
const T * castAs() const
Member-template castAs<specific type>.
static bool isFirstArgumentCompatibleWithType(ASTContext &Context, CXXConstructorDecl *Constructor, QualType Type)
void setTypeDependent(bool TD)
Set whether this expression is type-dependent or not.
Represents a C++ destructor within a class.
void setInvalidDecl(bool Invalid=true)
setInvalidDecl - Indicates the Decl had a semantic error.
unsigned getNumInits() const
bool isImplicit() const
isImplicit - Indicates whether the declaration was implicitly generated by the implementation.
const TemplateArgumentList * getTemplateSpecializationArgs() const
Retrieve the template arguments used to produce this function template specialization from the primar...
bool isNullPtrType() const
static void CompleteNonViableCandidate(Sema &S, OverloadCandidate *Cand, ArrayRef< Expr *> Args)
CompleteNonViableCandidate - Normally, overload resolution only computes up to the first bad conversi...
void copyFrom(const AmbiguousConversionSequence &)
static bool IsStandardConversion(Sema &S, Expr *From, QualType ToType, bool InOverloadResolution, StandardConversionSequence &SCS, bool CStyle, bool AllowObjCWritebackConversion)
IsStandardConversion - Determines whether there is a standard conversion sequence (C++ [conv]...
NestedNameSpecifier * getQualifier() const
Retrieve the nested-name-specifier that qualifies the name of this declaration, if it was present in ...
static Qualifiers CollectVRQualifiers(ASTContext &Context, Expr *ArgExpr)
CollectVRQualifiers - This routine returns Volatile/Restrict qualifiers, if any, found in visible typ...
bool performsVirtualDispatch(const LangOptions &LO) const
Returns true if virtual dispatch is performed.
ObjCLifetime getObjCLifetime() const
static ConstantExpr * Create(const ASTContext &Context, Expr *E, const APValue &Result)
CXXConstructorDecl * CopyConstructor
CopyConstructor - The copy constructor that is used to perform this conversion, when the conversion i...
bool isObjCClassType() const
static bool completeFunctionType(Sema &S, FunctionDecl *FD, SourceLocation Loc, bool Complain=true)
DeclContext * getDeclContext()
Overload resolution succeeded.
bool isObjCIdType() const
True if this is equivalent to the 'id' type, i.e.
bool isCPUDispatchMultiVersion() const
True if this function is a multiversioned dispatch function as a part of the cpu_specific/cpu_dispatc...
bool isAnyComplexType() const
static OverloadedOperatorKind getOverloadedOperator(Opcode Opc)
Retrieve the overloaded operator kind that corresponds to the given unary opcode. ...
static bool IsOverloaded(const UnresolvedSetImpl &Functions)
When performing template argument deduction for a function template, there were too few call argument...
static bool IsAcceptableNonMemberOperatorCandidate(ASTContext &Context, FunctionDecl *Fn, ArrayRef< Expr *> Args)
IsAcceptableNonMemberOperatorCandidate - Determine whether Fn is an acceptable non-member overloaded ...
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...
const Expr * getExpr() const
void getAsStringInternal(std::string &Str, const PrintingPolicy &Policy) const
decls_iterator decls_begin() const
ReferenceCompareResult
ReferenceCompareResult - Expresses the result of comparing two types (cv1 T1 and cv2 T2) to determine...
virtual SemaDiagnosticBuilder diagnoseAmbiguous(Sema &S, SourceLocation Loc, QualType T)=0
Emits a diagnostic when there are multiple possible conversion functions.
Floating-integral conversions (C++ [conv.fpint])
The current expression and its subexpressions occur within an unevaluated operand (C++11 [expr]p7)...
DependentFunctionTemplateSpecializationInfo * getDependentSpecializationInfo() const
ExprResult BuildTemplateIdExpr(const CXXScopeSpec &SS, SourceLocation TemplateKWLoc, LookupResult &R, bool RequiresADL, const TemplateArgumentListInfo *TemplateArgs)
FunctionDecl * ResolveSingleFunctionTemplateSpecialization(OverloadExpr *ovl, bool Complain=false, DeclAccessPair *Found=nullptr)
Given an expression that refers to an overloaded function, try to resolve that overloaded function ex...
bool isSameOrCompatibleFunctionType(CanQualType Param, CanQualType Arg)
Compare types for equality with respect to possibly compatible function types (noreturn adjustment...
CanQualType UnsignedInt128Ty
Specifies that a value-dependent expression of integral or dependent type should be considered a null...
bool isSignedIntegerType() const
Return true if this is an integer type that is signed, according to C99 6.2.5p4 [char, signed char, short, int, long..], or an enum decl which has a signed representation.
This conversion candidate was not considered because it is an illegal instantiation of a constructor ...
bool TryToFixBadConversion(unsigned Idx, Sema &S)
static void collectViableConversionCandidates(Sema &SemaRef, Expr *From, QualType ToType, UnresolvedSetImpl &ViableConversions, OverloadCandidateSet &CandidateSet)
CXXConversionDecl * Surrogate
Surrogate - The conversion function for which this candidate is a surrogate, but only if IsSurrogate ...
UserDefinedConversionSequence - Represents a user-defined conversion sequence (C++ 13...
This candidate was not viable because its address could not be taken.
void NoteDeductionFailure(Sema &S, bool ForTakingAddress)
Diagnose a template argument deduction failure.
static bool isBetterMultiversionCandidate(const OverloadCandidate &Cand1, const OverloadCandidate &Cand2)
StandardConversionSequence Standard
When ConversionKind == StandardConversion, provides the details of the standard conversion sequence...
bool ResolveAndFixSingleFunctionTemplateSpecialization(ExprResult &SrcExpr, bool DoFunctionPointerConverion=false, bool Complain=false, SourceRange OpRangeForComplaining=SourceRange(), QualType DestTypeForComplaining=QualType(), unsigned DiagIDForComplaining=0)
DeclContext * getParent()
getParent - Returns the containing DeclContext.
ExprResult BuildLiteralOperatorCall(LookupResult &R, DeclarationNameInfo &SuffixInfo, ArrayRef< Expr *> Args, SourceLocation LitEndLoc, TemplateArgumentListInfo *ExplicitTemplateArgs=nullptr)
BuildLiteralOperatorCall - Build a UserDefinedLiteral by creating a call to a literal operator descri...
static void DiagnoseOpenCLExtensionDisabled(Sema &S, OverloadCandidate *Cand)
void setAddressSpace(LangAS space)
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
static QualType AdjustAddressSpaceForBuiltinOperandType(Sema &S, QualType T, Expr *Arg)
Helper function for adjusting address spaces for the pointer or reference operands of builtin operato...
bool isAtLeastAsQualifiedAs(CanQual< T > Other) const
Determines whether this canonical type is at least as qualified as the Other canonical type...
virtual SemaDiagnosticBuilder noteExplicitConv(Sema &S, CXXConversionDecl *Conv, QualType ConvTy)=0
Emits a note for the explicit conversion function.
QualType getFunctionTypeWithExceptionSpec(QualType Orig, const FunctionProtoType::ExceptionSpecInfo &ESI)
Get a function type and produce the equivalent function type with the specified exception specificati...
UnaryOperator - This represents the unary-expression's (except sizeof and alignof), the postinc/postdec operators from postfix-expression, and various extensions.
QualType getFunctionType(QualType ResultTy, ArrayRef< QualType > Args, const FunctionProtoType::ExtProtoInfo &EPI) const
Return a normal function type with a typed argument list.
bool DeduceReturnType(FunctionDecl *FD, SourceLocation Loc, bool Diagnose=true)
SourceLocation getMemberLoc() const
getMemberLoc - Return the location of the "member", in X->F, it is the location of 'F'...
ExprResult BuildPossibleImplicitMemberExpr(const CXXScopeSpec &SS, SourceLocation TemplateKWLoc, LookupResult &R, const TemplateArgumentListInfo *TemplateArgs, const Scope *S)
Builds an expression which might be an implicit member expression.
An lvalue reference type, per C++11 [dcl.ref].
TemplateTemplateParmDecl - Declares a template template parameter, e.g., "T" in.
unsigned getNumArgs() const
void AddMethodTemplateCandidate(FunctionTemplateDecl *MethodTmpl, DeclAccessPair FoundDecl, CXXRecordDecl *ActingContext, TemplateArgumentListInfo *ExplicitTemplateArgs, QualType ObjectType, Expr::Classification ObjectClassification, ArrayRef< Expr *> Args, OverloadCandidateSet &CandidateSet, bool SuppressUserConversions=false, bool PartialOverloading=false)
Add a C++ member function template as a candidate to the candidate set, using template argument deduc...
static bool CheckArityMismatch(Sema &S, OverloadCandidate *Cand, unsigned NumArgs)
Additional arity mismatch diagnosis specific to a function overload candidates.
const BuiltinType * getAsPlaceholderType() const
After substituting deduced template arguments, a dependent parameter type did not match the correspon...
Represents a C++ conversion function within a class.
QualType getTypeDeclType(const TypeDecl *Decl, const TypeDecl *PrevDecl=nullptr) const
Return the unique reference to the type for the specified type declaration.
bool isNull() const
Return true if this QualType doesn't point to a type yet.
bool isVolatileQualified() const
OverloadsShown getShowOverloads() const
FriendObjectKind getFriendObjectKind() const
Determines whether this declaration is the object of a friend declaration and, if so...
SourceLocation getEndLoc() const LLVM_READONLY
unsigned getCVRQualifiers() const
Retrieve the set of CVR (const-volatile-restrict) qualifiers applied to this type.
static ImplicitConversionSequence::CompareKind CompareImplicitConversionSequences(Sema &S, SourceLocation Loc, const ImplicitConversionSequence &ICS1, const ImplicitConversionSequence &ICS2)
CompareImplicitConversionSequences - Compare two implicit conversion sequences to determine whether o...
A narrowing conversion, because a non-constant-expression variable might have got narrowed...
QualType getFromType() const
CanQualType getCanonicalTypeUnqualified() const
Lvalue-to-rvalue conversion (C++ [conv.lval])
bool isConstQualified() const
Determine whether this type is const-qualified.
NarrowingKind getNarrowingKind(ASTContext &Context, const Expr *Converted, APValue &ConstantValue, QualType &ConstantType, bool IgnoreFloatToIntegralConversion=false) const
Check if this standard conversion sequence represents a narrowing conversion, according to C++11 [dcl...
RecordDecl * getDecl() const
static bool isBetterReferenceBindingKind(const StandardConversionSequence &SCS1, const StandardConversionSequence &SCS2)
Determine whether one of the given reference bindings is better than the other based on what kind of ...
bool isExplicit() const
Return true if the declartion is already resolved to be explicit.
void EraseUnwantedCUDAMatches(const FunctionDecl *Caller, SmallVectorImpl< std::pair< DeclAccessPair, FunctionDecl *>> &Matches)
Finds a function in Matches with highest calling priority from Caller context and erases all function...
void AddTemplateOverloadCandidate(FunctionTemplateDecl *FunctionTemplate, DeclAccessPair FoundDecl, TemplateArgumentListInfo *ExplicitTemplateArgs, ArrayRef< Expr *> Args, OverloadCandidateSet &CandidateSet, bool SuppressUserConversions=false, bool PartialOverloading=false, bool AllowExplicit=true, ADLCallKind IsADLCandidate=ADLCallKind::NotADL)
Add a C++ function template specialization as a candidate in the candidate set, using template argume...
bool isTemplateDecl() const
returns true if this declaration is a template
void AddBuiltinOperatorCandidates(OverloadedOperatorKind Op, SourceLocation OpLoc, ArrayRef< Expr *> Args, OverloadCandidateSet &CandidateSet)
AddBuiltinOperatorCandidates - Add the appropriate built-in operator overloads to the candidate set (...
unsigned ObjCLifetimeConversionBinding
Whether this binds a reference to an object with a different Objective-C lifetime qualifier...
static bool isNullPointerConstantForConversion(Expr *Expr, bool InOverloadResolution, ASTContext &Context)
Decl::Kind getDeclKind() const
OpaqueValueExpr - An expression referring to an opaque object of a fixed type and value class...
Integral conversions (C++ [conv.integral])
void AddBuiltinCandidate(QualType *ParamTys, ArrayRef< Expr *> Args, OverloadCandidateSet &CandidateSet, bool IsAssignmentOperator=false, unsigned NumContextualBoolArguments=0)
AddBuiltinCandidate - Add a candidate for a built-in operator.
SmallVectorImpl< OverloadCandidate >::iterator iterator
Complex promotions (Clang extension)
Assigning into this object requires the old value to be released and the new value to be retained...
A reference to an overloaded function set, either an UnresolvedLookupExpr or an UnresolvedMemberExpr...
ImplicitConversionSequence - Represents an implicit conversion sequence, which may be a standard conv...
QualType getCanonicalType() const
bool isPointerConversionToVoidPointer(ASTContext &Context) const
isPointerConversionToVoidPointer - Determines whether this conversion is a conversion of a pointer to...
ActionResult - This structure is used while parsing/acting on expressions, stmts, etc...
static bool checkAddressOfCandidateIsAvailable(Sema &S, const FunctionDecl *FD)
OverloadCandidate - A single candidate in an overload set (C++ 13.3).
FunctionDecl * getAsFunction() LLVM_READONLY
Returns the function itself, or the templated function if this is a function template.
ASTContext & getASTContext() const
static bool DiagnoseTwoPhaseLookup(Sema &SemaRef, SourceLocation FnLoc, const CXXScopeSpec &SS, LookupResult &R, OverloadCandidateSet::CandidateSetKind CSK, TemplateArgumentListInfo *ExplicitTemplateArgs, ArrayRef< Expr *> Args, bool *DoDiagnoseEmptyLookup=nullptr)
Attempt to recover from an ill-formed use of a non-dependent name in a template, where the non-depend...
SourceLocation getNameLoc() const
Gets the location of the name.
const ExtParameterInfo * ExtParameterInfos
NullPointerConstantKind isNullPointerConstant(ASTContext &Ctx, NullPointerConstantValueDependence NPC) const
isNullPointerConstant - C99 6.3.2.3p3 - Test if this reduces down to a Null pointer constant...
FunctionDecl * getTemplatedDecl() const
Get the underlying function declaration of the template.
Encodes a location in the source.
C++ [over.match.ctor], [over.match.list] Initialization of an object of class type by constructor...
QualType getReturnType() const
A helper class that allows the use of isa/cast/dyncast to detect TagType objects of enums...
bool isIdentityConversion() const
void FindAssociatedClassesAndNamespaces(SourceLocation InstantiationLoc, ArrayRef< Expr *> Args, AssociatedNamespaceSet &AssociatedNamespaces, AssociatedClassSet &AssociatedClasses)
Find the associated classes and namespaces for argument-dependent lookup for a call with the given se...
LangAS getAddressSpace() const
Return the address space of this type.
llvm::mapped_iterator< decltype(Decls)::iterator, select_second > iterator
Interfaces are the core concept in Objective-C for object oriented design.
virtual SemaDiagnosticBuilder noteAmbiguous(Sema &S, CXXConversionDecl *Conv, QualType ConvTy)=0
Emits a note for one of the candidate conversions.
static ImplicitConversionSequence::CompareKind CompareStandardConversionSequences(Sema &S, SourceLocation Loc, const StandardConversionSequence &SCS1, const StandardConversionSequence &SCS2)
CompareStandardConversionSequences - Compare two standard conversion sequences to determine whether o...
A call to a literal operator (C++11 [over.literal]) written as a user-defined literal (C++11 [lit...
Template argument deduction failed due to inconsistent cv-qualifiers on a template parameter type tha...
MutableArrayRef< Expr * > MultiExprArg
void AddMemberOperatorCandidates(OverloadedOperatorKind Op, SourceLocation OpLoc, ArrayRef< Expr *> Args, OverloadCandidateSet &CandidateSet, SourceRange OpRange=SourceRange())
Add overload candidates for overloaded operators that are member functions.
Represents a call to a member function that may be written either with member call syntax (e...
A vector splat from an arithmetic type.
IncompatiblePointer - The assignment is between two pointers types that are not compatible, but we accept them as an extension.
Template argument deduction did not deduce a value for every expansion of an expanded template parame...
static Comparison compareEnableIfAttrs(const Sema &S, const FunctionDecl *Cand1, const FunctionDecl *Cand2)
Compares the enable_if attributes of two FunctionDecls, for the purposes of overload resolution...
OverloadingResult
OverloadingResult - Capture the result of performing overload resolution.
std::string getOpenCLExtensionsFromDeclExtMap(FunctionDecl *FD)
Check if a function declaration FD associates with any extensions present in OpenCLDeclExtMap and if ...
static ImplicitConversionSequence::CompareKind compareConversionFunctions(Sema &S, FunctionDecl *Function1, FunctionDecl *Function2)
Compare the user-defined conversion functions or constructors of two user-defined conversion sequence...
std::pair< SourceLocation, PartialDiagnostic > PartialDiagnosticAt
A partial diagnostic along with the source location where this diagnostic occurs. ...
bool isIntegralType(const ASTContext &Ctx) const
Determine whether this type is an integral type.
Represents a static or instance method of a struct/union/class.
static void DiagnoseBadConversion(Sema &S, OverloadCandidate *Cand, unsigned I, bool TakingCandidateAddress)
void AddConversionCandidate(CXXConversionDecl *Conversion, DeclAccessPair FoundDecl, CXXRecordDecl *ActingContext, Expr *From, QualType ToType, OverloadCandidateSet &CandidateSet, bool AllowObjCConversionOnExplicit, bool AllowExplicit, bool AllowResultConversion=true)
AddConversionCandidate - Add a C++ conversion function as a candidate in the candidate set (C++ [over...
ExprResult DefaultLvalueConversion(Expr *E)
Represents a C++ nested name specifier, such as "\::std::vector<int>::".
No ref-qualifier was provided.
Objective-C ARC writeback conversion.
bool DiagnoseMultipleUserDefinedConversion(Expr *From, QualType ToType)
const ParmVarDecl * getParamDecl(unsigned i) const
The declaration was invalid; do nothing.
static bool IsVectorConversion(Sema &S, QualType FromType, QualType ToType, ImplicitConversionKind &ICK)
Determine whether the conversion from FromType to ToType is a valid vector conversion.
const ArrayType * getAsArrayType(QualType T) const
Type Query functions.
unsigned pack_size() const
The number of template arguments in the given template argument pack.
Qualifiers getMethodQuals() const
bool isSignedIntegerOrEnumerationType() const
Determines whether this is an integer type that is signed or an enumeration types whose underlying ty...
static bool checkArgPlaceholdersForOverload(Sema &S, MultiExprArg Args, UnbridgedCastsSet &unbridged)
checkArgPlaceholdersForOverload - Check a set of call operands for placeholders.
Specifies that a value-dependent expression should be considered to never be a null pointer constant...
OverloadingResult BestViableFunction(Sema &S, SourceLocation Loc, OverloadCandidateSet::iterator &Best)
Find the best viable function on this overload set, if it exists.
bool isScoped() const
Returns true if this is a C++11 scoped enumeration.
void addDecl(NamedDecl *D)
TemplateDeductionResult DeduceTemplateArguments(ClassTemplatePartialSpecializationDecl *Partial, const TemplateArgumentList &TemplateArgs, sema::TemplateDeductionInfo &Info)
Perform template argument deduction to determine whether the given template arguments match the given...
llvm::Optional< unsigned > getCallArgIndex()
Return the index of the call argument that this deduction failure refers to, if any.
bool isValueDependent() const
isValueDependent - Determines whether this expression is value-dependent (C++ [temp.dep.constexpr]).
Qualifiers withoutObjCLifetime() const
bool isObjCObjectPointerType() const
bool isAnyPointerType() const
bool CheckMemberPointerConversion(Expr *From, QualType ToType, CastKind &Kind, CXXCastPath &BasePath, bool IgnoreBaseAccess)
CheckMemberPointerConversion - Check the member pointer conversion from the expression From to the ty...
void setAsIdentityConversion()
StandardConversionSequence - Set the standard conversion sequence to the identity conversion...
Pointer conversions (C++ [conv.ptr])
C++ [over.match.oper]: Lookup of operator function candidates in a call using operator syntax...
ImplicitCastExpr - Allows us to explicitly represent implicit type conversions, which have no direct ...
bool canBindObjCObjectType(QualType To, QualType From)
bool isLValue() const
isLValue - True if this expression is an "l-value" according to the rules of the current language...
bool hasUninstantiatedDefaultArg() const
Requests that all candidates be shown.
bool DiagnoseUseOfDecl(NamedDecl *D, ArrayRef< SourceLocation > Locs, const ObjCInterfaceDecl *UnknownObjCClass=nullptr, bool ObjCPropertyAccess=false, bool AvoidPartialAvailabilityChecks=false, ObjCInterfaceDecl *ClassReciever=nullptr)
Determine whether the use of this declaration is valid, and emit any corresponding diagnostics...
TypeClass getTypeClass() const
unsigned getMinRequiredArguments() const
Returns the minimum number of arguments needed to call this function.
unsigned HasDiagnostic
Indicates whether a diagnostic is stored in Diagnostic.
bool isAnyCharacterType() const
Determine whether this type is any of the built-in character types.
static ExplicitSpecifier getFromDecl(FunctionDecl *Function)
bool IsBuildingRecoveryCallExpr
Flag indicating if Sema is building a recovery call expression.
EnumDecl * getDecl() const
virtual bool match(QualType T)=0
Determine whether the specified type is a valid destination type for this conversion.
Derived-to-base (C++ [over.best.ics])
DeductionFailureInfo MakeDeductionFailureInfo(ASTContext &Context, Sema::TemplateDeductionResult TDK, sema::TemplateDeductionInfo &Info)
Convert from Sema's representation of template deduction information to the form used in overload-can...
bool isVectorType() const
static void DiagnoseBadDeduction(Sema &S, NamedDecl *Found, Decl *Templated, DeductionFailureInfo &DeductionFailure, unsigned NumArgs, bool TakingCandidateAddress)
Diagnose a failed template-argument deduction.
Complex-real conversions (C99 6.3.1.7)
This constructor/conversion candidate fail due to an address space mismatch between the object being ...
An rvalue ref-qualifier was provided (&&).
Assigning into this object requires a lifetime extension.
OverloadCandidateSet - A set of overload candidates, used in C++ overload resolution (C++ 13...
void setBad(BadConversionSequence::FailureKind Failure, Expr *FromExpr, QualType ToType)
Sets this sequence as a bad conversion for an explicit argument.
ExprResult BuildCallToObjectOfClassType(Scope *S, Expr *Object, SourceLocation LParenLoc, MultiExprArg Args, SourceLocation RParenLoc)
BuildCallToObjectOfClassType - Build a call to an object of class type (C++ [over.call.object]), which can end up invoking an overloaded function call operator (operator()) or performing a user-defined conversion on the object argument.
bool hasSameUnqualifiedType(QualType T1, QualType T2) const
Determine whether the given types are equivalent after cvr-qualifiers have been removed.
std::string getAsString() const
bool isInstantiationDependentType() const
Determine whether this type is an instantiation-dependent type, meaning that the type involves a temp...
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)
StringRef getName() const
Return the actual identifier string.
ImplicitConversionRank GetConversionRank(ImplicitConversionKind Kind)
GetConversionRank - Retrieve the implicit conversion rank corresponding to the given implicit convers...
A class for storing results from argument-dependent lookup.
CanQualType UnsignedShortTy
SourceLocation getBeginLoc() const LLVM_READONLY
static const Expr * IgnoreNarrowingConversion(const Expr *Converted)
Skip any implicit casts which could be either part of a narrowing conversion or after one in an impli...
const TemplateArgument * getFirstArg()
Return the first template argument this deduction failure refers to, if any.
Represents a template argument.
ExprResult PerformCopyInitialization(const InitializedEntity &Entity, SourceLocation EqualLoc, ExprResult Init, bool TopLevelOfInitList=false, bool AllowExplicit=false)
DeclContextLookupResult LookupConstructors(CXXRecordDecl *Class)
Look up the constructors for the given class.
DeclAccessPair FoundCopyConstructor
static ExprResult diagnoseAmbiguousConversion(Sema &SemaRef, SourceLocation Loc, Expr *From, Sema::ContextualImplicitConverter &Converter, QualType T, UnresolvedSetImpl &ViableConversions)
Abstract base class used to perform a contextual implicit conversion from an expression to any type p...
Dataflow Directional Tag Classes.
int getFloatingTypeOrder(QualType LHS, QualType RHS) const
Compare the rank of the two specified floating point types, ignoring the domain of the type (i...
bool isValid() const
Return true if this is a valid SourceLocation object.
SourceLocation getBeginLoc() const LLVM_READONLY
ExtInfo getExtInfo() const
A qualifier set is used to build a set of qualifiers.
DeclContext - This is used only as base class of specific decl types that can act as declaration cont...
EvalResult is a struct with detailed info about an evaluated expression.
static ImplicitConversionSequence TryImplicitConversion(Sema &S, Expr *From, QualType ToType, bool SuppressUserConversions, bool AllowExplicit, bool InOverloadResolution, bool CStyle, bool AllowObjCWritebackConversion, bool AllowObjCConversionOnExplicit)
TryImplicitConversion - Attempt to perform an implicit conversion from the given expression (Expr) to...
The base class of all kinds of template declarations (e.g., class, function, etc.).
static std::string getName(const CallEvent &Call)
bool IsFloatingPointPromotion(QualType FromType, QualType ToType)
IsFloatingPointPromotion - Determines whether the conversion from FromType to ToType is a floating po...
OverloadedOperatorKind
Enumeration specifying the different kinds of C++ overloaded operators.
ExprResult ImpCastExprToType(Expr *E, QualType Type, CastKind CK, ExprValueKind VK=VK_RValue, const CXXCastPath *BasePath=nullptr, CheckedConversionKind CCK=CCK_ImplicitConversion)
ImpCastExprToType - If Expr is not of type 'Type', insert an implicit cast.
QualType getRestrictType(QualType T) const
Return the uniqued reference to the type for a restrict qualified type.
void AddSurrogateCandidate(CXXConversionDecl *Conversion, DeclAccessPair FoundDecl, CXXRecordDecl *ActingContext, const FunctionProtoType *Proto, Expr *Object, ArrayRef< Expr *> Args, OverloadCandidateSet &CandidateSet)
AddSurrogateCandidate - Adds a "surrogate" candidate function that converts the given Object to a fun...
bool isObjCClassType() const
True if this is equivalent to the 'Class' type, i.e.
virtual SemaDiagnosticBuilder diagnoseNoMatch(Sema &S, SourceLocation Loc, QualType T)=0
Emits a diagnostic complaining that the expression does not have integral or enumeration type...
Qualifiers getMethodQualifiers() const
void AddOverloadCandidate(FunctionDecl *Function, DeclAccessPair FoundDecl, ArrayRef< Expr *> Args, OverloadCandidateSet &CandidateSet, bool SuppressUserConversions=false, bool PartialOverloading=false, bool AllowExplicit=true, bool AllowExplicitConversion=false, ADLCallKind IsADLCandidate=ADLCallKind::NotADL, ConversionSequenceList EarlyConversions=None)
AddOverloadCandidate - Adds the given function to the set of candidate functions, using the given fun...
void HandleFunctionTypeMismatch(PartialDiagnostic &PDiag, QualType FromType, QualType ToType)
HandleFunctionTypeMismatch - Gives diagnostic information for differeing function types...
bool IsAllowedCUDACall(const FunctionDecl *Caller, const FunctionDecl *Callee)
Determines whether Caller may invoke Callee, based on their CUDA host/device attributes.
static void NoteFunctionCandidate(Sema &S, OverloadCandidate *Cand, unsigned NumArgs, bool TakingCandidateAddress, LangAS CtorDestAS=LangAS::Default)
Generates a 'note' diagnostic for an overload candidate.
CanQualType UnsignedLongLongTy
static bool checkPlaceholderForOverload(Sema &S, Expr *&E, UnbridgedCastsSet *unbridgedCasts=nullptr)
checkPlaceholderForOverload - Do any interesting placeholder-like preprocessing on the given expressi...
Conversions allowed in C, but not C++.
static GenericSelectionExpr * Create(const ASTContext &Context, SourceLocation GenericLoc, Expr *ControllingExpr, ArrayRef< TypeSourceInfo *> AssocTypes, ArrayRef< Expr *> AssocExprs, SourceLocation DefaultLoc, SourceLocation RParenLoc, bool ContainsUnexpandedParameterPack, unsigned ResultIndex)
Create a non-result-dependent generic selection expression.
Array-to-pointer conversion (C++ [conv.array])
void setConversionChecker(TypeComparisonFuncTy Foo)
Resets the default conversion checker method.
A non-depnedent component of the parameter did not match the corresponding component of the argument...
PartialDiagnosticAt * getSFINAEDiagnostic()
Retrieve the diagnostic which caused this deduction failure, if any.
The name of a declaration.
static std::string getAsString(SplitQualType split, const PrintingPolicy &Policy)
StandardConversionSequence Before
Represents the standard conversion that occurs before the actual user-defined conversion.
bool IsBlockPointerConversion(QualType FromType, QualType ToType, QualType &ConvertedType)
const CXXRecordDecl * getParent() const
Return the parent of this method declaration, which is the class in which this method is defined...
bool isBooleanType() const
const Type * strip(QualType type)
Collect any qualifiers on the given type and return an unqualified type.
bool isSpecializationCopyingObject() const
Determine whether this is a member template specialization that would copy the object to itself...
bool isMoveConstructor(unsigned &TypeQuals) const
Determine whether this constructor is a move constructor (C++11 [class.copy]p3), which can be used to...
OverloadExpr * Expression
void AddArgumentDependentLookupCandidates(DeclarationName Name, SourceLocation Loc, ArrayRef< Expr *> Args, TemplateArgumentListInfo *ExplicitTemplateArgs, OverloadCandidateSet &CandidateSet, bool PartialOverloading=false)
Add function candidates found via argument-dependent lookup to the set of overloading candidates...
static QualType AdoptQualifiers(ASTContext &Context, QualType T, Qualifiers Qs)
Adopt the given qualifiers for the given type.
Expression is a Null pointer constant built from a zero integer expression that is not a simple...
bool isMSVCRTEntryPoint() const
Determines whether this function is a MSVCRT user defined entry point.
A set of unresolved declarations.
void setInstantiationDependent(bool ID)
Set whether this expression is instantiation-dependent or not.
Requests that only viable candidates be shown.
FunctionDecl * Function
Function - The actual function that this candidate represents.
bool IsMemberPointerConversion(Expr *From, QualType FromType, QualType ToType, bool InOverloadResolution, QualType &ConvertedType)
IsMemberPointerConversion - Determines whether the conversion of the expression From, which has the (possibly adjusted) type FromType, can be converted to the type ToType via a member pointer conversion (C++ 4.11).
A pointer to member type per C++ 8.3.3 - Pointers to members.
static void dropPointerConversion(StandardConversionSequence &SCS)
dropPointerConversions - If the given standard conversion sequence involves any pointer conversions...
QualType getCallResultType(const ASTContext &Context) const
Determine the type of an expression that calls a function of this type.
bool isIntegerConstantExpr(llvm::APSInt &Result, const ASTContext &Ctx, SourceLocation *Loc=nullptr, bool isEvaluated=true) const
isIntegerConstantExpr - Return true if this expression is a valid integer constant expression...
const FunctionType * adjustFunctionType(const FunctionType *Fn, FunctionType::ExtInfo EInfo)
Change the ExtInfo on a function type.
TemplateSpecCandidate & addCandidate()
Add a new candidate with NumConversions conversion sequence slots to the overload set...
Optional< sema::TemplateDeductionInfo * > isSFINAEContext() const
Determines whether we are currently in a context where template argument substitution failures are no...
bool isAggregateType() const
Determines whether the type is a C++ aggregate type or C aggregate or union type. ...
DeclarationNameInfo - A collector data type for bundling together a DeclarationName and the correspnd...
QualType apply(const ASTContext &Context, QualType QT) const
Apply the collected qualifiers to the given type.
bool CheckNonDependentConversions(FunctionTemplateDecl *FunctionTemplate, ArrayRef< QualType > ParamTypes, ArrayRef< Expr *> Args, OverloadCandidateSet &CandidateSet, ConversionSequenceList &Conversions, bool SuppressUserConversions, CXXRecordDecl *ActingContext=nullptr, QualType ObjectType=QualType(), Expr::Classification ObjectClassification={})
Check that implicit conversion sequences can be formed for each argument whose corresponding paramete...
void dump() const
dump - Print this user-defined conversion sequence to standard error.
void * Data
Opaque pointer containing additional data about this deduction failure.
bool isUndeducedType() const
Determine whether this type is an undeduced type, meaning that it somehow involves a C++11 'auto' typ...
void AddFunctionCandidates(const UnresolvedSetImpl &Functions, ArrayRef< Expr *> Args, OverloadCandidateSet &CandidateSet, TemplateArgumentListInfo *ExplicitTemplateArgs=nullptr, bool SuppressUserConversions=false, bool PartialOverloading=false, bool FirstArgumentIsBase=false)
Add all of the function declarations in the given function set to the overload candidate set...
param_iterator param_end()
static void NoteSurrogateCandidate(Sema &S, OverloadCandidate *Cand)
bool hasSFINAEDiagnostic() const
Is a SFINAE diagnostic available?
FunctionDecl * ConversionFunction
ConversionFunction - The function that will perform the user-defined conversion.
Represents a pointer to an Objective C object.
Conversion only allowed in the C standard (e.g. void* to char*).
unsigned getIntWidth(QualType T) const
Not an overloaded operator.
const UnresolvedSetImpl & asUnresolvedSet() const
ExprResult CreateOverloadedArraySubscriptExpr(SourceLocation LLoc, SourceLocation RLoc, Expr *Base, Expr *Idx)
bool IsPointerConversion(Expr *From, QualType FromType, QualType ToType, bool InOverloadResolution, QualType &ConvertedType, bool &IncompatibleObjC)
IsPointerConversion - Determines whether the conversion of the expression From, which has the (possib...
A helper class that allows the use of isa/cast/dyncast to detect TagType objects of structs/unions/cl...
void setAllToTypes(QualType T)
Complex values, per C99 6.2.5p11.
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.
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)
bool isInitListConstructor(const FunctionDecl *Ctor)
Determine whether Ctor is an initializer-list constructor, as defined in [dcl.init.list]p2.
static bool isNonTrivialObjCLifetimeConversion(Qualifiers FromQuals, Qualifiers ToQuals)
Determine whether the lifetime conversion between the two given qualifiers sets is nontrivial...
void NoteCandidates(PartialDiagnosticAt PA, Sema &S, OverloadCandidateDisplayKind OCD, ArrayRef< Expr *> Args, StringRef Opc="", SourceLocation Loc=SourceLocation(), llvm::function_ref< bool(OverloadCandidate &)> Filter=[](OverloadCandidate &) { return true;})
When overload resolution fails, prints diagnostic messages containing the candidates in the candidate...
bool isObjectType() const
Determine whether this type is an object type.
uint64_t getTypeSize(QualType T) const
Return the size of the specified (complete) type T, in bits.
Condition in a constexpr if statement.
bool isIncompleteType(NamedDecl **Def=nullptr) const
Types are partitioned into 3 broad categories (C99 6.2.5p1): object types, function types...
bool hasObjCGCAttr() const
bool checkAddressOfFunctionIsAvailable(const FunctionDecl *Function, bool Complain=false, SourceLocation Loc=SourceLocation())
Returns whether the given function's address can be taken or not, optionally emitting a diagnostic if...
bool LookupQualifiedName(LookupResult &R, DeclContext *LookupCtx, bool InUnqualifiedLookup=false)
Perform qualified name lookup into a given context.
TemplateArgumentList * getTemplateArgumentList()
Retrieve the template argument list associated with this deduction failure, if any.
ConversionFixItGenerator Fix
The FixIt hints which can be used to fix the Bad candidate.
llvm::iterator_range< specific_attr_iterator< T > > specific_attrs() const
CanQualType getCanonicalType(QualType T) const
Return the canonical (structural) type corresponding to the specified potentially non-canonical type ...
AmbiguousConversionSequence Ambiguous
When ConversionKind == AmbiguousConversion, provides the details of the ambiguous conversion...
void setHadMultipleCandidates(bool V=true)
Sets the flag telling whether this expression refers to a function that was resolved from an overload...
A template argument list.
bool isLValueReferenceType() const
void addConversion(NamedDecl *Found, FunctionDecl *D)
SourceLocation getCXXLiteralOperatorNameLoc() const
getCXXLiteralOperatorNameLoc - Returns the location of the literal operator name (not the operator ke...
X
Add a minimal nested name specifier fixit hint to allow lookup of a tag name from an outer enclosing ...
Reading or writing from this object requires a barrier call.
bool hasSimilarType(QualType T1, QualType T2)
Determine if two types are similar, according to the C++ rules.
ArgKind getKind() const
Return the kind of stored template argument.
CCEKind
Contexts in which a converted constant expression is required.
static void BuildBasePathArray(const CXXBasePath &Path, CXXCastPath &BasePathArray)
static CXXMemberCallExpr * Create(const ASTContext &Ctx, Expr *Fn, ArrayRef< Expr *> Args, QualType Ty, ExprValueKind VK, SourceLocation RP, unsigned MinNumArgs=0)
QualType getParamType(unsigned i) const
SmallVector< OverloadCandidate *, 32 > CompleteCandidates(Sema &S, OverloadCandidateDisplayKind OCD, ArrayRef< Expr *> Args, SourceLocation OpLoc=SourceLocation(), llvm::function_ref< bool(OverloadCandidate &)> Filter=[](OverloadCandidate &) { return true;})
bool typesAreCompatible(QualType T1, QualType T2, bool CompareUnqualified=false)
Compatibility predicates used to check assignment expressions.
bool FunctionParamTypesAreEqual(const FunctionProtoType *OldType, const FunctionProtoType *NewType, unsigned *ArgPos=nullptr)
FunctionParamTypesAreEqual - This routine checks two function proto types for equality of their argum...
Function-to-pointer (C++ [conv.array])
MemberExpr - [C99 6.5.2.3] Structure and Union Members.
QualType getToType() const
ActionResult< Expr * > ExprResult
QualType getUnqualifiedType() const
Retrieve the unqualified variant of the given type, removing as little sugar as possible.
bool hasUnaligned() const
bool mergeExtParameterInfo(const FunctionProtoType *FirstFnType, const FunctionProtoType *SecondFnType, bool &CanUseFirst, bool &CanUseSecond, SmallVectorImpl< FunctionProtoType::ExtParameterInfo > &NewParamInfos)
This function merges the ExtParameterInfo lists of two functions.
Represents a C++ struct/union/class.
static ImplicitConversionSequence TryReferenceInit(Sema &S, Expr *Init, QualType DeclType, SourceLocation DeclLoc, bool SuppressUserConversions, bool AllowExplicit)
Compute an implicit conversion sequence for reference initialization.
Compatible - the types are compatible according to the standard.
QualType getRValueReferenceType(QualType T) const
Return the uniqued reference to the type for an rvalue reference to the specified type...
The template argument is a template name that was provided for a template template parameter...
void addAllDecls(const LookupResult &Other)
Add all the declarations from another set of lookup results.
OverloadsShown
Specifies which overload candidates to display when overload resolution fails.
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.
static bool isAddressSpaceSupersetOf(LangAS A, LangAS B)
Returns true if address space A is equal to or a superset of B.
QualType getPointerType(QualType T) const
Return the uniqued reference to the type for a pointer to the specified type.
static FixItHint CreateReplacement(CharSourceRange RemoveRange, StringRef Code)
Create a code modification hint that replaces the given source range with the given code string...
This class is used for builtin types like 'int'.
bool DiagnoseEmptyLookup(Scope *S, CXXScopeSpec &SS, LookupResult &R, CorrectionCandidateCallback &CCC, TemplateArgumentListInfo *ExplicitTemplateArgs=nullptr, ArrayRef< Expr *> Args=None, TypoExpr **Out=nullptr)
Diagnose an empty lookup.
static void AddBuiltinAssignmentOperatorCandidates(Sema &S, QualType T, ArrayRef< Expr *> Args, OverloadCandidateSet &CandidateSet)
Helper function for AddBuiltinOperatorCandidates() that adds the volatile- and non-volatile-qualified...
After substituting deduced template arguments, an element of a dependent parameter type did not match...
SourceRange getSourceRange() const LLVM_READONLY
SourceLocation tokens are not useful in isolation - they are low level value objects created/interpre...
static void DiagnoseBadTarget(Sema &S, OverloadCandidate *Cand)
CUDA: diagnose an invalid call across targets.
__DEVICE__ int min(int __a, int __b)
A little helper class (which is basically a smart pointer that forwards info from DiagnosticsEngine) ...
static bool canBeDeclaredInNamespace(const DeclarationName &Name)
Determine whether a declaration with the specified name could be moved into a different namespace...
Defines the clang::TargetInfo interface.
CallExpr - Represents a function call (C99 6.5.2.2, C++ [expr.call]).
bool isMicrosoft() const
Is this ABI an MSVC-compatible ABI?
ImplicitConversionRank getRank() const
getRank - Retrieve the rank of this standard conversion sequence (C++ 13.3.3.1.1p3).
SourceRange getSourceRange() const override LLVM_READONLY
Source range that this declaration covers.
StringRef getName() const
Get the name of identifier for this declaration as a StringRef.
unsigned getCVRQualifiers() const
std::string getQualifiedNameAsString() const
ExprResult CheckConvertedConstantExpression(Expr *From, QualType T, llvm::APSInt &Value, CCEKind CCE)
bool IsQualificationConversion(QualType FromType, QualType ToType, bool CStyle, bool &ObjCLifetimeConversion)
IsQualificationConversion - Determines whether the conversion from an rvalue of type FromType to ToTy...
bool isDependentType() const
Whether this type is a dependent type, meaning that its definition somehow depends on a template para...
QualType getAsType() const
Retrieve the type for a type template argument.
SourceLocation getBeginLoc() const LLVM_READONLY
A reference to a declared variable, function, enum, etc.
Represents a type template specialization; the template must be a class template, a type alias templa...
void AddTemplateConversionCandidate(FunctionTemplateDecl *FunctionTemplate, DeclAccessPair FoundDecl, CXXRecordDecl *ActingContext, Expr *From, QualType ToType, OverloadCandidateSet &CandidateSet, bool AllowObjCConversionOnExplicit, bool AllowExplicit, bool AllowResultConversion=true)
Adds a conversion function template specialization candidate to the overload set, using template argu...
bool isDeleted() const
Whether this function has been deleted.
NestedNameSpecifierLoc getQualifierLoc() const
Fetches the nested-name qualifier with source-location information, if one was given.
bool isPointerType() const
Zero constant to event (OpenCL1.2 6.12.10)
unsigned CallArgIndex
The index of the function argument that caused a deduction failure.
SourceManager & SourceMgr
static OverloadedOperatorKind getOverloadedOperator(Opcode Opc)
Retrieve the overloaded operator kind that corresponds to the given binary opcode.
void NoteAllOverloadCandidates(Expr *E, QualType DestType=QualType(), bool TakingAddress=false)
BasePaths - Represents the set of paths from a derived class to one of its (direct or indirect) bases...
ImplicitConversionKind First
First – The first conversion can be an lvalue-to-rvalue conversion, array-to-pointer conversion...
No viable function found.
void NoteCandidates(Sema &S, SourceLocation Loc)
NoteCandidates - When no template specialization match is found, prints diagnostic messages containin...
TemplateArgument FirstArg
The first template argument to which the template argument deduction failure refers.
DeductionFailureInfo DeductionFailure
void suppressDiagnostics()
Suppress the diagnostics that would normally fire because of this lookup.
static bool recordConversion(Sema &SemaRef, SourceLocation Loc, Expr *&From, Sema::ContextualImplicitConverter &Converter, QualType T, bool HadMultipleCandidates, DeclAccessPair &Found)
bool empty() const
Return true if no decls were found.
An l-value expression is a reference to an object with independent storage.
bool isUnresolvedExceptionSpec(ExceptionSpecificationType ESpecType)
A trivial tuple used to represent a source range.
static StringRef getOpcodeStr(Opcode Op)
getOpcodeStr - Turn an Opcode enum value into the punctuation char it corresponds to...
This represents a decl that may have a name.
void dump() const
dump - Print this standard conversion sequence to standard error.
QualType getObjCObjectPointerType(QualType OIT) const
Return a ObjCObjectPointerType type for the given ObjCObjectType.
TemplateDecl * getDescribedTemplate() const
If this is a declaration that describes some template, this method returns that template declaration...
QualType getNonTypeTemplateArgumentType() const
If this is a non-type template argument, get its type.
TemplateName getAsTemplate() const
Retrieve the template name for a template name argument.
Pointer-to-member conversions (C++ [conv.mem])
SourceLocation getNameLoc() const
Gets the location of the identifier.
static OverloadingResult IsUserDefinedConversion(Sema &S, Expr *From, QualType ToType, UserDefinedConversionSequence &User, OverloadCandidateSet &Conversions, bool AllowExplicit, bool AllowObjCConversionOnExplicit)
Determines whether there is a user-defined conversion sequence (C++ [over.ics.user]) that converts ex...
Look up of an operator name (e.g., operator+) for use with operator overloading.
Describes an entity that is being initialized.
static UserDefinedLiteral * Create(const ASTContext &Ctx, Expr *Fn, ArrayRef< Expr *> Args, QualType Ty, ExprValueKind VK, SourceLocation LitEndLoc, SourceLocation SuffixLoc)
SmallVector< TemplateSpecCandidate, 16 >::iterator iterator
void setToType(unsigned Idx, QualType T)
EnableIfAttr * CheckEnableIf(FunctionDecl *Function, ArrayRef< Expr *> Args, bool MissingImplicitThis=false)
Check the enable_if expressions on the given function.
unsigned getNumParams() const
Return the number of parameters this function must have based on its FunctionType.
char Diagnostic[sizeof(PartialDiagnosticAt)]
A diagnostic indicating why deduction failed.
void removeAddressSpace()
SourceLocation getBegin() const
const LangOptions & getLangOpts() const
static ImplicitConversionSequence TryCopyInitialization(Sema &S, Expr *From, QualType ToType, bool SuppressUserConversions, bool InOverloadResolution, bool AllowObjCWritebackConversion, bool AllowExplicit=false)
TryCopyInitialization - Try to copy-initialize a value of type ToType from the expression From...
decls_iterator decls_end() const
The explicitly-specified template arguments were not valid template arguments for the given template...
This conversion candidate is not viable because its result type is not implicitly convertible to the ...
QualType getBaseType() const
Declaration of a template function.
static bool diagnoseDiagnoseIfAttrsWith(Sema &S, const NamedDecl *ND, bool ArgDependent, SourceLocation Loc, CheckFn &&IsSuccessful)
A class which abstracts out some details necessary for making a call.
static QualType BuildSimilarlyQualifiedPointerType(const Type *FromPtr, QualType ToPointee, QualType ToType, ASTContext &Context, bool StripObjCLifetime=false)
BuildSimilarlyQualifiedPointerType - In a pointer conversion from the pointer type FromPtr to a point...
static ImplicitConversionSequence TryUserDefinedConversion(Sema &S, Expr *From, QualType ToType, bool SuppressUserConversions, bool AllowExplicit, bool InOverloadResolution, bool CStyle, bool AllowObjCWritebackConversion, bool AllowObjCConversionOnExplicit)
Tries a user-defined conversion from From to ToType.
QualType getUnqualifiedArrayType(QualType T, Qualifiers &Quals)
Return this type as a completely-unqualified array type, capturing the qualifiers in Quals...
Attr - This represents one attribute.
bool isDeletedAsWritten() const
SourceLocation getLocation() const
bool isIncompleteOrObjectType() const
Return true if this is an incomplete or object type, in other words, not a function type...
bool isCXX11ConstantExpr(const ASTContext &Ctx, APValue *Result=nullptr, SourceLocation *Loc=nullptr) const
isCXX11ConstantExpr - Return true if this expression is a constant expression in C++11.
QualType getPointeeType() const
A single template declaration.
ArrayRef< ParmVarDecl * > parameters() const
Expr * IgnoreParens() LLVM_READONLY
Skip past any parentheses which might surround this expression until reaching a fixed point...
CanQualType UnsignedIntTy
bool hasErrorOccurred() const
Determine whether any SFINAE errors have been trapped.
unsigned NumConversionsFixed
The number of Conversions fixed.
param_type_iterator param_type_end() const
QualType getPointeeType() const
Gets the type pointed to by this ObjC pointer.
StandardConversionSequence - represents a standard conversion sequence (C++ 13.3.3.1.1).
static void DiagnoseFailedEnableIfAttr(Sema &S, OverloadCandidate *Cand)