36#include "llvm/Support/TimeProfiler.h"
47 return cast<CXXRecordDecl>(DC)->isLocalClass();
52template<
typename DeclT>
55 if (!OldDecl->getQualifierLoc())
58 assert((NewDecl->getFriendObjectKind() ||
59 !OldDecl->getLexicalDeclContext()->isDependentContext()) &&
60 "non-friend with qualified name defined in dependent context");
63 const_cast<DeclContext *
>(NewDecl->getFriendObjectKind()
64 ? NewDecl->getLexicalDeclContext()
65 : OldDecl->getLexicalDeclContext()));
74 NewDecl->setQualifierInfo(NewQualifierLoc);
80 return ::SubstQualifier(SemaRef, OldDecl, NewDecl, TemplateArgs);
85 return ::SubstQualifier(SemaRef, OldDecl, NewDecl, TemplateArgs);
89#include "clang/Sema/AttrTemplateInstantiate.inc"
93 const AlignedAttr *Aligned,
Decl *
New,
bool IsPackExpansion) {
94 if (Aligned->isAlignmentExpr()) {
103 S.
SubstType(Aligned->getAlignmentType(), TemplateArgs,
106 Aligned->getLocation(),
107 Result->getTypeLoc().getSourceRange()))
115 const AlignedAttr *Aligned,
Decl *
New) {
116 if (!Aligned->isPackExpansion()) {
122 if (Aligned->isAlignmentExpr())
128 assert(!Unexpanded.empty() &&
"Pack expansion without parameter packs?");
131 bool Expand =
true, RetainExpansion =
false;
136 Unexpanded, TemplateArgs,
138 Expand, RetainExpansion, NumExpansions))
145 for (
unsigned I = 0; I != *NumExpansions; ++I) {
154 const AssumeAlignedAttr *Aligned,
Decl *
New) {
159 Expr *
E, *OE =
nullptr;
165 if (Aligned->getOffset()) {
177 const AlignValueAttr *Aligned,
Decl *
New) {
188 const AllocAlignAttr *Align,
Decl *
New) {
191 llvm::APInt(64, Align->getParamIndex().getSourceIndex()),
204 bool HasDelayedArgs =
Attr->delayedArgs_size();
213 false, TemplateArgs, Args))
216 StringRef Str =
Attr->getAnnotation();
217 if (HasDelayedArgs) {
218 if (Args.size() < 1) {
228 ActualArgs.insert(ActualArgs.begin(), Args.begin() + 1, Args.end());
229 std::swap(Args, ActualArgs);
240 Expr *Cond =
nullptr;
254 Cond = Converted.
get();
260 S.
Diag(A->
getLocation(), diag::err_attr_cond_never_constant_expr) << A;
261 for (
const auto &
P : Diags)
262 S.
Diag(
P.first,
P.second);
272 S, TemplateArgs, EIA, EIA->getCond(), Tmpl,
New);
276 Cond, EIA->getMessage()));
283 S, TemplateArgs, DIA, DIA->getCond(), Tmpl,
New);
288 DIA->getDefaultSeverity(), DIA->getWarningGroup(),
289 DIA->getArgDependent(),
New));
306 Expr *MinBlocks =
nullptr;
307 if (
Attr.getMinBlocks()) {
314 Expr *MaxBlocks =
nullptr;
315 if (
Attr.getMaxBlocks()) {
338 if (
auto *FTD = dyn_cast<FunctionTemplateDecl>(
New))
339 New = FTD->getTemplatedDecl();
340 auto *FD = cast<FunctionDecl>(
New);
341 auto *ThisContext = dyn_cast_or_null<CXXRecordDecl>(FD->getDeclContext());
347 if (
auto *PVD = dyn_cast<ParmVarDecl>(DRE->getDecl())) {
350 if (FD->getNumParams() > PVD->getFunctionScopeIndex())
351 Local.InstantiatedLocal(
352 PVD, FD->getParamDecl(PVD->getFunctionScopeIndex()));
356 FD->isCXXInstanceMember());
372 if (
auto *
E =
Attr.getSimdlen())
375 if (
Attr.uniforms_size() > 0) {
376 for(
auto *
E :
Attr.uniforms()) {
380 Uniforms.push_back(Inst.
get());
384 auto AI =
Attr.alignments_begin();
385 for (
auto *
E :
Attr.aligneds()) {
389 Aligneds.push_back(Inst.
get());
393 Alignments.push_back(Inst.
get());
397 auto SI =
Attr.steps_begin();
398 for (
auto *
E :
Attr.linears()) {
402 Linears.push_back(Inst.
get());
406 Steps.push_back(Inst.
get());
409 LinModifiers.append(
Attr.modifiers_begin(),
Attr.modifiers_end());
412 Uniforms, Aligneds, Alignments, Linears, LinModifiers, Steps,
421 if (
auto *FTD = dyn_cast<FunctionTemplateDecl>(
New))
422 New = FTD->getTemplatedDecl();
423 auto *FD = cast<FunctionDecl>(
New);
424 auto *ThisContext = dyn_cast_or_null<CXXRecordDecl>(FD->getDeclContext());
426 auto &&SubstExpr = [FD, ThisContext, &S, &TemplateArgs](
Expr *
E) {
428 if (
auto *PVD = dyn_cast<ParmVarDecl>(DRE->getDecl())) {
431 if (FD->getNumParams() > PVD->getFunctionScopeIndex())
432 Local.InstantiatedLocal(
433 PVD, FD->getParamDecl(PVD->getFunctionScopeIndex()));
437 FD->isCXXInstanceMember());
443 auto &&Subst = [&SubstExpr, &S](
Expr *
E) {
453 if (
Expr *
E =
Attr.getVariantFuncRef()) {
458 VariantFuncRef = Subst(
E);
464 TI = *
Attr.getTraitInfos();
467 auto SubstScoreOrConditionExpr = [&S, Subst](
Expr *&
E,
bool) {
486 std::optional<std::pair<FunctionDecl *, Expr *>> DeclVarData =
494 E = DeclVarData->second;
495 FD = DeclVarData->first;
498 if (
auto *VariantFD = dyn_cast<FunctionDecl>(VariantDRE->getDecl())) {
499 if (
auto *VariantFTD = VariantFD->getDescribedFunctionTemplate()) {
500 if (!VariantFTD->isThisDeclarationADefinition())
511 SubstFD->getType(), FD->getType(),
517 New->getLocation(), SubstFD,
true,
519 SubstFD->setInstantiationIsPending(!SubstFD->isDefined());
523 SubstFD->getLocation(),
534 for (
Expr *
E :
Attr.adjustArgsNothing()) {
538 NothingExprs.push_back(ER.
get());
540 for (
Expr *
E :
Attr.adjustArgsNeedDevicePtr()) {
544 NeedDevicePtrExprs.push_back(ER.
get());
546 for (
Expr *
E :
Attr.adjustArgsNeedDeviceAddr()) {
550 NeedDeviceAddrExprs.push_back(ER.
get());
554 AppendArgs.emplace_back(II.IsTarget, II.IsTargetSync);
558 FD,
E, TI, NothingExprs, NeedDevicePtrExprs, NeedDeviceAddrExprs,
564 const AMDGPUFlatWorkGroupSizeAttr &
Attr,
Decl *
New) {
605 New->addAttr(::new (Context) ReqdWorkGroupSizeAttr(Context,
Attr,
X, Y, Z));
613 Expr *Cond =
nullptr;
621 Cond = SubstResult.
get();
641 Expr *MaxExpr =
nullptr;
642 if (
auto Max =
Attr.getMax()) {
654 const AMDGPUMaxNumWorkGroupsAttr &
Attr,
Decl *
New) {
658 Expr *XExpr =
nullptr;
659 Expr *YExpr =
nullptr;
660 Expr *ZExpr =
nullptr;
662 if (
Attr.getMaxNumWorkGroupsX()) {
668 if (
Attr.getMaxNumWorkGroupsY()) {
674 if (
Attr.getMaxNumWorkGroupsZ()) {
699 if (
const auto *PNA = dyn_cast<PreferredNameAttr>(A)) {
701 const auto *RD = cast<CXXRecordDecl>(
D);
707 PNA->getTypedefType()))
712 if (
const auto *BA = dyn_cast<BuiltinAttr>(A)) {
714 switch (BA->getID()) {
715 case Builtin::BIforward:
725 case Builtin::BImove:
726 case Builtin::BImove_if_noexcept:
756 for (
const auto *TmplAttr : Tmpl->
attrs()) {
763 *
this, dyn_cast_or_null<CXXRecordDecl>(ND->getDeclContext()),
767 TmplAttr,
Context, *
this, TemplateArgs);
769 New->addAttr(NewAttr);
777 case clang::attr::CFConsumed:
779 case clang::attr::OSConsumed:
781 case clang::attr::NSConsumed:
784 llvm_unreachable(
"Wrong argument supplied");
791 const OpenACCRoutineDeclAttr *OldAttr,
const Decl *Old,
Decl *
New);
797 for (
const auto *TmplAttr : Tmpl->
attrs()) {
802 const AlignedAttr *Aligned = dyn_cast<AlignedAttr>(TmplAttr);
803 if (Aligned && Aligned->isAlignmentDependent()) {
808 if (
const auto *AssumeAligned = dyn_cast<AssumeAlignedAttr>(TmplAttr)) {
813 if (
const auto *AlignValue = dyn_cast<AlignValueAttr>(TmplAttr)) {
818 if (
const auto *AllocAlign = dyn_cast<AllocAlignAttr>(TmplAttr)) {
823 if (
const auto *Annotate = dyn_cast<AnnotateAttr>(TmplAttr)) {
828 if (
const auto *EnableIf = dyn_cast<EnableIfAttr>(TmplAttr)) {
830 cast<FunctionDecl>(
New));
834 if (
const auto *DiagnoseIf = dyn_cast<DiagnoseIfAttr>(TmplAttr)) {
836 cast<FunctionDecl>(
New));
840 if (
const auto *CUDALaunchBounds =
841 dyn_cast<CUDALaunchBoundsAttr>(TmplAttr)) {
843 *CUDALaunchBounds,
New);
847 if (
const auto *Mode = dyn_cast<ModeAttr>(TmplAttr)) {
852 if (
const auto *OMPAttr = dyn_cast<OMPDeclareSimdDeclAttr>(TmplAttr)) {
857 if (
const auto *OMPAttr = dyn_cast<OMPDeclareVariantAttr>(TmplAttr)) {
862 if (
const auto *ReqdWorkGroupSize =
863 dyn_cast<ReqdWorkGroupSizeAttr>(TmplAttr)) {
865 *ReqdWorkGroupSize,
New);
868 if (
const auto *AMDGPUFlatWorkGroupSize =
869 dyn_cast<AMDGPUFlatWorkGroupSizeAttr>(TmplAttr)) {
871 *
this, TemplateArgs, *AMDGPUFlatWorkGroupSize,
New);
874 if (
const auto *AMDGPUFlatWorkGroupSize =
875 dyn_cast<AMDGPUWavesPerEUAttr>(TmplAttr)) {
877 *AMDGPUFlatWorkGroupSize,
New);
880 if (
const auto *AMDGPUMaxNumWorkGroups =
881 dyn_cast<AMDGPUMaxNumWorkGroupsAttr>(TmplAttr)) {
883 *
this, TemplateArgs, *AMDGPUMaxNumWorkGroups,
New);
886 if (
const auto *ParamAttr = dyn_cast<HLSLParamModifierAttr>(TmplAttr)) {
892 if (
const auto *RoutineAttr = dyn_cast<OpenACCRoutineDeclAttr>(TmplAttr)) {
894 RoutineAttr, Tmpl,
New);
899 if (TmplAttr->getKind() == attr::DLLExport ||
900 TmplAttr->getKind() == attr::DLLImport) {
901 if (
New->hasAttr<DLLExportAttr>() ||
New->hasAttr<DLLImportAttr>()) {
906 if (
const auto *ABIAttr = dyn_cast<ParameterABIAttr>(TmplAttr)) {
911 if (isa<NSConsumedAttr>(TmplAttr) || isa<OSConsumedAttr>(TmplAttr) ||
912 isa<CFConsumedAttr>(TmplAttr)) {
919 if (
auto *A = dyn_cast<PointerAttr>(TmplAttr)) {
920 if (!
New->hasAttr<PointerAttr>())
925 if (
auto *A = dyn_cast<OwnerAttr>(TmplAttr)) {
926 if (!
New->hasAttr<OwnerAttr>())
931 if (
auto *A = dyn_cast<DeviceKernelAttr>(TmplAttr)) {
936 if (
auto *A = dyn_cast<CUDAGridConstantAttr>(TmplAttr)) {
937 if (!
New->hasAttr<CUDAGridConstantAttr>())
942 assert(!TmplAttr->isPackExpansion());
943 if (TmplAttr->isLateParsed() && LateAttrs) {
952 auto *ND = cast<NamedDecl>(
New);
953 auto *ThisContext = dyn_cast_or_null<CXXRecordDecl>(ND->getDeclContext());
955 ND->isCXXInstanceMember());
958 *
this, TemplateArgs);
960 New->addAttr(NewAttr);
966 for (
const auto *
Attr : Pattern->
attrs()) {
967 if (
auto *A = dyn_cast<StrictFPAttr>(
Attr)) {
968 if (!Inst->
hasAttr<StrictFPAttr>())
981 DLLExportAttr *
Attr = Ctor->
getAttr<DLLExportAttr>();
984 for (
unsigned I = 0; I != NumParams; ++I) {
995template<
typename DeclT>
1011 llvm_unreachable(
"Translation units cannot be instantiated");
1015 llvm_unreachable(
"HLSL buffer declarations cannot be instantiated");
1018Decl *TemplateDeclInstantiator::VisitHLSLRootSignatureDecl(
1020 llvm_unreachable(
"HLSL root signature declarations cannot be instantiated");
1025 llvm_unreachable(
"pragma comment cannot be instantiated");
1028Decl *TemplateDeclInstantiator::VisitPragmaDetectMismatchDecl(
1030 llvm_unreachable(
"pragma comment cannot be instantiated");
1035 llvm_unreachable(
"extern \"C\" context cannot be instantiated");
1039 llvm_unreachable(
"GUID declaration cannot be instantiated");
1042Decl *TemplateDeclInstantiator::VisitUnnamedGlobalConstantDecl(
1044 llvm_unreachable(
"UnnamedGlobalConstantDecl cannot be instantiated");
1047Decl *TemplateDeclInstantiator::VisitTemplateParamObjectDecl(
1049 llvm_unreachable(
"template parameter objects cannot be instantiated");
1053TemplateDeclInstantiator::VisitLabelDecl(
LabelDecl *
D) {
1055 D->getIdentifier());
1063 llvm_unreachable(
"Namespaces cannot be instantiated");
1067class OpenACCDeclClauseInstantiator final
1076 OpenACCDeclClauseInstantiator(
Sema &S,
1080 : SemaRef(S), MLTAL(MLTAL), ExistingClauses(ExistingClauses),
1081 ParsedClause(ParsedClause) {}
1084#define VISIT_CLAUSE(CLAUSE_NAME) \
1085 void Visit##CLAUSE_NAME##Clause(const OpenACC##CLAUSE_NAME##Clause &Clause);
1086#include "clang/Basic/OpenACCClauses.def"
1090 for (
Expr *CurVar : VarList) {
1091 ExprResult Res = SemaRef.SubstExpr(CurVar, MLTAL);
1100 InstantiatedVarList.push_back(Res.
get());
1102 return InstantiatedVarList;
1106#define CLAUSE_NOT_ON_DECLS(CLAUSE_NAME) \
1107 void OpenACCDeclClauseInstantiator::Visit##CLAUSE_NAME##Clause( \
1108 const OpenACC##CLAUSE_NAME##Clause &) { \
1109 llvm_unreachable("Clause type invalid on declaration construct, or " \
1110 "instantiation not implemented"); \
1139#undef CLAUSE_NOT_ON_DECLS
1141void OpenACCDeclClauseInstantiator::VisitGangClause(
1145 assert(
C.getNumExprs() <= 1 &&
1146 "Only 1 expression allowed on gang clause in routine");
1148 if (
C.getNumExprs() > 0) {
1150 "Only dim allowed on routine");
1152 SemaRef.SubstExpr(
const_cast<Expr *
>(
C.getExpr(0).second), MLTAL);
1154 ER = SemaRef.OpenACC().CheckGangExpr(ExistingClauses,
1156 C.getExpr(0).first, ER.
get());
1159 TransformedIntExprs.push_back(ER.
get());
1164 NewClause = SemaRef.OpenACC().CheckGangClause(
1167 TransformedGangKinds, TransformedIntExprs, ParsedClause.
getEndLoc());
1175void OpenACCDeclClauseInstantiator::VisitNoHostClause(
1182void OpenACCDeclClauseInstantiator::VisitDeviceTypeClause(
1186 SemaRef.getASTContext(),
C.getClauseKind(), ParsedClause.
getBeginLoc(),
1191void OpenACCDeclClauseInstantiator::VisitWorkerClause(
1193 assert(!
C.hasIntExpr() &&
"Int Expr not allowed on routine 'worker' clause");
1199void OpenACCDeclClauseInstantiator::VisitVectorClause(
1201 assert(!
C.hasIntExpr() &&
"Int Expr not allowed on routine 'vector' clause");
1207void OpenACCDeclClauseInstantiator::VisitCopyClause(
1210 C.getModifierList());
1211 if (SemaRef.OpenACC().CheckDeclareClause(ParsedClause,
C.getModifierList()))
1220void OpenACCDeclClauseInstantiator::VisitLinkClause(
1223 SemaRef.OpenACC().CheckLinkClauseVarList(VisitVarList(
C.getVarList())),
1226 if (SemaRef.OpenACC().CheckDeclareClause(ParsedClause,
1231 SemaRef.getASTContext(), ParsedClause.
getBeginLoc(),
1236void OpenACCDeclClauseInstantiator::VisitDeviceResidentClause(
1240 if (SemaRef.OpenACC().CheckDeclareClause(ParsedClause,
1244 SemaRef.getASTContext(), ParsedClause.
getBeginLoc(),
1249void OpenACCDeclClauseInstantiator::VisitCopyInClause(
1252 C.getModifierList());
1254 if (SemaRef.OpenACC().CheckDeclareClause(ParsedClause,
C.getModifierList()))
1262void OpenACCDeclClauseInstantiator::VisitCopyOutClause(
1265 C.getModifierList());
1267 if (SemaRef.OpenACC().CheckDeclareClause(ParsedClause,
C.getModifierList()))
1275void OpenACCDeclClauseInstantiator::VisitCreateClause(
1278 C.getModifierList());
1280 if (SemaRef.OpenACC().CheckDeclareClause(ParsedClause,
C.getModifierList()))
1288void OpenACCDeclClauseInstantiator::VisitPresentClause(
1292 if (SemaRef.OpenACC().CheckDeclareClause(ParsedClause,
1296 SemaRef.getASTContext(), ParsedClause.
getBeginLoc(),
1300void OpenACCDeclClauseInstantiator::VisitDevicePtrClause(
1304 llvm::erase_if(VarList, [&](
Expr *
E) {
1309 if (SemaRef.OpenACC().CheckDeclareClause(ParsedClause,
1313 SemaRef.getASTContext(), ParsedClause.
getBeginLoc(),
1318void OpenACCDeclClauseInstantiator::VisitBindClause(
1321 if (
C.isStringArgument())
1323 SemaRef.getASTContext(), ParsedClause.
getBeginLoc(),
1328 SemaRef.getASTContext(), ParsedClause.
getBeginLoc(),
1338 for (
const auto *Clause : ClauseList) {
1340 Clause->getBeginLoc());
1341 ParsedClause.
setEndLoc(Clause->getEndLoc());
1342 if (
const auto *WithParms = dyn_cast<OpenACCClauseWithParams>(Clause))
1345 OpenACCDeclClauseInstantiator Instantiator{S, MLTAL, TransformedClauses,
1347 Instantiator.Visit(Clause);
1348 if (Instantiator.CreatedClause())
1349 TransformedClauses.push_back(Instantiator.CreatedClause());
1351 return TransformedClauses;
1358 const OpenACCRoutineDeclAttr *OldAttr,
const Decl *OldDecl,
Decl *NewDecl) {
1359 OpenACCRoutineDeclAttr *A =
1360 OpenACCRoutineDeclAttr::Create(S.
getASTContext(), OldAttr->getLocation());
1362 if (!OldAttr->Clauses.empty()) {
1364 InstantiateOpenACCClauseList(
1366 A->Clauses.assign(TransformedClauses.begin(), TransformedClauses.end());
1378 InstantiateOpenACCClauseList(SemaRef, TemplateArgs,
D->getDirectiveKind(),
1382 D->getDirectiveKind(),
D->
getBeginLoc(), TransformedClauses))
1386 D->getDirectiveKind(),
D->
getBeginLoc(),
D->getDirectiveLoc(), {}, {},
1398 InstantiateOpenACCClauseList(SemaRef, TemplateArgs,
D->getDirectiveKind(),
1402 if (
D->getFunctionReference()) {
1403 FuncRef = SemaRef.
SubstCXXIdExpr(
D->getFunctionReference(), TemplateArgs);
1411 D->getDirectiveKind(),
D->
getBeginLoc(), TransformedClauses))
1416 D->getRParenLoc(), TransformedClauses,
D->
getEndLoc(),
nullptr);
1428 D->getNamespaceLoc(),
1431 D->getQualifierLoc(),
1432 D->getTargetNameLoc(),
1444 DI = SemaRef.
SubstType(DI, TemplateArgs,
1466 D->getIdentifier() &&
D->getIdentifier()->isStr(
"type") &&
1486 if (
const TagType *oldTagType =
D->getUnderlyingType()->getAs<
TagType>()) {
1487 TagDecl *oldTag = oldTagType->getOriginalDecl();
1506 Typedef->setPreviousDecl(InstPrevTypedef);
1557 if (getPreviousDeclForInstantiation<TypedefNameDecl>(Pattern)) {
1559 if (!
Found.empty()) {
1560 PrevAliasTemplate = dyn_cast<TypeAliasTemplateDecl>(
Found.front());
1571 D->getDeclName(), InstParams, AliasInst);
1573 if (PrevAliasTemplate)
1578 if (!PrevAliasTemplate)
1595 D->getIdentifier(),
D->getType());
1607 for (
auto *OldBD :
D->bindings()) {
1608 Expr *BindingExpr = OldBD->getBinding();
1609 if (isa_and_present<FunctionParmPackExpr>(BindingExpr)) {
1611 assert(!OldBindingPack &&
"no more than one pack is allowed");
1612 OldBindingPack = OldBD;
1614 NewBindings.push_back(cast<BindingDecl>(VisitBindingDecl(OldBD)));
1618 auto *NewDD = cast_if_present<DecompositionDecl>(
1621 if (!NewDD || NewDD->isInvalidDecl()) {
1622 for (
auto *NewBD : NewBindings)
1623 NewBD->setInvalidDecl();
1624 }
else if (OldBindingPack) {
1629 assert(NewBindingPack !=
nullptr &&
"new bindings should also have a pack");
1634 assert(OldDecls.size() == NewDecls.size());
1635 for (
unsigned I = 0; I < OldDecls.size(); I++)
1648 bool InstantiatingVarTemplate,
1653 D->getTypeSourceInfo(), TemplateArgs,
D->getTypeSpecStartLoc(),
1654 D->getDeclName(),
true);
1659 SemaRef.
Diag(
D->
getLocation(), diag::err_variable_instantiates_to_function)
1660 <<
D->isStaticDataMember() << DI->
getType();
1677 DI,
D->getStorageClass());
1692 StartingScope, InstantiatingVarTemplate);
1695 if (
auto *F = dyn_cast<FunctionDecl>(DC))
1696 RT = F->getReturnType();
1697 else if (isa<BlockDecl>(DC))
1701 llvm_unreachable(
"Unknown context type");
1736 D->getAccessSpecifierLoc(),
D->getColonLoc());
1746 DI = SemaRef.
SubstType(DI, TemplateArgs,
1749 DI =
D->getTypeSourceInfo();
1766 Expr *BitWidth =
D->getBitWidth();
1769 else if (BitWidth) {
1775 = SemaRef.
SubstExpr(BitWidth, TemplateArgs);
1780 BitWidth = InstantiatedBitWidth.
getAs<
Expr>();
1785 cast<RecordDecl>(Owner),
1789 D->getInClassInitStyle(),
1790 D->getInnerLocStart(),
1800 if (
Field->hasAttrs())
1804 Field->setInvalidDecl();
1811 if (
Parent->isAnonymousStructOrUnion() &&
1812 Parent->getRedeclContext()->isFunctionOrMethod())
1832 DI = SemaRef.
SubstType(DI, TemplateArgs,
1835 DI =
D->getTypeSourceInfo();
1873 for (
auto *PI :
D->chain()) {
1879 NamedChain[i++] = Next;
1882 QualType T = cast<FieldDecl>(NamedChain[i-1])->getType();
1885 {NamedChain, D->getChainingSize()});
1892 Owner->
addDecl(IndirectField);
1893 return IndirectField;
1905 if (
D->isUnsupportedFriend()) {
1908 if (
D->isPackExpansion()) {
1911 assert(!Unexpanded.empty() &&
"Pack expansion without packs");
1913 bool ShouldExpand =
true;
1914 bool RetainExpansion =
false;
1919 ShouldExpand, RetainExpansion, NumExpansions))
1922 assert(!RetainExpansion &&
1923 "should never retain an expansion for a variadic friend decl");
1927 for (
unsigned I = 0; I != *NumExpansions; I++) {
1936 TSI,
D->getFriendLoc());
1940 Decls.push_back(FD);
1963 assert(ND &&
"friend decl must be a decl or a type!");
1970 if (!NewND)
return nullptr;
1974 cast<NamedDecl>(NewND),
D->getFriendLoc());
1982 Expr *AssertExpr =
D->getAssertExpr();
1989 = SemaRef.
SubstExpr(AssertExpr, TemplateArgs);
1994 SemaRef.
SubstExpr(
D->getMessage(), TemplateArgs);
1995 if (InstantiatedMessageExpr.
isInvalid())
2000 InstantiatedMessageExpr.
get(),
D->getRParenLoc(),
D->isFailed());
2009 if (!Prev)
return nullptr;
2010 PrevDecl = cast<EnumDecl>(Prev);
2016 D->isScoped(),
D->isScopedUsingClassTag(),
D->isFixed());
2036 Enum->setIntegerTypeSourceInfo(NewTI);
2047 Enum->setPromotionType(
2052 assert(!
D->getIntegerType()->isDependentType()
2053 &&
"Dependent type without type source info");
2054 Enum->setIntegerType(
D->getIntegerType());
2076 if (Def && Def !=
D) {
2083 SemaRef.
SubstType(TI->getType(), TemplateArgs,
2086 DefnUnderlying,
true,
Enum);
2101 if (PrevDecl ==
nullptr) {
2112 Enum->startDefinition();
2123 if (
Expr *UninstValue = EC->getInitExpr()) {
2133 if (
Value.isInvalid()) {
2146 Enum->setInvalidDecl();
2153 Enum->addDecl(EnumConst);
2154 Enumerators.push_back(EnumConst);
2155 LastEnumConst = EnumConst;
2158 !
Enum->isScoped()) {
2171 llvm_unreachable(
"EnumConstantDecls can only occur within EnumDecls.");
2176 llvm_unreachable(
"BuiltinTemplateDecls cannot be instantiated.");
2208 if (!
Found.empty()) {
2209 PrevClassTemplate = dyn_cast<ClassTemplateDecl>(
Found.front());
2210 if (PrevClassTemplate)
2223 SS.
Adopt(QualifierLoc);
2225 if (!DC)
return nullptr;
2239 if (R.isSingleResult()) {
2241 if (PrevClassTemplate)
2245 if (!PrevClassTemplate && QualifierLoc) {
2247 <<
D->getTemplatedDecl()->getTagKind() << Pattern->
getDeclName() << DC
2264 D->getIdentifier(), InstParams, RecordInst);
2273 if (PrevClassTemplate) {
2302 if (!PrevClassTemplate)
2321 if (!PrevClassTemplate) {
2326 D->getPartialSpecializations(PartialSpecs);
2327 for (
unsigned I = 0, N = PartialSpecs.size(); I != N; ++I)
2328 if (PartialSpecs[I]->getFirstDecl()->isOutOfLine())
2329 OutOfLinePartialSpecs.push_back(std::make_pair(Inst, PartialSpecs[I]));
2336TemplateDeclInstantiator::VisitClassTemplatePartialSpecializationDecl(
2348 = dyn_cast<ClassTemplateDecl>(
Found.front());
2349 if (!InstClassTemplate)
2360 assert(
D->getTemplatedDecl()->isStaticDataMember() &&
2361 "Only static data member templates are allowed.");
2371 VarDecl *Pattern =
D->getTemplatedDecl();
2377 PrevVarTemplate = dyn_cast<VarTemplateDecl>(
Found.front());
2383 if (!VarInst)
return nullptr;
2394 if (!PrevVarTemplate)
2404 if (!PrevVarTemplate) {
2409 D->getPartialSpecializations(PartialSpecs);
2410 for (
unsigned I = 0, N = PartialSpecs.size(); I != N; ++I)
2411 if (PartialSpecs[I]->getFirstDecl()->isOutOfLine())
2412 OutOfLineVarPartialSpecs.push_back(
2413 std::make_pair(Inst, PartialSpecs[I]));
2419Decl *TemplateDeclInstantiator::VisitVarTemplatePartialSpecializationDecl(
2421 assert(
D->isStaticDataMember() &&
2422 "Only static data member templates are allowed.");
2428 assert(!
Found.empty() &&
"Instantiation found nothing?");
2431 assert(InstVarTemplate &&
"Instantiation did not find a variable template?");
2455 if (
CXXMethodDecl *DMethod = dyn_cast<CXXMethodDecl>(
D->getTemplatedDecl()))
2460 D->getTemplatedDecl(),
2471 assert(InstTemplate &&
2472 "VisitFunctionDecl/CXXMethodDecl didn't create a template!");
2479 !(isFriend && !
D->getTemplatedDecl()->isThisDeclarationADefinition()))
2490 return InstTemplate;
2499 if (!Prev)
return nullptr;
2500 PrevDecl = cast<CXXRecordDecl>(Prev);
2504 bool IsInjectedClassName =
D->isInjectedClassName();
2508 D->getLambdaDependencyKind(),
D->isGenericLambda(),
2509 D->getLambdaCaptureDefault());
2513 D->getIdentifier(), PrevDecl);
2529 if (!IsInjectedClassName)
2535 Record->setObjectOfFriendDecl();
2538 if (
D->isAnonymousStructOrUnion())
2539 Record->setAnonymousStructOrUnion(
true);
2541 if (
D->isLocalClass())
2562 if (
D->isCompleteDefinition() &&
D->isLocalClass()) {
2572 if (!
D->isCXXClassMember())
2578 LocalInstantiations.perform();
2583 if (IsInjectedClassName)
2584 assert(
Record->isInjectedClassName() &&
"Broken injected-class-name");
2602 if (OrigFunc->
getExtInfo() == NewFunc->getExtInfo())
2608 NewFunc->getParamTypes(), NewEPI);
2632 if (isFriend && Source->wasThisDeclarationADefinition(
D)) {
2644 void *InsertPos =
nullptr;
2653 bool MergeWithParentScope = (TemplateParams !=
nullptr) ||
2655 !(isa<Decl>(Owner) &&
2656 cast<Decl>(Owner)->isDefinedOutsideFunctionOrMethod());
2660 if (
auto *DGuide = dyn_cast<CXXDeductionGuideDecl>(
D)) {
2662 TemplateArgs, DGuide->getExplicitSpecifier());
2663 if (InstantiatedExplicitSpecifier.
isInvalid())
2673 if (TemplateParams && TemplateParams->
size()) {
2675 dyn_cast<TemplateTypeParmDecl>(TemplateParams->
asArray().back());
2676 if (LastParam && LastParam->isImplicit() &&
2677 LastParam->hasTypeConstraint()) {
2707 }
else if (isFriend && QualifierLoc) {
2709 SS.
Adopt(QualifierLoc);
2711 if (!DC)
return nullptr;
2724 if (
auto *DGuide = dyn_cast<CXXDeductionGuideDecl>(
D)) {
2726 SemaRef.
Context, DC,
D->getInnerLocStart(),
2727 InstantiatedExplicitSpecifier, NameInfo,
T, TInfo,
2729 DGuide->getDeductionCandidateKind(), TrailingRequiresClause,
2730 DGuide->getSourceDeductionGuide(),
2731 DGuide->getSourceDeductionGuideKind());
2735 SemaRef.
Context, DC,
D->getInnerLocStart(), NameInfo,
T, TInfo,
2737 D->isInlineSpecified(),
D->hasWrittenPrototype(),
D->getConstexprKind(),
2738 TrailingRequiresClause);
2739 Function->setFriendConstraintRefersToEnclosingTemplate(
2740 D->FriendConstraintRefersToEnclosingTemplate());
2748 Function->setQualifierInfo(QualifierLoc);
2762 Function->setIsDestroyingOperatorDelete(
D->isDestroyingOperatorDelete());
2763 Function->setIsTypeAwareOperatorNewOrDelete(
2764 D->isTypeAwareOperatorNewOrDelete());
2765 Function->setLexicalDeclContext(LexicalDC);
2768 for (
unsigned P = 0;
P < Params.size(); ++
P)
2773 if (TrailingRequiresClause)
2774 Function->setTrailingRequiresClause(TrailingRequiresClause);
2776 if (TemplateParams) {
2799 if (isFriend &&
D->isThisDeclarationADefinition()) {
2801 D->getDescribedFunctionTemplate());
2813 if (isFriend &&
D->isThisDeclarationADefinition()) {
2818 }
else if (!isFriend) {
2829 FT->setObjectOfFriendDecl();
2835 bool IsExplicitSpecialization =
false;
2845 D->getDependentSpecializationInfo()) {
2846 assert(isFriend &&
"dependent specialization info on "
2847 "non-member non-friend function?");
2851 if (
const auto *ArgsWritten = DFTSI->TemplateArgumentsAsWritten) {
2852 ExplicitArgs.
setLAngleLoc(ArgsWritten->getLAngleLoc());
2853 ExplicitArgs.
setRAngleLoc(ArgsWritten->getRAngleLoc());
2870 DFTSI->TemplateArgumentsAsWritten ? &ExplicitArgs :
nullptr,
2874 IsExplicitSpecialization =
true;
2876 D->getTemplateSpecializationArgsAsWritten()) {
2882 ArgsWritten->getRAngleLoc());
2892 IsExplicitSpecialization =
true;
2909 if (isFriend && !QualifierLoc) {
2929 if (
Function->isLocalExternDecl()) {
2931 if (!PVD->hasDefaultArg())
2937 Expr *UninstExpr = PVD->getUninstantiatedDefaultArg();
2940 { UninstExpr }, UninstExpr->
getType());
2942 PVD->setDefaultArg(ErrorResult.
get());
2948 IsExplicitSpecialization,
2949 Function->isThisDeclarationADefinition());
2959 Function->isThisDeclarationADefinition()
2968 if (isFriend &&
D->isThisDeclarationADefinition() &&
Function->isUsed(
false)) {
2970 Function->getMemberSpecializationInfo()) {
2971 if (MSInfo->getPointOfInstantiation().isInvalid()) {
2973 MSInfo->setPointOfInstantiation(
Loc);
2979 if (
D->isExplicitlyDefaulted()) {
3012 void *InsertPos =
nullptr;
3027 bool MergeWithParentScope = (TemplateParams !=
nullptr) ||
3028 !(isa<Decl>(Owner) &&
3029 cast<Decl>(Owner)->isDefinedOutsideFunctionOrMethod());
3033 SemaRef,
D, TemplateArgs,
Scope);
3037 unsigned NumTempParamLists = 0;
3038 if (isFriend && (NumTempParamLists =
D->getNumTemplateParameterLists())) {
3039 TempParamLists.resize(NumTempParamLists);
3040 for (
unsigned I = 0; I != NumTempParamLists; ++I) {
3045 TempParamLists[I] = InstParams;
3051 const bool CouldInstantiate =
3052 InstantiatedExplicitSpecifier.getExpr() ==
nullptr ||
3053 !InstantiatedExplicitSpecifier.getExpr()->isValueDependent();
3057 if (CouldInstantiate ||
3061 TemplateArgs, InstantiatedExplicitSpecifier);
3063 if (InstantiatedExplicitSpecifier.isInvalid())
3076 isa<CXXConstructorDecl, CXXDestructorDecl>(
D)) {
3079 D->setTypeSourceInfo(TSI);
3088 if (TemplateParams && TemplateParams->
size()) {
3090 dyn_cast<TemplateTypeParmDecl>(TemplateParams->
asArray().back());
3091 if (LastParam && LastParam->isImplicit() &&
3092 LastParam->hasTypeConstraint()) {
3117 SS.
Adopt(QualifierLoc);
3127 if (!DC)
return nullptr;
3146 InstantiatedExplicitSpecifier,
Constructor->UsesFPIntrin(),
3149 TrailingRequiresClause);
3155 Destructor->getConstexprKind(), TrailingRequiresClause);
3156 Method->setIneligibleOrNotSelected(
true);
3164 Conversion->UsesFPIntrin(), Conversion->isInlineSpecified(),
3165 InstantiatedExplicitSpecifier, Conversion->getConstexprKind(),
3166 Conversion->getEndLoc(), TrailingRequiresClause);
3171 D->UsesFPIntrin(),
D->isInlineSpecified(),
D->getConstexprKind(),
3176 Method->setImplicitlyInline();
3179 Method->setQualifierInfo(QualifierLoc);
3181 if (TemplateParams) {
3221 if (NumTempParamLists)
3222 Method->setTemplateParameterListsInfo(
3226 Method->setLexicalDeclContext(Owner);
3227 Method->setObjectOfFriendDecl();
3232 for (
unsigned P = 0;
P < Params.size(); ++
P)
3233 Params[
P]->setOwningFunction(
Method);
3234 Method->setParams(Params);
3237 Method->setInvalidDecl();
3240 RedeclarationKind::ForExternalRedeclaration);
3242 bool IsExplicitSpecialization =
false;
3247 D->getDependentSpecializationInfo()) {
3250 if (
const auto *ArgsWritten = DFTSI->TemplateArgumentsAsWritten) {
3251 ExplicitArgs.
setLAngleLoc(ArgsWritten->getLAngleLoc());
3252 ExplicitArgs.
setRAngleLoc(ArgsWritten->getRAngleLoc());
3268 Method, DFTSI->TemplateArgumentsAsWritten ? &ExplicitArgs :
nullptr,
3270 Method->setInvalidDecl();
3272 IsExplicitSpecialization =
true;
3274 D->getTemplateSpecializationArgsAsWritten()) {
3278 ArgsWritten->getRAngleLoc());
3287 Method->setInvalidDecl();
3289 IsExplicitSpecialization =
true;
3317 for (
unsigned P = 0;
P < Params.size(); ++
P) {
3318 if (!Params[
P]->hasDefaultArg())
3324 Expr *UninstExpr = Params[
P]->getUninstantiatedDefaultArg();
3327 { UninstExpr }, UninstExpr->
getType());
3329 Params[
P]->setDefaultArg(ErrorResult.
get());
3335 IsExplicitSpecialization,
3336 Method->isThisDeclarationADefinition());
3338 if (
D->isPureVirtual())
3344 if (isFriend &&
Method->getPreviousDecl())
3345 Method->setAccess(
Method->getPreviousDecl()->getAccess());
3354 if (
D->isExplicitlyDefaulted()) {
3358 if (
D->isDeletedAsWritten())
3360 D->getDeletedMessage());
3365 if (IsExplicitSpecialization && !isFriend)
3378 Method->setIneligibleOrNotSelected(
true);
3379 }
else if (
Method->isCopyAssignmentOperator() ||
3380 Method->isMoveAssignmentOperator()) {
3381 Method->setIneligibleOrNotSelected(
true);
3393 }
else if (isFriend) {
3410 if (
Method->hasAttr<UsedAttr>()) {
3411 if (
const auto *A = dyn_cast<CXXRecordDecl>(Owner)) {
3414 A->getMemberSpecializationInfo())
3415 Loc = MSInfo->getPointOfInstantiation();
3416 else if (
const auto *Spec = dyn_cast<ClassTemplateSpecializationDecl>(A))
3417 Loc = Spec->getPointOfInstantiation();
3443Decl *TemplateDeclInstantiator::VisitTemplateTypeParmDecl(
3445 assert(
D->getTypeForDecl()->isTemplateTypeParmType());
3450 if (
D->isPackExpansion() && !
D->getNumExpansionParameters()) {
3451 assert(TC->getTemplateArgsAsWritten() &&
3452 "type parameter can only be an expansion when explicit arguments "
3458 for (
auto &ArgLoc : TC->getTemplateArgsAsWritten()->arguments())
3464 bool RetainExpansion =
false;
3466 cast<CXXFoldExpr>(TC->getImmediatelyDeclaredConstraint())
3469 TC->hasExplicitTemplateArgs()
3470 ? TC->getTemplateArgsAsWritten()->getRAngleLoc()
3471 : TC->getConceptNameInfo().getEndLoc()),
3472 Unexpanded, TemplateArgs,
true,
3473 Expand, RetainExpansion, NumExpanded))
3482 D->hasTypeConstraint(), NumExpanded);
3486 if (
auto *TC =
D->getTypeConstraint()) {
3492 EvaluateConstraints))
3496 if (
D->hasDefaultArgument() && !
D->defaultArgumentWasInherited()) {
3510Decl *TemplateDeclInstantiator::VisitNonTypeTemplateParmDecl(
3513 TypeLoc TL =
D->getTypeSourceInfo()->getTypeLoc();
3516 bool IsExpandedParameterPack =
false;
3521 if (
D->isExpandedParameterPack()) {
3524 ExpandedParameterPackTypes.reserve(
D->getNumExpansionTypes());
3525 ExpandedParameterPackTypesAsWritten.reserve(
D->getNumExpansionTypes());
3526 for (
unsigned I = 0, N =
D->getNumExpansionTypes(); I != N; ++I) {
3528 SemaRef.
SubstType(
D->getExpansionTypeSourceInfo(I), TemplateArgs,
3538 ExpandedParameterPackTypesAsWritten.push_back(NewDI);
3539 ExpandedParameterPackTypes.push_back(NewT);
3542 IsExpandedParameterPack =
true;
3543 DI =
D->getTypeSourceInfo();
3545 }
else if (
D->isPackExpansion()) {
3557 bool RetainExpansion =
false;
3562 Expansion.
getEllipsisLoc(), Pattern.getSourceRange(), Unexpanded,
3563 TemplateArgs,
true, Expand,
3564 RetainExpansion, NumExpansions))
3568 for (
unsigned I = 0; I != *NumExpansions; ++I) {
3581 ExpandedParameterPackTypesAsWritten.push_back(NewDI);
3582 ExpandedParameterPackTypes.push_back(NewT);
3588 IsExpandedParameterPack =
true;
3589 DI =
D->getTypeSourceInfo();
3611 DI = SemaRef.
SubstType(
D->getTypeSourceInfo(), TemplateArgs,
3625 if (IsExpandedParameterPack)
3629 D->getPosition(),
D->getIdentifier(),
T, DI, ExpandedParameterPackTypes,
3630 ExpandedParameterPackTypesAsWritten);
3638 if (AutoLoc.isConstrained()) {
3640 if (IsExpandedParameterPack)
3643 else if (
auto *Constraint = dyn_cast_if_present<CXXFoldExpr>(
3644 D->getPlaceholderTypeConstraint()))
3645 EllipsisLoc = Constraint->getEllipsisLoc();
3659 if (
D->hasDefaultArgument() && !
D->defaultArgumentWasInherited()) {
3678 for (
const auto &
P : *Params) {
3679 if (
P->isTemplateParameterPack())
3691TemplateDeclInstantiator::VisitTemplateTemplateParmDecl(
3698 bool IsExpandedParameterPack =
false;
3700 if (
D->isExpandedParameterPack()) {
3704 ExpandedParams.reserve(
D->getNumExpansionTemplateParameters());
3705 for (
unsigned I = 0, N =
D->getNumExpansionTemplateParameters();
3712 ExpandedParams.push_back(Expansion);
3715 IsExpandedParameterPack =
true;
3716 InstParams = TempParams;
3717 }
else if (
D->isPackExpansion()) {
3728 bool RetainExpansion =
false;
3732 TemplateArgs,
true, Expand,
3733 RetainExpansion, NumExpansions))
3737 for (
unsigned I = 0; I != *NumExpansions; ++I) {
3743 ExpandedParams.push_back(Expansion);
3749 IsExpandedParameterPack =
true;
3750 InstParams = TempParams;
3772 if (IsExpandedParameterPack)
3776 D->getPosition(),
D->getIdentifier(),
D->templateParameterKind(),
3777 D->wasDeclaredWithTypename(), InstParams, ExpandedParams);
3783 D->templateParameterKind(),
D->wasDeclaredWithTypename(), InstParams);
3784 if (
D->hasDefaultArgument() && !
D->defaultArgumentWasInherited()) {
3814 D->getNamespaceKeyLocation(),
3815 D->getQualifierLoc(),
3816 D->getIdentLocation(),
3817 D->getNominatedNamespace(),
3818 D->getCommonAncestor());
3834 for (
auto *Shadow :
D->shadows()) {
3838 NamedDecl *OldTarget = Shadow->getTargetDecl();
3839 if (
auto *CUSD = dyn_cast<ConstructorUsingShadowDecl>(Shadow))
3840 if (
auto *BaseShadow = CUSD->getNominatedBaseClassShadowDecl())
3841 OldTarget = BaseShadow;
3845 dyn_cast<UnresolvedUsingIfExistsDecl>(Shadow->getTargetDecl())) {
3847 SemaRef.
Context, Owner, EmptyD->getLocation(), EmptyD->getDeclName());
3850 Shadow->getLocation(), OldTarget, TemplateArgs));
3862 Shadow->getLocation(), OldPrev, TemplateArgs));
3865 nullptr, Inst, InstTarget, PrevDecl);
3868 if (isFunctionScope)
3896 if (
auto *RD = dyn_cast<CXXRecordDecl>(SemaRef.
CurContext))
3902 bool CheckRedeclaration = Owner->
isRecord();
3904 RedeclarationKind::ForVisibleRedeclaration);
3913 SS.
Adopt(QualifierLoc);
3914 if (CheckRedeclaration) {
3915 Prev.setHideTags(
false);
3920 D->hasTypename(), SS,
3984Decl *TemplateDeclInstantiator::VisitConstructorUsingShadowDecl(
3990template <
typename T>
3991Decl *TemplateDeclInstantiator::instantiateUnresolvedUsingDecl(
3992 T *
D,
bool InstantiatingPackElement) {
3994 if (
D->isPackExpansion() && !InstantiatingPackElement) {
4002 bool RetainExpansion =
false;
4006 true, Expand, RetainExpansion,
4012 assert(!RetainExpansion &&
4013 "should never need to retain an expansion for UsingPackDecl");
4019 return instantiateUnresolvedUsingDecl(
D,
true);
4030 SemaRef.
Diag(
D->getEllipsisLoc(),
4031 diag::err_using_decl_redeclaration_expansion);
4037 for (
unsigned I = 0; I != *NumExpansions; ++I) {
4039 Decl *Slice = instantiateUnresolvedUsingDecl(
D,
true);
4046 Expansions.push_back(cast<NamedDecl>(Slice));
4065 SS.
Adopt(QualifierLoc);
4072 bool InstantiatingSlice =
4077 bool IsUsingIfExists =
D->template hasAttr<UsingIfExistsAttr>();
4080 TD, TypenameLoc, SS, NameInfo, EllipsisLoc,
4082 true, IsUsingIfExists);
4091Decl *TemplateDeclInstantiator::VisitUnresolvedUsingTypenameDecl(
4093 return instantiateUnresolvedUsingDecl(
D);
4096Decl *TemplateDeclInstantiator::VisitUnresolvedUsingValueDecl(
4098 return instantiateUnresolvedUsingDecl(
D);
4101Decl *TemplateDeclInstantiator::VisitUnresolvedUsingIfExistsDecl(
4103 llvm_unreachable(
"referring to unresolved decl out of UsingShadowDecl");
4108 for (
auto *UD :
D->expansions()) {
4111 Expansions.push_back(NewUD);
4122Decl *TemplateDeclInstantiator::VisitOMPThreadPrivateDecl(
4125 for (
auto *I :
D->varlist()) {
4127 assert(isa<DeclRefExpr>(Var) &&
"threadprivate arg is not a DeclRefExpr");
4128 Vars.push_back(Var);
4142 for (
auto *I :
D->varlist()) {
4144 assert(isa<DeclRefExpr>(Var) &&
"allocate arg is not a DeclRefExpr");
4145 Vars.push_back(Var);
4151 if (
auto *AC = dyn_cast<OMPAllocatorClause>(
C)) {
4156 NewE.
get(), AC->getBeginLoc(), AC->getLParenLoc(), AC->getEndLoc());
4157 }
else if (
auto *AC = dyn_cast<OMPAlignClause>(
C)) {
4162 NewE.
get(), AC->getBeginLoc(), AC->getLParenLoc(), AC->getEndLoc());
4167 Clauses.push_back(IC);
4172 if (Res.
get().isNull())
4174 return Res.
get().getSingleDecl();
4179 "Requires directive cannot be instantiated within a dependent context");
4182Decl *TemplateDeclInstantiator::VisitOMPDeclareReductionDecl(
4185 const bool RequiresInstantiation =
4186 D->getType()->isDependentType() ||
4187 D->getType()->isInstantiationDependentType() ||
4188 D->getType()->containsUnexpandedParameterPack();
4190 if (RequiresInstantiation) {
4196 SubstReductionType =
D->getType();
4198 if (SubstReductionType.
isNull())
4200 Expr *Combiner =
D->getCombiner();
4202 bool IsCorrect =
true;
4204 std::pair<QualType, SourceLocation> ReductionTypes[] = {
4206 auto *PrevDeclInScope =
D->getPrevDeclInScope();
4207 if (PrevDeclInScope && !PrevDeclInScope->isInvalidDecl()) {
4208 PrevDeclInScope = cast<OMPDeclareReductionDecl>(
4213 nullptr, Owner,
D->getDeclName(), ReductionTypes,
D->
getAccess(),
4215 auto *NewDRD = cast<OMPDeclareReductionDecl>(DRD.get().getSingleDecl());
4217 Expr *SubstCombiner =
nullptr;
4218 Expr *SubstInitializer =
nullptr;
4224 cast<DeclRefExpr>(
D->getCombinerIn())->getDecl(),
4225 cast<DeclRefExpr>(NewDRD->getCombinerIn())->getDecl());
4227 cast<DeclRefExpr>(
D->getCombinerOut())->getDecl(),
4228 cast<DeclRefExpr>(NewDRD->getCombinerOut())->getDecl());
4229 auto *ThisContext = dyn_cast_or_null<CXXRecordDecl>(Owner);
4232 SubstCombiner = SemaRef.
SubstExpr(Combiner, TemplateArgs).
get();
4242 cast<DeclRefExpr>(
D->getInitOrig())->getDecl(),
4243 cast<DeclRefExpr>(NewDRD->getInitOrig())->getDecl());
4245 cast<DeclRefExpr>(
D->getInitPriv())->getDecl(),
4246 cast<DeclRefExpr>(NewDRD->getInitPriv())->getDecl());
4251 cast<VarDecl>(cast<DeclRefExpr>(
D->getInitPriv())->getDecl());
4252 IsCorrect = IsCorrect && OldPrivParm->hasInit();
4258 NewDRD, SubstInitializer, OmpPrivParm);
4260 IsCorrect = IsCorrect && SubstCombiner &&
4263 SubstInitializer) ||
4265 !SubstInitializer));
4276 const bool RequiresInstantiation =
4277 D->getType()->isDependentType() ||
4278 D->getType()->isInstantiationDependentType() ||
4279 D->getType()->containsUnexpandedParameterPack();
4282 if (RequiresInstantiation) {
4288 SubstMapperTy =
D->getType();
4290 if (SubstMapperTy.
isNull())
4293 auto *PrevDeclInScope =
D->getPrevDeclInScope();
4294 if (PrevDeclInScope && !PrevDeclInScope->isInvalidDecl()) {
4295 PrevDeclInScope = cast<OMPDeclareMapperDecl>(
4299 bool IsCorrect =
true;
4305 (*
D->clauselist_begin())->getBeginLoc());
4310 cast<DeclRefExpr>(
D->getMapperVarRef())->getDecl(),
4311 cast<DeclRefExpr>(MapperVarRef.
get())->getDecl());
4312 auto *ThisContext = dyn_cast_or_null<CXXRecordDecl>(Owner);
4317 auto *OldC = cast<OMPMapClause>(
C);
4319 for (
Expr *OE : OldC->varlist()) {
4325 NewVars.push_back(NE);
4333 SS.
Adopt(NewQualifierLoc);
4339 OldC->getIteratorModifier(), OldC->getMapTypeModifiers(),
4340 OldC->getMapTypeModifiersLoc(), SS, NewNameInfo, OldC->getMapType(),
4341 OldC->isImplicitMapType(), OldC->getMapLoc(), OldC->getColonLoc(),
4343 Clauses.push_back(NewC);
4349 nullptr, Owner,
D->getDeclName(), SubstMapperTy,
D->
getLocation(),
4350 VN,
D->
getAccess(), MapperVarRef.
get(), Clauses, PrevDeclInScope);
4351 Decl *NewDMD = DG.
get().getSingleDecl();
4356Decl *TemplateDeclInstantiator::VisitOMPCapturedExprDecl(
4358 llvm_unreachable(
"Should not be met in templates");
4368 if (Inst && !
D->getDescribedFunctionTemplate())
4378 llvm_unreachable(
"There are only CXXRecordDecls in C++");
4382TemplateDeclInstantiator::VisitClassTemplateSpecializationDecl(
4389 "can only instantiate an explicit specialization "
4390 "for a member class template");
4397 if (!InstClassTemplate)
4404 D->getTemplateArgsAsWritten()) {
4405 InstTemplateArgs.
setLAngleLoc(TemplateArgsInfo->getLAngleLoc());
4406 InstTemplateArgs.
setRAngleLoc(TemplateArgsInfo->getRAngleLoc());
4409 TemplateArgs, InstTemplateArgs))
4424 void *InsertPos =
nullptr;
4433 D->getSpecializationKind(),
4453 D->isThisDeclarationADefinition()) {
4456 diag::note_previous_definition);
4489 if (
D->isThisDeclarationADefinition() &&
4504 "A template specialization without specialized template?");
4509 if (!InstVarTemplate)
4514 D->getTemplateArgsAsWritten()) {
4515 VarTemplateArgsInfo.
setLAngleLoc(TemplateArgsInfo->getLAngleLoc());
4516 VarTemplateArgsInfo.
setRAngleLoc(TemplateArgsInfo->getRAngleLoc());
4519 TemplateArgs, VarTemplateArgsInfo))
4526 InstVarTemplate,
D->
getLocation(), VarTemplateArgsInfo,
4532 void *InsertPos =
nullptr;
4546 VarTemplateArgsInfo,
4558 SemaRef.
SubstType(
D->getTypeSourceInfo(), TemplateArgs,
4559 D->getTypeSpecStartLoc(),
D->getDeclName());
4564 SemaRef.
Diag(
D->
getLocation(), diag::err_variable_instantiates_to_function)
4565 <<
D->isStaticDataMember() << DI->
getType();
4575 void *InsertPos =
nullptr;
4576 VarTemplate->findSpecialization(Converted, InsertPos);
4588 StartingScope,
false, PrevDecl);
4594 llvm_unreachable(
"@defs is not supported in Objective-C++");
4601 "cannot instantiate %0 yet");
4609 llvm_unreachable(
"Concept definitions cannot reside inside a template");
4612Decl *TemplateDeclInstantiator::VisitImplicitConceptSpecializationDecl(
4614 llvm_unreachable(
"Concept specializations cannot reside inside a template");
4624 llvm_unreachable(
"Unexpected decl");
4635 SubstD = Instantiator.Visit(D);
4650 SemaRef.
Context.
BoolTy, FPT->getParamTypes(), FPT->getExtProtoInfo());
4661 assert(OldLoc &&
"type of function is not a function type?");
4663 for (
unsigned I = 0, N = OldLoc.getNumParams(); I != N; ++I)
4664 NewLoc.
setParam(I, OldLoc.getParam(I));
4674 if (Spaceship->isInvalidDecl())
4686 if (
auto *MD = dyn_cast<CXXMethodDecl>(Spaceship)) {
4691 assert(Spaceship->getFriendObjectKind() &&
4692 "defaulted spaceship is neither a member nor a friend");
4702 cast<NamedDecl>(R), Spaceship->getBeginLoc());
4706 return cast_or_null<FunctionDecl>(R);
4720 unsigned N = L->
size();
4724 for (
auto &
P : *L) {
4726 Params.push_back(
D);
4746 bool EvaluateConstraints) {
4793 ClassTemplate, PartialSpec->
getLocation(), InstTemplateArgs,
4806 void *InsertPos =
nullptr;
4809 InstParams, InsertPos);
4845 diag::err_partial_spec_redeclared)
4847 SemaRef.
Diag(PrevDecl->
getLocation(), diag::note_prev_partial_spec_here)
4859 return InstPartialSpec;
4903 InstTemplateArgs, {},
4915 void *InsertPos =
nullptr;
4918 InstParams, InsertPos);
4929 diag::err_variable_instantiates_to_function)
4966 diag::err_var_partial_spec_redeclared)
4969 diag::note_var_prev_partial_spec_here);
4977 VarTemplate->AddPartialSpecialization(InstPartialSpec,
nullptr);
4980 LateAttrs, Owner, StartingScope);
4982 return InstPartialSpec;
4989 assert(OldTInfo &&
"substituting function without type source info");
4990 assert(Params.empty() &&
"parameter vector is non-empty at start");
4995 ThisContext = cast<CXXRecordDecl>(Owner);
4996 ThisTypeQuals =
Method->getFunctionObjectParameterType().getQualifiers();
5000 OldTInfo, TemplateArgs,
D->getTypeSpecStartLoc(),
D->getDeclName(),
5001 ThisContext, ThisTypeQuals, EvaluateConstraints);
5007 if (NewTInfo != OldTInfo) {
5011 unsigned NewIdx = 0;
5012 for (
unsigned OldIdx = 0, NumOldParams = OldProtoLoc.getNumParams();
5013 OldIdx != NumOldParams; ++OldIdx) {
5014 ParmVarDecl *OldParam = OldProtoLoc.getParam(OldIdx);
5022 NumArgumentsInExpansion =
5025 if (!NumArgumentsInExpansion) {
5029 Params.push_back(NewParam);
5030 Scope->InstantiatedLocal(OldParam, NewParam);
5033 Scope->MakeInstantiatedLocalArgPack(OldParam);
5034 for (
unsigned I = 0; I != *NumArgumentsInExpansion; ++I) {
5036 Params.push_back(NewParam);
5037 Scope->InstantiatedLocalPackArg(OldParam, NewParam);
5046 cast<FunctionProtoType>(OldProtoLoc.getType());
5047 for (
unsigned i = 0, i_end = OldProtoLoc.getNumParams(); i != i_end;
5057 cast_or_null<ParmVarDecl>(VisitParmVarDecl(OldParam));
5060 Params.push_back(Parm);
5077 TemplateArgs, ParamTypes, &Params,
5090 for (
auto *
decl : PatternDecl->
decls()) {
5091 if (!isa<VarDecl>(
decl) || isa<ParmVarDecl>(
decl))
5097 auto it = llvm::find_if(
Function->decls(), [&](
Decl *inst) {
5098 VarDecl *InstVD = dyn_cast<VarDecl>(inst);
5099 return InstVD && InstVD->isLocalVarDecl() &&
5100 InstVD->getIdentifier() == II;
5106 Scope.InstantiatedLocal(VD, *it);
5107 LSI->
addCapture(cast<VarDecl>(*it),
false,
false,
5113bool Sema::addInstantiatedParametersToScope(
5117 unsigned FParamIdx = 0;
5118 for (
unsigned I = 0, N = PatternDecl->
getNumParams(); I != N; ++I) {
5122 assert(FParamIdx < Function->getNumParams());
5146 Scope.MakeInstantiatedLocalArgPack(PatternParam);
5149 if (NumArgumentsInExpansion) {
5152 for (
unsigned Arg = 0; Arg < *NumArgumentsInExpansion; ++Arg) {
5208 false, std::nullopt,
5217 L->DefaultArgumentInstantiated(Param);
5239 Diag(PointOfInstantiation, diag::err_exception_spec_cycle) <<
Decl;
5251 false, std::nullopt,
5299 if (ActiveInst.Kind == ActiveInstType::ExplicitTemplateArgumentSubstitution ||
5300 ActiveInst.Kind == ActiveInstType::DeducedTemplateArgumentSubstitution) {
5301 if (isa<FunctionTemplateDecl>(ActiveInst.Entity)) {
5303 {ActiveInst.Entity->getCanonicalDecl(), ActiveInst.Kind});
5305 ActiveInst.Kind = ActiveInstType::TemplateInstantiation;
5306 ActiveInst.Entity =
New;
5312 assert(Proto &&
"Function template without prototype?");
5336 assert(NewProto &&
"Template instantiation without function prototype?");
5354 LateAttrs, StartingScope);
5370 if (isa<CXXDestructorDecl>(
New) && SemaRef.
getLangOpts().CPlusPlus11)
5375 New->setVirtualAsWritten(
true);
5386 Lookups.reserve(DFI->getUnqualifiedLookups().size());
5387 bool AnyChanged =
false;
5390 DA.getDecl(), TemplateArgs);
5393 AnyChanged |= (
D != DA.getDecl());
5399 New->setDefaultedOrDeletedInfo(
5429 bool DefinitionRequired,
5437 Function->getTemplateSpecializationKindForInstantiation();
5444 !DefinitionRequired)
5449 if (
Function->isDefined(ExistingDefn,
5463 assert(PatternDecl &&
"instantiating a non-template");
5466 Stmt *Pattern =
nullptr;
5468 Pattern = PatternDef->
getBody(PatternDef);
5469 PatternDecl = PatternDef;
5471 PatternDef =
nullptr;
5475 bool Unreachable =
false;
5480 Function->getInstantiatedFromMemberFunction(), PatternDecl,
5482 DefinitionRequired, &Unreachable)) {
5483 if (DefinitionRequired)
5486 (
Function->isConstexpr() && !Recursive)) {
5490 Function->setInstantiationIsPending(
true);
5493 if (llvm::isTimeTraceVerbose()) {
5494 llvm::timeTraceAddInstantEvent(
"DeferInstantiation", [&] {
5496 llvm::raw_string_ostream
OS(Name);
5505 Diag(PointOfInstantiation, diag::warn_func_template_missing)
5511 diag::note_unreachable_template_decl);
5515 Diag(PointOfInstantiation, diag::note_inst_declaration_hint)
5527 Function->setInstantiationIsPending(
true);
5529 std::make_pair(
Function, PointOfInstantiation));
5533 llvm::TimeTraceScope TimeScope(
"InstantiateFunction", [&]() {
5534 llvm::TimeTraceMetadata M;
5535 llvm::raw_string_ostream
OS(M.Detail);
5538 if (llvm::isTimeTraceVerbose()) {
5567 "missing LateParsedTemplate");
5569 Pattern = PatternDecl->
getBody(PatternDecl);
5576 "unexpected kind of function template definition");
5591 for (
auto *
D =
Function->getMostRecentDecl(); ;
5593 D->setImplicitlyInline();
5603 "instantiating function definition");
5607 Function->setVisibleDespiteOwningModule();
5633 auto NameLocPointsToPattern = [&] {
5644 return PatternNameLoc;
5654 return PatternNameLoc;
5662 assert(PatternTSI &&
"Pattern is supposed to have an associated TSI");
5670 Function->setDeclarationNameLoc(NameLocPointsToPattern());
5678 ThisContext =
Method->getParent();
5679 ThisTypeQuals =
Method->getMethodQualifiers();
5689 bool MergeWithParentScope =
false;
5691 MergeWithParentScope =
5692 Rec->isLocalClass() && !
Function->isFunctionTemplateSpecialization();
5695 auto RebuildTypeSourceInfoForDefaultSpecialMembers = [&]() {
5701 "Special member needs to be defaulted");
5709 auto *NewRec = dyn_cast<CXXRecordDecl>(
Function->getDeclContext());
5710 const auto *PatternRec =
5712 if (!NewRec || !PatternRec)
5714 if (!PatternRec->isLambda())
5717 struct SpecialMemberTypeInfoRebuilder
5737 getDerived().TransformDecl(TL.
getNameLoc(),
T->getOriginalDecl()));
5739 return Base::TransformRecordType(TLB, TL);
5742 QualType Result = getDerived().RebuildTagType(
5743 ElaboratedTypeKeyword::None, std::nullopt, NewDecl);
5744 if (Result.isNull())
5753 } IR{*
this, PatternRec, NewRec};
5756 assert(NewSI &&
"Type Transform failed?");
5758 Function->setTypeSourceInfo(NewSI);
5762 assert(NewParmSI &&
"Type transformation failed.");
5768 RebuildTypeSourceInfoForDefaultSpecialMembers();
5772 std::optional<ArrayRef<TemplateArgument>> Innermost;
5773 if (
auto *Primary =
Function->getPrimaryTemplate();
5776 Function->getTemplateSpecializationKind() !=
5778 auto It = llvm::find_if(Primary->redecls(),
5780 return cast<FunctionTemplateDecl>(RTD)
5781 ->isCompatibleWithDefinition();
5783 assert(It != Primary->redecls().end() &&
5784 "Should't get here without a definition");
5785 if (
FunctionDecl *Def = cast<FunctionTemplateDecl>(*It)
5786 ->getTemplatedDecl()
5790 DC = (*It)->getLexicalDeclContext();
5791 Innermost.emplace(
Function->getTemplateSpecializationArgs()->asArray());
5794 Function, DC,
false, Innermost,
false, PatternDecl);
5812 if (addInstantiatedParametersToScope(
Function, PatternDecl,
Scope,
5829 Ctor->isDefaultConstructor()) {
5835 Body =
SubstStmt(Pattern, TemplateArgs);
5844 checkReferenceToTULocalFromOtherTU(
Function, PointOfInstantiation);
5849 Listener->FunctionDefinitionInstantiated(
Function);
5859 bool ShouldSkipCG = [&] {
5860 auto *RD = dyn_cast<CXXRecordDecl>(
Function->getParent());
5861 if (!RD || !RD->isLambda())
5865 return Context.isUnevaluated() ||
Context.isImmediateFunctionContext();
5868 if (!ShouldSkipCG) {
5875 LocalInstantiations.
perform();
5877 GlobalInstantiations.perform();
5903 bool IsMemberSpec =
false;
5905 if (
auto *PartialSpec =
5906 dyn_cast<VarTemplatePartialSpecializationDecl>(FromVar)) {
5907 assert(PartialSpecArgs);
5908 IsMemberSpec = PartialSpec->isMemberSpecialization();
5910 PartialSpec, PartialSpecArgs->
asArray(),
false);
5913 IsMemberSpec =
VarTemplate->isMemberSpecialization();
5925 return cast_or_null<VarTemplateSpecializationDecl>(
5927 VarTemplate, FromVar, TemplateArgsInfo, Converted));
5934 "don't have a definition to instantiate from");
5963 bool InstantiatingVarTemplate,
5967 bool InstantiatingVarTemplatePartialSpec =
5968 isa<VarTemplatePartialSpecializationDecl>(OldVar) &&
5969 isa<VarTemplatePartialSpecializationDecl>(NewVar);
5972 bool InstantiatingSpecFromTemplate =
5973 isa<VarTemplateSpecializationDecl>(NewVar) &&
5975 isa<VarTemplatePartialSpecializationDecl>(OldVar));
5998 if (OldVar->
isUsed(
false))
6020 }
else if (!isa<VarTemplateSpecializationDecl>(NewVar) &&
6023 }
else if (PrevDeclForVarTemplateSpecialization) {
6024 Previous.addDecl(PrevDeclForVarTemplateSpecialization);
6028 if (!InstantiatingVarTemplate) {
6046 !InstantiatingSpecFromTemplate)
6053 dyn_cast<VarTemplateSpecializationDecl>(OldVar)) {
6055 !isa<VarTemplatePartialSpecializationDecl>(OldVTSD))
6056 cast<VarTemplateSpecializationDecl>(NewVar)->setSpecializationKind(
6065 if (InstantiatingVarTemplate || InstantiatingVarTemplatePartialSpec) {
6070 }
else if (InstantiatingSpecFromTemplate ||
6092 L->VariableDefinitionInstantiated(Var);
6118 if (!
Init.isInvalid()) {
6121 if (Var->
hasAttr<DLLImportAttr>() &&
6125 }
else if (InitExpr) {
6161 bool DefinitionRequired,
bool AtEndOfTU) {
6173 assert(PatternDecl &&
"no pattern for templated variable");
6178 dyn_cast<VarTemplateSpecializationDecl>(Var);
6189 (PatternDecl = PatternDecl->
getFirstDecl())->hasInit() &&
6197 "instantiating variable initializer");
6208 Recursive, AtEndOfTU);
6217 PreviousContext.
pop();
6221 LocalInstantiations.
perform();
6223 GlobalInstantiations.
perform();
6227 "not a static data member?");
6236 if (!Def && !DefinitionRequired) {
6243 Diag(PointOfInstantiation, diag::warn_var_template_missing)
6247 Diag(PointOfInstantiation, diag::note_inst_declaration_hint) << Var;
6258 PatternDecl, Def, TSK,
6259 DefinitionRequired))
6276 struct PassToConsumerRAII {
6281 : Consumer(Consumer), Var(Var) { }
6283 ~PassToConsumerRAII() {
6286 } PassToConsumerRAII(
Consumer, Var);
6293 PointOfInstantiation);
6301 "instantiating variable definition");
6323 }
else if (!VarSpec) {
6352 cast<VarTemplateSpecializationDecl>(Var)->setInstantiationOf(
6363 PreviousContext.
pop();
6366 PassToConsumerRAII.Var = Var;
6373 LocalInstantiations.
perform();
6375 GlobalInstantiations.
perform();
6387 for (
const auto *
Init : Tmpl->
inits()) {
6390 if (!
Init->isWritten())
6395 if (
Init->isPackExpansion()) {
6397 TypeLoc BaseTL =
Init->getTypeSourceInfo()->getTypeLoc();
6401 bool ShouldExpand =
false;
6402 bool RetainExpansion =
false;
6406 TemplateArgs,
true, ShouldExpand,
6407 RetainExpansion, NumExpansions)) {
6409 New->setInvalidDecl();
6412 assert(ShouldExpand &&
"Partial instantiation of base initializer?");
6415 for (
unsigned I = 0; I != *NumExpansions; ++I) {
6429 Init->getSourceLocation(),
6430 New->getDeclName());
6438 BaseTInfo, TempInit.
get(),
6446 NewInits.push_back(NewInit.
get());
6461 if (
Init->isDelegatingInitializer() ||
Init->isBaseInitializer()) {
6464 Init->getSourceLocation(),
6465 New->getDeclName());
6468 New->setInvalidDecl();
6472 if (
Init->isBaseInitializer())
6474 New->getParent(), EllipsisLoc);
6478 }
else if (
Init->isMemberInitializer()) {
6480 Init->getMemberLocation(),
6485 New->setInvalidDecl();
6490 Init->getSourceLocation());
6491 }
else if (
Init->isIndirectMemberInitializer()) {
6494 Init->getMemberLocation(),
6495 Init->getIndirectMember(), TemplateArgs));
6497 if (!IndirectMember) {
6499 New->setInvalidDecl();
6504 Init->getSourceLocation());
6509 New->setInvalidDecl();
6511 NewInits.push_back(NewInit.
get());
6530 Instance = Instance->getCanonicalDecl();
6531 if (Pattern == Instance)
return true;
6532 Instance = Instance->getInstantiatedFromMemberTemplate();
6543 Instance = Instance->getCanonicalDecl();
6544 if (Pattern == Instance)
return true;
6545 Instance = Instance->getInstantiatedFromMemberTemplate();
6555 = cast<ClassTemplatePartialSpecializationDecl>(Pattern->
getCanonicalDecl());
6557 Instance = cast<ClassTemplatePartialSpecializationDecl>(
6558 Instance->getCanonicalDecl());
6559 if (Pattern == Instance)
6561 Instance = Instance->getInstantiatedFromMember();
6572 Instance = Instance->getCanonicalDecl();
6573 if (Pattern == Instance)
return true;
6574 Instance = Instance->getInstantiatedFromMemberClass();
6585 Instance = Instance->getCanonicalDecl();
6586 if (Pattern == Instance)
return true;
6587 Instance = Instance->getInstantiatedFromMemberFunction();
6598 Instance = Instance->getCanonicalDecl();
6599 if (Pattern == Instance)
return true;
6600 Instance = Instance->getInstantiatedFromMemberEnum();
6627 bool OtherIsPackExpansion;
6629 if (
auto *OtherUUD = dyn_cast<T>(
Other)) {
6630 OtherIsPackExpansion = OtherUUD->isPackExpansion();
6632 }
else if (
auto *OtherUPD = dyn_cast<UsingPackDecl>(
Other)) {
6633 OtherIsPackExpansion =
true;
6634 OtherFrom = OtherUPD->getInstantiatedFromUsingDecl();
6635 }
else if (
auto *OtherUD = dyn_cast<UsingDecl>(
Other)) {
6636 OtherIsPackExpansion =
false;
6641 return Pattern->isPackExpansion() == OtherIsPackExpansion &&
6647 assert(Instance->isStaticDataMember());
6652 Instance = Instance->getCanonicalDecl();
6653 if (Pattern == Instance)
return true;
6654 Instance = Instance->getInstantiatedFromStaticDataMember();
6663 if (
auto *UUD = dyn_cast<UnresolvedUsingTypenameDecl>(
D))
6666 if (
auto *UUD = dyn_cast<UnresolvedUsingValueDecl>(
D))
6672 if (
auto *
Record = dyn_cast<CXXRecordDecl>(
Other))
6678 if (
auto *
Enum = dyn_cast<EnumDecl>(
Other))
6681 if (
auto *Var = dyn_cast<VarDecl>(
Other))
6685 if (
auto *Temp = dyn_cast<ClassTemplateDecl>(
Other))
6688 if (
auto *Temp = dyn_cast<FunctionTemplateDecl>(
Other))
6691 if (
auto *PartialSpec =
6692 dyn_cast<ClassTemplatePartialSpecializationDecl>(
Other))
6696 if (
auto *Field = dyn_cast<FieldDecl>(
Other)) {
6697 if (!Field->getDeclName()) {
6700 cast<FieldDecl>(
D));
6704 if (
auto *Using = dyn_cast<UsingDecl>(
Other))
6707 if (
auto *Shadow = dyn_cast<UsingShadowDecl>(
Other))
6710 return D->getDeclName() &&
6711 D->getDeclName() == cast<NamedDecl>(
Other)->getDeclName();
6714template<
typename ForwardIterator>
6717 ForwardIterator first,
6718 ForwardIterator last) {
6719 for (; first != last; ++first)
6721 return cast<NamedDecl>(*first);
6728 if (
NamedDecl *
D = dyn_cast<NamedDecl>(DC)) {
6730 return cast_or_null<DeclContext>(ID);
6745 return cast<Decl>(DC)->getTemplateDepth() > Level;
6750 bool FindingInstantiatedContext) {
6772 if (isa<ParmVarDecl>(
D) && !ParentDependsOnArgs &&
6773 !cast<ParmVarDecl>(
D)->getType()->isInstantiationDependentType())
6775 if (isa<ParmVarDecl>(
D) || isa<NonTypeTemplateParmDecl>(
D) ||
6776 isa<TemplateTypeParmDecl>(
D) || isa<TemplateTemplateParmDecl>(
D) ||
6778 isa<OMPDeclareReductionDecl>(ParentDC) ||
6779 isa<OMPDeclareMapperDecl>(ParentDC))) ||
6780 (isa<CXXRecordDecl>(
D) && cast<CXXRecordDecl>(
D)->isLambda() &&
6781 cast<CXXRecordDecl>(
D)->getTemplateDepth() >
6788 if (
auto *BD = dyn_cast<BindingDecl>(FD);
6792 return cast<NamedDecl>(FD);
6796 "found declaration pack but not pack expanding");
6798 return cast<NamedDecl>(
6806 if (isa<NonTypeTemplateParmDecl>(
D) || isa<TemplateTypeParmDecl>(
D) ||
6807 isa<TemplateTemplateParmDecl>(
D))
6826 bool NeedInstantiate =
false;
6828 NeedInstantiate = RD->isLocalClass();
6829 else if (isa<TypedefNameDecl>(
D) &&
6831 NeedInstantiate =
true;
6833 NeedInstantiate = isa<EnumDecl>(
D);
6834 if (NeedInstantiate) {
6837 return cast<TypeDecl>(Inst);
6842 assert(isa<LabelDecl>(
D));
6845 assert(Inst &&
"Failed to instantiate label??");
6848 return cast<LabelDecl>(Inst);
6852 if (!
Record->isDependentContext())
6861 dyn_cast<ClassTemplateSpecializationDecl>(
Record))
6862 ClassTemplate = Spec->getSpecializedTemplate()->getCanonicalDecl();
6873 if (
CXXRecordDecl *InstRecord = dyn_cast<CXXRecordDecl>(DC)) {
6877 = dyn_cast<ClassTemplateSpecializationDecl>(InstRecord)){
6897 auto *Guide = dyn_cast<CXXDeductionGuideDecl>(FD);
6898 if (Guide && Guide->isImplicit()) {
6906 Unpacked = Arg.pack_elements();
6941 if (FindingInstantiatedContext &&
6943 Loc, cast<ClassTemplateSpecializationDecl>(SubstRecord))) {
6944 Diag(
Loc, diag::err_specialization_not_primary_template)
6961 if (!ParentDependsOnArgs)
6975 bool IsBeingInstantiated =
false;
6976 if (
auto *Spec = dyn_cast<CXXRecordDecl>(ParentDC)) {
6977 if (!Spec->isDependentContext()) {
6978 if (Spec->isEntityBeingDefined())
6979 IsBeingInstantiated =
true;
6981 diag::err_incomplete_type))
6984 ParentDC = Spec->getDefinitionOrSelf();
6991 if (
auto Name =
D->getDeclName()) {
7016 if (isa<UsingShadowDecl>(
D)) {
7023 }
else if (IsBeingInstantiated) {
7029 Diag(
Loc, diag::err_member_not_yet_instantiated)
7037 EnumDecl *
Enum = cast<EnumDecl>(ED->getLexicalDeclContext());
7042 Diag(
Loc, diag::err_enumerator_does_not_exist)
7049 llvm_unreachable(
"Unable to find instantiation of declaration!");
7060 std::deque<PendingImplicitInstantiation> DelayedImplicitInstantiations;
7065 bool LocalInstantiation =
false;
7072 LocalInstantiation =
true;
7077 bool DefinitionRequired =
Function->getTemplateSpecializationKind() ==
7082 [
this, Inst, DefinitionRequired, AtEndOfTU](
FunctionDecl *CurFD) {
7084 DefinitionRequired, AtEndOfTU);
7090 DefinitionRequired, AtEndOfTU);
7092 Function->setInstantiationIsPending(
false);
7095 if (!LocalOnly &&
LangOpts.PCHInstantiateTemplates &&
7097 DelayedImplicitInstantiations.push_back(Inst);
7098 else if (!AtEndOfTU &&
Function->instantiationIsPending() &&
7099 !LocalInstantiation)
7100 DelayedImplicitInstantiations.push_back(Inst);
7105 VarDecl *Var = cast<VarDecl>(Inst.first);
7108 isa<VarTemplateSpecializationDecl>(Var)) &&
7109 "Not a static data member, nor a variable template"
7110 " specialization?");
7122 llvm_unreachable(
"Cannot instantitiate an undeclared specialization.");
7137 "instantiating variable definition");
7144 DefinitionRequired, AtEndOfTU);
7147 if (!DelayedImplicitInstantiations.empty())
7153 for (
auto *DD : Pattern->
ddiags()) {
7154 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
This file declares semantic analysis functions specific to AMDGPU.
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 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 instantiateDependentDeviceKernelAttr(Sema &S, const MultiLevelTemplateArgumentList &TemplateArgs, const DeviceKernelAttr &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 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 instantiateDependentHLSLParamModifierAttr(Sema &S, const MultiLevelTemplateArgumentList &TemplateArgs, const HLSLParamModifierAttr *Attr, Decl *New)
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 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.
virtual bool HandleTopLevelDecl(DeclGroupRef D)
HandleTopLevelDecl - Handle the specified top-level declaration.
virtual void HandleCXXStaticMemberVarInstantiation(VarDecl *D)
HandleCXXStaticMemberVarInstantiation - Tell the consumer that this.
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
unsigned getManglingNumber(const NamedDecl *ND, bool ForAuxTarget=false) const
TypedefNameDecl * getTypedefNameForUnnamedTagDecl(const TagDecl *TD)
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
bool hasSameType(QualType T1, QualType T2) const
Determine whether the given types T1 and T2 are equivalent.
void setInstantiatedFromUsingShadowDecl(UsingShadowDecl *Inst, UsingShadowDecl *Pattern)
unsigned getStaticLocalNumber(const VarDecl *VD) const
void forEachMultiversionedFunctionVersion(const FunctionDecl *FD, llvm::function_ref< void(FunctionDecl *)> Pred) const
Visits all versions of a multiversioned function with the passed predicate.
void setInstantiatedFromUsingEnumDecl(UsingEnumDecl *Inst, UsingEnumDecl *Pattern)
Remember that the using enum decl Inst is an instantiation of the using enum decl Pattern of a class ...
void setStaticLocalNumber(const VarDecl *VD, unsigned Number)
OMPTraitInfo & getNewOMPTraitInfo()
Return a new OMPTraitInfo object owned by this context.
TypeSourceInfo * getTrivialTypeSourceInfo(QualType T, SourceLocation Loc=SourceLocation()) const
Allocate a TypeSourceInfo where all locations have been initialized to a given location,...
QualType getTypeDeclType(ElaboratedTypeKeyword Keyword, NestedNameSpecifier Qualifier, const TypeDecl *Decl) const
void setManglingNumber(const NamedDecl *ND, unsigned Number)
void addDeclaratorForUnnamedTagDecl(TagDecl *TD, DeclaratorDecl *DD)
FieldDecl * getInstantiatedFromUnnamedFieldDecl(FieldDecl *Field) const
DeclaratorDecl * getDeclaratorForUnnamedTagDecl(const TagDecl *TD)
CanQualType UnsignedLongLongTy
QualType getFunctionType(QualType ResultTy, ArrayRef< QualType > Args, const FunctionProtoType::ExtProtoInfo &EPI) const
Return a normal function type with a typed argument list.
QualType getPromotedIntegerType(QualType PromotableType) const
Return the type that PromotableType will promote to: C99 6.3.1.1p2, assuming that PromotableType is a...
const TargetInfo & getTargetInfo() const
void setInstantiatedFromUnnamedFieldDecl(FieldDecl *Inst, FieldDecl *Tmpl)
ExternalASTSource * getExternalSource() const
Retrieve a pointer to the external AST source associated with this AST context, if any.
CanQualType getCanonicalTagType(const TagDecl *TD) const
bool isPromotableIntegerType(QualType T) const
More type predicates useful for type checking/promotion.
void addTypedefNameForUnnamedTagDecl(TagDecl *TD, TypedefNameDecl *TND)
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)
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.
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)
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...
void setInstantiationOfMemberClass(CXXRecordDecl *RD, TemplateSpecializationKind TSK)
Specify that this record is an instantiation of the member class RD.
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.
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 this template.
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.
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)
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)
The results of name lookup within a DeclContext.
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.
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).
bool isParameterPack() const
Whether this declaration is a parameter pack.
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.
virtual bool hasBody() const
Returns true if this Decl represents a declaration for a body of code, such as a function or method d...
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)
virtual Decl * getCanonicalDecl()
Retrieves the "canonical" declaration of the given declaration.
virtual SourceRange getSourceRange() const LLVM_READONLY
Source range that this declaration covers.
void setVisibleDespiteOwningModule()
Set that this declaration is globally visible, even if it came from a module that is not visible.
DeclarationNameLoc - Additional source/type location info for a declaration name.
static DeclarationNameLoc makeNamedTypeLoc(TypeSourceInfo *TInfo)
Construct location information for a constructor, destructor or conversion operator.
The name of a declaration.
@ CXXConversionFunctionName
NameKind getNameKind() const
Determine what kind of name this is.
Represents a ValueDecl that came out of a declarator.
SourceLocation getInnerLocStart() const
Return start of source range ignoring outer template declarations.
SourceLocation getTypeSpecStartLoc() const
SourceLocation getBeginLoc() const LLVM_READONLY
void setTypeSourceInfo(TypeSourceInfo *TI)
TypeSourceInfo * getTypeSourceInfo() const
Represents the type decltype(expr) (C++11).
Expr * getUnderlyingExpr() const
A decomposition declaration.
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.
Represents a qualified type name for which the type name is dependent.
unsigned getCustomDiagID(Level L, const char(&FormatString)[N])
Return an ID for a diagnostic with the specified format string and level.
bool hasErrorOccurred() const
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.
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,...
EnumDecl * getCanonicalDecl() override
Retrieves the "canonical" declaration of the given declaration.
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
void setKind(ExplicitSpecKind Kind)
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.
bool isTypeDependent() const
Determines whether the type of this expression depends on.
Expr * IgnoreParenImpCasts() LLVM_READONLY
Skip past any parentheses and implicit casts which might surround this expression until reaching a fi...
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,...
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.
FriendDecl - Represents the declaration of a friend entity, which can be a function,...
static FriendDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation L, FriendUnion Friend_, SourceLocation FriendL, SourceLocation EllipsisLoc={}, ArrayRef< TemplateParameterList * > FriendTypeTPLists={})
void setUnsupportedFriend(bool Unsupported)
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.
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 isInlined() const
Determine whether this function should be inlined, because it is either marked "inline" or "constexpr...
QualType getReturnType() const
FunctionDecl * getTemplateInstantiationPattern(bool ForDefinition=true) const
Retrieve the function declaration from which this function could be instantiated, if it is an instant...
FunctionDecl * getCanonicalDecl() override
Retrieves the "canonical" declaration of the given declaration.
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 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.
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 isDefined(const FunctionDecl *&Definition, bool CheckForPendingFriendDefinition=false) const
Returns true if the function has a definition that does not need to be instantiated.
DefaultedOrDeletedFunctionInfo * getDefalutedOrDeletedInfo() const
bool willHaveBody() const
True if this function will eventually have a body, once it's fully parsed.
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 this template.
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.
static IndirectFieldDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation L, const IdentifierInfo *Id, QualType T, MutableArrayRef< NamedDecl * > CH)
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...
void InstantiatedLocal(const Decl *D, Decl *Inst)
LocalInstantiationScope * cloneScopes(LocalInstantiationScope *Outermost)
Clone this scope, and all outer scopes, down to the given outermost scope.
llvm::PointerUnion< Decl *, DeclArgumentPack * > * findInstantiationOf(const Decl *D)
Find the instantiation of the declaration D within the current instantiation scope.
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)
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.
unsigned getNumLevels() const
Determine the number of levels in this template argument list.
void setKind(TemplateSubstitutionKind K)
unsigned getNumSubstitutedLevels() const
Determine the number of substituted levels in this template argument list.
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.
Represents a C++ namespace alias.
static NamespaceAliasDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation NamespaceLoc, SourceLocation AliasLoc, IdentifierInfo *Alias, NestedNameSpecifierLoc QualifierLoc, SourceLocation IdentLoc, NamespaceBaseDecl *Namespace)
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.
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)
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.
Pseudo declaration for capturing expressions.
This is a basic class for representing single OpenMP clause.
This represents '#pragma omp declare mapper ...' directive.
This represents '#pragma omp declare reduction ...' 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(...).
Wrapper for void* pointer.
static OpaquePtr make(QualType P)
static OpenACCBindClause * Create(const ASTContext &C, SourceLocation BeginLoc, SourceLocation LParenLoc, const IdentifierInfo *ID, SourceLocation EndLoc)
This is the base type for all OpenACC Clauses.
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)
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 pack expansion of types.
UnsignedOrNone getNumExpansions() const
Retrieve the number of expansions that this pack expansion will generate, if known.
Represents a parameter to a function.
bool hasUninstantiatedDefaultArg() const
Represents a #pragma detect_mismatch line.
bool NeedsStdLibCxxWorkaroundBefore(std::uint64_t FixedVersion)
PrettyDeclStackTraceEntry - If a crash occurs in the parser while parsing something related to a decl...
A (possibly-)qualified type.
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.
Wrapper for source info for record types.
A helper class that allows the use of isa/cast/dyncast to detect TagType objects of structs/unions/cl...
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.
decl_type * getPreviousDecl()
Return the previous declaration of this declaration or NULL if this is the first declaration.
decl_type * getMostRecentDecl()
Returns the most recent (re)declaration of this 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, bool DeferHint=false)
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...
void setVarListDetails(ArrayRef< Expr * > VarList, OpenACCModifierKind ModKind)
OpenACCDirectiveKind getDirectiveKind() const
SourceLocation getEndLoc() const
void setLParenLoc(SourceLocation EndLoc)
OpenACCClauseKind getClauseKind() const
SourceLocation getLParenLoc() const
SourceLocation getBeginLoc() const
OpenACCModifierKind getModifierList() const
ArrayRef< Expr * > getVarList()
void setEndLoc(SourceLocation EndLoc)
ExprResult ActOnRoutineName(Expr *RoutineName)
bool ActOnStartDeclDirective(OpenACCDirectiveKind K, SourceLocation StartLoc, ArrayRef< const OpenACCClause * > Clauses)
Called after the directive, including its clauses, have been parsed and parsing has consumed the 'ann...
void ActOnVariableDeclarator(VarDecl *VD)
Function called when a variable declarator is created, which lets us implement the 'routine' 'functio...
DeclGroupRef ActOnEndRoutineDeclDirective(SourceLocation StartLoc, SourceLocation DirLoc, SourceLocation LParenLoc, Expr *ReferencedFunc, SourceLocation RParenLoc, ArrayRef< const OpenACCClause * > Clauses, SourceLocation EndLoc, DeclGroupPtrTy NextDecl)
DeclGroupRef ActOnEndDeclDirective(OpenACCDirectiveKind K, SourceLocation StartLoc, SourceLocation DirLoc, SourceLocation LParenLoc, SourceLocation RParenLoc, SourceLocation EndLoc, ArrayRef< OpenACCClause * > Clauses)
Called after the directive has been completely parsed, including the declaration group or associated ...
void ActOnConstruct(OpenACCDirectiveKind K, SourceLocation DirLoc)
Called after the construct has been parsed, but clauses haven't been parsed.
DeclGroupPtrTy ActOnOpenMPDeclareReductionDirectiveEnd(Scope *S, DeclGroupPtrTy DeclReductions, bool IsValid)
Called at the end of '#pragma omp declare reduction'.
void ActOnOpenMPDeclareReductionCombinerEnd(Decl *D, Expr *Combiner)
Finish current declare reduction construct initializer.
ExprResult ActOnOpenMPDeclareMapperDirectiveVarDecl(Scope *S, QualType MapperType, SourceLocation StartLoc, DeclarationName VN)
Build the mapper variable of '#pragma omp declare mapper'.
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.
VarDecl * ActOnOpenMPDeclareReductionInitializerStart(Scope *S, Decl *D)
Initialize declare reduction construct initializer.
QualType ActOnOpenMPDeclareReductionType(SourceLocation TyLoc, TypeResult ParsedType)
Check if the specified type is allowed to be used in 'omp declare reduction' construct.
DeclGroupPtrTy ActOnOpenMPAllocateDirective(SourceLocation Loc, ArrayRef< Expr * > VarList, ArrayRef< OMPClause * > Clauses, DeclContext *Owner=nullptr)
Called on well-formed '#pragma omp allocate'.
DeclGroupPtrTy ActOnOpenMPDeclareReductionDirectiveStart(Scope *S, DeclContext *DC, DeclarationName Name, ArrayRef< std::pair< QualType, SourceLocation > > ReductionTypes, AccessSpecifier AS, Decl *PrevDeclInScope=nullptr)
Called on start of '#pragma omp declare reduction'.
OMPClause * ActOnOpenMPAllocatorClause(Expr *Allocator, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Called on well-formed 'allocator' clause.
void EndOpenMPDSABlock(Stmt *CurDirective)
Called on end of data sharing attribute block.
QualType ActOnOpenMPDeclareMapperType(SourceLocation TyLoc, TypeResult ParsedType)
Check if the specified type is allowed to be used in 'omp declare mapper' construct.
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...
void ActOnOpenMPDeclareReductionCombinerStart(Scope *S, Decl *D)
Initialize declare reduction construct initializer.
OMPClause * ActOnOpenMPMapClause(Expr *IteratorModifier, ArrayRef< OpenMPMapModifierKind > MapTypeModifiers, ArrayRef< SourceLocation > MapTypeModifiersLoc, CXXScopeSpec &MapperIdScopeSpec, DeclarationNameInfo &MapperId, OpenMPMapClauseKind MapType, bool IsMapTypeImplicit, SourceLocation MapLoc, SourceLocation ColonLoc, ArrayRef< Expr * > VarList, const OMPVarListLocTy &Locs, bool NoDiagnose=false, ArrayRef< Expr * > UnresolvedMappers={})
Called on well-formed 'map' clause.
void StartOpenMPDSABlock(OpenMPDirectiveKind K, const DeclarationNameInfo &DirName, Scope *CurScope, SourceLocation Loc)
Called on start of new data sharing attribute block.
OMPThreadPrivateDecl * CheckOMPThreadPrivateDecl(SourceLocation Loc, ArrayRef< Expr * > VarList)
Builds a new OpenMPThreadPrivateDecl and checks its correctness.
void ActOnOpenMPDeclareReductionInitializerEnd(Decl *D, Expr *Initializer, VarDecl *OmpPrivParm)
Finish current declare reduction construct initializer.
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.
OMPClause * ActOnOpenMPAlignClause(Expr *Alignment, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Called on well-formed 'align' clause.
DeclGroupPtrTy ActOnOpenMPDeclareMapperDirective(Scope *S, DeclContext *DC, DeclarationName Name, QualType MapperType, SourceLocation StartLoc, DeclarationName VN, AccessSpecifier AS, Expr *MapperVarRef, ArrayRef< OMPClause * > Clauses, Decl *PrevDeclInScope=nullptr)
Called for '#pragma omp declare mapper'.
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)
VarTemplateSpecializationDecl * BuildVarTemplateInstantiation(VarTemplateDecl *VarTemplate, VarDecl *FromVar, const TemplateArgumentList *PartialSpecArgs, const TemplateArgumentListInfo &TemplateArgsInfo, SmallVectorImpl< TemplateArgument > &Converted, SourceLocation PointOfInstantiation, LateInstantiatedAttrVec *LateAttrs=nullptr, LocalInstantiationScope *StartingScope=nullptr)
bool SubstTypeConstraint(TemplateTypeParmDecl *Inst, const TypeConstraint *TC, const MultiLevelTemplateArgumentList &TemplateArgs, bool EvaluateConstraint)
SmallVector< CodeSynthesisContext, 16 > CodeSynthesisContexts
List of active code synthesis contexts.
LocalInstantiationScope * CurrentInstantiationScope
The current instantiation scope used to store local variables.
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)
Decl * BuildStaticAssertDeclaration(SourceLocation StaticAssertLoc, Expr *AssertExpr, Expr *AssertMessageExpr, SourceLocation RParenLoc, bool Failed)
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.
AccessResult CheckFriendAccess(NamedDecl *D)
Checks access to the target of a friend declaration.
const TranslationUnitKind TUKind
The kind of translation unit we are processing.
void InstantiateExceptionSpec(SourceLocation PointOfInstantiation, FunctionDecl *Function)
TemplateName SubstTemplateName(SourceLocation TemplateKWLoc, NestedNameSpecifierLoc &QualifierLoc, TemplateName Name, SourceLocation NameLoc, const MultiLevelTemplateArgumentList &TemplateArgs)
void AddAssumeAlignedAttr(Decl *D, const AttributeCommonInfo &CI, Expr *E, Expr *OE)
AddAssumeAlignedAttr - Adds an assume_aligned attribute to a particular declaration.
ParmVarDecl * SubstParmVarDecl(ParmVarDecl *D, const MultiLevelTemplateArgumentList &TemplateArgs, int indexAdjustment, UnsignedOrNone NumExpansions, bool ExpectParameterPack, bool EvaluateConstraints=true)
bool RequireCompleteDeclContext(CXXScopeSpec &SS, DeclContext *DC)
Require that the context specified by SS be complete.
bool TemplateParameterListsAreEqual(const TemplateCompareNewDeclInfo &NewInstFrom, TemplateParameterList *New, const NamedDecl *OldInstFrom, TemplateParameterList *Old, bool Complain, TemplateParameterListEqualKind Kind, SourceLocation TemplateArgLoc=SourceLocation())
Determine whether the given template parameter lists are equivalent.
void CheckOverrideControl(NamedDecl *D)
CheckOverrideControl - Check C++11 override control semantics.
Preprocessor & getPreprocessor() const
const ExpressionEvaluationContextRecord & currentEvaluationContext() const
llvm::DenseSet< std::pair< Decl *, unsigned > > InstantiatingSpecializations
Specializations whose definitions are currently being instantiated.
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)
Decl * ActOnFinishFunctionBody(Decl *Decl, Stmt *Body, bool IsInstantiation=false, bool RetainFunctionScopeInfo=false)
Performs semantic analysis at the end of a function body.
UsingShadowDecl * BuildUsingShadowDecl(Scope *S, BaseUsingDecl *BUD, NamedDecl *Target, UsingShadowDecl *PrevDecl)
Builds a shadow declaration corresponding to a 'using' declaration.
void CheckThreadLocalForLargeAlignment(VarDecl *VD)
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...
void CheckTemplatePartialSpecialization(ClassTemplatePartialSpecializationDecl *Partial)
QualType CheckTemplateIdType(ElaboratedTypeKeyword Keyword, TemplateName Template, SourceLocation TemplateLoc, TemplateArgumentListInfo &TemplateArgs)
StmtResult SubstStmt(Stmt *S, const MultiLevelTemplateArgumentList &TemplateArgs)
ParmVarDecl * BuildParmVarDeclForTypedef(DeclContext *DC, SourceLocation Loc, QualType T)
Synthesizes a variable for a parameter arising from a typedef.
bool CheckTemplatePartialSpecializationArgs(SourceLocation Loc, TemplateDecl *PrimaryTemplate, unsigned NumExplicitArgs, ArrayRef< TemplateArgument > Args)
Check the non-type template arguments of a class template partial specialization according to C++ [te...
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.
void inferGslPointerAttribute(NamedDecl *ND, CXXRecordDecl *UnderlyingRecord)
Add gsl::Pointer attribute to std::container::iterator.
NamedDecl * BuildUsingDeclaration(Scope *S, AccessSpecifier AS, SourceLocation UsingLoc, bool HasTypenameKeyword, SourceLocation TypenameLoc, CXXScopeSpec &SS, DeclarationNameInfo NameInfo, SourceLocation EllipsisLoc, const ParsedAttributesView &AttrList, bool IsInstantiation, bool IsUsingIfExists)
Builds a using declaration.
PrintingPolicy getPrintingPolicy() const
Retrieve a suitable printing policy for diagnostics.
bool SubstTemplateArguments(ArrayRef< TemplateArgumentLoc > Args, const MultiLevelTemplateArgumentList &TemplateArgs, TemplateArgumentListInfo &Outputs)
void HandleDependentAccessCheck(const DependentDiagnostic &DD, const MultiLevelTemplateArgumentList &TemplateArgs)
@ TPL_TemplateMatch
We are matching the template parameter lists of two templates that might be redeclarations.
bool CheckFunctionTemplateSpecialization(FunctionDecl *FD, TemplateArgumentListInfo *ExplicitTemplateArgs, LookupResult &Previous, bool QualifiedFriend=false)
Perform semantic analysis for the given function template specialization.
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...
bool CheckEnumUnderlyingType(TypeSourceInfo *TI)
Check that this is a valid underlying type for an enum declaration.
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
void InstantiateClassMembers(SourceLocation PointOfInstantiation, CXXRecordDecl *Instantiation, const MultiLevelTemplateArgumentList &TemplateArgs, TemplateSpecializationKind TSK)
Instantiates the definitions of all of the member of the given class, which is an instantiation of a ...
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...
bool CheckFunctionDeclaration(Scope *S, FunctionDecl *NewFD, LookupResult &Previous, bool IsMemberSpecialization, bool DeclIsDefn)
Perform semantic checking of a new function declaration.
FieldDecl * CheckFieldDecl(DeclarationName Name, QualType T, TypeSourceInfo *TInfo, RecordDecl *Record, SourceLocation Loc, bool Mutable, Expr *BitfieldWidth, InClassInitStyle InitStyle, SourceLocation TSSL, AccessSpecifier AS, NamedDecl *PrevDecl, Declarator *D=nullptr)
Build a new FieldDecl and check its well-formedness.
void updateAttrsForLateParsedTemplate(const Decl *Pattern, Decl *Inst)
Update instantiation attributes after template was late parsed.
bool CheckPureMethod(CXXMethodDecl *Method, SourceRange InitRange)
Mark the given method pure.
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.
std::vector< std::unique_ptr< TemplateInstantiationCallback > > TemplateInstCallbacks
The template instantiation callbacks to trace or track instantiations (objects can be chained).
const VarDecl * getCopyElisionCandidate(NamedReturnInfo &Info, QualType ReturnType)
Updates given NamedReturnInfo's move-eligible and copy-elidable statuses, considering the function re...
bool RequireCompleteEnumDecl(EnumDecl *D, SourceLocation L, CXXScopeSpec *SS=nullptr)
Require that the EnumDecl is completed with its enumerators defined or instantiated.
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 SubstParmTypes(SourceLocation Loc, ArrayRef< ParmVarDecl * > Params, const FunctionProtoType::ExtParameterInfo *ExtParamInfos, const MultiLevelTemplateArgumentList &TemplateArgs, SmallVectorImpl< QualType > &ParamTypes, SmallVectorImpl< ParmVarDecl * > *OutParams, ExtParameterInfoBuilder &ParamInfos)
Substitute the given template arguments into the given set of parameters, producing the set of parame...
bool CheckVariableDeclaration(VarDecl *NewVD, LookupResult &Previous)
Perform semantic checking on a newly-created variable declaration.
bool CheckUsingShadowDecl(BaseUsingDecl *BUD, NamedDecl *Target, const LookupResult &PreviousDecls, UsingShadowDecl *&PrevShadow)
Determines whether to create a using shadow decl for a particular decl, given the set of decls existi...
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...
void CompleteMemberSpecialization(NamedDecl *Member, LookupResult &Previous)
ExprResult PerformContextuallyConvertToBool(Expr *From)
PerformContextuallyConvertToBool - Perform a contextual conversion of the expression From to bool (C+...
void MarkDeclarationsReferencedInType(SourceLocation Loc, QualType T)
Mark all of the declarations referenced within a particular AST node as referenced.
bool CheckSpecializationInstantiationRedecl(SourceLocation NewLoc, TemplateSpecializationKind ActOnExplicitInstantiationNewTSK, NamedDecl *PrevDecl, TemplateSpecializationKind PrevTSK, SourceLocation PrevPtOfInstantiation, bool &SuppressNew)
Diagnose cases where we have an explicit template specialization before/after an explicit template in...
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 ActOnEnumBody(SourceLocation EnumLoc, SourceRange BraceRange, Decl *EnumDecl, ArrayRef< Decl * > Elements, Scope *S, const ParsedAttributesView &Attr)
void PerformPendingInstantiations(bool LocalOnly=false, bool AtEndOfTU=true)
Performs template instantiation for all implicit template instantiations we have seen until this poin...
Decl * SubstDecl(Decl *D, DeclContext *Owner, const MultiLevelTemplateArgumentList &TemplateArgs)
DeclContext * computeDeclContext(QualType T)
Compute the DeclContext that is associated with the given type.
QualType CheckNonTypeTemplateParameterType(TypeSourceInfo *&TSI, SourceLocation Loc)
Check that the type of a non-type template parameter is well-formed.
bool AttachTypeConstraint(NestedNameSpecifierLoc NS, DeclarationNameInfo NameInfo, TemplateDecl *NamedConcept, NamedDecl *FoundDecl, const TemplateArgumentListInfo *TemplateArgs, TemplateTypeParmDecl *ConstrainedParameter, SourceLocation EllipsisLoc)
Attach a type-constraint to a template parameter.
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 AdjustDestructorExceptionSpec(CXXDestructorDecl *Destructor)
Build an exception spec for destructors that don't have one.
bool InstantiateClass(SourceLocation PointOfInstantiation, CXXRecordDecl *Instantiation, CXXRecordDecl *Pattern, const MultiLevelTemplateArgumentList &TemplateArgs, TemplateSpecializationKind TSK, bool Complain=true)
Instantiate the definition of a class from a given pattern.
void InstantiateDefaultCtorDefaultArgs(CXXConstructorDecl *Ctor)
In the MS ABI, we need to instantiate default arguments of dllexported default constructors along wit...
RedeclarationKind forRedeclarationInCurContext() const
bool SubstTemplateArgument(const TemplateArgumentLoc &Input, const MultiLevelTemplateArgumentList &TemplateArgs, TemplateArgumentLoc &Output, SourceLocation Loc={}, const DeclarationName &Entity={})
void InstantiateFunctionDefinition(SourceLocation PointOfInstantiation, FunctionDecl *Function, bool Recursive=false, bool DefinitionRequired=false, bool AtEndOfTU=false)
Instantiate the definition of the given function from its template.
bool 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)
EnumConstantDecl * CheckEnumConstant(EnumDecl *Enum, EnumConstantDecl *LastEnumConst, SourceLocation IdLoc, IdentifierInfo *Id, Expr *val)
void DiagnoseUnusedNestedTypedefs(const RecordDecl *D)
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.
@ 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),...
void CheckStaticLocalForDllExport(VarDecl *VD)
Check if VD needs to be dllexport/dllimport due to being in a dllexport/import function.
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.
bool RebuildingImmediateInvocation
Whether the AST is currently being rebuilt to correct immediate invocations.
SmallVector< ExpressionEvaluationContextRecord, 8 > ExprEvalContexts
A stack of expression evaluation contexts.
bool DiagnoseUninstantiableTemplate(SourceLocation PointOfInstantiation, NamedDecl *Instantiation, bool InstantiatedFromMember, const NamedDecl *Pattern, const NamedDecl *PatternDef, TemplateSpecializationKind TSK, bool Complain=true, bool *Unreachable=nullptr)
Determine whether we would be unable to instantiate this template (because it either has no definitio...
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)
NamedDecl * BuildUsingPackDecl(NamedDecl *InstantiatedFrom, ArrayRef< NamedDecl * > Expansions)
void SetDeclDeleted(Decl *dcl, SourceLocation DelLoc, StringLiteral *Message=nullptr)
NamespaceDecl * getStdNamespace() const
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 FilterLookupForScope(LookupResult &R, DeclContext *Ctx, Scope *S, bool ConsiderLinkage, bool AllowInlineNamespace)
Filters out lookup results that don't fall within the given scope as determined by isDeclInScope.
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 MarkFunctionReferenced(SourceLocation Loc, FunctionDecl *Func, bool MightBeOdrUse=true)
Mark a function referenced, and check whether it is odr-used (C++ [basic.def.odr]p2,...
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.
bool CheckTemplateParameterList(TemplateParameterList *NewParams, TemplateParameterList *OldParams, TemplateParamListContext TPC, SkipBodyInfo *SkipBody=nullptr)
Checks the validity of a template parameter list, possibly considering the template parameter list fr...
ExprResult CreateRecoveryExpr(SourceLocation Begin, SourceLocation End, ArrayRef< Expr * > SubExprs, QualType T=QualType())
Attempts to produce a RecoveryExpr after some AST node cannot be created.
void UpdateExceptionSpec(FunctionDecl *FD, const FunctionProtoType::ExceptionSpecInfo &ESI)
ExprResult SubstCXXIdExpr(Expr *E, const MultiLevelTemplateArgumentList &TemplateArgs)
Substitute an expression as if it is a address-of-operand, which makes it act like a CXXIdExpression ...
void CheckAlignasUnderalignment(Decl *D)
bool CheckTemplateArgumentList(TemplateDecl *Template, SourceLocation TemplateLoc, TemplateArgumentListInfo &TemplateArgs, const DefaultArguments &DefaultArgs, bool PartialTemplateArgs, CheckTemplateArgumentInfo &CTAI, bool UpdateArgsWithConversions=true, bool *ConstraintsNotSatisfied=nullptr)
Check that the given template arguments can be provided to the given template, converting the argumen...
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.
bool isIncompatibleTypedef(const TypeDecl *Old, TypedefNameDecl *New)
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)
bool checkStringLiteralArgumentAttr(const AttributeCommonInfo &CI, const Expr *E, StringRef &Str, SourceLocation *ArgLocation=nullptr)
Check if the argument E is a ASCII string literal.
TypeSourceInfo * CheckPackExpansion(TypeSourceInfo *Pattern, SourceLocation EllipsisLoc, UnsignedOrNone NumExpansions)
Construct a pack expansion type from the pattern of the pack expansion.
bool CheckEnumRedeclaration(SourceLocation EnumLoc, bool IsScoped, QualType EnumUnderlyingTy, bool IsFixed, const EnumDecl *Prev)
Check whether this is a valid redeclaration of a previous enumeration.
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)
TypeSourceInfo * SubstFunctionDeclType(TypeSourceInfo *T, const MultiLevelTemplateArgumentList &TemplateArgs, SourceLocation Loc, DeclarationName Entity, CXXRecordDecl *ThisContext, Qualifiers ThisTypeQuals, bool EvaluateConstraints=true)
A form of SubstType intended specifically for instantiating the type of a FunctionDecl.
Encodes a location in the source.
bool isInSystemHeader(SourceLocation Loc) const
Returns if a SourceLocation is in a system header.
unsigned getExpansionLineNumber(SourceLocation Loc, bool *Invalid=nullptr) const
StringRef getFilename(SourceLocation SpellingLoc) const
Return the filename of the file containing a SourceLocation.
SourceLocation getExpansionLoc(SourceLocation Loc) const
Given a SourceLocation object Loc, return the expansion location referenced by the ID.
A trivial tuple used to represent a source range.
SourceLocation getEnd() const
Represents a C++11 static_assert declaration.
Stmt - This represents one statement.
SourceLocation getEndLoc() const LLVM_READONLY
SourceLocation getBeginLoc() const LLVM_READONLY
Represents the declaration of a struct/union/class/enum.
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)
bool isMicrosoft() const
Is this ABI an MSVC-compatible ABI?
TargetCXXABI getCXXABI() const
Get the C++ ABI currently in use.
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)
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)
Decl * VisitVarTemplateSpecializationDecl(VarTemplateDecl *VarTemplate, VarDecl *FromVar, const TemplateArgumentListInfo &TemplateArgsInfo, ArrayRef< TemplateArgument > Converted, VarTemplateSpecializationDecl *PrevDecl=nullptr)
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.
Represents a C++ template name within the type system.
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.
static TemplateTemplateParmDecl * Create(const ASTContext &C, DeclContext *DC, SourceLocation L, unsigned D, unsigned P, bool ParameterPack, IdentifierInfo *Id, TemplateNameKind ParameterKind, bool Typename, TemplateParameterList *Params)
void setDefaultArgument(const ASTContext &C, const TemplateArgumentLoc &DefArg)
Set the default argument for this template parameter, and whether that default argument was inherited...
Declaration of a template type parameter.
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)
void setDefaultArgument(const ASTContext &C, const TemplateArgumentLoc &DefArg)
Set the default argument for this template parameter.
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.
Models the abbreviated syntax to constrain a template type parameter: template <convertible_to<string...
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.
bool isRValueReferenceType() const
CXXRecordDecl * getAsCXXRecordDecl() const
Retrieves the CXXRecordDecl that this type refers to, either because the type is a RecordType or beca...
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 containsErrors() const
Whether this type is an error type.
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.
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.
static UsingDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation UsingL, NestedNameSpecifierLoc QualifierLoc, const DeclarationNameInfo &NameInfo, bool HasTypenameKeyword)
Represents C++ using-directive.
static UsingDirectiveDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation UsingLoc, SourceLocation NamespaceLoc, NestedNameSpecifierLoc QualifierLoc, SourceLocation IdentLoc, NamedDecl *Nominated, DeclContext *CommonAncestor)
Represents a C++ using-enum-declaration.
static UsingEnumDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation UsingL, SourceLocation EnumL, SourceLocation NameL, TypeSourceInfo *EnumType)
Represents a pack of using declarations that a single using-declarator 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)
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...
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 ...
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.
static VarTemplateDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation L, DeclarationName Name, TemplateParameterList *Params, VarDecl *Decl)
Create a variable template node.
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()
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)
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.
void atTemplateEnd(TemplateInstantiationCallbackPtrs &Callbacks, const Sema &TheSema, const Sema::CodeSynthesisContext &Inst)
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...
@ 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.
@ Private
'private' clause, allowed on 'parallel', 'serial', 'loop', 'parallel loop', and 'serial loop' constru...
@ 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.
@ 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.
const FunctionProtoType * T
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,...
@ None
No keyword precedes the qualified type name.
@ Enum
The "enum" keyword introduces the elaborated-type-specifier.
bool isLambdaMethod(const DeclContext *DC)
@ 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
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
This structure contains most locations needed for by an OMPVarListClause.
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.
bool isAlreadyInstantiating() const
Determine whether we are already instantiating this specialization in some surrounding active instant...