38#include "llvm/ADT/StringExtras.h"
39#include "llvm/Support/ErrorHandling.h"
40#include "llvm/Support/SaveAndRestore.h"
41#include "llvm/Support/TimeProfiler.h"
54 const Decl *NextDecl =
nullptr;
56 bool ClearRelativeToPrimary =
true;
57 static Response Done() {
62 static Response ChangeDecl(
const Decl *ND) {
67 static Response ChangeDecl(
const DeclContext *Ctx) {
73 static Response UseNextDecl(
const Decl *CurDecl) {
77 static Response DontClearRelativeToPrimaryNextDecl(
const Decl *CurDecl) {
78 Response R = Response::UseNextDecl(CurDecl);
79 R.ClearRelativeToPrimary =
false;
88getPrimaryTemplateOfGenericLambda(
const FunctionDecl *LambdaCallOperator) {
90 return LambdaCallOperator;
92 if (
auto *FTD = dyn_cast_if_present<FunctionTemplateDecl>(
94 FTD && FTD->getInstantiatedFromMemberTemplate()) {
96 FTD->getInstantiatedFromMemberTemplate()->getTemplatedDecl();
102 }
else if (
auto *Prev = cast<CXXMethodDecl>(LambdaCallOperator)
103 ->getInstantiatedFromMemberFunction())
104 LambdaCallOperator = Prev;
108 return LambdaCallOperator;
111struct EnclosingTypeAliasTemplateDetails {
121EnclosingTypeAliasTemplateDetails
122getEnclosingTypeAliasTemplateDecl(
Sema &SemaRef) {
125 TypeAliasTemplateInstantiation)
127 EnclosingTypeAliasTemplateDetails Result;
128 auto *TATD = cast<TypeAliasTemplateDecl>(CSC.Entity),
129 *Next = TATD->getInstantiatedFromMemberTemplate();
133 CSC.template_arguments(),
136 Result.PrimaryTypeAliasDecl = Next;
137 Next = Next->getInstantiatedFromMemberTemplate();
150bool isLambdaEnclosedByTypeAliasDecl(
154 Visitor(
const FunctionDecl *CallOperator) : CallOperator(CallOperator) {}
155 bool VisitLambdaExpr(
LambdaExpr *LE)
override {
158 return getPrimaryTemplateOfGenericLambda(LE->getCallOperator()) !=
167 return !Visitor(getPrimaryTemplateOfGenericLambda(LambdaCallOperator))
168 .TraverseType(Underlying);
175 bool SkipForSpecialization) {
179 return Response::DontClearRelativeToPrimaryNextDecl(VarTemplSpec);
183 !isa<VarTemplatePartialSpecializationDecl>(VarTemplSpec))
184 return Response::Done();
189 llvm::PointerUnion<VarTemplateDecl *, VarTemplatePartialSpecializationDecl *>
192 dyn_cast<VarTemplatePartialSpecializationDecl *>(Specialized)) {
193 if (!SkipForSpecialization)
194 Result.addOuterTemplateArguments(
197 if (Partial->isMemberSpecialization())
198 return Response::Done();
201 if (!SkipForSpecialization)
202 Result.addOuterTemplateArguments(
206 return Response::Done();
208 return Response::DontClearRelativeToPrimaryNextDecl(VarTemplSpec);
220 for (
unsigned I = 0, N = TTP->
getDepth() + 1; I != N; ++I)
221 Result.addOuterTemplateArguments(std::nullopt);
222 return Response::Done();
225Response HandlePartialClassTemplateSpec(
228 if (!SkipForSpecialization)
230 return Response::Done();
237 bool SkipForSpecialization) {
241 !isa<ClassTemplatePartialSpecializationDecl>(ClassTemplSpec))
242 return Response::Done();
244 if (!SkipForSpecialization)
245 Result.addOuterTemplateArguments(
254 return Response::Done();
260 if (
auto *InstFromPartialTempl =
263 return Response::ChangeDecl(
264 InstFromPartialTempl->getLexicalDeclContext());
266 return Response::UseNextDecl(ClassTemplSpec);
272 bool ForConstraintInstantiation,
273 bool ForDefaultArgumentSubstitution) {
275 if (!RelativeToPrimary &&
276 Function->getTemplateSpecializationKindForInstantiation() ==
278 return Response::Done();
280 if (!RelativeToPrimary &&
285 return Response::UseNextDecl(
Function);
287 Function->getTemplateSpecializationArgs()) {
290 TemplateArgs->asArray(),
293 if (RelativeToPrimary &&
294 (
Function->getTemplateSpecializationKind() ==
297 !
Function->getPrimaryTemplate()->getFriendObjectKind())))
298 return Response::UseNextDecl(
Function);
302 assert(
Function->getPrimaryTemplate() &&
"No function template?");
303 if (!ForDefaultArgumentSubstitution &&
304 Function->getPrimaryTemplate()->isMemberSpecialization())
305 return Response::Done();
308 if (!ForConstraintInstantiation &&
310 return Response::Done();
314 (ForConstraintInstantiation || Result.getNumSubstitutedLevels() == 0) &&
315 "Outer template not instantiated?");
316 if (ForConstraintInstantiation) {
324 Result.addOuterTemplateArguments(
Template, Inst.template_arguments(),
336 Function->getNonTransparentDeclContext()->isFileContext() &&
338 return Response::ChangeDecl(
Function->getLexicalDeclContext());
341 if (ForConstraintInstantiation &&
Function->getFriendObjectKind())
342 return Response::ChangeDecl(
Function->getLexicalDeclContext());
343 return Response::UseNextDecl(
Function);
346Response HandleFunctionTemplateDecl(
Sema &SemaRef,
349 if (!isa<ClassTemplateSpecializationDecl>(FTD->
getDeclContext())) {
350 Result.addOuterTemplateArguments(
358 for (
const Type *Ty = NNS.
getKind() == NestedNameSpecifier::Kind::Type
363 Ty = std::exchange(NextTy,
nullptr)) {
365 P.getKind() == NestedNameSpecifier::Kind::Type)
366 NextTy =
P.getAsType();
367 const auto *TSTy = dyn_cast<TemplateSpecializationType>(Ty);
389 if (TSTy->isCurrentInstantiation()) {
390 auto *RD = TSTy->getCanonicalTypeInternal()->getAsCXXRecordDecl();
392 Arguments = CTD->getInjectedTemplateArgs(SemaRef.
Context);
394 dyn_cast<ClassTemplateSpecializationDecl>(RD))
395 Arguments =
Specialization->getTemplateInstantiationArgs().asArray();
397 Result.addOuterTemplateArguments(
398 TSTy->getTemplateName().getAsTemplateDecl(), Arguments,
409 bool ForConstraintInstantiation) {
412 (ForConstraintInstantiation || Result.getNumSubstitutedLevels() == 0) &&
413 "Outer template not instantiated?");
414 if (ClassTemplate->isMemberSpecialization())
415 return Response::Done();
416 if (ForConstraintInstantiation)
417 Result.addOuterTemplateArguments(
419 ClassTemplate->getInjectedTemplateArgs(SemaRef.
Context),
426 return Response::Done();
431 if (ForConstraintInstantiation && IsFriend &&
440 return Response::ChangeDecl(LCD);
444 if (
auto TypeAlias = getEnclosingTypeAliasTemplateDecl(SemaRef);
445 ForConstraintInstantiation &&
TypeAlias) {
448 Result.addOuterTemplateArguments(
TypeAlias.Template,
464 return Response::ChangeDecl(
TypeAlias.Template->getDeclContext());
469 return Response::UseNextDecl(Rec);
472Response HandleImplicitConceptSpecializationDecl(
475 Result.addOuterTemplateArguments(
479 return Response::UseNextDecl(CSD);
482Response HandleGenericDeclContext(
const Decl *CurDecl) {
483 return Response::UseNextDecl(CurDecl);
491 const FunctionDecl *Pattern,
bool ForConstraintInstantiation,
492 bool SkipForSpecialization,
bool ForDefaultArgumentSubstitution) {
493 assert((ND || DC) &&
"Can't find arguments for a decl if one isn't provided");
498 const Decl *CurDecl = ND;
501 Result.addOuterTemplateArguments(
const_cast<NamedDecl *
>(ND), *Innermost,
511 if (
const auto *TTP = dyn_cast<TemplateTemplateParmDecl>(CurDecl))
512 HandleDefaultTempArgIntoTempTempParam(TTP,
Result);
514 : Response::UseNextDecl(CurDecl).NextDecl;
520 if (
const auto *VarTemplSpec =
521 dyn_cast<VarTemplateSpecializationDecl>(CurDecl)) {
522 R = HandleVarTemplateSpec(VarTemplSpec,
Result, SkipForSpecialization);
523 }
else if (
const auto *PartialClassTemplSpec =
524 dyn_cast<ClassTemplatePartialSpecializationDecl>(CurDecl)) {
525 R = HandlePartialClassTemplateSpec(PartialClassTemplSpec,
Result,
526 SkipForSpecialization);
527 }
else if (
const auto *ClassTemplSpec =
528 dyn_cast<ClassTemplateSpecializationDecl>(CurDecl)) {
529 R = HandleClassTemplateSpec(ClassTemplSpec,
Result,
530 SkipForSpecialization);
531 }
else if (
const auto *
Function = dyn_cast<FunctionDecl>(CurDecl)) {
532 R = HandleFunction(*
this,
Function,
Result, Pattern, RelativeToPrimary,
533 ForConstraintInstantiation,
534 ForDefaultArgumentSubstitution);
535 }
else if (
const auto *Rec = dyn_cast<CXXRecordDecl>(CurDecl)) {
537 ForConstraintInstantiation);
538 }
else if (
const auto *CSD =
539 dyn_cast<ImplicitConceptSpecializationDecl>(CurDecl)) {
540 R = HandleImplicitConceptSpecializationDecl(CSD,
Result);
541 }
else if (
const auto *FTD = dyn_cast<FunctionTemplateDecl>(CurDecl)) {
542 R = HandleFunctionTemplateDecl(*
this, FTD,
Result);
543 }
else if (
const auto *CTD = dyn_cast<ClassTemplateDecl>(CurDecl)) {
544 R = Response::ChangeDecl(CTD->getLexicalDeclContext());
545 }
else if (!isa<DeclContext>(CurDecl)) {
546 R = Response::DontClearRelativeToPrimaryNextDecl(CurDecl);
547 if (
const auto *TTP = dyn_cast<TemplateTemplateParmDecl>(CurDecl)) {
548 R = HandleDefaultTempArgIntoTempTempParam(TTP,
Result);
551 R = HandleGenericDeclContext(CurDecl);
556 if (R.ClearRelativeToPrimary)
557 RelativeToPrimary =
false;
559 CurDecl = R.NextDecl;
602 llvm_unreachable(
"Invalid SynthesisKind!");
630 Inst.InConstraintSubstitution =
633 Inst.InConstraintSubstitution |=
638 AlreadyInstantiating = !Inst.Entity ?
false :
640 .insert({Inst.Entity->getCanonicalDecl(), Inst.Kind})
651 PointOfInstantiation, InstantiationRange, Entity) {}
658 PointOfInstantiation, InstantiationRange, Entity) {}
678 TemplateArgs, &DeductionInfo) {
692 PointOfInstantiation, InstantiationRange,
Template, nullptr,
693 TemplateArgs, &DeductionInfo) {}
703 PointOfInstantiation, InstantiationRange, PartialSpec, nullptr,
704 TemplateArgs, &DeductionInfo) {}
714 PointOfInstantiation, InstantiationRange, PartialSpec, nullptr,
715 TemplateArgs, &DeductionInfo) {}
723 PointOfInstantiation, InstantiationRange, Param, nullptr,
733 PointOfInstantiation, InstantiationRange, Param,
Template,
743 PointOfInstantiation, InstantiationRange, Param,
Template,
752 PointOfInstantiation, InstantiationRange, Entity,
753 nullptr, TemplateArgs) {}
761 PointOfInstantiation, InstantiationRange, Param,
Template,
770 PointOfInstantiation, InstantiationRange, nullptr,
771 nullptr, {}, &DeductionInfo) {}
779 PointOfInstantiation, InstantiationRange, nullptr,
787 PointOfInstantiation, InstantiationRange, nullptr,
788 nullptr, {}, &DeductionInfo) {}
796 PointOfInstantiation, InstantiationRange,
Template, nullptr,
805 PointOfInstantiation, InstantiationRange,
Template, nullptr,
806 {}, &DeductionInfo) {}
814 PointOfInstantiation, InstantiationRange,
Template) {}
822 PointOfInstantiation, InstantiationRange,
Template) {}
829 PointOfInstantiation, InstantiationRange, Entity) {}
835 ArgLoc, InstantiationRange, PArg) {}
843 if (!Ctx.isInstantiationRecord())
853 if (!Active.isInstantiationRecord()) {
863 "forgot to remove a lookup module for a template instantiation");
882 if (!AlreadyInstantiating) {
886 {Active.Entity->getCanonicalDecl(), Active.Kind});
900 llvm::raw_string_ostream
OS(
Result);
901 llvm::ListSeparator Comma;
902 for (
const Expr *Arg : Args) {
904 Arg->IgnoreParens()->printPretty(
OS,
nullptr,
910bool Sema::InstantiatingTemplate::CheckInstantiationDepth(
921 diag::err_template_recursion_depth_exceeded)
923 << InstantiationRange;
924 SemaRef.
Diag(PointOfInstantiation, diag::note_template_recursion_depth)
934 SkipStart = Limit / 2 + Limit % 2;
939 unsigned InstantiationIdx = 0;
944 ++Active, ++InstantiationIdx) {
946 if (InstantiationIdx >= SkipStart && InstantiationIdx < SkipEnd) {
947 if (InstantiationIdx == SkipStart) {
949 DiagFunc(Active->PointOfInstantiation,
950 PDiag(diag::note_instantiation_contexts_suppressed)
956 switch (Active->Kind) {
958 Decl *
D = Active->Entity;
960 unsigned DiagID = diag::note_template_member_class_here;
961 if (isa<ClassTemplateSpecializationDecl>(
Record))
962 DiagID = diag::note_template_class_instantiation_here;
963 DiagFunc(Active->PointOfInstantiation,
964 PDiag(DiagID) <<
Record << Active->InstantiationRange);
968 DiagID = diag::note_function_template_spec_here;
970 DiagID = diag::note_template_member_function_here;
971 DiagFunc(Active->PointOfInstantiation,
973 }
else if (
VarDecl *VD = dyn_cast<VarDecl>(
D)) {
974 DiagFunc(Active->PointOfInstantiation,
975 PDiag(VD->isStaticDataMember()
976 ? diag::note_template_static_data_member_def_here
977 : diag::note_template_variable_def_here)
978 << VD << Active->InstantiationRange);
979 }
else if (
EnumDecl *ED = dyn_cast<EnumDecl>(
D)) {
980 DiagFunc(Active->PointOfInstantiation,
981 PDiag(diag::note_template_enum_def_here)
982 << ED << Active->InstantiationRange);
983 }
else if (
FieldDecl *FD = dyn_cast<FieldDecl>(
D)) {
984 DiagFunc(Active->PointOfInstantiation,
985 PDiag(diag::note_template_nsdmi_here)
986 << FD << Active->InstantiationRange);
988 DiagFunc(Active->PointOfInstantiation,
989 PDiag(diag::note_template_class_instantiation_here)
990 << CTD << Active->InstantiationRange);
998 llvm::raw_svector_ostream
OS(TemplateArgsStr);
1002 DiagFunc(Active->PointOfInstantiation,
1003 PDiag(diag::note_default_arg_instantiation_here)
1004 <<
OS.str() << Active->InstantiationRange);
1010 DiagFunc(Active->PointOfInstantiation,
1011 PDiag(diag::note_explicit_template_arg_substitution_here)
1015 Active->NumTemplateArgs)
1016 << Active->InstantiationRange);
1022 dyn_cast<FunctionTemplateDecl>(Active->Entity)) {
1024 Active->PointOfInstantiation,
1025 PDiag(diag::note_function_template_deduction_instantiation_here)
1028 FnTmpl->getTemplateParameters(), Active->TemplateArgs,
1029 Active->NumTemplateArgs)
1030 << Active->InstantiationRange);
1032 bool IsVar = isa<VarTemplateDecl>(Active->Entity) ||
1033 isa<VarTemplateSpecializationDecl>(Active->Entity);
1034 bool IsTemplate =
false;
1036 if (
auto *
D = dyn_cast<TemplateDecl>(Active->Entity)) {
1038 Params =
D->getTemplateParameters();
1039 }
else if (
auto *
D = dyn_cast<ClassTemplatePartialSpecializationDecl>(
1041 Params =
D->getTemplateParameters();
1042 }
else if (
auto *
D = dyn_cast<VarTemplatePartialSpecializationDecl>(
1044 Params =
D->getTemplateParameters();
1046 llvm_unreachable(
"unexpected template kind");
1049 DiagFunc(Active->PointOfInstantiation,
1050 PDiag(diag::note_deduced_template_arg_substitution_here)
1051 << IsVar << IsTemplate << cast<NamedDecl>(Active->Entity)
1053 Active->TemplateArgs,
1054 Active->NumTemplateArgs)
1055 << Active->InstantiationRange);
1061 ParmVarDecl *Param = cast<ParmVarDecl>(Active->Entity);
1065 llvm::raw_svector_ostream
OS(TemplateArgsStr);
1069 DiagFunc(Active->PointOfInstantiation,
1070 PDiag(diag::note_default_function_arg_instantiation_here)
1071 <<
OS.str() << Active->InstantiationRange);
1076 NamedDecl *Parm = cast<NamedDecl>(Active->Entity);
1079 Name = std::string(
" '") + Parm->
getName().str() +
"'";
1083 TemplateParams =
Template->getTemplateParameters();
1086 cast<ClassTemplatePartialSpecializationDecl>(Active->Template)
1087 ->getTemplateParameters();
1088 DiagFunc(Active->PointOfInstantiation,
1089 PDiag(diag::note_prior_template_arg_substitution)
1090 << isa<TemplateTemplateParmDecl>(Parm) << Name
1092 Active->TemplateArgs,
1093 Active->NumTemplateArgs)
1094 << Active->InstantiationRange);
1101 TemplateParams =
Template->getTemplateParameters();
1104 cast<ClassTemplatePartialSpecializationDecl>(Active->Template)
1105 ->getTemplateParameters();
1107 DiagFunc(Active->PointOfInstantiation,
1108 PDiag(diag::note_template_default_arg_checking)
1110 Active->TemplateArgs,
1111 Active->NumTemplateArgs)
1112 << Active->InstantiationRange);
1117 DiagFunc(Active->PointOfInstantiation,
1118 PDiag(diag::note_evaluating_exception_spec_here)
1119 << cast<FunctionDecl>(Active->Entity));
1123 DiagFunc(Active->PointOfInstantiation,
1124 PDiag(diag::note_template_exception_spec_instantiation_here)
1125 << cast<FunctionDecl>(Active->Entity)
1126 << Active->InstantiationRange);
1130 DiagFunc(Active->PointOfInstantiation,
1131 PDiag(diag::note_template_requirement_instantiation_here)
1132 << Active->InstantiationRange);
1135 DiagFunc(Active->PointOfInstantiation,
1136 PDiag(diag::note_template_requirement_params_instantiation_here)
1137 << Active->InstantiationRange);
1141 DiagFunc(Active->PointOfInstantiation,
1142 PDiag(diag::note_nested_requirement_here)
1143 << Active->InstantiationRange);
1147 DiagFunc(Active->PointOfInstantiation,
1148 PDiag(diag::note_in_declaration_of_implicit_special_member)
1149 << cast<CXXRecordDecl>(Active->Entity)
1150 << Active->SpecialMember);
1155 Active->Entity->getLocation(),
1156 PDiag(diag::note_in_declaration_of_implicit_equality_comparison));
1162 auto *FD = dyn_cast<FunctionDecl>(Active->Entity);
1169 auto *MD = cast<CXXMethodDecl>(FD);
1170 DiagFunc(Active->PointOfInstantiation,
1171 PDiag(diag::note_member_synthesized_at)
1177 .getNonReferenceType()
1178 .getUnqualifiedType();
1179 DiagFunc(Active->PointOfInstantiation,
1180 PDiag(diag::note_comparison_synthesized_at)
1187 DiagFunc(Active->Entity->getLocation(),
1188 PDiag(diag::note_rewriting_operator_as_spaceship));
1192 DiagFunc(Active->PointOfInstantiation,
1193 PDiag(diag::note_in_binding_decl_init)
1194 << cast<BindingDecl>(Active->Entity));
1198 DiagFunc(Active->PointOfInstantiation,
1199 PDiag(diag::note_due_to_dllexported_class)
1200 << cast<CXXRecordDecl>(Active->Entity)
1205 DiagFunc(Active->PointOfInstantiation,
1206 PDiag(diag::note_building_builtin_dump_struct_call)
1209 Active->NumCallArgs)));
1216 DiagFunc(Active->PointOfInstantiation,
1217 PDiag(diag::note_lambda_substitution_here));
1220 unsigned DiagID = 0;
1221 if (!Active->Entity) {
1222 DiagFunc(Active->PointOfInstantiation,
1223 PDiag(diag::note_nested_requirement_here)
1224 << Active->InstantiationRange);
1227 if (isa<ConceptDecl>(Active->Entity))
1228 DiagID = diag::note_concept_specialization_here;
1229 else if (isa<TemplateDecl>(Active->Entity))
1230 DiagID = diag::note_checking_constraints_for_template_id_here;
1231 else if (isa<VarTemplatePartialSpecializationDecl>(Active->Entity))
1232 DiagID = diag::note_checking_constraints_for_var_spec_id_here;
1233 else if (isa<ClassTemplatePartialSpecializationDecl>(Active->Entity))
1234 DiagID = diag::note_checking_constraints_for_class_spec_id_here;
1236 assert(isa<FunctionDecl>(Active->Entity));
1237 DiagID = diag::note_checking_constraints_for_function_here;
1240 llvm::raw_svector_ostream
OS(TemplateArgsStr);
1242 if (!isa<FunctionDecl>(Active->Entity)) {
1246 DiagFunc(Active->PointOfInstantiation,
1247 PDiag(DiagID) <<
OS.str() << Active->InstantiationRange);
1251 DiagFunc(Active->PointOfInstantiation,
1252 PDiag(diag::note_constraint_substitution_here)
1253 << Active->InstantiationRange);
1256 DiagFunc(Active->PointOfInstantiation,
1257 PDiag(diag::note_constraint_normalization_here)
1258 << cast<NamedDecl>(Active->Entity)
1259 << Active->InstantiationRange);
1262 DiagFunc(Active->PointOfInstantiation,
1263 PDiag(diag::note_parameter_mapping_substitution_here)
1264 << Active->InstantiationRange);
1267 DiagFunc(Active->PointOfInstantiation,
1268 PDiag(diag::note_building_deduction_guide_here));
1271 DiagFunc(Active->PointOfInstantiation,
1272 PDiag(diag::note_template_type_alias_instantiation_here)
1273 << cast<TypeAliasTemplateDecl>(Active->Entity)
1274 << Active->InstantiationRange);
1277 DiagFunc(Active->PointOfInstantiation,
1278 PDiag(diag::note_template_arg_template_params_mismatch));
1281 DiagFunc(ParamLoc,
PDiag(diag::note_template_prev_declaration)
1283 << Active->InstantiationRange);
1291 return std::optional<TemplateDeductionInfo *>(
nullptr);
1296 Active != ActiveEnd;
1299 switch (Active->Kind) {
1303 if (isa<TypeAliasTemplateDecl>(Active->Entity))
1314 return std::nullopt;
1321 return std::nullopt;
1343 assert(Active->DeductionInfo &&
"Missing deduction info pointer");
1344 return Active->DeductionInfo;
1355 return std::nullopt;
1369 if (Active->SavedInNonInstantiationSFINAEContext)
1370 return std::optional<TemplateDeductionInfo *>(
nullptr);
1373 return std::nullopt;
1390 class TemplateInstantiator :
public TreeTransform<TemplateInstantiator> {
1395 bool EvaluateConstraints =
true;
1398 bool IsIncomplete =
false;
1400 bool BailOutOnIncomplete;
1406 bool maybeInstantiateFunctionParameterToScope(
ParmVarDecl *OldParm);
1411 TemplateInstantiator(
Sema &SemaRef,
1414 bool BailOutOnIncomplete =
false)
1415 : inherited(SemaRef), TemplateArgs(TemplateArgs),
Loc(
Loc),
1416 Entity(Entity), BailOutOnIncomplete(BailOutOnIncomplete) {}
1418 void setEvaluateConstraints(
bool B) {
1419 EvaluateConstraints = B;
1421 bool getEvaluateConstraints() {
1422 return EvaluateConstraints;
1439 bool getIsIncomplete()
const {
return IsIncomplete; }
1445 this->Entity = Entity;
1448 unsigned TransformTemplateDepth(
unsigned Depth) {
1455 return std::nullopt;
1462 bool FailOnPackProducingTemplates,
1463 bool &ShouldExpand,
bool &RetainExpansion,
1469 if (
auto *PVD = dyn_cast_if_present<ParmVarDecl>(VD);
1470 PVD && maybeInstantiateFunctionParameterToScope(PVD))
1475 return getSema().CheckParameterPacksForExpansion(
1476 EllipsisLoc, PatternRange, Unexpanded, TemplateArgs,
1477 FailOnPackProducingTemplates, ShouldExpand, RetainExpansion,
1481 void ExpandingFunctionParameterPack(
ParmVarDecl *Pack) {
1491 unsigned Depth, Index;
1494 Result = TemplateArgs(Depth, Index);
1497 IsIncomplete =
true;
1498 if (BailOutOnIncomplete)
1514 unsigned Depth, Index;
1542 "unexpected pack arguments in template rewrite");
1559 (NewDecls.size() != 1 || !NewDecls.front()->isParameterPack())) {
1561 for (
auto *
New : NewDecls)
1563 Old, cast<VarDecl>(
New));
1567 assert(NewDecls.size() == 1 &&
1568 "should only have multiple expansions for a pack");
1574 auto *NewMD = dyn_cast<CXXMethodDecl>(
New);
1576 auto *OldMD = dyn_cast<CXXMethodDecl>(Old);
1577 if (
auto *NewTD = NewMD->getDescribedFunctionTemplate())
1578 NewTD->setInstantiatedFromMemberTemplate(
1579 OldMD->getDescribedFunctionTemplate());
1581 NewMD->setInstantiationOfMemberFunction(OldMD,
1589 if (
auto *DC = dyn_cast<DeclContext>(Old);
1590 DC && DC->isDependentContext() && DC->isFunctionOrMethod())
1625 NamedDecl *FirstQualifierInScope =
nullptr,
1626 bool AllowInjectedClassName =
false);
1628 const AnnotateAttr *TransformAnnotateAttr(
const AnnotateAttr *AA);
1629 const CXXAssumeAttr *TransformCXXAssumeAttr(
const CXXAssumeAttr *AA);
1630 const LoopHintAttr *TransformLoopHintAttr(
const LoopHintAttr *LH);
1631 const NoInlineAttr *TransformStmtNoInlineAttr(
const Stmt *OrigS,
1633 const NoInlineAttr *A);
1634 const AlwaysInlineAttr *
1635 TransformStmtAlwaysInlineAttr(
const Stmt *OrigS,
const Stmt *InstS,
1636 const AlwaysInlineAttr *A);
1637 const CodeAlignAttr *TransformCodeAlignAttr(
const CodeAlignAttr *CA);
1638 const OpenACCRoutineDeclAttr *
1639 TransformOpenACCRoutineDeclAttr(
const OpenACCRoutineDeclAttr *A);
1646 ExprResult TransformSubstNonTypeTemplateParmPackExpr(
1648 ExprResult TransformSubstNonTypeTemplateParmExpr(
1665 return inherited::TransformFunctionProtoType(TLB, TL);
1669 auto Type = inherited::TransformTagType(TLB, TL);
1675 if (
const auto *ICNT = dyn_cast<InjectedClassNameType>(TL.
getTypePtr());
1678 Type = inherited::TransformType(
1679 ICNT->getOriginalDecl()->getCanonicalTemplateSpecializationType(
1689 bool Uneval =
false) {
1691 std::vector<TemplateArgument> TArgs;
1703 if (TransformTemplateArgument(Input, Output, Uneval))
1714 return inherited::TransformTemplateArgument(Input, Output, Uneval);
1717 using TreeTransform::TransformTemplateSpecializationType;
1722 if (!getSema().ArgPackSubstIndex || !
T->
isSugared() ||
1724 return TreeTransform::TransformTemplateSpecializationType(TLB, TL);
1749 return std::nullopt;
1751 return inherited::ComputeSizeOfPackExprWithoutSubstitution(PackArgs);
1754 template<
typename Fn>
1759 Fn TransformExceptionSpec);
1762 int indexAdjustment,
1764 bool ExpectParameterPack);
1766 using inherited::TransformTemplateTypeParmType;
1771 bool SuppressObjCLifetime);
1773 QualType BuildSubstTemplateTypeParmType(
1781 using inherited::TransformSubstTemplateTypeParmPackType;
1785 bool SuppressObjCLifetime);
1793 TemplateInstArgsHelpers::getEnclosingTypeAliasTemplateDecl(
1795 TypeAlias && TemplateInstArgsHelpers::isLambdaEnclosedByTypeAliasDecl(
1797 unsigned TypeAliasDeclDepth =
TypeAlias.Template->getTemplateDepth();
1799 return CXXRecordDecl::LambdaDependencyKind::LDK_AlwaysDependent;
1802 return CXXRecordDecl::LambdaDependencyKind::LDK_AlwaysDependent;
1804 return inherited::ComputeLambdaDependency(LSI);
1816 return inherited::TransformLambdaExpr(
E);
1822 return inherited::TransformBlockExpr(
E);
1829 assert(PVD &&
"null in a parameter list");
1830 if (!PVD->hasDefaultArg())
1832 Expr *UninstExpr = PVD->getUninstantiatedDefaultArg();
1843 PVD->setDefaultArg(ErrorResult.
get());
1846 return inherited::RebuildLambdaExpr(StartLoc, EndLoc, LSI);
1860 return inherited::TransformLambdaBody(
E, Body);
1865 ExprResult TransReq = inherited::TransformRequiresExpr(
E);
1868 assert(TransReq.
get() !=
E &&
1869 "Do not change value of isSatisfied for the existing expression. "
1870 "Create a new expression instead.");
1871 if (
E->getBody()->isDependentContext()) {
1877 if (Trap.hasErrorOccurred())
1883 bool TransformRequiresExprRequirements(
1886 bool SatisfactionDetermined =
false;
1889 if (!SatisfactionDetermined) {
1890 if (
auto *TypeReq = dyn_cast<concepts::TypeRequirement>(Req))
1891 TransReq = TransformTypeRequirement(TypeReq);
1892 else if (
auto *ExprReq = dyn_cast<concepts::ExprRequirement>(Req))
1893 TransReq = TransformExprRequirement(ExprReq);
1895 TransReq = TransformNestedRequirement(
1896 cast<concepts::NestedRequirement>(Req));
1905 SatisfactionDetermined =
true;
1908 Transformed.push_back(TransReq);
1915 if (!OrigTPL || !OrigTPL->
size())
return OrigTPL;
1919 Owner, TemplateArgs);
1920 DeclInstantiator.setEvaluateConstraints(EvaluateConstraints);
1921 return DeclInstantiator.SubstTemplateParams(OrigTPL);
1939 transformNonTypeTemplateParmRef(
Decl *AssociatedDecl,
const NamedDecl *parm,
1945bool TemplateInstantiator::AlreadyTransformed(
QualType T) {
1953 getSema().MarkDeclarationsReferencedInType(
Loc,
T);
1968 TTP->getPosition())) {
1969 IsIncomplete =
true;
1970 return BailOutOnIncomplete ? nullptr :
D;
1975 if (TTP->isParameterPack()) {
1977 "Missing argument pack");
1983 "Wrong kind of template template argument");
1984 return Template.getAsTemplateDecl();
1994 maybeInstantiateFunctionParameterToScope(PVD))
2000bool TemplateInstantiator::maybeInstantiateFunctionParameterToScope(
2006 return !TransformFunctionTypeParam(OldParm, 0,
2017 assert(!Unexpanded.empty() &&
"Pack expansion without parameter packs?");
2019 bool ShouldExpand =
false;
2020 bool RetainExpansion =
false;
2025 Pattern.getSourceRange(), Unexpanded,
2027 ShouldExpand, RetainExpansion, NumExpansions))
2030 assert(ShouldExpand && !RetainExpansion &&
2031 "Shouldn't preserve pack expansion when evaluating constraints");
2032 ExpandingFunctionParameterPack(OldParm);
2033 for (
unsigned I = 0; I != *NumExpansions; ++I) {
2035 if (!TransformFunctionTypeParam(OldParm, 0,
2044 Decl *Inst = getSema().SubstDecl(
D, getSema().
CurContext, TemplateArgs);
2048 getSema().CurrentInstantiationScope->InstantiatedLocal(
D, Inst);
2052bool TemplateInstantiator::TransformExceptionSpec(
2059 return inherited::TransformExceptionSpec(
Loc, ESI, Exceptions, Changed);
2063TemplateInstantiator::TransformFirstQualifierInScope(
NamedDecl *
D,
2077 "Missing argument pack");
2087 return cast_or_null<NamedDecl>(TransformDecl(
Loc,
D));
2090 return Tag->getOriginalDecl();
2093 getSema().Diag(
Loc, diag::err_nested_name_spec_non_tag) <<
T;
2098 return cast_or_null<NamedDecl>(TransformDecl(
Loc,
D));
2102TemplateInstantiator::RebuildExceptionDecl(
VarDecl *ExceptionDecl,
2108 StartLoc, NameLoc, Name);
2110 getSema().CurrentInstantiationScope->InstantiatedLocal(ExceptionDecl, Var);
2114VarDecl *TemplateInstantiator::RebuildObjCExceptionDecl(
VarDecl *ExceptionDecl,
2117 VarDecl *Var = inherited::RebuildObjCExceptionDecl(ExceptionDecl, TSInfo,
T);
2119 getSema().CurrentInstantiationScope->InstantiatedLocal(ExceptionDecl, Var);
2123TemplateName TemplateInstantiator::TransformTemplateName(
2126 NamedDecl *FirstQualifierInScope,
bool AllowInjectedClassName) {
2128 assert(!QualifierLoc &&
"Unexpected qualifier");
2130 dyn_cast<TemplateTemplateParmDecl>(Name.getAsTemplateDecl());
2137 TTP->getPosition())) {
2138 IsIncomplete =
true;
2147 Arg = getTemplateArgumentPackPatternForRewrite(Arg);
2149 "unexpected nontype template argument kind in template rewrite");
2153 auto [AssociatedDecl, Final] =
2158 "Missing argument pack");
2164 return getSema().Context.getSubstTemplateTemplateParmPack(
2165 Arg, AssociatedDecl, TTP->
getIndex(), Final);
2168 PackIndex = getPackIndex(Arg);
2173 assert(!
Template.isNull() &&
"Null template template argument");
2174 return getSema().Context.getSubstTemplateTemplateParm(
2180 = Name.getAsSubstTemplateTemplateParmPack()) {
2187 return getSema().Context.getSubstTemplateTemplateParm(
2188 Template, SubstPack->getAssociatedDecl(), SubstPack->getIndex(),
2189 getPackIndex(Pack), SubstPack->getFinal());
2192 return inherited::TransformTemplateName(
2193 QualifierLoc, TemplateKWLoc, Name, NameLoc, ObjectType,
2194 FirstQualifierInScope, AllowInjectedClassName);
2202 return getSema().BuildPredefinedExpr(
E->getLocation(),
E->getIdentKind());
2206TemplateInstantiator::TransformTemplateParmRefExpr(
DeclRefExpr *
E,
2214 IsIncomplete =
true;
2215 return BailOutOnIncomplete ?
ExprError() :
E;
2223 Arg = getTemplateArgumentPackPatternForRewrite(Arg);
2225 "unexpected nontype template argument kind in template rewrite");
2231 auto [AssociatedDecl, Final] =
2236 "Missing argument pack");
2253 E->getLocation(), Arg, AssociatedDecl, NTTP->
getPosition(), Final);
2255 PackIndex = getPackIndex(Arg);
2258 return transformNonTypeTemplateParmRef(AssociatedDecl, NTTP,
E->getLocation(),
2259 Arg, PackIndex, Final);
2263TemplateInstantiator::TransformAnnotateAttr(
const AnnotateAttr *AA) {
2265 for (
Expr *Arg : AA->args()) {
2266 ExprResult Res = getDerived().TransformExpr(Arg);
2268 Args.push_back(Res.
get());
2270 return AnnotateAttr::CreateImplicit(getSema().
Context, AA->getAnnotation(),
2271 Args.data(), Args.size(), AA->getRange());
2274const CXXAssumeAttr *
2275TemplateInstantiator::TransformCXXAssumeAttr(
const CXXAssumeAttr *AA) {
2276 ExprResult Res = getDerived().TransformExpr(AA->getAssumption());
2280 if (!(Res.
get()->
getDependence() & ExprDependence::TypeValueInstantiation)) {
2281 Res = getSema().BuildCXXAssumeExpr(Res.
get(), AA->getAttrName(),
2287 return CXXAssumeAttr::CreateImplicit(getSema().
Context, Res.
get(),
2292TemplateInstantiator::TransformLoopHintAttr(
const LoopHintAttr *LH) {
2293 Expr *TransformedExpr = getDerived().TransformExpr(LH->getValue()).get();
2295 if (TransformedExpr == LH->getValue())
2300 LH->getSemanticSpelling() ==
2301 LoopHintAttr::Pragma_unroll))
2304 LoopHintAttr::OptionType Option = LH->getOption();
2305 LoopHintAttr::LoopHintState State = LH->getState();
2307 llvm::APSInt ValueAPS =
2310 if (ValueAPS.isZero() || ValueAPS.isOne()) {
2311 Option = LoopHintAttr::Unroll;
2312 State = LoopHintAttr::Disable;
2317 return LoopHintAttr::CreateImplicit(getSema().
Context, Option, State,
2318 TransformedExpr, *LH);
2320const NoInlineAttr *TemplateInstantiator::TransformStmtNoInlineAttr(
2321 const Stmt *OrigS,
const Stmt *InstS,
const NoInlineAttr *A) {
2327const AlwaysInlineAttr *TemplateInstantiator::TransformStmtAlwaysInlineAttr(
2328 const Stmt *OrigS,
const Stmt *InstS,
const AlwaysInlineAttr *A) {
2335const CodeAlignAttr *
2336TemplateInstantiator::TransformCodeAlignAttr(
const CodeAlignAttr *CA) {
2337 Expr *TransformedExpr = getDerived().TransformExpr(CA->getAlignment()).get();
2338 return getSema().BuildCodeAlignAttr(*CA, TransformedExpr);
2340const OpenACCRoutineDeclAttr *
2341TemplateInstantiator::TransformOpenACCRoutineDeclAttr(
2342 const OpenACCRoutineDeclAttr *A) {
2343 llvm_unreachable(
"RoutineDecl should only be a declaration attribute, as it "
2344 "applies to a Function Decl (and a few places for VarDecl)");
2347ExprResult TemplateInstantiator::transformNonTypeTemplateParmRef(
2354 auto SubstParamType = [&] {
2355 if (
const auto *NTTP = dyn_cast<NonTypeTemplateParmDecl>(parm)) {
2362 T = cast<PackExpansionType>(
T)->getPattern();
2369 bool refParam =
false;
2375 Expr *argExpr =
arg.getAsExpr();
2380 QualType paramType = SubstParamType();
2395 VD = cast_or_null<ValueDecl>(
2401 QualType paramType =
arg.getNonTypeTemplateArgumentType();
2402 assert(!paramType.
isNull() &&
"type substitution failed for param type");
2403 assert(!paramType->
isDependentType() &&
"param type still dependent");
2407 QualType paramType =
arg.getNonTypeTemplateArgumentType();
2418 Expr *resultExpr = result.
get();
2427TemplateInstantiator::TransformSubstNonTypeTemplateParmPackExpr(
2436 return transformNonTypeTemplateParmRef(
2437 E->getAssociatedDecl(),
E->getParameterPack(),
2438 E->getParameterPackLocation(), Arg, getPackIndex(Pack),
E->getFinal());
2442TemplateInstantiator::TransformSubstNonTypeTemplateParmExpr(
2444 ExprResult SubstReplacement =
E->getReplacement();
2445 if (!isa<ConstantExpr>(SubstReplacement.
get()))
2446 SubstReplacement = TransformExpr(
E->getReplacement());
2475 SubstReplacement.
get(), SugaredConverted,
2480 return transformNonTypeTemplateParmRef(
2482 SugaredConverted,
E->getPackIndex(),
E->getFinal());
2488 return getSema().BuildDeclarationNameExpr(
CXXScopeSpec(), NameInfo, PD);
2499 return RebuildVarDeclRefExpr(VD,
E->
getExprLoc());
2509 Vars.reserve(
E->getNumExpansions());
2520 E->getParameterPackLocation(), Vars);
2521 getSema().MarkFunctionParmPackReferenced(PackExpr);
2526TemplateInstantiator::TransformFunctionParmPackRefExpr(
DeclRefExpr *
E,
2529 llvm::PointerUnion<Decl *, DeclArgumentPack *> *
Found
2530 = getSema().CurrentInstantiationScope->findInstantiationOf(PD);
2531 assert(
Found &&
"no instantiation for parameter pack");
2533 Decl *TransformedDecl;
2534 if (DeclArgumentPack *Pack = dyn_cast<DeclArgumentPack *>(*
Found)) {
2543 getSema().MarkFunctionParmPackReferenced(PackExpr);
2547 TransformedDecl = (*Pack)[*getSema().ArgPackSubstIndex];
2549 TransformedDecl = cast<Decl *>(*
Found);
2553 return RebuildVarDeclRefExpr(cast<ValueDecl>(TransformedDecl),
2558TemplateInstantiator::TransformDeclRefExpr(
DeclRefExpr *
E) {
2565 return TransformTemplateParmRefExpr(
E, NTTP);
2572 if (
VarDecl *PD = dyn_cast<VarDecl>(
D))
2574 return TransformFunctionParmPackRefExpr(
E, PD);
2576 return inherited::TransformDeclRefExpr(
E);
2579ExprResult TemplateInstantiator::TransformCXXDefaultArgExpr(
2581 assert(!cast<FunctionDecl>(
E->getParam()->getDeclContext())->
2582 getDescribedFunctionTemplate() &&
2583 "Default arg expressions are never formed in dependent cases.");
2585 E->getUsedLocation(), cast<FunctionDecl>(
E->getParam()->getDeclContext()),
2589template<
typename Fn>
2594 Fn TransformExceptionSpec) {
2603 std::optional<LocalInstantiationScope>
Scope;
2604 if (!Current || !Current->isLambdaOrBlock())
2607 return inherited::TransformFunctionProtoType(
2608 TLB, TL, ThisContext, ThisTypeQuals, TransformExceptionSpec);
2611ParmVarDecl *TemplateInstantiator::TransformFunctionTypeParam(
2613 bool ExpectParameterPack) {
2615 OldParm, TemplateArgs, indexAdjustment, NumExpansions,
2616 ExpectParameterPack, EvaluateConstraints);
2622QualType TemplateInstantiator::BuildSubstTemplateTypeParmType(
2630 if (SuppressObjCLifetime) {
2632 RQs = Replacement.getQualifiers();
2639 QualType Result = getSema().Context.getSubstTemplateTypeParmType(
2640 Replacement, AssociatedDecl, Index, PackIndex, Final);
2648TemplateInstantiator::TransformTemplateTypeParmType(
TypeLocBuilder &TLB,
2650 bool SuppressObjCLifetime) {
2661 IsIncomplete =
true;
2662 if (BailOutOnIncomplete)
2676 Arg = getTemplateArgumentPackPatternForRewrite(Arg);
2678 "unexpected nontype template argument kind in template rewrite");
2684 auto [AssociatedDecl, Final] =
2687 if (
T->isParameterPack()) {
2689 "Missing argument pack");
2695 QualType Result = getSema().Context.getSubstTemplateTypeParmPackType(
2696 AssociatedDecl,
T->getIndex(), Final, Arg);
2704 PackIndex = getPackIndex(Arg);
2709 "Template argument kind mismatch");
2711 return BuildSubstTemplateTypeParmType(TLB, SuppressObjCLifetime, Final,
2712 AssociatedDecl,
T->getIndex(),
2722 NewTTPDecl = cast_or_null<TemplateTypeParmDecl>(
2726 T->isParameterPack(), NewTTPDecl);
2732QualType TemplateInstantiator::TransformSubstTemplateTypeParmPackType(
2734 bool SuppressObjCLifetime) {
2737 Decl *NewReplaced = TransformDecl(TL.
getNameLoc(),
T->getAssociatedDecl());
2742 if (NewReplaced !=
T->getAssociatedDecl())
2743 Result = getSema().Context.getSubstTemplateTypeParmPackType(
2744 NewReplaced,
T->getIndex(),
T->getFinal(),
T->getArgumentPack());
2753 return BuildSubstTemplateTypeParmType(
2754 TLB, SuppressObjCLifetime,
T->getFinal(), NewReplaced,
T->getIndex(),
2758QualType TemplateInstantiator::TransformSubstBuiltinTemplatePackType(
2761 return TreeTransform::TransformSubstBuiltinTemplatePackType(TLB, TL);
2762 auto &
Sema = getSema();
2766 return Result.getAsType();
2779 ErrorLoc = PDA.first;
2784 llvm::raw_svector_ostream
OS(Entity);
2788 C.backupStr(Entity), ErrorLoc,
C.backupStr(Message)};
2794 llvm::raw_svector_ostream
OS(Entity);
2798 C.backupStr(Entity),
2799 Location, StringRef()};
2802ExprResult TemplateInstantiator::TransformRequiresTypeParams(
2816 if (getDerived().TransformFunctionTypeParams(
2817 KWLoc, Params,
nullptr,
nullptr, PTypes,
2818 &TransParams, PInfos, &ErrorIdx) ||
2819 Trap.hasErrorOccurred()) {
2825 SemaRef, Info, [&](llvm::raw_ostream &
OS) {
OS << *FailedDecl; })));
2826 return getDerived().RebuildRequiresExpr(KWLoc, Body, RE->
getLParenLoc(),
2828 TransReqs, RBraceLoc);
2839 if (AlwaysRebuild())
2840 return RebuildTypeRequirement(
2850 if (TypeInst.isInvalid())
2853 if (!TransType || Trap.hasErrorOccurred())
2855 [&] (llvm::raw_ostream&
OS) {
2858 return RebuildTypeRequirement(TransType);
2868 llvm::PointerUnion<Expr *, concepts::Requirement::SubstitutionDiagnostic *>
2877 if (ExprInst.isInvalid())
2880 if (!TransExprRes.
isInvalid() && !Trap.hasErrorOccurred() &&
2883 if (TransExprRes.
isInvalid() || Trap.hasErrorOccurred())
2888 TransExpr = TransExprRes.
get();
2891 std::optional<concepts::ExprRequirement::ReturnTypeRequirement> TransRetReq;
2893 if (RetReq.isEmpty())
2894 TransRetReq.emplace();
2895 else if (RetReq.isSubstitutionFailure())
2896 TransRetReq.emplace(RetReq.getSubstitutionDiagnostic());
2897 else if (RetReq.isTypeConstraint()) {
2899 RetReq.getTypeConstraintTemplateParameterList();
2903 if (TPLInst.isInvalid())
2906 if (!TPL || Trap.hasErrorOccurred())
2908 [&] (llvm::raw_ostream&
OS) {
2909 RetReq.getTypeConstraint()->getImmediatelyDeclaredConstraint()
2914 TransRetReq.emplace(TPL);
2917 assert(TransRetReq &&
"All code paths leading here must set TransRetReq");
2918 if (
Expr *
E = TransExpr.dyn_cast<
Expr *>())
2920 std::move(*TransRetReq));
2921 return RebuildExprRequirement(
2922 cast<concepts::Requirement::SubstitutionDiagnostic *>(TransExpr),
2927TemplateInstantiator::TransformNestedRequirement(
2932 if (AlwaysRebuild())
2941 if (!getEvaluateConstraints()) {
2943 if (TransConstraint.
isInvalid() || !TransConstraint.
get())
2963 if (ConstrInst.isInvalid())
2973 TransConstraint =
Result[0];
2974 assert(!Trap.hasErrorOccurred() &&
"Substitution failures must be handled "
2975 "by CheckConstraintSatisfaction.");
2981 if (TransConstraint.
isInvalid() || !TransConstraint.
get() ||
2984 llvm::raw_svector_ostream
OS(Entity);
2998 bool AllowDeducedTST) {
3000 "Cannot perform an instantiation without some context on the "
3001 "instantiation stack");
3007 TemplateInstantiator Instantiator(*
this, Args,
Loc, Entity);
3008 return AllowDeducedTST ? Instantiator.TransformTypeWithDeducedTST(
T)
3009 : Instantiator.TransformType(
T);
3017 "Cannot perform an instantiation without some context on the "
3018 "instantiation stack");
3032 TemplateInstantiator Instantiator(*
this, Args,
Loc, Entity);
3046 bool *IsIncompleteSubstitution) {
3048 "Cannot perform an instantiation without some context on the "
3049 "instantiation stack");
3056 TemplateInstantiator Instantiator(
3057 *
this, TemplateArgs,
Loc, Entity,
3058 IsIncompleteSubstitution !=
nullptr);
3059 QualType QT = Instantiator.TransformType(
T);
3060 if (IsIncompleteSubstitution && Instantiator.getIsIncomplete())
3061 *IsIncompleteSubstitution =
true;
3070 TypeLoc TL =
T->getTypeLoc().IgnoreParens();
3093 bool EvaluateConstraints) {
3095 "Cannot perform an instantiation without some context on the "
3096 "instantiation stack");
3101 TemplateInstantiator Instantiator(*
this, Args,
Loc, Entity);
3102 Instantiator.setEvaluateConstraints(EvaluateConstraints);
3118 Result = Instantiator.TransformFunctionProtoType(
3119 TLB, Proto, ThisContext, ThisTypeQuals,
3121 bool &Changed) {
return false; });
3123 Result = Instantiator.TransformType(TLB, TL);
3137 bool Changed =
false;
3139 return Instantiator.TransformExceptionSpec(
Loc, ESI, ExceptionStorage,
3150 ESI, ExceptionStorage, Args))
3159 struct GetContainedInventedTypeParmVisitor :
3160 public TypeVisitor<GetContainedInventedTypeParmVisitor,
3161 TemplateTypeParmDecl *> {
3162 using TypeVisitor<GetContainedInventedTypeParmVisitor,
3168 return Visit(
T.getTypePtr());
3173 if (!
T->getDecl() || !
T->getDecl()->isImplicit())
3175 return T->getDecl();
3190 return Visit(
T->getPointeeTypeAsWritten());
3198 return Visit(
T->getElementType());
3203 return Visit(
T->getElementType());
3207 return Visit(
T->getElementType());
3211 return VisitFunctionType(
T);
3219 return Visit(
T->getInnerType());
3223 return Visit(
T->getModifiedType());
3227 return Visit(
T->getUnderlyingType());
3231 return Visit(
T->getOriginalType());
3235 return Visit(
T->getPattern());
3244 bool EvaluateConstraints) {
3248 if (!EvaluateConstraints) {
3280 bool ExpectParameterPack,
bool EvaluateConstraint) {
3300 }
else if (ExpectParameterPack) {
3306 diag::err_function_parameter_pack_without_parameter_packs)
3330 GetContainedInventedTypeParmVisitor().Visit(OldDI->
getType())) {
3332 auto *Inst = cast_or_null<TemplateTypeParmDecl>(
3337 if (Inst && !Inst->getTypeConstraint()) {
3406 "Cannot perform an instantiation without some context on the "
3407 "instantiation stack");
3409 TemplateInstantiator Instantiator(*
this, TemplateArgs,
Loc,
3411 return Instantiator.TransformFunctionTypeParams(
3412 Loc, Params,
nullptr, ExtParamInfos, ParamTypes, OutParams, ParamInfos);
3430 Diag(Param->
getBeginLoc(), diag::err_recursive_default_argument) << FD;
3442 std::optional<LocalInstantiationScope> LIS;
3453 if (addInstantiatedParametersToScope(FD, PatternFD, *LIS, TemplateArgs))
3475 Result = InitSeq.Perform(*
this, Entity, Kind, ResultE);
3505 auto ComputeInfo = [&S, &TemplateArgs, BaseSourceRange, BaseEllipsisLoc](
3512 if (IsLateExpansionAttempt) {
3519 if (!SawPackTypes) {
3531 BaseEllipsisLoc, BaseSourceRange, Unexpanded, TemplateArgs,
3536 if (ComputeInfo(
Base.getTypeSourceInfo(),
false, Info))
3540 Out =
Base.getTypeSourceInfo();
3550 if (!Out->getType()->containsUnexpandedParameterPack())
3555 if (ComputeInfo(Out,
true, Info))
3568 for (
const auto &
Base : Pattern->
bases()) {
3569 if (!
Base.getType()->isDependentType()) {
3571 if (RD->isInvalidDecl())
3580 if (
Base.isPackExpansion()) {
3592 ArgsForSubst = &EmptyList;
3607 Instantiation,
Base.getSourceRange(),
Base.isVirtual(),
3608 Base.getAccessSpecifierAsWritten(), Expanded,
3610 InstantiatedBases.push_back(InstantiatedBase);
3619 EllipsisLoc =
Base.getEllipsisLoc();
3627 Base.getSourceRange().getBegin(),
3638 Base.getSourceRange(),
3640 Base.getAccessSpecifierAsWritten(),
3643 InstantiatedBases.push_back(InstantiatedBase);
3675 Pattern, PatternDef, TSK, Complain))
3678 llvm::TimeTraceScope TimeScope(
"InstantiateClass", [&]() {
3679 llvm::TimeTraceMetadata M;
3680 llvm::raw_string_ostream
OS(M.Detail);
3683 if (llvm::isTimeTraceVerbose()) {
3691 Pattern = PatternDef;
3697 MSInfo->setPointOfInstantiation(PointOfInstantiation);
3699 = dyn_cast<ClassTemplateSpecializationDecl>(Instantiation)) {
3700 Spec->setTemplateSpecializationKind(TSK);
3701 Spec->setPointOfInstantiation(PointOfInstantiation);
3709 "instantiating class definition");
3727 SavePendingParsedClassStateRAII SavedPendingParsedClassState(*
this);
3753 bool MightHaveConstexprVirtualFunctions =
false;
3764 if (
Member->getDeclContext() != Pattern)
3771 if (isa<BlockDecl>(
Member) ||
3772 (isa<CXXRecordDecl>(
Member) && cast<CXXRecordDecl>(
Member)->isLambda()))
3775 if (
Member->isInvalidDecl()) {
3782 if (
FieldDecl *Field = dyn_cast<FieldDecl>(NewMember)) {
3783 Fields.push_back(Field);
3784 }
else if (
EnumDecl *
Enum = dyn_cast<EnumDecl>(NewMember)) {
3790 Enum->isCompleteDefinition()) {
3792 assert(MSInfo &&
"no spec info for member enum specialization");
3797 if (SA->isFailed()) {
3803 }
else if (
CXXMethodDecl *MD = dyn_cast<CXXMethodDecl>(NewMember)) {
3806 MightHaveConstexprVirtualFunctions =
true;
3827 if (ParsingClassDepth == 0)
3832 for (LateInstantiatedAttrVec::iterator I = LateAttrs.begin(),
3833 E = LateAttrs.end(); I !=
E; ++I) {
3838 auto *ND = cast<NamedDecl>(I->NewDecl);
3839 auto *ThisContext = dyn_cast_or_null<CXXRecordDecl>(ND->getDeclContext());
3841 ND->isCXXInstanceMember());
3846 I->NewDecl->addAttr(NewAttr);
3875 P->first,
P->second)) {
3888 P->first,
P->second)) {
3905 else if (MightHaveConstexprVirtualFunctions)
3922 Pattern, PatternDef, TSK,
true))
3924 Pattern = PatternDef;
3930 MSInfo->setPointOfInstantiation(PointOfInstantiation);
3939 "instantiating enum definition");
3974 "pattern and instantiation disagree about init style");
3982 Diag(PointOfInstantiation,
3983 diag::err_default_member_initializer_not_yet_parsed)
3984 << OutermostClass << Pattern;
3985 Diag(Pattern->getEndLoc(),
3986 diag::note_default_member_initializer_not_yet_parsed);
3996 Diag(PointOfInstantiation, diag::err_default_member_initializer_cycle)
4001 "instantiating default member init");
4009 PointOfInstantiation, Instantiation,
CurContext};
4020 assert((!
Init || !isa<ParenListExpr>(
Init)) &&
"call-style init in class");
4025 L->DefaultMemberInitializerInstantiated(Instantiation);
4034 struct PartialSpecMatchResult {
4060 !CTPSD->getMostRecentDecl()->isMemberSpecialization())
4089 if (!isa<ClassTemplatePartialSpecializationDecl *>(Specialized)) {
4104 Template->getPartialSpecializations(PartialSpecs);
4117 if (
Template->getMostRecentDecl()->isMemberSpecialization() &&
4118 !Partial->getMostRecentDecl()->isMemberSpecialization())
4136 if (Matched.empty() && PrimaryStrictPackMatch)
4137 Matched = std::move(ExtraMatched);
4143 if (Matched.size() >= 1) {
4145 if (Matched.size() == 1) {
4158 PEnd = Matched.end();
4161 P->Partial, Best->Partial, PointOfInstantiation) ==
4170 PEnd = Matched.end();
4173 P->Partial, Best->Partial,
4174 PointOfInstantiation) != Best->Partial) {
4183 S.
Diag(PointOfInstantiation,
4184 diag::err_partial_spec_ordering_ambiguous)
4185 << ClassTemplateSpec;
4189 PEnd = Matched.end();
4191 S.
Diag(
P->Partial->getLocation(), diag::note_partial_spec_match)
4193 P->Partial->getTemplateParameters(), *
P->Args);
4208 if (
auto *PartialSpec =
4211 while (PartialSpec->getInstantiatedFromMember()) {
4214 if (PartialSpec->isMemberSpecialization())
4217 PartialSpec = PartialSpec->getInstantiatedFromMember();
4219 Pattern = PartialSpec;
4222 while (
Template->getInstantiatedFromMemberTemplate()) {
4225 if (
Template->isMemberSpecialization())
4230 Pattern =
Template->getTemplatedDecl();
4240 bool PrimaryStrictPackMatch) {
4242 ClassTemplateSpec = cast<ClassTemplateSpecializationDecl>(
4247 bool HadAvaibilityWarning =
4253 ClassTemplateSpec, TSK,
4254 PrimaryStrictPackMatch);
4260 PointOfInstantiation, ClassTemplateSpec, Pattern.
get(),
4267 if (!Err && !HadAvaibilityWarning) {
4287 "Unexpected template specialization kind!");
4288 for (
auto *
D : Instantiation->
decls()) {
4289 bool SuppressNew =
false;
4290 if (
auto *
Function = dyn_cast<FunctionDecl>(
D)) {
4292 Function->getInstantiatedFromMemberFunction()) {
4294 if (
Function->getTrailingRequiresClause()) {
4302 if (
Function->hasAttr<ExcludeFromExplicitInstantiationAttr>())
4306 Function->getTemplateSpecializationKind();
4311 PointOfInstantiation, TSK,
Function, PrevTSK,
4312 Function->getPointOfInstantiation(), SuppressNew) ||
4325 Function->setTemplateSpecializationKind(TSK, PointOfInstantiation);
4335 std::make_pair(
Function, PointOfInstantiation));
4338 }
else if (
auto *Var = dyn_cast<VarDecl>(
D)) {
4339 if (isa<VarTemplateSpecializationDecl>(Var))
4343 if (Var->
hasAttr<ExcludeFromExplicitInstantiationAttr>())
4347 assert(MSInfo &&
"No member specialization information?");
4376 }
else if (
auto *
Record = dyn_cast<CXXRecordDecl>(
D)) {
4377 if (
Record->hasAttr<ExcludeFromExplicitInstantiationAttr>())
4385 if (
Record->isInjectedClassName() ||
Record->getPreviousDecl() ||
4390 assert(MSInfo &&
"No member specialization information?");
4416 assert(Pattern &&
"Missing instantiated-from-template information");
4418 if (!
Record->getDefinition()) {
4439 Record->getTemplateSpecializationKind() ==
4441 Record->setTemplateSpecializationKind(TSK);
4446 Pattern = cast_or_null<CXXRecordDecl>(
Record->getDefinition());
4450 }
else if (
auto *
Enum = dyn_cast<EnumDecl>(
D)) {
4452 assert(MSInfo &&
"No member specialization information?");
4459 PointOfInstantiation, TSK,
Enum,
4465 if (
Enum->getDefinition())
4468 EnumDecl *Pattern =
Enum->getTemplateInstantiationPattern();
4469 assert(Pattern &&
"Missing instantiated-from-template information");
4480 }
else if (
auto *Field = dyn_cast<FieldDecl>(
D)) {
4491 ClassPattern->
lookup(Field->getDeclName());
4524 TemplateInstantiator Instantiator(*
this, TemplateArgs,
4527 return Instantiator.TransformStmt(S);
4535 TemplateInstantiator Instantiator(*
this, TemplateArgs,
Loc, Entity);
4536 return Instantiator.TransformTemplateArgument(Input, Output);
4543 TemplateInstantiator Instantiator(*
this, TemplateArgs,
SourceLocation(),
4545 return Instantiator.TransformTemplateArguments(Args.begin(), Args.end(), Out);
4553 TemplateInstantiator Instantiator(*
this, TemplateArgs,
4556 return Instantiator.TransformExpr(
E);
4565 TemplateInstantiator Instantiator(*
this, TemplateArgs,
SourceLocation(),
4567 return Instantiator.TransformAddressOfOperand(
E);
4583 TemplateInstantiator Instantiator(*
this, TemplateArgs,
SourceLocation(),
4585 Instantiator.setEvaluateConstraints(
false);
4586 return Instantiator.TransformExpr(
E);
4591 bool CXXDirectInit) {
4592 TemplateInstantiator Instantiator(*
this, TemplateArgs,
SourceLocation(),
4594 return Instantiator.TransformInitializer(
Init, CXXDirectInit);
4603 TemplateInstantiator Instantiator(*
this, TemplateArgs,
4606 return Instantiator.TransformExprs(Exprs.data(), Exprs.size(),
4616 TemplateInstantiator Instantiator(*
this, TemplateArgs, NNS.
getBeginLoc(),
4618 return Instantiator.TransformNestedNameSpecifierLoc(NNS);
4624 TemplateInstantiator Instantiator(*
this, TemplateArgs, NameInfo.
getLoc(),
4626 return Instantiator.TransformDeclarationNameInfo(NameInfo);
4634 TemplateInstantiator Instantiator(*
this, TemplateArgs, NameLoc,
4636 return Instantiator.TransformTemplateName(QualifierLoc, TemplateKWLoc, Name,
4645 if (
const ParmVarDecl *PV = dyn_cast<ParmVarDecl>(
D)) {
4646 if (
const FunctionDecl *FD = dyn_cast<FunctionDecl>(PV->getDeclContext())) {
4647 unsigned i = PV->getFunctionScopeIndex();
4650 if (i < FD->getNumParams() && FD->getParamDecl(i) == PV)
4657llvm::PointerUnion<Decl *, LocalInstantiationScope::DeclArgumentPack *> *
4661 Current = Current->Outer) {
4664 const Decl *CheckD =
D;
4666 LocalDeclsMap::iterator
Found = Current->LocalDecls.find(CheckD);
4667 if (
Found != Current->LocalDecls.end())
4668 return &
Found->second;
4672 if (
const TagDecl *Tag = dyn_cast<TagDecl>(CheckD))
4673 CheckD = Tag->getPreviousDecl();
4679 if (!Current->CombineWithOuterScope)
4686llvm::PointerUnion<Decl *, LocalInstantiationScope::DeclArgumentPack *> *
4688 auto *
Result = getInstantiationOfIfExists(
D);
4693 if (isa<NonTypeTemplateParmDecl>(
D) || isa<TemplateTypeParmDecl>(
D) ||
4694 isa<TemplateTemplateParmDecl>(
D))
4699 if (RD->isLocalClass())
4704 if (isa<EnumDecl>(
D))
4709 if (isa<TypedefNameDecl>(
D) &&
4716 assert(isa<LabelDecl>(
D) &&
"declaration not instantiated in this scope");
4722 llvm::PointerUnion<Decl *, DeclArgumentPack *> &Stored = LocalDecls[
D];
4723 if (Stored.isNull()) {
4727 while (Current->CombineWithOuterScope && Current->Outer) {
4728 Current = Current->Outer;
4729 assert(!Current->LocalDecls.contains(
D) &&
4730 "Instantiated local in inner and outer scopes");
4734 }
else if (
DeclArgumentPack *Pack = dyn_cast<DeclArgumentPack *>(Stored)) {
4735 Pack->push_back(cast<ValueDecl>(Inst));
4737 assert(cast<Decl *>(Stored) == Inst &&
"Already instantiated this local");
4745 Pack->push_back(Inst);
4752 Current && Current->CombineWithOuterScope; Current = Current->Outer)
4753 assert(!Current->LocalDecls.contains(
D) &&
4754 "Creating local pack after instantiation of local");
4758 llvm::PointerUnion<Decl *, DeclArgumentPack *> &Stored = LocalDecls[
D];
4761 ArgumentPacks.push_back(Pack);
4766 if (llvm::is_contained(*Pack,
D))
4773 unsigned NumExplicitArgs) {
4774 assert((!PartiallySubstitutedPack || PartiallySubstitutedPack == Pack) &&
4775 "Already have a partially-substituted pack");
4776 assert((!PartiallySubstitutedPack
4777 || NumArgsInPartiallySubstitutedPack == NumExplicitArgs) &&
4778 "Wrong number of arguments in partially-substituted pack");
4779 PartiallySubstitutedPack = Pack;
4780 ArgsInPartiallySubstitutedPack = ExplicitArgs;
4781 NumArgsInPartiallySubstitutedPack = NumExplicitArgs;
4786 unsigned *NumExplicitArgs)
const {
4788 *ExplicitArgs =
nullptr;
4789 if (NumExplicitArgs)
4790 *NumExplicitArgs = 0;
4793 Current = Current->Outer) {
4794 if (Current->PartiallySubstitutedPack) {
4796 *ExplicitArgs = Current->ArgsInPartiallySubstitutedPack;
4797 if (NumExplicitArgs)
4798 *NumExplicitArgs = Current->NumArgsInPartiallySubstitutedPack;
4800 return Current->PartiallySubstitutedPack;
4803 if (!Current->CombineWithOuterScope)
This file provides AST data structures related to concepts.
Defines the clang::ASTContext interface.
This file provides some common utility functions for processing Lambda related AST Constructs.
Defines the C++ template declaration subclasses.
Defines Expressions and AST nodes for C++2a concepts.
static void print(llvm::raw_ostream &OS, const T &V, ASTContext &ASTCtx, QualType Ty)
Defines the clang::LangOptions interface.
llvm::MachO::Record Record
MatchFinder::MatchResult MatchResult
static bool PreparePackForExpansion(Sema &S, const CXXBaseSpecifier &Base, const MultiLevelTemplateArgumentList &TemplateArgs, TypeSourceInfo *&Out, UnexpandedInfo &Info)
static const Decl * getCanonicalParmVarDecl(const Decl *D)
static ActionResult< CXXRecordDecl * > getPatternForClassTemplateSpecialization(Sema &S, SourceLocation PointOfInstantiation, ClassTemplateSpecializationDecl *ClassTemplateSpec, TemplateSpecializationKind TSK, bool PrimaryStrictPackMatch)
Get the instantiation pattern to use to instantiate the definition of a given ClassTemplateSpecializa...
static bool NeedsInstantiationAsFunctionType(TypeSourceInfo *T)
static concepts::Requirement::SubstitutionDiagnostic * createSubstDiag(Sema &S, TemplateDeductionInfo &Info, Sema::EntityPrinter Printer)
static std::string convertCallArgsToString(Sema &S, llvm::ArrayRef< const Expr * > Args)
static TemplateArgument getPackSubstitutedTemplateArgument(Sema &S, TemplateArgument Arg)
Defines the clang::TypeLoc interface and its subclasses.
C Language Family Type Representation.
virtual void HandleTagDeclDefinition(TagDecl *D)
HandleTagDeclDefinition - This callback is invoked each time a TagDecl (e.g.
virtual bool HandleTopLevelDecl(DeclGroupRef D)
HandleTopLevelDecl - Handle the specified top-level declaration.
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
TranslationUnitDecl * getTranslationUnitDecl() const
bool hasSameType(QualType T1, QualType T2) const
Determine whether the given types T1 and T2 are equivalent.
QualType getQualifiedType(SplitQualType split) const
Un-split a SplitQualType.
const clang::PrintingPolicy & getPrintingPolicy() const
QualType getTypeDeclType(ElaboratedTypeKeyword Keyword, NestedNameSpecifier Qualifier, const TypeDecl *Decl) const
const TargetInfo & getTargetInfo() const
CanQualType getCanonicalTagType(const TagDecl *TD) const
Represents a type which was implicitly adjusted by the semantic engine for arbitrary reasons.
Represents an array type, per C99 6.7.5.2 - Array Declarators.
Attr - This represents one attribute.
An attributed type is a type to which a type attribute has been applied.
BlockExpr - Adaptor class for mixing a BlockDecl with expressions.
Represents a base class of a C++ class.
A default argument (C++ [dcl.fct.default]).
Represents a static or instance method of a struct/union/class.
Represents a C++ struct/union/class.
Decl * getLambdaContextDecl() const
Retrieve the declaration that provides additional context for a lambda, when the normal declaration c...
const FunctionDecl * isLocalClass() const
If the class is a local class [class.local], returns the enclosing function declaration.
CXXRecordDecl * getInstantiatedFromMemberClass() const
If this record is an instantiation of a member class, retrieves the member class from which it was in...
bool isLambda() const
Determine whether this class describes a lambda function object.
CXXRecordDecl * getDefinition() const
unsigned getNumBases() const
Retrieves the number of base classes of this class.
const CXXRecordDecl * getTemplateInstantiationPattern() const
Retrieve the record declaration from which this record could be instantiated.
TemplateSpecializationKind getTemplateSpecializationKind() const
Determine whether this particular class is a specialization or instantiation of a class template or m...
ClassTemplateDecl * getDescribedClassTemplate() const
Retrieves the class template that is described by this class declaration.
MemberSpecializationInfo * getMemberSpecializationInfo() const
If this class is an instantiation of a member class of a class template specialization,...
CXXMethodDecl * getLambdaCallOperator() const
Retrieve the lambda call operator of the closure type if this is a closure type.
CXXRecordDecl * getCanonicalDecl() override
Retrieves the "canonical" declaration of the given declaration.
void setTemplateSpecializationKind(TemplateSpecializationKind TSK)
Set the kind of specialization or template instantiation this is.
Represents a C++ nested-name-specifier or a global scope specifier.
Declaration of a class template.
ClassTemplateDecl * getMostRecentDecl()
llvm::FoldingSetVector< ClassTemplatePartialSpecializationDecl > & getPartialSpecializations() const
Retrieve the set of partial specializations of this class template.
Represents a class template specialization, which refers to a class template with a given set of temp...
TemplateSpecializationKind getSpecializationKind() const
Determine the kind of specialization that this declaration represents.
ClassTemplateDecl * getSpecializedTemplate() const
Retrieve the template that this specialization specializes.
bool isClassScopeExplicitSpecialization() const
Is this an explicit specialization at class scope (within the class that owns the primary template)?...
llvm::PointerUnion< ClassTemplateDecl *, ClassTemplatePartialSpecializationDecl * > getSpecializedTemplateOrPartial() const
Retrieve the class template or class template partial specialization which was specialized by this.
const TemplateArgumentList & getTemplateArgs() const
Retrieve the template arguments of the class template specialization.
const TemplateArgumentList & getTemplateInstantiationArgs() const
Retrieve the set of template arguments that should be used to instantiate members of the class templa...
void setInstantiationOf(ClassTemplatePartialSpecializationDecl *PartialSpec, const TemplateArgumentList *TemplateArgs)
Note that this class template specialization is actually an instantiation of the given class template...
NamedDecl * getFoundDecl() const
const TypeClass * getTypePtr() const
The result of a constraint satisfaction check, containing the necessary information to diagnose an un...
bool HasSubstitutionFailure()
static DeclAccessPair make(NamedDecl *D, AccessSpecifier AS)
The results of name lookup within a DeclContext.
DeclContext - This is used only as base class of specific decl types that can act as declaration cont...
bool isFileContext() const
bool isDependentContext() const
Determines whether this context is dependent on a template parameter.
lookup_result lookup(DeclarationName Name) const
lookup - Find the declarations (if any) with the given Name in this context.
RecordDecl * getOuterLexicalRecordContext()
Retrieve the outermost lexically enclosing record context.
decl_range decls() const
decls_begin/decls_end - Iterate over the declarations stored in this context.
A reference to a declared variable, function, enum, etc.
Decl - This represents one declaration (or definition), e.g.
TemplateDecl * getDescribedTemplate() const
If this is a declaration that describes some template, this method returns that template declaration.
FriendObjectKind getFriendObjectKind() const
Determines whether this declaration is the object of a friend declaration and, if so,...
bool isParameterPack() const
Whether this declaration is a parameter pack.
void setInvalidDecl(bool Invalid=true)
setInvalidDecl - Indicates the Decl had a semantic error.
bool isFileContextDecl() const
static Decl * castFromDeclContext(const DeclContext *)
unsigned getTemplateDepth() const
Determine the number of levels of template parameter surrounding this declaration.
DeclContext * getNonTransparentDeclContext()
Return the non transparent context.
bool isInvalidDecl() const
SourceLocation getLocation() const
void setLocation(SourceLocation L)
bool isDefinedOutsideFunctionOrMethod() const
isDefinedOutsideFunctionOrMethod - This predicate returns true if this scoped decl is defined outside...
DeclContext * getDeclContext()
void setDeclContext(DeclContext *DC)
setDeclContext - Set both the semantic and lexical DeclContext to DC.
DeclContext * getLexicalDeclContext()
getLexicalDeclContext - The declaration context where this Decl was lexically declared (LexicalDC).
virtual Decl * getCanonicalDecl()
Retrieves the "canonical" declaration of the given declaration.
void setVisibleDespiteOwningModule()
Set that this declaration is globally visible, even if it came from a module that is not visible.
The name of a declaration.
SourceLocation getInnerLocStart() const
Return start of source range ignoring outer template declarations.
SourceLocation getOuterLocStart() const
Return start of source range taking into account any outer template declarations.
SourceLocation getBeginLoc() const LLVM_READONLY
NestedNameSpecifier getQualifier() const
Retrieve the nested-name-specifier that qualifies the name of this declaration, if it was present in ...
TypeSourceInfo * getTypeSourceInfo() const
Information about one declarator, including the parsed type information and the identifier.
Represents an extended vector type where either the type or size is dependent.
bool hasFatalErrorOccurred() const
unsigned getTemplateBacktraceLimit() const
Retrieve the maximum number of template instantiation notes to emit along with a given diagnostic.
Recursive AST visitor that supports extension via dynamic dispatch.
RAII object that enters a new expression evaluation context.
MemberSpecializationInfo * getMemberSpecializationInfo() const
If this enumeration is an instantiation of a member enumeration of a class template specialization,...
void setTemplateSpecializationKind(TemplateSpecializationKind TSK, SourceLocation PointOfInstantiation=SourceLocation())
For an enumeration member that was instantiated from a member enumeration of a templated class,...
EnumDecl * getInstantiatedFromMemberEnum() const
Returns the enumeration (declared within the template) from which this enumeration type was instantia...
EnumDecl * getDefinition() const
This represents one expression.
ExprValueKind getValueKind() const
getValueKind - The value kind that this expression produces.
bool isTypeDependent() const
Determines whether the type of this expression depends on.
llvm::APSInt EvaluateKnownConstInt(const ASTContext &Ctx, SmallVectorImpl< PartialDiagnosticAt > *Diag=nullptr) const
EvaluateKnownConstInt - Call EvaluateAsRValue and return the folded integer.
bool isLValue() const
isLValue - True if this expression is an "l-value" according to the rules of the current language.
bool isInstantiationDependent() const
Whether this expression is instantiation-dependent, meaning that it depends in some way on.
SourceLocation getExprLoc() const LLVM_READONLY
getExprLoc - Return the preferred location for the arrow when diagnosing a problem with a generic exp...
bool hasPlaceholderType() const
Returns whether this expression has a placeholder type.
ExprDependence getDependence() const
Represents a member of a struct/union/class.
Expr * getInClassInitializer() const
Get the C++11 default member initializer for this member, or null if one has not been set.
bool hasInClassInitializer() const
Determine whether this member has a C++11 default member initializer.
InClassInitStyle getInClassInitStyle() const
Get the kind of (C++11) default member initializer that this field has.
const RecordDecl * getParent() const
Returns the parent of this field declaration, which is the struct in which this field is defined.
Represents a function declaration or definition.
ArrayRef< ParmVarDecl * > parameters() const
FunctionDecl * getTemplateInstantiationPattern(bool ForDefinition=true) const
Retrieve the function declaration from which this function could be instantiated, if it is an instant...
FunctionTemplateDecl * getPrimaryTemplate() const
Retrieve the primary template that this function template specialization either specializes or was in...
bool isConstexpr() const
Whether this is a (C++11) constexpr function or constexpr constructor.
bool isVirtualAsWritten() const
Whether this function is marked as virtual explicitly.
Represents a reference to a function parameter pack, init-capture pack, or binding pack that has been...
static FunctionParmPackExpr * Create(const ASTContext &Context, QualType T, ValueDecl *ParamPack, SourceLocation NameLoc, ArrayRef< ValueDecl * > Params)
ValueDecl *const * iterator
Iterators over the parameters which the parameter pack expanded into.
Represents a prototype with parameter type info, e.g.
ExtProtoInfo getExtProtoInfo() const
Declaration of a template function.
FunctionDecl * getTemplatedDecl() const
Get the underlying function declaration of the template.
ArrayRef< ParmVarDecl * > getParams() const
Interesting information about a specific parameter that can't simply be reflected in parameter's type...
FunctionType - C99 6.7.5.3 - Function Declarators.
QualType getReturnType() const
One of these records is kept for each identifier that is lexed.
ArrayRef< TemplateArgument > getTemplateArguments() const
const TypeClass * getTypePtr() const
Describes the kind of initialization being performed, along with location information for tokens rela...
static InitializationKind CreateCopy(SourceLocation InitLoc, SourceLocation EqualLoc, bool AllowExplicitConvs=false)
Create a copy initialization.
Describes the sequence of initializations required to initialize a given object or reference with a s...
Describes an entity that is being initialized.
static InitializedEntity InitializeParameter(ASTContext &Context, ParmVarDecl *Parm)
Create the initialization entity for a parameter.
A C++ lambda expression, which produces a function object (of unspecified type) that can be invoked l...
A stack-allocated class that identifies which local variable declaration instantiations are present i...
void SetPartiallySubstitutedPack(NamedDecl *Pack, const TemplateArgument *ExplicitArgs, unsigned NumExplicitArgs)
Note that the given parameter pack has been partially substituted via explicit specification of templ...
NamedDecl * getPartiallySubstitutedPack(const TemplateArgument **ExplicitArgs=nullptr, unsigned *NumExplicitArgs=nullptr) const
Retrieve the partially-substitued template parameter pack.
bool isLocalPackExpansion(const Decl *D)
Determine whether D is a pack expansion created in this scope.
llvm::PointerUnion< Decl *, DeclArgumentPack * > * getInstantiationOfIfExists(const Decl *D)
Similar to findInstantiationOf(), but it wouldn't assert if the instantiation was not found within th...
static void deleteScopes(LocalInstantiationScope *Scope, LocalInstantiationScope *Outermost)
deletes the given scope, and all outer scopes, down to the given outermost scope.
void InstantiatedLocal(const Decl *D, Decl *Inst)
void InstantiatedLocalPackArg(const Decl *D, VarDecl *Inst)
void MakeInstantiatedLocalArgPack(const Decl *D)
llvm::PointerUnion< Decl *, DeclArgumentPack * > * findInstantiationOf(const Decl *D)
Find the instantiation of the declaration D within the current instantiation scope.
Sugar type that represents a type that was qualified by a qualifier written as a macro invocation.
A pointer to member type per C++ 8.3.3 - Pointers to members.
Provides information a specialization of a member of a class template, which may be a member function...
void setTemplateSpecializationKind(TemplateSpecializationKind TSK)
Set the template specialization kind.
TemplateSpecializationKind getTemplateSpecializationKind() const
Determine what kind of template specialization this is.
SourceLocation getPointOfInstantiation() const
Retrieve the first point of instantiation of this member.
void setPointOfInstantiation(SourceLocation POI)
Set the first point of instantiation.
Describes a module or submodule.
Data structure that captures multiple levels of template argument lists for use in template instantia...
bool hasTemplateArgument(unsigned Depth, unsigned Index) const
Determine whether there is a non-NULL template argument at the given depth and index.
const ArgList & getInnermost() const
Retrieve the innermost template argument list.
std::pair< Decl *, bool > getAssociatedDecl(unsigned Depth) const
A template-like entity which owns the whole pattern being substituted.
unsigned getNumLevels() const
Determine the number of levels in this template argument list.
unsigned getNumSubstitutedLevels() const
Determine the number of substituted levels in this template argument list.
unsigned getNewDepth(unsigned OldDepth) const
Determine how many of the OldDepth outermost template parameter lists would be removed by substitutin...
void setArgument(unsigned Depth, unsigned Index, TemplateArgument Arg)
Clear out a specific template argument.
bool isRewrite() const
Determine whether we are rewriting template parameters rather than substituting for them.
This represents a decl that may have a name.
IdentifierInfo * getIdentifier() const
Get the identifier that names this declaration, if there is one.
StringRef getName() const
Get the name of identifier for this declaration as a StringRef.
DeclarationName getDeclName() const
Get the actual, stored name of the declaration, which may be a special name.
virtual void getNameForDiagnostic(raw_ostream &OS, const PrintingPolicy &Policy, bool Qualified) const
Appends a human-readable name for this declaration into the given stream.
virtual void printName(raw_ostream &OS, const PrintingPolicy &Policy) const
Pretty-print the unqualified name of this declaration.
A C++ nested-name-specifier augmented with source location information.
SourceLocation getBeginLoc() const
Retrieve the location of the beginning of this nested-name-specifier.
Represents a C++ nested name specifier, such as "\::std::vector<int>::".
const Type * getAsType() const
NonTypeTemplateParmDecl - Declares a non-type template parameter, e.g., "Size" in.
QualType getExpansionType(unsigned I) const
Retrieve a particular expansion type within an expanded parameter pack.
unsigned getPosition() const
Get the position of the template parameter within its parameter list.
bool isExpandedParameterPack() const
Whether this parameter is a non-type template parameter pack that has a known list of different types...
bool isParameterPack() const
Whether this parameter is a non-type template parameter pack.
unsigned getDepth() const
Get the nesting depth of the template parameter.
SourceLocation getEllipsisLoc() const
TypeLoc getPatternLoc() const
Represents a pack expansion of types.
UnsignedOrNone getNumExpansions() const
Retrieve the number of expansions that this pack expansion will generate, if known.
Sugar for parentheses used when specifying types.
Represents a parameter to a function.
unsigned getFunctionScopeIndex() const
Returns the index of this parameter in its prototype or method scope.
void setDefaultArg(Expr *defarg)
SourceLocation getExplicitObjectParamThisLoc() const
void setUnparsedDefaultArg()
Specify that this parameter has an unparsed default argument.
bool hasUnparsedDefaultArg() const
Determines whether this parameter has a default argument that has not yet been parsed.
void setUninstantiatedDefaultArg(Expr *arg)
void setScopeInfo(unsigned scopeDepth, unsigned parameterIndex)
bool hasUninstantiatedDefaultArg() const
bool hasInheritedDefaultArg() const
void setExplicitObjectParameterLoc(SourceLocation Loc)
Expr * getUninstantiatedDefaultArg()
unsigned getFunctionScopeDepth() const
void setHasInheritedDefaultArg(bool I=true)
PointerType - C99 6.7.5.1 - Pointer Declarators.
[C99 6.4.2.2] - A predefined identifier such as func.
PrettyDeclStackTraceEntry - If a crash occurs in the parser while parsing something related to a decl...
A (possibly-)qualified type.
QualType getNonLValueExprType(const ASTContext &Context) const
Determine the type of a (typically non-lvalue) expression with the specified result type.
void addConst()
Add the const type qualifier to this QualType.
bool isNull() const
Return true if this QualType doesn't point to a type yet.
QualType getNonReferenceType() const
If Type is a reference type (e.g., const int&), returns the type that the reference refers to ("const...
The collection of all-type qualifiers we support.
void removeObjCLifetime()
Represents a struct/union/class.
A helper class that allows the use of isa/cast/dyncast to detect TagType objects of structs/unions/cl...
bool isMemberSpecialization() const
Determines whether this template was a specialization of a member template.
Base for LValueReferenceType and RValueReferenceType.
Represents the body of a requires-expression.
C++2a [expr.prim.req]: A requires-expression provides a concise way to express requirements on templa...
SourceLocation getLParenLoc() const
SourceLocation getRParenLoc() const
Scope - A scope is a transient data structure that is used while parsing the program.
SemaDiagnosticBuilder Diag(SourceLocation Loc, unsigned DiagID, bool DeferHint=false)
Emit a diagnostic.
PartialDiagnostic PDiag(unsigned DiagID=0)
Build a partial diagnostic.
RAII object used to change the argument pack substitution index within a Sema object.
RAII object used to temporarily allow the C++ 'this' expression to be used, with the given qualifiers...
For a defaulted function, the kind of defaulted function that it is.
DefaultedComparisonKind asComparison() const
bool isSpecialMember() const
bool isComparison() const
CXXSpecialMemberKind asSpecialMember() const
A helper class for building up ExtParameterInfos.
RAII class used to determine whether SFINAE has trapped any errors that occur during template argumen...
Sema - This implements semantic analysis and AST building for C.
llvm::DenseSet< Module * > LookupModulesCache
Cache of additional modules that should be used for name lookup within the current template instantia...
bool SubstTypeConstraint(TemplateTypeParmDecl *Inst, const TypeConstraint *TC, const MultiLevelTemplateArgumentList &TemplateArgs, bool EvaluateConstraint)
SmallVector< CodeSynthesisContext, 16 > CodeSynthesisContexts
List of active code synthesis contexts.
LocalInstantiationScope * CurrentInstantiationScope
The current instantiation scope used to store local variables.
TemplateArgumentLoc getTrivialTemplateArgumentLoc(const TemplateArgument &Arg, QualType NTTPType, SourceLocation Loc, NamedDecl *TemplateParam=nullptr)
Allocate a TemplateArgumentLoc where all locations have been initialized to the given location.
DefaultedFunctionKind getDefaultedFunctionKind(const FunctionDecl *FD)
Determine the kind of defaulting that would be done for a given function.
void ActOnFinishCXXNonNestedClass()
NamedDecl * FindInstantiatedDecl(SourceLocation Loc, NamedDecl *D, const MultiLevelTemplateArgumentList &TemplateArgs, bool FindingInstantiatedContext=false)
Find the instantiation of the given declaration within the current instantiation.
void ActOnFinishDelayedMemberInitializers(Decl *Record)
TemplateName SubstTemplateName(SourceLocation TemplateKWLoc, NestedNameSpecifierLoc &QualifierLoc, TemplateName Name, SourceLocation NameLoc, const MultiLevelTemplateArgumentList &TemplateArgs)
ParmVarDecl * SubstParmVarDecl(ParmVarDecl *D, const MultiLevelTemplateArgumentList &TemplateArgs, int indexAdjustment, UnsignedOrNone NumExpansions, bool ExpectParameterPack, bool EvaluateConstraints=true)
void InstantiateClassTemplateSpecializationMembers(SourceLocation PointOfInstantiation, ClassTemplateSpecializationDecl *ClassTemplateSpec, TemplateSpecializationKind TSK)
Instantiate the definitions of all of the members of the given class template specialization,...
ClassTemplatePartialSpecializationDecl * getMoreSpecializedPartialSpecialization(ClassTemplatePartialSpecializationDecl *PS1, ClassTemplatePartialSpecializationDecl *PS2, SourceLocation Loc)
Returns the more specialized class template partial specialization according to the rules of partial ...
llvm::DenseSet< std::pair< Decl *, unsigned > > InstantiatingSpecializations
Specializations whose definitions are currently being instantiated.
void deduceOpenCLAddressSpace(ValueDecl *decl)
ExprResult SubstInitializer(Expr *E, const MultiLevelTemplateArgumentList &TemplateArgs, bool CXXDirectInit)
llvm::function_ref< void(llvm::raw_ostream &)> EntityPrinter
void SubstExceptionSpec(FunctionDecl *New, const FunctionProtoType *Proto, const MultiLevelTemplateArgumentList &Args)
concepts::Requirement::SubstitutionDiagnostic * createSubstDiagAt(SourceLocation Location, EntityPrinter Printer)
create a Requirement::SubstitutionDiagnostic with only a SubstitutedEntity and DiagLoc using ASTConte...
@ CTAK_Specified
The template argument was specified in the code or was instantiated with some deduced template argume...
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...
StmtResult SubstStmt(Stmt *S, const MultiLevelTemplateArgumentList &TemplateArgs)
bool InstantiateClassTemplateSpecialization(SourceLocation PointOfInstantiation, ClassTemplateSpecializationDecl *ClassTemplateSpec, TemplateSpecializationKind TSK, bool Complain, bool PrimaryStrictPackMatch)
bool InNonInstantiationSFINAEContext
Whether we are in a SFINAE context that is not associated with template instantiation.
ExprResult SubstExpr(Expr *E, const MultiLevelTemplateArgumentList &TemplateArgs)
DiagnosticsEngine & getDiagnostics() const
ExprResult BuildExpressionFromNonTypeTemplateArgument(const TemplateArgument &Arg, SourceLocation Loc)
ExprResult SubstConstraintExprWithoutSatisfaction(Expr *E, const MultiLevelTemplateArgumentList &TemplateArgs)
void PrintInstantiationStack()
ASTContext & getASTContext() const
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.
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 ActOnStartCXXInClassMemberInitializer()
Enter a new C++ default initializer scope.
PrintingPolicy getPrintingPolicy() const
Retrieve a suitable printing policy for diagnostics.
bool SubstTemplateArguments(ArrayRef< TemplateArgumentLoc > Args, const MultiLevelTemplateArgumentList &TemplateArgs, TemplateArgumentListInfo &Outputs)
bool CheckTemplateArgument(NamedDecl *Param, TemplateArgumentLoc &Arg, NamedDecl *Template, SourceLocation TemplateLoc, SourceLocation RAngleLoc, unsigned ArgumentPackIndex, CheckTemplateArgumentInfo &CTAI, CheckTemplateArgumentKind CTAK)
Check that the given template argument corresponds to the given template parameter.
void InstantiateAttrs(const MultiLevelTemplateArgumentList &TemplateArgs, const Decl *Pattern, Decl *Inst, LateInstantiatedAttrVec *LateAttrs=nullptr, LocalInstantiationScope *OuterMostScope=nullptr)
const LangOptions & getLangOpts() const
bool CheckConstraintSatisfaction(const NamedDecl *Template, ArrayRef< AssociatedConstraint > AssociatedConstraints, const MultiLevelTemplateArgumentList &TemplateArgLists, SourceRange TemplateIDRange, ConstraintSatisfaction &Satisfaction)
Check whether the given list of constraint expressions are satisfied (as if in a 'conjunction') given...
void collectUnexpandedParameterPacks(TemplateArgument Arg, SmallVectorImpl< UnexpandedParameterPack > &Unexpanded)
Collect the set of unexpanded parameter packs within the given template argument.
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 ...
void MarkVirtualMembersReferenced(SourceLocation Loc, const CXXRecordDecl *RD, bool ConstexprOnly=false)
MarkVirtualMembersReferenced - Will mark all members of the given CXXRecordDecl referenced.
DeclarationNameInfo SubstDeclarationNameInfo(const DeclarationNameInfo &NameInfo, const MultiLevelTemplateArgumentList &TemplateArgs)
Do template substitution on declaration name info.
void MarkVTableUsed(SourceLocation Loc, CXXRecordDecl *Class, bool DefinitionRequired=false)
Note that the vtable for the given class was used at the given location.
std::vector< std::unique_ptr< TemplateInstantiationCallback > > TemplateInstCallbacks
The template instantiation callbacks to trace or track instantiations (objects can be chained).
void popCodeSynthesisContext()
bool usesPartialOrExplicitSpecialization(SourceLocation Loc, ClassTemplateSpecializationDecl *ClassTemplateSpec)
void pushCodeSynthesisContext(CodeSynthesisContext Ctx)
bool CheckLoopHintExpr(Expr *E, SourceLocation Loc, bool AllowZero)
std::optional< sema::TemplateDeductionInfo * > isSFINAEContext() const
Determines whether we are currently in a context where template argument substitution failures are no...
CXXBaseSpecifier * CheckBaseSpecifier(CXXRecordDecl *Class, SourceRange SpecifierRange, bool Virtual, AccessSpecifier Access, TypeSourceInfo *TInfo, SourceLocation EllipsisLoc)
Check the validity of a C++ base class specifier.
llvm::function_ref< void(SourceLocation, PartialDiagnostic)> InstantiationContextDiagFuncRef
UnparsedDefaultArgInstantiationsMap UnparsedDefaultArgInstantiations
A mapping from parameters with unparsed default arguments to the set of instantiations of each parame...
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...
DeclContext * CurContext
CurContext - This is the current declaration context of parsing.
MultiLevelTemplateArgumentList getTemplateInstantiationArgs(const NamedDecl *D, const DeclContext *DC=nullptr, bool Final=false, std::optional< ArrayRef< TemplateArgument > > Innermost=std::nullopt, bool RelativeToPrimary=false, const FunctionDecl *Pattern=nullptr, bool ForConstraintInstantiation=false, bool SkipForSpecialization=false, bool ForDefaultArgumentSubstitution=false)
Retrieve the template argument list(s) that should be used to instantiate the definition of the given...
std::deque< PendingImplicitInstantiation > PendingLocalImplicitInstantiations
The queue of implicit template instantiations that are required and must be performed within the curr...
ParmVarDecl * CheckParameter(DeclContext *DC, SourceLocation StartLoc, SourceLocation NameLoc, const IdentifierInfo *Name, QualType T, TypeSourceInfo *TSInfo, StorageClass SC)
bool CheckFunctionConstraints(const FunctionDecl *FD, ConstraintSatisfaction &Satisfaction, SourceLocation UsageLoc=SourceLocation(), bool ForOverloadResolution=false)
Check whether the given function decl's trailing requires clause is satisfied, if any.
bool CheckSpecializationInstantiationRedecl(SourceLocation NewLoc, TemplateSpecializationKind ActOnExplicitInstantiationNewTSK, NamedDecl *PrevDecl, TemplateSpecializationKind PrevTSK, SourceLocation PrevPtOfInstantiation, bool &SuppressNew)
Diagnose cases where we have an explicit template specialization before/after an explicit template in...
ExprResult CheckPlaceholderExpr(Expr *E)
Check for operands with placeholder types and complain if found.
unsigned NonInstantiationEntries
The number of CodeSynthesisContexts that are not template instantiations and, therefore,...
bool CheckNoInlineAttr(const Stmt *OrigSt, const Stmt *CurSt, const AttributeCommonInfo &A)
void ActOnFinishCXXInClassMemberInitializer(Decl *VarDecl, SourceLocation EqualLoc, ExprResult Init)
This is invoked after parsing an in-class initializer for a non-static C++ class member,...
bool inConstraintSubstitution() const
Determine whether we are currently performing constraint substitution.
bool CheckAlwaysInlineAttr(const Stmt *OrigSt, const Stmt *CurSt, const AttributeCommonInfo &A)
void DiagnoseAvailabilityOfDecl(NamedDecl *D, ArrayRef< SourceLocation > Locs, const ObjCInterfaceDecl *UnknownObjCClass, bool ObjCPropertyAccess, bool AvoidPartialAvailabilityChecks, ObjCInterfaceDecl *ClassReceiver)
ExprResult BuildCXXDefaultArgExpr(SourceLocation CallLoc, FunctionDecl *FD, ParmVarDecl *Param, Expr *Init=nullptr)
BuildCXXDefaultArgExpr - Creates a CXXDefaultArgExpr, instantiating the default expr if needed.
bool AttachTypeConstraint(NestedNameSpecifierLoc NS, DeclarationNameInfo NameInfo, TemplateDecl *NamedConcept, NamedDecl *FoundDecl, const TemplateArgumentListInfo *TemplateArgs, TemplateTypeParmDecl *ConstrainedParameter, SourceLocation EllipsisLoc)
Attach a type-constraint to a template parameter.
std::pair< AvailabilityResult, const NamedDecl * > ShouldDiagnoseAvailabilityOfDecl(const NamedDecl *D, std::string *Message, ObjCInterfaceDecl *ClassReceiver)
The diagnostic we should emit for D, and the declaration that originated it, or AR_Available.
bool InstantiateInClassInitializer(SourceLocation PointOfInstantiation, FieldDecl *Instantiation, FieldDecl *Pattern, const MultiLevelTemplateArgumentList &TemplateArgs)
Instantiate the definition of a field from the given pattern.
UnsignedOrNone ArgPackSubstIndex
The current index into pack expansion arguments that will be used for substitution of parameter packs...
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.
bool SubstTemplateArgument(const TemplateArgumentLoc &Input, const MultiLevelTemplateArgumentList &TemplateArgs, TemplateArgumentLoc &Output, SourceLocation Loc={}, const DeclarationName &Entity={})
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 SubstDefaultArgument(SourceLocation Loc, ParmVarDecl *Param, const MultiLevelTemplateArgumentList &TemplateArgs, bool ForCallExpr=false)
Substitute the given template arguments into the default argument.
ExprResult SubstConstraintExpr(Expr *E, const MultiLevelTemplateArgumentList &TemplateArgs)
bool hasUncompilableErrorOccurred() const
Whether uncompilable error has occurred.
@ ConstantEvaluated
The current context is "potentially evaluated" in C++11 terms, but the expression is evaluated at com...
@ PotentiallyEvaluated
The current expression is potentially evaluated at run time, which means that code may be generated t...
unsigned LastEmittedCodeSynthesisContextDepth
The depth of the context stack at the point when the most recent error or warning was produced.
NestedNameSpecifierLoc SubstNestedNameSpecifierLoc(NestedNameSpecifierLoc NNS, const MultiLevelTemplateArgumentList &TemplateArgs)
void ActOnFields(Scope *S, SourceLocation RecLoc, Decl *TagDecl, ArrayRef< Decl * > Fields, SourceLocation LBrac, SourceLocation RBrac, const ParsedAttributesView &AttrList)
bool RebuildingImmediateInvocation
Whether the AST is currently being rebuilt to correct immediate invocations.
void CheckCompletedCXXClass(Scope *S, CXXRecordDecl *Record)
Perform semantic checks on a class definition that has been completing, introducing implicitly-declar...
SmallVector< ExpressionEvaluationContextRecord, 8 > ExprEvalContexts
A stack of expression evaluation contexts.
bool DiagnoseUninstantiableTemplate(SourceLocation PointOfInstantiation, NamedDecl *Instantiation, bool InstantiatedFromMember, const NamedDecl *Pattern, const NamedDecl *PatternDef, TemplateSpecializationKind TSK, bool Complain=true, bool *Unreachable=nullptr)
Determine whether we would be unable to instantiate this template (because it either has no definitio...
SourceManager & SourceMgr
bool CheckParameterPacksForExpansion(SourceLocation EllipsisLoc, SourceRange PatternRange, ArrayRef< UnexpandedParameterPack > Unexpanded, const MultiLevelTemplateArgumentList &TemplateArgs, bool FailOnPackProducingTemplates, bool &ShouldExpand, bool &RetainExpansion, UnsignedOrNone &NumExpansions)
Determine whether we could expand a pack expansion with the given set of parameter packs into separat...
DiagnosticsEngine & Diags
bool AttachBaseSpecifiers(CXXRecordDecl *Class, MutableArrayRef< CXXBaseSpecifier * > Bases)
Performs the actual work of attaching the given base class specifiers to a C++ class.
SmallVector< Module *, 16 > CodeSynthesisContextLookupModules
Extra modules inspected when performing a lookup during a template instantiation.
ExprResult ConvertParamDefaultArgument(ParmVarDecl *Param, Expr *DefaultArg, SourceLocation EqualLoc)
TemplateDeductionResult DeduceTemplateArguments(ClassTemplatePartialSpecializationDecl *Partial, ArrayRef< TemplateArgument > TemplateArgs, sema::TemplateDeductionInfo &Info)
void runWithSufficientStackSpace(SourceLocation Loc, llvm::function_ref< void()> Fn)
Run some code with "sufficient" stack space.
ExprResult CreateRecoveryExpr(SourceLocation Begin, SourceLocation End, ArrayRef< Expr * > SubExprs, QualType T=QualType())
Attempts to produce a RecoveryExpr after some AST node cannot be created.
bool InstantiateEnum(SourceLocation PointOfInstantiation, EnumDecl *Instantiation, EnumDecl *Pattern, const MultiLevelTemplateArgumentList &TemplateArgs, TemplateSpecializationKind TSK)
Instantiate the definition of an enum from a given pattern.
void UpdateExceptionSpec(FunctionDecl *FD, const FunctionProtoType::ExceptionSpecInfo &ESI)
ExprResult SubstCXXIdExpr(Expr *E, const MultiLevelTemplateArgumentList &TemplateArgs)
Substitute an expression as if it is a address-of-operand, which makes it act like a CXXIdExpression ...
std::string getTemplateArgumentBindingsText(const TemplateParameterList *Params, const TemplateArgumentList &Args)
Produces a formatted string that describes the binding of template parameters to template arguments.
ExprResult BuildExpressionFromDeclTemplateArgument(const TemplateArgument &Arg, QualType ParamType, SourceLocation Loc, NamedDecl *TemplateParam=nullptr)
Given a non-type template argument that refers to a declaration and the type of its corresponding non...
bool SubstBaseSpecifiers(CXXRecordDecl *Instantiation, CXXRecordDecl *Pattern, const MultiLevelTemplateArgumentList &TemplateArgs)
Perform substitution on the base class specifiers of the given class template specialization.
void PerformDependentDiagnostics(const DeclContext *Pattern, const MultiLevelTemplateArgumentList &TemplateArgs)
TypeSourceInfo * CheckPackExpansion(TypeSourceInfo *Pattern, SourceLocation EllipsisLoc, UnsignedOrNone NumExpansions)
Construct a pack expansion type from the pattern of the pack expansion.
ASTMutationListener * getASTMutationListener() const
ExprResult ActOnFinishFullExpr(Expr *Expr, bool DiscardedValue)
TypeSourceInfo * SubstFunctionDeclType(TypeSourceInfo *T, const MultiLevelTemplateArgumentList &TemplateArgs, SourceLocation Loc, DeclarationName Entity, CXXRecordDecl *ThisContext, Qualifiers ThisTypeQuals, bool EvaluateConstraints=true)
A form of SubstType intended specifically for instantiating the type of a FunctionDecl.
Encodes a location in the source.
unsigned getExpansionLineNumber(SourceLocation Loc, bool *Invalid=nullptr) const
StringRef getFilename(SourceLocation SpellingLoc) const
Return the filename of the file containing a SourceLocation.
SourceLocation getExpansionLoc(SourceLocation Loc) const
Given a SourceLocation object Loc, return the expansion location referenced by the ID.
A trivial tuple used to represent a source range.
SourceLocation getBegin() const
void warnOnStackNearlyExhausted(SourceLocation Loc)
Check to see if we're low on stack space and produce a warning if we're low on stack space (Currently...
Represents a C++11 static_assert declaration.
Stmt - This represents one statement.
SourceLocation getEndLoc() const LLVM_READONLY
void printPretty(raw_ostream &OS, PrinterHelper *Helper, const PrintingPolicy &Policy, unsigned Indentation=0, StringRef NewlineSymbol="\n", const ASTContext *Context=nullptr) const
SourceRange getSourceRange() const LLVM_READONLY
SourceLocation tokens are not useful in isolation - they are low level value objects created/interpre...
SourceLocation getBeginLoc() const LLVM_READONLY
Wrapper for substituted template type parameters.
Represents the result of substituting a builtin template as a pack.
Represents a reference to a non-type template parameter that has been substituted with a template arg...
Represents a reference to a non-type template parameter pack that has been substituted with a non-tem...
TemplateArgument getArgumentPack() const
A structure for storing an already-substituted template template parameter pack.
Wrapper for substituted template type parameters.
Represents the result of substituting a set of types for a template type parameter pack.
Wrapper for substituted template type parameters.
Represents the declaration of a struct/union/class/enum.
void setTagKind(TagKind TK)
SourceRange getBraceRange() const
SourceLocation getInnerLocStart() const
Return SourceLocation representing start of source range ignoring outer template declarations.
void startDefinition()
Starts the definition of this tag declaration.
TagKind getTagKind() const
void setBraceRange(SourceRange R)
SourceLocation getNameLoc() const
const llvm::Triple & getTriple() const
Returns the target triple of the primary target.
A convenient class for passing around template argument information.
void setLAngleLoc(SourceLocation Loc)
void setRAngleLoc(SourceLocation Loc)
A template argument list.
ArrayRef< TemplateArgument > asArray() const
Produce this as an array ref.
Location wrapper for a TemplateArgument.
const TemplateArgument & getArgument() const
Represents a template argument.
ArrayRef< TemplateArgument > getPackAsArray() const
Return the array of arguments in this template argument pack.
Expr * getAsExpr() const
Retrieve the template argument as an expression.
bool isDependent() const
Whether this template argument is dependent on a template parameter such that its result can change f...
pack_iterator pack_begin() const
Iterator referencing the first argument of a template argument pack.
QualType getAsType() const
Retrieve the type for a type template argument.
TemplateName getAsTemplate() const
Retrieve the template name for a template name argument.
TemplateArgument getPackExpansionPattern() const
When the template argument is a pack expansion, returns the pattern of the pack expansion.
bool isNull() const
Determine whether this template argument has no value.
unsigned pack_size() const
The number of template arguments in the given template argument pack.
@ Declaration
The template argument is a declaration that was provided for a pointer, reference,...
@ Template
The template argument is a template name that was provided for a template template parameter.
@ Pack
The template argument is actually a parameter pack.
@ NullPtr
The template argument is a null pointer or null pointer to member that was provided for a non-type te...
@ Type
The template argument is a type.
@ Expression
The template argument is an expression, and we've not resolved it to one of the other forms yet,...
ArgKind getKind() const
Return the kind of stored template argument.
bool isPackExpansion() const
Determine whether this template argument is a pack expansion.
void enableLateAttributeInstantiation(Sema::LateInstantiatedAttrVec *LA)
void disableLateAttributeInstantiation()
delayed_var_partial_spec_iterator delayed_var_partial_spec_end()
delayed_partial_spec_iterator delayed_partial_spec_begin()
Return an iterator to the beginning of the set of "delayed" partial specializations,...
void setEvaluateConstraints(bool B)
SmallVectorImpl< std::pair< VarTemplateDecl *, VarTemplatePartialSpecializationDecl * > >::iterator delayed_var_partial_spec_iterator
LocalInstantiationScope * getStartingScope() const
VarTemplatePartialSpecializationDecl * InstantiateVarTemplatePartialSpecialization(VarTemplateDecl *VarTemplate, VarTemplatePartialSpecializationDecl *PartialSpec)
Instantiate the declaration of a variable template partial specialization.
SmallVectorImpl< std::pair< ClassTemplateDecl *, ClassTemplatePartialSpecializationDecl * > >::iterator delayed_partial_spec_iterator
void InstantiateEnumDefinition(EnumDecl *Enum, EnumDecl *Pattern)
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...
delayed_var_partial_spec_iterator delayed_var_partial_spec_begin()
ClassTemplatePartialSpecializationDecl * InstantiateClassTemplatePartialSpecialization(ClassTemplateDecl *ClassTemplate, ClassTemplatePartialSpecializationDecl *PartialSpec)
Instantiate the declaration of a class template partial specialization.
The base class of all kinds of template declarations (e.g., class, function, etc.).
TemplateParameterList * getTemplateParameters() const
Get the list of template parameters.
Represents a C++ template name within the type system.
@ Template
A single template declaration.
Stores a list of template parameters for a TemplateDecl and its derived classes.
NamedDecl * getParam(unsigned Idx)
SourceRange getSourceRange() const LLVM_READONLY
SourceLocation getTemplateLoc() const
TemplateSpecCandidateSet - A set of generalized overload candidates, used in template specializations...
SourceLocation getLocation() const
TemplateSpecCandidate & addCandidate()
Add a new candidate with NumConversions conversion sequence slots to the overload set.
TemplateTemplateParmDecl - Declares a template template parameter, e.g., "T" in.
unsigned getDepth() const
Get the nesting depth of the template parameter.
Declaration of a template type parameter.
void setTypeConstraint(ConceptReference *CR, Expr *ImmediatelyDeclaredConstraint, UnsignedOrNone ArgPackSubstIndex)
bool isParameterPack() const
Returns whether this is a parameter pack.
Wrapper for template type parameters.
bool isParameterPack() const
unsigned getIndex() const
unsigned getDepth() const
Declaration of an alias template.
TypeAliasDecl * getTemplatedDecl() const
Get the underlying function declaration of the template.
Models the abbreviated syntax to constrain a template type parameter: template <convertible_to<string...
const ASTTemplateArgumentListInfo * getTemplateArgsAsWritten() const
UnsignedOrNone getArgPackSubstIndex() const
Expr * getImmediatelyDeclaredConstraint() const
Get the immediately-declared constraint expression introduced by this type-constraint,...
const NestedNameSpecifierLoc & getNestedNameSpecifierLoc() const
TemplateDecl * getNamedConcept() const
const DeclarationNameInfo & getConceptNameInfo() const
ConceptReference * getConceptReference() const
void setLocStart(SourceLocation L)
TyLocType push(QualType T)
Pushes space for a new TypeLoc of the given type.
void pushFullCopy(TypeLoc L)
Pushes a copy of the given TypeLoc onto this builder.
void reserve(size_t Requested)
Ensures that this buffer has at least as much capacity as described.
TypeSourceInfo * getTypeSourceInfo(ASTContext &Context, QualType T)
Creates a TypeSourceInfo for the given type.
void pushTrivial(ASTContext &Context, QualType T, SourceLocation Loc)
Pushes 'T' with all locations pointing to 'Loc'.
Base wrapper for a particular "section" of type source info.
QualType getType() const
Get the type for which this source info wrapper provides information.
T getAs() const
Convert to the specified TypeLoc type, returning a null TypeLoc if this TypeLoc is not of the desired...
TypeLoc IgnoreParens() const
T castAs() const
Convert to the specified TypeLoc type, asserting that this TypeLoc is of the desired type.
SourceRange getSourceRange() const LLVM_READONLY
Get the full source range.
unsigned getFullDataSize() const
Returns the size of the type source info data block.
SourceLocation getBeginLoc() const
Get the begin source location.
A container of type source information.
TypeLoc getTypeLoc() const
Return the TypeLoc wrapper for the type source info.
QualType getType() const
Return the type wrapped by this type source info.
SourceLocation getNameLoc() const
void setNameLoc(SourceLocation Loc)
The base class of the type hierarchy.
bool isReferenceType() const
QualType getPointeeType() const
If this is a pointer, ObjC object pointer, or block pointer, this returns the respective pointee.
bool isInstantiationDependentType() const
Determine whether this type is an instantiation-dependent type, meaning that the type involves a temp...
bool isDependentType() const
Whether this type is a dependent type, meaning that its definition somehow depends on a template para...
bool containsUnexpandedParameterPack() const
Whether this type is or contains an unexpanded parameter pack, used to support C++0x variadic templat...
bool isVariablyModifiedType() const
Whether this type is a variably-modified type (C99 6.7.5).
const T * getAs() const
Member-template getAs<specific type>'.
bool isRecordType() const
QualType getUnderlyingType() const
Represent the declaration of a variable (in which case it is an lvalue) a function (in which case it ...
bool isParameterPack() const
Determine whether this value is actually a function parameter pack, init-capture pack,...
Represents a variable declaration or definition.
bool isStaticDataMember() const
Determines whether this is a static data member.
VarDecl * getDefinition(ASTContext &)
Get the real (not just tentative) definition for this declaration.
VarDecl * getInstantiatedFromStaticDataMember() const
If this variable is an instantiated static data member of a class template specialization,...
void setTemplateSpecializationKind(TemplateSpecializationKind TSK, SourceLocation PointOfInstantiation=SourceLocation())
For a static data member that was instantiated from a static data member of a class template,...
StorageClass getStorageClass() const
Returns the storage class as written in the source.
MemberSpecializationInfo * getMemberSpecializationInfo() const
If this variable is an instantiation of a static data member of a class template specialization,...
Declaration of a variable template.
Represents a variable template specialization, which refers to a variable template with a given set o...
const TemplateArgumentList & getTemplateInstantiationArgs() const
Retrieve the set of template arguments that should be used to instantiate the initializer of the vari...
bool isClassScopeExplicitSpecialization() const
llvm::PointerUnion< VarTemplateDecl *, VarTemplatePartialSpecializationDecl * > getSpecializedTemplateOrPartial() const
Retrieve the variable template or variable template partial specialization which was specialized by t...
TemplateSpecializationKind getSpecializationKind() const
Determine the kind of specialization that this declaration represents.
VarTemplateDecl * getSpecializedTemplate() const
Retrieve the template that this specialization specializes.
Represents a GCC generic vector type.
A requires-expression requirement which queries the validity and properties of an expression ('simple...
SubstitutionDiagnostic * getExprSubstitutionDiagnostic() const
bool isExprSubstitutionFailure() const
const ReturnTypeRequirement & getReturnTypeRequirement() const
SourceLocation getNoexceptLoc() const
A requires-expression requirement which is satisfied when a general constraint expression is satisfie...
const ASTConstraintSatisfaction & getConstraintSatisfaction() const
bool hasInvalidConstraint() const
Expr * getConstraintExpr() const
StringRef getInvalidConstraintEntity()
A static requirement that can be used in a requires-expression to check properties of types and expre...
A requires-expression requirement which queries the existence of a type name or type template special...
bool isSubstitutionFailure() const
SubstitutionDiagnostic * getSubstitutionDiagnostic() const
TypeSourceInfo * getType() const
CXXMethodDecl * CallOperator
The lambda's compiler-generated operator().
Provides information about an attempted template argument deduction, whose success or failure was des...
TemplateArgumentList * takeCanonical()
SourceLocation getLocation() const
Returns the location at which template argument is occurring.
bool hasSFINAEDiagnostic() const
Is a SFINAE diagnostic available?
void takeSFINAEDiagnostic(PartialDiagnosticAt &PD)
Take ownership of the SFINAE diagnostic.
bool hasStrictPackMatch() const
Defines the clang::TargetInfo interface.
Attr * instantiateTemplateAttribute(const Attr *At, ASTContext &C, Sema &S, const MultiLevelTemplateArgumentList &TemplateArgs)
Attr * instantiateTemplateAttributeForDecl(const Attr *At, ASTContext &C, Sema &S, const MultiLevelTemplateArgumentList &TemplateArgs)
The JSON file list parser is used to communicate input to InstallAPI.
void atTemplateEnd(TemplateInstantiationCallbackPtrs &Callbacks, const Sema &TheSema, const Sema::CodeSynthesisContext &Inst)
void atTemplateBegin(TemplateInstantiationCallbackPtrs &Callbacks, const Sema &TheSema, const Sema::CodeSynthesisContext &Inst)
@ Specialization
We are substituting template parameters for template arguments in order to form a template specializa...
NamedDecl * getAsNamedDecl(TemplateParameter P)
std::pair< llvm::PointerUnion< const TemplateTypeParmType *, NamedDecl *, const TemplateSpecializationType *, const SubstBuiltinTemplatePackType * >, SourceLocation > UnexpandedParameterPack
bool isPackProducingBuiltinTemplateName(TemplateName N)
bool isGenericLambdaCallOperatorOrStaticInvokerSpecialization(const DeclContext *DC)
bool isLambdaCallOperator(const CXXMethodDecl *MD)
@ Result
The result type of a method or function.
std::pair< unsigned, unsigned > getDepthAndIndex(const NamedDecl *ND)
Retrieve the depth and index of a template parameter.
@ Template
We are parsing a template declaration.
DeductionFailureInfo MakeDeductionFailureInfo(ASTContext &Context, TemplateDeductionResult TDK, sema::TemplateDeductionInfo &Info)
Convert from Sema's representation of template deduction information to the form used in overload-can...
llvm::PointerUnion< TemplateTypeParmDecl *, NonTypeTemplateParmDecl *, TemplateTemplateParmDecl * > TemplateParameter
Stores a template parameter of any kind.
@ VK_PRValue
A pr-value expression (in the C++11 taxonomy) produces a temporary value.
@ VK_LValue
An l-value expression is a reference to an object with independent storage.
const FunctionProtoType * T
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.
std::pair< SourceLocation, PartialDiagnostic > PartialDiagnosticAt
A partial diagnostic along with the source location where this diagnostic occurs.
TemplateDeductionResult
Describes the result of template argument deduction.
@ Success
Template argument deduction was successful.
TemplateSpecializationKind
Describes the kind of template specialization that a particular template specialization declaration r...
@ TSK_ExplicitInstantiationDefinition
This template specialization was instantiated from a template due to an explicit instantiation defini...
@ TSK_ExplicitInstantiationDeclaration
This template specialization was instantiated from a template due to an explicit instantiation declar...
@ TSK_ExplicitSpecialization
This template specialization was declared or defined by an explicit specialization (C++ [temp....
@ TSK_ImplicitInstantiation
This template specialization was implicitly instantiated from a template.
@ TSK_Undeclared
This template specialization was formed from a template-id but has not yet been declared,...
@ Enum
The "enum" keyword introduces the elaborated-type-specifier.
@ EST_Uninstantiated
not instantiated yet
@ EST_None
no exception specification
__DEVICE__ _Tp arg(const std::complex< _Tp > &__c)
Represents an explicit template argument list in C++, e.g., the "<int>" in "sort<int>".
SourceLocation RAngleLoc
The source location of the right angle bracket ('>').
SourceLocation LAngleLoc
The source location of the left angle bracket ('<').
ArrayRef< TemplateArgumentLoc > arguments() const
DeclarationNameInfo - A collector data type for bundling together a DeclarationName and the correspon...
SourceLocation getLoc() const
getLoc - Returns the main location of the declaration name.
DeclarationName getName() const
getName - Returns the embedded declaration name.
Holds information about the various types of exception specification.
ExceptionSpecificationType Type
The kind of exception specification this is.
ExceptionSpecInfo ExceptionSpec
A context in which code is being synthesized (where a source location alone is not sufficient to iden...
SourceRange InstantiationRange
The source range that covers the construct that cause the instantiation, e.g., the template-id that c...
enum clang::Sema::CodeSynthesisContext::SynthesisKind Kind
const TemplateArgument * TemplateArgs
The list of template arguments we are substituting, if they are not part of the entity.
sema::TemplateDeductionInfo * DeductionInfo
The template deduction info object associated with the substitution or checking of explicit or deduce...
NamedDecl * Template
The template (or partial specialization) in which we are performing the instantiation,...
SourceLocation PointOfInstantiation
The point of instantiation or synthesis within the source code.
SynthesisKind
The kind of template instantiation we are performing.
@ MarkingClassDllexported
We are marking a class as __dllexport.
@ RequirementParameterInstantiation
@ DefaultTemplateArgumentInstantiation
We are instantiating a default argument for a template parameter.
@ ExplicitTemplateArgumentSubstitution
We are substituting explicit template arguments provided for a function template.
@ DefaultTemplateArgumentChecking
We are checking the validity of a default template argument that has been used when naming a template...
@ InitializingStructuredBinding
We are initializing a structured binding.
@ ExceptionSpecInstantiation
We are instantiating the exception specification for a function template which was deferred until it ...
@ NestedRequirementConstraintsCheck
We are checking the satisfaction of a nested requirement of a requires expression.
@ BuildingBuiltinDumpStructCall
We are building an implied call from __builtin_dump_struct.
@ ParameterMappingSubstitution
@ DefiningSynthesizedFunction
We are defining a synthesized function (such as a defaulted special member).
@ Memoization
Added for Template instantiation observation.
@ ConstraintNormalization
@ LambdaExpressionSubstitution
We are substituting into a lambda expression.
@ TypeAliasTemplateInstantiation
We are instantiating a type alias template declaration.
@ BuildingDeductionGuides
We are building deduction guides for a class.
@ PartialOrderingTTP
We are performing partial ordering for template template parameters.
@ DeducedTemplateArgumentSubstitution
We are substituting template argument determined as part of template argument deduction for either a ...
@ PriorTemplateArgumentSubstitution
We are substituting prior template arguments into a new template parameter.
@ ExceptionSpecEvaluation
We are computing the exception specification for a defaulted special member function.
@ TemplateInstantiation
We are instantiating a template declaration.
@ DeclaringSpecialMember
We are declaring an implicit special member function.
@ DeclaringImplicitEqualityComparison
We are declaring an implicit 'operator==' for a defaulted 'operator<=>'.
@ DefaultFunctionArgumentInstantiation
We are instantiating a default argument for a function.
@ RewritingOperatorAsSpaceship
We are rewriting a comparison operator in terms of an operator<=>.
@ RequirementInstantiation
We are instantiating a requirement of a requires expression.
Decl * Entity
The entity that is being synthesized.
bool isInstantiationRecord() const
Determines whether this template is an actual instantiation that should be counted toward the maximum...
A stack object to be created when performing template instantiation.
bool isInvalid() const
Determines whether we have exceeded the maximum recursive template instantiations.
InstantiatingTemplate(Sema &SemaRef, SourceLocation PointOfInstantiation, Decl *Entity, SourceRange InstantiationRange=SourceRange())
Note that we are instantiating a class template, function template, variable template,...
void Clear()
Note that we have finished instantiating this template.
bool isAlreadyInstantiating() const
Determine whether we are already instantiating this specialization in some surrounding active instant...
void set(DeclAccessPair Found, Decl *Spec, DeductionFailureInfo Info)
bool ExpandUnderForgetSubstitions
UnsignedOrNone NumExpansions