28 using namespace clang;
36 return cast<CXXRecordDecl>(DC)->isLocalClass();
41 template<
typename DeclT>
44 if (!OldDecl->getQualifierLoc())
47 assert((NewDecl->getFriendObjectKind() ||
48 !OldDecl->getLexicalDeclContext()->isDependentContext()) &&
49 "non-friend with qualified name defined in dependent context");
52 const_cast<DeclContext *>(NewDecl->getFriendObjectKind()
53 ? NewDecl->getLexicalDeclContext()
54 : OldDecl->getLexicalDeclContext()));
63 NewDecl->setQualifierInfo(NewQualifierLoc);
78 #include "clang/Sema/AttrTemplateInstantiate.inc" 82 const AlignedAttr *Aligned,
Decl *New,
bool IsPackExpansion) {
83 if (Aligned->isAlignmentExpr()) {
90 Aligned->getSpellingListIndex(), IsPackExpansion);
93 TemplateArgs, Aligned->getLocation(),
97 Aligned->getSpellingListIndex(), IsPackExpansion);
103 const AlignedAttr *Aligned,
Decl *New) {
104 if (!Aligned->isPackExpansion()) {
110 if (Aligned->isAlignmentExpr())
116 assert(!Unexpanded.empty() &&
"Pack expansion without parameter packs?");
119 bool Expand =
true, RetainExpansion =
false;
124 Unexpanded, TemplateArgs, Expand,
125 RetainExpansion, NumExpansions))
132 for (
unsigned I = 0; I != *NumExpansions; ++I) {
141 const AssumeAlignedAttr *Aligned,
Decl *New) {
146 Expr *E, *OE =
nullptr;
152 if (Aligned->getOffset()) {
153 Result = S.
SubstExpr(Aligned->getOffset(), TemplateArgs);
160 Aligned->getSpellingListIndex());
165 const AlignValueAttr *Aligned,
Decl *New) {
172 Aligned->getSpellingListIndex());
177 const AllocAlignAttr *Align,
Decl *New) {
180 llvm::APInt(64, Align->getParamIndex().getSourceIndex()),
183 Align->getSpellingListIndex());
189 Expr *Cond =
nullptr;
203 Cond = Converted.
get();
209 S.
Diag(A->
getLocation(), diag::err_attr_cond_never_constant_expr) << A;
210 for (
const auto &
P : Diags)
211 S.
Diag(
P.first,
P.second);
221 S, TemplateArgs, EIA, EIA->getCond(), Tmpl, New);
225 EIA->getLocation(), S.
getASTContext(), Cond, EIA->getMessage(),
226 EIA->getSpellingListIndex()));
233 S, TemplateArgs, DIA, DIA->getCond(), Tmpl, New);
237 DIA->getLocation(), S.
getASTContext(), Cond, DIA->getMessage(),
238 DIA->getDiagnosticType(), DIA->getArgDependent(), New,
239 DIA->getSpellingListIndex()));
246 const CUDALaunchBoundsAttr &
Attr,
Decl *New) {
256 Expr *MinBlocks =
nullptr;
257 if (Attr.getMinBlocks()) {
258 Result = S.
SubstExpr(Attr.getMinBlocks(), TemplateArgs);
265 Attr.getSpellingListIndex());
272 S.
AddModeAttr(Attr.getRange(), New, Attr.getMode(),
273 Attr.getSpellingListIndex(),
true);
279 const OMPDeclareSimdDeclAttr &
Attr,
Decl *New) {
281 if (
auto *FTD = dyn_cast<FunctionTemplateDecl>(New))
282 New = FTD->getTemplatedDecl();
283 auto *FD = cast<FunctionDecl>(New);
284 auto *ThisContext = dyn_cast_or_null<CXXRecordDecl>(FD->getDeclContext());
289 if (
auto *DRE = dyn_cast<DeclRefExpr>(E->IgnoreParenImpCasts()))
290 if (
auto *PVD = dyn_cast<ParmVarDecl>(DRE->getDecl())) {
293 if (FD->getNumParams() > PVD->getFunctionScopeIndex())
295 PVD, FD->getParamDecl(PVD->getFunctionScopeIndex()));
299 FD->isCXXInstanceMember());
304 if (
auto *E = Attr.getSimdlen())
307 if (Attr.uniforms_size() > 0) {
308 for(
auto *E : Attr.uniforms()) {
312 Uniforms.push_back(Inst.
get());
316 auto AI = Attr.alignments_begin();
317 for (
auto *E : Attr.aligneds()) {
321 Aligneds.push_back(Inst.
get());
325 Alignments.push_back(Inst.
get());
329 auto SI = Attr.steps_begin();
330 for (
auto *E : Attr.linears()) {
334 Linears.push_back(Inst.
get());
338 Steps.push_back(Inst.
get());
341 LinModifiers.append(Attr.modifiers_begin(), Attr.modifiers_end());
344 Uniforms, Aligneds, Alignments, Linears, LinModifiers, Steps,
352 if (
NamedDecl *ND = dyn_cast<NamedDecl>(New)) {
353 for (
const auto *TmplAttr : Tmpl->
attrs()) {
357 *
this, dyn_cast_or_null<CXXRecordDecl>(ND->getDeclContext()),
361 TmplAttr, Context, *
this, TemplateArgs);
371 case clang::attr::CFConsumed:
373 case clang::attr::OSConsumed:
375 case clang::attr::NSConsumed:
378 llvm_unreachable(
"Wrong argument supplied");
386 for (
const auto *TmplAttr : Tmpl->
attrs()) {
388 const AlignedAttr *Aligned = dyn_cast<AlignedAttr>(TmplAttr);
389 if (Aligned && Aligned->isAlignmentDependent()) {
394 const AssumeAlignedAttr *AssumeAligned = dyn_cast<AssumeAlignedAttr>(TmplAttr);
400 const AlignValueAttr *AlignValue = dyn_cast<AlignValueAttr>(TmplAttr);
406 if (
const auto *AllocAlign = dyn_cast<AllocAlignAttr>(TmplAttr)) {
412 if (
const auto *EnableIf = dyn_cast<EnableIfAttr>(TmplAttr)) {
414 cast<FunctionDecl>(New));
418 if (
const auto *DiagnoseIf = dyn_cast<DiagnoseIfAttr>(TmplAttr)) {
420 cast<FunctionDecl>(New));
424 if (
const CUDALaunchBoundsAttr *CUDALaunchBounds =
425 dyn_cast<CUDALaunchBoundsAttr>(TmplAttr)) {
427 *CUDALaunchBounds, New);
431 if (
const ModeAttr *Mode = dyn_cast<ModeAttr>(TmplAttr)) {
436 if (
const auto *OMPAttr = dyn_cast<OMPDeclareSimdDeclAttr>(TmplAttr)) {
442 if (TmplAttr->getKind() == attr::DLLExport ||
443 TmplAttr->getKind() == attr::DLLImport) {
444 if (New->
hasAttr<DLLExportAttr>() || New->
hasAttr<DLLImportAttr>()) {
449 if (
auto ABIAttr = dyn_cast<ParameterABIAttr>(TmplAttr)) {
450 AddParameterABIAttr(ABIAttr->getRange(), New, ABIAttr->getABI(),
451 ABIAttr->getSpellingListIndex());
455 if (isa<NSConsumedAttr>(TmplAttr) || isa<OSConsumedAttr>(TmplAttr) ||
456 isa<CFConsumedAttr>(TmplAttr)) {
457 AddXConsumedAttr(New, TmplAttr->getRange(),
458 TmplAttr->getSpellingListIndex(),
464 assert(!TmplAttr->isPackExpansion());
465 if (TmplAttr->isLateParsed() && LateAttrs) {
469 if (CurrentInstantiationScope)
470 Saved = CurrentInstantiationScope->
cloneScopes(OuterMostScope);
481 *
this, TemplateArgs);
492 template<
typename DeclT>
494 DeclT *
Result = D->getPreviousDecl();
499 if (Result && isa<CXXRecordDecl>(D->getDeclContext()) &&
500 D->getLexicalDeclContext() != Result->getLexicalDeclContext())
508 llvm_unreachable(
"Translation units cannot be instantiated");
513 llvm_unreachable(
"pragma comment cannot be instantiated");
516 Decl *TemplateDeclInstantiator::VisitPragmaDetectMismatchDecl(
518 llvm_unreachable(
"pragma comment cannot be instantiated");
523 llvm_unreachable(
"extern \"C\" context cannot be instantiated");
527 TemplateDeclInstantiator::VisitLabelDecl(
LabelDecl *D) {
535 TemplateDeclInstantiator::VisitNamespaceDecl(
NamespaceDecl *D) {
536 llvm_unreachable(
"Namespaces cannot be instantiated");
555 bool Invalid =
false;
599 TagDecl *oldTag = oldTagType->getDecl();
618 Typedef->setPreviousDecl(InstPrevTypedef);
656 if (getPreviousDeclForInstantiation<TypedefNameDecl>(Pattern)) {
658 if (!Found.
empty()) {
671 AliasInst->setDescribedAliasTemplate(Inst);
672 if (PrevAliasTemplate)
677 if (!PrevAliasTemplate)
697 NewBindings.push_back(cast<BindingDecl>(VisitBindingDecl(OldBD)));
700 auto *NewDD = cast_or_null<DecompositionDecl>(
703 if (!NewDD || NewDD->isInvalidDecl())
704 for (
auto *NewBD : NewBindings)
705 NewBD->setInvalidDecl();
715 bool InstantiatingVarTemplate,
726 SemaRef.
Diag(D->
getLocation(), diag::err_variable_instantiates_to_function)
756 StartingScope, InstantiatingVarTemplate);
759 QualType ReturnType = cast<FunctionDecl>(DC)->getReturnType();
761 Var->setNRVOVariable(
true);
766 if (Var->isStaticLocal())
780 Decl *TemplateDeclInstantiator::VisitFieldDecl(
FieldDecl *D) {
781 bool Invalid =
false;
797 SemaRef.
Diag(D->
getLocation(), diag::err_field_instantiates_to_function)
814 = SemaRef.
SubstExpr(BitWidth, TemplateArgs);
819 BitWidth = InstantiatedBitWidth.
getAs<
Expr>();
824 cast<RecordDecl>(Owner),
833 cast<Decl>(Owner)->setInvalidDecl();
839 if (Field->hasAttrs())
843 Field->setInvalidDecl();
845 if (!Field->getDeclName()) {
850 if (
Parent->isAnonymousStructOrUnion() &&
851 Parent->getRedeclContext()->isFunctionOrMethod())
863 bool Invalid =
false;
867 SemaRef.
Diag(D->
getLocation(), diag::err_property_is_variably_modified)
883 SemaRef.
Diag(D->
getLocation(), diag::err_field_instantiates_to_function)
912 for (
auto *PI : D->
chain()) {
918 NamedChain[i++] = Next;
921 QualType T = cast<FieldDecl>(NamedChain[i-1])->getType();
932 return IndirectField;
947 InstTy = SemaRef.
SubstType(Ty, TemplateArgs,
965 assert(ND &&
"friend decl must be a decl or a type!");
972 if (!NewND)
return nullptr;
991 = SemaRef.
SubstExpr(AssertExpr, TemplateArgs);
996 InstantiatedAssertExpr.
get(),
1002 Decl *TemplateDeclInstantiator::VisitEnumDecl(
EnumDecl *D) {
1008 if (!Prev)
return nullptr;
1009 PrevDecl = cast<EnumDecl>(Prev);
1027 Enum->setIntegerTypeSourceInfo(NewTI);
1030 &&
"Dependent type without type source info");
1053 if (Def && Def != D) {
1060 SemaRef.
SubstType(TI->getType(), TemplateArgs,
1063 DefnUnderlying,
true, Enum);
1095 if (
Expr *UninstValue = EC->getInitExpr()) {
1100 Value = SemaRef.
SubstExpr(UninstValue, TemplateArgs);
1126 Enumerators.push_back(EnumConst);
1127 LastEnumConst = EnumConst;
1143 llvm_unreachable(
"EnumConstantDecls can only occur within EnumDecls.");
1148 llvm_unreachable(
"BuiltinTemplateDecls cannot be instantiated.");
1180 if (!Found.
empty()) {
1182 if (PrevClassTemplate)
1195 SS.
Adopt(QualifierLoc);
1197 if (!DC)
return nullptr;
1211 if (R.isSingleResult()) {
1213 if (PrevClassTemplate)
1217 if (!PrevClassTemplate && QualifierLoc) {
1224 bool AdoptedPreviousTemplateParams =
false;
1225 if (PrevClassTemplate) {
1226 bool Complain =
true;
1238 cast<NamespaceDecl>(DC)->
getIdentifier()->isStr(
"__detail")) {
1242 cast<NamespaceDecl>(DCParent)->
getIdentifier()->isStr(
"tr1")) {
1243 if (cast<Decl>(DCParent)->isInStdNamespace())
1258 AdoptedPreviousTemplateParams =
true;
1259 InstParams = PrevParams;
1264 if (!AdoptedPreviousTemplateParams &&
1291 if (PrevClassTemplate)
1301 if (!PrevClassTemplate)
1324 if (!PrevClassTemplate) {
1330 for (
unsigned I = 0, N = PartialSpecs.size(); I != N; ++I)
1331 if (PartialSpecs[I]->getFirstDecl()->isOutOfLine())
1332 OutOfLinePartialSpecs.push_back(std::make_pair(Inst, PartialSpecs[I]));
1339 TemplateDeclInstantiator::VisitClassTemplatePartialSpecializationDecl(
1352 if (!InstClassTemplate)
1364 "Only static data member templates are allowed.");
1380 PrevVarTemplate = dyn_cast<VarTemplateDecl>(Found.
front());
1386 if (!VarInst)
return nullptr;
1397 if (!PrevVarTemplate)
1407 if (!PrevVarTemplate) {
1413 for (
unsigned I = 0, N = PartialSpecs.size(); I != N; ++I)
1414 if (PartialSpecs[I]->getFirstDecl()->isOutOfLine())
1415 OutOfLineVarPartialSpecs.push_back(
1416 std::make_pair(Inst, PartialSpecs[I]));
1422 Decl *TemplateDeclInstantiator::VisitVarTemplatePartialSpecializationDecl(
1425 "Only static data member templates are allowed.");
1431 assert(!Found.
empty() &&
"Instantiation found nothing?");
1434 assert(InstVarTemplate &&
"Instantiation did not find a variable template?");
1437 InstVarTemplate->findPartialSpecInstantiatedFromMember(D))
1471 = Instantiated->getDescribedFunctionTemplate();
1473 assert(InstTemplate &&
1474 "VisitFunctionDecl/CXXMethodDecl didn't create a template!");
1492 return InstTemplate;
1498 PrevDecl = cast<CXXRecordDecl>(Owner);
1503 if (!Prev)
return nullptr;
1504 PrevDecl = cast<CXXRecordDecl>(Prev);
1530 Record->setObjectOfFriendDecl();
1534 Record->setAnonymousStructOrUnion(
true);
1566 if (!D->isCXXClassMember())
1572 LocalInstantiations.
perform();
1593 if (OrigFunc->
getExtInfo() == NewFunc->getExtInfo())
1599 NewFunc->getParamTypes(), NewEPI);
1612 if (FunctionTemplate && !TemplateParams) {
1615 void *InsertPos =
nullptr;
1625 if (FunctionTemplate)
1630 bool MergeWithParentScope = (TemplateParams !=
nullptr) ||
1632 !(isa<Decl>(Owner) &&
1633 cast<Decl>(Owner)->isDefinedOutsideFunctionOrMethod());
1657 }
else if (isFriend && QualifierLoc) {
1659 SS.
Adopt(QualifierLoc);
1661 if (!DC)
return nullptr;
1671 if (
auto *DGuide = dyn_cast<CXXDeductionGuideDecl>(D)) {
1675 if (DGuide->isCopyDeductionCandidate())
1704 for (
unsigned P = 0;
P < Params.size(); ++
P)
1706 Params[
P]->setOwningFunction(Function);
1707 Function->setParams(Params);
1709 if (TemplateParams) {
1727 TemplateParams, Function);
1736 }
else if (FunctionTemplate) {
1739 Function->setFunctionTemplateSpecialization(FunctionTemplate,
1756 bool IsExplicitSpecialization =
false;
1767 assert(isFriend &&
"non-friend has dependent specialization info?");
1771 Info->getRAngleLoc());
1772 if (SemaRef.
Subst(Info->getTemplateArgs(), Info->getNumTemplateArgs(),
1773 ExplicitArgs, TemplateArgs))
1777 for (
unsigned I = 0, E = Info->getNumTemplates(); I != E; ++I) {
1779 Info->getTemplate(I),
1781 if (!Temp)
return nullptr;
1783 Previous.addDecl(cast<FunctionTemplateDecl>(Temp));
1791 IsExplicitSpecialization =
true;
1799 Info->getRAngleLoc());
1800 if (SemaRef.
Subst(Info->getTemplateArgs(), Info->getNumTemplateArgs(),
1801 ExplicitArgs, TemplateArgs))
1809 IsExplicitSpecialization =
true;
1810 }
else if (TemplateParams || !FunctionTemplate) {
1825 IsExplicitSpecialization);
1827 NamedDecl *PrincipalDecl = (TemplateParams
1828 ? cast<NamedDecl>(FunctionTemplate)
1836 FT->setObjectOfFriendDecl();
1839 bool QueuedInstantiation =
false;
1850 for (
auto R : Function->
redecls()) {
1856 if (!QueuedInstantiation && R->isUsed(
false)) {
1859 if (MSInfo->getPointOfInstantiation().isInvalid()) {
1861 MSInfo->setPointOfInstantiation(Loc);
1863 std::make_pair(Function, Loc));
1864 QueuedInstantiation =
true;
1893 assert(!D->
isDefaulted() &&
"only methods should be defaulted");
1900 bool IsClassScopeSpecialization) {
1902 if (FunctionTemplate && !TemplateParams) {
1908 void *InsertPos =
nullptr;
1918 if (FunctionTemplate)
1923 bool MergeWithParentScope = (TemplateParams !=
nullptr) ||
1924 !(isa<Decl>(Owner) &&
1925 cast<Decl>(Owner)->isDefinedOutsideFunctionOrMethod());
1930 unsigned NumTempParamLists = 0;
1932 TempParamLists.resize(NumTempParamLists);
1933 for (
unsigned I = 0; I != NumTempParamLists; ++I) {
1938 TempParamLists[I] = InstParams;
1960 SS.
Adopt(QualifierLoc);
1970 if (!DC)
return nullptr;
1982 StartLoc, NameInfo, T, TInfo,
1983 Constructor->isExplicit(),
1984 Constructor->isInlineSpecified(),
1985 false, Constructor->isConstexpr());
1989 StartLoc, NameInfo, T, TInfo,
1990 Destructor->isInlineSpecified(),
1995 SemaRef.
Context, Record, StartLoc, NameInfo, T, TInfo,
1996 Conversion->isInlineSpecified(), Conversion->isExplicit(),
1997 Conversion->isConstexpr(), Conversion->getEndLoc());
2009 Method->setQualifierInfo(QualifierLoc);
2011 if (TemplateParams) {
2027 Method->getDeclName(),
2028 TemplateParams, Method);
2034 Method->setDescribedFunctionTemplate(FunctionTemplate);
2035 }
else if (FunctionTemplate) {
2038 Method->setFunctionTemplateSpecialization(FunctionTemplate,
2042 }
else if (!isFriend) {
2051 if (NumTempParamLists)
2052 Method->setTemplateParameterListsInfo(
2054 llvm::makeArrayRef(TempParamLists.data(), NumTempParamLists));
2056 Method->setLexicalDeclContext(Owner);
2057 Method->setObjectOfFriendDecl();
2062 for (
unsigned P = 0;
P < Params.size(); ++
P)
2063 Params[
P]->setOwningFunction(Method);
2064 Method->setParams(Params);
2067 Method->setInvalidDecl();
2072 bool IsExplicitSpecialization =
false;
2078 assert(isFriend &&
"non-friend has dependent specialization info?");
2082 Info->getRAngleLoc());
2083 if (SemaRef.
Subst(Info->getTemplateArgs(), Info->getNumTemplateArgs(),
2084 ExplicitArgs, TemplateArgs))
2088 for (
unsigned I = 0, E = Info->getNumTemplates(); I != E; ++I) {
2090 Info->getTemplate(I),
2092 if (!Temp)
return nullptr;
2094 Previous.
addDecl(cast<FunctionTemplateDecl>(Temp));
2100 Method->setInvalidDecl();
2102 IsExplicitSpecialization =
true;
2108 Info->getRAngleLoc());
2109 if (SemaRef.
Subst(Info->getTemplateArgs(), Info->getNumTemplateArgs(),
2110 ExplicitArgs, TemplateArgs))
2116 Method->setInvalidDecl();
2118 IsExplicitSpecialization =
true;
2119 }
else if (!FunctionTemplate || TemplateParams || isFriend) {
2130 if (!IsClassScopeSpecialization)
2132 IsExplicitSpecialization);
2140 if (isFriend && Method->getPreviousDecl())
2141 Method->setAccess(Method->getPreviousDecl()->getAccess());
2144 if (FunctionTemplate)
2145 FunctionTemplate->
setAccess(Method->getAccess());
2156 if (FunctionTemplate) {
2160 }
else if (Method->isInvalidDecl() && !Previous.
empty()) {
2164 }
else if (isFriend) {
2175 }
else if (!IsClassScopeSpecialization) {
2199 Decl *TemplateDeclInstantiator::VisitTemplateTypeParmDecl(
2214 if (InstantiatedDefaultArg)
2215 Inst->setDefaultArgument(InstantiatedDefaultArg);
2225 Decl *TemplateDeclInstantiator::VisitNonTypeTemplateParmDecl(
2231 bool IsExpandedParameterPack =
false;
2234 bool Invalid =
false;
2253 ExpandedParameterPackTypesAsWritten.push_back(NewDI);
2254 ExpandedParameterPackTypes.push_back(NewT);
2257 IsExpandedParameterPack =
true;
2272 bool RetainExpansion =
false;
2277 Pattern.getSourceRange(),
2280 Expand, RetainExpansion,
2285 for (
unsigned I = 0; I != *NumExpansions; ++I) {
2298 ExpandedParameterPackTypesAsWritten.push_back(NewDI);
2299 ExpandedParameterPackTypes.push_back(NewT);
2305 IsExpandedParameterPack =
true;
2342 if (IsExpandedParameterPack)
2347 ExpandedParameterPackTypesAsWritten);
2356 Param->setInvalidDecl();
2363 Param->setDefaultArgument(Value.
get());
2376 for (
const auto &
P : *Params) {
2377 if (
P->isTemplateParameterPack())
2389 TemplateDeclInstantiator::VisitTemplateTemplateParmDecl(
2396 bool IsExpandedParameterPack =
false;
2410 ExpandedParams.push_back(Expansion);
2413 IsExpandedParameterPack =
true;
2414 InstParams = TempParams;
2426 bool RetainExpansion =
false;
2432 Expand, RetainExpansion,
2437 for (
unsigned I = 0; I != *NumExpansions; ++I) {
2443 ExpandedParams.push_back(Expansion);
2449 IsExpandedParameterPack =
true;
2450 InstParams = TempParams;
2472 if (IsExpandedParameterPack)
2491 Param->setDefaultArgument(
2526 Decl *TemplateDeclInstantiator::VisitUsingDecl(
UsingDecl *D) {
2547 if (
auto *RD = dyn_cast<CXXRecordDecl>(SemaRef.
CurContext))
2554 bool CheckRedeclaration = Owner->
isRecord();
2566 SS.
Adopt(QualifierLoc);
2567 if (CheckRedeclaration) {
2598 for (
auto *Shadow : D->
shadows()) {
2601 NamedDecl *OldTarget = Shadow->getTargetDecl();
2602 if (
auto *CUSD = dyn_cast<ConstructorUsingShadowDecl>(Shadow))
2603 if (
auto *BaseShadow = CUSD->getNominatedBaseClassShadowDecl())
2604 OldTarget = BaseShadow;
2608 Shadow->getLocation(), OldTarget, TemplateArgs));
2613 if (CheckRedeclaration) {
2619 Shadow->getLocation(), OldPrev, TemplateArgs));
2627 if (isFunctionScope)
2639 Decl *TemplateDeclInstantiator::VisitConstructorUsingShadowDecl(
2645 template <
typename T>
2646 Decl *TemplateDeclInstantiator::instantiateUnresolvedUsingDecl(
2647 T *D,
bool InstantiatingPackElement) {
2649 if (D->isPackExpansion() && !InstantiatingPackElement) {
2657 bool RetainExpansion =
false;
2660 D->getEllipsisLoc(), D->
getSourceRange(), Unexpanded, TemplateArgs,
2661 Expand, RetainExpansion, NumExpansions))
2666 assert(!RetainExpansion &&
2667 "should never need to retain an expansion for UsingPackDecl");
2673 return instantiateUnresolvedUsingDecl(D,
true);
2684 SemaRef.
Diag(D->getEllipsisLoc(),
2685 diag::err_using_decl_redeclaration_expansion);
2691 for (
unsigned I = 0; I != *NumExpansions; ++I) {
2693 Decl *Slice = instantiateUnresolvedUsingDecl(D,
true);
2700 Expansions.push_back(cast<NamedDecl>(Slice));
2719 SS.
Adopt(QualifierLoc);
2726 bool InstantiatingSlice = D->getEllipsisLoc().isValid() &&
2732 nullptr, D->
getAccess(), D->getUsingLoc(),
2733 TD, TypenameLoc, SS, NameInfo, EllipsisLoc,
2742 Decl *TemplateDeclInstantiator::VisitUnresolvedUsingTypenameDecl(
2744 return instantiateUnresolvedUsingDecl(D);
2747 Decl *TemplateDeclInstantiator::VisitUnresolvedUsingValueDecl(
2749 return instantiateUnresolvedUsingDecl(D);
2757 Expansions.push_back(NewUD);
2768 Decl *TemplateDeclInstantiator::VisitClassScopeFunctionSpecializationDecl(
2783 ExplicitTemplateArgsPtr = &ExplicitTemplateArgs;
2790 NewFD, ExplicitTemplateArgsPtr,
Previous)) {
2797 assert(Specialization &&
"Class scope Specialization is null");
2805 Decl *TemplateDeclInstantiator::VisitOMPThreadPrivateDecl(
2810 assert(isa<DeclRefExpr>(Var) &&
"threadprivate arg is not a DeclRefExpr");
2811 Vars.push_back(Var);
2823 Decl *TemplateDeclInstantiator::VisitOMPRequiresDecl(
OMPRequiresDecl *D) {
2825 "Requires directive cannot be instantiated within a dependent context");
2828 Decl *TemplateDeclInstantiator::VisitOMPDeclareReductionDecl(
2831 const bool RequiresInstantiation =
2836 if (RequiresInstantiation) {
2842 SubstReductionType = D->
getType();
2844 if (SubstReductionType.
isNull())
2846 bool IsCorrect = !SubstReductionType.
isNull();
2848 std::pair<QualType, SourceLocation> ReductionTypes[] = {
2849 std::make_pair(SubstReductionType, D->
getLocation())};
2851 if (PrevDeclInScope && !PrevDeclInScope->isInvalidDecl()) {
2852 PrevDeclInScope = cast<OMPDeclareReductionDecl>(
2859 auto *NewDRD = cast<OMPDeclareReductionDecl>(DRD.get().getSingleDecl());
2861 if (!RequiresInstantiation) {
2864 NewDRD->setCombiner(Combiner);
2874 Expr *SubstCombiner =
nullptr;
2875 Expr *SubstInitializer =
nullptr;
2882 cast<DeclRefExpr>(NewDRD->getCombinerIn())->getDecl());
2885 cast<DeclRefExpr>(NewDRD->getCombinerOut())->getDecl());
2886 auto *ThisContext = dyn_cast_or_null<CXXRecordDecl>(Owner);
2898 cast<DeclRefExpr>(NewDRD->getInitOrig())->getDecl());
2901 cast<DeclRefExpr>(NewDRD->getInitPriv())->getDecl());
2906 IsCorrect = IsCorrect && OmpPrivParm->
hasInit();
2909 NewDRD, SubstInitializer, OmpPrivParm);
2912 IsCorrect && SubstCombiner &&
2915 SubstInitializer) ||
2917 !SubstInitializer && !SubstInitializer));
2928 Decl *TemplateDeclInstantiator::VisitOMPCapturedExprDecl(
2930 llvm_unreachable(
"Should not be met in templates");
2949 Decl *TemplateDeclInstantiator::VisitRecordDecl(
RecordDecl *D) {
2950 llvm_unreachable(
"There are only CXXRecordDecls in C++");
2954 TemplateDeclInstantiator::VisitClassTemplateSpecializationDecl(
2961 "can only instantiate an explicit specialization " 2962 "for a member class template");
2972 if (!InstClassTemplate)
2978 castAs<TemplateSpecializationTypeLoc>();
2982 for (
unsigned I = 0; I != Loc.
getNumArgs(); ++I)
2984 if (SemaRef.
Subst(ArgLocs.data(), ArgLocs.size(),
2985 InstTemplateArgs, TemplateArgs))
3000 void *InsertPos =
nullptr;
3032 diag::note_previous_definition);
3040 D->
getLocation(), InstClassTemplate, Converted, PrevDecl);
3094 assert(VarTemplate &&
3095 "A template specialization without specialized template?");
3103 TemplateArgsInfo.
size(), VarTemplateArgsInfo, TemplateArgs))
3116 void *InsertPos =
nullptr;
3118 Converted, InsertPos))
3123 VarTemplateArgsInfo, Converted);
3139 SemaRef.
Diag(D->
getLocation(), diag::err_variable_instantiates_to_function)
3157 Owner, StartingScope);
3163 llvm_unreachable(
"@defs is not supported in Objective-C++");
3170 "cannot instantiate %0 yet");
3178 llvm_unreachable(
"Unexpected decl");
3187 return Instantiator.
Visit(D);
3199 bool Invalid =
false;
3201 unsigned N = L->
size();
3205 for (
auto &
P : *L) {
3207 Params.push_back(D);
3216 Expr *
const UninstantiatedRequiresClause = L->getRequiresClause();
3220 L->getLAngleLoc(), Params,
3222 UninstantiatedRequiresClause);
3268 InstTemplateArgs, TemplateArgs))
3289 void *InsertPos =
nullptr;
3329 SemaRef.
Diag(PartialSpec->
getLocation(), diag::err_partial_spec_redeclared)
3331 SemaRef.
Diag(PrevDecl->
getLocation(), diag::note_prev_partial_spec_here)
3342 ClassTemplate, Converted, InstTemplateArgs, CanonType,
nullptr);
3355 ClassTemplate->AddPartialSpecialization(InstPartialSpec,
3357 return InstPartialSpec;
3395 InstTemplateArgs, TemplateArgs))
3402 InstTemplateArgs,
false, Converted))
3413 void *InsertPos =
nullptr;
3450 diag::err_var_partial_spec_redeclared)
3453 diag::note_var_prev_partial_spec_here);
3466 diag::err_variable_instantiates_to_function)
3490 VarTemplate->AddPartialSpecialization(InstPartialSpec,
nullptr);
3493 LateAttrs, Owner, StartingScope);
3495 return InstPartialSpec;
3502 assert(OldTInfo &&
"substituting function without type source info");
3503 assert(Params.empty() &&
"parameter vector is non-empty at start");
3508 ThisContext = cast<CXXRecordDecl>(Owner);
3509 ThisTypeQuals = Method->getTypeQualifiers();
3516 ThisContext, ThisTypeQuals);
3522 if (NewTInfo != OldTInfo) {
3526 unsigned NewIdx = 0;
3527 for (
unsigned OldIdx = 0, NumOldParams = OldProtoLoc.getNumParams();
3528 OldIdx != NumOldParams; ++OldIdx) {
3529 ParmVarDecl *OldParam = OldProtoLoc.getParam(OldIdx);
3534 NumArgumentsInExpansion =
3537 if (!NumArgumentsInExpansion) {
3541 Params.push_back(NewParam);
3546 for (
unsigned I = 0; I != *NumArgumentsInExpansion; ++I) {
3548 Params.push_back(NewParam);
3558 cast<FunctionProtoType>(OldProtoLoc.getType());
3559 for (
unsigned i = 0, i_end = OldProtoLoc.getNumParams(); i != i_end;
3569 cast_or_null<ParmVarDecl>(VisitParmVarDecl(OldParam));
3572 Params.push_back(Parm);
3589 TemplateArgs, ParamTypes, &Params,
3604 unsigned FParamIdx = 0;
3605 for (
unsigned I = 0, N = PatternDecl->
getNumParams(); I != N; ++I) {
3609 assert(FParamIdx < Function->getNumParams());
3636 assert(NumArgumentsInExpansion &&
3637 "should only be called when all template arguments are known");
3640 for (
unsigned Arg = 0; Arg < *NumArgumentsInExpansion; ++Arg) {
3672 UpdateExceptionSpec(Decl,
EST_None);
3678 Diag(PointOfInstantiation, diag::err_exception_spec_cycle) << Decl;
3679 UpdateExceptionSpec(Decl,
EST_None);
3689 getTemplateInstantiationArgs(Decl,
nullptr,
true);
3694 UpdateExceptionSpec(Decl,
EST_None);
3728 if (ActiveInst.Kind == ActiveInstType::ExplicitTemplateArgumentSubstitution ||
3729 ActiveInst.Kind == ActiveInstType::DeducedTemplateArgumentSubstitution) {
3731 = dyn_cast<FunctionTemplateDecl>(ActiveInst.Entity)) {
3732 assert(FunTmpl->getTemplatedDecl() == Tmpl &&
3733 "Deduction from the wrong function template?");
3736 ActiveInst.Kind = ActiveInstType::TemplateInstantiation;
3737 ActiveInst.Entity = New;
3743 assert(Proto &&
"Function template without prototype?");
3767 assert(NewProto &&
"Template instantiation without function prototype?");
3785 LateAttrs, StartingScope);
3801 if (isa<CXXDestructorDecl>(New) && SemaRef.
getLangOpts().CPlusPlus11)
3825 *
this, Loc, FTD, Args->
asArray(),
3826 CodeSynthesisContext::ExplicitTemplateArgumentSubstitution, Info);
3827 if (Inst.isInvalid())
3833 return cast_or_null<FunctionDecl>(SubstDecl(FD, FD->
getParent(), MArgs));
3847 DLLExportAttr *
Attr = Ctor->
getAttr<DLLExportAttr>();
3850 for (
unsigned I = 0; I != NumParams; ++I) {
3877 bool DefinitionRequired,
3880 isa<CXXDeductionGuideDecl>(Function))
3892 assert(PatternDecl &&
"instantiating a non-template");
3895 Stmt *Pattern =
nullptr;
3897 Pattern = PatternDef->
getBody(PatternDef);
3898 PatternDecl = PatternDef;
3900 PatternDef =
nullptr;
3905 if (DiagnoseUninstantiableTemplate(PointOfInstantiation, Function,
3907 PatternDecl, PatternDef, TSK,
3908 DefinitionRequired)) {
3909 if (DefinitionRequired)
3916 PendingInstantiations.push_back(
3917 std::make_pair(Function, PointOfInstantiation));
3919 if (AtEndOfTU && !getDiagnostics().hasErrorOccurred() &&
3920 !getSourceManager().isInSystemHeader(PatternDecl->
getBeginLoc())) {
3921 Diag(PointOfInstantiation, diag::warn_func_template_missing)
3924 if (getLangOpts().CPlusPlus11)
3925 Diag(PointOfInstantiation, diag::note_inst_declaration_hint)
3935 !LateTemplateParser) {
3937 LateParsedInstantiations.push_back(
3938 std::make_pair(Function, PointOfInstantiation));
3954 LateTemplateParser) {
3957 ExternalSource->ReadLateParsedTemplates(LateParsedTemplateMap);
3959 auto LPTIter = LateParsedTemplateMap.find(PatternDecl);
3960 assert(LPTIter != LateParsedTemplateMap.end() &&
3961 "missing LateParsedTemplate");
3962 LateTemplateParser(OpaqueParser, *LPTIter->second);
3963 Pattern = PatternDecl->
getBody(PatternDecl);
3969 "unexpected kind of function template definition");
3986 D->setImplicitlyInline();
3996 "instantiating function definition");
4012 bool MergeWithParentScope =
false;
4014 MergeWithParentScope = Rec->isLocalClass();
4019 SetDeclDefaulted(Function, PatternDecl->
getLocation());
4022 getTemplateInstantiationArgs(Function,
nullptr,
false, PatternDecl);
4030 ActOnStartOfFunctionDef(
nullptr, Function);
4042 ActOnSkippedFunctionBody(Function);
4047 InstantiateMemInitializers(Ctor, cast<CXXConstructorDecl>(PatternDecl),
4053 Ctor->isDefaultConstructor()) {
4059 Body = SubstStmt(Pattern, TemplateArgs);
4066 ActOnFinishFunctionBody(Function, Body.
get(),
true);
4068 PerformDependentDiagnostics(PatternDecl, TemplateArgs);
4070 if (
auto *Listener = getASTMutationListener())
4071 Listener->FunctionDefinitionInstantiated(Function);
4077 Consumer.HandleTopLevelDecl(DG);
4081 LocalInstantiations.
perform();
4083 GlobalInstantiations.
perform();
4113 bool IsMemberSpec =
false;
4115 dyn_cast<VarTemplatePartialSpecializationDecl>(FromVar))
4116 IsMemberSpec = PartialSpec->isMemberSpecialization();
4118 IsMemberSpec = FromTemplate->isMemberSpecialization();
4128 return cast_or_null<VarTemplateSpecializationDecl>(
4129 Instantiator.VisitVarTemplateSpecializationDecl(
4130 VarTemplate, FromVar, InsertPos, TemplateArgsInfo, Converted));
4139 "don't have a definition to instantiate from");
4149 VarSpec->
setType(DI->getType());
4155 InstantiateVariableInitializer(VarSpec, PatternDecl, TemplateArgs);
4168 bool InstantiatingVarTemplate) {
4191 if (OldVar->
isUsed(
false))
4196 InstantiateAttrs(TemplateArgs, OldVar, NewVar, LateAttrs, StartingScope);
4203 : forRedeclarationInCurContext());
4210 if (
NamedDecl *NewPrev = FindInstantiatedDecl(
4213 }
else if (!isa<VarTemplateSpecializationDecl>(NewVar) &&
4216 CheckVariableDeclaration(NewVar,
Previous);
4218 if (!InstantiatingVarTemplate) {
4226 CurrentInstantiationScope->InstantiatedLocal(OldVar, NewVar);
4242 if ((!isa<VarTemplateSpecializationDecl>(NewVar) &&
4243 !InstantiatingVarTemplate &&
4247 InstantiateVariableInitializer(NewVar, OldVar, TemplateArgs);
4254 DiagnoseUnusedDecl(NewVar);
4262 L->VariableDefinitionInstantiated(Var);
4281 Init = SubstInitializer(OldVar->
getInit(), TemplateArgs,
4288 if (Var->
hasAttr<DLLImportAttr>() &&
4292 }
else if (InitExpr) {
4294 AddInitializerToDecl(Var, InitExpr, DirectInit);
4296 ActOnUninitializedDecl(Var);
4319 ActOnUninitializedDecl(Var);
4322 if (getLangOpts().CUDA)
4323 checkAllowedCUDAInitializer(Var);
4343 bool DefinitionRequired,
bool AtEndOfTU) {
4349 VarDecl *PatternDecl =
nullptr, *Def =
nullptr;
4351 getTemplateInstantiationArgs(Var);
4356 bool InstantiationDependent =
false;
4359 "Only instantiate variable template specializations that are " 4360 "not type-dependent");
4361 (void)InstantiationDependent;
4367 "Specialization without specialized template?");
4383 VarTemplateDecl *Tmpl = PatternPtr.get<VarTemplateDecl *>();
4384 while (VarTemplateDecl *From =
4402 if (PatternDecl->isStaticDataMember() &&
4403 (PatternDecl = PatternDecl->getFirstDecl())->hasInit() &&
4411 "instantiating variable initializer");
4428 InstantiateVariableInitializer(Var, PatternDecl, TemplateArgs);
4429 PreviousContext.pop();
4433 LocalInstantiations.
perform();
4435 GlobalInstantiations.
perform();
4439 Def = PatternDecl->getDefinition(getASTContext());
4445 assert(PatternDecl &&
"data member was not instantiated from a template?");
4446 assert(PatternDecl->isStaticDataMember() &&
"not a static data member?");
4447 Def = PatternDecl->getDefinition();
4456 if (!Def && !DefinitionRequired) {
4458 PendingInstantiations.push_back(
4459 std::make_pair(Var, PointOfInstantiation));
4462 if (AtEndOfTU && !getDiagnostics().hasErrorOccurred() &&
4463 !getSourceManager().isInSystemHeader(PatternDecl->getBeginLoc())) {
4464 Diag(PointOfInstantiation, diag::warn_var_template_missing)
4466 Diag(PatternDecl->getLocation(), diag::note_forward_template_decl);
4467 if (getLangOpts().CPlusPlus11)
4468 Diag(PointOfInstantiation, diag::note_inst_declaration_hint) << Var;
4478 if (DiagnoseUninstantiableTemplate(PointOfInstantiation, Var,
4480 PatternDecl, Def, TSK,
4481 DefinitionRequired))
4499 struct PassToConsumerRAII {
4504 : Consumer(Consumer), Var(Var) { }
4506 ~PassToConsumerRAII() {
4509 } PassToConsumerRAII(Consumer, Var);
4516 PointOfInstantiation);
4524 "instantiating variable definition");
4540 if (Def->isStaticDataMember() && !Def->isOutOfLine()) {
4543 InstantiateVariableInitializer(Var, Def, TemplateArgs);
4544 }
else if (!VarSpec) {
4545 Var = cast_or_null<VarDecl>(SubstDecl(Def, Var->
getDeclContext(),
4554 Var = cast_or_null<VarDecl>(Instantiator.VisitVarTemplateSpecializationDecl(
4563 cast<VarTemplateSpecializationDecl>(Var)->setInstantiationOf(
4567 LookupResult R(*
this, Var->getDeclName(), Var->getLocation(),
4568 LookupOrdinaryName, forRedeclarationInCurContext());
4570 MergeVarDecl(Var, R);
4573 InstantiateVariableInitializer(Var, Def, TemplateArgs);
4578 Var = CompleteVarTemplateSpecializationDecl(VarSpec, Def, TemplateArgs);
4580 PreviousContext.pop();
4583 PassToConsumerRAII.Var = Var;
4590 LocalInstantiations.
perform();
4592 GlobalInstantiations.
perform();
4604 for (
const auto *Init : Tmpl->
inits()) {
4607 if (!Init->isWritten())
4612 if (Init->isPackExpansion()) {
4614 TypeLoc BaseTL = Init->getTypeSourceInfo()->getTypeLoc();
4618 bool ShouldExpand =
false;
4619 bool RetainExpansion =
false;
4621 if (CheckParameterPacksForExpansion(Init->getEllipsisLoc(),
4624 TemplateArgs, ShouldExpand,
4631 assert(ShouldExpand &&
"Partial instantiation of base initializer?");
4634 for (
unsigned I = 0; I != *NumExpansions; ++I) {
4638 ExprResult TempInit = SubstInitializer(Init->getInit(), TemplateArgs,
4648 Init->getSourceLocation(),
4657 BaseTInfo, TempInit.
get(),
4665 NewInits.push_back(NewInit.
get());
4672 ExprResult TempInit = SubstInitializer(Init->getInit(), TemplateArgs,
4680 if (Init->isDelegatingInitializer() || Init->isBaseInitializer()) {
4683 Init->getSourceLocation(),
4691 if (Init->isBaseInitializer())
4692 NewInit = BuildBaseInitializer(TInfo->
getType(), TInfo, TempInit.
get(),
4695 NewInit = BuildDelegatingInitializer(TInfo, TempInit.
get(),
4696 cast<CXXRecordDecl>(CurContext->getParent()));
4697 }
else if (Init->isMemberInitializer()) {
4698 FieldDecl *Member = cast_or_null<FieldDecl>(FindInstantiatedDecl(
4699 Init->getMemberLocation(),
4708 NewInit = BuildMemberInitializer(Member, TempInit.
get(),
4709 Init->getSourceLocation());
4710 }
else if (Init->isIndirectMemberInitializer()) {
4712 cast_or_null<IndirectFieldDecl>(FindInstantiatedDecl(
4713 Init->getMemberLocation(),
4714 Init->getIndirectMember(), TemplateArgs));
4716 if (!IndirectMember) {
4722 NewInit = BuildMemberInitializer(IndirectMember, TempInit.
get(),
4723 Init->getSourceLocation());
4730 NewInits.push_back(NewInit.
get());
4735 ActOnMemInitializers(New,
4750 if (Pattern == Instance)
return true;
4763 if (Pattern == Instance)
return true;
4774 = cast<ClassTemplatePartialSpecializationDecl>(Pattern->
getCanonicalDecl());
4776 Instance = cast<ClassTemplatePartialSpecializationDecl>(
4778 if (Pattern == Instance)
4792 if (Pattern == Instance)
return true;
4805 if (Pattern == Instance)
return true;
4818 if (Pattern == Instance)
return true;
4837 template<
typename T>
4846 bool OtherIsPackExpansion;
4848 if (
auto *OtherUUD = dyn_cast<T>(Other)) {
4849 OtherIsPackExpansion = OtherUUD->isPackExpansion();
4851 }
else if (
auto *OtherUPD = dyn_cast<UsingPackDecl>(Other)) {
4852 OtherIsPackExpansion =
true;
4853 OtherFrom = OtherUPD->getInstantiatedFromUsingDecl();
4854 }
else if (
auto *OtherUD = dyn_cast<UsingDecl>(Other)) {
4855 OtherIsPackExpansion =
false;
4860 return Pattern->isPackExpansion() == OtherIsPackExpansion &&
4872 if (Pattern == Instance)
return true;
4882 if (
auto *UUD = dyn_cast<UnresolvedUsingTypenameDecl>(D))
4885 if (
auto *UUD = dyn_cast<UnresolvedUsingValueDecl>(D))
4891 if (
auto *Record = dyn_cast<CXXRecordDecl>(Other))
4894 if (
auto *Function = dyn_cast<FunctionDecl>(Other))
4897 if (
auto *Enum = dyn_cast<EnumDecl>(Other))
4900 if (
auto *Var = dyn_cast<VarDecl>(Other))
4901 if (Var->isStaticDataMember())
4904 if (
auto *Temp = dyn_cast<ClassTemplateDecl>(Other))
4907 if (
auto *Temp = dyn_cast<FunctionTemplateDecl>(Other))
4910 if (
auto *PartialSpec =
4911 dyn_cast<ClassTemplatePartialSpecializationDecl>(Other))
4915 if (
auto *Field = dyn_cast<FieldDecl>(Other)) {
4916 if (!Field->getDeclName()) {
4919 cast<FieldDecl>(D));
4923 if (
auto *Using = dyn_cast<UsingDecl>(Other))
4926 if (
auto *Shadow = dyn_cast<UsingShadowDecl>(Other))
4930 D->
getDeclName() == cast<NamedDecl>(Other)->getDeclName();
4933 template<
typename ForwardIterator>
4936 ForwardIterator first,
4937 ForwardIterator last) {
4938 for (; first != last; ++first)
4940 return cast<NamedDecl>(*first);
4951 if (
NamedDecl *D = dyn_cast<NamedDecl>(DC)) {
4952 Decl*
ID = FindInstantiatedDecl(Loc, D, TemplateArgs,
true);
4953 return cast_or_null<DeclContext>(
ID);
4985 bool FindingInstantiatedContext) {
5004 !cast<ParmVarDecl>(D)->getType()->isInstantiationDependentType())
5006 if (isa<ParmVarDecl>(D) || isa<NonTypeTemplateParmDecl>(D) ||
5007 isa<TemplateTypeParmDecl>(D) || isa<TemplateTemplateParmDecl>(D) ||
5009 isa<OMPDeclareReductionDecl>(ParentDC)) &&
5011 (isa<CXXRecordDecl>(D) && cast<CXXRecordDecl>(D)->isLambda())) {
5014 if (CurrentInstantiationScope) {
5015 if (
auto Found = CurrentInstantiationScope->findInstantiationOf(D)) {
5016 if (Decl *FD = Found->dyn_cast<Decl *>())
5017 return cast<NamedDecl>(FD);
5019 int PackIdx = ArgumentPackSubstitutionIndex;
5020 assert(PackIdx != -1 &&
5021 "found declaration pack but not pack expanding");
5023 return cast<NamedDecl>((*Found->get<DeclArgumentPack *>())[PackIdx]);
5030 if (isa<NonTypeTemplateParmDecl>(D) || isa<TemplateTypeParmDecl>(D) ||
5031 isa<TemplateTemplateParmDecl>(D))
5050 bool NeedInstantiate =
false;
5052 NeedInstantiate = RD->isLocalClass();
5054 NeedInstantiate = isa<EnumDecl>(D);
5055 if (NeedInstantiate) {
5056 Decl *Inst = SubstDecl(D, CurContext, TemplateArgs);
5057 CurrentInstantiationScope->InstantiatedLocal(D, Inst);
5058 return cast<TypeDecl>(Inst);
5063 assert(isa<LabelDecl>(D));
5065 Decl *Inst = SubstDecl(D, CurContext, TemplateArgs);
5066 assert(Inst &&
"Failed to instantiate label??");
5068 CurrentInstantiationScope->InstantiatedLocal(D, Inst);
5069 return cast<LabelDecl>(Inst);
5075 dyn_cast<VarTemplateSpecializationDecl>(D)) {
5076 bool InstantiationDependent =
false;
5078 VarSpec->getTemplateArgsInfo();
5080 VarTemplateArgs, InstantiationDependent))
5081 D = cast<NamedDecl>(
5087 if (!Record->isDependentContext())
5096 = dyn_cast<ClassTemplatePartialSpecializationDecl>(Record))
5108 if (
CXXRecordDecl *InstRecord = dyn_cast<CXXRecordDecl>(DC)) {
5112 = dyn_cast<ClassTemplateSpecializationDecl>(InstRecord)){
5125 if (FD->getFriendObjectKind() && FD->getDeclContext()->isFileContext()){
5126 DC = FD->getLexicalDeclContext();
5132 if (Guide && Guide->isImplicit()) {
5140 Unpacked = Arg.pack_elements();
5143 getTrivialTemplateArgumentLoc(UnpackedArg,
QualType(), Loc));
5149 assert(SubstRecord &&
"class template id not a class type?");
5155 if (FindingInstantiatedContext &&
5156 usesPartialOrExplicitSpecialization(
5157 Loc, cast<ClassTemplateSpecializationDecl>(SubstRecord))) {
5158 Diag(Loc, diag::err_specialization_not_primary_template)
5159 << T << (SubstRecord->getTemplateSpecializationKind() ==
5178 ParentDC = FindInstantiatedContext(Loc, ParentDC, TemplateArgs);
5189 bool IsBeingInstantiated =
false;
5190 if (
CXXRecordDecl *Spec = dyn_cast<CXXRecordDecl>(ParentDC)) {
5191 if (!Spec->isDependentContext()) {
5194 assert(Tag &&
"type of non-dependent record is not a RecordType");
5196 IsBeingInstantiated =
true;
5198 RequireCompleteType(Loc, T, diag::err_incomplete_type))
5210 Name = SubstDeclarationNameInfo(NameInfo, TemplateArgs).getName();
5230 if (isa<UsingShadowDecl>(D)) {
5232 }
else if (Diags.hasErrorOccurred()) {
5236 }
else if (IsBeingInstantiated) {
5242 Diag(Loc, diag::err_member_not_yet_instantiated)
5250 EnumDecl *Enum = cast<EnumDecl>(ED->getLexicalDeclContext());
5251 EnumDecl *Spec = cast<EnumDecl>(FindInstantiatedDecl(Loc, Enum,
5253 assert(Spec->getTemplateSpecializationKind() ==
5255 Diag(Loc, diag::err_enumerator_does_not_exist)
5258 Diag(Spec->getLocation(), diag::note_enum_specialized_here)
5262 llvm_unreachable(
"Unable to find instantiation of declaration!");
5275 while (!PendingLocalImplicitInstantiations.empty() ||
5276 (!LocalOnly && !PendingInstantiations.empty())) {
5279 if (PendingLocalImplicitInstantiations.empty()) {
5280 Inst = PendingInstantiations.front();
5281 PendingInstantiations.pop_front();
5283 Inst = PendingLocalImplicitInstantiations.front();
5284 PendingLocalImplicitInstantiations.pop_front();
5288 if (
FunctionDecl *Function = dyn_cast<FunctionDecl>(Inst.first)) {
5289 bool DefinitionRequired = Function->getTemplateSpecializationKind() ==
5291 if (Function->isMultiVersion()) {
5292 getASTContext().forEachMultiversionedFunctionVersion(
5293 Function, [
this, Inst, DefinitionRequired](
FunctionDecl *CurFD) {
5294 InstantiateFunctionDefinition( Inst.second, CurFD,
true,
5295 DefinitionRequired,
true);
5300 InstantiateFunctionDefinition( Inst.second, Function,
true,
5301 DefinitionRequired,
true);
5302 if (Function->isDefined())
5303 Function->setInstantiationIsPending(
false);
5309 VarDecl *Var = cast<VarDecl>(Inst.first);
5312 isa<VarTemplateSpecializationDecl>(Var)) &&
5313 "Not a static data member, nor a variable template" 5314 " specialization?");
5325 llvm_unreachable(
"Cannot instantitiate an undeclared specialization.");
5340 "instantiating variable definition");
5346 InstantiateVariableDefinition( Inst.second, Var,
true,
5347 DefinitionRequired,
true);
5353 for (
auto DD : Pattern->
ddiags()) {
5354 switch (DD->getKind()) {
5356 HandleDependentAccessCheck(*DD, TemplateArgs);
bool isPackExpansion() const
Whether this parameter pack is a pack expansion.
VarTemplateDecl * getDescribedVarTemplate() const
Retrieves the variable template that is described by this variable declaration.
The lookup results will be used for redeclaration of a name with external linkage; non-visible lookup...
Defines the clang::ASTContext interface.
FunctionDecl * getDefinition()
Get the definition for this declaration.
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 ...
static void collectUnexpandedParameterPacks(Sema &S, TemplateParameterList *Params, SmallVectorImpl< UnexpandedParameterPack > &Unexpanded)
The lookup results will be used for redeclaration of a name, if an entity by that name already exists...
void setImplicit(bool I=true)
Represents a function declaration or definition.
NamespaceDecl * getStdNamespace() const
static DiagnosticBuilder Diag(DiagnosticsEngine *Diags, const LangOptions &Features, FullSourceLoc TokLoc, const char *TokBegin, const char *TokRangeBegin, const char *TokRangeEnd, unsigned DiagID)
Produce a diagnostic highlighting some portion of a literal.
ExprResult PerformContextuallyConvertToBool(Expr *From)
PerformContextuallyConvertToBool - Perform a contextual conversion of the expression From to bool (C+...
no exception specification
virtual void HandleCXXStaticMemberVarInstantiation(VarDecl *D)
HandleCXXStaticMemberVarInstantiation - Tell the consumer that this.
bool TemplateParameterListsAreEqual(TemplateParameterList *New, TemplateParameterList *Old, bool Complain, TemplateParameterListEqualKind Kind, SourceLocation TemplateArgLoc=SourceLocation())
Determine whether the given template parameter lists are equivalent.
void InstantiateAttrsForDecl(const MultiLevelTemplateArgumentList &TemplateArgs, const Decl *Pattern, Decl *Inst, LateInstantiatedAttrVec *LateAttrs=nullptr, LocalInstantiationScope *OuterMostScope=nullptr)
A (possibly-)qualified type.
void ActOnOpenMPDeclareReductionCombinerStart(Scope *S, Decl *D)
Initialize declare reduction construct initializer.
const char * getDeclKindName() const
void InstantiatedLocal(const Decl *D, Decl *Inst)
void setTemplateKeywordLoc(SourceLocation Loc)
Sets the location of the template keyword.
Decl * VisitVarDecl(VarDecl *D, bool InstantiatingVarTemplate, ArrayRef< BindingDecl *> *Bindings=nullptr)
bool isOverloadedOperator() const
Whether this function declaration represents an C++ overloaded operator, e.g., "operator+".
ASTConsumer - This is an abstract interface that should be implemented by clients that read ASTs...
A stack-allocated class that identifies which local variable declaration instantiations are present i...
const TypeClass * getTypePtr() const
void InstantiateExceptionSpec(SourceLocation PointOfInstantiation, FunctionDecl *Function)
std::vector< std::unique_ptr< TemplateInstantiationCallback > > TemplateInstCallbacks
The template instantiation callbacks to trace or track instantiations (objects can be chained)...
SourceRange getSourceRange() const LLVM_READONLY
Retrieve the source range covering the entirety of this nested-name-specifier.
static TypeAliasTemplateDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation L, DeclarationName Name, TemplateParameterList *Params, NamedDecl *Decl)
Create a function template node.
FunctionDecl * findSpecialization(ArrayRef< TemplateArgument > Args, void *&InsertPos)
Return the specialization with the provided arguments if it exists, otherwise return the insertion po...
Ordinary name lookup, which finds ordinary names (functions, variables, typedefs, etc...
SourceRange getBraceRange() const
bool willHaveBody() const
True if this function will eventually have a body, once it's fully parsed.
static void instantiateDependentAllocAlignAttr(Sema &S, const MultiLevelTemplateArgumentList &TemplateArgs, const AllocAlignAttr *Align, Decl *New)
InClassInitStyle getInClassInitStyle() const
Get the kind of (C++11) default member initializer that this field has.
NestedNameSpecifierLoc getTemplateQualifierLoc() const
void addOuterTemplateArguments(const TemplateArgumentList *TemplateArgs)
Add a new outermost level to the multi-level template argument list.
Expr * getUnderlyingExpr() const
static IndirectFieldDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation L, IdentifierInfo *Id, QualType T, llvm::MutableArrayRef< NamedDecl *> CH)
Stmt - This represents one statement.
Expr * getBitWidth() const
We are matching the template parameter lists of two templates that might be redeclarations.
void setPreviousDecl(decl_type *PrevDecl)
Set the previous declaration.
const ASTTemplateArgumentListInfo * getTemplateSpecializationArgsAsWritten() const
Retrieve the template argument list as written in the sources, if any.
Provides information about an attempted template argument deduction, whose success or failure was des...
ClassTemplateSpecializationDecl * findSpecialization(ArrayRef< TemplateArgument > Args, void *&InsertPos)
Return the specialization with the provided arguments if it exists, otherwise return the insertion po...
static bool isDeclWithinFunction(const Decl *D)
VarDecl * getTemplatedDecl() const
Get the underlying variable declarations of the template.
void AddAlignedAttr(SourceRange AttrRange, Decl *D, Expr *E, unsigned SpellingListIndex, bool IsPackExpansion)
AddAlignedAttr - Adds an aligned attribute to a particular declaration.
bool isOutOfLine() const override
Determine whether this is or was instantiated from an out-of-line definition of a member function...
An instance of this object exists for each enum constant that is defined.
StorageClass getStorageClass() const
Returns the storage class as written in the source.
void setTypedefNameForAnonDecl(TypedefNameDecl *TDD)
Represents the declaration of a typedef-name via the 'typedef' type specifier.
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...
bool isConstexpr() const
Whether this is a (C++11) constexpr function or constexpr constructor.
void AddAllocAlignAttr(SourceRange AttrRange, Decl *D, Expr *ParamExpr, unsigned SpellingListIndex)
AddAllocAlignAttr - Adds an alloc_align attribute to a particular declaration.
VarTemplateSpecializationDecl * BuildVarTemplateInstantiation(VarTemplateDecl *VarTemplate, VarDecl *FromVar, const TemplateArgumentList &TemplateArgList, const TemplateArgumentListInfo &TemplateArgsInfo, SmallVectorImpl< TemplateArgument > &Converted, SourceLocation PointOfInstantiation, void *InsertPos, LateInstantiatedAttrVec *LateAttrs=nullptr, LocalInstantiationScope *StartingScope=nullptr)
unsigned getNumExpansionTypes() const
Retrieves the number of expansion types in an expanded parameter pack.
static TemplateTemplateParmDecl * Create(const ASTContext &C, DeclContext *DC, SourceLocation L, unsigned D, unsigned P, bool ParameterPack, IdentifierInfo *Id, TemplateParameterList *Params)
bool isSingleTagDecl() const
Asks if the result is a single tag decl.
NamedDecl * BuildUsingDeclaration(Scope *S, AccessSpecifier AS, SourceLocation UsingLoc, bool HasTypenameKeyword, SourceLocation TypenameLoc, CXXScopeSpec &SS, DeclarationNameInfo NameInfo, SourceLocation EllipsisLoc, const ParsedAttributesView &AttrList, bool IsInstantiation)
Builds a using declaration.
const Type * getTypeForDecl() const
SemaDiagnosticBuilder Diag(SourceLocation Loc, unsigned DiagID)
Emit a diagnostic.
Decl - This represents one declaration (or definition), e.g.
void setRangeEnd(SourceLocation E)
SourceLocation getBeginLoc() const LLVM_READONLY
static Expr * instantiateDependentFunctionAttrCondition(Sema &S, const MultiLevelTemplateArgumentList &TemplateArgs, const Attr *A, Expr *OldCond, const Decl *Tmpl, FunctionDecl *New)
IdentifierInfo * getGetterId() const
VarDecl * getDefinition(ASTContext &)
Get the real (not just tentative) definition for this declaration.
ThreadStorageClassSpecifier getTSCSpec() const
llvm::PointerUnion< Decl *, DeclArgumentPack * > * findInstantiationOf(const Decl *D)
Find the instantiation of the declaration D within the current instantiation scope.
Defines the C++ template declaration subclasses.
bool hasWrittenPrototype() const
Whether this function has a written prototype.
Decl * InstantiateTypedefNameDecl(TypedefNameDecl *D, bool IsTypeAlias)
SmallVector< CodeSynthesisContext, 16 > CodeSynthesisContexts
List of active code synthesis contexts.
Decl * getPreviousDecl()
Retrieve the previous declaration that declares the same entity as this declaration, or NULL if there is no previous declaration.
QualType getNonReferenceType() const
If Type is a reference type (e.g., const int&), returns the type that the reference refers to ("const...
FunctionDecl * InstantiateFunctionDeclaration(FunctionTemplateDecl *FTD, const TemplateArgumentList *Args, SourceLocation Loc)
Instantiate (or find existing instantiation of) a function template with a given set of template argu...
SourceLocation getColonLoc() const
The location of the colon following the access specifier.
bool isCXXForRangeDecl() const
Determine whether this variable is the for-range-declaration in a C++0x for-range statement...
bool isExpandedParameterPack() const
Whether this parameter is a template template parameter pack that has a known list of different templ...
std::deque< PendingImplicitInstantiation > PendingLocalImplicitInstantiations
The queue of implicit template instantiations that are required and must be performed within the curr...
Declaration of a variable template.
Represent a C++ namespace.
SourceLocation getEndLoc() const LLVM_READONLY
const TargetInfo & getTargetInfo() const
bool getNoReturnAttr() const
Determine whether this function type includes the GNU noreturn attribute.
A container of type source information.
TemplateParameterList * getTemplateParameters() const
Get the list of template parameters.
std::pair< ValueDecl *, SourceLocation > PendingImplicitInstantiation
An entity for which implicit template instantiation is required.
FieldDecl * getInstantiatedFromUnnamedFieldDecl(FieldDecl *Field)
TypeSourceInfo * getDefaultArgumentInfo() const
Retrieves the default argument's source information, if any.
bool isDefined(const FunctionDecl *&Definition) const
Returns true if the function has a definition that does not need to be instantiated.
void setTemplateArgsInfo(const TemplateArgumentListInfo &ArgsInfo)
void setInitStyle(InitializationStyle Style)
VarTemplatePartialSpecializationDecl * InstantiateVarTemplatePartialSpecialization(VarTemplateDecl *VarTemplate, VarTemplatePartialSpecializationDecl *PartialSpec)
Instantiate the declaration of a variable template partial specialization.
bool CheckTemplateArgumentList(TemplateDecl *Template, SourceLocation TemplateLoc, TemplateArgumentListInfo &TemplateArgs, bool PartialTemplateArgs, SmallVectorImpl< TemplateArgument > &Converted, bool UpdateArgsWithConversions=true)
Check that the given template arguments can be be provided to the given template, converting the argu...
Represents a C++ constructor within a class.
LLVM_ATTRIBUTE_REINITIALIZES void clear()
Clears out any current state.
TemplateName SubstTemplateName(NestedNameSpecifierLoc QualifierLoc, TemplateName Name, SourceLocation Loc, const MultiLevelTemplateArgumentList &TemplateArgs)
bool CheckCXXDefaultArgExpr(SourceLocation CallLoc, FunctionDecl *FD, ParmVarDecl *Param)
Instantiate or parse a C++ default argument expression as necessary.
bool isVirtualAsWritten() const
Whether this function is marked as virtual explicitly.
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.
static void instantiateDependentEnableIfAttr(Sema &S, const MultiLevelTemplateArgumentList &TemplateArgs, const EnableIfAttr *EIA, const Decl *Tmpl, FunctionDecl *New)
SourceLocation getTargetNameLoc() const
Returns the location of the identifier in the named namespace.
bool isCompleteDefinition() const
Return true if this decl has its body fully specified.
bool defaultArgumentWasInherited() const
Determines whether the default argument was inherited from a previous declaration of this template...
void AddModeAttr(SourceRange AttrRange, Decl *D, IdentifierInfo *Name, unsigned SpellingListIndex, bool InInstantiation=false)
AddModeAttr - Adds a mode attribute to a particular declaration.
TemplateParameterList * getTemplateParameters() const
Get the list of template parameters.
bool isDefaultConstructor() const
Whether this constructor is a default constructor (C++ [class.ctor]p5), which can be used to default-...
NamedDecl * BuildUsingPackDecl(NamedDecl *InstantiatedFrom, ArrayRef< NamedDecl *> Expansions)
bool isPackExpansion() const
Whether this parameter pack is a pack expansion.
void Adopt(NestedNameSpecifierLoc Other)
Adopt an existing nested-name-specifier (with source-range information).
void setRAngleLoc(SourceLocation Loc)
unsigned getDepth() const
Get the nesting depth of the template parameter.
enumerator_range enumerators() const
FriendDecl - Represents the declaration of a friend entity, which can be a function, a type, or a templated function or type.
void InstantiatedLocalPackArg(const Decl *D, ParmVarDecl *Inst)
TemplateParameterList * getExpansionTemplateParameters(unsigned I) const
Retrieve a particular expansion type within an expanded parameter pack.
RAII object that enters a new expression evaluation context.
Represents a variable declaration or definition.
static CXXConversionDecl * Create(ASTContext &C, CXXRecordDecl *RD, SourceLocation StartLoc, const DeclarationNameInfo &NameInfo, QualType T, TypeSourceInfo *TInfo, bool isInline, bool isExplicit, bool isConstexpr, SourceLocation EndLocation)
QualType getReturnType() const
bool SubstQualifier(const DeclaratorDecl *OldDecl, DeclaratorDecl *NewDecl)
bool isFixed() const
Returns true if this is an Objective-C, C++11, or Microsoft-style enumeration with a fixed underlying...
static void instantiateDependentAlignedAttr(Sema &S, const MultiLevelTemplateArgumentList &TemplateArgs, const AlignedAttr *Aligned, Decl *New, bool IsPackExpansion)
const T * getAs() const
Member-template getAs<specific type>'.
void setClassScopeSpecializationPattern(FunctionDecl *FD, FunctionDecl *Pattern)
bool hasDefaultArgument() const
Determine whether this template parameter has a default argument.
DeclContext * computeDeclContext(QualType T)
Compute the DeclContext that is associated with the given type.
SourceLocation getExternLoc() const
Gets the location of the extern keyword, if present.
Extra information about a function prototype.
Declaration context for names declared as extern "C" in C++.
static MSPropertyDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation L, DeclarationName N, QualType T, TypeSourceInfo *TInfo, SourceLocation StartL, IdentifierInfo *Getter, IdentifierInfo *Setter)
Represents a variable template specialization, which refers to a variable template with a given set o...
RAII object used to temporarily allow the C++ 'this' expression to be used, with the given qualifiers...
Represents an explicit template argument list in C++, e.g., the "<int>" in "sort<int>".
static void instantiateDependentCUDALaunchBoundsAttr(Sema &S, const MultiLevelTemplateArgumentList &TemplateArgs, const CUDALaunchBoundsAttr &Attr, Decl *New)
bool isInvalidDecl() const
Stores a list of template parameters for a TemplateDecl and its derived classes.
A context in which code is being synthesized (where a source location alone is not sufficient to iden...
static void instantiateDependentAssumeAlignedAttr(Sema &S, const MultiLevelTemplateArgumentList &TemplateArgs, const AssumeAlignedAttr *Aligned, Decl *New)
Look up an ordinary name that is going to be redeclared as a name with linkage.
Represents a parameter to a function.
static AccessSpecDecl * Create(ASTContext &C, AccessSpecifier AS, DeclContext *DC, SourceLocation ASLoc, SourceLocation ColonLoc)
Defines the clang::Expr interface and subclasses for C++ expressions.
Provides information about a dependent function-template specialization declaration.
Represents the builtin template declaration which is used to implement __make_integer_seq and other b...
The collection of all-type qualifiers we support.
const FunctionDecl * isLocalClass() const
If the class is a local class [class.local], returns the enclosing function declaration.
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.
void MarkDeclarationsReferencedInType(SourceLocation Loc, QualType T)
Mark all of the declarations referenced within a particular AST node as referenced.
IdentifierInfo * getIdentifier() const
Get the identifier that names this declaration, if there is one.
bool isLexicallyWithinFunctionOrMethod() const
Returns true if this declaration lexically is inside a function.
Base wrapper for a particular "section" of type source info.
AccessResult CheckFriendAccess(NamedDecl *D)
Checks access to the target of a friend declaration.
Represents a struct/union/class.
bool CheckUsingDeclQualifier(SourceLocation UsingLoc, bool HasTypename, const CXXScopeSpec &SS, const DeclarationNameInfo &NameInfo, SourceLocation NameLoc)
Checks that the given nested-name qualifier used in a using decl in the current context is appropriat...
llvm::PointerUnion< VarTemplateDecl *, VarTemplatePartialSpecializationDecl * > getSpecializedTemplateOrPartial() const
Retrieve the variable template or variable template partial specialization which was specialized by t...
DeclarationName getDeclName() const
Get the actual, stored name of the declaration, which may be a special name.
TypeSourceInfo * getIntegerTypeSourceInfo() const
Return the type source info for the underlying integer type, if no type source info exists...
FunctionType::ExtInfo ExtInfo
Represents a class template specialization, which refers to a class template with a given set of temp...
TargetCXXABI getCXXABI() const
Get the C++ ABI currently in use.
LocalInstantiationScope * CurrentInstantiationScope
The current instantiation scope used to store local variables.
TypeSourceInfo * getFriendType() const
If this friend declaration names an (untemplated but possibly dependent) type, return the type; other...
unsigned getDepth() const
Retrieve the depth of the template parameter.
StringLiteral * getMessage()
bool isStr(const char(&Str)[StrLen]) const
Return true if this is the identifier for the specified string.
void setManglingNumber(const NamedDecl *ND, unsigned Number)
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
A C++ nested-name-specifier augmented with source location information.
NestedNameSpecifierLoc SubstNestedNameSpecifierLoc(NestedNameSpecifierLoc NNS, const MultiLevelTemplateArgumentList &TemplateArgs)
TemplateSpecializationKind getSpecializationKind() const
Determine the kind of specialization that this declaration represents.
ArrayRef< QualType > getParamTypes() const
The results of name lookup within a DeclContext.
NamespaceDecl * getNamespace()
Retrieve the namespace declaration aliased by this directive.
void setInstantiatedFromUnnamedFieldDecl(FieldDecl *Inst, FieldDecl *Tmpl)
bool CheckEnumUnderlyingType(TypeSourceInfo *TI)
Check that this is a valid underlying type for an enum declaration.
static bool anyDependentTemplateArguments(ArrayRef< TemplateArgumentLoc > Args, bool &InstantiationDependent)
Determine whether any of the given template arguments are dependent.
void setObjCForDecl(bool FRD)
NameKind getNameKind() const
Determine what kind of name this is.
VarTemplatePartialSpecializationDecl * findPartialSpecialization(ArrayRef< TemplateArgument > Args, void *&InsertPos)
Return the partial specialization with the provided arguments if it exists, otherwise return the inse...
static DecompositionDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation StartLoc, SourceLocation LSquareLoc, QualType T, TypeSourceInfo *TInfo, StorageClass S, ArrayRef< BindingDecl *> Bindings)
bool hasSkippedBody() const
True if the function was a definition but its body was skipped.
Represents a member of a struct/union/class.
The current expression is potentially evaluated at run time, which means that code may be generated t...
DeclGroupPtrTy ConvertDeclToDeclGroup(Decl *Ptr, Decl *OwnedType=nullptr)
unsigned getStaticLocalNumber(const VarDecl *VD) const
Decl * VisitVarTemplateSpecializationDecl(VarTemplateDecl *VarTemplate, VarDecl *FromVar, void *InsertPos, const TemplateArgumentListInfo &TemplateArgsInfo, ArrayRef< TemplateArgument > Converted)
void setVisibleDespiteOwningModule()
Set that this declaration is globally visible, even if it came from a module that is not visible...
void setInstantiatedFromUsingDecl(NamedDecl *Inst, NamedDecl *Pattern)
Remember that the using decl Inst is an instantiation of the using decl Pattern of a class template...
void startDefinition()
Starts the definition of this tag declaration.
static TemplateArgumentList * CreateCopy(ASTContext &Context, ArrayRef< TemplateArgument > Args)
Create a new template argument list that copies the given set of template arguments.
void setName(DeclarationName N)
setName - Sets the embedded declaration name.
bool isReferenceType() const
InitKind getInitializerKind() const
Get initializer kind.
NamedDecl * getFriendDecl() const
If this friend declaration doesn't name a type, return the inner declaration.
virtual SourceRange getSourceRange() const LLVM_READONLY
Source range that this declaration covers.
void setStaticLocalNumber(const VarDecl *VD, unsigned Number)
bool isInIdentifierNamespace(unsigned NS) const
unsigned getPosition() const
Get the position of the template parameter within its parameter list.
ParmVarDecl * getParam(unsigned i) const
bool Equals(const DeclContext *DC) const
Determine whether this declaration context is equivalent to the declaration context DC...
static CXXDeductionGuideDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation StartLoc, bool IsExplicit, const DeclarationNameInfo &NameInfo, QualType T, TypeSourceInfo *TInfo, SourceLocation EndLocation)
void Exit()
Exit this local instantiation scope early.
bool CheckParameterPacksForExpansion(SourceLocation EllipsisLoc, SourceRange PatternRange, ArrayRef< UnexpandedParameterPack > Unexpanded, const MultiLevelTemplateArgumentList &TemplateArgs, bool &ShouldExpand, bool &RetainExpansion, Optional< unsigned > &NumExpansions)
Determine whether we could expand a pack expansion with the given set of parameter packs into separat...
Represents an access specifier followed by colon ':'.
DeclarationNameInfo SubstDeclarationNameInfo(const DeclarationNameInfo &NameInfo, const MultiLevelTemplateArgumentList &TemplateArgs)
Do template substitution on declaration name info.
SourceLocation getBeginLoc() const LLVM_READONLY
Declaration of a function specialization at template class scope.
bool isPreviousDeclInSameBlockScope() const
Whether this local extern variable declaration's previous declaration was declared in the same block ...
static bool adjustContextForLocalExternDecl(DeclContext *&DC)
Adjust the DeclContext for a function or variable that might be a function-local external declaration...
TypeSourceInfo * getTemplateSpecializationTypeInfo(TemplateName T, SourceLocation TLoc, const TemplateArgumentListInfo &Args, QualType Canon=QualType()) const
ArrayRef< ParmVarDecl * > parameters() const
SourceLocation getPointOfInstantiation() const
If this variable is an instantiation of a variable template or a static data member of a class templa...
void InstantiateMemInitializers(CXXConstructorDecl *New, const CXXConstructorDecl *Tmpl, const MultiLevelTemplateArgumentList &TemplateArgs)
TypeAliasDecl * getTemplatedDecl() const
Get the underlying function declaration of the template.
SourceLocation getLAngleLoc() const
Represents a C++ using-declaration.
FunctionTemplateDecl * getCanonicalDecl() override
Retrieves the canonical declaration of this template.
ArrayRef< BindingDecl * > bindings() const
static void instantiateDependentDiagnoseIfAttr(Sema &S, const MultiLevelTemplateArgumentList &TemplateArgs, const DiagnoseIfAttr *DIA, const Decl *Tmpl, FunctionDecl *New)
Expr * getInitializer()
Get initializer expression (if specified) of the declare reduction construct.
Represents the results of name lookup.
Stmt * getBody(const FunctionDecl *&Definition) const
Retrieve the body (definition) of the function.
TagKind getTagKind() const
bool isReferenced() const
Whether any declaration of this entity was referenced.
A convenient class for passing around template argument information.
const TemplateArgumentList & getTemplateArgs() const
Retrieve the template arguments of the variable template specialization.
Look up all declarations in a scope with the given name, including resolved using declarations...
bool CheckUsingShadowDecl(UsingDecl *UD, 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...
FunctionTemplateDecl * getDescribedFunctionTemplate() const
Retrieves the function template that is described by this function declaration.
bool isMemberSpecialization() const
Determines whether this template was a specialization of a member template.
ArrayRef< NamedDecl * > chain() const
bool InitFunctionInstantiation(FunctionDecl *New, FunctionDecl *Tmpl)
Initializes the common fields of an instantiation function declaration (New) from the corresponding f...
SourceLocation getBeginLoc() const LLVM_READONLY
bool containsUnexpandedParameterPack() const
Whether this type is or contains an unexpanded parameter pack, used to support C++0x variadic templat...
TemplateSpecializationKind getTemplateSpecializationKind() const
If this variable is an instantiation of a variable template or a static data member of a class templa...
static TemplateTypeParmDecl * Create(const ASTContext &C, DeclContext *DC, SourceLocation KeyLoc, SourceLocation NameLoc, unsigned D, unsigned P, IdentifierInfo *Id, bool Typename, bool ParameterPack)
void PerformPendingInstantiations(bool LocalOnly=false)
Performs template instantiation for all implicit template instantiations we have seen until this poin...
SourceLocation RAngleLoc
The source location of the right angle bracket ('>').
NestedNameSpecifierLoc getQualifierLoc() const
Retrieve the nested-name-specifier (with source-location information) that qualifies the name of this...
SourceLocation getDefaultArgumentLoc() const
Retrieves the location of the default argument declaration.
void setInstantiatedFromMember(ClassTemplatePartialSpecializationDecl *PartialSpec)
bool isConstexpr() const
Whether this variable is (C++11) constexpr.
const TemplateArgumentLoc * getArgumentArray() const
VarTemplateDecl * getSpecializedTemplate() const
Retrieve the template that this specialization specializes.
void setSpecializationKind(TemplateSpecializationKind TSK)
Scope - A scope is a transient data structure that is used while parsing the program.
CXXRecordDecl * getCanonicalDecl() override
Retrieves the "canonical" declaration of the given declaration.
bool declaresSameEntity(const Decl *D1, const Decl *D2)
Determine whether two declarations declare the same entity.
bool hasNameForLinkage() const
Is this tag type named, either directly or via being defined in a typedef of this type...
Represents a C++ nested-name-specifier or a global scope specifier.
bool hasDefaultArgument() const
Determine whether this template parameter has a default argument.
DeclContext * getLexicalDeclContext()
getLexicalDeclContext - The declaration context where this Decl was lexically declared (LexicalDC)...
bool isIncompatibleTypedef(TypeDecl *Old, TypedefNameDecl *New)
static VarDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, IdentifierInfo *Id, QualType T, TypeSourceInfo *TInfo, StorageClass S)
const LangOptions & getLangOpts() const
static NamespaceAliasDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation NamespaceLoc, SourceLocation AliasLoc, IdentifierInfo *Alias, NestedNameSpecifierLoc QualifierLoc, SourceLocation IdentLoc, NamedDecl *Namespace)
TemplateArgumentLoc getArgLoc(unsigned i) 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'.
void AdjustDestructorExceptionSpec(CXXDestructorDecl *Destructor)
Build an exception spec for destructors that don't have one.
bool isTypeDependent() const
isTypeDependent - Determines whether this expression is type-dependent (C++ [temp.dep.expr]), which means that its type could change from one template instantiation to the next.
FunctionDecl * getInstantiatedFromMemberFunction() const
If this function is an instantiation of a member function of a class template specialization, retrieves the function from which it was instantiated.
static FunctionTemplateDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation L, DeclarationName Name, TemplateParameterList *Params, NamedDecl *Decl)
Create a function template node.
void addDecl(NamedDecl *D)
Add a declaration to these results with its natural access.
SourceLocation getTypeSpecStartLoc() const
CXXRecordDecl * getTemplatedDecl() const
Get the underlying class declarations of the template.
void CheckStaticLocalForDllExport(VarDecl *VD)
Check if VD needs to be dllexport/dllimport due to being in a dllexport/import function.
bool isParameterPack() const
Whether this template template parameter is a template parameter pack.
FunctionDecl * SourceDecl
The function whose exception specification this is, for EST_Unevaluated and EST_Uninstantiated.
unsigned getNumArgs() const
A binding in a decomposition declaration.
MemberSpecializationInfo * getMemberSpecializationInfo() const
If this function is an instantiation of a member function of a class template specialization, retrieves the member specialization information.
The current context is "potentially evaluated" in C++11 terms, but the expression is evaluated at com...
static FunctionDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation StartLoc, SourceLocation NLoc, DeclarationName N, QualType T, TypeSourceInfo *TInfo, StorageClass SC, bool isInlineSpecified=false, bool hasWrittenPrototype=true, bool isConstexprSpecified=false)
RAII object used to change the argument pack substitution index within a Sema object.
bool isAnonymousStructOrUnion() const
Whether this is an anonymous struct or union.
UsingShadowDecl * BuildUsingShadowDecl(Scope *S, UsingDecl *UD, NamedDecl *Target, UsingShadowDecl *PrevDecl)
Builds a shadow declaration corresponding to a 'using' declaration.
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.
A helper class for building up ExtParameterInfos.
VarDecl * ActOnOpenMPDeclareReductionInitializerStart(Scope *S, Decl *D)
Initialize declare reduction construct initializer.
lookup_result lookup(DeclarationName Name) const
lookup - Find the declarations (if any) with the given Name in this context.
SourceLocation getRParenLoc() const
bool isExpandedParameterPack() const
Whether this parameter is a non-type template parameter pack that has a known list of different types...
DiagnosticsEngine & getDiagnostics() const
void BuildVariableInstantiation(VarDecl *NewVar, VarDecl *OldVar, const MultiLevelTemplateArgumentList &TemplateArgs, LateInstantiatedAttrVec *LateAttrs, DeclContext *Owner, LocalInstantiationScope *StartingScope, bool InstantiatingVarTemplate=false)
BuildVariableInstantiation - Used after a new variable has been created.
void MakeInstantiatedLocalArgPack(const Decl *D)
TypeSourceInfo * SubstFunctionDeclType(TypeSourceInfo *T, const MultiLevelTemplateArgumentList &TemplateArgs, SourceLocation Loc, DeclarationName Entity, CXXRecordDecl *ThisContext, Qualifiers ThisTypeQuals)
A form of SubstType intended specifically for instantiating the type of a FunctionDecl.
Sema - This implements semantic analysis and AST building for C.
Represents the declaration of a typedef-name via a C++11 alias-declaration.
CXXRecordDecl * getAsCXXRecordDecl() const
Retrieves the CXXRecordDecl that this type refers to, either because the type is a RecordType or beca...
void AddSpecialization(VarTemplateSpecializationDecl *D, void *InsertPos)
Insert the specified specialization knowing that it is not already in.
Represents a prototype with parameter type info, e.g.
bool isUsableInConstantExpressions(ASTContext &C) const
Determine whether this variable's value can be used in a constant expression, according to the releva...
void setImplicitlyInline(bool I=true)
Flag that this function is implicitly inline.
SourceLocation getTypenameLoc() const
Returns the source location of the 'typename' keyword.
TemplateSpecializationKind getTemplateSpecializationKind() const
Determine whether this particular class is a specialization or instantiation of a class template or m...
bool inferObjCARCLifetime(ValueDecl *decl)
Represents a ValueDecl that came out of a declarator.
DeclarationNameTable DeclarationNames
bool CheckSpecializationInstantiationRedecl(SourceLocation NewLoc, TemplateSpecializationKind NewTSK, NamedDecl *PrevDecl, TemplateSpecializationKind PrevTSK, SourceLocation PrevPtOfInstantiation, bool &SuppressNew)
Diagnose cases where we have an explicit template specialization before/after an explicit template in...
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...
unsigned getNumSubstitutedLevels() const
Determine the number of substituted levels in this template argument list.
bool isParameterPack() const
Whether this parameter is a non-type template parameter pack.
FunctionDecl * getClassScopeSpecializationPattern() const
Retrieve the class scope template pattern that this function template specialization is instantiated ...
bool isInlineSpecified() const
Expr * getCombiner()
Get combiner expression of the declare reduction construct.
TypeSourceInfo * getTrivialTypeSourceInfo(QualType T, SourceLocation Loc=SourceLocation()) const
Allocate a TypeSourceInfo where all locations have been initialized to a given location, which defaults to the empty location.
TypeSourceInfo * getTypeSourceInfo() const
This represents '#pragma omp requires...' directive.
static CXXDestructorDecl * Create(ASTContext &C, CXXRecordDecl *RD, SourceLocation StartLoc, const DeclarationNameInfo &NameInfo, QualType T, TypeSourceInfo *TInfo, bool isInline, bool isImplicitlyDeclared)
const ArgList & getInnermost() const
Retrieve the innermost template argument list.
void CheckAlignasUnderalignment(Decl *D)
TemplateParameterList * getTemplateParameters() const
Get the list of template parameters.
TypeSourceInfo * CheckPackExpansion(TypeSourceInfo *Pattern, SourceLocation EllipsisLoc, Optional< unsigned > NumExpansions)
Construct a pack expansion type from the pattern of the pack expansion.
bool isInlineSpecified() const
Determine whether the "inline" keyword was specified for this function.
Represents a shadow constructor declaration introduced into a class by a C++11 using-declaration that...
This represents one expression.
NestedNameSpecifierLoc getQualifierLoc() const
Retrieve the nested-name-specifier that qualifies the name, with source-location information.
void setCompleteDefinition()
void setInstantiatedFromUsingShadowDecl(UsingShadowDecl *Inst, UsingShadowDecl *Pattern)
unsigned getChainingSize() const
SourceLocation getAliasLoc() const
Returns the location of the alias name, i.e.
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)
bool isDefaulted() const
Whether this function is defaulted per C++0x.
void addTypedefNameForUnnamedTagDecl(TagDecl *TD, TypedefNameDecl *TND)
bool isScopedUsingClassTag() const
Returns true if this is a C++11 scoped enumeration.
void InstantiateAttrs(const MultiLevelTemplateArgumentList &TemplateArgs, const Decl *Pattern, Decl *Inst, LateInstantiatedAttrVec *LateAttrs=nullptr, LocalInstantiationScope *OuterMostScope=nullptr)
bool isInSystemHeader(SourceLocation Loc) const
Returns if a SourceLocation is in a system header.
void ActOnOpenMPDeclareReductionCombinerEnd(Decl *D, Expr *Combiner)
Finish current declare reduction construct initializer.
Declaration of a template type parameter.
OMPThreadPrivateDecl * CheckOMPThreadPrivateDecl(SourceLocation Loc, ArrayRef< Expr *> VarList)
Builds a new OpenMPThreadPrivateDecl and checks its correctness.
ClassTemplatePartialSpecializationDecl * InstantiateClassTemplatePartialSpecialization(ClassTemplateDecl *ClassTemplate, ClassTemplatePartialSpecializationDecl *PartialSpec)
Instantiate the declaration of a class template partial specialization.
DeclarationNameInfo getNameInfo() const
unsigned NumTemplateArgs
The number of template arguments in TemplateArgs.
void setHideTags(bool Hide)
Sets whether tag declarations should be hidden by non-tag declarations during resolution.
void PerformDependentDiagnostics(const DeclContext *Pattern, const MultiLevelTemplateArgumentList &TemplateArgs)
OMPDeclareReductionDecl * getPrevDeclInScope()
Get reference to previous declare reduction construct in the same scope with the same name...
const T * castAs() const
Member-template castAs<specific type>.
bool isInvalid() const
Determines whether we have exceeded the maximum recursive template instantiations.
T getAs() const
Convert to the specified TypeLoc type, returning a null TypeLoc if this TypeLoc is not of the desired...
static DeclT * getPreviousDeclForInstantiation(DeclT *D)
Get the previous declaration of a declaration for the purposes of template instantiation.
Represents a C++ destructor within a class.
bool isThisDeclarationADefinition() const
Returns whether this specific declaration of the function is also a definition that does not contain ...
void setInvalidDecl(bool Invalid=true)
setInvalidDecl - Indicates the Decl had a semantic error.
bool isImplicit() const
isImplicit - Indicates whether the declaration was implicitly generated by the implementation.
bool CheckInheritingConstructorUsingDecl(UsingDecl *UD)
Additional checks for a using declaration referring to a constructor name.
ClassTemplateDecl * getSpecializedTemplate() const
Retrieve the template that this specialization specializes.
bool isLocalExternDecl()
Determine whether this is a block-scope declaration with linkage.
bool isFileContext() const
TemplateParameterList * getTemplateParameterList(unsigned index) const
ParmVarDecl * SubstParmVarDecl(ParmVarDecl *D, const MultiLevelTemplateArgumentList &TemplateArgs, int indexAdjustment, Optional< unsigned > NumExpansions, bool ExpectParameterPack)
DeclContext * getDeclContext()
CXXRecordDecl * getDefinition() const
UsingShadowDecl * getInstantiatedFromUsingShadowDecl(UsingShadowDecl *Inst)
SourceLocation getEllipsisLoc() const
An abstract interface that should be implemented by listeners that want to be notified when an AST en...
StorageClass getStorageClass() const
Returns the storage class as written in the source.
ArrayRef< TemplateArgument > asArray() const
Produce this as an array ref.
NonTypeTemplateParmDecl - Declares a non-type template parameter, e.g., "Size" in.
Represents a C++ template name within the type system.
Represents the type decltype(expr) (C++11).
EnumDecl * getDefinition() const
static void InstantiateDefaultCtorDefaultArgs(Sema &S, CXXConstructorDecl *Ctor)
In the MS ABI, we need to instantiate default arguments of dllexported default constructors along wit...
Defines the clang::TypeLoc interface and its subclasses.
DependentFunctionTemplateSpecializationInfo * getDependentSpecializationInfo() const
void DiscardCleanupsInEvaluationContext()
AutoType * getContainedAutoType() const
Get the AutoType whose type will be deduced for a variable with an initializer of this type...
void setConstexpr(bool IC)
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.
const ASTTemplateArgumentListInfo * getTemplateArgsAsWritten() const
Get the template arguments as written.
bool isFunctionOrMethod() const
bool CheckEnumRedeclaration(SourceLocation EnumLoc, bool IsScoped, QualType EnumUnderlyingTy, bool IsFixed, const EnumDecl *Prev)
Check whether this is a valid redeclaration of a previous enumeration.
StorageClass
Storage classes.
IdentifierInfo * getSetterId() const
Declaration of an alias template.
llvm::FoldingSetVector< ClassTemplatePartialSpecializationDecl > & getPartialSpecializations()
Retrieve the set of partial specializations of this class template.
DeclContext * getParent()
getParent - Returns the containing DeclContext.
Data structure that captures multiple levels of template argument lists for use in template instantia...
void SetDeclDeleted(Decl *dcl, SourceLocation DelLoc)
void setTypeAsWritten(TypeSourceInfo *T)
Sets the type of this specialization as it was written by the user.
QualType getRecordType(const RecordDecl *Decl) const
SourceLocation getEnd() const
unsigned getNumExpansionTemplateParameters() const
Retrieves the number of expansion template parameters in an expanded parameter pack.
QualType getFunctionType(QualType ResultTy, ArrayRef< QualType > Args, const FunctionProtoType::ExtProtoInfo &EPI) const
Return a normal function type with a typed argument list.
void setLocation(SourceLocation L)
TemplateTemplateParmDecl - Declares a template template parameter, e.g., "T" in.
void addDeclaratorForUnnamedTagDecl(TagDecl *TD, DeclaratorDecl *DD)
ClassTemplatePartialSpecializationDecl * getInstantiatedFromMember() const
Retrieve the member class template partial specialization from which this particular class template p...
bool isDependentContext() const
Determines whether this context is dependent on a template parameter.
Expr * getInitPriv()
Get Priv variable of the initializer.
NamedDecl * getInstantiatedFromUsingDecl(NamedDecl *Inst)
If the given using decl Inst is an instantiation of a (possibly unresolved) using decl from a templat...
Represents a C++ deduction guide declaration.
void setDescribedClassTemplate(ClassTemplateDecl *Template)
Represents a C++ conversion function within a class.
QualType getTypeDeclType(const TypeDecl *Decl, const TypeDecl *PrevDecl=nullptr) const
Return the unique reference to the type for the specified type declaration.
The result type of a method or function.
This template specialization was implicitly instantiated from a template.
bool isNull() const
Return true if this QualType doesn't point to a type yet.
InitializationStyle getInitStyle() const
The style of initialization for this declaration.
static StringRef getIdentifier(const Token &Tok)
void AddAlignValueAttr(SourceRange AttrRange, Decl *D, Expr *E, unsigned SpellingListIndex)
AddAlignValueAttr - Adds an align_value attribute to a particular declaration.
static void instantiateOMPDeclareSimdDeclAttr(Sema &S, const MultiLevelTemplateArgumentList &TemplateArgs, const OMPDeclareSimdDeclAttr &Attr, Decl *New)
Instantiation of 'declare simd' attribute and its arguments.
static void instantiateDependentModeAttr(Sema &S, const MultiLevelTemplateArgumentList &TemplateArgs, const ModeAttr &Attr, Decl *New)
DeclContext * FindInstantiatedContext(SourceLocation Loc, DeclContext *DC, const MultiLevelTemplateArgumentList &TemplateArgs)
Finds the instantiation of the given declaration context within the current instantiation.
TypeSourceInfo * SubstFunctionType(FunctionDecl *D, SmallVectorImpl< ParmVarDecl *> &Params)
VarDecl * getCanonicalDecl() override
Retrieves the "canonical" declaration of the given declaration.
NamedDecl * FindInstantiatedDecl(SourceLocation Loc, NamedDecl *D, const MultiLevelTemplateArgumentList &TemplateArgs, bool FindingInstantiatedContext=false)
Find the instantiation of the given declaration within the current instantiation. ...
bool isDirectInit() const
Whether the initializer is a direct-initializer (list or call).
static TemplateParameterList * Create(const ASTContext &C, SourceLocation TemplateLoc, SourceLocation LAngleLoc, ArrayRef< NamedDecl *> Params, SourceLocation RAngleLoc, Expr *RequiresClause)
PrettyDeclStackTraceEntry - If a crash occurs in the parser while parsing something related to a decl...
bool defaultArgumentWasInherited() const
Determines whether the default argument was inherited from a previous declaration of this template...
FriendObjectKind getFriendObjectKind() const
Determines whether this declaration is the object of a friend declaration and, if so...
decl_type * getFirstDecl()
Return the first declaration of this declaration or itself if this is the only declaration.
static CXXRecordDecl * Create(const ASTContext &C, TagKind TK, DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, IdentifierInfo *Id, CXXRecordDecl *PrevDecl=nullptr, bool DelayTypeCreation=false)
Attr * instantiateTemplateAttribute(const Attr *At, ASTContext &C, Sema &S, const MultiLevelTemplateArgumentList &TemplateArgs)
ClassTemplateDecl * getInstantiatedFromMemberTemplate() const
EnumDecl * getInstantiatedFromMemberEnum() const
Returns the enumeration (declared within the template) from which this enumeration type was instantia...
RecordDecl * getDecl() const
TypeSourceInfo * getExpansionTypeSourceInfo(unsigned I) const
Retrieve a particular expansion type source info within an expanded parameter pack.
void CheckForFunctionRedefinition(FunctionDecl *FD, const FunctionDecl *EffectiveDefinition=nullptr, SkipBodyInfo *SkipBody=nullptr)
bool isInjectedClassName() const
Determines whether this declaration represents the injected class name.
void makeDeclVisibleInContext(NamedDecl *D)
Makes a declaration visible within this context.
TypeLoc getPatternLoc() const
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...
ActionResult - This structure is used while parsing/acting on expressions, stmts, etc...
ExceptionSpecificationType Type
The kind of exception specification this is.
TypeLoc IgnoreParens() const
decl_type * getPreviousDecl()
Return the previous declaration of this declaration or NULL if this is the first declaration.
A stack object to be created when performing template instantiation.
ExtProtoInfo getExtProtoInfo() const
Attr * instantiateTemplateAttributeForDecl(const Attr *At, ASTContext &C, Sema &S, const MultiLevelTemplateArgumentList &TemplateArgs)
static ClassTemplateSpecializationDecl * Create(ASTContext &Context, TagKind TK, DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, ClassTemplateDecl *SpecializedTemplate, ArrayRef< TemplateArgument > Args, ClassTemplateSpecializationDecl *PrevDecl)
bool Subst(const TemplateArgumentLoc *Args, unsigned NumArgs, TemplateArgumentListInfo &Result, const MultiLevelTemplateArgumentList &TemplateArgs)
ClassTemplatePartialSpecializationDecl * findPartialSpecInstantiatedFromMember(ClassTemplatePartialSpecializationDecl *D)
Find a class template partial specialization which was instantiated from the given member partial spe...
ASTContext & getASTContext() const
static FriendDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation L, FriendUnion Friend_, SourceLocation FriendL, ArrayRef< TemplateParameterList *> FriendTypeTPLists=None)
redecl_range redecls() const
Returns an iterator range for all the redeclarations of the same decl.
bool isParameterPack() const
Returns whether this is a parameter pack.
FunctionDecl * getTemplatedDecl() const
Get the underlying function declaration of the template.
Encodes a location in the source.
QualType getReturnType() const
bool isPure() const
Whether this virtual function is pure, i.e.
void atTemplateBegin(TemplateInstantiationCallbackPtrs &Callbacks, const Sema &TheSema, const Sema::CodeSynthesisContext &Inst)
bool CheckPureMethod(CXXMethodDecl *Method, SourceRange InitRange)
Mark the given method pure.
This represents '#pragma omp declare reduction ...' directive.
decl_iterator decls_begin() const
Pseudo declaration for capturing expressions.
static bool isInstantiationOfUnresolvedUsingDecl(T *Pattern, Decl *Other, ASTContext &Ctx)
Decl * BuildStaticAssertDeclaration(SourceLocation StaticAssertLoc, Expr *AssertExpr, StringLiteral *AssertMessageExpr, SourceLocation RParenLoc, bool Failed)
bool isVariablyModifiedType() const
Whether this type is a variably-modified type (C99 6.7.5).
Attr * clone(ASTContext &C) const
SourceLocation getNamespaceKeyLocation() const
Returns the location of the namespace keyword.
unsigned getManglingNumber(const NamedDecl *ND) const
void setExternLoc(SourceLocation Loc)
Sets the location of the extern keyword.
DeclarationName getName() const
getName - Returns the embedded declaration name.
bool wasDeclaredWithTypename() const
Whether this template type parameter was declared with the 'typename' keyword.
Represents the declaration of a struct/union/class/enum.
SourceLocation getUsingLoc() const
Return the source location of the 'using' keyword.
bool CheckFunctionTemplateSpecialization(FunctionDecl *FD, TemplateArgumentListInfo *ExplicitTemplateArgs, LookupResult &Previous, bool QualifiedFriend=false)
Perform semantic analysis for the given function template specialization.
const TemplateArgumentListInfo & templateArgs() const
TemplateParameterList * SubstTemplateParams(TemplateParameterList *List)
Instantiates a nested template parameter list in the current instantiation context.
void setReferenced(bool R=true)
Represents the declaration of a label.
Represents a dependent using declaration which was not marked with typename.
void setIsCopyDeductionCandidate(bool isCDC=true)
Represents a static or instance method of a struct/union/class.
TypedefNameDecl * getTypedefNameForUnnamedTagDecl(const TagDecl *TD)
SourceLocation getFriendLoc() const
Retrieves the location of the 'friend' keyword.
static bool isInstantiationOf(ClassTemplateDecl *Pattern, ClassTemplateDecl *Instance)
bool hasExceptionSpec() const
Return whether this function has any kind of exception spec.
EnumDecl * getCanonicalDecl() override
Retrieves the "canonical" declaration of the given declaration.
void SetDeclDefaulted(Decl *dcl, SourceLocation DefaultLoc)
Decl * VisitDecl(Decl *D)
SourceLocation getIdentLocation() const
Returns the location of this using declaration's identifier.
bool isMemberSpecialization()
Determines whether this variable template partial specialization was a specialization of a member par...
const ParmVarDecl * getParamDecl(unsigned i) const
static void instantiateDependentAlignValueAttr(Sema &S, const MultiLevelTemplateArgumentList &TemplateArgs, const AlignValueAttr *Aligned, Decl *New)
SourceLocation getLocation() const
NestedNameSpecifierLoc getQualifierLoc() const
Retrieve the nested-name-specifier that qualifies the name of the namespace, with source-location inf...
QualType getInjectedClassNameSpecialization()
Retrieve the template specialization type of the injected-class-name for this class template...
bool isScoped() const
Returns true if this is a C++11 scoped enumeration.
void setDeclName(DeclarationName N)
Set the name of this declaration.
bool isValueDependent() const
isValueDependent - Determines whether this expression is value-dependent (C++ [temp.dep.constexpr]).
const TemplateArgumentListInfo & getTemplateArgsInfo() const
bool hasDefaultArgument() const
Determine whether this template parameter has a default argument.
FunctionTemplateDecl * getPreviousDecl()
Retrieve the previous declaration of this function template, or nullptr if no such declaration exists...
ClassTemplateDecl * getMostRecentDecl()
void InstantiateEnumDefinition(EnumDecl *Enum, EnumDecl *Pattern)
bool isFromASTFile() const
Determine whether this declaration came from an AST file (such as a precompiled header or module) rat...
unsigned getCustomDiagID(Level L, const char(&FormatString)[N])
Return an ID for a diagnostic with the specified format string and level.
bool isUsed(bool CheckUsedAttr=true) const
Whether any (re-)declaration of the entity was used, meaning that a definition is required...
This template specialization was instantiated from a template due to an explicit instantiation defini...
This template specialization was formed from a template-id but has not yet been declared, defined, or instantiated.
FunctionTemplateDecl * getInstantiatedFromMemberTemplate() const
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.
SourceLocation getRAngleLoc() const
TypeSourceInfo * getTypeAsWritten() const
Gets the type of this specialization as it was written by the user, if it was so written.
bool isExplicitlyDefaulted() const
Whether this function is explicitly defaulted per C++0x.
DeclarationNameInfo getNameInfo() const
Represents a C++11 static_assert declaration.
void setInstantiatedFromMember(VarTemplatePartialSpecializationDecl *PartialSpec)
bool RequireCompleteDeclContext(CXXScopeSpec &SS, DeclContext *DC)
Require that the context specified by SS be complete.
Optional< unsigned > getNumExpansions() const
Retrieve the number of expansions that this pack expansion will generate, if known.
void setLAngleLoc(SourceLocation Loc)
SourceLocation getAccessSpecifierLoc() const
The location of the access specifier.
const TemplateArgumentList & getTemplateInstantiationArgs() const
Retrieve the set of template arguments that should be used to instantiate the initializer of the vari...
void addArgument(const TemplateArgumentLoc &Loc)
virtual bool isOutOfLine() const
Determine whether this declaration is declared out of line (outside its semantic context).
static ClassTemplateDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation L, DeclarationName Name, TemplateParameterList *Params, NamedDecl *Decl, Expr *AssociatedConstraints=nullptr)
Create a class template node.
bool isInstantiationDependentType() const
Determine whether this type is an instantiation-dependent type, meaning that the type involves a temp...
bool isTemplateTypeParmType() const
ExceptionSpecificationType getExceptionSpecType() const
Get the kind of exception specification on this function.
Expr * getInitOrig()
Get Orig variable of the initializer.
void setVirtualAsWritten(bool V)
State that this function is marked as virtual explicitly.
Represents a pack expansion of types.
static TypeAliasDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, IdentifierInfo *Id, TypeSourceInfo *TInfo)
NestedNameSpecifierLoc getQualifierLoc() const
Retrieve the nested-name-specifier (with source-location information) that qualifies the name of this...
const TemplateArgumentLoc * getTemplateArgs() const
Retrieve the template arguments.
ddiag_range ddiags() const
void AddAssumeAlignedAttr(SourceRange AttrRange, Decl *D, Expr *E, Expr *OE, unsigned SpellingListIndex)
AddAssumeAlignedAttr - Adds an assume_aligned attribute to a particular declaration.
void setTemplateSpecializationKind(TemplateSpecializationKind TSK, SourceLocation PointOfInstantiation=SourceLocation())
For a static data member that was instantiated from a static data member of a class template...
Base class for declarations which introduce a typedef-name.
Represents a template argument.
QualType getTemplateSpecializationType(TemplateName T, ArrayRef< TemplateArgument > Args, QualType Canon=QualType()) const
void collectUnexpandedParameterPacks(TemplateArgument Arg, SmallVectorImpl< UnexpandedParameterPack > &Unexpanded)
Collect the set of unexpanded parameter packs within the given template argument. ...
SourceLocation getTemplateKeywordLoc() const
Gets the location of the template keyword, if present.
static bool isInvalid(LocType Loc, bool *Invalid)
NamespaceDecl * getNominatedNamespace()
Returns the namespace nominated by this using-directive.
bool isNull() const
Determine whether this template name is NULL.
static bool addInstantiatedParametersToScope(Sema &S, FunctionDecl *Function, const FunctionDecl *PatternDecl, LocalInstantiationScope &Scope, const MultiLevelTemplateArgumentList &TemplateArgs)
Introduce the instantiated function parameters into the local instantiation scope, and set the parameter names to those used in the template.
Dataflow Directional Tag Classes.
int ArgumentPackSubstitutionIndex
The current index into pack expansion arguments that will be used for substitution of parameter packs...
ExtInfo getExtInfo() const
Decl * VisitFunctionDecl(FunctionDecl *D, TemplateParameterList *TemplateParams)
Normal class members are of more specific types and therefore don't make it here. ...
ParmVarDecl * BuildParmVarDeclForTypedef(DeclContext *DC, SourceLocation Loc, QualType T)
Synthesizes a variable for a parameter arising from a typedef.
const TemplateArgument & getArgument() const
not evaluated yet, for special member function
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 isLateTemplateParsed() const
Whether this templated function will be late parsed.
LocalInstantiationScope * cloneScopes(LocalInstantiationScope *Outermost)
Clone this scope, and all outer scopes, down to the given outermost scope.
DeclContext - This is used only as base class of specific decl types that can act as declaration cont...
bool hasExplicitTemplateArgs() const
void InstantiateVariableInitializer(VarDecl *Var, VarDecl *OldVar, const MultiLevelTemplateArgumentList &TemplateArgs)
Instantiate the initializer of a variable.
The base class of all kinds of template declarations (e.g., class, function, etc.).
TemplateSpecializationKind getTemplateSpecializationKind() const
Determine what kind of template instantiation this function represents.
Represents a field injected from an anonymous union/struct into the parent scope. ...
QualType getUnderlyingType() const
NestedNameSpecifierLoc getQualifierLoc() const
Retrieve the nested-name-specifier that qualifies the name of the namespace, with source-location inf...
CanQualType UnsignedLongLongTy
DeclContext * getCommonAncestor()
Returns the common ancestor context of this using-directive and its nominated namespace.
const Expr * getInit() const
AccessSpecifier getAccess() const
static NamedDecl * findInstantiationOf(ASTContext &Ctx, NamedDecl *D, ForwardIterator first, ForwardIterator last)
A decomposition declaration.
This template specialization was instantiated from a template due to an explicit instantiation declar...
unsigned getIndex() const
Retrieve the index of the template parameter.
Represents a dependent using declaration which was marked with typename.
FunctionDecl * getTemplateInstantiationPattern() const
Retrieve the function declaration from which this function could be instantiated, if it is an instant...
static UsingDirectiveDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation UsingLoc, SourceLocation NamespaceLoc, NestedNameSpecifierLoc QualifierLoc, SourceLocation IdentLoc, NamedDecl *Nominated, DeclContext *CommonAncestor)
The name of a declaration.
void setInstantiationIsPending(bool IC)
State that the instantiation of this function is pending.
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.
const CXXRecordDecl * getParent() const
Returns the parent of this method declaration, which is the class in which this method is defined...
CXXRecordDecl * getInstantiatedFromMemberClass() const
If this record is an instantiation of a member class, retrieves the member class from which it was in...
unsigned getNumTemplateParameterLists() const
SourceLocation LAngleLoc
The source location of the left angle bracket ('<').
void setInlineSpecified()
TemplateSpecializationKind
Describes the kind of template specialization that a particular template specialization declaration r...
Expr * getDefaultArgument() const
Retrieve the default argument, if any.
DeclGroupPtrTy ActOnOpenMPDeclareReductionDirectiveEnd(Scope *S, DeclGroupPtrTy DeclReductions, bool IsValid)
Called at the end of '#pragma omp declare reduction'.
bool isInitCapture() const
Whether this variable is the implicit variable for a lambda init-capture.
bool defaultArgumentWasInherited() const
Determines whether the default argument was inherited from a previous declaration of this template...
DeclarationNameInfo - A collector data type for bundling together a DeclarationName and the correspnd...
void setPreviousDeclInSameBlockScope(bool Same)
static EnumDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, IdentifierInfo *Id, EnumDecl *PrevDecl, bool IsScoped, bool IsScopedUsingClassTag, bool IsFixed)
VarTemplateSpecializationDecl * findSpecialization(ArrayRef< TemplateArgument > Args, void *&InsertPos)
Return the specialization with the provided arguments if it exists, otherwise return the insertion po...
bool isUndeducedType() const
Determine whether this type is an undeduced type, meaning that it somehow involves a C++11 'auto' typ...
static LabelDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation IdentL, IdentifierInfo *II)
void setObjectOfFriendDecl(bool PerformFriendInjection=false)
Changes the namespace of this declaration to reflect that it's the object of a friend declaration...
void setInitCapture(bool IC)
void setLocalExternDecl()
Changes the namespace of this declaration to reflect that it's a function-local extern declaration...
SourceRange getSourceRange() const LLVM_READONLY
Get the full source range.
void setImplicitlyInline()
FunctionDecl * SourceTemplate
The function template whose exception specification this is instantiated from, for EST_Uninstantiated...
A helper class that allows the use of isa/cast/dyncast to detect TagType objects of structs/unions/cl...
Location wrapper for a TemplateArgument.
void setIsUsed()
Set whether the declaration is used, in the sense of odr-use.
Decl * Visit(PTR(Decl) D)
void setQualifierInfo(NestedNameSpecifierLoc QualifierLoc)
void setInstantiatedFromMemberTemplate(RedeclarableTemplateDecl *TD)
This template specialization was declared or defined by an explicit specialization (C++ [temp...
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...
void setNonMemberOperator()
Specifies that this declaration is a C++ overloaded non-member.
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 setQualifierInfo(NestedNameSpecifierLoc QualifierLoc)
void ActOnEnumBody(SourceLocation EnumLoc, SourceRange BraceRange, Decl *EnumDecl, ArrayRef< Decl *> Elements, Scope *S, const ParsedAttributesView &Attr)
EnumConstantDecl * CheckEnumConstant(EnumDecl *Enum, EnumConstantDecl *LastEnumConst, SourceLocation IdLoc, IdentifierInfo *Id, Expr *val)
bool isObjCForDecl() const
Determine whether this variable is a for-loop declaration for a for-in statement in Objective-C...
bool isFunctionType() const
void ActOnOpenMPDeclareReductionInitializerEnd(Decl *D, Expr *Initializer, VarDecl *OmpPrivParm)
Finish current declare reduction construct initializer.
void setInstantiationOfStaticDataMember(VarDecl *VD, TemplateSpecializationKind TSK)
Specify that this variable is an instantiation of the static data member VD.
static bool SubstQualifier(Sema &SemaRef, const DeclT *OldDecl, DeclT *NewDecl, const MultiLevelTemplateArgumentList &TemplateArgs)
TypeSourceInfo * getTypeSourceInfo() const
DeclaratorDecl * getDeclaratorForUnnamedTagDecl(const TagDecl *TD)
ClassTemplateDecl * getCanonicalDecl() override
Retrieves the canonical declaration of this template.
QualType ActOnOpenMPDeclareReductionType(SourceLocation TyLoc, TypeResult ParsedType)
Check if the specified type is allowed to be used in 'omp declare reduction' construct.
static CXXMethodDecl * Create(ASTContext &C, CXXRecordDecl *RD, SourceLocation StartLoc, const DeclarationNameInfo &NameInfo, QualType T, TypeSourceInfo *TInfo, StorageClass SC, bool isInline, bool isConstexpr, SourceLocation EndLocation)
void setCXXForRangeDecl(bool FRD)
ExceptionSpecificationType
The various types of exception specifications that exist in C++11.
void addDecl(Decl *D)
Add the declaration D into this context.
void setInstantiationOfMemberClass(CXXRecordDecl *RD, TemplateSpecializationKind TSK)
Specify that this record is an instantiation of the member class RD.
void SubstExceptionSpec(FunctionDecl *New, const FunctionProtoType *Proto, const MultiLevelTemplateArgumentList &Args)
The template argument is actually a parameter pack.
bool isBeingDefined() const
Determines whether this type is in the process of being defined.
const TemplateArgumentLoc & getDefaultArgument() const
Retrieve the default argument, if any.
bool hasTypename() const
Return true if the using declaration has 'typename'.
void setInnerLocStart(SourceLocation L)
static BindingDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation IdLoc, IdentifierInfo *Id)
bool isInlined() const
Determine whether this function should be inlined, because it is either marked "inline" or "constexpr...
bool LookupQualifiedName(LookupResult &R, DeclContext *LookupCtx, bool InUnqualifiedLookup=false)
Perform qualified name lookup into a given context.
RedeclarationKind forRedeclarationInCurContext()
void CheckTemplatePartialSpecialization(ClassTemplatePartialSpecializationDecl *Partial)
CanQualType getCanonicalType(QualType T) const
Return the canonical (structural) type corresponding to the specified potentially non-canonical type ...
bool isAlreadyInstantiating() const
Determine whether we are already instantiating this specialization in some surrounding active instant...
A template argument list.
TypeLoc getTypeLoc() const
Return the TypeLoc wrapper for the type source info.
ExprResult SubstExpr(Expr *E, const MultiLevelTemplateArgumentList &TemplateArgs)
shadow_range shadows() const
QualType getParamType(unsigned i) const
Call-style initialization (C++98)
Represents a field declaration created by an @defs(...).
QualType CheckNonTypeTemplateParameterType(TypeSourceInfo *&TSI, SourceLocation Loc)
Check that the type of a non-type template parameter is well-formed.
void CheckOverrideControl(NamedDecl *D)
CheckOverrideControl - Check C++11 override control semantics.
void AddSpecialization(ClassTemplateSpecializationDecl *D, void *InsertPos)
Insert the specified specialization knowing that it is not already in.
TypedefNameDecl * getTypedefNameForAnonDecl() const
bool CheckFunctionDeclaration(Scope *S, FunctionDecl *NewFD, LookupResult &Previous, bool IsMemberSpecialization)
Perform semantic checking of a new function declaration.
bool isMutable() const
Determines whether this field is mutable (C++ only).
bool isThisDeclarationADefinition() const
Return true if this declaration is a completion definition of the type.
Represents a C++ struct/union/class.
VarDecl * getInstantiatedFromStaticDataMember() const
If this variable is an instantiated static data member of a class template specialization, returns the templated static data member from which it was instantiated.
void setTSCSpec(ThreadStorageClassSpecifier TSC)
bool isNRVOVariable() const
Determine whether this local variable can be used with the named return value optimization (NRVO)...
void setDescribedVarTemplate(VarTemplateDecl *Template)
bool isOutOfLine() const override
Determine whether this is or was instantiated from an out-of-line definition of a static data member...
VarTemplateSpecializationDecl * CompleteVarTemplateSpecializationDecl(VarTemplateSpecializationDecl *VarSpec, VarDecl *PatternDecl, const MultiLevelTemplateArgumentList &TemplateArgs)
Instantiates a variable template specialization by completing it with appropriate type information an...
void addHiddenDecl(Decl *D)
Add the declaration D to this context without modifying any lookup tables.
static TypedefDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, IdentifierInfo *Id, TypeSourceInfo *TInfo)
Provides information a specialization of a member of a class template, which may be a member function...
ClassTemplatePartialSpecializationDecl * findPartialSpecialization(ArrayRef< TemplateArgument > Args, void *&InsertPos)
Return the partial specialization with the provided arguments if it exists, otherwise return the inse...
void atTemplateEnd(TemplateInstantiationCallbackPtrs &Callbacks, const Sema &TheSema, const Sema::CodeSynthesisContext &Inst)
DeclContext * CurContext
CurContext - This is the current declaration context of parsing.
void setUnsupportedFriend(bool Unsupported)
static UsingDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation UsingL, NestedNameSpecifierLoc QualifierLoc, const DeclarationNameInfo &NameInfo, bool HasTypenameKeyword)
static VarTemplateDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation L, DeclarationName Name, TemplateParameterList *Params, VarDecl *Decl)
Create a variable template node.
Declaration of a class template.
CXXMethodDecl * getSpecialization() const
SourceManager & getSourceManager() const
QualType getInjectedClassNameType(CXXRecordDecl *Decl, QualType TST) const
getInjectedClassNameType - Return the unique reference to the injected class name type for the specif...
static bool isInstantiationOfStaticDataMember(VarDecl *Pattern, VarDecl *Instance)
bool isMicrosoft() const
Is this ABI an MSVC-compatible ABI?
VarTemplateDecl * getInstantiatedFromMemberTemplate() const
SourceRange getSourceRange() const override LLVM_READONLY
Source range that this declaration covers.
QualType getIntegerType() const
Return the integer type this enum decl corresponds to.
void setDescribedFunctionTemplate(FunctionTemplateDecl *Template)
Decl * SubstDecl(Decl *D, DeclContext *Owner, const MultiLevelTemplateArgumentList &TemplateArgs)
SourceLocation getLAngleLoc() const
FriendDecl * CheckFriendTypeDecl(SourceLocation LocStart, SourceLocation FriendLoc, TypeSourceInfo *TSInfo)
Perform semantic analysis of the given friend type declaration.
Expr * getCombinerIn()
Get In variable of the combiner.
static Sema::RetainOwnershipKind attrToRetainOwnershipKind(const Attr *A)
static OpaquePtr make(QualType P)
decl_type * getMostRecentDecl()
Returns the most recent (re)declaration of this declaration.
The top declaration context.
bool isDependentType() const
Whether this type is a dependent type, meaning that its definition somehow depends on a template para...
Optional< unsigned > getNumArgumentsInExpansion(QualType T, const MultiLevelTemplateArgumentList &TemplateArgs)
Determine the number of arguments in the given pack expansion type.
bool isDeleted() const
Whether this function has been deleted.
SourceLocation getTemplateNameLoc() const
bool isCopyElisionCandidate(QualType ReturnType, const VarDecl *VD, CopyElisionSemanticsKind CESK)
DefinitionKind isThisDeclarationADefinition(ASTContext &) const
Check whether this declaration is a definition.
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.
bool isStaticDataMember() const
Determines whether this is a static data member.
An instance of this class represents the declaration of a property member.
SourceLocation getNamespaceLoc() const
Returns the location of the namespace keyword.
static bool isPotentialConstantExprUnevaluated(Expr *E, const FunctionDecl *FD, SmallVectorImpl< PartialDiagnosticAt > &Diags)
isPotentialConstantExprUnevaluted - Return true if this expression might be usable in a constant expr...
TemplateParameterList * SubstTemplateParams(TemplateParameterList *Params, DeclContext *Owner, const MultiLevelTemplateArgumentList &TemplateArgs)
bool empty() const
Return true if no decls were found.
void AddLaunchBoundsAttr(SourceRange AttrRange, Decl *D, Expr *MaxThreads, Expr *MinBlocks, unsigned SpellingListIndex)
AddLaunchBoundsAttr - Adds a launch_bounds attribute to a particular declaration. ...
A trivial tuple used to represent a source range.
static VarTemplateSpecializationDecl * Create(ASTContext &Context, DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, VarTemplateDecl *SpecializedTemplate, QualType T, TypeSourceInfo *TInfo, StorageClass S, ArrayRef< TemplateArgument > Args)
void setLexicalDeclContext(DeclContext *DC)
FunctionDecl * getCanonicalDecl() override
Retrieves the "canonical" declaration of the given declaration.
This represents a decl that may have a name.
FunctionDecl * getExceptionSpecTemplate() const
If this function type has an uninstantiated exception specification, this is the function whose excep...
T castAs() const
Convert to the specified TypeLoc type, asserting that this TypeLoc is of the desired type...
void setAccess(AccessSpecifier AS)
Represents a C++ namespace alias.
bool isInline() const
Whether this variable is (C++1z) inline.
TemplateName getAsTemplate() const
Retrieve the template name for a template name argument.
Declaration of a friend template.
VarTemplatePartialSpecializationDecl * getInstantiatedFromMember() const
Retrieve the member variable template partial specialization from which this particular variable temp...
ArrayRef< NamedDecl * > expansions() const
Get the set of using declarations that this pack expanded into.
Represents C++ using-directive.
Represents a #pragma detect_mismatch line.
void setTypeAsWritten(TypeSourceInfo *T)
Sets the type of this specialization as it was written by the user.
SourceLocation getRAngleLoc() const
SourceLocation getPointOfInstantiation() const
Get the point of instantiation (if any), or null if none.
attr::Kind getKind() const
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...
Expr * getCombinerOut()
Get Out variable of the combiner.
unsigned getNumParams() const
Return the number of parameters this function must have based on its FunctionType.
void setType(QualType newType)
static CXXConstructorDecl * Create(ASTContext &C, CXXRecordDecl *RD, SourceLocation StartLoc, const DeclarationNameInfo &NameInfo, QualType T, TypeSourceInfo *TInfo, bool isExplicit, bool isInline, bool isImplicitlyDeclared, bool isConstexpr, InheritedConstructor Inherited=InheritedConstructor())
const ASTTemplateArgumentListInfo * getTemplateArgsAsWritten() const
Get the template arguments as written.
SourceRange getSourceRange() const LLVM_READONLY
SourceLocation getInnerLocStart() const
Return start of source range ignoring outer template declarations.
bool InitMethodInstantiation(CXXMethodDecl *New, CXXMethodDecl *Tmpl)
Initializes common fields of an instantiated method declaration (New) from the corresponding fields o...
bool isParameterPack() const
Determine whether this parameter is actually a function parameter pack.
void setDeletedAsWritten(bool D=true)
Decl * VisitCXXMethodDecl(CXXMethodDecl *D, TemplateParameterList *TemplateParams, bool IsClassScopeSpecialization=false)
This represents '#pragma omp threadprivate ...' directive.
bool isUnsupportedFriend() const
Determines if this friend kind is unsupported.
ExceptionSpecInfo ExceptionSpec
Declaration of a template function.
bool hasLinkage() const
Determine whether this declaration has linkage.
Attr - This represents one attribute.
bool isDeletedAsWritten() const
SourceLocation getLocation() const
Represents a shadow declaration introduced into a scope by a (resolved) using declaration.
Represents a pack of using declarations that a single using-declarator pack-expanded into...
QualType getType() const
Return the type wrapped by this type source info.
llvm::FoldingSetVector< VarTemplatePartialSpecializationDecl > & getPartialSpecializations()
Retrieve the set of partial specializations of this class template.
decl_iterator decls_end() const
bool isCXXInstanceMember() const
Determine whether the given declaration is an instance member of a C++ class.
void DiagnoseUnusedNestedTypedefs(const RecordDecl *D)