32#include "llvm/Support/TimeProfiler.h"
43 return cast<CXXRecordDecl>(DC)->isLocalClass();
48template<
typename DeclT>
51 if (!OldDecl->getQualifierLoc())
54 assert((NewDecl->getFriendObjectKind() ||
55 !OldDecl->getLexicalDeclContext()->isDependentContext()) &&
56 "non-friend with qualified name defined in dependent context");
59 const_cast<DeclContext *
>(NewDecl->getFriendObjectKind()
60 ? NewDecl->getLexicalDeclContext()
61 : OldDecl->getLexicalDeclContext()));
70 NewDecl->setQualifierInfo(NewQualifierLoc);
76 return ::SubstQualifier(SemaRef, OldDecl, NewDecl, TemplateArgs);
81 return ::SubstQualifier(SemaRef, OldDecl, NewDecl, TemplateArgs);
85#include "clang/Sema/AttrTemplateInstantiate.inc"
89 const AlignedAttr *Aligned,
Decl *New,
bool IsPackExpansion) {
90 if (Aligned->isAlignmentExpr()) {
99 S.
SubstType(Aligned->getAlignmentType(), TemplateArgs,
102 Aligned->getLocation(),
103 Result->getTypeLoc().getSourceRange()))
111 const AlignedAttr *Aligned,
Decl *New) {
112 if (!Aligned->isPackExpansion()) {
118 if (Aligned->isAlignmentExpr())
124 assert(!Unexpanded.empty() &&
"Pack expansion without parameter packs?");
127 bool Expand =
true, RetainExpansion =
false;
128 std::optional<unsigned> NumExpansions;
132 Unexpanded, TemplateArgs, Expand,
133 RetainExpansion, NumExpansions))
140 for (
unsigned I = 0; I != *NumExpansions; ++I) {
149 const AssumeAlignedAttr *Aligned,
Decl *New) {
154 Expr *E, *OE =
nullptr;
160 if (Aligned->getOffset()) {
172 const AlignValueAttr *Aligned,
Decl *New) {
183 const AllocAlignAttr *Align,
Decl *New) {
186 llvm::APInt(64, Align->getParamIndex().getSourceIndex()),
193 const AnnotateAttr *
Attr,
Decl *New) {
199 bool HasDelayedArgs =
Attr->delayedArgs_size();
208 false, TemplateArgs, Args))
211 StringRef Str =
Attr->getAnnotation();
212 if (HasDelayedArgs) {
213 if (Args.size() < 1) {
223 ActualArgs.insert(ActualArgs.begin(), Args.begin() + 1, Args.end());
224 std::swap(Args, ActualArgs);
232 Expr *Cond =
nullptr;
246 Cond = Converted.
get();
252 S.
Diag(A->
getLocation(), diag::err_attr_cond_never_constant_expr) << A;
253 for (
const auto &
P : Diags)
254 S.
Diag(
P.first,
P.second);
264 S, TemplateArgs, EIA, EIA->getCond(), Tmpl, New);
268 Cond, EIA->getMessage()));
275 S, TemplateArgs, DIA, DIA->getCond(), Tmpl, New);
280 DIA->getDiagnosticType(), DIA->getArgDependent(), New));
287 const CUDALaunchBoundsAttr &
Attr,
Decl *New) {
297 Expr *MinBlocks =
nullptr;
298 if (
Attr.getMinBlocks()) {
305 Expr *MaxBlocks =
nullptr;
306 if (
Attr.getMaxBlocks()) {
327 const OMPDeclareSimdDeclAttr &
Attr,
Decl *New) {
329 if (
auto *FTD = dyn_cast<FunctionTemplateDecl>(New))
330 New = FTD->getTemplatedDecl();
331 auto *FD = cast<FunctionDecl>(New);
332 auto *ThisContext = dyn_cast_or_null<CXXRecordDecl>(FD->getDeclContext());
337 if (
auto *DRE = dyn_cast<DeclRefExpr>(E->IgnoreParenImpCasts()))
338 if (
auto *PVD = dyn_cast<ParmVarDecl>(DRE->getDecl())) {
341 if (FD->getNumParams() > PVD->getFunctionScopeIndex())
342 Local.InstantiatedLocal(
343 PVD, FD->getParamDecl(PVD->getFunctionScopeIndex()));
347 FD->isCXXInstanceMember());
363 if (
auto *E =
Attr.getSimdlen())
366 if (
Attr.uniforms_size() > 0) {
367 for(
auto *E :
Attr.uniforms()) {
371 Uniforms.push_back(Inst.
get());
375 auto AI =
Attr.alignments_begin();
376 for (
auto *E :
Attr.aligneds()) {
380 Aligneds.push_back(Inst.
get());
384 Alignments.push_back(Inst.
get());
388 auto SI =
Attr.steps_begin();
389 for (
auto *E :
Attr.linears()) {
393 Linears.push_back(Inst.
get());
397 Steps.push_back(Inst.
get());
400 LinModifiers.append(
Attr.modifiers_begin(),
Attr.modifiers_end());
403 Uniforms, Aligneds, Alignments, Linears, LinModifiers, Steps,
410 const OMPDeclareVariantAttr &
Attr,
Decl *New) {
412 if (
auto *FTD = dyn_cast<FunctionTemplateDecl>(New))
413 New = FTD->getTemplatedDecl();
414 auto *FD = cast<FunctionDecl>(New);
415 auto *ThisContext = dyn_cast_or_null<CXXRecordDecl>(FD->getDeclContext());
417 auto &&SubstExpr = [FD, ThisContext, &S, &TemplateArgs](
Expr *E) {
418 if (
auto *DRE = dyn_cast<DeclRefExpr>(E->IgnoreParenImpCasts()))
419 if (
auto *PVD = dyn_cast<ParmVarDecl>(DRE->getDecl())) {
422 if (FD->getNumParams() > PVD->getFunctionScopeIndex())
423 Local.InstantiatedLocal(
424 PVD, FD->getParamDecl(PVD->getFunctionScopeIndex()));
428 FD->isCXXInstanceMember());
434 auto &&Subst = [&SubstExpr, &S](
Expr *E) {
444 if (
Expr *E =
Attr.getVariantFuncRef()) {
449 VariantFuncRef = Subst(E);
455 TI = *
Attr.getTraitInfos();
458 auto SubstScoreOrConditionExpr = [&S, Subst](
Expr *&E,
bool) {
473 Expr *E = VariantFuncRef.
get();
477 std::optional<std::pair<FunctionDecl *, Expr *>> DeclVarData =
479 Attr.appendArgs_size(),
485 E = DeclVarData->second;
486 FD = DeclVarData->first;
488 if (
auto *VariantDRE = dyn_cast<DeclRefExpr>(E->IgnoreParenImpCasts())) {
489 if (
auto *VariantFD = dyn_cast<FunctionDecl>(VariantDRE->getDecl())) {
490 if (
auto *VariantFTD = VariantFD->getDescribedFunctionTemplate()) {
491 if (!VariantFTD->isThisDeclarationADefinition())
502 SubstFD->getType(), FD->getType(),
510 SubstFD->setInstantiationIsPending(!SubstFD->isDefined());
514 SubstFD->getLocation(),
524 for (
Expr *E :
Attr.adjustArgsNothing()) {
528 NothingExprs.push_back(ER.
get());
530 for (
Expr *E :
Attr.adjustArgsNeedDevicePtr()) {
534 NeedDevicePtrExprs.push_back(ER.
get());
538 AppendArgs.emplace_back(II.IsTarget, II.IsTargetSync);
542 FD, E, TI, NothingExprs, NeedDevicePtrExprs, AppendArgs,
SourceLocation(),
548 const AMDGPUFlatWorkGroupSizeAttr &
Attr,
Decl *New) {
571 Expr *Cond =
nullptr;
579 Cond = SubstResult.
get();
589 const AMDGPUWavesPerEUAttr &
Attr,
Decl *New) {
599 Expr *MaxExpr =
nullptr;
600 if (
auto Max =
Attr.getMax()) {
612 const AMDGPUMaxNumWorkGroupsAttr &
Attr,
Decl *New) {
638 const SYCLKernelAttr &
Attr,
Decl *New) {
648 if (
const auto *PNA = dyn_cast<PreferredNameAttr>(A)) {
650 const auto *RD = cast<CXXRecordDecl>(D);
654 for (
const auto *ExistingPNA : D->
specific_attrs<PreferredNameAttr>())
656 PNA->getTypedefType()))
661 if (
const auto *BA = dyn_cast<BuiltinAttr>(A)) {
663 switch (BA->getID()) {
664 case Builtin::BIforward:
674 case Builtin::BImove:
675 case Builtin::BImove_if_noexcept:
691 const HLSLParamModifierAttr *
Attr,
Decl *New) {
701 if (
NamedDecl *ND = dyn_cast<NamedDecl>(New)) {
705 for (
const auto *TmplAttr : Tmpl->
attrs()) {
712 *
this, dyn_cast_or_null<CXXRecordDecl>(ND->getDeclContext()),
716 TmplAttr,
Context, *
this, TemplateArgs);
726 case clang::attr::CFConsumed:
728 case clang::attr::OSConsumed:
730 case clang::attr::NSConsumed:
733 llvm_unreachable(
"Wrong argument supplied");
741 for (
const auto *TmplAttr : Tmpl->
attrs()) {
746 const AlignedAttr *Aligned = dyn_cast<AlignedAttr>(TmplAttr);
747 if (Aligned && Aligned->isAlignmentDependent()) {
752 if (
const auto *AssumeAligned = dyn_cast<AssumeAlignedAttr>(TmplAttr)) {
757 if (
const auto *AlignValue = dyn_cast<AlignValueAttr>(TmplAttr)) {
762 if (
const auto *AllocAlign = dyn_cast<AllocAlignAttr>(TmplAttr)) {
767 if (
const auto *Annotate = dyn_cast<AnnotateAttr>(TmplAttr)) {
772 if (
const auto *EnableIf = dyn_cast<EnableIfAttr>(TmplAttr)) {
774 cast<FunctionDecl>(New));
778 if (
const auto *DiagnoseIf = dyn_cast<DiagnoseIfAttr>(TmplAttr)) {
780 cast<FunctionDecl>(New));
784 if (
const auto *CUDALaunchBounds =
785 dyn_cast<CUDALaunchBoundsAttr>(TmplAttr)) {
787 *CUDALaunchBounds, New);
791 if (
const auto *Mode = dyn_cast<ModeAttr>(TmplAttr)) {
796 if (
const auto *OMPAttr = dyn_cast<OMPDeclareSimdDeclAttr>(TmplAttr)) {
801 if (
const auto *OMPAttr = dyn_cast<OMPDeclareVariantAttr>(TmplAttr)) {
806 if (
const auto *AMDGPUFlatWorkGroupSize =
807 dyn_cast<AMDGPUFlatWorkGroupSizeAttr>(TmplAttr)) {
809 *
this, TemplateArgs, *AMDGPUFlatWorkGroupSize, New);
812 if (
const auto *AMDGPUFlatWorkGroupSize =
813 dyn_cast<AMDGPUWavesPerEUAttr>(TmplAttr)) {
815 *AMDGPUFlatWorkGroupSize, New);
818 if (
const auto *AMDGPUMaxNumWorkGroups =
819 dyn_cast<AMDGPUMaxNumWorkGroupsAttr>(TmplAttr)) {
821 *
this, TemplateArgs, *AMDGPUMaxNumWorkGroups, New);
824 if (
const auto *ParamAttr = dyn_cast<HLSLParamModifierAttr>(TmplAttr)) {
831 if (TmplAttr->getKind() == attr::DLLExport ||
832 TmplAttr->getKind() == attr::DLLImport) {
833 if (New->
hasAttr<DLLExportAttr>() || New->
hasAttr<DLLImportAttr>()) {
838 if (
const auto *ABIAttr = dyn_cast<ParameterABIAttr>(TmplAttr)) {
843 if (isa<NSConsumedAttr>(TmplAttr) || isa<OSConsumedAttr>(TmplAttr) ||
844 isa<CFConsumedAttr>(TmplAttr)) {
850 if (
auto *A = dyn_cast<PointerAttr>(TmplAttr)) {
851 if (!New->
hasAttr<PointerAttr>())
856 if (
auto *A = dyn_cast<OwnerAttr>(TmplAttr)) {
857 if (!New->
hasAttr<OwnerAttr>())
862 if (
auto *A = dyn_cast<SYCLKernelAttr>(TmplAttr)) {
867 assert(!TmplAttr->isPackExpansion());
868 if (TmplAttr->isLateParsed() && LateAttrs) {
877 auto *ND = cast<NamedDecl>(New);
878 auto *ThisContext = dyn_cast_or_null<CXXRecordDecl>(ND->getDeclContext());
880 ND->isCXXInstanceMember());
883 *
this, TemplateArgs);
897 for (
const auto *
Attr : Pattern->
attrs()) {
898 if (
auto *A = dyn_cast<StrictFPAttr>(
Attr)) {
899 if (!Inst->
hasAttr<StrictFPAttr>())
916 DLLExportAttr *
Attr = Ctor->
getAttr<DLLExportAttr>();
919 for (
unsigned I = 0; I != NumParams; ++I) {
930template<
typename DeclT>
932 DeclT *
Result = D->getPreviousDecl();
937 if (
Result && isa<CXXRecordDecl>(D->getDeclContext()) &&
938 D->getLexicalDeclContext() !=
Result->getLexicalDeclContext())
946 llvm_unreachable(
"Translation units cannot be instantiated");
950 llvm_unreachable(
"HLSL buffer declarations cannot be instantiated");
955 llvm_unreachable(
"pragma comment cannot be instantiated");
958Decl *TemplateDeclInstantiator::VisitPragmaDetectMismatchDecl(
960 llvm_unreachable(
"pragma comment cannot be instantiated");
965 llvm_unreachable(
"extern \"C\" context cannot be instantiated");
969 llvm_unreachable(
"GUID declaration cannot be instantiated");
972Decl *TemplateDeclInstantiator::VisitUnnamedGlobalConstantDecl(
974 llvm_unreachable(
"UnnamedGlobalConstantDecl cannot be instantiated");
977Decl *TemplateDeclInstantiator::VisitTemplateParamObjectDecl(
979 llvm_unreachable(
"template parameter objects cannot be instantiated");
983TemplateDeclInstantiator::VisitLabelDecl(
LabelDecl *D) {
991TemplateDeclInstantiator::VisitNamespaceDecl(
NamespaceDecl *D) {
992 llvm_unreachable(
"Namespaces cannot be instantiated");
1015 DI = SemaRef.
SubstType(DI, TemplateArgs,
1056 TagDecl *oldTag = oldTagType->getDecl();
1117 if (getPreviousDeclForInstantiation<TypedefNameDecl>(Pattern)) {
1119 if (!Found.
empty()) {
1120 PrevAliasTemplate = dyn_cast<TypeAliasTemplateDecl>(Found.
front());
1133 if (PrevAliasTemplate)
1138 if (!PrevAliasTemplate)
1158 NewBindings.push_back(cast<BindingDecl>(VisitBindingDecl(OldBD)));
1161 auto *NewDD = cast_or_null<DecompositionDecl>(
1164 if (!NewDD || NewDD->isInvalidDecl())
1165 for (
auto *NewBD : NewBindings)
1166 NewBD->setInvalidDecl();
1176 bool InstantiatingVarTemplate,
1187 SemaRef.
Diag(D->
getLocation(), diag::err_variable_instantiates_to_function)
1220 StartingScope, InstantiatingVarTemplate);
1223 if (
auto *F = dyn_cast<FunctionDecl>(DC))
1224 RT = F->getReturnType();
1225 else if (isa<BlockDecl>(DC))
1229 llvm_unreachable(
"Unknown context type");
1266Decl *TemplateDeclInstantiator::VisitFieldDecl(
FieldDecl *D) {
1271 DI = SemaRef.
SubstType(DI, TemplateArgs,
1283 SemaRef.
Diag(D->
getLocation(), diag::err_field_instantiates_to_function)
1294 else if (BitWidth) {
1300 = SemaRef.
SubstExpr(BitWidth, TemplateArgs);
1305 BitWidth = InstantiatedBitWidth.
getAs<
Expr>();
1310 cast<RecordDecl>(Owner),
1323 SemaRef.
InstantiateAttrs(TemplateArgs, D, Field, LateAttrs, StartingScope);
1325 if (
Field->hasAttrs())
1329 Field->setInvalidDecl();
1331 if (!
Field->getDeclName()) {
1336 if (
Parent->isAnonymousStructOrUnion() &&
1337 Parent->getRedeclContext()->isFunctionOrMethod())
1353 SemaRef.
Diag(D->
getLocation(), diag::err_property_is_variably_modified)
1357 DI = SemaRef.
SubstType(DI, TemplateArgs,
1369 SemaRef.
Diag(D->
getLocation(), diag::err_field_instantiates_to_function)
1398 for (
auto *PI : D->
chain()) {
1404 NamedChain[i++] = Next;
1407 QualType T = cast<FieldDecl>(NamedChain[i-1])->getType();
1410 {NamedChain, D->getChainingSize()});
1417 Owner->
addDecl(IndirectField);
1418 return IndirectField;
1433 InstTy = SemaRef.
SubstType(Ty, TemplateArgs,
1448 assert(ND &&
"friend decl must be a decl or a type!");
1455 if (!NewND)
return nullptr;
1474 = SemaRef.
SubstExpr(AssertExpr, TemplateArgs);
1480 if (InstantiatedMessageExpr.
isInvalid())
1488Decl *TemplateDeclInstantiator::VisitEnumDecl(
EnumDecl *D) {
1494 if (!Prev)
return nullptr;
1495 PrevDecl = cast<EnumDecl>(Prev);
1513 Enum->setIntegerTypeSourceInfo(NewTI);
1516 &&
"Dependent type without type source info");
1539 if (Def && Def != D) {
1546 SemaRef.
SubstType(TI->getType(), TemplateArgs,
1549 DefnUnderlying,
true,
Enum);
1570 Enum->startDefinition();
1581 if (
Expr *UninstValue = EC->getInitExpr()) {
1591 if (
Value.isInvalid()) {
1604 Enum->setInvalidDecl();
1611 Enum->addDecl(EnumConst);
1612 Enumerators.push_back(EnumConst);
1613 LastEnumConst = EnumConst;
1616 !
Enum->isScoped()) {
1629 llvm_unreachable(
"EnumConstantDecls can only occur within EnumDecls.");
1634 llvm_unreachable(
"BuiltinTemplateDecls cannot be instantiated.");
1666 if (!Found.
empty()) {
1667 PrevClassTemplate = dyn_cast<ClassTemplateDecl>(Found.
front());
1668 if (PrevClassTemplate)
1681 SS.
Adopt(QualifierLoc);
1683 if (!DC)
return nullptr;
1697 if (R.isSingleResult()) {
1699 if (PrevClassTemplate)
1703 if (!PrevClassTemplate && QualifierLoc) {
1732 if (PrevClassTemplate) {
1763 if (!PrevClassTemplate)
1786 if (!PrevClassTemplate) {
1792 for (
unsigned I = 0, N = PartialSpecs.size(); I != N; ++I)
1793 if (PartialSpecs[I]->getFirstDecl()->isOutOfLine())
1794 OutOfLinePartialSpecs.push_back(std::make_pair(Inst, PartialSpecs[I]));
1801TemplateDeclInstantiator::VisitClassTemplatePartialSpecializationDecl(
1813 = dyn_cast<ClassTemplateDecl>(Found.
front());
1814 if (!InstClassTemplate)
1826 "Only static data member templates are allowed.");
1842 PrevVarTemplate = dyn_cast<VarTemplateDecl>(Found.
front());
1848 if (!VarInst)
return nullptr;
1859 if (!PrevVarTemplate)
1869 if (!PrevVarTemplate) {
1875 for (
unsigned I = 0, N = PartialSpecs.size(); I != N; ++I)
1876 if (PartialSpecs[I]->getFirstDecl()->isOutOfLine())
1877 OutOfLineVarPartialSpecs.push_back(
1878 std::make_pair(Inst, PartialSpecs[I]));
1884Decl *TemplateDeclInstantiator::VisitVarTemplatePartialSpecializationDecl(
1887 "Only static data member templates are allowed.");
1893 assert(!Found.
empty() &&
"Instantiation found nothing?");
1896 assert(InstVarTemplate &&
"Instantiation did not find a variable template?");
1936 assert(InstTemplate &&
1937 "VisitFunctionDecl/CXXMethodDecl didn't create a template!");
1955 return InstTemplate;
1964 if (!Prev)
return nullptr;
1965 PrevDecl = cast<CXXRecordDecl>(Prev);
1979 IsInjectedClassName);
1981 if (IsInjectedClassName)
1997 if (!IsInjectedClassName)
2003 Record->setObjectOfFriendDecl();
2007 Record->setAnonymousStructOrUnion(
true);
2045 LocalInstantiations.perform();
2050 if (IsInjectedClassName)
2051 assert(
Record->isInjectedClassName() &&
"Broken injected-class-name");
2069 if (OrigFunc->
getExtInfo() == NewFunc->getExtInfo())
2075 NewFunc->getParamTypes(), NewEPI);
2089 if (FunctionTemplate && !TemplateParams) {
2092 void *InsertPos =
nullptr;
2102 if (FunctionTemplate)
2107 bool MergeWithParentScope = (TemplateParams !=
nullptr) ||
2109 !(isa<Decl>(Owner) &&
2110 cast<Decl>(Owner)->isDefinedOutsideFunctionOrMethod());
2114 if (
auto *DGuide = dyn_cast<CXXDeductionGuideDecl>(D)) {
2116 TemplateArgs, DGuide->getExplicitSpecifier());
2117 if (InstantiatedExplicitSpecifier.
isInvalid())
2127 if (TemplateParams && TemplateParams->
size()) {
2129 dyn_cast<TemplateTypeParmDecl>(TemplateParams->
asArray().back());
2130 if (LastParam && LastParam->isImplicit() &&
2131 LastParam->hasTypeConstraint()) {
2161 }
else if (isFriend && QualifierLoc) {
2163 SS.
Adopt(QualifierLoc);
2165 if (!DC)
return nullptr;
2178 if (
auto *DGuide = dyn_cast<CXXDeductionGuideDecl>(D)) {
2181 InstantiatedExplicitSpecifier, NameInfo, T, TInfo,
2183 DGuide->getDeductionCandidateKind());
2190 TrailingRequiresClause);
2191 Function->setFriendConstraintRefersToEnclosingTemplate(
2200 Function->setQualifierInfo(QualifierLoc);
2214 Function->setLexicalDeclContext(LexicalDC);
2217 for (
unsigned P = 0;
P < Params.size(); ++
P)
2222 if (TrailingRequiresClause)
2223 Function->setTrailingRequiresClause(TrailingRequiresClause);
2225 if (TemplateParams) {
2244 Function->setDescribedFunctionTemplate(FunctionTemplate);
2252 }
else if (FunctionTemplate &&
2257 Function->setFunctionTemplateSpecialization(FunctionTemplate,
2266 }
else if (!isFriend) {
2270 Function->setInstantiatedFromDecl(D);
2276 FT->setObjectOfFriendDecl();
2282 bool IsExplicitSpecialization =
false;
2293 assert(isFriend &&
"dependent specialization info on "
2294 "non-member non-friend function?");
2298 if (
const auto *ArgsWritten = DFTSI->TemplateArgumentsAsWritten) {
2299 ExplicitArgs.
setLAngleLoc(ArgsWritten->getLAngleLoc());
2300 ExplicitArgs.
setRAngleLoc(ArgsWritten->getRAngleLoc());
2317 DFTSI->TemplateArgumentsAsWritten ? &ExplicitArgs :
nullptr,
2321 IsExplicitSpecialization =
true;
2329 ArgsWritten->getRAngleLoc());
2339 IsExplicitSpecialization =
true;
2340 }
else if (TemplateParams || !FunctionTemplate) {
2356 if (isFriend && !QualifierLoc) {
2376 if (
Function->isLocalExternDecl()) {
2378 if (!PVD->hasDefaultArg())
2384 Expr *UninstExpr = PVD->getUninstantiatedDefaultArg();
2387 { UninstExpr }, UninstExpr->
getType());
2389 PVD->setDefaultArg(ErrorResult.
get());
2395 IsExplicitSpecialization,
2396 Function->isThisDeclarationADefinition());
2402 if (isFriend && TemplateParams && FunctionTemplate->
getPreviousDecl()) {
2406 Function->isThisDeclarationADefinition()
2417 Function->getMemberSpecializationInfo()) {
2418 if (MSInfo->getPointOfInstantiation().isInvalid()) {
2420 MSInfo->setPointOfInstantiation(Loc);
2435 (TemplateParams ? cast<NamedDecl>(FunctionTemplate) :
Function);
2454 if (FunctionTemplate && !TemplateParams) {
2460 void *InsertPos =
nullptr;
2470 if (FunctionTemplate)
2475 bool MergeWithParentScope = (TemplateParams !=
nullptr) ||
2476 !(isa<Decl>(Owner) &&
2477 cast<Decl>(Owner)->isDefinedOutsideFunctionOrMethod());
2485 unsigned NumTempParamLists = 0;
2487 TempParamLists.resize(NumTempParamLists);
2488 for (
unsigned I = 0; I != NumTempParamLists; ++I) {
2493 TempParamLists[I] = InstParams;
2499 const bool CouldInstantiate =
2500 InstantiatedExplicitSpecifier.getExpr() ==
nullptr ||
2501 !InstantiatedExplicitSpecifier.getExpr()->isValueDependent();
2505 if (CouldInstantiate ||
2509 TemplateArgs, InstantiatedExplicitSpecifier);
2511 if (InstantiatedExplicitSpecifier.isInvalid())
2523 if (cast<CXXRecordDecl>(D->
getParent())->isLambda() &&
2525 isa<CXXConstructorDecl, CXXDestructorDecl>(D)) {
2537 if (TemplateParams && TemplateParams->
size()) {
2539 dyn_cast<TemplateTypeParmDecl>(TemplateParams->
asArray().back());
2540 if (LastParam && LastParam->isImplicit() &&
2541 LastParam->hasTypeConstraint()) {
2566 SS.
Adopt(QualifierLoc);
2576 if (!DC)
return nullptr;
2595 InstantiatedExplicitSpecifier, Constructor->UsesFPIntrin(),
2596 Constructor->isInlineSpecified(),
false,
2598 TrailingRequiresClause);
2603 Destructor->UsesFPIntrin(), Destructor->isInlineSpecified(),
false,
2604 Destructor->getConstexprKind(), TrailingRequiresClause);
2613 Conversion->UsesFPIntrin(), Conversion->isInlineSpecified(),
2614 InstantiatedExplicitSpecifier, Conversion->getConstexprKind(),
2615 Conversion->getEndLoc(), TrailingRequiresClause);
2621 D->
getEndLoc(), TrailingRequiresClause);
2630 if (TemplateParams) {
2647 TemplateParams, Method);
2654 }
else if (FunctionTemplate) {
2661 }
else if (!isFriend) {
2670 if (NumTempParamLists)
2681 for (
unsigned P = 0;
P < Params.size(); ++
P)
2682 Params[
P]->setOwningFunction(Method);
2691 bool IsExplicitSpecialization =
false;
2699 if (
const auto *ArgsWritten = DFTSI->TemplateArgumentsAsWritten) {
2700 ExplicitArgs.
setLAngleLoc(ArgsWritten->getLAngleLoc());
2701 ExplicitArgs.
setRAngleLoc(ArgsWritten->getRAngleLoc());
2717 Method, DFTSI->TemplateArgumentsAsWritten ? &ExplicitArgs :
nullptr,
2721 IsExplicitSpecialization =
true;
2727 ArgsWritten->getRAngleLoc());
2738 IsExplicitSpecialization =
true;
2739 }
else if (!FunctionTemplate || TemplateParams || isFriend) {
2766 for (
unsigned P = 0;
P < Params.size(); ++
P) {
2767 if (!Params[
P]->hasDefaultArg())
2773 Expr *UninstExpr = Params[
P]->getUninstantiatedDefaultArg();
2776 { UninstExpr }, UninstExpr->
getType());
2778 Params[
P]->setDefaultArg(ErrorResult.
get());
2784 IsExplicitSpecialization,
2797 if (FunctionTemplate)
2813 if (IsExplicitSpecialization && !isFriend)
2823 if (
auto *Constructor = dyn_cast<CXXConstructorDecl>(Method)) {
2824 if (Constructor->isDefaultConstructor() ||
2825 Constructor->isCopyOrMoveConstructor())
2833 if (FunctionTemplate) {
2841 }
else if (isFriend) {
2847 Record->makeDeclVisibleInContext(Method);
2858 if (Method->
hasAttr<UsedAttr>()) {
2859 if (
const auto *A = dyn_cast<CXXRecordDecl>(Owner)) {
2862 A->getMemberSpecializationInfo())
2863 Loc = MSInfo->getPointOfInstantiation();
2864 else if (
const auto *Spec = dyn_cast<ClassTemplateSpecializationDecl>(A))
2865 Loc = Spec->getPointOfInstantiation();
2891Decl *TemplateDeclInstantiator::VisitTemplateTypeParmDecl(
2895 std::optional<unsigned> NumExpanded;
2899 assert(TC->getTemplateArgsAsWritten() &&
2900 "type parameter can only be an expansion when explicit arguments "
2906 for (
auto &ArgLoc : TC->getTemplateArgsAsWritten()->arguments())
2912 bool RetainExpansion =
false;
2914 cast<CXXFoldExpr>(TC->getImmediatelyDeclaredConstraint())
2917 TC->hasExplicitTemplateArgs() ?
2918 TC->getTemplateArgsAsWritten()->getRAngleLoc() :
2919 TC->getConceptNameInfo().getEndLoc()),
2920 Unexpanded, TemplateArgs, Expand, RetainExpansion, NumExpanded))
2939 EvaluateConstraints))
2947 if (InstantiatedDefaultArg)
2958Decl *TemplateDeclInstantiator::VisitNonTypeTemplateParmDecl(
2964 bool IsExpandedParameterPack =
false;
2986 ExpandedParameterPackTypesAsWritten.push_back(NewDI);
2987 ExpandedParameterPackTypes.push_back(NewT);
2990 IsExpandedParameterPack =
true;
3005 bool RetainExpansion =
false;
3006 std::optional<unsigned> OrigNumExpansions =
3008 std::optional<unsigned> NumExpansions = OrigNumExpansions;
3010 Pattern.getSourceRange(),
3013 Expand, RetainExpansion,
3018 for (
unsigned I = 0; I != *NumExpansions; ++I) {
3031 ExpandedParameterPackTypesAsWritten.push_back(NewDI);
3032 ExpandedParameterPackTypes.push_back(NewT);
3038 IsExpandedParameterPack =
true;
3075 if (IsExpandedParameterPack)
3080 ExpandedParameterPackTypesAsWritten);
3088 if (AutoLoc.isConstrained()) {
3090 if (IsExpandedParameterPack)
3093 else if (
auto *Constraint = dyn_cast_if_present<CXXFoldExpr>(
3095 EllipsisLoc = Constraint->getEllipsisLoc();
3113 if (!
Value.isInvalid())
3127 for (
const auto &
P : *Params) {
3128 if (
P->isTemplateParameterPack())
3140TemplateDeclInstantiator::VisitTemplateTemplateParmDecl(
3147 bool IsExpandedParameterPack =
false;
3161 ExpandedParams.push_back(Expansion);
3164 IsExpandedParameterPack =
true;
3165 InstParams = TempParams;
3177 bool RetainExpansion =
false;
3178 std::optional<unsigned> NumExpansions;
3183 Expand, RetainExpansion,
3188 for (
unsigned I = 0; I != *NumExpansions; ++I) {
3194 ExpandedParams.push_back(Expansion);
3200 IsExpandedParameterPack =
true;
3201 InstParams = TempParams;
3223 if (IsExpandedParameterPack)
3284 for (
auto *Shadow : D->
shadows()) {
3288 NamedDecl *OldTarget = Shadow->getTargetDecl();
3289 if (
auto *CUSD = dyn_cast<ConstructorUsingShadowDecl>(Shadow))
3290 if (
auto *BaseShadow = CUSD->getNominatedBaseClassShadowDecl())
3291 OldTarget = BaseShadow;
3295 dyn_cast<UnresolvedUsingIfExistsDecl>(Shadow->getTargetDecl())) {
3297 SemaRef.
Context, Owner, EmptyD->getLocation(), EmptyD->getDeclName());
3300 Shadow->getLocation(), OldTarget, TemplateArgs));
3312 Shadow->getLocation(), OldPrev, TemplateArgs));
3315 nullptr, Inst, InstTarget, PrevDecl);
3318 if (isFunctionScope)
3325Decl *TemplateDeclInstantiator::VisitUsingDecl(
UsingDecl *D) {
3346 if (
auto *RD = dyn_cast<CXXRecordDecl>(SemaRef.
CurContext))
3352 bool CheckRedeclaration = Owner->
isRecord();
3363 SS.
Adopt(QualifierLoc);
3364 if (CheckRedeclaration) {
3365 Prev.setHideTags(
false);
3430Decl *TemplateDeclInstantiator::VisitConstructorUsingShadowDecl(
3436template <
typename T>
3437Decl *TemplateDeclInstantiator::instantiateUnresolvedUsingDecl(
3438 T *D,
bool InstantiatingPackElement) {
3440 if (D->isPackExpansion() && !InstantiatingPackElement) {
3448 bool RetainExpansion =
false;
3449 std::optional<unsigned> NumExpansions;
3451 D->getEllipsisLoc(), D->getSourceRange(), Unexpanded, TemplateArgs,
3452 Expand, RetainExpansion, NumExpansions))
3457 assert(!RetainExpansion &&
3458 "should never need to retain an expansion for UsingPackDecl");
3464 return instantiateUnresolvedUsingDecl(D,
true);
3474 if (D->getDeclContext()->isFunctionOrMethod() && *NumExpansions > 1) {
3475 SemaRef.
Diag(D->getEllipsisLoc(),
3476 diag::err_using_decl_redeclaration_expansion);
3482 for (
unsigned I = 0; I != *NumExpansions; ++I) {
3484 Decl *Slice = instantiateUnresolvedUsingDecl(D,
true);
3491 Expansions.push_back(cast<NamedDecl>(Slice));
3510 SS.
Adopt(QualifierLoc);
3517 bool InstantiatingSlice = D->getEllipsisLoc().isValid() &&
3522 bool IsUsingIfExists = D->template hasAttr<UsingIfExistsAttr>();
3524 nullptr, D->getAccess(), D->getUsingLoc(),
3525 TD, TypenameLoc, SS, NameInfo, EllipsisLoc,
3527 true, IsUsingIfExists);
3536Decl *TemplateDeclInstantiator::VisitUnresolvedUsingTypenameDecl(
3538 return instantiateUnresolvedUsingDecl(D);
3541Decl *TemplateDeclInstantiator::VisitUnresolvedUsingValueDecl(
3543 return instantiateUnresolvedUsingDecl(D);
3546Decl *TemplateDeclInstantiator::VisitUnresolvedUsingIfExistsDecl(
3548 llvm_unreachable(
"referring to unresolved decl out of UsingShadowDecl");
3556 Expansions.push_back(NewUD);
3567Decl *TemplateDeclInstantiator::VisitOMPThreadPrivateDecl(
3572 assert(isa<DeclRefExpr>(Var) &&
"threadprivate arg is not a DeclRefExpr");
3573 Vars.push_back(Var);
3589 assert(isa<DeclRefExpr>(Var) &&
"allocate arg is not a DeclRefExpr");
3590 Vars.push_back(Var);
3596 if (
auto *AC = dyn_cast<OMPAllocatorClause>(
C)) {
3601 NewE.
get(), AC->getBeginLoc(), AC->getLParenLoc(), AC->getEndLoc());
3602 }
else if (
auto *AC = dyn_cast<OMPAlignClause>(
C)) {
3607 AC->getLParenLoc(), AC->getEndLoc());
3612 Clauses.push_back(IC);
3617 if (Res.
get().isNull())
3619 return Res.
get().getSingleDecl();
3624 "Requires directive cannot be instantiated within a dependent context");
3627Decl *TemplateDeclInstantiator::VisitOMPDeclareReductionDecl(
3630 const bool RequiresInstantiation =
3635 if (RequiresInstantiation) {
3641 SubstReductionType = D->
getType();
3643 if (SubstReductionType.
isNull())
3647 bool IsCorrect =
true;
3649 std::pair<QualType, SourceLocation> ReductionTypes[] = {
3650 std::make_pair(SubstReductionType, D->
getLocation())};
3652 if (PrevDeclInScope && !PrevDeclInScope->isInvalidDecl()) {
3653 PrevDeclInScope = cast<OMPDeclareReductionDecl>(
3660 auto *NewDRD = cast<OMPDeclareReductionDecl>(DRD.get().getSingleDecl());
3662 Expr *SubstCombiner =
nullptr;
3663 Expr *SubstInitializer =
nullptr;
3670 cast<DeclRefExpr>(NewDRD->getCombinerIn())->getDecl());
3673 cast<DeclRefExpr>(NewDRD->getCombinerOut())->getDecl());
3674 auto *ThisContext = dyn_cast_or_null<CXXRecordDecl>(Owner);
3677 SubstCombiner = SemaRef.
SubstExpr(Combiner, TemplateArgs).
get();
3686 cast<DeclRefExpr>(NewDRD->getInitOrig())->getDecl());
3689 cast<DeclRefExpr>(NewDRD->getInitPriv())->getDecl());
3694 cast<VarDecl>(cast<DeclRefExpr>(D->
getInitPriv())->getDecl());
3695 IsCorrect = IsCorrect && OldPrivParm->hasInit();
3703 IsCorrect = IsCorrect && SubstCombiner &&
3706 SubstInitializer) ||
3708 !SubstInitializer));
3719 const bool RequiresInstantiation =
3725 if (RequiresInstantiation) {
3733 if (SubstMapperTy.
isNull())
3737 if (PrevDeclInScope && !PrevDeclInScope->isInvalidDecl()) {
3738 PrevDeclInScope = cast<OMPDeclareMapperDecl>(
3742 bool IsCorrect =
true;
3753 cast<DeclRefExpr>(MapperVarRef.
get())->getDecl());
3754 auto *ThisContext = dyn_cast_or_null<CXXRecordDecl>(Owner);
3759 auto *OldC = cast<OMPMapClause>(
C);
3761 for (
Expr *OE : OldC->varlists()) {
3767 NewVars.push_back(NE);
3775 SS.
Adopt(NewQualifierLoc);
3781 OldC->getIteratorModifier(), OldC->getMapTypeModifiers(),
3782 OldC->getMapTypeModifiersLoc(), SS, NewNameInfo, OldC->getMapType(),
3783 OldC->isImplicitMapType(), OldC->getMapLoc(), OldC->getColonLoc(),
3785 Clauses.push_back(NewC);
3792 VN, D->
getAccess(), MapperVarRef.
get(), Clauses, PrevDeclInScope);
3793 Decl *NewDMD = DG.
get().getSingleDecl();
3798Decl *TemplateDeclInstantiator::VisitOMPCapturedExprDecl(
3800 llvm_unreachable(
"Should not be met in templates");
3820 llvm_unreachable(
"There are only CXXRecordDecls in C++");
3824TemplateDeclInstantiator::VisitClassTemplateSpecializationDecl(
3831 "can only instantiate an explicit specialization "
3832 "for a member class template");
3839 if (!InstClassTemplate)
3845 castAs<TemplateSpecializationTypeLoc>();
3849 for (
unsigned I = 0; I != Loc.
getNumArgs(); ++I)
3858 InstTemplateArgs,
false,
3859 SugaredConverted, CanonicalConverted,
3865 void *InsertPos =
nullptr;
3897 diag::note_previous_definition);
3905 D->
getLocation(), InstClassTemplate, CanonicalConverted, PrevDecl);
3960 assert(VarTemplate &&
3961 "A template specialization without specialized template?");
3966 if (!InstVarTemplate)
3972 VarTemplateArgsInfo.
setLAngleLoc(TemplateArgsInfo->getLAngleLoc());
3973 VarTemplateArgsInfo.
setRAngleLoc(TemplateArgsInfo->getRAngleLoc());
3976 TemplateArgs, VarTemplateArgsInfo))
3983 VarTemplateArgsInfo,
false,
3984 SugaredConverted, CanonicalConverted,
3989 void *InsertPos =
nullptr;
4003 InstVarTemplate, D, VarTemplateArgsInfo, CanonicalConverted, PrevDecl);
4020 SemaRef.
Diag(D->
getLocation(), diag::err_variable_instantiates_to_function)
4031 void *InsertPos =
nullptr;
4044 StartingScope,
false, PrevDecl);
4050 llvm_unreachable(
"@defs is not supported in Objective-C++");
4057 "cannot instantiate %0 yet");
4065 llvm_unreachable(
"Concept definitions cannot reside inside a template");
4068Decl *TemplateDeclInstantiator::VisitImplicitConceptSpecializationDecl(
4070 llvm_unreachable(
"Concept specializations cannot reside inside a template");
4080 llvm_unreachable(
"Unexpected decl");
4091 SubstD = Instantiator.Visit(D);
4106 SemaRef.
Context.
BoolTy, FPT->getParamTypes(), FPT->getExtProtoInfo());
4117 assert(OldLoc &&
"type of function is not a function type?");
4119 for (
unsigned I = 0, N = OldLoc.getNumParams(); I != N; ++I)
4120 NewLoc.
setParam(I, OldLoc.getParam(I));
4130 if (Spaceship->isInvalidDecl())
4142 if (
auto *MD = dyn_cast<CXXMethodDecl>(Spaceship)) {
4147 assert(Spaceship->getFriendObjectKind() &&
4148 "defaulted spaceship is neither a member nor a friend");
4158 cast<NamedDecl>(R), Spaceship->getBeginLoc());
4162 return cast_or_null<FunctionDecl>(R);
4176 unsigned N = L->
size();
4180 for (
auto &
P : *L) {
4182 Params.push_back(D);
4202 bool EvaluateConstraints) {
4249 ClassTemplate, PartialSpec->
getLocation(), InstTemplateArgs,
4250 false, SugaredConverted, CanonicalConverted))
4256 CanonicalConverted))
4261 void *InsertPos =
nullptr;
4301 SemaRef.
Diag(PartialSpec->
getLocation(), diag::err_partial_spec_redeclared)
4303 SemaRef.
Diag(PrevDecl->
getLocation(), diag::note_prev_partial_spec_here)
4314 ClassTemplate, CanonicalConverted, InstTemplateArgs, CanonType,
4330 return InstPartialSpec;
4374 VarTemplate, PartialSpec->
getLocation(), InstTemplateArgs,
4375 false, SugaredConverted, CanonicalConverted))
4381 CanonicalConverted))
4386 void *InsertPos =
nullptr;
4424 diag::err_var_partial_spec_redeclared)
4427 diag::note_var_prev_partial_spec_here);
4440 diag::err_variable_instantiates_to_function)
4468 LateAttrs, Owner, StartingScope);
4470 return InstPartialSpec;
4477 assert(OldTInfo &&
"substituting function without type source info");
4478 assert(Params.empty() &&
"parameter vector is non-empty at start");
4483 ThisContext = cast<CXXRecordDecl>(Owner);
4484 ThisTypeQuals = Method->getFunctionObjectParameterType().getQualifiers();
4489 ThisContext, ThisTypeQuals, EvaluateConstraints);
4495 if (NewTInfo != OldTInfo) {
4499 unsigned NewIdx = 0;
4500 for (
unsigned OldIdx = 0, NumOldParams = OldProtoLoc.getNumParams();
4501 OldIdx != NumOldParams; ++OldIdx) {
4502 ParmVarDecl *OldParam = OldProtoLoc.getParam(OldIdx);
4508 std::optional<unsigned> NumArgumentsInExpansion;
4510 NumArgumentsInExpansion =
4513 if (!NumArgumentsInExpansion) {
4517 Params.push_back(NewParam);
4518 Scope->InstantiatedLocal(OldParam, NewParam);
4521 Scope->MakeInstantiatedLocalArgPack(OldParam);
4522 for (
unsigned I = 0; I != *NumArgumentsInExpansion; ++I) {
4524 Params.push_back(NewParam);
4525 Scope->InstantiatedLocalPackArg(OldParam, NewParam);
4534 cast<FunctionProtoType>(OldProtoLoc.getType());
4535 for (
unsigned i = 0, i_end = OldProtoLoc.getNumParams(); i != i_end;
4545 cast_or_null<ParmVarDecl>(VisitParmVarDecl(OldParam));
4548 Params.push_back(Parm);
4565 TemplateArgs, ParamTypes, &Params,
4580 for (
auto *
decl : PatternDecl->
decls()) {
4581 if (!isa<VarDecl>(
decl) || isa<ParmVarDecl>(
decl))
4587 auto it = llvm::find_if(
Function->decls(), [&](
Decl *inst) {
4588 VarDecl *InstVD = dyn_cast<VarDecl>(inst);
4589 return InstVD && InstVD->isLocalVarDecl() &&
4590 InstVD->getIdentifier() == II;
4596 Scope.InstantiatedLocal(VD, *it);
4597 LSI->
addCapture(cast<VarDecl>(*it),
false,
false,
4606bool Sema::addInstantiatedParametersToScope(
4610 unsigned FParamIdx = 0;
4611 for (
unsigned I = 0, N = PatternDecl->
getNumParams(); I != N; ++I) {
4615 assert(FParamIdx < Function->getNumParams());
4633 Scope.InstantiatedLocal(PatternParam, FunctionParam);
4639 Scope.MakeInstantiatedLocalArgPack(PatternParam);
4640 std::optional<unsigned> NumArgumentsInExpansion =
4642 if (NumArgumentsInExpansion) {
4645 for (
unsigned Arg = 0; Arg < *NumArgumentsInExpansion; ++Arg) {
4658 Scope.InstantiatedLocalPackArg(PatternParam, FunctionParam);
4690 false, std::nullopt,
4697 L->DefaultArgumentInstantiated(Param);
4719 Diag(PointOfInstantiation, diag::err_exception_spec_cycle) <<
Decl;
4731 false, std::nullopt,
4739 if (addInstantiatedParametersToScope(
Decl, Template,
Scope, TemplateArgs)) {
4773 if (ActiveInst.Kind == ActiveInstType::ExplicitTemplateArgumentSubstitution ||
4774 ActiveInst.Kind == ActiveInstType::DeducedTemplateArgumentSubstitution) {
4775 if (isa<FunctionTemplateDecl>(ActiveInst.Entity)) {
4777 {ActiveInst.Entity->getCanonicalDecl(), ActiveInst.Kind});
4779 ActiveInst.Kind = ActiveInstType::TemplateInstantiation;
4780 ActiveInst.Entity = New;
4786 assert(Proto &&
"Function template without prototype?");
4810 assert(NewProto &&
"Template instantiation without function prototype?");
4828 LateAttrs, StartingScope);
4844 if (isa<CXXDestructorDecl>(New) && SemaRef.
getLangOpts().CPlusPlus11)
4860 Lookups.reserve(DFI->getUnqualifiedLookups().size());
4861 bool AnyChanged =
false;
4864 DA.getDecl(), TemplateArgs);
4867 AnyChanged |= (D != DA.getDecl());
4925 bool DefinitionRequired,
4933 Function->getTemplateSpecializationKindForInstantiation();
4940 !DefinitionRequired)
4945 if (
Function->isDefined(ExistingDefn,
4959 assert(PatternDecl &&
"instantiating a non-template");
4962 Stmt *Pattern =
nullptr;
4964 Pattern = PatternDef->
getBody(PatternDef);
4965 PatternDecl = PatternDef;
4967 PatternDef =
nullptr;
4973 Function->getInstantiatedFromMemberFunction(),
4974 PatternDecl, PatternDef, TSK,
4975 DefinitionRequired)) {
4976 if (DefinitionRequired)
4979 (
Function->isConstexpr() && !Recursive)) {
4983 Function->setInstantiationIsPending(
true);
4985 std::make_pair(
Function, PointOfInstantiation));
4989 Diag(PointOfInstantiation, diag::warn_func_template_missing)
4993 Diag(PointOfInstantiation, diag::note_inst_declaration_hint)
5004 Function->setInstantiationIsPending(
true);
5006 std::make_pair(
Function, PointOfInstantiation));
5010 llvm::TimeTraceScope TimeScope(
"InstantiateFunction", [&]() {
5012 llvm::raw_string_ostream
OS(Name);
5037 "missing LateParsedTemplate");
5039 Pattern = PatternDecl->
getBody(PatternDecl);
5046 "unexpected kind of function template definition");
5061 for (
auto *D =
Function->getMostRecentDecl(); ;
5063 D->setImplicitlyInline();
5073 "instantiating function definition");
5077 Function->setVisibleDespiteOwningModule();
5093 bool MergeWithParentScope =
false;
5095 MergeWithParentScope =
5096 Rec->isLocalClass() && !
Function->isFunctionTemplateSpecialization();
5099 auto RebuildTypeSourceInfoForDefaultSpecialMembers = [&]() {
5105 "Special member needs to be defaulted");
5113 auto *NewRec = dyn_cast<CXXRecordDecl>(
Function->getDeclContext());
5114 const auto *PatternRec =
5116 if (!NewRec || !PatternRec)
5118 if (!PatternRec->isLambda())
5121 struct SpecialMemberTypeInfoRebuilder
5143 return Base::TransformRecordType(TLB, TL);
5145 QualType Result = getDerived().RebuildRecordType(NewDecl);
5146 if (Result.isNull())
5153 } IR{*
this, PatternRec, NewRec};
5156 assert(NewSI &&
"Type Transform failed?");
5158 Function->setTypeSourceInfo(NewSI);
5167 RebuildTypeSourceInfoForDefaultSpecialMembers();
5172 std::nullopt,
false, PatternDecl);
5190 if (addInstantiatedParametersToScope(
Function, PatternDecl,
Scope,
5207 Ctor->isDefaultConstructor()) {
5213 Body =
SubstStmt(Pattern, TemplateArgs);
5225 Listener->FunctionDefinitionInstantiated(
Function);
5235 LocalInstantiations.
perform();
5237 GlobalInstantiations.perform();
5263 bool IsMemberSpec =
false;
5265 if (
auto *PartialSpec =
5266 dyn_cast<VarTemplatePartialSpecializationDecl>(FromVar)) {
5267 assert(PartialSpecArgs);
5268 IsMemberSpec = PartialSpec->isMemberSpecialization();
5270 PartialSpec, PartialSpecArgs->
asArray(),
false);
5273 IsMemberSpec =
VarTemplate->isMemberSpecialization();
5285 return cast_or_null<VarTemplateSpecializationDecl>(
5287 VarTemplate, FromVar, TemplateArgsInfo, Converted));
5296 "don't have a definition to instantiate from");
5328 bool InstantiatingVarTemplate,
5332 bool InstantiatingVarTemplatePartialSpec =
5333 isa<VarTemplatePartialSpecializationDecl>(OldVar) &&
5334 isa<VarTemplatePartialSpecializationDecl>(NewVar);
5337 bool InstantiatingSpecFromTemplate =
5338 isa<VarTemplateSpecializationDecl>(NewVar) &&
5340 isa<VarTemplatePartialSpecializationDecl>(OldVar));
5363 if (OldVar->
isUsed(
false))
5385 }
else if (!isa<VarTemplateSpecializationDecl>(NewVar) &&
5388 }
else if (PrevDeclForVarTemplateSpecialization) {
5389 Previous.addDecl(PrevDeclForVarTemplateSpecialization);
5393 if (!InstantiatingVarTemplate) {
5411 !InstantiatingSpecFromTemplate)
5418 dyn_cast<VarTemplateSpecializationDecl>(OldVar)) {
5420 !isa<VarTemplatePartialSpecializationDecl>(OldVTSD))
5421 cast<VarTemplateSpecializationDecl>(NewVar)->setSpecializationKind(
5430 if (InstantiatingVarTemplate || InstantiatingVarTemplatePartialSpec) {
5435 }
else if (InstantiatingSpecFromTemplate ||
5458 L->VariableDefinitionInstantiated(Var);
5483 if (!
Init.isInvalid()) {
5486 if (Var->
hasAttr<DLLImportAttr>() &&
5490 }
else if (InitExpr) {
5541 bool DefinitionRequired,
bool AtEndOfTU) {
5553 assert(PatternDecl &&
"no pattern for templated variable");
5558 dyn_cast<VarTemplateSpecializationDecl>(Var);
5569 (PatternDecl = PatternDecl->
getFirstDecl())->hasInit() &&
5577 "instantiating variable initializer");
5595 PreviousContext.
pop();
5599 LocalInstantiations.
perform();
5601 GlobalInstantiations.
perform();
5605 "not a static data member?");
5614 if (!Def && !DefinitionRequired) {
5617 std::make_pair(Var, PointOfInstantiation));
5622 Diag(PointOfInstantiation, diag::warn_var_template_missing)
5626 Diag(PointOfInstantiation, diag::note_inst_declaration_hint) << Var;
5637 PatternDecl, Def, TSK,
5638 DefinitionRequired))
5655 struct PassToConsumerRAII {
5660 : Consumer(Consumer), Var(Var) { }
5662 ~PassToConsumerRAII() {
5665 } PassToConsumerRAII(
Consumer, Var);
5672 PointOfInstantiation);
5680 "instantiating variable definition");
5700 }
else if (!VarSpec) {
5729 cast<VarTemplateSpecializationDecl>(Var)->setInstantiationOf(
5740 PreviousContext.
pop();
5743 PassToConsumerRAII.Var = Var;
5750 LocalInstantiations.
perform();
5752 GlobalInstantiations.
perform();
5764 for (
const auto *
Init : Tmpl->
inits()) {
5767 if (!
Init->isWritten())
5772 if (
Init->isPackExpansion()) {
5774 TypeLoc BaseTL =
Init->getTypeSourceInfo()->getTypeLoc();
5778 bool ShouldExpand =
false;
5779 bool RetainExpansion =
false;
5780 std::optional<unsigned> NumExpansions;
5784 TemplateArgs, ShouldExpand,
5791 assert(ShouldExpand &&
"Partial instantiation of base initializer?");
5794 for (
unsigned I = 0; I != *NumExpansions; ++I) {
5808 Init->getSourceLocation(),
5817 BaseTInfo, TempInit.
get(),
5825 NewInits.push_back(NewInit.
get());
5840 if (
Init->isDelegatingInitializer() ||
Init->isBaseInitializer()) {
5843 Init->getSourceLocation(),
5851 if (
Init->isBaseInitializer())
5857 }
else if (
Init->isMemberInitializer()) {
5859 Init->getMemberLocation(),
5869 Init->getSourceLocation());
5870 }
else if (
Init->isIndirectMemberInitializer()) {
5873 Init->getMemberLocation(),
5874 Init->getIndirectMember(), TemplateArgs));
5876 if (!IndirectMember) {
5883 Init->getSourceLocation());
5890 NewInits.push_back(NewInit.
get());
5909 Instance = Instance->getCanonicalDecl();
5910 if (Pattern == Instance)
return true;
5911 Instance = Instance->getInstantiatedFromMemberTemplate();
5922 Instance = Instance->getCanonicalDecl();
5923 if (Pattern == Instance)
return true;
5924 Instance = Instance->getInstantiatedFromMemberTemplate();
5934 = cast<ClassTemplatePartialSpecializationDecl>(Pattern->
getCanonicalDecl());
5936 Instance = cast<ClassTemplatePartialSpecializationDecl>(
5937 Instance->getCanonicalDecl());
5938 if (Pattern == Instance)
5940 Instance = Instance->getInstantiatedFromMember();
5951 Instance = Instance->getCanonicalDecl();
5952 if (Pattern == Instance)
return true;
5953 Instance = Instance->getInstantiatedFromMemberClass();
5964 Instance = Instance->getCanonicalDecl();
5965 if (Pattern == Instance)
return true;
5966 Instance = Instance->getInstantiatedFromMemberFunction();
5977 Instance = Instance->getCanonicalDecl();
5978 if (Pattern == Instance)
return true;
5979 Instance = Instance->getInstantiatedFromMemberEnum();
6006 bool OtherIsPackExpansion;
6008 if (
auto *OtherUUD = dyn_cast<T>(
Other)) {
6009 OtherIsPackExpansion = OtherUUD->isPackExpansion();
6011 }
else if (
auto *OtherUPD = dyn_cast<UsingPackDecl>(
Other)) {
6012 OtherIsPackExpansion =
true;
6013 OtherFrom = OtherUPD->getInstantiatedFromUsingDecl();
6014 }
else if (
auto *OtherUD = dyn_cast<UsingDecl>(
Other)) {
6015 OtherIsPackExpansion =
false;
6020 return Pattern->isPackExpansion() == OtherIsPackExpansion &&
6026 assert(Instance->isStaticDataMember());
6031 Instance = Instance->getCanonicalDecl();
6032 if (Pattern == Instance)
return true;
6033 Instance = Instance->getInstantiatedFromStaticDataMember();
6042 if (
auto *UUD = dyn_cast<UnresolvedUsingTypenameDecl>(D))
6045 if (
auto *UUD = dyn_cast<UnresolvedUsingValueDecl>(D))
6051 if (
auto *
Record = dyn_cast<CXXRecordDecl>(
Other))
6057 if (
auto *
Enum = dyn_cast<EnumDecl>(
Other))
6060 if (
auto *Var = dyn_cast<VarDecl>(
Other))
6064 if (
auto *Temp = dyn_cast<ClassTemplateDecl>(
Other))
6067 if (
auto *Temp = dyn_cast<FunctionTemplateDecl>(
Other))
6070 if (
auto *PartialSpec =
6071 dyn_cast<ClassTemplatePartialSpecializationDecl>(
Other))
6075 if (
auto *Field = dyn_cast<FieldDecl>(
Other)) {
6076 if (!Field->getDeclName()) {
6079 cast<FieldDecl>(D));
6083 if (
auto *Using = dyn_cast<UsingDecl>(
Other))
6086 if (
auto *Shadow = dyn_cast<UsingShadowDecl>(
Other))
6093template<
typename ForwardIterator>
6096 ForwardIterator first,
6097 ForwardIterator last) {
6098 for (; first != last; ++first)
6100 return cast<NamedDecl>(*first);
6111 if (
NamedDecl *D = dyn_cast<NamedDecl>(DC)) {
6113 return cast_or_null<DeclContext>(ID);
6128 return cast<Decl>(DC)->getTemplateDepth() > Level;
6159 bool FindingInstantiatedContext) {
6181 if (isa<ParmVarDecl>(D) && !ParentDependsOnArgs &&
6182 !cast<ParmVarDecl>(D)->getType()->isInstantiationDependentType())
6184 if (isa<ParmVarDecl>(D) || isa<NonTypeTemplateParmDecl>(D) ||
6185 isa<TemplateTypeParmDecl>(D) || isa<TemplateTemplateParmDecl>(D) ||
6187 isa<OMPDeclareReductionDecl>(ParentDC) ||
6188 isa<OMPDeclareMapperDecl>(ParentDC))) ||
6189 (isa<CXXRecordDecl>(D) && cast<CXXRecordDecl>(D)->isLambda() &&
6190 cast<CXXRecordDecl>(D)->getTemplateDepth() >
6196 if (
Decl *FD = Found->dyn_cast<
Decl *>())
6197 return cast<NamedDecl>(FD);
6200 assert(PackIdx != -1 &&
6201 "found declaration pack but not pack expanding");
6203 return cast<NamedDecl>((*Found->get<DeclArgumentPack *>())[PackIdx]);
6210 if (isa<NonTypeTemplateParmDecl>(D) || isa<TemplateTypeParmDecl>(D) ||
6211 isa<TemplateTemplateParmDecl>(D))
6230 bool NeedInstantiate =
false;
6232 NeedInstantiate = RD->isLocalClass();
6233 else if (isa<TypedefNameDecl>(D) &&
6235 NeedInstantiate =
true;
6237 NeedInstantiate = isa<EnumDecl>(D);
6238 if (NeedInstantiate) {
6241 return cast<TypeDecl>(Inst);
6246 assert(isa<LabelDecl>(D));
6249 assert(Inst &&
"Failed to instantiate label??");
6252 return cast<LabelDecl>(Inst);
6256 if (!
Record->isDependentContext())
6265 dyn_cast<ClassTemplateSpecializationDecl>(
Record))
6266 ClassTemplate = Spec->getSpecializedTemplate()->getCanonicalDecl();
6277 if (
CXXRecordDecl *InstRecord = dyn_cast<CXXRecordDecl>(DC)) {
6281 = dyn_cast<ClassTemplateSpecializationDecl>(InstRecord)){
6301 auto *Guide = dyn_cast<CXXDeductionGuideDecl>(FD);
6302 if (Guide && Guide->isImplicit()) {
6310 Unpacked = Arg.pack_elements();
6335 if (FindingInstantiatedContext &&
6337 Loc, cast<ClassTemplateSpecializationDecl>(SubstRecord))) {
6338 Diag(Loc, diag::err_specialization_not_primary_template)
6355 if (!ParentDependsOnArgs)
6369 bool IsBeingInstantiated =
false;
6370 if (
CXXRecordDecl *Spec = dyn_cast<CXXRecordDecl>(ParentDC)) {
6371 if (!Spec->isDependentContext()) {
6374 assert(Tag &&
"type of non-dependent record is not a RecordType");
6376 IsBeingInstantiated =
true;
6413 if (isa<UsingShadowDecl>(D)) {
6420 }
else if (IsBeingInstantiated) {
6426 Diag(Loc, diag::err_member_not_yet_instantiated)
6434 EnumDecl *
Enum = cast<EnumDecl>(ED->getLexicalDeclContext());
6439 Diag(Loc, diag::err_enumerator_does_not_exist)
6446 llvm_unreachable(
"Unable to find instantiation of declaration!");
6459 std::deque<PendingImplicitInstantiation> delayedPCHInstantiations;
6474 bool DefinitionRequired =
Function->getTemplateSpecializationKind() ==
6480 DefinitionRequired,
true);
6486 DefinitionRequired,
true);
6488 Function->setInstantiationIsPending(
false);
6491 if (!LocalOnly &&
LangOpts.PCHInstantiateTemplates &&
6493 delayedPCHInstantiations.push_back(Inst);
6498 VarDecl *Var = cast<VarDecl>(Inst.first);
6501 isa<VarTemplateSpecializationDecl>(Var)) &&
6502 "Not a static data member, nor a variable template"
6503 " specialization?");
6515 llvm_unreachable(
"Cannot instantitiate an undeclared specialization.");
6530 "instantiating variable definition");
6537 DefinitionRequired,
true);
6540 if (!LocalOnly &&
LangOpts.PCHInstantiateTemplates)
6546 for (
auto *DD : Pattern->
ddiags()) {
6547 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
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 bool isDependentContextAtLevel(DeclContext *DC, unsigned Level)
Determine whether the given context is dependent on template parameters at level Level or below.
static void instantiateDependentModeAttr(Sema &S, const MultiLevelTemplateArgumentList &TemplateArgs, const ModeAttr &Attr, Decl *New)
static void instantiateDependentCUDALaunchBoundsAttr(Sema &S, const MultiLevelTemplateArgumentList &TemplateArgs, const CUDALaunchBoundsAttr &Attr, Decl *New)
static bool isDeclWithinFunction(const Decl *D)
static void instantiateDependentAssumeAlignedAttr(Sema &S, const MultiLevelTemplateArgumentList &TemplateArgs, const AssumeAlignedAttr *Aligned, Decl *New)
static bool SubstQualifier(Sema &SemaRef, const DeclT *OldDecl, DeclT *NewDecl, const MultiLevelTemplateArgumentList &TemplateArgs)
static void collectUnexpandedParameterPacks(Sema &S, TemplateParameterList *Params, SmallVectorImpl< UnexpandedParameterPack > &Unexpanded)
static 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 instantiateDependentSYCLKernelAttr(Sema &S, const MultiLevelTemplateArgumentList &TemplateArgs, const SYCLKernelAttr &Attr, Decl *New)
static void instantiateDependentAlignValueAttr(Sema &S, const MultiLevelTemplateArgumentList &TemplateArgs, const AlignValueAttr *Aligned, Decl *New)
static void instantiateDependentAlignedAttr(Sema &S, const MultiLevelTemplateArgumentList &TemplateArgs, const AlignedAttr *Aligned, Decl *New, bool IsPackExpansion)
static void instantiateOMPDeclareVariantAttr(Sema &S, const MultiLevelTemplateArgumentList &TemplateArgs, const OMPDeclareVariantAttr &Attr, Decl *New)
Instantiation of 'declare variant' attribute and its arguments.
static void instantiateDependentEnableIfAttr(Sema &S, const MultiLevelTemplateArgumentList &TemplateArgs, const EnableIfAttr *EIA, const Decl *Tmpl, FunctionDecl *New)
static void instantiateDependentAnnotationAttr(Sema &S, const MultiLevelTemplateArgumentList &TemplateArgs, const AnnotateAttr *Attr, Decl *New)
static Sema::RetainOwnershipKind attrToRetainOwnershipKind(const Attr *A)
static 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
QualType getTemplateSpecializationType(TemplateName T, ArrayRef< TemplateArgument > Args, QualType Canon=QualType()) const
QualType getRecordType(const RecordDecl *Decl) const
QualType getInjectedClassNameType(CXXRecordDecl *Decl, QualType TST) const
getInjectedClassNameType - Return the unique reference to the injected class name type for the specif...
CanQualType getCanonicalType(QualType T) const
Return the canonical (structural) type corresponding to the specified potentially non-canonical type ...
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
QualType getLValueReferenceType(QualType T, bool SpelledAsLValue=true) const
Return the uniqued reference to the type for an lvalue reference to the specified type.
QualType getTypeDeclType(const TypeDecl *Decl, const TypeDecl *PrevDecl=nullptr) const
Return the unique reference to the type for the specified type declaration.
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)
FieldDecl * getInstantiatedFromUnnamedFieldDecl(FieldDecl *Field)
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,...
TypeSourceInfo * getTemplateSpecializationTypeInfo(TemplateName T, SourceLocation TLoc, const TemplateArgumentListInfo &Args, QualType Canon=QualType()) const
void setManglingNumber(const NamedDecl *ND, unsigned Number)
void addDeclaratorForUnnamedTagDecl(TagDecl *TD, DeclaratorDecl *DD)
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.
const TargetInfo & getTargetInfo() const
void setInstantiatedFromUnnamedFieldDecl(FieldDecl *Inst, FieldDecl *Tmpl)
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)
SourceLocation getColonLoc() const
The location of the colon following the access specifier.
SourceLocation getAccessSpecifierLoc() const
The location of the access specifier.
Attr - This represents one attribute.
attr::Kind getKind() const
Attr * clone(ASTContext &C) const
SourceLocation getLocation() const
SourceRange getRange() const
SourceLocation getLoc() const
Represents a C++ declaration that introduces decls from somewhere else.
shadow_range shadows() const
A binding in a decomposition declaration.
static BindingDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation IdLoc, IdentifierInfo *Id)
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(), Expr *TrailingRequiresClause=nullptr)
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, Expr *TrailingRequiresClause=nullptr)
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)
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, Expr *TrailingRequiresClause=nullptr)
Represents a static or instance method of a struct/union/class.
const CXXRecordDecl * getParent() const
Return the parent of this method declaration, which is the class in which this method is defined.
bool isMoveAssignmentOperator() const
Determine whether this is a move assignment operator.
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, Expr *TrailingRequiresClause=nullptr)
bool isCopyAssignmentOperator() const
Determine whether this is a copy-assignment operator, regardless of whether it was declared implicitl...
Represents a C++ struct/union/class.
bool isGenericLambda() const
Determine whether this class describes a generic lambda function object (i.e.
unsigned getLambdaDependencyKind() const
const FunctionDecl * isLocalClass() const
If the class is a local class [class.local], returns the enclosing function declaration.
bool isLambda() const
Determine whether this class describes a lambda function object.
CXXRecordDecl * getDefinition() const
static CXXRecordDecl * CreateLambda(const ASTContext &C, DeclContext *DC, TypeSourceInfo *Info, SourceLocation Loc, unsigned DependencyKind, bool IsGeneric, LambdaCaptureDefault CaptureDefault)
static CXXRecordDecl * Create(const ASTContext &C, TagKind TK, DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, IdentifierInfo *Id, CXXRecordDecl *PrevDecl=nullptr, bool DelayTypeCreation=false)
TemplateSpecializationKind getTemplateSpecializationKind() const
Determine whether this particular class is a specialization or instantiation of a class template or m...
TypeSourceInfo * getLambdaTypeInfo() const
void setInstantiationOfMemberClass(CXXRecordDecl *RD, TemplateSpecializationKind TSK)
Specify that this record is an instantiation of the member class RD.
LambdaCaptureDefault getLambdaCaptureDefault() const
void setDescribedClassTemplate(ClassTemplateDecl *Template)
CXXRecordDecl * getCanonicalDecl() override
Retrieves the "canonical" declaration of the given declaration.
Represents a C++ nested-name-specifier or a global scope specifier.
void Adopt(NestedNameSpecifierLoc Other)
Adopt an existing nested-name-specifier (with source-range information).
Declaration of a class template.
void AddPartialSpecialization(ClassTemplatePartialSpecializationDecl *D, void *InsertPos)
Insert the specified partial specialization knowing that it is not already in.
ClassTemplateDecl * getMostRecentDecl()
CXXRecordDecl * getTemplatedDecl() const
Get the underlying class declarations of the template.
llvm::FoldingSetVector< ClassTemplatePartialSpecializationDecl > & getPartialSpecializations() const
Retrieve the set of partial specializations of this class template.
ClassTemplatePartialSpecializationDecl * findPartialSpecialization(ArrayRef< TemplateArgument > Args, TemplateParameterList *TPL, void *&InsertPos)
Return the partial specialization with the provided arguments if it exists, otherwise return the inse...
static ClassTemplateDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation L, DeclarationName Name, TemplateParameterList *Params, NamedDecl *Decl)
Create a class template node.
ClassTemplateDecl * getCanonicalDecl() override
Retrieves the canonical declaration of 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)
QualType getInjectedClassNameSpecialization()
Retrieve the template specialization type of the injected-class-name for this class template.
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)
const ASTTemplateArgumentListInfo * getTemplateArgsAsWritten() const
Get the template arguments as written.
static ClassTemplatePartialSpecializationDecl * Create(ASTContext &Context, TagKind TK, DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, TemplateParameterList *Params, ClassTemplateDecl *SpecializedTemplate, ArrayRef< TemplateArgument > Args, const TemplateArgumentListInfo &ArgInfos, QualType CanonInjectedType, 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.
ClassTemplateDecl * getSpecializedTemplate() const
Retrieve the template that this specialization specializes.
SourceLocation getExternLoc() const
Gets the location of the extern keyword, if present.
void setTypeAsWritten(TypeSourceInfo *T)
Sets the type of this specialization as it was written by the user.
SourceLocation getPointOfInstantiation() const
Get the point of instantiation (if any), or null if none.
TypeSourceInfo * getTypeAsWritten() const
Gets the type of this specialization as it was written by the user, if it was so written.
void setSpecializationKind(TemplateSpecializationKind TSK)
void setTemplateKeywordLoc(SourceLocation Loc)
Sets the location of the template keyword.
SourceLocation getTemplateKeywordLoc() const
Gets the location of the template keyword, if present.
static ClassTemplateSpecializationDecl * Create(ASTContext &Context, TagKind TK, DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, ClassTemplateDecl *SpecializedTemplate, ArrayRef< TemplateArgument > Args, ClassTemplateSpecializationDecl *PrevDecl)
void setExternLoc(SourceLocation Loc)
Sets the location of the extern keyword.
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).
void setInvalidDecl(bool Invalid=true)
setInvalidDecl - Indicates the Decl had a semantic error.
bool isInIdentifierNamespace(unsigned NS) const
@ FOK_None
Not a friend object.
bool isReferenced() const
Whether any declaration of this entity was referenced.
unsigned getTemplateDepth() const
Determine the number of levels of template parameter surrounding this declaration.
void setObjectOfFriendDecl(bool PerformFriendInjection=false)
Changes the namespace of this declaration to reflect that it's the object of a friend declaration.
bool isFromASTFile() const
Determine whether this declaration came from an AST file (such as a precompiled header or module) rat...
bool isInLocalScopeForInstantiation() const
Determine whether a substitution into this declaration would occur as part of a substitution into a d...
DeclContext * getNonTransparentDeclContext()
Return the non transparent context.
bool isInvalidDecl() const
bool isLocalExternDecl() const
Determine whether this is a block-scope declaration with linkage.
llvm::iterator_range< specific_attr_iterator< T > > specific_attrs() const
void setAccess(AccessSpecifier AS)
SourceLocation getLocation() const
const char * getDeclKindName() const
@ IDNS_Ordinary
Ordinary names.
void setImplicit(bool I=true)
void setReferenced(bool R=true)
void setIsUsed()
Set whether the declaration is used, in the sense of odr-use.
bool isUsed(bool CheckUsedAttr=true) const
Whether any (re-)declaration of the entity was used, meaning that a definition is required.
DeclContext * getDeclContext()
AccessSpecifier getAccess() const
SourceLocation getBeginLoc() const LLVM_READONLY
DeclContext * getLexicalDeclContext()
getLexicalDeclContext - The declaration context where this Decl was lexically declared (LexicalDC).
void setNonMemberOperator()
Specifies that this declaration is a C++ overloaded non-member.
void setLexicalDeclContext(DeclContext *DC)
void setVisibleDespiteOwningModule()
Set that this declaration is globally visible, even if it came from a module that is not visible.
The name of a declaration.
NameKind getNameKind() const
Determine what kind of name this is.
Represents a ValueDecl that came out of a declarator.
SourceLocation getInnerLocStart() const
Return start of source range ignoring outer template declarations.
TemplateParameterList * getTemplateParameterList(unsigned index) const
SourceLocation getTypeSpecStartLoc() const
SourceLocation getBeginLoc() const LLVM_READONLY
unsigned getNumTemplateParameterLists() const
void setTypeSourceInfo(TypeSourceInfo *TI)
void setQualifierInfo(NestedNameSpecifierLoc QualifierLoc)
NestedNameSpecifierLoc getQualifierLoc() const
Retrieve the nested-name-specifier (with source-location information) that qualifies the name of this...
Expr * getTrailingRequiresClause()
Get the constraint-expression introduced by the trailing requires-clause in the function/member decla...
TypeSourceInfo * getTypeSourceInfo() const
void setTemplateParameterListsInfo(ASTContext &Context, ArrayRef< TemplateParameterList * > TPLists)
Represents the type decltype(expr) (C++11).
Expr * getUnderlyingExpr() const
A decomposition declaration.
ArrayRef< BindingDecl * > bindings() const
static DecompositionDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation StartLoc, SourceLocation LSquareLoc, QualType T, TypeSourceInfo *TInfo, StorageClass S, ArrayRef< BindingDecl * > Bindings)
Provides information about a dependent function-template specialization declaration.
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.
RAII object that enters a new expression evaluation context.
An instance of this object exists for each enum constant that is defined.
enumerator_range enumerators() const
bool isScoped() const
Returns true if this is a C++11 scoped enumeration.
bool isScopedUsingClassTag() const
Returns true if this is a C++11 scoped enumeration.
static EnumDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, IdentifierInfo *Id, EnumDecl *PrevDecl, bool IsScoped, bool IsScopedUsingClassTag, bool IsFixed)
TypeSourceInfo * getIntegerTypeSourceInfo() const
Return the type source info for the underlying integer type, if no type source info exists,...
bool isFixed() const
Returns true if this is an Objective-C, C++11, or Microsoft-style enumeration with a fixed underlying...
EnumDecl * getCanonicalDecl() override
Retrieves the "canonical" declaration of the given declaration.
QualType getIntegerType() const
Return the integer type this enum decl corresponds to.
EnumDecl * getDefinition() const
TemplateSpecializationKind getTemplateSpecializationKind() const
If this enumeration is a member of a specialization of a templated class, determine what kind of temp...
Store information needed for an explicit specifier.
ExplicitSpecKind getKind() const
bool isInvalid() const
Determine if the explicit specifier is invalid.
static ExplicitSpecifier Invalid()
const Expr * getExpr() const
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.
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++.
Represents difference between two FPOptions values.
Represents a member of a struct/union/class.
bool isMutable() const
Determines whether this field is mutable (C++ only).
InClassInitStyle getInClassInitStyle() const
Get the kind of (C++11) default member initializer that this field has.
Expr * getBitWidth() const
Returns the expression that represents the bit width, if this field is a bit field.
FriendDecl - Represents the declaration of a friend entity, which can be a function,...
static FriendDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation L, FriendUnion Friend_, SourceLocation FriendL, ArrayRef< TemplateParameterList * > FriendTypeTPLists=std::nullopt)
bool isUnsupportedFriend() const
Determines if this friend kind is unsupported.
SourceLocation getFriendLoc() const
Retrieves the location of the 'friend' keyword.
void setUnsupportedFriend(bool Unsupported)
NamedDecl * getFriendDecl() const
If this friend declaration doesn't name a type, return the inner declaration.
TypeSourceInfo * getFriendType() const
If this friend declaration names an (untemplated but possibly dependent) type, return the type; other...
Declaration of a friend template.
static DefaultedFunctionInfo * Create(ASTContext &Context, ArrayRef< DeclAccessPair > Lookups)
Represents a function declaration or definition.
void setInstantiationIsPending(bool IC)
State that the instantiation of this function is pending.
const ParmVarDecl * getParamDecl(unsigned i) const
Stmt * getBody(const FunctionDecl *&Definition) const
Retrieve the body (definition) of the function.
ConstexprSpecKind getConstexprKind() const
void setDescribedFunctionTemplate(FunctionTemplateDecl *Template)
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...
bool UsesFPIntrin() const
Determine whether the function was declared in source context that requires constrained FP intrinsics...
void setInstantiationOfMemberFunction(FunctionDecl *FD, TemplateSpecializationKind TSK)
Specify that this record is an instantiation of the member function FD.
QualType getReturnType() const
ArrayRef< ParmVarDecl * > parameters() const
bool isExplicitlyDefaulted() const
Whether this function is explicitly defaulted.
bool hasWrittenPrototype() const
Whether this function has a written prototype.
FunctionDecl * getCanonicalDecl() override
Retrieves the "canonical" declaration of the given declaration.
DependentFunctionTemplateSpecializationInfo * getDependentSpecializationInfo() const
bool isDeleted() const
Whether this function has been deleted.
StorageClass getStorageClass() const
Returns the storage class as written in the source.
bool isOutOfLine() const override
Determine whether this is or was instantiated from an out-of-line definition of a member function.
bool FriendConstraintRefersToEnclosingTemplate() const
bool isDeletedAsWritten() const
void setFunctionTemplateSpecialization(FunctionTemplateDecl *Template, const TemplateArgumentList *TemplateArgs, void *InsertPos, TemplateSpecializationKind TSK=TSK_ImplicitInstantiation, const TemplateArgumentListInfo *TemplateArgsAsWritten=nullptr, SourceLocation PointOfInstantiation=SourceLocation())
Specify that this function declaration is actually a function template specialization.
bool isPureVirtual() const
Whether this virtual function is pure, i.e.
bool isLateTemplateParsed() const
Whether this templated function will be late parsed.
void setVirtualAsWritten(bool V)
State that this function is marked as virtual explicitly.
bool hasSkippedBody() const
True if the function was a definition but its body was skipped.
FunctionDecl * getDefinition()
Get the definition for this declaration.
void setImplicitlyInline(bool I=true)
Flag that this function is implicitly inline.
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, Expr *TrailingRequiresClause=nullptr)
bool isThisDeclarationInstantiatedFromAFriendDefinition() const
Determine whether this specific declaration of the function is a friend declaration that was instanti...
void setRangeEnd(SourceLocation E)
bool isDefaulted() const
Whether this function is defaulted.
void setIneligibleOrNotSelected(bool II)
SourceRange getSourceRange() const override LLVM_READONLY
Source range that this declaration covers.
DefaultedFunctionInfo * getDefaultedFunctionInfo() const
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
void setDefaultedFunctionInfo(DefaultedFunctionInfo *Info)
bool isDefined(const FunctionDecl *&Definition, bool CheckForPendingFriendDefinition=false) const
Returns true if the function has a definition that does not need to be instantiated.
bool isInlineSpecified() const
Determine whether the "inline" keyword was specified for this function.
void setParams(ArrayRef< ParmVarDecl * > NewParamInfo)
bool willHaveBody() const
True if this function will eventually have a body, once it's fully parsed.
const ASTTemplateArgumentListInfo * getTemplateSpecializationArgsAsWritten() const
Retrieve the template argument list as written in the sources, if any.
Represents a prototype with parameter type info, e.g.
ExceptionSpecificationType getExceptionSpecType() const
Get the kind of exception specification on this function.
QualType getParamType(unsigned i) const
bool hasExceptionSpec() const
Return whether this function has any kind of exception spec.
ExtProtoInfo getExtProtoInfo() const
FunctionDecl * getExceptionSpecTemplate() const
If this function type has an uninstantiated exception specification, this is the function whose excep...
ArrayRef< QualType > getParamTypes() const
Declaration of a template function.
FunctionTemplateDecl * getCanonicalDecl() override
Retrieves the canonical declaration of this template.
FunctionDecl * findSpecialization(ArrayRef< TemplateArgument > Args, void *&InsertPos)
Return the specialization with the provided arguments if it exists, otherwise return the insertion po...
FunctionDecl * getTemplatedDecl() const
Get the underlying function declaration of the template.
FunctionTemplateDecl * getInstantiatedFromMemberTemplate() const
FunctionTemplateDecl * getPreviousDecl()
Retrieve the previous declaration of this function template, or nullptr if no such declaration exists...
static FunctionTemplateDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation L, DeclarationName Name, TemplateParameterList *Params, NamedDecl *Decl)
Create a function template node.
ParmVarDecl * getParam(unsigned i) const
void setParam(unsigned i, ParmVarDecl *VD)
ExtInfo getExtInfo() const
bool getNoReturnAttr() const
Determine whether this function type includes the GNU noreturn attribute.
QualType getReturnType() const
HLSLBufferDecl - Represent a cbuffer or tbuffer declaration.
One of these records is kept for each identifier that is lexed.
bool isStr(const char(&Str)[StrLen]) const
Return true if this is the identifier for the specified string.
Represents a field injected from an anonymous union/struct into the parent scope.
unsigned getChainingSize() const
static IndirectFieldDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation L, IdentifierInfo *Id, QualType T, llvm::MutableArrayRef< NamedDecl * > CH)
ArrayRef< NamedDecl * > chain() const
Description of a constructor that was inherited from a base class.
const TypeClass * getTypePtr() const
static IntegerLiteral * Create(const ASTContext &C, const llvm::APInt &V, QualType type, SourceLocation l)
Returns a new integer literal with value 'V' and type 'type'.
Represents the declaration of a label.
static LabelDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation IdentL, IdentifierInfo *II)
A stack-allocated class that identifies which local variable declaration instantiations are present i...
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)
IdentifierInfo * getGetterId() const
IdentifierInfo * getSetterId() const
Provides information a specialization of a member of a class template, which may be a member function...
Data structure that captures multiple levels of template argument lists for use in template instantia...
const ArgList & getInnermost() const
Retrieve the innermost template argument list.
void addOuterTemplateArguments(Decl *AssociatedDecl, ArgList Args, bool Final)
Add a new outmost level to the multi-level template argument list.
void setKind(TemplateSubstitutionKind K)
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.
void setDeclName(DeclarationName N)
Set the name of this declaration.
bool isCXXClassMember() const
Determine whether this declaration is a C++ class member.
Represents a C++ namespace alias.
static NamespaceAliasDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation NamespaceLoc, SourceLocation AliasLoc, IdentifierInfo *Alias, NestedNameSpecifierLoc QualifierLoc, SourceLocation IdentLoc, NamedDecl *Namespace)
NestedNameSpecifierLoc getQualifierLoc() const
Retrieve the nested-name-specifier that qualifies the name of the namespace, with source-location inf...
SourceLocation getAliasLoc() const
Returns the location of the alias name, i.e.
SourceLocation getNamespaceLoc() const
Returns the location of the namespace keyword.
SourceLocation getTargetNameLoc() const
Returns the location of the identifier in the named namespace.
NamespaceDecl * getNamespace()
Retrieve the namespace declaration aliased by this directive.
Represent a C++ namespace.
A C++ nested-name-specifier augmented with source location information.
bool hasQualifier() const
Evaluates true when this nested-name-specifier location is empty.
SourceRange getSourceRange() const LLVM_READONLY
Retrieve the source range covering the entirety of this nested-name-specifier.
NonTypeTemplateParmDecl - Declares a non-type template parameter, e.g., "Size" in.
bool isPackExpansion() const
Whether this parameter pack is a pack expansion.
static NonTypeTemplateParmDecl * Create(const ASTContext &C, DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, unsigned D, unsigned P, IdentifierInfo *Id, QualType T, bool ParameterPack, TypeSourceInfo *TInfo)
bool hasDefaultArgument() const
Determine whether this template parameter has a default argument.
unsigned getPosition() const
Get the position of the template parameter within its parameter list.
bool defaultArgumentWasInherited() const
Determines whether the default argument was inherited from a previous declaration of this template.
TypeSourceInfo * getExpansionTypeSourceInfo(unsigned I) const
Retrieve a particular expansion type source info within an expanded parameter pack.
unsigned getNumExpansionTypes() const
Retrieves the number of expansion types in an expanded parameter pack.
bool isExpandedParameterPack() const
Whether this parameter is a non-type template parameter pack that has a known list of different types...
bool isParameterPack() const
Whether this parameter is a non-type template parameter pack.
Expr * getDefaultArgument() const
Retrieve the default argument, if any.
void setDefaultArgument(Expr *DefArg)
Set the default argument for this template parameter, and whether that default argument was inherited...
unsigned getDepth() const
Get the nesting depth of the template parameter.
Expr * getPlaceholderTypeConstraint() const
Return the constraint introduced by the placeholder type of this non-type template parameter (if any)...
This represents '#pragma omp allocate ...' directive.
clauselist_range clauselists()
Pseudo declaration for capturing expressions.
This is a basic class for representing single OpenMP clause.
This represents '#pragma omp declare mapper ...' directive.
OMPDeclareMapperDecl * getPrevDeclInScope()
Get reference to previous declare mapper construct in the same scope with the same name.
clauselist_iterator clauselist_begin()
clauselist_range clauselists()
DeclarationName getVarName()
Get the name of the variable declared in the mapper.
Expr * getMapperVarRef()
Get the variable declared in the mapper.
This represents '#pragma omp declare reduction ...' directive.
Expr * getInitializer()
Get initializer expression (if specified) of the declare reduction construct.
Expr * getInitPriv()
Get Priv variable of the initializer.
Expr * getCombinerOut()
Get Out variable of the combiner.
Expr * getCombinerIn()
Get In variable of the combiner.
Expr * getCombiner()
Get combiner expression of the declare reduction construct.
OMPDeclareReductionDecl * getPrevDeclInScope()
Get reference to previous declare reduction construct in the same scope with the same name.
Expr * getInitOrig()
Get Orig variable of the initializer.
OMPDeclareReductionInitKind getInitializerKind() const
Get initializer kind.
This represents '#pragma omp 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)
SourceLocation getEllipsisLoc() const
TypeLoc getPatternLoc() const
Represents a pack expansion of types.
std::optional< unsigned > 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.
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...
The collection of all-type qualifiers we support.
Represents a struct/union/class.
bool isInjectedClassName() const
Determines whether this declaration represents the injected class name.
bool isAnonymousStructOrUnion() const
Whether this is an anonymous struct or union.
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...
RecordDecl * getDecl() const
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.
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...
CXXSpecialMember 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.
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=std::nullopt)
Called on well-formed 'map' clause.
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.
bool isIncompatibleTypedef(TypeDecl *Old, TypedefNameDecl *New)
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'.
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.
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.
bool CheckParameterPacksForExpansion(SourceLocation EllipsisLoc, SourceRange PatternRange, ArrayRef< UnexpandedParameterPack > Unexpanded, const MultiLevelTemplateArgumentList &TemplateArgs, bool &ShouldExpand, bool &RetainExpansion, std::optional< unsigned > &NumExpansions)
Determine whether we could expand a pack expansion with the given set of parameter packs into separat...
@ 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)
TemplateName SubstTemplateName(NestedNameSpecifierLoc QualifierLoc, TemplateName Name, SourceLocation Loc, const MultiLevelTemplateArgumentList &TemplateArgs)
ParmVarDecl * SubstParmVarDecl(ParmVarDecl *D, const MultiLevelTemplateArgumentList &TemplateArgs, int indexAdjustment, std::optional< unsigned > NumExpansions, bool ExpectParameterPack, bool EvaluateConstraints=true)
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)
SemaDiagnosticBuilder Diag(SourceLocation Loc, unsigned DiagID, bool DeferHint=false)
Emit a diagnostic.
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.
bool DiagnoseUninstantiableTemplate(SourceLocation PointOfInstantiation, NamedDecl *Instantiation, bool InstantiatedFromMember, const NamedDecl *Pattern, const NamedDecl *PatternDef, TemplateSpecializationKind TSK, bool Complain=true)
Determine whether we would be unable to instantiate this template (because it either has no definitio...
void InstantiateExceptionSpec(SourceLocation PointOfInstantiation, FunctionDecl *Function)
void AddAssumeAlignedAttr(Decl *D, const AttributeCommonInfo &CI, Expr *E, Expr *OE)
AddAssumeAlignedAttr - Adds an assume_aligned attribute to a particular declaration.
void addAMDGPUWavesPerEUAttr(Decl *D, const AttributeCommonInfo &CI, Expr *Min, Expr *Max)
addAMDGPUWavePersEUAttr - Adds an amdgpu_waves_per_eu attribute to a particular declaration.
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.
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...
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)
ExprResult ActOnOpenMPDeclareMapperDirectiveVarDecl(Scope *S, QualType MapperType, SourceLocation StartLoc, DeclarationName VN)
Build the mapper variable of '#pragma omp declare mapper'.
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)
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)
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
TypeSourceInfo * CheckPackExpansion(TypeSourceInfo *Pattern, SourceLocation EllipsisLoc, std::optional< unsigned > NumExpansions)
Construct a pack expansion type from the pattern of the pack expansion.
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.
void AddXConsumedAttr(Decl *D, const AttributeCommonInfo &CI, RetainOwnershipKind K, bool IsTemplateInstantiation)
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)
void checkAllowedCUDAInitializer(VarDecl *VD)
const LangOptions & getLangOpts() const
void ActOnOpenMPDeclareReductionCombinerStart(Scope *S, Decl *D)
Initialize declare reduction construct initializer.
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.
DeclGroupPtrTy ActOnOpenMPAllocateDirective(SourceLocation Loc, ArrayRef< Expr * > VarList, ArrayRef< OMPClause * > Clauses, DeclContext *Owner=nullptr)
Called on well-formed '#pragma omp allocate'.
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 ...
void PerformPendingInstantiations(bool LocalOnly=false)
Performs template instantiation for all implicit template instantiations we have seen until this poin...
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.
OMPThreadPrivateDecl * CheckOMPThreadPrivateDecl(SourceLocation Loc, ArrayRef< Expr * > VarList)
Builds a new OpenMPThreadPrivateDecl and checks its correctness.
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).
OMPClause * ActOnOpenMPAlignClause(Expr *Alignment, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Called on well-formed 'align' clause.
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.
void AddAnnotationAttr(Decl *D, const AttributeCommonInfo &CI, StringRef Annot, MutableArrayRef< Expr * > Args)
AddAnnotationAttr - Adds an annotation Annot with Args arguments to D.
bool usesPartialOrExplicitSpecialization(SourceLocation Loc, ClassTemplateSpecializationDecl *ClassTemplateSpec)
std::optional< unsigned > getNumArgumentsInExpansion(QualType T, const MultiLevelTemplateArgumentList &TemplateArgs)
Determine the number of arguments in the given pack expansion type.
TemplateArgumentLoc getTrivialTemplateArgumentLoc(const TemplateArgument &Arg, QualType NTTPType, SourceLocation Loc)
Allocate a TemplateArgumentLoc where all locations have been initialized to the given location.
ExplicitSpecifier instantiateExplicitSpecifier(const MultiLevelTemplateArgumentList &TemplateArgs, ExplicitSpecifier ES)
bool 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.
int ArgumentPackSubstitutionIndex
The current index into pack expansion arguments that will be used for substitution of parameter packs...
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...
void ActOnOpenMPDeclareVariantDirective(FunctionDecl *FD, Expr *VariantRef, OMPTraitInfo &TI, ArrayRef< Expr * > AdjustArgsNothing, ArrayRef< Expr * > AdjustArgsNeedDevicePtr, ArrayRef< OMPInteropInfo > AppendArgs, SourceLocation AdjustArgsLoc, SourceLocation AppendArgsLoc, SourceRange SR)
Called on well-formed '#pragma omp declare variant' after parsing of the associated method/function.
QualType ActOnOpenMPDeclareReductionType(SourceLocation TyLoc, TypeResult ParsedType)
Check if the specified type is allowed to be used in 'omp declare reduction' construct.
sema::BlockScopeInfo * getCurBlock()
Retrieve the current block, if any.
DeclContext * CurContext
CurContext - This is the current declaration context of parsing.
@ ForVisibleRedeclaration
The lookup results will be used for redeclaration of a name, if an entity by that name already exists...
@ ForExternalRedeclaration
The lookup results will be used for redeclaration of a name with external linkage; non-visible lookup...
VarDecl * ActOnOpenMPDeclareReductionInitializerStart(Scope *S, Decl *D)
Initialize declare reduction construct initializer.
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...
void ActOnOpenMPDeclareReductionInitializerEnd(Decl *D, Expr *Initializer, VarDecl *OmpPrivParm)
Finish current declare reduction construct initializer.
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)
RedeclarationKind forRedeclarationInCurContext() const
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.
QualType CheckTemplateIdType(TemplateName Template, SourceLocation TemplateLoc, TemplateArgumentListInfo &TemplateArgs)
Decl * ActOnFinishFunctionBody(Decl *Decl, Stmt *Body)
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 on start of '#pragma omp declare mapper'.
void keepInLifetimeExtendingContext()
keepInLifetimeExtendingContext - Pull down InLifetimeExtendingContext flag from previous context.
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)
DeclGroupPtrTy ActOnOpenMPDeclareReductionDirectiveEnd(Scope *S, DeclGroupPtrTy DeclReductions, bool IsValid)
Called at the end of '#pragma omp declare reduction'.
void AddLaunchBoundsAttr(Decl *D, const AttributeCommonInfo &CI, Expr *MaxThreads, Expr *MinBlocks, Expr *MaxBlocks)
AddLaunchBoundsAttr - Adds a launch_bounds attribute to a particular declaration.
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...
bool AttachTypeConstraint(NestedNameSpecifierLoc NS, DeclarationNameInfo NameInfo, ConceptDecl *NamedConcept, NamedDecl *FoundDecl, const TemplateArgumentListInfo *TemplateArgs, TemplateTypeParmDecl *ConstrainedParameter, SourceLocation EllipsisLoc)
Attach a type-constraint to a template parameter.
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.
QualType ActOnOpenMPDeclareMapperType(SourceLocation TyLoc, TypeResult ParsedType)
Check if the specified type is allowed to be used in 'omp declare mapper' construct.
void keepInMaterializeTemporaryObjectContext()
keepInMaterializeTemporaryObjectContext - Pull down InMaterializeTemporaryObjectContext flag from pre...
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)
bool CheckTemplateArgumentList(TemplateDecl *Template, SourceLocation TemplateLoc, TemplateArgumentListInfo &TemplateArgs, bool PartialTemplateArgs, SmallVectorImpl< TemplateArgument > &SugaredConverted, SmallVectorImpl< TemplateArgument > &CanonicalConverted, bool UpdateArgsWithConversions=true, bool *ConstraintsNotSatisfied=nullptr)
Check that the given template arguments can be provided to the given template, converting the argumen...
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.
bool inferObjCARCLifetime(ValueDecl *decl)
@ 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.
void StartOpenMPDSABlock(OpenMPDirectiveKind K, const DeclarationNameInfo &DirName, Scope *CurScope, SourceLocation Loc)
Called on start of new data sharing attribute block.
bool CheckAlignasTypeArgument(StringRef KWName, TypeSourceInfo *TInfo, SourceLocation OpLoc, SourceRange R)
NamedDecl * BuildUsingPackDecl(NamedDecl *InstantiatedFrom, ArrayRef< NamedDecl * > Expansions)
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 AddParameterABIAttr(Decl *D, const AttributeCommonInfo &CI, ParameterABI ABI)
NamespaceDecl * getStdNamespace() const
static bool adjustContextForLocalExternDecl(DeclContext *&DC)
Adjust the DeclContext for a function or variable that might be a function-local external declaration...
@ TPC_FriendFunctionTemplate
@ TPC_FriendFunctionTemplateDefinition
void DiagnoseUnusedDecl(const NamedDecl *ND)
void EndOpenMPDSABlock(Stmt *CurDirective)
Called on end of data sharing attribute block.
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)
void CheckAlignasUnderalignment(Decl *D)
void SetDeclDeleted(Decl *dcl, SourceLocation DelLoc)
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.
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 ActOnOpenMPDeclareReductionCombinerEnd(Decl *D, Expr *Combiner)
Finish current declare reduction construct initializer.
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)
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)
Retrieve the template argument list(s) that should be used to instantiate the definition of the given...
bool checkStringLiteralArgumentAttr(const AttributeCommonInfo &CI, const Expr *E, StringRef &Str, SourceLocation *ArgLocation=nullptr)
Check if the argument E is a ASCII string literal.
bool CheckEnumRedeclaration(SourceLocation EnumLoc, bool IsScoped, QualType EnumUnderlyingTy, bool IsFixed, const EnumDecl *Prev)
Check whether this is a valid redeclaration of a previous enumeration.
OMPClause * ActOnOpenMPAllocatorClause(Expr *Allocator, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Called on well-formed 'allocator' clause.
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.
A trivial tuple used to represent a source range.
SourceLocation getEnd() const
Represents a C++11 static_assert declaration.
SourceLocation getRParenLoc() const
Stmt - This represents one statement.
SourceLocation getEndLoc() const LLVM_READONLY
SourceLocation getBeginLoc() const LLVM_READONLY
Represents the declaration of a struct/union/class/enum.
bool isThisDeclarationADefinition() const
Return true if this declaration is a completion definition of the type.
bool isCompleteDefinition() const
Return true if this decl has its body fully specified.
NestedNameSpecifierLoc getQualifierLoc() const
Retrieve the nested-name-specifier (with source-location information) that qualifies the name of this...
TypedefNameDecl * getTypedefNameForAnonDecl() const
void setTypedefNameForAnonDecl(TypedefNameDecl *TDD)
void setQualifierInfo(NestedNameSpecifierLoc QualifierLoc)
bool hasNameForLinkage() const
Is this tag type named, either directly or via being defined in a typedef of this type?
TagKind getTagKind() const
bool isBeingDefined() const
Determines whether this type is in the process of being defined.
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
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 * 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
unsigned getNumArgs() const
SourceLocation getLAngleLoc() const
TemplateArgumentLoc getArgLoc(unsigned i) const
SourceLocation getRAngleLoc() const
TemplateTemplateParmDecl - Declares a template template parameter, e.g., "T" in.
TemplateParameterList * getExpansionTemplateParameters(unsigned I) const
Retrieve a particular expansion type within an expanded parameter pack.
bool isPackExpansion() const
Whether this parameter pack is a pack expansion.
unsigned getNumExpansionTemplateParameters() const
Retrieves the number of expansion template parameters in an expanded parameter pack.
const TemplateArgumentLoc & getDefaultArgument() const
Retrieve the default argument, if any.
unsigned getPosition() const
Get the position of the template parameter within its parameter list.
bool isParameterPack() const
Whether this template template parameter is a template parameter pack.
bool defaultArgumentWasInherited() const
Determines whether the default argument was inherited from a previous declaration of this template.
void setDefaultArgument(const ASTContext &C, const TemplateArgumentLoc &DefArg)
Set the default argument for this template parameter, and whether that default argument was inherited...
unsigned getDepth() const
Get the nesting depth of the template parameter.
bool isExpandedParameterPack() const
Whether this parameter is a template template parameter pack that has a known list of different templ...
static TemplateTemplateParmDecl * Create(const ASTContext &C, DeclContext *DC, SourceLocation L, unsigned D, unsigned P, bool ParameterPack, IdentifierInfo *Id, TemplateParameterList *Params)
bool hasDefaultArgument() const
Determine whether this template parameter has a default argument.
Declaration of a template type parameter.
bool wasDeclaredWithTypename() const
Whether this template type parameter was declared with the 'typename' keyword.
SourceLocation getDefaultArgumentLoc() const
Retrieves the location of the default argument declaration.
unsigned getIndex() const
Retrieve the index of the template parameter.
bool hasTypeConstraint() const
Determine whether this template parameter has a type-constraint.
TypeSourceInfo * getDefaultArgumentInfo() const
Retrieves the default argument's source information, if any.
const TypeConstraint * getTypeConstraint() const
Returns the type constraint associated with this template parameter (if any).
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, std::optional< unsigned > NumExpanded=std::nullopt)
bool hasDefaultArgument() const
Determine whether this template parameter has a default argument.
bool defaultArgumentWasInherited() const
Determines whether the default argument was inherited from a previous declaration of this template.
bool isExpandedParameterPack() const
Whether this parameter is a template type parameter pack that has a known list of different type-cons...
void setDefaultArgument(TypeSourceInfo *DefArg)
Set the default argument for this template parameter.
bool isParameterPack() const
Returns whether this is a parameter pack.
unsigned getDepth() const
Retrieve the depth of the template parameter.
bool isPackExpansion() const
Whether this parameter pack is a pack expansion.
The top declaration context.
Represents the declaration of a typedef-name via a C++11 alias-declaration.
void setDescribedAliasTemplate(TypeAliasTemplateDecl *TAT)
static TypeAliasDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, IdentifierInfo *Id, TypeSourceInfo *TInfo)
Declaration of an alias template.
static TypeAliasTemplateDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation L, DeclarationName Name, TemplateParameterList *Params, NamedDecl *Decl)
Create a function template node.
TypeAliasDecl * getTemplatedDecl() const
Get the underlying function declaration of the template.
Models the abbreviated syntax to constrain a template type parameter: template <convertible_to<string...
void setTypeForDecl(const Type *TD)
const Type * getTypeForDecl() const
SourceLocation getBeginLoc() const LLVM_READONLY
TyLocType push(QualType T)
Pushes space for a new TypeLoc of the given type.
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...
A container of type source information.
TypeLoc getTypeLoc() const
Return the TypeLoc wrapper for the type source info.
QualType getType() const
Return the type wrapped by this type source info.
SourceLocation getNameLoc() const
void setNameLoc(SourceLocation Loc)
CXXRecordDecl * getAsCXXRecordDecl() const
Retrieves the CXXRecordDecl that this type refers to, either because the type is a RecordType or beca...
bool isRValueReferenceType() const
const T * castAs() const
Member-template castAs<specific type>.
bool isReferenceType() const
AutoType * getContainedAutoType() const
Get the AutoType whose type will be deduced for a variable with an initializer of this type.
bool isInstantiationDependentType() const
Determine whether this type is an instantiation-dependent type, meaning that the type involves a temp...
bool isLValueReferenceType() const
bool isDependentType() const
Whether this type is a dependent type, meaning that its definition somehow depends on a template para...
bool containsUnexpandedParameterPack() const
Whether this type is or contains an unexpanded parameter pack, used to support C++0x variadic templat...
bool isTemplateTypeParmType() const
bool 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, IdentifierInfo *Id, TypeSourceInfo *TInfo)
Base class for declarations which introduce a typedef-name.
TypeSourceInfo * getTypeSourceInfo() const
QualType getUnderlyingType() const
An artificial decl, representing a global anonymous constant value which is uniquified by value withi...
This node is generated when a using-declaration that was annotated with attribute((using_if_exists)) ...
static UnresolvedUsingIfExistsDecl * Create(ASTContext &Ctx, DeclContext *DC, SourceLocation Loc, DeclarationName Name)
Represents a dependent using declaration which was marked with typename.
SourceLocation getTypenameLoc() const
Returns the source location of the 'typename' keyword.
Represents a dependent using declaration which was not marked with typename.
Represents a C++ using-declaration.
bool hasTypename() const
Return true if the using declaration has 'typename'.
NestedNameSpecifierLoc getQualifierLoc() const
Retrieve the nested-name-specifier that qualifies the name, with source-location information.
DeclarationNameInfo getNameInfo() const
static UsingDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation UsingL, NestedNameSpecifierLoc QualifierLoc, const DeclarationNameInfo &NameInfo, bool HasTypenameKeyword)
SourceLocation getUsingLoc() const
Return the source location of the 'using' keyword.
Represents C++ using-directive.
static UsingDirectiveDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation UsingLoc, SourceLocation NamespaceLoc, NestedNameSpecifierLoc QualifierLoc, SourceLocation IdentLoc, NamedDecl *Nominated, DeclContext *CommonAncestor)
NamespaceDecl * getNominatedNamespace()
Returns the namespace nominated by this using-directive.
DeclContext * getCommonAncestor()
Returns the common ancestor context of this using-directive and its nominated namespace.
SourceLocation getNamespaceKeyLocation() const
Returns the location of the namespace keyword.
SourceLocation getIdentLocation() const
Returns the location of this using declaration's identifier.
NestedNameSpecifierLoc getQualifierLoc() const
Retrieve the nested-name-specifier that qualifies the name of the namespace, with source-location inf...
Represents a C++ using-enum-declaration.
SourceLocation getEnumLoc() const
The source location of the 'enum' keyword.
EnumDecl * getEnumDecl() const
TypeSourceInfo * getEnumType() const
static UsingEnumDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation UsingL, SourceLocation EnumL, SourceLocation NameL, TypeSourceInfo *EnumType)
SourceLocation getUsingLoc() const
The source location of the 'using' keyword.
Represents a pack of using declarations that a single using-declarator pack-expanded into.
ArrayRef< NamedDecl * > expansions() const
Get the set of using declarations that this pack expanded into.
Represents a shadow declaration implicitly introduced into a scope by a (resolved) using-declaration ...
void setType(QualType newType)
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...
bool isNRVOVariable() const
Determine whether this local variable can be used with the named return value optimization (NRVO).
void setInlineSpecified()
bool isStaticLocal() const
Returns true if a variable with function scope is a static local variable.
void setTemplateSpecializationKind(TemplateSpecializationKind TSK, SourceLocation PointOfInstantiation=SourceLocation())
For a static data member that was instantiated from a static data member of a class template,...
void setTSCSpec(ThreadStorageClassSpecifier TSC)
void setNRVOVariable(bool NRVO)
bool isInline() const
Whether this variable is (C++1z) inline.
ThreadStorageClassSpecifier getTSCSpec() const
const Expr * getInit() const
void setConstexpr(bool IC)
void setDescribedVarTemplate(VarTemplateDecl *Template)
bool isDirectInit() const
Whether the initializer is a direct-initializer (list or call).
StorageClass getStorageClass() const
Returns the storage class as written in the source.
void setImplicitlyInline()
bool isPreviousDeclInSameBlockScope() const
Whether this local extern variable declaration's previous declaration was declared in the same block ...
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...
bool isParameterPack() const
Determine whether this variable is actually a function parameter pack or init-capture pack.
Declaration of a variable template.
VarDecl * getTemplatedDecl() const
Get the underlying variable declarations of the template.
void AddPartialSpecialization(VarTemplatePartialSpecializationDecl *D, void *InsertPos)
Insert the specified partial specialization knowing that it is not already in.
VarTemplatePartialSpecializationDecl * findPartialSpecialization(ArrayRef< TemplateArgument > Args, TemplateParameterList *TPL, void *&InsertPos)
Return the partial specialization with the provided arguments if it exists, otherwise return the inse...
void AddSpecialization(VarTemplateSpecializationDecl *D, void *InsertPos)
Insert the specified specialization knowing that it is not already in.
static VarTemplateDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation L, DeclarationName Name, TemplateParameterList *Params, VarDecl *Decl)
Create a variable template node.
llvm::FoldingSetVector< VarTemplatePartialSpecializationDecl > & getPartialSpecializations() const
Retrieve the set of partial specializations of this class template.
VarTemplateSpecializationDecl * findSpecialization(ArrayRef< TemplateArgument > Args, void *&InsertPos)
Return the specialization with the provided arguments if it exists, otherwise return the insertion po...
VarTemplatePartialSpecializationDecl * findPartialSpecInstantiatedFromMember(VarTemplatePartialSpecializationDecl *D)
Find a variable template partial specialization which was instantiated from the given member partial ...
const ASTTemplateArgumentListInfo * getTemplateArgsAsWritten() const
Get the template arguments as written.
TemplateParameterList * getTemplateParameters() const
Get the list of template parameters.
static VarTemplatePartialSpecializationDecl * Create(ASTContext &Context, DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, TemplateParameterList *Params, VarTemplateDecl *SpecializedTemplate, QualType T, TypeSourceInfo *TInfo, StorageClass S, ArrayRef< TemplateArgument > Args, const TemplateArgumentListInfo &ArgInfos)
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 setTemplateArgsInfo(const TemplateArgumentListInfo &ArgsInfo)
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...
void setTypeAsWritten(TypeSourceInfo *T)
Sets the type of this specialization as it was written by the user.
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.
const ASTTemplateArgumentListInfo * getTemplateArgsInfo() const
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...
StorageClass
Storage classes.
@ Property
The type of a property.
@ Result
The result type of a method or function.
@ TU_Prefix
The translation unit is a prefix to a translation unit, and is not complete.
@ VK_PRValue
A pr-value expression (in the C++11 taxonomy) produces a temporary value.
bool declaresSameEntity(const Decl *D1, const Decl *D2)
Determine whether two declarations declare the same entity.
TemplateSpecializationKind
Describes the kind of template specialization that a particular template specialization declaration r...
@ TSK_ExplicitInstantiationDefinition
This template specialization was instantiated from a template due to an explicit instantiation defini...
@ TSK_ExplicitInstantiationDeclaration
This template specialization was instantiated from a template due to an explicit instantiation declar...
@ TSK_ExplicitSpecialization
This template specialization was declared or defined by an explicit specialization (C++ [temp....
@ TSK_ImplicitInstantiation
This template specialization was implicitly instantiated from a template.
@ TSK_Undeclared
This template specialization was formed from a template-id but has not yet been declared,...
@ Enum
The "enum" keyword introduces the elaborated-type-specifier.
@ 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 ('<').
llvm::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.
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.
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 ...
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...