25 #include "llvm/ADT/SmallBitVector.h"
63 using namespace clang;
68 if (Y.getBitWidth() > X.getBitWidth())
69 X = X.extend(Y.getBitWidth());
70 else if (Y.getBitWidth() < X.getBitWidth())
71 Y = Y.extend(X.getBitWidth());
74 if (X.isSigned() != Y.isSigned()) {
76 if ((Y.isSigned() && Y.isNegative()) || (X.isSigned() && X.isNegative()))
91 TemplateDeductionInfo &Info,
92 SmallVectorImpl<DeducedTemplateArgument> &Deduced);
99 TemplateDeductionInfo &Info,
100 SmallVectorImpl<DeducedTemplateArgument> &
103 bool PartialOrdering =
false);
110 TemplateDeductionInfo &Info,
111 SmallVectorImpl<DeducedTemplateArgument> &Deduced);
121 E = IC->getSubExpr();
123 dyn_cast<SubstNonTypeTemplateParmExpr>(E))
124 E = Subst->getReplacement();
138 if (
NamedDecl *NX = dyn_cast<NamedDecl>(X))
139 X = NX->getUnderlyingDecl();
140 if (
NamedDecl *NY = dyn_cast<NamedDecl>(Y))
141 Y = NY->getUnderlyingDecl();
162 llvm_unreachable(
"Non-deduced template arguments handled above");
215 llvm::FoldingSetNodeID ID1, ID2;
216 X.
getAsExpr()->Profile(ID1, Context,
true);
217 Y.
getAsExpr()->Profile(ID2, Context,
true);
272 XA != XAEnd; ++XA, ++YA) {
284 llvm_unreachable(
"Invalid TemplateArgument Kind!");
293 bool DeducedFromArrayBound,
294 TemplateDeductionInfo &Info,
295 SmallVectorImpl<DeducedTemplateArgument> &Deduced) {
297 "Cannot deduce non-type template argument with depth > 0");
300 DeducedFromArrayBound);
306 Info.FirstArg = Deduced[NTTP->
getIndex()];
307 Info.SecondArg = NewDeduced;
323 TemplateDeductionInfo &Info,
324 SmallVectorImpl<DeducedTemplateArgument> &Deduced) {
326 "Cannot deduce non-type template argument with depth > 0");
328 "Expression template argument must be type- or value-dependent.");
337 Info.FirstArg = Deduced[NTTP->
getIndex()];
338 Info.SecondArg = NewDeduced;
354 TemplateDeductionInfo &Info,
355 SmallVectorImpl<DeducedTemplateArgument> &Deduced) {
357 "Cannot deduce non-type template argument with depth > 0");
359 D = D ? cast<ValueDecl>(D->getCanonicalDecl()) :
nullptr;
367 Info.FirstArg = Deduced[NTTP->
getIndex()];
368 Info.SecondArg = NewDeduced;
381 TemplateDeductionInfo &Info,
382 SmallVectorImpl<DeducedTemplateArgument> &Deduced) {
391 = dyn_cast<TemplateTemplateParmDecl>(ParamDecl)) {
394 Deduced[TempParam->getIndex()],
396 if (Result.isNull()) {
397 Info.Param = TempParam;
398 Info.FirstArg = Deduced[TempParam->getIndex()];
399 Info.SecondArg = NewDeduced;
403 Deduced[TempParam->getIndex()] = Result;
440 TemplateDeductionInfo &Info,
441 SmallVectorImpl<DeducedTemplateArgument> &Deduced) {
442 assert(Arg.
isCanonical() &&
"Argument type must be canonical");
446 = dyn_cast<TemplateSpecializationType>(Arg)) {
450 Param->getTemplateName(),
451 SpecArg->getTemplateName(),
460 Param->getArgs(), Param->getNumArgs(),
461 SpecArg->getArgs(), SpecArg->getNumArgs(),
487 Param->getTemplateName(),
494 Param->getArgs(), Param->getNumArgs(),
504 case Type::TypeOfExpr:
506 case Type::DependentName:
508 case Type::UnresolvedUsing:
509 case Type::TemplateTypeParm:
512 case Type::ConstantArray:
513 case Type::IncompleteArray:
514 case Type::VariableArray:
515 case Type::DependentSizedArray:
525 static std::pair<unsigned, unsigned>
528 return std::make_pair(TTP->getDepth(), TTP->getIndex());
531 return std::make_pair(NTTP->getDepth(), NTTP->getIndex());
538 static std::pair<unsigned, unsigned>
542 return std::make_pair(TTP->getDepth(), TTP->getIndex());
581 class PackDeductionScope {
586 :
S(S), TemplateParams(TemplateParams), Deduced(Deduced), Info(Info) {
590 llvm::SmallBitVector SawIndices(TemplateParams->
size());
593 for (
unsigned I = 0, N = Unexpanded.size();
I != N; ++
I) {
594 unsigned Depth, Index;
596 if (Depth == 0 && !SawIndices[Index]) {
597 SawIndices[Index] =
true;
602 Pack.
Saved = Deduced[Index];
605 Packs.push_back(Pack);
609 assert(!Packs.empty() &&
"Pack expansion without unexpanded packs?");
611 for (
auto &Pack : Packs) {
622 unsigned NumExplicitArgs;
625 &ExplicitArgs, &NumExplicitArgs);
626 if (PartiallySubstitutedPack &&
628 Pack.New.append(ExplicitArgs, ExplicitArgs + NumExplicitArgs);
633 ~PackDeductionScope() {
634 for (
auto &Pack : Packs)
639 void nextPackElement() {
643 for (
auto &Pack : Packs) {
645 if (!DeducedArg.
isNull()) {
646 Pack.New.push_back(DeducedArg);
658 for (
auto &Pack : Packs) {
660 Deduced[Pack.Index] = Pack.Saved;
664 if (HasAnyArguments && Pack.New.empty()) {
665 if (Pack.DeferredDeduction.isNull()) {
672 NewPack = Pack.DeferredDeduction;
674 }
else if (Pack.New.empty()) {
680 std::copy(Pack.New.begin(), Pack.New.end(), ArgumentPack);
683 Pack.New[0].wasDeducedFromArrayBound());
689 if (Pack.Outer->DeferredDeduction.isNull()) {
692 Pack.Outer->DeferredDeduction = NewPack;
695 Loc = &Pack.Outer->DeferredDeduction;
697 Loc = &Deduced[Pack.Index];
706 if (!Result.
isNull() && !Pack.DeferredDeduction.isNull()) {
708 NewPack = Pack.DeferredDeduction;
769 const QualType *Params,
unsigned NumParams,
771 TemplateDeductionInfo &Info,
772 SmallVectorImpl<DeducedTemplateArgument> &Deduced,
774 bool PartialOrdering =
false) {
776 if (NumParams != NumArgs &&
777 !(NumParams && isa<PackExpansionType>(Params[NumParams - 1])) &&
778 !(NumArgs && isa<PackExpansionType>(Args[NumArgs - 1])))
786 unsigned ArgIdx = 0, ParamIdx = 0;
787 for (; ParamIdx != NumParams; ++ParamIdx) {
795 if (ArgIdx >= NumArgs)
798 if (isa<PackExpansionType>(Args[ArgIdx])) {
808 Params[ParamIdx], Args[ArgIdx],
821 if (ParamIdx + 1 < NumParams)
832 PackDeductionScope PackScope(S, TemplateParams, Deduced, Info, Pattern);
834 bool HasAnyArguments =
false;
835 for (; ArgIdx <
NumArgs; ++ArgIdx) {
836 HasAnyArguments =
true;
841 Args[ArgIdx], Info, Deduced,
842 TDF, PartialOrdering))
845 PackScope.nextPackElement();
850 if (
auto Result = PackScope.finish(HasAnyArguments))
855 if (ArgIdx < NumArgs)
868 if (ParamQs == ArgQs)
905 if (!ParamFunction || !ArgFunction)
946 TemplateDeductionInfo &Info,
947 SmallVectorImpl<DeducedTemplateArgument> &Deduced,
949 bool PartialOrdering) {
958 = dyn_cast<PackExpansionType>(Arg))
959 Arg = ArgExpansion->getPattern();
961 if (PartialOrdering) {
1043 TDF &= ~TDF_TopLevelParameterTypeList;
1047 if (isa<TemplateTypeParmType>(ParamRef->getPointeeType()) &&
1048 !ParamRef->getPointeeType().getQualifiers())
1068 unsigned Index = TemplateTypeParm->getIndex();
1069 bool RecanonicalizeArg =
false;
1073 if (isa<ArrayType>(Arg)) {
1078 RecanonicalizeArg =
true;
1086 Info.Param = cast<TemplateTypeParmDecl>(TemplateParams->
getParam(Index));
1092 assert(TemplateTypeParm->getDepth() == 0 &&
"Can't deduce with depth > 0");
1113 Info.Param = cast<TemplateTypeParmDecl>(TemplateParams->
getParam(Index));
1130 if (RecanonicalizeArg)
1138 Info.Param = cast<TemplateTypeParmDecl>(TemplateParams->
getParam(Index));
1139 Info.FirstArg = Deduced[Index];
1140 Info.SecondArg = NewDeduced;
1144 Deduced[Index] = Result;
1156 if (isa<SubstTemplateTypeParmPackType>(Param))
1189 ParamUnqualType == ArgUnqualType;
1196 #define NON_CANONICAL_TYPE(Class, Base) \
1197 case Type::Class: llvm_unreachable("deducing non-canonical type: " #Class);
1198 #define TYPE(Class, Base)
1199 #include "clang/AST/TypeNodes.def"
1201 case Type::TemplateTypeParm:
1202 case Type::SubstTemplateTypeParmPack:
1203 llvm_unreachable(
"Type nodes handled above");
1208 case Type::VariableArray:
1210 case Type::FunctionNoProto:
1213 case Type::ObjCObject:
1214 case Type::ObjCInterface:
1215 case Type::ObjCObjectPointer: {
1219 if (TDF & TDF_IgnoreQualifiers) {
1232 ComplexArg->getElementType(),
1233 Info, Deduced, TDF);
1241 cast<AtomicType>(Param)->getValueType(),
1242 AtomicArg->getValueType(),
1243 Info, Deduced, TDF);
1248 case Type::Pointer: {
1261 cast<PointerType>(Param)->getPointeeType(),
1263 Info, Deduced, SubTDF);
1267 case Type::LValueReference: {
1274 cast<LValueReferenceType>(Param)->getPointeeType(),
1279 case Type::RValueReference: {
1286 cast<RValueReferenceType>(Param)->getPointeeType(),
1292 case Type::IncompleteArray: {
1295 if (!IncompleteArrayArg)
1302 Info, Deduced, SubTDF);
1306 case Type::ConstantArray: {
1309 if (!ConstantArrayArg)
1315 return Sema::TDK_NonDeducedMismatch;
1321 Info, Deduced, SubTDF);
1325 case Type::DependentSizedArray: {
1339 Info, Deduced, SubTDF))
1351 "Cannot deduce non-type template argument at depth > 0");
1353 = dyn_cast<ConstantArrayType>(ArrayArg)) {
1354 llvm::APSInt Size(ConstantArrayArg->getSize());
1361 = dyn_cast<DependentSizedArrayType>(ArrayArg))
1362 if (DependentArrayArg->getSizeExpr())
1364 DependentArrayArg->getSizeExpr(),
1374 case Type::FunctionProto: {
1378 if (!FunctionProtoArg)
1382 cast<FunctionProtoType>(Param);
1389 return Sema::TDK_NonDeducedMismatch;
1402 FunctionProtoArg->
getNumParams(), Info, Deduced, SubTDF);
1405 case Type::InjectedClassName: {
1408 Param = cast<InjectedClassNameType>(Param)
1409 ->getInjectedSpecializationType();
1410 assert(isa<TemplateSpecializationType>(Param) &&
1411 "injected class name is not a template specialization type");
1420 case Type::TemplateSpecialization: {
1422 = cast<TemplateSpecializationType>(Param);
1449 llvm::SmallPtrSet<const RecordType *, 8> Visited;
1451 ToVisit.push_back(RecordT);
1452 bool Successful =
false;
1455 while (!ToVisit.empty()) {
1457 const RecordType *NextT = ToVisit.pop_back_val();
1460 if (!Visited.insert(NextT).second)
1465 if (NextT != RecordT) {
1466 TemplateDeductionInfo BaseInfo(Info.getLocation());
1477 DeducedOrig.clear();
1478 DeducedOrig.append(Deduced.begin(), Deduced.end());
1479 Info.Param = BaseInfo.Param;
1480 Info.FirstArg = BaseInfo.FirstArg;
1481 Info.SecondArg = BaseInfo.SecondArg;
1484 Deduced = DeducedOrig;
1489 for (
const auto &
Base : Next->
bases()) {
1490 assert(
Base.getType()->isRecordType() &&
1491 "Base class that isn't a record?");
1514 case Type::MemberPointer: {
1523 false, Info.getLocation());
1527 false, Info.getLocation());
1534 TDF & TDF_IgnoreQualifiers))
1539 QualType(MemPtrArg->getClass(), 0),
1541 TDF & TDF_IgnoreQualifiers);
1549 case Type::BlockPointer: {
1565 case Type::ExtVector: {
1566 const ExtVectorType *VectorParam = cast<ExtVectorType>(Param);
1567 if (
const ExtVectorType *VectorArg = dyn_cast<ExtVectorType>(Arg)) {
1569 if (VectorParam->
getNumElements() != VectorArg->getNumElements())
1570 return Sema::TDK_NonDeducedMismatch;
1575 VectorArg->getElementType(),
1576 Info, Deduced, TDF);
1580 = dyn_cast<DependentSizedExtVectorType>(Arg)) {
1588 VectorArg->getElementType(),
1589 Info, Deduced, TDF);
1598 case Type::DependentSizedExtVector: {
1600 = cast<DependentSizedExtVectorType>(Param);
1602 if (
const ExtVectorType *VectorArg = dyn_cast<ExtVectorType>(Arg)) {
1607 VectorArg->getElementType(),
1608 Info, Deduced, TDF))
1618 ArgSize = VectorArg->getNumElements();
1620 false, Info, Deduced);
1624 = dyn_cast<DependentSizedExtVectorType>(Arg)) {
1629 VectorArg->getElementType(),
1630 Info, Deduced, TDF))
1646 case Type::TypeOfExpr:
1648 case Type::DependentName:
1649 case Type::UnresolvedUsing:
1650 case Type::Decltype:
1651 case Type::UnaryTransform:
1653 case Type::DependentTemplateSpecialization:
1654 case Type::PackExpansion:
1660 llvm_unreachable(
"Invalid Type Class!");
1668 TemplateDeductionInfo &Info,
1669 SmallVectorImpl<DeducedTemplateArgument> &Deduced) {
1678 llvm_unreachable(
"Null template argument in parameter list");
1686 Info.FirstArg = Param;
1687 Info.SecondArg = Arg;
1695 Info.FirstArg = Param;
1696 Info.SecondArg = Arg;
1700 llvm_unreachable(
"caller should handle pack expansions");
1707 Info.FirstArg = Param;
1708 Info.SecondArg = Arg;
1716 Info.FirstArg = Param;
1717 Info.SecondArg = Arg;
1725 Info.FirstArg = Param;
1726 Info.SecondArg = Arg;
1731 Info.FirstArg = Param;
1732 Info.SecondArg = Arg;
1736 Info.FirstArg = Param;
1737 Info.SecondArg = Arg;
1756 Info.FirstArg = Param;
1757 Info.SecondArg = Arg;
1765 llvm_unreachable(
"Argument packs should be expanded by the caller!");
1768 llvm_unreachable(
"Invalid TemplateArgument Kind!");
1782 if (ArgIdx == NumArgs)
1789 assert(ArgIdx == NumArgs - 1 &&
"Pack not at the end of argument list?");
1800 unsigned ArgIdx = 0;
1801 while (ArgIdx < NumArgs) {
1813 if (ArgIdx == NumArgs)
1828 TemplateDeductionInfo &Info,
1829 SmallVectorImpl<DeducedTemplateArgument> &Deduced) {
1841 unsigned ArgIdx = 0, ParamIdx = 0;
1844 if (!Params[ParamIdx].isPackExpansion()) {
1851 if (Args[ArgIdx].isPackExpansion()) {
1860 Params[ParamIdx], Args[ArgIdx],
1883 PackDeductionScope PackScope(S, TemplateParams, Deduced, Info, Pattern);
1888 bool HasAnyArguments =
false;
1890 HasAnyArguments =
true;
1898 PackScope.nextPackElement();
1903 if (
auto Result = PackScope.finish(HasAnyArguments))
1915 TemplateDeductionInfo &Info,
1916 SmallVectorImpl<DeducedTemplateArgument> &Deduced) {
1918 ParamList.
data(), ParamList.
size(),
1932 llvm_unreachable(
"Comparing NULL template argument");
1955 llvm::FoldingSetNodeID XID, YID;
1956 X.
getAsExpr()->Profile(XID, Context,
true);
1957 Y.
getAsExpr()->Profile(YID, Context,
true);
1968 XP != XPEnd; ++XP, ++YP)
1975 llvm_unreachable(
"Invalid TemplateArgument Kind!");
1999 llvm_unreachable(
"Can't get a NULL template argument here");
2053 llvm_unreachable(
"Invalid TemplateArgument Kind!");
2064 unsigned ArgumentPackIndex,
2065 TemplateDeductionInfo &Info,
2066 bool InFunctionTemplate,
2067 SmallVectorImpl<TemplateArgument> &Output) {
2079 NTTPType, PackedArgsBuilder.size(),
2080 Info, InFunctionTemplate, Output))
2084 PackedArgsBuilder.push_back(Output.pop_back_val());
2097 Info.getLocation());
2119 SmallVectorImpl<DeducedTemplateArgument> &Deduced,
2120 TemplateDeductionInfo &Info) {
2132 for (
unsigned I = 0, N = PartialParams->
size();
I != N; ++
I) {
2134 if (Deduced[
I].isNull()) {
2147 = dyn_cast<NonTypeTemplateParmDecl>(Param)) {
2148 NTTPType = NTTP->getType();
2151 Builder.data(), Builder.size());
2154 NTTP->getLocation(),
2155 NTTP->getDeclName());
2156 if (NTTPType.isNull()) {
2168 Partial, NTTPType, 0, Info,
false,
2183 Info.reset(DeducedArgumentList);
2202 unsigned ArgIdx = InstArgs.
size(), ParamIdx = ArgIdx;
2210 Info.FirstArg = PartialTemplateArgs[ArgIdx].
getArgument();
2216 InstArgs,
false, ConvertedInstArgs))
2221 for (
unsigned I = 0,
E = TemplateParams->
size();
I !=
E; ++
I) {
2225 Info.FirstArg = TemplateArgs[
I];
2226 Info.SecondArg = InstArg;
2263 TemplateArgs, Info, Deduced))
2269 if (Inst.isInvalid())
2289 SmallVectorImpl<DeducedTemplateArgument> &Deduced,
2290 TemplateDeductionInfo &Info) {
2300 for (
unsigned I = 0, N = PartialParams->
size();
I != N; ++
I) {
2302 if (Deduced[
I].isNull()) {
2315 dyn_cast<NonTypeTemplateParmDecl>(Param)) {
2316 NTTPType = NTTP->getType();
2319 Builder.data(), Builder.size());
2322 NTTP->getLocation(), NTTP->getDeclName());
2323 if (NTTPType.isNull()) {
2334 0, Info,
false, Builder)) {
2345 S.
Context, Builder.data(), Builder.size());
2347 Info.reset(DeducedArgumentList);
2366 unsigned ArgIdx = InstArgs.
size(), ParamIdx = ArgIdx;
2373 Info.FirstArg = PartialTemplateArgs[ArgIdx].
getArgument();
2378 false, ConvertedInstArgs))
2382 for (
unsigned I = 0,
E = TemplateParams->
size();
I !=
E; ++
I) {
2386 Info.FirstArg = TemplateArgs[
I];
2387 Info.SecondArg = InstArg;
2427 TemplateArgs, Info, Deduced))
2433 if (Inst.isInvalid())
2447 return Spec->getTemplateName().getAsTemplateDecl() !=
nullptr;
2488 if (ExplicitTemplateArgs.
size() == 0) {
2491 for (
auto P : Function->
params())
2492 ParamTypes.push_back(
P->getType());
2495 *FunctionType = Function->
getType();
2518 if (Inst.isInvalid())
2523 ExplicitTemplateArgs,
2526 unsigned Index = Builder.size();
2527 if (Index >= TemplateParams->
size())
2528 Index = TemplateParams->
size() - 1;
2537 Info.
reset(ExplicitArgumentList);
2549 for (
unsigned I = 0, N = Builder.size();
I != N; ++
I) {
2562 assert(Proto &&
"Function template does not have a prototype?");
2588 unsigned ThisTypeQuals = 0;
2590 if (
CXXMethodDecl *Method = dyn_cast<CXXMethodDecl>(Function)) {
2592 ThisTypeQuals = Method->getTypeQualifiers();
2634 Deduced.reserve(TemplateParams->
size());
2635 for (
unsigned I = 0, N = ExplicitArgumentList->
size();
I != N; ++
I) {
2640 Deduced.push_back(Arg);
2692 if (AQuals == DeducedAQuals) {
2711 bool ObjCLifetimeConversion =
false;
2715 ObjCLifetimeConversion) ||
2757 unsigned NumExplicitlySpecified,
2761 bool PartialOverloading) {
2776 if (Inst.isInvalid())
2785 for (
unsigned I = 0, N = TemplateParams->
size();
I != N; ++
I) {
2788 if (!Deduced[
I].isNull()) {
2789 if (
I < NumExplicitlySpecified) {
2793 Builder.push_back(Deduced[
I]);
2815 = dyn_cast<NonTypeTemplateParmDecl>(Param)) {
2816 NTTPType = NTTP->getType();
2819 Builder.data(), Builder.size());
2822 NTTP->getLocation(),
2823 NTTP->getDeclName());
2824 if (NTTPType.isNull()) {
2836 FunctionTemplate, NTTPType, 0, Info,
2857 unsigned NumExplicitArgs;
2863 llvm::makeArrayRef(ExplicitArgs, NumExplicitArgs)));
2875 bool HasDefaultArg =
false;
2886 const_cast<NamedDecl *>(TemplateParams->
getParam(
I)));
2889 if (PartialOverloading)
break;
2902 const_cast<NamedDecl *>(TemplateParams->
getParam(
I)));
2915 Info.
reset(DeducedArgumentList);
2922 Specialization = cast_or_null<FunctionDecl>(
2945 if (OriginalCallArgs) {
2950 for (
unsigned I = 0, N = OriginalCallArgs->size();
I != N; ++
I) {
2952 unsigned ParamIdx = OriginalArg.
ArgIdx;
2992 if (Method->isInstance()) {
3012 bool ParamWasReference) {
3020 if (ParamWasReference)
3060 TemplateDeductionInfo Info(Ovl->
getNameLoc());
3062 Specialization, Info))
3070 if (ArgType.isNull())
continue;
3074 ArgType->isFunctionType())
3090 Deduced(TemplateParams->
size());
3091 TemplateDeductionInfo Info(Ovl->
getNameLoc());
3094 ArgType, Info, Deduced, TDF);
3095 if (Result)
continue;
3133 ParamRefType !=
nullptr);
3151 isa<TemplateTypeParmType>(ParamType) &&
3197 (isa<PointerType>(ParamType) &&
3211 Expr *Arg, TemplateDeductionInfo &Info,
3212 SmallVectorImpl<DeducedTemplateArgument> &Deduced,
unsigned TDF);
3219 TemplateDeductionInfo &Info,
3220 SmallVectorImpl<DeducedTemplateArgument> &Deduced,
3235 const bool IsDependentSizedArray =
3240 const bool IsSTDList = !IsConstSizedArray && !IsDependentSizedArray &&
3243 if (!IsConstSizedArray && !IsDependentSizedArray && !IsSTDList)
3257 E, Info, Deduced, TDF)))
3261 if (IsDependentSizedArray) {
3269 assert(NTTP->getDepth() == 0 &&
3270 "Cannot deduce non-type template argument at depth > 0");
3275 S, NTTP, llvm::APSInt(Size), NTTP->getType(),
3276 true, Info, Deduced);
3290 TemplateDeductionInfo &Info,
3291 SmallVectorImpl<DeducedTemplateArgument> &Deduced,
3299 Deduced, TDF, Result))
3308 ArgType, Arg, TDF)) {
3309 Info.Expression = Arg;
3313 ArgType, Info, Deduced, TDF);
3339 bool PartialOverloading) {
3350 unsigned CheckArgs = Args.size();
3359 CheckArgs = NumParams;
3371 unsigned NumExplicitlySpecified = 0;
3372 if (ExplicitTemplateArgs) {
3375 *ExplicitTemplateArgs,
3383 NumExplicitlySpecified = Deduced.size();
3386 for (
unsigned I = 0;
I != NumParams; ++
I)
3391 Deduced.resize(TemplateParams->
size());
3392 unsigned ArgIdx = 0;
3394 for (
unsigned ParamIdx = 0, NumParamTypes = ParamTypes.size();
3395 ParamIdx != NumParamTypes; ++ParamIdx) {
3396 QualType OrigParamType = ParamTypes[ParamIdx];
3397 QualType ParamType = OrigParamType;
3401 if (!ParamExpansion) {
3403 if (ArgIdx >= CheckArgs)
3406 Expr *Arg = Args[ArgIdx++];
3411 ParamType, ArgType, Arg,
3424 Info, Deduced, TDF, Result))
3441 Info, Deduced, TDF))
3456 if (ParamIdx + 1 < NumParamTypes)
3460 PackDeductionScope PackScope(*
this, TemplateParams, Deduced, Info,
3463 bool HasAnyArguments =
false;
3464 for (; ArgIdx < Args.size(); ++ArgIdx) {
3465 HasAnyArguments =
true;
3467 QualType OrigParamType = ParamPattern;
3468 ParamType = OrigParamType;
3469 Expr *Arg = Args[ArgIdx];
3474 ParamType, ArgType, Arg,
3486 Info, Deduced, TDF, Result)) {
3503 ParamType, ArgType, Info,
3508 PackScope.nextPackElement();
3513 if (
auto Result = PackScope.finish(HasAnyArguments))
3521 NumExplicitlySpecified, Specialization,
3522 Info, &OriginalCallArgs,
3523 PartialOverloading);
3528 if (ArgFunctionType.
isNull())
3529 return ArgFunctionType;
3539 return ArgFunctionType;
3545 return QualType(ArgFunctionTypeP, 0);
3577 bool InOverloadResolution) {
3585 if (!InOverloadResolution)
3591 unsigned NumExplicitlySpecified = 0;
3593 if (ExplicitTemplateArgs) {
3596 *ExplicitTemplateArgs,
3597 Deduced, ParamTypes,
3598 &FunctionType, Info))
3601 NumExplicitlySpecified = Deduced.size();
3608 Deduced.resize(TemplateParams->
size());
3612 bool HasDeducedReturnType =
false;
3613 if (
getLangOpts().CPlusPlus14 && InOverloadResolution &&
3616 HasDeducedReturnType =
true;
3619 if (!ArgFunctionType.
isNull()) {
3625 FunctionType, ArgFunctionType,
3626 Info, Deduced, TDF))
3632 NumExplicitlySpecified,
3633 Specialization, Info))
3638 if (HasDeducedReturnType &&
3646 if (!ArgFunctionType.
isNull()) {
3651 else if(!InOverloadResolution &&
3669 assert(AutoResultType->getContainedAutoType());
3671 TypeToReplaceAutoWith);
3684 SmallVectorImpl<DeducedTemplateArgument> &DeducedArguments,
3685 QualType ReturnTypeOfDestFunctionPtr,
3686 TemplateDeductionInfo &TDInfo,
3693 QualType CallOpResultType = CallOpGeneric->getReturnType();
3694 const bool GenericLambdaCallOperatorHasDeducedReturnType =
3698 CallOpGeneric->getDescribedFunctionTemplate();
3706 0, CallOpSpecialized, TDInfo))
3710 if (GenericLambdaCallOperatorHasDeducedReturnType &&
3719 ReturnTypeOfDestFunctionPtr))
3728 getLambdaStaticInvoker()->getDescribedFunctionTemplate();
3734 InvokerSpecialized, TDInfo);
3736 "If the call operator succeeded so should the invoker!");
3739 if (GenericLambdaCallOperatorHasDeducedReturnType &&
3753 TypeToReplaceAutoWith, S);
3755 TypeToReplaceAutoWith, S);
3805 assert(!A->
isReferenceType() &&
"Reference types were handled above");
3841 Deduced.resize(TemplateParams->
size());
3865 P, A, Info, Deduced, TDF))
3874 ConversionSpecialized, Info);
3875 Specialization = cast_or_null<CXXConversionDecl>(ConversionSpecialized);
3887 "Can only convert from lambda to ptr-to-function");
3890 const QualType DestFunctionPtrReturnType = ToFunType->getReturnType();
3902 Specialization, Deduced, DestFunctionPtrReturnType,
3930 bool InOverloadResolution) {
3933 InOverloadResolution);
3939 class SubstituteAutoTransform :
3943 SubstituteAutoTransform(
Sema &SemaRef,
QualType Replacement)
3945 Replacement(Replacement) {}
3955 if (!Replacement.isNull() && isa<TemplateTypeParmType>(Replacement)) {
3963 !Replacement.isNull() && Replacement->isDependentType();
3965 SemaRef.Context.getAutoType(Dependent ?
QualType() : Replacement,
3984 return TransformType(TLB, TL);
4006 Init = NonPlaceholder.
get();
4011 assert(!Result.
isNull() &&
"substituting DependentTy can't fail");
4019 if (AT->isDecltypeAuto()) {
4020 if (isa<InitListExpr>(Init)) {
4021 Diag(Init->getLocStart(), diag::err_decltype_auto_initializer_list);
4030 Result = SubstituteAutoTransform(*
this, Deduced).Apply(Type);
4035 if (isa<InitListExpr>(Init)) {
4036 Diag(Init->getLocStart(), diag::err_auto_init_list_from_c);
4049 nullptr,
false,
false);
4053 Loc, Loc, TemplParamPtr, Loc);
4055 QualType FuncParam = SubstituteAutoTransform(*
this, TemplArg).Apply(Type);
4056 assert(!FuncParam.
isNull() &&
4057 "substituting template parameter for 'auto' failed");
4069 for (
unsigned i = 0, e = InitList->
getNumInits(); i < e; ++i) {
4071 TemplArg, InitList->
getInit(i),
4072 Info, Deduced, TDF))
4077 Diag(Loc, diag::err_auto_bitfield);
4082 *
this, TemplateParamsSt.
get(), FuncParam, InitType, Init, TDF))
4086 FuncParam, InitType, Info, Deduced,
4094 QualType DeducedType = Deduced[0].getAsType();
4098 if (DeducedType.
isNull())
4102 Result = SubstituteAutoTransform(*
this, DeducedType).Apply(Type);
4108 if (!InitList && !Result.
isNull() &&
4121 return SubstituteAutoTransform(*
this, TypeToReplaceAuto).
4122 TransformType(TypeWithAuto);
4127 return SubstituteAutoTransform(*
this, TypeToReplaceAuto).
4128 TransformType(TypeWithAuto);
4132 if (isa<InitListExpr>(Init))
4135 ? diag::err_init_capture_deduction_failure_from_init_list
4136 : diag::err_auto_var_deduction_failure_from_init_list)
4140 VDecl->
isInitCapture() ? diag::err_init_capture_deduction_failure
4141 : diag::err_auto_var_deduction_failure)
4143 << Init->getSourceRange();
4155 Diag(Loc, diag::err_auto_fn_used_before_defined) << FD;
4159 return StillUndeduced;
4166 llvm::SmallBitVector &Deduced);
4172 SmallVectorImpl<QualType> &ArgTypes) {
4187 ArgTypes.push_back(ArgTy);
4197 unsigned NumCallArguments1) {
4203 assert(Proto1 && Proto2 &&
"Function templates must have prototypes");
4206 Deduced.resize(TemplateParams->
size());
4211 TemplateDeductionInfo Info(Loc);
4237 unsigned NumComparedArguments = NumCallArguments1;
4239 if (!Method2 && Method1 && !Method1->
isStatic()) {
4242 ++NumComparedArguments;
4243 }
else if (!Method1 && Method2 && !Method2->
isStatic()) {
4250 Args2.insert(Args2.end(), Proto2->param_type_begin(),
4251 Proto2->param_type_end());
4256 if (Args1.size() > NumComparedArguments)
4257 Args1.resize(NumComparedArguments);
4258 if (Args2.size() > NumComparedArguments)
4259 Args2.resize(NumComparedArguments);
4261 Args1.data(), Args1.size(), Info, Deduced,
4272 S, TemplateParams, Proto2->getReturnType(), Proto1->
getReturnType(),
4295 unsigned ArgIdx = 0,
NumArgs = Deduced.size();
4296 for (; ArgIdx !=
NumArgs; ++ArgIdx)
4297 if (Deduced[ArgIdx].isNull())
4307 llvm::SmallBitVector UsedParameters(TemplateParams->
size());
4310 for (
unsigned I = 0, N = Args2.size();
I != N; ++
I)
4318 TemplateParams->
getDepth(), UsedParameters);
4328 for (; ArgIdx !=
NumArgs; ++ArgIdx)
4331 if (Deduced[ArgIdx].isNull() && UsedParameters[ArgIdx])
4350 while (--NumParams > 0) {
4381 unsigned NumCallArguments1,
4382 unsigned NumCallArguments2) {
4388 if (Better1 != Better2)
4389 return Better1 ? FT1 : FT2;
4391 if (!Better1 && !Better2)
4399 if (Variadic1 != Variadic2)
4400 return Variadic1? FT2 : FT1;
4446 bool Complain,
QualType TargetType) {
4447 if (SpecBegin == SpecEnd) {
4449 Diag(Loc, NoneDiag);
4455 if (SpecBegin + 1 == SpecEnd)
4462 = cast<FunctionDecl>(*Best)->getPrimaryTemplate();
4463 assert(BestTemplate &&
"Not a function template specialization?");
4466 = cast<FunctionDecl>(*I)->getPrimaryTemplate();
4467 assert(Challenger &&
"Not a function template specialization?");
4472 BestTemplate = Challenger;
4478 bool Ambiguous =
false;
4481 = cast<FunctionDecl>(*I)->getPrimaryTemplate();
4498 Diag(Loc, AmbigDiag);
4504 cast<FunctionDecl>(*I)->getPrimaryTemplate()->getTemplateParameters(),
4505 *cast<FunctionDecl>(*I)->getTemplateSpecializationArgs());
4506 if (!TargetType.
isNull())
4509 Diag((*I)->getLocation(), PD);
4588 if (Better1 == Better2)
4591 return Better1 ? PS1 : PS2;
4607 "the partial specializations being compared should specialize"
4608 " the same template.");
4647 if (Better1 == Better2)
4650 return Better1? PS1 : PS2;
4658 llvm::SmallBitVector &
Used);
4667 llvm::SmallBitVector &
Used) {
4670 E = Expansion->getPattern();
4676 E = ICE->getSubExpr();
4678 dyn_cast<SubstNonTypeTemplateParmExpr>(E))
4679 E = Subst->getReplacement();
4706 llvm::SmallBitVector &
Used) {
4713 OnlyDeduced, Depth, Used);
4723 llvm::SmallBitVector &
Used) {
4726 = dyn_cast<TemplateTemplateParmDecl>(Template)) {
4727 if (TTP->getDepth() ==
Depth)
4728 Used[TTP->getIndex()] =
true;
4747 llvm::SmallBitVector &
Used) {
4759 cast<PointerType>(T)->getPointeeType(),
4765 case Type::BlockPointer:
4767 cast<BlockPointerType>(T)->getPointeeType(),
4773 case Type::LValueReference:
4774 case Type::RValueReference:
4776 cast<ReferenceType>(T)->getPointeeType(),
4782 case Type::MemberPointer: {
4787 OnlyDeduced, Depth, Used);
4791 case Type::DependentSizedArray:
4793 cast<DependentSizedArrayType>(T)->getSizeExpr(),
4794 OnlyDeduced, Depth, Used);
4797 case Type::ConstantArray:
4798 case Type::IncompleteArray:
4801 OnlyDeduced, Depth, Used);
4805 case Type::ExtVector:
4808 OnlyDeduced, Depth, Used);
4811 case Type::DependentSizedExtVector: {
4813 = cast<DependentSizedExtVectorType>(T);
4821 case Type::FunctionProto: {
4831 case Type::TemplateTypeParm: {
4838 case Type::SubstTemplateTypeParmPack: {
4840 = cast<SubstTemplateTypeParmPackType>(T);
4843 OnlyDeduced, Depth, Used);
4849 case Type::InjectedClassName:
4850 T = cast<InjectedClassNameType>(T)->getInjectedSpecializationType();
4853 case Type::TemplateSpecialization: {
4855 = cast<TemplateSpecializationType>(T);
4867 for (
unsigned I = 0, N = Spec->getNumArgs();
I != N; ++
I)
4877 OnlyDeduced, Depth, Used);
4883 cast<AtomicType>(T)->getValueType(),
4884 OnlyDeduced, Depth, Used);
4887 case Type::DependentName:
4891 OnlyDeduced, Depth, Used);
4894 case Type::DependentTemplateSpecialization: {
4908 = cast<DependentTemplateSpecializationType>(T);
4913 for (
unsigned I = 0, N = Spec->getNumArgs();
I != N; ++
I)
4923 OnlyDeduced, Depth, Used);
4926 case Type::TypeOfExpr:
4929 cast<TypeOfExprType>(T)->getUnderlyingExpr(),
4930 OnlyDeduced, Depth, Used);
4933 case Type::Decltype:
4936 cast<DecltypeType>(T)->getUnderlyingExpr(),
4937 OnlyDeduced, Depth, Used);
4940 case Type::UnaryTransform:
4944 OnlyDeduced, Depth, Used);
4947 case Type::PackExpansion:
4949 cast<PackExpansionType>(T)->getPattern(),
4950 OnlyDeduced, Depth, Used);
4955 cast<AutoType>(T)->getDeducedType(),
4956 OnlyDeduced, Depth, Used);
4960 case Type::VariableArray:
4961 case Type::FunctionNoProto:
4964 case Type::ObjCInterface:
4965 case Type::ObjCObject:
4966 case Type::ObjCObjectPointer:
4967 case Type::UnresolvedUsing:
4969 #define TYPE(Class, Base)
4970 #define ABSTRACT_TYPE(Class, Base)
4971 #define DEPENDENT_TYPE(Class, Base)
4972 #define NON_CANONICAL_TYPE(Class, Base) case Type::Class:
4973 #include "clang/AST/TypeNodes.def"
4985 llvm::SmallBitVector &
Used) {
4986 switch (TemplateArg.
getKind()) {
5032 bool OnlyDeduced,
unsigned Depth,
5033 llvm::SmallBitVector &
Used) {
5042 for (
unsigned I = 0, N = TemplateArgs.
size();
I != N; ++
I)
5051 llvm::SmallBitVector &Deduced) {
5055 Deduced.resize(TemplateParams->
size());
5060 true, TemplateParams->
getDepth(), Deduced);
5071 llvm::SmallBitVector Deduced(TemplateParams->
size());
5075 return Deduced.any();
QualType BuildStdInitializerList(QualType Element, SourceLocation Loc)
Looks for the std::initializer_list template and instantiates it with Element, or emits an error if i...
unsigned getNumElements() const
bool hasObjCGCAttr() const
void copyTemplateArgumentsInto(TemplateArgumentListInfo &List) const
Copies the template arguments into the given structure.
ExprResult BuildExpressionFromIntegralTemplateArgument(const TemplateArgument &Arg, SourceLocation Loc)
Construct a new expression that refers to the given integral template argument with the given source-...
Defines the clang::ASTContext interface.
unsigned getNumInits() const
SourceLocation getEnd() const
Expr * getSizeExpr() const
FunctionDecl - An instance of this class is created to represent a function declaration or definition...
std::pair< llvm::PointerUnion< const TemplateTypeParmType *, NamedDecl * >, SourceLocation > UnexpandedParameterPack
static bool isSameTemplateArg(ASTContext &Context, const TemplateArgument &X, const TemplateArgument &Y)
Determine whether two template arguments are the same.
TemplateArgument getPackExpansionPattern() const
When the template argument is a pack expansion, returns the pattern of the pack expansion.
QualType getInjectedSpecializationType() const
Retrieves the injected specialization type for this partial specialization.
static DeducedTemplateArgument checkDeducedTemplateArguments(ASTContext &Context, const DeducedTemplateArgument &X, const DeducedTemplateArgument &Y)
Verify that the given, deduced template arguments are compatible.
unsigned getDepth() const
SuppressedDiagnosticsMap SuppressedDiagnostics
QualType BuildFunctionType(QualType T, MutableArrayRef< QualType > ParamTypes, SourceLocation Loc, DeclarationName Entity, const FunctionProtoType::ExtProtoInfo &EPI)
Build a function type.
bool isNonOverloadPlaceholderType() const
Test for a placeholder type other than Overload; see BuiltinType::isNonOverloadPlaceholderType.
llvm::iterator_range< pack_iterator > pack_elements() const
Iterator range referencing all of the elements of a template argument pack.
PointerType - C99 6.7.5.1 - Pointer Declarators.
A (possibly-)qualified type.
bool isConstantArrayType() const
bool hasExplicitTemplateArgs() const
Determines whether this expression had explicit template arguments.
TemplateDeductionResult
Describes the result of template argument deduction.
void MakeTrivial(ASTContext &Context, NestedNameSpecifier *Qualifier, SourceRange R)
Make a new nested-name-specifier from incomplete source-location information.
bool isLambdaConversionOperator(CXXConversionDecl *C)
llvm::APSInt getAsIntegral() const
Retrieve the template argument as an integral value.
ExtInfo withCallingConv(CallingConv cc) const
QualType getConversionType() const
Returns the type that this conversion function is converting to.
A stack-allocated class that identifies which local variable declaration instantiations are present i...
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.
QualType getQualifiedType(SplitQualType split) const
Un-split a SplitQualType.
const LangOptions & getLangOpts() const
CanQual< T > getUnqualifiedType() const
Retrieve the unqualified form of this type.
FunctionType - C99 6.7.5.3 - Function Declarators.
TemplateDecl * getAsTemplateDecl() const
Retrieve the underlying template declaration that this template name refers to, if known...
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...
CanQualType getSizeType() const
Return the unique type for "size_t" (C99 7.17), defined in <stddef.h>.
unsigned getIntWidth(QualType T) const
void setObjCLifetime(ObjCLifetime type)
The template argument is an expression, and we've not resolved it to one of the other forms yet...
std::string getTemplateArgumentBindingsText(const TemplateParameterList *Params, const TemplateArgumentList &Args)
Produces a formatted string that describes the binding of template parameters to template arguments...
bool isRecordType() const
SemaDiagnosticBuilder Diag(SourceLocation Loc, unsigned DiagID)
Emit a diagnostic.
Decl - This represents one declaration (or definition), e.g.
static bool IsPossiblyOpaquelyQualifiedType(QualType T)
Determines whether the given type is an opaque type that might be more qualified when instantiated...
AutoType * getContainedAutoType() const
Get the AutoType whose type will be deduced for a variable with an initializer of this type...
Defines the C++ template declaration subclasses.
Represents a C++11 auto or C++14 decltype(auto) type.
pack_iterator pack_begin() const
Iterator referencing the first argument of a template argument pack.
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.
TemplateSpecializationType(TemplateName T, const TemplateArgument *Args, unsigned NumArgs, QualType Canon, QualType Aliased)
bool hasErrorOccurred() const
Determine whether any SFINAE errors have been trapped.
QualType getPointeeType() const
The base class of the type hierarchy.
const IncompleteArrayType * getAsIncompleteArrayType(QualType T) const
DependentTemplateSpecializationType(ElaboratedTypeKeyword Keyword, NestedNameSpecifier *NNS, const IdentifierInfo *Name, unsigned NumArgs, const TemplateArgument *Args, QualType Canon)
unsigned getCVRQualifiers() const
Retrieve the set of CVR (const-volatile-restrict) qualifiers applied to this type.
Declaration of a variable template.
Represents an array type, per C99 6.7.5.2 - Array Declarators.
The template argument is a declaration that was provided for a pointer, reference, or pointer to member non-type template parameter.
Template argument deduction produced inconsistent deduced values for the given template parameter...
NestedNameSpecifier * getPrefix() const
Return the prefix of this nested name specifier.
NamedDecl * getParam(unsigned Idx)
bool compatiblyIncludes(Qualifiers other) const
Determines if these qualifiers compatibly include another set.
A container of type source information.
unsigned getIndex() const
Expr * getAsExpr() const
Retrieve the template argument as an expression.
const TemplateArgument & get(unsigned Idx) const
Retrieve the template argument at a given index.
Partial ordering of function templates for a call to a conversion function.
void SetPartiallySubstitutedPack(NamedDecl *Pack, const TemplateArgument *ExplicitArgs, unsigned NumExplicitArgs)
Note that the given parameter pack has been partially substituted via explicit specification of templ...
const ASTTemplateArgumentListInfo * getTemplateArgsAsWritten() const
Get the template arguments as written.
const llvm::APInt & getSize() const
This file provides some common utility functions for processing Lambda related AST Constructs...
VarTemplateDecl * getSpecializedTemplate() const
Retrieve the template that this specialization specializes.
RAII object that enters a new expression evaluation context.
VarDecl - An instance of this class is created to represent a variable declaration or definition...
void removeObjCLifetime()
ObjCLifetime getObjCLifetime() const
Represents an empty template argument, e.g., one that has not been deduced.
Extra information about a function prototype.
TemplateDeductionFlags
Various flags that control template argument deduction.
CallingConv getCallConv() const
AutoTypeKeyword getKeyword() const
uint64_t getTypeSize(QualType T) const
Return the size of the specified (complete) type T, in bits.
NamedDecl * getUnderlyingDecl()
Looks through UsingDecls and ObjCCompatibleAliasDecls for the underlying named decl.
RAII object used to temporarily allow the C++ 'this' expression to be used, with the given qualifiers...
Represents an explicit template argument list in C++, e.g., the "<int>" in "sort<int>".
Stores a list of template parameters for a TemplateDecl and its derived classes.
TemplateArgumentLoc SubstDefaultTemplateArgumentIfAvailable(TemplateDecl *Template, SourceLocation TemplateLoc, SourceLocation RAngleLoc, Decl *Param, SmallVectorImpl< TemplateArgument > &Converted, bool &HasDefaultArg)
If the given template parameter has a default template argument, substitute into that default templat...
static TemplateArgumentLoc getTrivialTemplateArgumentLoc(Sema &S, const TemplateArgument &Arg, QualType NTTPType, SourceLocation Loc)
Allocate a TemplateArgumentLoc where all locations have been initialized to the given location...
Whether we are performing template argument deduction for parameters and arguments in a top-level tem...
ParmVarDecl - Represents a parameter to a function.
Defines the clang::Expr interface and subclasses for C++ expressions.
TemplateParameter Param
The template parameter to which a template argument deduction failure refers.
bool isPackExpansion() const
Determine whether this template argument is a pack expansion.
SourceRange getSourceRange() const override LLVM_READONLY
Source range that this declaration covers.
The collection of all-type qualifiers we support.
QualType getArrayDecayedType(QualType T) const
Return the properly qualified result of decaying the specified array type to a pointer.
bool isTemplateVariadic() const
Determines whether this function prototype contains a parameter pack at the end.
Base wrapper for a particular "section" of type source info.
unsigned getNumParams() const
QualType getElementType() const
Represents a class template specialization, which refers to a class template with a given set of temp...
LocalInstantiationScope * CurrentInstantiationScope
The current instantiation scope used to store local variables.
void setDeducedFromArrayBound(bool Deduced)
Specify whether the given non-type template argument was deduced from an array bound.
QualType SubstAutoType(QualType TypeWithAuto, QualType Replacement)
Substitute Replacement for auto in TypeWithAuto.
static TemplateArgument getEmptyPack()
class LLVM_ALIGNAS(8) DependentTemplateSpecializationType const IdentifierInfo * Name
Represents a template specialization type whose template cannot be resolved, e.g. ...
bool wasDeducedFromArrayBound() const
For a non-type template argument, determine whether the template argument was deduced from an array b...
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 ...
Represents a dependent template name that cannot be resolved prior to template instantiation.
ArrayRef< QualType > getParamTypes() const
The template argument is an integral value stored in an llvm::APSInt that was provided for an integra...
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
FunctionDecl * getTemplatedDecl() const
Get the underlying function declaration of the template.
bool isAnyPointerType() const
static bool isVariadicFunctionTemplate(FunctionTemplateDecl *FunTmpl)
Determine whether this a function template whose parameter-type-list ends with a function parameter p...
The arguments included an overloaded function name that could not be resolved to a suitable function...
QualType adjustCCAndNoReturn(QualType ArgFunctionType, QualType FunctionType)
unsigned getCVRQualifiers() const
unsigned size() const
Retrieve the number of template arguments in this template argument list.
The iterator over UnresolvedSets.
bool hasSameType(QualType T1, QualType T2) const
Determine whether the given types T1 and T2 are equivalent.
virtual SourceRange getSourceRange() const LLVM_READONLY
Source range that this declaration covers.
Represents the result of substituting a set of types for a template type parameter pack...
QualType getTypeDeclType(const TypeDecl *Decl, const TypeDecl *PrevDecl=nullptr) const
Return the unique reference to the type for the specified type declaration.
bool hasSameUnqualifiedType(QualType T1, QualType T2) const
Determine whether the given types are equivalent after cvr-qualifiers have been removed.
Within template argument deduction from a function call, we are matching with a parameter type for wh...
Describes an C or C++ initializer list.
void adjustMemberFunctionCC(QualType &T, bool IsStatic, bool IsCtorOrDtor, SourceLocation Loc)
Adjust the calling convention of a method to be the ABI default if it wasn't specified explicitly...
FunctionTemplateDecl * getCanonicalDecl() override
Retrieves the canonical declaration of this template.
TemplateArgument getArgumentPack() const
bool isCompleteType(SourceLocation Loc, QualType T)
An rvalue reference type, per C++11 [dcl.ref].
static TemplateArgumentList * CreateCopy(ASTContext &Context, const TemplateArgument *Args, unsigned NumArgs)
Create a new template argument list that copies the given set of template arguments.
void setNameLoc(SourceLocation Loc)
bool HasFormOfMemberPointer
TemplateSpecCandidateSet - A set of generalized overload candidates, used in template specializations...
A convenient class for passing around template argument information.
const ASTTemplateArgumentListInfo * getTemplateArgsAsWritten() const
Get the template arguments as written.
CanProxy< U > getAs() const
Retrieve a canonical type pointer with a different static type, upcasting or downcasting as needed...
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...
static bool hasPackExpansionBeforeEnd(const TemplateArgument *Args, unsigned NumArgs)
Determine whether the given set of template arguments has a pack expansion that is not the last templ...
We are substituting template argument determined as part of template argument deduction for either a ...
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 TemplateTypeParmDecl * Create(const ASTContext &C, DeclContext *DC, SourceLocation KeyLoc, SourceLocation NameLoc, unsigned D, unsigned P, IdentifierInfo *Id, bool Typename, bool ParameterPack)
Substitution of the deduced template argument values resulted in an error.
SourceLocation RAngleLoc
The source location of the right angle bracket ('>').
bool isValueDependent() const
isValueDependent - Determines whether this expression is value-dependent (C++ [temp.dep.constexpr]).
QualifiedTemplateName * getAsQualifiedTemplateName() const
Retrieve the underlying qualified template name structure, if any.
RecordDecl * getDecl() const
FunctionDecl * getTemplateInstantiationPattern() const
Retrieve the function declaration from which this function could be instantiated, if it is an instant...
Template argument deduction exceeded the maximum template instantiation depth (which has already been...
void MarkDeducedTemplateParameters(const FunctionTemplateDecl *FunctionTemplate, llvm::SmallBitVector &Deduced)
static bool ConvertDeducedTemplateArgument(Sema &S, NamedDecl *Param, DeducedTemplateArgument Arg, NamedDecl *Template, QualType NTTPType, unsigned ArgumentPackIndex, TemplateDeductionInfo &Info, bool InFunctionTemplate, SmallVectorImpl< TemplateArgument > &Output)
Convert the given deduced template argument and add it to the set of fully-converted template argumen...
We are substituting explicit template arguments provided for a function template. ...
static TemplateArgument CreatePackCopy(ASTContext &Context, ArrayRef< TemplateArgument > Args)
Create a new template argument pack by copying the given set of template arguments.
TypeClass getTypeClass() const
DeclContext * getLexicalDeclContext()
getLexicalDeclContext - The declaration context where this Decl was lexically declared (LexicalDC)...
SmallVector< DeducedTemplateArgument, 4 > New
NestedNameSpecifierLoc getWithLocInContext(ASTContext &Context) const
Retrieve a nested-name-specifier with location information, copied into the given AST context...
A C++ lambda expression, which produces a function object (of unspecified type) that can be invoked l...
bool CheckTemplateArgumentList(TemplateDecl *Template, SourceLocation TemplateLoc, TemplateArgumentListInfo &TemplateArgs, bool PartialTemplateArgs, SmallVectorImpl< TemplateArgument > &Converted)
Check that the given template arguments can be be provided to the given template, converting the argu...
QualType OriginalParamType
detail::InMemoryDirectory::const_iterator I
static bool AdjustFunctionParmAndArgTypesForDeduction(Sema &S, TemplateParameterList *TemplateParams, QualType &ParamType, QualType &ArgType, Expr *Arg, unsigned &TDF)
Perform the adjustments to the parameter and argument types described in C++ [temp.deduct.call].
const DependentSizedArrayType * getAsDependentSizedArrayType(QualType T) const
virtual Decl * getCanonicalDecl()
Retrieves the "canonical" declaration of the given declaration.
static Sema::TemplateDeductionResult DeduceTemplateArgumentByListElement(Sema &S, TemplateParameterList *TemplateParams, QualType ParamType, Expr *Arg, TemplateDeductionInfo &Info, SmallVectorImpl< DeducedTemplateArgument > &Deduced, unsigned TDF)
Perform template argument deduction by matching a parameter type against a single expression...
Represents an extended vector type where either the type or size is dependent.
This object can be modified without requiring retains or releases.
const TemplateTypeParmType * getReplacedParameter() const
Gets the template parameter that was substituted for.
param_iterator param_begin()
static bool hasTemplateArgumentForDeduction(const TemplateArgument *&Args, unsigned &ArgIdx, unsigned &NumArgs)
Determine whether there is a template argument to be used for deduction.
TyLocType push(QualType T)
Pushes space for a new TypeLoc of the given type.
Class that aids in the construction of nested-name-specifiers along with source-location information ...
QualType getTemplateSpecializationType(TemplateName T, const TemplateArgument *Args, unsigned NumArgs, QualType Canon=QualType()) const
RAII class used to determine whether SFINAE has trapped any errors that occur during template argumen...
bool isTemplateParameterPack() const
isTemplateParameter - Determines whether this declaration is a template parameter pack...
static Sema::TemplateDeductionResult DeduceTemplateArguments(Sema &S, TemplateParameterList *TemplateParams, const TemplateArgument &Param, TemplateArgument Arg, TemplateDeductionInfo &Info, SmallVectorImpl< DeducedTemplateArgument > &Deduced)
void adjustDeducedFunctionResultType(FunctionDecl *FD, QualType ResultType)
Change the result type of a function type once it is deduced.
diag_iterator diag_end() const
Returns an iterator at the end of the sequence of suppressed diagnostics.
const TemplateArgumentLoc * getTemplateArgs() const
Retrieve the template arguments.
ExtInfo getExtInfo() const
Sema - This implements semantic analysis and AST building for C.
static bool isAtLeastAsSpecializedAs(Sema &S, SourceLocation Loc, FunctionTemplateDecl *FT1, FunctionTemplateDecl *FT2, TemplatePartialOrderingContext TPOC, unsigned NumCallArguments1)
Determine whether the function template FT1 is at least as specialized as FT2.
bool CheckTemplateArgument(NamedDecl *Param, TemplateArgumentLoc &Arg, NamedDecl *Template, SourceLocation TemplateLoc, SourceLocation RAngleLoc, unsigned ArgumentPackIndex, SmallVectorImpl< TemplateArgument > &Converted, CheckTemplateArgumentKind CTAK=CTAK_Specified)
Check that the given template argument corresponds to the given template parameter.
QualType getParamType(unsigned i) const
Represents a prototype with parameter type info, e.g.
void reset(TemplateArgumentList *NewDeduced)
Provide a new template argument list that contains the results of template argument deduction...
bool isParameterPack() const
Determine whether this parameter is actually a function parameter pack.
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...
param_type_iterator param_type_begin() const
static bool hasDeducibleTemplateParameters(Sema &S, FunctionTemplateDecl *FunctionTemplate, QualType T)
Template argument deduction did not deduce a value for every template parameter.
bool isGenericLambda() const
Determine whether this class describes a generic lambda function object (i.e.
SourceLocation getTypeSpecStartLoc() const
TemplateParameterList * getTemplateParameters() const
Get the list of template parameters.
QualType getPointeeType() const
If this is a pointer, ObjC object pointer, or block pointer, this returns the respective pointee...
bool isFunctionPointerType() const
static bool isSimpleTemplateIdType(QualType T)
Determine whether the given type T is a simple-template-id type.
static std::pair< unsigned, unsigned > getDepthAndIndex(NamedDecl *ND)
Retrieve the depth and index of a template parameter.
Represents an array type in C++ whose size is a value-dependent expression.
const Type * getTypeForDecl() const
unsigned getTypeQualifiers() const
QualType getPointeeType() const
ValueDecl - Represent the declaration of a variable (in which case it is an lvalue) a function (in wh...
bool isUndeducedType() const
Determine whether this type is an undeduced type, meaning that it somehow involves a C++11 'auto' typ...
Expr - This represents one expression.
TemplateDeductionResult FinishTemplateArgumentDeduction(FunctionTemplateDecl *FunctionTemplate, SmallVectorImpl< DeducedTemplateArgument > &Deduced, unsigned NumExplicitlySpecified, FunctionDecl *&Specialization, sema::TemplateDeductionInfo &Info, SmallVectorImpl< OriginalCallArg > const *OriginalCallArgs=nullptr, bool PartialOverloading=false)
Finish template argument deduction for a function template, checking the deduced template arguments f...
TemplateParameterList * get()
DeducedPack(unsigned Index)
When performing template argument deduction for a function template, there were too many call argumen...
decls_iterator decls_end() const
Declaration of a template type parameter.
SourceLocation getNameLoc() const
Gets the location of the name.
TemplateParameterList * getTemplateParameters() const
Get the list of template parameters.
static FindResult find(Expr *E)
Finds the overloaded expression in the given expression E of OverloadTy.
unsigned NumTemplateArgs
The number of template arguments in TemplateArgs.
This file defines the classes used to store parsed information about declaration-specifiers and decla...
The template argument is a null pointer or null pointer to member that was provided for a non-type te...
ExprResult BuildExpressionFromDeclTemplateArgument(const TemplateArgument &Arg, QualType ParamType, SourceLocation Loc)
Given a non-type template argument that refers to a declaration and the type of its corresponding non...
void setInvalidDecl(bool Invalid=true)
setInvalidDecl - Indicates the Decl had a semantic error.
diag_iterator diag_begin() const
Returns an iterator at the beginning of the sequence of suppressed diagnostics.
const ParmVarDecl * getParamDecl(unsigned i) const
ArgKind getKind() const
Return the kind of stored template argument.
ExtProtoInfo getExtProtoInfo() const
void completeExprArrayBound(Expr *E)
DeclContext * getDeclContext()
When performing template argument deduction for a function template, there were too few call argument...
ExprResult CheckPlaceholderExpr(Expr *E)
Check for operands with placeholder types and complain if found.
NonTypeTemplateParmDecl - Declares a non-type template parameter, e.g., "Size" in.
Represents a C++ template name within the type system.
ArrayRef< Expr * > inits()
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...
QualType getType() const
Get the type for which this source info wrapper provides information.
TemplateDeductionResult SubstituteExplicitTemplateArguments(FunctionTemplateDecl *FunctionTemplate, TemplateArgumentListInfo &ExplicitTemplateArgs, SmallVectorImpl< DeducedTemplateArgument > &Deduced, SmallVectorImpl< QualType > &ParamTypes, QualType *FunctionType, sema::TemplateDeductionInfo &Info)
Substitute the explicitly-provided template arguments into the given function template according to C...
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...
bool hasTrailingReturn() const
Within template argument deduction from overload resolution per C++ [over.over] allow matching functi...
DeclContext * getParent()
getParent - Returns the containing DeclContext.
TemplateName getAsTemplateOrTemplatePattern() const
Retrieve the template argument as a template name; if the argument is a pack expansion, return the pattern as a template name.
const TemplateArgument * data() const
Retrieve a pointer to the template argument list.
Data structure that captures multiple levels of template argument lists for use in template instantia...
bool DeduceReturnType(FunctionDecl *FD, SourceLocation Loc, bool Diagnose=true)
CXXMethodDecl * getLambdaCallOperator() const
Retrieve the lambda call operator of the closure type if this is a closure type.
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.
ClassTemplateDecl * getSpecializedTemplate() const
Retrieve the template that this specialization specializes.
Represents a reference to a non-type template parameter that has been substituted with a template arg...
class LLVM_ALIGNAS(8) TemplateSpecializationType unsigned NumArgs
Represents a type template specialization; the template must be a class template, a type alias templa...
const Type * getAsType() const
Retrieve the type stored in this nested name specifier.
After substituting deduced template arguments, a dependent parameter type did not match the correspon...
QualType getElementType() const
bool isStrictSupersetOf(Qualifiers Other) const
Determine whether this set of qualifiers is a strict superset of another set of qualifiers, not considering qualifier compatibility.
Represents a C++ conversion function within a class.
The result type of a method or function.
void removeCVRQualifiers(unsigned mask)
CallingConv
CallingConv - Specifies the calling convention that a function uses.
unsigned getDepth() const
Get the depth of this template parameter list in the set of template parameter lists.
const TypeClass * getTypePtr() const
Captures a template argument whose value has been deduced via c++ template argument deduction...
bool hasObjCLifetime() const
static bool hasInconsistentOrSupersetQualifiersOf(QualType ParamType, QualType ArgType)
Determine whether the parameter has qualifiers that are either inconsistent with or a superset of the...
decls_iterator decls_begin() const
bool getNoReturnAttr() const
Determine whether this function type includes the GNU noreturn attribute.
bool isDependentSizedArrayType() const
static void MarkUsedTemplateParameters(ASTContext &Ctx, QualType T, bool OnlyDeduced, unsigned Level, llvm::SmallBitVector &Deduced)
Mark the template parameters that are used by the given type.
SmallVector< DeducedPack *, 8 > PendingDeducedPacks
Information on packs that we're currently expanding.
void ResetPartiallySubstitutedPack()
Reset the partially-substituted pack when it is no longer of interest.
There is no lifetime qualification on this type.
TypeLoc getTypeLoc() const
Return the TypeLoc wrapper for the type source info.
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...
NamedDecl * getPartiallySubstitutedPack(const TemplateArgument **ExplicitArgs=nullptr, unsigned *NumExplicitArgs=nullptr) const
Retrieve the partially-substitued template parameter pack.
ActionResult - This structure is used while parsing/acting on expressions, stmts, etc...
A stack object to be created when performing template instantiation.
Stores a list of template parameters for a TemplateDecl and its derived classes.
static Sema::TemplateDeductionResult DeduceTemplateArgumentsByTypeMatch(Sema &S, TemplateParameterList *TemplateParams, QualType Param, QualType Arg, TemplateDeductionInfo &Info, SmallVectorImpl< DeducedTemplateArgument > &Deduced, unsigned TDF, bool PartialOrdering=false)
Deduce the template arguments by comparing the parameter type and the argument type (C++ [temp...
bool Subst(const TemplateArgumentLoc *Args, unsigned NumArgs, TemplateArgumentListInfo &Result, const MultiLevelTemplateArgumentList &TemplateArgs)
The template argument was deduced from an array bound via template argument deduction.
DeduceAutoResult
Result type of DeduceAutoType.
Encodes a location in the source.
static TemplateParameter makeTemplateParameter(Decl *D)
Helper function to build a TemplateParameter when we don't know its type statically.
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.
bool hasSameTemplateName(TemplateName X, TemplateName Y)
Determine whether the given template names refer to the same template.
TemplateName getAsTemplate() const
Retrieve the template name for a template name argument.
const TemplateArgument * iterator
RefQualifierKind getRefQualifier() const
Retrieve the ref-qualifier associated with this function type.
bool IsNoReturnConversion(QualType FromType, QualType ToType, QualType &ResultTy)
Determine whether the conversion from FromType to ToType is a valid conversion that strips "noreturn"...
static Sema::TemplateDeductionResult FinishTemplateArgumentDeduction(Sema &S, ClassTemplatePartialSpecializationDecl *Partial, const TemplateArgumentList &TemplateArgs, SmallVectorImpl< DeducedTemplateArgument > &Deduced, TemplateDeductionInfo &Info)
Complete template argument deduction for a class template partial specialization. ...
Template argument deduction failed due to inconsistent cv-qualifiers on a template parameter type tha...
TypeSourceInfo * getTrivialTypeSourceInfo(QualType T, SourceLocation Loc=SourceLocation()) const
Allocate a TypeSourceInfo where all locations have been initialized to a given location, which defaults to the empty location.
static bool isSameTemplate(TemplateDecl *T1, TemplateDecl *T2)
Determine if the two templates are equivalent.
static QualType getUnderlyingType(const SubRegion *R)
Within template argument deduction from a function call, we are matching in a case where we ignore cv...
Represents a static or instance method of a struct/union/class.
SourceLocation getNameLoc() const
Represents a C++ nested name specifier, such as "\::std::vector<int>::".
ExtInfo withNoReturn(bool noReturn) const
The declaration was invalid; do nothing.
const ConstantArrayType * getAsConstantArrayType(QualType T) const
void DiagnoseAutoDeductionFailure(VarDecl *VDecl, Expr *Init)
void reserve(size_t Requested)
Ensures that this buffer has at least as much capacity as described.
TemplateDeductionResult DeduceTemplateArguments(ClassTemplatePartialSpecializationDecl *Partial, const TemplateArgumentList &TemplateArgs, sema::TemplateDeductionInfo &Info)
Perform template argument deduction to determine whether the given template arguments match the given...
TypeSourceInfo * SubstAutoTypeSourceInfo(TypeSourceInfo *TypeWithAuto, QualType Replacement)
Substitute Replacement for auto in TypeWithAuto.
Within template argument deduction from a function call, we are matching in a case where we can perfo...
ImplicitCastExpr - Allows us to explicitly represent implicit type conversions, which have no direct ...
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.
static bool isSameDeclaration(Decl *X, Decl *Y)
Determine whether two declaration pointers refer to the same declaration.
static bool CheckOriginalCallArgDeduction(Sema &S, Sema::OriginalCallArg OriginalArg, QualType DeducedA)
Check whether the deduced argument type for a call to a function template matches the actual argument...
bool isMemberFunctionPointerType() const
An rvalue ref-qualifier was provided (&&).
bool refersToBitField() const
Returns true if this expression is a gl-value that potentially refers to a bit-field.
ValueDecl * getAsDecl() const
Retrieve the declaration for a declaration non-type template argument.
SourceLocation getExprLoc() const LLVM_READONLY
getExprLoc - Return the preferred location for the arrow when diagnosing a problem with a generic exp...
QualType getPointeeType() const
QualType getFunctionType(QualType ResultTy, ArrayRef< QualType > Args, const FunctionProtoType::ExtProtoInfo &EPI) const
Return a normal function type with a typed argument list.
Represents a pack expansion of types.
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...
static QualType GetTypeOfFunction(Sema &S, const OverloadExpr::FindResult &R, FunctionDecl *Fn)
Gets the type of a function for template-argument-deducton purposes when it's considered as part of a...
Expr * getSizeExpr() const
bool isInitCapture() const
Whether this variable is the implicit variable for a lambda init-capture.
Represents a template argument.
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.
void collectUnexpandedParameterPacks(TemplateArgument Arg, SmallVectorImpl< UnexpandedParameterPack > &Unexpanded)
Collect the set of unexpanded parameter packs within the given template argument. ...
Represents a template name that was expressed as a qualified name.
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 const Type * getElementType(const Expr *BaseExpr)
bool SubstParmTypes(SourceLocation Loc, ParmVarDecl **Params, unsigned NumParams, const MultiLevelTemplateArgumentList &TemplateArgs, SmallVectorImpl< QualType > &ParamTypes, SmallVectorImpl< ParmVarDecl * > *OutParams=nullptr)
Substitute the given template arguments into the given set of parameters, producing the set of parame...
Qualifiers withoutObjCLifetime() const
DeclContext - This is used only as base class of specific decl types that can act as declaration cont...
static QualType ResolveOverloadForDeduction(Sema &S, TemplateParameterList *TemplateParams, Expr *Arg, QualType ParamType, bool ParamWasReference)
Apply the deduction rules for overload sets.
The base class of all kinds of template declarations (e.g., class, function, etc.).
const TemplateArgumentList & getTemplateArgs() const
Retrieve the template arguments of the variable template specialization.
The template argument is a pack expansion of a template name that was provided for a template templat...
static bool DeduceFromInitializerList(Sema &S, TemplateParameterList *TemplateParams, QualType AdjustedParamType, InitListExpr *ILE, TemplateDeductionInfo &Info, SmallVectorImpl< DeducedTemplateArgument > &Deduced, unsigned TDF, Sema::TemplateDeductionResult &Result)
Attempt template argument deduction from an initializer list deemed to be an argument in a function c...
TemplateName getCanonicalTemplateName(TemplateName Name) const
Retrieves the "canonical" template name that refers to a given template.
bool isInvalidDecl() const
bool hasNonTrivialObjCLifetime() const
True if the lifetime is neither None or ExplicitNone.
void HandleFunctionTypeMismatch(PartialDiagnostic &PDiag, QualType FromType, QualType ToType)
HandleFunctionTypeMismatch - Gives diagnostic information for differeing function types...
A non-depnedent component of the parameter did not match the corresponding component of the argument...
QualType getPointerType(QualType T) const
Return the uniqued reference to the type for a pointer to the specified type.
OverloadExpr * Expression
Represents a C++11 pack expansion that produces a sequence of expressions.
bool isLValue() const
isLValue - True if this expression is an "l-value" according to the rules of the current language...
param_type_iterator param_type_end() const
bool isNull() const
Determine whether this template argument has no value.
SourceLocation LAngleLoc
The source location of the left angle bracket ('<').
detail::InMemoryDirectory::const_iterator E
A pointer to member type per C++ 8.3.3 - Pointers to members.
const FunctionType * adjustFunctionType(const FunctionType *Fn, FunctionType::ExtInfo EInfo)
Change the ExtInfo on a function type.
void setCVRQualifiers(unsigned mask)
CanQualType getCanonicalType(QualType T) const
Return the canonical (structural) type corresponding to the specified potentially non-canonical type ...
bool isLValueReferenceType() const
SourceLocation getPointOfInstantiation() const
Retrieve the (first) point of instantiation of a function template specialization or a member of a cl...
No template argument deduction flags, which indicates the strictest results for template argument ded...
Allow non-dependent types to differ, e.g., when performing template argument deduction from a functio...
void InstantiateFunctionDefinition(SourceLocation PointOfInstantiation, FunctionDecl *Function, bool Recursive=false, bool DefinitionRequired=false)
Instantiate the definition of the given function from its template.
unsigned getDepth() const
Get the nesting depth of the template parameter.
bool isRValueReferenceType() const
QualType getNonReferenceType() const
If Type is a reference type (e.g., const int&), returns the type that the reference refers to ("const...
Represents a pointer to an Objective C object.
A helper class that allows the use of isa/cast/dyncast to detect TagType objects of structs/unions/cl...
Complex values, per C99 6.2.5p11.
static Sema::TemplateDeductionResult DeduceNonTypeTemplateArgument(Sema &S, NonTypeTemplateParmDecl *NTTP, llvm::APSInt Value, QualType ValueType, bool DeducedFromArrayBound, TemplateDeductionInfo &Info, SmallVectorImpl< DeducedTemplateArgument > &Deduced)
Deduce the value of the given non-type template parameter from the given constant.
Location wrapper for a TemplateArgument.
The template argument was specified in the code or was instantiated with some deduced template argume...
const T * getAs() const
Member-template getAs<specific type>'.
unsigned getTypeQuals() const
TemplateArgumentList * take()
Take ownership of the deduced template argument list.
QualType getIntegralType() const
Retrieve the type of the integral value.
bool isFunctionType() const
NestedNameSpecifier * getQualifier() const
ExtVectorType - Extended vector type.
QualType BuildDecltypeType(Expr *E, SourceLocation Loc, bool AsUnevaluated=true)
If AsUnevaluated is false, E is treated as though it were an evaluated context, such as when building...
Base for LValueReferenceType and RValueReferenceType.
unsigned getAddressSpace() const
FriendObjectKind getFriendObjectKind() const
Determines whether this declaration is the object of a friend declaration and, if so...
The template argument is a type.
Deduction failed; that's all we know.
SourceLocation getLocation() const
Returns the location at which template argument is occurring.
The template argument is actually a parameter pack.
QualType getPointeeType() const
A template argument list.
const TemplateArgumentList & getTemplateArgs() const
Retrieve the template arguments of the class template specialization.
DependentTemplateName * getAsDependentTemplateName() const
Retrieve the underlying dependent template name structure, if any.
X
Add a minimal nested name specifier fixit hint to allow lookup of a tag name from an outer enclosing ...
const Type * getClass() const
static void SubstAutoWithinFunctionReturnType(FunctionDecl *F, QualType TypeToReplaceAutoWith, Sema &S)
Given a function declaration (e.g.
QualType getNullPtrType() const
Retrieve the type for null non-type template argument.
unsigned getFullDataSize() const
Returns the size of the type source info data block.
bool hasAddressSpace() const
unsigned pack_size() const
The number of template arguments in the given template argument pack.
QualType getUnqualifiedType() const
Retrieve the unqualified variant of the given type, removing as little sugar as possible.
Represents a C++ struct/union/class.
BoundNodesTreeBuilder *const Builder
bool isObjCObjectPointerType() const
bool isPlaceholderType() const
Test for a type which does not represent an actual type-system type but is instead used as a placehol...
The template argument is a template name that was provided for a template template parameter...
Represents a C array with an unspecified size.
static Sema::TemplateDeductionResult SpecializeCorrespondingLambdaCallOperatorAndInvoker(CXXConversionDecl *ConversionSpecialized, SmallVectorImpl< DeducedTemplateArgument > &DeducedArguments, QualType ReturnTypeOfDestFunctionPtr, TemplateDeductionInfo &TDInfo, Sema &S)
Given a specialized conversion operator of a generic lambda create the corresponding specializations ...
TPOC
The context in which partial ordering of function templates occurs.
static NonTypeTemplateParmDecl * getDeducedParameterFromExpr(Expr *E)
If the given expression is of a form that permits the deduction of a non-type template parameter...
Location information for a TemplateArgument.
TemplateArgument SecondArg
The second template argument to which the template argument deduction failure refers.
Declaration of a class template.
Partial ordering of function templates for a function call.
TemplateParameterList * getTemplateParameters() const
Get the list of template parameters.
pack_iterator pack_end() const
Iterator referencing one past the last argument of a template argument pack.
A pack that we're currently deducing.
DeducedTemplateArgument Saved
QualType getPattern() const
Retrieve the pattern of this pack expansion, which is the type that will be repeatedly instantiated w...
Decl * SubstDecl(Decl *D, DeclContext *Owner, const MultiLevelTemplateArgumentList &TemplateArgs)
ClassTemplatePartialSpecializationDecl * getMoreSpecializedPartialSpecialization(ClassTemplatePartialSpecializationDecl *PS1, ClassTemplatePartialSpecializationDecl *PS2, SourceLocation Loc)
Returns the more specialized class template partial specialization according to the rules of partial ...
static Qualifiers fromCVRMask(unsigned CVR)
bool isIncompleteArrayType() const
static Decl::Kind getKind(const Decl *D)
bool IsQualificationConversion(QualType FromType, QualType ToType, bool CStyle, bool &ObjCLifetimeConversion)
IsQualificationConversion - Determines whether the conversion from an rvalue of type FromType to ToTy...
A reference to a declared variable, function, enum, etc.
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.
unsigned CallArgIndex
The index of the function argument that caused a deduction failure.
const Expr * getInit(unsigned Init) const
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.
DeduceAutoResult DeduceAutoType(TypeSourceInfo *AutoType, Expr *&Initializer, QualType &Result)
static bool hasSameExtendedValue(llvm::APSInt X, llvm::APSInt Y)
Compare two APSInts, extending and switching the sign as necessary to compare their values regardless...
Wrapper for template type parameters.
bool isParameterPack() const
Whether this declaration is a parameter pack.
SourceLocation getLocation() const
FunctionDecl * getCanonicalDecl() override
Retrieves the "canonical" declaration of the given declaration.
NamedDecl - This represents a decl with a name.
Partial ordering of function templates in other contexts, e.g., taking the address of a function temp...
void MarkUsedTemplateParameters(const TemplateArgumentList &TemplateArgs, bool OnlyDeduced, unsigned Depth, llvm::SmallBitVector &Used)
Mark which template parameters can be deduced from a given template argument list.
static void AddImplicitObjectParameterType(ASTContext &Context, CXXMethodDecl *Method, SmallVectorImpl< QualType > &ArgTypes)
If this is a non-static member function,.
The template argument was deduced via template argument deduction.
bool isNull() const
Return true if this QualType doesn't point to a type yet.
void setType(QualType newType)
void removeAddressSpace()
const TemplateArgument & getArgument() const
brief A function argument from which we performed template argument
The explicitly-specified template arguments were not valid template arguments for the given template...
Represents the canonical version of C arrays with a specified constant size.
Declaration of a template function.
A class which abstracts out some details necessary for making a call.
QualType getUnqualifiedArrayType(QualType T, Qualifiers &Quals)
Return this type as a completely-unqualified array type, capturing the qualifiers in Quals...
DeducedTemplateArgument DeferredDeduction
unsigned getIndex() const
Get the index of the template parameter within its parameter list.
TypeSourceInfo * SubstType(TypeSourceInfo *T, const MultiLevelTemplateArgumentList &TemplateArgs, SourceLocation Loc, DeclarationName Entity)
Perform substitution on the type T with a given set of template arguments.
Qualifiers getQualifiers() const
Retrieve the set of qualifiers applied to this type.
bool isPointerType() const
QualType getDeducedType() const
Get the type deduced for this auto type, or null if it's either not been deduced or was deduced to a ...