clang: lib/Sema/SemaTemplateInstantiateDecl.cpp Source File (original) (raw)
1
2
3
4
5
6
7
8
9
10
11
36#include "llvm/Support/TimeProfiler.h"
37#include
38
39using namespace clang;
40
44 return true;
45
48
49 return false;
50}
51
52template
53static bool SubstQualifier(Sema &SemaRef, const DeclT *OldDecl, DeclT *NewDecl,
55 if (!OldDecl->getQualifierLoc())
56 return false;
57
58 assert((NewDecl->getFriendObjectKind() ||
59 !OldDecl->getLexicalDeclContext()->isDependentContext()) &&
60 "non-friend with qualified name defined in dependent context");
62 SemaRef,
63 const_cast<DeclContext *>(NewDecl->getFriendObjectKind()
64 ? NewDecl->getLexicalDeclContext()
65 : OldDecl->getLexicalDeclContext()));
66
69 TemplateArgs);
70
71 if (!NewQualifierLoc)
72 return true;
73
74 NewDecl->setQualifierInfo(NewQualifierLoc);
75 return false;
76}
77
80 return ::SubstQualifier(SemaRef, OldDecl, NewDecl, TemplateArgs);
81}
82
85 return ::SubstQualifier(SemaRef, OldDecl, NewDecl, TemplateArgs);
86}
87
88
89#include "clang/Sema/AttrTemplateInstantiate.inc"
90
93 const AlignedAttr *Aligned, Decl *New, bool IsPackExpansion) {
94 if (Aligned->isAlignmentExpr()) {
95
98 ExprResult Result = S.SubstExpr(Aligned->getAlignmentExpr(), TemplateArgs);
99 if (!Result.isInvalid())
101 } else {
103 S.SubstType(Aligned->getAlignmentType(), TemplateArgs,
106 Aligned->getLocation(),
107 Result->getTypeLoc().getSourceRange()))
109 }
110 }
111}
112
115 const AlignedAttr *Aligned, Decl *New) {
116 if (!Aligned->isPackExpansion()) {
118 return;
119 }
120
122 if (Aligned->isAlignmentExpr())
124 Unexpanded);
125 else
127 Unexpanded);
128 assert(!Unexpanded.empty() && "Pack expansion without parameter packs?");
129
130
131 bool Expand = true, RetainExpansion = false;
133
136 Unexpanded, TemplateArgs,
137 true,
138 Expand, RetainExpansion, NumExpansions))
139 return;
140
141 if (!Expand) {
144 } else {
145 for (unsigned I = 0; I != *NumExpansions; ++I) {
148 }
149 }
150}
151
154 const AssumeAlignedAttr *Aligned, Decl *New) {
155
158
159 Expr *E, *OE = nullptr;
161 if (Result.isInvalid())
162 return;
163 E = Result.getAs<Expr>();
164
165 if (Aligned->getOffset()) {
166 Result = S.SubstExpr(Aligned->getOffset(), TemplateArgs);
167 if (Result.isInvalid())
168 return;
169 OE = Result.getAs<Expr>();
170 }
171
173}
174
177 const AlignValueAttr *Aligned, Decl *New) {
178
182 if (!Result.isInvalid())
184}
185
188 const AllocAlignAttr *Align, Decl *New) {
191 llvm::APInt(64, Align->getParamIndex().getSourceIndex()),
194}
195
201
202
203
204 bool HasDelayedArgs = Attr->delayedArgs_size();
205
207 HasDelayedArgs
210
213 false, TemplateArgs, Args))
214 return;
215
216 StringRef Str = Attr->getAnnotation();
217 if (HasDelayedArgs) {
218 if (Args.size() < 1) {
219 S.Diag(Attr->getLoc(), diag::err_attribute_too_few_arguments)
220 << Attr << 1;
221 return;
222 }
223
225 return;
226
228 ActualArgs.insert(ActualArgs.begin(), Args.begin() + 1, Args.end());
229 std::swap(Args, ActualArgs);
230 }
232 if (AA) {
233 New->addAttr(AA);
234 }
235}
236
237template
241 Expr *tempInstPriority = nullptr;
242 {
246 if (Result.isInvalid())
247 return;
248 if (Result.isUsable()) {
249 tempInstPriority = Result.get();
250 if (std::optionalllvm::APSInt CE =
252
253
254 if (!CE->isIntN(32)) {
255 S.Diag(tempInstPriority->getExprLoc(), diag::err_ice_too_large)
256 << toString(*CE, 10, false) << 32 << 1;
257 return;
258 }
259 }
260 }
261 }
262 New->addAttr(Attr::Create(C, tempInstPriority, *A));
263}
264
269 {
274 if (Result.isInvalid())
275 return nullptr;
277 }
278 if (->isTypeDependent()) {
281 return nullptr;
283 }
284
288 S.Diag(A->getLocation(), diag::err_attr_cond_never_constant_expr) << A;
289 for (const auto &P : Diags)
290 S.Diag(P.first, P.second);
291 return nullptr;
292 }
294}
295
300 S, TemplateArgs, EIA, EIA->getCond(), Tmpl, New);
301
304 Cond, EIA->getMessage()));
305}
306
311 S, TemplateArgs, DIA, DIA->getCond(), Tmpl, New);
312
316 DIA->getDefaultSeverity(), DIA->getWarningGroup(),
317 DIA->getArgDependent(), New));
318}
319
320
321
324 const CUDALaunchBoundsAttr &Attr, Decl *New) {
325
328
330 if (Result.isInvalid())
331 return;
332 Expr *MaxThreads = Result.getAs<Expr>();
333
334 Expr *MinBlocks = nullptr;
335 if (Attr.getMinBlocks()) {
336 Result = S.SubstExpr(Attr.getMinBlocks(), TemplateArgs);
337 if (Result.isInvalid())
338 return;
339 MinBlocks = Result.getAs<Expr>();
340 }
341
342 Expr *MaxBlocks = nullptr;
343 if (Attr.getMaxBlocks()) {
344 Result = S.SubstExpr(Attr.getMaxBlocks(), TemplateArgs);
345 if (Result.isInvalid())
346 return;
347 MaxBlocks = Result.getAs<Expr>();
348 }
349
351}
352
353static void
360
361
364 const OMPDeclareSimdDeclAttr &Attr, Decl *New) {
365
366 if (auto *FTD = dyn_cast(New))
367 New = FTD->getTemplatedDecl();
369 auto *ThisContext = dyn_cast_or_null(FD->getDeclContext());
372
374 if (auto *DRE = dyn_cast(E->IgnoreParenImpCasts()))
375 if (auto *PVD = dyn_cast(DRE->getDecl())) {
378 if (FD->getNumParams() > PVD->getFunctionScopeIndex())
379 Local.InstantiatedLocal(
380 PVD, FD->getParamDecl(PVD->getFunctionScopeIndex()));
381 return S.SubstExpr(E, TemplateArgs);
382 }
384 FD->isCXXInstanceMember());
385 return S.SubstExpr(E, TemplateArgs);
386 };
387
388
389
395 return Res;
397 };
398
400 if (auto *E = Attr.getSimdlen())
401 Simdlen = Subst(E);
402
403 if (Attr.uniforms_size() > 0) {
404 for(auto *E : Attr.uniforms()) {
407 continue;
408 Uniforms.push_back(Inst.get());
409 }
410 }
411
412 auto AI = Attr.alignments_begin();
413 for (auto *E : Attr.aligneds()) {
416 continue;
417 Aligneds.push_back(Inst.get());
419 if (*AI)
420 Inst = S.SubstExpr(*AI, TemplateArgs);
421 Alignments.push_back(Inst.get());
422 ++AI;
423 }
424
425 auto SI = Attr.steps_begin();
426 for (auto *E : Attr.linears()) {
429 continue;
430 Linears.push_back(Inst.get());
432 if (*SI)
433 Inst = S.SubstExpr(*SI, TemplateArgs);
434 Steps.push_back(Inst.get());
435 ++SI;
436 }
437 LinModifiers.append(Attr.modifiers_begin(), Attr.modifiers_end());
440 Uniforms, Aligneds, Alignments, Linears, LinModifiers, Steps,
442}
443
444
447 const OMPDeclareVariantAttr &Attr, Decl *New) {
448
449 if (auto *FTD = dyn_cast(New))
450 New = FTD->getTemplatedDecl();
452 auto *ThisContext = dyn_cast_or_null(FD->getDeclContext());
453
454 auto &&SubstExpr = [FD, ThisContext, &S, &TemplateArgs](Expr *E) {
455 if (auto *DRE = dyn_cast(E->IgnoreParenImpCasts()))
456 if (auto *PVD = dyn_cast(DRE->getDecl())) {
459 if (FD->getNumParams() > PVD->getFunctionScopeIndex())
460 Local.InstantiatedLocal(
461 PVD, FD->getParamDecl(PVD->getFunctionScopeIndex()));
462 return S.SubstExpr(E, TemplateArgs);
463 }
465 FD->isCXXInstanceMember());
466 return S.SubstExpr(E, TemplateArgs);
467 };
468
469
470
471 auto &&Subst = [&SubstExpr, &S](Expr *E) {
476 return Res;
478 };
479
481 if (Expr *E = Attr.getVariantFuncRef()) {
482
483
486 VariantFuncRef = Subst(E);
487 }
488
489
490
492 TI = *Attr.getTraitInfos();
493
494
495 auto SubstScoreOrConditionExpr = [&S, Subst](Expr *&E, bool) {
496 if (E) {
501 E = ER.get();
502 else
503 return true;
504 }
505 return false;
506 };
508 return;
509
510 Expr *E = VariantFuncRef.get();
511
512
513
514 std::optional<std::pair<FunctionDecl *, Expr *>> DeclVarData =
518
519 if (!DeclVarData)
520 return;
521
522 E = DeclVarData->second;
523 FD = DeclVarData->first;
524
525 if (auto *VariantDRE = dyn_cast(E->IgnoreParenImpCasts())) {
526 if (auto *VariantFD = dyn_cast(VariantDRE->getDecl())) {
527 if (auto *VariantFTD = VariantFD->getDescribedFunctionTemplate()) {
528 if (!VariantFTD->isThisDeclarationADefinition())
529 return;
533
535 New->getLocation());
536 if (!SubstFD)
537 return;
539 SubstFD->getType(), FD->getType(),
540 false,
541 false, true);
542 if (NewType.isNull())
543 return;
545 New->getLocation(), SubstFD, true,
546 false, false);
547 SubstFD->setInstantiationIsPending(!SubstFD->isDefined());
550 false,
551 SubstFD->getLocation(),
553 }
554 }
555 }
556
561
562 for (Expr *E : Attr.adjustArgsNothing()) {
565 continue;
566 NothingExprs.push_back(ER.get());
567 }
568 for (Expr *E : Attr.adjustArgsNeedDevicePtr()) {
571 continue;
572 NeedDevicePtrExprs.push_back(ER.get());
573 }
574 for (Expr *E : Attr.adjustArgsNeedDeviceAddr()) {
577 continue;
578 NeedDeviceAddrExprs.push_back(ER.get());
579 }
581
582 AppendArgs.emplace_back(II.IsTarget, II.IsTargetSync);
583 }
584
586 FD, E, TI, NothingExprs, NeedDevicePtrExprs, NeedDeviceAddrExprs,
588}
589
592 const AMDGPUFlatWorkGroupSizeAttr &Attr, Decl *New) {
593
596
598 if (Result.isInvalid())
599 return;
600 Expr *MinExpr = Result.getAs<Expr>();
601
602 Result = S.SubstExpr(Attr.getMax(), TemplateArgs);
603 if (Result.isInvalid())
604 return;
605 Expr *MaxExpr = Result.getAs<Expr>();
606
608}
609
612 const ReqdWorkGroupSizeAttr &Attr, Decl *New) {
613
616
618 if (Result.isInvalid())
619 return;
621
622 Result = S.SubstExpr(Attr.getYDim(), TemplateArgs);
623 if (Result.isInvalid())
624 return;
625 Expr *Y = Result.getAs<Expr>();
626
627 Result = S.SubstExpr(Attr.getZDim(), TemplateArgs);
628 if (Result.isInvalid())
629 return;
630 Expr *Z = Result.getAs<Expr>();
631
633 New->addAttr(::new (Context) ReqdWorkGroupSizeAttr(Context, Attr, X, Y, Z));
634}
635
639 return ES;
642 {
648 }
650 }
652 if (->isTypeDependent())
655}
656
659 const AMDGPUWavesPerEUAttr &Attr, Decl *New) {
660
663
665 if (Result.isInvalid())
666 return;
667 Expr *MinExpr = Result.getAs<Expr>();
668
669 Expr *MaxExpr = nullptr;
670 if (auto Max = Attr.getMax()) {
672 if (Result.isInvalid())
673 return;
675 }
676
678}
679
682 const AMDGPUMaxNumWorkGroupsAttr &Attr, Decl *New) {
685
686 Expr *XExpr = nullptr;
687 Expr *YExpr = nullptr;
688 Expr *ZExpr = nullptr;
689
690 if (Attr.getMaxNumWorkGroupsX()) {
694 }
695
696 if (Attr.getMaxNumWorkGroupsY()) {
700 }
701
702 if (Attr.getMaxNumWorkGroupsZ()) {
706 }
707
708 if (XExpr)
710}
711
714 const CUDAClusterDimsAttr &Attr, Decl *New) {
717
718 auto SubstElt = [&S, &TemplateArgs](Expr *E) {
719 return E ? S.SubstExpr(E, TemplateArgs).get() : nullptr;
720 };
721
722 Expr *XExpr = SubstElt(Attr.getX());
723 Expr *YExpr = SubstElt(Attr.getY());
724 Expr *ZExpr = SubstElt(Attr.getZ());
725
727}
728
729
730
731
737
738
739
740
742
743
744 if (const auto *PNA = dyn_cast(A)) {
745 QualType T = PNA->getTypedefType();
747 if (->isDependentType() && !RD->isDependentContext() &&
749 return false;
750 for (const auto *ExistingPNA : D->specific_attrs())
752 PNA->getTypedefType()))
753 return false;
754 return true;
755 }
756
757 if (const auto *BA = dyn_cast(A)) {
758 const FunctionDecl *FD = dyn_cast(D);
759 switch (BA->getID()) {
760 case Builtin::BIforward:
761
762
763
767 return false;
768 }
769 [[fallthrough]];
770 case Builtin::BImove:
771 case Builtin::BImove_if_noexcept:
772
773
774
775
777 return false;
778 break;
779 }
780 }
781
782 return true;
783}
784
787 const HLSLParamModifierAttr *Attr, const Decl *Old, Decl *New) {
790
794
795 assert(
798 "out or inout parameter type must be a reference and restrict qualified");
799}
800
802 const MallocSpanAttr *Attr,
807}
808
813 if (NamedDecl *ND = dyn_cast(New)) {
814
815
816
817 for (const auto *TmplAttr : Tmpl->attrs()) {
819 continue;
820
821
822
824 *this, dyn_cast_or_null(ND->getDeclContext()),
825 Qualifiers(), ND->isCXXInstanceMember());
826
828 TmplAttr, Context, *this, TemplateArgs);
830 New->addAttr(NewAttr);
831 }
832 }
833}
834
838 case clang::attr::CFConsumed:
840 case clang::attr::OSConsumed:
842 case clang::attr::NSConsumed:
844 default:
845 llvm_unreachable("Wrong argument supplied");
846 }
847}
848
849
852 const OpenACCRoutineDeclAttr *OldAttr, const Decl *Old, Decl *New);
853
858 for (const auto *TmplAttr : Tmpl->attrs()) {
860 continue;
861
862
863 const AlignedAttr *Aligned = dyn_cast(TmplAttr);
864 if (Aligned && Aligned->isAlignmentDependent()) {
866 continue;
867 }
868
869 if (const auto *AssumeAligned = dyn_cast(TmplAttr)) {
871 continue;
872 }
873
874 if (const auto *AlignValue = dyn_cast(TmplAttr)) {
876 continue;
877 }
878
879 if (const auto *AllocAlign = dyn_cast(TmplAttr)) {
881 continue;
882 }
883
884 if (const auto *Annotate = dyn_cast(TmplAttr)) {
886 continue;
887 }
888
889 if (auto *Constructor = dyn_cast(TmplAttr)) {
892 continue;
893 }
894
895 if (auto *Destructor = dyn_cast(TmplAttr)) {
898 continue;
899 }
900
901 if (const auto *EnableIf = dyn_cast(TmplAttr)) {
904 continue;
905 }
906
907 if (const auto *DiagnoseIf = dyn_cast(TmplAttr)) {
910 continue;
911 }
912
913 if (const auto *CUDALaunchBounds =
914 dyn_cast(TmplAttr)) {
916 *CUDALaunchBounds, New);
917 continue;
918 }
919
920 if (const auto *Mode = dyn_cast(TmplAttr)) {
922 continue;
923 }
924
925 if (const auto *OMPAttr = dyn_cast(TmplAttr)) {
927 continue;
928 }
929
930 if (const auto *OMPAttr = dyn_cast(TmplAttr)) {
932 continue;
933 }
934
935 if (const auto *ReqdWorkGroupSize =
936 dyn_cast(TmplAttr)) {
938 *ReqdWorkGroupSize, New);
939 }
940
941 if (const auto *AMDGPUFlatWorkGroupSize =
942 dyn_cast(TmplAttr)) {
944 *this, TemplateArgs, *AMDGPUFlatWorkGroupSize, New);
945 }
946
947 if (const auto *AMDGPUFlatWorkGroupSize =
948 dyn_cast(TmplAttr)) {
950 *AMDGPUFlatWorkGroupSize, New);
951 }
952
953 if (const auto *AMDGPUMaxNumWorkGroups =
954 dyn_cast(TmplAttr)) {
956 *this, TemplateArgs, *AMDGPUMaxNumWorkGroups, New);
957 }
958
959 if (const auto *CUDAClusterDims = dyn_cast(TmplAttr)) {
961 *CUDAClusterDims, New);
962 }
963
964 if (const auto *ParamAttr = dyn_cast(TmplAttr)) {
966 Tmpl, New);
967 continue;
968 }
969
970 if (const auto *RoutineAttr = dyn_cast(TmplAttr)) {
972 RoutineAttr, Tmpl, New);
973 continue;
974 }
975
976
977 if (TmplAttr->getKind() == attr::DLLExport ||
978 TmplAttr->getKind() == attr::DLLImport) {
979 if (New->hasAttr() || New->hasAttr()) {
980 continue;
981 }
982 }
983
984 if (const auto *ABIAttr = dyn_cast(TmplAttr)) {
986 continue;
987 }
988
993 true);
994 continue;
995 }
996
997 if (auto *A = dyn_cast(TmplAttr)) {
998 if (->hasAttr())
1000 continue;
1001 }
1002
1003 if (auto *A = dyn_cast(TmplAttr)) {
1004 if (->hasAttr())
1006 continue;
1007 }
1008
1009 if (auto *A = dyn_cast(TmplAttr)) {
1011 continue;
1012 }
1013
1014 if (auto *A = dyn_cast(TmplAttr)) {
1015 if (->hasAttr())
1017 continue;
1018 }
1019
1020 if (auto *A = dyn_cast(TmplAttr)) {
1022 continue;
1023 }
1024
1025 if (auto *A = dyn_cast(TmplAttr)) {
1026 if (->hasAttr()) {
1027 auto *NewAttr = A->clone(Context);
1028 NewAttr->setArgLoc(A->getArgLoc());
1029 New->addAttr(NewAttr);
1030 }
1031 continue;
1032 }
1033
1034 assert(!TmplAttr->isPackExpansion());
1035 if (TmplAttr->isLateParsed() && LateAttrs) {
1036
1037
1042 } else {
1043
1045 auto *ThisContext = dyn_cast_or_null(ND->getDeclContext());
1047 ND->isCXXInstanceMember());
1048
1050 *this, TemplateArgs);
1052 New->addAttr(NewAttr);
1053 }
1054 }
1055}
1056
1058 for (const auto *Attr : Pattern->attrs()) {
1059 if (auto *A = dyn_cast(Attr)) {
1060 if (!Inst->hasAttr())
1062 continue;
1063 }
1064 }
1065}
1066
1068 assert(Context.getTargetInfo().getCXXABI().isMicrosoft() &&
1071 if (NumParams == 0)
1072 return;
1073 DLLExportAttr *Attr = Ctor->getAttr();
1075 return;
1076 for (unsigned I = 0; I != NumParams; ++I) {
1080 }
1081}
1082
1083
1084
1085
1086
1087template
1089 DeclT *Result = D->getPreviousDecl();
1090
1091
1092
1093
1095 D->getLexicalDeclContext() != Result->getLexicalDeclContext())
1096 return nullptr;
1097
1098 return Result;
1099}
1100
1102TemplateDeclInstantiator::VisitTranslationUnitDecl(TranslationUnitDecl *D) {
1103 llvm_unreachable("Translation units cannot be instantiated");
1104}
1105
1107 llvm_unreachable("HLSL buffer declarations cannot be instantiated");
1108}
1109
1110Decl *TemplateDeclInstantiator::VisitHLSLRootSignatureDecl(
1112 llvm_unreachable("HLSL root signature declarations cannot be instantiated");
1113}
1114
1116TemplateDeclInstantiator::VisitPragmaCommentDecl(PragmaCommentDecl *D) {
1117 llvm_unreachable("pragma comment cannot be instantiated");
1118}
1119
1120Decl *TemplateDeclInstantiator::VisitPragmaDetectMismatchDecl(
1122 llvm_unreachable("pragma comment cannot be instantiated");
1123}
1124
1126TemplateDeclInstantiator::VisitExternCContextDecl(ExternCContextDecl *D) {
1127 llvm_unreachable("extern \"C\" context cannot be instantiated");
1128}
1129
1130Decl *TemplateDeclInstantiator::VisitMSGuidDecl(MSGuidDecl *D) {
1131 llvm_unreachable("GUID declaration cannot be instantiated");
1132}
1133
1134Decl *TemplateDeclInstantiator::VisitUnnamedGlobalConstantDecl(
1136 llvm_unreachable("UnnamedGlobalConstantDecl cannot be instantiated");
1137}
1138
1139Decl *TemplateDeclInstantiator::VisitTemplateParamObjectDecl(
1141 llvm_unreachable("template parameter objects cannot be instantiated");
1142}
1143
1145TemplateDeclInstantiator::VisitLabelDecl(LabelDecl *D) {
1148 SemaRef.InstantiateAttrs(TemplateArgs, D, Inst, LateAttrs, StartingScope);
1149 Owner->addDecl(Inst);
1150 return Inst;
1151}
1152
1154TemplateDeclInstantiator::VisitNamespaceDecl(NamespaceDecl *D) {
1155 llvm_unreachable("Namespaces cannot be instantiated");
1156}
1157
1158namespace {
1159class OpenACCDeclClauseInstantiator final
1161 Sema &SemaRef;
1162 const MultiLevelTemplateArgumentList &MLTAL;
1163 ArrayRef<OpenACCClause *> ExistingClauses;
1164 SemaOpenACC::OpenACCParsedClause &ParsedClause;
1165 OpenACCClause *NewClause = nullptr;
1166
1167public:
1168 OpenACCDeclClauseInstantiator(Sema &S,
1169 const MultiLevelTemplateArgumentList &MLTAL,
1170 ArrayRef<OpenACCClause *> ExistingClauses,
1171 SemaOpenACC::OpenACCParsedClause &ParsedClause)
1172 : SemaRef(S), MLTAL(MLTAL), ExistingClauses(ExistingClauses),
1173 ParsedClause(ParsedClause) {}
1174
1175 OpenACCClause *CreatedClause() { return NewClause; }
1176#define VISIT_CLAUSE(CLAUSE_NAME) \
1177 void Visit##CLAUSE_NAME##Clause(const OpenACC##CLAUSE_NAME##Clause &Clause);
1178#include "clang/Basic/OpenACCClauses.def"
1179
1182 for (Expr *CurVar : VarList) {
1183 ExprResult Res = SemaRef.SubstExpr(CurVar, MLTAL);
1184
1186 continue;
1187
1188 Res = SemaRef.OpenACC().ActOnVar(ParsedClause.getDirectiveKind(),
1190
1192 InstantiatedVarList.push_back(Res.get());
1193 }
1194 return InstantiatedVarList;
1195 }
1196};
1197
1198#define CLAUSE_NOT_ON_DECLS(CLAUSE_NAME) \
1199 void OpenACCDeclClauseInstantiator::Visit##CLAUSE_NAME##Clause( \
1200 const OpenACC##CLAUSE_NAME##Clause &) { \
1201 llvm_unreachable("Clause type invalid on declaration construct, or " \
1202 "instantiation not implemented"); \
1203 }
1204
1231#undef CLAUSE_NOT_ON_DECLS
1232
1233void OpenACCDeclClauseInstantiator::VisitGangClause(
1237 assert(C.getNumExprs() <= 1 &&
1238 "Only 1 expression allowed on gang clause in routine");
1239
1240 if (C.getNumExprs() > 0) {
1242 "Only dim allowed on routine");
1244 SemaRef.SubstExpr(const_cast<Expr *>(C.getExpr(0).second), MLTAL);
1246 ER = SemaRef.OpenACC().CheckGangExpr(ExistingClauses,
1247 ParsedClause.getDirectiveKind(),
1248 C.getExpr(0).first, ER.get());
1251 TransformedIntExprs.push_back(ER.get());
1252 }
1253 }
1254 }
1255
1256 NewClause = SemaRef.OpenACC().CheckGangClause(
1257 ParsedClause.getDirectiveKind(), ExistingClauses,
1258 ParsedClause.getBeginLoc(), ParsedClause.getLParenLoc(),
1259 TransformedGangKinds, TransformedIntExprs, ParsedClause.getEndLoc());
1260}
1261
1262void OpenACCDeclClauseInstantiator::VisitSeqClause(const OpenACCSeqClause &C) {
1264 ParsedClause.getBeginLoc(),
1265 ParsedClause.getEndLoc());
1266}
1267void OpenACCDeclClauseInstantiator::VisitNoHostClause(
1270 ParsedClause.getBeginLoc(),
1271 ParsedClause.getEndLoc());
1272}
1273
1274void OpenACCDeclClauseInstantiator::VisitDeviceTypeClause(
1276
1278 SemaRef.getASTContext(), C.getClauseKind(), ParsedClause.getBeginLoc(),
1279 ParsedClause.getLParenLoc(), C.getArchitectures(),
1280 ParsedClause.getEndLoc());
1281}
1282
1283void OpenACCDeclClauseInstantiator::VisitWorkerClause(
1285 assert(.hasIntExpr() && "Int Expr not allowed on routine 'worker' clause");
1287 ParsedClause.getBeginLoc(), {},
1288 nullptr, ParsedClause.getEndLoc());
1289}
1290
1291void OpenACCDeclClauseInstantiator::VisitVectorClause(
1293 assert(.hasIntExpr() && "Int Expr not allowed on routine 'vector' clause");
1295 ParsedClause.getBeginLoc(), {},
1296 nullptr, ParsedClause.getEndLoc());
1297}
1298
1299void OpenACCDeclClauseInstantiator::VisitCopyClause(
1301 ParsedClause.setVarListDetails(VisitVarList(C.getVarList()),
1302 C.getModifierList());
1303 if (SemaRef.OpenACC().CheckDeclareClause(ParsedClause, C.getModifierList()))
1304 return;
1306 SemaRef.getASTContext(), ParsedClause.getClauseKind(),
1307 ParsedClause.getBeginLoc(), ParsedClause.getLParenLoc(),
1308 ParsedClause.getModifierList(), ParsedClause.getVarList(),
1309 ParsedClause.getEndLoc());
1310}
1311
1312void OpenACCDeclClauseInstantiator::VisitLinkClause(
1314 ParsedClause.setVarListDetails(
1315 SemaRef.OpenACC().CheckLinkClauseVarList(VisitVarList(C.getVarList())),
1317
1318 if (SemaRef.OpenACC().CheckDeclareClause(ParsedClause,
1320 return;
1321
1323 SemaRef.getASTContext(), ParsedClause.getBeginLoc(),
1324 ParsedClause.getLParenLoc(), ParsedClause.getVarList(),
1325 ParsedClause.getEndLoc());
1326}
1327
1328void OpenACCDeclClauseInstantiator::VisitDeviceResidentClause(
1330 ParsedClause.setVarListDetails(VisitVarList(C.getVarList()),
1332 if (SemaRef.OpenACC().CheckDeclareClause(ParsedClause,
1334 return;
1336 SemaRef.getASTContext(), ParsedClause.getBeginLoc(),
1337 ParsedClause.getLParenLoc(), ParsedClause.getVarList(),
1338 ParsedClause.getEndLoc());
1339}
1340
1341void OpenACCDeclClauseInstantiator::VisitCopyInClause(
1343 ParsedClause.setVarListDetails(VisitVarList(C.getVarList()),
1344 C.getModifierList());
1345
1346 if (SemaRef.OpenACC().CheckDeclareClause(ParsedClause, C.getModifierList()))
1347 return;
1349 SemaRef.getASTContext(), ParsedClause.getClauseKind(),
1350 ParsedClause.getBeginLoc(), ParsedClause.getLParenLoc(),
1351 ParsedClause.getModifierList(), ParsedClause.getVarList(),
1352 ParsedClause.getEndLoc());
1353}
1354void OpenACCDeclClauseInstantiator::VisitCopyOutClause(
1356 ParsedClause.setVarListDetails(VisitVarList(C.getVarList()),
1357 C.getModifierList());
1358
1359 if (SemaRef.OpenACC().CheckDeclareClause(ParsedClause, C.getModifierList()))
1360 return;
1362 SemaRef.getASTContext(), ParsedClause.getClauseKind(),
1363 ParsedClause.getBeginLoc(), ParsedClause.getLParenLoc(),
1364 ParsedClause.getModifierList(), ParsedClause.getVarList(),
1365 ParsedClause.getEndLoc());
1366}
1367void OpenACCDeclClauseInstantiator::VisitCreateClause(
1369 ParsedClause.setVarListDetails(VisitVarList(C.getVarList()),
1370 C.getModifierList());
1371
1372 if (SemaRef.OpenACC().CheckDeclareClause(ParsedClause, C.getModifierList()))
1373 return;
1375 SemaRef.getASTContext(), ParsedClause.getClauseKind(),
1376 ParsedClause.getBeginLoc(), ParsedClause.getLParenLoc(),
1377 ParsedClause.getModifierList(), ParsedClause.getVarList(),
1378 ParsedClause.getEndLoc());
1379}
1380void OpenACCDeclClauseInstantiator::VisitPresentClause(
1382 ParsedClause.setVarListDetails(VisitVarList(C.getVarList()),
1384 if (SemaRef.OpenACC().CheckDeclareClause(ParsedClause,
1386 return;
1388 SemaRef.getASTContext(), ParsedClause.getBeginLoc(),
1389 ParsedClause.getLParenLoc(), ParsedClause.getVarList(),
1390 ParsedClause.getEndLoc());
1391}
1392void OpenACCDeclClauseInstantiator::VisitDevicePtrClause(
1395
1396 llvm::erase_if(VarList, [&](Expr *E) {
1398 E);
1399 });
1401 if (SemaRef.OpenACC().CheckDeclareClause(ParsedClause,
1403 return;
1405 SemaRef.getASTContext(), ParsedClause.getBeginLoc(),
1406 ParsedClause.getLParenLoc(), ParsedClause.getVarList(),
1407 ParsedClause.getEndLoc());
1408}
1409
1410void OpenACCDeclClauseInstantiator::VisitBindClause(
1412
1413 if (C.isStringArgument())
1415 SemaRef.getASTContext(), ParsedClause.getBeginLoc(),
1416 ParsedClause.getLParenLoc(), C.getStringArgument(),
1417 ParsedClause.getEndLoc());
1418 else
1420 SemaRef.getASTContext(), ParsedClause.getBeginLoc(),
1421 ParsedClause.getLParenLoc(), C.getIdentifierArgument(),
1422 ParsedClause.getEndLoc());
1423}
1424
1429
1430 for (const auto *Clause : ClauseList) {
1432 Clause->getBeginLoc());
1433 ParsedClause.setEndLoc(Clause->getEndLoc());
1434 if (const auto *WithParms = dyn_cast(Clause))
1435 ParsedClause.setLParenLoc(WithParms->getLParenLoc());
1436
1437 OpenACCDeclClauseInstantiator Instantiator{S, MLTAL, TransformedClauses,
1438 ParsedClause};
1439 Instantiator.Visit(Clause);
1440 if (Instantiator.CreatedClause())
1441 TransformedClauses.push_back(Instantiator.CreatedClause());
1442 }
1443 return TransformedClauses;
1444}
1445
1446}
1447
1450 const OpenACCRoutineDeclAttr *OldAttr, const Decl *OldDecl, Decl *NewDecl) {
1451 OpenACCRoutineDeclAttr *A =
1452 OpenACCRoutineDeclAttr::Create(S.getASTContext(), OldAttr->getLocation());
1453
1454 if (!OldAttr->Clauses.empty()) {
1456 InstantiateOpenACCClauseList(
1458 A->Clauses.assign(TransformedClauses.begin(), TransformedClauses.end());
1459 }
1460
1461
1462
1463
1465}
1466
1469 llvm::SmallVector<OpenACCClause *> TransformedClauses =
1470 InstantiateOpenACCClauseList(SemaRef, TemplateArgs, D->getDirectiveKind(),
1472
1473 if (SemaRef.OpenACC().ActOnStartDeclDirective(
1475 return nullptr;
1476
1477 DeclGroupRef Res = SemaRef.OpenACC().ActOnEndDeclDirective(
1479 D->getEndLoc(), TransformedClauses);
1480
1482 return nullptr;
1483
1485}
1486
1489 llvm::SmallVector<OpenACCClause *> TransformedClauses =
1490 InstantiateOpenACCClauseList(SemaRef, TemplateArgs, D->getDirectiveKind(),
1492
1497 FuncRef = SemaRef.OpenACC().ActOnRoutineName(FuncRef.get());
1498
1499
1500 }
1501
1502 if (SemaRef.OpenACC().ActOnStartDeclDirective(
1504 return nullptr;
1505
1506 DeclGroupRef Res = SemaRef.OpenACC().ActOnEndRoutineDeclDirective(
1509
1511 return nullptr;
1512
1514}
1515
1517TemplateDeclInstantiator::VisitNamespaceAliasDecl(NamespaceAliasDecl *D) {
1518 NamespaceAliasDecl *Inst
1526 Owner->addDecl(Inst);
1527 return Inst;
1528}
1529
1531 bool IsTypeAlias) {
1536 TSI = SemaRef.SubstType(TSI, TemplateArgs, D->getLocation(),
1538 if (!TSI) {
1540 TSI = SemaRef.Context.getTrivialTypeSourceInfo(SemaRef.Context.IntTy);
1541 }
1542 } else {
1543 SemaRef.MarkDeclarationsReferencedInType(D->getLocation(), TSI->getType());
1544 }
1545
1546
1547
1548
1549
1550
1551 if (SemaRef.getPreprocessor().NeedsStdLibCxxWorkaroundBefore(2014'04'22)) {
1552 const DecltypeType *DT = TSI->getType()->getAs();
1555 DT->isReferenceType() &&
1556 RD->getEnclosingNamespaceContext() == SemaRef.getStdNamespace() &&
1557 RD->getIdentifier() && RD->getIdentifier()->isStr("common_type") &&
1559 SemaRef.getSourceManager().isInSystemHeader(D->getBeginLoc()))
1560
1561 TSI = SemaRef.Context.getTrivialTypeSourceInfo(
1563 }
1564
1565
1567 if (IsTypeAlias)
1570 else
1574 Typedef->setInvalidDecl();
1575
1576
1577
1579 TagDecl *oldTag = oldTagType->getDecl();
1584 }
1585 }
1586
1589 TemplateArgs);
1590 if (!InstPrev)
1591 return nullptr;
1592
1594
1595
1596 SemaRef.isIncompatibleTypedef(InstPrevTypedef, Typedef);
1597
1598 Typedef->setPreviousDecl(InstPrevTypedef);
1599 }
1600
1601 SemaRef.InstantiateAttrs(TemplateArgs, D, Typedef);
1602
1604 SemaRef.inferGslPointerAttribute(Typedef);
1605
1608
1610}
1611
1612Decl *TemplateDeclInstantiator::VisitTypedefDecl(TypedefDecl *D) {
1617}
1618
1619Decl *TemplateDeclInstantiator::VisitTypeAliasDecl(TypeAliasDecl *D) {
1621 if (Typedef)
1622 Owner->addDecl(Typedef);
1623 return Typedef;
1624}
1625
1628
1629
1631
1634 if (!InstParams)
1635 return nullptr;
1636
1637
1638
1639
1640
1641
1642
1643
1647 return nullptr;
1648
1653 if (.empty()) {
1654 PrevAliasTemplate = dyn_cast(Found.front());
1655 }
1656 }
1657
1658 TypeAliasDecl *AliasInst = cast_or_null(
1660 if (!AliasInst)
1661 return nullptr;
1662
1665 D->getDeclName(), InstParams, AliasInst);
1667 if (PrevAliasTemplate)
1669
1671
1672 if (!PrevAliasTemplate)
1674
1675 return Inst;
1676}
1677
1681 if (Inst)
1683
1684 return Inst;
1685}
1686
1687Decl *TemplateDeclInstantiator::VisitBindingDecl(BindingDecl *D) {
1692
1693 return NewBD;
1694}
1695
1697
1698
1699 SmallVector<BindingDecl*, 16> NewBindings;
1700 BindingDecl *OldBindingPack = nullptr;
1701 for (auto *OldBD : D->bindings()) {
1702 Expr *BindingExpr = OldBD->getBinding();
1703 if (isa_and_present(BindingExpr)) {
1704
1705 assert(!OldBindingPack && "no more than one pack is allowed");
1706 OldBindingPack = OldBD;
1707 }
1708 NewBindings.push_back(cast(VisitBindingDecl(OldBD)));
1709 }
1710 ArrayRef<BindingDecl*> NewBindingArray = NewBindings;
1711
1712 auto *NewDD = cast_if_present(
1713 VisitVarDecl(D, false, &NewBindingArray));
1714
1715 if (!NewDD || NewDD->isInvalidDecl()) {
1716 for (auto *NewBD : NewBindings)
1717 NewBD->setInvalidDecl();
1718 } else if (OldBindingPack) {
1719
1720 auto Bindings = NewDD->bindings();
1721 BindingDecl *NewBindingPack = *llvm::find_if(
1723 assert(NewBindingPack != nullptr && "new bindings should also have a pack");
1724 llvm::ArrayRef<BindingDecl *> OldDecls =
1726 llvm::ArrayRef<BindingDecl *> NewDecls =
1728 assert(OldDecls.size() == NewDecls.size());
1729 for (unsigned I = 0; I < OldDecls.size(); I++)
1730 SemaRef.CurrentInstantiationScope->InstantiatedLocal(OldDecls[I],
1731 NewDecls[I]);
1732 }
1733
1734 return NewDD;
1735}
1736
1740
1742 bool InstantiatingVarTemplate,
1744
1745
1748 D->getDeclName(), true);
1749 if (!TSI)
1750 return nullptr;
1751
1753 SemaRef.Diag(D->getLocation(), diag::err_variable_instantiates_to_function)
1755 return nullptr;
1756 }
1757
1761
1762
1768 else
1772
1773
1774 if (SemaRef.getLangOpts().ObjCAutoRefCount &&
1777
1780
1781
1783 return nullptr;
1784
1786 StartingScope, InstantiatingVarTemplate);
1789 if (auto *F = dyn_cast(DC))
1790 RT = F->getReturnType();
1793 ->getReturnType();
1794 else
1795 llvm_unreachable("Unknown context type");
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1811 }
1812
1814
1816 SemaRef.CheckStaticLocalForDllExport(Var);
1817
1819 SemaRef.CheckThreadLocalForLargeAlignment(Var);
1820
1821 if (SemaRef.getLangOpts().OpenACC)
1822 SemaRef.OpenACC().ActOnVariableDeclarator(Var);
1823
1824 return Var;
1825}
1826
1827Decl *TemplateDeclInstantiator::VisitAccessSpecDecl(AccessSpecDecl *D) {
1828 AccessSpecDecl* AD
1831 Owner->addHiddenDecl(AD);
1832 return AD;
1833}
1834
1835Decl *TemplateDeclInstantiator::VisitFieldDecl(FieldDecl *D) {
1840 TSI = SemaRef.SubstType(TSI, TemplateArgs, D->getLocation(),
1842 if (!TSI) {
1846
1847
1848
1849
1850
1851
1852 SemaRef.Diag(D->getLocation(), diag::err_field_instantiates_to_function)
1855 }
1856 } else {
1857 SemaRef.MarkDeclarationsReferencedInType(D->getLocation(), TSI->getType());
1858 }
1859
1862 BitWidth = nullptr;
1863 else if (BitWidth) {
1864
1865 EnterExpressionEvaluationContext Unevaluated(
1867
1869 = SemaRef.SubstExpr(BitWidth, TemplateArgs);
1870 if (InstantiatedBitWidth.isInvalid()) {
1872 BitWidth = nullptr;
1873 } else
1874 BitWidth = InstantiatedBitWidth.getAs();
1875 }
1876
1877 FieldDecl *Field = SemaRef.CheckFieldDecl(
1881 if (!Field) {
1882 cast(Owner)->setInvalidDecl();
1883 return nullptr;
1884 }
1885
1886 SemaRef.InstantiateAttrs(TemplateArgs, D, Field, LateAttrs, StartingScope);
1887
1888 if (Field->hasAttrs())
1889 SemaRef.CheckAlignasUnderalignment(Field);
1890
1892 Field->setInvalidDecl();
1893
1894 if (->getDeclName() || Field->isPlaceholderVar(SemaRef.getLangOpts())) {
1895
1896 SemaRef.Context.setInstantiatedFromUnnamedFieldDecl(Field, D);
1897 }
1898 if (CXXRecordDecl *Parent= dyn_cast(Field->getDeclContext())) {
1899 if (Parent->isAnonymousStructOrUnion() &&
1900 Parent->getRedeclContext()->isFunctionOrMethod())
1901 SemaRef.CurrentInstantiationScope->InstantiatedLocal(D, Field);
1902 }
1903
1906 Owner->addDecl(Field);
1907
1909}
1910
1911Decl *TemplateDeclInstantiator::VisitMSPropertyDecl(MSPropertyDecl *D) {
1914
1916 SemaRef.Diag(D->getLocation(), diag::err_property_is_variably_modified)
1917 << D;
1920 TSI = SemaRef.SubstType(TSI, TemplateArgs, D->getLocation(),
1922 if (!TSI) {
1926
1927
1928
1929
1930
1931
1932 SemaRef.Diag(D->getLocation(), diag::err_field_instantiates_to_function)
1935 }
1936 } else {
1937 SemaRef.MarkDeclarationsReferencedInType(D->getLocation(), TSI->getType());
1938 }
1939
1944
1945 SemaRef.InstantiateAttrs(TemplateArgs, D, Property, LateAttrs,
1946 StartingScope);
1947
1950
1953
1955}
1956
1958 NamedDecl **NamedChain =
1960
1961 int i = 0;
1962 for (auto *PI : D->chain()) {
1963 NamedDecl *Next = SemaRef.FindInstantiatedDecl(D->getLocation(), PI,
1964 TemplateArgs);
1966 return nullptr;
1967
1968 NamedChain[i++] = Next;
1969 }
1970
1974 {NamedChain, D->getChainingSize()});
1975
1976 for (const auto *Attr : D->attrs())
1977 IndirectField->addAttr(Attr->clone(SemaRef.Context));
1978
1981 Owner->addDecl(IndirectField);
1982 return IndirectField;
1983}
1984
1985Decl *TemplateDeclInstantiator::VisitFriendDecl(FriendDecl *D) {
1986
1987
1989 TypeSourceInfo *InstTy;
1990
1991
1992
1993
1995 InstTy = Ty;
1996 } else {
1998 SmallVector<UnexpandedParameterPack, 2> Unexpanded;
1999 SemaRef.collectUnexpandedParameterPacks(Ty->getTypeLoc(), Unexpanded);
2000 assert(!Unexpanded.empty() && "Pack expansion without packs");
2001
2002 bool ShouldExpand = true;
2003 bool RetainExpansion = false;
2004 UnsignedOrNone NumExpansions = std::nullopt;
2005 if (SemaRef.CheckParameterPacksForExpansion(
2007 TemplateArgs, true,
2008 ShouldExpand, RetainExpansion, NumExpansions))
2009 return nullptr;
2010
2011 assert(!RetainExpansion &&
2012 "should never retain an expansion for a variadic friend decl");
2013
2014 if (ShouldExpand) {
2015 SmallVector<FriendDecl *> Decls;
2016 for (unsigned I = 0; I != *NumExpansions; I++) {
2017 Sema::ArgPackSubstIndexRAII SubstIndex(SemaRef, I);
2018 TypeSourceInfo *TSI = SemaRef.SubstType(
2019 Ty, TemplateArgs, D->getEllipsisLoc(), DeclarationName());
2020 if (!TSI)
2021 return nullptr;
2022
2023 auto FD =
2026
2028 Owner->addDecl(FD);
2029 Decls.push_back(FD);
2030 }
2031
2032
2033 return nullptr;
2034 }
2035 }
2036
2037 InstTy = SemaRef.SubstType(Ty, TemplateArgs, D->getLocation(),
2038 DeclarationName());
2039 }
2040 if (!InstTy)
2041 return nullptr;
2042
2047 Owner->addDecl(FD);
2048 return FD;
2049 }
2050
2052 assert(ND && "friend decl must be a decl or a type!");
2053
2054
2055
2056
2057
2059 if (!NewND) return nullptr;
2060
2061 FriendDecl *FD =
2066 Owner->addDecl(FD);
2067 return FD;
2068}
2069
2072
2073
2074 EnterExpressionEvaluationContext Unevaluated(
2076
2078 = SemaRef.SubstExpr(AssertExpr, TemplateArgs);
2079 if (InstantiatedAssertExpr.isInvalid())
2080 return nullptr;
2081
2082 ExprResult InstantiatedMessageExpr =
2083 SemaRef.SubstExpr(D->getMessage(), TemplateArgs);
2084 if (InstantiatedMessageExpr.isInvalid())
2085 return nullptr;
2086
2087 return SemaRef.BuildStaticAssertDeclaration(
2090}
2091
2092Decl *TemplateDeclInstantiator::VisitEnumDecl(EnumDecl *D) {
2093 EnumDecl *PrevDecl = nullptr;
2095 NamedDecl *Prev = SemaRef.FindInstantiatedDecl(D->getLocation(),
2096 PatternPrev,
2097 TemplateArgs);
2098 if (!Prev) return nullptr;
2100 }
2101
2102 EnumDecl *Enum =
2108
2109
2110
2111 SourceLocation UnderlyingLoc = TI->getTypeLoc().getBeginLoc();
2112 TypeSourceInfo *NewTI = SemaRef.SubstType(TI, TemplateArgs, UnderlyingLoc,
2113 DeclarationName());
2114 if (!NewTI || SemaRef.CheckEnumUnderlyingType(NewTI))
2115 Enum->setIntegerType(SemaRef.Context.IntTy);
2116 else {
2117
2118
2119
2120
2121
2124 else
2125 Enum->setIntegerTypeSourceInfo(NewTI);
2126 }
2127
2128
2129
2130
2131
2132
2133
2134
2135 QualType UnderlyingType = Enum->getIntegerType();
2136 Enum->setPromotionType(
2137 SemaRef.Context.isPromotableIntegerType(UnderlyingType)
2138 ? SemaRef.Context.getPromotedIntegerType(UnderlyingType)
2139 : UnderlyingType);
2140 } else {
2142 && "Dependent type without type source info");
2144 }
2145 }
2146
2147 SemaRef.InstantiateAttrs(TemplateArgs, D, Enum);
2148
2151
2152 SemaRef.Context.setManglingNumber(Enum, SemaRef.Context.getManglingNumber(D));
2153
2154
2155 if (DeclaratorDecl *DD = SemaRef.Context.getDeclaratorForUnnamedTagDecl(D))
2156 SemaRef.Context.addDeclaratorForUnnamedTagDecl(Enum, DD);
2157
2158
2159 if (TypedefNameDecl *TND = SemaRef.Context.getTypedefNameForUnnamedTagDecl(D))
2160 SemaRef.Context.addTypedefNameForUnnamedTagDecl(Enum, TND);
2162 Owner->addDecl(Enum);
2163
2165 if (Def && Def != D) {
2166
2167
2168
2170 SourceLocation UnderlyingLoc = TI->getTypeLoc().getBeginLoc();
2171 QualType DefnUnderlying =
2172 SemaRef.SubstType(TI->getType(), TemplateArgs,
2173 UnderlyingLoc, DeclarationName());
2175 DefnUnderlying, true, Enum);
2176 }
2177 }
2178
2179
2180
2181
2182
2183
2184
2185
2187
2188
2189
2190 if (PrevDecl == nullptr) {
2191 SemaRef.CurrentInstantiationScope->InstantiatedLocal(D, Enum);
2193 }
2194 }
2195
2196 return Enum;
2197}
2198
2201 Enum->startDefinition();
2202
2203
2205
2207
2209 for (auto *EC : Pattern->enumerators()) {
2210
2212 if (Expr *UninstValue = EC->getInitExpr()) {
2213
2216
2217 Value = SemaRef.SubstExpr(UninstValue, TemplateArgs);
2218 }
2219
2220
2222 if (Value.isInvalid()) {
2223 Value = nullptr;
2225 }
2226
2228 = SemaRef.CheckEnumConstant(Enum, LastEnumConst,
2231
2233 if (EnumConst)
2235 Enum->setInvalidDecl();
2236 }
2237
2238 if (EnumConst) {
2239 SemaRef.InstantiateAttrs(TemplateArgs, EC, EnumConst);
2240
2242 Enum->addDecl(EnumConst);
2243 Enumerators.push_back(EnumConst);
2244 LastEnumConst = EnumConst;
2245
2247 ->isScoped()) {
2248
2249
2250 SemaRef.CurrentInstantiationScope->InstantiatedLocal(EC, EnumConst);
2251 }
2252 }
2253 }
2254
2255 SemaRef.ActOnEnumBody(Enum->getLocation(), Enum->getBraceRange(), Enum,
2257}
2258
2260 llvm_unreachable("EnumConstantDecls can only occur within EnumDecls.");
2261}
2262
2264TemplateDeclInstantiator::VisitBuiltinTemplateDecl(BuiltinTemplateDecl *D) {
2265 llvm_unreachable("BuiltinTemplateDecls cannot be instantiated.");
2266}
2267
2270
2271
2272
2273 LocalInstantiationScope Scope(SemaRef);
2276 if (!InstParams)
2277 return nullptr;
2278
2280
2281
2282
2283
2284 NestedNameSpecifierLoc QualifierLoc = Pattern->getQualifierLoc();
2285 if (QualifierLoc) {
2286 QualifierLoc = SemaRef.SubstNestedNameSpecifierLoc(QualifierLoc,
2287 TemplateArgs);
2288 if (!QualifierLoc)
2289 return nullptr;
2290 }
2291
2292 CXXRecordDecl *PrevDecl = nullptr;
2293 ClassTemplateDecl *PrevClassTemplate = nullptr;
2294
2297 if (.empty()) {
2298 PrevClassTemplate = dyn_cast(Found.front());
2299 if (PrevClassTemplate)
2301 }
2302 }
2303
2304
2305
2306
2307
2308 DeclContext *DC = Owner;
2309 if (isFriend) {
2310 if (QualifierLoc) {
2311 CXXScopeSpec SS;
2312 SS.Adopt(QualifierLoc);
2313 DC = SemaRef.computeDeclContext(SS);
2314 if (!DC) return nullptr;
2315 } else {
2316 DC = SemaRef.FindInstantiatedContext(Pattern->getLocation(),
2318 TemplateArgs);
2319 }
2320
2321
2322
2325 SemaRef.forRedeclarationInCurContext());
2326 SemaRef.LookupQualifiedName(R, DC);
2327
2328 if (R.isSingleResult()) {
2329 PrevClassTemplate = R.getAsSingle();
2330 if (PrevClassTemplate)
2332 }
2333
2334 if (!PrevClassTemplate && QualifierLoc) {
2335 SemaRef.Diag(Pattern->getLocation(), diag::err_not_tag_in_scope)
2338 return nullptr;
2339 }
2340 }
2341
2345 if (QualifierLoc)
2347
2348 SemaRef.InstantiateAttrsForDecl(TemplateArgs, Pattern, RecordInst, LateAttrs,
2349 StartingScope);
2350
2351 ClassTemplateDecl *Inst
2355
2356 if (isFriend) {
2357 assert(!Owner->isDependentContext());
2361
2362 if (PrevClassTemplate) {
2364 const ClassTemplateDecl *MostRecentPrevCT =
2366 TemplateParameterList *PrevParams =
2368
2369
2370 if (!SemaRef.TemplateParameterListsAreEqual(
2371 RecordInst, InstParams, MostRecentPrevCT->getTemplatedDecl(),
2373 return nullptr;
2374
2375
2376
2377 if (SemaRef.CheckTemplateParameterList(InstParams, PrevParams,
2379 return nullptr;
2380
2382 } else {
2384 }
2385
2387
2388
2389 } else {
2391 if (!PrevClassTemplate)
2393 }
2394
2396
2397
2398 if (isFriend) {
2400 return Inst;
2401 }
2402
2406 }
2407
2408 Owner->addDecl(Inst);
2409
2410 if (!PrevClassTemplate) {
2411
2412
2413
2414 SmallVector<ClassTemplatePartialSpecializationDecl *, 4> PartialSpecs;
2416 for (unsigned I = 0, N = PartialSpecs.size(); I != N; ++I)
2417 if (PartialSpecs[I]->getFirstDecl()->isOutOfLine())
2418 OutOfLinePartialSpecs.push_back(std::make_pair(Inst, PartialSpecs[I]));
2419 }
2420
2421 return Inst;
2422}
2423
2425TemplateDeclInstantiator::VisitClassTemplatePartialSpecializationDecl(
2428
2429
2430
2432 = Owner->lookup(ClassTemplate->getDeclName());
2433 if (Found.empty())
2434 return nullptr;
2435
2436 ClassTemplateDecl *InstClassTemplate
2437 = dyn_cast(Found.front());
2438 if (!InstClassTemplate)
2439 return nullptr;
2440
2441 if (ClassTemplatePartialSpecializationDecl *Result
2444
2446}
2447
2448Decl *TemplateDeclInstantiator::VisitVarTemplateDecl(VarTemplateDecl *D) {
2450 "Only static data member templates are allowed.");
2451
2452
2453
2454 LocalInstantiationScope Scope(SemaRef);
2457 if (!InstParams)
2458 return nullptr;
2459
2461 VarTemplateDecl *PrevVarTemplate = nullptr;
2462
2465 if (.empty())
2466 PrevVarTemplate = dyn_cast(Found.front());
2467 }
2468
2469 VarDecl *VarInst =
2471 true));
2472 if (!VarInst) return nullptr;
2473
2474 DeclContext *DC = Owner;
2475
2478 VarInst);
2481
2483 if (!PrevVarTemplate)
2485
2489 }
2490
2491 Owner->addDecl(Inst);
2492
2493 if (!PrevVarTemplate) {
2494
2495
2496
2497 SmallVector<VarTemplatePartialSpecializationDecl *, 1> PartialSpecs;
2499 for (unsigned I = 0, N = PartialSpecs.size(); I != N; ++I)
2500 if (PartialSpecs[I]->getFirstDecl()->isOutOfLine())
2501 OutOfLineVarPartialSpecs.push_back(
2502 std::make_pair(Inst, PartialSpecs[I]));
2503 }
2504
2505 return Inst;
2506}
2507
2508Decl *TemplateDeclInstantiator::VisitVarTemplatePartialSpecializationDecl(
2511 "Only static data member templates are allowed.");
2512
2514
2515
2517 assert(.empty() && "Instantiation found nothing?");
2518
2519 VarTemplateDecl *InstVarTemplate = dyn_cast(Found.front());
2520 assert(InstVarTemplate && "Instantiation did not find a variable template?");
2521
2522 if (VarTemplatePartialSpecializationDecl *Result =
2525
2527}
2528
2530TemplateDeclInstantiator::VisitFunctionTemplateDecl(FunctionTemplateDecl *D) {
2531
2532
2533
2534
2535 LocalInstantiationScope Scope(SemaRef);
2536 Sema::ConstraintEvalRAII RAII(*this);
2537
2540 if (!InstParams)
2541 return nullptr;
2542
2543 FunctionDecl *Instantiated = nullptr;
2544 if (CXXMethodDecl *DMethod = dyn_cast(D->getTemplatedDecl()))
2545 Instantiated = cast_or_null(VisitCXXMethodDecl(DMethod,
2546 InstParams));
2547 else
2550 InstParams));
2551
2552 if (!Instantiated)
2553 return nullptr;
2554
2555
2556
2557 FunctionTemplateDecl *InstTemplate
2560 assert(InstTemplate &&
2561 "VisitFunctionDecl/CXXMethodDecl didn't create a template!");
2562
2564
2565
2566
2570
2571
2572 if (!isFriend) {
2573 Owner->addDecl(InstTemplate);
2576 SemaRef.CheckFriendAccess(InstTemplate);
2577 }
2578
2579 return InstTemplate;
2580}
2581
2582Decl *TemplateDeclInstantiator::VisitCXXRecordDecl(CXXRecordDecl *D) {
2583 CXXRecordDecl *PrevDecl = nullptr;
2585 NamedDecl *Prev = SemaRef.FindInstantiatedDecl(D->getLocation(),
2586 PatternPrev,
2587 TemplateArgs);
2588 if (!Prev) return nullptr;
2590 }
2591
2592 CXXRecordDecl *Record = nullptr;
2599 else
2603
2605
2606
2608 return nullptr;
2609
2610 SemaRef.InstantiateAttrsForDecl(TemplateArgs, D, Record, LateAttrs,
2611 StartingScope);
2612
2613
2614
2615
2618 if (!IsInjectedClassName)
2620
2621
2622
2624 Record->setObjectOfFriendDecl();
2625
2626
2628 Record->setAnonymousStructOrUnion(true);
2629
2631 SemaRef.CurrentInstantiationScope->InstantiatedLocal(D, Record);
2632
2633
2634 SemaRef.Context.setManglingNumber(Record,
2635 SemaRef.Context.getManglingNumber(D));
2636
2637
2638
2639 if (DeclaratorDecl *DD = SemaRef.Context.getDeclaratorForUnnamedTagDecl(D))
2640 SemaRef.Context.addDeclaratorForUnnamedTagDecl(Record, DD);
2641
2642
2643
2644 if (TypedefNameDecl *TND = SemaRef.Context.getTypedefNameForUnnamedTagDecl(D))
2645 SemaRef.Context.addTypedefNameForUnnamedTagDecl(Record, TND);
2646
2647 Owner->addDecl(Record);
2648
2649
2650
2652 Sema::LocalEagerInstantiationScope LocalInstantiations(SemaRef,
2653 false);
2654
2655 SemaRef.InstantiateClass(D->getLocation(), Record, D, TemplateArgs,
2657 true);
2658
2659
2660
2662 SemaRef.InstantiateClassMembers(D->getLocation(), Record, TemplateArgs,
2664
2665
2666
2667 LocalInstantiations.perform();
2668 }
2669
2670 SemaRef.DiagnoseUnusedNestedTypedefs(Record);
2671
2672 if (IsInjectedClassName)
2673 assert(Record->isInjectedClassName() && "Broken injected-class-name");
2674
2676}
2677
2678
2679
2680
2681
2682
2683
2691 if (OrigFunc->getExtInfo() == NewFunc->getExtInfo())
2692 return TInfo->getType();
2693
2696 return Context.getFunctionType(NewFunc->getReturnType(),
2697 NewFunc->getParamTypes(), NewEPI);
2698}
2699
2700
2701
2702
2703
2704
2708
2709
2711 bool isFriend;
2714 else
2716
2717
2718
2719
2720 if (ExternalASTSource *Source = SemaRef.Context.getExternalSource()) {
2721 if (isFriend && Source->wasThisDeclarationADefinition(D)) {
2726 }
2727 }
2728 }
2729
2732
2733 void *InsertPos = nullptr;
2735 = FunctionTemplate->findSpecialization(Innermost, InsertPos);
2736
2737
2738 if (SpecFunc)
2739 return SpecFunc;
2740 }
2741
2742 bool MergeWithParentScope = (TemplateParams != nullptr) ||
2743 Owner->isFunctionOrMethod() ||
2745 cast(Owner)->isDefinedOutsideFunctionOrMethod());
2747
2749 if (auto *DGuide = dyn_cast(D)) {
2750 InstantiatedExplicitSpecifier = SemaRef.instantiateExplicitSpecifier(
2751 TemplateArgs, DGuide->getExplicitSpecifier());
2752 if (InstantiatedExplicitSpecifier.isInvalid())
2753 return nullptr;
2754 }
2755
2758 if (!TInfo)
2759 return nullptr;
2761
2762 if (TemplateParams && TemplateParams->size()) {
2763 auto *LastParam =
2764 dyn_cast(TemplateParams->asArray().back());
2765 if (LastParam && LastParam->isImplicit() &&
2766 LastParam->hasTypeConstraint()) {
2767
2768
2769
2770
2771
2776 }
2777 }
2778
2780 if (QualifierLoc) {
2781 QualifierLoc = SemaRef.SubstNestedNameSpecifierLoc(QualifierLoc,
2782 TemplateArgs);
2783 if (!QualifierLoc)
2784 return nullptr;
2785 }
2786
2788
2789
2790
2791
2794 DC = Owner;
2795 SemaRef.adjustContextForLocalExternDecl(DC);
2796 } else if (isFriend && QualifierLoc) {
2798 SS.Adopt(QualifierLoc);
2799 DC = SemaRef.computeDeclContext(SS);
2800 if (!DC) return nullptr;
2801 } else {
2803 TemplateArgs);
2804 }
2805
2807 = SemaRef.SubstDeclarationNameInfo(D->getNameInfo(), TemplateArgs);
2808
2811
2813 if (auto *DGuide = dyn_cast(D)) {
2816 InstantiatedExplicitSpecifier, NameInfo, T, TInfo,
2818 DGuide->getDeductionCandidateKind(), TrailingRequiresClause,
2819 DGuide->getSourceDeductionGuide(),
2820 DGuide->getSourceDeductionGuideKind());
2822 } else {
2827 TrailingRequiresClause);
2828 Function->setFriendConstraintRefersToEnclosingTemplate(
2831 }
2832
2834 Function->setImplicitlyInline();
2835
2836 if (QualifierLoc)
2837 Function->setQualifierInfo(QualifierLoc);
2838
2840 Function->setLocalExternDecl();
2841
2846 }
2848 LexicalDC = SemaRef.CurContext;
2849 }
2850
2852 Function->setIsTypeAwareOperatorNewOrDelete(
2854 Function->setLexicalDeclContext(LexicalDC);
2855
2856
2857 for (unsigned P = 0; P < Params.size(); ++P)
2858 if (Params[P])
2859 Params[P]->setOwningFunction(Function);
2860 Function->setParams(Params);
2861
2862 if (TrailingRequiresClause)
2863 Function->setTrailingRequiresClause(TrailingRequiresClause);
2864
2865 if (TemplateParams) {
2866
2867
2868
2869
2870
2871
2872
2873
2874
2875
2876
2877
2878
2879
2885
2887
2891 }
2893 SemaRef.CodeSynthesisContexts.back().Kind !=
2895
2899 Innermost),
2900 nullptr);
2903
2904
2905
2907 } else if (!isFriend) {
2908
2909
2910
2911 Function->setInstantiatedFromDecl(D);
2912 }
2913 }
2914
2915 if (isFriend) {
2916 Function->setObjectOfFriendDecl();
2918 FT->setObjectOfFriendDecl();
2919 }
2920
2923
2924 bool IsExplicitSpecialization = false;
2925
2931 : SemaRef.forRedeclarationInCurContext());
2932
2935 assert(isFriend && "dependent specialization info on "
2936 "non-member non-friend function?");
2937
2938
2940 if (const auto *ArgsWritten = DFTSI->TemplateArgumentsAsWritten) {
2941 ExplicitArgs.setLAngleLoc(ArgsWritten->getLAngleLoc());
2942 ExplicitArgs.setRAngleLoc(ArgsWritten->getRAngleLoc());
2943 if (SemaRef.SubstTemplateArguments(ArgsWritten->arguments(), TemplateArgs,
2944 ExplicitArgs))
2945 return nullptr;
2946 }
2947
2948
2951 SemaRef.FindInstantiatedDecl(D->getLocation(), FTD, TemplateArgs))
2953 else
2954 return nullptr;
2955 }
2956
2957 if (SemaRef.CheckFunctionTemplateSpecialization(
2959 DFTSI->TemplateArgumentsAsWritten ? &ExplicitArgs : nullptr,
2962
2963 IsExplicitSpecialization = true;
2966
2967 SemaRef.LookupQualifiedName(Previous, DC);
2968
2969
2971 ArgsWritten->getRAngleLoc());
2972 if (SemaRef.SubstTemplateArguments(ArgsWritten->arguments(), TemplateArgs,
2973 ExplicitArgs))
2974 return nullptr;
2975
2976 if (SemaRef.CheckFunctionTemplateSpecialization(Function,
2977 &ExplicitArgs,
2980
2981 IsExplicitSpecialization = true;
2983
2984
2985
2987
2988
2989
2990
2991
2992 if (Previous.isSingleTagDecl())
2994
2995
2996
2997
2998 if (isFriend && !QualifierLoc) {
2999 SemaRef.FilterLookupForScope(Previous, DC, nullptr,
3000 true,
3002 }
3003 }
3004
3005
3006
3007
3008
3009
3010
3011
3012
3013
3014
3015
3016
3017
3018 if (Function->isLocalExternDecl()) {
3020 if (!PVD->hasDefaultArg())
3021 continue;
3022 if (SemaRef.SubstDefaultArgument(D->getInnerLocStart(), PVD, TemplateArgs)) {
3023
3024
3025
3026 Expr *UninstExpr = PVD->getUninstantiatedDefaultArg();
3027 ExprResult ErrorResult = SemaRef.CreateRecoveryExpr(
3029 { UninstExpr }, UninstExpr->getType());
3031 PVD->setDefaultArg(ErrorResult.get());
3032 }
3033 }
3034 }
3035
3036 SemaRef.CheckFunctionDeclaration( nullptr, Function, Previous,
3037 IsExplicitSpecialization,
3038 Function->isThisDeclarationADefinition());
3039
3040
3041
3042
3043
3044 if (isFriend && TemplateParams && FunctionTemplate->getPreviousDecl()) {
3045 SemaRef.CheckTemplateParameterList(
3046 TemplateParams,
3047 FunctionTemplate->getPreviousDecl()->getTemplateParameters(),
3048 Function->isThisDeclarationADefinition()
3051 }
3052
3053
3054
3055
3056
3059 Function->getMemberSpecializationInfo()) {
3060 if (MSInfo->getPointOfInstantiation().isInvalid()) {
3062 MSInfo->setPointOfInstantiation(Loc);
3063 SemaRef.PendingLocalImplicitInstantiations.emplace_back(Function, Loc);
3064 }
3065 }
3066 }
3067
3070 return nullptr;
3071 }
3074
3077
3078
3079
3080 if (isFriend ||
3081 (Function->isLocalExternDecl() && ->getPreviousDecl()))
3083
3087
3089}
3090
3096
3097
3098
3100
3101 void *InsertPos = nullptr;
3103 = FunctionTemplate->findSpecialization(Innermost, InsertPos);
3104
3105
3106 if (SpecFunc)
3107 return SpecFunc;
3108 }
3109
3110 bool isFriend;
3113 else
3115
3116 bool MergeWithParentScope = (TemplateParams != nullptr) ||
3118 cast(Owner)->isDefinedOutsideFunctionOrMethod());
3120
3122 SemaRef, D, TemplateArgs, Scope);
3123
3124
3126 unsigned NumTempParamLists = 0;
3128 TempParamLists.resize(NumTempParamLists);
3129 for (unsigned I = 0; I != NumTempParamLists; ++I) {
3132 if (!InstParams)
3133 return nullptr;
3134 TempParamLists[I] = InstParams;
3135 }
3136 }
3137
3139
3140 const bool CouldInstantiate =
3141 InstantiatedExplicitSpecifier.getExpr() == nullptr ||
3142 !InstantiatedExplicitSpecifier.getExpr()->isValueDependent();
3143
3144
3145
3146 if (CouldInstantiate ||
3147 SemaRef.CodeSynthesisContexts.back().Kind !=
3149 InstantiatedExplicitSpecifier = SemaRef.instantiateExplicitSpecifier(
3150 TemplateArgs, InstantiatedExplicitSpecifier);
3151
3152 if (InstantiatedExplicitSpecifier.isInvalid())
3153 return nullptr;
3154 } else {
3156 }
3157
3158
3159
3160
3161
3162
3163
3167 SemaRef.Context.getTrivialTypeSourceInfo(D->getType());
3169 }
3170
3173 if (!TInfo)
3174 return nullptr;
3176
3177 if (TemplateParams && TemplateParams->size()) {
3178 auto *LastParam =
3179 dyn_cast(TemplateParams->asArray().back());
3180 if (LastParam && LastParam->isImplicit() &&
3181 LastParam->hasTypeConstraint()) {
3182
3183
3184
3185
3186
3191 }
3192 }
3193
3195 if (QualifierLoc) {
3196 QualifierLoc = SemaRef.SubstNestedNameSpecifierLoc(QualifierLoc,
3197 TemplateArgs);
3198 if (!QualifierLoc)
3199 return nullptr;
3200 }
3201
3203 if (isFriend) {
3204 if (QualifierLoc) {
3206 SS.Adopt(QualifierLoc);
3207 DC = SemaRef.computeDeclContext(SS);
3208
3209 if (DC && SemaRef.RequireCompleteDeclContext(SS, DC))
3210 return nullptr;
3211 } else {
3212 DC = SemaRef.FindInstantiatedContext(D->getLocation(),
3214 TemplateArgs);
3215 }
3216 if (!DC) return nullptr;
3217 }
3218
3221
3223 = SemaRef.SubstDeclarationNameInfo(D->getNameInfo(), TemplateArgs);
3224
3227
3228
3230
3234 SemaRef.Context, Record, StartLoc, NameInfo, T, TInfo,
3235 InstantiatedExplicitSpecifier, Constructor->UsesFPIntrin(),
3236 Constructor->isInlineSpecified(), false,
3238 TrailingRequiresClause);
3242 SemaRef.Context, Record, StartLoc, NameInfo, T, TInfo,
3244 Destructor->getConstexprKind(), TrailingRequiresClause);
3245 Method->setIneligibleOrNotSelected(true);
3247 Method->setDeclName(SemaRef.Context.DeclarationNames.getCXXDestructorName(
3248
3249 SemaRef.Context.getCanonicalTagType(Record)));
3250 } else if (CXXConversionDecl *Conversion = dyn_cast(D)) {
3252 SemaRef.Context, Record, StartLoc, NameInfo, T, TInfo,
3253 Conversion->UsesFPIntrin(), Conversion->isInlineSpecified(),
3254 InstantiatedExplicitSpecifier, Conversion->getConstexprKind(),
3255 Conversion->getEndLoc(), TrailingRequiresClause);
3256 } else {
3259 SemaRef.Context, Record, StartLoc, NameInfo, T, TInfo, SC,
3261 D->getEndLoc(), TrailingRequiresClause);
3262 }
3263
3265 Method->setImplicitlyInline();
3266
3267 if (QualifierLoc)
3268 Method->setQualifierInfo(QualifierLoc);
3269
3270 if (TemplateParams) {
3271
3272
3273
3274
3275
3276
3277
3278
3279
3280
3281
3282
3283
3285 Method->getLocation(),
3286 Method->getDeclName(),
3287 TemplateParams, Method);
3288 if (isFriend) {
3295
3299 Innermost),
3300 nullptr);
3301 } else if (!isFriend && FunctionRewriteKind == RewriteKind::None) {
3302
3304 }
3305
3306
3307
3308
3309 if (isFriend) {
3310 if (NumTempParamLists)
3311 Method->setTemplateParameterListsInfo(
3312 SemaRef.Context,
3313 llvm::ArrayRef(TempParamLists.data(), NumTempParamLists));
3314
3315 Method->setLexicalDeclContext(Owner);
3316 Method->setObjectOfFriendDecl();
3319
3320
3321 for (unsigned P = 0; P < Params.size(); ++P)
3322 Params[P]->setOwningFunction(Method);
3323 Method->setParams(Params);
3324
3326 Method->setInvalidDecl();
3327
3330
3331 bool IsExplicitSpecialization = false;
3332
3333
3334
3337
3339 if (const auto *ArgsWritten = DFTSI->TemplateArgumentsAsWritten) {
3340 ExplicitArgs.setLAngleLoc(ArgsWritten->getLAngleLoc());
3341 ExplicitArgs.setRAngleLoc(ArgsWritten->getRAngleLoc());
3342 if (SemaRef.SubstTemplateArguments(ArgsWritten->arguments(), TemplateArgs,
3343 ExplicitArgs))
3344 return nullptr;
3345 }
3346
3347
3350 SemaRef.FindInstantiatedDecl(D->getLocation(), FTD, TemplateArgs))
3352 else
3353 return nullptr;
3354 }
3355
3356 if (SemaRef.CheckFunctionTemplateSpecialization(
3357 Method, DFTSI->TemplateArgumentsAsWritten ? &ExplicitArgs : nullptr,
3359 Method->setInvalidDecl();
3360
3361 IsExplicitSpecialization = true;
3364 SemaRef.LookupQualifiedName(Previous, DC);
3365
3367 ArgsWritten->getRAngleLoc());
3368
3369 if (SemaRef.SubstTemplateArguments(ArgsWritten->arguments(), TemplateArgs,
3370 ExplicitArgs))
3371 return nullptr;
3372
3373 if (SemaRef.CheckFunctionTemplateSpecialization(Method,
3374 &ExplicitArgs,
3376 Method->setInvalidDecl();
3377
3378 IsExplicitSpecialization = true;
3379 } else if ( || TemplateParams || isFriend) {
3381
3382
3383
3384
3385
3386 if (Previous.isSingleTagDecl())
3388 }
3389
3390
3391
3392
3393
3394
3395
3396
3397
3398
3399
3400
3401
3402
3403
3404
3406 for (unsigned P = 0; P < Params.size(); ++P) {
3407 if (!Params[P]->hasDefaultArg())
3408 continue;
3409 if (SemaRef.SubstDefaultArgument(StartLoc, Params[P], TemplateArgs)) {
3410
3411
3412
3413 Expr *UninstExpr = Params[P]->getUninstantiatedDefaultArg();
3414 ExprResult ErrorResult = SemaRef.CreateRecoveryExpr(
3416 { UninstExpr }, UninstExpr->getType());
3418 Params[P]->setDefaultArg(ErrorResult.get());
3419 }
3420 }
3421 }
3422
3423 SemaRef.CheckFunctionDeclaration(nullptr, Method, Previous,
3424 IsExplicitSpecialization,
3425 Method->isThisDeclarationADefinition());
3426
3429
3430
3431
3432
3433 if (isFriend && Method->getPreviousDecl())
3434 Method->setAccess(Method->getPreviousDecl()->getAccess());
3435 else
3439
3440 SemaRef.CheckOverrideControl(Method);
3441
3442
3445 return nullptr;
3446 }
3448 SemaRef.SetDeclDeleted(Method, Method->getLocation(),
3450
3451
3452
3453
3454 if (IsExplicitSpecialization && !isFriend)
3455 SemaRef.CompleteMemberSpecialization(Method, Previous);
3456
3457
3458
3459
3460
3461
3462
3463
3465 if (Constructor->isDefaultConstructor() ||
3467 Method->setIneligibleOrNotSelected(true);
3468 } else if (Method->isCopyAssignmentOperator() ||
3469 Method->isMoveAssignmentOperator()) {
3470 Method->setIneligibleOrNotSelected(true);
3471 }
3472
3473
3475
3476
3477
3478 } else if (Method->isInvalidDecl() && .empty()) {
3479
3480
3481
3482 } else if (isFriend) {
3483
3484
3486 SemaRef.CheckFriendAccess(Method);
3487
3489
3490
3491
3492
3493 } else {
3494 Owner->addDecl(Method);
3495 }
3496
3497
3498
3499 if (Method->hasAttr()) {
3500 if (const auto *A = dyn_cast(Owner)) {
3503 A->getMemberSpecializationInfo())
3504 Loc = MSInfo->getPointOfInstantiation();
3505 else if (const auto *Spec = dyn_cast(A))
3506 Loc = Spec->getPointOfInstantiation();
3507 SemaRef.MarkFunctionReferenced(Loc, Method);
3508 }
3509 }
3510
3512}
3513
3516}
3517
3520}
3521
3524}
3525
3526Decl *TemplateDeclInstantiator::VisitParmVarDecl(ParmVarDecl *D) {
3527 return SemaRef.SubstParmVarDecl(D, TemplateArgs, 0,
3528 std::nullopt,
3529 false);
3530}
3531
3532Decl *TemplateDeclInstantiator::VisitTemplateTypeParmDecl(
3535
3536 UnsignedOrNone NumExpanded = std::nullopt;
3537
3540 assert(TC->getTemplateArgsAsWritten() &&
3541 "type parameter can only be an expansion when explicit arguments "
3542 "are specified");
3543
3544
3545
3546 SmallVector<UnexpandedParameterPack, 2> Unexpanded;
3547 for (auto &ArgLoc : TC->getTemplateArgsAsWritten()->arguments())
3548 SemaRef.collectUnexpandedParameterPacks(ArgLoc, Unexpanded);
3549
3550
3551
3552 bool Expand = true;
3553 bool RetainExpansion = false;
3554 if (SemaRef.CheckParameterPacksForExpansion(
3556 ->getEllipsisLoc(),
3557 SourceRange(TC->getConceptNameLoc(),
3558 TC->hasExplicitTemplateArgs()
3559 ? TC->getTemplateArgsAsWritten()->getRAngleLoc()
3560 : TC->getConceptNameInfo().getEndLoc()),
3561 Unexpanded, TemplateArgs, true,
3562 Expand, RetainExpansion, NumExpanded))
3563 return nullptr;
3564 }
3565 }
3566
3569 D->getDepth() - TemplateArgs.getNumSubstitutedLevels(), D->getIndex(),
3572
3577
3578
3579
3580 if (SemaRef.SubstTypeConstraint(Inst, TC, TemplateArgs,
3581 EvaluateConstraints))
3582 return nullptr;
3583 }
3584 }
3586 TemplateArgumentLoc Output;
3587 if (!SemaRef.SubstTemplateArgument(D->getDefaultArgument(), TemplateArgs,
3588 Output))
3590 }
3591
3592
3593
3594 SemaRef.CurrentInstantiationScope->InstantiatedLocal(D, Inst);
3595
3596 return Inst;
3597}
3598
3599Decl *TemplateDeclInstantiator::VisitNonTypeTemplateParmDecl(
3601
3603 SmallVector<TypeSourceInfo *, 4> ExpandedParameterPackTypesAsWritten;
3604 SmallVector<QualType, 4> ExpandedParameterPackTypes;
3605 bool IsExpandedParameterPack = false;
3606 TypeSourceInfo *TSI;
3607 QualType T;
3609
3611
3612
3616 TypeSourceInfo *NewTSI =
3619 if (!NewTSI)
3620 return nullptr;
3621
3622 QualType NewT =
3623 SemaRef.CheckNonTypeTemplateParameterType(NewTSI, D->getLocation());
3625 return nullptr;
3626
3627 ExpandedParameterPackTypesAsWritten.push_back(NewTSI);
3628 ExpandedParameterPackTypes.push_back(NewT);
3629 }
3630
3631 IsExpandedParameterPack = true;
3635
3636
3637
3638 PackExpansionTypeLoc Expansion = TL.castAs();
3640 SmallVector<UnexpandedParameterPack, 2> Unexpanded;
3641 SemaRef.collectUnexpandedParameterPacks(Pattern, Unexpanded);
3642
3643
3644
3645 bool Expand = true;
3646 bool RetainExpansion = false;
3647 UnsignedOrNone OrigNumExpansions =
3648 Expansion.getTypePtr()->getNumExpansions();
3649 UnsignedOrNone NumExpansions = OrigNumExpansions;
3650 if (SemaRef.CheckParameterPacksForExpansion(
3651 Expansion.getEllipsisLoc(), Pattern.getSourceRange(), Unexpanded,
3652 TemplateArgs, true, Expand,
3653 RetainExpansion, NumExpansions))
3654 return nullptr;
3655
3656 if (Expand) {
3657 for (unsigned I = 0; I != *NumExpansions; ++I) {
3658 Sema::ArgPackSubstIndexRAII SubstIndex(SemaRef, I);
3659 TypeSourceInfo *NewTSI = SemaRef.SubstType(
3661 if (!NewTSI)
3662 return nullptr;
3663
3664 QualType NewT =
3665 SemaRef.CheckNonTypeTemplateParameterType(NewTSI, D->getLocation());
3667 return nullptr;
3668
3669 ExpandedParameterPackTypesAsWritten.push_back(NewTSI);
3670 ExpandedParameterPackTypes.push_back(NewT);
3671 }
3672
3673
3674
3675
3676 IsExpandedParameterPack = true;
3679 } else {
3680
3681
3682 Sema::ArgPackSubstIndexRAII SubstIndex(SemaRef, std::nullopt);
3683 TypeSourceInfo *NewPattern = SemaRef.SubstType(Pattern, TemplateArgs,
3686 if (!NewPattern)
3687 return nullptr;
3688
3689 SemaRef.CheckNonTypeTemplateParameterType(NewPattern, D->getLocation());
3690 TSI = SemaRef.CheckPackExpansion(NewPattern, Expansion.getEllipsisLoc(),
3691 NumExpansions);
3692 if (!TSI)
3693 return nullptr;
3694
3696 }
3697 } else {
3698
3701 if (!TSI)
3702 return nullptr;
3703
3704
3705 T = SemaRef.CheckNonTypeTemplateParameterType(TSI, D->getLocation());
3706 if (T.isNull()) {
3707 T = SemaRef.Context.IntTy;
3709 }
3710 }
3711
3712 NonTypeTemplateParmDecl *Param;
3713 if (IsExpandedParameterPack)
3716 D->getDepth() - TemplateArgs.getNumSubstitutedLevels(),
3718 ExpandedParameterPackTypes, ExpandedParameterPackTypesAsWritten);
3719 else
3722 D->getDepth() - TemplateArgs.getNumSubstitutedLevels(),
3724
3726 if (AutoLoc.isConstrained()) {
3727 SourceLocation EllipsisLoc;
3728 if (IsExpandedParameterPack)
3729 EllipsisLoc =
3730 TSI->getTypeLoc().getAs().getEllipsisLoc();
3731 else if (auto *Constraint = dyn_cast_if_present(
3733 EllipsisLoc = Constraint->getEllipsisLoc();
3734
3735
3736
3737 if (SemaRef.AttachTypeConstraint(AutoLoc, Param,
3738 D, EllipsisLoc))
3740 }
3741
3746
3748 EnterExpressionEvaluationContext ConstantEvaluated(
3750 TemplateArgumentLoc Result;
3751 if (!SemaRef.SubstTemplateArgument(D->getDefaultArgument(), TemplateArgs,
3754 }
3755
3756
3757
3758 SemaRef.CurrentInstantiationScope->InstantiatedLocal(D, Param);
3759 return Param;
3760}
3761
3766 for (const auto &P : *Params) {
3767 if (P->isTemplateParameterPack())
3768 continue;
3771 Unexpanded);
3774 Unexpanded);
3775 }
3776}
3777
3779TemplateDeclInstantiator::VisitTemplateTemplateParmDecl(
3781
3783 TemplateParameterList *InstParams;
3784 SmallVector<TemplateParameterList*, 8> ExpandedParams;
3785
3786 bool IsExpandedParameterPack = false;
3787
3789
3790
3791
3794 I != N; ++I) {
3795 LocalInstantiationScope Scope(SemaRef, true);
3796 TemplateParameterList *Expansion =
3798 if (!Expansion)
3799 return nullptr;
3800 ExpandedParams.push_back(Expansion);
3801 }
3802
3803 IsExpandedParameterPack = true;
3804 InstParams = TempParams;
3806
3807
3808
3809 SmallVector<UnexpandedParameterPack, 2> Unexpanded;
3811 Unexpanded);
3812
3813
3814
3815 bool Expand = true;
3816 bool RetainExpansion = false;
3817 UnsignedOrNone NumExpansions = std::nullopt;
3818 if (SemaRef.CheckParameterPacksForExpansion(
3820 TemplateArgs, true, Expand,
3821 RetainExpansion, NumExpansions))
3822 return nullptr;
3823
3824 if (Expand) {
3825 for (unsigned I = 0; I != *NumExpansions; ++I) {
3826 Sema::ArgPackSubstIndexRAII SubstIndex(SemaRef, I);
3827 LocalInstantiationScope Scope(SemaRef, true);
3829 if (!Expansion)
3830 return nullptr;
3831 ExpandedParams.push_back(Expansion);
3832 }
3833
3834
3835
3836
3837 IsExpandedParameterPack = true;
3838 }
3839
3840 Sema::ArgPackSubstIndexRAII SubstIndex(SemaRef, std::nullopt);
3841
3842 LocalInstantiationScope Scope(SemaRef, true);
3844 if (!InstParams)
3845 return nullptr;
3846 } else {
3847
3848
3849 LocalInstantiationScope Scope(SemaRef, true);
3851 if (!InstParams)
3852 return nullptr;
3853 }
3854
3855
3856 TemplateTemplateParmDecl *Param;
3857 if (IsExpandedParameterPack)
3859 SemaRef.Context, Owner, D->getLocation(),
3860 D->getDepth() - TemplateArgs.getNumSubstitutedLevels(),
3863 else
3865 SemaRef.Context, Owner, D->getLocation(),
3866 D->getDepth() - TemplateArgs.getNumSubstitutedLevels(),
3872
3873 TemplateName TName = SemaRef.SubstTemplateName(
3876 if (!TName.isNull())
3878 SemaRef.Context,
3879 TemplateArgumentLoc(SemaRef.Context, TemplateArgument(TName),
3882 }
3885
3886
3887
3888 SemaRef.CurrentInstantiationScope->InstantiatedLocal(D, Param);
3889
3890 return Param;
3891}
3892
3894
3895
3896
3897 UsingDirectiveDecl *Inst
3904
3905
3906
3907 if (!Owner->isFunctionOrMethod())
3908 Owner->addDecl(Inst);
3909
3910 return Inst;
3911}
3912
3916
3917 bool isFunctionScope = Owner->isFunctionOrMethod();
3918
3919 for (auto *Shadow : D->shadows()) {
3920
3921
3922
3923 NamedDecl *OldTarget = Shadow->getTargetDecl();
3924 if (auto *CUSD = dyn_cast(Shadow))
3925 if (auto *BaseShadow = CUSD->getNominatedBaseClassShadowDecl())
3926 OldTarget = BaseShadow;
3927
3928 NamedDecl *InstTarget = nullptr;
3929 if (auto *EmptyD =
3930 dyn_cast(Shadow->getTargetDecl())) {
3932 SemaRef.Context, Owner, EmptyD->getLocation(), EmptyD->getDeclName());
3933 } else {
3934 InstTarget = cast_or_null(SemaRef.FindInstantiatedDecl(
3935 Shadow->getLocation(), OldTarget, TemplateArgs));
3936 }
3937 if (!InstTarget)
3938 return nullptr;
3939
3941 if (Lookup &&
3942 SemaRef.CheckUsingShadowDecl(Inst, InstTarget, *Lookup, PrevDecl))
3943 continue;
3944
3946 PrevDecl = cast_or_null(SemaRef.FindInstantiatedDecl(
3947 Shadow->getLocation(), OldPrev, TemplateArgs));
3948
3949 UsingShadowDecl *InstShadow = SemaRef.BuildUsingShadowDecl(
3950 nullptr, Inst, InstTarget, PrevDecl);
3951 SemaRef.Context.setInstantiatedFromUsingShadowDecl(InstShadow, Shadow);
3952
3953 if (isFunctionScope)
3954 SemaRef.CurrentInstantiationScope->InstantiatedLocal(Shadow, InstShadow);
3955 }
3956
3957 return Inst;
3958}
3959
3960Decl *TemplateDeclInstantiator::VisitUsingDecl(UsingDecl *D) {
3961
3962
3963
3964
3965
3966
3967
3968
3969
3972 TemplateArgs);
3973 if (!QualifierLoc)
3974 return nullptr;
3975
3976
3977
3978
3981 if (auto *RD = dyn_cast(SemaRef.CurContext))
3984
3985
3986
3987 bool CheckRedeclaration = Owner->isRecord();
3990
3993 QualifierLoc,
3994 NameInfo,
3996
3998 SS.Adopt(QualifierLoc);
3999 if (CheckRedeclaration) {
4000 Prev.setHideTags(false);
4002
4003
4008 }
4009
4012 NameInfo, D->getLocation(), nullptr, D))
4014
4018
4019
4021 return NewUD;
4022
4023
4024
4027
4028 return VisitBaseUsingDecls(D, NewUD, CheckRedeclaration ? &Prev : nullptr);
4029}
4030
4031Decl *TemplateDeclInstantiator::VisitUsingEnumDecl(UsingEnumDecl *D) {
4032
4033 EnumDecl *EnumD = cast_or_null(SemaRef.FindInstantiatedDecl(
4035
4036 if (SemaRef.RequireCompleteEnumDecl(EnumD, EnumD->getLocation()))
4037 return nullptr;
4038
4039 TypeSourceInfo *TSI = SemaRef.SubstType(D->getEnumType(), TemplateArgs,
4041
4042 if (!TSI)
4043 return nullptr;
4044
4045 UsingEnumDecl *NewUD =
4048
4049 SemaRef.Context.setInstantiatedFromUsingEnumDecl(NewUD, D);
4051 Owner->addDecl(NewUD);
4052
4053
4055 return NewUD;
4056
4057
4058
4059
4060
4062}
4063
4064Decl *TemplateDeclInstantiator::VisitUsingShadowDecl(UsingShadowDecl *D) {
4065
4066 return nullptr;
4067}
4068
4069Decl *TemplateDeclInstantiator::VisitConstructorUsingShadowDecl(
4071
4072 return nullptr;
4073}
4074
4075template
4076Decl *TemplateDeclInstantiator::instantiateUnresolvedUsingDecl(
4077 T *D, bool InstantiatingPackElement) {
4078
4079 if (D->isPackExpansion() && !InstantiatingPackElement) {
4080 SmallVector<UnexpandedParameterPack, 2> Unexpanded;
4081 SemaRef.collectUnexpandedParameterPacks(D->getQualifierLoc(), Unexpanded);
4082 SemaRef.collectUnexpandedParameterPacks(D->getNameInfo(), Unexpanded);
4083
4084
4085
4086 bool Expand = true;
4087 bool RetainExpansion = false;
4088 UnsignedOrNone NumExpansions = std::nullopt;
4089 if (SemaRef.CheckParameterPacksForExpansion(
4090 D->getEllipsisLoc(), D->getSourceRange(), Unexpanded, TemplateArgs,
4091 true, Expand, RetainExpansion,
4092 NumExpansions))
4093 return nullptr;
4094
4095
4096
4097 assert(!RetainExpansion &&
4098 "should never need to retain an expansion for UsingPackDecl");
4099
4100 if (!Expand) {
4101
4102
4103 Sema::ArgPackSubstIndexRAII SubstIndex(SemaRef, std::nullopt);
4104 return instantiateUnresolvedUsingDecl(D, true);
4105 }
4106
4107
4108
4109
4110
4111
4112
4113
4114 if (D->getDeclContext()->isFunctionOrMethod() && *NumExpansions > 1) {
4115 SemaRef.Diag(D->getEllipsisLoc(),
4116 diag::err_using_decl_redeclaration_expansion);
4117 return nullptr;
4118 }
4119
4120
4121 SmallVector<NamedDecl*, 8> Expansions;
4122 for (unsigned I = 0; I != *NumExpansions; ++I) {
4123 Sema::ArgPackSubstIndexRAII SubstIndex(SemaRef, I);
4124 Decl *Slice = instantiateUnresolvedUsingDecl(D, true);
4125 if (!Slice)
4126 return nullptr;
4127
4128
4129
4130
4132 }
4133
4134 auto *NewD = SemaRef.BuildUsingPackDecl(D, Expansions);
4136 SemaRef.CurrentInstantiationScope->InstantiatedLocal(D, NewD);
4137 return NewD;
4138 }
4139
4140 UnresolvedUsingTypenameDecl *TD = dyn_cast(D);
4141 SourceLocation TypenameLoc = TD ? TD->getTypenameLoc() : SourceLocation();
4142
4143 NestedNameSpecifierLoc QualifierLoc
4144 = SemaRef.SubstNestedNameSpecifierLoc(D->getQualifierLoc(),
4145 TemplateArgs);
4146 if (!QualifierLoc)
4147 return nullptr;
4148
4149 CXXScopeSpec SS;
4150 SS.Adopt(QualifierLoc);
4151
4152 DeclarationNameInfo NameInfo
4153 = SemaRef.SubstDeclarationNameInfo(D->getNameInfo(), TemplateArgs);
4154
4155
4156
4157 bool InstantiatingSlice =
4158 D->getEllipsisLoc().isValid() && SemaRef.ArgPackSubstIndex;
4159 SourceLocation EllipsisLoc =
4160 InstantiatingSlice ? SourceLocation() : D->getEllipsisLoc();
4161
4163 NamedDecl *UD = SemaRef.BuildUsingDeclaration(
4164 nullptr, D->getAccess(), D->getUsingLoc(),
4165 TD, TypenameLoc, SS, NameInfo, EllipsisLoc,
4166 ParsedAttributesView(),
4167 true, IsUsingIfExists);
4168 if (UD) {
4169 SemaRef.InstantiateAttrs(TemplateArgs, D, UD);
4170 SemaRef.Context.setInstantiatedFromUsingDecl(UD, D);
4171 }
4172
4173 return UD;
4174}
4175
4176Decl *TemplateDeclInstantiator::VisitUnresolvedUsingTypenameDecl(
4178 return instantiateUnresolvedUsingDecl(D);
4179}
4180
4181Decl *TemplateDeclInstantiator::VisitUnresolvedUsingValueDecl(
4183 return instantiateUnresolvedUsingDecl(D);
4184}
4185
4186Decl *TemplateDeclInstantiator::VisitUnresolvedUsingIfExistsDecl(
4188 llvm_unreachable("referring to unresolved decl out of UsingShadowDecl");
4189}
4190
4191Decl *TemplateDeclInstantiator::VisitUsingPackDecl(UsingPackDecl *D) {
4192 SmallVector<NamedDecl*, 8> Expansions;
4194 if (NamedDecl *NewUD =
4195 SemaRef.FindInstantiatedDecl(D->getLocation(), UD, TemplateArgs))
4196 Expansions.push_back(NewUD);
4197 else
4198 return nullptr;
4199 }
4200
4201 auto *NewD = SemaRef.BuildUsingPackDecl(D, Expansions);
4203 SemaRef.CurrentInstantiationScope->InstantiatedLocal(D, NewD);
4204 return NewD;
4205}
4206
4207Decl *TemplateDeclInstantiator::VisitOMPThreadPrivateDecl(
4209 SmallVector<Expr *, 5> Vars;
4210 for (auto *I : D->varlist()) {
4211 Expr *Var = SemaRef.SubstExpr(I, TemplateArgs).get();
4212 assert(isa(Var) && "threadprivate arg is not a DeclRefExpr");
4213 Vars.push_back(Var);
4214 }
4215
4216 OMPThreadPrivateDecl *TD =
4217 SemaRef.OpenMP().CheckOMPThreadPrivateDecl(D->getLocation(), Vars);
4218
4220 Owner->addDecl(TD);
4221
4222 return TD;
4223}
4224
4226TemplateDeclInstantiator::VisitOMPGroupPrivateDecl(OMPGroupPrivateDecl *D) {
4227 SmallVector<Expr *, 5> Vars;
4228 for (auto *I : D->varlist()) {
4229 Expr *Var = SemaRef.SubstExpr(I, TemplateArgs).get();
4230 assert(isa(Var) && "groupprivate arg is not a DeclRefExpr");
4231 Vars.push_back(Var);
4232 }
4233
4234 OMPGroupPrivateDecl *TD =
4235 SemaRef.OpenMP().CheckOMPGroupPrivateDecl(D->getLocation(), Vars);
4236
4238 Owner->addDecl(TD);
4239
4240 return TD;
4241}
4242
4243Decl *TemplateDeclInstantiator::VisitOMPAllocateDecl(OMPAllocateDecl *D) {
4244 SmallVector<Expr *, 5> Vars;
4245 for (auto *I : D->varlist()) {
4246 Expr *Var = SemaRef.SubstExpr(I, TemplateArgs).get();
4247 assert(isa(Var) && "allocate arg is not a DeclRefExpr");
4248 Vars.push_back(Var);
4249 }
4250 SmallVector<OMPClause *, 4> Clauses;
4251
4253 OMPClause *IC = nullptr;
4254 if (auto *AC = dyn_cast(C)) {
4255 ExprResult NewE = SemaRef.SubstExpr(AC->getAllocator(), TemplateArgs);
4257 continue;
4258 IC = SemaRef.OpenMP().ActOnOpenMPAllocatorClause(
4259 NewE.get(), AC->getBeginLoc(), AC->getLParenLoc(), AC->getEndLoc());
4260 } else if (auto *AC = dyn_cast(C)) {
4261 ExprResult NewE = SemaRef.SubstExpr(AC->getAlignment(), TemplateArgs);
4263 continue;
4264 IC = SemaRef.OpenMP().ActOnOpenMPAlignClause(
4265 NewE.get(), AC->getBeginLoc(), AC->getLParenLoc(), AC->getEndLoc());
4266
4267 if (!IC)
4268 continue;
4269 }
4270 Clauses.push_back(IC);
4271 }
4272
4274 D->getLocation(), Vars, Clauses, Owner);
4276 return nullptr;
4278}
4279
4280Decl *TemplateDeclInstantiator::VisitOMPRequiresDecl(OMPRequiresDecl *D) {
4281 llvm_unreachable(
4282 "Requires directive cannot be instantiated within a dependent context");
4283}
4284
4285Decl *TemplateDeclInstantiator::VisitOMPDeclareReductionDecl(
4287
4288 const bool RequiresInstantiation =
4292 QualType SubstReductionType;
4293 if (RequiresInstantiation) {
4294 SubstReductionType = SemaRef.OpenMP().ActOnOpenMPDeclareReductionType(
4298 } else {
4299 SubstReductionType = D->getType();
4300 }
4301 if (SubstReductionType.isNull())
4302 return nullptr;
4305 bool IsCorrect = true;
4306
4307 std::pair<QualType, SourceLocation> ReductionTypes[] = {
4308 std::make_pair(SubstReductionType, D->getLocation())};
4310 if (PrevDeclInScope && !PrevDeclInScope->isInvalidDecl()) {
4312 cast<Decl *>(*SemaRef.CurrentInstantiationScope->findInstantiationOf(
4313 PrevDeclInScope)));
4314 }
4315 auto DRD = SemaRef.OpenMP().ActOnOpenMPDeclareReductionDirectiveStart(
4317 PrevDeclInScope);
4319 SemaRef.CurrentInstantiationScope->InstantiatedLocal(D, NewDRD);
4320 Expr *SubstCombiner = nullptr;
4321 Expr *SubstInitializer = nullptr;
4322
4323 if (Combiner) {
4324 SemaRef.OpenMP().ActOnOpenMPDeclareReductionCombinerStart(
4325 nullptr, NewDRD);
4326 SemaRef.CurrentInstantiationScope->InstantiatedLocal(
4329 SemaRef.CurrentInstantiationScope->InstantiatedLocal(
4332 auto *ThisContext = dyn_cast_or_null(Owner);
4333 Sema::CXXThisScopeRAII ThisScope(SemaRef, ThisContext, Qualifiers(),
4334 ThisContext);
4335 SubstCombiner = SemaRef.SubstExpr(Combiner, TemplateArgs).get();
4336 SemaRef.OpenMP().ActOnOpenMPDeclareReductionCombinerEnd(NewDRD,
4337 SubstCombiner);
4338 }
4339
4341 VarDecl *OmpPrivParm =
4342 SemaRef.OpenMP().ActOnOpenMPDeclareReductionInitializerStart(
4343 nullptr, NewDRD);
4344 SemaRef.CurrentInstantiationScope->InstantiatedLocal(
4347 SemaRef.CurrentInstantiationScope->InstantiatedLocal(
4351 SubstInitializer = SemaRef.SubstExpr(Init, TemplateArgs).get();
4352 } else {
4353 auto *OldPrivParm =
4355 IsCorrect = IsCorrect && OldPrivParm->hasInit();
4356 if (IsCorrect)
4357 SemaRef.InstantiateVariableInitializer(OmpPrivParm, OldPrivParm,
4358 TemplateArgs);
4359 }
4360 SemaRef.OpenMP().ActOnOpenMPDeclareReductionInitializerEnd(
4361 NewDRD, SubstInitializer, OmpPrivParm);
4362 }
4363 IsCorrect = IsCorrect && SubstCombiner &&
4366 SubstInitializer) ||
4368 !SubstInitializer));
4369
4370 (void)SemaRef.OpenMP().ActOnOpenMPDeclareReductionDirectiveEnd(
4371 nullptr, DRD, IsCorrect && !D->isInvalidDecl());
4372
4373 return NewDRD;
4374}
4375
4377TemplateDeclInstantiator::VisitOMPDeclareMapperDecl(OMPDeclareMapperDecl *D) {
4378
4379 const bool RequiresInstantiation =
4383 QualType SubstMapperTy;
4384 DeclarationName VN = D->getVarName();
4385 if (RequiresInstantiation) {
4386 SubstMapperTy = SemaRef.OpenMP().ActOnOpenMPDeclareMapperType(
4390 } else {
4391 SubstMapperTy = D->getType();
4392 }
4393 if (SubstMapperTy.isNull())
4394 return nullptr;
4395
4397 if (PrevDeclInScope && !PrevDeclInScope->isInvalidDecl()) {
4399 cast<Decl *>(*SemaRef.CurrentInstantiationScope->findInstantiationOf(
4400 PrevDeclInScope)));
4401 }
4402 bool IsCorrect = true;
4403 SmallVector<OMPClause *, 6> Clauses;
4404
4405 DeclarationNameInfo DirName;
4406 SemaRef.OpenMP().StartOpenMPDSABlock(llvm::omp::OMPD_declare_mapper, DirName,
4407 nullptr,
4410 SemaRef.OpenMP().ActOnOpenMPDeclareMapperDirectiveVarDecl(
4411 nullptr, SubstMapperTy, D->getLocation(), VN);
4412 SemaRef.CurrentInstantiationScope->InstantiatedLocal(
4415 auto *ThisContext = dyn_cast_or_null(Owner);
4416 Sema::CXXThisScopeRAII ThisScope(SemaRef, ThisContext, Qualifiers(),
4417 ThisContext);
4418
4421 SmallVector<Expr *, 4> NewVars;
4422 for (Expr *OE : OldC->varlist()) {
4423 Expr *NE = SemaRef.SubstExpr(OE, TemplateArgs).get();
4424 if (!NE) {
4425 IsCorrect = false;
4426 break;
4427 }
4428 NewVars.push_back(NE);
4429 }
4430 if (!IsCorrect)
4431 break;
4432 NestedNameSpecifierLoc NewQualifierLoc =
4433 SemaRef.SubstNestedNameSpecifierLoc(OldC->getMapperQualifierLoc(),
4434 TemplateArgs);
4435 CXXScopeSpec SS;
4436 SS.Adopt(NewQualifierLoc);
4437 DeclarationNameInfo NewNameInfo =
4438 SemaRef.SubstDeclarationNameInfo(OldC->getMapperIdInfo(), TemplateArgs);
4439 OMPVarListLocTy Locs(OldC->getBeginLoc(), OldC->getLParenLoc(),
4440 OldC->getEndLoc());
4441 OMPClause *NewC = SemaRef.OpenMP().ActOnOpenMPMapClause(
4442 OldC->getIteratorModifier(), OldC->getMapTypeModifiers(),
4443 OldC->getMapTypeModifiersLoc(), SS, NewNameInfo, OldC->getMapType(),
4444 OldC->isImplicitMapType(), OldC->getMapLoc(), OldC->getColonLoc(),
4445 NewVars, Locs);
4446 Clauses.push_back(NewC);
4447 }
4448 SemaRef.OpenMP().EndOpenMPDSABlock(nullptr);
4449 if (!IsCorrect)
4450 return nullptr;
4451 Sema::DeclGroupPtrTy DG = SemaRef.OpenMP().ActOnOpenMPDeclareMapperDirective(
4453 VN, D->getAccess(), MapperVarRef.get(), Clauses, PrevDeclInScope);
4455 SemaRef.CurrentInstantiationScope->InstantiatedLocal(D, NewDMD);
4456 return NewDMD;
4457}
4458
4459Decl *TemplateDeclInstantiator::VisitOMPCapturedExprDecl(
4461 llvm_unreachable("Should not be met in templates");
4462}
4463
4466}
4467
4472 Owner->addDecl(Inst);
4473 return Inst;
4474}
4475
4478}
4479
4480Decl *TemplateDeclInstantiator::VisitRecordDecl(RecordDecl *D) {
4481 llvm_unreachable("There are only CXXRecordDecls in C++");
4482}
4483
4485TemplateDeclInstantiator::VisitClassTemplateSpecializationDecl(
4487
4488
4492 "can only instantiate an explicit specialization "
4493 "for a member class template");
4494
4495
4496
4497 ClassTemplateDecl *InstClassTemplate =
4498 cast_or_null(SemaRef.FindInstantiatedDecl(
4499 D->getLocation(), ClassTemplate, TemplateArgs));
4500 if (!InstClassTemplate)
4501 return nullptr;
4502
4503
4504
4505 TemplateArgumentListInfo InstTemplateArgs;
4506 if (const ASTTemplateArgumentListInfo *TemplateArgsInfo =
4508 InstTemplateArgs.setLAngleLoc(TemplateArgsInfo->getLAngleLoc());
4509 InstTemplateArgs.setRAngleLoc(TemplateArgsInfo->getRAngleLoc());
4510
4511 if (SemaRef.SubstTemplateArguments(TemplateArgsInfo->arguments(),
4512 TemplateArgs, InstTemplateArgs))
4513 return nullptr;
4514 }
4515
4516
4517
4518 Sema::CheckTemplateArgumentInfo CTAI;
4519 if (SemaRef.CheckTemplateArgumentList(
4520 InstClassTemplate, D->getLocation(), InstTemplateArgs,
4521 {}, false, CTAI,
4522 true))
4523 return nullptr;
4524
4525
4526
4527 void *InsertPos = nullptr;
4528 ClassTemplateSpecializationDecl *PrevDecl =
4530
4531
4532
4534 if (PrevDecl &&
4535 SemaRef.CheckSpecializationInstantiationRedecl(D->getLocation(),
4537 PrevDecl,
4540 Ignored))
4541 return nullptr;
4542
4543
4544
4545
4546
4547
4548
4549
4550
4551
4552
4553
4554
4557 SemaRef.Diag(D->getLocation(), diag::err_redefinition) << PrevDecl;
4559 diag::note_previous_definition);
4560 return nullptr;
4561 }
4562
4563
4564 ClassTemplateSpecializationDecl *InstD =
4570
4571
4572
4573 if (!PrevDecl)
4575
4576
4578 return nullptr;
4579
4585
4586 Owner->addDecl(InstD);
4587
4588
4589
4590
4591
4593 SemaRef.InstantiateClass(D->getLocation(), InstD, D, TemplateArgs,
4595 true))
4596 return nullptr;
4597
4598 return InstD;
4599}
4600
4603
4607 "A template specialization without specialized template?");
4608
4610 cast_or_null(SemaRef.FindInstantiatedDecl(
4612 if (!InstVarTemplate)
4613 return nullptr;
4614
4615
4618 VarTemplateArgsInfo.setLAngleLoc(TemplateArgsInfo->getLAngleLoc());
4619 VarTemplateArgsInfo.setRAngleLoc(TemplateArgsInfo->getRAngleLoc());
4620
4621 if (SemaRef.SubstTemplateArguments(TemplateArgsInfo->arguments(),
4622 TemplateArgs, VarTemplateArgsInfo))
4623 return nullptr;
4624 }
4625
4626
4628 if (SemaRef.CheckTemplateArgumentList(
4629 InstVarTemplate, D->getLocation(), VarTemplateArgsInfo,
4630 {}, false, CTAI,
4631 true))
4632 return nullptr;
4633
4634
4635 void *InsertPos = nullptr;
4638
4639
4640
4641 bool Ignored;
4642 if (PrevDecl && SemaRef.CheckSpecializationInstantiationRedecl(
4646 return nullptr;
4647
4650 VTSD->setTemplateArgsAsWritten(VarTemplateArgsInfo);
4651 return VTSD;
4652 }
4653 return nullptr;
4654}
4655
4661
4662
4666 if (!TSI)
4667 return nullptr;
4668
4670 SemaRef.Diag(D->getLocation(), diag::err_variable_instantiates_to_function)
4672 return nullptr;
4673 }
4674
4675
4679 if (!PrevDecl) {
4680 void *InsertPos = nullptr;
4681 VarTemplate->findSpecialization(Converted, InsertPos);
4682 VarTemplate->AddSpecialization(Var, InsertPos);
4683 }
4684
4685 if (SemaRef.getLangOpts().OpenCL)
4686 SemaRef.deduceOpenCLAddressSpace(Var);
4687
4688
4690 return nullptr;
4691
4692 SemaRef.BuildVariableInstantiation(Var, D, TemplateArgs, LateAttrs, Owner,
4693 StartingScope, false, PrevDecl);
4694
4695 return Var;
4696}
4697
4699 llvm_unreachable("@defs is not supported in Objective-C++");
4700}
4701
4703
4704 unsigned DiagID = SemaRef.getDiagnostics().getCustomDiagID(
4706 "cannot instantiate %0 yet");
4709
4710 return nullptr;
4711}
4712
4713Decl *TemplateDeclInstantiator::VisitConceptDecl(ConceptDecl *D) {
4714 llvm_unreachable("Concept definitions cannot reside inside a template");
4715}
4716
4717Decl *TemplateDeclInstantiator::VisitImplicitConceptSpecializationDecl(
4719 llvm_unreachable("Concept specializations cannot reside inside a template");
4720}
4721
4723TemplateDeclInstantiator::VisitRequiresExprBodyDecl(RequiresExprBodyDecl *D) {
4726}
4727
4729 llvm_unreachable("Unexpected decl");
4730}
4731
4736 return nullptr;
4737
4738 Decl *SubstD;
4740 SubstD = Instantiator.Visit(D);
4741 });
4742 return SubstD;
4743}
4744
4750
4751
4752
4754 T = SemaRef.Context.getFunctionType(
4755 SemaRef.Context.BoolTy, FPT->getParamTypes(), FPT->getExtProtoInfo());
4756
4757
4758
4759
4760
4761
4762
4764 SemaRef.Context.getTrivialTypeSourceInfo(T, Orig->getEndLoc());
4766 assert(OldLoc && "type of function is not a function type?");
4768 for (unsigned I = 0, N = OldLoc.getNumParams(); I != N; ++I)
4769 NewLoc.setParam(I, OldLoc.getParam(I));
4770 TInfo = NewTInfo;
4771
4772
4774 SemaRef.Context.DeclarationNames.getCXXOperatorName(OO_EqualEqual));
4775}
4776
4779 if (Spaceship->isInvalidDecl())
4780 return nullptr;
4781
4782
4783
4784
4785
4791 if (auto *MD = dyn_cast(Spaceship)) {
4793 MD, nullptr,
4795 } else {
4796 assert(Spaceship->getFriendObjectKind() &&
4797 "defaulted spaceship is neither a member nor a friend");
4798
4800 Spaceship, nullptr,
4802 if (!R)
4803 return nullptr;
4804
4810 }
4811 return cast_or_null(R);
4812}
4813
4814
4815
4816
4817
4818
4819
4822
4824
4825 unsigned N = L->size();
4827 ParamVector Params;
4828 Params.reserve(N);
4829 for (auto &P : *L) {
4831 Params.push_back(D);
4833 }
4834
4835
4837 return nullptr;
4838
4840
4845 return InstL;
4846}
4847
4851 bool EvaluateConstraints) {
4855}
4856
4857
4858
4859
4860
4861
4862
4863
4864
4865
4866
4867
4872
4873
4874
4876
4877
4878
4881 if (!InstParams)
4882 return nullptr;
4883
4884
4885
4890 if (SemaRef.SubstTemplateArguments(TemplArgInfo->arguments(), TemplateArgs,
4891 InstTemplateArgs))
4892 return nullptr;
4893
4894
4895
4897 if (SemaRef.CheckTemplateArgumentList(
4898 ClassTemplate, PartialSpec->getLocation(), InstTemplateArgs,
4899 {},
4900 false, CTAI))
4901 return nullptr;
4902
4903
4904 if (SemaRef.CheckTemplatePartialSpecializationArgs(
4905 PartialSpec->getLocation(), ClassTemplate, InstTemplateArgs.size(),
4907 return nullptr;
4908
4909
4910
4911 void *InsertPos = nullptr;
4914 InstParams, InsertPos);
4915
4916
4919 SemaRef.Context, PartialSpec->getTagKind(), Owner,
4923 nullptr);
4924
4926
4927
4929 return nullptr;
4930
4932
4933 if (PrevDecl) {
4934
4935
4936
4937
4938
4939
4940
4941
4942
4943
4944
4945
4946
4947
4948
4949 SemaRef.Diag(InstPartialSpec->getLocation(),
4950 diag::err_partial_spec_redeclared)
4951 << InstPartialSpec;
4952 SemaRef.Diag(PrevDecl->getLocation(), diag::note_prev_partial_spec_here)
4953 << SemaRef.Context.getCanonicalTagType(PrevDecl);
4954 return nullptr;
4955 }
4956
4957
4958 SemaRef.CheckTemplatePartialSpecialization(InstPartialSpec);
4959
4960
4961
4963 nullptr);
4964 return InstPartialSpec;
4965}
4966
4967
4968
4969
4970
4971
4972
4973
4974
4975
4976
4977
4982
4983
4984
4986
4987
4988
4991 if (!InstParams)
4992 return nullptr;
4993
4994
4995
5000 if (SemaRef.SubstTemplateArguments(TemplArgInfo->arguments(), TemplateArgs,
5001 InstTemplateArgs))
5002 return nullptr;
5003
5004
5005
5008 InstTemplateArgs, {},
5009 false, CTAI))
5010 return nullptr;
5011
5012
5013 if (SemaRef.CheckTemplatePartialSpecializationArgs(
5016 return nullptr;
5017
5018
5019
5020 void *InsertPos = nullptr;
5023 InstParams, InsertPos);
5024
5025
5029 if (!TSI)
5030 return nullptr;
5031
5033 SemaRef.Diag(PartialSpec->getLocation(),
5034 diag::err_variable_instantiates_to_function)
5036 return nullptr;
5037 }
5038
5039
5045
5047
5048
5050 return nullptr;
5051
5053
5054 if (PrevDecl) {
5055
5056
5057
5058
5059
5060
5061
5062
5063
5064
5065
5066
5067
5068
5069
5070 SemaRef.Diag(PartialSpec->getLocation(),
5071 diag::err_var_partial_spec_redeclared)
5072 << InstPartialSpec;
5074 diag::note_var_prev_partial_spec_here);
5075 return nullptr;
5076 }
5077
5078 SemaRef.CheckTemplatePartialSpecialization(InstPartialSpec);
5079
5080
5081
5082 VarTemplate->AddPartialSpecialization(InstPartialSpec, nullptr);
5083
5084 SemaRef.BuildVariableInstantiation(InstPartialSpec, PartialSpec, TemplateArgs,
5085 LateAttrs, Owner, StartingScope);
5086
5087 return InstPartialSpec;
5088}
5089
5094 assert(OldTInfo && "substituting function without type source info");
5095 assert(Params.empty() && "parameter vector is non-empty at start");
5096
5101 ThisTypeQuals = Method->getFunctionObjectParameterType().getQualifiers();
5102 }
5103
5104 TypeSourceInfo *NewTInfo = SemaRef.SubstFunctionDeclType(
5106 ThisContext, ThisTypeQuals, EvaluateConstraints);
5107 if (!NewTInfo)
5108 return nullptr;
5109
5112 if (NewTInfo != OldTInfo) {
5113
5116 unsigned NewIdx = 0;
5117 for (unsigned OldIdx = 0, NumOldParams = OldProtoLoc.getNumParams();
5118 OldIdx != NumOldParams; ++OldIdx) {
5119 ParmVarDecl *OldParam = OldProtoLoc.getParam(OldIdx);
5120 if (!OldParam)
5121 return nullptr;
5122
5124
5125 UnsignedOrNone NumArgumentsInExpansion = std::nullopt;
5127 NumArgumentsInExpansion =
5128 SemaRef.getNumArgumentsInExpansion(OldParam->getType(),
5129 TemplateArgs);
5130 if (!NumArgumentsInExpansion) {
5131
5132
5134 Params.push_back(NewParam);
5135 Scope->InstantiatedLocal(OldParam, NewParam);
5136 } else {
5137
5138 Scope->MakeInstantiatedLocalArgPack(OldParam);
5139 for (unsigned I = 0; I != *NumArgumentsInExpansion; ++I) {
5141 Params.push_back(NewParam);
5142 Scope->InstantiatedLocalPackArg(OldParam, NewParam);
5143 }
5144 }
5145 }
5146 } else {
5147
5148
5149
5152 for (unsigned i = 0, i_end = OldProtoLoc.getNumParams(); i != i_end;
5153 ++i) {
5154 ParmVarDecl *OldParam = OldProtoLoc.getParam(i);
5155 if (!OldParam) {
5156 Params.push_back(SemaRef.BuildParmVarDeclForTypedef(
5158 continue;
5159 }
5160
5162 cast_or_null(VisitParmVarDecl(OldParam));
5163 if (!Parm)
5164 return nullptr;
5165 Params.push_back(Parm);
5166 }
5167 }
5168 } else {
5169
5170
5171
5172
5173
5174
5175
5176
5177
5178
5182 TemplateArgs, ParamTypes, &Params,
5183 ExtParamInfos))
5184 return nullptr;
5185 }
5186
5187 return NewTInfo;
5188}
5189
5194
5195 for (auto *decl : PatternDecl->decls()) {
5197 continue;
5198
5201
5202 auto it = llvm::find_if(Function->decls(), [&](Decl *inst) {
5203 VarDecl *InstVD = dyn_cast(inst);
5204 return InstVD && InstVD->isLocalVarDecl() &&
5205 InstVD->getIdentifier() == II;
5206 });
5207
5208 if (it == Function->decls().end())
5209 continue;
5210
5211 Scope.InstantiatedLocal(VD, *it);
5214 VD->getType(), false);
5215 }
5216}
5217
5218bool Sema::addInstantiatedParametersToScope(
5222 unsigned FParamIdx = 0;
5223 for (unsigned I = 0, N = PatternDecl->getNumParams(); I != N; ++I) {
5224 const ParmVarDecl *PatternParam = PatternDecl->getParamDecl(I);
5226
5227 assert(FParamIdx < Function->getNumParams());
5230
5231
5232
5233
5234
5235
5240 if (T.isNull())
5241 return true;
5243 }
5244
5246 ++FParamIdx;
5247 continue;
5248 }
5249
5250
5252 UnsignedOrNone NumArgumentsInExpansion =
5254 if (NumArgumentsInExpansion) {
5255 QualType PatternType =
5256 PatternParam->getType()->castAs()->getPattern();
5257 for (unsigned Arg = 0; Arg < *NumArgumentsInExpansion; ++Arg) {
5261 Sema::ArgPackSubstIndexRAII SubstIndex(*this, Arg);
5262 QualType T =
5265 if (T.isNull())
5266 return true;
5268 }
5269
5271 ++FParamIdx;
5272 }
5273 }
5274 }
5275
5276 return false;
5277}
5278
5281 assert(Param->hasUninstantiatedDefaultArg());
5282
5283
5284
5285
5286
5287
5288
5289
5292 return true;
5293
5294
5295
5296
5297
5298
5299
5300
5301
5302
5303
5304
5305
5306
5307
5308
5309
5310
5313 false, std::nullopt,
5314 true, nullptr,
5315 false, false,
5316 true);
5317
5318 if (SubstDefaultArgument(CallLoc, Param, TemplateArgs, true))
5319 return true;
5320
5322 L->DefaultArgumentInstantiated(Param);
5323
5324 return false;
5325}
5326
5331 return;
5332
5335 if (AlreadyInstantiating) {
5336
5337
5338 Diag(PointOfInstantiation, diag::err_exception_spec_cycle) << Decl;
5340 return;
5341 }
5342
5347
5348
5350 return;
5351 }
5352
5353
5354
5357
5360 false, std::nullopt,
5361 true);
5362
5363
5364
5365
5366
5368 if (addInstantiatedParametersToScope(Decl, Template, Scope, TemplateArgs)) {
5370 return;
5371 }
5372
5373
5374
5376 *this, Decl, TemplateArgs, Scope,
5377 false);
5378
5380 TemplateArgs);
5381}
5382
5383
5384
5385
5386
5387bool
5391
5392
5393 SemaRef.Context.setManglingNumber(New,
5394 SemaRef.Context.getManglingNumber(Tmpl));
5395
5396
5397
5398
5399
5400
5401
5402
5403
5404
5405
5407 ActiveInstType &ActiveInst = SemaRef.CodeSynthesisContexts.back();
5408 if (ActiveInst.Kind == ActiveInstType::ExplicitTemplateArgumentSubstitution ||
5409 ActiveInst.Kind == ActiveInstType::DeducedTemplateArgumentSubstitution) {
5411 SemaRef.CurrentSFINAEContext = nullptr;
5412 atTemplateEnd(SemaRef.TemplateInstCallbacks, SemaRef, ActiveInst);
5413 ActiveInst.Kind = ActiveInstType::TemplateInstantiation;
5414 ActiveInst.Entity = New;
5415 atTemplateBegin(SemaRef.TemplateInstCallbacks, SemaRef, ActiveInst);
5416 }
5417 }
5418
5420 assert(Proto && "Function template without prototype?");
5421
5424
5425
5426
5427
5428
5429 if (SemaRef.getLangOpts().CPlusPlus11 &&
5440
5441
5444 assert(NewProto && "Template instantiation without function prototype?");
5449 New->setType(SemaRef.Context.getFunctionType(
5451 } else {
5453 SemaRef.SubstExceptionSpec(New, Proto, TemplateArgs);
5454 }
5455 }
5456
5457
5460
5461 SemaRef.InstantiateAttrs(TemplateArgs, Definition, New,
5462 LateAttrs, StartingScope);
5463
5464 return false;
5465}
5466
5467
5468
5469
5470
5471
5472bool
5476 return true;
5477
5480
5483 New->setVirtualAsWritten(true);
5484
5485
5486 return false;
5487}
5488
5491
5494 Lookups.reserve(DFI->getUnqualifiedLookups().size());
5495 bool AnyChanged = false;
5496 for (DeclAccessPair DA : DFI->getUnqualifiedLookups()) {
5497 NamedDecl *D = SemaRef.FindInstantiatedDecl(New->getLocation(),
5498 DA.getDecl(), TemplateArgs);
5499 if (!D)
5500 return true;
5501 AnyChanged |= (D != DA.getDecl());
5503 }
5504
5505
5506
5507 New->setDefaultedOrDeletedInfo(
5509 SemaRef.Context, Lookups)
5510 : DFI);
5511 }
5512
5514 return false;
5515}
5516
5521
5524 return nullptr;
5525
5528 false);
5529
5530 return cast_or_null(SubstDecl(FD, FD->getParent(), MArgs));
5531}
5532
5535 bool Recursive,
5536 bool DefinitionRequired,
5537 bool AtEndOfTU) {
5539 return;
5540
5541
5542
5544 Function->getTemplateSpecializationKindForInstantiation();
5546 return;
5547
5548
5549
5551 !DefinitionRequired)
5552 return;
5553
5554
5556 if (Function->isDefined(ExistingDefn,
5557 true)) {
5559 return;
5560
5561
5562
5563
5566 }
5567
5568#ifndef NDEBUG
5571 assert(!AlreadyInstantiating && "should have been caught by caller");
5572#endif
5573
5574
5575 const FunctionDecl *PatternDecl = Function->getTemplateInstantiationPattern();
5576 assert(PatternDecl && "instantiating a non-template");
5577
5579 Stmt *Pattern = nullptr;
5580 if (PatternDef) {
5581 Pattern = PatternDef->getBody(PatternDef);
5582 PatternDecl = PatternDef;
5584 PatternDef = nullptr;
5585 }
5586
5587
5588 bool Unreachable = false;
5589
5590
5592 PointOfInstantiation, Function,
5593 Function->getInstantiatedFromMemberFunction(), PatternDecl,
5594 PatternDef, TSK,
5595 DefinitionRequired, &Unreachable)) {
5596 if (DefinitionRequired)
5599 (Function->isConstexpr() && !Recursive)) {
5600
5601
5602 assert(!Recursive);
5603 Function->setInstantiationIsPending(true);
5605
5606 if (llvm::isTimeTraceVerbose()) {
5607 llvm::timeTraceAddInstantEvent("DeferInstantiation", [&] {
5608 std::string Name;
5609 llvm::raw_string_ostream OS(Name);
5611 true);
5612 return Name;
5613 });
5614 }
5616 if (AtEndOfTU && ().hasErrorOccurred() &&
5618 Diag(PointOfInstantiation, diag::warn_func_template_missing)
5620 if (Unreachable) {
5621
5622
5624 diag::note_unreachable_template_decl);
5625 } else {
5626 Diag(PatternDecl->getLocation(), diag::note_forward_template_decl);
5628 Diag(PointOfInstantiation, diag::note_inst_declaration_hint)
5630 }
5631 }
5632 }
5633
5634 return;
5635 }
5636
5637
5640 Function->setInstantiationIsPending(true);
5642 std::make_pair(Function, PointOfInstantiation));
5643 return;
5644 }
5645
5646 llvm::TimeTraceScope TimeScope("InstantiateFunction", [&]() {
5647 llvm::TimeTraceMetadata M;
5648 llvm::raw_string_ostream OS(M.Detail);
5650 true);
5651 if (llvm::isTimeTraceVerbose()) {
5653 M.File = SourceMgr.getFilename(Loc);
5654 M.Line = SourceMgr.getExpansionLineNumber(Loc);
5655 }
5656 return M;
5657 });
5658
5659
5660
5661
5662
5663
5665 Recursive,
5666 AtEndOfTU);
5668 AtEndOfTU);
5669
5670
5671
5674
5677
5680 "missing LateParsedTemplate");
5682 Pattern = PatternDecl->getBody(PatternDecl);
5684 }
5685
5686
5687 assert((Pattern || PatternDecl->isDefaulted() ||
5689 "unexpected kind of function template definition");
5690
5691
5692
5693
5694
5695
5699 return;
5700
5702
5703
5704 for (auto *D = Function->getMostRecentDecl(); ;
5706 D->setImplicitlyInline();
5708 break;
5709 }
5710 }
5711
5715 return;
5717 "instantiating function definition");
5718
5719
5720
5721 Function->setVisibleDespiteOwningModule();
5722
5723
5727
5728
5729
5730
5731
5732
5733
5734
5735
5736
5737
5738
5739
5740
5741
5742
5743
5744
5745
5746
5747 auto NameLocPointsToPattern = [&] {
5754 break;
5755 default:
5756
5757
5758 return PatternNameLoc;
5759 }
5760
5762
5763
5764 if (!TSI) {
5765
5766
5767
5768 return PatternNameLoc;
5769 }
5770
5772
5773
5776 assert(PatternTSI && "Pattern is supposed to have an associated TSI");
5777
5778
5779
5783 };
5784 Function->setDeclarationNameLoc(NameLocPointsToPattern());
5785
5788
5792 ThisContext = Method->getParent();
5793 ThisTypeQuals = Method->getMethodQualifiers();
5794 }
5795 CXXThisScopeRAII ThisScope(*this, ThisContext, ThisTypeQuals);
5796
5797
5798
5799
5800
5801
5802
5803 bool MergeWithParentScope = false;
5805 MergeWithParentScope =
5806 Rec->isLocalClass() && ->isFunctionTemplateSpecialization();
5807
5809 auto RebuildTypeSourceInfoForDefaultSpecialMembers = [&]() {
5810
5811
5812
5813
5815 "Special member needs to be defaulted");
5821 return;
5822
5823 auto *NewRec = dyn_cast(Function->getDeclContext());
5824 const auto *PatternRec =
5825 dyn_cast(PatternDecl->getDeclContext());
5826 if (!NewRec || !PatternRec)
5827 return;
5828 if (!PatternRec->isLambda())
5829 return;
5830
5831 struct SpecialMemberTypeInfoRebuilder
5832 : TreeTransform {
5836
5840
5844 bool &Changed) {
5845 return false;
5846 }
5847
5851 getDerived().TransformDecl(TL.getNameLoc(), T->getDecl()));
5852 if (Record != OldDecl)
5853 return Base::TransformRecordType(TLB, TL);
5854
5855
5858 if (Result.isNull())
5860
5866 }
5867 } IR{*this, PatternRec, NewRec};
5868
5870 assert(NewSI && "Type Transform failed?");
5872 Function->setTypeSourceInfo(NewSI);
5873
5876 assert(NewParmSI && "Type transformation failed.");
5879 };
5880
5882 RebuildTypeSourceInfoForDefaultSpecialMembers();
5884 } else {
5886 std::optional<ArrayRef> Innermost;
5887 if (auto *Primary = Function->getPrimaryTemplate();
5888 Primary &&
5890 Function->getTemplateSpecializationKind() !=
5892 auto It = llvm::find_if(Primary->redecls(),
5894 return cast(RTD)
5895 ->isCompatibleWithDefinition();
5896 });
5897 assert(It != Primary->redecls().end() &&
5898 "Should't get here without a definition");
5900 ->getTemplatedDecl()
5903 else
5904 DC = (*It)->getLexicalDeclContext();
5905 Innermost.emplace(Function->getTemplateSpecializationArgs()->asArray());
5906 }
5908 Function, DC, false, Innermost, false, PatternDecl);
5909
5910
5911
5912
5913
5915
5917
5918
5919
5921
5925
5926 if (addInstantiatedParametersToScope(Function, PatternDecl, Scope,
5927 TemplateArgs))
5928 return;
5929
5933 Body = nullptr;
5934 } else {
5936
5938 TemplateArgs);
5939
5940
5941
5942 if (Context.getTargetInfo().getCXXABI().isMicrosoft() &&
5943 Ctor->isDefaultConstructor()) {
5945 }
5946 }
5947
5948
5949 Body = SubstStmt(Pattern, TemplateArgs);
5950
5953 }
5954
5955
5957
5958 checkReferenceToTULocalFromOtherTU(Function, PointOfInstantiation);
5959
5961
5963 Listener->FunctionDefinitionInstantiated(Function);
5964
5965 savedContext.pop();
5966 }
5967
5968
5969
5970
5971
5972
5973 bool ShouldSkipCG = [&] {
5974 auto *RD = dyn_cast(Function->getParent());
5975 if (!RD || !RD->isLambda())
5976 return false;
5977
5979 return Context.isUnevaluated() || Context.isImmediateFunctionContext();
5980 });
5981 }();
5982 if (!ShouldSkipCG) {
5984 Consumer.HandleTopLevelDecl(DG);
5985 }
5986
5987
5988
5989 LocalInstantiations.perform();
5991 GlobalInstantiations.perform();
5992}
5993
6001 return nullptr;
6002
6006 return nullptr;
6007
6008
6009
6010
6011
6012
6013
6014
6015
6016
6017 bool IsMemberSpec = false;
6019 if (auto *PartialSpec =
6020 dyn_cast(FromVar)) {
6021 assert(PartialSpecArgs);
6022 IsMemberSpec = PartialSpec->isMemberSpecialization();
6024 PartialSpec, PartialSpecArgs->asArray(), false);
6025 } else {
6027 IsMemberSpec = VarTemplate->isMemberSpecialization();
6029 false);
6030 }
6031 if (!IsMemberSpec)
6033
6035 MultiLevelList);
6036
6037
6038
6040 Converted);
6041}
6042
6047 "don't have a definition to instantiate from");
6048
6049
6053 if (!TSI)
6054 return nullptr;
6055
6056
6058
6059
6061
6062
6064
6067
6068 return VarSpec;
6069}
6070
6076 bool InstantiatingVarTemplate,
6078
6079
6080 bool InstantiatingVarTemplatePartialSpec =
6083
6084
6085 bool InstantiatingSpecFromTemplate =
6089
6090
6091
6092
6093
6094
6109
6111 if (OldVar->isUsed(false))
6114 }
6115
6116 InstantiateAttrs(TemplateArgs, OldVar, NewVar, LateAttrs, StartingScope);
6117
6124
6128
6129
6136 } else if (PrevDeclForVarTemplateSpecialization) {
6137 Previous.addDecl(PrevDeclForVarTemplateSpecialization);
6138 }
6140
6141 if (!InstantiatingVarTemplate) {
6145 }
6146
6150 }
6151
6152
6153
6154
6155
6156
6157
6159 !InstantiatingSpecFromTemplate)
6162
6163
6164
6166 dyn_cast(OldVar)) {
6171 }
6172
6173
6174 Context.setManglingNumber(NewVar, Context.getManglingNumber(OldVar));
6175 Context.setStaticLocalNumber(NewVar, Context.getStaticLocalNumber(OldVar));
6176
6177
6178 if (InstantiatingVarTemplate || InstantiatingVarTemplatePartialSpec) {
6179
6181
6183 } else if (InstantiatingSpecFromTemplate ||
6186
6187
6188
6189 } else {
6191 }
6192
6193
6194
6199}
6200
6205 L->VariableDefinitionInstantiated(Var);
6206
6207
6208
6209
6212 else if (OldVar->isInline())
6214
6216
6224
6225
6226
6228
6229 if (OldVar->getInit()) {
6230
6234
6235 if (.isInvalid()) {
6236 Expr *InitExpr = Init.get();
6237
6238 if (Var->hasAttr() &&
6239 (!InitExpr ||
6241
6242 } else if (InitExpr) {
6245 } else
6247 } else {
6248
6249
6251 }
6252 } else {
6253
6254
6257 return;
6258
6259
6260
6262 return;
6263 }
6264
6265
6267 return;
6268
6270 }
6271
6274}
6275
6277 VarDecl *Var, bool Recursive,
6278 bool DefinitionRequired, bool AtEndOfTU) {
6280 return;
6281
6282
6286 return;
6287
6290 if (AlreadyInstantiating)
6291 return;
6292
6293
6295 assert(PatternDecl && "no pattern for templated variable");
6298
6300 dyn_cast(Var);
6301 if (VarSpec) {
6302
6303
6304
6305
6306
6307
6308
6309
6311 (PatternDecl = PatternDecl->getFirstDecl())->hasInit() &&
6313
6314
6318 return;
6320 "instantiating variable initializer");
6321
6322
6323
6325
6326
6327
6328
6330 *this,
6331 Recursive, AtEndOfTU);
6334 AtEndOfTU);
6335
6336
6337
6340 PreviousContext.pop();
6341
6342
6343
6344 LocalInstantiations.perform();
6345 Local.Exit();
6346 GlobalInstantiations.perform();
6347 }
6348 } else {
6350 "not a static data member?");
6351 }
6352
6354
6355
6356
6357
6358
6359 if (!Def && !DefinitionRequired) {
6363
6364 if (AtEndOfTU && ().hasErrorOccurred() &&
6366 Diag(PointOfInstantiation, diag::warn_var_template_missing)
6367 << Var;
6368 Diag(PatternDecl->getLocation(), diag::note_forward_template_decl);
6370 Diag(PointOfInstantiation, diag::note_inst_declaration_hint) << Var;
6371 }
6372 return;
6373 }
6374 }
6375
6376
6377
6378
6380 false,
6381 PatternDecl, Def, TSK,
6382 DefinitionRequired))
6383 return;
6384
6385
6386
6387
6388
6389
6390
6391
6392
6393
6396 return;
6397
6398
6399 struct PassToConsumerRAII {
6402
6405
6406 ~PassToConsumerRAII() {
6407 Consumer.HandleCXXStaticMemberVarInstantiation(Var);
6408 }
6409 } PassToConsumerRAII(Consumer, Var);
6410
6411
6413
6414
6416 PointOfInstantiation);
6417 return;
6418 }
6419
6423 return;
6425 "instantiating variable definition");
6426
6427
6428
6429
6431 Recursive,
6432 AtEndOfTU);
6433
6434
6435
6438
6440 AtEndOfTU);
6441
6444
6445
6447 } else if (!VarSpec) {
6449 TemplateArgs));
6452
6453
6454
6456 TemplateArgs);
6457
6461 TemplateArgInfo.setLAngleLoc(ArgInfo->getLAngleLoc());
6462 TemplateArgInfo.setRAngleLoc(ArgInfo->getRAngleLoc());
6465 }
6466
6471 Var = VTSD;
6472
6473 if (Var) {
6475
6483
6484
6486 }
6487 } else
6488
6489
6491
6492 PreviousContext.pop();
6493
6494 if (Var) {
6495 PassToConsumerRAII.Var = Var;
6498
6500 }
6501
6502
6503
6504 LocalInstantiations.perform();
6505 Local.Exit();
6506 GlobalInstantiations.perform();
6507}
6508
6509void
6513
6516
6517
6518 for (const auto *Init : Tmpl->inits()) {
6519
6520
6521 if (->isWritten())
6522 continue;
6523
6525
6526 if (Init->isPackExpansion()) {
6527
6528 TypeLoc BaseTL = Init->getTypeSourceInfo()->getTypeLoc();
6532 bool ShouldExpand = false;
6533 bool RetainExpansion = false;
6537 TemplateArgs, true, ShouldExpand,
6538 RetainExpansion, NumExpansions)) {
6539 AnyErrors = true;
6540 New->setInvalidDecl();
6541 continue;
6542 }
6543 assert(ShouldExpand && "Partial instantiation of base initializer?");
6544
6545
6546 for (unsigned I = 0; I != *NumExpansions; ++I) {
6548
6549
6551 true);
6553 AnyErrors = true;
6554 break;
6555 }
6556
6557
6559 TemplateArgs,
6560 Init->getSourceLocation(),
6561 New->getDeclName());
6562 if (!BaseTInfo) {
6563 AnyErrors = true;
6564 break;
6565 }
6566
6567
6569 BaseTInfo, TempInit.get(),
6570 New->getParent(),
6573 AnyErrors = true;
6574 break;
6575 }
6576
6577 NewInits.push_back(NewInit.get());
6578 }
6579
6580 continue;
6581 }
6582
6583
6585 true);
6587 AnyErrors = true;
6588 continue;
6589 }
6590
6592 if (Init->isDelegatingInitializer() || Init->isBaseInitializer()) {
6594 TemplateArgs,
6595 Init->getSourceLocation(),
6596 New->getDeclName());
6597 if (!TInfo) {
6598 AnyErrors = true;
6599 New->setInvalidDecl();
6600 continue;
6601 }
6602
6603 if (Init->isBaseInitializer())
6605 New->getParent(), EllipsisLoc);
6606 else
6609 } else if (Init->isMemberInitializer()) {
6611 Init->getMemberLocation(),
6612 Init->getMember(),
6613 TemplateArgs));
6615 AnyErrors = true;
6616 New->setInvalidDecl();
6617 continue;
6618 }
6619
6621 Init->getSourceLocation());
6622 } else if (Init->isIndirectMemberInitializer()) {
6625 Init->getMemberLocation(),
6626 Init->getIndirectMember(), TemplateArgs));
6627
6628 if (!IndirectMember) {
6629 AnyErrors = true;
6630 New->setInvalidDecl();
6631 continue;
6632 }
6633
6635 Init->getSourceLocation());
6636 }
6637
6639 AnyErrors = true;
6640 New->setInvalidDecl();
6641 } else {
6642 NewInits.push_back(NewInit.get());
6643 }
6644 }
6645
6646
6648
6650 NewInits,
6651 AnyErrors);
6652}
6653
6654
6655
6659
6660 do {
6661 Instance = Instance->getCanonicalDecl();
6662 if (Pattern == Instance) return true;
6663 Instance = Instance->getInstantiatedFromMemberTemplate();
6664 } while (Instance);
6665
6666 return false;
6667}
6668
6672
6673 do {
6674 Instance = Instance->getCanonicalDecl();
6675 if (Pattern == Instance) return true;
6676 Instance = Instance->getInstantiatedFromMemberTemplate();
6677 } while (Instance);
6678
6679 return false;
6680}
6681
6682static bool
6685 Pattern
6687 do {
6689 Instance->getCanonicalDecl());
6690 if (Pattern == Instance)
6691 return true;
6692 Instance = Instance->getInstantiatedFromMember();
6693 } while (Instance);
6694
6695 return false;
6696}
6697
6701
6702 do {
6703 Instance = Instance->getCanonicalDecl();
6704 if (Pattern == Instance) return true;
6705 Instance = Instance->getInstantiatedFromMemberClass();
6706 } while (Instance);
6707
6708 return false;
6709}
6710
6714
6715 do {
6716 Instance = Instance->getCanonicalDecl();
6717 if (Pattern == Instance) return true;
6718 Instance = Instance->getInstantiatedFromMemberFunction();
6719 } while (Instance);
6720
6721 return false;
6722}
6723
6727
6728 do {
6729 Instance = Instance->getCanonicalDecl();
6730 if (Pattern == Instance) return true;
6731 Instance = Instance->getInstantiatedFromMemberEnum();
6732 } while (Instance);
6733
6734 return false;
6735}
6736
6740 return declaresSameEntity(C.getInstantiatedFromUsingShadowDecl(Instance),
6741 Pattern);
6742}
6743
6748
6749template
6752
6753
6754
6755
6756
6757
6758 bool OtherIsPackExpansion;
6760 if (auto *OtherUUD = dyn_cast(Other)) {
6761 OtherIsPackExpansion = OtherUUD->isPackExpansion();
6763 } else if (auto *OtherUPD = dyn_cast(Other)) {
6764 OtherIsPackExpansion = true;
6765 OtherFrom = OtherUPD->getInstantiatedFromUsingDecl();
6766 } else if (auto *OtherUD = dyn_cast(Other)) {
6767 OtherIsPackExpansion = false;
6769 } else {
6770 return false;
6771 }
6772 return Pattern->isPackExpansion() == OtherIsPackExpansion &&
6774}
6775
6778 assert(Instance->isStaticDataMember());
6779
6781
6782 do {
6783 Instance = Instance->getCanonicalDecl();
6784 if (Pattern == Instance) return true;
6785 Instance = Instance->getInstantiatedFromStaticDataMember();
6786 } while (Instance);
6787
6788 return false;
6789}
6790
6791
6792
6794 if (auto *UUD = dyn_cast(D))
6796
6797 if (auto *UUD = dyn_cast(D))
6799
6801 return false;
6802
6803 if (auto *Record = dyn_cast(Other))
6805
6806 if (auto *Function = dyn_cast(Other))
6808
6809 if (auto *Enum = dyn_cast(Other))
6811
6812 if (auto *Var = dyn_cast(Other))
6815
6816 if (auto *Temp = dyn_cast(Other))
6818
6819 if (auto *Temp = dyn_cast(Other))
6821
6822 if (auto *PartialSpec =
6823 dyn_cast(Other))
6825 PartialSpec);
6826
6827 if (auto *Field = dyn_cast(Other)) {
6828 if (!Field->getDeclName()) {
6829
6832 }
6833 }
6834
6835 if (auto *Using = dyn_cast(Other))
6837
6838 if (auto *Shadow = dyn_cast(Other))
6840
6843}
6844
6845template
6848 ForwardIterator first,
6849 ForwardIterator last) {
6850 for (; first != last; ++first)
6853
6854 return nullptr;
6855}
6856
6859 if (NamedDecl *D = dyn_cast(DC)) {
6861 return cast_or_null(ID);
6862 } else return DC;
6863}
6864
6865
6866
6867
6868
6869
6870
6873 return false;
6874 if (!Level)
6875 return true;
6876 return cast(DC)->getTemplateDepth() > Level;
6877}
6878
6881 bool FindingInstantiatedContext) {
6883
6884
6887
6888
6889
6890
6891
6892
6893
6894
6895
6896
6897
6898
6899
6900
6901
6902
6905 return D;
6914
6915
6919 if (auto *BD = dyn_cast(FD);
6922 }
6924 }
6925
6927 "found declaration pack but not pack expanding");
6931 }
6932 }
6933
6934
6935
6936
6939 return D;
6940
6942 return nullptr;
6943
6944
6945
6946
6947
6948
6949
6950
6951
6952
6953
6954
6955
6956
6957 bool NeedInstantiate = false;
6958 if (CXXRecordDecl *RD = dyn_cast(D))
6959 NeedInstantiate = RD->isLocalClass();
6962 NeedInstantiate = true;
6963 else
6965 if (NeedInstantiate) {
6969 }
6970
6971
6972
6974
6976 assert(Inst && "Failed to instantiate label??");
6977
6980 }
6981
6983 if (->isDependentContext())
6984 return D;
6985
6986
6987
6992 dyn_cast(Record))
6993 ClassTemplate = Spec->getSpecializedTemplate()->getCanonicalDecl();
6994
6995
6996
6999
7000
7003
7004 if (CXXRecordDecl *InstRecord = dyn_cast(DC)) {
7005
7006
7008 = dyn_cast(InstRecord)){
7009 ClassTemplateDecl *SpecTemplate = InstSpec->getSpecializedTemplate();
7011 return InstRecord;
7012 }
7013
7014
7016 return InstRecord;
7017 }
7018
7019
7020 if (FunctionDecl *FD = dyn_cast(DC)) {
7024 continue;
7025 }
7026
7027
7028 auto *Guide = dyn_cast(FD);
7029 if (Guide && Guide->isImplicit()) {
7030 TemplateDecl *TD = Guide->getDeducedTemplate();
7031
7037 Unpacked = Arg.pack_elements();
7041 }
7044 nullptr, false);
7045
7046
7047
7048
7049
7050 if (T.isNull() || T->containsErrors())
7051 return nullptr;
7052 CXXRecordDecl *SubstRecord = T->getAsCXXRecordDecl();
7053
7054 if (!SubstRecord) {
7055
7056
7057
7058
7059
7060 assert(SemaRef.RebuildingImmediateInvocation ||
7063
7064
7065
7066 return nullptr;
7067 }
7068
7069
7070
7071
7072
7073 if (FindingInstantiatedContext &&
7076 Diag(Loc, diag::err_specialization_not_primary_template)
7079 return nullptr;
7080 }
7081 DC = SubstRecord;
7082 continue;
7083 }
7084 }
7085
7087 }
7088
7089
7090
7091 }
7092
7093 if (!ParentDependsOnArgs)
7094 return D;
7095
7097 if (!ParentDC)
7098 return nullptr;
7099
7101
7102
7103
7104
7105
7106
7107 bool IsBeingInstantiated = false;
7108 if (auto *Spec = dyn_cast(ParentDC)) {
7109 if (!Spec->isDependentContext()) {
7110 if (Spec->isEntityBeingDefined())
7111 IsBeingInstantiated = true;
7113 diag::err_incomplete_type))
7114 return nullptr;
7115
7116 ParentDC = Spec->getDefinitionOrSelf();
7117 }
7118 }
7119
7121
7122
7127 Name = NewNameInfo.getName();
7128 if (!Name)
7129 return nullptr;
7131
7133 } else {
7134
7135
7136
7137
7138
7139
7140
7141
7145 }
7146
7149
7151
7152
7153
7154
7155 } else if (IsBeingInstantiated) {
7156
7157
7158
7159
7160
7161 Diag(Loc, diag::err_member_not_yet_instantiated)
7164 Diag(D->getLocation(), diag::note_non_instantiated_member_here);
7165 } else if (EnumConstantDecl *ED = dyn_cast(D)) {
7166
7167
7168
7171 TemplateArgs));
7174 Diag(Loc, diag::err_enumerator_does_not_exist)
7177 Diag(Spec->getLocation(), diag::note_enum_specialized_here)
7178 << Context.getCanonicalTagType(Spec);
7179 } else {
7180
7181 llvm_unreachable("Unable to find instantiation of declaration!");
7182 }
7183 }
7184
7186 }
7187
7188 return D;
7189}
7190
7192 std::deque DelayedImplicitInstantiations;
7196
7197 bool LocalInstantiation = false;
7201 } else {
7204 LocalInstantiation = true;
7205 }
7206
7207
7209 bool DefinitionRequired = Function->getTemplateSpecializationKind() ==
7211 if (Function->isMultiVersion()) {
7214 [this, Inst, DefinitionRequired, AtEndOfTU](FunctionDecl *CurFD) {
7216 DefinitionRequired, AtEndOfTU);
7219 });
7220 } else {
7222 DefinitionRequired, AtEndOfTU);
7224 Function->setInstantiationIsPending(false);
7225 }
7226
7227 if (!LocalOnly && LangOpts.PCHInstantiateTemplates &&
7229 DelayedImplicitInstantiations.push_back(Inst);
7230 else if (!AtEndOfTU && Function->instantiationIsPending() &&
7231 !LocalInstantiation)
7232 DelayedImplicitInstantiations.push_back(Inst);
7233 continue;
7234 }
7235
7236
7238
7241 "Not a static data member, nor a variable template"
7242 " specialization?");
7243
7244
7245
7247 continue;
7248
7249
7250
7254 llvm_unreachable("Cannot instantitiate an undeclared specialization.");
7257 continue;
7259
7260
7262 continue;
7263 break;
7265 break;
7266 }
7267
7269 "instantiating variable definition");
7272
7273
7274
7276 DefinitionRequired, AtEndOfTU);
7277 }
7278
7279 if (!DelayedImplicitInstantiations.empty())
7281}
7282
7285 for (auto *DD : Pattern->ddiags()) {
7286 switch (DD->getKind()) {
7289 break;
7290 }
7291 }
7292}
Defines the clang::ASTContext interface.
Defines the C++ template declaration subclasses.
Defines the clang::Expr interface and subclasses for C++ expressions.
TokenType getType() const
Returns the token's type, e.g.
FormatToken * Previous
The previous token in the unwrapped line.
FormatToken * Next
The next token in the unwrapped line.
llvm::MachO::Record Record
@ ForExternalRedeclaration
The lookup results will be used for redeclaration of a name with external linkage; non-visible lookup...
@ ForVisibleRedeclaration
The lookup results will be used for redeclaration of a name, if an entity by that name already exists...
llvm::SmallVector< std::pair< const MemRegion *, SVal >, 4 > Bindings
static std::string toString(const clang::SanitizerSet &Sanitizers)
Produce a string containing comma-separated names of sanitizers in Sanitizers set.
This file declares semantic analysis functions specific to AMDGPU.
static bool hasAttr(const Decl *D, bool IgnoreImplicitAttr)
This file declares semantic analysis for CUDA constructs.
static const NamedDecl * getDefinition(const Decl *D)
This file declares semantic analysis for HLSL constructs.
This file declares semantic analysis for Objective-C.
This file declares semantic analysis for OpenMP constructs and clauses.
This file declares semantic analysis functions specific to Swift.
static void instantiateDependentAMDGPUWavesPerEUAttr(Sema &S, const MultiLevelTemplateArgumentList &TemplateArgs, const AMDGPUWavesPerEUAttr &Attr, Decl *New)
Definition SemaTemplateInstantiateDecl.cpp:657
static NamedDecl * findInstantiationOf(ASTContext &Ctx, NamedDecl *D, ForwardIterator first, ForwardIterator last)
Definition SemaTemplateInstantiateDecl.cpp:6846
static void instantiateDependentAMDGPUMaxNumWorkGroupsAttr(Sema &S, const MultiLevelTemplateArgumentList &TemplateArgs, const AMDGPUMaxNumWorkGroupsAttr &Attr, Decl *New)
Definition SemaTemplateInstantiateDecl.cpp:680
static void instantiateDependentAMDGPUFlatWorkGroupSizeAttr(Sema &S, const MultiLevelTemplateArgumentList &TemplateArgs, const AMDGPUFlatWorkGroupSizeAttr &Attr, Decl *New)
Definition SemaTemplateInstantiateDecl.cpp:590
static void instantiateDependentCUDAClusterDimsAttr(Sema &S, const MultiLevelTemplateArgumentList &TemplateArgs, const CUDAClusterDimsAttr &Attr, Decl *New)
Definition SemaTemplateInstantiateDecl.cpp:712
static void sharedInstantiateConstructorDestructorAttr(Sema &S, const MultiLevelTemplateArgumentList &TemplateArgs, const Attr *A, Decl *New, ASTContext &C)
Definition SemaTemplateInstantiateDecl.cpp:238
static void instantiateDependentDiagnoseIfAttr(Sema &S, const MultiLevelTemplateArgumentList &TemplateArgs, const DiagnoseIfAttr *DIA, const Decl *Tmpl, FunctionDecl *New)
Definition SemaTemplateInstantiateDecl.cpp:307
static QualType adjustFunctionTypeForInstantiation(ASTContext &Context, FunctionDecl *D, TypeSourceInfo *TInfo)
Adjust the given function type for an instantiation of the given declaration, to cope with modificati...
Definition SemaTemplateInstantiateDecl.cpp:2684
static bool isRelevantAttr(Sema &S, const Decl *D, const Attr *A)
Determine whether the attribute A might be relevant to the declaration D.
Definition SemaTemplateInstantiateDecl.cpp:741
static void instantiateDependentReqdWorkGroupSizeAttr(Sema &S, const MultiLevelTemplateArgumentList &TemplateArgs, const ReqdWorkGroupSizeAttr &Attr, Decl *New)
Definition SemaTemplateInstantiateDecl.cpp:610
#define CLAUSE_NOT_ON_DECLS(CLAUSE_NAME)
Definition SemaTemplateInstantiateDecl.cpp:1198
static void instantiateDependentMallocSpanAttr(Sema &S, const MallocSpanAttr *Attr, Decl *New)
Definition SemaTemplateInstantiateDecl.cpp:801
static bool isDependentContextAtLevel(DeclContext *DC, unsigned Level)
Determine whether the given context is dependent on template parameters at level Level or below.
Definition SemaTemplateInstantiateDecl.cpp:6871
static void instantiateDependentModeAttr(Sema &S, const MultiLevelTemplateArgumentList &TemplateArgs, const ModeAttr &Attr, Decl *New)
Definition SemaTemplateInstantiateDecl.cpp:354
static void instantiateDependentCUDALaunchBoundsAttr(Sema &S, const MultiLevelTemplateArgumentList &TemplateArgs, const CUDALaunchBoundsAttr &Attr, Decl *New)
Definition SemaTemplateInstantiateDecl.cpp:322
static bool isDeclWithinFunction(const Decl *D)
Definition SemaTemplateInstantiateDecl.cpp:41
static void instantiateDependentAssumeAlignedAttr(Sema &S, const MultiLevelTemplateArgumentList &TemplateArgs, const AssumeAlignedAttr *Aligned, Decl *New)
Definition SemaTemplateInstantiateDecl.cpp:152
static bool SubstQualifier(Sema &SemaRef, const DeclT *OldDecl, DeclT *NewDecl, const MultiLevelTemplateArgumentList &TemplateArgs)
Definition SemaTemplateInstantiateDecl.cpp:53
static void collectUnexpandedParameterPacks(Sema &S, TemplateParameterList *Params, SmallVectorImpl< UnexpandedParameterPack > &Unexpanded)
Definition SemaTemplateInstantiateDecl.cpp:3762
static void instantiateDependentHLSLParamModifierAttr(Sema &S, const MultiLevelTemplateArgumentList &TemplateArgs, const HLSLParamModifierAttr *Attr, const Decl *Old, Decl *New)
Definition SemaTemplateInstantiateDecl.cpp:785
static DeclT * getPreviousDeclForInstantiation(DeclT *D)
Get the previous declaration of a declaration for the purposes of template instantiation.
Definition SemaTemplateInstantiateDecl.cpp:1088
static Expr * instantiateDependentFunctionAttrCondition(Sema &S, const MultiLevelTemplateArgumentList &TemplateArgs, const Attr *A, Expr *OldCond, const Decl *Tmpl, FunctionDecl *New)
Definition SemaTemplateInstantiateDecl.cpp:265
static bool isInstantiationOf(ClassTemplateDecl *Pattern, ClassTemplateDecl *Instance)
Definition SemaTemplateInstantiateDecl.cpp:6656
static void instantiateDependentAllocAlignAttr(Sema &S, const MultiLevelTemplateArgumentList &TemplateArgs, const AllocAlignAttr *Align, Decl *New)
Definition SemaTemplateInstantiateDecl.cpp:186
static bool isInstantiationOfStaticDataMember(VarDecl *Pattern, VarDecl *Instance)
Definition SemaTemplateInstantiateDecl.cpp:6776
static void instantiateOMPDeclareSimdDeclAttr(Sema &S, const MultiLevelTemplateArgumentList &TemplateArgs, const OMPDeclareSimdDeclAttr &Attr, Decl *New)
Instantiation of 'declare simd' attribute and its arguments.
Definition SemaTemplateInstantiateDecl.cpp:362
static void instantiateDependentSYCLKernelAttr(Sema &S, const MultiLevelTemplateArgumentList &TemplateArgs, const SYCLKernelAttr &Attr, Decl *New)
Definition SemaTemplateInstantiateDecl.cpp:732
static void instantiateDependentAlignValueAttr(Sema &S, const MultiLevelTemplateArgumentList &TemplateArgs, const AlignValueAttr *Aligned, Decl *New)
Definition SemaTemplateInstantiateDecl.cpp:175
static void instantiateDependentAlignedAttr(Sema &S, const MultiLevelTemplateArgumentList &TemplateArgs, const AlignedAttr *Aligned, Decl *New, bool IsPackExpansion)
Definition SemaTemplateInstantiateDecl.cpp:91
static void instantiateOMPDeclareVariantAttr(Sema &S, const MultiLevelTemplateArgumentList &TemplateArgs, const OMPDeclareVariantAttr &Attr, Decl *New)
Instantiation of 'declare variant' attribute and its arguments.
Definition SemaTemplateInstantiateDecl.cpp:445
static void instantiateDependentEnableIfAttr(Sema &S, const MultiLevelTemplateArgumentList &TemplateArgs, const EnableIfAttr *EIA, const Decl *Tmpl, FunctionDecl *New)
Definition SemaTemplateInstantiateDecl.cpp:296
static void instantiateDependentAnnotationAttr(Sema &S, const MultiLevelTemplateArgumentList &TemplateArgs, const AnnotateAttr *Attr, Decl *New)
Definition SemaTemplateInstantiateDecl.cpp:196
static Sema::RetainOwnershipKind attrToRetainOwnershipKind(const Attr *A)
Definition SemaTemplateInstantiateDecl.cpp:836
static void instantiateDependentOpenACCRoutineDeclAttr(Sema &S, const MultiLevelTemplateArgumentList &TemplateArgs, const OpenACCRoutineDeclAttr *OldAttr, const Decl *Old, Decl *New)
Definition SemaTemplateInstantiateDecl.cpp:1448
static bool isInstantiationOfUnresolvedUsingDecl(T *Pattern, Decl *Other, ASTContext &Ctx)
Definition SemaTemplateInstantiateDecl.cpp:6750
static bool isInvalid(LocType Loc, bool *Invalid)
Defines the SourceManager interface.
Defines the clang::TypeLoc interface and its subclasses.
ASTConsumer - This is an abstract interface that should be implemented by clients that read ASTs.
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
void setInstantiatedFromUsingDecl(NamedDecl *Inst, NamedDecl *Pattern)
Remember that the using decl Inst is an instantiation of the using decl Pattern of a class template.
QualType mergeFunctionTypes(QualType, QualType, bool OfBlockPointer=false, bool Unqualified=false, bool AllowCXX=false, bool IsConditionalOperator=false)
NamedDecl * getInstantiatedFromUsingDecl(NamedDecl *Inst)
If the given using decl Inst is an instantiation of another (possibly unresolved) using decl,...
DeclarationNameTable DeclarationNames
void forEachMultiversionedFunctionVersion(const FunctionDecl *FD, llvm::function_ref< void(FunctionDecl *)> Pred) const
Visits all versions of a multiversioned function with the passed predicate.
OMPTraitInfo & getNewOMPTraitInfo()
Return a new OMPTraitInfo object owned by this context.
FieldDecl * getInstantiatedFromUnnamedFieldDecl(FieldDecl *Field) const
CanQualType UnsignedLongLongTy
static bool hasSameType(QualType T1, QualType T2)
Determine whether the given types T1 and T2 are equivalent.
CanQualType getCanonicalTagType(const TagDecl *TD) const
An abstract interface that should be implemented by listeners that want to be notified when an AST en...
Represents an access specifier followed by colon ':'.
static AccessSpecDecl * Create(ASTContext &C, AccessSpecifier AS, DeclContext *DC, SourceLocation ASLoc, SourceLocation ColonLoc)
SourceLocation getColonLoc() const
The location of the colon following the access specifier.
SourceLocation getAccessSpecifierLoc() const
The location of the access specifier.
Attr - This represents one attribute.
attr::Kind getKind() const
Attr * clone(ASTContext &C) const
SourceLocation getLocation() const
SourceRange getRange() const
SourceLocation getLoc() const
Represents a C++ declaration that introduces decls from somewhere else.
shadow_range shadows() const
A binding in a decomposition declaration.
static BindingDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation IdLoc, IdentifierInfo *Id, QualType T)
ArrayRef< BindingDecl * > getBindingPackDecls() const
Represents the builtin template declaration which is used to implement __make_integer_seq and other b...
Represents a C++ constructor within a class.
bool isDefaultConstructor() const
Whether this constructor is a default constructor (C++ [class.ctor]p5), which can be used to default-...
static CXXConstructorDecl * Create(ASTContext &C, CXXRecordDecl *RD, SourceLocation StartLoc, const DeclarationNameInfo &NameInfo, QualType T, TypeSourceInfo *TInfo, ExplicitSpecifier ES, bool UsesFPIntrin, bool isInline, bool isImplicitlyDeclared, ConstexprSpecKind ConstexprKind, InheritedConstructor Inherited=InheritedConstructor(), const AssociatedConstraint &TrailingRequiresClause={})
Represents a C++ conversion function within a class.
static CXXConversionDecl * Create(ASTContext &C, CXXRecordDecl *RD, SourceLocation StartLoc, const DeclarationNameInfo &NameInfo, QualType T, TypeSourceInfo *TInfo, bool UsesFPIntrin, bool isInline, ExplicitSpecifier ES, ConstexprSpecKind ConstexprKind, SourceLocation EndLocation, const AssociatedConstraint &TrailingRequiresClause={})
Represents a C++ deduction guide declaration.
static CXXDeductionGuideDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation StartLoc, ExplicitSpecifier ES, const DeclarationNameInfo &NameInfo, QualType T, TypeSourceInfo *TInfo, SourceLocation EndLocation, CXXConstructorDecl *Ctor=nullptr, DeductionCandidate Kind=DeductionCandidate::Normal, const AssociatedConstraint &TrailingRequiresClause={}, const CXXDeductionGuideDecl *SourceDG=nullptr, SourceDeductionGuideKind SK=SourceDeductionGuideKind::None)
Represents a C++ destructor within a class.
static CXXDestructorDecl * Create(ASTContext &C, CXXRecordDecl *RD, SourceLocation StartLoc, const DeclarationNameInfo &NameInfo, QualType T, TypeSourceInfo *TInfo, bool UsesFPIntrin, bool isInline, bool isImplicitlyDeclared, ConstexprSpecKind ConstexprKind, const AssociatedConstraint &TrailingRequiresClause={})
Represents a static or instance method of a struct/union/class.
static CXXMethodDecl * Create(ASTContext &C, CXXRecordDecl *RD, SourceLocation StartLoc, const DeclarationNameInfo &NameInfo, QualType T, TypeSourceInfo *TInfo, StorageClass SC, bool UsesFPIntrin, bool isInline, ConstexprSpecKind ConstexprKind, SourceLocation EndLocation, const AssociatedConstraint &TrailingRequiresClause={})
Represents a C++ struct/union/class.
static CXXRecordDecl * Create(const ASTContext &C, TagKind TK, DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, IdentifierInfo *Id, CXXRecordDecl *PrevDecl=nullptr)
bool isGenericLambda() const
Determine whether this class describes a generic lambda function object (i.e.
unsigned getLambdaDependencyKind() const
const FunctionDecl * isLocalClass() const
If the class is a local class [class.local], returns the enclosing function declaration.
bool isLambda() const
Determine whether this class describes a lambda function object.
CXXRecordDecl * getDefinition() const
static CXXRecordDecl * CreateLambda(const ASTContext &C, DeclContext *DC, TypeSourceInfo *Info, SourceLocation Loc, unsigned DependencyKind, bool IsGeneric, LambdaCaptureDefault CaptureDefault)
TemplateSpecializationKind getTemplateSpecializationKind() const
Determine whether this particular class is a specialization or instantiation of a class template or m...
TypeSourceInfo * getLambdaTypeInfo() const
void setInstantiationOfMemberClass(CXXRecordDecl *RD, TemplateSpecializationKind TSK)
Specify that this record is an instantiation of the member class RD.
bool isInjectedClassName() const
Determines whether this declaration represents the injected class name.
LambdaCaptureDefault getLambdaCaptureDefault() const
void setDescribedClassTemplate(ClassTemplateDecl *Template)
CXXRecordDecl * getCanonicalDecl() override
Retrieves the "canonical" declaration of the given declaration.
Represents a C++ nested-name-specifier or a global scope specifier.
void Adopt(NestedNameSpecifierLoc Other)
Adopt an existing nested-name-specifier (with source-range information).
Declaration of a class template.
void AddPartialSpecialization(ClassTemplatePartialSpecializationDecl *D, void *InsertPos)
Insert the specified partial specialization knowing that it is not already in.
ClassTemplateDecl * getMostRecentDecl()
CXXRecordDecl * getTemplatedDecl() const
Get the underlying class declarations of the template.
llvm::FoldingSetVector< ClassTemplatePartialSpecializationDecl > & getPartialSpecializations() const
Retrieve the set of partial specializations of this class template.
ClassTemplatePartialSpecializationDecl * findPartialSpecialization(ArrayRef< TemplateArgument > Args, TemplateParameterList *TPL, void *&InsertPos)
Return the partial specialization with the provided arguments if it exists, otherwise return the inse...
static ClassTemplateDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation L, DeclarationName Name, TemplateParameterList *Params, NamedDecl *Decl)
Create a class template node.
ClassTemplateDecl * getCanonicalDecl() override
Retrieves the "canonical" declaration of the given declaration.
ClassTemplatePartialSpecializationDecl * findPartialSpecInstantiatedFromMember(ClassTemplatePartialSpecializationDecl *D)
Find a class template partial specialization which was instantiated from the given member partial spe...
void AddSpecialization(ClassTemplateSpecializationDecl *D, void *InsertPos)
Insert the specified specialization knowing that it is not already in.
void setCommonPtr(Common *C)
Common * getCommonPtr() const
ClassTemplateSpecializationDecl * findSpecialization(ArrayRef< TemplateArgument > Args, void *&InsertPos)
Return the specialization with the provided arguments if it exists, otherwise return the insertion po...
void setInstantiatedFromMember(ClassTemplatePartialSpecializationDecl *PartialSpec)
static ClassTemplatePartialSpecializationDecl * Create(ASTContext &Context, TagKind TK, DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, TemplateParameterList *Params, ClassTemplateDecl *SpecializedTemplate, ArrayRef< TemplateArgument > Args, CanQualType CanonInjectedTST, ClassTemplatePartialSpecializationDecl *PrevDecl)
TemplateParameterList * getTemplateParameters() const
Get the list of template parameters.
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.
const ASTTemplateArgumentListInfo * getTemplateArgsAsWritten() const
Retrieve the template argument list as written in the sources, if any.
ClassTemplateDecl * getSpecializedTemplate() const
Retrieve the template that this specialization specializes.
static ClassTemplateSpecializationDecl * Create(ASTContext &Context, TagKind TK, DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, ClassTemplateDecl *SpecializedTemplate, ArrayRef< TemplateArgument > Args, bool StrictPackMatch, ClassTemplateSpecializationDecl *PrevDecl)
SourceLocation getPointOfInstantiation() const
Get the point of instantiation (if any), or null if none.
void setExternKeywordLoc(SourceLocation Loc)
Sets the location of the extern keyword.
void setSpecializationKind(TemplateSpecializationKind TSK)
SourceLocation getExternKeywordLoc() const
Gets the location of the extern keyword, if present.
SourceLocation getTemplateKeywordLoc() const
Gets the location of the template keyword, if present.
void setTemplateKeywordLoc(SourceLocation Loc)
Sets the location of the template keyword.
void setTemplateArgsAsWritten(const ASTTemplateArgumentListInfo *ArgsWritten)
Set the template argument list as written in the sources.
Declaration of a C++20 concept.
const TypeClass * getTypePtr() const
Represents a shadow constructor declaration introduced into a class by a C++11 using-declaration that...
A POD class for pairing a NamedDecl* with an access specifier.
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...
DeclContext * getParent()
getParent - Returns the containing DeclContext.
bool Equals(const DeclContext *DC) const
Determine whether this declaration context is equivalent to the declaration context DC.
bool isFileContext() const
void makeDeclVisibleInContext(NamedDecl *D)
Makes a declaration visible within this context.
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.
DeclContext * getRedeclContext()
getRedeclContext - Retrieve the context in which an entity conflicts with other entities of the same ...
void addDecl(Decl *D)
Add the declaration D into this context.
decl_iterator decls_end() const
ddiag_range ddiags() const
decl_range decls() const
decls_begin/decls_end - Iterate over the declarations stored in this context.
bool isFunctionOrMethod() const
void addHiddenDecl(Decl *D)
Add the declaration D to this context without modifying any lookup tables.
decl_iterator decls_begin() const
static DeclRefExpr * Create(const ASTContext &Context, NestedNameSpecifierLoc QualifierLoc, SourceLocation TemplateKWLoc, ValueDecl *D, bool RefersToEnclosingVariableOrCapture, SourceLocation NameLoc, QualType T, ExprValueKind VK, NamedDecl *FoundD=nullptr, const TemplateArgumentListInfo *TemplateArgs=nullptr, NonOdrUseReason NOUR=NOUR_None)
Decl - This represents one declaration (or definition), e.g.
Decl * getPreviousDecl()
Retrieve the previous declaration that declares the same entity as this declaration,...
SourceLocation getEndLoc() const LLVM_READONLY
FriendObjectKind getFriendObjectKind() const
Determines whether this declaration is the object of a friend declaration and, if so,...
bool isImplicit() const
isImplicit - Indicates whether the declaration was implicitly generated by the implementation.
void setLocalExternDecl()
Changes the namespace of this declaration to reflect that it's a function-local extern declaration.
virtual bool isOutOfLine() const
Determine whether this declaration is declared out of line (outside its semantic context).
void setInvalidDecl(bool Invalid=true)
setInvalidDecl - Indicates the Decl had a semantic error.
bool isInIdentifierNamespace(unsigned NS) const
@ FOK_None
Not a friend object.
bool isReferenced() const
Whether any declaration of this entity was referenced.
unsigned getTemplateDepth() const
Determine the number of levels of template parameter surrounding this declaration.
void setObjectOfFriendDecl(bool PerformFriendInjection=false)
Changes the namespace of this declaration to reflect that it's the object of a friend declaration.
bool isFromASTFile() const
Determine whether this declaration came from an AST file (such as a precompiled header or module) rat...
bool isInLocalScopeForInstantiation() const
Determine whether a substitution into this declaration would occur as part of a substitution into a d...
DeclContext * getNonTransparentDeclContext()
Return the non transparent context.
bool isInvalidDecl() const
bool isLocalExternDecl() const
Determine whether this is a block-scope declaration with linkage.
llvm::iterator_range< specific_attr_iterator< T > > specific_attrs() const
void setAccess(AccessSpecifier AS)
SourceLocation getLocation() const
const char * getDeclKindName() const
@ IDNS_Ordinary
Ordinary names.
void setImplicit(bool I=true)
void setReferenced(bool R=true)
void setIsUsed()
Set whether the declaration is used, in the sense of odr-use.
bool isUsed(bool CheckUsedAttr=true) const
Whether any (re-)declaration of the entity was used, meaning that a definition is required.
DeclContext * getDeclContext()
AccessSpecifier getAccess() const
SourceLocation getBeginLoc() const LLVM_READONLY
DeclContext * getLexicalDeclContext()
getLexicalDeclContext - The declaration context where this Decl was lexically declared (LexicalDC).
void setNonMemberOperator()
Specifies that this declaration is a C++ overloaded non-member.
void setLexicalDeclContext(DeclContext *DC)
void setVisibleDespiteOwningModule()
Set that this declaration is globally visible, even if it came from a module that is not visible.
DeclarationNameLoc - Additional source/type location info for a declaration name.
static DeclarationNameLoc makeNamedTypeLoc(TypeSourceInfo *TInfo)
Construct location information for a constructor, destructor or conversion operator.
The name of a declaration.
@ CXXConversionFunctionName
NameKind getNameKind() const
Determine what kind of name this is.
Represents a ValueDecl that came out of a declarator.
SourceLocation getInnerLocStart() const
Return start of source range ignoring outer template declarations.
TemplateParameterList * getTemplateParameterList(unsigned index) const
SourceLocation getTypeSpecStartLoc() const
SourceLocation getBeginLoc() const LLVM_READONLY
const AssociatedConstraint & getTrailingRequiresClause() const
Get the constraint-expression introduced by the trailing requires-clause in the function/member decla...
unsigned getNumTemplateParameterLists() const
void setTypeSourceInfo(TypeSourceInfo *TI)
NestedNameSpecifierLoc getQualifierLoc() const
Retrieve the nested-name-specifier (with source-location information) that qualifies the name of this...
TypeSourceInfo * getTypeSourceInfo() const
A decomposition declaration.
ArrayRef< BindingDecl * > bindings() const
static DecompositionDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation StartLoc, SourceLocation LSquareLoc, QualType T, TypeSourceInfo *TInfo, StorageClass S, ArrayRef< BindingDecl * > Bindings)
Provides information about a dependent function-template specialization declaration.
RAII object that enters a new function expression evaluation context.
RAII object that enters a new expression evaluation context.
An instance of this object exists for each enum constant that is defined.
enumerator_range enumerators() const
bool isScoped() const
Returns true if this is a C++11 scoped enumeration.
bool isScopedUsingClassTag() const
Returns true if this is a C++11 scoped enumeration.
static EnumDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, IdentifierInfo *Id, EnumDecl *PrevDecl, bool IsScoped, bool IsScopedUsingClassTag, bool IsFixed)
TypeSourceInfo * getIntegerTypeSourceInfo() const
Return the type source info for the underlying integer type, if no type source info exists,...
bool isFixed() const
Returns true if this is an Objective-C, C++11, or Microsoft-style enumeration with a fixed underlying...
EnumDecl * getCanonicalDecl() override
Retrieves the "canonical" declaration of the given declaration.
QualType getIntegerType() const
Return the integer type this enum decl corresponds to.
EnumDecl * getDefinition() const
TemplateSpecializationKind getTemplateSpecializationKind() const
If this enumeration is a member of a specialization of a templated class, determine what kind of temp...
Store information needed for an explicit specifier.
ExplicitSpecKind getKind() const
bool isInvalid() const
Determine if the explicit specifier is invalid.
static ExplicitSpecifier Invalid()
const Expr * getExpr() const
static ExplicitSpecifier getFromDecl(FunctionDecl *Function)
This represents one expression.
static bool isPotentialConstantExprUnevaluated(Expr *E, const FunctionDecl *FD, SmallVectorImpl< PartialDiagnosticAt > &Diags)
isPotentialConstantExprUnevaluated - Return true if this expression might be usable in a constant exp...
bool isValueDependent() const
Determines whether the value of this expression depends on.
std::optional< llvm::APSInt > getIntegerConstantExpr(const ASTContext &Ctx) const
isIntegerConstantExpr - Return the value if this expression is a valid integer constant expression.
bool isConstantInitializer(ASTContext &Ctx, bool ForRef, const Expr **Culprit=nullptr) const
isConstantInitializer - Returns true if this expression can be emitted to IR as a constant,...
SourceLocation getExprLoc() const LLVM_READONLY
getExprLoc - Return the preferred location for the arrow when diagnosing a problem with a generic exp...
Declaration context for names declared as extern "C" in C++.
Abstract interface for external sources of AST nodes.
Represents difference between two FPOptions values.
Represents a member of a struct/union/class.
bool isMutable() const
Determines whether this field is mutable (C++ only).
InClassInitStyle getInClassInitStyle() const
Get the kind of (C++11) default member initializer that this field has.
Expr * getBitWidth() const
Returns the expression that represents the bit width, if this field is a bit field.
FriendDecl - Represents the declaration of a friend entity, which can be a function,...
bool isUnsupportedFriend() const
Determines if this friend kind is unsupported.
static FriendDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation L, FriendUnion Friend_, SourceLocation FriendL, SourceLocation EllipsisLoc={}, ArrayRef< TemplateParameterList * > FriendTypeTPLists={})
SourceLocation getFriendLoc() const
Retrieves the location of the 'friend' keyword.
void setUnsupportedFriend(bool Unsupported)
SourceRange getSourceRange() const override LLVM_READONLY
Retrieves the source range for the friend declaration.
SourceLocation getEllipsisLoc() const
Retrieves the location of the '...', if present.
NamedDecl * getFriendDecl() const
If this friend declaration doesn't name a type, return the inner declaration.
TypeSourceInfo * getFriendType() const
If this friend declaration names an (untemplated but possibly dependent) type, return the type; other...
bool isPackExpansion() const
Declaration of a friend template.
static DefaultedOrDeletedFunctionInfo * Create(ASTContext &Context, ArrayRef< DeclAccessPair > Lookups, StringLiteral *DeletedMessage=nullptr)
Represents a function declaration or definition.
void setInstantiationIsPending(bool IC)
State that the instantiation of this function is pending.
static FunctionDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation StartLoc, SourceLocation NLoc, DeclarationName N, QualType T, TypeSourceInfo *TInfo, StorageClass SC, bool UsesFPIntrin=false, bool isInlineSpecified=false, bool hasWrittenPrototype=true, ConstexprSpecKind ConstexprKind=ConstexprSpecKind::Unspecified, const AssociatedConstraint &TrailingRequiresClause={})
const ParmVarDecl * getParamDecl(unsigned i) const
Stmt * getBody(const FunctionDecl *&Definition) const
Retrieve the body (definition) of the function.
ConstexprSpecKind getConstexprKind() const
DefaultedOrDeletedFunctionInfo * getDefaultedOrDeletedInfo() const
FunctionTemplateDecl * getDescribedFunctionTemplate() const
Retrieves the function template that is described by this function declaration.
bool isThisDeclarationADefinition() const
Returns whether this specific declaration of the function is also a definition that does not contain ...
bool isDestroyingOperatorDelete() const
Determine whether this is a destroying operator delete.
StringLiteral * getDeletedMessage() const
Get the message that indicates why this function was deleted.
bool isInlined() const
Determine whether this function should be inlined, because it is either marked "inline" or "constexpr...
bool UsesFPIntrin() const
Determine whether the function was declared in source context that requires constrained FP intrinsics...
QualType getReturnType() const
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...
bool isExplicitlyDefaulted() const
Whether this function is explicitly defaulted.
bool hasWrittenPrototype() const
Whether this function has a written prototype.
FunctionDecl * getCanonicalDecl() override
Retrieves the "canonical" declaration of the given declaration.
DependentFunctionTemplateSpecializationInfo * getDependentSpecializationInfo() const
bool isDeleted() const
Whether this function has been deleted.
StorageClass getStorageClass() const
Returns the storage class as written in the source.
bool isOutOfLine() const override
Determine whether this is or was instantiated from an out-of-line definition of a member function.
bool FriendConstraintRefersToEnclosingTemplate() const
bool isDeletedAsWritten() const
bool isPureVirtual() const
Whether this virtual function is pure, i.e.
bool isLateTemplateParsed() const
Whether this templated function will be late parsed.
bool hasSkippedBody() const
True if the function was a definition but its body was skipped.
FunctionDecl * getDefinition()
Get the definition for this declaration.
bool isTypeAwareOperatorNewOrDelete() const
Determine whether this is a type aware operator new or delete.
bool isThisDeclarationInstantiatedFromAFriendDefinition() const
Determine whether this specific declaration of the function is a friend declaration that was instanti...
bool isDefaulted() const
Whether this function is defaulted.
SourceRange getSourceRange() const override LLVM_READONLY
Source range that this declaration covers.
bool isVirtualAsWritten() const
Whether this function is marked as virtual explicitly.
unsigned getNumParams() const
Return the number of parameters this function must have based on its FunctionType.
DeclarationNameInfo getNameInfo() const
bool hasBody(const FunctionDecl *&Definition) const
Returns true if the function has a body.
bool isDefined(const FunctionDecl *&Definition, bool CheckForPendingFriendDefinition=false) const
Returns true if the function has a definition that does not need to be instantiated.
FunctionDecl * getPreviousDecl()
Return the previous declaration of this declaration or NULL if this is the first declaration.
bool isInlineSpecified() const
Determine whether the "inline" keyword was specified for this function.
bool willHaveBody() const
True if this function will eventually have a body, once it's fully parsed.
const ASTTemplateArgumentListInfo * getTemplateSpecializationArgsAsWritten() const
Retrieve the template argument list as written in the sources, if any.
Represents a prototype with parameter type info, e.g.
ExceptionSpecificationType getExceptionSpecType() const
Get the kind of exception specification on this function.
QualType getParamType(unsigned i) const
bool hasExceptionSpec() const
Return whether this function has any kind of exception spec.
ExtProtoInfo getExtProtoInfo() const
FunctionDecl * getExceptionSpecTemplate() const
If this function type has an uninstantiated exception specification, this is the function whose excep...
ArrayRef< QualType > getParamTypes() const
Declaration of a template function.
FunctionTemplateDecl * getCanonicalDecl() override
Retrieves the "canonical" declaration of the given declaration.
FunctionDecl * getTemplatedDecl() const
Get the underlying function declaration of the template.
FunctionTemplateDecl * getInstantiatedFromMemberTemplate() const
void setInstantiatedFromMemberTemplate(FunctionTemplateDecl *D)
static FunctionTemplateDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation L, DeclarationName Name, TemplateParameterList *Params, NamedDecl *Decl)
Create a function template node.
ParmVarDecl * getParam(unsigned i) const
void setParam(unsigned i, ParmVarDecl *VD)
ExtInfo getExtInfo() const
bool getNoReturnAttr() const
Determine whether this function type includes the GNU noreturn attribute.
QualType getReturnType() const
HLSLBufferDecl - Represent a cbuffer or tbuffer declaration.
One of these records is kept for each identifier that is lexed.
bool isStr(const char(&Str)[StrLen]) const
Return true if this is the identifier for the specified string.
Represents a field injected from an anonymous union/struct into the parent scope.
unsigned getChainingSize() const
static IndirectFieldDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation L, const IdentifierInfo *Id, QualType T, MutableArrayRef< NamedDecl * > CH)
ArrayRef< NamedDecl * > chain() const
Description of a constructor that was inherited from a base class.
const TypeClass * getTypePtr() const
static IntegerLiteral * Create(const ASTContext &C, const llvm::APInt &V, QualType type, SourceLocation l)
Returns a new integer literal with value 'V' and type 'type'.
Represents the declaration of a label.
static LabelDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation IdentL, IdentifierInfo *II)
A stack-allocated class that identifies which local variable declaration instantiations are present i...
SmallVector< ValueDecl *, 4 > DeclArgumentPack
A set of declarations.
void InstantiatedLocal(const Decl *D, Decl *Inst)
void InstantiatedLocalPackArg(const Decl *D, VarDecl *Inst)
void MakeInstantiatedLocalArgPack(const Decl *D)
Represents the results of name lookup.
An instance of this class represents the declaration of a property member.
static MSPropertyDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation L, DeclarationName N, QualType T, TypeSourceInfo *TInfo, SourceLocation StartL, IdentifierInfo *Getter, IdentifierInfo *Setter)
IdentifierInfo * getGetterId() const
IdentifierInfo * getSetterId() const
Provides information a specialization of a member of a class template, which may be a member function...
Data structure that captures multiple levels of template argument lists for use in template instantia...
const ArgList & getInnermost() const
Retrieve the innermost template argument list.
void addOuterTemplateArguments(Decl *AssociatedDecl, ArgList Args, bool Final)
Add a new outmost level to the multi-level template argument list.
void setKind(TemplateSubstitutionKind K)
void addOuterRetainedLevels(unsigned Num)
unsigned getNumRetainedOuterLevels() const
This represents a decl that may have a name.
IdentifierInfo * getIdentifier() const
Get the identifier that names this declaration, if there is one.
DeclarationName getDeclName() const
Get the actual, stored name of the declaration, which may be a special name.
bool hasLinkage() const
Determine whether this declaration has linkage.
bool isCXXClassMember() const
Determine whether this declaration is a C++ class member.
Represents a C++ namespace alias.
NestedNameSpecifierLoc getQualifierLoc() const
Retrieve the nested-name-specifier that qualifies the name of the namespace, with source-location inf...
SourceLocation getAliasLoc() const
Returns the location of the alias name, i.e.
static NamespaceAliasDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation NamespaceLoc, SourceLocation AliasLoc, IdentifierInfo *Alias, NestedNameSpecifierLoc QualifierLoc, SourceLocation IdentLoc, NamespaceBaseDecl *Namespace)
SourceLocation getNamespaceLoc() const
Returns the location of the namespace keyword.
SourceLocation getTargetNameLoc() const
Returns the location of the identifier in the named namespace.
NamespaceDecl * getNamespace()
Retrieve the namespace declaration aliased by this directive.
Represent a C++ namespace.
A C++ nested-name-specifier augmented with source location information.
SourceRange getSourceRange() const LLVM_READONLY
Retrieve the source range covering the entirety of this nested-name-specifier.
bool hasQualifier() const
Evaluates true when this nested-name-specifier location is non-empty.
NonTypeTemplateParmDecl - Declares a non-type template parameter, e.g., "Size" in.
bool isPackExpansion() const
Whether this parameter pack is a pack expansion.
bool hasDefaultArgument() const
Determine whether this template parameter has a default argument.
unsigned getPosition() const
Get the position of the template parameter within its parameter list.
bool defaultArgumentWasInherited() const
Determines whether the default argument was inherited from a previous declaration of this template.
TypeSourceInfo * getExpansionTypeSourceInfo(unsigned I) const
Retrieve a particular expansion type source info within an expanded parameter pack.
unsigned getNumExpansionTypes() const
Retrieves the number of expansion types in an expanded parameter pack.
const TemplateArgumentLoc & getDefaultArgument() const
Retrieve the default argument, if any.
bool isExpandedParameterPack() const
Whether this parameter is a non-type template parameter pack that has a known list of different types...
static NonTypeTemplateParmDecl * Create(const ASTContext &C, DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, unsigned D, unsigned P, const IdentifierInfo *Id, QualType T, bool ParameterPack, TypeSourceInfo *TInfo)
bool isParameterPack() const
Whether this parameter is a non-type template parameter pack.
unsigned getDepth() const
Get the nesting depth of the template parameter.
Expr * getPlaceholderTypeConstraint() const
Return the constraint introduced by the placeholder type of this non-type template parameter (if any)...
void setDefaultArgument(const ASTContext &C, const TemplateArgumentLoc &DefArg)
Set the default argument for this template parameter, and whether that default argument was inherited...
This represents 'pragma omp allocate ...' directive.
clauselist_range clauselists()
Pseudo declaration for capturing expressions.
This represents 'pragma omp declare mapper ...' directive.
OMPDeclareMapperDecl * getPrevDeclInScope()
Get reference to previous declare mapper construct in the same scope with the same name.
clauselist_iterator clauselist_begin()
clauselist_range clauselists()
DeclarationName getVarName()
Get the name of the variable declared in the mapper.
Expr * getMapperVarRef()
Get the variable declared in the mapper.
This represents 'pragma omp declare reduction ...' directive.
Expr * getInitializer()
Get initializer expression (if specified) of the declare reduction construct.
Expr * getInitPriv()
Get Priv variable of the initializer.
Expr * getCombinerOut()
Get Out variable of the combiner.
Expr * getCombinerIn()
Get In variable of the combiner.
Expr * getCombiner()
Get combiner expression of the declare reduction construct.
OMPDeclareReductionDecl * getPrevDeclInScope()
Get reference to previous declare reduction construct in the same scope with the same name.
Expr * getInitOrig()
Get Orig variable of the initializer.
OMPDeclareReductionInitKind getInitializerKind() const
Get initializer kind.
This represents 'pragma omp groupprivate ...' directive.
This represents 'pragma omp requires...' directive.
This represents 'pragma omp threadprivate ...' directive.
Helper data structure representing the traits in a match clause of an declare variant or metadirectiv...
bool anyScoreOrCondition(llvm::function_ref< bool(Expr *&, bool)> Cond)
Represents a field declaration created by an @defs(...).
static OpaquePtr make(QualType P)
static OpenACCBindClause * Create(const ASTContext &C, SourceLocation BeginLoc, SourceLocation LParenLoc, const IdentifierInfo *ID, SourceLocation EndLoc)
OpenACCDirectiveKind getDirectiveKind() const
ArrayRef< const OpenACCClause * > clauses() const
SourceLocation getDirectiveLoc() const
static OpenACCCopyClause * Create(const ASTContext &C, OpenACCClauseKind Spelling, SourceLocation BeginLoc, SourceLocation LParenLoc, OpenACCModifierKind Mods, ArrayRef< Expr * > VarList, SourceLocation EndLoc)
static OpenACCCopyInClause * Create(const ASTContext &C, OpenACCClauseKind Spelling, SourceLocation BeginLoc, SourceLocation LParenLoc, OpenACCModifierKind Mods, ArrayRef< Expr * > VarList, SourceLocation EndLoc)
static OpenACCCopyOutClause * Create(const ASTContext &C, OpenACCClauseKind Spelling, SourceLocation BeginLoc, SourceLocation LParenLoc, OpenACCModifierKind Mods, ArrayRef< Expr * > VarList, SourceLocation EndLoc)
static OpenACCCreateClause * Create(const ASTContext &C, OpenACCClauseKind Spelling, SourceLocation BeginLoc, SourceLocation LParenLoc, OpenACCModifierKind Mods, ArrayRef< Expr * > VarList, SourceLocation EndLoc)
static OpenACCDevicePtrClause * Create(const ASTContext &C, SourceLocation BeginLoc, SourceLocation LParenLoc, ArrayRef< Expr * > VarList, SourceLocation EndLoc)
static OpenACCDeviceResidentClause * Create(const ASTContext &C, SourceLocation BeginLoc, SourceLocation LParenLoc, ArrayRef< Expr * > VarList, SourceLocation EndLoc)
A 'device_type' or 'dtype' clause, takes a list of either an 'asterisk' or an identifier.
static OpenACCDeviceTypeClause * Create(const ASTContext &C, OpenACCClauseKind K, SourceLocation BeginLoc, SourceLocation LParenLoc, ArrayRef< DeviceTypeArgument > Archs, SourceLocation EndLoc)
static OpenACCLinkClause * Create(const ASTContext &C, SourceLocation BeginLoc, SourceLocation LParenLoc, ArrayRef< Expr * > VarList, SourceLocation EndLoc)
static OpenACCNoHostClause * Create(const ASTContext &Ctx, SourceLocation BeginLoc, SourceLocation EndLoc)
static OpenACCPresentClause * Create(const ASTContext &C, SourceLocation BeginLoc, SourceLocation LParenLoc, ArrayRef< Expr * > VarList, SourceLocation EndLoc)
SourceLocation getRParenLoc() const
const Expr * getFunctionReference() const
SourceLocation getLParenLoc() const
static OpenACCSeqClause * Create(const ASTContext &Ctx, SourceLocation BeginLoc, SourceLocation EndLoc)
static OpenACCVectorClause * Create(const ASTContext &Ctx, SourceLocation BeginLoc, SourceLocation LParenLoc, Expr *IntExpr, SourceLocation EndLoc)
static OpenACCWorkerClause * Create(const ASTContext &Ctx, SourceLocation BeginLoc, SourceLocation LParenLoc, Expr *IntExpr, SourceLocation EndLoc)
SourceLocation getEllipsisLoc() const
TypeLoc getPatternLoc() const
Represents a parameter to a function.
Represents a #pragma detect_mismatch line.
PrettyDeclStackTraceEntry - If a crash occurs in the parser while parsing something related to a decl...
A (possibly-)qualified type.
bool isRestrictQualified() const
Determine whether this type is restrict-qualified.
bool isNull() const
Return true if this QualType doesn't point to a type yet.
QualType getNonReferenceType() const
If Type is a reference type (e.g., const int&), returns the type that the reference refers to ("const...
QualType getAtomicUnqualifiedType() const
Remove all qualifiers including _Atomic.
The collection of all-type qualifiers we support.
Represents a struct/union/class.
bool isAnonymousStructOrUnion() const
Whether this is an anonymous struct or union.
Wrapper for source info for record types.
Declaration of a redeclarable template.
void setInstantiatedFromMemberTemplate(RedeclarableTemplateDecl *TD)
decl_type * getFirstDecl()
Return the first declaration of this declaration or itself if this is the only declaration.
void setPreviousDecl(decl_type *PrevDecl)
Set the previous declaration.
Represents the body of a requires-expression.
static RequiresExprBodyDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation StartLoc)
Scope - A scope is a transient data structure that is used while parsing the program.
void addAMDGPUFlatWorkGroupSizeAttr(Decl *D, const AttributeCommonInfo &CI, Expr *Min, Expr *Max)
addAMDGPUFlatWorkGroupSizeAttr - Adds an amdgpu_flat_work_group_size attribute to a particular declar...
void addAMDGPUWavesPerEUAttr(Decl *D, const AttributeCommonInfo &CI, Expr *Min, Expr *Max)
addAMDGPUWavePersEUAttr - Adds an amdgpu_waves_per_eu attribute to a particular declaration.
void addAMDGPUMaxNumWorkGroupsAttr(Decl *D, const AttributeCommonInfo &CI, Expr *XExpr, Expr *YExpr, Expr *ZExpr)
addAMDGPUMaxNumWorkGroupsAttr - Adds an amdgpu_max_num_work_groups attribute to a particular declarat...
SemaDiagnosticBuilder Diag(SourceLocation Loc, unsigned DiagID)
Emit a diagnostic.
void checkAllowedInitializer(VarDecl *VD)
QualType getInoutParameterType(QualType Ty)
bool inferObjCARCLifetime(ValueDecl *decl)
void AddXConsumedAttr(Decl *D, const AttributeCommonInfo &CI, Sema::RetainOwnershipKind K, bool IsTemplateInstantiation)
A type to represent all the data for an OpenACC Clause that has been parsed, but not yet created/sema...
OpenACCDirectiveKind getDirectiveKind() const
OpenACCClauseKind getClauseKind() const
void ActOnOpenMPDeclareVariantDirective(FunctionDecl *FD, Expr *VariantRef, OMPTraitInfo &TI, ArrayRef< Expr * > AdjustArgsNothing, ArrayRef< Expr * > AdjustArgsNeedDevicePtr, ArrayRef< Expr * > AdjustArgsNeedDeviceAddr, ArrayRef< OMPInteropInfo > AppendArgs, SourceLocation AdjustArgsLoc, SourceLocation AppendArgsLoc, SourceRange SR)
Called on well-formed '#pragma omp declare variant' after parsing of the associated method/function.
std::optional< std::pair< FunctionDecl *, Expr * > > checkOpenMPDeclareVariantFunction(DeclGroupPtrTy DG, Expr *VariantRef, OMPTraitInfo &TI, unsigned NumAppendArgs, SourceRange SR)
Checks '#pragma omp declare variant' variant function and original functions after parsing of the ass...
DeclGroupPtrTy ActOnOpenMPDeclareSimdDirective(DeclGroupPtrTy DG, OMPDeclareSimdDeclAttr::BranchStateTy BS, Expr *Simdlen, ArrayRef< Expr * > Uniforms, ArrayRef< Expr * > Aligneds, ArrayRef< Expr * > Alignments, ArrayRef< Expr * > Linears, ArrayRef< unsigned > LinModifiers, ArrayRef< Expr * > Steps, SourceRange SR)
Called on well-formed '#pragma omp declare simd' after parsing of the associated method/function.
void AddParameterABIAttr(Decl *D, const AttributeCommonInfo &CI, ParameterABI abi)
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...
CXXSpecialMemberKind asSpecialMember() const
A helper class for building up ExtParameterInfos.
Records and restores the CurFPFeatures state on entry/exit of compound statements.
RAII class used to indicate that we are performing provisional semantic analysis to determine the val...
Sema - This implements semantic analysis and AST building for C.
MemInitResult BuildDelegatingInitializer(TypeSourceInfo *TInfo, Expr *Init, CXXRecordDecl *ClassDecl)
SmallVector< CodeSynthesisContext, 16 > CodeSynthesisContexts
List of active code synthesis contexts.
LocalInstantiationScope * CurrentInstantiationScope
The current instantiation scope used to store local variables.
TemplateArgumentLoc getTrivialTemplateArgumentLoc(const TemplateArgument &Arg, QualType NTTPType, SourceLocation Loc, NamedDecl *TemplateParam=nullptr)
Allocate a TemplateArgumentLoc where all locations have been initialized to the given location.
bool CheckUsingDeclQualifier(SourceLocation UsingLoc, bool HasTypename, const CXXScopeSpec &SS, const DeclarationNameInfo &NameInfo, SourceLocation NameLoc, const LookupResult *R=nullptr, const UsingDecl *UD=nullptr)
Checks that the given nested-name qualifier used in a using decl in the current context is appropriat...
DefaultedFunctionKind getDefaultedFunctionKind(const FunctionDecl *FD)
Determine the kind of defaulting that would be done for a given function.
@ LookupOrdinaryName
Ordinary name lookup, which finds ordinary names (functions, variables, typedefs, etc....
@ LookupUsingDeclName
Look up all declarations in a scope with the given name, including resolved using declarations.
@ LookupRedeclarationWithLinkage
Look up an ordinary name that is going to be redeclared as a name with linkage.
Decl * ActOnSkippedFunctionBody(Decl *Decl)
NamedDecl * FindInstantiatedDecl(SourceLocation Loc, NamedDecl *D, const MultiLevelTemplateArgumentList &TemplateArgs, bool FindingInstantiatedContext=false)
Find the instantiation of the given declaration within the current instantiation.
Definition SemaTemplateInstantiateDecl.cpp:6879
MemInitResult BuildBaseInitializer(QualType BaseType, TypeSourceInfo *BaseTInfo, Expr *Init, CXXRecordDecl *ClassDecl, SourceLocation EllipsisLoc)
bool InstantiateDefaultArgument(SourceLocation CallLoc, FunctionDecl *FD, ParmVarDecl *Param)
Definition SemaTemplateInstantiateDecl.cpp:5279
void AddAlignedAttr(Decl *D, const AttributeCommonInfo &CI, Expr *E, bool IsPackExpansion)
AddAlignedAttr - Adds an aligned attribute to a particular declaration.
const TranslationUnitKind TUKind
The kind of translation unit we are processing.
void InstantiateExceptionSpec(SourceLocation PointOfInstantiation, FunctionDecl *Function)
Definition SemaTemplateInstantiateDecl.cpp:5327
void AddAssumeAlignedAttr(Decl *D, const AttributeCommonInfo &CI, Expr *E, Expr *OE)
AddAssumeAlignedAttr - Adds an assume_aligned attribute to a particular declaration.
const ExpressionEvaluationContextRecord & currentEvaluationContext() const
void deduceOpenCLAddressSpace(ValueDecl *decl)
PragmaStack< FPOptionsOverride > FpPragmaStack
FunctionDecl * InstantiateFunctionDeclaration(FunctionTemplateDecl *FTD, const TemplateArgumentList *Args, SourceLocation Loc, CodeSynthesisContext::SynthesisKind CSC=CodeSynthesisContext::ExplicitTemplateArgumentSubstitution)
Instantiate (or find existing instantiation of) a function template with a given set of template argu...
Definition SemaTemplateInstantiateDecl.cpp:5517
bool tryResolveExplicitSpecifier(ExplicitSpecifier &ExplicitSpec)
tryResolveExplicitSpecifier - Attempt to resolve the explict specifier.
ExprResult SubstInitializer(Expr *E, const MultiLevelTemplateArgumentList &TemplateArgs, bool CXXDirectInit)
MemInitResult BuildMemberInitializer(ValueDecl *Member, Expr *Init, SourceLocation IdLoc)
VarTemplateSpecializationDecl * BuildVarTemplateInstantiation(VarTemplateDecl *VarTemplate, VarDecl *FromVar, const TemplateArgumentList *PartialSpecArgs, SmallVectorImpl< TemplateArgument > &Converted, SourceLocation PointOfInstantiation, LateInstantiatedAttrVec *LateAttrs=nullptr, LocalInstantiationScope *StartingScope=nullptr)
Definition SemaTemplateInstantiateDecl.cpp:5994
Decl * ActOnFinishFunctionBody(Decl *Decl, Stmt *Body, bool IsInstantiation=false, bool RetainFunctionScopeInfo=false)
Performs semantic analysis at the end of a function body.
void SubstExceptionSpec(FunctionDecl *New, const FunctionProtoType *Proto, const MultiLevelTemplateArgumentList &Args)
ExpressionEvaluationContextRecord & parentEvaluationContext()
LateParsedTemplateMapT LateParsedTemplateMap
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)
ExprResult SubstExpr(Expr *E, const MultiLevelTemplateArgumentList &TemplateArgs)
DiagnosticsEngine & getDiagnostics() const
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...
DeclGroupPtrTy ConvertDeclToDeclGroup(Decl *Ptr, Decl *OwnedType=nullptr)
void InstantiateMemInitializers(CXXConstructorDecl *New, const CXXConstructorDecl *Tmpl, const MultiLevelTemplateArgumentList &TemplateArgs)
Definition SemaTemplateInstantiateDecl.cpp:6510
void CleanupVarDeclMarking()
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.
Definition SemaTemplateInstantiateDecl.cpp:6276
SmallVector< LateInstantiatedAttribute, 1 > LateInstantiatedAttrVec
PrintingPolicy getPrintingPolicy() const
Retrieve a suitable printing policy for diagnostics.
void HandleDependentAccessCheck(const DependentDiagnostic &DD, const MultiLevelTemplateArgumentList &TemplateArgs)
@ TPL_TemplateMatch
We are matching the template parameter lists of two templates that might be redeclarations.
void SetDeclDefaulted(Decl *dcl, SourceLocation DefaultLoc)
NamedReturnInfo getNamedReturnInfo(Expr *&E, SimplerImplicitMoveMode Mode=SimplerImplicitMoveMode::Normal)
Determine whether the given expression might be move-eligible or copy-elidable in either a (co_)retur...
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)
Definition SemaTemplateInstantiateDecl.cpp:854
const LangOptions & getLangOpts() const
void AddModeAttr(Decl *D, const AttributeCommonInfo &CI, IdentifierInfo *Name, bool InInstantiation=false)
AddModeAttr - Adds a mode attribute to a particular declaration.
void collectUnexpandedParameterPacks(TemplateArgument Arg, SmallVectorImpl< UnexpandedParameterPack > &Unexpanded)
Collect the set of unexpanded parameter packs within the given template argument.
const LangOptions & LangOpts
Decl * ActOnStartOfFunctionDef(Scope *S, Declarator &D, MultiTemplateParamsArg TemplateParamLists, SkipBodyInfo *SkipBody=nullptr, FnBodyKind BodyKind=FnBodyKind::Other)
VarTemplateSpecializationDecl * CompleteVarTemplateSpecializationDecl(VarTemplateSpecializationDecl *VarSpec, VarDecl *PatternDecl, const MultiLevelTemplateArgumentList &TemplateArgs)
Instantiates a variable template specialization by completing it with appropriate type information an...
Definition SemaTemplateInstantiateDecl.cpp:6043
void updateAttrsForLateParsedTemplate(const Decl *Pattern, Decl *Inst)
Update instantiation attributes after template was late parsed.
Definition SemaTemplateInstantiateDecl.cpp:1057
void InstantiateVariableInitializer(VarDecl *Var, VarDecl *OldVar, const MultiLevelTemplateArgumentList &TemplateArgs)
Instantiate the initializer of a variable.
Definition SemaTemplateInstantiateDecl.cpp:6201
SmallVector< PendingImplicitInstantiation, 1 > LateParsedInstantiations
Queue of implicit template instantiations that cannot be performed eagerly.
DeclarationNameInfo SubstDeclarationNameInfo(const DeclarationNameInfo &NameInfo, const MultiLevelTemplateArgumentList &TemplateArgs)
Do template substitution on declaration name info.
const VarDecl * getCopyElisionCandidate(NamedReturnInfo &Info, QualType ReturnType)
Updates given NamedReturnInfo's move-eligible and copy-elidable statuses, considering the function re...
void AddAllocAlignAttr(Decl *D, const AttributeCommonInfo &CI, Expr *ParamExpr)
AddAllocAlignAttr - Adds an alloc_align attribute to a particular declaration.
UnsignedOrNone getNumArgumentsInExpansion(QualType T, const MultiLevelTemplateArgumentList &TemplateArgs)
Determine the number of arguments in the given pack expansion type.
bool usesPartialOrExplicitSpecialization(SourceLocation Loc, ClassTemplateSpecializationDecl *ClassTemplateSpec)
ExplicitSpecifier instantiateExplicitSpecifier(const MultiLevelTemplateArgumentList &TemplateArgs, ExplicitSpecifier ES)
Definition SemaTemplateInstantiateDecl.cpp:636
bool CheckVariableDeclaration(VarDecl *NewVD, LookupResult &Previous)
Perform semantic checking on a newly-created variable declaration.
sema::BlockScopeInfo * getCurBlock()
Retrieve the current block, if any.
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...
ExprResult PerformContextuallyConvertToBool(Expr *From)
PerformContextuallyConvertToBool - Perform a contextual conversion of the expression From to bool (C+...
SourceManager & getSourceManager() const
FunctionDecl * SubstSpaceshipAsEqualEqual(CXXRecordDecl *RD, FunctionDecl *Spaceship)
Substitute the name and return type of a defaulted 'operator<=>' to form an implicit 'operator=='.
Definition SemaTemplateInstantiateDecl.cpp:4777
void PerformPendingInstantiations(bool LocalOnly=false, bool AtEndOfTU=true)
Performs template instantiation for all implicit template instantiations we have seen until this poin...
Definition SemaTemplateInstantiateDecl.cpp:7191
Decl * SubstDecl(Decl *D, DeclContext *Owner, const MultiLevelTemplateArgumentList &TemplateArgs)
Definition SemaTemplateInstantiateDecl.cpp:4732
void ActOnMemInitializers(Decl *ConstructorDecl, SourceLocation ColonLoc, ArrayRef< CXXCtorInitializer * > MemInits, bool AnyErrors)
ActOnMemInitializers - Handle the member initializers for a constructor.
TemplateParameterList * SubstTemplateParams(TemplateParameterList *Params, DeclContext *Owner, const MultiLevelTemplateArgumentList &TemplateArgs, bool EvaluateConstraints=true)
Definition SemaTemplateInstantiateDecl.cpp:4849
void AddLaunchBoundsAttr(Decl *D, const AttributeCommonInfo &CI, Expr *MaxThreads, Expr *MinBlocks, Expr *MaxBlocks)
AddLaunchBoundsAttr - Adds a launch_bounds attribute to a particular declaration.
UnsignedOrNone ArgPackSubstIndex
The current index into pack expansion arguments that will be used for substitution of parameter packs...
void InstantiateDefaultCtorDefaultArgs(CXXConstructorDecl *Ctor)
In the MS ABI, we need to instantiate default arguments of dllexported default constructors along wit...
Definition SemaTemplateInstantiateDecl.cpp:1067
QualType CheckTemplateIdType(ElaboratedTypeKeyword Keyword, TemplateName Template, SourceLocation TemplateLoc, TemplateArgumentListInfo &TemplateArgs, Scope *Scope, bool ForNestedNameSpecifier)
RedeclarationKind forRedeclarationInCurContext() const
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.
Definition SemaTemplateInstantiateDecl.cpp:5533
bool CheckUsingDeclRedeclaration(SourceLocation UsingLoc, bool HasTypenameKeyword, const CXXScopeSpec &SS, SourceLocation NameLoc, const LookupResult &Previous)
Checks that the given using declaration is not an invalid redeclaration.
bool SubstDefaultArgument(SourceLocation Loc, ParmVarDecl *Param, const MultiLevelTemplateArgumentList &TemplateArgs, bool ForCallExpr=false)
Substitute the given template arguments into the default argument.
void InstantiateAttrsForDecl(const MultiLevelTemplateArgumentList &TemplateArgs, const Decl *Pattern, Decl *Inst, LateInstantiatedAttrVec *LateAttrs=nullptr, LocalInstantiationScope *OuterMostScope=nullptr)
Definition SemaTemplateInstantiateDecl.cpp:809
IntrusiveRefCntPtr< ExternalSemaSource > ExternalSource
Source of additional semantic information.
sema::AnalysisBasedWarnings AnalysisWarnings
Worker object for performing CFG-based warnings.
bool hasUncompilableErrorOccurred() const
Whether uncompilable error has occurred.
std::deque< PendingImplicitInstantiation > PendingInstantiations
The queue of implicit template instantiations that are required but have not yet been performed.
bool CheckInheritingConstructorUsingDecl(UsingDecl *UD)
Additional checks for a using declaration referring to a constructor name.
void addClusterDimsAttr(Decl *D, const AttributeCommonInfo &CI, Expr *X, Expr *Y, Expr *Z)
@ 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...
@ Unevaluated
The current expression and its subexpressions occur within an unevaluated operand (C++11 [expr]p7),...
NestedNameSpecifierLoc SubstNestedNameSpecifierLoc(NestedNameSpecifierLoc NNS, const MultiLevelTemplateArgumentList &TemplateArgs)
bool RequireCompleteType(SourceLocation Loc, QualType T, CompleteTypeKind Kind, TypeDiagnoser &Diagnoser)
Ensure that the type T is a complete type.
LateTemplateParserCB * LateTemplateParser
bool LookupQualifiedName(LookupResult &R, DeclContext *LookupCtx, bool InUnqualifiedLookup=false)
Perform qualified name lookup into a given context.
SmallVector< ExpressionEvaluationContextRecord, 8 > ExprEvalContexts
A stack of expression evaluation contexts.
bool DiagnoseUninstantiableTemplate(SourceLocation PointOfInstantiation, NamedDecl *Instantiation, bool InstantiatedFromMember, const NamedDecl *Pattern, const NamedDecl *PatternDef, TemplateSpecializationKind TSK, bool Complain=true, bool *Unreachable=nullptr)
Determine whether we would be unable to instantiate this template (because it either has no definitio...
SourceManager & SourceMgr
bool CheckAlignasTypeArgument(StringRef KWName, TypeSourceInfo *TInfo, SourceLocation OpLoc, SourceRange R)
static bool adjustContextForLocalExternDecl(DeclContext *&DC)
Adjust the DeclContext for a function or variable that might be a function-local external declaration...
Attr * CreateAnnotationAttr(const AttributeCommonInfo &CI, StringRef Annot, MutableArrayRef< Expr * > Args)
CreateAnnotationAttr - Creates an annotation Annot with Args arguments.
@ TPC_FriendFunctionTemplate
@ TPC_FriendFunctionTemplateDefinition
void DiagnoseUnusedDecl(const NamedDecl *ND)
void ActOnUninitializedDecl(Decl *dcl)
void AddInitializerToDecl(Decl *dcl, Expr *init, bool DirectInit)
AddInitializerToDecl - Adds the initializer Init to the declaration dcl.
void runWithSufficientStackSpace(SourceLocation Loc, llvm::function_ref< void()> Fn)
Run some code with "sufficient" stack space.
bool CheckSpanLikeType(const AttributeCommonInfo &CI, const QualType &Ty)
Check that the type is a plain record with one field being a pointer type and the other field being a...
void BuildVariableInstantiation(VarDecl *NewVar, VarDecl *OldVar, const MultiLevelTemplateArgumentList &TemplateArgs, LateInstantiatedAttrVec *LateAttrs, DeclContext *Owner, LocalInstantiationScope *StartingScope, bool InstantiatingVarTemplate=false, VarTemplateSpecializationDecl *PrevVTSD=nullptr)
BuildVariableInstantiation - Used after a new variable has been created.
Definition SemaTemplateInstantiateDecl.cpp:6071
void UpdateExceptionSpec(FunctionDecl *FD, const FunctionProtoType::ExceptionSpecInfo &ESI)
std::pair< ValueDecl *, SourceLocation > PendingImplicitInstantiation
An entity for which implicit template instantiation is required.
DeclContext * FindInstantiatedContext(SourceLocation Loc, DeclContext *DC, const MultiLevelTemplateArgumentList &TemplateArgs)
Finds the instantiation of the given declaration context within the current instantiation.
Definition SemaTemplateInstantiateDecl.cpp:6857
void AddAlignValueAttr(Decl *D, const AttributeCommonInfo &CI, Expr *E)
AddAlignValueAttr - Adds an align_value attribute to a particular declaration.
ArrayRef< sema::FunctionScopeInfo * > getFunctionScopes() const
void PerformDependentDiagnostics(const DeclContext *Pattern, const MultiLevelTemplateArgumentList &TemplateArgs)
Definition SemaTemplateInstantiateDecl.cpp:7283
OpaquePtr< DeclGroupRef > DeclGroupPtrTy
bool checkStringLiteralArgumentAttr(const AttributeCommonInfo &CI, const Expr *E, StringRef &Str, SourceLocation *ArgLocation=nullptr)
Check if the argument E is a ASCII string literal.
bool CheckCXXDefaultArgExpr(SourceLocation CallLoc, FunctionDecl *FD, ParmVarDecl *Param, Expr *Init=nullptr, bool SkipImmediateInvocations=true)
Instantiate or parse a C++ default argument expression as necessary.
ASTMutationListener * getASTMutationListener() const
ExprResult ActOnFinishFullExpr(Expr *Expr, bool DiscardedValue)
Encodes a location in the source.
A trivial tuple used to represent a source range.
SourceLocation getEnd() const
Represents a C++11 static_assert declaration.
SourceLocation getRParenLoc() const
Stmt - This represents one statement.
SourceLocation getEndLoc() const LLVM_READONLY
SourceLocation getBeginLoc() const LLVM_READONLY
Represents the declaration of a struct/union/class/enum.
bool isThisDeclarationADefinition() const
Return true if this declaration is a completion definition of the type.
bool isCompleteDefinition() const
Return true if this decl has its body fully specified.
NestedNameSpecifierLoc getQualifierLoc() const
Retrieve the nested-name-specifier (with source-location information) that qualifies the name of this...
TypedefNameDecl * getTypedefNameForAnonDecl() const
void setTypedefNameForAnonDecl(TypedefNameDecl *TDD)
void setQualifierInfo(NestedNameSpecifierLoc QualifierLoc)
bool hasNameForLinkage() const
Is this tag type named, either directly or via being defined in a typedef of this type?
TagKind getTagKind() const
SourceLocation getNameLoc() const
void setQualifierLoc(NestedNameSpecifierLoc QualifierLoc)
void setNameLoc(SourceLocation Loc)
void setElaboratedKeywordLoc(SourceLocation Loc)
A convenient class for passing around template argument information.
void setLAngleLoc(SourceLocation Loc)
void setRAngleLoc(SourceLocation Loc)
void addArgument(const TemplateArgumentLoc &Loc)
A template argument list.
static TemplateArgumentList * CreateCopy(ASTContext &Context, ArrayRef< TemplateArgument > Args)
Create a new template argument list that copies the given set of template arguments.
ArrayRef< TemplateArgument > asArray() const
Produce this as an array ref.
Location wrapper for a TemplateArgument.
const TemplateArgument & getArgument() const
SourceLocation getTemplateNameLoc() const
SourceLocation getTemplateKWLoc() const
NestedNameSpecifierLoc getTemplateQualifierLoc() const
Represents a template argument.
TemplateName getAsTemplate() const
Retrieve the template name for a template name argument.
@ Pack
The template argument is actually a parameter pack.
@ RewriteSpaceshipAsEqualEqual
void setEvaluateConstraints(bool B)
Decl * VisitDecl(Decl *D)
Definition SemaTemplateInstantiateDecl.cpp:4728
VarTemplateSpecializationDecl * VisitVarTemplateSpecializationDecl(VarTemplateDecl *VarTemplate, VarDecl *FromVar, ArrayRef< TemplateArgument > Converted, VarTemplateSpecializationDecl *PrevDecl=nullptr)
Definition SemaTemplateInstantiateDecl.cpp:4601
Decl * VisitVarDecl(VarDecl *D, bool InstantiatingVarTemplate, ArrayRef< BindingDecl * > *Bindings=nullptr)
Definition SemaTemplateInstantiateDecl.cpp:1737
bool InitMethodInstantiation(CXXMethodDecl *New, CXXMethodDecl *Tmpl)
Initializes common fields of an instantiated method declaration (New) from the corresponding fields o...
Definition SemaTemplateInstantiateDecl.cpp:5473
bool InitFunctionInstantiation(FunctionDecl *New, FunctionDecl *Tmpl)
Initializes the common fields of an instantiation function declaration (New) from the corresponding f...
Definition SemaTemplateInstantiateDecl.cpp:5388
VarTemplatePartialSpecializationDecl * InstantiateVarTemplatePartialSpecialization(VarTemplateDecl *VarTemplate, VarTemplatePartialSpecializationDecl *PartialSpec)
Instantiate the declaration of a variable template partial specialization.
Definition SemaTemplateInstantiateDecl.cpp:4979
void adjustForRewrite(RewriteKind RK, FunctionDecl *Orig, QualType &T, TypeSourceInfo *&TInfo, DeclarationNameInfo &NameInfo)
Definition SemaTemplateInstantiateDecl.cpp:4745
TypeSourceInfo * SubstFunctionType(FunctionDecl *D, SmallVectorImpl< ParmVarDecl * > &Params)
Definition SemaTemplateInstantiateDecl.cpp:5091
void InstantiateEnumDefinition(EnumDecl *Enum, EnumDecl *Pattern)
Definition SemaTemplateInstantiateDecl.cpp:2199
Decl * VisitFunctionDecl(FunctionDecl *D, TemplateParameterList *TemplateParams, RewriteKind RK=RewriteKind::None)
Normal class members are of more specific types and therefore don't make it here.
Definition SemaTemplateInstantiateDecl.cpp:2705
Decl * VisitCXXMethodDecl(CXXMethodDecl *D, TemplateParameterList *TemplateParams, RewriteKind RK=RewriteKind::None)
Definition SemaTemplateInstantiateDecl.cpp:3091
Decl * InstantiateTypeAliasTemplateDecl(TypeAliasTemplateDecl *D)
Definition SemaTemplateInstantiateDecl.cpp:1626
Decl * VisitBaseUsingDecls(BaseUsingDecl *D, BaseUsingDecl *Inst, LookupResult *Lookup)
Definition SemaTemplateInstantiateDecl.cpp:3913
bool SubstQualifier(const DeclaratorDecl *OldDecl, DeclaratorDecl *NewDecl)
Definition SemaTemplateInstantiateDecl.cpp:78
TemplateParameterList * SubstTemplateParams(TemplateParameterList *List)
Instantiates a nested template parameter list in the current instantiation context.
Definition SemaTemplateInstantiateDecl.cpp:4821
Decl * InstantiateTypedefNameDecl(TypedefNameDecl *D, bool IsTypeAlias)
Definition SemaTemplateInstantiateDecl.cpp:1530
ClassTemplatePartialSpecializationDecl * InstantiateClassTemplatePartialSpecialization(ClassTemplateDecl *ClassTemplate, ClassTemplatePartialSpecializationDecl *PartialSpec)
Instantiate the declaration of a class template partial specialization.
Definition SemaTemplateInstantiateDecl.cpp:4869
bool SubstDefaultedFunction(FunctionDecl *New, FunctionDecl *Tmpl)
Definition SemaTemplateInstantiateDecl.cpp:5489
The base class of all kinds of template declarations (e.g., class, function, etc.).
TemplateParameterList * getTemplateParameters() const
Get the list of template parameters.
bool isNull() const
Determine whether this template name is NULL.
A template parameter object.
Stores a list of template parameters for a TemplateDecl and its derived classes.
SourceRange getSourceRange() const LLVM_READONLY
static TemplateParameterList * Create(const ASTContext &C, SourceLocation TemplateLoc, SourceLocation LAngleLoc, ArrayRef< NamedDecl * > Params, SourceLocation RAngleLoc, Expr *RequiresClause)
Expr * getRequiresClause()
The constraint-expression of the associated requires-clause.
SourceLocation getRAngleLoc() const
SourceLocation getLAngleLoc() const
ArrayRef< NamedDecl * > asArray()
SourceLocation getTemplateLoc() const
TemplateTemplateParmDecl - Declares a template template parameter, e.g., "T" in.
bool wasDeclaredWithTypename() const
Whether this template template parameter was declared with the 'typename' keyword.
TemplateParameterList * getExpansionTemplateParameters(unsigned I) const
Retrieve a particular expansion type within an expanded parameter pack.
bool isPackExpansion() const
Whether this parameter pack is a pack expansion.
unsigned getNumExpansionTemplateParameters() const
Retrieves the number of expansion template parameters in an expanded parameter pack.
TemplateNameKind templateParameterKind() const
const TemplateArgumentLoc & getDefaultArgument() const
Retrieve the default argument, if any.
unsigned getPosition() const
Get the position of the template parameter within its parameter list.
static TemplateTemplateParmDecl * Create(const ASTContext &C, DeclContext *DC, SourceLocation L, unsigned D, unsigned P, bool ParameterPack, IdentifierInfo *Id, TemplateNameKind ParameterKind, bool Typename, TemplateParameterList *Params)
bool isParameterPack() const
Whether this template template parameter is a template parameter pack.
bool defaultArgumentWasInherited() const
Determines whether the default argument was inherited from a previous declaration of this template.
void setDefaultArgument(const ASTContext &C, const TemplateArgumentLoc &DefArg)
Set the default argument for this template parameter, and whether that default argument was inherited...
unsigned getDepth() const
Get the nesting depth of the template parameter.
bool isExpandedParameterPack() const
Whether this parameter is a template template parameter pack that has a known list of different templ...
bool hasDefaultArgument() const
Determine whether this template parameter has a default argument.
Declaration of a template type parameter.
bool wasDeclaredWithTypename() const
Whether this template type parameter was declared with the 'typename' keyword.
const TemplateArgumentLoc & getDefaultArgument() const
Retrieve the default argument, if any.
unsigned getIndex() const
Retrieve the index of the template parameter.
bool hasTypeConstraint() const
Determine whether this template parameter has a type-constraint.
const TypeConstraint * getTypeConstraint() const
Returns the type constraint associated with this template parameter (if any).
UnsignedOrNone getNumExpansionParameters() const
Whether this parameter is a template type parameter pack that has a known list of different type-cons...
bool hasDefaultArgument() const
Determine whether this template parameter has a default argument.
bool defaultArgumentWasInherited() const
Determines whether the default argument was inherited from a previous declaration of this template.
bool isParameterPack() const
Returns whether this is a parameter pack.
static TemplateTypeParmDecl * Create(const ASTContext &C, DeclContext *DC, SourceLocation KeyLoc, SourceLocation NameLoc, unsigned D, unsigned P, IdentifierInfo *Id, bool Typename, bool ParameterPack, bool HasTypeConstraint=false, UnsignedOrNone NumExpanded=std::nullopt)
unsigned getDepth() const
Retrieve the depth of the template parameter.
void setDefaultArgument(const ASTContext &C, const TemplateArgumentLoc &DefArg)
Set the default argument for this template parameter.
bool isPackExpansion() const
Whether this parameter pack is a pack expansion.
The top declaration context.
A semantic tree transformation that allows one to transform one abstract syntax tree into another.
Represents the declaration of a typedef-name via a C++11 alias-declaration.
static TypeAliasDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, const IdentifierInfo *Id, TypeSourceInfo *TInfo)
void setDescribedAliasTemplate(TypeAliasTemplateDecl *TAT)
Declaration of an alias template.
static TypeAliasTemplateDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation L, DeclarationName Name, TemplateParameterList *Params, NamedDecl *Decl)
Create a function template node.
TypeAliasDecl * getTemplatedDecl() const
Get the underlying function declaration of the template.
const Type * getTypeForDecl() const
SourceLocation getBeginLoc() const LLVM_READONLY
TyLocType push(QualType T)
Pushes space for a new TypeLoc of the given type.
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.
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.
AutoTypeLoc getContainedAutoTypeLoc() const
Get the typeloc of an AutoType whose type will be deduced for a variable with an initializer of this ...
T getAsAdjusted() const
Convert to the specified TypeLoc type, returning a null TypeLoc if this TypeLoc is not of the desired...
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.
The base class of the type hierarchy.
bool isRValueReferenceType() const
const T * castAs() const
Member-template castAs.
bool isReferenceType() const
AutoType * getContainedAutoType() const
Get the AutoType whose type will be deduced for a variable with an initializer of this type.
bool isInstantiationDependentType() const
Determine whether this type is an instantiation-dependent type, meaning that the type involves a temp...
bool isLValueReferenceType() const
bool isDependentType() const
Whether this type is a dependent type, meaning that its definition somehow depends on a template para...
bool containsUnexpandedParameterPack() const
Whether this type is or contains an unexpanded parameter pack, used to support C++0x variadic templat...
bool isTemplateTypeParmType() const
bool isAtomicType() const
bool isVariablyModifiedType() const
Whether this type is a variably-modified type (C99 6.7.5).
bool isUndeducedType() const
Determine whether this type is an undeduced type, meaning that it somehow involves a C++11 'auto' typ...
bool isFunctionType() const
const T * getAs() const
Member-template getAs'.
Represents the declaration of a typedef-name via the 'typedef' type specifier.
static TypedefDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, const IdentifierInfo *Id, TypeSourceInfo *TInfo)
Base class for declarations which introduce a typedef-name.
TypeSourceInfo * getTypeSourceInfo() const
QualType getUnderlyingType() const
An artificial decl, representing a global anonymous constant value which is uniquified by value withi...
This node is generated when a using-declaration that was annotated with attribute((using_if_exists)) ...
static UnresolvedUsingIfExistsDecl * Create(ASTContext &Ctx, DeclContext *DC, SourceLocation Loc, DeclarationName Name)
Represents a dependent using declaration which was marked with typename.
SourceLocation getTypenameLoc() const
Returns the source location of the 'typename' keyword.
Represents a dependent using declaration which was not marked with typename.
Represents a C++ using-declaration.
bool hasTypename() const
Return true if the using declaration has 'typename'.
NestedNameSpecifierLoc getQualifierLoc() const
Retrieve the nested-name-specifier that qualifies the name, with source-location information.
DeclarationNameInfo getNameInfo() const
static UsingDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation UsingL, NestedNameSpecifierLoc QualifierLoc, const DeclarationNameInfo &NameInfo, bool HasTypenameKeyword)
SourceLocation getUsingLoc() const
Return the source location of the 'using' keyword.
Represents C++ using-directive.
static UsingDirectiveDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation UsingLoc, SourceLocation NamespaceLoc, NestedNameSpecifierLoc QualifierLoc, SourceLocation IdentLoc, NamedDecl *Nominated, DeclContext *CommonAncestor)
NamespaceDecl * getNominatedNamespace()
Returns the namespace nominated by this using-directive.
DeclContext * getCommonAncestor()
Returns the common ancestor context of this using-directive and its nominated namespace.
SourceLocation getNamespaceKeyLocation() const
Returns the location of the namespace keyword.
SourceLocation getIdentLocation() const
Returns the location of this using declaration's identifier.
NestedNameSpecifierLoc getQualifierLoc() const
Retrieve the nested-name-specifier that qualifies the name of the namespace, with source-location inf...
Represents a C++ using-enum-declaration.
SourceLocation getEnumLoc() const
The source location of the 'enum' keyword.
EnumDecl * getEnumDecl() const
TypeSourceInfo * getEnumType() const
static UsingEnumDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation UsingL, SourceLocation EnumL, SourceLocation NameL, TypeSourceInfo *EnumType)
SourceLocation getUsingLoc() const
The source location of the 'using' keyword.
Represents a pack of using declarations that a single using-declarator pack-expanded into.
ArrayRef< NamedDecl * > expansions() const
Get the set of using declarations that this pack expanded into.
Represents a shadow declaration implicitly introduced into a scope by a (resolved) using-declaration ...
void setType(QualType newType)
bool isParameterPack() const
Determine whether this value is actually a function parameter pack, init-capture pack,...
Represents a variable declaration or definition.
VarTemplateDecl * getDescribedVarTemplate() const
Retrieves the variable template that is described by this variable declaration.
void setObjCForDecl(bool FRD)
static VarDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, const IdentifierInfo *Id, QualType T, TypeSourceInfo *TInfo, StorageClass S)
void setCXXForRangeDecl(bool FRD)
bool isConstexpr() const
Whether this variable is (C++11) constexpr.
void setInstantiationOfStaticDataMember(VarDecl *VD, TemplateSpecializationKind TSK)
Specify that this variable is an instantiation of the static data member VD.
TLSKind getTLSKind() const
void setInitStyle(InitializationStyle Style)
VarDecl * getMostRecentDecl()
Returns the most recent (re)declaration of this declaration.
InitializationStyle getInitStyle() const
The style of initialization for this declaration.
void setInitCapture(bool IC)
DefinitionKind isThisDeclarationADefinition(ASTContext &) const
Check whether this declaration is a definition.
bool isOutOfLine() const override
Determine whether this is or was instantiated from an out-of-line definition of a static data member.
VarDecl * getCanonicalDecl() override
Retrieves the "canonical" declaration of the given declaration.
bool isInitCapture() const
Whether this variable is the implicit variable for a lambda init-capture.
@ CallInit
Call-style initialization (C++98)
bool isObjCForDecl() const
Determine whether this variable is a for-loop declaration for a for-in statement in Objective-C.
void setPreviousDeclInSameBlockScope(bool Same)
bool isInlineSpecified() const
bool isStaticDataMember() const
Determines whether this is a static data member.
VarDecl * getTemplateInstantiationPattern() const
Retrieve the variable declaration from which this variable could be instantiated, if it is an instant...
bool isCXXForRangeDecl() const
Determine whether this variable is the for-range-declaration in a C++0x for-range statement.
VarDecl * getDefinition(ASTContext &)
Get the real (not just tentative) definition for this declaration.
bool mightBeUsableInConstantExpressions(const ASTContext &C) const
Determine whether this variable's value might be usable in a constant expression, according to the re...
bool isNRVOVariable() const
Determine whether this local variable can be used with the named return value optimization (NRVO).
void setInlineSpecified()
bool isStaticLocal() const
Returns true if a variable with function scope is a static local variable.
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 setTSCSpec(ThreadStorageClassSpecifier TSC)
void setNRVOVariable(bool NRVO)
bool isInline() const
Whether this variable is (C++1z) inline.
ThreadStorageClassSpecifier getTSCSpec() const
const Expr * getInit() const
void setConstexpr(bool IC)
void setDescribedVarTemplate(VarTemplateDecl *Template)
bool isDirectInit() const
Whether the initializer is a direct-initializer (list or call).
StorageClass getStorageClass() const
Returns the storage class as written in the source.
void setImplicitlyInline()
bool isPreviousDeclInSameBlockScope() const
Whether this local extern variable declaration's previous declaration was declared in the same block ...
VarDecl * getPreviousDecl()
Return the previous declaration of this declaration or NULL if this is the first declaration.
SourceLocation getPointOfInstantiation() const
If this variable is an instantiation of a variable template or a static data member of a class templa...
TemplateSpecializationKind getTemplateSpecializationKindForInstantiation() const
Get the template specialization kind of this variable for the purposes of template instantiation.
TemplateSpecializationKind getTemplateSpecializationKind() const
If this variable is an instantiation of a variable template or a static data member of a class templa...
Declaration of a variable template.
VarDecl * getTemplatedDecl() const
Get the underlying variable declarations of the template.
static VarTemplateDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation L, DeclarationName Name, TemplateParameterList *Params, VarDecl *Decl)
Create a variable template node.
llvm::FoldingSetVector< VarTemplatePartialSpecializationDecl > & getPartialSpecializations() const
Retrieve the set of partial specializations of this class template.
VarTemplateSpecializationDecl * findSpecialization(ArrayRef< TemplateArgument > Args, void *&InsertPos)
Return the specialization with the provided arguments if it exists, otherwise return the insertion po...
VarTemplatePartialSpecializationDecl * findPartialSpecInstantiatedFromMember(VarTemplatePartialSpecializationDecl *D)
Find a variable template partial specialization which was instantiated from the given member partial ...
static VarTemplatePartialSpecializationDecl * Create(ASTContext &Context, DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, TemplateParameterList *Params, VarTemplateDecl *SpecializedTemplate, QualType T, TypeSourceInfo *TInfo, StorageClass S, ArrayRef< TemplateArgument > Args)
TemplateParameterList * getTemplateParameters() const
Get the list of template parameters.
void setInstantiatedFromMember(VarTemplatePartialSpecializationDecl *PartialSpec)
Represents a variable template specialization, which refers to a variable template with a given set o...
SourceLocation getPointOfInstantiation() const
Get the point of instantiation (if any), or null if none.
void setTemplateArgsAsWritten(const ASTTemplateArgumentListInfo *ArgsWritten)
Set the template argument list as written in the sources.
const ASTTemplateArgumentListInfo * getTemplateArgsAsWritten() const
Retrieve the template argument list as written in the sources, if any.
const TemplateArgumentList & getTemplateArgs() const
Retrieve the template arguments of the variable template specialization.
const TemplateArgumentList & getTemplateInstantiationArgs() const
Retrieve the set of template arguments that should be used to instantiate the initializer of the vari...
static VarTemplateSpecializationDecl * Create(ASTContext &Context, DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, VarTemplateDecl *SpecializedTemplate, QualType T, TypeSourceInfo *TInfo, StorageClass S, ArrayRef< TemplateArgument > Args)
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.
void setCompleteDefinition()
Decl * Visit(PTR(Decl) D)
QualType FunctionType
BlockType - The function type of the block, if one was given.
void addCapture(ValueDecl *Var, bool isBlock, bool isByref, bool isNested, SourceLocation Loc, SourceLocation EllipsisLoc, QualType CaptureType, bool Invalid)
Defines the clang::TargetInfo interface.
const internal::VariadicAllOfMatcher< Decl > decl
Matches declarations.
bool NE(InterpState &S, CodePtr OpPC)
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)
The JSON file list parser is used to communicate input to InstallAPI.
CanQual< Type > CanQualType
Represents a canonical, potentially-qualified type.
void atTemplateEnd(TemplateInstantiationCallbackPtrs &Callbacks, const Sema &TheSema, const Sema::CodeSynthesisContext &Inst)
bool isa(CodeGen::Address addr)
void atTemplateBegin(TemplateInstantiationCallbackPtrs &Callbacks, const Sema &TheSema, const Sema::CodeSynthesisContext &Inst)
@ Rewrite
We are substituting template parameters for (typically) other template parameters in order to rewrite...
QualType getFunctionOrMethodResultType(const Decl *D)
@ TemplateName
The identifier is a template name. FIXME: Add an annotation for that.
@ DevicePtr
'deviceptr' clause, allowed on Compute and Combined Constructs, plus 'data' and 'declare'.
@ VectorLength
'vector_length' clause, allowed on 'parallel', 'kernels', 'parallel loop', and 'kernels loop' constru...
@ Async
'async' clause, allowed on Compute, Data, 'update', 'wait', and Combined constructs.
@ Collapse
'collapse' clause, allowed on 'loop' and Combined constructs.
@ DeviceNum
'device_num' clause, allowed on 'init', 'shutdown', and 'set' constructs.
@ DefaultAsync
'default_async' clause, allowed on 'set' construct.
@ Attach
'attach' clause, allowed on Compute and Combined constructs, plus 'data' and 'enter data'.
@ NumGangs
'num_gangs' clause, allowed on 'parallel', 'kernels', parallel loop', and 'kernels loop' constructs.
@ If
'if' clause, allowed on all the Compute Constructs, Data Constructs, Executable Constructs,...
@ UseDevice
'use_device' clause, allowed on 'host_data' construct.
@ NoCreate
'no_create' clause, allowed on allowed on Compute and Combined constructs, plus 'data'.
@ Reduction
'reduction' clause, allowed on Parallel, Serial, Loop, and the combined constructs.
@ Self
'self' clause, allowed on Compute and Combined Constructs, plus 'update'.
@ FirstPrivate
'firstprivate' clause, allowed on 'parallel', 'serial', 'parallel loop', and 'serial loop' constructs...
@ Tile
'tile' clause, allowed on 'loop' and Combined constructs.
@ Independent
'independent' clause, allowed on 'loop' directives.
@ NumWorkers
'num_workers' clause, allowed on 'parallel', 'kernels', parallel loop', and 'kernels loop' constructs...
@ IfPresent
'if_present' clause, allowed on 'host_data' and 'update' directives.
@ Detach
'detach' clause, allowed on the 'exit data' construct.
@ Delete
'delete' clause, allowed on the 'exit data' construct.
@ Finalize
'finalize' clause, allowed on 'exit data' directive.
StorageClass
Storage classes.
bool isGenericLambdaCallOperatorOrStaticInvokerSpecialization(const DeclContext *DC)
@ Property
The type of a property.
@ Result
The result type of a method or function.
ActionResult< CXXCtorInitializer * > MemInitResult
const FunctionProtoType * T
@ Template
We are parsing a template declaration.
@ FunctionTemplate
The name was classified as a function template name.
@ VarTemplate
The name was classified as a variable template name.
@ TU_Prefix
The translation unit is a prefix to a translation unit, and is not complete.
@ VK_PRValue
A pr-value expression (in the C++11 taxonomy) produces a temporary value.
bool declaresSameEntity(const Decl *D1, const Decl *D2)
Determine whether two declarations declare the same entity.
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)
@ None
No keyword precedes the qualified type name.
@ Enum
The "enum" keyword introduces the elaborated-type-specifier.
bool isLambdaMethod(const DeclContext *DC)
ActionResult< Expr * > ExprResult
@ Other
Other implicit parameter.
ExceptionSpecificationType
The various types of exception specifications that exist in C++11.
@ EST_Uninstantiated
not instantiated yet
@ EST_None
no exception specification
@ EST_BasicNoexcept
noexcept
@ EST_Unevaluated
not evaluated yet, for special member function
ActionResult< Stmt * > StmtResult
Represents an explicit template argument list in C++, e.g., the "" in "sort".
SourceLocation RAngleLoc
The source location of the right angle bracket ('>').
SourceLocation LAngleLoc
The source location of the left angle bracket ('<').
ArrayRef< TemplateArgumentLoc > arguments() const
DeclarationNameInfo - A collector data type for bundling together a DeclarationName and the correspon...
DeclarationName getName() const
getName - Returns the embedded declaration name.
void setName(DeclarationName N)
setName - Sets the embedded declaration name.
const DeclarationNameLoc & getInfo() const
TypeSourceInfo * getNamedTypeInfo() const
getNamedTypeInfo - Returns the source type info associated to the name.
Holds information about the various types of exception specification.
FunctionDecl * SourceDecl
The function whose exception specification this is, for EST_Unevaluated and EST_Uninstantiated.
FunctionDecl * SourceTemplate
The function template whose exception specification this is instantiated from, for EST_Uninstantiated...
ExceptionSpecificationType Type
The kind of exception specification this is.
Extra information about a function prototype.
ExceptionSpecInfo ExceptionSpec
FunctionType::ExtInfo ExtInfo
bool StrictPackMatch
Is set to true when, in the context of TTP matching, a pack parameter matches non-pack arguments.
SmallVector< TemplateArgument, 4 > CanonicalConverted
A context in which code is being synthesized (where a source location alone is not sufficient to iden...
SynthesisKind
The kind of template instantiation we are performing.
@ BuildingDeductionGuides
We are building deduction guides for a class.
@ DeducedTemplateArgumentSubstitution
We are substituting template argument determined as part of template argument deduction for either a ...
bool InLifetimeExtendingContext
Whether we are currently in a context in which all temporaries must be lifetime-extended,...
bool RebuildDefaultArgOrDefaultInit
Whether we should rebuild CXXDefaultArgExpr and CXXDefaultInitExpr.
VarDecl * DeclForInitializer
Declaration for initializer if one is currently being parsed.
A stack object to be created when performing template instantiation.
bool isInvalid() const
Determines whether we have exceeded the maximum recursive template instantiations.