Go to the documentation of this file.
32 #include "llvm/Support/TimeProfiler.h"
34 using namespace clang;
65 Result.addOuterTemplateArguments(Innermost);
67 const auto *Ctx = dyn_cast<DeclContext>(D);
74 const auto *Spec = dyn_cast<VarTemplateSpecializationDecl>(D);
75 if (Spec && !Spec->isClassScopeExplicitSpecialization()) {
78 !isa<VarTemplatePartialSpecializationDecl>(Spec))
81 Result.addOuterTemplateArguments(&Spec->getTemplateInstantiationArgs());
85 assert(Spec->getSpecializedTemplate() &&
"No variable template?");
91 if (Partial->isMemberSpecialization())
106 if (Ctx->isTranslationUnit()) {
107 if (
const auto *TTP = dyn_cast<TemplateTemplateParmDecl>(D)) {
108 for (
unsigned I = 0, N = TTP->getDepth() + 1; I != N; ++I)
109 Result.addOuterTemplateArguments(None);
115 while (!Ctx->isFileContext()) {
117 const auto *Spec = dyn_cast<ClassTemplateSpecializationDecl>(Ctx);
118 if (Spec && !Spec->isClassScopeExplicitSpecialization()) {
121 !isa<ClassTemplatePartialSpecializationDecl>(Spec))
124 Result.addOuterTemplateArguments(&Spec->getTemplateInstantiationArgs());
128 assert(Spec->getSpecializedTemplate() &&
"No class template?");
129 if (Spec->getSpecializedTemplate()->isMemberSpecialization())
133 else if (
const auto *Function = dyn_cast<FunctionDecl>(Ctx)) {
134 if (!RelativeToPrimary &&
135 Function->getTemplateSpecializationKindForInstantiation() ==
139 if (!RelativeToPrimary && Function->getTemplateSpecializationKind() ==
145 = Function->getTemplateSpecializationArgs()) {
147 Result.addOuterTemplateArguments(TemplateArgs);
151 assert(Function->getPrimaryTemplate() &&
"No function template?");
152 if (Function->getPrimaryTemplate()->isMemberSpecialization())
159 }
else if (Function->getDescribedFunctionTemplate()) {
160 assert(Result.getNumSubstitutedLevels() == 0 &&
161 "Outer template not instantiated?");
168 if (Function->getFriendObjectKind() &&
169 Function->getDeclContext()->isFileContext() &&
171 Ctx = Function->getLexicalDeclContext();
172 RelativeToPrimary =
false;
175 }
else if (
const auto *Rec = dyn_cast<CXXRecordDecl>(Ctx)) {
177 assert(Result.getNumSubstitutedLevels() == 0 &&
178 "Outer template not instantiated?");
179 if (ClassTemplate->isMemberSpecialization())
184 Ctx = Ctx->getParent();
185 RelativeToPrimary =
false;
193 case TemplateInstantiation:
194 case ExceptionSpecInstantiation:
195 case DefaultTemplateArgumentInstantiation:
196 case DefaultFunctionArgumentInstantiation:
197 case ExplicitTemplateArgumentSubstitution:
198 case DeducedTemplateArgumentSubstitution:
199 case PriorTemplateArgumentSubstitution:
200 case ConstraintsCheck:
201 case NestedRequirementConstraintsCheck:
204 case RequirementInstantiation:
205 case DefaultTemplateArgumentChecking:
206 case DeclaringSpecialMember:
207 case DeclaringImplicitEqualityComparison:
208 case DefiningSynthesizedFunction:
209 case ExceptionSpecEvaluation:
210 case ConstraintSubstitution:
211 case ParameterMappingSubstitution:
212 case ConstraintNormalization:
213 case RewritingOperatorAsSpaceship:
214 case InitializingStructuredBinding:
215 case MarkingClassDllexported:
216 case BuildingBuiltinDumpStructCall:
224 llvm_unreachable(
"Invalid SynthesisKind!");
254 AlreadyInstantiating = !Inst.Entity ?
false :
256 .insert({Inst.Entity->getCanonicalDecl(), Inst.Kind})
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 {Active.Entity->getCanonicalDecl(), Active.Kind});
489 llvm::raw_string_ostream OS(Result);
490 llvm::ListSeparator Comma;
491 for (
const Expr *Arg : Args) {
493 Arg->IgnoreParens()->printPretty(OS,
nullptr,
499 bool Sema::InstantiatingTemplate::CheckInstantiationDepth(
509 SemaRef.
Diag(PointOfInstantiation,
510 diag::err_template_recursion_depth_exceeded)
512 << InstantiationRange;
513 SemaRef.
Diag(PointOfInstantiation, diag::note_template_recursion_depth)
525 SkipStart = Limit / 2 + Limit % 2;
530 unsigned InstantiationIdx = 0;
535 ++Active, ++InstantiationIdx) {
537 if (InstantiationIdx >= SkipStart && InstantiationIdx < SkipEnd) {
538 if (InstantiationIdx == SkipStart) {
541 diag::note_instantiation_contexts_suppressed)
547 switch (Active->Kind) {
549 Decl *D = Active->Entity;
551 unsigned DiagID = diag::note_template_member_class_here;
552 if (isa<ClassTemplateSpecializationDecl>(Record))
553 DiagID = diag::note_template_class_instantiation_here;
555 << Record << Active->InstantiationRange;
556 }
else if (
FunctionDecl *Function = dyn_cast<FunctionDecl>(D)) {
558 if (Function->getPrimaryTemplate())
559 DiagID = diag::note_function_template_spec_here;
561 DiagID = diag::note_template_member_function_here;
564 << Active->InstantiationRange;
565 }
else if (
VarDecl *VD = dyn_cast<VarDecl>(D)) {
567 VD->isStaticDataMember()?
568 diag::note_template_static_data_member_def_here
569 : diag::note_template_variable_def_here)
571 << Active->InstantiationRange;
572 }
else if (
EnumDecl *ED = dyn_cast<EnumDecl>(D)) {
574 diag::note_template_enum_def_here)
576 << Active->InstantiationRange;
577 }
else if (
FieldDecl *FD = dyn_cast<FieldDecl>(D)) {
579 diag::note_template_nsdmi_here)
580 << FD << Active->InstantiationRange;
583 diag::note_template_type_alias_instantiation_here)
584 << cast<TypeAliasTemplateDecl>(D)
585 << Active->InstantiationRange;
591 TemplateDecl *Template = cast<TemplateDecl>(Active->Template);
593 llvm::raw_svector_ostream OS(TemplateArgsStr);
598 diag::note_default_arg_instantiation_here)
600 << Active->InstantiationRange;
607 diag::note_explicit_template_arg_substitution_here)
610 Active->TemplateArgs,
611 Active->NumTemplateArgs)
612 << Active->InstantiationRange;
618 dyn_cast<FunctionTemplateDecl>(Active->Entity)) {
620 diag::note_function_template_deduction_instantiation_here)
623 Active->TemplateArgs,
624 Active->NumTemplateArgs)
625 << Active->InstantiationRange;
627 bool IsVar = isa<VarTemplateDecl>(Active->Entity) ||
628 isa<VarTemplateSpecializationDecl>(Active->Entity);
629 bool IsTemplate =
false;
631 if (
auto *D = dyn_cast<TemplateDecl>(Active->Entity)) {
633 Params = D->getTemplateParameters();
634 }
else if (
auto *D = dyn_cast<ClassTemplatePartialSpecializationDecl>(
636 Params = D->getTemplateParameters();
637 }
else if (
auto *D = dyn_cast<VarTemplatePartialSpecializationDecl>(
639 Params = D->getTemplateParameters();
641 llvm_unreachable(
"unexpected template kind");
645 diag::note_deduced_template_arg_substitution_here)
646 << IsVar << IsTemplate << cast<NamedDecl>(Active->Entity)
648 Active->NumTemplateArgs)
649 << Active->InstantiationRange;
655 ParmVarDecl *Param = cast<ParmVarDecl>(Active->Entity);
659 llvm::raw_svector_ostream OS(TemplateArgsStr);
664 diag::note_default_function_arg_instantiation_here)
666 << Active->InstantiationRange;
671 NamedDecl *Parm = cast<NamedDecl>(Active->Entity);
677 if (
TemplateDecl *Template = dyn_cast<TemplateDecl>(Active->Template))
678 TemplateParams = Template->getTemplateParameters();
681 cast<ClassTemplatePartialSpecializationDecl>(Active->Template)
682 ->getTemplateParameters();
684 diag::note_prior_template_arg_substitution)
685 << isa<TemplateTemplateParmDecl>(Parm)
688 Active->TemplateArgs,
689 Active->NumTemplateArgs)
690 << Active->InstantiationRange;
696 if (
TemplateDecl *Template = dyn_cast<TemplateDecl>(Active->Template))
697 TemplateParams = Template->getTemplateParameters();
700 cast<ClassTemplatePartialSpecializationDecl>(Active->Template)
701 ->getTemplateParameters();
704 diag::note_template_default_arg_checking)
706 Active->TemplateArgs,
707 Active->NumTemplateArgs)
708 << Active->InstantiationRange;
714 diag::note_evaluating_exception_spec_here)
715 << cast<FunctionDecl>(Active->Entity);
720 diag::note_template_exception_spec_instantiation_here)
721 << cast<FunctionDecl>(Active->Entity)
722 << Active->InstantiationRange;
727 diag::note_template_requirement_instantiation_here)
728 << Active->InstantiationRange;
733 diag::note_nested_requirement_here)
734 << Active->InstantiationRange;
739 diag::note_in_declaration_of_implicit_special_member)
740 << cast<CXXRecordDecl>(Active->Entity) << Active->SpecialMember;
745 diag::note_in_declaration_of_implicit_equality_comparison);
751 auto *FD = dyn_cast<FunctionDecl>(Active->Entity);
755 auto *MD = cast<CXXMethodDecl>(FD);
757 diag::note_member_synthesized_at)
762 diag::note_comparison_synthesized_at)
765 cast<CXXRecordDecl>(FD->getLexicalDeclContext()));
772 diag::note_rewriting_operator_as_spaceship);
777 diag::note_in_binding_decl_init)
778 << cast<BindingDecl>(Active->Entity);
783 diag::note_due_to_dllexported_class)
784 << cast<CXXRecordDecl>(Active->Entity) << !
getLangOpts().CPlusPlus11;
789 diag::note_building_builtin_dump_struct_call)
792 llvm::makeArrayRef(Active->CallArgs, Active->NumCallArgs));
800 if (!Active->Entity) {
802 diag::note_nested_requirement_here)
803 << Active->InstantiationRange;
806 if (isa<ConceptDecl>(Active->Entity))
807 DiagID = diag::note_concept_specialization_here;
808 else if (isa<TemplateDecl>(Active->Entity))
809 DiagID = diag::note_checking_constraints_for_template_id_here;
810 else if (isa<VarTemplatePartialSpecializationDecl>(Active->Entity))
811 DiagID = diag::note_checking_constraints_for_var_spec_id_here;
812 else if (isa<ClassTemplatePartialSpecializationDecl>(Active->Entity))
813 DiagID = diag::note_checking_constraints_for_class_spec_id_here;
815 assert(isa<FunctionDecl>(Active->Entity));
816 DiagID = diag::note_checking_constraints_for_function_here;
819 llvm::raw_svector_ostream OS(TemplateArgsStr);
820 cast<NamedDecl>(Active->Entity)->printName(OS);
821 if (!isa<FunctionDecl>(Active->Entity)) {
825 Diags.
Report(Active->PointOfInstantiation, DiagID) << OS.str()
826 << Active->InstantiationRange;
831 diag::note_constraint_substitution_here)
832 << Active->InstantiationRange;
836 diag::note_constraint_normalization_here)
837 << cast<NamedDecl>(Active->Entity)->getName()
838 << Active->InstantiationRange;
842 diag::note_parameter_mapping_substitution_here)
843 << Active->InstantiationRange;
859 switch (Active->Kind) {
863 if (isa<TypeAliasTemplateDecl>(Active->Entity))
891 assert(Active->DeductionInfo &&
"Missing deduction info pointer");
892 return Active->DeductionInfo;
916 if (Active->SavedInNonInstantiationSFINAEContext)
927 class TemplateInstantiator :
public TreeTransform<TemplateInstantiator> {
935 TemplateInstantiator(
Sema &SemaRef,
939 : inherited(SemaRef), TemplateArgs(TemplateArgs), Loc(Loc),
947 bool AlreadyTransformed(
QualType T);
959 this->Entity = Entity;
962 unsigned TransformTemplateDepth(
unsigned Depth) {
969 bool &ShouldExpand,
bool &RetainExpansion,
971 return getSema().CheckParameterPacksForExpansion(EllipsisLoc,
972 PatternRange, Unexpanded,
979 void ExpandingFunctionParameterPack(
ParmVarDecl *Pack) {
989 unsigned Depth, Index;
992 Result = TemplateArgs(
Depth, Index);
1008 unsigned Depth, Index;
1018 void transformAttrs(
Decl *Old,
Decl *New) {
1025 for (
auto *New : NewDecls)
1027 Old, cast<VarDecl>(New));
1031 assert(NewDecls.size() == 1 &&
1032 "should only have multiple expansions for a pack");
1033 Decl *New = NewDecls.front();
1038 auto *NewMD = dyn_cast<CXXMethodDecl>(New);
1040 auto *OldMD = dyn_cast<CXXMethodDecl>(Old);
1041 if (
auto *NewTD = NewMD->getDescribedFunctionTemplate())
1042 NewTD->setInstantiatedFromMemberTemplate(
1043 OldMD->getDescribedFunctionTemplate());
1045 NewMD->setInstantiationOfMemberFunction(OldMD,
1053 if (
auto *DC = dyn_cast<DeclContext>(Old))
1089 NamedDecl *FirstQualifierInScope =
nullptr,
1090 bool AllowInjectedClassName =
false);
1092 const LoopHintAttr *TransformLoopHintAttr(
const LoopHintAttr *LH);
1100 ExprResult TransformSubstNonTypeTemplateParmPackExpr(
1102 ExprResult TransformSubstNonTypeTemplateParmExpr(
1119 return inherited::TransformFunctionProtoType(TLB, TL);
1122 template<
typename Fn>
1127 Fn TransformExceptionSpec);
1130 int indexAdjustment,
1132 bool ExpectParameterPack);
1147 return inherited::TransformLambdaExpr(E);
1152 return inherited::TransformRequiresExpr(E);
1155 bool TransformRequiresExprRequirements(
1158 bool SatisfactionDetermined =
false;
1161 if (!SatisfactionDetermined) {
1162 if (
auto *TypeReq = dyn_cast<concepts::TypeRequirement>(Req))
1163 TransReq = TransformTypeRequirement(TypeReq);
1164 else if (
auto *ExprReq = dyn_cast<concepts::ExprRequirement>(Req))
1165 TransReq = TransformExprRequirement(ExprReq);
1167 TransReq = TransformNestedRequirement(
1168 cast<concepts::NestedRequirement>(Req));
1177 SatisfactionDetermined =
true;
1180 Transformed.push_back(TransReq);
1187 if (!OrigTPL || !OrigTPL->
size())
return OrigTPL;
1191 Owner, TemplateArgs);
1192 return DeclInstantiator.SubstTemplateParams(OrigTPL);
1209 bool TemplateInstantiator::AlreadyTransformed(
QualType T) {
1216 getSema().MarkDeclarationsReferencedInType(Loc, T);
1241 TTP->getPosition()))
1246 if (TTP->isParameterPack()) {
1248 "Missing argument pack");
1254 "Wrong kind of template template argument");
1266 Decl *Inst = getSema().SubstDecl(D, getSema().
CurContext, TemplateArgs);
1270 getSema().CurrentInstantiationScope->InstantiatedLocal(D, Inst);
1275 TemplateInstantiator::TransformFirstQualifierInScope(
NamedDecl *D,
1289 "Missing argument pack");
1299 return cast_or_null<NamedDecl>(TransformDecl(Loc, D));
1302 return Tag->getDecl();
1305 getSema().Diag(Loc, diag::err_nested_name_spec_non_tag) << T;
1310 return cast_or_null<NamedDecl>(TransformDecl(Loc, D));
1314 TemplateInstantiator::RebuildExceptionDecl(
VarDecl *ExceptionDecl,
1320 StartLoc, NameLoc, Name);
1322 getSema().CurrentInstantiationScope->InstantiatedLocal(ExceptionDecl, Var);
1326 VarDecl *TemplateInstantiator::RebuildObjCExceptionDecl(
VarDecl *ExceptionDecl,
1329 VarDecl *Var = inherited::RebuildObjCExceptionDecl(ExceptionDecl, TSInfo, T);
1331 getSema().CurrentInstantiationScope->InstantiatedLocal(ExceptionDecl, Var);
1336 TemplateInstantiator::RebuildElaboratedType(
SourceLocation KeywordLoc,
1353 SemaRef.
Diag(TagLocation, diag::err_use_with_wrong_tag)
1362 return inherited::RebuildElaboratedType(KeywordLoc, Keyword, QualifierLoc, T);
1365 TemplateName TemplateInstantiator::TransformTemplateName(
1368 bool AllowInjectedClassName) {
1370 = dyn_cast_or_null<TemplateTemplateParmDecl>(Name.getAsTemplateDecl())) {
1377 TTP->getPosition()))
1387 "unexpected pack arguments in template rewrite");
1391 "unexpected nontype template argument kind in template rewrite");
1397 "Missing argument pack");
1403 return getSema().Context.getSubstTemplateTemplateParmPack(TTP, Arg);
1410 assert(!Template.
isNull() &&
"Null template template argument");
1412 "template decl to substitute is qualified?");
1414 Template = getSema().Context.getSubstTemplateTemplateParm(TTP, Template);
1420 = Name.getAsSubstTemplateTemplateParmPack()) {
1429 return inherited::TransformTemplateName(SS, Name, NameLoc, ObjectType,
1430 FirstQualifierInScope,
1431 AllowInjectedClassName);
1435 TemplateInstantiator::TransformPredefinedExpr(
PredefinedExpr *E) {
1443 TemplateInstantiator::TransformTemplateParmRefExpr(
DeclRefExpr *E,
1460 "unexpected pack arguments in template rewrite");
1464 "unexpected nontype template argument kind in template rewrite");
1472 "Missing argument pack");
1496 return transformNonTypeTemplateParmRef(NTTP, E->
getLocation(), Arg);
1499 const LoopHintAttr *
1500 TemplateInstantiator::TransformLoopHintAttr(
const LoopHintAttr *LH) {
1501 Expr *TransformedExpr = getDerived().TransformExpr(LH->getValue()).get();
1503 if (TransformedExpr == LH->getValue())
1512 return LoopHintAttr::CreateImplicit(getSema().
Context, LH->getOption(),
1513 LH->getState(), TransformedExpr, *LH);
1516 ExprResult TemplateInstantiator::transformNonTypeTemplateParmRef(
1524 auto SubstParamType = [&] {
1531 T = cast<PackExpansionType>(T)->getPattern();
1535 bool refParam =
false;
1541 Expr *argExpr =
arg.getAsExpr();
1546 QualType paramType = SubstParamType();
1558 VD =
arg.getAsDecl();
1562 VD = cast_or_null<ValueDecl>(
1571 QualType paramType = VD ?
arg.getParamTypeForDecl() :
arg.getNullPtrType();
1572 assert(!paramType.
isNull() &&
"type substitution failed for param type");
1573 assert(!paramType->
isDependentType() &&
"param type still dependent");
1580 arg.getIntegralType()));
1586 Expr *resultExpr = result.
get();
1593 TemplateInstantiator::TransformSubstNonTypeTemplateParmPackExpr(
1608 TemplateInstantiator::TransformSubstNonTypeTemplateParmExpr(
1611 if (!isa<ConstantExpr>(SubstReplacement.
get()))
1640 SubstReplacement.
get(),
1641 Converted).isInvalid())
1643 return transformNonTypeTemplateParmRef(E->
getParameter(),
1650 return getSema().BuildDeclarationNameExpr(
CXXScopeSpec(), NameInfo, PD);
1661 return RebuildVarDeclRefExpr(VD, E->
getExprLoc());
1683 getSema().MarkFunctionParmPackReferenced(PackExpr);
1688 TemplateInstantiator::TransformFunctionParmPackRefExpr(
DeclRefExpr *E,
1691 llvm::PointerUnion<Decl *, DeclArgumentPack *> *Found
1692 = getSema().CurrentInstantiationScope->findInstantiationOf(PD);
1693 assert(Found &&
"no instantiation for parameter pack");
1695 Decl *TransformedDecl;
1696 if (DeclArgumentPack *Pack = Found->dyn_cast<DeclArgumentPack *>()) {
1705 getSema().MarkFunctionParmPackReferenced(PackExpr);
1709 TransformedDecl = (*Pack)[getSema().ArgumentPackSubstitutionIndex];
1711 TransformedDecl = Found->get<
Decl*>();
1715 return RebuildVarDeclRefExpr(cast<VarDecl>(TransformedDecl), E->
getExprLoc());
1719 TemplateInstantiator::TransformDeclRefExpr(
DeclRefExpr *E) {
1726 return TransformTemplateParmRefExpr(E, NTTP);
1733 if (
VarDecl *PD = dyn_cast<VarDecl>(D))
1735 return TransformFunctionParmPackRefExpr(E, PD);
1737 return inherited::TransformDeclRefExpr(E);
1740 ExprResult TemplateInstantiator::TransformCXXDefaultArgExpr(
1743 getDescribedFunctionTemplate() &&
1744 "Default arg expressions are never formed in dependent cases.");
1750 template<
typename Fn>
1755 Fn TransformExceptionSpec) {
1758 return inherited::TransformFunctionProtoType(
1759 TLB, TL, ThisContext, ThisTypeQuals, TransformExceptionSpec);
1763 TemplateInstantiator::TransformFunctionTypeParam(
ParmVarDecl *OldParm,
1764 int indexAdjustment,
1766 bool ExpectParameterPack) {
1769 NumExpansions, ExpectParameterPack);
1776 TemplateInstantiator::TransformTemplateTypeParmType(
TypeLocBuilder &TLB,
1801 "unexpected pack arguments in template rewrite");
1805 "unexpected nontype template argument kind in template rewrite");
1807 assert(isa<TemplateTypeParmType>(NewT) &&
1808 "type parm not rewritten to type parm");
1816 "Missing argument pack");
1823 = getSema().Context.getSubstTemplateTypeParmPackType(T, Arg);
1834 "Template argument kind mismatch");
1840 = getSema().Context.getSubstTemplateTypeParmType(T, Replacement);
1853 NewTTPDecl = cast_or_null<TemplateTypeParmDecl>(
1856 QualType Result = getSema().Context.getTemplateTypeParmType(
1865 TemplateInstantiator::TransformSubstTemplateTypeParmPackType(
1880 Result = getSema().Context.getSubstTemplateTypeParmType(
1889 template<
typename EntityPr
inter>
1899 ErrorLoc = PDA.first;
1903 char *MessageBuf =
new (S.
Context)
char[Message.size()];
1904 std::copy(Message.begin(), Message.end(), MessageBuf);
1906 llvm::raw_svector_ostream OS(Entity);
1908 char *EntityBuf =
new (S.
Context)
char[Entity.size()];
1909 std::copy(Entity.begin(), Entity.end(), EntityBuf);
1911 StringRef(EntityBuf, Entity.size()), ErrorLoc,
1912 StringRef(MessageBuf, Message.size())};
1920 if (AlwaysRebuild())
1921 return RebuildTypeRequirement(
1931 if (TypeInst.isInvalid())
1934 if (!TransType || Trap.hasErrorOccurred())
1936 [&] (llvm::raw_ostream& OS) {
1939 return RebuildTypeRequirement(TransType);
1949 llvm::PointerUnion<Expr *, concepts::Requirement::SubstitutionDiagnostic *>
1958 if (ExprInst.isInvalid())
1961 if (!TransExprRes.
isInvalid() && !Trap.hasErrorOccurred() &&
1962 TransExprRes.
get()->hasPlaceholderType())
1964 if (TransExprRes.
isInvalid() || Trap.hasErrorOccurred())
1965 TransExpr =
createSubstDiag(SemaRef, Info, [&](llvm::raw_ostream &OS) {
1969 TransExpr = TransExprRes.
get();
1974 if (RetReq.isEmpty())
1975 TransRetReq.emplace();
1976 else if (RetReq.isSubstitutionFailure())
1977 TransRetReq.emplace(RetReq.getSubstitutionDiagnostic());
1978 else if (RetReq.isTypeConstraint()) {
1980 RetReq.getTypeConstraintTemplateParameterList();
1984 if (TPLInst.isInvalid())
1987 TransformTemplateParameterList(OrigTPL);
1990 [&] (llvm::raw_ostream& OS) {
1991 RetReq.getTypeConstraint()->getImmediatelyDeclaredConstraint()
1996 TransRetReq.emplace(TPL);
1999 assert(TransRetReq.hasValue() &&
2000 "All code paths leading here must set TransRetReq");
2001 if (
Expr *E = TransExpr.dyn_cast<
Expr *>())
2003 std::move(*TransRetReq));
2004 return RebuildExprRequirement(
2010 TemplateInstantiator::TransformNestedRequirement(
2015 if (AlwaysRebuild())
2016 return RebuildNestedRequirement(
2034 if (ConstrInst.isInvalid())
2037 if (TransConstraint.
isInvalid() || Trap.hasErrorOccurred())
2039 [&] (llvm::raw_ostream& OS) {
2044 return RebuildNestedRequirement(TransConstraint.
get());
2082 bool AllowDeducedTST) {
2084 "Cannot perform an instantiation without some context on the "
2085 "instantiation stack");
2091 TemplateInstantiator Instantiator(*
this, Args, Loc, Entity);
2092 return AllowDeducedTST ? Instantiator.TransformTypeWithDeducedTST(T)
2093 : Instantiator.TransformType(T);
2101 "Cannot perform an instantiation without some context on the "
2102 "instantiation stack");
2116 TemplateInstantiator Instantiator(*
this, Args, Loc, Entity);
2119 QualType Result = Instantiator.TransformType(TLB, TL);
2120 if (Result.isNull())
2131 "Cannot perform an instantiation without some context on the "
2132 "instantiation stack");
2139 TemplateInstantiator Instantiator(*
this, TemplateArgs, Loc, Entity);
2140 return Instantiator.TransformType(T);
2176 "Cannot perform an instantiation without some context on the "
2177 "instantiation stack");
2182 TemplateInstantiator Instantiator(*
this, Args, Loc, Entity);
2198 Result = Instantiator.TransformFunctionProtoType(
2199 TLB, Proto, ThisContext, ThisTypeQuals,
2201 bool &Changed) {
return false; });
2203 Result = Instantiator.TransformType(TLB, TL);
2205 if (Result.isNull())
2217 bool Changed =
false;
2218 TemplateInstantiator Instantiator(*
this, Args, Loc,
DeclarationName());
2219 return Instantiator.TransformExceptionSpec(Loc, ESI, ExceptionStorage,
2230 ESI, ExceptionStorage, Args))
2239 struct GetContainedInventedTypeParmVisitor :
2240 public TypeVisitor<GetContainedInventedTypeParmVisitor,
2241 TemplateTypeParmDecl *> {
2242 using TypeVisitor<GetContainedInventedTypeParmVisitor,
2295 return VisitFunctionType(T);
2350 int indexAdjustment,
2352 bool ExpectParameterPack) {
2361 NewDI =
SubstType(ExpansionTL.getPatternLoc(), TemplateArgs,
2372 }
else if (ExpectParameterPack) {
2378 diag::err_function_parameter_pack_without_parameter_packs)
2402 GetContainedInventedTypeParmVisitor().Visit(OldDI->
getType())) {
2404 auto *Inst = cast_or_null<TemplateTypeParmDecl>(
2409 if (Inst && !Inst->getTypeConstraint()) {
2447 if (Result.isInvalid())
2493 "Cannot perform an instantiation without some context on the "
2494 "instantiation stack");
2496 TemplateInstantiator Instantiator(*
this, TemplateArgs, Loc,
2498 return Instantiator.TransformFunctionTypeParams(
2499 Loc, Params,
nullptr, ExtParamInfos, ParamTypes, OutParams, ParamInfos);
2512 bool Invalid =
false;
2514 for (
const auto &
Base : Pattern->
bases()) {
2515 if (!
Base.getType()->isDependentType()) {
2517 if (RD->isInvalidDecl())
2526 if (
Base.isPackExpansion()) {
2532 bool ShouldExpand =
false;
2533 bool RetainExpansion =
false;
2536 Base.getSourceRange(),
2538 TemplateArgs, ShouldExpand,
2547 for (
unsigned I = 0; I != *NumExpansions; ++I) {
2552 Base.getSourceRange().getBegin(),
2561 Base.getSourceRange(),
2563 Base.getAccessSpecifierAsWritten(),
2566 InstantiatedBases.push_back(InstantiatedBase);
2575 EllipsisLoc =
Base.getEllipsisLoc();
2579 Base.getSourceRange().getBegin(),
2584 Base.getSourceRange().getBegin(),
2595 Base.getSourceRange(),
2597 Base.getAccessSpecifierAsWritten(),
2600 InstantiatedBases.push_back(InstantiatedBase);
2654 Pattern, PatternDef, TSK, Complain))
2657 llvm::TimeTraceScope TimeScope(
"InstantiateClass", [&]() {
2659 llvm::raw_string_ostream OS(Name);
2665 Pattern = PatternDef;
2671 MSInfo->setPointOfInstantiation(PointOfInstantiation);
2673 = dyn_cast<ClassTemplateSpecializationDecl>(Instantiation)) {
2674 Spec->setTemplateSpecializationKind(TSK);
2675 Spec->setPointOfInstantiation(PointOfInstantiation);
2683 "instantiating class definition");
2701 SavePendingParsedClassStateRAII SavedPendingParsedClassState(*
this);
2714 Instantiation->
setTagKind(Pattern->getTagKind());
2726 bool MightHaveConstexprVirtualFunctions =
false;
2727 for (
auto *
Member : Pattern->decls()) {
2737 if (
Member->getDeclContext() != Pattern)
2744 if (isa<BlockDecl>(
Member) ||
2745 (isa<CXXRecordDecl>(
Member) && cast<CXXRecordDecl>(
Member)->isLambda()))
2748 if (
Member->isInvalidDecl()) {
2755 if (
FieldDecl *Field = dyn_cast<FieldDecl>(NewMember)) {
2756 Fields.push_back(Field);
2757 }
else if (
EnumDecl *Enum = dyn_cast<EnumDecl>(NewMember)) {
2763 Enum->isCompleteDefinition()) {
2765 assert(MSInfo &&
"no spec info for member enum specialization");
2770 if (SA->isFailed()) {
2776 }
else if (
CXXMethodDecl *MD = dyn_cast<CXXMethodDecl>(NewMember)) {
2777 if (MD->isConstexpr() && !MD->getFriendObjectKind() &&
2778 (MD->isVirtualAsWritten() || Instantiation->
getNumBases()))
2779 MightHaveConstexprVirtualFunctions =
true;
2800 if (ParsingClassDepth == 0)
2805 for (LateInstantiatedAttrVec::iterator I = LateAttrs.begin(),
2806 E = LateAttrs.end(); I != E; ++I) {
2811 auto *ND = cast<NamedDecl>(I->NewDecl);
2812 auto *ThisContext = dyn_cast_or_null<CXXRecordDecl>(ND->getDeclContext());
2814 ND->isCXXInstanceMember());
2819 I->NewDecl->addAttr(NewAttr);
2831 Instantiation->
setLocation(Pattern->getLocation());
2832 Instantiation->
setLocStart(Pattern->getInnerLocStart());
2838 if (Pattern->isDependentContext())
2848 P->first,
P->second)) {
2861 P->first,
P->second)) {
2878 else if (MightHaveConstexprVirtualFunctions)
2910 Pattern, PatternDef, TSK,
true))
2912 Pattern = PatternDef;
2918 MSInfo->setPointOfInstantiation(PointOfInstantiation);
2927 "instantiating enum definition");
2977 "pattern and instantiation disagree about init style");
2985 Diag(PointOfInstantiation,
2986 diag::err_default_member_initializer_not_yet_parsed)
2987 << OutermostClass << Pattern;
2988 Diag(Pattern->getEndLoc(),
2989 diag::note_default_member_initializer_not_yet_parsed);
2999 Diag(PointOfInstantiation, diag::err_default_member_initializer_cycle)
3004 "instantiating default member init");
3021 assert((!Init || !isa<ParenListExpr>(Init)) &&
"call-style init in class");
3023 Instantiation, Init ? Init->getBeginLoc() :
SourceLocation(), Init);
3026 L->DefaultMemberInitializerInstantiated(Instantiation);
3035 struct PartialSpecMatchResult {
3050 for (
unsigned I = 0, N = PartialSpecs.size(); I != N; ++I) {
3094 for (
unsigned I = 0, N = PartialSpecs.size(); I != N; ++I) {
3106 Matched.push_back(PartialSpecMatchResult());
3107 Matched.back().Partial = Partial;
3108 Matched.back().Args = Info.
take();
3116 if (Matched.size() >= 1) {
3118 if (Matched.size() == 1) {
3131 PEnd = Matched.end();
3134 P->Partial, Best->Partial, PointOfInstantiation) ==
3141 bool Ambiguous =
false;
3143 PEnd = Matched.end();
3146 P->Partial, Best->Partial,
3147 PointOfInstantiation) != Best->Partial) {
3157 S.
Diag(PointOfInstantiation,
3158 diag::err_partial_spec_ordering_ambiguous)
3159 << ClassTemplateSpec;
3163 PEnd = Matched.end();
3165 S.
Diag(
P->Partial->getLocation(), diag::note_partial_spec_match)
3167 P->Partial->getTemplateParameters(), *
P->Args);
3182 if (
auto *PartialSpec =
3185 while (PartialSpec->getInstantiatedFromMember()) {
3188 if (PartialSpec->isMemberSpecialization())
3191 PartialSpec = PartialSpec->getInstantiatedFromMember();
3193 Pattern = PartialSpec;
3215 ClassTemplateSpec = cast<ClassTemplateSpecializationDecl>(
3222 ClassTemplateSpec, TSK);
3227 PointOfInstantiation, ClassTemplateSpec, Pattern.
get(),
3246 "Unexpected template specialization kind!");
3247 for (
auto *D : Instantiation->
decls()) {
3248 bool SuppressNew =
false;
3249 if (
auto *Function = dyn_cast<FunctionDecl>(D)) {
3251 Function->getInstantiatedFromMemberFunction()) {
3253 if (Function->getTrailingRequiresClause()) {
3261 if (Function->hasAttr<ExcludeFromExplicitInstantiationAttr>())
3265 Function->getMemberSpecializationInfo();
3266 assert(MSInfo &&
"No member specialization information?");
3288 Function->setTemplateSpecializationKind(TSK, PointOfInstantiation);
3290 if (Function->isDefined()) {
3298 std::make_pair(Function, PointOfInstantiation));
3301 }
else if (
auto *Var = dyn_cast<VarDecl>(D)) {
3302 if (isa<VarTemplateSpecializationDecl>(Var))
3306 if (Var->
hasAttr<ExcludeFromExplicitInstantiationAttr>())
3310 assert(MSInfo &&
"No member specialization information?");
3339 }
else if (
auto *Record = dyn_cast<CXXRecordDecl>(D)) {
3340 if (Record->hasAttr<ExcludeFromExplicitInstantiationAttr>())
3348 if (Record->isInjectedClassName() || Record->getPreviousDecl() ||
3353 assert(MSInfo &&
"No member specialization information?");
3379 assert(Pattern &&
"Missing instantiated-from-template information");
3381 if (!Record->getDefinition()) {
3402 Record->getTemplateSpecializationKind() ==
3404 Record->setTemplateSpecializationKind(TSK);
3409 Pattern = cast_or_null<CXXRecordDecl>(Record->getDefinition());
3413 }
else if (
auto *Enum = dyn_cast<EnumDecl>(D)) {
3415 assert(MSInfo &&
"No member specialization information?");
3422 PointOfInstantiation, TSK, Enum,
3428 if (Enum->getDefinition())
3431 EnumDecl *Pattern = Enum->getTemplateInstantiationPattern();
3432 assert(Pattern &&
"Missing instantiated-from-template information");
3438 InstantiateEnum(PointOfInstantiation, Enum, Pattern, TemplateArgs, TSK);
3443 }
else if (
auto *Field = dyn_cast<FieldDecl>(D)) {
3450 ClassPattern->
lookup(Field->getDeclName());
3486 TemplateInstantiator Instantiator(*
this, TemplateArgs,
3489 return Instantiator.TransformStmt(S);
3496 TemplateInstantiator Instantiator(*
this, TemplateArgs,
3499 return Instantiator.TransformTemplateArguments(Args.begin(), Args.end(),
3508 TemplateInstantiator Instantiator(*
this, TemplateArgs,
3511 return Instantiator.TransformExpr(E);
3516 bool CXXDirectInit) {
3517 TemplateInstantiator Instantiator(*
this, TemplateArgs,
3520 return Instantiator.TransformInitializer(Init, CXXDirectInit);
3529 TemplateInstantiator Instantiator(*
this, TemplateArgs,
3532 return Instantiator.TransformExprs(Exprs.data(), Exprs.size(),
3542 TemplateInstantiator Instantiator(*
this, TemplateArgs, NNS.
getBeginLoc(),
3544 return Instantiator.TransformNestedNameSpecifierLoc(NNS);
3551 TemplateInstantiator Instantiator(*
this, TemplateArgs, NameInfo.
getLoc(),
3553 return Instantiator.TransformDeclarationNameInfo(NameInfo);
3560 TemplateInstantiator Instantiator(*
this, TemplateArgs, Loc,
3563 SS.
Adopt(QualifierLoc);
3564 return Instantiator.TransformTemplateName(SS, Name, Loc);
3572 if (
const ParmVarDecl *PV = dyn_cast<ParmVarDecl>(D)) {
3573 if (
const FunctionDecl *FD = dyn_cast<FunctionDecl>(PV->getDeclContext())) {
3574 unsigned i = PV->getFunctionScopeIndex();
3577 if (i < FD->getNumParams() && FD->getParamDecl(i) == PV)
3585 llvm::PointerUnion<Decl *, LocalInstantiationScope::DeclArgumentPack *> *
3589 Current = Current->Outer) {
3592 const Decl *CheckD = D;
3594 LocalDeclsMap::iterator Found = Current->LocalDecls.find(CheckD);
3595 if (Found != Current->LocalDecls.end())
3596 return &Found->second;
3600 if (
const TagDecl *Tag = dyn_cast<TagDecl>(CheckD))
3607 if (!Current->CombineWithOuterScope)
3613 if (isa<NonTypeTemplateParmDecl>(D) || isa<TemplateTypeParmDecl>(D) ||
3614 isa<TemplateTemplateParmDecl>(D))
3619 if (RD->isLocalClass())
3624 if (isa<EnumDecl>(D))
3629 if (isa<TypedefNameDecl>(D) &&
3636 assert(isa<LabelDecl>(D) &&
"declaration not instantiated in this scope");
3642 llvm::PointerUnion<Decl *, DeclArgumentPack *> &Stored = LocalDecls[D];
3643 if (Stored.isNull()) {
3647 while (Current->CombineWithOuterScope && Current->Outer) {
3648 Current = Current->Outer;
3649 assert(Current->LocalDecls.find(D) == Current->LocalDecls.end() &&
3650 "Instantiated local in inner and outer scopes");
3655 Pack->push_back(cast<VarDecl>(Inst));
3657 assert(Stored.get<
Decl *>() == Inst &&
"Already instantiated this local");
3665 Pack->push_back(Inst);
3672 Current && Current->CombineWithOuterScope; Current = Current->Outer)
3673 assert(Current->LocalDecls.find(D) == Current->LocalDecls.end() &&
3674 "Creating local pack after instantiation of local");
3678 llvm::PointerUnion<Decl *, DeclArgumentPack *> &Stored = LocalDecls[D];
3681 ArgumentPacks.push_back(Pack);
3686 if (llvm::is_contained(*Pack, D))
3693 unsigned NumExplicitArgs) {
3694 assert((!PartiallySubstitutedPack || PartiallySubstitutedPack == Pack) &&
3695 "Already have a partially-substituted pack");
3696 assert((!PartiallySubstitutedPack
3697 || NumArgsInPartiallySubstitutedPack == NumExplicitArgs) &&
3698 "Wrong number of arguments in partially-substituted pack");
3699 PartiallySubstitutedPack = Pack;
3700 ArgsInPartiallySubstitutedPack = ExplicitArgs;
3701 NumArgsInPartiallySubstitutedPack = NumExplicitArgs;
3706 unsigned *NumExplicitArgs)
const {
3708 *ExplicitArgs =
nullptr;
3709 if (NumExplicitArgs)
3710 *NumExplicitArgs = 0;
3713 Current = Current->Outer) {
3714 if (Current->PartiallySubstitutedPack) {
3716 *ExplicitArgs = Current->ArgsInPartiallySubstitutedPack;
3717 if (NumExplicitArgs)
3718 *NumExplicitArgs = Current->NumArgsInPartiallySubstitutedPack;
3720 return Current->PartiallySubstitutedPack;
3723 if (!Current->CombineWithOuterScope)
ElaboratedTypeKeyword
The elaboration keyword that precedes a qualified type name or introduces an elaborated-type-specifie...
SourceLocation getInnerLocStart() const
Return start of source range ignoring outer template declarations.
TemplateArgumentList * take()
Take ownership of the deduced template argument list.
StringRef getKindName() const
virtual void HandleTagDeclDefinition(TagDecl *D)
HandleTagDeclDefinition - This callback is invoked each time a TagDecl (e.g.
DeclContext * CurContext
CurContext - This is the current declaration context of parsing.
Represents a reference to a non-type template parameter that has been substituted with a template arg...
ExprValueKind getValueKind() const
getValueKind - The value kind that this expression produces.
void setArgument(unsigned Depth, unsigned Index, TemplateArgument Arg)
Clear out a specific template argument.
SubstitutionDiagnostic * getExprSubstitutionDiagnostic() const
bool isRecordType() const
void warnStackExhausted(SourceLocation Loc)
Warn that the stack is nearly exhausted.
static bool NeedsInstantiationAsFunctionType(TypeSourceInfo *T)
bool isLambdaCallOperator(const CXXMethodDecl *MD)
QualType getInnerType() const
void setUnparsedDefaultArg()
Specify that this parameter has an unparsed default argument.
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.
ExprResult CheckPlaceholderExpr(Expr *E)
Check for operands with placeholder types and complain if found.
QualType getTypeDeclType(const TypeDecl *Decl, const TypeDecl *PrevDecl=nullptr) const
Return the unique reference to the type for the specified type declaration.
delayed_var_partial_spec_iterator delayed_var_partial_spec_begin()
UnparsedDefaultArgInstantiationsMap UnparsedDefaultArgInstantiations
A mapping from parameters with unparsed default arguments to the set of instantiations of each parame...
DeclarationNameInfo SubstDeclarationNameInfo(const DeclarationNameInfo &NameInfo, const MultiLevelTemplateArgumentList &TemplateArgs)
Do template substitution on declaration name info.
decl_range decls() const
decls_begin/decls_end - Iterate over the declarations stored in this context.
void setDeclContext(DeclContext *DC)
setDeclContext - Set both the semantic and lexical DeclContext to DC.
SourceLocation getLocation() const
void setTemplateSpecializationKind(TemplateSpecializationKind TSK, SourceLocation PointOfInstantiation=SourceLocation())
For a static data member that was instantiated from a static data member of a class template,...
void deduceOpenCLAddressSpace(ValueDecl *decl)
QualType getType() const
Return the type wrapped by this type source info.
SubstitutionDiagnostic * getSubstitutionDiagnostic() const
ArrayRef< ParmVarDecl * > getParams() const
An attributed type is a type to which a type attribute has been applied.
Provides information a specialization of a member of a class template, which may be a member function...
bool isStackNearlyExhausted()
Determine whether the stack is nearly exhausted.
void pushCodeSynthesisContext(CodeSynthesisContext Ctx)
void Adopt(NestedNameSpecifierLoc Other)
Adopt an existing nested-name-specifier (with source-range information).
TemplateTypeParmDecl * getDecl() const
RAII object used to temporarily allow the C++ 'this' expression to be used, with the given qualifiers...
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...
TemplateArgument getArgumentPack() const
static concepts::Requirement::SubstitutionDiagnostic * createSubstDiag(Sema &S, TemplateDeductionInfo &Info, EntityPrinter Printer)
bool isLValue() const
isLValue - True if this expression is an "l-value" according to the rules of the current language.
A trivial tuple used to represent a source range.
DeclContext - This is used only as base class of specific decl types that can act as declaration cont...
MemberSpecializationInfo * getMemberSpecializationInfo() const
If this class is an instantiation of a member class of a class template specialization,...
pack_iterator pack_begin() const
Iterator referencing the first argument of a template argument pack.
void ActOnFinishCXXNonNestedClass()
static std::string convertCallArgsToString(Sema &S, llvm::ArrayRef< const Expr * > Args)
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.
void pushFullCopy(TypeLoc L)
Pushes a copy of the given TypeLoc onto this builder.
int ArgumentPackSubstitutionIndex
The current index into pack expansion arguments that will be used for substitution of parameter packs...
Represents a reference to a non-type template parameter pack that has been substituted with a non-tem...
VarDecl * getParameterPack() const
Get the parameter pack which this expression refers to.
Encodes a location in the source.
@ ParameterMappingSubstitution
SourceLocation PointOfInstantiation
The point of instantiation or synthesis within the source code.
SourceLocation getLocation() const
This represents a decl that may have a name.
bool AttachTypeConstraint(NestedNameSpecifierLoc NS, DeclarationNameInfo NameInfo, ConceptDecl *NamedConcept, const TemplateArgumentListInfo *TemplateArgs, TemplateTypeParmDecl *ConstrainedParameter, SourceLocation EllipsisLoc)
Attach a type-constraint to a template parameter.
ClassTemplateDecl * getSpecializedTemplate() const
Retrieve the template that this specialization specializes.
NamedDecl * FindInstantiatedDecl(SourceLocation Loc, NamedDecl *D, const MultiLevelTemplateArgumentList &TemplateArgs, bool FindingInstantiatedContext=false)
Find the instantiation of the given declaration within the current instantiation.
TypeSourceInfo * getTypeSourceInfo(ASTContext &Context, QualType T)
Creates a TypeSourceInfo for the given type.
SourceRange getSourceRange() const LLVM_READONLY
SourceLocation tokens are not useful in isolation - they are low level value objects created/interpre...
ConceptDecl * getNamedConcept() const
CXXRecordDecl * getDefinition() const
A (possibly-)qualified type.
NonTypeTemplateParmDecl - Declares a non-type template parameter, e.g., "Size" in.
TemplateDecl * getAsTemplateDecl() const
Retrieve the underlying template declaration that this template name refers to, if known.
@ EST_None
no exception specification
Expr * getImmediatelyDeclaredConstraint() const
Get the immediately-declared constraint expression introduced by this type-constraint,...
ClassTemplateDecl * getInstantiatedFromMemberTemplate() const
ClassTemplatePartialSpecializationDecl * getMoreSpecializedPartialSpecialization(ClassTemplatePartialSpecializationDecl *PS1, ClassTemplatePartialSpecializationDecl *PS2, SourceLocation Loc)
Returns the more specialized class template partial specialization according to the rules of partial ...
Represents a member of a struct/union/class.
void setBraceRange(SourceRange R)
C++2a [expr.prim.req]: A requires-expression provides a concise way to express requirements on templa...
Expr * getInClassInitializer() const
Get the C++11 default member initializer for this member, or null if one has not been set.
The collection of all-type qualifiers we support.
SmallVectorImpl< std::pair< VarTemplateDecl *, VarTemplatePartialSpecializationDecl * > >::iterator delayed_var_partial_spec_iterator
Represents a parameter to a function.
SemaDiagnosticBuilder Diag(SourceLocation Loc, unsigned DiagID, bool DeferHint=false)
Emit a diagnostic.
SubstitutionDiagnostic * getSubstitutionDiagnostic() const
SmallVector< CodeSynthesisContext, 16 > CodeSynthesisContexts
List of active code synthesis contexts.
@ Declaration
The template argument is a declaration that was provided for a pointer, reference,...
void setInstantiationOf(ClassTemplatePartialSpecializationDecl *PartialSpec, const TemplateArgumentList *TemplateArgs)
Note that this class template specialization is actually an instantiation of the given class template...
bool containsUnexpandedParameterPack() const
Whether this type is or contains an unexpanded parameter pack, used to support C++0x variadic templat...
QualType getExpansionType(unsigned I) const
Retrieve a particular expansion type within an expanded parameter pack.
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.
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...
void PrintInstantiationStack()
Prints the current instantiation stack through a series of notes.
SourceLocation getEndLoc() const
Get the end source location.
void ActOnFields(Scope *S, SourceLocation RecLoc, Decl *TagDecl, ArrayRef< Decl * > Fields, SourceLocation LBrac, SourceLocation RBrac, const ParsedAttributesView &AttrList)
void CheckCompletedCXXClass(Scope *S, CXXRecordDecl *Record)
Perform semantic checks on a class definition that has been completing, introducing implicitly-declar...
void ActOnFinishCXXInClassMemberInitializer(Decl *VarDecl, SourceLocation EqualLoc, Expr *Init)
This is invoked after parsing an in-class initializer for a non-static C++ class member,...
SourceLocation getNameLoc() const
bool isNull() const
Determine whether this template argument has no value.
static ActionResult< CXXRecordDecl * > getPatternForClassTemplateSpecialization(Sema &S, SourceLocation PointOfInstantiation, ClassTemplateSpecializationDecl *ClassTemplateSpec, TemplateSpecializationKind TSK)
Get the instantiation pattern to use to instantiate the definition of a given ClassTemplateSpecializa...
void printTemplateArgumentList(raw_ostream &OS, ArrayRef< TemplateArgument > Args, const PrintingPolicy &Policy, const TemplateParameterList *TPL=nullptr)
Print a template argument list, including the '<' and '>' enclosing the template arguments.
static void deleteScopes(LocalInstantiationScope *Scope, LocalInstantiationScope *Outermost)
deletes the given scope, and all otuer scopes, down to the given outermost scope.
std::vector< std::unique_ptr< TemplateInstantiationCallback > > TemplateInstCallbacks
The template instantiation callbacks to trace or track instantiations (objects can be chained).
Represents a C++ nested-name-specifier or a global scope specifier.
QualType getPointeeTypeAsWritten() const
unsigned LastEmittedCodeSynthesisContextDepth
The depth of the context stack at the point when the most recent error or warning was produced.
void disableLateAttributeInstantiation()
static FunctionParmPackExpr * Create(const ASTContext &Context, QualType T, VarDecl *ParamPack, SourceLocation NameLoc, ArrayRef< VarDecl * > Params)
void print(llvm::raw_ostream &OS, const Pointer &P, ASTContext &Ctx, QualType Ty)
void setLocStart(SourceLocation L)
virtual void getNameForDiagnostic(raw_ostream &OS, const PrintingPolicy &Policy, bool Qualified) const
Appends a human-readable name for this declaration into the given stream.
FunctionType - C99 6.7.5.3 - Function Declarators.
TemplateName getNameToSubstitute() const
Get the template name to substitute when this template name is used as a template template argument.
Expr * getAsExpr() const
Retrieve the template argument as an expression.
The name of a declaration.
TranslationUnitDecl * getTranslationUnitDecl() const
ExprResult BuildExpressionFromIntegralTemplateArgument(const TemplateArgument &Arg, SourceLocation Loc)
Construct a new expression that refers to the given integral template argument with the given source-...
@ Expression
The template argument is an expression, and we've not resolved it to one of the other forms yet,...
llvm::ArrayRef< TemplateArgumentLoc > arguments() const
SmallVector< Module *, 16 > CodeSynthesisContextLookupModules
Extra modules inspected when performing a lookup during a template instantiation.
void setTemplateSpecializationKind(TemplateSpecializationKind TSK, SourceLocation PointOfInstantiation=SourceLocation())
For an enumeration member that was instantiated from a member enumeration of a templated class,...
bool isAlreadyInstantiating() const
Determine whether we are already instantiating this specialization in some surrounding active instant...
IdentKind getIdentKind() const
SynthesisKind
The kind of template instantiation we are performing.
const TemplateTypeParmType * getReplacedParameter() const
Gets the template parameter that was substituted for.
RAII class used to determine whether SFINAE has trapped any errors that occur during template argumen...
void MarkVirtualMembersReferenced(SourceLocation Loc, const CXXRecordDecl *RD, bool ConstexprOnly=false)
MarkVirtualMembersReferenced - Will mark all members of the given CXXRecordDecl referenced.
SourceLocation getBeginLoc() const
Get the begin source location.
@ DefaultTemplateArgumentInstantiation
We are instantiating a default argument for a template parameter.
const LangOptions & getLangOpts() const
llvm::FoldingSetVector< ClassTemplatePartialSpecializationDecl > & getPartialSpecializations() const
Retrieve the set of partial specializations of this class template.
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...
Represents a reference to a function parameter pack or init-capture pack that has been substituted bu...
void setTagKind(TagKind TK)
@ NullPtr
The template argument is a null pointer or null pointer to member that was provided for a non-type te...
void setScopeInfo(unsigned scopeDepth, unsigned parameterIndex)
DeclContext * getLexicalDeclContext()
getLexicalDeclContext - The declaration context where this Decl was lexically declared (LexicalDC).
TemplateName SubstTemplateName(NestedNameSpecifierLoc QualifierLoc, TemplateName Name, SourceLocation Loc, const MultiLevelTemplateArgumentList &TemplateArgs)
bool isParameterPack() const
Determine whether this variable is actually a function parameter pack or init-capture pack.
const TemplateArgument * TemplateArgs
The list of template arguments we are substituting, if they are not part of the entity.
Declaration of a template function.
Expr * getConstraintExpr() const
CXXRecordDecl * getInstantiatedFromMemberClass() const
If this record is an instantiation of a member class, retrieves the member class from which it was in...
TyLocType push(QualType T)
Pushes space for a new TypeLoc of the given type.
bool isReferenceType() const
@ TSK_ExplicitInstantiationDeclaration
This template specialization was instantiated from a template due to an explicit instantiation declar...
QualType getPattern() const
Retrieve the pattern of this pack expansion, which is the type that will be repeatedly instantiated w...
unsigned NonInstantiationEntries
The number of CodeSynthesisContexts that are not template instantiations and, therefore,...
ExprResult BuildCXXDefaultArgExpr(SourceLocation CallLoc, FunctionDecl *FD, ParmVarDecl *Param)
BuildCXXDefaultArgExpr - Creates a CXXDefaultArgExpr, instantiating the default expr if needed.
const ASTTemplateArgumentListInfo * getTemplateArgsAsWritten() const
MultiLevelTemplateArgumentList getTemplateInstantiationArgs(const 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...
Represents a type that was referred to using an elaborated type keyword, e.g., struct S,...
bool isTypeDependent() const
Determines whether the type of this expression depends on.
NamedDecl * Template
The template (or partial specialization) in which we are performing the instantiation,...
static TagTypeKind getTagTypeKindForKeyword(ElaboratedTypeKeyword Keyword)
Converts an elaborated type keyword into a TagTypeKind.
VarDecl * getInstantiatedFromStaticDataMember() const
If this variable is an instantiated static data member of a class template specialization,...
ArgKind getKind() const
Return the kind of stored template argument.
bool AttachBaseSpecifiers(CXXRecordDecl *Class, MutableArrayRef< CXXBaseSpecifier * > Bases)
Performs the actual work of attaching the given base class specifiers to a C++ class.
@ ExceptionSpecInstantiation
We are instantiating the exception specification for a function template which was deferred until it ...
Wrapper for substituted template type parameters.
Describes a module or submodule.
const TemplateArgumentList & getTemplateArgs() const
Retrieve the template arguments of the class template specialization.
NamedDecl * getParam(unsigned Idx)
Represents a pack expansion of types.
bool isInstantiationRecord() const
Determines whether this template is an actual instantiation that should be counted toward the maximum...
std::pair< SourceLocation, PartialDiagnostic > PartialDiagnosticAt
A partial diagnostic along with the source location where this diagnostic occurs.
DiagnosticsEngine & getDiagnostics() const
A convenient class for passing around template argument information.
RAII object used to change the argument pack substitution index within a Sema object.
QualType getNonLValueExprType(const ASTContext &Context) const
Determine the type of a (typically non-lvalue) expression with the specified result type.
static DeclAccessPair make(NamedDecl *D, AccessSpecifier AS)
void printPretty(raw_ostream &OS, PrinterHelper *Helper, const PrintingPolicy &Policy, unsigned Indentation=0, StringRef NewlineSymbol="\n", const ASTContext *Context=nullptr) const
TagTypeKind
The kind of a tag type.
void UpdateExceptionSpec(FunctionDecl *FD, const FunctionProtoType::ExceptionSpecInfo &ESI)
void ActOnFinishDelayedMemberInitializers(Decl *Record)
bool hasFatalErrorOccurred() const
unsigned getNumExpansions() const
Get the number of parameters in this parameter pack.
unsigned getIndex() const
Holds information about the various types of exception specification.
bool hasUncompilableErrorOccurred() const
Whether uncompilable error has occurred.
NonTypeTemplateParmDecl * getParameterPack() const
Retrieve the non-type template parameter pack being substituted.
A C++ lambda expression, which produces a function object (of unspecified type) that can be invoked l...
Scope - A scope is a transient data structure that is used while parsing the program.
bool isComparison() const
MatchFinder::MatchResult MatchResult
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...
Expr * getReplacement() const
@ TemplateInstantiation
We are instantiating a template declaration.
std::deque< PendingImplicitInstantiation > PendingLocalImplicitInstantiations
The queue of implicit template instantiations that are required and must be performed within the curr...
Represents a GCC generic vector type.
MemberSpecializationInfo * getMemberSpecializationInfo() const
If this variable is an instantiation of a static data member of a class template specialization,...
bool isStaticDataMember() const
Determines whether this is a static data member.
@ RequirementInstantiation
We are instantiating a requirement of a requires expression.
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
void InstantiateAttrs(const MultiLevelTemplateArgumentList &TemplateArgs, const Decl *Pattern, Decl *Inst, LateInstantiatedAttrVec *LateAttrs=nullptr, LocalInstantiationScope *OuterMostScope=nullptr)
Represents an array type, per C99 6.7.5.2 - Array Declarators.
QualType getPointeeType() const
static const Decl * getCanonicalParmVarDecl(const Decl *D)
EnumDecl * getDefinition() const
A requires-expression requirement which is satisfied when a general constraint expression is satisfie...
const T * getAs() const
Member-template getAs<specific type>'.
unsigned getNumBases() const
Retrieves the number of base classes of this class.
bool isInvalidDecl() const
void set(DeclAccessPair Found, Decl *Spec, DeductionFailureInfo Info)
bool SubstTemplateArguments(ArrayRef< TemplateArgumentLoc > Args, const MultiLevelTemplateArgumentList &TemplateArgs, TemplateArgumentListInfo &Outputs)
Attr * instantiateTemplateAttribute(const Attr *At, ASTContext &C, Sema &S, const MultiLevelTemplateArgumentList &TemplateArgs)
Represents a template argument.
void atTemplateEnd(TemplateInstantiationCallbackPtrs &Callbacks, const Sema &TheSema, const Sema::CodeSynthesisContext &Inst)
void setTemplateSpecializationKind(TemplateSpecializationKind TSK)
Set the template specialization kind.
A static requirement that can be used in a requires-expression to check properties of types and expre...
Attr * instantiateTemplateAttributeForDecl(const Attr *At, ASTContext &C, Sema &S, const MultiLevelTemplateArgumentList &TemplateArgs)
Data structure that captures multiple levels of template argument lists for use in template instantia...
@ DeducedTemplateArgumentSubstitution
We are substituting template argument determined as part of template argument deduction for either a ...
DiagnosticsEngine & Diags
bool hasUnparsedDefaultArg() const
Determines whether this parameter has a default argument that has not yet been parsed.
virtual Decl * getCanonicalDecl()
Retrieves the "canonical" declaration of the given declaration.
MemberSpecializationInfo * getMemberSpecializationInfo() const
If this enumeration is an instantiation of a member enumeration of a class template specialization,...
Sugar type that represents a type that was qualified by a qualifier written as a macro invocation.
bool isInvalid() const
Determines whether we have exceeded the maximum recursive template instantiations.
void InstantiateClassTemplateSpecializationMembers(SourceLocation PointOfInstantiation, ClassTemplateSpecializationDecl *ClassTemplateSpec, TemplateSpecializationKind TSK)
Instantiate the definitions of all of the members of the given class template specialization,...
TemplateSpecCandidateSet - A set of generalized overload candidates, used in template specializations...
bool hasInClassInitializer() const
Determine whether this member has a C++11 default member initializer.
A context in which code is being synthesized (where a source location alone is not sufficient to iden...
TemplateTemplateParmDecl - Declares a template template parameter, e.g., "T" in.
DefaultedFunctionKind getDefaultedFunctionKind(const FunctionDecl *FD)
Determine the kind of defaulting that would be done for a given function.
void setLAngleLoc(SourceLocation Loc)
ExprResult SubstExpr(Expr *E, const MultiLevelTemplateArgumentList &TemplateArgs)
void setUninstantiatedDefaultArg(Expr *arg)
Represents a variable declaration or definition.
void atTemplateBegin(TemplateInstantiationCallbackPtrs &Callbacks, const Sema &TheSema, const Sema::CodeSynthesisContext &Inst)
@ NestedRequirementConstraintsCheck
We are checking the satisfaction of a nested requirement of a requires expression.
static TemplateArgument getPackSubstitutedTemplateArgument(Sema &S, TemplateArgument Arg)
Represents the declaration of a struct/union/class/enum.
Stores a list of template parameters for a TemplateDecl and its derived classes.
@ TSK_ExplicitInstantiationDefinition
This template specialization was instantiated from a template due to an explicit instantiation defini...
QualType getUnderlyingType() const
unsigned getNumLevels() const
Determine the number of levels in this template argument list.
void setVisibleDespiteOwningModule()
Set that this declaration is globally visible, even if it came from a module that is not visible.
bool isVariablyModifiedType() const
Whether this type is a variably-modified type (C99 6.7.5).
TemplateDeductionResult DeduceTemplateArguments(ClassTemplatePartialSpecializationDecl *Partial, const TemplateArgumentList &TemplateArgs, sema::TemplateDeductionInfo &Info)
Perform template argument deduction to determine whether the given template arguments match the given...
A C++ nested-name-specifier augmented with source location information.
bool isPackExpansion() const
Determine whether this template argument is a pack expansion.
A structure for storing an already-substituted template template parameter pack.
A default argument (C++ [dcl.fct.default]).
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.
bool isSubstitutionFailure() const
llvm::DenseSet< std::pair< Decl *, unsigned > > InstantiatingSpecializations
Specializations whose definitions are currently being instantiated.
ASTMutationListener * getASTMutationListener() const
Declaration of a template type parameter.
unsigned getFunctionScopeDepth() const
llvm::PointerUnion< ClassTemplateDecl *, ClassTemplatePartialSpecializationDecl * > getSpecializedTemplateOrPartial() const
Retrieve the class template or class template partial specialization which was specialized by this.
Represents a type which was implicitly adjusted by the semantic engine for arbitrary reasons.
SourceLocation getTemplateLoc() const
bool isNull() const
Determine whether this template name is NULL.
bool isImplicit() const
isImplicit - Indicates whether the declaration was implicitly generated by the implementation.
SourceLocation getPointOfInstantiation() const
Retrieve the first point of instantiation of this member.
void reserve(size_t Requested)
Ensures that this buffer has at least as much capacity as described.
virtual bool HandleTopLevelDecl(DeclGroupRef D)
HandleTopLevelDecl - Handle the specified top-level declaration.
TemplateParameterList * getTemplateParameters() const
Get the list of template parameters.
bool isSpecialMember() const
@ ETK_None
No keyword precedes the qualified type name.
DeclarationName getName() const
getName - Returns the embedded declaration name.
bool isGenericLambdaCallOperatorOrStaticInvokerSpecialization(const DeclContext *DC)
@ ExplicitTemplateArgumentSubstitution
We are substituting explicit template arguments provided for a function template.
void setHasInheritedDefaultArg(bool I=true)
bool InstantiateInClassInitializer(SourceLocation PointOfInstantiation, FieldDecl *Instantiation, FieldDecl *Pattern, const MultiLevelTemplateArgumentList &TemplateArgs)
Instantiate the definition of a field from the given pattern.
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...
@ VK_LValue
An l-value expression is a reference to an object with independent storage.
Expr * getUninstantiatedDefaultArg()
InstantiatingTemplate(Sema &SemaRef, SourceLocation PointOfInstantiation, Decl *Entity, SourceRange InstantiationRange=SourceRange())
Note that we are instantiating a class template, function template, variable template,...
QualifiedTemplateName * getAsQualifiedTemplateName() const
Retrieve the underlying qualified template name structure, if any.
bool CheckLoopHintExpr(Expr *E, SourceLocation Loc)
delayed_var_partial_spec_iterator delayed_var_partial_spec_end()
const llvm::Triple & getTriple() const
Returns the target triple of the primary target.
delayed_partial_spec_iterator delayed_partial_spec_begin()
Return an iterator to the beginning of the set of "delayed" partial specializations,...
void setLocation(SourceLocation L)
Represents a C++ struct/union/class.
void MarkVTableUsed(SourceLocation Loc, CXXRecordDecl *Class, bool DefinitionRequired=false)
Note that the vtable for the given class was used at the given location.
@ Memoization
Added for Template instantiation observation.
EnumDecl * getInstantiatedFromMemberEnum() const
Returns the enumeration (declared within the template) from which this enumeration type was instantia...
@ DefaultFunctionArgumentInstantiation
We are instantiating a default argument for a function.
void SetParamDefaultArgument(ParmVarDecl *Param, Expr *DefaultArg, SourceLocation EqualLoc)
bool hasSFINAEDiagnostic() const
Is a SFINAE diagnostic available?
@ EST_Uninstantiated
not instantiated yet
Wrapper for substituted template type parameters.
TemplateDeductionResult
Describes the result of template argument deduction.
bool isDependentType() const
Whether this type is a dependent type, meaning that its definition somehow depends on a template para...
llvm::DenseSet< Module * > LookupModulesCache
Cache of additional modules that should be used for name lookup within the current template instantia...
bool isInstantiationDependentType() const
Determine whether this type is an instantiation-dependent type, meaning that the type involves a temp...
@ VK_PRValue
A pr-value expression (in the C++11 taxonomy) produces a temporary value.
TemplateSpecializationKind
Describes the kind of template specialization that a particular template specialization declaration r...
For a defaulted function, the kind of defaulted function that it is.
void startDefinition()
Starts the definition of this tag declaration.
Decl * getPreviousDecl()
Retrieve the previous declaration that declares the same entity as this declaration,...
NamedDecl * getPartiallySubstitutedPack(const TemplateArgument **ExplicitArgs=nullptr, unsigned *NumExplicitArgs=nullptr) const
Retrieve the partially-substitued template parameter pack.
unsigned getFullDataSize() const
Returns the size of the type source info data block.
NamedDecl * getAsNamedDecl(TemplateParameter P)
bool hasTemplateArgument(unsigned Depth, unsigned Index) const
Determine whether there is a non-NULL template argument at the given depth and index.
Represents a C++11 static_assert declaration.
StmtResult SubstStmt(Stmt *S, const MultiLevelTemplateArgumentList &TemplateArgs)
SourceLocation getLocation() const
A requires-expression requirement which queries the existence of a type name or type template special...
A helper class for building up ExtParameterInfos.
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...
QualType getNamedType() const
Retrieve the type named by the qualified-id.
IdentifierInfo * getIdentifier() const
Get the identifier that names this declaration, if there is one.
SourceLocation LAngleLoc
The source location of the left angle bracket ('<').
Declaration of a class template.
Represent the declaration of a variable (in which case it is an lvalue) a function (in which case it ...
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.
Represents a C++ template name within the type system.
StorageClass getStorageClass() const
Returns the storage class as written in the source.
@ DeclaringSpecialMember
We are declaring an implicit special member function.
NonTypeTemplateParmDecl * getParameter() const
QualType getTagDeclType(const TagDecl *Decl) const
Return the unique reference to the type for the specified TagDecl (struct/union/class/enum) decl.
Represents a prototype with parameter type info, e.g.
SourceLocation getExprLoc() const LLVM_READONLY
getExprLoc - Return the preferred location for the arrow when diagnosing a problem with a generic exp...
const clang::PrintingPolicy & getPrintingPolicy() const
T getAs() const
Convert to the specified TypeLoc type, returning a null TypeLoc if this TypeLoc is not of the desired...
The base class of all kinds of template declarations (e.g., class, function, etc.).
bool isExpandedParameterPack() const
Whether this parameter is a non-type template parameter pack that has a known list of different types...
QualType getPointeeType() const
void InstantiateEnumDefinition(EnumDecl *Enum, EnumDecl *Pattern)
VarDecl * getDefinition(ASTContext &)
Get the real (not just tentative) definition for this declaration.
bool isNull() const
Return true if this QualType doesn't point to a type yet.
VarDecl *const * iterator
Iterators over the parameters which the parameter pack expanded into.
Decl - This represents one declaration (or definition), e.g.
PrettyDeclStackTraceEntry - If a crash occurs in the parser while parsing something related to a decl...
RAII object that enters a new expression evaluation context.
unsigned getFunctionScopeIndex() const
Returns the index of this parameter in its prototype or method scope.
void PerformDependentDiagnostics(const DeclContext *Pattern, const MultiLevelTemplateArgumentList &TemplateArgs)
Base wrapper for a particular "section" of type source info.
Interesting information about a specific parameter that can't simply be reflected in parameter's type...
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...
RecordDecl * getOuterLexicalRecordContext()
Retrieve the outermost lexically enclosing record context.
void popCodeSynthesisContext()
Sema - This implements semantic analysis and AST building for C.
QualType getElementType() const
QualType getType() const
Get the type for which this source info wrapper provides information.
unsigned getDepth() const
Get the nesting depth of the template parameter.
ExprResult SubstInitializer(Expr *E, const MultiLevelTemplateArgumentList &TemplateArgs, bool CXXDirectInit)
CXXRecordDecl * getTemplatedDecl() const
Get the underlying class declarations of the template.
@ TSK_ExplicitSpecialization
This template specialization was declared or defined by an explicit specialization (C++ [temp....
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...
SourceLocation getLocation() const
Returns the location at which template argument is occurring.
TypeSourceInfo * getType() const
@ DefaultTemplateArgumentChecking
We are checking the validity of a default template argument that has been used when naming a template...
Wrapper for template type parameters.
SourceRange InstantiationRange
The source range that covers the construct that cause the instantiation, e.g., the template-id that c...
A template argument list.
bool isFileContext() const
LocalInstantiationScope * CurrentInstantiationScope
The current instantiation scope used to store local variables.
Provides information about an attempted template argument deduction, whose success or failure was des...
One of these records is kept for each identifier that is lexed.
const TargetInfo & getTargetInfo() const
bool InstantiateEnum(SourceLocation PointOfInstantiation, EnumDecl *Instantiation, EnumDecl *Pattern, const MultiLevelTemplateArgumentList &TemplateArgs, TemplateSpecializationKind TSK)
Instantiate the definition of an enum from a given pattern.
InClassInitStyle getInClassInitStyle() const
Get the kind of (C++11) default member initializer that this field has.
unsigned getNewDepth(unsigned OldDepth) const
Determine how many of the OldDepth outermost template parameter lists would be removed by substitutin...
llvm::PointerUnion< VarTemplateDecl *, VarTemplatePartialSpecializationDecl * > getSpecializedTemplateOrPartial() const
Retrieve the variable template or variable template partial specialization which was specialized by t...
A stack object to be created when performing template instantiation.
bool isParameterPack() const
Returns whether this is a parameter pack.
A pointer to member type per C++ 8.3.3 - Pointers to members.
@ ConstraintNormalization
SourceLocation getParameterPackLocation() const
Retrieve the location of the parameter pack name.
SourceRange getSourceRange() const LLVM_READONLY
ActionResult - This structure is used while parsing/acting on expressions, stmts, etc.
const FunctionDecl * isLocalClass() const
If the class is a local class [class.local], returns the enclosing function declaration.
@ DeclaringImplicitEqualityComparison
We are declaring an implicit 'operator==' for a defaulted 'operator<=>'.
ExceptionSpecificationType Type
The kind of exception specification this is.
void setTemplateSpecializationKind(TemplateSpecializationKind TSK)
Set the kind of specialization or template instantiation this is.
ExceptionSpecInfo ExceptionSpec
void SetPartiallySubstitutedPack(NamedDecl *Pack, const TemplateArgument *ExplicitArgs, unsigned NumExplicitArgs)
Note that the given parameter pack has been partially substituted via explicit specification of templ...
@ ConstantEvaluated
The current context is "potentially evaluated" in C++11 terms, but the expression is evaluated at com...
TypeLoc IgnoreParens() const
void collectUnexpandedParameterPacks(TemplateArgument Arg, SmallVectorImpl< UnexpandedParameterPack > &Unexpanded)
Collect the set of unexpanded parameter packs within the given template argument.
@ ExceptionSpecEvaluation
We are computing the exception specification for a defaulted special member function.
[C99 6.4.2.2] - A predefined identifier such as func.
PointerType - C99 6.7.5.1 - Pointer Declarators.
bool SavedInNonInstantiationSFINAEContext
Was the enclosing context a non-instantiation SFINAE context?
bool InNonInstantiationSFINAEContext
Whether we are in a SFINAE context that is not associated with template instantiation.
unsigned getNumSubstitutedLevels() const
Determine the number of substituted levels in this template argument list.
@ InitializingStructuredBinding
We are initializing a structured binding.
bool isParameterPack() const
Whether this declaration is a parameter pack.
ParmVarDecl * CheckParameter(DeclContext *DC, SourceLocation StartLoc, SourceLocation NameLoc, IdentifierInfo *Name, QualType T, TypeSourceInfo *TSInfo, StorageClass SC)
@ Type
The template argument is a type.
unsigned getDepth() const
bool usesPartialOrExplicitSpecialization(SourceLocation Loc, ClassTemplateSpecializationDecl *ClassTemplateSpec)
const RecordDecl * getParent() const
Returns the parent of this field declaration, which is the struct in which this field is defined.
TemplateSpecializationKind getTemplateSpecializationKind() const
Determine whether this particular class is a specialization or instantiation of a class template or m...
SourceLocation getUsedLocation() const
Retrieve the location where this default argument was actually used.
void setRAngleLoc(SourceLocation Loc)
lookup_result lookup(DeclarationName Name) const
lookup - Find the declarations (if any) with the given Name in this context.
QualType getElementType() const
TemplateArgument getPackExpansionPattern() const
When the template argument is a pack expansion, returns the pattern of the pack expansion.
VarDecl * getExpansion(unsigned I) const
Get an expansion of the parameter pack by index.
void takeSFINAEDiagnostic(PartialDiagnosticAt &PD)
Take ownership of the SFINAE diagnostic.
@ Template
The template argument is a template name that was provided for a template template parameter.
bool isParameterPack() const
Whether this parameter is a non-type template parameter pack.
Stmt - This represents one statement.
TemplateName getAsTemplate() const
Retrieve the template name for a template name argument.
TemplateSpecCandidate & addCandidate()
Add a new candidate with NumConversions conversion sequence slots to the overload set.
__DEVICE__ _Tp arg(const std::complex< _Tp > &__c)
CXXRecordDecl * getCanonicalDecl() override
Retrieves the "canonical" declaration of the given declaration.
bool hasUninstantiatedDefaultArg() const
Information about one declarator, including the parsed type information and the identifier.
Represents a base class of a C++ class.
const ParmVarDecl * getParam() const
Attr - This represents one attribute.
A container of type source information.
QualType getReturnType() const
VarTemplatePartialSpecializationDecl * InstantiateVarTemplatePartialSpecialization(VarTemplateDecl *VarTemplate, VarTemplatePartialSpecializationDecl *PartialSpec)
Instantiate the declaration of a variable template partial specialization.
A stack-allocated class that identifies which local variable declaration instantiations are present i...
DeclarationName getDeclName() const
Get the actual, stored name of the declaration, which may be a special name.
NestedNameSpecifierLoc SubstNestedNameSpecifierLoc(NestedNameSpecifierLoc NNS, const MultiLevelTemplateArgumentList &TemplateArgs)
void ActOnStartCXXInClassMemberInitializer()
Enter a new C++ default initializer scope.
virtual void printName(raw_ostream &os) const
Pretty-print the unqualified name of this declaration.
bool CheckFunctionConstraints(const FunctionDecl *FD, ConstraintSatisfaction &Satisfaction, SourceLocation UsageLoc=SourceLocation())
Check whether the given function decl's trailing requires clause is satisfied, if any.
SourceLocation getBeginLoc() const LLVM_READONLY
@ BuildingBuiltinDumpStructCall
We are building an implied call from __builtin_dump_struct.
Optional< sema::TemplateDeductionInfo * > isSFINAEContext() const
Determines whether we are currently in a context where template argument substitution failures are no...
SourceLocation getNoexceptLoc() const
@ RewritingOperatorAsSpaceship
We are rewriting a comparison operator in terms of an operator<=>.
void InstantiatedLocalPackArg(const Decl *D, VarDecl *Inst)
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.
SmallVectorImpl< std::pair< ClassTemplateDecl *, ClassTemplatePartialSpecializationDecl * > >::iterator delayed_partial_spec_iterator
ExprResult ConvertParamDefaultArgument(ParmVarDecl *Param, Expr *DefaultArg, SourceLocation EqualLoc)
bool isDefinedOutsideFunctionOrMethod() const
isDefinedOutsideFunctionOrMethod - This predicate returns true if this scoped decl is defined outside...
The results of name lookup within a DeclContext.
void setNameLoc(SourceLocation Loc)
SourceRange getSourceRange() const LLVM_READONLY
Get the full source range.
The result of a constraint satisfaction check, containing the necessary information to diagnose an un...
const NestedNameSpecifierLoc & getNestedNameSpecifierLoc() const
const Type * getTypePtr() const
Retrieves a pointer to the underlying (unqualified) type.
CXXBaseSpecifier * CheckBaseSpecifier(CXXRecordDecl *Class, SourceRange SpecifierRange, bool Virtual, AccessSpecifier Access, TypeSourceInfo *TInfo, SourceLocation EllipsisLoc)
ActOnBaseSpecifier - Parsed a base specifier.
const TypeClass * getTypePtr() const
@ ETK_Typename
The "typename" keyword precedes the qualified type name, e.g., typename T::type.
ClassTemplatePartialSpecializationDecl * InstantiateClassTemplatePartialSpecialization(ClassTemplateDecl *ClassTemplate, ClassTemplatePartialSpecializationDecl *PartialSpec)
Instantiate the declaration of a class template partial specialization.
Base for LValueReferenceType and RValueReferenceType.
DefaultedComparisonKind asComparison() const
QualType getPointeeType() const
const DeclarationNameInfo & getConceptNameInfo() const
unsigned getTemplateBacktraceLimit() const
Retrieve the maximum number of template instantiation notes to emit along with a given diagnostic.
void setInvalidDecl(bool Invalid=true)
setInvalidDecl - Indicates the Decl had a semantic error.
unsigned pack_size() const
The number of template arguments in the given template argument pack.
bool isRewrite() const
Determine whether we are rewriting template parameters rather than substituting for them.
bool InstantiateClassTemplateSpecialization(SourceLocation PointOfInstantiation, ClassTemplateSpecializationDecl *ClassTemplateSpec, TemplateSpecializationKind TSK, bool Complain=true)
bool hasSameType(QualType T1, QualType T2) const
Determine whether the given types T1 and T2 are equivalent.
LocalInstantiationScope * getStartingScope() const
Represents an explicit template argument list in C++, e.g., the "<int>" in "sort<int>".
T castAs() const
Convert to the specified TypeLoc type, asserting that this TypeLoc is of the desired type.
TemplateArgument getArgumentPack() const
Retrieve the template argument pack containing the substituted template arguments.
bool SubstTypeConstraint(TemplateTypeParmDecl *Inst, const TypeConstraint *TC, const MultiLevelTemplateArgumentList &TemplateArgs)
unsigned getPosition() const
Get the position of the template parameter within its parameter list.
TemplateSpecializationKind getTemplateSpecializationKind() const
Determine what kind of template specialization this is.
SourceLocation getBeginLoc() const
Retrieve the location of the beginning of this nested-name-specifier.
PrintingPolicy getPrintingPolicy() const
Retrieve a suitable printing policy for diagnostics.
Declaration of a variable template.
QualType getElementType() const
bool isMemberSpecialization() const
Determines whether this template was a specialization of a member template.
This represents one expression.
Decl * Entity
The entity that is being synthesized.
std::pair< unsigned, unsigned > getDepthAndIndex(NamedDecl *ND)
Retrieve the depth and index of a template parameter.
bool isParameterPack() const
A requires-expression requirement which queries the validity and properties of an expression ('simple...
SourceLocation getParameterPackLocation() const
Get the location of the parameter pack.
bool isSubstitutionFailure() const
CXXSpecialMember asSpecialMember() const
void SubstExceptionSpec(FunctionDecl *New, const FunctionProtoType *Proto, const MultiLevelTemplateArgumentList &Args)
@ TSK_ImplicitInstantiation
This template specialization was implicitly instantiated from a template.
void addConst()
Add the const type qualifier to this QualType.
ExtProtoInfo getExtProtoInfo() const
SourceLocation getLoc() const
getLoc - Returns the main location of the declaration name.
TypeSourceInfo * CheckPackExpansion(TypeSourceInfo *Pattern, SourceLocation EllipsisLoc, Optional< unsigned > NumExpansions)
Construct a pack expansion type from the pattern of the pack expansion.
DeclarationNameInfo - A collector data type for bundling together a DeclarationName and the correspnd...
Represents a class template specialization, which refers to a class template with a given set of temp...
bool isInLocalScopeForInstantiation() const
Determine whether a substitution into this declaration would occur as part of a substitution into a d...
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...
bool isLocalPackExpansion(const Decl *D)
Determine whether D is a pack expansion created in this scope.
bool isExprSubstitutionFailure() const
Represents an extended vector type where either the type or size is dependent.
QualType getModifiedType() const
SourceLocation getLocation() const
const CXXRecordDecl * getTemplateInstantiationPattern() const
Retrieve the record declaration from which this record could be instantiated.
enum clang::Sema::CodeSynthesisContext::SynthesisKind Kind
A reference to a declared variable, function, enum, etc.
Represents a function declaration or definition.
SourceLocation RAngleLoc
The source location of the right angle bracket ('>').
Represents a struct/union/class.
llvm::PointerUnion< TemplateTypeParmDecl *, NonTypeTemplateParmDecl *, TemplateTemplateParmDecl * > TemplateParameter
Stores a template parameter of any kind.
void setPointOfInstantiation(SourceLocation POI)
Set the first point of instantiation.
QualType getParameterType(const ASTContext &Ctx) const
Determine the substituted type of the template parameter.
@ PriorTemplateArgumentSubstitution
We are substituting prior template arguments into a new template parameter.
@ DefiningSynthesizedFunction
We are defining a synthesized function (such as a defaulted special member).
sema::TemplateDeductionInfo * DeductionInfo
The template deduction info object associated with the substitution or checking of explicit or deduce...
QualType getOriginalType() const
void MakeInstantiatedLocalArgPack(const Decl *D)
TypeSourceInfo * getTypeSourceInfo() const
static FixItHint CreateReplacement(CharSourceRange RemoveRange, StringRef Code)
Create a code modification hint that replaces the given source range with the given code string.
bool hasInheritedDefaultArg() const
@ MarkingClassDllexported
We are marking a class as __dllexport.
bool SubstBaseSpecifiers(CXXRecordDecl *Instantiation, CXXRecordDecl *Pattern, const MultiLevelTemplateArgumentList &TemplateArgs)
Perform substitution on the base class specifiers of the given class template specialization.
Sugar for parentheses used when specifying types.
std::string getTemplateArgumentBindingsText(const TemplateParameterList *Params, const TemplateArgumentList &Args)
Produces a formatted string that describes the binding of template parameters to template arguments.
const ReturnTypeRequirement & getReturnTypeRequirement() const
llvm::PointerUnion< Decl *, DeclArgumentPack * > * findInstantiationOf(const Decl *D)
Find the instantiation of the declaration D within the current instantiation scope.
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 ...
QualType getAsType() const
Retrieve the type for a type template argument.
DiagnosticBuilder Report(SourceLocation Loc, unsigned DiagID)
Issue the message to the client.
TypeLoc getTypeLoc() const
Return the TypeLoc wrapper for the type source info.
@ Pack
The template argument is actually a parameter pack.
void Clear()
Note that we have finished instantiating this template.
Represents a static or instance method of a struct/union/class.
ParmVarDecl * SubstParmVarDecl(ParmVarDecl *D, const MultiLevelTemplateArgumentList &TemplateArgs, int indexAdjustment, Optional< unsigned > NumExpansions, bool ExpectParameterPack)
DeclContext * getDeclContext()
@ PotentiallyEvaluated
The current expression is potentially evaluated at run time, which means that code may be generated t...
void enableLateAttributeInstantiation(Sema::LateInstantiatedAttrVec *LA)
StringRef getName() const
Get the name of identifier for this declaration as a StringRef.
void InstantiatedLocal(const Decl *D, Decl *Inst)