31 #include "llvm/Support/TimeProfiler.h" 33 using namespace clang;
60 bool RelativeToPrimary,
80 !isa<VarTemplatePartialSpecializationDecl>(Spec))
93 if (Partial->isMemberSpecialization())
96 VarTemplateDecl *Tmpl = Specialized.get<VarTemplateDecl *>();
110 = dyn_cast<TemplateTemplateParmDecl>(D)) {
111 for (
unsigned I = 0, N = TTP->getDepth() + 1; I != N; ++I)
125 !isa<ClassTemplatePartialSpecializationDecl>(Spec))
137 else if (
FunctionDecl *Function = dyn_cast<FunctionDecl>(Ctx)) {
138 if (!RelativeToPrimary &&
139 Function->getTemplateSpecializationKindForInstantiation() ==
144 = Function->getTemplateSpecializationArgs()) {
150 assert(Function->getPrimaryTemplate() &&
"No function template?");
151 if (Function->getPrimaryTemplate()->isMemberSpecialization())
159 = Function->getDescribedFunctionTemplate()) {
168 if (Function->getFriendObjectKind() &&
169 Function->getDeclContext()->isFileContext() &&
171 Ctx = Function->getLexicalDeclContext();
172 RelativeToPrimary =
false;
175 }
else if (
CXXRecordDecl *Rec = dyn_cast<CXXRecordDecl>(Ctx)) {
177 QualType T = ClassTemplate->getInjectedClassNameSpecialization();
182 if (ClassTemplate->isMemberSpecialization())
188 RelativeToPrimary =
false;
196 case TemplateInstantiation:
197 case ExceptionSpecInstantiation:
198 case DefaultTemplateArgumentInstantiation:
199 case DefaultFunctionArgumentInstantiation:
200 case ExplicitTemplateArgumentSubstitution:
201 case DeducedTemplateArgumentSubstitution:
202 case PriorTemplateArgumentSubstitution:
203 case ConstraintsCheck:
204 case NestedRequirementConstraintsCheck:
207 case RequirementInstantiation:
208 case DefaultTemplateArgumentChecking:
209 case DeclaringSpecialMember:
210 case DeclaringImplicitEqualityComparison:
211 case DefiningSynthesizedFunction:
212 case ExceptionSpecEvaluation:
213 case ConstraintSubstitution:
214 case ParameterMappingSubstitution:
215 case ConstraintNormalization:
216 case RewritingOperatorAsSpaceship:
224 llvm_unreachable(
"Invalid SynthesisKind!");
241 Invalid = CheckInstantiationDepth(PointOfInstantiation, InstantiationRange);
267 PointOfInstantiation, InstantiationRange, Entity) {}
274 PointOfInstantiation, InstantiationRange, Entity) {}
284 Template, TemplateArgs) {}
293 InstantiationRange, FunctionTemplate, nullptr,
294 TemplateArgs, &DeductionInfo) {
308 PointOfInstantiation, InstantiationRange, Template, nullptr,
309 TemplateArgs, &DeductionInfo) {}
319 PointOfInstantiation, InstantiationRange, PartialSpec, nullptr,
320 TemplateArgs, &DeductionInfo) {}
330 PointOfInstantiation, InstantiationRange, PartialSpec, nullptr,
331 TemplateArgs, &DeductionInfo) {}
339 PointOfInstantiation, InstantiationRange, Param, nullptr,
349 PointOfInstantiation, InstantiationRange, Param, Template,
359 PointOfInstantiation, InstantiationRange, Param, Template,
368 PointOfInstantiation, InstantiationRange, Param, Template,
377 PointOfInstantiation, InstantiationRange, nullptr,
378 nullptr, None, &DeductionInfo) {}
387 PointOfInstantiation, InstantiationRange, nullptr,
397 PointOfInstantiation, InstantiationRange, Template, nullptr,
406 PointOfInstantiation, InstantiationRange, Template, nullptr,
407 {}, &DeductionInfo) {}
415 PointOfInstantiation, InstantiationRange, Template) {}
423 PointOfInstantiation, InstantiationRange, Template) {}
442 if (!Active.isInstantiationRecord()) {
452 "forgot to remove a lookup module for a template instantiation");
471 if (!AlreadyInstantiating) {
475 std::make_pair(Active.Entity, Active.Kind));
486 bool Sema::InstantiatingTemplate::CheckInstantiationDepth(
496 SemaRef.
Diag(PointOfInstantiation,
497 diag::err_template_recursion_depth_exceeded)
499 << InstantiationRange;
500 SemaRef.
Diag(PointOfInstantiation, diag::note_template_recursion_depth)
512 SkipStart = Limit / 2 + Limit % 2;
517 unsigned InstantiationIdx = 0;
522 ++Active, ++InstantiationIdx) {
524 if (InstantiationIdx >= SkipStart && InstantiationIdx < SkipEnd) {
525 if (InstantiationIdx == SkipStart) {
528 diag::note_instantiation_contexts_suppressed)
534 switch (Active->Kind) {
536 Decl *D = Active->Entity;
538 unsigned DiagID = diag::note_template_member_class_here;
539 if (isa<ClassTemplateSpecializationDecl>(Record))
540 DiagID = diag::note_template_class_instantiation_here;
542 << Record << Active->InstantiationRange;
543 }
else if (
FunctionDecl *Function = dyn_cast<FunctionDecl>(D)) {
545 if (Function->getPrimaryTemplate())
546 DiagID = diag::note_function_template_spec_here;
548 DiagID = diag::note_template_member_function_here;
551 << Active->InstantiationRange;
552 }
else if (
VarDecl *VD = dyn_cast<VarDecl>(D)) {
554 VD->isStaticDataMember()?
555 diag::note_template_static_data_member_def_here
556 : diag::note_template_variable_def_here)
558 << Active->InstantiationRange;
559 }
else if (
EnumDecl *ED = dyn_cast<EnumDecl>(D)) {
561 diag::note_template_enum_def_here)
563 << Active->InstantiationRange;
564 }
else if (
FieldDecl *FD = dyn_cast<FieldDecl>(D)) {
566 diag::note_template_nsdmi_here)
567 << FD << Active->InstantiationRange;
570 diag::note_template_type_alias_instantiation_here)
571 << cast<TypeAliasTemplateDecl>(D)
572 << Active->InstantiationRange;
578 TemplateDecl *Template = cast<TemplateDecl>(Active->Template);
580 llvm::raw_svector_ostream OS(TemplateArgsStr);
585 diag::note_default_arg_instantiation_here)
587 << Active->InstantiationRange;
594 diag::note_explicit_template_arg_substitution_here)
597 Active->TemplateArgs,
598 Active->NumTemplateArgs)
599 << Active->InstantiationRange;
605 dyn_cast<FunctionTemplateDecl>(Active->Entity)) {
607 diag::note_function_template_deduction_instantiation_here)
610 Active->TemplateArgs,
611 Active->NumTemplateArgs)
612 << Active->InstantiationRange;
614 bool IsVar = isa<VarTemplateDecl>(Active->Entity) ||
615 isa<VarTemplateSpecializationDecl>(Active->Entity);
616 bool IsTemplate =
false;
618 if (
auto *D = dyn_cast<TemplateDecl>(Active->Entity)) {
620 Params = D->getTemplateParameters();
621 }
else if (
auto *D = dyn_cast<ClassTemplatePartialSpecializationDecl>(
623 Params = D->getTemplateParameters();
624 }
else if (
auto *D = dyn_cast<VarTemplatePartialSpecializationDecl>(
626 Params = D->getTemplateParameters();
628 llvm_unreachable(
"unexpected template kind");
632 diag::note_deduced_template_arg_substitution_here)
633 << IsVar << IsTemplate << cast<NamedDecl>(Active->Entity)
635 Active->NumTemplateArgs)
636 << Active->InstantiationRange;
642 ParmVarDecl *Param = cast<ParmVarDecl>(Active->Entity);
646 llvm::raw_svector_ostream OS(TemplateArgsStr);
651 diag::note_default_function_arg_instantiation_here)
653 << Active->InstantiationRange;
658 NamedDecl *Parm = cast<NamedDecl>(Active->Entity);
661 Name = std::string(
" '") + Parm->
getName().str() +
"'";
664 if (
TemplateDecl *Template = dyn_cast<TemplateDecl>(Active->Template))
665 TemplateParams = Template->getTemplateParameters();
668 cast<ClassTemplatePartialSpecializationDecl>(Active->Template)
669 ->getTemplateParameters();
671 diag::note_prior_template_arg_substitution)
672 << isa<TemplateTemplateParmDecl>(Parm)
675 Active->TemplateArgs,
676 Active->NumTemplateArgs)
677 << Active->InstantiationRange;
683 if (
TemplateDecl *Template = dyn_cast<TemplateDecl>(Active->Template))
684 TemplateParams = Template->getTemplateParameters();
687 cast<ClassTemplatePartialSpecializationDecl>(Active->Template)
688 ->getTemplateParameters();
691 diag::note_template_default_arg_checking)
693 Active->TemplateArgs,
694 Active->NumTemplateArgs)
695 << Active->InstantiationRange;
701 diag::note_evaluating_exception_spec_here)
702 << cast<FunctionDecl>(Active->Entity);
707 diag::note_template_exception_spec_instantiation_here)
708 << cast<FunctionDecl>(Active->Entity)
709 << Active->InstantiationRange;
714 diag::note_template_requirement_instantiation_here)
715 << Active->InstantiationRange;
720 diag::note_nested_requirement_here)
721 << Active->InstantiationRange;
726 diag::note_in_declaration_of_implicit_special_member)
727 << cast<CXXRecordDecl>(Active->Entity) << Active->SpecialMember;
732 diag::note_in_declaration_of_implicit_equality_comparison);
741 if (DFK.isSpecialMember()) {
742 auto *MD = cast<CXXMethodDecl>(FD);
744 diag::note_member_synthesized_at)
745 << MD->isExplicitlyDefaulted() << DFK.asSpecialMember()
747 }
else if (DFK.isComparison()) {
749 diag::note_comparison_synthesized_at)
750 << (int)DFK.asComparison()
752 cast<CXXRecordDecl>(FD->getLexicalDeclContext()));
759 diag::note_rewriting_operator_as_spaceship);
767 if (!Active->Entity) {
769 diag::note_nested_requirement_here)
770 << Active->InstantiationRange;
773 if (isa<ConceptDecl>(Active->Entity))
774 DiagID = diag::note_concept_specialization_here;
775 else if (isa<TemplateDecl>(Active->Entity))
776 DiagID = diag::note_checking_constraints_for_template_id_here;
777 else if (isa<VarTemplatePartialSpecializationDecl>(Active->Entity))
778 DiagID = diag::note_checking_constraints_for_var_spec_id_here;
779 else if (isa<ClassTemplatePartialSpecializationDecl>(Active->Entity))
780 DiagID = diag::note_checking_constraints_for_class_spec_id_here;
782 assert(isa<FunctionDecl>(Active->Entity));
783 DiagID = diag::note_checking_constraints_for_function_here;
786 llvm::raw_svector_ostream OS(TemplateArgsStr);
787 cast<NamedDecl>(Active->Entity)->printName(OS);
788 if (!isa<FunctionDecl>(Active->Entity))
791 Diags.
Report(Active->PointOfInstantiation, DiagID) << OS.str()
792 << Active->InstantiationRange;
797 diag::note_constraint_substitution_here)
798 << Active->InstantiationRange;
802 diag::note_constraint_normalization_here)
803 << cast<NamedDecl>(Active->Entity)->
getName()
804 << Active->InstantiationRange;
808 diag::note_parameter_mapping_substitution_here)
809 << Active->InstantiationRange;
825 switch (Active->Kind) {
829 if (isa<TypeAliasTemplateDecl>(Active->Entity))
856 assert(Active->DeductionInfo &&
"Missing deduction info pointer");
857 return Active->DeductionInfo;
879 if (Active->SavedInNonInstantiationSFINAEContext)
890 class TemplateInstantiator :
public TreeTransform<TemplateInstantiator> {
898 TemplateInstantiator(
Sema &SemaRef,
902 : inherited(SemaRef), TemplateArgs(TemplateArgs), Loc(Loc),
910 bool AlreadyTransformed(
QualType T);
922 this->Entity = Entity;
928 bool &ShouldExpand,
bool &RetainExpansion,
930 return getSema().CheckParameterPacksForExpansion(EllipsisLoc,
931 PatternRange, Unexpanded,
938 void ExpandingFunctionParameterPack(
ParmVarDecl *Pack) {
948 unsigned Depth, Index;
951 Result = TemplateArgs(Depth, Index);
967 unsigned Depth, Index;
977 void transformAttrs(
Decl *Old,
Decl *New) {
984 for (
auto *New : NewDecls)
986 Old, cast<VarDecl>(New));
990 assert(NewDecls.size() == 1 &&
991 "should only have multiple expansions for a pack");
992 Decl *New = NewDecls.front();
1000 if (
auto *NewTD = NewMD->getDescribedFunctionTemplate())
1001 NewTD->setInstantiatedFromMemberTemplate(
1002 OldMD->getDescribedFunctionTemplate());
1012 if (
auto *DC = dyn_cast<DeclContext>(Old))
1048 NamedDecl *FirstQualifierInScope =
nullptr,
1049 bool AllowInjectedClassName =
false);
1051 const LoopHintAttr *TransformLoopHintAttr(
const LoopHintAttr *LH);
1059 ExprResult TransformSubstNonTypeTemplateParmPackExpr(
1061 ExprResult TransformSubstNonTypeTemplateParmExpr(
1078 return inherited::TransformFunctionProtoType(TLB, TL);
1081 template<
typename Fn>
1086 Fn TransformExceptionSpec);
1089 int indexAdjustment,
1091 bool ExpectParameterPack);
1114 bool TransformRequiresExprRequirements(
1117 bool SatisfactionDetermined =
false;
1120 if (!SatisfactionDetermined) {
1121 if (
auto *TypeReq = dyn_cast<concepts::TypeRequirement>(Req))
1122 TransReq = TransformTypeRequirement(TypeReq);
1123 else if (
auto *ExprReq = dyn_cast<concepts::ExprRequirement>(Req))
1124 TransReq = TransformExprRequirement(ExprReq);
1126 TransReq = TransformNestedRequirement(
1127 cast<concepts::NestedRequirement>(Req));
1136 SatisfactionDetermined =
true;
1139 Transformed.push_back(TransReq);
1146 if (!OrigTPL || !OrigTPL->
size())
return OrigTPL;
1150 Owner, TemplateArgs);
1168 bool TemplateInstantiator::AlreadyTransformed(
QualType T) {
1175 getSema().MarkDeclarationsReferencedInType(Loc, T);
1184 if (Arg.isPackExpansion())
1194 if (TTP->getDepth() < TemplateArgs.getNumLevels()) {
1199 if (!TemplateArgs.hasTemplateArgument(TTP->getDepth(),
1200 TTP->getPosition()))
1205 if (TTP->isParameterPack()) {
1207 "Missing argument pack");
1213 "Wrong kind of template template argument");
1225 Decl *Inst = getSema().SubstDecl(D, getSema().
CurContext, TemplateArgs);
1229 getSema().CurrentInstantiationScope->InstantiatedLocal(D, Inst);
1234 TemplateInstantiator::TransformFirstQualifierInScope(
NamedDecl *D,
1240 = cast<TemplateTypeParmType>(getSema().Context.getTypeDeclType(TTPD));
1242 if (TTP->
getDepth() < TemplateArgs.getNumLevels()) {
1248 "Missing argument pack");
1250 if (getSema().ArgumentPackSubstitutionIndex == -1)
1258 return cast_or_null<NamedDecl>(TransformDecl(Loc, D));
1261 return Tag->getDecl();
1264 getSema().Diag(Loc, diag::err_nested_name_spec_non_tag) << T;
1269 return cast_or_null<NamedDecl>(TransformDecl(Loc, D));
1273 TemplateInstantiator::RebuildExceptionDecl(
VarDecl *ExceptionDecl,
1278 VarDecl *Var = inherited::RebuildExceptionDecl(ExceptionDecl, Declarator,
1279 StartLoc, NameLoc, Name);
1281 getSema().CurrentInstantiationScope->InstantiatedLocal(ExceptionDecl, Var);
1285 VarDecl *TemplateInstantiator::RebuildObjCExceptionDecl(
VarDecl *ExceptionDecl,
1288 VarDecl *Var = inherited::RebuildObjCExceptionDecl(ExceptionDecl, TSInfo, T);
1290 getSema().CurrentInstantiationScope->InstantiatedLocal(ExceptionDecl, Var);
1295 TemplateInstantiator::RebuildElaboratedType(
SourceLocation KeywordLoc,
1312 SemaRef.
Diag(TagLocation, diag::err_use_with_wrong_tag)
1327 TemplateName TemplateInstantiator::TransformTemplateName(
1330 bool AllowInjectedClassName) {
1333 if (TTP->getDepth() < TemplateArgs.getNumLevels()) {
1338 if (!TemplateArgs.hasTemplateArgument(TTP->getDepth(),
1339 TTP->getPosition()))
1344 if (TTP->isParameterPack()) {
1346 "Missing argument pack");
1348 if (getSema().ArgumentPackSubstitutionIndex == -1) {
1352 return getSema().Context.getSubstTemplateTemplateParmPack(TTP, Arg);
1359 assert(!Template.
isNull() &&
"Null template template argument");
1361 "template decl to substitute is qualified?");
1363 Template = getSema().Context.getSubstTemplateTemplateParm(TTP, Template);
1370 if (getSema().ArgumentPackSubstitutionIndex == -1)
1378 return inherited::TransformTemplateName(SS, Name, NameLoc, ObjectType,
1379 FirstQualifierInScope,
1380 AllowInjectedClassName);
1384 TemplateInstantiator::TransformPredefinedExpr(
PredefinedExpr *E) {
1392 TemplateInstantiator::TransformTemplateParmRefExpr(
DeclRefExpr *E,
1398 if (!TemplateArgs.hasTemplateArgument(NTTP->
getDepth(),
1404 if (TemplateArgs.getNumLevels() != TemplateArgs.getNumSubstitutedLevels()) {
1412 "unexpected pack arguments in partial substitution");
1416 "unexpected nontype template argument kind in partial substitution");
1422 "Missing argument pack");
1424 if (getSema().ArgumentPackSubstitutionIndex == -1) {
1443 return transformNonTypeTemplateParmRef(NTTP, E->
getLocation(), Arg);
1446 const LoopHintAttr *
1447 TemplateInstantiator::TransformLoopHintAttr(
const LoopHintAttr *LH) {
1448 Expr *TransformedExpr = getDerived().TransformExpr(LH->getValue()).
get();
1450 if (TransformedExpr == LH->getValue())
1454 if (getSema().CheckLoopHintExpr(TransformedExpr, LH->getLocation()))
1459 return LoopHintAttr::CreateImplicit(getSema().
Context, LH->getOption(),
1460 LH->getState(), TransformedExpr, *LH);
1463 ExprResult TemplateInstantiator::transformNonTypeTemplateParmRef(
1485 VD = cast_or_null<ValueDecl>(
1486 getSema().FindInstantiatedDecl(loc, VD, TemplateArgs));
1499 isa<PackExpansionType>(parm->
getType())) {
1501 cast<PackExpansionType>(parm->
getType())->getPattern(),
1507 assert(!type.
isNull() &&
"type substitution failed for param type");
1511 if (!result.isInvalid()) type = result.get()->getType();
1521 Expr *resultExpr = result.
get();
1523 type, resultExpr->
getValueKind(), loc, parm, resultExpr);
1527 TemplateInstantiator::TransformSubstNonTypeTemplateParmPackExpr(
1542 TemplateInstantiator::TransformSubstNonTypeTemplateParmExpr(
1572 SubstReplacement.
get(),
1575 return transformNonTypeTemplateParmRef(E->
getParameter(),
1582 return getSema().BuildDeclarationNameExpr(
CXXScopeSpec(), NameInfo, PD);
1593 return RebuildVarDeclRefExpr(VD, E->
getExprLoc());
1615 getSema().MarkFunctionParmPackReferenced(PackExpr);
1620 TemplateInstantiator::TransformFunctionParmPackRefExpr(
DeclRefExpr *E,
1623 llvm::PointerUnion<Decl *, DeclArgumentPack *> *Found
1624 = getSema().CurrentInstantiationScope->findInstantiationOf(PD);
1625 assert(Found &&
"no instantiation for parameter pack");
1627 Decl *TransformedDecl;
1628 if (DeclArgumentPack *Pack = Found->dyn_cast<DeclArgumentPack *>()) {
1637 getSema().MarkFunctionParmPackReferenced(PackExpr);
1641 TransformedDecl = (*Pack)[getSema().ArgumentPackSubstitutionIndex];
1643 TransformedDecl = Found->get<
Decl*>();
1647 return RebuildVarDeclRefExpr(cast<VarDecl>(TransformedDecl), E->
getExprLoc());
1651 TemplateInstantiator::TransformDeclRefExpr(
DeclRefExpr *E) {
1657 if (NTTP->
getDepth() < TemplateArgs.getNumLevels())
1658 return TransformTemplateParmRefExpr(E, NTTP);
1665 if (
VarDecl *PD = dyn_cast<VarDecl>(D))
1667 return TransformFunctionParmPackRefExpr(E, PD);
1672 ExprResult TemplateInstantiator::TransformCXXDefaultArgExpr(
1675 getDescribedFunctionTemplate() &&
1676 "Default arg expressions are never formed in dependent cases.");
1682 template<
typename Fn>
1687 Fn TransformExceptionSpec) {
1690 return inherited::TransformFunctionProtoType(
1691 TLB, TL, ThisContext, ThisTypeQuals, TransformExceptionSpec);
1695 TemplateInstantiator::TransformFunctionTypeParam(
ParmVarDecl *OldParm,
1696 int indexAdjustment,
1698 bool ExpectParameterPack) {
1701 NumExpansions, ExpectParameterPack);
1708 TemplateInstantiator::TransformTemplateTypeParmType(
TypeLocBuilder &TLB,
1711 if (T->
getDepth() < TemplateArgs.getNumLevels()) {
1730 "Missing argument pack");
1732 if (getSema().ArgumentPackSubstitutionIndex == -1) {
1737 = getSema().Context.getSubstTemplateTypeParmPackType(T, Arg);
1748 "Template argument kind mismatch");
1754 = getSema().Context.getSubstTemplateTypeParmType(T, Replacement);
1767 NewTTPDecl = cast_or_null<TemplateTypeParmDecl>(
1779 TemplateInstantiator::TransformSubstTemplateTypeParmPackType(
1794 Result = getSema().Context.getSubstTemplateTypeParmType(
1803 template<
typename EntityPr
inter>
1813 ErrorLoc = PDA.first;
1817 char *MessageBuf =
new (S.
Context)
char[Message.size()];
1818 std::copy(Message.begin(), Message.end(), MessageBuf);
1820 llvm::raw_svector_ostream OS(Entity);
1822 char *EntityBuf =
new (S.
Context)
char[Entity.size()];
1823 std::copy(Entity.begin(), Entity.end(), EntityBuf);
1825 StringRef(EntityBuf, Entity.size()), ErrorLoc,
1826 StringRef(MessageBuf, Message.size())};
1834 if (AlwaysRebuild())
1835 return RebuildTypeRequirement(
1845 if (TypeInst.isInvalid())
1850 [&] (llvm::raw_ostream& OS) {
1853 return RebuildTypeRequirement(TransType);
1864 llvm::PointerUnion<Expr *, concepts::Requirement::SubstitutionDiagnostic *>
1872 if (ExprInst.isInvalid())
1877 [&] (llvm::raw_ostream& OS) {
1882 TransExpr = TransExprRes.
get();
1887 if (RetReq.isEmpty())
1888 TransRetReq.emplace();
1889 else if (RetReq.isSubstitutionFailure())
1890 TransRetReq.emplace(RetReq.getSubstitutionDiagnostic());
1891 else if (RetReq.isTypeConstraint()) {
1893 RetReq.getTypeConstraintTemplateParameterList();
1896 if (TPLInst.isInvalid())
1899 TransformTemplateParameterList(OrigTPL);
1902 [&] (llvm::raw_ostream& OS) {
1903 RetReq.getTypeConstraint()->getImmediatelyDeclaredConstraint()
1908 TransRetReq.emplace(TPL);
1911 assert(TransRetReq.hasValue() &&
1912 "All code paths leading here must set TransRetReq");
1913 if (
Expr *E = TransExpr.dyn_cast<
Expr *>())
1915 std::move(*TransRetReq));
1916 return RebuildExprRequirement(
1922 TemplateInstantiator::TransformNestedRequirement(
1927 if (AlwaysRebuild())
1928 return RebuildNestedRequirement(
1946 if (ConstrInst.isInvalid())
1951 [&] (llvm::raw_ostream& OS) {
1956 return RebuildNestedRequirement(TransConstraint.get());
1994 bool AllowDeducedTST) {
1996 "Cannot perform an instantiation without some context on the " 1997 "instantiation stack");
2003 TemplateInstantiator Instantiator(*
this, Args, Loc, Entity);
2004 return AllowDeducedTST ? Instantiator.TransformTypeWithDeducedTST(T)
2005 : Instantiator.TransformType(T);
2013 "Cannot perform an instantiation without some context on the " 2014 "instantiation stack");
2028 TemplateInstantiator Instantiator(*
this, Args, Loc, Entity);
2043 "Cannot perform an instantiation without some context on the " 2044 "instantiation stack");
2051 TemplateInstantiator Instantiator(*
this, TemplateArgs, Loc, Entity);
2052 return Instantiator.TransformType(T);
2088 "Cannot perform an instantiation without some context on the " 2089 "instantiation stack");
2094 TemplateInstantiator Instantiator(*
this, Args, Loc, Entity);
2110 Result = Instantiator.TransformFunctionProtoType(
2111 TLB, Proto, ThisContext, ThisTypeQuals,
2113 bool &Changed) {
return false; });
2115 Result = Instantiator.TransformType(TLB, TL);
2129 bool Changed =
false;
2130 TemplateInstantiator Instantiator(*
this, Args, Loc,
DeclarationName());
2131 return Instantiator.TransformExceptionSpec(Loc, ESI, ExceptionStorage,
2142 ESI, ExceptionStorage, Args))
2151 struct GetContainedInventedTypeParmVisitor :
2152 public TypeVisitor<GetContainedInventedTypeParmVisitor,
2153 TemplateTypeParmDecl *> {
2154 using TypeVisitor<GetContainedInventedTypeParmVisitor,
2207 return VisitFunctionType(T);
2239 int indexAdjustment,
2241 bool ExpectParameterPack) {
2250 NewDI =
SubstType(ExpansionTL.getPatternLoc(), TemplateArgs,
2261 }
else if (ExpectParameterPack) {
2267 diag::err_function_parameter_pack_without_parameter_packs)
2291 GetContainedInventedTypeParmVisitor().Visit(OldDI->
getType())) {
2293 auto *Inst = cast_or_null<TemplateTypeParmDecl>(
2298 if (Inst && !Inst->getTypeConstraint()) {
2302 = TC->getTemplateArgsAsWritten();
2313 TC->getNestedNameSpecifierLoc(), TC->getConceptNameInfo(),
2314 TC->getNamedConcept(), &InstArgs, Inst,
2315 TTP->isParameterPack()
2316 ? cast<CXXFoldExpr>(TC->getImmediatelyDeclaredConstraint())
2394 "Cannot perform an instantiation without some context on the " 2395 "instantiation stack");
2397 TemplateInstantiator Instantiator(*
this, TemplateArgs, Loc,
2399 return Instantiator.TransformFunctionTypeParams(
2400 Loc, Params,
nullptr, ExtParamInfos, ParamTypes, OutParams, ParamInfos);
2413 bool Invalid =
false;
2415 for (
const auto &
Base : Pattern->
bases()) {
2416 if (!
Base.getType()->isDependentType()) {
2418 if (RD->isInvalidDecl())
2427 if (
Base.isPackExpansion()) {
2433 bool ShouldExpand =
false;
2434 bool RetainExpansion =
false;
2437 Base.getSourceRange(),
2439 TemplateArgs, ShouldExpand,
2448 for (
unsigned I = 0; I != *NumExpansions; ++I) {
2453 Base.getSourceRange().getBegin(),
2462 Base.getSourceRange(),
2464 Base.getAccessSpecifierAsWritten(),
2467 InstantiatedBases.push_back(InstantiatedBase);
2476 EllipsisLoc =
Base.getEllipsisLoc();
2480 Base.getSourceRange().getBegin(),
2485 Base.getSourceRange().getBegin(),
2496 Base.getSourceRange(),
2498 Base.getAccessSpecifierAsWritten(),
2501 InstantiatedBases.push_back(InstantiatedBase);
2555 Pattern, PatternDef, TSK, Complain))
2558 llvm::TimeTraceScope TimeScope(
"InstantiateClass", [&]() {
2560 llvm::raw_string_ostream OS(Name);
2566 Pattern = PatternDef;
2572 MSInfo->setPointOfInstantiation(PointOfInstantiation);
2574 = dyn_cast<ClassTemplateSpecializationDecl>(Instantiation)) {
2575 Spec->setTemplateSpecializationKind(TSK);
2576 Spec->setPointOfInstantiation(PointOfInstantiation);
2584 "instantiating class definition");
2602 SavePendingParsedClassStateRAII SavedPendingParsedClassState(*
this);
2615 Instantiation->
setTagKind(Pattern->getTagKind());
2627 bool MightHaveConstexprVirtualFunctions =
false;
2628 for (
auto *Member : Pattern->decls()) {
2638 if (Member->getDeclContext() != Pattern)
2643 if (isa<BlockDecl>(Member))
2646 if (Member->isInvalidDecl()) {
2651 Decl *NewMember = Instantiator.
Visit(Member);
2653 if (
FieldDecl *Field = dyn_cast<FieldDecl>(NewMember)) {
2654 Fields.push_back(Field);
2655 }
else if (
EnumDecl *Enum = dyn_cast<EnumDecl>(NewMember)) {
2661 Enum->isCompleteDefinition()) {
2663 assert(MSInfo &&
"no spec info for member enum specialization");
2668 if (SA->isFailed()) {
2674 }
else if (
CXXMethodDecl *MD = dyn_cast<CXXMethodDecl>(NewMember)) {
2675 if (MD->isConstexpr() && !MD->getFriendObjectKind() &&
2676 (MD->isVirtualAsWritten() || Instantiation->
getNumBases()))
2677 MightHaveConstexprVirtualFunctions =
true;
2698 if (ParsingClassDepth == 0)
2703 for (LateInstantiatedAttrVec::iterator I = LateAttrs.begin(),
2704 E = LateAttrs.end(); I != E; ++I) {
2717 I->NewDecl->addAttr(NewAttr);
2729 Instantiation->
setLocation(Pattern->getLocation());
2730 Instantiation->
setLocStart(Pattern->getInnerLocStart());
2745 P->first,
P->second)) {
2758 P->first,
P->second)) {
2777 else if (MightHaveConstexprVirtualFunctions)
2807 Pattern, PatternDef, TSK,
true))
2809 Pattern = PatternDef;
2815 MSInfo->setPointOfInstantiation(PointOfInstantiation);
2824 "instantiating enum definition");
2874 "pattern and instantiation disagree about init style");
2882 Diag(PointOfInstantiation,
2883 diag::err_in_class_initializer_not_yet_parsed)
2884 << OutermostClass << Pattern;
2885 Diag(Pattern->getEndLoc(), diag::note_in_class_initializer_not_yet_parsed);
2895 Diag(PointOfInstantiation, diag::err_in_class_initializer_cycle)
2900 "instantiating default member init");
2916 Expr *Init = NewInit.get();
2917 assert((!Init || !isa<ParenListExpr>(Init)) &&
"call-style init in class");
2922 L->DefaultMemberInitializerInstantiated(Instantiation);
2931 struct PartialSpecMatchResult {
2946 for (
unsigned I = 0, N = PartialSpecs.size(); I != N; ++I) {
2988 for (
unsigned I = 0, N = PartialSpecs.size(); I != N; ++I) {
3000 Matched.push_back(PartialSpecMatchResult());
3001 Matched.back().Partial = Partial;
3002 Matched.back().Args = Info.take();
3010 if (Matched.size() >= 1) {
3012 if (Matched.size() == 1) {
3025 PEnd = Matched.end();
3028 P->Partial, Best->Partial, PointOfInstantiation) ==
3035 bool Ambiguous =
false;
3037 PEnd = Matched.end();
3040 P->Partial, Best->Partial,
3041 PointOfInstantiation) != Best->Partial) {
3051 S.
Diag(PointOfInstantiation,
3052 diag::err_partial_spec_ordering_ambiguous)
3053 << ClassTemplateSpec;
3057 PEnd = Matched.end();
3059 S.
Diag(
P->Partial->getLocation(), diag::note_partial_spec_match)
3061 P->Partial->getTemplateParameters(), *
P->Args);
3076 if (
auto *PartialSpec =
3079 while (PartialSpec->getInstantiatedFromMember()) {
3082 if (PartialSpec->isMemberSpecialization())
3085 PartialSpec = PartialSpec->getInstantiatedFromMember();
3087 Pattern = PartialSpec;
3109 ClassTemplateSpec = cast<ClassTemplateSpecializationDecl>(
3115 *
this, PointOfInstantiation, ClassTemplateSpec, TSK, Complain);
3139 "Unexpected template specialization kind!");
3140 for (
auto *D : Instantiation->
decls()) {
3141 bool SuppressNew =
false;
3142 if (
auto *Function = dyn_cast<FunctionDecl>(D)) {
3144 Function->getInstantiatedFromMemberFunction()) {
3146 if (Function->hasAttr<ExcludeFromExplicitInstantiationAttr>())
3150 Function->getMemberSpecializationInfo();
3151 assert(MSInfo &&
"No member specialization information?");
3173 Function->setTemplateSpecializationKind(TSK, PointOfInstantiation);
3175 if (Function->isDefined()) {
3183 std::make_pair(Function, PointOfInstantiation));
3186 }
else if (
auto *Var = dyn_cast<VarDecl>(D)) {
3187 if (isa<VarTemplateSpecializationDecl>(Var))
3190 if (Var->isStaticDataMember()) {
3191 if (Var->hasAttr<ExcludeFromExplicitInstantiationAttr>())
3195 assert(MSInfo &&
"No member specialization information?");
3215 if (!Var->getInstantiatedFromStaticDataMember()->getDefinition())
3218 Var->setTemplateSpecializationKind(TSK, PointOfInstantiation);
3221 Var->setTemplateSpecializationKind(TSK, PointOfInstantiation);
3224 }
else if (
auto *Record = dyn_cast<CXXRecordDecl>(D)) {
3225 if (Record->hasAttr<ExcludeFromExplicitInstantiationAttr>())
3233 if (Record->isInjectedClassName() || Record->getPreviousDecl() ||
3238 assert(MSInfo &&
"No member specialization information?");
3264 assert(Pattern &&
"Missing instantiated-from-template information");
3266 if (!Record->getDefinition()) {
3287 Record->getTemplateSpecializationKind() ==
3289 Record->setTemplateSpecializationKind(TSK);
3294 Pattern = cast_or_null<CXXRecordDecl>(Record->getDefinition());
3298 }
else if (
auto *Enum = dyn_cast<EnumDecl>(D)) {
3300 assert(MSInfo &&
"No member specialization information?");
3307 PointOfInstantiation, TSK, Enum,
3313 if (Enum->getDefinition())
3316 EnumDecl *Pattern = Enum->getTemplateInstantiationPattern();
3317 assert(Pattern &&
"Missing instantiated-from-template information");
3323 InstantiateEnum(PointOfInstantiation, Enum, Pattern, TemplateArgs, TSK);
3328 }
else if (
auto *Field = dyn_cast<FieldDecl>(D)) {
3335 ClassPattern->
lookup(Field->getDeclName());
3370 TemplateInstantiator Instantiator(*
this, TemplateArgs,
3373 return Instantiator.TransformStmt(S);
3380 TemplateInstantiator Instantiator(*
this, TemplateArgs,
3383 return Instantiator.TransformTemplateArguments(Args.begin(), Args.end(),
3392 TemplateInstantiator Instantiator(*
this, TemplateArgs,
3395 return Instantiator.TransformExpr(E);
3400 bool CXXDirectInit) {
3401 TemplateInstantiator Instantiator(*
this, TemplateArgs,
3404 return Instantiator.TransformInitializer(Init, CXXDirectInit);
3413 TemplateInstantiator Instantiator(*
this, TemplateArgs,
3416 return Instantiator.TransformExprs(Exprs.data(), Exprs.size(),
3426 TemplateInstantiator Instantiator(*
this, TemplateArgs, NNS.
getBeginLoc(),
3428 return Instantiator.TransformNestedNameSpecifierLoc(NNS);
3435 TemplateInstantiator Instantiator(*
this, TemplateArgs, NameInfo.
getLoc(),
3437 return Instantiator.TransformDeclarationNameInfo(NameInfo);
3444 TemplateInstantiator Instantiator(*
this, TemplateArgs, Loc,
3447 SS.
Adopt(QualifierLoc);
3448 return Instantiator.TransformTemplateName(SS, Name, Loc);
3454 TemplateInstantiator Instantiator(*
this, TemplateArgs,
SourceLocation(),
3457 return Instantiator.TransformTemplateArguments(Args, NumArgs, Result);
3465 if (
const ParmVarDecl *PV = dyn_cast<ParmVarDecl>(D)) {
3466 if (
const FunctionDecl *FD = dyn_cast<FunctionDecl>(PV->getDeclContext())) {
3467 unsigned i = PV->getFunctionScopeIndex();
3470 if (i < FD->getNumParams() && FD->getParamDecl(i) == PV)
3478 llvm::PointerUnion<Decl *, LocalInstantiationScope::DeclArgumentPack *> *
3482 Current = Current->Outer) {
3485 const Decl *CheckD = D;
3487 LocalDeclsMap::iterator Found = Current->LocalDecls.find(CheckD);
3488 if (Found != Current->LocalDecls.end())
3489 return &Found->second;
3493 if (
const TagDecl *Tag = dyn_cast<TagDecl>(CheckD))
3500 if (!Current->CombineWithOuterScope)
3506 if (isa<NonTypeTemplateParmDecl>(D) || isa<TemplateTypeParmDecl>(D) ||
3507 isa<TemplateTemplateParmDecl>(D))
3512 if (RD->isLocalClass())
3517 if (isa<EnumDecl>(D))
3523 assert(isa<LabelDecl>(D) &&
"declaration not instantiated in this scope");
3529 llvm::PointerUnion<Decl *, DeclArgumentPack *> &Stored = LocalDecls[D];
3530 if (Stored.isNull()) {
3534 while (Current->CombineWithOuterScope && Current->Outer) {
3535 Current = Current->Outer;
3536 assert(Current->LocalDecls.find(D) == Current->LocalDecls.end() &&
3537 "Instantiated local in inner and outer scopes");
3542 Pack->push_back(cast<VarDecl>(Inst));
3544 assert(Stored.get<
Decl *>() == Inst &&
"Already instantiated this local");
3552 Pack->push_back(Inst);
3559 Current && Current->CombineWithOuterScope; Current = Current->Outer)
3560 assert(Current->LocalDecls.find(D) == Current->LocalDecls.end() &&
3561 "Creating local pack after instantiation of local");
3565 llvm::PointerUnion<Decl *, DeclArgumentPack *> &Stored = LocalDecls[D];
3568 ArgumentPacks.push_back(Pack);
3573 unsigned NumExplicitArgs) {
3574 assert((!PartiallySubstitutedPack || PartiallySubstitutedPack == Pack) &&
3575 "Already have a partially-substituted pack");
3576 assert((!PartiallySubstitutedPack
3577 || NumArgsInPartiallySubstitutedPack == NumExplicitArgs) &&
3578 "Wrong number of arguments in partially-substituted pack");
3579 PartiallySubstitutedPack = Pack;
3580 ArgsInPartiallySubstitutedPack = ExplicitArgs;
3581 NumArgsInPartiallySubstitutedPack = NumExplicitArgs;
3586 unsigned *NumExplicitArgs)
const {
3588 *ExplicitArgs =
nullptr;
3589 if (NumExplicitArgs)
3590 *NumExplicitArgs = 0;
3593 Current = Current->Outer) {
3594 if (Current->PartiallySubstitutedPack) {
3596 *ExplicitArgs = Current->ArgsInPartiallySubstitutedPack;
3597 if (NumExplicitArgs)
3598 *NumExplicitArgs = Current->NumArgsInPartiallySubstitutedPack;
3600 return Current->PartiallySubstitutedPack;
3603 if (!Current->CombineWithOuterScope)
SourceLocation getLoc() const
getLoc - Returns the main location of the declaration name.
QualType getPattern() const
Retrieve the pattern of this pack expansion, which is the type that will be repeatedly instantiated w...
const internal::VariadicAllOfMatcher< Type > type
Matches Types in the clang AST.
ExprResult BuildExpressionFromIntegralTemplateArgument(const TemplateArgument &Arg, SourceLocation Loc)
Construct a new expression that refers to the given integral template argument with the given source-...
Defines the clang::ASTContext interface.
unsigned getTemplateBacktraceLimit() const
Retrieve the maximum number of template instantiation notes to emit along with a given diagnostic...
void ActOnFinishDelayedMemberInitializers(Decl *Record)
Represents a type that was referred to using an elaborated type keyword, e.g., struct S...
void setScopeInfo(unsigned scopeDepth, unsigned parameterIndex)
void InstantiateClassMembers(SourceLocation PointOfInstantiation, CXXRecordDecl *Instantiation, const MultiLevelTemplateArgumentList &TemplateArgs, TemplateSpecializationKind TSK)
Instantiates the definitions of all of the member of the given class, which is an instantiation of a ...
We are defining a synthesized function (such as a defaulted special member).
Represents a function declaration or definition.
delayed_var_partial_spec_iterator delayed_var_partial_spec_begin()
no exception specification
const TypeClass * getTypePtr() const
if(T->getSizeExpr()) TRY_TO(TraverseStmt(T -> getSizeExpr()))
PointerType - C99 6.7.5.1 - Pointer Declarators.
QualType getPointeeType() const
SourceLocation getUsedLocation() const
Retrieve the location where this default argument was actually used.
A (possibly-)qualified type.
TemplateDeductionResult
Describes the result of template argument deduction.
void InstantiatedLocal(const Decl *D, Decl *Inst)
void UpdateExceptionSpec(FunctionDecl *FD, const FunctionProtoType::ExceptionSpecInfo &ESI)
unsigned getNumBases() const
Retrieves the number of base classes of this class.
A stack-allocated class that identifies which local variable declaration instantiations are present i...
A requires-expression requirement which queries the validity and properties of an expression ('simple...
std::vector< std::unique_ptr< TemplateInstantiationCallback > > TemplateInstCallbacks
The template instantiation callbacks to trace or track instantiations (objects can be chained)...
VarDecl * getParameterPack() const
Get the parameter pack which this expression refers to.
InClassInitStyle getInClassInitStyle() const
Get the kind of (C++11) default member initializer that this field has.
void addOuterTemplateArguments(const TemplateArgumentList *TemplateArgs)
Add a new outermost level to the multi-level template argument list.
Decl * Entity
The entity that is being synthesized.
Stmt - This represents one statement.
ExprResult SubstInitializer(Expr *E, const MultiLevelTemplateArgumentList &TemplateArgs, bool CXXDirectInit)
FunctionType - C99 6.7.5.3 - Function Declarators.
Provides information about an attempted template argument deduction, whose success or failure was des...
const llvm::Triple & getTriple() const
Returns the target triple of the primary target.
StorageClass getStorageClass() const
Returns the storage class as written in the source.
ExprResult BuildCXXDefaultArgExpr(SourceLocation CallLoc, FunctionDecl *FD, ParmVarDecl *Param)
BuildCXXDefaultArgExpr - Creates a CXXDefaultArgExpr, instantiating the default expr if needed...
The template argument is an expression, and we've not resolved it to one of the other forms yet...
void CheckCompletedCXXClass(Scope *S, CXXRecordDecl *Record)
Perform semantic checks on a class definition that has been completing, introducing implicitly-declar...
std::string getTemplateArgumentBindingsText(const TemplateParameterList *Params, const TemplateArgumentList &Args)
Produces a formatted string that describes the binding of template parameters to template arguments...
bool isInstantiationRecord() const
Determines whether this template is an actual instantiation that should be counted toward the maximum...
QualType getUnderlyingType() const
SemaDiagnosticBuilder Diag(SourceLocation Loc, unsigned DiagID)
Emit a diagnostic.
Decl - This represents one declaration (or definition), e.g.
llvm::PointerUnion< Decl *, DeclArgumentPack * > * findInstantiationOf(const Decl *D)
Find the instantiation of the declaration D within the current instantiation scope.
Defines the C++ template declaration subclasses.
void disableLateAttributeInstantiation()
SmallVector< CodeSynthesisContext, 16 > CodeSynthesisContexts
List of active code synthesis contexts.
Decl * getPreviousDecl()
Retrieve the previous declaration that declares the same entity as this declaration, or NULL if there is no previous declaration.
SmallVector< Module *, 16 > CodeSynthesisContextLookupModules
Extra modules inspected when performing a lookup during a template instantiation. ...
const RecordDecl * getParent() const
Returns the parent of this field declaration, which is the struct in which this field is defined...
bool InstantiateClassTemplateSpecialization(SourceLocation PointOfInstantiation, ClassTemplateSpecializationDecl *ClassTemplateSpec, TemplateSpecializationKind TSK, bool Complain=true)
std::deque< PendingImplicitInstantiation > PendingLocalImplicitInstantiations
The queue of implicit template instantiations that are required and must be performed within the curr...
DiagnosticBuilder Report(SourceLocation Loc, unsigned DiagID)
Issue the message to the client.
Represents an array type, per C99 6.7.5.2 - Array Declarators.
Declaration of a variable template.
The template argument is a declaration that was provided for a pointer, reference, or pointer to member non-type template parameter.
NamedDecl * getParam(unsigned Idx)
const TargetInfo & getTargetInfo() const
A container of type source information.
bool SubstExprs(ArrayRef< Expr *> Exprs, bool IsCall, const MultiLevelTemplateArgumentList &TemplateArgs, SmallVectorImpl< Expr *> &Outputs)
Substitute the given template arguments into a list of expressions, expanding pack expansions if requ...
IdentKind getIdentKind() const
bool isStackNearlyExhausted()
Determine whether the stack is nearly exhausted.
bool DiagnoseUninstantiableTemplate(SourceLocation PointOfInstantiation, NamedDecl *Instantiation, bool InstantiatedFromMember, const NamedDecl *Pattern, const NamedDecl *PatternDef, TemplateSpecializationKind TSK, bool Complain=true)
Determine whether we would be unable to instantiate this template (because it either has no definitio...
bool isSubstitutionFailure() const
We are instantiating a default argument for a template parameter.
VarTemplatePartialSpecializationDecl * InstantiateVarTemplatePartialSpecialization(VarTemplateDecl *VarTemplate, VarTemplatePartialSpecializationDecl *PartialSpec)
Instantiate the declaration of a variable template partial specialization.
TemplateTypeParmDecl * getDecl() const
void SetPartiallySubstitutedPack(NamedDecl *Pack, const TemplateArgument *ExplicitArgs, unsigned NumExplicitArgs)
Note that the given parameter pack has been partially substituted via explicit specification of templ...
TemplateName SubstTemplateName(NestedNameSpecifierLoc QualifierLoc, TemplateName Name, SourceLocation Loc, const MultiLevelTemplateArgumentList &TemplateArgs)
unsigned NonInstantiationEntries
The number of CodeSynthesisContexts that are not template instantiations and, therefore, should not be counted as part of the instantiation depth.
SubstitutionDiagnostic * getSubstitutionDiagnostic() const
bool hasInClassInitializer() const
Determine whether this member has a C++11 default member initializer.
void InstantiateVariableDefinition(SourceLocation PointOfInstantiation, VarDecl *Var, bool Recursive=false, bool DefinitionRequired=false, bool AtEndOfTU=false)
Instantiate the definition of the given variable from its template.
SourceLocation getEndLoc() const
Get the end source location.
QualType getElementType() const
LocalInstantiationScope * getStartingScope() const
This file provides some common utility functions for processing Lambda related AST Constructs...
void Adopt(NestedNameSpecifierLoc Other)
Adopt an existing nested-name-specifier (with source-range information).
SubstitutionDiagnostic * getExprSubstitutionDiagnostic() const
void setRAngleLoc(SourceLocation Loc)
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.
Information about one declarator, including the parsed type information and the identifier.
MatchFinder::MatchResult MatchResult
DiagnosticsEngine & Diags
const T * getAs() const
Member-template getAs<specific type>'.
PrintingPolicy getPrintingPolicy() const
Retrieve a suitable printing policy for diagnostics.
void ActOnFinishCXXNonNestedClass()
bool hasInheritedDefaultArg() const
decl_range decls() const
decls_begin/decls_end - Iterate over the declarations stored in this context.
QualifiedTemplateName * getAsQualifiedTemplateName() const
Retrieve the underlying qualified template name structure, if any.
Represents a variable template specialization, which refers to a variable template with a given set o...
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>".
bool isInvalidDecl() const
Stores a list of template parameters for a TemplateDecl and its derived classes.
A context in which code is being synthesized (where a source location alone is not sufficient to iden...
bool isParameterPack() const
Whether this declaration is a parameter pack.
TemplateSpecializationKind getTemplateSpecializationKind() const
Determine what kind of template specialization this is.
Represents a parameter to a function.
QualType getIntegralType() const
Retrieve the type of the integral value.
const TemplateArgument * TemplateArgs
The list of template arguments we are substituting, if they are not part of the entity.
The collection of all-type qualifiers we support.
const FunctionDecl * isLocalClass() const
If the class is a local class [class.local], returns the enclosing function declaration.
void setTemplateSpecializationKind(TemplateSpecializationKind TSK)
Set the kind of specialization or template instantiation this is.
IdentifierInfo * getIdentifier() const
Get the identifier that names this declaration, if there is one.
bool isLexicallyWithinFunctionOrMethod() const
Returns true if this declaration lexically is inside a function.
Base wrapper for a particular "section" of type source info.
Represents a struct/union/class.
enum clang::Sema::CodeSynthesisContext::SynthesisKind Kind
llvm::PointerUnion< VarTemplateDecl *, VarTemplatePartialSpecializationDecl * > getSpecializedTemplateOrPartial() const
Retrieve the variable template or variable template partial specialization which was specialized by t...
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.
void PrintInstantiationStack()
Prints the current instantiation stack through a series of notes.
QualType getOriginalType() const
One of these records is kept for each identifier that is lexed.
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.
TemplateArgument getPackExpansionPattern() const
When the template argument is a pack expansion, returns the pattern of the pack expansion.
C++2a [expr.prim.req]: A requires-expression provides a concise way to express requirements on templa...
TemplateName getNameToSubstitute() const
Get the template name to substitute when this template name is used as a template template argument...
QualType getPointeeType() const
Expr * getAsExpr() const
Retrieve the template argument as an expression.
void setUninstantiatedDefaultArg(Expr *arg)
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
A C++ nested-name-specifier augmented with source location information.
NestedNameSpecifierLoc SubstNestedNameSpecifierLoc(NestedNameSpecifierLoc NNS, const MultiLevelTemplateArgumentList &TemplateArgs)
TemplateSpecializationKind getSpecializationKind() const
Determine the kind of specialization that this declaration represents.
The results of name lookup within a DeclContext.
TemplateDecl * getAsTemplateDecl() const
Retrieve the underlying template declaration that this template name refers to, if known...
NamedDecl * getPartiallySubstitutedPack(const TemplateArgument **ExplicitArgs=nullptr, unsigned *NumExplicitArgs=nullptr) const
Retrieve the partially-substitued template parameter pack.
TypeSourceInfo * getTypeSourceInfo(ASTContext &Context, QualType T)
Creates a TypeSourceInfo for the given type.
SourceLocation getBeginLoc() const LLVM_READONLY
bool isAcceptableTagRedeclaration(const TagDecl *Previous, TagTypeKind NewTag, bool isDefinition, SourceLocation NewTagLoc, const IdentifierInfo *Name)
Determine whether a tag with a given kind is acceptable as a redeclaration of the given tag declarati...
Represents a member of a struct/union/class.
The current expression is potentially evaluated at run time, which means that code may be generated t...
void setArgument(unsigned Depth, unsigned Index, TemplateArgument Arg)
Clear out a specific template argument.
SubstTemplateTemplateParmPackStorage * getAsSubstTemplateTemplateParmPack() const
Retrieve the substituted template template parameter pack, if known.
NonTypeTemplateParmDecl * getParameter() const
unsigned getFunctionScopeIndex() const
Returns the index of this parameter in its prototype or method scope.
void setVisibleDespiteOwningModule()
Set that this declaration is globally visible, even if it came from a module that is not visible...
NamedDecl * Template
The template (or partial specialization) in which we are performing the instantiation, for substitutions of prior template arguments.
void startDefinition()
Starts the definition of this tag declaration.
bool usesPartialOrExplicitSpecialization(SourceLocation Loc, ClassTemplateSpecializationDecl *ClassTemplateSpec)
bool isReferenceType() const
bool isDefinedOutsideFunctionOrMethod() const
isDefinedOutsideFunctionOrMethod - This predicate returns true if this scoped decl is defined outside...
unsigned getPosition() const
Get the position of the template parameter within its parameter list.
bool CheckParameterPacksForExpansion(SourceLocation EllipsisLoc, SourceRange PatternRange, ArrayRef< UnexpandedParameterPack > Unexpanded, const MultiLevelTemplateArgumentList &TemplateArgs, bool &ShouldExpand, bool &RetainExpansion, Optional< unsigned > &NumExpansions)
Determine whether we could expand a pack expansion with the given set of parameter packs into separat...
DeclarationNameInfo SubstDeclarationNameInfo(const DeclarationNameInfo &NameInfo, const MultiLevelTemplateArgumentList &TemplateArgs)
Do template substitution on declaration name info.
void set(DeclAccessPair Found, Decl *Spec, DeductionFailureInfo Info)
SourceLocation getTemplateLoc() const
Represents a reference to a non-type template parameter pack that has been substituted with a non-tem...
delayed_var_partial_spec_iterator delayed_var_partial_spec_end()
QualType getParamTypeForDecl() const
Describes a module or submodule.
An r-value expression (a pr-value in the C++11 taxonomy) produces a temporary value.
We are instantiating the exception specification for a function template which was deferred until it ...
unsigned getNumExpansions() const
Get the number of parameters in this parameter pack.
void setNameLoc(SourceLocation Loc)
static DeclAccessPair make(NamedDecl *D, AccessSpecifier AS)
TemplateArgument getArgumentPack() const
Retrieve the template argument pack containing the substituted template arguments.
void setTemplateSpecializationKind(TemplateSpecializationKind TSK, SourceLocation PointOfInstantiation=SourceLocation())
For an enumeration member that was instantiated from a member enumeration of a templated class...
TemplateSpecCandidateSet - A set of generalized overload candidates, used in template specializations...
SourceLocation getParameterPackLocation() const
Retrieve the location of the parameter pack name.
A convenient class for passing around template argument information.
static TemplateArgument getPackSubstitutedTemplateArgument(Sema &S, TemplateArgument Arg)
We are checking the satisfaction of a nested requirement of a requires expression.
Expr * getConstraintExpr() const
void print(raw_ostream &OS, const PrintingPolicy &Policy, const Twine &PlaceHolder=Twine(), unsigned Indentation=0) const
StmtResult SubstStmt(Stmt *S, const MultiLevelTemplateArgumentList &TemplateArgs)
bool isMemberSpecialization() const
Determines whether this template was a specialization of a member template.
QualType getNullPtrType() const
Retrieve the type for null non-type template argument.
ExprValueKind getValueKind() const
getValueKind - The value kind that this expression produces.
Wrapper for substituted template type parameters.
Sugar type that represents a type that was qualified by a qualifier written as a macro invocation...
llvm::DenseSet< Module * > LookupModulesCache
Cache of additional modules that should be used for name lookup within the current template instantia...
bool containsUnexpandedParameterPack() const
Whether this type is or contains an unexpanded parameter pack, used to support C++0x variadic templat...
Wrapper for substituted template type parameters.
SourceLocation RAngleLoc
The source location of the right angle bracket ('>').
unsigned LastEmittedCodeSynthesisContextDepth
The depth of the context stack at the point when the most recent error or warning was produced...
SourceLocation PointOfInstantiation
The point of instantiation or synthesis within the source code.
MemberSpecializationInfo * getMemberSpecializationInfo() const
If this enumeration is an instantiation of a member enumeration of a class template specialization...
void setInstantiationOf(ClassTemplatePartialSpecializationDecl *PartialSpec, const TemplateArgumentList *TemplateArgs)
Note that this class template specialization is actually an instantiation of the given class template...
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.
bool SetParamDefaultArgument(ParmVarDecl *Param, Expr *DefaultArg, SourceLocation EqualLoc)
InstantiatingTemplate(Sema &SemaRef, SourceLocation PointOfInstantiation, Decl *Entity, SourceRange InstantiationRange=SourceRange())
Note that we are instantiating a class template, function template, variable template, alias template, or a member thereof.
const Type * getTypePtr() const
Retrieves a pointer to the underlying (unqualified) type.
CXXRecordDecl * getCanonicalDecl() override
Retrieves the "canonical" declaration of the given declaration.
const TemplateArgument * getArgs() const
Retrieve the template arguments.
bool hasUnparsedDefaultArg() const
Determines whether this parameter has a default argument that has not yet been parsed.
CXXBaseSpecifier * CheckBaseSpecifier(CXXRecordDecl *Class, SourceRange SpecifierRange, bool Virtual, AccessSpecifier Access, TypeSourceInfo *TInfo, SourceLocation EllipsisLoc)
ActOnBaseSpecifier - Parsed a base specifier.
SubstitutionDiagnostic * getSubstitutionDiagnostic() const
Represents a C++ nested-name-specifier or a global scope specifier.
DeclContext * getLexicalDeclContext()
getLexicalDeclContext - The declaration context where this Decl was lexically declared (LexicalDC)...
QualType getExpansionType(unsigned I) const
Retrieve a particular expansion type within an expanded parameter pack.
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.
bool isLambdaCallOperator(const CXXMethodDecl *MD)
CXXRecordDecl * getTemplatedDecl() const
Get the underlying class declarations of the template.
The current context is "potentially evaluated" in C++11 terms, but the expression is evaluated at com...
A default argument (C++ [dcl.fct.default]).
void setLocStart(SourceLocation L)
QualType getPointeeTypeAsWritten() const
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.
void warnStackExhausted(SourceLocation Loc)
Warn that the stack is nearly exhausted.
Represents an extended vector type where either the type or size is dependent.
TyLocType push(QualType T)
Pushes space for a new TypeLoc of the given type.
void InstantiateFunctionDefinition(SourceLocation PointOfInstantiation, FunctionDecl *Function, bool Recursive=false, bool DefinitionRequired=false, bool AtEndOfTU=false)
Instantiate the definition of the given function from its template.
A helper class for building up ExtParameterInfos.
lookup_result lookup(DeclarationName Name) const
lookup - Find the declarations (if any) with the given Name in this context.
bool isExpandedParameterPack() const
Whether this parameter is a non-type template parameter pack that has a known list of different types...
DiagnosticsEngine & getDiagnostics() const
RAII class used to determine whether SFINAE has trapped any errors that occur during template argumen...
bool SubstBaseSpecifiers(CXXRecordDecl *Instantiation, CXXRecordDecl *Pattern, const MultiLevelTemplateArgumentList &TemplateArgs)
Perform substitution on the base class specifiers of the given class template specialization.
void MakeInstantiatedLocalArgPack(const Decl *D)
We are substituting explicit template arguments provided for a function template. ...
TypeSourceInfo * SubstFunctionDeclType(TypeSourceInfo *T, const MultiLevelTemplateArgumentList &TemplateArgs, SourceLocation Loc, DeclarationName Entity, CXXRecordDecl *ThisContext, Qualifiers ThisTypeQuals)
A form of SubstType intended specifically for instantiating the type of a FunctionDecl.
Sema - This implements semantic analysis and AST building for C.
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.
A requires-expression requirement which queries the existence of a type name or type template special...
Represents a prototype with parameter type info, e.g.
bool InstantiateEnum(SourceLocation PointOfInstantiation, EnumDecl *Instantiation, EnumDecl *Pattern, const MultiLevelTemplateArgumentList &TemplateArgs, TemplateSpecializationKind TSK)
Instantiate the definition of an enum from a given pattern.
TemplateSpecializationKind getTemplateSpecializationKind() const
Determine whether this particular class is a specialization or instantiation of a class template or m...
std::pair< unsigned, unsigned > getDepthAndIndex(NamedDecl *ND)
Retrieve the depth and index of a template parameter.
static FunctionParmPackExpr * Create(const ASTContext &Context, QualType T, VarDecl *ParamPack, SourceLocation NameLoc, ArrayRef< VarDecl *> Params)
bool CheckSpecializationInstantiationRedecl(SourceLocation NewLoc, TemplateSpecializationKind NewTSK, NamedDecl *PrevDecl, TemplateSpecializationKind PrevTSK, SourceLocation PrevPtOfInstantiation, bool &SuppressNew)
Diagnose cases where we have an explicit template specialization before/after an explicit template in...
bool isParameterPack() const
Whether this parameter is a non-type template parameter pack.
SourceLocation getLocation() const
void ActOnFields(Scope *S, SourceLocation RecLoc, Decl *TagDecl, ArrayRef< Decl *> Fields, SourceLocation LBrac, SourceLocation RBrac, const ParsedAttributesView &AttrList)
We are instantiating a template declaration.
ValueDecl * getAsDecl() const
Retrieve the declaration for a declaration non-type template argument.
Added for Template instantiation observation.
bool InstantiateInClassInitializer(SourceLocation PointOfInstantiation, FieldDecl *Instantiation, FieldDecl *Pattern, const MultiLevelTemplateArgumentList &TemplateArgs)
Instantiate the definition of a field from the given pattern.
delayed_partial_spec_iterator delayed_partial_spec_begin()
Return an iterator to the beginning of the set of "delayed" partial specializations, which must be passed to InstantiateClassTemplatePartialSpecialization once the class definition has been completed.
SourceLocation getBeginLoc() const
Get the begin source location.
TemplateParameterList * getTemplateParameters() const
Get the list of template parameters.
TypeSourceInfo * CheckPackExpansion(TypeSourceInfo *Pattern, SourceLocation EllipsisLoc, Optional< unsigned > NumExpansions)
Construct a pack expansion type from the pattern of the pack expansion.
unsigned getFunctionScopeDepth() const
MultiLevelTemplateArgumentList getTemplateInstantiationArgs(NamedDecl *D, const TemplateArgumentList *Innermost=nullptr, bool RelativeToPrimary=false, const FunctionDecl *Pattern=nullptr)
Retrieve the template argument list(s) that should be used to instantiate the definition of the given...
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.
StringRef getKindName() const
SourceLocation getLocation() const
Returns the location at which template argument is occurring.
The "typename" keyword precedes the qualified type name, e.g., typename T::type.
void InstantiateAttrs(const MultiLevelTemplateArgumentList &TemplateArgs, const Decl *Pattern, Decl *Inst, LateInstantiatedAttrVec *LateAttrs=nullptr, LocalInstantiationScope *OuterMostScope=nullptr)
void deduceOpenCLAddressSpace(ValueDecl *decl)
void takeSFINAEDiagnostic(PartialDiagnosticAt &PD)
Take ownership of the SFINAE diagnostic.
bool hasUncompilableErrorOccurred() const
Errors that actually prevent compilation, not those that are upgraded from a warning by -Werror...
Declaration of a template type parameter.
unsigned getIndex() const
ClassTemplatePartialSpecializationDecl * InstantiateClassTemplatePartialSpecialization(ClassTemplateDecl *ClassTemplate, ClassTemplatePartialSpecializationDecl *PartialSpec)
Instantiate the declaration of a class template partial specialization.
unsigned NumTemplateArgs
The number of template arguments in TemplateArgs.
void PerformDependentDiagnostics(const DeclContext *Pattern, const MultiLevelTemplateArgumentList &TemplateArgs)
This file defines the classes used to store parsed information about declaration-specifiers and decla...
bool isInvalid() const
Determines whether we have exceeded the maximum recursive template instantiations.
We are substituting template argument determined as part of template argument deduction for either a ...
ElaboratedTypeKeyword
The elaboration keyword that precedes a qualified type name or introduces an elaborated-type-specifie...
The template argument is a null pointer or null pointer to member that was provided for a non-type te...
SourceLocation getBeginLoc() const
Retrieve the location of the beginning of this nested-name-specifier.
ExprResult BuildExpressionFromDeclTemplateArgument(const TemplateArgument &Arg, QualType ParamType, SourceLocation Loc)
Given a non-type template argument that refers to a declaration and the type of its corresponding non...
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.
bool isImplicit() const
isImplicit - Indicates whether the declaration was implicitly generated by the implementation.
const CXXRecordDecl * getTemplateInstantiationPattern() const
Retrieve the record declaration from which this record could be instantiated.
bool InNonInstantiationSFINAEContext
Whether we are in a SFINAE context that is not associated with template instantiation.
QualType getTagDeclType(const TagDecl *Decl) const
Return the unique reference to the type for the specified TagDecl (struct/union/class/enum) decl...
bool isSubstitutionFailure() const
ClassTemplateDecl * getSpecializedTemplate() const
Retrieve the template that this specialization specializes.
bool isFileContext() const
ParmVarDecl * SubstParmVarDecl(ParmVarDecl *D, const MultiLevelTemplateArgumentList &TemplateArgs, int indexAdjustment, Optional< unsigned > NumExpansions, bool ExpectParameterPack)
DeclContext * getDeclContext()
CXXRecordDecl * getDefinition() const
void ActOnFinishCXXInClassMemberInitializer(Decl *VarDecl, SourceLocation EqualLoc, Expr *Init)
This is invoked after parsing an in-class initializer for a non-static C++ class member, and after instantiating an in-class initializer in a class template.
llvm::PointerUnion< TemplateTypeParmDecl *, NonTypeTemplateParmDecl *, TemplateTemplateParmDecl * > TemplateParameter
Stores a template parameter of any kind.
NonTypeTemplateParmDecl - Declares a non-type template parameter, e.g., "Size" in.
Represents a C++ template name within the type system.
EnumDecl * getDefinition() const
llvm::PointerUnion< ClassTemplateDecl *, ClassTemplatePartialSpecializationDecl * > getSpecializedTemplateOrPartial() const
Retrieve the class template or class template partial specialization which was specialized by this...
void printTemplateArgumentList(raw_ostream &OS, ArrayRef< TemplateArgument > Args, const PrintingPolicy &Policy)
Print a template argument list, including the '<' and '>' enclosing the template arguments.
TypeSourceInfo * getType() const
llvm::FoldingSetVector< ClassTemplatePartialSpecializationDecl > & getPartialSpecializations()
Retrieve the set of partial specializations of this class template.
DeclContext * getParent()
getParent - Returns the containing DeclContext.
For a defaulted function, the kind of defaulted function that it is.
Data structure that captures multiple levels of template argument lists for use in template instantia...
void setLocation(SourceLocation L)
Represents a GCC generic vector type.
MemberSpecializationInfo * getMemberSpecializationInfo() const
If this class is an instantiation of a member class of a class template specialization, retrieves the member specialization information.
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...
bool isPackExpansion() const
Determine whether this template argument is a pack expansion.
SourceLocation getLocation() const
We are instantiating a requirement of a requires expression.
The result type of a method or function.
This template specialization was implicitly instantiated from a template.
bool isNull() const
Return true if this QualType doesn't point to a type yet.
void setDeclContext(DeclContext *DC)
setDeclContext - Set both the semantic and lexical DeclContext to DC.
NamedDecl * FindInstantiatedDecl(SourceLocation Loc, NamedDecl *D, const MultiLevelTemplateArgumentList &TemplateArgs, bool FindingInstantiatedContext=false)
Find the instantiation of the given declaration within the current instantiation. ...
PrettyDeclStackTraceEntry - If a crash occurs in the parser while parsing something related to a decl...
Attr * instantiateTemplateAttribute(const Attr *At, ASTContext &C, Sema &S, const MultiLevelTemplateArgumentList &TemplateArgs)
ClassTemplateDecl * getInstantiatedFromMemberTemplate() const
EnumDecl * getInstantiatedFromMemberEnum() const
Returns the enumeration (declared within the template) from which this enumeration type was instantia...
static void deleteScopes(LocalInstantiationScope *Scope, LocalInstantiationScope *Outermost)
deletes the given scope, and all otuer scopes, down to the given outermost scope. ...
virtual void printName(raw_ostream &os) const
void ActOnStartCXXInClassMemberInitializer()
Enter a new C++ default initializer scope.
void pushCodeSynthesisContext(CodeSynthesisContext Ctx)
We are declaring an implicit special member function.
ActionResult - This structure is used while parsing/acting on expressions, stmts, etc...
ExceptionSpecificationType Type
The kind of exception specification this is.
TypeLoc IgnoreParens() const
A stack object to be created when performing template instantiation.
Attr * instantiateTemplateAttributeForDecl(const Attr *At, ASTContext &C, Sema &S, const MultiLevelTemplateArgumentList &TemplateArgs)
ExtProtoInfo getExtProtoInfo() const
bool Subst(const TemplateArgumentLoc *Args, unsigned NumArgs, TemplateArgumentListInfo &Result, const MultiLevelTemplateArgumentList &TemplateArgs)
Encodes a location in the source.
Sugar for parentheses used when specifying types.
QualType getReturnType() const
We are computing the exception specification for a defaulted special member function.
void atTemplateBegin(TemplateInstantiationCallbackPtrs &Callbacks, const Sema &TheSema, const Sema::CodeSynthesisContext &Inst)
bool isVariablyModifiedType() const
Whether this type is a variably-modified type (C99 6.7.5).
void setBraceRange(SourceRange R)
sema::TemplateDeductionInfo * DeductionInfo
The template deduction info object associated with the substitution or checking of explicit or deduce...
A structure for storing an already-substituted template template parameter pack.
DeclarationName getName() const
getName - Returns the embedded declaration name.
Represents the declaration of a struct/union/class/enum.
TemplateArgument getArgumentPack() const
TemplateParameterList * SubstTemplateParams(TemplateParameterList *List)
Instantiates a nested template parameter list in the current instantiation context.
QualType getElementType() const
Expr * getInClassInitializer() const
Get the C++11 default member initializer for this member, or null if one has not been set...
SynthesisKind
The kind of template instantiation we are performing.
std::pair< SourceLocation, PartialDiagnostic > PartialDiagnosticAt
A partial diagnostic along with the source location where this diagnostic occurs. ...
Represents a static or instance method of a struct/union/class.
VarDecl * getExpansion(unsigned I) const
Get an expansion of the parameter pack by index.
We are checking the validity of a default template argument that has been used when naming a template...
bool isParameterPack() const
SourceLocation getNoexceptLoc() const
void reserve(size_t Requested)
Ensures that this buffer has at least as much capacity as described.
unsigned pack_size() const
The number of template arguments in the given template argument pack.
const TemplateTypeParmType * getReplacedParameter() const
Gets the template parameter that was substituted for.
TemplateSpecializationKind getSpecializationKind() const
Determine the kind of specialization that this declaration represents.
static const Decl * getCanonicalParmVarDecl(const Decl *D)
TemplateDeductionResult DeduceTemplateArguments(ClassTemplatePartialSpecializationDecl *Partial, const TemplateArgumentList &TemplateArgs, sema::TemplateDeductionInfo &Info)
Perform template argument deduction to determine whether the given template arguments match the given...
QualType getInnerType() const
void setTagKind(TagKind TK)
void InstantiateEnumDefinition(EnumDecl *Enum, EnumDecl *Pattern)
llvm::DenseSet< std::pair< Decl *, unsigned > > InstantiatingSpecializations
Specializations whose definitions are currently being instantiated.
bool hasUninstantiatedDefaultArg() const
void MarkVTableUsed(SourceLocation Loc, CXXRecordDecl *Class, bool DefinitionRequired=false)
Note that the vtable for the given class was used at the given location.
This template specialization was instantiated from a template due to an explicit instantiation defini...
bool SubstTemplateArguments(ArrayRef< TemplateArgumentLoc > Args, const MultiLevelTemplateArgumentList &TemplateArgs, TemplateArgumentListInfo &Outputs)
Represents a C++11 static_assert declaration.
DeductionFailureInfo MakeDeductionFailureInfo(ASTContext &Context, Sema::TemplateDeductionResult TDK, sema::TemplateDeductionInfo &Info)
Convert from Sema's representation of template deduction information to the form used in overload-can...
A static requirement that can be used in a requires-expression to check properties of types and expre...
DefaultedFunctionKind getDefaultedFunctionKind(const FunctionDecl *FD)
Determine the kind of defaulting that would be done for a given function.
ArrayRef< ParmVarDecl * > getParams() const
unsigned getFullDataSize() const
Returns the size of the type source info data block.
bool hasTemplateArgument(unsigned Depth, unsigned Index) const
Determine whether there is a non-NULL template argument at the given depth and index.
static TagTypeKind getTagTypeKindForKeyword(ElaboratedTypeKeyword Keyword)
Converts an elaborated type keyword into a TagTypeKind.
void InstantiatedLocalPackArg(const Decl *D, VarDecl *Inst)
void setHasInheritedDefaultArg(bool I=true)
void setLAngleLoc(SourceLocation Loc)
bool isGenericLambdaCallOperatorOrStaticInvokerSpecialization(DeclContext *DC)
const TemplateArgumentList & getTemplateInstantiationArgs() const
Retrieve the set of template arguments that should be used to instantiate the initializer of the vari...
bool isInstantiationDependentType() const
Determine whether this type is an instantiation-dependent type, meaning that the type involves a temp...
SourceLocation getExprLoc() const LLVM_READONLY
getExprLoc - Return the preferred location for the arrow when diagnosing a problem with a generic exp...
Represents a pack expansion of types.
void setTemplateSpecializationKind(TemplateSpecializationKind TSK)
Set the template specialization kind.
SourceLocation getLocation() const
const TemplateArgumentLoc * getTemplateArgs() const
Retrieve the template arguments.
void InstantiateClassTemplateSpecializationMembers(SourceLocation PointOfInstantiation, ClassTemplateSpecializationDecl *ClassTemplateSpec, TemplateSpecializationKind TSK)
Instantiate the definitions of all of the members of the given class template specialization, which was named as part of an explicit instantiation.
Represents a reference to a function parameter pack or init-capture pack that has been substituted bu...
Represents a template argument.
Represents a type which was implicitly adjusted by the semantic engine for arbitrary reasons...
void collectUnexpandedParameterPacks(TemplateArgument Arg, SmallVectorImpl< UnexpandedParameterPack > &Unexpanded)
Collect the set of unexpanded parameter packs within the given template argument. ...
TagTypeKind
The kind of a tag type.
bool isNull() const
Determine whether this template name is NULL.
Dataflow Directional Tag Classes.
virtual void getNameForDiagnostic(raw_ostream &OS, const PrintingPolicy &Policy, bool Qualified) const
Appends a human-readable name for this declaration into the given stream.
int ArgumentPackSubstitutionIndex
The current index into pack expansion arguments that will be used for substitution of parameter packs...
unsigned NumTemplateArgs
The number of template arguments in TemplateArgs.
[C99 6.4.2.2] - A predefined identifier such as func.
DeclContext - This is used only as base class of specific decl types that can act as declaration cont...
The base class of all kinds of template declarations (e.g., class, function, etc.).
static std::string getName(const CallEvent &Call)
ASTMutationListener * getASTMutationListener() const
NonTypeTemplateParmDecl * getParameterPack() const
Retrieve the non-type template parameter pack being substituted.
QualType getType() const
Get the type for which this source info wrapper provides information.
We are instantiating a default argument for a function.
delayed_partial_spec_iterator delayed_partial_spec_end()
Return an iterator to the end of the set of "delayed" partial specializations, which must be passed t...
Interesting information about a specific parameter that can't simply be reflected in parameter's type...
This template specialization was instantiated from a template due to an explicit instantiation declar...
RecordDecl * getOuterLexicalRecordContext()
Retrieve the outermost lexically enclosing record context.
VarDecl *const * iterator
Iterators over the parameters which the parameter pack expanded into.
The name of a declaration.
bool InstantiateClass(SourceLocation PointOfInstantiation, CXXRecordDecl *Instantiation, CXXRecordDecl *Pattern, const MultiLevelTemplateArgumentList &TemplateArgs, TemplateSpecializationKind TSK, bool Complain=true)
Instantiate the definition of a class from a given pattern.
void setInstantiationOfMemberFunction(FunctionDecl *FD, TemplateSpecializationKind TSK)
Specify that this record is an instantiation of the member function FD.
SourceRange InstantiationRange
The source range that covers the construct that cause the instantiation, e.g., the template-id that c...
CXXRecordDecl * getInstantiatedFromMemberClass() const
If this record is an instantiation of a member class, retrieves the member class from which it was in...
bool isClassScopeExplicitSpecialization() const
Is this an explicit specialization at class scope (within the class that owns the primary template)...
bool isClassScopeExplicitSpecialization() const
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...
SourceLocation getParameterPackLocation() const
Get the location of the parameter pack.
TemplateSpecializationKind
Describes the kind of template specialization that a particular template specialization declaration r...
TemplateSpecCandidate & addCandidate()
Add a new candidate with NumConversions conversion sequence slots to the overload set...
Optional< sema::TemplateDeductionInfo * > isSFINAEContext() const
Determines whether we are currently in a context where template argument substitution failures are no...
DeclarationNameInfo - A collector data type for bundling together a DeclarationName and the correspnd...
bool isExprSubstitutionFailure() const
pack_iterator pack_begin() const
Iterator referencing the first argument of a template argument pack.
ParmVarDecl * CheckParameter(DeclContext *DC, SourceLocation StartLoc, SourceLocation NameLoc, IdentifierInfo *Name, QualType T, TypeSourceInfo *TSInfo, StorageClass SC)
bool isNull() const
Determine whether this template argument has no value.
We are declaring an implicit 'operator==' for a defaulted 'operator<=>'.
bool hasSFINAEDiagnostic() const
Is a SFINAE diagnostic available?
QualType getModifiedType() const
SourceRange getSourceRange() const LLVM_READONLY
Get the full source range.
Location wrapper for a TemplateArgument.
unsigned getNumArgs() const
Retrieve the number of template arguments.
void setUnparsedDefaultArg()
Specify that this parameter has an unparsed default argument.
Expr * getUninstantiatedDefaultArg()
bool AttachTypeConstraint(NestedNameSpecifierLoc NS, DeclarationNameInfo NameInfo, ConceptDecl *NamedConcept, const TemplateArgumentListInfo *TemplateArgs, TemplateTypeParmDecl *ConstrainedParameter, SourceLocation EllipsisLoc)
Attach a type-constraint to a template parameter.
void MarkVirtualMembersReferenced(SourceLocation Loc, const CXXRecordDecl *RD, bool ConstexprOnly=false)
MarkVirtualMembersReferenced - Will mark all members of the given CXXRecordDecl referenced.
This template specialization was declared or defined by an explicit specialization (C++ [temp...
static concepts::Requirement::SubstitutionDiagnostic * createSubstDiag(Sema &S, TemplateDeductionInfo &Info, EntityPrinter Printer)
Expr * getReplacement() const
TypeSourceInfo * getTypeSourceInfo() const
UnparsedDefaultArgInstantiationsMap UnparsedDefaultArgInstantiations
A mapping from parameters with unparsed default arguments to the set of instantiations of each parame...
Base for LValueReferenceType and RValueReferenceType.
The template argument is a type.
Holds information about the various types of exception specification.
SmallVectorImpl< std::pair< VarTemplateDecl *, VarTemplatePartialSpecializationDecl * > >::iterator delayed_var_partial_spec_iterator
void SubstExceptionSpec(FunctionDecl *New, const FunctionProtoType *Proto, const MultiLevelTemplateArgumentList &Args)
The template argument is actually a parameter pack.
QualType getNonLValueExprType(const ASTContext &Context) const
Determine the type of a (typically non-lvalue) expression with the specified result type...
Represents a base class of a C++ class.
bool SavedInNonInstantiationSFINAEContext
Was the enclosing context a non-instantiation SFINAE context?
CanQualType getCanonicalType(QualType T) const
Return the canonical (structural) type corresponding to the specified potentially non-canonical type ...
bool isAlreadyInstantiating() const
Determine whether we are already instantiating this specialization in some surrounding active instant...
A template argument list.
bool hasFatalErrorOccurred() const
TypeLoc getTypeLoc() const
Return the TypeLoc wrapper for the type source info.
ExprResult SubstExpr(Expr *E, const MultiLevelTemplateArgumentList &TemplateArgs)
ArgKind getKind() const
Return the kind of stored template argument.
unsigned getDepth() const
An attributed type is a type to which a type attribute has been applied.
void printPretty(raw_ostream &OS, PrinterHelper *Helper, const PrintingPolicy &Policy, unsigned Indentation=0, StringRef NewlineSymbol="\, const ASTContext *Context=nullptr) const
TranslationUnitDecl * getTranslationUnitDecl() const
Represents a C++ struct/union/class.
static bool NeedsInstantiationAsFunctionType(TypeSourceInfo *T)
bool AttachBaseSpecifiers(CXXRecordDecl *Class, MutableArrayRef< CXXBaseSpecifier *> Bases)
Performs the actual work of attaching the given base class specifiers to a C++ class.
A requires-expression requirement which is satisfied when a general constraint expression is satisfie...
void enableLateAttributeInstantiation(Sema::LateInstantiatedAttrVec *LA)
void popCodeSynthesisContext()
void Clear()
Note that we have finished instantiating this template.
Provides information a specialization of a member of a class template, which may be a member function...
QualType getNamedType() const
Retrieve the type named by the qualified-id.
void atTemplateEnd(TemplateInstantiationCallbackPtrs &Callbacks, const Sema &TheSema, const Sema::CodeSynthesisContext &Inst)
SmallVectorImpl< std::pair< ClassTemplateDecl *, ClassTemplatePartialSpecializationDecl * > >::iterator delayed_partial_spec_iterator
DeclContext * CurContext
CurContext - This is the current declaration context of parsing.
Declaration of a class template.
static FixItHint CreateReplacement(CharSourceRange RemoveRange, StringRef Code)
Create a code modification hint that replaces the given source range with the given code string...
We are rewriting a comparison operator in terms of an operator<=>.
SourceRange getSourceRange() const LLVM_READONLY
SourceLocation tokens are not useful in isolation - they are low level value objects created/interpre...
SourceLocation getNameLoc() const
We are substituting prior template arguments into a new template parameter.
StringRef getName() const
Get the name of identifier for this declaration as a StringRef.
ClassTemplatePartialSpecializationDecl * getMoreSpecializedPartialSpecialization(ClassTemplatePartialSpecializationDecl *PS1, ClassTemplatePartialSpecializationDecl *PS2, SourceLocation Loc)
Returns the more specialized class template partial specialization according to the rules of partial ...
const ParmVarDecl * getParam() const
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 a type template specialization; the template must be a class template, a type alias templa...
Defines utilities for dealing with stack allocation and stack space.
virtual bool HandleTopLevelDecl(DeclGroupRef D)
HandleTopLevelDecl - Handle the specified top-level declaration.
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.
An l-value expression is a reference to an object with independent storage.
Wrapper for template type parameters.
A trivial tuple used to represent a source range.
This represents a decl that may have a name.
bool isTranslationUnit() const
T castAs() const
Convert to the specified TypeLoc type, asserting that this TypeLoc is of the desired type...
NamedDecl * getAsNamedDecl(TemplateParameter P)
const TemplateArgumentList & getTemplateInstantiationArgs() const
Retrieve the set of template arguments that should be used to instantiate members of the class templa...
No keyword precedes the qualified type name.
TemplateName getAsTemplate() const
Retrieve the template name for a template name argument.
SourceLocation getPointOfInstantiation() const
Retrieve the first point of instantiation of this member.
void setPointOfInstantiation(SourceLocation POI)
Set the first point of instantiation.
bool SubstParmTypes(SourceLocation Loc, ArrayRef< ParmVarDecl *> Params, const FunctionProtoType::ExtParameterInfo *ExtParamInfos, const MultiLevelTemplateArgumentList &TemplateArgs, SmallVectorImpl< QualType > &ParamTypes, SmallVectorImpl< ParmVarDecl *> *OutParams, ExtParameterInfoBuilder &ParamInfos)
Substitute the given template arguments into the given set of parameters, producing the set of parame...
void pushFullCopy(TypeLoc L)
Pushes a copy of the given TypeLoc onto this builder.
SourceRange getSourceRange() const LLVM_READONLY
SourceLocation getInnerLocStart() const
Return start of source range ignoring outer template declarations.
ExceptionSpecInfo ExceptionSpec
Declaration of a template function.
Attr - This represents one attribute.
SourceLocation getLocation() const
QualType getPointeeType() const
QualType getType() const
Return the type wrapped by this type source info.
virtual void HandleTagDeclDefinition(TagDecl *D)
HandleTagDeclDefinition - This callback is invoked each time a TagDecl (e.g.
bool isCXXInstanceMember() const
Determine whether the given declaration is an instance member of a C++ class.
bool hasErrorOccurred() const
Determine whether any SFINAE errors have been trapped.
static CXXRecordDecl * getPatternForClassTemplateSpecialization(Sema &S, SourceLocation PointOfInstantiation, ClassTemplateSpecializationDecl *ClassTemplateSpec, TemplateSpecializationKind TSK, bool Complain)
Get the instantiation pattern to use to instantiate the definition of a given ClassTemplateSpecializa...
const ReturnTypeRequirement & getReturnTypeRequirement() const