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()) {
99 if (!Result.isInvalid())
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;
161 if (Result.isInvalid())
163 E = Result.getAs<
Expr>();
165 if (Aligned->getOffset()) {
166 Result = S.
SubstExpr(Aligned->getOffset(), TemplateArgs);
167 if (Result.isInvalid())
169 OE = Result.getAs<
Expr>();
177 const AlignValueAttr *Aligned,
Decl *
New) {
182 if (!Result.isInvalid())
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;
246 if (Result.isInvalid())
248 tempInstPriority = Result.get();
249 if (std::optional<llvm::APSInt> CE =
253 if (!CE->isIntN(32)) {
255 <<
toString(*CE, 10,
false) << 32 << 1;
260 New->addAttr(Attr::Create(
C, tempInstPriority, *A));
272 if (Result.isInvalid())
276 if (!
Cond->isTypeDependent()) {
286 S.
Diag(A->
getLocation(), diag::err_attr_cond_never_constant_expr) << A;
287 for (
const auto &P : Diags)
288 S.
Diag(P.first, P.second);
298 S, TemplateArgs, EIA, EIA->getCond(), Tmpl,
New);
302 Cond, EIA->getMessage()));
309 S, TemplateArgs, DIA, DIA->getCond(), Tmpl,
New);
314 DIA->getDefaultSeverity(), DIA->getWarningGroup(),
315 DIA->getArgDependent(),
New));
328 if (Result.isInvalid())
330 Expr *MaxThreads = Result.getAs<
Expr>();
332 Expr *MinBlocks =
nullptr;
333 if (
Attr.getMinBlocks()) {
335 if (Result.isInvalid())
340 Expr *MaxBlocks =
nullptr;
341 if (
Attr.getMaxBlocks()) {
343 if (Result.isInvalid())
345 MaxBlocks = Result.getAs<
Expr>();
364 if (
auto *FTD = dyn_cast<FunctionTemplateDecl>(
New))
365 New = FTD->getTemplatedDecl();
367 auto *ThisContext = dyn_cast_or_null<CXXRecordDecl>(FD->getDeclContext());
372 if (
auto *DRE = dyn_cast<DeclRefExpr>(E->IgnoreParenImpCasts()))
373 if (
auto *PVD = dyn_cast<ParmVarDecl>(DRE->getDecl())) {
376 if (FD->getNumParams() > PVD->getFunctionScopeIndex())
377 Local.InstantiatedLocal(
378 PVD, FD->getParamDecl(PVD->getFunctionScopeIndex()));
382 FD->isCXXInstanceMember());
398 if (
auto *E =
Attr.getSimdlen())
401 if (
Attr.uniforms_size() > 0) {
402 for(
auto *E :
Attr.uniforms()) {
406 Uniforms.push_back(Inst.
get());
410 auto AI =
Attr.alignments_begin();
411 for (
auto *E :
Attr.aligneds()) {
415 Aligneds.push_back(Inst.
get());
419 Alignments.push_back(Inst.
get());
423 auto SI =
Attr.steps_begin();
424 for (
auto *E :
Attr.linears()) {
428 Linears.push_back(Inst.
get());
432 Steps.push_back(Inst.
get());
435 LinModifiers.append(
Attr.modifiers_begin(),
Attr.modifiers_end());
438 Uniforms, Aligneds, Alignments, Linears, LinModifiers, Steps,
447 if (
auto *FTD = dyn_cast<FunctionTemplateDecl>(
New))
448 New = FTD->getTemplatedDecl();
450 auto *ThisContext = dyn_cast_or_null<CXXRecordDecl>(FD->getDeclContext());
452 auto &&SubstExpr = [FD, ThisContext, &S, &TemplateArgs](
Expr *E) {
453 if (
auto *DRE = dyn_cast<DeclRefExpr>(E->IgnoreParenImpCasts()))
454 if (
auto *PVD = dyn_cast<ParmVarDecl>(DRE->getDecl())) {
457 if (FD->getNumParams() > PVD->getFunctionScopeIndex())
458 Local.InstantiatedLocal(
459 PVD, FD->getParamDecl(PVD->getFunctionScopeIndex()));
463 FD->isCXXInstanceMember());
469 auto &&Subst = [&SubstExpr, &S](
Expr *E) {
479 if (
Expr *E =
Attr.getVariantFuncRef()) {
484 VariantFuncRef = Subst(E);
490 TI = *
Attr.getTraitInfos();
493 auto SubstScoreOrConditionExpr = [&S, Subst](
Expr *&E,
bool) {
508 Expr *E = VariantFuncRef.
get();
512 std::optional<std::pair<FunctionDecl *, Expr *>> DeclVarData =
520 E = DeclVarData->second;
521 FD = DeclVarData->first;
523 if (
auto *VariantDRE = dyn_cast<DeclRefExpr>(E->IgnoreParenImpCasts())) {
524 if (
auto *VariantFD = dyn_cast<FunctionDecl>(VariantDRE->getDecl())) {
525 if (
auto *VariantFTD = VariantFD->getDescribedFunctionTemplate()) {
526 if (!VariantFTD->isThisDeclarationADefinition())
537 SubstFD->getType(), FD->getType(),
543 New->getLocation(), SubstFD,
true,
545 SubstFD->setInstantiationIsPending(!SubstFD->isDefined());
549 SubstFD->getLocation(),
560 for (
Expr *E :
Attr.adjustArgsNothing()) {
564 NothingExprs.push_back(ER.
get());
566 for (
Expr *E :
Attr.adjustArgsNeedDevicePtr()) {
570 NeedDevicePtrExprs.push_back(ER.
get());
572 for (
Expr *E :
Attr.adjustArgsNeedDeviceAddr()) {
576 NeedDeviceAddrExprs.push_back(ER.
get());
580 AppendArgs.emplace_back(II.IsTarget, II.IsTargetSync);
584 FD, E, TI, NothingExprs, NeedDevicePtrExprs, NeedDeviceAddrExprs,
590 const AMDGPUFlatWorkGroupSizeAttr &
Attr,
Decl *
New) {
596 if (Result.isInvalid())
598 Expr *MinExpr = Result.getAs<
Expr>();
601 if (Result.isInvalid())
603 Expr *MaxExpr = Result.getAs<
Expr>();
616 if (Result.isInvalid())
621 if (Result.isInvalid())
626 if (Result.isInvalid())
631 New->addAttr(::new (Context) ReqdWorkGroupSizeAttr(Context,
Attr,
X, Y, Z));
650 if (!
Cond->isTypeDependent())
663 if (Result.isInvalid())
665 Expr *MinExpr = Result.getAs<
Expr>();
667 Expr *MaxExpr =
nullptr;
668 if (
auto Max =
Attr.getMax()) {
670 if (Result.isInvalid())
680 const AMDGPUMaxNumWorkGroupsAttr &
Attr,
Decl *
New) {
684 Expr *XExpr =
nullptr;
685 Expr *YExpr =
nullptr;
686 Expr *ZExpr =
nullptr;
688 if (
Attr.getMaxNumWorkGroupsX()) {
694 if (
Attr.getMaxNumWorkGroupsY()) {
700 if (
Attr.getMaxNumWorkGroupsZ()) {
716 auto SubstElt = [&S, &TemplateArgs](
Expr *E) {
717 return E ? S.
SubstExpr(E, TemplateArgs).
get() :
nullptr;
720 Expr *XExpr = SubstElt(
Attr.getX());
721 Expr *YExpr = SubstElt(
Attr.getY());
722 Expr *ZExpr = SubstElt(
Attr.getZ());
742 if (
const auto *PNA = dyn_cast<PreferredNameAttr>(A)) {
745 if (!
T->isDependentType() && !RD->isDependentContext() &&
748 for (
const auto *ExistingPNA : D->
specific_attrs<PreferredNameAttr>())
750 PNA->getTypedefType()))
755 if (
const auto *BA = dyn_cast<BuiltinAttr>(A)) {
757 switch (BA->getID()) {
758 case Builtin::BIforward:
768 case Builtin::BImove:
769 case Builtin::BImove_if_noexcept:
796 "out or inout parameter type must be a reference and restrict qualified");
807 for (
const auto *TmplAttr : Tmpl->
attrs()) {
814 *
this, dyn_cast_or_null<CXXRecordDecl>(ND->getDeclContext()),
818 TmplAttr,
Context, *
this, TemplateArgs);
820 New->addAttr(NewAttr);
828 case clang::attr::CFConsumed:
830 case clang::attr::OSConsumed:
832 case clang::attr::NSConsumed:
835 llvm_unreachable(
"Wrong argument supplied");
842 const OpenACCRoutineDeclAttr *OldAttr,
const Decl *Old,
Decl *
New);
848 for (
const auto *TmplAttr : Tmpl->
attrs()) {
853 const AlignedAttr *Aligned = dyn_cast<AlignedAttr>(TmplAttr);
854 if (Aligned && Aligned->isAlignmentDependent()) {
859 if (
const auto *AssumeAligned = dyn_cast<AssumeAlignedAttr>(TmplAttr)) {
864 if (
const auto *AlignValue = dyn_cast<AlignValueAttr>(TmplAttr)) {
869 if (
const auto *AllocAlign = dyn_cast<AllocAlignAttr>(TmplAttr)) {
874 if (
const auto *Annotate = dyn_cast<AnnotateAttr>(TmplAttr)) {
879 if (
auto *
Constructor = dyn_cast<ConstructorAttr>(TmplAttr)) {
885 if (
auto *
Destructor = dyn_cast<DestructorAttr>(TmplAttr)) {
891 if (
const auto *EnableIf = dyn_cast<EnableIfAttr>(TmplAttr)) {
897 if (
const auto *DiagnoseIf = dyn_cast<DiagnoseIfAttr>(TmplAttr)) {
903 if (
const auto *CUDALaunchBounds =
904 dyn_cast<CUDALaunchBoundsAttr>(TmplAttr)) {
906 *CUDALaunchBounds,
New);
910 if (
const auto *Mode = dyn_cast<ModeAttr>(TmplAttr)) {
915 if (
const auto *OMPAttr = dyn_cast<OMPDeclareSimdDeclAttr>(TmplAttr)) {
920 if (
const auto *OMPAttr = dyn_cast<OMPDeclareVariantAttr>(TmplAttr)) {
925 if (
const auto *ReqdWorkGroupSize =
926 dyn_cast<ReqdWorkGroupSizeAttr>(TmplAttr)) {
928 *ReqdWorkGroupSize,
New);
931 if (
const auto *AMDGPUFlatWorkGroupSize =
932 dyn_cast<AMDGPUFlatWorkGroupSizeAttr>(TmplAttr)) {
934 *
this, TemplateArgs, *AMDGPUFlatWorkGroupSize,
New);
937 if (
const auto *AMDGPUFlatWorkGroupSize =
938 dyn_cast<AMDGPUWavesPerEUAttr>(TmplAttr)) {
940 *AMDGPUFlatWorkGroupSize,
New);
943 if (
const auto *AMDGPUMaxNumWorkGroups =
944 dyn_cast<AMDGPUMaxNumWorkGroupsAttr>(TmplAttr)) {
946 *
this, TemplateArgs, *AMDGPUMaxNumWorkGroups,
New);
949 if (
const auto *CUDAClusterDims = dyn_cast<CUDAClusterDimsAttr>(TmplAttr)) {
951 *CUDAClusterDims,
New);
954 if (
const auto *ParamAttr = dyn_cast<HLSLParamModifierAttr>(TmplAttr)) {
960 if (
const auto *RoutineAttr = dyn_cast<OpenACCRoutineDeclAttr>(TmplAttr)) {
962 RoutineAttr, Tmpl,
New);
967 if (TmplAttr->getKind() == attr::DLLExport ||
968 TmplAttr->getKind() == attr::DLLImport) {
969 if (
New->hasAttr<DLLExportAttr>() ||
New->hasAttr<DLLImportAttr>()) {
974 if (
const auto *ABIAttr = dyn_cast<ParameterABIAttr>(TmplAttr)) {
987 if (
auto *A = dyn_cast<PointerAttr>(TmplAttr)) {
988 if (!
New->hasAttr<PointerAttr>())
993 if (
auto *A = dyn_cast<OwnerAttr>(TmplAttr)) {
994 if (!
New->hasAttr<OwnerAttr>())
999 if (
auto *A = dyn_cast<SYCLKernelAttr>(TmplAttr)) {
1004 if (
auto *A = dyn_cast<CUDAGridConstantAttr>(TmplAttr)) {
1005 if (!
New->hasAttr<CUDAGridConstantAttr>())
1010 assert(!TmplAttr->isPackExpansion());
1011 if (TmplAttr->isLateParsed() && LateAttrs) {
1021 auto *ThisContext = dyn_cast_or_null<CXXRecordDecl>(ND->getDeclContext());
1023 ND->isCXXInstanceMember());
1026 *
this, TemplateArgs);
1028 New->addAttr(NewAttr);
1034 for (
const auto *
Attr : Pattern->
attrs()) {
1035 if (
auto *A = dyn_cast<StrictFPAttr>(
Attr)) {
1036 if (!Inst->
hasAttr<StrictFPAttr>())
1044 assert(
Context.getTargetInfo().getCXXABI().isMicrosoft() &&
1049 DLLExportAttr *
Attr = Ctor->
getAttr<DLLExportAttr>();
1052 for (
unsigned I = 0; I != NumParams; ++I) {
1063template<
typename DeclT>
1065 DeclT *Result = D->getPreviousDecl();
1071 D->getLexicalDeclContext() != Result->getLexicalDeclContext())
1079 llvm_unreachable(
"Translation units cannot be instantiated");
1083 llvm_unreachable(
"HLSL buffer declarations cannot be instantiated");
1086Decl *TemplateDeclInstantiator::VisitHLSLRootSignatureDecl(
1088 llvm_unreachable(
"HLSL root signature declarations cannot be instantiated");
1093 llvm_unreachable(
"pragma comment cannot be instantiated");
1096Decl *TemplateDeclInstantiator::VisitPragmaDetectMismatchDecl(
1098 llvm_unreachable(
"pragma comment cannot be instantiated");
1103 llvm_unreachable(
"extern \"C\" context cannot be instantiated");
1107 llvm_unreachable(
"GUID declaration cannot be instantiated");
1110Decl *TemplateDeclInstantiator::VisitUnnamedGlobalConstantDecl(
1112 llvm_unreachable(
"UnnamedGlobalConstantDecl cannot be instantiated");
1115Decl *TemplateDeclInstantiator::VisitTemplateParamObjectDecl(
1117 llvm_unreachable(
"template parameter objects cannot be instantiated");
1121TemplateDeclInstantiator::VisitLabelDecl(
LabelDecl *D) {
1124 SemaRef.InstantiateAttrs(TemplateArgs, D, Inst, LateAttrs, StartingScope);
1125 Owner->addDecl(Inst);
1130TemplateDeclInstantiator::VisitNamespaceDecl(
NamespaceDecl *D) {
1131 llvm_unreachable(
"Namespaces cannot be instantiated");
1135class OpenACCDeclClauseInstantiator final
1138 const MultiLevelTemplateArgumentList &MLTAL;
1139 ArrayRef<OpenACCClause *> ExistingClauses;
1140 SemaOpenACC::OpenACCParsedClause &ParsedClause;
1141 OpenACCClause *NewClause =
nullptr;
1144 OpenACCDeclClauseInstantiator(Sema &S,
1145 const MultiLevelTemplateArgumentList &MLTAL,
1146 ArrayRef<OpenACCClause *> ExistingClauses,
1147 SemaOpenACC::OpenACCParsedClause &ParsedClause)
1148 : SemaRef(S), MLTAL(MLTAL), ExistingClauses(ExistingClauses),
1149 ParsedClause(ParsedClause) {}
1151 OpenACCClause *CreatedClause() {
return NewClause; }
1152#define VISIT_CLAUSE(CLAUSE_NAME) \
1153 void Visit##CLAUSE_NAME##Clause(const OpenACC##CLAUSE_NAME##Clause &Clause);
1154#include "clang/Basic/OpenACCClauses.def"
1158 for (
Expr *CurVar : VarList) {
1159 ExprResult Res = SemaRef.SubstExpr(CurVar, MLTAL);
1168 InstantiatedVarList.push_back(Res.
get());
1170 return InstantiatedVarList;
1174#define CLAUSE_NOT_ON_DECLS(CLAUSE_NAME) \
1175 void OpenACCDeclClauseInstantiator::Visit##CLAUSE_NAME##Clause( \
1176 const OpenACC##CLAUSE_NAME##Clause &) { \
1177 llvm_unreachable("Clause type invalid on declaration construct, or " \
1178 "instantiation not implemented"); \
1207#undef CLAUSE_NOT_ON_DECLS
1209void OpenACCDeclClauseInstantiator::VisitGangClause(
1213 assert(
C.getNumExprs() <= 1 &&
1214 "Only 1 expression allowed on gang clause in routine");
1216 if (
C.getNumExprs() > 0) {
1218 "Only dim allowed on routine");
1220 SemaRef.SubstExpr(
const_cast<Expr *
>(
C.getExpr(0).second), MLTAL);
1222 ER = SemaRef.OpenACC().CheckGangExpr(ExistingClauses,
1223 ParsedClause.getDirectiveKind(),
1224 C.getExpr(0).first, ER.
get());
1227 TransformedIntExprs.push_back(ER.
get());
1232 NewClause = SemaRef.OpenACC().CheckGangClause(
1233 ParsedClause.getDirectiveKind(), ExistingClauses,
1234 ParsedClause.getBeginLoc(), ParsedClause.getLParenLoc(),
1235 TransformedGangKinds, TransformedIntExprs, ParsedClause.getEndLoc());
1240 ParsedClause.getBeginLoc(),
1241 ParsedClause.getEndLoc());
1243void OpenACCDeclClauseInstantiator::VisitNoHostClause(
1246 ParsedClause.getBeginLoc(),
1247 ParsedClause.getEndLoc());
1250void OpenACCDeclClauseInstantiator::VisitDeviceTypeClause(
1254 SemaRef.getASTContext(),
C.getClauseKind(), ParsedClause.getBeginLoc(),
1255 ParsedClause.getLParenLoc(),
C.getArchitectures(),
1256 ParsedClause.getEndLoc());
1259void OpenACCDeclClauseInstantiator::VisitWorkerClause(
1261 assert(!
C.hasIntExpr() &&
"Int Expr not allowed on routine 'worker' clause");
1263 ParsedClause.getBeginLoc(), {},
1264 nullptr, ParsedClause.getEndLoc());
1267void OpenACCDeclClauseInstantiator::VisitVectorClause(
1269 assert(!
C.hasIntExpr() &&
"Int Expr not allowed on routine 'vector' clause");
1271 ParsedClause.getBeginLoc(), {},
1272 nullptr, ParsedClause.getEndLoc());
1275void OpenACCDeclClauseInstantiator::VisitCopyClause(
1277 ParsedClause.setVarListDetails(VisitVarList(
C.getVarList()),
1278 C.getModifierList());
1279 if (SemaRef.OpenACC().CheckDeclareClause(ParsedClause,
C.getModifierList()))
1282 SemaRef.getASTContext(), ParsedClause.getClauseKind(),
1283 ParsedClause.getBeginLoc(), ParsedClause.getLParenLoc(),
1284 ParsedClause.getModifierList(), ParsedClause.getVarList(),
1285 ParsedClause.getEndLoc());
1288void OpenACCDeclClauseInstantiator::VisitLinkClause(
1290 ParsedClause.setVarListDetails(
1291 SemaRef.OpenACC().CheckLinkClauseVarList(VisitVarList(
C.getVarList())),
1294 if (SemaRef.OpenACC().CheckDeclareClause(ParsedClause,
1299 SemaRef.getASTContext(), ParsedClause.getBeginLoc(),
1300 ParsedClause.getLParenLoc(), ParsedClause.getVarList(),
1301 ParsedClause.getEndLoc());
1304void OpenACCDeclClauseInstantiator::VisitDeviceResidentClause(
1306 ParsedClause.setVarListDetails(VisitVarList(
C.getVarList()),
1308 if (SemaRef.OpenACC().CheckDeclareClause(ParsedClause,
1312 SemaRef.getASTContext(), ParsedClause.getBeginLoc(),
1313 ParsedClause.getLParenLoc(), ParsedClause.getVarList(),
1314 ParsedClause.getEndLoc());
1317void OpenACCDeclClauseInstantiator::VisitCopyInClause(
1319 ParsedClause.setVarListDetails(VisitVarList(
C.getVarList()),
1320 C.getModifierList());
1322 if (SemaRef.OpenACC().CheckDeclareClause(ParsedClause,
C.getModifierList()))
1325 SemaRef.getASTContext(), ParsedClause.getClauseKind(),
1326 ParsedClause.getBeginLoc(), ParsedClause.getLParenLoc(),
1327 ParsedClause.getModifierList(), ParsedClause.getVarList(),
1328 ParsedClause.getEndLoc());
1330void OpenACCDeclClauseInstantiator::VisitCopyOutClause(
1332 ParsedClause.setVarListDetails(VisitVarList(
C.getVarList()),
1333 C.getModifierList());
1335 if (SemaRef.OpenACC().CheckDeclareClause(ParsedClause,
C.getModifierList()))
1338 SemaRef.getASTContext(), ParsedClause.getClauseKind(),
1339 ParsedClause.getBeginLoc(), ParsedClause.getLParenLoc(),
1340 ParsedClause.getModifierList(), ParsedClause.getVarList(),
1341 ParsedClause.getEndLoc());
1343void OpenACCDeclClauseInstantiator::VisitCreateClause(
1345 ParsedClause.setVarListDetails(VisitVarList(
C.getVarList()),
1346 C.getModifierList());
1348 if (SemaRef.OpenACC().CheckDeclareClause(ParsedClause,
C.getModifierList()))
1351 SemaRef.getASTContext(), ParsedClause.getClauseKind(),
1352 ParsedClause.getBeginLoc(), ParsedClause.getLParenLoc(),
1353 ParsedClause.getModifierList(), ParsedClause.getVarList(),
1354 ParsedClause.getEndLoc());
1356void OpenACCDeclClauseInstantiator::VisitPresentClause(
1358 ParsedClause.setVarListDetails(VisitVarList(
C.getVarList()),
1360 if (SemaRef.OpenACC().CheckDeclareClause(ParsedClause,
1364 SemaRef.getASTContext(), ParsedClause.getBeginLoc(),
1365 ParsedClause.getLParenLoc(), ParsedClause.getVarList(),
1366 ParsedClause.getEndLoc());
1368void OpenACCDeclClauseInstantiator::VisitDevicePtrClause(
1372 llvm::erase_if(VarList, [&](
Expr *E) {
1377 if (SemaRef.OpenACC().CheckDeclareClause(ParsedClause,
1381 SemaRef.getASTContext(), ParsedClause.getBeginLoc(),
1382 ParsedClause.getLParenLoc(), ParsedClause.getVarList(),
1383 ParsedClause.getEndLoc());
1386void OpenACCDeclClauseInstantiator::VisitBindClause(
1389 if (
C.isStringArgument())
1391 SemaRef.getASTContext(), ParsedClause.getBeginLoc(),
1392 ParsedClause.getLParenLoc(),
C.getStringArgument(),
1393 ParsedClause.getEndLoc());
1396 SemaRef.getASTContext(), ParsedClause.getBeginLoc(),
1397 ParsedClause.getLParenLoc(),
C.getIdentifierArgument(),
1398 ParsedClause.getEndLoc());
1406 for (
const auto *Clause : ClauseList) {
1408 Clause->getBeginLoc());
1409 ParsedClause.setEndLoc(Clause->getEndLoc());
1410 if (
const auto *WithParms = dyn_cast<OpenACCClauseWithParams>(Clause))
1411 ParsedClause.setLParenLoc(WithParms->getLParenLoc());
1413 OpenACCDeclClauseInstantiator Instantiator{S, MLTAL, TransformedClauses,
1415 Instantiator.Visit(Clause);
1416 if (Instantiator.CreatedClause())
1417 TransformedClauses.push_back(Instantiator.CreatedClause());
1419 return TransformedClauses;
1426 const OpenACCRoutineDeclAttr *OldAttr,
const Decl *OldDecl,
Decl *NewDecl) {
1427 OpenACCRoutineDeclAttr *A =
1428 OpenACCRoutineDeclAttr::Create(S.
getASTContext(), OldAttr->getLocation());
1430 if (!OldAttr->Clauses.empty()) {
1432 InstantiateOpenACCClauseList(
1434 A->Clauses.assign(TransformedClauses.begin(), TransformedClauses.end());
1445 llvm::SmallVector<OpenACCClause *> TransformedClauses =
1449 if (SemaRef.OpenACC().ActOnStartDeclDirective(
1453 DeclGroupRef Res = SemaRef.OpenACC().ActOnEndDeclDirective(
1465 llvm::SmallVector<OpenACCClause *> TransformedClauses =
1473 FuncRef = SemaRef.OpenACC().ActOnRoutineName(FuncRef.
get());
1478 if (SemaRef.OpenACC().ActOnStartDeclDirective(
1482 DeclGroupRef Res = SemaRef.OpenACC().ActOnEndRoutineDeclDirective(
1494 NamespaceAliasDecl *Inst
1502 Owner->addDecl(Inst);
1512 DI = SemaRef.SubstType(DI, TemplateArgs,
1516 DI = SemaRef.Context.getTrivialTypeSourceInfo(SemaRef.Context.IntTy);
1527 if (SemaRef.getPreprocessor().NeedsStdLibCxxWorkaroundBefore(2014'04'22)) {
1528 const DecltypeType *DT = DI->
getType()->
getAs<DecltypeType>();
1531 DT->isReferenceType() &&
1532 RD->getEnclosingNamespaceContext() == SemaRef.getStdNamespace() &&
1533 RD->getIdentifier() && RD->getIdentifier()->isStr(
"common_type") &&
1535 SemaRef.getSourceManager().isInSystemHeader(D->
getBeginLoc()))
1537 DI = SemaRef.Context.getTrivialTypeSourceInfo(
1555 TagDecl *oldTag = oldTagType->getDecl();
1572 SemaRef.isIncompatibleTypedef(InstPrevTypedef,
Typedef);
1574 Typedef->setPreviousDecl(InstPrevTypedef);
1577 SemaRef.InstantiateAttrs(TemplateArgs, D,
Typedef);
1580 SemaRef.inferGslPointerAttribute(
Typedef);
1629 if (!
Found.empty()) {
1630 PrevAliasTemplate = dyn_cast<TypeAliasTemplateDecl>(
Found.front());
1643 if (PrevAliasTemplate)
1648 if (!PrevAliasTemplate)
1675 SmallVector<BindingDecl*, 16> NewBindings;
1676 BindingDecl *OldBindingPack =
nullptr;
1677 for (
auto *OldBD : D->
bindings()) {
1678 Expr *BindingExpr = OldBD->getBinding();
1679 if (isa_and_present<FunctionParmPackExpr>(BindingExpr)) {
1681 assert(!OldBindingPack &&
"no more than one pack is allowed");
1682 OldBindingPack = OldBD;
1686 ArrayRef<BindingDecl*> NewBindingArray = NewBindings;
1688 auto *NewDD = cast_if_present<DecompositionDecl>(
1691 if (!NewDD || NewDD->isInvalidDecl()) {
1692 for (
auto *NewBD : NewBindings)
1693 NewBD->setInvalidDecl();
1694 }
else if (OldBindingPack) {
1697 BindingDecl *NewBindingPack = *llvm::find_if(
1699 assert(NewBindingPack !=
nullptr &&
"new bindings should also have a pack");
1700 llvm::ArrayRef<BindingDecl *> OldDecls =
1702 llvm::ArrayRef<BindingDecl *> NewDecls =
1704 assert(OldDecls.size() == NewDecls.size());
1705 for (
unsigned I = 0; I < OldDecls.size(); I++)
1706 SemaRef.CurrentInstantiationScope->InstantiatedLocal(OldDecls[I],
1718 bool InstantiatingVarTemplate,
1729 SemaRef.
Diag(D->
getLocation(), diag::err_variable_instantiates_to_function)
1762 StartingScope, InstantiatingVarTemplate);
1765 if (
auto *F = dyn_cast<FunctionDecl>(DC))
1766 RT = F->getReturnType();
1771 llvm_unreachable(
"Unknown context type");
1792 SemaRef.CheckStaticLocalForDllExport(Var);
1795 SemaRef.CheckThreadLocalForLargeAlignment(Var);
1797 if (SemaRef.getLangOpts().OpenACC)
1798 SemaRef.OpenACC().ActOnVariableDeclarator(Var);
1807 Owner->addHiddenDecl(AD);
1811Decl *TemplateDeclInstantiator::VisitFieldDecl(
FieldDecl *D) {
1816 DI = SemaRef.SubstType(DI, TemplateArgs,
1828 SemaRef.Diag(D->
getLocation(), diag::err_field_instantiates_to_function)
1839 else if (BitWidth) {
1845 = SemaRef.SubstExpr(BitWidth, TemplateArgs);
1850 BitWidth = InstantiatedBitWidth.
getAs<Expr>();
1868 SemaRef.InstantiateAttrs(TemplateArgs, D, Field, LateAttrs, StartingScope);
1870 if (
Field->hasAttrs())
1871 SemaRef.CheckAlignasUnderalignment(Field);
1874 Field->setInvalidDecl();
1876 if (!
Field->getDeclName() ||
Field->isPlaceholderVar(SemaRef.getLangOpts())) {
1878 SemaRef.Context.setInstantiatedFromUnnamedFieldDecl(Field, D);
1880 if (CXXRecordDecl *Parent= dyn_cast<CXXRecordDecl>(
Field->getDeclContext())) {
1881 if (Parent->isAnonymousStructOrUnion() &&
1882 Parent->getRedeclContext()->isFunctionOrMethod())
1883 SemaRef.CurrentInstantiationScope->InstantiatedLocal(D, Field);
1888 Owner->addDecl(Field);
1898 SemaRef.Diag(D->
getLocation(), diag::err_property_is_variably_modified)
1902 DI = SemaRef.SubstType(DI, TemplateArgs,
1914 SemaRef.Diag(D->
getLocation(), diag::err_field_instantiates_to_function)
1926 SemaRef.InstantiateAttrs(TemplateArgs, D,
Property, LateAttrs,
1939 NamedDecl **NamedChain =
1943 for (
auto *PI : D->
chain()) {
1949 NamedChain[i++] =
Next;
1955 {NamedChain, D->getChainingSize()});
1957 for (
const auto *Attr : D->
attrs())
1958 IndirectField->
addAttr(Attr->clone(SemaRef.Context));
1962 Owner->addDecl(IndirectField);
1963 return IndirectField;
1970 TypeSourceInfo *InstTy;
1979 SmallVector<UnexpandedParameterPack, 2> Unexpanded;
1980 SemaRef.collectUnexpandedParameterPacks(Ty->getTypeLoc(), Unexpanded);
1981 assert(!Unexpanded.empty() &&
"Pack expansion without packs");
1983 bool ShouldExpand =
true;
1984 bool RetainExpansion =
false;
1985 UnsignedOrNone NumExpansions = std::nullopt;
1986 if (SemaRef.CheckParameterPacksForExpansion(
1989 ShouldExpand, RetainExpansion, NumExpansions))
1992 assert(!RetainExpansion &&
1993 "should never retain an expansion for a variadic friend decl");
1996 SmallVector<FriendDecl *> Decls;
1997 for (
unsigned I = 0; I != *NumExpansions; I++) {
1998 Sema::ArgPackSubstIndexRAII SubstIndex(SemaRef, I);
1999 TypeSourceInfo *TSI = SemaRef.SubstType(
2010 Decls.push_back(FD);
2018 InstTy = SemaRef.SubstType(Ty, TemplateArgs, D->
getLocation(),
2033 assert(ND &&
"friend decl must be a decl or a type!");
2040 if (!NewND)
return nullptr;
2059 = SemaRef.SubstExpr(AssertExpr, TemplateArgs);
2064 SemaRef.SubstExpr(D->
getMessage(), TemplateArgs);
2065 if (InstantiatedMessageExpr.
isInvalid())
2068 return SemaRef.BuildStaticAssertDeclaration(
2073Decl *TemplateDeclInstantiator::VisitEnumDecl(
EnumDecl *D) {
2074 EnumDecl *PrevDecl =
nullptr;
2076 NamedDecl *Prev = SemaRef.FindInstantiatedDecl(D->
getLocation(),
2079 if (!Prev)
return nullptr;
2092 SourceLocation UnderlyingLoc = TI->getTypeLoc().getBeginLoc();
2093 TypeSourceInfo *NewTI = SemaRef.SubstType(TI, TemplateArgs, UnderlyingLoc,
2095 if (!NewTI || SemaRef.CheckEnumUnderlyingType(NewTI))
2096 Enum->setIntegerType(SemaRef.Context.IntTy);
2106 Enum->setIntegerTypeSourceInfo(NewTI);
2116 QualType UnderlyingType =
Enum->getIntegerType();
2117 Enum->setPromotionType(
2118 SemaRef.Context.isPromotableIntegerType(UnderlyingType)
2119 ? SemaRef.Context.getPromotedIntegerType(UnderlyingType)
2123 &&
"Dependent type without type source info");
2128 SemaRef.InstantiateAttrs(TemplateArgs, D,
Enum);
2133 SemaRef.Context.setManglingNumber(
Enum, SemaRef.Context.getManglingNumber(D));
2136 if (DeclaratorDecl *DD = SemaRef.Context.getDeclaratorForUnnamedTagDecl(D))
2137 SemaRef.Context.addDeclaratorForUnnamedTagDecl(
Enum, DD);
2140 if (TypedefNameDecl *TND = SemaRef.Context.getTypedefNameForUnnamedTagDecl(D))
2141 SemaRef.Context.addTypedefNameForUnnamedTagDecl(
Enum, TND);
2143 Owner->addDecl(
Enum);
2146 if (Def && Def != D) {
2151 SourceLocation UnderlyingLoc = TI->getTypeLoc().getBeginLoc();
2152 QualType DefnUnderlying =
2153 SemaRef.SubstType(TI->getType(), TemplateArgs,
2154 UnderlyingLoc, DeclarationName());
2156 DefnUnderlying,
true,
Enum);
2171 if (PrevDecl ==
nullptr) {
2172 SemaRef.CurrentInstantiationScope->InstantiatedLocal(D,
Enum);
2182 Enum->startDefinition();
2193 if (
Expr *UninstValue = EC->getInitExpr()) {
2198 Value = SemaRef.SubstExpr(UninstValue, TemplateArgs);
2203 if (
Value.isInvalid()) {
2209 = SemaRef.CheckEnumConstant(
Enum, LastEnumConst,
2216 Enum->setInvalidDecl();
2220 SemaRef.InstantiateAttrs(TemplateArgs, EC, EnumConst);
2223 Enum->addDecl(EnumConst);
2224 Enumerators.push_back(EnumConst);
2225 LastEnumConst = EnumConst;
2228 !
Enum->isScoped()) {
2231 SemaRef.CurrentInstantiationScope->InstantiatedLocal(EC, EnumConst);
2236 SemaRef.ActOnEnumBody(
Enum->getLocation(),
Enum->getBraceRange(),
Enum,
2241 llvm_unreachable(
"EnumConstantDecls can only occur within EnumDecls.");
2246 llvm_unreachable(
"BuiltinTemplateDecls cannot be instantiated.");
2254 LocalInstantiationScope Scope(SemaRef);
2267 QualifierLoc = SemaRef.SubstNestedNameSpecifierLoc(QualifierLoc,
2273 CXXRecordDecl *PrevDecl =
nullptr;
2274 ClassTemplateDecl *PrevClassTemplate =
nullptr;
2278 if (!
Found.empty()) {
2279 PrevClassTemplate = dyn_cast<ClassTemplateDecl>(
Found.front());
2280 if (PrevClassTemplate)
2289 DeclContext *DC = Owner;
2293 SS.
Adopt(QualifierLoc);
2294 DC = SemaRef.computeDeclContext(SS);
2295 if (!DC)
return nullptr;
2297 DC = SemaRef.FindInstantiatedContext(Pattern->
getLocation(),
2306 SemaRef.forRedeclarationInCurContext());
2307 SemaRef.LookupQualifiedName(R, DC);
2309 if (R.isSingleResult()) {
2310 PrevClassTemplate = R.getAsSingle<ClassTemplateDecl>();
2311 if (PrevClassTemplate)
2315 if (!PrevClassTemplate && QualifierLoc) {
2316 SemaRef.Diag(Pattern->
getLocation(), diag::err_not_tag_in_scope)
2329 SemaRef.InstantiateAttrsForDecl(TemplateArgs, Pattern, RecordInst, LateAttrs,
2332 ClassTemplateDecl *Inst
2338 assert(!Owner->isDependentContext());
2343 if (PrevClassTemplate) {
2345 const ClassTemplateDecl *MostRecentPrevCT =
2347 TemplateParameterList *PrevParams =
2351 if (!SemaRef.TemplateParameterListsAreEqual(
2358 if (SemaRef.CheckTemplateParameterList(InstParams, PrevParams,
2372 if (!PrevClassTemplate)
2389 Owner->addDecl(Inst);
2391 if (!PrevClassTemplate) {
2395 SmallVector<ClassTemplatePartialSpecializationDecl *, 4> PartialSpecs;
2397 for (
unsigned I = 0, N = PartialSpecs.size(); I != N; ++I)
2398 if (PartialSpecs[I]->getFirstDecl()->isOutOfLine())
2399 OutOfLinePartialSpecs.push_back(std::make_pair(Inst, PartialSpecs[I]));
2406TemplateDeclInstantiator::VisitClassTemplatePartialSpecializationDecl(
2417 ClassTemplateDecl *InstClassTemplate
2418 = dyn_cast<ClassTemplateDecl>(
Found.front());
2419 if (!InstClassTemplate)
2422 if (ClassTemplatePartialSpecializationDecl *
Result
2431 "Only static data member templates are allowed.");
2435 LocalInstantiationScope Scope(SemaRef);
2442 VarTemplateDecl *PrevVarTemplate =
nullptr;
2447 PrevVarTemplate = dyn_cast<VarTemplateDecl>(
Found.front());
2453 if (!VarInst)
return nullptr;
2455 DeclContext *DC = Owner;
2464 if (!PrevVarTemplate)
2472 Owner->addDecl(Inst);
2474 if (!PrevVarTemplate) {
2478 SmallVector<VarTemplatePartialSpecializationDecl *, 1> PartialSpecs;
2480 for (
unsigned I = 0, N = PartialSpecs.size(); I != N; ++I)
2481 if (PartialSpecs[I]->getFirstDecl()->isOutOfLine())
2482 OutOfLineVarPartialSpecs.push_back(
2483 std::make_pair(Inst, PartialSpecs[I]));
2489Decl *TemplateDeclInstantiator::VisitVarTemplatePartialSpecializationDecl(
2492 "Only static data member templates are allowed.");
2498 assert(!
Found.empty() &&
"Instantiation found nothing?");
2500 VarTemplateDecl *InstVarTemplate = dyn_cast<VarTemplateDecl>(
Found.front());
2501 assert(InstVarTemplate &&
"Instantiation did not find a variable template?");
2503 if (VarTemplatePartialSpecializationDecl *
Result =
2516 LocalInstantiationScope Scope(SemaRef);
2517 Sema::ConstraintEvalRAII<TemplateDeclInstantiator> RAII(*
this);
2524 FunctionDecl *Instantiated =
nullptr;
2525 if (CXXMethodDecl *DMethod = dyn_cast<CXXMethodDecl>(D->
getTemplatedDecl()))
2538 FunctionTemplateDecl *InstTemplate
2541 assert(InstTemplate &&
2542 "VisitFunctionDecl/CXXMethodDecl didn't create a template!");
2554 Owner->addDecl(InstTemplate);
2557 SemaRef.CheckFriendAccess(InstTemplate);
2560 return InstTemplate;
2564 CXXRecordDecl *PrevDecl =
nullptr;
2566 NamedDecl *Prev = SemaRef.FindInstantiatedDecl(D->
getLocation(),
2569 if (!Prev)
return nullptr;
2573 CXXRecordDecl *
Record =
nullptr;
2591 SemaRef.InstantiateAttrsForDecl(TemplateArgs, D,
Record, LateAttrs,
2599 if (!IsInjectedClassName)
2605 Record->setObjectOfFriendDecl();
2609 Record->setAnonymousStructOrUnion(
true);
2612 SemaRef.CurrentInstantiationScope->InstantiatedLocal(D,
Record);
2615 SemaRef.Context.setManglingNumber(
Record,
2616 SemaRef.Context.getManglingNumber(D));
2620 if (DeclaratorDecl *DD = SemaRef.Context.getDeclaratorForUnnamedTagDecl(D))
2621 SemaRef.Context.addDeclaratorForUnnamedTagDecl(
Record, DD);
2625 if (TypedefNameDecl *TND = SemaRef.Context.getTypedefNameForUnnamedTagDecl(D))
2626 SemaRef.Context.addTypedefNameForUnnamedTagDecl(
Record, TND);
2633 Sema::LocalEagerInstantiationScope LocalInstantiations(SemaRef,
2648 LocalInstantiations.perform();
2651 SemaRef.DiagnoseUnusedNestedTypedefs(
Record);
2653 if (IsInjectedClassName)
2654 assert(
Record->isInjectedClassName() &&
"Broken injected-class-name");
2672 if (OrigFunc->
getExtInfo() == NewFunc->getExtInfo())
2677 return Context.getFunctionType(NewFunc->getReturnType(),
2678 NewFunc->getParamTypes(), NewEPI);
2702 if (isFriend && Source->wasThisDeclarationADefinition(D)) {
2714 void *InsertPos =
nullptr;
2723 bool MergeWithParentScope = (TemplateParams !=
nullptr) ||
2724 Owner->isFunctionOrMethod() ||
2726 cast<Decl>(Owner)->isDefinedOutsideFunctionOrMethod());
2730 if (
auto *DGuide = dyn_cast<CXXDeductionGuideDecl>(D)) {
2731 InstantiatedExplicitSpecifier = SemaRef.instantiateExplicitSpecifier(
2732 TemplateArgs, DGuide->getExplicitSpecifier());
2733 if (InstantiatedExplicitSpecifier.
isInvalid())
2743 if (TemplateParams && TemplateParams->
size()) {
2745 dyn_cast<TemplateTypeParmDecl>(TemplateParams->
asArray().back());
2746 if (LastParam && LastParam->isImplicit() &&
2747 LastParam->hasTypeConstraint()) {
2762 QualifierLoc = SemaRef.SubstNestedNameSpecifierLoc(QualifierLoc,
2776 SemaRef.adjustContextForLocalExternDecl(DC);
2777 }
else if (isFriend && QualifierLoc) {
2779 SS.
Adopt(QualifierLoc);
2780 DC = SemaRef.computeDeclContext(SS);
2781 if (!DC)
return nullptr;
2788 = SemaRef.SubstDeclarationNameInfo(D->
getNameInfo(), TemplateArgs);
2794 if (
auto *DGuide = dyn_cast<CXXDeductionGuideDecl>(D)) {
2797 InstantiatedExplicitSpecifier, NameInfo,
T, TInfo,
2799 DGuide->getDeductionCandidateKind(), TrailingRequiresClause,
2800 DGuide->getSourceDeductionGuide(),
2801 DGuide->getSourceDeductionGuideKind());
2808 TrailingRequiresClause);
2809 Function->setFriendConstraintRefersToEnclosingTemplate(
2818 Function->setQualifierInfo(QualifierLoc);
2829 LexicalDC = SemaRef.CurContext;
2833 Function->setIsTypeAwareOperatorNewOrDelete(
2835 Function->setLexicalDeclContext(LexicalDC);
2838 for (
unsigned P = 0; P < Params.size(); ++P)
2840 Params[P]->setOwningFunction(
Function);
2843 if (TrailingRequiresClause)
2844 Function->setTrailingRequiresClause(TrailingRequiresClause);
2846 if (TemplateParams) {
2874 SemaRef.CodeSynthesisContexts.back().Kind !=
2888 }
else if (!isFriend) {
2892 Function->setInstantiatedFromDecl(D);
2899 FT->setObjectOfFriendDecl();
2905 bool IsExplicitSpecialization =
false;
2912 : SemaRef.forRedeclarationInCurContext());
2916 assert(isFriend &&
"dependent specialization info on "
2917 "non-member non-friend function?");
2921 if (
const auto *ArgsWritten = DFTSI->TemplateArgumentsAsWritten) {
2922 ExplicitArgs.
setLAngleLoc(ArgsWritten->getLAngleLoc());
2923 ExplicitArgs.
setRAngleLoc(ArgsWritten->getRAngleLoc());
2924 if (SemaRef.SubstTemplateArguments(ArgsWritten->arguments(), TemplateArgs,
2932 SemaRef.FindInstantiatedDecl(D->
getLocation(), FTD, TemplateArgs))
2938 if (SemaRef.CheckFunctionTemplateSpecialization(
2940 DFTSI->TemplateArgumentsAsWritten ? &ExplicitArgs :
nullptr,
2944 IsExplicitSpecialization =
true;
2948 SemaRef.LookupQualifiedName(
Previous, DC);
2952 ArgsWritten->getRAngleLoc());
2953 if (SemaRef.SubstTemplateArguments(ArgsWritten->arguments(), TemplateArgs,
2957 if (SemaRef.CheckFunctionTemplateSpecialization(
Function,
2962 IsExplicitSpecialization =
true;
2979 if (isFriend && !QualifierLoc) {
2980 SemaRef.FilterLookupForScope(
Previous, DC,
nullptr,
2999 if (
Function->isLocalExternDecl()) {
3001 if (!PVD->hasDefaultArg())
3003 if (SemaRef.SubstDefaultArgument(D->
getInnerLocStart(), PVD, TemplateArgs)) {
3007 Expr *UninstExpr = PVD->getUninstantiatedDefaultArg();
3008 ExprResult ErrorResult = SemaRef.CreateRecoveryExpr(
3010 { UninstExpr }, UninstExpr->
getType());
3012 PVD->setDefaultArg(ErrorResult.
get());
3018 IsExplicitSpecialization,
3019 Function->isThisDeclarationADefinition());
3026 SemaRef.CheckTemplateParameterList(
3029 Function->isThisDeclarationADefinition()
3040 Function->getMemberSpecializationInfo()) {
3041 if (MSInfo->getPointOfInstantiation().isInvalid()) {
3043 MSInfo->setPointOfInstantiation(Loc);
3044 SemaRef.PendingLocalImplicitInstantiations.emplace_back(
Function, Loc);
3082 void *InsertPos =
nullptr;
3097 bool MergeWithParentScope = (TemplateParams !=
nullptr) ||
3099 cast<Decl>(Owner)->isDefinedOutsideFunctionOrMethod());
3103 SemaRef, D, TemplateArgs,
Scope);
3107 unsigned NumTempParamLists = 0;
3109 TempParamLists.resize(NumTempParamLists);
3110 for (
unsigned I = 0; I != NumTempParamLists; ++I) {
3115 TempParamLists[I] = InstParams;
3121 const bool CouldInstantiate =
3122 InstantiatedExplicitSpecifier.getExpr() ==
nullptr ||
3123 !InstantiatedExplicitSpecifier.getExpr()->isValueDependent();
3127 if (CouldInstantiate ||
3128 SemaRef.CodeSynthesisContexts.back().Kind !=
3130 InstantiatedExplicitSpecifier = SemaRef.instantiateExplicitSpecifier(
3131 TemplateArgs, InstantiatedExplicitSpecifier);
3133 if (InstantiatedExplicitSpecifier.isInvalid())
3148 SemaRef.Context.getTrivialTypeSourceInfo(D->
getType());
3158 if (TemplateParams && TemplateParams->
size()) {
3160 dyn_cast<TemplateTypeParmDecl>(TemplateParams->
asArray().back());
3161 if (LastParam && LastParam->isImplicit() &&
3162 LastParam->hasTypeConstraint()) {
3177 QualifierLoc = SemaRef.SubstNestedNameSpecifierLoc(QualifierLoc,
3187 SS.
Adopt(QualifierLoc);
3188 DC = SemaRef.computeDeclContext(SS);
3190 if (DC && SemaRef.RequireCompleteDeclContext(SS, DC))
3193 DC = SemaRef.FindInstantiatedContext(D->
getLocation(),
3197 if (!DC)
return nullptr;
3204 = SemaRef.SubstDeclarationNameInfo(D->
getNameInfo(), TemplateArgs);
3215 SemaRef.Context,
Record, StartLoc, NameInfo,
T, TInfo,
3216 InstantiatedExplicitSpecifier,
Constructor->UsesFPIntrin(),
3219 TrailingRequiresClause);
3223 SemaRef.Context,
Record, StartLoc, NameInfo,
T, TInfo,
3225 Destructor->getConstexprKind(), TrailingRequiresClause);
3226 Method->setIneligibleOrNotSelected(
true);
3228 Method->setDeclName(SemaRef.Context.DeclarationNames.getCXXDestructorName(
3230 SemaRef.Context.getCanonicalTagType(
Record)));
3233 SemaRef.Context,
Record, StartLoc, NameInfo,
T, TInfo,
3234 Conversion->UsesFPIntrin(), Conversion->isInlineSpecified(),
3235 InstantiatedExplicitSpecifier, Conversion->getConstexprKind(),
3236 Conversion->getEndLoc(), TrailingRequiresClause);
3240 SemaRef.Context,
Record, StartLoc, NameInfo,
T, TInfo, SC,
3242 D->
getEndLoc(), TrailingRequiresClause);
3246 Method->setImplicitlyInline();
3249 Method->setQualifierInfo(QualifierLoc);
3251 if (TemplateParams) {
3291 if (NumTempParamLists)
3292 Method->setTemplateParameterListsInfo(
3296 Method->setLexicalDeclContext(Owner);
3297 Method->setObjectOfFriendDecl();
3302 for (
unsigned P = 0; P < Params.size(); ++P)
3303 Params[P]->setOwningFunction(
Method);
3304 Method->setParams(Params);
3307 Method->setInvalidDecl();
3312 bool IsExplicitSpecialization =
false;
3320 if (
const auto *ArgsWritten = DFTSI->TemplateArgumentsAsWritten) {
3321 ExplicitArgs.
setLAngleLoc(ArgsWritten->getLAngleLoc());
3322 ExplicitArgs.
setRAngleLoc(ArgsWritten->getRAngleLoc());
3323 if (SemaRef.SubstTemplateArguments(ArgsWritten->arguments(), TemplateArgs,
3331 SemaRef.FindInstantiatedDecl(D->
getLocation(), FTD, TemplateArgs))
3337 if (SemaRef.CheckFunctionTemplateSpecialization(
3338 Method, DFTSI->TemplateArgumentsAsWritten ? &ExplicitArgs :
nullptr,
3340 Method->setInvalidDecl();
3342 IsExplicitSpecialization =
true;
3345 SemaRef.LookupQualifiedName(
Previous, DC);
3348 ArgsWritten->getRAngleLoc());
3350 if (SemaRef.SubstTemplateArguments(ArgsWritten->arguments(), TemplateArgs,
3354 if (SemaRef.CheckFunctionTemplateSpecialization(
Method,
3357 Method->setInvalidDecl();
3359 IsExplicitSpecialization =
true;
3387 for (
unsigned P = 0; P < Params.size(); ++P) {
3388 if (!Params[P]->hasDefaultArg())
3390 if (SemaRef.SubstDefaultArgument(StartLoc, Params[P], TemplateArgs)) {
3394 Expr *UninstExpr = Params[P]->getUninstantiatedDefaultArg();
3395 ExprResult ErrorResult = SemaRef.CreateRecoveryExpr(
3397 { UninstExpr }, UninstExpr->
getType());
3399 Params[P]->setDefaultArg(ErrorResult.
get());
3405 IsExplicitSpecialization,
3406 Method->isThisDeclarationADefinition());
3414 if (isFriend &&
Method->getPreviousDecl())
3415 Method->setAccess(
Method->getPreviousDecl()->getAccess());
3421 SemaRef.CheckOverrideControl(
Method);
3435 if (IsExplicitSpecialization && !isFriend)
3448 Method->setIneligibleOrNotSelected(
true);
3449 }
else if (
Method->isCopyAssignmentOperator() ||
3450 Method->isMoveAssignmentOperator()) {
3451 Method->setIneligibleOrNotSelected(
true);
3463 }
else if (isFriend) {
3467 SemaRef.CheckFriendAccess(
Method);
3480 if (
Method->hasAttr<UsedAttr>()) {
3481 if (
const auto *A = dyn_cast<CXXRecordDecl>(Owner)) {
3484 A->getMemberSpecializationInfo())
3485 Loc = MSInfo->getPointOfInstantiation();
3486 else if (
const auto *Spec = dyn_cast<ClassTemplateSpecializationDecl>(A))
3487 Loc = Spec->getPointOfInstantiation();
3488 SemaRef.MarkFunctionReferenced(Loc,
Method);
3508 return SemaRef.SubstParmVarDecl(D, TemplateArgs, 0,
3513Decl *TemplateDeclInstantiator::VisitTemplateTypeParmDecl(
3517 UnsignedOrNone NumExpanded = std::nullopt;
3521 assert(TC->getTemplateArgsAsWritten() &&
3522 "type parameter can only be an expansion when explicit arguments "
3527 SmallVector<UnexpandedParameterPack, 2> Unexpanded;
3528 for (
auto &ArgLoc : TC->getTemplateArgsAsWritten()->arguments())
3529 SemaRef.collectUnexpandedParameterPacks(ArgLoc, Unexpanded);
3534 bool RetainExpansion =
false;
3535 if (SemaRef.CheckParameterPacksForExpansion(
3538 SourceRange(TC->getConceptNameLoc(),
3539 TC->hasExplicitTemplateArgs()
3540 ? TC->getTemplateArgsAsWritten()->getRAngleLoc()
3541 : TC->getConceptNameInfo().getEndLoc()),
3542 Unexpanded, TemplateArgs,
true,
3543 Expand, RetainExpansion, NumExpanded))
3561 if (SemaRef.SubstTypeConstraint(Inst, TC, TemplateArgs,
3562 EvaluateConstraints))
3567 TemplateArgumentLoc Output;
3575 SemaRef.CurrentInstantiationScope->InstantiatedLocal(D, Inst);
3580Decl *TemplateDeclInstantiator::VisitNonTypeTemplateParmDecl(
3584 SmallVector<TypeSourceInfo *, 4> ExpandedParameterPackTypesAsWritten;
3585 SmallVector<QualType, 4> ExpandedParameterPackTypes;
3586 bool IsExpandedParameterPack =
false;
3597 TypeSourceInfo *NewDI =
3604 SemaRef.CheckNonTypeTemplateParameterType(NewDI, D->
getLocation());
3608 ExpandedParameterPackTypesAsWritten.push_back(NewDI);
3609 ExpandedParameterPackTypes.push_back(NewT);
3612 IsExpandedParameterPack =
true;
3619 PackExpansionTypeLoc Expansion = TL.
castAs<PackExpansionTypeLoc>();
3621 SmallVector<UnexpandedParameterPack, 2> Unexpanded;
3622 SemaRef.collectUnexpandedParameterPacks(Pattern, Unexpanded);
3627 bool RetainExpansion =
false;
3628 UnsignedOrNone OrigNumExpansions =
3630 UnsignedOrNone NumExpansions = OrigNumExpansions;
3631 if (SemaRef.CheckParameterPacksForExpansion(
3632 Expansion.
getEllipsisLoc(), Pattern.getSourceRange(), Unexpanded,
3633 TemplateArgs,
true, Expand,
3634 RetainExpansion, NumExpansions))
3638 for (
unsigned I = 0; I != *NumExpansions; ++I) {
3639 Sema::ArgPackSubstIndexRAII SubstIndex(SemaRef, I);
3640 TypeSourceInfo *NewDI = SemaRef.SubstType(Pattern, TemplateArgs,
3647 SemaRef.CheckNonTypeTemplateParameterType(NewDI, D->
getLocation());
3651 ExpandedParameterPackTypesAsWritten.push_back(NewDI);
3652 ExpandedParameterPackTypes.push_back(NewT);
3658 IsExpandedParameterPack =
true;
3664 Sema::ArgPackSubstIndexRAII SubstIndex(SemaRef, std::nullopt);
3665 TypeSourceInfo *NewPattern = SemaRef.SubstType(Pattern, TemplateArgs,
3671 SemaRef.CheckNonTypeTemplateParameterType(NewPattern, D->
getLocation());
3672 DI = SemaRef.CheckPackExpansion(NewPattern, Expansion.
getEllipsisLoc(),
3687 T = SemaRef.CheckNonTypeTemplateParameterType(DI, D->
getLocation());
3689 T = SemaRef.Context.IntTy;
3694 NonTypeTemplateParmDecl *Param;
3695 if (IsExpandedParameterPack)
3698 D->
getDepth() - TemplateArgs.getNumSubstitutedLevels(),
3700 ExpandedParameterPackTypesAsWritten);
3704 D->
getDepth() - TemplateArgs.getNumSubstitutedLevels(),
3708 if (AutoLoc.isConstrained()) {
3709 SourceLocation EllipsisLoc;
3710 if (IsExpandedParameterPack)
3713 else if (
auto *Constraint = dyn_cast_if_present<CXXFoldExpr>(
3715 EllipsisLoc = Constraint->getEllipsisLoc();
3719 if (SemaRef.AttachTypeConstraint(AutoLoc, Param,
3730 EnterExpressionEvaluationContext ConstantEvaluated(
3732 TemplateArgumentLoc
Result;
3740 SemaRef.CurrentInstantiationScope->InstantiatedLocal(D, Param);
3748 for (
const auto &P : *Params) {
3749 if (P->isTemplateParameterPack())
3761TemplateDeclInstantiator::VisitTemplateTemplateParmDecl(
3765 TemplateParameterList *InstParams;
3766 SmallVector<TemplateParameterList*, 8> ExpandedParams;
3768 bool IsExpandedParameterPack =
false;
3777 LocalInstantiationScope Scope(SemaRef,
true);
3778 TemplateParameterList *Expansion =
3782 ExpandedParams.push_back(Expansion);
3785 IsExpandedParameterPack =
true;
3786 InstParams = TempParams;
3791 SmallVector<UnexpandedParameterPack, 2> Unexpanded;
3798 bool RetainExpansion =
false;
3799 UnsignedOrNone NumExpansions = std::nullopt;
3800 if (SemaRef.CheckParameterPacksForExpansion(
3802 TemplateArgs,
true, Expand,
3803 RetainExpansion, NumExpansions))
3807 for (
unsigned I = 0; I != *NumExpansions; ++I) {
3808 Sema::ArgPackSubstIndexRAII SubstIndex(SemaRef, I);
3809 LocalInstantiationScope Scope(SemaRef,
true);
3813 ExpandedParams.push_back(Expansion);
3819 IsExpandedParameterPack =
true;
3822 Sema::ArgPackSubstIndexRAII SubstIndex(SemaRef, std::nullopt);
3824 LocalInstantiationScope Scope(SemaRef,
true);
3831 LocalInstantiationScope Scope(SemaRef,
true);
3838 TemplateTemplateParmDecl *Param;
3839 if (IsExpandedParameterPack)
3842 D->
getDepth() - TemplateArgs.getNumSubstitutedLevels(),
3848 D->
getDepth() - TemplateArgs.getNumSubstitutedLevels(),
3861 TemplateArgumentLoc(SemaRef.Context, TemplateArgument(TName),
3870 SemaRef.CurrentInstantiationScope->InstantiatedLocal(D, Param);
3879 UsingDirectiveDecl *Inst
3889 if (!Owner->isFunctionOrMethod())
3890 Owner->addDecl(Inst);
3899 bool isFunctionScope = Owner->isFunctionOrMethod();
3901 for (
auto *Shadow : D->
shadows()) {
3905 NamedDecl *OldTarget = Shadow->getTargetDecl();
3906 if (
auto *CUSD = dyn_cast<ConstructorUsingShadowDecl>(Shadow))
3907 if (
auto *BaseShadow = CUSD->getNominatedBaseClassShadowDecl())
3908 OldTarget = BaseShadow;
3912 dyn_cast<UnresolvedUsingIfExistsDecl>(Shadow->getTargetDecl())) {
3914 SemaRef.Context, Owner, EmptyD->getLocation(), EmptyD->getDeclName());
3916 InstTarget = cast_or_null<NamedDecl>(SemaRef.FindInstantiatedDecl(
3917 Shadow->getLocation(), OldTarget, TemplateArgs));
3924 SemaRef.CheckUsingShadowDecl(Inst, InstTarget, *Lookup, PrevDecl))
3928 PrevDecl = cast_or_null<UsingShadowDecl>(SemaRef.FindInstantiatedDecl(
3929 Shadow->getLocation(), OldPrev, TemplateArgs));
3932 nullptr, Inst, InstTarget, PrevDecl);
3933 SemaRef.Context.setInstantiatedFromUsingShadowDecl(InstShadow, Shadow);
3935 if (isFunctionScope)
3936 SemaRef.CurrentInstantiationScope->InstantiatedLocal(Shadow, InstShadow);
3942Decl *TemplateDeclInstantiator::VisitUsingDecl(
UsingDecl *D) {
3963 if (
auto *RD = dyn_cast<CXXRecordDecl>(SemaRef.
CurContext))
3969 bool CheckRedeclaration = Owner->
isRecord();
3980 SS.
Adopt(QualifierLoc);
3981 if (CheckRedeclaration) {
3982 Prev.setHideTags(
false);
4015 EnumDecl *EnumD = cast_or_null<EnumDecl>(SemaRef.FindInstantiatedDecl(
4018 if (SemaRef.RequireCompleteEnumDecl(EnumD, EnumD->
getLocation()))
4021 TypeSourceInfo *TSI = SemaRef.SubstType(D->
getEnumType(), TemplateArgs,
4027 UsingEnumDecl *NewUD =
4031 SemaRef.Context.setInstantiatedFromUsingEnumDecl(NewUD, D);
4033 Owner->addDecl(NewUD);
4051Decl *TemplateDeclInstantiator::VisitConstructorUsingShadowDecl(
4057template <
typename T>
4058Decl *TemplateDeclInstantiator::instantiateUnresolvedUsingDecl(
4059 T *D,
bool InstantiatingPackElement) {
4061 if (D->isPackExpansion() && !InstantiatingPackElement) {
4062 SmallVector<UnexpandedParameterPack, 2> Unexpanded;
4063 SemaRef.collectUnexpandedParameterPacks(D->getQualifierLoc(), Unexpanded);
4064 SemaRef.collectUnexpandedParameterPacks(D->getNameInfo(), Unexpanded);
4069 bool RetainExpansion =
false;
4070 UnsignedOrNone NumExpansions = std::nullopt;
4071 if (SemaRef.CheckParameterPacksForExpansion(
4072 D->getEllipsisLoc(), D->getSourceRange(), Unexpanded, TemplateArgs,
4073 true, Expand, RetainExpansion,
4079 assert(!RetainExpansion &&
4080 "should never need to retain an expansion for UsingPackDecl");
4085 Sema::ArgPackSubstIndexRAII SubstIndex(SemaRef, std::nullopt);
4086 return instantiateUnresolvedUsingDecl(D,
true);
4096 if (D->getDeclContext()->isFunctionOrMethod() && *NumExpansions > 1) {
4097 SemaRef.Diag(D->getEllipsisLoc(),
4098 diag::err_using_decl_redeclaration_expansion);
4103 SmallVector<NamedDecl*, 8> Expansions;
4104 for (
unsigned I = 0; I != *NumExpansions; ++I) {
4105 Sema::ArgPackSubstIndexRAII SubstIndex(SemaRef, I);
4106 Decl *Slice = instantiateUnresolvedUsingDecl(D,
true);
4116 auto *NewD = SemaRef.BuildUsingPackDecl(D, Expansions);
4118 SemaRef.CurrentInstantiationScope->InstantiatedLocal(D, NewD);
4122 UnresolvedUsingTypenameDecl *TD = dyn_cast<UnresolvedUsingTypenameDecl>(D);
4123 SourceLocation TypenameLoc = TD ? TD->
getTypenameLoc() : SourceLocation();
4125 NestedNameSpecifierLoc QualifierLoc
4126 = SemaRef.SubstNestedNameSpecifierLoc(D->getQualifierLoc(),
4132 SS.
Adopt(QualifierLoc);
4134 DeclarationNameInfo NameInfo
4135 = SemaRef.SubstDeclarationNameInfo(D->getNameInfo(), TemplateArgs);
4139 bool InstantiatingSlice =
4140 D->getEllipsisLoc().isValid() && SemaRef.ArgPackSubstIndex;
4141 SourceLocation EllipsisLoc =
4142 InstantiatingSlice ? SourceLocation() : D->getEllipsisLoc();
4145 NamedDecl *UD = SemaRef.BuildUsingDeclaration(
4146 nullptr, D->getAccess(), D->getUsingLoc(),
4147 TD, TypenameLoc, SS, NameInfo, EllipsisLoc,
4148 ParsedAttributesView(),
4149 true, IsUsingIfExists);
4151 SemaRef.InstantiateAttrs(TemplateArgs, D, UD);
4152 SemaRef.Context.setInstantiatedFromUsingDecl(UD, D);
4158Decl *TemplateDeclInstantiator::VisitUnresolvedUsingTypenameDecl(
4160 return instantiateUnresolvedUsingDecl(D);
4163Decl *TemplateDeclInstantiator::VisitUnresolvedUsingValueDecl(
4165 return instantiateUnresolvedUsingDecl(D);
4168Decl *TemplateDeclInstantiator::VisitUnresolvedUsingIfExistsDecl(
4170 llvm_unreachable(
"referring to unresolved decl out of UsingShadowDecl");
4174 SmallVector<NamedDecl*, 8> Expansions;
4176 if (NamedDecl *NewUD =
4177 SemaRef.FindInstantiatedDecl(D->
getLocation(), UD, TemplateArgs))
4178 Expansions.push_back(NewUD);
4183 auto *NewD = SemaRef.BuildUsingPackDecl(D, Expansions);
4185 SemaRef.CurrentInstantiationScope->InstantiatedLocal(D, NewD);
4189Decl *TemplateDeclInstantiator::VisitOMPThreadPrivateDecl(
4191 SmallVector<Expr *, 5> Vars;
4192 for (
auto *I : D->
varlist()) {
4193 Expr *Var = SemaRef.SubstExpr(I, TemplateArgs).get();
4195 Vars.push_back(Var);
4198 OMPThreadPrivateDecl *TD =
4199 SemaRef.OpenMP().CheckOMPThreadPrivateDecl(D->
getLocation(), Vars);
4209 SmallVector<Expr *, 5> Vars;
4210 for (
auto *I : D->
varlist()) {
4211 Expr *Var = SemaRef.SubstExpr(I, TemplateArgs).get();
4213 Vars.push_back(Var);
4216 OMPGroupPrivateDecl *TD =
4217 SemaRef.OpenMP().CheckOMPGroupPrivateDecl(D->
getLocation(), Vars);
4226 SmallVector<Expr *, 5> Vars;
4227 for (
auto *I : D->
varlist()) {
4228 Expr *Var = SemaRef.SubstExpr(I, TemplateArgs).get();
4230 Vars.push_back(Var);
4232 SmallVector<OMPClause *, 4> Clauses;
4235 OMPClause *IC =
nullptr;
4236 if (
auto *AC = dyn_cast<OMPAllocatorClause>(
C)) {
4237 ExprResult NewE = SemaRef.SubstExpr(AC->getAllocator(), TemplateArgs);
4240 IC = SemaRef.OpenMP().ActOnOpenMPAllocatorClause(
4241 NewE.
get(), AC->
getBeginLoc(), AC->getLParenLoc(), AC->getEndLoc());
4242 }
else if (
auto *AC = dyn_cast<OMPAlignClause>(
C)) {
4243 ExprResult NewE = SemaRef.SubstExpr(AC->getAlignment(), TemplateArgs);
4246 IC = SemaRef.OpenMP().ActOnOpenMPAlignClause(
4247 NewE.
get(), AC->
getBeginLoc(), AC->getLParenLoc(), AC->getEndLoc());
4252 Clauses.push_back(IC);
4264 "Requires directive cannot be instantiated within a dependent context");
4267Decl *TemplateDeclInstantiator::VisitOMPDeclareReductionDecl(
4270 const bool RequiresInstantiation =
4274 QualType SubstReductionType;
4275 if (RequiresInstantiation) {
4276 SubstReductionType = SemaRef.OpenMP().ActOnOpenMPDeclareReductionType(
4281 SubstReductionType = D->
getType();
4283 if (SubstReductionType.
isNull())
4287 bool IsCorrect =
true;
4289 std::pair<QualType, SourceLocation> ReductionTypes[] = {
4290 std::make_pair(SubstReductionType, D->
getLocation())};
4292 if (PrevDeclInScope && !PrevDeclInScope->isInvalidDecl()) {
4294 cast<Decl *>(*SemaRef.CurrentInstantiationScope->findInstantiationOf(
4297 auto DRD = SemaRef.OpenMP().ActOnOpenMPDeclareReductionDirectiveStart(
4301 SemaRef.CurrentInstantiationScope->InstantiatedLocal(D, NewDRD);
4302 Expr *SubstCombiner =
nullptr;
4303 Expr *SubstInitializer =
nullptr;
4306 SemaRef.OpenMP().ActOnOpenMPDeclareReductionCombinerStart(
4308 SemaRef.CurrentInstantiationScope->InstantiatedLocal(
4311 SemaRef.CurrentInstantiationScope->InstantiatedLocal(
4314 auto *ThisContext = dyn_cast_or_null<CXXRecordDecl>(Owner);
4315 Sema::CXXThisScopeRAII ThisScope(SemaRef, ThisContext, Qualifiers(),
4317 SubstCombiner = SemaRef.SubstExpr(Combiner, TemplateArgs).get();
4318 SemaRef.OpenMP().ActOnOpenMPDeclareReductionCombinerEnd(NewDRD,
4323 VarDecl *OmpPrivParm =
4324 SemaRef.OpenMP().ActOnOpenMPDeclareReductionInitializerStart(
4326 SemaRef.CurrentInstantiationScope->InstantiatedLocal(
4329 SemaRef.CurrentInstantiationScope->InstantiatedLocal(
4333 SubstInitializer = SemaRef.SubstExpr(
Init, TemplateArgs).get();
4337 IsCorrect = IsCorrect && OldPrivParm->hasInit();
4339 SemaRef.InstantiateVariableInitializer(OmpPrivParm, OldPrivParm,
4342 SemaRef.OpenMP().ActOnOpenMPDeclareReductionInitializerEnd(
4343 NewDRD, SubstInitializer, OmpPrivParm);
4345 IsCorrect = IsCorrect && SubstCombiner &&
4348 SubstInitializer) ||
4350 !SubstInitializer));
4352 (void)SemaRef.OpenMP().ActOnOpenMPDeclareReductionDirectiveEnd(
4361 const bool RequiresInstantiation =
4365 QualType SubstMapperTy;
4367 if (RequiresInstantiation) {
4368 SubstMapperTy = SemaRef.OpenMP().ActOnOpenMPDeclareMapperType(
4375 if (SubstMapperTy.
isNull())
4379 if (PrevDeclInScope && !PrevDeclInScope->isInvalidDecl()) {
4381 cast<Decl *>(*SemaRef.CurrentInstantiationScope->findInstantiationOf(
4384 bool IsCorrect =
true;
4385 SmallVector<OMPClause *, 6> Clauses;
4387 DeclarationNameInfo DirName;
4388 SemaRef.OpenMP().StartOpenMPDSABlock(llvm::omp::OMPD_declare_mapper, DirName,
4392 SemaRef.OpenMP().ActOnOpenMPDeclareMapperDirectiveVarDecl(
4394 SemaRef.CurrentInstantiationScope->InstantiatedLocal(
4397 auto *ThisContext = dyn_cast_or_null<CXXRecordDecl>(Owner);
4398 Sema::CXXThisScopeRAII ThisScope(SemaRef, ThisContext, Qualifiers(),
4403 SmallVector<Expr *, 4> NewVars;
4404 for (Expr *OE : OldC->varlist()) {
4405 Expr *
NE = SemaRef.SubstExpr(OE, TemplateArgs).get();
4410 NewVars.push_back(NE);
4414 NestedNameSpecifierLoc NewQualifierLoc =
4415 SemaRef.SubstNestedNameSpecifierLoc(OldC->getMapperQualifierLoc(),
4418 SS.
Adopt(NewQualifierLoc);
4419 DeclarationNameInfo NewNameInfo =
4420 SemaRef.SubstDeclarationNameInfo(OldC->getMapperIdInfo(), TemplateArgs);
4421 OMPVarListLocTy Locs(OldC->getBeginLoc(), OldC->getLParenLoc(),
4423 OMPClause *NewC = SemaRef.OpenMP().ActOnOpenMPMapClause(
4424 OldC->getIteratorModifier(), OldC->getMapTypeModifiers(),
4425 OldC->getMapTypeModifiersLoc(), SS, NewNameInfo, OldC->getMapType(),
4426 OldC->isImplicitMapType(), OldC->getMapLoc(), OldC->getColonLoc(),
4428 Clauses.push_back(NewC);
4430 SemaRef.OpenMP().EndOpenMPDSABlock(
nullptr);
4435 VN, D->
getAccess(), MapperVarRef.
get(), Clauses, PrevDeclInScope);
4437 SemaRef.CurrentInstantiationScope->InstantiatedLocal(D, NewDMD);
4441Decl *TemplateDeclInstantiator::VisitOMPCapturedExprDecl(
4443 llvm_unreachable(
"Should not be met in templates");
4454 Owner->addDecl(Inst);
4463 llvm_unreachable(
"There are only CXXRecordDecls in C++");
4467TemplateDeclInstantiator::VisitClassTemplateSpecializationDecl(
4474 "can only instantiate an explicit specialization "
4475 "for a member class template");
4479 ClassTemplateDecl *InstClassTemplate =
4480 cast_or_null<ClassTemplateDecl>(SemaRef.FindInstantiatedDecl(
4482 if (!InstClassTemplate)
4487 TemplateArgumentListInfo InstTemplateArgs;
4488 if (
const ASTTemplateArgumentListInfo *TemplateArgsInfo =
4490 InstTemplateArgs.
setLAngleLoc(TemplateArgsInfo->getLAngleLoc());
4491 InstTemplateArgs.
setRAngleLoc(TemplateArgsInfo->getRAngleLoc());
4493 if (SemaRef.SubstTemplateArguments(TemplateArgsInfo->arguments(),
4494 TemplateArgs, InstTemplateArgs))
4500 Sema::CheckTemplateArgumentInfo CTAI;
4501 if (SemaRef.CheckTemplateArgumentList(
4502 InstClassTemplate, D->
getLocation(), InstTemplateArgs,
4509 void *InsertPos =
nullptr;
4510 ClassTemplateSpecializationDecl *PrevDecl =
4517 SemaRef.CheckSpecializationInstantiationRedecl(D->
getLocation(),
4539 SemaRef.Diag(D->
getLocation(), diag::err_redefinition) << PrevDecl;
4541 diag::note_previous_definition);
4546 ClassTemplateSpecializationDecl *InstD =
4568 Owner->addDecl(InstD);
4575 SemaRef.InstantiateClass(D->
getLocation(), InstD, D, TemplateArgs,
4589 "A template specialization without specialized template?");
4592 cast_or_null<VarTemplateDecl>(SemaRef.FindInstantiatedDecl(
4594 if (!InstVarTemplate)
4600 VarTemplateArgsInfo.
setLAngleLoc(TemplateArgsInfo->getLAngleLoc());
4601 VarTemplateArgsInfo.
setRAngleLoc(TemplateArgsInfo->getRAngleLoc());
4603 if (SemaRef.SubstTemplateArguments(TemplateArgsInfo->arguments(),
4604 TemplateArgs, VarTemplateArgsInfo))
4610 if (SemaRef.CheckTemplateArgumentList(
4611 InstVarTemplate, D->
getLocation(), VarTemplateArgsInfo,
4617 void *InsertPos =
nullptr;
4624 if (PrevDecl && SemaRef.CheckSpecializationInstantiationRedecl(
4632 VTSD->setTemplateArgsAsWritten(VarTemplateArgsInfo);
4652 SemaRef.
Diag(D->
getLocation(), diag::err_variable_instantiates_to_function)
4662 void *InsertPos =
nullptr;
4663 VarTemplate->findSpecialization(Converted, InsertPos);
4667 if (SemaRef.getLangOpts().OpenCL)
4668 SemaRef.deduceOpenCLAddressSpace(Var);
4674 SemaRef.BuildVariableInstantiation(Var, D, TemplateArgs, LateAttrs, Owner,
4675 StartingScope,
false, PrevDecl);
4681 llvm_unreachable(
"@defs is not supported in Objective-C++");
4686 unsigned DiagID = SemaRef.getDiagnostics().getCustomDiagID(
4688 "cannot instantiate %0 yet");
4696 llvm_unreachable(
"Concept definitions cannot reside inside a template");
4699Decl *TemplateDeclInstantiator::VisitImplicitConceptSpecializationDecl(
4701 llvm_unreachable(
"Concept specializations cannot reside inside a template");
4711 llvm_unreachable(
"Unexpected decl");
4722 SubstD = Instantiator.Visit(D);
4736 T = SemaRef.Context.getFunctionType(
4737 SemaRef.Context.BoolTy, FPT->getParamTypes(), FPT->getExtProtoInfo());
4746 SemaRef.Context.getTrivialTypeSourceInfo(
T, Orig->
getEndLoc());
4748 assert(OldLoc &&
"type of function is not a function type?");
4750 for (
unsigned I = 0, N = OldLoc.getNumParams(); I != N; ++I)
4751 NewLoc.
setParam(I, OldLoc.getParam(I));
4756 SemaRef.Context.DeclarationNames.getCXXOperatorName(OO_EqualEqual));
4761 if (Spaceship->isInvalidDecl())
4773 if (
auto *MD = dyn_cast<CXXMethodDecl>(Spaceship)) {
4778 assert(Spaceship->getFriendObjectKind() &&
4779 "defaulted spaceship is neither a member nor a friend");
4793 return cast_or_null<FunctionDecl>(R);
4807 unsigned N = L->
size();
4811 for (
auto &P : *L) {
4813 Params.push_back(D);
4833 bool EvaluateConstraints) {
4872 if (SemaRef.SubstTemplateArguments(TemplArgInfo->
arguments(), TemplateArgs,
4879 if (SemaRef.CheckTemplateArgumentList(
4880 ClassTemplate, PartialSpec->
getLocation(), InstTemplateArgs,
4886 if (SemaRef.CheckTemplatePartialSpecializationArgs(
4893 void *InsertPos =
nullptr;
4896 InstParams, InsertPos);
4901 SemaRef.Context, PartialSpec->
getTagKind(), Owner,
4932 diag::err_partial_spec_redeclared)
4934 SemaRef.Diag(PrevDecl->
getLocation(), diag::note_prev_partial_spec_here)
4935 << SemaRef.Context.getCanonicalTagType(PrevDecl);
4940 SemaRef.CheckTemplatePartialSpecialization(InstPartialSpec);
4946 return InstPartialSpec;
4982 if (SemaRef.SubstTemplateArguments(TemplArgInfo->
arguments(), TemplateArgs,
4990 InstTemplateArgs, {},
4995 if (SemaRef.CheckTemplatePartialSpecializationArgs(
5002 void *InsertPos =
nullptr;
5005 InstParams, InsertPos);
5016 diag::err_variable_instantiates_to_function)
5053 diag::err_var_partial_spec_redeclared)
5056 diag::note_var_prev_partial_spec_here);
5060 SemaRef.CheckTemplatePartialSpecialization(InstPartialSpec);
5064 VarTemplate->AddPartialSpecialization(InstPartialSpec,
nullptr);
5066 SemaRef.BuildVariableInstantiation(InstPartialSpec, PartialSpec, TemplateArgs,
5067 LateAttrs, Owner, StartingScope);
5069 return InstPartialSpec;
5076 assert(OldTInfo &&
"substituting function without type source info");
5077 assert(Params.empty() &&
"parameter vector is non-empty at start");
5083 ThisTypeQuals =
Method->getFunctionObjectParameterType().getQualifiers();
5088 ThisContext, ThisTypeQuals, EvaluateConstraints);
5094 if (NewTInfo != OldTInfo) {
5098 unsigned NewIdx = 0;
5099 for (
unsigned OldIdx = 0, NumOldParams = OldProtoLoc.getNumParams();
5100 OldIdx != NumOldParams; ++OldIdx) {
5101 ParmVarDecl *OldParam = OldProtoLoc.getParam(OldIdx);
5109 NumArgumentsInExpansion =
5110 SemaRef.getNumArgumentsInExpansion(OldParam->
getType(),
5112 if (!NumArgumentsInExpansion) {
5116 Params.push_back(NewParam);
5117 Scope->InstantiatedLocal(OldParam, NewParam);
5120 Scope->MakeInstantiatedLocalArgPack(OldParam);
5121 for (
unsigned I = 0; I != *NumArgumentsInExpansion; ++I) {
5123 Params.push_back(NewParam);
5124 Scope->InstantiatedLocalPackArg(OldParam, NewParam);
5134 for (
unsigned i = 0, i_end = OldProtoLoc.getNumParams(); i != i_end;
5138 Params.push_back(SemaRef.BuildParmVarDeclForTypedef(
5144 cast_or_null<ParmVarDecl>(VisitParmVarDecl(OldParam));
5147 Params.push_back(Parm);
5164 TemplateArgs, ParamTypes, &Params,
5177 for (
auto *
decl : PatternDecl->
decls()) {
5184 auto it = llvm::find_if(
Function->decls(), [&](
Decl *inst) {
5185 VarDecl *InstVD = dyn_cast<VarDecl>(inst);
5186 return InstVD && InstVD->isLocalVarDecl() &&
5187 InstVD->getIdentifier() == II;
5193 Scope.InstantiatedLocal(VD, *it);
5200bool Sema::addInstantiatedParametersToScope(
5204 unsigned FParamIdx = 0;
5205 for (
unsigned I = 0, N = PatternDecl->
getNumParams(); I != N; ++I) {
5206 const ParmVarDecl *PatternParam = PatternDecl->
getParamDecl(I);
5209 assert(FParamIdx < Function->getNumParams());
5234 UnsignedOrNone NumArgumentsInExpansion =
5236 if (NumArgumentsInExpansion) {
5237 QualType PatternType =
5238 PatternParam->
getType()->
castAs<PackExpansionType>()->getPattern();
5239 for (
unsigned Arg = 0; Arg < *NumArgumentsInExpansion; ++Arg) {
5243 Sema::ArgPackSubstIndexRAII SubstIndex(*
this, Arg);
5263 assert(Param->hasUninstantiatedDefaultArg());
5295 false, std::nullopt,
5304 L->DefaultArgumentInstantiated(Param);
5317 if (AlreadyInstantiating) {
5320 Diag(PointOfInstantiation, diag::err_exception_spec_cycle) <<
Decl;
5341 false, std::nullopt,
5374 SemaRef.Context.setManglingNumber(
New,
5375 SemaRef.Context.getManglingNumber(Tmpl));
5388 ActiveInstType &ActiveInst = SemaRef.CodeSynthesisContexts.back();
5389 if (ActiveInst.Kind == ActiveInstType::ExplicitTemplateArgumentSubstitution ||
5390 ActiveInst.Kind == ActiveInstType::DeducedTemplateArgumentSubstitution) {
5392 atTemplateEnd(SemaRef.TemplateInstCallbacks, SemaRef, ActiveInst);
5393 ActiveInst.Kind = ActiveInstType::TemplateInstantiation;
5394 ActiveInst.Entity =
New;
5400 assert(Proto &&
"Function template without prototype?");
5409 if (SemaRef.getLangOpts().CPlusPlus11 &&
5424 assert(NewProto &&
"Template instantiation without function prototype?");
5429 New->setType(SemaRef.Context.getFunctionType(
5433 SemaRef.SubstExceptionSpec(
New, Proto, TemplateArgs);
5442 LateAttrs, StartingScope);
5463 New->setVirtualAsWritten(
true);
5474 Lookups.reserve(DFI->getUnqualifiedLookups().size());
5475 bool AnyChanged =
false;
5477 NamedDecl *D = SemaRef.FindInstantiatedDecl(
New->getLocation(),
5478 DA.getDecl(), TemplateArgs);
5481 AnyChanged |= (D != DA.getDecl());
5487 New->setDefaultedOrDeletedInfo(
5489 SemaRef.Context, Lookups)
5517 bool DefinitionRequired,
5525 Function->getTemplateSpecializationKindForInstantiation();
5532 !DefinitionRequired)
5537 if (
Function->isDefined(ExistingDefn,
5552 assert(!AlreadyInstantiating &&
"should have been caught by caller");
5557 assert(PatternDecl &&
"instantiating a non-template");
5560 Stmt *Pattern =
nullptr;
5562 Pattern = PatternDef->
getBody(PatternDef);
5563 PatternDecl = PatternDef;
5565 PatternDef =
nullptr;
5569 bool Unreachable =
false;
5574 Function->getInstantiatedFromMemberFunction(), PatternDecl,
5576 DefinitionRequired, &Unreachable)) {
5577 if (DefinitionRequired)
5580 (
Function->isConstexpr() && !Recursive)) {
5584 Function->setInstantiationIsPending(
true);
5587 if (llvm::isTimeTraceVerbose()) {
5588 llvm::timeTraceAddInstantEvent(
"DeferInstantiation", [&] {
5590 llvm::raw_string_ostream
OS(Name);
5599 Diag(PointOfInstantiation, diag::warn_func_template_missing)
5605 diag::note_unreachable_template_decl);
5609 Diag(PointOfInstantiation, diag::note_inst_declaration_hint)
5621 Function->setInstantiationIsPending(
true);
5623 std::make_pair(
Function, PointOfInstantiation));
5627 llvm::TimeTraceScope TimeScope(
"InstantiateFunction", [&]() {
5628 llvm::TimeTraceMetadata M;
5629 llvm::raw_string_ostream
OS(M.Detail);
5632 if (llvm::isTimeTraceVerbose()) {
5635 M.Line =
SourceMgr.getExpansionLineNumber(Loc);
5661 "missing LateParsedTemplate");
5663 Pattern = PatternDecl->
getBody(PatternDecl);
5670 "unexpected kind of function template definition");
5685 for (
auto *D =
Function->getMostRecentDecl(); ;
5687 D->setImplicitlyInline();
5697 "instantiating function definition");
5701 Function->setVisibleDespiteOwningModule();
5727 auto NameLocPointsToPattern = [&] {
5738 return PatternNameLoc;
5748 return PatternNameLoc;
5756 assert(PatternTSI &&
"Pattern is supposed to have an associated TSI");
5764 Function->setDeclarationNameLoc(NameLocPointsToPattern());
5772 ThisContext =
Method->getParent();
5773 ThisTypeQuals =
Method->getMethodQualifiers();
5783 bool MergeWithParentScope =
false;
5785 MergeWithParentScope =
5786 Rec->isLocalClass() && !
Function->isFunctionTemplateSpecialization();
5789 auto RebuildTypeSourceInfoForDefaultSpecialMembers = [&]() {
5795 "Special member needs to be defaulted");
5803 auto *NewRec = dyn_cast<CXXRecordDecl>(
Function->getDeclContext());
5804 const auto *PatternRec =
5806 if (!NewRec || !PatternRec)
5808 if (!PatternRec->isLambda())
5811 struct SpecialMemberTypeInfoRebuilder
5831 getDerived().TransformDecl(TL.
getNameLoc(),
T->getDecl()));
5833 return Base::TransformRecordType(TLB, TL);
5847 } IR{*
this, PatternRec, NewRec};
5850 assert(NewSI &&
"Type Transform failed?");
5852 Function->setTypeSourceInfo(NewSI);
5856 assert(NewParmSI &&
"Type transformation failed.");
5862 RebuildTypeSourceInfoForDefaultSpecialMembers();
5866 std::optional<ArrayRef<TemplateArgument>> Innermost;
5867 if (
auto *Primary =
Function->getPrimaryTemplate();
5870 Function->getTemplateSpecializationKind() !=
5872 auto It = llvm::find_if(Primary->redecls(),
5874 return cast<FunctionTemplateDecl>(RTD)
5875 ->isCompatibleWithDefinition();
5877 assert(It != Primary->redecls().end() &&
5878 "Should't get here without a definition");
5880 ->getTemplatedDecl()
5884 DC = (*It)->getLexicalDeclContext();
5885 Innermost.emplace(
Function->getTemplateSpecializationArgs()->asArray());
5888 Function, DC,
false, Innermost,
false, PatternDecl);
5906 if (addInstantiatedParametersToScope(
Function, PatternDecl,
Scope,
5922 if (
Context.getTargetInfo().getCXXABI().isMicrosoft() &&
5923 Ctor->isDefaultConstructor()) {
5929 Body =
SubstStmt(Pattern, TemplateArgs);
5938 checkReferenceToTULocalFromOtherTU(
Function, PointOfInstantiation);
5943 Listener->FunctionDefinitionInstantiated(
Function);
5953 bool ShouldSkipCG = [&] {
5954 auto *RD = dyn_cast<CXXRecordDecl>(
Function->getParent());
5955 if (!RD || !RD->isLambda())
5959 return Context.isUnevaluated() ||
Context.isImmediateFunctionContext();
5962 if (!ShouldSkipCG) {
5969 LocalInstantiations.
perform();
5971 GlobalInstantiations.perform();
5996 bool IsMemberSpec =
false;
5998 if (
auto *PartialSpec =
5999 dyn_cast<VarTemplatePartialSpecializationDecl>(FromVar)) {
6000 assert(PartialSpecArgs);
6001 IsMemberSpec = PartialSpec->isMemberSpecialization();
6003 PartialSpec, PartialSpecArgs->
asArray(),
false);
6006 IsMemberSpec =
VarTemplate->isMemberSpecialization();
6026 "don't have a definition to instantiate from");
6055 bool InstantiatingVarTemplate,
6059 bool InstantiatingVarTemplatePartialSpec =
6064 bool InstantiatingSpecFromTemplate =
6090 if (OldVar->
isUsed(
false))
6115 }
else if (PrevDeclForVarTemplateSpecialization) {
6116 Previous.addDecl(PrevDeclForVarTemplateSpecialization);
6120 if (!InstantiatingVarTemplate) {
6138 !InstantiatingSpecFromTemplate)
6145 dyn_cast<VarTemplateSpecializationDecl>(OldVar)) {
6153 Context.setManglingNumber(NewVar,
Context.getManglingNumber(OldVar));
6154 Context.setStaticLocalNumber(NewVar,
Context.getStaticLocalNumber(OldVar));
6157 if (InstantiatingVarTemplate || InstantiatingVarTemplatePartialSpec) {
6162 }
else if (InstantiatingSpecFromTemplate ||
6184 L->VariableDefinitionInstantiated(Var);
6210 if (!
Init.isInvalid()) {
6213 if (Var->
hasAttr<DLLImportAttr>() &&
6217 }
else if (InitExpr) {
6253 bool DefinitionRequired,
bool AtEndOfTU) {
6265 if (AlreadyInstantiating)
6270 assert(PatternDecl &&
"no pattern for templated variable");
6275 dyn_cast<VarTemplateSpecializationDecl>(Var);
6286 (PatternDecl = PatternDecl->
getFirstDecl())->hasInit() &&
6294 "instantiating variable initializer");
6305 Recursive, AtEndOfTU);
6314 PreviousContext.
pop();
6318 LocalInstantiations.
perform();
6320 GlobalInstantiations.
perform();
6324 "not a static data member?");
6333 if (!Def && !DefinitionRequired) {
6340 Diag(PointOfInstantiation, diag::warn_var_template_missing)
6344 Diag(PointOfInstantiation, diag::note_inst_declaration_hint) << Var;
6355 PatternDecl, Def, TSK,
6356 DefinitionRequired))
6373 struct PassToConsumerRAII {
6380 ~PassToConsumerRAII() {
6381 Consumer.HandleCXXStaticMemberVarInstantiation(Var);
6383 } PassToConsumerRAII(
Consumer, Var);
6390 PointOfInstantiation);
6398 "instantiating variable definition");
6420 }
else if (!VarSpec) {
6465 PreviousContext.
pop();
6468 PassToConsumerRAII.Var = Var;
6475 LocalInstantiations.
perform();
6477 GlobalInstantiations.
perform();
6489 for (
const auto *
Init : Tmpl->
inits()) {
6492 if (!
Init->isWritten())
6497 if (
Init->isPackExpansion()) {
6499 TypeLoc BaseTL =
Init->getTypeSourceInfo()->getTypeLoc();
6503 bool ShouldExpand =
false;
6504 bool RetainExpansion =
false;
6508 TemplateArgs,
true, ShouldExpand,
6509 RetainExpansion, NumExpansions)) {
6511 New->setInvalidDecl();
6514 assert(ShouldExpand &&
"Partial instantiation of base initializer?");
6517 for (
unsigned I = 0; I != *NumExpansions; ++I) {
6531 Init->getSourceLocation(),
6532 New->getDeclName());
6540 BaseTInfo, TempInit.
get(),
6548 NewInits.push_back(NewInit.
get());
6563 if (
Init->isDelegatingInitializer() ||
Init->isBaseInitializer()) {
6566 Init->getSourceLocation(),
6567 New->getDeclName());
6570 New->setInvalidDecl();
6574 if (
Init->isBaseInitializer())
6576 New->getParent(), EllipsisLoc);
6580 }
else if (
Init->isMemberInitializer()) {
6582 Init->getMemberLocation(),
6587 New->setInvalidDecl();
6592 Init->getSourceLocation());
6593 }
else if (
Init->isIndirectMemberInitializer()) {
6596 Init->getMemberLocation(),
6597 Init->getIndirectMember(), TemplateArgs));
6599 if (!IndirectMember) {
6601 New->setInvalidDecl();
6606 Init->getSourceLocation());
6611 New->setInvalidDecl();
6613 NewInits.push_back(NewInit.
get());
6632 Instance = Instance->getCanonicalDecl();
6633 if (Pattern == Instance)
return true;
6634 Instance = Instance->getInstantiatedFromMemberTemplate();
6645 Instance = Instance->getCanonicalDecl();
6646 if (Pattern == Instance)
return true;
6647 Instance = Instance->getInstantiatedFromMemberTemplate();
6660 Instance->getCanonicalDecl());
6661 if (Pattern == Instance)
6663 Instance = Instance->getInstantiatedFromMember();
6674 Instance = Instance->getCanonicalDecl();
6675 if (Pattern == Instance)
return true;
6676 Instance = Instance->getInstantiatedFromMemberClass();
6687 Instance = Instance->getCanonicalDecl();
6688 if (Pattern == Instance)
return true;
6689 Instance = Instance->getInstantiatedFromMemberFunction();
6700 Instance = Instance->getCanonicalDecl();
6701 if (Pattern == Instance)
return true;
6702 Instance = Instance->getInstantiatedFromMemberEnum();
6729 bool OtherIsPackExpansion;
6731 if (
auto *OtherUUD = dyn_cast<T>(
Other)) {
6732 OtherIsPackExpansion = OtherUUD->isPackExpansion();
6734 }
else if (
auto *OtherUPD = dyn_cast<UsingPackDecl>(
Other)) {
6735 OtherIsPackExpansion =
true;
6736 OtherFrom = OtherUPD->getInstantiatedFromUsingDecl();
6737 }
else if (
auto *OtherUD = dyn_cast<UsingDecl>(
Other)) {
6738 OtherIsPackExpansion =
false;
6743 return Pattern->isPackExpansion() == OtherIsPackExpansion &&
6749 assert(Instance->isStaticDataMember());
6754 Instance = Instance->getCanonicalDecl();
6755 if (Pattern == Instance)
return true;
6756 Instance = Instance->getInstantiatedFromStaticDataMember();
6765 if (
auto *UUD = dyn_cast<UnresolvedUsingTypenameDecl>(D))
6768 if (
auto *UUD = dyn_cast<UnresolvedUsingValueDecl>(D))
6774 if (
auto *
Record = dyn_cast<CXXRecordDecl>(
Other))
6777 if (
auto *Function = dyn_cast<FunctionDecl>(
Other))
6780 if (
auto *
Enum = dyn_cast<EnumDecl>(
Other))
6783 if (
auto *Var = dyn_cast<VarDecl>(
Other))
6787 if (
auto *Temp = dyn_cast<ClassTemplateDecl>(
Other))
6790 if (
auto *Temp = dyn_cast<FunctionTemplateDecl>(
Other))
6793 if (
auto *PartialSpec =
6794 dyn_cast<ClassTemplatePartialSpecializationDecl>(
Other))
6798 if (
auto *Field = dyn_cast<FieldDecl>(
Other)) {
6799 if (!Field->getDeclName()) {
6806 if (
auto *Using = dyn_cast<UsingDecl>(
Other))
6809 if (
auto *Shadow = dyn_cast<UsingShadowDecl>(
Other))
6816template<
typename ForwardIterator>
6819 ForwardIterator first,
6820 ForwardIterator last) {
6821 for (; first != last; ++first)
6830 if (
NamedDecl *D = dyn_cast<NamedDecl>(DC)) {
6832 return cast_or_null<DeclContext>(ID);
6847 return cast<Decl>(DC)->getTemplateDepth() > Level;
6852 bool FindingInstantiatedContext) {
6890 if (
auto *BD = dyn_cast<BindingDecl>(FD);
6898 "found declaration pack but not pack expanding");
6928 bool NeedInstantiate =
false;
6930 NeedInstantiate = RD->isLocalClass();
6933 NeedInstantiate =
true;
6936 if (NeedInstantiate) {
6947 assert(Inst &&
"Failed to instantiate label??");
6954 if (!
Record->isDependentContext())
6963 dyn_cast<ClassTemplateSpecializationDecl>(
Record))
6964 ClassTemplate = Spec->getSpecializedTemplate()->getCanonicalDecl();
6975 if (
CXXRecordDecl *InstRecord = dyn_cast<CXXRecordDecl>(DC)) {
6979 = dyn_cast<ClassTemplateSpecializationDecl>(InstRecord)){
6999 auto *Guide = dyn_cast<CXXDeductionGuideDecl>(FD);
7000 if (Guide && Guide->isImplicit()) {
7008 Unpacked = Arg.pack_elements();
7021 if (
T.isNull() ||
T->containsErrors())
7031 assert(
SemaRef.RebuildingImmediateInvocation ||
7044 if (FindingInstantiatedContext &&
7047 Diag(Loc, diag::err_specialization_not_primary_template)
7064 if (!ParentDependsOnArgs)
7078 bool IsBeingInstantiated =
false;
7079 if (
auto *Spec = dyn_cast<CXXRecordDecl>(ParentDC)) {
7080 if (!Spec->isDependentContext()) {
7081 if (Spec->isEntityBeingDefined())
7082 IsBeingInstantiated =
true;
7084 diag::err_incomplete_type))
7087 ParentDC = Spec->getDefinitionOrSelf();
7126 }
else if (IsBeingInstantiated) {
7132 Diag(Loc, diag::err_member_not_yet_instantiated)
7145 Diag(Loc, diag::err_enumerator_does_not_exist)
7149 <<
Context.getCanonicalTagType(Spec);
7152 llvm_unreachable(
"Unable to find instantiation of declaration!");
7163 std::deque<PendingImplicitInstantiation> DelayedImplicitInstantiations;
7168 bool LocalInstantiation =
false;
7175 LocalInstantiation =
true;
7180 bool DefinitionRequired =
Function->getTemplateSpecializationKind() ==
7185 [
this, Inst, DefinitionRequired, AtEndOfTU](
FunctionDecl *CurFD) {
7187 DefinitionRequired, AtEndOfTU);
7193 DefinitionRequired, AtEndOfTU);
7195 Function->setInstantiationIsPending(
false);
7198 if (!LocalOnly &&
LangOpts.PCHInstantiateTemplates &&
7200 DelayedImplicitInstantiations.push_back(Inst);
7201 else if (!AtEndOfTU &&
Function->instantiationIsPending() &&
7202 !LocalInstantiation)
7203 DelayedImplicitInstantiations.push_back(Inst);
7212 "Not a static data member, nor a variable template"
7213 " specialization?");
7225 llvm_unreachable(
"Cannot instantitiate an undeclared specialization.");
7240 "instantiating variable definition");
7247 DefinitionRequired, AtEndOfTU);
7250 if (!DelayedImplicitInstantiations.empty())
7256 for (
auto *DD : Pattern->
ddiags()) {
7257 switch (DD->getKind()) {
Defines the clang::ASTContext interface.
Defines the C++ template declaration subclasses.
Defines the clang::Expr interface and subclasses for C++ expressions.
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 bool isRelevantAttr(Sema &S, const Decl *D, const Attr *A)
Determine whether the attribute A might be relevant to the declaration D.
static void instantiateDependentReqdWorkGroupSizeAttr(Sema &S, const MultiLevelTemplateArgumentList &TemplateArgs, const ReqdWorkGroupSizeAttr &Attr, Decl *New)
#define CLAUSE_NOT_ON_DECLS(CLAUSE_NAME)
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.
ASTConsumer - This is an abstract interface that should be implemented by clients that read ASTs.
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
void setInstantiatedFromUsingDecl(NamedDecl *Inst, NamedDecl *Pattern)
Remember that the using decl Inst is an instantiation of the using decl Pattern of a class template.
QualType mergeFunctionTypes(QualType, QualType, bool OfBlockPointer=false, bool Unqualified=false, bool AllowCXX=false, bool IsConditionalOperator=false)
NamedDecl * getInstantiatedFromUsingDecl(NamedDecl *Inst)
If the given using decl Inst is an instantiation of another (possibly unresolved) using decl,...
DeclarationNameTable DeclarationNames
void forEachMultiversionedFunctionVersion(const FunctionDecl *FD, llvm::function_ref< void(FunctionDecl *)> Pred) const
Visits all versions of a multiversioned function with the passed predicate.
OMPTraitInfo & getNewOMPTraitInfo()
Return a new OMPTraitInfo object owned by this context.
FieldDecl * getInstantiatedFromUnnamedFieldDecl(FieldDecl *Field) const
CanQualType UnsignedLongLongTy
static bool hasSameType(QualType T1, QualType T2)
Determine whether the given types T1 and T2 are equivalent.
CanQualType getCanonicalTagType(const TagDecl *TD) const
An abstract interface that should be implemented by listeners that want to be notified when an AST en...
Represents an access specifier followed by colon ':'.
static AccessSpecDecl * Create(ASTContext &C, AccessSpecifier AS, DeclContext *DC, SourceLocation ASLoc, SourceLocation ColonLoc)
SourceLocation getColonLoc() const
The location of the colon following the access specifier.
SourceLocation getAccessSpecifierLoc() const
The location of the access specifier.
Attr - This represents one attribute.
attr::Kind getKind() const
Attr * clone(ASTContext &C) const
SourceLocation getLocation() const
SourceRange getRange() const
SourceLocation getLoc() const
Represents a C++ declaration that introduces decls from somewhere else.
shadow_range shadows() const
A binding in a decomposition declaration.
static BindingDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation IdLoc, IdentifierInfo *Id, QualType T)
ArrayRef< BindingDecl * > getBindingPackDecls() const
Represents the builtin template declaration which is used to implement __make_integer_seq and other b...
Represents a C++ constructor within a class.
bool isDefaultConstructor() const
Whether this constructor is a default constructor (C++ [class.ctor]p5), which can be used to default-...
static CXXConstructorDecl * Create(ASTContext &C, CXXRecordDecl *RD, SourceLocation StartLoc, const DeclarationNameInfo &NameInfo, QualType T, TypeSourceInfo *TInfo, ExplicitSpecifier ES, bool UsesFPIntrin, bool isInline, bool isImplicitlyDeclared, ConstexprSpecKind ConstexprKind, InheritedConstructor Inherited=InheritedConstructor(), const AssociatedConstraint &TrailingRequiresClause={})
Represents a C++ conversion function within a class.
static CXXConversionDecl * Create(ASTContext &C, CXXRecordDecl *RD, SourceLocation StartLoc, const DeclarationNameInfo &NameInfo, QualType T, TypeSourceInfo *TInfo, bool UsesFPIntrin, bool isInline, ExplicitSpecifier ES, ConstexprSpecKind ConstexprKind, SourceLocation EndLocation, const AssociatedConstraint &TrailingRequiresClause={})
Represents a C++ deduction guide declaration.
static CXXDeductionGuideDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation StartLoc, ExplicitSpecifier ES, const DeclarationNameInfo &NameInfo, QualType T, TypeSourceInfo *TInfo, SourceLocation EndLocation, CXXConstructorDecl *Ctor=nullptr, DeductionCandidate Kind=DeductionCandidate::Normal, const AssociatedConstraint &TrailingRequiresClause={}, const CXXDeductionGuideDecl *SourceDG=nullptr, SourceDeductionGuideKind SK=SourceDeductionGuideKind::None)
Represents a C++ destructor within a class.
static CXXDestructorDecl * Create(ASTContext &C, CXXRecordDecl *RD, SourceLocation StartLoc, const DeclarationNameInfo &NameInfo, QualType T, TypeSourceInfo *TInfo, bool UsesFPIntrin, bool isInline, bool isImplicitlyDeclared, ConstexprSpecKind ConstexprKind, const AssociatedConstraint &TrailingRequiresClause={})
Represents a static or instance method of a struct/union/class.
static CXXMethodDecl * Create(ASTContext &C, CXXRecordDecl *RD, SourceLocation StartLoc, const DeclarationNameInfo &NameInfo, QualType T, TypeSourceInfo *TInfo, StorageClass SC, bool UsesFPIntrin, bool isInline, ConstexprSpecKind ConstexprKind, SourceLocation EndLocation, const AssociatedConstraint &TrailingRequiresClause={})
Represents a C++ struct/union/class.
static CXXRecordDecl * Create(const ASTContext &C, TagKind TK, DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, IdentifierInfo *Id, CXXRecordDecl *PrevDecl=nullptr)
bool isGenericLambda() const
Determine whether this class describes a generic lambda function object (i.e.
unsigned getLambdaDependencyKind() const
const FunctionDecl * isLocalClass() const
If the class is a local class [class.local], returns the enclosing function declaration.
bool isLambda() const
Determine whether this class describes a lambda function object.
CXXRecordDecl * getDefinition() const
static CXXRecordDecl * CreateLambda(const ASTContext &C, DeclContext *DC, TypeSourceInfo *Info, SourceLocation Loc, unsigned DependencyKind, bool IsGeneric, LambdaCaptureDefault CaptureDefault)
TemplateSpecializationKind getTemplateSpecializationKind() const
Determine whether this particular class is a specialization or instantiation of a class template or m...
TypeSourceInfo * getLambdaTypeInfo() const
void setInstantiationOfMemberClass(CXXRecordDecl *RD, TemplateSpecializationKind TSK)
Specify that this record is an instantiation of the member class RD.
bool isInjectedClassName() const
Determines whether this declaration represents the injected class name.
LambdaCaptureDefault getLambdaCaptureDefault() const
void setDescribedClassTemplate(ClassTemplateDecl *Template)
CXXRecordDecl * getCanonicalDecl() override
Retrieves the "canonical" declaration of the given declaration.
Represents a C++ nested-name-specifier or a global scope specifier.
void Adopt(NestedNameSpecifierLoc Other)
Adopt an existing nested-name-specifier (with source-range information).
Declaration of a class template.
void AddPartialSpecialization(ClassTemplatePartialSpecializationDecl *D, void *InsertPos)
Insert the specified partial specialization knowing that it is not already in.
ClassTemplateDecl * getMostRecentDecl()
CXXRecordDecl * getTemplatedDecl() const
Get the underlying class declarations of the template.
llvm::FoldingSetVector< ClassTemplatePartialSpecializationDecl > & getPartialSpecializations() const
Retrieve the set of partial specializations of this class template.
ClassTemplatePartialSpecializationDecl * findPartialSpecialization(ArrayRef< TemplateArgument > Args, TemplateParameterList *TPL, void *&InsertPos)
Return the partial specialization with the provided arguments if it exists, otherwise return the inse...
static ClassTemplateDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation L, DeclarationName Name, TemplateParameterList *Params, NamedDecl *Decl)
Create a class template node.
ClassTemplateDecl * getCanonicalDecl() override
Retrieves the "canonical" declaration of the given declaration.
ClassTemplatePartialSpecializationDecl * findPartialSpecInstantiatedFromMember(ClassTemplatePartialSpecializationDecl *D)
Find a class template partial specialization which was instantiated from the given member partial spe...
void AddSpecialization(ClassTemplateSpecializationDecl *D, void *InsertPos)
Insert the specified specialization knowing that it is not already in.
void setCommonPtr(Common *C)
Common * getCommonPtr() const
ClassTemplateSpecializationDecl * findSpecialization(ArrayRef< TemplateArgument > Args, void *&InsertPos)
Return the specialization with the provided arguments if it exists, otherwise return the insertion po...
void setInstantiatedFromMember(ClassTemplatePartialSpecializationDecl *PartialSpec)
static ClassTemplatePartialSpecializationDecl * Create(ASTContext &Context, TagKind TK, DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, TemplateParameterList *Params, ClassTemplateDecl *SpecializedTemplate, ArrayRef< TemplateArgument > Args, CanQualType CanonInjectedTST, ClassTemplatePartialSpecializationDecl *PrevDecl)
TemplateParameterList * getTemplateParameters() const
Get the list of template parameters.
Represents a class template specialization, which refers to a class template with a given set of temp...
TemplateSpecializationKind getSpecializationKind() const
Determine the kind of specialization that this declaration represents.
const ASTTemplateArgumentListInfo * getTemplateArgsAsWritten() const
Retrieve the template argument list as written in the sources, if any.
ClassTemplateDecl * getSpecializedTemplate() const
Retrieve the template that this specialization specializes.
static ClassTemplateSpecializationDecl * Create(ASTContext &Context, TagKind TK, DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, ClassTemplateDecl *SpecializedTemplate, ArrayRef< TemplateArgument > Args, bool StrictPackMatch, ClassTemplateSpecializationDecl *PrevDecl)
SourceLocation getPointOfInstantiation() const
Get the point of instantiation (if any), or null if none.
void setExternKeywordLoc(SourceLocation Loc)
Sets the location of the extern keyword.
void setSpecializationKind(TemplateSpecializationKind TSK)
SourceLocation getExternKeywordLoc() const
Gets the location of the extern keyword, if present.
SourceLocation getTemplateKeywordLoc() const
Gets the location of the template keyword, if present.
void setTemplateKeywordLoc(SourceLocation Loc)
Sets the location of the template keyword.
void setTemplateArgsAsWritten(const ASTTemplateArgumentListInfo *ArgsWritten)
Set the template argument list as written in the sources.
Declaration of a C++20 concept.
const TypeClass * getTypePtr() const
Represents a shadow constructor declaration introduced into a class by a C++11 using-declaration that...
A POD class for pairing a NamedDecl* with an access specifier.
static DeclAccessPair make(NamedDecl *D, AccessSpecifier AS)
DeclContext - This is used only as base class of specific decl types that can act as declaration cont...
DeclContext * getParent()
getParent - Returns the containing DeclContext.
bool Equals(const DeclContext *DC) const
Determine whether this declaration context is equivalent to the declaration context DC.
bool isFileContext() const
void makeDeclVisibleInContext(NamedDecl *D)
Makes a declaration visible within this context.
DeclContextLookupResult lookup_result
bool isDependentContext() const
Determines whether this context is dependent on a template parameter.
lookup_result lookup(DeclarationName Name) const
lookup - Find the declarations (if any) with the given Name in this context.
DeclContext * getRedeclContext()
getRedeclContext - Retrieve the context in which an entity conflicts with other entities of the same ...
void addDecl(Decl *D)
Add the declaration D into this context.
decl_iterator decls_end() const
ddiag_range ddiags() const
decl_range decls() const
decls_begin/decls_end - Iterate over the declarations stored in this context.
bool isFunctionOrMethod() const
void addHiddenDecl(Decl *D)
Add the declaration D to this context without modifying any lookup tables.
decl_iterator decls_begin() const
static DeclRefExpr * Create(const ASTContext &Context, NestedNameSpecifierLoc QualifierLoc, SourceLocation TemplateKWLoc, ValueDecl *D, bool RefersToEnclosingVariableOrCapture, SourceLocation NameLoc, QualType T, ExprValueKind VK, NamedDecl *FoundD=nullptr, const TemplateArgumentListInfo *TemplateArgs=nullptr, NonOdrUseReason NOUR=NOUR_None)
Decl - This represents one declaration (or definition), e.g.
Decl * getPreviousDecl()
Retrieve the previous declaration that declares the same entity as this declaration,...
SourceLocation getEndLoc() const LLVM_READONLY
FriendObjectKind getFriendObjectKind() const
Determines whether this declaration is the object of a friend declaration and, if so,...
bool isImplicit() const
isImplicit - Indicates whether the declaration was implicitly generated by the implementation.
void setLocalExternDecl()
Changes the namespace of this declaration to reflect that it's a function-local extern declaration.
virtual bool isOutOfLine() const
Determine whether this declaration is declared out of line (outside its semantic context).
void setInvalidDecl(bool Invalid=true)
setInvalidDecl - Indicates the Decl had a semantic error.
bool isInIdentifierNamespace(unsigned NS) const
@ FOK_None
Not a friend object.
bool isReferenced() const
Whether any declaration of this entity was referenced.
unsigned getTemplateDepth() const
Determine the number of levels of template parameter surrounding this declaration.
void setObjectOfFriendDecl(bool PerformFriendInjection=false)
Changes the namespace of this declaration to reflect that it's the object of a friend declaration.
bool isFromASTFile() const
Determine whether this declaration came from an AST file (such as a precompiled header or module) rat...
bool isInLocalScopeForInstantiation() const
Determine whether a substitution into this declaration would occur as part of a substitution into a d...
DeclContext * getNonTransparentDeclContext()
Return the non transparent context.
bool isInvalidDecl() const
bool isLocalExternDecl() const
Determine whether this is a block-scope declaration with linkage.
llvm::iterator_range< specific_attr_iterator< T > > specific_attrs() const
void setAccess(AccessSpecifier AS)
SourceLocation getLocation() const
const char * getDeclKindName() const
@ IDNS_Ordinary
Ordinary names.
void setImplicit(bool I=true)
void setReferenced(bool R=true)
void setIsUsed()
Set whether the declaration is used, in the sense of odr-use.
bool isUsed(bool CheckUsedAttr=true) const
Whether any (re-)declaration of the entity was used, meaning that a definition is required.
DeclContext * getDeclContext()
AccessSpecifier getAccess() const
SourceLocation getBeginLoc() const LLVM_READONLY
DeclContext * getLexicalDeclContext()
getLexicalDeclContext - The declaration context where this Decl was lexically declared (LexicalDC).
void setNonMemberOperator()
Specifies that this declaration is a C++ overloaded non-member.
void setLexicalDeclContext(DeclContext *DC)
void setVisibleDespiteOwningModule()
Set that this declaration is globally visible, even if it came from a module that is not visible.
DeclarationNameLoc - Additional source/type location info for a declaration name.
static DeclarationNameLoc makeNamedTypeLoc(TypeSourceInfo *TInfo)
Construct location information for a constructor, destructor or conversion operator.
The name of a declaration.
@ CXXConversionFunctionName
NameKind getNameKind() const
Determine what kind of name this is.
Represents a ValueDecl that came out of a declarator.
SourceLocation getInnerLocStart() const
Return start of source range ignoring outer template declarations.
TemplateParameterList * getTemplateParameterList(unsigned index) const
SourceLocation getTypeSpecStartLoc() const
SourceLocation getBeginLoc() const LLVM_READONLY
const AssociatedConstraint & getTrailingRequiresClause() const
Get the constraint-expression introduced by the trailing requires-clause in the function/member decla...
unsigned getNumTemplateParameterLists() const
void setTypeSourceInfo(TypeSourceInfo *TI)
NestedNameSpecifierLoc getQualifierLoc() const
Retrieve the nested-name-specifier (with source-location information) that qualifies the name of this...
TypeSourceInfo * getTypeSourceInfo() const
A decomposition declaration.
ArrayRef< BindingDecl * > bindings() const
static DecompositionDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation StartLoc, SourceLocation LSquareLoc, QualType T, TypeSourceInfo *TInfo, StorageClass S, ArrayRef< BindingDecl * > Bindings)
Provides information about a dependent function-template specialization declaration.
RAII object that enters a new function expression evaluation context.
RAII object that enters a new expression evaluation context.
An instance of this object exists for each enum constant that is defined.
enumerator_range enumerators() const
bool isScoped() const
Returns true if this is a C++11 scoped enumeration.
bool isScopedUsingClassTag() const
Returns true if this is a C++11 scoped enumeration.
static EnumDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, IdentifierInfo *Id, EnumDecl *PrevDecl, bool IsScoped, bool IsScopedUsingClassTag, bool IsFixed)
TypeSourceInfo * getIntegerTypeSourceInfo() const
Return the type source info for the underlying integer type, if no type source info exists,...
bool isFixed() const
Returns true if this is an Objective-C, C++11, or Microsoft-style enumeration with a fixed underlying...
EnumDecl * getCanonicalDecl() override
Retrieves the "canonical" declaration of the given declaration.
QualType getIntegerType() const
Return the integer type this enum decl corresponds to.
EnumDecl * getDefinition() const
TemplateSpecializationKind getTemplateSpecializationKind() const
If this enumeration is a member of a specialization of a templated class, determine what kind of temp...
Store information needed for an explicit specifier.
ExplicitSpecKind getKind() const
bool isInvalid() const
Determine if the explicit specifier is invalid.
static ExplicitSpecifier Invalid()
const Expr * getExpr() const
static ExplicitSpecifier getFromDecl(FunctionDecl *Function)
This represents one expression.
static bool isPotentialConstantExprUnevaluated(Expr *E, const FunctionDecl *FD, SmallVectorImpl< PartialDiagnosticAt > &Diags)
isPotentialConstantExprUnevaluated - Return true if this expression might be usable in a constant exp...
bool isValueDependent() const
Determines whether the value of this expression depends on.
std::optional< llvm::APSInt > getIntegerConstantExpr(const ASTContext &Ctx) const
isIntegerConstantExpr - Return the value if this expression is a valid integer constant expression.
bool isConstantInitializer(ASTContext &Ctx, bool ForRef, const Expr **Culprit=nullptr) const
isConstantInitializer - Returns true if this expression can be emitted to IR as a constant,...
SourceLocation getExprLoc() const LLVM_READONLY
getExprLoc - Return the preferred location for the arrow when diagnosing a problem with a generic exp...
Declaration context for names declared as extern "C" in C++.
Abstract interface for external sources of AST nodes.
Represents difference between two FPOptions values.
Represents a member of a struct/union/class.
bool isMutable() const
Determines whether this field is mutable (C++ only).
InClassInitStyle getInClassInitStyle() const
Get the kind of (C++11) default member initializer that this field has.
Expr * getBitWidth() const
Returns the expression that represents the bit width, if this field is a bit field.
FriendDecl - Represents the declaration of a friend entity, which can be a function,...
bool isUnsupportedFriend() const
Determines if this friend kind is unsupported.
static FriendDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation L, FriendUnion Friend_, SourceLocation FriendL, SourceLocation EllipsisLoc={}, ArrayRef< TemplateParameterList * > FriendTypeTPLists={})
SourceLocation getFriendLoc() const
Retrieves the location of the 'friend' keyword.
void setUnsupportedFriend(bool Unsupported)
SourceRange getSourceRange() const override LLVM_READONLY
Retrieves the source range for the friend declaration.
SourceLocation getEllipsisLoc() const
Retrieves the location of the '...', if present.
NamedDecl * getFriendDecl() const
If this friend declaration doesn't name a type, return the inner declaration.
TypeSourceInfo * getFriendType() const
If this friend declaration names an (untemplated but possibly dependent) type, return the type; other...
bool isPackExpansion() const
Declaration of a friend template.
static DefaultedOrDeletedFunctionInfo * Create(ASTContext &Context, ArrayRef< DeclAccessPair > Lookups, StringLiteral *DeletedMessage=nullptr)
Represents a function declaration or definition.
void setInstantiationIsPending(bool IC)
State that the instantiation of this function is pending.
static FunctionDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation StartLoc, SourceLocation NLoc, DeclarationName N, QualType T, TypeSourceInfo *TInfo, StorageClass SC, bool UsesFPIntrin=false, bool isInlineSpecified=false, bool hasWrittenPrototype=true, ConstexprSpecKind ConstexprKind=ConstexprSpecKind::Unspecified, const AssociatedConstraint &TrailingRequiresClause={})
const ParmVarDecl * getParamDecl(unsigned i) const
Stmt * getBody(const FunctionDecl *&Definition) const
Retrieve the body (definition) of the function.
ConstexprSpecKind getConstexprKind() const
FunctionTemplateDecl * getDescribedFunctionTemplate() const
Retrieves the function template that is described by this function declaration.
bool isThisDeclarationADefinition() const
Returns whether this specific declaration of the function is also a definition that does not contain ...
bool isDestroyingOperatorDelete() const
Determine whether this is a destroying operator delete.
StringLiteral * getDeletedMessage() const
Get the message that indicates why this function was deleted.
bool isInlined() const
Determine whether this function should be inlined, because it is either marked "inline" or "constexpr...
bool UsesFPIntrin() const
Determine whether the function was declared in source context that requires constrained FP intrinsics...
QualType getReturnType() const
ArrayRef< ParmVarDecl * > parameters() const
FunctionDecl * getTemplateInstantiationPattern(bool ForDefinition=true) const
Retrieve the function declaration from which this function could be instantiated, if it is an instant...
bool isExplicitlyDefaulted() const
Whether this function is explicitly defaulted.
bool hasWrittenPrototype() const
Whether this function has a written prototype.
FunctionDecl * getCanonicalDecl() override
Retrieves the "canonical" declaration of the given declaration.
DependentFunctionTemplateSpecializationInfo * getDependentSpecializationInfo() const
bool isDeleted() const
Whether this function has been deleted.
StorageClass getStorageClass() const
Returns the storage class as written in the source.
bool isOutOfLine() const override
Determine whether this is or was instantiated from an out-of-line definition of a member function.
bool FriendConstraintRefersToEnclosingTemplate() const
bool isDeletedAsWritten() const
bool isPureVirtual() const
Whether this virtual function is pure, i.e.
bool isLateTemplateParsed() const
Whether this templated function will be late parsed.
bool hasSkippedBody() const
True if the function was a definition but its body was skipped.
FunctionDecl * getDefinition()
Get the definition for this declaration.
bool isTypeAwareOperatorNewOrDelete() const
Determine whether this is a type aware operator new or delete.
bool isThisDeclarationInstantiatedFromAFriendDefinition() const
Determine whether this specific declaration of the function is a friend declaration that was instanti...
bool isDefaulted() const
Whether this function is defaulted.
SourceRange getSourceRange() const override LLVM_READONLY
Source range that this declaration covers.
bool isVirtualAsWritten() const
Whether this function is marked as virtual explicitly.
unsigned getNumParams() const
Return the number of parameters this function must have based on its FunctionType.
DeclarationNameInfo getNameInfo() const
bool hasBody(const FunctionDecl *&Definition) const
Returns true if the function has a body.
bool isDefined(const FunctionDecl *&Definition, bool CheckForPendingFriendDefinition=false) const
Returns true if the function has a definition that does not need to be instantiated.
FunctionDecl * getPreviousDecl()
Return the previous declaration of this declaration or NULL if this is the first declaration.
bool isInlineSpecified() const
Determine whether the "inline" keyword was specified for this function.
DefaultedOrDeletedFunctionInfo * getDefalutedOrDeletedInfo() const
bool willHaveBody() const
True if this function will eventually have a body, once it's fully parsed.
const ASTTemplateArgumentListInfo * getTemplateSpecializationArgsAsWritten() const
Retrieve the template argument list as written in the sources, if any.
Represents a prototype with parameter type info, e.g.
ExceptionSpecificationType getExceptionSpecType() const
Get the kind of exception specification on this function.
QualType getParamType(unsigned i) const
bool hasExceptionSpec() const
Return whether this function has any kind of exception spec.
ExtProtoInfo getExtProtoInfo() const
FunctionDecl * getExceptionSpecTemplate() const
If this function type has an uninstantiated exception specification, this is the function whose excep...
ArrayRef< QualType > getParamTypes() const
Declaration of a template function.
FunctionTemplateDecl * getCanonicalDecl() override
Retrieves the "canonical" declaration of the given declaration.
FunctionDecl * getTemplatedDecl() const
Get the underlying function declaration of the template.
FunctionTemplateDecl * getInstantiatedFromMemberTemplate() const
void setInstantiatedFromMemberTemplate(FunctionTemplateDecl *D)
static FunctionTemplateDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation L, DeclarationName Name, TemplateParameterList *Params, NamedDecl *Decl)
Create a function template node.
ParmVarDecl * getParam(unsigned i) const
void setParam(unsigned i, ParmVarDecl *VD)
ExtInfo getExtInfo() const
bool getNoReturnAttr() const
Determine whether this function type includes the GNU noreturn attribute.
QualType getReturnType() const
HLSLBufferDecl - Represent a cbuffer or tbuffer declaration.
One of these records is kept for each identifier that is lexed.
bool isStr(const char(&Str)[StrLen]) const
Return true if this is the identifier for the specified string.
Represents a field injected from an anonymous union/struct into the parent scope.
unsigned getChainingSize() const
static IndirectFieldDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation L, const IdentifierInfo *Id, QualType T, MutableArrayRef< NamedDecl * > CH)
ArrayRef< NamedDecl * > chain() const
Description of a constructor that was inherited from a base class.
const TypeClass * getTypePtr() const
static IntegerLiteral * Create(const ASTContext &C, const llvm::APInt &V, QualType type, SourceLocation l)
Returns a new integer literal with value 'V' and type 'type'.
Represents the declaration of a label.
static LabelDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation IdentL, IdentifierInfo *II)
A stack-allocated class that identifies which local variable declaration instantiations are present i...
SmallVector< ValueDecl *, 4 > DeclArgumentPack
A set of declarations.
void InstantiatedLocal(const Decl *D, Decl *Inst)
void InstantiatedLocalPackArg(const Decl *D, VarDecl *Inst)
void MakeInstantiatedLocalArgPack(const Decl *D)
Represents the results of name lookup.
An instance of this class represents the declaration of a property member.
static MSPropertyDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation L, DeclarationName N, QualType T, TypeSourceInfo *TInfo, SourceLocation StartL, IdentifierInfo *Getter, IdentifierInfo *Setter)
IdentifierInfo * getGetterId() const
IdentifierInfo * getSetterId() const
Provides information a specialization of a member of a class template, which may be a member function...
Data structure that captures multiple levels of template argument lists for use in template instantia...
const ArgList & getInnermost() const
Retrieve the innermost template argument list.
void addOuterTemplateArguments(Decl *AssociatedDecl, ArgList Args, bool Final)
Add a new outmost level to the multi-level template argument list.
void setKind(TemplateSubstitutionKind K)
void addOuterRetainedLevels(unsigned Num)
unsigned getNumRetainedOuterLevels() const
This represents a decl that may have a name.
IdentifierInfo * getIdentifier() const
Get the identifier that names this declaration, if there is one.
DeclarationName getDeclName() const
Get the actual, stored name of the declaration, which may be a special name.
bool hasLinkage() const
Determine whether this declaration has linkage.
bool isCXXClassMember() const
Determine whether this declaration is a C++ class member.
Represents a C++ namespace alias.
NestedNameSpecifierLoc getQualifierLoc() const
Retrieve the nested-name-specifier that qualifies the name of the namespace, with source-location inf...
SourceLocation getAliasLoc() const
Returns the location of the alias name, i.e.
static NamespaceAliasDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation NamespaceLoc, SourceLocation AliasLoc, IdentifierInfo *Alias, NestedNameSpecifierLoc QualifierLoc, SourceLocation IdentLoc, NamespaceBaseDecl *Namespace)
SourceLocation getNamespaceLoc() const
Returns the location of the namespace keyword.
SourceLocation getTargetNameLoc() const
Returns the location of the identifier in the named namespace.
NamespaceDecl * getNamespace()
Retrieve the namespace declaration aliased by this directive.
Represent a C++ namespace.
A C++ nested-name-specifier augmented with source location information.
SourceRange getSourceRange() const LLVM_READONLY
Retrieve the source range covering the entirety of this nested-name-specifier.
bool hasQualifier() const
Evaluates true when this nested-name-specifier location is non-empty.
NonTypeTemplateParmDecl - Declares a non-type template parameter, e.g., "Size" in.
bool isPackExpansion() const
Whether this parameter pack is a pack expansion.
bool hasDefaultArgument() const
Determine whether this template parameter has a default argument.
unsigned getPosition() const
Get the position of the template parameter within its parameter list.
bool defaultArgumentWasInherited() const
Determines whether the default argument was inherited from a previous declaration of this template.
TypeSourceInfo * getExpansionTypeSourceInfo(unsigned I) const
Retrieve a particular expansion type source info within an expanded parameter pack.
unsigned getNumExpansionTypes() const
Retrieves the number of expansion types in an expanded parameter pack.
const TemplateArgumentLoc & getDefaultArgument() const
Retrieve the default argument, if any.
bool isExpandedParameterPack() const
Whether this parameter is a non-type template parameter pack that has a known list of different types...
static NonTypeTemplateParmDecl * Create(const ASTContext &C, DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, unsigned D, unsigned P, const IdentifierInfo *Id, QualType T, bool ParameterPack, TypeSourceInfo *TInfo)
bool isParameterPack() const
Whether this parameter is a non-type template parameter pack.
unsigned getDepth() const
Get the nesting depth of the template parameter.
Expr * getPlaceholderTypeConstraint() const
Return the constraint introduced by the placeholder type of this non-type template parameter (if any)...
void setDefaultArgument(const ASTContext &C, const TemplateArgumentLoc &DefArg)
Set the default argument for this template parameter, and whether that default argument was inherited...
This represents 'pragma omp allocate ...' directive.
clauselist_range clauselists()
Pseudo declaration for capturing expressions.
This represents 'pragma omp declare mapper ...' directive.
OMPDeclareMapperDecl * getPrevDeclInScope()
Get reference to previous declare mapper construct in the same scope with the same name.
clauselist_iterator clauselist_begin()
clauselist_range clauselists()
DeclarationName getVarName()
Get the name of the variable declared in the mapper.
Expr * getMapperVarRef()
Get the variable declared in the mapper.
This represents 'pragma omp declare reduction ...' directive.
Expr * getInitializer()
Get initializer expression (if specified) of the declare reduction construct.
Expr * getInitPriv()
Get Priv variable of the initializer.
Expr * getCombinerOut()
Get Out variable of the combiner.
Expr * getCombinerIn()
Get In variable of the combiner.
Expr * getCombiner()
Get combiner expression of the declare reduction construct.
OMPDeclareReductionDecl * getPrevDeclInScope()
Get reference to previous declare reduction construct in the same scope with the same name.
Expr * getInitOrig()
Get Orig variable of the initializer.
OMPDeclareReductionInitKind getInitializerKind() const
Get initializer kind.
This represents 'pragma omp groupprivate ...' directive.
This represents 'pragma omp requires...' directive.
This represents 'pragma omp threadprivate ...' directive.
Helper data structure representing the traits in a match clause of an declare variant or metadirectiv...
bool anyScoreOrCondition(llvm::function_ref< bool(Expr *&, bool)> Cond)
Represents a field declaration created by an @defs(...).
static OpaquePtr make(QualType P)
static OpenACCBindClause * Create(const ASTContext &C, SourceLocation BeginLoc, SourceLocation LParenLoc, const IdentifierInfo *ID, SourceLocation EndLoc)
OpenACCDirectiveKind getDirectiveKind() const
ArrayRef< const OpenACCClause * > clauses() const
SourceLocation getDirectiveLoc() const
static OpenACCCopyClause * Create(const ASTContext &C, OpenACCClauseKind Spelling, SourceLocation BeginLoc, SourceLocation LParenLoc, OpenACCModifierKind Mods, ArrayRef< Expr * > VarList, SourceLocation EndLoc)
static OpenACCCopyInClause * Create(const ASTContext &C, OpenACCClauseKind Spelling, SourceLocation BeginLoc, SourceLocation LParenLoc, OpenACCModifierKind Mods, ArrayRef< Expr * > VarList, SourceLocation EndLoc)
static OpenACCCopyOutClause * Create(const ASTContext &C, OpenACCClauseKind Spelling, SourceLocation BeginLoc, SourceLocation LParenLoc, OpenACCModifierKind Mods, ArrayRef< Expr * > VarList, SourceLocation EndLoc)
static OpenACCCreateClause * Create(const ASTContext &C, OpenACCClauseKind Spelling, SourceLocation BeginLoc, SourceLocation LParenLoc, OpenACCModifierKind Mods, ArrayRef< Expr * > VarList, SourceLocation EndLoc)
static OpenACCDevicePtrClause * Create(const ASTContext &C, SourceLocation BeginLoc, SourceLocation LParenLoc, ArrayRef< Expr * > VarList, SourceLocation EndLoc)
static OpenACCDeviceResidentClause * Create(const ASTContext &C, SourceLocation BeginLoc, SourceLocation LParenLoc, ArrayRef< Expr * > VarList, SourceLocation EndLoc)
A 'device_type' or 'dtype' clause, takes a list of either an 'asterisk' or an identifier.
static OpenACCDeviceTypeClause * Create(const ASTContext &C, OpenACCClauseKind K, SourceLocation BeginLoc, SourceLocation LParenLoc, ArrayRef< DeviceTypeArgument > Archs, SourceLocation EndLoc)
static OpenACCLinkClause * Create(const ASTContext &C, SourceLocation BeginLoc, SourceLocation LParenLoc, ArrayRef< Expr * > VarList, SourceLocation EndLoc)
static OpenACCNoHostClause * Create(const ASTContext &Ctx, SourceLocation BeginLoc, SourceLocation EndLoc)
static OpenACCPresentClause * Create(const ASTContext &C, SourceLocation BeginLoc, SourceLocation LParenLoc, ArrayRef< Expr * > VarList, SourceLocation EndLoc)
SourceLocation getRParenLoc() const
const Expr * getFunctionReference() const
SourceLocation getLParenLoc() const
static OpenACCSeqClause * Create(const ASTContext &Ctx, SourceLocation BeginLoc, SourceLocation EndLoc)
static OpenACCVectorClause * Create(const ASTContext &Ctx, SourceLocation BeginLoc, SourceLocation LParenLoc, Expr *IntExpr, SourceLocation EndLoc)
static OpenACCWorkerClause * Create(const ASTContext &Ctx, SourceLocation BeginLoc, SourceLocation LParenLoc, Expr *IntExpr, SourceLocation EndLoc)
SourceLocation getEllipsisLoc() const
TypeLoc getPatternLoc() const
Represents a parameter to a function.
Represents a #pragma detect_mismatch line.
PrettyDeclStackTraceEntry - If a crash occurs in the parser while parsing something related to a decl...
A (possibly-)qualified type.
bool isRestrictQualified() const
Determine whether this type is restrict-qualified.
bool isNull() const
Return true if this QualType doesn't point to a type yet.
QualType getNonReferenceType() const
If Type is a reference type (e.g., const int&), returns the type that the reference refers to ("const...
QualType getAtomicUnqualifiedType() const
Remove all qualifiers including _Atomic.
The collection of all-type qualifiers we support.
Represents a struct/union/class.
bool isAnonymousStructOrUnion() const
Whether this is an anonymous struct or union.
Wrapper for source info for record types.
Declaration of a redeclarable template.
void setInstantiatedFromMemberTemplate(RedeclarableTemplateDecl *TD)
decl_type * getFirstDecl()
Return the first declaration of this declaration or itself if this is the only declaration.
void setPreviousDecl(decl_type *PrevDecl)
Set the previous declaration.
Represents the body of a requires-expression.
static RequiresExprBodyDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation StartLoc)
Scope - A scope is a transient data structure that is used while parsing the program.
void addAMDGPUFlatWorkGroupSizeAttr(Decl *D, const AttributeCommonInfo &CI, Expr *Min, Expr *Max)
addAMDGPUFlatWorkGroupSizeAttr - Adds an amdgpu_flat_work_group_size attribute to a particular declar...
void addAMDGPUWavesPerEUAttr(Decl *D, const AttributeCommonInfo &CI, Expr *Min, Expr *Max)
addAMDGPUWavePersEUAttr - Adds an amdgpu_waves_per_eu attribute to a particular declaration.
void addAMDGPUMaxNumWorkGroupsAttr(Decl *D, const AttributeCommonInfo &CI, Expr *XExpr, Expr *YExpr, Expr *ZExpr)
addAMDGPUMaxNumWorkGroupsAttr - Adds an amdgpu_max_num_work_groups attribute to a particular declarat...
SemaDiagnosticBuilder Diag(SourceLocation Loc, unsigned DiagID)
Emit a diagnostic.
void checkAllowedInitializer(VarDecl *VD)
QualType getInoutParameterType(QualType Ty)
bool inferObjCARCLifetime(ValueDecl *decl)
void AddXConsumedAttr(Decl *D, const AttributeCommonInfo &CI, Sema::RetainOwnershipKind K, bool IsTemplateInstantiation)
A type to represent all the data for an OpenACC Clause that has been parsed, but not yet created/sema...
OpenACCDirectiveKind getDirectiveKind() const
OpenACCClauseKind getClauseKind() const
void ActOnOpenMPDeclareVariantDirective(FunctionDecl *FD, Expr *VariantRef, OMPTraitInfo &TI, ArrayRef< Expr * > AdjustArgsNothing, ArrayRef< Expr * > AdjustArgsNeedDevicePtr, ArrayRef< Expr * > AdjustArgsNeedDeviceAddr, ArrayRef< OMPInteropInfo > AppendArgs, SourceLocation AdjustArgsLoc, SourceLocation AppendArgsLoc, SourceRange SR)
Called on well-formed '#pragma omp declare variant' after parsing of the associated method/function.
std::optional< std::pair< FunctionDecl *, Expr * > > checkOpenMPDeclareVariantFunction(DeclGroupPtrTy DG, Expr *VariantRef, OMPTraitInfo &TI, unsigned NumAppendArgs, SourceRange SR)
Checks '#pragma omp declare variant' variant function and original functions after parsing of the ass...
DeclGroupPtrTy ActOnOpenMPDeclareSimdDirective(DeclGroupPtrTy DG, OMPDeclareSimdDeclAttr::BranchStateTy BS, Expr *Simdlen, ArrayRef< Expr * > Uniforms, ArrayRef< Expr * > Aligneds, ArrayRef< Expr * > Alignments, ArrayRef< Expr * > Linears, ArrayRef< unsigned > LinModifiers, ArrayRef< Expr * > Steps, SourceRange SR)
Called on well-formed '#pragma omp declare simd' after parsing of the associated method/function.
void AddParameterABIAttr(Decl *D, const AttributeCommonInfo &CI, ParameterABI abi)
RAII object used to change the argument pack substitution index within a Sema object.
RAII object used to temporarily allow the C++ 'this' expression to be used, with the given qualifiers...
CXXSpecialMemberKind asSpecialMember() const
A helper class for building up ExtParameterInfos.
Records and restores the CurFPFeatures state on entry/exit of compound statements.
RAII class used to indicate that we are performing provisional semantic analysis to determine the val...
Sema - This implements semantic analysis and AST building for C.
MemInitResult BuildDelegatingInitializer(TypeSourceInfo *TInfo, Expr *Init, CXXRecordDecl *ClassDecl)
SmallVector< CodeSynthesisContext, 16 > CodeSynthesisContexts
List of active code synthesis contexts.
LocalInstantiationScope * CurrentInstantiationScope
The current instantiation scope used to store local variables.
TemplateArgumentLoc getTrivialTemplateArgumentLoc(const TemplateArgument &Arg, QualType NTTPType, SourceLocation Loc, NamedDecl *TemplateParam=nullptr)
Allocate a TemplateArgumentLoc where all locations have been initialized to the given location.
bool CheckUsingDeclQualifier(SourceLocation UsingLoc, bool HasTypename, const CXXScopeSpec &SS, const DeclarationNameInfo &NameInfo, SourceLocation NameLoc, const LookupResult *R=nullptr, const UsingDecl *UD=nullptr)
Checks that the given nested-name qualifier used in a using decl in the current context is appropriat...
DefaultedFunctionKind getDefaultedFunctionKind(const FunctionDecl *FD)
Determine the kind of defaulting that would be done for a given function.
@ LookupOrdinaryName
Ordinary name lookup, which finds ordinary names (functions, variables, typedefs, etc....
@ LookupUsingDeclName
Look up all declarations in a scope with the given name, including resolved using declarations.
@ LookupRedeclarationWithLinkage
Look up an ordinary name that is going to be redeclared as a name with linkage.
Decl * ActOnSkippedFunctionBody(Decl *Decl)
NamedDecl * FindInstantiatedDecl(SourceLocation Loc, NamedDecl *D, const MultiLevelTemplateArgumentList &TemplateArgs, bool FindingInstantiatedContext=false)
Find the instantiation of the given declaration within the current instantiation.
MemInitResult BuildBaseInitializer(QualType BaseType, TypeSourceInfo *BaseTInfo, Expr *Init, CXXRecordDecl *ClassDecl, SourceLocation EllipsisLoc)
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.
const ExpressionEvaluationContextRecord & currentEvaluationContext() const
void deduceOpenCLAddressSpace(ValueDecl *decl)
PragmaStack< FPOptionsOverride > FpPragmaStack
FunctionDecl * InstantiateFunctionDeclaration(FunctionTemplateDecl *FTD, const TemplateArgumentList *Args, SourceLocation Loc, CodeSynthesisContext::SynthesisKind CSC=CodeSynthesisContext::ExplicitTemplateArgumentSubstitution)
Instantiate (or find existing instantiation of) a function template with a given set of template argu...
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
DeclGroupPtrTy ConvertDeclToDeclGroup(Decl *Ptr, Decl *OwnedType=nullptr)
void InstantiateMemInitializers(CXXConstructorDecl *New, const CXXConstructorDecl *Tmpl, const MultiLevelTemplateArgumentList &TemplateArgs)
void CleanupVarDeclMarking()
ASTContext & getASTContext() const
TypeSourceInfo * SubstType(TypeSourceInfo *T, const MultiLevelTemplateArgumentList &TemplateArgs, SourceLocation Loc, DeclarationName Entity, bool AllowDeducedTST=false)
Perform substitution on the type T with a given set of template arguments.
void InstantiateVariableDefinition(SourceLocation PointOfInstantiation, VarDecl *Var, bool Recursive=false, bool DefinitionRequired=false, bool AtEndOfTU=false)
Instantiate the definition of the given variable from its template.
SmallVector< LateInstantiatedAttribute, 1 > LateInstantiatedAttrVec
PrintingPolicy getPrintingPolicy() const
Retrieve a suitable printing policy for diagnostics.
void HandleDependentAccessCheck(const DependentDiagnostic &DD, const MultiLevelTemplateArgumentList &TemplateArgs)
@ TPL_TemplateMatch
We are matching the template parameter lists of two templates that might be redeclarations.
void SetDeclDefaulted(Decl *dcl, SourceLocation DefaultLoc)
NamedReturnInfo getNamedReturnInfo(Expr *&E, SimplerImplicitMoveMode Mode=SimplerImplicitMoveMode::Normal)
Determine whether the given expression might be move-eligible or copy-elidable in either a (co_)retur...
Sema(Preprocessor &pp, ASTContext &ctxt, ASTConsumer &consumer, TranslationUnitKind TUKind=TU_Complete, CodeCompleteConsumer *CompletionConsumer=nullptr)
void InstantiateAttrs(const MultiLevelTemplateArgumentList &TemplateArgs, const Decl *Pattern, Decl *Inst, LateInstantiatedAttrVec *LateAttrs=nullptr, LocalInstantiationScope *OuterMostScope=nullptr)
const LangOptions & getLangOpts() const
void AddModeAttr(Decl *D, const AttributeCommonInfo &CI, IdentifierInfo *Name, bool InInstantiation=false)
AddModeAttr - Adds a mode attribute to a particular declaration.
void collectUnexpandedParameterPacks(TemplateArgument Arg, SmallVectorImpl< UnexpandedParameterPack > &Unexpanded)
Collect the set of unexpanded parameter packs within the given template argument.
const LangOptions & LangOpts
Decl * ActOnStartOfFunctionDef(Scope *S, Declarator &D, MultiTemplateParamsArg TemplateParamLists, SkipBodyInfo *SkipBody=nullptr, FnBodyKind BodyKind=FnBodyKind::Other)
VarTemplateSpecializationDecl * CompleteVarTemplateSpecializationDecl(VarTemplateSpecializationDecl *VarSpec, VarDecl *PatternDecl, const MultiLevelTemplateArgumentList &TemplateArgs)
Instantiates a variable template specialization by completing it with appropriate type information an...
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.
const VarDecl * getCopyElisionCandidate(NamedReturnInfo &Info, QualType ReturnType)
Updates given NamedReturnInfo's move-eligible and copy-elidable statuses, considering the function re...
void AddAllocAlignAttr(Decl *D, const AttributeCommonInfo &CI, Expr *ParamExpr)
AddAllocAlignAttr - Adds an alloc_align attribute to a particular declaration.
UnsignedOrNone getNumArgumentsInExpansion(QualType T, const MultiLevelTemplateArgumentList &TemplateArgs)
Determine the number of arguments in the given pack expansion type.
bool usesPartialOrExplicitSpecialization(SourceLocation Loc, ClassTemplateSpecializationDecl *ClassTemplateSpec)
ExplicitSpecifier instantiateExplicitSpecifier(const MultiLevelTemplateArgumentList &TemplateArgs, ExplicitSpecifier ES)
bool CheckVariableDeclaration(VarDecl *NewVD, LookupResult &Previous)
Perform semantic checking on a newly-created variable declaration.
sema::BlockScopeInfo * getCurBlock()
Retrieve the current block, if any.
DeclContext * CurContext
CurContext - This is the current declaration context of parsing.
MultiLevelTemplateArgumentList getTemplateInstantiationArgs(const NamedDecl *D, const DeclContext *DC=nullptr, bool Final=false, std::optional< ArrayRef< TemplateArgument > > Innermost=std::nullopt, bool RelativeToPrimary=false, const FunctionDecl *Pattern=nullptr, bool ForConstraintInstantiation=false, bool SkipForSpecialization=false, bool ForDefaultArgumentSubstitution=false)
Retrieve the template argument list(s) that should be used to instantiate the definition of the given...
std::deque< PendingImplicitInstantiation > PendingLocalImplicitInstantiations
The queue of implicit template instantiations that are required and must be performed within the curr...
ExprResult PerformContextuallyConvertToBool(Expr *From)
PerformContextuallyConvertToBool - Perform a contextual conversion of the expression From to bool (C+...
SourceManager & getSourceManager() const
FunctionDecl * SubstSpaceshipAsEqualEqual(CXXRecordDecl *RD, FunctionDecl *Spaceship)
Substitute the name and return type of a defaulted 'operator<=>' to form an implicit 'operator=='.
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)
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...
void InstantiateDefaultCtorDefaultArgs(CXXConstructorDecl *Ctor)
In the MS ABI, we need to instantiate default arguments of dllexported default constructors along wit...
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.
bool hasUncompilableErrorOccurred() const
Whether uncompilable error has occurred.
std::deque< PendingImplicitInstantiation > PendingInstantiations
The queue of implicit template instantiations that are required but have not yet been performed.
bool CheckInheritingConstructorUsingDecl(UsingDecl *UD)
Additional checks for a using declaration referring to a constructor name.
void addClusterDimsAttr(Decl *D, const AttributeCommonInfo &CI, Expr *X, Expr *Y, Expr *Z)
@ ConstantEvaluated
The current context is "potentially evaluated" in C++11 terms, but the expression is evaluated at com...
@ PotentiallyEvaluated
The current expression is potentially evaluated at run time, which means that code may be generated t...
@ Unevaluated
The current expression and its subexpressions occur within an unevaluated operand (C++11 [expr]p7),...
NestedNameSpecifierLoc SubstNestedNameSpecifierLoc(NestedNameSpecifierLoc NNS, const MultiLevelTemplateArgumentList &TemplateArgs)
bool RequireCompleteType(SourceLocation Loc, QualType T, CompleteTypeKind Kind, TypeDiagnoser &Diagnoser)
Ensure that the type T is a complete type.
LateTemplateParserCB * LateTemplateParser
bool LookupQualifiedName(LookupResult &R, DeclContext *LookupCtx, bool InUnqualifiedLookup=false)
Perform qualified name lookup into a given context.
SmallVector< ExpressionEvaluationContextRecord, 8 > ExprEvalContexts
A stack of expression evaluation contexts.
bool DiagnoseUninstantiableTemplate(SourceLocation PointOfInstantiation, NamedDecl *Instantiation, bool InstantiatedFromMember, const NamedDecl *Pattern, const NamedDecl *PatternDef, TemplateSpecializationKind TSK, bool Complain=true, bool *Unreachable=nullptr)
Determine whether we would be unable to instantiate this template (because it either has no definitio...
SourceManager & SourceMgr
bool CheckParameterPacksForExpansion(SourceLocation EllipsisLoc, SourceRange PatternRange, ArrayRef< UnexpandedParameterPack > Unexpanded, const MultiLevelTemplateArgumentList &TemplateArgs, bool FailOnPackProducingTemplates, bool &ShouldExpand, bool &RetainExpansion, UnsignedOrNone &NumExpansions)
Determine whether we could expand a pack expansion with the given set of parameter packs into separat...
bool CheckAlignasTypeArgument(StringRef KWName, TypeSourceInfo *TInfo, SourceLocation OpLoc, SourceRange R)
static bool adjustContextForLocalExternDecl(DeclContext *&DC)
Adjust the DeclContext for a function or variable that might be a function-local external declaration...
Attr * CreateAnnotationAttr(const AttributeCommonInfo &CI, StringRef Annot, MutableArrayRef< Expr * > Args)
CreateAnnotationAttr - Creates an annotation Annot with Args arguments.
@ TPC_FriendFunctionTemplate
@ TPC_FriendFunctionTemplateDefinition
void DiagnoseUnusedDecl(const NamedDecl *ND)
void ActOnUninitializedDecl(Decl *dcl)
void AddInitializerToDecl(Decl *dcl, Expr *init, bool DirectInit)
AddInitializerToDecl - Adds the initializer Init to the declaration dcl.
void runWithSufficientStackSpace(SourceLocation Loc, llvm::function_ref< void()> Fn)
Run some code with "sufficient" stack space.
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.
bool CheckCXXDefaultArgExpr(SourceLocation CallLoc, FunctionDecl *FD, ParmVarDecl *Param, Expr *Init=nullptr, bool SkipImmediateInvocations=true)
Instantiate or parse a C++ default argument expression as necessary.
ASTMutationListener * getASTMutationListener() const
ExprResult ActOnFinishFullExpr(Expr *Expr, bool DiscardedValue)
Encodes a location in the source.
A trivial tuple used to represent a source range.
SourceLocation getEnd() const
Represents a C++11 static_assert declaration.
SourceLocation getRParenLoc() const
Stmt - This represents one statement.
SourceLocation getEndLoc() const LLVM_READONLY
SourceLocation getBeginLoc() const LLVM_READONLY
Represents the declaration of a struct/union/class/enum.
bool isThisDeclarationADefinition() const
Return true if this declaration is a completion definition of the type.
bool isCompleteDefinition() const
Return true if this decl has its body fully specified.
NestedNameSpecifierLoc getQualifierLoc() const
Retrieve the nested-name-specifier (with source-location information) that qualifies the name of this...
TypedefNameDecl * getTypedefNameForAnonDecl() const
void setTypedefNameForAnonDecl(TypedefNameDecl *TDD)
void setQualifierInfo(NestedNameSpecifierLoc QualifierLoc)
bool hasNameForLinkage() const
Is this tag type named, either directly or via being defined in a typedef of this type?
TagKind getTagKind() const
SourceLocation getNameLoc() const
void setQualifierLoc(NestedNameSpecifierLoc QualifierLoc)
void setNameLoc(SourceLocation Loc)
void setElaboratedKeywordLoc(SourceLocation Loc)
A convenient class for passing around template argument information.
void setLAngleLoc(SourceLocation Loc)
void setRAngleLoc(SourceLocation Loc)
void addArgument(const TemplateArgumentLoc &Loc)
A template argument list.
static TemplateArgumentList * CreateCopy(ASTContext &Context, ArrayRef< TemplateArgument > Args)
Create a new template argument list that copies the given set of template arguments.
ArrayRef< TemplateArgument > asArray() const
Produce this as an array ref.
Location wrapper for a TemplateArgument.
const TemplateArgument & getArgument() const
SourceLocation getTemplateNameLoc() const
SourceLocation getTemplateKWLoc() const
NestedNameSpecifierLoc getTemplateQualifierLoc() const
Represents a template argument.
TemplateName getAsTemplate() const
Retrieve the template name for a template name argument.
@ Pack
The template argument is actually a parameter pack.
@ RewriteSpaceshipAsEqualEqual
void setEvaluateConstraints(bool B)
Decl * VisitDecl(Decl *D)
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.
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.
bool isNull() const
Determine whether this template name is NULL.
A template parameter object.
Stores a list of template parameters for a TemplateDecl and its derived classes.
SourceRange getSourceRange() const LLVM_READONLY
static TemplateParameterList * Create(const ASTContext &C, SourceLocation TemplateLoc, SourceLocation LAngleLoc, ArrayRef< NamedDecl * > Params, SourceLocation RAngleLoc, Expr *RequiresClause)
Expr * getRequiresClause()
The constraint-expression of the associated requires-clause.
SourceLocation getRAngleLoc() const
SourceLocation getLAngleLoc() const
ArrayRef< NamedDecl * > asArray()
SourceLocation getTemplateLoc() const
TemplateTemplateParmDecl - Declares a template template parameter, e.g., "T" in.
bool wasDeclaredWithTypename() const
Whether this template template parameter was declared with the 'typename' keyword.
TemplateParameterList * getExpansionTemplateParameters(unsigned I) const
Retrieve a particular expansion type within an expanded parameter pack.
bool isPackExpansion() const
Whether this parameter pack is a pack expansion.
unsigned getNumExpansionTemplateParameters() const
Retrieves the number of expansion template parameters in an expanded parameter pack.
TemplateNameKind templateParameterKind() const
const TemplateArgumentLoc & getDefaultArgument() const
Retrieve the default argument, if any.
unsigned getPosition() const
Get the position of the template parameter within its parameter list.
static TemplateTemplateParmDecl * Create(const ASTContext &C, DeclContext *DC, SourceLocation L, unsigned D, unsigned P, bool ParameterPack, IdentifierInfo *Id, TemplateNameKind ParameterKind, bool Typename, TemplateParameterList *Params)
bool isParameterPack() const
Whether this template template parameter is a template parameter pack.
bool defaultArgumentWasInherited() const
Determines whether the default argument was inherited from a previous declaration of this template.
void setDefaultArgument(const ASTContext &C, const TemplateArgumentLoc &DefArg)
Set the default argument for this template parameter, and whether that default argument was inherited...
unsigned getDepth() const
Get the nesting depth of the template parameter.
bool isExpandedParameterPack() const
Whether this parameter is a template template parameter pack that has a known list of different templ...
bool hasDefaultArgument() const
Determine whether this template parameter has a default argument.
Declaration of a template type parameter.
bool wasDeclaredWithTypename() const
Whether this template type parameter was declared with the 'typename' keyword.
const TemplateArgumentLoc & getDefaultArgument() const
Retrieve the default argument, if any.
unsigned getIndex() const
Retrieve the index of the template parameter.
bool hasTypeConstraint() const
Determine whether this template parameter has a type-constraint.
const TypeConstraint * getTypeConstraint() const
Returns the type constraint associated with this template parameter (if any).
UnsignedOrNone getNumExpansionParameters() const
Whether this parameter is a template type parameter pack that has a known list of different type-cons...
bool hasDefaultArgument() const
Determine whether this template parameter has a default argument.
bool defaultArgumentWasInherited() const
Determines whether the default argument was inherited from a previous declaration of this template.
bool isParameterPack() const
Returns whether this is a parameter pack.
static TemplateTypeParmDecl * Create(const ASTContext &C, DeclContext *DC, SourceLocation KeyLoc, SourceLocation NameLoc, unsigned D, unsigned P, IdentifierInfo *Id, bool Typename, bool ParameterPack, bool HasTypeConstraint=false, UnsignedOrNone NumExpanded=std::nullopt)
unsigned getDepth() const
Retrieve the depth of the template parameter.
void setDefaultArgument(const ASTContext &C, const TemplateArgumentLoc &DefArg)
Set the default argument for this template parameter.
bool isPackExpansion() const
Whether this parameter pack is a pack expansion.
The top declaration context.
Represents the declaration of a typedef-name via a C++11 alias-declaration.
static TypeAliasDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, const IdentifierInfo *Id, TypeSourceInfo *TInfo)
void setDescribedAliasTemplate(TypeAliasTemplateDecl *TAT)
Declaration of an alias template.
static TypeAliasTemplateDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation L, DeclarationName Name, TemplateParameterList *Params, NamedDecl *Decl)
Create a function template node.
TypeAliasDecl * getTemplatedDecl() const
Get the underlying function declaration of the template.
const Type * getTypeForDecl() const
SourceLocation getBeginLoc() const LLVM_READONLY
TyLocType push(QualType T)
Pushes space for a new TypeLoc of the given type.
TypeSourceInfo * getTypeSourceInfo(ASTContext &Context, QualType T)
Creates a TypeSourceInfo for the given type.
void pushTrivial(ASTContext &Context, QualType T, SourceLocation Loc)
Pushes 'T' with all locations pointing to 'Loc'.
Base wrapper for a particular "section" of type source info.
T getAs() const
Convert to the specified TypeLoc type, returning a null TypeLoc if this TypeLoc is not of the desired...
TypeLoc IgnoreParens() const
T castAs() const
Convert to the specified TypeLoc type, asserting that this TypeLoc is of the desired type.
SourceRange getSourceRange() const LLVM_READONLY
Get the full source range.
AutoTypeLoc getContainedAutoTypeLoc() const
Get the typeloc of an AutoType whose type will be deduced for a variable with an initializer of this ...
T getAsAdjusted() const
Convert to the specified TypeLoc type, returning a null TypeLoc if this TypeLoc is not of the desired...
SourceLocation getBeginLoc() const
Get the begin source location.
A container of type source information.
TypeLoc getTypeLoc() const
Return the TypeLoc wrapper for the type source info.
QualType getType() const
Return the type wrapped by this type source info.
The base class of the type hierarchy.
bool isRValueReferenceType() const
const T * castAs() const
Member-template castAs<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.
static VarTemplateDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation L, DeclarationName Name, TemplateParameterList *Params, VarDecl *Decl)
Create a variable template node.
llvm::FoldingSetVector< VarTemplatePartialSpecializationDecl > & getPartialSpecializations() const
Retrieve the set of partial specializations of this class template.
VarTemplateSpecializationDecl * findSpecialization(ArrayRef< TemplateArgument > Args, void *&InsertPos)
Return the specialization with the provided arguments if it exists, otherwise return the insertion po...
VarTemplatePartialSpecializationDecl * findPartialSpecInstantiatedFromMember(VarTemplatePartialSpecializationDecl *D)
Find a variable template partial specialization which was instantiated from the given member partial ...
static VarTemplatePartialSpecializationDecl * Create(ASTContext &Context, DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, TemplateParameterList *Params, VarTemplateDecl *SpecializedTemplate, QualType T, TypeSourceInfo *TInfo, StorageClass S, ArrayRef< TemplateArgument > Args)
TemplateParameterList * getTemplateParameters() const
Get the list of template parameters.
void setInstantiatedFromMember(VarTemplatePartialSpecializationDecl *PartialSpec)
Represents a variable template specialization, which refers to a variable template with a given set o...
SourceLocation getPointOfInstantiation() const
Get the point of instantiation (if any), or null if none.
void setTemplateArgsAsWritten(const ASTTemplateArgumentListInfo *ArgsWritten)
Set the template argument list as written in the sources.
const ASTTemplateArgumentListInfo * getTemplateArgsAsWritten() const
Retrieve the template argument list as written in the sources, if any.
const TemplateArgumentList & getTemplateArgs() const
Retrieve the template arguments of the variable template specialization.
const TemplateArgumentList & getTemplateInstantiationArgs() const
Retrieve the set of template arguments that should be used to instantiate the initializer of the vari...
static VarTemplateSpecializationDecl * Create(ASTContext &Context, DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, VarTemplateDecl *SpecializedTemplate, QualType T, TypeSourceInfo *TInfo, StorageClass S, ArrayRef< TemplateArgument > Args)
llvm::PointerUnion< VarTemplateDecl *, VarTemplatePartialSpecializationDecl * > getSpecializedTemplateOrPartial() const
Retrieve the variable template or variable template partial specialization which was specialized by t...
TemplateSpecializationKind getSpecializationKind() const
Determine the kind of specialization that this declaration represents.
VarTemplateDecl * getSpecializedTemplate() const
Retrieve the template that this specialization specializes.
void setCompleteDefinition()
Decl * Visit(PTR(Decl) D)
QualType FunctionType
BlockType - The function type of the block, if one was given.
void addCapture(ValueDecl *Var, bool isBlock, bool isByref, bool isNested, SourceLocation Loc, SourceLocation EllipsisLoc, QualType CaptureType, bool Invalid)
Provides information about an attempted template argument deduction, whose success or failure was des...
Defines the clang::TargetInfo interface.
const internal::VariadicAllOfMatcher< Decl > decl
Matches declarations.
bool NE(InterpState &S, CodePtr OpPC)
std::variant< struct RequiresDecl, struct HeaderDecl, struct UmbrellaDirDecl, struct ModuleDecl, struct ExcludeDecl, struct ExportDecl, struct ExportAsDecl, struct ExternModuleDecl, struct UseDecl, struct LinkDecl, struct ConfigMacrosDecl, struct ConflictDecl > Decl
All declarations that can appear in a module declaration.
Attr * instantiateTemplateAttribute(const Attr *At, ASTContext &C, Sema &S, const MultiLevelTemplateArgumentList &TemplateArgs)
Attr * instantiateTemplateAttributeForDecl(const Attr *At, ASTContext &C, Sema &S, const MultiLevelTemplateArgumentList &TemplateArgs)
The JSON file list parser is used to communicate input to InstallAPI.
CanQual< Type > CanQualType
Represents a canonical, potentially-qualified type.
void atTemplateEnd(TemplateInstantiationCallbackPtrs &Callbacks, const Sema &TheSema, const Sema::CodeSynthesisContext &Inst)
bool isa(CodeGen::Address addr)
void atTemplateBegin(TemplateInstantiationCallbackPtrs &Callbacks, const Sema &TheSema, const Sema::CodeSynthesisContext &Inst)
@ Rewrite
We are substituting template parameters for (typically) other template parameters in order to rewrite...
@ TemplateName
The identifier is a template name. FIXME: Add an annotation for that.
@ DevicePtr
'deviceptr' clause, allowed on Compute and Combined Constructs, plus 'data' and 'declare'.
@ VectorLength
'vector_length' clause, allowed on 'parallel', 'kernels', 'parallel loop', and 'kernels loop' constru...
@ Async
'async' clause, allowed on Compute, Data, 'update', 'wait', and Combined constructs.
@ Collapse
'collapse' clause, allowed on 'loop' and Combined constructs.
@ DeviceNum
'device_num' clause, allowed on 'init', 'shutdown', and 'set' constructs.
@ DefaultAsync
'default_async' clause, allowed on 'set' construct.
@ Attach
'attach' clause, allowed on Compute and Combined constructs, plus 'data' and 'enter data'.
@ NumGangs
'num_gangs' clause, allowed on 'parallel', 'kernels', parallel loop', and 'kernels loop' constructs.
@ If
'if' clause, allowed on all the Compute Constructs, Data Constructs, Executable Constructs,...
@ UseDevice
'use_device' clause, allowed on 'host_data' construct.
@ NoCreate
'no_create' clause, allowed on allowed on Compute and Combined constructs, plus 'data'.
@ Reduction
'reduction' clause, allowed on Parallel, Serial, Loop, and the combined constructs.
@ Self
'self' clause, allowed on Compute and Combined Constructs, plus 'update'.
@ FirstPrivate
'firstprivate' clause, allowed on 'parallel', 'serial', 'parallel loop', and 'serial loop' constructs...
@ Tile
'tile' clause, allowed on 'loop' and Combined constructs.
@ Independent
'independent' clause, allowed on 'loop' directives.
@ NumWorkers
'num_workers' clause, allowed on 'parallel', 'kernels', parallel loop', and 'kernels loop' constructs...
@ IfPresent
'if_present' clause, allowed on 'host_data' and 'update' directives.
@ Detach
'detach' clause, allowed on the 'exit data' construct.
@ Delete
'delete' clause, allowed on the 'exit data' construct.
@ Finalize
'finalize' clause, allowed on 'exit data' directive.
StorageClass
Storage classes.
bool isGenericLambdaCallOperatorOrStaticInvokerSpecialization(const DeclContext *DC)
@ Property
The type of a property.
@ Result
The result type of a method or function.
ActionResult< CXXCtorInitializer * > MemInitResult
const FunctionProtoType * T
@ Template
We are parsing a template declaration.
@ FunctionTemplate
The name was classified as a function template name.
@ VarTemplate
The name was classified as a variable template name.
@ TU_Prefix
The translation unit is a prefix to a translation unit, and is not complete.
@ VK_PRValue
A pr-value expression (in the C++11 taxonomy) produces a temporary value.
bool declaresSameEntity(const Decl *D1, const Decl *D2)
Determine whether two declarations declare the same entity.
TemplateSpecializationKind
Describes the kind of template specialization that a particular template specialization declaration r...
@ TSK_ExplicitInstantiationDefinition
This template specialization was instantiated from a template due to an explicit instantiation defini...
@ TSK_ExplicitInstantiationDeclaration
This template specialization was instantiated from a template due to an explicit instantiation declar...
@ TSK_ExplicitSpecialization
This template specialization was declared or defined by an explicit specialization (C++ [temp....
@ TSK_ImplicitInstantiation
This template specialization was implicitly instantiated from a template.
@ TSK_Undeclared
This template specialization was formed from a template-id but has not yet been declared,...
U cast(CodeGen::Address addr)
@ None
No keyword precedes the qualified type name.
@ Enum
The "enum" keyword introduces the elaborated-type-specifier.
bool isLambdaMethod(const DeclContext *DC)
ActionResult< Expr * > ExprResult
@ Other
Other implicit parameter.
ExceptionSpecificationType
The various types of exception specifications that exist in C++11.
@ EST_Uninstantiated
not instantiated yet
@ EST_None
no exception specification
@ EST_BasicNoexcept
noexcept
@ EST_Unevaluated
not evaluated yet, for special member function
ActionResult< Stmt * > StmtResult
Represents an explicit template argument list in C++, e.g., the "<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
getNamedTypeInfo - Returns the source type info associated to the name.
Holds information about the various types of exception specification.
FunctionDecl * SourceDecl
The function whose exception specification this is, for EST_Unevaluated and EST_Uninstantiated.
FunctionDecl * SourceTemplate
The function template whose exception specification this is instantiated from, for EST_Uninstantiated...
ExceptionSpecificationType Type
The kind of exception specification this is.
Extra information about a function prototype.
ExceptionSpecInfo ExceptionSpec
FunctionType::ExtInfo ExtInfo
bool StrictPackMatch
Is set to true when, in the context of TTP matching, a pack parameter matches non-pack arguments.
SmallVector< TemplateArgument, 4 > CanonicalConverted
A context in which code is being synthesized (where a source location alone is not sufficient to iden...
SynthesisKind
The kind of template instantiation we are performing.
@ BuildingDeductionGuides
We are building deduction guides for a class.
@ DeducedTemplateArgumentSubstitution
We are substituting template argument determined as part of template argument deduction for either a ...
bool InLifetimeExtendingContext
Whether we are currently in a context in which all temporaries must be lifetime-extended,...
bool RebuildDefaultArgOrDefaultInit
Whether we should rebuild CXXDefaultArgExpr and CXXDefaultInitExpr.
A stack object to be created when performing template instantiation.
bool isInvalid() const
Determines whether we have exceeded the maximum recursive template instantiations.