31 #include "llvm/ADT/DenseSet.h"
32 #include "llvm/ADT/STLExtras.h"
33 #include "llvm/ADT/SmallPtrSet.h"
34 #include "llvm/ADT/SmallString.h"
38 using namespace clang;
43 std::mem_fn(&ParmVarDecl::hasAttr<PassObjectSizeAttr>));
49 bool HadMultipleCandidates,
64 if (HadMultipleCandidates)
69 CK_FunctionToPointerDecay);
73 bool InOverloadResolution,
76 bool AllowObjCWritebackConversion);
80 bool InOverloadResolution,
88 bool AllowObjCConversionOnExplicit);
140 return Rank[(int)Kind];
150 "Function-to-pointer",
151 "Noreturn adjustment",
153 "Integral promotion",
154 "Floating point promotion",
156 "Integral conversion",
157 "Floating conversion",
158 "Complex conversion",
159 "Floating-integral conversion",
160 "Pointer conversion",
161 "Pointer-to-member conversion",
162 "Boolean conversion",
163 "Compatible-types conversion",
164 "Derived-to-base conversion",
167 "Complex-real conversion",
168 "Block Pointer conversion",
169 "Transparent Union Conversion",
170 "Writeback conversion",
171 "OpenCL Zero Event Conversion",
172 "C specific type conversion"
183 DeprecatedStringLiteralToCharPtr =
false;
184 QualificationIncludesObjCLifetime =
false;
185 ReferenceBinding =
false;
186 DirectBinding =
false;
187 IsLvalueReference =
true;
188 BindsToFunctionLvalue =
false;
189 BindsToRvalue =
false;
190 BindsImplicitObjectArgumentWithoutRefQualifier =
false;
191 ObjCLifetimeConversionBinding =
false;
192 CopyConstructor =
nullptr;
219 (getFromType()->isPointerType() ||
220 getFromType()->isObjCObjectPointerType() ||
221 getFromType()->isBlockPointerType() ||
222 getFromType()->isNullPtrType() ||
255 while (
const ImplicitCastExpr *ICE = dyn_cast<ImplicitCastExpr>(Converted)) {
256 switch (ICE->getCastKind()) {
258 case CK_IntegralCast:
259 case CK_IntegralToBoolean:
260 case CK_IntegralToFloating:
261 case CK_BooleanToSignedIntegral:
262 case CK_FloatingToIntegral:
263 case CK_FloatingToBoolean:
264 case CK_FloatingCast:
265 Converted = ICE->getSubExpr();
287 const Expr *Converted,
290 assert(Ctx.
getLangOpts().CPlusPlus &&
"narrowing check outside C++");
301 ToType = ET->getDecl()->getIntegerType();
306 if (FromType->isRealFloatingType())
307 goto FloatingIntegralConversion;
308 if (FromType->isIntegralOrUnscopedEnumerationType())
309 goto IntegralConversion;
321 FloatingIntegralConversion:
322 if (FromType->isRealFloatingType() && ToType->
isIntegralType(Ctx)) {
325 llvm::APSInt IntConstantValue;
331 Result.convertFromAPInt(IntConstantValue, IntConstantValue.isSigned(),
332 llvm::APFloat::rmNearestTiesToEven);
334 llvm::APSInt ConvertedValue = IntConstantValue;
336 Result.convertToInteger(ConvertedValue,
337 llvm::APFloat::rmTowardZero, &ignored);
339 if (IntConstantValue != ConvertedValue) {
340 ConstantValue =
APValue(IntConstantValue);
341 ConstantType = Initializer->
getType();
362 assert(ConstantValue.
isFloat());
363 llvm::APFloat FloatVal = ConstantValue.
getFloat();
366 llvm::APFloat::opStatus ConvertStatus = FloatVal.convert(
368 llvm::APFloat::rmNearestTiesToEven, &ignored);
371 if (ConvertStatus & llvm::APFloat::opOverflow) {
372 ConstantType = Initializer->
getType();
387 IntegralConversion: {
388 assert(FromType->isIntegralOrUnscopedEnumerationType());
390 const bool FromSigned = FromType->isSignedIntegerOrEnumerationType();
391 const unsigned FromWidth = Ctx.
getIntWidth(FromType);
395 if (FromWidth > ToWidth ||
396 (FromWidth == ToWidth && FromSigned != ToSigned) ||
397 (FromSigned && !ToSigned)) {
399 llvm::APSInt InitializerValue;
405 bool Narrowing =
false;
406 if (FromWidth < ToWidth) {
409 if (InitializerValue.isSigned() && InitializerValue.isNegative())
414 InitializerValue = InitializerValue.extend(
415 InitializerValue.getBitWidth() + 1);
417 llvm::APSInt ConvertedValue = InitializerValue;
418 ConvertedValue = ConvertedValue.trunc(ToWidth);
419 ConvertedValue.setIsSigned(ToSigned);
420 ConvertedValue = ConvertedValue.extend(InitializerValue.getBitWidth());
421 ConvertedValue.setIsSigned(InitializerValue.isSigned());
423 if (ConvertedValue != InitializerValue)
427 ConstantType = Initializer->
getType();
428 ConstantValue =
APValue(InitializerValue);
444 raw_ostream &OS = llvm::errs();
445 bool PrintedSomething =
false;
448 PrintedSomething =
true;
452 if (PrintedSomething) {
457 if (CopyConstructor) {
458 OS <<
" (by copy constructor)";
459 }
else if (DirectBinding) {
460 OS <<
" (direct reference binding)";
461 }
else if (ReferenceBinding) {
462 OS <<
" (reference binding)";
464 PrintedSomething =
true;
468 if (PrintedSomething) {
472 PrintedSomething =
true;
475 if (!PrintedSomething) {
476 OS <<
"No conversions required";
483 raw_ostream &OS = llvm::errs();
484 if (Before.First || Before.Second || Before.Third) {
488 if (ConversionFunction)
489 OS <<
'\'' << *ConversionFunction <<
'\'';
491 OS <<
"aggregate initialization";
501 raw_ostream &OS = llvm::errs();
502 if (isStdInitializerListElement())
503 OS <<
"Worst std::initializer_list element conversion: ";
504 switch (ConversionKind) {
505 case StandardConversion:
506 OS <<
"Standard conversion: ";
509 case UserDefinedConversion:
510 OS <<
"User-defined conversion: ";
513 case EllipsisConversion:
514 OS <<
"Ellipsis conversion";
516 case AmbiguousConversion:
517 OS <<
"Ambiguous conversion";
520 OS <<
"Bad conversion";
532 conversions().~ConversionSet();
545 struct DFIArguments {
551 struct DFIParamWithArguments : DFIArguments {
556 struct DFIDeducedMismatchArgs : DFIArguments {
558 unsigned CallArgIndex;
569 Result.
Result =
static_cast<unsigned>(TDK);
578 Result.
Data =
nullptr;
583 Result.
Data = Info.
Param.getOpaqueValue();
588 auto *Saved =
new (
Context) DFIDeducedMismatchArgs;
591 Saved->TemplateArgs = Info.
take();
599 DFIArguments *Saved =
new (
Context) DFIArguments;
609 DFIParamWithArguments *Saved =
new (
Context) DFIParamWithArguments;
610 Saved->Param = Info.
Param;
636 switch (static_cast<Sema::TemplateDeductionResult>(
Result)) {
659 Diag->~PartialDiagnosticAt();
660 HasDiagnostic =
false;
677 switch (static_cast<Sema::TemplateDeductionResult>(
Result)) {
691 return TemplateParameter::getFromOpaqueValue(Data);
695 return static_cast<DFIParamWithArguments*
>(Data)->Param;
706 switch (static_cast<Sema::TemplateDeductionResult>(
Result)) {
721 return static_cast<DFIDeducedMismatchArgs*
>(Data)->TemplateArgs;
735 switch (static_cast<Sema::TemplateDeductionResult>(
Result)) {
751 return &
static_cast<DFIArguments*
>(Data)->FirstArg;
762 switch (static_cast<Sema::TemplateDeductionResult>(
Result)) {
778 return &
static_cast<DFIArguments*
>(Data)->SecondArg;
789 if (static_cast<Sema::TemplateDeductionResult>(
Result) ==
791 return static_cast<Expr*
>(Data);
797 if (static_cast<Sema::TemplateDeductionResult>(
Result) ==
799 return static_cast<DFIDeducedMismatchArgs*
>(Data)->CallArgIndex;
804 void OverloadCandidateSet::destroyCandidates() {
806 for (
unsigned ii = 0, ie = i->NumConversions; ii != ie; ++ii)
807 i->Conversions[ii].~ImplicitConversionSequence();
809 i->DeductionFailure.Destroy();
815 NumInlineSequences = 0;
821 class UnbridgedCastsSet {
831 Entry entry = { &
E, E };
832 Entries.push_back(entry);
838 i = Entries.begin(), e = Entries.end(); i != e; ++i)
853 UnbridgedCastsSet *unbridgedCasts =
nullptr) {
857 if (placeholder->getKind() == BuiltinType::Overload)
return false;
861 if (placeholder->getKind() == BuiltinType::ARCUnbridgedCast &&
863 unbridgedCasts->save(S, E);
884 UnbridgedCastsSet &unbridged) {
885 for (
unsigned i = 0, e = Args.size(); i != e; ++i)
928 NamedDecl *&Match,
bool NewIsUsingDecl) {
933 bool OldIsUsingDecl =
false;
934 if (isa<UsingShadowDecl>(OldD)) {
935 OldIsUsingDecl =
true;
939 if (NewIsUsingDecl)
continue;
941 OldD = cast<UsingShadowDecl>(OldD)->getTargetDecl();
946 if ((OldIsUsingDecl || NewIsUsingDecl) && !isVisible(*
I))
954 bool UseMemberUsingDeclRules =
955 (OldIsUsingDecl || NewIsUsingDecl) && CurContext->isRecord() &&
956 !New->getFriendObjectKind();
959 if (!IsOverload(New, OldF, UseMemberUsingDeclRules)) {
960 if (UseMemberUsingDeclRules && OldIsUsingDecl) {
961 HideUsingShadowDecl(S, cast<UsingShadowDecl>(*
I));
965 if (!isa<FunctionTemplateDecl>(OldD) &&
966 !shouldLinkPossiblyHiddenDecl(*
I, New))
972 }
else if (isa<UsingDecl>(OldD)) {
976 }
else if (isa<TagDecl>(OldD)) {
978 }
else if (isa<UnresolvedUsingValueDecl>(OldD)) {
987 return Ovl_NonFunction;
995 bool UseMemberUsingDeclRules,
bool ConsiderCudaAttrs) {
1010 if ((OldTemplate ==
nullptr) != (NewTemplate ==
nullptr))
1023 if (isa<FunctionNoProtoType>(OldQType.
getTypePtr()) ||
1024 isa<FunctionNoProtoType>(NewQType.
getTypePtr()))
1033 if (OldQType != NewQType &&
1035 OldType->
isVariadic() != NewType->isVariadic() ||
1036 !FunctionParamTypesAreEqual(OldType, NewType)))
1051 if (!UseMemberUsingDeclRules && NewTemplate &&
1054 false, TPL_TemplateMatch) ||
1068 if (OldMethod && NewMethod &&
1069 !OldMethod->
isStatic() && !NewMethod->isStatic()) {
1071 if (!UseMemberUsingDeclRules &&
1073 NewMethod->getRefQualifier() ==
RQ_None)) {
1080 Diag(NewMethod->getLocation(), diag::err_ref_qualifier_overload)
1082 Diag(OldMethod->getLocation(), diag::note_previous_declaration);
1092 unsigned NewQuals = NewMethod->getTypeQualifiers();
1093 if (!getLangOpts().
CPlusPlus14 && NewMethod->isConstexpr() &&
1094 !isa<CXXConstructorDecl>(NewMethod))
1100 if (OldQuals != NewQuals)
1114 NewI = New->specific_attr_begin<EnableIfAttr>(),
1115 NewE = New->specific_attr_end<EnableIfAttr>(),
1116 OldI = Old->specific_attr_begin<EnableIfAttr>(),
1117 OldE = Old->specific_attr_end<EnableIfAttr>();
1118 NewI != NewE || OldI != OldE; ++NewI, ++OldI) {
1119 if (NewI == NewE || OldI == OldE)
1121 llvm::FoldingSetNodeID NewID, OldID;
1123 OldI->getCond()->Profile(OldID,
Context,
true);
1128 if (getLangOpts().CUDA && ConsiderCudaAttrs) {
1130 OldTarget = IdentifyCUDATarget(Old);
1131 if (NewTarget == CFT_InvalidTarget || NewTarget == CFT_Global)
1134 assert((OldTarget != CFT_InvalidTarget) &&
"Unexpected invalid target.");
1141 if ((NewTarget == CFT_HostDevice) || (OldTarget == CFT_HostDevice) ||
1142 (NewTarget == CFT_Global) || (OldTarget == CFT_Global))
1147 return NewTarget != OldTarget;
1160 if (!FD->isUnavailable())
1164 Decl *C = cast<Decl>(CurContext);
1166 if (C->isUnavailable())
1168 }
while ((C = cast_or_null<Decl>(C->getDeclContext())));
1178 bool SuppressUserConversions,
1180 bool InOverloadResolution,
1182 bool AllowObjCWritebackConversion,
1183 bool AllowObjCConversionOnExplicit) {
1186 if (SuppressUserConversions) {
1197 Conversions, AllowExplicit,
1198 AllowObjCConversionOnExplicit)) {
1216 if (Constructor->isCopyConstructor() &&
1217 (FromCanon == ToCanon ||
1218 S.
IsDerivedFrom(From->getLocStart(), FromCanon, ToCanon))) {
1228 if (ToCanon != FromCanon)
1239 Cand != Conversions.end(); ++Cand)
1282 bool SuppressUserConversions,
1284 bool InOverloadResolution,
1286 bool AllowObjCWritebackConversion,
1287 bool AllowObjCConversionOnExplicit) {
1290 ICS.
Standard, CStyle, AllowObjCWritebackConversion)){
1330 AllowExplicit, InOverloadResolution, CStyle,
1331 AllowObjCWritebackConversion,
1332 AllowObjCConversionOnExplicit);
1337 bool SuppressUserConversions,
1339 bool InOverloadResolution,
1341 bool AllowObjCWritebackConversion) {
1343 SuppressUserConversions, AllowExplicit,
1344 InOverloadResolution, CStyle,
1345 AllowObjCWritebackConversion,
1358 return PerformImplicitConversion(From, ToType, Action, AllowExplicit, ICS);
1369 bool AllowObjCWritebackConversion
1370 = getLangOpts().ObjCAutoRefCount &&
1371 (Action == AA_Passing || Action == AA_Sending);
1372 if (getLangOpts().ObjC1)
1373 CheckObjCBridgeRelatedConversions(From->getLocStart(),
1374 ToType, From->
getType(), From);
1380 AllowObjCWritebackConversion,
1382 return PerformImplicitConversion(From, ToType, ICS, Action);
1400 if (TyClass != CanFrom->getTypeClass())
return false;
1401 if (TyClass != Type::FunctionProto && TyClass != Type::FunctionNoProto) {
1402 if (TyClass == Type::Pointer) {
1405 }
else if (TyClass == Type::BlockPointer) {
1408 }
else if (TyClass == Type::MemberPointer) {
1415 TyClass = CanTo->getTypeClass();
1416 if (TyClass != CanFrom->getTypeClass())
return false;
1417 if (TyClass != Type::FunctionProto && TyClass != Type::FunctionNoProto)
1421 const FunctionType *FromFn = cast<FunctionType>(CanFrom);
1423 if (!EInfo.getNoReturn())
return false;
1426 assert(
QualType(FromFn, 0).isCanonical());
1427 if (
QualType(FromFn, 0) != CanTo)
return false;
1479 bool InOverloadResolution,
1492 bool InOverloadResolution,
1495 bool AllowObjCWritebackConversion) {
1542 if (Method && !Method->
isStatic()) {
1544 "Non-unary operator on non-static member address");
1545 assert(cast<UnaryOperator>(From->
IgnoreParens())->getOpcode()
1547 "Non-address-of operator on non-static member address");
1548 const Type *ClassType
1552 assert(cast<UnaryOperator>(From->
IgnoreParens())->getOpcode() ==
1554 "Non-address-of operator for overloaded function expression");
1579 FromType = Atomic->getValueType();
1614 if (
auto *FD = dyn_cast<FunctionDecl>(DRE->getDecl()))
1634 bool IncompatibleObjC =
false;
1685 if (Float128AndLongDouble &&
1687 &llvm::APFloat::IEEEdouble))
1702 }
else if (AllowObjCWritebackConversion &&
1706 FromType, IncompatibleObjC)) {
1712 InOverloadResolution, FromType)) {
1727 InOverloadResolution,
1750 bool ObjCLifetimeConversion;
1752 ObjCLifetimeConversion)) {
1772 CanonFrom = CanonTo;
1777 if (CanonFrom == CanonTo)
1782 if (S.
getLangOpts().CPlusPlus || !InOverloadResolution)
1805 bool InOverloadResolution,
1810 if (!UT || !UT->
getDecl()->hasAttr<TransparentUnionAttr>())
1815 for (
const auto *it : UD->
fields()) {
1818 ToType = it->getType();
1848 return To->
getKind() == BuiltinType::Int;
1851 return To->
getKind() == BuiltinType::UInt;
1875 if (FromEnumType->getDecl()->isScoped())
1882 if (FromEnumType->getDecl()->isFixed()) {
1883 QualType Underlying = FromEnumType->getDecl()->getIntegerType();
1885 IsIntegralPromotion(
nullptr, Underlying, ToType);
1890 isCompleteType(From->getLocStart(), FromType))
1892 ToType, FromEnumType->getDecl()->getPromotionType());
1918 for (
int Idx = 0; Idx < 6; ++Idx) {
1920 if (FromSize < ToSize ||
1921 (FromSize == ToSize &&
1922 FromIsSigned == PromoteTypes[Idx]->isSignedIntegerType())) {
1942 llvm::APSInt BitWidth;
1944 MemberDecl->getBitWidth()->isIntegerConstantExpr(BitWidth,
Context)) {
1945 llvm::APSInt ToSize(BitWidth.getBitWidth(), BitWidth.isUnsigned());
1949 if (BitWidth < ToSize ||
1951 return To->
getKind() == BuiltinType::Int;
1957 return To->
getKind() == BuiltinType::UInt;
1982 if (FromBuiltin->getKind() == BuiltinType::Float &&
1983 ToBuiltin->getKind() == BuiltinType::Double)
1989 if (!getLangOpts().CPlusPlus &&
1990 (FromBuiltin->getKind() == BuiltinType::Float ||
1991 FromBuiltin->getKind() == BuiltinType::Double) &&
1992 (ToBuiltin->getKind() == BuiltinType::LongDouble ||
1993 ToBuiltin->getKind() == BuiltinType::Float128))
1997 if (!getLangOpts().NativeHalfType &&
1998 FromBuiltin->getKind() == BuiltinType::Half &&
1999 ToBuiltin->getKind() == BuiltinType::Float)
2036 bool StripObjCLifetime =
false) {
2039 "Invalid similarly-qualified pointer type");
2050 if (StripObjCLifetime)
2061 if (isa<ObjCObjectPointerType>(ToType))
2070 if (isa<ObjCObjectPointerType>(ToType))
2076 bool InOverloadResolution,
2082 return !InOverloadResolution;
2106 bool InOverloadResolution,
2108 bool &IncompatibleObjC) {
2109 IncompatibleObjC =
false;
2110 if (isObjCPointerConversion(FromType, ToType, ConvertedType,
2117 ConvertedType = ToType;
2124 ConvertedType = ToType;
2131 ConvertedType = ToType;
2139 ConvertedType = ToType;
2149 ConvertedType = ToType;
2157 !getLangOpts().ObjCAutoRefCount) {
2188 if (getLangOpts().MSVCCompat && FromPointeeType->
isFunctionType() &&
2222 IsDerivedFrom(From->getLocStart(), FromPointeeType, ToPointeeType)) {
2259 bool &IncompatibleObjC) {
2260 if (!getLangOpts().ObjC1)
2272 if (ToObjCPtr && FromObjCPtr) {
2283 if (getLangOpts().
CPlusPlus && LHS && RHS &&
2285 FromObjCPtr->getPointeeType()))
2298 IncompatibleObjC =
true;
2314 if (FromObjCPtr && FromObjCPtr->isObjCBuiltinType()) {
2342 isObjCPointerConversion(FromPointeeType, ToPointeeType, ConvertedType,
2343 IncompatibleObjC)) {
2345 IncompatibleObjC =
true;
2354 isObjCPointerConversion(FromPointeeType, ToPointeeType, ConvertedType,
2355 IncompatibleObjC)) {
2370 if (FromFunctionType && ToFunctionType) {
2379 if (FromFunctionType->
getNumParams() != ToFunctionType->getNumParams() ||
2380 FromFunctionType->
isVariadic() != ToFunctionType->isVariadic() ||
2381 FromFunctionType->
getTypeQuals() != ToFunctionType->getTypeQuals())
2384 bool HasObjCConversion =
false;
2388 }
else if (isObjCPointerConversion(FromFunctionType->
getReturnType(),
2389 ToFunctionType->getReturnType(),
2390 ConvertedType, IncompatibleObjC)) {
2392 HasObjCConversion =
true;
2400 ArgIdx !=
NumArgs; ++ArgIdx) {
2402 QualType ToArgType = ToFunctionType->getParamType(ArgIdx);
2406 }
else if (isObjCPointerConversion(FromArgType, ToArgType,
2407 ConvertedType, IncompatibleObjC)) {
2409 HasObjCConversion =
true;
2416 if (HasObjCConversion) {
2420 IncompatibleObjC =
true;
2439 if (!getLangOpts().ObjCAutoRefCount ||
2481 bool IncompatibleObjC;
2483 FromPointee = ToPointee;
2484 else if (!isObjCPointerConversion(FromPointee, ToPointee, FromPointee,
2519 if (!FromFunctionType || !ToFunctionType)
2527 if (FromFunctionType->
getNumParams() != ToFunctionType->getNumParams() ||
2528 FromFunctionType->
isVariadic() != ToFunctionType->isVariadic())
2533 if (FromEInfo != ToEInfo)
2536 bool IncompatibleObjC =
false;
2538 ToFunctionType->getReturnType())) {
2542 QualType LHS = ToFunctionType->getReturnType();
2549 }
else if (isObjCPointerConversion(RHS, LHS,
2550 ConvertedType, IncompatibleObjC)) {
2551 if (IncompatibleObjC)
2561 ArgIdx !=
NumArgs; ++ArgIdx) {
2562 IncompatibleObjC =
false;
2564 QualType ToArgType = ToFunctionType->getParamType(ArgIdx);
2567 }
else if (isObjCPointerConversion(ToArgType, FromArgType,
2568 ConvertedType, IncompatibleObjC)) {
2569 if (IncompatibleObjC)
2580 ConvertedType = ToType;
2655 if (!FromFunction || !ToFunction) {
2660 if (FromFunction->
getNumParams() != ToFunction->getNumParams()) {
2668 if (!FunctionParamTypesAreEqual(FromFunction, ToFunction, &ArgPos)) {
2670 << ToFunction->getParamType(ArgPos)
2677 ToFunction->getReturnType())) {
2684 ToQuals = ToFunction->getTypeQuals();
2685 if (FromQuals != ToQuals) {
2704 O && (O !=
E); ++O, ++N) {
2706 N->getUnqualifiedType())) {
2724 bool IgnoreBaseAccess,
2727 bool IsCStyleOrFunctionalCast = IgnoreBaseAccess;
2731 if (Diagnose && !IsCStyleOrFunctionalCast && !FromType->
isAnyPointerType() &&
2735 DiagRuntimeBehavior(From->
getExprLoc(), From,
2736 PDiag(diag::warn_impcast_bool_to_null_pointer)
2737 << ToType << From->getSourceRange());
2738 else if (!isUnevaluatedContext())
2740 << ToType << From->getSourceRange();
2747 if (FromPointeeType->
isRecordType() && ToPointeeType->isRecordType() &&
2751 unsigned InaccessibleID = 0;
2752 unsigned AmbigiousID = 0;
2754 InaccessibleID = diag::err_upcast_to_inaccessible_base;
2755 AmbigiousID = diag::err_ambiguous_derived_to_base_conv;
2757 if (CheckDerivedToBaseConversion(
2758 FromPointeeType, ToPointeeType, InaccessibleID, AmbigiousID,
2760 &BasePath, IgnoreBaseAccess))
2764 Kind = CK_DerivedToBase;
2767 if (Diagnose && !IsCStyleOrFunctionalCast &&
2768 FromPointeeType->
isFunctionType() && ToPointeeType->isVoidType()) {
2769 assert(getLangOpts().MSVCCompat &&
2770 "this should only be possible with MSVCCompat!");
2772 << From->getSourceRange();
2782 if (FromPtrType->isObjCBuiltinType() || ToPtrType->isObjCBuiltinType())
2785 Kind = CK_BlockPointerToObjCPointerCast;
2787 Kind = CK_CPointerToObjCPointerCast;
2791 Kind = CK_AnyPointerToBlockPointerCast;
2797 Kind = CK_NullToPointer;
2809 bool InOverloadResolution,
2819 ConvertedType = ToType;
2834 IsDerivedFrom(From->getLocStart(), ToClass, FromClass)) {
2852 bool IgnoreBaseAccess) {
2859 "Expr must be null pointer constant!");
2860 Kind = CK_NullToMemberPointer;
2865 assert(ToPtrType &&
"No member pointer cast has a target type "
2866 "that is not a member pointer.");
2872 assert(FromClass->
isRecordType() &&
"Pointer into non-class.");
2873 assert(ToClass->isRecordType() &&
"Pointer into non-class.");
2877 bool DerivationOkay =
2878 IsDerivedFrom(From->getLocStart(), ToClass, FromClass, Paths);
2879 assert(DerivationOkay &&
2880 "Should not have been called if derivation isn't OK.");
2881 (void)DerivationOkay;
2884 getUnqualifiedType())) {
2885 std::string PathDisplayStr = getAmbiguousPathsDisplayString(Paths);
2887 << 0 << FromClass << ToClass << PathDisplayStr << From->getSourceRange();
2891 if (
const RecordType *VBase = Paths.getDetectedVirtual()) {
2893 << FromClass << ToClass <<
QualType(VBase, 0)
2894 << From->getSourceRange();
2898 if (!IgnoreBaseAccess)
2899 CheckBaseClassAccess(From->
getExprLoc(), FromClass, ToClass,
2901 diag::err_downcast_from_inaccessible_base);
2904 BuildBasePathArray(Paths, BasePath);
2905 Kind = CK_BaseToDerivedMemberPointer;
2930 bool CStyle,
bool &ObjCLifetimeConversion) {
2933 ObjCLifetimeConversion =
false;
2943 bool PreviousToQualsIncludeConst =
true;
2944 bool UnwrappedAnyPointer =
false;
2952 UnwrappedAnyPointer =
true;
2964 UnwrappedAnyPointer) {
2967 ObjCLifetimeConversion =
true;
2992 && !PreviousToQualsIncludeConst)
2997 PreviousToQualsIncludeConst
2998 = PreviousToQualsIncludeConst && ToQuals.
hasConst();
3015 bool InOverloadResolution,
3024 InOverloadResolution, InnerSCS,
3028 SCS.
Second = InnerSCS.Second;
3029 SCS.
setToType(1, InnerSCS.getToType(1));
3030 SCS.
Third = InnerSCS.Third;
3032 = InnerSCS.QualificationIncludesObjCLifetime;
3033 SCS.
setToType(2, InnerSCS.getToType(2));
3055 bool AllowExplicit) {
3061 bool Usable = !Info.Constructor->isInvalidDecl() &&
3063 (AllowExplicit || !Info.Constructor->isExplicit());
3068 S.
Context, Info.Constructor, ToType);
3069 if (Info.ConstructorTmpl)
3072 CandidateSet, SuppressUserConversions);
3075 CandidateSet, SuppressUserConversions);
3079 bool HadMultipleCandidates = (CandidateSet.
size() > 1);
3107 llvm_unreachable(
"Invalid OverloadResult!");
3129 bool AllowObjCConversionOnExplicit) {
3130 assert(AllowExplicit || !AllowObjCConversionOnExplicit);
3133 bool ConstructorsOnly =
false;
3149 ConstructorsOnly =
true;
3154 = dyn_cast<CXXRecordDecl>(ToRecordType->getDecl())) {
3156 Expr **Args = &From;
3158 bool ListInitializing =
false;
3159 if (
InitListExpr *InitList = dyn_cast<InitListExpr>(From)) {
3162 S, From, ToType, ToRecordDecl, User, CandidateSet, AllowExplicit);
3166 CandidateSet.
clear();
3170 Args = InitList->getInits();
3171 NumArgs = InitList->getNumInits();
3172 ListInitializing =
true;
3180 bool Usable = !Info.Constructor->isInvalidDecl();
3181 if (ListInitializing)
3182 Usable = Usable && (AllowExplicit || !Info.Constructor->isExplicit());
3185 Info.Constructor->isConvertingConstructor(AllowExplicit);
3187 bool SuppressUserConversions = !ConstructorsOnly;
3188 if (SuppressUserConversions && ListInitializing) {
3189 SuppressUserConversions =
false;
3194 S.
Context, Info.Constructor, ToType);
3197 if (Info.ConstructorTmpl)
3199 Info.ConstructorTmpl, Info.FoundDecl,
3200 nullptr, llvm::makeArrayRef(Args, NumArgs),
3201 CandidateSet, SuppressUserConversions);
3206 llvm::makeArrayRef(Args, NumArgs),
3207 CandidateSet, SuppressUserConversions);
3214 if (ConstructorsOnly || isa<InitListExpr>(From)) {
3220 = dyn_cast<CXXRecordDecl>(FromRecordType->getDecl())) {
3222 const auto &Conversions = FromRecordDecl->getVisibleConversionFunctions();
3223 for (
auto I = Conversions.begin(), E = Conversions.end();
I !=
E; ++
I) {
3226 CXXRecordDecl *ActingContext = cast<CXXRecordDecl>(D->getDeclContext());
3227 if (isa<UsingShadowDecl>(D))
3228 D = cast<UsingShadowDecl>(D)->getTargetDecl();
3232 if ((ConvTemplate = dyn_cast<FunctionTemplateDecl>(D)))
3235 Conv = cast<CXXConversionDecl>(D);
3237 if (AllowExplicit || !Conv->isExplicit()) {
3240 ActingContext, From, ToType,
3242 AllowObjCConversionOnExplicit);
3245 From, ToType, CandidateSet,
3246 AllowObjCConversionOnExplicit);
3252 bool HadMultipleCandidates = (CandidateSet.
size() > 1);
3261 = dyn_cast<CXXConstructorDecl>(Best->Function)) {
3269 if (isa<InitListExpr>(From)) {
3273 if (Best->Conversions[0].isEllipsis())
3276 User.
Before = Best->Conversions[0].Standard;
3289 = dyn_cast<CXXConversionDecl>(Best->Function)) {
3296 User.
Before = Best->Conversions[0].Standard;
3311 User.
After = Best->FinalConversion;
3314 llvm_unreachable(
"Not a constructor or conversion function?");
3323 llvm_unreachable(
"Invalid OverloadResult!");
3333 CandidateSet,
false,
false);
3335 Diag(From->getLocStart(), diag::err_typecheck_ambiguous_condition)
3336 << From->
getType() << ToType << From->getSourceRange();
3339 diag::err_typecheck_nonviable_condition_incomplete,
3340 From->
getType(), From->getSourceRange()))
3341 Diag(From->getLocStart(), diag::err_typecheck_nonviable_condition)
3342 <<
false << From->
getType() << From->getSourceRange() << ToType;
3375 if (Block1 != Block2)
3462 if (!ICS1.
isBad()) {
3605 else if (Rank2 < Rank1)
3626 bool SCS1ConvertsToVoid
3628 bool SCS2ConvertsToVoid
3630 if (SCS1ConvertsToVoid != SCS2ConvertsToVoid) {
3635 }
else if (!SCS1ConvertsToVoid && !SCS2ConvertsToVoid) {
3641 }
else if (SCS1ConvertsToVoid && SCS2ConvertsToVoid &&
3670 if (FromObjCPtr1 && FromObjCPtr2) {
3675 if (AssignLeft != AssignRight) {
3708 if (UnqualT1 == UnqualT2) {
3720 if (isa<ArrayType>(T1) && T1Quals)
3722 if (isa<ArrayType>(T2) && T2Quals)
3781 if (UnqualT1 == UnqualT2)
3786 if (isa<ArrayType>(T1) && T1Quals)
3788 if (isa<ArrayType>(T2) && T2Quals)
3911 if (FromPointee1 == FromPointee2 && ToPointee1 != ToPointee2) {
3919 if (FromPointee1 != FromPointee2 && ToPointee1 == ToPointee2) {
3936 if (FromPtr1 && FromPtr2 && ToPtr1 && ToPtr2) {
3943 bool FromAssignRight
3952 if (ToPtr1->isObjCIdType() &&
3953 (ToPtr2->isObjCQualifiedIdType() || ToPtr2->getInterfaceDecl()))
3955 if (ToPtr2->isObjCIdType() &&
3956 (ToPtr1->isObjCQualifiedIdType() || ToPtr1->getInterfaceDecl()))
3961 if (ToPtr1->isObjCQualifiedIdType() && ToPtr2->getInterfaceDecl())
3963 if (ToPtr2->isObjCQualifiedIdType() && ToPtr1->getInterfaceDecl())
3968 if (ToPtr1->isObjCClassType() &&
3969 (ToPtr2->isObjCQualifiedClassType() || ToPtr2->getInterfaceDecl()))
3971 if (ToPtr2->isObjCClassType() &&
3972 (ToPtr1->isObjCQualifiedClassType() || ToPtr1->getInterfaceDecl()))
3977 if (ToPtr1->isObjCQualifiedClassType() && ToPtr2->getInterfaceDecl())
3979 if (ToPtr2->isObjCQualifiedClassType() && ToPtr1->getInterfaceDecl())
3985 (ToAssignLeft != ToAssignRight))
3991 (FromAssignLeft != FromAssignRight))
4009 const Type *FromPointeeType1 = FromMemPointer1->
getClass();
4010 const Type *ToPointeeType1 = ToMemPointer1->getClass();
4011 const Type *FromPointeeType2 = FromMemPointer2->getClass();
4012 const Type *ToPointeeType2 = ToMemPointer2->getClass();
4018 if (FromPointee1 == FromPointee2 && ToPointee1 != ToPointee2) {
4025 if (ToPointee1 == ToPointee2 && FromPointee1 != FromPointee2) {
4066 return !Record->isInvalidDecl();
4081 bool &DerivedToBase,
4082 bool &ObjCConversion,
4083 bool &ObjCLifetimeConversion) {
4085 "T1 must be the pointee type of the reference type");
4086 assert(!OrigT2->
isReferenceType() &&
"T2 cannot be a reference type");
4098 DerivedToBase =
false;
4099 ObjCConversion =
false;
4100 ObjCLifetimeConversion =
false;
4101 if (UnqualT1 == UnqualT2) {
4106 DerivedToBase =
true;
4110 ObjCConversion =
true;
4119 if (isa<ArrayType>(T1) && T1Quals)
4121 if (isa<ArrayType>(T2) && T2Quals)
4139 ObjCLifetimeConversion =
true;
4149 if (T1Quals == T2Quals)
4163 bool AllowExplicit) {
4164 assert(T2->
isRecordType() &&
"Can only find conversions of record types.");
4169 const auto &Conversions = T2RecordDecl->getVisibleConversionFunctions();
4170 for (
auto I = Conversions.begin(), E = Conversions.end();
I !=
E; ++
I) {
4172 CXXRecordDecl *ActingDC = cast<CXXRecordDecl>(D->getDeclContext());
4173 if (isa<UsingShadowDecl>(D))
4174 D = cast<UsingShadowDecl>(D)->getTargetDecl();
4182 Conv = cast<CXXConversionDecl>(D);
4186 if (!AllowExplicit && Conv->isExplicit())
4190 bool DerivedToBase =
false;
4191 bool ObjCConversion =
false;
4192 bool ObjCLifetimeConversion =
false;
4203 if (!ConvTemplate &&
4206 Conv->getConversionType().getNonReferenceType()
4207 .getUnqualifiedType(),
4209 DerivedToBase, ObjCConversion, ObjCLifetimeConversion) ==
4227 Init, DeclType, CandidateSet,
4231 DeclType, CandidateSet,
4235 bool HadMultipleCandidates = (CandidateSet.size() > 1);
4238 switch (CandidateSet.BestViableFunction(S, DeclLoc, Best,
true)) {
4250 if (!Best->FinalConversion.DirectBinding)
4262 "Expected a direct reference binding!");
4268 Cand != CandidateSet.end(); ++Cand)
4280 llvm_unreachable(
"Invalid OverloadResult!");
4288 bool SuppressUserConversions,
4289 bool AllowExplicit) {
4290 assert(DeclType->
isReferenceType() &&
"Reference init needs a reference");
4311 bool DerivedToBase =
false;
4312 bool ObjCConversion =
false;
4313 bool ObjCLifetimeConversion =
false;
4317 ObjCConversion, ObjCLifetimeConversion);
4346 ICS.Standard.setToType(0, T2);
4347 ICS.Standard.setToType(1, T1);
4348 ICS.Standard.setToType(2, T1);
4349 ICS.Standard.ReferenceBinding =
true;
4350 ICS.Standard.DirectBinding =
true;
4351 ICS.Standard.IsLvalueReference = !isRValRef;
4353 ICS.Standard.BindsToRvalue =
false;
4354 ICS.Standard.BindsImplicitObjectArgumentWithoutRefQualifier =
false;
4355 ICS.Standard.ObjCLifetimeConversionBinding = ObjCLifetimeConversion;
4356 ICS.Standard.CopyConstructor =
nullptr;
4357 ICS.Standard.DeprecatedStringLiteralToCharPtr =
false;
4404 ICS.Standard.setToType(0, T2);
4405 ICS.Standard.setToType(1, T1);
4406 ICS.Standard.setToType(2, T1);
4407 ICS.Standard.ReferenceBinding =
true;
4413 ICS.Standard.DirectBinding =
4416 ICS.Standard.IsLvalueReference = !isRValRef;
4418 ICS.Standard.BindsToRvalue = InitCategory.
isRValue();
4419 ICS.Standard.BindsImplicitObjectArgumentWithoutRefQualifier =
false;
4420 ICS.Standard.ObjCLifetimeConversionBinding = ObjCLifetimeConversion;
4421 ICS.Standard.CopyConstructor =
nullptr;
4422 ICS.Standard.DeprecatedStringLiteralToCharPtr =
false;
4445 if (ICS.isUserDefined() && isRValRef &&
4517 if (ICS.isStandard()) {
4518 ICS.Standard.ReferenceBinding =
true;
4519 ICS.Standard.IsLvalueReference = !isRValRef;
4520 ICS.Standard.BindsToFunctionLvalue =
false;
4521 ICS.Standard.BindsToRvalue =
true;
4522 ICS.Standard.BindsImplicitObjectArgumentWithoutRefQualifier =
false;
4523 ICS.Standard.ObjCLifetimeConversionBinding =
false;
4524 }
else if (ICS.isUserDefined()) {
4526 ICS.UserDefined.ConversionFunction->getReturnType()
4543 ICS.UserDefined.Before.setAsIdentityConversion();
4544 ICS.UserDefined.After.ReferenceBinding =
true;
4545 ICS.UserDefined.After.IsLvalueReference = !isRValRef;
4546 ICS.UserDefined.After.BindsToFunctionLvalue =
false;
4547 ICS.UserDefined.After.BindsToRvalue = !LValRefType;
4548 ICS.UserDefined.After.BindsImplicitObjectArgumentWithoutRefQualifier =
false;
4549 ICS.UserDefined.After.ObjCLifetimeConversionBinding =
false;
4557 bool SuppressUserConversions,
4558 bool InOverloadResolution,
4559 bool AllowObjCWritebackConversion,
4560 bool AllowExplicit =
false);
4566 bool SuppressUserConversions,
4567 bool InOverloadResolution,
4568 bool AllowObjCWritebackConversion) {
4597 SuppressUserConversions,
4598 InOverloadResolution,
4599 AllowObjCWritebackConversion);
4632 bool toStdInitializerList =
false;
4639 for (
unsigned i = 0, e = From->
getNumInits(); i < e; ++i) {
4643 InOverloadResolution,
4644 AllowObjCWritebackConversion);
4651 if (Result.
isBad() ||
4682 InOverloadResolution,
false,
4683 AllowObjCWritebackConversion,
4737 Init, ToType,
false, Found))
4742 bool dummy1 =
false;
4743 bool dummy2 =
false;
4744 bool dummy3 =
false;
4751 SuppressUserConversions,
4759 InOverloadResolution,
4760 AllowObjCWritebackConversion);
4764 "Sub-initialization cannot result in ellipsis conversion.");
4791 if (NumInits == 1 && !isa<InitListExpr>(From->
getInit(0)))
4793 SuppressUserConversions,
4794 InOverloadResolution,
4795 AllowObjCWritebackConversion);
4798 else if (NumInits == 0) {
4821 bool SuppressUserConversions,
4822 bool InOverloadResolution,
4823 bool AllowObjCWritebackConversion,
4824 bool AllowExplicit) {
4825 if (
InitListExpr *FromInitList = dyn_cast<InitListExpr>(From))
4827 InOverloadResolution,AllowObjCWritebackConversion);
4831 From->getLocStart(),
4832 SuppressUserConversions,
4836 SuppressUserConversions,
4838 InOverloadResolution,
4840 AllowObjCWritebackConversion,
4853 return !ICS.
isBad();
4867 unsigned Quals = isa<CXXDestructorDecl>(Method) ?
4881 assert(FromClassification.
isLValue());
4907 != FromTypeCanon.getLocalCVRQualifiers() &&
4910 FromType, ImplicitParamType);
4924 FromType, ImplicitParamType);
4944 if (!FromClassification.
isRValue()) {
4987 FromRecordType = From->
getType();
4988 DestType = ImplicitParamRecordType;
4995 *
this, From->getLocStart(), From->
getType(), FromClassification, Method,
5003 Diag(From->getLocStart(),
5004 diag::err_member_function_call_bad_cvr)
5005 << Method->getDeclName() << FromRecordType << (CVR - 1)
5006 << From->getSourceRange();
5007 Diag(Method->getLocation(), diag::note_previous_decl)
5008 << Method->getDeclName();
5013 return Diag(From->getLocStart(),
5014 diag::err_implicit_object_parameter_init)
5015 << ImplicitParamRecordType << FromRecordType << From->getSourceRange();
5023 From = FromRes.
get();
5056 return Diag(From->getLocStart(),
5057 diag::err_typecheck_bool_condition)
5058 << From->
getType() << From->getSourceRange();
5114 llvm_unreachable(
"found a first conversion kind in Second");
5117 llvm_unreachable(
"found a third conversion kind in Second");
5123 llvm_unreachable(
"unknown conversion kind");
5134 "converted constant expression outside C++11");
5163 return S.
Diag(From->getLocStart(),
5164 diag::err_typecheck_converted_constant_expression)
5165 << From->
getType() << From->getSourceRange() << T;
5169 llvm_unreachable(
"ellipsis conversion in converted constant expression");
5174 return S.
Diag(From->getLocStart(),
5175 diag::err_typecheck_converted_constant_expression_disallowed)
5176 << From->
getType() << From->getSourceRange() << T;
5180 return S.
Diag(From->getLocStart(),
5181 diag::err_typecheck_converted_constant_expression_indirect)
5182 << From->
getType() << From->getSourceRange() << T;
5194 PreNarrowingType)) {
5202 S.
Diag(From->getLocStart(), diag::ext_cce_narrowing)
5208 S.
Diag(From->getLocStart(), diag::ext_cce_narrowing)
5209 << CCE << 0 << From->
getType() << T;
5221 (RequireInt && !Eval.
Val.
isInt())) {
5228 if (Notes.empty()) {
5235 if (Notes.size() == 1 &&
5236 Notes[0].second.getDiagID() == diag::note_invalid_subexpr_in_const_expr)
5237 S.
Diag(Notes[0].first, diag::err_expr_not_cce) << CCE;
5239 S.
Diag(From->getLocStart(), diag::err_expr_not_cce)
5240 << CCE << From->getSourceRange();
5241 for (
unsigned I = 0;
I < Notes.size(); ++
I)
5242 S.
Diag(Notes[
I].first, Notes[I].second);
5253 llvm::APSInt &
Value,
5341 for (
unsigned I = 0, N = ViableConversions.
size();
I != N; ++
I) {
5343 cast<CXXConversionDecl>(ViableConversions[
I]->getUnderlyingDecl());
5353 QualType T,
bool HadMultipleCandidates,
5355 if (ExplicitConversions.
size() == 1 && !Converter.
Suppress) {
5363 std::string TypeStr;
5368 "static_cast<" + TypeStr +
">(")
5380 HadMultipleCandidates);
5385 CK_UserDefinedConversion, Result.
get(),
5393 QualType T,
bool HadMultipleCandidates,
5405 << From->getSourceRange();
5409 HadMultipleCandidates);
5414 CK_UserDefinedConversion, Result.
get(),
5424 << From->getSourceRange();
5433 for (
unsigned I = 0, N = ViableConversions.
size();
I != N; ++
I) {
5436 CXXRecordDecl *ActingContext = cast<CXXRecordDecl>(D->getDeclContext());
5437 if (isa<UsingShadowDecl>(D))
5438 D = cast<UsingShadowDecl>(D)->getTargetDecl();
5442 if ((ConvTemplate = dyn_cast<FunctionTemplateDecl>(D)))
5445 Conv = cast<CXXConversionDecl>(D);
5449 ConvTemplate, FoundDecl, ActingContext, From, ToType, CandidateSet,
5453 ToType, CandidateSet,
5487 From = result.
get();
5492 if (Converter.
match(T))
5512 : Converter(Converter), From(From) {}
5517 } IncompleteDiagnoser(Converter, From);
5527 const auto &Conversions =
5528 cast<CXXRecordDecl>(RecordTy->
getDecl())->getVisibleConversionFunctions();
5530 bool HadMultipleCandidates =
5531 (
std::distance(Conversions.begin(), Conversions.end()) > 1);
5535 bool HasUniqueTargetType =
true;
5538 for (
auto I = Conversions.begin(), E = Conversions.end();
I !=
E; ++
I) {
5548 Conversion = cast<CXXConversionDecl>(D);
5551 "Conversion operator templates are considered potentially "
5555 if (Converter.
match(CurToType) || ConvTemplate) {
5561 ExplicitConversions.
addDecl(
I.getDecl(),
I.getAccess());
5566 else if (HasUniqueTargetType &&
5568 HasUniqueTargetType =
false;
5570 ViableConversions.
addDecl(
I.getDecl(),
I.getAccess());
5588 HadMultipleCandidates,
5589 ExplicitConversions))
5595 if (!HasUniqueTargetType)
5614 HadMultipleCandidates, Found))
5623 HadMultipleCandidates,
5624 ExplicitConversions))
5632 switch (ViableConversions.
size()) {
5635 HadMultipleCandidates,
5636 ExplicitConversions))
5646 HadMultipleCandidates, Found))
5711 bool SuppressUserConversions,
5712 bool PartialOverloading,
5713 bool AllowExplicit) {
5716 assert(Proto &&
"Functions without a prototype cannot be overloaded");
5718 "Use AddTemplateOverloadCandidate for function templates");
5720 if (
CXXMethodDecl *Method = dyn_cast<CXXMethodDecl>(Function)) {
5721 if (!isa<CXXConstructorDecl>(Method)) {
5731 Args, CandidateSet, SuppressUserConversions,
5732 PartialOverloading);
5782 Candidate.
Viable =
false;
5795 Candidate.
Viable =
false;
5806 if (Args.size() < MinRequiredArgs && !PartialOverloading) {
5808 Candidate.
Viable =
false;
5821 Candidate.
Viable =
false;
5828 for (
unsigned ArgIdx = 0; ArgIdx < Args.size(); ++ArgIdx) {
5829 if (ArgIdx < NumParams) {
5837 SuppressUserConversions,
5843 Candidate.
Viable =
false;
5855 if (EnableIfAttr *FailedAttr =
CheckEnableIf(Function, Args)) {
5856 Candidate.
Viable =
false;
5866 if (Methods.size() <= 1)
5869 for (
unsigned b = 0, e = Methods.size(); b < e; b++) {
5877 if (Args.size() < NumNamedArgs)
5880 for (
unsigned i = 0; i < NumNamedArgs; i++) {
5882 if (Args[i]->isTypeDependent()) {
5888 Expr *argExpr = Args[i];
5889 assert(argExpr &&
"SelectBestMethod(): missing expression");
5894 !param->hasAttr<CFConsumedAttr>())
5910 if (ConversionState.
isBad()) {
5917 for (
unsigned i = NumNamedArgs, e = Args.size(); i < e; ++i) {
5918 if (Args[i]->isTypeDependent()) {
5931 if (Args.size() != NumNamedArgs)
5933 else if (Match && NumNamedArgs == 0 && Methods.size() > 1) {
5936 for (
unsigned b = 0, e = Methods.size(); b < e; b++) {
5937 QualType ReturnT = Methods[b]->getReturnType();
5956 if (!Function->hasAttrs())
5959 const auto &FuncAttrs = Function->getAttrs();
5961 if (
auto *EnableIf = dyn_cast<EnableIfAttr>(
Attr))
5962 Result.push_back(EnableIf);
5964 std::reverse(Result.begin(), Result.end());
5969 bool MissingImplicitThis) {
5971 if (EnableIfAttrs.empty())
5976 bool InitializationFailed =
false;
5983 for (
unsigned I = 0;
I != ArgSizeNoVarargs; ++
I) {
5985 if (
I == 0 && !MissingImplicitThis && isa<CXXMethodDecl>(Function) &&
5986 !cast<CXXMethodDecl>(Function)->isStatic() &&
5987 !isa<CXXConstructorDecl>(Function)) {
5998 InitializationFailed =
true;
6002 ConvertedArgs.push_back(R.
get());
6006 return EnableIfAttrs[0];
6010 for (
unsigned i = Args.size(), e = Function->
getNumParams(); i != e; ++i) {
6019 InitializationFailed =
true;
6022 ConvertedArgs.push_back(R.
get());
6026 return EnableIfAttrs[0];
6029 for (
auto *EIA : EnableIfAttrs) {
6033 if (!EIA->getCond()->EvaluateWithSubstitution(
6034 Result,
Context, Function, llvm::makeArrayRef(ConvertedArgs)))
6037 if (!Result.
isInt() || !Result.
getInt().getBoolValue())
6049 bool SuppressUserConversions,
6050 bool PartialOverloading) {
6054 if (isa<CXXMethodDecl>(FD) && !cast<CXXMethodDecl>(FD)->isStatic())
6056 cast<CXXMethodDecl>(FD)->getParent(),
6057 Args[0]->getType(), Args[0]->Classify(
Context),
6058 Args.slice(1), CandidateSet,
6059 SuppressUserConversions, PartialOverloading);
6062 SuppressUserConversions, PartialOverloading);
6068 cast<CXXRecordDecl>(FunTmpl->getDeclContext()),
6069 ExplicitTemplateArgs,
6071 Args[0]->Classify(
Context), Args.slice(1),
6072 CandidateSet, SuppressUserConversions,
6073 PartialOverloading);
6076 ExplicitTemplateArgs, Args,
6077 CandidateSet, SuppressUserConversions,
6078 PartialOverloading);
6090 bool SuppressUserConversions) {
6092 CXXRecordDecl *ActingContext = cast<CXXRecordDecl>(Decl->getDeclContext());
6094 if (isa<UsingShadowDecl>(Decl))
6095 Decl = cast<UsingShadowDecl>(Decl)->getTargetDecl();
6098 assert(isa<CXXMethodDecl>(TD->getTemplatedDecl()) &&
6099 "Expected a member function template");
6102 ObjectType, ObjectClassification,
6104 SuppressUserConversions);
6107 ObjectType, ObjectClassification,
6109 CandidateSet, SuppressUserConversions);
6126 bool SuppressUserConversions,
6127 bool PartialOverloading) {
6130 assert(Proto &&
"Methods without a prototype cannot be overloaded");
6131 assert(!isa<CXXConstructorDecl>(Method) &&
6132 "Use AddOverloadCandidate for constructors");
6162 Candidate.
Viable =
false;
6173 if (Args.size() < MinRequiredArgs && !PartialOverloading) {
6175 Candidate.
Viable =
false;
6189 *
this, CandidateSet.
getLocation(), ObjectType, ObjectClassification,
6190 Method, ActingContext);
6192 Candidate.
Viable =
false;
6202 Candidate.Viable =
false;
6209 for (
unsigned ArgIdx = 0; ArgIdx < Args.size(); ++ArgIdx) {
6210 if (ArgIdx < NumParams) {
6215 QualType ParamType = Proto->getParamType(ArgIdx);
6216 Candidate.Conversions[ArgIdx + 1]
6218 SuppressUserConversions,
6222 if (Candidate.Conversions[ArgIdx + 1].isBad()) {
6223 Candidate.Viable =
false;
6231 Candidate.Conversions[ArgIdx + 1].setEllipsis();
6235 if (EnableIfAttr *FailedAttr =
CheckEnableIf(Method, Args,
true)) {
6236 Candidate.Viable =
false;
6238 Candidate.DeductionFailure.Data = FailedAttr;
6255 bool SuppressUserConversions,
6256 bool PartialOverloading) {
6273 Specialization, Info, PartialOverloading)) {
6277 Candidate.
Viable =
false;
6289 assert(Specialization &&
"Missing member function template specialization?");
6290 assert(isa<CXXMethodDecl>(Specialization) &&
6291 "Specialization is not a member function?");
6293 ActingContext, ObjectType, ObjectClassification, Args,
6294 CandidateSet, SuppressUserConversions, PartialOverloading);
6306 bool SuppressUserConversions,
6307 bool PartialOverloading) {
6324 Specialization, Info, PartialOverloading)) {
6328 Candidate.
Viable =
false;
6340 assert(Specialization &&
"Missing function template specialization?");
6342 SuppressUserConversions, PartialOverloading);
6359 bool AllowObjCPointerConversion) {
6367 bool ObjCLifetimeConversion;
6369 ObjCLifetimeConversion))
6374 if (!AllowObjCPointerConversion)
6378 bool IncompatibleObjC =
false;
6396 bool AllowObjCConversionOnExplicit) {
6398 "Conversion function templates use AddTemplateConversionCandidate");
6405 if (
getLangOpts().CPlusPlus14 && ConvType->isUndeducedType()) {
6416 AllowObjCConversionOnExplicit))
6445 = cast<CXXRecordDecl>(ImplicitParamType->
getAs<
RecordType>()->getDecl());
6452 Candidate.
Viable =
false;
6463 if (FromCanon == ToCanon ||
6465 Candidate.
Viable =
false;
6482 CK_FunctionToPointerDecay,
6487 Candidate.
Viable =
false;
6499 From->getLocStart());
6506 switch (ICS.getKind()) {
6516 Candidate.
Viable =
false;
6528 Candidate.
Viable =
false;
6535 Candidate.
Viable =
false;
6541 "Can only end up with a standard conversion sequence or failure");
6545 Candidate.
Viable =
false;
6563 bool AllowObjCConversionOnExplicit) {
6565 "Only conversion function templates permitted here");
6574 Specialization, Info)) {
6578 Candidate.
Viable =
false;
6590 assert(Specialization &&
"Missing function template specialization?");
6592 CandidateSet, AllowObjCConversionOnExplicit);
6627 if (ObjectInit.
isBad()) {
6628 Candidate.
Viable =
false;
6653 if (Args.size() > NumParams && !Proto->
isVariadic()) {
6654 Candidate.
Viable =
false;
6661 if (Args.size() < NumParams) {
6663 Candidate.
Viable =
false;
6670 for (
unsigned ArgIdx = 0, N = Args.size(); ArgIdx != N; ++ArgIdx) {
6671 if (ArgIdx < NumParams) {
6684 Candidate.
Viable =
false;
6697 Candidate.
Viable =
false;
6738 if (!T1Rec->getDecl()->getDefinition())
6746 OperEnd = Operators.
end();
6768 bool IsAssignmentOperator,
6769 unsigned NumContextualBoolArguments) {
6780 for (
unsigned ArgIdx = 0, N = Args.size(); ArgIdx != N; ++ArgIdx)
6787 for (
unsigned ArgIdx = 0, N = Args.size(); ArgIdx != N; ++ArgIdx) {
6800 if (ArgIdx < NumContextualBoolArguments) {
6802 "Contextual conversion to bool requires bool type");
6808 ArgIdx == 0 && IsAssignmentOperator,
6814 Candidate.
Viable =
false;
6827 class BuiltinCandidateTypeSet {
6829 typedef llvm::SetVector<QualType, SmallVector<QualType, 8>,
6830 llvm::SmallPtrSet<QualType, 8>> TypeSet;
6834 TypeSet PointerTypes;
6838 TypeSet MemberPointerTypes;
6842 TypeSet EnumerationTypes;
6846 TypeSet VectorTypes;
6849 bool HasNonRecordTypes;
6853 bool HasArithmeticOrEnumeralTypes;
6857 bool HasNullPtrType;
6866 bool AddPointerWithMoreQualifiedTypeVariants(
QualType Ty,
6868 bool AddMemberPointerWithMoreQualifiedTypeVariants(
QualType Ty);
6874 BuiltinCandidateTypeSet(
Sema &SemaRef)
6875 : HasNonRecordTypes(
false),
6876 HasArithmeticOrEnumeralTypes(
false),
6877 HasNullPtrType(
false),
6881 void AddTypesConvertedFrom(
QualType Ty,
6883 bool AllowUserConversions,
6884 bool AllowExplicitConversions,
6885 const Qualifiers &VisibleTypeConversionsQuals);
6888 iterator pointer_begin() {
return PointerTypes.begin(); }
6891 iterator pointer_end() {
return PointerTypes.end(); }
6894 iterator member_pointer_begin() {
return MemberPointerTypes.begin(); }
6897 iterator member_pointer_end() {
return MemberPointerTypes.end(); }
6900 iterator enumeration_begin() {
return EnumerationTypes.begin(); }
6903 iterator enumeration_end() {
return EnumerationTypes.end(); }
6905 iterator vector_begin() {
return VectorTypes.begin(); }
6906 iterator vector_end() {
return VectorTypes.end(); }
6908 bool hasNonRecordTypes() {
return HasNonRecordTypes; }
6909 bool hasArithmeticOrEnumeralTypes() {
return HasArithmeticOrEnumeralTypes; }
6910 bool hasNullPtrType()
const {
return HasNullPtrType; }
6925 BuiltinCandidateTypeSet::AddPointerWithMoreQualifiedTypeVariants(
QualType Ty,
6929 if (!PointerTypes.insert(Ty))
6934 bool buildObjCPtr =
false;
6938 buildObjCPtr =
true;
6950 unsigned BaseCVR = PointeeTy.getCVRQualifiers();
6956 if ((CVR | BaseCVR) != CVR)
continue;
6978 PointerTypes.insert(QPointerTy);
6994 BuiltinCandidateTypeSet::AddMemberPointerWithMoreQualifiedTypeVariants(
6997 if (!MemberPointerTypes.insert(Ty))
7001 assert(PointerTy &&
"type was not a member pointer type!");
7016 if ((CVR | BaseCVR) != CVR)
continue;
7019 MemberPointerTypes.insert(
7035 BuiltinCandidateTypeSet::AddTypesConvertedFrom(
QualType Ty,
7037 bool AllowUserConversions,
7038 bool AllowExplicitConversions,
7050 Ty = SemaRef.Context.getArrayDecayedType(Ty);
7057 HasNonRecordTypes = HasNonRecordTypes || !TyRec;
7060 HasArithmeticOrEnumeralTypes =
7064 PointerTypes.insert(Ty);
7068 if (!AddPointerWithMoreQualifiedTypeVariants(Ty, VisibleQuals))
7072 if (!AddMemberPointerWithMoreQualifiedTypeVariants(Ty))
7075 HasArithmeticOrEnumeralTypes =
true;
7076 EnumerationTypes.insert(Ty);
7080 HasArithmeticOrEnumeralTypes =
true;
7081 VectorTypes.insert(Ty);
7083 HasNullPtrType =
true;
7084 }
else if (AllowUserConversions && TyRec) {
7086 if (!SemaRef.isCompleteType(Loc, Ty))
7091 if (isa<UsingShadowDecl>(D))
7092 D = cast<UsingShadowDecl>(D)->getTargetDecl();
7096 if (isa<FunctionTemplateDecl>(D))
7100 if (AllowExplicitConversions || !Conv->
isExplicit()) {
7155 if (isa<UsingShadowDecl>(D))
7156 D = cast<UsingShadowDecl>(D)->getTargetDecl();
7190 class BuiltinOperatorOverloadBuilder {
7195 bool HasArithmeticOrEnumeralCandidateType;
7203 static const unsigned FirstIntegralType = 4;
7204 static const unsigned LastIntegralType = 21;
7205 static const unsigned FirstPromotedIntegralType = 4,
7206 LastPromotedIntegralType = 12;
7207 static const unsigned FirstPromotedArithmeticType = 0,
7208 LastPromotedArithmeticType = 12;
7209 static const unsigned NumArithmeticTypes = 21;
7213 assert(index < NumArithmeticTypes);
7215 ArithmeticTypes[NumArithmeticTypes] = {
7245 return S.
Context.*ArithmeticTypes[index];
7250 CanQualType getUsualArithmeticConversions(
unsigned L,
unsigned R) {
7263 enum PromotedType : int8_t {
7265 Flt, Dbl, LDbl, SI, SL, SLL, S128, UI, UL, ULL, U128
7267 static const PromotedType ConversionsTable[LastPromotedArithmeticType]
7268 [LastPromotedArithmeticType] = {
7269 { Flt, Dbl, LDbl, Flt, Flt, Flt, Flt, Flt, Flt, Flt, Flt },
7270 { Dbl, Dbl, LDbl, Dbl, Dbl, Dbl, Dbl, Dbl, Dbl, Dbl, Dbl },
7271 { LDbl, LDbl, LDbl, LDbl, LDbl, LDbl, LDbl, LDbl, LDbl, LDbl, LDbl },
7272 { Flt, Dbl, LDbl, SI, SL, SLL, S128, UI, UL, ULL, U128 },
7273 { Flt, Dbl, LDbl, SL, SL, SLL, S128, Dep, UL, ULL, U128 },
7274 { Flt, Dbl, LDbl, SLL, SLL, SLL, S128, Dep, Dep, ULL, U128 },
7275 { Flt, Dbl, LDbl, S128, S128, S128, S128, S128, S128, S128, U128 },
7276 { Flt, Dbl, LDbl, UI, Dep, Dep, S128, UI, UL, ULL, U128 },
7277 { Flt, Dbl, LDbl, UL, UL, Dep, S128, UL, UL, ULL, U128 },
7278 { Flt, Dbl, LDbl, ULL, ULL, ULL, S128, ULL, ULL, ULL, U128 },
7279 { Flt, Dbl, LDbl, U128, U128, U128, U128, U128, U128, U128, U128 },
7282 assert(L < LastPromotedArithmeticType);
7283 assert(R < LastPromotedArithmeticType);
7284 int Idx = ConversionsTable[L][R];
7287 if (Idx != Dep)
return getArithmeticType(Idx);
7292 RT = getArithmeticType(R);
7297 if (LW > RW)
return LT;
7298 else if (LW < RW)
return RT;
7302 assert(L == SLL || R == SLL);
7308 void addPlusPlusMinusMinusStyleOverloads(
QualType CandidateTy,
7317 if (Args.size() == 1)
7328 if (Args.size() == 1)
7341 if (Args.size() == 1)
7350 (Qualifiers::Volatile |
7351 Qualifiers::Restrict)));
7352 if (Args.size() == 1)
7362 BuiltinOperatorOverloadBuilder(
7365 bool HasArithmeticOrEnumeralCandidateType,
7369 VisibleTypeConversionsQuals(VisibleTypeConversionsQuals),
7370 HasArithmeticOrEnumeralCandidateType(
7371 HasArithmeticOrEnumeralCandidateType),
7372 CandidateTypes(CandidateTypes),
7373 CandidateSet(CandidateSet) {
7375 assert(getArithmeticType(FirstPromotedIntegralType) == S.
Context.
IntTy &&
7376 "Invalid first promoted integral type");
7377 assert(getArithmeticType(LastPromotedIntegralType - 1)
7379 "Invalid last promoted integral type");
7380 assert(getArithmeticType(FirstPromotedArithmeticType)
7382 "Invalid first promoted arithmetic type");
7383 assert(getArithmeticType(LastPromotedArithmeticType - 1)
7385 "Invalid last promoted arithmetic type");
7406 if (!HasArithmeticOrEnumeralCandidateType)
7409 for (
unsigned Arith = (Op == OO_PlusPlus? 0 : 1);
7410 Arith < NumArithmeticTypes; ++Arith) {
7411 addPlusPlusMinusMinusStyleOverloads(
7412 getArithmeticType(Arith),
7428 void addPlusPlusMinusMinusPointerOverloads() {
7429 for (BuiltinCandidateTypeSet::iterator
7430 Ptr = CandidateTypes[0].pointer_begin(),
7431 PtrEnd = CandidateTypes[0].pointer_end();
7432 Ptr != PtrEnd; ++Ptr) {
7434 if (!(*Ptr)->getPointeeType()->isObjectType())
7437 addPlusPlusMinusMinusStyleOverloads(*Ptr,
7438 (!(*Ptr).isVolatileQualified() &&
7440 (!(*Ptr).isRestrictQualified() &&
7455 void addUnaryStarPointerOverloads() {
7456 for (BuiltinCandidateTypeSet::iterator
7457 Ptr = CandidateTypes[0].pointer_begin(),
7458 PtrEnd = CandidateTypes[0].pointer_end();
7459 Ptr != PtrEnd; ++Ptr) {
7466 if (Proto->getTypeQuals() || Proto->getRefQualifier())
7470 &ParamTy, Args, CandidateSet);
7480 void addUnaryPlusOrMinusArithmeticOverloads() {
7481 if (!HasArithmeticOrEnumeralCandidateType)
7484 for (
unsigned Arith = FirstPromotedArithmeticType;
7485 Arith < LastPromotedArithmeticType; ++Arith) {
7486 QualType ArithTy = getArithmeticType(Arith);
7491 for (BuiltinCandidateTypeSet::iterator
7492 Vec = CandidateTypes[0].vector_begin(),
7493 VecEnd = CandidateTypes[0].vector_end();
7494 Vec != VecEnd; ++Vec) {
7505 void addUnaryPlusPointerOverloads() {
7506 for (BuiltinCandidateTypeSet::iterator
7507 Ptr = CandidateTypes[0].pointer_begin(),
7508 PtrEnd = CandidateTypes[0].pointer_end();
7509 Ptr != PtrEnd; ++Ptr) {
7520 void addUnaryTildePromotedIntegralOverloads() {
7521 if (!HasArithmeticOrEnumeralCandidateType)
7524 for (
unsigned Int = FirstPromotedIntegralType;
7525 Int < LastPromotedIntegralType; ++Int) {
7526 QualType IntTy = getArithmeticType(Int);
7531 for (BuiltinCandidateTypeSet::iterator
7532 Vec = CandidateTypes[0].vector_begin(),
7533 VecEnd = CandidateTypes[0].vector_end();
7534 Vec != VecEnd; ++Vec) {
7546 void addEqualEqualOrNotEqualMemberPointerOverloads() {
7548 llvm::SmallPtrSet<QualType, 8> AddedTypes;
7550 for (
unsigned ArgIdx = 0, N = Args.size(); ArgIdx != N; ++ArgIdx) {
7551 for (BuiltinCandidateTypeSet::iterator
7552 MemPtr = CandidateTypes[ArgIdx].member_pointer_begin(),
7553 MemPtrEnd = CandidateTypes[ArgIdx].member_pointer_end();
7554 MemPtr != MemPtrEnd;
7560 QualType ParamTypes[2] = { *MemPtr, *MemPtr };
7577 void addRelationalPointerOrEnumeralOverloads() {
7591 UserDefinedBinaryOperators;
7593 for (
unsigned ArgIdx = 0, N = Args.size(); ArgIdx != N; ++ArgIdx) {
7594 if (CandidateTypes[ArgIdx].enumeration_begin() !=
7595 CandidateTypes[ArgIdx].enumeration_end()) {
7597 CEnd = CandidateSet.
end();
7599 if (!
C->Viable || !
C->Function ||
C->Function->getNumParams() != 2)
7602 if (
C->Function->isFunctionTemplateSpecialization())
7606 C->Function->getParamDecl(0)->getType().getUnqualifiedType();
7608 C->Function->getParamDecl(1)->getType().getUnqualifiedType();
7616 UserDefinedBinaryOperators.insert(
7624 llvm::SmallPtrSet<QualType, 8> AddedTypes;
7626 for (
unsigned ArgIdx = 0, N = Args.size(); ArgIdx != N; ++ArgIdx) {
7627 for (BuiltinCandidateTypeSet::iterator
7628 Ptr = CandidateTypes[ArgIdx].pointer_begin(),
7629 PtrEnd = CandidateTypes[ArgIdx].pointer_end();
7630 Ptr != PtrEnd; ++Ptr) {
7635 QualType ParamTypes[2] = { *Ptr, *Ptr };
7638 for (BuiltinCandidateTypeSet::iterator
7639 Enum = CandidateTypes[ArgIdx].enumeration_begin(),
7640 EnumEnd = CandidateTypes[ArgIdx].enumeration_end();
7646 if (!AddedTypes.insert(CanonType).second ||
7647 UserDefinedBinaryOperators.count(std::make_pair(CanonType,
7655 if (CandidateTypes[ArgIdx].hasNullPtrType()) {
7657 if (AddedTypes.insert(NullPtrTy).second &&
7658 !UserDefinedBinaryOperators.count(std::make_pair(NullPtrTy,
7660 QualType ParamTypes[2] = { NullPtrTy, NullPtrTy };
7687 llvm::SmallPtrSet<QualType, 8> AddedTypes;
7689 for (
int Arg = 0; Arg < 2; ++Arg) {
7690 QualType AsymmetricParamTypes[2] = {
7694 for (BuiltinCandidateTypeSet::iterator
7695 Ptr = CandidateTypes[Arg].pointer_begin(),
7696 PtrEnd = CandidateTypes[Arg].pointer_end();
7697 Ptr != PtrEnd; ++Ptr) {
7702 AsymmetricParamTypes[Arg] = *Ptr;
7703 if (Arg == 0 || Op == OO_Plus) {
7708 if (Op == OO_Minus) {
7713 QualType ParamTypes[2] = { *Ptr, *Ptr };
7715 Args, CandidateSet);
7750 void addGenericBinaryArithmeticOverloads(
bool isComparison) {
7751 if (!HasArithmeticOrEnumeralCandidateType)
7754 for (
unsigned Left = FirstPromotedArithmeticType;
7755 Left < LastPromotedArithmeticType; ++Left) {
7756 for (
unsigned Right = FirstPromotedArithmeticType;
7757 Right < LastPromotedArithmeticType; ++Right) {
7758 QualType LandR[2] = { getArithmeticType(Left),
7759 getArithmeticType(Right) };
7762 : getUsualArithmeticConversions(Left, Right);
7769 for (BuiltinCandidateTypeSet::iterator
7770 Vec1 = CandidateTypes[0].vector_begin(),
7771 Vec1End = CandidateTypes[0].vector_end();
7772 Vec1 != Vec1End; ++Vec1) {
7773 for (BuiltinCandidateTypeSet::iterator
7774 Vec2 = CandidateTypes[1].vector_begin(),
7775 Vec2End = CandidateTypes[1].vector_end();
7776 Vec2 != Vec2End; ++Vec2) {
7777 QualType LandR[2] = { *Vec1, *Vec2 };
7779 if (!isComparison) {
7780 if ((*Vec1)->isExtVectorType() || !(*Vec2)->isExtVectorType())
7806 if (!HasArithmeticOrEnumeralCandidateType)
7809 for (
unsigned Left = FirstPromotedIntegralType;
7810 Left < LastPromotedIntegralType; ++Left) {
7811 for (
unsigned Right = FirstPromotedIntegralType;
7812 Right < LastPromotedIntegralType; ++Right) {
7813 QualType LandR[2] = { getArithmeticType(Left),
7814 getArithmeticType(Right) };
7815 QualType Result = (Op == OO_LessLess || Op == OO_GreaterGreater)
7817 : getUsualArithmeticConversions(Left, Right);
7830 void addAssignmentMemberPointerOrEnumeralOverloads() {
7832 llvm::SmallPtrSet<QualType, 8> AddedTypes;
7834 for (
unsigned ArgIdx = 0; ArgIdx < 2; ++ArgIdx) {
7835 for (BuiltinCandidateTypeSet::iterator
7836 Enum = CandidateTypes[ArgIdx].enumeration_begin(),
7837 EnumEnd = CandidateTypes[ArgIdx].enumeration_end();
7845 for (BuiltinCandidateTypeSet::iterator
7846 MemPtr = CandidateTypes[ArgIdx].member_pointer_begin(),
7847 MemPtrEnd = CandidateTypes[ArgIdx].member_pointer_end();
7848 MemPtr != MemPtrEnd; ++MemPtr) {
7873 void addAssignmentPointerOverloads(
bool isEqualOp) {
7875 llvm::SmallPtrSet<QualType, 8> AddedTypes;
7877 for (BuiltinCandidateTypeSet::iterator
7878 Ptr = CandidateTypes[0].pointer_begin(),
7879 PtrEnd = CandidateTypes[0].pointer_end();
7880 Ptr != PtrEnd; ++Ptr) {
7884 else if (!(*Ptr)->getPointeeType()->isObjectType())
7895 bool NeedVolatile = !(*Ptr).isVolatileQualified() &&
7905 if (!(*Ptr).isRestrictQualified() &&
7918 (Qualifiers::Volatile |
7919 Qualifiers::Restrict)));
7927 for (BuiltinCandidateTypeSet::iterator
7928 Ptr = CandidateTypes[1].pointer_begin(),
7929 PtrEnd = CandidateTypes[1].pointer_end();
7930 Ptr != PtrEnd; ++Ptr) {
7944 bool NeedVolatile = !(*Ptr).isVolatileQualified() &&
7954 if (!(*Ptr).isRestrictQualified() &&
7967 (Qualifiers::Volatile |
7968 Qualifiers::Restrict)));
7989 void addAssignmentArithmeticOverloads(
bool isEqualOp) {
7990 if (!HasArithmeticOrEnumeralCandidateType)
7993 for (
unsigned Left = 0; Left < NumArithmeticTypes; ++Left) {
7994 for (
unsigned Right = FirstPromotedArithmeticType;
7995 Right < LastPromotedArithmeticType; ++Right) {
7997 ParamTypes[1] = getArithmeticType(Right);
8017 for (BuiltinCandidateTypeSet::iterator
8018 Vec1 = CandidateTypes[0].vector_begin(),
8019 Vec1End = CandidateTypes[0].vector_end();
8020 Vec1 != Vec1End; ++Vec1) {
8021 for (BuiltinCandidateTypeSet::iterator
8022 Vec2 = CandidateTypes[1].vector_begin(),
8023 Vec2End = CandidateTypes[1].vector_end();
8024 Vec2 != Vec2End; ++Vec2) {
8026 ParamTypes[1] = *Vec2;
8055 void addAssignmentIntegralOverloads() {
8056 if (!HasArithmeticOrEnumeralCandidateType)
8059 for (
unsigned Left = FirstIntegralType; Left < LastIntegralType; ++Left) {
8060 for (
unsigned Right = FirstPromotedIntegralType;
8061 Right < LastPromotedIntegralType; ++Right) {
8063 ParamTypes[1] = getArithmeticType(Right);
8071 ParamTypes[0] = getArithmeticType(Left);
8087 void addExclaimOverload() {
8093 void addAmpAmpOrPipePipeOverload() {
8110 void addSubscriptOverloads() {
8111 for (BuiltinCandidateTypeSet::iterator
8112 Ptr = CandidateTypes[0].pointer_begin(),
8113 PtrEnd = CandidateTypes[0].pointer_end();
8114 Ptr != PtrEnd; ++Ptr) {
8126 for (BuiltinCandidateTypeSet::iterator
8127 Ptr = CandidateTypes[1].pointer_begin(),
8128 PtrEnd = CandidateTypes[1].pointer_end();
8129 Ptr != PtrEnd; ++Ptr) {
8151 void addArrowStarOverloads() {
8152 for (BuiltinCandidateTypeSet::iterator
8153 Ptr = CandidateTypes[0].pointer_begin(),
8154 PtrEnd = CandidateTypes[0].pointer_end();
8155 Ptr != PtrEnd; ++Ptr) {
8160 if (!isa<RecordType>(C1))
8169 for (BuiltinCandidateTypeSet::iterator
8170 MemPtr = CandidateTypes[1].member_pointer_begin(),
8171 MemPtrEnd = CandidateTypes[1].member_pointer_end();
8172 MemPtr != MemPtrEnd; ++MemPtr) {
8178 QualType ParamTypes[2] = { *Ptr, *MemPtr };
8204 void addConditionalOperatorOverloads() {
8206 llvm::SmallPtrSet<QualType, 8> AddedTypes;
8208 for (
unsigned ArgIdx = 0; ArgIdx < 2; ++ArgIdx) {
8209 for (BuiltinCandidateTypeSet::iterator
8210 Ptr = CandidateTypes[ArgIdx].pointer_begin(),
8211 PtrEnd = CandidateTypes[ArgIdx].pointer_end();
8212 Ptr != PtrEnd; ++Ptr) {
8216 QualType ParamTypes[2] = { *Ptr, *Ptr };
8220 for (BuiltinCandidateTypeSet::iterator
8221 MemPtr = CandidateTypes[ArgIdx].member_pointer_begin(),
8222 MemPtrEnd = CandidateTypes[ArgIdx].member_pointer_end();
8223 MemPtr != MemPtrEnd; ++MemPtr) {
8227 QualType ParamTypes[2] = { *MemPtr, *MemPtr };
8232 for (BuiltinCandidateTypeSet::iterator
8233 Enum = CandidateTypes[ArgIdx].enumeration_begin(),
8234 EnumEnd = CandidateTypes[ArgIdx].enumeration_end();
8266 VisibleTypeConversionsQuals.
addConst();
8267 for (
unsigned ArgIdx = 0, N = Args.size(); ArgIdx != N; ++ArgIdx)
8270 bool HasNonRecordCandidateType =
false;
8271 bool HasArithmeticOrEnumeralCandidateType =
false;
8273 for (
unsigned ArgIdx = 0, N = Args.size(); ArgIdx != N; ++ArgIdx) {
8274 CandidateTypes.emplace_back(*
this);
8275 CandidateTypes[ArgIdx].AddTypesConvertedFrom(Args[ArgIdx]->getType(),
8278 (Op == OO_Exclaim ||
8281 VisibleTypeConversionsQuals);
8282 HasNonRecordCandidateType = HasNonRecordCandidateType ||
8283 CandidateTypes[ArgIdx].hasNonRecordTypes();
8284 HasArithmeticOrEnumeralCandidateType =
8285 HasArithmeticOrEnumeralCandidateType ||
8286 CandidateTypes[ArgIdx].hasArithmeticOrEnumeralTypes();
8294 if (!HasNonRecordCandidateType &&
8295 !(Op == OO_Exclaim || Op == OO_AmpAmp || Op == OO_PipePipe))
8299 BuiltinOperatorOverloadBuilder OpBuilder(*
this, Args,
8300 VisibleTypeConversionsQuals,
8301 HasArithmeticOrEnumeralCandidateType,
8302 CandidateTypes, CandidateSet);
8308 llvm_unreachable(
"Expected an overloaded operator");
8313 case OO_Array_Delete:
8316 "Special operators don't use AddBuiltinOperatorCandidates");
8328 if (Args.size() == 1)
8329 OpBuilder.addUnaryPlusPointerOverloads();
8333 if (Args.size() == 1) {
8334 OpBuilder.addUnaryPlusOrMinusArithmeticOverloads();
8336 OpBuilder.addBinaryPlusOrMinusPointerOverloads(Op);
8337 OpBuilder.addGenericBinaryArithmeticOverloads(
false);
8342 if (Args.size() == 1)
8343 OpBuilder.addUnaryStarPointerOverloads();
8345 OpBuilder.addGenericBinaryArithmeticOverloads(
false);
8349 OpBuilder.addGenericBinaryArithmeticOverloads(
false);
8354 OpBuilder.addPlusPlusMinusMinusArithmeticOverloads(Op);
8355 OpBuilder.addPlusPlusMinusMinusPointerOverloads();
8359 case OO_ExclaimEqual:
8360 OpBuilder.addEqualEqualOrNotEqualMemberPointerOverloads();
8366 case OO_GreaterEqual:
8367 OpBuilder.addRelationalPointerOrEnumeralOverloads();
8368 OpBuilder.addGenericBinaryArithmeticOverloads(
true);
8375 case OO_GreaterGreater:
8376 OpBuilder.addBinaryBitwiseArithmeticOverloads(Op);
8380 if (Args.size() == 1)
8386 OpBuilder.addBinaryBitwiseArithmeticOverloads(Op);
8390 OpBuilder.addUnaryTildePromotedIntegralOverloads();
8394 OpBuilder.addAssignmentMemberPointerOrEnumeralOverloads();
8399 OpBuilder.addAssignmentPointerOverloads(Op == OO_Equal);
8404 OpBuilder.addAssignmentArithmeticOverloads(Op == OO_Equal);
8407 case OO_PercentEqual:
8408 case OO_LessLessEqual:
8409 case OO_GreaterGreaterEqual:
8413 OpBuilder.addAssignmentIntegralOverloads();
8417 OpBuilder.addExclaimOverload();
8422 OpBuilder.addAmpAmpOrPipePipeOverload();
8426 OpBuilder.addSubscriptOverloads();
8430 OpBuilder.addArrowStarOverloads();
8433 case OO_Conditional:
8434 OpBuilder.addConditionalOperatorOverloads();
8435 OpBuilder.addGenericBinaryArithmeticOverloads(
false);
8453 bool PartialOverloading) {
8468 CandEnd = CandidateSet.
end();
8469 Cand != CandEnd; ++Cand)
8470 if (Cand->Function) {
8471 Fns.
erase(Cand->Function);
8481 if (ExplicitTemplateArgs)
8485 PartialOverloading);
8488 FoundDecl, ExplicitTemplateArgs,
8489 Args, CandidateSet, PartialOverloading);
8511 bool Cand1Attr = Cand1->hasAttr<EnableIfAttr>();
8512 bool Cand2Attr = Cand2->hasAttr<EnableIfAttr>();
8513 if (!Cand1Attr || !Cand2Attr) {
8514 if (Cand1Attr == Cand2Attr)
8515 return Comparison::Equal;
8516 return Cand1Attr ? Comparison::Better : Comparison::Worse;
8527 if (Cand1Attrs.size() < Cand2Attrs.size())
8528 return Comparison::Worse;
8530 auto Cand1I = Cand1Attrs.begin();
8531 llvm::FoldingSetNodeID Cand1ID, Cand2ID;
8532 for (
auto &Cand2A : Cand2Attrs) {
8536 auto &Cand1A = *Cand1I++;
8537 Cand1A->getCond()->Profile(Cand1ID, S.
getASTContext(),
true);
8538 Cand2A->getCond()->Profile(Cand2ID, S.
getASTContext(),
true);
8539 if (Cand1ID != Cand2ID)
8540 return Comparison::Worse;
8543 return Cand1I == Cand1Attrs.end() ? Comparison::Equal : Comparison::Better;
8551 bool UserDefinedConversion) {
8565 unsigned StartArg = 0;
8574 assert(Cand2.
NumConversions == NumArgs &&
"Overload candidate mismatch");
8575 bool HasBetterConversion =
false;
8576 for (
unsigned ArgIdx = StartArg; ArgIdx <
NumArgs; ++ArgIdx) {
8582 HasBetterConversion =
true;
8597 if (HasBetterConversion)
8607 isa<CXXConversionDecl>(Cand1.
Function) &&
8608 isa<CXXConversionDecl>(Cand2.
Function)) {
8630 bool Cand1IsSpecialization = Cand1.
Function &&
8632 bool Cand2IsSpecialization = Cand2.
Function &&
8634 if (Cand1IsSpecialization != Cand2IsSpecialization)
8635 return Cand2IsSpecialization;
8641 if (Cand1IsSpecialization && Cand2IsSpecialization) {
8655 bool Cand1IsInherited =
8657 bool Cand2IsInherited =
8659 if (Cand1IsInherited != Cand2IsInherited)
8660 return Cand2IsInherited;
8661 else if (Cand1IsInherited) {
8662 assert(Cand2IsInherited);
8663 auto *Cand1Class = cast<CXXRecordDecl>(Cand1.
Function->getDeclContext());
8664 auto *Cand2Class = cast<CXXRecordDecl>(Cand2.
Function->getDeclContext());
8665 if (Cand1Class->isDerivedFrom(Cand2Class))
8667 if (Cand2Class->isDerivedFrom(Cand1Class))
8675 if (Cmp != Comparison::Equal)
8676 return Cmp == Comparison::Better;
8685 bool HasPS1 = Cand1.
Function !=
nullptr &&
8687 bool HasPS2 = Cand2.
Function !=
nullptr &&
8689 return HasPS1 != HasPS2 && HasPS1;
8701 auto *VA = dyn_cast_or_null<ValueDecl>(A);
8702 auto *VB = dyn_cast_or_null<ValueDecl>(B);
8708 if (!VA->getDeclContext()->getRedeclContext()->Equals(
8709 VB->getDeclContext()->getRedeclContext()) ||
8712 VA->isExternallyVisible() || VB->isExternallyVisible())
8725 if (
auto *EA = dyn_cast<EnumConstantDecl>(VA)) {
8726 if (
auto *EB = dyn_cast<EnumConstantDecl>(VB)) {
8729 auto *EnumA = cast<EnumDecl>(EA->getDeclContext());
8730 auto *EnumB = cast<EnumDecl>(EB->getDeclContext());
8731 if (EnumA->hasNameForLinkage() || EnumB->hasNameForLinkage() ||
8733 EnumB->getIntegerType()))
8736 return llvm::APSInt::isSameValue(EA->getInitVal(), EB->getInitVal());
8746 Diag(Loc, diag::ext_equivalent_internal_linkage_decl_in_modules) << D;
8749 Diag(D->getLocation(), diag::note_equivalent_internal_linkage_decl)
8752 for (
auto *E : Equiv) {
8754 Diag(E->getLocation(), diag::note_equivalent_internal_linkage_decl)
8772 bool UserDefinedConversion) {
8774 std::transform(
begin(),
end(), std::back_inserter(Candidates),
8786 bool ContainsSameSideCandidate =
8792 if (ContainsSameSideCandidate) {
8798 Candidates.erase(std::remove_if(Candidates.begin(), Candidates.end(),
8799 IsWrongSideCandidate),
8806 for (
auto *Cand : Candidates)
8809 UserDefinedConversion))
8820 for (
auto *Cand : Candidates) {
8824 UserDefinedConversion)) {
8827 EquivalentCands.push_back(Cand->
Function);
8837 if (Best->Function &&
8838 (Best->Function->isDeleted() ||
8842 if (!EquivalentCands.empty())
8855 oc_function_template,
8857 oc_constructor_template,
8858 oc_implicit_default_constructor,
8859 oc_implicit_copy_constructor,
8860 oc_implicit_move_constructor,
8861 oc_implicit_copy_assignment,
8862 oc_implicit_move_assignment,
8863 oc_inherited_constructor,
8864 oc_inherited_constructor_template
8870 std::string &Description) {
8880 if (!Ctor->isImplicit()) {
8881 if (isa<ConstructorUsingShadowDecl>(Found))
8882 return isTemplate ? oc_inherited_constructor_template
8883 : oc_inherited_constructor;
8885 return isTemplate ? oc_constructor_template : oc_constructor;
8888 if (Ctor->isDefaultConstructor())
8889 return oc_implicit_default_constructor;
8891 if (Ctor->isMoveConstructor())
8892 return oc_implicit_move_constructor;
8894 assert(Ctor->isCopyConstructor() &&
8895 "unexpected sort of implicit constructor");
8896 return oc_implicit_copy_constructor;
8902 if (!Meth->isImplicit())
8903 return isTemplate ? oc_method_template : oc_method;
8905 if (Meth->isMoveAssignmentOperator())
8906 return oc_implicit_move_assignment;
8908 if (Meth->isCopyAssignmentOperator())
8909 return oc_implicit_copy_assignment;
8911 assert(isa<CXXConversionDecl>(Meth) &&
"expected conversion");
8915 return isTemplate ? oc_function_template : oc_function;
8918 void MaybeEmitInheritedConstructorNote(
Sema &S,
Decl *FoundDecl) {
8921 if (
auto *Shadow = dyn_cast<ConstructorUsingShadowDecl>(FoundDecl))
8922 S.
Diag(FoundDecl->getLocation(),
8923 diag::note_ovl_candidate_inherited_constructor)
8924 << Shadow->getNominatedBaseClass();
8931 for (
auto *EnableIf : FD->specific_attrs<EnableIfAttr>()) {
8933 if (!EnableIf->getCond()->EvaluateAsBooleanCondition(AlwaysTrue, Ctx))
8950 bool InOverloadResolution,
8954 if (InOverloadResolution)
8956 diag::note_addrof_ovl_candidate_disabled_by_enable_if_attr);
8958 S.
Diag(Loc, diag::err_addrof_function_disabled_by_enable_if_attr) << FD;
8963 auto I = llvm::find_if(
8964 FD->
parameters(), std::mem_fn(&ParmVarDecl::hasAttr<PassObjectSizeAttr>));
8971 if (InOverloadResolution)
8972 S.
Diag(FD->getLocation(),
8973 diag::note_ovl_candidate_has_pass_object_size_params)
8976 S.
Diag(Loc, diag::err_address_of_function_with_pass_object_size_params)
8999 QualType DestType,
bool TakingAddress) {
9009 Diag(Fn->getLocation(), PD);
9010 MaybeEmitInheritedConstructorNote(*
this, Found);
9016 bool TakingAddress) {
9026 dyn_cast<FunctionTemplateDecl>((*I)->getUnderlyingDecl()) ) {
9030 = dyn_cast<FunctionDecl>((*I)->getUnderlyingDecl()) ) {
9043 S.
Diag(CaretLoc, PDiag)
9049 unsigned CandsShown = 0;
9052 if (CandsShown >= 4 && ShowOverloads ==
Ovl_Best)
9062 unsigned I,
bool TakingCandidateAddress) {
9064 assert(Conv.
isBad());
9065 assert(Cand->
Function &&
"for now, candidate must be a function");
9071 bool isObjectArgument =
false;
9072 if (isa<CXXMethodDecl>(Fn) && !isa<CXXConstructorDecl>(Fn)) {
9074 isObjectArgument =
true;
9081 ClassifyOverloadCandidate(S, Cand->
FoundDecl, Fn, FnDesc);
9088 assert(FromExpr &&
"overload set argument came from implicit argument?");
9090 if (isa<UnaryOperator>(E))
9094 S.
Diag(Fn->getLocation(), diag::note_ovl_candidate_bad_overload)
9095 << (
unsigned) FnKind << FnDesc
9096 << (FromExpr ? FromExpr->getSourceRange() :
SourceRange())
9097 << ToTy << Name << I+1;
9098 MaybeEmitInheritedConstructorNote(S, Cand->
FoundDecl);
9107 CToTy = RT->getPointeeType();
9112 CFromTy = FromPT->getPointeeType();
9113 CToTy = ToPT->getPointeeType();
9123 S.
Diag(Fn->getLocation(), diag::note_ovl_candidate_bad_addrspace)
9124 << (
unsigned) FnKind << FnDesc
9125 << (FromExpr ? FromExpr->getSourceRange() :
SourceRange())
9128 << (
unsigned) isObjectArgument << I+1;
9129 MaybeEmitInheritedConstructorNote(S, Cand->
FoundDecl);
9134 S.
Diag(Fn->getLocation(), diag::note_ovl_candidate_bad_ownership)
9135 << (
unsigned) FnKind << FnDesc
9136 << (FromExpr ? FromExpr->getSourceRange() :
SourceRange())
9139 << (
unsigned) isObjectArgument << I+1;
9140 MaybeEmitInheritedConstructorNote(S, Cand->
FoundDecl);
9145 S.
Diag(Fn->getLocation(), diag::note_ovl_candidate_bad_gc)
9146 << (
unsigned) FnKind << FnDesc
9147 << (FromExpr ? FromExpr->getSourceRange() :
SourceRange())
9150 << (
unsigned) isObjectArgument << I+1;
9151 MaybeEmitInheritedConstructorNote(S, Cand->
FoundDecl);
9156 S.
Diag(Fn->getLocation(), diag::note_ovl_candidate_bad_unaligned)
9157 << (
unsigned) FnKind << FnDesc
9158 << (FromExpr ? FromExpr->getSourceRange() :
SourceRange())
9160 MaybeEmitInheritedConstructorNote(S, Cand->
FoundDecl);
9165 assert(CVR &&
"unexpected qualifiers mismatch");
9167 if (isObjectArgument) {
9168 S.
Diag(Fn->getLocation(), diag::note_ovl_candidate_bad_cvr_this)
9169 << (
unsigned) FnKind << FnDesc
9170 << (FromExpr ? FromExpr->getSourceRange() :
SourceRange())
9171 << FromTy << (CVR - 1);
9173 S.
Diag(Fn->getLocation(), diag::note_ovl_candidate_bad_cvr)
9174 << (
unsigned) FnKind << FnDesc
9175 << (FromExpr ? FromExpr->getSourceRange() :
SourceRange())
9176 << FromTy << (CVR - 1) << I+1;
9178 MaybeEmitInheritedConstructorNote(S, Cand->
FoundDecl);
9184 if (FromExpr && isa<InitListExpr>(FromExpr)) {
9185 S.
Diag(Fn->getLocation(), diag::note_ovl_candidate_bad_list_argument)
9186 << (
unsigned) FnKind << FnDesc
9187 << (FromExpr ? FromExpr->getSourceRange() :
SourceRange())
9188 << FromTy << ToTy << (
unsigned) isObjectArgument << I+1;
9189 MaybeEmitInheritedConstructorNote(S, Cand->
FoundDecl);
9201 S.
Diag(Fn->getLocation(), diag::note_ovl_candidate_bad_conv_incomplete)
9202 << (
unsigned) FnKind << FnDesc
9203 << (FromExpr ? FromExpr->getSourceRange() :
SourceRange())
9204 << FromTy << ToTy << (
unsigned) isObjectArgument << I+1
9207 MaybeEmitInheritedConstructorNote(S, Cand->
FoundDecl);
9212 unsigned BaseToDerivedConversion = 0;
9215 if (ToPtrTy->getPointeeType().isAtLeastAsQualifiedAs(
9216 FromPtrTy->getPointeeType()) &&
9217 !FromPtrTy->getPointeeType()->isIncompleteType() &&
9218 !ToPtrTy->getPointeeType()->isIncompleteType() &&
9220 FromPtrTy->getPointeeType()))
9221 BaseToDerivedConversion = 1;
9229 if (ToPtrTy->getPointeeType().isAtLeastAsQualifiedAs(
9230 FromPtrTy->getPointeeType()) &&
9231 FromIface->isSuperClassOf(ToIface))
9232 BaseToDerivedConversion = 2;
9234 if (ToRefTy->getPointeeType().isAtLeastAsQualifiedAs(FromTy) &&
9236 !ToRefTy->getPointeeType()->isIncompleteType() &&
9238 BaseToDerivedConversion = 3;
9242 S.
Diag(Fn->getLocation(), diag::note_ovl_candidate_bad_lvalue)
9243 << (
unsigned) FnKind << FnDesc
9244 << (FromExpr ? FromExpr->getSourceRange() :
SourceRange())
9245 << (
unsigned) isObjectArgument << I + 1;
9246 MaybeEmitInheritedConstructorNote(S, Cand->
FoundDecl);
9251 if (BaseToDerivedConversion) {
9252 S.
Diag(Fn->getLocation(),
9253 diag::note_ovl_candidate_bad_base_to_derived_conv)
9254 << (
unsigned) FnKind << FnDesc
9255 << (FromExpr ? FromExpr->getSourceRange() :
SourceRange())
9256 << (BaseToDerivedConversion - 1)
9257 << FromTy << ToTy << I+1;
9258 MaybeEmitInheritedConstructorNote(S, Cand->
FoundDecl);
9262 if (isa<ObjCObjectPointerType>(CFromTy) &&
9263 isa<PointerType>(CToTy)) {
9267 S.
Diag(Fn->getLocation(), diag::note_ovl_candidate_bad_arc_conv)
9268 << (
unsigned) FnKind << FnDesc
9269 << (FromExpr ? FromExpr->getSourceRange() :
SourceRange())
9270 << FromTy << ToTy << (
unsigned) isObjectArgument << I+1;
9271 MaybeEmitInheritedConstructorNote(S, Cand->
FoundDecl);
9276 if (TakingCandidateAddress &&
9282 FDiag << (
unsigned) FnKind << FnDesc
9283 << (FromExpr ? FromExpr->getSourceRange() :
SourceRange())
9284 << FromTy << ToTy << (
unsigned) isObjectArgument << I + 1
9289 HE = Cand->
Fix.
Hints.end(); HI != HE; ++HI)
9291 S.
Diag(Fn->getLocation(), FDiag);
9293 MaybeEmitInheritedConstructorNote(S, Cand->
FoundDecl);
9309 if (Fn->isInvalidDecl() &&
9313 if (NumArgs < MinParams) {
9328 unsigned NumFormalArgs) {
9329 assert(isa<FunctionDecl>(D) &&
9330 "The templated declaration should at least be a function"
9331 " when diagnosing bad template argument deduction due to too many"
9332 " or too few arguments");
9341 unsigned mode, modeCount;
9342 if (NumFormalArgs < MinParams) {
9343 if (MinParams != FnTy->getNumParams() || FnTy->isVariadic() ||
9344 FnTy->isTemplateVariadic())
9348 modeCount = MinParams;
9350 if (MinParams != FnTy->getNumParams())
9354 modeCount = FnTy->getNumParams();
9357 std::string Description;
9359 ClassifyOverloadCandidate(S, Found, Fn, Description);
9362 S.
Diag(Fn->getLocation(), diag::note_ovl_candidate_arity_one)
9366 S.
Diag(Fn->getLocation(), diag::note_ovl_candidate_arity)
9368 << mode << modeCount << NumFormalArgs;
9369 MaybeEmitInheritedConstructorNote(S, Found);
9374 unsigned NumFormalArgs) {
9380 if (
TemplateDecl *TD = Templated->getDescribedTemplate())
9382 llvm_unreachable(
"Unsupported: Getting the described template declaration"
9383 " for bad deduction diagnosis");
9390 bool TakingCandidateAddress) {
9396 switch (DeductionFailure.
Result) {
9398 llvm_unreachable(
"TDK_success while diagnosing bad deduction");
9401 assert(ParamD &&
"no parameter found for incomplete deduction result");
9402 S.
Diag(Templated->getLocation(),
9403 diag::note_ovl_candidate_incomplete_deduction)
9405 MaybeEmitInheritedConstructorNote(S, Found);
9410 assert(ParamD &&
"no parameter found for bad qualifiers deduction result");
9428 S.
Diag(Templated->getLocation(), diag::note_ovl_candidate_underqualified)
9430 MaybeEmitInheritedConstructorNote(S, Found);
9435 assert(ParamD &&
"no parameter found for inconsistent deduction result");
9437 if (isa<TemplateTypeParmDecl>(ParamD))
9439 else if (isa<NonTypeTemplateParmDecl>(ParamD))
9445 S.
Diag(Templated->getLocation(),
9446 diag::note_ovl_candidate_inconsistent_deduction)
9449 MaybeEmitInheritedConstructorNote(S, Found);
9454 assert(ParamD &&
"no parameter found for invalid explicit arguments");
9456 S.
Diag(Templated->getLocation(),
9457 diag::note_ovl_candidate_explicit_arg_mismatch_named)
9462 index = TTP->getIndex();
9464 = dyn_cast<NonTypeTemplateParmDecl>(ParamD))
9465 index = NTTP->getIndex();
9467 index = cast<TemplateTemplateParmDecl>(ParamD)->getIndex();
9468 S.
Diag(Templated->getLocation(),
9469 diag::note_ovl_candidate_explicit_arg_mismatch_unnamed)
9472 MaybeEmitInheritedConstructorNote(S, Found);
9481 S.
Diag(Templated->getLocation(),
9482 diag::note_ovl_candidate_instantiation_depth);
9483 MaybeEmitInheritedConstructorNote(S, Found);
9491 TemplateArgString =
" ";
9498 if (PDiag && PDiag->second.getDiagID() ==
9499 diag::err_typename_nested_not_found_enable_if) {
9502 S.
Diag(PDiag->first, diag::note_ovl_candidate_disabled_by_enable_if)
9503 <<
"'enable_if'" << TemplateArgString;
9513 SFINAEArgString =
": ";
9518 S.
Diag(Templated->getLocation(),
9519 diag::note_ovl_candidate_substitution_failure)
9520 << TemplateArgString << SFINAEArgString << R;
9521 MaybeEmitInheritedConstructorNote(S, Found);
9527 S.
Diag(Templated->getLocation(),
9528 diag::note_ovl_candidate_failed_overload_resolution)
9538 TemplateArgString =
" ";
9543 S.
Diag(Templated->getLocation(), diag::note_ovl_candidate_deduced_mismatch)
9546 << TemplateArgString;
9568 S.
Diag(Templated->getLocation(),
9569 diag::note_ovl_candidate_non_deduced_mismatch_qualified)
9576 if (TakingCandidateAddress && isa<FunctionDecl>(Templated) &&
9584 S.
Diag(Templated->getLocation(),
9585 diag::note_ovl_candidate_non_deduced_mismatch)
9586 << FirstTA << SecondTA;
9592 S.
Diag(Templated->getLocation(), diag::note_ovl_candidate_bad_deduction);
9593 MaybeEmitInheritedConstructorNote(S, Found);
9601 bool TakingCandidateAddress) {
9621 ClassifyOverloadCandidate(S, Cand->
FoundDecl, Callee, FnDesc);
9623 S.
Diag(Callee->getLocation(), diag::note_ovl_candidate_bad_target)
9624 << (
unsigned)FnKind << CalleeTarget << CallerTarget;
9629 if (Meth !=
nullptr && Meth->isImplicit()) {
9636 case oc_implicit_default_constructor:
9639 case oc_implicit_copy_constructor:
9642 case oc_implicit_move_constructor:
9645 case oc_implicit_copy_assignment:
9648 case oc_implicit_move_assignment:
9653 bool ConstRHS =
false;
9657 ConstRHS = RT->getPointeeType().isConstQualified();
9671 S.
Diag(Callee->getLocation(),
9672 diag::note_ovl_candidate_disabled_by_enable_if_attr)
9673 << Attr->getCond()->getSourceRange() << Attr->getMessage();
9691 bool TakingCandidateAddress) {
9699 ClassifyOverloadCandidate(S, Cand->
FoundDecl, Fn, FnDesc);
9701 S.
Diag(Fn->getLocation(), diag::note_ovl_candidate_deleted)
9704 MaybeEmitInheritedConstructorNote(S, Cand->
FoundDecl);
9721 TakingCandidateAddress);
9724 S.
Diag(Fn->getLocation(), diag::note_ovl_candidate_illegal_constructor)
9726 MaybeEmitInheritedConstructorNote(S, Cand->
FoundDecl);
9767 bool isLValueReference =
false;
9768 bool isRValueReference =
false;
9769 bool isPointer =
false;
9773 isLValueReference =
true;
9777 isRValueReference =
true;
9790 S.
Diag(Cand->
Surrogate->getLocation(), diag::note_ovl_surrogate_cand)
9797 assert(Cand->
NumConversions <= 2 &&
"builtin operator is not binary");
9798 std::string TypeStr(
"operator");
9804 S.
Diag(OpLoc, diag::note_ovl_builtin_unary_candidate) << TypeStr;
9809 S.
Diag(OpLoc, diag::note_ovl_builtin_binary_candidate) << TypeStr;
9816 for (
unsigned ArgIdx = 0; ArgIdx < NoOperands; ++ArgIdx) {
9818 if (ICS.
isBad())
break;
9822 S, OpLoc, S.
PDiag(diag::note_ambiguous_type_conversion));
9828 return Cand->
Function->getLocation();
9837 llvm_unreachable(
"TDK_success while diagnosing bad deduction");
9864 llvm_unreachable(
"Unhandled deduction result");
9868 struct CompareOverloadCandidatesForDisplay {
9879 if (L == R)
return false;
9883 if (!R->
Viable)
return true;
9904 if (LDist == RDist) {
9913 return LDist < RDist;
9931 numLFixes = (numLFixes == 0) ?
UINT_MAX : numLFixes;
9932 numRFixes = (numRFixes == 0) ?
UINT_MAX : numRFixes;
9933 if (numLFixes != numRFixes) {
9934 return numLFixes < numRFixes;
9959 if (leftBetter > 0)
return true;
9960 if (leftBetter < 0)
return false;
10001 bool Unfixable =
false;
10009 assert(ConvIdx != ConvCount &&
"no bad conversion in candidate");
10017 if (ConvIdx == ConvCount)
10021 "remaining conversion is initialized?");
10025 bool SuppressUserConversions =
false;
10028 unsigned ArgIdx = ConvIdx;
10039 if (isa<CXXMethodDecl>(Cand->
Function) &&
10040 !isa<CXXConstructorDecl>(Cand->
Function))
10044 assert(ConvCount <= 3);
10045 for (; ConvIdx != ConvCount; ++ConvIdx)
10049 SuppressUserConversions,
10058 for (; ConvIdx != ConvCount; ++ConvIdx, ++ArgIdx) {
10059 if (ArgIdx < NumParams) {
10061 S, Args[ArgIdx], Proto->
getParamType(ArgIdx), SuppressUserConversions,
10086 for (
iterator Cand =
begin(), LastCand =
end(); Cand != LastCand; ++Cand) {
10088 Cands.push_back(Cand);
10091 if (Cand->Function || Cand->IsSurrogate)
10092 Cands.push_back(Cand);
10098 std::sort(Cands.begin(), Cands.end(),
10099 CompareOverloadCandidatesForDisplay(S, OpLoc, Args.size()));
10101 bool ReportedAmbiguousConversions =
false;
10105 unsigned CandsShown = 0;
10106 for (I = Cands.begin(), E = Cands.end(); I !=
E; ++
I) {
10112 if (CandsShown >= 4 && ShowOverloads ==
Ovl_Best) {
10124 "Non-viable built-in candidates are not added to Cands.");
10131 if (!ReportedAmbiguousConversions) {
10133 ReportedAmbiguousConversions =
true;
10142 S.
Diag(OpLoc, diag::note_ovl_too_many_candidates) << int(E - I);
10152 struct CompareTemplateSpecCandidatesForDisplay {
10154 CompareTemplateSpecCandidatesForDisplay(
Sema &S) : S(S) {}
10188 bool ForTakingAddress) {
10193 void TemplateSpecCandidateSet::destroyCandidates() {
10195 i->DeductionFailure.Destroy();
10200 destroyCandidates();
10201 Candidates.clear();
10214 Cands.reserve(
size());
10215 for (
iterator Cand =
begin(), LastCand =
end(); Cand != LastCand; ++Cand) {
10216 if (Cand->Specialization)
10217 Cands.push_back(Cand);
10222 std::sort(Cands.begin(), Cands.end(),
10223 CompareTemplateSpecCandidatesForDisplay(S));
10230 unsigned CandsShown = 0;
10231 for (I = Cands.begin(), E = Cands.end(); I !=
E; ++
I) {
10237 if (CandsShown >= 4 && ShowOverloads ==
Ovl_Best)
10242 "Non-matching built-in candidates are not added to Cands.");
10247 S.
Diag(Loc, diag::note_ovl_too_many_candidates) << int(E - I);
10257 QualType Ret = PossiblyAFunctionType;
10275 class AddressOfFunctionResolver {
10285 bool TargetTypeIsNonStaticMemberFunction;
10286 bool FoundNonTemplateFunction;
10287 bool StaticMemberFunctionFromBoundPointer;
10288 bool HasComplained;
10297 AddressOfFunctionResolver(
Sema &S,
Expr *SourceExpr,
10298 const QualType &TargetType,
bool Complain)
10299 : S(S), SourceExpr(SourceExpr), TargetType(TargetType),
10300 Complain(Complain),
Context(S.getASTContext()),
10301 TargetTypeIsNonStaticMemberFunction(
10303 FoundNonTemplateFunction(
false),
10304 StaticMemberFunctionFromBoundPointer(
false),
10305 HasComplained(
false),
10307 OvlExpr(OvlExprInfo.Expression),
10308 FailedCandidates(OvlExpr->getNameLoc(),
true) {
10309 ExtractUnqualifiedFunctionTypeFromTargetType();
10311 if (TargetFunctionType->isFunctionType()) {
10313 if (!UME->isImplicitAccess() &&
10315 StaticMemberFunctionFromBoundPointer =
true;
10316 }
else if (OvlExpr->hasExplicitTemplateArgs()) {
10319 OvlExpr,
false, &dap)) {
10321 if (!Method->isStatic()) {
10325 TargetTypeIsNonStaticMemberFunction =
true;
10329 if (!OvlExprInfo.HasFormOfMemberPointer)
10333 Matches.push_back(std::make_pair(dap, Fn));
10338 if (OvlExpr->hasExplicitTemplateArgs())
10339 OvlExpr->copyTemplateArgumentsInto(OvlExplicitTemplateArgs);
10341 if (FindAllFunctionsThatMatchTargetTypeExactly()) {
10344 if (
Matches.size() > 1 && !eliminiateSuboptimalOverloadCandidates()) {
10345 if (FoundNonTemplateFunction)
10346 EliminateAllTemplateMatches();
10348 EliminateAllExceptMostSpecializedTemplate();
10353 EliminateSuboptimalCudaMatches();
10356 bool hasComplained()
const {
return HasComplained; }
10359 bool candidateHasExactlyCorrectType(
const FunctionDecl *FD) {
10371 return candidateHasExactlyCorrectType(A) &&
10372 (!candidateHasExactlyCorrectType(B) ||
10378 bool eliminiateSuboptimalOverloadCandidates() {
10383 if (isBetterCandidate(I->second, Best->second))
10387 auto IsBestOrInferiorToBest = [
this, BestFn](
10388 const std::pair<DeclAccessPair, FunctionDecl *> &Pair) {
10389 return BestFn == Pair.second || isBetterCandidate(BestFn, Pair.second);
10394 if (!std::all_of(
Matches.begin(),
Matches.end(), IsBestOrInferiorToBest))
10401 bool isTargetTypeAFunction()
const {
10402 return TargetFunctionType->isFunctionType();
10410 void inline ExtractUnqualifiedFunctionTypeFromTargetType() {
10421 if (Method->isStatic() == TargetTypeIsNonStaticMemberFunction)
10424 else if (TargetTypeIsNonStaticMemberFunction)
10437 &OvlExplicitTemplateArgs,
10438 TargetFunctionType, Specialization,
10441 FailedCandidates.addCandidate()
10457 Matches.push_back(std::make_pair(CurAccessFunPair, Specialization));
10461 bool AddMatchingNonTemplateFunction(
NamedDecl* Fn,
10466 if (Method->isStatic() == TargetTypeIsNonStaticMemberFunction)
10469 else if (TargetTypeIsNonStaticMemberFunction)
10472 if (
FunctionDecl *FunDecl = dyn_cast<FunctionDecl>(Fn)) {
10481 FunDecl->getReturnType()->isUndeducedType() &&
10483 HasComplained |= Complain;
10492 candidateHasExactlyCorrectType(FunDecl)) {
10493 Matches.push_back(std::make_pair(
10494 CurAccessFunPair, cast<FunctionDecl>(FunDecl->getCanonicalDecl())));
10495 FoundNonTemplateFunction =
true;
10503 bool FindAllFunctionsThatMatchTargetTypeExactly() {
10508 if (IsInvalidFormOfPointerToMemberFunction())
10512 E = OvlExpr->decls_end();
10524 = dyn_cast<FunctionTemplateDecl>(Fn)) {
10525 if (AddMatchingTemplateFunction(FunctionTemplate, I.getPair()))
10529 else if (!OvlExpr->hasExplicitTemplateArgs() &&
10530 AddMatchingNonTemplateFunction(Fn, I.getPair()))
10533 assert(Ret ||
Matches.empty());
10537 void EliminateAllExceptMostSpecializedTemplate() {
10550 for (
unsigned I = 0, E =
Matches.size(); I !=
E; ++
I)
10556 MatchesCopy.
begin(), MatchesCopy.
end(), FailedCandidates,
10557 SourceExpr->getLocStart(), S.
PDiag(),
10558 S.
PDiag(diag::err_addr_ovl_ambiguous)
10559 <<
Matches[0].second->getDeclName(),
10560 S.
PDiag(diag::note_ovl_candidate)
10561 << (
unsigned)oc_function_template,
10562 Complain, TargetFunctionType);
10564 if (Result != MatchesCopy.
end()) {
10567 Matches[0].second = cast<FunctionDecl>(*Result);
10570 HasComplained |= Complain;
10573 void EliminateAllTemplateMatches() {
10576 for (
unsigned I = 0, N =
Matches.size(); I != N; ) {
10577 if (
Matches[I].second->getPrimaryTemplate() ==
nullptr)
10586 void EliminateSuboptimalCudaMatches() {
10591 void ComplainNoMatchesFound()
const {
10593 S.
Diag(OvlExpr->getLocStart(), diag::err_addr_ovl_no_viable)
10594 << OvlExpr->getName() << TargetFunctionType
10595 << OvlExpr->getSourceRange();
10596 if (FailedCandidates.empty())
10604 IEnd = OvlExpr->decls_end();
10607 dyn_cast<FunctionDecl>((*I)->getUnderlyingDecl()))
10611 FailedCandidates.NoteCandidates(S, OvlExpr->getLocStart());
10615 bool IsInvalidFormOfPointerToMemberFunction()
const {
10616 return TargetTypeIsNonStaticMemberFunction &&
10617 !OvlExprInfo.HasFormOfMemberPointer;
10620 void ComplainIsInvalidFormOfPointerToMemberFunction()
const {
10624 S.
Diag(OvlExpr->getNameLoc(), diag::err_addr_ovl_no_qualifier)
10625 << TargetType << OvlExpr->getSourceRange();
10628 bool IsStaticMemberFunctionFromBoundPointer()
const {
10629 return StaticMemberFunctionFromBoundPointer;
10632 void ComplainIsStaticMemberFunctionFromBoundPointer()
const {
10633 S.
Diag(OvlExpr->getLocStart(),
10634 diag::err_invalid_form_pointer_member_function)
10635 << OvlExpr->getSourceRange();
10638 void ComplainOfInvalidConversion()
const {
10639 S.
Diag(OvlExpr->getLocStart(), diag::err_addr_ovl_not_func_ptrref)
10640 << OvlExpr->getName() << TargetType;
10643 void ComplainMultipleMatchesFound()
const {
10645 S.
Diag(OvlExpr->getLocStart(), diag::err_addr_ovl_ambiguous)
10646 << OvlExpr->getName()
10647 << OvlExpr->getSourceRange();
10652 bool hadMultipleCandidates()
const {
return (OvlExpr->getNumDecls() > 1); }
10654 int getNumMatches()
const {
return Matches.size(); }
10657 if (
Matches.size() != 1)
return nullptr;
10662 if (
Matches.size() != 1)
return nullptr;
10688 bool *pHadMultipleCandidates) {
10691 AddressOfFunctionResolver Resolver(*
this, AddressOfExpr, TargetType,
10693 int NumMatches = Resolver.getNumMatches();
10695 bool ShouldComplain = Complain && !Resolver.hasComplained();
10696 if (NumMatches == 0 && ShouldComplain) {
10697 if (Resolver.IsInvalidFormOfPointerToMemberFunction())
10698 Resolver.ComplainIsInvalidFormOfPointerToMemberFunction();
10700 Resolver.ComplainNoMatchesFound();
10702 else if (NumMatches > 1 && ShouldComplain)
10703 Resolver.ComplainMultipleMatchesFound();
10704 else if (NumMatches == 1) {
10705 Fn = Resolver.getMatchingFunctionDecl();
10707 FoundResult = *Resolver.getMatchingFunctionAccessPair();
10709 if (Resolver.IsStaticMemberFunctionFromBoundPointer())
10710 Resolver.ComplainIsStaticMemberFunctionFromBoundPointer();
10716 if (pHadMultipleCandidates)
10717 *pHadMultipleCandidates = Resolver.hadMultipleCandidates();
10738 auto *FD = dyn_cast<
FunctionDecl>(I->getUnderlyingDecl());
10828 = cast<FunctionTemplateDecl>((*I)->getUnderlyingDecl());
10840 Specialization, Info,
10844 FailedCandidates.addCandidate()
10850 assert(Specialization &&
"no specialization and no error?");
10862 Matched = Specialization;
10863 if (FoundResult) *FoundResult = I.getPair();
10867 Matched->getReturnType()->isUndeducedType() &&
10886 ExprResult &SrcExpr,
bool doFunctionPointerConverion,
10887 bool complain,
SourceRange OpRangeForComplaining,
10889 unsigned DiagIDForComplaining) {
10897 ovl.Expression,
false, &found)) {
10907 if (!ovl.HasFormOfMemberPointer &&
10908 isa<CXXMethodDecl>(fn) &&
10909 cast<CXXMethodDecl>(fn)->isInstance()) {
10910 if (!complain)
return false;
10912 Diag(ovl.Expression->getExprLoc(),
10913 diag::err_bound_member_function)
10914 << 0 << ovl.Expression->getSourceRange();
10926 SingleFunctionExpression =
10930 if (doFunctionPointerConverion) {
10931 SingleFunctionExpression =
10933 if (SingleFunctionExpression.
isInvalid()) {
10940 if (!SingleFunctionExpression.
isUsable()) {
10942 Diag(OpRangeForComplaining.
getBegin(), DiagIDForComplaining)
10943 << ovl.Expression->getName()
10944 << DestTypeForComplaining
10945 << OpRangeForComplaining
10946 << ovl.Expression->getQualifierLoc().getSourceRange();
10956 SrcExpr = SingleFunctionExpression;
10966 bool PartialOverloading,
10969 if (isa<UsingShadowDecl>(Callee))
10970 Callee = cast<UsingShadowDecl>(Callee)->getTargetDecl();
10972 if (
FunctionDecl *Func = dyn_cast<FunctionDecl>(Callee)) {
10973 if (ExplicitTemplateArgs) {
10974 assert(!KnownValid &&
"Explicit template arguments?");
10979 PartialOverloading);
10984 = dyn_cast<FunctionTemplateDecl>(Callee)) {
10986 ExplicitTemplateArgs, Args, CandidateSet,
10988 PartialOverloading);
10992 assert(!KnownValid &&
"unhandled case in overloaded call candidate");
11000 bool PartialOverloading) {
11023 assert(!(*I)->getDeclContext()->isRecord());
11024 assert(isa<UsingShadowDecl>(*I) ||
11025 !(*I)->getDeclContext()->isFunctionOrMethod());
11026 assert((*I)->getUnderlyingDecl()->isFunctionOrFunctionTemplate());
11036 ExplicitTemplateArgs = &TABuffer;
11042 CandidateSet, PartialOverloading,
11047 Args, ExplicitTemplateArgs,
11048 CandidateSet, PartialOverloading);
11055 case OO_New:
case OO_Array_New:
11056 case OO_Delete:
case OO_Array_Delete:
11076 bool *DoDiagnoseEmptyLookup =
nullptr) {
11081 if (DC->isTransparentContext())
11089 if (isa<CXXRecordDecl>(DC)) {
11093 if (DoDiagnoseEmptyLookup)
11094 *DoDiagnoseEmptyLookup =
true;
11101 ExplicitTemplateArgs, Args,
11102 Candidates,
false,
false);
11105 if (Candidates.BestViableFunction(SemaRef, FnLoc, Best) !=
OR_Success) {
11117 AssociatedNamespaces,
11118 AssociatedClasses);
11123 it = AssociatedNamespaces.begin(),
11124 end = AssociatedNamespaces.end(); it !=
end; ++it) {
11136 SuggestedNamespaces.insert(*it);
11140 SemaRef.
Diag(R.
getNameLoc(), diag::err_not_found_by_two_phase_lookup)
11142 if (SuggestedNamespaces.empty()) {
11143 SemaRef.
Diag(Best->Function->getLocation(),
11144 diag::note_not_found_by_two_phase_lookup)
11146 }
else if (SuggestedNamespaces.size() == 1) {
11147 SemaRef.
Diag(Best->Function->getLocation(),
11148 diag::note_not_found_by_two_phase_lookup)
11154 SemaRef.
Diag(Best->Function->getLocation(),
11155 diag::note_not_found_by_two_phase_lookup)
11187 class BuildRecoveryCallExprRAII {
11190 BuildRecoveryCallExprRAII(
Sema &S) : SemaRef(S) {
11191 assert(SemaRef.IsBuildingRecoveryCallExpr ==
false);
11192 SemaRef.IsBuildingRecoveryCallExpr =
true;
11195 ~BuildRecoveryCallExprRAII() {
11196 SemaRef.IsBuildingRecoveryCallExpr =
false;
11202 static std::unique_ptr<CorrectionCandidateCallback>
11204 bool HasTemplateArgs,
bool AllowTypoCorrection) {
11205 if (!AllowTypoCorrection)
11206 return llvm::make_unique<NoTypoCorrectionCCC>();
11207 return llvm::make_unique<FunctionCallFilterCCC>(SemaRef,
NumArgs,
11208 HasTemplateArgs, ME);
11220 bool EmptyLookup,
bool AllowTypoCorrection) {
11229 BuildRecoveryCallExprRAII RCE(SemaRef);
11239 ExplicitTemplateArgs = &TABuffer;
11244 bool DoDiagnoseEmptyLookup = EmptyLookup;
11247 ExplicitTemplateArgs, Args,
11248 &DoDiagnoseEmptyLookup) &&
11251 MakeValidator(SemaRef, dyn_cast<MemberExpr>(Fn), Args.size(),
11252 ExplicitTemplateArgs !=
nullptr, AllowTypoCorrection),
11253 ExplicitTemplateArgs, Args)))
11256 assert(!R.empty() &&
"lookup results empty despite recovery");
11261 if ((*R.begin())->isCXXClassMember())
11263 ExplicitTemplateArgs, S);
11264 else if (ExplicitTemplateArgs || TemplateKWLoc.
isValid())
11266 ExplicitTemplateArgs);
11270 if (NewFn.isInvalid())
11276 return SemaRef.
ActOnCallExpr(
nullptr, NewFn.get(), LParenLoc,
11293 assert(!ULE->
getQualifier() &&
"qualified name with ADL");
11300 F->getBuiltinID() && F->isImplicit())
11301 llvm_unreachable(
"performing ADL for builtin");
11308 UnbridgedCastsSet UnbridgedCasts;
11323 if (CandidateSet->
empty() ||
11340 if (CandidateSet->
empty())
11343 UnbridgedCasts.restore();
11359 bool AllowTypoCorrection) {
11360 if (CandidateSet->
empty())
11363 AllowTypoCorrection);
11365 switch (OverloadResult) {
11382 AllowTypoCorrection);
11389 for (
const Expr *Arg : Args) {
11390 if (!Arg->getType()->isFunctionType())
11392 if (
auto *DRE = dyn_cast<DeclRefExpr>(Arg->IgnoreParenImpCasts())) {
11396 Arg->getExprLoc()))
11401 SemaRef.
Diag(Fn->getLocStart(), diag::err_ovl_no_viable_function_in_call)
11402 << ULE->
getName() << Fn->getSourceRange();
11408 SemaRef.
Diag(Fn->getLocStart(), diag::err_ovl_ambiguous_call)
11409 << ULE->
getName() << Fn->getSourceRange();
11414 SemaRef.
Diag(Fn->getLocStart(), diag::err_ovl_deleted_call)
11415 << (*Best)->Function->isDeleted()
11418 << Fn->getSourceRange();
11436 for (
auto I = CS.
begin(), E = CS.
end(); I !=
E; ++
I) {
11457 bool AllowTypoCorrection,
11458 bool CalleesAddressIsTaken) {
11469 if (CalleesAddressIsTaken)
11477 RParenLoc, ExecConfig, &CandidateSet,
11478 &Best, OverloadResult,
11479 AllowTypoCorrection);
11483 return Functions.
size() > 1 ||
11484 (Functions.
size() == 1 && isa<FunctionTemplateDecl>(*Functions.
begin()));
11507 assert(Op !=
OO_None &&
"Invalid opcode for overloaded unary operator");
11521 if (Opc == UO_PostInc || Opc == UO_PostDec) {
11563 bool HadMultipleCandidates = (CandidateSet.
size() > 1);
11577 if (
CXXMethodDecl *Method = dyn_cast<CXXMethodDecl>(FnDecl)) {
11582 Best->FoundDecl, Method);
11585 Input = InputRes.
get();
11596 Input = InputInit.
get();
11601 HadMultipleCandidates, OpLoc);
11613 ResultTy, VK, OpLoc,
false);
11628 Input = InputRes.
get();
11646 Diag(OpLoc, diag::err_ovl_ambiguous_oper_unary)
11649 << Input->getSourceRange();
11655 Diag(OpLoc, diag::err_ovl_deleted_oper)
11656 << Best->Function->isDeleted()
11659 << Input->getSourceRange();
11692 Expr *Args[2] = { LHS, RHS };
11700 if (Args[0]->isTypeDependent() || Args[1]->isTypeDependent()) {
11704 if (Opc <= BO_Assign || Opc > BO_OrAssign)
11745 if (Opc == BO_Assign && !Args[0]->getType()->isOverloadableType())
11750 if (Opc == BO_PtrMemD)
11765 if (Opc != BO_Assign)
11773 bool HadMultipleCandidates = (CandidateSet.
size() > 1);
11787 if (
CXXMethodDecl *Method = dyn_cast<CXXMethodDecl>(FnDecl)) {
11801 Best->FoundDecl, Method);
11829 HadMultipleCandidates, OpLoc);
11840 Args, ResultTy, VK, OpLoc,
11849 if (isa<CXXMethodDecl>(FnDecl))
11850 ArgsArray = ArgsArray.slice(1);
11853 if (Op == OO_Equal)
11856 checkCall(FnDecl,
nullptr, ArgsArray, isa<CXXMethodDecl>(FnDecl), OpLoc,
11869 Args[0] = ArgsRes0.
get();
11876 Args[1] = ArgsRes1.
get();
11886 if (Opc == BO_Comma)
11894 Opc >= BO_Assign && Opc <= BO_OrAssign) {
11895 Diag(OpLoc, diag::err_ovl_no_viable_oper)
11897 << Args[0]->getSourceRange() << Args[1]->getSourceRange();
11898 if (Args[0]->getType()->isIncompleteType()) {
11899 Diag(OpLoc, diag::note_assign_lhs_incomplete)
11901 << Args[0]->getSourceRange() << Args[1]->getSourceRange();
11916 "C++ binary operator overloading is missing candidates!");
11924 Diag(OpLoc, diag::err_ovl_ambiguous_oper_binary)
11927 << Args[0]->getSourceRange() << Args[1]->getSourceRange();
11934 CXXMethodDecl *Method = cast<CXXMethodDecl>(Best->Function);
11935 Diag(OpLoc, diag::err_ovl_deleted_special_oper)
11944 Diag(OpLoc, diag::err_ovl_deleted_oper)
11945 << Best->Function->isDeleted()
11948 << Args[0]->getSourceRange() << Args[1]->getSourceRange();
11963 Expr *Args[2] = { Base, Idx };
11969 if (Args[0]->isTypeDependent() || Args[1]->isTypeDependent()) {
12005 bool HadMultipleCandidates = (CandidateSet.
size() > 1);
12024 Best->FoundDecl, Method);
12025 if (Arg0.isInvalid())
12027 Args[0] = Arg0.get();
12043 OpLocInfo.setCXXOperatorNameRange(
SourceRange(LLoc, RLoc));
12046 HadMultipleCandidates,
12047 OpLocInfo.getLoc(),
12048 OpLocInfo.getInfo());
12059 FnExpr.
get(), Args,
12060 ResultTy, VK, RLoc,
12076 Args[0] = ArgsRes0.
get();
12083 Args[1] = ArgsRes1.
get();
12090 if (CandidateSet.
empty())
12091 Diag(LLoc, diag::err_ovl_no_oper)
12093 << Args[0]->getSourceRange() << Args[1]->getSourceRange();
12095 Diag(LLoc, diag::err_ovl_no_viable_subscript)
12097 << Args[0]->getSourceRange() << Args[1]->getSourceRange();
12104 Diag(LLoc, diag::err_ovl_ambiguous_oper_binary)
12107 << Args[0]->getSourceRange() << Args[1]->getSourceRange();
12113 Diag(LLoc, diag::err_ovl_deleted_oper)
12114 << Best->Function->isDeleted() <<
"[]"
12116 << Args[0]->getSourceRange() << Args[1]->getSourceRange();
12146 if (
BinaryOperator *op = dyn_cast<BinaryOperator>(NakedMemExpr)) {
12148 assert(op->getOpcode() == BO_PtrMemD || op->getOpcode() == BO_PtrMemI);
12161 QualType objectType = op->getLHS()->getType();
12162 if (op->getOpcode() == BO_PtrMemI)
12164 Qualifiers objectQuals = objectType.getQualifiers();
12166 Qualifiers difference = objectQuals - funcQuals;
12170 std::string qualsString = difference.
getAsString();
12171 Diag(LParenLoc, diag::err_pointer_to_member_call_drops_quals)
12172 << fnType.getUnqualifiedType()
12174 << (qualsString.find(
' ') == std::string::npos ? 1 : 2);
12179 resultType, valueKind, RParenLoc);
12188 if (CheckOtherCall(call, proto))
12194 if (isa<CXXPseudoDestructorExpr>(NakedMemExpr))
12198 UnbridgedCastsSet UnbridgedCasts;
12206 if (isa<MemberExpr>(NakedMemExpr)) {
12207 MemExpr = cast<MemberExpr>(NakedMemExpr);
12211 UnbridgedCasts.restore();
12229 TemplateArgs = &TemplateArgsBuffer;
12236 CXXRecordDecl *ActingDC = cast<CXXRecordDecl>(Func->getDeclContext());
12237 if (isa<UsingShadowDecl>(Func))
12238 Func = cast<UsingShadowDecl>(Func)->getTargetDecl();
12242 if (
getLangOpts().MicrosoftExt && isa<CXXConstructorDecl>(Func)) {
12244 Args, CandidateSet);
12245 }
else if ((Method = dyn_cast<CXXMethodDecl>(Func))) {
12252 ObjectClassification, Args, CandidateSet,
12256 I.getPair(), ActingDC, TemplateArgs,
12257 ObjectType, ObjectClassification,
12258 Args, CandidateSet,
12265 UnbridgedCasts.restore();
12271 Method = cast<CXXMethodDecl>(Best->Function);
12272 FoundDecl = Best->FoundDecl;
12282 if (Method != FoundDecl.getDecl() &&
12289 diag::err_ovl_no_viable_member_function_in_call)
12290 << DeclName << MemExprE->getSourceRange();
12297 << DeclName << MemExprE->getSourceRange();
12304 << Best->Function->isDeleted()
12307 << MemExprE->getSourceRange();
12329 assert(Method &&
"Member call to something that isn't a method?");
12332 ResultType, VK, RParenLoc);
12357 FoundDecl, Method);
12372 if (CheckFunctionCall(Method, TheCall, Proto))
12378 if (isa<MemberExpr>(NakedMemExpr)) {
12380 Diag(MemExprE->getLocStart(),
12381 diag::err_ovl_no_viable_member_function_in_call)
12383 Diag(Method->getLocation(),
12384 diag::note_ovl_candidate_disabled_by_enable_if_attr)
12385 <<
Attr->getCond()->getSourceRange() <<
Attr->getMessage();
12398 diag::warn_call_to_pure_virtual_member_function_from_ctor_dtor)
12405 diag::note_pure_qualified_call_kext)
12416 CallCanBeVirtual,
true,
12436 UnbridgedCastsSet UnbridgedCasts;
12441 "Requires object type argument");
12456 diag::err_incomplete_object_call, Object.
get()))
12464 Oper != OperEnd; ++Oper) {
12467 Args, CandidateSet,
12488 const auto &Conversions =
12489 cast<CXXRecordDecl>(Record->getDecl())->getVisibleConversionFunctions();
12490 for (
auto I = Conversions.begin(), E = Conversions.end(); I !=
E; ++
I) {
12492 CXXRecordDecl *ActingContext = cast<CXXRecordDecl>(D->getDeclContext());
12493 if (isa<UsingShadowDecl>(D))
12494 D = cast<UsingShadowDecl>(D)->getTargetDecl();
12498 if (isa<FunctionTemplateDecl>(D))
12512 Object.
get(), Args, CandidateSet);
12517 bool HadMultipleCandidates = (CandidateSet.size() > 1);
12521 switch (CandidateSet.BestViableFunction(*
this, Object.
get()->getLocStart(),
12529 if (CandidateSet.empty())
12530 Diag(Object.
get()->getLocStart(), diag::err_ovl_no_oper)
12532 << Object.
get()->getSourceRange();
12534 Diag(Object.
get()->getLocStart(),
12535 diag::err_ovl_no_viable_object_call)
12536 << Object.
get()->
getType() << Object.
get()->getSourceRange();
12541 Diag(Object.
get()->getLocStart(),
12542 diag::err_ovl_ambiguous_object_call)
12543 << Object.
get()->
getType() << Object.
get()->getSourceRange();
12548 Diag(Object.
get()->getLocStart(),
12549 diag::err_ovl_deleted_object_call)
12550 << Best->Function->isDeleted()
12553 << Object.
get()->getSourceRange();
12558 if (Best == CandidateSet.end())
12561 UnbridgedCasts.restore();
12563 if (Best->Function ==
nullptr) {
12567 = cast<CXXConversionDecl>(
12568 Best->Conversions[0].UserDefined.ConversionFunction);
12574 assert(Conv == Best->FoundDecl.getDecl() &&
12575 "Found Decl & conversion-to-functionptr should be same, right?!");
12583 Conv, HadMultipleCandidates);
12584 if (Call.isInvalid())
12588 CK_UserDefinedConversion, Call.get(),
12591 return ActOnCallExpr(S, Call.get(), LParenLoc, Args, RParenLoc);
12599 CXXMethodDecl *Method = cast<CXXMethodDecl>(Best->Function);
12602 if (Method->isInvalidDecl())
12614 HadMultipleCandidates,
12615 OpLocInfo.getLoc(),
12616 OpLocInfo.getInfo());
12622 std::unique_ptr<Expr * []> MethodArgs(
new Expr *[Args.size() + 1]);
12623 MethodArgs[0] = Object.
get();
12624 std::copy(Args.begin(), Args.end(), &MethodArgs[1]);
12628 QualType ResultTy = Method->getReturnType();
12630 ResultTy = ResultTy.getNonLValueExprType(
Context);
12634 llvm::makeArrayRef(MethodArgs.get(), Args.size() + 1),
12635 ResultTy, VK, RParenLoc,
false);
12636 MethodArgs.reset();
12643 if (Args.size() < NumParams)
12646 bool IsError =
false;
12651 Best->FoundDecl, Method);
12656 TheCall->setArg(0, Object.
get());
12659 for (
unsigned i = 0; i != NumParams; i++) {
12661 if (i < Args.size()) {
12669 Method->getParamDecl(i)),
12685 TheCall->setArg(i + 1, Arg);
12691 for (
unsigned i = NumParams, e = Args.size(); i < e; i++) {
12695 TheCall->setArg(i + 1, Arg.
get());
12699 if (IsError)
return true;
12703 if (CheckFunctionCall(Method, TheCall, Proto))
12714 bool *NoArrowOperatorFound) {
12716 "left-hand side must have class type");
12735 diag::err_typecheck_incomplete_tag, Base))
12743 Oper != OperEnd; ++Oper) {
12745 None, CandidateSet,
false);
12748 bool HadMultipleCandidates = (CandidateSet.
size() > 1);
12758 if (CandidateSet.
empty()) {
12760 if (NoArrowOperatorFound) {
12763 *NoArrowOperatorFound =
true;
12766 Diag(OpLoc, diag::err_typecheck_member_reference_arrow)
12767 << BaseType << Base->getSourceRange();
12769 Diag(OpLoc, diag::note_typecheck_member_reference_suggestion)
12773 Diag(OpLoc, diag::err_ovl_no_viable_oper)
12774 <<
"operator->" << Base->getSourceRange();
12779 Diag(OpLoc, diag::err_ovl_ambiguous_oper_unary)
12780 <<
"->" << Base->
getType() << Base->getSourceRange();
12785 Diag(OpLoc, diag::err_ovl_deleted_oper)
12786 << Best->Function->isDeleted()
12789 << Base->getSourceRange();
12797 CXXMethodDecl *Method = cast<CXXMethodDecl>(Best->Function);
12800 Best->FoundDecl, Method);
12801 if (BaseResult.isInvalid())
12803 Base = BaseResult.get();
12807 HadMultipleCandidates, OpLoc);
12816 Base, ResultTy, VK, OpLoc,
false);
12838 bool HadMultipleCandidates = (CandidateSet.size() > 1);
12843 switch (CandidateSet.BestViableFunction(*
this, UDSuffixLoc, Best)) {
12849 Diag(UDSuffixLoc, diag::err_ovl_no_viable_function_in_call)
12862 HadMultipleCandidates,
12871 for (
unsigned ArgIdx = 0, N = Args.size(); ArgIdx != N; ++ArgIdx) {
12877 ConvArgs[ArgIdx] = InputInit.
get();
12886 llvm::makeArrayRef(ConvArgs, Args.size()),
12887 ResultTy, VK, LitEndLoc, UDSuffixLoc);
12892 if (CheckFunctionCall(FD, UDL,
nullptr))
12912 Scope *S =
nullptr;
12914 CandidateSet->
clear();
12915 if (!MemberLookup.
empty()) {
12938 FoundNames.
begin(), FoundNames.
end());
12941 CandidateSet, CallExpr);
12942 if (CandidateSet->
empty() || CandidateSetError) {
12955 Loc,
nullptr, CandidateSet, &Best,
12974 if (
ParenExpr *PE = dyn_cast<ParenExpr>(E)) {
12977 if (SubExpr == PE->getSubExpr())
12980 return new (
Context)
ParenExpr(PE->getLParen(), PE->getRParen(), SubExpr);
12988 "Implicit cast type cannot be determined from overload");
12989 assert(ICE->path_empty() &&
"fixing up hierarchy conversion?");
12990 if (SubExpr == ICE->getSubExpr())
12994 ICE->getCastKind(),
13000 assert(UnOp->getOpcode() == UO_AddrOf &&
13001 "Can only take the address of an overloaded function");
13003 if (Method->isStatic()) {
13012 if (SubExpr == UnOp->getSubExpr())
13015 assert(isa<DeclRefExpr>(SubExpr)
13016 &&
"fixed to something other than a decl ref");
13018 &&
"fixed to a member ref with no nested name qualifier");
13033 UnOp->getOperatorLoc());
13038 if (SubExpr == UnOp->getSubExpr())
13044 UnOp->getOperatorLoc());
13050 if (ULE->hasExplicitTemplateArgs()) {
13051 ULE->copyTemplateArgumentsInto(TemplateArgsBuffer);
13052 TemplateArgs = &TemplateArgsBuffer;
13056 ULE->getQualifierLoc(),
13057 ULE->getTemplateKeywordLoc(),
13073 if (MemExpr->hasExplicitTemplateArgs()) {
13074 MemExpr->copyTemplateArgumentsInto(TemplateArgsBuffer);
13075 TemplateArgs = &TemplateArgsBuffer;
13082 if (MemExpr->isImplicitAccess()) {
13083 if (cast<CXXMethodDecl>(Fn)->isStatic()) {
13085 MemExpr->getQualifierLoc(),
13086 MemExpr->getTemplateKeywordLoc(),
13089 MemExpr->getMemberLoc(),
13099 if (MemExpr->getQualifier())
13100 Loc = MemExpr->getQualifierLoc().getBeginLoc();
13103 MemExpr->getBaseType(),
13107 Base = MemExpr->getBase();
13111 if (cast<CXXMethodDecl>(Fn)->isStatic()) {
13120 Context, Base, MemExpr->isArrow(), MemExpr->getOperatorLoc(),
13121 MemExpr->getQualifierLoc(), MemExpr->getTemplateKeywordLoc(), Fn, Found,
13122 MemExpr->getMemberNameInfo(), TemplateArgs,
type, valueKind,
13129 llvm_unreachable(
"Invalid reference to overloaded function");
Abstract class used to diagnose incomplete types.
unsigned ExplicitCallArguments
The number of call arguments that were explicitly provided, to be used while performing partial order...
bool hasObjCGCAttr() const
A call to an overloaded operator written using operator syntax.
ValueDecl * getMemberDecl() const
Retrieve the member declaration to which this expression refers.
bool compatiblyIncludesObjCLifetime(Qualifiers other) const
Determines if these qualifiers compatibly include another set of qualifiers from the narrow perspecti...
int getFloatingTypeOrder(QualType LHS, QualType RHS) const
Compare the rank of the two specified floating point types, ignoring the domain of the type (i...
void copyTemplateArgumentsInto(TemplateArgumentListInfo &List) const
Copies the template arguments into the given structure.
void setValueDependent(bool VD)
Set whether this expression is value-dependent or not.
bool isObjCObjectOrInterfaceType() const
DeclAccessPair FoundConversionFunction
The declaration that we found via name lookup, which might be the same as ConversionFunction or it mi...
Defines the clang::ASTContext interface.
Module * getOwningModule(Decl *Entity)
Get the module owning an entity.
unsigned getNumInits() const
unsigned DeprecatedStringLiteralToCharPtr
Whether this is the deprecated conversion of a string literal to a pointer to non-const character dat...
Qualifiers getLocalQualifiers() const
Retrieve the set of qualifiers local to this particular QualType instance, not including any qualifie...
SmallVector< TemplateSpecCandidate, 16 >::iterator iterator
(CUDA) This candidate was not viable because the callee was not accessible from the caller's target (...
FunctionDecl - An instance of this class is created to represent a function declaration or definition...
bool isMSVCRTEntryPoint() const
Determines whether this function is a MSVCRT user defined entry point.
bool CheckCUDATarget(const FunctionDecl *Caller, const FunctionDecl *Callee)
Determines whether Caller may invoke Callee, based on their CUDA host/device attributes.
void setStdInitializerListElement(bool V=true)
static DiagnosticBuilder Diag(DiagnosticsEngine *Diags, const LangOptions &Features, FullSourceLoc TokLoc, const char *TokBegin, const char *TokRangeBegin, const char *TokRangeEnd, unsigned DiagID)
Produce a diagnostic highlighting some portion of a literal.
bool EllipsisConversion
EllipsisConversion - When this is true, it means user-defined conversion sequence starts with a ...
static void markUnaddressableCandidatesUnviable(Sema &S, OverloadCandidateSet &CS)
bool isNullPtrType() const
QualType getToType() const
StringRef getName() const
getName - Get the name of identifier for this declaration as a StringRef.
ExprResult PerformContextuallyConvertToBool(Expr *From)
PerformContextuallyConvertToBool - Perform a contextual conversion of the expression From to bool (C+...
const TemplateArgument * getSecondArg()
Return the second template argument this deduction failure refers to, if any.
Smart pointer class that efficiently represents Objective-C method names.
static bool isTypeValid(QualType T)
Determine whether the given type is valid, e.g., it is not an invalid C++ class.
PointerType - C99 6.7.5.1 - Pointer Declarators.
bool isAtLeastAsQualifiedAs(QualType Other) const
Determine whether this type is at least as qualified as the other given type, requiring exact equalit...
A (possibly-)qualified type.
bool hasExplicitTemplateArgs() const
Determines whether this expression had explicit template arguments.
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)
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.
void EraseUnwantedCUDAMatches(const FunctionDecl *Caller, SmallVectorImpl< FunctionDecl * > &Matches)
Finds a function in Matches with highest calling priority from Caller context and erases all function...
bool isEquivalentInternalLinkageDeclaration(const NamedDecl *A, const NamedDecl *B)
Determine if A and B are equivalent internal linkage declarations from different modules, and thus an ambiguity error can be downgraded to an extension warning.
void setFromType(QualType T)
QualType getConversionType() const
Returns the type that this conversion function is converting to.
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
Template argument deduction was successful.
UnresolvedSetIterator getMostSpecialized(UnresolvedSetIterator SBegin, UnresolvedSetIterator SEnd, TemplateSpecCandidateSet &FailedCandidates, SourceLocation Loc, const PartialDiagnostic &NoneDiag, const PartialDiagnostic &AmbigDiag, const PartialDiagnostic &CandidateDiag, bool Complain=true, QualType TargetType=QualType())
Retrieve the most specialized of the given function template specializations.
Ordinary name lookup, which finds ordinary names (functions, variables, typedefs, etc...
IdentifierInfo * getIdentifier() const
getIdentifier - Get the identifier that names this declaration, if there is one.
bool isInstantiationDependentType() const
Determine whether this type is an instantiation-dependent type, meaning that the type involves a temp...
bool isObjCPointerConversion(QualType FromType, QualType ToType, QualType &ConvertedType, bool &IncompatibleObjC)
isObjCPointerConversion - Determines whether this is an Objective-C pointer conversion.
QualType getNonLValueExprType(const ASTContext &Context) const
Determine the type of a (typically non-lvalue) expression with the specified result type...
QualType getQualifiedType(SplitQualType split) const
Un-split a SplitQualType.
const LangOptions & getLangOpts() const
A structure used to record information about a failed template argument deduction, for diagnosis.
static UnresolvedLookupExpr * Create(const ASTContext &C, CXXRecordDecl *NamingClass, NestedNameSpecifierLoc QualifierLoc, const DeclarationNameInfo &NameInfo, bool ADL, bool Overloaded, UnresolvedSetIterator Begin, UnresolvedSetIterator End)
CanQual< T > getUnqualifiedType() const
Retrieve the unqualified form of this type.
void dump() const
dump - Print this standard conversion sequence to standard error.
SourceLocation getCXXLiteralOperatorNameLoc() const
getCXXLiteralOperatorNameLoc - Returns the location of the literal operator name (not the operator ke...
bool isAnyCharacterType() const
Determine whether this type is any of the built-in character types.
static void AddBuiltinAssignmentOperatorCandidates(Sema &S, QualType T, ArrayRef< Expr * > Args, OverloadCandidateSet &CandidateSet)
Helper function for AddBuiltinOperatorCandidates() that adds the volatile- and non-volatile-qualified...
FunctionType - C99 6.7.5.3 - Function Declarators.
TemplateDecl * getAsTemplateDecl() const
Retrieve the underlying template declaration that this template name refers to, if known...
bool isMain() const
Determines whether this function is "main", which is the entry point into an executable program...
Provides information about an attempted template argument deduction, whose success or failure was des...
QualType getRValueReferenceType(QualType T) const
Return the uniqued reference to the type for an rvalue reference to the specified type...
unsigned getIntWidth(QualType T) const
void clear()
Clear out all of the candidates.
ExprResult BuildCXXDefaultArgExpr(SourceLocation CallLoc, FunctionDecl *FD, ParmVarDecl *Param)
BuildCXXDefaultArgExpr - Creates a CXXDefaultArgExpr, instantiating the default expr if needed...
Complex conversions (C99 6.3.1.6)
void setObjCLifetime(ObjCLifetime type)
bool hasPlaceholderType() const
Returns whether this expression has a placeholder type.
std::string getTemplateArgumentBindingsText(const TemplateParameterList *Params, const TemplateArgumentList &Args)
Produces a formatted string that describes the binding of template parameters to template arguments...
NestedNameSpecifier * getQualifier() const
If the member name was qualified, retrieves the nested-name-specifier that precedes the member name...
bool isRecordType() const
UserDefinedConversionSequence UserDefined
When ConversionKind == UserDefinedConversion, provides the details of the user-defined conversion seq...
SemaDiagnosticBuilder Diag(SourceLocation Loc, unsigned DiagID)
Emit a diagnostic.
ConstructorInfo getConstructorInfo(NamedDecl *ND)
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)
A reference to a name which we were able to look up during parsing but could not resolve to a specifi...
ExprResult PerformContextualImplicitConversion(SourceLocation Loc, Expr *FromE, ContextualImplicitConverter &Converter)
Perform a contextual implicit conversion.
QualType getVolatileType(QualType T) const
Return the uniqued reference to the type for a volatile qualified type.
bool 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
Expr * getExpr()
Return the expression this deduction failure refers to, if any.
ParenExpr - This represents a parethesized expression, e.g.
bool CanPerformCopyInitialization(const InitializedEntity &Entity, ExprResult Init)
ImplicitConversionRank
ImplicitConversionRank - The rank of an implicit conversion kind.
bool hasDefinition() const
std::string getAsString() const
static void NoteFunctionCandidate(Sema &S, OverloadCandidate *Cand, unsigned NumArgs, bool TakingCandidateAddress)
Generates a 'note' diagnostic for an overload candidate.
ExprResult CreateBuiltinArraySubscriptExpr(Expr *Base, SourceLocation LLoc, Expr *Idx, SourceLocation RLoc)
QualType getLValueReferenceType(QualType T, bool SpelledAsLValue=true) const
Return the uniqued reference to the type for an lvalue reference to the specified type...
RefQualifierKind getRefQualifier() const
Retrieve the ref-qualifier associated with this method.
bool hasErrorOccurred() const
Determine whether any SFINAE errors have been trapped.
QualType getPointeeType() const
static void CompleteNonViableCandidate(Sema &S, OverloadCandidate *Cand, ArrayRef< Expr * > Args)
CompleteNonViableCandidate - Normally, overload resolution only computes up to the first...
The base class of the type hierarchy.
bool isDependentContext() const
Determines whether this context is dependent on a template parameter.
unsigned IncompatibleObjC
IncompatibleObjC - Whether this is an Objective-C conversion that we should warn about (if we actuall...
unsigned getCVRQualifiers() const
Retrieve the set of CVR (const-volatile-restrict) qualifiers applied to this type.
QualType getRecordType(const RecordDecl *Decl) const
void MarkDeclRefReferenced(DeclRefExpr *E)
Perform reference-marking and odr-use handling for a DeclRefExpr.
NamespaceDecl - Represent a C++ namespace.
Template argument deduction produced inconsistent deduced values for the given template parameter...
SourceLocation getLocForEndOfToken(SourceLocation Loc, unsigned Offset=0)
Calls Lexer::getLocForEndOfToken()
static ExprValueKind getValueKindForType(QualType T)
getValueKindForType - Given a formal return or parameter type, give its value kind.
Ambiguous candidates found.
bool isBooleanType() const
bool compatiblyIncludes(Qualifiers other) const
Determines if these qualifiers compatibly include another set.
Conversions between compatible types in C99.
bool isBlockPointerType() const
static bool CheckConvertedConstantConversions(Sema &S, StandardConversionSequence &SCS)
Check that the specified conversion is permitted in a converted constant expression, according to C++11 [expr.const]p3.
bool inferCUDATargetForImplicitSpecialMember(CXXRecordDecl *ClassDecl, CXXSpecialMember CSM, CXXMethodDecl *MemberDecl, bool ConstRHS, bool Diagnose)
Given a implicit special member, infer its CUDA target from the calls it needs to make to underlying ...
bool IgnoreObjectArgument
IgnoreObjectArgument - True to indicate that the first argument's conversion, which for this function...
Partial ordering of function templates for a call to a conversion function.
unsigned DirectBinding
DirectBinding - True when this is a reference binding that is a direct binding (C++ [dcl...
Represents a C++ constructor within a class.
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)
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...
uint64_t getTypeSize(QualType T) const
Return the size of the specified (complete) type T, in bits.
ObjCMethodDecl - Represents an instance or class method declaration.
QualType getThisType(ASTContext &C) const
Returns the type of the this pointer.
NamedDecl * getUnderlyingDecl()
Looks through UsingDecls and ObjCCompatibleAliasDecls for the underlying named decl.
QualType ExtractUnqualifiedFunctionType(QualType PossiblyAFunctionType)
bool HadMultipleCandidates
HadMultipleCandidates - When this is true, it means that the conversion function was resolved from an...
Removal of noreturn from a type (Clang)
Like System, but searched after the system directories.
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.
ExprResult PerformImplicitConversion(Expr *From, QualType ToType, AssignmentAction Action, bool AllowExplicit=false)
PerformImplicitConversion - Perform an implicit conversion of the expression From to the type ToType...
ExprResult CreateOverloadedBinOp(SourceLocation OpLoc, BinaryOperatorKind Opc, const UnresolvedSetImpl &Fns, Expr *LHS, Expr *RHS)
Create a binary operation that may resolve to an overloaded operator.
unsigned getNumParams() const
Expr * FixOverloadedFunctionReference(Expr *E, DeclAccessPair FoundDecl, FunctionDecl *Fn)
FixOverloadedFunctionReference - E is an expression that refers to a C++ overloaded function (possibl...
RecordDecl - Represents a struct/union/class.
std::string getFullModuleName() const
Retrieve the full name of this module, including the path from its top-level module.
bool 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.
class LLVM_ALIGNAS(8) DependentTemplateSpecializationType const IdentifierInfo * Name
Represents a template specialization type whose template cannot be resolved, e.g. ...
void AddArgumentDependentLookupCandidates(DeclarationName Name, SourceLocation Loc, ArrayRef< Expr * > Args, TemplateArgumentListInfo *ExplicitTemplateArgs, OverloadCandidateSet &CandidateSet, bool PartialOverloading=false)
Add function candidates found via argument-dependent lookup to the set of overloading candidates...
const TemplateArgumentList * getTemplateSpecializationArgs() const
Retrieve the template arguments used to produce this function template specialization from the primar...
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
A C++ nested-name-specifier augmented with source location information.
llvm::mapped_iterator< decltype(Decls)::iterator, select_second > iterator
OverloadCandidate & addCandidate(unsigned NumConversions=0)
Add a new candidate with NumConversions conversion sequence slots to the overload set...
static bool diagnoseNoViableConversion(Sema &SemaRef, SourceLocation Loc, Expr *&From, Sema::ContextualImplicitConverter &Converter, QualType T, bool HadMultipleCandidates, UnresolvedSetImpl &ExplicitConversions)
ImplicitConversionSequence * Conversions
Conversions - The conversion sequences used to convert the function arguments to the function paramet...
unsigned BindsToFunctionLvalue
Whether we're binding to a function lvalue.
BadConversionSequence Bad
When ConversionKind == BadConversion, provides the details of the bad conversion. ...
bool IsDerivedFrom(SourceLocation Loc, QualType Derived, QualType Base)
Determine whether the type Derived is a C++ class that is derived from the type Base.
bool isReferenceType() const
QualType getReturnType() const
FieldDecl - An instance of this class is created by Sema::ActOnField to represent a member of a struc...
FunctionDecl * getTemplatedDecl() const
Get the underlying function declaration of the template.
bool isAnyPointerType() const
Expr * getBase()
Retrieve the base object of this member expressions, e.g., the x in x.m.
Identity conversion (no conversion)
The arguments included an overloaded function name that could not be resolved to a suitable function...
void AddBuiltinOperatorCandidates(OverloadedOperatorKind Op, SourceLocation OpLoc, ArrayRef< Expr * > Args, OverloadCandidateSet &CandidateSet)
AddBuiltinOperatorCandidates - Add the appropriate built-in operator overloads to the candidate set (...
void setNumArgs(const ASTContext &C, unsigned NumArgs)
setNumArgs - This changes the number of arguments present in this call.
ConversionSet & conversions()
bool isPure() const
Whether this virtual function is pure, i.e.
bool buildOverloadedCallSet(Scope *S, Expr *Fn, UnresolvedLookupExpr *ULE, MultiExprArg Args, SourceLocation RParenLoc, OverloadCandidateSet *CandidateSet, ExprResult *Result)
Constructs and populates an OverloadedCandidateSet from the given function.
QualType getToType() const
Floating point conversions (C++ 4.8)
virtual SemaDiagnosticBuilder diagnoseConversion(Sema &S, SourceLocation Loc, QualType T, QualType ConvTy)=0
Emits a diagnostic when we picked a conversion function (for cases when we are not allowed to pick a ...
unsigned getCVRQualifiers() const
The iterator over UnresolvedSets.
bool hasSameType(QualType T1, QualType T2) const
Determine whether the given types T1 and T2 are equivalent.
static DeclRefExpr * Create(const ASTContext &Context, NestedNameSpecifierLoc QualifierLoc, SourceLocation TemplateKWLoc, ValueDecl *D, bool RefersToEnclosingVariableOrCapture, SourceLocation NameLoc, QualType T, ExprValueKind VK, NamedDecl *FoundD=nullptr, const TemplateArgumentListInfo *TemplateArgs=nullptr)
ExprResult PerformContextuallyConvertToObjCPointer(Expr *From)
PerformContextuallyConvertToObjCPointer - Perform a contextual conversion of the expression From to a...
bool match(QualType T) override
Match an integral or (possibly scoped) enumeration type.
bool isMoveConstructor(unsigned &TypeQuals) const
Determine whether this constructor is a move constructor (C++11 [class.copy]p3), which can be used to...
const RecordType * getAsUnionType() const
NOTE: getAs*ArrayType are methods on ASTContext.
static bool DiagnoseTwoPhaseOperatorLookup(Sema &SemaRef, OverloadedOperatorKind Op, SourceLocation OpLoc, ArrayRef< Expr * > Args)
Attempt to recover from ill-formed use of a non-dependent operator in a template, where the non-depen...
Represents a C++ member access expression for which lookup produced a set of overloaded functions...
Ref_Incompatible - The two types are incompatible, so direct reference binding is not possible...
ExprResult CreateOverloadedUnaryOp(SourceLocation OpLoc, UnaryOperatorKind Opc, const UnresolvedSetImpl &Fns, Expr *input)
Create a unary operation that may resolve to an overloaded operator.
void AddConversionCandidate(CXXConversionDecl *Conversion, DeclAccessPair FoundDecl, CXXRecordDecl *ActingContext, Expr *From, QualType ToType, OverloadCandidateSet &CandidateSet, bool AllowObjCConversionOnExplicit)
AddConversionCandidate - Add a C++ conversion function as a candidate in the candidate set (C++ [over...
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...
bool DiagnoseUseOfDecl(NamedDecl *D, SourceLocation Loc, const ObjCInterfaceDecl *UnknownObjCClass=nullptr, bool ObjCPropertyAccess=false)
Determine whether the use of this declaration is valid, and emit any corresponding diagnostics...
static DeclAccessPair make(NamedDecl *D, AccessSpecifier AS)
const LangOptions & getLangOpts() const
void setCXXOperatorNameRange(SourceRange R)
setCXXOperatorNameRange - Sets the range of the operator name (without the operator keyword)...
TemplateSpecCandidateSet - A set of generalized overload candidates, used in template specializations...
ReferenceCompareResult CompareReferenceRelationship(SourceLocation Loc, QualType T1, QualType T2, bool &DerivedToBase, bool &ObjCConversion, bool &ObjCLifetimeConversion)
CompareReferenceRelationship - Compare the two types T1 and T2 to determine whether they are referenc...
Succeeded, but refers to a deleted function.
APValue Val
Val - This is the value the expression can be folded to.
A convenient class for passing around template argument information.
CanProxy< U > getAs() const
Retrieve a canonical type pointer with a different static type, upcasting or downcasting as needed...
Ref_Compatible - The two types are reference-compatible and have equivalent qualifiers (cv1 == cv2)...
QualType getReturnType() const
unsigned getMinRequiredArguments() const
getMinRequiredArguments - Returns the minimum number of arguments needed to call this function...
const CXXRecordDecl * getParent() const
Returns the parent of this method declaration, which is the class in which this method is defined...
bool isDefaulted() const
Whether this function is defaulted per C++0x.
unsigned QualificationIncludesObjCLifetime
Whether the qualification conversion involves a change in the Objective-C lifetime (for automatic ref...
field_range fields() const
bool 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.
const ArrayType * getAsArrayType(QualType T) const
Type Query functions.
static bool isRecordType(QualType T)
static bool IsAcceptableNonMemberOperatorCandidate(ASTContext &Context, FunctionDecl *Fn, ArrayRef< Expr * > Args)
IsAcceptableNonMemberOperatorCandidate - Determine whether Fn is an acceptable non-member overloaded ...
A builtin binary operation expression such as "x + y" or "x <= y".
Substitution of the deduced template argument values resulted in an error.
static void AddOverloadedCallCandidate(Sema &S, DeclAccessPair FoundDecl, TemplateArgumentListInfo *ExplicitTemplateArgs, ArrayRef< Expr * > Args, OverloadCandidateSet &CandidateSet, bool PartialOverloading, bool KnownValid)
Add a single candidate to the overload set.
This candidate function was not viable because an enable_if attribute disabled it.
bool isValueDependent() const
isValueDependent - Determines whether this expression is value-dependent (C++ [temp.dep.constexpr]).
A set of unresolved declarations.
RecordDecl * getDecl() const
ImplicitConversionKind Second
Second - The second conversion can be an integral promotion, floating point promotion, integral conversion, floating point conversion, floating-integral conversion, pointer conversion, pointer-to-member conversion, or boolean conversion.
SourceLocation getTemplateKeywordLoc() const
Retrieve the location of the template keyword preceding this name, if any.
bool requiresADL() const
True if this declaration should be extended by argument-dependent lookup.
Template argument deduction exceeded the maximum template instantiation depth (which has already been...
static ImplicitConversionSequence TryListConversion(Sema &S, InitListExpr *From, QualType ToType, bool SuppressUserConversions, bool InOverloadResolution, bool AllowObjCWritebackConversion)
TryListConversion - Try to copy-initialize a value of type ToType from the initializer list From...
bool isUnsignedIntegerType() const
Return true if this is an integer type that is unsigned, according to C99 6.2.5p6 [which returns true...
A narrowing conversion, because a constant expression got narrowed.
FunctionDecl * ResolveAddressOfOverloadedFunction(Expr *AddressOfExpr, QualType TargetType, bool Complain, DeclAccessPair &Found, bool *pHadMultipleCandidates=nullptr)
ResolveAddressOfOverloadedFunction - Try to resolve the address of an overloaded function (C++ [over...
ExprResult BuildOverloadedCallExpr(Scope *S, Expr *Fn, UnresolvedLookupExpr *ULE, SourceLocation LParenLoc, MultiExprArg Args, SourceLocation RParenLoc, Expr *ExecConfig, bool AllowTypoCorrection=true, bool CalleesAddressIsTaken=false)
BuildOverloadedCallExpr - Given the call expression that calls Fn (which eventually refers to the dec...
unsigned IsLvalueReference
Whether this is an lvalue reference binding (otherwise, it's an rvalue reference binding).
Expr * IgnoreParenCasts() LLVM_READONLY
IgnoreParenCasts - Ignore parentheses and casts.
bool isVariadic() const
Whether this function is variadic.
NarrowingKind
NarrowingKind - The kind of narrowing conversion being performed by a standard conversion sequence ac...
Scope - A scope is a transient data structure that is used while parsing the program.
void Destroy()
Free any memory associated with this deduction failure.
Qualification conversions (C++ 4.4)
static bool isBooleanType(QualType Ty)
Represents a C++ nested-name-specifier or a global scope specifier.
TypeClass getTypeClass() const
void diagnoseEquivalentInternalLinkageDeclarations(SourceLocation Loc, const NamedDecl *D, ArrayRef< const NamedDecl * > Equiv)
bool isIncompleteType(NamedDecl **Def=nullptr) const
Types are partitioned into 3 broad categories (C99 6.2.5p1): object types, function types...
void setFromType(QualType T)
static bool checkAddressOfFunctionIsAvailable(Sema &S, const FunctionDecl *FD, bool Complain, bool InOverloadResolution, SourceLocation Loc)
Returns true if we can take the address of the function.
NarrowingKind getNarrowingKind(ASTContext &Context, const Expr *Converted, APValue &ConstantValue, QualType &ConstantType) const
Check if this standard conversion sequence represents a narrowing conversion, according to C++11 [dcl...
static IntegerLiteral * Create(const ASTContext &C, const llvm::APInt &V, QualType type, SourceLocation l)
Returns a new integer literal with value 'V' and type 'type'.
ExprResult DefaultFunctionArrayLvalueConversion(Expr *E, bool Diagnose=true)
static ImplicitConversionSequence TryContextuallyConvertToObjCPointer(Sema &S, Expr *From)
TryContextuallyConvertToObjCPointer - Attempt to contextually convert the expression From to an Objec...
AssignConvertType CheckSingleAssignmentConstraints(QualType LHSType, ExprResult &RHS, bool Diagnose=true, bool DiagnoseCFAudited=false, bool ConvertRHS=true)
An ordinary object is located at an address in memory.
virtual SemaDiagnosticBuilder diagnoseIncomplete(Sema &S, SourceLocation Loc, QualType T)=0
Emits a diagnostic when the expression has incomplete class type.
FunctionTemplateDecl * getDescribedFunctionTemplate() const
Retrieves the function template that is described by this function declaration.
The number of conversion kinds.
ForRangeStatus BuildForRangeBeginEndCall(SourceLocation Loc, SourceLocation RangeLoc, const DeclarationNameInfo &NameInfo, LookupResult &MemberLookup, OverloadCandidateSet *CandidateSet, Expr *Range, ExprResult *CallExpr)
Build a call to 'begin' or 'end' for a C++11 for-range statement.
TemplateParameter getTemplateParameter()
Retrieve the template parameter this deduction failure refers to, if any.
Represents an ObjC class declaration.
ExprResult BuildMemberReferenceExpr(Expr *Base, QualType BaseType, SourceLocation OpLoc, bool IsArrow, CXXScopeSpec &SS, SourceLocation TemplateKWLoc, NamedDecl *FirstQualifierInScope, const DeclarationNameInfo &NameInfo, const TemplateArgumentListInfo *TemplateArgs, const Scope *S, ActOnMemberAccessExtraArgs *ExtraArgs=nullptr)
bool isExtVectorType() const
static ExprResult finishContextualImplicitConversion(Sema &SemaRef, SourceLocation Loc, Expr *From, Sema::ContextualImplicitConverter &Converter)
ImplicitConversionKind Third
Third - The third conversion can be a qualification conversion.
static ExprResult BuildRecoveryCallExpr(Sema &SemaRef, Scope *S, Expr *Fn, UnresolvedLookupExpr *ULE, SourceLocation LParenLoc, MutableArrayRef< Expr * > Args, SourceLocation RParenLoc, bool EmptyLookup, bool AllowTypoCorrection)
Attempts to recover from a call where no functions were found.
detail::InMemoryDirectory::const_iterator I
ExprResult BuildDeclarationNameExpr(const CXXScopeSpec &SS, LookupResult &R, bool NeedsADL, bool AcceptInvalidDecl=false)
Complex <-> Real conversion.
bool Viable
Viable - True to indicate that this overload candidate is viable.
FunctionDecl * resolveAddressOfOnlyViableOverloadCandidate(Expr *E, DeclAccessPair &FoundResult)
Given an expression that refers to an overloaded function, try to resolve that function to a single f...
static Classification makeSimpleLValue()
Create a simple, modifiably lvalue.
CanQualType UnsignedCharTy
Integral promotions (C++ 4.5)
This conversion function template specialization candidate is not viable because the final conversion...
bool IsStringLiteralToNonConstPointerConversion(Expr *From, QualType ToType)
Helper function to determine whether this is the (deprecated) C++ conversion from a string literal to...
bool isCXX11ConstantExpr(const ASTContext &Ctx, APValue *Result=nullptr, SourceLocation *Loc=nullptr) const
isCXX11ConstantExpr - Return true if this expression is a constant expression in C++11.
This object can be modified without requiring retains or releases.
const UnresolvedSetImpl & asUnresolvedSet() const
AccessResult CheckUnresolvedMemberAccess(UnresolvedMemberExpr *E, DeclAccessPair FoundDecl)
Perform access-control checking on a previously-unresolved member access which has now been resolved ...
param_iterator param_begin()
Represents the this expression in C++.
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)
CXXSpecialMember
Kinds of C++ special members.
OverloadFixItKind Kind
The type of fix applied.
QualType getValueType() const
Gets the type contained by this atomic type, i.e.
DeductionFailureInfo DeductionFailure
Template argument deduction info.
ExtInfo getExtInfo() const
static void NoteAmbiguousUserConversions(Sema &S, SourceLocation OpLoc, OverloadCandidate *Cand)
Sema - This implements semantic analysis and AST building for C.
bool isBetterOverloadCandidate(Sema &S, const OverloadCandidate &Cand1, const OverloadCandidate &Cand2, SourceLocation Loc, bool UserDefinedConversion=false)
isBetterOverloadCandidate - Determines whether the first overload candidate is a better candidate tha...
QualType getParamType(unsigned i) const
Represents a prototype with parameter type info, e.g.
static ExprResult CreateFunctionRefExpr(Sema &S, FunctionDecl *Fn, NamedDecl *FoundDecl, bool HadMultipleCandidates, SourceLocation Loc=SourceLocation(), const DeclarationNameLoc &LocInfo=DeclarationNameLoc())
A convenience routine for creating a decayed reference to a function.
CXXMethodDecl * getMethodDecl() const
Retrieves the declaration of the called method.
ExprResult CreateBuiltinBinOp(SourceLocation OpLoc, BinaryOperatorKind Opc, Expr *LHSExpr, Expr *RHSExpr)
CreateBuiltinBinOp - Creates a new built-in binary operation with operator Opc at location TokLoc...
void erase(NamedDecl *D)
Removes any data associated with a given decl.
Transparent Union Conversions.
bool isStdInitializerList(QualType Ty, QualType *Element)
Tests whether Ty is an instance of std::initializer_list and, if it is and Element is not NULL...
bool EvaluateAsRValue(EvalResult &Result, const ASTContext &Ctx) const
EvaluateAsRValue - Return true if this is a constant which we can fold to an rvalue using any crazy t...
CastKind
CastKind - The kind of operation required for a conversion.
The return type of classify().
param_type_iterator param_type_begin() const
static ImplicitCastExpr * Create(const ASTContext &Context, QualType T, CastKind Kind, Expr *Operand, const CXXCastPath *BasePath, ExprValueKind Cat)
void AddMemberOperatorCandidates(OverloadedOperatorKind Op, SourceLocation OpLoc, ArrayRef< Expr * > Args, OverloadCandidateSet &CandidateSet, SourceRange OpRange=SourceRange())
Add overload candidates for overloaded operators that are member functions.
DeclarationNameTable DeclarationNames
Template argument deduction did not deduce a value for every template parameter.
bool CheckPointerConversion(Expr *From, QualType ToType, CastKind &Kind, CXXCastPath &BasePath, bool IgnoreBaseAccess, bool Diagnose=true)
CheckPointerConversion - Check the pointer conversion from the expression From to the type ToType...
virtual SemaDiagnosticBuilder diagnoseExplicitConv(Sema &S, SourceLocation Loc, QualType T, QualType ConvTy)=0
Emits a diagnostic when the only matching conversion function is explicit.
NamedDecl * getDecl() const
static const char * GetImplicitConversionName(ImplicitConversionKind Kind)
GetImplicitConversionName - Return the name of this kind of implicit conversion.
This conversion candidate was not considered because it duplicates the work of a trivial or derived-t...
static void NoteBuiltinOperatorCandidate(Sema &S, StringRef Opc, SourceLocation OpLoc, OverloadCandidate *Cand)
bool isNewCandidate(Decl *F)
Determine when this overload candidate will be new to the overload set.
A narrowing conversion by virtue of the source and destination types.
StandardConversionSequence FinalConversion
FinalConversion - For a conversion function (where Function is a CXXConversionDecl), the standard conversion that occurs after the call to the overload candidate to convert the result of calling the conversion function to the required type.
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)
unsigned getTypeQualifiers() const
void dump() const
dump - Print this user-defined conversion sequence to standard error.
ExprResult BuildResolvedCallExpr(Expr *Fn, NamedDecl *NDecl, SourceLocation LParenLoc, ArrayRef< Expr * > Arg, SourceLocation RParenLoc, Expr *Config=nullptr, bool IsExecConfig=false)
BuildResolvedCallExpr - Build a call to a resolved expression, i.e.
Expr - This represents one expression.
bool DiagnoseEmptyLookup(Scope *S, CXXScopeSpec &SS, LookupResult &R, std::unique_ptr< CorrectionCandidateCallback > CCC, TemplateArgumentListInfo *ExplicitTemplateArgs=nullptr, ArrayRef< Expr * > Args=None, TypoExpr **Out=nullptr)
Diagnose an empty lookup.
DeclarationName getLookupName() const
Gets the name to look up.
static ImplicitConversionSequence TryObjectArgumentInitialization(Sema &S, SourceLocation Loc, QualType FromType, Expr::Classification FromClassification, CXXMethodDecl *Method, CXXRecordDecl *ActingContext)
TryObjectArgumentInitialization - Try to initialize the object parameter of the given member function...
Show just the "best" overload candidates.
Represents an ambiguous user-defined conversion sequence.
ExprValueKind
The categorization of expression values, currently following the C++11 scheme.
bool performsVirtualDispatch(const LangOptions &LO) const
Returns true if virtual dispatch is performed.
Expr * stripARCUnbridgedCast(Expr *e)
stripARCUnbridgedCast - Given an expression of ARCUnbridgedCast type, remove the placeholder cast...
Qualifiers getQualifiers() const
Retrieve all qualifiers.
unsigned getNumArgs() const
bool isAnyComplexType() const
bool isDeletedAsWritten() const
void takeSFINAEDiagnostic(PartialDiagnosticAt &PD)
Take ownership of the SFINAE diagnostic.
bool isBeforeInTranslationUnit(SourceLocation LHS, SourceLocation RHS) const
Determines the order of 2 source locations in the translation unit.
When performing template argument deduction for a function template, there were too many call argumen...
NestedNameSpecifierLoc getQualifierLoc() const
Fetches the nested-name qualifier with source-location information, if one was given.
bool isObjCClassType() const
decls_iterator decls_end() const
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...
bool isInitListConstructor(const CXXConstructorDecl *Ctor)
Determine whether Ctor is an initializer-list constructor, as defined in [dcl.init.list]p2.
CXXConstructorDecl * CopyConstructor
CopyConstructor - The copy constructor that is used to perform this conversion, when the conversion i...
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.
bool resolveAndFixAddressOfOnlyViableOverloadCandidate(ExprResult &SrcExpr)
Given an overloaded function, tries to turn it into a non-overloaded function reference using resolve...
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)
ExprResult BuildTemplateIdExpr(const CXXScopeSpec &SS, SourceLocation TemplateKWLoc, LookupResult &R, bool RequiresADL, const TemplateArgumentListInfo *TemplateArgs)
FunctionDecl * ResolveSingleFunctionTemplateSpecialization(OverloadExpr *ovl, bool Complain=false, DeclAccessPair *Found=nullptr)
Given an expression that refers to an overloaded function, try to resolve that overloaded function ex...
bool isSameOrCompatibleFunctionType(CanQualType Param, CanQualType Arg)
Compare types for equality with respect to possibly compatible function types (noreturn adjustment...
CanQualType UnsignedInt128Ty
Specifies that a value-dependent expression of integral or dependent type should be considered a null...
This conversion candidate was not considered because it is an illegal instantiation of a constructor ...
bool TryToFixBadConversion(unsigned Idx, Sema &S)
QualType getFromType() const
static void collectViableConversionCandidates(Sema &SemaRef, Expr *From, QualType ToType, UnresolvedSetImpl &ViableConversions, OverloadCandidateSet &CandidateSet)
CXXConversionDecl * Surrogate
Surrogate - The conversion function for which this candidate is a surrogate, but only if IsSurrogate ...
UserDefinedConversionSequence - Represents a user-defined conversion sequence (C++ 13...
bool isScoped() const
Returns true if this is a C++11 scoped enumeration.
This candidate was not viable because its address could not be taken.
void NoteCandidates(Sema &S, OverloadCandidateDisplayKind OCD, ArrayRef< Expr * > Args, StringRef Opc="", SourceLocation Loc=SourceLocation())
PrintOverloadCandidates - When overload resolution fails, prints diagnostic messages containing the c...
void NoteDeductionFailure(Sema &S, bool ForTakingAddress)
Diagnose a template argument deduction failure.
static bool TooManyArguments(size_t NumParams, size_t NumArgs, bool PartialOverloading=false)
To be used for checking whether the arguments being passed to function exceeds the number of paramete...
bool isDependentType() const
Whether this type is a dependent type, meaning that its definition somehow depends on a template para...
StandardConversionSequence Standard
When ConversionKind == StandardConversion, provides the details of the standard conversion sequence...
bool ResolveAndFixSingleFunctionTemplateSpecialization(ExprResult &SrcExpr, bool DoFunctionPointerConverion=false, bool Complain=false, SourceRange OpRangeForComplaining=SourceRange(), QualType DestTypeForComplaining=QualType(), unsigned DiagIDForComplaining=0)
DeclContext * getParent()
getParent - Returns the containing DeclContext.
bool isAtLeastAsQualifiedAs(CanQual< T > Other) const
Determines whether this canonical type is at least as qualified as the Other canonical type...
void AddFunctionCandidates(const UnresolvedSetImpl &Functions, ArrayRef< Expr * > Args, OverloadCandidateSet &CandidateSet, TemplateArgumentListInfo *ExplicitTemplateArgs=nullptr, bool SuppressUserConversions=false, bool PartialOverloading=false)
Add all of the function declarations in the given function set to the overload candidate set...
QualType getObjCIdType() const
Represents the Objective-CC id type.
void AddTemplateOverloadCandidate(FunctionTemplateDecl *FunctionTemplate, DeclAccessPair FoundDecl, TemplateArgumentListInfo *ExplicitTemplateArgs, ArrayRef< Expr * > Args, OverloadCandidateSet &CandidateSet, bool SuppressUserConversions=false, bool PartialOverloading=false)
Add a C++ function template specialization as a candidate in the candidate set, using template argume...
static const FunctionProtoType * tryGetFunctionProtoType(QualType FromType)
Attempts to get the FunctionProtoType from a Type.
virtual SemaDiagnosticBuilder noteExplicitConv(Sema &S, CXXConversionDecl *Conv, QualType ConvTy)=0
Emits a note for the explicit conversion function.
UnaryOperator - This represents the unary-expression's (except sizeof and alignof), the postinc/postdec operators from postfix-expression, and various extensions.
SmallVector< ActiveTemplateInstantiation, 16 > ActiveTemplateInstantiations
List of active template instantiations.
bool DeduceReturnType(FunctionDecl *FD, SourceLocation Loc, bool Diagnose=true)
ExprResult BuildPossibleImplicitMemberExpr(const CXXScopeSpec &SS, SourceLocation TemplateKWLoc, LookupResult &R, const TemplateArgumentListInfo *TemplateArgs, const Scope *S)
Builds an expression which might be an implicit member expression.
An lvalue reference type, per C++11 [dcl.ref].
DeclarationName getDeclName() const
getDeclName - Get the actual, stored name of the declaration, which may be a special name...
TemplateTemplateParmDecl - Declares a template template parameter, e.g., "T" in.
DiagnosticsEngine & getDiagnostics() const
class LLVM_ALIGNAS(8) TemplateSpecializationType unsigned NumArgs
Represents a type template specialization; the template must be a class template, a type alias templa...
static bool CheckArityMismatch(Sema &S, OverloadCandidate *Cand, unsigned NumArgs)
Additional arity mismatch diagnosis specific to a function overload candidates.
After substituting deduced template arguments, a dependent parameter type did not match the correspon...
Represents a C++ conversion function within a class.
QualType getCVRQualifiedType(QualType T, unsigned CVR) const
Return a type with additional const, volatile, or restrict qualifiers.
The result type of a method or function.
bool isExplicit() const
Whether this is an explicit conversion operator (C++11 and later).
bool isObjectType() const
Determine whether this type is an object type.
static ImplicitConversionSequence::CompareKind CompareImplicitConversionSequences(Sema &S, SourceLocation Loc, const ImplicitConversionSequence &ICS1, const ImplicitConversionSequence &ICS2)
CompareImplicitConversionSequences - Compare two implicit conversion sequences to determine whether o...
A narrowing conversion, because a non-constant-expression variable might have got narrowed...
Lvalue-to-rvalue conversion (C++ 4.1)
decls_iterator decls_begin() const
static bool isBetterReferenceBindingKind(const StandardConversionSequence &SCS1, const StandardConversionSequence &SCS2)
Determine whether one of the given reference bindings is better than the other based on what kind of ...
ArrayRef< ParmVarDecl * > parameters() const
unsigned ObjCLifetimeConversionBinding
Whether this binds a reference to an object with a different Objective-C lifetime qualifier...
static bool isNullPointerConstantForConversion(Expr *Expr, bool InOverloadResolution, ASTContext &Context)
unsigned NumConversions
NumConversions - The number of elements in the Conversions array.
bool isIdentityConversion() const
QualType getFromType() const
OpaqueValueExpr - An expression referring to an opaque object of a fixed type and value class...
static std::unique_ptr< CorrectionCandidateCallback > MakeValidator(Sema &SemaRef, MemberExpr *ME, size_t NumArgs, bool HasTemplateArgs, bool AllowTypoCorrection)
Integral conversions (C++ 4.7)
Complex promotions (Clang extension)
ExprResult MaybeBindToTemporary(Expr *E)
MaybeBindToTemporary - If the passed in expression has a record type with a non-trivial destructor...
Assigning into this object requires the old value to be released and the new value to be retained...
A reference to an overloaded function set, either an UnresolvedLookupExpr or an UnresolvedMemberExpr...
ImplicitConversionSequence - Represents an implicit conversion sequence, which may be a standard conv...
bool isIntegralOrEnumerationType() const
Determine whether this type is an integral or enumeration type.
static bool checkAddressOfCandidateIsAvailable(Sema &S, const FunctionDecl *FD)
bool isInitialized() const
Determines whether this conversion sequence has been initialized.
bool isVolatileQualified() const
OverloadCandidate - A single candidate in an overload set (C++ 13.3).
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...
const TemplateArgument * iterator
QualType getElementType() const
Interfaces are the core concept in Objective-C for object oriented design.
virtual SemaDiagnosticBuilder noteAmbiguous(Sema &S, CXXConversionDecl *Conv, QualType ConvTy)=0
Emits a note for one of the candidate conversions.
bool IsNoReturnConversion(QualType FromType, QualType ToType, QualType &ResultTy)
Determine whether the conversion from FromType to ToType is a valid conversion that strips "noreturn"...
bool isValid() const
Return true if this is a valid SourceLocation object.
OverloadedOperatorKind getCXXOverloadedOperator() const
getCXXOverloadedOperator - If this name is the name of an overloadable operator in C++ (e...
static ImplicitConversionSequence::CompareKind CompareStandardConversionSequences(Sema &S, SourceLocation Loc, const StandardConversionSequence &SCS1, const StandardConversionSequence &SCS2)
CompareStandardConversionSequences - Compare two standard conversion sequences to determine whether o...
CUDAFunctionTarget IdentifyCUDATarget(const FunctionDecl *D)
IdentifyCUDATarget - Determine the CUDA compilation target for this function.
A call to a literal operator (C++11 [over.literal]) written as a user-defined literal (C++11 [lit...
Template argument deduction failed due to inconsistent cv-qualifiers on a template parameter type tha...
Represents a call to a member function that may be written either with member call syntax (e...
ASTContext & getASTContext() const
A vector splat from an arithmetic type.
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...
void AddBuiltinCandidate(QualType ResultTy, QualType *ParamTys, ArrayRef< Expr * > Args, OverloadCandidateSet &CandidateSet, bool IsAssignmentOperator=false, unsigned NumContextualBoolArguments=0)
AddBuiltinCandidate - Add a candidate for a built-in operator.
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)
Expr * Expression
The expression which caused a deduction failure.
The declaration was invalid; do nothing.
bool isIntegralType(const ASTContext &Ctx) const
Determine whether this type is an integral type.
Ref_Compatible_With_Added_Qualification - The two types are reference-compatible with added qualifica...
static bool IsVectorConversion(Sema &S, QualType FromType, QualType ToType, ImplicitConversionKind &ICK)
Determine whether the conversion from FromType to ToType is a valid vector conversion.
void dump() const
dump - Print this implicit conversion sequence to standard error.
bool isIntegerConstantExpr(llvm::APSInt &Result, const ASTContext &Ctx, SourceLocation *Loc=nullptr, bool isEvaluated=true) const
isIntegerConstantExpr - Return true if this expression is a valid integer constant expression...
static bool checkArgPlaceholdersForOverload(Sema &S, MultiExprArg Args, UnbridgedCastsSet &unbridged)
checkArgPlaceholdersForOverload - Check a set of call operands for placeholders.
Specifies that a value-dependent expression should be considered to never be a null pointer constant...
void addDecl(NamedDecl *D)
TemplateDeductionResult DeduceTemplateArguments(ClassTemplatePartialSpecializationDecl *Partial, const TemplateArgumentList &TemplateArgs, sema::TemplateDeductionInfo &Info)
Perform template argument deduction to determine whether the given template arguments match the given...
llvm::Optional< unsigned > getCallArgIndex()
Return the index of the call argument that this deduction failure refers to, if any.
bool isStdInitializerListElement() const
Whether the target is really a std::initializer_list, and the sequence only represents the worst elem...
bool CheckMemberPointerConversion(Expr *From, QualType ToType, CastKind &Kind, CXXCastPath &BasePath, bool IgnoreBaseAccess)
CheckMemberPointerConversion - Check the member pointer conversion from the expression From to the ty...
void setAsIdentityConversion()
StandardConversionSequence - Set the standard conversion sequence to the identity conversion...
Pointer conversions (C++ 4.10)
Lookup for candidates for a call using operator syntax.
ImplicitCastExpr - Allows us to explicitly represent implicit type conversions, which have no direct ...
std::pair< SourceLocation, PartialDiagnostic > PartialDiagnosticAt
A partial diagnostic along with the source location where this diagnostic occurs. ...
bool canBindObjCObjectType(QualType To, QualType From)
CandidateSetKind getKind() const
QualType getToType(unsigned Idx) const
SourceLocation getBegin() const
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)
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)
virtual SemaDiagnosticBuilder diagnoseNoMatch(Sema &S, SourceLocation Loc, QualType T)=0
Emits a diagnostic complaining that the expression does not have integral or enumeration type...
void HandleFunctionTypeMismatch(PartialDiagnostic &PDiag, QualType FromType, QualType ToType)
HandleFunctionTypeMismatch - Gives diagnostic information for differeing function types...
SourceLocation getLocStart() const LLVM_READONLY
CanQualType UnsignedLongLongTy
static bool checkPlaceholderForOverload(Sema &S, Expr *&E, UnbridgedCastsSet *unbridgedCasts=nullptr)
checkPlaceholderForOverload - Do any interesting placeholder-like preprocessing on the given expressi...
Conversions allowed in C, but not C++.
Array-to-pointer conversion (C++ 4.2)
void setConversionChecker(TypeComparisonFuncTy Foo)
Resets the default conversion checker method.
A non-depnedent component of the parameter did not match the corresponding component of the argument...
const ObjCInterfaceType * getInterfaceType() const
If this pointer points to an Objective C @interface type, gets the type for that interface.
PartialDiagnosticAt * getSFINAEDiagnostic()
Retrieve the diagnostic which caused this deduction failure, if any.
QualType getPointerType(QualType T) const
Return the uniqued reference to the type for a pointer to the specified type.
bool hasSFINAEDiagnostic() const
Is a SFINAE diagnostic available?
DeclarationName - The name of a declaration.
bool IsBlockPointerConversion(QualType FromType, QualType ToType, QualType &ConvertedType)
StandardConversionSequence Before
Represents the standard conversion that occurs before the actual user-defined conversion.
const Type * strip(QualType type)
Collect any qualifiers on the given type and return an unqualified type.
QualType getObjCObjectPointerType(QualType OIT) const
Return a ObjCObjectPointerType type for the given ObjCObjectType.
OverloadExpr * Expression
bool isLValue() const
isLValue - True if this expression is an "l-value" according to the rules of the current language...
static QualType AdoptQualifiers(ASTContext &Context, QualType T, Qualifiers Qs)
Adopt the given qualifiers for the given type.
Expression is a Null pointer constant built from a zero integer expression that is not a simple...
param_type_iterator param_type_end() const
A set of unresolved declarations.
std::string getAsString(ASTContext &Ctx, QualType Ty) const
void setInstantiationDependent(bool ID)
Set whether this expression is instantiation-dependent or not.
SourceLocation getLocStart() const LLVM_READONLY
size_t param_size() const
Requests that only viable candidates be shown.
detail::InMemoryDirectory::const_iterator E
FunctionDecl * Function
Function - The actual function that this candidate represents.
bool IsMemberPointerConversion(Expr *From, QualType FromType, QualType ToType, bool InOverloadResolution, QualType &ConvertedType)
IsMemberPointerConversion - Determines whether the conversion of the expression From, which has the (possibly adjusted) type FromType, can be converted to the type ToType via a member pointer conversion (C++ 4.11).
A pointer to member type per C++ 8.3.3 - Pointers to members.
static void dropPointerConversion(StandardConversionSequence &SCS)
dropPointerConversions - If the given standard conversion sequence involves any pointer conversions...
const FunctionType * adjustFunctionType(const FunctionType *Fn, FunctionType::ExtInfo EInfo)
Change the ExtInfo on a function type.
CanQualType getCanonicalType(QualType T) const
Return the canonical (structural) type corresponding to the specified potentially non-canonical type ...
bool isLValueReferenceType() const
DeclarationNameInfo - A collector data type for bundling together a DeclarationName and the correspnd...
unsigned getNumParams() const
bool isLambda() const
Determine whether this class describes a lambda function object.
void * Data
Opaque pointer containing additional data about this deduction failure.
bool isPointerConversionToBool() const
isPointerConversionToBool - Determines whether this conversion is a conversion of a pointer or pointe...
param_iterator param_end()
Defines the Diagnostic-related interfaces.
bool isRValueReferenceType() const
static void NoteSurrogateCandidate(Sema &S, OverloadCandidate *Cand)
QualType getPointeeType() const
Gets the type pointed to by this ObjC pointer.
QualType getNonReferenceType() const
If Type is a reference type (e.g., const int&), returns the type that the reference refers to ("const...
FunctionDecl * ConversionFunction
ConversionFunction - The function that will perform the user-defined conversion.
Represents a pointer to an Objective C object.
SourceLocation getMemberLoc() const
getMemberLoc - Return the location of the "member", in X->F, it is the location of 'F'...
Conversion only allowed in the C standard.
bool empty() const
Return true if no decls were found.
Not an overloaded operator.
QualType getLocalUnqualifiedType() const
Return this type with all of the instance-specific qualifiers removed, but without removing any quali...
ExprResult CreateOverloadedArraySubscriptExpr(SourceLocation LLoc, SourceLocation RLoc, Expr *Base, Expr *Idx)
void setHadMultipleCandidates(bool V=true)
Sets the flag telling whether this expression refers to a method that was resolved from an overloaded...
bool IsPointerConversion(Expr *From, QualType FromType, QualType ToType, bool InOverloadResolution, QualType &ConvertedType, bool &IncompatibleObjC)
IsPointerConversion - Determines whether the conversion of the expression From, which has the (possib...
A helper class that allows the use of isa/cast/dyncast to detect TagType objects of structs/unions/cl...
void setAllToTypes(QualType T)
Complex values, per C99 6.2.5p11.
QualType getPointerDiffType() const
Return the unique type for "ptrdiff_t" (C99 7.17) defined in <stddef.h>.
Expr * getUninstantiatedDefaultArg()
const T * getAs() const
Member-template getAs<specific type>'.
ExprResult BuildLiteralOperatorCall(LookupResult &R, DeclarationNameInfo &SuffixInfo, ArrayRef< Expr * > Args, SourceLocation LitEndLoc, TemplateArgumentListInfo *ExplicitTemplateArgs=nullptr)
BuildLiteralOperatorCall - Build a UserDefinedLiteral by creating a call to a literal operator descri...
PrintingPolicy getPrintingPolicy() const
Retrieve a suitable printing policy.
CUDAFunctionPreference IdentifyCUDAPreference(const FunctionDecl *Caller, const FunctionDecl *Callee)
Identifies relative preference of a given Caller/Callee combination, based on their host/device attri...
bool ConvertArgumentsForCall(CallExpr *Call, Expr *Fn, FunctionDecl *FDecl, const FunctionProtoType *Proto, ArrayRef< Expr * > Args, SourceLocation RParenLoc, bool ExecConfig=false)
ConvertArgumentsForCall - Converts the arguments specified in Args/NumArgs to the parameter types of ...
unsigned getTypeQuals() const
QualType getCanonicalType() const
TemplateArgumentList * take()
Take ownership of the deduced template argument list.
CanQualType UnsignedLongTy
unsigned getKindRank() const
Return a ranking of the implicit conversion sequence kind, where smaller ranks represent better conve...
bool areCompatibleVectorTypes(QualType FirstVec, QualType SecondVec)
Return true if the given vector types are of the same unqualified type or if they are equivalent to t...
unsigned BindsImplicitObjectArgumentWithoutRefQualifier
Whether this binds an implicit object argument to a non-static member function without a ref-qualifie...
unsigned char FailureKind
FailureKind - The reason why this candidate is not viable.
static bool FindConversionForRefInit(Sema &S, ImplicitConversionSequence &ICS, QualType DeclType, SourceLocation DeclLoc, Expr *Init, QualType T2, bool AllowRvalues, bool AllowExplicit)
Look for a user-defined conversion to an value reference-compatible with DeclType.
bool isObjCQualifiedIdType() const
bool isFunctionType() const
NestedNameSpecifier * getQualifier() const
DeclAccessPair FoundDecl
FoundDecl - The original declaration that was looked up / invented / otherwise found, together with its access.
bool isImplicitlyDeleted(FunctionDecl *FD)
Determine whether the given function is an implicitly-deleted special member function.
Base for LValueReferenceType and RValueReferenceType.
CanQualType BoundMemberTy
const DeclarationNameLoc & getInfo() const
CXXRecordDecl * getAsCXXRecordDecl() const
Retrieves the CXXRecordDecl that this type refers to, either because the type is a RecordType or beca...
AccessResult CheckMemberOperatorAccess(SourceLocation Loc, Expr *ObjectExpr, Expr *ArgExpr, DeclAccessPair FoundDecl)
Checks access to an overloaded member operator, including conversion operators.
unsigned getAddressSpace() const
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.
static bool isNonTrivialObjCLifetimeConversion(Qualifiers FromQuals, Qualifiers ToQuals)
Determine whether the lifetime conversion between the two given qualifiers sets is nontrivial...
void DiagnoseSentinelCalls(NamedDecl *D, SourceLocation Loc, ArrayRef< Expr * > Args)
DiagnoseSentinelCalls - This routine checks whether a call or message-send is to a declaration with t...
QualType getPointeeType() const
std::string getQualifiedNameAsString() const
bool checkAddressOfFunctionIsAvailable(const FunctionDecl *Function, bool Complain=false, SourceLocation Loc=SourceLocation())
Returns whether the given function's address can be taken or not, optionally emitting a diagnostic if...
bool LookupQualifiedName(LookupResult &R, DeclContext *LookupCtx, bool InUnqualifiedLookup=false)
Perform qualified name lookup into a given context.
TemplateArgumentList * getTemplateArgumentList()
Retrieve the template argument list associated with this deduction failure, if any.
ConversionFixItGenerator Fix
The FixIt hints which can be used to fix the Bad candidate.
AmbiguousConversionSequence Ambiguous
When ConversionKind == AmbiguousConversion, provides the details of the ambiguous conversion...
void setHadMultipleCandidates(bool V=true)
Sets the flag telling whether this expression refers to a function that was resolved from an overload...
A template argument list.
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.
void AddOverloadCandidate(FunctionDecl *Function, DeclAccessPair FoundDecl, ArrayRef< Expr * > Args, OverloadCandidateSet &CandidateSet, bool SuppressUserConversions=false, bool PartialOverloading=false, bool AllowExplicit=false)
AddOverloadCandidate - Adds the given function to the set of candidate functions, using the given fun...
QualType getUnqualifiedType() const
Retrieve the unqualified variant of the given type, removing as little sugar as possible.
Represents a C++ struct/union/class.
static ImplicitConversionSequence TryReferenceInit(Sema &S, Expr *Init, QualType DeclType, SourceLocation DeclLoc, bool SuppressUserConversions, bool AllowExplicit)
Compute an implicit conversion sequence for reference initialization.
Compatible - the types are compatible according to the standard.
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...
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.
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
static Qualifiers fromCVRMask(unsigned CVR)
ExprResult PerformObjectMemberConversion(Expr *From, NestedNameSpecifier *Qualifier, NamedDecl *FoundDecl, NamedDecl *Member)
Cast a base object to a member's actual type.
ExprResult CheckConvertedConstantExpression(Expr *From, QualType T, llvm::APSInt &Value, CCEKind CCE)
bool IsQualificationConversion(QualType FromType, QualType ToType, bool CStyle, bool &ObjCLifetimeConversion)
IsQualificationConversion - Determines whether the conversion from an rvalue of type FromType to ToTy...
void DiagnoseSelfMove(const Expr *LHSExpr, const Expr *RHSExpr, SourceLocation OpLoc)
Warn if a value is moved to itself.
A reference to a declared variable, function, enum, etc.
ExprValueKind getValueKind() const
getValueKind - The value kind that this expression produces.
void AddOverloadedCallCandidates(UnresolvedLookupExpr *ULE, ArrayRef< Expr * > Args, OverloadCandidateSet &CandidateSet, bool PartialOverloading=false)
Add the overload candidates named by callee and/or found by argument dependent lookup to the given ov...
The current expression and its subexpressions occur within an unevaluated operand (C++11 [expr]p7)...
QualType getElementType() const
bool hasQualifiers() const
Determine whether this type has any qualifiers.
Zero constant to event (OpenCL1.2 6.12.10)
unsigned CallArgIndex
The index of the function argument that caused a deduction failure.
SourceManager & SourceMgr
static OverloadedOperatorKind getOverloadedOperator(Opcode Opc)
Retrieve the overloaded operator kind that corresponds to the given binary opcode.
void NoteAllOverloadCandidates(Expr *E, QualType DestType=QualType(), bool TakingAddress=false)
BasePaths - Represents the set of paths from a derived class to one of its (direct or indirect) bases...
void clear()
Clear out all of the candidates.
ImplicitConversionKind First
First – The first conversion can be an lvalue-to-rvalue conversion, array-to-pointer conversion...
const Expr * getInit(unsigned Init) const
struct clang::OverloadCandidate::@202 BuiltinTypes
No viable function found.
void NoteCandidates(Sema &S, SourceLocation Loc)
NoteCandidates - When no template specialization match is found, prints diagnostic messages containin...
TemplateArgument FirstArg
The first template argument to which the template argument deduction failure refers.
DeductionFailureInfo DeductionFailure
void suppressDiagnostics()
Suppress the diagnostics that would normally fire because of this lookup.
static bool recordConversion(Sema &SemaRef, SourceLocation Loc, Expr *&From, Sema::ContextualImplicitConverter &Converter, QualType T, bool HadMultipleCandidates, DeclAccessPair &Found)
AccessResult CheckAddressOfMemberAccess(Expr *OvlExpr, DeclAccessPair FoundDecl)
An l-value expression is a reference to an object with independent storage.
const llvm::fltSemantics & getFloatTypeSemantics(QualType T) const
Return the APFloat 'semantics' for the specified scalar floating point type.
A trivial tuple used to represent a source range.
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.
static OverloadingResult IsUserDefinedConversion(Sema &S, Expr *From, QualType ToType, UserDefinedConversionSequence &User, OverloadCandidateSet &Conversions, bool AllowExplicit, bool AllowObjCConversionOnExplicit)
Determines whether there is a user-defined conversion sequence (C++ [over.ics.user]) that converts ex...
Look up of an operator name (e.g., operator+) for use with operator overloading.
Describes an entity that is being initialized.
static InitializedEntity InitializeParameter(ASTContext &Context, ParmVarDecl *Parm)
Create the initialization entity for a parameter.
void setToType(unsigned Idx, QualType T)
bool isObjCIdType() const
True if this is equivalent to the 'id' type, i.e.
NamespaceDecl * getStdNamespace() const
char Diagnostic[sizeof(PartialDiagnosticAt)]
void removeAddressSpace()
static ImplicitConversionSequence TryCopyInitialization(Sema &S, Expr *From, QualType ToType, bool SuppressUserConversions, bool InOverloadResolution, bool AllowObjCWritebackConversion, bool AllowExplicit=false)
TryCopyInitialization - Try to copy-initialize a value of type ToType from the expression From...
bool isPointerConversionToVoidPointer(ASTContext &Context) const
isPointerConversionToVoidPointer - Determines whether this conversion is a conversion of a pointer to...
TemplateSpecializationType(TemplateName T, ArrayRef< TemplateArgument > Args, QualType Canon, QualType Aliased)
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.
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)