27 using namespace clang;
54 bool RelativeToPrimary,
68 dyn_cast<VarTemplateSpecializationDecl>(D)) {
71 !isa<VarTemplatePartialSpecializationDecl>(Spec))
78 assert(Spec->getSpecializedTemplate() &&
"No variable template?");
84 if (Partial->isMemberSpecialization())
87 VarTemplateDecl *Tmpl = Specialized.get<VarTemplateDecl *>();
101 = dyn_cast<TemplateTemplateParmDecl>(D)) {
102 for (
unsigned I = 0, N = TTP->getDepth() + 1; I != N; ++I)
112 = dyn_cast<ClassTemplateSpecializationDecl>(Ctx)) {
115 !isa<ClassTemplatePartialSpecializationDecl>(Spec))
122 assert(Spec->getSpecializedTemplate() &&
"No class template?");
123 if (Spec->getSpecializedTemplate()->isMemberSpecialization())
127 else if (
FunctionDecl *Function = dyn_cast<FunctionDecl>(Ctx)) {
128 if (!RelativeToPrimary &&
129 (Function->getTemplateSpecializationKind() ==
131 !Function->getClassScopeSpecializationPattern()))
135 = Function->getTemplateSpecializationArgs()) {
141 assert(Function->getPrimaryTemplate() &&
"No function template?");
142 if (Function->getPrimaryTemplate()->isMemberSpecialization())
150 = Function->getDescribedFunctionTemplate()) {
159 if (Function->getFriendObjectKind() &&
160 Function->getDeclContext()->isFileContext() &&
162 Ctx = Function->getLexicalDeclContext();
163 RelativeToPrimary =
false;
166 }
else if (
CXXRecordDecl *Rec = dyn_cast<CXXRecordDecl>(Ctx)) {
168 QualType T = ClassTemplate->getInjectedClassNameSpecialization();
173 if (ClassTemplate->isMemberSpecialization())
179 RelativeToPrimary =
false;
187 case TemplateInstantiation:
188 case ExceptionSpecInstantiation:
189 case DefaultTemplateArgumentInstantiation:
190 case DefaultFunctionArgumentInstantiation:
191 case ExplicitTemplateArgumentSubstitution:
192 case DeducedTemplateArgumentSubstitution:
193 case PriorTemplateArgumentSubstitution:
196 case DefaultTemplateArgumentChecking:
200 llvm_unreachable(
"Invalid InstantiationKind!");
208 : SemaRef(SemaRef), SavedInNonInstantiationSFINAEContext(
209 SemaRef.InNonInstantiationSFINAEContext) {
216 Invalid = CheckInstantiationDepth(PointOfInstantiation, InstantiationRange);
223 Inst.TemplateArgs = TemplateArgs.data();
224 Inst.NumTemplateArgs = TemplateArgs.size();
229 if (!Inst.isInstantiationRecord())
239 PointOfInstantiation, InstantiationRange, Entity) {}
246 PointOfInstantiation, InstantiationRange, Entity) {}
254 PointOfInstantiation, InstantiationRange, Template, nullptr,
264 InstantiationRange, FunctionTemplate, nullptr,
265 TemplateArgs, &DeductionInfo) {}
275 PointOfInstantiation, InstantiationRange, PartialSpec, nullptr,
276 TemplateArgs, &DeductionInfo) {}
286 PointOfInstantiation, InstantiationRange, PartialSpec, nullptr,
287 TemplateArgs, &DeductionInfo) {}
295 PointOfInstantiation, InstantiationRange, Param, nullptr,
305 PointOfInstantiation, InstantiationRange, Param, Template,
315 PointOfInstantiation, InstantiationRange, Param, Template,
324 PointOfInstantiation, InstantiationRange, Param, Template,
334 = SavedInNonInstantiationSFINAEContext;
339 "forgot to remove a lookup module for a template instantiation");
352 bool Sema::InstantiatingTemplate::CheckInstantiationDepth(
362 SemaRef.
Diag(PointOfInstantiation,
363 diag::err_template_recursion_depth_exceeded)
365 << InstantiationRange;
366 SemaRef.
Diag(PointOfInstantiation, diag::note_template_recursion_depth)
378 SkipStart = Limit / 2 + Limit % 2;
383 unsigned InstantiationIdx = 0;
388 ++Active, ++InstantiationIdx) {
390 if (InstantiationIdx >= SkipStart && InstantiationIdx < SkipEnd) {
391 if (InstantiationIdx == SkipStart) {
394 diag::note_instantiation_contexts_suppressed)
400 switch (Active->Kind) {
402 Decl *D = Active->Entity;
404 unsigned DiagID = diag::note_template_member_class_here;
405 if (isa<ClassTemplateSpecializationDecl>(Record))
406 DiagID = diag::note_template_class_instantiation_here;
409 << Active->InstantiationRange;
410 }
else if (
FunctionDecl *Function = dyn_cast<FunctionDecl>(D)) {
412 if (Function->getPrimaryTemplate())
413 DiagID = diag::note_function_template_spec_here;
415 DiagID = diag::note_template_member_function_here;
418 << Active->InstantiationRange;
419 }
else if (
VarDecl *VD = dyn_cast<VarDecl>(D)) {
421 VD->isStaticDataMember()?
422 diag::note_template_static_data_member_def_here
423 : diag::note_template_variable_def_here)
425 << Active->InstantiationRange;
426 }
else if (
EnumDecl *ED = dyn_cast<EnumDecl>(D)) {
428 diag::note_template_enum_def_here)
430 << Active->InstantiationRange;
431 }
else if (
FieldDecl *FD = dyn_cast<FieldDecl>(D)) {
433 diag::note_template_nsdmi_here)
434 << FD << Active->InstantiationRange;
437 diag::note_template_type_alias_instantiation_here)
438 << cast<TypeAliasTemplateDecl>(D)
439 << Active->InstantiationRange;
445 TemplateDecl *Template = cast<TemplateDecl>(Active->Entity);
447 llvm::raw_svector_ostream OS(TemplateArgsStr);
450 Active->TemplateArgs,
451 Active->NumTemplateArgs,
454 diag::note_default_arg_instantiation_here)
456 << Active->InstantiationRange;
463 diag::note_explicit_template_arg_substitution_here)
466 Active->TemplateArgs,
467 Active->NumTemplateArgs)
468 << Active->InstantiationRange;
474 dyn_cast<ClassTemplatePartialSpecializationDecl>(Active->Entity)) {
476 diag::note_partial_spec_deduct_instantiation_here)
479 PartialSpec->getTemplateParameters(),
480 Active->TemplateArgs,
481 Active->NumTemplateArgs)
482 << Active->InstantiationRange;
485 = cast<FunctionTemplateDecl>(Active->Entity);
487 diag::note_function_template_deduction_instantiation_here)
490 Active->TemplateArgs,
491 Active->NumTemplateArgs)
492 << Active->InstantiationRange;
497 ParmVarDecl *Param = cast<ParmVarDecl>(Active->Entity);
501 llvm::raw_svector_ostream OS(TemplateArgsStr);
504 Active->TemplateArgs,
505 Active->NumTemplateArgs,
508 diag::note_default_function_arg_instantiation_here)
510 << Active->InstantiationRange;
515 NamedDecl *Parm = cast<NamedDecl>(Active->Entity);
518 Name = std::string(
" '") + Parm->
getName().str() +
"'";
521 if (
TemplateDecl *Template = dyn_cast<TemplateDecl>(Active->Template))
522 TemplateParams = Template->getTemplateParameters();
525 cast<ClassTemplatePartialSpecializationDecl>(Active->Template)
526 ->getTemplateParameters();
528 diag::note_prior_template_arg_substitution)
529 << isa<TemplateTemplateParmDecl>(Parm)
532 Active->TemplateArgs,
533 Active->NumTemplateArgs)
534 << Active->InstantiationRange;
540 if (
TemplateDecl *Template = dyn_cast<TemplateDecl>(Active->Template))
541 TemplateParams = Template->getTemplateParameters();
544 cast<ClassTemplatePartialSpecializationDecl>(Active->Template)
545 ->getTemplateParameters();
548 diag::note_template_default_arg_checking)
550 Active->TemplateArgs,
551 Active->NumTemplateArgs)
552 << Active->InstantiationRange;
558 diag::note_template_exception_spec_instantiation_here)
559 << cast<FunctionDecl>(Active->Entity)
560 << Active->InstantiationRange;
576 switch(Active->Kind) {
580 if (isa<TypeAliasTemplateDecl>(Active->Entity))
600 assert(Active->DeductionInfo &&
"Missing deduction info pointer");
601 return Active->DeductionInfo;
609 static std::pair<unsigned, unsigned>
612 return std::make_pair(TTP->getDepth(), TTP->getIndex());
615 return std::make_pair(NTTP->getDepth(), NTTP->getIndex());
625 class TemplateInstantiator :
public TreeTransform<TemplateInstantiator> {
633 TemplateInstantiator(
Sema &SemaRef,
637 : inherited(SemaRef), TemplateArgs(TemplateArgs), Loc(Loc),
645 bool AlreadyTransformed(
QualType T);
657 this->Entity = Entity;
663 bool &ShouldExpand,
bool &RetainExpansion,
665 return getSema().CheckParameterPacksForExpansion(EllipsisLoc,
666 PatternRange, Unexpanded,
673 void ExpandingFunctionParameterPack(
ParmVarDecl *Pack) {
683 unsigned Depth, Index;
686 Result = TemplateArgs(Depth, Index);
702 unsigned Depth, Index;
712 void transformAttrs(
Decl *Old,
Decl *New) {
716 void transformedLocalDecl(
Decl *Old,
Decl *New) {
723 if (
auto *NewTD = NewMD->getDescribedFunctionTemplate())
724 NewTD->setInstantiatedFromMemberTemplate(
725 OldMD->getDescribedFunctionTemplate());
766 NamedDecl *FirstQualifierInScope =
nullptr);
768 const LoopHintAttr *TransformLoopHintAttr(
const LoopHintAttr *LH);
776 ExprResult TransformSubstNonTypeTemplateParmPackExpr(
794 return inherited::TransformFunctionProtoType(TLB, TL);
797 template<
typename Fn>
801 unsigned ThisTypeQuals,
802 Fn TransformExceptionSpec);
807 bool ExpectParameterPack);
821 getSema().CallsUndergoingInstantiation.push_back(CE);
824 getSema().CallsUndergoingInstantiation.pop_back();
835 if (!OrigTPL || !OrigTPL->
size())
return OrigTPL;
839 Owner, TemplateArgs);
840 return DeclInstantiator.SubstTemplateParams(OrigTPL);
849 bool TemplateInstantiator::AlreadyTransformed(
QualType T) {
856 getSema().MarkDeclarationsReferencedInType(Loc, T);
865 if (Arg.isPackExpansion())
886 if (TTP->isParameterPack()) {
888 "Missing argument pack");
894 "Wrong kind of template template argument");
906 Decl *Inst = getSema().SubstDecl(D, getSema().
CurContext, TemplateArgs);
910 getSema().CurrentInstantiationScope->InstantiatedLocal(D, Inst);
915 TemplateInstantiator::TransformFirstQualifierInScope(
NamedDecl *D,
921 = cast<TemplateTypeParmType>(getSema().Context.getTypeDeclType(TTPD));
929 "Missing argument pack");
931 if (getSema().ArgumentPackSubstitutionIndex == -1)
939 return cast_or_null<NamedDecl>(TransformDecl(Loc, D));
942 return Tag->getDecl();
945 getSema().Diag(Loc, diag::err_nested_name_spec_non_tag) << T;
950 return cast_or_null<NamedDecl>(TransformDecl(Loc, D));
954 TemplateInstantiator::RebuildExceptionDecl(
VarDecl *ExceptionDecl,
959 VarDecl *Var = inherited::RebuildExceptionDecl(ExceptionDecl, Declarator,
960 StartLoc, NameLoc, Name);
962 getSema().CurrentInstantiationScope->InstantiatedLocal(ExceptionDecl, Var);
966 VarDecl *TemplateInstantiator::RebuildObjCExceptionDecl(
VarDecl *ExceptionDecl,
969 VarDecl *Var = inherited::RebuildObjCExceptionDecl(ExceptionDecl, TSInfo, T);
971 getSema().CurrentInstantiationScope->InstantiatedLocal(ExceptionDecl, Var);
976 TemplateInstantiator::RebuildElaboratedType(
SourceLocation KeywordLoc,
993 SemaRef.
Diag(TagLocation, diag::err_use_with_wrong_tag)
1021 TTP->getPosition()))
1028 "Missing argument pack");
1030 if (getSema().ArgumentPackSubstitutionIndex == -1) {
1034 return getSema().Context.getSubstTemplateTemplateParmPack(TTP, Arg);
1041 assert(!Template.
isNull() &&
"Null template template argument");
1049 Template = getSema().Context.getSubstTemplateTemplateParm(TTP, Template);
1056 if (getSema().ArgumentPackSubstitutionIndex == -1)
1064 return inherited::TransformTemplateName(SS, Name, NameLoc, ObjectType,
1065 FirstQualifierInScope);
1069 TemplateInstantiator::TransformPredefinedExpr(
PredefinedExpr *E) {
1077 TemplateInstantiator::TransformTemplateParmRefExpr(
DeclRefExpr *E,
1090 "Missing argument pack");
1092 if (getSema().ArgumentPackSubstitutionIndex == -1) {
1111 return transformNonTypeTemplateParmRef(NTTP, E->
getLocation(), Arg);
1114 const LoopHintAttr *
1115 TemplateInstantiator::TransformLoopHintAttr(
const LoopHintAttr *LH) {
1116 Expr *TransformedExpr = getDerived().TransformExpr(LH->getValue()).
get();
1118 if (TransformedExpr == LH->getValue())
1122 if (getSema().CheckLoopHintExpr(TransformedExpr, LH->getLocation()))
1127 return LoopHintAttr::CreateImplicit(
1128 getSema().
Context, LH->getSemanticSpelling(), LH->getOption(),
1129 LH->getState(), TransformedExpr, LH->getRange());
1132 ExprResult TemplateInstantiator::transformNonTypeTemplateParmRef(
1154 VD = cast_or_null<ValueDecl>(
1155 getSema().FindInstantiatedDecl(loc, VD, TemplateArgs));
1168 isa<PackExpansionType>(parm->
getType())) {
1170 cast<PackExpansionType>(parm->
getType())->getPattern(),
1176 assert(!type.
isNull() &&
"type substitution failed for param type");
1180 if (!result.isInvalid()) type = result.get()->getType();
1188 if (result.isInvalid())
return ExprError();
1190 Expr *resultExpr = result.get();
1192 type, resultExpr->
getValueKind(), loc, parm, resultExpr);
1196 TemplateInstantiator::TransformSubstNonTypeTemplateParmPackExpr(
1211 TemplateInstantiator::RebuildParmVarDeclRefExpr(
ParmVarDecl *PD,
1214 return getSema().BuildDeclarationNameExpr(
CXXScopeSpec(), NameInfo, PD);
1225 return RebuildParmVarDeclRefExpr(cast<ParmVarDecl>(VD), E->
getExprLoc());
1239 cast_or_null<ParmVarDecl>(TransformDecl(E->
getExprLoc(), *I));
1251 TemplateInstantiator::TransformFunctionParmPackRefExpr(
DeclRefExpr *E,
1254 llvm::PointerUnion<Decl *, DeclArgumentPack *> *Found
1255 = getSema().CurrentInstantiationScope->findInstantiationOf(PD);
1256 assert(Found &&
"no instantiation for parameter pack");
1258 Decl *TransformedDecl;
1259 if (DeclArgumentPack *Pack = Found->dyn_cast<DeclArgumentPack *>()) {
1270 TransformedDecl = (*Pack)[getSema().ArgumentPackSubstitutionIndex];
1272 TransformedDecl = Found->get<
Decl*>();
1276 return RebuildParmVarDeclRefExpr(cast<ParmVarDecl>(TransformedDecl),
1281 TemplateInstantiator::TransformDeclRefExpr(
DeclRefExpr *E) {
1288 return TransformTemplateParmRefExpr(E, NTTP);
1297 return TransformFunctionParmPackRefExpr(E, PD);
1302 ExprResult TemplateInstantiator::TransformCXXDefaultArgExpr(
1305 getDescribedFunctionTemplate() &&
1306 "Default arg expressions are never formed in dependent cases.");
1312 template<
typename Fn>
1316 unsigned ThisTypeQuals,
1317 Fn TransformExceptionSpec) {
1320 return inherited::TransformFunctionProtoType(
1321 TLB, TL, ThisContext, ThisTypeQuals, TransformExceptionSpec);
1325 TemplateInstantiator::TransformFunctionTypeParam(
ParmVarDecl *OldParm,
1326 int indexAdjustment,
1328 bool ExpectParameterPack) {
1330 NumExpansions, ExpectParameterPack);
1334 TemplateInstantiator::TransformTemplateTypeParmType(
TypeLocBuilder &TLB,
1356 "Missing argument pack");
1358 if (getSema().ArgumentPackSubstitutionIndex == -1) {
1363 = getSema().Context.getSubstTemplateTypeParmPackType(T, Arg);
1374 "Template argument kind mismatch");
1380 = getSema().Context.getSubstTemplateTypeParmType(T, Replacement);
1393 NewTTPDecl = cast_or_null<TemplateTypeParmDecl>(
1397 = getSema().Context.getTemplateTypeParmType(T->
getDepth()
1408 TemplateInstantiator::TransformSubstTemplateTypeParmPackType(
1423 Result = getSema().Context.getSubstTemplateTypeParmType(
1464 "Cannot perform an instantiation without some context on the "
1465 "instantiation stack");
1471 TemplateInstantiator Instantiator(*
this, Args, Loc, Entity);
1472 return Instantiator.TransformType(T);
1480 "Cannot perform an instantiation without some context on the "
1481 "instantiation stack");
1495 TemplateInstantiator Instantiator(*
this, Args, Loc, Entity);
1498 QualType Result = Instantiator.TransformType(TLB, TL);
1510 "Cannot perform an instantiation without some context on the "
1511 "instantiation stack");
1518 TemplateInstantiator Instantiator(*
this, TemplateArgs, Loc, Entity);
1519 return Instantiator.TransformType(T);
1532 for (
unsigned I = 0, E = FP.
getNumParams(); I != E; ++I) {
1563 unsigned ThisTypeQuals) {
1565 "Cannot perform an instantiation without some context on the "
1566 "instantiation stack");
1571 TemplateInstantiator Instantiator(*
this, Args, Loc, Entity);
1587 Result = Instantiator.TransformFunctionProtoType(
1588 TLB, Proto, ThisContext, ThisTypeQuals,
1590 bool &Changed) {
return false; });
1592 Result = Instantiator.TransformType(TLB, TL);
1606 TemplateInstantiator Instantiator(*
this, Args, New->
getLocation(),
1610 bool Changed =
false;
1611 if (Instantiator.TransformExceptionSpec(
1613 ExceptionStorage, Changed))
1622 int indexAdjustment,
1624 bool ExpectParameterPack) {
1633 NewDI =
SubstType(ExpansionTL.getPatternLoc(), TemplateArgs,
1644 }
else if (ExpectParameterPack) {
1650 diag::err_function_parameter_pack_without_parameter_packs)
1686 if (ClassD && ClassD->isLocalClass() && !ClassD->isLambda()) {
1733 "Cannot perform an instantiation without some context on the "
1734 "instantiation stack");
1736 TemplateInstantiator Instantiator(*
this, TemplateArgs, Loc,
1738 return Instantiator.TransformFunctionTypeParams(Loc, Params, NumParams,
1739 nullptr, ParamTypes,
1753 bool Invalid =
false;
1755 for (
const auto &
Base : Pattern->
bases()) {
1756 if (!
Base.getType()->isDependentType()) {
1758 if (RD->isInvalidDecl())
1767 if (
Base.isPackExpansion()) {
1773 bool ShouldExpand =
false;
1774 bool RetainExpansion =
false;
1777 Base.getSourceRange(),
1779 TemplateArgs, ShouldExpand,
1788 for (
unsigned I = 0; I != *NumExpansions; ++I) {
1793 Base.getSourceRange().getBegin(),
1802 Base.getSourceRange(),
1804 Base.getAccessSpecifierAsWritten(),
1807 InstantiatedBases.push_back(InstantiatedBase);
1816 EllipsisLoc =
Base.getEllipsisLoc();
1820 Base.getSourceRange().getBegin(),
1825 Base.getSourceRange().getBegin(),
1836 Base.getSourceRange(),
1838 Base.getAccessSpecifierAsWritten(),
1841 InstantiatedBases.push_back(InstantiatedBase);
1848 InstantiatedBases.size()))
1867 bool InstantiatedFromMember,
1871 bool Complain =
true) {
1875 if (!Complain || (PatternDef && PatternDef->
isInvalidDecl())) {
1877 }
else if (PatternDef) {
1879 S.
Diag(PointOfInstantiation,
1880 diag::err_template_instantiate_within_definition)
1886 }
else if (InstantiatedFromMember) {
1887 S.
Diag(PointOfInstantiation,
1888 diag::err_implicit_instantiate_member_undefined)
1892 S.
Diag(PointOfInstantiation, diag::err_template_instantiate_undefined)
1939 Pattern, PatternDef, TSK, Complain))
1941 Pattern = PatternDef;
1947 MSInfo->setPointOfInstantiation(PointOfInstantiation);
1949 = dyn_cast<ClassTemplateSpecializationDecl>(Instantiation)) {
1950 Spec->setTemplateSpecializationKind(TSK);
1951 Spec->setPointOfInstantiation(PointOfInstantiation);
1993 for (
auto *Member : Pattern->
decls()) {
2003 if (Member->getDeclContext() != Pattern)
2006 if (Member->isInvalidDecl()) {
2011 Decl *NewMember = Instantiator.
Visit(Member);
2013 if (
FieldDecl *Field = dyn_cast<FieldDecl>(NewMember)) {
2014 Fields.push_back(Field);
2015 }
else if (
EnumDecl *Enum = dyn_cast<EnumDecl>(NewMember)) {
2021 Enum->isCompleteDefinition()) {
2023 assert(MSInfo &&
"no spec info for member enum specialization");
2028 if (SA->isFailed()) {
2057 for (LateInstantiatedAttrVec::iterator I = LateAttrs.begin(),
2058 E = LateAttrs.end(); I != E; ++I) {
2071 I->NewDecl->addAttr(NewAttr);
2099 P->first,
P->second)) {
2112 P->first,
P->second)) {
2156 Pattern, PatternDef, TSK,
true))
2158 Pattern = PatternDef;
2164 MSInfo->setPointOfInstantiation(PointOfInstantiation);
2219 "pattern and instantiation disagree about init style");
2227 if (OutermostClass == PatternRD) {
2228 Diag(Pattern->
getLocEnd(), diag::err_in_class_initializer_not_yet_parsed)
2229 << PatternRD << Pattern;
2232 diag::err_in_class_initializer_not_yet_parsed_outer_class)
2233 << PatternRD << OutermostClass << Pattern;
2257 Expr *Init = NewInit.get();
2258 assert((!Init || !isa<ParenListExpr>(Init)) &&
"call-style init in class");
2260 Instantiation, Init ? Init->getLocStart() :
SourceLocation(), Init);
2272 struct PartialSpecMatchResult {
2283 ClassTemplateSpec = cast<ClassTemplateSpecializationDecl>(
2299 typedef PartialSpecMatchResult MatchResult;
2304 for (
unsigned I = 0, N = PartialSpecs.size(); I != N; ++I) {
2317 Matched.push_back(PartialSpecMatchResult());
2318 Matched.back().Partial = Partial;
2319 Matched.back().Args = Info.take();
2327 if (Matched.size() >= 1) {
2329 if (Matched.size() == 1) {
2342 PEnd = Matched.end();
2345 PointOfInstantiation)
2352 bool Ambiguous =
false;
2354 PEnd = Matched.end();
2358 PointOfInstantiation)
2368 Diag(PointOfInstantiation, diag::err_partial_spec_ordering_ambiguous)
2369 << ClassTemplateSpec;
2373 PEnd = Matched.end();
2375 Diag(
P->Partial->getLocation(), diag::note_partial_spec_match)
2377 P->Partial->getTemplateParameters(),
2395 Pattern = OrigPartialSpec;
2437 "Unexpected template specialization kind!");
2438 for (
auto *D : Instantiation->
decls()) {
2439 bool SuppressNew =
false;
2440 if (
auto *Function = dyn_cast<FunctionDecl>(D)) {
2444 = Function->getMemberSpecializationInfo();
2445 assert(MSInfo &&
"No member specialization information?");
2467 Function->setTemplateSpecializationKind(TSK, PointOfInstantiation);
2469 if (Function->isDefined()) {
2477 std::make_pair(Function, PointOfInstantiation));
2480 }
else if (
auto *Var = dyn_cast<VarDecl>(D)) {
2481 if (isa<VarTemplateSpecializationDecl>(Var))
2486 assert(MSInfo &&
"No member specialization information?");
2516 }
else if (
auto *Record = dyn_cast<CXXRecordDecl>(D)) {
2522 if (Record->isInjectedClassName() || Record->getPreviousDecl() ||
2527 assert(MSInfo &&
"No member specialization information?");
2542 assert(Pattern &&
"Missing instantiated-from-template information");
2544 if (!Record->getDefinition()) {
2565 Record->getTemplateSpecializationKind() ==
2567 Record->setTemplateSpecializationKind(TSK);
2572 Pattern = cast_or_null<CXXRecordDecl>(Record->getDefinition());
2576 }
else if (
auto *Enum = dyn_cast<EnumDecl>(D)) {
2578 assert(MSInfo &&
"No member specialization information?");
2585 PointOfInstantiation, TSK, Enum,
2591 if (Enum->getDefinition())
2595 assert(Pattern &&
"Missing instantiated-from-template information");
2601 InstantiateEnum(PointOfInstantiation, Enum, Pattern, TemplateArgs, TSK);
2606 }
else if (
auto *Field = dyn_cast<FieldDecl>(D)) {
2613 ClassPattern->
lookup(Field->getDeclName());
2614 assert(Lookup.
size() == 1);
2615 FieldDecl *Pattern = cast<FieldDecl>(Lookup[0]);
2649 TemplateInstantiator Instantiator(*
this, TemplateArgs,
2652 return Instantiator.TransformStmt(S);
2660 TemplateInstantiator Instantiator(*
this, TemplateArgs,
2663 return Instantiator.TransformExpr(E);
2668 bool CXXDirectInit) {
2669 TemplateInstantiator Instantiator(*
this, TemplateArgs,
2672 return Instantiator.TransformInitializer(Init, CXXDirectInit);
2681 TemplateInstantiator Instantiator(*
this, TemplateArgs,
2684 return Instantiator.TransformExprs(Exprs, NumExprs, IsCall, Outputs);
2693 TemplateInstantiator Instantiator(*
this, TemplateArgs, NNS.
getBeginLoc(),
2695 return Instantiator.TransformNestedNameSpecifierLoc(NNS);
2702 TemplateInstantiator Instantiator(*
this, TemplateArgs, NameInfo.
getLoc(),
2704 return Instantiator.TransformDeclarationNameInfo(NameInfo);
2711 TemplateInstantiator Instantiator(*
this, TemplateArgs, Loc,
2714 SS.
Adopt(QualifierLoc);
2715 return Instantiator.TransformTemplateName(SS, Name, Loc);
2721 TemplateInstantiator Instantiator(*
this, TemplateArgs,
SourceLocation(),
2724 return Instantiator.TransformTemplateArguments(Args, NumArgs, Result);
2732 if (
const ParmVarDecl *PV = dyn_cast<ParmVarDecl>(D)) {
2733 if (
const FunctionDecl *FD = dyn_cast<FunctionDecl>(PV->getDeclContext())) {
2734 unsigned i = PV->getFunctionScopeIndex();
2737 if (FD->getParamDecl(i) == PV)
2745 llvm::PointerUnion<Decl *, LocalInstantiationScope::DeclArgumentPack *> *
2752 const Decl *CheckD = D;
2754 LocalDeclsMap::iterator Found =
Current->LocalDecls.find(CheckD);
2755 if (Found !=
Current->LocalDecls.end())
2756 return &Found->second;
2760 if (
const TagDecl *Tag = dyn_cast<TagDecl>(CheckD))
2767 if (!
Current->CombineWithOuterScope)
2773 if (isa<NonTypeTemplateParmDecl>(D) || isa<TemplateTypeParmDecl>(D) ||
2774 isa<TemplateTemplateParmDecl>(D))
2779 if (RD->isLocalClass())
2784 if (isa<EnumDecl>(D))
2790 assert(isa<LabelDecl>(D) &&
"declaration not instantiated in this scope");
2796 llvm::PointerUnion<Decl *, DeclArgumentPack *> &Stored = LocalDecls[D];
2797 if (Stored.isNull()) {
2801 while (Current->CombineWithOuterScope && Current->Outer) {
2802 Current = Current->Outer;
2803 assert(Current->LocalDecls.find(D) == Current->LocalDecls.end() &&
2804 "Instantiated local in inner and outer scopes");
2808 }
else if (DeclArgumentPack *Pack = Stored.dyn_cast<DeclArgumentPack *>()) {
2809 Pack->push_back(Inst);
2811 assert(Stored.get<
Decl *>() == Inst &&
"Already instantiated this local");
2818 DeclArgumentPack *Pack = LocalDecls[D].get<DeclArgumentPack *>();
2819 Pack->push_back(Inst);
2827 assert(
Current->LocalDecls.find(D) ==
Current->LocalDecls.end() &&
2828 "Creating local pack after instantiation of local");
2832 llvm::PointerUnion<Decl *, DeclArgumentPack *> &Stored = LocalDecls[D];
2833 DeclArgumentPack *Pack =
new DeclArgumentPack;
2835 ArgumentPacks.push_back(Pack);
2840 unsigned NumExplicitArgs) {
2841 assert((!PartiallySubstitutedPack || PartiallySubstitutedPack == Pack) &&
2842 "Already have a partially-substituted pack");
2843 assert((!PartiallySubstitutedPack
2844 || NumArgsInPartiallySubstitutedPack == NumExplicitArgs) &&
2845 "Wrong number of arguments in partially-substituted pack");
2846 PartiallySubstitutedPack = Pack;
2847 ArgsInPartiallySubstitutedPack = ExplicitArgs;
2848 NumArgsInPartiallySubstitutedPack = NumExplicitArgs;
2853 unsigned *NumExplicitArgs)
const {
2855 *ExplicitArgs =
nullptr;
2856 if (NumExplicitArgs)
2857 *NumExplicitArgs = 0;
2861 if (
Current->PartiallySubstitutedPack) {
2863 *ExplicitArgs =
Current->ArgsInPartiallySubstitutedPack;
2864 if (NumExplicitArgs)
2865 *NumExplicitArgs =
Current->NumArgsInPartiallySubstitutedPack;
2867 return Current->PartiallySubstitutedPack;
2870 if (!
Current->CombineWithOuterScope)
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.
void ActOnFinishDelayedMemberInitializers(Decl *Record)
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 ...
T getAs() const
Convert to the specified TypeLoc type, returning a null TypeLoc if this TypeLoc is not of the desired...
ParmVarDecl *const * iterator
Iterators over the parameters which the parameter pack expanded into.
SmallVector< Module *, 16 > ActiveTemplateInstantiationLookupModules
Extra modules inspected when performing a lookup during a template instantiation. Computed lazily...
TemplateArgument getPackExpansionPattern() const
When the template argument is a pack expansion, returns the pattern of the pack expansion.
unsigned getDepth() const
StringRef getName() const
delayed_var_partial_spec_iterator delayed_var_partial_spec_begin()
no exception specification
void setHidden(bool Hide)
Set whether this declaration is hidden from name lookup.
TemplateDeductionResult
Describes the result of template argument deduction.
void InstantiatedLocal(const Decl *D, Decl *Inst)
void UpdateExceptionSpec(FunctionDecl *FD, const FunctionProtoType::ExceptionSpecInfo &ESI)
A stack-allocated class that identifies which local variable declaration instantiations are present i...
unsigned getTemplateBacktraceLimit() const
Retrieve the maximum number of template instantiation notes to emit along with a given diagnostic...
IdentifierInfo * getIdentifier() const
bool isInstantiationDependentType() const
Determine whether this type is an instantiation-dependent type, meaning that the type involves a temp...
void addOuterTemplateArguments(const TemplateArgumentList *TemplateArgs)
Add a new outermost level to the multi-level template argument list.
const LangOptions & getLangOpts() const
bool isMemberSpecialization()
Determines whether this class template partial specialization template was a specialization of a memb...
bool isGenericLambdaCallOperatorSpecialization(const CXXMethodDecl *MD)
ExprResult SubstInitializer(Expr *E, const MultiLevelTemplateArgumentList &TemplateArgs, bool CXXDirectInit)
TemplateDecl * getAsTemplateDecl() const
Retrieve the underlying template declaration that this template name refers to, if known...
Provides information about an attempted template argument deduction, whose success or failure was des...
ExprResult BuildCXXDefaultArgExpr(SourceLocation CallLoc, FunctionDecl *FD, ParmVarDecl *Param)
void ActOnFinishCXXMemberDefaultArgs(Decl *D)
The current expression is potentially evaluated at run time, which means that code may be generated t...
unsigned getFunctionScopeIndex() const
Returns the index of this parameter in its prototype or method scope.
std::string getTemplateArgumentBindingsText(const TemplateParameterList *Params, const TemplateArgumentList &Args)
Produces a formatted string that describes the binding of template parameters to template arguments...
CXXRecordDecl * getTemplatedDecl() const
Get the underlying class declarations of the template.
bool hasTemplateArgument(unsigned Depth, unsigned Index) const
Determine whether there is a non-NULL template argument at the given depth and index.
SemaDiagnosticBuilder Diag(SourceLocation Loc, unsigned DiagID)
Emit a diagnostic.
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()
Decl * getPreviousDecl()
Retrieve the previous declaration that declares the same entity as this declaration, or NULL if there is no previous declaration.
MemberSpecializationInfo * getMemberSpecializationInfo() const
If this enumeration is an instantiation of a member enumeration of a class template specialization...
pack_iterator pack_begin() const
Iterator referencing the first argument of a template argument pack.
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...
const FunctionDecl * isLocalClass() const
If the class is a local class [class.local], returns the enclosing function declaration.
DiagnosticBuilder Report(SourceLocation Loc, unsigned DiagID)
Issue the message to the client.
Declaration of a variable template.
NamedDecl * getParam(unsigned Idx)
A container of type source information.
unsigned getIndex() const
Expr * getAsExpr() const
Retrieve the template argument as an expression.
static bool DiagnoseUninstantiableTemplate(Sema &S, SourceLocation PointOfInstantiation, TagDecl *Instantiation, bool InstantiatedFromMember, TagDecl *Pattern, TagDecl *PatternDef, TemplateSpecializationKind TSK, bool Complain=true)
SourceLocation getLocEnd() const LLVM_READONLY
VarTemplatePartialSpecializationDecl * InstantiateVarTemplatePartialSpecialization(VarTemplateDecl *VarTemplate, VarTemplatePartialSpecializationDecl *PartialSpec)
Instantiate the declaration of a variable template partial specialization.
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 ActiveTemplateInstantiation entries in ActiveTemplateInstantiations that are not actual...
Expr * getInClassInitializer() const
InClassInitStyle getInClassInitStyle() const
enum clang::Sema::ActiveTemplateInstantiation::InstantiationKind Kind
IdentType getIdentType() 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).
RAII object that enters a new expression evaluation context.
Information about one declarator, including the parsed type information and the identifier.
DiagnosticsEngine & Diags
void setUninstantiatedDefaultArg(Expr *arg)
void InstantiatedLocalPackArg(const Decl *D, Decl *Inst)
TypeSourceInfo * SubstFunctionDeclType(TypeSourceInfo *T, const MultiLevelTemplateArgumentList &TemplateArgs, SourceLocation Loc, DeclarationName Entity, CXXRecordDecl *ThisContext, unsigned ThisTypeQuals)
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...
TemplateTypeParmDecl * getDecl() const
SmallVectorImpl< std::pair< ClassTemplateDecl *, ClassTemplatePartialSpecializationDecl * > >::iterator delayed_partial_spec_iterator
Stores a list of template parameters for a TemplateDecl and its derived classes.
const ParmVarDecl * getParam() const
bool containsUnexpandedParameterPack() const
Whether this type is or contains an unexpanded parameter pack, used to support C++0x variadic templat...
ParmVarDecl - Represents a parameter to a function.
SourceLocation PointOfInstantiation
The point of instantiation within the source code.
unsigned getNumArgs() const
Retrieve the number of template arguments.
SourceLocation getLocation() const
const CXXRecordDecl * getTemplateInstantiationPattern() const
Retrieve the record declaration from which this record could be instantiated. Returns null if this cl...
void setTemplateSpecializationKind(TemplateSpecializationKind TSK)
Set the kind of specialization or template instantiation this is.
Base wrapper for a particular "section" of type source info.
bool hasUninstantiatedDefaultArg() const
void PrintInstantiationStack()
Prints the current instantiation stack through a series of notes.
DeclarationName getName() const
getName - Returns the embedded declaration name.
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.
EnumDecl * getInstantiatedFromMemberEnum() const
Returns the enumeration (declared within the template) from which this enumeration type was instantia...
bool isVariablyModifiedType() const
Whether this type is a variably-modified type (C99 6.7.5).
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)
The results of name lookup within a DeclContext. This is either a single result (with no stable stora...
TypeSourceInfo * getTypeSourceInfo(ASTContext &Context, QualType T)
Creates a TypeSourceInfo for the given type.
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...
void setArgument(unsigned Depth, unsigned Index, TemplateArgument Arg)
Clear out a specific template argument.
Decl * Entity
The entity that is being instantiated.
void startDefinition()
Starts the definition of this tag declaration.
ParmVarDecl * getParam(unsigned i) const
CXXRecordDecl * getDefinition() const
bool isTranslationUnit() const
TagKind getTagKind() const
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.
QualType getTypeDeclType(const TypeDecl *Decl, const TypeDecl *PrevDecl=nullptr) const
Return the unique reference to the type for the specified type declaration.
SubstTemplateTemplateParmPackStorage * getAsSubstTemplateTemplateParmPack() const
Retrieve the substituted template template parameter pack, if known.
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()
Describes a module or submodule.
StorageClass getStorageClass() const
Returns the storage class as written in the source. For the computed linkage of symbol, see getLinkage.
llvm::PointerUnion< VarTemplateDecl *, VarTemplatePartialSpecializationDecl * > getSpecializedTemplateOrPartial() const
Retrieve the variable template or variable template partial specialization which was specialized by t...
bool isNull() const
Determine whether this template name is NULL.
TemplateArgument getArgumentPack() const
void setNameLoc(SourceLocation Loc)
bool isParameterPack() const
Whether this parameter is a non-type template parameter pack.
void setTemplateSpecializationKind(TemplateSpecializationKind TSK, SourceLocation PointOfInstantiation=SourceLocation())
For an enumeration member that was instantiated from a member enumeration of a templated class...
SourceRange InstantiationRange
The source range that covers the construct that cause the instantiation, e.g., the template-id that c...
static TemplateArgument getPackSubstitutedTemplateArgument(Sema &S, TemplateArgument Arg)
StmtResult SubstStmt(Stmt *S, const MultiLevelTemplateArgumentList &TemplateArgs)
Wrapper for substituted template type parameters.
llvm::DenseSet< Module * > LookupModulesCache
Cache of additional modules that should be used for name lookup within the current template instantia...
ParmVarDecl * getExpansion(unsigned I) const
Get an expansion of the parameter pack by index.
Wrapper for substituted template type parameters.
void setInstantiationOf(ClassTemplatePartialSpecializationDecl *PartialSpec, const TemplateArgumentList *TemplateArgs)
Note that this class template specialization is actually an instantiation of the given class template...
InstantiatingTemplate(Sema &SemaRef, SourceLocation PointOfInstantiation, Decl *Entity, SourceRange InstantiationRange=SourceRange())
Note that we are instantiating a class template, function template, or a member thereof.
CXXRecordDecl * getCanonicalDecl() override
Retrieves the "canonical" declaration of the given declaration.
SourceLocation getRBraceLoc() const
CXXBaseSpecifier * CheckBaseSpecifier(CXXRecordDecl *Class, SourceRange SpecifierRange, bool Virtual, AccessSpecifier Access, TypeSourceInfo *TInfo, SourceLocation EllipsisLoc)
ActOnBaseSpecifier - Parsed a base specifier.
Represents a C++ nested-name-specifier or a global scope specifier.
DeclContext * getLexicalDeclContext()
ClassTemplatePartialSpecializationDecl * getInstantiatedFromMember()
Retrieve the member class template partial specialization from which this particular class template p...
A C++ lambda expression, which produces a function object (of unspecified type) that can be invoked l...
bool isLambdaCallOperator(const CXXMethodDecl *MD)
SourceLocation getLocation() const
unsigned getNumParams() const
SourceLocation getUsedLocation() const
Retrieve the location where this default argument was actually used.
A default argument (C++ [dcl.fct.default]).
void setLocStart(SourceLocation L)
virtual Decl * getCanonicalDecl()
Retrieves the "canonical" declaration of the given declaration.
T castAs() const
Convert to the specified TypeLoc type, asserting that this TypeLoc is of the desired type...
RAII object used to change the argument pack substitution index within a Sema object.
const TemplateTypeParmType * getReplacedParameter() const
Gets the template parameter that was substituted for.
TyLocType push(QualType T)
SourceLocation getLoc() const
getLoc - Returns the main location of the declaration name.
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)
sema::TemplateDeductionInfo * DeductionInfo
The template deduction info object associated with the substitution or checking of explicit or deduce...
Sema - This implements semantic analysis and AST building for C.
CXXRecordDecl * getInstantiatedFromMemberClass() const
If this record is an instantiation of a member class, retrieves the member class from which it was in...
unsigned getPosition() const
Get the position of the template parameter within its parameter list.
bool InstantiateEnum(SourceLocation PointOfInstantiation, EnumDecl *Instantiation, EnumDecl *Pattern, const MultiLevelTemplateArgumentList &TemplateArgs, TemplateSpecializationKind TSK)
Instantiate the definition of an enum from a given pattern.
bool isParameterPack() const
Determine whether this parameter is actually a function parameter pack.
unsigned getNumExpansions() const
Get the number of parameters in this parameter pack.
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...
SourceLocation getInnerLocStart() const
MemberSpecializationInfo * getMemberSpecializationInfo() const
If this variable is an instantiation of a static data member of a class template specialization, retrieves the member specialization information.
bool isCXXInstanceMember() const
Determine whether the given declaration is an instance member of a C++ class.
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.
TypeSourceInfo * CheckPackExpansion(TypeSourceInfo *Pattern, SourceLocation EllipsisLoc, Optional< unsigned > NumExpansions)
Construct a pack expansion type from the pattern of the pack expansion.
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...
Defines the clang::LangOptions interface.
The "typename" keyword precedes the qualified type name, e.g., typename T::type.
VarDecl * getOutOfLineDefinition()
If this is a static data member, find its out-of-line definition.
bool hasFatalErrorOccurred() const
void InstantiateAttrs(const MultiLevelTemplateArgumentList &TemplateArgs, const Decl *Pattern, Decl *Inst, LateInstantiatedAttrVec *LateAttrs=nullptr, LocalInstantiationScope *OuterMostScope=nullptr)
Declaration of a template type parameter.
ClassTemplatePartialSpecializationDecl * InstantiateClassTemplatePartialSpecialization(ClassTemplateDecl *ClassTemplate, ClassTemplatePartialSpecializationDecl *PartialSpec)
Instantiate the declaration of a class template partial specialization.
void PerformDependentDiagnostics(const DeclContext *Pattern, const MultiLevelTemplateArgumentList &TemplateArgs)
This file defines the classes used to store parsed information about declaration-specifiers and decla...
ElaboratedTypeKeyword
The elaboration keyword that precedes a qualified type name or introduces an elaborated-type-specifie...
ExprResult BuildExpressionFromDeclTemplateArgument(const TemplateArgument &Arg, QualType ParamType, SourceLocation Loc)
Given a non-type template argument that refers to a declaration and the type of its corresponding non...
void setInvalidDecl(bool Invalid=true)
TranslationUnitDecl * getTranslationUnitDecl() const
bool InNonInstantiationSFINAEContext
Whether we are in a SFINAE context that is not associated with template instantiation.
SourceLocation getLocation() const
ArgKind getKind() const
Return the kind of stored template argument.
ExtProtoInfo getExtProtoInfo() const
ParmVarDecl * SubstParmVarDecl(ParmVarDecl *D, const MultiLevelTemplateArgumentList &TemplateArgs, int indexAdjustment, Optional< unsigned > NumExpansions, bool ExpectParameterPack)
DeclContext * getDeclContext()
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. Such actions are deferred until the class is complete.
bool hasDefaultArg() const
Represents a C++ template name within the type system.
void setDefaultArg(Expr *defarg)
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.
bool isMemberSpecialization() const
Determines whether this template was a specialization of a member template.
Expr * getUninstantiatedDefaultArg()
ClassTemplateDecl * getInstantiatedFromMemberTemplate()
void CheckCompletedCXXClass(CXXRecordDecl *Record)
Perform semantic checks on a class definition that has been completing, introducing implicitly-declar...
bool isDependentType() const
llvm::FoldingSetVector< ClassTemplatePartialSpecializationDecl > & getPartialSpecializations()
Retrieve the set of partial specializations of this class template.
DeclContext * getParent()
getParent - Returns the containing DeclContext.
Data structure that captures multiple levels of template argument lists for use in template instantia...
SmallVector< ActiveTemplateInstantiation, 16 > ActiveTemplateInstantiations
List of active template instantiations.
void setLocation(SourceLocation L)
DeclarationName getDeclName() const
ClassTemplateDecl * getSpecializedTemplate() const
Retrieve the template that this specialization specializes.
bool AttachBaseSpecifiers(CXXRecordDecl *Class, CXXBaseSpecifier **Bases, unsigned NumBases)
Performs the actual work of attaching the given base class specifiers to a C++ class.
Represents a reference to a non-type template parameter that has been substituted with a template arg...
The result type of a method or function.
SourceLocation getLocEnd() const LLVM_READONLY
TypeSourceInfo * getTypeSourceInfo() const
void setDeclContext(DeclContext *DC)
SourceLocation getParameterPackLocation() const
Retrieve the location of the parameter pack name.
const TypeClass * getTypePtr() const
Attr * instantiateTemplateAttribute(const Attr *At, ASTContext &C, Sema &S, const MultiLevelTemplateArgumentList &TemplateArgs)
static void deleteScopes(LocalInstantiationScope *Scope, LocalInstantiationScope *Outermost)
deletes the given scope, and all otuer scopes, down to the given outermost scope. ...
ActiveTemplateInstantiation()
void ActOnStartCXXInClassMemberInitializer()
Enter a new C++ default initializer scope. After calling this, the caller must call ActOnFinishCXXInC...
TypeLoc getTypeLoc() const
Return the TypeLoc wrapper for the type source info.
NamedDecl * getPartiallySubstitutedPack(const TemplateArgument **ExplicitArgs=nullptr, unsigned *NumExplicitArgs=nullptr) const
Retrieve the partially-substitued template parameter pack.
ExceptionSpecificationType Type
The kind of exception specification this is.
A stack object to be created when performing template instantiation.
bool Subst(const TemplateArgumentLoc *Args, unsigned NumArgs, TemplateArgumentListInfo &Result, const MultiLevelTemplateArgumentList &TemplateArgs)
unsigned getNumLevels() const
Determine the number of levels in this template argument list.
Encodes a location in the source. The SourceManager can decode this to get at the full include stack...
TemplateName getAsTemplate() const
Retrieve the template name for a template name argument.
QualType getExpansionType(unsigned I) const
Retrieve a particular expansion type within an expanded parameter pack.
A structure for storing an already-substituted template template parameter pack.
void InstantiateStaticDataMemberDefinition(SourceLocation PointOfInstantiation, VarDecl *Var, bool Recursive=false, bool DefinitionRequired=false)
Instantiate the definition of the given variable from its template.
SmallVectorImpl< std::pair< VarTemplateDecl *, VarTemplatePartialSpecializationDecl * > >::iterator delayed_var_partial_spec_iterator
TagDecl - Represents the declaration of a struct/union/class/enum.
SourceLocation getBeginLoc() const
Retrieve the location of the beginning of this nested-name-specifier.
void printName(raw_ostream &os) const
TemplateArgument getArgumentPack() const
Retrieve the template argument pack containing the substituted template arguments.
Represents a static or instance method of a struct/union/class.
SourceLocation getNameLoc() const
void set(Decl *Spec, DeductionFailureInfo Info)
void reserve(size_t Requested)
Ensures that this buffer has at least as much capacity as described.
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...
bool isInstantiationRecord() const
Determines whether this template is an actual instantiation that should be counted toward the maximum...
void setTagKind(TagKind TK)
void InstantiateEnumDefinition(EnumDecl *Enum, EnumDecl *Pattern)
ParmVarDecl * getParameterPack() const
Get the parameter pack which this expression refers to.
bool isTypeDependent() const
lookup_result lookup(DeclarationName Name) const
void MarkVTableUsed(SourceLocation Loc, CXXRecordDecl *Class, bool DefinitionRequired=false)
Note that the vtable for the given class was used at the given location.
bool isFileContext() const
Represents a C++11 static_assert declaration.
VarDecl * getInstantiatedFromStaticDataMember() const
If this variable is an instantiated static data member of a class template specialization, returns the templated static data member from which it was instantiated.
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...
void ActOnFields(Scope *S, SourceLocation RecLoc, Decl *TagDecl, ArrayRef< Decl * > Fields, SourceLocation LBrac, SourceLocation RBrac, AttributeList *AttrList)
static TagTypeKind getTagTypeKindForKeyword(ElaboratedTypeKeyword Keyword)
getTagTypeKindForKeyword - Converts an elaborated type keyword into
QualifiedTemplateName * getAsQualifiedTemplateName() const
Retrieve the underlying qualified template name structure, if any.
void setHasInheritedDefaultArg(bool I=true)
QualType getType() const
Return the type wrapped by this type source info.
ValueDecl * getAsDecl() const
Retrieve the declaration for a declaration non-type template argument.
SourceLocation getExprLoc() const LLVM_READONLY
void setTemplateSpecializationKind(TemplateSpecializationKind TSK)
Set the template specialization kind.
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.
void setTemplateSpecializationKind(TemplateSpecializationKind TSK, SourceLocation PointOfInstantiation=SourceLocation())
For a static data member that was instantiated from a static data member of a class template...
if(T->getSizeExpr()) TRY_TO(TraverseStmt(T-> getSizeExpr()))
Represents a reference to a function parameter pack that has been substituted but not yet expanded...
Represents a template argument.
QualType getAsType() const
Retrieve the type for a type template argument.
void collectUnexpandedParameterPacks(TemplateArgument Arg, SmallVectorImpl< UnexpandedParameterPack > &Unexpanded)
Collect the set of unexpanded parameter packs within the given template argument. ...
Represents a template name that was expressed as a qualified name.
TagTypeKind
The kind of a tag type.
int ArgumentPackSubstitutionIndex
The current index into pack expansion arguments that will be used for substitution of parameter packs...
bool SubstParmTypes(SourceLocation Loc, ParmVarDecl **Params, unsigned NumParams, const MultiLevelTemplateArgumentList &TemplateArgs, SmallVectorImpl< QualType > &ParamTypes, SmallVectorImpl< ParmVarDecl * > *OutParams=nullptr)
Substitute the given template arguments into the given set of parameters, producing the set of parame...
[C99 6.4.2.2] - A predefined identifier such as func.
LocalInstantiationScope * getStartingScope() const
The base class of all kinds of template declarations (e.g., class, function, etc.).
A template instantiation that is currently in progress.
bool hasUnparsedDefaultArg() const
const internal::VariadicAllOfMatcher< Type > type
Matches Types in the clang AST.
bool isInvalidDecl() const
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...
TypeLoc IgnoreParens() const
RecordDecl * getOuterLexicalRecordContext()
Retrieve the outermost lexically enclosing record context.
bool isParameterPack() const
TemplateSpecializationKind getTemplateSpecializationKind() const
Determine what kind of template specialization this is.
bool SubstExprs(Expr **Exprs, unsigned NumExprs, bool IsCall, const MultiLevelTemplateArgumentList &TemplateArgs, SmallVectorImpl< Expr * > &Outputs)
Substitute the given template arguments into a list of expressions, expanding pack expansions if requ...
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.
bool isNull() const
Determine whether this template argument has no value.
bool isDefinedOutsideFunctionOrMethod() const
unsigned getFunctionScopeDepth() const
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...
CanQualType getCanonicalType(QualType T) const
Return the canonical (structural) type corresponding to the specified potentially non-canonical type ...
SourceLocation getParameterPackLocation() const
Get the location of the parameter pack.
ParmVarDecl * CheckParameter(DeclContext *DC, SourceLocation StartLoc, SourceLocation NameLoc, IdentifierInfo *Name, QualType T, TypeSourceInfo *TSInfo, StorageClass SC)
void InstantiateFunctionDefinition(SourceLocation PointOfInstantiation, FunctionDecl *Function, bool Recursive=false, bool DefinitionRequired=false)
Instantiate the definition of the given function from its template.
unsigned getDepth() const
Get the nesting depth of the template parameter.
bool hasInheritedDefaultArg() const
const TemplateArgument * getArgs() const
Retrieve the template arguments.
void setUnparsedDefaultArg()
PrintingPolicy getPrintingPolicy() const
Retrieve a suitable printing policy.
SourceLocation getPointOfInstantiation() const
Retrieve the first point of instantiation of this member. If the point of instantiation is an invalid...
static std::pair< unsigned, unsigned > getDepthAndIndex(NamedDecl *ND)
Retrieve the depth and index of a parameter pack.
QualType getIntegralType() const
Retrieve the type of the integral value.
UnparsedDefaultArgInstantiationsMap UnparsedDefaultArgInstantiations
A mapping from parameters with unparsed default arguments to the set of instantiations of each parame...
The template argument is a type.
void SubstExceptionSpec(FunctionDecl *New, const FunctionProtoType *Proto, const MultiLevelTemplateArgumentList &Args)
bool isStaticDataMember() const
Determines whether this is a static data member.
Represents a base class of a C++ class.
A template argument list.
const TemplateArgumentList & getTemplateArgs() const
Retrieve the template arguments of the class template specialization.
static FunctionParmPackExpr * Create(const ASTContext &Context, QualType T, ParmVarDecl *ParamPack, SourceLocation NameLoc, ArrayRef< Decl * > Params)
ExprResult SubstExpr(Expr *E, const MultiLevelTemplateArgumentList &TemplateArgs)
unsigned getFullDataSize() const
Returns the size of the type source info data block.
unsigned pack_size() const
The number of template arguments in the given template argument pack.
NamedDecl * Template
The template (or partial specialization) in which we are performing the instantiation, for substitutions of prior template arguments.
Represents a C++ struct/union/class.
static bool NeedsInstantiationAsFunctionType(TypeSourceInfo *T)
Optional< sema::TemplateDeductionInfo * > isSFINAEContext() const
Determines whether we are currently in a context where template argument substitution failures are no...
void enableLateAttributeInstantiation(Sema::LateInstantiatedAttrVec *LA)
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...
NamedDecl * FindInstantiatedDecl(SourceLocation Loc, NamedDecl *D, const MultiLevelTemplateArgumentList &TemplateArgs)
Find the instantiation of the given declaration within the current instantiation. ...
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...
TemplateParameterList * getTemplateParameters() const
Get the list of template parameters.
bool isExpandedParameterPack() const
Whether this parameter is a non-type template parameter pack that has a known list of different types...
ClassTemplatePartialSpecializationDecl * getMoreSpecializedPartialSpecialization(ClassTemplatePartialSpecializationDecl *PS1, ClassTemplatePartialSpecializationDecl *PS2, SourceLocation Loc)
Returns the more specialized class template partial specialization according to the rules of partial ...
A reference to a declared variable, function, enum, etc. [C99 6.5.1p2].
ExprValueKind getValueKind() const
getValueKind - The value kind that this expression produces.
MemberSpecializationInfo * getMemberSpecializationInfo() const
If this class is an instantiation of a member class of a class template specialization, retrieves the member specialization information.
Represents a type template specialization; the template must be a class template, a type alias templa...
SourceLocation getInnerLocStart() const
virtual bool HandleTopLevelDecl(DeclGroupRef D)
static void PrintTemplateArgumentList(raw_ostream &OS, const TemplateArgument *Args, unsigned NumArgs, const PrintingPolicy &Policy, bool SkipBrackets=false)
Print a template argument list, including the '<' and '>' enclosing the template arguments...
InstantiationKind
The kind of template instantiation we are performing.
StringRef getKindName() const
Wrapper for template type parameters.
bool isInvalid() const
Determines whether we have exceeded the maximum recursive template instantiations.
A trivial tuple used to represent a source range.
SourceLocation getLocation() const
FunctionDecl * getInstantiatedFromMemberFunction() const
If this function is an instantiation of a member function of a class template specialization, retrieves the function from which it was instantiated.
EnumDecl * getDefinition() const
No keyword precedes the qualified type name.
bool isNull() const
isNull - Return true if this QualType doesn't point to a type yet.
void setPointOfInstantiation(SourceLocation POI)
Set the first point of instantiation.
void pushFullCopy(TypeLoc L)
bool isBeingDefined() const
isBeingDefined - Return true if this decl is currently being defined.
ExceptionSpecInfo ExceptionSpec
Declaration of a template function.
Attr - This represents one attribute.
void setRBraceLoc(SourceLocation L)
const RecordDecl * getParent() const
unsigned getIndex() const
Get the index of the template parameter within its parameter list.
virtual void HandleTagDeclDefinition(TagDecl *D)
TypeSourceInfo * SubstType(TypeSourceInfo *T, const MultiLevelTemplateArgumentList &TemplateArgs, SourceLocation Loc, DeclarationName Entity)
Perform substitution on the type T with a given set of template arguments.
bool hasInClassInitializer() const