31 #include "llvm/ADT/DenseSet.h"
32 #include "llvm/ADT/STLExtras.h"
33 #include "llvm/ADT/SmallPtrSet.h"
34 #include "llvm/ADT/SmallString.h"
38 using namespace clang;
43 std::mem_fn(&ParmVarDecl::hasAttr<PassObjectSizeAttr>));
49 bool HadMultipleCandidates,
64 if (HadMultipleCandidates)
73 bool InOverloadResolution,
76 bool AllowObjCWritebackConversion);
80 bool InOverloadResolution,
88 bool AllowObjCConversionOnExplicit);
140 return Rank[(int)Kind];
150 "Function-to-pointer",
151 "Noreturn adjustment",
153 "Integral promotion",
154 "Floating point promotion",
156 "Integral conversion",
157 "Floating conversion",
158 "Complex conversion",
159 "Floating-integral conversion",
160 "Pointer conversion",
161 "Pointer-to-member conversion",
162 "Boolean conversion",
163 "Compatible-types conversion",
164 "Derived-to-base conversion",
167 "Complex-real conversion",
168 "Block Pointer conversion",
169 "Transparent Union Conversion",
170 "Writeback conversion",
171 "OpenCL Zero Event Conversion",
172 "C specific type conversion"
183 DeprecatedStringLiteralToCharPtr =
false;
184 QualificationIncludesObjCLifetime =
false;
185 ReferenceBinding =
false;
186 DirectBinding =
false;
187 IsLvalueReference =
true;
188 BindsToFunctionLvalue =
false;
189 BindsToRvalue =
false;
190 BindsImplicitObjectArgumentWithoutRefQualifier =
false;
191 ObjCLifetimeConversionBinding =
false;
192 CopyConstructor =
nullptr;
219 (getFromType()->isPointerType() ||
220 getFromType()->isObjCObjectPointerType() ||
221 getFromType()->isBlockPointerType() ||
222 getFromType()->isNullPtrType() ||
255 while (
const ImplicitCastExpr *ICE = dyn_cast<ImplicitCastExpr>(Converted)) {
256 switch (ICE->getCastKind()) {
265 Converted = ICE->getSubExpr();
287 const Expr *Converted,
290 assert(Ctx.
getLangOpts().CPlusPlus &&
"narrowing check outside C++");
299 if (FromType->isRealFloatingType())
300 goto FloatingIntegralConversion;
301 if (FromType->isIntegralOrUnscopedEnumerationType())
302 goto IntegralConversion;
314 FloatingIntegralConversion:
315 if (FromType->isRealFloatingType() && ToType->
isIntegralType(Ctx)) {
318 llvm::APSInt IntConstantValue;
324 Result.convertFromAPInt(IntConstantValue, IntConstantValue.isSigned(),
325 llvm::APFloat::rmNearestTiesToEven);
327 llvm::APSInt ConvertedValue = IntConstantValue;
329 Result.convertToInteger(ConvertedValue,
330 llvm::APFloat::rmTowardZero, &ignored);
332 if (IntConstantValue != ConvertedValue) {
333 ConstantValue =
APValue(IntConstantValue);
334 ConstantType = Initializer->
getType();
355 assert(ConstantValue.
isFloat());
356 llvm::APFloat FloatVal = ConstantValue.
getFloat();
359 llvm::APFloat::opStatus ConvertStatus = FloatVal.convert(
361 llvm::APFloat::rmNearestTiesToEven, &ignored);
364 if (ConvertStatus & llvm::APFloat::opOverflow) {
365 ConstantType = Initializer->
getType();
380 IntegralConversion: {
381 assert(FromType->isIntegralOrUnscopedEnumerationType());
383 const bool FromSigned = FromType->isSignedIntegerOrEnumerationType();
384 const unsigned FromWidth = Ctx.
getIntWidth(FromType);
388 if (FromWidth > ToWidth ||
389 (FromWidth == ToWidth && FromSigned != ToSigned) ||
390 (FromSigned && !ToSigned)) {
392 llvm::APSInt InitializerValue;
398 bool Narrowing =
false;
399 if (FromWidth < ToWidth) {
402 if (InitializerValue.isSigned() && InitializerValue.isNegative())
407 InitializerValue = InitializerValue.extend(
408 InitializerValue.getBitWidth() + 1);
410 llvm::APSInt ConvertedValue = InitializerValue;
411 ConvertedValue = ConvertedValue.trunc(ToWidth);
412 ConvertedValue.setIsSigned(ToSigned);
413 ConvertedValue = ConvertedValue.extend(InitializerValue.getBitWidth());
414 ConvertedValue.setIsSigned(InitializerValue.isSigned());
416 if (ConvertedValue != InitializerValue)
420 ConstantType = Initializer->
getType();
421 ConstantValue =
APValue(InitializerValue);
437 raw_ostream &OS = llvm::errs();
438 bool PrintedSomething =
false;
441 PrintedSomething =
true;
445 if (PrintedSomething) {
450 if (CopyConstructor) {
451 OS <<
" (by copy constructor)";
452 }
else if (DirectBinding) {
453 OS <<
" (direct reference binding)";
454 }
else if (ReferenceBinding) {
455 OS <<
" (reference binding)";
457 PrintedSomething =
true;
461 if (PrintedSomething) {
465 PrintedSomething =
true;
468 if (!PrintedSomething) {
469 OS <<
"No conversions required";
476 raw_ostream &OS = llvm::errs();
477 if (Before.First || Before.Second || Before.Third) {
481 if (ConversionFunction)
482 OS <<
'\'' << *ConversionFunction <<
'\'';
484 OS <<
"aggregate initialization";
494 raw_ostream &OS = llvm::errs();
495 if (isStdInitializerListElement())
496 OS <<
"Worst std::initializer_list element conversion: ";
497 switch (ConversionKind) {
498 case StandardConversion:
499 OS <<
"Standard conversion: ";
502 case UserDefinedConversion:
503 OS <<
"User-defined conversion: ";
506 case EllipsisConversion:
507 OS <<
"Ellipsis conversion";
509 case AmbiguousConversion:
510 OS <<
"Ambiguous conversion";
513 OS <<
"Bad conversion";
525 conversions().~ConversionSet();
538 struct DFIArguments {
544 struct DFIParamWithArguments : DFIArguments {
549 struct DFIDeducedMismatchArgs : DFIArguments {
551 unsigned CallArgIndex;
562 Result.
Result =
static_cast<unsigned>(TDK);
571 Result.
Data =
nullptr;
576 Result.
Data = Info.
Param.getOpaqueValue();
581 auto *Saved =
new (
Context) DFIDeducedMismatchArgs;
584 Saved->TemplateArgs = Info.
take();
592 DFIArguments *Saved =
new (
Context) DFIArguments;
602 DFIParamWithArguments *Saved =
new (
Context) DFIParamWithArguments;
603 Saved->Param = Info.
Param;
629 switch (static_cast<Sema::TemplateDeductionResult>(
Result)) {
652 Diag->~PartialDiagnosticAt();
653 HasDiagnostic =
false;
670 switch (static_cast<Sema::TemplateDeductionResult>(
Result)) {
684 return TemplateParameter::getFromOpaqueValue(Data);
688 return static_cast<DFIParamWithArguments*
>(Data)->Param;
699 switch (static_cast<Sema::TemplateDeductionResult>(
Result)) {
714 return static_cast<DFIDeducedMismatchArgs*
>(Data)->TemplateArgs;
728 switch (static_cast<Sema::TemplateDeductionResult>(
Result)) {
744 return &
static_cast<DFIArguments*
>(Data)->FirstArg;
755 switch (static_cast<Sema::TemplateDeductionResult>(
Result)) {
771 return &
static_cast<DFIArguments*
>(Data)->SecondArg;
782 if (static_cast<Sema::TemplateDeductionResult>(
Result) ==
784 return static_cast<Expr*
>(Data);
790 if (static_cast<Sema::TemplateDeductionResult>(
Result) ==
792 return static_cast<DFIDeducedMismatchArgs*
>(Data)->CallArgIndex;
797 void OverloadCandidateSet::destroyCandidates() {
799 for (
unsigned ii = 0, ie = i->NumConversions; ii != ie; ++ii)
800 i->Conversions[ii].~ImplicitConversionSequence();
802 i->DeductionFailure.Destroy();
808 NumInlineSequences = 0;
814 class UnbridgedCastsSet {
824 Entry entry = { &
E, E };
825 Entries.push_back(entry);
831 i = Entries.begin(), e = Entries.end(); i != e; ++i)
846 UnbridgedCastsSet *unbridgedCasts =
nullptr) {
850 if (placeholder->getKind() == BuiltinType::Overload)
return false;
854 if (placeholder->getKind() == BuiltinType::ARCUnbridgedCast &&
856 unbridgedCasts->save(S, E);
877 UnbridgedCastsSet &unbridged) {
878 for (
unsigned i = 0, e = Args.size(); i != e; ++i)
921 NamedDecl *&Match,
bool NewIsUsingDecl) {
926 bool OldIsUsingDecl =
false;
927 if (isa<UsingShadowDecl>(OldD)) {
928 OldIsUsingDecl =
true;
932 if (NewIsUsingDecl)
continue;
934 OldD = cast<UsingShadowDecl>(OldD)->getTargetDecl();
939 if ((OldIsUsingDecl || NewIsUsingDecl) && !isVisible(*
I))
947 bool UseMemberUsingDeclRules =
948 (OldIsUsingDecl || NewIsUsingDecl) && CurContext->isRecord() &&
952 if (!IsOverload(New, OldF, UseMemberUsingDeclRules)) {
953 if (UseMemberUsingDeclRules && OldIsUsingDecl) {
954 HideUsingShadowDecl(S, cast<UsingShadowDecl>(*
I));
958 if (!isa<FunctionTemplateDecl>(OldD) &&
959 !shouldLinkPossiblyHiddenDecl(*
I, New))
965 }
else if (isa<UsingDecl>(OldD)) {
969 }
else if (isa<TagDecl>(OldD)) {
971 }
else if (isa<UnresolvedUsingValueDecl>(OldD)) {
980 return Ovl_NonFunction;
988 bool UseUsingDeclRules) {
1003 if ((OldTemplate ==
nullptr) != (NewTemplate ==
nullptr))
1016 if (isa<FunctionNoProtoType>(OldQType.
getTypePtr()) ||
1017 isa<FunctionNoProtoType>(NewQType.
getTypePtr()))
1026 if (OldQType != NewQType &&
1028 OldType->
isVariadic() != NewType->isVariadic() ||
1029 !FunctionParamTypesAreEqual(OldType, NewType)))
1044 if (!UseUsingDeclRules && NewTemplate &&
1047 false, TPL_TemplateMatch) ||
1061 if (OldMethod && NewMethod &&
1062 !OldMethod->
isStatic() && !NewMethod->isStatic()) {
1064 if (!UseUsingDeclRules &&
1066 NewMethod->getRefQualifier() ==
RQ_None)) {
1073 Diag(NewMethod->getLocation(), diag::err_ref_qualifier_overload)
1085 unsigned NewQuals = NewMethod->getTypeQualifiers();
1086 if (!getLangOpts().
CPlusPlus14 && NewMethod->isConstexpr() &&
1087 !isa<CXXConstructorDecl>(NewMethod))
1093 if (OldQuals != NewQuals)
1111 NewI != NewE || OldI != OldE; ++NewI, ++OldI) {
1112 if (NewI == NewE || OldI == OldE)
1114 llvm::FoldingSetNodeID NewID, OldID;
1116 OldI->getCond()->Profile(OldID,
Context,
true);
1121 if (getLangOpts().CUDA && getLangOpts().CUDATargetOverloads) {
1123 OldTarget = IdentifyCUDATarget(Old);
1124 if (NewTarget == CFT_InvalidTarget || NewTarget == CFT_Global)
1127 assert((OldTarget != CFT_InvalidTarget) &&
"Unexpected invalid target.");
1132 if ((NewTarget == CFT_HostDevice) || (OldTarget == CFT_HostDevice))
1137 return NewTarget != OldTarget;
1150 return FD->
isUnavailable() && !cast<Decl>(CurContext)->isUnavailable();
1159 bool SuppressUserConversions,
1161 bool InOverloadResolution,
1163 bool AllowObjCWritebackConversion,
1164 bool AllowObjCConversionOnExplicit) {
1167 if (SuppressUserConversions) {
1178 Conversions, AllowExplicit,
1179 AllowObjCConversionOnExplicit)) {
1197 if (Constructor->isCopyConstructor() &&
1198 (FromCanon == ToCanon ||
1199 S.
IsDerivedFrom(From->getLocStart(), FromCanon, ToCanon))) {
1207 if (ToCanon != FromCanon)
1218 Cand != Conversions.end(); ++Cand)
1261 bool SuppressUserConversions,
1263 bool InOverloadResolution,
1265 bool AllowObjCWritebackConversion,
1266 bool AllowObjCConversionOnExplicit) {
1269 ICS.
Standard, CStyle, AllowObjCWritebackConversion)){
1309 AllowExplicit, InOverloadResolution, CStyle,
1310 AllowObjCWritebackConversion,
1311 AllowObjCConversionOnExplicit);
1316 bool SuppressUserConversions,
1318 bool InOverloadResolution,
1320 bool AllowObjCWritebackConversion) {
1322 SuppressUserConversions, AllowExplicit,
1323 InOverloadResolution, CStyle,
1324 AllowObjCWritebackConversion,
1337 return PerformImplicitConversion(From, ToType, Action, AllowExplicit, ICS);
1348 bool AllowObjCWritebackConversion
1349 = getLangOpts().ObjCAutoRefCount &&
1350 (Action == AA_Passing || Action == AA_Sending);
1351 if (getLangOpts().ObjC1)
1352 CheckObjCBridgeRelatedConversions(From->getLocStart(),
1353 ToType, From->
getType(), From);
1359 AllowObjCWritebackConversion,
1361 return PerformImplicitConversion(From, ToType, ICS, Action);
1379 if (TyClass != CanFrom->getTypeClass())
return false;
1380 if (TyClass != Type::FunctionProto && TyClass != Type::FunctionNoProto) {
1381 if (TyClass == Type::Pointer) {
1384 }
else if (TyClass == Type::BlockPointer) {
1387 }
else if (TyClass == Type::MemberPointer) {
1394 TyClass = CanTo->getTypeClass();
1395 if (TyClass != CanFrom->getTypeClass())
return false;
1396 if (TyClass != Type::FunctionProto && TyClass != Type::FunctionNoProto)
1400 const FunctionType *FromFn = cast<FunctionType>(CanFrom);
1402 if (!EInfo.getNoReturn())
return false;
1405 assert(
QualType(FromFn, 0).isCanonical());
1406 if (
QualType(FromFn, 0) != CanTo)
return false;
1458 bool InOverloadResolution,
1471 bool InOverloadResolution,
1474 bool AllowObjCWritebackConversion) {
1521 if (Method && !Method->
isStatic()) {
1523 "Non-unary operator on non-static member address");
1524 assert(cast<UnaryOperator>(From->
IgnoreParens())->getOpcode()
1526 "Non-address-of operator on non-static member address");
1527 const Type *ClassType
1531 assert(cast<UnaryOperator>(From->
IgnoreParens())->getOpcode() ==
1533 "Non-address-of operator for overloaded function expression");
1558 FromType = Atomic->getValueType();
1593 if (
auto *FD = dyn_cast<FunctionDecl>(DRE->getDecl()))
1613 bool IncompatibleObjC =
false;
1667 }
else if (AllowObjCWritebackConversion &&
1671 FromType, IncompatibleObjC)) {
1677 InOverloadResolution, FromType)) {
1692 InOverloadResolution,
1715 bool ObjCLifetimeConversion;
1717 ObjCLifetimeConversion)) {
1737 CanonFrom = CanonTo;
1742 if (CanonFrom == CanonTo)
1747 if (S.
getLangOpts().CPlusPlus || !InOverloadResolution)
1770 bool InOverloadResolution,
1780 for (
const auto *it : UD->
fields()) {
1783 ToType = it->getType();
1814 return To->
getKind() == BuiltinType::Int;
1817 return To->
getKind() == BuiltinType::UInt;
1841 if (FromEnumType->getDecl()->isScoped())
1848 if (FromEnumType->getDecl()->isFixed()) {
1849 QualType Underlying = FromEnumType->getDecl()->getIntegerType();
1851 IsIntegralPromotion(
nullptr, Underlying, ToType);
1856 isCompleteType(From->getLocStart(), FromType))
1858 ToType, FromEnumType->getDecl()->getPromotionType());
1884 for (
int Idx = 0; Idx < 6; ++Idx) {
1886 if (FromSize < ToSize ||
1887 (FromSize == ToSize &&
1888 FromIsSigned == PromoteTypes[Idx]->isSignedIntegerType())) {
1908 llvm::APSInt BitWidth;
1910 MemberDecl->getBitWidth()->isIntegerConstantExpr(BitWidth,
Context)) {
1911 llvm::APSInt ToSize(BitWidth.getBitWidth(), BitWidth.isUnsigned());
1915 if (BitWidth < ToSize ||
1917 return To->
getKind() == BuiltinType::Int;
1923 return To->
getKind() == BuiltinType::UInt;
1948 if (FromBuiltin->getKind() == BuiltinType::Float &&
1949 ToBuiltin->getKind() == BuiltinType::Double)
1955 if (!getLangOpts().CPlusPlus &&
1956 (FromBuiltin->getKind() == BuiltinType::Float ||
1957 FromBuiltin->getKind() == BuiltinType::Double) &&
1958 (ToBuiltin->getKind() == BuiltinType::LongDouble))
1962 if (!getLangOpts().NativeHalfType &&
1963 FromBuiltin->getKind() == BuiltinType::Half &&
1964 ToBuiltin->getKind() == BuiltinType::Float)
2001 bool StripObjCLifetime =
false) {
2004 "Invalid similarly-qualified pointer type");
2015 if (StripObjCLifetime)
2026 if (isa<ObjCObjectPointerType>(ToType))
2035 if (isa<ObjCObjectPointerType>(ToType))
2041 bool InOverloadResolution,
2047 return !InOverloadResolution;
2071 bool InOverloadResolution,
2073 bool &IncompatibleObjC) {
2074 IncompatibleObjC =
false;
2075 if (isObjCPointerConversion(FromType, ToType, ConvertedType,
2082 ConvertedType = ToType;
2089 ConvertedType = ToType;
2096 ConvertedType = ToType;
2104 ConvertedType = ToType;
2114 ConvertedType = ToType;
2122 !getLangOpts().ObjCAutoRefCount) {
2153 if (getLangOpts().MSVCCompat && FromPointeeType->
isFunctionType() &&
2187 IsDerivedFrom(From->getLocStart(), FromPointeeType, ToPointeeType)) {
2224 bool &IncompatibleObjC) {
2225 if (!getLangOpts().ObjC1)
2237 if (ToObjCPtr && FromObjCPtr) {
2248 if (getLangOpts().
CPlusPlus && LHS && RHS &&
2250 FromObjCPtr->getPointeeType()))
2263 IncompatibleObjC =
true;
2279 if (FromObjCPtr && FromObjCPtr->isObjCBuiltinType()) {
2307 isObjCPointerConversion(FromPointeeType, ToPointeeType, ConvertedType,
2308 IncompatibleObjC)) {
2310 IncompatibleObjC =
true;
2319 isObjCPointerConversion(FromPointeeType, ToPointeeType, ConvertedType,
2320 IncompatibleObjC)) {
2335 if (FromFunctionType && ToFunctionType) {
2344 if (FromFunctionType->
getNumParams() != ToFunctionType->getNumParams() ||
2345 FromFunctionType->
isVariadic() != ToFunctionType->isVariadic() ||
2346 FromFunctionType->
getTypeQuals() != ToFunctionType->getTypeQuals())
2349 bool HasObjCConversion =
false;
2353 }
else if (isObjCPointerConversion(FromFunctionType->
getReturnType(),
2354 ToFunctionType->getReturnType(),
2355 ConvertedType, IncompatibleObjC)) {
2357 HasObjCConversion =
true;
2365 ArgIdx !=
NumArgs; ++ArgIdx) {
2367 QualType ToArgType = ToFunctionType->getParamType(ArgIdx);
2371 }
else if (isObjCPointerConversion(FromArgType, ToArgType,
2372 ConvertedType, IncompatibleObjC)) {
2374 HasObjCConversion =
true;
2381 if (HasObjCConversion) {
2385 IncompatibleObjC =
true;
2404 if (!getLangOpts().ObjCAutoRefCount ||
2446 bool IncompatibleObjC;
2448 FromPointee = ToPointee;
2449 else if (!isObjCPointerConversion(FromPointee, ToPointee, FromPointee,
2484 if (!FromFunctionType || !ToFunctionType)
2492 if (FromFunctionType->
getNumParams() != ToFunctionType->getNumParams() ||
2493 FromFunctionType->
isVariadic() != ToFunctionType->isVariadic())
2498 if (FromEInfo != ToEInfo)
2501 bool IncompatibleObjC =
false;
2503 ToFunctionType->getReturnType())) {
2507 QualType LHS = ToFunctionType->getReturnType();
2514 }
else if (isObjCPointerConversion(RHS, LHS,
2515 ConvertedType, IncompatibleObjC)) {
2516 if (IncompatibleObjC)
2526 ArgIdx !=
NumArgs; ++ArgIdx) {
2527 IncompatibleObjC =
false;
2529 QualType ToArgType = ToFunctionType->getParamType(ArgIdx);
2532 }
else if (isObjCPointerConversion(ToArgType, FromArgType,
2533 ConvertedType, IncompatibleObjC)) {
2534 if (IncompatibleObjC)
2541 if (LangOpts.ObjCAutoRefCount &&
2546 ConvertedType = ToType;
2621 if (!FromFunction || !ToFunction) {
2626 if (FromFunction->
getNumParams() != ToFunction->getNumParams()) {
2634 if (!FunctionParamTypesAreEqual(FromFunction, ToFunction, &ArgPos)) {
2636 << ToFunction->getParamType(ArgPos)
2643 ToFunction->getReturnType())) {
2650 ToQuals = ToFunction->getTypeQuals();
2651 if (FromQuals != ToQuals) {
2670 O && (O !=
E); ++O, ++N) {
2672 N->getUnqualifiedType())) {
2690 bool IgnoreBaseAccess,
2693 bool IsCStyleOrFunctionalCast = IgnoreBaseAccess;
2697 if (Diagnose && !IsCStyleOrFunctionalCast && !FromType->
isAnyPointerType() &&
2701 DiagRuntimeBehavior(From->
getExprLoc(), From,
2702 PDiag(diag::warn_impcast_bool_to_null_pointer)
2703 << ToType << From->getSourceRange());
2704 else if (!isUnevaluatedContext())
2706 << ToType << From->getSourceRange();
2713 if (FromPointeeType->
isRecordType() && ToPointeeType->isRecordType() &&
2717 unsigned InaccessibleID = 0;
2718 unsigned AmbigiousID = 0;
2720 InaccessibleID = diag::err_upcast_to_inaccessible_base;
2721 AmbigiousID = diag::err_ambiguous_derived_to_base_conv;
2723 if (CheckDerivedToBaseConversion(
2724 FromPointeeType, ToPointeeType, InaccessibleID, AmbigiousID,
2726 &BasePath, IgnoreBaseAccess))
2733 if (Diagnose && !IsCStyleOrFunctionalCast &&
2734 FromPointeeType->
isFunctionType() && ToPointeeType->isVoidType()) {
2735 assert(getLangOpts().MSVCCompat &&
2736 "this should only be possible with MSVCCompat!");
2738 << From->getSourceRange();
2748 if (FromPtrType->isObjCBuiltinType() || ToPtrType->isObjCBuiltinType())
2775 bool InOverloadResolution,
2785 ConvertedType = ToType;
2800 IsDerivedFrom(From->getLocStart(), ToClass, FromClass)) {
2818 bool IgnoreBaseAccess) {
2825 "Expr must be null pointer constant!");
2831 assert(ToPtrType &&
"No member pointer cast has a target type "
2832 "that is not a member pointer.");
2838 assert(FromClass->
isRecordType() &&
"Pointer into non-class.");
2839 assert(ToClass->isRecordType() &&
"Pointer into non-class.");
2843 bool DerivationOkay =
2844 IsDerivedFrom(From->getLocStart(), ToClass, FromClass, Paths);
2845 assert(DerivationOkay &&
2846 "Should not have been called if derivation isn't OK.");
2847 (void)DerivationOkay;
2850 getUnqualifiedType())) {
2851 std::string PathDisplayStr = getAmbiguousPathsDisplayString(Paths);
2853 << 0 << FromClass << ToClass << PathDisplayStr << From->getSourceRange();
2857 if (
const RecordType *VBase = Paths.getDetectedVirtual()) {
2859 << FromClass << ToClass <<
QualType(VBase, 0)
2860 << From->getSourceRange();
2864 if (!IgnoreBaseAccess)
2865 CheckBaseClassAccess(From->
getExprLoc(), FromClass, ToClass,
2867 diag::err_downcast_from_inaccessible_base);
2870 BuildBasePathArray(Paths, BasePath);
2896 bool CStyle,
bool &ObjCLifetimeConversion) {
2899 ObjCLifetimeConversion =
false;
2909 bool PreviousToQualsIncludeConst =
true;
2910 bool UnwrappedAnyPointer =
false;
2918 UnwrappedAnyPointer =
true;
2926 UnwrappedAnyPointer) {
2929 ObjCLifetimeConversion =
true;
2954 && !PreviousToQualsIncludeConst)
2959 PreviousToQualsIncludeConst
2960 = PreviousToQualsIncludeConst && ToQuals.
hasConst();
2977 bool InOverloadResolution,
2986 InOverloadResolution, InnerSCS,
2990 SCS.
Second = InnerSCS.Second;
2991 SCS.
setToType(1, InnerSCS.getToType(1));
2992 SCS.
Third = InnerSCS.Third;
2994 = InnerSCS.QualificationIncludesObjCLifetime;
2995 SCS.
setToType(2, InnerSCS.getToType(2));
3017 bool AllowExplicit) {
3020 Con != ConEnd; ++Con) {
3028 if (ConstructorTmpl)
3032 Constructor = cast<CXXConstructorDecl>(D);
3036 (AllowExplicit || !Constructor->isExplicit());
3040 bool SuppressUserConversions =
3042 if (ConstructorTmpl)
3046 SuppressUserConversions);
3050 SuppressUserConversions);
3054 bool HadMultipleCandidates = (CandidateSet.
size() > 1);
3082 llvm_unreachable(
"Invalid OverloadResult!");
3104 bool AllowObjCConversionOnExplicit) {
3105 assert(AllowExplicit || !AllowObjCConversionOnExplicit);
3108 bool ConstructorsOnly =
false;
3124 ConstructorsOnly =
true;
3129 = dyn_cast<CXXRecordDecl>(ToRecordType->getDecl())) {
3131 Expr **Args = &From;
3133 bool ListInitializing =
false;
3134 if (
InitListExpr *InitList = dyn_cast<InitListExpr>(From)) {
3137 S, From, ToType, ToRecordDecl, User, CandidateSet, AllowExplicit);
3141 CandidateSet.
clear();
3145 Args = InitList->getInits();
3146 NumArgs = InitList->getNumInits();
3147 ListInitializing =
true;
3152 Con != ConEnd; ++Con) {
3160 if (ConstructorTmpl)
3164 Constructor = cast<CXXConstructorDecl>(D);
3167 if (ListInitializing)
3168 Usable = Usable && (AllowExplicit || !Constructor->isExplicit());
3170 Usable = Usable &&Constructor->isConvertingConstructor(AllowExplicit);
3172 bool SuppressUserConversions = !ConstructorsOnly;
3173 if (SuppressUserConversions && ListInitializing) {
3174 SuppressUserConversions =
false;
3179 S.
Context, Constructor, ToType);
3182 if (ConstructorTmpl)
3185 llvm::makeArrayRef(Args, NumArgs),
3186 CandidateSet, SuppressUserConversions);
3191 llvm::makeArrayRef(Args, NumArgs),
3192 CandidateSet, SuppressUserConversions);
3199 if (ConstructorsOnly || isa<InitListExpr>(From)) {
3205 = dyn_cast<CXXRecordDecl>(FromRecordType->getDecl())) {
3207 const auto &Conversions = FromRecordDecl->getVisibleConversionFunctions();
3208 for (
auto I = Conversions.begin(), E = Conversions.end();
I !=
E; ++
I) {
3212 if (isa<UsingShadowDecl>(D))
3213 D = cast<UsingShadowDecl>(D)->getTargetDecl();
3217 if ((ConvTemplate = dyn_cast<FunctionTemplateDecl>(D)))
3220 Conv = cast<CXXConversionDecl>(D);
3222 if (AllowExplicit || !Conv->isExplicit()) {
3225 ActingContext, From, ToType,
3227 AllowObjCConversionOnExplicit);
3230 From, ToType, CandidateSet,
3231 AllowObjCConversionOnExplicit);
3237 bool HadMultipleCandidates = (CandidateSet.
size() > 1);
3246 = dyn_cast<CXXConstructorDecl>(Best->Function)) {
3254 if (isa<InitListExpr>(From)) {
3258 if (Best->Conversions[0].isEllipsis())
3261 User.
Before = Best->Conversions[0].Standard;
3274 = dyn_cast<CXXConversionDecl>(Best->Function)) {
3281 User.
Before = Best->Conversions[0].Standard;
3296 User.
After = Best->FinalConversion;
3299 llvm_unreachable(
"Not a constructor or conversion function?");
3308 llvm_unreachable(
"Invalid OverloadResult!");
3318 CandidateSet,
false,
false);
3320 Diag(From->getLocStart(), diag::err_typecheck_ambiguous_condition)
3321 << From->
getType() << ToType << From->getSourceRange();
3324 diag::err_typecheck_nonviable_condition_incomplete,
3325 From->
getType(), From->getSourceRange()))
3326 Diag(From->getLocStart(), diag::err_typecheck_nonviable_condition)
3327 <<
false << From->
getType() << From->getSourceRange() << ToType;
3360 if (Block1 != Block2)
3447 if (!ICS1.
isBad()) {
3590 else if (Rank2 < Rank1)
3611 bool SCS1ConvertsToVoid
3613 bool SCS2ConvertsToVoid
3615 if (SCS1ConvertsToVoid != SCS2ConvertsToVoid) {
3620 }
else if (!SCS1ConvertsToVoid && !SCS2ConvertsToVoid) {
3626 }
else if (SCS1ConvertsToVoid && SCS2ConvertsToVoid &&
3655 if (FromObjCPtr1 && FromObjCPtr2) {
3660 if (AssignLeft != AssignRight) {
3693 if (UnqualT1 == UnqualT2) {
3705 if (isa<ArrayType>(T1) && T1Quals)
3707 if (isa<ArrayType>(T2) && T2Quals)
3766 if (UnqualT1 == UnqualT2)
3771 if (isa<ArrayType>(T1) && T1Quals)
3773 if (isa<ArrayType>(T2) && T2Quals)
3896 if (FromPointee1 == FromPointee2 && ToPointee1 != ToPointee2) {
3904 if (FromPointee1 != FromPointee2 && ToPointee1 == ToPointee2) {
3921 if (FromPtr1 && FromPtr2 && ToPtr1 && ToPtr2) {
3928 bool FromAssignRight
3937 if (ToPtr1->isObjCIdType() &&
3938 (ToPtr2->isObjCQualifiedIdType() || ToPtr2->getInterfaceDecl()))
3940 if (ToPtr2->isObjCIdType() &&
3941 (ToPtr1->isObjCQualifiedIdType() || ToPtr1->getInterfaceDecl()))
3946 if (ToPtr1->isObjCQualifiedIdType() && ToPtr2->getInterfaceDecl())
3948 if (ToPtr2->isObjCQualifiedIdType() && ToPtr1->getInterfaceDecl())
3953 if (ToPtr1->isObjCClassType() &&
3954 (ToPtr2->isObjCQualifiedClassType() || ToPtr2->getInterfaceDecl()))
3956 if (ToPtr2->isObjCClassType() &&
3957 (ToPtr1->isObjCQualifiedClassType() || ToPtr1->getInterfaceDecl()))
3962 if (ToPtr1->isObjCQualifiedClassType() && ToPtr2->getInterfaceDecl())
3964 if (ToPtr2->isObjCQualifiedClassType() && ToPtr1->getInterfaceDecl())
3970 (ToAssignLeft != ToAssignRight))
3976 (FromAssignLeft != FromAssignRight))
3994 const Type *FromPointeeType1 = FromMemPointer1->
getClass();
3995 const Type *ToPointeeType1 = ToMemPointer1->getClass();
3996 const Type *FromPointeeType2 = FromMemPointer2->getClass();
3997 const Type *ToPointeeType2 = ToMemPointer2->getClass();
4003 if (FromPointee1 == FromPointee2 && ToPointee1 != ToPointee2) {
4010 if (ToPointee1 == ToPointee2 && FromPointee1 != FromPointee2) {
4051 return !Record->isInvalidDecl();
4066 bool &DerivedToBase,
4067 bool &ObjCConversion,
4068 bool &ObjCLifetimeConversion) {
4070 "T1 must be the pointee type of the reference type");
4071 assert(!OrigT2->
isReferenceType() &&
"T2 cannot be a reference type");
4083 DerivedToBase =
false;
4084 ObjCConversion =
false;
4085 ObjCLifetimeConversion =
false;
4086 if (UnqualT1 == UnqualT2) {
4091 DerivedToBase =
true;
4095 ObjCConversion =
true;
4104 if (isa<ArrayType>(T1) && T1Quals)
4106 if (isa<ArrayType>(T2) && T2Quals)
4124 ObjCLifetimeConversion =
true;
4130 if (T1Quals == T2Quals)
4144 bool AllowExplicit) {
4145 assert(T2->
isRecordType() &&
"Can only find conversions of record types.");
4150 const auto &Conversions = T2RecordDecl->getVisibleConversionFunctions();
4151 for (
auto I = Conversions.begin(), E = Conversions.end();
I !=
E; ++
I) {
4154 if (isa<UsingShadowDecl>(D))
4155 D = cast<UsingShadowDecl>(D)->getTargetDecl();
4163 Conv = cast<CXXConversionDecl>(D);
4167 if (!AllowExplicit && Conv->isExplicit())
4171 bool DerivedToBase =
false;
4172 bool ObjCConversion =
false;
4173 bool ObjCLifetimeConversion =
false;
4184 if (!ConvTemplate &&
4187 Conv->getConversionType().getNonReferenceType()
4188 .getUnqualifiedType(),
4190 DerivedToBase, ObjCConversion, ObjCLifetimeConversion) ==
4208 Init, DeclType, CandidateSet,
4212 DeclType, CandidateSet,
4216 bool HadMultipleCandidates = (CandidateSet.size() > 1);
4219 switch (CandidateSet.BestViableFunction(S, DeclLoc, Best,
true)) {
4231 if (!Best->FinalConversion.DirectBinding)
4243 "Expected a direct reference binding!");
4249 Cand != CandidateSet.end(); ++Cand)
4261 llvm_unreachable(
"Invalid OverloadResult!");
4269 bool SuppressUserConversions,
4270 bool AllowExplicit) {
4271 assert(DeclType->
isReferenceType() &&
"Reference init needs a reference");
4292 bool DerivedToBase =
false;
4293 bool ObjCConversion =
false;
4294 bool ObjCLifetimeConversion =
false;
4298 ObjCConversion, ObjCLifetimeConversion);
4327 ICS.Standard.setToType(0, T2);
4328 ICS.Standard.setToType(1, T1);
4329 ICS.Standard.setToType(2, T1);
4330 ICS.Standard.ReferenceBinding =
true;
4331 ICS.Standard.DirectBinding =
true;
4332 ICS.Standard.IsLvalueReference = !isRValRef;
4334 ICS.Standard.BindsToRvalue =
false;
4335 ICS.Standard.BindsImplicitObjectArgumentWithoutRefQualifier =
false;
4336 ICS.Standard.ObjCLifetimeConversionBinding = ObjCLifetimeConversion;
4337 ICS.Standard.CopyConstructor =
nullptr;
4338 ICS.Standard.DeprecatedStringLiteralToCharPtr =
false;
4385 ICS.Standard.setToType(0, T2);
4386 ICS.Standard.setToType(1, T1);
4387 ICS.Standard.setToType(2, T1);
4388 ICS.Standard.ReferenceBinding =
true;
4394 ICS.Standard.DirectBinding =
4397 ICS.Standard.IsLvalueReference = !isRValRef;
4399 ICS.Standard.BindsToRvalue = InitCategory.
isRValue();
4400 ICS.Standard.BindsImplicitObjectArgumentWithoutRefQualifier =
false;
4401 ICS.Standard.ObjCLifetimeConversionBinding = ObjCLifetimeConversion;
4402 ICS.Standard.CopyConstructor =
nullptr;
4403 ICS.Standard.DeprecatedStringLiteralToCharPtr =
false;
4426 if (ICS.isUserDefined() && isRValRef &&
4495 if (ICS.isStandard()) {
4496 ICS.Standard.ReferenceBinding =
true;
4497 ICS.Standard.IsLvalueReference = !isRValRef;
4498 ICS.Standard.BindsToFunctionLvalue =
false;
4499 ICS.Standard.BindsToRvalue =
true;
4500 ICS.Standard.BindsImplicitObjectArgumentWithoutRefQualifier =
false;
4501 ICS.Standard.ObjCLifetimeConversionBinding =
false;
4502 }
else if (ICS.isUserDefined()) {
4504 ICS.UserDefined.ConversionFunction->getReturnType()
4521 ICS.UserDefined.Before.setAsIdentityConversion();
4522 ICS.UserDefined.After.ReferenceBinding =
true;
4523 ICS.UserDefined.After.IsLvalueReference = !isRValRef;
4524 ICS.UserDefined.After.BindsToFunctionLvalue =
false;
4525 ICS.UserDefined.After.BindsToRvalue = !LValRefType;
4526 ICS.UserDefined.After.BindsImplicitObjectArgumentWithoutRefQualifier =
false;
4527 ICS.UserDefined.After.ObjCLifetimeConversionBinding =
false;
4535 bool SuppressUserConversions,
4536 bool InOverloadResolution,
4537 bool AllowObjCWritebackConversion,
4538 bool AllowExplicit =
false);
4544 bool SuppressUserConversions,
4545 bool InOverloadResolution,
4546 bool AllowObjCWritebackConversion) {
4575 SuppressUserConversions,
4576 InOverloadResolution,
4577 AllowObjCWritebackConversion);
4610 bool toStdInitializerList =
false;
4617 for (
unsigned i = 0, e = From->
getNumInits(); i < e; ++i) {
4621 InOverloadResolution,
4622 AllowObjCWritebackConversion);
4629 if (Result.
isBad() ||
4660 InOverloadResolution,
false,
4661 AllowObjCWritebackConversion,
4715 Init, ToType,
false, Found))
4720 bool dummy1 =
false;
4721 bool dummy2 =
false;
4722 bool dummy3 =
false;
4729 SuppressUserConversions,
4737 InOverloadResolution,
4738 AllowObjCWritebackConversion);
4742 "Sub-initialization cannot result in ellipsis conversion.");
4769 if (NumInits == 1 && !isa<InitListExpr>(From->
getInit(0)))
4771 SuppressUserConversions,
4772 InOverloadResolution,
4773 AllowObjCWritebackConversion);
4776 else if (NumInits == 0) {
4799 bool SuppressUserConversions,
4800 bool InOverloadResolution,
4801 bool AllowObjCWritebackConversion,
4802 bool AllowExplicit) {
4803 if (
InitListExpr *FromInitList = dyn_cast<InitListExpr>(From))
4805 InOverloadResolution,AllowObjCWritebackConversion);
4809 From->getLocStart(),
4810 SuppressUserConversions,
4814 SuppressUserConversions,
4816 InOverloadResolution,
4818 AllowObjCWritebackConversion,
4831 return !ICS.
isBad();
4845 unsigned Quals = isa<CXXDestructorDecl>(Method) ?
4859 assert(FromClassification.
isLValue());
4885 != FromTypeCanon.getLocalCVRQualifiers() &&
4888 FromType, ImplicitParamType);
4902 FromType, ImplicitParamType);
4922 if (!FromClassification.
isRValue()) {
4965 FromRecordType = From->
getType();
4966 DestType = ImplicitParamRecordType;
4973 *
this, From->getLocStart(), From->
getType(), FromClassification, Method,
4981 Diag(From->getLocStart(),
4982 diag::err_member_function_call_bad_cvr)
4983 << Method->getDeclName() << FromRecordType << (CVR - 1)
4984 << From->getSourceRange();
4985 Diag(Method->getLocation(), diag::note_previous_decl)
4986 << Method->getDeclName();
4991 return Diag(From->getLocStart(),
4992 diag::err_implicit_object_parameter_init)
4993 << ImplicitParamRecordType << FromRecordType << From->getSourceRange();
5001 From = FromRes.
get();
5034 return Diag(From->getLocStart(),
5035 diag::err_typecheck_bool_condition)
5036 << From->
getType() << From->getSourceRange();
5092 llvm_unreachable(
"found a first conversion kind in Second");
5095 llvm_unreachable(
"found a third conversion kind in Second");
5101 llvm_unreachable(
"unknown conversion kind");
5112 "converted constant expression outside C++11");
5141 return S.
Diag(From->getLocStart(),
5142 diag::err_typecheck_converted_constant_expression)
5143 << From->
getType() << From->getSourceRange() << T;
5147 llvm_unreachable(
"ellipsis conversion in converted constant expression");
5152 return S.
Diag(From->getLocStart(),
5153 diag::err_typecheck_converted_constant_expression_disallowed)
5154 << From->
getType() << From->getSourceRange() << T;
5158 return S.
Diag(From->getLocStart(),
5159 diag::err_typecheck_converted_constant_expression_indirect)
5160 << From->
getType() << From->getSourceRange() << T;
5172 PreNarrowingType)) {
5180 S.
Diag(From->getLocStart(), diag::ext_cce_narrowing)
5186 S.
Diag(From->getLocStart(), diag::ext_cce_narrowing)
5187 << CCE << 0 << From->
getType() << T;
5199 (RequireInt && !Eval.
Val.
isInt())) {
5206 if (Notes.empty()) {
5213 if (Notes.size() == 1 &&
5214 Notes[0].second.getDiagID() == diag::note_invalid_subexpr_in_const_expr)
5215 S.
Diag(Notes[0].first, diag::err_expr_not_cce) << CCE;
5217 S.
Diag(From->getLocStart(), diag::err_expr_not_cce)
5218 << CCE << From->getSourceRange();
5219 for (
unsigned I = 0;
I < Notes.size(); ++
I)
5220 S.
Diag(Notes[
I].first, Notes[I].second);
5231 llvm::APSInt &
Value,
5319 for (
unsigned I = 0, N = ViableConversions.
size();
I != N; ++
I) {
5321 cast<CXXConversionDecl>(ViableConversions[
I]->getUnderlyingDecl());
5331 QualType T,
bool HadMultipleCandidates,
5333 if (ExplicitConversions.
size() == 1 && !Converter.
Suppress) {
5341 std::string TypeStr;
5346 "static_cast<" + TypeStr +
">(")
5358 HadMultipleCandidates);
5371 QualType T,
bool HadMultipleCandidates,
5383 << From->getSourceRange();
5387 HadMultipleCandidates);
5402 << From->getSourceRange();
5411 for (
unsigned I = 0, N = ViableConversions.
size();
I != N; ++
I) {
5415 if (isa<UsingShadowDecl>(D))
5416 D = cast<UsingShadowDecl>(D)->getTargetDecl();
5420 if ((ConvTemplate = dyn_cast<FunctionTemplateDecl>(D)))
5423 Conv = cast<CXXConversionDecl>(D);
5427 ConvTemplate, FoundDecl, ActingContext, From, ToType, CandidateSet,
5431 ToType, CandidateSet,
5465 From = result.
get();
5470 if (Converter.
match(T))
5490 : Converter(Converter), From(From) {}
5495 } IncompleteDiagnoser(Converter, From);
5505 const auto &Conversions =
5506 cast<CXXRecordDecl>(RecordTy->
getDecl())->getVisibleConversionFunctions();
5508 bool HadMultipleCandidates =
5509 (std::distance(Conversions.begin(), Conversions.end()) > 1);
5513 bool HasUniqueTargetType =
true;
5516 for (
auto I = Conversions.begin(), E = Conversions.end();
I !=
E; ++
I) {
5526 Conversion = cast<CXXConversionDecl>(D);
5529 "Conversion operator templates are considered potentially "
5533 if (Converter.
match(CurToType) || ConvTemplate) {
5539 ExplicitConversions.
addDecl(
I.getDecl(),
I.getAccess());
5544 else if (HasUniqueTargetType &&
5546 HasUniqueTargetType =
false;
5548 ViableConversions.
addDecl(
I.getDecl(),
I.getAccess());
5566 HadMultipleCandidates,
5567 ExplicitConversions))
5573 if (!HasUniqueTargetType)
5592 HadMultipleCandidates, Found))
5601 HadMultipleCandidates,
5602 ExplicitConversions))
5610 switch (ViableConversions.
size()) {
5613 HadMultipleCandidates,
5614 ExplicitConversions))
5624 HadMultipleCandidates, Found))
5689 bool SuppressUserConversions,
5690 bool PartialOverloading,
5691 bool AllowExplicit) {
5694 assert(Proto &&
"Functions without a prototype cannot be overloaded");
5696 "Use AddTemplateOverloadCandidate for function templates");
5698 if (
CXXMethodDecl *Method = dyn_cast<CXXMethodDecl>(Function)) {
5699 if (!isa<CXXConstructorDecl>(Method)) {
5709 Args, CandidateSet, SuppressUserConversions,
5710 PartialOverloading);
5760 Candidate.
Viable =
false;
5773 Candidate.
Viable =
false;
5784 if (Args.size() < MinRequiredArgs && !PartialOverloading) {
5786 Candidate.
Viable =
false;
5799 Candidate.
Viable =
false;
5806 for (
unsigned ArgIdx = 0; ArgIdx < Args.size(); ++ArgIdx) {
5807 if (ArgIdx < NumParams) {
5815 SuppressUserConversions,
5821 Candidate.
Viable =
false;
5833 if (EnableIfAttr *FailedAttr =
CheckEnableIf(Function, Args)) {
5834 Candidate.
Viable =
false;
5847 for (
unsigned b = 0, e = Methods.size(); b < e; b++) {
5855 if (Args.size() < NumNamedArgs)
5858 for (
unsigned i = 0; i < NumNamedArgs; i++) {
5860 if (Args[i]->isTypeDependent()) {
5866 Expr *argExpr = Args[i];
5867 assert(argExpr &&
"SelectBestMethod(): missing expression");
5872 !param->
hasAttr<CFConsumedAttr>())
5888 if (ConversionState.
isBad()) {
5895 for (
unsigned i = NumNamedArgs, e = Args.size(); i < e; ++i) {
5896 if (Args[i]->isTypeDependent()) {
5909 if (Args.size() != NumNamedArgs)
5911 else if (Match && NumNamedArgs == 0 && Methods.size() > 1) {
5914 for (
unsigned b = 0, e = Methods.size(); b < e; b++) {
5915 QualType ReturnT = Methods[b]->getReturnType();
5937 const auto &FuncAttrs = Function->
getAttrs();
5939 if (
auto *EnableIf = dyn_cast<EnableIfAttr>(
Attr))
5940 Result.push_back(EnableIf);
5942 std::reverse(Result.begin(), Result.end());
5947 bool MissingImplicitThis) {
5949 if (EnableIfAttrs.empty())
5954 bool InitializationFailed =
false;
5955 bool ContainsValueDependentExpr =
false;
5958 for (
unsigned i = 0, e = Args.size(); i != e; ++i) {
5959 if (i == 0 && !MissingImplicitThis && isa<CXXMethodDecl>(Function) &&
5960 !cast<CXXMethodDecl>(Function)->isStatic() &&
5961 !isa<CXXConstructorDecl>(Function)) {
5966 if (R.isInvalid()) {
5967 InitializationFailed =
true;
5970 ContainsValueDependentExpr |= R.get()->isValueDependent();
5971 ConvertedArgs.push_back(R.get());
5980 InitializationFailed =
true;
5984 ConvertedArgs.push_back(R.
get());
5989 return EnableIfAttrs[0];
5993 for (
unsigned i = Args.size(), e = Function->
getNumParams(); i != e; ++i) {
6002 InitializationFailed =
true;
6006 ConvertedArgs.push_back(R.
get());
6010 return EnableIfAttrs[0];
6013 for (
auto *EIA : EnableIfAttrs) {
6015 if (EIA->getCond()->isValueDependent()) {
6020 if (!EIA->getCond()->EvaluateWithSubstitution(
6021 Result,
Context, Function, llvm::makeArrayRef(ConvertedArgs))) {
6022 if (!ContainsValueDependentExpr)
6024 }
else if (!Result.
isInt() || !Result.
getInt().getBoolValue()) {
6037 bool SuppressUserConversions,
6038 bool PartialOverloading) {
6042 if (isa<CXXMethodDecl>(FD) && !cast<CXXMethodDecl>(FD)->isStatic())
6044 cast<CXXMethodDecl>(FD)->getParent(),
6045 Args[0]->getType(), Args[0]->Classify(
Context),
6046 Args.slice(1), CandidateSet,
6047 SuppressUserConversions, PartialOverloading);
6050 SuppressUserConversions, PartialOverloading);
6057 ExplicitTemplateArgs,
6059 Args[0]->Classify(
Context), Args.slice(1),
6060 CandidateSet, SuppressUserConversions,
6061 PartialOverloading);
6064 ExplicitTemplateArgs, Args,
6065 CandidateSet, SuppressUserConversions,
6066 PartialOverloading);
6078 bool SuppressUserConversions) {
6082 if (isa<UsingShadowDecl>(Decl))
6083 Decl = cast<UsingShadowDecl>(Decl)->getTargetDecl();
6086 assert(isa<CXXMethodDecl>(TD->getTemplatedDecl()) &&
6087 "Expected a member function template");
6090 ObjectType, ObjectClassification,
6092 SuppressUserConversions);
6095 ObjectType, ObjectClassification,
6097 CandidateSet, SuppressUserConversions);
6114 bool SuppressUserConversions,
6115 bool PartialOverloading) {
6118 assert(Proto &&
"Methods without a prototype cannot be overloaded");
6119 assert(!isa<CXXConstructorDecl>(Method) &&
6120 "Use AddOverloadCandidate for constructors");
6150 Candidate.
Viable =
false;
6161 if (Args.size() < MinRequiredArgs && !PartialOverloading) {
6163 Candidate.
Viable =
false;
6177 *
this, CandidateSet.
getLocation(), ObjectType, ObjectClassification,
6178 Method, ActingContext);
6180 Candidate.
Viable =
false;
6190 Candidate.Viable =
false;
6197 for (
unsigned ArgIdx = 0; ArgIdx < Args.size(); ++ArgIdx) {
6198 if (ArgIdx < NumParams) {
6203 QualType ParamType = Proto->getParamType(ArgIdx);
6204 Candidate.Conversions[ArgIdx + 1]
6206 SuppressUserConversions,
6210 if (Candidate.Conversions[ArgIdx + 1].isBad()) {
6211 Candidate.Viable =
false;
6219 Candidate.Conversions[ArgIdx + 1].setEllipsis();
6223 if (EnableIfAttr *FailedAttr =
CheckEnableIf(Method, Args,
true)) {
6224 Candidate.Viable =
false;
6226 Candidate.DeductionFailure.Data = FailedAttr;
6243 bool SuppressUserConversions,
6244 bool PartialOverloading) {
6261 Specialization, Info, PartialOverloading)) {
6265 Candidate.
Viable =
false;
6277 assert(Specialization &&
"Missing member function template specialization?");
6278 assert(isa<CXXMethodDecl>(Specialization) &&
6279 "Specialization is not a member function?");
6281 ActingContext, ObjectType, ObjectClassification, Args,
6282 CandidateSet, SuppressUserConversions, PartialOverloading);
6294 bool SuppressUserConversions,
6295 bool PartialOverloading) {
6312 Specialization, Info, PartialOverloading)) {
6316 Candidate.
Viable =
false;
6328 assert(Specialization &&
"Missing function template specialization?");
6330 SuppressUserConversions, PartialOverloading);
6347 bool AllowObjCPointerConversion) {
6355 bool ObjCLifetimeConversion;
6357 ObjCLifetimeConversion))
6362 if (!AllowObjCPointerConversion)
6366 bool IncompatibleObjC =
false;
6384 bool AllowObjCConversionOnExplicit) {
6386 "Conversion function templates use AddTemplateConversionCandidate");
6393 if (
getLangOpts().CPlusPlus14 && ConvType->isUndeducedType()) {
6404 AllowObjCConversionOnExplicit))
6433 = cast<CXXRecordDecl>(ImplicitParamType->
getAs<
RecordType>()->getDecl());
6440 Candidate.
Viable =
false;
6451 if (FromCanon == ToCanon ||
6453 Candidate.
Viable =
false;
6475 Candidate.
Viable =
false;
6487 From->getLocStart());
6494 switch (ICS.getKind()) {
6504 Candidate.
Viable =
false;
6516 Candidate.
Viable =
false;
6523 Candidate.
Viable =
false;
6529 "Can only end up with a standard conversion sequence or failure");
6533 Candidate.
Viable =
false;
6551 bool AllowObjCConversionOnExplicit) {
6553 "Only conversion function templates permitted here");
6562 Specialization, Info)) {
6566 Candidate.
Viable =
false;
6578 assert(Specialization &&
"Missing function template specialization?");
6580 CandidateSet, AllowObjCConversionOnExplicit);
6615 if (ObjectInit.
isBad()) {
6616 Candidate.
Viable =
false;
6641 if (Args.size() > NumParams && !Proto->
isVariadic()) {
6642 Candidate.
Viable =
false;
6649 if (Args.size() < NumParams) {
6651 Candidate.
Viable =
false;
6658 for (
unsigned ArgIdx = 0, N = Args.size(); ArgIdx != N; ++ArgIdx) {
6659 if (ArgIdx < NumParams) {
6672 Candidate.
Viable =
false;
6685 Candidate.
Viable =
false;
6726 if (!T1Rec->getDecl()->getDefinition())
6734 OperEnd = Operators.
end();
6756 bool IsAssignmentOperator,
6757 unsigned NumContextualBoolArguments) {
6768 for (
unsigned ArgIdx = 0, N = Args.size(); ArgIdx != N; ++ArgIdx)
6775 for (
unsigned ArgIdx = 0, N = Args.size(); ArgIdx != N; ++ArgIdx) {
6788 if (ArgIdx < NumContextualBoolArguments) {
6790 "Contextual conversion to bool requires bool type");
6796 ArgIdx == 0 && IsAssignmentOperator,
6802 Candidate.
Viable =
false;
6815 class BuiltinCandidateTypeSet {
6817 typedef llvm::SmallPtrSet<QualType, 8> TypeSet;
6821 TypeSet PointerTypes;
6825 TypeSet MemberPointerTypes;
6829 TypeSet EnumerationTypes;
6833 TypeSet VectorTypes;
6836 bool HasNonRecordTypes;
6840 bool HasArithmeticOrEnumeralTypes;
6844 bool HasNullPtrType;
6853 bool AddPointerWithMoreQualifiedTypeVariants(
QualType Ty,
6855 bool AddMemberPointerWithMoreQualifiedTypeVariants(
QualType Ty);
6861 BuiltinCandidateTypeSet(
Sema &SemaRef)
6862 : HasNonRecordTypes(
false),
6863 HasArithmeticOrEnumeralTypes(
false),
6864 HasNullPtrType(
false),
6868 void AddTypesConvertedFrom(
QualType Ty,
6870 bool AllowUserConversions,
6871 bool AllowExplicitConversions,
6872 const Qualifiers &VisibleTypeConversionsQuals);
6875 iterator pointer_begin() {
return PointerTypes.begin(); }
6878 iterator pointer_end() {
return PointerTypes.end(); }
6881 iterator member_pointer_begin() {
return MemberPointerTypes.begin(); }
6884 iterator member_pointer_end() {
return MemberPointerTypes.end(); }
6887 iterator enumeration_begin() {
return EnumerationTypes.begin(); }
6890 iterator enumeration_end() {
return EnumerationTypes.end(); }
6892 iterator vector_begin() {
return VectorTypes.begin(); }
6893 iterator vector_end() {
return VectorTypes.end(); }
6895 bool hasNonRecordTypes() {
return HasNonRecordTypes; }
6896 bool hasArithmeticOrEnumeralTypes() {
return HasArithmeticOrEnumeralTypes; }
6897 bool hasNullPtrType()
const {
return HasNullPtrType; }
6912 BuiltinCandidateTypeSet::AddPointerWithMoreQualifiedTypeVariants(
QualType Ty,
6916 if (!PointerTypes.insert(Ty).second)
6921 bool buildObjCPtr =
false;
6925 buildObjCPtr =
true;
6937 unsigned BaseCVR = PointeeTy.getCVRQualifiers();
6943 if ((CVR | BaseCVR) != CVR)
continue;
6965 PointerTypes.insert(QPointerTy);
6981 BuiltinCandidateTypeSet::AddMemberPointerWithMoreQualifiedTypeVariants(
6984 if (!MemberPointerTypes.insert(Ty).second)
6988 assert(PointerTy &&
"type was not a member pointer type!");
7003 if ((CVR | BaseCVR) != CVR)
continue;
7006 MemberPointerTypes.insert(
7022 BuiltinCandidateTypeSet::AddTypesConvertedFrom(
QualType Ty,
7024 bool AllowUserConversions,
7025 bool AllowExplicitConversions,
7037 Ty = SemaRef.Context.getArrayDecayedType(Ty);
7044 HasNonRecordTypes = HasNonRecordTypes || !TyRec;
7047 HasArithmeticOrEnumeralTypes =
7051 PointerTypes.insert(Ty);
7055 if (!AddPointerWithMoreQualifiedTypeVariants(Ty, VisibleQuals))
7059 if (!AddMemberPointerWithMoreQualifiedTypeVariants(Ty))
7062 HasArithmeticOrEnumeralTypes =
true;
7063 EnumerationTypes.insert(Ty);
7067 HasArithmeticOrEnumeralTypes =
true;
7068 VectorTypes.insert(Ty);
7070 HasNullPtrType =
true;
7071 }
else if (AllowUserConversions && TyRec) {
7073 if (!SemaRef.isCompleteType(Loc, Ty))
7078 if (isa<UsingShadowDecl>(D))
7079 D = cast<UsingShadowDecl>(D)->getTargetDecl();
7083 if (isa<FunctionTemplateDecl>(D))
7087 if (AllowExplicitConversions || !Conv->
isExplicit()) {
7142 if (isa<UsingShadowDecl>(D))
7143 D = cast<UsingShadowDecl>(D)->getTargetDecl();
7177 class BuiltinOperatorOverloadBuilder {
7182 bool HasArithmeticOrEnumeralCandidateType;
7190 static const unsigned FirstIntegralType = 3;
7191 static const unsigned LastIntegralType = 20;
7192 static const unsigned FirstPromotedIntegralType = 3,
7193 LastPromotedIntegralType = 11;
7194 static const unsigned FirstPromotedArithmeticType = 0,
7195 LastPromotedArithmeticType = 11;
7196 static const unsigned NumArithmeticTypes = 20;
7200 assert(index < NumArithmeticTypes);
7202 ArithmeticTypes[NumArithmeticTypes] = {
7231 return S.
Context.*ArithmeticTypes[index];
7236 CanQualType getUsualArithmeticConversions(
unsigned L,
unsigned R) {
7251 Flt, Dbl, LDbl, SI, SL, SLL, S128, UI, UL, ULL, U128
7253 static const PromotedType ConversionsTable[LastPromotedArithmeticType]
7254 [LastPromotedArithmeticType] = {
7255 { Flt, Dbl, LDbl, Flt, Flt, Flt, Flt, Flt, Flt, Flt, Flt },
7256 { Dbl, Dbl, LDbl, Dbl, Dbl, Dbl, Dbl, Dbl, Dbl, Dbl, Dbl },
7257 { LDbl, LDbl, LDbl, LDbl, LDbl, LDbl, LDbl, LDbl, LDbl, LDbl, LDbl },
7258 { Flt, Dbl, LDbl, SI, SL, SLL, S128, UI, UL, ULL, U128 },
7259 { Flt, Dbl, LDbl, SL, SL, SLL, S128, Dep, UL, ULL, U128 },
7260 { Flt, Dbl, LDbl, SLL, SLL, SLL, S128, Dep, Dep, ULL, U128 },
7261 { Flt, Dbl, LDbl, S128, S128, S128, S128, S128, S128, S128, U128 },
7262 { Flt, Dbl, LDbl, UI, Dep, Dep, S128, UI, UL, ULL, U128 },
7263 { Flt, Dbl, LDbl, UL, UL, Dep, S128, UL, UL, ULL, U128 },
7264 { Flt, Dbl, LDbl, ULL, ULL, ULL, S128, ULL, ULL, ULL, U128 },
7265 { Flt, Dbl, LDbl, U128, U128, U128, U128, U128, U128, U128, U128 },
7268 assert(L < LastPromotedArithmeticType);
7269 assert(R < LastPromotedArithmeticType);
7270 int Idx = ConversionsTable[L][R];
7273 if (Idx != Dep)
return getArithmeticType(Idx);
7278 RT = getArithmeticType(R);
7283 if (LW > RW)
return LT;
7284 else if (LW < RW)
return RT;
7288 assert(L == SLL || R == SLL);
7294 void addPlusPlusMinusMinusStyleOverloads(
QualType CandidateTy,
7303 if (Args.size() == 1)
7314 if (Args.size() == 1)
7327 if (Args.size() == 1)
7336 (Qualifiers::Volatile |
7337 Qualifiers::Restrict)));
7338 if (Args.size() == 1)
7348 BuiltinOperatorOverloadBuilder(
7351 bool HasArithmeticOrEnumeralCandidateType,
7355 VisibleTypeConversionsQuals(VisibleTypeConversionsQuals),
7356 HasArithmeticOrEnumeralCandidateType(
7357 HasArithmeticOrEnumeralCandidateType),
7358 CandidateTypes(CandidateTypes),
7359 CandidateSet(CandidateSet) {
7361 assert(getArithmeticType(FirstPromotedIntegralType) == S.
Context.
IntTy &&
7362 "Invalid first promoted integral type");
7363 assert(getArithmeticType(LastPromotedIntegralType - 1)
7365 "Invalid last promoted integral type");
7366 assert(getArithmeticType(FirstPromotedArithmeticType)
7368 "Invalid first promoted arithmetic type");
7369 assert(getArithmeticType(LastPromotedArithmeticType - 1)
7371 "Invalid last promoted arithmetic type");
7392 if (!HasArithmeticOrEnumeralCandidateType)
7395 for (
unsigned Arith = (Op == OO_PlusPlus? 0 : 1);
7396 Arith < NumArithmeticTypes; ++Arith) {
7397 addPlusPlusMinusMinusStyleOverloads(
7398 getArithmeticType(Arith),
7414 void addPlusPlusMinusMinusPointerOverloads() {
7415 for (BuiltinCandidateTypeSet::iterator
7416 Ptr = CandidateTypes[0].pointer_begin(),
7417 PtrEnd = CandidateTypes[0].pointer_end();
7418 Ptr != PtrEnd; ++Ptr) {
7420 if (!(*Ptr)->getPointeeType()->isObjectType())
7423 addPlusPlusMinusMinusStyleOverloads(*Ptr,
7424 (!(*Ptr).isVolatileQualified() &&
7426 (!(*Ptr).isRestrictQualified() &&
7441 void addUnaryStarPointerOverloads() {
7442 for (BuiltinCandidateTypeSet::iterator
7443 Ptr = CandidateTypes[0].pointer_begin(),
7444 PtrEnd = CandidateTypes[0].pointer_end();
7445 Ptr != PtrEnd; ++Ptr) {
7452 if (Proto->getTypeQuals() || Proto->getRefQualifier())
7456 &ParamTy, Args, CandidateSet);
7466 void addUnaryPlusOrMinusArithmeticOverloads() {
7467 if (!HasArithmeticOrEnumeralCandidateType)
7470 for (
unsigned Arith = FirstPromotedArithmeticType;
7471 Arith < LastPromotedArithmeticType; ++Arith) {
7472 QualType ArithTy = getArithmeticType(Arith);
7477 for (BuiltinCandidateTypeSet::iterator
7478 Vec = CandidateTypes[0].vector_begin(),
7479 VecEnd = CandidateTypes[0].vector_end();
7480 Vec != VecEnd; ++Vec) {
7491 void addUnaryPlusPointerOverloads() {
7492 for (BuiltinCandidateTypeSet::iterator
7493 Ptr = CandidateTypes[0].pointer_begin(),
7494 PtrEnd = CandidateTypes[0].pointer_end();
7495 Ptr != PtrEnd; ++Ptr) {
7506 void addUnaryTildePromotedIntegralOverloads() {
7507 if (!HasArithmeticOrEnumeralCandidateType)
7510 for (
unsigned Int = FirstPromotedIntegralType;
7511 Int < LastPromotedIntegralType; ++Int) {
7512 QualType IntTy = getArithmeticType(Int);
7517 for (BuiltinCandidateTypeSet::iterator
7518 Vec = CandidateTypes[0].vector_begin(),
7519 VecEnd = CandidateTypes[0].vector_end();
7520 Vec != VecEnd; ++Vec) {
7532 void addEqualEqualOrNotEqualMemberPointerOverloads() {
7534 llvm::SmallPtrSet<QualType, 8> AddedTypes;
7536 for (
unsigned ArgIdx = 0, N = Args.size(); ArgIdx != N; ++ArgIdx) {
7537 for (BuiltinCandidateTypeSet::iterator
7538 MemPtr = CandidateTypes[ArgIdx].member_pointer_begin(),
7539 MemPtrEnd = CandidateTypes[ArgIdx].member_pointer_end();
7540 MemPtr != MemPtrEnd;
7546 QualType ParamTypes[2] = { *MemPtr, *MemPtr };
7563 void addRelationalPointerOrEnumeralOverloads() {
7577 UserDefinedBinaryOperators;
7579 for (
unsigned ArgIdx = 0, N = Args.size(); ArgIdx != N; ++ArgIdx) {
7580 if (CandidateTypes[ArgIdx].enumeration_begin() !=
7581 CandidateTypes[ArgIdx].enumeration_end()) {
7583 CEnd = CandidateSet.
end();
7585 if (!
C->Viable || !
C->Function ||
C->Function->getNumParams() != 2)
7588 if (
C->Function->isFunctionTemplateSpecialization())
7592 C->Function->getParamDecl(0)->getType().getUnqualifiedType();
7594 C->Function->getParamDecl(1)->getType().getUnqualifiedType();
7602 UserDefinedBinaryOperators.insert(
7610 llvm::SmallPtrSet<QualType, 8> AddedTypes;
7612 for (
unsigned ArgIdx = 0, N = Args.size(); ArgIdx != N; ++ArgIdx) {
7613 for (BuiltinCandidateTypeSet::iterator
7614 Ptr = CandidateTypes[ArgIdx].pointer_begin(),
7615 PtrEnd = CandidateTypes[ArgIdx].pointer_end();
7616 Ptr != PtrEnd; ++Ptr) {
7621 QualType ParamTypes[2] = { *Ptr, *Ptr };
7624 for (BuiltinCandidateTypeSet::iterator
7625 Enum = CandidateTypes[ArgIdx].enumeration_begin(),
7626 EnumEnd = CandidateTypes[ArgIdx].enumeration_end();
7627 Enum != EnumEnd; ++Enum) {
7632 if (!AddedTypes.insert(CanonType).second ||
7633 UserDefinedBinaryOperators.count(std::make_pair(CanonType,
7637 QualType ParamTypes[2] = { *Enum, *Enum };
7641 if (CandidateTypes[ArgIdx].hasNullPtrType()) {
7643 if (AddedTypes.insert(NullPtrTy).second &&
7644 !UserDefinedBinaryOperators.count(std::make_pair(NullPtrTy,
7646 QualType ParamTypes[2] = { NullPtrTy, NullPtrTy };
7673 llvm::SmallPtrSet<QualType, 8> AddedTypes;
7675 for (
int Arg = 0; Arg < 2; ++Arg) {
7676 QualType AsymmetricParamTypes[2] = {
7680 for (BuiltinCandidateTypeSet::iterator
7681 Ptr = CandidateTypes[Arg].pointer_begin(),
7682 PtrEnd = CandidateTypes[Arg].pointer_end();
7683 Ptr != PtrEnd; ++Ptr) {
7688 AsymmetricParamTypes[Arg] = *Ptr;
7689 if (Arg == 0 || Op == OO_Plus) {
7694 if (Op == OO_Minus) {
7699 QualType ParamTypes[2] = { *Ptr, *Ptr };
7701 Args, CandidateSet);
7736 void addGenericBinaryArithmeticOverloads(
bool isComparison) {
7737 if (!HasArithmeticOrEnumeralCandidateType)
7740 for (
unsigned Left = FirstPromotedArithmeticType;
7741 Left < LastPromotedArithmeticType; ++Left) {
7742 for (
unsigned Right = FirstPromotedArithmeticType;
7743 Right < LastPromotedArithmeticType; ++Right) {
7744 QualType LandR[2] = { getArithmeticType(Left),
7745 getArithmeticType(Right) };
7748 : getUsualArithmeticConversions(Left, Right);
7755 for (BuiltinCandidateTypeSet::iterator
7756 Vec1 = CandidateTypes[0].vector_begin(),
7757 Vec1End = CandidateTypes[0].vector_end();
7758 Vec1 != Vec1End; ++Vec1) {
7759 for (BuiltinCandidateTypeSet::iterator
7760 Vec2 = CandidateTypes[1].vector_begin(),
7761 Vec2End = CandidateTypes[1].vector_end();
7762 Vec2 != Vec2End; ++Vec2) {
7763 QualType LandR[2] = { *Vec1, *Vec2 };
7765 if (!isComparison) {
7766 if ((*Vec1)->isExtVectorType() || !(*Vec2)->isExtVectorType())
7792 if (!HasArithmeticOrEnumeralCandidateType)
7795 for (
unsigned Left = FirstPromotedIntegralType;
7796 Left < LastPromotedIntegralType; ++Left) {
7797 for (
unsigned Right = FirstPromotedIntegralType;
7798 Right < LastPromotedIntegralType; ++Right) {
7799 QualType LandR[2] = { getArithmeticType(Left),
7800 getArithmeticType(Right) };
7801 QualType Result = (Op == OO_LessLess || Op == OO_GreaterGreater)
7803 : getUsualArithmeticConversions(Left, Right);
7816 void addAssignmentMemberPointerOrEnumeralOverloads() {
7818 llvm::SmallPtrSet<QualType, 8> AddedTypes;
7820 for (
unsigned ArgIdx = 0; ArgIdx < 2; ++ArgIdx) {
7821 for (BuiltinCandidateTypeSet::iterator
7822 Enum = CandidateTypes[ArgIdx].enumeration_begin(),
7823 EnumEnd = CandidateTypes[ArgIdx].enumeration_end();
7824 Enum != EnumEnd; ++Enum) {
7831 for (BuiltinCandidateTypeSet::iterator
7832 MemPtr = CandidateTypes[ArgIdx].member_pointer_begin(),
7833 MemPtrEnd = CandidateTypes[ArgIdx].member_pointer_end();
7834 MemPtr != MemPtrEnd; ++MemPtr) {
7859 void addAssignmentPointerOverloads(
bool isEqualOp) {
7861 llvm::SmallPtrSet<QualType, 8> AddedTypes;
7863 for (BuiltinCandidateTypeSet::iterator
7864 Ptr = CandidateTypes[0].pointer_begin(),
7865 PtrEnd = CandidateTypes[0].pointer_end();
7866 Ptr != PtrEnd; ++Ptr) {
7870 else if (!(*Ptr)->getPointeeType()->isObjectType())
7881 bool NeedVolatile = !(*Ptr).isVolatileQualified() &&
7891 if (!(*Ptr).isRestrictQualified() &&
7904 (Qualifiers::Volatile |
7905 Qualifiers::Restrict)));
7913 for (BuiltinCandidateTypeSet::iterator
7914 Ptr = CandidateTypes[1].pointer_begin(),
7915 PtrEnd = CandidateTypes[1].pointer_end();
7916 Ptr != PtrEnd; ++Ptr) {
7930 bool NeedVolatile = !(*Ptr).isVolatileQualified() &&
7940 if (!(*Ptr).isRestrictQualified() &&
7953 (Qualifiers::Volatile |
7954 Qualifiers::Restrict)));
7975 void addAssignmentArithmeticOverloads(
bool isEqualOp) {
7976 if (!HasArithmeticOrEnumeralCandidateType)
7979 for (
unsigned Left = 0; Left < NumArithmeticTypes; ++Left) {
7980 for (
unsigned Right = FirstPromotedArithmeticType;
7981 Right < LastPromotedArithmeticType; ++Right) {
7983 ParamTypes[1] = getArithmeticType(Right);
8003 for (BuiltinCandidateTypeSet::iterator
8004 Vec1 = CandidateTypes[0].vector_begin(),
8005 Vec1End = CandidateTypes[0].vector_end();
8006 Vec1 != Vec1End; ++Vec1) {
8007 for (BuiltinCandidateTypeSet::iterator
8008 Vec2 = CandidateTypes[1].vector_begin(),
8009 Vec2End = CandidateTypes[1].vector_end();
8010 Vec2 != Vec2End; ++Vec2) {
8012 ParamTypes[1] = *Vec2;
8041 void addAssignmentIntegralOverloads() {
8042 if (!HasArithmeticOrEnumeralCandidateType)
8045 for (
unsigned Left = FirstIntegralType; Left < LastIntegralType; ++Left) {
8046 for (
unsigned Right = FirstPromotedIntegralType;
8047 Right < LastPromotedIntegralType; ++Right) {
8049 ParamTypes[1] = getArithmeticType(Right);
8057 ParamTypes[0] = getArithmeticType(Left);
8073 void addExclaimOverload() {
8079 void addAmpAmpOrPipePipeOverload() {
8096 void addSubscriptOverloads() {
8097 for (BuiltinCandidateTypeSet::iterator
8098 Ptr = CandidateTypes[0].pointer_begin(),
8099 PtrEnd = CandidateTypes[0].pointer_end();
8100 Ptr != PtrEnd; ++Ptr) {
8112 for (BuiltinCandidateTypeSet::iterator
8113 Ptr = CandidateTypes[1].pointer_begin(),
8114 PtrEnd = CandidateTypes[1].pointer_end();
8115 Ptr != PtrEnd; ++Ptr) {
8137 void addArrowStarOverloads() {
8138 for (BuiltinCandidateTypeSet::iterator
8139 Ptr = CandidateTypes[0].pointer_begin(),
8140 PtrEnd = CandidateTypes[0].pointer_end();
8141 Ptr != PtrEnd; ++Ptr) {
8146 if (!isa<RecordType>(C1))
8155 for (BuiltinCandidateTypeSet::iterator
8156 MemPtr = CandidateTypes[1].member_pointer_begin(),
8157 MemPtrEnd = CandidateTypes[1].member_pointer_end();
8158 MemPtr != MemPtrEnd; ++MemPtr) {
8164 QualType ParamTypes[2] = { *Ptr, *MemPtr };
8190 void addConditionalOperatorOverloads() {
8192 llvm::SmallPtrSet<QualType, 8> AddedTypes;
8194 for (
unsigned ArgIdx = 0; ArgIdx < 2; ++ArgIdx) {
8195 for (BuiltinCandidateTypeSet::iterator
8196 Ptr = CandidateTypes[ArgIdx].pointer_begin(),
8197 PtrEnd = CandidateTypes[ArgIdx].pointer_end();
8198 Ptr != PtrEnd; ++Ptr) {
8202 QualType ParamTypes[2] = { *Ptr, *Ptr };
8206 for (BuiltinCandidateTypeSet::iterator
8207 MemPtr = CandidateTypes[ArgIdx].member_pointer_begin(),
8208 MemPtrEnd = CandidateTypes[ArgIdx].member_pointer_end();
8209 MemPtr != MemPtrEnd; ++MemPtr) {
8213 QualType ParamTypes[2] = { *MemPtr, *MemPtr };
8218 for (BuiltinCandidateTypeSet::iterator
8219 Enum = CandidateTypes[ArgIdx].enumeration_begin(),
8220 EnumEnd = CandidateTypes[ArgIdx].enumeration_end();
8221 Enum != EnumEnd; ++Enum) {
8228 QualType ParamTypes[2] = { *Enum, *Enum };
8252 VisibleTypeConversionsQuals.
addConst();
8253 for (
unsigned ArgIdx = 0, N = Args.size(); ArgIdx != N; ++ArgIdx)
8256 bool HasNonRecordCandidateType =
false;
8257 bool HasArithmeticOrEnumeralCandidateType =
false;
8259 for (
unsigned ArgIdx = 0, N = Args.size(); ArgIdx != N; ++ArgIdx) {
8260 CandidateTypes.emplace_back(*
this);
8261 CandidateTypes[ArgIdx].AddTypesConvertedFrom(Args[ArgIdx]->getType(),
8264 (Op == OO_Exclaim ||
8267 VisibleTypeConversionsQuals);
8268 HasNonRecordCandidateType = HasNonRecordCandidateType ||
8269 CandidateTypes[ArgIdx].hasNonRecordTypes();
8270 HasArithmeticOrEnumeralCandidateType =
8271 HasArithmeticOrEnumeralCandidateType ||
8272 CandidateTypes[ArgIdx].hasArithmeticOrEnumeralTypes();
8280 if (!HasNonRecordCandidateType &&
8281 !(Op == OO_Exclaim || Op == OO_AmpAmp || Op == OO_PipePipe))
8285 BuiltinOperatorOverloadBuilder OpBuilder(*
this, Args,
8286 VisibleTypeConversionsQuals,
8287 HasArithmeticOrEnumeralCandidateType,
8288 CandidateTypes, CandidateSet);
8294 llvm_unreachable(
"Expected an overloaded operator");
8299 case OO_Array_Delete:
8302 "Special operators don't use AddBuiltinOperatorCandidates");
8314 if (Args.size() == 1)
8315 OpBuilder.addUnaryPlusPointerOverloads();
8319 if (Args.size() == 1) {
8320 OpBuilder.addUnaryPlusOrMinusArithmeticOverloads();
8322 OpBuilder.addBinaryPlusOrMinusPointerOverloads(Op);
8323 OpBuilder.addGenericBinaryArithmeticOverloads(
false);
8328 if (Args.size() == 1)
8329 OpBuilder.addUnaryStarPointerOverloads();
8331 OpBuilder.addGenericBinaryArithmeticOverloads(
false);
8335 OpBuilder.addGenericBinaryArithmeticOverloads(
false);
8340 OpBuilder.addPlusPlusMinusMinusArithmeticOverloads(Op);
8341 OpBuilder.addPlusPlusMinusMinusPointerOverloads();
8345 case OO_ExclaimEqual:
8346 OpBuilder.addEqualEqualOrNotEqualMemberPointerOverloads();
8352 case OO_GreaterEqual:
8353 OpBuilder.addRelationalPointerOrEnumeralOverloads();
8354 OpBuilder.addGenericBinaryArithmeticOverloads(
true);
8361 case OO_GreaterGreater:
8362 OpBuilder.addBinaryBitwiseArithmeticOverloads(Op);
8366 if (Args.size() == 1)
8372 OpBuilder.addBinaryBitwiseArithmeticOverloads(Op);
8376 OpBuilder.addUnaryTildePromotedIntegralOverloads();
8380 OpBuilder.addAssignmentMemberPointerOrEnumeralOverloads();
8385 OpBuilder.addAssignmentPointerOverloads(Op == OO_Equal);
8390 OpBuilder.addAssignmentArithmeticOverloads(Op == OO_Equal);
8393 case OO_PercentEqual:
8394 case OO_LessLessEqual:
8395 case OO_GreaterGreaterEqual:
8399 OpBuilder.addAssignmentIntegralOverloads();
8403 OpBuilder.addExclaimOverload();
8408 OpBuilder.addAmpAmpOrPipePipeOverload();
8412 OpBuilder.addSubscriptOverloads();
8416 OpBuilder.addArrowStarOverloads();
8419 case OO_Conditional:
8420 OpBuilder.addConditionalOperatorOverloads();
8421 OpBuilder.addGenericBinaryArithmeticOverloads(
false);
8439 bool PartialOverloading) {
8454 CandEnd = CandidateSet.
end();
8455 Cand != CandEnd; ++Cand)
8456 if (Cand->Function) {
8457 Fns.
erase(Cand->Function);
8467 if (ExplicitTemplateArgs)
8471 PartialOverloading);
8474 FoundDecl, ExplicitTemplateArgs,
8475 Args, CandidateSet, PartialOverloading);
8498 if (Cand1Attrs.size() <= Cand2Attrs.size())
8501 auto Cand1I = Cand1Attrs.begin();
8502 llvm::FoldingSetNodeID Cand1ID, Cand2ID;
8503 for (
auto &Cand2A : Cand2Attrs) {
8507 auto &Cand1A = *Cand1I++;
8508 Cand1A->getCond()->Profile(Cand1ID, S.
getASTContext(),
true);
8509 Cand2A->getCond()->Profile(Cand2ID, S.
getASTContext(),
true);
8510 if (Cand1ID != Cand2ID)
8522 bool UserDefinedConversion) {
8536 unsigned StartArg = 0;
8545 assert(Cand2.
NumConversions == NumArgs &&
"Overload candidate mismatch");
8546 bool HasBetterConversion =
false;
8547 for (
unsigned ArgIdx = StartArg; ArgIdx <
NumArgs; ++ArgIdx) {
8553 HasBetterConversion =
true;
8568 if (HasBetterConversion)
8578 isa<CXXConversionDecl>(Cand1.
Function) &&
8579 isa<CXXConversionDecl>(Cand2.
Function)) {
8601 bool Cand1IsSpecialization = Cand1.
Function &&
8603 bool Cand2IsSpecialization = Cand2.
Function &&
8605 if (Cand1IsSpecialization != Cand2IsSpecialization)
8606 return Cand2IsSpecialization;
8612 if (Cand1IsSpecialization && Cand2IsSpecialization) {
8637 bool HasPS1 = Cand1.
Function !=
nullptr &&
8639 bool HasPS2 = Cand2.
Function !=
nullptr &&
8641 return HasPS1 != HasPS2 && HasPS1;
8653 auto *VA = dyn_cast_or_null<ValueDecl>(A);
8654 auto *VB = dyn_cast_or_null<ValueDecl>(B);
8660 if (!VA->getDeclContext()->getRedeclContext()->Equals(
8661 VB->getDeclContext()->getRedeclContext()) ||
8664 VA->isExternallyVisible() || VB->isExternallyVisible())
8677 if (
auto *EA = dyn_cast<EnumConstantDecl>(VA)) {
8678 if (
auto *EB = dyn_cast<EnumConstantDecl>(VB)) {
8681 auto *EnumA = cast<EnumDecl>(EA->getDeclContext());
8682 auto *EnumB = cast<EnumDecl>(EB->getDeclContext());
8683 if (EnumA->hasNameForLinkage() || EnumB->hasNameForLinkage() ||
8685 EnumB->getIntegerType()))
8688 return llvm::APSInt::isSameValue(EA->getInitVal(), EB->getInitVal());
8698 Diag(Loc, diag::ext_equivalent_internal_linkage_decl_in_modules) << D;
8704 for (
auto *E : Equiv) {
8706 Diag(E->getLocation(), diag::note_equivalent_internal_linkage_decl)
8724 bool UserDefinedConversion) {
8730 UserDefinedConversion))
8746 UserDefinedConversion)) {
8749 EquivalentCands.push_back(Cand->Function);
8759 if (Best->Function &&
8760 (Best->Function->isDeleted() ||
8764 if (!EquivalentCands.empty())
8777 oc_function_template,
8779 oc_constructor_template,
8780 oc_implicit_default_constructor,
8781 oc_implicit_copy_constructor,
8782 oc_implicit_move_constructor,
8783 oc_implicit_copy_assignment,
8784 oc_implicit_move_assignment,
8785 oc_implicit_inherited_constructor
8790 std::string &Description) {
8800 if (!Ctor->isImplicit())
8801 return isTemplate ? oc_constructor_template : oc_constructor;
8803 if (Ctor->getInheritedConstructor())
8804 return oc_implicit_inherited_constructor;
8806 if (Ctor->isDefaultConstructor())
8807 return oc_implicit_default_constructor;
8809 if (Ctor->isMoveConstructor())
8810 return oc_implicit_move_constructor;
8812 assert(Ctor->isCopyConstructor() &&
8813 "unexpected sort of implicit constructor");
8814 return oc_implicit_copy_constructor;
8820 if (!Meth->isImplicit())
8821 return isTemplate ? oc_method_template : oc_method;
8823 if (Meth->isMoveAssignmentOperator())
8824 return oc_implicit_move_assignment;
8826 if (Meth->isCopyAssignmentOperator())
8827 return oc_implicit_copy_assignment;
8829 assert(isa<CXXConversionDecl>(Meth) &&
"expected conversion");
8833 return isTemplate ? oc_function_template : oc_function;
8836 void MaybeEmitInheritedConstructorNote(
Sema &S,
Decl *Fn) {
8843 S.
Diag(Ctor->
getLocation(), diag::note_ovl_candidate_inherited_constructor);
8852 if (!EnableIf->getCond()->EvaluateAsBooleanCondition(AlwaysTrue, Ctx))
8869 bool InOverloadResolution,
8873 if (InOverloadResolution)
8875 diag::note_addrof_ovl_candidate_disabled_by_enable_if_attr);
8877 S.
Diag(Loc, diag::err_addrof_function_disabled_by_enable_if_attr) << FD;
8883 std::mem_fn(&ParmVarDecl::hasAttr<PassObjectSizeAttr>));
8889 unsigned ParamNo = std::distance(FD->
param_begin(),
I) + 1;
8890 if (InOverloadResolution)
8892 diag::note_ovl_candidate_has_pass_object_size_params)
8895 S.
Diag(Loc, diag::err_address_of_function_with_pass_object_size_params)
8918 bool TakingAddress) {
8929 MaybeEmitInheritedConstructorNote(*
this, Fn);
8935 bool TakingAddress) {
8945 dyn_cast<FunctionTemplateDecl>((*I)->getUnderlyingDecl()) ) {
8949 = dyn_cast<FunctionDecl>((*I)->getUnderlyingDecl()) ) {
8962 S.
Diag(CaretLoc, PDiag)
8968 unsigned CandsShown = 0;
8971 if (CandsShown >= 4 && ShowOverloads ==
Ovl_Best)
8981 unsigned I,
bool TakingCandidateAddress) {
8983 assert(Conv.
isBad());
8984 assert(Cand->
Function &&
"for now, candidate must be a function");
8990 bool isObjectArgument =
false;
8991 if (isa<CXXMethodDecl>(Fn) && !isa<CXXConstructorDecl>(Fn)) {
8993 isObjectArgument =
true;
9006 assert(FromExpr &&
"overload set argument came from implicit argument?");
9008 if (isa<UnaryOperator>(E))
9013 << (
unsigned) FnKind << FnDesc
9014 << (FromExpr ? FromExpr->getSourceRange() :
SourceRange())
9015 << ToTy << Name << I+1;
9016 MaybeEmitInheritedConstructorNote(S, Fn);
9025 CToTy = RT->getPointeeType();
9030 CFromTy = FromPT->getPointeeType(), CToTy = ToPT->getPointeeType();
9040 << (
unsigned) FnKind << FnDesc
9041 << (FromExpr ? FromExpr->getSourceRange() :
SourceRange())
9044 << (
unsigned) isObjectArgument << I+1;
9045 MaybeEmitInheritedConstructorNote(S, Fn);
9051 << (
unsigned) FnKind << FnDesc
9052 << (FromExpr ? FromExpr->getSourceRange() :
SourceRange())
9055 << (
unsigned) isObjectArgument << I+1;
9056 MaybeEmitInheritedConstructorNote(S, Fn);
9062 << (
unsigned) FnKind << FnDesc
9063 << (FromExpr ? FromExpr->getSourceRange() :
SourceRange())
9066 << (
unsigned) isObjectArgument << I+1;
9067 MaybeEmitInheritedConstructorNote(S, Fn);
9072 assert(CVR &&
"unexpected qualifiers mismatch");
9074 if (isObjectArgument) {
9076 << (
unsigned) FnKind << FnDesc
9077 << (FromExpr ? FromExpr->getSourceRange() :
SourceRange())
9078 << FromTy << (CVR - 1);
9081 << (
unsigned) FnKind << FnDesc
9082 << (FromExpr ? FromExpr->getSourceRange() :
SourceRange())
9083 << FromTy << (CVR - 1) << I+1;
9085 MaybeEmitInheritedConstructorNote(S, Fn);
9091 if (FromExpr && isa<InitListExpr>(FromExpr)) {
9093 << (
unsigned) FnKind << FnDesc
9094 << (FromExpr ? FromExpr->getSourceRange() :
SourceRange())
9095 << FromTy << ToTy << (
unsigned) isObjectArgument << I+1;
9096 MaybeEmitInheritedConstructorNote(S, Fn);
9107 S.
Diag(Fn->
getLocation(), diag::note_ovl_candidate_bad_conv_incomplete)
9108 << (
unsigned) FnKind << FnDesc
9109 << (FromExpr ? FromExpr->getSourceRange() :
SourceRange())
9110 << FromTy << ToTy << (
unsigned) isObjectArgument << I+1;
9111 MaybeEmitInheritedConstructorNote(S, Fn);
9116 unsigned BaseToDerivedConversion = 0;
9119 if (ToPtrTy->getPointeeType().isAtLeastAsQualifiedAs(
9120 FromPtrTy->getPointeeType()) &&
9121 !FromPtrTy->getPointeeType()->isIncompleteType() &&
9122 !ToPtrTy->getPointeeType()->isIncompleteType() &&
9124 FromPtrTy->getPointeeType()))
9125 BaseToDerivedConversion = 1;
9133 if (ToPtrTy->getPointeeType().isAtLeastAsQualifiedAs(
9134 FromPtrTy->getPointeeType()) &&
9135 FromIface->isSuperClassOf(ToIface))
9136 BaseToDerivedConversion = 2;
9138 if (ToRefTy->getPointeeType().isAtLeastAsQualifiedAs(FromTy) &&
9140 !ToRefTy->getPointeeType()->isIncompleteType() &&
9142 BaseToDerivedConversion = 3;
9147 << (
unsigned) FnKind << FnDesc
9148 << (FromExpr ? FromExpr->getSourceRange() :
SourceRange())
9149 << (
unsigned) isObjectArgument << I + 1;
9150 MaybeEmitInheritedConstructorNote(S, Fn);
9155 if (BaseToDerivedConversion) {
9157 diag::note_ovl_candidate_bad_base_to_derived_conv)
9158 << (
unsigned) FnKind << FnDesc
9159 << (FromExpr ? FromExpr->getSourceRange() :
SourceRange())
9160 << (BaseToDerivedConversion - 1)
9161 << FromTy << ToTy << I+1;
9162 MaybeEmitInheritedConstructorNote(S, Fn);
9166 if (isa<ObjCObjectPointerType>(CFromTy) &&
9167 isa<PointerType>(CToTy)) {
9172 << (
unsigned) FnKind << FnDesc
9173 << (FromExpr ? FromExpr->getSourceRange() :
SourceRange())
9174 << FromTy << ToTy << (
unsigned) isObjectArgument << I+1;
9175 MaybeEmitInheritedConstructorNote(S, Fn);
9180 if (TakingCandidateAddress &&
9186 FDiag << (
unsigned) FnKind << FnDesc
9187 << (FromExpr ? FromExpr->getSourceRange() :
SourceRange())
9188 << FromTy << ToTy << (
unsigned) isObjectArgument << I + 1
9193 HE = Cand->
Fix.
Hints.end(); HI != HE; ++HI)
9197 MaybeEmitInheritedConstructorNote(S, Fn);
9217 if (NumArgs < MinParams) {
9232 assert(isa<FunctionDecl>(D) &&
9233 "The templated declaration should at least be a function"
9234 " when diagnosing bad template argument deduction due to too many"
9235 " or too few arguments");
9244 unsigned mode, modeCount;
9245 if (NumFormalArgs < MinParams) {
9246 if (MinParams != FnTy->getNumParams() || FnTy->isVariadic() ||
9247 FnTy->isTemplateVariadic())
9251 modeCount = MinParams;
9253 if (MinParams != FnTy->getNumParams())
9257 modeCount = FnTy->getNumParams();
9260 std::string Description;
9270 << mode << modeCount << NumFormalArgs;
9271 MaybeEmitInheritedConstructorNote(S, Fn);
9276 unsigned NumFormalArgs) {
9282 if (
FunctionDecl *FD = dyn_cast<FunctionDecl>(Templated))
9283 return FD->getDescribedFunctionTemplate();
9284 else if (
CXXRecordDecl *RD = dyn_cast<CXXRecordDecl>(Templated))
9285 return RD->getDescribedClassTemplate();
9287 llvm_unreachable(
"Unsupported: Getting the described template declaration"
9288 " for bad deduction diagnosis");
9295 bool TakingCandidateAddress) {
9301 switch (DeductionFailure.
Result) {
9303 llvm_unreachable(
"TDK_success while diagnosing bad deduction");
9306 assert(ParamD &&
"no parameter found for incomplete deduction result");
9308 diag::note_ovl_candidate_incomplete_deduction)
9310 MaybeEmitInheritedConstructorNote(S, Templated);
9315 assert(ParamD &&
"no parameter found for bad qualifiers deduction result");
9333 S.
Diag(Templated->
getLocation(), diag::note_ovl_candidate_underqualified)
9335 MaybeEmitInheritedConstructorNote(S, Templated);
9340 assert(ParamD &&
"no parameter found for inconsistent deduction result");
9342 if (isa<TemplateTypeParmDecl>(ParamD))
9344 else if (isa<NonTypeTemplateParmDecl>(ParamD))
9351 diag::note_ovl_candidate_inconsistent_deduction)
9354 MaybeEmitInheritedConstructorNote(S, Templated);
9359 assert(ParamD &&
"no parameter found for invalid explicit arguments");
9362 diag::note_ovl_candidate_explicit_arg_mismatch_named)
9367 index = TTP->getIndex();
9369 = dyn_cast<NonTypeTemplateParmDecl>(ParamD))
9370 index = NTTP->getIndex();
9372 index = cast<TemplateTemplateParmDecl>(ParamD)->getIndex();
9374 diag::note_ovl_candidate_explicit_arg_mismatch_unnamed)
9377 MaybeEmitInheritedConstructorNote(S, Templated);
9387 diag::note_ovl_candidate_instantiation_depth);
9388 MaybeEmitInheritedConstructorNote(S, Templated);
9396 TemplateArgString =
" ";
9403 if (PDiag && PDiag->second.getDiagID() ==
9404 diag::err_typename_nested_not_found_enable_if) {
9407 S.
Diag(PDiag->first, diag::note_ovl_candidate_disabled_by_enable_if)
9408 <<
"'enable_if'" << TemplateArgString;
9418 SFINAEArgString =
": ";
9424 diag::note_ovl_candidate_substitution_failure)
9425 << TemplateArgString << SFINAEArgString << R;
9426 MaybeEmitInheritedConstructorNote(S, Templated);
9433 diag::note_ovl_candidate_failed_overload_resolution)
9443 TemplateArgString =
" ";
9448 S.
Diag(Templated->
getLocation(), diag::note_ovl_candidate_deduced_mismatch)
9451 << TemplateArgString;
9474 diag::note_ovl_candidate_non_deduced_mismatch_qualified)
9481 if (TakingCandidateAddress && isa<FunctionDecl>(Templated) &&
9490 diag::note_ovl_candidate_non_deduced_mismatch)
9491 << FirstTA << SecondTA;
9497 S.
Diag(Templated->
getLocation(), diag::note_ovl_candidate_bad_deduction);
9498 MaybeEmitInheritedConstructorNote(S, Templated);
9506 bool TakingCandidateAddress) {
9527 S.
Diag(Callee->getLocation(), diag::note_ovl_candidate_bad_target)
9528 << (
unsigned)FnKind << CalleeTarget << CallerTarget;
9540 case oc_implicit_default_constructor:
9543 case oc_implicit_copy_constructor:
9546 case oc_implicit_move_constructor:
9549 case oc_implicit_copy_assignment:
9552 case oc_implicit_move_assignment:
9557 bool ConstRHS =
false;
9561 ConstRHS = RT->getPointeeType().isConstQualified();
9576 diag::note_ovl_candidate_disabled_by_enable_if_attr)
9577 << Attr->getCond()->getSourceRange() << Attr->getMessage();
9595 bool TakingCandidateAddress) {
9607 MaybeEmitInheritedConstructorNote(S, Fn);
9626 S.
Diag(Fn->
getLocation(), diag::note_ovl_candidate_illegal_constructor)
9628 MaybeEmitInheritedConstructorNote(S, Fn);
9669 bool isLValueReference =
false;
9670 bool isRValueReference =
false;
9671 bool isPointer =
false;
9675 isLValueReference =
true;
9679 isRValueReference =
true;
9694 MaybeEmitInheritedConstructorNote(S, Cand->
Surrogate);
9700 assert(Cand->
NumConversions <= 2 &&
"builtin operator is not binary");
9701 std::string TypeStr(
"operator");
9707 S.
Diag(OpLoc, diag::note_ovl_builtin_unary_candidate) << TypeStr;
9712 S.
Diag(OpLoc, diag::note_ovl_builtin_binary_candidate) << TypeStr;
9719 for (
unsigned ArgIdx = 0; ArgIdx < NoOperands; ++ArgIdx) {
9721 if (ICS.
isBad())
break;
9725 S.
PDiag(diag::note_ambiguous_type_conversion));
9740 llvm_unreachable(
"TDK_success while diagnosing bad deduction");
9767 llvm_unreachable(
"Unhandled deduction result");
9771 struct CompareOverloadCandidatesForDisplay {
9782 if (L == R)
return false;
9786 if (!R->
Viable)
return true;
9807 if (LDist == RDist) {
9816 return LDist < RDist;
9834 numLFixes = (numLFixes == 0) ?
UINT_MAX : numLFixes;
9835 numRFixes = (numRFixes == 0) ?
UINT_MAX : numRFixes;
9836 if (numLFixes != numRFixes) {
9837 return numLFixes < numRFixes;
9862 if (leftBetter > 0)
return true;
9863 if (leftBetter < 0)
return false;
9904 bool Unfixable =
false;
9912 assert(ConvIdx != ConvCount &&
"no bad conversion in candidate");
9920 if (ConvIdx == ConvCount)
9924 "remaining conversion is initialized?");
9928 bool SuppressUserConversions =
false;
9931 unsigned ArgIdx = ConvIdx;
9942 if (isa<CXXMethodDecl>(Cand->
Function) &&
9943 !isa<CXXConstructorDecl>(Cand->
Function))
9947 assert(ConvCount <= 3);
9948 for (; ConvIdx != ConvCount; ++ConvIdx)
9952 SuppressUserConversions,
9961 for (; ConvIdx != ConvCount; ++ConvIdx, ++ArgIdx) {
9962 if (ArgIdx < NumParams) {
9964 S, Args[ArgIdx], Proto->
getParamType(ArgIdx), SuppressUserConversions,
9989 for (
iterator Cand =
begin(), LastCand =
end(); Cand != LastCand; ++Cand) {
9991 Cands.push_back(Cand);
9994 if (Cand->Function || Cand->IsSurrogate)
9995 Cands.push_back(Cand);
10001 std::sort(Cands.begin(), Cands.end(),
10002 CompareOverloadCandidatesForDisplay(S, OpLoc, Args.size()));
10004 bool ReportedAmbiguousConversions =
false;
10008 unsigned CandsShown = 0;
10009 for (I = Cands.begin(), E = Cands.end(); I !=
E; ++
I) {
10015 if (CandsShown >= 4 && ShowOverloads ==
Ovl_Best) {
10027 "Non-viable built-in candidates are not added to Cands.");
10034 if (!ReportedAmbiguousConversions) {
10036 ReportedAmbiguousConversions =
true;
10045 S.
Diag(OpLoc, diag::note_ovl_too_many_candidates) << int(E - I);
10055 struct CompareTemplateSpecCandidatesForDisplay {
10057 CompareTemplateSpecCandidatesForDisplay(
Sema &S) : S(S) {}
10091 bool ForTakingAddress) {
10096 void TemplateSpecCandidateSet::destroyCandidates() {
10098 i->DeductionFailure.Destroy();
10103 destroyCandidates();
10104 Candidates.clear();
10117 Cands.reserve(
size());
10118 for (
iterator Cand =
begin(), LastCand =
end(); Cand != LastCand; ++Cand) {
10119 if (Cand->Specialization)
10120 Cands.push_back(Cand);
10125 std::sort(Cands.begin(), Cands.end(),
10126 CompareTemplateSpecCandidatesForDisplay(S));
10133 unsigned CandsShown = 0;
10134 for (I = Cands.begin(), E = Cands.end(); I !=
E; ++
I) {
10140 if (CandsShown >= 4 && ShowOverloads ==
Ovl_Best)
10145 "Non-matching built-in candidates are not added to Cands.");
10150 S.
Diag(Loc, diag::note_ovl_too_many_candidates) << int(E - I);
10160 QualType Ret = PossiblyAFunctionType;
10178 class AddressOfFunctionResolver {
10188 bool TargetTypeIsNonStaticMemberFunction;
10189 bool FoundNonTemplateFunction;
10190 bool StaticMemberFunctionFromBoundPointer;
10191 bool HasComplained;
10200 AddressOfFunctionResolver(
Sema &S,
Expr *SourceExpr,
10201 const QualType &TargetType,
bool Complain)
10202 : S(S), SourceExpr(SourceExpr), TargetType(TargetType),
10203 Complain(Complain),
Context(S.getASTContext()),
10204 TargetTypeIsNonStaticMemberFunction(
10206 FoundNonTemplateFunction(
false),
10207 StaticMemberFunctionFromBoundPointer(
false),
10208 HasComplained(
false),
10210 OvlExpr(OvlExprInfo.Expression),
10211 FailedCandidates(OvlExpr->getNameLoc(),
true) {
10212 ExtractUnqualifiedFunctionTypeFromTargetType();
10214 if (TargetFunctionType->isFunctionType()) {
10216 if (!UME->isImplicitAccess() &&
10218 StaticMemberFunctionFromBoundPointer =
true;
10219 }
else if (OvlExpr->hasExplicitTemplateArgs()) {
10222 OvlExpr,
false, &dap)) {
10224 if (!Method->isStatic()) {
10228 TargetTypeIsNonStaticMemberFunction =
true;
10232 if (!OvlExprInfo.HasFormOfMemberPointer)
10236 Matches.push_back(std::make_pair(dap, Fn));
10241 if (OvlExpr->hasExplicitTemplateArgs())
10242 OvlExpr->copyTemplateArgumentsInto(OvlExplicitTemplateArgs);
10244 if (FindAllFunctionsThatMatchTargetTypeExactly()) {
10247 if (
Matches.size() > 1 && !eliminiateSuboptimalOverloadCandidates()) {
10248 if (FoundNonTemplateFunction)
10249 EliminateAllTemplateMatches();
10251 EliminateAllExceptMostSpecializedTemplate();
10257 EliminateSuboptimalCudaMatches();
10260 bool hasComplained()
const {
return HasComplained; }
10270 bool eliminiateSuboptimalOverloadCandidates() {
10275 if (isBetterCandidate(I->second, Best->second))
10279 auto IsBestOrInferiorToBest = [
this, BestFn](
10280 const std::pair<DeclAccessPair, FunctionDecl *> &Pair) {
10281 return BestFn == Pair.second || isBetterCandidate(BestFn, Pair.second);
10286 if (!std::all_of(
Matches.begin(),
Matches.end(), IsBestOrInferiorToBest))
10293 bool isTargetTypeAFunction()
const {
10294 return TargetFunctionType->isFunctionType();
10302 void inline ExtractUnqualifiedFunctionTypeFromTargetType() {
10313 if (Method->isStatic() == TargetTypeIsNonStaticMemberFunction)
10316 else if (TargetTypeIsNonStaticMemberFunction)
10329 &OvlExplicitTemplateArgs,
10330 TargetFunctionType, Specialization,
10333 FailedCandidates.addCandidate()
10350 Matches.push_back(std::make_pair(CurAccessFunPair, Specialization));
10354 bool AddMatchingNonTemplateFunction(
NamedDecl* Fn,
10359 if (Method->isStatic() == TargetTypeIsNonStaticMemberFunction)
10362 else if (TargetTypeIsNonStaticMemberFunction)
10365 if (
FunctionDecl *FunDecl = dyn_cast<FunctionDecl>(Fn)) {
10374 FunDecl->getReturnType()->isUndeducedType() &&
10376 HasComplained |= Complain;
10385 FunDecl->getType()) ||
10389 Matches.push_back(std::make_pair(
10390 CurAccessFunPair, cast<FunctionDecl>(FunDecl->getCanonicalDecl())));
10391 FoundNonTemplateFunction =
true;
10399 bool FindAllFunctionsThatMatchTargetTypeExactly() {
10404 if (IsInvalidFormOfPointerToMemberFunction())
10408 E = OvlExpr->decls_end();
10420 = dyn_cast<FunctionTemplateDecl>(Fn)) {
10421 if (AddMatchingTemplateFunction(FunctionTemplate, I.getPair()))
10425 else if (!OvlExpr->hasExplicitTemplateArgs() &&
10426 AddMatchingNonTemplateFunction(Fn, I.getPair()))
10429 assert(Ret ||
Matches.empty());
10433 void EliminateAllExceptMostSpecializedTemplate() {
10446 for (
unsigned I = 0, E =
Matches.size(); I !=
E; ++
I)
10452 MatchesCopy.
begin(), MatchesCopy.
end(), FailedCandidates,
10453 SourceExpr->getLocStart(), S.
PDiag(),
10455 .second->getDeclName(),
10456 S.
PDiag(diag::note_ovl_candidate) << (
unsigned)oc_function_template,
10457 Complain, TargetFunctionType);
10459 if (Result != MatchesCopy.
end()) {
10462 Matches[0].second = cast<FunctionDecl>(*Result);
10465 HasComplained |= Complain;
10468 void EliminateAllTemplateMatches() {
10471 for (
unsigned I = 0, N =
Matches.size(); I != N; ) {
10472 if (
Matches[I].second->getPrimaryTemplate() ==
nullptr)
10481 void EliminateSuboptimalCudaMatches() {
10486 void ComplainNoMatchesFound()
const {
10488 S.
Diag(OvlExpr->getLocStart(), diag::err_addr_ovl_no_viable)
10489 << OvlExpr->getName() << TargetFunctionType
10490 << OvlExpr->getSourceRange();
10491 if (FailedCandidates.empty())
10499 IEnd = OvlExpr->decls_end();
10502 dyn_cast<FunctionDecl>((*I)->getUnderlyingDecl()))
10506 FailedCandidates.NoteCandidates(S, OvlExpr->getLocStart());
10510 bool IsInvalidFormOfPointerToMemberFunction()
const {
10511 return TargetTypeIsNonStaticMemberFunction &&
10512 !OvlExprInfo.HasFormOfMemberPointer;
10515 void ComplainIsInvalidFormOfPointerToMemberFunction()
const {
10519 S.
Diag(OvlExpr->getNameLoc(), diag::err_addr_ovl_no_qualifier)
10520 << TargetType << OvlExpr->getSourceRange();
10523 bool IsStaticMemberFunctionFromBoundPointer()
const {
10524 return StaticMemberFunctionFromBoundPointer;
10527 void ComplainIsStaticMemberFunctionFromBoundPointer()
const {
10528 S.
Diag(OvlExpr->getLocStart(),
10529 diag::err_invalid_form_pointer_member_function)
10530 << OvlExpr->getSourceRange();
10533 void ComplainOfInvalidConversion()
const {
10534 S.
Diag(OvlExpr->getLocStart(), diag::err_addr_ovl_not_func_ptrref)
10535 << OvlExpr->getName() << TargetType;
10538 void ComplainMultipleMatchesFound()
const {
10540 S.
Diag(OvlExpr->getLocStart(), diag::err_addr_ovl_ambiguous)
10541 << OvlExpr->getName()
10542 << OvlExpr->getSourceRange();
10547 bool hadMultipleCandidates()
const {
return (OvlExpr->getNumDecls() > 1); }
10549 int getNumMatches()
const {
return Matches.size(); }
10552 if (
Matches.size() != 1)
return nullptr;
10557 if (
Matches.size() != 1)
return nullptr;
10583 bool *pHadMultipleCandidates) {
10586 AddressOfFunctionResolver Resolver(*
this, AddressOfExpr, TargetType,
10588 int NumMatches = Resolver.getNumMatches();
10590 bool ShouldComplain = Complain && !Resolver.hasComplained();
10591 if (NumMatches == 0 && ShouldComplain) {
10592 if (Resolver.IsInvalidFormOfPointerToMemberFunction())
10593 Resolver.ComplainIsInvalidFormOfPointerToMemberFunction();
10595 Resolver.ComplainNoMatchesFound();
10597 else if (NumMatches > 1 && ShouldComplain)
10598 Resolver.ComplainMultipleMatchesFound();
10599 else if (NumMatches == 1) {
10600 Fn = Resolver.getMatchingFunctionDecl();
10602 FoundResult = *Resolver.getMatchingFunctionAccessPair();
10604 if (Resolver.IsStaticMemberFunctionFromBoundPointer())
10605 Resolver.ComplainIsStaticMemberFunctionFromBoundPointer();
10611 if (pHadMultipleCandidates)
10612 *pHadMultipleCandidates = Resolver.hadMultipleCandidates();
10657 = cast<FunctionTemplateDecl>((*I)->getUnderlyingDecl());
10669 Specialization, Info,
10673 FailedCandidates.addCandidate()
10679 assert(Specialization &&
"no specialization and no error?");
10691 Matched = Specialization;
10692 if (FoundResult) *FoundResult = I.getPair();
10696 Matched->getReturnType()->isUndeducedType() &&
10715 ExprResult &SrcExpr,
bool doFunctionPointerConverion,
10716 bool complain,
SourceRange OpRangeForComplaining,
10718 unsigned DiagIDForComplaining) {
10726 ovl.Expression,
false, &found)) {
10736 if (!ovl.HasFormOfMemberPointer &&
10737 isa<CXXMethodDecl>(fn) &&
10738 cast<CXXMethodDecl>(fn)->isInstance()) {
10739 if (!complain)
return false;
10741 Diag(ovl.Expression->getExprLoc(),
10742 diag::err_bound_member_function)
10743 << 0 << ovl.Expression->getSourceRange();
10755 SingleFunctionExpression =
10759 if (doFunctionPointerConverion) {
10760 SingleFunctionExpression =
10762 if (SingleFunctionExpression.
isInvalid()) {
10769 if (!SingleFunctionExpression.
isUsable()) {
10771 Diag(OpRangeForComplaining.
getBegin(), DiagIDForComplaining)
10772 << ovl.Expression->getName()
10773 << DestTypeForComplaining
10774 << OpRangeForComplaining
10775 << ovl.Expression->getQualifierLoc().getSourceRange();
10785 SrcExpr = SingleFunctionExpression;
10795 bool PartialOverloading,
10798 if (isa<UsingShadowDecl>(Callee))
10799 Callee = cast<UsingShadowDecl>(Callee)->getTargetDecl();
10801 if (
FunctionDecl *Func = dyn_cast<FunctionDecl>(Callee)) {
10802 if (ExplicitTemplateArgs) {
10803 assert(!KnownValid &&
"Explicit template arguments?");
10808 PartialOverloading);
10813 = dyn_cast<FunctionTemplateDecl>(Callee)) {
10815 ExplicitTemplateArgs, Args, CandidateSet,
10817 PartialOverloading);
10821 assert(!KnownValid &&
"unhandled case in overloaded call candidate");
10829 bool PartialOverloading) {
10852 assert(!(*I)->getDeclContext()->isRecord());
10853 assert(isa<UsingShadowDecl>(*I) ||
10854 !(*I)->getDeclContext()->isFunctionOrMethod());
10855 assert((*I)->getUnderlyingDecl()->isFunctionOrFunctionTemplate());
10865 ExplicitTemplateArgs = &TABuffer;
10871 CandidateSet, PartialOverloading,
10876 Args, ExplicitTemplateArgs,
10877 CandidateSet, PartialOverloading);
10884 case OO_New:
case OO_Array_New:
10885 case OO_Delete:
case OO_Array_Delete:
10905 bool *DoDiagnoseEmptyLookup =
nullptr) {
10910 if (DC->isTransparentContext())
10918 if (isa<CXXRecordDecl>(DC)) {
10922 if (DoDiagnoseEmptyLookup)
10923 *DoDiagnoseEmptyLookup =
true;
10930 ExplicitTemplateArgs, Args,
10931 Candidates,
false,
false);
10934 if (Candidates.BestViableFunction(SemaRef, FnLoc, Best) !=
OR_Success) {
10946 AssociatedNamespaces,
10947 AssociatedClasses);
10952 it = AssociatedNamespaces.begin(),
10953 end = AssociatedNamespaces.end(); it !=
end; ++it) {
10965 SuggestedNamespaces.insert(*it);
10969 SemaRef.
Diag(R.
getNameLoc(), diag::err_not_found_by_two_phase_lookup)
10971 if (SuggestedNamespaces.empty()) {
10972 SemaRef.
Diag(Best->Function->getLocation(),
10973 diag::note_not_found_by_two_phase_lookup)
10975 }
else if (SuggestedNamespaces.size() == 1) {
10976 SemaRef.
Diag(Best->Function->getLocation(),
10977 diag::note_not_found_by_two_phase_lookup)
10983 SemaRef.
Diag(Best->Function->getLocation(),
10984 diag::note_not_found_by_two_phase_lookup)
11016 class BuildRecoveryCallExprRAII {
11019 BuildRecoveryCallExprRAII(
Sema &S) : SemaRef(S) {
11020 assert(SemaRef.IsBuildingRecoveryCallExpr ==
false);
11021 SemaRef.IsBuildingRecoveryCallExpr =
true;
11024 ~BuildRecoveryCallExprRAII() {
11025 SemaRef.IsBuildingRecoveryCallExpr =
false;
11031 static std::unique_ptr<CorrectionCandidateCallback>
11033 bool HasTemplateArgs,
bool AllowTypoCorrection) {
11034 if (!AllowTypoCorrection)
11035 return llvm::make_unique<NoTypoCorrectionCCC>();
11036 return llvm::make_unique<FunctionCallFilterCCC>(SemaRef,
NumArgs,
11037 HasTemplateArgs, ME);
11049 bool EmptyLookup,
bool AllowTypoCorrection) {
11058 BuildRecoveryCallExprRAII RCE(SemaRef);
11068 ExplicitTemplateArgs = &TABuffer;
11073 bool DoDiagnoseEmptyLookup = EmptyLookup;
11076 ExplicitTemplateArgs, Args,
11077 &DoDiagnoseEmptyLookup) &&
11080 MakeValidator(SemaRef, dyn_cast<MemberExpr>(Fn), Args.size(),
11081 ExplicitTemplateArgs !=
nullptr, AllowTypoCorrection),
11082 ExplicitTemplateArgs, Args)))
11085 assert(!R.empty() &&
"lookup results empty despite recovery");
11090 if ((*R.begin())->isCXXClassMember())
11092 ExplicitTemplateArgs, S);
11093 else if (ExplicitTemplateArgs || TemplateKWLoc.
isValid())
11095 ExplicitTemplateArgs);
11099 if (NewFn.isInvalid())
11105 return SemaRef.
ActOnCallExpr(
nullptr, NewFn.get(), LParenLoc,
11122 assert(!ULE->
getQualifier() &&
"qualified name with ADL");
11130 llvm_unreachable(
"performing ADL for builtin");
11137 UnbridgedCastsSet UnbridgedCasts;
11152 if (CandidateSet->
empty() ||
11169 if (CandidateSet->
empty())
11172 UnbridgedCasts.restore();
11188 bool AllowTypoCorrection) {
11189 if (CandidateSet->
empty())
11192 AllowTypoCorrection);
11194 switch (OverloadResult) {
11211 AllowTypoCorrection);
11218 for (
const Expr *Arg : Args) {
11219 if (!Arg->getType()->isFunctionType())
11221 if (
auto *DRE = dyn_cast<DeclRefExpr>(Arg->IgnoreParenImpCasts())) {
11225 Arg->getExprLoc()))
11230 SemaRef.
Diag(Fn->getLocStart(), diag::err_ovl_no_viable_function_in_call)
11231 << ULE->
getName() << Fn->getSourceRange();
11237 SemaRef.
Diag(Fn->getLocStart(), diag::err_ovl_ambiguous_call)
11238 << ULE->
getName() << Fn->getSourceRange();
11243 SemaRef.
Diag(Fn->getLocStart(), diag::err_ovl_deleted_call)
11244 << (*Best)->Function->isDeleted()
11247 << Fn->getSourceRange();
11265 for (
auto I = CS.
begin(), E = CS.
end(); I !=
E; ++
I) {
11286 bool AllowTypoCorrection,
11287 bool CalleesAddressIsTaken) {
11298 if (CalleesAddressIsTaken)
11306 RParenLoc, ExecConfig, &CandidateSet,
11307 &Best, OverloadResult,
11308 AllowTypoCorrection);
11312 return Functions.
size() > 1 ||
11313 (Functions.
size() == 1 && isa<FunctionTemplateDecl>(*Functions.
begin()));
11336 assert(Op !=
OO_None &&
"Invalid opcode for overloaded unary operator");
11392 bool HadMultipleCandidates = (CandidateSet.
size() > 1);
11406 if (
CXXMethodDecl *Method = dyn_cast<CXXMethodDecl>(FnDecl)) {
11411 Best->FoundDecl, Method);
11414 Input = InputRes.
get();
11425 Input = InputInit.
get();
11430 HadMultipleCandidates, OpLoc);
11442 ResultTy, VK, OpLoc,
false);
11457 Input = InputRes.
get();
11475 Diag(OpLoc, diag::err_ovl_ambiguous_oper_unary)
11478 << Input->getSourceRange();
11484 Diag(OpLoc, diag::err_ovl_deleted_oper)
11485 << Best->Function->isDeleted()
11488 << Input->getSourceRange();
11521 Expr *Args[2] = { LHS, RHS };
11529 if (Args[0]->isTypeDependent() || Args[1]->isTypeDependent()) {
11574 if (Opc ==
BO_Assign && !Args[0]->getType()->isOverloadableType())
11602 bool HadMultipleCandidates = (CandidateSet.
size() > 1);
11616 if (
CXXMethodDecl *Method = dyn_cast<CXXMethodDecl>(FnDecl)) {
11630 Best->FoundDecl, Method);
11658 HadMultipleCandidates, OpLoc);
11669 Args, ResultTy, VK, OpLoc,
11678 if (isa<CXXMethodDecl>(FnDecl))
11679 ArgsArray = ArgsArray.slice(1);
11682 if (Op == OO_Equal)
11685 checkCall(FnDecl,
nullptr, ArgsArray, isa<CXXMethodDecl>(FnDecl), OpLoc,
11698 Args[0] = ArgsRes0.
get();
11705 Args[1] = ArgsRes1.
get();
11724 Diag(OpLoc, diag::err_ovl_no_viable_oper)
11726 << Args[0]->getSourceRange() << Args[1]->getSourceRange();
11727 if (Args[0]->getType()->isIncompleteType()) {
11728 Diag(OpLoc, diag::note_assign_lhs_incomplete)
11730 << Args[0]->getSourceRange() << Args[1]->getSourceRange();
11745 "C++ binary operator overloading is missing candidates!");
11753 Diag(OpLoc, diag::err_ovl_ambiguous_oper_binary)
11756 << Args[0]->getSourceRange() << Args[1]->getSourceRange();
11763 CXXMethodDecl *Method = cast<CXXMethodDecl>(Best->Function);
11764 Diag(OpLoc, diag::err_ovl_deleted_special_oper)
11773 Diag(OpLoc, diag::err_ovl_deleted_oper)
11774 << Best->Function->isDeleted()
11777 << Args[0]->getSourceRange() << Args[1]->getSourceRange();
11792 Expr *Args[2] = { Base, Idx };
11798 if (Args[0]->isTypeDependent() || Args[1]->isTypeDependent()) {
11834 bool HadMultipleCandidates = (CandidateSet.
size() > 1);
11853 Best->FoundDecl, Method);
11854 if (Arg0.isInvalid())
11856 Args[0] = Arg0.get();
11872 OpLocInfo.setCXXOperatorNameRange(
SourceRange(LLoc, RLoc));
11875 HadMultipleCandidates,
11876 OpLocInfo.getLoc(),
11877 OpLocInfo.getInfo());
11888 FnExpr.
get(), Args,
11889 ResultTy, VK, RLoc,
11905 Args[0] = ArgsRes0.
get();
11912 Args[1] = ArgsRes1.
get();
11919 if (CandidateSet.
empty())
11920 Diag(LLoc, diag::err_ovl_no_oper)
11922 << Args[0]->getSourceRange() << Args[1]->getSourceRange();
11924 Diag(LLoc, diag::err_ovl_no_viable_subscript)
11926 << Args[0]->getSourceRange() << Args[1]->getSourceRange();
11933 Diag(LLoc, diag::err_ovl_ambiguous_oper_binary)
11936 << Args[0]->getSourceRange() << Args[1]->getSourceRange();
11942 Diag(LLoc, diag::err_ovl_deleted_oper)
11943 << Best->Function->isDeleted() <<
"[]"
11945 << Args[0]->getSourceRange() << Args[1]->getSourceRange();
11975 if (
BinaryOperator *op = dyn_cast<BinaryOperator>(NakedMemExpr)) {
11990 QualType objectType = op->getLHS()->getType();
11993 Qualifiers objectQuals = objectType.getQualifiers();
11995 Qualifiers difference = objectQuals - funcQuals;
11999 std::string qualsString = difference.
getAsString();
12000 Diag(LParenLoc, diag::err_pointer_to_member_call_drops_quals)
12001 << fnType.getUnqualifiedType()
12003 << (qualsString.find(
' ') == std::string::npos ? 1 : 2);
12008 resultType, valueKind, RParenLoc);
12017 if (CheckOtherCall(call, proto))
12023 if (isa<CXXPseudoDestructorExpr>(NakedMemExpr))
12027 UnbridgedCastsSet UnbridgedCasts;
12035 if (isa<MemberExpr>(NakedMemExpr)) {
12036 MemExpr = cast<MemberExpr>(NakedMemExpr);
12040 UnbridgedCasts.restore();
12058 TemplateArgs = &TemplateArgsBuffer;
12066 if (isa<UsingShadowDecl>(Func))
12067 Func = cast<UsingShadowDecl>(Func)->getTargetDecl();
12071 if (
getLangOpts().MicrosoftExt && isa<CXXConstructorDecl>(Func)) {
12073 Args, CandidateSet);
12074 }
else if ((Method = dyn_cast<CXXMethodDecl>(Func))) {
12081 ObjectClassification, Args, CandidateSet,
12085 I.getPair(), ActingDC, TemplateArgs,
12086 ObjectType, ObjectClassification,
12087 Args, CandidateSet,
12094 UnbridgedCasts.restore();
12100 Method = cast<CXXMethodDecl>(Best->Function);
12101 FoundDecl = Best->FoundDecl;
12111 if (Method != FoundDecl.getDecl() &&
12118 diag::err_ovl_no_viable_member_function_in_call)
12119 << DeclName << MemExprE->getSourceRange();
12126 << DeclName << MemExprE->getSourceRange();
12133 << Best->Function->isDeleted()
12136 << MemExprE->getSourceRange();
12158 assert(Method &&
"Member call to something that isn't a method?");
12161 ResultType, VK, RParenLoc);
12186 FoundDecl, Method);
12201 if (CheckFunctionCall(Method, TheCall, Proto))
12207 if (isa<MemberExpr>(NakedMemExpr)) {
12209 Diag(MemExprE->getLocStart(),
12210 diag::err_ovl_no_viable_member_function_in_call)
12213 diag::note_ovl_candidate_disabled_by_enable_if_attr)
12214 <<
Attr->getCond()->getSourceRange() <<
Attr->getMessage();
12227 diag::warn_call_to_pure_virtual_member_function_from_ctor_dtor)
12234 diag::note_pure_qualified_call_kext)
12255 UnbridgedCastsSet UnbridgedCasts;
12260 "Requires object type argument");
12275 diag::err_incomplete_object_call, Object.
get()))
12283 Oper != OperEnd; ++Oper) {
12286 Args, CandidateSet,
12307 const auto &Conversions =
12308 cast<CXXRecordDecl>(Record->getDecl())->getVisibleConversionFunctions();
12309 for (
auto I = Conversions.begin(), E = Conversions.end(); I !=
E; ++
I) {
12312 if (isa<UsingShadowDecl>(D))
12313 D = cast<UsingShadowDecl>(D)->getTargetDecl();
12317 if (isa<FunctionTemplateDecl>(D))
12331 Object.
get(), Args, CandidateSet);
12336 bool HadMultipleCandidates = (CandidateSet.size() > 1);
12340 switch (CandidateSet.BestViableFunction(*
this, Object.
get()->getLocStart(),
12348 if (CandidateSet.empty())
12349 Diag(Object.
get()->getLocStart(), diag::err_ovl_no_oper)
12351 << Object.
get()->getSourceRange();
12353 Diag(Object.
get()->getLocStart(),
12354 diag::err_ovl_no_viable_object_call)
12355 << Object.
get()->
getType() << Object.
get()->getSourceRange();
12360 Diag(Object.
get()->getLocStart(),
12361 diag::err_ovl_ambiguous_object_call)
12362 << Object.
get()->
getType() << Object.
get()->getSourceRange();
12367 Diag(Object.
get()->getLocStart(),
12368 diag::err_ovl_deleted_object_call)
12369 << Best->Function->isDeleted()
12372 << Object.
get()->getSourceRange();
12377 if (Best == CandidateSet.end())
12380 UnbridgedCasts.restore();
12382 if (Best->Function ==
nullptr) {
12386 = cast<CXXConversionDecl>(
12387 Best->Conversions[0].UserDefined.ConversionFunction);
12393 assert(Conv == Best->FoundDecl.getDecl() &&
12394 "Found Decl & conversion-to-functionptr should be same, right?!");
12402 Conv, HadMultipleCandidates);
12403 if (Call.isInvalid())
12410 return ActOnCallExpr(S, Call.get(), LParenLoc, Args, RParenLoc);
12418 CXXMethodDecl *Method = cast<CXXMethodDecl>(Best->Function);
12421 if (Method->isInvalidDecl())
12433 HadMultipleCandidates,
12434 OpLocInfo.getLoc(),
12435 OpLocInfo.getInfo());
12441 std::unique_ptr<Expr * []> MethodArgs(
new Expr *[Args.size() + 1]);
12442 MethodArgs[0] = Object.
get();
12443 std::copy(Args.begin(), Args.end(), &MethodArgs[1]);
12447 QualType ResultTy = Method->getReturnType();
12449 ResultTy = ResultTy.getNonLValueExprType(
Context);
12453 llvm::makeArrayRef(MethodArgs.get(), Args.size() + 1),
12454 ResultTy, VK, RParenLoc,
false);
12455 MethodArgs.reset();
12462 if (Args.size() < NumParams)
12465 bool IsError =
false;
12470 Best->FoundDecl, Method);
12475 TheCall->setArg(0, Object.
get());
12478 for (
unsigned i = 0; i != NumParams; i++) {
12480 if (i < Args.size()) {
12488 Method->getParamDecl(i)),
12504 TheCall->setArg(i + 1, Arg);
12510 for (
unsigned i = NumParams, e = Args.size(); i < e; i++) {
12514 TheCall->setArg(i + 1, Arg.
get());
12518 if (IsError)
return true;
12522 if (CheckFunctionCall(Method, TheCall, Proto))
12533 bool *NoArrowOperatorFound) {
12535 "left-hand side must have class type");
12554 diag::err_typecheck_incomplete_tag, Base))
12562 Oper != OperEnd; ++Oper) {
12564 None, CandidateSet,
false);
12567 bool HadMultipleCandidates = (CandidateSet.
size() > 1);
12577 if (CandidateSet.
empty()) {
12579 if (NoArrowOperatorFound) {
12582 *NoArrowOperatorFound =
true;
12585 Diag(OpLoc, diag::err_typecheck_member_reference_arrow)
12586 << BaseType << Base->getSourceRange();
12588 Diag(OpLoc, diag::note_typecheck_member_reference_suggestion)
12592 Diag(OpLoc, diag::err_ovl_no_viable_oper)
12593 <<
"operator->" << Base->getSourceRange();
12598 Diag(OpLoc, diag::err_ovl_ambiguous_oper_unary)
12599 <<
"->" << Base->
getType() << Base->getSourceRange();
12604 Diag(OpLoc, diag::err_ovl_deleted_oper)
12605 << Best->Function->isDeleted()
12608 << Base->getSourceRange();
12616 CXXMethodDecl *Method = cast<CXXMethodDecl>(Best->Function);
12619 Best->FoundDecl, Method);
12620 if (BaseResult.isInvalid())
12622 Base = BaseResult.get();
12626 HadMultipleCandidates, OpLoc);
12635 Base, ResultTy, VK, OpLoc,
false);
12657 bool HadMultipleCandidates = (CandidateSet.size() > 1);
12662 switch (CandidateSet.BestViableFunction(*
this, UDSuffixLoc, Best)) {
12668 Diag(UDSuffixLoc, diag::err_ovl_no_viable_function_in_call)
12681 HadMultipleCandidates,
12690 for (
unsigned ArgIdx = 0, N = Args.size(); ArgIdx != N; ++ArgIdx) {
12696 ConvArgs[ArgIdx] = InputInit.
get();
12705 llvm::makeArrayRef(ConvArgs, Args.size()),
12706 ResultTy, VK, LitEndLoc, UDSuffixLoc);
12711 if (CheckFunctionCall(FD, UDL,
nullptr))
12731 Scope *S =
nullptr;
12733 CandidateSet->
clear();
12734 if (!MemberLookup.
empty()) {
12757 FoundNames.
begin(), FoundNames.
end());
12760 CandidateSet, CallExpr);
12761 if (CandidateSet->
empty() || CandidateSetError) {
12774 Loc,
nullptr, CandidateSet, &Best,
12793 if (
ParenExpr *PE = dyn_cast<ParenExpr>(E)) {
12796 if (SubExpr == PE->getSubExpr())
12799 return new (
Context)
ParenExpr(PE->getLParen(), PE->getRParen(), SubExpr);
12807 "Implicit cast type cannot be determined from overload");
12808 assert(ICE->path_empty() &&
"fixing up hierarchy conversion?");
12809 if (SubExpr == ICE->getSubExpr())
12813 ICE->getCastKind(),
12819 assert(UnOp->getOpcode() ==
UO_AddrOf &&
12820 "Can only take the address of an overloaded function");
12822 if (Method->isStatic()) {
12831 if (SubExpr == UnOp->getSubExpr())
12834 assert(isa<DeclRefExpr>(SubExpr)
12835 &&
"fixed to something other than a decl ref");
12837 &&
"fixed to a member ref with no nested name qualifier");
12849 UnOp->getOperatorLoc());
12854 if (SubExpr == UnOp->getSubExpr())
12860 UnOp->getOperatorLoc());
12866 if (ULE->hasExplicitTemplateArgs()) {
12867 ULE->copyTemplateArgumentsInto(TemplateArgsBuffer);
12868 TemplateArgs = &TemplateArgsBuffer;
12872 ULE->getQualifierLoc(),
12873 ULE->getTemplateKeywordLoc(),
12889 if (MemExpr->hasExplicitTemplateArgs()) {
12890 MemExpr->copyTemplateArgumentsInto(TemplateArgsBuffer);
12891 TemplateArgs = &TemplateArgsBuffer;
12898 if (MemExpr->isImplicitAccess()) {
12899 if (cast<CXXMethodDecl>(Fn)->isStatic()) {
12901 MemExpr->getQualifierLoc(),
12902 MemExpr->getTemplateKeywordLoc(),
12905 MemExpr->getMemberLoc(),
12915 if (MemExpr->getQualifier())
12916 Loc = MemExpr->getQualifierLoc().getBeginLoc();
12919 MemExpr->getBaseType(),
12923 Base = MemExpr->getBase();
12927 if (cast<CXXMethodDecl>(Fn)->isStatic()) {
12936 Context, Base, MemExpr->isArrow(), MemExpr->getOperatorLoc(),
12937 MemExpr->getQualifierLoc(), MemExpr->getTemplateKeywordLoc(), Fn, Found,
12938 MemExpr->getMemberNameInfo(), TemplateArgs,
type, valueKind,
12945 llvm_unreachable(
"Invalid reference to overloaded function");
Abstract class used to diagnose incomplete types.
unsigned ExplicitCallArguments
The number of call arguments that were explicitly provided, to be used while performing partial order...
bool hasObjCGCAttr() const
A call to an overloaded operator written using operator syntax.
ValueDecl * getMemberDecl() const
Retrieve the member declaration to which this expression refers.
bool compatiblyIncludesObjCLifetime(Qualifiers other) const
Determines if these qualifiers compatibly include another set of qualifiers from the narrow perspecti...
int getFloatingTypeOrder(QualType LHS, QualType RHS) const
Compare the rank of the two specified floating point types, ignoring the domain of the type (i...
void copyTemplateArgumentsInto(TemplateArgumentListInfo &List) const
Copies the template arguments into the given structure.
void setValueDependent(bool VD)
Set whether this expression is value-dependent or not.
bool isObjCObjectOrInterfaceType() const
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.
Module * getOwningModule(Decl *Entity)
Get the module owning an entity.
unsigned getNumInits() const
unsigned DeprecatedStringLiteralToCharPtr
Whether this is the deprecated conversion of a string literal to a pointer to non-const character dat...
Qualifiers getLocalQualifiers() const
Retrieve the set of qualifiers local to this particular QualType instance, not including any qualifie...
SmallVector< TemplateSpecCandidate, 16 >::iterator iterator
(CUDA) This candidate was not viable because the callee was not accessible from the caller's target (...
FunctionDecl - An instance of this class is created to represent a function declaration or definition...
bool isMSVCRTEntryPoint() const
Determines whether this function is a MSVCRT user defined entry point.
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 ...
static void markUnaddressableCandidatesUnviable(Sema &S, OverloadCandidateSet &CS)
bool isNullPtrType() const
QualType getToType() const
StringRef getName() const
getName - Get the name of identifier for this declaration as a StringRef.
ExprResult PerformContextuallyConvertToBool(Expr *From)
PerformContextuallyConvertToBool - Perform a contextual conversion of the expression From to bool (C+...
const TemplateArgument * getSecondArg()
Return the second template argument this deduction failure refers to, if any.
Smart pointer class that efficiently represents Objective-C method names.
static bool isTypeValid(QualType T)
Determine whether the given type is valid, e.g., it is not an invalid C++ class.
PointerType - C99 6.7.5.1 - Pointer Declarators.
bool isAtLeastAsQualifiedAs(QualType Other) const
Determine whether this type is at least as qualified as the other given type, requiring exact equalit...
A (possibly-)qualified type.
bool hasExplicitTemplateArgs() const
Determines whether this expression had explicit template arguments.
TemplateDeductionResult
Describes the result of template argument deduction.
void setToType(QualType T)
ImplicitConversionKind
ImplicitConversionKind - The kind of implicit conversion used to convert an argument to a parameter's...
void EraseUnwantedCUDAMatches(const FunctionDecl *Caller, SmallVectorImpl< FunctionDecl * > &Matches)
Finds a function in Matches with highest calling priority from Caller context and erases all function...
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)
QualType getConversionType() const
Returns the type that this conversion function is converting to.
specific_attr_iterator< T > specific_attr_begin() const
static bool IsTransparentUnionStandardConversion(Sema &S, Expr *From, QualType &ToType, bool InOverloadResolution, StandardConversionSequence &SCS, bool CStyle)
EnableIfAttr * CheckEnableIf(FunctionDecl *Function, ArrayRef< Expr * > Args, bool MissingImplicitThis=false)
Check the enable_if expressions on the given function.
bool isMemberPointerType() const
bool isUnavailable(std::string *Message=nullptr) const
Determine whether this declaration is marked 'unavailable'.
Template argument deduction was successful.
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...
IdentifierInfo * getIdentifier() const
getIdentifier - Get the identifier that names this declaration, if there is one.
bool isInstantiationDependentType() const
Determine whether this type is an instantiation-dependent type, meaning that the type involves a temp...
bool isObjCPointerConversion(QualType FromType, QualType ToType, QualType &ConvertedType, bool &IncompatibleObjC)
isObjCPointerConversion - Determines whether this is an Objective-C pointer conversion.
QualType getNonLValueExprType(const ASTContext &Context) const
Determine the type of a (typically non-lvalue) expression with the specified result type...
QualType getQualifiedType(SplitQualType split) const
Un-split a SplitQualType.
const LangOptions & getLangOpts() const
A structure used to record information about a failed template argument deduction, for diagnosis.
static UnresolvedLookupExpr * Create(const ASTContext &C, CXXRecordDecl *NamingClass, NestedNameSpecifierLoc QualifierLoc, const DeclarationNameInfo &NameInfo, bool ADL, bool Overloaded, UnresolvedSetIterator Begin, UnresolvedSetIterator End)
CanQual< T > getUnqualifiedType() const
Retrieve the unqualified form of this type.
SourceLocation getCXXLiteralOperatorNameLoc() const
getCXXLiteralOperatorNameLoc - Returns the location of the literal operator name (not the operator ke...
bool isAnyCharacterType() const
Determine whether this type is any of the built-in character types.
static void AddBuiltinAssignmentOperatorCandidates(Sema &S, QualType T, ArrayRef< Expr * > Args, OverloadCandidateSet &CandidateSet)
Helper function for AddBuiltinOperatorCandidates() that adds the volatile- and non-volatile-qualified...
FunctionType - C99 6.7.5.3 - Function Declarators.
TemplateDecl * getAsTemplateDecl() const
Retrieve the underlying template declaration that this template name refers to, if known...
bool isMain() const
Determines whether this function is "main", which is the entry point into an executable program...
Provides information about an attempted template argument deduction, whose success or failure was des...
QualType getRValueReferenceType(QualType T) const
Return the uniqued reference to the type for an rvalue reference to the specified type...
unsigned getIntWidth(QualType T) const
void clear()
Clear out all of the candidates.
ExprResult BuildCXXDefaultArgExpr(SourceLocation CallLoc, FunctionDecl *FD, ParmVarDecl *Param)
BuildCXXDefaultArgExpr - Creates a CXXDefaultArgExpr, instantiating the default expr if needed...
Complex conversions (C99 6.3.1.6)
void setObjCLifetime(ObjCLifetime type)
bool hasPlaceholderType() const
Returns whether this expression has a placeholder type.
std::string getTemplateArgumentBindingsText(const TemplateParameterList *Params, const TemplateArgumentList &Args)
Produces a formatted string that describes the binding of template parameters to template arguments...
NestedNameSpecifier * getQualifier() const
If the member name was qualified, retrieves the nested-name-specifier that precedes the member name...
bool isRecordType() const
UserDefinedConversionSequence UserDefined
When ConversionKind == UserDefinedConversion, provides the details of the user-defined conversion seq...
SemaDiagnosticBuilder Diag(SourceLocation Loc, unsigned DiagID)
Emit a diagnostic.
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...
ExprResult BuildCallToMemberFunction(Scope *S, Expr *MemExpr, SourceLocation LParenLoc, MultiExprArg Args, SourceLocation RParenLoc)
BuildCallToMemberFunction - Build a call to a member function.
bool isSpecializationCopyingObject() const
Determine whether this is a member template specialization that would copy the object to itself...
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)
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.
QualType getVolatileType(QualType T) const
Return the uniqued reference to the type for a volatile qualified type.
bool isVoidPointerType() const
Not a narrowing conversion.
llvm::iterator_range< conversion_iterator > getVisibleConversionFunctions()
Get all conversion functions visible in current class, including conversion function templates...
bool isEnumeralType() const
Expr * getExpr()
Return the expression this deduction failure refers to, if any.
ParenExpr - This represents a parethesized expression, e.g.
bool CanPerformCopyInitialization(const InitializedEntity &Entity, ExprResult Init)
ImplicitConversionRank
ImplicitConversionRank - The rank of an implicit conversion kind.
bool hasDefinition() const
std::string getAsString() const
static void NoteFunctionCandidate(Sema &S, OverloadCandidate *Cand, unsigned NumArgs, bool TakingCandidateAddress)
Generates a 'note' diagnostic for an overload candidate.
ExprResult CreateBuiltinArraySubscriptExpr(Expr *Base, SourceLocation LLoc, Expr *Idx, SourceLocation RLoc)
QualType getLValueReferenceType(QualType T, bool SpelledAsLValue=true) const
Return the uniqued reference to the type for an lvalue reference to the specified type...
TemplateSpecializationType(TemplateName T, const TemplateArgument *Args, unsigned NumArgs, QualType Canon, QualType Aliased)
RefQualifierKind getRefQualifier() const
Retrieve the ref-qualifier associated with this method.
bool hasErrorOccurred() const
Determine whether any SFINAE errors have been trapped.
QualType getPointeeType() const
static void CompleteNonViableCandidate(Sema &S, OverloadCandidate *Cand, ArrayRef< Expr * > Args)
CompleteNonViableCandidate - Normally, overload resolution only computes up to the first...
The base class of the type hierarchy.
bool isDependentContext() const
Determines whether this context is dependent on a template parameter.
CK_BaseToDerivedMemberPointer - Member pointer in base class to member pointer in derived class...
unsigned IncompatibleObjC
IncompatibleObjC - Whether this is an Objective-C conversion that we should warn about (if we actuall...
unsigned getCVRQualifiers() const
Retrieve the set of CVR (const-volatile-restrict) qualifiers applied to this type.
QualType getRecordType(const RecordDecl *Decl) const
void MarkDeclRefReferenced(DeclRefExpr *E)
Perform reference-marking and odr-use handling for a DeclRefExpr.
NamespaceDecl - Represent a C++ namespace.
Template argument deduction produced inconsistent deduced values for the given template parameter...
SourceLocation getLocForEndOfToken(SourceLocation Loc, unsigned Offset=0)
Calls Lexer::getLocForEndOfToken()
static ExprValueKind getValueKindForType(QualType T)
getValueKindForType - Given a formal return or parameter type, give its value kind.
Ambiguous candidates found.
CK_FloatingToIntegral - Floating point to integral.
bool isBooleanType() const
bool compatiblyIncludes(Qualifiers other) const
Determines if these qualifiers compatibly include another set.
Conversions between compatible types in C99.
bool isBlockPointerType() const
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...
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.
static unsigned RankDeductionFailure(const DeductionFailureInfo &DFI)
void * getAsOpaquePtr() const
CK_IntegralToFloating - Integral to floating point.
void ArgumentDependentLookup(DeclarationName Name, SourceLocation Loc, ArrayRef< Expr * > Args, ADLResult &Functions)
static bool isFunctionAlwaysEnabled(const ASTContext &Ctx, const FunctionDecl *FD)
void Adopt(NestedNameSpecifierLoc Other)
Adopt an existing nested-name-specifier (with source-range information).
RAII object that enters a new expression evaluation context.
QualType getRestrictType(QualType T) const
Return the uniqued reference to the type for a restrict qualified type.
PartialDiagnostic PDiag(unsigned DiagID=0)
Build a partial diagnostic.
CK_IntegralCast - A cast between integral types (other than to boolean).
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 ...
void removeObjCLifetime()
DiagnosticsEngine & Diags
ObjCLifetime getObjCLifetime() const
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...
OverloadKind CheckOverload(Scope *S, FunctionDecl *New, const LookupResult &OldDecls, NamedDecl *&OldDecl, bool IsForUsingDecl)
static bool functionHasPassObjectSizeParams(const FunctionDecl *FD)
void NoteOverloadCandidate(FunctionDecl *Fn, QualType DestType=QualType(), bool TakingAddress=false)
AccessSpecifier getAccess() const
bool IsSurrogate
IsSurrogate - True to indicate that this candidate is a surrogate for a conversion to a function poin...
static ImplicitConversionSequence::CompareKind CompareQualificationConversions(Sema &S, const StandardConversionSequence &SCS1, const StandardConversionSequence &SCS2)
CompareQualificationConversions - Compares two standard conversion sequences to determine whether the...
std::string getAsString() const
std::string getDeletedOrUnavailableSuffix(const FunctionDecl *FD)
Retrieve the message suffix that should be added to a diagnostic complaining about the given function...
uint64_t getTypeSize(QualType T) const
Return the size of the specified (complete) type T, in bits.
ObjCMethodDecl - Represents an instance or class method declaration.
QualType getThisType(ASTContext &C) const
Returns the type of the this pointer.
NamedDecl * getUnderlyingDecl()
Looks through UsingDecls and ObjCCompatibleAliasDecls for the underlying named decl.
QualType ExtractUnqualifiedFunctionType(QualType PossiblyAFunctionType)
bool HadMultipleCandidates
HadMultipleCandidates - When this is true, it means that the conversion function was resolved from an...
Removal of noreturn from a type (Clang)
Like System, but searched after the system directories.
static bool hasBetterEnableIfAttrs(Sema &S, const FunctionDecl *Cand1, const FunctionDecl *Cand2)
Decl * Specialization
Specialization - The actual specialization that this candidate represents.
void getAsStringInternal(std::string &Str, const PrintingPolicy &Policy) const
const BuiltinType * getAsPlaceholderType() const
bool IsIntegralPromotion(Expr *From, QualType FromType, QualType ToType)
IsIntegralPromotion - Determines whether the conversion from the expression From (whose potentially-a...
unsigned param_size() const
bool FunctionTypesMatchOnNSConsumedAttrs(const FunctionProtoType *FromFunctionType, const FunctionProtoType *ToFunctionType)
std::vector< FixItHint > Hints
The list of Hints generated so far.
ParmVarDecl - Represents a parameter to a function.
QualType getBaseType() const
NullPointerConstantKind isNullPointerConstant(ASTContext &Ctx, NullPointerConstantValueDependence NPC) const
isNullPointerConstant - C99 6.3.2.3p3 - Test if this reduces down to a Null pointer constant...
bool isMoveAssignmentOperator() const
Determine whether this is a move assignment operator.
Defines the clang::Expr interface and subclasses for C++ expressions.
TemplateParameter Param
The template parameter to which a template argument deduction failure refers.
bool isEmpty() const
No scope specifier.
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.
ExprResult ActOnCallExpr(Scope *S, Expr *Fn, SourceLocation LParenLoc, MultiExprArg ArgExprs, SourceLocation RParenLoc, Expr *ExecConfig=nullptr, bool IsExecConfig=false)
ActOnCallExpr - Handle a call to Fn with the specified array of arguments.
QualType getArrayDecayedType(QualType T) const
Return the properly qualified result of decaying the specified array type to a pointer.
ExprResult PerformImplicitConversion(Expr *From, QualType ToType, AssignmentAction Action, bool AllowExplicit=false)
PerformImplicitConversion - Perform an implicit conversion of the expression From to the type ToType...
ExprResult CreateOverloadedBinOp(SourceLocation OpLoc, BinaryOperatorKind Opc, const UnresolvedSetImpl &Fns, Expr *LHS, Expr *RHS)
Create a binary operation that may resolve to an overloaded operator.
unsigned getNumParams() const
Expr * FixOverloadedFunctionReference(Expr *E, DeclAccessPair FoundDecl, FunctionDecl *Fn)
FixOverloadedFunctionReference - E is an expression that refers to a C++ overloaded function (possibl...
RecordDecl - Represents a struct/union/class.
std::string getFullModuleName() const
Retrieve the full name of this module, including the path from its top-level module.
bool hasUninstantiatedDefaultArg() const
DeclarationName getMemberName() const
Retrieve the name of the member that this expression refers to.
Boolean conversions (C++ 4.12)
QualType apply(const ASTContext &Context, QualType QT) const
Apply the collected qualifiers to the given type.
class LLVM_ALIGNAS(8) DependentTemplateSpecializationType const IdentifierInfo * Name
Represents a template specialization type whose template cannot be resolved, e.g. ...
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...
const TemplateArgumentList * getTemplateSpecializationArgs() const
Retrieve the template arguments used to produce this function template specialization from the primar...
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.
The results of name lookup within a DeclContext.
OverloadCandidate & addCandidate(unsigned NumConversions=0)
Add a new candidate with NumConversions conversion sequence slots to the overload set...
static bool diagnoseNoViableConversion(Sema &SemaRef, SourceLocation Loc, Expr *&From, Sema::ContextualImplicitConverter &Converter, QualType T, bool HadMultipleCandidates, UnresolvedSetImpl &ExplicitConversions)
ImplicitConversionSequence * Conversions
Conversions - The conversion sequences used to convert the function arguments to the function paramet...
unsigned BindsToFunctionLvalue
Whether we're binding to a function lvalue.
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.
bool isReferenceType() const
QualType getReturnType() const
FieldDecl - An instance of this class is created by Sema::ActOnField to represent a member of a struc...
FunctionDecl * getTemplatedDecl() const
Get the underlying function declaration of the template.
bool isAnyPointerType() const
Expr * getBase()
Retrieve the base object of this member expressions, e.g., the x in x.m.
Identity conversion (no conversion)
The arguments included an overloaded function name that could not be resolved to a suitable function...
void AddBuiltinOperatorCandidates(OverloadedOperatorKind Op, SourceLocation OpLoc, ArrayRef< Expr * > Args, OverloadCandidateSet &CandidateSet)
AddBuiltinOperatorCandidates - Add the appropriate built-in operator overloads to the candidate set (...
void setNumArgs(const ASTContext &C, unsigned NumArgs)
setNumArgs - This changes the number of arguments present in this call.
ConversionSet & conversions()
bool isPure() const
Whether this virtual function is pure, i.e.
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.
QualType getToType() const
Floating point conversions (C++ 4.8)
virtual SemaDiagnosticBuilder diagnoseConversion(Sema &S, SourceLocation Loc, QualType T, QualType ConvTy)=0
Emits a diagnostic when we picked a conversion function (for cases when we are not allowed to pick a ...
unsigned getCVRQualifiers() const
The iterator over UnresolvedSets.
bool hasSameType(QualType T1, QualType T2) const
Determine whether the given types T1 and T2 are equivalent.
CK_FloatingCast - Casting between floating types of different size.
static DeclRefExpr * Create(const ASTContext &Context, NestedNameSpecifierLoc QualifierLoc, SourceLocation TemplateKWLoc, ValueDecl *D, bool RefersToEnclosingVariableOrCapture, SourceLocation NameLoc, QualType T, ExprValueKind VK, NamedDecl *FoundD=nullptr, const TemplateArgumentListInfo *TemplateArgs=nullptr)
ExprResult PerformContextuallyConvertToObjCPointer(Expr *From)
PerformContextuallyConvertToObjCPointer - Perform a contextual conversion of the expression From to a...
bool match(QualType T) override
Match an integral or (possibly scoped) enumeration type.
bool isMoveConstructor(unsigned &TypeQuals) const
Determine whether this constructor is a move constructor (C++11 [class.copy]p3), which can be used to...
const RecordType * getAsUnionType() const
NOTE: getAs*ArrayType are methods on ASTContext.
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...
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...
ExprResult CreateOverloadedUnaryOp(SourceLocation OpLoc, UnaryOperatorKind Opc, const UnresolvedSetImpl &Fns, Expr *input)
Create a unary operation that may resolve to an overloaded operator.
void AddConversionCandidate(CXXConversionDecl *Conversion, DeclAccessPair FoundDecl, CXXRecordDecl *ActingContext, Expr *From, QualType ToType, OverloadCandidateSet &CandidateSet, bool AllowObjCConversionOnExplicit)
AddConversionCandidate - Add a C++ conversion function as a candidate in the candidate set (C++ [over...
CK_NullToPointer - Null pointer constant to pointer, ObjC pointer, or block pointer.
QualType getTypeDeclType(const TypeDecl *Decl, const TypeDecl *PrevDecl=nullptr) const
Return the unique reference to the type for the specified type declaration.
SourceLocation getLocStart() const LLVM_READONLY
OverloadKind
C++ Overloading.
bool hasSameUnqualifiedType(QualType T1, QualType T2) const
Determine whether the given types are equivalent after cvr-qualifiers have been removed.
struct clang::OverloadCandidate::@201 BuiltinTypes
Describes a module or submodule.
OverloadCandidateDisplayKind
void NoteDeletedFunction(FunctionDecl *FD)
Emit a note explaining that this function is deleted.
An r-value expression (a pr-value in the C++11 taxonomy) produces a temporary value.
Floating point promotions (C++ 4.6)
Describes an C or C++ initializer list.
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...
bool isIntegralOrUnscopedEnumerationType() const
Determine whether this type is an integral or unscoped enumeration type.
CK_IntegralToBoolean - Integral to boolean.
ImplicitConversionRank getRank() const
getRank - Retrieve the rank of this standard conversion sequence (C++ 13.3.3.1.1p3).
QualType getCallResultType(ASTContext &Context) const
Determine the type of an expression that calls a function of this type.
bool isFunctionConsideredUnavailable(FunctionDecl *FD)
Checks availability of the function depending on the current function context.Inside an unavailable f...
An rvalue reference type, per C++11 [dcl.ref].
bool isCompleteType(SourceLocation Loc, QualType T)
static ExprResult CheckConvertedConstantExpression(Sema &S, Expr *From, QualType T, APValue &Value, Sema::CCEKind CCE, bool RequireInt)
CheckConvertedConstantExpression - Check that the expression From is a converted constant expression ...
SmallVectorImpl< PartialDiagnosticAt > * Diag
Diag - If this is non-null, it will be filled in with a stack of notes indicating why evaluation fail...
Represents the results of name lookup.
An lvalue ref-qualifier was provided (&).
unsigned BindsToRvalue
Whether we're binding to an rvalue.
static ImplicitConversionSequence::CompareKind compareStandardConversionSubsets(ASTContext &Context, const StandardConversionSequence &SCS1, const StandardConversionSequence &SCS2)
bool UnwrapSimilarPointerTypes(QualType &T1, QualType &T2)
UnwrapSimilarPointerTypes - If T1 and T2 are pointer types that may be similar (C++ 4...
bool DiagnoseUseOfDecl(NamedDecl *D, SourceLocation Loc, const ObjCInterfaceDecl *UnknownObjCClass=nullptr, bool ObjCPropertyAccess=false)
Determine whether the use of this declaration is valid, and emit any corresponding diagnostics...
static DeclAccessPair make(NamedDecl *D, AccessSpecifier AS)
const LangOptions & getLangOpts() const
bool isImplicit() const
isImplicit - Indicates whether the declaration was implicitly generated by the implementation.
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.
CanProxy< U > getAs() const
Retrieve a canonical type pointer with a different static type, upcasting or downcasting as needed...
Ref_Compatible - The two types are reference-compatible and have equivalent qualifiers (cv1 == cv2)...
QualType getReturnType() const
unsigned getMinRequiredArguments() const
getMinRequiredArguments - Returns the minimum number of arguments needed to call this function...
const CXXRecordDecl * getParent() const
Returns the parent of this method declaration, which is the class in which this method is defined...
bool isDefaulted() const
Whether this function is defaulted per C++0x.
unsigned QualificationIncludesObjCLifetime
Whether the qualification conversion involves a change in the Objective-C lifetime (for automatic ref...
field_range fields() const
bool isObjCLifetimeType() const
Returns true if objects of this type have lifetime semantics under ARC.
const ArrayType * getAsArrayType(QualType T) const
Type Query functions.
static bool isRecordType(QualType T)
static bool IsAcceptableNonMemberOperatorCandidate(ASTContext &Context, FunctionDecl *Fn, ArrayRef< Expr * > Args)
IsAcceptableNonMemberOperatorCandidate - Determine whether Fn is an acceptable non-member overloaded ...
A builtin binary operation expression such as "x + y" or "x <= y".
Substitution of the deduced template argument values resulted in an error.
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.
This candidate function was not viable because an enable_if attribute disabled it.
bool isValueDependent() const
isValueDependent - Determines whether this expression is value-dependent (C++ [temp.dep.constexpr]).
A set of unresolved declarations.
RecordDecl * getDecl() const
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.
SourceLocation getTemplateKeywordLoc() const
Retrieve the location of the template keyword preceding this name, if any.
bool requiresADL() const
True if this declaration should be extended by argument-dependent lookup.
Template argument deduction exceeded the maximum template instantiation depth (which has already been...
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...
bool isUnsignedIntegerType() const
Return true if this is an integer type that is unsigned, according to C99 6.2.5p6 [which returns true...
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).
Expr * IgnoreParenCasts() LLVM_READONLY
IgnoreParenCasts - Ignore parentheses and casts.
bool isVariadic() const
Whether this function is variadic.
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.
void Destroy()
Free any memory associated with this deduction failure.
Qualification conversions (C++ 4.4)
static bool isBooleanType(QualType Ty)
Represents a C++ nested-name-specifier or a global scope specifier.
TypeClass getTypeClass() const
void diagnoseEquivalentInternalLinkageDeclarations(SourceLocation Loc, const NamedDecl *D, ArrayRef< const NamedDecl * > Equiv)
bool isIncompleteType(NamedDecl **Def=nullptr) const
Types are partitioned into 3 broad categories (C99 6.2.5p1): object types, function types...
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.
NarrowingKind getNarrowingKind(ASTContext &Context, const Expr *Converted, APValue &ConstantValue, QualType &ConstantType) const
Check if this standard conversion sequence represents a narrowing conversion, according to C++11 [dcl...
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'.
ExprResult DefaultFunctionArrayLvalueConversion(Expr *E, bool Diagnose=true)
static ImplicitConversionSequence TryContextuallyConvertToObjCPointer(Sema &S, Expr *From)
TryContextuallyConvertToObjCPointer - Attempt to contextually convert the expression From to an Objec...
AssignConvertType CheckSingleAssignmentConstraints(QualType LHSType, ExprResult &RHS, bool Diagnose=true, bool DiagnoseCFAudited=false, bool ConvertRHS=true)
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.
FunctionTemplateDecl * getDescribedFunctionTemplate() const
Retrieves the function template that is described by this function declaration.
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.
ExprResult BuildMemberReferenceExpr(Expr *Base, QualType BaseType, SourceLocation OpLoc, bool IsArrow, CXXScopeSpec &SS, SourceLocation TemplateKWLoc, NamedDecl *FirstQualifierInScope, const DeclarationNameInfo &NameInfo, const TemplateArgumentListInfo *TemplateArgs, const Scope *S, ActOnMemberAccessExtraArgs *ExtraArgs=nullptr)
bool isExtVectorType() const
static ExprResult finishContextualImplicitConversion(Sema &SemaRef, SourceLocation Loc, Expr *From, Sema::ContextualImplicitConverter &Converter)
ImplicitConversionKind Third
Third - The third conversion can be a qualification conversion.
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.
detail::InMemoryDirectory::const_iterator I
ExprResult BuildDeclarationNameExpr(const CXXScopeSpec &SS, LookupResult &R, bool NeedsADL, bool AcceptInvalidDecl=false)
Complex <-> Real conversion.
bool Viable
Viable - True to indicate that this overload candidate is viable.
static Classification makeSimpleLValue()
Create a simple, modifiably lvalue.
CanQualType UnsignedCharTy
Integral promotions (C++ 4.5)
This conversion function template specialization candidate is not viable because the final conversion...
bool IsStringLiteralToNonConstPointerConversion(Expr *From, QualType ToType)
Helper function to determine whether this is the (deprecated) C++ conversion from a string literal to...
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.
This object can be modified without requiring retains or releases.
const UnresolvedSetImpl & asUnresolvedSet() const
AccessResult CheckUnresolvedMemberAccess(UnresolvedMemberExpr *E, DeclAccessPair FoundDecl)
Perform access-control checking on a previously-unresolved member access which has now been resolved ...
param_iterator param_begin()
Represents the this expression in C++.
bool IsOverload(FunctionDecl *New, FunctionDecl *Old, bool IsForUsingDecl)
SourceLocation getLoc() const
getLoc - Returns the main location of the declaration name.
EnumDecl * getDecl() const
bool IsComplexPromotion(QualType FromType, QualType ToType)
Determine if a conversion is a complex promotion.
RAII class used to determine whether SFINAE has trapped any errors that occur during template argumen...
CK_AnyPointerToBlockPointerCast - Casting any non-block pointer to a block pointer.
static bool hasDeprecatedStringLiteralToCharPtrConversion(const ImplicitConversionSequence &ICS)
specific_attr_iterator< T > specific_attr_end() const
CXXSpecialMember
Kinds of C++ special members.
OverloadFixItKind Kind
The type of fix applied.
QualType getValueType() const
Gets the type contained by this atomic type, i.e.
DeductionFailureInfo DeductionFailure
Template argument deduction info.
ExtInfo getExtInfo() const
static void NoteAmbiguousUserConversions(Sema &S, SourceLocation OpLoc, OverloadCandidate *Cand)
Sema - This implements semantic analysis and AST building for C.
bool isBetterOverloadCandidate(Sema &S, const OverloadCandidate &Cand1, const OverloadCandidate &Cand2, SourceLocation Loc, bool UserDefinedConversion=false)
isBetterOverloadCandidate - Determines whether the first overload candidate is a better candidate tha...
bool CheckCUDATarget(const FunctionDecl *Caller, const FunctionDecl *Callee)
QualType getParamType(unsigned i) const
Represents a prototype with parameter type info, e.g.
static ExprResult CreateFunctionRefExpr(Sema &S, FunctionDecl *Fn, NamedDecl *FoundDecl, bool HadMultipleCandidates, SourceLocation Loc=SourceLocation(), const DeclarationNameLoc &LocInfo=DeclarationNameLoc())
A convenience routine for creating a decayed reference to a function.
CXXMethodDecl * getMethodDecl() const
Retrieves the declaration of the called method.
ExprResult CreateBuiltinBinOp(SourceLocation OpLoc, BinaryOperatorKind Opc, Expr *LHSExpr, Expr *RHSExpr)
CreateBuiltinBinOp - Creates a new built-in binary operation with operator Opc at location TokLoc...
void erase(NamedDecl *D)
Removes any data associated with a given decl.
Transparent Union Conversions.
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...
bool EvaluateAsRValue(EvalResult &Result, const ASTContext &Ctx) const
EvaluateAsRValue - Return true if this is a constant which we can fold to an rvalue using any crazy t...
CastKind
CastKind - The kind of operation required for a conversion.
The return type of classify().
param_type_iterator param_type_begin() const
static ImplicitCastExpr * Create(const ASTContext &Context, QualType T, CastKind Kind, Expr *Operand, const CXXCastPath *BasePath, ExprValueKind Cat)
void AddMemberOperatorCandidates(OverloadedOperatorKind Op, SourceLocation OpLoc, ArrayRef< Expr * > Args, OverloadCandidateSet &CandidateSet, SourceRange OpRange=SourceRange())
Add overload candidates for overloaded operators that are member functions.
DeclarationNameTable DeclarationNames
Template argument deduction did not deduce a value for every template parameter.
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.
NamedDecl * getDecl() const
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...
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.
CK_FunctionToPointerDecay - Function to pointer decay.
unsigned Result
A Sema::TemplateDeductionResult.
bool isMoreQualifiedThan(QualType Other) const
Determine whether this type is more qualified than the other given type, requiring exact equality for...
QualType getPointeeType() const
If this is a pointer, ObjC object pointer, or block pointer, this returns the respective pointee...
NameKind getNameKind() const
getNameKind - Determine what kind of name this is.
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...
bool isRealFloatingType() const
Floating point categories.
static SourceLocation GetLocationForCandidate(const OverloadCandidate *Cand)
An Objective-C property is a logical field of an Objective-C object which is read and written via Obj...
bool isSignedIntegerOrEnumerationType() const
Determines whether this is an integer type that is signed or an enumeration types whose underlying ty...
Allows QualTypes to be sorted and hence used in maps and sets.
ObjC ARC writeback conversion.
bool isDeleted() const
Whether this function has been deleted.
const Type * getTypeForDecl() const
static OverloadingResult IsInitializerListConstructorConversion(Sema &S, Expr *From, QualType ToType, CXXRecordDecl *To, UserDefinedConversionSequence &User, OverloadCandidateSet &CandidateSet, bool AllowExplicit)
unsigned getTypeQualifiers() const
void dump() const
dump - Print this user-defined conversion sequence to standard error.
ExprResult BuildResolvedCallExpr(Expr *Fn, NamedDecl *NDecl, SourceLocation LParenLoc, ArrayRef< Expr * > Arg, SourceLocation RParenLoc, Expr *Config=nullptr, bool IsExecConfig=false)
BuildResolvedCallExpr - Build a call to a resolved expression, i.e.
Expr - This represents one expression.
bool DiagnoseEmptyLookup(Scope *S, CXXScopeSpec &SS, LookupResult &R, std::unique_ptr< CorrectionCandidateCallback > CCC, TemplateArgumentListInfo *ExplicitTemplateArgs=nullptr, ArrayRef< Expr * > Args=None, TypoExpr **Out=nullptr)
Diagnose an empty lookup.
DeclarationName getLookupName() const
Gets the name to look up.
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.
Represents an ambiguous user-defined conversion sequence.
ExprValueKind
The categorization of expression values, currently following the C++11 scheme.
bool performsVirtualDispatch(const LangOptions &LO) const
Returns true if virtual dispatch is performed.
Expr * stripARCUnbridgedCast(Expr *e)
stripARCUnbridgedCast - Given an expression of ARCUnbridgedCast type, remove the placeholder cast...
CK_BitCast - A conversion which causes a bit pattern of one type to be reinterpreted as a bit pattern...
Qualifiers getQualifiers() const
Retrieve all qualifiers.
unsigned getNumArgs() const
bool isAnyComplexType() const
bool isDeletedAsWritten() const
void takeSFINAEDiagnostic(PartialDiagnosticAt &PD)
Take ownership of the SFINAE diagnostic.
bool isBeforeInTranslationUnit(SourceLocation LHS, SourceLocation RHS) const
Determines the order of 2 source locations in the translation unit.
When performing template argument deduction for a function template, there were too many call argumen...
NestedNameSpecifierLoc getQualifierLoc() const
Fetches the nested-name qualifier with source-location information, if one was given.
bool isObjCClassType() const
decls_iterator decls_end() const
bool CollectMultipleMethodsInGlobalPool(Selector Sel, SmallVectorImpl< ObjCMethodDecl * > &Methods, bool instance)
Returns instance or factory methods in global method pool for given selector.
Declaration of a template type parameter.
void dump() const
dump - Print this standard conversion sequence to standard error.
SourceLocation getNameLoc() const
Gets the location of the name.
static FindResult find(Expr *E)
Finds the overloaded expression in the given expression E of OverloadTy.
StandardConversionSequence After
After - Represents the standard conversion that occurs after the actual user-defined conversion...
SourceLocation getNameLoc() const
Gets the location of the identifier.
bool Encloses(const DeclContext *DC) const
Determine whether this declaration context encloses the declaration context DC.
SourceLocation getMemberLoc() const
static bool isFirstArgumentCompatibleWithType(ASTContext &Context, CXXConstructorDecl *Constructor, QualType Type)
void setTypeDependent(bool TD)
Set whether this expression is type-dependent or not.
SmallVectorImpl< OverloadCandidate >::iterator iterator
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]...
ArgKind getKind() const
Return the kind of stored template argument.
const ParmVarDecl * getParamDecl(unsigned i) const
static Qualifiers CollectVRQualifiers(ASTContext &Context, Expr *ArgExpr)
CollectVRQualifiers - This routine returns Volatile/Restrict qualifiers, if any, found in visible typ...
bool isInitListConstructor(const CXXConstructorDecl *Ctor)
Determine whether Ctor is an initializer-list constructor, as defined in [dcl.init.list]p2.
CXXConstructorDecl * CopyConstructor
CopyConstructor - The copy constructor that is used to perform this conversion, when the conversion i...
void addConversion(FunctionDecl *D)
DeclContext * getDeclContext()
Overload resolution succeeded.
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...
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.
QualType getFromType() const
Classification Classify(ASTContext &Ctx) const
Classify - Classify this expression according to the C++11 expression taxonomy.
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...
ReferenceCompareResult
ReferenceCompareResult - Expresses the result of comparing two types (cv1 T1 and cv2 T2) to determine...
bool RequireCompleteType(SourceLocation Loc, QualType T, TypeDiagnoser &Diagnoser)
Ensure that the type T is a complete type.
bool isObjCIdType() const
virtual SemaDiagnosticBuilder diagnoseAmbiguous(Sema &S, SourceLocation Loc, QualType T)=0
Emits a diagnostic when there are multiple possible conversion functions.
Floating-integral conversions (C++ 4.9)
static SmallVector< EnableIfAttr *, 4 > getOrderedEnableIfAttrs(const FunctionDecl *Function)
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...
This conversion candidate was not considered because it is an illegal instantiation of a constructor ...
bool TryToFixBadConversion(unsigned Idx, Sema &S)
QualType getFromType() const
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...
bool isScoped() const
Returns true if this is a C++11 scoped enumeration.
This candidate was not viable because its address could not be taken.
void NoteCandidates(Sema &S, OverloadCandidateDisplayKind OCD, ArrayRef< Expr * > Args, StringRef Opc="", SourceLocation Loc=SourceLocation())
PrintOverloadCandidates - When overload resolution fails, prints diagnostic messages containing the c...
void NoteDeductionFailure(Sema &S, bool ForTakingAddress)
Diagnose a template argument deduction failure.
static bool TooManyArguments(size_t NumParams, size_t NumArgs, bool PartialOverloading=false)
To be used for checking whether the arguments being passed to function exceeds the number of paramete...
bool isDependentType() const
Whether this type is a dependent type, meaning that its definition somehow depends on a template para...
StandardConversionSequence Standard
When ConversionKind == StandardConversion, provides the details of the standard conversion sequence...
llvm::SmallPtrSet< CXXRecordDecl *, 16 > AssociatedClassSet
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.
bool isAtLeastAsQualifiedAs(CanQual< T > Other) const
Determines whether this canonical type is at least as qualified as the Other canonical type...
void AddFunctionCandidates(const UnresolvedSetImpl &Functions, ArrayRef< Expr * > Args, OverloadCandidateSet &CandidateSet, TemplateArgumentListInfo *ExplicitTemplateArgs=nullptr, bool SuppressUserConversions=false, bool PartialOverloading=false)
Add all of the function declarations in the given function set to the overload candidate set...
QualType getObjCIdType() const
Represents the Objective-CC id type.
void AddTemplateOverloadCandidate(FunctionTemplateDecl *FunctionTemplate, DeclAccessPair FoundDecl, TemplateArgumentListInfo *ExplicitTemplateArgs, ArrayRef< Expr * > Args, OverloadCandidateSet &CandidateSet, bool SuppressUserConversions=false, bool PartialOverloading=false)
Add a C++ function template specialization as a candidate in the candidate set, using template argume...
static const FunctionProtoType * tryGetFunctionProtoType(QualType FromType)
Attempts to get the FunctionProtoType from a Type.
virtual SemaDiagnosticBuilder noteExplicitConv(Sema &S, CXXConversionDecl *Conv, QualType ConvTy)=0
Emits a note for the explicit conversion function.
UnaryOperator - This represents the unary-expression's (except sizeof and alignof), the postinc/postdec operators from postfix-expression, and various extensions.
SmallVector< ActiveTemplateInstantiation, 16 > ActiveTemplateInstantiations
List of active template instantiations.
bool DeduceReturnType(FunctionDecl *FD, SourceLocation Loc, bool Diagnose=true)
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].
DeclarationName getDeclName() const
getDeclName - Get the actual, stored name of the declaration, which may be a special name...
TemplateTemplateParmDecl - Declares a template template parameter, e.g., "T" in.
DiagnosticsEngine & getDiagnostics() const
class LLVM_ALIGNAS(8) TemplateSpecializationType unsigned NumArgs
Represents a type template specialization; the template must be a class template, a type alias templa...
static bool CheckArityMismatch(Sema &S, OverloadCandidate *Cand, unsigned NumArgs)
Additional arity mismatch diagnosis specific to a function overload candidates.
After substituting deduced template arguments, a dependent parameter type did not match the correspon...
Represents a C++ conversion function within a class.
QualType getCVRQualifiedType(QualType T, unsigned CVR) const
Return a type with additional const, volatile, or restrict qualifiers.
The result type of a method or function.
bool isExplicit() const
Whether this is an explicit conversion operator (C++11 and later).
bool isObjectType() const
Determine whether this type is an object 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...
Lvalue-to-rvalue conversion (C++ 4.1)
decls_iterator decls_begin() 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 ...
ArrayRef< ParmVarDecl * > parameters() const
CK_CPointerToObjCPointerCast - Casting a C pointer kind to an Objective-C pointer.
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)
unsigned NumConversions
NumConversions - The number of elements in the Conversions array.
bool isIdentityConversion() const
QualType getFromType() const
OpaqueValueExpr - An expression referring to an opaque object of a fixed type and value class...
static std::unique_ptr< CorrectionCandidateCallback > MakeValidator(Sema &SemaRef, MemberExpr *ME, size_t NumArgs, bool HasTemplateArgs, bool AllowTypoCorrection)
Integral conversions (C++ 4.7)
Complex promotions (Clang extension)
ExprResult MaybeBindToTemporary(Expr *E)
MaybeBindToTemporary - If the passed in expression has a record type with a non-trivial destructor...
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...
bool isIntegralOrEnumerationType() const
Determine whether this type is an integral or enumeration type.
static bool checkAddressOfCandidateIsAvailable(Sema &S, const FunctionDecl *FD)
bool isInitialized() const
Determines whether this conversion sequence has been initialized.
CK_UserDefinedConversion - Conversion using a user defined type conversion function.
bool isVolatileQualified() const
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.
Encodes a location in the source.
unsigned getNumParams() const
getNumParams - Return the number of parameters this function must have based on its FunctionType...
A helper class that allows the use of isa/cast/dyncast to detect TagType objects of enums...
const Type * getTypePtr() const
Retrieves a pointer to the underlying (unqualified) type.
TemplateName getAsTemplate() const
Retrieve the template name for a template name argument.
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...
const TemplateArgument * iterator
QualType getElementType() const
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.
bool IsNoReturnConversion(QualType FromType, QualType ToType, QualType &ResultTy)
Determine whether the conversion from FromType to ToType is a valid conversion that strips "noreturn"...
bool isValid() const
Return true if this is a valid SourceLocation object.
OverloadedOperatorKind getCXXOverloadedOperator() const
getCXXOverloadedOperator - If this name is the name of an overloadable operator in C++ (e...
static ImplicitConversionSequence::CompareKind CompareStandardConversionSequences(Sema &S, SourceLocation Loc, const StandardConversionSequence &SCS1, const StandardConversionSequence &SCS2)
CompareStandardConversionSequences - Compare two standard conversion sequences to determine whether o...
CUDAFunctionTarget IdentifyCUDATarget(const FunctionDecl *D)
IdentifyCUDATarget - Determine the CUDA compilation target for this function.
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...
Represents a call to a member function that may be written either with member call syntax (e...
CK_NullToMemberPointer - Null pointer constant to member pointer.
ASTContext & getASTContext() const
A vector splat from an arithmetic type.
static void DiagnoseBadDeduction(Sema &S, Decl *Templated, DeductionFailureInfo &DeductionFailure, unsigned NumArgs, bool TakingCandidateAddress)
Diagnose a failed template-argument deduction.
llvm::APSInt EvaluateKnownConstInt(const ASTContext &Ctx, SmallVectorImpl< PartialDiagnosticAt > *Diag=nullptr) const
EvaluateKnownConstInt - Call EvaluateAsRValue and return the folded integer.
OverloadingResult
OverloadingResult - Capture the result of performing overload resolution.
static ImplicitConversionSequence::CompareKind compareConversionFunctions(Sema &S, FunctionDecl *Function1, FunctionDecl *Function2)
Compare the user-defined conversion functions or constructors of two user-defined conversion sequence...
Represents a static or instance method of a struct/union/class.
bool isObjCBuiltinType() const
static void DiagnoseBadConversion(Sema &S, OverloadCandidate *Cand, unsigned I, bool TakingCandidateAddress)
void AddTemplateConversionCandidate(FunctionTemplateDecl *FunctionTemplate, DeclAccessPair FoundDecl, CXXRecordDecl *ActingContext, Expr *From, QualType ToType, OverloadCandidateSet &CandidateSet, bool AllowObjCConversionOnExplicit)
Adds a conversion function template specialization candidate to the overload set, using template argu...
void AddBuiltinCandidate(QualType ResultTy, QualType *ParamTys, ArrayRef< Expr * > Args, OverloadCandidateSet &CandidateSet, bool IsAssignmentOperator=false, unsigned NumContextualBoolArguments=0)
AddBuiltinCandidate - Add a candidate for a built-in operator.
CK_DerivedToBase - A conversion from a C++ class pointer to a base class pointer. ...
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)
Expr * Expression
The expression which caused a deduction failure.
The declaration was invalid; do nothing.
Ref_Compatible_With_Added_Qualification - The two types are reference-compatible with added qualifica...
static bool IsVectorConversion(Sema &S, QualType FromType, QualType ToType, ImplicitConversionKind &ICK)
Determine whether the conversion from FromType to ToType is a valid vector conversion.
void dump() const
dump - Print this implicit conversion sequence to standard error.
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...
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...
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 isStdInitializerListElement() const
Whether the target is really a std::initializer_list, and the sequence only represents the worst elem...
bool CheckMemberPointerConversion(Expr *From, QualType ToType, CastKind &Kind, CXXCastPath &BasePath, bool IgnoreBaseAccess)
CheckMemberPointerConversion - Check the member pointer conversion from the expression From to the ty...
void setAsIdentityConversion()
StandardConversionSequence - Set the standard conversion sequence to the identity conversion...
Pointer conversions (C++ 4.10)
Lookup for candidates for a call using operator syntax.
ImplicitCastExpr - Allows us to explicitly represent implicit type conversions, which have no direct ...
std::pair< SourceLocation, PartialDiagnostic > PartialDiagnosticAt
A partial diagnostic along with the source location where this diagnostic occurs. ...
bool canBindObjCObjectType(QualType To, QualType From)
CandidateSetKind getKind() const
QualType getToType(unsigned Idx) const
SourceLocation getBegin() const
llvm::SmallPtrSet< DeclContext *, 16 > AssociatedNamespaceSet
Requests that all candidates be shown.
const T * castAs() const
Member-template castAs<specific 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.
bool isArrow() const
Determine whether this member expression used the '->' operator; otherwise, it used the '...
bool isVectorType() const
unsigned HasDiagnostic
Indicates whether a diagnostic is stored in Diagnostic.
bool IsBuildingRecoveryCallExpr
Flag indicating if Sema is building a recovery call expression.
bool isPromotableIntegerType() const
More type predicates useful for type checking/promotion.
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...
Complex-real conversions (C99 6.3.1.7)
An rvalue ref-qualifier was provided (&&).
Assigning into this object requires a lifetime extension.
SourceLocation getLocStart() const LLVM_READONLY
bool isVolatileQualified() const
Determine whether this type is volatile-qualified.
OverloadCandidateSet - A set of overload candidates, used in C++ overload resolution (C++ 13...
void setBad(BadConversionSequence::FailureKind Failure, Expr *FromExpr, QualType ToType)
Sets this sequence as a bad conversion for an explicit argument.
MutableArrayRef< Expr * > MultiExprArg
ExprResult BuildCallToObjectOfClassType(Scope *S, Expr *Object, SourceLocation LParenLoc, MultiExprArg Args, SourceLocation RParenLoc)
BuildCallToObjectOfClassType - Build a call to an object of class type (C++ [over.call.object]), which can end up invoking an overloaded function call operator (operator()) or performing a user-defined conversion on the object argument.
static MemberExpr * Create(const ASTContext &C, Expr *base, bool isarrow, SourceLocation OperatorLoc, NestedNameSpecifierLoc QualifierLoc, SourceLocation TemplateKWLoc, ValueDecl *memberdecl, DeclAccessPair founddecl, DeclarationNameInfo MemberNameInfo, const TemplateArgumentListInfo *targs, QualType ty, ExprValueKind VK, ExprObjectKind OK)
SourceLocation getExprLoc() const LLVM_READONLY
getExprLoc - Return the preferred location for the arrow when diagnosing a problem with a generic exp...
QualType getPointeeType() const
CXXSpecialMember getSpecialMember(const CXXMethodDecl *MD)
getSpecialMember - get the special member enum for a method.
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...
CompoundAssignOperator - For compound assignments (e.g.
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)
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
void MarkMemberReferenced(MemberExpr *E)
Perform reference-marking and odr-use handling for a MemberExpr.
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)
void DiagnoseAmbiguousConversion(Sema &S, SourceLocation CaretLoc, const PartialDiagnostic &PDiag) const
Diagnoses an ambiguous conversion.
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 ...
QualType getAsType() const
Retrieve the type for a type template argument.
DeclContextLookupResult LookupConstructors(CXXRecordDecl *Class)
Look up the constructors for the given class.
FunctionTemplateDecl * getPrimaryTemplate() const
Retrieve the primary template that this function template specialization either specializes or was in...
llvm::PointerUnion3< TemplateTypeParmDecl *, NonTypeTemplateParmDecl *, TemplateTemplateParmDecl * > TemplateParameter
Stores a template parameter of any kind.
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...
StringRef getOpcodeStr() const
A qualifier set is used to build a set of qualifiers.
Qualifiers withoutObjCLifetime() const
DeclContext - This is used only as base class of specific decl types that can act as declaration cont...
bool isAggregateType() const
Determines whether the type is a C++ aggregate type or C aggregate or union type. ...
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.).
Sema::LookupNameKind getLookupKind() const
Gets the kind of lookup to perform.
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.
const internal::VariadicAllOfMatcher< Type > type
Matches Types in the clang AST.
ExprResult ImpCastExprToType(Expr *E, QualType Type, CastKind CK, ExprValueKind VK=VK_RValue, const CXXCastPath *BasePath=nullptr, CheckedConversionKind CCK=CCK_ImplicitConversion)
ImpCastExprToType - If Expr is not of type 'Type', insert an implicit cast.
ConversionSet::const_iterator const_iterator
static bool hasSimilarType(ASTContext &Context, QualType T1, QualType T2)
bool isInvalidDecl() const
virtual SemaDiagnosticBuilder diagnoseNoMatch(Sema &S, SourceLocation Loc, QualType T)=0
Emits a diagnostic complaining that the expression does not have integral or enumeration type...
void HandleFunctionTypeMismatch(PartialDiagnostic &PDiag, QualType FromType, QualType ToType)
HandleFunctionTypeMismatch - Gives diagnostic information for differeing function types...
SourceLocation getLocStart() const LLVM_READONLY
CanQualType UnsignedLongLongTy
static void DiagnoseArityMismatch(Sema &S, Decl *D, unsigned NumFormalArgs)
General arity mismatch diagnosis over a candidate in a candidate set.
static bool checkPlaceholderForOverload(Sema &S, Expr *&E, UnbridgedCastsSet *unbridgedCasts=nullptr)
checkPlaceholderForOverload - Do any interesting placeholder-like preprocessing on the given expressi...
Conversions allowed in C, but not C++.
Array-to-pointer conversion (C++ 4.2)
void setConversionChecker(TypeComparisonFuncTy Foo)
Resets the default conversion checker method.
A non-depnedent component of the parameter did not match the corresponding component of the argument...
const ObjCInterfaceType * getInterfaceType() const
If this pointer points to an Objective C @interface type, gets the type for that interface.
PartialDiagnosticAt * getSFINAEDiagnostic()
Retrieve the diagnostic which caused this deduction failure, if any.
QualType getPointerType(QualType T) const
Return the uniqued reference to the type for a pointer to the specified type.
bool hasSFINAEDiagnostic() const
Is a SFINAE diagnostic available?
DeclarationName - The name of a declaration.
bool IsBlockPointerConversion(QualType FromType, QualType ToType, QualType &ConvertedType)
StandardConversionSequence Before
Represents the standard conversion that occurs before the actual user-defined conversion.
const Type * strip(QualType type)
Collect any qualifiers on the given type and return an unqualified type.
QualType getObjCObjectPointerType(QualType OIT) const
Return a ObjCObjectPointerType type for the given ObjCObjectType.
OverloadExpr * Expression
bool isLValue() const
isLValue - True if this expression is an "l-value" according to the rules of the current language...
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...
param_type_iterator param_type_end() const
A set of unresolved declarations.
std::string getAsString(ASTContext &Ctx, QualType Ty) const
void setInstantiationDependent(bool ID)
Set whether this expression is instantiation-dependent or not.
SourceLocation getLocStart() const LLVM_READONLY
Requests that only viable candidates be shown.
CK_BlockPointerToObjCPointerCast - Casting a block pointer to an ObjC pointer.
detail::InMemoryDirectory::const_iterator E
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...
const FunctionType * adjustFunctionType(const FunctionType *Fn, FunctionType::ExtInfo EInfo)
Change the ExtInfo on a function type.
CanQualType getCanonicalType(QualType T) const
Return the canonical (structural) type corresponding to the specified potentially non-canonical type ...
bool isLValueReferenceType() const
DeclarationNameInfo - A collector data type for bundling together a DeclarationName and the correspnd...
unsigned getNumParams() const
bool isLambda() const
Determine whether this class describes a lambda function object.
void * Data
Opaque pointer containing additional data about this deduction failure.
bool isPointerConversionToBool() const
isPointerConversionToBool - Determines whether this conversion is a conversion of a pointer or pointe...
param_iterator param_end()
Defines the Diagnostic-related interfaces.
bool isRValueReferenceType() const
static void NoteSurrogateCandidate(Sema &S, OverloadCandidate *Cand)
QualType getPointeeType() const
Gets the type pointed to by this ObjC pointer.
QualType getNonReferenceType() const
If Type is a reference type (e.g., const int&), returns the type that the reference refers to ("const...
FunctionDecl * ConversionFunction
ConversionFunction - The function that will perform the user-defined conversion.
Represents a pointer to an Objective C object.
SourceLocation getMemberLoc() const
getMemberLoc - Return the location of the "member", in X->F, it is the location of 'F'...
Conversion only allowed in the C standard.
bool empty() const
Return true if no decls were found.
Not an overloaded operator.
QualType getLocalUnqualifiedType() const
Return this type with all of the instance-specific qualifiers removed, but without removing any quali...
ExprResult CreateOverloadedArraySubscriptExpr(SourceLocation LLoc, SourceLocation RLoc, Expr *Base, Expr *Idx)
void setHadMultipleCandidates(bool V=true)
Sets the flag telling whether this expression refers to a method that was resolved from an overloaded...
bool IsPointerConversion(Expr *From, QualType FromType, QualType ToType, bool InOverloadResolution, QualType &ConvertedType, bool &IncompatibleObjC)
IsPointerConversion - Determines whether the conversion of the expression From, which has the (possib...
A helper class that allows the use of isa/cast/dyncast to detect TagType objects of structs/unions/cl...
void setAllToTypes(QualType T)
Complex values, per C99 6.2.5p11.
QualType getPointerDiffType() const
Return the unique type for "ptrdiff_t" (C99 7.17) defined in <stddef.h>.
Expr * getUninstantiatedDefaultArg()
const T * getAs() const
Member-template getAs<specific type>'.
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...
PrintingPolicy getPrintingPolicy() const
Retrieve a suitable printing policy.
CUDAFunctionPreference IdentifyCUDAPreference(const FunctionDecl *Caller, const FunctionDecl *Callee)
Identifies relative preference of a given Caller/Callee combination, based on their host/device attri...
bool ConvertArgumentsForCall(CallExpr *Call, Expr *Fn, FunctionDecl *FDecl, const FunctionProtoType *Proto, ArrayRef< Expr * > Args, SourceLocation RParenLoc, bool ExecConfig=false)
ConvertArgumentsForCall - Converts the arguments specified in Args/NumArgs to the parameter types of ...
unsigned getTypeQuals() const
QualType getCanonicalType() const
TemplateArgumentList * take()
Take ownership of the deduced template argument list.
CanQualType UnsignedLongTy
unsigned getKindRank() const
Return a ranking of the implicit conversion sequence kind, where smaller ranks represent better conve...
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 an value reference-compatible with DeclType.
bool isObjCQualifiedIdType() const
bool isFunctionType() const
NestedNameSpecifier * getQualifier() const
DeclAccessPair FoundDecl
FoundDecl - The original declaration that was looked up / invented / otherwise found, together with its access.
bool isImplicitlyDeleted(FunctionDecl *FD)
Determine whether the given function is an implicitly-deleted special member function.
Base for LValueReferenceType and RValueReferenceType.
CanQualType BoundMemberTy
const DeclarationNameLoc & getInfo() const
CXXRecordDecl * getAsCXXRecordDecl() const
Retrieves the CXXRecordDecl that this type refers to, either because the type is a RecordType or beca...
AccessResult CheckMemberOperatorAccess(SourceLocation Loc, Expr *ObjectExpr, Expr *ArgExpr, DeclAccessPair FoundDecl)
Checks access to an overloaded member operator, including conversion operators.
unsigned getAddressSpace() const
FriendObjectKind getFriendObjectKind() const
Determines whether this declaration is the object of a friend declaration and, if so...
ExprResult CreateBuiltinUnaryOp(SourceLocation OpLoc, UnaryOperatorKind Opc, Expr *InputExpr)
TemplateSpecCandidate - This is a generalization of OverloadCandidate which keeps track of template a...
bool isRestrictQualified() const
Determine whether this type is restrict-qualified.
Block Pointer conversions.
Deduction failed; that's all we know.
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...
APValue - This class implements a discriminated union of [uninitialized] [APSInt] [APFloat]...
static bool tryAtomicConversion(Sema &S, Expr *From, QualType ToType, bool InOverloadResolution, StandardConversionSequence &SCS, bool CStyle)
Determine whether this is a conversion from a scalar type to an atomic type.
const CXXConstructorDecl * getInheritedConstructor() const
Get the constructor that this inheriting constructor is based on.
static bool isNonTrivialObjCLifetimeConversion(Qualifiers FromQuals, Qualifiers ToQuals)
Determine whether the lifetime conversion between the two given qualifiers sets is nontrivial...
void DiagnoseSentinelCalls(NamedDecl *D, SourceLocation Loc, ArrayRef< Expr * > Args)
DiagnoseSentinelCalls - This routine checks whether a call or message-send is to a declaration with t...
QualType getPointeeType() const
std::string getQualifiedNameAsString() 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.
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.
X
Add a minimal nested name specifier fixit hint to allow lookup of a tag name from an outer enclosing ...
const Type * getClass() const
Reading or writing from this object requires a barrier call.
CCEKind
Contexts in which a converted constant expression is required.
ExprResult DefaultVariadicArgumentPromotion(Expr *E, VariadicCallType CT, FunctionDecl *FDecl)
DefaultVariadicArgumentPromotion - Like DefaultArgumentPromotion, but will create a trap if the resul...
bool typesAreCompatible(QualType T1, QualType T2, bool CompareUnqualified=false)
Compatibility predicates used to check assignment expressions.
bool FunctionParamTypesAreEqual(const FunctionProtoType *OldType, const FunctionProtoType *NewType, unsigned *ArgPos=nullptr)
FunctionParamTypesAreEqual - This routine checks two function proto types for equality of their argum...
Function-to-pointer (C++ 4.3)
MemberExpr - [C99 6.5.2.3] Structure and Union Members.
bool isObjCClassType() const
True if this is equivalent to the 'Class' type, i.e.
void AddOverloadCandidate(FunctionDecl *Function, DeclAccessPair FoundDecl, ArrayRef< Expr * > Args, OverloadCandidateSet &CandidateSet, bool SuppressUserConversions=false, bool PartialOverloading=false, bool AllowExplicit=false)
AddOverloadCandidate - Adds the given function to the set of candidate functions, using the given fun...
QualType getUnqualifiedType() const
Retrieve the unqualified variant of the given type, removing as little sugar as possible.
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.
bool isObjCObjectPointerType() const
The template argument is a template name that was provided for a template template parameter...
Optional< sema::TemplateDeductionInfo * > isSFINAEContext() const
Determines whether we are currently in a context where template argument substitution failures are no...
llvm::iterator_range< specific_attr_iterator< T > > specific_attrs() const
OverloadsShown
Specifies which overload candidates to display when overload resolution fails.
OverloadsShown getShowOverloads() const
bool isLaxVectorConversion(QualType srcType, QualType destType)
Is this a legal conversion between two types, one of which is known to be a vector 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...
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 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'.
TemplateParameterList * getTemplateParameters() const
Get the list of template parameters.
static void DiagnoseBadTarget(Sema &S, OverloadCandidate *Cand)
CUDA: diagnose an invalid call across targets.
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...
A little helper class (which is basically a smart pointer that forwards info from DiagnosticsEngine) ...
OverloadingResult BestViableFunction(Sema &S, SourceLocation Loc, OverloadCandidateSet::iterator &Best, bool UserDefinedConversion=false)
Find the best viable function on this overload set, if it exists.
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]).
DeclarationName getName() const
Gets the name looked up.
bool isUserDefined() const
SourceRange getSourceRange() const override LLVM_READONLY
Source range that this declaration covers.
static Qualifiers fromCVRMask(unsigned CVR)
ExprResult PerformObjectMemberConversion(Expr *From, NestedNameSpecifier *Qualifier, NamedDecl *FoundDecl, NamedDecl *Member)
Cast a base object to a member's actual type.
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...
void DiagnoseSelfMove(const Expr *LHSExpr, const Expr *RHSExpr, SourceLocation OpLoc)
Warn if a value is moved to itself.
CK_NoOp - A conversion which does not affect the type other than (possibly) adding qualifiers...
A reference to a declared variable, function, enum, etc.
ExprValueKind getValueKind() const
getValueKind - The value kind that this expression produces.
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...
The current expression and its subexpressions occur within an unevaluated operand (C++11 [expr]p7)...
QualType getElementType() const
bool hasQualifiers() const
Determine whether this type has any qualifiers.
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...
void clear()
Clear out all of the candidates.
ImplicitConversionKind First
First – The first conversion can be an lvalue-to-rvalue conversion, array-to-pointer conversion...
const Expr * getInit(unsigned Init) const
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)
AccessResult CheckAddressOfMemberAccess(Expr *OvlExpr, DeclAccessPair FoundDecl)
An l-value expression is a reference to an object with independent storage.
const llvm::fltSemantics & getFloatTypeSemantics(QualType T) const
Return the APFloat 'semantics' for the specified scalar floating point type.
A trivial tuple used to represent a source range.
SourceLocation getLocation() const
static StringRef getOpcodeStr(Opcode Op)
getOpcodeStr - Turn an Opcode enum value into the punctuation char it corresponds to...
FunctionDecl * getCanonicalDecl() override
Retrieves the "canonical" declaration of the given declaration.
NamedDecl - This represents a decl with a name.
NestedNameSpecifier * getQualifier() const
Fetches the nested-name qualifier, if one was given.
bool CheckCallReturnType(QualType ReturnType, SourceLocation Loc, CallExpr *CE, FunctionDecl *FD)
CheckCallReturnType - Checks that a call expression's return type is complete.
bool isArithmeticType() const
bool CheckCXXThisCapture(SourceLocation Loc, bool Explicit=false, bool BuildAndDiagnose=true, const unsigned *const FunctionScopeIndexToStopAt=nullptr)
Make sure the value of 'this' is actually available in the current context, if it is a potentially ev...
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...
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.
bool isConstQualified() const
Determine whether this type is const-qualified.
Pointer-to-member conversions (C++ 4.11)
bool EvaluateAsLValue(EvalResult &Result, const ASTContext &Ctx) const
EvaluateAsLValue - Evaluate an expression to see if we can fold it to an lvalue with link time known ...
bool isNull() const
Return true if this QualType doesn't point to a type yet.
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 InitializedEntity InitializeParameter(ASTContext &Context, ParmVarDecl *Parm)
Create the initialization entity for a parameter.
void setToType(unsigned Idx, QualType T)
bool isObjCIdType() const
True if this is equivalent to the 'id' type, i.e.
NamespaceDecl * getStdNamespace() const
char Diagnostic[sizeof(PartialDiagnosticAt)]
void removeAddressSpace()
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...
bool isPointerConversionToVoidPointer(ASTContext &Context) const
isPointerConversionToVoidPointer - Determines whether this conversion is a conversion of a pointer to...
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 ...
bool isIntegralType(ASTContext &Ctx) const
Determine whether this type is an integral type.
Declaration of a template function.
void clear()
Clears out any current state.
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.
A single template declaration.
bool isIntegerType() const
isIntegerType() does not include complex integers (a GCC extension).
SourceLocation getLocation() const
Expr * IgnoreParens() LLVM_READONLY
IgnoreParens - Ignore parentheses.
CanQualType UnsignedIntTy
DeclAccessPair getFoundDecl() const
Retrieves the declaration found by lookup.
void Profile(llvm::FoldingSetNodeID &ID) const
Qualifiers getQualifiers() const
Retrieve the set of qualifiers applied to this type.
bool isPointerType() const
unsigned NumConversionsFixed
The number of Conversions fixed.
StandardConversionSequence - represents a standard conversion sequence (C++ 13.3.3.1.1).
CK_FloatingToBoolean - Floating point to boolean.
bool isIncompleteOrObjectType() const
Return true if this is an incomplete or object type, in other words, not a function type...
SourceLocation getLocStart() const LLVM_READONLY
static void DiagnoseFailedEnableIfAttr(Sema &S, OverloadCandidate *Cand)