36#include "llvm/ADT/SmallVectorExtras.h"
37#include "llvm/ADT/StringExtras.h"
38#include "llvm/Support/ErrorHandling.h"
39#include "llvm/Support/SaveAndRestore.h"
40#include "llvm/Support/TimeProfiler.h"
53 const Decl *NextDecl =
nullptr;
55 bool ClearRelativeToPrimary =
true;
56 static Response Done() {
61 static Response ChangeDecl(
const Decl *ND) {
66 static Response ChangeDecl(
const DeclContext *Ctx) {
72 static Response UseNextDecl(
const Decl *CurDecl) {
76 static Response DontClearRelativeToPrimaryNextDecl(
const Decl *CurDecl) {
77 Response R = Response::UseNextDecl(CurDecl);
78 R.ClearRelativeToPrimary =
false;
87getPrimaryTemplateOfGenericLambda(
const FunctionDecl *LambdaCallOperator) {
89 return LambdaCallOperator;
91 if (
auto *FTD = dyn_cast_if_present<FunctionTemplateDecl>(
93 FTD && FTD->getInstantiatedFromMemberTemplate()) {
95 FTD->getInstantiatedFromMemberTemplate()->getTemplatedDecl();
102 ->getInstantiatedFromMemberFunction())
103 LambdaCallOperator = Prev;
107 return LambdaCallOperator;
110struct EnclosingTypeAliasTemplateDetails {
120EnclosingTypeAliasTemplateDetails
121getEnclosingTypeAliasTemplateDecl(
Sema &SemaRef) {
124 TypeAliasTemplateInstantiation)
126 EnclosingTypeAliasTemplateDetails Result;
128 *
Next = TATD->getInstantiatedFromMemberTemplate();
132 CSC.template_arguments(),
135 Result.PrimaryTypeAliasDecl =
Next;
136 Next =
Next->getInstantiatedFromMemberTemplate();
149bool isLambdaEnclosedByTypeAliasDecl(
153 Visitor(
const FunctionDecl *CallOperator) : CallOperator(CallOperator) {}
154 bool VisitLambdaExpr(
LambdaExpr *LE)
override {
157 return getPrimaryTemplateOfGenericLambda(LE->getCallOperator()) !=
166 return !Visitor(getPrimaryTemplateOfGenericLambda(LambdaCallOperator))
167 .TraverseType(Underlying);
174 bool SkipForSpecialization) {
178 return Response::DontClearRelativeToPrimaryNextDecl(VarTemplSpec);
183 return Response::Done();
188 llvm::PointerUnion<VarTemplateDecl *, VarTemplatePartialSpecializationDecl *>
191 dyn_cast<VarTemplatePartialSpecializationDecl *>(Specialized)) {
192 if (!SkipForSpecialization)
193 Result.addOuterTemplateArguments(
196 if (Partial->isMemberSpecialization())
197 return Response::Done();
200 if (!SkipForSpecialization)
201 Result.addOuterTemplateArguments(
205 return Response::Done();
207 return Response::DontClearRelativeToPrimaryNextDecl(VarTemplSpec);
219 for (
unsigned I = 0, N = TTP->
getDepth() + 1; I != N; ++I)
220 Result.addOuterTemplateArguments(std::nullopt);
221 return Response::Done();
224Response HandlePartialClassTemplateSpec(
227 if (!SkipForSpecialization)
229 return Response::Done();
236 bool SkipForSpecialization) {
241 return Response::Done();
243 if (!SkipForSpecialization)
244 Result.addOuterTemplateArguments(
253 return Response::Done();
259 if (
auto *InstFromPartialTempl =
260 dyn_cast<ClassTemplatePartialSpecializationDecl *>(
262 return Response::ChangeDecl(
263 InstFromPartialTempl->getLexicalDeclContext());
265 return Response::UseNextDecl(ClassTemplSpec);
271 bool ForConstraintInstantiation,
272 bool ForDefaultArgumentSubstitution) {
274 if (!RelativeToPrimary &&
275 Function->getTemplateSpecializationKindForInstantiation() ==
277 return Response::Done();
279 if (!RelativeToPrimary &&
284 return Response::UseNextDecl(Function);
286 Function->getTemplateSpecializationArgs()) {
288 Result.addOuterTemplateArguments(
const_cast<FunctionDecl *
>(Function),
289 TemplateArgs->asArray(),
292 if (RelativeToPrimary &&
293 (Function->getTemplateSpecializationKind() ==
295 (Function->getFriendObjectKind() &&
296 !Function->getPrimaryTemplate()->getFriendObjectKind())))
297 return Response::UseNextDecl(Function);
301 assert(Function->getPrimaryTemplate() &&
"No function template?");
302 if (!ForDefaultArgumentSubstitution &&
303 Function->getPrimaryTemplate()->isMemberSpecialization())
304 return Response::Done();
307 if (!ForConstraintInstantiation &&
309 return Response::Done();
311 }
else if (
auto *
Template = Function->getDescribedFunctionTemplate()) {
313 (ForConstraintInstantiation || Result.getNumSubstitutedLevels() == 0) &&
314 "Outer template not instantiated?");
315 if (ForConstraintInstantiation) {
323 Result.addOuterTemplateArguments(
Template, Inst.template_arguments(),
334 if ((Function->getFriendObjectKind() || Function->isLocalExternDecl()) &&
335 Function->getNonTransparentDeclContext()->isFileContext() &&
337 return Response::ChangeDecl(Function->getLexicalDeclContext());
340 if (ForConstraintInstantiation && Function->getFriendObjectKind())
341 return Response::ChangeDecl(Function->getLexicalDeclContext());
342 return Response::UseNextDecl(Function);
345Response HandleFunctionTemplateDecl(
Sema &SemaRef,
349 Result.addOuterTemplateArguments(
362 Ty = std::exchange(NextTy,
nullptr)) {
365 NextTy = P.getAsType();
366 const auto *TSTy = dyn_cast<TemplateSpecializationType>(Ty);
388 if (TSTy->isCurrentInstantiation()) {
389 auto *RD = TSTy->getCanonicalTypeInternal()->getAsCXXRecordDecl();
391 Arguments = CTD->getInjectedTemplateArgs(SemaRef.
Context);
393 dyn_cast<ClassTemplateSpecializationDecl>(RD))
394 Arguments =
Specialization->getTemplateInstantiationArgs().asArray();
396 Result.addOuterTemplateArguments(
397 TSTy->getTemplateName().getAsTemplateDecl(), Arguments,
408 bool ForConstraintInstantiation) {
411 (ForConstraintInstantiation || Result.getNumSubstitutedLevels() == 0) &&
412 "Outer template not instantiated?");
413 if (ClassTemplate->isMemberSpecialization())
414 return Response::Done();
415 if (ForConstraintInstantiation)
416 Result.addOuterTemplateArguments(
418 ClassTemplate->getInjectedTemplateArgs(SemaRef.
Context),
425 return Response::Done();
430 if (ForConstraintInstantiation && IsFriend &&
439 return Response::ChangeDecl(LCD);
443 if (
auto TypeAlias = getEnclosingTypeAliasTemplateDecl(SemaRef);
444 ForConstraintInstantiation &&
TypeAlias) {
447 Result.addOuterTemplateArguments(
TypeAlias.Template,
463 return Response::ChangeDecl(
TypeAlias.Template->getDeclContext());
468 return Response::UseNextDecl(Rec);
471Response HandleImplicitConceptSpecializationDecl(
474 Result.addOuterTemplateArguments(
478 return Response::UseNextDecl(CSD);
481Response HandleGenericDeclContext(
const Decl *CurDecl) {
482 return Response::UseNextDecl(CurDecl);
490 const FunctionDecl *Pattern,
bool ForConstraintInstantiation,
491 bool SkipForSpecialization,
bool ForDefaultArgumentSubstitution) {
492 assert((ND || DC) &&
"Can't find arguments for a decl if one isn't provided");
497 const Decl *CurDecl = ND;
500 Result.addOuterTemplateArguments(
const_cast<NamedDecl *
>(ND), *Innermost,
510 if (
const auto *TTP = dyn_cast<TemplateTemplateParmDecl>(CurDecl))
511 HandleDefaultTempArgIntoTempTempParam(TTP,
Result);
513 : Response::UseNextDecl(CurDecl).NextDecl;
519 if (
const auto *VarTemplSpec =
520 dyn_cast<VarTemplateSpecializationDecl>(CurDecl)) {
521 R = HandleVarTemplateSpec(VarTemplSpec,
Result, SkipForSpecialization);
522 }
else if (
const auto *PartialClassTemplSpec =
523 dyn_cast<ClassTemplatePartialSpecializationDecl>(CurDecl)) {
524 R = HandlePartialClassTemplateSpec(PartialClassTemplSpec,
Result,
525 SkipForSpecialization);
526 }
else if (
const auto *ClassTemplSpec =
527 dyn_cast<ClassTemplateSpecializationDecl>(CurDecl)) {
528 R = HandleClassTemplateSpec(ClassTemplSpec,
Result,
529 SkipForSpecialization);
530 }
else if (
const auto *
Function = dyn_cast<FunctionDecl>(CurDecl)) {
531 R = HandleFunction(*
this,
Function,
Result, Pattern, RelativeToPrimary,
532 ForConstraintInstantiation,
533 ForDefaultArgumentSubstitution);
534 }
else if (
const auto *Rec = dyn_cast<CXXRecordDecl>(CurDecl)) {
536 ForConstraintInstantiation);
537 }
else if (
const auto *CSD =
538 dyn_cast<ImplicitConceptSpecializationDecl>(CurDecl)) {
539 R = HandleImplicitConceptSpecializationDecl(CSD,
Result);
540 }
else if (
const auto *FTD = dyn_cast<FunctionTemplateDecl>(CurDecl)) {
541 R = HandleFunctionTemplateDecl(*
this, FTD,
Result);
542 }
else if (
const auto *CTD = dyn_cast<ClassTemplateDecl>(CurDecl)) {
543 R = Response::ChangeDecl(CTD->getLexicalDeclContext());
545 R = Response::DontClearRelativeToPrimaryNextDecl(CurDecl);
546 if (
const auto *TTP = dyn_cast<TemplateTemplateParmDecl>(CurDecl)) {
547 R = HandleDefaultTempArgIntoTempTempParam(TTP,
Result);
550 R = HandleGenericDeclContext(CurDecl);
555 if (R.ClearRelativeToPrimary)
556 RelativeToPrimary =
false;
558 CurDecl = R.NextDecl;
603 llvm_unreachable(
"Invalid SynthesisKind!");
614 if (
SemaRef.Diags.hasFatalErrorOccurred() &&
615 SemaRef.hasUncompilableErrorOccurred()) {
628 Inst.InConstraintSubstitution =
630 Inst.InParameterMappingSubstitution =
632 if (!
SemaRef.CodeSynthesisContexts.empty()) {
633 Inst.InConstraintSubstitution |=
634 SemaRef.CodeSynthesisContexts.back().InConstraintSubstitution;
635 Inst.InParameterMappingSubstitution |=
636 SemaRef.CodeSynthesisContexts.back().InParameterMappingSubstitution;
647 PointOfInstantiation, InstantiationRange, Entity) {}
654 PointOfInstantiation, InstantiationRange, Entity) {}
693 PointOfInstantiation, InstantiationRange, PartialSpec,
nullptr,
702 PointOfInstantiation, InstantiationRange, PartialSpec,
nullptr,
711 PointOfInstantiation, InstantiationRange, Param,
nullptr,
721 PointOfInstantiation, InstantiationRange, Param,
Template,
731 PointOfInstantiation, InstantiationRange, Param,
Template,
740 PointOfInstantiation, InstantiationRange, Entity,
749 PointOfInstantiation, InstantiationRange, Param,
Template,
757 PointOfInstantiation, InstantiationRange,
nullptr,
766 PointOfInstantiation, InstantiationRange,
nullptr,
775 PointOfInstantiation, InstantiationRange,
nullptr,
783 PointOfInstantiation, InstantiationRange,
nullptr,
808 PointOfInstantiation, InstantiationRange,
Template) {}
815 PointOfInstantiation, InstantiationRange, Entity) {}
821 ArgLoc, InstantiationRange, PArg) {}
827 assert(
SemaRef.NonInstantiationEntries <=
828 SemaRef.CodeSynthesisContexts.size());
829 if ((
SemaRef.CodeSynthesisContexts.size() -
830 SemaRef.NonInstantiationEntries) >
831 SemaRef.getLangOpts().InstantiationDepth) {
833 diag::err_template_recursion_depth_exceeded)
836 diag::note_template_recursion_depth)
837 <<
SemaRef.getLangOpts().InstantiationDepth;
852 if (!Active.isInstantiationRecord()) {
860 "forgot to remove a lookup module for a template instantiation");
879 SemaRef.popCodeSynthesisContext();
887 llvm::raw_string_ostream
OS(
Result);
888 llvm::ListSeparator Comma;
889 for (
const Expr *Arg : Args) {
891 Arg->IgnoreParens()->printPretty(
OS,
nullptr,
901 llvm::raw_string_ostream
OS(
Result);
902 llvm::ListSeparator Comma;
904 for (
const Expr *Arg : Args) {
906 const char *ValueCategory =
908 : (EVK ==
VK_XValue ?
"xvalue" :
"prvalue"));
909 OS << Comma << ValueCategory <<
" of type '";
920 unsigned Limit =
Diags.getTemplateBacktraceLimit();
922 SkipStart = Limit / 2 + Limit % 2;
927 unsigned InstantiationIdx = 0;
932 ++Active, ++InstantiationIdx) {
934 if (InstantiationIdx >= SkipStart && InstantiationIdx < SkipEnd) {
935 if (InstantiationIdx == SkipStart) {
937 DiagFunc(Active->PointOfInstantiation,
938 PDiag(diag::note_instantiation_contexts_suppressed)
944 switch (Active->Kind) {
946 Decl *D = Active->Entity;
948 unsigned DiagID = diag::note_template_member_class_here;
950 DiagID = diag::note_template_class_instantiation_here;
951 DiagFunc(Active->PointOfInstantiation,
952 PDiag(DiagID) <<
Record << Active->InstantiationRange);
956 DiagID = diag::note_function_template_spec_here;
958 DiagID = diag::note_template_member_function_here;
959 DiagFunc(Active->PointOfInstantiation,
961 }
else if (
VarDecl *VD = dyn_cast<VarDecl>(D)) {
962 DiagFunc(Active->PointOfInstantiation,
963 PDiag(VD->isStaticDataMember()
964 ? diag::note_template_static_data_member_def_here
965 : diag::note_template_variable_def_here)
966 << VD << Active->InstantiationRange);
967 }
else if (
EnumDecl *ED = dyn_cast<EnumDecl>(D)) {
968 DiagFunc(Active->PointOfInstantiation,
969 PDiag(diag::note_template_enum_def_here)
970 << ED << Active->InstantiationRange);
971 }
else if (
FieldDecl *FD = dyn_cast<FieldDecl>(D)) {
972 DiagFunc(Active->PointOfInstantiation,
973 PDiag(diag::note_template_nsdmi_here)
974 << FD << Active->InstantiationRange);
976 DiagFunc(Active->PointOfInstantiation,
977 PDiag(diag::note_template_class_instantiation_here)
978 << CTD << Active->InstantiationRange);
986 llvm::raw_svector_ostream
OS(TemplateArgsStr);
988 printTemplateArgumentList(
OS, Active->template_arguments(),
990 DiagFunc(Active->PointOfInstantiation,
991 PDiag(diag::note_default_arg_instantiation_here)
992 <<
OS.str() << Active->InstantiationRange);
998 DiagFunc(Active->PointOfInstantiation,
999 PDiag(diag::note_explicit_template_arg_substitution_here)
1003 Active->NumTemplateArgs)
1004 << Active->InstantiationRange);
1010 dyn_cast<FunctionTemplateDecl>(Active->Entity)) {
1012 Active->PointOfInstantiation,
1013 PDiag(diag::note_function_template_deduction_instantiation_here)
1016 FnTmpl->getTemplateParameters(), Active->TemplateArgs,
1017 Active->NumTemplateArgs)
1018 << Active->InstantiationRange);
1022 bool IsTemplate =
false;
1024 if (
auto *D = dyn_cast<TemplateDecl>(Active->Entity)) {
1026 Params = D->getTemplateParameters();
1027 }
else if (
auto *D = dyn_cast<ClassTemplatePartialSpecializationDecl>(
1029 Params = D->getTemplateParameters();
1030 }
else if (
auto *D = dyn_cast<VarTemplatePartialSpecializationDecl>(
1032 Params = D->getTemplateParameters();
1034 llvm_unreachable(
"unexpected template kind");
1037 DiagFunc(Active->PointOfInstantiation,
1038 PDiag(diag::note_deduced_template_arg_substitution_here)
1041 Active->TemplateArgs,
1042 Active->NumTemplateArgs)
1043 << Active->InstantiationRange);
1053 llvm::raw_svector_ostream
OS(TemplateArgsStr);
1055 printTemplateArgumentList(
OS, Active->template_arguments(),
1057 DiagFunc(Active->PointOfInstantiation,
1058 PDiag(diag::note_default_function_arg_instantiation_here)
1059 <<
OS.str() << Active->InstantiationRange);
1067 Name = std::string(
" '") + Parm->
getName().str() +
"'";
1071 TemplateParams =
Template->getTemplateParameters();
1075 ->getTemplateParameters();
1076 DiagFunc(Active->PointOfInstantiation,
1077 PDiag(diag::note_prior_template_arg_substitution)
1080 Active->TemplateArgs,
1081 Active->NumTemplateArgs)
1082 << Active->InstantiationRange);
1089 TemplateParams =
Template->getTemplateParameters();
1093 ->getTemplateParameters();
1095 DiagFunc(Active->PointOfInstantiation,
1096 PDiag(diag::note_template_default_arg_checking)
1098 Active->TemplateArgs,
1099 Active->NumTemplateArgs)
1100 << Active->InstantiationRange);
1105 DiagFunc(Active->PointOfInstantiation,
1106 PDiag(diag::note_evaluating_exception_spec_here)
1111 DiagFunc(Active->PointOfInstantiation,
1112 PDiag(diag::note_template_exception_spec_instantiation_here)
1114 << Active->InstantiationRange);
1118 DiagFunc(Active->PointOfInstantiation,
1119 PDiag(diag::note_template_requirement_instantiation_here)
1120 << Active->InstantiationRange);
1123 DiagFunc(Active->PointOfInstantiation,
1124 PDiag(diag::note_template_requirement_params_instantiation_here)
1125 << Active->InstantiationRange);
1129 DiagFunc(Active->PointOfInstantiation,
1130 PDiag(diag::note_nested_requirement_here)
1131 << Active->InstantiationRange);
1135 DiagFunc(Active->PointOfInstantiation,
1136 PDiag(diag::note_in_declaration_of_implicit_special_member)
1138 << Active->SpecialMember);
1143 Active->Entity->getLocation(),
1144 PDiag(diag::note_in_declaration_of_implicit_equality_comparison));
1150 auto *FD = dyn_cast<FunctionDecl>(Active->Entity);
1155 FD ? FD->getDefaultedFunctionKind()
1159 DiagFunc(Active->PointOfInstantiation,
1160 PDiag(diag::note_member_synthesized_at)
1162 <<
Context.getCanonicalTagType(MD->getParent()));
1164 QualType RecordType = FD->getParamDecl(0)
1166 .getNonReferenceType()
1167 .getUnqualifiedType();
1168 DiagFunc(Active->PointOfInstantiation,
1169 PDiag(diag::note_comparison_synthesized_at)
1174 DiagFunc(Active->PointOfInstantiation,
1175 PDiag(diag::note_postfix_operator_synthesized_at)
1177 << FD->getReturnType().getUnqualifiedType());
1183 DiagFunc(Active->Entity->getLocation(),
1184 PDiag(diag::note_rewriting_operator_as_spaceship));
1188 DiagFunc(Active->PointOfInstantiation,
1189 PDiag(diag::note_in_binding_decl_init)
1194 DiagFunc(Active->PointOfInstantiation,
1195 PDiag(diag::note_due_to_dllexported_class)
1201 DiagFunc(Active->PointOfInstantiation,
1202 PDiag(diag::note_building_builtin_dump_struct_call)
1205 Active->NumCallArgs)));
1212 DiagFunc(Active->PointOfInstantiation,
1213 PDiag(diag::note_lambda_substitution_here));
1216 unsigned DiagID = 0;
1217 if (!Active->Entity) {
1218 DiagFunc(Active->PointOfInstantiation,
1219 PDiag(diag::note_nested_requirement_here)
1220 << Active->InstantiationRange);
1224 DiagID = diag::note_concept_specialization_here;
1226 DiagID = diag::note_checking_constraints_for_template_id_here;
1228 DiagID = diag::note_checking_constraints_for_var_spec_id_here;
1230 DiagID = diag::note_checking_constraints_for_class_spec_id_here;
1233 DiagID = diag::note_checking_constraints_for_function_here;
1236 llvm::raw_svector_ostream
OS(TemplateArgsStr);
1239 printTemplateArgumentList(
OS, Active->template_arguments(),
1242 DiagFunc(Active->PointOfInstantiation,
1243 PDiag(DiagID) <<
OS.str() << Active->InstantiationRange);
1247 DiagFunc(Active->PointOfInstantiation,
1248 PDiag(diag::note_constraint_substitution_here)
1249 << Active->InstantiationRange);
1252 DiagFunc(Active->PointOfInstantiation,
1253 PDiag(diag::note_parameter_mapping_substitution_here)
1254 << Active->InstantiationRange);
1257 DiagFunc(Active->PointOfInstantiation,
1258 PDiag(diag::note_building_deduction_guide_here));
1265 if (Active->NumTemplateArgs == 0)
1267 DiagFunc(Active->PointOfInstantiation,
1268 PDiag(diag::note_template_type_alias_instantiation_here)
1270 << Active->InstantiationRange);
1273 DiagFunc(Active->PointOfInstantiation,
1274 PDiag(diag::note_template_arg_template_params_mismatch));
1277 DiagFunc(ParamLoc,
PDiag(diag::note_template_prev_declaration)
1279 << Active->InstantiationRange);
1282 const auto *SKEPAttr =
1283 Active->Entity->getAttr<SYCLKernelEntryPointAttr>();
1284 assert(SKEPAttr &&
"Missing sycl_kernel_entry_point attribute");
1285 assert(!SKEPAttr->isInvalidAttr() &&
1286 "sycl_kernel_entry_point attribute is invalid");
1287 DiagFunc(SKEPAttr->getLocation(),
PDiag(diag::note_sycl_runtime_defect));
1288 DiagFunc(SKEPAttr->getLocation(),
1289 PDiag(diag::note_sycl_kernel_launch_lookup_here)
1290 <<
SYCL().GetSYCLKernelInfoClassSpecializationType(
1291 SKEPAttr->getKernelName()));
1295 const auto *SKEPAttr =
1296 Active->Entity->getAttr<SYCLKernelEntryPointAttr>();
1297 assert(SKEPAttr &&
"Missing sycl_kernel_entry_point attribute");
1298 assert(!SKEPAttr->isInvalidAttr() &&
1299 "sycl_kernel_entry_point attribute is invalid");
1300 DiagFunc(SKEPAttr->getLocation(),
PDiag(diag::note_sycl_runtime_defect));
1301 DiagFunc(SKEPAttr->getLocation(),
1302 PDiag(diag::note_sycl_kernel_launch_overload_resolution_here)
1303 <<
SYCL().GetSYCLKernelInfoClassSpecializationType(
1304 SKEPAttr->getKernelName())
1307 Active->NumCallArgs)));
1311 Diags.Report(Active->PointOfInstantiation,
1312 diag::note_expansion_stmt_instantiation_here);
1322 class TemplateInstantiator :
public TreeTransform<TemplateInstantiator> {
1327 bool EvaluateConstraints =
true;
1328 bool EvaluateLambdaConstraint =
false;
1331 bool IsIncomplete =
false;
1333 bool BailOutOnIncomplete;
1335 std::optional<llvm::FoldingSetNodeID> TemplateArgsHashValue;
1336 llvm::DenseMap<llvm::FoldingSetNodeIDRef, TemplateArgumentLoc>
1337 *CurrentCachedTemplateArgs =
nullptr;
1350 bool instantiateMissingDeclsToScopeForConcepts(
Decl *D);
1355 TemplateInstantiator(
Sema &SemaRef,
1358 bool BailOutOnIncomplete =
false)
1359 : inherited(SemaRef), TemplateArgs(TemplateArgs), Loc(Loc),
1360 Entity(Entity), BailOutOnIncomplete(BailOutOnIncomplete) {
1363 "Cannot perform an instantiation without some context on the "
1364 "instantiation stack");
1369 FunctionOfParmAttrs = Fn;
1370 FunctionParmAttrs = Attrs;
1374 void setEvaluateConstraints(
bool B) {
1375 EvaluateConstraints = B;
1377 bool getEvaluateConstraints() {
1378 return EvaluateConstraints;
1381 inline static struct ForParameterMappingSubstitution_t {
1382 } ForParameterMappingSubstitution;
1384 inline static struct ForConstraintSubstitution_t {
1385 } ForConstraintSubstitution;
1387 TemplateInstantiator(
1388 ForParameterMappingSubstitution_t, Sema &SemaRef, SourceLocation Loc,
1389 const MultiLevelTemplateArgumentList &TemplateArgs,
1390 llvm::DenseMap<llvm::FoldingSetNodeIDRef, TemplateArgumentLoc> *
Cache)
1391 : inherited(SemaRef), TemplateArgs(TemplateArgs), Loc(Loc),
1392 EvaluateLambdaConstraint(
true), BailOutOnIncomplete(
false),
1393 CurrentCachedTemplateArgs(
Cache) {
1396 auto &
V = TemplateArgsHashValue.emplace();
1397 for (
auto &
Level : TemplateArgs)
1398 for (
auto &Arg :
Level.Args)
1402 TemplateInstantiator(ForConstraintSubstitution_t, Sema &SemaRef,
1403 const MultiLevelTemplateArgumentList &TemplateArgs,
1404 SourceLocation Loc, DeclarationName Entity,
1405 bool BailOutOnIncomplete =
false)
1406 : inherited(SemaRef), TemplateArgs(TemplateArgs), Loc(Loc),
1407 EvaluateLambdaConstraint(
true), BailOutOnIncomplete(
false) {}
1414 bool AlreadyTransformed(QualType T);
1417 SourceLocation getBaseLocation() {
return Loc; }
1420 DeclarationName getBaseEntity() {
return Entity; }
1423 bool getIsIncomplete()
const {
return IsIncomplete; }
1427 void setBase(SourceLocation Loc, DeclarationName Entity) {
1429 this->Entity = Entity;
1432 unsigned TransformTemplateDepth(
unsigned Depth) {
1433 return TemplateArgs.getNewDepth(Depth);
1436 bool TryExpandParameterPacks(SourceLocation EllipsisLoc,
1437 SourceRange PatternRange,
1438 ArrayRef<UnexpandedParameterPack> Unexpanded,
1439 bool FailOnPackProducingTemplates,
1440 bool &ShouldExpand,
bool &RetainExpansion,
1442 bool Diagnose =
true) {
1444 if (instantiateMissingDeclsToScopeForConcepts(
1445 dyn_cast<NamedDecl *>(ParmPack.first)))
1449 return getSema().CheckParameterPacksForExpansion(
1450 EllipsisLoc, PatternRange, Unexpanded, TemplateArgs,
1451 FailOnPackProducingTemplates, ShouldExpand, RetainExpansion,
1452 NumExpansions, Diagnose);
1455 void ExpandingFunctionParameterPack(ParmVarDecl *Pack) {
1459 TemplateArgument ForgetPartiallySubstitutedPack() {
1463 MultiLevelTemplateArgumentList &TemplateArgs =
1464 const_cast<MultiLevelTemplateArgumentList &
>(this->TemplateArgs);
1465 unsigned Depth, Index;
1468 Result = TemplateArgs(Depth, Index);
1469 TemplateArgs.
setArgument(Depth, Index, TemplateArgument());
1471 IsIncomplete =
true;
1472 if (BailOutOnIncomplete)
1473 return TemplateArgument();
1480 void RememberPartiallySubstitutedPack(TemplateArgument Arg) {
1486 MultiLevelTemplateArgumentList &TemplateArgs =
1487 const_cast<MultiLevelTemplateArgumentList &
>(this->TemplateArgs);
1488 unsigned Depth, Index;
1494 MultiLevelTemplateArgumentList ForgetSubstitution() {
1495 MultiLevelTemplateArgumentList
New;
1498 MultiLevelTemplateArgumentList Old =
1499 const_cast<MultiLevelTemplateArgumentList &
>(this->TemplateArgs);
1500 const_cast<MultiLevelTemplateArgumentList &
>(this->TemplateArgs) =
1505 void RememberSubstitution(MultiLevelTemplateArgumentList Old) {
1506 const_cast<MultiLevelTemplateArgumentList &
>(this->TemplateArgs) =
1511 getTemplateArgumentPackPatternForRewrite(
const TemplateArgument &TA) {
1517 "unexpected pack arguments in template rewrite");
1526 Decl *TransformDecl(SourceLocation Loc, Decl *D);
1528 void transformAttrs(Decl *Old, Decl *
New) {
1532 void transformedLocalDecl(Decl *Old, ArrayRef<Decl *> NewDecls) {
1534 (NewDecls.size() != 1 || !NewDecls.front()->isParameterPack())) {
1536 for (
auto *
New : NewDecls)
1542 assert(NewDecls.size() == 1 &&
1543 "should only have multiple expansions for a pack");
1549 auto *NewMD = dyn_cast<CXXMethodDecl>(
New);
1551 auto *OldMD = dyn_cast<CXXMethodDecl>(Old);
1552 if (
auto *NewTD = NewMD->getDescribedFunctionTemplate())
1553 NewTD->setInstantiatedFromMemberTemplate(
1554 OldMD->getDescribedFunctionTemplate());
1556 NewMD->setInstantiationOfMemberFunction(OldMD,
1564 if (
auto *DC = dyn_cast<DeclContext>(Old);
1565 DC && DC->isDependentContext() && DC->isFunctionOrMethod())
1571 Decl *TransformDefinition(SourceLocation Loc, Decl *D);
1575 NamedDecl *TransformFirstQualifierInScope(NamedDecl *D, SourceLocation Loc);
1577 bool TransformExceptionSpec(SourceLocation Loc,
1578 FunctionProtoType::ExceptionSpecInfo &ESI,
1579 SmallVectorImpl<QualType> &Exceptions,
1584 VarDecl *RebuildExceptionDecl(VarDecl *ExceptionDecl,
1585 TypeSourceInfo *Declarator,
1586 SourceLocation StartLoc,
1587 SourceLocation NameLoc,
1588 IdentifierInfo *Name);
1592 VarDecl *RebuildObjCExceptionDecl(VarDecl *ExceptionDecl,
1593 TypeSourceInfo *TSInfo, QualType T);
1596 TransformTemplateName(NestedNameSpecifierLoc &QualifierLoc,
1598 SourceLocation NameLoc,
1599 QualType ObjectType = QualType(),
1600 NamedDecl *FirstQualifierInScope =
nullptr,
1601 bool AllowInjectedClassName =
false);
1603 const AnnotateAttr *TransformAnnotateAttr(
const AnnotateAttr *AA);
1604 const CXXAssumeAttr *TransformCXXAssumeAttr(
const CXXAssumeAttr *AA);
1605 const LoopHintAttr *TransformLoopHintAttr(
const LoopHintAttr *LH);
1606 const NoInlineAttr *TransformStmtNoInlineAttr(
const Stmt *OrigS,
1608 const NoInlineAttr *A);
1609 const AlwaysInlineAttr *
1610 TransformStmtAlwaysInlineAttr(
const Stmt *OrigS,
const Stmt *InstS,
1611 const AlwaysInlineAttr *A);
1612 const CodeAlignAttr *TransformCodeAlignAttr(
const CodeAlignAttr *CA);
1613 const OpenACCRoutineDeclAttr *
1614 TransformOpenACCRoutineDeclAttr(
const OpenACCRoutineDeclAttr *A);
1615 ExprResult TransformPredefinedExpr(PredefinedExpr *E);
1616 ExprResult TransformDeclRefExpr(DeclRefExpr *E);
1617 ExprResult TransformCXXDefaultArgExpr(CXXDefaultArgExpr *E);
1619 ExprResult TransformTemplateParmRefExpr(DeclRefExpr *E,
1620 NonTypeTemplateParmDecl *D);
1623 ExprResult RebuildVarDeclRefExpr(ValueDecl *PD, SourceLocation Loc);
1626 ExprResult TransformFunctionParmPackRefExpr(DeclRefExpr *E, ValueDecl *PD);
1631 ExprResult TransformFunctionParmPackExpr(FunctionParmPackExpr *E);
1633 QualType TransformFunctionProtoType(TypeLocBuilder &TLB,
1634 FunctionProtoTypeLoc TL) {
1636 return inherited::TransformFunctionProtoType(TLB, TL);
1639 QualType TransformTagType(TypeLocBuilder &TLB, TagTypeLoc TL) {
1640 auto Type = inherited::TransformTagType(TLB, TL);
1646 if (
const auto *ICNT = dyn_cast<InjectedClassNameType>(TL.
getTypePtr());
1649 Type = inherited::TransformType(
1650 ICNT->getDecl()->getCanonicalTemplateSpecializationType(
1660 bool TransformTemplateArgument(
const TemplateArgumentLoc &Input,
1661 TemplateArgumentLoc &Output,
1662 bool Uneval =
false) {
1663 const TemplateArgument &Arg = Input.getArgument();
1664 if (
auto *
Cache = CurrentCachedTemplateArgs;
1665 Cache && TemplateArgsHashValue) {
1666 llvm::FoldingSetNodeID
ID = *TemplateArgsHashValue;
1676 if (
auto Iter =
Cache->find(ID); Iter !=
Cache->end()) {
1677 Output = Iter->second;
1680 bool Ret = inherited::TransformTemplateArgument(Input, Output, Uneval);
1687 std::vector<TemplateArgument> TArgs;
1695 pack, QualType(), SourceLocation{});
1696 TemplateArgumentLoc Output;
1697 if (TransformTemplateArgument(Input, Output, Uneval))
1699 TArgs.push_back(Output.getArgument());
1702 TemplateArgument(llvm::ArrayRef(TArgs).copy(SemaRef.
Context)),
1703 QualType(), SourceLocation{});
1709 return inherited::TransformTemplateArgument(Input, Output, Uneval);
1714 TransformTemplateSpecializationType(TypeLocBuilder &TLB,
1715 TemplateSpecializationTypeLoc TL) {
1717 if (!getSema().ArgPackSubstIndex || !T->isSugared() ||
1727 QualType
R = TransformType(T->desugar());
1733 ArrayRef<TemplateArgument> PackArgs) {
1744 return std::nullopt;
1746 return inherited::ComputeSizeOfPackExprWithoutSubstitution(PackArgs);
1749 template<
typename Fn>
1750 QualType TransformFunctionProtoType(TypeLocBuilder &TLB,
1751 FunctionProtoTypeLoc TL,
1752 CXXRecordDecl *ThisContext,
1753 Qualifiers ThisTypeQuals,
1754 Fn TransformExceptionSpec);
1756 ParmVarDecl *TransformFunctionTypeParam(ParmVarDecl *OldParm,
1757 int indexAdjustment,
1759 bool ExpectParameterPack);
1761 using inherited::TransformFunctionTypeParams;
1762 bool TransformFunctionTypeParams(
1763 SourceLocation Loc, ArrayRef<ParmVarDecl *> Params,
1764 const QualType *ParamTypes,
1765 const FunctionProtoType::ExtParameterInfo *ParamInfos,
1766 SmallVectorImpl<QualType> &PTypes,
1767 SmallVectorImpl<ParmVarDecl *> *PVars,
1768 Sema::ExtParameterInfoBuilder &PInfos,
unsigned *LastParamTransformed);
1770 using inherited::TransformTemplateTypeParmType;
1773 QualType TransformTemplateTypeParmType(TypeLocBuilder &TLB,
1774 TemplateTypeParmTypeLoc TL,
1775 bool SuppressObjCLifetime);
1777 QualType BuildSubstTemplateTypeParmType(
1778 TypeLocBuilder &TLB,
bool SuppressObjCLifetime,
bool Final,
1780 TemplateArgument Arg, SourceLocation NameLoc);
1785 using inherited::TransformSubstTemplateTypeParmPackType;
1787 TransformSubstTemplateTypeParmPackType(TypeLocBuilder &TLB,
1788 SubstTemplateTypeParmPackTypeLoc TL,
1789 bool SuppressObjCLifetime);
1791 TransformSubstBuiltinTemplatePackType(TypeLocBuilder &TLB,
1792 SubstBuiltinTemplatePackTypeLoc TL);
1795 ComputeLambdaDependency(LambdaScopeInfo *LSI) {
1797 TemplateInstArgsHelpers::getEnclosingTypeAliasTemplateDecl(
1799 TypeAlias && TemplateInstArgsHelpers::isLambdaEnclosedByTypeAliasDecl(
1801 unsigned TypeAliasDeclDepth =
TypeAlias.Template->getTemplateDepth();
1803 return CXXRecordDecl::LambdaDependencyKind::LDK_AlwaysDependent;
1804 for (
const TemplateArgument &TA :
TypeAlias.AssociatedTemplateArguments)
1806 return CXXRecordDecl::LambdaDependencyKind::LDK_AlwaysDependent;
1808 if (
auto *CD = dyn_cast_if_present<ImplicitConceptSpecializationDecl>(
1810 if (llvm::any_of(CD->getTemplateArguments(),
1811 [](
const auto &TA) { return TA.isDependent(); }))
1812 return CXXRecordDecl::LambdaDependencyKind::LDK_AlwaysDependent;
1814 return inherited::ComputeLambdaDependency(LSI);
1817 ExprResult TransformLambdaConstraint(Expr *AC) {
1818 if (AC && EvaluateLambdaConstraint)
1819 return TransformExpr(
const_cast<Expr *
>(AC));
1829 LocalInstantiationScope Scope(SemaRef,
true,
1831 llvm::SaveAndRestore RAII(EvaluateConstraints, EvaluateLambdaConstraint);
1833 return inherited::TransformLambdaExpr(E);
1836 ExprResult TransformBlockExpr(BlockExpr *E) {
1837 LocalInstantiationScope Scope(SemaRef,
true,
1839 return inherited::TransformBlockExpr(E);
1842 ExprResult RebuildLambdaExpr(SourceLocation StartLoc, SourceLocation EndLoc,
1843 LambdaScopeInfo *LSI) {
1846 assert(PVD &&
"null in a parameter list");
1847 if (!PVD->hasDefaultArg())
1849 Expr *UninstExpr = PVD->getUninstantiatedDefaultArg();
1851 SourceLocation EqualLoc = UninstExpr->
getBeginLoc();
1860 PVD->setDefaultArg(ErrorResult.
get());
1863 return inherited::RebuildLambdaExpr(StartLoc, EndLoc, LSI);
1876 llvm::SaveAndRestore _(EvaluateConstraints,
true);
1877 return inherited::TransformLambdaBody(E, Body);
1881 LocalInstantiationScope Scope(SemaRef,
true);
1882 ExprResult TransReq = inherited::TransformRequiresExpr(E);
1885 assert(TransReq.
get() != E &&
1886 "Do not change value of isSatisfied for the existing expression. "
1887 "Create a new expression instead.");
1889 Sema::SFINAETrap Trap(SemaRef);
1894 if (Trap.hasErrorOccurred())
1900 bool TransformRequiresExprRequirements(
1901 ArrayRef<concepts::Requirement *> Reqs,
1902 SmallVectorImpl<concepts::Requirement *> &Transformed) {
1903 bool SatisfactionDetermined =
false;
1904 for (concepts::Requirement *Req : Reqs) {
1905 concepts::Requirement *TransReq =
nullptr;
1906 if (!SatisfactionDetermined) {
1907 if (
auto *TypeReq = dyn_cast<concepts::TypeRequirement>(Req))
1908 TransReq = TransformTypeRequirement(TypeReq);
1909 else if (
auto *ExprReq = dyn_cast<concepts::ExprRequirement>(Req))
1910 TransReq = TransformExprRequirement(ExprReq);
1912 TransReq = TransformNestedRequirement(
1922 SatisfactionDetermined =
true;
1925 Transformed.push_back(TransReq);
1930 TemplateParameterList *TransformTemplateParameterList(
1931 TemplateParameterList *OrigTPL) {
1932 if (!OrigTPL || !OrigTPL->
size())
return OrigTPL;
1935 TemplateDeclInstantiator DeclInstantiator(getSema(),
1938 DeclInstantiator.setEvaluateConstraints(EvaluateConstraints);
1939 return DeclInstantiator.SubstTemplateParams(OrigTPL);
1942 concepts::TypeRequirement *
1943 TransformTypeRequirement(concepts::TypeRequirement *Req);
1944 concepts::ExprRequirement *
1945 TransformExprRequirement(concepts::ExprRequirement *Req);
1946 concepts::NestedRequirement *
1947 TransformNestedRequirement(concepts::NestedRequirement *Req);
1949 SourceLocation KWLoc, SourceLocation RBraceLoc,
const RequiresExpr *RE,
1950 RequiresExprBodyDecl *Body, ArrayRef<ParmVarDecl *> Params,
1951 SmallVectorImpl<QualType> &PTypes,
1952 SmallVectorImpl<ParmVarDecl *> &TransParams,
1953 Sema::ExtParameterInfoBuilder &PInfos);
1955 ExprResult TransformCXXDynamicCastExpr(CXXDynamicCastExpr *E) {
1957 if (
Ret.isInvalid())
1959 QualType T =
Ret.get()->getType();
1963 if (DestDecl && DestDecl->isEffectivelyFinal())
1964 getSema().MarkVTableUsed(
Ret.get()->getExprLoc(), DestDecl);
1970bool TemplateInstantiator::AlreadyTransformed(QualType T) {
1978 getSema().MarkDeclarationsReferencedInType(Loc, T);
1982Decl *TemplateInstantiator::TransformDecl(SourceLocation Loc, Decl *D) {
1986 if (TemplateTemplateParmDecl *TTP = dyn_cast<TemplateTemplateParmDecl>(D)) {
1993 TTP->getPosition())) {
1994 IsIncomplete =
true;
1995 return BailOutOnIncomplete ?
nullptr : D;
1998 TemplateArgument Arg = TemplateArgs(TTP->getDepth(), TTP->getPosition());
2000 if (TTP->isParameterPack()) {
2002 "Missing argument pack");
2003 Arg =
SemaRef.getPackSubstitutedTemplateArgument(Arg);
2008 "Wrong kind of template template argument");
2009 return Template.getAsTemplateDecl();
2016 if (instantiateMissingDeclsToScopeForConcepts(D))
2020 assert(
SemaRef.CurrentInstantiationScope);
2022 *
SemaRef.CurrentInstantiationScope->findInstantiationOf(D));
2028bool TemplateInstantiator::instantiateMissingDeclsToScopeForConcepts(Decl *D) {
2029 if (!(D && (
SemaRef.inConstraintSubstitution() ||
2030 SemaRef.inParameterMappingSubstitution())))
2033 auto *Current =
SemaRef.CurrentInstantiationScope;
2034 if (!Current || Current->getInstantiationOfIfExists(D))
2040 auto *OldParm = dyn_cast<ParmVarDecl>(D);
2044 if (!OldParm->isParameterPack())
2045 return !TransformFunctionTypeParam(OldParm, 0,
2049 SmallVector<UnexpandedParameterPack, 2> Unexpanded;
2052 TypeLoc TL = OldParm->getTypeSourceInfo()->getTypeLoc();
2053 PackExpansionTypeLoc ExpansionTL = TL.
castAs<PackExpansionTypeLoc>();
2055 SemaRef.collectUnexpandedParameterPacks(Pattern, Unexpanded);
2056 assert(!Unexpanded.empty() &&
"Pack expansion without parameter packs?");
2058 bool ShouldExpand =
false;
2059 bool RetainExpansion =
false;
2061 ExpansionTL.
getTypePtr()->getNumExpansions();
2064 Pattern.getSourceRange(), Unexpanded,
2066 ShouldExpand, RetainExpansion, NumExpansions))
2069 assert(ShouldExpand && !RetainExpansion &&
2070 "Shouldn't preserve pack expansion when evaluating constraints");
2071 ExpandingFunctionParameterPack(OldParm);
2072 for (
unsigned I = 0; I != *NumExpansions; ++I) {
2073 Sema::ArgPackSubstIndexRAII SubstIndex(getSema(), I);
2074 if (!TransformFunctionTypeParam(OldParm, 0,
2082Decl *TemplateInstantiator::TransformDefinition(SourceLocation Loc, Decl *D) {
2083 Decl *Inst = getSema().SubstDecl(D, getSema().
CurContext, TemplateArgs);
2087 getSema().CurrentInstantiationScope->InstantiatedLocal(D, Inst);
2091bool TemplateInstantiator::TransformExceptionSpec(
2092 SourceLocation Loc, FunctionProtoType::ExceptionSpecInfo &ESI,
2093 SmallVectorImpl<QualType> &Exceptions,
bool &Changed) {
2098 return inherited::TransformExceptionSpec(Loc, ESI, Exceptions, Changed);
2102TemplateInstantiator::TransformFirstQualifierInScope(NamedDecl *D,
2103 SourceLocation Loc) {
2106 if (TemplateTypeParmDecl *TTPD = dyn_cast_or_null<TemplateTypeParmDecl>(D)) {
2107 const TemplateTypeParmType *TTP
2112 TemplateArgument Arg = TemplateArgs(TTP->getDepth(), TTP->getIndex());
2114 if (TTP->isParameterPack()) {
2116 "Missing argument pack");
2121 Arg =
SemaRef.getPackSubstitutedTemplateArgument(Arg);
2126 return cast_or_null<NamedDecl>(TransformDecl(Loc, D));
2128 if (
const TagType *Tag = T->
getAs<TagType>())
2129 return Tag->getDecl();
2132 getSema().Diag(Loc, diag::err_nested_name_spec_non_tag) << T;
2137 return cast_or_null<NamedDecl>(TransformDecl(Loc, D));
2141TemplateInstantiator::RebuildExceptionDecl(VarDecl *ExceptionDecl,
2142 TypeSourceInfo *Declarator,
2143 SourceLocation StartLoc,
2144 SourceLocation NameLoc,
2145 IdentifierInfo *Name) {
2146 VarDecl *Var = inherited::RebuildExceptionDecl(ExceptionDecl, Declarator,
2147 StartLoc, NameLoc, Name);
2149 getSema().CurrentInstantiationScope->InstantiatedLocal(ExceptionDecl, Var);
2153VarDecl *TemplateInstantiator::RebuildObjCExceptionDecl(VarDecl *ExceptionDecl,
2154 TypeSourceInfo *TSInfo,
2156 VarDecl *Var = inherited::RebuildObjCExceptionDecl(ExceptionDecl, TSInfo, T);
2158 getSema().CurrentInstantiationScope->InstantiatedLocal(ExceptionDecl, Var);
2162TemplateName TemplateInstantiator::TransformTemplateName(
2163 NestedNameSpecifierLoc &QualifierLoc, SourceLocation TemplateKWLoc,
2164 TemplateName Name, SourceLocation NameLoc, QualType ObjectType,
2165 NamedDecl *FirstQualifierInScope,
bool AllowInjectedClassName) {
2167 assert(!QualifierLoc &&
"Unexpected qualifier");
2170 TTP && TTP->getDepth() < TemplateArgs.
getNumLevels()) {
2176 TTP->getPosition())) {
2177 IsIncomplete =
true;
2181 TemplateArgument Arg = TemplateArgs(TTP->getDepth(), TTP->getPosition());
2186 Arg = getTemplateArgumentPackPatternForRewrite(Arg);
2188 "unexpected nontype template argument kind in template rewrite");
2192 auto [AssociatedDecl, Final] =
2195 if (TTP->isParameterPack()) {
2197 "Missing argument pack");
2203 return getSema().Context.getSubstTemplateTemplateParmPack(
2204 Arg, AssociatedDecl, TTP->getIndex(), Final);
2208 Arg =
SemaRef.getPackSubstitutedTemplateArgument(Arg);
2212 assert(!
Template.isNull() &&
"Null template template argument");
2213 return getSema().Context.getSubstTemplateTemplateParm(
2218 if (SubstTemplateTemplateParmPackStorage *SubstPack
2223 TemplateArgument Pack = SubstPack->getArgumentPack();
2225 SemaRef.getPackSubstitutedTemplateArgument(Pack).getAsTemplate();
2226 return getSema().Context.getSubstTemplateTemplateParm(
2227 Template, SubstPack->getAssociatedDecl(), SubstPack->getIndex(),
2228 SemaRef.getPackIndex(Pack), SubstPack->getFinal());
2231 return inherited::TransformTemplateName(
2232 QualifierLoc, TemplateKWLoc, Name, NameLoc, ObjectType,
2233 FirstQualifierInScope, AllowInjectedClassName);
2237TemplateInstantiator::TransformPredefinedExpr(PredefinedExpr *E) {
2245TemplateInstantiator::TransformTemplateParmRefExpr(DeclRefExpr *E,
2246 NonTypeTemplateParmDecl *NTTP) {
2256 IsIncomplete =
true;
2257 return BailOutOnIncomplete ?
ExprError() : E;
2265 Arg = getTemplateArgumentPackPatternForRewrite(Arg);
2267 "unexpected nontype template argument kind in template rewrite");
2280 assert(!ParamType.
isNull() &&
"Shouldn't substitute to an invalid type");
2282 auto [AssociatedDecl, Final] =
2302 return new (
SemaRef.Context) SubstNonTypeTemplateParmPackExpr(
2307 Arg =
SemaRef.getPackSubstitutedTemplateArgument(Arg);
2309 return SemaRef.BuildSubstNonTypeTemplateParmExpr(
2315TemplateInstantiator::TransformAnnotateAttr(
const AnnotateAttr *AA) {
2316 SmallVector<Expr *> Args;
2317 for (Expr *Arg : AA->args()) {
2318 ExprResult Res = getDerived().TransformExpr(Arg);
2320 Args.push_back(Res.
get());
2322 return AnnotateAttr::CreateImplicit(getSema().
Context, AA->getAnnotation(),
2323 Args.data(), Args.size(), AA->getRange());
2326const CXXAssumeAttr *
2327TemplateInstantiator::TransformCXXAssumeAttr(
const CXXAssumeAttr *AA) {
2328 ExprResult Res = getDerived().TransformExpr(AA->getAssumption());
2332 if (!(Res.
get()->
getDependence() & ExprDependence::TypeValueInstantiation)) {
2333 Res = getSema().BuildCXXAssumeExpr(Res.
get(), AA->getAttrName(),
2339 return CXXAssumeAttr::CreateImplicit(getSema().
Context, Res.
get(),
2344TemplateInstantiator::TransformLoopHintAttr(
const LoopHintAttr *LH) {
2345 ExprResult TransformedExprResult = getDerived().TransformExpr(LH->getValue());
2346 if (!TransformedExprResult.
isUsable() ||
2347 TransformedExprResult.
get() == LH->getValue())
2349 Expr *TransformedExpr = TransformedExprResult.
get();
2353 LH->getSemanticSpelling() ==
2354 LoopHintAttr::Pragma_unroll))
2357 LoopHintAttr::OptionType Option = LH->getOption();
2358 LoopHintAttr::LoopHintState State = LH->getState();
2365 if (Option == LoopHintAttr::UnrollCount &&
2367 llvm::APSInt ValueAPS =
2371 if (ValueAPS.isZero() || ValueAPS.isOne()) {
2372 Option = LoopHintAttr::Unroll;
2373 State = LoopHintAttr::Disable;
2379 return LoopHintAttr::CreateImplicit(getSema().
Context, Option, State,
2380 TransformedExpr, *LH);
2382const NoInlineAttr *TemplateInstantiator::TransformStmtNoInlineAttr(
2383 const Stmt *OrigS,
const Stmt *InstS,
const NoInlineAttr *A) {
2389const AlwaysInlineAttr *TemplateInstantiator::TransformStmtAlwaysInlineAttr(
2390 const Stmt *OrigS,
const Stmt *InstS,
const AlwaysInlineAttr *A) {
2397const CodeAlignAttr *
2398TemplateInstantiator::TransformCodeAlignAttr(
const CodeAlignAttr *CA) {
2399 Expr *TransformedExpr = getDerived().TransformExpr(CA->getAlignment()).get();
2400 return getSema().BuildCodeAlignAttr(*CA, TransformedExpr);
2402const OpenACCRoutineDeclAttr *
2403TemplateInstantiator::TransformOpenACCRoutineDeclAttr(
2404 const OpenACCRoutineDeclAttr *A) {
2405 llvm_unreachable(
"RoutineDecl should only be a declaration attribute, as it "
2406 "applies to a Function Decl (and a few places for VarDecl)");
2409ExprResult TemplateInstantiator::RebuildVarDeclRefExpr(ValueDecl *PD,
2410 SourceLocation Loc) {
2411 DeclarationNameInfo NameInfo(PD->
getDeclName(), Loc);
2412 return getSema().BuildDeclarationNameExpr(CXXScopeSpec(), NameInfo, PD);
2416TemplateInstantiator::TransformFunctionParmPackExpr(FunctionParmPackExpr *E) {
2420 ValueDecl *VD = cast_or_null<ValueDecl>(TransformDecl(E->
getExprLoc(), D));
2423 return RebuildVarDeclRefExpr(VD, E->
getExprLoc());
2426 QualType T = TransformType(E->
getType());
2432 SmallVector<ValueDecl *, 8> Vars;
2436 ValueDecl *D = cast_or_null<ValueDecl>(TransformDecl(E->
getExprLoc(), *I));
2445 getSema().MarkFunctionParmPackReferenced(PackExpr);
2450TemplateInstantiator::TransformFunctionParmPackRefExpr(DeclRefExpr *E,
2453 llvm::PointerUnion<Decl *, DeclArgumentPack *> *
Found =
2454 getSema().CurrentInstantiationScope->getInstantiationOfIfExists(PD);
2461 Decl *TransformedDecl;
2462 if (DeclArgumentPack *Pack = dyn_cast<DeclArgumentPack *>(*
Found)) {
2466 QualType T = TransformType(E->
getType());
2471 getSema().MarkFunctionParmPackReferenced(PackExpr);
2475 TransformedDecl = (*Pack)[*getSema().ArgPackSubstIndex];
2486TemplateInstantiator::TransformDeclRefExpr(DeclRefExpr *E) {
2491 if (NonTypeTemplateParmDecl *NTTP = dyn_cast<NonTypeTemplateParmDecl>(D)) {
2493 return TransformTemplateParmRefExpr(E, NTTP);
2500 if (VarDecl *PD = dyn_cast<VarDecl>(D))
2502 if (instantiateMissingDeclsToScopeForConcepts(PD))
2505 return TransformFunctionParmPackRefExpr(E, PD);
2508 return inherited::TransformDeclRefExpr(E);
2511ExprResult TemplateInstantiator::TransformCXXDefaultArgExpr(
2512 CXXDefaultArgExpr *E) {
2514 getDescribedFunctionTemplate() &&
2515 "Default arg expressions are never formed in dependent cases.");
2516 return SemaRef.BuildCXXDefaultArgExpr(
2521template<
typename Fn>
2522QualType TemplateInstantiator::TransformFunctionProtoType(TypeLocBuilder &TLB,
2523 FunctionProtoTypeLoc TL,
2524 CXXRecordDecl *ThisContext,
2525 Qualifiers ThisTypeQuals,
2526 Fn TransformExceptionSpec) {
2534 LocalInstantiationScope *Current = getSema().CurrentInstantiationScope;
2535 std::optional<LocalInstantiationScope> Scope;
2539 return inherited::TransformFunctionProtoType(
2540 TLB, TL, ThisContext, ThisTypeQuals, TransformExceptionSpec);
2543ParmVarDecl *TemplateInstantiator::TransformFunctionTypeParam(
2544 ParmVarDecl *OldParm,
int indexAdjustment,
UnsignedOrNone NumExpansions,
2545 bool ExpectParameterPack) {
2553 if (LateParmAttrs &&
SemaRef.CurrentInstantiationScope == LateParmAttrScope)
2554 LateAttrs = LateParmAttrs;
2556 assert((
SemaRef.inConstraintSubstitution() ||
2557 SemaRef.inParameterMappingSubstitution()) &&
2558 "parameter transformed outside its prototype");
2559 auto NewParm =
SemaRef.SubstParmVarDecl(
2560 OldParm, TemplateArgs, indexAdjustment, NumExpansions,
2561 ExpectParameterPack, EvaluateConstraints, LateAttrs);
2562 if (NewParm &&
SemaRef.getLangOpts().OpenCL)
2563 SemaRef.deduceOpenCLAddressSpace(NewParm);
2567bool TemplateInstantiator::TransformFunctionTypeParams(
2568 SourceLocation Loc, ArrayRef<ParmVarDecl *> Params,
2569 const QualType *ParamTypes,
2570 const FunctionProtoType::ExtParameterInfo *ParamInfos,
2571 SmallVectorImpl<QualType> &PTypes, SmallVectorImpl<ParmVarDecl *> *PVars,
2572 Sema::ExtParameterInfoBuilder &PInfos,
unsigned *LastParamTransformed) {
2576 LocalInstantiationScope *Scope =
SemaRef.CurrentInstantiationScope;
2577 llvm::SaveAndRestore SaveLateAttrs(LateParmAttrs, &LateAttrs);
2578 llvm::SaveAndRestore SaveLateScope(LateParmAttrScope, Scope);
2579 bool Failed = inherited::TransformFunctionTypeParams(
2580 Loc, Params, ParamTypes, ParamInfos, PTypes, PVars, PInfos,
2581 LastParamTransformed);
2585 llvm::all_of(LateAttrs, [&](
const Sema::LateInstantiatedAttribute &LA) {
2586 return LA.
Scope == Scope;
2593 const auto *It = llvm::find_if(Params, [](ParmVarDecl *P) {
return P; });
2594 if (FunctionParmAttrs && It != Params.end() &&
2595 (*It)->getDeclContext() == FunctionOfParmAttrs) {
2597 for (
const Sema::LateInstantiatedAttribute &LA : LateAttrs)
2598 FunctionParmAttrs->push_back(Sema::LateInstantiatedAttribute(
2603 SemaRef.InstantiateLateAttrs(TemplateArgs, LateAttrs, Scope);
2607QualType TemplateInstantiator::BuildSubstTemplateTypeParmType(
2608 TypeLocBuilder &TLB,
bool SuppressObjCLifetime,
bool Final,
2610 TemplateArgument Arg, SourceLocation NameLoc) {
2615 if (SuppressObjCLifetime) {
2617 RQs = Replacement.getQualifiers();
2620 SemaRef.Context.getQualifiedType(Replacement.getUnqualifiedType(), RQs);
2624 QualType
Result = getSema().Context.getSubstTemplateTypeParmType(
2625 Replacement, AssociatedDecl, Index,
PackIndex, Final);
2626 SubstTemplateTypeParmTypeLoc NewTL =
2627 TLB.
push<SubstTemplateTypeParmTypeLoc>(
Result);
2633TemplateInstantiator::TransformTemplateTypeParmType(TypeLocBuilder &TLB,
2634 TemplateTypeParmTypeLoc TL,
2635 bool SuppressObjCLifetime) {
2636 const TemplateTypeParmType *T = TL.
getTypePtr();
2646 IsIncomplete =
true;
2647 if (BailOutOnIncomplete)
2650 TemplateTypeParmTypeLoc NewTL
2651 = TLB.
push<TemplateTypeParmTypeLoc>(TL.
getType());
2656 TemplateArgument Arg = TemplateArgs(T->getDepth(), T->getIndex());
2661 Arg = getTemplateArgumentPackPatternForRewrite(Arg);
2663 "unexpected nontype template argument kind in template rewrite");
2669 auto [AssociatedDecl, Final] =
2672 if (T->isParameterPack() ||
2679 (T->getDecl() && T->getDecl()->isTemplateParameterPack())) {
2681 "Missing argument pack");
2687 QualType
Result = getSema().Context.getSubstTemplateTypeParmPackType(
2688 AssociatedDecl, T->getIndex(), Final, Arg);
2689 SubstTemplateTypeParmPackTypeLoc NewTL
2690 = TLB.
push<SubstTemplateTypeParmPackTypeLoc>(
Result);
2697 Arg =
SemaRef.getPackSubstitutedTemplateArgument(Arg);
2701 "Template argument kind mismatch");
2703 return BuildSubstTemplateTypeParmType(TLB, SuppressObjCLifetime, Final,
2704 AssociatedDecl, T->getIndex(),
2712 TemplateTypeParmDecl *NewTTPDecl =
nullptr;
2713 if (TemplateTypeParmDecl *OldTTPDecl = T->getDecl())
2714 NewTTPDecl = cast_or_null<TemplateTypeParmDecl>(
2716 QualType
Result = getSema().Context.getTemplateTypeParmType(
2720 T->getIndex(), T->isParameterPack(), NewTTPDecl);
2721 TemplateTypeParmTypeLoc NewTL = TLB.
push<TemplateTypeParmTypeLoc>(
Result);
2726QualType TemplateInstantiator::TransformSubstTemplateTypeParmPackType(
2727 TypeLocBuilder &TLB, SubstTemplateTypeParmPackTypeLoc TL,
2728 bool SuppressObjCLifetime) {
2729 const SubstTemplateTypeParmPackType *T = TL.
getTypePtr();
2731 Decl *NewReplaced = TransformDecl(TL.
getNameLoc(), T->getAssociatedDecl());
2736 if (NewReplaced != T->getAssociatedDecl())
2737 Result = getSema().Context.getSubstTemplateTypeParmPackType(
2738 NewReplaced, T->getIndex(), T->getFinal(), T->getArgumentPack());
2739 SubstTemplateTypeParmPackTypeLoc NewTL =
2740 TLB.
push<SubstTemplateTypeParmPackTypeLoc>(
Result);
2745 TemplateArgument Pack = T->getArgumentPack();
2746 TemplateArgument Arg =
SemaRef.getPackSubstitutedTemplateArgument(Pack);
2747 return BuildSubstTemplateTypeParmType(
2748 TLB, SuppressObjCLifetime, T->getFinal(), NewReplaced, T->getIndex(),
2752QualType TemplateInstantiator::TransformSubstBuiltinTemplatePackType(
2753 TypeLocBuilder &TLB, SubstBuiltinTemplatePackTypeLoc TL) {
2755 return TreeTransform::TransformSubstBuiltinTemplatePackType(TLB, TL);
2756 TemplateArgument
Result =
SemaRef.getPackSubstitutedTemplateArgument(
2760 return Result.getAsType();
2763static concepts::Requirement::SubstitutionDiagnostic *
2773 ErrorLoc = PDA.first;
2778 llvm::raw_svector_ostream
OS(Entity);
2782 C.backupStr(Entity), ErrorLoc,
C.backupStr(Message)};
2785concepts::Requirement::SubstitutionDiagnostic *
2788 llvm::raw_svector_ostream
OS(Entity);
2792 C.backupStr(Entity),
2793 Location, StringRef()};
2796ExprResult TemplateInstantiator::TransformRequiresTypeParams(
2809 if (getDerived().TransformFunctionTypeParams(
2810 KWLoc, Params,
nullptr,
nullptr, PTypes,
2811 &TransParams, PInfos, &ErrorIdx) ||
2812 Trap.hasErrorOccurred()) {
2818 SemaRef, Info, [&](llvm::raw_ostream &
OS) {
OS << *FailedDecl; })));
2819 return getDerived().RebuildRequiresExpr(KWLoc, Body, RE->
getLParenLoc(),
2821 TransReqs, RBraceLoc);
2827concepts::TypeRequirement *
2828TemplateInstantiator::TransformTypeRequirement(concepts::TypeRequirement *Req) {
2832 if (AlwaysRebuild())
2833 return RebuildTypeRequirement(
2839 Sema::SFINAETrap Trap(
SemaRef, Info);
2840 Sema::InstantiatingTemplate TypeInst(
2843 if (TypeInst.isInvalid())
2845 TypeSourceInfo *TransType = TransformType(Req->
getType());
2846 if (!TransType || Trap.hasErrorOccurred())
2848 [&] (llvm::raw_ostream&
OS) {
2851 return RebuildTypeRequirement(TransType);
2854concepts::ExprRequirement *
2855TemplateInstantiator::TransformExprRequirement(concepts::ExprRequirement *Req) {
2859 llvm::PointerUnion<Expr *, concepts::Requirement::SubstitutionDiagnostic *>
2866 Sema::SFINAETrap Trap(
SemaRef, Info);
2869 if (ExprInst.isInvalid())
2872 if (!TransExprRes.
isInvalid() && !Trap.hasErrorOccurred() &&
2874 TransExprRes =
SemaRef.CheckPlaceholderExpr(TransExprRes.
get());
2875 if (TransExprRes.
isInvalid() || Trap.hasErrorOccurred())
2880 TransExpr = TransExprRes.
get();
2883 std::optional<concepts::ExprRequirement::ReturnTypeRequirement> TransRetReq;
2885 if (RetReq.isEmpty())
2886 TransRetReq.emplace();
2887 else if (RetReq.isSubstitutionFailure())
2888 TransRetReq.emplace(RetReq.getSubstitutionDiagnostic());
2889 else if (RetReq.isTypeConstraint()) {
2890 TemplateParameterList *OrigTPL =
2891 RetReq.getTypeConstraintTemplateParameterList();
2893 Sema::SFINAETrap Trap(
SemaRef, Info);
2896 if (TPLInst.isInvalid())
2898 TemplateParameterList *TPL = TransformTemplateParameterList(OrigTPL);
2899 if (!TPL || Trap.hasErrorOccurred())
2901 [&] (llvm::raw_ostream&
OS) {
2902 RetReq.getTypeConstraint()->getImmediatelyDeclaredConstraint()
2903 ->printPretty(
OS,
nullptr,
SemaRef.getPrintingPolicy());
2907 TransRetReq.emplace(TPL);
2910 assert(TransRetReq &&
"All code paths leading here must set TransRetReq");
2911 if (Expr *E = dyn_cast<Expr *>(TransExpr))
2913 std::move(*TransRetReq));
2914 return RebuildExprRequirement(
2919concepts::NestedRequirement *
2920TemplateInstantiator::TransformNestedRequirement(
2921 concepts::NestedRequirement *Req) {
2925 ConstraintSatisfaction Satisfaction;
2927 auto NestedReqWithDiag = [&
C,
this](Expr *E,
2928 ConstraintSatisfaction Satisfaction) {
2930 SmallString<128> Entity;
2931 llvm::raw_svector_ostream
OS(Entity);
2932 E->printPretty(
OS,
nullptr,
SemaRef.getPrintingPolicy());
2933 return new (
C) concepts::NestedRequirement(
2934 SemaRef.Context,
C.backupStr(Entity), std::move(Satisfaction));
2938 if (AlwaysRebuild())
2946 if (!getEvaluateConstraints()) {
2948 if (TransConstraint.
isInvalid() || !TransConstraint.
get())
2952 concepts::NestedRequirement(TransConstraint.
get());
2953 ConstraintSatisfaction Satisfaction;
2954 return new (
SemaRef.Context) concepts::NestedRequirement(
2955 SemaRef.Context, TransConstraint.
get(), Satisfaction);
2959 Expr *NewConstraint;
2963 Sema::InstantiatingTemplate ConstrInst(
2965 Sema::InstantiatingTemplate::ConstraintsCheck(),
2968 if (ConstrInst.isInvalid())
2972 Req, AssociatedConstraint(Constraint), TemplateArgs,
2974 nullptr, &NewConstraint);
2978 return NestedReqWithDiag(Constraint, Satisfaction);
2982 if (!NewConstraint) {
2984 return NestedReqWithDiag(Constraint, Satisfaction);
2986 NewConstraint = Constraint;
2988 return new (
C) concepts::NestedRequirement(
C, NewConstraint, Satisfaction);
2994 bool AllowDeducedTST) {
2995 if (!T->getType()->isInstantiationDependentType() &&
2996 !T->getType()->isVariablyModifiedType())
2999 TemplateInstantiator Instantiator(*
this, Args, Loc, Entity);
3000 return AllowDeducedTST ? Instantiator.TransformTypeWithDeducedTST(T)
3001 : Instantiator.TransformType(T);
3019 TemplateInstantiator Instantiator(*
this, Args, Loc, Entity);
3033 bool *IsIncompleteSubstitution) {
3036 if (!T->isInstantiationDependentType() && !T->isVariablyModifiedType())
3039 TemplateInstantiator Instantiator(
3040 *
this, TemplateArgs, Loc, Entity,
3041 IsIncompleteSubstitution !=
nullptr);
3042 QualType QT = Instantiator.TransformType(T);
3043 if (IsIncompleteSubstitution && Instantiator.getIsIncomplete())
3044 *IsIncompleteSubstitution =
true;
3049 if (T->getType()->isInstantiationDependentType() ||
3050 T->getType()->isVariablyModifiedType())
3078 TemplateInstantiator Instantiator(*
this, Args, Loc, Entity);
3079 Instantiator.setEvaluateConstraints(EvaluateConstraints);
3080 Instantiator.deferFunctionParmAttrs(Fn, ParamAttrs);
3096 Result = Instantiator.TransformFunctionProtoType(
3097 TLB, Proto, ThisContext, ThisTypeQuals,
3099 bool &Changed) {
return false; });
3101 Result = Instantiator.TransformType(TLB, TL);
3115 bool Changed =
false;
3116 TemplateInstantiator Instantiator(*
this, Args, Loc,
DeclarationName());
3117 return Instantiator.TransformExceptionSpec(Loc, ESI, ExceptionStorage,
3128 ESI, ExceptionStorage, Args))
3137 struct GetContainedInventedTypeParmVisitor :
3138 public TypeVisitor<GetContainedInventedTypeParmVisitor,
3139 TemplateTypeParmDecl *> {
3140 using TypeVisitor<GetContainedInventedTypeParmVisitor,
3146 return Visit(T.getTypePtr());
3150 const TemplateTypeParmType *T) {
3151 if (!T->getDecl() || !T->getDecl()->isImplicit())
3153 return T->getDecl();
3159 TemplateTypeParmDecl *VisitPointerType(
const PointerType *T) {
3163 TemplateTypeParmDecl *VisitBlockPointerType(
const BlockPointerType *T) {
3167 TemplateTypeParmDecl *VisitReferenceType(
const ReferenceType *T) {
3171 TemplateTypeParmDecl *VisitMemberPointerType(
const MemberPointerType *T) {
3175 TemplateTypeParmDecl *VisitArrayType(
const ArrayType *T) {
3179 TemplateTypeParmDecl *VisitDependentSizedExtVectorType(
3180 const DependentSizedExtVectorType *T) {
3184 TemplateTypeParmDecl *VisitVectorType(
const VectorType *T) {
3188 TemplateTypeParmDecl *VisitFunctionProtoType(
const FunctionProtoType *T) {
3189 return VisitFunctionType(T);
3192 TemplateTypeParmDecl *VisitFunctionType(
const FunctionType *T) {
3196 TemplateTypeParmDecl *VisitParenType(
const ParenType *T) {
3200 TemplateTypeParmDecl *VisitAttributedType(
const AttributedType *T) {
3201 return Visit(T->getModifiedType());
3204 TemplateTypeParmDecl *VisitMacroQualifiedType(
const MacroQualifiedType *T) {
3208 TemplateTypeParmDecl *VisitAdjustedType(
const AdjustedType *T) {
3212 TemplateTypeParmDecl *VisitPackExpansionType(
const PackExpansionType *T) {
3213 return Visit(T->getPattern());
3222 bool EvaluateConstraints) {
3226 if (!EvaluateConstraints) {
3228 bool ContainsUnexpandedPack =
3232 return TA.getArgument().containsUnexpandedParameterPack();
3234 if (!Index && ContainsUnexpandedPack)
3235 Index =
SemaRef.ArgPackSubstIndex;
3247 TemplateInstantiator Instantiator(
3248 TemplateInstantiator::ForConstraintSubstitution, *
this, TemplateArgs,
3250 if (Instantiator.TransformTemplateArguments(
3267 int indexAdjustment,
UnsignedOrNone NumExpansions,
bool ExpectParameterPack,
3288 }
else if (ExpectParameterPack) {
3294 diag::err_function_parameter_pack_without_parameter_packs)
3318 GetContainedInventedTypeParmVisitor().Visit(OldTSI->
getType())) {
3320 auto *Inst = cast_or_null<TemplateTypeParmDecl>(
3325 if (Inst && !Inst->getTypeConstraint()) {
3402 assert((OldParamTypes || !llvm::is_contained(Params,
nullptr)) &&
3403 "a parameter with no ParmVarDecl needs OldParamTypes to be passed");
3404 TemplateInstantiator Instantiator(*
this, TemplateArgs, Loc,
3406 Instantiator.setEvaluateConstraints(EvaluateConstraints);
3407 Instantiator.deferFunctionParmAttrs(Fn, ParamAttrs);
3408 return Instantiator.TransformFunctionTypeParams(Loc, Params, OldParamTypes,
3409 ExtParamInfos, ParamTypes,
3410 OutParams, ParamInfos);
3419 Expr *PatternExpr = Param->getUninstantiatedDefaultArg();
3423 if (AlreadyInstantiating) {
3424 Param->setInvalidDecl();
3425 return Diag(Param->getBeginLoc(), diag::err_recursive_default_argument)
3443 std::optional<LocalInstantiationScope> LIS;
3454 if (addInstantiatedParametersToScope(FD, PatternFD, *LIS, TemplateArgs))
3471 Param->getLocation(),
3476 Result = InitSeq.Perform(*
this, Entity, Kind, ResultE);
3506 auto ComputeInfo = [&S, &TemplateArgs, BaseSourceRange, BaseEllipsisLoc](
3513 if (IsLateExpansionAttempt) {
3520 if (!SawPackTypes) {
3532 BaseEllipsisLoc, BaseSourceRange, Unexpanded, TemplateArgs,
3537 if (ComputeInfo(
Base.getTypeSourceInfo(),
false, Info))
3541 Out =
Base.getTypeSourceInfo();
3551 if (!Out->getType()->containsUnexpandedParameterPack())
3556 if (ComputeInfo(Out,
true, Info))
3569 for (
const auto &
Base : Pattern->
bases()) {
3570 if (!
Base.getType()->isInstantiationDependentType()) {
3572 if (RD->isInvalidDecl())
3581 if (
Base.isPackExpansion()) {
3593 ArgsForSubst = &EmptyList;
3608 Instantiation,
Base.getSourceRange(),
Base.isVirtual(),
3609 Base.getAccessSpecifierAsWritten(), Expanded,
3611 InstantiatedBases.push_back(InstantiatedBase);
3620 EllipsisLoc =
Base.getEllipsisLoc();
3628 Base.getSourceRange().getBegin(),
3639 Base.getSourceRange(),
3641 Base.getAccessSpecifierAsWritten(),
3644 InstantiatedBases.push_back(InstantiatedBase);
3674 assert(!AlreadyInstantiating &&
"should have been caught by caller");
3677 return InstantiateClassImpl(PointOfInstantiation, Instantiation, Pattern,
3678 TemplateArgs, TSK, Complain);
3681bool Sema::InstantiateClassImpl(
3688 if (DiagnoseUninstantiableTemplate(PointOfInstantiation, Instantiation,
3690 Pattern, PatternDef, TSK, Complain))
3693 llvm::TimeTraceScope TimeScope(
"InstantiateClass", [&]() {
3694 llvm::TimeTraceMetadata M;
3695 llvm::raw_string_ostream OS(M.Detail);
3698 if (llvm::isTimeTraceVerbose()) {
3699 auto Loc = SourceMgr.getExpansionLoc(Instantiation->
getLocation());
3700 M.File = SourceMgr.getFilename(Loc);
3701 M.Line = SourceMgr.getExpansionLineNumber(Loc);
3706 Pattern = PatternDef;
3709 if (MemberSpecializationInfo *MSInfo
3711 MSInfo->setTemplateSpecializationKind(TSK);
3712 MSInfo->setPointOfInstantiation(PointOfInstantiation);
3713 }
else if (ClassTemplateSpecializationDecl *Spec
3714 = dyn_cast<ClassTemplateSpecializationDecl>(Instantiation)) {
3715 Spec->setTemplateSpecializationKind(TSK);
3716 Spec->setPointOfInstantiation(PointOfInstantiation);
3719 NonSFINAEContext _(*
this);
3720 InstantiatingTemplate Inst(*
this, PointOfInstantiation, Instantiation);
3721 if (Inst.isInvalid())
3723 PrettyDeclStackTraceEntry CrashInfo(Context, Instantiation, SourceLocation(),
3724 "instantiating class definition");
3728 ContextRAII SavedContext(*
this, Instantiation);
3729 EnterExpressionEvaluationContext EvalContext(
3730 *
this, Sema::ExpressionEvaluationContext::PotentiallyEvaluated);
3736 LocalInstantiationScope Scope(*
this, MergeWithParentScope);
3742 SavePendingParsedClassStateRAII SavedPendingParsedClassState(*
this);
3745 InstantiateAttrs(TemplateArgs, Pattern, Instantiation);
3755 Instantiation->
setTagKind(Pattern->getTagKind());
3758 if (SubstBaseSpecifiers(Instantiation, Pattern, TemplateArgs))
3761 TemplateDeclInstantiator Instantiator(*
this, Instantiation, TemplateArgs);
3762 Instantiator.setEvaluateConstraints(
false);
3763 SmallVector<Decl*, 4> Fields;
3765 LateInstantiatedAttrVec LateAttrs;
3766 Instantiator.enableLateAttributeInstantiation(&LateAttrs);
3768 bool MightHaveConstexprVirtualFunctions =
false;
3769 for (
auto *
Member : Pattern->decls()) {
3779 if (
Member->getDeclContext() != Pattern)
3790 if (
Member->isInvalidDecl()) {
3800 Decl *NewMember = Instantiator.Visit(
Member);
3802 if (FieldDecl *Field = dyn_cast<FieldDecl>(NewMember)) {
3803 Fields.push_back(Field);
3804 }
else if (EnumDecl *
Enum = dyn_cast<EnumDecl>(NewMember)) {
3810 Enum->isCompleteDefinition()) {
3811 MemberSpecializationInfo *MSInfo =
Enum->getMemberSpecializationInfo();
3812 assert(MSInfo &&
"no spec info for member enum specialization");
3816 }
else if (StaticAssertDecl *SA = dyn_cast<StaticAssertDecl>(NewMember)) {
3817 if (SA->isFailed()) {
3823 }
else if (CXXMethodDecl *MD = dyn_cast<CXXMethodDecl>(NewMember)) {
3826 MightHaveConstexprVirtualFunctions =
true;
3829 if (
Member->isInvalidDecl())
3843 ActOnFields(
nullptr, Instantiation->
getLocation(), Instantiation, Fields,
3844 SourceLocation(), SourceLocation(), ParsedAttributesView());
3845 CheckCompletedCXXClass(
nullptr, Instantiation);
3850 if (ParsingClassDepth == 0)
3851 ActOnFinishCXXNonNestedClass();
3854 InstantiateLateAttrs(TemplateArgs, LateAttrs,
3855 Instantiator.getStartingScope());
3856 Instantiator.disableLateAttributeInstantiation();
3858 ActOnFinishDelayedMemberInitializers(Instantiation);
3863 Instantiation->
setLocation(Pattern->getLocation());
3864 Instantiation->
setLocStart(Pattern->getInnerLocStart());
3870 if (Pattern->isDependentContext())
3871 PerformDependentDiagnostics(Pattern, TemplateArgs);
3876 P = Instantiator.delayed_partial_spec_begin(),
3877 PEnd = Instantiator.delayed_partial_spec_end();
3879 if (!Instantiator.InstantiateClassTemplatePartialSpecialization(
3880 P->first, P->second)) {
3889 P = Instantiator.delayed_var_partial_spec_begin(),
3890 PEnd = Instantiator.delayed_var_partial_spec_end();
3892 if (!Instantiator.InstantiateVarTemplatePartialSpecialization(
3893 P->first, P->second)) {
3911 MarkVTableUsed(PointOfInstantiation, Instantiation,
true);
3912 else if (MightHaveConstexprVirtualFunctions)
3913 MarkVirtualMembersReferenced(PointOfInstantiation, Instantiation,
3917 Consumer.HandleTagDeclDefinition(Instantiation);
3929 assert(!AlreadyInstantiating &&
"should have been caught by caller");
3935 Pattern, PatternDef, TSK,
true))
3937 Pattern = PatternDef;
3951 "instantiating enum definition");
3986 "pattern and instantiation disagree about init style");
3990 if (AlreadyInstantiating)
3992 return Diag(PointOfInstantiation,
3993 diag::err_default_member_initializer_cycle)
4002 Diag(PointOfInstantiation,
4003 diag::err_default_member_initializer_not_yet_parsed)
4004 << OutermostClass << Pattern;
4005 Diag(Pattern->getEndLoc(),
4006 diag::note_default_member_initializer_not_yet_parsed);
4015 "instantiating default member init");
4024 PointOfInstantiation, Instantiation,
CurContext};
4040 L->DefaultMemberInitializerInstantiated(Instantiation);
4049 struct PartialSpecMatchResult {
4094 std::optional<Sema::NonSFINAEContext> NSC(S);
4114 typedef PartialSpecMatchResult MatchResult;
4117 Template->getPartialSpecializations(PartialSpecs);
4130 if (
Template->isMemberSpecialization() &&
4131 !Partial->isMemberSpecialization())
4149 if (Matched.empty() && PrimaryStrictPackMatch)
4150 Matched = std::move(ExtraMatched);
4156 if (Matched.size() >= 1) {
4158 if (Matched.size() == 1) {
4171 PEnd = Matched.end();
4174 P->Partial, Best->Partial, PointOfInstantiation) ==
4183 PEnd = Matched.end();
4186 P->Partial, Best->Partial,
4187 PointOfInstantiation) != Best->Partial) {
4197 S.
Diag(PointOfInstantiation,
4198 diag::err_partial_spec_ordering_ambiguous)
4199 << ClassTemplateSpec;
4203 PEnd = Matched.end();
4207 P->Partial->getTemplateParameters(), *P->Args);
4222 if (
auto *PartialSpec =
4223 dyn_cast<ClassTemplatePartialSpecializationDecl *>(Specialized)) {
4225 while (PartialSpec->getInstantiatedFromMember()) {
4228 if (PartialSpec->isMemberSpecialization())
4231 PartialSpec = PartialSpec->getInstantiatedFromMember();
4233 Pattern = PartialSpec;
4236 while (
Template->getInstantiatedFromMemberTemplate()) {
4239 if (
Template->isMemberSpecialization())
4244 Pattern =
Template->getTemplatedDecl();
4254 bool PrimaryStrictPackMatch) {
4263 if (AlreadyInstantiating)
4266 bool HadAvaibilityWarning =
4272 ClassTemplateSpec, TSK,
4273 PrimaryStrictPackMatch);
4280 if (!Pattern.
get()->isCompleteDefinition() &&
4281 Pattern.
get()->hasExternalLexicalStorage())
4283 Source->CompleteType(Pattern.
get());
4285 bool Err = InstantiateClassImpl(
4286 PointOfInstantiation, ClassTemplateSpec, Pattern.
get(),
4293 if (!Err && !HadAvaibilityWarning) {
4313 "Unexpected template specialization kind!");
4314 for (
auto *D : Instantiation->
decls()) {
4315 bool SuppressNew =
false;
4316 if (
auto *
Function = dyn_cast<FunctionDecl>(D)) {
4318 Function->getInstantiatedFromMemberFunction()) {
4320 if (
Function->getTrailingRequiresClause()) {
4328 if (
Function->hasAttr<ExcludeFromExplicitInstantiationAttr>())
4332 Function->getTemplateSpecializationKind();
4337 PointOfInstantiation, TSK,
Function, PrevTSK,
4338 Function->getPointOfInstantiation(), SuppressNew) ||
4351 Function->setTemplateSpecializationKind(TSK, PointOfInstantiation);
4361 std::make_pair(
Function, PointOfInstantiation));
4364 }
else if (
auto *Var = dyn_cast<VarDecl>(D)) {
4369 if (Var->
hasAttr<ExcludeFromExplicitInstantiationAttr>())
4373 assert(MSInfo &&
"No member specialization information?");
4402 }
else if (
auto *
Record = dyn_cast<CXXRecordDecl>(D)) {
4403 if (
Record->hasAttr<ExcludeFromExplicitInstantiationAttr>())
4411 if (
Record->isInjectedClassName() ||
Record->getPreviousDecl() ||
4416 assert(MSInfo &&
"No member specialization information?");
4422 if (
Context.getTargetInfo().getTriple().isOSWindows() &&
4442 assert(Pattern &&
"Missing instantiated-from-template information");
4444 if (!
Record->getDefinition()) {
4465 Record->getTemplateSpecializationKind() ==
4467 Record->setTemplateSpecializationKind(TSK);
4472 Pattern = cast_or_null<CXXRecordDecl>(
Record->getDefinition());
4476 }
else if (
auto *
Enum = dyn_cast<EnumDecl>(D)) {
4478 assert(MSInfo &&
"No member specialization information?");
4485 PointOfInstantiation, TSK,
Enum,
4491 if (
Enum->getDefinition())
4494 EnumDecl *Pattern =
Enum->getTemplateInstantiationPattern();
4495 assert(Pattern &&
"Missing instantiated-from-template information");
4506 }
else if (
auto *Field = dyn_cast<FieldDecl>(D)) {
4517 ClassPattern->
lookup(Field->getDeclName());
4550 TemplateInstantiator Instantiator(*
this, TemplateArgs,
4553 return Instantiator.TransformStmt(S);
4561 TemplateInstantiator Instantiator(*
this, TemplateArgs, Loc, Entity);
4562 return Instantiator.TransformTemplateArgument(Input, Output);
4569 TemplateInstantiator Instantiator(*
this, TemplateArgs,
SourceLocation(),
4571 return Instantiator.TransformTemplateArguments(Args.begin(), Args.end(), Out);
4578 TemplateInstantiator Instantiator(
4579 TemplateInstantiator::ForParameterMappingSubstitution, *
this, BaseLoc,
4580 TemplateArgs, CurrentCachedTemplateArgs);
4581 return Instantiator.TransformTemplateArguments(Args.begin(), Args.end(), Out);
4586 TemplateInstantiator Instantiator(
4587 TemplateInstantiator::ForConstraintSubstitution, *
this, TemplateArgs,
4592 assert(!Unexpanded.empty() &&
"Pack expansion without parameter packs?");
4595 bool RetainExpansion =
false;
4597 if (Instantiator.TryExpandParameterPacks(
4599 false, Expand, RetainExpansion,
4600 NumExpansions,
false) ||
4601 !Expand || RetainExpansion)
4602 return std::nullopt;
4604 if (NumExpansions && getLangOpts().BracketDepth < *NumExpansions)
4605 return std::nullopt;
4606 return NumExpansions;
4614 TemplateInstantiator Instantiator(*
this, TemplateArgs,
4617 return Instantiator.TransformExpr(E);
4626 TemplateInstantiator Instantiator(*
this, TemplateArgs,
SourceLocation(),
4628 return Instantiator.TransformAddressOfOperand(E);
4637 TemplateInstantiator Instantiator(
4638 TemplateInstantiator::ForConstraintSubstitution, *
this, TemplateArgs,
4640 return Instantiator.TransformExpr(E);
4648 TemplateInstantiator Instantiator(*
this, TemplateArgs,
SourceLocation(),
4650 Instantiator.setEvaluateConstraints(
false);
4651 return Instantiator.TransformExpr(E);
4659 TemplateInstantiator Instantiator(*
this, MLTAL,
SourceLocation(),
4666 if (Instantiator.TransformConceptTemplateArguments(
4690 struct ConstraintExprTransformer :
TreeTransform<ConstraintExprTransformer> {
4702 case Stmt::BinaryOperatorClass:
4703 case Stmt::ConceptSpecializationExprClass:
4704 case Stmt::ParenExprClass:
4705 case Stmt::UnresolvedLookupExprClass:
4706 case Stmt::DependentTemplateIdExprClass:
4707 return Base::TransformExpr(E);
4718 if (!(E->
getOpcode() == BinaryOperatorKind::BO_LAnd ||
4719 E->
getOpcode() == BinaryOperatorKind::BO_LOr))
4736 bool Uneval =
false) {
4737 if (Input.getArgument().isConceptOrConceptTemplateParameter())
4738 return Base::TransformTemplateArgument(Input, Output, Uneval);
4751 if (TransformTemplateArguments(Args, NumArgs, TransArgs))
4757 ResolvedConcept, ResolvedConcept,
4782 ConceptDecl *ResolvedConcept = dyn_cast_if_present<ConceptDecl>(
4784 if (!ResolvedConcept)
4787 return RebuildConceptSpecialization(ResolvedConcept, E->
getNameLoc(),
4794 ConstraintExprTransformer Transformer(*
this, MLTALForConstraint);
4796 Transformer.TransformExpr(
const_cast<Expr *
>(ConstraintExpr));
4802 bool CXXDirectInit) {
4803 TemplateInstantiator Instantiator(*
this, TemplateArgs,
SourceLocation(),
4805 return Instantiator.TransformInitializer(
Init, CXXDirectInit);
4814 TemplateInstantiator Instantiator(*
this, TemplateArgs,
4817 return Instantiator.TransformExprs(Exprs.data(), Exprs.size(),
4827 TemplateInstantiator Instantiator(*
this, TemplateArgs, NNS.
getBeginLoc(),
4829 return Instantiator.TransformNestedNameSpecifierLoc(NNS);
4835 TemplateInstantiator Instantiator(*
this, TemplateArgs, NameInfo.
getLoc(),
4837 return Instantiator.TransformDeclarationNameInfo(NameInfo);
4845 TemplateInstantiator Instantiator(*
this, TemplateArgs, NameLoc,
4847 return Instantiator.TransformTemplateName(QualifierLoc, TemplateKWLoc, Name,
4856 if (
const ParmVarDecl *PV = dyn_cast<ParmVarDecl>(D)) {
4857 if (
const FunctionDecl *FD = dyn_cast<FunctionDecl>(PV->getDeclContext())) {
4858 unsigned i = PV->getFunctionScopeIndex();
4861 if (i < FD->getNumParams() && FD->getParamDecl(i) == PV)
4862 return FD->getCanonicalDecl()->getParamDecl(i);
4868llvm::PointerUnion<Decl *, LocalInstantiationScope::DeclArgumentPack *> *
4872 Current = Current->Outer) {
4875 const Decl *CheckD = D;
4877 LocalDeclsMap::iterator
Found = Current->LocalDecls.find(CheckD);
4878 if (
Found != Current->LocalDecls.end())
4879 return &
Found->second;
4883 if (
const TagDecl *Tag = dyn_cast<TagDecl>(CheckD))
4890 if (!Current->CombineWithOuterScope)
4897llvm::PointerUnion<Decl *, LocalInstantiationScope::DeclArgumentPack *> *
4910 if (RD->isLocalClass())
4927 assert(
isa<LabelDecl>(D) &&
"declaration not instantiated in this scope");
4933 llvm::PointerUnion<Decl *, DeclArgumentPack *> &Stored = LocalDecls[D];
4934 if (Stored.isNull()) {
4938 while (Current->CombineWithOuterScope && Current->Outer) {
4939 Current = Current->Outer;
4940 assert(!Current->LocalDecls.contains(D) &&
4941 "Instantiated local in inner and outer scopes");
4945 }
else if (
DeclArgumentPack *Pack = dyn_cast<DeclArgumentPack *>(Stored)) {
4948 assert(
cast<Decl *>(Stored) == Inst &&
"Already instantiated this local");
4956 Pack->push_back(Inst);
4963 Current && Current->CombineWithOuterScope; Current = Current->Outer)
4964 assert(!Current->LocalDecls.contains(D) &&
4965 "Creating local pack after instantiation of local");
4969 llvm::PointerUnion<Decl *, DeclArgumentPack *> &Stored = LocalDecls[D];
4972 ArgumentPacks.push_back(Pack);
4977 if (llvm::is_contained(*Pack, D))
4984 unsigned NumExplicitArgs) {
4985 assert((!PartiallySubstitutedPack || PartiallySubstitutedPack == Pack) &&
4986 "Already have a partially-substituted pack");
4987 assert((!PartiallySubstitutedPack
4988 || NumArgsInPartiallySubstitutedPack == NumExplicitArgs) &&
4989 "Wrong number of arguments in partially-substituted pack");
4990 PartiallySubstitutedPack = Pack;
4991 ArgsInPartiallySubstitutedPack = ExplicitArgs;
4992 NumArgsInPartiallySubstitutedPack = NumExplicitArgs;
4997 unsigned *NumExplicitArgs)
const {
4999 *ExplicitArgs =
nullptr;
5000 if (NumExplicitArgs)
5001 *NumExplicitArgs = 0;
5004 Current = Current->Outer) {
5005 if (Current->PartiallySubstitutedPack) {
5007 *ExplicitArgs = Current->ArgsInPartiallySubstitutedPack;
5008 if (NumExplicitArgs)
5009 *NumExplicitArgs = Current->NumArgsInPartiallySubstitutedPack;
5011 return Current->PartiallySubstitutedPack;
5014 if (!Current->CombineWithOuterScope)
Defines the clang::ASTContext interface.
This file provides some common utility functions for processing Lambda related AST Constructs.
This file defines the classes used to store parsed information about declaration-specifiers and decla...
Defines the C++ template declaration subclasses.
Defines Expressions and AST nodes for C++2a concepts.
Result
Implement __builtin_bit_cast and related operations.
Defines the clang::LangOptions interface.
static DiagnosticBuilder Diag(DiagnosticsEngine *Diags, const LangOptions &Features, FullSourceLoc TokLoc, const char *TokBegin, const char *TokRangeBegin, const char *TokRangeEnd, unsigned DiagID)
Produce a diagnostic highlighting some portion of a literal.
llvm::MachO::Record Record
static AccessResult DeduceTemplateArguments(Sema &S, FriendTemplateDecl *FTD, DeclContext *DC, const TemplateSpecializationType *TST, ArrayRef< TemplateParameterList * > TPLs, TemplateSpecCandidateSet *FailedTSC, MultiLevelTemplateArgumentList &DeducedArgs)
static void collectUnexpandedParameterPacks(Sema &S, TemplateParameterList *Params, SmallVectorImpl< UnexpandedParameterPack > &Unexpanded)
static bool PreparePackForExpansion(Sema &S, const CXXBaseSpecifier &Base, const MultiLevelTemplateArgumentList &TemplateArgs, TypeSourceInfo *&Out, UnexpandedInfo &Info)
static const Decl * getCanonicalParmVarDecl(const Decl *D)
static std::string convertCallArgsValueCategoryAndTypeToString(Sema &S, llvm::ArrayRef< const Expr * > Args)
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)
Defines the clang::TypeLoc interface and its subclasses.
TypePropertyCache< Private > Cache
C Language Family Type Representation.
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
const clang::PrintingPolicy & getPrintingPolicy() const
The result of parsing/analyzing an expression, statement etc.
QualType getOriginalType() const
QualType getElementType() const
Attr - This represents one attribute.
A builtin binary operation expression such as "x + y" or "x <= y".
SourceLocation getOperatorLoc() const
static BinaryOperator * Create(const ASTContext &C, Expr *lhs, Expr *rhs, Opcode opc, QualType ResTy, ExprValueKind VK, ExprObjectKind OK, SourceLocation opLoc, FPOptionsOverride FPFeatures)
QualType getPointeeType() const
Represents a base class of a C++ class.
SourceLocation getUsedLocation() const
Retrieve the location where this default argument was actually used.
const ParmVarDecl * getParam() const
CXXExpansionStmtPattern - Represents an unexpanded C++ expansion statement.
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...
void setIsHLSLBuiltinRecord(bool Value)
Sets the flag that the class is a built-in HLSL record.
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.
Represents a C++ nested-name-specifier or a global scope specifier.
Declaration of a class template.
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...
Declaration of a C++20 concept.
NamedDecl * getFoundDecl() const
Represents the specialization of a concept - evaluates to a prvalue of type bool.
const ASTTemplateArgumentListInfo * getTemplateArgsAsWritten() const
ConceptDecl * getConceptDecl() 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)
DeclContext - This is used only as base class of specific decl types that can act as declaration cont...
bool isFileContext() const
DeclContextLookupResult lookup_result
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.
bool isTranslationUnit() const
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.
NamedDecl * getFoundDecl()
Get the NamedDecl through which this reference occurred.
SourceLocation getLocation() const
Decl - This represents one declaration (or definition), e.g.
Decl * getPreviousDecl()
Retrieve the previous declaration that declares the same entity as this declaration,...
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).
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.
NestedNameSpecifier getQualifier() const
Retrieve the nested-name-specifier that qualifies the name of this declaration, if it was present in ...
TypeSourceInfo * getTypeSourceInfo() const
QualType getElementType() const
A template-id naming a variable template or a concept through a template template parameter.
bool isConceptReference() const
ArrayRef< TemplateArgumentLoc > template_arguments() const
TemplateTemplateParmDecl * getParameter() const
SourceLocation getRAngleLoc() const
TemplateName getTemplateName() const
unsigned getNumTemplateArgs() const
SourceLocation getNameLoc() const
SourceLocation getLAngleLoc() const
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,...
EnumDecl * getInstantiatedFromMemberEnum() const
Returns the enumeration (declared within the template) from which this enumeration type was instantia...
EnumDecl * getDefinition() const
This represents one expression.
bool isValueDependent() const
Determines whether the value of this expression depends on.
bool isTypeDependent() const
Determines whether the type of this expression depends on.
llvm::APSInt EvaluateKnownConstInt(const ASTContext &Ctx) const
EvaluateKnownConstInt - Call EvaluateAsRValue and return the folded integer.
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
Abstract interface for external sources of AST nodes.
Represents difference between two FPOptions values.
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.
For a defaulted function, the kind of defaulted function that it is.
CXXSpecialMemberKind asSpecialMember() const
bool isComparison() const
bool isPostfixOperator() const
PostfixOperatorKind asPostfixOperator() const
bool isSpecialMember() const
DefaultedComparisonKind asComparison() const
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.
static FunctionParmPackExpr * Create(const ASTContext &Context, QualType T, ValueDecl *ParamPack, SourceLocation NameLoc, ArrayRef< ValueDecl * > Params)
ValueDecl * getExpansion(unsigned I) const
Get an expansion of the parameter pack by index.
ValueDecl *const * iterator
Iterators over the parameters which the parameter pack expanded into.
ValueDecl * getParameterPack() const
Get the parameter pack which this expression refers to.
unsigned getNumExpansions() const
Get the number of parameters in this parameter pack.
SourceLocation getParameterPackLocation() const
Get the location of the parameter pack.
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...
QualType getReturnType() const
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 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...
LocalInstantiationScope(Sema &SemaRef, bool CombineWithOuterScope=false, bool InstantiatingLambdaOrBlock=false)
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.
SmallVector< ValueDecl *, 4 > DeclArgumentPack
A set of declarations.
llvm::PointerUnion< Decl *, DeclArgumentPack * > * getInstantiationOfIfExists(const Decl *D)
Similar to findInstantiationOf(), but it wouldn't assert if the instantiation was not found within th...
void InstantiatedLocal(const Decl *D, Decl *Inst)
void InstantiatedLocalPackArg(const Decl *D, VarDecl *Inst)
bool isLambdaOrBlock() const
Determine whether this scope is for instantiating a lambda or block.
void MakeInstantiatedLocalArgPack(const Decl *D)
LocalInstantiationScope * cloneScopes(LocalInstantiationScope *Outermost)
Clone this scope, and all outer scopes, down to the given outermost scope.
llvm::PointerUnion< Decl *, DeclArgumentPack * > * findInstantiationOf(const Decl *D)
Find the instantiation of the declaration D within the current instantiation scope.
QualType getUnderlyingType() const
QualType getPointeeType() const
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.
bool retainInnerDepths() const
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.
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
@ Type
A type, stored as a Type*.
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
A structure for storing a pack-index-template-name ([temp.names]).
QualType getInnerType() const
Represents a parameter to a function.
unsigned getFunctionScopeIndex() const
Returns the index of this parameter in its prototype or method scope.
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)
QualType getPointeeType() const
PredefinedIdentKind getIdentKind() const
SourceLocation getLocation() const
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.
void print(raw_ostream &OS, const PrintingPolicy &Policy, const Twine &PlaceHolder=Twine(), unsigned Indentation=0) const
QualType getNonPackExpansionType() const
Remove an outer pack expansion type (if any) from this type.
The collection of all-type qualifiers we support.
void removeObjCLifetime()
Represents a struct/union/class.
bool isMemberSpecialization() const
Determines whether this template was a specialization of a member template.
QualType getPointeeTypeAsWritten() const
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
RequiresExprBodyDecl * getBody() const
Scope - A scope is a transient data structure that is used while parsing the program.
PartialDiagnostic PDiag(unsigned DiagID=0)
Build a partial diagnostic.
SemaDiagnosticBuilder Diag(SourceLocation Loc, unsigned DiagID)
Emit a 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...
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.
ExprResult SubstConceptTemplateArguments(const ConceptSpecializationExpr *CSE, const Expr *ConstraintExpr, const MultiLevelTemplateArgumentList &MLTAL)
Substitute concept template arguments in the constraint expression of a concept-id.
NamedDecl * FindInstantiatedDecl(SourceLocation Loc, NamedDecl *D, const MultiLevelTemplateArgumentList &TemplateArgs, bool FindingInstantiatedContext=false)
Find the instantiation of the given declaration within the current instantiation.
llvm::function_ref< void(SourceLocation, PartialDiagnostic)> InstantiationContextDiagFuncRef
TemplateName SubstTemplateName(SourceLocation TemplateKWLoc, NestedNameSpecifierLoc &QualifierLoc, TemplateName Name, SourceLocation NameLoc, const MultiLevelTemplateArgumentList &TemplateArgs)
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 ...
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...
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)
ExprResult SubstExpr(Expr *E, const MultiLevelTemplateArgumentList &TemplateArgs)
DiagnosticsEngine & getDiagnostics() const
bool AttachTypeConstraint(NestedNameSpecifierLoc NS, DeclarationNameInfo NameInfo, TemplateName NamedConcept, NamedDecl *FoundDecl, const TemplateArgumentListInfo *TemplateArgs, TemplateTypeParmDecl *ConstrainedParameter, SourceLocation EllipsisLoc)
Attach a type-constraint to a template parameter.
TypeSourceInfo * SubstFunctionDeclType(TypeSourceInfo *T, const MultiLevelTemplateArgumentList &TemplateArgs, SourceLocation Loc, DeclarationName Entity, CXXRecordDecl *ThisContext, Qualifiers ThisTypeQuals, bool EvaluateConstraints=true, const FunctionDecl *Fn=nullptr, LateInstantiatedAttrVec *ParamAttrs=nullptr)
A form of SubstType intended specifically for instantiating the type of a FunctionDecl.
bool CheckParameterPacksForExpansion(SourceLocation EllipsisLoc, SourceRange PatternRange, ArrayRef< UnexpandedParameterPack > Unexpanded, const MultiLevelTemplateArgumentList &TemplateArgs, bool FailOnPackProducingTemplates, bool &ShouldExpand, bool &RetainExpansion, UnsignedOrNone &NumExpansions, bool Diagnose=true)
Determine whether we could expand a pack expansion with the given set of parameter packs into separat...
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.
SmallVector< LateInstantiatedAttribute, 1 > LateInstantiatedAttrVec
void ActOnStartCXXInClassMemberInitializer()
Enter a new C++ default initializer scope.
PrintingPolicy getPrintingPolicy() const
Retrieve a suitable printing policy for diagnostics.
bool pushCodeSynthesisContext(CodeSynthesisContext Ctx)
bool SubstTemplateArguments(ArrayRef< TemplateArgumentLoc > Args, const MultiLevelTemplateArgumentList &TemplateArgs, TemplateArgumentListInfo &Outputs)
Sema(Preprocessor &pp, ASTContext &ctxt, ASTConsumer &consumer, TranslationUnitKind TUKind=TU_Complete, CodeCompleteConsumer *CompletionConsumer=nullptr)
void InstantiateAttrs(const MultiLevelTemplateArgumentList &TemplateArgs, const Decl *Pattern, Decl *Inst, LateInstantiatedAttrVec *LateAttrs=nullptr, LocalInstantiationScope *OuterMostScope=nullptr)
const LangOptions & getLangOpts() const
void collectUnexpandedParameterPacks(TemplateArgument Arg, SmallVectorImpl< UnexpandedParameterPack > &Unexpanded)
Collect the set of unexpanded parameter packs within the given template argument.
bool SubstTemplateArgumentsInParameterMapping(ArrayRef< TemplateArgumentLoc > Args, SourceLocation BaseLoc, const MultiLevelTemplateArgumentList &TemplateArgs, TemplateArgumentListInfo &Out)
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 ...
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.
TemplateArgument getPackSubstitutedTemplateArgument(TemplateArgument Arg) const
void popCodeSynthesisContext()
bool usesPartialOrExplicitSpecialization(SourceLocation Loc, ClassTemplateSpecializationDecl *ClassTemplateSpec)
bool CheckLoopHintExpr(Expr *E, SourceLocation Loc, bool AllowZero)
TemplateArgumentLoc getTrivialTemplateArgumentLoc(const TemplateArgument &Arg, QualType NTTPType, SourceLocation Loc)
Allocate a TemplateArgumentLoc where all locations have been initialized to the given location.
ParmVarDecl * SubstParmVarDecl(ParmVarDecl *D, const MultiLevelTemplateArgumentList &TemplateArgs, int indexAdjustment, UnsignedOrNone NumExpansions, bool ExpectParameterPack, bool EvaluateConstraints=true, LateInstantiatedAttrVec *LateAttrs=nullptr)
Substitute into a function parameter.
CXXBaseSpecifier * CheckBaseSpecifier(CXXRecordDecl *Class, SourceRange SpecifierRange, bool Virtual, AccessSpecifier Access, TypeSourceInfo *TInfo, SourceLocation EllipsisLoc)
Check the validity of a C++ base class specifier.
UnparsedDefaultArgInstantiationsMap UnparsedDefaultArgInstantiations
A mapping from parameters with unparsed default arguments to the set of instantiations of each 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...
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 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)
bool SubstParmTypes(SourceLocation Loc, ArrayRef< ParmVarDecl * > Params, const FunctionProtoType::ExtParameterInfo *ExtParamInfos, const MultiLevelTemplateArgumentList &TemplateArgs, SmallVectorImpl< QualType > &ParamTypes, SmallVectorImpl< ParmVarDecl * > *OutParams, ExtParameterInfoBuilder &ParamInfos, const QualType *OldParamTypes=nullptr, bool EvaluateConstraints=true, const FunctionDecl *Fn=nullptr, LateInstantiatedAttrVec *ParamAttrs=nullptr)
Substitute the given template arguments into the given set of parameters, producing the set of parame...
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 isSFINAEContext() const
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)
@ 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)
bool RebuildingImmediateInvocation
Whether the AST is currently being rebuilt to correct immediate invocations.
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...
DiagnosticsEngine & Diags
bool AttachBaseSpecifiers(CXXRecordDecl *Class, MutableArrayRef< CXXBaseSpecifier * > Bases)
Performs the actual work of attaching the given base class specifiers to a C++ class.
friend class InitializationSequence
SmallVector< Module *, 16 > CodeSynthesisContextLookupModules
Extra modules inspected when performing a lookup during a template instantiation.
ExprResult ConvertParamDefaultArgument(ParmVarDecl *Param, Expr *DefaultArg, SourceLocation EqualLoc)
llvm::BumpPtrAllocator BumpAlloc
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.
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)
Encodes a location in the source.
bool isValid() const
Return true if this is a valid SourceLocation object.
A trivial tuple used to represent a source range.
SourceLocation getBegin() const
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
StmtClass getStmtClass() 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
Represents the declaration of a struct/union/class/enum.
void setTagKind(TagKind TK)
void startDefinition()
Starts the definition of this tag declaration.
void setBraceRange(SourceRange R)
SourceLocation getNameLoc() const
A convenient class for passing around template argument information.
void setLAngleLoc(SourceLocation Loc)
void setRAngleLoc(SourceLocation Loc)
ArrayRef< TemplateArgumentLoc > arguments() const
A template argument list.
ArrayRef< TemplateArgument > asArray() const
Produce this as an array ref.
Location wrapper for a TemplateArgument.
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.
void Profile(llvm::FoldingSetNodeID &ID, const ASTContext &Context) const
Used to insert TemplateArguments into FoldingSets.
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.
@ 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.
@ 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.
SmallVectorImpl< std::pair< ClassTemplateDecl *, ClassTemplatePartialSpecializationDecl * > >::iterator delayed_partial_spec_iterator
void InstantiateEnumDefinition(EnumDecl *Enum, EnumDecl *Pattern)
SmallVectorImpl< std::pair< VarTemplateDecl *, VarTemplatePartialSpecializationDecl * > >::iterator delayed_var_partial_spec_iterator
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.
TemplateDecl * getAsTemplateDecl(bool IgnoreDeduced=false) const
Retrieve the underlying template declaration that this template name refers to, if known.
@ Template
A single template declaration.
SubstTemplateTemplateParmPackStorage * getAsSubstTemplateTemplateParmPack() const
Retrieve the substituted template template parameter pack, if known.
PackIndexingTemplateStorage * getAsPackIndexingTemplate() const
Retrieve the pack-index-template-name storage, if any.
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 getPosition() const
Get the position of the template parameter within its parameter list.
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.
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
const DeclarationNameInfo & getConceptNameInfo() const
TemplateName getNamedConcept() const
SourceLocation getConceptNameLoc() 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.
CXXRecordDecl * getAsCXXRecordDecl() const
Retrieves the CXXRecordDecl that this type refers to, either because the type is a RecordType or beca...
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 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 * getAsCanonical() const
If this type is canonically the specified type, return its canonical type cast to that specified type...
const T * getAs() const
Member-template getAs<specific type>'.
bool isRecordType() const
QualType getUnderlyingType() const
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,...
void deduceParmAddressSpace(const ASTContext &Ctxt)
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.
QualType getElementType() const
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...
bool isSubstitutionFailure() const
SubstitutionDiagnostic * getSubstitutionDiagnostic() const
TypeSourceInfo * getType() const
CXXRecordDecl * Lambda
The class that describes the lambda.
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.
PRESERVE_NONE bool Ret(InterpState &S)
std::variant< struct RequiresDecl, struct HeaderDecl, struct UmbrellaDirDecl, struct ModuleDecl, struct ExcludeDecl, struct ExportDecl, struct ExportAsDecl, struct ExternModuleDecl, struct UseDecl, struct LinkDecl, struct ConfigMacrosDecl, struct ConflictDecl > Decl
All declarations that can appear in a module declaration.
Attr * instantiateTemplateAttribute(const Attr *At, ASTContext &C, Sema &S, const MultiLevelTemplateArgumentList &TemplateArgs)
Attr * instantiateTemplateAttributeForDecl(const Attr *At, ASTContext &C, Sema &S, const MultiLevelTemplateArgumentList &TemplateArgs)
Top level wrappers for InstallAPI frontend operations.
bool isa(CodeGen::Address addr)
if(T->getSizeExpr()) TRY_TO(TraverseStmt(const_cast< Expr * >(T -> getSizeExpr())))
@ Specialization
We are substituting template parameters for template arguments in order to form a template specializa...
@ Ambiguous
Name lookup results in an ambiguity; use getAmbiguityKind to figure out what kind of ambiguity we hav...
@ TemplateName
The identifier is a template name. FIXME: Add an annotation for that.
NamedDecl * getAsNamedDecl(TemplateParameter P)
@ OK_Ordinary
An ordinary object is located at an address in memory.
std::pair< llvm::PointerUnion< const TemplateTypeParmType *, NamedDecl *, const TemplateSpecializationType *, const SubstBuiltinTemplatePackType * >, SourceLocation > UnexpandedParameterPack
bool isPackProducingBuiltinTemplateName(TemplateName N)
nullptr
This class represents a compute construct, representing a 'Kind' of ‘parallel’, 'serial',...
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.
OptionalUnsigned< unsigned > UnsignedOrNone
@ 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...
std::pair< SourceLocation, PartialDiagnostic > PartialDiagnosticAt
A partial diagnostic along with the source location where this diagnostic occurs.
ExprValueKind
The categorization of expression values, currently following the C++11 scheme.
@ VK_PRValue
A pr-value expression (in the C++11 taxonomy) produces a temporary value.
@ VK_XValue
An x-value expression is a reference to an object with independent storage but which can be "moved",...
@ VK_LValue
An l-value expression is a reference to an object with independent storage.
llvm::PointerUnion< TemplateTypeParmDecl *, NonTypeTemplateParmDecl *, TemplateTemplateParmDecl * > TemplateParameter
Stores a template parameter of any kind.
DynamicRecursiveASTVisitorBase< false > DynamicRecursiveASTVisitor
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,...
U cast(CodeGen::Address addr)
@ PackIndex
Index of a pack indexing expression or specifier.
@ Enum
The "enum" keyword introduces the elaborated-type-specifier.
ActionResult< Expr * > ExprResult
@ EST_Uninstantiated
not instantiated yet
@ EST_None
no exception specification
ActionResult< Stmt * > StmtResult
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 ('>').
const TemplateArgumentLoc * getTemplateArgs() const
Retrieve the template arguments.
SourceLocation LAngleLoc
The source location of the left angle bracket ('<').
SourceLocation getLAngleLoc() const
ArrayRef< TemplateArgumentLoc > arguments() const
unsigned getNumTemplateArgs() const
SourceLocation getRAngleLoc() 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
constexpr underlying_type toInternalRepresentation() const
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.
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.
@ 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.
@ SYCLKernelLaunchOverloadResolution
We are performing overload resolution for a call to a function template or variable template named 's...
@ ExpansionStmtInstantiation
We are instantiating an expansion statement.
@ 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<=>.
@ SYCLKernelLaunchLookup
We are performing name lookup for a function template or variable template named 'sycl_kernel_launch'...
@ 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.
LocalInstantiationScope * Scope
void set(DeclAccessPair Found, Decl *Spec, DeductionFailureInfo Info)
bool ExpandUnderForgetSubstitions
UnsignedOrNone NumExpansions