43 #include "llvm/ADT/APInt.h" 44 #include "llvm/ADT/APSInt.h" 45 #include "llvm/ADT/ArrayRef.h" 46 #include "llvm/ADT/DenseMap.h" 47 #include "llvm/ADT/FoldingSet.h" 48 #include "llvm/ADT/Optional.h" 49 #include "llvm/ADT/SmallBitVector.h" 50 #include "llvm/ADT/SmallPtrSet.h" 51 #include "llvm/ADT/SmallVector.h" 52 #include "llvm/Support/Casting.h" 53 #include "llvm/Support/Compiler.h" 54 #include "llvm/Support/ErrorHandling.h" 110 using namespace clang;
111 using namespace sema;
116 if (Y.getBitWidth() > X.getBitWidth())
117 X = X.extend(Y.getBitWidth());
118 else if (Y.getBitWidth() < X.getBitWidth())
119 Y = Y.extend(X.getBitWidth());
122 if (X.isSigned() != Y.isSigned()) {
124 if ((Y.isSigned() && Y.isNegative()) || (X.isSigned() && X.isNegative()))
140 SmallVectorImpl<DeducedTemplateArgument> &Deduced);
148 SmallVectorImpl<DeducedTemplateArgument> &
152 bool DeducedFromArrayBound =
false);
156 ArrayRef<TemplateArgument> Params,
157 ArrayRef<TemplateArgument> Args,
159 SmallVectorImpl<DeducedTemplateArgument> &Deduced,
160 bool NumberOfArgumentsMustMatch);
164 bool OnlyDeduced,
unsigned Depth,
165 llvm::SmallBitVector &
Used);
168 bool OnlyDeduced,
unsigned Level,
169 llvm::SmallBitVector &Deduced);
180 E = IC->getSubExpr();
182 E = CE->getSubExpr();
184 dyn_cast<SubstNonTypeTemplateParmExpr>(E))
185 E = Subst->getReplacement();
191 if (
auto *NTTP = dyn_cast<NonTypeTemplateParmDecl>(DRE->getDecl()))
201 if (
NamedDecl *NX = dyn_cast<NamedDecl>(X))
202 X = NX->getUnderlyingDecl();
203 if (
NamedDecl *NY = dyn_cast<NamedDecl>(Y))
204 Y = NY->getUnderlyingDecl();
239 llvm_unreachable(
"Non-deduced template arguments handled above");
290 llvm::FoldingSetNodeID ID1, ID2;
354 XA != XAEnd; ++XA, ++YA) {
360 NewPack.push_back(Merged);
369 llvm_unreachable(
"Invalid TemplateArgument Kind!");
379 SmallVectorImpl<DeducedTemplateArgument> &Deduced) {
381 "deducing non-type template argument with wrong depth");
385 if (Result.isNull()) {
406 if (
auto *Expansion = dyn_cast<PackExpansionType>(ParamType))
407 ParamType = Expansion->getPattern();
426 SmallVectorImpl<DeducedTemplateArgument> &Deduced) {
428 S, TemplateParams, NTTP,
430 DeducedFromArrayBound),
431 ValueType, Info, Deduced);
440 SmallVectorImpl<DeducedTemplateArgument> &Deduced) {
444 NullPtrType, CK_NullToPointer)
448 Value->
getType(), Info, Deduced);
458 SmallVectorImpl<DeducedTemplateArgument> &Deduced) {
461 Value->
getType(), Info, Deduced);
472 SmallVectorImpl<DeducedTemplateArgument> &Deduced) {
485 SmallVectorImpl<DeducedTemplateArgument> &Deduced) {
494 = dyn_cast<TemplateTemplateParmDecl>(ParamDecl)) {
501 Deduced[TempParam->getIndex()],
503 if (Result.isNull()) {
504 Info.
Param = TempParam;
505 Info.
FirstArg = Deduced[TempParam->getIndex()];
510 Deduced[TempParam->getIndex()] = Result;
548 SmallVectorImpl<DeducedTemplateArgument> &Deduced) {
549 assert(Arg.
isCanonical() &&
"Argument type must be canonical");
552 if (
auto *Injected = dyn_cast<InjectedClassNameType>(Arg))
553 Arg = Injected->getInjectedSpecializationType();
557 = dyn_cast<TemplateSpecializationType>(Arg)) {
562 SpecArg->getTemplateName(),
572 SpecArg->template_arguments(), Info, Deduced,
613 case Type::TypeOfExpr:
615 case Type::DependentName:
617 case Type::UnresolvedUsing:
618 case Type::TemplateTypeParm:
621 case Type::ConstantArray:
622 case Type::IncompleteArray:
623 case Type::VariableArray:
624 case Type::DependentSizedArray:
626 cast<ArrayType>(T)->getElementType());
646 if (
auto *TTP = dyn_cast<TemplateTypeParmDecl>(Param))
647 if (TTP->isExpandedParameterPack())
648 return TTP->getNumExpansionParameters();
650 if (
auto *NTTP = dyn_cast<NonTypeTemplateParmDecl>(Param))
651 if (NTTP->isExpandedParameterPack())
652 return NTTP->getNumExpansionTypes();
654 if (
auto *TTP = dyn_cast<TemplateTemplateParmDecl>(Param))
655 if (TTP->isExpandedParameterPack())
656 return TTP->getNumExpansionTemplateParameters();
685 class PackDeductionScope {
691 : S(S), TemplateParams(TemplateParams), Deduced(Deduced), Info(Info) {
692 unsigned NumNamedPacks = addPacks(Pattern);
693 finishConstruction(NumNamedPacks);
700 : S(S), TemplateParams(TemplateParams), Deduced(Deduced), Info(Info) {
702 finishConstruction(1);
706 void addPack(
unsigned Index) {
710 Pack.
Saved = Deduced[Index];
718 FixedNumExpansions = ExpandedPackExpansions;
720 Packs.push_back(Pack);
726 llvm::SmallBitVector SawIndices(TemplateParams->
size());
729 auto AddPack = [&](
unsigned Index) {
730 if (SawIndices[Index])
732 SawIndices[Index] =
true;
739 if (
auto *NTTP = dyn_cast<NonTypeTemplateParmDecl>(
741 if (
auto *Expansion = dyn_cast<PackExpansionType>(NTTP->getType()))
742 ExtraDeductions.push_back(Expansion->getPattern());
751 for (
unsigned I = 0, N = Unexpanded.size(); I != N; ++I) {
752 unsigned Depth, Index;
761 assert(!Packs.empty() &&
"Pack expansion without unexpanded packs?");
763 unsigned NumNamedPacks = Packs.size();
767 while (!ExtraDeductions.empty())
768 Collect(ExtraDeductions.pop_back_val());
770 return NumNamedPacks;
773 void finishConstruction(
unsigned NumNamedPacks) {
776 unsigned NumPartialPackArgs = 0;
777 std::pair<unsigned, unsigned> PartialPackDepthIndex(-1u, -1u);
779 if (
auto *Partial =
Scope->getPartiallySubstitutedPack(
780 &PartialPackArgs, &NumPartialPackArgs))
786 bool IsExpanded =
true;
787 for (
unsigned I = 0; I != NumNamedPacks; ++I) {
790 IsPartiallyExpanded =
false;
793 if (PartialPackDepthIndex ==
795 IsPartiallyExpanded =
true;
801 if (IsPartiallyExpanded)
802 PackElements += NumPartialPackArgs;
804 PackElements += *FixedNumExpansions;
806 for (
auto &Pack : Packs) {
813 if (PartialPackDepthIndex ==
815 Pack.New.append(PartialPackArgs, PartialPackArgs + NumPartialPackArgs);
824 if (!IsPartiallyExpanded)
825 Deduced[Pack.Index] = Pack.New[PackElements];
831 ~PackDeductionScope() {
832 for (
auto &Pack : Packs)
838 bool isPartiallyExpanded() {
return IsPartiallyExpanded; }
843 bool hasFixedArity() {
return FixedNumExpansions.hasValue(); }
848 bool hasNextElement() {
849 return !FixedNumExpansions || *FixedNumExpansions > PackElements;
853 void nextPackElement() {
857 for (
auto &Pack : Packs) {
859 if (!Pack.New.empty() || !DeducedArg.
isNull()) {
860 while (Pack.New.size() < PackElements)
862 if (Pack.New.size() == PackElements)
863 Pack.New.push_back(DeducedArg);
865 Pack.New[PackElements] = DeducedArg;
866 DeducedArg = Pack.New.size() > PackElements + 1
867 ? Pack.New[PackElements + 1]
880 for (
auto &Pack : Packs) {
882 Deduced[Pack.Index] = Pack.Saved;
897 Pack.New.resize(PackElements);
901 if (Pack.New.empty()) {
907 std::copy(Pack.New.begin(), Pack.New.end(), ArgumentPack);
915 Pack.New[0].wasDeducedFromArrayBound());
921 if (Pack.Outer->DeferredDeduction.isNull()) {
924 Pack.Outer->DeferredDeduction = NewPack;
927 Loc = &Pack.Outer->DeferredDeduction;
929 Loc = &Deduced[Pack.Index];
938 if (!Result.
isNull() && !Pack.DeferredDeduction.isNull()) {
940 NewPack = Pack.DeferredDeduction;
955 if (*Expansions != PackElements) {
973 unsigned PackElements = 0;
974 bool IsPartiallyExpanded =
false;
1016 const QualType *Params,
unsigned NumParams,
1017 const QualType *Args,
unsigned NumArgs,
1019 SmallVectorImpl<DeducedTemplateArgument> &Deduced,
1021 bool PartialOrdering =
false) {
1036 if (ArgIdx >= NumArgs)
1039 if (isa<PackExpansionType>(Args[ArgIdx])) {
1066 PackDeductionScope PackScope(S, TemplateParams, Deduced, Info, Pattern);
1070 if (
ParamIdx + 1 == NumParams || PackScope.hasFixedArity()) {
1071 for (; ArgIdx < NumArgs && PackScope.hasNextElement(); ++ArgIdx) {
1075 Args[ArgIdx], Info, Deduced,
1079 PackScope.nextPackElement();
1100 if (NumExpansions && !PackScope.isPartiallyExpanded()) {
1101 for (
unsigned I = 0; I != *NumExpansions && ArgIdx < NumArgs;
1103 PackScope.nextPackElement();
1109 if (
auto Result = PackScope.finish())
1114 if (ArgIdx < NumArgs)
1129 if (ParamQs == ArgQs)
1164 if (!ParamFunction || !ArgFunction)
1165 return Param == Arg;
1169 if (IsFunctionConversion(Param, Arg, AdjustedParam))
1174 return Param == Arg;
1183 if (!Guide || !Guide->isImplicit())
1195 if (ParamRef->getPointeeType().getQualifiers())
1198 return TypeParm && TypeParm->
getIndex() >= FirstInnerIndex;
1232 SmallVectorImpl<DeducedTemplateArgument> &Deduced,
1234 bool PartialOrdering,
1235 bool DeducedFromArrayBound) {
1244 = dyn_cast<PackExpansionType>(Arg))
1245 Arg = ArgExpansion->getPattern();
1247 if (PartialOrdering) {
1329 TDF &= ~TDF_TopLevelParameterTypeList;
1350 unsigned Index = TemplateTypeParm->getIndex();
1351 bool RecanonicalizeArg =
false;
1355 if (isa<ArrayType>(Arg)) {
1360 RecanonicalizeArg =
true;
1368 Info.
Param = cast<TemplateTypeParmDecl>(TemplateParams->
getParam(Index));
1381 "saw template type parameter with wrong depth");
1402 Info.
Param = cast<TemplateTypeParmDecl>(TemplateParams->
getParam(Index));
1419 if (RecanonicalizeArg)
1427 Info.
Param = cast<TemplateTypeParmDecl>(TemplateParams->
getParam(Index));
1433 Deduced[Index] = Result;
1445 if (isa<SubstTemplateTypeParmPackType>(Param))
1491 : ParamUnqualType == ArgUnqualType;
1498 #define NON_CANONICAL_TYPE(Class, Base) \ 1499 case Type::Class: llvm_unreachable("deducing non-canonical type: " #Class); 1500 #define TYPE(Class, Base) 1501 #include "clang/AST/TypeNodes.inc" 1503 case Type::TemplateTypeParm:
1504 case Type::SubstTemplateTypeParmPack:
1505 llvm_unreachable(
"Type nodes handled above");
1510 case Type::VariableArray:
1512 case Type::FunctionNoProto:
1515 case Type::ObjCObject:
1516 case Type::ObjCInterface:
1517 case Type::ObjCObjectPointer:
1521 if (TDF & TDF_IgnoreQualifiers) {
1532 cast<ComplexType>(Param)->getElementType(),
1533 ComplexArg->getElementType(),
1534 Info, Deduced, TDF);
1542 cast<AtomicType>(Param)->getValueType(),
1543 AtomicArg->getValueType(),
1544 Info, Deduced, TDF);
1549 case Type::Pointer: {
1562 cast<PointerType>(Param)->getPointeeType(),
1564 Info, Deduced, SubTDF);
1568 case Type::LValueReference: {
1575 cast<LValueReferenceType>(Param)->getPointeeType(),
1580 case Type::RValueReference: {
1587 cast<RValueReferenceType>(Param)->getPointeeType(),
1593 case Type::IncompleteArray: {
1596 if (!IncompleteArrayArg)
1603 Info, Deduced, SubTDF);
1607 case Type::ConstantArray: {
1610 if (!ConstantArrayArg)
1616 return Sema::TDK_NonDeducedMismatch;
1622 Info, Deduced, SubTDF);
1626 case Type::DependentSizedArray: {
1640 Info, Deduced, SubTDF))
1652 "saw non-type template parameter with wrong depth");
1654 = dyn_cast<ConstantArrayType>(ArrayArg)) {
1662 = dyn_cast<DependentSizedArrayType>(ArrayArg))
1663 if (DependentArrayArg->getSizeExpr())
1665 DependentArrayArg->getSizeExpr(),
1675 case Type::FunctionProto: {
1679 if (!FunctionProtoArg)
1683 cast<FunctionProtoType>(Param);
1690 return Sema::TDK_NonDeducedMismatch;
1703 FunctionProtoArg->
getNumParams(), Info, Deduced, SubTDF))
1717 "saw non-type template parameter with wrong depth");
1720 switch (FunctionProtoArg->
canThrow()) {
1730 true, Info, Deduced);
1735 S, TemplateParams, NTTP, ArgNoexceptExpr, Info, Deduced);
1748 case Type::InjectedClassName:
1751 Param = cast<InjectedClassNameType>(Param)
1752 ->getInjectedSpecializationType();
1753 assert(isa<TemplateSpecializationType>(Param) &&
1754 "injected class name is not a template specialization type");
1762 case Type::TemplateSpecialization: {
1764 cast<TemplateSpecializationType>(Param);
1777 S, TemplateParams, SpecParam, Arg, Info, Deduced);
1800 Deduced = DeducedOrig;
1805 llvm::SmallPtrSet<const RecordType *, 8> Visited;
1807 ToVisit.push_back(RecordT);
1808 bool Successful =
false;
1810 while (!ToVisit.empty()) {
1812 const RecordType *NextT = ToVisit.pop_back_val();
1815 if (!Visited.insert(NextT).second)
1820 if (NextT != RecordT) {
1824 QualType(NextT, 0), BaseInfo, Deduced);
1836 std::swap(SuccessfulDeduced, Deduced);
1838 Info.
Param = BaseInfo.Param;
1843 Deduced = DeducedOrig;
1848 for (
const auto &
Base : Next->
bases()) {
1849 assert(
Base.getType()->isRecordType() &&
1850 "Base class that isn't a record?");
1856 std::swap(SuccessfulDeduced, Deduced);
1872 case Type::MemberPointer: {
1892 TDF & TDF_IgnoreQualifiers))
1897 QualType(MemPtrArg->getClass(), 0),
1899 TDF & TDF_IgnoreQualifiers);
1907 case Type::BlockPointer: {
1923 case Type::ExtVector: {
1924 const ExtVectorType *VectorParam = cast<ExtVectorType>(Param);
1925 if (
const ExtVectorType *VectorArg = dyn_cast<ExtVectorType>(Arg)) {
1927 if (VectorParam->
getNumElements() != VectorArg->getNumElements())
1928 return Sema::TDK_NonDeducedMismatch;
1933 VectorArg->getElementType(),
1934 Info, Deduced, TDF);
1938 = dyn_cast<DependentSizedExtVectorType>(Arg)) {
1946 VectorArg->getElementType(),
1947 Info, Deduced, TDF);
1953 case Type::DependentVector: {
1954 const auto *VectorParam = cast<DependentVectorType>(Param);
1956 if (
const auto *VectorArg = dyn_cast<VectorType>(Arg)) {
1960 S, TemplateParams, VectorParam->getElementType(),
1961 VectorArg->getElementType(), Info, Deduced, TDF))
1971 ArgSize = VectorArg->getNumElements();
1980 if (
const auto *VectorArg = dyn_cast<DependentVectorType>(Arg)) {
1984 S, TemplateParams, VectorParam->getElementType(),
1985 VectorArg->getElementType(), Info, Deduced, TDF))
1990 Info, VectorParam->getSizeExpr());
1995 S, TemplateParams, NTTP, VectorArg->getSizeExpr(), Info, Deduced);
2004 case Type::DependentSizedExtVector: {
2006 = cast<DependentSizedExtVectorType>(Param);
2008 if (
const ExtVectorType *VectorArg = dyn_cast<ExtVectorType>(Arg)) {
2013 VectorArg->getElementType(),
2014 Info, Deduced, TDF))
2024 ArgSize = VectorArg->getNumElements();
2034 = dyn_cast<DependentSizedExtVectorType>(Arg)) {
2039 VectorArg->getElementType(),
2040 Info, Deduced, TDF))
2050 VectorArg->getSizeExpr(),
2060 case Type::DependentAddressSpace: {
2062 cast<DependentAddressSpaceType>(Param);
2065 dyn_cast<DependentAddressSpaceType>(Arg)) {
2080 S, TemplateParams, NTTP, AddressSpaceArg->getAddrSpaceExpr(), Info,
2104 true, Info, Deduced);
2110 case Type::TypeOfExpr:
2112 case Type::DependentName:
2113 case Type::UnresolvedUsing:
2114 case Type::Decltype:
2115 case Type::UnaryTransform:
2117 case Type::DeducedTemplateSpecialization:
2118 case Type::DependentTemplateSpecialization:
2119 case Type::PackExpansion:
2125 llvm_unreachable(
"Invalid Type Class!");
2134 SmallVectorImpl<DeducedTemplateArgument> &Deduced) {
2143 llvm_unreachable(
"Null template argument in parameter list");
2165 llvm_unreachable(
"caller should handle pack expansions");
2236 llvm_unreachable(
"Argument packs should be expanded by the caller!");
2239 llvm_unreachable(
"Invalid TemplateArgument Kind!");
2252 if (ArgIdx == Args.size())
2259 assert(ArgIdx == Args.size() - 1 &&
"Pack not at the end of argument list?");
2262 return ArgIdx < Args.size();
2268 bool FoundPackExpansion =
false;
2269 for (
const auto &A : Args) {
2270 if (FoundPackExpansion)
2278 if (A.isPackExpansion())
2279 FoundPackExpansion =
true;
2287 ArrayRef<TemplateArgument> Params,
2288 ArrayRef<TemplateArgument> Args,
2290 SmallVectorImpl<DeducedTemplateArgument> &Deduced,
2291 bool NumberOfArgumentsMustMatch) {
2305 if (!Params[
ParamIdx].isPackExpansion()) {
2310 return NumberOfArgumentsMustMatch
2317 if (Args[ArgIdx].isPackExpansion())
2342 PackDeductionScope PackScope(S, TemplateParams, Deduced, Info, Pattern);
2348 PackScope.hasNextElement();
2356 PackScope.nextPackElement();
2361 if (
auto Result = PackScope.finish())
2374 SmallVectorImpl<DeducedTemplateArgument> &Deduced) {
2376 ArgList.
asArray(), Info, Deduced,
2384 bool PackExpansionMatchesPack =
false) {
2395 llvm_unreachable(
"Comparing NULL template argument");
2418 llvm::FoldingSetNodeID XID, YID;
2431 XP != XPEnd; ++XP, ++YP)
2438 llvm_unreachable(
"Invalid TemplateArgument Kind!");
2459 llvm_unreachable(
"Can't get a NULL template argument here");
2468 Expr *E = BuildExpressionFromDeclTemplateArgument(Arg, NTTPType, Loc)
2476 Expr *E = BuildExpressionFromDeclTemplateArgument(Arg, NTTPType, Loc)
2484 BuildExpressionFromIntegralTemplateArgument(Arg, Loc).getAs<
Expr>();
2493 Builder.
MakeTrivial(Context, DTN->getQualifier(), Loc);
2496 Builder.
MakeTrivial(Context, QTN->getQualifier(), Loc);
2513 llvm_unreachable(
"Invalid TemplateArgument Kind!");
2519 return getTrivialTemplateArgumentLoc(
2531 SmallVectorImpl<TemplateArgument> &Output) {
2533 unsigned ArgumentPackIndex) {
2561 "deduced nested pack");
2568 diag::err_template_arg_deduced_incomplete_pack)
2572 if (ConvertArg(InnerArg, PackedArgsBuilder.size()))
2576 PackedArgsBuilder.push_back(Output.pop_back_val());
2581 if (PackedArgsBuilder.empty()) {
2586 if (
auto *NTTP = dyn_cast<NonTypeTemplateParmDecl>(Param)) {
2590 if (Inst.isInvalid() ||
2591 S.
SubstType(NTTP->getType(), Args, NTTP->getLocation(),
2592 NTTP->getDeclName()).isNull())
2594 }
else if (
auto *TTP = dyn_cast<TemplateTemplateParmDecl>(Param)) {
2610 return ConvertArg(Arg, 0);
2616 template<
typename TemplateDeclT>
2618 Sema &S, TemplateDeclT *Template,
bool IsDeduced,
2619 SmallVectorImpl<DeducedTemplateArgument> &Deduced,
2622 unsigned NumAlreadyConverted = 0,
bool PartialOverloading =
false) {
2625 for (
unsigned I = 0, N = TemplateParams->
size(); I != N; ++I) {
2634 PackDeductionScope(S, TemplateParams, Deduced, Info, I).finish())
2638 if (!Deduced[I].isNull()) {
2639 if (I < NumAlreadyConverted) {
2644 CurrentInstantiationScope->getPartiallySubstitutedPack() == Param) {
2647 CurrentInstantiationScope->ResetPartiallySubstitutedPack();
2654 Builder.push_back(Deduced[I]);
2662 IsDeduced, Builder)) {
2673 bool HasDefaultArg =
false;
2676 assert(isa<ClassTemplatePartialSpecializationDecl>(Template) ||
2677 isa<VarTemplatePartialSpecializationDecl>(Template));
2688 const_cast<NamedDecl *>(TemplateParams->
getParam(I)));
2690 if (PartialOverloading)
break;
2701 const_cast<NamedDecl *>(TemplateParams->
getParam(I)));
2714 if (
auto *DC = dyn_cast<DeclContext>(D))
2720 static constexpr
bool value =
false;
2724 static constexpr
bool value =
true;
2728 static constexpr
bool value =
true;
2731 template<
typename TemplateDeclT>
2734 ArrayRef<TemplateArgument> DeducedArgs,
2737 Template->getAssociatedConstraints(AssociatedConstraints);
2749 template <
typename T>
2750 static typename std::enable_if<IsPartialSpecialization<T>::value,
2753 Sema &S, T *Partial,
bool IsPartialOrdering,
2755 SmallVectorImpl<DeducedTemplateArgument> &Deduced,
2769 S, Partial, IsPartialOrdering, Deduced, Info, Builder))
2776 Info.
reset(DeducedArgumentList);
2784 auto *Template = Partial->getSpecializedTemplate();
2786 Partial->getTemplateArgsAsWritten();
2796 if (
ParamIdx >= Partial->getTemplateParameters()->size())
2797 ParamIdx = Partial->getTemplateParameters()->size() - 1;
2800 Partial->getTemplateParameters()->getParam(
ParamIdx));
2806 bool ConstraintsNotSatisfied;
2809 false, ConvertedInstArgs,
2811 &ConstraintsNotSatisfied))
2816 for (
unsigned I = 0, E = TemplateParams->
size(); I != E; ++I) {
2841 SmallVectorImpl<DeducedTemplateArgument> &Deduced,
2855 S, Template, PartialOrdering, Deduced, Info, Builder))
2860 for (
unsigned I = 0, E = TemplateParams->
size(); I != E; ++I) {
2908 TemplateArgs, Info, Deduced))
2914 if (Inst.isInvalid())
2915 return TDK_InstantiationDepth;
2921 *
this, Partial,
false, TemplateArgs, Deduced, Info);
2949 TemplateArgs, Info, Deduced))
2955 if (Inst.isInvalid())
2956 return TDK_InstantiationDepth;
2962 *
this, Partial,
false, TemplateArgs, Deduced, Info);
2969 return Spec->getTemplateName().getAsTemplateDecl() !=
nullptr;
3021 if (ExplicitTemplateArgs.
size() == 0) {
3025 ParamTypes.push_back(
P->getType());
3028 *FunctionType = Function->
getType();
3049 *
this, Info.
getLocation(), FunctionTemplate, DeducedArgs,
3050 CodeSynthesisContext::ExplicitTemplateArgumentSubstitution, Info);
3051 if (Inst.isInvalid())
3052 return TDK_InstantiationDepth;
3054 if (CheckTemplateArgumentList(FunctionTemplate,
SourceLocation(),
3055 ExplicitTemplateArgs,
true, Builder,
false) ||
3057 unsigned Index = Builder.size();
3058 if (Index >= TemplateParams->
size())
3059 return TDK_SubstitutionFailure;
3061 return TDK_InvalidExplicitArguments;
3080 unsigned PartiallySubstitutedPackIndex = -1u;
3081 if (!Builder.empty()) {
3084 auto *Param = TemplateParams->
getParam(Builder.size() - 1);
3088 if (!Expansions || Arg.
pack_size() < *Expansions) {
3089 PartiallySubstitutedPackIndex = Builder.size() - 1;
3090 CurrentInstantiationScope->SetPartiallySubstitutedPack(
3098 assert(Proto &&
"Function template does not have a prototype?");
3113 ParamTypes,
nullptr, ExtParamInfos))
3114 return TDK_SubstitutionFailure;
3128 if (
CXXMethodDecl *Method = dyn_cast<CXXMethodDecl>(Function)) {
3130 ThisTypeQuals = Method->getMethodQualifiers();
3141 return TDK_SubstitutionFailure;
3143 if (getLangOpts().CUDA)
3147 return TDK_SubstitutionFailure;
3157 ParamTypes,
nullptr, ExtParamInfos))
3158 return TDK_SubstitutionFailure;
3168 if (getLangOpts().CPlusPlus17 &&
3170 Function->
getLocation(), EPI.ExceptionSpec, ExceptionStorage,
3172 return TDK_SubstitutionFailure;
3174 *FunctionType = BuildFunctionType(ResultType, ParamTypes,
3179 return TDK_SubstitutionFailure;
3192 Deduced.reserve(TemplateParams->
size());
3193 for (
unsigned I = 0, N = ExplicitArgumentList->
size(); I != N; ++I) {
3195 if (I == PartiallySubstitutedPackIndex)
3198 Deduced.push_back(Arg);
3266 if (AQuals == DeducedAQuals) {
3284 bool ObjCLifetimeConversion =
false;
3288 ObjCLifetimeConversion) ||
3334 if (PD->isParameterPack()) {
3335 unsigned NumExpansions =
3337 if (Idx + NumExpansions > ParamIdx)
3338 return ParamIdx - Idx;
3339 Idx += NumExpansions;
3341 if (Idx == ParamIdx)
3347 llvm_unreachable(
"parameter index would not be produced from template");
3359 unsigned NumExplicitlySpecified,
FunctionDecl *&Specialization,
3362 bool PartialOverloading, llvm::function_ref<
bool()> CheckNonDependent) {
3372 *
this, Info.
getLocation(), FunctionTemplate, DeducedArgs,
3373 CodeSynthesisContext::DeducedTemplateArgumentSubstitution, Info);
3374 if (Inst.isInvalid())
3375 return TDK_InstantiationDepth;
3384 *
this, FunctionTemplate,
true, Deduced, Info, Builder,
3385 CurrentInstantiationScope, NumExplicitlySpecified,
3386 PartialOverloading))
3398 if (CheckNonDependent())
3399 return TDK_NonDependentConversionFailure;
3404 Info.
reset(DeducedArgumentList);
3412 Specialization = cast_or_null<FunctionDecl>(
3415 return TDK_SubstitutionFailure;
3431 return TDK_SubstitutionFailure;
3442 if (!PartialOverloading ||
3444 if (CheckInstantiatedFunctionTemplateConstraints(Info.
getLocation(),
3446 return TDK_MiscellaneousDeductionFailure;
3450 return TDK_ConstraintsNotSatisfied;
3454 if (OriginalCallArgs) {
3459 llvm::SmallDenseMap<std::pair<unsigned, QualType>,
QualType> DeducedATypes;
3460 for (
unsigned I = 0, N = OriginalCallArgs->size(); I != N; ++I) {
3481 if (CacheEntry.
isNull()) {
3490 DeducedA = CacheEntry;
3504 SuppressedDiagnosticsMap::iterator
3506 if (Pos == SuppressedDiagnostics.end())
3524 if (Method->isInstance()) {
3545 bool ParamWasReference) {
3553 if (ParamWasReference)
3600 Specialization, Info))
3608 if (ArgType.isNull())
continue;
3612 ArgType->isFunctionType())
3628 Deduced(TemplateParams->
size());
3632 ArgType, Info, Deduced, TDF);
3633 if (Result)
continue;
3669 ParamRefType !=
nullptr);
3730 (isa<PointerType>(ParamType) &&
3745 SmallVectorImpl<DeducedTemplateArgument> &Deduced,
3746 SmallVectorImpl<Sema::OriginalCallArg> &OriginalCallArgs,
3747 bool DecomposedParam,
unsigned ArgIdx,
unsigned TDF);
3754 SmallVectorImpl<DeducedTemplateArgument> &Deduced,
3755 SmallVectorImpl<Sema::OriginalCallArg> &OriginalCallArgs,
unsigned ArgIdx,
3771 ElTy = ArrTy->getElementType();
3781 if (isa<DesignatedInitExpr>(E))
3788 S, TemplateParams, 0, ElTy, E, Info, Deduced, OriginalCallArgs,
true,
3796 if (
auto *DependentArrTy = dyn_cast_or_null<DependentSizedArrayType>(ArrTy)) {
3808 true, Info, Deduced))
3821 SmallVectorImpl<DeducedTemplateArgument> &Deduced,
3822 SmallVectorImpl<Sema::OriginalCallArg> &OriginalCallArgs,
3823 bool DecomposedParam,
unsigned ArgIdx,
unsigned TDF) {
3825 QualType OrigParamType = ParamType;
3830 S, TemplateParams, FirstInnerIndex, ParamType, ArgType, Arg, TDF))
3836 Deduced, OriginalCallArgs, ArgIdx, TDF);
3843 OriginalCallArgs.push_back(
3846 ArgType, Info, Deduced, TDF);
3878 bool PartialOverloading,
3893 return TDK_TooFewArguments;
3894 else if (TooManyArguments(NumParams, Args.size(), PartialOverloading)) {
3896 if (Proto->isTemplateVariadic())
3898 else if (!Proto->isVariadic())
3899 return TDK_TooManyArguments;
3909 unsigned NumExplicitlySpecified = 0;
3910 if (ExplicitTemplateArgs) {
3912 SubstituteExplicitTemplateArguments(FunctionTemplate,
3913 *ExplicitTemplateArgs,
3921 NumExplicitlySpecified = Deduced.size();
3924 for (
unsigned I = 0; I != NumParams; ++I)
3931 auto DeduceCallArgument = [&](
QualType ParamType,
unsigned ArgIdx) {
3941 *
this, TemplateParams, FirstInnerIndex, ParamType, Args[ArgIdx], Info, Deduced,
3942 OriginalCallArgs,
false, ArgIdx, 0);
3946 Deduced.resize(TemplateParams->
size());
3948 for (
unsigned ParamIdx = 0, NumParamTypes = ParamTypes.size(), ArgIdx = 0;
3954 if (!ParamExpansion) {
3956 if (ArgIdx >= Args.size())
3959 ParamTypesForArgChecking.push_back(ParamType);
3960 if (
auto Result = DeduceCallArgument(ParamType, ArgIdx++))
3967 PackDeductionScope PackScope(*
this, TemplateParams, Deduced, Info,
3986 if (
ParamIdx + 1 == NumParamTypes || PackScope.hasFixedArity()) {
3987 for (; ArgIdx < Args.size() && PackScope.hasNextElement();
3988 PackScope.nextPackElement(), ++ArgIdx) {
3989 ParamTypesForArgChecking.push_back(ParamPattern);
3990 if (
auto Result = DeduceCallArgument(ParamPattern, ArgIdx))
3998 if (NumExpansions && !PackScope.isPartiallyExpanded()) {
3999 for (
unsigned I = 0; I != *NumExpansions && ArgIdx < Args.size();
4001 ParamTypesForArgChecking.push_back(ParamPattern);
4004 PackScope.nextPackElement();
4011 if (
auto Result = PackScope.finish())
4020 FunctionTemplate, Deduced, NumExplicitlySpecified, Specialization, Info,
4021 &OriginalCallArgs, PartialOverloading, [&, CallingCtx]() {
4023 return CheckNonDependent(ParamTypesForArgChecking);
4029 bool AdjustExceptionSpec) {
4030 if (ArgFunctionType.
isNull())
4031 return ArgFunctionType;
4036 bool Rebuild =
false;
4039 if (EPI.ExtInfo.getCC() != CC) {
4040 EPI.
ExtInfo = EPI.ExtInfo.withCallingConv(CC);
4044 bool NoReturn = FunctionTypeP->getNoReturnAttr();
4045 if (EPI.ExtInfo.getNoReturn() != NoReturn) {
4046 EPI.ExtInfo = EPI.ExtInfo.withNoReturn(NoReturn);
4050 if (AdjustExceptionSpec && (FunctionTypeP->hasExceptionSpec() ||
4052 EPI.ExceptionSpec = FunctionTypeP->getExtProtoInfo().ExceptionSpec;
4057 return ArgFunctionType;
4095 bool IsAddressOfFunction) {
4107 unsigned NumExplicitlySpecified = 0;
4109 if (ExplicitTemplateArgs) {
4111 = SubstituteExplicitTemplateArguments(FunctionTemplate,
4112 *ExplicitTemplateArgs,
4113 Deduced, ParamTypes,
4114 &FunctionType, Info))
4117 NumExplicitlySpecified = Deduced.size();
4123 if (!IsAddressOfFunction)
4124 ArgFunctionType = adjustCCAndNoReturn(ArgFunctionType, FunctionType,
4132 Deduced.resize(TemplateParams->
size());
4138 bool HasDeducedReturnType =
false;
4139 if (getLangOpts().CPlusPlus14 && IsAddressOfFunction &&
4141 FunctionType = SubstAutoType(FunctionType, Context.
DependentTy);
4142 HasDeducedReturnType =
true;
4145 if (!ArgFunctionType.
isNull()) {
4151 FunctionType, ArgFunctionType,
4152 Info, Deduced, TDF))
4158 NumExplicitlySpecified,
4159 Specialization, Info))
4164 if (HasDeducedReturnType &&
4166 DeduceReturnType(Specialization, Info.
getLocation(),
false))
4167 return TDK_MiscellaneousDeductionFailure;
4171 auto *SpecializationFPT =
4173 if (getLangOpts().CPlusPlus17 &&
4175 !ResolveExceptionSpec(Info.
getLocation(), SpecializationFPT))
4176 return TDK_MiscellaneousDeductionFailure;
4183 if (!IsAddressOfFunction)
4184 ArgFunctionType = adjustCCAndNoReturn(ArgFunctionType, SpecializationType,
4190 if (!ArgFunctionType.
isNull()) {
4191 if (IsAddressOfFunction &&
4192 !isSameOrCompatibleFunctionType(
4195 return TDK_MiscellaneousDeductionFailure;
4197 if (!IsAddressOfFunction &&
4198 !Context.
hasSameType(SpecializationType, ArgFunctionType))
4199 return TDK_MiscellaneousDeductionFailure;
4248 assert(!A->
isReferenceType() &&
"Reference types were handled above");
4285 Deduced.resize(TemplateParams->
size());
4309 P, A, Info, Deduced, TDF))
4318 ConversionSpecialized, Info);
4319 Specialization = cast_or_null<CXXConversionDecl>(ConversionSpecialized);
4351 bool IsAddressOfFunction) {
4354 IsAddressOfFunction);
4358 struct DependentAuto {
bool IsPack; };
4362 class SubstituteDeducedTypeTransform :
4365 bool ReplacementIsPack;
4369 SubstituteDeducedTypeTransform(
Sema &SemaRef, DependentAuto DA)
4371 ReplacementIsPack(DA.IsPack), UseTypeSugar(
true) {}
4373 SubstituteDeducedTypeTransform(
Sema &SemaRef,
QualType Replacement,
4374 bool UseTypeSugar =
true)
4376 Replacement(Replacement), ReplacementIsPack(
false),
4377 UseTypeSugar(UseTypeSugar) {}
4380 assert(isa<TemplateTypeParmType>(Replacement) &&
4381 "unexpected unsugared replacement kind");
4399 return TransformDesugared(TLB, TL);
4410 QualType TransformDeducedTemplateSpecializationType(
4413 return TransformDesugared(TLB, TL);
4417 Replacement, Replacement.
isNull());
4433 return TransformType(TLB, TL);
4442 bool IgnoreConstraints) {
4443 return DeduceAutoType(Type->
getTypeLoc(), Init, Result,
4444 DependentDeductionDepth, IgnoreConstraints);
4453 ArrayRef<SourceRange> Ranges) {
4457 auto D = S.
Diag(Info.
getLocation(), diag::err_auto_inconsistent_deduction);
4459 for (
auto R : Ranges)
4483 for (
unsigned I = 0, C = TypeLoc.
getNumArgs(); I != C; ++I)
4484 TemplateArgs.addArgument(TypeLoc.
getArgLoc(I));
4496 llvm::raw_string_ostream OS(Buf);
4497 OS <<
"'" << Concept->
getName();
4507 diag::err_placeholder_constraints_not_satisfied)
4534 bool IgnoreConstraints) {
4536 ExprResult NonPlaceholder = CheckPlaceholderExpr(Init);
4538 return DAR_FailedAlreadyDiagnosed;
4539 Init = NonPlaceholder.
get();
4542 DependentAuto DependentResult = {
4545 if (!DependentDeductionDepth &&
4548 Result = SubstituteDeducedTypeTransform(*
this, DependentResult).Apply(Type);
4549 assert(!Result.
isNull() &&
"substituting DependentTy can't fail");
4550 return DAR_Succeeded;
4554 unsigned Depth = DependentDeductionDepth.getValueOr(0);
4560 if (AT->isDecltypeAuto()) {
4561 if (isa<InitListExpr>(Init)) {
4563 return DAR_FailedAlreadyDiagnosed;
4568 return DAR_FailedAlreadyDiagnosed;
4572 return DAR_FailedAlreadyDiagnosed;
4575 if (AT->isConstrained() && !IgnoreConstraints) {
4576 auto ConstraintsResult =
4580 if (ConstraintsResult != DAR_Succeeded)
4581 return ConstraintsResult;
4583 Result = SubstituteDeducedTypeTransform(*
this, Deduced).Apply(Type);
4585 return DAR_FailedAlreadyDiagnosed;
4586 return DAR_Succeeded;
4587 }
else if (!getLangOpts().CPlusPlus) {
4588 if (isa<InitListExpr>(Init)) {
4590 return DAR_FailedAlreadyDiagnosed;
4601 Context,
nullptr,
SourceLocation(), Loc, Depth, 0,
nullptr,
false,
false,
4606 Context, Loc, Loc, TemplParamPtr, Loc,
nullptr);
4609 SubstituteDeducedTypeTransform(*
this, TemplArg,
false)
4611 assert(!FuncParam.
isNull() &&
4612 "substituting template parameter for 'auto' failed");
4626 SubstituteDeducedTypeTransform(*
this, DependentResult).Apply(Type);
4627 assert(!Result.
isNull() &&
"substituting DependentTy can't fail");
4628 return DAR_Succeeded;
4631 return DAR_FailedAlreadyDiagnosed;
4648 if (isa<DesignatedInitExpr>(E))
4652 for (
unsigned i = 0, e = InitList->
getNumInits(); i < e; ++i) {
4656 *
this, TemplateParamsSt.get(), 0, TemplArg, Init,
4657 Info, Deduced, OriginalCallArgs,
true,
4659 return DeductionFailed(TDK, {DeducedFromInitRange,
4660 Init->getSourceRange()});
4664 DeducedFromInitRange = Init->getSourceRange();
4668 Diag(Loc, diag::err_auto_bitfield);
4669 return DAR_FailedAlreadyDiagnosed;
4673 *
this, TemplateParamsSt.get(), 0, FuncParam, Init, Info, Deduced,
4674 OriginalCallArgs,
false, 0, 0))
4675 return DeductionFailed(TDK, {});
4680 return DeductionFailed(TDK_Incomplete, {});
4685 DeducedType = BuildStdInitializerList(DeducedType, Loc);
4686 if (DeducedType.isNull())
4687 return DAR_FailedAlreadyDiagnosed;
4691 if (AT->isConstrained() && !IgnoreConstraints) {
4692 auto ConstraintsResult =
4696 if (ConstraintsResult != DAR_Succeeded)
4697 return ConstraintsResult;
4701 Result = SubstituteDeducedTypeTransform(*
this, DeducedType).Apply(Type);
4703 return DAR_FailedAlreadyDiagnosed;
4707 QualType DeducedA = InitList ? Deduced[0].getAsType() : Result;
4709 assert((
bool)InitList == OriginalArg.DecomposedParam &&
4710 "decomposed non-init-list in auto deduction?");
4714 return DeductionFailed(TDK, {});
4718 return DAR_Succeeded;
4724 return SubstituteDeducedTypeTransform(
4725 *
this, DependentAuto{
4727 .TransformType(TypeWithAuto);
4728 return SubstituteDeducedTypeTransform(*
this, TypeToReplaceAuto)
4729 .TransformType(TypeWithAuto);
4735 return SubstituteDeducedTypeTransform(
4739 .TransformType(TypeWithAuto);
4740 return SubstituteDeducedTypeTransform(*
this, TypeToReplaceAuto)
4741 .TransformType(TypeWithAuto);
4746 return SubstituteDeducedTypeTransform(*
this, TypeToReplaceAuto,
4748 .TransformType(TypeWithAuto);
4752 if (isa<InitListExpr>(Init))
4755 ? diag::err_init_capture_deduction_failure_from_init_list
4756 : diag::err_auto_var_deduction_failure_from_init_list)
4760 VDecl->
isInitCapture() ? diag::err_init_capture_deduction_failure
4761 : diag::err_auto_var_deduction_failure)
4773 CXXRecordDecl *Lambda = cast<CXXMethodDecl>(FD)->getParent();
4778 CallOp = InstantiateFunctionDeclaration(
4787 InstantiateFunctionDefinition(Loc, CallOp);
4795 "failed to deduce lambda return type");
4798 QualType RetType = getLambdaConversionFunctionResultType(
4812 InstantiateFunctionDefinition(Loc, FD);
4818 Diag(Loc, diag::err_auto_fn_used_before_defined) << FD;
4822 return StillUndeduced;
4829 SmallVectorImpl<QualType> &ArgTypes) {
4843 ArgTypes.push_back(ArgTy);
4853 unsigned NumCallArguments1) {
4859 assert(Proto1 && Proto2 &&
"Function templates must have prototypes");
4862 Deduced.resize(TemplateParams->
size());
4893 unsigned NumComparedArguments = NumCallArguments1;
4895 if (!Method2 && Method1 && !Method1->
isStatic()) {
4898 ++NumComparedArguments;
4899 }
else if (!Method1 && Method2 && !Method2->
isStatic()) {
4906 Args2.insert(Args2.end(), Proto2->param_type_begin(),
4907 Proto2->param_type_end());
4912 if (Args1.size() > NumComparedArguments)
4913 Args1.resize(NumComparedArguments);
4914 if (Args2.size() > NumComparedArguments)
4915 Args2.resize(NumComparedArguments);
4917 Args1.data(), Args1.size(), Info, Deduced,
4928 S, TemplateParams, Proto2->getReturnType(), Proto1->
getReturnType(),
4951 unsigned ArgIdx = 0, NumArgs = Deduced.size();
4952 for (; ArgIdx != NumArgs; ++ArgIdx)
4953 if (Deduced[ArgIdx].isNull())
4960 if (ArgIdx == NumArgs) {
4967 llvm::SmallBitVector UsedParameters(TemplateParams->
size());
4970 for (
unsigned I = 0, N = Args2.size(); I != N; ++I)
4978 TemplateParams->
getDepth(), UsedParameters);
4988 for (; ArgIdx != NumArgs; ++ArgIdx)
4991 if (Deduced[ArgIdx].isNull() && UsedParameters[ArgIdx])
5010 while (--NumParams > 0) {
5041 unsigned NumCallArguments1,
5042 unsigned NumCallArguments2) {
5048 bool AtLeastAsConstrained1, AtLeastAsConstrained2;
5049 if (IsAtLeastAsConstrained(FT1, AC1, FT2, AC2, AtLeastAsConstrained1))
5051 if (IsAtLeastAsConstrained(FT2, AC2, FT1, AC1, AtLeastAsConstrained2))
5053 if (AtLeastAsConstrained1 == AtLeastAsConstrained2)
5055 return AtLeastAsConstrained1 ? FT1 : FT2;
5063 if (Better1 != Better2)
5064 return Better1 ? FT1 : FT2;
5066 if (!Better1 && !Better2)
5067 return JudgeByConstraints();
5074 if (Variadic1 != Variadic2)
5075 return Variadic1? FT2 : FT1;
5077 return JudgeByConstraints();
5121 bool Complain,
QualType TargetType) {
5122 if (SpecBegin == SpecEnd) {
5124 Diag(Loc, NoneDiag);
5130 if (SpecBegin + 1 == SpecEnd)
5137 = cast<FunctionDecl>(*Best)->getPrimaryTemplate();
5138 assert(BestTemplate &&
"Not a function template specialization?");
5141 = cast<FunctionDecl>(*I)->getPrimaryTemplate();
5142 assert(Challenger &&
"Not a function template specialization?");
5143 if (
isSameTemplate(getMoreSpecializedTemplate(BestTemplate, Challenger,
5147 BestTemplate = Challenger;
5153 bool Ambiguous =
false;
5156 = cast<FunctionDecl>(*I)->getPrimaryTemplate();
5158 !
isSameTemplate(getMoreSpecializedTemplate(BestTemplate, Challenger,
5173 Diag(Loc, AmbigDiag);
5178 const auto *FD = cast<FunctionDecl>(*I);
5179 PD << FD << getTemplateArgumentBindingsText(
5180 FD->getPrimaryTemplate()->getTemplateParameters(),
5181 *FD->getTemplateSpecializationArgs());
5182 if (!TargetType.
isNull())
5183 HandleFunctionTypeMismatch(PD, FD->getType(), TargetType);
5184 Diag((*I)->getLocation(), PD);
5198 template<
typename TemplateLikeDecl>
5200 TemplateLikeDecl *P2,
5229 Deduced.resize(P2->getTemplateParameters()->size());
5243 TST1->template_arguments()),
5272 if (!Better1 && !Better2)
5274 if (Better1 && Better2) {
5278 bool AtLeastAsConstrained1, AtLeastAsConstrained2;
5279 if (IsAtLeastAsConstrained(PS1, AC1, PS2, AC2, AtLeastAsConstrained1))
5281 if (IsAtLeastAsConstrained(PS2, AC2, PS1, AC1, AtLeastAsConstrained2))
5283 if (AtLeastAsConstrained1 == AtLeastAsConstrained2)
5285 return AtLeastAsConstrained1 ? PS1 : PS2;
5288 return Better1 ? PS1 : PS2;
5304 bool AtLeastAsConstrainedPrimary, AtLeastAsConstrainedSpec;
5305 if (IsAtLeastAsConstrained(Spec, SpecAC, Primary, PrimaryAC,
5306 AtLeastAsConstrainedSpec))
5308 if (!AtLeastAsConstrainedSpec)
5310 if (IsAtLeastAsConstrained(Primary, PrimaryAC, Spec, SpecAC,
5311 AtLeastAsConstrainedPrimary))
5313 return !AtLeastAsConstrainedPrimary;
5323 "the partial specializations being compared should specialize" 5324 " the same template.");
5336 if (!Better1 && !Better2)
5338 if (Better1 && Better2) {
5342 bool AtLeastAsConstrained1, AtLeastAsConstrained2;
5343 if (IsAtLeastAsConstrained(PS1, AC1, PS2, AC2, AtLeastAsConstrained1))
5345 if (IsAtLeastAsConstrained(PS2, AC2, PS1, AC1, AtLeastAsConstrained2))
5347 if (AtLeastAsConstrained1 == AtLeastAsConstrained2)
5349 return AtLeastAsConstrained1 ? PS1 : PS2;
5352 return Better1 ? PS1 : PS2;
5367 CanonTemplate, PrimaryArgs);
5379 bool AtLeastAsConstrainedPrimary, AtLeastAsConstrainedSpec;
5380 if (IsAtLeastAsConstrained(Spec, SpecAC, Primary, PrimaryAC,
5381 AtLeastAsConstrainedSpec))
5383 if (!AtLeastAsConstrainedSpec)
5385 if (IsAtLeastAsConstrained(Primary, PrimaryAC, Spec, SpecAC,
5386 AtLeastAsConstrainedPrimary))
5388 return !AtLeastAsConstrainedPrimary;
5424 for (
unsigned I = 0, N = P->
size(); I != N; ++I) {
5432 PArgList.addArgument(getTrivialTemplateArgumentLoc(
5440 if (CheckTemplateArgumentList(AArg, Loc, PArgList,
false, PArgs) ||
5456 struct MarkUsedTemplateParameterVisitor :
5458 llvm::SmallBitVector &
Used;
5461 MarkUsedTemplateParameterVisitor(llvm::SmallBitVector &Used,
5474 if (TTP->getDepth() ==
Depth)
5475 Used[TTP->getIndex()] =
true;
5482 if (
auto *NTTP = dyn_cast<NonTypeTemplateParmDecl>(E->
getDecl()))
5483 if (NTTP->getDepth() ==
Depth)
5484 Used[NTTP->getIndex()] =
true;
5497 llvm::SmallBitVector &
Used) {
5499 MarkUsedTemplateParameterVisitor(Used, Depth)
5500 .TraverseStmt(const_cast<Expr *>(E));
5506 E = Expansion->getPattern();
5512 E = ICE->getSubExpr();
5513 else if (
const ConstantExpr *CE = dyn_cast<ConstantExpr>(E))
5514 E = CE->getSubExpr();
5516 dyn_cast<SubstNonTypeTemplateParmExpr>(E))
5517 E = Subst->getReplacement();
5547 llvm::SmallBitVector &
Used) {
5554 OnlyDeduced, Depth, Used);
5564 llvm::SmallBitVector &
Used) {
5567 = dyn_cast<TemplateTemplateParmDecl>(Template)) {
5568 if (TTP->getDepth() ==
Depth)
5569 Used[TTP->getIndex()] =
true;
5588 llvm::SmallBitVector &
Used) {
5600 cast<PointerType>(T)->getPointeeType(),
5606 case Type::BlockPointer:
5608 cast<BlockPointerType>(T)->getPointeeType(),
5614 case Type::LValueReference:
5615 case Type::RValueReference:
5617 cast<ReferenceType>(T)->getPointeeType(),
5623 case Type::MemberPointer: {
5628 OnlyDeduced, Depth, Used);
5632 case Type::DependentSizedArray:
5634 cast<DependentSizedArrayType>(T)->getSizeExpr(),
5635 OnlyDeduced, Depth, Used);
5639 case Type::ConstantArray:
5640 case Type::IncompleteArray:
5642 cast<ArrayType>(T)->getElementType(),
5643 OnlyDeduced, Depth, Used);
5647 case Type::ExtVector:
5649 cast<VectorType>(T)->getElementType(),
5650 OnlyDeduced, Depth, Used);
5653 case Type::DependentVector: {
5654 const auto *VecType = cast<DependentVectorType>(T);
5661 case Type::DependentSizedExtVector: {
5663 = cast<DependentSizedExtVectorType>(T);
5671 case Type::DependentAddressSpace: {
5673 cast<DependentAddressSpaceType>(T);
5682 case Type::FunctionProto: {
5686 for (
unsigned I = 0, N = Proto->
getNumParams(); I != N; ++I) {
5691 if (!OnlyDeduced || I + 1 == N ||
5709 case Type::TemplateTypeParm: {
5716 case Type::SubstTemplateTypeParmPack: {
5718 = cast<SubstTemplateTypeParmPackType>(T);
5721 OnlyDeduced, Depth, Used);
5727 case Type::InjectedClassName:
5728 T = cast<InjectedClassNameType>(T)->getInjectedSpecializationType();
5731 case Type::TemplateSpecialization: {
5733 = cast<TemplateSpecializationType>(T);
5745 for (
unsigned I = 0, N = Spec->
getNumArgs(); I != N; ++I)
5754 cast<ComplexType>(T)->getElementType(),
5755 OnlyDeduced, Depth, Used);
5761 cast<AtomicType>(T)->getValueType(),
5762 OnlyDeduced, Depth, Used);
5765 case Type::DependentName:
5768 cast<DependentNameType>(T)->getQualifier(),
5769 OnlyDeduced, Depth, Used);
5772 case Type::DependentTemplateSpecialization: {
5786 = cast<DependentTemplateSpecializationType>(T);
5791 for (
unsigned I = 0, N = Spec->
getNumArgs(); I != N; ++I)
5801 OnlyDeduced, Depth, Used);
5804 case Type::TypeOfExpr:
5807 cast<TypeOfExprType>(T)->getUnderlyingExpr(),
5808 OnlyDeduced, Depth, Used);
5811 case Type::Decltype:
5814 cast<DecltypeType>(T)->getUnderlyingExpr(),
5815 OnlyDeduced, Depth, Used);
5818 case Type::UnaryTransform:
5822 OnlyDeduced, Depth, Used);
5825 case Type::PackExpansion:
5827 cast<PackExpansionType>(T)->getPattern(),
5828 OnlyDeduced, Depth, Used);
5832 case Type::DeducedTemplateSpecialization:
5834 cast<DeducedType>(T)->getDeducedType(),
5835 OnlyDeduced, Depth, Used);
5840 case Type::VariableArray:
5841 case Type::FunctionNoProto:
5844 case Type::ObjCInterface:
5845 case Type::ObjCObject:
5846 case Type::ObjCObjectPointer:
5847 case Type::UnresolvedUsing:
5849 #define TYPE(Class, Base) 5850 #define ABSTRACT_TYPE(Class, Base) 5851 #define DEPENDENT_TYPE(Class, Base) 5852 #define NON_CANONICAL_TYPE(Class, Base) case Type::Class: 5853 #include "clang/AST/TypeNodes.inc" 5865 llvm::SmallBitVector &
Used) {
5866 switch (TemplateArg.
getKind()) {
5911 llvm::SmallBitVector &
Used) {
5926 bool OnlyDeduced,
unsigned Depth,
5927 llvm::SmallBitVector &
Used) {
5936 for (
unsigned I = 0, N = TemplateArgs.
size(); I != N; ++I)
5945 llvm::SmallBitVector &Deduced) {
5949 Deduced.resize(TemplateParams->
size());
5952 for (
unsigned I = 0, N = Function->
getNumParams(); I != N; ++I)
5954 true, TemplateParams->
getDepth(), Deduced);
5965 llvm::SmallBitVector Deduced(TemplateParams->
size());
5969 return Deduced.any();
const IncompleteArrayType * getAsIncompleteArrayType(QualType T) const
QualType getPattern() const
Retrieve the pattern of this pack expansion, which is the type that will be repeatedly instantiated w...
Defines the clang::ASTContext interface.
The null pointer literal (C++11 [lex.nullptr])
Represents a function declaration or definition.
void getAssociatedConstraints(llvm::SmallVectorImpl< const Expr *> &AC) const
All associated constraints of this partial specialization, including the requires clause and any cons...
static DiagnosticBuilder Diag(DiagnosticsEngine *Diags, const LangOptions &Features, FullSourceLoc TokLoc, const char *TokBegin, const char *TokRangeBegin, const char *TokRangeEnd, unsigned DiagID)
Produce a diagnostic highlighting some portion of a literal.
bool hasExplicitTemplateArgs() const
Determines whether this expression had explicit template arguments.
bool isStrictSupersetOf(Qualifiers Other) const
Determine whether this set of qualifiers is a strict superset of another set of qualifiers, not considering qualifier compatibility.
static DeducedTemplateArgument checkDeducedTemplateArguments(ASTContext &Context, const DeducedTemplateArgument &X, const DeducedTemplateArgument &Y)
Verify that the given, deduced template arguments are compatible.
QualType getAdjustedParameterType(QualType T) const
Perform adjustment on the parameter type of a function.
const TypeClass * getTypePtr() const
RefQualifierKind getRefQualifier() const
Retrieve the ref-qualifier associated with this function type.
PointerType - C99 6.7.5.1 - Pointer Declarators.
QualType getPointeeType() const
A (possibly-)qualified type.
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 isMemberPointerType() const
bool isLambdaConversionOperator(CXXConversionDecl *C)
void DiagnoseUnsatisfiedConstraint(const ConstraintSatisfaction &Satisfaction, bool First=true)
Emit diagnostics explaining why a constraint expression was deemed unsatisfied.
A stack-allocated class that identifies which local variable declaration instantiations are present i...
const TypeClass * getTypePtr() 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.
unsigned getNumArgs() const
const Expr * getInit(unsigned Init) const
ArrayRef< TemplateArgument > getTypeConstraintArguments() const
static Sema::TemplateDeductionResult ConvertDeducedTemplateArguments(Sema &S, TemplateDeclT *Template, bool IsDeduced, SmallVectorImpl< DeducedTemplateArgument > &Deduced, TemplateDeductionInfo &Info, SmallVectorImpl< TemplateArgument > &Builder, LocalInstantiationScope *CurrentInstantiationScope=nullptr, unsigned NumAlreadyConverted=0, bool PartialOverloading=false)
FunctionType - C99 6.7.5.3 - Function Declarators.
static Sema::TemplateDeductionResult CheckOriginalCallArgDeduction(Sema &S, TemplateDeductionInfo &Info, Sema::OriginalCallArg OriginalArg, QualType DeducedA)
Check whether the deduced argument type for a call to a function template matches the actual argument...
Provides information about an attempted template argument deduction, whose success or failure was des...
QualType getPointeeType() const
If this is a pointer, ObjC object pointer, or block pointer, this returns the respective pointee...
C Language Family Type Representation.
void setObjCLifetime(ObjCLifetime type)
The template argument is an expression, and we've not resolved it to one of the other forms yet...
bool isRecordType() const
unsigned size() const
Retrieve the number of template arguments in this template argument list.
static TemplateTypeParmDecl * Create(const ASTContext &C, DeclContext *DC, SourceLocation KeyLoc, SourceLocation NameLoc, unsigned D, unsigned P, IdentifierInfo *Id, bool Typename, bool ParameterPack, bool HasTypeConstraint=false, Optional< unsigned > NumExpanded=None)
QualType getQualifiedType(SplitQualType split) const
Un-split a SplitQualType.
QualType getLValueReferenceType(QualType T, bool SpelledAsLValue=true) const
Return the uniqued reference to the type for an lvalue reference to the specified type...
const Type * getTypeForDecl() 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...
bool isVariadic() const
Whether this function prototype is variadic.
NestedNameSpecifier * getPrefix() const
Return the prefix of this nested name specifier.
QualType getDeducedTemplateSpecializationType(TemplateName Template, QualType DeducedType, bool IsDependent) const
C++17 deduced class template specialization type.
Defines the C++ template declaration subclasses.
Represents a C++11 auto or C++14 decltype(auto) type, possibly constrained by a type-constraint.
QualType getNonReferenceType() const
If Type is a reference type (e.g., const int&), returns the type that the reference refers to ("const...
QualType getBlockPointerType(QualType T) const
Return the uniqued reference to the type for a block of the specified type.
The base class of the type hierarchy.
CanQual< T > getUnqualifiedType() const
Retrieve the unqualified form of this type.
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...
NamedDecl * getParam(unsigned Idx)
A container of type source information.
TemplateParameterList * getTemplateParameters() const
Get the list of template parameters.
QualType getConversionType() const
Returns the type that this conversion function is converting to.
Partial ordering of function templates for a call to a conversion function.
bool TraverseTemplateName(TemplateName Template)
Recursively visit a template name and dispatch to the appropriate method.
void copy(AutoTypeLoc Loc)
TemplateDeductionResult FinishTemplateArgumentDeduction(FunctionTemplateDecl *FunctionTemplate, SmallVectorImpl< DeducedTemplateArgument > &Deduced, unsigned NumExplicitlySpecified, FunctionDecl *&Specialization, sema::TemplateDeductionInfo &Info, SmallVectorImpl< OriginalCallArg > const *OriginalCallArgs=nullptr, bool PartialOverloading=false, llvm::function_ref< bool()> CheckNonDependent=[]{ return false;})
Finish template argument deduction for a function template, checking the deduced template arguments f...
QualType getElementType() const
TemplateParameterList * getTemplateParameters() const
Get the list of template parameters.
SourceRange getLocalSourceRange() const
static void MarkUsedTemplateParameters(ASTContext &Ctx, const TemplateArgument &TemplateArg, bool OnlyDeduced, unsigned Depth, llvm::SmallBitVector &Used)
Mark the template parameters that are used by this template argument.
TemplateName getTemplateName() const
Retrieve the name of the template that we are deducing.
This file provides some common utility functions for processing Lambda related AST Constructs...
unsigned getDepth() const
Get the nesting depth of the template parameter.
RAII object that enters a new expression evaluation context.
Represents a variable declaration or definition.
void removeObjCLifetime()
QualType getReturnType() const
unsigned getNumParams() const
const T * getAs() const
Member-template getAs<specific type>'.
PrintingPolicy getPrintingPolicy() const
Retrieve a suitable printing policy for diagnostics.
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.
void Profile(llvm::FoldingSetNodeID &ID, const ASTContext &Context, bool Canonical) const
Produce a unique representation of the given statement.
QualifiedTemplateName * getAsQualifiedTemplateName() const
Retrieve the underlying qualified template name structure, if any.
NamedDecl * getUnderlyingDecl()
Looks through UsingDecls and ObjCCompatibleAliasDecls for the underlying named decl.
SourceLocation getLAngleLoc() const
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>".
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 ...
bool isInvalidDecl() const
Stores a list of template parameters for a TemplateDecl and its derived classes.
void clearSFINAEDiagnostic()
Discard any SFINAE diagnostics.
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...
bool isParameterPack() const
Whether this declaration is a parameter pack.
Whether we are performing template argument deduction for parameters and arguments in a top-level tem...
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.
QualType getIntegralType() const
Retrieve the type of the integral value.
SourceRange getSourceRange() const override LLVM_READONLY
Source range that this declaration covers.
The collection of all-type qualifiers we support.
Base wrapper for a particular "section" of type source info.
QualType adjustCCAndNoReturn(QualType ArgFunctionType, QualType FunctionType, bool AdjustExceptionSpec=false)
Adjust the type ArgFunctionType to match the calling convention, noreturn, and optionally the excepti...
const TemplateArgumentList & getTemplateArgs() const
Retrieve the template arguments of the class template specialization.
DeclarationName getDeclName() const
Get the actual, stored name of the declaration, which may be a special name.
FunctionType::ExtInfo ExtInfo
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.
TemplateArgument getPackExpansionPattern() const
When the template argument is a pack expansion, returns the pattern of the pack expansion.
QualType SubstAutoType(QualType TypeWithAuto, QualType Replacement)
Substitute Replacement for auto in TypeWithAuto.
static TemplateArgument getEmptyPack()
const TemplateArgument & get(unsigned Idx) const
Retrieve the template argument at a given index.
QualType getPointeeType() const
Expr * getAsExpr() const
Retrieve the template argument as an expression.
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
bool isObjCLifetimeType() const
Returns true if objects of this type have lifetime semantics under ARC.
The template argument is an integral value stored in an llvm::APSInt that was provided for an integra...
TemplateDecl * getAsTemplateDecl() const
Retrieve the underlying template declaration that this template name refers to, if known...
bool IsDerivedFrom(SourceLocation Loc, QualType Derived, QualType Base)
Determine whether the type Derived is a C++ class that is derived from the type Base.
SourceLocation getBeginLoc() const LLVM_READONLY
TemplateName getTemplateName() const
Retrieve the name of the template that we are specializing.
const Type * getAsType() const
Retrieve the type stored in this nested name specifier.
static bool isVariadicFunctionTemplate(FunctionTemplateDecl *FunTmpl)
Determine whether this a function template whose parameter-type-list ends with a function parameter p...
Defines the ExceptionSpecificationType enumeration and various utility functions. ...
static Sema::TemplateDeductionResult CheckDeducedArgumentConstraints(Sema &S, TemplateDeclT *Template, ArrayRef< TemplateArgument > DeducedArgs, TemplateDeductionInfo &Info)
static TemplateArgumentList * CreateCopy(ASTContext &Context, ArrayRef< TemplateArgument > Args)
Create a new template argument list that copies the given set of template arguments.
bool isReferenceType() const
The iterator over UnresolvedSets.
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...
bool isTemplateTemplateParameterAtLeastAsSpecializedAs(TemplateParameterList *PParam, TemplateDecl *AArg, SourceLocation Loc)
static NonTypeTemplateParmDecl * getDeducedParameterFromExpr(TemplateDeductionInfo &Info, Expr *E)
If the given expression is of a form that permits the deduction of a non-type template parameter...
void copyTemplateArgumentsInto(TemplateArgumentListInfo &List) const
Copies the template arguments into the given structure.
bool hasNonTrivialObjCLifetime() const
True if the lifetime is neither None or ExplicitNone.
ConstraintSatisfaction AssociatedConstraintsSatisfaction
The constraint satisfaction details resulting from the associated constraints satisfaction tests...
Within template argument deduction from overload resolution per C++ [over.over] allow matching functi...
QualType getParamTypeForDecl() const
ArrayRef< ParmVarDecl * > parameters() const
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...
DeduceAutoResult DeduceAutoType(TypeSourceInfo *AutoType, Expr *&Initializer, QualType &Result, Optional< unsigned > DependentDeductionDepth=None, bool IgnoreConstraints=false)
FunctionTemplateDecl * getCanonicalDecl() override
Retrieves the canonical declaration of this template.
bool isCompleteType(SourceLocation Loc, QualType T)
An rvalue reference type, per C++11 [dcl.ref].
void setNameLoc(SourceLocation Loc)
RefQualifierKind getRefQualifier() const
Retrieve the ref-qualifier associated with this method.
bool refersToBitField() const
Returns true if this expression is a gl-value that potentially refers to a bit-field.
bool HasFormOfMemberPointer
TemplateSpecCandidateSet - A set of generalized overload candidates, used in template specializations...
A convenient class for passing around template argument information.
const TemplateArgumentList & getTemplateArgs() const
Retrieve the template arguments of the variable template specialization.
void getAssociatedConstraints(llvm::SmallVectorImpl< const Expr *> &AC) const
All associated constraints of this partial specialization, including the requires clause and any cons...
bool hasAddressSpace() const
Forward-declares and imports various common LLVM datatypes that clang wants to use unqualified...
FunctionTemplateDecl * getDescribedFunctionTemplate() const
Retrieves the function template that is described by this function declaration.
bool isMoreSpecializedThanPrimary(ClassTemplatePartialSpecializationDecl *T, sema::TemplateDeductionInfo &Info)
QualType getNullPtrType() const
Retrieve the type for null non-type template argument.
unsigned toTargetAddressSpace(LangAS AS)
bool IsFunctionConversion(QualType FromType, QualType ToType, QualType &ResultTy)
Determine whether the conversion from FromType to ToType is a valid conversion that strips "noexcept"...
bool containsUnexpandedParameterPack() const
Whether this type is or contains an unexpanded parameter pack, used to support C++0x variadic templat...
Substitution of the deduced template argument values resulted in an error.
SourceLocation RAngleLoc
The source location of the right angle bracket ('>').
LangAS getAddressSpace() const
const TemplateArgument & getArg(unsigned Idx) const
const Type * getClass() const
void MarkDeducedTemplateParameters(const FunctionTemplateDecl *FunctionTemplate, llvm::SmallBitVector &Deduced)
VarTemplateDecl * getSpecializedTemplate() const
Retrieve the template that this specialization specializes.
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.
const Type * getTypePtr() const
Retrieves a pointer to the underlying (unqualified) type.
param_type_iterator param_type_begin() const
unsigned getIndex() const
Get the index of the template parameter within its parameter list.
const DependentSizedArrayType * getAsDependentSizedArrayType(QualType T) const
DeclContext * getLexicalDeclContext()
getLexicalDeclContext - The declaration context where this Decl was lexically declared (LexicalDC)...
TemplateArgumentLoc getIdentityTemplateArgumentLoc(NamedDecl *Param, SourceLocation Location)
Get a template argument mapping the given template parameter to itself, e.g.
SmallVector< DeducedTemplateArgument, 4 > New
A C++ lambda expression, which produces a function object (of unspecified type) that can be invoked l...
const LangOptions & getLangOpts() const
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.
QualType OriginalParamType
A class that does preorder or postorder depth-first traversal on the entire Clang AST and visits each...
SourceLocation getTypeSpecStartLoc() const
Expr * getSizeExpr() const
TemplateArgumentLoc getTrivialTemplateArgumentLoc(const TemplateArgument &Arg, QualType NTTPType, SourceLocation Loc)
Allocate a TemplateArgumentLoc where all locations have been initialized to the given location...
virtual Decl * getCanonicalDecl()
Retrieves the "canonical" declaration of the given declaration.
QualType getElementType() const
RAII object used to change the argument pack substitution index within a Sema object.
Represents an extended vector type where either the type or size is dependent.
This object can be modified without requiring retains or releases.
TyLocType push(QualType T)
Pushes space for a new TypeLoc of the given type.
A helper class for building up ExtParameterInfos.
Class that aids in the construction of nested-name-specifiers along with source-location information ...
static bool diagnoseAutoDeductionFailure(Sema &S, Sema::TemplateDeductionResult TDK, TemplateDeductionInfo &Info, ArrayRef< SourceRange > Ranges)
Attempt to produce an informative diagostic explaining why auto deduction failed. ...
bool isExpandedParameterPack() const
Whether this parameter is a non-type template parameter pack that has a known list of different types...
FunctionTemplateDecl * getPrimaryTemplate() const
Retrieve the primary template that this function template specialization either specializes or was in...
RAII class used to determine whether SFINAE has trapped any errors that occur during template argumen...
Expr * getAddrSpaceExpr() const
Provides definitions for the various language-specific address spaces.
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.
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.
Represents a prototype with parameter type info, e.g.
bool compatiblyIncludes(Qualifiers other) const
Determines if these qualifiers compatibly include another set.
void reset(TemplateArgumentList *NewDeduced)
Provide a new template argument list that contains the results of template argument deduction...
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...
std::pair< unsigned, unsigned > getDepthAndIndex(NamedDecl *ND)
Retrieve the depth and index of a template parameter.
static bool hasDeducibleTemplateParameters(Sema &S, FunctionTemplateDecl *FunctionTemplate, QualType T)
Template argument deduction did not deduce a value for every template parameter.
bool isNonOverloadPlaceholderType() const
Test for a placeholder type other than Overload; see BuiltinType::isNonOverloadPlaceholderType.
bool hasQualifiers() const
Determine whether this type has any qualifiers.
ConstantExpr - An expression that occurs in a constant context and optionally the result of evaluatin...
static Sema::TemplateDeductionResult DeduceFromInitializerList(Sema &S, TemplateParameterList *TemplateParams, QualType AdjustedParamType, InitListExpr *ILE, TemplateDeductionInfo &Info, SmallVectorImpl< DeducedTemplateArgument > &Deduced, SmallVectorImpl< Sema::OriginalCallArg > &OriginalCallArgs, unsigned ArgIdx, unsigned TDF)
Attempt template argument deduction from an initializer list deemed to be an argument in a function c...
The result of a constraint satisfaction check, containing the necessary information to diagnose an un...
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.
ValueDecl * getAsDecl() const
Retrieve the declaration for a declaration non-type template argument.
static bool isSimpleTemplateIdType(QualType T)
Determine whether the given type T is a simple-template-id type.
void setExplicitArgs(TemplateArgumentList *NewDeduced)
Provide an initial template argument list that contains the explicitly-specified arguments.
void runWithSufficientStackSpace(llvm::function_ref< void()> Diag, llvm::function_ref< void()> Fn)
Run a given function on a stack with "sufficient" space.
Represents an array type in C++ whose size is a value-dependent expression.
TemplateParameterList * getTemplateParameters() const
Get the list of template parameters.
static Sema::TemplateDeductionResult DeduceNullPtrTemplateArgument(Sema &S, TemplateParameterList *TemplateParams, NonTypeTemplateParmDecl *NTTP, QualType NullPtrType, TemplateDeductionInfo &Info, SmallVectorImpl< DeducedTemplateArgument > &Deduced)
Deduce the value of the given non-type template parameter from the given null pointer template argume...
A single parameter index whose accessors require each use to make explicit the parameter index encodi...
QualType getInjectedSpecializationType() const
Retrieves the injected specialization type for this partial specialization.
unsigned getNumArgs() const
Retrieve the number of template arguments.
Represent the declaration of a variable (in which case it is an lvalue) a function (in which case it ...
This represents one expression.
Defines the clang::LangOptions interface.
QualType getPointeeType() const
SourceLocation getLocation() const
Returns the location at which template argument is occurring.
DeducedPack(unsigned Index)
static Sema::TemplateDeductionResult DeduceNonTypeTemplateArgument(Sema &S, TemplateParameterList *TemplateParams, NonTypeTemplateParmDecl *NTTP, const DeducedTemplateArgument &NewDeduced, QualType ValueType, TemplateDeductionInfo &Info, SmallVectorImpl< DeducedTemplateArgument > &Deduced)
Deduce the value of the given non-type template parameter as the given deduced template argument...
Declaration of a template type parameter.
unsigned getIndex() const
static DeclContext * getAsDeclContextOrEnclosing(Decl *D)
static FindResult find(Expr *E)
Finds the overloaded expression in the given expression E of OverloadTy.
bool CheckConstraintSatisfaction(const NamedDecl *Template, ArrayRef< const Expr *> ConstraintExprs, ArrayRef< TemplateArgument > TemplateArgs, SourceRange TemplateIDRange, ConstraintSatisfaction &Satisfaction)
Check whether the given list of constraint expressions are satisfied (as if in a 'conjunction') given...
static Sema::TemplateDeductionResult DeduceTemplateArgumentsByTypeMatch(Sema &S, TemplateParameterList *TemplateParams, QualType Param, QualType Arg, TemplateDeductionInfo &Info, SmallVectorImpl< DeducedTemplateArgument > &Deduced, unsigned TDF, bool PartialOrdering=false, bool DeducedFromArrayBound=false)
Deduce the template arguments by comparing the parameter type and the argument type (C++ [temp...
static Sema::TemplateDeductionResult DeduceTemplateArgumentsFromCallArgument(Sema &S, TemplateParameterList *TemplateParams, unsigned FirstInnerIndex, QualType ParamType, Expr *Arg, TemplateDeductionInfo &Info, SmallVectorImpl< DeducedTemplateArgument > &Deduced, SmallVectorImpl< Sema::OriginalCallArg > &OriginalCallArgs, bool DecomposedParam, unsigned ArgIdx, unsigned TDF)
Perform template argument deduction per [temp.deduct.call] for a single parameter / argument pair...
unsigned NumTemplateArgs
The number of template arguments in TemplateArgs.
SourceLocation getLAngleLoc() const
const T * castAs() const
Member-template castAs<specific type>.
The template argument is a null pointer or null pointer to member that was provided for a non-type te...
static bool ConvertDeducedTemplateArgument(Sema &S, NamedDecl *Param, DeducedTemplateArgument Arg, NamedDecl *Template, TemplateDeductionInfo &Info, bool IsDeduced, SmallVectorImpl< TemplateArgument > &Output)
Convert the given deduced template argument and add it to the set of fully-converted template argumen...
T getAs() const
Convert to the specified TypeLoc type, returning a null TypeLoc if this TypeLoc is not of the desired...
void setInvalidDecl(bool Invalid=true)
setInvalidDecl - Indicates the Decl had a semantic error.
unsigned getNumInits() const
const TemplateArgumentList * getTemplateSpecializationArgs() const
Retrieve the template arguments used to produce this function template specialization from the primar...
bool CheckTemplateArgumentList(TemplateDecl *Template, SourceLocation TemplateLoc, TemplateArgumentListInfo &TemplateArgs, bool PartialTemplateArgs, SmallVectorImpl< TemplateArgument > &Converted, bool UpdateArgsWithConversions=true, bool *ConstraintsNotSatisfied=nullptr)
Check that the given template arguments can be be provided to the given template, converting the argu...
void completeExprArrayBound(Expr *E)
ClassTemplateDecl * getSpecializedTemplate() const
Retrieve the template that this specialization specializes.
ObjCLifetime getObjCLifetime() const
DeclContext * getDeclContext()
static Sema::DeduceAutoResult CheckDeducedPlaceholderConstraints(Sema &S, const AutoType &Type, AutoTypeLoc TypeLoc, QualType Deduced)
llvm::PointerUnion< TemplateTypeParmDecl *, NonTypeTemplateParmDecl *, TemplateTemplateParmDecl * > TemplateParameter
Stores a template parameter of any kind.
ArrayRef< TemplateArgument > asArray() const
Produce this as an array ref.
NonTypeTemplateParmDecl - Declares a non-type template parameter, e.g., "Size" in.
bool isTemplateParameterPack() const
isTemplateParameter - Determines whether this declaration is a template parameter pack...
Represents a C++ template name within the type system.
decls_iterator decls_begin() const
Defines the clang::TypeLoc interface and its subclasses.
The current expression and its subexpressions occur within an unevaluated operand (C++11 [expr]p7)...
ArrayRef< Expr * > inits()
AutoType * getContainedAutoType() const
Get the AutoType whose type will be deduced for a variable with an initializer of this type...
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...
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...
DeclContext * getParent()
getParent - Returns the containing DeclContext.
Data structure that captures multiple levels of template argument lists for use in template instantia...
SourceLocation getEnd() const
QualType getFunctionType(QualType ResultTy, ArrayRef< QualType > Args, const FunctionProtoType::ExtProtoInfo &EPI) const
Return a normal function type with a typed argument list.
bool DeduceReturnType(FunctionDecl *FD, SourceLocation Loc, bool Diagnose=true)
An lvalue reference type, per C++11 [dcl.ref].
TemplateTemplateParmDecl - Declares a template template parameter, e.g., "T" in.
Represents a reference to a non-type template parameter that has been substituted with a template arg...
Common base class for placeholders for types that get replaced by placeholder type deduction: C++11 a...
const FunctionProtoType::ExtParameterInfo * getPointerOrNull(unsigned numParams)
Return a pointer (suitable for setting in an ExtProtoInfo) to the ExtParameterInfo array we've built ...
bool isPackExpansion() const
Determine whether this template argument is a pack expansion.
Represents a C++ deduction guide declaration.
After substituting deduced template arguments, a dependent parameter type did not match the correspon...
Represents a C++ conversion function within a class.
QualType getTypeDeclType(const TypeDecl *Decl, const TypeDecl *PrevDecl=nullptr) const
Return the unique reference to the type for the specified type declaration.
bool isNull() const
Return true if this QualType doesn't point to a type yet.
void removeCVRQualifiers(unsigned mask)
CallingConv
CallingConv - Specifies the calling convention that a function uses.
FriendObjectKind getFriendObjectKind() const
Determines whether this declaration is the object of a friend declaration and, if so...
unsigned getCVRQualifiers() const
Retrieve the set of CVR (const-volatile-restrict) qualifiers applied to this type.
Captures a template argument whose value has been deduced via c++ template argument deduction...
static bool hasInconsistentOrSupersetQualifiersOf(QualType ParamType, QualType ArgType)
Determine whether the parameter has qualifiers that the argument lacks.
bool hasTrailingReturn() const
Whether this function prototype has a trailing return type.
RecordDecl * getDecl() const
static unsigned getPackIndexForParam(Sema &S, FunctionTemplateDecl *FunctionTemplate, const MultiLevelTemplateArgumentList &Args, unsigned ParamIdx)
Find the pack index for a particular parameter index in an instantiation of a function template with ...
SmallVector< DeducedPack *, 8 > PendingDeducedPacks
Information on packs that we're currently expanding.
There is no lifetime qualification on this type.
AutoTypeLoc getContainedAutoTypeLoc() const
Get the typeloc of an AutoType whose type will be deduced for a variable with an initializer of this ...
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...
ActionResult - This structure is used while parsing/acting on expressions, stmts, etc...
FunctionDecl * resolveAddressOfSingleOverloadCandidate(Expr *E, DeclAccessPair &FoundResult)
Given an expression that refers to an overloaded function, try to resolve that function to a single f...
A stack object to be created when performing template instantiation.
Stores a list of template parameters and the associated requires-clause (if any) for a TemplateDecl a...
ExtProtoInfo getExtProtoInfo() const
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.
SourceLocation getNameLoc() const
Gets the location of the name.
const ExtParameterInfo * ExtParameterInfos
DeduceAutoResult
Result type of DeduceAutoType.
Encodes a location in the source.
FunctionDecl * getTemplatedDecl() const
Get the underlying function declaration of the template.
static TemplateParameter makeTemplateParameter(Decl *D)
Helper function to build a TemplateParameter when we don't know its type statically.
QualType getReturnType() const
bool hasSameTemplateName(TemplateName X, TemplateName Y)
Determine whether the given template names refer to the same template.
LangAS getAddressSpace() const
Return the address space of this type.
Template argument deduction failed due to inconsistent cv-qualifiers on a template parameter type tha...
TemplateArgument getArgumentPack() const
static bool isSameTemplate(TemplateDecl *T1, TemplateDecl *T2)
Determine if the two templates are equivalent.
QualType getElementType() const
static QualType getUnderlyingType(const SubRegion *R)
Template argument deduction did not deduce a value for every expansion of an expanded template parame...
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.
const ConstantArrayType * getAsConstantArrayType(QualType T) const
bool hasExceptionSpec() const
Return whether this function has any kind of exception spec.
Represents a C++ nested name specifier, such as "\::std::vector<int>::".
const ParmVarDecl * getParamDecl(unsigned i) const
void DiagnoseAutoDeductionFailure(VarDecl *VDecl, Expr *Init)
void reserve(size_t Requested)
Ensures that this buffer has at least as much capacity as described.
const ArrayType * getAsArrayType(QualType T) const
Type Query functions.
unsigned pack_size() const
The number of template arguments in the given template argument pack.
QualType getInjectedClassNameSpecialization()
Retrieve the template specialization type of the injected-class-name for this class template...
Qualifiers getMethodQuals() const
const TemplateTypeParmType * getReplacedParameter() const
Gets the template parameter that was substituted for.
Expr * getNoexceptExpr() const
Return the expression inside noexcept(expression), or a null pointer if there is none (because the ex...
SourceLocation getRAngleLoc() const
TemplateDeductionResult DeduceTemplateArguments(ClassTemplatePartialSpecializationDecl *Partial, const TemplateArgumentList &TemplateArgs, sema::TemplateDeductionInfo &Info)
Perform template argument deduction to determine whether the given template arguments match the given...
Qualifiers withoutObjCLifetime() const
TypeSourceInfo * SubstAutoTypeSourceInfo(TypeSourceInfo *TypeWithAuto, QualType Replacement)
Substitute Replacement for auto in TypeWithAuto.
bool isMemberFunctionPointerType() const
bool isObjCObjectPointerType() const
bool isAnyPointerType() const
static unsigned getFirstInnerIndex(FunctionTemplateDecl *FTD)
Get the index of the first template parameter that was originally from the innermost template-paramet...
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 ...
bool isLValue() const
isLValue - True if this expression is an "l-value" according to the rules of the current language...
static bool isSameDeclaration(Decl *X, Decl *Y)
Determine whether two declaration pointers refer to the same declaration.
AutoTypeKeyword getKeyword() const
TypeClass getTypeClass() const
unsigned getMinRequiredArguments() const
Returns the minimum number of arguments needed to call this function.
llvm::APSInt getAsIntegral() const
Retrieve the template argument as an integral value.
SourceLocation getRAngleLoc() const
bool isTargetAddressSpace(LangAS AS)
unsigned getDeducedDepth() const
The depth of template parameters for which deduction is being performed.
diag_iterator diag_end() const
Returns an iterator at the end of the sequence of suppressed diagnostics.
An rvalue ref-qualifier was provided (&&).
unsigned getFullDataSize() const
Returns the size of the type source info data block.
Optional< unsigned > getNumExpansions() const
Retrieve the number of expansions that this pack expansion will generate, if known.
void addArgument(const TemplateArgumentLoc &Loc)
DependentTemplateName * getAsDependentTemplateName() const
Retrieve the underlying dependent template name structure, if any.
bool hasSameUnqualifiedType(QualType T1, QualType T2) const
Determine whether the given types are equivalent after cvr-qualifiers have been removed.
static bool hasPackExpansionBeforeEnd(ArrayRef< TemplateArgument > Args)
Determine whether the given set of template arguments has a pack expansion that is not the last templ...
SourceLocation getExprLoc() const LLVM_READONLY
getExprLoc - Return the preferred location for the arrow when diagnosing a problem with a generic exp...
QualType getArrayDecayedType(QualType T) const
Return the properly qualified result of decaying the specified array type to a pointer.
The injected class name of a C++ class template or class template partial specialization.
CanProxy< U > getAs() const
Retrieve a canonical type pointer with a different static type, upcasting or downcasting as needed...
QualType getPointeeType() const
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...
ArrayRef< TemplateArgument > pack_elements() const
Iterator range referencing all of the elements of a template argument pack.
Defines various enumerations that describe declaration and type specifiers.
A POD class for pairing a NamedDecl* with an access specifier.
bool isPlaceholderType() const
Test for a type which does not represent an actual type-system type but is instead used as a placehol...
const TemplateArgumentLoc * getTemplateArgs() const
Retrieve the template arguments.
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...
static std::enable_if< IsPartialSpecialization< T >::value, Sema::TemplateDeductionResult >::type FinishTemplateArgumentDeduction(Sema &S, T *Partial, bool IsPartialOrdering, const TemplateArgumentList &TemplateArgs, SmallVectorImpl< DeducedTemplateArgument > &Deduced, TemplateDeductionInfo &Info)
Complete template argument deduction for a partial specialization.
Represents a template argument.
QualType getTemplateSpecializationType(TemplateName T, ArrayRef< TemplateArgument > Args, QualType Canon=QualType()) const
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.
Dataflow Directional Tag Classes.
void getInjectedTemplateArgs(const TemplateParameterList *Params, SmallVectorImpl< TemplateArgument > &Args)
Get a template argument list with one argument per template parameter in a template parameter list...
CXXMethodDecl * getLambdaCallOperator() const
Retrieve the lambda call operator of the closure type if this is a closure type.
const TemplateArgument & getArgument() const
NestedNameSpecifier * getQualifier() 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.).
ExprResult ImpCastExprToType(Expr *E, QualType Type, CastKind CK, ExprValueKind VK=VK_RValue, const CXXCastPath *BasePath=nullptr, CheckedConversionKind CCK=CCK_ImplicitConversion)
ImpCastExprToType - If Expr is not of type 'Type', insert an implicit cast.
QualType getType() const
Get the type for which this source info wrapper provides information.
The template argument is a pack expansion of a template name that was provided for a template templat...
Qualifiers getMethodQualifiers() const
A non-depnedent component of the parameter did not match the corresponding component of the argument...
FunctionDecl * getTemplateInstantiationPattern() const
Retrieve the function declaration from which this function could be instantiated, if it is an instant...
const CXXRecordDecl * getParent() const
Return the parent of this method declaration, which is the class in which this method is defined...
OverloadExpr * Expression
Represents a C++11 pack expansion that produces a sequence of expressions.
SourceLocation LAngleLoc
The source location of the left angle bracket ('<').
A pointer to member type per C++ 8.3.3 - Pointers to members.
bool isParameterPack() const
Determine whether this variable is actually a function parameter pack or init-capture pack...
bool hasObjCLifetime() const
void setCVRQualifiers(unsigned mask)
bool isInitCapture() const
Whether this variable is the implicit variable for a lambda init-capture.
bool wasDeducedFromArrayBound() const
For a non-type template argument, determine whether the template argument was deduced from an array b...
pack_iterator pack_begin() const
Iterator referencing the first argument of a template argument pack.
bool isNull() const
Determine whether this template argument has no value.
No template argument deduction flags, which indicates the strictest results for template argument ded...
bool isUndeducedType() const
Determine whether this type is an undeduced type, meaning that it somehow involves a C++11 'auto' typ...
Allow non-dependent types to differ, e.g., when performing template argument deduction from a functio...
unsigned getDepth() const
Get the depth of this template parameter list in the set of template parameter lists.
Represents a pointer to an Objective C object.
static bool isForwardingReference(QualType Param, unsigned FirstInnerIndex)
Determine whether a type denotes a forwarding reference.
unsigned getIntWidth(QualType T) const
bool isIncompleteArrayType() const
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.
unsigned getNumArgs() const
Retrieve the number of template arguments.
The template argument was specified in the code or was instantiated with some deduced template argume...
TemplateArgumentList * take()
Take ownership of the deduced template argument list.
CanThrowResult canThrow() const
Determine whether this function type has a non-throwing exception specification.
const TemplateArgument & getArg(unsigned Idx) const
Retrieve a specific template argument as a type.
const llvm::APInt & getSize() const
bool isFunctionType() const
ExtVectorType - Extended vector type.
Base for LValueReferenceType and RValueReferenceType.
bool hasSameType(QualType T1, QualType T2) const
Determine whether the given types T1 and T2 are equivalent.
The deduced arguments did not satisfy the constraints associated with the template.
The template argument is a type.
Deduction failed; that's all we know.
TemplateArgument getInjectedTemplateArg(NamedDecl *ParamDecl)
Implements a partial diagnostic that can be emitted anwyhere in a DiagnosticBuilder stream...
The template argument is actually a parameter pack.
static bool AdjustFunctionParmAndArgTypesForDeduction(Sema &S, TemplateParameterList *TemplateParams, unsigned FirstInnerIndex, QualType &ParamType, QualType &ArgType, Expr *Arg, unsigned &TDF)
Perform the adjustments to the parameter and argument types described in C++ [temp.deduct.call].
uint64_t getTypeSize(QualType T) const
Return the size of the specified (complete) type T, in bits.
bool hasObjCGCAttr() const
CanQualType getCanonicalType(QualType T) const
Return the canonical (structural) type corresponding to the specified potentially non-canonical type ...
A template argument list.
bool isLValueReferenceType() const
TypeLoc getTypeLoc() const
Return the TypeLoc wrapper for the type source info.
X
Add a minimal nested name specifier fixit hint to allow lookup of a tag name from an outer enclosing ...
pack_iterator pack_end() const
Iterator referencing one past the last argument of a template argument pack.
ArgKind getKind() const
Return the kind of stored template argument.
unsigned getDepth() const
Defines the C++ Decl subclasses, other than those for templates (found in DeclTemplate.h) and friends (in DeclFriend.h).
QualType getParamType(unsigned i) const
Defines the clang::SourceLocation class and associated facilities.
NestedNameSpecifierLoc getWithLocInContext(ASTContext &Context) const
Retrieve a nested-name-specifier with location information, copied into the given AST context...
Within template argument deduction for a conversion function, we are matching with an argument type f...
QualType getUnqualifiedType() const
Retrieve the unqualified variant of the given type, removing as little sugar as possible.
Represents a C++ struct/union/class.
Represents a template specialization type whose template cannot be resolved, e.g. ...
ArrayRef< TemplateArgument > template_arguments() const
void getAssociatedConstraints(llvm::SmallVectorImpl< const Expr *> &AC) const
Get the total constraint-expression associated with this template, including constraint-expressions d...
QualType getRValueReferenceType(QualType T) const
Return the uniqued reference to the type for an rvalue reference to the specified type...
The template argument is a template name that was provided for a template template parameter...
unsigned getNumExplicitArgs() const
Get the number of explicitly-specified arguments.
Represents a C array with an unspecified size.
TemplateName getCanonicalTemplateName(TemplateName Name) const
Retrieves the "canonical" template name that refers to a given template.
bool hasExplicitTemplateArgs() const
Qualifiers getQualifiers() const
Retrieve the set of qualifiers applied to this type.
QualType removeAddrSpaceQualType(QualType T) const
Remove any existing address space on the type and returns the type with qualifiers intact (or that's ...
TPOC
The context in which partial ordering of function templates occurs.
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.
bool containsUnexpandedParameterPack() const
Whether this expression contains an unexpanded parameter pack (for C++11 variadic templates)...
Declaration of a class template.
Partial ordering of function templates for a function call.
QualType getPointerType(QualType T) const
Return the uniqued reference to the type for a pointer to the specified type.
After substituting deduced template arguments, an element of a dependent parameter type did not match...
SourceRange getSourceRange() const LLVM_READONLY
SourceLocation tokens are not useful in isolation - they are low level value objects created/interpre...
A pack that we're currently deducing.
DeducedTemplateArgument Saved
SourceLocation getNameLoc() const
SourceRange getSourceRange() const override LLVM_READONLY
Source range that this declaration covers.
StringRef getName() const
Get the name of identifier for this declaration as a StringRef.
unsigned getCVRQualifiers() const
static bool isSameTemplateArg(ASTContext &Context, TemplateArgument X, const TemplateArgument &Y, bool PackExpansionMatchesPack=false)
Determine whether two template arguments are the same.
QualType ReplaceAutoType(QualType TypeWithAuto, QualType Replacement)
Completely replace the auto in TypeWithAuto by Replacement.
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 Decl::Kind getKind(const Decl *D)
unsigned getNumElements() const
bool IsQualificationConversion(QualType FromType, QualType ToType, bool CStyle, bool &ObjCLifetimeConversion)
IsQualificationConversion - Determines whether the conversion from an rvalue of type FromType to ToTy...
bool isDependentType() const
Whether this type is a dependent type, meaning that its definition somehow depends on a template para...
QualType getAsType() const
Retrieve the type for a type template argument.
A reference to a declared variable, function, enum, etc.
Represents an extended address space qualifier where the input address space value is dependent...
Represents a type template specialization; the template must be a class template, a type alias templa...
Optional< unsigned > getNumArgumentsInExpansion(QualType T, const MultiLevelTemplateArgumentList &TemplateArgs)
Determine the number of arguments in the given pack expansion type.
void MarkUsedTemplateParameters(const Expr *E, bool OnlyDeduced, unsigned Depth, llvm::SmallBitVector &Used)
Mark which template parameters are used in a given expression.
bool isPointerType() const
TemplateArgumentLoc getArgLoc(unsigned i) const
unsigned CallArgIndex
The index of the function argument that caused a deduction failure.
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.
TypeSourceInfo * SubstType(TypeSourceInfo *T, const MultiLevelTemplateArgumentList &TemplateArgs, SourceLocation Loc, DeclarationName Entity, bool AllowDeducedTST=false)
Perform substitution on the type T with a given set of template arguments.
static bool hasSameExtendedValue(llvm::APSInt X, llvm::APSInt Y)
Compare two APSInts, extending and switching the sign as necessary to compare their values regardless...
static bool hasTemplateArgumentForDeduction(ArrayRef< TemplateArgument > &Args, unsigned &ArgIdx)
Determine whether there is a template argument to be used for deduction.
bool isUnresolvedExceptionSpec(ExceptionSpecificationType ESpecType)
Wrapper for template type parameters.
A trivial tuple used to represent a source range.
FunctionDecl * getCanonicalDecl() override
Retrieves the "canonical" declaration of the given declaration.
This represents a decl that may have a name.
Partial ordering of function templates in other contexts, e.g., taking the address of a function temp...
static Optional< unsigned > getExpandedPackSize(NamedDecl *Param)
If Param is an expanded parameter pack, get the number of expansions.
static void AddImplicitObjectParameterType(ASTContext &Context, CXXMethodDecl *Method, SmallVectorImpl< QualType > &ArgTypes)
If this is a non-static member function,.
QualType getNonTypeTemplateArgumentType() const
If this is a non-type template argument, get its type.
TemplateName getAsTemplate() const
Retrieve the template name for a template name argument.
The template argument was deduced via template argument deduction.
const ExtParameterInfo * getExtParameterInfosOrNull() const
Return a pointer to the beginning of the array of extra parameter information, if present...
ConceptDecl * getTypeConstraintConcept() const
bool isFunctionPointerType() const
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.
unsigned getNumParams() const
Return the number of parameters this function must have based on its FunctionType.
void removeAddressSpace()
brief A function argument from which we performed template argument
TemplateDecl * getDeducedTemplate() const
Get the template for which this guide performs deduction.
const LangOptions & getLangOpts() const
diag_iterator diag_begin() const
Returns an iterator at the beginning of the sequence of suppressed diagnostics.
decls_iterator decls_end() const
QualType getAutoType(QualType DeducedType, AutoTypeKeyword Keyword, bool IsDependent, bool IsPack=false, ConceptDecl *TypeConstraintConcept=nullptr, ArrayRef< TemplateArgument > TypeConstraintArgs={}) const
C++11 deduced auto type.
Represents the canonical version of C arrays with a specified constant size.
Declaration of a template function.
SourceLocation getConceptNameLoc() const
QualType getUnqualifiedArrayType(QualType T, Qualifiers &Quals)
Return this type as a completely-unqualified array type, capturing the qualifiers in Quals...
DeducedTemplateArgument DeferredDeduction
SourceLocation getLocation() const
QualType getPointeeType() const
CanQualType UnsignedIntTy
Expr * getSizeExpr() const
bool hasErrorOccurred() const
Determine whether any SFINAE errors have been trapped.
CanQualType getSizeType() const
Return the unique type for "size_t" (C99 7.17), defined in <stddef.h>.
param_type_iterator param_type_end() const