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 << SKEPAttr->getKernelName());
1294 const auto *SKEPAttr =
1295 Active->Entity->getAttr<SYCLKernelEntryPointAttr>();
1296 assert(SKEPAttr &&
"Missing sycl_kernel_entry_point attribute");
1297 assert(!SKEPAttr->isInvalidAttr() &&
1298 "sycl_kernel_entry_point attribute is invalid");
1299 DiagFunc(SKEPAttr->getLocation(),
PDiag(diag::note_sycl_runtime_defect));
1300 DiagFunc(SKEPAttr->getLocation(),
1301 PDiag(diag::note_sycl_kernel_launch_overload_resolution_here)
1302 << SKEPAttr->getKernelName()
1305 Active->NumCallArgs)));
1309 Diags.Report(Active->PointOfInstantiation,
1310 diag::note_expansion_stmt_instantiation_here);
1320 class TemplateInstantiator :
public TreeTransform<TemplateInstantiator> {
1325 bool EvaluateConstraints =
true;
1326 bool EvaluateLambdaConstraint =
false;
1329 bool IsIncomplete =
false;
1331 bool BailOutOnIncomplete;
1333 std::optional<llvm::FoldingSetNodeID> TemplateArgsHashValue;
1334 llvm::DenseMap<llvm::FoldingSetNodeIDRef, TemplateArgumentLoc>
1335 *CurrentCachedTemplateArgs =
nullptr;
1342 bool instantiateMissingDeclsToScopeForConcepts(
Decl *D);
1347 TemplateInstantiator(
Sema &SemaRef,
1350 bool BailOutOnIncomplete =
false)
1351 : inherited(SemaRef), TemplateArgs(TemplateArgs), Loc(Loc),
1352 Entity(Entity), BailOutOnIncomplete(BailOutOnIncomplete) {
1355 "Cannot perform an instantiation without some context on the "
1356 "instantiation stack");
1359 void setEvaluateConstraints(
bool B) {
1360 EvaluateConstraints = B;
1362 bool getEvaluateConstraints() {
1363 return EvaluateConstraints;
1366 inline static struct ForParameterMappingSubstitution_t {
1367 } ForParameterMappingSubstitution;
1369 inline static struct ForConstraintSubstitution_t {
1370 } ForConstraintSubstitution;
1372 TemplateInstantiator(
1373 ForParameterMappingSubstitution_t, Sema &SemaRef, SourceLocation Loc,
1374 const MultiLevelTemplateArgumentList &TemplateArgs,
1375 llvm::DenseMap<llvm::FoldingSetNodeIDRef, TemplateArgumentLoc> *
Cache)
1376 : inherited(SemaRef), TemplateArgs(TemplateArgs), Loc(Loc),
1377 EvaluateLambdaConstraint(
true), BailOutOnIncomplete(
false),
1378 CurrentCachedTemplateArgs(
Cache) {
1381 auto &
V = TemplateArgsHashValue.emplace();
1382 for (
auto &
Level : TemplateArgs)
1383 for (
auto &Arg :
Level.Args)
1387 TemplateInstantiator(ForConstraintSubstitution_t, Sema &SemaRef,
1388 const MultiLevelTemplateArgumentList &TemplateArgs,
1389 SourceLocation Loc, DeclarationName Entity,
1390 bool BailOutOnIncomplete =
false)
1391 : inherited(SemaRef), TemplateArgs(TemplateArgs), Loc(Loc),
1392 EvaluateLambdaConstraint(
true), BailOutOnIncomplete(
false) {}
1399 bool AlreadyTransformed(QualType
T);
1402 SourceLocation getBaseLocation() {
return Loc; }
1405 DeclarationName getBaseEntity() {
return Entity; }
1408 bool getIsIncomplete()
const {
return IsIncomplete; }
1412 void setBase(SourceLocation Loc, DeclarationName Entity) {
1414 this->Entity = Entity;
1417 unsigned TransformTemplateDepth(
unsigned Depth) {
1418 return TemplateArgs.getNewDepth(Depth);
1421 bool TryExpandParameterPacks(SourceLocation EllipsisLoc,
1422 SourceRange PatternRange,
1423 ArrayRef<UnexpandedParameterPack> Unexpanded,
1424 bool FailOnPackProducingTemplates,
1425 bool &ShouldExpand,
bool &RetainExpansion,
1427 bool Diagnose =
true) {
1429 if (instantiateMissingDeclsToScopeForConcepts(
1430 dyn_cast<NamedDecl *>(ParmPack.first)))
1434 return getSema().CheckParameterPacksForExpansion(
1435 EllipsisLoc, PatternRange, Unexpanded, TemplateArgs,
1436 FailOnPackProducingTemplates, ShouldExpand, RetainExpansion,
1437 NumExpansions, Diagnose);
1440 void ExpandingFunctionParameterPack(ParmVarDecl *Pack) {
1444 TemplateArgument ForgetPartiallySubstitutedPack() {
1448 MultiLevelTemplateArgumentList &TemplateArgs =
1449 const_cast<MultiLevelTemplateArgumentList &
>(this->TemplateArgs);
1450 unsigned Depth, Index;
1453 Result = TemplateArgs(Depth, Index);
1454 TemplateArgs.
setArgument(Depth, Index, TemplateArgument());
1456 IsIncomplete =
true;
1457 if (BailOutOnIncomplete)
1458 return TemplateArgument();
1465 void RememberPartiallySubstitutedPack(TemplateArgument Arg) {
1471 MultiLevelTemplateArgumentList &TemplateArgs =
1472 const_cast<MultiLevelTemplateArgumentList &
>(this->TemplateArgs);
1473 unsigned Depth, Index;
1479 MultiLevelTemplateArgumentList ForgetSubstitution() {
1480 MultiLevelTemplateArgumentList
New;
1483 MultiLevelTemplateArgumentList Old =
1484 const_cast<MultiLevelTemplateArgumentList &
>(this->TemplateArgs);
1485 const_cast<MultiLevelTemplateArgumentList &
>(this->TemplateArgs) =
1490 void RememberSubstitution(MultiLevelTemplateArgumentList Old) {
1491 const_cast<MultiLevelTemplateArgumentList &
>(this->TemplateArgs) =
1496 getTemplateArgumentPackPatternForRewrite(
const TemplateArgument &TA) {
1502 "unexpected pack arguments in template rewrite");
1511 Decl *TransformDecl(SourceLocation Loc, Decl *D);
1513 void transformAttrs(Decl *Old, Decl *
New) {
1517 void transformedLocalDecl(Decl *Old, ArrayRef<Decl *> NewDecls) {
1519 (NewDecls.size() != 1 || !NewDecls.front()->isParameterPack())) {
1521 for (
auto *
New : NewDecls)
1527 assert(NewDecls.size() == 1 &&
1528 "should only have multiple expansions for a pack");
1534 auto *NewMD = dyn_cast<CXXMethodDecl>(
New);
1536 auto *OldMD = dyn_cast<CXXMethodDecl>(Old);
1537 if (
auto *NewTD = NewMD->getDescribedFunctionTemplate())
1538 NewTD->setInstantiatedFromMemberTemplate(
1539 OldMD->getDescribedFunctionTemplate());
1541 NewMD->setInstantiationOfMemberFunction(OldMD,
1549 if (
auto *DC = dyn_cast<DeclContext>(Old);
1550 DC && DC->isDependentContext() && DC->isFunctionOrMethod())
1556 Decl *TransformDefinition(SourceLocation Loc, Decl *D);
1560 NamedDecl *TransformFirstQualifierInScope(NamedDecl *D, SourceLocation Loc);
1562 bool TransformExceptionSpec(SourceLocation Loc,
1563 FunctionProtoType::ExceptionSpecInfo &ESI,
1564 SmallVectorImpl<QualType> &Exceptions,
1569 VarDecl *RebuildExceptionDecl(VarDecl *ExceptionDecl,
1570 TypeSourceInfo *Declarator,
1571 SourceLocation StartLoc,
1572 SourceLocation NameLoc,
1573 IdentifierInfo *Name);
1577 VarDecl *RebuildObjCExceptionDecl(VarDecl *ExceptionDecl,
1578 TypeSourceInfo *TSInfo, QualType
T);
1581 TransformTemplateName(NestedNameSpecifierLoc &QualifierLoc,
1583 SourceLocation NameLoc,
1584 QualType ObjectType = QualType(),
1585 NamedDecl *FirstQualifierInScope =
nullptr,
1586 bool AllowInjectedClassName =
false);
1588 const AnnotateAttr *TransformAnnotateAttr(
const AnnotateAttr *AA);
1589 const CXXAssumeAttr *TransformCXXAssumeAttr(
const CXXAssumeAttr *AA);
1590 const LoopHintAttr *TransformLoopHintAttr(
const LoopHintAttr *LH);
1591 const NoInlineAttr *TransformStmtNoInlineAttr(
const Stmt *OrigS,
1593 const NoInlineAttr *A);
1594 const AlwaysInlineAttr *
1595 TransformStmtAlwaysInlineAttr(
const Stmt *OrigS,
const Stmt *InstS,
1596 const AlwaysInlineAttr *A);
1597 const CodeAlignAttr *TransformCodeAlignAttr(
const CodeAlignAttr *CA);
1598 const OpenACCRoutineDeclAttr *
1599 TransformOpenACCRoutineDeclAttr(
const OpenACCRoutineDeclAttr *A);
1600 ExprResult TransformPredefinedExpr(PredefinedExpr *E);
1601 ExprResult TransformDeclRefExpr(DeclRefExpr *E);
1602 ExprResult TransformCXXDefaultArgExpr(CXXDefaultArgExpr *E);
1604 ExprResult TransformTemplateParmRefExpr(DeclRefExpr *E,
1605 NonTypeTemplateParmDecl *D);
1608 ExprResult RebuildVarDeclRefExpr(ValueDecl *PD, SourceLocation Loc);
1611 ExprResult TransformFunctionParmPackRefExpr(DeclRefExpr *E, ValueDecl *PD);
1616 ExprResult TransformFunctionParmPackExpr(FunctionParmPackExpr *E);
1618 QualType TransformFunctionProtoType(TypeLocBuilder &TLB,
1619 FunctionProtoTypeLoc TL) {
1621 return inherited::TransformFunctionProtoType(TLB, TL);
1624 QualType TransformTagType(TypeLocBuilder &TLB, TagTypeLoc TL) {
1625 auto Type = inherited::TransformTagType(TLB, TL);
1631 if (
const auto *ICNT = dyn_cast<InjectedClassNameType>(TL.
getTypePtr());
1634 Type = inherited::TransformType(
1635 ICNT->getDecl()->getCanonicalTemplateSpecializationType(
1645 bool TransformTemplateArgument(
const TemplateArgumentLoc &Input,
1646 TemplateArgumentLoc &Output,
1647 bool Uneval =
false) {
1648 const TemplateArgument &Arg = Input.
getArgument();
1649 if (
auto *
Cache = CurrentCachedTemplateArgs;
1650 Cache && TemplateArgsHashValue) {
1651 llvm::FoldingSetNodeID
ID = *TemplateArgsHashValue;
1661 if (
auto Iter =
Cache->find(ID); Iter !=
Cache->end()) {
1662 Output = Iter->second;
1665 bool Ret = inherited::TransformTemplateArgument(Input, Output, Uneval);
1672 std::vector<TemplateArgument> TArgs;
1680 pack, QualType(), SourceLocation{});
1681 TemplateArgumentLoc Output;
1682 if (TransformTemplateArgument(Input, Output, Uneval))
1687 TemplateArgument(llvm::ArrayRef(TArgs).copy(SemaRef.
Context)),
1688 QualType(), SourceLocation{});
1694 return inherited::TransformTemplateArgument(Input, Output, Uneval);
1699 TransformTemplateSpecializationType(TypeLocBuilder &TLB,
1700 TemplateSpecializationTypeLoc TL) {
1702 if (!getSema().ArgPackSubstIndex || !
T->
isSugared() ||
1712 QualType
R = TransformType(
T->
desugar());
1718 ArrayRef<TemplateArgument> PackArgs) {
1729 return std::nullopt;
1731 return inherited::ComputeSizeOfPackExprWithoutSubstitution(PackArgs);
1734 template<
typename Fn>
1735 QualType TransformFunctionProtoType(TypeLocBuilder &TLB,
1736 FunctionProtoTypeLoc TL,
1737 CXXRecordDecl *ThisContext,
1738 Qualifiers ThisTypeQuals,
1739 Fn TransformExceptionSpec);
1741 ParmVarDecl *TransformFunctionTypeParam(ParmVarDecl *OldParm,
1742 int indexAdjustment,
1744 bool ExpectParameterPack);
1746 using inherited::TransformFunctionTypeParams;
1747 bool TransformFunctionTypeParams(
1748 SourceLocation Loc, ArrayRef<ParmVarDecl *> Params,
1749 const QualType *ParamTypes,
1750 const FunctionProtoType::ExtParameterInfo *ParamInfos,
1751 SmallVectorImpl<QualType> &PTypes,
1752 SmallVectorImpl<ParmVarDecl *> *PVars,
1753 Sema::ExtParameterInfoBuilder &PInfos,
unsigned *LastParamTransformed);
1755 using inherited::TransformTemplateTypeParmType;
1758 QualType TransformTemplateTypeParmType(TypeLocBuilder &TLB,
1759 TemplateTypeParmTypeLoc TL,
1760 bool SuppressObjCLifetime);
1762 QualType BuildSubstTemplateTypeParmType(
1763 TypeLocBuilder &TLB,
bool SuppressObjCLifetime,
bool Final,
1765 TemplateArgument Arg, SourceLocation NameLoc);
1770 using inherited::TransformSubstTemplateTypeParmPackType;
1772 TransformSubstTemplateTypeParmPackType(TypeLocBuilder &TLB,
1773 SubstTemplateTypeParmPackTypeLoc TL,
1774 bool SuppressObjCLifetime);
1776 TransformSubstBuiltinTemplatePackType(TypeLocBuilder &TLB,
1777 SubstBuiltinTemplatePackTypeLoc TL);
1780 ComputeLambdaDependency(LambdaScopeInfo *LSI) {
1782 TemplateInstArgsHelpers::getEnclosingTypeAliasTemplateDecl(
1784 TypeAlias && TemplateInstArgsHelpers::isLambdaEnclosedByTypeAliasDecl(
1786 unsigned TypeAliasDeclDepth =
TypeAlias.Template->getTemplateDepth();
1788 return CXXRecordDecl::LambdaDependencyKind::LDK_AlwaysDependent;
1789 for (
const TemplateArgument &TA :
TypeAlias.AssociatedTemplateArguments)
1791 return CXXRecordDecl::LambdaDependencyKind::LDK_AlwaysDependent;
1793 if (
auto *CD = dyn_cast_if_present<ImplicitConceptSpecializationDecl>(
1795 if (llvm::any_of(CD->getTemplateArguments(),
1796 [](
const auto &TA) { return TA.isDependent(); }))
1797 return CXXRecordDecl::LambdaDependencyKind::LDK_AlwaysDependent;
1799 return inherited::ComputeLambdaDependency(LSI);
1802 ExprResult TransformLambdaConstraint(Expr *AC) {
1803 if (AC && EvaluateLambdaConstraint)
1804 return TransformExpr(
const_cast<Expr *
>(AC));
1814 LocalInstantiationScope Scope(SemaRef,
true,
1816 llvm::SaveAndRestore RAII(EvaluateConstraints, EvaluateLambdaConstraint);
1818 return inherited::TransformLambdaExpr(E);
1821 ExprResult TransformBlockExpr(BlockExpr *E) {
1822 LocalInstantiationScope Scope(SemaRef,
true,
1824 return inherited::TransformBlockExpr(E);
1827 ExprResult RebuildLambdaExpr(SourceLocation StartLoc, SourceLocation EndLoc,
1828 LambdaScopeInfo *LSI) {
1831 assert(PVD &&
"null in a parameter list");
1832 if (!PVD->hasDefaultArg())
1834 Expr *UninstExpr = PVD->getUninstantiatedDefaultArg();
1836 SourceLocation EqualLoc = UninstExpr->
getBeginLoc();
1845 PVD->setDefaultArg(ErrorResult.
get());
1848 return inherited::RebuildLambdaExpr(StartLoc, EndLoc, LSI);
1861 llvm::SaveAndRestore _(EvaluateConstraints,
true);
1862 return inherited::TransformLambdaBody(E, Body);
1866 LocalInstantiationScope Scope(SemaRef,
true);
1867 ExprResult TransReq = inherited::TransformRequiresExpr(E);
1870 assert(TransReq.
get() != E &&
1871 "Do not change value of isSatisfied for the existing expression. "
1872 "Create a new expression instead.");
1874 Sema::SFINAETrap Trap(SemaRef);
1879 if (Trap.hasErrorOccurred())
1885 bool TransformRequiresExprRequirements(
1886 ArrayRef<concepts::Requirement *> Reqs,
1887 SmallVectorImpl<concepts::Requirement *> &Transformed) {
1888 bool SatisfactionDetermined =
false;
1889 for (concepts::Requirement *Req : Reqs) {
1890 concepts::Requirement *TransReq =
nullptr;
1891 if (!SatisfactionDetermined) {
1892 if (
auto *TypeReq = dyn_cast<concepts::TypeRequirement>(Req))
1893 TransReq = TransformTypeRequirement(TypeReq);
1894 else if (
auto *ExprReq = dyn_cast<concepts::ExprRequirement>(Req))
1895 TransReq = TransformExprRequirement(ExprReq);
1897 TransReq = TransformNestedRequirement(
1907 SatisfactionDetermined =
true;
1910 Transformed.push_back(TransReq);
1915 TemplateParameterList *TransformTemplateParameterList(
1916 TemplateParameterList *OrigTPL) {
1917 if (!OrigTPL || !OrigTPL->
size())
return OrigTPL;
1920 TemplateDeclInstantiator DeclInstantiator(getSema(),
1923 DeclInstantiator.setEvaluateConstraints(EvaluateConstraints);
1924 return DeclInstantiator.SubstTemplateParams(OrigTPL);
1927 concepts::TypeRequirement *
1928 TransformTypeRequirement(concepts::TypeRequirement *Req);
1929 concepts::ExprRequirement *
1930 TransformExprRequirement(concepts::ExprRequirement *Req);
1931 concepts::NestedRequirement *
1932 TransformNestedRequirement(concepts::NestedRequirement *Req);
1934 SourceLocation KWLoc, SourceLocation RBraceLoc,
const RequiresExpr *RE,
1935 RequiresExprBodyDecl *Body, ArrayRef<ParmVarDecl *> Params,
1936 SmallVectorImpl<QualType> &PTypes,
1937 SmallVectorImpl<ParmVarDecl *> &TransParams,
1938 Sema::ExtParameterInfoBuilder &PInfos);
1940 ExprResult TransformCXXDynamicCastExpr(CXXDynamicCastExpr *E) {
1942 if (
Ret.isInvalid())
1944 QualType
T =
Ret.get()->getType();
1948 if (DestDecl && DestDecl->isEffectivelyFinal())
1949 getSema().MarkVTableUsed(
Ret.get()->getExprLoc(), DestDecl);
1955bool TemplateInstantiator::AlreadyTransformed(QualType
T) {
1963 getSema().MarkDeclarationsReferencedInType(Loc,
T);
1967Decl *TemplateInstantiator::TransformDecl(SourceLocation Loc, Decl *D) {
1971 if (TemplateTemplateParmDecl *TTP = dyn_cast<TemplateTemplateParmDecl>(D)) {
1978 TTP->getPosition())) {
1979 IsIncomplete =
true;
1980 return BailOutOnIncomplete ?
nullptr : D;
1983 TemplateArgument Arg = TemplateArgs(TTP->getDepth(), TTP->getPosition());
1985 if (TTP->isParameterPack()) {
1987 "Missing argument pack");
1988 Arg =
SemaRef.getPackSubstitutedTemplateArgument(Arg);
1993 "Wrong kind of template template argument");
1994 return Template.getAsTemplateDecl();
2001 if (instantiateMissingDeclsToScopeForConcepts(D))
2005 assert(
SemaRef.CurrentInstantiationScope);
2007 *
SemaRef.CurrentInstantiationScope->findInstantiationOf(D));
2013bool TemplateInstantiator::instantiateMissingDeclsToScopeForConcepts(Decl *D) {
2014 if (!(D && (
SemaRef.inConstraintSubstitution() ||
2015 SemaRef.inParameterMappingSubstitution())))
2018 auto *Current =
SemaRef.CurrentInstantiationScope;
2019 if (!Current || Current->getInstantiationOfIfExists(D))
2025 auto *OldParm = dyn_cast<ParmVarDecl>(D);
2029 if (!OldParm->isParameterPack())
2030 return !TransformFunctionTypeParam(OldParm, 0,
2034 SmallVector<UnexpandedParameterPack, 2> Unexpanded;
2037 TypeLoc TL = OldParm->getTypeSourceInfo()->getTypeLoc();
2038 PackExpansionTypeLoc ExpansionTL = TL.
castAs<PackExpansionTypeLoc>();
2040 SemaRef.collectUnexpandedParameterPacks(Pattern, Unexpanded);
2041 assert(!Unexpanded.empty() &&
"Pack expansion without parameter packs?");
2043 bool ShouldExpand =
false;
2044 bool RetainExpansion =
false;
2046 ExpansionTL.
getTypePtr()->getNumExpansions();
2049 Pattern.getSourceRange(), Unexpanded,
2051 ShouldExpand, RetainExpansion, NumExpansions))
2054 assert(ShouldExpand && !RetainExpansion &&
2055 "Shouldn't preserve pack expansion when evaluating constraints");
2056 ExpandingFunctionParameterPack(OldParm);
2057 for (
unsigned I = 0; I != *NumExpansions; ++I) {
2058 Sema::ArgPackSubstIndexRAII SubstIndex(getSema(), I);
2059 if (!TransformFunctionTypeParam(OldParm, 0,
2067Decl *TemplateInstantiator::TransformDefinition(SourceLocation Loc, Decl *D) {
2068 Decl *Inst = getSema().SubstDecl(D, getSema().
CurContext, TemplateArgs);
2072 getSema().CurrentInstantiationScope->InstantiatedLocal(D, Inst);
2076bool TemplateInstantiator::TransformExceptionSpec(
2077 SourceLocation Loc, FunctionProtoType::ExceptionSpecInfo &ESI,
2078 SmallVectorImpl<QualType> &Exceptions,
bool &Changed) {
2083 return inherited::TransformExceptionSpec(Loc, ESI, Exceptions, Changed);
2087TemplateInstantiator::TransformFirstQualifierInScope(NamedDecl *D,
2088 SourceLocation Loc) {
2091 if (TemplateTypeParmDecl *TTPD = dyn_cast_or_null<TemplateTypeParmDecl>(D)) {
2092 const TemplateTypeParmType *TTP
2097 TemplateArgument Arg = TemplateArgs(TTP->getDepth(), TTP->getIndex());
2099 if (TTP->isParameterPack()) {
2101 "Missing argument pack");
2106 Arg =
SemaRef.getPackSubstitutedTemplateArgument(Arg);
2111 return cast_or_null<NamedDecl>(TransformDecl(Loc, D));
2113 if (
const TagType *Tag =
T->
getAs<TagType>())
2114 return Tag->getDecl();
2117 getSema().Diag(Loc, diag::err_nested_name_spec_non_tag) <<
T;
2122 return cast_or_null<NamedDecl>(TransformDecl(Loc, D));
2126TemplateInstantiator::RebuildExceptionDecl(VarDecl *ExceptionDecl,
2127 TypeSourceInfo *Declarator,
2128 SourceLocation StartLoc,
2129 SourceLocation NameLoc,
2130 IdentifierInfo *Name) {
2131 VarDecl *Var = inherited::RebuildExceptionDecl(ExceptionDecl, Declarator,
2132 StartLoc, NameLoc, Name);
2134 getSema().CurrentInstantiationScope->InstantiatedLocal(ExceptionDecl, Var);
2138VarDecl *TemplateInstantiator::RebuildObjCExceptionDecl(VarDecl *ExceptionDecl,
2139 TypeSourceInfo *TSInfo,
2141 VarDecl *Var = inherited::RebuildObjCExceptionDecl(ExceptionDecl, TSInfo,
T);
2143 getSema().CurrentInstantiationScope->InstantiatedLocal(ExceptionDecl, Var);
2147TemplateName TemplateInstantiator::TransformTemplateName(
2148 NestedNameSpecifierLoc &QualifierLoc, SourceLocation TemplateKWLoc,
2149 TemplateName Name, SourceLocation NameLoc, QualType ObjectType,
2150 NamedDecl *FirstQualifierInScope,
bool AllowInjectedClassName) {
2152 assert(!QualifierLoc &&
"Unexpected qualifier");
2155 TTP && TTP->getDepth() < TemplateArgs.
getNumLevels()) {
2161 TTP->getPosition())) {
2162 IsIncomplete =
true;
2166 TemplateArgument Arg = TemplateArgs(TTP->getDepth(), TTP->getPosition());
2171 Arg = getTemplateArgumentPackPatternForRewrite(Arg);
2173 "unexpected nontype template argument kind in template rewrite");
2177 auto [AssociatedDecl, Final] =
2180 if (TTP->isParameterPack()) {
2182 "Missing argument pack");
2188 return getSema().Context.getSubstTemplateTemplateParmPack(
2189 Arg, AssociatedDecl, TTP->getIndex(), Final);
2193 Arg =
SemaRef.getPackSubstitutedTemplateArgument(Arg);
2197 assert(!
Template.isNull() &&
"Null template template argument");
2198 return getSema().Context.getSubstTemplateTemplateParm(
2203 if (SubstTemplateTemplateParmPackStorage *SubstPack
2208 TemplateArgument Pack = SubstPack->getArgumentPack();
2210 SemaRef.getPackSubstitutedTemplateArgument(Pack).getAsTemplate();
2211 return getSema().Context.getSubstTemplateTemplateParm(
2212 Template, SubstPack->getAssociatedDecl(), SubstPack->getIndex(),
2213 SemaRef.getPackIndex(Pack), SubstPack->getFinal());
2216 return inherited::TransformTemplateName(
2217 QualifierLoc, TemplateKWLoc, Name, NameLoc, ObjectType,
2218 FirstQualifierInScope, AllowInjectedClassName);
2222TemplateInstantiator::TransformPredefinedExpr(PredefinedExpr *E) {
2230TemplateInstantiator::TransformTemplateParmRefExpr(DeclRefExpr *E,
2231 NonTypeTemplateParmDecl *NTTP) {
2241 IsIncomplete =
true;
2242 return BailOutOnIncomplete ?
ExprError() : E;
2250 Arg = getTemplateArgumentPackPatternForRewrite(Arg);
2252 "unexpected nontype template argument kind in template rewrite");
2265 assert(!ParamType.
isNull() &&
"Shouldn't substitute to an invalid type");
2267 auto [AssociatedDecl, Final] =
2287 return new (
SemaRef.Context) SubstNonTypeTemplateParmPackExpr(
2292 Arg =
SemaRef.getPackSubstitutedTemplateArgument(Arg);
2294 return SemaRef.BuildSubstNonTypeTemplateParmExpr(
2300TemplateInstantiator::TransformAnnotateAttr(
const AnnotateAttr *AA) {
2301 SmallVector<Expr *> Args;
2302 for (Expr *Arg : AA->args()) {
2303 ExprResult Res = getDerived().TransformExpr(Arg);
2305 Args.push_back(Res.
get());
2307 return AnnotateAttr::CreateImplicit(getSema().
Context, AA->getAnnotation(),
2308 Args.data(), Args.size(), AA->getRange());
2311const CXXAssumeAttr *
2312TemplateInstantiator::TransformCXXAssumeAttr(
const CXXAssumeAttr *AA) {
2313 ExprResult Res = getDerived().TransformExpr(AA->getAssumption());
2317 if (!(Res.
get()->
getDependence() & ExprDependence::TypeValueInstantiation)) {
2318 Res = getSema().BuildCXXAssumeExpr(Res.
get(), AA->getAttrName(),
2324 return CXXAssumeAttr::CreateImplicit(getSema().
Context, Res.
get(),
2329TemplateInstantiator::TransformLoopHintAttr(
const LoopHintAttr *LH) {
2330 ExprResult TransformedExprResult = getDerived().TransformExpr(LH->getValue());
2331 if (!TransformedExprResult.
isUsable() ||
2332 TransformedExprResult.
get() == LH->getValue())
2334 Expr *TransformedExpr = TransformedExprResult.
get();
2338 LH->getSemanticSpelling() ==
2339 LoopHintAttr::Pragma_unroll))
2342 LoopHintAttr::OptionType Option = LH->getOption();
2343 LoopHintAttr::LoopHintState State = LH->getState();
2350 if (Option == LoopHintAttr::UnrollCount &&
2352 llvm::APSInt ValueAPS =
2356 if (ValueAPS.isZero() || ValueAPS.isOne()) {
2357 Option = LoopHintAttr::Unroll;
2358 State = LoopHintAttr::Disable;
2364 return LoopHintAttr::CreateImplicit(getSema().
Context, Option, State,
2365 TransformedExpr, *LH);
2367const NoInlineAttr *TemplateInstantiator::TransformStmtNoInlineAttr(
2368 const Stmt *OrigS,
const Stmt *InstS,
const NoInlineAttr *A) {
2374const AlwaysInlineAttr *TemplateInstantiator::TransformStmtAlwaysInlineAttr(
2375 const Stmt *OrigS,
const Stmt *InstS,
const AlwaysInlineAttr *A) {
2382const CodeAlignAttr *
2383TemplateInstantiator::TransformCodeAlignAttr(
const CodeAlignAttr *CA) {
2384 Expr *TransformedExpr = getDerived().TransformExpr(CA->getAlignment()).get();
2385 return getSema().BuildCodeAlignAttr(*CA, TransformedExpr);
2387const OpenACCRoutineDeclAttr *
2388TemplateInstantiator::TransformOpenACCRoutineDeclAttr(
2389 const OpenACCRoutineDeclAttr *A) {
2390 llvm_unreachable(
"RoutineDecl should only be a declaration attribute, as it "
2391 "applies to a Function Decl (and a few places for VarDecl)");
2394ExprResult TemplateInstantiator::RebuildVarDeclRefExpr(ValueDecl *PD,
2395 SourceLocation Loc) {
2396 DeclarationNameInfo NameInfo(PD->
getDeclName(), Loc);
2397 return getSema().BuildDeclarationNameExpr(CXXScopeSpec(), NameInfo, PD);
2401TemplateInstantiator::TransformFunctionParmPackExpr(FunctionParmPackExpr *E) {
2405 ValueDecl *VD = cast_or_null<ValueDecl>(TransformDecl(E->
getExprLoc(), D));
2408 return RebuildVarDeclRefExpr(VD, E->
getExprLoc());
2411 QualType
T = TransformType(E->
getType());
2417 SmallVector<ValueDecl *, 8> Vars;
2421 ValueDecl *D = cast_or_null<ValueDecl>(TransformDecl(E->
getExprLoc(), *I));
2430 getSema().MarkFunctionParmPackReferenced(PackExpr);
2435TemplateInstantiator::TransformFunctionParmPackRefExpr(DeclRefExpr *E,
2438 llvm::PointerUnion<Decl *, DeclArgumentPack *> *
Found =
2439 getSema().CurrentInstantiationScope->getInstantiationOfIfExists(PD);
2446 Decl *TransformedDecl;
2447 if (DeclArgumentPack *Pack = dyn_cast<DeclArgumentPack *>(*
Found)) {
2451 QualType
T = TransformType(E->
getType());
2456 getSema().MarkFunctionParmPackReferenced(PackExpr);
2460 TransformedDecl = (*Pack)[*getSema().ArgPackSubstIndex];
2471TemplateInstantiator::TransformDeclRefExpr(DeclRefExpr *E) {
2476 if (NonTypeTemplateParmDecl *NTTP = dyn_cast<NonTypeTemplateParmDecl>(D)) {
2478 return TransformTemplateParmRefExpr(E, NTTP);
2485 if (VarDecl *PD = dyn_cast<VarDecl>(D))
2487 if (instantiateMissingDeclsToScopeForConcepts(PD))
2490 return TransformFunctionParmPackRefExpr(E, PD);
2493 return inherited::TransformDeclRefExpr(E);
2496ExprResult TemplateInstantiator::TransformCXXDefaultArgExpr(
2497 CXXDefaultArgExpr *E) {
2499 getDescribedFunctionTemplate() &&
2500 "Default arg expressions are never formed in dependent cases.");
2501 return SemaRef.BuildCXXDefaultArgExpr(
2506template<
typename Fn>
2507QualType TemplateInstantiator::TransformFunctionProtoType(TypeLocBuilder &TLB,
2508 FunctionProtoTypeLoc TL,
2509 CXXRecordDecl *ThisContext,
2510 Qualifiers ThisTypeQuals,
2511 Fn TransformExceptionSpec) {
2519 LocalInstantiationScope *Current = getSema().CurrentInstantiationScope;
2520 std::optional<LocalInstantiationScope> Scope;
2524 return inherited::TransformFunctionProtoType(
2525 TLB, TL, ThisContext, ThisTypeQuals, TransformExceptionSpec);
2528ParmVarDecl *TemplateInstantiator::TransformFunctionTypeParam(
2529 ParmVarDecl *OldParm,
int indexAdjustment,
UnsignedOrNone NumExpansions,
2530 bool ExpectParameterPack) {
2538 if (LateParmAttrs &&
SemaRef.CurrentInstantiationScope == LateParmAttrScope)
2539 LateAttrs = LateParmAttrs;
2541 assert((
SemaRef.inConstraintSubstitution() ||
2542 SemaRef.inParameterMappingSubstitution()) &&
2543 "parameter transformed outside its prototype");
2544 auto NewParm =
SemaRef.SubstParmVarDecl(
2545 OldParm, TemplateArgs, indexAdjustment, NumExpansions,
2546 ExpectParameterPack, EvaluateConstraints, LateAttrs);
2547 if (NewParm &&
SemaRef.getLangOpts().OpenCL)
2548 SemaRef.deduceOpenCLAddressSpace(NewParm);
2552bool TemplateInstantiator::TransformFunctionTypeParams(
2553 SourceLocation Loc, ArrayRef<ParmVarDecl *> Params,
2554 const QualType *ParamTypes,
2555 const FunctionProtoType::ExtParameterInfo *ParamInfos,
2556 SmallVectorImpl<QualType> &PTypes, SmallVectorImpl<ParmVarDecl *> *PVars,
2557 Sema::ExtParameterInfoBuilder &PInfos,
unsigned *LastParamTransformed) {
2561 LocalInstantiationScope *Scope =
SemaRef.CurrentInstantiationScope;
2562 llvm::SaveAndRestore SaveLateAttrs(LateParmAttrs, &LateAttrs);
2563 llvm::SaveAndRestore SaveLateScope(LateParmAttrScope, Scope);
2564 bool Failed = inherited::TransformFunctionTypeParams(
2565 Loc, Params, ParamTypes, ParamInfos, PTypes, PVars, PInfos,
2566 LastParamTransformed);
2570 llvm::all_of(LateAttrs, [&](
const Sema::LateInstantiatedAttribute &LA) {
2571 return LA.
Scope == Scope;
2575 SemaRef.InstantiateLateAttrs(TemplateArgs, LateAttrs, Scope);
2579QualType TemplateInstantiator::BuildSubstTemplateTypeParmType(
2580 TypeLocBuilder &TLB,
bool SuppressObjCLifetime,
bool Final,
2582 TemplateArgument Arg, SourceLocation NameLoc) {
2587 if (SuppressObjCLifetime) {
2589 RQs = Replacement.getQualifiers();
2592 SemaRef.Context.getQualifiedType(Replacement.getUnqualifiedType(), RQs);
2596 QualType
Result = getSema().Context.getSubstTemplateTypeParmType(
2597 Replacement, AssociatedDecl, Index,
PackIndex, Final);
2598 SubstTemplateTypeParmTypeLoc NewTL =
2599 TLB.
push<SubstTemplateTypeParmTypeLoc>(
Result);
2605TemplateInstantiator::TransformTemplateTypeParmType(TypeLocBuilder &TLB,
2606 TemplateTypeParmTypeLoc TL,
2607 bool SuppressObjCLifetime) {
2618 IsIncomplete =
true;
2619 if (BailOutOnIncomplete)
2622 TemplateTypeParmTypeLoc NewTL
2623 = TLB.
push<TemplateTypeParmTypeLoc>(TL.
getType());
2628 TemplateArgument Arg = TemplateArgs(
T->getDepth(),
T->getIndex());
2633 Arg = getTemplateArgumentPackPatternForRewrite(Arg);
2635 "unexpected nontype template argument kind in template rewrite");
2641 auto [AssociatedDecl, Final] =
2644 if (
T->isParameterPack() ||
2651 (
T->getDecl() &&
T->getDecl()->isTemplateParameterPack())) {
2653 "Missing argument pack");
2659 QualType
Result = getSema().Context.getSubstTemplateTypeParmPackType(
2660 AssociatedDecl,
T->getIndex(), Final, Arg);
2661 SubstTemplateTypeParmPackTypeLoc NewTL
2662 = TLB.
push<SubstTemplateTypeParmPackTypeLoc>(
Result);
2669 Arg =
SemaRef.getPackSubstitutedTemplateArgument(Arg);
2673 "Template argument kind mismatch");
2675 return BuildSubstTemplateTypeParmType(TLB, SuppressObjCLifetime, Final,
2676 AssociatedDecl,
T->getIndex(),
2684 TemplateTypeParmDecl *NewTTPDecl =
nullptr;
2685 if (TemplateTypeParmDecl *OldTTPDecl =
T->getDecl())
2686 NewTTPDecl = cast_or_null<TemplateTypeParmDecl>(
2688 QualType
Result = getSema().Context.getTemplateTypeParmType(
2692 T->getIndex(),
T->isParameterPack(), NewTTPDecl);
2693 TemplateTypeParmTypeLoc NewTL = TLB.
push<TemplateTypeParmTypeLoc>(
Result);
2698QualType TemplateInstantiator::TransformSubstTemplateTypeParmPackType(
2699 TypeLocBuilder &TLB, SubstTemplateTypeParmPackTypeLoc TL,
2700 bool SuppressObjCLifetime) {
2701 const SubstTemplateTypeParmPackType *
T = TL.
getTypePtr();
2703 Decl *NewReplaced = TransformDecl(TL.
getNameLoc(),
T->getAssociatedDecl());
2708 if (NewReplaced !=
T->getAssociatedDecl())
2709 Result = getSema().Context.getSubstTemplateTypeParmPackType(
2710 NewReplaced,
T->getIndex(),
T->getFinal(),
T->getArgumentPack());
2711 SubstTemplateTypeParmPackTypeLoc NewTL =
2712 TLB.
push<SubstTemplateTypeParmPackTypeLoc>(
Result);
2717 TemplateArgument Pack =
T->getArgumentPack();
2718 TemplateArgument Arg =
SemaRef.getPackSubstitutedTemplateArgument(Pack);
2719 return BuildSubstTemplateTypeParmType(
2720 TLB, SuppressObjCLifetime,
T->getFinal(), NewReplaced,
T->getIndex(),
2724QualType TemplateInstantiator::TransformSubstBuiltinTemplatePackType(
2725 TypeLocBuilder &TLB, SubstBuiltinTemplatePackTypeLoc TL) {
2727 return TreeTransform::TransformSubstBuiltinTemplatePackType(TLB, TL);
2728 TemplateArgument
Result =
SemaRef.getPackSubstitutedTemplateArgument(
2732 return Result.getAsType();
2735static concepts::Requirement::SubstitutionDiagnostic *
2745 ErrorLoc = PDA.first;
2750 llvm::raw_svector_ostream
OS(Entity);
2754 C.backupStr(Entity), ErrorLoc,
C.backupStr(Message)};
2757concepts::Requirement::SubstitutionDiagnostic *
2760 llvm::raw_svector_ostream
OS(Entity);
2764 C.backupStr(Entity),
2765 Location, StringRef()};
2768ExprResult TemplateInstantiator::TransformRequiresTypeParams(
2781 if (getDerived().TransformFunctionTypeParams(
2782 KWLoc, Params,
nullptr,
nullptr, PTypes,
2783 &TransParams, PInfos, &ErrorIdx) ||
2784 Trap.hasErrorOccurred()) {
2790 SemaRef, Info, [&](llvm::raw_ostream &
OS) {
OS << *FailedDecl; })));
2791 return getDerived().RebuildRequiresExpr(KWLoc, Body, RE->
getLParenLoc(),
2793 TransReqs, RBraceLoc);
2799concepts::TypeRequirement *
2800TemplateInstantiator::TransformTypeRequirement(concepts::TypeRequirement *Req) {
2804 if (AlwaysRebuild())
2805 return RebuildTypeRequirement(
2811 Sema::SFINAETrap Trap(
SemaRef, Info);
2812 Sema::InstantiatingTemplate TypeInst(
2815 if (TypeInst.isInvalid())
2817 TypeSourceInfo *TransType = TransformType(Req->
getType());
2818 if (!TransType || Trap.hasErrorOccurred())
2820 [&] (llvm::raw_ostream&
OS) {
2823 return RebuildTypeRequirement(TransType);
2826concepts::ExprRequirement *
2827TemplateInstantiator::TransformExprRequirement(concepts::ExprRequirement *Req) {
2831 llvm::PointerUnion<Expr *, concepts::Requirement::SubstitutionDiagnostic *>
2838 Sema::SFINAETrap Trap(
SemaRef, Info);
2841 if (ExprInst.isInvalid())
2844 if (!TransExprRes.
isInvalid() && !Trap.hasErrorOccurred() &&
2846 TransExprRes =
SemaRef.CheckPlaceholderExpr(TransExprRes.
get());
2847 if (TransExprRes.
isInvalid() || Trap.hasErrorOccurred())
2852 TransExpr = TransExprRes.
get();
2855 std::optional<concepts::ExprRequirement::ReturnTypeRequirement> TransRetReq;
2857 if (RetReq.isEmpty())
2858 TransRetReq.emplace();
2859 else if (RetReq.isSubstitutionFailure())
2860 TransRetReq.emplace(RetReq.getSubstitutionDiagnostic());
2861 else if (RetReq.isTypeConstraint()) {
2862 TemplateParameterList *OrigTPL =
2863 RetReq.getTypeConstraintTemplateParameterList();
2865 Sema::SFINAETrap Trap(
SemaRef, Info);
2868 if (TPLInst.isInvalid())
2870 TemplateParameterList *TPL = TransformTemplateParameterList(OrigTPL);
2871 if (!TPL || Trap.hasErrorOccurred())
2873 [&] (llvm::raw_ostream&
OS) {
2874 RetReq.getTypeConstraint()->getImmediatelyDeclaredConstraint()
2875 ->printPretty(
OS,
nullptr,
SemaRef.getPrintingPolicy());
2879 TransRetReq.emplace(TPL);
2882 assert(TransRetReq &&
"All code paths leading here must set TransRetReq");
2883 if (Expr *E = dyn_cast<Expr *>(TransExpr))
2885 std::move(*TransRetReq));
2886 return RebuildExprRequirement(
2891concepts::NestedRequirement *
2892TemplateInstantiator::TransformNestedRequirement(
2893 concepts::NestedRequirement *Req) {
2897 ConstraintSatisfaction Satisfaction;
2899 auto NestedReqWithDiag = [&
C,
this](Expr *E,
2900 ConstraintSatisfaction Satisfaction) {
2902 SmallString<128> Entity;
2903 llvm::raw_svector_ostream
OS(Entity);
2904 E->printPretty(
OS,
nullptr,
SemaRef.getPrintingPolicy());
2905 return new (
C) concepts::NestedRequirement(
2906 SemaRef.Context,
C.backupStr(Entity), std::move(Satisfaction));
2910 if (AlwaysRebuild())
2918 if (!getEvaluateConstraints()) {
2920 if (TransConstraint.
isInvalid() || !TransConstraint.
get())
2924 concepts::NestedRequirement(TransConstraint.
get());
2925 ConstraintSatisfaction Satisfaction;
2926 return new (
SemaRef.Context) concepts::NestedRequirement(
2927 SemaRef.Context, TransConstraint.
get(), Satisfaction);
2931 Expr *NewConstraint;
2935 Sema::InstantiatingTemplate ConstrInst(
2937 Sema::InstantiatingTemplate::ConstraintsCheck(),
2940 if (ConstrInst.isInvalid())
2944 Req, AssociatedConstraint(Constraint), TemplateArgs,
2946 nullptr, &NewConstraint);
2950 return NestedReqWithDiag(Constraint, Satisfaction);
2954 if (!NewConstraint) {
2956 return NestedReqWithDiag(Constraint, Satisfaction);
2958 NewConstraint = Constraint;
2960 return new (
C) concepts::NestedRequirement(
C, NewConstraint, Satisfaction);
2966 bool AllowDeducedTST) {
2967 if (!
T->getType()->isInstantiationDependentType() &&
2968 !
T->getType()->isVariablyModifiedType())
2971 TemplateInstantiator Instantiator(*
this, Args, Loc, Entity);
2972 return AllowDeducedTST ? Instantiator.TransformTypeWithDeducedTST(
T)
2973 : Instantiator.TransformType(
T);
2991 TemplateInstantiator Instantiator(*
this, Args, Loc, Entity);
3005 bool *IsIncompleteSubstitution) {
3008 if (!
T->isInstantiationDependentType() && !
T->isVariablyModifiedType())
3011 TemplateInstantiator Instantiator(
3012 *
this, TemplateArgs, Loc, Entity,
3013 IsIncompleteSubstitution !=
nullptr);
3014 QualType QT = Instantiator.TransformType(
T);
3015 if (IsIncompleteSubstitution && Instantiator.getIsIncomplete())
3016 *IsIncompleteSubstitution =
true;
3021 if (
T->getType()->isInstantiationDependentType() ||
3022 T->getType()->isVariablyModifiedType())
3025 TypeLoc TL =
T->getTypeLoc().IgnoreParens();
3045 Qualifiers ThisTypeQuals,
bool EvaluateConstraints) {
3049 TemplateInstantiator Instantiator(*
this, Args, Loc, Entity);
3050 Instantiator.setEvaluateConstraints(EvaluateConstraints);
3066 Result = Instantiator.TransformFunctionProtoType(
3067 TLB, Proto, ThisContext, ThisTypeQuals,
3069 bool &Changed) {
return false; });
3071 Result = Instantiator.TransformType(TLB, TL);
3085 bool Changed =
false;
3086 TemplateInstantiator Instantiator(*
this, Args, Loc,
DeclarationName());
3087 return Instantiator.TransformExceptionSpec(Loc, ESI, ExceptionStorage,
3098 ESI, ExceptionStorage, Args))
3107 struct GetContainedInventedTypeParmVisitor :
3108 public TypeVisitor<GetContainedInventedTypeParmVisitor,
3109 TemplateTypeParmDecl *> {
3110 using TypeVisitor<GetContainedInventedTypeParmVisitor,
3116 return Visit(
T.getTypePtr());
3120 const TemplateTypeParmType *
T) {
3121 if (!
T->getDecl() || !
T->getDecl()->isImplicit())
3123 return T->getDecl();
3129 TemplateTypeParmDecl *VisitPointerType(
const PointerType *
T) {
3133 TemplateTypeParmDecl *VisitBlockPointerType(
const BlockPointerType *
T) {
3137 TemplateTypeParmDecl *VisitReferenceType(
const ReferenceType *
T) {
3138 return Visit(
T->getPointeeTypeAsWritten());
3141 TemplateTypeParmDecl *VisitMemberPointerType(
const MemberPointerType *
T) {
3145 TemplateTypeParmDecl *VisitArrayType(
const ArrayType *
T) {
3146 return Visit(
T->getElementType());
3149 TemplateTypeParmDecl *VisitDependentSizedExtVectorType(
3150 const DependentSizedExtVectorType *
T) {
3151 return Visit(
T->getElementType());
3154 TemplateTypeParmDecl *VisitVectorType(
const VectorType *
T) {
3155 return Visit(
T->getElementType());
3158 TemplateTypeParmDecl *VisitFunctionProtoType(
const FunctionProtoType *
T) {
3159 return VisitFunctionType(
T);
3162 TemplateTypeParmDecl *VisitFunctionType(
const FunctionType *
T) {
3166 TemplateTypeParmDecl *VisitParenType(
const ParenType *
T) {
3167 return Visit(
T->getInnerType());
3170 TemplateTypeParmDecl *VisitAttributedType(
const AttributedType *
T) {
3171 return Visit(
T->getModifiedType());
3174 TemplateTypeParmDecl *VisitMacroQualifiedType(
const MacroQualifiedType *
T) {
3175 return Visit(
T->getUnderlyingType());
3178 TemplateTypeParmDecl *VisitAdjustedType(
const AdjustedType *
T) {
3179 return Visit(
T->getOriginalType());
3182 TemplateTypeParmDecl *VisitPackExpansionType(
const PackExpansionType *
T) {
3183 return Visit(
T->getPattern());
3192 bool EvaluateConstraints) {
3196 if (!EvaluateConstraints) {
3198 bool ContainsUnexpandedPack =
3202 return TA.getArgument().containsUnexpandedParameterPack();
3204 if (!Index && ContainsUnexpandedPack)
3205 Index =
SemaRef.ArgPackSubstIndex;
3217 TemplateInstantiator Instantiator(
3218 TemplateInstantiator::ForConstraintSubstitution, *
this, TemplateArgs,
3220 if (Instantiator.TransformTemplateArguments(
3237 int indexAdjustment,
UnsignedOrNone NumExpansions,
bool ExpectParameterPack,
3258 }
else if (ExpectParameterPack) {
3264 diag::err_function_parameter_pack_without_parameter_packs)
3288 GetContainedInventedTypeParmVisitor().Visit(OldTSI->
getType())) {
3290 auto *Inst = cast_or_null<TemplateTypeParmDecl>(
3295 if (Inst && !Inst->getTypeConstraint()) {
3364 bool EvaluateConstraints) {
3367 assert((OldParamTypes || !llvm::is_contained(Params,
nullptr)) &&
3368 "a parameter with no ParmVarDecl needs OldParamTypes to be passed");
3369 TemplateInstantiator Instantiator(*
this, TemplateArgs, Loc,
3371 Instantiator.setEvaluateConstraints(EvaluateConstraints);
3372 return Instantiator.TransformFunctionTypeParams(Loc, Params, OldParamTypes,
3373 ExtParamInfos, ParamTypes,
3374 OutParams, ParamInfos);
3383 Expr *PatternExpr = Param->getUninstantiatedDefaultArg();
3387 if (AlreadyInstantiating) {
3388 Param->setInvalidDecl();
3389 return Diag(Param->getBeginLoc(), diag::err_recursive_default_argument)
3407 std::optional<LocalInstantiationScope> LIS;
3418 if (addInstantiatedParametersToScope(FD, PatternFD, *LIS, TemplateArgs))
3435 Param->getLocation(),
3440 Result = InitSeq.Perform(*
this, Entity, Kind, ResultE);
3470 auto ComputeInfo = [&S, &TemplateArgs, BaseSourceRange, BaseEllipsisLoc](
3477 if (IsLateExpansionAttempt) {
3484 if (!SawPackTypes) {
3496 BaseEllipsisLoc, BaseSourceRange, Unexpanded, TemplateArgs,
3501 if (ComputeInfo(
Base.getTypeSourceInfo(),
false, Info))
3505 Out =
Base.getTypeSourceInfo();
3515 if (!Out->getType()->containsUnexpandedParameterPack())
3520 if (ComputeInfo(Out,
true, Info))
3533 for (
const auto &
Base : Pattern->
bases()) {
3534 if (!
Base.getType()->isInstantiationDependentType()) {
3536 if (RD->isInvalidDecl())
3545 if (
Base.isPackExpansion()) {
3557 ArgsForSubst = &EmptyList;
3572 Instantiation,
Base.getSourceRange(),
Base.isVirtual(),
3573 Base.getAccessSpecifierAsWritten(), Expanded,
3575 InstantiatedBases.push_back(InstantiatedBase);
3584 EllipsisLoc =
Base.getEllipsisLoc();
3592 Base.getSourceRange().getBegin(),
3603 Base.getSourceRange(),
3605 Base.getAccessSpecifierAsWritten(),
3608 InstantiatedBases.push_back(InstantiatedBase);
3638 assert(!AlreadyInstantiating &&
"should have been caught by caller");
3641 return InstantiateClassImpl(PointOfInstantiation, Instantiation, Pattern,
3642 TemplateArgs, TSK, Complain);
3645bool Sema::InstantiateClassImpl(
3652 if (DiagnoseUninstantiableTemplate(PointOfInstantiation, Instantiation,
3654 Pattern, PatternDef, TSK, Complain))
3657 llvm::TimeTraceScope TimeScope(
"InstantiateClass", [&]() {
3658 llvm::TimeTraceMetadata M;
3659 llvm::raw_string_ostream OS(M.Detail);
3662 if (llvm::isTimeTraceVerbose()) {
3663 auto Loc = SourceMgr.getExpansionLoc(Instantiation->
getLocation());
3664 M.File = SourceMgr.getFilename(Loc);
3665 M.Line = SourceMgr.getExpansionLineNumber(Loc);
3670 Pattern = PatternDef;
3673 if (MemberSpecializationInfo *MSInfo
3675 MSInfo->setTemplateSpecializationKind(TSK);
3676 MSInfo->setPointOfInstantiation(PointOfInstantiation);
3677 }
else if (ClassTemplateSpecializationDecl *Spec
3678 = dyn_cast<ClassTemplateSpecializationDecl>(Instantiation)) {
3679 Spec->setTemplateSpecializationKind(TSK);
3680 Spec->setPointOfInstantiation(PointOfInstantiation);
3683 NonSFINAEContext _(*
this);
3684 InstantiatingTemplate Inst(*
this, PointOfInstantiation, Instantiation);
3685 if (Inst.isInvalid())
3687 PrettyDeclStackTraceEntry CrashInfo(Context, Instantiation, SourceLocation(),
3688 "instantiating class definition");
3692 ContextRAII SavedContext(*
this, Instantiation);
3693 EnterExpressionEvaluationContext EvalContext(
3694 *
this, Sema::ExpressionEvaluationContext::PotentiallyEvaluated);
3700 LocalInstantiationScope Scope(*
this, MergeWithParentScope);
3706 SavePendingParsedClassStateRAII SavedPendingParsedClassState(*
this);
3709 InstantiateAttrs(TemplateArgs, Pattern, Instantiation);
3719 Instantiation->
setTagKind(Pattern->getTagKind());
3722 if (SubstBaseSpecifiers(Instantiation, Pattern, TemplateArgs))
3725 TemplateDeclInstantiator Instantiator(*
this, Instantiation, TemplateArgs);
3726 Instantiator.setEvaluateConstraints(
false);
3727 SmallVector<Decl*, 4> Fields;
3729 LateInstantiatedAttrVec LateAttrs;
3730 Instantiator.enableLateAttributeInstantiation(&LateAttrs);
3732 bool MightHaveConstexprVirtualFunctions =
false;
3733 for (
auto *
Member : Pattern->decls()) {
3743 if (
Member->getDeclContext() != Pattern)
3754 if (
Member->isInvalidDecl()) {
3764 Decl *NewMember = Instantiator.Visit(
Member);
3766 if (FieldDecl *Field = dyn_cast<FieldDecl>(NewMember)) {
3767 Fields.push_back(Field);
3768 }
else if (EnumDecl *
Enum = dyn_cast<EnumDecl>(NewMember)) {
3774 Enum->isCompleteDefinition()) {
3775 MemberSpecializationInfo *MSInfo =
Enum->getMemberSpecializationInfo();
3776 assert(MSInfo &&
"no spec info for member enum specialization");
3780 }
else if (StaticAssertDecl *SA = dyn_cast<StaticAssertDecl>(NewMember)) {
3781 if (SA->isFailed()) {
3787 }
else if (CXXMethodDecl *MD = dyn_cast<CXXMethodDecl>(NewMember)) {
3790 MightHaveConstexprVirtualFunctions =
true;
3793 if (
Member->isInvalidDecl())
3807 ActOnFields(
nullptr, Instantiation->
getLocation(), Instantiation, Fields,
3808 SourceLocation(), SourceLocation(), ParsedAttributesView());
3809 CheckCompletedCXXClass(
nullptr, Instantiation);
3814 if (ParsingClassDepth == 0)
3815 ActOnFinishCXXNonNestedClass();
3818 InstantiateLateAttrs(TemplateArgs, LateAttrs,
3819 Instantiator.getStartingScope());
3820 Instantiator.disableLateAttributeInstantiation();
3822 ActOnFinishDelayedMemberInitializers(Instantiation);
3827 Instantiation->
setLocation(Pattern->getLocation());
3828 Instantiation->
setLocStart(Pattern->getInnerLocStart());
3834 if (Pattern->isDependentContext())
3835 PerformDependentDiagnostics(Pattern, TemplateArgs);
3840 P = Instantiator.delayed_partial_spec_begin(),
3841 PEnd = Instantiator.delayed_partial_spec_end();
3843 if (!Instantiator.InstantiateClassTemplatePartialSpecialization(
3844 P->first, P->second)) {
3853 P = Instantiator.delayed_var_partial_spec_begin(),
3854 PEnd = Instantiator.delayed_var_partial_spec_end();
3856 if (!Instantiator.InstantiateVarTemplatePartialSpecialization(
3857 P->first, P->second)) {
3875 MarkVTableUsed(PointOfInstantiation, Instantiation,
true);
3876 else if (MightHaveConstexprVirtualFunctions)
3877 MarkVirtualMembersReferenced(PointOfInstantiation, Instantiation,
3881 Consumer.HandleTagDeclDefinition(Instantiation);
3893 assert(!AlreadyInstantiating &&
"should have been caught by caller");
3899 Pattern, PatternDef, TSK,
true))
3901 Pattern = PatternDef;
3915 "instantiating enum definition");
3950 "pattern and instantiation disagree about init style");
3954 if (AlreadyInstantiating)
3956 return Diag(PointOfInstantiation,
3957 diag::err_default_member_initializer_cycle)
3966 Diag(PointOfInstantiation,
3967 diag::err_default_member_initializer_not_yet_parsed)
3968 << OutermostClass << Pattern;
3969 Diag(Pattern->getEndLoc(),
3970 diag::note_default_member_initializer_not_yet_parsed);
3979 "instantiating default member init");
3988 PointOfInstantiation, Instantiation,
CurContext};
4004 L->DefaultMemberInitializerInstantiated(Instantiation);
4013 struct PartialSpecMatchResult {
4058 std::optional<Sema::NonSFINAEContext> NSC(S);
4078 typedef PartialSpecMatchResult MatchResult;
4081 Template->getPartialSpecializations(PartialSpecs);
4094 if (
Template->isMemberSpecialization() &&
4095 !Partial->isMemberSpecialization())
4113 if (Matched.empty() && PrimaryStrictPackMatch)
4114 Matched = std::move(ExtraMatched);
4120 if (Matched.size() >= 1) {
4122 if (Matched.size() == 1) {
4135 PEnd = Matched.end();
4138 P->Partial, Best->Partial, PointOfInstantiation) ==
4147 PEnd = Matched.end();
4150 P->Partial, Best->Partial,
4151 PointOfInstantiation) != Best->Partial) {
4161 S.
Diag(PointOfInstantiation,
4162 diag::err_partial_spec_ordering_ambiguous)
4163 << ClassTemplateSpec;
4167 PEnd = Matched.end();
4169 S.
Diag(P->Partial->getLocation(), diag::note_partial_spec_match)
4171 P->Partial->getTemplateParameters(), *P->Args);
4186 if (
auto *PartialSpec =
4187 dyn_cast<ClassTemplatePartialSpecializationDecl *>(Specialized)) {
4189 while (PartialSpec->getInstantiatedFromMember()) {
4192 if (PartialSpec->isMemberSpecialization())
4195 PartialSpec = PartialSpec->getInstantiatedFromMember();
4197 Pattern = PartialSpec;
4200 while (
Template->getInstantiatedFromMemberTemplate()) {
4203 if (
Template->isMemberSpecialization())
4208 Pattern =
Template->getTemplatedDecl();
4218 bool PrimaryStrictPackMatch) {
4227 if (AlreadyInstantiating)
4230 bool HadAvaibilityWarning =
4236 ClassTemplateSpec, TSK,
4237 PrimaryStrictPackMatch);
4244 if (!Pattern.
get()->isCompleteDefinition() &&
4245 Pattern.
get()->hasExternalLexicalStorage())
4247 Source->CompleteType(Pattern.
get());
4249 bool Err = InstantiateClassImpl(
4250 PointOfInstantiation, ClassTemplateSpec, Pattern.
get(),
4257 if (!Err && !HadAvaibilityWarning) {
4277 "Unexpected template specialization kind!");
4278 for (
auto *D : Instantiation->
decls()) {
4279 bool SuppressNew =
false;
4280 if (
auto *
Function = dyn_cast<FunctionDecl>(D)) {
4282 Function->getInstantiatedFromMemberFunction()) {
4284 if (
Function->getTrailingRequiresClause()) {
4292 if (
Function->hasAttr<ExcludeFromExplicitInstantiationAttr>())
4296 Function->getTemplateSpecializationKind();
4301 PointOfInstantiation, TSK,
Function, PrevTSK,
4302 Function->getPointOfInstantiation(), SuppressNew) ||
4315 Function->setTemplateSpecializationKind(TSK, PointOfInstantiation);
4325 std::make_pair(
Function, PointOfInstantiation));
4328 }
else if (
auto *Var = dyn_cast<VarDecl>(D)) {
4333 if (Var->
hasAttr<ExcludeFromExplicitInstantiationAttr>())
4337 assert(MSInfo &&
"No member specialization information?");
4366 }
else if (
auto *
Record = dyn_cast<CXXRecordDecl>(D)) {
4367 if (
Record->hasAttr<ExcludeFromExplicitInstantiationAttr>())
4375 if (
Record->isInjectedClassName() ||
Record->getPreviousDecl() ||
4380 assert(MSInfo &&
"No member specialization information?");
4386 if (
Context.getTargetInfo().getTriple().isOSWindows() &&
4406 assert(Pattern &&
"Missing instantiated-from-template information");
4408 if (!
Record->getDefinition()) {
4429 Record->getTemplateSpecializationKind() ==
4431 Record->setTemplateSpecializationKind(TSK);
4436 Pattern = cast_or_null<CXXRecordDecl>(
Record->getDefinition());
4440 }
else if (
auto *
Enum = dyn_cast<EnumDecl>(D)) {
4442 assert(MSInfo &&
"No member specialization information?");
4449 PointOfInstantiation, TSK,
Enum,
4455 if (
Enum->getDefinition())
4458 EnumDecl *Pattern =
Enum->getTemplateInstantiationPattern();
4459 assert(Pattern &&
"Missing instantiated-from-template information");
4470 }
else if (
auto *Field = dyn_cast<FieldDecl>(D)) {
4481 ClassPattern->
lookup(Field->getDeclName());
4514 TemplateInstantiator Instantiator(*
this, TemplateArgs,
4517 return Instantiator.TransformStmt(S);
4525 TemplateInstantiator Instantiator(*
this, TemplateArgs, Loc, Entity);
4526 return Instantiator.TransformTemplateArgument(Input, Output);
4533 TemplateInstantiator Instantiator(*
this, TemplateArgs,
SourceLocation(),
4535 return Instantiator.TransformTemplateArguments(Args.begin(), Args.end(), Out);
4542 TemplateInstantiator Instantiator(
4543 TemplateInstantiator::ForParameterMappingSubstitution, *
this, BaseLoc,
4544 TemplateArgs, CurrentCachedTemplateArgs);
4545 return Instantiator.TransformTemplateArguments(Args.begin(), Args.end(), Out);
4550 TemplateInstantiator Instantiator(
4551 TemplateInstantiator::ForConstraintSubstitution, *
this, TemplateArgs,
4556 assert(!Unexpanded.empty() &&
"Pack expansion without parameter packs?");
4559 bool RetainExpansion =
false;
4561 if (Instantiator.TryExpandParameterPacks(
4563 false, Expand, RetainExpansion,
4564 NumExpansions,
false) ||
4565 !Expand || RetainExpansion)
4566 return std::nullopt;
4568 if (NumExpansions && getLangOpts().BracketDepth < *NumExpansions)
4569 return std::nullopt;
4570 return NumExpansions;
4578 TemplateInstantiator Instantiator(*
this, TemplateArgs,
4581 return Instantiator.TransformExpr(E);
4590 TemplateInstantiator Instantiator(*
this, TemplateArgs,
SourceLocation(),
4592 return Instantiator.TransformAddressOfOperand(E);
4601 TemplateInstantiator Instantiator(
4602 TemplateInstantiator::ForConstraintSubstitution, *
this, TemplateArgs,
4604 return Instantiator.TransformExpr(E);
4612 TemplateInstantiator Instantiator(*
this, TemplateArgs,
SourceLocation(),
4614 Instantiator.setEvaluateConstraints(
false);
4615 return Instantiator.TransformExpr(E);
4623 TemplateInstantiator Instantiator(*
this, MLTAL,
SourceLocation(),
4630 if (Instantiator.TransformConceptTemplateArguments(
4654 struct ConstraintExprTransformer :
TreeTransform<ConstraintExprTransformer> {
4666 case Stmt::BinaryOperatorClass:
4667 case Stmt::ConceptSpecializationExprClass:
4668 case Stmt::ParenExprClass:
4669 case Stmt::UnresolvedLookupExprClass:
4670 case Stmt::DependentTemplateIdExprClass:
4671 return Base::TransformExpr(E);
4682 if (!(E->
getOpcode() == BinaryOperatorKind::BO_LAnd ||
4683 E->
getOpcode() == BinaryOperatorKind::BO_LOr))
4700 bool Uneval =
false) {
4702 return Base::TransformTemplateArgument(Input, Output, Uneval);
4715 if (TransformTemplateArguments(Args, NumArgs, TransArgs))
4721 ResolvedConcept, ResolvedConcept,
4746 ConceptDecl *ResolvedConcept = dyn_cast_if_present<ConceptDecl>(
4748 if (!ResolvedConcept)
4751 return RebuildConceptSpecialization(ResolvedConcept, E->
getNameLoc(),
4758 ConstraintExprTransformer Transformer(*
this, MLTALForConstraint);
4760 Transformer.TransformExpr(
const_cast<Expr *
>(ConstraintExpr));
4766 bool CXXDirectInit) {
4767 TemplateInstantiator Instantiator(*
this, TemplateArgs,
SourceLocation(),
4769 return Instantiator.TransformInitializer(
Init, CXXDirectInit);
4778 TemplateInstantiator Instantiator(*
this, TemplateArgs,
4781 return Instantiator.TransformExprs(Exprs.data(), Exprs.size(),
4791 TemplateInstantiator Instantiator(*
this, TemplateArgs, NNS.
getBeginLoc(),
4793 return Instantiator.TransformNestedNameSpecifierLoc(NNS);
4799 TemplateInstantiator Instantiator(*
this, TemplateArgs, NameInfo.
getLoc(),
4801 return Instantiator.TransformDeclarationNameInfo(NameInfo);
4809 TemplateInstantiator Instantiator(*
this, TemplateArgs, NameLoc,
4811 return Instantiator.TransformTemplateName(QualifierLoc, TemplateKWLoc, Name,
4820 if (
const ParmVarDecl *PV = dyn_cast<ParmVarDecl>(D)) {
4821 if (
const FunctionDecl *FD = dyn_cast<FunctionDecl>(PV->getDeclContext())) {
4822 unsigned i = PV->getFunctionScopeIndex();
4825 if (i < FD->getNumParams() && FD->getParamDecl(i) == PV)
4826 return FD->getCanonicalDecl()->getParamDecl(i);
4832llvm::PointerUnion<Decl *, LocalInstantiationScope::DeclArgumentPack *> *
4836 Current = Current->Outer) {
4839 const Decl *CheckD = D;
4841 LocalDeclsMap::iterator
Found = Current->LocalDecls.find(CheckD);
4842 if (
Found != Current->LocalDecls.end())
4843 return &
Found->second;
4847 if (
const TagDecl *Tag = dyn_cast<TagDecl>(CheckD))
4854 if (!Current->CombineWithOuterScope)
4861llvm::PointerUnion<Decl *, LocalInstantiationScope::DeclArgumentPack *> *
4874 if (RD->isLocalClass())
4891 assert(
isa<LabelDecl>(D) &&
"declaration not instantiated in this scope");
4897 llvm::PointerUnion<Decl *, DeclArgumentPack *> &Stored = LocalDecls[D];
4898 if (Stored.isNull()) {
4902 while (Current->CombineWithOuterScope && Current->Outer) {
4903 Current = Current->Outer;
4904 assert(!Current->LocalDecls.contains(D) &&
4905 "Instantiated local in inner and outer scopes");
4909 }
else if (
DeclArgumentPack *Pack = dyn_cast<DeclArgumentPack *>(Stored)) {
4912 assert(
cast<Decl *>(Stored) == Inst &&
"Already instantiated this local");
4920 Pack->push_back(Inst);
4927 Current && Current->CombineWithOuterScope; Current = Current->Outer)
4928 assert(!Current->LocalDecls.contains(D) &&
4929 "Creating local pack after instantiation of local");
4933 llvm::PointerUnion<Decl *, DeclArgumentPack *> &Stored = LocalDecls[D];
4936 ArgumentPacks.push_back(Pack);
4941 if (llvm::is_contained(*Pack, D))
4948 unsigned NumExplicitArgs) {
4949 assert((!PartiallySubstitutedPack || PartiallySubstitutedPack == Pack) &&
4950 "Already have a partially-substituted pack");
4951 assert((!PartiallySubstitutedPack
4952 || NumArgsInPartiallySubstitutedPack == NumExplicitArgs) &&
4953 "Wrong number of arguments in partially-substituted pack");
4954 PartiallySubstitutedPack = Pack;
4955 ArgsInPartiallySubstitutedPack = ExplicitArgs;
4956 NumArgsInPartiallySubstitutedPack = NumExplicitArgs;
4961 unsigned *NumExplicitArgs)
const {
4963 *ExplicitArgs =
nullptr;
4964 if (NumExplicitArgs)
4965 *NumExplicitArgs = 0;
4968 Current = Current->Outer) {
4969 if (Current->PartiallySubstitutedPack) {
4971 *ExplicitArgs = Current->ArgsInPartiallySubstitutedPack;
4972 if (NumExplicitArgs)
4973 *NumExplicitArgs = Current->NumArgsInPartiallySubstitutedPack;
4975 return Current->PartiallySubstitutedPack;
4978 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.
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)
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.
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
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)
llvm::PointerUnion< Decl *, DeclArgumentPack * > * findInstantiationOf(const Decl *D)
Find the instantiation of the declaration D within the current instantiation scope.
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]).
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)
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.
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.
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)
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)
Substitute the given template arguments into the given set of parameters, producing the set of parame...
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)
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)
TypeSourceInfo * SubstFunctionDeclType(TypeSourceInfo *T, const MultiLevelTemplateArgumentList &TemplateArgs, SourceLocation Loc, DeclarationName Entity, CXXRecordDecl *ThisContext, Qualifiers ThisTypeQuals, bool EvaluateConstraints=true)
A form of SubstType intended specifically for instantiating the type of a FunctionDecl.
Encodes a location in the source.
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.
const TemplateArgument & getArgument() const
Represents a template argument.
ArrayRef< TemplateArgument > getPackAsArray() const
Return the array of arguments in this template argument pack.
Expr * getAsExpr() const
Retrieve the template argument as an expression.
bool isDependent() const
Whether this template argument is dependent on a template parameter such that its result can change f...
pack_iterator pack_begin() const
Iterator referencing the first argument of a template argument pack.
bool isConceptOrConceptTemplateParameter() const
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.
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
const FunctionProtoType * T
@ 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