31 #include "llvm/ADT/DenseSet.h"
32 #include "llvm/ADT/Optional.h"
33 #include "llvm/ADT/STLExtras.h"
34 #include "llvm/ADT/SmallPtrSet.h"
35 #include "llvm/ADT/SmallString.h"
39 using namespace clang;
44 return P->hasAttr<PassObjectSizeAttr>();
51 const Expr *
Base,
bool HadMultipleCandidates,
68 if (HadMultipleCandidates)
73 CK_FunctionToPointerDecay);
77 bool InOverloadResolution,
80 bool AllowObjCWritebackConversion);
84 bool InOverloadResolution,
92 bool AllowObjCConversionOnExplicit);
145 return Rank[(int)Kind];
155 "Function-to-pointer",
156 "Function pointer conversion",
158 "Integral promotion",
159 "Floating point promotion",
161 "Integral conversion",
162 "Floating conversion",
163 "Complex conversion",
164 "Floating-integral conversion",
165 "Pointer conversion",
166 "Pointer-to-member conversion",
167 "Boolean conversion",
168 "Compatible-types conversion",
169 "Derived-to-base conversion",
172 "Complex-real conversion",
173 "Block Pointer conversion",
174 "Transparent Union Conversion",
175 "Writeback conversion",
176 "OpenCL Zero Event Conversion",
177 "C specific type conversion",
178 "Incompatible pointer conversion"
189 DeprecatedStringLiteralToCharPtr =
false;
190 QualificationIncludesObjCLifetime =
false;
191 ReferenceBinding =
false;
192 DirectBinding =
false;
193 IsLvalueReference =
true;
194 BindsToFunctionLvalue =
false;
195 BindsToRvalue =
false;
196 BindsImplicitObjectArgumentWithoutRefQualifier =
false;
197 ObjCLifetimeConversionBinding =
false;
198 CopyConstructor =
nullptr;
225 (getFromType()->isPointerType() ||
226 getFromType()->isObjCObjectPointerType() ||
227 getFromType()->isBlockPointerType() ||
228 getFromType()->isNullPtrType() ||
261 while (
const ImplicitCastExpr *ICE = dyn_cast<ImplicitCastExpr>(Converted)) {
262 switch (ICE->getCastKind()) {
264 case CK_IntegralCast:
265 case CK_IntegralToBoolean:
266 case CK_IntegralToFloating:
267 case CK_BooleanToSignedIntegral:
268 case CK_FloatingToIntegral:
269 case CK_FloatingToBoolean:
270 case CK_FloatingCast:
271 Converted = ICE->getSubExpr();
293 const Expr *Converted,
296 assert(Ctx.
getLangOpts().CPlusPlus &&
"narrowing check outside C++");
307 ToType = ET->getDecl()->getIntegerType();
312 if (FromType->isRealFloatingType())
313 goto FloatingIntegralConversion;
314 if (FromType->isIntegralOrUnscopedEnumerationType())
315 goto IntegralConversion;
327 FloatingIntegralConversion:
328 if (FromType->isRealFloatingType() && ToType->
isIntegralType(Ctx)) {
331 llvm::APSInt IntConstantValue;
333 assert(Initializer &&
"Unknown conversion expression");
342 Result.convertFromAPInt(IntConstantValue, IntConstantValue.isSigned(),
343 llvm::APFloat::rmNearestTiesToEven);
345 llvm::APSInt ConvertedValue = IntConstantValue;
347 Result.convertToInteger(ConvertedValue,
348 llvm::APFloat::rmTowardZero, &ignored);
350 if (IntConstantValue != ConvertedValue) {
351 ConstantValue =
APValue(IntConstantValue);
352 ConstantType = Initializer->
getType();
378 assert(ConstantValue.
isFloat());
379 llvm::APFloat FloatVal = ConstantValue.
getFloat();
382 llvm::APFloat::opStatus ConvertStatus = FloatVal.convert(
384 llvm::APFloat::rmNearestTiesToEven, &ignored);
387 if (ConvertStatus & llvm::APFloat::opOverflow) {
388 ConstantType = Initializer->
getType();
403 IntegralConversion: {
404 assert(FromType->isIntegralOrUnscopedEnumerationType());
406 const bool FromSigned = FromType->isSignedIntegerOrEnumerationType();
407 const unsigned FromWidth = Ctx.
getIntWidth(FromType);
411 if (FromWidth > ToWidth ||
412 (FromWidth == ToWidth && FromSigned != ToSigned) ||
413 (FromSigned && !ToSigned)) {
415 llvm::APSInt InitializerValue;
426 bool Narrowing =
false;
427 if (FromWidth < ToWidth) {
430 if (InitializerValue.isSigned() && InitializerValue.isNegative())
435 InitializerValue = InitializerValue.extend(
436 InitializerValue.getBitWidth() + 1);
438 llvm::APSInt ConvertedValue = InitializerValue;
439 ConvertedValue = ConvertedValue.trunc(ToWidth);
440 ConvertedValue.setIsSigned(ToSigned);
441 ConvertedValue = ConvertedValue.extend(InitializerValue.getBitWidth());
442 ConvertedValue.setIsSigned(InitializerValue.isSigned());
444 if (ConvertedValue != InitializerValue)
448 ConstantType = Initializer->
getType();
449 ConstantValue =
APValue(InitializerValue);
465 raw_ostream &OS = llvm::errs();
466 bool PrintedSomething =
false;
469 PrintedSomething =
true;
473 if (PrintedSomething) {
478 if (CopyConstructor) {
479 OS <<
" (by copy constructor)";
480 }
else if (DirectBinding) {
481 OS <<
" (direct reference binding)";
482 }
else if (ReferenceBinding) {
483 OS <<
" (reference binding)";
485 PrintedSomething =
true;
489 if (PrintedSomething) {
493 PrintedSomething =
true;
496 if (!PrintedSomething) {
497 OS <<
"No conversions required";
504 raw_ostream &OS = llvm::errs();
505 if (Before.First || Before.Second || Before.Third) {
509 if (ConversionFunction)
510 OS <<
'\'' << *ConversionFunction <<
'\'';
512 OS <<
"aggregate initialization";
522 raw_ostream &OS = llvm::errs();
523 if (isStdInitializerListElement())
524 OS <<
"Worst std::initializer_list element conversion: ";
525 switch (ConversionKind) {
526 case StandardConversion:
527 OS <<
"Standard conversion: ";
530 case UserDefinedConversion:
531 OS <<
"User-defined conversion: ";
534 case EllipsisConversion:
535 OS <<
"Ellipsis conversion";
537 case AmbiguousConversion:
538 OS <<
"Ambiguous conversion";
541 OS <<
"Bad conversion";
553 conversions().~ConversionSet();
566 struct DFIArguments {
572 struct DFIParamWithArguments : DFIArguments {
577 struct DFIDeducedMismatchArgs : DFIArguments {
579 unsigned CallArgIndex;
590 Result.
Result =
static_cast<unsigned>(TDK);
599 Result.
Data =
nullptr;
604 Result.
Data = Info.
Param.getOpaqueValue();
610 auto *Saved =
new (
Context) DFIDeducedMismatchArgs;
613 Saved->TemplateArgs = Info.
take();
621 DFIArguments *Saved =
new (
Context) DFIArguments;
631 DFIParamWithArguments *Saved =
new (
Context) DFIParamWithArguments;
632 Saved->Param = Info.
Param;
651 llvm_unreachable(
"not a deduction failure");
658 switch (static_cast<Sema::TemplateDeductionResult>(
Result)) {
683 Diag->~PartialDiagnosticAt();
684 HasDiagnostic =
false;
701 switch (static_cast<Sema::TemplateDeductionResult>(
Result)) {
717 return TemplateParameter::getFromOpaqueValue(Data);
721 return static_cast<DFIParamWithArguments*
>(Data)->Param;
732 switch (static_cast<Sema::TemplateDeductionResult>(
Result)) {
749 return static_cast<DFIDeducedMismatchArgs*
>(Data)->TemplateArgs;
763 switch (static_cast<Sema::TemplateDeductionResult>(
Result)) {
781 return &
static_cast<DFIArguments*
>(Data)->FirstArg;
792 switch (static_cast<Sema::TemplateDeductionResult>(
Result)) {
810 return &
static_cast<DFIArguments*
>(Data)->SecondArg;
821 switch (static_cast<Sema::TemplateDeductionResult>(
Result)) {
824 return static_cast<DFIDeducedMismatchArgs*
>(Data)->CallArgIndex;
831 void OverloadCandidateSet::destroyCandidates() {
832 for (iterator i = begin(), e = end(); i != e; ++i) {
833 for (
auto &C : i->Conversions)
834 C.~ImplicitConversionSequence();
836 i->DeductionFailure.Destroy();
842 SlabAllocator.Reset();
843 NumInlineBytesUsed = 0;
849 class UnbridgedCastsSet {
859 Entry entry = { &
E, E };
860 Entries.push_back(entry);
866 i = Entries.begin(), e = Entries.end(); i != e; ++i)
881 UnbridgedCastsSet *unbridgedCasts =
nullptr) {
885 if (placeholder->getKind() == BuiltinType::Overload)
return false;
889 if (placeholder->getKind() == BuiltinType::ARCUnbridgedCast &&
891 unbridgedCasts->save(S, E);
912 UnbridgedCastsSet &unbridged) {
913 for (
unsigned i = 0, e = Args.size(); i != e; ++i)
955 NamedDecl *&Match,
bool NewIsUsingDecl) {
960 bool OldIsUsingDecl =
false;
961 if (isa<UsingShadowDecl>(OldD)) {
962 OldIsUsingDecl =
true;
966 if (NewIsUsingDecl)
continue;
968 OldD = cast<UsingShadowDecl>(OldD)->getTargetDecl();
973 if ((OldIsUsingDecl || NewIsUsingDecl) && !isVisible(*
I))
981 bool UseMemberUsingDeclRules =
982 (OldIsUsingDecl || NewIsUsingDecl) && CurContext->isRecord() &&
986 if (!IsOverload(New, OldF, UseMemberUsingDeclRules)) {
987 if (UseMemberUsingDeclRules && OldIsUsingDecl) {
988 HideUsingShadowDecl(S, cast<UsingShadowDecl>(*
I));
992 if (!isa<FunctionTemplateDecl>(OldD) &&
993 !shouldLinkPossiblyHiddenDecl(*
I, New))
999 }
else if (isa<UsingDecl>(OldD) || isa<UsingPackDecl>(OldD)) {
1003 }
else if (isa<TagDecl>(OldD)) {
1005 }
else if (
auto *UUD = dyn_cast<UnresolvedUsingValueDecl>(OldD)) {
1012 if (UUD->getQualifier()->isDependent() && !UUD->isCXXClassMember()) {
1014 return Ovl_NonFunction;
1021 return Ovl_NonFunction;
1025 return Ovl_Overload;
1029 bool UseMemberUsingDeclRules,
bool ConsiderCudaAttrs) {
1044 if ((OldTemplate ==
nullptr) != (NewTemplate ==
nullptr))
1057 if (isa<FunctionNoProtoType>(OldQType.
getTypePtr()) ||
1058 isa<FunctionNoProtoType>(NewQType.
getTypePtr()))
1067 if (OldQType != NewQType &&
1069 OldType->
isVariadic() != NewType->isVariadic() ||
1070 !FunctionParamTypesAreEqual(OldType, NewType)))
1085 if (!UseMemberUsingDeclRules && NewTemplate &&
1088 false, TPL_TemplateMatch) ||
1102 if (OldMethod && NewMethod &&
1103 !OldMethod->
isStatic() && !NewMethod->isStatic()) {
1105 if (!UseMemberUsingDeclRules &&
1107 NewMethod->getRefQualifier() ==
RQ_None)) {
1114 Diag(NewMethod->getLocation(), diag::err_ref_qualifier_overload)
1126 unsigned NewQuals = NewMethod->getTypeQualifiers();
1127 if (!getLangOpts().
CPlusPlus14 && NewMethod->isConstexpr() &&
1128 !isa<CXXConstructorDecl>(NewMethod))
1134 if (OldQuals != NewQuals)
1152 NewI != NewE || OldI != OldE; ++NewI, ++OldI) {
1153 if (NewI == NewE || OldI == OldE)
1155 llvm::FoldingSetNodeID NewID, OldID;
1157 OldI->getCond()->Profile(OldID,
Context,
true);
1162 if (getLangOpts().CUDA && ConsiderCudaAttrs) {
1165 if (isa<CXXDestructorDecl>(New))
1169 OldTarget = IdentifyCUDATarget(Old);
1170 if (NewTarget == CFT_InvalidTarget)
1173 assert((OldTarget != CFT_InvalidTarget) &&
"Unexpected invalid target.");
1177 return NewTarget != OldTarget;
1194 Decl *C = cast<Decl>(CurContext);
1208 bool SuppressUserConversions,
1210 bool InOverloadResolution,
1212 bool AllowObjCWritebackConversion,
1213 bool AllowObjCConversionOnExplicit) {
1216 if (SuppressUserConversions) {
1227 Conversions, AllowExplicit,
1228 AllowObjCConversionOnExplicit)) {
1245 if (Constructor->isCopyConstructor() &&
1246 (FromCanon == ToCanon ||
1257 if (ToCanon != FromCanon)
1268 Cand != Conversions.end(); ++Cand)
1311 bool SuppressUserConversions,
1313 bool InOverloadResolution,
1315 bool AllowObjCWritebackConversion,
1316 bool AllowObjCConversionOnExplicit) {
1319 ICS.
Standard, CStyle, AllowObjCWritebackConversion)){
1359 AllowExplicit, InOverloadResolution, CStyle,
1360 AllowObjCWritebackConversion,
1361 AllowObjCConversionOnExplicit);
1366 bool SuppressUserConversions,
1368 bool InOverloadResolution,
1370 bool AllowObjCWritebackConversion) {
1372 SuppressUserConversions, AllowExplicit,
1373 InOverloadResolution, CStyle,
1374 AllowObjCWritebackConversion,
1387 return PerformImplicitConversion(From, ToType, Action, AllowExplicit, ICS);
1398 bool AllowObjCWritebackConversion
1399 = getLangOpts().ObjCAutoRefCount &&
1400 (Action == AA_Passing || Action == AA_Sending);
1401 if (getLangOpts().ObjC1)
1402 CheckObjCBridgeRelatedConversions(From->
getLocStart(),
1403 ToType, From->
getType(), From);
1409 AllowObjCWritebackConversion,
1411 return PerformImplicitConversion(From, ToType, ICS, Action);
1432 if (TyClass != CanFrom->getTypeClass())
return false;
1433 if (TyClass != Type::FunctionProto && TyClass != Type::FunctionNoProto) {
1434 if (TyClass == Type::Pointer) {
1437 }
else if (TyClass == Type::BlockPointer) {
1440 }
else if (TyClass == Type::MemberPointer) {
1444 if (ToMPT->getClass() != FromMPT->
getClass())
1446 CanTo = ToMPT->getPointeeType();
1452 TyClass = CanTo->getTypeClass();
1453 if (TyClass != CanFrom->getTypeClass())
return false;
1454 if (TyClass != Type::FunctionProto && TyClass != Type::FunctionNoProto)
1458 const auto *FromFn = cast<FunctionType>(CanFrom);
1461 const auto *ToFn = cast<FunctionType>(CanTo);
1464 bool Changed =
false;
1467 if (FromEInfo.getNoReturn() && !ToEInfo.getNoReturn()) {
1473 if (
const auto *FromFPT = dyn_cast<FunctionProtoType>(FromFn)) {
1474 const auto *ToFPT = cast<FunctionProtoType>(ToFn);
1476 FromFn = cast<FunctionType>(
1478 FromFPT->getParamTypes(),
1479 FromFPT->getExtProtoInfo().withExceptionSpec(
1489 assert(
QualType(FromFn, 0).isCanonical());
1490 if (
QualType(FromFn, 0) != CanTo)
return false;
1542 bool InOverloadResolution,
1555 bool InOverloadResolution,
1558 bool AllowObjCWritebackConversion) {
1605 if (Method && !Method->
isStatic()) {
1607 "Non-unary operator on non-static member address");
1610 "Non-address-of operator on non-static member address");
1611 const Type *ClassType
1617 "Non-address-of operator for overloaded function expression");
1644 FromType = Atomic->getValueType();
1679 if (
auto *FD = dyn_cast<FunctionDecl>(DRE->getDecl()))
1699 bool IncompatibleObjC =
false;
1750 if (Float128AndLongDouble &&
1752 &llvm::APFloat::IEEEdouble()))
1767 }
else if (AllowObjCWritebackConversion &&
1771 FromType, IncompatibleObjC)) {
1777 InOverloadResolution, FromType)) {
1789 InOverloadResolution,
1816 bool ObjCLifetimeConversion;
1822 ObjCLifetimeConversion)) {
1841 CanonFrom = CanonTo;
1846 if (CanonFrom == CanonTo)
1851 if (S.
getLangOpts().CPlusPlus || !InOverloadResolution)
1895 bool InOverloadResolution,
1905 for (
const auto *it : UD->
fields()) {
1908 ToType = it->getType();
1938 return To->
getKind() == BuiltinType::Int;
1941 return To->
getKind() == BuiltinType::UInt;
1965 if (FromEnumType->getDecl()->isScoped())
1972 if (FromEnumType->getDecl()->isFixed()) {
1973 QualType Underlying = FromEnumType->getDecl()->getIntegerType();
1975 IsIntegralPromotion(
nullptr, Underlying, ToType);
1982 ToType, FromEnumType->getDecl()->getPromotionType());
2008 for (
int Idx = 0; Idx < 6; ++Idx) {
2010 if (FromSize < ToSize ||
2011 (FromSize == ToSize &&
2012 FromIsSigned == PromoteTypes[Idx]->isSignedIntegerType())) {
2032 llvm::APSInt BitWidth;
2034 MemberDecl->getBitWidth()->isIntegerConstantExpr(BitWidth,
Context)) {
2035 llvm::APSInt ToSize(BitWidth.getBitWidth(), BitWidth.isUnsigned());
2039 if (BitWidth < ToSize ||
2041 return To->
getKind() == BuiltinType::Int;
2047 return To->
getKind() == BuiltinType::UInt;
2072 if (FromBuiltin->getKind() == BuiltinType::Float &&
2073 ToBuiltin->getKind() == BuiltinType::Double)
2079 if (!getLangOpts().CPlusPlus &&
2080 (FromBuiltin->getKind() == BuiltinType::Float ||
2081 FromBuiltin->getKind() == BuiltinType::Double) &&
2082 (ToBuiltin->getKind() == BuiltinType::LongDouble ||
2083 ToBuiltin->getKind() == BuiltinType::Float128))
2087 if (!getLangOpts().NativeHalfType &&
2088 FromBuiltin->getKind() == BuiltinType::Half &&
2089 ToBuiltin->getKind() == BuiltinType::Float)
2126 bool StripObjCLifetime =
false) {
2129 "Invalid similarly-qualified pointer type");
2140 if (StripObjCLifetime)
2151 if (isa<ObjCObjectPointerType>(ToType))
2160 if (isa<ObjCObjectPointerType>(ToType))
2166 bool InOverloadResolution,
2172 return !InOverloadResolution;
2196 bool InOverloadResolution,
2198 bool &IncompatibleObjC) {
2199 IncompatibleObjC =
false;
2200 if (isObjCPointerConversion(FromType, ToType, ConvertedType,
2207 ConvertedType = ToType;
2214 ConvertedType = ToType;
2221 ConvertedType = ToType;
2229 ConvertedType = ToType;
2239 ConvertedType = ToType;
2247 !getLangOpts().ObjCAutoRefCount) {
2278 if (getLangOpts().MSVCCompat && FromPointeeType->
isFunctionType() &&
2312 IsDerivedFrom(From->
getLocStart(), FromPointeeType, ToPointeeType)) {
2349 bool &IncompatibleObjC) {
2350 if (!getLangOpts().ObjC1)
2362 if (ToObjCPtr && FromObjCPtr) {
2373 if (getLangOpts().
CPlusPlus && LHS && RHS &&
2375 FromObjCPtr->getPointeeType()))
2388 IncompatibleObjC =
true;
2404 if (FromObjCPtr && FromObjCPtr->isObjCBuiltinType()) {
2432 isObjCPointerConversion(FromPointeeType, ToPointeeType, ConvertedType,
2433 IncompatibleObjC)) {
2435 IncompatibleObjC =
true;
2444 isObjCPointerConversion(FromPointeeType, ToPointeeType, ConvertedType,
2445 IncompatibleObjC)) {
2460 if (FromFunctionType && ToFunctionType) {
2469 if (FromFunctionType->
getNumParams() != ToFunctionType->getNumParams() ||
2470 FromFunctionType->
isVariadic() != ToFunctionType->isVariadic() ||
2471 FromFunctionType->
getTypeQuals() != ToFunctionType->getTypeQuals())
2474 bool HasObjCConversion =
false;
2478 }
else if (isObjCPointerConversion(FromFunctionType->
getReturnType(),
2479 ToFunctionType->getReturnType(),
2480 ConvertedType, IncompatibleObjC)) {
2482 HasObjCConversion =
true;
2489 for (
unsigned ArgIdx = 0, NumArgs = FromFunctionType->
getNumParams();
2490 ArgIdx != NumArgs; ++ArgIdx) {
2492 QualType ToArgType = ToFunctionType->getParamType(ArgIdx);
2496 }
else if (isObjCPointerConversion(FromArgType, ToArgType,
2497 ConvertedType, IncompatibleObjC)) {
2499 HasObjCConversion =
true;
2506 if (HasObjCConversion) {
2510 IncompatibleObjC =
true;
2529 if (!getLangOpts().ObjCAutoRefCount ||
2571 bool IncompatibleObjC;
2573 FromPointee = ToPointee;
2574 else if (!isObjCPointerConversion(FromPointee, ToPointee, FromPointee,
2609 if (!FromFunctionType || !ToFunctionType)
2617 if (FromFunctionType->
getNumParams() != ToFunctionType->getNumParams() ||
2618 FromFunctionType->
isVariadic() != ToFunctionType->isVariadic())
2623 if (FromEInfo != ToEInfo)
2626 bool IncompatibleObjC =
false;
2628 ToFunctionType->getReturnType())) {
2632 QualType LHS = ToFunctionType->getReturnType();
2639 }
else if (isObjCPointerConversion(RHS, LHS,
2640 ConvertedType, IncompatibleObjC)) {
2641 if (IncompatibleObjC)
2650 for (
unsigned ArgIdx = 0, NumArgs = FromFunctionType->
getNumParams();
2651 ArgIdx != NumArgs; ++ArgIdx) {
2652 IncompatibleObjC =
false;
2654 QualType ToArgType = ToFunctionType->getParamType(ArgIdx);
2657 }
else if (isObjCPointerConversion(ToArgType, FromArgType,
2658 ConvertedType, IncompatibleObjC)) {
2659 if (IncompatibleObjC)
2670 ConvertedType = ToType;
2746 if (!FromFunction || !ToFunction) {
2751 if (FromFunction->
getNumParams() != ToFunction->getNumParams()) {
2759 if (!FunctionParamTypesAreEqual(FromFunction, ToFunction, &ArgPos)) {
2761 << ToFunction->getParamType(ArgPos)
2768 ToFunction->getReturnType())) {
2775 ToQuals = ToFunction->getTypeQuals();
2776 if (FromQuals != ToQuals) {
2785 cast<FunctionProtoType>(ToFunction->getCanonicalTypeUnqualified())
2805 O && (O !=
E); ++O, ++N) {
2807 N->getUnqualifiedType())) {
2825 bool IgnoreBaseAccess,
2828 bool IsCStyleOrFunctionalCast = IgnoreBaseAccess;
2832 if (Diagnose && !IsCStyleOrFunctionalCast && !FromType->
isAnyPointerType() &&
2836 DiagRuntimeBehavior(From->
getExprLoc(), From,
2837 PDiag(diag::warn_impcast_bool_to_null_pointer)
2839 else if (!isUnevaluatedContext())
2848 if (FromPointeeType->
isRecordType() && ToPointeeType->isRecordType() &&
2852 unsigned InaccessibleID = 0;
2853 unsigned AmbigiousID = 0;
2855 InaccessibleID = diag::err_upcast_to_inaccessible_base;
2856 AmbigiousID = diag::err_ambiguous_derived_to_base_conv;
2858 if (CheckDerivedToBaseConversion(
2859 FromPointeeType, ToPointeeType, InaccessibleID, AmbigiousID,
2861 &BasePath, IgnoreBaseAccess))
2865 Kind = CK_DerivedToBase;
2868 if (Diagnose && !IsCStyleOrFunctionalCast &&
2869 FromPointeeType->
isFunctionType() && ToPointeeType->isVoidType()) {
2870 assert(getLangOpts().MSVCCompat &&
2871 "this should only be possible with MSVCCompat!");
2883 if (FromPtrType->isObjCBuiltinType() || ToPtrType->isObjCBuiltinType())
2886 Kind = CK_BlockPointerToObjCPointerCast;
2888 Kind = CK_CPointerToObjCPointerCast;
2892 Kind = CK_AnyPointerToBlockPointerCast;
2898 Kind = CK_NullToPointer;
2910 bool InOverloadResolution,
2920 ConvertedType = ToType;
2935 IsDerivedFrom(From->
getLocStart(), ToClass, FromClass)) {
2953 bool IgnoreBaseAccess) {
2960 "Expr must be null pointer constant!");
2961 Kind = CK_NullToMemberPointer;
2966 assert(ToPtrType &&
"No member pointer cast has a target type "
2967 "that is not a member pointer.");
2973 assert(FromClass->
isRecordType() &&
"Pointer into non-class.");
2974 assert(ToClass->isRecordType() &&
"Pointer into non-class.");
2978 bool DerivationOkay =
2979 IsDerivedFrom(From->
getLocStart(), ToClass, FromClass, Paths);
2980 assert(DerivationOkay &&
2981 "Should not have been called if derivation isn't OK.");
2982 (void)DerivationOkay;
2985 getUnqualifiedType())) {
2986 std::string PathDisplayStr = getAmbiguousPathsDisplayString(Paths);
2988 << 0 << FromClass << ToClass << PathDisplayStr << From->
getSourceRange();
2992 if (
const RecordType *VBase = Paths.getDetectedVirtual()) {
2994 << FromClass << ToClass <<
QualType(VBase, 0)
2999 if (!IgnoreBaseAccess)
3000 CheckBaseClassAccess(From->
getExprLoc(), FromClass, ToClass,
3002 diag::err_downcast_from_inaccessible_base);
3005 BuildBasePathArray(Paths, BasePath);
3006 Kind = CK_BaseToDerivedMemberPointer;
3031 bool CStyle,
bool &ObjCLifetimeConversion) {
3034 ObjCLifetimeConversion =
false;
3044 bool PreviousToQualsIncludeConst =
true;
3045 bool UnwrappedAnyPointer =
false;
3053 UnwrappedAnyPointer =
true;
3065 UnwrappedAnyPointer) {
3068 ObjCLifetimeConversion =
true;
3093 && !PreviousToQualsIncludeConst)
3098 PreviousToQualsIncludeConst
3099 = PreviousToQualsIncludeConst && ToQuals.
hasConst();
3116 bool InOverloadResolution,
3125 InOverloadResolution, InnerSCS,
3129 SCS.
Second = InnerSCS.Second;
3130 SCS.
setToType(1, InnerSCS.getToType(1));
3131 SCS.
Third = InnerSCS.Third;
3133 = InnerSCS.QualificationIncludesObjCLifetime;
3134 SCS.
setToType(2, InnerSCS.getToType(2));
3156 bool AllowExplicit) {
3162 bool Usable = !Info.Constructor->isInvalidDecl() &&
3164 (AllowExplicit || !Info.Constructor->isExplicit());
3169 S.
Context, Info.Constructor, ToType);
3170 if (Info.ConstructorTmpl)
3173 CandidateSet, SuppressUserConversions);
3176 CandidateSet, SuppressUserConversions);
3180 bool HadMultipleCandidates = (CandidateSet.
size() > 1);
3208 llvm_unreachable(
"Invalid OverloadResult!");
3230 bool AllowObjCConversionOnExplicit) {
3231 assert(AllowExplicit || !AllowObjCConversionOnExplicit);
3234 bool ConstructorsOnly =
false;
3250 ConstructorsOnly =
true;
3255 = dyn_cast<CXXRecordDecl>(ToRecordType->getDecl())) {
3257 Expr **Args = &From;
3258 unsigned NumArgs = 1;
3259 bool ListInitializing =
false;
3260 if (
InitListExpr *InitList = dyn_cast<InitListExpr>(From)) {
3263 S, From, ToType, ToRecordDecl, User, CandidateSet, AllowExplicit);
3267 CandidateSet.
clear();
3271 Args = InitList->getInits();
3272 NumArgs = InitList->getNumInits();
3273 ListInitializing =
true;
3281 bool Usable = !Info.Constructor->isInvalidDecl();
3282 if (ListInitializing)
3283 Usable = Usable && (AllowExplicit || !Info.Constructor->isExplicit());
3286 Info.Constructor->isConvertingConstructor(AllowExplicit);
3288 bool SuppressUserConversions = !ConstructorsOnly;
3289 if (SuppressUserConversions && ListInitializing) {
3290 SuppressUserConversions =
false;
3295 S.
Context, Info.Constructor, ToType);
3298 if (Info.ConstructorTmpl)
3300 Info.ConstructorTmpl, Info.FoundDecl,
3301 nullptr, llvm::makeArrayRef(Args, NumArgs),
3302 CandidateSet, SuppressUserConversions);
3307 llvm::makeArrayRef(Args, NumArgs),
3308 CandidateSet, SuppressUserConversions);
3315 if (ConstructorsOnly || isa<InitListExpr>(From)) {
3321 = dyn_cast<CXXRecordDecl>(FromRecordType->getDecl())) {
3323 const auto &Conversions = FromRecordDecl->getVisibleConversionFunctions();
3324 for (
auto I = Conversions.begin(), E = Conversions.end();
I !=
E; ++
I) {
3328 if (isa<UsingShadowDecl>(D))
3329 D = cast<UsingShadowDecl>(D)->getTargetDecl();
3333 if ((ConvTemplate = dyn_cast<FunctionTemplateDecl>(D)))
3336 Conv = cast<CXXConversionDecl>(D);
3338 if (AllowExplicit || !Conv->isExplicit()) {
3341 ActingContext, From, ToType,
3343 AllowObjCConversionOnExplicit);
3346 From, ToType, CandidateSet,
3347 AllowObjCConversionOnExplicit);
3353 bool HadMultipleCandidates = (CandidateSet.
size() > 1);
3362 = dyn_cast<CXXConstructorDecl>(Best->Function)) {
3370 if (isa<InitListExpr>(From)) {
3374 if (Best->Conversions[0].isEllipsis())
3377 User.
Before = Best->Conversions[0].Standard;
3390 = dyn_cast<CXXConversionDecl>(Best->Function)) {
3397 User.
Before = Best->Conversions[0].Standard;
3412 User.
After = Best->FinalConversion;
3415 llvm_unreachable(
"Not a constructor or conversion function?");
3424 llvm_unreachable(
"Invalid OverloadResult!");
3434 CandidateSet,
false,
false);
3440 diag::err_typecheck_nonviable_condition_incomplete,
3476 if (Block1 != Block2)
3563 if (!ICS1.
isBad()) {
3706 else if (Rank2 < Rank1)
3727 bool SCS1ConvertsToVoid
3729 bool SCS2ConvertsToVoid
3731 if (SCS1ConvertsToVoid != SCS2ConvertsToVoid) {
3736 }
else if (!SCS1ConvertsToVoid && !SCS2ConvertsToVoid) {
3742 }
else if (SCS1ConvertsToVoid && SCS2ConvertsToVoid &&
3771 if (FromObjCPtr1 && FromObjCPtr2) {
3776 if (AssignLeft != AssignRight) {
3809 if (UnqualT1 == UnqualT2) {
3821 if (isa<ArrayType>(T1) && T1Quals)
3823 if (isa<ArrayType>(T2) && T2Quals)
3882 if (UnqualT1 == UnqualT2)
3887 if (isa<ArrayType>(T1) && T1Quals)
3889 if (isa<ArrayType>(T2) && T2Quals)
4012 if (FromPointee1 == FromPointee2 && ToPointee1 != ToPointee2) {
4020 if (FromPointee1 != FromPointee2 && ToPointee1 == ToPointee2) {
4037 if (FromPtr1 && FromPtr2 && ToPtr1 && ToPtr2) {
4044 bool FromAssignRight
4053 if (ToPtr1->isObjCIdType() &&
4054 (ToPtr2->isObjCQualifiedIdType() || ToPtr2->getInterfaceDecl()))
4056 if (ToPtr2->isObjCIdType() &&
4057 (ToPtr1->isObjCQualifiedIdType() || ToPtr1->getInterfaceDecl()))
4062 if (ToPtr1->isObjCQualifiedIdType() && ToPtr2->getInterfaceDecl())
4064 if (ToPtr2->isObjCQualifiedIdType() && ToPtr1->getInterfaceDecl())
4069 if (ToPtr1->isObjCClassType() &&
4070 (ToPtr2->isObjCQualifiedClassType() || ToPtr2->getInterfaceDecl()))
4072 if (ToPtr2->isObjCClassType() &&
4073 (ToPtr1->isObjCQualifiedClassType() || ToPtr1->getInterfaceDecl()))
4078 if (ToPtr1->isObjCQualifiedClassType() && ToPtr2->getInterfaceDecl())
4080 if (ToPtr2->isObjCQualifiedClassType() && ToPtr1->getInterfaceDecl())
4086 (ToAssignLeft != ToAssignRight)) {
4097 }
else if (IsSecondSame)
4106 (FromAssignLeft != FromAssignRight))
4124 const Type *FromPointeeType1 = FromMemPointer1->
getClass();
4125 const Type *ToPointeeType1 = ToMemPointer1->getClass();
4126 const Type *FromPointeeType2 = FromMemPointer2->getClass();
4127 const Type *ToPointeeType2 = ToMemPointer2->getClass();
4133 if (FromPointee1 == FromPointee2 && ToPointee1 != ToPointee2) {
4140 if (ToPointee1 == ToPointee2 && FromPointee1 != FromPointee2) {
4181 return !Record->isInvalidDecl();
4196 bool &DerivedToBase,
4197 bool &ObjCConversion,
4198 bool &ObjCLifetimeConversion) {
4200 "T1 must be the pointee type of the reference type");
4201 assert(!OrigT2->
isReferenceType() &&
"T2 cannot be a reference type");
4213 DerivedToBase =
false;
4214 ObjCConversion =
false;
4215 ObjCLifetimeConversion =
false;
4217 if (UnqualT1 == UnqualT2) {
4222 DerivedToBase =
true;
4226 ObjCConversion =
true;
4244 if (isa<ArrayType>(T1) && T1Quals)
4246 if (isa<ArrayType>(T2) && T2Quals)
4264 ObjCLifetimeConversion =
true;
4286 bool AllowExplicit) {
4287 assert(T2->
isRecordType() &&
"Can only find conversions of record types.");
4292 const auto &Conversions = T2RecordDecl->getVisibleConversionFunctions();
4293 for (
auto I = Conversions.begin(), E = Conversions.end();
I !=
E; ++
I) {
4296 if (isa<UsingShadowDecl>(D))
4297 D = cast<UsingShadowDecl>(D)->getTargetDecl();
4305 Conv = cast<CXXConversionDecl>(D);
4309 if (!AllowExplicit && Conv->isExplicit())
4313 bool DerivedToBase =
false;
4314 bool ObjCConversion =
false;
4315 bool ObjCLifetimeConversion =
false;
4326 if (!ConvTemplate &&
4329 Conv->getConversionType().getNonReferenceType()
4330 .getUnqualifiedType(),
4332 DerivedToBase, ObjCConversion, ObjCLifetimeConversion) ==
4350 Init, DeclType, CandidateSet,
4354 DeclType, CandidateSet,
4358 bool HadMultipleCandidates = (CandidateSet.size() > 1);
4361 switch (CandidateSet.BestViableFunction(S, DeclLoc, Best,
true)) {
4373 if (!Best->FinalConversion.DirectBinding)
4385 "Expected a direct reference binding!");
4391 Cand != CandidateSet.end(); ++Cand)
4403 llvm_unreachable(
"Invalid OverloadResult!");
4411 bool SuppressUserConversions,
4412 bool AllowExplicit) {
4413 assert(DeclType->
isReferenceType() &&
"Reference init needs a reference");
4434 bool DerivedToBase =
false;
4435 bool ObjCConversion =
false;
4436 bool ObjCLifetimeConversion =
false;
4440 ObjCConversion, ObjCLifetimeConversion);
4468 ICS.Standard.setToType(0, T2);
4469 ICS.Standard.setToType(1, T1);
4470 ICS.Standard.setToType(2, T1);
4471 ICS.Standard.ReferenceBinding =
true;
4472 ICS.Standard.DirectBinding =
true;
4473 ICS.Standard.IsLvalueReference = !isRValRef;
4475 ICS.Standard.BindsToRvalue =
false;
4476 ICS.Standard.BindsImplicitObjectArgumentWithoutRefQualifier =
false;
4477 ICS.Standard.ObjCLifetimeConversionBinding = ObjCLifetimeConversion;
4478 ICS.Standard.CopyConstructor =
nullptr;
4479 ICS.Standard.DeprecatedStringLiteralToCharPtr =
false;
4526 ICS.Standard.setToType(0, T2);
4527 ICS.Standard.setToType(1, T1);
4528 ICS.Standard.setToType(2, T1);
4529 ICS.Standard.ReferenceBinding =
true;
4535 ICS.Standard.DirectBinding =
4538 ICS.Standard.IsLvalueReference = !isRValRef;
4540 ICS.Standard.BindsToRvalue = InitCategory.
isRValue();
4541 ICS.Standard.BindsImplicitObjectArgumentWithoutRefQualifier =
false;
4542 ICS.Standard.ObjCLifetimeConversionBinding = ObjCLifetimeConversion;
4543 ICS.Standard.CopyConstructor =
nullptr;
4544 ICS.Standard.DeprecatedStringLiteralToCharPtr =
false;
4567 if (ICS.isUserDefined() && isRValRef &&
4639 if (ICS.isStandard()) {
4640 ICS.Standard.ReferenceBinding =
true;
4641 ICS.Standard.IsLvalueReference = !isRValRef;
4642 ICS.Standard.BindsToFunctionLvalue =
false;
4643 ICS.Standard.BindsToRvalue =
true;
4644 ICS.Standard.BindsImplicitObjectArgumentWithoutRefQualifier =
false;
4645 ICS.Standard.ObjCLifetimeConversionBinding =
false;
4646 }
else if (ICS.isUserDefined()) {
4648 ICS.UserDefined.ConversionFunction->getReturnType()
4665 ICS.UserDefined.After.ReferenceBinding =
true;
4666 ICS.UserDefined.After.IsLvalueReference = !isRValRef;
4667 ICS.UserDefined.After.BindsToFunctionLvalue =
false;
4668 ICS.UserDefined.After.BindsToRvalue = !LValRefType;
4669 ICS.UserDefined.After.BindsImplicitObjectArgumentWithoutRefQualifier =
false;
4670 ICS.UserDefined.After.ObjCLifetimeConversionBinding =
false;
4678 bool SuppressUserConversions,
4679 bool InOverloadResolution,
4680 bool AllowObjCWritebackConversion,
4681 bool AllowExplicit =
false);
4687 bool SuppressUserConversions,
4688 bool InOverloadResolution,
4689 bool AllowObjCWritebackConversion) {
4718 SuppressUserConversions,
4719 InOverloadResolution,
4720 AllowObjCWritebackConversion);
4753 bool toStdInitializerList =
false;
4760 for (
unsigned i = 0, e = From->
getNumInits(); i < e; ++i) {
4764 InOverloadResolution,
4765 AllowObjCWritebackConversion);
4772 if (Result.
isBad() ||
4803 InOverloadResolution,
false,
4804 AllowObjCWritebackConversion,
4861 Init, ToType,
false, Found))
4866 bool dummy1 =
false;
4867 bool dummy2 =
false;
4868 bool dummy3 =
false;
4875 SuppressUserConversions,
4883 InOverloadResolution,
4884 AllowObjCWritebackConversion);
4888 "Sub-initialization cannot result in ellipsis conversion.");
4915 if (NumInits == 1 && !isa<InitListExpr>(From->
getInit(0)))
4917 SuppressUserConversions,
4918 InOverloadResolution,
4919 AllowObjCWritebackConversion);
4922 else if (NumInits == 0) {
4945 bool SuppressUserConversions,
4946 bool InOverloadResolution,
4947 bool AllowObjCWritebackConversion,
4948 bool AllowExplicit) {
4949 if (
InitListExpr *FromInitList = dyn_cast<InitListExpr>(From))
4951 InOverloadResolution,AllowObjCWritebackConversion);
4956 SuppressUserConversions,
4960 SuppressUserConversions,
4962 InOverloadResolution,
4964 AllowObjCWritebackConversion,
4977 return !ICS.
isBad();
4991 unsigned Quals = isa<CXXDestructorDecl>(Method) ?
5005 assert(FromClassification.
isLValue());
5031 != FromTypeCanon.getLocalCVRQualifiers() &&
5034 FromType, ImplicitParamType);
5048 FromType, ImplicitParamType);
5068 if (!FromClassification.
isRValue()) {
5111 FromRecordType = From->
getType();
5112 DestType = ImplicitParamRecordType;
5128 diag::err_member_function_call_bad_cvr)
5129 << Method->getDeclName() << FromRecordType << (CVR - 1)
5131 Diag(Method->getLocation(), diag::note_previous_decl)
5132 << Method->getDeclName();
5138 diag::err_implicit_object_parameter_init)
5139 << ImplicitParamRecordType << FromRecordType << From->
getSourceRange();
5147 From = FromRes.
get();
5181 diag::err_typecheck_bool_condition)
5240 llvm_unreachable(
"found a first conversion kind in Second");
5243 llvm_unreachable(
"found a third conversion kind in Second");
5249 llvm_unreachable(
"unknown conversion kind");
5260 "converted constant expression outside C++11");
5296 diag::err_typecheck_converted_constant_expression)
5301 llvm_unreachable(
"ellipsis conversion in converted constant expression");
5307 diag::err_typecheck_converted_constant_expression_disallowed)
5313 diag::err_typecheck_converted_constant_expression_indirect)
5326 PreNarrowingType)) {
5344 << CCE << 0 << From->
getType() << T;
5361 (RequireInt && !Eval.
Val.
isInt())) {
5368 if (Notes.empty()) {
5375 if (Notes.size() == 1 &&
5376 Notes[0].second.getDiagID() == diag::note_invalid_subexpr_in_const_expr)
5377 S.
Diag(Notes[0].first, diag::err_expr_not_cce) << CCE;
5381 for (
unsigned I = 0;
I < Notes.size(); ++
I)
5382 S.
Diag(Notes[
I].first, Notes[I].second);
5393 llvm::APSInt &
Value,
5399 if (!R.isInvalid() && !R.get()->isValueDependent())
5482 for (
unsigned I = 0, N = ViableConversions.
size();
I != N; ++
I) {
5484 cast<CXXConversionDecl>(ViableConversions[
I]->getUnderlyingDecl());
5494 QualType T,
bool HadMultipleCandidates,
5496 if (ExplicitConversions.
size() == 1 && !Converter.
Suppress) {
5504 std::string TypeStr;
5509 "static_cast<" + TypeStr +
">(")
5521 HadMultipleCandidates);
5526 CK_UserDefinedConversion, Result.
get(),
5534 QualType T,
bool HadMultipleCandidates,
5550 HadMultipleCandidates);
5555 CK_UserDefinedConversion, Result.
get(),
5574 for (
unsigned I = 0, N = ViableConversions.
size();
I != N; ++
I) {
5578 if (isa<UsingShadowDecl>(D))
5579 D = cast<UsingShadowDecl>(D)->getTargetDecl();
5583 if ((ConvTemplate = dyn_cast<FunctionTemplateDecl>(D)))
5586 Conv = cast<CXXConversionDecl>(D);
5590 ConvTemplate, FoundDecl, ActingContext, From, ToType, CandidateSet,
5594 ToType, CandidateSet,
5628 From = result.
get();
5633 if (Converter.
match(T))
5653 : Converter(Converter), From(From) {}
5658 } IncompleteDiagnoser(Converter, From);
5668 const auto &Conversions =
5669 cast<CXXRecordDecl>(RecordTy->
getDecl())->getVisibleConversionFunctions();
5671 bool HadMultipleCandidates =
5672 (
std::distance(Conversions.begin(), Conversions.end()) > 1);
5676 bool HasUniqueTargetType =
true;
5679 for (
auto I = Conversions.begin(), E = Conversions.end();
I !=
E; ++
I) {
5689 Conversion = cast<CXXConversionDecl>(D);
5692 "Conversion operator templates are considered potentially "
5696 if (Converter.
match(CurToType) || ConvTemplate) {
5702 ExplicitConversions.
addDecl(
I.getDecl(),
I.getAccess());
5707 else if (HasUniqueTargetType &&
5709 HasUniqueTargetType =
false;
5711 ViableConversions.
addDecl(
I.getDecl(),
I.getAccess());
5729 HadMultipleCandidates,
5730 ExplicitConversions))
5736 if (!HasUniqueTargetType)
5755 HadMultipleCandidates, Found))
5764 HadMultipleCandidates,
5765 ExplicitConversions))
5773 switch (ViableConversions.
size()) {
5776 HadMultipleCandidates,
5777 ExplicitConversions))
5787 HadMultipleCandidates, Found))
5852 bool SuppressUserConversions,
5853 bool PartialOverloading,
5858 assert(Proto &&
"Functions without a prototype cannot be overloaded");
5860 "Use AddTemplateOverloadCandidate for function templates");
5862 if (
CXXMethodDecl *Method = dyn_cast<CXXMethodDecl>(Function)) {
5863 if (!isa<CXXConstructorDecl>(Method)) {
5873 CandidateSet, SuppressUserConversions,
5874 PartialOverloading, EarlyConversions);
5909 CandidateSet.
addCandidate(Args.size(), EarlyConversions);
5926 Candidate.
Viable =
false;
5939 if (Shadow && Args.size() == 1 && Constructor->
getNumParams() >= 1 &&
5947 Candidate.
Viable =
false;
5961 Candidate.
Viable =
false;
5972 if (Args.size() < MinRequiredArgs && !PartialOverloading) {
5974 Candidate.
Viable =
false;
5987 Candidate.
Viable =
false;
5994 for (
unsigned ArgIdx = 0; ArgIdx < Args.size(); ++ArgIdx) {
5995 if (Candidate.
Conversions[ArgIdx].isInitialized()) {
5998 }
else if (ArgIdx < NumParams) {
6006 SuppressUserConversions,
6012 Candidate.
Viable =
false;
6024 if (EnableIfAttr *FailedAttr =
CheckEnableIf(Function, Args)) {
6025 Candidate.
Viable =
false;
6032 Candidate.
Viable =
false;
6041 if (Methods.size() <= 1)
6044 for (
unsigned b = 0, e = Methods.size(); b < e; b++) {
6052 if (Args.size() < NumNamedArgs)
6055 for (
unsigned i = 0; i < NumNamedArgs; i++) {
6057 if (Args[i]->isTypeDependent()) {
6063 Expr *argExpr = Args[i];
6064 assert(argExpr &&
"SelectBestMethod(): missing expression");
6069 !param->
hasAttr<CFConsumedAttr>())
6087 if (ConversionState.
isBad() ||
6097 for (
unsigned i = NumNamedArgs, e = Args.size(); i < e; ++i) {
6098 if (Args[i]->isTypeDependent()) {
6111 if (Args.size() != NumNamedArgs)
6113 else if (Match && NumNamedArgs == 0 && Methods.size() > 1) {
6116 for (
unsigned b = 0, e = Methods.size(); b < e; b++) {
6117 QualType ReturnT = Methods[b]->getReturnType();
6139 const auto &FuncAttrs = Function->
getAttrs();
6141 if (
auto *EnableIf = dyn_cast<EnableIfAttr>(
Attr))
6142 Result.push_back(EnableIf);
6144 std::reverse(Result.begin(), Result.end());
6151 bool MissingImplicitThis,
Expr *&ConvertedThis,
6155 assert(!isa<CXXConstructorDecl>(Method) &&
6156 "Shouldn't have `this` for ctors!");
6157 assert(!Method->
isStatic() &&
"Shouldn't have `this` for static methods!");
6159 ThisArg,
nullptr, Method, Method);
6162 ConvertedThis = R.get();
6164 if (
auto *MD = dyn_cast<CXXMethodDecl>(Function)) {
6166 assert((MissingImplicitThis || MD->isStatic() ||
6167 isa<CXXConstructorDecl>(MD)) &&
6168 "Expected `this` for non-ctor instance methods");
6170 ConvertedThis =
nullptr;
6178 for (
unsigned I = 0;
I != ArgSizeNoVarargs; ++
I) {
6187 ConvertedArgs.push_back(R.
get());
6195 for (
unsigned i = Args.size(), e = Function->
getNumParams(); i != e; ++i) {
6205 ConvertedArgs.push_back(R.
get());
6215 bool MissingImplicitThis) {
6218 if (EnableIfAttrs.empty())
6224 Expr *DiscardedThis;
6226 *
this, Function,
nullptr, Args, Trap,
6227 true, DiscardedThis, ConvertedArgs))
6228 return EnableIfAttrs[0];
6230 for (
auto *EIA : EnableIfAttrs) {
6234 if (!EIA->getCond()->EvaluateWithSubstitution(
6235 Result,
Context, Function, llvm::makeArrayRef(ConvertedArgs)))
6238 if (!Result.
isInt() || !Result.
getInt().getBoolValue())
6244 template <
typename CheckFn>
6247 CheckFn &&IsSuccessful) {
6250 if (ArgDependent == DIA->getArgDependent())
6251 Attrs.push_back(DIA);
6258 auto WarningBegin = std::stable_partition(
6259 Attrs.begin(), Attrs.end(),
6260 [](
const DiagnoseIfAttr *DIA) {
return DIA->isError(); });
6264 auto ErrAttr = llvm::find_if(llvm::make_range(Attrs.begin(), WarningBegin),
6266 if (ErrAttr != WarningBegin) {
6267 const DiagnoseIfAttr *DIA = *ErrAttr;
6268 S.
Diag(Loc, diag::err_diagnose_if_succeeded) << DIA->getMessage();
6269 S.
Diag(DIA->getLocation(), diag::note_from_diagnose_if)
6270 << DIA->getParent() << DIA->getCond()->getSourceRange();
6274 for (
const auto *DIA : llvm::make_range(WarningBegin, Attrs.end()))
6275 if (IsSuccessful(DIA)) {
6276 S.
Diag(Loc, diag::warn_diagnose_if_succeeded) << DIA->getMessage();
6277 S.
Diag(DIA->getLocation(), diag::note_from_diagnose_if)
6278 << DIA->getParent() << DIA->getCond()->getSourceRange();
6285 const Expr *ThisArg,
6289 *
this, Function,
true, Loc,
6290 [&](
const DiagnoseIfAttr *DIA) {
6295 if (!DIA->getCond()->EvaluateWithSubstitution(
6296 Result,
Context, cast<FunctionDecl>(DIA->getParent()), Args, ThisArg))
6298 return Result.
isInt() && Result.
getInt().getBoolValue();
6305 *
this, ND,
false, Loc,
6306 [&](
const DiagnoseIfAttr *DIA) {
6308 return DIA->getCond()->EvaluateAsBooleanCondition(Result,
Context) &&
6319 bool SuppressUserConversions,
6320 bool PartialOverloading) {
6324 if (isa<CXXMethodDecl>(FD) && !cast<CXXMethodDecl>(FD)->isStatic()) {
6327 if (
Expr *E = Args[0]) {
6333 cast<CXXMethodDecl>(FD)->getParent(), ObjectType,
6334 ObjectClassification, Args.slice(1), CandidateSet,
6335 SuppressUserConversions, PartialOverloading);
6338 SuppressUserConversions, PartialOverloading);
6346 if (
Expr *E = Args[0]) {
6352 FunTmpl, F.getPair(),
6354 ExplicitTemplateArgs, ObjectType, ObjectClassification,
6355 Args.slice(1), CandidateSet, SuppressUserConversions,
6356 PartialOverloading);
6359 ExplicitTemplateArgs, Args,
6360 CandidateSet, SuppressUserConversions,
6361 PartialOverloading);
6374 bool SuppressUserConversions) {
6378 if (isa<UsingShadowDecl>(Decl))
6379 Decl = cast<UsingShadowDecl>(Decl)->getTargetDecl();
6382 assert(isa<CXXMethodDecl>(TD->getTemplatedDecl()) &&
6383 "Expected a member function template");
6385 nullptr, ObjectType,
6386 ObjectClassification, Args, CandidateSet,
6387 SuppressUserConversions);
6390 ObjectType, ObjectClassification, Args, CandidateSet,
6391 SuppressUserConversions);
6408 bool SuppressUserConversions,
6409 bool PartialOverloading,
6413 assert(Proto &&
"Methods without a prototype cannot be overloaded");
6414 assert(!isa<CXXConstructorDecl>(Method) &&
6415 "Use AddOverloadCandidate for constructors");
6433 CandidateSet.
addCandidate(Args.size() + 1, EarlyConversions);
6447 Candidate.
Viable =
false;
6458 if (Args.size() < MinRequiredArgs && !PartialOverloading) {
6460 Candidate.
Viable =
false;
6474 *
this, CandidateSet.
getLocation(), ObjectType, ObjectClassification,
6475 Method, ActingContext);
6477 Candidate.
Viable =
false;
6487 Candidate.Viable =
false;
6494 for (
unsigned ArgIdx = 0; ArgIdx < Args.size(); ++ArgIdx) {
6495 if (Candidate.Conversions[ArgIdx + 1].isInitialized()) {
6498 }
else if (ArgIdx < NumParams) {
6503 QualType ParamType = Proto->getParamType(ArgIdx);
6504 Candidate.Conversions[ArgIdx + 1]
6506 SuppressUserConversions,
6510 if (Candidate.Conversions[ArgIdx + 1].isBad()) {
6511 Candidate.Viable =
false;
6519 Candidate.Conversions[ArgIdx + 1].setEllipsis();
6523 if (EnableIfAttr *FailedAttr =
CheckEnableIf(Method, Args,
true)) {
6524 Candidate.Viable =
false;
6526 Candidate.DeductionFailure.Data = FailedAttr;
6543 bool SuppressUserConversions,
6544 bool PartialOverloading) {
6561 MethodTmpl, ExplicitTemplateArgs, Args, Specialization, Info,
6564 MethodTmpl, ParamTypes, Args, CandidateSet, Conversions,
6565 SuppressUserConversions, ActingContext, ObjectType,
6566 ObjectClassification);
6569 CandidateSet.
addCandidate(Conversions.size(), Conversions);
6572 Candidate.
Viable =
false;
6575 cast<CXXMethodDecl>(Candidate.
Function)->isStatic() ||
6590 assert(Specialization &&
"Missing member function template specialization?");
6591 assert(isa<CXXMethodDecl>(Specialization) &&
6592 "Specialization is not a member function?");
6594 ActingContext, ObjectType, ObjectClassification, Args,
6595 CandidateSet, SuppressUserConversions, PartialOverloading,
6608 bool SuppressUserConversions,
6609 bool PartialOverloading) {
6626 FunctionTemplate, ExplicitTemplateArgs, Args, Specialization, Info,
6629 Args, CandidateSet, Conversions,
6630 SuppressUserConversions);
6633 CandidateSet.
addCandidate(Conversions.size(), Conversions);
6636 Candidate.
Viable =
false;
6641 isa<CXXMethodDecl>(Candidate.
Function) &&
6642 !isa<CXXConstructorDecl>(Candidate.
Function);
6656 assert(Specialization &&
"Missing function template specialization?");
6658 SuppressUserConversions, PartialOverloading,
6659 false, Conversions);
6674 const bool AllowExplicit =
false;
6678 bool HasThisConversion = Method && !isa<CXXConstructorDecl>(Method);
6679 unsigned ThisConversions = HasThisConversion ? 1 : 0;
6691 if (HasThisConversion && !cast<CXXMethodDecl>(FD)->isStatic() &&
6694 *
this, CandidateSet.
getLocation(), ObjectType, ObjectClassification,
6695 Method, ActingContext);
6696 if (Conversions[0].isBad())
6700 for (
unsigned I = 0, N =
std::min(ParamTypes.size(), Args.size());
I != N;
6704 Conversions[ThisConversions +
I]
6706 SuppressUserConversions,
6711 if (Conversions[ThisConversions + I].isBad())
6733 bool AllowObjCPointerConversion) {
6741 bool ObjCLifetimeConversion;
6743 ObjCLifetimeConversion))
6748 if (!AllowObjCPointerConversion)
6752 bool IncompatibleObjC =
false;
6770 bool AllowObjCConversionOnExplicit) {
6772 "Conversion function templates use AddTemplateConversionCandidate");
6779 if (
getLangOpts().CPlusPlus14 && ConvType->isUndeducedType()) {
6790 AllowObjCConversionOnExplicit))
6820 = cast<CXXRecordDecl>(ImplicitParamType->
getAs<
RecordType>()->getDecl());
6827 Candidate.
Viable =
false;
6838 if (FromCanon == ToCanon ||
6840 Candidate.
Viable =
false;
6857 CK_FunctionToPointerDecay,
6862 Candidate.
Viable =
false;
6881 switch (ICS.getKind()) {
6891 Candidate.
Viable =
false;
6903 Candidate.
Viable =
false;
6910 Candidate.
Viable =
false;
6916 "Can only end up with a standard conversion sequence or failure");
6920 Candidate.
Viable =
false;
6938 bool AllowObjCConversionOnExplicit) {
6940 "Only conversion function templates permitted here");
6949 Specialization, Info)) {
6953 Candidate.
Viable =
false;
6965 assert(Specialization &&
"Missing function template specialization?");
6967 CandidateSet, AllowObjCConversionOnExplicit);
7003 if (ObjectInit.
isBad()) {
7004 Candidate.
Viable =
false;
7015 Candidate.
Conversions[0].UserDefined.EllipsisConversion =
false;
7016 Candidate.
Conversions[0].UserDefined.HadMultipleCandidates =
false;
7017 Candidate.
Conversions[0].UserDefined.ConversionFunction = Conversion;
7021 Candidate.
Conversions[0].UserDefined.After.setAsIdentityConversion();
7029 if (Args.size() > NumParams && !Proto->
isVariadic()) {
7030 Candidate.
Viable =
false;
7037 if (Args.size() < NumParams) {
7039 Candidate.
Viable =
false;
7046 for (
unsigned ArgIdx = 0, N = Args.size(); ArgIdx != N; ++ArgIdx) {
7047 if (ArgIdx < NumParams) {
7060 Candidate.
Viable =
false;
7073 Candidate.
Viable =
false;
7114 if (!T1Rec->getDecl()->getDefinition())
7122 OperEnd = Operators.
end();
7126 Args[0]->Classify(
Context), Args.slice(1),
7127 CandidateSet,
false);
7141 bool IsAssignmentOperator,
7142 unsigned NumContextualBoolArguments) {
7159 for (
unsigned ArgIdx = 0, N = Args.size(); ArgIdx != N; ++ArgIdx) {
7172 if (ArgIdx < NumContextualBoolArguments) {
7174 "Contextual conversion to bool requires bool type");
7180 ArgIdx == 0 && IsAssignmentOperator,
7186 Candidate.
Viable =
false;
7199 class BuiltinCandidateTypeSet {
7201 typedef llvm::SetVector<QualType, SmallVector<QualType, 8>,
7202 llvm::SmallPtrSet<QualType, 8>> TypeSet;
7206 TypeSet PointerTypes;
7210 TypeSet MemberPointerTypes;
7214 TypeSet EnumerationTypes;
7218 TypeSet VectorTypes;
7221 bool HasNonRecordTypes;
7225 bool HasArithmeticOrEnumeralTypes;
7229 bool HasNullPtrType;
7238 bool AddPointerWithMoreQualifiedTypeVariants(
QualType Ty,
7240 bool AddMemberPointerWithMoreQualifiedTypeVariants(
QualType Ty);
7244 typedef TypeSet::iterator iterator;
7246 BuiltinCandidateTypeSet(
Sema &SemaRef)
7247 : HasNonRecordTypes(
false),
7248 HasArithmeticOrEnumeralTypes(
false),
7249 HasNullPtrType(
false),
7253 void AddTypesConvertedFrom(
QualType Ty,
7255 bool AllowUserConversions,
7256 bool AllowExplicitConversions,
7257 const Qualifiers &VisibleTypeConversionsQuals);
7260 iterator pointer_begin() {
return PointerTypes.begin(); }
7263 iterator pointer_end() {
return PointerTypes.end(); }
7266 iterator member_pointer_begin() {
return MemberPointerTypes.begin(); }
7269 iterator member_pointer_end() {
return MemberPointerTypes.end(); }
7272 iterator enumeration_begin() {
return EnumerationTypes.begin(); }
7275 iterator enumeration_end() {
return EnumerationTypes.end(); }
7277 iterator vector_begin() {
return VectorTypes.begin(); }
7278 iterator vector_end() {
return VectorTypes.end(); }
7280 bool hasNonRecordTypes() {
return HasNonRecordTypes; }
7281 bool hasArithmeticOrEnumeralTypes() {
return HasArithmeticOrEnumeralTypes; }
7282 bool hasNullPtrType()
const {
return HasNullPtrType; }
7297 BuiltinCandidateTypeSet::AddPointerWithMoreQualifiedTypeVariants(
QualType Ty,
7301 if (!PointerTypes.insert(Ty))
7306 bool buildObjCPtr =
false;
7310 buildObjCPtr =
true;
7322 unsigned BaseCVR = PointeeTy.getCVRQualifiers();
7328 if ((CVR | BaseCVR) != CVR)
continue;
7350 PointerTypes.insert(QPointerTy);
7366 BuiltinCandidateTypeSet::AddMemberPointerWithMoreQualifiedTypeVariants(
7369 if (!MemberPointerTypes.insert(Ty))
7373 assert(PointerTy &&
"type was not a member pointer type!");
7388 if ((CVR | BaseCVR) != CVR)
continue;
7391 MemberPointerTypes.insert(
7407 BuiltinCandidateTypeSet::AddTypesConvertedFrom(
QualType Ty,
7409 bool AllowUserConversions,
7410 bool AllowExplicitConversions,
7422 Ty = SemaRef.Context.getArrayDecayedType(Ty);
7429 HasNonRecordTypes = HasNonRecordTypes || !TyRec;
7432 HasArithmeticOrEnumeralTypes =
7436 PointerTypes.insert(Ty);
7440 if (!AddPointerWithMoreQualifiedTypeVariants(Ty, VisibleQuals))
7444 if (!AddMemberPointerWithMoreQualifiedTypeVariants(Ty))
7447 HasArithmeticOrEnumeralTypes =
true;
7448 EnumerationTypes.insert(Ty);
7452 HasArithmeticOrEnumeralTypes =
true;
7453 VectorTypes.insert(Ty);
7455 HasNullPtrType =
true;
7456 }
else if (AllowUserConversions && TyRec) {
7458 if (!SemaRef.isCompleteType(Loc, Ty))
7463 if (isa<UsingShadowDecl>(D))
7464 D = cast<UsingShadowDecl>(D)->getTargetDecl();
7468 if (isa<FunctionTemplateDecl>(D))
7472 if (AllowExplicitConversions || !Conv->
isExplicit()) {
7527 if (isa<UsingShadowDecl>(D))
7528 D = cast<UsingShadowDecl>(D)->getTargetDecl();
7562 class BuiltinOperatorOverloadBuilder {
7567 bool HasArithmeticOrEnumeralCandidateType;
7575 static const unsigned FirstIntegralType = 4;
7576 static const unsigned LastIntegralType = 21;
7577 static const unsigned FirstPromotedIntegralType = 4,
7578 LastPromotedIntegralType = 12;
7579 static const unsigned FirstPromotedArithmeticType = 0,
7580 LastPromotedArithmeticType = 12;
7581 static const unsigned NumArithmeticTypes = 21;
7585 assert(index < NumArithmeticTypes);
7587 ArithmeticTypes[NumArithmeticTypes] = {
7617 return S.
Context.*ArithmeticTypes[index];
7622 void addPlusPlusMinusMinusStyleOverloads(
QualType CandidateTy,
7655 (Qualifiers::Volatile |
7656 Qualifiers::Restrict)));
7664 BuiltinOperatorOverloadBuilder(
7667 bool HasArithmeticOrEnumeralCandidateType,
7671 VisibleTypeConversionsQuals(VisibleTypeConversionsQuals),
7672 HasArithmeticOrEnumeralCandidateType(
7673 HasArithmeticOrEnumeralCandidateType),
7674 CandidateTypes(CandidateTypes),
7675 CandidateSet(CandidateSet) {
7677 assert(getArithmeticType(FirstPromotedIntegralType) == S.
Context.
IntTy &&
7678 "Invalid first promoted integral type");
7679 assert(getArithmeticType(LastPromotedIntegralType - 1)
7681 "Invalid last promoted integral type");
7682 assert(getArithmeticType(FirstPromotedArithmeticType)
7684 "Invalid first promoted arithmetic type");
7685 assert(getArithmeticType(LastPromotedArithmeticType - 1)
7687 "Invalid last promoted arithmetic type");
7708 if (!HasArithmeticOrEnumeralCandidateType)
7711 for (
unsigned Arith = (Op == OO_PlusPlus? 0 : 1);
7712 Arith < NumArithmeticTypes; ++Arith) {
7713 addPlusPlusMinusMinusStyleOverloads(
7714 getArithmeticType(Arith),
7730 void addPlusPlusMinusMinusPointerOverloads() {
7731 for (BuiltinCandidateTypeSet::iterator
7732 Ptr = CandidateTypes[0].pointer_begin(),
7733 PtrEnd = CandidateTypes[0].pointer_end();
7734 Ptr != PtrEnd; ++Ptr) {
7736 if (!(*Ptr)->getPointeeType()->isObjectType())
7739 addPlusPlusMinusMinusStyleOverloads(*Ptr,
7740 (!(*Ptr).isVolatileQualified() &&
7742 (!(*Ptr).isRestrictQualified() &&
7757 void addUnaryStarPointerOverloads() {
7758 for (BuiltinCandidateTypeSet::iterator
7759 Ptr = CandidateTypes[0].pointer_begin(),
7760 PtrEnd = CandidateTypes[0].pointer_end();
7761 Ptr != PtrEnd; ++Ptr) {
7768 if (Proto->getTypeQuals() || Proto->getRefQualifier())
7781 void addUnaryPlusOrMinusArithmeticOverloads() {
7782 if (!HasArithmeticOrEnumeralCandidateType)
7785 for (
unsigned Arith = FirstPromotedArithmeticType;
7786 Arith < LastPromotedArithmeticType; ++Arith) {
7787 QualType ArithTy = getArithmeticType(Arith);
7792 for (BuiltinCandidateTypeSet::iterator
7793 Vec = CandidateTypes[0].vector_begin(),
7794 VecEnd = CandidateTypes[0].vector_end();
7795 Vec != VecEnd; ++Vec) {
7806 void addUnaryPlusPointerOverloads() {
7807 for (BuiltinCandidateTypeSet::iterator
7808 Ptr = CandidateTypes[0].pointer_begin(),
7809 PtrEnd = CandidateTypes[0].pointer_end();
7810 Ptr != PtrEnd; ++Ptr) {
7821 void addUnaryTildePromotedIntegralOverloads() {
7822 if (!HasArithmeticOrEnumeralCandidateType)
7825 for (
unsigned Int = FirstPromotedIntegralType;
7826 Int < LastPromotedIntegralType; ++Int) {
7827 QualType IntTy = getArithmeticType(Int);
7832 for (BuiltinCandidateTypeSet::iterator
7833 Vec = CandidateTypes[0].vector_begin(),
7834 VecEnd = CandidateTypes[0].vector_end();
7835 Vec != VecEnd; ++Vec) {
7847 void addEqualEqualOrNotEqualMemberPointerOrNullptrOverloads() {
7849 llvm::SmallPtrSet<QualType, 8> AddedTypes;
7851 for (
unsigned ArgIdx = 0, N = Args.size(); ArgIdx != N; ++ArgIdx) {
7852 for (BuiltinCandidateTypeSet::iterator
7853 MemPtr = CandidateTypes[ArgIdx].member_pointer_begin(),
7854 MemPtrEnd = CandidateTypes[ArgIdx].member_pointer_end();
7855 MemPtr != MemPtrEnd;
7861 QualType ParamTypes[2] = { *MemPtr, *MemPtr };
7865 if (CandidateTypes[ArgIdx].hasNullPtrType()) {
7867 if (AddedTypes.insert(NullPtrTy).second) {
7868 QualType ParamTypes[2] = { NullPtrTy, NullPtrTy };
7886 void addRelationalPointerOrEnumeralOverloads() {
7900 UserDefinedBinaryOperators;
7902 for (
unsigned ArgIdx = 0, N = Args.size(); ArgIdx != N; ++ArgIdx) {
7903 if (CandidateTypes[ArgIdx].enumeration_begin() !=
7904 CandidateTypes[ArgIdx].enumeration_end()) {
7906 CEnd = CandidateSet.
end();
7908 if (!
C->Viable || !
C->Function ||
C->Function->getNumParams() != 2)
7911 if (
C->Function->isFunctionTemplateSpecialization())
7915 C->Function->getParamDecl(0)->getType().getUnqualifiedType();
7917 C->Function->getParamDecl(1)->getType().getUnqualifiedType();
7925 UserDefinedBinaryOperators.insert(
7933 llvm::SmallPtrSet<QualType, 8> AddedTypes;
7935 for (
unsigned ArgIdx = 0, N = Args.size(); ArgIdx != N; ++ArgIdx) {
7936 for (BuiltinCandidateTypeSet::iterator
7937 Ptr = CandidateTypes[ArgIdx].pointer_begin(),
7938 PtrEnd = CandidateTypes[ArgIdx].pointer_end();
7939 Ptr != PtrEnd; ++Ptr) {
7944 QualType ParamTypes[2] = { *Ptr, *Ptr };
7947 for (BuiltinCandidateTypeSet::iterator
7948 Enum = CandidateTypes[ArgIdx].enumeration_begin(),
7949 EnumEnd = CandidateTypes[ArgIdx].enumeration_end();
7955 if (!AddedTypes.insert(CanonType).second ||
7956 UserDefinedBinaryOperators.count(std::make_pair(CanonType,
7985 llvm::SmallPtrSet<QualType, 8> AddedTypes;
7987 for (
int Arg = 0; Arg < 2; ++Arg) {
7988 QualType AsymmetricParamTypes[2] = {
7992 for (BuiltinCandidateTypeSet::iterator
7993 Ptr = CandidateTypes[Arg].pointer_begin(),
7994 PtrEnd = CandidateTypes[Arg].pointer_end();
7995 Ptr != PtrEnd; ++Ptr) {
8000 AsymmetricParamTypes[Arg] = *Ptr;
8001 if (Arg == 0 || Op == OO_Plus) {
8006 if (Op == OO_Minus) {
8011 QualType ParamTypes[2] = { *Ptr, *Ptr };
8047 void addGenericBinaryArithmeticOverloads() {
8048 if (!HasArithmeticOrEnumeralCandidateType)
8051 for (
unsigned Left = FirstPromotedArithmeticType;
8052 Left < LastPromotedArithmeticType; ++Left) {
8053 for (
unsigned Right = FirstPromotedArithmeticType;
8054 Right < LastPromotedArithmeticType; ++Right) {
8055 QualType LandR[2] = { getArithmeticType(Left),
8056 getArithmeticType(Right) };
8063 for (BuiltinCandidateTypeSet::iterator
8064 Vec1 = CandidateTypes[0].vector_begin(),
8065 Vec1End = CandidateTypes[0].vector_end();
8066 Vec1 != Vec1End; ++Vec1) {
8067 for (BuiltinCandidateTypeSet::iterator
8068 Vec2 = CandidateTypes[1].vector_begin(),
8069 Vec2End = CandidateTypes[1].vector_end();
8070 Vec2 != Vec2End; ++Vec2) {
8071 QualType LandR[2] = { *Vec1, *Vec2 };
8092 if (!HasArithmeticOrEnumeralCandidateType)
8095 for (
unsigned Left = FirstPromotedIntegralType;
8096 Left < LastPromotedIntegralType; ++Left) {
8097 for (
unsigned Right = FirstPromotedIntegralType;
8098 Right < LastPromotedIntegralType; ++Right) {
8099 QualType LandR[2] = { getArithmeticType(Left),
8100 getArithmeticType(Right) };
8113 void addAssignmentMemberPointerOrEnumeralOverloads() {
8115 llvm::SmallPtrSet<QualType, 8> AddedTypes;
8117 for (
unsigned ArgIdx = 0; ArgIdx < 2; ++ArgIdx) {
8118 for (BuiltinCandidateTypeSet::iterator
8119 Enum = CandidateTypes[ArgIdx].enumeration_begin(),
8120 EnumEnd = CandidateTypes[ArgIdx].enumeration_end();
8128 for (BuiltinCandidateTypeSet::iterator
8129 MemPtr = CandidateTypes[ArgIdx].member_pointer_begin(),
8130 MemPtrEnd = CandidateTypes[ArgIdx].member_pointer_end();
8131 MemPtr != MemPtrEnd; ++MemPtr) {
8156 void addAssignmentPointerOverloads(
bool isEqualOp) {
8158 llvm::SmallPtrSet<QualType, 8> AddedTypes;
8160 for (BuiltinCandidateTypeSet::iterator
8161 Ptr = CandidateTypes[0].pointer_begin(),
8162 PtrEnd = CandidateTypes[0].pointer_end();
8163 Ptr != PtrEnd; ++Ptr) {
8167 else if (!(*Ptr)->getPointeeType()->isObjectType())
8178 bool NeedVolatile = !(*Ptr).isVolatileQualified() &&
8188 if (!(*Ptr).isRestrictQualified() &&
8201 (Qualifiers::Volatile |
8202 Qualifiers::Restrict)));
8210 for (BuiltinCandidateTypeSet::iterator
8211 Ptr = CandidateTypes[1].pointer_begin(),
8212 PtrEnd = CandidateTypes[1].pointer_end();
8213 Ptr != PtrEnd; ++Ptr) {
8227 bool NeedVolatile = !(*Ptr).isVolatileQualified() &&
8237 if (!(*Ptr).isRestrictQualified() &&
8250 (Qualifiers::Volatile |
8251 Qualifiers::Restrict)));
8272 void addAssignmentArithmeticOverloads(
bool isEqualOp) {
8273 if (!HasArithmeticOrEnumeralCandidateType)
8276 for (
unsigned Left = 0; Left < NumArithmeticTypes; ++Left) {
8277 for (
unsigned Right = FirstPromotedArithmeticType;
8278 Right < LastPromotedArithmeticType; ++Right) {
8280 ParamTypes[1] = getArithmeticType(Right);
8300 for (BuiltinCandidateTypeSet::iterator
8301 Vec1 = CandidateTypes[0].vector_begin(),
8302 Vec1End = CandidateTypes[0].vector_end();
8303 Vec1 != Vec1End; ++Vec1) {
8304 for (BuiltinCandidateTypeSet::iterator
8305 Vec2 = CandidateTypes[1].vector_begin(),
8306 Vec2End = CandidateTypes[1].vector_end();
8307 Vec2 != Vec2End; ++Vec2) {
8309 ParamTypes[1] = *Vec2;
8338 void addAssignmentIntegralOverloads() {
8339 if (!HasArithmeticOrEnumeralCandidateType)
8342 for (
unsigned Left = FirstIntegralType; Left < LastIntegralType; ++Left) {
8343 for (
unsigned Right = FirstPromotedIntegralType;
8344 Right < LastPromotedIntegralType; ++Right) {
8346 ParamTypes[1] = getArithmeticType(Right);
8354 ParamTypes[0] = getArithmeticType(Left);
8370 void addExclaimOverload() {
8376 void addAmpAmpOrPipePipeOverload() {
8393 void addSubscriptOverloads() {
8394 for (BuiltinCandidateTypeSet::iterator
8395 Ptr = CandidateTypes[0].pointer_begin(),
8396 PtrEnd = CandidateTypes[0].pointer_end();
8397 Ptr != PtrEnd; ++Ptr) {
8407 for (BuiltinCandidateTypeSet::iterator
8408 Ptr = CandidateTypes[1].pointer_begin(),
8409 PtrEnd = CandidateTypes[1].pointer_end();
8410 Ptr != PtrEnd; ++Ptr) {
8430 void addArrowStarOverloads() {
8431 for (BuiltinCandidateTypeSet::iterator
8432 Ptr = CandidateTypes[0].pointer_begin(),
8433 PtrEnd = CandidateTypes[0].pointer_end();
8434 Ptr != PtrEnd; ++Ptr) {
8439 if (!isa<RecordType>(C1))
8448 for (BuiltinCandidateTypeSet::iterator
8449 MemPtr = CandidateTypes[1].member_pointer_begin(),
8450 MemPtrEnd = CandidateTypes[1].member_pointer_end();
8451 MemPtr != MemPtrEnd; ++MemPtr) {
8457 QualType ParamTypes[2] = { *Ptr, *MemPtr };
8482 void addConditionalOperatorOverloads() {
8484 llvm::SmallPtrSet<QualType, 8> AddedTypes;
8486 for (
unsigned ArgIdx = 0; ArgIdx < 2; ++ArgIdx) {
8487 for (BuiltinCandidateTypeSet::iterator
8488 Ptr = CandidateTypes[ArgIdx].pointer_begin(),
8489 PtrEnd = CandidateTypes[ArgIdx].pointer_end();
8490 Ptr != PtrEnd; ++Ptr) {
8494 QualType ParamTypes[2] = { *Ptr, *Ptr };
8498 for (BuiltinCandidateTypeSet::iterator
8499 MemPtr = CandidateTypes[ArgIdx].member_pointer_begin(),
8500 MemPtrEnd = CandidateTypes[ArgIdx].member_pointer_end();
8501 MemPtr != MemPtrEnd; ++MemPtr) {
8505 QualType ParamTypes[2] = { *MemPtr, *MemPtr };
8510 for (BuiltinCandidateTypeSet::iterator
8511 Enum = CandidateTypes[ArgIdx].enumeration_begin(),
8512 EnumEnd = CandidateTypes[ArgIdx].enumeration_end();
8544 VisibleTypeConversionsQuals.
addConst();
8545 for (
unsigned ArgIdx = 0, N = Args.size(); ArgIdx != N; ++ArgIdx)
8548 bool HasNonRecordCandidateType =
false;
8549 bool HasArithmeticOrEnumeralCandidateType =
false;
8551 for (
unsigned ArgIdx = 0, N = Args.size(); ArgIdx != N; ++ArgIdx) {
8552 CandidateTypes.emplace_back(*
this);
8553 CandidateTypes[ArgIdx].AddTypesConvertedFrom(Args[ArgIdx]->getType(),
8556 (Op == OO_Exclaim ||
8559 VisibleTypeConversionsQuals);
8560 HasNonRecordCandidateType = HasNonRecordCandidateType ||
8561 CandidateTypes[ArgIdx].hasNonRecordTypes();
8562 HasArithmeticOrEnumeralCandidateType =
8563 HasArithmeticOrEnumeralCandidateType ||
8564 CandidateTypes[ArgIdx].hasArithmeticOrEnumeralTypes();
8572 if (!HasNonRecordCandidateType &&
8573 !(Op == OO_Exclaim || Op == OO_AmpAmp || Op == OO_PipePipe))
8577 BuiltinOperatorOverloadBuilder OpBuilder(*
this, Args,
8578 VisibleTypeConversionsQuals,
8579 HasArithmeticOrEnumeralCandidateType,
8580 CandidateTypes, CandidateSet);
8586 llvm_unreachable(
"Expected an overloaded operator");
8591 case OO_Array_Delete:
8594 "Special operators don't use AddBuiltinOperatorCandidates");
8606 if (Args.size() == 1)
8607 OpBuilder.addUnaryPlusPointerOverloads();
8611 if (Args.size() == 1) {
8612 OpBuilder.addUnaryPlusOrMinusArithmeticOverloads();
8614 OpBuilder.addBinaryPlusOrMinusPointerOverloads(Op);
8615 OpBuilder.addGenericBinaryArithmeticOverloads();
8620 if (Args.size() == 1)
8621 OpBuilder.addUnaryStarPointerOverloads();
8623 OpBuilder.addGenericBinaryArithmeticOverloads();
8627 OpBuilder.addGenericBinaryArithmeticOverloads();
8632 OpBuilder.addPlusPlusMinusMinusArithmeticOverloads(Op);
8633 OpBuilder.addPlusPlusMinusMinusPointerOverloads();
8637 case OO_ExclaimEqual:
8638 OpBuilder.addEqualEqualOrNotEqualMemberPointerOrNullptrOverloads();
8644 case OO_GreaterEqual:
8645 OpBuilder.addRelationalPointerOrEnumeralOverloads();
8646 OpBuilder.addGenericBinaryArithmeticOverloads();
8653 case OO_GreaterGreater:
8654 OpBuilder.addBinaryBitwiseArithmeticOverloads(Op);
8658 if (Args.size() == 1)
8664 OpBuilder.addBinaryBitwiseArithmeticOverloads(Op);
8668 OpBuilder.addUnaryTildePromotedIntegralOverloads();
8672 OpBuilder.addAssignmentMemberPointerOrEnumeralOverloads();
8677 OpBuilder.addAssignmentPointerOverloads(Op == OO_Equal);
8682 OpBuilder.addAssignmentArithmeticOverloads(Op == OO_Equal);
8685 case OO_PercentEqual:
8686 case OO_LessLessEqual:
8687 case OO_GreaterGreaterEqual:
8691 OpBuilder.addAssignmentIntegralOverloads();
8695 OpBuilder.addExclaimOverload();
8700 OpBuilder.addAmpAmpOrPipePipeOverload();
8704 OpBuilder.addSubscriptOverloads();
8708 OpBuilder.addArrowStarOverloads();
8711 case OO_Conditional:
8712 OpBuilder.addConditionalOperatorOverloads();
8713 OpBuilder.addGenericBinaryArithmeticOverloads();
8731 bool PartialOverloading) {
8746 CandEnd = CandidateSet.
end();
8747 Cand != CandEnd; ++Cand)
8748 if (Cand->Function) {
8749 Fns.
erase(Cand->Function);
8759 if (ExplicitTemplateArgs)
8763 PartialOverloading);
8766 FoundDecl, ExplicitTemplateArgs,
8767 Args, CandidateSet, PartialOverloading);
8789 bool Cand1Attr = Cand1->
hasAttr<EnableIfAttr>();
8790 bool Cand2Attr = Cand2->
hasAttr<EnableIfAttr>();
8791 if (!Cand1Attr || !Cand2Attr) {
8792 if (Cand1Attr == Cand2Attr)
8793 return Comparison::Equal;
8794 return Cand1Attr ? Comparison::Better : Comparison::Worse;
8805 if (Cand1Attrs.size() < Cand2Attrs.size())
8806 return Comparison::Worse;
8808 auto Cand1I = Cand1Attrs.begin();
8809 llvm::FoldingSetNodeID Cand1ID, Cand2ID;
8810 for (
auto &Cand2A : Cand2Attrs) {
8814 auto &Cand1A = *Cand1I++;
8815 Cand1A->getCond()->Profile(Cand1ID, S.
getASTContext(),
true);
8816 Cand2A->getCond()->Profile(Cand2ID, S.
getASTContext(),
true);
8817 if (Cand1ID != Cand2ID)
8818 return Comparison::Worse;
8821 return Cand1I == Cand1Attrs.end() ? Comparison::Equal : Comparison::Better;
8829 bool UserDefinedConversion) {
8843 unsigned StartArg = 0;
8850 return ICS.isStandard() &&
8862 assert(Cand2.
Conversions.size() == NumArgs &&
"Overload candidate mismatch");
8863 bool HasBetterConversion =
false;
8864 for (
unsigned ArgIdx = StartArg; ArgIdx < NumArgs; ++ArgIdx) {
8865 bool Cand1Bad = IsIllFormedConversion(Cand1.
Conversions[ArgIdx]);
8866 bool Cand2Bad = IsIllFormedConversion(Cand2.
Conversions[ArgIdx]);
8867 if (Cand1Bad != Cand2Bad) {
8870 HasBetterConversion =
true;
8874 if (HasBetterConversion)
8881 for (
unsigned ArgIdx = StartArg; ArgIdx < NumArgs; ++ArgIdx) {
8887 HasBetterConversion =
true;
8902 if (HasBetterConversion)
8912 isa<CXXConversionDecl>(Cand1.
Function) &&
8913 isa<CXXConversionDecl>(Cand2.
Function)) {
8934 auto *Guide1 = dyn_cast_or_null<CXXDeductionGuideDecl>(Cand1.
Function);
8935 auto *Guide2 = dyn_cast_or_null<CXXDeductionGuideDecl>(Cand2.
Function);
8936 if (Guide1 && Guide2 && Guide1->isImplicit() != Guide2->isImplicit())
8937 return Guide2->isImplicit();
8941 bool Cand1IsSpecialization = Cand1.
Function &&
8943 bool Cand2IsSpecialization = Cand2.
Function &&
8945 if (Cand1IsSpecialization != Cand2IsSpecialization)
8946 return Cand2IsSpecialization;
8952 if (Cand1IsSpecialization && Cand2IsSpecialization) {
8966 bool Cand1IsInherited =
8968 bool Cand2IsInherited =
8970 if (Cand1IsInherited != Cand2IsInherited)
8971 return Cand2IsInherited;
8972 else if (Cand1IsInherited) {
8973 assert(Cand2IsInherited);
8976 if (Cand1Class->isDerivedFrom(Cand2Class))
8978 if (Cand2Class->isDerivedFrom(Cand1Class))
8986 if (Cmp != Comparison::Equal)
8987 return Cmp == Comparison::Better;
8996 bool HasPS1 = Cand1.
Function !=
nullptr &&
8998 bool HasPS2 = Cand2.
Function !=
nullptr &&
9000 return HasPS1 != HasPS2 && HasPS1;
9012 auto *VA = dyn_cast_or_null<ValueDecl>(A);
9013 auto *VB = dyn_cast_or_null<ValueDecl>(B);
9019 if (!VA->getDeclContext()->getRedeclContext()->Equals(
9020 VB->getDeclContext()->getRedeclContext()) ||
9023 VA->isExternallyVisible() || VB->isExternallyVisible())
9036 if (
auto *EA = dyn_cast<EnumConstantDecl>(VA)) {
9037 if (
auto *EB = dyn_cast<EnumConstantDecl>(VB)) {
9040 auto *EnumA = cast<EnumDecl>(EA->getDeclContext());
9041 auto *EnumB = cast<EnumDecl>(EB->getDeclContext());
9042 if (EnumA->hasNameForLinkage() || EnumB->hasNameForLinkage() ||
9044 EnumB->getIntegerType()))
9047 return llvm::APSInt::isSameValue(EA->getInitVal(), EB->getInitVal());
9057 Diag(Loc, diag::ext_equivalent_internal_linkage_decl_in_modules) << D;
9063 for (
auto *E : Equiv) {
9065 Diag(E->getLocation(), diag::note_equivalent_internal_linkage_decl)
9083 bool UserDefinedConversion) {
9085 std::transform(
begin(),
end(), std::back_inserter(Candidates),
9097 bool ContainsSameSideCandidate =
9103 if (ContainsSameSideCandidate) {
9109 llvm::erase_if(Candidates, IsWrongSideCandidate);
9115 for (
auto *Cand : Candidates)
9118 UserDefinedConversion))
9129 for (
auto *Cand : Candidates) {
9133 UserDefinedConversion)) {
9136 EquivalentCands.push_back(Cand->
Function);
9146 if (Best->Function &&
9147 (Best->Function->isDeleted() ||
9151 if (!EquivalentCands.empty())
9164 oc_function_template,
9166 oc_constructor_template,
9167 oc_implicit_default_constructor,
9168 oc_implicit_copy_constructor,
9169 oc_implicit_move_constructor,
9170 oc_implicit_copy_assignment,
9171 oc_implicit_move_assignment,
9172 oc_inherited_constructor,
9173 oc_inherited_constructor_template
9178 std::string &Description) {
9188 if (!Ctor->isImplicit()) {
9189 if (isa<ConstructorUsingShadowDecl>(Found))
9190 return isTemplate ? oc_inherited_constructor_template
9191 : oc_inherited_constructor;
9193 return isTemplate ? oc_constructor_template : oc_constructor;
9196 if (Ctor->isDefaultConstructor())
9197 return oc_implicit_default_constructor;
9199 if (Ctor->isMoveConstructor())
9200 return oc_implicit_move_constructor;
9202 assert(Ctor->isCopyConstructor() &&
9203 "unexpected sort of implicit constructor");
9204 return oc_implicit_copy_constructor;
9210 if (!Meth->isImplicit())
9211 return isTemplate ? oc_method_template : oc_method;
9213 if (Meth->isMoveAssignmentOperator())
9214 return oc_implicit_move_assignment;
9216 if (Meth->isCopyAssignmentOperator())
9217 return oc_implicit_copy_assignment;
9219 assert(isa<CXXConversionDecl>(Meth) &&
"expected conversion");
9223 return isTemplate ? oc_function_template : oc_function;
9226 void MaybeEmitInheritedConstructorNote(
Sema &S,
Decl *FoundDecl) {
9229 if (
auto *Shadow = dyn_cast<ConstructorUsingShadowDecl>(FoundDecl))
9231 diag::note_ovl_candidate_inherited_constructor)
9232 << Shadow->getNominatedBaseClass();
9241 if (!EnableIf->getCond()->EvaluateAsBooleanCondition(AlwaysTrue, Ctx))
9258 bool InOverloadResolution,
9262 if (InOverloadResolution)
9264 diag::note_addrof_ovl_candidate_disabled_by_enable_if_attr);
9266 S.
Diag(Loc, diag::err_addrof_function_disabled_by_enable_if_attr) << FD;
9272 return P->hasAttr<PassObjectSizeAttr>();
9280 if (InOverloadResolution)
9282 diag::note_ovl_candidate_has_pass_object_size_params)
9285 S.
Diag(Loc, diag::err_address_of_function_with_pass_object_size_params)
9308 QualType DestType,
bool TakingAddress) {
9319 MaybeEmitInheritedConstructorNote(*
this, Found);
9325 bool TakingAddress) {
9335 dyn_cast<FunctionTemplateDecl>((*I)->getUnderlyingDecl()) ) {
9339 = dyn_cast<FunctionDecl>((*I)->getUnderlyingDecl()) ) {
9352 S.
Diag(CaretLoc, PDiag)
9358 unsigned CandsShown = 0;
9361 if (CandsShown >= 4 && ShowOverloads ==
Ovl_Best)
9371 unsigned I,
bool TakingCandidateAddress) {
9373 assert(Conv.
isBad());
9374 assert(Cand->
Function &&
"for now, candidate must be a function");
9380 bool isObjectArgument =
false;
9381 if (isa<CXXMethodDecl>(Fn) && !isa<CXXConstructorDecl>(Fn)) {
9383 isObjectArgument =
true;
9390 ClassifyOverloadCandidate(S, Cand->
FoundDecl, Fn, FnDesc);
9397 assert(FromExpr &&
"overload set argument came from implicit argument?");
9399 if (isa<UnaryOperator>(E))
9404 << (
unsigned) FnKind << FnDesc
9406 << ToTy << Name << I+1;
9407 MaybeEmitInheritedConstructorNote(S, Cand->
FoundDecl);
9416 CToTy = RT->getPointeeType();
9421 CFromTy = FromPT->getPointeeType();
9422 CToTy = ToPT->getPointeeType();
9433 << (
unsigned) FnKind << FnDesc
9438 << (
unsigned) isObjectArgument << I+1;
9439 MaybeEmitInheritedConstructorNote(S, Cand->
FoundDecl);
9445 << (
unsigned) FnKind << FnDesc
9449 << (
unsigned) isObjectArgument << I+1;
9450 MaybeEmitInheritedConstructorNote(S, Cand->
FoundDecl);
9456 << (
unsigned) FnKind << FnDesc
9460 << (
unsigned) isObjectArgument << I+1;
9461 MaybeEmitInheritedConstructorNote(S, Cand->
FoundDecl);
9467 << (
unsigned) FnKind << FnDesc
9470 MaybeEmitInheritedConstructorNote(S, Cand->
FoundDecl);
9475 assert(CVR &&
"unexpected qualifiers mismatch");
9477 if (isObjectArgument) {
9479 << (
unsigned) FnKind << FnDesc
9481 << FromTy << (CVR - 1);
9484 << (
unsigned) FnKind << FnDesc
9486 << FromTy << (CVR - 1) << I+1;
9488 MaybeEmitInheritedConstructorNote(S, Cand->
FoundDecl);
9494 if (FromExpr && isa<InitListExpr>(FromExpr)) {
9496 << (
unsigned) FnKind << FnDesc
9498 << FromTy << ToTy << (
unsigned) isObjectArgument << I+1;
9499 MaybeEmitInheritedConstructorNote(S, Cand->
FoundDecl);
9511 S.
Diag(Fn->
getLocation(), diag::note_ovl_candidate_bad_conv_incomplete)
9512 << (
unsigned) FnKind << FnDesc
9514 << FromTy << ToTy << (
unsigned) isObjectArgument << I+1
9517 MaybeEmitInheritedConstructorNote(S, Cand->
FoundDecl);
9522 unsigned BaseToDerivedConversion = 0;
9525 if (ToPtrTy->getPointeeType().isAtLeastAsQualifiedAs(
9526 FromPtrTy->getPointeeType()) &&
9527 !FromPtrTy->getPointeeType()->isIncompleteType() &&
9528 !ToPtrTy->getPointeeType()->isIncompleteType() &&
9530 FromPtrTy->getPointeeType()))
9531 BaseToDerivedConversion = 1;
9539 if (ToPtrTy->getPointeeType().isAtLeastAsQualifiedAs(
9540 FromPtrTy->getPointeeType()) &&
9541 FromIface->isSuperClassOf(ToIface))
9542 BaseToDerivedConversion = 2;
9544 if (ToRefTy->getPointeeType().isAtLeastAsQualifiedAs(FromTy) &&
9546 !ToRefTy->getPointeeType()->isIncompleteType() &&
9548 BaseToDerivedConversion = 3;
9553 << (
unsigned) FnKind << FnDesc
9555 << (
unsigned) isObjectArgument << I + 1;
9556 MaybeEmitInheritedConstructorNote(S, Cand->
FoundDecl);
9561 if (BaseToDerivedConversion) {
9563 diag::note_ovl_candidate_bad_base_to_derived_conv)
9564 << (
unsigned) FnKind << FnDesc
9566 << (BaseToDerivedConversion - 1)
9567 << FromTy << ToTy << I+1;
9568 MaybeEmitInheritedConstructorNote(S, Cand->
FoundDecl);
9572 if (isa<ObjCObjectPointerType>(CFromTy) &&
9573 isa<PointerType>(CToTy)) {
9578 << (
unsigned) FnKind << FnDesc
9580 << FromTy << ToTy << (
unsigned) isObjectArgument << I+1;
9581 MaybeEmitInheritedConstructorNote(S, Cand->
FoundDecl);
9586 if (TakingCandidateAddress &&
9592 FDiag << (
unsigned) FnKind << FnDesc
9594 << FromTy << ToTy << (
unsigned) isObjectArgument << I + 1
9598 for (std::vector<FixItHint>::iterator HI = Cand->
Fix.
Hints.begin(),
9599 HE = Cand->
Fix.
Hints.end(); HI != HE; ++HI)
9603 MaybeEmitInheritedConstructorNote(S, Cand->
FoundDecl);
9623 if (NumArgs < MinParams) {
9638 unsigned NumFormalArgs) {
9639 assert(isa<FunctionDecl>(D) &&
9640 "The templated declaration should at least be a function"
9641 " when diagnosing bad template argument deduction due to too many"
9642 " or too few arguments");
9651 unsigned mode, modeCount;
9652 if (NumFormalArgs < MinParams) {
9653 if (MinParams != FnTy->getNumParams() || FnTy->isVariadic() ||
9654 FnTy->isTemplateVariadic())
9658 modeCount = MinParams;
9660 if (MinParams != FnTy->getNumParams())
9664 modeCount = FnTy->getNumParams();
9667 std::string Description;
9669 ClassifyOverloadCandidate(S, Found, Fn, Description);
9678 << mode << modeCount << NumFormalArgs;
9679 MaybeEmitInheritedConstructorNote(S, Found);
9684 unsigned NumFormalArgs) {
9692 llvm_unreachable(
"Unsupported: Getting the described template declaration"
9693 " for bad deduction diagnosis");
9700 bool TakingCandidateAddress) {
9706 switch (DeductionFailure.
Result) {
9708 llvm_unreachable(
"TDK_success while diagnosing bad deduction");
9711 assert(ParamD &&
"no parameter found for incomplete deduction result");
9713 diag::note_ovl_candidate_incomplete_deduction)
9715 MaybeEmitInheritedConstructorNote(S, Found);
9720 assert(ParamD &&
"no parameter found for bad qualifiers deduction result");
9738 S.
Diag(Templated->
getLocation(), diag::note_ovl_candidate_underqualified)
9740 MaybeEmitInheritedConstructorNote(S, Found);
9745 assert(ParamD &&
"no parameter found for inconsistent deduction result");
9747 if (isa<TemplateTypeParmDecl>(ParamD))
9749 else if (isa<NonTypeTemplateParmDecl>(ParamD)) {
9759 diag::note_ovl_candidate_inconsistent_deduction_types)
9762 MaybeEmitInheritedConstructorNote(S, Found);
9772 diag::note_ovl_candidate_inconsistent_deduction)
9775 MaybeEmitInheritedConstructorNote(S, Found);
9780 assert(ParamD &&
"no parameter found for invalid explicit arguments");
9783 diag::note_ovl_candidate_explicit_arg_mismatch_named)
9788 index = TTP->getIndex();
9790 = dyn_cast<NonTypeTemplateParmDecl>(ParamD))
9791 index = NTTP->getIndex();
9793 index = cast<TemplateTemplateParmDecl>(ParamD)->getIndex();
9795 diag::note_ovl_candidate_explicit_arg_mismatch_unnamed)
9798 MaybeEmitInheritedConstructorNote(S, Found);
9808 diag::note_ovl_candidate_instantiation_depth);
9809 MaybeEmitInheritedConstructorNote(S, Found);
9817 TemplateArgString =
" ";
9824 if (PDiag && PDiag->second.getDiagID() ==
9825 diag::err_typename_nested_not_found_enable_if) {
9828 S.
Diag(PDiag->first, diag::note_ovl_candidate_disabled_by_enable_if)
9829 <<
"'enable_if'" << TemplateArgString;
9834 if (PDiag && PDiag->second.getDiagID() ==
9835 diag::err_typename_nested_not_found_requirement) {
9837 diag::note_ovl_candidate_disabled_by_requirement)
9838 << PDiag->second.getStringArg(0) << TemplateArgString;
9848 SFINAEArgString =
": ";
9854 diag::note_ovl_candidate_substitution_failure)
9855 << TemplateArgString << SFINAEArgString << R;
9856 MaybeEmitInheritedConstructorNote(S, Found);
9866 TemplateArgString =
" ";
9871 S.
Diag(Templated->
getLocation(), diag::note_ovl_candidate_deduced_mismatch)
9874 << TemplateArgString
9898 diag::note_ovl_candidate_non_deduced_mismatch_qualified)
9905 if (TakingCandidateAddress && isa<FunctionDecl>(Templated) &&
9914 diag::note_ovl_candidate_non_deduced_mismatch)
9915 << FirstTA << SecondTA;
9921 S.
Diag(Templated->
getLocation(), diag::note_ovl_candidate_bad_deduction);
9922 MaybeEmitInheritedConstructorNote(S, Found);
9926 diag::note_cuda_ovl_candidate_target_mismatch);
9934 bool TakingCandidateAddress) {
9954 ClassifyOverloadCandidate(S, Cand->
FoundDecl, Callee, FnDesc);
9956 S.
Diag(Callee->getLocation(), diag::note_ovl_candidate_bad_target)
9957 << (
unsigned)FnKind << CalleeTarget << CallerTarget;
9969 case oc_implicit_default_constructor:
9972 case oc_implicit_copy_constructor:
9975 case oc_implicit_move_constructor:
9978 case oc_implicit_copy_assignment:
9981 case oc_implicit_move_assignment:
9986 bool ConstRHS =
false;
9990 ConstRHS = RT->getPointeeType().isConstQualified();
10005 diag::note_ovl_candidate_disabled_by_function_cond_attr)
10006 << Attr->getCond()->getSourceRange() << Attr->getMessage();
10013 diag::note_ovl_candidate_disabled_by_extension);
10031 bool TakingCandidateAddress) {
10037 std::string FnDesc;
10039 ClassifyOverloadCandidate(S, Cand->
FoundDecl, Fn, FnDesc);
10042 << FnKind << FnDesc
10044 MaybeEmitInheritedConstructorNote(S, Cand->
FoundDecl);
10060 TakingCandidateAddress);
10063 S.
Diag(Fn->
getLocation(), diag::note_ovl_candidate_illegal_constructor)
10065 MaybeEmitInheritedConstructorNote(S, Cand->
FoundDecl);
10076 for (
unsigned N = Cand->
Conversions.size(); I != N; ++
I)
10097 if (cast<CXXConstructorDecl>(Fn)->isCopyOrMoveConstructor())
10100 diag::note_ovl_candidate_inherited_constructor_slice)
10103 MaybeEmitInheritedConstructorNote(S, Cand->
FoundDecl);
10109 assert(!Available);
10120 bool isLValueReference =
false;
10121 bool isRValueReference =
false;
10122 bool isPointer =
false;
10126 isLValueReference =
true;
10130 isRValueReference =
true;
10150 assert(Cand->
Conversions.size() <= 2 &&
"builtin operator is not binary");
10151 std::string TypeStr(
"operator");
10157 S.
Diag(OpLoc, diag::note_ovl_builtin_unary_candidate) << TypeStr;
10162 S.
Diag(OpLoc, diag::note_ovl_builtin_binary_candidate) << TypeStr;
10169 if (ICS.
isBad())
break;
10173 S, OpLoc, S.
PDiag(diag::note_ambiguous_type_conversion));
10189 llvm_unreachable(
"non-deduction failure while diagnosing bad deduction");
10217 llvm_unreachable(
"Unhandled deduction result");
10221 struct CompareOverloadCandidatesForDisplay {
10227 : S(S), NumArgs(nArgs) {}
10232 if (L == R)
return false;
10236 if (!R->
Viable)
return true;
10257 if (LDist == RDist) {
10266 return LDist < RDist;
10284 numLFixes = (numLFixes == 0) ?
UINT_MAX : numLFixes;
10285 numRFixes = (numRFixes == 0) ?
UINT_MAX : numRFixes;
10286 if (numLFixes != numRFixes) {
10287 return numLFixes < numRFixes;
10294 int leftBetter = 0;
10312 if (leftBetter > 0)
return true;
10313 if (leftBetter < 0)
return false;
10355 bool Unfixable =
false;
10363 assert(ConvIdx != ConvCount &&
"no bad conversion in candidate");
10364 if (Cand->
Conversions[ConvIdx].isInitialized() &&
10373 bool SuppressUserConversions =
false;
10375 unsigned ConvIdx = 0;
10389 if (isa<CXXMethodDecl>(Cand->
Function) &&
10390 !isa<CXXConstructorDecl>(Cand->
Function)) {
10396 assert(ConvCount <= 3);
10401 for (
unsigned ArgIdx = 0; ConvIdx != ConvCount; ++ConvIdx, ++ArgIdx) {
10402 if (Cand->
Conversions[ConvIdx].isInitialized()) {
10404 }
else if (ArgIdx < ParamTypes.size()) {
10405 if (ParamTypes[ArgIdx]->isDependentType())
10406 Cand->
Conversions[ConvIdx].setAsIdentityConversion(
10407 Args[ArgIdx]->getType());
10411 SuppressUserConversions,
10416 if (!Unfixable && Cand->
Conversions[ConvIdx].isBad())
10435 for (
iterator Cand =
begin(), LastCand =
end(); Cand != LastCand; ++Cand) {
10436 if (!Filter(*Cand))
10439 Cands.push_back(Cand);
10442 if (Cand->Function || Cand->IsSurrogate)
10443 Cands.push_back(Cand);
10449 std::sort(Cands.begin(), Cands.end(),
10450 CompareOverloadCandidatesForDisplay(S, OpLoc, Args.size()));
10452 bool ReportedAmbiguousConversions =
false;
10456 unsigned CandsShown = 0;
10457 for (I = Cands.begin(), E = Cands.end(); I !=
E; ++
I) {
10463 if (CandsShown >= 4 && ShowOverloads ==
Ovl_Best) {
10475 "Non-viable built-in candidates are not added to Cands.");
10482 if (!ReportedAmbiguousConversions) {
10484 ReportedAmbiguousConversions =
true;
10493 S.
Diag(OpLoc, diag::note_ovl_too_many_candidates) << int(E - I);
10503 struct CompareTemplateSpecCandidatesForDisplay {
10505 CompareTemplateSpecCandidatesForDisplay(
Sema &S) : S(S) {}
10539 bool ForTakingAddress) {
10544 void TemplateSpecCandidateSet::destroyCandidates() {
10546 i->DeductionFailure.Destroy();
10551 destroyCandidates();
10552 Candidates.clear();
10565 Cands.reserve(
size());
10566 for (
iterator Cand =
begin(), LastCand =
end(); Cand != LastCand; ++Cand) {
10567 if (Cand->Specialization)
10568 Cands.push_back(Cand);
10573 std::sort(Cands.begin(), Cands.end(),
10574 CompareTemplateSpecCandidatesForDisplay(S));
10581 unsigned CandsShown = 0;
10582 for (I = Cands.begin(), E = Cands.end(); I !=
E; ++
I) {
10588 if (CandsShown >= 4 && ShowOverloads ==
Ovl_Best)
10593 "Non-matching built-in candidates are not added to Cands.");
10598 S.
Diag(Loc, diag::note_ovl_too_many_candidates) << int(E - I);
10608 QualType Ret = PossiblyAFunctionType;
10624 bool Complain =
true) {
10641 class AddressOfFunctionResolver {
10651 bool TargetTypeIsNonStaticMemberFunction;
10652 bool FoundNonTemplateFunction;
10653 bool StaticMemberFunctionFromBoundPointer;
10654 bool HasComplained;
10663 AddressOfFunctionResolver(
Sema &S,
Expr *SourceExpr,
10664 const QualType &TargetType,
bool Complain)
10665 : S(S), SourceExpr(SourceExpr), TargetType(TargetType),
10666 Complain(Complain),
Context(S.getASTContext()),
10667 TargetTypeIsNonStaticMemberFunction(
10669 FoundNonTemplateFunction(
false),
10670 StaticMemberFunctionFromBoundPointer(
false),
10671 HasComplained(
false),
10673 OvlExpr(OvlExprInfo.Expression),
10674 FailedCandidates(OvlExpr->getNameLoc(),
true) {
10675 ExtractUnqualifiedFunctionTypeFromTargetType();
10677 if (TargetFunctionType->isFunctionType()) {
10679 if (!UME->isImplicitAccess() &&
10681 StaticMemberFunctionFromBoundPointer =
true;
10682 }
else if (OvlExpr->hasExplicitTemplateArgs()) {
10685 OvlExpr,
false, &dap)) {
10687 if (!Method->isStatic()) {
10691 TargetTypeIsNonStaticMemberFunction =
true;
10695 if (!OvlExprInfo.HasFormOfMemberPointer)
10699 Matches.push_back(std::make_pair(dap, Fn));
10704 if (OvlExpr->hasExplicitTemplateArgs())
10705 OvlExpr->copyTemplateArgumentsInto(OvlExplicitTemplateArgs);
10707 if (FindAllFunctionsThatMatchTargetTypeExactly()) {
10710 if (
Matches.size() > 1 && !eliminiateSuboptimalOverloadCandidates()) {
10711 if (FoundNonTemplateFunction)
10712 EliminateAllTemplateMatches();
10714 EliminateAllExceptMostSpecializedTemplate();
10719 EliminateSuboptimalCudaMatches();
10722 bool hasComplained()
const {
return HasComplained; }
10725 bool candidateHasExactlyCorrectType(
const FunctionDecl *FD) {
10737 return candidateHasExactlyCorrectType(A) &&
10738 (!candidateHasExactlyCorrectType(B) ||
10744 bool eliminiateSuboptimalOverloadCandidates() {
10749 if (isBetterCandidate(I->second, Best->second))
10753 auto IsBestOrInferiorToBest = [
this, BestFn](
10754 const std::pair<DeclAccessPair, FunctionDecl *> &Pair) {
10755 return BestFn == Pair.second || isBetterCandidate(BestFn, Pair.second);
10760 if (!std::all_of(
Matches.begin(),
Matches.end(), IsBestOrInferiorToBest))
10767 bool isTargetTypeAFunction()
const {
10768 return TargetFunctionType->isFunctionType();
10776 void inline ExtractUnqualifiedFunctionTypeFromTargetType() {
10787 if (Method->isStatic() == TargetTypeIsNonStaticMemberFunction)
10790 else if (TargetTypeIsNonStaticMemberFunction)
10803 &OvlExplicitTemplateArgs,
10804 TargetFunctionType, Specialization,
10807 FailedCandidates.addCandidate()
10823 Matches.push_back(std::make_pair(CurAccessFunPair, Specialization));
10827 bool AddMatchingNonTemplateFunction(
NamedDecl* Fn,
10832 if (Method->isStatic() == TargetTypeIsNonStaticMemberFunction)
10835 else if (TargetTypeIsNonStaticMemberFunction)
10838 if (
FunctionDecl *FunDecl = dyn_cast<FunctionDecl>(Fn)) {
10848 HasComplained |= Complain;
10857 candidateHasExactlyCorrectType(FunDecl)) {
10858 Matches.push_back(std::make_pair(
10859 CurAccessFunPair, cast<FunctionDecl>(FunDecl->getCanonicalDecl())));
10860 FoundNonTemplateFunction =
true;
10868 bool FindAllFunctionsThatMatchTargetTypeExactly() {
10873 if (IsInvalidFormOfPointerToMemberFunction())
10877 E = OvlExpr->decls_end();
10889 = dyn_cast<FunctionTemplateDecl>(Fn)) {
10890 if (AddMatchingTemplateFunction(FunctionTemplate, I.getPair()))
10894 else if (!OvlExpr->hasExplicitTemplateArgs() &&
10895 AddMatchingNonTemplateFunction(Fn, I.getPair()))
10898 assert(Ret ||
Matches.empty());
10902 void EliminateAllExceptMostSpecializedTemplate() {
10915 for (
unsigned I = 0, E =
Matches.size(); I !=
E; ++
I)
10921 MatchesCopy.
begin(), MatchesCopy.
end(), FailedCandidates,
10923 S.
PDiag(diag::err_addr_ovl_ambiguous)
10924 <<
Matches[0].second->getDeclName(),
10925 S.
PDiag(diag::note_ovl_candidate)
10926 << (
unsigned)oc_function_template,
10927 Complain, TargetFunctionType);
10929 if (Result != MatchesCopy.
end()) {
10932 Matches[0].second = cast<FunctionDecl>(*Result);
10935 HasComplained |= Complain;
10938 void EliminateAllTemplateMatches() {
10941 for (
unsigned I = 0, N =
Matches.size(); I != N; ) {
10942 if (
Matches[I].second->getPrimaryTemplate() ==
nullptr)
10951 void EliminateSuboptimalCudaMatches() {
10956 void ComplainNoMatchesFound()
const {
10958 S.
Diag(OvlExpr->getLocStart(), diag::err_addr_ovl_no_viable)
10959 << OvlExpr->getName() << TargetFunctionType
10960 << OvlExpr->getSourceRange();
10961 if (FailedCandidates.empty())
10969 IEnd = OvlExpr->decls_end();
10972 dyn_cast<FunctionDecl>((*I)->getUnderlyingDecl()))
10976 FailedCandidates.NoteCandidates(S, OvlExpr->getLocStart());
10980 bool IsInvalidFormOfPointerToMemberFunction()
const {
10981 return TargetTypeIsNonStaticMemberFunction &&
10982 !OvlExprInfo.HasFormOfMemberPointer;
10985 void ComplainIsInvalidFormOfPointerToMemberFunction()
const {
10989 S.
Diag(OvlExpr->getNameLoc(), diag::err_addr_ovl_no_qualifier)
10990 << TargetType << OvlExpr->getSourceRange();
10993 bool IsStaticMemberFunctionFromBoundPointer()
const {
10994 return StaticMemberFunctionFromBoundPointer;
10997 void ComplainIsStaticMemberFunctionFromBoundPointer()
const {
10998 S.
Diag(OvlExpr->getLocStart(),
10999 diag::err_invalid_form_pointer_member_function)
11000 << OvlExpr->getSourceRange();
11003 void ComplainOfInvalidConversion()
const {
11004 S.
Diag(OvlExpr->getLocStart(), diag::err_addr_ovl_not_func_ptrref)
11005 << OvlExpr->getName() << TargetType;
11008 void ComplainMultipleMatchesFound()
const {
11010 S.
Diag(OvlExpr->getLocStart(), diag::err_addr_ovl_ambiguous)
11011 << OvlExpr->getName()
11012 << OvlExpr->getSourceRange();
11017 bool hadMultipleCandidates()
const {
return (OvlExpr->getNumDecls() > 1); }
11019 int getNumMatches()
const {
return Matches.size(); }
11022 if (
Matches.size() != 1)
return nullptr;
11027 if (
Matches.size() != 1)
return nullptr;
11053 bool *pHadMultipleCandidates) {
11056 AddressOfFunctionResolver Resolver(*
this, AddressOfExpr, TargetType,
11058 int NumMatches = Resolver.getNumMatches();
11060 bool ShouldComplain = Complain && !Resolver.hasComplained();
11061 if (NumMatches == 0 && ShouldComplain) {
11062 if (Resolver.IsInvalidFormOfPointerToMemberFunction())
11063 Resolver.ComplainIsInvalidFormOfPointerToMemberFunction();
11065 Resolver.ComplainNoMatchesFound();
11067 else if (NumMatches > 1 && ShouldComplain)
11068 Resolver.ComplainMultipleMatchesFound();
11069 else if (NumMatches == 1) {
11070 Fn = Resolver.getMatchingFunctionDecl();
11074 FoundResult = *Resolver.getMatchingFunctionAccessPair();
11076 if (Resolver.IsStaticMemberFunctionFromBoundPointer())
11077 Resolver.ComplainIsStaticMemberFunctionFromBoundPointer();
11083 if (pHadMultipleCandidates)
11084 *pHadMultipleCandidates = Resolver.hadMultipleCandidates();
11105 auto *FD = dyn_cast<
FunctionDecl>(I->getUnderlyingDecl());
11132 ExprResult &SrcExpr,
bool DoFunctionPointerConverion) {
11195 = cast<FunctionTemplateDecl>((*I)->getUnderlyingDecl());
11207 Specialization, Info,
11211 FailedCandidates.addCandidate()
11217 assert(Specialization &&
"no specialization and no error?");
11229 Matched = Specialization;
11230 if (FoundResult) *FoundResult = I.getPair();
11252 ExprResult &SrcExpr,
bool doFunctionPointerConverion,
11253 bool complain,
SourceRange OpRangeForComplaining,
11255 unsigned DiagIDForComplaining) {
11263 ovl.Expression,
false, &found)) {
11273 if (!ovl.HasFormOfMemberPointer &&
11274 isa<CXXMethodDecl>(fn) &&
11275 cast<CXXMethodDecl>(fn)->isInstance()) {
11276 if (!complain)
return false;
11278 Diag(ovl.Expression->getExprLoc(),
11279 diag::err_bound_member_function)
11280 << 0 << ovl.Expression->getSourceRange();
11292 SingleFunctionExpression =
11296 if (doFunctionPointerConverion) {
11297 SingleFunctionExpression =
11299 if (SingleFunctionExpression.
isInvalid()) {
11306 if (!SingleFunctionExpression.
isUsable()) {
11308 Diag(OpRangeForComplaining.
getBegin(), DiagIDForComplaining)
11309 << ovl.Expression->getName()
11310 << DestTypeForComplaining
11311 << OpRangeForComplaining
11312 << ovl.Expression->getQualifierLoc().getSourceRange();
11322 SrcExpr = SingleFunctionExpression;
11332 bool PartialOverloading,
11335 if (isa<UsingShadowDecl>(Callee))
11336 Callee = cast<UsingShadowDecl>(Callee)->getTargetDecl();
11338 if (
FunctionDecl *Func = dyn_cast<FunctionDecl>(Callee)) {
11339 if (ExplicitTemplateArgs) {
11340 assert(!KnownValid &&
"Explicit template arguments?");
11344 if (!dyn_cast<FunctionProtoType>(Func->getType()->getAs<
FunctionType>()))
11349 PartialOverloading);
11354 = dyn_cast<FunctionTemplateDecl>(Callee)) {
11356 ExplicitTemplateArgs, Args, CandidateSet,
11358 PartialOverloading);
11362 assert(!KnownValid &&
"unhandled case in overloaded call candidate");
11370 bool PartialOverloading) {
11393 assert(!(*I)->getDeclContext()->isRecord());
11394 assert(isa<UsingShadowDecl>(*I) ||
11395 !(*I)->getDeclContext()->isFunctionOrMethod());
11396 assert((*I)->getUnderlyingDecl()->isFunctionOrFunctionTemplate());
11406 ExplicitTemplateArgs = &TABuffer;
11412 CandidateSet, PartialOverloading,
11417 Args, ExplicitTemplateArgs,
11418 CandidateSet, PartialOverloading);
11425 case OO_New:
case OO_Array_New:
11426 case OO_Delete:
case OO_Array_Delete:
11446 bool *DoDiagnoseEmptyLookup =
nullptr) {
11451 if (DC->isTransparentContext())
11459 if (isa<CXXRecordDecl>(DC)) {
11463 if (DoDiagnoseEmptyLookup)
11464 *DoDiagnoseEmptyLookup =
true;
11471 ExplicitTemplateArgs, Args,
11472 Candidates,
false,
false);
11475 if (Candidates.BestViableFunction(SemaRef, FnLoc, Best) !=
OR_Success) {
11487 AssociatedNamespaces,
11488 AssociatedClasses);
11492 for (Sema::AssociatedNamespaceSet::iterator
11493 it = AssociatedNamespaces.begin(),
11494 end = AssociatedNamespaces.end(); it != end; ++it) {
11506 SuggestedNamespaces.insert(*it);
11510 SemaRef.
Diag(R.
getNameLoc(), diag::err_not_found_by_two_phase_lookup)
11512 if (SuggestedNamespaces.empty()) {
11513 SemaRef.
Diag(Best->Function->getLocation(),
11514 diag::note_not_found_by_two_phase_lookup)
11516 }
else if (SuggestedNamespaces.size() == 1) {
11517 SemaRef.
Diag(Best->Function->getLocation(),
11518 diag::note_not_found_by_two_phase_lookup)
11524 SemaRef.
Diag(Best->Function->getLocation(),
11525 diag::note_not_found_by_two_phase_lookup)
11557 class BuildRecoveryCallExprRAII {
11560 BuildRecoveryCallExprRAII(
Sema &S) : SemaRef(S) {
11561 assert(SemaRef.IsBuildingRecoveryCallExpr ==
false);
11562 SemaRef.IsBuildingRecoveryCallExpr =
true;
11565 ~BuildRecoveryCallExprRAII() {
11566 SemaRef.IsBuildingRecoveryCallExpr =
false;
11572 static std::unique_ptr<CorrectionCandidateCallback>
11574 bool HasTemplateArgs,
bool AllowTypoCorrection) {
11575 if (!AllowTypoCorrection)
11576 return llvm::make_unique<NoTypoCorrectionCCC>();
11577 return llvm::make_unique<FunctionCallFilterCCC>(SemaRef, NumArgs,
11578 HasTemplateArgs, ME);
11590 bool EmptyLookup,
bool AllowTypoCorrection) {
11599 BuildRecoveryCallExprRAII RCE(SemaRef);
11609 ExplicitTemplateArgs = &TABuffer;
11614 bool DoDiagnoseEmptyLookup = EmptyLookup;
11617 ExplicitTemplateArgs, Args,
11618 &DoDiagnoseEmptyLookup) &&
11621 MakeValidator(SemaRef, dyn_cast<MemberExpr>(Fn), Args.size(),
11622 ExplicitTemplateArgs !=
nullptr, AllowTypoCorrection),
11623 ExplicitTemplateArgs, Args)))
11626 assert(!R.empty() &&
"lookup results empty despite recovery");
11629 if (R.isAmbiguous()) {
11630 R.suppressDiagnostics();
11637 if ((*R.begin())->isCXXClassMember())
11639 ExplicitTemplateArgs, S);
11640 else if (ExplicitTemplateArgs || TemplateKWLoc.
isValid())
11642 ExplicitTemplateArgs);
11669 assert(!ULE->
getQualifier() &&
"qualified name with ADL");
11677 llvm_unreachable(
"performing ADL for builtin");
11684 UnbridgedCastsSet UnbridgedCasts;
11699 if (CandidateSet->
empty() ||
11716 if (CandidateSet->
empty())
11719 UnbridgedCasts.restore();
11735 bool AllowTypoCorrection) {
11736 if (CandidateSet->
empty())
11739 AllowTypoCorrection);
11741 switch (OverloadResult) {
11758 AllowTypoCorrection);
11765 for (
const Expr *Arg : Args) {
11766 if (!Arg->getType()->isFunctionType())
11768 if (
auto *DRE = dyn_cast<DeclRefExpr>(Arg->IgnoreParenImpCasts())) {
11772 Arg->getExprLoc()))
11777 SemaRef.
Diag(Fn->
getLocStart(), diag::err_ovl_no_viable_function_in_call)
11791 << (*Best)->Function->isDeleted()
11812 for (
auto I = CS.
begin(), E = CS.
end(); I !=
E; ++
I) {
11833 bool AllowTypoCorrection,
11834 bool CalleesAddressIsTaken) {
11845 if (CalleesAddressIsTaken)
11853 RParenLoc, ExecConfig, &CandidateSet,
11854 &Best, OverloadResult,
11855 AllowTypoCorrection);
11859 return Functions.
size() > 1 ||
11860 (Functions.
size() == 1 && isa<FunctionTemplateDecl>(*Functions.
begin()));
11883 assert(Op !=
OO_None &&
"Invalid opcode for overloaded unary operator");
11892 unsigned NumArgs = 1;
11897 if (Opc == UO_PostInc || Opc == UO_PostDec) {
11939 bool HadMultipleCandidates = (CandidateSet.
size() > 1);
11949 Expr *Base =
nullptr;
11954 if (
CXXMethodDecl *Method = dyn_cast<CXXMethodDecl>(FnDecl)) {
11959 Best->FoundDecl, Method);
11962 Base = Input = InputRes.
get();
11973 Input = InputInit.
get();
11978 Base, HadMultipleCandidates,
11996 if (CheckFunctionCall(FnDecl, TheCall,
12006 Input, Best->BuiltinParamTypes[0], Best->Conversions[0],
AA_Passing);
12009 Input = InputRes.
get();
12027 Diag(OpLoc, diag::err_ovl_ambiguous_oper_unary)
12036 Diag(OpLoc, diag::err_ovl_deleted_oper)
12037 << Best->Function->isDeleted()
12073 Expr *Args[2] = { LHS, RHS };
12081 if (Args[0]->isTypeDependent() || Args[1]->isTypeDependent()) {
12085 if (Opc <= BO_Assign || Opc > BO_OrAssign)
12126 if (Opc == BO_Assign && !Args[0]->getType()->isOverloadableType())
12131 if (Opc == BO_PtrMemD)
12146 if (Opc != BO_Assign)
12154 bool HadMultipleCandidates = (CandidateSet.
size() > 1);
12164 Expr *Base =
nullptr;
12169 if (
CXXMethodDecl *Method = dyn_cast<CXXMethodDecl>(FnDecl)) {
12183 Best->FoundDecl, Method);
12210 Best->FoundDecl, Base,
12211 HadMultipleCandidates, OpLoc);
12222 Args, ResultTy, VK, OpLoc,
12230 const Expr *ImplicitThis =
nullptr;
12232 if (isa<CXXMethodDecl>(FnDecl)) {
12233 ImplicitThis = ArgsArray[0];
12234 ArgsArray = ArgsArray.slice(1);
12238 if (Op == OO_Equal)
12241 checkCall(FnDecl,
nullptr, ImplicitThis, ArgsArray,
12242 isa<CXXMethodDecl>(FnDecl), OpLoc, TheCall->getSourceRange(),
12255 Args[0] = ArgsRes0.
get();
12262 Args[1] = ArgsRes1.
get();
12272 if (Opc == BO_Comma)
12280 Opc >= BO_Assign && Opc <= BO_OrAssign) {
12281 Diag(OpLoc, diag::err_ovl_no_viable_oper)
12284 if (Args[0]->getType()->isIncompleteType()) {
12285 Diag(OpLoc, diag::note_assign_lhs_incomplete)
12302 "C++ binary operator overloading is missing candidates!");
12310 Diag(OpLoc, diag::err_ovl_ambiguous_oper_binary)
12320 CXXMethodDecl *Method = cast<CXXMethodDecl>(Best->Function);
12321 Diag(OpLoc, diag::err_ovl_deleted_special_oper)
12330 Diag(OpLoc, diag::err_ovl_deleted_oper)
12331 << Best->Function->isDeleted()
12349 Expr *Args[2] = { Base, Idx };
12355 if (Args[0]->isTypeDependent() || Args[1]->isTypeDependent()) {
12391 bool HadMultipleCandidates = (CandidateSet.
size() > 1);
12410 Best->FoundDecl, Method);
12411 if (Arg0.isInvalid())
12413 Args[0] = Arg0.get();
12429 OpLocInfo.setCXXOperatorNameRange(
SourceRange(LLoc, RLoc));
12433 HadMultipleCandidates,
12434 OpLocInfo.getLoc(),
12435 OpLocInfo.getInfo());
12446 FnExpr.
get(), Args,
12447 ResultTy, VK, RLoc,
12453 if (CheckFunctionCall(Method, TheCall,
12467 Args[0] = ArgsRes0.
get();
12474 Args[1] = ArgsRes1.
get();
12481 if (CandidateSet.
empty())
12482 Diag(LLoc, diag::err_ovl_no_oper)
12486 Diag(LLoc, diag::err_ovl_no_viable_subscript)
12495 Diag(LLoc, diag::err_ovl_ambiguous_oper_binary)
12504 Diag(LLoc, diag::err_ovl_deleted_oper)
12505 << Best->Function->isDeleted() <<
"[]"
12537 if (
BinaryOperator *op = dyn_cast<BinaryOperator>(NakedMemExpr)) {
12539 assert(op->getOpcode() == BO_PtrMemD || op->getOpcode() == BO_PtrMemI);
12552 QualType objectType = op->getLHS()->getType();
12553 if (op->getOpcode() == BO_PtrMemI)
12555 Qualifiers objectQuals = objectType.getQualifiers();
12557 Qualifiers difference = objectQuals - funcQuals;
12561 std::string qualsString = difference.
getAsString();
12562 Diag(LParenLoc, diag::err_pointer_to_member_call_drops_quals)
12563 << fnType.getUnqualifiedType()
12565 << (qualsString.find(
' ') == std::string::npos ? 1 : 2);
12570 resultType, valueKind, RParenLoc);
12579 if (CheckOtherCall(call, proto))
12585 if (isa<CXXPseudoDestructorExpr>(NakedMemExpr))
12589 UnbridgedCastsSet UnbridgedCasts;
12597 if (isa<MemberExpr>(NakedMemExpr)) {
12598 MemExpr = cast<MemberExpr>(NakedMemExpr);
12602 UnbridgedCasts.restore();
12620 TemplateArgs = &TemplateArgsBuffer;
12628 if (isa<UsingShadowDecl>(Func))
12629 Func = cast<UsingShadowDecl>(Func)->getTargetDecl();
12633 if (
getLangOpts().MicrosoftExt && isa<CXXConstructorDecl>(Func)) {
12635 Args, CandidateSet);
12636 }
else if ((Method = dyn_cast<CXXMethodDecl>(Func))) {
12643 ObjectClassification, Args, CandidateSet,
12647 cast<FunctionTemplateDecl>(Func), I.getPair(), ActingDC,
12648 TemplateArgs, ObjectType, ObjectClassification, Args, CandidateSet,
12655 UnbridgedCasts.restore();
12661 Method = cast<CXXMethodDecl>(Best->Function);
12662 FoundDecl = Best->FoundDecl;
12672 if (Method != FoundDecl.getDecl() &&
12679 diag::err_ovl_no_viable_member_function_in_call)
12694 << Best->Function->isDeleted()
12719 assert(Method &&
"Member call to something that isn't a method?");
12722 ResultType, VK, RParenLoc);
12750 if (CheckFunctionCall(Method, TheCall, Proto))
12756 if (
auto *MemE = dyn_cast<MemberExpr>(NakedMemExpr)) {
12758 Diag(MemE->getMemberLoc(),
12759 diag::err_ovl_no_viable_member_function_in_call)
12762 diag::note_ovl_candidate_disabled_by_function_cond_attr)
12763 <<
Attr->getCond()->getSourceRange() <<
Attr->getMessage();
12776 diag::warn_call_to_pure_virtual_member_function_from_ctor_dtor)
12783 diag::note_pure_qualified_call_kext)
12794 CallCanBeVirtual,
true,
12814 UnbridgedCastsSet UnbridgedCasts;
12819 "Requires object type argument");
12834 diag::err_incomplete_object_call, Object.
get()))
12842 Oper != OperEnd; ++Oper) {
12865 const auto &Conversions =
12866 cast<CXXRecordDecl>(Record->getDecl())->getVisibleConversionFunctions();
12867 for (
auto I = Conversions.begin(), E = Conversions.end(); I !=
E; ++
I) {
12870 if (isa<UsingShadowDecl>(D))
12871 D = cast<UsingShadowDecl>(D)->getTargetDecl();
12875 if (isa<FunctionTemplateDecl>(D))
12889 Object.
get(), Args, CandidateSet);
12894 bool HadMultipleCandidates = (CandidateSet.size() > 1);
12898 switch (CandidateSet.BestViableFunction(*
this, Object.
get()->
getLocStart(),
12906 if (CandidateSet.empty())
12912 diag::err_ovl_no_viable_object_call)
12919 diag::err_ovl_ambiguous_object_call)
12926 diag::err_ovl_deleted_object_call)
12927 << Best->Function->isDeleted()
12935 if (Best == CandidateSet.end())
12938 UnbridgedCasts.restore();
12940 if (Best->Function ==
nullptr) {
12944 = cast<CXXConversionDecl>(
12945 Best->Conversions[0].UserDefined.ConversionFunction);
12951 assert(Conv == Best->FoundDecl.getDecl() &&
12952 "Found Decl & conversion-to-functionptr should be same, right?!");
12960 Conv, HadMultipleCandidates);
12961 if (Call.isInvalid())
12965 CK_UserDefinedConversion, Call.get(),
12968 return ActOnCallExpr(S, Call.get(), LParenLoc, Args, RParenLoc);
12976 CXXMethodDecl *Method = cast<CXXMethodDecl>(Best->Function);
12979 if (Method->isInvalidDecl())
12991 Obj, HadMultipleCandidates,
12992 OpLocInfo.getLoc(),
12993 OpLocInfo.getInfo());
13000 MethodArgs[0] = Object.
get();
13001 std::copy(Args.begin(), Args.end(), MethodArgs.begin() + 1);
13005 QualType ResultTy = Method->getReturnType();
13007 ResultTy = ResultTy.getNonLValueExprType(
Context);
13018 if (Args.size() < NumParams)
13021 bool IsError =
false;
13026 Best->FoundDecl, Method);
13031 TheCall->setArg(0, Object.
get());
13034 for (
unsigned i = 0; i != NumParams; i++) {
13036 if (i < Args.size()) {
13044 Method->getParamDecl(i)),
13060 TheCall->setArg(i + 1, Arg);
13066 for (
unsigned i = NumParams, e = Args.size(); i < e; i++) {
13070 TheCall->setArg(i + 1, Arg.
get());
13074 if (IsError)
return true;
13078 if (CheckFunctionCall(Method, TheCall, Proto))
13089 bool *NoArrowOperatorFound) {
13091 "left-hand side must have class type");
13110 diag::err_typecheck_incomplete_tag, Base))
13118 Oper != OperEnd; ++Oper) {
13120 None, CandidateSet,
false);
13123 bool HadMultipleCandidates = (CandidateSet.
size() > 1);
13133 if (CandidateSet.
empty()) {
13135 if (NoArrowOperatorFound) {
13138 *NoArrowOperatorFound =
true;
13141 Diag(OpLoc, diag::err_typecheck_member_reference_arrow)
13144 Diag(OpLoc, diag::note_typecheck_member_reference_suggestion)
13148 Diag(OpLoc, diag::err_ovl_no_viable_oper)
13154 Diag(OpLoc, diag::err_ovl_ambiguous_oper_unary)
13160 Diag(OpLoc, diag::err_ovl_deleted_oper)
13161 << Best->Function->isDeleted()
13172 CXXMethodDecl *Method = cast<CXXMethodDecl>(Best->Function);
13175 Best->FoundDecl, Method);
13176 if (BaseResult.isInvalid())
13178 Base = BaseResult.get();
13182 Base, HadMultipleCandidates, OpLoc);
13191 Base, ResultTy, VK, OpLoc,
FPOptions());
13196 if (CheckFunctionCall(Method, TheCall,
13217 bool HadMultipleCandidates = (CandidateSet.size() > 1);
13222 switch (CandidateSet.BestViableFunction(*
this, UDSuffixLoc, Best)) {
13228 Diag(UDSuffixLoc, diag::err_ovl_no_viable_function_in_call)
13241 nullptr, HadMultipleCandidates,
13250 for (
unsigned ArgIdx = 0, N = Args.size(); ArgIdx != N; ++ArgIdx) {
13256 ConvArgs[ArgIdx] = InputInit.
get();
13265 llvm::makeArrayRef(ConvArgs, Args.size()),
13266 ResultTy, VK, LitEndLoc, UDSuffixLoc);
13271 if (CheckFunctionCall(FD, UDL,
nullptr))
13291 Scope *S =
nullptr;
13293 CandidateSet->
clear();
13294 if (!MemberLookup.
empty()) {
13317 FoundNames.
begin(), FoundNames.
end());
13320 CandidateSet, CallExpr);
13321 if (CandidateSet->
empty() || CandidateSetError) {
13334 Loc,
nullptr, CandidateSet, &Best,
13353 if (
ParenExpr *PE = dyn_cast<ParenExpr>(E)) {
13356 if (SubExpr == PE->getSubExpr())
13359 return new (
Context)
ParenExpr(PE->getLParen(), PE->getRParen(), SubExpr);
13367 "Implicit cast type cannot be determined from overload");
13368 assert(ICE->path_empty() &&
"fixing up hierarchy conversion?");
13369 if (SubExpr == ICE->getSubExpr())
13373 ICE->getCastKind(),
13378 if (
auto *GSE = dyn_cast<GenericSelectionExpr>(E)) {
13379 if (!GSE->isResultDependent()) {
13382 if (SubExpr == GSE->getResultExpr())
13389 unsigned ResultIdx = GSE->getResultIndex();
13390 AssocExprs[ResultIdx] = SubExpr;
13393 Context, GSE->getGenericLoc(), GSE->getControllingExpr(),
13394 GSE->getAssocTypeSourceInfos(), AssocExprs, GSE->getDefaultLoc(),
13395 GSE->getRParenLoc(), GSE->containsUnexpandedParameterPack(),
13404 assert(UnOp->getOpcode() == UO_AddrOf &&
13405 "Can only take the address of an overloaded function");
13407 if (Method->isStatic()) {
13416 if (SubExpr == UnOp->getSubExpr())
13419 assert(isa<DeclRefExpr>(SubExpr)
13420 &&
"fixed to something other than a decl ref");
13421 assert(cast<DeclRefExpr>(SubExpr)->getQualifier()
13422 &&
"fixed to a member ref with no nested name qualifier");
13437 UnOp->getOperatorLoc());
13442 if (SubExpr == UnOp->getSubExpr())
13448 UnOp->getOperatorLoc());
13461 if (ULE->hasExplicitTemplateArgs()) {
13462 ULE->copyTemplateArgumentsInto(TemplateArgsBuffer);
13463 TemplateArgs = &TemplateArgsBuffer;
13467 ULE->getQualifierLoc(),
13468 ULE->getTemplateKeywordLoc(),
13484 if (MemExpr->hasExplicitTemplateArgs()) {
13485 MemExpr->copyTemplateArgumentsInto(TemplateArgsBuffer);
13486 TemplateArgs = &TemplateArgsBuffer;
13493 if (MemExpr->isImplicitAccess()) {
13494 if (cast<CXXMethodDecl>(Fn)->isStatic()) {
13496 MemExpr->getQualifierLoc(),
13497 MemExpr->getTemplateKeywordLoc(),
13500 MemExpr->getMemberLoc(),
13510 if (MemExpr->getQualifier())
13511 Loc = MemExpr->getQualifierLoc().getBeginLoc();
13514 MemExpr->getBaseType(),
13518 Base = MemExpr->getBase();
13522 if (cast<CXXMethodDecl>(Fn)->isStatic()) {
13531 Context, Base, MemExpr->isArrow(), MemExpr->getOperatorLoc(),
13532 MemExpr->getQualifierLoc(), MemExpr->getTemplateKeywordLoc(), Fn, Found,
13533 MemExpr->getMemberNameInfo(), TemplateArgs,
type, valueKind,
13540 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
Function pointer conversion (C++17 4.13)
DeclAccessPair FoundConversionFunction
The declaration that we found via name lookup, which might be the same as ConversionFunction or it mi...
Defines the clang::ASTContext interface.
unsigned 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 ...
CUDA Target attributes do not match.
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+...
QualType getNonTypeTemplateArgumentType() const
If this is a non-type template argument, get its type.
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.
bool diagnoseArgDependentDiagnoseIfAttrs(const FunctionDecl *Function, const Expr *ThisArg, ArrayRef< const Expr * > Args, SourceLocation Loc)
Emit diagnostics for the diagnose_if attributes on Function, ignoring any non-ArgDependent DiagnoseIf...
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.
static void DiagnoseArityMismatch(Sema &S, NamedDecl *Found, Decl *D, unsigned NumFormalArgs)
General arity mismatch diagnosis over a candidate in a candidate set.
TemplateDeductionResult
Describes the result of template argument deduction.
void setToType(QualType T)
TemplateDecl * getDescribedTemplate() const
If this is a declaration that describes some template, this method returns that template declaration...
ImplicitConversionKind
ImplicitConversionKind - The kind of implicit conversion used to convert an argument to a parameter's...
QualType getCallResultType(const ASTContext &Context) const
Determine the type of an expression that calls a function of this type.
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.
Conversion not allowed by the C standard, but that we accept as an extension anyway.
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.
const FunctionProtoType * ResolveExceptionSpec(SourceLocation Loc, const FunctionProtoType *FPT)
UnresolvedSetIterator getMostSpecialized(UnresolvedSetIterator SBegin, UnresolvedSetIterator SEnd, TemplateSpecCandidateSet &FailedCandidates, SourceLocation Loc, const PartialDiagnostic &NoneDiag, const PartialDiagnostic &AmbigDiag, const PartialDiagnostic &CandidateDiag, bool Complain=true, QualType TargetType=QualType())
Retrieve the most specialized of the given function template specializations.
Ordinary name lookup, which finds ordinary names (functions, variables, typedefs, etc...
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
void NoteCandidates(Sema &S, OverloadCandidateDisplayKind OCD, ArrayRef< Expr * > Args, StringRef Opc="", SourceLocation Loc=SourceLocation(), llvm::function_ref< bool(OverloadCandidate &)> Filter=[](OverloadCandidate &){return true;})
PrintOverloadCandidates - When overload resolution fails, prints diagnostic messages containing the c...
A structure used to record information about a failed template argument deduction, for diagnosis.
Checking non-dependent argument conversions failed.
static UnresolvedLookupExpr * Create(const ASTContext &C, CXXRecordDecl *NamingClass, NestedNameSpecifierLoc QualifierLoc, const DeclarationNameInfo &NameInfo, bool ADL, bool Overloaded, UnresolvedSetIterator Begin, UnresolvedSetIterator End)
CanQual< T > getUnqualifiedType() const
Retrieve the unqualified form of this type.
void dump() const
dump - Print this standard conversion sequence to standard error.
bool CheckNonDependentConversions(FunctionTemplateDecl *FunctionTemplate, ArrayRef< QualType > ParamTypes, ArrayRef< Expr * > Args, OverloadCandidateSet &CandidateSet, ConversionSequenceList &Conversions, bool SuppressUserConversions, CXXRecordDecl *ActingContext=nullptr, QualType ObjectType=QualType(), Expr::Classification ObjectClassification={})
Check that implicit conversion sequences can be formed for each argument whose corresponding paramete...
Cannot tell whether this is a narrowing conversion because the expression is value-dependent.
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.
ActionResult< Expr * > ExprResult
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...
static InitializedEntity InitializeParameter(ASTContext &Context, const ParmVarDecl *Parm)
Create the initialization entity for a parameter.
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.
ConstructorInfo getConstructorInfo(NamedDecl *ND)
Decl - This represents one declaration (or definition), e.g.
static ImplicitConversionSequence TryContextuallyConvertToBool(Sema &S, Expr *From)
TryContextuallyConvertToBool - Attempt to contextually convert the expression From to bool (C++0x [co...
specific_attr_iterator - Iterates over a subrange of an AttrVec, only providing attributes that are o...
__DEVICE__ long long abs(long long __n)
ExprResult BuildCallToMemberFunction(Scope *S, Expr *MemExpr, SourceLocation LParenLoc, MultiExprArg Args, SourceLocation RParenLoc)
BuildCallToMemberFunction - Build a call to a member function.
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)
AssignConvertType
AssignConvertType - All of the 'assignment' semantic checks return this enum to indicate whether the ...
A reference to a name which we were able to look up during parsing but could not resolve to a specifi...
void AddBuiltinCandidate(QualType *ParamTys, ArrayRef< Expr * > Args, OverloadCandidateSet &CandidateSet, bool IsAssignmentOperator=false, unsigned NumContextualBoolArguments=0)
AddBuiltinCandidate - Add a candidate for a built-in operator.
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 IsOverload(FunctionDecl *New, FunctionDecl *Old, bool IsForUsingDecl, bool ConsiderCudaAttrs=true)
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
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...
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 bad conversi...
The base class of the type hierarchy.
bool isDependentContext() const
Determines whether this context is dependent on a template parameter.
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
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.
bool isBooleanType() const
bool compatiblyIncludes(Qualifiers other) const
Determines if these qualifiers compatibly include another set.
Conversions between compatible types in C99.
Floating point control options.
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.
float __ovld __cnfn distance(float p0, float p1)
Returns the distance between p0 and p1.
static unsigned RankDeductionFailure(const DeductionFailureInfo &DFI)
void * getAsOpaquePtr() const
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.
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)
Determine whether the given New declaration is an overload of the declarations in Old...
static bool functionHasPassObjectSizeParams(const FunctionDecl *FD)
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...
bool isSpecialized() const
Whether this type is specialized, meaning that it has type arguments.
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...
Like System, but searched after the system directories.
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
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.
OverloadCandidate & addCandidate(unsigned NumConversions=0, ConversionSequenceList Conversions=None)
Add a new candidate with NumConversions conversion sequence slots to the overload set...
ExprResult PerformImplicitConversion(Expr *From, QualType ToType, AssignmentAction Action, bool AllowExplicit=false)
PerformImplicitConversion - Perform an implicit conversion of the expression From to the type ToType...
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.
bool doFunctionTypesMatchOnExtParameterInfos(const FunctionProtoType *FromFunctionType, const FunctionProtoType *ToFunctionType)
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.
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.
llvm::mapped_iterator< decltype(Decls)::iterator, select_second > iterator
static bool diagnoseNoViableConversion(Sema &SemaRef, SourceLocation Loc, Expr *&From, Sema::ContextualImplicitConverter &Converter, QualType T, bool HadMultipleCandidates, UnresolvedSetImpl &ExplicitConversions)
unsigned BindsToFunctionLvalue
Whether we're binding to a function lvalue.
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)
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.
std::string getFullModuleName(bool AllowStringLiterals=false) const
Retrieve the full name of this module, including the path from its top-level module.
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...
CompatiblePointerDiscardsQualifiers - The assignment discards c/v/r qualifiers, which we accept as an...
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...
CUDAFunctionTarget IdentifyCUDATarget(const FunctionDecl *D, bool IgnoreImplicitHDAttr=false)
Determines whether the given function is a CUDA device/host/kernel/etc.
bool isOpenCLDisabledDecl(Decl *FD)
ExprResult CreateOverloadedUnaryOp(SourceLocation OpLoc, UnaryOperatorKind Opc, const UnresolvedSetImpl &Fns, Expr *input)
Create a unary operation that may resolve to an overloaded operator.
ConversionSequenceList allocateConversionSequences(unsigned NumConversions)
Allocate storage for conversion sequences for NumConversions conversions.
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...
ExprResult DefaultFunctionArrayConversion(Expr *E, bool Diagnose=true)
DefaultFunctionArrayConversion (C99 6.3.2.1p3, C99 6.3.2.1p4).
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.
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.
ImplicitConversionRank getRank() const
getRank - Retrieve the rank of this standard conversion sequence (C++ 13.3.3.1.1p3).
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.
const TargetInfo & getTargetInfo() const
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...
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.
Module * getOwningModule(Decl *Entity)
Get the module owning an entity.
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.
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 CheckCXXThisCapture(SourceLocation Loc, bool Explicit=false, bool BuildAndDiagnose=true, const unsigned *const FunctionScopeIndexToStopAt=nullptr, bool ByCopy=false)
Make sure the value of 'this' is actually available in the current context, if it is a potentially ev...
bool isObjCLifetimeType() const
Returns true if objects of this type have lifetime semantics under ARC.
bool IsFunctionConversion(QualType FromType, QualType ToType, QualType &ResultTy)
Determine whether the conversion from FromType to ToType is a valid conversion that strips "noexcept"...
void MarkDeclRefReferenced(DeclRefExpr *E, const Expr *Base=nullptr)
Perform reference-marking and odr-use handling for a DeclRefExpr.
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 ...
bool diagnoseArgIndependentDiagnoseIfAttrs(const NamedDecl *ND, SourceLocation Loc)
Emit diagnostics for the diagnose_if attributes on Function, ignoring any ArgDependent DiagnoseIfAttr...
A builtin binary operation expression such as "x + y" or "x <= y".
Substitution of the deduced template argument values resulted in an error.
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...
Defines the Diagnostic-related interfaces.
A narrowing conversion, because a constant expression got narrowed.
FunctionDecl * ResolveAddressOfOverloadedFunction(Expr *AddressOfExpr, QualType TargetType, bool Complain, DeclAccessPair &Found, bool *pHadMultipleCandidates=nullptr)
ResolveAddressOfOverloadedFunction - Try to resolve the address of an overloaded function (C++ [over...
ExprResult BuildOverloadedCallExpr(Scope *S, Expr *Fn, UnresolvedLookupExpr *ULE, SourceLocation LParenLoc, MultiExprArg Args, SourceLocation RParenLoc, Expr *ExecConfig, bool AllowTypoCorrection=true, bool CalleesAddressIsTaken=false)
BuildOverloadedCallExpr - Given the call expression that calls Fn (which eventually refers to the dec...
unsigned IsLvalueReference
Whether this is an lvalue reference binding (otherwise, it's an rvalue reference binding).
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)
Check assignment constraints for an assignment of RHS to LHSType.
An ordinary object is located at an address in memory.
virtual SemaDiagnosticBuilder diagnoseIncomplete(Sema &S, SourceLocation Loc, QualType T)=0
Emits a diagnostic when the expression has incomplete class type.
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 or a function 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
IncompatiblePointerSign - The assignment is between two pointers types which point to integers which ...
ExprResult BuildDeclarationNameExpr(const CXXScopeSpec &SS, LookupResult &R, bool NeedsADL, bool AcceptInvalidDecl=false)
Complex <-> Real conversion.
bool Viable
Viable - True to indicate that this overload candidate is viable.
ConversionSequenceList Conversions
The conversion sequences used to convert the function arguments to the function parameters.
FunctionDecl * resolveAddressOfOnlyViableOverloadCandidate(Expr *E, DeclAccessPair &FoundResult)
Given an expression that refers to an overloaded function, try to resolve that function to a single f...
static Classification makeSimpleLValue()
Create a simple, modifiably lvalue.
CanQualType UnsignedCharTy
Integral promotions (C++ 4.5)
This conversion function template specialization candidate is not viable because the final conversion...
const LangOptions & LangOpts
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.
QualType BuiltinParamTypes[3]
BuiltinParamTypes - Provides the parameter types of a built-in overload candidate.
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++.
C-only conversion between pointers with incompatible types.
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...
static bool hasDeprecatedStringLiteralToCharPtrConversion(const ImplicitConversionSequence &ICS)
specific_attr_iterator< T > specific_attr_end() const
CXXSpecialMember
Kinds of C++ special members.
void EraseUnwantedCUDAMatches(const FunctionDecl *Caller, SmallVectorImpl< std::pair< DeclAccessPair, FunctionDecl * >> &Matches)
Finds a function in Matches with highest calling priority from Caller context and erases all function...
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...
CanQualType getCanonicalTypeUnqualified() const
QualType getParamType(unsigned i) const
Represents a prototype with parameter type info, e.g.
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)
SourceLocation getLocEnd() const LLVM_READONLY
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.
static ExprResult CreateFunctionRefExpr(Sema &S, FunctionDecl *Fn, NamedDecl *FoundDecl, const Expr *Base, bool HadMultipleCandidates, SourceLocation Loc=SourceLocation(), const DeclarationNameLoc &LocInfo=DeclarationNameLoc())
A convenience routine for creating a decayed reference to a function.
bool CheckPointerConversion(Expr *From, QualType ToType, CastKind &Kind, CXXCastPath &BasePath, bool IgnoreBaseAccess, bool Diagnose=true)
CheckPointerConversion - Check the pointer conversion from the expression From to the type ToType...
virtual SemaDiagnosticBuilder diagnoseExplicitConv(Sema &S, SourceLocation Loc, QualType T, QualType ConvTy)=0
Emits a diagnostic when the only matching conversion function is explicit.
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.
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 hasUnaligned() const
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.
bool isMicrosoft() const
Is this ABI an MSVC-compatible ABI?
const Type * getTypeForDecl() const
static OverloadingResult IsInitializerListConstructorConversion(Sema &S, Expr *From, QualType ToType, CXXRecordDecl *To, UserDefinedConversionSequence &User, OverloadCandidateSet &CandidateSet, bool AllowExplicit)
Represents a shadow constructor declaration introduced into a class by a C++11 using-declaration that...
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.
bool isUndeducedType() const
Determine whether this type is an undeduced type, meaning that it somehow involves a C++11 'auto' typ...
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...
Qualifiers getQualifiers() const
Retrieve all qualifiers.
unsigned getNumArgs() const
This inherited constructor is not viable because it would slice the argument.
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
Declaration of a template type parameter.
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.
Represents a C++ destructor within a class.
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...
CXXConstructorDecl * CopyConstructor
CopyConstructor - The copy constructor that is used to perform this conversion, when the conversion i...
static bool completeFunctionType(Sema &S, FunctionDecl *FD, SourceLocation Loc, bool Complain=true)
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...
char __ovld __cnfn min(char x, char y)
Returns y if y < x, otherwise it returns x.
ReferenceCompareResult
ReferenceCompareResult - Expresses the result of comparing two types (cv1 T1 and cv2 T2) to determine...
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)
The current expression and its subexpressions occur within an unevaluated operand (C++11 [expr]p7)...
ExprResult BuildTemplateIdExpr(const CXXScopeSpec &SS, SourceLocation TemplateKWLoc, LookupResult &R, bool RequiresADL, const TemplateArgumentListInfo *TemplateArgs)
FunctionDecl * ResolveSingleFunctionTemplateSpecialization(OverloadExpr *ovl, bool Complain=false, DeclAccessPair *Found=nullptr)
Given an expression that refers to an overloaded function, try to resolve that overloaded function ex...
bool isSameOrCompatibleFunctionType(CanQualType Param, CanQualType Arg)
Compare types for equality with respect to possibly compatible function types (noreturn adjustment...
CanQualType UnsignedInt128Ty
Specifies that a value-dependent expression of integral or dependent type should be considered a null...
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 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...
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...
static void DiagnoseOpenCLExtensionDisabled(Sema &S, OverloadCandidate *Cand)
QualType getObjCIdType() const
Represents the Objective-CC id type.
bool resolveAndFixAddressOfOnlyViableOverloadCandidate(ExprResult &SrcExpr, bool DoFunctionPointerConversion=false)
Given an overloaded function, tries to turn it into a non-overloaded function reference using resolve...
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.
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
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 function is explicit.
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
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)
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 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...
const Type * getTypePtr() const
Retrieves a pointer to the underlying (unqualified) type.
A helper class that allows the use of isa/cast/dyncast to detect TagType objects of enums...
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...
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 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...
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...
ASTContext & getASTContext() const
A vector splat from an arithmetic type.
IncompatiblePointer - The assignment is between two pointers types that are not compatible, but we accept them as an extension.
llvm::APSInt EvaluateKnownConstInt(const ASTContext &Ctx, SmallVectorImpl< PartialDiagnosticAt > *Diag=nullptr) const
EvaluateKnownConstInt - Call EvaluateAsRValue and return the folded integer.
static Comparison compareEnableIfAttrs(const Sema &S, const FunctionDecl *Cand1, const FunctionDecl *Cand2)
Compares the enable_if attributes of two FunctionDecls, for the purposes of overload resolution...
OverloadingResult
OverloadingResult - Capture the result of performing overload resolution.
static ImplicitConversionSequence::CompareKind compareConversionFunctions(Sema &S, FunctionDecl *Function1, FunctionDecl *Function2)
Compare the user-defined conversion functions or constructors of two user-defined conversion sequence...
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...
ExprResult DefaultLvalueConversion(Expr *E)
Represents a C++ nested name specifier, such as "\::std::vector<int>::".
No ref-qualifier was provided.
ArrayRef< ParmVarDecl * > parameters() const
Objective-C ARC writeback conversion.
bool DiagnoseMultipleUserDefinedConversion(Expr *From, QualType ToType)
The declaration was invalid; do nothing.
bool isIntegralType(const ASTContext &Ctx) const
Determine whether this type is an integral type.
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
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...
static void DiagnoseBadDeduction(Sema &S, NamedDecl *Found, Decl *Templated, DeductionFailureInfo &DeductionFailure, unsigned NumArgs, bool TakingCandidateAddress)
Diagnose a failed template-argument deduction.
Complex-real conversions (C99 6.3.1.7)
An rvalue ref-qualifier was provided (&&).
Assigning into this object requires a lifetime extension.
SourceLocation getLocStart() const LLVM_READONLY
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)
void NoteOverloadCandidate(NamedDecl *Found, FunctionDecl *Fn, QualType DestType=QualType(), bool TakingAddress=false)
SourceLocation getExprLoc() const LLVM_READONLY
getExprLoc - Return the preferred location for the arrow when diagnosing a problem with a generic exp...
QualType 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)
Represents a C11 generic selection.
ImplicitConversionRank GetConversionRank(ImplicitConversionKind Kind)
GetConversionRank - Retrieve the implicit conversion rank corresponding to the given implicit convers...
A class for storing results from argument-dependent lookup.
CanQualType UnsignedShortTy
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.
DeclAccessPair FoundCopyConstructor
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...
void CheckVirtualDtorCall(CXXDestructorDecl *dtor, SourceLocation Loc, bool IsDelete, bool CallCanBeVirtual, bool WarnOnNonAbstractTypes, SourceLocation DtorLoc)
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...
bool IsAllowedCUDACall(const FunctionDecl *Caller, const FunctionDecl *Callee)
Determines whether Caller may invoke Callee, based on their CUDA host/device attributes.
SourceLocation getLocStart() const LLVM_READONLY
BinaryOperator::Opcode getOpcode(const SymExpr *SE)
bool DiagnoseUseOfDecl(NamedDecl *D, SourceLocation Loc, const ObjCInterfaceDecl *UnknownObjCClass=nullptr, bool ObjCPropertyAccess=false, bool AvoidPartialAvailabilityChecks=false)
Determine whether the use of this declaration is valid, and emit any corresponding diagnostics...
CanQualType UnsignedLongLongTy
static bool checkPlaceholderForOverload(Sema &S, Expr *&E, UnbridgedCastsSet *unbridgedCasts=nullptr)
checkPlaceholderForOverload - Do any interesting placeholder-like preprocessing on the given expressi...
Conversions allowed in C, but not C++.
Array-to-pointer conversion (C++ 4.2)
void setConversionChecker(TypeComparisonFuncTy Foo)
Resets the default conversion checker method.
A non-depnedent component of the parameter did not match the corresponding component of the argument...
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.
StandardConversionSequence Before
Represents the standard conversion that occurs before the actual user-defined conversion.
bool IsBlockPointerConversion(QualType FromType, QualType ToType, QualType &ConvertedType)
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
size_t param_size() const
Requests that only viable candidates be shown.
detail::InMemoryDirectory::const_iterator E
bool inTemplateInstantiation() const
Determine whether we are currently performing template instantiation.
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 ...
static bool convertArgsForAvailabilityChecks(Sema &S, FunctionDecl *Function, Expr *ThisArg, ArrayRef< Expr * > Args, Sema::SFINAETrap &Trap, bool MissingImplicitThis, Expr *&ConvertedThis, SmallVectorImpl< Expr * > &ConvertedArgs)
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()
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
This candidate was not viable because its OpenCL extension is disabled.
ObjCInterfaceDecl * getInterfaceDecl() const
If this pointer points to an Objective @interface type, gets the declaration for that interface...
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...
QualType getFunctionType(QualType ResultTy, ArrayRef< QualType > Args, const FunctionProtoType::ExtProtoInfo &EPI) const
Return a normal function type with a typed argument list.
unsigned BindsImplicitObjectArgumentWithoutRefQualifier
Whether this binds an implicit object argument to a non-static member function without a ref-qualifie...
unsigned char FailureKind
FailureKind - The reason why this candidate is not viable.
static bool FindConversionForRefInit(Sema &S, ImplicitConversionSequence &ICS, QualType DeclType, SourceLocation DeclLoc, Expr *Init, QualType T2, bool AllowRvalues, bool AllowExplicit)
Look for a user-defined conversion to a value reference-compatible with DeclType. ...
bool isObjCQualifiedIdType() const
bool isFunctionType() 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.
bool isInitListConstructor(const FunctionDecl *Ctor)
Determine whether Ctor is an initializer-list constructor, as defined in [dcl.init.list]p2.
static bool isNonTrivialObjCLifetimeConversion(Qualifiers FromQuals, Qualifiers ToQuals)
Determine whether the lifetime conversion between the two given qualifiers sets is nontrivial...
void 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
Condition in a constexpr if statement.
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.
void addConversion(NamedDecl *Found, FunctionDecl *D)
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.
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.
TargetCXXABI getCXXABI() const
Get the C++ ABI currently in use.
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 hasQualifier() const
Determines whether this member expression actually had a C++ nested-name-specifier prior to the name ...
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.
After substituting deduced template arguments, an element of a dependent parameter type did not match...
SourceRange getSourceRange() const LLVM_READONLY
SourceLocation tokens are not useful in isolation - they are low level value objects created/interpre...
static void DiagnoseBadTarget(Sema &S, OverloadCandidate *Cand)
CUDA: diagnose an invalid call across targets.
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.
unsigned getAddressSpaceAttributePrintValue() const
Get the address space attribute value to be printed by diagnostics.
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.
A reference to a declared variable, function, enum, etc.
ExprValueKind getValueKind() const
getValueKind - The value kind that this expression produces.
Represents a type template specialization; the template must be a class template, a type alias templa...
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...
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.
bool isUnresolvedExceptionSpec(ExceptionSpecificationType ESpecType)
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...
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
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.
void AddOverloadCandidate(FunctionDecl *Function, DeclAccessPair FoundDecl, ArrayRef< Expr * > Args, OverloadCandidateSet &CandidateSet, bool SuppressUserConversions=false, bool PartialOverloading=false, bool AllowExplicit=false, ConversionSequenceList EarlyConversions=None)
AddOverloadCandidate - Adds the given function to the set of candidate functions, using the given fun...
static OverloadingResult IsUserDefinedConversion(Sema &S, Expr *From, QualType ToType, UserDefinedConversionSequence &User, OverloadCandidateSet &Conversions, bool AllowExplicit, bool AllowObjCConversionOnExplicit)
Determines whether there is a user-defined conversion sequence (C++ [over.ics.user]) that converts ex...
Look up of an operator name (e.g., operator+) for use with operator overloading.
Describes an entity that is being initialized.
void setToType(unsigned Idx, QualType T)
bool isObjCIdType() const
True if this is equivalent to the 'id' type, i.e.
NamespaceDecl * getStdNamespace() const
char Diagnostic[sizeof(PartialDiagnosticAt)]
A diagnostic indicating why deduction failed.
SourceLocation getLocStart() const LLVM_READONLY
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 ...
Declaration of a template function.
void clear()
Clears out any current state.
static bool diagnoseDiagnoseIfAttrsWith(Sema &S, const NamedDecl *ND, bool ArgDependent, SourceLocation Loc, CheckFn &&IsSuccessful)
A class which abstracts out some details necessary for making a call.
static QualType BuildSimilarlyQualifiedPointerType(const Type *FromPtr, QualType ToPointee, QualType ToType, ASTContext &Context, bool StripObjCLifetime=false)
BuildSimilarlyQualifiedPointerType - In a pointer conversion from the pointer type FromPtr to a point...
static ImplicitConversionSequence TryUserDefinedConversion(Sema &S, Expr *From, QualType ToType, bool SuppressUserConversions, bool AllowExplicit, bool InOverloadResolution, bool CStyle, bool AllowObjCWritebackConversion, bool AllowObjCConversionOnExplicit)
Tries a user-defined conversion from From to ToType.
QualType getUnqualifiedArrayType(QualType T, Qualifiers &Quals)
Return this type as a completely-unqualified array type, capturing the qualifiers in Quals...
Attr - This represents one attribute.
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).
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)