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);
109 TemplateDeductionInfo &Info,
110 SmallVectorImpl<DeducedTemplateArgument> &Deduced,
111 bool NumberOfArgumentsMustMatch);
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();
143 return X->getCanonicalDecl() == Y->getCanonicalDecl();
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!");
291 QualType ValueType,
bool DeducedFromArrayBound, TemplateDeductionInfo &Info,
292 SmallVectorImpl<DeducedTemplateArgument> &Deduced) {
294 "Cannot deduce non-type template argument with depth > 0");
297 DeducedFromArrayBound);
303 Info.FirstArg = Deduced[NTTP->
getIndex()];
304 Info.SecondArg = NewDeduced;
320 TemplateDeductionInfo &Info,
321 SmallVectorImpl<DeducedTemplateArgument> &Deduced) {
323 "Cannot deduce non-type template argument with depth > 0");
325 "Expression template argument must be type- or value-dependent.");
334 Info.FirstArg = Deduced[NTTP->
getIndex()];
335 Info.SecondArg = NewDeduced;
351 TemplateDeductionInfo &Info,
352 SmallVectorImpl<DeducedTemplateArgument> &Deduced) {
354 "Cannot deduce non-type template argument with depth > 0");
356 D = D ? cast<ValueDecl>(D->getCanonicalDecl()) :
nullptr;
364 Info.FirstArg = Deduced[NTTP->
getIndex()];
365 Info.SecondArg = NewDeduced;
378 TemplateDeductionInfo &Info,
379 SmallVectorImpl<DeducedTemplateArgument> &Deduced) {
388 = dyn_cast<TemplateTemplateParmDecl>(ParamDecl)) {
391 Deduced[TempParam->getIndex()],
393 if (Result.isNull()) {
394 Info.Param = TempParam;
395 Info.FirstArg = Deduced[TempParam->getIndex()];
396 Info.SecondArg = NewDeduced;
400 Deduced[TempParam->getIndex()] = Result;
437 TemplateDeductionInfo &Info,
438 SmallVectorImpl<DeducedTemplateArgument> &Deduced) {
439 assert(Arg.
isCanonical() &&
"Argument type must be canonical");
443 = dyn_cast<TemplateSpecializationType>(Arg)) {
447 Param->getTemplateName(),
448 SpecArg->getTemplateName(),
457 Param->getNumArgs(), SpecArg->getArgs(),
458 SpecArg->getNumArgs(), Info, Deduced,
484 Param->getTemplateName(),
491 S, TemplateParams, Param->getArgs(), Param->getNumArgs(),
493 Info, Deduced,
true);
500 case Type::TypeOfExpr:
502 case Type::DependentName:
504 case Type::UnresolvedUsing:
505 case Type::TemplateTypeParm:
508 case Type::ConstantArray:
509 case Type::IncompleteArray:
510 case Type::VariableArray:
511 case Type::DependentSizedArray:
513 cast<ArrayType>(T)->getElementType());
521 static std::pair<unsigned, unsigned>
524 return std::make_pair(TTP->getDepth(), TTP->getIndex());
527 return std::make_pair(NTTP->getDepth(), NTTP->getIndex());
534 static std::pair<unsigned, unsigned>
538 return std::make_pair(TTP->getDepth(), TTP->getIndex());
577 class PackDeductionScope {
582 :
S(S), TemplateParams(TemplateParams), Deduced(Deduced), Info(Info) {
586 llvm::SmallBitVector SawIndices(TemplateParams->
size());
589 for (
unsigned I = 0, N = Unexpanded.size();
I != N; ++
I) {
590 unsigned Depth, Index;
592 if (Depth == 0 && !SawIndices[Index]) {
593 SawIndices[Index] =
true;
598 Pack.
Saved = Deduced[Index];
601 Packs.push_back(Pack);
605 assert(!Packs.empty() &&
"Pack expansion without unexpanded packs?");
607 for (
auto &Pack : Packs) {
618 unsigned NumExplicitArgs;
621 &ExplicitArgs, &NumExplicitArgs);
622 if (PartiallySubstitutedPack &&
624 Pack.New.append(ExplicitArgs, ExplicitArgs + NumExplicitArgs);
629 ~PackDeductionScope() {
630 for (
auto &Pack : Packs)
635 void nextPackElement() {
639 for (
auto &Pack : Packs) {
641 if (!DeducedArg.
isNull()) {
642 Pack.New.push_back(DeducedArg);
654 for (
auto &Pack : Packs) {
656 Deduced[Pack.Index] = Pack.Saved;
660 if (HasAnyArguments && Pack.New.empty()) {
661 if (Pack.DeferredDeduction.isNull()) {
668 NewPack = Pack.DeferredDeduction;
670 }
else if (Pack.New.empty()) {
676 std::copy(Pack.New.begin(), Pack.New.end(), ArgumentPack);
679 Pack.New[0].wasDeducedFromArrayBound());
685 if (Pack.Outer->DeferredDeduction.isNull()) {
688 Pack.Outer->DeferredDeduction = NewPack;
691 Loc = &Pack.Outer->DeferredDeduction;
693 Loc = &Deduced[Pack.Index];
702 if (!Result.
isNull() && !Pack.DeferredDeduction.isNull()) {
704 NewPack = Pack.DeferredDeduction;
765 const QualType *Params,
unsigned NumParams,
767 TemplateDeductionInfo &Info,
768 SmallVectorImpl<DeducedTemplateArgument> &Deduced,
770 bool PartialOrdering =
false) {
772 if (NumParams != NumArgs &&
773 !(NumParams && isa<PackExpansionType>(Params[NumParams - 1])) &&
774 !(NumArgs && isa<PackExpansionType>(Args[NumArgs - 1])))
782 unsigned ArgIdx = 0, ParamIdx = 0;
783 for (; ParamIdx != NumParams; ++ParamIdx) {
791 if (ArgIdx >= NumArgs)
794 if (isa<PackExpansionType>(Args[ArgIdx])) {
804 Params[ParamIdx], Args[ArgIdx],
817 if (ParamIdx + 1 < NumParams)
828 PackDeductionScope PackScope(S, TemplateParams, Deduced, Info, Pattern);
830 bool HasAnyArguments =
false;
831 for (; ArgIdx <
NumArgs; ++ArgIdx) {
832 HasAnyArguments =
true;
837 Args[ArgIdx], Info, Deduced,
838 TDF, PartialOrdering))
841 PackScope.nextPackElement();
846 if (
auto Result = PackScope.finish(HasAnyArguments))
851 if (ArgIdx < NumArgs)
864 if (ParamQs == ArgQs)
901 if (!ParamFunction || !ArgFunction)
942 TemplateDeductionInfo &Info,
943 SmallVectorImpl<DeducedTemplateArgument> &Deduced,
945 bool PartialOrdering) {
954 = dyn_cast<PackExpansionType>(Arg))
955 Arg = ArgExpansion->getPattern();
957 if (PartialOrdering) {
1039 TDF &= ~TDF_TopLevelParameterTypeList;
1043 if (isa<TemplateTypeParmType>(ParamRef->getPointeeType()) &&
1044 !ParamRef->getPointeeType().getQualifiers())
1064 unsigned Index = TemplateTypeParm->getIndex();
1065 bool RecanonicalizeArg =
false;
1069 if (isa<ArrayType>(Arg)) {
1074 RecanonicalizeArg =
true;
1082 Info.Param = cast<TemplateTypeParmDecl>(TemplateParams->
getParam(Index));
1088 assert(TemplateTypeParm->getDepth() == 0 &&
"Can't deduce with depth > 0");
1109 Info.Param = cast<TemplateTypeParmDecl>(TemplateParams->
getParam(Index));
1126 if (RecanonicalizeArg)
1134 Info.Param = cast<TemplateTypeParmDecl>(TemplateParams->
getParam(Index));
1135 Info.FirstArg = Deduced[Index];
1136 Info.SecondArg = NewDeduced;
1140 Deduced[Index] = Result;
1152 if (isa<SubstTemplateTypeParmPackType>(Param))
1185 ParamUnqualType == ArgUnqualType;
1192 #define NON_CANONICAL_TYPE(Class, Base) \
1193 case Type::Class: llvm_unreachable("deducing non-canonical type: " #Class);
1194 #define TYPE(Class, Base)
1195 #include "clang/AST/TypeNodes.def"
1197 case Type::TemplateTypeParm:
1198 case Type::SubstTemplateTypeParmPack:
1199 llvm_unreachable(
"Type nodes handled above");
1204 case Type::VariableArray:
1206 case Type::FunctionNoProto:
1209 case Type::ObjCObject:
1210 case Type::ObjCInterface:
1211 case Type::ObjCObjectPointer: {
1215 if (TDF & TDF_IgnoreQualifiers) {
1227 cast<ComplexType>(Param)->getElementType(),
1228 ComplexArg->getElementType(),
1229 Info, Deduced, TDF);
1237 cast<AtomicType>(Param)->getValueType(),
1238 AtomicArg->getValueType(),
1239 Info, Deduced, TDF);
1244 case Type::Pointer: {
1257 cast<PointerType>(Param)->getPointeeType(),
1259 Info, Deduced, SubTDF);
1263 case Type::LValueReference: {
1270 cast<LValueReferenceType>(Param)->getPointeeType(),
1275 case Type::RValueReference: {
1282 cast<RValueReferenceType>(Param)->getPointeeType(),
1288 case Type::IncompleteArray: {
1291 if (!IncompleteArrayArg)
1298 Info, Deduced, SubTDF);
1302 case Type::ConstantArray: {
1305 if (!ConstantArrayArg)
1311 return Sema::TDK_NonDeducedMismatch;
1317 Info, Deduced, SubTDF);
1321 case Type::DependentSizedArray: {
1335 Info, Deduced, SubTDF))
1347 "Cannot deduce non-type template argument at depth > 0");
1349 = dyn_cast<ConstantArrayType>(ArrayArg)) {
1350 llvm::APSInt Size(ConstantArrayArg->getSize());
1357 = dyn_cast<DependentSizedArrayType>(ArrayArg))
1358 if (DependentArrayArg->getSizeExpr())
1360 DependentArrayArg->getSizeExpr(),
1370 case Type::FunctionProto: {
1374 if (!FunctionProtoArg)
1378 cast<FunctionProtoType>(Param);
1385 return Sema::TDK_NonDeducedMismatch;
1398 FunctionProtoArg->
getNumParams(), Info, Deduced, SubTDF);
1401 case Type::InjectedClassName: {
1404 Param = cast<InjectedClassNameType>(Param)
1405 ->getInjectedSpecializationType();
1406 assert(isa<TemplateSpecializationType>(Param) &&
1407 "injected class name is not a template specialization type");
1416 case Type::TemplateSpecialization: {
1418 cast<TemplateSpecializationType>(Param);
1431 S, TemplateParams, SpecParam, Arg, Info, Deduced);
1454 Deduced = DeducedOrig;
1459 llvm::SmallPtrSet<const RecordType *, 8> Visited;
1461 ToVisit.push_back(RecordT);
1462 bool Successful =
false;
1464 while (!ToVisit.empty()) {
1466 const RecordType *NextT = ToVisit.pop_back_val();
1469 if (!Visited.insert(NextT).second)
1474 if (NextT != RecordT) {
1475 TemplateDeductionInfo BaseInfo(Info.getLocation());
1478 QualType(NextT, 0), BaseInfo, Deduced);
1490 std::swap(SuccessfulDeduced, Deduced);
1492 Info.Param = BaseInfo.Param;
1493 Info.FirstArg = BaseInfo.FirstArg;
1494 Info.SecondArg = BaseInfo.SecondArg;
1497 Deduced = DeducedOrig;
1502 for (
const auto &
Base : Next->
bases()) {
1503 assert(
Base.getType()->isRecordType() &&
1504 "Base class that isn't a record?");
1510 std::swap(SuccessfulDeduced, Deduced);
1526 case Type::MemberPointer: {
1535 false, Info.getLocation());
1539 false, Info.getLocation());
1546 TDF & TDF_IgnoreQualifiers))
1551 QualType(MemPtrArg->getClass(), 0),
1553 TDF & TDF_IgnoreQualifiers);
1561 case Type::BlockPointer: {
1577 case Type::ExtVector: {
1578 const ExtVectorType *VectorParam = cast<ExtVectorType>(Param);
1579 if (
const ExtVectorType *VectorArg = dyn_cast<ExtVectorType>(Arg)) {
1581 if (VectorParam->
getNumElements() != VectorArg->getNumElements())
1582 return Sema::TDK_NonDeducedMismatch;
1587 VectorArg->getElementType(),
1588 Info, Deduced, TDF);
1592 = dyn_cast<DependentSizedExtVectorType>(Arg)) {
1600 VectorArg->getElementType(),
1601 Info, Deduced, TDF);
1610 case Type::DependentSizedExtVector: {
1612 = cast<DependentSizedExtVectorType>(Param);
1614 if (
const ExtVectorType *VectorArg = dyn_cast<ExtVectorType>(Arg)) {
1619 VectorArg->getElementType(),
1620 Info, Deduced, TDF))
1630 ArgSize = VectorArg->getNumElements();
1632 false, Info, Deduced);
1636 = dyn_cast<DependentSizedExtVectorType>(Arg)) {
1641 VectorArg->getElementType(),
1642 Info, Deduced, TDF))
1658 case Type::TypeOfExpr:
1660 case Type::DependentName:
1661 case Type::UnresolvedUsing:
1662 case Type::Decltype:
1663 case Type::UnaryTransform:
1665 case Type::DependentTemplateSpecialization:
1666 case Type::PackExpansion:
1672 llvm_unreachable(
"Invalid Type Class!");
1680 TemplateDeductionInfo &Info,
1681 SmallVectorImpl<DeducedTemplateArgument> &Deduced) {
1690 llvm_unreachable(
"Null template argument in parameter list");
1698 Info.FirstArg = Param;
1699 Info.SecondArg = Arg;
1707 Info.FirstArg = Param;
1708 Info.SecondArg = Arg;
1712 llvm_unreachable(
"caller should handle pack expansions");
1719 Info.FirstArg = Param;
1720 Info.SecondArg = Arg;
1728 Info.FirstArg = Param;
1729 Info.SecondArg = Arg;
1737 Info.FirstArg = Param;
1738 Info.SecondArg = Arg;
1743 Info.FirstArg = Param;
1744 Info.SecondArg = Arg;
1748 Info.FirstArg = Param;
1749 Info.SecondArg = Arg;
1768 Info.FirstArg = Param;
1769 Info.SecondArg = Arg;
1777 llvm_unreachable(
"Argument packs should be expanded by the caller!");
1780 llvm_unreachable(
"Invalid TemplateArgument Kind!");
1794 if (ArgIdx == NumArgs)
1801 assert(ArgIdx == NumArgs - 1 &&
"Pack not at the end of argument list?");
1812 unsigned ArgIdx = 0;
1813 while (ArgIdx < NumArgs) {
1825 if (ArgIdx == NumArgs)
1839 TemplateDeductionInfo &Info,
1840 SmallVectorImpl<DeducedTemplateArgument> &Deduced,
1841 bool NumberOfArgumentsMustMatch) {
1853 unsigned ArgIdx = 0, ParamIdx = 0;
1856 if (!Params[ParamIdx].isPackExpansion()) {
1864 if (Args[ArgIdx].isPackExpansion()) {
1873 Params[ParamIdx], Args[ArgIdx],
1896 PackDeductionScope PackScope(S, TemplateParams, Deduced, Info, Pattern);
1901 bool HasAnyArguments =
false;
1903 HasAnyArguments =
true;
1911 PackScope.nextPackElement();
1916 if (
auto Result = PackScope.finish(HasAnyArguments))
1928 TemplateDeductionInfo &Info,
1929 SmallVectorImpl<DeducedTemplateArgument> &Deduced) {
1931 ParamList.
data(), ParamList.
size(),
1933 Info, Deduced,
false);
1945 llvm_unreachable(
"Comparing NULL template argument");
1968 llvm::FoldingSetNodeID XID, YID;
1969 X.
getAsExpr()->Profile(XID, Context,
true);
1970 Y.
getAsExpr()->Profile(YID, Context,
true);
1981 XP != XPEnd; ++XP, ++YP)
1988 llvm_unreachable(
"Invalid TemplateArgument Kind!");
2012 llvm_unreachable(
"Can't get a NULL template argument here");
2066 llvm_unreachable(
"Invalid TemplateArgument Kind!");
2076 TemplateDeductionInfo &Info,
2077 bool InFunctionTemplate,
2078 SmallVectorImpl<TemplateArgument> &Output) {
2084 dyn_cast<NonTypeTemplateParmDecl>(Param)) {
2085 NTTPType = NTTP->getType();
2090 NTTP->getLocation(),
2091 NTTP->getDeclName());
2098 unsigned ArgumentPackIndex) {
2107 Param, ArgLoc, Template, Template->getLocation(),
2108 Template->getSourceRange().getEnd(), ArgumentPackIndex, Output,
2126 "deduced nested pack");
2127 if (ConvertArg(InnerArg, PackedArgsBuilder.size()))
2131 PackedArgsBuilder.push_back(Output.pop_back_val());
2138 if (TTP && PackedArgsBuilder.empty()) {
2143 Template->getSourceRange());
2144 if (Inst.isInvalid())
2159 return ConvertArg(Arg, 0);
2168 SmallVectorImpl<DeducedTemplateArgument> &Deduced,
2169 TemplateDeductionInfo &Info) {
2181 for (
unsigned I = 0, N = PartialParams->
size();
I != N; ++
I) {
2183 if (Deduced[
I].isNull()) {
2191 Partial, Info,
false,
2204 Info.reset(DeducedArgumentList);
2223 unsigned ArgIdx = InstArgs.
size(), ParamIdx = ArgIdx;
2231 Info.FirstArg = PartialTemplateArgs[ArgIdx].
getArgument();
2237 InstArgs,
false, ConvertedInstArgs))
2242 for (
unsigned I = 0,
E = TemplateParams->
size();
I !=
E; ++
I) {
2246 Info.FirstArg = TemplateArgs[
I];
2247 Info.SecondArg = InstArg;
2265 if (Partial->isInvalidDecl())
2284 TemplateArgs, Info, Deduced))
2290 if (Inst.isInvalid())
2310 SmallVectorImpl<DeducedTemplateArgument> &Deduced,
2311 TemplateDeductionInfo &Info) {
2321 for (
unsigned I = 0, N = PartialParams->
size();
I != N; ++
I) {
2323 if (Deduced[
I].isNull()) {
2331 Info,
false, Builder)) {
2343 Info.reset(DeducedArgumentList);
2362 unsigned ArgIdx = InstArgs.
size(), ParamIdx = ArgIdx;
2369 Info.FirstArg = PartialTemplateArgs[ArgIdx].
getArgument();
2374 false, ConvertedInstArgs))
2378 for (
unsigned I = 0,
E = TemplateParams->
size();
I !=
E; ++
I) {
2382 Info.FirstArg = TemplateArgs[
I];
2383 Info.SecondArg = InstArg;
2406 if (Partial->isInvalidDecl())
2423 TemplateArgs, Info, Deduced))
2429 if (Inst.isInvalid())
2443 return Spec->getTemplateName().getAsTemplateDecl() !=
nullptr;
2484 if (ExplicitTemplateArgs.
size() == 0) {
2488 ParamTypes.push_back(
P->getType());
2491 *FunctionType = Function->
getType();
2514 if (Inst.isInvalid())
2519 ExplicitTemplateArgs,
2522 unsigned Index = Builder.size();
2523 if (Index >= TemplateParams->
size())
2524 Index = TemplateParams->
size() - 1;
2533 Info.
reset(ExplicitArgumentList);
2545 for (
unsigned I = 0, N = Builder.size();
I != N; ++
I) {
2558 assert(Proto &&
"Function template does not have a prototype?");
2573 ParamTypes,
nullptr, ExtParamInfos))
2586 unsigned ThisTypeQuals = 0;
2588 if (
CXXMethodDecl *Method = dyn_cast<CXXMethodDecl>(Function)) {
2590 ThisTypeQuals = Method->getTypeQualifiers();
2610 ParamTypes,
nullptr, ExtParamInfos))
2617 Function->getLocation(),
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]);
2811 FunctionTemplate, Info,
2826 if (Param->isTemplateParameterPack()) {
2831 unsigned NumExplicitArgs;
2837 llvm::makeArrayRef(ExplicitArgs, NumExplicitArgs)));
2847 FunctionTemplate, Info,
true,
2859 bool HasDefaultArg =
false;
2862 FunctionTemplate->getLocation(),
2870 const_cast<NamedDecl *>(TemplateParams->
getParam(
I)));
2872 if (PartialOverloading)
break;
2880 FunctionTemplate->getLocation(),
2885 const_cast<NamedDecl *>(TemplateParams->
getParam(
I)));
2897 Info.
reset(DeducedArgumentList);
2901 DeclContext *Owner = FunctionTemplate->getDeclContext();
2902 if (FunctionTemplate->getFriendObjectKind())
2903 Owner = FunctionTemplate->getLexicalDeclContext();
2904 Specialization = cast_or_null<FunctionDecl>(
2907 if (!Specialization || Specialization->isInvalidDecl())
2923 Specialization->setInvalidDecl(
true);
2927 if (OriginalCallArgs) {
2932 for (
unsigned I = 0, N = OriginalCallArgs->size();
I != N; ++
I) {
2934 unsigned ParamIdx = OriginalArg.
ArgIdx;
2974 if (Method->isInstance()) {
2994 bool ParamWasReference) {
3002 if (ParamWasReference)
3047 TemplateDeductionInfo Info(Ovl->
getNameLoc());
3049 Specialization, Info))
3057 if (ArgType.isNull())
continue;
3061 ArgType->isFunctionType())
3077 Deduced(TemplateParams->
size());
3078 TemplateDeductionInfo Info(Ovl->
getNameLoc());
3081 ArgType, Info, Deduced, TDF);
3082 if (Result)
continue;
3120 ParamRefType !=
nullptr);
3138 isa<TemplateTypeParmType>(ParamType) &&
3184 (isa<PointerType>(ParamType) &&
3198 Expr *Arg, TemplateDeductionInfo &Info,
3199 SmallVectorImpl<DeducedTemplateArgument> &Deduced,
unsigned TDF);
3206 TemplateDeductionInfo &Info,
3207 SmallVectorImpl<DeducedTemplateArgument> &Deduced,
3222 const bool IsDependentSizedArray =
3227 const bool IsSTDList = !IsConstSizedArray && !IsDependentSizedArray &&
3230 if (!IsConstSizedArray && !IsDependentSizedArray && !IsSTDList)
3244 E, Info, Deduced, TDF)))
3248 if (IsDependentSizedArray) {
3256 assert(NTTP->getDepth() == 0 &&
3257 "Cannot deduce non-type template argument at depth > 0");
3262 S, NTTP, llvm::APSInt(Size), NTTP->getType(),
3263 true, Info, Deduced);
3277 TemplateDeductionInfo &Info,
3278 SmallVectorImpl<DeducedTemplateArgument> &Deduced,
3286 Deduced, TDF, Result))
3295 ArgType, Arg, TDF)) {
3296 Info.Expression = Arg;
3300 ArgType, Info, Deduced, TDF);
3326 bool PartialOverloading) {
3327 if (FunctionTemplate->isInvalidDecl())
3337 unsigned CheckArgs = Args.size();
3346 CheckArgs = NumParams;
3358 unsigned NumExplicitlySpecified = 0;
3359 if (ExplicitTemplateArgs) {
3362 *ExplicitTemplateArgs,
3370 NumExplicitlySpecified = Deduced.size();
3373 for (
unsigned I = 0;
I != NumParams; ++
I)
3378 Deduced.resize(TemplateParams->
size());
3379 unsigned ArgIdx = 0;
3381 for (
unsigned ParamIdx = 0, NumParamTypes = ParamTypes.size();
3382 ParamIdx != NumParamTypes; ++ParamIdx) {
3383 QualType OrigParamType = ParamTypes[ParamIdx];
3384 QualType ParamType = OrigParamType;
3388 if (!ParamExpansion) {
3390 if (ArgIdx >= CheckArgs)
3393 Expr *Arg = Args[ArgIdx++];
3398 ParamType, ArgType, Arg,
3411 Info, Deduced, TDF, Result))
3428 Info, Deduced, TDF))
3443 if (ParamIdx + 1 < NumParamTypes)
3447 PackDeductionScope PackScope(*
this, TemplateParams, Deduced, Info,
3450 bool HasAnyArguments =
false;
3451 for (; ArgIdx < Args.size(); ++ArgIdx) {
3452 HasAnyArguments =
true;
3454 QualType OrigParamType = ParamPattern;
3455 ParamType = OrigParamType;
3456 Expr *Arg = Args[ArgIdx];
3461 ParamType, ArgType, Arg,
3473 Info, Deduced, TDF, Result)) {
3490 ParamType, ArgType, Info,
3495 PackScope.nextPackElement();
3500 if (
auto Result = PackScope.finish(HasAnyArguments))
3508 NumExplicitlySpecified, Specialization,
3509 Info, &OriginalCallArgs,
3510 PartialOverloading);
3515 if (ArgFunctionType.
isNull())
3516 return ArgFunctionType;
3526 return ArgFunctionType;
3532 return QualType(ArgFunctionTypeP, 0);
3564 bool InOverloadResolution) {
3565 if (FunctionTemplate->isInvalidDecl())
3572 if (!InOverloadResolution)
3578 unsigned NumExplicitlySpecified = 0;
3580 if (ExplicitTemplateArgs) {
3583 *ExplicitTemplateArgs,
3584 Deduced, ParamTypes,
3585 &FunctionType, Info))
3588 NumExplicitlySpecified = Deduced.size();
3595 Deduced.resize(TemplateParams->
size());
3599 bool HasDeducedReturnType =
false;
3600 if (
getLangOpts().CPlusPlus14 && InOverloadResolution &&
3603 HasDeducedReturnType =
true;
3606 if (!ArgFunctionType.
isNull()) {
3612 FunctionType, ArgFunctionType,
3613 Info, Deduced, TDF))
3619 NumExplicitlySpecified,
3620 Specialization, Info))
3625 if (HasDeducedReturnType &&
3633 if (!ArgFunctionType.
isNull()) {
3638 else if(!InOverloadResolution &&
3656 assert(AutoResultType->getContainedAutoType());
3658 TypeToReplaceAutoWith);
3671 SmallVectorImpl<DeducedTemplateArgument> &DeducedArguments,
3672 QualType ReturnTypeOfDestFunctionPtr,
3673 TemplateDeductionInfo &TDInfo,
3680 QualType CallOpResultType = CallOpGeneric->getReturnType();
3681 const bool GenericLambdaCallOperatorHasDeducedReturnType =
3685 CallOpGeneric->getDescribedFunctionTemplate();
3693 0, CallOpSpecialized, TDInfo))
3697 if (GenericLambdaCallOperatorHasDeducedReturnType &&
3706 ReturnTypeOfDestFunctionPtr))
3715 getLambdaStaticInvoker()->getDescribedFunctionTemplate();
3721 InvokerSpecialized, TDInfo);
3723 "If the call operator succeeded so should the invoker!");
3726 if (GenericLambdaCallOperatorHasDeducedReturnType &&
3740 TypeToReplaceAutoWith, S);
3742 TypeToReplaceAutoWith, S);
3765 if (ConversionTemplate->isInvalidDecl())
3792 assert(!A->
isReferenceType() &&
"Reference types were handled above");
3828 Deduced.resize(TemplateParams->
size());
3852 P, A, Info, Deduced, TDF))
3861 ConversionSpecialized, Info);
3862 Specialization = cast_or_null<CXXConversionDecl>(ConversionSpecialized);
3874 "Can only convert from lambda to ptr-to-function");
3877 const QualType DestFunctionPtrReturnType = ToFunType->getReturnType();
3889 Specialization, Deduced, DestFunctionPtrReturnType,
3917 bool InOverloadResolution) {
3920 InOverloadResolution);
3926 class SubstituteAutoTransform :
3932 Replacement(Replacement) {}
3971 return TransformType(TLB, TL);
3993 Init = NonPlaceholder.
get();
3998 assert(!Result.
isNull() &&
"substituting DependentTy can't fail");
4006 if (AT->isDecltypeAuto()) {
4007 if (isa<InitListExpr>(Init)) {
4008 Diag(Init->getLocStart(), diag::err_decltype_auto_initializer_list);
4017 Result = SubstituteAutoTransform(*
this, Deduced).Apply(Type);
4022 if (isa<InitListExpr>(Init)) {
4023 Diag(Init->getLocStart(), diag::err_auto_init_list_from_c);
4036 nullptr,
false,
false);
4040 Loc, Loc, TemplParamPtr, Loc);
4042 QualType FuncParam = SubstituteAutoTransform(*
this, TemplArg).Apply(Type);
4043 assert(!FuncParam.
isNull() &&
4044 "substituting template parameter for 'auto' failed");
4056 for (
unsigned i = 0, e = InitList->
getNumInits(); i < e; ++i) {
4058 TemplArg, InitList->
getInit(i),
4059 Info, Deduced, TDF))
4064 Diag(Loc, diag::err_auto_bitfield);
4069 *
this, TemplateParamsSt.
get(), FuncParam, InitType, Init, TDF))
4073 FuncParam, InitType, Info, Deduced,
4081 QualType DeducedType = Deduced[0].getAsType();
4085 if (DeducedType.
isNull())
4089 Result = SubstituteAutoTransform(*
this, DeducedType).Apply(Type);
4095 if (!InitList && !Result.
isNull() &&
4108 return SubstituteAutoTransform(*
this, TypeToReplaceAuto).
4109 TransformType(TypeWithAuto);
4114 return SubstituteAutoTransform(*
this, TypeToReplaceAuto).
4115 TransformType(TypeWithAuto);
4119 if (isa<InitListExpr>(Init))
4120 Diag(VDecl->getLocation(),
4122 ? diag::err_init_capture_deduction_failure_from_init_list
4123 : diag::err_auto_var_deduction_failure_from_init_list)
4126 Diag(VDecl->getLocation(),
4127 VDecl->
isInitCapture() ? diag::err_init_capture_deduction_failure
4128 : diag::err_auto_var_deduction_failure)
4130 << Init->getSourceRange();
4141 if (StillUndeduced && Diagnose && !FD->isInvalidDecl()) {
4142 Diag(Loc, diag::err_auto_fn_used_before_defined) << FD;
4143 Diag(FD->getLocation(), diag::note_callee_decl) << FD;
4146 return StillUndeduced;
4153 llvm::SmallBitVector &Deduced);
4159 SmallVectorImpl<QualType> &ArgTypes) {
4174 ArgTypes.push_back(ArgTy);
4184 unsigned NumCallArguments1) {
4190 assert(Proto1 && Proto2 &&
"Function templates must have prototypes");
4193 Deduced.resize(TemplateParams->
size());
4198 TemplateDeductionInfo Info(Loc);
4224 unsigned NumComparedArguments = NumCallArguments1;
4226 if (!Method2 && Method1 && !Method1->
isStatic()) {
4229 ++NumComparedArguments;
4230 }
else if (!Method1 && Method2 && !Method2->
isStatic()) {
4237 Args2.insert(Args2.end(), Proto2->param_type_begin(),
4238 Proto2->param_type_end());
4243 if (Args1.size() > NumComparedArguments)
4244 Args1.resize(NumComparedArguments);
4245 if (Args2.size() > NumComparedArguments)
4246 Args2.resize(NumComparedArguments);
4248 Args1.data(), Args1.size(), Info, Deduced,
4259 S, TemplateParams, Proto2->getReturnType(), Proto1->
getReturnType(),
4282 unsigned ArgIdx = 0,
NumArgs = Deduced.size();
4283 for (; ArgIdx !=
NumArgs; ++ArgIdx)
4284 if (Deduced[ArgIdx].isNull())
4294 llvm::SmallBitVector UsedParameters(TemplateParams->
size());
4297 for (
unsigned I = 0, N = Args2.size();
I != N; ++
I)
4305 TemplateParams->
getDepth(), UsedParameters);
4315 for (; ArgIdx !=
NumArgs; ++ArgIdx)
4318 if (Deduced[ArgIdx].isNull() && UsedParameters[ArgIdx])
4337 while (--NumParams > 0) {
4368 unsigned NumCallArguments1,
4369 unsigned NumCallArguments2) {
4375 if (Better1 != Better2)
4376 return Better1 ? FT1 : FT2;
4378 if (!Better1 && !Better2)
4386 if (Variadic1 != Variadic2)
4387 return Variadic1? FT2 : FT1;
4400 return T1->getCanonicalDecl() == T2->getCanonicalDecl();
4433 bool Complain,
QualType TargetType) {
4434 if (SpecBegin == SpecEnd) {
4436 Diag(Loc, NoneDiag);
4442 if (SpecBegin + 1 == SpecEnd)
4449 = cast<FunctionDecl>(*Best)->getPrimaryTemplate();
4450 assert(BestTemplate &&
"Not a function template specialization?");
4453 = cast<FunctionDecl>(*I)->getPrimaryTemplate();
4454 assert(Challenger &&
"Not a function template specialization?");
4459 BestTemplate = Challenger;
4465 bool Ambiguous =
false;
4468 = cast<FunctionDecl>(*I)->getPrimaryTemplate();
4485 Diag(Loc, AmbigDiag);
4491 cast<FunctionDecl>(*I)->getPrimaryTemplate()->getTemplateParameters(),
4492 *cast<FunctionDecl>(*I)->getTemplateSpecializationArgs());
4493 if (!TargetType.
isNull())
4496 Diag((*I)->getLocation(), PD);
4575 if (Better1 == Better2)
4578 return Better1 ? PS1 : PS2;
4594 "the partial specializations being compared should specialize"
4595 " the same template.");
4632 if (Better1 == Better2)
4635 return Better1? PS1 : PS2;
4643 llvm::SmallBitVector &
Used);
4652 llvm::SmallBitVector &
Used) {
4655 E = Expansion->getPattern();
4661 E = ICE->getSubExpr();
4663 dyn_cast<SubstNonTypeTemplateParmExpr>(E))
4664 E = Subst->getReplacement();
4691 llvm::SmallBitVector &
Used) {
4698 OnlyDeduced, Depth, Used);
4708 llvm::SmallBitVector &
Used) {
4711 = dyn_cast<TemplateTemplateParmDecl>(Template)) {
4712 if (TTP->getDepth() ==
Depth)
4713 Used[TTP->getIndex()] =
true;
4732 llvm::SmallBitVector &
Used) {
4744 cast<PointerType>(T)->getPointeeType(),
4750 case Type::BlockPointer:
4752 cast<BlockPointerType>(T)->getPointeeType(),
4758 case Type::LValueReference:
4759 case Type::RValueReference:
4761 cast<ReferenceType>(T)->getPointeeType(),
4767 case Type::MemberPointer: {
4772 OnlyDeduced, Depth, Used);
4776 case Type::DependentSizedArray:
4778 cast<DependentSizedArrayType>(T)->getSizeExpr(),
4779 OnlyDeduced, Depth, Used);
4782 case Type::ConstantArray:
4783 case Type::IncompleteArray:
4785 cast<ArrayType>(T)->getElementType(),
4786 OnlyDeduced, Depth, Used);
4790 case Type::ExtVector:
4792 cast<VectorType>(T)->getElementType(),
4793 OnlyDeduced, Depth, Used);
4796 case Type::DependentSizedExtVector: {
4798 = cast<DependentSizedExtVectorType>(T);
4806 case Type::FunctionProto: {
4816 case Type::TemplateTypeParm: {
4823 case Type::SubstTemplateTypeParmPack: {
4825 = cast<SubstTemplateTypeParmPackType>(T);
4828 OnlyDeduced, Depth, Used);
4834 case Type::InjectedClassName:
4835 T = cast<InjectedClassNameType>(T)->getInjectedSpecializationType();
4838 case Type::TemplateSpecialization: {
4840 = cast<TemplateSpecializationType>(T);
4852 for (
unsigned I = 0, N = Spec->getNumArgs();
I != N; ++
I)
4861 cast<ComplexType>(T)->getElementType(),
4862 OnlyDeduced, Depth, Used);
4868 cast<AtomicType>(T)->getValueType(),
4869 OnlyDeduced, Depth, Used);
4872 case Type::DependentName:
4876 OnlyDeduced, Depth, Used);
4879 case Type::DependentTemplateSpecialization: {
4893 = cast<DependentTemplateSpecializationType>(T);
4898 for (
unsigned I = 0, N = Spec->getNumArgs();
I != N; ++
I)
4908 OnlyDeduced, Depth, Used);
4911 case Type::TypeOfExpr:
4914 cast<TypeOfExprType>(T)->getUnderlyingExpr(),
4915 OnlyDeduced, Depth, Used);
4918 case Type::Decltype:
4921 cast<DecltypeType>(T)->getUnderlyingExpr(),
4922 OnlyDeduced, Depth, Used);
4925 case Type::UnaryTransform:
4929 OnlyDeduced, Depth, Used);
4932 case Type::PackExpansion:
4934 cast<PackExpansionType>(T)->getPattern(),
4935 OnlyDeduced, Depth, Used);
4940 cast<AutoType>(T)->getDeducedType(),
4941 OnlyDeduced, Depth, Used);
4945 case Type::VariableArray:
4946 case Type::FunctionNoProto:
4949 case Type::ObjCInterface:
4950 case Type::ObjCObject:
4951 case Type::ObjCObjectPointer:
4952 case Type::UnresolvedUsing:
4954 #define TYPE(Class, Base)
4955 #define ABSTRACT_TYPE(Class, Base)
4956 #define DEPENDENT_TYPE(Class, Base)
4957 #define NON_CANONICAL_TYPE(Class, Base) case Type::Class:
4958 #include "clang/AST/TypeNodes.def"
4970 llvm::SmallBitVector &
Used) {
4971 switch (TemplateArg.
getKind()) {
5017 bool OnlyDeduced,
unsigned Depth,
5018 llvm::SmallBitVector &
Used) {
5027 for (
unsigned I = 0, N = TemplateArgs.
size();
I != N; ++
I)
5036 llvm::SmallBitVector &Deduced) {
5040 Deduced.resize(TemplateParams->
size());
5045 true, TemplateParams->
getDepth(), Deduced);
5056 llvm::SmallBitVector Deduced(TemplateParams->
size());
5060 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
const ExtParameterInfo * getExtParameterInfosOrNull() const
Return a pointer to the beginning of the array of extra parameter information, if present...
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
bool SubstParmTypes(SourceLocation Loc, ArrayRef< ParmVarDecl * > Params, const FunctionProtoType::ExtParameterInfo *ExtParamInfos, const MultiLevelTemplateArgumentList &TemplateArgs, SmallVectorImpl< QualType > &ParamTypes, SmallVectorImpl< ParmVarDecl * > *OutParams, ExtParameterInfoBuilder &ParamInfos)
Substitute the given template arguments into the given set of parameters, producing the set of parame...
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.
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.
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
unsigned getCVRQualifiers() const
Retrieve the set of CVR (const-volatile-restrict) qualifiers applied to this type.
DependentTemplateSpecializationType(ElaboratedTypeKeyword Keyword, NestedNameSpecifier *NNS, const IdentifierInfo *Name, ArrayRef< TemplateArgument > Args, QualType Canon)
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.
static Sema::TemplateDeductionResult DeduceNonTypeTemplateArgument(Sema &S, NonTypeTemplateParmDecl *NTTP, const 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.
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
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...
static TemplateArgumentList * CreateCopy(ASTContext &Context, ArrayRef< TemplateArgument > Args)
Create a new template argument list that copies the given set of template arguments.
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.
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
TemplateArgument getArgumentPack() const
bool isCompleteType(SourceLocation Loc, QualType T)
An rvalue reference type, per C++11 [dcl.ref].
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)
We are substituting explicit template arguments provided for a function template. ...
Scope - A scope is a transient data structure that is used while parsing the program.
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
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
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 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.
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.
void InstantiateFunctionDefinition(SourceLocation PointOfInstantiation, FunctionDecl *Function, bool Recursive=false, bool DefinitionRequired=false, bool AtEndOfTU=false)
Instantiate the definition of the given function from its template.
A helper class for building up ExtParameterInfos.
Class that aids in the construction of nested-name-specifiers along with source-location information ...
RAII class used to determine whether SFINAE has trapped any errors that occur during template argumen...
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.
ArrayRef< TemplateArgument > asArray() const
Produce this as an array ref.
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...
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)
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 FunctionProtoType::ExtParameterInfo * getPointerOrNull(unsigned numParams)
Return a pointer (suitable for setting in an ExtProtoInfo) to the ExtParameterInfo array we've built ...
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.
const ExtParameterInfo * ExtParameterInfos
static bool ConvertDeducedTemplateArgument(Sema &S, NamedDecl *Param, DeducedTemplateArgument Arg, NamedDecl *Template, TemplateDeductionInfo &Info, bool InFunctionTemplate, SmallVectorImpl< TemplateArgument > &Output)
Convert the given deduced template argument and add it to the set of fully-converted template argumen...
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...
QualType getTemplateSpecializationType(TemplateName T, ArrayRef< TemplateArgument > Args, QualType Canon=QualType()) const
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>::".
ArrayRef< ParmVarDecl * > parameters() const
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...
A POD class for pairing a NamedDecl* with an access specifier.
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.
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 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...
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.
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
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.
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.
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.
FunctionDecl * getCanonicalDecl() override
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
TemplateSpecializationType(TemplateName T, ArrayRef< TemplateArgument > Args, QualType Canon, QualType Aliased)
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 ...