35#include "llvm/Support/SaveAndRestore.h"
36#include "llvm/Support/TimeProfiler.h"
52template<
typename DeclT>
55 if (!OldDecl->getQualifierLoc())
58 assert((NewDecl->getFriendObjectKind() ||
59 !OldDecl->getLexicalDeclContext()->isDependentContext()) &&
60 "non-friend with qualified name defined in dependent context");
63 const_cast<DeclContext *
>(NewDecl->getFriendObjectKind()
64 ? NewDecl->getLexicalDeclContext()
65 : OldDecl->getLexicalDeclContext()));
74 NewDecl->setQualifierInfo(NewQualifierLoc);
80 return ::SubstQualifier(SemaRef, OldDecl, NewDecl, TemplateArgs);
85 return ::SubstQualifier(SemaRef, OldDecl, NewDecl, TemplateArgs);
89#include "clang/Sema/AttrTemplateInstantiate.inc"
93 const AlignedAttr *Aligned,
Decl *
New,
bool IsPackExpansion) {
94 if (Aligned->isAlignmentExpr()) {
103 S.
SubstType(Aligned->getAlignmentType(), TemplateArgs,
106 Aligned->getLocation(),
107 Result->getTypeLoc().getSourceRange()))
115 const AlignedAttr *Aligned,
Decl *
New) {
116 if (!Aligned->isPackExpansion()) {
122 if (Aligned->isAlignmentExpr())
128 assert(!Unexpanded.empty() &&
"Pack expansion without parameter packs?");
131 bool Expand =
true, RetainExpansion =
false;
136 Unexpanded, TemplateArgs,
138 Expand, RetainExpansion, NumExpansions))
145 for (
unsigned I = 0; I != *NumExpansions; ++I) {
154 const AssumeAlignedAttr *Aligned,
Decl *
New) {
159 Expr *E, *OE =
nullptr;
165 if (Aligned->getOffset()) {
177 const AlignValueAttr *Aligned,
Decl *
New) {
188 const AllocAlignAttr *Align,
Decl *
New) {
191 llvm::APInt(64, Align->getParamIndex().getSourceIndex()),
204 bool HasDelayedArgs =
Attr->delayedArgs_size();
213 false, TemplateArgs, Args))
216 StringRef Str =
Attr->getAnnotation();
217 if (HasDelayedArgs) {
218 if (Args.size() < 1) {
228 ActualArgs.insert(ActualArgs.begin(), Args.begin() + 1, Args.end());
229 std::swap(Args, ActualArgs);
237template <
typename Attr>
241 Expr *tempInstPriority =
nullptr;
249 tempInstPriority =
Result.get();
250 if (std::optional<llvm::APSInt> CE =
254 if (!CE->isIntN(32)) {
256 <<
toString(*CE, 10,
false) << 32 << 1;
262 New->addAttr(Attr::Create(
C, tempInstPriority, *A));
268 Expr *Cond =
nullptr;
282 Cond = Converted.
get();
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);
300 S, TemplateArgs, EIA, EIA->getCond(), Tmpl,
New);
304 Cond, EIA->getMessage()));
311 S, TemplateArgs, DIA, DIA->getCond(), Tmpl,
New);
316 DIA->getDefaultSeverity(), DIA->getWarningGroup(),
317 DIA->getArgDependent(),
New));
334 Expr *MinBlocks =
nullptr;
335 if (
Attr.getMinBlocks()) {
342 Expr *MaxBlocks =
nullptr;
343 if (
Attr.getMaxBlocks()) {
366 if (
auto *FTD = dyn_cast<FunctionTemplateDecl>(
New))
367 New = FTD->getTemplatedDecl();
369 auto *ThisContext = dyn_cast_or_null<CXXRecordDecl>(FD->getDeclContext());
374 if (
auto *DRE = dyn_cast<DeclRefExpr>(E->IgnoreParenImpCasts()))
375 if (
auto *PVD = dyn_cast<ParmVarDecl>(DRE->getDecl())) {
378 if (FD->getNumParams() > PVD->getFunctionScopeIndex())
379 Local.InstantiatedLocal(
380 PVD, FD->getParamDecl(PVD->getFunctionScopeIndex()));
384 FD->isCXXInstanceMember());
400 if (
auto *E =
Attr.getSimdlen())
403 if (
Attr.uniforms_size() > 0) {
404 for(
auto *E :
Attr.uniforms()) {
408 Uniforms.push_back(Inst.
get());
412 auto AI =
Attr.alignments_begin();
413 for (
auto *E :
Attr.aligneds()) {
417 Aligneds.push_back(Inst.
get());
421 Alignments.push_back(Inst.
get());
425 auto SI =
Attr.steps_begin();
426 for (
auto *E :
Attr.linears()) {
430 Linears.push_back(Inst.
get());
434 Steps.push_back(Inst.
get());
437 LinModifiers.append(
Attr.modifiers_begin(),
Attr.modifiers_end());
440 Uniforms, Aligneds, Alignments, Linears, LinModifiers, Steps,
449 if (
auto *FTD = dyn_cast<FunctionTemplateDecl>(
New))
450 New = FTD->getTemplatedDecl();
452 auto *ThisContext = dyn_cast_or_null<CXXRecordDecl>(FD->getDeclContext());
454 auto &&SubstExpr = [FD, ThisContext, &S, &TemplateArgs](
Expr *E) {
455 if (
auto *DRE = dyn_cast<DeclRefExpr>(E->IgnoreParenImpCasts()))
456 if (
auto *PVD = dyn_cast<ParmVarDecl>(DRE->getDecl())) {
459 if (FD->getNumParams() > PVD->getFunctionScopeIndex())
460 Local.InstantiatedLocal(
461 PVD, FD->getParamDecl(PVD->getFunctionScopeIndex()));
465 FD->isCXXInstanceMember());
471 auto &&Subst = [&SubstExpr, &S](
Expr *E) {
481 if (
Expr *E =
Attr.getVariantFuncRef()) {
486 VariantFuncRef = Subst(E);
492 TI = *
Attr.getTraitInfos();
495 auto SubstScoreOrConditionExpr = [&S, Subst](
Expr *&E,
bool) {
510 Expr *E = VariantFuncRef.
get();
514 std::optional<std::pair<FunctionDecl *, Expr *>> DeclVarData =
522 E = DeclVarData->second;
523 FD = DeclVarData->first;
525 if (
auto *VariantDRE = dyn_cast<DeclRefExpr>(E->IgnoreParenImpCasts())) {
526 if (
auto *VariantFD = dyn_cast<FunctionDecl>(VariantDRE->getDecl())) {
527 if (
auto *VariantFTD = VariantFD->getDescribedFunctionTemplate()) {
528 if (!VariantFTD->isThisDeclarationADefinition())
539 SubstFD->getType(), FD->getType(),
545 New->getLocation(), SubstFD,
true,
547 SubstFD->setInstantiationIsPending(!SubstFD->isDefined());
551 SubstFD->getLocation(),
562 for (
Expr *E :
Attr.adjustArgsNothing()) {
566 NothingExprs.push_back(ER.
get());
568 for (
Expr *E :
Attr.adjustArgsNeedDevicePtr()) {
572 NeedDevicePtrExprs.push_back(ER.
get());
574 for (
Expr *E :
Attr.adjustArgsNeedDeviceAddr()) {
578 NeedDeviceAddrExprs.push_back(ER.
get());
584 Expr *SubstFr =
nullptr;
595 SubstAttrs.push_back(ER.
get());
597 Info.
Prefs.emplace_back(SubstFr, std::move(SubstAttrs));
599 AppendArgs.push_back(Info);
603 FD, E, TI, NothingExprs, NeedDevicePtrExprs, NeedDeviceAddrExprs,
609 const AMDGPUFlatWorkGroupSizeAttr &
Attr,
Decl *
New) {
650 New->addAttr(::new (Context) ReqdWorkGroupSizeAttr(Context,
Attr,
X, Y, Z));
658 Expr *Cond =
nullptr;
666 Cond = SubstResult.
get();
686 Expr *MaxExpr =
nullptr;
687 if (
auto Max =
Attr.getMax()) {
699 const AMDGPUMaxNumWorkGroupsAttr &
Attr,
Decl *
New) {
703 Expr *XExpr =
nullptr;
704 Expr *YExpr =
nullptr;
705 Expr *ZExpr =
nullptr;
707 if (
Attr.getMaxNumWorkGroupsX()) {
713 if (
Attr.getMaxNumWorkGroupsY()) {
719 if (
Attr.getMaxNumWorkGroupsZ()) {
735 auto SubstElt = [&S, &TemplateArgs](
Expr *E) {
736 return E ? S.
SubstExpr(E, TemplateArgs).
get() :
nullptr;
739 Expr *XExpr = SubstElt(
Attr.getX());
740 Expr *YExpr = SubstElt(
Attr.getY());
741 Expr *ZExpr = SubstElt(
Attr.getZ());
761 if (
const auto *PNA = dyn_cast<PreferredNameAttr>(A)) {
764 if (!
T->isDependentType() && !RD->isDependentContext() &&
767 for (
const auto *ExistingPNA : D->
specific_attrs<PreferredNameAttr>())
769 PNA->getTypedefType()))
774 if (
const auto *BA = dyn_cast<BuiltinAttr>(A)) {
776 switch (BA->getID()) {
777 case Builtin::BIforward:
787 case Builtin::BImove:
788 case Builtin::BImove_if_noexcept:
815 <<
Attr <<
"'groupshared'";
827 "out or inout parameter type must be a reference and restrict qualified");
831 const MallocSpanAttr *
Attr,
846 for (
const auto *TmplAttr : Tmpl->
attrs()) {
853 *
this, dyn_cast_or_null<CXXRecordDecl>(ND->getDeclContext()),
857 TmplAttr,
Context, *
this, TemplateArgs);
860 New->addAttr(NewAttr);
868 case clang::attr::CFConsumed:
870 case clang::attr::OSConsumed:
872 case clang::attr::NSConsumed:
875 llvm_unreachable(
"Wrong argument supplied");
882 const OpenACCRoutineDeclAttr *OldAttr,
const Decl *Old,
Decl *
New);
888 for (
const auto *TmplAttr : Tmpl->
attrs()) {
893 const AlignedAttr *Aligned = dyn_cast<AlignedAttr>(TmplAttr);
894 if (Aligned && Aligned->isAlignmentDependent()) {
899 if (
const auto *AssumeAligned = dyn_cast<AssumeAlignedAttr>(TmplAttr)) {
904 if (
const auto *AlignValue = dyn_cast<AlignValueAttr>(TmplAttr)) {
909 if (
const auto *AllocAlign = dyn_cast<AllocAlignAttr>(TmplAttr)) {
914 if (
const auto *Annotate = dyn_cast<AnnotateAttr>(TmplAttr)) {
919 if (
auto *
Constructor = dyn_cast<ConstructorAttr>(TmplAttr)) {
925 if (
auto *
Destructor = dyn_cast<DestructorAttr>(TmplAttr)) {
931 if (
const auto *EnableIf = dyn_cast<EnableIfAttr>(TmplAttr)) {
937 if (
const auto *DiagnoseIf = dyn_cast<DiagnoseIfAttr>(TmplAttr)) {
943 if (
const auto *CUDALaunchBounds =
944 dyn_cast<CUDALaunchBoundsAttr>(TmplAttr)) {
946 *CUDALaunchBounds,
New);
950 if (
const auto *Mode = dyn_cast<ModeAttr>(TmplAttr)) {
955 if (
const auto *OMPAttr = dyn_cast<OMPDeclareSimdDeclAttr>(TmplAttr)) {
960 if (
const auto *OMPAttr = dyn_cast<OMPDeclareVariantAttr>(TmplAttr)) {
965 if (
const auto *ReqdWorkGroupSize =
966 dyn_cast<ReqdWorkGroupSizeAttr>(TmplAttr)) {
968 *ReqdWorkGroupSize,
New);
972 if (
const auto *AMDGPUFlatWorkGroupSize =
973 dyn_cast<AMDGPUFlatWorkGroupSizeAttr>(TmplAttr)) {
975 *
this, TemplateArgs, *AMDGPUFlatWorkGroupSize,
New);
979 if (
const auto *AMDGPUFlatWorkGroupSize =
980 dyn_cast<AMDGPUWavesPerEUAttr>(TmplAttr)) {
982 *AMDGPUFlatWorkGroupSize,
New);
986 if (
const auto *AMDGPUMaxNumWorkGroups =
987 dyn_cast<AMDGPUMaxNumWorkGroupsAttr>(TmplAttr)) {
989 *
this, TemplateArgs, *AMDGPUMaxNumWorkGroups,
New);
993 if (
const auto *CUDAClusterDims = dyn_cast<CUDAClusterDimsAttr>(TmplAttr)) {
995 *CUDAClusterDims,
New);
999 if (
const auto *ParamAttr = dyn_cast<HLSLParamModifierAttr>(TmplAttr)) {
1005 if (
const auto *RoutineAttr = dyn_cast<OpenACCRoutineDeclAttr>(TmplAttr)) {
1007 RoutineAttr, Tmpl,
New);
1012 if (TmplAttr->getKind() == attr::DLLExport ||
1013 TmplAttr->getKind() == attr::DLLImport) {
1014 if (
New->hasAttr<DLLExportAttr>() ||
New->hasAttr<DLLImportAttr>()) {
1019 if (
const auto *ABIAttr = dyn_cast<ParameterABIAttr>(TmplAttr)) {
1032 if (
auto *A = dyn_cast<PointerAttr>(TmplAttr)) {
1033 if (!
New->hasAttr<PointerAttr>())
1038 if (
auto *A = dyn_cast<OwnerAttr>(TmplAttr)) {
1039 if (!
New->hasAttr<OwnerAttr>())
1044 if (
auto *A = dyn_cast<SYCLKernelAttr>(TmplAttr)) {
1049 if (
auto *A = dyn_cast<CUDAGridConstantAttr>(TmplAttr)) {
1050 if (!
New->hasAttr<CUDAGridConstantAttr>())
1055 if (
auto *A = dyn_cast<MallocSpanAttr>(TmplAttr)) {
1060 if (
auto *A = dyn_cast<CleanupAttr>(TmplAttr)) {
1061 if (!
New->hasAttr<CleanupAttr>()) {
1062 auto *NewAttr = A->clone(
Context);
1063 NewAttr->setArgLoc(A->getArgLoc());
1064 New->addAttr(NewAttr);
1069 assert(!TmplAttr->isPackExpansion());
1070 if (TmplAttr->isLateParsed() && LateAttrs) {
1080 auto *ThisContext = dyn_cast_or_null<CXXRecordDecl>(ND->getDeclContext());
1082 ND->isCXXInstanceMember());
1085 *
this, TemplateArgs);
1088 New->addAttr(NewAttr);
1094 for (
const auto *
Attr : Pattern->
attrs()) {
1095 if (
auto *A = dyn_cast<StrictFPAttr>(
Attr)) {
1096 if (!Inst->
hasAttr<StrictFPAttr>())
1107template<
typename DeclT>
1109 DeclT *
Result = D->getPreviousDecl();
1115 D->getLexicalDeclContext() !=
Result->getLexicalDeclContext())
1123 llvm_unreachable(
"Translation units cannot be instantiated");
1127 llvm_unreachable(
"HLSL buffer declarations cannot be instantiated");
1130Decl *TemplateDeclInstantiator::VisitHLSLRootSignatureDecl(
1132 llvm_unreachable(
"HLSL root signature declarations cannot be instantiated");
1137 llvm_unreachable(
"pragma comment cannot be instantiated");
1140Decl *TemplateDeclInstantiator::VisitPragmaDetectMismatchDecl(
1142 llvm_unreachable(
"pragma comment cannot be instantiated");
1147 llvm_unreachable(
"extern \"C\" context cannot be instantiated");
1151 llvm_unreachable(
"GUID declaration cannot be instantiated");
1154Decl *TemplateDeclInstantiator::VisitUnnamedGlobalConstantDecl(
1156 llvm_unreachable(
"UnnamedGlobalConstantDecl cannot be instantiated");
1159Decl *TemplateDeclInstantiator::VisitTemplateParamObjectDecl(
1161 llvm_unreachable(
"template parameter objects cannot be instantiated");
1165TemplateDeclInstantiator::VisitLabelDecl(
LabelDecl *D) {
1168 SemaRef.InstantiateAttrs(TemplateArgs, D, Inst, LateAttrs, StartingScope);
1169 Owner->addDecl(Inst);
1174TemplateDeclInstantiator::VisitNamespaceDecl(
NamespaceDecl *D) {
1175 llvm_unreachable(
"Namespaces cannot be instantiated");
1179class OpenACCDeclClauseInstantiator final
1182 const MultiLevelTemplateArgumentList &MLTAL;
1183 ArrayRef<OpenACCClause *> ExistingClauses;
1184 SemaOpenACC::OpenACCParsedClause &ParsedClause;
1185 OpenACCClause *NewClause =
nullptr;
1188 OpenACCDeclClauseInstantiator(Sema &S,
1189 const MultiLevelTemplateArgumentList &MLTAL,
1190 ArrayRef<OpenACCClause *> ExistingClauses,
1191 SemaOpenACC::OpenACCParsedClause &ParsedClause)
1192 : SemaRef(S), MLTAL(MLTAL), ExistingClauses(ExistingClauses),
1193 ParsedClause(ParsedClause) {}
1195 OpenACCClause *CreatedClause() {
return NewClause; }
1196#define VISIT_CLAUSE(CLAUSE_NAME) \
1197 void Visit##CLAUSE_NAME##Clause(const OpenACC##CLAUSE_NAME##Clause &Clause);
1198#include "clang/Basic/OpenACCClauses.def"
1202 for (
Expr *CurVar : VarList) {
1203 ExprResult Res = SemaRef.SubstExpr(CurVar, MLTAL);
1212 InstantiatedVarList.push_back(Res.
get());
1214 return InstantiatedVarList;
1218#define CLAUSE_NOT_ON_DECLS(CLAUSE_NAME) \
1219 void OpenACCDeclClauseInstantiator::Visit##CLAUSE_NAME##Clause( \
1220 const OpenACC##CLAUSE_NAME##Clause &) { \
1221 llvm_unreachable("Clause type invalid on declaration construct, or " \
1222 "instantiation not implemented"); \
1251#undef CLAUSE_NOT_ON_DECLS
1253void OpenACCDeclClauseInstantiator::VisitGangClause(
1257 assert(
C.getNumExprs() <= 1 &&
1258 "Only 1 expression allowed on gang clause in routine");
1260 if (
C.getNumExprs() > 0) {
1262 "Only dim allowed on routine");
1264 SemaRef.SubstExpr(
const_cast<Expr *
>(
C.getExpr(0).second), MLTAL);
1266 ER = SemaRef.OpenACC().CheckGangExpr(ExistingClauses,
1267 ParsedClause.getDirectiveKind(),
1268 C.getExpr(0).first, ER.
get());
1271 TransformedIntExprs.push_back(ER.
get());
1276 NewClause = SemaRef.OpenACC().CheckGangClause(
1277 ParsedClause.getDirectiveKind(), ExistingClauses,
1278 ParsedClause.getBeginLoc(), ParsedClause.getLParenLoc(),
1279 TransformedGangKinds, TransformedIntExprs, ParsedClause.getEndLoc());
1284 ParsedClause.getBeginLoc(),
1285 ParsedClause.getEndLoc());
1287void OpenACCDeclClauseInstantiator::VisitNoHostClause(
1290 ParsedClause.getBeginLoc(),
1291 ParsedClause.getEndLoc());
1294void OpenACCDeclClauseInstantiator::VisitDeviceTypeClause(
1298 SemaRef.getASTContext(),
C.getClauseKind(), ParsedClause.getBeginLoc(),
1299 ParsedClause.getLParenLoc(),
C.getArchitectures(),
1300 ParsedClause.getEndLoc());
1303void OpenACCDeclClauseInstantiator::VisitWorkerClause(
1305 assert(!
C.hasIntExpr() &&
"Int Expr not allowed on routine 'worker' clause");
1307 ParsedClause.getBeginLoc(), {},
1308 nullptr, ParsedClause.getEndLoc());
1311void OpenACCDeclClauseInstantiator::VisitVectorClause(
1313 assert(!
C.hasIntExpr() &&
"Int Expr not allowed on routine 'vector' clause");
1315 ParsedClause.getBeginLoc(), {},
1316 nullptr, ParsedClause.getEndLoc());
1319void OpenACCDeclClauseInstantiator::VisitCopyClause(
1321 ParsedClause.setVarListDetails(VisitVarList(
C.getVarList()),
1322 C.getModifierList());
1323 if (SemaRef.OpenACC().CheckDeclareClause(ParsedClause,
C.getModifierList()))
1326 SemaRef.getASTContext(), ParsedClause.getClauseKind(),
1327 ParsedClause.getBeginLoc(), ParsedClause.getLParenLoc(),
1328 ParsedClause.getModifierList(), ParsedClause.getVarList(),
1329 ParsedClause.getEndLoc());
1332void OpenACCDeclClauseInstantiator::VisitLinkClause(
1334 ParsedClause.setVarListDetails(
1335 SemaRef.OpenACC().CheckLinkClauseVarList(VisitVarList(
C.getVarList())),
1338 if (SemaRef.OpenACC().CheckDeclareClause(ParsedClause,
1343 SemaRef.getASTContext(), ParsedClause.getBeginLoc(),
1344 ParsedClause.getLParenLoc(), ParsedClause.getVarList(),
1345 ParsedClause.getEndLoc());
1348void OpenACCDeclClauseInstantiator::VisitDeviceResidentClause(
1350 ParsedClause.setVarListDetails(VisitVarList(
C.getVarList()),
1352 if (SemaRef.OpenACC().CheckDeclareClause(ParsedClause,
1356 SemaRef.getASTContext(), ParsedClause.getBeginLoc(),
1357 ParsedClause.getLParenLoc(), ParsedClause.getVarList(),
1358 ParsedClause.getEndLoc());
1361void OpenACCDeclClauseInstantiator::VisitCopyInClause(
1363 ParsedClause.setVarListDetails(VisitVarList(
C.getVarList()),
1364 C.getModifierList());
1366 if (SemaRef.OpenACC().CheckDeclareClause(ParsedClause,
C.getModifierList()))
1369 SemaRef.getASTContext(), ParsedClause.getClauseKind(),
1370 ParsedClause.getBeginLoc(), ParsedClause.getLParenLoc(),
1371 ParsedClause.getModifierList(), ParsedClause.getVarList(),
1372 ParsedClause.getEndLoc());
1374void OpenACCDeclClauseInstantiator::VisitCopyOutClause(
1376 ParsedClause.setVarListDetails(VisitVarList(
C.getVarList()),
1377 C.getModifierList());
1379 if (SemaRef.OpenACC().CheckDeclareClause(ParsedClause,
C.getModifierList()))
1382 SemaRef.getASTContext(), ParsedClause.getClauseKind(),
1383 ParsedClause.getBeginLoc(), ParsedClause.getLParenLoc(),
1384 ParsedClause.getModifierList(), ParsedClause.getVarList(),
1385 ParsedClause.getEndLoc());
1387void OpenACCDeclClauseInstantiator::VisitCreateClause(
1389 ParsedClause.setVarListDetails(VisitVarList(
C.getVarList()),
1390 C.getModifierList());
1392 if (SemaRef.OpenACC().CheckDeclareClause(ParsedClause,
C.getModifierList()))
1395 SemaRef.getASTContext(), ParsedClause.getClauseKind(),
1396 ParsedClause.getBeginLoc(), ParsedClause.getLParenLoc(),
1397 ParsedClause.getModifierList(), ParsedClause.getVarList(),
1398 ParsedClause.getEndLoc());
1400void OpenACCDeclClauseInstantiator::VisitPresentClause(
1402 ParsedClause.setVarListDetails(VisitVarList(
C.getVarList()),
1404 if (SemaRef.OpenACC().CheckDeclareClause(ParsedClause,
1408 SemaRef.getASTContext(), ParsedClause.getBeginLoc(),
1409 ParsedClause.getLParenLoc(), ParsedClause.getVarList(),
1410 ParsedClause.getEndLoc());
1412void OpenACCDeclClauseInstantiator::VisitDevicePtrClause(
1416 llvm::erase_if(VarList, [&](
Expr *E) {
1421 if (SemaRef.OpenACC().CheckDeclareClause(ParsedClause,
1425 SemaRef.getASTContext(), ParsedClause.getBeginLoc(),
1426 ParsedClause.getLParenLoc(), ParsedClause.getVarList(),
1427 ParsedClause.getEndLoc());
1430void OpenACCDeclClauseInstantiator::VisitBindClause(
1433 if (
C.isStringArgument())
1435 SemaRef.getASTContext(), ParsedClause.getBeginLoc(),
1436 ParsedClause.getLParenLoc(),
C.getStringArgument(),
1437 ParsedClause.getEndLoc());
1440 SemaRef.getASTContext(), ParsedClause.getBeginLoc(),
1441 ParsedClause.getLParenLoc(),
C.getIdentifierArgument(),
1442 ParsedClause.getEndLoc());
1450 for (
const auto *Clause : ClauseList) {
1452 Clause->getBeginLoc());
1453 ParsedClause.setEndLoc(Clause->getEndLoc());
1454 if (
const auto *WithParms = dyn_cast<OpenACCClauseWithParams>(Clause))
1455 ParsedClause.setLParenLoc(WithParms->getLParenLoc());
1457 OpenACCDeclClauseInstantiator Instantiator{S, MLTAL, TransformedClauses,
1459 Instantiator.Visit(Clause);
1460 if (Instantiator.CreatedClause())
1461 TransformedClauses.push_back(Instantiator.CreatedClause());
1463 return TransformedClauses;
1470 const OpenACCRoutineDeclAttr *OldAttr,
const Decl *OldDecl,
Decl *NewDecl) {
1471 OpenACCRoutineDeclAttr *A =
1472 OpenACCRoutineDeclAttr::Create(S.
getASTContext(), OldAttr->getLocation());
1474 if (!OldAttr->Clauses.empty()) {
1476 InstantiateOpenACCClauseList(
1478 A->Clauses.assign(TransformedClauses.begin(), TransformedClauses.end());
1489 llvm::SmallVector<OpenACCClause *> TransformedClauses =
1493 if (SemaRef.OpenACC().ActOnStartDeclDirective(
1497 DeclGroupRef Res = SemaRef.OpenACC().ActOnEndDeclDirective(
1509 llvm::SmallVector<OpenACCClause *> TransformedClauses =
1517 FuncRef = SemaRef.OpenACC().ActOnRoutineName(FuncRef.
get());
1522 if (SemaRef.OpenACC().ActOnStartDeclDirective(
1526 DeclGroupRef Res = SemaRef.OpenACC().ActOnEndRoutineDeclDirective(
1538 NamespaceAliasDecl *Inst
1546 Owner->addDecl(Inst);
1556 TSI = SemaRef.SubstType(TSI, TemplateArgs, D->
getLocation(),
1560 TSI = SemaRef.Context.getTrivialTypeSourceInfo(SemaRef.Context.IntTy);
1571 if (SemaRef.getPreprocessor().NeedsStdLibCxxWorkaroundBefore(2014'04'22)) {
1572 const DecltypeType *DT = TSI->
getType()->
getAs<DecltypeType>();
1575 DT->isReferenceType() &&
1576 RD->getEnclosingNamespaceContext() == SemaRef.getStdNamespace() &&
1577 RD->getIdentifier() && RD->getIdentifier()->isStr(
"common_type") &&
1579 SemaRef.getSourceManager().isInSystemHeader(D->
getBeginLoc()))
1581 TSI = SemaRef.Context.getTrivialTypeSourceInfo(
1599 TagDecl *oldTag = oldTagType->getDecl();
1616 SemaRef.isIncompatibleTypedef(InstPrevTypedef,
Typedef);
1618 Typedef->setPreviousDecl(InstPrevTypedef);
1621 SemaRef.InstantiateAttrs(TemplateArgs, D,
Typedef);
1624 SemaRef.inferGslPointerAttribute(
Typedef);
1673 if (!
Found.empty()) {
1674 PrevAliasTemplate = dyn_cast<TypeAliasTemplateDecl>(
Found.front());
1687 if (PrevAliasTemplate)
1692 if (!PrevAliasTemplate)
1719 SmallVector<BindingDecl*, 16> NewBindings;
1720 BindingDecl *OldBindingPack =
nullptr;
1721 for (
auto *OldBD : D->
bindings()) {
1722 Expr *BindingExpr = OldBD->getBinding();
1723 if (isa_and_present<FunctionParmPackExpr>(BindingExpr)) {
1725 assert(!OldBindingPack &&
"no more than one pack is allowed");
1726 OldBindingPack = OldBD;
1730 ArrayRef<BindingDecl*> NewBindingArray = NewBindings;
1732 auto *NewDD = cast_if_present<DecompositionDecl>(
1735 if (!NewDD || NewDD->isInvalidDecl()) {
1736 for (
auto *NewBD : NewBindings)
1737 NewBD->setInvalidDecl();
1738 }
else if (OldBindingPack) {
1741 BindingDecl *NewBindingPack = *llvm::find_if(
1743 assert(NewBindingPack !=
nullptr &&
"new bindings should also have a pack");
1744 llvm::ArrayRef<BindingDecl *> OldDecls =
1746 llvm::ArrayRef<BindingDecl *> NewDecls =
1748 assert(OldDecls.size() == NewDecls.size());
1749 for (
unsigned I = 0; I < OldDecls.size(); I++)
1750 SemaRef.CurrentInstantiationScope->InstantiatedLocal(OldDecls[I],
1762 bool InstantiatingVarTemplate,
1771 if (!InstantiatingVarTemplate)
1777 SemaRef.
Diag(D->
getLocation(), diag::err_variable_instantiates_to_function)
1779 if (!InstantiatingVarTemplate)
1784 DeclContext *DC = Owner;
1786 SemaRef.adjustContextForLocalExternDecl(DC);
1800 if (SemaRef.getLangOpts().ObjCAutoRefCount &&
1801 SemaRef.ObjC().inferObjCARCLifetime(Var))
1804 if (SemaRef.getLangOpts().OpenCL)
1805 SemaRef.deduceOpenCLAddressSpace(Var);
1811 SemaRef.BuildVariableInstantiation(Var, D, TemplateArgs, LateAttrs, Owner,
1812 StartingScope, InstantiatingVarTemplate);
1815 if (
auto *F = dyn_cast<FunctionDecl>(DC))
1816 RT = F->getReturnType();
1821 llvm_unreachable(
"Unknown context type");
1834 Sema::NamedReturnInfo Info = SemaRef.getNamedReturnInfo(Var);
1835 bool NRVO = SemaRef.getCopyElisionCandidate(Info, RT) !=
nullptr;
1842 SemaRef.CheckStaticLocalForDllExport(Var);
1845 SemaRef.CheckThreadLocalForLargeAlignment(Var);
1847 if (SemaRef.getLangOpts().OpenACC)
1848 SemaRef.OpenACC().ActOnVariableDeclarator(Var);
1860 Owner->addHiddenDecl(AD);
1864Decl *TemplateDeclInstantiator::VisitFieldDecl(
FieldDecl *D) {
1869 TSI = SemaRef.SubstType(TSI, TemplateArgs, D->
getLocation(),
1881 SemaRef.Diag(D->
getLocation(), diag::err_field_instantiates_to_function)
1892 else if (BitWidth) {
1898 = SemaRef.SubstExpr(BitWidth, TemplateArgs);
1903 BitWidth = InstantiatedBitWidth.
getAs<Expr>();
1906 FieldDecl *
Field = SemaRef.CheckFieldDecl(
1915 SemaRef.InstantiateAttrs(TemplateArgs, D, Field, LateAttrs, StartingScope);
1917 if (
Field->hasAttrs())
1918 SemaRef.CheckAlignasUnderalignment(Field);
1921 Field->setInvalidDecl();
1923 if (!
Field->getDeclName() ||
Field->isPlaceholderVar(SemaRef.getLangOpts())) {
1925 SemaRef.Context.setInstantiatedFromUnnamedFieldDecl(Field, D);
1927 if (CXXRecordDecl *Parent= dyn_cast<CXXRecordDecl>(
Field->getDeclContext())) {
1928 if (Parent->isAnonymousStructOrUnion() &&
1929 Parent->getRedeclContext()->isFunctionOrMethod())
1930 SemaRef.CurrentInstantiationScope->InstantiatedLocal(D, Field);
1935 Owner->addDecl(Field);
1945 SemaRef.Diag(D->
getLocation(), diag::err_property_is_variably_modified)
1949 TSI = SemaRef.SubstType(TSI, TemplateArgs, D->
getLocation(),
1961 SemaRef.Diag(D->
getLocation(), diag::err_field_instantiates_to_function)
1974 SemaRef.InstantiateAttrs(TemplateArgs, D,
Property, LateAttrs,
1987 NamedDecl **NamedChain =
1991 for (
auto *PI : D->
chain()) {
1997 NamedChain[i++] =
Next;
2003 {NamedChain, D->getChainingSize()});
2005 for (
const auto *Attr : D->
attrs())
2006 IndirectField->
addAttr(Attr->clone(SemaRef.Context));
2010 Owner->addDecl(IndirectField);
2011 return IndirectField;
2014static std::optional<TemplateName>
2017 bool HasTemplateKeyword,
bool RequireClassTemplate) {
2022 SS.
Adopt(QualifierLoc);
2028 return std::nullopt;
2033 return std::nullopt;
2038 if (RequireClassTemplate && !IsDependentContext) {
2039 SemaRef.
Diag(NameLoc, diag::err_no_member_template)
2041 return std::nullopt;
2046 if (
Result.isAmbiguous())
2047 return std::nullopt;
2051 if (RequireClassTemplate && !IsDependentContext) {
2052 SemaRef.
Diag(NameLoc, diag::err_redefinition_different_kind) << Name;
2054 Result.getRepresentativeDecl()->getUnderlyingDecl()->getLocation(),
2055 diag::note_previous_definition);
2056 return std::nullopt;
2061 auto *FoundUsingShadow =
2062 dyn_cast<UsingShadowDecl>(
Result.getRepresentativeDecl());
2077 if (!TSTL || !QualifierLoc ||
2078 !QualifierLoc.getNestedNameSpecifier().isDependent())
2079 return SubstType(TSI, TemplateArgs, Loc, Entity);
2082 auto *FriendCTD = dyn_cast_or_null<ClassTemplateDecl>(
2083 FriendTST->getTemplateName().getAsTemplateDecl());
2085 return SubstType(TSI, TemplateArgs, Loc, Entity);
2097 if (InstTemplate->isNull())
2098 return SubstType(TSI, TemplateArgs, Loc, Entity);
2101 for (
unsigned I = 0, N = TSTL.
getNumArgs(); I != N; ++I)
2102 FriendArgLocs.push_back(TSTL.
getArgLoc(I));
2129static std::optional<SubstitutedFriend>
2139 if (!InstQualifierLoc ||
2142 return std::nullopt;
2148 assert(DNTL &&
"friend class template must have a dependent name type");
2151 SemaRef, InstQualifierLoc, DNTL.getTypePtr()->getIdentifier(),
2152 DNTL.getNameLoc(),
false,
2155 return std::nullopt;
2156 if (!InstTemplate->isNull())
2160 assert(DTN &&
"unresolved friend template must have a dependent name");
2163 DTN->hasTemplateKeyword()});
2169 return std::nullopt;
2175 assert(TSI &&
"friend pack expansion must name a type");
2177 const auto *FTD = dyn_cast<FriendTemplateDecl>(D);
2180 TPLs = FTD->getTemplateParameterLists();
2183 SemaRef.collectUnexpandedParameterPacks(TSI->
getTypeLoc(), Unexpanded);
2184 assert(!Unexpanded.empty() &&
"Pack expansion without packs");
2186 bool ShouldExpand =
true;
2187 bool RetainExpansion =
false;
2189 if (SemaRef.CheckParameterPacksForExpansion(
2191 true, ShouldExpand, RetainExpansion,
2195 assert(!RetainExpansion &&
2196 "should never retain an expansion for a friend declaration");
2201 for (
unsigned I = 0; I != *NumExpansions; I++) {
2208 std::optional<SubstitutedFriend> InstFriend;
2211 SemaRef, TSI, FTD->getFriendTemplateName(), TemplateArgs,
2216 if (!InstFriend || InstFriend->empty())
2226 {}, InstFriend->Template);
2228 assert(InstTPLs.empty() &&
"unexpected template parameter lists");
2229 assert(InstFriend->Template.isNull() &&
2230 "non-template friend resolved to a class template");
2260 assert(ND &&
"friend decl must be a decl or a type!");
2267 if (!NewND)
return nullptr;
2285 = SemaRef.SubstExpr(AssertExpr, TemplateArgs);
2290 SemaRef.SubstExpr(D->
getMessage(), TemplateArgs);
2291 if (InstantiatedMessageExpr.
isInvalid())
2294 return SemaRef.BuildStaticAssertDeclaration(
2299Decl *TemplateDeclInstantiator::VisitExplicitInstantiationDecl(
2303 llvm_unreachable(
"ExplicitInstantiationDecl should not be instantiated");
2306Decl *TemplateDeclInstantiator::VisitCXXExpansionStmtDecl(
2309 CXXExpansionStmtDecl *NewESD = SemaRef.BuildCXXExpansionStmtDecl(
2311 SemaRef.CurrentInstantiationScope->InstantiatedLocal(OldESD, NewESD);
2316 StmtResult NewInst = SemaRef.SubstStmt(OldInst, TemplateArgs);
2317 if (NewInst.isInvalid())
2328 Sema::ContextRAII Context(SemaRef, NewESD,
false);
2332 if (Expansion.isInvalid())
2341Decl *TemplateDeclInstantiator::VisitEnumDecl(
EnumDecl *D) {
2342 EnumDecl *PrevDecl =
nullptr;
2344 NamedDecl *Prev = SemaRef.FindInstantiatedDecl(D->
getLocation(),
2347 if (!Prev)
return nullptr;
2360 SourceLocation UnderlyingLoc = TI->getTypeLoc().getBeginLoc();
2361 TypeSourceInfo *NewTI = SemaRef.SubstType(TI, TemplateArgs, UnderlyingLoc,
2363 if (!NewTI || SemaRef.CheckEnumUnderlyingType(NewTI))
2364 Enum->setIntegerType(SemaRef.Context.IntTy);
2374 Enum->setIntegerTypeSourceInfo(NewTI);
2384 QualType UnderlyingType =
Enum->getIntegerType();
2385 Enum->setPromotionType(
2386 SemaRef.Context.isPromotableIntegerType(UnderlyingType)
2387 ? SemaRef.Context.getPromotedIntegerType(UnderlyingType)
2391 &&
"Dependent type without type source info");
2396 SemaRef.InstantiateAttrs(TemplateArgs, D,
Enum);
2401 SemaRef.Context.setManglingNumber(
Enum, SemaRef.Context.getManglingNumber(D));
2404 if (DeclaratorDecl *DD = SemaRef.Context.getDeclaratorForUnnamedTagDecl(D))
2405 SemaRef.Context.addDeclaratorForUnnamedTagDecl(
Enum, DD);
2408 if (TypedefNameDecl *TND = SemaRef.Context.getTypedefNameForUnnamedTagDecl(D))
2409 SemaRef.Context.addTypedefNameForUnnamedTagDecl(
Enum, TND);
2411 Owner->addDecl(
Enum);
2414 if (Def && Def != D) {
2419 SourceLocation UnderlyingLoc = TI->getTypeLoc().getBeginLoc();
2420 QualType DefnUnderlying =
2421 SemaRef.SubstType(TI->getType(), TemplateArgs,
2422 UnderlyingLoc, DeclarationName());
2424 DefnUnderlying,
true,
Enum);
2439 if (PrevDecl ==
nullptr) {
2440 SemaRef.CurrentInstantiationScope->InstantiatedLocal(D,
Enum);
2450 Enum->startDefinition();
2461 if (
Expr *UninstValue = EC->getInitExpr()) {
2466 Value = SemaRef.SubstExpr(UninstValue, TemplateArgs);
2471 if (
Value.isInvalid()) {
2477 = SemaRef.CheckEnumConstant(
Enum, LastEnumConst,
2484 Enum->setInvalidDecl();
2488 SemaRef.InstantiateAttrs(TemplateArgs, EC, EnumConst);
2491 Enum->addDecl(EnumConst);
2492 Enumerators.push_back(EnumConst);
2493 LastEnumConst = EnumConst;
2496 !
Enum->isScoped()) {
2499 SemaRef.CurrentInstantiationScope->InstantiatedLocal(EC, EnumConst);
2504 SemaRef.ActOnEnumBody(
Enum->getLocation(),
Enum->getBraceRange(),
Enum,
2509 llvm_unreachable(
"EnumConstantDecls can only occur within EnumDecls.");
2514 llvm_unreachable(
"BuiltinTemplateDecls cannot be instantiated.");
2522 LocalInstantiationScope Scope(SemaRef);
2535 QualifierLoc = SemaRef.SubstNestedNameSpecifierLoc(QualifierLoc,
2541 CXXRecordDecl *PrevDecl =
nullptr;
2542 ClassTemplateDecl *PrevClassTemplate =
nullptr;
2546 if (!
Found.empty()) {
2547 PrevClassTemplate = dyn_cast<ClassTemplateDecl>(
Found.front());
2548 if (PrevClassTemplate)
2557 DeclContext *DC = Owner;
2561 SS.
Adopt(QualifierLoc);
2562 DC = SemaRef.computeDeclContext(SS);
2563 if (!DC)
return nullptr;
2565 DC = SemaRef.FindInstantiatedContext(Pattern->
getLocation(),
2574 SemaRef.forRedeclarationInCurContext());
2575 SemaRef.LookupQualifiedName(R, DC);
2577 if (
R.isSingleResult()) {
2578 PrevClassTemplate =
R.getAsSingle<ClassTemplateDecl>();
2579 if (PrevClassTemplate)
2583 if (!PrevClassTemplate && QualifierLoc) {
2584 SemaRef.Diag(Pattern->
getLocation(), diag::err_not_tag_in_scope)
2597 SemaRef.InstantiateAttrsForDecl(TemplateArgs, Pattern, RecordInst, LateAttrs,
2600 ClassTemplateDecl *Inst
2606 assert(!Owner->isDependentContext());
2611 if (PrevClassTemplate) {
2613 const ClassTemplateDecl *MostRecentPrevCT =
2615 TemplateParameterList *PrevParams =
2619 if (!SemaRef.TemplateParameterListsAreEqual(
2626 if (SemaRef.CheckTemplateParameterList(InstParams, PrevParams,
2640 if (!PrevClassTemplate)
2657 Owner->addDecl(Inst);
2659 if (!PrevClassTemplate) {
2663 SmallVector<ClassTemplatePartialSpecializationDecl *, 4> PartialSpecs;
2665 for (
unsigned I = 0, N = PartialSpecs.size(); I != N; ++I)
2666 if (PartialSpecs[I]->getFirstDecl()->isOutOfLine())
2667 OutOfLinePartialSpecs.push_back(std::make_pair(Inst, PartialSpecs[I]));
2674TemplateDeclInstantiator::VisitClassTemplatePartialSpecializationDecl(
2685 ClassTemplateDecl *InstClassTemplate
2686 = dyn_cast<ClassTemplateDecl>(
Found.front());
2687 if (!InstClassTemplate)
2690 if (ClassTemplatePartialSpecializationDecl *
Result
2699 "Only static data member templates are allowed.");
2703 LocalInstantiationScope Scope(SemaRef);
2710 VarTemplateDecl *PrevVarTemplate =
nullptr;
2715 PrevVarTemplate = dyn_cast<VarTemplateDecl>(
Found.front());
2721 if (!VarInst)
return nullptr;
2723 DeclContext *DC = Owner;
2732 if (!PrevVarTemplate)
2740 Owner->addDecl(Inst);
2741 SemaRef.InstantiateAttrsForDecl(TemplateArgs, D, Inst, LateAttrs,
2744 if (!PrevVarTemplate) {
2748 SmallVector<VarTemplatePartialSpecializationDecl *, 1> PartialSpecs;
2750 for (
unsigned I = 0, N = PartialSpecs.size(); I != N; ++I)
2751 if (PartialSpecs[I]->getFirstDecl()->isOutOfLine())
2752 OutOfLineVarPartialSpecs.push_back(
2753 std::make_pair(Inst, PartialSpecs[I]));
2759Decl *TemplateDeclInstantiator::VisitVarTemplatePartialSpecializationDecl(
2762 "Only static data member templates are allowed.");
2768 assert(!
Found.empty() &&
"Instantiation found nothing?");
2770 VarTemplateDecl *InstVarTemplate = dyn_cast<VarTemplateDecl>(
Found.front());
2771 assert(InstVarTemplate &&
"Instantiation did not find a variable template?");
2773 if (VarTemplatePartialSpecializationDecl *
Result =
2786 LocalInstantiationScope Scope(SemaRef);
2787 llvm::SaveAndRestore RAII(EvaluateConstraints,
false);
2794 FunctionDecl *Instantiated =
nullptr;
2795 if (CXXMethodDecl *DMethod = dyn_cast<CXXMethodDecl>(D->
getTemplatedDecl()))
2808 FunctionTemplateDecl *InstTemplate
2811 assert(InstTemplate &&
2812 "VisitFunctionDecl/CXXMethodDecl didn't create a template!");
2824 Owner->addDecl(InstTemplate);
2828 SemaRef.CheckFriendAccess(InstTemplate);
2831 return InstTemplate;
2835 CXXRecordDecl *PrevDecl =
nullptr;
2837 NamedDecl *Prev = SemaRef.FindInstantiatedDecl(D->
getLocation(),
2840 if (!Prev)
return nullptr;
2844 CXXRecordDecl *
Record =
nullptr;
2862 SemaRef.InstantiateAttrsForDecl(TemplateArgs, D,
Record, LateAttrs,
2870 if (!IsInjectedClassName)
2876 Record->setObjectOfFriendDecl();
2880 Record->setAnonymousStructOrUnion(
true);
2883 SemaRef.CurrentInstantiationScope->InstantiatedLocal(D,
Record);
2886 SemaRef.Context.setManglingNumber(
Record,
2887 SemaRef.Context.getManglingNumber(D));
2891 if (DeclaratorDecl *DD = SemaRef.Context.getDeclaratorForUnnamedTagDecl(D))
2892 SemaRef.Context.addDeclaratorForUnnamedTagDecl(
Record, DD);
2896 if (TypedefNameDecl *TND = SemaRef.Context.getTypedefNameForUnnamedTagDecl(D))
2897 SemaRef.Context.addTypedefNameForUnnamedTagDecl(
Record, TND);
2904 Sema::LocalEagerInstantiationScope LocalInstantiations(SemaRef,
2919 LocalInstantiations.perform();
2922 SemaRef.DiagnoseUnusedNestedTypedefs(
Record);
2924 if (IsInjectedClassName)
2925 assert(
Record->isInjectedClassName() &&
"Broken injected-class-name");
2943 if (OrigFunc->
getExtInfo() == NewFunc->getExtInfo())
2948 return Context.getFunctionType(NewFunc->getReturnType(),
2949 NewFunc->getParamTypes(), NewEPI);
2973 if (isFriend && Source->wasThisDeclarationADefinition(D)) {
2985 llvm::FoldingSetInsertToken InsertToken;
2994 bool MergeWithParentScope = (TemplateParams !=
nullptr) ||
2995 Owner->isFunctionOrMethod() ||
2997 cast<Decl>(Owner)->isDefinedOutsideFunctionOrMethod());
3001 if (
auto *DGuide = dyn_cast<CXXDeductionGuideDecl>(D)) {
3002 InstantiatedExplicitSpecifier = SemaRef.instantiateExplicitSpecifier(
3003 TemplateArgs, DGuide->getExplicitSpecifier());
3004 if (InstantiatedExplicitSpecifier.
isInvalid())
3014 if (TemplateParams && TemplateParams->
size()) {
3016 dyn_cast<TemplateTypeParmDecl>(TemplateParams->
asArray().back());
3017 if (LastParam && LastParam->isImplicit() &&
3018 LastParam->hasTypeConstraint()) {
3033 QualifierLoc = SemaRef.SubstNestedNameSpecifierLoc(QualifierLoc,
3041 SemaRef.CheckDependentFriend(D->
getLocation(), QualifierLoc,
3053 SemaRef.adjustContextForLocalExternDecl(DC);
3054 }
else if (isFriend && QualifierLoc) {
3056 SS.
Adopt(QualifierLoc);
3057 DC = SemaRef.computeDeclContext(SS);
3058 if (!DC)
return nullptr;
3065 = SemaRef.SubstDeclarationNameInfo(D->
getNameInfo(), TemplateArgs);
3071 if (
auto *DGuide = dyn_cast<CXXDeductionGuideDecl>(D)) {
3074 InstantiatedExplicitSpecifier, NameInfo,
T, TInfo,
3076 DGuide->getDeductionCandidateKind(), TrailingRequiresClause,
3077 DGuide->getSourceDeductionGuide(),
3078 DGuide->getSourceDeductionGuideKind());
3085 TrailingRequiresClause);
3086 Function->setFriendConstraintRefersToEnclosingTemplate(
3095 Function->setQualifierInfo(QualifierLoc);
3106 LexicalDC = SemaRef.CurContext;
3110 Function->setIsTypeAwareOperatorNewOrDelete(
3112 Function->setLexicalDeclContext(LexicalDC);
3115 for (
unsigned P = 0; P < Params.size(); ++P)
3117 Params[P]->setOwningFunction(
Function);
3120 if (TrailingRequiresClause)
3121 Function->setTrailingRequiresClause(TrailingRequiresClause);
3123 if (TemplateParams) {
3151 SemaRef.CodeSynthesisContexts.back().Kind !=
3155 Function->setFunctionTemplateSpecialization(
3165 }
else if (!isFriend) {
3169 Function->setInstantiatedFromDecl(D);
3176 FT->setObjectOfFriendDecl();
3182 bool IsExplicitSpecialization =
false;
3189 : SemaRef.forRedeclarationInCurContext());
3193 assert(isFriend &&
"dependent specialization info on "
3194 "non-member non-friend function?");
3198 if (
const auto *ArgsWritten = DFTSI->TemplateArgumentsAsWritten) {
3199 ExplicitArgs.
setLAngleLoc(ArgsWritten->getLAngleLoc());
3200 ExplicitArgs.
setRAngleLoc(ArgsWritten->getRAngleLoc());
3201 if (SemaRef.SubstTemplateArguments(ArgsWritten->arguments(), TemplateArgs,
3209 SemaRef.FindInstantiatedDecl(D->
getLocation(), FTD, TemplateArgs))
3215 if (SemaRef.CheckFunctionTemplateSpecialization(
3217 DFTSI->TemplateArgumentsAsWritten ? &ExplicitArgs :
nullptr,
3221 IsExplicitSpecialization =
true;
3225 SemaRef.LookupQualifiedName(
Previous, DC);
3229 ArgsWritten->getRAngleLoc());
3230 if (SemaRef.SubstTemplateArguments(ArgsWritten->arguments(), TemplateArgs,
3234 if (SemaRef.CheckFunctionTemplateSpecialization(
Function,
3239 IsExplicitSpecialization =
true;
3256 if (isFriend && !QualifierLoc) {
3257 SemaRef.FilterLookupForScope(
Previous, DC,
nullptr,
3276 if (
Function->isLocalExternDecl()) {
3278 if (!PVD->hasDefaultArg())
3280 if (SemaRef.SubstDefaultArgument(D->
getInnerLocStart(), PVD, TemplateArgs)) {
3284 Expr *UninstExpr = PVD->getUninstantiatedDefaultArg();
3285 ExprResult ErrorResult = SemaRef.CreateRecoveryExpr(
3287 { UninstExpr }, UninstExpr->
getType());
3289 PVD->setDefaultArg(ErrorResult.
get());
3295 IsExplicitSpecialization,
3296 Function->isThisDeclarationADefinition());
3303 SemaRef.CheckTemplateParameterList(
3306 Function->isThisDeclarationADefinition()
3317 Function->getMemberSpecializationInfo()) {
3318 if (MSInfo->getPointOfInstantiation().isInvalid()) {
3320 MSInfo->setPointOfInstantiation(Loc);
3321 SemaRef.PendingLocalImplicitInstantiations.emplace_back(
Function, Loc);
3359 llvm::FoldingSetInsertToken InsertToken;
3374 bool MergeWithParentScope = (TemplateParams !=
nullptr) ||
3376 cast<Decl>(Owner)->isDefinedOutsideFunctionOrMethod());
3380 SemaRef, D, TemplateArgs,
Scope);
3385 if (isFriend && !TPLs.empty()) {
3386 TempParamLists.resize(TPLs.size());
3387 for (
unsigned I = 0; I != TPLs.size(); ++I) {
3391 TempParamLists[I] = InstParams;
3397 const bool CouldInstantiate =
3398 InstantiatedExplicitSpecifier.getExpr() ==
nullptr ||
3399 !InstantiatedExplicitSpecifier.getExpr()->isValueDependent();
3403 if (CouldInstantiate ||
3404 SemaRef.CodeSynthesisContexts.back().Kind !=
3406 InstantiatedExplicitSpecifier = SemaRef.instantiateExplicitSpecifier(
3407 TemplateArgs, InstantiatedExplicitSpecifier);
3409 if (InstantiatedExplicitSpecifier.isInvalid())
3424 SemaRef.Context.getTrivialTypeSourceInfo(D->
getType());
3434 if (TemplateParams && TemplateParams->
size()) {
3436 dyn_cast<TemplateTypeParmDecl>(TemplateParams->
asArray().back());
3437 if (LastParam && LastParam->isImplicit() &&
3438 LastParam->hasTypeConstraint()) {
3453 QualifierLoc = SemaRef.SubstNestedNameSpecifierLoc(QualifierLoc,
3461 SemaRef.CheckDependentFriend(D->
getLocation(), QualifierLoc,
3469 SS.
Adopt(QualifierLoc);
3470 DC = SemaRef.computeDeclContext(SS);
3472 if (DC && SemaRef.RequireCompleteDeclContext(SS, DC))
3474 }
else if (!QualifierLoc) {
3475 DC = SemaRef.FindInstantiatedContext(D->
getLocation(),
3479 if (!DC)
return nullptr;
3486 = SemaRef.SubstDeclarationNameInfo(D->
getNameInfo(), TemplateArgs);
3502 SemaRef.Context,
Record, StartLoc, NameInfo,
T, TInfo,
3503 InstantiatedExplicitSpecifier,
Constructor->UsesFPIntrin(),
3506 TrailingRequiresClause);
3510 SemaRef.Context,
Record, StartLoc, NameInfo,
T, TInfo,
3512 Destructor->getConstexprKind(), TrailingRequiresClause);
3513 Method->setIneligibleOrNotSelected(
true);
3515 Method->setDeclName(SemaRef.Context.DeclarationNames.getCXXDestructorName(
3517 SemaRef.Context.getCanonicalTagType(
Record)));
3520 SemaRef.Context,
Record, StartLoc, NameInfo,
T, TInfo,
3521 Conversion->UsesFPIntrin(), Conversion->isInlineSpecified(),
3522 InstantiatedExplicitSpecifier, Conversion->getConstexprKind(),
3523 Conversion->getEndLoc(), TrailingRequiresClause);
3527 SemaRef.Context,
Record, StartLoc, NameInfo,
T, TInfo, SC,
3529 D->
getEndLoc(), TrailingRequiresClause);
3533 Method->setImplicitlyInline();
3536 Method->setQualifierInfo(QualifierLoc);
3538 if (TemplateParams) {
3565 Method->setFunctionTemplateSpecialization(
3578 if (!TempParamLists.empty())
3579 Method->setTemplateParameterListsInfo(SemaRef.Context, TempParamLists);
3581 Method->setLexicalDeclContext(Owner);
3582 Method->setObjectOfFriendDecl();
3587 for (
unsigned P = 0; P < Params.size(); ++P)
3588 Params[P]->setOwningFunction(
Method);
3589 Method->setParams(Params);
3592 Method->setInvalidDecl();
3597 bool IsExplicitSpecialization =
false;
3605 if (
const auto *ArgsWritten = DFTSI->TemplateArgumentsAsWritten) {
3606 ExplicitArgs.
setLAngleLoc(ArgsWritten->getLAngleLoc());
3607 ExplicitArgs.
setRAngleLoc(ArgsWritten->getRAngleLoc());
3608 if (SemaRef.SubstTemplateArguments(ArgsWritten->arguments(), TemplateArgs,
3616 SemaRef.FindInstantiatedDecl(D->
getLocation(), FTD, TemplateArgs))
3623 if (SemaRef.CheckDependentFunctionTemplateSpecialization(
3625 DFTSI->TemplateArgumentsAsWritten ? &ExplicitArgs :
nullptr,
3627 Method->setInvalidDecl();
3630 SemaRef.LookupQualifiedName(
Previous, DC);
3631 if (SemaRef.CheckFunctionTemplateSpecialization(
3633 DFTSI->TemplateArgumentsAsWritten ? &ExplicitArgs :
nullptr,
3635 Method->setInvalidDecl();
3636 IsExplicitSpecialization =
true;
3640 SemaRef.LookupQualifiedName(
Previous, DC);
3643 ArgsWritten->getRAngleLoc());
3645 if (SemaRef.SubstTemplateArguments(ArgsWritten->arguments(), TemplateArgs,
3649 if (SemaRef.CheckFunctionTemplateSpecialization(
Method,
3652 Method->setInvalidDecl();
3654 IsExplicitSpecialization =
true;
3682 for (
unsigned P = 0; P < Params.size(); ++P) {
3683 if (!Params[P]->hasDefaultArg())
3685 if (SemaRef.SubstDefaultArgument(StartLoc, Params[P], TemplateArgs)) {
3689 Expr *UninstExpr = Params[P]->getUninstantiatedDefaultArg();
3690 ExprResult ErrorResult = SemaRef.CreateRecoveryExpr(
3692 { UninstExpr }, UninstExpr->
getType());
3694 Params[P]->setDefaultArg(ErrorResult.
get());
3700 IsExplicitSpecialization,
3701 Method->isThisDeclarationADefinition());
3709 if (isFriend &&
Method->getPreviousDecl())
3710 Method->setAccess(
Method->getPreviousDecl()->getAccess());
3716 SemaRef.CheckOverrideControl(
Method);
3730 if (IsExplicitSpecialization && !isFriend)
3743 Method->setIneligibleOrNotSelected(
true);
3744 }
else if (
Method->isCopyAssignmentOperator() ||
3745 Method->isMoveAssignmentOperator()) {
3746 Method->setIneligibleOrNotSelected(
true);
3758 }
else if (isFriend) {
3762 SemaRef.CheckFriendAccess(
Method);
3775 if (
Method->hasAttr<UsedAttr>()) {
3776 if (
const auto *A = dyn_cast<CXXRecordDecl>(Owner)) {
3779 A->getMemberSpecializationInfo())
3780 Loc = MSInfo->getPointOfInstantiation();
3781 else if (
const auto *Spec = dyn_cast<ClassTemplateSpecializationDecl>(A))
3782 Loc = Spec->getPointOfInstantiation();
3783 SemaRef.MarkFunctionReferenced(Loc,
Method);
3803 return SemaRef.SubstParmVarDecl(D, TemplateArgs, 0,
3808Decl *TemplateDeclInstantiator::VisitTemplateTypeParmDecl(
3816 assert(TC->getTemplateArgsAsWritten() &&
3817 "type parameter can only be an expansion when explicit arguments "
3822 SmallVector<UnexpandedParameterPack, 2> Unexpanded;
3823 for (
auto &ArgLoc : TC->getTemplateArgsAsWritten()->arguments())
3824 SemaRef.collectUnexpandedParameterPacks(ArgLoc, Unexpanded);
3829 bool RetainExpansion =
false;
3830 if (SemaRef.CheckParameterPacksForExpansion(
3833 SourceRange(TC->getConceptNameLoc(),
3834 TC->hasExplicitTemplateArgs()
3835 ? TC->getTemplateArgsAsWritten()->getRAngleLoc()
3836 : TC->getConceptNameInfo().getEndLoc()),
3837 Unexpanded, TemplateArgs,
true,
3838 Expand, RetainExpansion, NumExpanded))
3845 D->
getDepth() - (TemplateArgs.retainInnerDepths()
3847 : TemplateArgs.getNumSubstitutedLevels()),
3858 if (SemaRef.SubstTypeConstraint(Inst, TC, TemplateArgs,
3859 EvaluateConstraints))
3864 TemplateArgumentLoc Output;
3872 SemaRef.CurrentInstantiationScope->InstantiatedLocal(D, Inst);
3877Decl *TemplateDeclInstantiator::VisitNonTypeTemplateParmDecl(
3881 SmallVector<TypeSourceInfo *, 4> ExpandedParameterPackTypesAsWritten;
3882 SmallVector<QualType, 4> ExpandedParameterPackTypes;
3883 bool IsExpandedParameterPack =
false;
3884 TypeSourceInfo *TSI;
3894 TypeSourceInfo *NewTSI =
3901 SemaRef.CheckNonTypeTemplateParameterType(NewTSI, D->
getLocation());
3905 ExpandedParameterPackTypesAsWritten.push_back(NewTSI);
3906 ExpandedParameterPackTypes.push_back(NewT);
3909 IsExpandedParameterPack =
true;
3916 PackExpansionTypeLoc Expansion = TL.
castAs<PackExpansionTypeLoc>();
3918 SmallVector<UnexpandedParameterPack, 2> Unexpanded;
3919 SemaRef.collectUnexpandedParameterPacks(Pattern, Unexpanded);
3924 bool RetainExpansion =
false;
3928 if (SemaRef.CheckParameterPacksForExpansion(
3929 Expansion.
getEllipsisLoc(), Pattern.getSourceRange(), Unexpanded,
3930 TemplateArgs,
true, Expand,
3931 RetainExpansion, NumExpansions))
3935 for (
unsigned I = 0; I != *NumExpansions; ++I) {
3936 Sema::ArgPackSubstIndexRAII SubstIndex(SemaRef, I);
3937 TypeSourceInfo *NewTSI = SemaRef.SubstType(
3943 SemaRef.CheckNonTypeTemplateParameterType(NewTSI, D->
getLocation());
3947 ExpandedParameterPackTypesAsWritten.push_back(NewTSI);
3948 ExpandedParameterPackTypes.push_back(NewT);
3954 IsExpandedParameterPack =
true;
3960 Sema::ArgPackSubstIndexRAII SubstIndex(SemaRef, std::nullopt);
3961 TypeSourceInfo *NewPattern = SemaRef.SubstType(Pattern, TemplateArgs,
3967 SemaRef.CheckNonTypeTemplateParameterType(NewPattern, D->
getLocation());
3968 TSI = SemaRef.CheckPackExpansion(NewPattern, Expansion.
getEllipsisLoc(),
3983 T = SemaRef.CheckNonTypeTemplateParameterType(TSI, D->
getLocation());
3985 T = SemaRef.Context.IntTy;
3990 NonTypeTemplateParmDecl *Param;
3991 if (IsExpandedParameterPack)
3994 D->
getDepth() - TemplateArgs.getNumSubstitutedLevels(),
3996 ExpandedParameterPackTypes, ExpandedParameterPackTypesAsWritten);
4000 D->
getDepth() - TemplateArgs.getNumSubstitutedLevels(),
4004 if (AutoLoc.isConstrained()) {
4005 SourceLocation EllipsisLoc;
4006 if (IsExpandedParameterPack)
4009 else if (
auto *Constraint = dyn_cast_if_present<CXXFoldExpr>(
4011 EllipsisLoc = Constraint->getEllipsisLoc();
4015 if (SemaRef.AttachTypeConstraint(AutoLoc, Param,
4026 EnterExpressionEvaluationContext ConstantEvaluated(
4028 TemplateArgumentLoc
Result;
4036 SemaRef.CurrentInstantiationScope->InstantiatedLocal(D, Param);
4044 for (
const auto &P : *Params) {
4045 if (P->isTemplateParameterPack())
4057TemplateDeclInstantiator::VisitTemplateTemplateParmDecl(
4061 TemplateParameterList *InstParams;
4062 SmallVector<TemplateParameterList*, 8> ExpandedParams;
4064 bool IsExpandedParameterPack =
false;
4073 LocalInstantiationScope Scope(SemaRef,
true);
4074 TemplateParameterList *Expansion =
4078 ExpandedParams.push_back(Expansion);
4081 IsExpandedParameterPack =
true;
4082 InstParams = TempParams;
4087 SmallVector<UnexpandedParameterPack, 2> Unexpanded;
4094 bool RetainExpansion =
false;
4096 if (SemaRef.CheckParameterPacksForExpansion(
4098 TemplateArgs,
true, Expand,
4099 RetainExpansion, NumExpansions))
4103 for (
unsigned I = 0; I != *NumExpansions; ++I) {
4104 Sema::ArgPackSubstIndexRAII SubstIndex(SemaRef, I);
4105 LocalInstantiationScope Scope(SemaRef,
true);
4109 ExpandedParams.push_back(Expansion);
4115 IsExpandedParameterPack =
true;
4118 Sema::ArgPackSubstIndexRAII SubstIndex(SemaRef, std::nullopt);
4120 LocalInstantiationScope Scope(SemaRef,
true);
4127 LocalInstantiationScope Scope(SemaRef,
true);
4134 TemplateTemplateParmDecl *Param;
4135 if (IsExpandedParameterPack)
4138 D->
getDepth() - TemplateArgs.getNumSubstitutedLevels(),
4144 D->
getDepth() - TemplateArgs.getNumSubstitutedLevels(),
4157 TemplateArgumentLoc(SemaRef.Context, TemplateArgument(TName),
4166 SemaRef.CurrentInstantiationScope->InstantiatedLocal(D, Param);
4175 UsingDirectiveDecl *Inst
4185 if (!Owner->isFunctionOrMethod())
4186 Owner->addDecl(Inst);
4195 bool isFunctionScope = Owner->isFunctionOrMethod();
4197 for (
auto *Shadow : D->
shadows()) {
4201 NamedDecl *OldTarget = Shadow->getTargetDecl();
4202 if (
auto *CUSD = dyn_cast<ConstructorUsingShadowDecl>(Shadow))
4203 if (
auto *BaseShadow = CUSD->getNominatedBaseClassShadowDecl())
4204 OldTarget = BaseShadow;
4208 dyn_cast<UnresolvedUsingIfExistsDecl>(Shadow->getTargetDecl())) {
4210 SemaRef.Context, Owner, EmptyD->getLocation(), EmptyD->getDeclName());
4212 InstTarget = cast_or_null<NamedDecl>(SemaRef.FindInstantiatedDecl(
4213 Shadow->getLocation(), OldTarget, TemplateArgs));
4220 SemaRef.CheckUsingShadowDecl(Inst, InstTarget, *Lookup, PrevDecl))
4224 PrevDecl = cast_or_null<UsingShadowDecl>(SemaRef.FindInstantiatedDecl(
4225 Shadow->getLocation(), OldPrev, TemplateArgs));
4228 nullptr, Inst, InstTarget, PrevDecl);
4229 SemaRef.Context.setInstantiatedFromUsingShadowDecl(InstShadow, Shadow);
4231 if (isFunctionScope)
4232 SemaRef.CurrentInstantiationScope->InstantiatedLocal(Shadow, InstShadow);
4238Decl *TemplateDeclInstantiator::VisitUsingDecl(
UsingDecl *D) {
4259 if (
auto *RD = dyn_cast<CXXRecordDecl>(SemaRef.
CurContext))
4265 bool CheckRedeclaration = Owner->
isRecord();
4276 SS.
Adopt(QualifierLoc);
4277 if (CheckRedeclaration) {
4278 Prev.setHideTags(
false);
4311 EnumDecl *EnumD = cast_or_null<EnumDecl>(SemaRef.FindInstantiatedDecl(
4314 if (SemaRef.RequireCompleteEnumDecl(EnumD, EnumD->
getLocation()))
4317 TypeSourceInfo *TSI = SemaRef.SubstType(D->
getEnumType(), TemplateArgs,
4323 UsingEnumDecl *NewUD =
4327 SemaRef.Context.setInstantiatedFromUsingEnumDecl(NewUD, D);
4329 Owner->addDecl(NewUD);
4347Decl *TemplateDeclInstantiator::VisitConstructorUsingShadowDecl(
4353template <
typename T>
4354Decl *TemplateDeclInstantiator::instantiateUnresolvedUsingDecl(
4355 T *D,
bool InstantiatingPackElement) {
4357 if (D->isPackExpansion() && !InstantiatingPackElement) {
4358 SmallVector<UnexpandedParameterPack, 2> Unexpanded;
4359 SemaRef.collectUnexpandedParameterPacks(D->getQualifierLoc(), Unexpanded);
4360 SemaRef.collectUnexpandedParameterPacks(D->getNameInfo(), Unexpanded);
4365 bool RetainExpansion =
false;
4367 if (SemaRef.CheckParameterPacksForExpansion(
4368 D->getEllipsisLoc(), D->getSourceRange(), Unexpanded, TemplateArgs,
4369 true, Expand, RetainExpansion,
4375 assert(!RetainExpansion &&
4376 "should never need to retain an expansion for UsingPackDecl");
4381 Sema::ArgPackSubstIndexRAII SubstIndex(SemaRef, std::nullopt);
4382 return instantiateUnresolvedUsingDecl(D,
true);
4392 if (D->getDeclContext()->isFunctionOrMethod() && *NumExpansions > 1) {
4393 SemaRef.Diag(D->getEllipsisLoc(),
4394 diag::err_using_decl_redeclaration_expansion);
4399 SmallVector<NamedDecl*, 8> Expansions;
4400 for (
unsigned I = 0; I != *NumExpansions; ++I) {
4401 Sema::ArgPackSubstIndexRAII SubstIndex(SemaRef, I);
4402 Decl *Slice = instantiateUnresolvedUsingDecl(D,
true);
4412 auto *NewD = SemaRef.BuildUsingPackDecl(D, Expansions);
4414 SemaRef.CurrentInstantiationScope->InstantiatedLocal(D, NewD);
4418 UnresolvedUsingTypenameDecl *TD = dyn_cast<UnresolvedUsingTypenameDecl>(D);
4419 SourceLocation TypenameLoc = TD ? TD->
getTypenameLoc() : SourceLocation();
4421 NestedNameSpecifierLoc QualifierLoc
4422 = SemaRef.SubstNestedNameSpecifierLoc(D->getQualifierLoc(),
4428 SS.
Adopt(QualifierLoc);
4430 DeclarationNameInfo NameInfo
4431 = SemaRef.SubstDeclarationNameInfo(D->getNameInfo(), TemplateArgs);
4435 bool InstantiatingSlice =
4436 D->getEllipsisLoc().isValid() && SemaRef.ArgPackSubstIndex;
4437 SourceLocation EllipsisLoc =
4438 InstantiatingSlice ? SourceLocation() : D->getEllipsisLoc();
4441 NamedDecl *UD = SemaRef.BuildUsingDeclaration(
4442 nullptr, D->getAccess(), D->getUsingLoc(),
4443 TD, TypenameLoc, SS, NameInfo, EllipsisLoc,
4444 ParsedAttributesView(),
4445 true, IsUsingIfExists);
4447 SemaRef.InstantiateAttrs(TemplateArgs, D, UD);
4448 SemaRef.Context.setInstantiatedFromUsingDecl(UD, D);
4454Decl *TemplateDeclInstantiator::VisitUnresolvedUsingTypenameDecl(
4456 return instantiateUnresolvedUsingDecl(D);
4459Decl *TemplateDeclInstantiator::VisitUnresolvedUsingValueDecl(
4461 return instantiateUnresolvedUsingDecl(D);
4464Decl *TemplateDeclInstantiator::VisitUnresolvedUsingIfExistsDecl(
4466 llvm_unreachable(
"referring to unresolved decl out of UsingShadowDecl");
4470 SmallVector<NamedDecl*, 8> Expansions;
4472 if (NamedDecl *NewUD =
4473 SemaRef.FindInstantiatedDecl(D->
getLocation(), UD, TemplateArgs))
4474 Expansions.push_back(NewUD);
4479 auto *NewD = SemaRef.BuildUsingPackDecl(D, Expansions);
4481 SemaRef.CurrentInstantiationScope->InstantiatedLocal(D, NewD);
4485Decl *TemplateDeclInstantiator::VisitOMPThreadPrivateDecl(
4487 SmallVector<Expr *, 5> Vars;
4488 for (
auto *I : D->
varlist()) {
4489 Expr *Var = SemaRef.SubstExpr(I, TemplateArgs).get();
4491 Vars.push_back(Var);
4494 OMPThreadPrivateDecl *TD =
4495 SemaRef.OpenMP().CheckOMPThreadPrivateDecl(D->
getLocation(), Vars);
4505 SmallVector<Expr *, 5> Vars;
4506 for (
auto *I : D->
varlist()) {
4507 Expr *Var = SemaRef.SubstExpr(I, TemplateArgs).get();
4509 Vars.push_back(Var);
4512 OMPGroupPrivateDecl *TD =
4513 SemaRef.OpenMP().CheckOMPGroupPrivateDecl(D->
getLocation(), Vars);
4522 SmallVector<Expr *, 5> Vars;
4523 for (
auto *I : D->
varlist()) {
4524 Expr *Var = SemaRef.SubstExpr(I, TemplateArgs).get();
4526 Vars.push_back(Var);
4528 SmallVector<OMPClause *, 4> Clauses;
4531 OMPClause *IC =
nullptr;
4532 if (
auto *AC = dyn_cast<OMPAllocatorClause>(
C)) {
4533 ExprResult NewE = SemaRef.SubstExpr(AC->getAllocator(), TemplateArgs);
4536 IC = SemaRef.OpenMP().ActOnOpenMPAllocatorClause(
4537 NewE.
get(), AC->
getBeginLoc(), AC->getLParenLoc(), AC->getEndLoc());
4538 }
else if (
auto *AC = dyn_cast<OMPAlignClause>(
C)) {
4539 ExprResult NewE = SemaRef.SubstExpr(AC->getAlignment(), TemplateArgs);
4542 IC = SemaRef.OpenMP().ActOnOpenMPAlignClause(
4543 NewE.
get(), AC->
getBeginLoc(), AC->getLParenLoc(), AC->getEndLoc());
4548 Clauses.push_back(IC);
4560 "Requires directive cannot be instantiated within a dependent context");
4563Decl *TemplateDeclInstantiator::VisitOMPDeclareReductionDecl(
4566 const bool RequiresInstantiation =
4570 QualType SubstReductionType;
4571 if (RequiresInstantiation) {
4572 SubstReductionType = SemaRef.OpenMP().ActOnOpenMPDeclareReductionType(
4577 SubstReductionType = D->
getType();
4579 if (SubstReductionType.
isNull())
4583 bool IsCorrect =
true;
4585 std::pair<QualType, SourceLocation> ReductionTypes[] = {
4586 std::make_pair(SubstReductionType, D->
getLocation())};
4588 if (PrevDeclInScope && !PrevDeclInScope->isInvalidDecl()) {
4590 cast<Decl *>(*SemaRef.CurrentInstantiationScope->findInstantiationOf(
4593 auto DRD = SemaRef.OpenMP().ActOnOpenMPDeclareReductionDirectiveStart(
4597 SemaRef.CurrentInstantiationScope->InstantiatedLocal(D, NewDRD);
4598 Expr *SubstCombiner =
nullptr;
4599 Expr *SubstInitializer =
nullptr;
4602 SemaRef.OpenMP().ActOnOpenMPDeclareReductionCombinerStart(
4604 SemaRef.CurrentInstantiationScope->InstantiatedLocal(
4607 SemaRef.CurrentInstantiationScope->InstantiatedLocal(
4610 auto *ThisContext = dyn_cast_or_null<CXXRecordDecl>(Owner);
4611 Sema::CXXThisScopeRAII ThisScope(SemaRef, ThisContext, Qualifiers(),
4613 SubstCombiner = SemaRef.SubstExpr(Combiner, TemplateArgs).get();
4614 SemaRef.OpenMP().ActOnOpenMPDeclareReductionCombinerEnd(NewDRD,
4619 VarDecl *OmpPrivParm =
4620 SemaRef.OpenMP().ActOnOpenMPDeclareReductionInitializerStart(
4622 SemaRef.CurrentInstantiationScope->InstantiatedLocal(
4625 SemaRef.CurrentInstantiationScope->InstantiatedLocal(
4629 SubstInitializer = SemaRef.SubstExpr(
Init, TemplateArgs).get();
4633 IsCorrect = IsCorrect && OldPrivParm->hasInit();
4635 SemaRef.InstantiateVariableInitializer(OmpPrivParm, OldPrivParm,
4638 SemaRef.OpenMP().ActOnOpenMPDeclareReductionInitializerEnd(
4639 NewDRD, SubstInitializer, OmpPrivParm);
4641 IsCorrect = IsCorrect && SubstCombiner &&
4644 SubstInitializer) ||
4646 !SubstInitializer));
4648 (void)SemaRef.OpenMP().ActOnOpenMPDeclareReductionDirectiveEnd(
4657 const bool RequiresInstantiation =
4661 QualType SubstMapperTy;
4663 if (RequiresInstantiation) {
4664 SubstMapperTy = SemaRef.OpenMP().ActOnOpenMPDeclareMapperType(
4671 if (SubstMapperTy.
isNull())
4675 if (PrevDeclInScope && !PrevDeclInScope->isInvalidDecl()) {
4677 cast<Decl *>(*SemaRef.CurrentInstantiationScope->findInstantiationOf(
4680 bool IsCorrect =
true;
4681 SmallVector<OMPClause *, 6> Clauses;
4683 DeclarationNameInfo DirName;
4684 SemaRef.OpenMP().StartOpenMPDSABlock(llvm::omp::OMPD_declare_mapper, DirName,
4688 SemaRef.OpenMP().ActOnOpenMPDeclareMapperDirectiveVarDecl(
4690 SemaRef.CurrentInstantiationScope->InstantiatedLocal(
4693 auto *ThisContext = dyn_cast_or_null<CXXRecordDecl>(Owner);
4694 Sema::CXXThisScopeRAII ThisScope(SemaRef, ThisContext, Qualifiers(),
4699 SmallVector<Expr *, 4> NewVars;
4700 for (Expr *OE : OldC->varlist()) {
4701 Expr *
NE = SemaRef.SubstExpr(OE, TemplateArgs).get();
4706 NewVars.push_back(NE);
4710 NestedNameSpecifierLoc NewQualifierLoc =
4711 SemaRef.SubstNestedNameSpecifierLoc(OldC->getMapperQualifierLoc(),
4714 SS.
Adopt(NewQualifierLoc);
4715 DeclarationNameInfo NewNameInfo =
4716 SemaRef.SubstDeclarationNameInfo(OldC->getMapperIdInfo(), TemplateArgs);
4717 OMPVarListLocTy Locs(OldC->getBeginLoc(), OldC->getLParenLoc(),
4719 OMPClause *NewC = SemaRef.OpenMP().ActOnOpenMPMapClause(
4720 OldC->getIteratorModifier(), OldC->getMapTypeModifiers(),
4721 OldC->getMapTypeModifiersLoc(), SS, NewNameInfo, OldC->getMapType(),
4722 OldC->isImplicitMapType(), OldC->getMapLoc(), OldC->getColonLoc(),
4724 Clauses.push_back(NewC);
4726 SemaRef.OpenMP().EndOpenMPDSABlock(
nullptr);
4731 VN, D->
getAccess(), MapperVarRef.
get(), Clauses, PrevDeclInScope);
4733 SemaRef.CurrentInstantiationScope->InstantiatedLocal(D, NewDMD);
4737Decl *TemplateDeclInstantiator::VisitOMPCapturedExprDecl(
4739 llvm_unreachable(
"Should not be met in templates");
4750 Owner->addDecl(Inst);
4759 llvm_unreachable(
"There are only CXXRecordDecls in C++");
4763TemplateDeclInstantiator::VisitClassTemplateSpecializationDecl(
4770 "can only instantiate an explicit specialization "
4771 "for a member class template");
4775 ClassTemplateDecl *InstClassTemplate =
4776 cast_or_null<ClassTemplateDecl>(SemaRef.FindInstantiatedDecl(
4778 if (!InstClassTemplate)
4783 TemplateArgumentListInfo InstTemplateArgs;
4784 if (
const ASTTemplateArgumentListInfo *TemplateArgsInfo =
4786 InstTemplateArgs.
setLAngleLoc(TemplateArgsInfo->getLAngleLoc());
4787 InstTemplateArgs.
setRAngleLoc(TemplateArgsInfo->getRAngleLoc());
4789 if (SemaRef.SubstTemplateArguments(TemplateArgsInfo->arguments(),
4790 TemplateArgs, InstTemplateArgs))
4796 Sema::CheckTemplateArgumentInfo CTAI;
4797 if (SemaRef.CheckTemplateArgumentList(
4798 InstClassTemplate, D->
getLocation(), InstTemplateArgs,
4805 llvm::FoldingSetInsertToken InsertToken;
4806 ClassTemplateSpecializationDecl *PrevDecl =
4814 SemaRef.CheckSpecializationInstantiationRedecl(D->
getLocation(),
4836 SemaRef.Diag(D->
getLocation(), diag::err_redefinition) << PrevDecl;
4838 diag::note_previous_definition);
4843 ClassTemplateSpecializationDecl *InstD =
4865 Owner->addDecl(InstD);
4872 SemaRef.InstantiateClass(D->
getLocation(), InstD, D, TemplateArgs,
4886 "A template specialization without specialized template?");
4889 cast_or_null<VarTemplateDecl>(SemaRef.FindInstantiatedDecl(
4891 if (!InstVarTemplate)
4897 VarTemplateArgsInfo.
setLAngleLoc(TemplateArgsInfo->getLAngleLoc());
4898 VarTemplateArgsInfo.
setRAngleLoc(TemplateArgsInfo->getRAngleLoc());
4900 if (SemaRef.SubstTemplateArguments(TemplateArgsInfo->arguments(),
4901 TemplateArgs, VarTemplateArgsInfo))
4907 if (SemaRef.CheckTemplateArgumentList(
4908 InstVarTemplate, D->
getLocation(), VarTemplateArgsInfo,
4914 llvm::FoldingSetInsertToken InsertToken;
4921 if (PrevDecl && SemaRef.CheckSpecializationInstantiationRedecl(
4929 VTSD->setTemplateArgsAsWritten(VarTemplateArgsInfo);
4949 SemaRef.
Diag(D->
getLocation(), diag::err_variable_instantiates_to_function)
4959 llvm::FoldingSetInsertToken InsertToken;
4960 VarTemplate->findSpecialization(Converted, InsertToken);
4964 if (SemaRef.getLangOpts().OpenCL)
4965 SemaRef.deduceOpenCLAddressSpace(Var);
4971 SemaRef.BuildVariableInstantiation(Var, D, TemplateArgs, LateAttrs, Owner,
4972 StartingScope,
false, PrevDecl);
4978 llvm_unreachable(
"@defs is not supported in Objective-C++");
4988 LocalInstantiationScope Scope(SemaRef,
true);
4989 SmallVector<TemplateParameterList *, 1> InstTPLs;
4999 if (!Substituted || Substituted->empty())
5001 ToFriend = Substituted->TypeInfo;
5002 ToTemplate = Substituted->
Template;
5004 if (
auto *InstTemplate =
5010 if (
auto *InstFriendDecl =
5012 ToFriend = InstFriendDecl;
5019 InstTPLs, {}, ToTemplate);
5022 Owner->addDecl(InstFriend);
5027 llvm_unreachable(
"Concept definitions cannot reside inside a template");
5030Decl *TemplateDeclInstantiator::VisitImplicitConceptSpecializationDecl(
5032 llvm_unreachable(
"Concept specializations cannot reside inside a template");
5042 llvm_unreachable(
"Unexpected decl");
5053 SubstD = Instantiator.Visit(D);
5067 T = SemaRef.Context.getFunctionType(
5068 SemaRef.Context.BoolTy, FPT->getParamTypes(), FPT->getExtProtoInfo());
5077 SemaRef.Context.getTrivialTypeSourceInfo(
T, Orig->
getEndLoc());
5079 assert(OldLoc &&
"type of function is not a function type?");
5081 for (
unsigned I = 0, N = OldLoc.getNumParams(); I != N; ++I)
5082 NewLoc.
setParam(I, OldLoc.getParam(I));
5087 SemaRef.Context.DeclarationNames.getCXXOperatorName(OO_EqualEqual));
5092 if (Spaceship->isInvalidDecl())
5104 if (
auto *MD = dyn_cast<CXXMethodDecl>(Spaceship)) {
5109 assert(Spaceship->getFriendObjectKind() &&
5110 "defaulted spaceship is neither a member nor a friend");
5124 return cast_or_null<FunctionDecl>(R);
5138 unsigned N = L->
size();
5142 for (
auto &P : *L) {
5144 Params.push_back(D);
5153 if (InstRequiresClause && EvaluateConstraints) {
5155 SemaRef.SubstConstraintExpr(InstRequiresClause, TemplateArgs);
5158 InstRequiresClause = E.
get();
5177 if (
Expr *RequiresClause = L->getRequiresClause()) {
5179 SemaRef.SubstConstraintExprWithoutSatisfaction(RequiresClause,
5181 if (!InstRequiresClause.
isUsable())
5190 InstTPLs.push_back(InstParams);
5198 bool EvaluateConstraints) {
5237 if (SemaRef.SubstTemplateArguments(TemplArgInfo->
arguments(), TemplateArgs,
5244 if (SemaRef.CheckTemplateArgumentList(
5245 ClassTemplate, PartialSpec->
getLocation(), InstTemplateArgs,
5251 if (SemaRef.CheckTemplatePartialSpecializationArgs(
5258 llvm::FoldingSetInsertToken InsertToken;
5261 InstParams, InsertToken);
5266 SemaRef.Context, PartialSpec->
getTagKind(), Owner,
5297 diag::err_partial_spec_redeclared)
5299 SemaRef.Diag(PrevDecl->
getLocation(), diag::note_prev_partial_spec_here)
5300 << SemaRef.Context.getCanonicalTagType(PrevDecl);
5305 SemaRef.CheckTemplatePartialSpecialization(InstPartialSpec);
5311 return InstPartialSpec;
5347 if (SemaRef.SubstTemplateArguments(TemplArgInfo->
arguments(), TemplateArgs,
5355 InstTemplateArgs, {},
5360 if (SemaRef.CheckTemplatePartialSpecializationArgs(
5367 llvm::FoldingSetInsertToken InsertToken;
5370 InstParams, InsertToken);
5381 diag::err_variable_instantiates_to_function)
5418 diag::err_var_partial_spec_redeclared)
5421 diag::note_var_prev_partial_spec_here);
5425 SemaRef.CheckTemplatePartialSpecialization(InstPartialSpec);
5429 VarTemplate->AddPartialSpecialization(InstPartialSpec, {});
5431 SemaRef.BuildVariableInstantiation(InstPartialSpec, PartialSpec, TemplateArgs,
5432 LateAttrs, Owner, StartingScope);
5434 return InstPartialSpec;
5440 assert(OldTInfo &&
"substituting function without type source info");
5441 assert(Params.empty() &&
"parameter vector is non-empty at start");
5447 ThisTypeQuals =
Method->getFunctionObjectParameterType().getQualifiers();
5452 ThisContext, ThisTypeQuals, EvaluateConstraints);
5458 if (NewTInfo != OldTInfo) {
5462 unsigned NewIdx = 0;
5463 for (
unsigned OldIdx = 0, NumOldParams = OldProtoLoc.getNumParams();
5464 OldIdx != NumOldParams; ++OldIdx) {
5465 ParmVarDecl *OldParam = OldProtoLoc.getParam(OldIdx);
5473 NumArgumentsInExpansion =
5474 SemaRef.getNumArgumentsInExpansion(OldParam->
getType(),
5476 if (!NumArgumentsInExpansion) {
5480 Params.push_back(NewParam);
5481 Scope->InstantiatedLocal(OldParam, NewParam);
5484 Scope->MakeInstantiatedLocalArgPack(OldParam);
5485 for (
unsigned I = 0; I != *NumArgumentsInExpansion; ++I) {
5487 Params.push_back(NewParam);
5488 Scope->InstantiatedLocalPackArg(OldParam, NewParam);
5498 for (
unsigned i = 0, i_end = OldProtoLoc.getNumParams(); i != i_end;
5502 Params.push_back(SemaRef.BuildParmVarDeclForTypedef(
5508 OldParam, TemplateArgs, 0,
5510 false, EvaluateConstraints);
5513 Params.push_back(Parm);
5530 TemplateArgs, ParamTypes, &Params,
5543 for (
auto *
decl : PatternDecl->
decls()) {
5550 auto it = llvm::find_if(
Function->decls(), [&](
Decl *inst) {
5551 VarDecl *InstVD = dyn_cast<VarDecl>(inst);
5552 return InstVD && InstVD->isLocalVarDecl() &&
5553 InstVD->getIdentifier() == II;
5559 Scope.InstantiatedLocal(VD, *it);
5566bool Sema::addInstantiatedParametersToScope(
5570 unsigned FParamIdx = 0;
5571 for (
unsigned I = 0, N = PatternDecl->
getNumParams(); I != N; ++I) {
5572 const ParmVarDecl *PatternParam = PatternDecl->
getParamDecl(I);
5575 assert(FParamIdx < Function->getNumParams());
5602 if (NumArgumentsInExpansion) {
5603 QualType PatternType =
5604 PatternParam->
getType()->
castAs<PackExpansionType>()->getPattern();
5605 for (
unsigned Arg = 0; Arg < *NumArgumentsInExpansion; ++Arg) {
5609 Sema::ArgPackSubstIndexRAII SubstIndex(*
this, Arg);
5629 assert(Param->hasUninstantiatedDefaultArg());
5661 false, std::nullopt,
5670 L->DefaultArgumentInstantiated(Param);
5683 if (AlreadyInstantiating) {
5686 Diag(PointOfInstantiation, diag::err_exception_spec_cycle) <<
Decl;
5708 false, std::nullopt,
5741 SemaRef.Context.setManglingNumber(
New,
5742 SemaRef.Context.getManglingNumber(Tmpl));
5755 ActiveInstType &ActiveInst = SemaRef.CodeSynthesisContexts.back();
5756 if (ActiveInst.Kind == ActiveInstType::ExplicitTemplateArgumentSubstitution ||
5757 ActiveInst.Kind == ActiveInstType::DeducedTemplateArgumentSubstitution) {
5759 SemaRef.CurrentSFINAEContext =
nullptr;
5760 ActiveInst.Kind = ActiveInstType::TemplateInstantiation;
5761 ActiveInst.Entity =
New;
5766 assert(Proto &&
"Function template without prototype?");
5775 if (SemaRef.getLangOpts().CPlusPlus11 &&
5790 assert(NewProto &&
"Template instantiation without function prototype?");
5795 New->setType(SemaRef.Context.getFunctionType(
5799 SemaRef.SubstExceptionSpec(
New, Proto, TemplateArgs);
5808 LateAttrs, StartingScope);
5810 SemaRef.inferLifetimeBoundAttribute(
New);
5831 New->setVirtualAsWritten(
true);
5842 Lookups.reserve(DFI->getUnqualifiedLookups().size());
5843 bool AnyChanged =
false;
5845 NamedDecl *D = SemaRef.FindInstantiatedDecl(
New->getLocation(),
5846 DA.getDecl(), TemplateArgs);
5849 AnyChanged |= (D != DA.getDecl());
5853 New->setDefaultedOrDeletedInfo(
5855 SemaRef.Context, Lookups, DFI->getFPFeatures(),
5856 DFI->getDeletedMessage())
5883 bool DefinitionRequired,
5891 Function->getTemplateSpecializationKindForInstantiation();
5898 !DefinitionRequired)
5903 if (
Function->isDefined(ExistingDefn,
5918 assert(!AlreadyInstantiating &&
"should have been caught by caller");
5923 assert(PatternDecl &&
"instantiating a non-template");
5926 Stmt *Pattern =
nullptr;
5928 Pattern = PatternDef->
getBody(PatternDef);
5929 PatternDecl = PatternDef;
5931 PatternDef =
nullptr;
5935 bool Unreachable =
false;
5940 Function->getInstantiatedFromMemberFunction(), PatternDecl,
5942 DefinitionRequired, &Unreachable)) {
5943 if (DefinitionRequired)
5946 (
Function->isConstexpr() && !Recursive)) {
5950 Function->setInstantiationIsPending(
true);
5953 if (llvm::isTimeTraceVerbose()) {
5954 llvm::timeTraceAddInstantEvent(
"DeferInstantiation", [&] {
5956 llvm::raw_string_ostream
OS(Name);
5965 Diag(PointOfInstantiation, diag::warn_func_template_missing)
5971 diag::note_unreachable_template_decl);
5975 Diag(PointOfInstantiation, diag::note_inst_declaration_hint)
5987 Function->setInstantiationIsPending(
true);
5989 std::make_pair(
Function, PointOfInstantiation));
5993 llvm::TimeTraceScope TimeScope(
"InstantiateFunction", [&]() {
5994 llvm::TimeTraceMetadata M;
5995 llvm::raw_string_ostream
OS(M.Detail);
5998 if (llvm::isTimeTraceVerbose()) {
6001 M.Line =
SourceMgr.getExpansionLineNumber(Loc);
6027 "missing LateParsedTemplate");
6029 Pattern = PatternDecl->
getBody(PatternDecl);
6036 "unexpected kind of function template definition");
6051 for (
auto *D =
Function->getMostRecentDecl(); ;
6053 D->setImplicitlyInline();
6064 "instantiating function definition");
6068 Function->setVisibleDespiteOwningModule();
6094 auto NameLocPointsToPattern = [&] {
6105 return PatternNameLoc;
6115 return PatternNameLoc;
6123 assert(PatternTSI &&
"Pattern is supposed to have an associated TSI");
6131 Function->setDeclarationNameLoc(NameLocPointsToPattern());
6139 ThisContext =
Method->getParent();
6140 ThisTypeQuals =
Method->getMethodQualifiers();
6150 bool MergeWithParentScope =
false;
6152 MergeWithParentScope =
6153 Rec->isLocalClass() && !
Function->isFunctionTemplateSpecialization();
6156 auto RebuildTypeSourceInfoForDefaultSpecialMembers = [&]() {
6162 "Special member needs to be defaulted");
6170 auto *NewRec = dyn_cast<CXXRecordDecl>(
Function->getDeclContext());
6171 const auto *PatternRec =
6173 if (!NewRec || !PatternRec)
6175 if (!PatternRec->isLambda())
6178 struct SpecialMemberTypeInfoRebuilder
6198 getDerived().TransformDecl(TL.
getNameLoc(),
T->getDecl()));
6200 return Base::TransformRecordType(TLB, TL);
6214 } IR{*
this, PatternRec, NewRec};
6217 assert(NewSI &&
"Type Transform failed?");
6219 Function->setTypeSourceInfo(NewSI);
6223 assert(NewParmSI &&
"Type transformation failed.");
6229 RebuildTypeSourceInfoForDefaultSpecialMembers();
6233 std::optional<ArrayRef<TemplateArgument>> Innermost;
6234 if (
auto *Primary =
Function->getPrimaryTemplate();
6237 Function->getTemplateSpecializationKind() !=
6239 auto It = llvm::find_if(Primary->redecls(),
6241 return cast<FunctionTemplateDecl>(RTD)
6242 ->isCompatibleWithDefinition();
6244 assert(It != Primary->redecls().end() &&
6245 "Should't get here without a definition");
6247 ->getTemplatedDecl()
6251 DC = (*It)->getLexicalDeclContext();
6252 Innermost.emplace(
Function->getTemplateSpecializationArgs()->asArray());
6255 Function, DC,
false, Innermost,
false, PatternDecl);
6273 if (addInstantiatedParametersToScope(
Function, PatternDecl,
Scope,
6289 if (
Context.getTargetInfo().getCXXABI().isMicrosoft() &&
6290 Ctor->isDefaultConstructor()) {
6291 if (DLLExportAttr *
Attr = Ctor->getAttr<DLLExportAttr>())
6297 Body =
SubstStmt(Pattern, TemplateArgs);
6308 checkReferenceToTULocalFromOtherTU(
Function, PointOfInstantiation);
6314 Listener->FunctionDefinitionInstantiated(
Function);
6324 bool ShouldSkipCG = [&] {
6325 auto *RD = dyn_cast<CXXRecordDecl>(
Function->getParent());
6326 if (!RD || !RD->isLambda())
6330 return Context.isUnevaluated() ||
Context.isImmediateFunctionContext();
6333 if (!ShouldSkipCG) {
6340 LocalInstantiations.
perform();
6342 GlobalInstantiations.perform();
6367 bool IsMemberSpec =
false;
6369 if (
auto *PartialSpec =
6370 dyn_cast<VarTemplatePartialSpecializationDecl>(FromVar)) {
6371 assert(PartialSpecArgs);
6372 IsMemberSpec = PartialSpec->isMemberSpecialization();
6374 PartialSpec, PartialSpecArgs->
asArray(),
false);
6377 IsMemberSpec =
VarTemplate->isMemberSpecialization();
6397 "don't have a definition to instantiate from");
6426 bool InstantiatingVarTemplate,
6430 bool InstantiatingVarTemplatePartialSpec =
6435 bool InstantiatingSpecFromTemplate =
6461 if (OldVar->
isUsed(
false))
6486 }
else if (PrevDeclForVarTemplateSpecialization) {
6487 Previous.addDecl(PrevDeclForVarTemplateSpecialization);
6491 if (!InstantiatingVarTemplate) {
6509 !InstantiatingSpecFromTemplate)
6516 dyn_cast<VarTemplateSpecializationDecl>(OldVar)) {
6524 Context.setManglingNumber(NewVar,
Context.getManglingNumber(OldVar));
6525 Context.setStaticLocalNumber(NewVar,
Context.getStaticLocalNumber(OldVar));
6528 if (InstantiatingVarTemplate || InstantiatingVarTemplatePartialSpec) {
6533 }
else if (InstantiatingSpecFromTemplate ||
6555 L->VariableDefinitionInstantiated(Var);
6585 if (!
Init.isInvalid()) {
6588 if (Var->
hasAttr<DLLImportAttr>() &&
6591 }
else if (InitExpr) {
6627 bool DefinitionRequired,
bool AtEndOfTU) {
6639 if (AlreadyInstantiating)
6644 assert(PatternDecl &&
"no pattern for templated variable");
6649 dyn_cast<VarTemplateSpecializationDecl>(Var);
6660 (PatternDecl = PatternDecl->
getFirstDecl())->hasInit() &&
6669 "instantiating variable initializer");
6680 Recursive, AtEndOfTU);
6689 PreviousContext.
pop();
6693 LocalInstantiations.
perform();
6695 GlobalInstantiations.
perform();
6699 "not a static data member?");
6708 if (!Def && !DefinitionRequired) {
6715 Diag(PointOfInstantiation, diag::warn_var_template_missing)
6719 Diag(PointOfInstantiation, diag::note_inst_declaration_hint) << Var;
6730 PatternDecl, Def, TSK,
6731 DefinitionRequired))
6748 struct PassToConsumerRAII {
6755 ~PassToConsumerRAII() {
6756 Consumer.HandleCXXStaticMemberVarInstantiation(Var);
6758 } PassToConsumerRAII(
Consumer, Var);
6765 PointOfInstantiation);
6774 "instantiating variable definition");
6796 }
else if (!VarSpec) {
6829 dyn_cast<VarTemplatePartialSpecializationDecl *>(PatternPtr))
6841 PreviousContext.
pop();
6844 PassToConsumerRAII.Var = Var;
6853 LocalInstantiations.
perform();
6855 GlobalInstantiations.
perform();
6867 for (
const auto *
Init : Tmpl->
inits()) {
6870 if (!
Init->isWritten())
6875 if (
Init->isPackExpansion()) {
6877 TypeLoc BaseTL =
Init->getTypeSourceInfo()->getTypeLoc();
6881 bool ShouldExpand =
false;
6882 bool RetainExpansion =
false;
6886 TemplateArgs,
true, ShouldExpand,
6887 RetainExpansion, NumExpansions)) {
6889 New->setInvalidDecl();
6892 assert(ShouldExpand &&
"Partial instantiation of base initializer?");
6895 for (
unsigned I = 0; I != *NumExpansions; ++I) {
6909 Init->getSourceLocation(),
6910 New->getDeclName());
6918 BaseTInfo, TempInit.
get(),
6926 NewInits.push_back(NewInit.
get());
6941 if (
Init->isDelegatingInitializer() ||
Init->isBaseInitializer()) {
6944 Init->getSourceLocation(),
6945 New->getDeclName());
6948 New->setInvalidDecl();
6952 if (
Init->isBaseInitializer())
6954 New->getParent(), EllipsisLoc);
6958 }
else if (
Init->isMemberInitializer()) {
6960 Init->getMemberLocation(),
6965 New->setInvalidDecl();
6970 Init->getSourceLocation());
6971 }
else if (
Init->isIndirectMemberInitializer()) {
6974 Init->getMemberLocation(),
6975 Init->getIndirectMember(), TemplateArgs));
6977 if (!IndirectMember) {
6979 New->setInvalidDecl();
6984 Init->getSourceLocation());
6989 New->setInvalidDecl();
6991 NewInits.push_back(NewInit.
get());
7010 Instance = Instance->getCanonicalDecl();
7011 if (Pattern == Instance)
return true;
7012 Instance = Instance->getInstantiatedFromMemberTemplate();
7023 Instance = Instance->getCanonicalDecl();
7024 if (Pattern == Instance)
return true;
7025 Instance = Instance->getInstantiatedFromMemberTemplate();
7038 Instance->getCanonicalDecl());
7039 if (Pattern == Instance)
7041 Instance = Instance->getInstantiatedFromMember();
7052 Instance = Instance->getCanonicalDecl();
7053 if (Pattern == Instance)
return true;
7054 Instance = Instance->getInstantiatedFromMemberClass();
7065 Instance = Instance->getCanonicalDecl();
7066 if (Pattern == Instance)
return true;
7067 Instance = Instance->getInstantiatedFromMemberFunction();
7078 Instance = Instance->getCanonicalDecl();
7079 if (Pattern == Instance)
return true;
7080 Instance = Instance->getInstantiatedFromMemberEnum();
7107 bool OtherIsPackExpansion;
7109 if (
auto *OtherUUD = dyn_cast<T>(
Other)) {
7110 OtherIsPackExpansion = OtherUUD->isPackExpansion();
7112 }
else if (
auto *OtherUPD = dyn_cast<UsingPackDecl>(
Other)) {
7113 OtherIsPackExpansion =
true;
7114 OtherFrom = OtherUPD->getInstantiatedFromUsingDecl();
7115 }
else if (
auto *OtherUD = dyn_cast<UsingDecl>(
Other)) {
7116 OtherIsPackExpansion =
false;
7121 return Pattern->isPackExpansion() == OtherIsPackExpansion &&
7127 assert(Instance->isStaticDataMember());
7132 Instance = Instance->getCanonicalDecl();
7133 if (Pattern == Instance)
return true;
7134 Instance = Instance->getInstantiatedFromStaticDataMember();
7143 if (
auto *UUD = dyn_cast<UnresolvedUsingTypenameDecl>(D))
7146 if (
auto *UUD = dyn_cast<UnresolvedUsingValueDecl>(D))
7152 if (
auto *
Record = dyn_cast<CXXRecordDecl>(
Other))
7155 if (
auto *Function = dyn_cast<FunctionDecl>(
Other))
7158 if (
auto *
Enum = dyn_cast<EnumDecl>(
Other))
7161 if (
auto *Var = dyn_cast<VarDecl>(
Other))
7165 if (
auto *Temp = dyn_cast<ClassTemplateDecl>(
Other))
7168 if (
auto *Temp = dyn_cast<FunctionTemplateDecl>(
Other))
7171 if (
auto *PartialSpec =
7172 dyn_cast<ClassTemplatePartialSpecializationDecl>(
Other))
7176 if (
auto *Field = dyn_cast<FieldDecl>(
Other)) {
7177 if (!Field->getDeclName()) {
7184 if (
auto *Using = dyn_cast<UsingDecl>(
Other))
7187 if (
auto *Shadow = dyn_cast<UsingShadowDecl>(
Other))
7194template<
typename ForwardIterator>
7197 ForwardIterator first,
7198 ForwardIterator last) {
7199 for (; first != last; ++first)
7208 if (
NamedDecl *D = dyn_cast<NamedDecl>(DC)) {
7210 return cast_or_null<DeclContext>(ID);
7225 return cast<Decl>(DC)->getTemplateDepth() > Level;
7230 bool FindingInstantiatedContext) {
7267 if (
Decl *FD = dyn_cast<Decl *>(*
Found)) {
7268 if (
auto *BD = dyn_cast<BindingDecl>(FD);
7276 "found declaration pack but not pack expanding");
7306 bool NeedInstantiate =
false;
7308 NeedInstantiate = RD->isLocalClass();
7311 NeedInstantiate =
true;
7314 if (NeedInstantiate) {
7325 assert(Inst &&
"Failed to instantiate label??");
7332 if (!
Record->isDependentContext())
7341 dyn_cast<ClassTemplateSpecializationDecl>(
Record))
7342 ClassTemplate = Spec->getSpecializedTemplate()->getCanonicalDecl();
7353 if (
CXXRecordDecl *InstRecord = dyn_cast<CXXRecordDecl>(DC)) {
7357 = dyn_cast<ClassTemplateSpecializationDecl>(InstRecord)){
7377 auto *Guide = dyn_cast<CXXDeductionGuideDecl>(FD);
7378 if (Guide && Guide->isImplicit()) {
7386 Unpacked = Arg.pack_elements();
7399 if (
T.isNull() ||
T->containsErrors())
7409 assert(
SemaRef.RebuildingImmediateInvocation ||
7422 if (FindingInstantiatedContext &&
7425 Diag(Loc, diag::err_specialization_not_primary_template)
7448 if (!ParentDependsOnArgs)
7462 bool IsBeingInstantiated =
false;
7463 if (
auto *Spec = dyn_cast<CXXRecordDecl>(ParentDC)) {
7464 if (!Spec->isDependentContext()) {
7465 if (Spec->isEntityBeingDefined())
7466 IsBeingInstantiated =
true;
7468 diag::err_incomplete_type))
7471 ParentDC = Spec->getDefinitionOrSelf();
7510 }
else if (IsBeingInstantiated) {
7516 Diag(Loc, diag::err_member_not_yet_instantiated)
7529 Diag(Loc, diag::err_enumerator_does_not_exist)
7533 <<
Context.getCanonicalTagType(Spec);
7536 llvm_unreachable(
"Unable to find instantiation of declaration!");
7547 std::deque<PendingImplicitInstantiation> DelayedImplicitInstantiations;
7552 bool LocalInstantiation =
false;
7559 LocalInstantiation =
true;
7564 bool DefinitionRequired =
Function->getTemplateSpecializationKind() ==
7569 [
this, Inst, DefinitionRequired, AtEndOfTU](
FunctionDecl *CurFD) {
7571 DefinitionRequired, AtEndOfTU);
7577 DefinitionRequired, AtEndOfTU);
7579 Function->setInstantiationIsPending(
false);
7582 if (!LocalOnly &&
LangOpts.PCHInstantiateTemplates &&
7584 DelayedImplicitInstantiations.push_back(Inst);
7585 else if (!AtEndOfTU &&
Function->instantiationIsPending() &&
7586 !LocalInstantiation)
7587 DelayedImplicitInstantiations.push_back(Inst);
7596 "Not a static data member, nor a variable template"
7597 " specialization?");
7609 llvm_unreachable(
"Cannot instantitiate an undeclared specialization.");
7624 "instantiating variable definition");
7631 DefinitionRequired, AtEndOfTU);
7634 if (!DelayedImplicitInstantiations.empty())
7640 for (
auto *DD : Pattern->
ddiags()) {
7641 switch (DD->getKind()) {
Defines the clang::ASTContext interface.
Defines the C++ template declaration subclasses.
Defines the clang::Expr interface and subclasses for C++ expressions.
Result
Implement __builtin_bit_cast and related operations.
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)
static NamedDecl * findInstantiationOf(ASTContext &Ctx, NamedDecl *D, ForwardIterator first, ForwardIterator last)
static void instantiateDependentAMDGPUMaxNumWorkGroupsAttr(Sema &S, const MultiLevelTemplateArgumentList &TemplateArgs, const AMDGPUMaxNumWorkGroupsAttr &Attr, Decl *New)
static void instantiateDependentAMDGPUFlatWorkGroupSizeAttr(Sema &S, const MultiLevelTemplateArgumentList &TemplateArgs, const AMDGPUFlatWorkGroupSizeAttr &Attr, Decl *New)
static void instantiateDependentCUDAClusterDimsAttr(Sema &S, const MultiLevelTemplateArgumentList &TemplateArgs, const CUDAClusterDimsAttr &Attr, Decl *New)
static void sharedInstantiateConstructorDestructorAttr(Sema &S, const MultiLevelTemplateArgumentList &TemplateArgs, const Attr *A, Decl *New, ASTContext &C)
static void instantiateDependentDiagnoseIfAttr(Sema &S, const MultiLevelTemplateArgumentList &TemplateArgs, const DiagnoseIfAttr *DIA, const Decl *Tmpl, FunctionDecl *New)
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...
static std::optional< SubstitutedFriend > SubstFriendTemplateType(Sema &SemaRef, TypeSourceInfo *TSI, TemplateName FriendTemplate, const MultiLevelTemplateArgumentList &TemplateArgs, SourceLocation Loc, DeclarationName Entity)
static bool isRelevantAttr(Sema &S, const Decl *D, const Attr *A)
Determine whether the attribute A might be relevant to the declaration D.
static std::optional< TemplateName > LookupFriendTemplateName(Sema &SemaRef, NestedNameSpecifierLoc QualifierLoc, DeclarationName Name, SourceLocation NameLoc, bool HasTemplateKeyword, bool RequireClassTemplate)
static void instantiateDependentReqdWorkGroupSizeAttr(Sema &S, const MultiLevelTemplateArgumentList &TemplateArgs, const ReqdWorkGroupSizeAttr &Attr, Decl *New)
#define CLAUSE_NOT_ON_DECLS(CLAUSE_NAME)
static void instantiateDependentMallocSpanAttr(Sema &S, const MallocSpanAttr *Attr, Decl *New)
static bool isDependentContextAtLevel(DeclContext *DC, unsigned Level)
Determine whether the given context is dependent on template parameters at level Level or below.
static void instantiateDependentModeAttr(Sema &S, const MultiLevelTemplateArgumentList &TemplateArgs, const ModeAttr &Attr, Decl *New)
static void instantiateDependentCUDALaunchBoundsAttr(Sema &S, const MultiLevelTemplateArgumentList &TemplateArgs, const CUDALaunchBoundsAttr &Attr, Decl *New)
static bool isDeclWithinFunction(const Decl *D)
static void instantiateDependentAssumeAlignedAttr(Sema &S, const MultiLevelTemplateArgumentList &TemplateArgs, const AssumeAlignedAttr *Aligned, Decl *New)
static bool SubstQualifier(Sema &SemaRef, const DeclT *OldDecl, DeclT *NewDecl, const MultiLevelTemplateArgumentList &TemplateArgs)
static void collectUnexpandedParameterPacks(Sema &S, TemplateParameterList *Params, SmallVectorImpl< UnexpandedParameterPack > &Unexpanded)
static void instantiateDependentHLSLParamModifierAttr(Sema &S, const MultiLevelTemplateArgumentList &TemplateArgs, const HLSLParamModifierAttr *Attr, const Decl *Old, Decl *New)
static DeclT * getPreviousDeclForInstantiation(DeclT *D)
Get the previous declaration of a declaration for the purposes of template instantiation.
static Expr * instantiateDependentFunctionAttrCondition(Sema &S, const MultiLevelTemplateArgumentList &TemplateArgs, const Attr *A, Expr *OldCond, const Decl *Tmpl, FunctionDecl *New)
static bool isInstantiationOf(ClassTemplateDecl *Pattern, ClassTemplateDecl *Instance)
static void instantiateDependentAllocAlignAttr(Sema &S, const MultiLevelTemplateArgumentList &TemplateArgs, const AllocAlignAttr *Align, Decl *New)
static bool isInstantiationOfStaticDataMember(VarDecl *Pattern, VarDecl *Instance)
static void instantiateOMPDeclareSimdDeclAttr(Sema &S, const MultiLevelTemplateArgumentList &TemplateArgs, const OMPDeclareSimdDeclAttr &Attr, Decl *New)
Instantiation of 'declare simd' attribute and its arguments.
static void instantiateDependentSYCLKernelAttr(Sema &S, const MultiLevelTemplateArgumentList &TemplateArgs, const SYCLKernelAttr &Attr, Decl *New)
static void instantiateDependentAlignValueAttr(Sema &S, const MultiLevelTemplateArgumentList &TemplateArgs, const AlignValueAttr *Aligned, Decl *New)
static void instantiateDependentAlignedAttr(Sema &S, const MultiLevelTemplateArgumentList &TemplateArgs, const AlignedAttr *Aligned, Decl *New, bool IsPackExpansion)
static void instantiateOMPDeclareVariantAttr(Sema &S, const MultiLevelTemplateArgumentList &TemplateArgs, const OMPDeclareVariantAttr &Attr, Decl *New)
Instantiation of 'declare variant' attribute and its arguments.
static void instantiateDependentEnableIfAttr(Sema &S, const MultiLevelTemplateArgumentList &TemplateArgs, const EnableIfAttr *EIA, const Decl *Tmpl, FunctionDecl *New)
static void instantiateDependentAnnotationAttr(Sema &S, const MultiLevelTemplateArgumentList &TemplateArgs, const AnnotateAttr *Attr, Decl *New)
static Sema::RetainOwnershipKind attrToRetainOwnershipKind(const Attr *A)
static void instantiateDependentOpenACCRoutineDeclAttr(Sema &S, const MultiLevelTemplateArgumentList &TemplateArgs, const OpenACCRoutineDeclAttr *OldAttr, const Decl *Old, Decl *New)
static bool isInstantiationOfUnresolvedUsingDecl(T *Pattern, Decl *Other, ASTContext &Ctx)
static bool isInvalid(LocType Loc, bool *Invalid)
Defines the SourceManager interface.
Defines the clang::TypeLoc interface and its subclasses.
bool anyScoreOrCondition(llvm::function_ref< bool(Expr *&, bool)> Cond)
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
TemplateName getDependentTemplateName(const DependentTemplateStorage &Name) const
Retrieve the template name that represents a dependent template name such as MetaFun::template operat...
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.
TypeSourceInfo * getTrivialTypeSourceInfo(QualType T, SourceLocation Loc=SourceLocation()) const
Allocate a TypeSourceInfo where all locations have been initialized to a given location,...
TemplateName getQualifiedTemplateName(NestedNameSpecifier Qualifier, bool TemplateKeyword, TemplateName Template) const
Retrieve the template name that represents a qualified template name such as std::vector.
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.
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 C++26 expansion statement declaration.
CXXExpansionStmtPattern * getExpansionPattern()
CXXExpansionStmtInstantiation * getInstantiations()
void setInstantiations(CXXExpansionStmtInstantiation *S)
NonTypeTemplateParmDecl * getIndexTemplateParm()
void setExpansionPattern(CXXExpansionStmtPattern *S)
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.
ClassTemplatePartialSpecializationDecl * findPartialSpecialization(ArrayRef< TemplateArgument > Args, TemplateParameterList *TPL, llvm::FoldingSetInsertToken &InsertToken)
Return the partial specialization with the provided arguments if it exists, otherwise return the inse...
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.
static ClassTemplateDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation L, DeclarationName Name, TemplateParameterList *Params, NamedDecl *Decl)
Create a class template node.
ClassTemplateSpecializationDecl * findSpecialization(ArrayRef< TemplateArgument > Args, llvm::FoldingSetInsertToken &InsertToken)
Return the specialization with the provided arguments if it exists, otherwise return the insertion po...
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, llvm::FoldingSetInsertToken InsertToken)
Insert the specified specialization knowing that it is not already in.
void setCommonPtr(Common *C)
void AddPartialSpecialization(ClassTemplatePartialSpecializationDecl *D, llvm::FoldingSetInsertToken InsertToken)
Insert the specified partial specialization knowing that it is not already in.
Common * getCommonPtr() const
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
Returns true if this DeclContext is a function, Objective-C method, or block, or a DeclContext that c...
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
@ 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.
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...
void setTypeSourceInfo(TypeSourceInfo *TI)
ArrayRef< TemplateParameterList * > getTemplateParameterLists() const
NestedNameSpecifierLoc getQualifierLoc() const
Retrieve the nested-name-specifier (with source-location information) that qualifies the name of this...
NestedNameSpecifier getQualifier() const
Retrieve the nested-name-specifier that qualifies the name of this declaration, if it was present in ...
TypeSourceInfo * getTypeSourceInfo() const
A decomposition declaration.
ArrayRef< BindingDecl * > bindings() const
static DecompositionDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation StartLoc, SourceLocation LSquareLoc, SourceLocation RSquareLoc, 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...
Represents an explicit instantiation of a template entity in source code.
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(const 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.
bool isTypeDependent() const
Determines whether the type of this expression depends on.
bool isConstantInitializer(ASTContext &Ctx, bool ForRef=false, const Expr **Culprit=nullptr) const
Returns true if this expression can be emitted to IR as a constant, and thus can be used as a constan...
std::optional< llvm::APSInt > getIntegerConstantExpr(const ASTContext &Ctx, bool AllowRelaxedEval=false) const
isIntegerConstantExpr - Return the value if this expression is a valid integer constant expression.
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,...
llvm::PointerUnion< NamedDecl *, TypeSourceInfo * > FriendUnion
SourceRange getSourceRange() const override LLVM_READONLY
Source range that this declaration covers.
SourceLocation getFriendLoc() const
SourceLocation getEllipsisLoc() const
Retrieves the location of the '...', if present.
virtual 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
static FriendDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation L, FriendUnion Friend, SourceLocation FriendL, SourceLocation EllipsisLoc={})
Declaration of a friend template.
static FriendTemplateDecl * Create(ASTContext &Context, DeclContext *DC, SourceLocation Loc, FriendUnion Friend, SourceLocation FriendLoc, ArrayRef< TemplateParameterList * > FriendTPLists, SourceLocation EllipsisLoc={}, TemplateName Template={})
NamedDecl * getFriendDecl() const override
If this friend declaration doesn't name a type, return the inner declaration.
TemplateName getFriendTemplateName() const
ArrayRef< TemplateParameterList * > getTemplateParameterLists() const
CXXSpecialMemberKind asSpecialMember() const
static DefaultedOrDeletedFunctionInfo * Create(ASTContext &Context, ArrayRef< DeclAccessPair > Lookups, FPOptionsOverride FPFeatures, 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.
DefaultedFunctionKind getDefaultedFunctionKind() const
Determine the kind of defaulting that would be done for a given function.
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'.
An lvalue reference type, per C++11 [dcl.ref].
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.
NestedNameSpecifier getNestedNameSpecifier() const
Retrieve the nested-name-specifier to which this instance refers.
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.
bool isDependent() const
Whether this nested name specifier refers to a dependent type or not.
NonTypeTemplateParmDecl - Declares a non-type template parameter, e.g., "Size" in.
bool isPackExpansion() const
Whether this parameter pack is a pack expansion.
static NonTypeTemplateParmDecl * Create(const ASTContext &C, DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, int D, int P, const IdentifierInfo *Id, QualType T, bool ParameterPack, TypeSourceInfo *TInfo)
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...
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.
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)
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...
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.
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...
@ 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.
void deduceOpenCLAddressSpace(VarDecl *decl)
MemInitResult BuildBaseInitializer(QualType BaseType, TypeSourceInfo *BaseTInfo, Expr *Init, CXXRecordDecl *ClassDecl, SourceLocation EllipsisLoc)
TypeSourceInfo * SubstFriendType(TypeSourceInfo *TSI, const MultiLevelTemplateArgumentList &TemplateArgs, SourceLocation Loc, DeclarationName Entity)
bool InstantiateDefaultArgument(SourceLocation CallLoc, FunctionDecl *FD, ParmVarDecl *Param)
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)
void AddAssumeAlignedAttr(Decl *D, const AttributeCommonInfo &CI, Expr *E, Expr *OE)
AddAssumeAlignedAttr - Adds an assume_aligned attribute to a particular declaration.
bool RequireCompleteDeclContext(CXXScopeSpec &SS, DeclContext *DC)
Require that the context specified by SS be complete.
const ExpressionEvaluationContextRecord & currentEvaluationContext() const
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...
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)
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)
void AddModeAttr(Decl *D, const AttributeCommonInfo &CI, const IdentifierInfo *Name, bool InInstantiation=false)
AddModeAttr - Adds a mode attribute to a particular declaration.
ASTContext & getASTContext() const
TypeSourceInfo * SubstType(TypeSourceInfo *T, const MultiLevelTemplateArgumentList &TemplateArgs, SourceLocation Loc, DeclarationName Entity, bool AllowDeducedTST=false)
Perform substitution on the type T with a given set of template arguments.
void InstantiateVariableDefinition(SourceLocation PointOfInstantiation, VarDecl *Var, bool Recursive=false, bool DefinitionRequired=false, bool AtEndOfTU=false)
Instantiate the definition of the given variable from its template.
SmallVector< LateInstantiatedAttribute, 1 > LateInstantiatedAttrVec
PrintingPolicy getPrintingPolicy() const
Retrieve a suitable printing policy for diagnostics.
bool SubstTemplateArguments(ArrayRef< TemplateArgumentLoc > Args, const MultiLevelTemplateArgumentList &TemplateArgs, TemplateArgumentListInfo &Outputs)
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)
Sema(Preprocessor &pp, ASTContext &ctxt, ASTConsumer &consumer, TranslationUnitKind TUKind=TU_Complete, CodeCompleteConsumer *CompletionConsumer=nullptr)
void InstantiateAttrs(const MultiLevelTemplateArgumentList &TemplateArgs, const Decl *Pattern, Decl *Inst, LateInstantiatedAttrVec *LateAttrs=nullptr, LocalInstantiationScope *OuterMostScope=nullptr)
const LangOptions & getLangOpts() const
void inferLifetimeBoundAttribute(FunctionDecl *FD)
Add [[clang:lifetimebound]] attr for std:: functions and methods.
void collectUnexpandedParameterPacks(TemplateArgument Arg, SmallVectorImpl< UnexpandedParameterPack > &Unexpanded)
Collect the set of unexpanded parameter packs within the given template argument.
bool BuildCtorClosureDefaultArgs(SourceLocation Loc, CXXConstructorDecl *Ctor, bool IsCopy=false)
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...
void updateAttrsForLateParsedTemplate(const Decl *Pattern, Decl *Inst)
Update instantiation attributes after template was late parsed.
void InstantiateVariableInitializer(VarDecl *Var, VarDecl *OldVar, const MultiLevelTemplateArgumentList &TemplateArgs)
Instantiate the initializer of a variable.
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.
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)
TemplateArgumentLoc getTrivialTemplateArgumentLoc(const TemplateArgument &Arg, QualType NTTPType, SourceLocation Loc)
Allocate a TemplateArgumentLoc where all locations have been initialized to the given location.
ExplicitSpecifier instantiateExplicitSpecifier(const MultiLevelTemplateArgumentList &TemplateArgs, ExplicitSpecifier ES)
bool CheckVariableDeclaration(VarDecl *NewVD, LookupResult &Previous)
Perform semantic checking on a newly-created variable declaration.
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=='.
void PerformPendingInstantiations(bool LocalOnly=false, bool AtEndOfTU=true)
Performs template instantiation for all implicit template instantiations we have seen until this poin...
Decl * SubstDecl(Decl *D, DeclContext *Owner, const MultiLevelTemplateArgumentList &TemplateArgs)
DeclContext * computeDeclContext(QualType T)
Compute the DeclContext that is associated with the given type.
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)
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...
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.
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)
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 checkInstantiatedThreadSafetyAttrs(const Decl *D, const Attr *A)
Recheck instantiated thread-safety attributes that could not be validated on the dependent pattern de...
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 CheckDependentFriend(SourceLocation Loc, NestedNameSpecifierLoc NNSLoc, ArrayRef< TemplateParameterList * > TPLs, bool IsInstantiation)
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)
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.
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.
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)
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.
ASTMutationListener * getASTMutationListener() const
ExprResult ActOnFinishFullExpr(Expr *Expr, bool DiscardedValue)
Encodes a location in the source.
bool isValid() const
Return true if this is a valid SourceLocation object.
A trivial tuple used to represent a source range.
SourceLocation 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
bool SubstTemplateParameterLists(ArrayRef< TemplateParameterList * > TPLs, SmallVectorImpl< TemplateParameterList * > &InstTPLs)
void setEvaluateConstraints(bool B)
Decl * VisitDecl(Decl *D)
VarTemplateSpecializationDecl * VisitVarTemplateSpecializationDecl(VarTemplateDecl *VarTemplate, VarDecl *FromVar, ArrayRef< TemplateArgument > Converted, VarTemplateSpecializationDecl *PrevDecl=nullptr)
Decl * VisitVarDecl(VarDecl *D, bool InstantiatingVarTemplate, ArrayRef< BindingDecl * > *Bindings=nullptr)
bool InitMethodInstantiation(CXXMethodDecl *New, CXXMethodDecl *Tmpl)
Initializes common fields of an instantiated method declaration (New) from the corresponding fields o...
bool InitFunctionInstantiation(FunctionDecl *New, FunctionDecl *Tmpl)
Initializes the common fields of an instantiation function declaration (New) from the corresponding f...
VarTemplatePartialSpecializationDecl * InstantiateVarTemplatePartialSpecialization(VarTemplateDecl *VarTemplate, VarTemplatePartialSpecializationDecl *PartialSpec)
Instantiate the declaration of a variable template partial specialization.
void adjustForRewrite(RewriteKind RK, FunctionDecl *Orig, QualType &T, TypeSourceInfo *&TInfo, DeclarationNameInfo &NameInfo)
TypeSourceInfo * SubstFunctionType(FunctionDecl *D, SmallVectorImpl< ParmVarDecl * > &Params)
void InstantiateEnumDefinition(EnumDecl *Enum, EnumDecl *Pattern)
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.
Decl * VisitCXXMethodDecl(CXXMethodDecl *D, TemplateParameterList *TemplateParams, RewriteKind RK=RewriteKind::None)
Decl * InstantiateTypeAliasTemplateDecl(TypeAliasTemplateDecl *D)
Decl * VisitBaseUsingDecls(BaseUsingDecl *D, BaseUsingDecl *Inst, LookupResult *Lookup)
bool SubstQualifier(const DeclaratorDecl *OldDecl, DeclaratorDecl *NewDecl)
TemplateParameterList * SubstTemplateParams(TemplateParameterList *List)
Instantiates a nested template parameter list in the current instantiation context.
bool InstantiateFriendPackExpansion(FriendDecl *D)
Decl * InstantiateTypedefNameDecl(TypedefNameDecl *D, bool IsTypeAlias)
ClassTemplatePartialSpecializationDecl * InstantiateClassTemplatePartialSpecialization(ClassTemplateDecl *ClassTemplate, ClassTemplatePartialSpecializationDecl *PartialSpec)
Instantiate the declaration of a class template partial specialization.
bool SubstDefaultedFunction(FunctionDecl *New, FunctionDecl *Tmpl)
The base class of all kinds of template declarations (e.g., class, function, etc.).
TemplateParameterList * getTemplateParameters() const
Get the list of template parameters.
Represents a C++ template name within the type system.
bool isNull() const
Determine whether this template name is NULL.
@ Template
A single template declaration.
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
unsigned getNumArgs() const
SourceLocation getLAngleLoc() const
TemplateArgumentLoc getArgLoc(unsigned i) const
SourceLocation getRAngleLoc() const
SourceLocation getTemplateNameLoc() const
SourceLocation getTemplateKeywordLoc() const
NestedNameSpecifierLoc getQualifierLoc() const
SourceLocation getElaboratedKeywordLoc() 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.
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.
static TemplateTemplateParmDecl * Create(const ASTContext &C, DeclContext *DC, SourceLocation L, int D, int P, bool ParameterPack, IdentifierInfo *Id, TemplateNameKind ParameterKind, bool Typename, TemplateParameterList *Params)
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.
static TemplateTypeParmDecl * Create(const ASTContext &C, DeclContext *DC, SourceLocation KeyLoc, SourceLocation NameLoc, int D, int P, IdentifierInfo *Id, bool Typename, bool ParameterPack, bool HasTypeConstraint=false, UnsignedOrNone NumExpanded=std::nullopt)
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.
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.
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...
NestedNameSpecifierLoc getPrefix() const
If this type represents a qualified-id, this returns it's nested name specifier.
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<specific type>.
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<specific type>'.
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.
VarTemplateSpecializationDecl * findSpecialization(ArrayRef< TemplateArgument > Args, llvm::FoldingSetInsertToken &InsertToken)
Return the specialization with the provided arguments if it exists, otherwise return the insertion po...
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.
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)
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)
Top level wrappers for InstallAPI frontend operations.
CanQual< Type > CanQualType
Represents a canonical, potentially-qualified type.
bool isa(CodeGen::Address addr)
@ 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)
@ Default
Set to the current date and time.
@ Property
The type of a property.
@ Result
The result type of a method or function.
ActionResult< CXXCtorInitializer * > MemInitResult
OptionalUnsigned< unsigned > UnsignedOrNone
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
TypeSourceInfo * TypeInfo
Represents an explicit template argument list in C++, e.g., the "<int>" in "sort<int>".
SourceLocation RAngleLoc
The source location of the right angle bracket ('>').
SourceLocation LAngleLoc
The source location of the left angle bracket ('<').
ArrayRef< TemplateArgumentLoc > arguments() const
DeclarationNameInfo - A collector data type for bundling together a DeclarationName and the correspon...
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
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
llvm::SmallVector< OMPInteropPref, 4 > Prefs
One entry of a prefer_type list.
llvm::SmallVector< Expr *, 2 > Attrs
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.